ReactOS 0.4.15-dev-8127-g6338913
stream.h
Go to the documentation of this file.
1#ifndef _STREAM_H_
2#define _STREAM_H_
3
4const int DMA_ENGINE_OFF = 0;
5const int DMA_ENGINE_PAUSE = 1;
6const int DMA_ENGINE_PEND = 2;
7const int DMA_ENGINE_ON = 3;
8
9//*****************************************************************************
10// Defines
11//*****************************************************************************
12
13//
14// The scatter gather can (only) handle 32 entries
15//
16const int MAX_BDL_ENTRIES = 32;
17
18//
19// Mask for accessing the scatter gather entries with a counter.
20//
21const int BDL_MASK = 31;
22
23//
24// Structure to describe the AC97 Buffer Descriptor List (BDL).
25// The AC97 can handle 32 entries, they are allocated at once in common
26// memory (non-cached memory). To avoid slow-down of CPU, the additional
27// information for handling this structure is stored in tBDList.
28//
29typedef struct tagBDEntry
30{
35
36
37class CMiniportStream : public IDrmAudioStream
38{
39 UCHAR UpdateDMA(void);
40
41public:
43 WavePins Pin; // channel this stream handles.
44 BOOL Capture; // TRUE=Capture,FALSE=Render
45 WORD NumberOfChannels; // Number of channels
46 DEVICE_POWER_STATE m_PowerState; // Current power state of the device.
47
49
50
51
53
54
55 PSERVICEGROUP ServiceGroup; // service group helps with DPCs
56 ULONG CurrentRate; // Current Sample Rate
57 ULONG DMAEngineState; // DMA engine state
58 ULONG m_ulBDAddr; // Offset of the stream's DMA registers.
59
60 PHYSICAL_ADDRESS BDList_PhysAddr; // Physical address of BDList
61 tBDEntry *BDList; // Virtual Address of BDList
62
63public:
65
66
67
68 //
69 // DMA start/stop/pause/reset routines.
70 //
71 void ResetDMA (void);
72 void PauseDMA (void);
74
75
76 //
77 // Get playback position
78 //
79 int GetBuffPos
80 (
81 DWORD* buffPos
82 );
83
84 //
85 // Stream regiter read/write
86 //
93
94 /*************************************************************************
95 * Include IDrmAudioStream (public/exported) methods.
96 *************************************************************************
97 */
99
100
102 (
104 );
105
106
107
108
109 //
110 // This method is called when the device changes power states.
111 //
113 (
114 IN POWER_STATE NewState
115 );
116
117 virtual void PowerChangeNotify_
118 (
119 IN POWER_STATE NewState
120 );
121
122
123
124
125
126
127 //
128 // Return the current sample rate.
129 //
131 {
132 return CurrentRate;
133 }
134
136 (
137 IN CMiniport* Miniport_,
139 IN WavePins Pin_,
140 IN BOOLEAN Capture_,
141 IN PKSDATAFORMAT DataFormat_,
142 OUT PSERVICEGROUP *ServiceGroup_
143 );
144
145
147 virtual NTSTATUS Init_() PURE;
148
150 (
153 _In_ REFIID iStream,
155 );
156
157
159 (
161 );
162
164 (
165 _Inout_ PLONGLONG PhysicalPosition
166 );
167
168
170 void BDList_Free();
171
173 {
174 UCHAR CIV = ReadReg8(X_CIV);
175 WriteReg8(X_LVI, (CIV-1) & BDL_MASK);
176 }
177};
178
179
180
181#define IMP_CMiniportStream_SetFormat(cType) \
182 STDMETHODIMP_(NTSTATUS) cType::SetFormat (_In_ PKSDATAFORMAT Format) \
183 { return CMiniportStream::SetFormat(Format); }
184
185#define IMP_CMiniportStream_QueryInterface(cType, sType) \
186 STDMETHODIMP_(NTSTATUS) cType::NonDelegatingQueryInterface( \
187 _In_ REFIID Interface, \
188 _COM_Outptr_ PVOID *Object) \
189 { return CMiniportStream::NonDelegatingQueryInterface( \
190 Interface, Object, IID_##sType, (sType*)this); }
191
192#define IMP_CMiniport_SetState(cType) \
193 STDMETHODIMP_(NTSTATUS) cType::SetState (_In_ KSSTATE State) \
194 { return CMiniportStream::SetState(State); }
195
196#define IMP_CMiniport_NormalizePhysicalPosition(cType) \
197 STDMETHODIMP_(NTSTATUS) cType::NormalizePhysicalPosition (_Inout_ PLONGLONG PhysicalPosition) \
198 { return CMiniportStream::NormalizePhysicalPosition(PhysicalPosition); }
199
200#endif
unsigned char BOOLEAN
static int state
Definition: maze.c:121
LONG NTSTATUS
Definition: precomp.h:26
#define PURE
Definition: basetyps.h:64
tBDEntry * BDList
Definition: stream.h:61
NTSTATUS NonDelegatingQueryInterface(_In_ REFIID Interface, _COM_Outptr_ PVOID *Object, _In_ REFIID iStream, _In_ PUNKNOWN stream)
Definition: stream.cpp:19
BOOL Capture
Definition: stream.h:44
PVOID BDList_Alloc()
Definition: stream2.cpp:11
void WriteReg16(ULONG addr, USHORT data)
Definition: stream.cpp:625
WORD NumberOfChannels
Definition: stream.h:45
void ResumeDMA(ULONG state=DMA_ENGINE_ON)
Definition: stream.cpp:599
UCHAR ReadReg8(ULONG addr)
Definition: stream.cpp:629
ULONG CurrentRate
Definition: stream.h:56
void BDList_Free()
Definition: stream2.cpp:25
void WriteReg32(ULONG addr, ULONG data)
Definition: stream.cpp:627
CMiniport * Miniport
Definition: stream.h:42
void ResetDMA(void)
Definition: stream.cpp:544
virtual void InterruptServiceRoutine() PURE
NTSTATUS NormalizePhysicalPosition(_Inout_ PLONGLONG PhysicalPosition)
Definition: stream2.cpp:139
void UpdateLviCyclic()
Definition: stream.h:172
virtual NTSTATUS Init_() PURE
virtual void PowerChangeNotify_(IN POWER_STATE NewState)
Definition: stream2.cpp:51
int GetBuffPos(DWORD *buffPos)
Definition: stream.cpp:509
USHORT ReadReg16(ULONG addr)
Definition: stream.cpp:631
void PowerChangeNotify(IN POWER_STATE NewState)
Definition: stream.cpp:289
void PauseDMA(void)
Definition: stream.cpp:614
PKSDATAFORMAT_WAVEFORMATEX DataFormat
Definition: stream.h:52
PPORTSTREAM_ PortStream
Definition: stream.h:48
PSERVICEGROUP ServiceGroup
Definition: stream.h:55
UCHAR UpdateDMA(void)
Definition: stream.cpp:493
void WriteReg8(ULONG addr, UCHAR data)
Definition: stream.cpp:623
NTSTATUS SetState(_In_ KSSTATE State)
Definition: stream2.cpp:78
ULONG GetCurrentSampleRate(void)
Definition: stream.h:130
STDMETHODIMP_(NTSTATUS) SetFormat(_In_ PKSDATAFORMAT Format)
ULONG DMAEngineState
Definition: stream.h:57
ULONG ReadReg32(ULONG addr)
Definition: stream.cpp:633
WavePins Pin
Definition: stream.h:43
PHYSICAL_ADDRESS BDList_PhysAddr
Definition: stream.h:60
DEVICE_POWER_STATE m_PowerState
Definition: stream.h:46
ULONG m_ulBDAddr
Definition: stream.h:58
#define PPORTSTREAM_
Definition: miniport.h:6
WavePins
Definition: shared.h:317
struct tagBDEntry tBDEntry
const int DMA_ENGINE_PAUSE
Definition: stream.h:5
const int MAX_BDL_ENTRIES
Definition: stream.h:16
const int DMA_ENGINE_OFF
Definition: stream.h:4
const int DMA_ENGINE_ON
Definition: stream.h:7
const int BDL_MASK
Definition: stream.h:21
const int DMA_ENGINE_PEND
Definition: stream.h:6
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum const GLvoid * addr
Definition: glext.h:9621
const ULONG X_LVI
Definition: ichreg.h:52
const ULONG X_CIV
Definition: ichreg.h:51
KSSTATE
Definition: ks.h:1214
#define _Inout_
Definition: ms_sal.h:378
#define _COM_Outptr_
Definition: ms_sal.h:449
#define _In_
Definition: ms_sal.h:308
__GNU_EXTENSION typedef __int64 * PLONGLONG
Definition: ntbasedef.h:382
enum _DEVICE_POWER_STATE DEVICE_POWER_STATE
unsigned short USHORT
Definition: pedump.c:61
IServiceGroup * PSERVICEGROUP
Definition: portcls.h:614
#define REFIID
Definition: guiddef.h:118
Definition: parse.h:23
WORD wPolicyBits
Definition: stream.h:33
WORD wLength
Definition: stream.h:32
DWORD dwPtrToPhyAddress
Definition: stream.h:31
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
unsigned char UCHAR
Definition: xmlstorage.h:181