Lines Matching +full:no +full:- +full:eeprom

1 // SPDX-License-Identifier: GPL-2.0-or-later
48 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
86 /* check whether the clock mode is spdif-in */
97 return (!ice->is_spdif_master(ice)) && PRO_RATE_LOCKED;
116 dev_dbg(ice->card->dev, "snd_vt1724_ac97_ready: timeout\n");
126 dev_dbg(ice->card->dev, "snd_vt1724_ac97_wait_bit: timeout\n");
127 return -EIO;
134 struct snd_ice1712 *ice = ac97->private_data;
139 old_cmd |= ac97->num;
148 struct snd_ice1712 *ice = ac97->private_data;
153 old_cmd |= ac97->num;
170 inw(ICEREG1724(ice, GPIO_DIRECTION)); /* dummy read for pci-posting */
183 if (!ice->vt1720) /* VT1720 supports only 16 GPIO bits */
185 inw(ICEREG1724(ice, GPIO_WRITE_MASK)); /* dummy read for pci-posting */
191 if (!ice->vt1720)
202 if (!ice->vt1720)
204 inw(ICEREG1724(ice, GPIO_DATA)); /* dummy read for pci-posting */
210 if (!ice->vt1720)
226 for (count = inb(ICEREG1724(ice, MPU_RXFIFO)); count > 0; --count)
233 return list_first_entry(&ice->rmidi[0]->streams[stream].substreams,
246 count = 31 - inb(ICEREG1724(ice, MPU_TXFIFO));
275 /* call with ice->reg_lock */
289 struct snd_ice1712 *ice = substream->rmidi->private_data;
291 guard(spinlock_irq)(&ice->reg_lock);
307 struct snd_ice1712 *ice = s->rmidi->private_data;
309 guard(spinlock_irqsave)(&ice->reg_lock);
311 ice->midi_output = 1;
314 ice->midi_output = 0;
321 struct snd_ice1712 *ice = s->rmidi->private_data;
343 vt1724_midi_clear_rx(s->rmidi->private_data);
356 struct snd_ice1712 *ice = s->rmidi->private_data;
358 guard(spinlock_irqsave)(&ice->reg_lock);
360 ice->midi_input = 1;
363 ice->midi_input = 0;
392 scoped_guard(spinlock, &ice->reg_lock) {
395 dev_err(ice->card->dev,
398 dev_err(ice->card->dev, "Disabling MPU_TX\n");
405 if (ice->midi_output)
417 if (ice->midi_input)
427 * Multi-track PCM
439 if (ice->playback_pro_substream)
440 snd_pcm_period_elapsed(ice->playback_pro_substream);
443 if (ice->capture_pro_substream)
444 snd_pcm_period_elapsed(ice->capture_pro_substream);
447 if (ice->playback_con_substream_ds[0])
448 snd_pcm_period_elapsed(ice->playback_con_substream_ds[0]);
451 if (ice->playback_con_substream_ds[1])
452 snd_pcm_period_elapsed(ice->playback_con_substream_ds[1]);
455 if (ice->playback_con_substream_ds[2])
456 snd_pcm_period_elapsed(ice->playback_con_substream_ds[2]);
459 if (ice->playback_con_substream)
460 snd_pcm_period_elapsed(ice->playback_con_substream);
463 if (ice->capture_con_substream)
464 snd_pcm_period_elapsed(ice->capture_con_substream);
483 * PCM code - professional part (multitrack)
493 .count = ARRAY_SIZE(rates) - 2, /* up to 96000 */
499 .count = ARRAY_SIZE(rates) - 5, /* up to 48000 */
528 reg = s->runtime->private_data;
529 what |= reg->start;
537 scoped_guard(spinlock, &ice->reg_lock) {
550 scoped_guard(spinlock, &ice->reg_lock) {
565 return -EINVAL;
604 if (ice->eeprom.data[ICE_EEP2_ACLINK] & VT1724_CFG_PRO_I2S) {
616 /* no change in master clock */
627 if (rate > ice->hw_rates->list[ice->hw_rates->count - 1])
628 return -EINVAL;
630 scoped_guard(spinlock_irqsave, &ice->reg_lock) {
634 return ((rate == ice->cur_rate) && !force) ? 0 : -EBUSY;
637 /* comparing required and current rate - makes sense for
639 return (rate == ice->cur_rate) ? 0 : -EBUSY;
642 if (force || !ice->is_spdif_master(ice)) {
645 old_rate = ice->get_rate(ice);
648 else if (rate == ice->cur_rate) {
653 ice->cur_rate = rate;
657 ice->set_rate(ice, rate);
660 mclk_change = ice->set_mclk(ice, rate);
662 if (mclk_change && ice->gpio.i2s_mclk_changed)
663 ice->gpio.i2s_mclk_changed(ice);
664 if (ice->gpio.set_pro_rate)
665 ice->gpio.set_pro_rate(ice, rate);
668 for (i = 0; i < ice->akm_codecs; i++) {
669 if (ice->akm[i].ops.set_rate_val)
670 ice->akm[i].ops.set_rate_val(&ice->akm[i], rate);
672 if (ice->spdif.ops.setup_rate)
673 ice->spdif.ops.setup_rate(ice, rate);
686 if (substream == ice->playback_pro_substream) {
687 /* PDMA0 can be multi-channel up to 8 */
688 chs = chs / 2 - 1;
690 if (ice->pcm_reserved[i] &&
691 ice->pcm_reserved[i] != substream)
692 return -EBUSY;
693 ice->pcm_reserved[i] = substream;
696 if (ice->pcm_reserved[i] == substream)
697 ice->pcm_reserved[i] = NULL;
702 if (ice->playback_con_substream_ds[i] == substream) {
703 if (ice->pcm_reserved[i] &&
704 ice->pcm_reserved[i] != substream)
705 return -EBUSY;
706 ice->pcm_reserved[i] = substream;
721 scoped_guard(mutex, &ice->open_mutex) {
735 guard(mutex)(&ice->open_mutex);
738 if (ice->pcm_reserved[i] == substream)
739 ice->pcm_reserved[i] = NULL;
749 guard(spinlock_irq)(&ice->reg_lock);
750 val = (8 - substream->runtime->channels) >> 1;
753 outl(substream->runtime->dma_addr, ICEMT1724(ice, PLAYBACK_ADDR));
755 size = (snd_pcm_lib_buffer_bytes(substream) >> 2) - 1;
759 size = (snd_pcm_lib_period_bytes(substream) >> 2) - 1;
765 dev_dbg(ice->card->dev, "pro prepare: ch = %d, addr = 0x%x, "
767 substream->runtime->channels,
768 (unsigned int)substream->runtime->dma_addr,
784 if (ptr < substream->runtime->dma_addr) {
785 dev_dbg(ice->card->dev, "invalid negative ptr\n");
788 ptr -= substream->runtime->dma_addr;
789 ptr = bytes_to_frames(substream->runtime, ptr);
790 if (ptr >= substream->runtime->buffer_size) {
791 dev_dbg(ice->card->dev, "invalid ptr %d (size=%d)\n",
792 (int)ptr, (int)substream->runtime->period_size);
798 ptr = bytes_to_frames(substream->runtime, ptr);
801 else if (ptr <= substream->runtime->buffer_size)
802 ptr = substream->runtime->buffer_size - ptr;
804 dev_dbg(ice->card->dev, "invalid ptr %d (size=%d)\n",
805 (int)ptr, (int)substream->runtime->buffer_size);
815 const struct vt1724_pcm_reg *reg = substream->runtime->private_data;
817 guard(spinlock_irq)(&ice->reg_lock);
818 outl(substream->runtime->dma_addr, ice->profi_port + reg->addr);
819 outw((snd_pcm_lib_buffer_bytes(substream) >> 2) - 1,
820 ice->profi_port + reg->size);
821 outw((snd_pcm_lib_period_bytes(substream) >> 2) - 1,
822 ice->profi_port + reg->count);
829 const struct vt1724_pcm_reg *reg = substream->runtime->private_data;
832 if (!(inl(ICEMT1724(ice, DMA_CONTROL)) & reg->start))
835 ptr = inl(ice->profi_port + reg->addr);
836 ptr -= substream->runtime->dma_addr;
837 return bytes_to_frames(substream->runtime, ptr);
839 ptr = inw(ice->profi_port + reg->size);
841 ptr = bytes_to_frames(substream->runtime, ptr);
844 else if (ptr <= substream->runtime->buffer_size)
845 ptr = substream->runtime->buffer_size - ptr;
847 dev_dbg(ice->card->dev, "invalid ptr %d (size=%d)\n",
848 (int)ptr, (int)substream->runtime->buffer_size);
950 if (ice->eeprom.data[ICE_EEP2_ACLINK] & VT1724_CFG_PRO_I2S) {
953 if ((ice->eeprom.data[ICE_EEP2_I2S] & 0x08) && !ice->vt1720)
954 ice->hw_rates = &hw_constraints_rates_192;
956 ice->hw_rates = &hw_constraints_rates_96;
959 ice->hw_rates = &hw_constraints_rates_48;
966 struct snd_pcm_runtime *runtime = substream->runtime;
968 runtime->hw.rate_min = ice->hw_rates->list[0];
969 runtime->hw.rate_max = ice->hw_rates->list[ice->hw_rates->count - 1];
970 runtime->hw.rates = SNDRV_PCM_RATE_KNOT;
973 ice->hw_rates);
982 struct snd_pcm_runtime *runtime = substream->runtime;
985 rate = ice->get_rate(ice);
986 if (rate >= runtime->hw.rate_min
987 && rate <= runtime->hw.rate_max) {
988 runtime->hw.rate_min = rate;
989 runtime->hw.rate_max = rate;
995 /* multi-channel playback needs alignment 8x32bit regardless of the channels
1002 struct snd_pcm_runtime *runtime = substream->runtime;
1006 runtime->private_data = (void *)&vt1724_playback_pro_reg;
1007 ice->playback_pro_substream = substream;
1008 runtime->hw = snd_vt1724_playback_pro;
1012 scoped_guard(mutex, &ice->open_mutex) {
1014 num_indeps = ice->num_total_dacs / 2 - 1;
1016 if (ice->pcm_reserved[chs])
1020 runtime->hw.channels_max = chs;
1029 if (ice->pro_open)
1030 ice->pro_open(ice, substream);
1037 struct snd_pcm_runtime *runtime = substream->runtime;
1039 runtime->private_data = (void *)&vt1724_capture_pro_reg;
1040 ice->capture_pro_substream = substream;
1041 runtime->hw = snd_vt1724_2ch_stereo;
1050 if (ice->pro_open)
1051 ice->pro_open(ice, substream);
1060 snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 0);
1061 ice->playback_pro_substream = NULL;
1071 snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 0);
1072 ice->capture_pro_substream = NULL;
1101 if ((ice->eeprom.data[ICE_EEP2_SYSCONF] & VT1724_CFG_ADC_MASK) ==
1106 err = snd_pcm_new(ice->card, "ICE1724", device, 1, capt, &pcm);
1115 pcm->private_data = ice;
1116 pcm->info_flags = 0;
1117 strscpy(pcm->name, "ICE1724");
1120 &ice->pci->dev, 256*1024, 256*1024);
1122 ice->pcm_pro = pcm;
1152 guard(spinlock_irqsave)(&ice->reg_lock);
1171 if (!ice->force_pdma4)
1172 update_spdif_rate(ice, substream->runtime->rate);
1179 struct snd_pcm_runtime *runtime = substream->runtime;
1181 runtime->private_data = (void *)&vt1724_playback_spdif_reg;
1182 ice->playback_con_substream = substream;
1183 if (ice->force_pdma4) {
1184 runtime->hw = snd_vt1724_2ch_stereo;
1187 runtime->hw = snd_vt1724_spdif;
1195 if (ice->spdif.ops.open)
1196 ice->spdif.ops.open(ice, substream);
1205 snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 0);
1206 ice->playback_con_substream = NULL;
1207 if (ice->spdif.ops.close)
1208 ice->spdif.ops.close(ice, substream);
1216 struct snd_pcm_runtime *runtime = substream->runtime;
1218 runtime->private_data = (void *)&vt1724_capture_spdif_reg;
1219 ice->capture_con_substream = substream;
1220 if (ice->force_rdma1) {
1221 runtime->hw = snd_vt1724_2ch_stereo;
1224 runtime->hw = snd_vt1724_spdif;
1232 if (ice->spdif.ops.open)
1233 ice->spdif.ops.open(ice, substream);
1242 snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 0);
1243 ice->capture_con_substream = NULL;
1244 if (ice->spdif.ops.close)
1245 ice->spdif.ops.close(ice, substream);
1278 if (ice->force_pdma4 ||
1279 (ice->eeprom.data[ICE_EEP2_SPDIF] & VT1724_CFG_SPDIF_OUT_INT)) {
1281 ice->has_spdif = 1;
1284 if (ice->force_rdma1 ||
1285 (ice->eeprom.data[ICE_EEP2_SPDIF] & VT1724_CFG_SPDIF_IN)) {
1287 ice->has_spdif = 1;
1291 return 0; /* no spdif device */
1293 if (ice->force_pdma4 || ice->force_rdma1)
1297 err = snd_pcm_new(ice->card, name, device, play, capt, &pcm);
1308 pcm->private_data = ice;
1309 pcm->info_flags = 0;
1310 strscpy(pcm->name, name);
1313 &ice->pci->dev, 256*1024, 256*1024);
1315 ice->pcm = pcm;
1351 scoped_guard(spinlock_irq, &ice->reg_lock) {
1352 val = 3 - substream->number;
1362 struct snd_pcm_runtime *runtime = substream->runtime;
1364 scoped_guard(mutex, &ice->open_mutex) {
1366 if (ice->pcm_reserved[substream->number])
1367 return -EBUSY; /* FIXME: should handle blocking mode properly */
1369 runtime->private_data = (void *)&vt1724_playback_dma_regs[substream->number];
1370 ice->playback_con_substream_ds[substream->number] = substream;
1371 runtime->hw = snd_vt1724_2ch_stereo;
1383 snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 0);
1384 ice->playback_con_substream_ds[substream->number] = NULL;
1385 ice->pcm_reserved[substream->number] = NULL;
1407 play = ice->num_total_dacs / 2 - 1;
1411 err = snd_pcm_new(ice->card, "ICE1724 Surrounds", device, play, 0, &pcm);
1418 pcm->private_data = ice;
1419 pcm->info_flags = 0;
1420 strscpy(pcm->name, "ICE1724 Surround PCM");
1423 &ice->pci->dev, 256*1024, 256*1024);
1425 ice->pcm_ds = pcm;
1439 if (!(ice->eeprom.data[ICE_EEP2_ACLINK] & VT1724_CFG_PRO_I2S)) {
1452 err = snd_ac97_bus(ice->card, 0, &ops, NULL, &pbus);
1457 err = snd_ac97_mixer(pbus, &ac97, &ice->ac97);
1459 dev_warn(ice->card->dev,
1465 strcat(ice->card->mixername, "ICE1724 - multitrack");
1475 return (unsigned int)ice->eeprom.data[idx] | \
1476 ((unsigned int)ice->eeprom.data[idx + 1] << 8) | \
1477 ((unsigned int)ice->eeprom.data[idx + 2] << 16);
1483 struct snd_ice1712 *ice = entry->private_data;
1486 snd_iprintf(buffer, "%s\n\n", ice->card->longname);
1487 snd_iprintf(buffer, "EEPROM:\n");
1489 snd_iprintf(buffer, " Subvendor : 0x%x\n", ice->eeprom.subvendor);
1490 snd_iprintf(buffer, " Size : %i bytes\n", ice->eeprom.size);
1491 snd_iprintf(buffer, " Version : %i\n", ice->eeprom.version);
1493 ice->eeprom.data[ICE_EEP2_SYSCONF]);
1495 ice->eeprom.data[ICE_EEP2_ACLINK]);
1497 ice->eeprom.data[ICE_EEP2_I2S]);
1499 ice->eeprom.data[ICE_EEP2_SPDIF]);
1501 ice->eeprom.gpiodir);
1503 ice->eeprom.gpiomask);
1505 ice->eeprom.gpiostate);
1506 for (idx = 0x12; idx < ice->eeprom.size; idx++)
1508 idx, ice->eeprom.data[idx]);
1516 idx, inb(ice->port+idx));
1519 idx, inb(ice->profi_port+idx));
1524 snd_card_ro_proc_new(ice->card, "ice1724", ice, snd_vt1724_proc_read);
1534 uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
1535 uinfo->count = sizeof(struct snd_ice1712_eeprom);
1544 memcpy(ucontrol->value.bytes.data, &ice->eeprom, sizeof(ice->eeprom));
1550 .name = "ICE1724 EEPROM",
1561 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
1562 uinfo->count = 1;
1570 val = diga->status[0] & 0x03; /* professional, non-audio */
1573 if ((diga->status[0] & IEC958_AES0_PRO_EMPHASIS) ==
1576 rbits = (diga->status[4] >> 3) & 0x0f;
1585 switch (diga->status[0] & IEC958_AES0_PRO_FS) {
1598 val |= diga->status[1] & 0x04; /* copyright */
1599 if ((diga->status[0] & IEC958_AES0_CON_EMPHASIS) ==
1602 val |= (unsigned int)(diga->status[1] & 0x3f) << 4; /* category */
1603 val |= (unsigned int)(diga->status[3] & IEC958_AES3_CON_FS) << 12; /* fs */
1610 memset(diga->status, 0, sizeof(diga->status));
1611 diga->status[0] = val & 0x03; /* professional, non-audio */
1615 diga->status[0] |= IEC958_AES0_PRO_EMPHASIS_5015;
1620 diga->status[0] |= IEC958_AES0_PRO_FS_32000;
1623 diga->status[0] |= IEC958_AES0_PRO_FS_48000;
1628 diga->status[0] |= val & (1U << 2); /* copyright */
1630 diga->status[0] |= IEC958_AES0_CON_EMPHASIS_5015;
1631 diga->status[1] |= (val >> 4) & 0x3f; /* category */
1632 diga->status[3] |= (val >> 12) & 0x07; /* fs */
1642 decode_spdif_bits(&ucontrol->value.iec958, val);
1652 val = encode_spdif_bits(&ucontrol->value.iec958);
1653 guard(spinlock_irq)(&ice->reg_lock);
1672 ucontrol->value.iec958.status[0] = IEC958_AES0_NONAUDIO |
1676 ucontrol->value.iec958.status[1] = IEC958_AES1_CON_ORIGINAL |
1678 ucontrol->value.iec958.status[3] = IEC958_AES3_CON_FS;
1685 ucontrol->value.iec958.status[0] = IEC958_AES0_NONAUDIO |
1716 ucontrol->value.integer.value[0] = inb(ICEREG1724(ice, SPDIF_CFG)) &
1727 guard(spinlock_irq)(&ice->reg_lock);
1730 if (ucontrol->value.integer.value[0])
1760 int shift = kcontrol->private_value & 0xff;
1761 int invert = (kcontrol->private_value & (1<<24)) ? 1 : 0;
1764 ucontrol->value.integer.value[0] =
1774 int shift = kcontrol->private_value & 0xff;
1775 int invert = (kcontrol->private_value & (1<<24)) ? mask : 0;
1778 if (kcontrol->private_value & (1 << 31))
1779 return -EPERM;
1780 nval = (ucontrol->value.integer.value[0] ? (1 << shift) : 0) ^ invert;
1798 int hw_rates_count = ice->hw_rates->count;
1799 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1800 uinfo->count = 1;
1803 uinfo->value.enumerated.items = hw_rates_count;
1805 if (ice->force_rdma1 ||
1806 (ice->eeprom.data[ICE_EEP2_SPDIF] & VT1724_CFG_SPDIF_IN))
1807 uinfo->value.enumerated.items += ice->ext_clock_count;
1808 /* upper limit - keep at top */
1809 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
1810 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
1811 if (uinfo->value.enumerated.item >= hw_rates_count)
1813 strscpy(uinfo->value.enumerated.name,
1814 ice->ext_clock_names[
1815 uinfo->value.enumerated.item - hw_rates_count]);
1818 sprintf(uinfo->value.enumerated.name, "%d",
1819 ice->hw_rates->list[uinfo->value.enumerated.item]);
1829 guard(spinlock_irq)(&ice->reg_lock);
1830 if (ice->is_spdif_master(ice)) {
1831 ucontrol->value.enumerated.item[0] = ice->hw_rates->count +
1832 ice->get_spdif_master_type(ice);
1834 rate = ice->get_rate(ice);
1835 ucontrol->value.enumerated.item[0] = 0;
1836 for (i = 0; i < ice->hw_rates->count; i++) {
1837 if (ice->hw_rates->list[i] == rate) {
1838 ucontrol->value.enumerated.item[0] = i;
1848 /* standard external clock - only single type - SPDIF IN */
1852 /* setting clock to external - SPDIF */
1871 unsigned int item = ucontrol->value.enumerated.item[0];
1872 unsigned int first_ext_clock = ice->hw_rates->count;
1875 if (item > first_ext_clock + ice->ext_clock_count - 1)
1876 return -EINVAL;
1879 scoped_guard(spinlock_irq, &ice->reg_lock) {
1880 if (ice->is_spdif_master(ice))
1883 old_rate = ice->get_rate(ice);
1886 ice->set_spdif_clock(ice, item - first_ext_clock);
1889 /* internal on-card clock */
1890 new_rate = ice->hw_rates->list[item];
1891 ice->pro_rate_default = new_rate;
1897 snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 1);
1903 if (ice->gpio.set_pro_rate)
1904 ice->gpio.set_pro_rate(ice, 0);
1905 for (i = 0; i < ice->akm_codecs; i++) {
1906 if (ice->akm[i].ops.set_rate_val)
1907 ice->akm[i].ops.set_rate_val(&ice->akm[i], 0);
1926 ucontrol->value.integer.value[0] = PRO_RATE_LOCKED;
1936 nval = ucontrol->value.integer.value[0] ? 1 : 0;
1937 guard(spinlock_irq)(&ice->reg_lock);
1956 ucontrol->value.integer.value[0] = PRO_RATE_RESET ? 1 : 0;
1966 nval = ucontrol->value.integer.value[0] ? 1 : 0;
1967 guard(spinlock_irq)(&ice->reg_lock);
1990 "H/W In 0", "H/W In 1", /* 1-2 */
1991 "IEC958 In L", "IEC958 In R", /* 3-4 */
2053 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2054 ucontrol->value.enumerated.item[0] =
2063 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2065 ucontrol->value.enumerated.item[0],
2073 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2074 ucontrol->value.enumerated.item[0] =
2083 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2085 ucontrol->value.enumerated.item[0],
2111 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
2112 uinfo->count = 22; /* FIXME: for compatibility with ice1712... */
2113 uinfo->value.integer.min = 0;
2114 uinfo->value.integer.max = 255;
2124 guard(spinlock_irq)(&ice->reg_lock);
2127 ucontrol->value.integer.value[idx] =
2142 ooAoo cards with no controls
2145 [ICE_EEP2_SYSCONF] = 0x4c, /* 49MHz crystal, no mpu401, no ADC,
2148 [ICE_EEP2_I2S] = 0x78, /* no volume, 96k, 24bit, 192k */
2149 [ICE_EEP2_SPDIF] = 0xc1, /* out-en, out-int, out-ext */
2150 [ICE_EEP2_GPIO_DIR] = 0x00, /* no GPIOs are used */
2200 while ((inb(ICEREG1724(ice, I2C_CTRL)) & VT1724_I2C_BUSY) && t--)
2202 if (t == -1)
2203 dev_err(ice->card->dev, "i2c busy timeout\n");
2211 guard(mutex)(&ice->i2c_mutex);
2218 dev_dbg(ice->card->dev, "i2c_read: [0x%x,0x%x] = 0x%x\n", dev, addr, val);
2226 guard(mutex)(&ice->i2c_mutex);
2229 dev_dbg(ice->card->dev, "i2c_write: [0x%x,0x%x] = 0x%x\n", dev, addr, data);
2240 const int dev = 0xa0; /* EEPROM device address */
2245 ice->eeprom.subvendor = 0;
2247 ice->eeprom.subvendor =
2252 if (ice->eeprom.subvendor == 0 ||
2253 ice->eeprom.subvendor == (unsigned int)-1) {
2254 /* invalid subvendor from EEPROM, try the PCI
2258 pci_read_config_word(ice->pci, PCI_SUBSYSTEM_VENDOR_ID,
2260 pci_read_config_word(ice->pci, PCI_SUBSYSTEM_ID, &device);
2261 ice->eeprom.subvendor =
2263 if (ice->eeprom.subvendor == 0 ||
2264 ice->eeprom.subvendor == (unsigned int)-1) {
2265 dev_err(ice->card->dev,
2266 "No valid ID is found\n");
2267 return -ENXIO;
2272 for (c = *tbl; c->name; c++) {
2273 if (modelname && c->model &&
2274 !strcmp(modelname, c->model)) {
2275 dev_info(ice->card->dev,
2277 c->name);
2278 ice->eeprom.subvendor = c->subvendor;
2279 } else if (c->subvendor != ice->eeprom.subvendor)
2281 ice->card_info = c;
2282 if (!c->eeprom_size || !c->eeprom_data)
2284 /* if the EEPROM is given by the driver, use it */
2285 dev_dbg(ice->card->dev, "using the defined eeprom..\n");
2286 ice->eeprom.version = 2;
2287 ice->eeprom.size = c->eeprom_size + 6;
2288 memcpy(ice->eeprom.data, c->eeprom_data, c->eeprom_size);
2292 dev_warn(ice->card->dev, "No matching model found for ID 0x%x\n",
2293 ice->eeprom.subvendor);
2295 /* assume AC97-only card which can suspend without additional code */
2296 ice->pm_suspend_enabled = 1;
2300 ice->eeprom.size = snd_vt1724_read_i2c(ice, dev, 0x04);
2301 if (ice->eeprom.size < 6)
2302 ice->eeprom.size = 32;
2303 else if (ice->eeprom.size > 32) {
2304 dev_err(ice->card->dev, "Invalid EEPROM (size = %i)\n",
2305 ice->eeprom.size);
2306 return -EIO;
2308 ice->eeprom.version = snd_vt1724_read_i2c(ice, dev, 0x05);
2309 if (ice->eeprom.version != 1 && ice->eeprom.version != 2)
2310 dev_warn(ice->card->dev, "Invalid EEPROM version %i\n",
2311 ice->eeprom.version);
2312 size = ice->eeprom.size - 6;
2314 ice->eeprom.data[i] = snd_vt1724_read_i2c(ice, dev, i + 6);
2317 ice->eeprom.gpiomask = eeprom_triple(ice, ICE_EEP2_GPIO_MASK);
2318 ice->eeprom.gpiostate = eeprom_triple(ice, ICE_EEP2_GPIO_STATE);
2319 ice->eeprom.gpiodir = eeprom_triple(ice, ICE_EEP2_GPIO_DIR);
2338 outb(ice->eeprom.data[ICE_EEP2_SYSCONF], ICEREG1724(ice, SYS_CFG));
2339 outb(ice->eeprom.data[ICE_EEP2_ACLINK], ICEREG1724(ice, AC97_CFG));
2340 outb(ice->eeprom.data[ICE_EEP2_I2S], ICEREG1724(ice, I2S_FEATURES));
2341 outb(ice->eeprom.data[ICE_EEP2_SPDIF], ICEREG1724(ice, SPDIF_CFG));
2343 ice->gpio.write_mask = ice->eeprom.gpiomask;
2344 ice->gpio.direction = ice->eeprom.gpiodir;
2345 snd_vt1724_set_gpio_mask(ice, ice->eeprom.gpiomask);
2346 snd_vt1724_set_gpio_dir(ice, ice->eeprom.gpiodir);
2347 snd_vt1724_set_gpio_data(ice, ice->eeprom.gpiostate);
2367 if (snd_BUG_ON(!ice->pcm))
2368 return -EIO;
2370 if (!ice->own_routing) {
2371 err = snd_ctl_add(ice->card,
2377 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_vt1724_spdif_switch, ice));
2382 kctl->id.device = ice->pcm->device;
2383 err = snd_ctl_add(ice->card, kctl);
2387 kctl->id.device = ice->pcm->device;
2388 err = snd_ctl_add(ice->card, kctl);
2392 kctl->id.device = ice->pcm->device;
2393 err = snd_ctl_add(ice->card, kctl);
2398 kctl->id.device = ice->pcm->device;
2399 err = snd_ctl_add(ice->card, kctl);
2402 ice->spdif.stream_ctl = kctl;
2412 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_vt1724_eeprom, ice));
2415 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_vt1724_pro_internal_clock, ice));
2419 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_vt1724_pro_rate_locking, ice));
2422 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_vt1724_pro_rate_reset, ice));
2426 if (!ice->own_routing && ice->num_total_dacs > 0) {
2428 tmp.count = ice->num_total_dacs;
2429 if (ice->vt1720 && tmp.count > 2)
2431 err = snd_ctl_add(ice->card, snd_ctl_new1(&tmp, ice));
2436 return snd_ctl_add(ice->card,
2442 struct snd_ice1712 *ice = card->private_data;
2455 struct snd_ice1712 *ice = card->private_data;
2463 ice->vt1724 = 1;
2464 spin_lock_init(&ice->reg_lock);
2465 mutex_init(&ice->gpio_mutex);
2466 mutex_init(&ice->open_mutex);
2467 mutex_init(&ice->i2c_mutex);
2468 ice->gpio.set_mask = snd_vt1724_set_gpio_mask;
2469 ice->gpio.get_mask = snd_vt1724_get_gpio_mask;
2470 ice->gpio.set_dir = snd_vt1724_set_gpio_dir;
2471 ice->gpio.get_dir = snd_vt1724_get_gpio_dir;
2472 ice->gpio.set_data = snd_vt1724_set_gpio_data;
2473 ice->gpio.get_data = snd_vt1724_get_gpio_data;
2474 ice->card = card;
2475 ice->pci = pci;
2476 ice->irq = -1;
2483 ice->port = pci_resource_start(pci, 0);
2484 ice->profi_port = pci_resource_start(pci, 1);
2486 if (devm_request_irq(&pci->dev, pci->irq, snd_vt1724_interrupt,
2488 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
2489 return -EIO;
2492 ice->irq = pci->irq;
2493 card->sync_irq = ice->irq;
2494 card->private_free = snd_vt1724_free;
2498 return -EIO;
2500 return -EIO;
2522 return -ENODEV;
2525 return -ENOENT;
2528 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
2532 ice = card->private_data;
2534 strscpy(card->driver, "ICE1724");
2535 strscpy(card->shortname, "ICEnsemble ICE1724");
2542 ice->ext_clock_count = 0;
2544 c = ice->card_info;
2546 strscpy(card->shortname, c->name);
2547 if (c->driver) /* specific driver? */
2548 strscpy(card->driver, c->driver);
2549 if (c->chip_init) {
2550 err = c->chip_init(ice);
2564 ice->pro_rate_default = PRO_RATE_DEFAULT;
2565 if (!ice->is_spdif_master)
2566 ice->is_spdif_master = stdclock_is_spdif_master;
2567 if (!ice->get_rate)
2568 ice->get_rate = stdclock_get_rate;
2569 if (!ice->set_rate)
2570 ice->set_rate = stdclock_set_rate;
2571 if (!ice->set_mclk)
2572 ice->set_mclk = stdclock_set_mclk;
2573 if (!ice->set_spdif_clock)
2574 ice->set_spdif_clock = stdclock_set_spdif_clock;
2575 if (!ice->get_spdif_master_type)
2576 ice->get_spdif_master_type = stdclock_get_spdif_master_type;
2577 if (!ice->ext_clock_names)
2578 ice->ext_clock_names = ext_clock_names;
2579 if (!ice->ext_clock_count)
2580 ice->ext_clock_count = ARRAY_SIZE(ext_clock_names);
2582 if (!ice->hw_rates)
2605 if (ice->pcm && ice->has_spdif) { /* has SPDIF I/O */
2611 if (c && c->build_controls) {
2612 err = c->build_controls(ice);
2617 if (!c || !c->no_mpu401) {
2618 if (ice->eeprom.data[ICE_EEP2_SYSCONF] & VT1724_CFG_MPU401) {
2624 ice->rmidi[0] = rmidi;
2625 rmidi->private_data = ice;
2626 strscpy(rmidi->name, "ICE1724 MIDI");
2627 rmidi->info_flags = SNDRV_RAWMIDI_INFO_OUTPUT |
2644 sprintf(card->longname, "%s at 0x%lx, irq %i",
2645 card->shortname, ice->port, ice->irq);
2658 return snd_card_free_on_error(&pci->dev, __snd_vt1724_probe(pci, pci_id));
2665 struct snd_ice1712 *ice = card->private_data;
2667 if (!ice->pm_suspend_enabled)
2672 snd_ac97_suspend(ice->ac97);
2674 scoped_guard(spinlock_irq, &ice->reg_lock) {
2675 ice->pm_saved_is_spdif_master = ice->is_spdif_master(ice);
2676 ice->pm_saved_spdif_ctrl = inw(ICEMT1724(ice, SPDIF_CTRL));
2677 ice->pm_saved_spdif_cfg = inb(ICEREG1724(ice, SPDIF_CFG));
2678 ice->pm_saved_route = inl(ICEMT1724(ice, ROUTE_PLAYBACK));
2681 if (ice->pm_suspend)
2682 ice->pm_suspend(ice);
2689 struct snd_ice1712 *ice = card->private_data;
2691 if (!ice->pm_suspend_enabled)
2698 return -EIO;
2701 if (ice->pm_resume)
2702 ice->pm_resume(ice);
2704 if (ice->pm_saved_is_spdif_master) {
2706 ice->set_spdif_clock(ice, 0);
2708 /* internal on-card clock */
2710 if (ice->cur_rate)
2711 rate = ice->cur_rate;
2713 rate = ice->pro_rate_default;
2717 update_spdif_bits(ice, ice->pm_saved_spdif_ctrl);
2719 outb(ice->pm_saved_spdif_cfg, ICEREG1724(ice, SPDIF_CFG));
2720 outl(ice->pm_saved_route, ICEMT1724(ice, ROUTE_PLAYBACK));
2722 snd_ac97_resume(ice->ac97);