2018-03-16 15:56:19 +03:00
|
|
|
/*
|
|
|
|
* Experimental Intel High-Definition Audio "driver"
|
|
|
|
*/
|
|
|
|
|
2018-03-19 05:38:11 +03:00
|
|
|
#include <kernel/module.h>
|
|
|
|
#include <kernel/printf.h>
|
|
|
|
#include <kernel/pci.h>
|
|
|
|
#include <kernel/mod/shell.h>
|
2018-03-16 15:56:19 +03:00
|
|
|
|
|
|
|
struct hda_device {
|
|
|
|
uint32_t pci_device;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct hda_device _device;
|
|
|
|
|
|
|
|
static void find_hda(uint32_t device, uint16_t vendorid, uint16_t deviceid, void * extra) {
|
|
|
|
|
|
|
|
struct hda_device * hda = extra;
|
|
|
|
|
|
|
|
if ((vendorid == 0x8086) && (deviceid == 0x2668)) {
|
|
|
|
hda->pci_device = device;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_SHELL_FUNCTION(hda_test, "[debug] Intel HDA experiments") {
|
|
|
|
|
|
|
|
if (!_device.pci_device) {
|
|
|
|
fprintf(tty, "No HDA device found.\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
fprintf(tty, "HDA audio device is at 0x%x.\n", _device.pci_device);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int init(void) {
|
|
|
|
BIND_SHELL_FUNCTION(hda_test);
|
|
|
|
pci_scan(&find_hda, -1, &_device);
|
|
|
|
if (!_device.pci_device) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fini(void) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
MODULE_DEF(hda, init, fini);
|
|
|
|
MODULE_DEPENDS(debugshell);
|