- Implement a common property handler for filter property requests
[reactos.git] / reactos / drivers / wdm / audio / sysaudio / pin.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Kernel Streaming
4 * FILE: drivers/wdm/audio/sysaudio/deviface.c
5 * PURPOSE: System Audio graph builder
6 * PROGRAMMER: Johannes Anderwald
7 */
8
9 #include <ntifs.h>
10 #include <ntddk.h>
11 #include <portcls.h>
12 #include <ks.h>
13 #include <ksmedia.h>
14 #include <math.h>
15 #define YDEBUG
16 #include <debug.h>
17 #include "sysaudio.h"
18
19 NTSTATUS
20 NTAPI
21 Pin_fnDeviceIoControl(
22 PDEVICE_OBJECT DeviceObject,
23 PIRP Irp)
24 {
25 PDISPATCH_CONTEXT Context;
26 NTSTATUS Status;
27 ULONG BytesReturned;
28 PIO_STACK_LOCATION IoStack;
29
30 DPRINT1("Pin_fnDeviceIoControl called DeviceObject %p Irp %p\n", DeviceObject);
31
32 IoStack = IoGetCurrentIrpStackLocation(Irp);
33
34 Context = (PDISPATCH_CONTEXT)IoStack->FileObject->FsContext2;
35 ASSERT(Context);
36
37 Status = KsSynchronousIoControlDevice(Context->FileObject, KernelMode, IoStack->Parameters.DeviceIoControl.IoControlCode,
38 IoStack->Parameters.DeviceIoControl.Type3InputBuffer,
39 IoStack->Parameters.DeviceIoControl.InputBufferLength,
40 Irp->UserBuffer,
41 IoStack->Parameters.DeviceIoControl.OutputBufferLength,
42 &BytesReturned);
43
44 DPRINT1("Status %x\n", Status);
45
46 Irp->IoStatus.Information = BytesReturned;
47 Irp->IoStatus.Status = Status;
48 IoCompleteRequest(Irp, IO_NO_INCREMENT);
49 return Status;
50 }
51
52 NTSTATUS
53 NTAPI
54 Pin_fnRead(
55 PDEVICE_OBJECT DeviceObject,
56 PIRP Irp)
57 {
58 DPRINT1("Pin_fnRead called DeviceObject %p Irp %p\n", DeviceObject);
59
60 return STATUS_SUCCESS;
61 }
62
63 NTSTATUS
64 NTAPI
65 PinWriteCompletionRoutine(
66 IN PDEVICE_OBJECT DeviceObject,
67 IN PIRP Irp,
68 IN PVOID Context)
69 {
70 PIRP CIrp = (PIRP)Context;
71
72 CIrp->IoStatus.Status = STATUS_SUCCESS;
73 CIrp->IoStatus.Information = 0;
74 IoCompleteRequest(CIrp, IO_NO_INCREMENT);
75 return STATUS_SUCCESS;
76 }
77
78 NTSTATUS
79 NTAPI
80 Pin_fnWrite(
81 PDEVICE_OBJECT DeviceObject,
82 PIRP Irp)
83 {
84 PDISPATCH_CONTEXT Context;
85 PIO_STACK_LOCATION IoStack;
86 ULONG BytesReturned;
87 NTSTATUS Status;
88
89 DPRINT1("Pin_fnWrite called DeviceObject %p Irp %p\n", DeviceObject);
90
91 IoStack = IoGetCurrentIrpStackLocation(Irp);
92
93 Context = (PDISPATCH_CONTEXT)IoStack->FileObject->FsContext2;
94 ASSERT(Context);
95
96 Status = KsSynchronousIoControlDevice(Context->FileObject, KernelMode, IOCTL_KS_WRITE_STREAM,
97 IoStack->Parameters.DeviceIoControl.Type3InputBuffer,
98 IoStack->Parameters.DeviceIoControl.InputBufferLength,
99 Irp->UserBuffer,
100 IoStack->Parameters.DeviceIoControl.OutputBufferLength,
101 &BytesReturned);
102
103 Irp->IoStatus.Information = BytesReturned;
104 Irp->IoStatus.Status = Status;
105 IoCompleteRequest(Irp, IO_NO_INCREMENT);
106 return Status;
107 }
108
109 NTSTATUS
110 NTAPI
111 Pin_fnFlush(
112 PDEVICE_OBJECT DeviceObject,
113 PIRP Irp)
114 {
115 DPRINT1("Pin_fnFlush called DeviceObject %p Irp %p\n", DeviceObject);
116
117 return STATUS_SUCCESS;
118 }
119
120 NTSTATUS
121 NTAPI
122 Pin_fnClose(
123 PDEVICE_OBJECT DeviceObject,
124 PIRP Irp)
125 {
126 DPRINT1("Pin_fnClose called DeviceObject %p Irp %p\n", DeviceObject);
127
128
129 return STATUS_SUCCESS;
130 }
131
132 NTSTATUS
133 NTAPI
134 Pin_fnQuerySecurity(
135 PDEVICE_OBJECT DeviceObject,
136 PIRP Irp)
137 {
138 DPRINT1("Pin_fnQuerySecurity called DeviceObject %p Irp %p\n", DeviceObject);
139
140
141 return STATUS_SUCCESS;
142 }
143
144 NTSTATUS
145 NTAPI
146 Pin_fnSetSecurity(
147 PDEVICE_OBJECT DeviceObject,
148 PIRP Irp)
149 {
150
151 DPRINT1("Pin_fnSetSecurity called DeviceObject %p Irp %p\n", DeviceObject);
152
153 return STATUS_SUCCESS;
154 }
155
156 BOOLEAN
157 NTAPI
158 Pin_fnFastDeviceIoControl(
159 PFILE_OBJECT FileObject,
160 BOOLEAN Wait,
161 PVOID InputBuffer,
162 ULONG InputBufferLength,
163 PVOID OutputBuffer,
164 ULONG OutputBufferLength,
165 ULONG IoControlCode,
166 PIO_STATUS_BLOCK IoStatus,
167 PDEVICE_OBJECT DeviceObject)
168 {
169 DPRINT1("Pin_fnFastDeviceIoControl called DeviceObject %p Irp %p\n", DeviceObject);
170
171
172 return FALSE;
173 }
174
175
176 BOOLEAN
177 NTAPI
178 Pin_fnFastRead(
179 PFILE_OBJECT FileObject,
180 PLARGE_INTEGER FileOffset,
181 ULONG Length,
182 BOOLEAN Wait,
183 ULONG LockKey,
184 PVOID Buffer,
185 PIO_STATUS_BLOCK IoStatus,
186 PDEVICE_OBJECT DeviceObject)
187 {
188 DPRINT1("Pin_fnFastRead called DeviceObject %p Irp %p\n", DeviceObject);
189
190 return FALSE;
191
192 }
193
194 BOOLEAN
195 NTAPI
196 Pin_fnFastWrite(
197 PFILE_OBJECT FileObject,
198 PLARGE_INTEGER FileOffset,
199 ULONG Length,
200 BOOLEAN Wait,
201 ULONG LockKey,
202 PVOID Buffer,
203 PIO_STATUS_BLOCK IoStatus,
204 PDEVICE_OBJECT DeviceObject)
205 {
206 DPRINT1("Pin_fnFastWrite called DeviceObject %p Irp %p\n", DeviceObject);
207
208 return FALSE;
209 }
210
211 static KSDISPATCH_TABLE PinTable =
212 {
213 Pin_fnDeviceIoControl,
214 Pin_fnRead,
215 Pin_fnWrite,
216 Pin_fnFlush,
217 Pin_fnClose,
218 Pin_fnQuerySecurity,
219 Pin_fnSetSecurity,
220 Pin_fnFastDeviceIoControl,
221 Pin_fnFastRead,
222 Pin_fnFastWrite,
223 };
224
225 NTSTATUS
226 CreateDispatcher(
227 IN PIRP Irp)
228 {
229 NTSTATUS Status;
230 KSOBJECT_HEADER ObjectHeader;
231
232 /* allocate object header */
233 Status = KsAllocateObjectHeader(&ObjectHeader, 0, NULL, Irp, &PinTable);
234 return Status;
235 }