29 #include <linux/pci.h>
30 #include <linux/slab.h>
31 #include <linux/module.h>
77 "{ICEnsemble,Generic ICE1724},"
78 "{ICEnsemble,Generic Envy24HT}"
79 "{ICEnsemble,Generic Envy24PT}}");
105 static int PRO_RATE_LOCKED;
106 static int PRO_RATE_RESET = 1;
107 static unsigned int PRO_RATE_DEFAULT = 44100;
120 static inline int stdclock_is_spdif_master(
struct snd_ice1712 *ice)
128 static inline int is_pro_rate_locked(
struct snd_ice1712 *ice)
137 static unsigned char snd_vt1724_ac97_ready(
struct snd_ice1712 *ice)
139 unsigned char old_cmd;
141 for (tm = 0; tm < 0x10000; tm++) {
153 static int snd_vt1724_ac97_wait_bit(
struct snd_ice1712 *ice,
unsigned char bit)
156 for (tm = 0; tm < 0x10000; tm++)
163 static void snd_vt1724_ac97_write(
struct snd_ac97 *
ac97,
168 unsigned char old_cmd;
170 old_cmd = snd_vt1724_ac97_ready(ice);
172 old_cmd |= ac97->
num;
179 static unsigned short snd_vt1724_ac97_read(
struct snd_ac97 *ac97,
unsigned short reg)
182 unsigned char old_cmd;
184 old_cmd = snd_vt1724_ac97_ready(ice);
186 old_cmd |= ac97->
num;
200 static void snd_vt1724_set_gpio_dir(
struct snd_ice1712 *ice,
unsigned int data)
207 static unsigned int snd_vt1724_get_gpio_dir(
struct snd_ice1712 *ice)
213 static void snd_vt1724_set_gpio_mask(
struct snd_ice1712 *ice,
unsigned int data)
221 static unsigned int snd_vt1724_get_gpio_mask(
struct snd_ice1712 *ice)
232 static void snd_vt1724_set_gpio_data(
struct snd_ice1712 *ice,
unsigned int data)
240 static unsigned int snd_vt1724_get_gpio_data(
struct snd_ice1712 *ice)
255 static void vt1724_midi_clear_rx(
struct snd_ice1712 *ice)
272 static void vt1724_midi_write(
struct snd_ice1712 *ice)
282 for (i = 0; i <
count; ++
i)
292 static void vt1724_midi_read(
struct snd_ice1712 *ice)
301 count =
min(count, 32);
302 for (i = 0; i <
count; ++
i)
325 enable_midi_irq(ice, flag, enable);
347 vt1724_midi_write(ice);
352 spin_unlock_irqrestore(&ice->
reg_lock, flags);
371 .open = vt1724_midi_output_open,
372 .close = vt1724_midi_output_close,
373 .trigger = vt1724_midi_output_trigger,
374 .drain = vt1724_midi_output_drain,
379 vt1724_midi_clear_rx(s->
rmidi->private_data);
398 vt1724_midi_read(ice);
402 spin_unlock_irqrestore(&ice->
reg_lock, flags);
406 .open = vt1724_midi_input_open,
407 .close = vt1724_midi_input_close,
408 .trigger = vt1724_midi_input_trigger,
420 unsigned char status_mask =
427 status &= status_mask;
431 if (++timeout > 10) {
434 "status = 0x%x\n", status);
437 enable_midi_irq(ice, VT1724_IRQ_MPU_TX, 0);
445 vt1724_midi_write(ice);
447 enable_midi_irq(ice, VT1724_IRQ_MPU_TX, 0);
453 status_mask &= ~VT1724_IRQ_MPU_TX;
457 vt1724_midi_read(ice);
459 vt1724_midi_clear_rx(ice);
509 unsigned char fstat =
inb(
ICEMT1724(ice, DMA_FIFO_ERR));
524 static unsigned int rates[] = {
525 8000, 9600, 11025, 12000, 16000, 22050, 24000,
526 32000, 44100, 48000, 64000, 88200, 96000,
566 reg = s->
runtime->private_data;
568 snd_pcm_trigger_done(s, substream);
611 #define DMA_STARTS (VT1724_RDMA0_START|VT1724_PDMA0_START|VT1724_RDMA1_START|\
612 VT1724_PDMA1_START|VT1724_PDMA2_START|VT1724_PDMA3_START|VT1724_PDMA4_START)
613 #define DMA_PAUSES (VT1724_RDMA0_PAUSE|VT1724_PDMA0_PAUSE|VT1724_RDMA1_PAUSE|\
614 VT1724_PDMA1_PAUSE|VT1724_PDMA2_PAUSE|VT1724_PDMA3_PAUSE|VT1724_PDMA4_PAUSE)
616 static const unsigned int stdclock_rate_list[16] = {
617 48000, 24000, 12000, 9600, 32000, 16000, 8000, 96000, 44100,
618 22050, 11025, 88200, 176400, 0, 192000, 64000
621 static unsigned int stdclock_get_rate(
struct snd_ice1712 *ice)
628 static void stdclock_set_rate(
struct snd_ice1712 *ice,
unsigned int rate)
631 for (i = 0; i <
ARRAY_SIZE(stdclock_rate_list); i++) {
632 if (stdclock_rate_list[i] == rate) {
639 static unsigned char stdclock_set_mclk(
struct snd_ice1712 *ice,
642 unsigned char val, old;
660 static int snd_vt1724_set_pro_rate(
struct snd_ice1712 *ice,
unsigned int rate,
664 unsigned char mclk_change;
665 unsigned int i, old_rate;
674 spin_unlock_irqrestore(&ice->
reg_lock, flags);
677 if (!force && is_pro_rate_locked(ice)) {
680 spin_unlock_irqrestore(&ice->
reg_lock, flags);
688 if (force || (old_rate != rate))
691 spin_unlock_irqrestore(&ice->
reg_lock, flags);
699 mclk_change = ice->
set_mclk(ice, rate);
701 spin_unlock_irqrestore(&ice->
reg_lock, flags);
703 if (mclk_change && ice->
gpio.i2s_mclk_changed)
704 ice->
gpio.i2s_mclk_changed(ice);
705 if (ice->
gpio.set_pro_rate)
706 ice->
gpio.set_pro_rate(ice, rate);
710 if (ice->
akm[i].ops.set_rate_val)
711 ice->
akm[
i].ops.set_rate_val(&ice->
akm[i], rate);
713 if (ice->
spdif.ops.setup_rate)
714 ice->
spdif.ops.setup_rate(ice, rate);
731 for (i = 0; i < chs; i++) {
744 for (i = 0; i < 3; i++) {
759 err = snd_vt1724_set_pro_rate(ice,
params_rate(hw_params), 0);
773 for (i = 0; i < 3; i++)
787 val = (8 - substream->
runtime->channels) >> 1;
792 size = (snd_pcm_lib_buffer_bytes(substream) >> 2) - 1;
796 size = (snd_pcm_lib_period_bytes(substream) >> 2) - 1;
823 if (ptr < substream->runtime->dma_addr) {
824 snd_printd(
"ice1724: invalid negative ptr\n");
827 ptr -= substream->
runtime->dma_addr;
828 ptr = bytes_to_frames(substream->
runtime, ptr);
829 if (ptr >= substream->
runtime->buffer_size) {
830 snd_printd(
"ice1724: invalid ptr %d (size=%d)\n",
831 (
int)ptr, (
int)substream->
runtime->period_size);
836 ptr = (ptr + 1) << 2;
837 ptr = bytes_to_frames(substream->
runtime, ptr);
840 else if (ptr <= substream->runtime->buffer_size)
843 snd_printd(
"ice1724: invalid ptr %d (size=%d)\n",
844 (
int)ptr, (
int)substream->
runtime->buffer_size);
858 outw((snd_pcm_lib_buffer_bytes(substream) >> 2) - 1,
860 outw((snd_pcm_lib_period_bytes(substream) >> 2) - 1,
876 ptr -= substream->
runtime->dma_addr;
877 return bytes_to_frames(substream->
runtime, ptr);
880 ptr = (ptr + 1) << 2;
881 ptr = bytes_to_frames(substream->
runtime, ptr);
884 else if (ptr <= substream->runtime->buffer_size)
887 snd_printd(
"ice1724: invalid ptr %d (size=%d)\n",
888 (
int)ptr, (
int)substream->
runtime->buffer_size);
923 #define vt1724_playback_pro_reg vt1724_pdma0_reg
924 #define vt1724_playback_spdif_reg vt1724_pdma4_reg
925 #define vt1724_capture_pro_reg vt1724_rdma0_reg
926 #define vt1724_capture_spdif_reg vt1724_rdma1_reg
940 .period_bytes_min = 8 * 4 * 2,
941 .period_bytes_max = (1
UL << 21),
960 .buffer_bytes_max = (1
UL << 18),
979 .period_bytes_min = 2 * 4 * 2,
980 .period_bytes_max = (1
UL << 18),
988 static void set_std_hw_rates(
struct snd_ice1712 *ice)
994 ice->
hw_rates = &hw_constraints_rates_192;
996 ice->
hw_rates = &hw_constraints_rates_96;
999 ice->
hw_rates = &hw_constraints_rates_48;
1003 static int set_rate_constraints(
struct snd_ice1712 *ice,
1008 runtime->
hw.rate_min = ice->
hw_rates->list[0];
1024 if (is_pro_rate_locked(ice)) {
1026 if (rate >= runtime->
hw.rate_min
1027 && rate <= runtime->
hw.rate_max) {
1028 runtime->
hw.rate_min =
rate;
1029 runtime->
hw.rate_max =
rate;
1038 #define VT1724_BUFFER_ALIGN 0x20
1044 int chs, num_indeps;
1048 runtime->
hw = snd_vt1724_playback_pro;
1051 set_rate_constraints(ice, substream);
1055 for (chs = 0; chs < num_indeps; chs++) {
1059 chs = (chs + 1) * 2;
1060 runtime->
hw.channels_max = chs;
1068 constrain_rate_if_locked(substream);
1081 runtime->
hw = snd_vt1724_2ch_stereo;
1084 set_rate_constraints(ice, substream);
1089 constrain_rate_if_locked(substream);
1116 static struct snd_pcm_ops snd_vt1724_playback_pro_ops = {
1117 .open = snd_vt1724_playback_pro_open,
1118 .close = snd_vt1724_playback_pro_close,
1120 .hw_params = snd_vt1724_pcm_hw_params,
1121 .hw_free = snd_vt1724_pcm_hw_free,
1122 .prepare = snd_vt1724_playback_pro_prepare,
1123 .trigger = snd_vt1724_pcm_trigger,
1124 .pointer = snd_vt1724_playback_pro_pointer,
1127 static struct snd_pcm_ops snd_vt1724_capture_pro_ops = {
1128 .open = snd_vt1724_capture_pro_open,
1129 .close = snd_vt1724_capture_pro_close,
1131 .hw_params = snd_vt1724_pcm_hw_params,
1132 .hw_free = snd_vt1724_pcm_hw_free,
1133 .prepare = snd_vt1724_pcm_prepare,
1134 .trigger = snd_vt1724_pcm_trigger,
1135 .pointer = snd_vt1724_pcm_pointer,
1155 &snd_vt1724_capture_pro_ops);
1163 256*1024, 256*1024);
1176 static void update_spdif_bits(
struct snd_ice1712 *ice,
unsigned int val)
1178 unsigned char cbit, disabled;
1182 if (cbit != disabled)
1185 if (cbit != disabled)
1191 static void update_spdif_rate(
struct snd_ice1712 *ice,
unsigned int rate)
1193 unsigned int val, nval;
1194 unsigned long flags;
1201 case 48000: nval |= 2 << 12;
break;
1202 case 32000: nval |= 3 << 12;
break;
1203 case 88200: nval |= 4 << 12;
break;
1204 case 96000: nval |= 5 << 12;
break;
1205 case 192000: nval |= 6 << 12;
break;
1206 case 176400: nval |= 7 << 12;
break;
1209 update_spdif_bits(ice, nval);
1210 spin_unlock_irqrestore(&ice->
reg_lock, flags);
1213 static int snd_vt1724_playback_spdif_prepare(
struct snd_pcm_substream *substream)
1217 update_spdif_rate(ice, substream->
runtime->rate);
1218 return snd_vt1724_pcm_prepare(substream);
1229 runtime->
hw = snd_vt1724_2ch_stereo;
1230 set_rate_constraints(ice, substream);
1232 runtime->
hw = snd_vt1724_spdif;
1239 constrain_rate_if_locked(substream);
1240 if (ice->
spdif.ops.open)
1241 ice->
spdif.ops.open(ice, substream);
1252 if (ice->
spdif.ops.close)
1253 ice->
spdif.ops.close(ice, substream);
1266 runtime->
hw = snd_vt1724_2ch_stereo;
1267 set_rate_constraints(ice, substream);
1269 runtime->
hw = snd_vt1724_spdif;
1276 constrain_rate_if_locked(substream);
1277 if (ice->
spdif.ops.open)
1278 ice->
spdif.ops.open(ice, substream);
1289 if (ice->
spdif.ops.close)
1290 ice->
spdif.ops.close(ice, substream);
1295 static struct snd_pcm_ops snd_vt1724_playback_spdif_ops = {
1296 .open = snd_vt1724_playback_spdif_open,
1297 .close = snd_vt1724_playback_spdif_close,
1299 .hw_params = snd_vt1724_pcm_hw_params,
1300 .hw_free = snd_vt1724_pcm_hw_free,
1301 .prepare = snd_vt1724_playback_spdif_prepare,
1302 .trigger = snd_vt1724_pcm_trigger,
1303 .pointer = snd_vt1724_pcm_pointer,
1306 static struct snd_pcm_ops snd_vt1724_capture_spdif_ops = {
1307 .open = snd_vt1724_capture_spdif_open,
1308 .close = snd_vt1724_capture_spdif_close,
1310 .hw_params = snd_vt1724_pcm_hw_params,
1311 .hw_free = snd_vt1724_pcm_hw_free,
1312 .prepare = snd_vt1724_pcm_prepare,
1313 .trigger = snd_vt1724_pcm_trigger,
1314 .pointer = snd_vt1724_pcm_pointer,
1341 name =
"ICE1724 Secondary";
1343 name =
"ICE1724 IEC958";
1350 &snd_vt1724_playback_spdif_ops);
1353 &snd_vt1724_capture_spdif_ops);
1361 256*1024, 256*1024);
1373 static const struct vt1724_pcm_reg vt1724_playback_dma_regs[3] = {
1394 static int snd_vt1724_playback_indep_prepare(
struct snd_pcm_substream *substream)
1400 val = 3 - substream->
number;
1404 return snd_vt1724_pcm_prepare(substream);
1421 runtime->
hw = snd_vt1724_2ch_stereo;
1424 set_rate_constraints(ice, substream);
1440 static struct snd_pcm_ops snd_vt1724_playback_indep_ops = {
1441 .open = snd_vt1724_playback_indep_open,
1442 .close = snd_vt1724_playback_indep_close,
1444 .hw_params = snd_vt1724_pcm_hw_params,
1445 .hw_free = snd_vt1724_pcm_hw_free,
1446 .prepare = snd_vt1724_playback_indep_prepare,
1447 .trigger = snd_vt1724_pcm_trigger,
1448 .pointer = snd_vt1724_pcm_pointer,
1462 err =
snd_pcm_new(ice->
card,
"ICE1724 Surrounds", device, play, 0, &pcm);
1467 &snd_vt1724_playback_indep_ops);
1475 256*1024, 256*1024);
1495 .write = snd_vt1724_ac97_write,
1496 .read = snd_vt1724_ac97_read,
1507 memset(&ac97, 0,
sizeof(ac97));
1516 strcat(ice->
card->mixername,
"ICE1724 - multitrack");
1524 static inline unsigned int eeprom_triple(
struct snd_ice1712 *ice,
int idx)
1526 return (
unsigned int)ice->
eeprom.data[
idx] | \
1527 ((
unsigned int)ice->
eeprom.data[idx + 1] << 8) | \
1528 ((
unsigned int)ice->
eeprom.data[idx + 2] << 16);
1537 snd_iprintf(buffer,
"%s\n\n", ice->
card->longname);
1538 snd_iprintf(buffer,
"EEPROM:\n");
1540 snd_iprintf(buffer,
" Subvendor : 0x%x\n", ice->
eeprom.subvendor);
1541 snd_iprintf(buffer,
" Size : %i bytes\n", ice->
eeprom.size);
1542 snd_iprintf(buffer,
" Version : %i\n", ice->
eeprom.version);
1543 snd_iprintf(buffer,
" System Config : 0x%x\n",
1545 snd_iprintf(buffer,
" ACLink : 0x%x\n",
1547 snd_iprintf(buffer,
" I2S : 0x%x\n",
1549 snd_iprintf(buffer,
" S/PDIF : 0x%x\n",
1551 snd_iprintf(buffer,
" GPIO direction : 0x%x\n",
1553 snd_iprintf(buffer,
" GPIO mask : 0x%x\n",
1555 snd_iprintf(buffer,
" GPIO state : 0x%x\n",
1557 for (idx = 0x12; idx < ice->
eeprom.size; idx++)
1558 snd_iprintf(buffer,
" Extra #%02i : 0x%x\n",
1559 idx, ice->
eeprom.data[idx]);
1561 snd_iprintf(buffer,
"\nRegisters:\n");
1563 snd_iprintf(buffer,
" PSDOUT03 : 0x%08x\n",
1565 for (idx = 0x0; idx < 0x20 ; idx++)
1566 snd_iprintf(buffer,
" CCS%02x : 0x%02x\n",
1568 for (idx = 0x0; idx < 0x30 ; idx++)
1569 snd_iprintf(buffer,
" MT%02x : 0x%02x\n",
1577 if (!snd_card_proc_new(ice->
card,
"ice1724", &entry))
1578 snd_info_set_text_ops(entry, ice, snd_vt1724_proc_read);
1585 static int snd_vt1724_eeprom_info(
struct snd_kcontrol *kcontrol,
1593 static int snd_vt1724_eeprom_get(
struct snd_kcontrol *kcontrol,
1604 .name =
"ICE1724 EEPROM",
1606 .info = snd_vt1724_eeprom_info,
1607 .get = snd_vt1724_eeprom_get
1612 static int snd_vt1724_spdif_info(
struct snd_kcontrol *kcontrol,
1620 static unsigned int encode_spdif_bits(
struct snd_aes_iec958 *diga)
1622 unsigned int val, rbits;
1624 val = diga->
status[0] & 0x03;
1630 rbits = (diga->
status[4] >> 3) & 0x0f;
1633 case 2: val |= 5 << 12;
break;
1634 case 3: val |= 6 << 12;
break;
1635 case 10: val |= 4 << 12;
break;
1636 case 11: val |= 7 << 12;
break;
1652 val |= diga->
status[1] & 0x04;
1656 val |= (
unsigned int)(diga->
status[1] & 0x3f) << 4;
1662 static void decode_spdif_bits(
struct snd_aes_iec958 *diga,
unsigned int val)
1665 diga->
status[0] = val & 0x03;
1668 if (val & (1
U << 3))
1670 switch ((val >> 12) & 0x7) {
1682 diga->
status[0] |= val & (1
U << 2);
1683 if (val & (1
U << 3))
1685 diga->
status[1] |= (val >> 4) & 0x3f;
1686 diga->
status[3] |= (val >> 12) & 0x07;
1690 static int snd_vt1724_spdif_default_get(
struct snd_kcontrol *kcontrol,
1696 decode_spdif_bits(&ucontrol->
value.iec958, val);
1700 static int snd_vt1724_spdif_default_put(
struct snd_kcontrol *kcontrol,
1704 unsigned int val, old;
1706 val = encode_spdif_bits(&ucontrol->
value.iec958);
1710 update_spdif_bits(ice, val);
1719 .info = snd_vt1724_spdif_info,
1720 .get = snd_vt1724_spdif_default_get,
1721 .put = snd_vt1724_spdif_default_put
1724 static int snd_vt1724_spdif_maskc_get(
struct snd_kcontrol *kcontrol,
1737 static int snd_vt1724_spdif_maskp_get(
struct snd_kcontrol *kcontrol,
1752 .info = snd_vt1724_spdif_info,
1753 .get = snd_vt1724_spdif_maskc_get,
1761 .info = snd_vt1724_spdif_info,
1762 .get = snd_vt1724_spdif_maskp_get,
1765 #define snd_vt1724_spdif_sw_info snd_ctl_boolean_mono_info
1767 static int snd_vt1724_spdif_sw_get(
struct snd_kcontrol *kcontrol,
1776 static int snd_vt1724_spdif_sw_put(
struct snd_kcontrol *kcontrol,
1780 unsigned char old,
val;
1785 if (ucontrol->
value.integer.value[0])
1800 .get = snd_vt1724_spdif_sw_get,
1801 .put = snd_vt1724_spdif_sw_put
1810 #define snd_vt1724_gpio_info snd_ctl_boolean_mono_info
1819 snd_ice1712_save_gpio_status(ice);
1820 ucontrol->
value.integer.value[0] =
1821 (snd_ice1712_gpio_read(ice) & (1 << shift) ? 1 : 0) ^ invert;
1822 snd_ice1712_restore_gpio_status(ice);
1831 int invert = (kcontrol->
private_value & (1<<24)) ? mask : 0;
1832 unsigned int val, nval;
1836 nval = (ucontrol->
value.integer.value[0] ? (1 << shift) : 0) ^ invert;
1837 snd_ice1712_save_gpio_status(ice);
1838 val = snd_ice1712_gpio_read(ice);
1839 nval |= val & ~(1 << shift);
1841 snd_ice1712_gpio_write(ice, nval);
1842 snd_ice1712_restore_gpio_status(ice);
1850 static int snd_vt1724_pro_internal_clock_info(
struct snd_kcontrol *kcontrol,
1854 int hw_rates_count = ice->
hw_rates->count;
1879 static int snd_vt1724_pro_internal_clock_get(
struct snd_kcontrol *kcontrol,
1883 unsigned int i,
rate;
1891 ucontrol->
value.enumerated.item[0] = 0;
1892 for (i = 0; i < ice->
hw_rates->count; i++) {
1893 if (ice->
hw_rates->list[i] == rate) {
1894 ucontrol->
value.enumerated.item[0] =
i;
1903 static int stdclock_get_spdif_master_type(
struct snd_ice1712 *ice)
1910 static int stdclock_set_spdif_clock(
struct snd_ice1712 *ice,
int type)
1913 unsigned char i2s_oval;
1923 static int snd_vt1724_pro_internal_clock_put(
struct snd_kcontrol *kcontrol,
1927 unsigned int old_rate, new_rate;
1928 unsigned int item = ucontrol->
value.enumerated.item[0];
1929 unsigned int first_ext_clock = ice->
hw_rates->count;
1940 if (item >= first_ext_clock) {
1955 if (old_rate != new_rate && !new_rate) {
1958 if (ice->
gpio.set_pro_rate)
1959 ice->
gpio.set_pro_rate(ice, 0);
1961 if (ice->
akm[i].ops.set_rate_val)
1962 ice->
akm[
i].ops.set_rate_val(&ice->
akm[i], 0);
1965 return old_rate != new_rate;
1968 static struct snd_kcontrol_new snd_vt1724_pro_internal_clock __devinitdata = {
1970 .name =
"Multi Track Internal Clock",
1971 .info = snd_vt1724_pro_internal_clock_info,
1972 .get = snd_vt1724_pro_internal_clock_get,
1973 .put = snd_vt1724_pro_internal_clock_put
1976 #define snd_vt1724_pro_rate_locking_info snd_ctl_boolean_mono_info
1978 static int snd_vt1724_pro_rate_locking_get(
struct snd_kcontrol *kcontrol,
1981 ucontrol->
value.integer.value[0] = PRO_RATE_LOCKED;
1985 static int snd_vt1724_pro_rate_locking_put(
struct snd_kcontrol *kcontrol,
1989 int change = 0, nval;
1991 nval = ucontrol->
value.integer.value[0] ? 1 : 0;
1993 change = PRO_RATE_LOCKED != nval;
1994 PRO_RATE_LOCKED = nval;
1999 static struct snd_kcontrol_new snd_vt1724_pro_rate_locking __devinitdata = {
2001 .name =
"Multi Track Rate Locking",
2003 .get = snd_vt1724_pro_rate_locking_get,
2004 .put = snd_vt1724_pro_rate_locking_put
2007 #define snd_vt1724_pro_rate_reset_info snd_ctl_boolean_mono_info
2009 static int snd_vt1724_pro_rate_reset_get(
struct snd_kcontrol *kcontrol,
2012 ucontrol->
value.integer.value[0] = PRO_RATE_RESET ? 1 : 0;
2016 static int snd_vt1724_pro_rate_reset_put(
struct snd_kcontrol *kcontrol,
2020 int change = 0, nval;
2022 nval = ucontrol->
value.integer.value[0] ? 1 : 0;
2024 change = PRO_RATE_RESET != nval;
2025 PRO_RATE_RESET = nval;
2032 .name =
"Multi Track Rate Reset",
2034 .get = snd_vt1724_pro_rate_reset_get,
2035 .put = snd_vt1724_pro_rate_reset_put
2042 static int snd_vt1724_pro_route_info(
struct snd_kcontrol *kcontrol,
2045 static char *texts[] = {
2047 "H/W In 0",
"H/W In 1",
2048 "IEC958 In L",
"IEC958 In R",
2060 static inline int analog_route_shift(
int idx)
2062 return (idx % 2) * 12 + ((idx / 2) * 3) + 8;
2065 static inline int digital_route_shift(
int idx)
2073 unsigned char eitem;
2074 static const unsigned char xlate[8] = {
2075 0, 255, 1, 2, 255, 255, 3, 4,
2092 unsigned int old_val, nval;
2094 static const unsigned char xroute[8] = {
2102 nval = xroute[val % 5];
2104 val &= ~(0x07 << shift);
2105 val |= nval << shift;
2106 change = val != old_val;
2112 static int snd_vt1724_pro_route_analog_get(
struct snd_kcontrol *kcontrol,
2116 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id);
2117 ucontrol->
value.enumerated.item[0] =
2122 static int snd_vt1724_pro_route_analog_put(
struct snd_kcontrol *kcontrol,
2126 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id);
2128 ucontrol->
value.enumerated.item[0],
2129 analog_route_shift(idx));
2132 static int snd_vt1724_pro_route_spdif_get(
struct snd_kcontrol *kcontrol,
2136 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id);
2137 ucontrol->
value.enumerated.item[0] =
2142 static int snd_vt1724_pro_route_spdif_put(
struct snd_kcontrol *kcontrol,
2146 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id);
2148 ucontrol->
value.enumerated.item[0],
2149 digital_route_shift(idx));
2152 static struct snd_kcontrol_new snd_vt1724_mixer_pro_analog_route __devinitdata =
2155 .name =
"H/W Playback Route",
2156 .info = snd_vt1724_pro_route_info,
2157 .get = snd_vt1724_pro_route_analog_get,
2158 .put = snd_vt1724_pro_route_analog_put,
2161 static struct snd_kcontrol_new snd_vt1724_mixer_pro_spdif_route __devinitdata = {
2164 .info = snd_vt1724_pro_route_info,
2165 .get = snd_vt1724_pro_route_spdif_get,
2166 .put = snd_vt1724_pro_route_spdif_put,
2171 static int snd_vt1724_pro_peak_info(
struct snd_kcontrol *kcontrol,
2181 static int snd_vt1724_pro_peak_get(
struct snd_kcontrol *kcontrol,
2188 for (idx = 0; idx < 22; idx++) {
2190 ucontrol->
value.integer.value[
idx] =
2199 .name =
"Multi Track Peak",
2201 .info = snd_vt1724_pro_peak_info,
2202 .get = snd_vt1724_pro_peak_get
2215 static unsigned char ooaoo_sq210_eeprom[] __devinitdata = {
2237 .
name =
"ooAoo SQ210a",
2239 .eeprom_size =
sizeof(ooaoo_sq210_eeprom),
2259 snd_vt1724_ooaoo_cards,
2267 static void wait_i2c_busy(
struct snd_ice1712 *ice)
2277 unsigned char dev,
unsigned char addr)
2295 unsigned char dev,
unsigned char addr,
unsigned char data)
2310 const char *modelname)
2312 const int dev = 0xa0;
2313 unsigned int i,
size;
2316 if (!modelname || !*modelname) {
2317 ice->
eeprom.subvendor = 0;
2324 if (ice->
eeprom.subvendor == 0 ||
2325 ice->
eeprom.subvendor == (
unsigned int)-1) {
2335 if (ice->
eeprom.subvendor == 0 ||
2336 ice->
eeprom.subvendor == (
unsigned int)-1) {
2342 for (tbl = card_tables; *tbl; tbl++) {
2343 for (c = *tbl; c->
name; c++) {
2344 if (modelname && c->
model &&
2366 if (ice->
eeprom.size < 6)
2368 else if (ice->
eeprom.size > 32) {
2374 if (ice->
eeprom.version != 2)
2377 size = ice->
eeprom.size - 6;
2378 for (i = 0; i <
size; i++)
2391 static void snd_vt1724_chip_reset(
struct snd_ice1712 *ice)
2401 static int snd_vt1724_chip_init(
struct snd_ice1712 *ice)
2410 snd_vt1724_set_gpio_mask(ice, ice->
eeprom.gpiomask);
2411 snd_vt1724_set_gpio_dir(ice, ice->
eeprom.gpiodir);
2412 snd_vt1724_set_gpio_data(ice, ice->
eeprom.gpiostate);
2417 outb(VT1724_IRQ_MPU_RX | VT1724_IRQ_MPU_TX ,
ICEREG1724(ice, IRQMASK));
2449 kctl->
id.device = ice->
pcm->device;
2453 kctl->
id.device = ice->
pcm->device;
2457 kctl->
id.device = ice->
pcm->device;
2462 kctl->
id.device = ice->
pcm->device;
2463 ice->
spdif.stream_ctl = kctl;
2504 static int snd_vt1724_free(
struct snd_ice1712 *ice)
2523 static int snd_vt1724_dev_free(
struct snd_device *device)
2526 return snd_vt1724_free(ice);
2531 const char *modelname,
2537 .dev_free = snd_vt1724_dev_free,
2557 ice->
gpio.set_mask = snd_vt1724_set_gpio_mask;
2558 ice->
gpio.get_mask = snd_vt1724_get_gpio_mask;
2559 ice->
gpio.set_dir = snd_vt1724_set_gpio_dir;
2560 ice->
gpio.get_dir = snd_vt1724_get_gpio_dir;
2561 ice->
gpio.set_data = snd_vt1724_set_gpio_data;
2562 ice->
gpio.get_data = snd_vt1724_get_gpio_data;
2567 snd_vt1724_proc_init(ice);
2584 snd_vt1724_free(ice);
2590 snd_vt1724_chip_reset(ice);
2591 if (snd_vt1724_read_eeprom(ice, modelname) < 0) {
2592 snd_vt1724_free(ice);
2595 if (snd_vt1724_chip_init(ice) < 0) {
2596 snd_vt1724_free(ice);
2602 snd_vt1724_free(ice);
2642 err = snd_vt1724_create(card, pci,
model[dev], &ice);
2651 for (tbl = card_tables; *tbl; tbl++) {
2652 for (c = *tbl; c->
name; c++) {
2699 set_std_hw_rates(ice);
2701 err = snd_vt1724_pcm_profi(ice, pcm_dev++);
2707 err = snd_vt1724_pcm_spdif(ice, pcm_dev++);
2713 err = snd_vt1724_pcm_indep(ice, pcm_dev++);
2719 err = snd_vt1724_ac97_mixer(ice);
2725 err = snd_vt1724_build_controls(ice);
2732 err = snd_vt1724_spdif_build_controls(ice);
2756 ice->
rmidi[0] = rmidi;
2763 &vt1724_midi_output_ops);
2765 &vt1724_midi_input_ops);
2784 pci_set_drvdata(pci, card);
2792 pci_set_drvdata(pci,
NULL);
2795 #ifdef CONFIG_PM_SLEEP
2796 static int snd_vt1724_suspend(
struct device *dev)
2802 if (!ice->pm_suspend_enabled)
2807 snd_pcm_suspend_all(ice->
pcm);
2808 snd_pcm_suspend_all(ice->
pcm_pro);
2809 snd_pcm_suspend_all(ice->
pcm_ds);
2810 snd_ac97_suspend(ice->
ac97);
2814 ice->pm_saved_spdif_ctrl =
inw(
ICEMT1724(ice, SPDIF_CTRL));
2816 ice->pm_saved_route =
inl(
ICEMT1724(ice, ROUTE_PLAYBACK));
2819 if (ice->pm_suspend)
2820 ice->pm_suspend(ice);
2828 static int snd_vt1724_resume(
struct device *dev)
2834 if (!ice->pm_suspend_enabled)
2847 snd_vt1724_chip_reset(ice);
2849 if (snd_vt1724_chip_init(ice) < 0) {
2855 ice->pm_resume(ice);
2857 if (ice->pm_saved_is_spdif_master) {
2867 snd_vt1724_set_pro_rate(ice, rate, 1);
2870 update_spdif_bits(ice, ice->pm_saved_spdif_ctrl);
2876 snd_ac97_resume(ice->
ac97);
2883 #define SND_VT1724_PM_OPS &snd_vt1724_pm
2885 #define SND_VT1724_PM_OPS NULL
2889 .name = KBUILD_MODNAME,
2890 .id_table = snd_vt1724_ids,
2891 .probe = snd_vt1724_probe,