ReactOS  0.4.15-dev-1152-g6c94e4f
businterface.cpp
Go to the documentation of this file.
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Kernel Streaming
4 * FILE: drivers/wdm/audio/hdaudbus/hdaudbus.cpp
5 * PURPOSE: HDA Driver Entry
6 * PROGRAMMER: Johannes Anderwald
7 */
8 #include "hdaudbus.h"
9 
10 
11 VOID
12 NTAPI
14 PVOID BusContext)
15 {
16  DPRINT1("HDA_InterfaceReference\n");
17 }
18 
19 VOID
20 NTAPI
22 PVOID BusContext)
23 {
24  DPRINT1("HDA_InterfaceDereference\n");
25 }
26 
28 NTAPI
30  IN PVOID _context,
31  IN ULONG Count,
32  IN OUT PHDAUDIO_CODEC_TRANSFER CodecTransfer,
35 {
37  ULONG Index;
38  PHDA_PDO_DEVICE_EXTENSION DeviceExtension;
39 
40  DPRINT1("HDA_TransferCodecVerbs Count %lu CodecTransfer %p Callback %p Context %p\n", Count, CodecTransfer, Callback, Context);
41 
42  /* get device extension */
43  DeviceExtension = (PHDA_PDO_DEVICE_EXTENSION)_context;
44  ASSERT(DeviceExtension->IsFDO == FALSE);
45 
46  /* FIXME handle callback*/
47  ASSERT(Callback == NULL);
48 
49  for (Index = 0; Index < Count; Index++)
50  {
51  Verbs[Index] = CodecTransfer[Index].Output.Command;
52  }
53 
54  HDA_SendVerbs(DeviceExtension->FDO, DeviceExtension->Codec, Verbs, Responses, Count);
55 
56  for (Index = 0; Index < DeviceExtension->Codec->ResponseCount; Index++)
57  {
58  CodecTransfer[Index].Input.Response = DeviceExtension->Codec->Responses[Index];
59  }
60  return STATUS_SUCCESS;
61 }
62 
64 NTAPI
66  IN PVOID _context,
67  IN UCHAR CodecAddress,
68  IN PHDAUDIO_STREAM_FORMAT StreamFormat,
70  OUT PHDAUDIO_CONVERTER_FORMAT ConverterFormat)
71 {
73  ASSERT(FALSE);
75 }
76 
78 NTAPI
80  IN PVOID _context,
81  IN PHDAUDIO_STREAM_FORMAT StreamFormat,
82  IN BOOLEAN Stripe,
84  OUT PHDAUDIO_CONVERTER_FORMAT ConverterFormat)
85 {
87  ASSERT(FALSE);
89 }
90 
92 NTAPI
94  IN PVOID _context,
96  IN PHDAUDIO_STREAM_FORMAT StreamFormat,
97  OUT PHDAUDIO_CONVERTER_FORMAT ConverterFormat)
98 {
100  ASSERT(FALSE);
101  return STATUS_NOT_IMPLEMENTED;
102 }
103 
104 NTSTATUS
105 NTAPI
107  IN PVOID _context,
108  IN HANDLE Handle,
109  IN SIZE_T RequestedBufferSize,
110  OUT PMDL *BufferMdl,
111  OUT PSIZE_T AllocatedBufferSize,
112  OUT PUCHAR StreamId,
113  OUT PULONG FifoSize)
114 {
116  ASSERT(FALSE);
117  return STATUS_NOT_IMPLEMENTED;
118 }
119 
120 NTSTATUS
121 NTAPI
123  IN PVOID _context,
124  IN HANDLE Handle)
125 {
127  ASSERT(FALSE);
128  return STATUS_NOT_IMPLEMENTED;
129 }
130 
131 NTSTATUS
132 NTAPI
134  IN PVOID _context,
135  IN HANDLE Handle)
136 {
138  ASSERT(FALSE);
139  return STATUS_NOT_IMPLEMENTED;
140 }
141 
142 NTSTATUS
143 NTAPI
145  IN PVOID _context,
146  IN HDAUDIO_STREAM_STATE StreamState,
147  IN ULONG NumberOfHandles,
148  IN PHANDLE Handles)
149 {
151  ASSERT(FALSE);
152  return STATUS_NOT_IMPLEMENTED;
153 }
154 
155 VOID
156 NTAPI
158  IN PVOID _context,
159  OUT PULONG *Wallclock)
160 {
162  ASSERT(FALSE);
163 }
164 
165 NTSTATUS
166 NTAPI
168  IN PVOID _context,
169  IN HANDLE Handle,
171 {
173  ASSERT(FALSE);
174  return STATUS_NOT_IMPLEMENTED;
175 }
176 
177 NTSTATUS
178 NTAPI
180  IN PVOID _context,
182  IN PVOID Context,
183  OUT PUCHAR Tag)
184 {
186  *Tag = 1;
187  return STATUS_SUCCESS;
188 }
189 
190 
191 NTSTATUS
192 NTAPI
194 IN PVOID _context,
195 IN UCHAR Tag)
196 {
198  ASSERT(FALSE);
199  return STATUS_NOT_IMPLEMENTED;
200 }
201 
202 NTSTATUS
203 NTAPI
205  IN PVOID _context,
206  OUT PHDAUDIO_DEVICE_INFORMATION DeviceInformation)
207 {
208  PHDA_PDO_DEVICE_EXTENSION DeviceExtension;
209 
210  DeviceExtension = (PHDA_PDO_DEVICE_EXTENSION)_context;
211 
212  DPRINT1("HDA_GetDeviceInformation\n");
213 
214  DeviceInformation->Size = sizeof(HDAUDIO_DEVICE_INFORMATION);
215  DeviceInformation->CodecsDetected = 1; // FIXME
216  DeviceInformation->DeviceVersion = DeviceExtension->Codec->Major << 8 | DeviceExtension->Codec->Minor;
217  DeviceInformation->DriverVersion = DeviceExtension->Codec->Major << 8 | DeviceExtension->Codec->Minor;
218  DeviceInformation->IsStripingSupported = FALSE;
219 
220  return STATUS_SUCCESS;
221 }
222 
223 VOID
224 NTAPI
226  IN PVOID _context,
227  OUT PUCHAR CodecAddress,
228  OUT PUCHAR FunctionGroupStartNode)
229 {
230  PHDA_PDO_DEVICE_EXTENSION DeviceExtension;
231 
232  DeviceExtension = (PHDA_PDO_DEVICE_EXTENSION)_context;
233 
234  DPRINT1("HDA_GetResourceInformation Addr %x NodeId %x\n", DeviceExtension->Codec->Addr, DeviceExtension->AudioGroup->NodeId);
235 
236  *CodecAddress = DeviceExtension->Codec->Addr;
237  *FunctionGroupStartNode = DeviceExtension->AudioGroup->NodeId;
238 }
239 
240 NTSTATUS
241 NTAPI
243  IN PVOID _context,
244  IN HANDLE Handle,
245  IN ULONG NotificationCount,
246  IN SIZE_T RequestedBufferSize,
247  OUT PMDL *BufferMdl,
248  OUT PSIZE_T AllocatedBufferSize,
249  OUT PSIZE_T OffsetFromFirstPage,
250  OUT PUCHAR StreamId,
251  OUT PULONG FifoSize)
252 {
254  ASSERT(FALSE);
255  return STATUS_NOT_IMPLEMENTED;
256 
257 }
258 NTSTATUS
259 NTAPI
261  IN PVOID _context,
262  IN HANDLE Handle,
263  IN PMDL BufferMdl,
265 {
267  ASSERT(FALSE);
268  return STATUS_NOT_IMPLEMENTED;
269 
270 }
271 
272 NTSTATUS
273 NTAPI
275  PVOID _context,
276  HANDLE Handle,
278 {
280  ASSERT(FALSE);
281  return STATUS_NOT_IMPLEMENTED;
282 
283 }
284 
285 NTSTATUS
286 NTAPI
288  IN PVOID _context,
289  IN HANDLE Handle,
291 {
293  ASSERT(FALSE);
294  return STATUS_NOT_IMPLEMENTED;
295 }
296 
297 
298 NTSTATUS
301  IN PIRP Irp)
302 {
303  PIO_STACK_LOCATION IoStack;
304  PHDAUDIO_BUS_INTERFACE_V2 InterfaceHDA;
305  PHDA_PDO_DEVICE_EXTENSION DeviceExtension;
306 
307  /* get device extension */
308  DeviceExtension = (PHDA_PDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
309  ASSERT(DeviceExtension->IsFDO == FALSE);
310 
312 
313  if (IsEqualGUIDAligned(*IoStack->Parameters.QueryInterface.InterfaceType, GUID_HDAUDIO_BUS_INTERFACE))
314  {
315  InterfaceHDA = (PHDAUDIO_BUS_INTERFACE_V2)IoStack->Parameters.QueryInterface.Interface;
316  InterfaceHDA->Version = IoStack->Parameters.QueryInterface.Version;
317  InterfaceHDA->Size = sizeof(HDAUDIO_BUS_INTERFACE);
318  InterfaceHDA->Context = DeviceExtension;
321 
327  InterfaceHDA->FreeDmaBuffer = HDA_FreeDmaBuffer;
328  InterfaceHDA->FreeDmaEngine = HDA_FreeDmaEngine;
336  return STATUS_SUCCESS;
337  }
338  else if (IsEqualGUIDAligned(*IoStack->Parameters.QueryInterface.InterfaceType, GUID_HDAUDIO_BUS_INTERFACE_V2))
339  {
340  InterfaceHDA = (PHDAUDIO_BUS_INTERFACE_V2)IoStack->Parameters.QueryInterface.Interface;
341  InterfaceHDA->Version = IoStack->Parameters.QueryInterface.Version;
342  InterfaceHDA->Size = sizeof(HDAUDIO_BUS_INTERFACE_V2);
343  InterfaceHDA->Context = DeviceExtension;
346 
352  InterfaceHDA->FreeDmaBuffer = HDA_FreeDmaBuffer;
353  InterfaceHDA->FreeDmaEngine = HDA_FreeDmaEngine;
361 
366  }
367 
368  // FIXME
369  // implement support for GUID_HDAUDIO_BUS_INTERFACE_BDL
371  return STATUS_NOT_SUPPORTED;
372 }
PFREE_DMA_BUFFER FreeDmaBuffer
Definition: hdaudio.h:359
#define IN
Definition: typedefs.h:39
struct _HDAUDIO_DEVICE_INFORMATION HDAUDIO_DEVICE_INFORMATION
PHDA_CODEC_ENTRY Codec
Definition: hdaudbus.h:90
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
NTSTATUS NTAPI HDA_AllocateCaptureDmaEngine(IN PVOID _context, IN UCHAR CodecAddress, IN PHDAUDIO_STREAM_FORMAT StreamFormat, OUT PHANDLE Handle, OUT PHDAUDIO_CONVERTER_FORMAT ConverterFormat)
_In_ PIRP Irp
Definition: csq.h:116
VOID NTAPI HDA_InterfaceReference(PVOID BusContext)
static COORD Position
Definition: mouse.c:34
unsigned char * PUCHAR
Definition: retypes.h:3
PALLOCATE_RENDER_DMA_ENGINE AllocateRenderDmaEngine
Definition: hdaudio.h:356
struct HDA_PDO_DEVICE_EXTENSION * PHDA_PDO_DEVICE_EXTENSION
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI HDA_AllocateDmaBufferWithNotification(IN PVOID _context, IN HANDLE Handle, IN ULONG NotificationCount, IN SIZE_T RequestedBufferSize, OUT PMDL *BufferMdl, OUT PSIZE_T AllocatedBufferSize, OUT PSIZE_T OffsetFromFirstPage, OUT PUCHAR StreamId, OUT PULONG FifoSize)
PSET_DMA_ENGINE_STATE SetDmaEngineState
Definition: hdaudio.h:361
PDEVICE_OBJECT FDO
Definition: hdaudbus.h:92
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1223
PGET_LINK_POSITION_REGISTER GetLinkPositionRegister
Definition: hdaudio.h:363
PCHANGE_BANDWIDTH_ALLOCATION ChangeBandwidthAllocation
Definition: hdaudio.h:357
NTSTATUS NTAPI HDA_TransferCodecVerbs(IN PVOID _context, IN ULONG Count, IN OUT PHDAUDIO_CODEC_TRANSFER CodecTransfer, IN PHDAUDIO_TRANSFER_COMPLETE_CALLBACK Callback, IN PVOID Context)
NTSTATUS NTAPI HDA_SetDmaEngineState(IN PVOID _context, IN HDAUDIO_STREAM_STATE StreamState, IN ULONG NumberOfHandles, IN PHANDLE Handles)
PUNREGISTER_NOTIFICATION_EVENT UnregisterNotificationEvent
Definition: hdaudio.h:371
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:240
PINTERFACE_REFERENCE InterfaceReference
Definition: hdaudio.h:352
ULONG_PTR * PSIZE_T
Definition: typedefs.h:80
NTSTATUS NTAPI HDA_FreeDmaBufferWithNotification(IN PVOID _context, IN HANDLE Handle, IN PMDL BufferMdl, IN SIZE_T BufferSize)
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
VOID NTAPI HDA_GetWallClockRegister(IN PVOID _context, OUT PULONG *Wallclock)
#define FALSE
Definition: types.h:117
NTSTATUS NTAPI HDA_UnregisterNotificationEvent(IN PVOID _context, IN HANDLE Handle, IN PKEVENT NotificationEvent)
PALLOCATE_DMA_BUFFER AllocateDmaBuffer
Definition: hdaudio.h:358
#define MAX_CODEC_RESPONSES
Definition: driver.h:43
PUNREGISTER_EVENT_CALLBACK UnregisterEventCallback
Definition: hdaudio.h:365
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI HDA_UnregisterEventCallback(IN PVOID _context, IN UCHAR Tag)
NTSTATUS NTAPI HDA_AllocateRenderDmaEngine(IN PVOID _context, IN PHDAUDIO_STREAM_FORMAT StreamFormat, IN BOOLEAN Stripe, OUT PHANDLE Handle, OUT PHDAUDIO_CONVERTER_FORMAT ConverterFormat)
NTSTATUS NTAPI HDA_FreeDmaBuffer(IN PVOID _context, IN HANDLE Handle)
PGET_DEVICE_INFORMATION GetDeviceInformation
Definition: hdaudio.h:366
VOID NTAPI HDA_InterfaceDereference(PVOID BusContext)
UCHAR Minor
Definition: hdaudbus.h:50
_In_ HANDLE Handle
Definition: extypes.h:390
ULONG Responses[MAX_CODEC_RESPONSES]
Definition: hdaudbus.h:55
PFREE_DMA_ENGINE FreeDmaEngine
Definition: hdaudio.h:360
PREGISTER_NOTIFICATION_EVENT RegisterNotificationEvent
Definition: hdaudio.h:370
NTSTATUS NTAPI HDA_ChangeBandwidthAllocation(IN PVOID _context, IN HANDLE Handle, IN PHDAUDIO_STREAM_FORMAT StreamFormat, OUT PHDAUDIO_CONVERTER_FORMAT ConverterFormat)
VOID NTAPI HDA_GetResourceInformation(IN PVOID _context, OUT PUCHAR CodecAddress, OUT PUCHAR FunctionGroupStartNode)
NTSTATUS NTAPI HDA_FreeDmaEngine(IN PVOID _context, IN HANDLE Handle)
VOID HDA_SendVerbs(IN PDEVICE_OBJECT DeviceObject, IN PHDA_CODEC_ENTRY Codec, IN PULONG Verbs, OUT PULONG Responses, IN ULONG Count)
Definition: fdo.cpp:138
static const UCHAR Index[8]
Definition: usbohci.c:18
#define BufferSize
Definition: mmc.h:75
PALLOCATE_CAPTURE_DMA_ENGINE AllocateCaptureDmaEngine
Definition: hdaudio.h:355
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
PTRANSFER_CODEC_VERBS TransferCodecVerbs
Definition: hdaudio.h:354
unsigned char UCHAR
Definition: xmlstorage.h:181
PGET_RESOURCE_INFORMATION GetResourceInformation
Definition: hdaudio.h:367
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:454
NTSTATUS NTAPI HDA_AllocateDmaBuffer(IN PVOID _context, IN HANDLE Handle, IN SIZE_T RequestedBufferSize, OUT PMDL *BufferMdl, OUT PSIZE_T AllocatedBufferSize, OUT PUCHAR StreamId, OUT PULONG FifoSize)
NTSTATUS NTAPI HDA_RegisterNotificationEvent(PVOID _context, HANDLE Handle, IN PKEVENT NotificationEvent)
UCHAR Major
Definition: hdaudbus.h:49
PINTERFACE_DEREFERENCE InterfaceDereference
Definition: hdaudio.h:353
NTSTATUS HDA_PDOHandleQueryInterface(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
NTSTATUS NTAPI HDA_GetDeviceInformation(IN PVOID _context, OUT PHDAUDIO_DEVICE_INFORMATION DeviceInformation)
VOID(NTAPI * PHDAUDIO_UNSOLICITED_RESPONSE_CALLBACK)(HDAUDIO_CODEC_RESPONSE, PVOID)
Definition: hdaudio.h:95
PREGISTER_EVENT_CALLBACK RegisterEventCallback
Definition: hdaudio.h:364
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
ULONG_PTR SIZE_T
Definition: typedefs.h:80
PALLOCATE_DMA_BUFFER_WITH_NOTIFICATION AllocateDmaBufferWithNotification
Definition: hdaudio.h:368
PFREE_DMA_BUFFER_WITH_NOTIFICATION FreeDmaBufferWithNotification
Definition: hdaudio.h:369
PGET_WALL_CLOCK_REGISTER GetWallClockRegister
Definition: hdaudio.h:362
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
unsigned int * PULONG
Definition: retypes.h:1
UCHAR Addr
Definition: hdaudbus.h:53
PHDA_CODEC_AUDIO_GROUP AudioGroup
Definition: hdaudbus.h:91
enum _HDAUDIO_STREAM_STATE HDAUDIO_STREAM_STATE
#define DPRINT1
Definition: precomp.h:8
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
IN ULONG IN ULONG Tag
Definition: evtlib.h:159
NTSTATUS NTAPI HDA_RegisterEventCallback(IN PVOID _context, IN PHDAUDIO_UNSOLICITED_RESPONSE_CALLBACK Routine, IN PVOID Context, OUT PUCHAR Tag)
#define OUT
Definition: typedefs.h:40
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
unsigned int ULONG
Definition: retypes.h:1
#define UNIMPLEMENTED
Definition: debug.h:115
struct _HDAUDIO_BUS_INTERFACE_V2 * PHDAUDIO_BUS_INTERFACE_V2
VOID(NTAPI * PHDAUDIO_TRANSFER_COMPLETE_CALLBACK)(HDAUDIO_CODEC_TRANSFER *, PVOID)
Definition: hdaudio.h:90
NTSTATUS NTAPI HDA_GetLinkPositionRegister(IN PVOID _context, IN HANDLE Handle, OUT PULONG *Position)
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
return STATUS_SUCCESS
Definition: btrfs.c:3014
LPFNPSPCALLBACK Callback
Definition: desk.c:112
ULONG ResponseCount
Definition: hdaudbus.h:56