1c2c66affSColin Finck /*
2c2c66affSColin Finck  * COPYRIGHT:       See COPYING in the top level directory
3c2c66affSColin Finck  * PROJECT:         ReactOS Kernel Streaming
4c2c66affSColin Finck  * FILE:            drivers/wdm/audio/backpln/portcls/port_dmus.cpp
5c2c66affSColin Finck  * PURPOSE:         DirectMusic Port driver
6c2c66affSColin Finck  * PROGRAMMER:      Johannes Anderwald
7c2c66affSColin Finck  */
8c2c66affSColin Finck 
9c2c66affSColin Finck #include "private.hpp"
10c2c66affSColin Finck 
11c2c66affSColin Finck #define NDEBUG
12c2c66affSColin Finck #include <debug.h>
13c2c66affSColin Finck 
14*6e97b431SVictor Perevertkin class CPortDMus : public CUnknownImpl<IPortDMus, ISubdevice>
15c2c66affSColin Finck {
16c2c66affSColin Finck public:
17c2c66affSColin Finck     STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface);
18c2c66affSColin Finck 
19c2c66affSColin Finck     IMP_IPortDMus;
20c2c66affSColin Finck     IMP_ISubdevice;
CPortDMus(IUnknown * OuterUnknown)21c2c66affSColin Finck     CPortDMus(IUnknown *OuterUnknown){}
~CPortDMus()22c2c66affSColin Finck     virtual ~CPortDMus(){}
23c2c66affSColin Finck 
24c2c66affSColin Finck protected:
25c2c66affSColin Finck 
26c2c66affSColin Finck     BOOL m_bInitialized;
27c2c66affSColin Finck     IMiniportDMus * m_pMiniport;
28c2c66affSColin Finck     IMiniportMidi * m_pMiniportMidi;
29c2c66affSColin Finck     DEVICE_OBJECT * m_pDeviceObject;
30c2c66affSColin Finck     PSERVICEGROUP m_ServiceGroup;
31c2c66affSColin Finck     PPINCOUNT m_pPinCount;
32c2c66affSColin Finck     PPOWERNOTIFY m_pPowerNotify;
33c2c66affSColin Finck     PPORTFILTERDMUS m_Filter;
34c2c66affSColin Finck 
35c2c66affSColin Finck     PPCFILTER_DESCRIPTOR m_pDescriptor;
36c2c66affSColin Finck     PSUBDEVICE_DESCRIPTOR m_SubDeviceDescriptor;
37c2c66affSColin Finck 
38c2c66affSColin Finck     friend VOID GetDMusMiniport(IN IPortDMus * iface, IN PMINIPORTDMUS * Miniport, IN PMINIPORTMIDI * MidiMiniport);
39c2c66affSColin Finck 
40c2c66affSColin Finck };
41c2c66affSColin Finck 
42c2c66affSColin Finck static GUID InterfaceGuids[3] =
43c2c66affSColin Finck {
44c2c66affSColin Finck     {
45c2c66affSColin Finck         /// KS_CATEGORY_AUDIO
46c2c66affSColin Finck         0x6994AD04, 0x93EF, 0x11D0, {0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}
47c2c66affSColin Finck     },
48c2c66affSColin Finck     {
49c2c66affSColin Finck         /// KS_CATEGORY_RENDER
50c2c66affSColin Finck         0x65E8773E, 0x8F56, 0x11D0, {0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}
51c2c66affSColin Finck     },
52c2c66affSColin Finck     {
53c2c66affSColin Finck         /// KS_CATEGORY_CAPTURE
54c2c66affSColin Finck         0x65E8773D, 0x8F56, 0x11D0, {0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}
55c2c66affSColin Finck     }
56c2c66affSColin Finck };
57c2c66affSColin Finck 
58c2c66affSColin Finck DEFINE_KSPROPERTY_TOPOLOGYSET(PortFilterDMusTopologySet, TopologyPropertyHandler);
59c2c66affSColin Finck DEFINE_KSPROPERTY_PINPROPOSEDATAFORMAT(PortFilterDMusPinSet, PinPropertyHandler, PinPropertyHandler, PinPropertyHandler);
60c2c66affSColin Finck 
61c2c66affSColin Finck KSPROPERTY_SET PortDMusPropertySet[] =
62c2c66affSColin Finck {
63c2c66affSColin Finck     {
64c2c66affSColin Finck         &KSPROPSETID_Topology,
65c2c66affSColin Finck         sizeof(PortFilterDMusTopologySet) / sizeof(KSPROPERTY_ITEM),
66c2c66affSColin Finck         (const KSPROPERTY_ITEM*)&PortFilterDMusTopologySet,
67c2c66affSColin Finck         0,
68c2c66affSColin Finck         NULL
69c2c66affSColin Finck     },
70c2c66affSColin Finck     {
71c2c66affSColin Finck         &KSPROPSETID_Pin,
72c2c66affSColin Finck         sizeof(PortFilterDMusPinSet) / sizeof(KSPROPERTY_ITEM),
73c2c66affSColin Finck         (const KSPROPERTY_ITEM*)&PortFilterDMusPinSet,
74c2c66affSColin Finck         0,
75c2c66affSColin Finck         NULL
76c2c66affSColin Finck     }
77c2c66affSColin Finck };
78c2c66affSColin Finck 
79c2c66affSColin Finck //---------------------------------------------------------------
80c2c66affSColin Finck // IUnknown interface functions
81c2c66affSColin Finck //
82c2c66affSColin Finck 
83c2c66affSColin Finck NTSTATUS
84c2c66affSColin Finck NTAPI
QueryInterface(IN REFIID refiid,OUT PVOID * Output)85c2c66affSColin Finck CPortDMus::QueryInterface(
86c2c66affSColin Finck     IN  REFIID refiid,
87c2c66affSColin Finck     OUT PVOID* Output)
88c2c66affSColin Finck {
89c2c66affSColin Finck     UNICODE_STRING GuidString;
90c2c66affSColin Finck 
91c2c66affSColin Finck     if (IsEqualGUIDAligned(refiid, IID_IPortDMus) ||
92c2c66affSColin Finck         IsEqualGUIDAligned(refiid, IID_IPortMidi) ||
93c2c66affSColin Finck         IsEqualGUIDAligned(refiid, IID_IPort) ||
94c2c66affSColin Finck         IsEqualGUIDAligned(refiid, IID_IUnknown))
95c2c66affSColin Finck     {
96c2c66affSColin Finck         *Output = PVOID(PUNKNOWN((IPortDMus*)this));
97c2c66affSColin Finck         PUNKNOWN(*Output)->AddRef();
98c2c66affSColin Finck         return STATUS_SUCCESS;
99c2c66affSColin Finck     }
100c2c66affSColin Finck     else if (IsEqualGUIDAligned(refiid, IID_ISubdevice))
101c2c66affSColin Finck     {
102c2c66affSColin Finck         *Output = PVOID(PSUBDEVICE(this));
103c2c66affSColin Finck         PUNKNOWN(*Output)->AddRef();
104c2c66affSColin Finck         return STATUS_SUCCESS;
105c2c66affSColin Finck     }
106c2c66affSColin Finck     else if (IsEqualGUIDAligned(refiid, IID_IDrmPort) ||
107c2c66affSColin Finck              IsEqualGUIDAligned(refiid, IID_IDrmPort2))
108c2c66affSColin Finck     {
109c2c66affSColin Finck         return NewIDrmPort((PDRMPORT2*)Output);
110c2c66affSColin Finck     }
111c2c66affSColin Finck     else if (IsEqualGUIDAligned(refiid, IID_IPortClsVersion))
112c2c66affSColin Finck     {
113c2c66affSColin Finck         return NewPortClsVersion((PPORTCLSVERSION*)Output);
114c2c66affSColin Finck     }
115c2c66affSColin Finck     else if (IsEqualGUIDAligned(refiid, IID_IUnregisterSubdevice))
116c2c66affSColin Finck     {
117c2c66affSColin Finck         return NewIUnregisterSubdevice((PUNREGISTERSUBDEVICE*)Output);
118c2c66affSColin Finck     }
119c2c66affSColin Finck     else if (IsEqualGUIDAligned(refiid, IID_IUnregisterPhysicalConnection))
120c2c66affSColin Finck     {
121c2c66affSColin Finck         return NewIUnregisterPhysicalConnection((PUNREGISTERPHYSICALCONNECTION*)Output);
122c2c66affSColin Finck     }
123c2c66affSColin Finck 
124c2c66affSColin Finck     if (RtlStringFromGUID(refiid, &GuidString) == STATUS_SUCCESS)
125c2c66affSColin Finck     {
126c2c66affSColin Finck         DPRINT("IPortMidi_fnQueryInterface no interface!!! iface %S\n", GuidString.Buffer);
127c2c66affSColin Finck         RtlFreeUnicodeString(&GuidString);
128c2c66affSColin Finck     }
129c2c66affSColin Finck     return STATUS_UNSUCCESSFUL;
130c2c66affSColin Finck }
131c2c66affSColin Finck 
132c2c66affSColin Finck //---------------------------------------------------------------
133c2c66affSColin Finck // IPort interface functions
134c2c66affSColin Finck //
135c2c66affSColin Finck 
136c2c66affSColin Finck NTSTATUS
137c2c66affSColin Finck NTAPI
GetDeviceProperty(IN DEVICE_REGISTRY_PROPERTY DeviceRegistryProperty,IN ULONG BufferLength,OUT PVOID PropertyBuffer,OUT PULONG ReturnLength)138c2c66affSColin Finck CPortDMus::GetDeviceProperty(
139c2c66affSColin Finck     IN DEVICE_REGISTRY_PROPERTY  DeviceRegistryProperty,
140c2c66affSColin Finck     IN ULONG  BufferLength,
141c2c66affSColin Finck     OUT PVOID  PropertyBuffer,
142c2c66affSColin Finck     OUT PULONG  ReturnLength)
143c2c66affSColin Finck {
144c2c66affSColin Finck     PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
145c2c66affSColin Finck 
146c2c66affSColin Finck     if (!m_bInitialized)
147c2c66affSColin Finck     {
148c2c66affSColin Finck         DPRINT("IPortDMus_fnNewRegistryKey called w/o initialized\n");
149c2c66affSColin Finck         return STATUS_UNSUCCESSFUL;
150c2c66affSColin Finck     }
151c2c66affSColin Finck 
152c2c66affSColin Finck     return IoGetDeviceProperty(m_pDeviceObject, DeviceRegistryProperty, BufferLength, PropertyBuffer, ReturnLength);
153c2c66affSColin Finck }
154c2c66affSColin Finck 
155c2c66affSColin Finck NTSTATUS
156c2c66affSColin Finck NTAPI
Init(IN PDEVICE_OBJECT DeviceObject,IN PIRP Irp,IN PUNKNOWN UnknownMiniport,IN PUNKNOWN UnknownAdapter OPTIONAL,IN PRESOURCELIST ResourceList)157c2c66affSColin Finck CPortDMus::Init(
158c2c66affSColin Finck     IN PDEVICE_OBJECT  DeviceObject,
159c2c66affSColin Finck     IN PIRP  Irp,
160c2c66affSColin Finck     IN PUNKNOWN  UnknownMiniport,
161c2c66affSColin Finck     IN PUNKNOWN  UnknownAdapter  OPTIONAL,
162c2c66affSColin Finck     IN PRESOURCELIST  ResourceList)
163c2c66affSColin Finck {
164c2c66affSColin Finck     IMiniportDMus * Miniport = NULL;
165c2c66affSColin Finck     IMiniportMidi * MidiMiniport = NULL;
166c2c66affSColin Finck     NTSTATUS Status;
167c2c66affSColin Finck     PSERVICEGROUP ServiceGroup = NULL;
168c2c66affSColin Finck     PPINCOUNT PinCount;
169c2c66affSColin Finck     PPOWERNOTIFY PowerNotify;
170c2c66affSColin Finck 
171c2c66affSColin Finck     PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
172c2c66affSColin Finck 
173c2c66affSColin Finck     if (m_bInitialized)
174c2c66affSColin Finck     {
175c2c66affSColin Finck         DPRINT("IPortDMus_Init called again\n");
176c2c66affSColin Finck         return STATUS_SUCCESS;
177c2c66affSColin Finck     }
178c2c66affSColin Finck 
179c2c66affSColin Finck     Status = UnknownMiniport->QueryInterface(IID_IMiniportDMus, (PVOID*)&Miniport);
180c2c66affSColin Finck     if (!NT_SUCCESS(Status))
181c2c66affSColin Finck     {
182c2c66affSColin Finck         // check for legacy interface
183c2c66affSColin Finck         Status = UnknownMiniport->QueryInterface(IID_IMiniportMidi, (PVOID*)&MidiMiniport);
184c2c66affSColin Finck         if (!NT_SUCCESS(Status))
185c2c66affSColin Finck         {
186c2c66affSColin Finck             DPRINT("IPortDMus_Init called with invalid IMiniport adapter\n");
187c2c66affSColin Finck             return STATUS_INVALID_PARAMETER;
188c2c66affSColin Finck         }
189c2c66affSColin Finck     }
190c2c66affSColin Finck 
191c2c66affSColin Finck     // Initialize port object
192c2c66affSColin Finck     m_pMiniport = Miniport;
193c2c66affSColin Finck     m_pMiniportMidi = MidiMiniport;
194c2c66affSColin Finck     m_pDeviceObject = DeviceObject;
195c2c66affSColin Finck     m_bInitialized = TRUE;
196c2c66affSColin Finck 
197c2c66affSColin Finck     if (Miniport)
198c2c66affSColin Finck     {
199c2c66affSColin Finck         // initialize IMiniportDMus
200c2c66affSColin Finck         Status = Miniport->Init(UnknownAdapter, ResourceList, this, &ServiceGroup);
201c2c66affSColin Finck         if (!NT_SUCCESS(Status))
202c2c66affSColin Finck         {
203c2c66affSColin Finck             DPRINT("IMiniportDMus_Init failed with %x\n", Status);
204c2c66affSColin Finck             m_bInitialized = FALSE;
205c2c66affSColin Finck             return Status;
206c2c66affSColin Finck         }
207c2c66affSColin Finck 
208c2c66affSColin Finck         // get the miniport device descriptor
209c2c66affSColin Finck         Status = Miniport->GetDescription(&m_pDescriptor);
210c2c66affSColin Finck         if (!NT_SUCCESS(Status))
211c2c66affSColin Finck         {
212c2c66affSColin Finck             DPRINT("failed to get description\n");
213c2c66affSColin Finck             Miniport->Release();
214c2c66affSColin Finck             m_bInitialized = FALSE;
215c2c66affSColin Finck             return Status;
216c2c66affSColin Finck         }
217c2c66affSColin Finck 
218c2c66affSColin Finck         // increment reference on miniport adapter
219c2c66affSColin Finck         Miniport->AddRef();
220c2c66affSColin Finck 
221c2c66affSColin Finck     }
222c2c66affSColin Finck     else
223c2c66affSColin Finck     {
224c2c66affSColin Finck         // initialize IMiniportMidi
225c2c66affSColin Finck         Status = MidiMiniport->Init(UnknownAdapter, ResourceList, (IPortMidi*)this, &ServiceGroup);
226c2c66affSColin Finck         if (!NT_SUCCESS(Status))
227c2c66affSColin Finck         {
228c2c66affSColin Finck             DPRINT("IMiniportMidi_Init failed with %x\n", Status);
229c2c66affSColin Finck             m_bInitialized = FALSE;
230c2c66affSColin Finck             return Status;
231c2c66affSColin Finck         }
232c2c66affSColin Finck 
233c2c66affSColin Finck         // get the miniport device descriptor
234c2c66affSColin Finck         Status = MidiMiniport->GetDescription(&m_pDescriptor);
235c2c66affSColin Finck         if (!NT_SUCCESS(Status))
236c2c66affSColin Finck         {
237c2c66affSColin Finck             DPRINT("failed to get description\n");
238c2c66affSColin Finck             MidiMiniport->Release();
239c2c66affSColin Finck             m_bInitialized = FALSE;
240c2c66affSColin Finck             return Status;
241c2c66affSColin Finck         }
242c2c66affSColin Finck 
243c2c66affSColin Finck         // increment reference on miniport adapter
244c2c66affSColin Finck         MidiMiniport->AddRef();
245c2c66affSColin Finck     }
246c2c66affSColin Finck 
247c2c66affSColin Finck     // create the subdevice descriptor
248c2c66affSColin Finck     Status = PcCreateSubdeviceDescriptor(&m_SubDeviceDescriptor,
249c2c66affSColin Finck                                          3,
250c2c66affSColin Finck                                          InterfaceGuids,
251c2c66affSColin Finck                                          0,
252c2c66affSColin Finck                                          NULL,
253c2c66affSColin Finck                                          2,
254c2c66affSColin Finck                                          PortDMusPropertySet,
255c2c66affSColin Finck                                          0,
256c2c66affSColin Finck                                          0,
257c2c66affSColin Finck                                          0,
258c2c66affSColin Finck                                          NULL,
259c2c66affSColin Finck                                          0,
260c2c66affSColin Finck                                          NULL,
261c2c66affSColin Finck                                          m_pDescriptor);
262c2c66affSColin Finck 
263c2c66affSColin Finck     if (!NT_SUCCESS(Status))
264c2c66affSColin Finck     {
265c2c66affSColin Finck         DPRINT("Failed to create descriptor\n");
266c2c66affSColin Finck 
267c2c66affSColin Finck         if (Miniport)
268c2c66affSColin Finck             Miniport->Release();
269c2c66affSColin Finck         else
270c2c66affSColin Finck             MidiMiniport->Release();
271c2c66affSColin Finck 
272c2c66affSColin Finck         m_bInitialized = FALSE;
273c2c66affSColin Finck         return Status;
274c2c66affSColin Finck     }
275c2c66affSColin Finck 
276c2c66affSColin Finck     if (m_ServiceGroup == NULL && ServiceGroup)
277c2c66affSColin Finck     {
278c2c66affSColin Finck         // register service group
279c2c66affSColin Finck         m_ServiceGroup = ServiceGroup;
280c2c66affSColin Finck     }
281c2c66affSColin Finck 
282c2c66affSColin Finck     // check if it supports IPinCount interface
283c2c66affSColin Finck     Status = UnknownMiniport->QueryInterface(IID_IPinCount, (PVOID*)&PinCount);
284c2c66affSColin Finck     if (NT_SUCCESS(Status))
285c2c66affSColin Finck     {
286c2c66affSColin Finck         // store IPinCount interface
287c2c66affSColin Finck         m_pPinCount = PinCount;
288c2c66affSColin Finck     }
289c2c66affSColin Finck 
290c2c66affSColin Finck     // does the Miniport adapter support IPowerNotify interface*/
291c2c66affSColin Finck     Status = UnknownMiniport->QueryInterface(IID_IPowerNotify, (PVOID*)&PowerNotify);
292c2c66affSColin Finck     if (NT_SUCCESS(Status))
293c2c66affSColin Finck     {
294c2c66affSColin Finck         // store reference
295c2c66affSColin Finck         m_pPowerNotify = PowerNotify;
296c2c66affSColin Finck     }
297c2c66affSColin Finck 
298c2c66affSColin Finck     return STATUS_SUCCESS;
299c2c66affSColin Finck }
300c2c66affSColin Finck 
301c2c66affSColin Finck NTSTATUS
302c2c66affSColin Finck NTAPI
NewRegistryKey(OUT PREGISTRYKEY * OutRegistryKey,IN PUNKNOWN OuterUnknown OPTIONAL,IN ULONG RegistryKeyType,IN ACCESS_MASK DesiredAccess,IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,IN ULONG CreateOptions OPTIONAL,OUT PULONG Disposition OPTIONAL)303c2c66affSColin Finck CPortDMus::NewRegistryKey(
304c2c66affSColin Finck     OUT PREGISTRYKEY  *OutRegistryKey,
305c2c66affSColin Finck     IN PUNKNOWN  OuterUnknown  OPTIONAL,
306c2c66affSColin Finck     IN ULONG  RegistryKeyType,
307c2c66affSColin Finck     IN ACCESS_MASK  DesiredAccess,
308c2c66affSColin Finck     IN POBJECT_ATTRIBUTES  ObjectAttributes  OPTIONAL,
309c2c66affSColin Finck     IN ULONG  CreateOptions  OPTIONAL,
310c2c66affSColin Finck     OUT PULONG  Disposition  OPTIONAL)
311c2c66affSColin Finck {
312c2c66affSColin Finck     PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
313c2c66affSColin Finck 
314c2c66affSColin Finck     if (!m_bInitialized)
315c2c66affSColin Finck     {
316c2c66affSColin Finck         DPRINT("IPortDMus_fnNewRegistryKey called w/o initialized\n");
317c2c66affSColin Finck         return STATUS_UNSUCCESSFUL;
318c2c66affSColin Finck     }
319c2c66affSColin Finck 
320c2c66affSColin Finck     return PcNewRegistryKey(OutRegistryKey,
321c2c66affSColin Finck                             OuterUnknown,
322c2c66affSColin Finck                             RegistryKeyType,
323c2c66affSColin Finck                             DesiredAccess,
324c2c66affSColin Finck                             m_pDeviceObject,
325c2c66affSColin Finck                             (ISubdevice*)this,
326c2c66affSColin Finck                             ObjectAttributes,
327c2c66affSColin Finck                             CreateOptions,
328c2c66affSColin Finck                             Disposition);
329c2c66affSColin Finck }
330c2c66affSColin Finck 
331c2c66affSColin Finck VOID
332c2c66affSColin Finck NTAPI
Notify(IN PSERVICEGROUP ServiceGroup OPTIONAL)333c2c66affSColin Finck CPortDMus::Notify(
334c2c66affSColin Finck     IN PSERVICEGROUP  ServiceGroup  OPTIONAL)
335c2c66affSColin Finck {
336c2c66affSColin Finck     if (ServiceGroup)
337c2c66affSColin Finck     {
338c2c66affSColin Finck         ServiceGroup->RequestService ();
339c2c66affSColin Finck         return;
340c2c66affSColin Finck     }
341c2c66affSColin Finck 
342c2c66affSColin Finck     PC_ASSERT(m_ServiceGroup);
343c2c66affSColin Finck 
344c2c66affSColin Finck     // notify miniport service group
345c2c66affSColin Finck     m_ServiceGroup->RequestService();
346c2c66affSColin Finck 
347c2c66affSColin Finck     // notify stream miniport service group
348c2c66affSColin Finck     if (m_Filter)
349c2c66affSColin Finck     {
350c2c66affSColin Finck         m_Filter->NotifyPins();
351c2c66affSColin Finck     }
352c2c66affSColin Finck }
353c2c66affSColin Finck 
354c2c66affSColin Finck VOID
355c2c66affSColin Finck NTAPI
RegisterServiceGroup(IN PSERVICEGROUP ServiceGroup)356c2c66affSColin Finck CPortDMus::RegisterServiceGroup(
357c2c66affSColin Finck     IN PSERVICEGROUP  ServiceGroup)
358c2c66affSColin Finck {
359c2c66affSColin Finck     PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
360c2c66affSColin Finck 
361c2c66affSColin Finck     m_ServiceGroup = ServiceGroup;
362c2c66affSColin Finck 
363c2c66affSColin Finck     ServiceGroup->AddMember(PSERVICESINK(this));
364c2c66affSColin Finck }
365c2c66affSColin Finck //---------------------------------------------------------------
366c2c66affSColin Finck // ISubdevice interface
367c2c66affSColin Finck //
368c2c66affSColin Finck 
369c2c66affSColin Finck NTSTATUS
370c2c66affSColin Finck NTAPI
NewIrpTarget(OUT struct IIrpTarget ** OutTarget,IN PCWSTR Name,IN PUNKNOWN Unknown,IN POOL_TYPE PoolType,IN PDEVICE_OBJECT DeviceObject,IN PIRP Irp,IN KSOBJECT_CREATE * CreateObject)371c2c66affSColin Finck CPortDMus::NewIrpTarget(
372c2c66affSColin Finck     OUT struct IIrpTarget **OutTarget,
373c2c66affSColin Finck     IN PCWSTR Name,
374c2c66affSColin Finck     IN PUNKNOWN Unknown,
375c2c66affSColin Finck     IN POOL_TYPE PoolType,
376c2c66affSColin Finck     IN PDEVICE_OBJECT DeviceObject,
377c2c66affSColin Finck     IN PIRP Irp,
378c2c66affSColin Finck     IN KSOBJECT_CREATE *CreateObject)
379c2c66affSColin Finck {
380c2c66affSColin Finck     NTSTATUS Status;
381c2c66affSColin Finck     PPORTFILTERDMUS Filter;
382c2c66affSColin Finck 
383c2c66affSColin Finck     DPRINT("ISubDevice_NewIrpTarget this %p\n", this);
384c2c66affSColin Finck 
385c2c66affSColin Finck     if (m_Filter)
386c2c66affSColin Finck     {
387c2c66affSColin Finck         *OutTarget = (IIrpTarget*)m_Filter;
388c2c66affSColin Finck         return STATUS_SUCCESS;
389c2c66affSColin Finck     }
390c2c66affSColin Finck 
391c2c66affSColin Finck     Status = NewPortFilterDMus(&Filter);
392c2c66affSColin Finck     if (!NT_SUCCESS(Status))
393c2c66affSColin Finck     {
394c2c66affSColin Finck         return Status;
395c2c66affSColin Finck     }
396c2c66affSColin Finck 
397c2c66affSColin Finck     Status = Filter->Init(PPORTDMUS(this));
398c2c66affSColin Finck     if (!NT_SUCCESS(Status))
399c2c66affSColin Finck     {
400c2c66affSColin Finck         Filter->Release();
401c2c66affSColin Finck         return Status;
402c2c66affSColin Finck     }
403c2c66affSColin Finck 
404c2c66affSColin Finck     *OutTarget = (IIrpTarget*)Filter;
405c2c66affSColin Finck     return Status;
406c2c66affSColin Finck }
407c2c66affSColin Finck 
408c2c66affSColin Finck NTSTATUS
409c2c66affSColin Finck NTAPI
ReleaseChildren()410c2c66affSColin Finck CPortDMus::ReleaseChildren()
411c2c66affSColin Finck {
412c2c66affSColin Finck     UNIMPLEMENTED;
413c2c66affSColin Finck     return STATUS_UNSUCCESSFUL;
414c2c66affSColin Finck }
415c2c66affSColin Finck 
416c2c66affSColin Finck NTSTATUS
417c2c66affSColin Finck NTAPI
GetDescriptor(IN SUBDEVICE_DESCRIPTOR ** Descriptor)418c2c66affSColin Finck CPortDMus::GetDescriptor(
419c2c66affSColin Finck     IN SUBDEVICE_DESCRIPTOR ** Descriptor)
420c2c66affSColin Finck {
421c2c66affSColin Finck     DPRINT("ISubDevice_GetDescriptor this %p\n", this);
422c2c66affSColin Finck     *Descriptor = m_SubDeviceDescriptor;
423c2c66affSColin Finck     return STATUS_SUCCESS;
424c2c66affSColin Finck }
425c2c66affSColin Finck 
426c2c66affSColin Finck NTSTATUS
427c2c66affSColin Finck NTAPI
DataRangeIntersection(IN ULONG PinId,IN PKSDATARANGE DataRange,IN PKSDATARANGE MatchingDataRange,IN ULONG OutputBufferLength,OUT PVOID ResultantFormat OPTIONAL,OUT PULONG ResultantFormatLength)428c2c66affSColin Finck CPortDMus::DataRangeIntersection(
429c2c66affSColin Finck     IN  ULONG PinId,
430c2c66affSColin Finck     IN  PKSDATARANGE DataRange,
431c2c66affSColin Finck     IN  PKSDATARANGE MatchingDataRange,
432c2c66affSColin Finck     IN  ULONG OutputBufferLength,
433c2c66affSColin Finck     OUT PVOID ResultantFormat OPTIONAL,
434c2c66affSColin Finck     OUT PULONG ResultantFormatLength)
435c2c66affSColin Finck {
436c2c66affSColin Finck     DPRINT("ISubDevice_DataRangeIntersection this %p\n", this);
437c2c66affSColin Finck 
438c2c66affSColin Finck     if (m_pMiniport)
439c2c66affSColin Finck     {
440c2c66affSColin Finck         return m_pMiniport->DataRangeIntersection (PinId, DataRange, MatchingDataRange, OutputBufferLength, ResultantFormat, ResultantFormatLength);
441c2c66affSColin Finck     }
442c2c66affSColin Finck 
443c2c66affSColin Finck     return STATUS_UNSUCCESSFUL;
444c2c66affSColin Finck }
445c2c66affSColin Finck 
446c2c66affSColin Finck NTSTATUS
447c2c66affSColin Finck NTAPI
PowerChangeNotify(IN POWER_STATE PowerState)448c2c66affSColin Finck CPortDMus::PowerChangeNotify(
449c2c66affSColin Finck     IN POWER_STATE PowerState)
450c2c66affSColin Finck {
451c2c66affSColin Finck     if (m_pPowerNotify)
452c2c66affSColin Finck     {
453c2c66affSColin Finck         m_pPowerNotify->PowerChangeNotify(PowerState);
454c2c66affSColin Finck     }
455c2c66affSColin Finck 
456c2c66affSColin Finck     return STATUS_SUCCESS;
457c2c66affSColin Finck }
458c2c66affSColin Finck 
459c2c66affSColin Finck NTSTATUS
460c2c66affSColin Finck NTAPI
PinCount(IN ULONG PinId,IN OUT PULONG FilterNecessary,IN OUT PULONG FilterCurrent,IN OUT PULONG FilterPossible,IN OUT PULONG GlobalCurrent,IN OUT PULONG GlobalPossible)461c2c66affSColin Finck CPortDMus::PinCount(
462c2c66affSColin Finck     IN ULONG  PinId,
463c2c66affSColin Finck     IN OUT PULONG  FilterNecessary,
464c2c66affSColin Finck     IN OUT PULONG  FilterCurrent,
465c2c66affSColin Finck     IN OUT PULONG  FilterPossible,
466c2c66affSColin Finck     IN OUT PULONG  GlobalCurrent,
467c2c66affSColin Finck     IN OUT PULONG  GlobalPossible)
468c2c66affSColin Finck {
469c2c66affSColin Finck     if (m_pPinCount)
470c2c66affSColin Finck     {
471c2c66affSColin Finck        m_pPinCount->PinCount(PinId, FilterNecessary, FilterCurrent, FilterPossible, GlobalCurrent, GlobalPossible);
472c2c66affSColin Finck        return STATUS_SUCCESS;
473c2c66affSColin Finck     }
474c2c66affSColin Finck 
475c2c66affSColin Finck     // FIXME
476c2c66affSColin Finck     // scan filter descriptor
477c2c66affSColin Finck 
478c2c66affSColin Finck     return STATUS_UNSUCCESSFUL;
479c2c66affSColin Finck }
480c2c66affSColin Finck 
481c2c66affSColin Finck NTSTATUS
NewPortDMus(OUT PPORT * OutPort)482c2c66affSColin Finck NewPortDMus(
483c2c66affSColin Finck     OUT PPORT* OutPort)
484c2c66affSColin Finck {
485c2c66affSColin Finck     NTSTATUS Status;
486c2c66affSColin Finck     CPortDMus * Port = new(NonPagedPool, TAG_PORTCLASS) CPortDMus(NULL);
487c2c66affSColin Finck     if (!Port)
488c2c66affSColin Finck         return STATUS_INSUFFICIENT_RESOURCES;
489c2c66affSColin Finck 
490c2c66affSColin Finck     Status = Port->QueryInterface(IID_IPort, (PVOID*)OutPort);
491c2c66affSColin Finck 
492c2c66affSColin Finck     if (!NT_SUCCESS(Status))
493c2c66affSColin Finck     {
494c2c66affSColin Finck         delete Port;
495c2c66affSColin Finck     }
496c2c66affSColin Finck 
497c2c66affSColin Finck     DPRINT("NewPortDMus %p Status %u\n", Port, Status);
498c2c66affSColin Finck     return Status;
499c2c66affSColin Finck 
500c2c66affSColin Finck }
501c2c66affSColin Finck 
502c2c66affSColin Finck VOID
GetDMusMiniport(IN IPortDMus * iface,IN PMINIPORTDMUS * Miniport,IN PMINIPORTMIDI * MidiMiniport)503c2c66affSColin Finck GetDMusMiniport(
504c2c66affSColin Finck     IN IPortDMus * iface,
505c2c66affSColin Finck     IN PMINIPORTDMUS * Miniport,
506c2c66affSColin Finck     IN PMINIPORTMIDI * MidiMiniport)
507c2c66affSColin Finck {
508c2c66affSColin Finck     CPortDMus * This = (CPortDMus*)iface;
509c2c66affSColin Finck 
510c2c66affSColin Finck     *Miniport = This->m_pMiniport;
511c2c66affSColin Finck     *MidiMiniport = This->m_pMiniportMidi;
512c2c66affSColin Finck }
513