2 * ALSA driver for ICEnsemble VT1724 (Envy24HT)
4 * Lowlevel functions for AudioTrak Prodigy 192 cards
5 * Supported IEC958 input from optional MI/ODI/O add-on card.
10 * * SPDIF-OUT on the card:
11 * - coax (through isolation transformer)/toslink supplied by
12 * 74HC04 gates - 3 in parallel
13 * - output switched between on-board CD drive dig-out connector
14 * and ice1724 SPDTX pin, using 74HC02 NOR gates, controlled
15 * by GPIO20 (0 = CD dig-out, 1 = SPDTX)
16 * * SPDTX goes straight to MI/ODI/O card's SPDIF-OUT coax
18 * * MI/ODI/O card: AK4114 based, used for iec958 input only
19 * - toslink input -> RX0
23 * ------------------------------
24 * CDTO (pin 32) -- GPIO11 pin 86
25 * CDTI (pin 33) -- GPIO10 pin 77
26 * CCLK (pin 34) -- GPIO9 pin 76
27 * CSN (pin 35) -- GPIO8 pin 75
28 * - output data Mode 7 (24bit, I2S, slave)
29 * - both MCKO1 and MCKO2 of ak4114 are fed to FPGA, which
30 * outputs master clock to SPMCLKIN of ice1724.
31 * Experimentally I found out that only a combination of
32 * OCKS0=1, OCKS1=1 (128fs, 64fs output) and ice1724 -
33 * VT1724_MT_I2S_MCLK_128X=0 (256fs input) yields correct
34 * sampling rate. That means the the FPGA doubles the
37 * Copyright (c) 2003 Takashi Iwai <tiwai@suse.de>
38 * Copyright (c) 2003 Dimitromanolakis Apostolos <apostol@cs.utoronto.ca>
39 * Copyright (c) 2004 Kouichi ONO <co2b@ceres.dti.ne.jp>
41 * This program is free software; you can redistribute it and/or modify
42 * it under the terms of the GNU General Public License as published by
43 * the Free Software Foundation; either version 2 of the License, or
44 * (at your option) any later version.
46 * This program is distributed in the hope that it will be useful,
47 * but WITHOUT ANY WARRANTY; without even the implied warranty of
48 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49 * GNU General Public License for more details.
51 * You should have received a copy of the GNU General Public License
52 * along with this program; if not, write to the Free Software
53 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
57 #include <sound/driver.h>
59 #include <linux/delay.h>
60 #include <linux/interrupt.h>
61 #include <linux/init.h>
62 #include <linux/slab.h>
63 #include <sound/core.h>
67 #include "prodigy192.h"
69 #include <sound/tlv.h>
71 static inline void stac9460_put(struct snd_ice1712
*ice
, int reg
, unsigned char val
)
73 snd_vt1724_write_i2c(ice
, PRODIGY192_STAC9460_ADDR
, reg
, val
);
76 static inline unsigned char stac9460_get(struct snd_ice1712
*ice
, int reg
)
78 return snd_vt1724_read_i2c(ice
, PRODIGY192_STAC9460_ADDR
, reg
);
84 static int stac9460_dac_mute_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
86 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_BOOLEAN
;
88 uinfo
->value
.integer
.min
= 0;
89 uinfo
->value
.integer
.max
= 1;
93 static int stac9460_dac_mute_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
95 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
99 if (kcontrol
->private_value
)
100 idx
= STAC946X_MASTER_VOLUME
;
102 idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
) + STAC946X_LF_VOLUME
;
103 val
= stac9460_get(ice
, idx
);
104 ucontrol
->value
.integer
.value
[0] = (~val
>> 7) & 0x1;
108 static int stac9460_dac_mute_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
110 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
111 unsigned char new, old
;
115 if (kcontrol
->private_value
)
116 idx
= STAC946X_MASTER_VOLUME
;
118 idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
) + STAC946X_LF_VOLUME
;
119 old
= stac9460_get(ice
, idx
);
120 new = (~ucontrol
->value
.integer
.value
[0]<< 7 & 0x80) | (old
& ~0x80);
121 change
= (new != old
);
123 stac9460_put(ice
, idx
, new);
129 * DAC volume attenuation mixer control
131 static int stac9460_dac_vol_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
133 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_INTEGER
;
135 uinfo
->value
.integer
.min
= 0; /* mute */
136 uinfo
->value
.integer
.max
= 0x7f; /* 0dB */
140 static int stac9460_dac_vol_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
142 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
146 if (kcontrol
->private_value
)
147 idx
= STAC946X_MASTER_VOLUME
;
149 idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
) + STAC946X_LF_VOLUME
;
150 vol
= stac9460_get(ice
, idx
) & 0x7f;
151 ucontrol
->value
.integer
.value
[0] = 0x7f - vol
;
156 static int stac9460_dac_vol_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
158 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
160 unsigned char tmp
, ovol
, nvol
;
163 if (kcontrol
->private_value
)
164 idx
= STAC946X_MASTER_VOLUME
;
166 idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
) + STAC946X_LF_VOLUME
;
167 nvol
= ucontrol
->value
.integer
.value
[0];
168 tmp
= stac9460_get(ice
, idx
);
169 ovol
= 0x7f - (tmp
& 0x7f);
170 change
= (ovol
!= nvol
);
172 stac9460_put(ice
, idx
, (0x7f - nvol
) | (tmp
& 0x80));
180 static int stac9460_adc_mute_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
182 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_BOOLEAN
;
184 uinfo
->value
.integer
.min
= 0;
185 uinfo
->value
.integer
.max
= 1;
189 static int stac9460_adc_mute_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
191 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
195 for (i
= 0; i
< 2; ++i
) {
196 val
= stac9460_get(ice
, STAC946X_MIC_L_VOLUME
+ i
);
197 ucontrol
->value
.integer
.value
[i
] = ~val
>>7 & 0x1;
203 static int stac9460_adc_mute_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
205 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
206 unsigned char new, old
;
210 for (i
= 0; i
< 2; ++i
) {
211 reg
= STAC946X_MIC_L_VOLUME
+ i
;
212 old
= stac9460_get(ice
, reg
);
213 new = (~ucontrol
->value
.integer
.value
[i
]<<7&0x80) | (old
&~0x80);
214 change
= (new != old
);
216 stac9460_put(ice
, reg
, new);
223 * ADC gain mixer control
225 static int stac9460_adc_vol_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
227 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_INTEGER
;
229 uinfo
->value
.integer
.min
= 0; /* 0dB */
230 uinfo
->value
.integer
.max
= 0x0f; /* 22.5dB */
234 static int stac9460_adc_vol_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
236 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
240 for (i
= 0; i
< 2; ++i
) {
241 reg
= STAC946X_MIC_L_VOLUME
+ i
;
242 vol
= stac9460_get(ice
, reg
) & 0x0f;
243 ucontrol
->value
.integer
.value
[i
] = 0x0f - vol
;
249 static int stac9460_adc_vol_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
251 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
253 unsigned char ovol
, nvol
;
256 for (i
= 0; i
< 2; ++i
) {
257 reg
= STAC946X_MIC_L_VOLUME
+ i
;
258 nvol
= ucontrol
->value
.integer
.value
[i
];
259 ovol
= 0x0f - stac9460_get(ice
, reg
);
260 change
= ((ovol
& 0x0f) != nvol
);
262 stac9460_put(ice
, reg
, (0x0f - nvol
) | (ovol
& ~0x0f));
270 * Headphone Amplifier
272 static int aureon_set_headphone_amp(struct snd_ice1712
*ice
, int enable
)
274 unsigned int tmp
, tmp2
;
276 tmp2
= tmp
= snd_ice1712_gpio_read(ice
);
278 tmp
|= AUREON_HP_SEL
;
280 tmp
&= ~ AUREON_HP_SEL
;
282 snd_ice1712_gpio_write(ice
, tmp
);
288 static int aureon_get_headphone_amp(struct snd_ice1712
*ice
)
290 unsigned int tmp
= snd_ice1712_gpio_read(ice
);
292 return ( tmp
& AUREON_HP_SEL
)!= 0;
295 static int aureon_bool_info(struct snd_kcontrol
*k
, struct snd_ctl_elem_info
*uinfo
)
297 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_BOOLEAN
;
299 uinfo
->value
.integer
.min
= 0;
300 uinfo
->value
.integer
.max
= 1;
304 static int aureon_hpamp_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
306 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
308 ucontrol
->value
.integer
.value
[0] = aureon_get_headphone_amp(ice
);
313 static int aureon_hpamp_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
315 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
317 return aureon_set_headphone_amp(ice
,ucontrol
->value
.integer
.value
[0]);
323 static int aureon_deemp_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
325 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
326 ucontrol
->value
.integer
.value
[0] = (wm_get(ice
, WM_DAC_CTRL2
) & 0xf) == 0xf;
330 static int aureon_deemp_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
332 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
334 temp2
= temp
= wm_get(ice
, WM_DAC_CTRL2
);
335 if (ucontrol
->value
.integer
.value
[0])
340 wm_put(ice
, WM_DAC_CTRL2
, temp
);
349 static int aureon_oversampling_info(struct snd_kcontrol
*k
, struct snd_ctl_elem_info
*uinfo
)
351 static char *texts
[2] = { "128x", "64x" };
353 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
355 uinfo
->value
.enumerated
.items
= 2;
357 if (uinfo
->value
.enumerated
.item
>= uinfo
->value
.enumerated
.items
)
358 uinfo
->value
.enumerated
.item
= uinfo
->value
.enumerated
.items
- 1;
359 strcpy(uinfo
->value
.enumerated
.name
, texts
[uinfo
->value
.enumerated
.item
]);
364 static int aureon_oversampling_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
366 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
367 ucontrol
->value
.enumerated
.item
[0] = (wm_get(ice
, WM_MASTER
) & 0x8) == 0x8;
371 static int aureon_oversampling_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
374 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
376 temp2
= temp
= wm_get(ice
, WM_MASTER
);
378 if (ucontrol
->value
.enumerated
.item
[0])
384 wm_put(ice
, WM_MASTER
, temp
);
390 static int stac9460_mic_sw_info(struct snd_kcontrol
*kcontrol
,
391 struct snd_ctl_elem_info
*uinfo
)
393 static char *texts
[2] = { "Line In", "Mic" };
395 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
397 uinfo
->value
.enumerated
.items
= 2;
399 if (uinfo
->value
.enumerated
.item
>= uinfo
->value
.enumerated
.items
)
400 uinfo
->value
.enumerated
.item
= uinfo
->value
.enumerated
.items
- 1;
401 strcpy(uinfo
->value
.enumerated
.name
, texts
[uinfo
->value
.enumerated
.item
]);
407 static int stac9460_mic_sw_get(struct snd_kcontrol
*kcontrol
,
408 struct snd_ctl_elem_value
*ucontrol
)
410 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
413 val
= stac9460_get(ice
, STAC946X_GENERAL_PURPOSE
);
414 ucontrol
->value
.enumerated
.item
[0] = (val
>> 7) & 0x1;
418 static int stac9460_mic_sw_put(struct snd_kcontrol
*kcontrol
,
419 struct snd_ctl_elem_value
*ucontrol
)
421 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
422 unsigned char new, old
;
424 old
= stac9460_get(ice
, STAC946X_GENERAL_PURPOSE
);
425 new = (ucontrol
->value
.enumerated
.item
[0] << 7 & 0x80) | (old
& ~0x80);
426 change
= (new != old
);
428 stac9460_put(ice
, STAC946X_GENERAL_PURPOSE
, new);
432 static const DECLARE_TLV_DB_SCALE(db_scale_dac
, -19125, 75, 0);
433 static const DECLARE_TLV_DB_SCALE(db_scale_adc
, 0, 150, 0);
439 static struct snd_kcontrol_new stac_controls
[] __devinitdata
= {
441 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
442 .name
= "Master Playback Switch",
443 .info
= stac9460_dac_mute_info
,
444 .get
= stac9460_dac_mute_get
,
445 .put
= stac9460_dac_mute_put
,
447 .tlv
= { .p
= db_scale_dac
}
450 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
451 .access
= (SNDRV_CTL_ELEM_ACCESS_READWRITE
|
452 SNDRV_CTL_ELEM_ACCESS_TLV_READ
),
453 .name
= "Master Playback Volume",
454 .info
= stac9460_dac_vol_info
,
455 .get
= stac9460_dac_vol_get
,
456 .put
= stac9460_dac_vol_put
,
458 .tlv
= { .p
= db_scale_dac
}
461 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
462 .name
= "DAC Switch",
464 .info
= stac9460_dac_mute_info
,
465 .get
= stac9460_dac_mute_get
,
466 .put
= stac9460_dac_mute_put
,
469 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
470 .access
= (SNDRV_CTL_ELEM_ACCESS_READWRITE
|
471 SNDRV_CTL_ELEM_ACCESS_TLV_READ
),
472 .name
= "DAC Volume",
474 .info
= stac9460_dac_vol_info
,
475 .get
= stac9460_dac_vol_get
,
476 .put
= stac9460_dac_vol_put
,
477 .tlv
= { .p
= db_scale_dac
}
480 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
481 .name
= "ADC Capture Switch",
483 .info
= stac9460_adc_mute_info
,
484 .get
= stac9460_adc_mute_get
,
485 .put
= stac9460_adc_mute_put
,
489 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
490 .access
= (SNDRV_CTL_ELEM_ACCESS_READWRITE
|
491 SNDRV_CTL_ELEM_ACCESS_TLV_READ
),
492 .name
= "ADC Capture Volume",
494 .info
= stac9460_adc_vol_info
,
495 .get
= stac9460_adc_vol_get
,
496 .put
= stac9460_adc_vol_put
,
497 .tlv
= { .p
= db_scale_adc
}
500 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
501 .name
= "Analog Capture Input",
502 .info
= stac9460_mic_sw_info
,
503 .get
= stac9460_mic_sw_get
,
504 .put
= stac9460_mic_sw_put
,
509 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
510 .name
= "Capture Route",
511 .info
= wm_adc_mux_info
,
512 .get
= wm_adc_mux_get
,
513 .put
= wm_adc_mux_put
,
516 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
517 .name
= "Headphone Amplifier Switch",
518 .info
= aureon_bool_info
,
519 .get
= aureon_hpamp_get
,
520 .put
= aureon_hpamp_put
523 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
524 .name
= "DAC Deemphasis Switch",
525 .info
= aureon_bool_info
,
526 .get
= aureon_deemp_get
,
527 .put
= aureon_deemp_put
530 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
531 .name
= "ADC Oversampling",
532 .info
= aureon_oversampling_info
,
533 .get
= aureon_oversampling_get
,
534 .put
= aureon_oversampling_put
540 /* AK4114 - ICE1724 connections on Prodigy192 + MI/ODI/O */
541 /* CDTO (pin 32) -- GPIO11 pin 86
542 * CDTI (pin 33) -- GPIO10 pin 77
543 * CCLK (pin 34) -- GPIO9 pin 76
544 * CSN (pin 35) -- GPIO8 pin 75
546 #define AK4114_ADDR 0x00 /* C1-C0: Chip Address
547 * (According to datasheet fixed to “00”)
551 * 4wire ak4114 protocol - writing data
553 static void write_data(struct snd_ice1712
*ice
, unsigned int gpio
,
554 unsigned int data
, int idx
)
556 for (; idx
>= 0; idx
--) {
558 gpio
&= ~VT1724_PRODIGY192_CCLK
;
559 snd_ice1712_gpio_write(ice
, gpio
);
562 if (data
& (1 << idx
))
563 gpio
|= VT1724_PRODIGY192_CDOUT
;
565 gpio
&= ~VT1724_PRODIGY192_CDOUT
;
566 snd_ice1712_gpio_write(ice
, gpio
);
569 gpio
|= VT1724_PRODIGY192_CCLK
;
570 snd_ice1712_gpio_write(ice
, gpio
);
576 * 4wire ak4114 protocol - reading data
578 static unsigned char read_data(struct snd_ice1712
*ice
, unsigned int gpio
,
581 unsigned char data
= 0;
583 for (; idx
>= 0; idx
--) {
585 gpio
&= ~VT1724_PRODIGY192_CCLK
;
586 snd_ice1712_gpio_write(ice
, gpio
);
589 if (snd_ice1712_gpio_read(ice
) & VT1724_PRODIGY192_CDIN
)
593 gpio
|= VT1724_PRODIGY192_CCLK
;
594 snd_ice1712_gpio_write(ice
, gpio
);
600 * 4wire ak4114 protocol - starting sequence
602 static unsigned int prodigy192_4wire_start(struct snd_ice1712
*ice
)
606 snd_ice1712_save_gpio_status(ice
);
607 tmp
= snd_ice1712_gpio_read(ice
);
609 tmp
|= VT1724_PRODIGY192_CCLK
; /* high at init */
610 tmp
&= ~VT1724_PRODIGY192_CS
; /* drop chip select */
611 snd_ice1712_gpio_write(ice
, tmp
);
617 * 4wire ak4114 protocol - final sequence
619 static void prodigy192_4wire_finish(struct snd_ice1712
*ice
, unsigned int tmp
)
621 tmp
|= VT1724_PRODIGY192_CS
; /* raise chip select */
622 snd_ice1712_gpio_write(ice
, tmp
);
624 snd_ice1712_restore_gpio_status(ice
);
628 * Write data to addr register of ak4114
630 static void prodigy192_ak4114_write(void *private_data
, unsigned char addr
,
633 struct snd_ice1712
*ice
= private_data
;
634 unsigned int tmp
, addrdata
;
635 tmp
= prodigy192_4wire_start(ice
);
636 addrdata
= (AK4114_ADDR
<< 6) | 0x20 | (addr
& 0x1f);
637 addrdata
= (addrdata
<< 8) | data
;
638 write_data(ice
, tmp
, addrdata
, 15);
639 prodigy192_4wire_finish(ice
, tmp
);
643 * Read data from addr register of ak4114
645 static unsigned char prodigy192_ak4114_read(void *private_data
,
648 struct snd_ice1712
*ice
= private_data
;
652 tmp
= prodigy192_4wire_start(ice
);
653 write_data(ice
, tmp
, (AK4114_ADDR
<< 6) | (addr
& 0x1f), 7);
654 data
= read_data(ice
, tmp
, 7);
655 prodigy192_4wire_finish(ice
, tmp
);
660 static int ak4114_input_sw_info(struct snd_kcontrol
*kcontrol
,
661 struct snd_ctl_elem_info
*uinfo
)
663 static char *texts
[2] = { "Toslink", "Coax" };
665 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
667 uinfo
->value
.enumerated
.items
= 2;
668 if (uinfo
->value
.enumerated
.item
>= uinfo
->value
.enumerated
.items
)
669 uinfo
->value
.enumerated
.item
= uinfo
->value
.enumerated
.items
- 1;
670 strcpy(uinfo
->value
.enumerated
.name
, texts
[uinfo
->value
.enumerated
.item
]);
675 static int ak4114_input_sw_get(struct snd_kcontrol
*kcontrol
,
676 struct snd_ctl_elem_value
*ucontrol
)
678 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
681 val
= prodigy192_ak4114_read(ice
, AK4114_REG_IO1
);
682 /* AK4114_IPS0 bit = 0 -> RX0 = Toslink
683 * AK4114_IPS0 bit = 1 -> RX1 = Coax
685 ucontrol
->value
.enumerated
.item
[0] = (val
& AK4114_IPS0
) ? 1 : 0;
689 static int ak4114_input_sw_put(struct snd_kcontrol
*kcontrol
,
690 struct snd_ctl_elem_value
*ucontrol
)
692 struct snd_ice1712
*ice
= snd_kcontrol_chip(kcontrol
);
693 unsigned char new, old
, itemvalue
;
696 old
= prodigy192_ak4114_read(ice
, AK4114_REG_IO1
);
697 /* AK4114_IPS0 could be any bit */
698 itemvalue
= (ucontrol
->value
.enumerated
.item
[0]) ? 0xff : 0x00;
700 new = (itemvalue
& AK4114_IPS0
) | (old
& ~AK4114_IPS0
);
701 change
= (new != old
);
703 prodigy192_ak4114_write(ice
, AK4114_REG_IO1
, new);
708 static struct snd_kcontrol_new ak4114_controls
[] __devinitdata
= {
710 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
711 .name
= "MIODIO IEC958 Capture Input",
712 .info
= ak4114_input_sw_info
,
713 .get
= ak4114_input_sw_get
,
714 .put
= ak4114_input_sw_put
,
720 static int prodigy192_ak4114_init(struct snd_ice1712
*ice
)
722 static const unsigned char ak4114_init_vals
[] = {
723 AK4114_RST
| AK4114_PWN
| AK4114_OCKS0
| AK4114_OCKS1
,
724 /* ice1724 expects I2S and provides clock,
725 * DEM0 disables the deemphasis filter
727 AK4114_DIF_I24I2S
| AK4114_DEM0
,
729 AK4114_EFH_1024
| AK4114_DIT
, /* default input RX0 */
733 static const unsigned char ak4114_init_txcsb
[] = {
734 0x41, 0x02, 0x2c, 0x00, 0x00
737 return snd_ak4114_create(ice
->card
,
738 prodigy192_ak4114_read
,
739 prodigy192_ak4114_write
,
740 ak4114_init_vals
, ak4114_init_txcsb
,
741 ice
, &ice
->spec
.prodigy192
.ak4114
);
744 static int __devinit
prodigy192_add_controls(struct snd_ice1712
*ice
)
749 for (i
= 0; i
< ARRAY_SIZE(stac_controls
); i
++) {
750 err
= snd_ctl_add(ice
->card
,
751 snd_ctl_new1(&stac_controls
[i
], ice
));
755 if (ice
->spec
.prodigy192
.ak4114
) {
756 /* ak4114 is connected */
757 for (i
= 0; i
< ARRAY_SIZE(ak4114_controls
); i
++) {
758 err
= snd_ctl_add(ice
->card
,
759 snd_ctl_new1(&ak4114_controls
[i
],
764 err
= snd_ak4114_build(ice
->spec
.prodigy192
.ak4114
,
765 NULL
, /* ak4114 in MIO/DI/O handles no IEC958 output */
766 ice
->pcm
->streams
[SNDRV_PCM_STREAM_CAPTURE
].substream
);
774 * check for presence of MI/ODI/O add-on card with digital inputs
776 static int prodigy192_miodio_exists(struct snd_ice1712
*ice
)
779 unsigned char orig_value
;
780 const unsigned char test_data
= 0xd1; /* random value */
781 unsigned char addr
= AK4114_REG_INT0_MASK
; /* random SAFE address */
784 orig_value
= prodigy192_ak4114_read(ice
, addr
);
785 prodigy192_ak4114_write(ice
, addr
, test_data
);
786 if (prodigy192_ak4114_read(ice
, addr
) == test_data
) {
787 /* ak4114 seems to communicate, apparently exists */
788 /* writing back original value */
789 prodigy192_ak4114_write(ice
, addr
, orig_value
);
796 * initialize the chip
798 static int __devinit
prodigy192_init(struct snd_ice1712
*ice
)
800 static const unsigned short stac_inits_prodigy
[] = {
802 /* STAC946X_MASTER_VOLUME, 0,
803 STAC946X_LF_VOLUME, 0,
804 STAC946X_RF_VOLUME, 0,
805 STAC946X_LR_VOLUME, 0,
806 STAC946X_RR_VOLUME, 0,
807 STAC946X_CENTER_VOLUME, 0,
808 STAC946X_LFE_VOLUME, 0,*/
811 const unsigned short *p
;
815 ice
->num_total_dacs
= 6;
816 ice
->num_total_adcs
= 2;
817 ice
->vt1720
= 0; /* ice1724, e.g. 23 GPIOs */
819 /* initialize codec */
820 p
= stac_inits_prodigy
;
821 for (; *p
!= (unsigned short)-1; p
+= 2)
822 stac9460_put(ice
, p
[0], p
[1]);
824 /* MI/ODI/O add on card with AK4114 */
825 if (prodigy192_miodio_exists(ice
)) {
826 err
= prodigy192_ak4114_init(ice
);
827 /* from this moment if err = 0 then
828 * ice->spec.prodigy192.ak4114 should not be null
830 snd_printdd("AK4114 initialized with status %d\n", err
);
832 snd_printdd("AK4114 not found\n");
841 * Aureon boards don't provide the EEPROM data except for the vendor IDs.
842 * hence the driver needs to sets up it properly.
845 static unsigned char prodigy71_eeprom
[] __devinitdata
= {
846 [ICE_EEP2_SYSCONF
] = 0x6a, /* 49MHz crystal, mpu401,
847 * spdif-in+ 1 stereo ADC,
850 [ICE_EEP2_ACLINK
] = 0x80, /* I2S */
851 [ICE_EEP2_I2S
] = 0xf8, /* vol, 96k, 24bit, 192k */
852 [ICE_EEP2_SPDIF
] = 0xc3, /* out-en, out-int, spdif-in */
853 [ICE_EEP2_GPIO_DIR
] = 0xff,
854 [ICE_EEP2_GPIO_DIR1
] = ~(VT1724_PRODIGY192_CDIN
>> 8) ,
855 [ICE_EEP2_GPIO_DIR2
] = 0xbf,
856 [ICE_EEP2_GPIO_MASK
] = 0x00,
857 [ICE_EEP2_GPIO_MASK1
] = 0x00,
858 [ICE_EEP2_GPIO_MASK2
] = 0x00,
859 [ICE_EEP2_GPIO_STATE
] = 0x00,
860 [ICE_EEP2_GPIO_STATE1
] = 0x00,
861 [ICE_EEP2_GPIO_STATE2
] = 0x10, /* GPIO20: 0 = CD drive dig. input
863 * 1 = SPDIF-OUT from ice1724
869 struct snd_ice1712_card_info snd_vt1724_prodigy192_cards
[] __devinitdata
= {
871 .subvendor
= VT1724_SUBDEVICE_PRODIGY192VE
,
872 .name
= "Audiotrak Prodigy 192",
873 .model
= "prodigy192",
874 .chip_init
= prodigy192_init
,
875 .build_controls
= prodigy192_add_controls
,
876 .eeprom_size
= sizeof(prodigy71_eeprom
),
877 .eeprom_data
= prodigy71_eeprom
,