ReactOS  0.4.15-dev-2155-g06f57e1
pdo.cpp File Reference
#include "hdaudbus.h"
Include dependency graph for pdo.cpp:

Go to the source code of this file.

Functions

NTSTATUS HDA_PDORemoveDevice (_In_ PDEVICE_OBJECT DeviceObject)
 
NTSTATUS HDA_PDOQueryBusInformation (IN PIRP Irp)
 
NTSTATUS NTAPI HDA_PDOQueryId (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS HDA_PDOHandleQueryDeviceText (IN PIRP Irp)
 
NTSTATUS HDA_PDOQueryBusDeviceCapabilities (IN PIRP Irp)
 
NTSTATUS HDA_PDOQueryBusDevicePnpState (IN PIRP Irp)
 

Function Documentation

◆ HDA_PDOHandleQueryDeviceText()

NTSTATUS HDA_PDOHandleQueryDeviceText ( IN PIRP  Irp)

Definition at line 154 of file pdo.cpp.

156 {
157  PIO_STACK_LOCATION IoStack;
158  LPWSTR Buffer;
159  static WCHAR DeviceText[] = L"Audio Device on High Definition Audio Bus";
160 
162  if (IoStack->Parameters.QueryDeviceText.DeviceTextType == DeviceTextDescription)
163  {
164  DPRINT("HDA_PdoHandleQueryDeviceText DeviceTextDescription\n");
165 
166  Buffer = (LPWSTR)AllocateItem(PagedPool, sizeof(DeviceText));
167  if (!Buffer)
168  {
169  Irp->IoStatus.Information = 0;
171  }
172 
173  wcscpy(Buffer, DeviceText);
174 
175  Irp->IoStatus.Information = (ULONG_PTR)Buffer;
176  return STATUS_SUCCESS;
177  }
178  else
179  {
180  DPRINT("HDA_PdoHandleQueryDeviceText DeviceTextLocationInformation\n");
181 
182  Buffer = (LPWSTR)AllocateItem(PagedPool, sizeof(DeviceText));
183  if (!Buffer)
184  {
185  Irp->IoStatus.Information = 0;
187  }
188 
189  wcscpy(Buffer, DeviceText);
190 
191  /* save result */
192  Irp->IoStatus.Information = (ULONG_PTR)Buffer;
193  return STATUS_SUCCESS;
194  }
195 
196 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
_In_ PIRP Irp
Definition: csq.h:116
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
#define ULONG_PTR
Definition: config.h:101
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
WCHAR * LPWSTR
Definition: xmlstorage.h:184
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3124

Referenced by HDA_PdoPnp().

◆ HDA_PDOQueryBusDeviceCapabilities()

NTSTATUS HDA_PDOQueryBusDeviceCapabilities ( IN PIRP  Irp)

Definition at line 199 of file pdo.cpp.

201 {
203  PIO_STACK_LOCATION IoStack;
204 
205  /* get stack location */
207 
208  /* get capabilities */
209  Capabilities = IoStack->Parameters.DeviceCapabilities.Capabilities;
210 
212 
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;
221 
222  /* done */
223  return STATUS_SUCCESS;
224 }
#define TRUE
Definition: types.h:120
DEVICE_CAPABILITIES
Definition: iotypes.h:965
_In_ PIRP Irp
Definition: csq.h:116
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
* PDEVICE_CAPABILITIES
Definition: iotypes.h:965
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3124

Referenced by HDA_PdoPnp().

◆ HDA_PDOQueryBusDevicePnpState()

NTSTATUS HDA_PDOQueryBusDevicePnpState ( IN PIRP  Irp)

Definition at line 227 of file pdo.cpp.

229 {
230  /* set device flags */
232 
233  /* done */
234  return STATUS_SUCCESS;
235 }
#define PNP_DEVICE_DONT_DISPLAY_IN_UI
Definition: iotypes.h:1002
_In_ PIRP Irp
Definition: csq.h:116
#define PNP_DEVICE_NOT_DISABLEABLE
Definition: iotypes.h:1006
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by HDA_PdoPnp().

◆ HDA_PDOQueryBusInformation()

NTSTATUS HDA_PDOQueryBusInformation ( IN PIRP  Irp)

Definition at line 33 of file pdo.cpp.

35 {
37 
38  /* allocate bus information */
40 
41  if (!BusInformation)
42  {
43  /* no memory */
45  }
46 
47  /* return info */
48  BusInformation->BusNumber = 0;
49  BusInformation->LegacyBusType = PCIBus;
50  RtlMoveMemory(&BusInformation->BusTypeGuid, &GUID_HDAUDIO_BUS_INTERFACE, sizeof(GUID));
51 
52  /* store result */
53  Irp->IoStatus.Information = (ULONG_PTR)BusInformation;
54 
55  /* done */
56  return STATUS_SUCCESS;
57 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
_In_ PIRP Irp
Definition: csq.h:116
struct _PNP_BUS_INFORMATION * PPNP_BUS_INFORMATION
#define ULONG_PTR
Definition: config.h:101
#define STATUS_SUCCESS
Definition: shellext.h:65
_In_ WDFDEVICE _In_ PPNP_BUS_INFORMATION BusInformation
Definition: wdfdevice.h:3912

Referenced by HDA_PdoPnp().

◆ HDA_PDOQueryId()

NTSTATUS NTAPI HDA_PDOQueryId ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 62 of file pdo.cpp.

65 {
66  PIO_STACK_LOCATION IoStack;
67  WCHAR DeviceName[200];
68  PHDA_PDO_DEVICE_EXTENSION DeviceExtension;
69  ULONG Length;
70  LPWSTR Device;
72 
73  /* get device extension */
74  DeviceExtension = (PHDA_PDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
75  ASSERT(DeviceExtension->IsFDO == FALSE);
76 
77  /* get current irp stack location */
79 
80  if (IoStack->Parameters.QueryId.IdType == BusQueryInstanceID)
81  {
83  sizeof(DeviceName),
84  L"%02x%02x",
85  DeviceExtension->Codec->Addr,
86  DeviceExtension->AudioGroup->NodeId);
88  Length = wcslen(DeviceName) + 1;
89 
90  /* allocate result buffer*/
92  if (!Device)
94 
96  Length * sizeof(WCHAR),
97  DeviceName);
99 
100  DPRINT1("ID: %S\n", Device);
101  /* store result */
102  Irp->IoStatus.Information = (ULONG_PTR)Device;
103  return STATUS_SUCCESS;
104  }
105  else if (IoStack->Parameters.QueryId.IdType == BusQueryDeviceID ||
106  IoStack->Parameters.QueryId.IdType == BusQueryHardwareIDs)
107  {
108 
109  /* calculate size */
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;
112 
113  /* allocate result buffer*/
115  if (!Device)
117 
119 
120  DPRINT1("ID: %S\n", Device);
121  /* store result */
122  Irp->IoStatus.Information = (ULONG_PTR)Device;
123  return STATUS_SUCCESS;
124  }
125  else if (IoStack->Parameters.QueryId.IdType == BusQueryCompatibleIDs)
126  {
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;
132 
133  /* allocate result buffer*/
135  if (!Device)
137 
139 
140  DPRINT1("ID: %S\n", Device);
141  /* store result */
142  Irp->IoStatus.Information = (ULONG_PTR)Device;
143  return STATUS_SUCCESS;
144  }
145  else
146  {
147  DPRINT1("QueryID Type %x not implemented\n", IoStack->Parameters.QueryId.IdType);
148  return Irp->IoStatus.Status;
149  }
150  return STATUS_NOT_IMPLEMENTED;
151 }
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:174
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
PHDA_CODEC_ENTRY Codec
Definition: hdaudbus.h:90
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
struct HDA_PDO_DEVICE_EXTENSION * PHDA_PDO_DEVICE_EXTENSION
LONG NTSTATUS
Definition: precomp.h:26
#define swprintf
Definition: precomp.h:40
USHORT ProductId
Definition: hdaudbus.h:48
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
return STATUS_NOT_IMPLEMENTED
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3272
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
UCHAR Revision
Definition: hdaudbus.h:51
UCHAR Minor
Definition: hdaudbus.h:50
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTRSAFEVAPI RtlStringCbPrintfW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1173
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
UCHAR Major
Definition: hdaudbus.h:49
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
USHORT VendorId
Definition: hdaudbus.h:47
UCHAR Addr
Definition: hdaudbus.h:53
PHDA_CODEC_AUDIO_GROUP AudioGroup
Definition: hdaudbus.h:91
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ULONG_PTR
Definition: config.h:101
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
WCHAR * LPWSTR
Definition: xmlstorage.h:184
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3124
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by HDA_PdoPnp().

◆ HDA_PDORemoveDevice()

NTSTATUS HDA_PDORemoveDevice ( _In_ PDEVICE_OBJECT  DeviceObject)

Definition at line 11 of file pdo.cpp.

13 {
14  PHDA_PDO_DEVICE_EXTENSION DeviceExtension;
15 
16  /* get device extension */
17  DeviceExtension = static_cast<PHDA_PDO_DEVICE_EXTENSION>(DeviceObject->DeviceExtension);
18  ASSERT(DeviceExtension->IsFDO == FALSE);
19 
20  if (DeviceExtension->ReportedMissing)
21  {
22  if (DeviceExtension->AudioGroup != NULL)
23  {
24  DeviceExtension->AudioGroup->ChildPDO = NULL;
25  }
27  }
28 
29  return STATUS_SUCCESS;
30 }
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FALSE
Definition: types.h:117
#define ASSERT(a)
Definition: mode.c:45
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
#define NULL
Definition: types.h:112
PHDA_CODEC_AUDIO_GROUP AudioGroup
Definition: hdaudbus.h:91
PDEVICE_OBJECT ChildPDO
Definition: hdaudbus.h:40
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by HDA_FDORemoveDevice(), and HDA_PdoPnp().