ReactOS  0.4.13-dev-100-gc8611ae
propertyhandler.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/backpln/portcls/propertyhandler.cpp
5  * PURPOSE: Pin property handler
6  * PROGRAMMER: Johannes Anderwald
7  */
8 
9 #include "private.hpp"
10 
11 #ifndef YDEBUG
12 #define NDEBUG
13 #endif
14 
15 #include <debug.h>
16 
21  IN OUT PVOID Data,
23  IN BOOL Global,
24  IN ISubdevice *SubDevice)
25 {
26  KSPIN_CINSTANCES * Instances;
27  KSP_PIN * Pin = (KSP_PIN*)Request;
28  ULONG FilterNecessary, FilterCurrent, FilterPossible, GlobalCurrent, GlobalPossible;
30 
31  if (Pin->PinId >= Descriptor->Factory.PinDescriptorCount)
32  {
33  IoStatus->Information = 0;
36  }
37 
38  Instances = (KSPIN_CINSTANCES*)Data;
39 
40  // check if the miniport supports the IPinCount interface
41  Status = SubDevice->PinCount(Pin->PinId, &FilterNecessary, &FilterCurrent, &FilterPossible, &GlobalCurrent, &GlobalPossible);
42 
43  if (NT_SUCCESS(Status))
44  {
45  if (Global)
46  {
47  Instances->PossibleCount = GlobalPossible;
48  Instances->CurrentCount = GlobalCurrent;
49  }
50  else
51  {
52  Instances->PossibleCount = FilterPossible;
53  Instances->CurrentCount = FilterCurrent;
54  }
55  }
56  else
57  {
58  if (Global)
59  Instances->PossibleCount = Descriptor->Factory.Instances[Pin->PinId].MaxGlobalInstanceCount;
60  else
61  Instances->PossibleCount = Descriptor->Factory.Instances[Pin->PinId].MaxFilterInstanceCount;
62 
63  Instances->CurrentCount = Descriptor->Factory.Instances[Pin->PinId].CurrentPinInstanceCount;
64  }
65 
66  IoStatus->Information = sizeof(KSPIN_CINSTANCES);
67  IoStatus->Status = STATUS_SUCCESS;
68  return STATUS_SUCCESS;
69 }
70 
75  IN OUT PVOID Data,
77  IN ISubdevice *SubDevice)
78 {
79  PULONG Result;
80  KSP_PIN * Pin = (KSP_PIN*)Request;
81  ULONG FilterNecessary, FilterCurrent, FilterPossible, GlobalCurrent, GlobalPossible;
83 
84  if (Pin->PinId >= Descriptor->Factory.PinDescriptorCount)
85  {
86  IoStatus->Information = 0;
89  }
90 
91  Result = (PULONG)Data;
92 
93 
94  // check if the miniport supports the IPinCount interface
95  Status = SubDevice->PinCount(Pin->PinId, &FilterNecessary, &FilterCurrent, &FilterPossible, &GlobalCurrent, &GlobalPossible);
96 
97  if (NT_SUCCESS(Status))
98  {
99  *Result = FilterNecessary;
100  }
101  else
102  {
103  *Result = Descriptor->Factory.Instances[Pin->PinId].MinFilterInstanceCount;
104  }
105 
106  IoStatus->Information = sizeof(ULONG);
107  IoStatus->Status = STATUS_SUCCESS;
108  return STATUS_SUCCESS;
109 }
110 
111 NTSTATUS
115  IN OUT PVOID Data,
118  IN ISubdevice *SubDevice)
119 {
120  KSP_PIN * Pin = (KSP_PIN*)Request;
121  PKSMULTIPLE_ITEM MultipleItem;
122  PKSDATARANGE DataRange;
124  ULONG Index, Length;
125 
126  // Access parameters
127  MultipleItem = (PKSMULTIPLE_ITEM)(Pin + 1);
128  DataRange = (PKSDATARANGE)(MultipleItem + 1);
129 
130  for(Index = 0; Index < MultipleItem->Count; Index++)
131  {
132  // Call miniport's proprietary handler
133  PC_ASSERT(Descriptor->Factory.KsPinDescriptor[Pin->PinId].DataRangesCount);
134  PC_ASSERT(Descriptor->Factory.KsPinDescriptor[Pin->PinId].DataRanges[0]);
135  Status = SubDevice->DataRangeIntersection(Pin->PinId, DataRange, (PKSDATARANGE)Descriptor->Factory.KsPinDescriptor[Pin->PinId].DataRanges[0],
136  DataLength, Data, &Length);
137 
138  if (Status == STATUS_SUCCESS)
139  {
140  IoStatus->Information = Length;
141  break;
142  }
143  DataRange = (PKSDATARANGE)((PUCHAR)DataRange + DataRange->FormatSize);
144  }
145 
146  IoStatus->Status = Status;
147  return Status;
148 }
149 
150 NTSTATUS
154  IN ULONG RequestLength,
155  IN OUT PVOID Data,
158 {
159  PKSP_PIN Pin;
161  //PKSPIN_PHYSICALCONNECTION Connection;
163 
164  // get pin
165  Pin = (PKSP_PIN)Request;
166 
167  if (RequestLength < sizeof(KSP_PIN))
168  {
169  // input buffer must be at least sizeof KSP_PIN
170  DPRINT("input length too small\n");
172  }
173 
174  if (IsListEmpty(&Descriptor->PhysicalConnectionList))
175  {
176  DPRINT("no connection\n");
177  return STATUS_NOT_FOUND;
178  }
179 
180  // get first item
181  Entry = Descriptor->PhysicalConnectionList.Flink;
182 
183  do
184  {
186 
187  if (ConEntry->FromPin == Pin->PinId)
188  {
189  //Connection = (PKSPIN_PHYSICALCONNECTION)Data;
190  DPRINT("FoundEntry %S Size %u\n", ConEntry->Connection.SymbolicLinkName, ConEntry->Connection.Size);
191  IoStatus->Information = ConEntry->Connection.Size;
192 
193  if (!DataLength)
194  {
195  IoStatus->Information = ConEntry->Connection.Size;
196  return STATUS_MORE_ENTRIES;
197  }
198 
199  if (DataLength < ConEntry->Connection.Size)
200  {
202  }
203 
204  RtlMoveMemory(Data, &ConEntry->Connection, ConEntry->Connection.Size);
205  return STATUS_SUCCESS;
206  }
207 
208  // move to next item
209  Entry = Entry->Flink;
210  }while(Entry != &Descriptor->PhysicalConnectionList);
211 
212  IoStatus->Information = 0;
213  return STATUS_NOT_FOUND;
214 }
215 
216 NTSTATUS
217 NTAPI
219  IN PIRP Irp,
221  IN OUT PVOID Data)
222 {
223  PIO_STACK_LOCATION IoStack;
224  //PKSOBJECT_CREATE_ITEM CreateItem;
226  IIrpTarget * IrpTarget;
227  IPort *Port;
228  ISubdevice *SubDevice;
229  PDISPATCH_CONTEXT DispatchContext;
230 
232 
233  Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
235 
236  // get current irp stack
238 
239  // get dispatch context
240  DispatchContext = (PDISPATCH_CONTEXT)IoStack->FileObject->FsContext;
241 
242  // Get the IrpTarget
243  IrpTarget = DispatchContext->Target;
244  PC_ASSERT(IrpTarget);
245 
246  // Get the parent
247  Status = IrpTarget->QueryInterface(IID_IPort, (PVOID*)&Port);
248  if (!NT_SUCCESS(Status))
249  {
250  DPRINT("Failed to obtain IPort interface from filter\n");
251  Irp->IoStatus.Information = 0;
252  Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
253  return STATUS_UNSUCCESSFUL;
254  }
255 
256  // Get private ISubdevice interface
257  Status = Port->QueryInterface(IID_ISubdevice, (PVOID*)&SubDevice);
258  if (!NT_SUCCESS(Status))
259  {
260  DPRINT("Failed to obtain ISubdevice interface from port driver\n");
261  DbgBreakPoint();
262  while(TRUE);
263  }
264 
265  // get current stack location
267 
268  switch(Request->Id)
269  {
277  case KSPROPERTY_PIN_NAME:
279  Status = KsPinPropertyHandler(Irp, Request, Data, Descriptor->Factory.PinDescriptorCount, Descriptor->Factory.KsPinDescriptor);
280  break;
282  Status = HandlePropertyInstances(&Irp->IoStatus, Request, Data, Descriptor, TRUE, SubDevice);
283  break;
285  Status = HandlePropertyInstances(&Irp->IoStatus, Request, Data, Descriptor, FALSE, SubDevice);
286  break;
289  break;
290 
292  Status = HandleDataIntersection(&Irp->IoStatus, Request, Data, IoStack->Parameters.DeviceIoControl.OutputBufferLength, Descriptor, SubDevice);
293  break;
295  Status = HandlePhysicalConnection(&Irp->IoStatus, Request, IoStack->Parameters.DeviceIoControl.InputBufferLength, Data, IoStack->Parameters.DeviceIoControl.OutputBufferLength, Descriptor);
296  break;
300  break;
301  default:
304  }
305 
306  // Release reference
307  Port->Release();
308 
309  // Release subdevice reference
310  SubDevice->Release();
311 
312  return Status;
313 }
314 
315 NTSTATUS
316 NTAPI
318  IN PIRP Irp,
320  IN OUT PVOID Data)
321 {
323 
324  Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
325 
326  return KsTopologyPropertyHandler(Irp, Request, Data, Descriptor->Topology);
327 }
ULONG Count
Definition: ks.h:2010
CPPORT Port[4]
Definition: headless.c:34
#define IN
Definition: typedefs.h:38
#define TRUE
Definition: types.h:120
#define PC_ASSERT(exp)
Definition: usbehci.h:17
struct _Entry Entry
Definition: kefuncs.h:640
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI TopologyPropertyHandler(IN PIRP Irp, IN PKSIDENTIFIER Request, IN OUT PVOID Data)
WCHAR SymbolicLinkName[1]
Definition: ks.h:688
void DbgBreakPoint()
Definition: mach.c:558
UNICODE_STRING Global
Definition: symlink.c:37
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
_In_ NDIS_HANDLE _In_ PNDIS_REQUEST Request
Definition: ndis.h:5155
IIrpTarget * Target
Definition: private.hpp:431
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
unsigned int BOOL
Definition: ntddk_ex.h:94
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
void DPRINT(...)
Definition: polytest.cpp:61
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
KSPIN_PHYSICALCONNECTION Connection
Definition: interfaces.hpp:183
#define STATUS_NOT_FOUND
Definition: shellext.h:67
struct DISPATCH_CONTEXT * PDISPATCH_CONTEXT
NTSTATUS HandleNecessaryPropertyInstances(IN PIO_STATUS_BLOCK IoStatus, IN PKSIDENTIFIER Request, IN OUT PVOID Data, IN PSUBDEVICE_DESCRIPTOR Descriptor, IN ISubdevice *SubDevice)
Definition: ks.h:672
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:415
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG PossibleCount
Definition: ks.h:681
static const UCHAR Index[8]
Definition: usbohci.c:18
nsrefcnt Release()
KSDDKAPI NTSTATUS NTAPI KsPinPropertyHandler(IN PIRP Irp, IN PKSPROPERTY Property, IN OUT PVOID Data, IN ULONG DescriptorsCount, IN const KSPIN_DESCRIPTOR *Descriptor)
Definition: connectivity.c:666
struct PHYSICAL_CONNECTION_ENTRY * PPHYSICAL_CONNECTION_ENTRY
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
NTSTATUS HandlePropertyInstances(IN PIO_STATUS_BLOCK IoStatus, IN PKSIDENTIFIER Request, IN OUT PVOID Data, IN PSUBDEVICE_DESCRIPTOR Descriptor, IN BOOL Global, IN ISubdevice *SubDevice)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
ULONG FromPin
Definition: interfaces.hpp:182
KSDDKAPI NTSTATUS NTAPI KsTopologyPropertyHandler(IN PIRP Irp, IN PKSPROPERTY Property, IN OUT PVOID Data, IN const KSTOPOLOGY *Topology)
Definition: topology.c:144
NTSTATUS NTAPI PinPropertyHandler(IN PIRP Irp, IN PKSIDENTIFIER Request, IN OUT PVOID Data)
struct KSMULTIPLE_ITEM * PKSMULTIPLE_ITEM
NTSTATUS HandlePhysicalConnection(IN PIO_STATUS_BLOCK IoStatus, IN PKSIDENTIFIER Request, IN ULONG RequestLength, IN OUT PVOID Data, IN ULONG DataLength, IN PSUBDEVICE_DESCRIPTOR Descriptor)
Definition: typedefs.h:117
#define STATUS_MORE_ENTRIES
Definition: udferr_usr.h:124
Status
Definition: gdiplustypes.h:24
union KSDATAFORMAT * PKSDATARANGE
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
Definition: interfaces.hpp:179
PFILE_OBJECT FileObject
Definition: iotypes.h:2812
#define STATUS_NO_MATCH
Definition: ntstatus.h:737
unsigned int * PULONG
Definition: retypes.h:1
ULONG CurrentCount
Definition: ks.h:682
struct KSP_PIN * PKSP_PIN
#define OUT
Definition: typedefs.h:39
unsigned int ULONG
Definition: retypes.h:1
#define UNIMPLEMENTED
Definition: debug.h:114
NTSTATUS HandleDataIntersection(IN PIO_STATUS_BLOCK IoStatus, IN PKSIDENTIFIER Request, IN OUT PVOID Data, IN ULONG DataLength, IN PSUBDEVICE_DESCRIPTOR Descriptor, IN ISubdevice *SubDevice)
_Must_inspect_result_ _Out_writes_to_ DataLength PHIDP_DATA _Inout_ PULONG DataLength
Definition: hidpi.h:333
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
return STATUS_SUCCESS
Definition: btrfs.c:2725
struct SUBDEVICE_DESCRIPTOR * PSUBDEVICE_DESCRIPTOR
base of all file and directory entries
Definition: entries.h:82
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966