29 #include <linux/slab.h>
60 unsigned char tmp = 0;
97 snd_ice1712_save_gpio_status(ice);
100 switch (ice->
eeprom.subvendor) {
108 snd_ice1712_gpio_write_bits(ice, mask, mask);
114 snd_ice1712_restore_gpio_status(ice);
120 unsigned char mask = 0;
133 .start = ewx_i2c_start,
134 .stop = ewx_i2c_stop,
135 .direction = ewx_i2c_direction,
136 .setlines = ewx_i2c_setlines,
137 .getclock = ewx_i2c_getclock,
138 .getdata = ewx_i2c_getdata,
147 static int snd_ice1712_ews88mt_chip_select(
struct snd_ice1712 *ice,
int chip_mask)
150 unsigned char data, ndata;
152 if (
snd_BUG_ON(chip_mask < 0 || chip_mask > 0x0f))
154 snd_i2c_lock(ice->
i2c);
157 ndata = (data & 0xf0) | chip_mask;
162 snd_i2c_unlock(ice->
i2c);
166 snd_i2c_unlock(ice->
i2c);
177 if (snd_ice1712_ews88mt_chip_select(ice, ~(1 << chip) & 0x0f) < 0)
179 snd_ice1712_save_gpio_status(ice);
184 ice->
gpio.direction | tmp);
189 static void ews88mt_ak4524_unlock(
struct snd_akm4xxx *ak,
int chip)
192 snd_ice1712_restore_gpio_status(ice);
194 snd_ice1712_ews88mt_chip_select(ice, 0x0f);
198 static void ewx2496_ak4524_lock(
struct snd_akm4xxx *ak,
int chip)
202 snd_ice1712_save_gpio_status(ice);
208 ice->
gpio.direction | tmp);
213 static void dmx6fire_ak4524_lock(
struct snd_akm4xxx *ak,
int chip)
218 snd_ice1712_save_gpio_status(ice);
224 ice->
gpio.direction | tmp);
232 static void snd_ice1712_ews_cs8404_spdif_write(
struct snd_ice1712 *ice,
unsigned char bits)
235 unsigned char bytes[2];
237 snd_i2c_lock(ice->
i2c);
238 switch (ice->
eeprom.subvendor) {
251 if (bits != bytes[1]) {
260 snd_i2c_unlock(ice->
i2c);
268 snd_cs8404_decode_spdif_bits(&ucontrol->
value.iec958, ice->
spdif.cs8403_bits);
276 val = snd_cs8404_encode_spdif_bits(&ucontrol->
value.iec958);
278 change = ice->
spdif.cs8403_bits !=
val;
282 snd_ice1712_ews_cs8404_spdif_write(ice, val);
291 snd_cs8404_decode_spdif_bits(&ucontrol->
value.iec958, ice->
spdif.cs8403_stream_bits);
299 val = snd_cs8404_encode_spdif_bits(&ucontrol->
value.iec958);
301 change = ice->
spdif.cs8403_stream_bits !=
val;
302 ice->
spdif.cs8403_stream_bits =
val;
305 snd_ice1712_ews_cs8404_spdif_write(ice, val);
316 ice->
spdif.cs8403_stream_bits = ice->
spdif.cs8403_bits;
327 tmp = ice->
spdif.cs8403_stream_bits;
329 tmp &= (tmp & 0x01) ? ~0x06 : ~0x60;
331 case 32000: tmp |= (tmp & 0x01) ? 0x02 : 0x00;
break;
332 case 44100: tmp |= (tmp & 0x01) ? 0x06 : 0x40;
break;
333 case 48000: tmp |= (tmp & 0x01) ? 0x04 : 0x20;
break;
334 default: tmp |= (tmp & 0x01) ? 0x06 : 0x40;
break;
336 change = ice->
spdif.cs8403_stream_bits !=
tmp;
337 ice->
spdif.cs8403_stream_bits =
tmp;
338 spin_unlock_irqrestore(&ice->
reg_lock, flags);
341 snd_ice1712_ews_cs8404_spdif_write(ice, tmp);
352 .lock = ews88mt_ak4524_lock,
353 .unlock = ews88mt_ak4524_unlock
369 static struct snd_akm4xxx akm_ewx2496 __devinitdata = {
374 .lock = ewx2496_ak4524_lock
390 static struct snd_akm4xxx akm_6fire __devinitdata = {
395 .lock = dmx6fire_ak4524_lock
416 #define PCF9554_REG_INPUT 0
417 #define PCF9554_REG_OUTPUT 1
418 #define PCF9554_REG_POLARITY 2
419 #define PCF9554_REG_CONFIG 3
421 static int snd_ice1712_6fire_write_pca(
struct snd_ice1712 *ice,
unsigned char reg,
unsigned char data);
430 switch (ice->
eeprom.subvendor) {
463 ice->
i2c->private_data = ice;
464 ice->
i2c->hw_ops.bit = &snd_ice1712_ewx_cs8427_bit_ops;
467 switch (ice->
eeprom.subvendor) {
499 if ((err = snd_ice1712_ews88mt_chip_select(ice, 0x0f)) < 0)
512 switch (ice->
eeprom.subvendor) {
529 ice->
spdif.ops.open = ews88_open_spdif;
530 ice->
spdif.ops.setup_rate = ews88_setup_spdif;
531 ice->
spdif.ops.default_get = ews88_spdif_default_get;
532 ice->
spdif.ops.default_put = ews88_spdif_default_put;
533 ice->
spdif.ops.stream_get = ews88_spdif_stream_get;
534 ice->
spdif.ops.stream_put = ews88_spdif_stream_put;
536 snd_ice1712_ews_cs8404_spdif_write(ice, ice->
spdif.cs8403_bits);
541 switch (ice->
eeprom.subvendor) {
552 switch (ice->
eeprom.subvendor) {
579 static char *texts[2] = {
596 snd_ice1712_save_gpio_status(ice);
598 snd_ice1712_restore_gpio_status(ice);
610 nval = ucontrol->
value.enumerated.item[0] ? mask : 0;
611 snd_ice1712_save_gpio_status(ice);
615 snd_ice1712_restore_gpio_status(ice);
619 static struct snd_kcontrol_new snd_ice1712_ewx2496_controls[] __devinitdata = {
622 .name =
"Input Sensitivity Switch",
623 .info = snd_ice1712_ewx_io_sense_info,
624 .get = snd_ice1712_ewx_io_sense_get,
625 .put = snd_ice1712_ewx_io_sense_put,
630 .name =
"Output Sensitivity Switch",
631 .info = snd_ice1712_ewx_io_sense_info,
632 .get = snd_ice1712_ewx_io_sense_get,
633 .put = snd_ice1712_ewx_io_sense_put,
649 snd_i2c_lock(ice->
i2c);
651 snd_i2c_unlock(ice->
i2c);
654 snd_i2c_unlock(ice->
i2c);
664 unsigned char data, ndata;
666 snd_i2c_lock(ice->
i2c);
668 snd_i2c_unlock(ice->
i2c);
674 snd_i2c_unlock(ice->
i2c);
677 snd_i2c_unlock(ice->
i2c);
678 return ndata !=
data;
686 int channel = snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id);
691 snd_i2c_lock(ice->
i2c);
693 snd_i2c_unlock(ice->
i2c);
697 ucontrol->
value.enumerated.item[0] = data & (1 <<
channel) ? 0 : 1;
698 snd_i2c_unlock(ice->
i2c);
707 int channel = snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id);
708 unsigned char data, ndata;
712 snd_i2c_lock(ice->
i2c);
714 snd_i2c_unlock(ice->
i2c);
717 ndata = (data & ~(1 <<
channel)) | (ucontrol->
value.enumerated.item[0] ? 0 : (1 <<
channel));
720 snd_i2c_unlock(ice->
i2c);
723 snd_i2c_unlock(ice->
i2c);
724 return ndata !=
data;
727 static struct snd_kcontrol_new snd_ice1712_ews88mt_input_sense __devinitdata = {
729 .name =
"Input Sensitivity Switch",
730 .info = snd_ice1712_ewx_io_sense_info,
731 .get = snd_ice1712_ews88mt_input_sense_get,
732 .put = snd_ice1712_ews88mt_input_sense_put,
736 static struct snd_kcontrol_new snd_ice1712_ews88mt_output_sense __devinitdata = {
738 .name =
"Output Sensitivity Switch",
739 .info = snd_ice1712_ewx_io_sense_info,
740 .get = snd_ice1712_ews88mt_output_sense_get,
741 .put = snd_ice1712_ews88mt_output_sense_put,
749 #define snd_ice1712_ews88d_control_info snd_ctl_boolean_mono_info
757 unsigned char data[2];
759 snd_i2c_lock(ice->
i2c);
761 snd_i2c_unlock(ice->
i2c);
764 snd_i2c_unlock(ice->
i2c);
765 data[0] = (data[shift >> 3] >> (shift & 7)) & 0x01;
768 ucontrol->
value.integer.value[0] = data[0];
778 unsigned char data[2], ndata[2];
781 snd_i2c_lock(ice->
i2c);
783 snd_i2c_unlock(ice->
i2c);
786 ndata[shift >> 3] = data[shift >> 3] & ~(1 << (shift & 7));
788 if (! ucontrol->
value.integer.value[0])
789 ndata[shift >> 3] |= (1 << (shift & 7));
791 if (ucontrol->
value.integer.value[0])
792 ndata[shift >> 3] |= (1 << (shift & 7));
794 change = (data[shift >> 3] != ndata[shift >> 3]);
797 snd_i2c_unlock(ice->
i2c);
800 snd_i2c_unlock(ice->
i2c);
804 #define EWS88D_CONTROL(xiface, xname, xshift, xinvert, xaccess) \
808 .info = snd_ice1712_ews88d_control_info,\
809 .get = snd_ice1712_ews88d_control_get,\
810 .put = snd_ice1712_ews88d_control_put,\
811 .private_value = xshift | (xinvert << 8),\
814 static struct snd_kcontrol_new snd_ice1712_ews88d_controls[] __devinitdata = {
827 static int snd_ice1712_6fire_read_pca(
struct snd_ice1712 *ice,
unsigned char reg)
832 snd_i2c_lock(ice->
i2c);
837 snd_i2c_unlock(ice->
i2c);
841 snd_i2c_unlock(ice->
i2c);
845 static int snd_ice1712_6fire_write_pca(
struct snd_ice1712 *ice,
unsigned char reg,
unsigned char data)
847 unsigned char bytes[2];
850 snd_i2c_lock(ice->
i2c);
854 snd_i2c_unlock(ice->
i2c);
857 snd_i2c_unlock(ice->
i2c);
861 #define snd_ice1712_6fire_control_info snd_ctl_boolean_mono_info
872 data = (data >> shift) & 1;
888 ndata = data & ~(1 << shift);
889 if (ucontrol->
value.integer.value[0])
890 ndata |= (1 << shift);
892 ndata ^= (1 << shift);
902 static char *texts[4] = {
903 "Internal",
"Front Input",
"Rear Input",
"Wave Table"
921 ucontrol->
value.integer.value[0] = data & 3;
933 ndata |= (ucontrol->
value.integer.value[0] & 3);
942 #define DMX6FIRE_CONTROL(xname, xshift, xinvert) \
943 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER,\
945 .info = snd_ice1712_6fire_control_info,\
946 .get = snd_ice1712_6fire_control_get,\
947 .put = snd_ice1712_6fire_control_put,\
948 .private_value = xshift | (xinvert << 8),\
951 static struct snd_kcontrol_new snd_ice1712_6fire_controls[] __devinitdata = {
954 .name =
"Analog Input Select",
955 .info = snd_ice1712_6fire_select_input_info,
956 .get = snd_ice1712_6fire_select_input_get,
957 .put = snd_ice1712_6fire_select_input_put,
980 switch (ice->
eeprom.subvendor) {
994 switch (ice->
eeprom.subvendor) {
996 for (idx = 0; idx <
ARRAY_SIZE(snd_ice1712_ewx2496_controls); idx++) {
1014 for (idx = 0; idx <
ARRAY_SIZE(snd_ice1712_ews88d_controls); idx++) {
1021 for (idx = 0; idx <
ARRAY_SIZE(snd_ice1712_6fire_controls); idx++) {
1036 .name =
"TerraTec EWX24/96",
1038 .chip_init = snd_ice1712_ews_init,
1039 .build_controls = snd_ice1712_ews_add_controls,
1043 .name =
"TerraTec EWS88MT",
1045 .chip_init = snd_ice1712_ews_init,
1046 .build_controls = snd_ice1712_ews_add_controls,
1050 .name =
"TerraTec EWS88MT",
1051 .model =
"ews88mt_new",
1052 .chip_init = snd_ice1712_ews_init,
1053 .build_controls = snd_ice1712_ews_add_controls,
1057 .name =
"TerraTec Phase88",
1059 .chip_init = snd_ice1712_ews_init,
1060 .build_controls = snd_ice1712_ews_add_controls,
1064 .name =
"terrasoniq TS88",
1066 .chip_init = snd_ice1712_ews_init,
1067 .build_controls = snd_ice1712_ews_add_controls,
1071 .name =
"TerraTec EWS88D",
1073 .chip_init = snd_ice1712_ews_init,
1074 .build_controls = snd_ice1712_ews_add_controls,
1078 .name =
"TerraTec DMX6Fire",
1079 .model =
"dmx6fire",
1080 .chip_init = snd_ice1712_ews_init,
1081 .build_controls = snd_ice1712_ews_add_controls,
1082 .mpu401_1_name =
"MIDI-Front DMX6fire",
1083 .mpu401_2_name =
"Wavetable DMX6fire",