2 * ALSA driver for ICEnsemble VT1724 (Envy24HT)
4 * Lowlevel functions for Terratec Aureon cards
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
25 * - we reuse the struct snd_akm4xxx record for storing the wm8770 codec data.
26 * both wm and akm codecs are pretty similar, so we can integrate
27 * both controls in the future, once if wm codecs are reused in
30 * - DAC digital volumes are not implemented in the mixer.
31 * if they show better response than DAC analog volumes, we can use them
34 * Lowlevel functions for AudioTrak Prodigy 7.1 (and possibly 192) cards
35 * Copyright (c) 2003 Dimitromanolakis Apostolos <apostol@cs.utoronto.ca>
37 * version 0.82: Stable / not all features work yet (no communication with AC97 secondary)
38 * added 64x/128x oversampling switch (should be 64x only for 96khz)
39 * fixed some recording labels (still need to check the rest)
40 * recording is working probably thanks to correct wm8770 initialization
42 * version 0.5: Initial release:
43 * working: analog output, mixer, headphone amplifier switch
44 * not working: prety much everything else, at least i could verify that
45 * we have no digital output, no capture, pretty bad clicks and poops
46 * on mixer switch and other coll stuff.
50 #include <linux/delay.h>
51 #include <linux/interrupt.h>
52 #include <linux/init.h>
53 #include <linux/slab.h>
54 #include <linux/mutex.h>
56 #include <sound/core.h>
61 #include <sound/tlv.h>
63 /* AC97 register cache for Aureon */
65 unsigned short stac9744[64];
66 unsigned int cs8415_mux;
67 unsigned short master[2];
68 unsigned short vol[8];
69 unsigned char pca9554_out;
72 /* WM8770 registers */
73 #define WM_DAC_ATTEN 0x00 /* DAC1-8 analog attenuation */
74 #define WM_DAC_MASTER_ATTEN 0x08 /* DAC master analog attenuation */
75 #define WM_DAC_DIG_ATTEN 0x09 /* DAC1-8 digital attenuation */
76 #define WM_DAC_DIG_MASTER_ATTEN 0x11 /* DAC master digital attenuation */
77 #define WM_PHASE_SWAP 0x12 /* DAC phase */
78 #define WM_DAC_CTRL1 0x13 /* DAC control bits */
79 #define WM_MUTE 0x14 /* mute controls */
80 #define WM_DAC_CTRL2 0x15 /* de-emphasis and zefo-flag */
81 #define WM_INT_CTRL 0x16 /* interface control */
82 #define WM_MASTER 0x17 /* master clock and mode */
83 #define WM_POWERDOWN 0x18 /* power-down controls */
84 #define WM_ADC_GAIN 0x19 /* ADC gain L(19)/R(1a) */
85 #define WM_ADC_MUX 0x1b /* input MUX */
86 #define WM_OUT_MUX1 0x1c /* output MUX */
87 #define WM_OUT_MUX2 0x1e /* output MUX */
88 #define WM_RESET 0x1f /* software reset */
90 /* CS8415A registers */
91 #define CS8415_CTRL1 0x01
92 #define CS8415_CTRL2 0x02
93 #define CS8415_QSUB 0x14
94 #define CS8415_RATIO 0x1E
95 #define CS8415_C_BUFFER 0x20
96 #define CS8415_ID 0x7F
98 /* PCA9554 registers */
99 #define PCA9554_DEV 0x40 /* I2C device address */
100 #define PCA9554_IN 0x00 /* input port */
101 #define PCA9554_OUT 0x01 /* output port */
102 #define PCA9554_INVERT 0x02 /* input invert */
103 #define PCA9554_DIR 0x03 /* port directions */
106 * Aureon Universe additional controls using PCA9554
110 * Send data to pca9554
112 static void aureon_pca9554_write(struct snd_ice1712 *ice, unsigned char reg,
117 unsigned char dev = PCA9554_DEV; /* ID 0100000, write */
118 unsigned char val = 0;
120 tmp = snd_ice1712_gpio_read(ice);
122 snd_ice1712_gpio_set_mask(ice, ~(AUREON_SPI_MOSI|AUREON_SPI_CLK|
123 AUREON_WM_RW|AUREON_WM_CS|
126 tmp |= AUREON_CS8415_CS | AUREON_WM_CS; /* disable SPI devices */
128 tmp &= ~AUREON_SPI_MOSI;
129 tmp &= ~AUREON_SPI_CLK;
130 snd_ice1712_gpio_write(ice, tmp);
134 * send i2c stop condition and start condition
135 * to obtain sane state
137 tmp |= AUREON_SPI_CLK;
138 snd_ice1712_gpio_write(ice, tmp);
140 tmp |= AUREON_SPI_MOSI;
141 snd_ice1712_gpio_write(ice, tmp);
143 tmp &= ~AUREON_SPI_MOSI;
144 snd_ice1712_gpio_write(ice, tmp);
146 tmp &= ~AUREON_SPI_CLK;
147 snd_ice1712_gpio_write(ice, tmp);
150 * send device address, command and value,
151 * skipping ack cycles inbetween
153 for (j = 0; j < 3; j++) {
165 for (i = 7; i >= 0; i--) {
166 tmp &= ~AUREON_SPI_CLK;
167 snd_ice1712_gpio_write(ice, tmp);
170 tmp |= AUREON_SPI_MOSI;
172 tmp &= ~AUREON_SPI_MOSI;
173 snd_ice1712_gpio_write(ice, tmp);
175 tmp |= AUREON_SPI_CLK;
176 snd_ice1712_gpio_write(ice, tmp);
179 tmp &= ~AUREON_SPI_CLK;
180 snd_ice1712_gpio_write(ice, tmp);
182 tmp |= AUREON_SPI_CLK;
183 snd_ice1712_gpio_write(ice, tmp);
185 tmp &= ~AUREON_SPI_CLK;
186 snd_ice1712_gpio_write(ice, tmp);
189 tmp &= ~AUREON_SPI_CLK;
190 snd_ice1712_gpio_write(ice, tmp);
192 tmp &= ~AUREON_SPI_MOSI;
193 snd_ice1712_gpio_write(ice, tmp);
195 tmp |= AUREON_SPI_CLK;
196 snd_ice1712_gpio_write(ice, tmp);
198 tmp |= AUREON_SPI_MOSI;
199 snd_ice1712_gpio_write(ice, tmp);
203 static int aureon_universe_inmux_info(struct snd_kcontrol *kcontrol,
204 struct snd_ctl_elem_info *uinfo)
206 char *texts[3] = {"Internal Aux", "Wavetable", "Rear Line-In"};
208 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
210 uinfo->value.enumerated.items = 3;
211 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
212 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
213 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
217 static int aureon_universe_inmux_get(struct snd_kcontrol *kcontrol,
218 struct snd_ctl_elem_value *ucontrol)
220 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
221 struct aureon_spec *spec = ice->spec;
222 ucontrol->value.enumerated.item[0] = spec->pca9554_out;
226 static int aureon_universe_inmux_put(struct snd_kcontrol *kcontrol,
227 struct snd_ctl_elem_value *ucontrol)
229 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
230 struct aureon_spec *spec = ice->spec;
231 unsigned char oval, nval;
234 nval = ucontrol->value.enumerated.item[0];
237 snd_ice1712_save_gpio_status(ice);
238 oval = spec->pca9554_out;
239 change = (oval != nval);
241 aureon_pca9554_write(ice, PCA9554_OUT, nval);
242 spec->pca9554_out = nval;
244 snd_ice1712_restore_gpio_status(ice);
249 static void aureon_ac97_write(struct snd_ice1712 *ice, unsigned short reg,
252 struct aureon_spec *spec = ice->spec;
255 /* Send address to XILINX chip */
256 tmp = (snd_ice1712_gpio_read(ice) & ~0xFF) | (reg & 0x7F);
257 snd_ice1712_gpio_write(ice, tmp);
259 tmp |= AUREON_AC97_ADDR;
260 snd_ice1712_gpio_write(ice, tmp);
262 tmp &= ~AUREON_AC97_ADDR;
263 snd_ice1712_gpio_write(ice, tmp);
266 /* Send low-order byte to XILINX chip */
267 tmp &= ~AUREON_AC97_DATA_MASK;
268 tmp |= val & AUREON_AC97_DATA_MASK;
269 snd_ice1712_gpio_write(ice, tmp);
271 tmp |= AUREON_AC97_DATA_LOW;
272 snd_ice1712_gpio_write(ice, tmp);
274 tmp &= ~AUREON_AC97_DATA_LOW;
275 snd_ice1712_gpio_write(ice, tmp);
278 /* Send high-order byte to XILINX chip */
279 tmp &= ~AUREON_AC97_DATA_MASK;
280 tmp |= (val >> 8) & AUREON_AC97_DATA_MASK;
282 snd_ice1712_gpio_write(ice, tmp);
284 tmp |= AUREON_AC97_DATA_HIGH;
285 snd_ice1712_gpio_write(ice, tmp);
287 tmp &= ~AUREON_AC97_DATA_HIGH;
288 snd_ice1712_gpio_write(ice, tmp);
291 /* Instruct XILINX chip to parse the data to the STAC9744 chip */
292 tmp |= AUREON_AC97_COMMIT;
293 snd_ice1712_gpio_write(ice, tmp);
295 tmp &= ~AUREON_AC97_COMMIT;
296 snd_ice1712_gpio_write(ice, tmp);
299 /* Store the data in out private buffer */
300 spec->stac9744[(reg & 0x7F) >> 1] = val;
303 static unsigned short aureon_ac97_read(struct snd_ice1712 *ice, unsigned short reg)
305 struct aureon_spec *spec = ice->spec;
306 return spec->stac9744[(reg & 0x7F) >> 1];
310 * Initialize STAC9744 chip
312 static int aureon_ac97_init(struct snd_ice1712 *ice)
314 struct aureon_spec *spec = ice->spec;
316 static const unsigned short ac97_defaults[] = {
340 tmp = (snd_ice1712_gpio_read(ice) | AUREON_AC97_RESET) & ~AUREON_AC97_DATA_MASK;
341 snd_ice1712_gpio_write(ice, tmp);
344 tmp &= ~AUREON_AC97_RESET;
345 snd_ice1712_gpio_write(ice, tmp);
348 tmp |= AUREON_AC97_RESET;
349 snd_ice1712_gpio_write(ice, tmp);
352 memset(&spec->stac9744, 0, sizeof(spec->stac9744));
353 for (i = 0; ac97_defaults[i] != (unsigned short)-1; i += 2)
354 spec->stac9744[(ac97_defaults[i]) >> 1] = ac97_defaults[i+1];
356 /* Unmute AC'97 master volume permanently - muting is done by WM8770 */
357 aureon_ac97_write(ice, AC97_MASTER, 0x0000);
362 #define AUREON_AC97_STEREO 0x80
365 * AC'97 volume controls
367 static int aureon_ac97_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
369 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
370 uinfo->count = kcontrol->private_value & AUREON_AC97_STEREO ? 2 : 1;
371 uinfo->value.integer.min = 0;
372 uinfo->value.integer.max = 31;
376 static int aureon_ac97_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
378 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
381 mutex_lock(&ice->gpio_mutex);
383 vol = aureon_ac97_read(ice, kcontrol->private_value & 0x7F);
384 ucontrol->value.integer.value[0] = 0x1F - (vol & 0x1F);
385 if (kcontrol->private_value & AUREON_AC97_STEREO)
386 ucontrol->value.integer.value[1] = 0x1F - ((vol >> 8) & 0x1F);
388 mutex_unlock(&ice->gpio_mutex);
392 static int aureon_ac97_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
394 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
395 unsigned short ovol, nvol;
398 snd_ice1712_save_gpio_status(ice);
400 ovol = aureon_ac97_read(ice, kcontrol->private_value & 0x7F);
401 nvol = (0x1F - ucontrol->value.integer.value[0]) & 0x001F;
402 if (kcontrol->private_value & AUREON_AC97_STEREO)
403 nvol |= ((0x1F - ucontrol->value.integer.value[1]) << 8) & 0x1F00;
404 nvol |= ovol & ~0x1F1F;
406 change = (ovol != nvol);
408 aureon_ac97_write(ice, kcontrol->private_value & 0x7F, nvol);
410 snd_ice1712_restore_gpio_status(ice);
416 * AC'97 mute controls
418 #define aureon_ac97_mute_info snd_ctl_boolean_mono_info
420 static int aureon_ac97_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
422 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
424 mutex_lock(&ice->gpio_mutex);
426 ucontrol->value.integer.value[0] = aureon_ac97_read(ice,
427 kcontrol->private_value & 0x7F) & 0x8000 ? 0 : 1;
429 mutex_unlock(&ice->gpio_mutex);
433 static int aureon_ac97_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
435 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
436 unsigned short ovol, nvol;
439 snd_ice1712_save_gpio_status(ice);
441 ovol = aureon_ac97_read(ice, kcontrol->private_value & 0x7F);
442 nvol = (ucontrol->value.integer.value[0] ? 0x0000 : 0x8000) | (ovol & ~0x8000);
444 change = (ovol != nvol);
446 aureon_ac97_write(ice, kcontrol->private_value & 0x7F, nvol);
448 snd_ice1712_restore_gpio_status(ice);
454 * AC'97 mute controls
456 #define aureon_ac97_micboost_info snd_ctl_boolean_mono_info
458 static int aureon_ac97_micboost_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
460 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
462 mutex_lock(&ice->gpio_mutex);
464 ucontrol->value.integer.value[0] = aureon_ac97_read(ice, AC97_MIC) & 0x0020 ? 0 : 1;
466 mutex_unlock(&ice->gpio_mutex);
470 static int aureon_ac97_micboost_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
472 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
473 unsigned short ovol, nvol;
476 snd_ice1712_save_gpio_status(ice);
478 ovol = aureon_ac97_read(ice, AC97_MIC);
479 nvol = (ucontrol->value.integer.value[0] ? 0x0000 : 0x0020) | (ovol & ~0x0020);
481 change = (ovol != nvol);
483 aureon_ac97_write(ice, AC97_MIC, nvol);
485 snd_ice1712_restore_gpio_status(ice);
491 * write data in the SPI mode
493 static void aureon_spi_write(struct snd_ice1712 *ice, unsigned int cs, unsigned int data, int bits)
497 unsigned int mosi, clk;
499 tmp = snd_ice1712_gpio_read(ice);
501 if (ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71LT ||
502 ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71XT) {
503 snd_ice1712_gpio_set_mask(ice, ~(PRODIGY_SPI_MOSI|PRODIGY_SPI_CLK|PRODIGY_WM_CS));
504 mosi = PRODIGY_SPI_MOSI;
505 clk = PRODIGY_SPI_CLK;
507 snd_ice1712_gpio_set_mask(ice, ~(AUREON_WM_RW|AUREON_SPI_MOSI|AUREON_SPI_CLK|
508 AUREON_WM_CS|AUREON_CS8415_CS));
509 mosi = AUREON_SPI_MOSI;
510 clk = AUREON_SPI_CLK;
516 snd_ice1712_gpio_write(ice, tmp);
519 for (i = bits - 1; i >= 0; i--) {
521 snd_ice1712_gpio_write(ice, tmp);
527 snd_ice1712_gpio_write(ice, tmp);
530 snd_ice1712_gpio_write(ice, tmp);
536 snd_ice1712_gpio_write(ice, tmp);
539 snd_ice1712_gpio_write(ice, tmp);
544 * Read data in SPI mode
546 static void aureon_spi_read(struct snd_ice1712 *ice, unsigned int cs,
547 unsigned int data, int bits, unsigned char *buffer, int size)
552 tmp = (snd_ice1712_gpio_read(ice) & ~AUREON_SPI_CLK) | AUREON_CS8415_CS|AUREON_WM_CS;
553 snd_ice1712_gpio_write(ice, tmp);
555 snd_ice1712_gpio_write(ice, tmp);
558 for (i = bits-1; i >= 0; i--) {
560 tmp |= AUREON_SPI_MOSI;
562 tmp &= ~AUREON_SPI_MOSI;
563 snd_ice1712_gpio_write(ice, tmp);
566 tmp |= AUREON_SPI_CLK;
567 snd_ice1712_gpio_write(ice, tmp);
570 tmp &= ~AUREON_SPI_CLK;
571 snd_ice1712_gpio_write(ice, tmp);
575 for (j = 0; j < size; j++) {
576 unsigned char outdata = 0;
577 for (i = 7; i >= 0; i--) {
578 tmp = snd_ice1712_gpio_read(ice);
580 outdata |= (tmp & AUREON_SPI_MISO) ? 1 : 0;
583 tmp |= AUREON_SPI_CLK;
584 snd_ice1712_gpio_write(ice, tmp);
587 tmp &= ~AUREON_SPI_CLK;
588 snd_ice1712_gpio_write(ice, tmp);
595 snd_ice1712_gpio_write(ice, tmp);
598 static unsigned char aureon_cs8415_get(struct snd_ice1712 *ice, int reg)
601 aureon_spi_write(ice, AUREON_CS8415_CS, 0x2000 | reg, 16);
602 aureon_spi_read(ice, AUREON_CS8415_CS, 0x21, 8, &val, 1);
606 static void aureon_cs8415_read(struct snd_ice1712 *ice, int reg,
607 unsigned char *buffer, int size)
609 aureon_spi_write(ice, AUREON_CS8415_CS, 0x2000 | reg, 16);
610 aureon_spi_read(ice, AUREON_CS8415_CS, 0x21, 8, buffer, size);
613 static void aureon_cs8415_put(struct snd_ice1712 *ice, int reg,
616 aureon_spi_write(ice, AUREON_CS8415_CS, 0x200000 | (reg << 8) | val, 24);
620 * get the current register value of WM codec
622 static unsigned short wm_get(struct snd_ice1712 *ice, int reg)
625 return ((unsigned short)ice->akm[0].images[reg] << 8) |
626 ice->akm[0].images[reg + 1];
630 * set the register value of WM codec
632 static void wm_put_nocache(struct snd_ice1712 *ice, int reg, unsigned short val)
634 aureon_spi_write(ice,
635 ((ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71LT ||
636 ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71XT) ?
637 PRODIGY_WM_CS : AUREON_WM_CS),
638 (reg << 9) | (val & 0x1ff), 16);
642 * set the register value of WM codec and remember it
644 static void wm_put(struct snd_ice1712 *ice, int reg, unsigned short val)
646 wm_put_nocache(ice, reg, val);
648 ice->akm[0].images[reg] = val >> 8;
649 ice->akm[0].images[reg + 1] = val;
654 #define aureon_mono_bool_info snd_ctl_boolean_mono_info
657 * AC'97 master playback mute controls (Mute on WM8770 chip)
659 #define aureon_ac97_mmute_info snd_ctl_boolean_mono_info
661 static int aureon_ac97_mmute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
663 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
665 mutex_lock(&ice->gpio_mutex);
667 ucontrol->value.integer.value[0] = (wm_get(ice, WM_OUT_MUX1) >> 1) & 0x01;
669 mutex_unlock(&ice->gpio_mutex);
673 static int aureon_ac97_mmute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
675 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
676 unsigned short ovol, nvol;
679 snd_ice1712_save_gpio_status(ice);
681 ovol = wm_get(ice, WM_OUT_MUX1);
682 nvol = (ovol & ~0x02) | (ucontrol->value.integer.value[0] ? 0x02 : 0x00);
683 change = (ovol != nvol);
685 wm_put(ice, WM_OUT_MUX1, nvol);
687 snd_ice1712_restore_gpio_status(ice);
692 static const DECLARE_TLV_DB_SCALE(db_scale_wm_dac, -10000, 100, 1);
693 static const DECLARE_TLV_DB_SCALE(db_scale_wm_pcm, -6400, 50, 1);
694 static const DECLARE_TLV_DB_SCALE(db_scale_wm_adc, -1200, 100, 0);
695 static const DECLARE_TLV_DB_SCALE(db_scale_ac97_master, -4650, 150, 0);
696 static const DECLARE_TLV_DB_SCALE(db_scale_ac97_gain, -3450, 150, 0);
698 #define WM_VOL_MAX 100
699 #define WM_VOL_CNT 101 /* 0dB .. -100dB */
700 #define WM_VOL_MUTE 0x8000
702 static void wm_set_vol(struct snd_ice1712 *ice, unsigned int index, unsigned short vol, unsigned short master)
706 if ((master & WM_VOL_MUTE) || (vol & WM_VOL_MUTE))
709 nvol = ((vol % WM_VOL_CNT) * (master % WM_VOL_CNT)) /
712 wm_put(ice, index, nvol);
713 wm_put_nocache(ice, index, 0x180 | nvol);
719 #define wm_pcm_mute_info snd_ctl_boolean_mono_info
721 static int wm_pcm_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
723 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
725 mutex_lock(&ice->gpio_mutex);
726 ucontrol->value.integer.value[0] = (wm_get(ice, WM_MUTE) & 0x10) ? 0 : 1;
727 mutex_unlock(&ice->gpio_mutex);
731 static int wm_pcm_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
733 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
734 unsigned short nval, oval;
737 snd_ice1712_save_gpio_status(ice);
738 oval = wm_get(ice, WM_MUTE);
739 nval = (oval & ~0x10) | (ucontrol->value.integer.value[0] ? 0 : 0x10);
740 change = (oval != nval);
742 wm_put(ice, WM_MUTE, nval);
743 snd_ice1712_restore_gpio_status(ice);
749 * Master volume attenuation mixer control
751 static int wm_master_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
753 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
755 uinfo->value.integer.min = 0;
756 uinfo->value.integer.max = WM_VOL_MAX;
760 static int wm_master_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
762 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
763 struct aureon_spec *spec = ice->spec;
765 for (i = 0; i < 2; i++)
766 ucontrol->value.integer.value[i] =
767 spec->master[i] & ~WM_VOL_MUTE;
771 static int wm_master_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
773 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
774 struct aureon_spec *spec = ice->spec;
777 snd_ice1712_save_gpio_status(ice);
778 for (ch = 0; ch < 2; ch++) {
779 unsigned int vol = ucontrol->value.integer.value[ch];
780 if (vol > WM_VOL_MAX)
782 vol |= spec->master[ch] & WM_VOL_MUTE;
783 if (vol != spec->master[ch]) {
785 spec->master[ch] = vol;
786 for (dac = 0; dac < ice->num_total_dacs; dac += 2)
787 wm_set_vol(ice, WM_DAC_ATTEN + dac + ch,
793 snd_ice1712_restore_gpio_status(ice);
798 * DAC volume attenuation mixer control
800 static int wm_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
802 int voices = kcontrol->private_value >> 8;
803 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
804 uinfo->count = voices;
805 uinfo->value.integer.min = 0; /* mute (-101dB) */
806 uinfo->value.integer.max = WM_VOL_MAX; /* 0dB */
810 static int wm_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
812 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
813 struct aureon_spec *spec = ice->spec;
816 voices = kcontrol->private_value >> 8;
817 ofs = kcontrol->private_value & 0xff;
818 for (i = 0; i < voices; i++)
819 ucontrol->value.integer.value[i] =
820 spec->vol[ofs+i] & ~WM_VOL_MUTE;
824 static int wm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
826 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
827 struct aureon_spec *spec = ice->spec;
828 int i, idx, ofs, voices;
831 voices = kcontrol->private_value >> 8;
832 ofs = kcontrol->private_value & 0xff;
833 snd_ice1712_save_gpio_status(ice);
834 for (i = 0; i < voices; i++) {
835 unsigned int vol = ucontrol->value.integer.value[i];
836 if (vol > WM_VOL_MAX)
838 vol |= spec->vol[ofs+i];
839 if (vol != spec->vol[ofs+i]) {
840 spec->vol[ofs+i] = vol;
841 idx = WM_DAC_ATTEN + ofs + i;
842 wm_set_vol(ice, idx, spec->vol[ofs + i],
847 snd_ice1712_restore_gpio_status(ice);
852 * WM8770 mute control
854 static int wm_mute_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
856 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
857 uinfo->count = kcontrol->private_value >> 8;
858 uinfo->value.integer.min = 0;
859 uinfo->value.integer.max = 1;
863 static int wm_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
865 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
866 struct aureon_spec *spec = ice->spec;
869 voices = kcontrol->private_value >> 8;
870 ofs = kcontrol->private_value & 0xFF;
872 for (i = 0; i < voices; i++)
873 ucontrol->value.integer.value[i] =
874 (spec->vol[ofs + i] & WM_VOL_MUTE) ? 0 : 1;
878 static int wm_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
880 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
881 struct aureon_spec *spec = ice->spec;
882 int change = 0, voices, ofs, i;
884 voices = kcontrol->private_value >> 8;
885 ofs = kcontrol->private_value & 0xFF;
887 snd_ice1712_save_gpio_status(ice);
888 for (i = 0; i < voices; i++) {
889 int val = (spec->vol[ofs + i] & WM_VOL_MUTE) ? 0 : 1;
890 if (ucontrol->value.integer.value[i] != val) {
891 spec->vol[ofs + i] &= ~WM_VOL_MUTE;
892 spec->vol[ofs + i] |=
893 ucontrol->value.integer.value[i] ? 0 : WM_VOL_MUTE;
894 wm_set_vol(ice, ofs + i, spec->vol[ofs + i],
899 snd_ice1712_restore_gpio_status(ice);
905 * WM8770 master mute control
907 #define wm_master_mute_info snd_ctl_boolean_stereo_info
909 static int wm_master_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
911 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
912 struct aureon_spec *spec = ice->spec;
914 ucontrol->value.integer.value[0] =
915 (spec->master[0] & WM_VOL_MUTE) ? 0 : 1;
916 ucontrol->value.integer.value[1] =
917 (spec->master[1] & WM_VOL_MUTE) ? 0 : 1;
921 static int wm_master_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
923 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
924 struct aureon_spec *spec = ice->spec;
927 snd_ice1712_save_gpio_status(ice);
928 for (i = 0; i < 2; i++) {
929 int val = (spec->master[i] & WM_VOL_MUTE) ? 0 : 1;
930 if (ucontrol->value.integer.value[i] != val) {
932 spec->master[i] &= ~WM_VOL_MUTE;
934 ucontrol->value.integer.value[i] ? 0 : WM_VOL_MUTE;
935 for (dac = 0; dac < ice->num_total_dacs; dac += 2)
936 wm_set_vol(ice, WM_DAC_ATTEN + dac + i,
942 snd_ice1712_restore_gpio_status(ice);
947 /* digital master volume */
949 #define PCM_RES 128 /* -64dB */
950 #define PCM_MIN (PCM_0dB - PCM_RES)
951 static int wm_pcm_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
953 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
955 uinfo->value.integer.min = 0; /* mute (-64dB) */
956 uinfo->value.integer.max = PCM_RES; /* 0dB */
960 static int wm_pcm_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
962 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
965 mutex_lock(&ice->gpio_mutex);
966 val = wm_get(ice, WM_DAC_DIG_MASTER_ATTEN) & 0xff;
967 val = val > PCM_MIN ? (val - PCM_MIN) : 0;
968 ucontrol->value.integer.value[0] = val;
969 mutex_unlock(&ice->gpio_mutex);
973 static int wm_pcm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
975 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
976 unsigned short ovol, nvol;
979 nvol = ucontrol->value.integer.value[0];
982 snd_ice1712_save_gpio_status(ice);
983 nvol = (nvol ? (nvol + PCM_MIN) : 0) & 0xff;
984 ovol = wm_get(ice, WM_DAC_DIG_MASTER_ATTEN) & 0xff;
986 wm_put(ice, WM_DAC_DIG_MASTER_ATTEN, nvol); /* prelatch */
987 wm_put_nocache(ice, WM_DAC_DIG_MASTER_ATTEN, nvol | 0x100); /* update */
990 snd_ice1712_restore_gpio_status(ice);
997 #define wm_adc_mute_info snd_ctl_boolean_stereo_info
999 static int wm_adc_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1001 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1005 mutex_lock(&ice->gpio_mutex);
1006 for (i = 0; i < 2; i++) {
1007 val = wm_get(ice, WM_ADC_GAIN + i);
1008 ucontrol->value.integer.value[i] = ~val>>5 & 0x1;
1010 mutex_unlock(&ice->gpio_mutex);
1014 static int wm_adc_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1016 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1017 unsigned short new, old;
1020 snd_ice1712_save_gpio_status(ice);
1021 for (i = 0; i < 2; i++) {
1022 old = wm_get(ice, WM_ADC_GAIN + i);
1023 new = (~ucontrol->value.integer.value[i]<<5&0x20) | (old&~0x20);
1025 wm_put(ice, WM_ADC_GAIN + i, new);
1029 snd_ice1712_restore_gpio_status(ice);
1035 * ADC gain mixer control
1037 static int wm_adc_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1039 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1041 uinfo->value.integer.min = 0; /* -12dB */
1042 uinfo->value.integer.max = 0x1f; /* 19dB */
1046 static int wm_adc_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1048 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1052 mutex_lock(&ice->gpio_mutex);
1053 for (i = 0; i < 2; i++) {
1054 idx = WM_ADC_GAIN + i;
1055 vol = wm_get(ice, idx) & 0x1f;
1056 ucontrol->value.integer.value[i] = vol;
1058 mutex_unlock(&ice->gpio_mutex);
1062 static int wm_adc_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1064 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1066 unsigned short ovol, nvol;
1069 snd_ice1712_save_gpio_status(ice);
1070 for (i = 0; i < 2; i++) {
1071 idx = WM_ADC_GAIN + i;
1072 nvol = ucontrol->value.integer.value[i] & 0x1f;
1073 ovol = wm_get(ice, idx);
1074 if ((ovol & 0x1f) != nvol) {
1075 wm_put(ice, idx, nvol | (ovol & ~0x1f));
1079 snd_ice1712_restore_gpio_status(ice);
1084 * ADC input mux mixer control
1086 static int wm_adc_mux_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1088 static const char * const texts[] = {
1095 static const char * const universe_texts[] = {
1105 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1107 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1109 if (ice->eeprom.subvendor == VT1724_SUBDEVICE_AUREON71_UNIVERSE) {
1110 uinfo->value.enumerated.items = 8;
1111 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
1112 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
1113 strcpy(uinfo->value.enumerated.name, universe_texts[uinfo->value.enumerated.item]);
1115 uinfo->value.enumerated.items = 5;
1116 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
1117 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
1118 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1123 static int wm_adc_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1125 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1128 mutex_lock(&ice->gpio_mutex);
1129 val = wm_get(ice, WM_ADC_MUX);
1130 ucontrol->value.enumerated.item[0] = val & 7;
1131 ucontrol->value.enumerated.item[1] = (val >> 4) & 7;
1132 mutex_unlock(&ice->gpio_mutex);
1136 static int wm_adc_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1138 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1139 unsigned short oval, nval;
1142 snd_ice1712_save_gpio_status(ice);
1143 oval = wm_get(ice, WM_ADC_MUX);
1144 nval = oval & ~0x77;
1145 nval |= ucontrol->value.enumerated.item[0] & 7;
1146 nval |= (ucontrol->value.enumerated.item[1] & 7) << 4;
1147 change = (oval != nval);
1149 wm_put(ice, WM_ADC_MUX, nval);
1150 snd_ice1712_restore_gpio_status(ice);
1157 static int aureon_cs8415_mux_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1159 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1160 static const char * const aureon_texts[] = {
1162 "Optical" /* RXP1 */
1164 static const char * const prodigy_texts[] = {
1168 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1170 uinfo->value.enumerated.items = 2;
1171 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
1172 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
1173 if (ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71)
1174 strcpy(uinfo->value.enumerated.name, prodigy_texts[uinfo->value.enumerated.item]);
1176 strcpy(uinfo->value.enumerated.name, aureon_texts[uinfo->value.enumerated.item]);
1180 static int aureon_cs8415_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1182 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1183 struct aureon_spec *spec = ice->spec;
1185 /* snd_ice1712_save_gpio_status(ice); */
1186 /* val = aureon_cs8415_get(ice, CS8415_CTRL2); */
1187 ucontrol->value.enumerated.item[0] = spec->cs8415_mux;
1188 /* snd_ice1712_restore_gpio_status(ice); */
1192 static int aureon_cs8415_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1194 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1195 struct aureon_spec *spec = ice->spec;
1196 unsigned short oval, nval;
1199 snd_ice1712_save_gpio_status(ice);
1200 oval = aureon_cs8415_get(ice, CS8415_CTRL2);
1201 nval = oval & ~0x07;
1202 nval |= ucontrol->value.enumerated.item[0] & 7;
1203 change = (oval != nval);
1205 aureon_cs8415_put(ice, CS8415_CTRL2, nval);
1206 snd_ice1712_restore_gpio_status(ice);
1207 spec->cs8415_mux = ucontrol->value.enumerated.item[0];
1211 static int aureon_cs8415_rate_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1213 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1215 uinfo->value.integer.min = 0;
1216 uinfo->value.integer.max = 192000;
1220 static int aureon_cs8415_rate_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1222 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1223 unsigned char ratio;
1224 ratio = aureon_cs8415_get(ice, CS8415_RATIO);
1225 ucontrol->value.integer.value[0] = (int)((unsigned int)ratio * 750);
1232 #define aureon_cs8415_mute_info snd_ctl_boolean_mono_info
1234 static int aureon_cs8415_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1236 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1237 snd_ice1712_save_gpio_status(ice);
1238 ucontrol->value.integer.value[0] = (aureon_cs8415_get(ice, CS8415_CTRL1) & 0x20) ? 0 : 1;
1239 snd_ice1712_restore_gpio_status(ice);
1243 static int aureon_cs8415_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1245 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1246 unsigned char oval, nval;
1248 snd_ice1712_save_gpio_status(ice);
1249 oval = aureon_cs8415_get(ice, CS8415_CTRL1);
1250 if (ucontrol->value.integer.value[0])
1251 nval = oval & ~0x20;
1254 change = (oval != nval);
1256 aureon_cs8415_put(ice, CS8415_CTRL1, nval);
1257 snd_ice1712_restore_gpio_status(ice);
1262 * CS8415A Q-Sub info
1264 static int aureon_cs8415_qsub_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1266 uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
1271 static int aureon_cs8415_qsub_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1273 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1275 snd_ice1712_save_gpio_status(ice);
1276 aureon_cs8415_read(ice, CS8415_QSUB, ucontrol->value.bytes.data, 10);
1277 snd_ice1712_restore_gpio_status(ice);
1282 static int aureon_cs8415_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1284 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
1289 static int aureon_cs8415_mask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1291 memset(ucontrol->value.iec958.status, 0xFF, 24);
1295 static int aureon_cs8415_spdif_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1297 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1299 snd_ice1712_save_gpio_status(ice);
1300 aureon_cs8415_read(ice, CS8415_C_BUFFER, ucontrol->value.iec958.status, 24);
1301 snd_ice1712_restore_gpio_status(ice);
1306 * Headphone Amplifier
1308 static int aureon_set_headphone_amp(struct snd_ice1712 *ice, int enable)
1310 unsigned int tmp, tmp2;
1312 tmp2 = tmp = snd_ice1712_gpio_read(ice);
1314 if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT &&
1315 ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71XT)
1316 tmp |= AUREON_HP_SEL;
1318 tmp |= PRODIGY_HP_SEL;
1320 if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT &&
1321 ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71XT)
1322 tmp &= ~AUREON_HP_SEL;
1324 tmp &= ~PRODIGY_HP_SEL;
1326 snd_ice1712_gpio_write(ice, tmp);
1332 static int aureon_get_headphone_amp(struct snd_ice1712 *ice)
1334 unsigned int tmp = snd_ice1712_gpio_read(ice);
1336 return (tmp & AUREON_HP_SEL) != 0;
1339 #define aureon_hpamp_info snd_ctl_boolean_mono_info
1341 static int aureon_hpamp_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1343 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1345 ucontrol->value.integer.value[0] = aureon_get_headphone_amp(ice);
1350 static int aureon_hpamp_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1352 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1354 return aureon_set_headphone_amp(ice, ucontrol->value.integer.value[0]);
1361 #define aureon_deemp_info snd_ctl_boolean_mono_info
1363 static int aureon_deemp_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1365 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1366 ucontrol->value.integer.value[0] = (wm_get(ice, WM_DAC_CTRL2) & 0xf) == 0xf;
1370 static int aureon_deemp_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1372 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1374 temp2 = temp = wm_get(ice, WM_DAC_CTRL2);
1375 if (ucontrol->value.integer.value[0])
1379 if (temp != temp2) {
1380 wm_put(ice, WM_DAC_CTRL2, temp);
1389 static int aureon_oversampling_info(struct snd_kcontrol *k, struct snd_ctl_elem_info *uinfo)
1391 static const char * const texts[2] = { "128x", "64x" };
1393 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1395 uinfo->value.enumerated.items = 2;
1397 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
1398 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
1399 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1404 static int aureon_oversampling_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1406 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1407 ucontrol->value.enumerated.item[0] = (wm_get(ice, WM_MASTER) & 0x8) == 0x8;
1411 static int aureon_oversampling_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1414 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1416 temp2 = temp = wm_get(ice, WM_MASTER);
1418 if (ucontrol->value.enumerated.item[0])
1423 if (temp != temp2) {
1424 wm_put(ice, WM_MASTER, temp);
1434 static struct snd_kcontrol_new aureon_dac_controls[] __devinitdata = {
1436 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1437 .name = "Master Playback Switch",
1438 .info = wm_master_mute_info,
1439 .get = wm_master_mute_get,
1440 .put = wm_master_mute_put
1443 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1444 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
1445 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
1446 .name = "Master Playback Volume",
1447 .info = wm_master_vol_info,
1448 .get = wm_master_vol_get,
1449 .put = wm_master_vol_put,
1450 .tlv = { .p = db_scale_wm_dac }
1453 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1454 .name = "Front Playback Switch",
1455 .info = wm_mute_info,
1458 .private_value = (2 << 8) | 0
1461 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1462 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
1463 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
1464 .name = "Front Playback Volume",
1465 .info = wm_vol_info,
1468 .private_value = (2 << 8) | 0,
1469 .tlv = { .p = db_scale_wm_dac }
1472 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1473 .name = "Rear Playback Switch",
1474 .info = wm_mute_info,
1477 .private_value = (2 << 8) | 2
1480 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1481 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
1482 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
1483 .name = "Rear Playback Volume",
1484 .info = wm_vol_info,
1487 .private_value = (2 << 8) | 2,
1488 .tlv = { .p = db_scale_wm_dac }
1491 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1492 .name = "Center Playback Switch",
1493 .info = wm_mute_info,
1496 .private_value = (1 << 8) | 4
1499 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1500 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
1501 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
1502 .name = "Center Playback Volume",
1503 .info = wm_vol_info,
1506 .private_value = (1 << 8) | 4,
1507 .tlv = { .p = db_scale_wm_dac }
1510 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1511 .name = "LFE Playback Switch",
1512 .info = wm_mute_info,
1515 .private_value = (1 << 8) | 5
1518 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1519 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
1520 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
1521 .name = "LFE Playback Volume",
1522 .info = wm_vol_info,
1525 .private_value = (1 << 8) | 5,
1526 .tlv = { .p = db_scale_wm_dac }
1529 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1530 .name = "Side Playback Switch",
1531 .info = wm_mute_info,
1534 .private_value = (2 << 8) | 6
1537 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1538 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
1539 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
1540 .name = "Side Playback Volume",
1541 .info = wm_vol_info,
1544 .private_value = (2 << 8) | 6,
1545 .tlv = { .p = db_scale_wm_dac }
1549 static struct snd_kcontrol_new wm_controls[] __devinitdata = {
1551 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1552 .name = "PCM Playback Switch",
1553 .info = wm_pcm_mute_info,
1554 .get = wm_pcm_mute_get,
1555 .put = wm_pcm_mute_put
1558 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1559 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
1560 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
1561 .name = "PCM Playback Volume",
1562 .info = wm_pcm_vol_info,
1563 .get = wm_pcm_vol_get,
1564 .put = wm_pcm_vol_put,
1565 .tlv = { .p = db_scale_wm_pcm }
1568 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1569 .name = "Capture Switch",
1570 .info = wm_adc_mute_info,
1571 .get = wm_adc_mute_get,
1572 .put = wm_adc_mute_put,
1575 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1576 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
1577 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
1578 .name = "Capture Volume",
1579 .info = wm_adc_vol_info,
1580 .get = wm_adc_vol_get,
1581 .put = wm_adc_vol_put,
1582 .tlv = { .p = db_scale_wm_adc }
1585 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1586 .name = "Capture Source",
1587 .info = wm_adc_mux_info,
1588 .get = wm_adc_mux_get,
1589 .put = wm_adc_mux_put,
1593 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1594 .name = "External Amplifier",
1595 .info = aureon_hpamp_info,
1596 .get = aureon_hpamp_get,
1597 .put = aureon_hpamp_put
1600 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1601 .name = "DAC Deemphasis Switch",
1602 .info = aureon_deemp_info,
1603 .get = aureon_deemp_get,
1604 .put = aureon_deemp_put
1607 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1608 .name = "ADC Oversampling",
1609 .info = aureon_oversampling_info,
1610 .get = aureon_oversampling_get,
1611 .put = aureon_oversampling_put
1615 static struct snd_kcontrol_new ac97_controls[] __devinitdata = {
1617 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1618 .name = "AC97 Playback Switch",
1619 .info = aureon_ac97_mmute_info,
1620 .get = aureon_ac97_mmute_get,
1621 .put = aureon_ac97_mmute_put,
1622 .private_value = AC97_MASTER
1625 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1626 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
1627 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
1628 .name = "AC97 Playback Volume",
1629 .info = aureon_ac97_vol_info,
1630 .get = aureon_ac97_vol_get,
1631 .put = aureon_ac97_vol_put,
1632 .private_value = AC97_MASTER|AUREON_AC97_STEREO,
1633 .tlv = { .p = db_scale_ac97_master }
1636 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1637 .name = "CD Playback Switch",
1638 .info = aureon_ac97_mute_info,
1639 .get = aureon_ac97_mute_get,
1640 .put = aureon_ac97_mute_put,
1641 .private_value = AC97_CD
1644 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1645 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
1646 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
1647 .name = "CD Playback Volume",
1648 .info = aureon_ac97_vol_info,
1649 .get = aureon_ac97_vol_get,
1650 .put = aureon_ac97_vol_put,
1651 .private_value = AC97_CD|AUREON_AC97_STEREO,
1652 .tlv = { .p = db_scale_ac97_gain }
1655 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1656 .name = "Aux Playback Switch",
1657 .info = aureon_ac97_mute_info,
1658 .get = aureon_ac97_mute_get,
1659 .put = aureon_ac97_mute_put,
1660 .private_value = AC97_AUX,
1663 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1664 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
1665 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
1666 .name = "Aux Playback Volume",
1667 .info = aureon_ac97_vol_info,
1668 .get = aureon_ac97_vol_get,
1669 .put = aureon_ac97_vol_put,
1670 .private_value = AC97_AUX|AUREON_AC97_STEREO,
1671 .tlv = { .p = db_scale_ac97_gain }
1674 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1675 .name = "Line Playback Switch",
1676 .info = aureon_ac97_mute_info,
1677 .get = aureon_ac97_mute_get,
1678 .put = aureon_ac97_mute_put,
1679 .private_value = AC97_LINE
1682 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1683 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
1684 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
1685 .name = "Line Playback Volume",
1686 .info = aureon_ac97_vol_info,
1687 .get = aureon_ac97_vol_get,
1688 .put = aureon_ac97_vol_put,
1689 .private_value = AC97_LINE|AUREON_AC97_STEREO,
1690 .tlv = { .p = db_scale_ac97_gain }
1693 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1694 .name = "Mic Playback Switch",
1695 .info = aureon_ac97_mute_info,
1696 .get = aureon_ac97_mute_get,
1697 .put = aureon_ac97_mute_put,
1698 .private_value = AC97_MIC
1701 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1702 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
1703 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
1704 .name = "Mic Playback Volume",
1705 .info = aureon_ac97_vol_info,
1706 .get = aureon_ac97_vol_get,
1707 .put = aureon_ac97_vol_put,
1708 .private_value = AC97_MIC,
1709 .tlv = { .p = db_scale_ac97_gain }
1712 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1713 .name = "Mic Boost (+20dB)",
1714 .info = aureon_ac97_micboost_info,
1715 .get = aureon_ac97_micboost_get,
1716 .put = aureon_ac97_micboost_put
1720 static struct snd_kcontrol_new universe_ac97_controls[] __devinitdata = {
1722 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1723 .name = "AC97 Playback Switch",
1724 .info = aureon_ac97_mmute_info,
1725 .get = aureon_ac97_mmute_get,
1726 .put = aureon_ac97_mmute_put,
1727 .private_value = AC97_MASTER
1730 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1731 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
1732 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
1733 .name = "AC97 Playback Volume",
1734 .info = aureon_ac97_vol_info,
1735 .get = aureon_ac97_vol_get,
1736 .put = aureon_ac97_vol_put,
1737 .private_value = AC97_MASTER|AUREON_AC97_STEREO,
1738 .tlv = { .p = db_scale_ac97_master }
1741 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1742 .name = "CD Playback Switch",
1743 .info = aureon_ac97_mute_info,
1744 .get = aureon_ac97_mute_get,
1745 .put = aureon_ac97_mute_put,
1746 .private_value = AC97_AUX
1749 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1750 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
1751 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
1752 .name = "CD Playback Volume",
1753 .info = aureon_ac97_vol_info,
1754 .get = aureon_ac97_vol_get,
1755 .put = aureon_ac97_vol_put,
1756 .private_value = AC97_AUX|AUREON_AC97_STEREO,
1757 .tlv = { .p = db_scale_ac97_gain }
1760 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1761 .name = "Phono Playback Switch",
1762 .info = aureon_ac97_mute_info,
1763 .get = aureon_ac97_mute_get,
1764 .put = aureon_ac97_mute_put,
1765 .private_value = AC97_CD
1768 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1769 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
1770 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
1771 .name = "Phono Playback Volume",
1772 .info = aureon_ac97_vol_info,
1773 .get = aureon_ac97_vol_get,
1774 .put = aureon_ac97_vol_put,
1775 .private_value = AC97_CD|AUREON_AC97_STEREO,
1776 .tlv = { .p = db_scale_ac97_gain }
1779 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1780 .name = "Line Playback Switch",
1781 .info = aureon_ac97_mute_info,
1782 .get = aureon_ac97_mute_get,
1783 .put = aureon_ac97_mute_put,
1784 .private_value = AC97_LINE
1787 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1788 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
1789 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
1790 .name = "Line Playback Volume",
1791 .info = aureon_ac97_vol_info,
1792 .get = aureon_ac97_vol_get,
1793 .put = aureon_ac97_vol_put,
1794 .private_value = AC97_LINE|AUREON_AC97_STEREO,
1795 .tlv = { .p = db_scale_ac97_gain }
1798 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1799 .name = "Mic Playback Switch",
1800 .info = aureon_ac97_mute_info,
1801 .get = aureon_ac97_mute_get,
1802 .put = aureon_ac97_mute_put,
1803 .private_value = AC97_MIC
1806 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1807 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
1808 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
1809 .name = "Mic Playback Volume",
1810 .info = aureon_ac97_vol_info,
1811 .get = aureon_ac97_vol_get,
1812 .put = aureon_ac97_vol_put,
1813 .private_value = AC97_MIC,
1814 .tlv = { .p = db_scale_ac97_gain }
1817 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1818 .name = "Mic Boost (+20dB)",
1819 .info = aureon_ac97_micboost_info,
1820 .get = aureon_ac97_micboost_get,
1821 .put = aureon_ac97_micboost_put
1824 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1825 .name = "Aux Playback Switch",
1826 .info = aureon_ac97_mute_info,
1827 .get = aureon_ac97_mute_get,
1828 .put = aureon_ac97_mute_put,
1829 .private_value = AC97_VIDEO,
1832 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1833 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
1834 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
1835 .name = "Aux Playback Volume",
1836 .info = aureon_ac97_vol_info,
1837 .get = aureon_ac97_vol_get,
1838 .put = aureon_ac97_vol_put,
1839 .private_value = AC97_VIDEO|AUREON_AC97_STEREO,
1840 .tlv = { .p = db_scale_ac97_gain }
1843 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1844 .name = "Aux Source",
1845 .info = aureon_universe_inmux_info,
1846 .get = aureon_universe_inmux_get,
1847 .put = aureon_universe_inmux_put
1852 static struct snd_kcontrol_new cs8415_controls[] __devinitdata = {
1854 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1855 .name = SNDRV_CTL_NAME_IEC958("", CAPTURE, SWITCH),
1856 .info = aureon_cs8415_mute_info,
1857 .get = aureon_cs8415_mute_get,
1858 .put = aureon_cs8415_mute_put
1861 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1862 .name = SNDRV_CTL_NAME_IEC958("", CAPTURE, NONE) "Source",
1863 .info = aureon_cs8415_mux_info,
1864 .get = aureon_cs8415_mux_get,
1865 .put = aureon_cs8415_mux_put,
1868 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
1869 .name = SNDRV_CTL_NAME_IEC958("Q-subcode ", CAPTURE, DEFAULT),
1870 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
1871 .info = aureon_cs8415_qsub_info,
1872 .get = aureon_cs8415_qsub_get,
1875 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
1876 .name = SNDRV_CTL_NAME_IEC958("", CAPTURE, MASK),
1877 .access = SNDRV_CTL_ELEM_ACCESS_READ,
1878 .info = aureon_cs8415_spdif_info,
1879 .get = aureon_cs8415_mask_get
1882 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
1883 .name = SNDRV_CTL_NAME_IEC958("", CAPTURE, DEFAULT),
1884 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
1885 .info = aureon_cs8415_spdif_info,
1886 .get = aureon_cs8415_spdif_get
1889 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
1890 .name = SNDRV_CTL_NAME_IEC958("", CAPTURE, NONE) "Rate",
1891 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
1892 .info = aureon_cs8415_rate_info,
1893 .get = aureon_cs8415_rate_get
1897 static int __devinit aureon_add_controls(struct snd_ice1712 *ice)
1899 unsigned int i, counts;
1902 counts = ARRAY_SIZE(aureon_dac_controls);
1903 if (ice->eeprom.subvendor == VT1724_SUBDEVICE_AUREON51_SKY)
1904 counts -= 2; /* no side */
1905 for (i = 0; i < counts; i++) {
1906 err = snd_ctl_add(ice->card, snd_ctl_new1(&aureon_dac_controls[i], ice));
1911 for (i = 0; i < ARRAY_SIZE(wm_controls); i++) {
1912 err = snd_ctl_add(ice->card, snd_ctl_new1(&wm_controls[i], ice));
1917 if (ice->eeprom.subvendor == VT1724_SUBDEVICE_AUREON71_UNIVERSE) {
1918 for (i = 0; i < ARRAY_SIZE(universe_ac97_controls); i++) {
1919 err = snd_ctl_add(ice->card, snd_ctl_new1(&universe_ac97_controls[i], ice));
1923 } else if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT &&
1924 ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71XT) {
1925 for (i = 0; i < ARRAY_SIZE(ac97_controls); i++) {
1926 err = snd_ctl_add(ice->card, snd_ctl_new1(&ac97_controls[i], ice));
1932 if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT &&
1933 ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71XT) {
1935 snd_ice1712_save_gpio_status(ice);
1936 id = aureon_cs8415_get(ice, CS8415_ID);
1938 snd_printk(KERN_INFO "No CS8415 chip. Skipping CS8415 controls.\n");
1939 else if ((id & 0x0F) != 0x01)
1940 snd_printk(KERN_INFO "Detected unsupported CS8415 rev. (%c)\n", (char)((id & 0x0F) + 'A' - 1));
1942 for (i = 0; i < ARRAY_SIZE(cs8415_controls); i++) {
1943 struct snd_kcontrol *kctl;
1944 err = snd_ctl_add(ice->card, (kctl = snd_ctl_new1(&cs8415_controls[i], ice)));
1948 kctl->id.device = ice->pcm->device;
1951 snd_ice1712_restore_gpio_status(ice);
1959 * initialize the chip
1961 static int __devinit aureon_init(struct snd_ice1712 *ice)
1963 static const unsigned short wm_inits_aureon[] = {
1964 /* These come first to reduce init pop noise */
1965 0x1b, 0x044, /* ADC Mux (AC'97 source) */
1966 0x1c, 0x00B, /* Out Mux1 (VOUT1 = DAC+AUX, VOUT2 = DAC) */
1967 0x1d, 0x009, /* Out Mux2 (VOUT2 = DAC, VOUT3 = DAC) */
1969 0x18, 0x000, /* All power-up */
1971 0x16, 0x122, /* I2S, normal polarity, 24bit */
1972 0x17, 0x022, /* 256fs, slave mode */
1973 0x00, 0, /* DAC1 analog mute */
1974 0x01, 0, /* DAC2 analog mute */
1975 0x02, 0, /* DAC3 analog mute */
1976 0x03, 0, /* DAC4 analog mute */
1977 0x04, 0, /* DAC5 analog mute */
1978 0x05, 0, /* DAC6 analog mute */
1979 0x06, 0, /* DAC7 analog mute */
1980 0x07, 0, /* DAC8 analog mute */
1981 0x08, 0x100, /* master analog mute */
1982 0x09, 0xff, /* DAC1 digital full */
1983 0x0a, 0xff, /* DAC2 digital full */
1984 0x0b, 0xff, /* DAC3 digital full */
1985 0x0c, 0xff, /* DAC4 digital full */
1986 0x0d, 0xff, /* DAC5 digital full */
1987 0x0e, 0xff, /* DAC6 digital full */
1988 0x0f, 0xff, /* DAC7 digital full */
1989 0x10, 0xff, /* DAC8 digital full */
1990 0x11, 0x1ff, /* master digital full */
1991 0x12, 0x000, /* phase normal */
1992 0x13, 0x090, /* unmute DAC L/R */
1993 0x14, 0x000, /* all unmute */
1994 0x15, 0x000, /* no deemphasis, no ZFLG */
1995 0x19, 0x000, /* -12dB ADC/L */
1996 0x1a, 0x000, /* -12dB ADC/R */
1999 static const unsigned short wm_inits_prodigy[] = {
2001 /* These come first to reduce init pop noise */
2002 0x1b, 0x000, /* ADC Mux */
2003 0x1c, 0x009, /* Out Mux1 */
2004 0x1d, 0x009, /* Out Mux2 */
2006 0x18, 0x000, /* All power-up */
2008 0x16, 0x022, /* I2S, normal polarity, 24bit, high-pass on */
2009 0x17, 0x006, /* 128fs, slave mode */
2011 0x00, 0, /* DAC1 analog mute */
2012 0x01, 0, /* DAC2 analog mute */
2013 0x02, 0, /* DAC3 analog mute */
2014 0x03, 0, /* DAC4 analog mute */
2015 0x04, 0, /* DAC5 analog mute */
2016 0x05, 0, /* DAC6 analog mute */
2017 0x06, 0, /* DAC7 analog mute */
2018 0x07, 0, /* DAC8 analog mute */
2019 0x08, 0x100, /* master analog mute */
2021 0x09, 0x7f, /* DAC1 digital full */
2022 0x0a, 0x7f, /* DAC2 digital full */
2023 0x0b, 0x7f, /* DAC3 digital full */
2024 0x0c, 0x7f, /* DAC4 digital full */
2025 0x0d, 0x7f, /* DAC5 digital full */
2026 0x0e, 0x7f, /* DAC6 digital full */
2027 0x0f, 0x7f, /* DAC7 digital full */
2028 0x10, 0x7f, /* DAC8 digital full */
2029 0x11, 0x1FF, /* master digital full */
2031 0x12, 0x000, /* phase normal */
2032 0x13, 0x090, /* unmute DAC L/R */
2033 0x14, 0x000, /* all unmute */
2034 0x15, 0x000, /* no deemphasis, no ZFLG */
2036 0x19, 0x000, /* -12dB ADC/L */
2037 0x1a, 0x000, /* -12dB ADC/R */
2041 static const unsigned short cs_inits[] = {
2043 0x0180, /* no mute, OMCK output on RMCK pin */
2044 0x0201, /* S/PDIF source on RXP1 */
2045 0x0605, /* slave, 24bit, MSB on second OSCLK, SDOUT for right channel when OLRCK is high */
2048 struct aureon_spec *spec;
2050 const unsigned short *p;
2053 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2058 if (ice->eeprom.subvendor == VT1724_SUBDEVICE_AUREON51_SKY) {
2059 ice->num_total_dacs = 6;
2060 ice->num_total_adcs = 2;
2062 /* aureon 7.1 and prodigy 7.1 */
2063 ice->num_total_dacs = 8;
2064 ice->num_total_adcs = 2;
2067 /* to remeber the register values of CS8415 */
2068 ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL);
2071 ice->akm_codecs = 1;
2073 err = aureon_ac97_init(ice);
2077 snd_ice1712_gpio_set_dir(ice, 0x5fffff); /* fix this for the time being */
2079 /* reset the wm codec as the SPI mode */
2080 snd_ice1712_save_gpio_status(ice);
2081 snd_ice1712_gpio_set_mask(ice, ~(AUREON_WM_RESET|AUREON_WM_CS|AUREON_CS8415_CS|AUREON_HP_SEL));
2083 tmp = snd_ice1712_gpio_read(ice);
2084 tmp &= ~AUREON_WM_RESET;
2085 snd_ice1712_gpio_write(ice, tmp);
2087 tmp |= AUREON_WM_CS | AUREON_CS8415_CS;
2088 snd_ice1712_gpio_write(ice, tmp);
2090 tmp |= AUREON_WM_RESET;
2091 snd_ice1712_gpio_write(ice, tmp);
2094 /* initialize WM8770 codec */
2095 if (ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71 ||
2096 ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71LT ||
2097 ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71XT)
2098 p = wm_inits_prodigy;
2100 p = wm_inits_aureon;
2101 for (; *p != (unsigned short)-1; p += 2)
2102 wm_put(ice, p[0], p[1]);
2104 /* initialize CS8415A codec */
2105 if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT &&
2106 ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71XT) {
2107 for (p = cs_inits; *p != (unsigned short)-1; p++)
2108 aureon_spi_write(ice, AUREON_CS8415_CS, *p | 0x200000, 24);
2109 spec->cs8415_mux = 1;
2111 aureon_set_headphone_amp(ice, 1);
2114 snd_ice1712_restore_gpio_status(ice);
2116 /* initialize PCA9554 pin directions & set default input */
2117 aureon_pca9554_write(ice, PCA9554_DIR, 0x00);
2118 aureon_pca9554_write(ice, PCA9554_OUT, 0x00); /* internal AUX */
2120 spec->master[0] = WM_VOL_MUTE;
2121 spec->master[1] = WM_VOL_MUTE;
2122 for (i = 0; i < ice->num_total_dacs; i++) {
2123 spec->vol[i] = WM_VOL_MUTE;
2124 wm_set_vol(ice, i, spec->vol[i], spec->master[i % 2]);
2132 * Aureon boards don't provide the EEPROM data except for the vendor IDs.
2133 * hence the driver needs to sets up it properly.
2136 static unsigned char aureon51_eeprom[] __devinitdata = {
2137 [ICE_EEP2_SYSCONF] = 0x0a, /* clock 512, spdif-in/ADC, 3DACs */
2138 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
2139 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */
2140 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
2141 [ICE_EEP2_GPIO_DIR] = 0xff,
2142 [ICE_EEP2_GPIO_DIR1] = 0xff,
2143 [ICE_EEP2_GPIO_DIR2] = 0x5f,
2144 [ICE_EEP2_GPIO_MASK] = 0x00,
2145 [ICE_EEP2_GPIO_MASK1] = 0x00,
2146 [ICE_EEP2_GPIO_MASK2] = 0x00,
2147 [ICE_EEP2_GPIO_STATE] = 0x00,
2148 [ICE_EEP2_GPIO_STATE1] = 0x00,
2149 [ICE_EEP2_GPIO_STATE2] = 0x00,
2152 static unsigned char aureon71_eeprom[] __devinitdata = {
2153 [ICE_EEP2_SYSCONF] = 0x0b, /* clock 512, spdif-in/ADC, 4DACs */
2154 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
2155 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */
2156 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
2157 [ICE_EEP2_GPIO_DIR] = 0xff,
2158 [ICE_EEP2_GPIO_DIR1] = 0xff,
2159 [ICE_EEP2_GPIO_DIR2] = 0x5f,
2160 [ICE_EEP2_GPIO_MASK] = 0x00,
2161 [ICE_EEP2_GPIO_MASK1] = 0x00,
2162 [ICE_EEP2_GPIO_MASK2] = 0x00,
2163 [ICE_EEP2_GPIO_STATE] = 0x00,
2164 [ICE_EEP2_GPIO_STATE1] = 0x00,
2165 [ICE_EEP2_GPIO_STATE2] = 0x00,
2167 #define prodigy71_eeprom aureon71_eeprom
2169 static unsigned char aureon71_universe_eeprom[] __devinitdata = {
2170 [ICE_EEP2_SYSCONF] = 0x2b, /* clock 512, mpu401, spdif-in/ADC,
2173 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
2174 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */
2175 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
2176 [ICE_EEP2_GPIO_DIR] = 0xff,
2177 [ICE_EEP2_GPIO_DIR1] = 0xff,
2178 [ICE_EEP2_GPIO_DIR2] = 0x5f,
2179 [ICE_EEP2_GPIO_MASK] = 0x00,
2180 [ICE_EEP2_GPIO_MASK1] = 0x00,
2181 [ICE_EEP2_GPIO_MASK2] = 0x00,
2182 [ICE_EEP2_GPIO_STATE] = 0x00,
2183 [ICE_EEP2_GPIO_STATE1] = 0x00,
2184 [ICE_EEP2_GPIO_STATE2] = 0x00,
2187 static unsigned char prodigy71lt_eeprom[] __devinitdata = {
2188 [ICE_EEP2_SYSCONF] = 0x4b, /* clock 384, spdif-in/ADC, 4DACs */
2189 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
2190 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */
2191 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
2192 [ICE_EEP2_GPIO_DIR] = 0xff,
2193 [ICE_EEP2_GPIO_DIR1] = 0xff,
2194 [ICE_EEP2_GPIO_DIR2] = 0x5f,
2195 [ICE_EEP2_GPIO_MASK] = 0x00,
2196 [ICE_EEP2_GPIO_MASK1] = 0x00,
2197 [ICE_EEP2_GPIO_MASK2] = 0x00,
2198 [ICE_EEP2_GPIO_STATE] = 0x00,
2199 [ICE_EEP2_GPIO_STATE1] = 0x00,
2200 [ICE_EEP2_GPIO_STATE2] = 0x00,
2202 #define prodigy71xt_eeprom prodigy71lt_eeprom
2205 struct snd_ice1712_card_info snd_vt1724_aureon_cards[] __devinitdata = {
2207 .subvendor = VT1724_SUBDEVICE_AUREON51_SKY,
2208 .name = "Terratec Aureon 5.1-Sky",
2209 .model = "aureon51",
2210 .chip_init = aureon_init,
2211 .build_controls = aureon_add_controls,
2212 .eeprom_size = sizeof(aureon51_eeprom),
2213 .eeprom_data = aureon51_eeprom,
2214 .driver = "Aureon51",
2217 .subvendor = VT1724_SUBDEVICE_AUREON71_SPACE,
2218 .name = "Terratec Aureon 7.1-Space",
2219 .model = "aureon71",
2220 .chip_init = aureon_init,
2221 .build_controls = aureon_add_controls,
2222 .eeprom_size = sizeof(aureon71_eeprom),
2223 .eeprom_data = aureon71_eeprom,
2224 .driver = "Aureon71",
2227 .subvendor = VT1724_SUBDEVICE_AUREON71_UNIVERSE,
2228 .name = "Terratec Aureon 7.1-Universe",
2229 .model = "universe",
2230 .chip_init = aureon_init,
2231 .build_controls = aureon_add_controls,
2232 .eeprom_size = sizeof(aureon71_universe_eeprom),
2233 .eeprom_data = aureon71_universe_eeprom,
2234 .driver = "Aureon71Univ", /* keep in 15 letters */
2237 .subvendor = VT1724_SUBDEVICE_PRODIGY71,
2238 .name = "Audiotrak Prodigy 7.1",
2239 .model = "prodigy71",
2240 .chip_init = aureon_init,
2241 .build_controls = aureon_add_controls,
2242 .eeprom_size = sizeof(prodigy71_eeprom),
2243 .eeprom_data = prodigy71_eeprom,
2244 .driver = "Prodigy71", /* should be identical with Aureon71 */
2247 .subvendor = VT1724_SUBDEVICE_PRODIGY71LT,
2248 .name = "Audiotrak Prodigy 7.1 LT",
2249 .model = "prodigy71lt",
2250 .chip_init = aureon_init,
2251 .build_controls = aureon_add_controls,
2252 .eeprom_size = sizeof(prodigy71lt_eeprom),
2253 .eeprom_data = prodigy71lt_eeprom,
2254 .driver = "Prodigy71LT",
2257 .subvendor = VT1724_SUBDEVICE_PRODIGY71XT,
2258 .name = "Audiotrak Prodigy 7.1 XT",
2259 .model = "prodigy71xt",
2260 .chip_init = aureon_init,
2261 .build_controls = aureon_add_controls,
2262 .eeprom_size = sizeof(prodigy71xt_eeprom),
2263 .eeprom_data = prodigy71xt_eeprom,
2264 .driver = "Prodigy71LT",
2266 { } /* terminator */