hda.c 948 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Experimental Intel High-Definition Audio "driver"
  3. */
  4. #include <kernel/module.h>
  5. #include <kernel/printf.h>
  6. #include <kernel/pci.h>
  7. #include <kernel/mod/shell.h>
  8. struct hda_device {
  9. uint32_t pci_device;
  10. };
  11. static struct hda_device _device;
  12. static void find_hda(uint32_t device, uint16_t vendorid, uint16_t deviceid, void * extra) {
  13. struct hda_device * hda = extra;
  14. if ((vendorid == 0x8086) && (deviceid == 0x2668)) {
  15. hda->pci_device = device;
  16. }
  17. }
  18. DEFINE_SHELL_FUNCTION(hda_test, "[debug] Intel HDA experiments") {
  19. if (!_device.pci_device) {
  20. fprintf(tty, "No HDA device found.\n");
  21. return 1;
  22. }
  23. fprintf(tty, "HDA audio device is at 0x%x.\n", _device.pci_device);
  24. return 0;
  25. }
  26. static int init(void) {
  27. BIND_SHELL_FUNCTION(hda_test);
  28. pci_scan(&find_hda, -1, &_device);
  29. if (!_device.pci_device) {
  30. return 1;
  31. }
  32. return 0;
  33. }
  34. static int fini(void) {
  35. return 0;
  36. }
  37. MODULE_DEF(hda, init, fini);
  38. MODULE_DEPENDS(debugshell);