ReactOS  0.4.15-dev-5452-g3c95c95
wavepciminiport.cpp
Go to the documentation of this file.
1 /********************************************************************************
2 ** Copyright (c) 1998-2000 Microsoft Corporation. All Rights Reserved.
3 **
4 ** Portions Copyright (c) 1998-1999 Intel Corporation
5 **
6 ********************************************************************************/
7 
8 /* The file wavepciminiport.cpp was reviewed by LCA in June 2011 and is acceptable for use by Microsoft. */
9 
10 // Every debug output has "Modulname text"
11 #define STR_MODULENAME "AC97 Wave: "
12 
13 #include "wavepciminiport.h"
14 #include "wavepcistream.h"
15 
16 
17 #ifdef _MSC_VER
18 #pragma code_seg("PAGE")
19 #endif
20 
21 IMP_CMiniport(CMiniportWaveICH, IID_IMiniportWavePci)
22 
23 /*****************************************************************************
24  * CreateAC97MiniportWavePCI
25  *****************************************************************************
26  * Creates a AC97 wave miniport object for the AC97 adapter.
27  * This uses a macro from STDUNK.H to do all the work.
28  */
30 (
33  IN PUNKNOWN UnknownOuter OPTIONAL,
35  __drv_reportError("Must succeed pool allocations are forbidden. "
36  "Allocation failures cause a system crash"))
38 )
39 {
40  PAGED_CODE ();
41 
42  ASSERT (Unknown);
43 
44  DOUT (DBG_PRINT, ("[CreateAC97MiniportWavePCI]"));
45 
46  STD_CREATE_BODY_WITH_TAG_(CMiniportWaveICH,Unknown,UnknownOuter,PoolType,
48 }
49 
50 /*****************************************************************************
51  * CMiniportWaveICH::Init
52  *****************************************************************************
53  * Initializes the miniport.
54  * Initializes variables and modifies the wave topology if needed.
55  */
57 (
58  _In_ PUNKNOWN UnknownAdapter,
60  _In_ PPORTWAVEPCI Port_,
61  _Out_ PSERVICEGROUP *ServiceGroup_
62 )
63 {
64  PAGED_CODE ();
65 
66  //
67  // No miniport service group
68  //
69  *ServiceGroup_ = NULL;
70 
71  NTSTATUS ntStatus = CMiniport::Init(
72  UnknownAdapter,
74  Port_
75  );
76 
77  if (!NT_SUCCESS (ntStatus))
78  {
79  return ntStatus;
80  }
81 
82  //
83  // Create the DMA Channel object.
84  //
85  ntStatus = Port->NewMasterDmaChannel (&DmaChannel, // OutDmaChannel
86  NULL, // OuterUnknown (opt)
87  NonPagedPool, // Pool Type
88  NULL, // ResourceList (opt)
89  TRUE, // ScatterGather
90  TRUE, // Dma32BitAddresses
91  FALSE, // Dma64BitAddresses
92  FALSE, // IgnoreCount
93  Width32Bits, // DmaWidth
94  MaximumDmaSpeed, // DmaSpeed
95  0x1FFFE, // MaximumLength (128KByte -2)
96  0); // DmaPort
97  if (!NT_SUCCESS (ntStatus))
98  {
99  DOUT (DBG_ERROR, ("Failed on NewMasterDmaChannel!"));
100  return ntStatus;
101  }
102 
103  //
104  // On failure object is destroyed which cleans up.
105  //
106  return ntStatus;
107 }
108 
109 /*****************************************************************************
110  * CMiniportWaveICH::NewStream
111  *****************************************************************************
112  * Creates a new stream.
113  * This function is called when a streaming pin is created.
114  * It checks if the channel is already in use, tests the data format, creates
115  * and initializes the stream object.
116  */
118 STDMETHODIMP CMiniportWaveICH::NewStream
119 (
121  PUNKNOWN OuterUnknown,
123  PPORTWAVEPCISTREAM PortStream,
124  ULONG Pin_,
127  PDMACHANNEL *DmaChannel_,
128  PSERVICEGROUP *ServiceGroup
129 )
130 {
131  PAGED_CODE ();
132 
133  ASSERT (Stream);
134  ASSERT (PortStream);
135  ASSERT (DataFormat);
136  ASSERT (DmaChannel_);
137  ASSERT (ServiceGroup);
138 
139  CMiniportWaveICHStream *pWaveICHStream = NULL;
140  NTSTATUS ntStatus = STATUS_SUCCESS;
141 
142  DOUT (DBG_PRINT, ("[CMiniportWaveICH::NewStream]"));
143 
144  //
145  // Check parameters.
146  //
147  ntStatus = ValidateFormat (DataFormat, (WavePins)Pin_);
148  if (!NT_SUCCESS (ntStatus))
149  {
150  return ntStatus;
151  }
152 
153  //
154  // Create a new stream.
155  //
156  ntStatus = CreateMiniportWaveICHStream (&pWaveICHStream, OuterUnknown,
157  PoolType);
158 
159  //
160  // Return in case of an error.
161  //
162  if (!NT_SUCCESS (ntStatus))
163  {
164  DOUT (DBG_ERROR, ("[NewStream] Failed to create stream!"));
165  return ntStatus;
166  }
167 
168  //
169  // Initialize the stream.
170  //
171  ntStatus = pWaveICHStream->Init ((CMiniport*)this,
172  PortStream,
173  (WavePins)Pin_,
174  Capture,
175  DataFormat,
176  ServiceGroup);
177  if (!NT_SUCCESS (ntStatus))
178  {
179  //
180  // Release the stream and clean up.
181  //
182  DOUT (DBG_ERROR, ("[NewStream] Failed to init stream!"));
183  pWaveICHStream->Release ();
184 
185  return ntStatus;
186  }
187 
188  //
189  // Save the pointers.
190  //
191  *Stream = (PMINIPORTWAVEPCISTREAM)pWaveICHStream;
192  obj_AddRef(DmaChannel, (PVOID *)DmaChannel_);
193 
194  return STATUS_SUCCESS;
195 }
196 
197 /*****************************************************************************
198  * Non paged code begins here
199  *****************************************************************************
200  */
201 
202 #ifdef _MSC_VER
203 #pragma code_seg()
204 #endif
205 /*****************************************************************************
206  * CMiniportWaveICH::Service
207  *****************************************************************************
208  * Processing routine for dealing with miniport interrupts. This routine is
209  * called at DISPATCH_LEVEL.
210  */
212 {
213  // not needed
214 }
IServiceGroup * PSERVICEGROUP
Definition: portcls.h:614
#define IN
Definition: typedefs.h:39
IDmaChannel * PDMACHANNEL
Definition: portcls.h:782
#define __drv_reportError(why)
Definition: driverspecs.h:319
NTSTATUS ValidateFormat(IN PKSDATAFORMAT DataFormat, IN WavePins Pin)
Definition: miniport.cpp:781
#define _Out_
Definition: ms_sal.h:345
#define TRUE
Definition: types.h:120
IPortWavePciStream * PPORTWAVEPCISTREAM
Definition: portcls.h:1588
LONG NTSTATUS
Definition: precomp.h:26
BOOL Init(PUSERCONNECT UserCon)
Definition: dllmain.c:386
_In_ PRESOURCELIST _In_ PPORT Port_
Definition: miniport.h:96
#define DOUT(lvl, strings)
Definition: debug.h:82
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:304
IMiniportWavePciStream * PMINIPORTWAVEPCISTREAM
Definition: portcls.h:1641
#define _Use_decl_annotations_
Definition: ms_sal.h:275
PDMACHANNEL DmaChannel
Definition: miniport.h:33
#define FALSE
Definition: types.h:117
#define STDMETHODIMP
Definition: basetyps.h:43
NTSTATUS Init(IN CMiniport *Miniport_, IN PUNKNOWN PortStream, IN WavePins Pin_, IN BOOLEAN Capture_, IN PKSDATAFORMAT DataFormat_, OUT PSERVICEGROUP *ServiceGroup_)
Definition: stream.cpp:65
unsigned char BOOLEAN
IN IN PUNKNOWN UnknownOuter _When_((PoolType &NonPagedPoolMustSucceed) !=0, __drv_reportError("Must succeed pool allocations are forbidden. " "Allocation failures cause a system crash")) IN POOL_TYPE PoolType)
#define _In_
Definition: ms_sal.h:308
IMiniportWavePci * PMINIPORTWAVEPCI
Definition: portcls.h:1695
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
INT POOL_TYPE
Definition: typedefs.h:78
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG PoolTag
Definition: wdfmemory.h:159
IMP_CMiniport(CMiniportWaveICH, IID_IMiniportWavePci) NTSTATUS CreateAC97MiniportWavePCI(OUT PUNKNOWN *Unknown
const int DBG_ERROR
Definition: debug.h:19
NTSTATUS CreateMiniportWaveICHStream(OUT CMiniportWaveICHStream **pWaveIchStream, IN PUNKNOWN pUnknown, _When_((PoolType &NonPagedPoolMustSucceed) !=0, __drv_reportError("Must succeed pool allocations are forbidden. " "Allocation failures cause a system crash")) IN POOL_TYPE PoolType)
IResourceList * PRESOURCELIST
Definition: portcls.h:442
IPortWavePci * PPORTWAVEPCI
Definition: portcls.h:1246
#define NULL
Definition: types.h:112
NTSTATUS CreateAC97MiniportWavePCI(OUT PUNKNOWN *Unknown, IN REFCLSID, IN PUNKNOWN UnknownOuter OPTIONAL, IN POOL_TYPE PoolType)
PPORT_ Port
Definition: miniport.h:30
#define OUT
Definition: typedefs.h:40
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3810
unsigned int ULONG
Definition: retypes.h:1
WavePins
Definition: shared.h:316
#define STATUS_SUCCESS
Definition: shellext.h:65
const int DBG_PRINT
Definition: debug.h:17
_Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING Stream
Definition: fltkernel.h:1092
IN REFCLSID
struct _Capture Capture
Definition: capture.h:24
void __fastcall obj_AddRef(PUNKNOWN obj, void **ppvObject)
Definition: miniport.cpp:1264
STDMETHODIMP_(NTSTATUS) CMiniportWaveICH
#define PAGED_CODE()
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68