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>
37 * change the rate of envy24HT, AK4355 and AK4381
39 static void revo_set_rate_val(akm4xxx_t *ak, unsigned int rate)
41 unsigned char old, tmp, dfs;
44 if (rate == 0) /* no hint - S/PDIF input is master, simply return */
47 /* adjust DFS on codecs */
50 else if (rate > 48000)
55 if (ak->type == SND_AK4355) {
62 tmp = snd_akm4xxx_get(ak, 0, reg);
63 old = (tmp >> shift) & 0x03;
68 snd_akm4xxx_reset(ak, 1);
69 tmp = snd_akm4xxx_get(ak, 0, reg);
70 tmp &= ~(0x03 << shift);
72 // snd_akm4xxx_write(ak, 0, reg, tmp);
73 snd_akm4xxx_set(ak, 0, reg, tmp); /* the value is written in reset(0) */
74 snd_akm4xxx_reset(ak, 0);
78 * initialize the chips on M-Audio Revolution cards
81 static akm4xxx_t akm_revo_front __devinitdata = {
85 .set_rate_val = revo_set_rate_val
89 static struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = {
92 .data_mask = VT1724_REVO_CDOUT,
93 .clk_mask = VT1724_REVO_CCLK,
94 .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS1 | VT1724_REVO_CS2,
95 .cs_addr = VT1724_REVO_CS0 | VT1724_REVO_CS2,
96 .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS1 | VT1724_REVO_CS2,
97 .add_flags = VT1724_REVO_CCLK, /* high at init */
101 static akm4xxx_t akm_revo_surround __devinitdata = {
106 .set_rate_val = revo_set_rate_val
110 static struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = {
113 .data_mask = VT1724_REVO_CDOUT,
114 .clk_mask = VT1724_REVO_CCLK,
115 .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS1 | VT1724_REVO_CS2,
116 .cs_addr = VT1724_REVO_CS0 | VT1724_REVO_CS1,
117 .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS1 | VT1724_REVO_CS2,
118 .add_flags = VT1724_REVO_CCLK, /* high at init */
122 static int __devinit revo_init(ice1712_t *ice)
127 /* determine I2C, DACs and ADCs */
128 switch (ice->eeprom.subvendor) {
129 case VT1724_SUBDEVICE_REVOLUTION71:
130 ice->num_total_dacs = 8;
131 ice->num_total_adcs = 4;
138 /* second stage of initialization, analog parts and others */
139 ak = ice->akm = snd_kcalloc(sizeof(akm4xxx_t) * 2, GFP_KERNEL);
143 switch (ice->eeprom.subvendor) {
144 case VT1724_SUBDEVICE_REVOLUTION71:
145 if ((err = snd_ice1712_akm4xxx_init(ak, &akm_revo_front, &akm_revo_front_priv, ice)) < 0)
147 if ((err = snd_ice1712_akm4xxx_init(ak + 1, &akm_revo_surround, &akm_revo_surround_priv, ice)) < 0)
149 /* unmute all codecs */
150 snd_ice1712_gpio_write_bits(ice, VT1724_REVO_MUTE, VT1724_REVO_MUTE);
158 static int __devinit revo_add_controls(ice1712_t *ice)
162 switch (ice->eeprom.subvendor) {
163 case VT1724_SUBDEVICE_REVOLUTION71:
164 err = snd_ice1712_akm4xxx_build_controls(ice);
172 struct snd_ice1712_card_info snd_vt1724_revo_cards[] __devinitdata = {
174 .subvendor = VT1724_SUBDEVICE_REVOLUTION71,
175 .name = "M Audio Revolution-7.1",
177 .chip_init = revo_init,
178 .build_controls = revo_add_controls,