Lines Matching +full:assign +full:- +full:clock +full:- +full:rates

1 // SPDX-License-Identifier: GPL-2.0-or-later
10 - spdif nonaudio consumer mode does not work (at least with my
11 Sony STR-DB830)
18 * split the code to several files. each low-level routine
25 * I also haven't done anything with the internal S/PDIF transmitter or the MPU-401
40 #include <linux/dma-mapping.h>
70 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
75 static int cs8427_timeout[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 500}; /* CS8427 S/PDIF transcei…
85 MODULE_PARM_DESC(omni, "Enable Midiman M-Audio Delta Omni I/O support.");
112 /* check whether the clock mode is spdif-in */
139 struct snd_ice1712 *ice = ac97->private_data; in snd_ice1712_ac97_write()
163 struct snd_ice1712 *ice = ac97->private_data; in snd_ice1712_ac97_read()
193 struct snd_ice1712 *ice = ac97->private_data; in snd_ice1712_pro_ac97_write()
218 struct snd_ice1712 *ice = ac97->private_data; in snd_ice1712_pro_ac97_read()
249 ucontrol->value.integer.value[0] = inb(ICEMT(ice, MONITOR_ROUTECTRL)) & ICE1712_ROUTE_AC97 ? 1 : 0; in snd_ice1712_digmix_route_ac97_get()
258 spin_lock_irq(&ice->reg_lock); in snd_ice1712_digmix_route_ac97_put()
261 if (ucontrol->value.integer.value[0]) in snd_ice1712_digmix_route_ac97_put()
264 spin_unlock_irq(&ice->reg_lock); in snd_ice1712_digmix_route_ac97_put()
283 inb(ICEREG(ice, DATA)); /* dummy read for pci-posting */ in snd_ice1712_set_gpio_dir()
299 inb(ICEREG(ice, DATA)); /* dummy read for pci-posting */ in snd_ice1712_set_gpio_mask()
310 inb(ICEREG(ice, DATA)); /* dummy read for pci-posting */ in snd_ice1712_set_gpio_data()
320 * change the input clock selection
321 * spdif_clock = 1 - IEC958 input, 0 - Envy24
329 snd_i2c_lock(ice->i2c); in snd_ice1712_cs8427_set_input_clock()
330 if (snd_i2c_sendbytes(ice->cs8427, reg, 1) != 1) { in snd_ice1712_cs8427_set_input_clock()
331 snd_i2c_unlock(ice->i2c); in snd_ice1712_cs8427_set_input_clock()
332 return -EIO; in snd_ice1712_cs8427_set_input_clock()
334 if (snd_i2c_readbytes(ice->cs8427, &val, 1) != 1) { in snd_ice1712_cs8427_set_input_clock()
335 snd_i2c_unlock(ice->i2c); in snd_ice1712_cs8427_set_input_clock()
336 return -EIO; in snd_ice1712_cs8427_set_input_clock()
345 if (snd_i2c_sendbytes(ice->cs8427, reg, 2) != 2) { in snd_ice1712_cs8427_set_input_clock()
346 res = -EIO; in snd_ice1712_cs8427_set_input_clock()
351 snd_i2c_unlock(ice->i2c); in snd_ice1712_cs8427_set_input_clock()
360 snd_cs8427_iec958_active(ice->cs8427, 1); in open_cs8427()
365 snd_cs8427_iec958_active(ice->cs8427, 0); in close_cs8427()
370 snd_cs8427_iec958_pcm(ice->cs8427, rate); in setup_cs8427()
380 err = snd_cs8427_create(ice->i2c, addr, in snd_ice1712_init_cs8427()
381 (ice->cs8427_timeout * HZ) / 1000, &ice->cs8427); in snd_ice1712_init_cs8427()
383 dev_err(ice->card->dev, "CS8427 initialization failed\n"); in snd_ice1712_init_cs8427()
386 ice->spdif.ops.open = open_cs8427; in snd_ice1712_init_cs8427()
387 ice->spdif.ops.close = close_cs8427; in snd_ice1712_init_cs8427()
388 ice->spdif.ops.setup_rate = setup_cs8427; in snd_ice1712_init_cs8427()
394 /* change CS8427 clock source too */ in snd_ice1712_set_input_clock_source()
395 if (ice->cs8427) in snd_ice1712_set_input_clock_source()
400 for (i = 0; i < ice->akm_codecs; i++) { in snd_ice1712_set_input_clock_source()
401 if (ice->akm[i].ops.set_rate_val) in snd_ice1712_set_input_clock_source()
402 ice->akm[i].ops.set_rate_val(&ice->akm[i], 0); in snd_ice1712_set_input_clock_source()
423 if (ice->rmidi[0]) in snd_ice1712_interrupt()
424 snd_mpu401_uart_interrupt(irq, ice->rmidi[0]->private_data); in snd_ice1712_interrupt()
431 if (ice->rmidi[1]) in snd_ice1712_interrupt()
432 snd_mpu401_uart_interrupt(irq, ice->rmidi[1]->private_data); in snd_ice1712_interrupt()
439 if (ice->playback_pro_substream) in snd_ice1712_interrupt()
440 snd_pcm_period_elapsed(ice->playback_pro_substream); in snd_ice1712_interrupt()
444 if (ice->capture_pro_substream) in snd_ice1712_interrupt()
445 snd_pcm_period_elapsed(ice->capture_pro_substream); in snd_ice1712_interrupt()
456 /* dev_dbg(ice->card->dev, "pbkstatus = 0x%x\n", pbkstatus); */ in snd_ice1712_interrupt()
460 substream = ice->playback_con_substream_ds[idx]; in snd_ice1712_interrupt()
468 if (ice->capture_con_substream) in snd_ice1712_interrupt()
469 snd_pcm_period_elapsed(ice->capture_con_substream); in snd_ice1712_interrupt()
473 if (ice->playback_con_substream) in snd_ice1712_interrupt()
474 snd_pcm_period_elapsed(ice->playback_con_substream); in snd_ice1712_interrupt()
483 * PCM part - consumer I/O
493 spin_lock(&ice->reg_lock); in snd_ice1712_playback_trigger()
504 result = -EINVAL; in snd_ice1712_playback_trigger()
507 spin_unlock(&ice->reg_lock); in snd_ice1712_playback_trigger()
518 spin_lock(&ice->reg_lock); in snd_ice1712_playback_ds_trigger()
519 tmp = snd_ice1712_ds_read(ice, substream->number * 2, ICE1712_DSC_CONTROL); in snd_ice1712_playback_ds_trigger()
529 result = -EINVAL; in snd_ice1712_playback_ds_trigger()
531 snd_ice1712_ds_write(ice, substream->number * 2, ICE1712_DSC_CONTROL, tmp); in snd_ice1712_playback_ds_trigger()
532 spin_unlock(&ice->reg_lock); in snd_ice1712_playback_ds_trigger()
543 spin_lock(&ice->reg_lock); in snd_ice1712_capture_trigger()
550 result = -EINVAL; in snd_ice1712_capture_trigger()
553 spin_unlock(&ice->reg_lock); in snd_ice1712_capture_trigger()
560 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ice1712_playback_prepare()
563 period_size = (snd_pcm_lib_period_bytes(substream) >> 2) - 1; in snd_ice1712_playback_prepare()
564 buf_size = snd_pcm_lib_buffer_bytes(substream) - 1; in snd_ice1712_playback_prepare()
566 if (snd_pcm_format_width(runtime->format) == 16) in snd_ice1712_playback_prepare()
568 if (runtime->channels == 2) in snd_ice1712_playback_prepare()
570 rate = (runtime->rate * 8192) / 375; in snd_ice1712_playback_prepare()
573 spin_lock_irq(&ice->reg_lock); in snd_ice1712_playback_prepare()
574 outb(0, ice->ddma_port + 15); in snd_ice1712_playback_prepare()
575 outb(ICE1712_DMA_MODE_WRITE | ICE1712_DMA_AUTOINIT, ice->ddma_port + 0x0b); in snd_ice1712_playback_prepare()
576 outl(runtime->dma_addr, ice->ddma_port + 0); in snd_ice1712_playback_prepare()
577 outw(buf_size, ice->ddma_port + 4); in snd_ice1712_playback_prepare()
586 spin_unlock_irq(&ice->reg_lock); in snd_ice1712_playback_prepare()
593 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ice1712_playback_ds_prepare()
596 period_size = snd_pcm_lib_period_bytes(substream) - 1; in snd_ice1712_playback_ds_prepare()
598 if (snd_pcm_format_width(runtime->format) == 16) in snd_ice1712_playback_ds_prepare()
600 if (runtime->channels == 2) in snd_ice1712_playback_ds_prepare()
602 rate = (runtime->rate * 8192) / 375; in snd_ice1712_playback_ds_prepare()
605 ice->playback_con_active_buf[substream->number] = 0; in snd_ice1712_playback_ds_prepare()
606 ice->playback_con_virt_addr[substream->number] = runtime->dma_addr; in snd_ice1712_playback_ds_prepare()
607 chn = substream->number * 2; in snd_ice1712_playback_ds_prepare()
608 spin_lock_irq(&ice->reg_lock); in snd_ice1712_playback_ds_prepare()
609 snd_ice1712_ds_write(ice, chn, ICE1712_DSC_ADDR0, runtime->dma_addr); in snd_ice1712_playback_ds_prepare()
611 …snd_ice1712_ds_write(ice, chn, ICE1712_DSC_ADDR1, runtime->dma_addr + (runtime->periods > 1 ? peri… in snd_ice1712_playback_ds_prepare()
616 if (runtime->channels == 2) { in snd_ice1712_playback_ds_prepare()
620 spin_unlock_irq(&ice->reg_lock); in snd_ice1712_playback_ds_prepare()
627 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ice1712_capture_prepare()
631 period_size = (snd_pcm_lib_period_bytes(substream) >> 2) - 1; in snd_ice1712_capture_prepare()
632 buf_size = snd_pcm_lib_buffer_bytes(substream) - 1; in snd_ice1712_capture_prepare()
634 if (snd_pcm_format_width(runtime->format) == 16) in snd_ice1712_capture_prepare()
636 if (runtime->channels == 2) in snd_ice1712_capture_prepare()
638 spin_lock_irq(&ice->reg_lock); in snd_ice1712_capture_prepare()
639 outl(ice->capture_con_virt_addr = runtime->dma_addr, ICEREG(ice, CONCAP_ADDR)); in snd_ice1712_capture_prepare()
644 spin_unlock_irq(&ice->reg_lock); in snd_ice1712_capture_prepare()
645 snd_ac97_set_rate(ice->ac97, AC97_PCM_LR_ADC_RATE, runtime->rate); in snd_ice1712_capture_prepare()
652 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ice1712_playback_pointer()
657 ptr = runtime->buffer_size - inw(ice->ddma_port + 4); in snd_ice1712_playback_pointer()
658 ptr = bytes_to_frames(substream->runtime, ptr); in snd_ice1712_playback_pointer()
659 if (ptr == runtime->buffer_size) in snd_ice1712_playback_pointer()
670 if (!(snd_ice1712_ds_read(ice, substream->number * 2, ICE1712_DSC_CONTROL) & 1)) in snd_ice1712_playback_ds_pointer()
672 if (ice->playback_con_active_buf[substream->number]) in snd_ice1712_playback_ds_pointer()
676 ptr = snd_ice1712_ds_read(ice, substream->number * 2, addr) - in snd_ice1712_playback_ds_pointer()
677 ice->playback_con_virt_addr[substream->number]; in snd_ice1712_playback_ds_pointer()
678 ptr = bytes_to_frames(substream->runtime, ptr); in snd_ice1712_playback_ds_pointer()
679 if (ptr == substream->runtime->buffer_size) in snd_ice1712_playback_ds_pointer()
691 ptr = inl(ICEREG(ice, CONCAP_ADDR)) - ice->capture_con_virt_addr; in snd_ice1712_capture_pointer()
692 ptr = bytes_to_frames(substream->runtime, ptr); in snd_ice1712_capture_pointer()
693 if (ptr == substream->runtime->buffer_size) in snd_ice1712_capture_pointer()
704 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000,
723 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000,
741 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000,
756 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ice1712_playback_open()
759 ice->playback_con_substream = substream; in snd_ice1712_playback_open()
760 runtime->hw = snd_ice1712_playback; in snd_ice1712_playback_open()
766 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ice1712_playback_ds_open()
770 ice->playback_con_substream_ds[substream->number] = substream; in snd_ice1712_playback_ds_open()
771 runtime->hw = snd_ice1712_playback_ds; in snd_ice1712_playback_ds_open()
772 spin_lock_irq(&ice->reg_lock); in snd_ice1712_playback_ds_open()
773 tmp = inw(ICEDS(ice, INTMASK)) & ~(1 << (substream->number * 2)); in snd_ice1712_playback_ds_open()
775 spin_unlock_irq(&ice->reg_lock); in snd_ice1712_playback_ds_open()
781 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ice1712_capture_open()
784 ice->capture_con_substream = substream; in snd_ice1712_capture_open()
785 runtime->hw = snd_ice1712_capture; in snd_ice1712_capture_open()
786 runtime->hw.rates = ice->ac97->rates[AC97_RATES_ADC]; in snd_ice1712_capture_open()
787 if (!(runtime->hw.rates & SNDRV_PCM_RATE_8000)) in snd_ice1712_capture_open()
788 runtime->hw.rate_min = 48000; in snd_ice1712_capture_open()
796 ice->playback_con_substream = NULL; in snd_ice1712_playback_close()
805 spin_lock_irq(&ice->reg_lock); in snd_ice1712_playback_ds_close()
806 tmp = inw(ICEDS(ice, INTMASK)) | (3 << (substream->number * 2)); in snd_ice1712_playback_ds_close()
808 spin_unlock_irq(&ice->reg_lock); in snd_ice1712_playback_ds_close()
809 ice->playback_con_substream_ds[substream->number] = NULL; in snd_ice1712_playback_ds_close()
817 ice->capture_con_substream = NULL; in snd_ice1712_capture_close()
850 err = snd_pcm_new(ice->card, "ICE1712 consumer", device, 1, 1, &pcm); in snd_ice1712_pcm()
857 pcm->private_data = ice; in snd_ice1712_pcm()
858 pcm->info_flags = 0; in snd_ice1712_pcm()
859 strcpy(pcm->name, "ICE1712 consumer"); in snd_ice1712_pcm()
860 ice->pcm = pcm; in snd_ice1712_pcm()
863 &ice->pci->dev, 64*1024, 64*1024); in snd_ice1712_pcm()
865 dev_warn(ice->card->dev, in snd_ice1712_pcm()
866 "Consumer PCM code does not work well at the moment --jk\n"); in snd_ice1712_pcm()
876 err = snd_pcm_new(ice->card, "ICE1712 consumer (DS)", device, 6, 0, &pcm); in snd_ice1712_pcm_ds()
882 pcm->private_data = ice; in snd_ice1712_pcm_ds()
883 pcm->info_flags = 0; in snd_ice1712_pcm_ds()
884 strcpy(pcm->name, "ICE1712 consumer (DS)"); in snd_ice1712_pcm_ds()
885 ice->pcm_ds = pcm; in snd_ice1712_pcm_ds()
888 &ice->pci->dev, 64*1024, 128*1024); in snd_ice1712_pcm_ds()
894 * PCM code - professional part (multitrack)
897 static const unsigned int rates[] = { 8000, 9600, 11025, 12000, 16000, 22050, 24000, variable
901 .count = ARRAY_SIZE(rates),
902 .list = rates,
916 if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) in snd_ice1712_pro_trigger()
917 return -EINVAL; in snd_ice1712_pro_trigger()
920 spin_lock(&ice->reg_lock); in snd_ice1712_pro_trigger()
927 spin_unlock(&ice->reg_lock); in snd_ice1712_pro_trigger()
938 if (s == ice->playback_pro_substream) { in snd_ice1712_pro_trigger()
941 } else if (s == ice->capture_pro_substream) { in snd_ice1712_pro_trigger()
946 spin_lock(&ice->reg_lock); in snd_ice1712_pro_trigger()
953 spin_unlock(&ice->reg_lock); in snd_ice1712_pro_trigger()
957 return -EINVAL; in snd_ice1712_pro_trigger()
991 spin_lock_irqsave(&ice->reg_lock, flags); in snd_ice1712_set_pro_rate()
996 spin_unlock_irqrestore(&ice->reg_lock, flags); in snd_ice1712_set_pro_rate()
1006 ice->cur_rate = rate; in snd_ice1712_set_pro_rate()
1008 spin_unlock_irqrestore(&ice->reg_lock, flags); in snd_ice1712_set_pro_rate()
1010 if (ice->gpio.set_pro_rate) in snd_ice1712_set_pro_rate()
1011 ice->gpio.set_pro_rate(ice, rate); in snd_ice1712_set_pro_rate()
1012 for (i = 0; i < ice->akm_codecs; i++) { in snd_ice1712_set_pro_rate()
1013 if (ice->akm[i].ops.set_rate_val) in snd_ice1712_set_pro_rate()
1014 ice->akm[i].ops.set_rate_val(&ice->akm[i], rate); in snd_ice1712_set_pro_rate()
1016 if (ice->spdif.ops.setup_rate) in snd_ice1712_set_pro_rate()
1017 ice->spdif.ops.setup_rate(ice, rate); in snd_ice1712_set_pro_rate()
1024 ice->playback_pro_size = snd_pcm_lib_buffer_bytes(substream); in snd_ice1712_playback_pro_prepare()
1025 spin_lock_irq(&ice->reg_lock); in snd_ice1712_playback_pro_prepare()
1026 outl(substream->runtime->dma_addr, ICEMT(ice, PLAYBACK_ADDR)); in snd_ice1712_playback_pro_prepare()
1027 outw((ice->playback_pro_size >> 2) - 1, ICEMT(ice, PLAYBACK_SIZE)); in snd_ice1712_playback_pro_prepare()
1028 outw((snd_pcm_lib_period_bytes(substream) >> 2) - 1, ICEMT(ice, PLAYBACK_COUNT)); in snd_ice1712_playback_pro_prepare()
1029 spin_unlock_irq(&ice->reg_lock); in snd_ice1712_playback_pro_prepare()
1047 ice->capture_pro_size = snd_pcm_lib_buffer_bytes(substream); in snd_ice1712_capture_pro_prepare()
1048 spin_lock_irq(&ice->reg_lock); in snd_ice1712_capture_pro_prepare()
1049 outl(substream->runtime->dma_addr, ICEMT(ice, CAPTURE_ADDR)); in snd_ice1712_capture_pro_prepare()
1050 outw((ice->capture_pro_size >> 2) - 1, ICEMT(ice, CAPTURE_SIZE)); in snd_ice1712_capture_pro_prepare()
1051 outw((snd_pcm_lib_period_bytes(substream) >> 2) - 1, ICEMT(ice, CAPTURE_COUNT)); in snd_ice1712_capture_pro_prepare()
1052 spin_unlock_irq(&ice->reg_lock); in snd_ice1712_capture_pro_prepare()
1072 ptr = ice->playback_pro_size - (inw(ICEMT(ice, PLAYBACK_SIZE)) << 2); in snd_ice1712_playback_pro_pointer()
1073 ptr = bytes_to_frames(substream->runtime, ptr); in snd_ice1712_playback_pro_pointer()
1074 if (ptr == substream->runtime->buffer_size) in snd_ice1712_playback_pro_pointer()
1086 ptr = ice->capture_pro_size - (inw(ICEMT(ice, CAPTURE_SIZE)) << 2); in snd_ice1712_capture_pro_pointer()
1087 ptr = bytes_to_frames(substream->runtime, ptr); in snd_ice1712_capture_pro_pointer()
1088 if (ptr == substream->runtime->buffer_size) in snd_ice1712_capture_pro_pointer()
1099 .rates = SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_8000_96000,
1118 .rates = SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_8000_96000,
1133 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ice1712_playback_pro_open()
1136 ice->playback_pro_substream = substream; in snd_ice1712_playback_pro_open()
1137 runtime->hw = snd_ice1712_playback_pro; in snd_ice1712_playback_pro_open()
1142 runtime->hw.rate_min = PRO_RATE_DEFAULT; in snd_ice1712_playback_pro_open()
1143 runtime->hw.rate_max = PRO_RATE_DEFAULT; in snd_ice1712_playback_pro_open()
1146 if (ice->spdif.ops.open) in snd_ice1712_playback_pro_open()
1147 ice->spdif.ops.open(ice, substream); in snd_ice1712_playback_pro_open()
1155 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ice1712_capture_pro_open()
1157 ice->capture_pro_substream = substream; in snd_ice1712_capture_pro_open()
1158 runtime->hw = snd_ice1712_capture_pro; in snd_ice1712_capture_pro_open()
1163 runtime->hw.rate_min = PRO_RATE_DEFAULT; in snd_ice1712_capture_pro_open()
1164 runtime->hw.rate_max = PRO_RATE_DEFAULT; in snd_ice1712_capture_pro_open()
1176 ice->playback_pro_substream = NULL; in snd_ice1712_playback_pro_close()
1177 if (ice->spdif.ops.close) in snd_ice1712_playback_pro_close()
1178 ice->spdif.ops.close(ice, substream); in snd_ice1712_playback_pro_close()
1189 ice->capture_pro_substream = NULL; in snd_ice1712_capture_pro_close()
1216 err = snd_pcm_new(ice->card, "ICE1712 multi", device, 1, 1, &pcm); in snd_ice1712_pcm_profi()
1223 pcm->private_data = ice; in snd_ice1712_pcm_profi()
1224 pcm->info_flags = 0; in snd_ice1712_pcm_profi()
1225 strcpy(pcm->name, "ICE1712 multi"); in snd_ice1712_pcm_profi()
1228 &ice->pci->dev, 256*1024, 256*1024); in snd_ice1712_pcm_profi()
1230 ice->pcm_pro = pcm; in snd_ice1712_pcm_profi()
1232 if (ice->cs8427) { in snd_ice1712_pcm_profi()
1233 /* assign channels to iec958 */ in snd_ice1712_pcm_profi()
1234 err = snd_cs8427_iec958_build(ice->cs8427, in snd_ice1712_pcm_profi()
1235 pcm->streams[0].substream, in snd_ice1712_pcm_profi()
1236 pcm->streams[1].substream); in snd_ice1712_pcm_profi()
1250 unsigned int vol = ice->pro_volumes[index]; in snd_ice1712_update_volume()
1253 val |= (vol & 0x8000) == 0 ? (96 - (vol & 0x7f)) : 0x7f; in snd_ice1712_update_volume()
1254 val |= ((vol & 0x80000000) == 0 ? (96 - ((vol >> 16) & 0x7f)) : 0x7f) << 8; in snd_ice1712_update_volume()
1264 int priv_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + in snd_ice1712_pro_mixer_switch_get()
1265 kcontrol->private_value; in snd_ice1712_pro_mixer_switch_get()
1267 spin_lock_irq(&ice->reg_lock); in snd_ice1712_pro_mixer_switch_get()
1268 ucontrol->value.integer.value[0] = in snd_ice1712_pro_mixer_switch_get()
1269 !((ice->pro_volumes[priv_idx] >> 15) & 1); in snd_ice1712_pro_mixer_switch_get()
1270 ucontrol->value.integer.value[1] = in snd_ice1712_pro_mixer_switch_get()
1271 !((ice->pro_volumes[priv_idx] >> 31) & 1); in snd_ice1712_pro_mixer_switch_get()
1272 spin_unlock_irq(&ice->reg_lock); in snd_ice1712_pro_mixer_switch_get()
1279 int priv_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + in snd_ice1712_pro_mixer_switch_put()
1280 kcontrol->private_value; in snd_ice1712_pro_mixer_switch_put()
1283 nval = (ucontrol->value.integer.value[0] ? 0 : 0x00008000) | in snd_ice1712_pro_mixer_switch_put()
1284 (ucontrol->value.integer.value[1] ? 0 : 0x80000000); in snd_ice1712_pro_mixer_switch_put()
1285 spin_lock_irq(&ice->reg_lock); in snd_ice1712_pro_mixer_switch_put()
1286 nval |= ice->pro_volumes[priv_idx] & ~0x80008000; in snd_ice1712_pro_mixer_switch_put()
1287 change = nval != ice->pro_volumes[priv_idx]; in snd_ice1712_pro_mixer_switch_put()
1288 ice->pro_volumes[priv_idx] = nval; in snd_ice1712_pro_mixer_switch_put()
1290 spin_unlock_irq(&ice->reg_lock); in snd_ice1712_pro_mixer_switch_put()
1296 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_ice1712_pro_mixer_volume_info()
1297 uinfo->count = 2; in snd_ice1712_pro_mixer_volume_info()
1298 uinfo->value.integer.min = 0; in snd_ice1712_pro_mixer_volume_info()
1299 uinfo->value.integer.max = 96; in snd_ice1712_pro_mixer_volume_info()
1306 int priv_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + in snd_ice1712_pro_mixer_volume_get()
1307 kcontrol->private_value; in snd_ice1712_pro_mixer_volume_get()
1309 spin_lock_irq(&ice->reg_lock); in snd_ice1712_pro_mixer_volume_get()
1310 ucontrol->value.integer.value[0] = in snd_ice1712_pro_mixer_volume_get()
1311 (ice->pro_volumes[priv_idx] >> 0) & 127; in snd_ice1712_pro_mixer_volume_get()
1312 ucontrol->value.integer.value[1] = in snd_ice1712_pro_mixer_volume_get()
1313 (ice->pro_volumes[priv_idx] >> 16) & 127; in snd_ice1712_pro_mixer_volume_get()
1314 spin_unlock_irq(&ice->reg_lock); in snd_ice1712_pro_mixer_volume_get()
1321 int priv_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + in snd_ice1712_pro_mixer_volume_put()
1322 kcontrol->private_value; in snd_ice1712_pro_mixer_volume_put()
1325 nval = (ucontrol->value.integer.value[0] & 127) | in snd_ice1712_pro_mixer_volume_put()
1326 ((ucontrol->value.integer.value[1] & 127) << 16); in snd_ice1712_pro_mixer_volume_put()
1327 spin_lock_irq(&ice->reg_lock); in snd_ice1712_pro_mixer_volume_put()
1328 nval |= ice->pro_volumes[priv_idx] & ~0x007f007f; in snd_ice1712_pro_mixer_volume_put()
1329 change = nval != ice->pro_volumes[priv_idx]; in snd_ice1712_pro_mixer_volume_put()
1330 ice->pro_volumes[priv_idx] = nval; in snd_ice1712_pro_mixer_volume_put()
1332 spin_unlock_irq(&ice->reg_lock); in snd_ice1712_pro_mixer_volume_put()
1336 static const DECLARE_TLV_DB_SCALE(db_scale_playback, -14400, 150, 0);
1405 struct snd_card *card = ice->card; in snd_ice1712_build_pro_mixer()
1409 /* multi-channel mixer */ in snd_ice1712_build_pro_mixer()
1416 if (ice->num_total_adcs > 0) { in snd_ice1712_build_pro_mixer()
1418 tmp.count = ice->num_total_adcs; in snd_ice1712_build_pro_mixer()
1428 if (ice->num_total_adcs > 0) { in snd_ice1712_build_pro_mixer()
1430 tmp.count = ice->num_total_adcs; in snd_ice1712_build_pro_mixer()
1442 ice->pro_volumes[idx] = 0x80008000; /* mute */ in snd_ice1712_build_pro_mixer()
1445 for (idx = 10; idx < 10 + ice->num_total_adcs; idx++) { in snd_ice1712_build_pro_mixer()
1446 ice->pro_volumes[idx] = 0x80008000; /* mute */ in snd_ice1712_build_pro_mixer()
1450 ice->pro_volumes[idx] = 0x80008000; /* mute */ in snd_ice1712_build_pro_mixer()
1458 struct snd_ice1712 *ice = ac97->private_data; in snd_ice1712_mixer_free_ac97()
1459 ice->ac97 = NULL; in snd_ice1712_mixer_free_ac97()
1477 err = snd_ac97_bus(ice->card, bus_num++, &con_ops, NULL, &pbus); in snd_ice1712_ac97_mixer()
1483 err = snd_ac97_mixer(pbus, &ac97, &ice->ac97); in snd_ice1712_ac97_mixer()
1485 dev_warn(ice->card->dev, in snd_ice1712_ac97_mixer()
1488 return snd_ctl_add(ice->card, in snd_ice1712_ac97_mixer()
1494 if (!(ice->eeprom.data[ICE_EEP1_ACLINK] & ICE1712_CFG_PRO_I2S)) { in snd_ice1712_ac97_mixer()
1495 err = snd_ac97_bus(ice->card, bus_num, &pro_ops, NULL, &pbus); in snd_ice1712_ac97_mixer()
1501 err = snd_ac97_mixer(pbus, &ac97, &ice->ac97); in snd_ice1712_ac97_mixer()
1503 dev_warn(ice->card->dev, in snd_ice1712_ac97_mixer()
1509 strcat(ice->card->mixername, "ICE1712 - multitrack"); in snd_ice1712_ac97_mixer()
1519 return (unsigned int)ice->eeprom.data[idx] | ((unsigned int)ice->eeprom.data[idx + 1] << 8); in eeprom_double()
1525 struct snd_ice1712 *ice = entry->private_data; in snd_ice1712_proc_read()
1528 snd_iprintf(buffer, "%s\n\n", ice->card->longname); in snd_ice1712_proc_read()
1531 snd_iprintf(buffer, " Subvendor : 0x%x\n", ice->eeprom.subvendor); in snd_ice1712_proc_read()
1532 snd_iprintf(buffer, " Size : %i bytes\n", ice->eeprom.size); in snd_ice1712_proc_read()
1533 snd_iprintf(buffer, " Version : %i\n", ice->eeprom.version); in snd_ice1712_proc_read()
1534 snd_iprintf(buffer, " Codec : 0x%x\n", ice->eeprom.data[ICE_EEP1_CODEC]); in snd_ice1712_proc_read()
1535 snd_iprintf(buffer, " ACLink : 0x%x\n", ice->eeprom.data[ICE_EEP1_ACLINK]); in snd_ice1712_proc_read()
1536 snd_iprintf(buffer, " I2S ID : 0x%x\n", ice->eeprom.data[ICE_EEP1_I2SID]); in snd_ice1712_proc_read()
1537 snd_iprintf(buffer, " S/PDIF : 0x%x\n", ice->eeprom.data[ICE_EEP1_SPDIF]); in snd_ice1712_proc_read()
1538 snd_iprintf(buffer, " GPIO mask : 0x%x\n", ice->eeprom.gpiomask); in snd_ice1712_proc_read()
1539 snd_iprintf(buffer, " GPIO state : 0x%x\n", ice->eeprom.gpiostate); in snd_ice1712_proc_read()
1540 snd_iprintf(buffer, " GPIO direction : 0x%x\n", ice->eeprom.gpiodir); in snd_ice1712_proc_read()
1544 snd_iprintf(buffer, " AC'97 record src : 0x%x\n", ice->eeprom.data[ICE_EEP1_AC97_RECSRC]); in snd_ice1712_proc_read()
1546 snd_iprintf(buffer, " DAC ID #%i : 0x%x\n", idx, ice->eeprom.data[ICE_EEP1_DAC_ID + idx]); in snd_ice1712_proc_read()
1548 snd_iprintf(buffer, " ADC ID #%i : 0x%x\n", idx, ice->eeprom.data[ICE_EEP1_ADC_ID + idx]); in snd_ice1712_proc_read()
1549 for (idx = 0x1c; idx < ice->eeprom.size; idx++) in snd_ice1712_proc_read()
1550 snd_iprintf(buffer, " Extra #%02i : 0x%x\n", idx, ice->eeprom.data[idx]); in snd_ice1712_proc_read()
1564 snd_card_ro_proc_new(ice->card, "ice1712", ice, snd_ice1712_proc_read); in snd_ice1712_proc_init()
1574 uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; in snd_ice1712_eeprom_info()
1575 uinfo->count = sizeof(struct snd_ice1712_eeprom); in snd_ice1712_eeprom_info()
1584 memcpy(ucontrol->value.bytes.data, &ice->eeprom, sizeof(ice->eeprom)); in snd_ice1712_eeprom_get()
1601 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; in snd_ice1712_spdif_info()
1602 uinfo->count = 1; in snd_ice1712_spdif_info()
1610 if (ice->spdif.ops.default_get) in snd_ice1712_spdif_default_get()
1611 ice->spdif.ops.default_get(ice, ucontrol); in snd_ice1712_spdif_default_get()
1619 if (ice->spdif.ops.default_put) in snd_ice1712_spdif_default_put()
1620 return ice->spdif.ops.default_put(ice, ucontrol); in snd_ice1712_spdif_default_put()
1637 if (ice->spdif.ops.default_get) { in snd_ice1712_spdif_maskc_get()
1638 ucontrol->value.iec958.status[0] = IEC958_AES0_NONAUDIO | in snd_ice1712_spdif_maskc_get()
1642 ucontrol->value.iec958.status[1] = IEC958_AES1_CON_ORIGINAL | in snd_ice1712_spdif_maskc_get()
1644 ucontrol->value.iec958.status[3] = IEC958_AES3_CON_FS; in snd_ice1712_spdif_maskc_get()
1646 ucontrol->value.iec958.status[0] = 0xff; in snd_ice1712_spdif_maskc_get()
1647 ucontrol->value.iec958.status[1] = 0xff; in snd_ice1712_spdif_maskc_get()
1648 ucontrol->value.iec958.status[2] = 0xff; in snd_ice1712_spdif_maskc_get()
1649 ucontrol->value.iec958.status[3] = 0xff; in snd_ice1712_spdif_maskc_get()
1650 ucontrol->value.iec958.status[4] = 0xff; in snd_ice1712_spdif_maskc_get()
1659 if (ice->spdif.ops.default_get) { in snd_ice1712_spdif_maskp_get()
1660 ucontrol->value.iec958.status[0] = IEC958_AES0_NONAUDIO | in snd_ice1712_spdif_maskp_get()
1664 ucontrol->value.iec958.status[1] = IEC958_AES1_PRO_MODE; in snd_ice1712_spdif_maskp_get()
1666 ucontrol->value.iec958.status[0] = 0xff; in snd_ice1712_spdif_maskp_get()
1667 ucontrol->value.iec958.status[1] = 0xff; in snd_ice1712_spdif_maskp_get()
1668 ucontrol->value.iec958.status[2] = 0xff; in snd_ice1712_spdif_maskp_get()
1669 ucontrol->value.iec958.status[3] = 0xff; in snd_ice1712_spdif_maskp_get()
1670 ucontrol->value.iec958.status[4] = 0xff; in snd_ice1712_spdif_maskp_get()
1697 if (ice->spdif.ops.stream_get) in snd_ice1712_spdif_stream_get()
1698 ice->spdif.ops.stream_get(ice, ucontrol); in snd_ice1712_spdif_stream_get()
1706 if (ice->spdif.ops.stream_put) in snd_ice1712_spdif_stream_put()
1707 return ice->spdif.ops.stream_put(ice, ucontrol); in snd_ice1712_spdif_stream_put()
1726 unsigned char mask = kcontrol->private_value & 0xff; in snd_ice1712_gpio_get()
1727 int invert = (kcontrol->private_value & (1<<24)) ? 1 : 0; in snd_ice1712_gpio_get()
1730 ucontrol->value.integer.value[0] = in snd_ice1712_gpio_get()
1740 unsigned char mask = kcontrol->private_value & 0xff; in snd_ice1712_gpio_put()
1741 int invert = (kcontrol->private_value & (1<<24)) ? mask : 0; in snd_ice1712_gpio_put()
1744 if (kcontrol->private_value & (1 << 31)) in snd_ice1712_gpio_put()
1745 return -EPERM; in snd_ice1712_gpio_put()
1746 nval = (ucontrol->value.integer.value[0] ? mask : 0) ^ invert; in snd_ice1712_gpio_put()
1776 "IEC958 Input", /* 13: -- */ in snd_ice1712_pro_internal_clock_info()
1790 spin_lock_irq(&ice->reg_lock); in snd_ice1712_pro_internal_clock_get()
1792 ucontrol->value.enumerated.item[0] = 13; in snd_ice1712_pro_internal_clock_get()
1799 ucontrol->value.enumerated.item[0] = val; in snd_ice1712_pro_internal_clock_get()
1801 spin_unlock_irq(&ice->reg_lock); in snd_ice1712_pro_internal_clock_get()
1816 spin_lock_irq(&ice->reg_lock); in snd_ice1712_pro_internal_clock_put()
1818 if (ucontrol->value.enumerated.item[0] == 13) { in snd_ice1712_pro_internal_clock_put()
1821 PRO_RATE_DEFAULT = xrate[ucontrol->value.integer.value[0] % 13]; in snd_ice1712_pro_internal_clock_put()
1822 spin_unlock_irq(&ice->reg_lock); in snd_ice1712_pro_internal_clock_put()
1824 spin_lock_irq(&ice->reg_lock); in snd_ice1712_pro_internal_clock_put()
1827 spin_unlock_irq(&ice->reg_lock); in snd_ice1712_pro_internal_clock_put()
1838 .name = "Multi Track Internal Clock",
1861 /* "IEC958 Input", 13: -- */ in snd_ice1712_pro_internal_clock_default_info()
1880 ucontrol->value.enumerated.item[0] = val; in snd_ice1712_pro_internal_clock_default_get()
1895 PRO_RATE_DEFAULT = xrate[ucontrol->value.integer.value[0] % 13]; in snd_ice1712_pro_internal_clock_default_put()
1903 .name = "Multi Track Internal Clock Default",
1914 ucontrol->value.integer.value[0] = PRO_RATE_LOCKED; in snd_ice1712_pro_rate_locking_get()
1924 nval = ucontrol->value.integer.value[0] ? 1 : 0; in snd_ice1712_pro_rate_locking_put()
1925 spin_lock_irq(&ice->reg_lock); in snd_ice1712_pro_rate_locking_put()
1928 spin_unlock_irq(&ice->reg_lock); in snd_ice1712_pro_rate_locking_put()
1945 ucontrol->value.integer.value[0] = PRO_RATE_RESET; in snd_ice1712_pro_rate_reset_get()
1955 nval = ucontrol->value.integer.value[0] ? 1 : 0; in snd_ice1712_pro_rate_reset_put()
1956 spin_lock_irq(&ice->reg_lock); in snd_ice1712_pro_rate_reset_put()
1959 spin_unlock_irq(&ice->reg_lock); in snd_ice1712_pro_rate_reset_put()
1979 "H/W In 0", "H/W In 1", "H/W In 2", "H/W In 3", /* 1-4 */ in snd_ice1712_pro_route_info()
1980 "H/W In 4", "H/W In 5", "H/W In 6", "H/W In 7", /* 5-8 */ in snd_ice1712_pro_route_info()
1981 "IEC958 In L", "IEC958 In R", /* 9-10 */ in snd_ice1712_pro_route_info()
1982 "Digital Mixer", /* 11 - optional */ in snd_ice1712_pro_route_info()
1984 int num_items = snd_ctl_get_ioffidx(kcontrol, &uinfo->id) < 2 ? 12 : 11; in snd_ice1712_pro_route_info()
1992 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); in snd_ice1712_pro_route_analog_get()
1995 spin_lock_irq(&ice->reg_lock); in snd_ice1712_pro_route_analog_get()
1998 spin_unlock_irq(&ice->reg_lock); in snd_ice1712_pro_route_analog_get()
2004 ucontrol->value.enumerated.item[0] = 11; in snd_ice1712_pro_route_analog_get()
2006 ucontrol->value.enumerated.item[0] = (cval & 7) + 1; in snd_ice1712_pro_route_analog_get()
2008 ucontrol->value.enumerated.item[0] = ((cval >> 3) & 1) + 9; in snd_ice1712_pro_route_analog_get()
2010 ucontrol->value.enumerated.item[0] = 0; in snd_ice1712_pro_route_analog_get()
2019 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); in snd_ice1712_pro_route_analog_put()
2023 if (ucontrol->value.enumerated.item[0] >= 11) in snd_ice1712_pro_route_analog_put()
2025 else if (ucontrol->value.enumerated.item[0] >= 9) in snd_ice1712_pro_route_analog_put()
2027 else if (ucontrol->value.enumerated.item[0] >= 1) in snd_ice1712_pro_route_analog_put()
2032 spin_lock_irq(&ice->reg_lock); in snd_ice1712_pro_route_analog_put()
2039 spin_unlock_irq(&ice->reg_lock); in snd_ice1712_pro_route_analog_put()
2044 spin_lock_irq(&ice->reg_lock); in snd_ice1712_pro_route_analog_put()
2048 nval = ucontrol->value.enumerated.item[0] - 1; in snd_ice1712_pro_route_analog_put()
2052 nval = (ucontrol->value.enumerated.item[0] - 9) << 3; in snd_ice1712_pro_route_analog_put()
2060 spin_unlock_irq(&ice->reg_lock); in snd_ice1712_pro_route_analog_put()
2068 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); in snd_ice1712_pro_route_spdif_get()
2074 ucontrol->value.enumerated.item[0] = 11; in snd_ice1712_pro_route_spdif_get()
2076 ucontrol->value.enumerated.item[0] = (cval & 7) + 1; in snd_ice1712_pro_route_spdif_get()
2078 ucontrol->value.enumerated.item[0] = ((cval >> 3) & 1) + 9; in snd_ice1712_pro_route_spdif_get()
2080 ucontrol->value.enumerated.item[0] = 0; in snd_ice1712_pro_route_spdif_get()
2089 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); in snd_ice1712_pro_route_spdif_put()
2093 spin_lock_irq(&ice->reg_lock); in snd_ice1712_pro_route_spdif_put()
2095 if (ucontrol->value.enumerated.item[0] >= 11) in snd_ice1712_pro_route_spdif_put()
2097 else if (ucontrol->value.enumerated.item[0] >= 9) in snd_ice1712_pro_route_spdif_put()
2099 else if (ucontrol->value.enumerated.item[0] >= 1) in snd_ice1712_pro_route_spdif_put()
2108 nval = ucontrol->value.enumerated.item[0] - 1; in snd_ice1712_pro_route_spdif_put()
2112 nval = (ucontrol->value.enumerated.item[0] - 9) << 3; in snd_ice1712_pro_route_spdif_put()
2119 spin_unlock_irq(&ice->reg_lock); in snd_ice1712_pro_route_spdif_put()
2144 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_ice1712_pro_volume_rate_info()
2145 uinfo->count = 1; in snd_ice1712_pro_volume_rate_info()
2146 uinfo->value.integer.min = 0; in snd_ice1712_pro_volume_rate_info()
2147 uinfo->value.integer.max = 255; in snd_ice1712_pro_volume_rate_info()
2156 ucontrol->value.integer.value[0] = inb(ICEMT(ice, MONITOR_RATE)); in snd_ice1712_pro_volume_rate_get()
2166 spin_lock_irq(&ice->reg_lock); in snd_ice1712_pro_volume_rate_put()
2167 change = inb(ICEMT(ice, MONITOR_RATE)) != ucontrol->value.integer.value[0]; in snd_ice1712_pro_volume_rate_put()
2168 outb(ucontrol->value.integer.value[0], ICEMT(ice, MONITOR_RATE)); in snd_ice1712_pro_volume_rate_put()
2169 spin_unlock_irq(&ice->reg_lock); in snd_ice1712_pro_volume_rate_put()
2184 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_ice1712_pro_peak_info()
2185 uinfo->count = 22; in snd_ice1712_pro_peak_info()
2186 uinfo->value.integer.min = 0; in snd_ice1712_pro_peak_info()
2187 uinfo->value.integer.max = 255; in snd_ice1712_pro_peak_info()
2197 spin_lock_irq(&ice->reg_lock); in snd_ice1712_pro_peak_get()
2200 ucontrol->value.integer.value[idx] = inb(ICEMT(ice, MONITOR_PEAKDATA)); in snd_ice1712_pro_peak_get()
2202 spin_unlock_irq(&ice->reg_lock); in snd_ice1712_pro_peak_get()
2236 while (t-- > 0 && (inb(ICEREG(ice, I2C_CTRL)) & ICE1712_I2C_BUSY)) ; in snd_ice1712_read_i2c()
2248 ice->eeprom.subvendor = 0; in snd_ice1712_read_eeprom()
2250 ice->eeprom.subvendor = (snd_ice1712_read_i2c(ice, dev, 0x00) << 0) | in snd_ice1712_read_eeprom()
2254 if (ice->eeprom.subvendor == 0 || in snd_ice1712_read_eeprom()
2255 ice->eeprom.subvendor == (unsigned int)-1) { in snd_ice1712_read_eeprom()
2258 pci_read_config_word(ice->pci, PCI_SUBSYSTEM_VENDOR_ID, &vendor); in snd_ice1712_read_eeprom()
2259 pci_read_config_word(ice->pci, PCI_SUBSYSTEM_ID, &device); in snd_ice1712_read_eeprom()
2260 ice->eeprom.subvendor = ((unsigned int)swab16(vendor) << 16) | swab16(device); in snd_ice1712_read_eeprom()
2261 if (ice->eeprom.subvendor == 0 || ice->eeprom.subvendor == (unsigned int)-1) { in snd_ice1712_read_eeprom()
2262 dev_err(ice->card->dev, in snd_ice1712_read_eeprom()
2264 return -ENXIO; in snd_ice1712_read_eeprom()
2269 for (c = *tbl; c->subvendor; c++) { in snd_ice1712_read_eeprom()
2270 if (modelname && c->model && !strcmp(modelname, c->model)) { in snd_ice1712_read_eeprom()
2271 dev_info(ice->card->dev, in snd_ice1712_read_eeprom()
2272 "Using board model %s\n", c->name); in snd_ice1712_read_eeprom()
2273 ice->eeprom.subvendor = c->subvendor; in snd_ice1712_read_eeprom()
2274 } else if (c->subvendor != ice->eeprom.subvendor) in snd_ice1712_read_eeprom()
2276 if (!c->eeprom_size || !c->eeprom_data) in snd_ice1712_read_eeprom()
2279 dev_dbg(ice->card->dev, "using the defined eeprom..\n"); in snd_ice1712_read_eeprom()
2280 ice->eeprom.version = 1; in snd_ice1712_read_eeprom()
2281 ice->eeprom.size = c->eeprom_size + 6; in snd_ice1712_read_eeprom()
2282 memcpy(ice->eeprom.data, c->eeprom_data, c->eeprom_size); in snd_ice1712_read_eeprom()
2286 dev_warn(ice->card->dev, "No matching model found for ID 0x%x\n", in snd_ice1712_read_eeprom()
2287 ice->eeprom.subvendor); in snd_ice1712_read_eeprom()
2290 ice->eeprom.size = snd_ice1712_read_i2c(ice, dev, 0x04); in snd_ice1712_read_eeprom()
2291 if (ice->eeprom.size < 6) in snd_ice1712_read_eeprom()
2292 ice->eeprom.size = 32; /* FIXME: any cards without the correct size? */ in snd_ice1712_read_eeprom()
2293 else if (ice->eeprom.size > 32) { in snd_ice1712_read_eeprom()
2294 dev_err(ice->card->dev, in snd_ice1712_read_eeprom()
2295 "invalid EEPROM (size = %i)\n", ice->eeprom.size); in snd_ice1712_read_eeprom()
2296 return -EIO; in snd_ice1712_read_eeprom()
2298 ice->eeprom.version = snd_ice1712_read_i2c(ice, dev, 0x05); in snd_ice1712_read_eeprom()
2299 if (ice->eeprom.version != 1) { in snd_ice1712_read_eeprom()
2300 dev_err(ice->card->dev, "invalid EEPROM version %i\n", in snd_ice1712_read_eeprom()
2301 ice->eeprom.version); in snd_ice1712_read_eeprom()
2302 /* return -EIO; */ in snd_ice1712_read_eeprom()
2304 size = ice->eeprom.size - 6; in snd_ice1712_read_eeprom()
2306 ice->eeprom.data[i] = snd_ice1712_read_i2c(ice, dev, i + 6); in snd_ice1712_read_eeprom()
2309 ice->eeprom.gpiomask = ice->eeprom.data[ICE_EEP1_GPIO_MASK]; in snd_ice1712_read_eeprom()
2310 ice->eeprom.gpiostate = ice->eeprom.data[ICE_EEP1_GPIO_STATE]; in snd_ice1712_read_eeprom()
2311 ice->eeprom.gpiodir = ice->eeprom.data[ICE_EEP1_GPIO_DIR]; in snd_ice1712_read_eeprom()
2324 if (ice->eeprom.subvendor == ICE1712_SUBDEVICE_DMX6FIRE && in snd_ice1712_chip_init()
2325 !ice->dxr_enable) in snd_ice1712_chip_init()
2330 ice->eeprom.data[ICE_EEP1_CODEC] = 0x3a; in snd_ice1712_chip_init()
2331 pci_write_config_byte(ice->pci, 0x60, ice->eeprom.data[ICE_EEP1_CODEC]); in snd_ice1712_chip_init()
2332 pci_write_config_byte(ice->pci, 0x61, ice->eeprom.data[ICE_EEP1_ACLINK]); in snd_ice1712_chip_init()
2333 pci_write_config_byte(ice->pci, 0x62, ice->eeprom.data[ICE_EEP1_I2SID]); in snd_ice1712_chip_init()
2334 pci_write_config_byte(ice->pci, 0x63, ice->eeprom.data[ICE_EEP1_SPDIF]); in snd_ice1712_chip_init()
2335 if (ice->eeprom.subvendor != ICE1712_SUBDEVICE_STDSP24 && in snd_ice1712_chip_init()
2336 ice->eeprom.subvendor != ICE1712_SUBDEVICE_STAUDIO_ADCIII) { in snd_ice1712_chip_init()
2337 ice->gpio.write_mask = ice->eeprom.gpiomask; in snd_ice1712_chip_init()
2338 ice->gpio.direction = ice->eeprom.gpiodir; in snd_ice1712_chip_init()
2340 ice->eeprom.gpiomask); in snd_ice1712_chip_init()
2342 ice->eeprom.gpiodir); in snd_ice1712_chip_init()
2344 ice->eeprom.gpiostate); in snd_ice1712_chip_init()
2346 ice->gpio.write_mask = 0xc0; in snd_ice1712_chip_init()
2347 ice->gpio.direction = 0xff; in snd_ice1712_chip_init()
2354 if (!(ice->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_NO_CON_AC97)) { in snd_ice1712_chip_init()
2363 outb(((ice->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_2xMPU401) == 0 ? in snd_ice1712_chip_init()
2365 ((ice->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_NO_CON_AC97) ? in snd_ice1712_chip_init()
2378 if (snd_BUG_ON(!ice->pcm_pro)) in snd_ice1712_spdif_build_controls()
2379 return -EIO; in snd_ice1712_spdif_build_controls()
2380 err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_ice1712_spdif_default, ice)); in snd_ice1712_spdif_build_controls()
2383 kctl->id.device = ice->pcm_pro->device; in snd_ice1712_spdif_build_controls()
2384 err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_ice1712_spdif_maskc, ice)); in snd_ice1712_spdif_build_controls()
2387 kctl->id.device = ice->pcm_pro->device; in snd_ice1712_spdif_build_controls()
2388 err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_ice1712_spdif_maskp, ice)); in snd_ice1712_spdif_build_controls()
2391 kctl->id.device = ice->pcm_pro->device; in snd_ice1712_spdif_build_controls()
2392 err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_ice1712_spdif_stream, ice)); in snd_ice1712_spdif_build_controls()
2395 kctl->id.device = ice->pcm_pro->device; in snd_ice1712_spdif_build_controls()
2396 ice->spdif.stream_ctl = kctl; in snd_ice1712_spdif_build_controls()
2405 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_eeprom, ice)); in snd_ice1712_build_controls()
2408 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_pro_internal_clock, ice)); in snd_ice1712_build_controls()
2411 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_pro_internal_clock_default, ice)); in snd_ice1712_build_controls()
2415 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_pro_rate_locking, ice)); in snd_ice1712_build_controls()
2418 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_pro_rate_reset, ice)); in snd_ice1712_build_controls()
2422 if (ice->num_total_dacs > 0) { in snd_ice1712_build_controls()
2424 tmp.count = ice->num_total_dacs; in snd_ice1712_build_controls()
2425 err = snd_ctl_add(ice->card, snd_ctl_new1(&tmp, ice)); in snd_ice1712_build_controls()
2430 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_mixer_pro_spdif_route, ice)); in snd_ice1712_build_controls()
2434 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_mixer_pro_volume_rate, ice)); in snd_ice1712_build_controls()
2437 return snd_ctl_add(ice->card, in snd_ice1712_build_controls()
2443 if (!ice->port) in snd_ice1712_free()
2448 /* --- */ in snd_ice1712_free()
2450 if (ice->irq >= 0) in snd_ice1712_free()
2451 free_irq(ice->irq, ice); in snd_ice1712_free()
2453 if (ice->port) in snd_ice1712_free()
2454 pci_release_regions(ice->pci); in snd_ice1712_free()
2456 pci_disable_device(ice->pci); in snd_ice1712_free()
2457 kfree(ice->spec); in snd_ice1712_free()
2464 struct snd_ice1712 *ice = device->device_data; in snd_ice1712_dev_free()
2489 if (dma_set_mask(&pci->dev, DMA_BIT_MASK(28)) < 0 || in snd_ice1712_create()
2490 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(28)) < 0) { in snd_ice1712_create()
2491 dev_err(card->dev, in snd_ice1712_create()
2494 return -ENXIO; in snd_ice1712_create()
2500 return -ENOMEM; in snd_ice1712_create()
2502 ice->omni = omni ? 1 : 0; in snd_ice1712_create()
2507 ice->cs8427_timeout = cs8427_timeout; in snd_ice1712_create()
2508 ice->dxr_enable = dxr_enable; in snd_ice1712_create()
2509 spin_lock_init(&ice->reg_lock); in snd_ice1712_create()
2510 mutex_init(&ice->gpio_mutex); in snd_ice1712_create()
2511 mutex_init(&ice->i2c_mutex); in snd_ice1712_create()
2512 mutex_init(&ice->open_mutex); in snd_ice1712_create()
2513 ice->gpio.set_mask = snd_ice1712_set_gpio_mask; in snd_ice1712_create()
2514 ice->gpio.get_mask = snd_ice1712_get_gpio_mask; in snd_ice1712_create()
2515 ice->gpio.set_dir = snd_ice1712_set_gpio_dir; in snd_ice1712_create()
2516 ice->gpio.get_dir = snd_ice1712_get_gpio_dir; in snd_ice1712_create()
2517 ice->gpio.set_data = snd_ice1712_set_gpio_data; in snd_ice1712_create()
2518 ice->gpio.get_data = snd_ice1712_get_gpio_data; in snd_ice1712_create()
2520 ice->spdif.cs8403_bits = in snd_ice1712_create()
2521 ice->spdif.cs8403_stream_bits = (0x01 | /* consumer format */ in snd_ice1712_create()
2524 ice->card = card; in snd_ice1712_create()
2525 ice->pci = pci; in snd_ice1712_create()
2526 ice->irq = -1; in snd_ice1712_create()
2529 pci_write_config_word(ice->pci, 0x40, 0x807f); in snd_ice1712_create()
2530 pci_write_config_word(ice->pci, 0x42, 0x0006); in snd_ice1712_create()
2533 card->private_data = ice; in snd_ice1712_create()
2541 ice->port = pci_resource_start(pci, 0); in snd_ice1712_create()
2542 ice->ddma_port = pci_resource_start(pci, 1); in snd_ice1712_create()
2543 ice->dmapath_port = pci_resource_start(pci, 2); in snd_ice1712_create()
2544 ice->profi_port = pci_resource_start(pci, 3); in snd_ice1712_create()
2546 if (request_irq(pci->irq, snd_ice1712_interrupt, IRQF_SHARED, in snd_ice1712_create()
2548 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); in snd_ice1712_create()
2550 return -EIO; in snd_ice1712_create()
2553 ice->irq = pci->irq; in snd_ice1712_create()
2554 card->sync_irq = ice->irq; in snd_ice1712_create()
2558 return -EIO; in snd_ice1712_create()
2562 return -EIO; in snd_ice1712_create()
2594 return -ENODEV; in snd_ice1712_probe()
2597 return -ENOENT; in snd_ice1712_probe()
2600 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, in snd_ice1712_probe()
2605 strcpy(card->driver, "ICE1712"); in snd_ice1712_probe()
2606 strcpy(card->shortname, "ICEnsemble ICE1712"); in snd_ice1712_probe()
2616 for (c = *tbl; c->subvendor; c++) { in snd_ice1712_probe()
2617 if (c->subvendor == ice->eeprom.subvendor) { in snd_ice1712_probe()
2618 ice->card_info = c; in snd_ice1712_probe()
2619 strcpy(card->shortname, c->name); in snd_ice1712_probe()
2620 if (c->driver) /* specific driver? */ in snd_ice1712_probe()
2621 strcpy(card->driver, c->driver); in snd_ice1712_probe()
2622 if (c->chip_init) { in snd_ice1712_probe()
2623 err = c->chip_init(ice); in snd_ice1712_probe()
2662 if (c->build_controls) { in snd_ice1712_probe()
2663 err = c->build_controls(ice); in snd_ice1712_probe()
2678 if (!c->no_mpu401) { in snd_ice1712_probe()
2681 c->mpu401_1_info_flags | in snd_ice1712_probe()
2683 -1, &ice->rmidi[0]); in snd_ice1712_probe()
2688 if (c->mpu401_1_name) in snd_ice1712_probe()
2690 snprintf(ice->rmidi[0]->name, in snd_ice1712_probe()
2691 sizeof(ice->rmidi[0]->name), in snd_ice1712_probe()
2692 "%s %d", c->mpu401_1_name, card->number); in snd_ice1712_probe()
2694 if (ice->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_2xMPU401) { in snd_ice1712_probe()
2698 c->mpu401_2_info_flags | in snd_ice1712_probe()
2700 -1, &ice->rmidi[1]); in snd_ice1712_probe()
2706 if (c->mpu401_2_name) in snd_ice1712_probe()
2708 snprintf(ice->rmidi[1]->name, in snd_ice1712_probe()
2709 sizeof(ice->rmidi[1]->name), in snd_ice1712_probe()
2710 "%s %d", c->mpu401_2_name, in snd_ice1712_probe()
2711 card->number); in snd_ice1712_probe()
2717 sprintf(card->longname, "%s at 0x%lx, irq %i", in snd_ice1712_probe()
2718 card->shortname, ice->port, ice->irq); in snd_ice1712_probe()
2733 struct snd_ice1712 *ice = card->private_data; in snd_ice1712_remove()
2735 if (ice->card_info && ice->card_info->chip_exit) in snd_ice1712_remove()
2736 ice->card_info->chip_exit(ice); in snd_ice1712_remove()
2744 struct snd_ice1712 *ice = card->private_data; in snd_ice1712_suspend()
2746 if (!ice->pm_suspend_enabled) in snd_ice1712_suspend()
2751 snd_ac97_suspend(ice->ac97); in snd_ice1712_suspend()
2753 spin_lock_irq(&ice->reg_lock); in snd_ice1712_suspend()
2754 ice->pm_saved_is_spdif_master = is_spdif_master(ice); in snd_ice1712_suspend()
2755 ice->pm_saved_spdif_ctrl = inw(ICEMT(ice, ROUTE_SPDOUT)); in snd_ice1712_suspend()
2756 ice->pm_saved_route = inw(ICEMT(ice, ROUTE_PSDOUT03)); in snd_ice1712_suspend()
2757 spin_unlock_irq(&ice->reg_lock); in snd_ice1712_suspend()
2759 if (ice->pm_suspend) in snd_ice1712_suspend()
2760 ice->pm_suspend(ice); in snd_ice1712_suspend()
2767 struct snd_ice1712 *ice = card->private_data; in snd_ice1712_resume()
2770 if (!ice->pm_suspend_enabled) in snd_ice1712_resume()
2773 if (ice->cur_rate) in snd_ice1712_resume()
2774 rate = ice->cur_rate; in snd_ice1712_resume()
2780 return -EIO; in snd_ice1712_resume()
2783 ice->cur_rate = rate; in snd_ice1712_resume()
2785 if (ice->pm_resume) in snd_ice1712_resume()
2786 ice->pm_resume(ice); in snd_ice1712_resume()
2788 if (ice->pm_saved_is_spdif_master) { in snd_ice1712_resume()
2789 /* switching to external clock via SPDIF */ in snd_ice1712_resume()
2790 spin_lock_irq(&ice->reg_lock); in snd_ice1712_resume()
2793 spin_unlock_irq(&ice->reg_lock); in snd_ice1712_resume()
2796 /* internal on-card clock */ in snd_ice1712_resume()
2801 outw(ice->pm_saved_spdif_ctrl, ICEMT(ice, ROUTE_SPDOUT)); in snd_ice1712_resume()
2802 outw(ice->pm_saved_route, ICEMT(ice, ROUTE_PSDOUT03)); in snd_ice1712_resume()
2804 snd_ac97_resume(ice->ac97); in snd_ice1712_resume()