1 /*
2 * sound/ad1848_mixer.h
3 *
4 * Definitions for the mixer of AD1848 and compatible codecs.
5 */
6
7 /*
8 * Copyright by Hannu Savolainen 1993-1996
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are
12 * met: 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 2.
14 * Redistributions in binary form must reproduce the above copyright notice,
15 * this list of conditions and the following disclaimer in the documentation
16 * and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
22 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31
32 /*
33 * The AD1848 codec has generic input lines called Line, Aux1 and Aux2.
34 * Soundcard manufacturers have connected actual inputs (CD, synth, line,
35 * etc) to these inputs in different order. Therefore it's difficult
36 * to assign mixer channels to to these inputs correctly. The following
37 * contains two alternative mappings. The first one is for GUS MAX and
38 * the second is just a generic one (line1, line2 and line3).
39 * (Actually this is not a mapping but rather some kind of interleaving
40 * solution).
41 */
42 #define MODE1_REC_DEVICES (SOUND_MASK_LINE3 | SOUND_MASK_MIC | \
43 SOUND_MASK_LINE1|SOUND_MASK_IMIX)
44
45 #define MODE1_MIXER_DEVICES (SOUND_MASK_LINE1 | SOUND_MASK_MIC | \
46 SOUND_MASK_LINE2 | \
47 SOUND_MASK_IGAIN | \
48 SOUND_MASK_PCM | SOUND_MASK_IMIX)
49
50 #define MODE2_MIXER_DEVICES (SOUND_MASK_LINE1 | SOUND_MASK_LINE2 | SOUND_MASK_MIC | \
51 SOUND_MASK_LINE3 | SOUND_MASK_SPEAKER | \
52 SOUND_MASK_IGAIN | \
53 SOUND_MASK_PCM | SOUND_MASK_IMIX)
54
55 #define MODE3_MIXER_DEVICES (MODE2_MIXER_DEVICES | SOUND_MASK_VOLUME)
56
57 struct mixer_def {
58 unsigned int regno: 7;
59 unsigned int polarity:1; /* 0=normal, 1=reversed */
60 unsigned int bitpos:4;
61 unsigned int nbits:4;
62 };
63
64 static char mix_cvt[101] = {
65 0, 0,3,7,10,13,16,19,21,23,26,28,30,32,34,35,37,39,40,42,
66 43,45,46,47,49,50,51,52,53,55,56,57,58,59,60,61,62,63,64,65,
67 65,66,67,68,69,70,70,71,72,73,73,74,75,75,76,77,77,78,79,79,
68 80,81,81,82,82,83,84,84,85,85,86,86,87,87,88,88,89,89,90,90,
69 91,91,92,92,93,93,94,94,95,95,96,96,96,97,97,98,98,98,99,99,
70 100
71 };
72
73 typedef struct mixer_def mixer_ent;
74
75 /*
76 * Most of the mixer entries work in backwards. Setting the polarity field
77 * makes them to work correctly.
78 *
79 * The channel numbering used by individual soundcards is not fixed. Some
80 * cards have assigned different meanings for the AUX1, AUX2 and LINE inputs.
81 * The current version doesn't try to compensate this.
82 */
83
84 #define MIX_ENT(name, reg_l, pola_l, pos_l, len_l, reg_r, pola_r, pos_r, len_r) \
85 {{reg_l, pola_l, pos_l, len_l}, {reg_r, pola_r, pos_r, len_r}}
86
87 mixer_ent mix_devices[32][2] = {
88 MIX_ENT(SOUND_MIXER_VOLUME, 27, 1, 0, 4, 29, 1, 0, 4),
89 MIX_ENT(SOUND_MIXER_BASS, 0, 0, 0, 0, 0, 0, 0, 0),
90 MIX_ENT(SOUND_MIXER_TREBLE, 0, 0, 0, 0, 0, 0, 0, 0),
91 MIX_ENT(SOUND_MIXER_SYNTH, 4, 1, 0, 5, 5, 1, 0, 5),
92 MIX_ENT(SOUND_MIXER_PCM, 6, 1, 0, 6, 7, 1, 0, 6),
93 MIX_ENT(SOUND_MIXER_SPEAKER, 26, 1, 0, 4, 0, 0, 0, 0),
94 MIX_ENT(SOUND_MIXER_LINE, 18, 1, 0, 5, 19, 1, 0, 5),
95 MIX_ENT(SOUND_MIXER_MIC, 0, 0, 5, 1, 1, 0, 5, 1),
96 MIX_ENT(SOUND_MIXER_CD, 2, 1, 0, 5, 3, 1, 0, 5),
97 MIX_ENT(SOUND_MIXER_IMIX, 13, 1, 2, 6, 0, 0, 0, 0),
98 MIX_ENT(SOUND_MIXER_ALTPCM, 0, 0, 0, 0, 0, 0, 0, 0),
99 MIX_ENT(SOUND_MIXER_RECLEV, 0, 0, 0, 0, 0, 0, 0, 0),
100 MIX_ENT(SOUND_MIXER_IGAIN, 0, 0, 0, 4, 1, 0, 0, 4),
101 MIX_ENT(SOUND_MIXER_OGAIN, 0, 0, 0, 0, 0, 0, 0, 0),
102 MIX_ENT(SOUND_MIXER_LINE1, 2, 1, 0, 5, 3, 1, 0, 5),
103 MIX_ENT(SOUND_MIXER_LINE2, 4, 1, 0, 5, 5, 1, 0, 5),
104 MIX_ENT(SOUND_MIXER_LINE3, 18, 1, 0, 5, 19, 1, 0, 5)
105 };
106
107 static unsigned short default_mixer_levels[SOUND_MIXER_NRDEVICES] =
108 {
109 0x3232, /* Master Volume */
110 0x3232, /* Bass */
111 0x3232, /* Treble */
112 0x4b4b, /* FM */
113 0x3232, /* PCM */
114 0x4b4b, /* PC Speaker */
115 0x2020, /* Ext Line */
116 0x1010, /* Mic */
117 0x4b4b, /* CD */
118 0x0000, /* Recording monitor */
119 0x4b4b, /* SB PCM */
120 0x4b4b, /* Recording level */
121 0x4b4b, /* Input gain */
122 0x4b4b, /* Output gain */
123 0x4040, /* Line1 */
124 0x4040, /* Line2 */
125 0x1515 /* Line3 (usually line in)*/
126 };
127
128 #define LEFT_CHN 0
129 #define RIGHT_CHN 1