ReactOS 0.4.16-dev-300-g2aadf2e
mixer.c
Go to the documentation of this file.
1/*
2 ReactOS Sound System
3 Sound Blaster DSP support
4 Mixer routines
5
6 Author:
7 Andrew Greenwood (silverblade@reactos.org)
8
9 History:
10 2 July 2008 - Created
11
12 Notes:
13 Functions documented in sbdsp.h
14
15 Currently, input/output switches and PC speaker volume
16 level are not supported.
17
18 The I/O switches are used for muting/unmuting mic, etc.
19*/
20
21#include "precomp.h"
22
23VOID
25{
27 /* Are we meant to send anything else? */
28}
29
34 OUT PUCHAR PackedLevel)
35{
36 if ( ! PackedLevel )
38
39 switch ( Line )
40 {
51 case SB_MIX_MIC_LEVEL :
52 case SB_MIX_LEGACY_MIC_LEVEL : /* is this correct? */
53 {
54 if ( Level >= 0x20 )
56
57 *PackedLevel = Level << 3;
58 return STATUS_SUCCESS;
59 }
60
65 {
66 if ( Level >= 0x04 )
68
69 *PackedLevel = Level << 6;
70 return STATUS_SUCCESS;
71 }
72
73 case SB_MIX_VOC_LEVEL : /* legacy */
75 case SB_MIX_FM_LEVEL :
76 case SB_MIX_CD_LEVEL :
78 case SB_MIX_TREBLE_LEFT_LEVEL : /* bass/treble */
82 {
83 if ( Level >= 0x10 )
85
86 *PackedLevel = Level << 4;
87 return STATUS_SUCCESS;
88 }
89
90 default :
92 };
93}
94
98 IN UCHAR PackedLevel,
100{
101 if ( ! Level )
103
104 switch ( Line )
105 {
116 case SB_MIX_MIC_LEVEL :
117 {
118 *Level = PackedLevel >> 3;
119 return STATUS_SUCCESS;
120 }
121
126 {
127 *Level = PackedLevel >> 6;
128 return STATUS_SUCCESS;
129 }
130
131 case SB_MIX_VOC_LEVEL : /* legacy */
133 case SB_MIX_FM_LEVEL :
134 case SB_MIX_CD_LEVEL :
135 case SB_MIX_LINE_LEVEL :
136 case SB_MIX_TREBLE_LEFT_LEVEL : /* bass/treble */
140 {
141 *Level = PackedLevel >> 4;
142 return STATUS_SUCCESS;
143 }
144
145 default :
147 };
148}
149
152 IN PUCHAR BasePort,
153 IN UCHAR Line,
154 IN UCHAR Level)
155{
156 UCHAR PackedLevel = 0;
158
159 Status = SbMixerPackLevelData(Line, Level, &PackedLevel);
160
161 switch ( Status )
162 {
163 case STATUS_SUCCESS :
164 break;
165
168
171
172 default :
173 return Status;
174 };
175
176 DbgPrint("SbMixerSetLevel: Line 0x%x, raw level 0x%x, packed 0x%x\n", Line, Level, PackedLevel);
177
178 WRITE_SB_MIXER_REGISTER(BasePort, Line);
179 WRITE_SB_MIXER_DATA(BasePort, PackedLevel);
180
181 return STATUS_SUCCESS;
182}
183
186 IN PUCHAR BasePort,
187 IN UCHAR Line,
189{
190 UCHAR PackedLevel = 0;
192
193 if ( ! Level )
195
196 WRITE_SB_MIXER_REGISTER(BasePort, Line);
197 PackedLevel = READ_SB_MIXER_DATA(BasePort);
198
199 Status = SbMixerUnpackLevelData(Line, PackedLevel, Level);
200
201 switch ( Status )
202 {
203 case STATUS_SUCCESS :
204 break;
205
208
211
212 default :
213 return Status;
214 };
215
216 DbgPrint("SbMixerGetLevel: Line 0x%x, raw level 0x%x, packed 0x%x\n", Line, Level, PackedLevel);
217
218 return STATUS_SUCCESS;
219}
220
221VOID
223{
224 /* Untested... */
226 WRITE_SB_MIXER_DATA(BasePort, 1);
227}
228
229VOID
231{
232 /* Untested... */
234 WRITE_SB_MIXER_DATA(BasePort, 0);
235}
236
239{
240 /* Untested... */
242 return (READ_SB_MIXER_DATA(BasePort) != 0);
243}
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: gdiplustypes.h:25
#define DbgPrint
Definition: hal.h:12
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:476
#define STATUS_INVALID_PARAMETER_1
Definition: ntstatus.h:475
#define STATUS_INVALID_PARAMETER_3
Definition: ntstatus.h:477
#define SB_MIX_RESET
Definition: sbdsp.h:93
#define SB_MIX_LINE_LEVEL
Definition: sbdsp.h:88
#define WRITE_SB_MIXER_DATA(bp, x)
Definition: sbdsp.h:45
#define SB_MIX_CD_RIGHT_LEVEL
Definition: sbdsp.h:101
#define SB_MIX_MIDI_LEFT_LEVEL
Definition: sbdsp.h:98
#define WRITE_SB_MIXER_REGISTER(bp, x)
Definition: sbdsp.h:43
#define SB_MIX_INPUT_LEFT_GAIN
Definition: sbdsp.h:109
#define SB_MIX_MIC_LEVEL
Definition: sbdsp.h:104
#define SB_MIX_BASS_RIGHT_LEVEL
Definition: sbdsp.h:117
#define SB_MIX_MASTER_LEFT_LEVEL
Definition: sbdsp.h:94
#define SB_MIX_AGC
Definition: sbdsp.h:113
#define SB_MIX_CD_LEVEL
Definition: sbdsp.h:87
#define SB_MIX_INPUT_RIGHT_GAIN
Definition: sbdsp.h:110
#define SB_MIX_MASTER_LEVEL
Definition: sbdsp.h:85
#define SB_MIX_VOC_LEFT_LEVEL
Definition: sbdsp.h:96
#define SB_MIX_BASS_LEFT_LEVEL
Definition: sbdsp.h:116
#define SB_MIX_LINE_RIGHT_LEVEL
Definition: sbdsp.h:103
#define SB_MIX_MASTER_RIGHT_LEVEL
Definition: sbdsp.h:95
#define SB_MIX_LEGACY_MIC_LEVEL
Definition: sbdsp.h:84
#define SB_MIX_VOC_LEVEL
Definition: sbdsp.h:83
#define SB_MIX_OUTPUT_LEFT_GAIN
Definition: sbdsp.h:111
#define READ_SB_MIXER_DATA(bp)
Definition: sbdsp.h:44
#define SB_MIX_TREBLE_LEFT_LEVEL
Definition: sbdsp.h:114
#define SB_MIX_OUTPUT_RIGHT_GAIN
Definition: sbdsp.h:112
#define SB_MIX_TREBLE_RIGHT_LEVEL
Definition: sbdsp.h:115
#define SB_MIX_VOC_RIGHT_LEVEL
Definition: sbdsp.h:97
#define SB_MIX_LINE_LEFT_LEVEL
Definition: sbdsp.h:102
#define SB_MIX_FM_LEVEL
Definition: sbdsp.h:86
#define SB_MIX_CD_LEFT_LEVEL
Definition: sbdsp.h:100
#define SB_MIX_MIDI_RIGHT_LEVEL
Definition: sbdsp.h:99
BOOLEAN SbMixerIsAGCEnabled(IN PUCHAR BasePort)
Definition: mixer.c:238
NTSTATUS SbMixerUnpackLevelData(IN UCHAR Line, IN UCHAR PackedLevel, OUT PUCHAR Level)
Definition: mixer.c:96
VOID SbMixerEnableAGC(IN PUCHAR BasePort)
Definition: mixer.c:222
NTSTATUS SbMixerSetLevel(IN PUCHAR BasePort, IN UCHAR Line, IN UCHAR Level)
Definition: mixer.c:151
NTSTATUS SbMixerPackLevelData(IN UCHAR Line, IN UCHAR Level, OUT PUCHAR PackedLevel)
Definition: mixer.c:31
VOID SbMixerReset(IN PUCHAR BasePort)
Definition: mixer.c:24
NTSTATUS SbMixerGetLevel(IN PUCHAR BasePort, IN UCHAR Line, OUT PUCHAR Level)
Definition: mixer.c:185
VOID SbMixerDisableAGC(IN PUCHAR BasePort)
Definition: mixer.c:230
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: ncftp.h:79
#define IN
Definition: typedefs.h:39
unsigned char * PUCHAR
Definition: typedefs.h:53
#define OUT
Definition: typedefs.h:40
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:56
unsigned char UCHAR
Definition: xmlstorage.h:181