blob: 2cf719b5fbbc51ac254eb0cba16817d92fe3322e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Uwe Zeisbergerf30c2262006-10-03 23:01:26 +02002 * sound/oss/ad1848_mixer.h
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
4 * Definitions for the mixer of AD1848 and compatible codecs.
5 */
6
7/*
8 * Copyright (C) by Hannu Savolainen 1993-1997
9 *
10 * OSS/Free for Linux is distributed under the GNU GENERAL PUBLIC LICENSE (GPL)
11 * Version 2 (June 1991). See the "COPYING" file distributed with this software
12 * for more info.
13 */
14
15
16/*
17 * The AD1848 codec has generic input lines called Line, Aux1 and Aux2.
18 * Sound card manufacturers have connected actual inputs (CD, synth, line,
19 * etc) to these inputs in different order. Therefore it's difficult
20 * to assign mixer channels to these inputs correctly. The following
21 * contains two alternative mappings. The first one is for GUS MAX and
22 * the second is just a generic one (line1, line2 and line3).
23 * (Actually this is not a mapping but rather some kind of interleaving
24 * solution).
25 */
26#define MODE1_REC_DEVICES (SOUND_MASK_LINE3 | SOUND_MASK_MIC | \
27 SOUND_MASK_LINE1 | SOUND_MASK_IMIX)
28
29#define SPRO_REC_DEVICES (SOUND_MASK_LINE | SOUND_MASK_MIC | \
30 SOUND_MASK_CD | SOUND_MASK_LINE1)
31
32#define MODE1_MIXER_DEVICES (SOUND_MASK_LINE1 | SOUND_MASK_MIC | \
33 SOUND_MASK_LINE2 | \
34 SOUND_MASK_IGAIN | \
35 SOUND_MASK_PCM | SOUND_MASK_IMIX)
36
37#define MODE2_MIXER_DEVICES (SOUND_MASK_LINE1 | SOUND_MASK_LINE2 | \
38 SOUND_MASK_MIC | \
39 SOUND_MASK_LINE3 | SOUND_MASK_SPEAKER | \
40 SOUND_MASK_IGAIN | \
41 SOUND_MASK_PCM | SOUND_MASK_IMIX)
42
43#define MODE3_MIXER_DEVICES (MODE2_MIXER_DEVICES | SOUND_MASK_VOLUME)
44
45/* OPTi 82C930 has no IMIX level control, but it can still be selected as an
46 * input
47 */
48#define C930_MIXER_DEVICES (SOUND_MASK_LINE1 | SOUND_MASK_LINE2 | \
49 SOUND_MASK_MIC | SOUND_MASK_VOLUME | \
50 SOUND_MASK_LINE3 | \
51 SOUND_MASK_IGAIN | SOUND_MASK_PCM)
52
53#define SPRO_MIXER_DEVICES (SOUND_MASK_VOLUME | SOUND_MASK_PCM | \
54 SOUND_MASK_LINE | SOUND_MASK_SYNTH | \
55 SOUND_MASK_CD | SOUND_MASK_MIC | \
56 SOUND_MASK_SPEAKER | SOUND_MASK_LINE1 | \
57 SOUND_MASK_OGAIN)
58
59struct mixer_def {
60 unsigned int regno:6; /* register number for volume */
61 unsigned int polarity:1; /* volume polarity: 0=normal, 1=reversed */
62 unsigned int bitpos:3; /* position of bits in register for volume */
63 unsigned int nbits:3; /* number of bits in register for volume */
64 unsigned int mutereg:6; /* register number for mute bit */
65 unsigned int mutepol:1; /* mute polarity: 0=normal, 1=reversed */
66 unsigned int mutepos:4; /* position of mute bit in register */
67 unsigned int recreg:6; /* register number for recording bit */
68 unsigned int recpol:1; /* recording polarity: 0=normal, 1=reversed */
69 unsigned int recpos:4; /* position of recording bit in register */
70};
71
72static char mix_cvt[101] = {
73 0, 0, 3, 7,10,13,16,19,21,23,26,28,30,32,34,35,37,39,40,42,
74 43,45,46,47,49,50,51,52,53,55,56,57,58,59,60,61,62,63,64,65,
75 65,66,67,68,69,70,70,71,72,73,73,74,75,75,76,77,77,78,79,79,
76 80,81,81,82,82,83,84,84,85,85,86,86,87,87,88,88,89,89,90,90,
77 91,91,92,92,93,93,94,94,95,95,96,96,96,97,97,98,98,98,99,99,
78 100
79};
80
81typedef struct mixer_def mixer_ent;
82typedef mixer_ent mixer_ents[2];
83
84/*
85 * Most of the mixer entries work in backwards. Setting the polarity field
86 * makes them to work correctly.
87 *
88 * The channel numbering used by individual sound cards is not fixed. Some
89 * cards have assigned different meanings for the AUX1, AUX2 and LINE inputs.
90 * The current version doesn't try to compensate this.
91 */
92
93#define MIX_ENT(name, reg_l, pola_l, pos_l, len_l, reg_r, pola_r, pos_r, len_r, mute_bit) \
94 [name] = {{reg_l, pola_l, pos_l, len_l, reg_l, 0, mute_bit, 0, 0, 8}, \
95 {reg_r, pola_r, pos_r, len_r, reg_r, 0, mute_bit, 0, 0, 8}}
96
97#define MIX_ENT2(name, reg_l, pola_l, pos_l, len_l, mute_reg_l, mute_pola_l, mute_pos_l, \
98 rec_reg_l, rec_pola_l, rec_pos_l, \
99 reg_r, pola_r, pos_r, len_r, mute_reg_r, mute_pola_r, mute_pos_r, \
100 rec_reg_r, rec_pola_r, rec_pos_r) \
101 [name] = {{reg_l, pola_l, pos_l, len_l, mute_reg_l, mute_pola_l, mute_pos_l, \
102 rec_reg_l, rec_pola_l, rec_pos_l}, \
103 {reg_r, pola_r, pos_r, len_r, mute_reg_r, mute_pola_r, mute_pos_r, \
104 rec_reg_r, rec_pola_r, rec_pos_r}}
105
106static mixer_ents ad1848_mix_devices[32] = {
107 MIX_ENT(SOUND_MIXER_VOLUME, 27, 1, 0, 4, 29, 1, 0, 4, 8),
108 MIX_ENT(SOUND_MIXER_BASS, 0, 0, 0, 0, 0, 0, 0, 0, 8),
109 MIX_ENT(SOUND_MIXER_TREBLE, 0, 0, 0, 0, 0, 0, 0, 0, 8),
110 MIX_ENT(SOUND_MIXER_SYNTH, 4, 1, 0, 5, 5, 1, 0, 5, 7),
111 MIX_ENT(SOUND_MIXER_PCM, 6, 1, 0, 6, 7, 1, 0, 6, 7),
112 MIX_ENT(SOUND_MIXER_SPEAKER, 26, 1, 0, 4, 0, 0, 0, 0, 8),
113 MIX_ENT(SOUND_MIXER_LINE, 18, 1, 0, 5, 19, 1, 0, 5, 7),
114 MIX_ENT(SOUND_MIXER_MIC, 0, 0, 5, 1, 1, 0, 5, 1, 8),
115 MIX_ENT(SOUND_MIXER_CD, 2, 1, 0, 5, 3, 1, 0, 5, 7),
116 MIX_ENT(SOUND_MIXER_IMIX, 13, 1, 2, 6, 0, 0, 0, 0, 8),
117 MIX_ENT(SOUND_MIXER_ALTPCM, 0, 0, 0, 0, 0, 0, 0, 0, 8),
118 MIX_ENT(SOUND_MIXER_RECLEV, 0, 0, 0, 0, 0, 0, 0, 0, 8),
119 MIX_ENT(SOUND_MIXER_IGAIN, 0, 0, 0, 4, 1, 0, 0, 4, 8),
120 MIX_ENT(SOUND_MIXER_OGAIN, 0, 0, 0, 0, 0, 0, 0, 0, 8),
121 MIX_ENT(SOUND_MIXER_LINE1, 2, 1, 0, 5, 3, 1, 0, 5, 7),
122 MIX_ENT(SOUND_MIXER_LINE2, 4, 1, 0, 5, 5, 1, 0, 5, 7),
123 MIX_ENT(SOUND_MIXER_LINE3, 18, 1, 0, 5, 19, 1, 0, 5, 7)
124};
125
126static mixer_ents iwave_mix_devices[32] = {
127 MIX_ENT(SOUND_MIXER_VOLUME, 25, 1, 0, 5, 27, 1, 0, 5, 8),
128 MIX_ENT(SOUND_MIXER_BASS, 0, 0, 0, 0, 0, 0, 0, 0, 8),
129 MIX_ENT(SOUND_MIXER_TREBLE, 0, 0, 0, 0, 0, 0, 0, 0, 8),
130 MIX_ENT(SOUND_MIXER_SYNTH, 4, 1, 0, 5, 5, 1, 0, 5, 7),
131 MIX_ENT(SOUND_MIXER_PCM, 6, 1, 0, 6, 7, 1, 0, 6, 7),
132 MIX_ENT(SOUND_MIXER_SPEAKER, 26, 1, 0, 4, 0, 0, 0, 0, 8),
133 MIX_ENT(SOUND_MIXER_LINE, 18, 1, 0, 5, 19, 1, 0, 5, 7),
134 MIX_ENT(SOUND_MIXER_MIC, 0, 0, 5, 1, 1, 0, 5, 1, 8),
135 MIX_ENT(SOUND_MIXER_CD, 2, 1, 0, 5, 3, 1, 0, 5, 7),
136 MIX_ENT(SOUND_MIXER_IMIX, 16, 1, 0, 5, 17, 1, 0, 5, 8),
137 MIX_ENT(SOUND_MIXER_ALTPCM, 0, 0, 0, 0, 0, 0, 0, 0, 8),
138 MIX_ENT(SOUND_MIXER_RECLEV, 0, 0, 0, 0, 0, 0, 0, 0, 8),
139 MIX_ENT(SOUND_MIXER_IGAIN, 0, 0, 0, 4, 1, 0, 0, 4, 8),
140 MIX_ENT(SOUND_MIXER_OGAIN, 0, 0, 0, 0, 0, 0, 0, 0, 8),
141 MIX_ENT(SOUND_MIXER_LINE1, 2, 1, 0, 5, 3, 1, 0, 5, 7),
142 MIX_ENT(SOUND_MIXER_LINE2, 4, 1, 0, 5, 5, 1, 0, 5, 7),
143 MIX_ENT(SOUND_MIXER_LINE3, 18, 1, 0, 5, 19, 1, 0, 5, 7)
144};
145
146static mixer_ents cs42xb_mix_devices[32] = {
147 /* Digital master volume actually has seven bits, but we only use
148 six to avoid the discontinuity when the analog gain kicks in. */
149 MIX_ENT(SOUND_MIXER_VOLUME, 46, 1, 0, 6, 47, 1, 0, 6, 7),
150 MIX_ENT(SOUND_MIXER_BASS, 0, 0, 0, 0, 0, 0, 0, 0, 8),
151 MIX_ENT(SOUND_MIXER_TREBLE, 0, 0, 0, 0, 0, 0, 0, 0, 8),
152 MIX_ENT(SOUND_MIXER_SYNTH, 4, 1, 0, 5, 5, 1, 0, 5, 7),
153 MIX_ENT(SOUND_MIXER_PCM, 6, 1, 0, 6, 7, 1, 0, 6, 7),
154 MIX_ENT(SOUND_MIXER_SPEAKER, 26, 1, 0, 4, 0, 0, 0, 0, 8),
155 MIX_ENT(SOUND_MIXER_LINE, 18, 1, 0, 5, 19, 1, 0, 5, 7),
156 MIX_ENT(SOUND_MIXER_MIC, 34, 1, 0, 5, 35, 1, 0, 5, 7),
157 MIX_ENT(SOUND_MIXER_CD, 2, 1, 0, 5, 3, 1, 0, 5, 7),
158 /* For the IMIX entry, it was not possible to use the MIX_ENT macro
159 because the mute bit is in different positions for the two
160 channels and requires reverse polarity. */
161 [SOUND_MIXER_IMIX] = {{13, 1, 2, 6, 13, 1, 0, 0, 0, 8},
162 {42, 1, 0, 6, 42, 1, 7, 0, 0, 8}},
163 MIX_ENT(SOUND_MIXER_ALTPCM, 0, 0, 0, 0, 0, 0, 0, 0, 8),
164 MIX_ENT(SOUND_MIXER_RECLEV, 0, 0, 0, 0, 0, 0, 0, 0, 8),
165 MIX_ENT(SOUND_MIXER_IGAIN, 0, 0, 0, 4, 1, 0, 0, 4, 8),
166 MIX_ENT(SOUND_MIXER_OGAIN, 0, 0, 0, 0, 0, 0, 0, 0, 8),
167 MIX_ENT(SOUND_MIXER_LINE1, 2, 1, 0, 5, 3, 1, 0, 5, 7),
168 MIX_ENT(SOUND_MIXER_LINE2, 4, 1, 0, 5, 5, 1, 0, 5, 7),
169 MIX_ENT(SOUND_MIXER_LINE3, 38, 1, 0, 6, 39, 1, 0, 6, 7)
170};
171
172/* OPTi 82C930 has somewhat different port addresses.
173 * Note: VOLUME == SPEAKER, SYNTH == LINE2, LINE == LINE3, CD == LINE1
174 * VOLUME, SYNTH, LINE, CD are not enabled above.
175 * MIC is level of mic monitoring direct to output. Same for CD, LINE, etc.
176 */
177static mixer_ents c930_mix_devices[32] = {
178 MIX_ENT(SOUND_MIXER_VOLUME, 22, 1, 1, 5, 23, 1, 1, 5, 7),
179 MIX_ENT(SOUND_MIXER_BASS, 0, 0, 0, 0, 0, 0, 0, 0, 8),
180 MIX_ENT(SOUND_MIXER_TREBLE, 0, 0, 0, 0, 0, 0, 0, 0, 8),
181 MIX_ENT(SOUND_MIXER_SYNTH, 4, 1, 1, 4, 5, 1, 1, 4, 7),
182 MIX_ENT(SOUND_MIXER_PCM, 6, 1, 0, 5, 7, 1, 0, 5, 7),
183 MIX_ENT(SOUND_MIXER_SPEAKER, 22, 1, 1, 5, 23, 1, 1, 5, 7),
184 MIX_ENT(SOUND_MIXER_LINE, 18, 1, 1, 4, 19, 1, 1, 4, 7),
185 MIX_ENT(SOUND_MIXER_MIC, 20, 1, 1, 4, 21, 1, 1, 4, 7),
186 MIX_ENT(SOUND_MIXER_CD, 2, 1, 1, 4, 3, 1, 1, 4, 7),
187 MIX_ENT(SOUND_MIXER_IMIX, 0, 0, 0, 0, 0, 0, 0, 0, 8),
188 MIX_ENT(SOUND_MIXER_ALTPCM, 0, 0, 0, 0, 0, 0, 0, 0, 8),
189 MIX_ENT(SOUND_MIXER_RECLEV, 0, 0, 0, 0, 0, 0, 0, 0, 8),
190 MIX_ENT(SOUND_MIXER_IGAIN, 0, 0, 0, 4, 1, 0, 0, 4, 8),
191 MIX_ENT(SOUND_MIXER_OGAIN, 0, 0, 0, 0, 0, 0, 0, 0, 8),
192 MIX_ENT(SOUND_MIXER_LINE1, 2, 1, 1, 4, 3, 1, 1, 4, 7),
193 MIX_ENT(SOUND_MIXER_LINE2, 4, 1, 1, 4, 5, 1, 1, 4, 7),
194 MIX_ENT(SOUND_MIXER_LINE3, 18, 1, 1, 4, 19, 1, 1, 4, 7)
195};
196
197static mixer_ents spro_mix_devices[32] = {
198 MIX_ENT (SOUND_MIXER_VOLUME, 19, 0, 4, 4, 19, 0, 0, 4, 8),
199 MIX_ENT (SOUND_MIXER_BASS, 0, 0, 0, 0, 0, 0, 0, 0, 8),
200 MIX_ENT (SOUND_MIXER_TREBLE, 0, 0, 0, 0, 0, 0, 0, 0, 8),
201 MIX_ENT2(SOUND_MIXER_SYNTH, 4, 1, 1, 4, 23, 0, 3, 0, 0, 8,
202 5, 1, 1, 4, 23, 0, 3, 0, 0, 8),
203 MIX_ENT (SOUND_MIXER_PCM, 6, 1, 1, 4, 7, 1, 1, 4, 8),
204 MIX_ENT (SOUND_MIXER_SPEAKER, 18, 0, 3, 2, 0, 0, 0, 0, 8),
205 MIX_ENT2(SOUND_MIXER_LINE, 20, 0, 4, 4, 17, 1, 4, 16, 0, 2,
206 20, 0, 0, 4, 17, 1, 3, 16, 0, 1),
207 MIX_ENT2(SOUND_MIXER_MIC, 18, 0, 0, 3, 17, 1, 0, 16, 0, 0,
208 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
209 MIX_ENT2(SOUND_MIXER_CD, 21, 0, 4, 4, 17, 1, 2, 16, 0, 4,
210 21, 0, 0, 4, 17, 1, 1, 16, 0, 3),
211 MIX_ENT (SOUND_MIXER_IMIX, 0, 0, 0, 0, 0, 0, 0, 0, 8),
212 MIX_ENT (SOUND_MIXER_ALTPCM, 0, 0, 0, 0, 0, 0, 0, 0, 8),
213 MIX_ENT (SOUND_MIXER_RECLEV, 0, 0, 0, 0, 0, 0, 0, 0, 8),
214 MIX_ENT (SOUND_MIXER_IGAIN, 0, 0, 0, 0, 0, 0, 0, 0, 8),
215 MIX_ENT (SOUND_MIXER_OGAIN, 17, 1, 6, 1, 0, 0, 0, 0, 8),
216 /* This is external wavetable */
217 MIX_ENT2(SOUND_MIXER_LINE1, 22, 0, 4, 4, 23, 1, 1, 23, 0, 4,
218 22, 0, 0, 4, 23, 1, 0, 23, 0, 5),
219};
220
221static int default_mixer_levels[32] =
222{
223 0x3232, /* Master Volume */
224 0x3232, /* Bass */
225 0x3232, /* Treble */
226 0x4b4b, /* FM */
227 0x3232, /* PCM */
228 0x1515, /* PC Speaker */
229 0x2020, /* Ext Line */
230 0x1010, /* Mic */
231 0x4b4b, /* CD */
232 0x0000, /* Recording monitor */
233 0x4b4b, /* Second PCM */
234 0x4b4b, /* Recording level */
235 0x4b4b, /* Input gain */
236 0x4b4b, /* Output gain */
237 0x2020, /* Line1 */
238 0x2020, /* Line2 */
239 0x1515 /* Line3 (usually line in)*/
240};
241
242#define LEFT_CHN 0
243#define RIGHT_CHN 1
244
245/*
246 * Channel enable bits for ioctl(SOUND_MIXER_PRIVATE1)
247 */
248
249#ifndef AUDIO_SPEAKER
250#define AUDIO_SPEAKER 0x01 /* Enable mono output */
251#define AUDIO_HEADPHONE 0x02 /* Sparc only */
252#define AUDIO_LINE_OUT 0x04 /* Sparc only */
253#endif