29 #include <linux/slab.h>
48 static void ap_cs8427_write_byte(
struct snd_ice1712 *ice,
unsigned char data,
unsigned char tmp)
52 for (idx = 7; idx >= 0; idx--) {
54 if (data & (1 << idx))
65 static unsigned char ap_cs8427_read_byte(
struct snd_ice1712 *ice,
unsigned char tmp)
67 unsigned char data = 0;
70 for (idx = 7; idx >= 0; idx--) {
84 static unsigned char ap_cs8427_codec_select(
struct snd_ice1712 *ice)
88 switch (ice->
eeprom.subvendor) {
115 static void ap_cs8427_codec_deassert(
struct snd_ice1712 *ice,
unsigned char tmp)
117 switch (ice->
eeprom.subvendor) {
145 tmp = ap_cs8427_codec_select(ice);
146 ap_cs8427_write_byte(ice, (device->
addr << 1) | 0, tmp);
148 ap_cs8427_write_byte(ice, *bytes++, tmp);
149 ap_cs8427_codec_deassert(ice, tmp);
155 static int ap_cs8427_readbytes(
struct snd_i2c_device *device,
unsigned char *bytes,
int count)
162 tmp = ap_cs8427_codec_select(ice);
163 ap_cs8427_write_byte(ice, (device->
addr << 1) | 1, tmp);
165 *bytes++ = ap_cs8427_read_byte(ice, tmp);
166 ap_cs8427_codec_deassert(ice, tmp);
179 .sendbytes = ap_cs8427_sendbytes,
180 .readbytes = ap_cs8427_readbytes,
181 .probeaddr = ap_cs8427_probeaddr,
187 static void snd_ice1712_delta_cs8403_spdif_write(
struct snd_ice1712 *ice,
unsigned char bits)
189 unsigned char tmp, mask1, mask2;
196 for (idx = 7; idx >= 0; idx--) {
197 tmp &= ~(mask1 | mask2);
198 if (bits & (1 << idx))
214 snd_cs8403_decode_spdif_bits(&ucontrol->
value.iec958, ice->
spdif.cs8403_bits);
222 val = snd_cs8403_encode_spdif_bits(&ucontrol->
value.iec958);
224 change = ice->
spdif.cs8403_bits !=
val;
228 snd_ice1712_delta_cs8403_spdif_write(ice, val);
237 snd_cs8403_decode_spdif_bits(&ucontrol->
value.iec958, ice->
spdif.cs8403_stream_bits);
245 val = snd_cs8403_encode_spdif_bits(&ucontrol->
value.iec958);
247 change = ice->
spdif.cs8403_stream_bits !=
val;
248 ice->
spdif.cs8403_stream_bits =
val;
251 snd_ice1712_delta_cs8403_spdif_write(ice, val);
267 snd_ice1712_save_gpio_status(ice);
276 static void delta1010lt_ak4524_lock(
struct snd_akm4xxx *ak,
int chip)
281 snd_ice1712_save_gpio_status(ice);
289 static void delta66e_ak4524_lock(
struct snd_akm4xxx *ak,
int chip)
294 snd_ice1712_save_gpio_status(ice);
303 static void vx442_ak4524_lock(
struct snd_akm4xxx *ak,
int chip)
308 snd_ice1712_save_gpio_status(ice);
317 static void delta_1010_set_rate_val(
struct snd_ice1712 *ice,
unsigned int rate)
319 unsigned char tmp, tmp2;
337 static void delta_ak4524_set_rate_val(
struct snd_akm4xxx *ak,
unsigned int rate)
339 unsigned char tmp, tmp2;
369 static void vx442_ak4524_set_rate_val(
struct snd_akm4xxx *ak,
unsigned int rate)
373 val = (rate > 48000) ? 0x65 : 0x60;
391 ice->
spdif.cs8403_stream_bits = ice->
spdif.cs8403_bits;
395 static void delta_setup_spdif(
struct snd_ice1712 *ice,
int rate)
402 tmp = ice->
spdif.cs8403_stream_bits;
404 tmp &= (tmp & 0x01) ? ~0x06 : ~0x18;
406 case 32000: tmp |= (tmp & 0x01) ? 0x04 : 0x00;
break;
407 case 44100: tmp |= (tmp & 0x01) ? 0x00 : 0x10;
break;
408 case 48000: tmp |= (tmp & 0x01) ? 0x02 : 0x08;
break;
409 default: tmp |= (tmp & 0x01) ? 0x00 : 0x18;
break;
411 change = ice->
spdif.cs8403_stream_bits !=
tmp;
412 ice->
spdif.cs8403_stream_bits =
tmp;
413 spin_unlock_irqrestore(&ice->
reg_lock, flags);
416 snd_ice1712_delta_cs8403_spdif_write(ice, tmp);
419 #define snd_ice1712_delta1010lt_wordclock_status_info \
420 snd_ctl_boolean_mono_info
422 static int snd_ice1712_delta1010lt_wordclock_status_get(
struct snd_kcontrol *kcontrol,
439 .
name =
"Word Clock Status",
441 .
get = snd_ice1712_delta1010lt_wordclock_status_get,
448 static struct snd_akm4xxx akm_audiophile __devinitdata = {
453 .set_rate_val = delta_ak4524_set_rate_val
469 static struct snd_akm4xxx akm_delta410 __devinitdata = {
474 .set_rate_val = delta_ak4524_set_rate_val
490 static struct snd_akm4xxx akm_delta1010lt __devinitdata = {
495 .lock = delta1010lt_ak4524_lock,
496 .set_rate_val = delta_ak4524_set_rate_val
512 static struct snd_akm4xxx akm_delta66e __devinitdata = {
517 .lock = delta66e_ak4524_lock,
518 .set_rate_val = delta_ak4524_set_rate_val
535 static struct snd_akm4xxx akm_delta44 __devinitdata = {
540 .lock = delta_ak4524_lock,
541 .set_rate_val = delta_ak4524_set_rate_val
557 static struct snd_akm4xxx akm_vx442 __devinitdata = {
562 .lock = vx442_ak4524_lock,
563 .set_rate_val = vx442_ak4524_set_rate_val
586 ice->
eeprom.gpiodir == 0x7b)
590 ice->
eeprom.gpiodir == 0xfb)
594 switch (ice->
eeprom.subvendor) {
633 switch (ice->
eeprom.subvendor) {
644 ice->
i2c->private_data = ice;
645 ice->
i2c->ops = &ap_cs8427_i2c_ops;
651 ice->
gpio.set_pro_rate = delta_1010_set_rate_val;
654 ice->
gpio.set_pro_rate = delta_1010_set_rate_val;
657 ice->
spdif.ops.open = delta_open_spdif;
658 ice->
spdif.ops.setup_rate = delta_setup_spdif;
659 ice->
spdif.ops.default_get = delta_spdif_default_get;
660 ice->
spdif.ops.default_put = delta_spdif_default_put;
661 ice->
spdif.ops.stream_get = delta_spdif_stream_get;
662 ice->
spdif.ops.stream_put = delta_spdif_stream_put;
664 snd_ice1712_delta_cs8403_spdif_write(ice, ice->
spdif.cs8403_bits);
669 switch (ice->
eeprom.subvendor) {
683 switch (ice->
eeprom.subvendor) {
717 static struct snd_kcontrol_new snd_ice1712_delta1010_wordclock_select __devinitdata =
719 static struct snd_kcontrol_new snd_ice1712_delta1010lt_wordclock_select __devinitdata =
721 static struct snd_kcontrol_new snd_ice1712_delta1010_wordclock_status __devinitdata =
723 static struct snd_kcontrol_new snd_ice1712_deltadio2496_spdif_in_select __devinitdata =
725 static struct snd_kcontrol_new snd_ice1712_delta_spdif_in_status __devinitdata =
734 switch (ice->
eeprom.subvendor) {
761 switch (ice->
eeprom.subvendor) {
773 switch (ice->
eeprom.subvendor) {
785 switch (ice->
eeprom.subvendor) {
808 .name =
"M Audio Delta 1010",
809 .model =
"delta1010",
810 .chip_init = snd_ice1712_delta_init,
811 .build_controls = snd_ice1712_delta_add_controls,
815 .name =
"M Audio Delta DiO 2496",
817 .chip_init = snd_ice1712_delta_init,
818 .build_controls = snd_ice1712_delta_add_controls,
823 .name =
"M Audio Delta 66",
825 .chip_init = snd_ice1712_delta_init,
826 .build_controls = snd_ice1712_delta_add_controls,
831 .name =
"M Audio Delta 44",
833 .chip_init = snd_ice1712_delta_init,
834 .build_controls = snd_ice1712_delta_add_controls,
839 .name =
"M Audio Audiophile 24/96",
840 .model =
"audiophile",
841 .chip_init = snd_ice1712_delta_init,
842 .build_controls = snd_ice1712_delta_add_controls,
846 .name =
"M Audio Delta 410",
848 .chip_init = snd_ice1712_delta_init,
849 .build_controls = snd_ice1712_delta_add_controls,
853 .name =
"M Audio Delta 1010LT",
854 .model =
"delta1010lt",
855 .chip_init = snd_ice1712_delta_init,
856 .build_controls = snd_ice1712_delta_add_controls,
860 .name =
"Digigram VX442",
862 .chip_init = snd_ice1712_delta_init,
863 .build_controls = snd_ice1712_delta_add_controls,
868 .name =
"Lionstracs Mediastation",
869 .model =
"mediastation",
870 .chip_init = snd_ice1712_delta_init,
871 .build_controls = snd_ice1712_delta_add_controls,
875 .name =
"Edirol DA2496",
877 .chip_init = snd_ice1712_delta_init,
878 .build_controls = snd_ice1712_delta_add_controls,