ReactOS 0.4.16-dev-297-gc569aee
wavecyclicminiport.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// Every debug output has "Modulname text"
9#define STR_MODULENAME "AC97 Wave Cyclic: "
10
11#include "wavecyclicminiport.h"
12#include "wavecyclicstream.h"
13
14
15#ifdef _MSC_VER
16#pragma code_seg("PAGE")
17#endif
18
19IMP_CMiniport(CMiniportWaveCyclic, IID_IMiniportWaveCyclic)
20
21/*****************************************************************************
22 * CreateAC97MiniportWaveCyclic
23 *****************************************************************************
24 * Creates a AC97 wave miniport object for the AC97 adapter.
25 * This uses a macro from STDUNK.H to do all the work.
26 */
28(
31 IN PUNKNOWN UnknownOuter OPTIONAL,
33 __drv_reportError("Must succeed pool allocations are forbidden. "
34 "Allocation failures cause a system crash"))
36)
37{
38 PAGED_CODE ();
39
41
42 DOUT (DBG_PRINT, ("[CreateAC97MiniportWaveCyclic]"));
43
44 STD_CREATE_BODY_WITH_TAG_(CMiniportWaveCyclic,Unknown,UnknownOuter,PoolType,
46}
47
48/*****************************************************************************
49 * CMiniportWaveCyclic::Init
50 *****************************************************************************
51 * Initializes the miniport.
52 * Initializes variables and modifies the wave topology if needed.
53 */
54STDMETHODIMP_(NTSTATUS) CMiniportWaveCyclic::Init
55(
56 _In_ PUNKNOWN UnknownAdapter,
59)
60{
61 PAGED_CODE ();
62
63 NTSTATUS ntStatus = CMiniport::Init(
64 UnknownAdapter,
66 Port_
67 );
68
69 if (!NT_SUCCESS (ntStatus))
70 {
71 return ntStatus;
72 }
73
74 //
75 // Create the DMA Channel object.
76 //
77 ntStatus = Port->NewMasterDmaChannel (&DmaChannel, // OutDmaChannel
78 NULL, // OuterUnknown (opt)
79 NULL, // ResourceList (opt)
80 0x1FFFE, // MaximumLength
81 TRUE, // Dma32BitAddresses
82 FALSE, // Dma64BitAddresses
83 Width32Bits, // DmaWidth
84 MaximumDmaSpeed); // DmaSpeed
85 if (!NT_SUCCESS (ntStatus))
86 {
87 DOUT (DBG_ERROR, ("Failed on NewMasterDmaChannel!"));
88 return ntStatus;
89 }
90
91 //
92 // On failure object is destroyed which cleans up.
93 //
94 return ntStatus;
95}
96
97/*****************************************************************************
98 * CMiniportWaveCyclic::NewStream
99 *****************************************************************************
100 * Creates a new stream.
101 * This function is called when a streaming pin is created.
102 * It checks if the channel is already in use, tests the data format, creates
103 * and initializes the stream object.
104 */
106STDMETHODIMP CMiniportWaveCyclic::NewStream
107(
109 PUNKNOWN OuterUnknown,
111 ULONG Pin_,
114 PDMACHANNEL *DmaChannel_,
115 PSERVICEGROUP *ServiceGroup
116)
117{
118 PAGED_CODE ();
119
120 ASSERT (Stream);
122 ASSERT (DmaChannel_);
123 ASSERT (ServiceGroup);
124
125 CMiniportWaveCyclicStream *pWaveCyclicStream = NULL;
126 NTSTATUS ntStatus = STATUS_SUCCESS;
127
128 DOUT (DBG_PRINT, ("[CMiniportWaveCyclic::NewStream]"));
129
130 //
131 // Check parameters.
132 //
133 ntStatus = ValidateFormat (DataFormat, (WavePins)Pin_);
134 if (!NT_SUCCESS (ntStatus))
135 {
136 return ntStatus;
137 }
138
139 //
140 // Create a new stream.
141 //
142 ntStatus = CreateMiniportWaveCyclicStream (&pWaveCyclicStream, OuterUnknown,
143 PoolType);
144
145 //
146 // Return in case of an error.
147 //
148 if (!NT_SUCCESS (ntStatus))
149 {
150 DOUT (DBG_ERROR, ("[NewStream] Failed to create stream!"));
151 return ntStatus;
152 }
153
154 //
155 // Initialize the stream.
156 //
157
158 ntStatus = pWaveCyclicStream->Init ((CMiniport*)this,
159 NULL,
160 (WavePins)Pin_,
161 Capture,
163 ServiceGroup);
164 if (!NT_SUCCESS (ntStatus))
165 {
166 //
167 // Release the stream and clean up.
168 //
169 DOUT (DBG_ERROR, ("[NewStream] Failed to init stream!"));
170 pWaveCyclicStream->Release ();
171
172 return ntStatus;
173 }
174
175 //
176 // Save the pointers.
177 //
178 *Stream = (PMINIPORTWAVECYCLICSTREAM)pWaveCyclicStream;
179 obj_AddRef(DmaChannel, (PVOID *)DmaChannel_);
180
181 return STATUS_SUCCESS;
182}
#define PAGED_CODE()
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define STDMETHODIMP
Definition: basetyps.h:43
#define STDMETHODIMP_(t)
Definition: basetyps.h:44
struct _Capture Capture
Definition: capture.h:24
NTSTATUS Init(IN CMiniport *Miniport_, IN PUNKNOWN PortStream, IN WavePins Pin_, IN BOOLEAN Capture_, IN PKSDATAFORMAT DataFormat_, OUT PSERVICEGROUP *ServiceGroup_)
Definition: stream.cpp:65
NTSTATUS ValidateFormat(IN PKSDATAFORMAT DataFormat, IN WavePins Pin)
Definition: miniport.cpp:781
PDMACHANNEL DmaChannel
Definition: miniport.h:33
_In_ PRESOURCELIST _In_ PPORT Port_
Definition: miniport.h:98
PPORT_ Port
Definition: miniport.h:30
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
void __fastcall obj_AddRef(PUNKNOWN obj, void **ppvObject)
Definition: miniport.cpp:1264
NTSTATUS CreateAC97MiniportWaveCyclic(OUT PUNKNOWN *Unknown, IN REFCLSID, IN PUNKNOWN UnknownOuter OPTIONAL, IN POOL_TYPE PoolType)
#define DOUT(lvl, strings)
Definition: debug.h:82
#define IMP_CMiniport(cType, IID)
Definition: miniport.h:119
WavePins
Definition: shared.h:317
#define __drv_reportError(why)
Definition: driverspecs.h:320
@ Unknown
Definition: i8042prt.h:114
#define ASSERT(a)
Definition: mode.c:44
static IStream Stream
Definition: htmldoc.c:1115
#define DBG_ERROR
Definition: nfs41_debug.h:78
#define _Use_decl_annotations_
Definition: no_sal2.h:92
#define _In_
Definition: no_sal2.h:158
#define _When_(c, a)
Definition: no_sal2.h:38
IMiniportWaveCyclic * PMINIPORTWAVECYCLIC
Definition: portcls.h:1543
IDmaChannel * PDMACHANNEL
Definition: portcls.h:784
IResourceList * PRESOURCELIST
Definition: portcls.h:442
IMiniportWaveCyclicStream * PMINIPORTWAVECYCLICSTREAM
Definition: portcls.h:1487
IPortWaveCyclic * PPORTWAVECYCLIC
Definition: portcls.h:1184
IServiceGroup * PSERVICEGROUP
Definition: portcls.h:614
@ Width32Bits
Definition: miniport.h:107
@ MaximumDmaSpeed
Definition: miniport.h:117
#define STATUS_SUCCESS
Definition: shellext.h:65
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
INT POOL_TYPE
Definition: typedefs.h:78
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
IN REFCLSID
NTSTATUS CreateMiniportWaveCyclicStream(OUT CMiniportWaveCyclicStream **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)
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3815
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG PoolTag
Definition: wdfmemory.h:164
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:309
#define DBG_PRINT(ppi, ch, level)
Definition: win32kdebug.h:169
@ NonPagedPoolMustSucceed
Definition: ketypes.h:880