ReactOS 0.4.16-dev-2293-g4d8327b
fdo.cpp File Reference
#include "driver.h"
#include "nhlt.h"
#include "sof-tplg.h"
Include dependency graph for fdo.cpp:

Go to the source code of this file.

Macros

#define HDAC_MAX_CAPS   10
 
#define ENABLE_HDA   1
 

Functions

void CheckHDAGraphicsRegistryKeys (PFDO_CONTEXT fdoCtx)
 
NTSTATUS NTAPI HDAGraphicsPowerInterfaceCallback (PVOID NotificationStruct, PVOID Context)
 
NTSTATUS NTAPI Fdo_Initialize (_In_ PFDO_CONTEXT FdoCtx)
 
NTSTATUS NTAPI Fdo_Create (_Inout_ PWDFDEVICE_INIT DeviceInit)
 
NTSTATUS NTAPI Fdo_EvtDevicePrepareHardware (_In_ WDFDEVICE Device, _In_ WDFCMRESLIST ResourcesRaw, _In_ WDFCMRESLIST ResourcesTranslated)
 
NTSTATUS NTAPI Fdo_EvtDeviceReleaseHardware (_In_ WDFDEVICE Device, _In_ WDFCMRESLIST ResourcesTranslated)
 
NTSTATUS NTAPI Fdo_EvtDeviceD0Entry (_In_ WDFDEVICE Device, _In_ WDF_POWER_DEVICE_STATE PreviousState)
 
NTSTATUS NTAPI Fdo_EvtDeviceD0EntryPostInterrupts (_In_ WDFDEVICE Device, _In_ WDF_POWER_DEVICE_STATE PreviousState)
 
NTSTATUS NTAPI Fdo_EvtDeviceD0Exit (_In_ WDFDEVICE Device, _In_ WDF_POWER_DEVICE_STATE TargetState)
 
void NTAPI Fdo_EnumerateCodec (PFDO_CONTEXT fdoCtx, UINT8 addr)
 
NTSTATUS NTAPI Fdo_EvtDeviceSelfManagedIoInit (_In_ WDFDEVICE Device)
 

Variables

EVT_WDF_DEVICE_PREPARE_HARDWARE Fdo_EvtDevicePrepareHardware
 
EVT_WDF_DEVICE_RELEASE_HARDWARE Fdo_EvtDeviceReleaseHardware
 
EVT_WDF_DEVICE_D0_ENTRY Fdo_EvtDeviceD0Entry
 
EVT_WDF_DEVICE_D0_ENTRY_POST_INTERRUPTS_ENABLED Fdo_EvtDeviceD0EntryPostInterrupts
 
EVT_WDF_DEVICE_D0_EXIT Fdo_EvtDeviceD0Exit
 
EVT_WDF_DEVICE_SELF_MANAGED_IO_INIT Fdo_EvtDeviceSelfManagedIoInit
 

Macro Definition Documentation

◆ ENABLE_HDA

#define ENABLE_HDA   1

Definition at line 553 of file fdo.cpp.

◆ HDAC_MAX_CAPS

#define HDAC_MAX_CAPS   10

Function Documentation

◆ CheckHDAGraphicsRegistryKeys()

void CheckHDAGraphicsRegistryKeys ( PFDO_CONTEXT  fdoCtx)

Definition at line 313 of file sgpc.cpp.

313 {
315 WDFKEY driverKey;
316 status = WdfDeviceOpenRegistryKey(fdoCtx->WdfDevice, PLUGPLAY_REGKEY_DRIVER, READ_CONTROL, NULL, &driverKey);
317 if (!NT_SUCCESS(status)) {
318 return;
319 }
320
321 WDFKEY settingsKey;
322 DECLARE_CONST_UNICODE_STRING(DriverSettings, L"Settings");
323 DECLARE_CONST_UNICODE_STRING(GfxSharedCodecAddress, L"GfxSharedCodecAddress");
324 status = WdfRegistryOpenKey(driverKey, &DriverSettings, READ_CONTROL, NULL, &settingsKey);
325 if (!NT_SUCCESS(status)) {
326 goto closeDriverKey;
327 }
328
329 ULONG GfxCodecAddr;
330 status = WdfRegistryQueryULong(settingsKey, &GfxSharedCodecAddress, &GfxCodecAddr);
331 if (NT_SUCCESS(status)) {
332 fdoCtx->UseSGPCCodec = TRUE;
333 fdoCtx->GraphicsCodecAddress = GfxCodecAddr;
334 }
335
336 WdfRegistryClose(settingsKey);
337
338closeDriverKey:
339 WdfRegistryClose(driverKey);
340}
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define L(x)
Definition: resources.c:13
#define READ_CONTROL
Definition: nt_native.h:58
WDFDEVICE WdfDevice
Definition: fdo.h:115
ULONG GraphicsCodecAddress
Definition: fdo.h:130
BOOLEAN UseSGPCCodec
Definition: fdo.h:131
Definition: ps.c:97
uint32_t ULONG
Definition: typedefs.h:59
#define PLUGPLAY_REGKEY_DRIVER
Definition: usbd.c:42
#define DECLARE_CONST_UNICODE_STRING(_variablename, _string)
Definition: wdfcore.h:161

Referenced by Fdo_Create().

◆ Fdo_Create()

NTSTATUS NTAPI Fdo_Create ( _Inout_ PWDFDEVICE_INIT  DeviceInit)

Definition at line 29 of file fdo.cpp.

32{
34 WDF_OBJECT_ATTRIBUTES attributes;
35 WDF_PNPPOWER_EVENT_CALLBACKS pnpPowerCallbacks;
36 PFDO_CONTEXT fdoCtx;
37 WDFDEVICE wdfDevice;
39
40 SklHdAudBusPrint(DEBUG_LEVEL_INFO, DBG_INIT,
41 "%s\n", __func__);
42
43 WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&pnpPowerCallbacks);
46 pnpPowerCallbacks.EvtDeviceD0Entry = Fdo_EvtDeviceD0Entry;
48 pnpPowerCallbacks.EvtDeviceD0Exit = Fdo_EvtDeviceD0Exit;
50 WdfDeviceInitSetPnpPowerEventCallbacks(DeviceInit, &pnpPowerCallbacks);
51
52 //
53 // WDF_ DEVICE_LIST_CONFIG describes how the framework should handle
54 // dynamic child enumeration on behalf of the driver writer.
55 // Since we are a bus driver, we need to specify identification description
56 // for our child devices. This description will serve as the identity of our
57 // child device. Since the description is opaque to the framework, we
58 // have to provide bunch of callbacks to compare, copy, or free
59 // any other resources associated with the description.
60 //
63 Bus_EvtDeviceListCreatePdo // callback to create a child device.
64 );
65
66 //
67 // This function pointer will be called when the framework needs to copy a
68 // identification description from one location to another. An implementation
69 // of this function is only necessary if the description contains description
70 // relative pointer values (like LIST_ENTRY for instance) .
71 // If set to NULL, the framework will use RtlCopyMemory to copy an identification .
72 // description. In this sample, it's not required to provide these callbacks.
73 // they are added just for illustration.
74 //
75 config.EvtChildListIdentificationDescriptionDuplicate =
77
78 //
79 // This function pointer will be called when the framework needs to compare
80 // two identificaiton descriptions. If left NULL a call to RtlCompareMemory
81 // will be used to compare two identificaiton descriptions.
82 //
83 config.EvtChildListIdentificationDescriptionCompare =
85 //
86 // This function pointer will be called when the framework needs to free a
87 // identification description. An implementation of this function is only
88 // necessary if the description contains dynamically allocated memory
89 // (by the driver writer) that needs to be freed. The actual identification
90 // description pointer itself will be freed by the framework.
91 //
92 config.EvtChildListIdentificationDescriptionCleanup =
94
95 //
96 // Tell the framework to use the built-in childlist to track the state
97 // of the device based on the configuration we just created.
98 //
99 WdfFdoInitSetDefaultChildListConfig(DeviceInit,
100 &config,
102
104 status = WdfDeviceCreate(&DeviceInit, &attributes, &wdfDevice);
105 if (!NT_SUCCESS(status)) {
106 SklHdAudBusPrint(DEBUG_LEVEL_ERROR, DBG_INIT,
107 "WdfDriverCreate failed %x\n", status);
108 goto Exit;
109 }
110
111 /*{
112 WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS IdleSettings;
113
114 WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS_INIT(&IdleSettings, IdleCannotWakeFromS0);
115 IdleSettings.IdleTimeoutType = SystemManagedIdleTimeoutWithHint;
116 IdleSettings.IdleTimeout = 1000;
117 IdleSettings.UserControlOfIdleSettings = IdleDoNotAllowUserControl;
118
119 WdfDeviceAssignS0IdleSettings(wdfDevice, &IdleSettings);
120 }*/
121
122 {
123 WDF_DEVICE_STATE deviceState;
124 WDF_DEVICE_STATE_INIT(&deviceState);
125
126 deviceState.NotDisableable = WdfFalse;
127 WdfDeviceSetDeviceState(wdfDevice, &deviceState);
128 }
129
130 fdoCtx = Fdo_GetContext(wdfDevice);
131 fdoCtx->WdfDevice = wdfDevice;
132
133 status = Fdo_Initialize(fdoCtx);
134 if (!NT_SUCCESS(status))
135 {
136 goto Exit;
137 }
138
140
141Exit:
142 return status;
143}
BOOLEAN NTAPI Bus_EvtChildListIdentificationDescriptionCompare(WDFCHILDLIST DeviceList, PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER FirstIdentificationDescription, PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER SecondIdentificationDescription)
Definition: buspdo.cpp:60
VOID NTAPI Bus_EvtChildListIdentificationDescriptionCleanup(_In_ WDFCHILDLIST DeviceList, _Inout_ PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER IdentificationDescription)
Definition: buspdo.cpp:100
NTSTATUS NTAPI Bus_EvtDeviceListCreatePdo(WDFCHILDLIST DeviceList, PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER IdentificationDescription, PWDFDEVICE_INIT ChildInit)
Definition: buspdo.cpp:121
NTSTATUS NTAPI Bus_EvtChildListIdentificationDescriptionDuplicate(WDFCHILDLIST DeviceList, PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER SourceIdentificationDescription, PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER DestinationIdentificationDescription)
Definition: buspdo.cpp:13
struct config_s config
#define SklHdAudBusPrint(dbglevel, fmt,...)
Definition: driver.h:111
NTSTATUS NTAPI Fdo_Initialize(_In_ PFDO_CONTEXT FdoCtx)
Definition: fdo.cpp:147
EVT_WDF_DEVICE_RELEASE_HARDWARE Fdo_EvtDeviceReleaseHardware
Definition: fdo.cpp:6
EVT_WDF_DEVICE_SELF_MANAGED_IO_INIT Fdo_EvtDeviceSelfManagedIoInit
Definition: fdo.cpp:10
EVT_WDF_DEVICE_PREPARE_HARDWARE Fdo_EvtDevicePrepareHardware
Definition: fdo.cpp:5
void CheckHDAGraphicsRegistryKeys(PFDO_CONTEXT fdoCtx)
Definition: sgpc.cpp:313
EVT_WDF_DEVICE_D0_ENTRY Fdo_EvtDeviceD0Entry
Definition: fdo.cpp:7
EVT_WDF_DEVICE_D0_EXIT Fdo_EvtDeviceD0Exit
Definition: fdo.cpp:9
EVT_WDF_DEVICE_D0_ENTRY_POST_INTERRUPTS_ENABLED Fdo_EvtDeviceD0EntryPostInterrupts
Definition: fdo.cpp:8
static void Exit(void)
Definition: sock.c:1330
WDF_TRI_STATE NotDisableable
Definition: wdfdevice.h:1477
PFN_WDF_DEVICE_D0_ENTRY EvtDeviceD0Entry
Definition: wdfdevice.h:1164
PFN_WDF_DEVICE_SELF_MANAGED_IO_INIT EvtDeviceSelfManagedIoInit
Definition: wdfdevice.h:1172
PFN_WDF_DEVICE_D0_EXIT EvtDeviceD0Exit
Definition: wdfdevice.h:1166
PFN_WDF_DEVICE_PREPARE_HARDWARE EvtDevicePrepareHardware
Definition: wdfdevice.h:1168
PFN_WDF_DEVICE_D0_ENTRY_POST_INTERRUPTS_ENABLED EvtDeviceD0EntryPostInterruptsEnabled
Definition: wdfdevice.h:1165
PFN_WDF_DEVICE_RELEASE_HARDWARE EvtDeviceReleaseHardware
Definition: wdfdevice.h:1169
FORCEINLINE VOID WDF_CHILD_LIST_CONFIG_INIT(_Out_ PWDF_CHILD_LIST_CONFIG Config, _In_ ULONG IdentificationDescriptionSize, _In_ PFN_WDF_CHILD_LIST_CREATE_DEVICE EvtChildListCreateDevice)
Definition: wdfchildlist.h:415
_In_ PWDFDEVICE_INIT DeviceInit
Definition: wdfcontrol.h:113
FORCEINLINE VOID WDF_DEVICE_STATE_INIT(_Out_ PWDF_DEVICE_STATE PnpDeviceState)
Definition: wdfdevice.h:1496
FORCEINLINE VOID WDF_PNPPOWER_EVENT_CALLBACKS_INIT(_Out_ PWDF_PNPPOWER_EVENT_CALLBACKS Callbacks)
Definition: wdfdevice.h:1214
#define WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(_attributes, _contexttype)
Definition: wdfobject.h:170
@ WdfFalse
Definition: wdftypes.h:87
#define WDF_NO_OBJECT_ATTRIBUTES
Definition: wdftypes.h:105

Referenced by SklHdAudBusEvtDeviceAdd().

◆ Fdo_EnumerateCodec()

void NTAPI Fdo_EnumerateCodec ( PFDO_CONTEXT  fdoCtx,
UINT8  addr 
)

Definition at line 680 of file fdo.cpp.

684{
685 UINT32 cmdTmpl = (addr << 28) | (AC_NODE_ROOT << 20) |
686 (AC_VERB_PARAMETERS << 8);
687 ULONG funcType = 0, vendorDevice, subsysId, revId, nodeCount;
688 if (!NT_SUCCESS(RunSingleHDACmd(fdoCtx, cmdTmpl | AC_PAR_VENDOR_ID, &vendorDevice))) {
689 return;
690 }
691 if (!NT_SUCCESS(RunSingleHDACmd(fdoCtx, cmdTmpl | AC_PAR_REV_ID, &revId))) {
692 return;
693 }
694 if (!NT_SUCCESS(RunSingleHDACmd(fdoCtx, cmdTmpl | AC_PAR_NODE_COUNT, &nodeCount))) {
695 return;
696 }
697
698 fdoCtx->numCodecs += 1;
699
700 UINT8 startID = (nodeCount >> 16) & 0xFF;
701 nodeCount = (nodeCount & 0x7FFF);
702
703 UINT16 mainFuncGrp = 0;
704 {
705 UINT16 nid = startID;
706 for (UINT32 i = 0; i < nodeCount; i++, nid++) {
707 UINT32 cmd = (addr << 28) | (nid << 20) |
709 if (!NT_SUCCESS(RunSingleHDACmd(fdoCtx, cmd, &funcType))) {
710 continue;
711 }
712 switch (funcType & 0xFF) {
715 mainFuncGrp = nid;
716 break;
717 }
718 }
719 }
720
721 UINT32 cmd = (addr << 28) | (mainFuncGrp << 20) |
723 RunSingleHDACmd(fdoCtx, cmd, &subsysId);
724
726 //
727 // Initialize the description with the information about the detected codec.
728 //
730 &description.Header,
731 sizeof(description)
732 );
733
734 description.FdoContext = fdoCtx;
735
736 description.CodecIds.CtlrDevId = fdoCtx->devId;
737 description.CodecIds.CtlrVenId = fdoCtx->venId;
738
739 description.CodecIds.CodecAddress = addr;
740 if (fdoCtx->UseSGPCCodec && addr == fdoCtx->GraphicsCodecAddress)
741 description.CodecIds.IsGraphicsCodec = TRUE;
742 else
743 description.CodecIds.IsGraphicsCodec = FALSE;
744
745 description.CodecIds.FunctionGroupStartNode = startID;
746
747 description.CodecIds.IsDSP = FALSE;
748
749 description.CodecIds.FuncId = funcType & 0xFF;
750 description.CodecIds.VenId = (vendorDevice >> 16) & 0xFFFF;
751 description.CodecIds.DevId = vendorDevice & 0xFFFF;
752 description.CodecIds.SubsysId = subsysId;
753 description.CodecIds.RevId = (revId >> 8) & 0xFFFF;
754
755 //
756 // Call the framework to add this child to the childlist. This call
757 // will internaly call our DescriptionCompare callback to check
758 // whether this device is a new device or existing device. If
759 // it's a new device, the framework will call DescriptionDuplicate to create
760 // a copy of this description in nonpaged pool.
761 // The actual creation of the child device will happen when the framework
762 // receives QUERY_DEVICE_RELATION request from the PNP manager in
763 // response to InvalidateDeviceRelations call made as part of adding
764 // a new child.
765 //
766 WdfChildListAddOrUpdateChildDescriptionAsPresent(
767 WdfFdoGetDefaultChildList(fdoCtx->WdfDevice), &description.Header,
768 NULL); // AddressDescription
769}
unsigned short UINT16
Definition: actypes.h:129
unsigned char UINT8
Definition: actypes.h:128
#define FALSE
Definition: types.h:117
GLenum const GLvoid * addr
Definition: glext.h:9621
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define AC_NODE_ROOT
Definition: hda_verbs.h:4
#define AC_VERB_GET_SUBSYSTEM_ID
Definition: hda_verbs.h:45
#define AC_PAR_NODE_COUNT
Definition: hda_verbs.h:106
#define AC_PAR_VENDOR_ID
Definition: hda_verbs.h:103
#define AC_PAR_FUNCTION_TYPE
Definition: hda_verbs.h:107
#define AC_PAR_REV_ID
Definition: hda_verbs.h:105
@ AC_GRP_AUDIO_FUNCTION
Definition: hda_verbs.h:10
@ AC_GRP_MODEM_FUNCTION
Definition: hda_verbs.h:11
#define AC_VERB_PARAMETERS
Definition: hda_verbs.h:21
NTSTATUS RunSingleHDACmd(PFDO_CONTEXT fdoCtx, ULONG val, ULONG *res)
NOTIFYICONDATA nid
Definition: magnifier.c:44
USHORT numCodecs
Definition: fdo.h:161
UINT16 venId
Definition: fdo.h:117
UINT16 devId
Definition: fdo.h:118
Definition: ftp_var.h:139
uint32_t UINT32
Definition: typedefs.h:59
FORCEINLINE VOID WDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER_INIT(_Out_ PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER Header, _In_ ULONG IdentificationDescriptionSize)
Definition: wdfchildlist.h:83
const char * description
Definition: directx.c:2497

Referenced by EnumerateGraphicsCodec(), and Fdo_EvtDeviceSelfManagedIoInit().

◆ Fdo_EvtDeviceD0Entry()

NTSTATUS NTAPI Fdo_EvtDeviceD0Entry ( _In_ WDFDEVICE  Device,
_In_ WDF_POWER_DEVICE_STATE  PreviousState 
)

Definition at line 557 of file fdo.cpp.

561{
563
565 PFDO_CONTEXT fdoCtx;
566
567 fdoCtx = Fdo_GetContext(Device);
568
569 SklHdAudBusPrint(DEBUG_LEVEL_INFO, DBG_INIT,
570 "%s\n", __func__);
571
573
574 if (fdoCtx->venId == VEN_INTEL) {
575 UINT32 val;
577 val = val & ~INTEL_HDA_CGCTL_MISCBDCGE;
579 }
580 else if (fdoCtx->venId == VEN_AMD || fdoCtx->venId == VEN_ATI) {
582 }
583 else if (fdoCtx->venId == VEN_NVIDIA) {
587 }
588
589 //Reset CORB / RIRB
590 RtlZeroMemory(&fdoCtx->corb, sizeof(fdoCtx->corb));
591 RtlZeroMemory(&fdoCtx->rirb, sizeof(fdoCtx->rirb));
592 fdoCtx->processRirb = FALSE;
593
594 status = StartHDAController(fdoCtx);
595
596 if (fdoCtx->venId == VEN_INTEL) {
597 UINT32 val;
601
603 }
604
605 if (!NT_SUCCESS(status)) {
606 return status;
607 }
608
609 SklHdAudBusPrint(DEBUG_LEVEL_INFO, DBG_INIT,
610 "hda bus initialized\n");
611
612 return status;
613}
#define VEN_ATI
Definition: driver.h:47
#define VEN_NVIDIA
Definition: driver.h:49
#define VEN_INTEL
Definition: driver.h:46
#define VEN_AMD
Definition: driver.h:48
GLuint GLfloat * val
Definition: glext.h:7180
#define NVIDIA_HDA_OSTRM_COH
#define NVIDIA_HDA_ENABLE_COHBIT
#define NVIDIA_HDA_ISTRM_COH
#define INTEL_HDA_CGCTL_MISCBDCGE
#define ATI_SB450_HDAUDIO_ENABLE_SNOOP
#define ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR
#define HDA_VS_EM2_DUM
#define NVIDIA_HDA_TRANSREG_ADDR
#define INTEL_HDA_CGCTL
NTSTATUS StartHDAController(PFDO_CONTEXT fdoCtx)
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
static void pci_write_cfg_dword(PBUS_INTERFACE_STANDARD pciInterface, UINT reg, UINT32 data)
Definition: regfuncs.h:37
#define hda_update32(ctx, reg, mask, val)
Definition: regfuncs.h:61
static void pci_read_cfg_dword(PBUS_INTERFACE_STANDARD pciInterface, UINT reg, UINT32 *data)
Definition: regfuncs.h:29
static void update_pci_byte(PBUS_INTERFACE_STANDARD pciInterface, UINT reg, BYTE mask, BYTE val)
Definition: regfuncs.h:41
#define STATUS_SUCCESS
Definition: shellext.h:65
BOOL processRirb
Definition: fdo.h:165
HDAC_RB corb
Definition: fdo.h:163
BUS_INTERFACE_STANDARD BusInterface
Definition: fdo.h:123
HDAC_RB rirb
Definition: fdo.h:164
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_In_ WDF_POWER_DEVICE_STATE PreviousState
Definition: wdfdevice.h:829

◆ Fdo_EvtDeviceD0EntryPostInterrupts()

NTSTATUS NTAPI Fdo_EvtDeviceD0EntryPostInterrupts ( _In_ WDFDEVICE  Device,
_In_ WDF_POWER_DEVICE_STATE  PreviousState 
)

Definition at line 617 of file fdo.cpp.

621{
623
625 PFDO_CONTEXT fdoCtx;
626
628 fdoCtx = Fdo_GetContext(Device);
629
630#if ENABLE_HDA
631 for (UINT8 addr = 0; addr < HDA_MAX_CODECS; addr++) {
633 if (((fdoCtx->codecMask >> addr) & 0x1) == 0)
634 continue;
635
636 if (fdoCtx->UseSGPCCodec && fdoCtx->GraphicsCodecAddress == addr)
637 continue;
638
639 UINT32 cmdTmpl = (addr << 28) | (AC_NODE_ROOT << 20) |
640 (AC_VERB_PARAMETERS << 8);
641
642 ULONG vendorDevice;
643 if (!NT_SUCCESS(RunSingleHDACmd(fdoCtx, cmdTmpl | AC_PAR_VENDOR_ID, &vendorDevice))) { //Some codecs might need a kickstart
644 //First attempt failed. Retry
645 NTSTATUS status2 = RunSingleHDACmd(fdoCtx, cmdTmpl | AC_PAR_VENDOR_ID, &vendorDevice); //If this fails, something is wrong.
646 if (!NT_SUCCESS(status2)) {
647 SklHdAudBusPrint(DEBUG_LEVEL_ERROR, DBG_INIT, "Warning: Failed to wake up codec %d: 0x%x", addr, status2);
648 }
649 }
650 }
651#endif
652
653 return status;
654}
#define HDA_MAX_CODECS
Definition: driver.h:41
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
@ NotificationEvent
UINT16 codecMask
Definition: fdo.h:160
KEVENT xferEvent[HDA_MAX_CODECS]
Definition: fdo.h:96

◆ Fdo_EvtDeviceD0Exit()

NTSTATUS NTAPI Fdo_EvtDeviceD0Exit ( _In_ WDFDEVICE  Device,
_In_ WDF_POWER_DEVICE_STATE  TargetState 
)

Definition at line 658 of file fdo.cpp.

662{
664
666 PFDO_CONTEXT fdoCtx;
667
668 fdoCtx = Fdo_GetContext(Device);
669
670 status = StopHDAController(fdoCtx);
671
672 SklHdAudBusPrint(DEBUG_LEVEL_INFO, DBG_INIT,
673 "%s\n", __func__);
674
675 return status;
676}
NTSTATUS StopHDAController(PFDO_CONTEXT fdoCtx)
_In_ WDF_POWER_DEVICE_STATE TargetState
Definition: wdfdevice.h:859

◆ Fdo_EvtDevicePrepareHardware()

NTSTATUS NTAPI Fdo_EvtDevicePrepareHardware ( _In_ WDFDEVICE  Device,
_In_ WDFCMRESLIST  ResourcesRaw,
_In_ WDFCMRESLIST  ResourcesTranslated 
)

Definition at line 210 of file fdo.cpp.

215{
217
218 BOOLEAN fBar0Found = FALSE;
219 BOOLEAN fBar4Found = FALSE;
221 PFDO_CONTEXT fdoCtx;
222 ULONG resourceCount;
223
224 fdoCtx = Fdo_GetContext(Device);
225 resourceCount = WdfCmResourceListGetCount(ResourcesTranslated);
226
227 SklHdAudBusPrint(DEBUG_LEVEL_INFO, DBG_INIT,
228 "%s\n", __func__);
229
230 status = WdfFdoQueryForInterface(Device, &GUID_BUS_INTERFACE_STANDARD, (PINTERFACE)&fdoCtx->BusInterface, sizeof(BUS_INTERFACE_STANDARD), PCI_BUS_INTERFACE_STANDARD_VERSION, NULL);
231 if (!NT_SUCCESS(status)) {
232 return status;
233 }
234
235 for (ULONG i = 0; i < resourceCount; i++)
236 {
238
239 pDescriptor = WdfCmResourceListGetDescriptor(
241
242 switch (pDescriptor->Type)
243 {
245 //Look for BAR0 and BAR4
246 if (fBar0Found == FALSE) {
247 SklHdAudBusPrint(DEBUG_LEVEL_INFO, DBG_INIT,
248 "Found BAR0: 0x%llx (size 0x%lx)\n", pDescriptor->u.Memory.Start.QuadPart, pDescriptor->u.Memory.Length);
249
250 fdoCtx->m_BAR0.Base.Base = MmMapIoSpace(pDescriptor->u.Memory.Start, pDescriptor->u.Memory.Length, MmNonCached);
251 fdoCtx->m_BAR0.Len = pDescriptor->u.Memory.Length;
252
253 SklHdAudBusPrint(DEBUG_LEVEL_INFO, DBG_INIT,
254 "Mapped to %p\n", fdoCtx->m_BAR0.Base.baseptr);
255 fBar0Found = TRUE;
256 }
257 else if (fBar4Found == FALSE) {
258 SklHdAudBusPrint(DEBUG_LEVEL_INFO, DBG_INIT,
259 "Found BAR4: 0x%llx (size 0x%lx)\n", pDescriptor->u.Memory.Start.QuadPart, pDescriptor->u.Memory.Length);
260
261 //BAR4 is an optional ADSP memory mapping
262 fdoCtx->m_BAR4.Base.Base = MmMapIoSpace(pDescriptor->u.Memory.Start, pDescriptor->u.Memory.Length, MmNonCached);
263 fdoCtx->m_BAR4.Len = pDescriptor->u.Memory.Length;
264
265 SklHdAudBusPrint(DEBUG_LEVEL_INFO, DBG_INIT,
266 "Mapped to %p\n", fdoCtx->m_BAR4.Base.baseptr);
267 fBar4Found = TRUE;
268 }
269 break;
270 }
271 }
272
273 if (fdoCtx->m_BAR0.Base.Base == NULL) {
274 status = STATUS_NOT_FOUND; //BAR0 is required
275 return status;
276 }
277
281
282 //mlcap & lctl (hda_intel_init_chip)
283 if (fdoCtx->venId == VEN_INTEL) {
284 //read bus capabilities
285
286 unsigned int cur_cap;
287 unsigned int offset;
288 unsigned int counter = 0;
289
290 offset = hda_read16(fdoCtx, LLCH);
291
292#define HDAC_MAX_CAPS 10
293
294 /* Lets walk the linked capabilities list */
295 do {
296 cur_cap = read32(fdoCtx->m_BAR0.Base.baseptr + offset);
297
298 SklHdAudBusPrint(DEBUG_LEVEL_INFO, DBG_INIT,
299 "Capability version: 0x%x\n",
301
302 SklHdAudBusPrint(DEBUG_LEVEL_INFO, DBG_INIT,
303 "HDA capability ID: 0x%x\n",
305
306 if (cur_cap == (unsigned int)-1) {
307 SklHdAudBusPrint(DEBUG_LEVEL_INFO, DBG_INIT,
308 "Invalid capability reg read\n");
309 break;
310 }
311
312 switch ((cur_cap & HDA_CAP_HDR_ID_MASK) >> HDA_CAP_HDR_ID_OFF) {
313 case HDA_ML_CAP_ID:
314 SklHdAudBusPrint(DEBUG_LEVEL_INFO, DBG_INIT,
315 "Found ML capability\n");
316 fdoCtx->mlcap = fdoCtx->m_BAR0.Base.baseptr + offset;
317 break;
318
319 case HDA_GTS_CAP_ID:
320 SklHdAudBusPrint(DEBUG_LEVEL_INFO, DBG_INIT,
321 "Found GTS capability offset=%x\n", offset);
322 break;
323
324 case HDA_PP_CAP_ID:
325 /* PP capability found, the Audio DSP is present */
326 SklHdAudBusPrint(DEBUG_LEVEL_INFO, DBG_INIT,
327 "Found PP capability offset=%x\n", offset);
328 fdoCtx->ppcap = fdoCtx->m_BAR0.Base.baseptr + offset;
329 break;
330
331 case HDA_SPB_CAP_ID:
332 /* SPIB capability found, handler function */
333 SklHdAudBusPrint(DEBUG_LEVEL_INFO, DBG_INIT,
334 "Found SPB capability\n");
335 fdoCtx->spbcap = fdoCtx->m_BAR0.Base.baseptr + offset;
336 break;
337
338 case HDA_DRSM_CAP_ID:
339 /* DMA resume capability found, handler function */
340 SklHdAudBusPrint(DEBUG_LEVEL_INFO, DBG_INIT,
341 "Found DRSM capability\n");
342 break;
343
344 default:
345 SklHdAudBusPrint(DEBUG_LEVEL_ERROR, DBG_INIT, "Unknown capability %d\n", cur_cap);
346 cur_cap = 0;
347 break;
348 }
349
350 counter++;
351
352 if (counter > HDAC_MAX_CAPS) {
353 SklHdAudBusPrint(DEBUG_LEVEL_ERROR, DBG_INIT, "We exceeded HDAC capabilities!!!\n");
354 break;
355 }
356
357 /* read the offset of next capability */
359
360 } while (offset);
361 }
362
363 status = GetHDACapabilities(fdoCtx);
364 if (!NT_SUCCESS(status)) {
365 return status;
366 }
367
369 if (!fdoCtx->streams) {
370 return STATUS_NO_MEMORY;
371 }
372
373 PHYSICAL_ADDRESS maxAddr;
374 maxAddr.QuadPart = fdoCtx->is64BitOK ? MAXULONG64 : MAXULONG32;
375
376 fdoCtx->posbuf = MmAllocateContiguousMemory(PAGE_SIZE, maxAddr);
377 if (!fdoCtx->posbuf) {
378 return STATUS_NO_MEMORY;
379 }
380
382
383 fdoCtx->rb = (UINT8 *)MmAllocateContiguousMemory(PAGE_SIZE, maxAddr);
384 if (!fdoCtx->rb) {
385 return STATUS_NO_MEMORY;
386 }
387
388 RtlZeroMemory(fdoCtx->rb, PAGE_SIZE);
389
390 //Init Streams
391 {
392 UINT8 i;
393 UINT8 streamTags[2] = { 0, 0 };
394
395 for (i = 0; i < fdoCtx->numStreams; i++) {
396 int isCapture = (i >= fdoCtx->captureIndexOff &&
397 i < fdoCtx->captureIndexOff + fdoCtx->captureStreams);
398 /* stream tag must be unique throughout
399 * the stream direction group,
400 * valid values 1...15
401 * use separate stream tag
402 */
403 UINT8 tag = ++streamTags[isCapture];
404
405 {
406 UINT64 idx = i;
407
408 PHDAC_STREAM stream = &fdoCtx->streams[i];
409 stream->FdoContext = fdoCtx;
410 /* offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */
411 stream->sdAddr = fdoCtx->m_BAR0.Base.baseptr + (0x20 * idx + 0x80);
412 /* int mask: SDI0=0x01, SDI1=0x02, ... SDO3=0x80 */
413 stream->int_sta_mask = 1 << i;
414 stream->idx = i;
415 if (fdoCtx->venId == VEN_INTEL)
416 stream->streamTag = tag;
417 else
418 stream->streamTag = i + 1;
419
420 stream->posbuf = (UINT32 *)(((UINT8 *)fdoCtx->posbuf) + (idx * 8));
421
422 stream->spib_addr = NULL;
423 if (fdoCtx->spbcap) {
424 stream->spib_addr = fdoCtx->spbcap + HDA_SPB_BASE + (HDA_SPB_INTERVAL * idx) + HDA_SPB_SPIB;
425 }
426
428 if (stream->bdl) {
430 }
431 }
432
433 SklHdAudBusPrint(DEBUG_LEVEL_INFO, DBG_INIT,
434 "Stream tag (idx %d): %d\n", i, tag);
435 }
436 }
437
438 fdoCtx->nhlt = NULL;
439 fdoCtx->nhltSz = 0;
440
441 { //Check NHLT for Intel SST
443 if (NT_SUCCESS(status2)) {
444 UINT64 nhltAddr;
445 UINT64 nhltSz;
446
447 status2 = NHLTQueryTableAddress(Device, &nhltAddr, &nhltSz);
448
449 if (NT_SUCCESS(status2)) {
450 PHYSICAL_ADDRESS nhltBaseAddr;
451 nhltBaseAddr.QuadPart = nhltAddr;
452
453 if (nhltAddr != 0 && nhltSz != 0) {
454 fdoCtx->nhlt = MmMapIoSpace(nhltBaseAddr, nhltSz, MmCached);
455 if (!fdoCtx->nhlt) {
456 return STATUS_NO_MEMORY;
457 }
458 fdoCtx->nhltSz = nhltSz;
459 }
460 }
461 }
462 }
463
464 fdoCtx->sofTplg = NULL;
465 fdoCtx->sofTplgSz = 0;
466
467 { //Check topology for Intel SOF
468 SOF_TPLG sofTplg = { 0 };
469 NTSTATUS status2 = GetSOFTplg(Device, &sofTplg);
470 if (NT_SUCCESS(status2) && sofTplg.magic == SOFTPLG_MAGIC) {
472 RtlCopyMemory(fdoCtx->sofTplg, &sofTplg, sofTplg.length);
473 fdoCtx->sofTplgSz = sofTplg.length;
474 }
475 }
476
478
479 return status;
480}
#define ExAllocatePoolUninitialized
unsigned char BOOLEAN
Definition: actypes.h:127
COMPILER_DEPENDENT_UINT64 UINT64
Definition: actypes.h:131
PVOID NTAPI MmAllocateContiguousMemory(IN SIZE_T NumberOfBytes, IN PHYSICAL_ADDRESS HighestAcceptableAddress)
Definition: contmem.c:626
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
unsigned int idx
Definition: utils.c:41
#define SKLHDAUDBUS_POOL_TAG
Definition: driver.h:44
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define NonPagedPool
Definition: env_spec_w32.h:307
struct _HDAC_STREAM * PHDAC_STREAM
struct _HDAC_BDLENTRY * PHDAC_BDLENTRY
GLintptr offset
Definition: glext.h:5920
#define HDA_CAP_HDR_NXT_PTR_MASK
#define HDA_ML_CAP_ID
#define HDA_DRSM_CAP_ID
#define HDA_PP_CAP_ID
#define HDA_SPB_INTERVAL
#define HDA_SPB_CAP_ID
#define HDA_CAP_HDR_VER_OFF
#define HDA_SPB_SPIB
#define HDA_GTS_CAP_ID
#define BDL_SIZE
#define HDA_CAP_HDR_ID_OFF
#define HDA_CAP_HDR_VER_MASK
#define HDA_SPB_BASE
#define HDA_CAP_HDR_ID_MASK
NTSTATUS GetHDACapabilities(PFDO_CONTEXT fdoCtx)
#define HDAC_MAX_CAPS
PVOID NTAPI MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, IN SIZE_T NumberOfBytes, IN MEMORY_CACHING_TYPE CacheType)
Definition: iosup.c:47
FORCEINLINE PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
Definition: precomp.h:45
NTSTATUS NHLTCheckSupported(_In_ WDFDEVICE FxDevice)
Definition: nhlt.cpp:146
NTSTATUS NHLTQueryTableAddress(_In_ WDFDEVICE FxDevice, UINT64 *nhltAddr, UINT64 *nhltSz)
Definition: nhlt.cpp:182
#define hda_read16(ctx, reg)
Definition: regfuncs.h:56
static UINT32 read32(PVOID addr)
Definition: regfuncs.h:17
#define CmResourceTypeMemory
Definition: restypes.h:106
#define STATUS_NOT_FOUND
Definition: shellext.h:72
NTSTATUS GetSOFTplg(_In_ WDFDEVICE FxDevice, SOF_TPLG *sofTplg)
Definition: sof-tplg.cpp:14
#define SOFTPLG_MAGIC
Definition: sof-tplg.h:1
PGET_SET_DEVICE_DATA GetBusData
Definition: iotypes.h:916
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@382 u
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@382::@387 Memory
UINT8 * rb
Definition: fdo.h:167
UINT8 revId
Definition: fdo.h:119
UINT64 sofTplgSz
Definition: fdo.h:157
PVOID sofTplg
Definition: fdo.h:156
UINT32 captureIndexOff
Definition: fdo.h:143
BOOLEAN is64BitOK
Definition: fdo.h:140
UINT32 numStreams
Definition: fdo.h:147
UINT8 * mlcap
Definition: fdo.h:134
PCI_BAR m_BAR4
Definition: fdo.h:122
PHDAC_STREAM streams
Definition: fdo.h:149
PVOID posbuf
Definition: fdo.h:168
UINT32 captureStreams
Definition: fdo.h:145
UINT8 * spbcap
Definition: fdo.h:136
PCI_BAR m_BAR0
Definition: fdo.h:121
UINT8 * ppcap
Definition: fdo.h:135
PVOID nhlt
Definition: fdo.h:154
UINT64 nhltSz
Definition: fdo.h:155
ULONG Len
Definition: fdo.h:11
union baseaddr Base
Definition: fdo.h:10
UINT32 magic
Definition: sof-tplg.h:10
UINT32 length
Definition: sof-tplg.h:11
Definition: parse.h:23
Definition: ecma_167.h:138
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
LONGLONG QuadPart
Definition: typedefs.h:114
PVOID Base
Definition: fdo.h:5
UINT8 * baseptr
Definition: fdo.h:6
_In_ WDFCMRESLIST _In_ WDFCMRESLIST ResourcesTranslated
Definition: wdfdevice.h:891
_In_ WDFCMRESLIST ResourcesRaw
Definition: wdfdevice.h:888
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING DeviceID
Definition: wdfpdo.h:278
#define PCI_BUS_INTERFACE_STANDARD_VERSION
Definition: iotypes.h:5339
#define PCI_WHICHSPACE_CONFIG
Definition: iotypes.h:3646
_In_ USHORT _In_ UCHAR RevisionID
Definition: iotypes.h:893
@ MmCached
Definition: mmtypes.h:130
@ MmNonCached
Definition: mmtypes.h:129

◆ Fdo_EvtDeviceReleaseHardware()

NTSTATUS NTAPI Fdo_EvtDeviceReleaseHardware ( _In_ WDFDEVICE  Device,
_In_ WDFCMRESLIST  ResourcesTranslated 
)

Definition at line 484 of file fdo.cpp.

488{
489 PFDO_CONTEXT fdoCtx;
490
492
493 fdoCtx = Fdo_GetContext(Device);
494
495 SklHdAudBusPrint(DEBUG_LEVEL_INFO, DBG_INIT,
496 "%s\n", __func__);
497
498 if (fdoCtx->GraphicsDevicesCollection) {
499 for (ULONG i = 0; i < WdfCollectionGetCount(fdoCtx->GraphicsDevicesCollection); i++) {
500 WDFIOTARGET ioTarget = (WDFIOTARGET)WdfCollectionGetItem(fdoCtx->GraphicsDevicesCollection, i);
501 PGRAPHICSIOTARGET_CONTEXT ioTargetContext = GraphicsIoTarget_GetContext(ioTarget);
502
503 if (ioTargetContext->graphicsPowerRegisterOutput.DeviceHandle && ioTargetContext->graphicsPowerRegisterOutput.UnregisterCb) {
504 NTSTATUS status = ioTargetContext->graphicsPowerRegisterOutput.UnregisterCb(ioTargetContext->graphicsPowerRegisterOutput.DeviceHandle, fdoCtx);
505 if (!NT_SUCCESS(status)) {
506 SklHdAudBusPrint(DEBUG_LEVEL_ERROR, DBG_INIT, "Warning: unregister failed with status 0x%x\n", status);
507 }
508 }
509 }
510 }
511
512 if (fdoCtx->GraphicsNotificationHandle) {
514 }
515
516 if (fdoCtx->nhlt) {
517 MmUnmapIoSpace(fdoCtx->nhlt, fdoCtx->nhltSz);
518 fdoCtx->nhlt = NULL;
519 }
520
521 if (fdoCtx->sofTplg)
523
524 if (fdoCtx->posbuf)
526 if (fdoCtx->rb)
527 MmFreeContiguousMemory(fdoCtx->rb);
528
529 if (fdoCtx->streams) {
530 for (UINT32 i = 0; i < fdoCtx->numStreams; i++) {
531 PHDAC_STREAM stream = &fdoCtx->streams[i];
532 if (stream->bdl) {
534 stream->bdl = NULL;
535 }
536 }
537
539 }
540
541 if (fdoCtx->m_BAR0.Base.Base) {
542 MmUnmapIoSpace(fdoCtx->m_BAR0.Base.Base, fdoCtx->m_BAR0.Len);
543 fdoCtx->m_BAR0.Base.Base = NULL;
544 }
545 if (fdoCtx->m_BAR4.Base.Base) {
546 MmUnmapIoSpace(fdoCtx->m_BAR4.Base.Base, fdoCtx->m_BAR4.Len);
547 fdoCtx->m_BAR4.Base.Base = NULL;
548 }
549
550 return STATUS_SUCCESS;
551}
VOID NTAPI MmFreeContiguousMemory(IN PVOID BaseAddress)
Definition: contmem.c:653
VOID NTAPI MmUnmapIoSpace(IN PVOID BaseAddress, IN SIZE_T NumberOfBytes)
Definition: iosup.c:193
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
NTSTATUS NTAPI IoUnregisterPlugPlayNotification(_In_ PVOID NotificationEntry)
Definition: pnpnotify.c:480
PVOID GraphicsNotificationHandle
Definition: fdo.h:127
WDFCOLLECTION GraphicsDevicesCollection
Definition: fdo.h:129
DXGK_GRAPHICSPOWER_REGISTER_OUTPUT graphicsPowerRegisterOutput
Definition: fdo.h:109

◆ Fdo_EvtDeviceSelfManagedIoInit()

NTSTATUS NTAPI Fdo_EvtDeviceSelfManagedIoInit ( _In_ WDFDEVICE  Device)

Definition at line 773 of file fdo.cpp.

776{
778 PFDO_CONTEXT fdoCtx;
779
780 fdoCtx = Fdo_GetContext(Device);
781
782 WdfChildListBeginScan(WdfFdoGetDefaultChildList(Device));
783
784 fdoCtx->numCodecs = 0;
785#if ENABLE_HDA
786 for (UINT8 addr = 0; addr < HDA_MAX_CODECS; addr++) {
787 fdoCtx->codecs[addr] = NULL;
788 if (((fdoCtx->codecMask >> addr) & 0x1) == 0)
789 continue;
790
791 if (fdoCtx->UseSGPCCodec && fdoCtx->GraphicsCodecAddress == addr)
792 continue;
793
794 Fdo_EnumerateCodec(fdoCtx, addr);
795 }
796
797 if (fdoCtx->mlcap) {
801 (PVOID)&GUID_DEVINTERFACE_GRAPHICSPOWER,
802 WdfDriverWdmGetDriverObject(WdfDeviceGetDriver(fdoCtx->WdfDevice)),
804 (PVOID)fdoCtx,
805 &fdoCtx->GraphicsNotificationHandle
806 );
807
808 }
809#endif
810
811 fdoCtx->dspInterruptCallback = NULL;
812 if (fdoCtx->m_BAR4.Base.Base) { //Populate ADSP if present
814 //
815 // Initialize the description with the information about the detected codec.
816 //
818 &description.Header,
819 sizeof(description)
820 );
821
822 description.FdoContext = fdoCtx;
823
824 description.CodecIds.CtlrDevId = fdoCtx->devId;
825 description.CodecIds.CtlrVenId = fdoCtx->venId;
826
827 description.CodecIds.CodecAddress = 0x10000000;
828 description.CodecIds.IsDSP = TRUE;
829
830 //
831 // Call the framework to add this child to the childlist. This call
832 // will internaly call our DescriptionCompare callback to check
833 // whether this device is a new device or existing device. If
834 // it's a new device, the framework will call DescriptionDuplicate to create
835 // a copy of this description in nonpaged pool.
836 // The actual creation of the child device will happen when the framework
837 // receives QUERY_DEVICE_RELATION request from the PNP manager in
838 // response to InvalidateDeviceRelations call made as part of adding
839 // a new child.
840 //
841 status = WdfChildListAddOrUpdateChildDescriptionAsPresent(
842 WdfFdoGetDefaultChildList(Device), &description.Header,
843 NULL); // AddressDescription
844 }
845
846 WdfChildListEndScan(WdfFdoGetDefaultChildList(Device));
847
848 SklHdAudBusPrint(DEBUG_LEVEL_INFO, DBG_INIT,
849 "hda scan complete\n");
850 return status;
851}
NTSTATUS NTAPI HDAGraphicsPowerInterfaceCallback(PVOID NotificationStruct, PVOID Context)
Definition: sgpc.cpp:267
void NTAPI Fdo_EnumerateCodec(PFDO_CONTEXT fdoCtx, UINT8 addr)
Definition: fdo.cpp:680
NTSTATUS NTAPI IoRegisterPlugPlayNotification(_In_ IO_NOTIFICATION_EVENT_CATEGORY EventCategory, _In_ ULONG EventCategoryFlags, _In_opt_ PVOID EventCategoryData, _In_ PDRIVER_OBJECT DriverObject, _In_ PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine, _Inout_opt_ PVOID Context, _Out_ PVOID *NotificationEntry)
Definition: pnpnotify.c:346
struct _PDO_DEVICE_DATA * codecs[HDA_MAX_CODECS]
Definition: fdo.h:150
PADSP_INTERRUPT_CALLBACK dspInterruptCallback
Definition: fdo.h:152
@ EventCategoryDeviceInterfaceChange
Definition: iotypes.h:1226
#define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES
Definition: iotypes.h:1239

◆ Fdo_Initialize()

NTSTATUS NTAPI Fdo_Initialize ( _In_ PFDO_CONTEXT  FdoCtx)

Definition at line 147 of file fdo.cpp.

150{
152 WDFDEVICE device;
153 WDF_INTERRUPT_CONFIG interruptConfig;
154
155 device = FdoCtx->WdfDevice;
156
157 SklHdAudBusPrint(DEBUG_LEVEL_INFO, DBG_INIT,
158 "%s\n", __func__);
159
160 //
161 // Create an interrupt object for hardware notifications
162 //
164 &interruptConfig,
166 hda_dpc);
167
168 status = WdfInterruptCreate(
169 device,
170 &interruptConfig,
172 &FdoCtx->Interrupt);
173
174 if (!NT_SUCCESS(status))
175 {
176 SklHdAudBusPrint(DEBUG_LEVEL_ERROR, DBG_PNP,
177 "Error creating WDF interrupt object - %!STATUS!",
178 status);
179
180 return status;
181 }
182
183
184 status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &FdoCtx->GraphicsDevicesCollectionWaitLock);
185 if (!NT_SUCCESS(status))
186 {
187 SklHdAudBusPrint(DEBUG_LEVEL_ERROR, DBG_PNP,
188 "Error creating WDF wait lock - %!STATUS!",
189 status);
190
191 return status;
192 }
193
194 status = WdfCollectionCreate(WDF_NO_OBJECT_ATTRIBUTES, &FdoCtx->GraphicsDevicesCollection);
195
196 if (!NT_SUCCESS(status))
197 {
198 SklHdAudBusPrint(DEBUG_LEVEL_ERROR, DBG_PNP,
199 "Error creating WDF collection - %!STATUS!",
200 status);
201
202 return status;
203 }
204
205 return STATUS_SUCCESS;
206}
void NTAPI hda_dpc(WDFINTERRUPT Interrupt, WDFOBJECT AssociatedObject)
BOOLEAN NTAPI hda_interrupt(WDFINTERRUPT Interrupt, ULONG MessageID)
Definition: devices.h:37
FORCEINLINE VOID WDF_INTERRUPT_CONFIG_INIT(_Out_ PWDF_INTERRUPT_CONFIG Configuration, _In_ PFN_WDF_INTERRUPT_ISR EvtInterruptIsr, _In_opt_ PFN_WDF_INTERRUPT_DPC EvtInterruptDpc)
Definition: wdfinterrupt.h:271

Referenced by Fdo_Create().

◆ HDAGraphicsPowerInterfaceCallback()

NTSTATUS NTAPI HDAGraphicsPowerInterfaceCallback ( PVOID  NotificationStruct,
PVOID  Context 
)

Definition at line 267 of file sgpc.cpp.

270 {
273 PDEVICE_INTERFACE_CHANGE_NOTIFICATION devNotificationStruct = (PDEVICE_INTERFACE_CHANGE_NOTIFICATION)NotificationStruct;
274
275 if (!IsEqualGUID(devNotificationStruct->InterfaceClassGuid, GUID_DEVINTERFACE_GRAPHICSPOWER)) {
277 }
278
279 if (IsEqualGUID(devNotificationStruct->Event, GUID_DEVICE_INTERFACE_ARRIVAL)) {
280 SklHdAudBusPrint(DEBUG_LEVEL_INFO, DBG_INIT,
281 "Graphics Arrival Notification!\n");
282
283 status = RtlUnicodeStringValidate(devNotificationStruct->SymbolicLinkName);
284 if (!NT_SUCCESS(status)) {
285 return status;
286 }
287
288 WDF_WORKITEM_CONFIG workItemConfig;
290
291 WDF_OBJECT_ATTRIBUTES attributes;
292 WDFWORKITEM workItem;
293
294 WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
296 &attributes,
298 );
299 attributes.ParentObject = fdoCtx->WdfDevice;
300
301 WdfWorkItemCreate(&workItemConfig, &attributes, &workItem);
302
303 PGRAPHICSWORKITEM_CONTEXT workItemContext = GraphicsWorkitem_GetContext(workItem);
304 workItemContext->FdoContext = fdoCtx;
305 workItemContext->GPUDeviceSymlink = *devNotificationStruct->SymbolicLinkName;
306
307 WdfWorkItemEnqueue(workItem);
308 }
309
310 return status;
311}
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
const GUID GUID_DEVICE_INTERFACE_ARRIVAL
Definition: deviface.c:14
struct _FDO_CONTEXT * PFDO_CONTEXT
NTSTRSAFEAPI RtlUnicodeStringValidate(PCUNICODE_STRING SourceString)
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
void NTAPI HDAGraphicsPowerInterfaceAdd(WDFWORKITEM WorkItem)
Definition: sgpc.cpp:192
UNICODE_STRING GPUDeviceSymlink
Definition: fdo.h:102
struct _FDO_CONTEXT * FdoContext
Definition: fdo.h:101
WDFOBJECT ParentObject
Definition: wdfobject.h:130
FORCEINLINE VOID WDF_OBJECT_ATTRIBUTES_INIT(_Out_ PWDF_OBJECT_ATTRIBUTES Attributes)
Definition: wdfobject.h:147
#define WDF_OBJECT_ATTRIBUTES_SET_CONTEXT_TYPE(_attributes, _contexttype)
Definition: wdfobject.h:157
FORCEINLINE VOID WDF_WORKITEM_CONFIG_INIT(_Out_ PWDF_WORKITEM_CONFIG Config, _In_ PFN_WDF_WORKITEM EvtWorkItemFunc)
Definition: wdfworkitem.h:85
struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION * PDEVICE_INTERFACE_CHANGE_NOTIFICATION

Referenced by Fdo_EvtDeviceSelfManagedIoInit().

Variable Documentation

◆ Fdo_EvtDeviceD0Entry

EVT_WDF_DEVICE_D0_ENTRY Fdo_EvtDeviceD0Entry

Definition at line 7 of file fdo.cpp.

Referenced by Fdo_Create().

◆ Fdo_EvtDeviceD0EntryPostInterrupts

EVT_WDF_DEVICE_D0_ENTRY_POST_INTERRUPTS_ENABLED Fdo_EvtDeviceD0EntryPostInterrupts

Definition at line 8 of file fdo.cpp.

Referenced by Fdo_Create().

◆ Fdo_EvtDeviceD0Exit

EVT_WDF_DEVICE_D0_EXIT Fdo_EvtDeviceD0Exit

Definition at line 9 of file fdo.cpp.

Referenced by Fdo_Create().

◆ Fdo_EvtDevicePrepareHardware

EVT_WDF_DEVICE_PREPARE_HARDWARE Fdo_EvtDevicePrepareHardware

Definition at line 5 of file fdo.cpp.

Referenced by Fdo_Create().

◆ Fdo_EvtDeviceReleaseHardware

EVT_WDF_DEVICE_RELEASE_HARDWARE Fdo_EvtDeviceReleaseHardware

Definition at line 6 of file fdo.cpp.

Referenced by Fdo_Create().

◆ Fdo_EvtDeviceSelfManagedIoInit

EVT_WDF_DEVICE_SELF_MANAGED_IO_INIT Fdo_EvtDeviceSelfManagedIoInit

Definition at line 10 of file fdo.cpp.

Referenced by Fdo_Create().