2 * ALSA driver for ICEnsemble ICE1712 (Envy24)
4 * Lowlevel functions for M-Audio Revolution 7.1
6 * Copyright (c) 2003 Takashi Iwai <tiwai@suse.de>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <sound/driver.h>
26 #include <linux/delay.h>
27 #include <linux/interrupt.h>
28 #include <linux/init.h>
29 #include <linux/slab.h>
30 #include <sound/core.h>
36 static void revo_i2s_mclk_changed(struct snd_ice1712
*ice
)
38 /* assert PRST# to converters; MT05 bit 7 */
39 outb(inb(ICEMT1724(ice
, AC97_CMD
)) | 0x80, ICEMT1724(ice
, AC97_CMD
));
42 outb(inb(ICEMT1724(ice
, AC97_CMD
)) & ~0x80, ICEMT1724(ice
, AC97_CMD
));
46 * change the rate of envy24HT, AK4355 and AK4381
48 static void revo_set_rate_val(struct snd_akm4xxx
*ak
, unsigned int rate
)
50 unsigned char old
, tmp
, dfs
;
53 if (rate
== 0) /* no hint - S/PDIF input is master, simply return */
56 /* adjust DFS on codecs */
59 else if (rate
> 48000)
64 if (ak
->type
== SND_AK4355
|| ak
->type
== SND_AK4358
) {
71 tmp
= snd_akm4xxx_get(ak
, 0, reg
);
72 old
= (tmp
>> shift
) & 0x03;
77 snd_akm4xxx_reset(ak
, 1);
78 tmp
= snd_akm4xxx_get(ak
, 0, reg
);
79 tmp
&= ~(0x03 << shift
);
81 // snd_akm4xxx_write(ak, 0, reg, tmp);
82 snd_akm4xxx_set(ak
, 0, reg
, tmp
); /* the value is written in reset(0) */
83 snd_akm4xxx_reset(ak
, 0);
87 * initialize the chips on M-Audio Revolution cards
90 #define AK_DAC(xname,xch) { .name = xname, .num_channels = xch }
92 static struct snd_akm4xxx_dac_channel revo71_front
[] = {
93 AK_DAC("PCM Playback Volume", 2)
96 static struct snd_akm4xxx_dac_channel revo71_surround
[] = {
97 AK_DAC("PCM Center Playback Volume", 1),
98 AK_DAC("PCM LFE Playback Volume", 1),
99 AK_DAC("PCM Side Playback Volume", 2),
100 AK_DAC("PCM Rear Playback Volume", 2),
103 static struct snd_akm4xxx_dac_channel revo51_dac
[] = {
104 AK_DAC("PCM Playback Volume", 2),
105 AK_DAC("PCM Center Playback Volume", 1),
106 AK_DAC("PCM LFE Playback Volume", 1),
107 AK_DAC("PCM Rear Playback Volume", 2),
110 static const char *revo51_adc_input_names
[] = {
117 static struct snd_akm4xxx_adc_channel revo51_adc
[] = {
119 .name
= "PCM Capture Volume",
120 .switch_name
= "PCM Capture Switch",
122 .input_names
= revo51_adc_input_names
126 static struct snd_akm4xxx akm_revo_front __devinitdata
= {
130 .set_rate_val
= revo_set_rate_val
132 .dac_info
= revo71_front
,
135 static struct snd_ak4xxx_private akm_revo_front_priv __devinitdata
= {
138 .data_mask
= VT1724_REVO_CDOUT
,
139 .clk_mask
= VT1724_REVO_CCLK
,
140 .cs_mask
= VT1724_REVO_CS0
| VT1724_REVO_CS1
| VT1724_REVO_CS2
,
141 .cs_addr
= VT1724_REVO_CS0
| VT1724_REVO_CS2
,
142 .cs_none
= VT1724_REVO_CS0
| VT1724_REVO_CS1
| VT1724_REVO_CS2
,
143 .add_flags
= VT1724_REVO_CCLK
, /* high at init */
147 static struct snd_akm4xxx akm_revo_surround __devinitdata
= {
152 .set_rate_val
= revo_set_rate_val
154 .dac_info
= revo71_surround
,
157 static struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata
= {
160 .data_mask
= VT1724_REVO_CDOUT
,
161 .clk_mask
= VT1724_REVO_CCLK
,
162 .cs_mask
= VT1724_REVO_CS0
| VT1724_REVO_CS1
| VT1724_REVO_CS2
,
163 .cs_addr
= VT1724_REVO_CS0
| VT1724_REVO_CS1
,
164 .cs_none
= VT1724_REVO_CS0
| VT1724_REVO_CS1
| VT1724_REVO_CS2
,
165 .add_flags
= VT1724_REVO_CCLK
, /* high at init */
169 static struct snd_akm4xxx akm_revo51 __devinitdata
= {
173 .set_rate_val
= revo_set_rate_val
175 .dac_info
= revo51_dac
,
178 static struct snd_ak4xxx_private akm_revo51_priv __devinitdata
= {
181 .data_mask
= VT1724_REVO_CDOUT
,
182 .clk_mask
= VT1724_REVO_CCLK
,
183 .cs_mask
= VT1724_REVO_CS0
| VT1724_REVO_CS1
| VT1724_REVO_CS2
,
184 .cs_addr
= VT1724_REVO_CS1
| VT1724_REVO_CS2
,
185 .cs_none
= VT1724_REVO_CS0
| VT1724_REVO_CS1
| VT1724_REVO_CS2
,
186 .add_flags
= VT1724_REVO_CCLK
, /* high at init */
190 static struct snd_akm4xxx akm_revo51_adc __devinitdata
= {
193 .adc_info
= revo51_adc
,
196 static struct snd_ak4xxx_private akm_revo51_adc_priv __devinitdata
= {
199 .data_mask
= VT1724_REVO_CDOUT
,
200 .clk_mask
= VT1724_REVO_CCLK
,
201 .cs_mask
= VT1724_REVO_CS0
| VT1724_REVO_CS1
| VT1724_REVO_CS2
,
202 .cs_addr
= VT1724_REVO_CS0
| VT1724_REVO_CS2
,
203 .cs_none
= VT1724_REVO_CS0
| VT1724_REVO_CS1
| VT1724_REVO_CS2
,
204 .add_flags
= VT1724_REVO_CCLK
, /* high at init */
208 static int __devinit
revo_init(struct snd_ice1712
*ice
)
210 struct snd_akm4xxx
*ak
;
213 /* determine I2C, DACs and ADCs */
214 switch (ice
->eeprom
.subvendor
) {
215 case VT1724_SUBDEVICE_REVOLUTION71
:
216 ice
->num_total_dacs
= 8;
217 ice
->num_total_adcs
= 2;
218 ice
->gpio
.i2s_mclk_changed
= revo_i2s_mclk_changed
;
220 case VT1724_SUBDEVICE_REVOLUTION51
:
221 ice
->num_total_dacs
= 6;
222 ice
->num_total_adcs
= 2;
229 /* second stage of initialization, analog parts and others */
230 ak
= ice
->akm
= kcalloc(2, sizeof(struct snd_akm4xxx
), GFP_KERNEL
);
234 switch (ice
->eeprom
.subvendor
) {
235 case VT1724_SUBDEVICE_REVOLUTION71
:
237 if ((err
= snd_ice1712_akm4xxx_init(ak
, &akm_revo_front
, &akm_revo_front_priv
, ice
)) < 0)
239 if ((err
= snd_ice1712_akm4xxx_init(ak
+ 1, &akm_revo_surround
, &akm_revo_surround_priv
, ice
)) < 0)
241 /* unmute all codecs */
242 snd_ice1712_gpio_write_bits(ice
, VT1724_REVO_MUTE
, VT1724_REVO_MUTE
);
244 case VT1724_SUBDEVICE_REVOLUTION51
:
246 if ((err
= snd_ice1712_akm4xxx_init(ak
, &akm_revo51
, &akm_revo51_priv
, ice
)) < 0)
248 err
= snd_ice1712_akm4xxx_init(ak
+ 1, &akm_revo51_adc
,
249 &akm_revo51_adc_priv
, ice
);
252 /* unmute all codecs - needed! */
253 snd_ice1712_gpio_write_bits(ice
, VT1724_REVO_MUTE
, VT1724_REVO_MUTE
);
261 static int __devinit
revo_add_controls(struct snd_ice1712
*ice
)
265 switch (ice
->eeprom
.subvendor
) {
266 case VT1724_SUBDEVICE_REVOLUTION71
:
267 case VT1724_SUBDEVICE_REVOLUTION51
:
268 err
= snd_ice1712_akm4xxx_build_controls(ice
);
276 struct snd_ice1712_card_info snd_vt1724_revo_cards
[] __devinitdata
= {
278 .subvendor
= VT1724_SUBDEVICE_REVOLUTION71
,
279 .name
= "M Audio Revolution-7.1",
281 .chip_init
= revo_init
,
282 .build_controls
= revo_add_controls
,
285 .subvendor
= VT1724_SUBDEVICE_REVOLUTION51
,
286 .name
= "M Audio Revolution-5.1",
288 .chip_init
= revo_init
,
289 .build_controls
= revo_add_controls
,