File: /usr/src/linux/drivers/sound/ad1848_mixer.h

1     /*
2      * sound/ad1848_mixer.h
3      *
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     
59     struct mixer_def {
60     	unsigned int regno:5;		/* 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:5;		/* 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:5;		/* 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     
72     static 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     
81     typedef struct mixer_def mixer_ent;
82     typedef 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     
106     static 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     
126     static 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     
146     /* OPTi 82C930 has somewhat different port addresses.
147      * Note: VOLUME == SPEAKER, SYNTH == LINE2, LINE == LINE3, CD == LINE1
148      * VOLUME, SYNTH, LINE, CD are not enabled above.
149      * MIC is level of mic monitoring direct to output. Same for CD, LINE, etc.
150      */
151     static mixer_ents c930_mix_devices[32] = {
152     MIX_ENT(SOUND_MIXER_VOLUME,	22, 1, 1, 5,	23, 1, 1, 5,  7),
153     MIX_ENT(SOUND_MIXER_BASS,	 0, 0, 0, 0,	 0, 0, 0, 0,  8),
154     MIX_ENT(SOUND_MIXER_TREBLE,	 0, 0, 0, 0,	 0, 0, 0, 0,  8),
155     MIX_ENT(SOUND_MIXER_SYNTH,	 4, 1, 1, 4,	 5, 1, 1, 4,  7),
156     MIX_ENT(SOUND_MIXER_PCM,	 6, 1, 0, 5,	 7, 1, 0, 5,  7),
157     MIX_ENT(SOUND_MIXER_SPEAKER,	22, 1, 1, 5,	23, 1, 1, 5,  7),
158     MIX_ENT(SOUND_MIXER_LINE,	18, 1, 1, 4,	19, 1, 1, 4,  7),
159     MIX_ENT(SOUND_MIXER_MIC,	20, 1, 1, 4,	21, 1, 1, 4,  7),
160     MIX_ENT(SOUND_MIXER_CD,		 2, 1, 1, 4,	 3, 1, 1, 4,  7),
161     MIX_ENT(SOUND_MIXER_IMIX,	 0, 0, 0, 0,	 0, 0, 0, 0,  8),
162     MIX_ENT(SOUND_MIXER_ALTPCM,	 0, 0, 0, 0,	 0, 0, 0, 0,  8),
163     MIX_ENT(SOUND_MIXER_RECLEV,	 0, 0, 0, 0,	 0, 0, 0, 0,  8),
164     MIX_ENT(SOUND_MIXER_IGAIN,	 0, 0, 0, 4,	 1, 0, 0, 4,  8),
165     MIX_ENT(SOUND_MIXER_OGAIN,	 0, 0, 0, 0,	 0, 0, 0, 0,  8),
166     MIX_ENT(SOUND_MIXER_LINE1,	 2, 1, 1, 4,	 3, 1, 1, 4,  7),
167     MIX_ENT(SOUND_MIXER_LINE2,	 4, 1, 1, 4,	 5, 1, 1, 4,  7),
168     MIX_ENT(SOUND_MIXER_LINE3,	18, 1, 1, 4,	19, 1, 1, 4,  7)
169     };
170     
171     static mixer_ents spro_mix_devices[32] = {
172     MIX_ENT (SOUND_MIXER_VOLUME,	19, 0, 4, 4,			 19, 0, 0, 4,  8),
173     MIX_ENT (SOUND_MIXER_BASS,	 0, 0, 0, 0,			  0, 0, 0, 0,  8),
174     MIX_ENT (SOUND_MIXER_TREBLE,	 0, 0, 0, 0,			  0, 0, 0, 0,  8),
175     MIX_ENT2(SOUND_MIXER_SYNTH,	 4, 1, 1, 4, 23, 0, 3,  0, 0, 8,
176     	 			 5, 1, 1, 4, 23, 0, 3, 0, 0, 8),
177     MIX_ENT (SOUND_MIXER_PCM,	 6, 1, 1, 4,			  7, 1, 1, 4,  8),
178     MIX_ENT (SOUND_MIXER_SPEAKER,	18, 0, 3, 2,			  0, 0, 0, 0,  8),
179     MIX_ENT2(SOUND_MIXER_LINE,	20, 0, 4, 4, 17, 1, 4, 16, 0, 2,
180     	 			20, 0, 0, 4, 17, 1, 3, 16, 0, 1),
181     MIX_ENT2(SOUND_MIXER_MIC,	18, 0, 0, 3, 17, 1, 0, 16, 0, 0,
182     	 			 0, 0, 0, 0,  0, 0, 0,  0, 0, 0),
183     MIX_ENT2(SOUND_MIXER_CD,	21, 0, 4, 4, 17, 1, 2, 16, 0, 4,
184     				21, 0, 0, 4, 17, 1, 1, 16, 0, 3),
185     MIX_ENT (SOUND_MIXER_IMIX,	 0, 0, 0, 0,			  0, 0, 0, 0,  8),
186     MIX_ENT (SOUND_MIXER_ALTPCM,	 0, 0, 0, 0,			  0, 0, 0, 0,  8),
187     MIX_ENT (SOUND_MIXER_RECLEV,	 0, 0, 0, 0,			  0, 0, 0, 0,  8),
188     MIX_ENT (SOUND_MIXER_IGAIN,	 0, 0, 0, 0,			  0, 0, 0, 0,  8),
189     MIX_ENT (SOUND_MIXER_OGAIN,	17, 1, 6, 1,			  0, 0, 0, 0,  8),
190     /* This is external wavetable */
191     MIX_ENT2(SOUND_MIXER_LINE1,	22, 0, 4, 4, 23, 1, 1, 23, 0, 4,
192     	 			22, 0, 0, 4, 23, 1, 0, 23, 0, 5),
193     };
194     
195     static int default_mixer_levels[32] =
196     {
197       0x3232,			/* Master Volume */
198       0x3232,			/* Bass */
199       0x3232,			/* Treble */
200       0x4b4b,			/* FM */
201       0x3232,			/* PCM */
202       0x1515,			/* PC Speaker */
203       0x2020,			/* Ext Line */
204       0x1010,			/* Mic */
205       0x4b4b,			/* CD */
206       0x0000,			/* Recording monitor */
207       0x4b4b,			/* Second PCM */
208       0x4b4b,			/* Recording level */
209       0x4b4b,			/* Input gain */
210       0x4b4b,			/* Output gain */
211       0x2020,			/* Line1 */
212       0x2020,			/* Line2 */
213       0x1515			/* Line3 (usually line in)*/
214     };
215     
216     #define LEFT_CHN	0
217     #define RIGHT_CHN	1
218     
219     /*
220      * Channel enable bits for ioctl(SOUND_MIXER_PRIVATE1)
221      */
222     
223     #ifndef AUDIO_SPEAKER
224     #define	AUDIO_SPEAKER		0x01	/* Enable mono output */
225     #define	AUDIO_HEADPHONE		0x02	/* Sparc only */
226     #define	AUDIO_LINE_OUT		0x04	/* Sparc only */
227     #endif
228