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
11 HDA_PDOQueryBusInformation(
14 PPNP_BUS_INFORMATION BusInformation
;
16 /* allocate bus information */
17 BusInformation
= (PPNP_BUS_INFORMATION
)AllocateItem(PagedPool
, sizeof(PNP_BUS_INFORMATION
));
22 return STATUS_INSUFFICIENT_RESOURCES
;
26 BusInformation
->BusNumber
= 0;
27 BusInformation
->LegacyBusType
= PCIBus
;
28 RtlMoveMemory(&BusInformation
->BusTypeGuid
, &GUID_HDAUDIO_BUS_INTERFACE
, sizeof(GUID
));
31 Irp
->IoStatus
.Information
= (ULONG_PTR
)BusInformation
;
34 return STATUS_SUCCESS
;
41 IN PDEVICE_OBJECT DeviceObject
,
44 PIO_STACK_LOCATION IoStack
;
45 WCHAR DeviceName
[200];
46 PHDA_PDO_DEVICE_EXTENSION DeviceExtension
;
50 /* get device extension */
51 DeviceExtension
= (PHDA_PDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
52 ASSERT(DeviceExtension
->IsFDO
== FALSE
);
54 /* get current irp stack location */
55 IoStack
= IoGetCurrentIrpStackLocation(Irp
);
57 if (IoStack
->Parameters
.QueryId
.IdType
== BusQueryInstanceID
)
62 swprintf(DeviceName
, L
"%08x", 1);
63 Length
= wcslen(DeviceName
) + 20;
65 /* allocate result buffer*/
66 Device
= (LPWSTR
)AllocateItem(PagedPool
, Length
* sizeof(WCHAR
));
68 return STATUS_INSUFFICIENT_RESOURCES
;
70 swprintf(Device
, L
"%08x", 1);
72 DPRINT1("ID: %S\n", Device
);
74 Irp
->IoStatus
.Information
= (ULONG_PTR
)Device
;
75 return STATUS_SUCCESS
;
77 else if (IoStack
->Parameters
.QueryId
.IdType
== BusQueryDeviceID
||
78 IoStack
->Parameters
.QueryId
.IdType
== BusQueryHardwareIDs
)
82 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
);
83 Length
= wcslen(DeviceName
) + 20;
85 /* allocate result buffer*/
86 Device
= (LPWSTR
)AllocateItem(PagedPool
, Length
* sizeof(WCHAR
));
88 return STATUS_INSUFFICIENT_RESOURCES
;
90 wcscpy(Device
, DeviceName
);
92 DPRINT1("ID: %S\n", Device
);
94 Irp
->IoStatus
.Information
= (ULONG_PTR
)Device
;
95 return STATUS_SUCCESS
;
97 else if (IoStack
->Parameters
.QueryId
.IdType
== BusQueryCompatibleIDs
)
99 RtlZeroMemory(DeviceName
, sizeof(DeviceName
));
100 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;
101 Length
+= swprintf(&DeviceName
[Length
], L
"HDAUDIO\\FUNC_%02X&VEN_%04X&DEV_%04X", DeviceExtension
->AudioGroup
->FunctionGroup
, DeviceExtension
->Codec
->VendorId
, DeviceExtension
->Codec
->ProductId
) + 1;
102 Length
+= swprintf(&DeviceName
[Length
], L
"HDAUDIO\\FUNC_%02X&VEN_%04X", DeviceExtension
->AudioGroup
->FunctionGroup
, DeviceExtension
->Codec
->VendorId
) + 1;
103 Length
+= swprintf(&DeviceName
[Length
], L
"HDAUDIO\\FUNC_%02X", DeviceExtension
->AudioGroup
->FunctionGroup
) + 2;
105 /* allocate result buffer*/
106 Device
= (LPWSTR
)AllocateItem(PagedPool
, Length
* sizeof(WCHAR
));
108 return STATUS_INSUFFICIENT_RESOURCES
;
110 RtlCopyMemory(Device
, DeviceName
, Length
* sizeof(WCHAR
));
112 DPRINT1("ID: %S\n", Device
);
114 Irp
->IoStatus
.Information
= (ULONG_PTR
)Device
;
115 return STATUS_SUCCESS
;
119 DPRINT1("QueryID Type %x not implemented\n", IoStack
->Parameters
.QueryId
.IdType
);
120 return Irp
->IoStatus
.Status
;
122 return STATUS_NOT_IMPLEMENTED
;
126 HDA_PDOHandleQueryDeviceText(
129 PIO_STACK_LOCATION IoStack
;
131 static WCHAR DeviceText
[] = L
"Audio Device on High Definition Audio Bus";
133 IoStack
= IoGetCurrentIrpStackLocation(Irp
);
134 if (IoStack
->Parameters
.QueryDeviceText
.DeviceTextType
== DeviceTextDescription
)
136 DPRINT("HDA_PdoHandleQueryDeviceText DeviceTextDescription\n");
138 Buffer
= (LPWSTR
)AllocateItem(PagedPool
, sizeof(DeviceText
));
141 Irp
->IoStatus
.Information
= 0;
142 return STATUS_INSUFFICIENT_RESOURCES
;
145 wcscpy(Buffer
, DeviceText
);
147 Irp
->IoStatus
.Information
= (ULONG_PTR
)Buffer
;
148 return STATUS_SUCCESS
;
152 DPRINT("HDA_PdoHandleQueryDeviceText DeviceTextLocationInformation\n");
154 Buffer
= (LPWSTR
)AllocateItem(PagedPool
, sizeof(DeviceText
));
157 Irp
->IoStatus
.Information
= 0;
158 return STATUS_INSUFFICIENT_RESOURCES
;
161 wcscpy(Buffer
, DeviceText
);
164 Irp
->IoStatus
.Information
= (ULONG_PTR
)Buffer
;
165 return STATUS_SUCCESS
;
171 HDA_PDOQueryBusDeviceCapabilities(
174 PDEVICE_CAPABILITIES Capabilities
;
175 PIO_STACK_LOCATION IoStack
;
177 /* get stack location */
178 IoStack
= IoGetCurrentIrpStackLocation(Irp
);
180 /* get capabilities */
181 Capabilities
= IoStack
->Parameters
.DeviceCapabilities
.Capabilities
;
183 RtlZeroMemory(Capabilities
, sizeof(DEVICE_CAPABILITIES
));
185 /* setup capabilities */
186 Capabilities
->UniqueID
= TRUE
;
187 Capabilities
->SilentInstall
= TRUE
;
188 Capabilities
->SurpriseRemovalOK
= TRUE
;
189 Capabilities
->Address
= 0;
190 Capabilities
->UINumber
= 0;
191 Capabilities
->SystemWake
= PowerSystemWorking
; /* FIXME common device extension */
192 Capabilities
->DeviceWake
= PowerDeviceD0
;
195 return STATUS_SUCCESS
;
199 HDA_PDOQueryBusDevicePnpState(
202 /* set device flags */
203 Irp
->IoStatus
.Information
= PNP_DEVICE_DONT_DISPLAY_IN_UI
| PNP_DEVICE_NOT_DISABLEABLE
;
206 return STATUS_SUCCESS
;