2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Kernel Streaming
4 * FILE: drivers/wdm/audio/hdaudbus/pdo.cpp
5 * PURPOSE: HDA Driver Entry
6 * PROGRAMMER: Johannes Anderwald
12 _In_ PDEVICE_OBJECT DeviceObject
)
14 PHDA_PDO_DEVICE_EXTENSION DeviceExtension
;
16 /* get device extension */
17 DeviceExtension
= static_cast<PHDA_PDO_DEVICE_EXTENSION
>(DeviceObject
->DeviceExtension
);
18 ASSERT(DeviceExtension
->IsFDO
== FALSE
);
20 if (DeviceExtension
->ReportedMissing
)
22 if (DeviceExtension
->AudioGroup
!= NULL
)
24 DeviceExtension
->AudioGroup
->ChildPDO
= NULL
;
26 IoDeleteDevice(DeviceObject
);
29 return STATUS_SUCCESS
;
33 HDA_PDOQueryBusInformation(
36 PPNP_BUS_INFORMATION BusInformation
;
38 /* allocate bus information */
39 BusInformation
= (PPNP_BUS_INFORMATION
)AllocateItem(PagedPool
, sizeof(PNP_BUS_INFORMATION
));
44 return STATUS_INSUFFICIENT_RESOURCES
;
48 BusInformation
->BusNumber
= 0;
49 BusInformation
->LegacyBusType
= PCIBus
;
50 RtlMoveMemory(&BusInformation
->BusTypeGuid
, &GUID_HDAUDIO_BUS_INTERFACE
, sizeof(GUID
));
53 Irp
->IoStatus
.Information
= (ULONG_PTR
)BusInformation
;
56 return STATUS_SUCCESS
;
63 IN PDEVICE_OBJECT DeviceObject
,
66 PIO_STACK_LOCATION IoStack
;
67 WCHAR DeviceName
[200];
68 PHDA_PDO_DEVICE_EXTENSION DeviceExtension
;
73 /* get device extension */
74 DeviceExtension
= (PHDA_PDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
75 ASSERT(DeviceExtension
->IsFDO
== FALSE
);
77 /* get current irp stack location */
78 IoStack
= IoGetCurrentIrpStackLocation(Irp
);
80 if (IoStack
->Parameters
.QueryId
.IdType
== BusQueryInstanceID
)
82 Status
= RtlStringCbPrintfW(DeviceName
,
85 DeviceExtension
->Codec
->Addr
,
86 DeviceExtension
->AudioGroup
->NodeId
);
87 NT_ASSERT(NT_SUCCESS(Status
));
88 Length
= wcslen(DeviceName
) + 1;
90 /* allocate result buffer*/
91 Device
= (LPWSTR
)AllocateItem(PagedPool
, Length
* sizeof(WCHAR
));
93 return STATUS_INSUFFICIENT_RESOURCES
;
95 Status
= RtlStringCbCopyW(Device
,
96 Length
* sizeof(WCHAR
),
98 NT_ASSERT(NT_SUCCESS(Status
));
100 DPRINT1("ID: %S\n", Device
);
102 Irp
->IoStatus
.Information
= (ULONG_PTR
)Device
;
103 return STATUS_SUCCESS
;
105 else if (IoStack
->Parameters
.QueryId
.IdType
== BusQueryDeviceID
||
106 IoStack
->Parameters
.QueryId
.IdType
== BusQueryHardwareIDs
)
110 swprintf(DeviceName
, L
"HDAUDIO\\FUNC_%02X&VEN_%04X&DEV_%04X&SUBSYS_%08X", DeviceExtension
->AudioGroup
->FunctionGroup
, DeviceExtension
->Codec
->VendorId
, DeviceExtension
->Codec
->ProductId
, DeviceExtension
->Codec
->VendorId
<< 16 | DeviceExtension
->Codec
->ProductId
);
111 Length
= wcslen(DeviceName
) + 20;
113 /* allocate result buffer*/
114 Device
= (LPWSTR
)AllocateItem(PagedPool
, Length
* sizeof(WCHAR
));
116 return STATUS_INSUFFICIENT_RESOURCES
;
118 wcscpy(Device
, DeviceName
);
120 DPRINT1("ID: %S\n", Device
);
122 Irp
->IoStatus
.Information
= (ULONG_PTR
)Device
;
123 return STATUS_SUCCESS
;
125 else if (IoStack
->Parameters
.QueryId
.IdType
== BusQueryCompatibleIDs
)
127 RtlZeroMemory(DeviceName
, sizeof(DeviceName
));
128 Length
= swprintf(DeviceName
, L
"HDAUDIO\\FUNC_%02X&VEN_%04X&DEV_%04X&REV_%04X", DeviceExtension
->AudioGroup
->FunctionGroup
, DeviceExtension
->Codec
->VendorId
, DeviceExtension
->Codec
->ProductId
, DeviceExtension
->Codec
->Major
<< 12 | DeviceExtension
->Codec
->Minor
<< 8 | DeviceExtension
->Codec
->Revision
) + 1;
129 Length
+= swprintf(&DeviceName
[Length
], L
"HDAUDIO\\FUNC_%02X&VEN_%04X&DEV_%04X", DeviceExtension
->AudioGroup
->FunctionGroup
, DeviceExtension
->Codec
->VendorId
, DeviceExtension
->Codec
->ProductId
) + 1;
130 Length
+= swprintf(&DeviceName
[Length
], L
"HDAUDIO\\FUNC_%02X&VEN_%04X", DeviceExtension
->AudioGroup
->FunctionGroup
, DeviceExtension
->Codec
->VendorId
) + 1;
131 Length
+= swprintf(&DeviceName
[Length
], L
"HDAUDIO\\FUNC_%02X", DeviceExtension
->AudioGroup
->FunctionGroup
) + 2;
133 /* allocate result buffer*/
134 Device
= (LPWSTR
)AllocateItem(PagedPool
, Length
* sizeof(WCHAR
));
136 return STATUS_INSUFFICIENT_RESOURCES
;
138 RtlCopyMemory(Device
, DeviceName
, Length
* sizeof(WCHAR
));
140 DPRINT1("ID: %S\n", Device
);
142 Irp
->IoStatus
.Information
= (ULONG_PTR
)Device
;
143 return STATUS_SUCCESS
;
147 DPRINT1("QueryID Type %x not implemented\n", IoStack
->Parameters
.QueryId
.IdType
);
148 return Irp
->IoStatus
.Status
;
150 return STATUS_NOT_IMPLEMENTED
;
154 HDA_PDOHandleQueryDeviceText(
157 PIO_STACK_LOCATION IoStack
;
159 static WCHAR DeviceText
[] = L
"Audio Device on High Definition Audio Bus";
161 IoStack
= IoGetCurrentIrpStackLocation(Irp
);
162 if (IoStack
->Parameters
.QueryDeviceText
.DeviceTextType
== DeviceTextDescription
)
164 DPRINT("HDA_PdoHandleQueryDeviceText DeviceTextDescription\n");
166 Buffer
= (LPWSTR
)AllocateItem(PagedPool
, sizeof(DeviceText
));
169 Irp
->IoStatus
.Information
= 0;
170 return STATUS_INSUFFICIENT_RESOURCES
;
173 wcscpy(Buffer
, DeviceText
);
175 Irp
->IoStatus
.Information
= (ULONG_PTR
)Buffer
;
176 return STATUS_SUCCESS
;
180 DPRINT("HDA_PdoHandleQueryDeviceText DeviceTextLocationInformation\n");
182 Buffer
= (LPWSTR
)AllocateItem(PagedPool
, sizeof(DeviceText
));
185 Irp
->IoStatus
.Information
= 0;
186 return STATUS_INSUFFICIENT_RESOURCES
;
189 wcscpy(Buffer
, DeviceText
);
192 Irp
->IoStatus
.Information
= (ULONG_PTR
)Buffer
;
193 return STATUS_SUCCESS
;
199 HDA_PDOQueryBusDeviceCapabilities(
202 PDEVICE_CAPABILITIES Capabilities
;
203 PIO_STACK_LOCATION IoStack
;
205 /* get stack location */
206 IoStack
= IoGetCurrentIrpStackLocation(Irp
);
208 /* get capabilities */
209 Capabilities
= IoStack
->Parameters
.DeviceCapabilities
.Capabilities
;
211 RtlZeroMemory(Capabilities
, sizeof(DEVICE_CAPABILITIES
));
213 /* setup capabilities */
214 Capabilities
->UniqueID
= TRUE
;
215 Capabilities
->SilentInstall
= TRUE
;
216 Capabilities
->SurpriseRemovalOK
= TRUE
;
217 Capabilities
->Address
= 0;
218 Capabilities
->UINumber
= 0;
219 Capabilities
->SystemWake
= PowerSystemWorking
; /* FIXME common device extension */
220 Capabilities
->DeviceWake
= PowerDeviceD0
;
223 return STATUS_SUCCESS
;
227 HDA_PDOQueryBusDevicePnpState(
230 /* set device flags */
231 Irp
->IoStatus
.Information
= PNP_DEVICE_DONT_DISPLAY_IN_UI
| PNP_DEVICE_NOT_DISABLEABLE
;
234 return STATUS_SUCCESS
;