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 shared.h was reviewed by LCA in June 2011 and is acceptable for use by Microsoft. */
9
10 #ifndef _SHARED_H_
11 #define _SHARED_H_
12
13 #define PC_IMPLEMENTATION 1
14
15 //
16 // Get the NTDDK headers instead of the WDM headers that portcls.h wants to include.
17 //
18 #define WIN9X_COMPAT_SPINLOCK
19
20 #ifdef UNDER_NT
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 #include <ntddk.h>
25 #ifdef __cplusplus
26 } // extern "C"
27 #endif
28 #endif
29
30 #include <portcls.h>
31 #include <stdunk.h>
32 #include "ichreg.h"
33 #include "ac97reg.h"
34 #include "debug.h"
35
36 #ifdef __REACTOS__
37
38 PVOID
39 operator new (
40 size_t size,
41 POOL_TYPE pool_type,
42 ULONG tag);
43
44 #define GZCALL NTAPI
45 #else
46 #define GZCALL
47 #endif
48
49 /*****************************************************************************
50 * Structures and Typedefs
51 */
52
53 const ULONG PoolTag = '79CA';
54
55 // This enum defines all the possible pin configurations. It is pretty easy,
56 // cause a pin can be there or not, depending if the CoDec supports it (like
57 // Headphone output (PINC_HPOUT_PRESENT)) or if the OEM disabled the feature
58 // with a private inf file.
59 // Look at common.h file for the registry string names.
60 // ATTN: Don't change without changing the static struct in common.cpp too.
61 enum TopoPinConfig
62 {
63 PINC_PCBEEP_PRESENT = 0,
64 PINC_PHONE_PRESENT,
65 PINC_MIC2_PRESENT,
66 PINC_VIDEO_PRESENT,
67 PINC_AUX_PRESENT,
68 PINC_HPOUT_PRESENT,
69 PINC_MONOOUT_PRESENT,
70 PINC_MICIN_PRESENT,
71 PINC_MIC_PRESENT,
72 PINC_LINEIN_PRESENT,
73 PINC_CD_PRESENT,
74 PINC_SURROUND_PRESENT,
75 PINC_CENTER_LFE_PRESENT,
76 PINC_TOP_ELEMENT // number of PINC's
77 };
78
79 // This enum defines the functional configuration, called nodes. Nodes are
80 // black boxes that implement a functionality like 3d (NODEC_3D_PRESENT).
81 // At startup, we probe the Codec for features (like the pins above) and
82 // initialize an array which holds the configuration.
83 enum TopoNodeConfig
84 {
85 NODEC_3D_PRESENT = 0,
86 NODEC_TONE_PRESENT,
87 NODEC_LOUDNESS_PRESENT,
88 NODEC_SIMUL_STEREO_PRESENT,
89 NODEC_6BIT_MASTER_VOLUME,
90 NODEC_6BIT_HPOUT_VOLUME,
91 NODEC_6BIT_MONOOUT_VOLUME,
92 NODEC_6BIT_SURROUND_VOLUME,
93 NODEC_6BIT_CENTER_LFE_VOLUME,
94 NODEC_3D_CENTER_ADJUSTABLE,
95 NODEC_3D_DEPTH_ADJUSTABLE,
96 NODEC_PCM_VARIABLERATE_SUPPORTED,
97 NODEC_PCM_VSR_INDEPENDENT_RATES,
98 NODEC_PCM_DOUBLERATE_SUPPORTED,
99 NODEC_MIC_VARIABLERATE_SUPPORTED,
100 NODEC_CENTER_DAC_PRESENT,
101 NODEC_SURROUND_DAC_PRESENT,
102 NODEC_LFE_DAC_PRESENT,
103 NODEC_TOP_ELEMENT // number of NODES's
104 };
105
106 //
107 // Pin Defininition goes here
108 // We define all the possible pins in the AC97 CoDec and some "virtual" pins
109 // that are used for the topology to connect special functionality like 3D.
110 //
111 enum TopoPins
112 {
113 // Source is something that goes into the AC97, dest goes out.
114 PIN_WAVEOUT_SOURCE = 0,
115 PIN_PCBEEP_SOURCE,
116 PIN_PHONE_SOURCE,
117 PIN_MIC_SOURCE,
118 PIN_LINEIN_SOURCE,
119 PIN_CD_SOURCE,
120 PIN_VIDEO_SOURCE,
121 PIN_AUX_SOURCE,
122 PIN_VIRT_3D_CENTER_SOURCE,
123 PIN_VIRT_3D_DEPTH_SOURCE,
124 PIN_VIRT_3D_MIX_MONO_SOURCE,
125 PIN_VIRT_TONE_MIX_SOURCE,
126 PIN_VIRT_TONE_MIX_MONO_SOURCE,
127 PIN_VIRT_SURROUND_SOURCE,
128 PIN_VIRT_CENTER_SOURCE,
129 PIN_VIRT_LFE_SOURCE,
130 PIN_VIRT_FRONT_SOURCE,
131 PIN_MASTEROUT_DEST,
132 PIN_HPOUT_SOURCE,
133 PIN_MONOOUT_DEST,
134 PIN_WAVEIN_DEST,
135 PIN_MICIN_DEST,
136 PIN_TOP_ELEMENT, // number of pins
137 PIN_INVALID
138 };
139
140 #if (DBG)
141 // In case we print some debug information about the pins, we use the names
142 // defined here.
143 const PCHAR TopoPinStrings[] =
144 {
145 "PIN_WAVEOUT_SOURCE",
146 "PIN_PCBEEP_SOURCE",
147 "PIN_PHONE_SOURCE",
148 "PIN_MIC_SOURCE",
149 "PIN_LINEIN_SOURCE",
150 "PIN_CD_SOURCE",
151 "PIN_VIDEO_SOURCE",
152 "PIN_AUX_SOURCE",
153 "PIN_VIRT_3D_CENTER_SOURCE",
154 "PIN_VIRT_3D_DEPTH_SOURCE",
155 "PIN_VIRT_3D_MIX_MONO_SOURCE",
156 "PIN_VIRT_TONE_MIX_SOURCE",
157 "PIN_VIRT_TONE_MIX_MONO_SOURCE",
158 "PIN_VIRT_SURROUND_SOURCE",
159 "PIN_VIRT_CENTER_SOURCE",
160 "PIN_VIRT_LFE_SOURCE",
161 "PIN_VIRT_FRONT_SOURCE",
162 "PIN_MASTEROUT_DEST",
163 "PIN_HPOUT_SOURCE",
164 "PIN_MONOOUT_DEST",
165 "PIN_WAVEIN_DEST",
166 "PIN_MICIN_DEST",
167 "TOP_ELEMENT", // should never dump this
168 "INVALID" // or this either
169 };
170 #endif
171
172
173 //
174 // Node Definition goes here.
175 // We define all the possible nodes here (nodes are black boxes that represent
176 // a functional block like bass volume) and some virtual nodes, mainly volume
177 // controls, that are used to represent special functionality in the topology
178 // like 3D controls (exposed as volumes) or to give the user volume controls
179 // for each possible record line. In that case, the volume is placed in front
180 // of the record selector (mux). The topology is not parsed correctly if there
181 // are no volume controls between the pins and a muxer. Also, these virtual
182 // controls only represent volumes and no mutes, cause mutes wouldn't be dis-
183 // played by sndvol32.
184 // ATTN: DON'T change without first looking at the table in ac97reg.h!!!
185 enum TopoNodes
186 {
187 NODE_WAVEOUT_VOLUME = 0,
188 NODE_WAVEOUT_MUTE,
189 NODE_VIRT_WAVEOUT_3D_BYPASS, // exposed as AGC control
190 NODE_PCBEEP_VOLUME,
191 NODE_PCBEEP_MUTE,
192 NODE_PHONE_VOLUME,
193 NODE_PHONE_MUTE,
194 NODE_MIC_SELECT,
195 NODE_MIC_BOOST,
196 NODE_MIC_VOLUME,
197 NODE_MIC_MUTE,
198 NODE_LINEIN_VOLUME,
199 NODE_LINEIN_MUTE,
200 NODE_CD_VOLUME,
201 NODE_CD_MUTE,
202 NODE_VIDEO_VOLUME,
203 NODE_VIDEO_MUTE,
204 NODE_AUX_VOLUME,
205 NODE_AUX_MUTE,
206 NODE_MAIN_MIX,
207 NODE_VIRT_3D_CENTER, // we have no 3D control type, so we
208 NODE_VIRT_3D_DEPTH, // expose 2 volume controls and 2 mute
209 NODE_VIRT_3D_ENABLE, // checkboxs (the other is bypass).
210 NODE_BEEP_MIX,
211 NODE_BASS,
212 NODE_TREBLE,
213 NODE_LOUDNESS,
214 NODE_SIMUL_STEREO,
215 NODE_MASTEROUT_VOLUME,
216 NODE_MASTEROUT_MUTE,
217 NODE_HPOUT_VOLUME,
218 NODE_HPOUT_MUTE,
219 NODE_MONOOUT_SELECT,
220 NODE_VIRT_MONOOUT_VOLUME1, // each mono out must have volume
221 NODE_VIRT_MONOOUT_VOLUME2,
222 NODE_WAVEIN_SELECT,
223 NODE_VIRT_MASTER_INPUT_VOLUME1, // boy, each master input must have a
224 NODE_VIRT_MASTER_INPUT_VOLUME2, // volume
225 NODE_VIRT_MASTER_INPUT_VOLUME3,
226 NODE_VIRT_MASTER_INPUT_VOLUME4,
227 NODE_VIRT_MASTER_INPUT_VOLUME5,
228 NODE_VIRT_MASTER_INPUT_VOLUME6,
229 NODE_VIRT_MASTER_INPUT_VOLUME7,
230 NODE_VIRT_MASTER_INPUT_VOLUME8,
231 NODE_MICIN_VOLUME,
232 NODE_MICIN_MUTE,
233 NODE_SURROUND_VOLUME,
234 NODE_SURROUND_MUTE,
235 NODE_CENTER_VOLUME,
236 NODE_CENTER_MUTE,
237 NODE_LFE_VOLUME,
238 NODE_LFE_MUTE,
239 NODE_FRONT_VOLUME,
240 NODE_FRONT_MUTE,
241 NODE_VIRT_MASTERMONO_VOLUME, // used for multichannel or headphone
242 NODE_VIRT_MASTERMONO_MUTE,
243 NODE_TOP_ELEMENT, // number of nodes
244 NODE_INVALID
245 };
246
247 #if (DBG)
248 // In case we print some debug information about the nodes, we use names
249 // defined here.
250 const PCHAR NodeStrings[] =
251 {
252 "WAVEOUT_VOLUME",
253 "WAVEOUT_MUTE",
254 "WAVEOUT_3D_BYPASS",
255 "PCBEEP_VOLUME",
256 "PCBEEP_MUTE",
257 "PHONE_VOLUME",
258 "PHONE_MUTE",
259 "MIC_SELECT",
260 "MIC_BOOST",
261 "MIC_VOLUME",
262 "MIC_MUTE",
263 "LINEIN_VOLUME",
264 "LINEIN_MUTE",
265 "CD_VOLUME",
266 "CD_MUTE",
267 "VIDEO_VOLUME",
268 "VIDEO_MUTE",
269 "AUX_VOLUME",
270 "AUX_MUTE",
271 "MAIN_MIX",
272 "3D_CENTER",
273 "3D_DEPTH",
274 "3D_ENABLE",
275 "BEEP_MIX",
276 "BASS",
277 "TREBLE",
278 "LOUDNESS",
279 "SIMUL_STEREO",
280 "MASTER_VOLUME",
281 "MASTER_MUTE",
282 "HPOUT_VOLUME",
283 "HPOUT_MUTE",
284 "MONOOUT_SELECT",
285 "MONOOUT_VOLUME_3D_MIX",
286 "MONOOUT_VOLUME_MIC",
287 "WAVEIN_SELECT",
288 "MASTER_INPUT_VOLUME_MIC",
289 "MASTER_INPUT_VOLUME_CD",
290 "MASTER_INPUT_VOLUME_VIDEO",
291 "MASTER_INPUT_VOLUME_AUX",
292 "MASTER_INPUT_VOLUME_LINEIN",
293 "MASTER_INPUT_VOLUME_TONE_MIX",
294 "MASTER_INPUT_VOLUME_TONE_MIX_MONO",
295 "MASTER_INPUT_VOLUME_PHONE",
296 "MICIN_VOLUME",
297 "MICIN_MUTE",
298 "SURROUND_VOLUME",
299 "SURROUND_MUTE",
300 "CENTER_VOLUME",
301 "CENTER_MUTE",
302 "LFE_VOLUME",
303 "LFE_MUTE",
304 "FRONT_VOLUME",
305 "FRONT_MUTE",
306 "VIRT_MASTERMONO_VOLUME",
307 "VIRT_MASTERMONO_MUTE",
308 "TOP_ELEMENT", // should never dump this
309 "INVALID" // or this
310 };
311 #endif
312
313 //
314 // The pins used for the wave miniport connection.
315 //
316 enum WavePins
317 {
318 PIN_WAVEOUT = 0,
319 PIN_WAVEOUT_BRIDGE,
320 PIN_WAVEIN,
321 PIN_WAVEIN_BRIDGE,
322 PIN_MICIN,
323 PIN_MICIN_BRIDGE
324 };
325
326 //
327 // The nodes used for the wave miniport connection.
328 //
329 enum WaveNodes
330 {
331 NODE_WAVEOUT_DAC,
332 NODE_WAVEIN_ADC,
333 NODE_MICIN_ADC
334 };
335
336 /*****************************************************************************
337 * Function prototypes
338 */
339
340 /*****************************************************************************
341 * NewAdapterCommon()
342 *****************************************************************************
343 * Create a new adapter common object.
344 */
345 NTSTATUS NewAdapterCommon
346 (
347 OUT PUNKNOWN * Unknown,
348 IN REFCLSID,
349 IN PUNKNOWN UnknownOuter OPTIONAL,
350 _When_((PoolType & NonPagedPoolMustSucceed) != 0,
351 __drv_reportError("Must succeed pool allocations are forbidden. "
352 "Allocation failures cause a system crash"))
353 IN POOL_TYPE PoolType
354 );
355
356 /*****************************************************************************
357 * Class definitions
358 */
359
360 /*****************************************************************************
361 * IAC97MiniportTopology
362 *****************************************************************************
363 * Interface for topology miniport.
364 */
DECLARE_INTERFACE_(IAC97MiniportTopology,IMiniportTopology)365 DECLARE_INTERFACE_(IAC97MiniportTopology,IMiniportTopology)
366 {
367 STDMETHOD_(NTSTATUS,GetPhysicalConnectionPins)
368 ( THIS_
369 OUT PULONG WaveOutSource,
370 OUT PULONG WaveInDest,
371 OUT PULONG MicInDest
372 ) PURE;
373 // Used for DRM:
374 STDMETHOD_(void, SetCopyProtectFlag)
375 ( THIS_
376 IN BOOL
377 ) PURE;
378 };
379
380 typedef IAC97MiniportTopology *PAC97MINIPORTTOPOLOGY;
381
382 /*****************************************************************************
383 * IAC97AdapterCommon
384 *****************************************************************************
385 * Interface for adapter common object.
386 */
DECLARE_INTERFACE_(IAC97AdapterCommon,IUnknown)387 DECLARE_INTERFACE_(IAC97AdapterCommon,IUnknown)
388 {
389 STDMETHOD_(NTSTATUS,Init)
390 ( THIS_
391 IN PRESOURCELIST ResourceList,
392 IN PDEVICE_OBJECT DeviceObject
393 ) PURE;
394 STDMETHOD_(BOOL,GetPinConfig)
395 ( THIS_
396 IN TopoPinConfig
397 ) PURE;
398 STDMETHOD_(void,SetPinConfig)
399 ( THIS_
400 IN TopoPinConfig,
401 IN BOOL
402 ) PURE;
403 STDMETHOD_(BOOL,GetNodeConfig)
404 ( THIS_
405 IN TopoNodeConfig
406 ) PURE;
407 STDMETHOD_(void,SetNodeConfig)
408 ( THIS_
409 IN TopoNodeConfig,
410 IN BOOL
411 ) PURE;
412 STDMETHOD_(AC97Register,GetNodeReg)
413 ( THIS_
414 IN TopoNodes
415 ) PURE;
416 STDMETHOD_(WORD,GetNodeMask)
417 ( THIS_
418 IN TopoNodes
419 ) PURE;
420 STDMETHOD_(NTSTATUS,ReadCodecRegister)
421 ( THIS_
422 _In_range_(0, AC97REG_INVALID) IN AC97Register Register,
423 _Out_ OUT PWORD wData
424 ) PURE;
425 STDMETHOD_(NTSTATUS,WriteCodecRegister)
426 ( THIS_
427 _In_range_(0, AC97REG_INVALID) IN AC97Register Register,
428 _In_ IN WORD wData,
429 _In_ IN WORD wMask
430 ) PURE;
431 STDMETHOD_(UCHAR,ReadBMControlRegister8)
432 ( THIS_
433 IN ULONG Offset
434 ) PURE;
435 STDMETHOD_(USHORT,ReadBMControlRegister16)
436 ( THIS_
437 IN ULONG Offset
438 ) PURE;
439 STDMETHOD_(ULONG,ReadBMControlRegister32)
440 ( THIS_
441 IN ULONG Offset
442 ) PURE;
443 STDMETHOD_(void,WriteBMControlRegister)
444 ( THIS_
445 IN ULONG Offset,
446 IN UCHAR Value
447 ) PURE;
448 STDMETHOD_(void,WriteBMControlRegister)
449 ( THIS_
450 IN ULONG Offset,
451 IN USHORT Value
452 ) PURE;
453 STDMETHOD_(void,WriteBMControlRegister)
454 ( THIS_
455 IN ULONG Offset,
456 IN ULONG Value
457 ) PURE;
458 STDMETHOD_(NTSTATUS, RestoreCodecRegisters)
459 ( THIS_
460 void
461 ) PURE;
462 STDMETHOD_(NTSTATUS, ProgramSampleRate)
463 ( THIS_
464 IN AC97Register Register,
465 IN DWORD dwSampleRate
466 ) PURE;
467 // Used for DRM:
468 STDMETHOD_(void, SetMiniportTopology)
469 ( THIS_
470 IN PAC97MINIPORTTOPOLOGY
471 ) PURE;
472 STDMETHOD_(PAC97MINIPORTTOPOLOGY, GetMiniportTopology)
473 ( THIS_
474 void
475 ) PURE;
476 // These are used by the wave miniport.
477 STDMETHOD_(void, ReadChannelConfigDefault)
478 ( THIS_
479 PDWORD pwChannelConfig,
480 PWORD pwChannels
481 ) PURE;
482 STDMETHOD_(void, WriteChannelConfigDefault)
483 ( THIS_
484 DWORD dwChannelConfig
485 ) PURE;
486 };
487
488 typedef IAC97AdapterCommon *PADAPTERCOMMON;
489
490 /*****************************************************************************
491 * Guids for the Interfaces
492 *****************************************************************************
493 */
494
495 // {77481FA0-1EF2-11d2-883A-0080C765647D}
496 DEFINE_GUID(IID_IAC97AdapterCommon,
497 0x77481fa0, 0x1ef2, 0x11d2, 0x88, 0x3a, 0x0, 0x80, 0xc7, 0x65, 0x64, 0x7d);
498
499 // {245AE964-49C8-11d2-95D7-00C04FB925D3}
500 DEFINE_GUID(IID_IAC97MiniportTopology,
501 0x245ae964, 0x49c8, 0x11d2, 0x95, 0xd7, 0x0, 0xc0, 0x4f, 0xb9, 0x25, 0xd3);
502
503 #endif //_SHARED_H_
504
505