ReactOS 0.4.15-dev-7924-g5949c20
mintopo.h
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 mintopo.h was reviewed by LCA in June 2011 and is acceptable for use by Microsoft. */
9
10#ifndef _MINTOPO_H_
11#define _MINTOPO_H_
12
13#include "shared.h"
14#include "guids.h"
15#ifdef INCLUDE_PRIVATE_PROPERTY
16#include "prvprop.h"
17#endif
18
19
20/*****************************************************************************
21 * Structures and Definitions
22 */
23
24// This structure is used to translate the TopoPins member to a (registered)
25// system pin member or vice versa.
26typedef struct
27{
29 int PinNr;
31
32
33// This structure is used to translate the TopoNodes member to a (registered)
34// system node member or vice versa.
35typedef struct
36{
38 int NodeNr;
40
41// max. number of connections
42const int TOPO_MAX_CONNECTIONS = 0x80;
43
44// Looking at the structure stMapNodeToReg, it defines a mask for a node.
45// A volume node for instance could be used to prg. the left or right channel,
46// so we have to mask the mask in stMapNodeToReg with a "left channel mask"
47// or a "right channel mask" to only prg. the left or right channel.
48const WORD AC97REG_MASK_LEFT = 0x3F00;
49const WORD AC97REG_MASK_RIGHT = 0x003F;
50const WORD AC97REG_MASK_MUTE = 0x8000;
51
52// When the user moves the fader of a volume control to the bottom, the
53// system calls the property handler with a -MAXIMUM dB value. That's not
54// what you returned at a basic support "data range", but the most negative
55// value you can represent with a long.
56const long PROP_MOST_NEGATIVE = (long)0x80000000;
57
58// We must cache the values for the volume and tone controls. If we don't,
59// the controls will "jump".
60// We have around 50% volume controls in the nodes. One way would be to
61// create a separate structure for the node cache and a second array for
62// the mapping. But we just use one big array (that could cache mute controls
63// too) and in that way simplify the code a little.
64// We use the bLeftValid and bRightValid to indicate whether the values stored
65// in lLeft and lRight are true - remember at startup we only write and
66// initialize the AC97 registers and not this structure. But as soon as there
67// is a property get or a property set, this element (node) will be stored here
68// and marked valid.
69// We don't have to save/restore the virtual controls for WaveIn and MonoOut
70// in the registry, cause WDMAUD will do this for every node that is exposed
71// in the topology. We can also be sure that this structure gets initialized at
72// startup because WDMAUD will query every node that it finds.
73typedef struct
74{
75 long lLeft;
76 long lRight;
80
81
82/*****************************************************************************
83 * Classes
84 */
85
86/*****************************************************************************
87 * CAC97MiniportTopology
88 *****************************************************************************
89 * AC97 topology miniport. This object is associated with the device and is
90 * created when the device is started. The class inherits IMiniportTopology
91 * so it can expose this interface and CUnknown so it automatically gets
92 * reference counting and aggregation support.
93 */
94class CAC97MiniportTopology : public IAC97MiniportTopology,
95 public CUnknown
96{
97private:
98 PADAPTERCOMMON AdapterCommon; // Adapter common object
103
107 BOOL m_bCopyProtectFlag; // Copy protect flag for DRM.
108
109 /*************************************************************************
110 * CAC97MiniportTopology methods
111 *
112 * These are private member functions used internally by the object. See
113 * MINIPORT.CPP for specific descriptions.
114 */
115
116 // builds the topology.
117 NTSTATUS BuildTopology (void);
118
119 // registers (builds) the pins
121
122 // registers (builds) the nodes
124
125 // registers (builds) the connection between the pin, nodes.
127
128#if (DBG)
129 // dumps the topology. you can specify if you want to dump pins, nodes,
130 // connections (see debug.h).
131 void DumpTopology (void);
132#endif
133
134 // translates the system node id to a TopoNode.
136 {
137#if (DBG)
138 TopoNodes n;
139
141 // check for invalid translation. could be caused by a connection
142 // to a not registered node or wrong use of nodes.
143 if (n == NODE_INVALID)
144 DOUT (DBG_ERROR, ("Invalid node nr %u.", Node));
145 return n;
146#else
147 return stNodeTrans[Node].NodeDef;
148#endif
149 };
150
151 // translates a TopoNode to a system node id.
153 {
154#if (DBG)
155 int n;
156
157 // check for invalid translation. could be caused by a connection
158 // to a not registered node or wrong use of nodes.
160 if (n == -1)
161 DOUT (DBG_ERROR, ("Invalid TopoNode %u.", Node));
162 return n;
163#else
164 return stNodeTrans[Node].NodeNr;
165#endif
166 };
167
168 // translates a system pin id to a TopoPin.
170 {
171#if (DBG)
172 TopoPins p;
173
175 // check for invalid translation. could be caused by a connection
176 // to a not registered pin or wrong use of pins.
177 if (p == PIN_INVALID)
178 DOUT (DBG_ERROR, ("Invalid pin nr %u.", Pin));
179 return p;
180#else
181 return stPinTrans[Pin].PinDef;
182#endif
183 };
184
185 // translates a TopoPin to a system pin id.
187 {
188#if (DBG)
189 int p;
190
192 // check for invalid translation. could be caused by a connection
193 // to a not registered pin or wrong use of pins.
194 if (p == -1)
195 DOUT (DBG_ERROR, ("Invalid TopoPin %u.", Pin));
196 return p;
197#else
198 return stPinTrans[Pin].PinNr;
199#endif
200 };
201
202 // sets one table entry for translation.
203 void SetNodeTranslation (IN int NodeNr, IN TopoNodes NodeDef)
204 {
205 stNodeTrans[NodeNr].NodeDef = NodeDef;
206 stNodeTrans[NodeDef].NodeNr = NodeNr;
207 };
208
209 // sets one table entry for translation.
210 void SetPinTranslation (IN int PinNr, IN TopoPins PinDef)
211 {
212 stPinTrans[PinNr].PinDef = PinDef;
213 stPinTrans[PinDef].PinNr = PinNr;
214 };
215
216 // Updates the record mute - used for DRM.
217 void UpdateRecordMute (void);
218
219public:
220 /*************************************************************************
221 * The following two macros are from STDUNK.H. DECLARE_STD_UNKNOWN()
222 * defines inline IUnknown implementations that use CUnknown's aggregation
223 * support. NonDelegatingQueryInterface() is declared, but it cannot be
224 * implemented generically. Its definition appears in MINIPORT.CPP.
225 * DEFINE_STD_CONSTRUCTOR() defines inline a constructor which accepts
226 * only the outer unknown, which is used for aggregation. The standard
227 * create macro (in MINIPORT.CPP) uses this constructor.
228 */
231
233
234 /*************************************************************************
235 * include IMiniportTopology (public/exported) methods
236 */
238
239 /*************************************************************************
240 * IAC97MiniportTopology methods
241 */
242 // returns the system pin id's for wave out, wave in and mic in.
243 STDMETHODIMP_(NTSTATUS) GetPhysicalConnectionPins
244 (
245 OUT PULONG WaveOutSource,
248 );
249
250 // sets the copy protect flag.
251 STDMETHODIMP_(void) SetCopyProtectFlag (BOOL flag)
252 {
254 {
257 }
258 };
259
260 /*************************************************************************
261 * static functions for the property handler.
262 * They are not part of an COM interface and are called directly.
263 */
264
265 // Get the data range of volume or tone controls in dB.
266 // Called by the property handler.
267 static NTSTATUS GetDBValues
268 (
271 OUT LONG *plMinimum,
272 OUT LONG *plMaximum,
273 OUT ULONG *puStep
274 );
275
276 // Calculates the speaker mute with respect to master mono.
277 // Called by the property handler.
279 (
281 IN TopoNodes Mute
282 );
283
284 // Calculates the speaker volume with respect to master mono.
285 // Called by the property handler.
287 (
290 );
291
292 // property handler for mute controls of checkboxes like Loudness.
294 (
295 IN PPCPROPERTY_REQUEST PropertyRequest
296 );
297
298 // This routine is the basic support handler for volume or tone controls.
300 (
301 IN PPCPROPERTY_REQUEST PropertyRequest
302 );
303
304 // property handler for all volume controls.
306 (
307 IN PPCPROPERTY_REQUEST PropertyRequest
308 );
309
310 // property handler for tone controls.
312 (
313 IN PPCPROPERTY_REQUEST PropertyRequest
314 );
315
316 // property handler for muxer. we have just two muxer, one for recording
317 // and one for mono out.
319 (
320 IN PPCPROPERTY_REQUEST PropertyRequest
321 );
322
323 // this says that audio is played and processed without CPU resources.
325 (
326 IN PPCPROPERTY_REQUEST PropertyRequest
327 );
328
329#ifdef INCLUDE_PRIVATE_PROPERTY
330 // property handler for private properties. we currently have only
331 // one request defined (KSPROPERTY_AC97_FEATURES).
333 (
334 IN PPCPROPERTY_REQUEST PropertyRequest
335 );
336#endif
337};
338
339#endif // _MINTOPO_H_
NTSTATUS NTAPI PropertyHandler_Private(PPCPROPERTY_REQUEST PropertyRequest)
Definition: mintopo.cpp:1337
LONG NTSTATUS
Definition: precomp.h:26
OUT PULONG OUT PULONG MicInDest
Definition: mintopo.h:248
TopoPins TransPinNrToPinDef(IN int Pin)
Definition: mintopo.h:169
PPCNODE_DESCRIPTOR NodeDescriptors
Definition: mintopo.h:101
tNodeCache stNodeCache[NODE_TOP_ELEMENT]
Definition: mintopo.h:106
static NTSTATUS GetDBValues(IN PADAPTERCOMMON, IN TopoNodes Node, OUT LONG *plMinimum, OUT LONG *plMaximum, OUT ULONG *puStep)
Definition: prophnd.cpp:156
PPCFILTER_DESCRIPTOR FilterDescriptor
Definition: mintopo.h:99
TopoNodes TransNodeNrToNodeDef(IN int Node)
Definition: mintopo.h:135
PPCPIN_DESCRIPTOR PinDescriptors
Definition: mintopo.h:100
OUT PULONG WaveInDest
Definition: mintopo.h:246
DEFINE_STD_CONSTRUCTOR(CAC97MiniportTopology)
NTSTATUS BuildPinDescriptors(void)
Definition: mintopo.cpp:704
static NTSTATUS SetMultichannelMute(IN CAC97MiniportTopology *that, IN TopoNodes Mute)
Definition: prophnd.cpp:36
int TransNodeDefToNodeNr(IN TopoNodes Node)
Definition: mintopo.h:152
NTSTATUS BuildNodeDescriptors(void)
Definition: mintopo.cpp:978
NTSTATUS BuildTopology(void)
Definition: mintopo.cpp:656
int TransPinDefToPinNr(IN TopoPins Pin)
Definition: mintopo.h:186
PADAPTERCOMMON AdapterCommon
Definition: mintopo.h:98
void SetPinTranslation(IN int PinNr, IN TopoPins PinDef)
Definition: mintopo.h:210
tNodeTranslationTable stNodeTrans[NODE_TOP_ELEMENT]
Definition: mintopo.h:105
static NTSTATUS NTAPI PropertyHandler_Ulong(IN PPCPROPERTY_REQUEST PropertyRequest)
Definition: prophnd.cpp:1373
NTSTATUS BuildConnectionDescriptors(void)
Definition: mintopo.cpp:1580
static NTSTATUS BasicSupportHandler(IN PPCPROPERTY_REQUEST PropertyRequest)
Definition: prophnd.cpp:573
static NTSTATUS NTAPI PropertyHandler_Level(IN PPCPROPERTY_REQUEST PropertyRequest)
Definition: prophnd.cpp:682
PPCCONNECTION_DESCRIPTOR ConnectionDescriptors
Definition: mintopo.h:102
static NTSTATUS SetMultichannelVolume(IN CAC97MiniportTopology *that, IN TopoNodes Volume)
Definition: prophnd.cpp:77
void UpdateRecordMute(void)
Definition: mintopo.cpp:2053
void SetNodeTranslation(IN int NodeNr, IN TopoNodes NodeDef)
Definition: mintopo.h:203
tPinTranslationTable stPinTrans[PIN_TOP_ELEMENT]
Definition: mintopo.h:104
STDMETHODIMP_(NTSTATUS) GetPhysicalConnectionPins(OUT PULONG WaveOutSource
STDMETHODIMP_(void) SetCopyProtectFlag(BOOL flag)
Definition: mintopo.h:251
static NTSTATUS NTAPI PropertyHandler_Tone(IN PPCPROPERTY_REQUEST PropertyRequest)
Definition: prophnd.cpp:1169
static NTSTATUS NTAPI PropertyHandler_OnOff(IN PPCPROPERTY_REQUEST PropertyRequest)
Definition: prophnd.cpp:327
static NTSTATUS NTAPI PropertyHandler_CpuResources(IN PPCPROPERTY_REQUEST PropertyRequest)
Definition: prophnd.cpp:1625
union node Node
Definition: types.h:1255
#define DOUT(lvl, strings)
Definition: debug.h:82
TopoNodes
Definition: shared.h:186
@ NODE_TOP_ELEMENT
Definition: shared.h:243
@ NODE_INVALID
Definition: shared.h:244
TopoPins
Definition: shared.h:112
@ PIN_TOP_ELEMENT
Definition: shared.h:136
@ PIN_INVALID
Definition: shared.h:137
IAC97AdapterCommon * PADAPTERCOMMON
Definition: shared.h:488
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:427
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned short WORD
Definition: ntddk_ex.h:93
GLdouble n
Definition: glext.h:7729
GLfloat GLfloat p
Definition: glext.h:8902
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean flag
Definition: glfuncs.h:52
const WORD AC97REG_MASK_RIGHT
Definition: mintopo.h:49
const WORD AC97REG_MASK_MUTE
Definition: mintopo.h:50
const WORD AC97REG_MASK_LEFT
Definition: mintopo.h:48
const int TOPO_MAX_CONNECTIONS
Definition: mintopo.h:42
const long PROP_MOST_NEGATIVE
Definition: mintopo.h:56
UNICODE_STRING Volume
Definition: fltkernel.h:1172
#define DBG_ERROR
Definition: nfs41_debug.h:78
long LONG
Definition: pedump.c:60
#define long
Definition: qsort.c:33
BYTE bLeftValid
Definition: mintopo.h:77
BYTE bRightValid
Definition: mintopo.h:78
long lLeft
Definition: mintopo.h:75
long lRight
Definition: mintopo.h:76
TopoNodes NodeDef
Definition: mintopo.h:37
TopoPins PinDef
Definition: mintopo.h:28
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
Definition: dlist.c:348
unsigned char BYTE
Definition: xxhash.c:193