blob: 1d3b1ebf9c9b6e2b76e771182eb2d2b51804c48e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * ALSA driver for ICEnsemble ICE1712 (Envy24)
3 *
4 * Lowlevel functions for M-Audio Revolution 7.1
5 *
6 * Copyright (c) 2003 Takashi Iwai <tiwai@suse.de>
7 *
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.
12 *
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.
17 *
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
21 *
22 */
23
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <asm/io.h>
25#include <linux/delay.h>
26#include <linux/interrupt.h>
27#include <linux/init.h>
28#include <linux/slab.h>
29#include <sound/core.h>
30
31#include "ice1712.h"
32#include "envy24ht.h"
33#include "revo.h"
34
Takashi Iwai7cda8ba2008-01-18 13:36:07 +010035/* a non-standard I2C device for revo51 */
36struct revo51_spec {
37 struct snd_i2c_device *dev;
38 struct snd_pt2258 *pt2258;
Harvey Harrison008f3592008-02-29 11:46:32 +010039};
Takashi Iwai7cda8ba2008-01-18 13:36:07 +010040
Takashi Iwaiab0c7d72005-11-17 15:00:18 +010041static void revo_i2s_mclk_changed(struct snd_ice1712 *ice)
Linus Torvalds1da177e2005-04-16 15:20:36 -070042{
43 /* assert PRST# to converters; MT05 bit 7 */
44 outb(inb(ICEMT1724(ice, AC97_CMD)) | 0x80, ICEMT1724(ice, AC97_CMD));
45 mdelay(5);
46 /* deassert PRST# */
47 outb(inb(ICEMT1724(ice, AC97_CMD)) & ~0x80, ICEMT1724(ice, AC97_CMD));
48}
49
50/*
51 * change the rate of envy24HT, AK4355 and AK4381
52 */
Takashi Iwaiab0c7d72005-11-17 15:00:18 +010053static void revo_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate)
Linus Torvalds1da177e2005-04-16 15:20:36 -070054{
55 unsigned char old, tmp, dfs;
56 int reg, shift;
57
58 if (rate == 0) /* no hint - S/PDIF input is master, simply return */
59 return;
60
61 /* adjust DFS on codecs */
62 if (rate > 96000)
63 dfs = 2;
64 else if (rate > 48000)
65 dfs = 1;
66 else
67 dfs = 0;
68
Takashi Iwai59acf762005-12-05 19:22:34 +010069 if (ak->type == SND_AK4355 || ak->type == SND_AK4358) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 reg = 2;
71 shift = 4;
72 } else {
73 reg = 1;
74 shift = 3;
75 }
76 tmp = snd_akm4xxx_get(ak, 0, reg);
77 old = (tmp >> shift) & 0x03;
78 if (old == dfs)
79 return;
80
81 /* reset DFS */
82 snd_akm4xxx_reset(ak, 1);
83 tmp = snd_akm4xxx_get(ak, 0, reg);
84 tmp &= ~(0x03 << shift);
85 tmp |= dfs << shift;
86 // snd_akm4xxx_write(ak, 0, reg, tmp);
87 snd_akm4xxx_set(ak, 0, reg, tmp); /* the value is written in reset(0) */
88 snd_akm4xxx_reset(ak, 0);
89}
90
91/*
Jochen Vossfeaa6a72006-10-04 18:08:43 +020092 * I2C access to the PT2258 volume controller on GPIO 6/7 (Revolution 5.1)
93 */
94
95static void revo_i2c_start(struct snd_i2c_bus *bus)
96{
97 struct snd_ice1712 *ice = bus->private_data;
98 snd_ice1712_save_gpio_status(ice);
99}
100
101static void revo_i2c_stop(struct snd_i2c_bus *bus)
102{
103 struct snd_ice1712 *ice = bus->private_data;
104 snd_ice1712_restore_gpio_status(ice);
105}
106
107static void revo_i2c_direction(struct snd_i2c_bus *bus, int clock, int data)
108{
109 struct snd_ice1712 *ice = bus->private_data;
110 unsigned int mask, val;
111
112 val = 0;
113 if (clock)
114 val |= VT1724_REVO_I2C_CLOCK; /* write SCL */
115 if (data)
116 val |= VT1724_REVO_I2C_DATA; /* write SDA */
117 mask = VT1724_REVO_I2C_CLOCK | VT1724_REVO_I2C_DATA;
118 ice->gpio.direction &= ~mask;
119 ice->gpio.direction |= val;
120 snd_ice1712_gpio_set_dir(ice, ice->gpio.direction);
121 snd_ice1712_gpio_set_mask(ice, ~mask);
122}
123
124static void revo_i2c_setlines(struct snd_i2c_bus *bus, int clk, int data)
125{
126 struct snd_ice1712 *ice = bus->private_data;
127 unsigned int val = 0;
128
129 if (clk)
130 val |= VT1724_REVO_I2C_CLOCK;
131 if (data)
132 val |= VT1724_REVO_I2C_DATA;
133 snd_ice1712_gpio_write_bits(ice,
134 VT1724_REVO_I2C_DATA |
135 VT1724_REVO_I2C_CLOCK, val);
136 udelay(5);
137}
138
139static int revo_i2c_getdata(struct snd_i2c_bus *bus, int ack)
140{
141 struct snd_ice1712 *ice = bus->private_data;
142 int bit;
143
144 if (ack)
145 udelay(5);
146 bit = snd_ice1712_gpio_read_bits(ice, VT1724_REVO_I2C_DATA) ? 1 : 0;
147 return bit;
148}
149
150static struct snd_i2c_bit_ops revo51_bit_ops = {
151 .start = revo_i2c_start,
152 .stop = revo_i2c_stop,
153 .direction = revo_i2c_direction,
154 .setlines = revo_i2c_setlines,
155 .getdata = revo_i2c_getdata,
156};
157
158static int revo51_i2c_init(struct snd_ice1712 *ice,
159 struct snd_pt2258 *pt)
160{
Takashi Iwai7cda8ba2008-01-18 13:36:07 +0100161 struct revo51_spec *spec;
Jochen Vossfeaa6a72006-10-04 18:08:43 +0200162 int err;
163
Takashi Iwai7cda8ba2008-01-18 13:36:07 +0100164 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
165 if (!spec)
166 return -ENOMEM;
167 ice->spec = spec;
168
Jochen Vossfeaa6a72006-10-04 18:08:43 +0200169 /* create the I2C bus */
170 err = snd_i2c_bus_create(ice->card, "ICE1724 GPIO6", NULL, &ice->i2c);
171 if (err < 0)
172 return err;
173
174 ice->i2c->private_data = ice;
175 ice->i2c->hw_ops.bit = &revo51_bit_ops;
176
177 /* create the I2C device */
Takashi Iwai7cda8ba2008-01-18 13:36:07 +0100178 err = snd_i2c_device_create(ice->i2c, "PT2258", 0x40, &spec->dev);
Jochen Vossfeaa6a72006-10-04 18:08:43 +0200179 if (err < 0)
180 return err;
181
182 pt->card = ice->card;
183 pt->i2c_bus = ice->i2c;
Takashi Iwai7cda8ba2008-01-18 13:36:07 +0100184 pt->i2c_dev = spec->dev;
185 spec->pt2258 = pt;
Jochen Vossfeaa6a72006-10-04 18:08:43 +0200186
187 snd_pt2258_reset(pt);
188
189 return 0;
190}
191
192/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193 * initialize the chips on M-Audio Revolution cards
194 */
195
Takashi Iwai723b2b02006-08-30 16:49:54 +0200196#define AK_DAC(xname,xch) { .name = xname, .num_channels = xch }
Jani Alinikulac83c0c42006-06-27 15:00:55 +0200197
Takashi Iwai517400c2007-01-29 15:27:56 +0100198static const struct snd_akm4xxx_dac_channel revo71_front[] = {
Pavel Hofmanea7cfcd2007-05-19 17:21:04 +0200199 {
200 .name = "PCM Playback Volume",
201 .num_channels = 2,
202 /* front channels DAC supports muting */
203 .switch_name = "PCM Playback Switch",
204 },
Takashi Iwai723b2b02006-08-30 16:49:54 +0200205};
Jani Alinikulac83c0c42006-06-27 15:00:55 +0200206
Takashi Iwai517400c2007-01-29 15:27:56 +0100207static const struct snd_akm4xxx_dac_channel revo71_surround[] = {
Takashi Iwai723b2b02006-08-30 16:49:54 +0200208 AK_DAC("PCM Center Playback Volume", 1),
209 AK_DAC("PCM LFE Playback Volume", 1),
210 AK_DAC("PCM Side Playback Volume", 2),
211 AK_DAC("PCM Rear Playback Volume", 2),
212};
Jani Alinikulac83c0c42006-06-27 15:00:55 +0200213
Takashi Iwai517400c2007-01-29 15:27:56 +0100214static const struct snd_akm4xxx_dac_channel revo51_dac[] = {
Takashi Iwai723b2b02006-08-30 16:49:54 +0200215 AK_DAC("PCM Playback Volume", 2),
216 AK_DAC("PCM Center Playback Volume", 1),
217 AK_DAC("PCM LFE Playback Volume", 1),
218 AK_DAC("PCM Rear Playback Volume", 2),
219};
220
Jochen Vossa58e7cb2006-10-04 18:04:10 +0200221static const char *revo51_adc_input_names[] = {
222 "Mic",
223 "Line",
224 "CD",
225 NULL
226};
227
Takashi Iwai517400c2007-01-29 15:27:56 +0100228static const struct snd_akm4xxx_adc_channel revo51_adc[] = {
Takashi Iwai723b2b02006-08-30 16:49:54 +0200229 {
230 .name = "PCM Capture Volume",
Takashi Iwai723b2b02006-08-30 16:49:54 +0200231 .switch_name = "PCM Capture Switch",
Jochen Vossa58e7cb2006-10-04 18:04:10 +0200232 .num_channels = 2,
233 .input_names = revo51_adc_input_names
Takashi Iwai723b2b02006-08-30 16:49:54 +0200234 },
235};
Jochen Voss96d9e932006-08-08 21:13:42 +0200236
Takashi Iwai1b60f6b2007-03-13 22:13:47 +0100237static struct snd_akm4xxx akm_revo_front __devinitdata = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238 .type = SND_AK4381,
239 .num_dacs = 2,
240 .ops = {
241 .set_rate_val = revo_set_rate_val
Jani Alinikulac83c0c42006-06-27 15:00:55 +0200242 },
Takashi Iwai723b2b02006-08-30 16:49:54 +0200243 .dac_info = revo71_front,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244};
245
Takashi Iwai1b60f6b2007-03-13 22:13:47 +0100246static struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 .caddr = 1,
248 .cif = 0,
249 .data_mask = VT1724_REVO_CDOUT,
250 .clk_mask = VT1724_REVO_CCLK,
251 .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS1 | VT1724_REVO_CS2,
252 .cs_addr = VT1724_REVO_CS0 | VT1724_REVO_CS2,
253 .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS1 | VT1724_REVO_CS2,
254 .add_flags = VT1724_REVO_CCLK, /* high at init */
255 .mask_flags = 0,
256};
257
Takashi Iwai1b60f6b2007-03-13 22:13:47 +0100258static struct snd_akm4xxx akm_revo_surround __devinitdata = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 .type = SND_AK4355,
260 .idx_offset = 1,
261 .num_dacs = 6,
262 .ops = {
263 .set_rate_val = revo_set_rate_val
Jani Alinikulac83c0c42006-06-27 15:00:55 +0200264 },
Takashi Iwai723b2b02006-08-30 16:49:54 +0200265 .dac_info = revo71_surround,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266};
267
Takashi Iwai1b60f6b2007-03-13 22:13:47 +0100268static struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269 .caddr = 3,
270 .cif = 0,
271 .data_mask = VT1724_REVO_CDOUT,
272 .clk_mask = VT1724_REVO_CCLK,
273 .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS1 | VT1724_REVO_CS2,
274 .cs_addr = VT1724_REVO_CS0 | VT1724_REVO_CS1,
275 .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS1 | VT1724_REVO_CS2,
276 .add_flags = VT1724_REVO_CCLK, /* high at init */
277 .mask_flags = 0,
278};
279
Takashi Iwai1b60f6b2007-03-13 22:13:47 +0100280static struct snd_akm4xxx akm_revo51 __devinitdata = {
Takashi Iwai59acf762005-12-05 19:22:34 +0100281 .type = SND_AK4358,
282 .num_dacs = 6,
283 .ops = {
284 .set_rate_val = revo_set_rate_val
Jani Alinikulac83c0c42006-06-27 15:00:55 +0200285 },
Takashi Iwai723b2b02006-08-30 16:49:54 +0200286 .dac_info = revo51_dac,
Takashi Iwai59acf762005-12-05 19:22:34 +0100287};
288
Takashi Iwai1b60f6b2007-03-13 22:13:47 +0100289static struct snd_ak4xxx_private akm_revo51_priv __devinitdata = {
Takashi Iwai59acf762005-12-05 19:22:34 +0100290 .caddr = 2,
291 .cif = 0,
292 .data_mask = VT1724_REVO_CDOUT,
293 .clk_mask = VT1724_REVO_CCLK,
Jochen Vossfeaa6a72006-10-04 18:08:43 +0200294 .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS1,
295 .cs_addr = VT1724_REVO_CS1,
296 .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS1,
Jochen Voss96d9e932006-08-08 21:13:42 +0200297 .add_flags = VT1724_REVO_CCLK, /* high at init */
298 .mask_flags = 0,
299};
300
Takashi Iwai1b60f6b2007-03-13 22:13:47 +0100301static struct snd_akm4xxx akm_revo51_adc __devinitdata = {
Jochen Voss96d9e932006-08-08 21:13:42 +0200302 .type = SND_AK5365,
303 .num_adcs = 2,
Takashi Iwai723b2b02006-08-30 16:49:54 +0200304 .adc_info = revo51_adc,
Jochen Voss96d9e932006-08-08 21:13:42 +0200305};
306
Takashi Iwai1b60f6b2007-03-13 22:13:47 +0100307static struct snd_ak4xxx_private akm_revo51_adc_priv __devinitdata = {
Jochen Voss96d9e932006-08-08 21:13:42 +0200308 .caddr = 2,
309 .cif = 0,
310 .data_mask = VT1724_REVO_CDOUT,
311 .clk_mask = VT1724_REVO_CCLK,
Jochen Vossfeaa6a72006-10-04 18:08:43 +0200312 .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS1,
313 .cs_addr = VT1724_REVO_CS0,
314 .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS1,
Takashi Iwai59acf762005-12-05 19:22:34 +0100315 .add_flags = VT1724_REVO_CCLK, /* high at init */
316 .mask_flags = 0,
317};
318
Jochen Vossfeaa6a72006-10-04 18:08:43 +0200319static struct snd_pt2258 ptc_revo51_volume;
320
Takashi Iwai56255062006-11-09 16:47:26 +0100321/* AK4358 for AP192 DAC, AK5385A for ADC */
322static void ap192_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate)
323{
324 struct snd_ice1712 *ice = ak->private_data[0];
325
326 revo_set_rate_val(ak, rate);
327
328#if 1 /* FIXME: do we need this procedure? */
329 /* reset DFS pin of AK5385A for ADC, too */
330 /* DFS0 (pin 18) -- GPIO10 pin 77 */
331 snd_ice1712_save_gpio_status(ice);
332 snd_ice1712_gpio_write_bits(ice, 1 << 10,
333 rate > 48000 ? (1 << 10) : 0);
334 snd_ice1712_restore_gpio_status(ice);
335#endif
336}
337
Takashi Iwai517400c2007-01-29 15:27:56 +0100338static const struct snd_akm4xxx_dac_channel ap192_dac[] = {
Takashi Iwai56255062006-11-09 16:47:26 +0100339 AK_DAC("PCM Playback Volume", 2)
340};
341
Takashi Iwai1b60f6b2007-03-13 22:13:47 +0100342static struct snd_akm4xxx akm_ap192 __devinitdata = {
Takashi Iwai56255062006-11-09 16:47:26 +0100343 .type = SND_AK4358,
344 .num_dacs = 2,
345 .ops = {
346 .set_rate_val = ap192_set_rate_val
347 },
348 .dac_info = ap192_dac,
349};
350
Takashi Iwai1b60f6b2007-03-13 22:13:47 +0100351static struct snd_ak4xxx_private akm_ap192_priv __devinitdata = {
Takashi Iwai56255062006-11-09 16:47:26 +0100352 .caddr = 2,
353 .cif = 0,
354 .data_mask = VT1724_REVO_CDOUT,
355 .clk_mask = VT1724_REVO_CCLK,
Takashi Iwaif339eb02008-02-04 12:34:59 +0100356 .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS1,
357 .cs_addr = VT1724_REVO_CS1,
358 .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS1,
Takashi Iwai56255062006-11-09 16:47:26 +0100359 .add_flags = VT1724_REVO_CCLK, /* high at init */
360 .mask_flags = 0,
361};
362
Takashi Iwai56255062006-11-09 16:47:26 +0100363/* AK4114 support on Audiophile 192 */
364/* CDTO (pin 32) -- GPIO2 pin 52
365 * CDTI (pin 33) -- GPIO3 pin 53 (shared with AK4358)
366 * CCLK (pin 34) -- GPIO1 pin 51 (shared with AK4358)
367 * CSN (pin 35) -- GPIO7 pin 59
368 */
Takashi Iwaif339eb02008-02-04 12:34:59 +0100369#define AK4114_ADDR 0x02
Takashi Iwai56255062006-11-09 16:47:26 +0100370
371static void write_data(struct snd_ice1712 *ice, unsigned int gpio,
372 unsigned int data, int idx)
373{
374 for (; idx >= 0; idx--) {
375 /* drop clock */
376 gpio &= ~VT1724_REVO_CCLK;
377 snd_ice1712_gpio_write(ice, gpio);
378 udelay(1);
379 /* set data */
380 if (data & (1 << idx))
381 gpio |= VT1724_REVO_CDOUT;
382 else
383 gpio &= ~VT1724_REVO_CDOUT;
384 snd_ice1712_gpio_write(ice, gpio);
385 udelay(1);
386 /* raise clock */
387 gpio |= VT1724_REVO_CCLK;
388 snd_ice1712_gpio_write(ice, gpio);
389 udelay(1);
390 }
391}
392
393static unsigned char read_data(struct snd_ice1712 *ice, unsigned int gpio,
394 int idx)
395{
396 unsigned char data = 0;
397
398 for (; idx >= 0; idx--) {
399 /* drop clock */
400 gpio &= ~VT1724_REVO_CCLK;
401 snd_ice1712_gpio_write(ice, gpio);
402 udelay(1);
403 /* read data */
404 if (snd_ice1712_gpio_read(ice) & VT1724_REVO_CDIN)
405 data |= (1 << idx);
406 udelay(1);
407 /* raise clock */
408 gpio |= VT1724_REVO_CCLK;
409 snd_ice1712_gpio_write(ice, gpio);
410 udelay(1);
411 }
412 return data;
413}
414
Takashi Iwaic052f042007-03-29 12:34:15 +0200415static unsigned int ap192_4wire_start(struct snd_ice1712 *ice)
Takashi Iwai56255062006-11-09 16:47:26 +0100416{
417 unsigned int tmp;
418
419 snd_ice1712_save_gpio_status(ice);
420 tmp = snd_ice1712_gpio_read(ice);
421 tmp |= VT1724_REVO_CCLK; /* high at init */
422 tmp |= VT1724_REVO_CS0;
Takashi Iwaif339eb02008-02-04 12:34:59 +0100423 tmp &= ~VT1724_REVO_CS1;
Takashi Iwai56255062006-11-09 16:47:26 +0100424 snd_ice1712_gpio_write(ice, tmp);
425 udelay(1);
426 return tmp;
427}
428
429static void ap192_4wire_finish(struct snd_ice1712 *ice, unsigned int tmp)
430{
Takashi Iwaif339eb02008-02-04 12:34:59 +0100431 tmp |= VT1724_REVO_CS1;
Takashi Iwai56255062006-11-09 16:47:26 +0100432 tmp |= VT1724_REVO_CS0;
433 snd_ice1712_gpio_write(ice, tmp);
434 udelay(1);
435 snd_ice1712_restore_gpio_status(ice);
436}
437
438static void ap192_ak4114_write(void *private_data, unsigned char addr,
439 unsigned char data)
440{
441 struct snd_ice1712 *ice = private_data;
442 unsigned int tmp, addrdata;
443
444 tmp = ap192_4wire_start(ice);
445 addrdata = (AK4114_ADDR << 6) | 0x20 | (addr & 0x1f);
446 addrdata = (addrdata << 8) | data;
447 write_data(ice, tmp, addrdata, 15);
448 ap192_4wire_finish(ice, tmp);
449}
450
451static unsigned char ap192_ak4114_read(void *private_data, unsigned char addr)
452{
453 struct snd_ice1712 *ice = private_data;
454 unsigned int tmp;
455 unsigned char data;
456
457 tmp = ap192_4wire_start(ice);
458 write_data(ice, tmp, (AK4114_ADDR << 6) | (addr & 0x1f), 7);
459 data = read_data(ice, tmp, 7);
460 ap192_4wire_finish(ice, tmp);
461 return data;
462}
463
Takashi Iwai1b60f6b2007-03-13 22:13:47 +0100464static int __devinit ap192_ak4114_init(struct snd_ice1712 *ice)
Takashi Iwai56255062006-11-09 16:47:26 +0100465{
Takashi Iwai32b47da2007-01-29 15:26:36 +0100466 static const unsigned char ak4114_init_vals[] = {
Takashi Iwai56255062006-11-09 16:47:26 +0100467 AK4114_RST | AK4114_PWN | AK4114_OCKS0 | AK4114_OCKS1,
468 AK4114_DIF_I24I2S,
469 AK4114_TX1E,
470 AK4114_EFH_1024 | AK4114_DIT | AK4114_IPS(1),
471 0,
472 0
473 };
Takashi Iwai32b47da2007-01-29 15:26:36 +0100474 static const unsigned char ak4114_init_txcsb[] = {
Takashi Iwai56255062006-11-09 16:47:26 +0100475 0x41, 0x02, 0x2c, 0x00, 0x00
476 };
477 struct ak4114 *ak;
478 int err;
479
Takashi Iwaif339eb02008-02-04 12:34:59 +0100480 err = snd_ak4114_create(ice->card,
Takashi Iwai56255062006-11-09 16:47:26 +0100481 ap192_ak4114_read,
482 ap192_ak4114_write,
483 ak4114_init_vals, ak4114_init_txcsb,
484 ice, &ak);
Takashi Iwaif339eb02008-02-04 12:34:59 +0100485 return 0; /* error ignored; it's no fatal error */
Takashi Iwai56255062006-11-09 16:47:26 +0100486}
Takashi Iwai56255062006-11-09 16:47:26 +0100487
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100488static int __devinit revo_init(struct snd_ice1712 *ice)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489{
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100490 struct snd_akm4xxx *ak;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 int err;
492
493 /* determine I2C, DACs and ADCs */
494 switch (ice->eeprom.subvendor) {
495 case VT1724_SUBDEVICE_REVOLUTION71:
496 ice->num_total_dacs = 8;
497 ice->num_total_adcs = 2;
Takashi Iwai59acf762005-12-05 19:22:34 +0100498 ice->gpio.i2s_mclk_changed = revo_i2s_mclk_changed;
499 break;
500 case VT1724_SUBDEVICE_REVOLUTION51:
501 ice->num_total_dacs = 6;
502 ice->num_total_adcs = 2;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 break;
Takashi Iwai56255062006-11-09 16:47:26 +0100504 case VT1724_SUBDEVICE_AUDIOPHILE192:
505 ice->num_total_dacs = 2;
506 ice->num_total_adcs = 2;
507 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508 default:
509 snd_BUG();
510 return -EINVAL;
511 }
512
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513 /* second stage of initialization, analog parts and others */
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100514 ak = ice->akm = kcalloc(2, sizeof(struct snd_akm4xxx), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515 if (! ak)
516 return -ENOMEM;
517 ice->akm_codecs = 2;
518 switch (ice->eeprom.subvendor) {
519 case VT1724_SUBDEVICE_REVOLUTION71:
Takashi Iwai59acf762005-12-05 19:22:34 +0100520 ice->akm_codecs = 2;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521 if ((err = snd_ice1712_akm4xxx_init(ak, &akm_revo_front, &akm_revo_front_priv, ice)) < 0)
522 return err;
523 if ((err = snd_ice1712_akm4xxx_init(ak + 1, &akm_revo_surround, &akm_revo_surround_priv, ice)) < 0)
524 return err;
525 /* unmute all codecs */
526 snd_ice1712_gpio_write_bits(ice, VT1724_REVO_MUTE, VT1724_REVO_MUTE);
527 break;
Takashi Iwai59acf762005-12-05 19:22:34 +0100528 case VT1724_SUBDEVICE_REVOLUTION51:
Jochen Voss96d9e932006-08-08 21:13:42 +0200529 ice->akm_codecs = 2;
Jochen Vossfeaa6a72006-10-04 18:08:43 +0200530 err = snd_ice1712_akm4xxx_init(ak, &akm_revo51,
531 &akm_revo51_priv, ice);
532 if (err < 0)
Takashi Iwai59acf762005-12-05 19:22:34 +0100533 return err;
Jochen Vossfeaa6a72006-10-04 18:08:43 +0200534 err = snd_ice1712_akm4xxx_init(ak+1, &akm_revo51_adc,
Jochen Voss96d9e932006-08-08 21:13:42 +0200535 &akm_revo51_adc_priv, ice);
536 if (err < 0)
537 return err;
Jochen Vossfeaa6a72006-10-04 18:08:43 +0200538 err = revo51_i2c_init(ice, &ptc_revo51_volume);
539 if (err < 0)
540 return err;
541 /* unmute all codecs */
542 snd_ice1712_gpio_write_bits(ice, VT1724_REVO_MUTE,
543 VT1724_REVO_MUTE);
Takashi Iwai59acf762005-12-05 19:22:34 +0100544 break;
Takashi Iwai56255062006-11-09 16:47:26 +0100545 case VT1724_SUBDEVICE_AUDIOPHILE192:
546 ice->akm_codecs = 1;
547 err = snd_ice1712_akm4xxx_init(ak, &akm_ap192, &akm_ap192_priv,
548 ice);
549 if (err < 0)
550 return err;
551
552 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553 }
554
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 return 0;
556}
557
558
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100559static int __devinit revo_add_controls(struct snd_ice1712 *ice)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560{
Takashi Iwai7cda8ba2008-01-18 13:36:07 +0100561 struct revo51_spec *spec;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 int err;
563
564 switch (ice->eeprom.subvendor) {
565 case VT1724_SUBDEVICE_REVOLUTION71:
Jochen Vossfeaa6a72006-10-04 18:08:43 +0200566 err = snd_ice1712_akm4xxx_build_controls(ice);
567 if (err < 0)
568 return err;
569 break;
Takashi Iwai59acf762005-12-05 19:22:34 +0100570 case VT1724_SUBDEVICE_REVOLUTION51:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 err = snd_ice1712_akm4xxx_build_controls(ice);
572 if (err < 0)
573 return err;
Takashi Iwai7cda8ba2008-01-18 13:36:07 +0100574 spec = ice->spec;
575 err = snd_pt2258_build_controls(spec->pt2258);
Jochen Vossfeaa6a72006-10-04 18:08:43 +0200576 if (err < 0)
577 return err;
578 break;
Takashi Iwai56255062006-11-09 16:47:26 +0100579 case VT1724_SUBDEVICE_AUDIOPHILE192:
580 err = snd_ice1712_akm4xxx_build_controls(ice);
581 if (err < 0)
582 return err;
Takashi Iwai56255062006-11-09 16:47:26 +0100583 err = ap192_ak4114_init(ice);
584 if (err < 0)
585 return err;
Takashi Iwai56255062006-11-09 16:47:26 +0100586 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 }
588 return 0;
589}
590
591/* entry point */
Takashi Iwai1b60f6b2007-03-13 22:13:47 +0100592struct snd_ice1712_card_info snd_vt1724_revo_cards[] __devinitdata = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 {
594 .subvendor = VT1724_SUBDEVICE_REVOLUTION71,
595 .name = "M Audio Revolution-7.1",
596 .model = "revo71",
597 .chip_init = revo_init,
598 .build_controls = revo_add_controls,
599 },
Takashi Iwai59acf762005-12-05 19:22:34 +0100600 {
601 .subvendor = VT1724_SUBDEVICE_REVOLUTION51,
602 .name = "M Audio Revolution-5.1",
603 .model = "revo51",
604 .chip_init = revo_init,
605 .build_controls = revo_add_controls,
606 },
Takashi Iwai56255062006-11-09 16:47:26 +0100607 {
608 .subvendor = VT1724_SUBDEVICE_AUDIOPHILE192,
609 .name = "M Audio Audiophile192",
610 .model = "ap192",
611 .chip_init = revo_init,
612 .build_controls = revo_add_controls,
613 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 { } /* terminator */
615};