Lines Matching +full:mixed +full:- +full:burst
1 // SPDX-License-Identifier: GPL-2.0-or-later
67 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
105 /* check whether the clock mode is spdif-in */
116 return (!ice->is_spdif_master(ice)) && PRO_RATE_LOCKED; in is_pro_rate_locked()
135 dev_dbg(ice->card->dev, "snd_vt1724_ac97_ready: timeout\n"); in snd_vt1724_ac97_ready()
145 dev_dbg(ice->card->dev, "snd_vt1724_ac97_wait_bit: timeout\n"); in snd_vt1724_ac97_wait_bit()
146 return -EIO; in snd_vt1724_ac97_wait_bit()
153 struct snd_ice1712 *ice = ac97->private_data; in snd_vt1724_ac97_write()
158 old_cmd |= ac97->num; in snd_vt1724_ac97_write()
167 struct snd_ice1712 *ice = ac97->private_data; in snd_vt1724_ac97_read()
172 old_cmd |= ac97->num; in snd_vt1724_ac97_read()
189 inw(ICEREG1724(ice, GPIO_DIRECTION)); /* dummy read for pci-posting */ in snd_vt1724_set_gpio_dir()
202 if (!ice->vt1720) /* VT1720 supports only 16 GPIO bits */ in snd_vt1724_set_gpio_mask()
204 inw(ICEREG1724(ice, GPIO_WRITE_MASK)); /* dummy read for pci-posting */ in snd_vt1724_set_gpio_mask()
210 if (!ice->vt1720) in snd_vt1724_get_gpio_mask()
221 if (!ice->vt1720) in snd_vt1724_set_gpio_data()
223 inw(ICEREG1724(ice, GPIO_DATA)); /* dummy read for pci-posting */ in snd_vt1724_set_gpio_data()
229 if (!ice->vt1720) in snd_vt1724_get_gpio_data()
245 for (count = inb(ICEREG1724(ice, MPU_RXFIFO)); count > 0; --count) in vt1724_midi_clear_rx()
252 return list_first_entry(&ice->rmidi[0]->streams[stream].substreams, in get_rawmidi_substream()
265 count = 31 - inb(ICEREG1724(ice, MPU_TXFIFO)); in vt1724_midi_write()
294 /* call with ice->reg_lock */
308 struct snd_ice1712 *ice = substream->rmidi->private_data; in vt1724_enable_midi_irq()
310 spin_lock_irq(&ice->reg_lock); in vt1724_enable_midi_irq()
312 spin_unlock_irq(&ice->reg_lock); in vt1724_enable_midi_irq()
327 struct snd_ice1712 *ice = s->rmidi->private_data; in vt1724_midi_output_trigger()
330 spin_lock_irqsave(&ice->reg_lock, flags); in vt1724_midi_output_trigger()
332 ice->midi_output = 1; in vt1724_midi_output_trigger()
335 ice->midi_output = 0; in vt1724_midi_output_trigger()
338 spin_unlock_irqrestore(&ice->reg_lock, flags); in vt1724_midi_output_trigger()
343 struct snd_ice1712 *ice = s->rmidi->private_data; in vt1724_midi_output_drain()
365 vt1724_midi_clear_rx(s->rmidi->private_data); in vt1724_midi_input_open()
378 struct snd_ice1712 *ice = s->rmidi->private_data; in vt1724_midi_input_trigger()
381 spin_lock_irqsave(&ice->reg_lock, flags); in vt1724_midi_input_trigger()
383 ice->midi_input = 1; in vt1724_midi_input_trigger()
386 ice->midi_input = 0; in vt1724_midi_input_trigger()
388 spin_unlock_irqrestore(&ice->reg_lock, flags); in vt1724_midi_input_trigger()
416 spin_lock(&ice->reg_lock); in snd_vt1724_interrupt()
419 dev_err(ice->card->dev, in snd_vt1724_interrupt()
422 dev_err(ice->card->dev, "Disabling MPU_TX\n"); in snd_vt1724_interrupt()
425 spin_unlock(&ice->reg_lock); in snd_vt1724_interrupt()
430 if (ice->midi_output) in snd_vt1724_interrupt()
442 if (ice->midi_input) in snd_vt1724_interrupt()
449 spin_unlock(&ice->reg_lock); in snd_vt1724_interrupt()
452 * Multi-track PCM in snd_vt1724_interrupt()
464 if (ice->playback_pro_substream) in snd_vt1724_interrupt()
465 snd_pcm_period_elapsed(ice->playback_pro_substream); in snd_vt1724_interrupt()
468 if (ice->capture_pro_substream) in snd_vt1724_interrupt()
469 snd_pcm_period_elapsed(ice->capture_pro_substream); in snd_vt1724_interrupt()
472 if (ice->playback_con_substream_ds[0]) in snd_vt1724_interrupt()
473 snd_pcm_period_elapsed(ice->playback_con_substream_ds[0]); in snd_vt1724_interrupt()
476 if (ice->playback_con_substream_ds[1]) in snd_vt1724_interrupt()
477 snd_pcm_period_elapsed(ice->playback_con_substream_ds[1]); in snd_vt1724_interrupt()
480 if (ice->playback_con_substream_ds[2]) in snd_vt1724_interrupt()
481 snd_pcm_period_elapsed(ice->playback_con_substream_ds[2]); in snd_vt1724_interrupt()
484 if (ice->playback_con_substream) in snd_vt1724_interrupt()
485 snd_pcm_period_elapsed(ice->playback_con_substream); in snd_vt1724_interrupt()
488 if (ice->capture_con_substream) in snd_vt1724_interrupt()
489 snd_pcm_period_elapsed(ice->capture_con_substream); in snd_vt1724_interrupt()
507 * PCM code - professional part (multitrack)
517 .count = ARRAY_SIZE(rates) - 2, /* up to 96000 */
523 .count = ARRAY_SIZE(rates) - 5, /* up to 48000 */
552 reg = s->runtime->private_data; in snd_vt1724_pcm_trigger()
553 what |= reg->start; in snd_vt1724_pcm_trigger()
561 spin_lock(&ice->reg_lock); in snd_vt1724_pcm_trigger()
568 spin_unlock(&ice->reg_lock); in snd_vt1724_pcm_trigger()
574 spin_lock(&ice->reg_lock); in snd_vt1724_pcm_trigger()
581 spin_unlock(&ice->reg_lock); in snd_vt1724_pcm_trigger()
589 return -EINVAL; in snd_vt1724_pcm_trigger()
628 if (ice->eeprom.data[ICE_EEP2_ACLINK] & VT1724_CFG_PRO_I2S) { in stdclock_set_mclk()
652 if (rate > ice->hw_rates->list[ice->hw_rates->count - 1]) in snd_vt1724_set_pro_rate()
653 return -EINVAL; in snd_vt1724_set_pro_rate()
655 spin_lock_irqsave(&ice->reg_lock, flags); in snd_vt1724_set_pro_rate()
659 spin_unlock_irqrestore(&ice->reg_lock, flags); in snd_vt1724_set_pro_rate()
660 return ((rate == ice->cur_rate) && !force) ? 0 : -EBUSY; in snd_vt1724_set_pro_rate()
663 /* comparing required and current rate - makes sense for in snd_vt1724_set_pro_rate()
665 spin_unlock_irqrestore(&ice->reg_lock, flags); in snd_vt1724_set_pro_rate()
666 return (rate == ice->cur_rate) ? 0 : -EBUSY; in snd_vt1724_set_pro_rate()
669 if (force || !ice->is_spdif_master(ice)) { in snd_vt1724_set_pro_rate()
672 old_rate = ice->get_rate(ice); in snd_vt1724_set_pro_rate()
675 else if (rate == ice->cur_rate) { in snd_vt1724_set_pro_rate()
676 spin_unlock_irqrestore(&ice->reg_lock, flags); in snd_vt1724_set_pro_rate()
681 ice->cur_rate = rate; in snd_vt1724_set_pro_rate()
682 spin_unlock_irqrestore(&ice->reg_lock, flags); in snd_vt1724_set_pro_rate()
685 ice->set_rate(ice, rate); in snd_vt1724_set_pro_rate()
688 mclk_change = ice->set_mclk(ice, rate); in snd_vt1724_set_pro_rate()
690 if (mclk_change && ice->gpio.i2s_mclk_changed) in snd_vt1724_set_pro_rate()
691 ice->gpio.i2s_mclk_changed(ice); in snd_vt1724_set_pro_rate()
692 if (ice->gpio.set_pro_rate) in snd_vt1724_set_pro_rate()
693 ice->gpio.set_pro_rate(ice, rate); in snd_vt1724_set_pro_rate()
696 for (i = 0; i < ice->akm_codecs; i++) { in snd_vt1724_set_pro_rate()
697 if (ice->akm[i].ops.set_rate_val) in snd_vt1724_set_pro_rate()
698 ice->akm[i].ops.set_rate_val(&ice->akm[i], rate); in snd_vt1724_set_pro_rate()
700 if (ice->spdif.ops.setup_rate) in snd_vt1724_set_pro_rate()
701 ice->spdif.ops.setup_rate(ice, rate); in snd_vt1724_set_pro_rate()
713 mutex_lock(&ice->open_mutex); in snd_vt1724_pcm_hw_params()
715 if (substream == ice->playback_pro_substream) { in snd_vt1724_pcm_hw_params()
716 /* PDMA0 can be multi-channel up to 8 */ in snd_vt1724_pcm_hw_params()
717 chs = chs / 2 - 1; in snd_vt1724_pcm_hw_params()
719 if (ice->pcm_reserved[i] && in snd_vt1724_pcm_hw_params()
720 ice->pcm_reserved[i] != substream) { in snd_vt1724_pcm_hw_params()
721 mutex_unlock(&ice->open_mutex); in snd_vt1724_pcm_hw_params()
722 return -EBUSY; in snd_vt1724_pcm_hw_params()
724 ice->pcm_reserved[i] = substream; in snd_vt1724_pcm_hw_params()
727 if (ice->pcm_reserved[i] == substream) in snd_vt1724_pcm_hw_params()
728 ice->pcm_reserved[i] = NULL; in snd_vt1724_pcm_hw_params()
733 if (ice->playback_con_substream_ds[i] == substream) { in snd_vt1724_pcm_hw_params()
734 if (ice->pcm_reserved[i] && in snd_vt1724_pcm_hw_params()
735 ice->pcm_reserved[i] != substream) { in snd_vt1724_pcm_hw_params()
736 mutex_unlock(&ice->open_mutex); in snd_vt1724_pcm_hw_params()
737 return -EBUSY; in snd_vt1724_pcm_hw_params()
739 ice->pcm_reserved[i] = substream; in snd_vt1724_pcm_hw_params()
744 mutex_unlock(&ice->open_mutex); in snd_vt1724_pcm_hw_params()
754 mutex_lock(&ice->open_mutex); in snd_vt1724_pcm_hw_free()
757 if (ice->pcm_reserved[i] == substream) in snd_vt1724_pcm_hw_free()
758 ice->pcm_reserved[i] = NULL; in snd_vt1724_pcm_hw_free()
759 mutex_unlock(&ice->open_mutex); in snd_vt1724_pcm_hw_free()
769 spin_lock_irq(&ice->reg_lock); in snd_vt1724_playback_pro_prepare()
770 val = (8 - substream->runtime->channels) >> 1; in snd_vt1724_playback_pro_prepare()
771 outb(val, ICEMT1724(ice, BURST)); in snd_vt1724_playback_pro_prepare()
773 outl(substream->runtime->dma_addr, ICEMT1724(ice, PLAYBACK_ADDR)); in snd_vt1724_playback_pro_prepare()
775 size = (snd_pcm_lib_buffer_bytes(substream) >> 2) - 1; in snd_vt1724_playback_pro_prepare()
779 size = (snd_pcm_lib_period_bytes(substream) >> 2) - 1; in snd_vt1724_playback_pro_prepare()
784 spin_unlock_irq(&ice->reg_lock); in snd_vt1724_playback_pro_prepare()
787 dev_dbg(ice->card->dev, "pro prepare: ch = %d, addr = 0x%x, " in snd_vt1724_playback_pro_prepare()
789 substream->runtime->channels, in snd_vt1724_playback_pro_prepare()
790 (unsigned int)substream->runtime->dma_addr, in snd_vt1724_playback_pro_prepare()
806 if (ptr < substream->runtime->dma_addr) { in snd_vt1724_playback_pro_pointer()
807 dev_dbg(ice->card->dev, "invalid negative ptr\n"); in snd_vt1724_playback_pro_pointer()
810 ptr -= substream->runtime->dma_addr; in snd_vt1724_playback_pro_pointer()
811 ptr = bytes_to_frames(substream->runtime, ptr); in snd_vt1724_playback_pro_pointer()
812 if (ptr >= substream->runtime->buffer_size) { in snd_vt1724_playback_pro_pointer()
813 dev_dbg(ice->card->dev, "invalid ptr %d (size=%d)\n", in snd_vt1724_playback_pro_pointer()
814 (int)ptr, (int)substream->runtime->period_size); in snd_vt1724_playback_pro_pointer()
820 ptr = bytes_to_frames(substream->runtime, ptr); in snd_vt1724_playback_pro_pointer()
823 else if (ptr <= substream->runtime->buffer_size) in snd_vt1724_playback_pro_pointer()
824 ptr = substream->runtime->buffer_size - ptr; in snd_vt1724_playback_pro_pointer()
826 dev_dbg(ice->card->dev, "invalid ptr %d (size=%d)\n", in snd_vt1724_playback_pro_pointer()
827 (int)ptr, (int)substream->runtime->buffer_size); in snd_vt1724_playback_pro_pointer()
837 const struct vt1724_pcm_reg *reg = substream->runtime->private_data; in snd_vt1724_pcm_prepare()
839 spin_lock_irq(&ice->reg_lock); in snd_vt1724_pcm_prepare()
840 outl(substream->runtime->dma_addr, ice->profi_port + reg->addr); in snd_vt1724_pcm_prepare()
841 outw((snd_pcm_lib_buffer_bytes(substream) >> 2) - 1, in snd_vt1724_pcm_prepare()
842 ice->profi_port + reg->size); in snd_vt1724_pcm_prepare()
843 outw((snd_pcm_lib_period_bytes(substream) >> 2) - 1, in snd_vt1724_pcm_prepare()
844 ice->profi_port + reg->count); in snd_vt1724_pcm_prepare()
845 spin_unlock_irq(&ice->reg_lock); in snd_vt1724_pcm_prepare()
852 const struct vt1724_pcm_reg *reg = substream->runtime->private_data; in snd_vt1724_pcm_pointer()
855 if (!(inl(ICEMT1724(ice, DMA_CONTROL)) & reg->start)) in snd_vt1724_pcm_pointer()
858 ptr = inl(ice->profi_port + reg->addr); in snd_vt1724_pcm_pointer()
859 ptr -= substream->runtime->dma_addr; in snd_vt1724_pcm_pointer()
860 return bytes_to_frames(substream->runtime, ptr); in snd_vt1724_pcm_pointer()
862 ptr = inw(ice->profi_port + reg->size); in snd_vt1724_pcm_pointer()
864 ptr = bytes_to_frames(substream->runtime, ptr); in snd_vt1724_pcm_pointer()
867 else if (ptr <= substream->runtime->buffer_size) in snd_vt1724_pcm_pointer()
868 ptr = substream->runtime->buffer_size - ptr; in snd_vt1724_pcm_pointer()
870 dev_dbg(ice->card->dev, "invalid ptr %d (size=%d)\n", in snd_vt1724_pcm_pointer()
871 (int)ptr, (int)substream->runtime->buffer_size); in snd_vt1724_pcm_pointer()
973 if (ice->eeprom.data[ICE_EEP2_ACLINK] & VT1724_CFG_PRO_I2S) { in set_std_hw_rates()
976 if ((ice->eeprom.data[ICE_EEP2_I2S] & 0x08) && !ice->vt1720) in set_std_hw_rates()
977 ice->hw_rates = &hw_constraints_rates_192; in set_std_hw_rates()
979 ice->hw_rates = &hw_constraints_rates_96; in set_std_hw_rates()
982 ice->hw_rates = &hw_constraints_rates_48; in set_std_hw_rates()
989 struct snd_pcm_runtime *runtime = substream->runtime; in set_rate_constraints()
991 runtime->hw.rate_min = ice->hw_rates->list[0]; in set_rate_constraints()
992 runtime->hw.rate_max = ice->hw_rates->list[ice->hw_rates->count - 1]; in set_rate_constraints()
993 runtime->hw.rates = SNDRV_PCM_RATE_KNOT; in set_rate_constraints()
996 ice->hw_rates); in set_rate_constraints()
1005 struct snd_pcm_runtime *runtime = substream->runtime; in constrain_rate_if_locked()
1008 rate = ice->get_rate(ice); in constrain_rate_if_locked()
1009 if (rate >= runtime->hw.rate_min in constrain_rate_if_locked()
1010 && rate <= runtime->hw.rate_max) { in constrain_rate_if_locked()
1011 runtime->hw.rate_min = rate; in constrain_rate_if_locked()
1012 runtime->hw.rate_max = rate; in constrain_rate_if_locked()
1018 /* multi-channel playback needs alignment 8x32bit regardless of the channels
1025 struct snd_pcm_runtime *runtime = substream->runtime; in snd_vt1724_playback_pro_open()
1029 runtime->private_data = (void *)&vt1724_playback_pro_reg; in snd_vt1724_playback_pro_open()
1030 ice->playback_pro_substream = substream; in snd_vt1724_playback_pro_open()
1031 runtime->hw = snd_vt1724_playback_pro; in snd_vt1724_playback_pro_open()
1035 mutex_lock(&ice->open_mutex); in snd_vt1724_playback_pro_open()
1037 num_indeps = ice->num_total_dacs / 2 - 1; in snd_vt1724_playback_pro_open()
1039 if (ice->pcm_reserved[chs]) in snd_vt1724_playback_pro_open()
1043 runtime->hw.channels_max = chs; in snd_vt1724_playback_pro_open()
1046 mutex_unlock(&ice->open_mutex); in snd_vt1724_playback_pro_open()
1052 if (ice->pro_open) in snd_vt1724_playback_pro_open()
1053 ice->pro_open(ice, substream); in snd_vt1724_playback_pro_open()
1060 struct snd_pcm_runtime *runtime = substream->runtime; in snd_vt1724_capture_pro_open()
1062 runtime->private_data = (void *)&vt1724_capture_pro_reg; in snd_vt1724_capture_pro_open()
1063 ice->capture_pro_substream = substream; in snd_vt1724_capture_pro_open()
1064 runtime->hw = snd_vt1724_2ch_stereo; in snd_vt1724_capture_pro_open()
1073 if (ice->pro_open) in snd_vt1724_capture_pro_open()
1074 ice->pro_open(ice, substream); in snd_vt1724_capture_pro_open()
1083 snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 0); in snd_vt1724_playback_pro_close()
1084 ice->playback_pro_substream = NULL; in snd_vt1724_playback_pro_close()
1094 snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 0); in snd_vt1724_capture_pro_close()
1095 ice->capture_pro_substream = NULL; in snd_vt1724_capture_pro_close()
1124 if ((ice->eeprom.data[ICE_EEP2_SYSCONF] & VT1724_CFG_ADC_MASK) == in snd_vt1724_pcm_profi()
1129 err = snd_pcm_new(ice->card, "ICE1724", device, 1, capt, &pcm); in snd_vt1724_pcm_profi()
1138 pcm->private_data = ice; in snd_vt1724_pcm_profi()
1139 pcm->info_flags = 0; in snd_vt1724_pcm_profi()
1140 strcpy(pcm->name, "ICE1724"); in snd_vt1724_pcm_profi()
1143 &ice->pci->dev, 256*1024, 256*1024); in snd_vt1724_pcm_profi()
1145 ice->pcm_pro = pcm; in snd_vt1724_pcm_profi()
1176 spin_lock_irqsave(&ice->reg_lock, flags); in update_spdif_rate()
1190 spin_unlock_irqrestore(&ice->reg_lock, flags); in update_spdif_rate()
1196 if (!ice->force_pdma4) in snd_vt1724_playback_spdif_prepare()
1197 update_spdif_rate(ice, substream->runtime->rate); in snd_vt1724_playback_spdif_prepare()
1204 struct snd_pcm_runtime *runtime = substream->runtime; in snd_vt1724_playback_spdif_open()
1206 runtime->private_data = (void *)&vt1724_playback_spdif_reg; in snd_vt1724_playback_spdif_open()
1207 ice->playback_con_substream = substream; in snd_vt1724_playback_spdif_open()
1208 if (ice->force_pdma4) { in snd_vt1724_playback_spdif_open()
1209 runtime->hw = snd_vt1724_2ch_stereo; in snd_vt1724_playback_spdif_open()
1212 runtime->hw = snd_vt1724_spdif; in snd_vt1724_playback_spdif_open()
1220 if (ice->spdif.ops.open) in snd_vt1724_playback_spdif_open()
1221 ice->spdif.ops.open(ice, substream); in snd_vt1724_playback_spdif_open()
1230 snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 0); in snd_vt1724_playback_spdif_close()
1231 ice->playback_con_substream = NULL; in snd_vt1724_playback_spdif_close()
1232 if (ice->spdif.ops.close) in snd_vt1724_playback_spdif_close()
1233 ice->spdif.ops.close(ice, substream); in snd_vt1724_playback_spdif_close()
1241 struct snd_pcm_runtime *runtime = substream->runtime; in snd_vt1724_capture_spdif_open()
1243 runtime->private_data = (void *)&vt1724_capture_spdif_reg; in snd_vt1724_capture_spdif_open()
1244 ice->capture_con_substream = substream; in snd_vt1724_capture_spdif_open()
1245 if (ice->force_rdma1) { in snd_vt1724_capture_spdif_open()
1246 runtime->hw = snd_vt1724_2ch_stereo; in snd_vt1724_capture_spdif_open()
1249 runtime->hw = snd_vt1724_spdif; in snd_vt1724_capture_spdif_open()
1257 if (ice->spdif.ops.open) in snd_vt1724_capture_spdif_open()
1258 ice->spdif.ops.open(ice, substream); in snd_vt1724_capture_spdif_open()
1267 snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 0); in snd_vt1724_capture_spdif_close()
1268 ice->capture_con_substream = NULL; in snd_vt1724_capture_spdif_close()
1269 if (ice->spdif.ops.close) in snd_vt1724_capture_spdif_close()
1270 ice->spdif.ops.close(ice, substream); in snd_vt1724_capture_spdif_close()
1303 if (ice->force_pdma4 || in snd_vt1724_pcm_spdif()
1304 (ice->eeprom.data[ICE_EEP2_SPDIF] & VT1724_CFG_SPDIF_OUT_INT)) { in snd_vt1724_pcm_spdif()
1306 ice->has_spdif = 1; in snd_vt1724_pcm_spdif()
1309 if (ice->force_rdma1 || in snd_vt1724_pcm_spdif()
1310 (ice->eeprom.data[ICE_EEP2_SPDIF] & VT1724_CFG_SPDIF_IN)) { in snd_vt1724_pcm_spdif()
1312 ice->has_spdif = 1; in snd_vt1724_pcm_spdif()
1318 if (ice->force_pdma4 || ice->force_rdma1) in snd_vt1724_pcm_spdif()
1322 err = snd_pcm_new(ice->card, name, device, play, capt, &pcm); in snd_vt1724_pcm_spdif()
1333 pcm->private_data = ice; in snd_vt1724_pcm_spdif()
1334 pcm->info_flags = 0; in snd_vt1724_pcm_spdif()
1335 strcpy(pcm->name, name); in snd_vt1724_pcm_spdif()
1338 &ice->pci->dev, 256*1024, 256*1024); in snd_vt1724_pcm_spdif()
1340 ice->pcm = pcm; in snd_vt1724_pcm_spdif()
1376 spin_lock_irq(&ice->reg_lock); in snd_vt1724_playback_indep_prepare()
1377 val = 3 - substream->number; in snd_vt1724_playback_indep_prepare()
1378 if (inb(ICEMT1724(ice, BURST)) < val) in snd_vt1724_playback_indep_prepare()
1379 outb(val, ICEMT1724(ice, BURST)); in snd_vt1724_playback_indep_prepare()
1380 spin_unlock_irq(&ice->reg_lock); in snd_vt1724_playback_indep_prepare()
1387 struct snd_pcm_runtime *runtime = substream->runtime; in snd_vt1724_playback_indep_open()
1389 mutex_lock(&ice->open_mutex); in snd_vt1724_playback_indep_open()
1391 if (ice->pcm_reserved[substream->number]) { in snd_vt1724_playback_indep_open()
1392 mutex_unlock(&ice->open_mutex); in snd_vt1724_playback_indep_open()
1393 return -EBUSY; /* FIXME: should handle blocking mode properly */ in snd_vt1724_playback_indep_open()
1395 mutex_unlock(&ice->open_mutex); in snd_vt1724_playback_indep_open()
1396 runtime->private_data = (void *)&vt1724_playback_dma_regs[substream->number]; in snd_vt1724_playback_indep_open()
1397 ice->playback_con_substream_ds[substream->number] = substream; in snd_vt1724_playback_indep_open()
1398 runtime->hw = snd_vt1724_2ch_stereo; in snd_vt1724_playback_indep_open()
1410 snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 0); in snd_vt1724_playback_indep_close()
1411 ice->playback_con_substream_ds[substream->number] = NULL; in snd_vt1724_playback_indep_close()
1412 ice->pcm_reserved[substream->number] = NULL; in snd_vt1724_playback_indep_close()
1434 play = ice->num_total_dacs / 2 - 1; in snd_vt1724_pcm_indep()
1438 err = snd_pcm_new(ice->card, "ICE1724 Surrounds", device, play, 0, &pcm); in snd_vt1724_pcm_indep()
1445 pcm->private_data = ice; in snd_vt1724_pcm_indep()
1446 pcm->info_flags = 0; in snd_vt1724_pcm_indep()
1447 strcpy(pcm->name, "ICE1724 Surround PCM"); in snd_vt1724_pcm_indep()
1450 &ice->pci->dev, 256*1024, 256*1024); in snd_vt1724_pcm_indep()
1452 ice->pcm_ds = pcm; in snd_vt1724_pcm_indep()
1466 if (!(ice->eeprom.data[ICE_EEP2_ACLINK] & VT1724_CFG_PRO_I2S)) { in snd_vt1724_ac97_mixer()
1479 err = snd_ac97_bus(ice->card, 0, &ops, NULL, &pbus); in snd_vt1724_ac97_mixer()
1484 err = snd_ac97_mixer(pbus, &ac97, &ice->ac97); in snd_vt1724_ac97_mixer()
1486 dev_warn(ice->card->dev, in snd_vt1724_ac97_mixer()
1492 strcat(ice->card->mixername, "ICE1724 - multitrack"); in snd_vt1724_ac97_mixer()
1502 return (unsigned int)ice->eeprom.data[idx] | \ in eeprom_triple()
1503 ((unsigned int)ice->eeprom.data[idx + 1] << 8) | \ in eeprom_triple()
1504 ((unsigned int)ice->eeprom.data[idx + 2] << 16); in eeprom_triple()
1510 struct snd_ice1712 *ice = entry->private_data; in snd_vt1724_proc_read()
1513 snd_iprintf(buffer, "%s\n\n", ice->card->longname); in snd_vt1724_proc_read()
1516 snd_iprintf(buffer, " Subvendor : 0x%x\n", ice->eeprom.subvendor); in snd_vt1724_proc_read()
1517 snd_iprintf(buffer, " Size : %i bytes\n", ice->eeprom.size); in snd_vt1724_proc_read()
1518 snd_iprintf(buffer, " Version : %i\n", ice->eeprom.version); in snd_vt1724_proc_read()
1520 ice->eeprom.data[ICE_EEP2_SYSCONF]); in snd_vt1724_proc_read()
1522 ice->eeprom.data[ICE_EEP2_ACLINK]); in snd_vt1724_proc_read()
1524 ice->eeprom.data[ICE_EEP2_I2S]); in snd_vt1724_proc_read()
1526 ice->eeprom.data[ICE_EEP2_SPDIF]); in snd_vt1724_proc_read()
1528 ice->eeprom.gpiodir); in snd_vt1724_proc_read()
1530 ice->eeprom.gpiomask); in snd_vt1724_proc_read()
1532 ice->eeprom.gpiostate); in snd_vt1724_proc_read()
1533 for (idx = 0x12; idx < ice->eeprom.size; idx++) in snd_vt1724_proc_read()
1535 idx, ice->eeprom.data[idx]); in snd_vt1724_proc_read()
1543 idx, inb(ice->port+idx)); in snd_vt1724_proc_read()
1546 idx, inb(ice->profi_port+idx)); in snd_vt1724_proc_read()
1551 snd_card_ro_proc_new(ice->card, "ice1724", ice, snd_vt1724_proc_read); in snd_vt1724_proc_init()
1561 uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; in snd_vt1724_eeprom_info()
1562 uinfo->count = sizeof(struct snd_ice1712_eeprom); in snd_vt1724_eeprom_info()
1571 memcpy(ucontrol->value.bytes.data, &ice->eeprom, sizeof(ice->eeprom)); in snd_vt1724_eeprom_get()
1588 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; in snd_vt1724_spdif_info()
1589 uinfo->count = 1; in snd_vt1724_spdif_info()
1597 val = diga->status[0] & 0x03; /* professional, non-audio */ in encode_spdif_bits()
1600 if ((diga->status[0] & IEC958_AES0_PRO_EMPHASIS) == in encode_spdif_bits()
1603 rbits = (diga->status[4] >> 3) & 0x0f; in encode_spdif_bits()
1612 switch (diga->status[0] & IEC958_AES0_PRO_FS) { in encode_spdif_bits()
1625 val |= diga->status[1] & 0x04; /* copyright */ in encode_spdif_bits()
1626 if ((diga->status[0] & IEC958_AES0_CON_EMPHASIS) == in encode_spdif_bits()
1629 val |= (unsigned int)(diga->status[1] & 0x3f) << 4; /* category */ in encode_spdif_bits()
1630 val |= (unsigned int)(diga->status[3] & IEC958_AES3_CON_FS) << 12; /* fs */ in encode_spdif_bits()
1637 memset(diga->status, 0, sizeof(diga->status)); in decode_spdif_bits()
1638 diga->status[0] = val & 0x03; /* professional, non-audio */ in decode_spdif_bits()
1642 diga->status[0] |= IEC958_AES0_PRO_EMPHASIS_5015; in decode_spdif_bits()
1647 diga->status[0] |= IEC958_AES0_PRO_FS_32000; in decode_spdif_bits()
1650 diga->status[0] |= IEC958_AES0_PRO_FS_48000; in decode_spdif_bits()
1655 diga->status[0] |= val & (1U << 2); /* copyright */ in decode_spdif_bits()
1657 diga->status[0] |= IEC958_AES0_CON_EMPHASIS_5015; in decode_spdif_bits()
1658 diga->status[1] |= (val >> 4) & 0x3f; /* category */ in decode_spdif_bits()
1659 diga->status[3] |= (val >> 12) & 0x07; /* fs */ in decode_spdif_bits()
1669 decode_spdif_bits(&ucontrol->value.iec958, val); in snd_vt1724_spdif_default_get()
1679 val = encode_spdif_bits(&ucontrol->value.iec958); in snd_vt1724_spdif_default_put()
1680 spin_lock_irq(&ice->reg_lock); in snd_vt1724_spdif_default_put()
1684 spin_unlock_irq(&ice->reg_lock); in snd_vt1724_spdif_default_put()
1700 ucontrol->value.iec958.status[0] = IEC958_AES0_NONAUDIO | in snd_vt1724_spdif_maskc_get()
1704 ucontrol->value.iec958.status[1] = IEC958_AES1_CON_ORIGINAL | in snd_vt1724_spdif_maskc_get()
1706 ucontrol->value.iec958.status[3] = IEC958_AES3_CON_FS; in snd_vt1724_spdif_maskc_get()
1713 ucontrol->value.iec958.status[0] = IEC958_AES0_NONAUDIO | in snd_vt1724_spdif_maskp_get()
1744 ucontrol->value.integer.value[0] = inb(ICEREG1724(ice, SPDIF_CFG)) & in snd_vt1724_spdif_sw_get()
1755 spin_lock_irq(&ice->reg_lock); in snd_vt1724_spdif_sw_put()
1758 if (ucontrol->value.integer.value[0]) in snd_vt1724_spdif_sw_put()
1762 spin_unlock_irq(&ice->reg_lock); in snd_vt1724_spdif_sw_put()
1789 int shift = kcontrol->private_value & 0xff;
1790 int invert = (kcontrol->private_value & (1<<24)) ? 1 : 0;
1793 ucontrol->value.integer.value[0] =
1803 int shift = kcontrol->private_value & 0xff;
1804 int invert = (kcontrol->private_value & (1<<24)) ? mask : 0;
1807 if (kcontrol->private_value & (1 << 31))
1808 return -EPERM;
1809 nval = (ucontrol->value.integer.value[0] ? (1 << shift) : 0) ^ invert;
1827 int hw_rates_count = ice->hw_rates->count; in snd_vt1724_pro_internal_clock_info()
1828 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in snd_vt1724_pro_internal_clock_info()
1829 uinfo->count = 1; in snd_vt1724_pro_internal_clock_info()
1832 uinfo->value.enumerated.items = hw_rates_count; in snd_vt1724_pro_internal_clock_info()
1834 if (ice->force_rdma1 || in snd_vt1724_pro_internal_clock_info()
1835 (ice->eeprom.data[ICE_EEP2_SPDIF] & VT1724_CFG_SPDIF_IN)) in snd_vt1724_pro_internal_clock_info()
1836 uinfo->value.enumerated.items += ice->ext_clock_count; in snd_vt1724_pro_internal_clock_info()
1837 /* upper limit - keep at top */ in snd_vt1724_pro_internal_clock_info()
1838 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) in snd_vt1724_pro_internal_clock_info()
1839 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; in snd_vt1724_pro_internal_clock_info()
1840 if (uinfo->value.enumerated.item >= hw_rates_count) in snd_vt1724_pro_internal_clock_info()
1842 strcpy(uinfo->value.enumerated.name, in snd_vt1724_pro_internal_clock_info()
1843 ice->ext_clock_names[ in snd_vt1724_pro_internal_clock_info()
1844 uinfo->value.enumerated.item - hw_rates_count]); in snd_vt1724_pro_internal_clock_info()
1847 sprintf(uinfo->value.enumerated.name, "%d", in snd_vt1724_pro_internal_clock_info()
1848 ice->hw_rates->list[uinfo->value.enumerated.item]); in snd_vt1724_pro_internal_clock_info()
1858 spin_lock_irq(&ice->reg_lock); in snd_vt1724_pro_internal_clock_get()
1859 if (ice->is_spdif_master(ice)) { in snd_vt1724_pro_internal_clock_get()
1860 ucontrol->value.enumerated.item[0] = ice->hw_rates->count + in snd_vt1724_pro_internal_clock_get()
1861 ice->get_spdif_master_type(ice); in snd_vt1724_pro_internal_clock_get()
1863 rate = ice->get_rate(ice); in snd_vt1724_pro_internal_clock_get()
1864 ucontrol->value.enumerated.item[0] = 0; in snd_vt1724_pro_internal_clock_get()
1865 for (i = 0; i < ice->hw_rates->count; i++) { in snd_vt1724_pro_internal_clock_get()
1866 if (ice->hw_rates->list[i] == rate) { in snd_vt1724_pro_internal_clock_get()
1867 ucontrol->value.enumerated.item[0] = i; in snd_vt1724_pro_internal_clock_get()
1872 spin_unlock_irq(&ice->reg_lock); in snd_vt1724_pro_internal_clock_get()
1878 /* standard external clock - only single type - SPDIF IN */ in stdclock_get_spdif_master_type()
1882 /* setting clock to external - SPDIF */
1901 unsigned int item = ucontrol->value.enumerated.item[0]; in snd_vt1724_pro_internal_clock_put()
1902 unsigned int first_ext_clock = ice->hw_rates->count; in snd_vt1724_pro_internal_clock_put()
1904 if (item > first_ext_clock + ice->ext_clock_count - 1) in snd_vt1724_pro_internal_clock_put()
1905 return -EINVAL; in snd_vt1724_pro_internal_clock_put()
1908 spin_lock_irq(&ice->reg_lock); in snd_vt1724_pro_internal_clock_put()
1909 if (ice->is_spdif_master(ice)) in snd_vt1724_pro_internal_clock_put()
1912 old_rate = ice->get_rate(ice); in snd_vt1724_pro_internal_clock_put()
1915 ice->set_spdif_clock(ice, item - first_ext_clock); in snd_vt1724_pro_internal_clock_put()
1918 /* internal on-card clock */ in snd_vt1724_pro_internal_clock_put()
1919 new_rate = ice->hw_rates->list[item]; in snd_vt1724_pro_internal_clock_put()
1920 ice->pro_rate_default = new_rate; in snd_vt1724_pro_internal_clock_put()
1921 spin_unlock_irq(&ice->reg_lock); in snd_vt1724_pro_internal_clock_put()
1922 snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 1); in snd_vt1724_pro_internal_clock_put()
1923 spin_lock_irq(&ice->reg_lock); in snd_vt1724_pro_internal_clock_put()
1925 spin_unlock_irq(&ice->reg_lock); in snd_vt1724_pro_internal_clock_put()
1931 if (ice->gpio.set_pro_rate) in snd_vt1724_pro_internal_clock_put()
1932 ice->gpio.set_pro_rate(ice, 0); in snd_vt1724_pro_internal_clock_put()
1933 for (i = 0; i < ice->akm_codecs; i++) { in snd_vt1724_pro_internal_clock_put()
1934 if (ice->akm[i].ops.set_rate_val) in snd_vt1724_pro_internal_clock_put()
1935 ice->akm[i].ops.set_rate_val(&ice->akm[i], 0); in snd_vt1724_pro_internal_clock_put()
1954 ucontrol->value.integer.value[0] = PRO_RATE_LOCKED; in snd_vt1724_pro_rate_locking_get()
1964 nval = ucontrol->value.integer.value[0] ? 1 : 0; in snd_vt1724_pro_rate_locking_put()
1965 spin_lock_irq(&ice->reg_lock); in snd_vt1724_pro_rate_locking_put()
1968 spin_unlock_irq(&ice->reg_lock); in snd_vt1724_pro_rate_locking_put()
1985 ucontrol->value.integer.value[0] = PRO_RATE_RESET ? 1 : 0; in snd_vt1724_pro_rate_reset_get()
1995 nval = ucontrol->value.integer.value[0] ? 1 : 0; in snd_vt1724_pro_rate_reset_put()
1996 spin_lock_irq(&ice->reg_lock); in snd_vt1724_pro_rate_reset_put()
1999 spin_unlock_irq(&ice->reg_lock); in snd_vt1724_pro_rate_reset_put()
2020 "H/W In 0", "H/W In 1", /* 1-2 */ in snd_vt1724_pro_route_info()
2021 "IEC958 In L", "IEC958 In R", /* 3-4 */ in snd_vt1724_pro_route_info()
2083 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); in snd_vt1724_pro_route_analog_get()
2084 ucontrol->value.enumerated.item[0] = in snd_vt1724_pro_route_analog_get()
2093 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); in snd_vt1724_pro_route_analog_put()
2095 ucontrol->value.enumerated.item[0], in snd_vt1724_pro_route_analog_put()
2103 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); in snd_vt1724_pro_route_spdif_get()
2104 ucontrol->value.enumerated.item[0] = in snd_vt1724_pro_route_spdif_get()
2113 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); in snd_vt1724_pro_route_spdif_put()
2115 ucontrol->value.enumerated.item[0], in snd_vt1724_pro_route_spdif_put()
2141 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_vt1724_pro_peak_info()
2142 uinfo->count = 22; /* FIXME: for compatibility with ice1712... */ in snd_vt1724_pro_peak_info()
2143 uinfo->value.integer.min = 0; in snd_vt1724_pro_peak_info()
2144 uinfo->value.integer.max = 255; in snd_vt1724_pro_peak_info()
2154 spin_lock_irq(&ice->reg_lock); in snd_vt1724_pro_peak_get()
2157 ucontrol->value.integer.value[idx] = in snd_vt1724_pro_peak_get()
2160 spin_unlock_irq(&ice->reg_lock); in snd_vt1724_pro_peak_get()
2187 [ICE_EEP2_SPDIF] = 0xc1, /* out-en, out-int, out-ext */
2238 while ((inb(ICEREG1724(ice, I2C_CTRL)) & VT1724_I2C_BUSY) && t--) in wait_i2c_busy()
2240 if (t == -1) in wait_i2c_busy()
2241 dev_err(ice->card->dev, "i2c busy timeout\n"); in wait_i2c_busy()
2249 mutex_lock(&ice->i2c_mutex); in snd_vt1724_read_i2c()
2255 mutex_unlock(&ice->i2c_mutex); in snd_vt1724_read_i2c()
2257 dev_dbg(ice->card->dev, "i2c_read: [0x%x,0x%x] = 0x%x\n", dev, addr, val); in snd_vt1724_read_i2c()
2265 mutex_lock(&ice->i2c_mutex); in snd_vt1724_write_i2c()
2268 dev_dbg(ice->card->dev, "i2c_write: [0x%x,0x%x] = 0x%x\n", dev, addr, data); in snd_vt1724_write_i2c()
2274 mutex_unlock(&ice->i2c_mutex); in snd_vt1724_write_i2c()
2285 ice->eeprom.subvendor = 0; in snd_vt1724_read_eeprom()
2287 ice->eeprom.subvendor = in snd_vt1724_read_eeprom()
2292 if (ice->eeprom.subvendor == 0 || in snd_vt1724_read_eeprom()
2293 ice->eeprom.subvendor == (unsigned int)-1) { in snd_vt1724_read_eeprom()
2298 pci_read_config_word(ice->pci, PCI_SUBSYSTEM_VENDOR_ID, in snd_vt1724_read_eeprom()
2300 pci_read_config_word(ice->pci, PCI_SUBSYSTEM_ID, &device); in snd_vt1724_read_eeprom()
2301 ice->eeprom.subvendor = in snd_vt1724_read_eeprom()
2303 if (ice->eeprom.subvendor == 0 || in snd_vt1724_read_eeprom()
2304 ice->eeprom.subvendor == (unsigned int)-1) { in snd_vt1724_read_eeprom()
2305 dev_err(ice->card->dev, in snd_vt1724_read_eeprom()
2307 return -ENXIO; in snd_vt1724_read_eeprom()
2312 for (c = *tbl; c->name; c++) { in snd_vt1724_read_eeprom()
2313 if (modelname && c->model && in snd_vt1724_read_eeprom()
2314 !strcmp(modelname, c->model)) { in snd_vt1724_read_eeprom()
2315 dev_info(ice->card->dev, in snd_vt1724_read_eeprom()
2317 c->name); in snd_vt1724_read_eeprom()
2318 ice->eeprom.subvendor = c->subvendor; in snd_vt1724_read_eeprom()
2319 } else if (c->subvendor != ice->eeprom.subvendor) in snd_vt1724_read_eeprom()
2321 ice->card_info = c; in snd_vt1724_read_eeprom()
2322 if (!c->eeprom_size || !c->eeprom_data) in snd_vt1724_read_eeprom()
2325 dev_dbg(ice->card->dev, "using the defined eeprom..\n"); in snd_vt1724_read_eeprom()
2326 ice->eeprom.version = 2; in snd_vt1724_read_eeprom()
2327 ice->eeprom.size = c->eeprom_size + 6; in snd_vt1724_read_eeprom()
2328 memcpy(ice->eeprom.data, c->eeprom_data, c->eeprom_size); in snd_vt1724_read_eeprom()
2332 dev_warn(ice->card->dev, "No matching model found for ID 0x%x\n", in snd_vt1724_read_eeprom()
2333 ice->eeprom.subvendor); in snd_vt1724_read_eeprom()
2335 /* assume AC97-only card which can suspend without additional code */ in snd_vt1724_read_eeprom()
2336 ice->pm_suspend_enabled = 1; in snd_vt1724_read_eeprom()
2340 ice->eeprom.size = snd_vt1724_read_i2c(ice, dev, 0x04); in snd_vt1724_read_eeprom()
2341 if (ice->eeprom.size < 6) in snd_vt1724_read_eeprom()
2342 ice->eeprom.size = 32; in snd_vt1724_read_eeprom()
2343 else if (ice->eeprom.size > 32) { in snd_vt1724_read_eeprom()
2344 dev_err(ice->card->dev, "Invalid EEPROM (size = %i)\n", in snd_vt1724_read_eeprom()
2345 ice->eeprom.size); in snd_vt1724_read_eeprom()
2346 return -EIO; in snd_vt1724_read_eeprom()
2348 ice->eeprom.version = snd_vt1724_read_i2c(ice, dev, 0x05); in snd_vt1724_read_eeprom()
2349 if (ice->eeprom.version != 1 && ice->eeprom.version != 2) in snd_vt1724_read_eeprom()
2350 dev_warn(ice->card->dev, "Invalid EEPROM version %i\n", in snd_vt1724_read_eeprom()
2351 ice->eeprom.version); in snd_vt1724_read_eeprom()
2352 size = ice->eeprom.size - 6; in snd_vt1724_read_eeprom()
2354 ice->eeprom.data[i] = snd_vt1724_read_i2c(ice, dev, i + 6); in snd_vt1724_read_eeprom()
2357 ice->eeprom.gpiomask = eeprom_triple(ice, ICE_EEP2_GPIO_MASK); in snd_vt1724_read_eeprom()
2358 ice->eeprom.gpiostate = eeprom_triple(ice, ICE_EEP2_GPIO_STATE); in snd_vt1724_read_eeprom()
2359 ice->eeprom.gpiodir = eeprom_triple(ice, ICE_EEP2_GPIO_DIR); in snd_vt1724_read_eeprom()
2378 outb(ice->eeprom.data[ICE_EEP2_SYSCONF], ICEREG1724(ice, SYS_CFG)); in snd_vt1724_chip_init()
2379 outb(ice->eeprom.data[ICE_EEP2_ACLINK], ICEREG1724(ice, AC97_CFG)); in snd_vt1724_chip_init()
2380 outb(ice->eeprom.data[ICE_EEP2_I2S], ICEREG1724(ice, I2S_FEATURES)); in snd_vt1724_chip_init()
2381 outb(ice->eeprom.data[ICE_EEP2_SPDIF], ICEREG1724(ice, SPDIF_CFG)); in snd_vt1724_chip_init()
2383 ice->gpio.write_mask = ice->eeprom.gpiomask; in snd_vt1724_chip_init()
2384 ice->gpio.direction = ice->eeprom.gpiodir; in snd_vt1724_chip_init()
2385 snd_vt1724_set_gpio_mask(ice, ice->eeprom.gpiomask); in snd_vt1724_chip_init()
2386 snd_vt1724_set_gpio_dir(ice, ice->eeprom.gpiodir); in snd_vt1724_chip_init()
2387 snd_vt1724_set_gpio_data(ice, ice->eeprom.gpiostate); in snd_vt1724_chip_init()
2407 if (snd_BUG_ON(!ice->pcm)) in snd_vt1724_spdif_build_controls()
2408 return -EIO; in snd_vt1724_spdif_build_controls()
2410 if (!ice->own_routing) { in snd_vt1724_spdif_build_controls()
2411 err = snd_ctl_add(ice->card, in snd_vt1724_spdif_build_controls()
2417 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_vt1724_spdif_switch, ice)); in snd_vt1724_spdif_build_controls()
2421 err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_vt1724_spdif_default, ice)); in snd_vt1724_spdif_build_controls()
2424 kctl->id.device = ice->pcm->device; in snd_vt1724_spdif_build_controls()
2425 err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_vt1724_spdif_maskc, ice)); in snd_vt1724_spdif_build_controls()
2428 kctl->id.device = ice->pcm->device; in snd_vt1724_spdif_build_controls()
2429 err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_vt1724_spdif_maskp, ice)); in snd_vt1724_spdif_build_controls()
2432 kctl->id.device = ice->pcm->device; in snd_vt1724_spdif_build_controls()
2434 err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_vt1724_spdif_stream, ice)); in snd_vt1724_spdif_build_controls()
2437 kctl->id.device = ice->pcm->device; in snd_vt1724_spdif_build_controls()
2438 ice->spdif.stream_ctl = kctl; in snd_vt1724_spdif_build_controls()
2448 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_vt1724_eeprom, ice)); in snd_vt1724_build_controls()
2451 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_vt1724_pro_internal_clock, ice)); in snd_vt1724_build_controls()
2455 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_vt1724_pro_rate_locking, ice)); in snd_vt1724_build_controls()
2458 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_vt1724_pro_rate_reset, ice)); in snd_vt1724_build_controls()
2462 if (!ice->own_routing && ice->num_total_dacs > 0) { in snd_vt1724_build_controls()
2464 tmp.count = ice->num_total_dacs; in snd_vt1724_build_controls()
2465 if (ice->vt1720 && tmp.count > 2) in snd_vt1724_build_controls()
2467 err = snd_ctl_add(ice->card, snd_ctl_new1(&tmp, ice)); in snd_vt1724_build_controls()
2472 return snd_ctl_add(ice->card, in snd_vt1724_build_controls()
2478 if (!ice->port) in snd_vt1724_free()
2483 /* --- */ in snd_vt1724_free()
2485 if (ice->irq >= 0) in snd_vt1724_free()
2486 free_irq(ice->irq, ice); in snd_vt1724_free()
2487 pci_release_regions(ice->pci); in snd_vt1724_free()
2489 pci_disable_device(ice->pci); in snd_vt1724_free()
2490 kfree(ice->spec); in snd_vt1724_free()
2497 struct snd_ice1712 *ice = device->device_data; in snd_vt1724_dev_free()
2522 return -ENOMEM; in snd_vt1724_create()
2524 ice->vt1724 = 1; in snd_vt1724_create()
2525 spin_lock_init(&ice->reg_lock); in snd_vt1724_create()
2526 mutex_init(&ice->gpio_mutex); in snd_vt1724_create()
2527 mutex_init(&ice->open_mutex); in snd_vt1724_create()
2528 mutex_init(&ice->i2c_mutex); in snd_vt1724_create()
2529 ice->gpio.set_mask = snd_vt1724_set_gpio_mask; in snd_vt1724_create()
2530 ice->gpio.get_mask = snd_vt1724_get_gpio_mask; in snd_vt1724_create()
2531 ice->gpio.set_dir = snd_vt1724_set_gpio_dir; in snd_vt1724_create()
2532 ice->gpio.get_dir = snd_vt1724_get_gpio_dir; in snd_vt1724_create()
2533 ice->gpio.set_data = snd_vt1724_set_gpio_data; in snd_vt1724_create()
2534 ice->gpio.get_data = snd_vt1724_get_gpio_data; in snd_vt1724_create()
2535 ice->card = card; in snd_vt1724_create()
2536 ice->pci = pci; in snd_vt1724_create()
2537 ice->irq = -1; in snd_vt1724_create()
2541 card->private_data = ice; in snd_vt1724_create()
2549 ice->port = pci_resource_start(pci, 0); in snd_vt1724_create()
2550 ice->profi_port = pci_resource_start(pci, 1); in snd_vt1724_create()
2552 if (request_irq(pci->irq, snd_vt1724_interrupt, in snd_vt1724_create()
2554 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); in snd_vt1724_create()
2556 return -EIO; in snd_vt1724_create()
2559 ice->irq = pci->irq; in snd_vt1724_create()
2560 card->sync_irq = ice->irq; in snd_vt1724_create()
2565 return -EIO; in snd_vt1724_create()
2569 return -EIO; in snd_vt1724_create()
2599 return -ENODEV; in snd_vt1724_probe()
2602 return -ENOENT; in snd_vt1724_probe()
2605 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, in snd_vt1724_probe()
2610 strcpy(card->driver, "ICE1724"); in snd_vt1724_probe()
2611 strcpy(card->shortname, "ICEnsemble ICE1724"); in snd_vt1724_probe()
2620 ice->ext_clock_count = 0; in snd_vt1724_probe()
2623 for (c = *tbl; c->name; c++) { in snd_vt1724_probe()
2624 if ((model[dev] && c->model && in snd_vt1724_probe()
2625 !strcmp(model[dev], c->model)) || in snd_vt1724_probe()
2626 (c->subvendor == ice->eeprom.subvendor)) { in snd_vt1724_probe()
2627 strcpy(card->shortname, c->name); in snd_vt1724_probe()
2628 if (c->driver) /* specific driver? */ in snd_vt1724_probe()
2629 strcpy(card->driver, c->driver); in snd_vt1724_probe()
2630 if (c->chip_init) { in snd_vt1724_probe()
2631 err = c->chip_init(ice); in snd_vt1724_probe()
2645 * ICE1712 has only one for both (mixed up). in snd_vt1724_probe()
2651 ice->pro_rate_default = PRO_RATE_DEFAULT; in snd_vt1724_probe()
2652 if (!ice->is_spdif_master) in snd_vt1724_probe()
2653 ice->is_spdif_master = stdclock_is_spdif_master; in snd_vt1724_probe()
2654 if (!ice->get_rate) in snd_vt1724_probe()
2655 ice->get_rate = stdclock_get_rate; in snd_vt1724_probe()
2656 if (!ice->set_rate) in snd_vt1724_probe()
2657 ice->set_rate = stdclock_set_rate; in snd_vt1724_probe()
2658 if (!ice->set_mclk) in snd_vt1724_probe()
2659 ice->set_mclk = stdclock_set_mclk; in snd_vt1724_probe()
2660 if (!ice->set_spdif_clock) in snd_vt1724_probe()
2661 ice->set_spdif_clock = stdclock_set_spdif_clock; in snd_vt1724_probe()
2662 if (!ice->get_spdif_master_type) in snd_vt1724_probe()
2663 ice->get_spdif_master_type = stdclock_get_spdif_master_type; in snd_vt1724_probe()
2664 if (!ice->ext_clock_names) in snd_vt1724_probe()
2665 ice->ext_clock_names = ext_clock_names; in snd_vt1724_probe()
2666 if (!ice->ext_clock_count) in snd_vt1724_probe()
2667 ice->ext_clock_count = ARRAY_SIZE(ext_clock_names); in snd_vt1724_probe()
2669 if (!ice->hw_rates) in snd_vt1724_probe()
2702 if (ice->pcm && ice->has_spdif) { /* has SPDIF I/O */ in snd_vt1724_probe()
2710 if (c->build_controls) { in snd_vt1724_probe()
2711 err = c->build_controls(ice); in snd_vt1724_probe()
2718 if (!c->no_mpu401) { in snd_vt1724_probe()
2719 if (ice->eeprom.data[ICE_EEP2_SYSCONF] & VT1724_CFG_MPU401) { in snd_vt1724_probe()
2727 ice->rmidi[0] = rmidi; in snd_vt1724_probe()
2728 rmidi->private_data = ice; in snd_vt1724_probe()
2729 strcpy(rmidi->name, "ICE1724 MIDI"); in snd_vt1724_probe()
2730 rmidi->info_flags = SNDRV_RAWMIDI_INFO_OUTPUT | in snd_vt1724_probe()
2747 sprintf(card->longname, "%s at 0x%lx, irq %i", in snd_vt1724_probe()
2748 card->shortname, ice->port, ice->irq); in snd_vt1724_probe()
2763 struct snd_ice1712 *ice = card->private_data; in snd_vt1724_remove()
2765 if (ice->card_info && ice->card_info->chip_exit) in snd_vt1724_remove()
2766 ice->card_info->chip_exit(ice); in snd_vt1724_remove()
2774 struct snd_ice1712 *ice = card->private_data; in snd_vt1724_suspend()
2776 if (!ice->pm_suspend_enabled) in snd_vt1724_suspend()
2781 snd_ac97_suspend(ice->ac97); in snd_vt1724_suspend()
2783 spin_lock_irq(&ice->reg_lock); in snd_vt1724_suspend()
2784 ice->pm_saved_is_spdif_master = ice->is_spdif_master(ice); in snd_vt1724_suspend()
2785 ice->pm_saved_spdif_ctrl = inw(ICEMT1724(ice, SPDIF_CTRL)); in snd_vt1724_suspend()
2786 ice->pm_saved_spdif_cfg = inb(ICEREG1724(ice, SPDIF_CFG)); in snd_vt1724_suspend()
2787 ice->pm_saved_route = inl(ICEMT1724(ice, ROUTE_PLAYBACK)); in snd_vt1724_suspend()
2788 spin_unlock_irq(&ice->reg_lock); in snd_vt1724_suspend()
2790 if (ice->pm_suspend) in snd_vt1724_suspend()
2791 ice->pm_suspend(ice); in snd_vt1724_suspend()
2798 struct snd_ice1712 *ice = card->private_data; in snd_vt1724_resume()
2800 if (!ice->pm_suspend_enabled) in snd_vt1724_resume()
2807 return -EIO; in snd_vt1724_resume()
2810 if (ice->pm_resume) in snd_vt1724_resume()
2811 ice->pm_resume(ice); in snd_vt1724_resume()
2813 if (ice->pm_saved_is_spdif_master) { in snd_vt1724_resume()
2815 ice->set_spdif_clock(ice, 0); in snd_vt1724_resume()
2817 /* internal on-card clock */ in snd_vt1724_resume()
2819 if (ice->cur_rate) in snd_vt1724_resume()
2820 rate = ice->cur_rate; in snd_vt1724_resume()
2822 rate = ice->pro_rate_default; in snd_vt1724_resume()
2826 update_spdif_bits(ice, ice->pm_saved_spdif_ctrl); in snd_vt1724_resume()
2828 outb(ice->pm_saved_spdif_cfg, ICEREG1724(ice, SPDIF_CFG)); in snd_vt1724_resume()
2829 outl(ice->pm_saved_route, ICEMT1724(ice, ROUTE_PLAYBACK)); in snd_vt1724_resume()
2831 snd_ac97_resume(ice->ac97); in snd_vt1724_resume()