• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/sound/pci/ice1712/

Lines Matching refs:ice

116 static int snd_ice1712_build_pro_mixer(struct snd_ice1712 *ice);
117 static int snd_ice1712_build_controls(struct snd_ice1712 *ice);
128 static inline int is_spdif_master(struct snd_ice1712 *ice)
130 return (inb(ICEMT(ice, RATE)) & ICE1712_SPDIF_MASTER) ? 1 : 0;
133 static inline int is_pro_rate_locked(struct snd_ice1712 *ice)
135 return is_spdif_master(ice) || PRO_RATE_LOCKED;
138 static inline void snd_ice1712_ds_write(struct snd_ice1712 *ice, u8 channel, u8 addr, u32 data)
140 outb((channel << 4) | addr, ICEDS(ice, INDEX));
141 outl(data, ICEDS(ice, DATA));
144 static inline u32 snd_ice1712_ds_read(struct snd_ice1712 *ice, u8 channel, u8 addr)
146 outb((channel << 4) | addr, ICEDS(ice, INDEX));
147 return inl(ICEDS(ice, DATA));
154 struct snd_ice1712 *ice = ac97->private_data;
159 old_cmd = inb(ICEREG(ice, AC97_CMD));
166 outb(reg, ICEREG(ice, AC97_INDEX));
167 outw(val, ICEREG(ice, AC97_DATA));
169 outb(old_cmd | ICE1712_AC97_WRITE, ICEREG(ice, AC97_CMD));
171 if ((inb(ICEREG(ice, AC97_CMD)) & ICE1712_AC97_WRITE) == 0)
178 struct snd_ice1712 *ice = ac97->private_data;
183 old_cmd = inb(ICEREG(ice, AC97_CMD));
190 outb(reg, ICEREG(ice, AC97_INDEX));
191 outb(old_cmd | ICE1712_AC97_READ, ICEREG(ice, AC97_CMD));
193 if ((inb(ICEREG(ice, AC97_CMD)) & ICE1712_AC97_READ) == 0)
197 return inw(ICEREG(ice, AC97_DATA));
208 struct snd_ice1712 *ice = ac97->private_data;
213 old_cmd = inb(ICEMT(ice, AC97_CMD));
220 outb(reg, ICEMT(ice, AC97_INDEX));
221 outw(val, ICEMT(ice, AC97_DATA));
223 outb(old_cmd | ICE1712_AC97_WRITE, ICEMT(ice, AC97_CMD));
225 if ((inb(ICEMT(ice, AC97_CMD)) & ICE1712_AC97_WRITE) == 0)
233 struct snd_ice1712 *ice = ac97->private_data;
238 old_cmd = inb(ICEMT(ice, AC97_CMD));
245 outb(reg, ICEMT(ice, AC97_INDEX));
246 outb(old_cmd | ICE1712_AC97_READ, ICEMT(ice, AC97_CMD));
248 if ((inb(ICEMT(ice, AC97_CMD)) & ICE1712_AC97_READ) == 0)
252 return inw(ICEMT(ice, AC97_DATA));
262 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
264 ucontrol->value.integer.value[0] = inb(ICEMT(ice, MONITOR_ROUTECTRL)) & ICE1712_ROUTE_AC97 ? 1 : 0;
270 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
273 spin_lock_irq(&ice->reg_lock);
274 val = inb(ICEMT(ice, MONITOR_ROUTECTRL));
278 outb(nval, ICEMT(ice, MONITOR_ROUTECTRL));
279 spin_unlock_irq(&ice->reg_lock);
295 static void snd_ice1712_set_gpio_dir(struct snd_ice1712 *ice, unsigned int data)
297 snd_ice1712_write(ice, ICE1712_IREG_GPIO_DIRECTION, data);
298 inb(ICEREG(ice, DATA)); /* dummy read for pci-posting */
301 static unsigned int snd_ice1712_get_gpio_dir(struct snd_ice1712 *ice)
303 return snd_ice1712_read(ice, ICE1712_IREG_GPIO_DIRECTION);
306 static unsigned int snd_ice1712_get_gpio_mask(struct snd_ice1712 *ice)
308 return snd_ice1712_read(ice, ICE1712_IREG_GPIO_WRITE_MASK);
311 static void snd_ice1712_set_gpio_mask(struct snd_ice1712 *ice, unsigned int data)
313 snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, data);
314 inb(ICEREG(ice, DATA)); /* dummy read for pci-posting */
317 static unsigned int snd_ice1712_get_gpio_data(struct snd_ice1712 *ice)
319 return snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA);
322 static void snd_ice1712_set_gpio_data(struct snd_ice1712 *ice, unsigned int val)
324 snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, val);
325 inb(ICEREG(ice, DATA)); /* dummy read for pci-posting */
338 static int snd_ice1712_cs8427_set_input_clock(struct snd_ice1712 *ice, int spdif_clock)
344 snd_i2c_lock(ice->i2c);
345 if (snd_i2c_sendbytes(ice->cs8427, reg, 1) != 1) {
346 snd_i2c_unlock(ice->i2c);
349 if (snd_i2c_readbytes(ice->cs8427, &val, 1) != 1) {
350 snd_i2c_unlock(ice->i2c);
360 if (snd_i2c_sendbytes(ice->cs8427, reg, 2) != 2) {
366 snd_i2c_unlock(ice->i2c);
373 static void open_cs8427(struct snd_ice1712 *ice, struct snd_pcm_substream *substream)
375 snd_cs8427_iec958_active(ice->cs8427, 1);
378 static void close_cs8427(struct snd_ice1712 *ice, struct snd_pcm_substream *substream)
380 snd_cs8427_iec958_active(ice->cs8427, 0);
383 static void setup_cs8427(struct snd_ice1712 *ice, int rate)
385 snd_cs8427_iec958_pcm(ice->cs8427, rate);
391 int __devinit snd_ice1712_init_cs8427(struct snd_ice1712 *ice, int addr)
395 err = snd_cs8427_create(ice->i2c, addr,
396 (ice->cs8427_timeout * HZ) / 1000, &ice->cs8427);
401 ice->spdif.ops.open = open_cs8427;
402 ice->spdif.ops.close = close_cs8427;
403 ice->spdif.ops.setup_rate = setup_cs8427;
407 static void snd_ice1712_set_input_clock_source(struct snd_ice1712 *ice, int spdif_is_master)
410 if (ice->cs8427)
411 snd_ice1712_cs8427_set_input_clock(ice, spdif_is_master);
415 for (i = 0; i < ice->akm_codecs; i++) {
416 if (ice->akm[i].ops.set_rate_val)
417 ice->akm[i].ops.set_rate_val(&ice->akm[i], 0);
428 struct snd_ice1712 *ice = dev_id;
433 status = inb(ICEREG(ice, IRQSTAT));
438 if (ice->rmidi[0])
439 snd_mpu401_uart_interrupt(irq, ice->rmidi[0]->private_data);
440 outb(ICE1712_IRQ_MPU1, ICEREG(ice, IRQSTAT));
444 outb(ICE1712_IRQ_TIMER, ICEREG(ice, IRQSTAT));
446 if (ice->rmidi[1])
447 snd_mpu401_uart_interrupt(irq, ice->rmidi[1]->private_data);
448 outb(ICE1712_IRQ_MPU2, ICEREG(ice, IRQSTAT));
452 unsigned char mtstat = inb(ICEMT(ice, IRQ));
454 if (ice->playback_pro_substream)
455 snd_pcm_period_elapsed(ice->playback_pro_substream);
456 outb(ICE1712_MULTI_PBKSTATUS, ICEMT(ice, IRQ));
459 if (ice->capture_pro_substream)
460 snd_pcm_period_elapsed(ice->capture_pro_substream);
461 outb(ICE1712_MULTI_CAPSTATUS, ICEMT(ice, IRQ));
465 outb(ICE1712_IRQ_FM, ICEREG(ice, IRQSTAT));
470 pbkstatus = inw(ICEDS(ice, INTSTAT));
475 substream = ice->playback_con_substream_ds[idx];
478 outw(3 << (idx * 2), ICEDS(ice, INTSTAT));
480 outb(ICE1712_IRQ_PBKDS, ICEREG(ice, IRQSTAT));
483 if (ice->capture_con_substream)
484 snd_pcm_period_elapsed(ice->capture_con_substream);
485 outb(ICE1712_IRQ_CONCAP, ICEREG(ice, IRQSTAT));
488 if (ice->playback_con_substream)
489 snd_pcm_period_elapsed(ice->playback_con_substream);
490 outb(ICE1712_IRQ_CONPBK, ICEREG(ice, IRQSTAT));
519 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
523 spin_lock(&ice->reg_lock);
524 tmp = snd_ice1712_read(ice, ICE1712_IREG_PBK_CTRL);
536 snd_ice1712_write(ice, ICE1712_IREG_PBK_CTRL, tmp);
537 spin_unlock(&ice->reg_lock);
544 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
548 spin_lock(&ice->reg_lock);
549 tmp = snd_ice1712_ds_read(ice, substream->number * 2, ICE1712_DSC_CONTROL);
561 snd_ice1712_ds_write(ice, substream->number * 2, ICE1712_DSC_CONTROL, tmp);
562 spin_unlock(&ice->reg_lock);
569 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
573 spin_lock(&ice->reg_lock);
574 tmp = snd_ice1712_read(ice, ICE1712_IREG_CAP_CTRL);
582 snd_ice1712_write(ice, ICE1712_IREG_CAP_CTRL, tmp);
583 spin_unlock(&ice->reg_lock);
589 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
603 spin_lock_irq(&ice->reg_lock);
604 outb(0, ice->ddma_port + 15);
605 outb(ICE1712_DMA_MODE_WRITE | ICE1712_DMA_AUTOINIT, ice->ddma_port + 0x0b);
606 outl(runtime->dma_addr, ice->ddma_port + 0);
607 outw(buf_size, ice->ddma_port + 4);
608 snd_ice1712_write(ice, ICE1712_IREG_PBK_RATE_LO, rate & 0xff);
609 snd_ice1712_write(ice, ICE1712_IREG_PBK_RATE_MID, (rate >> 8) & 0xff);
610 snd_ice1712_write(ice, ICE1712_IREG_PBK_RATE_HI, (rate >> 16) & 0xff);
611 snd_ice1712_write(ice, ICE1712_IREG_PBK_CTRL, tmp);
612 snd_ice1712_write(ice, ICE1712_IREG_PBK_COUNT_LO, period_size & 0xff);
613 snd_ice1712_write(ice, ICE1712_IREG_PBK_COUNT_HI, period_size >> 8);
614 snd_ice1712_write(ice, ICE1712_IREG_PBK_LEFT, 0);
615 snd_ice1712_write(ice, ICE1712_IREG_PBK_RIGHT, 0);
616 spin_unlock_irq(&ice->reg_lock);
622 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
636 ice->playback_con_active_buf[substream->number] = 0;
637 ice->playback_con_virt_addr[substream->number] = runtime->dma_addr;
639 spin_lock_irq(&ice->reg_lock);
640 snd_ice1712_ds_write(ice, chn, ICE1712_DSC_ADDR0, runtime->dma_addr);
641 snd_ice1712_ds_write(ice, chn, ICE1712_DSC_COUNT0, period_size);
642 snd_ice1712_ds_write(ice, chn, ICE1712_DSC_ADDR1, runtime->dma_addr + (runtime->periods > 1 ? period_size + 1 : 0));
643 snd_ice1712_ds_write(ice, chn, ICE1712_DSC_COUNT1, period_size);
644 snd_ice1712_ds_write(ice, chn, ICE1712_DSC_RATE, rate);
645 snd_ice1712_ds_write(ice, chn, ICE1712_DSC_VOLUME, 0);
646 snd_ice1712_ds_write(ice, chn, ICE1712_DSC_CONTROL, tmp);
648 snd_ice1712_ds_write(ice, chn + 1, ICE1712_DSC_RATE, rate);
649 snd_ice1712_ds_write(ice, chn + 1, ICE1712_DSC_VOLUME, 0);
651 spin_unlock_irq(&ice->reg_lock);
657 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
669 spin_lock_irq(&ice->reg_lock);
670 outl(ice->capture_con_virt_addr = runtime->dma_addr, ICEREG(ice, CONCAP_ADDR));
671 outw(buf_size, ICEREG(ice, CONCAP_COUNT));
672 snd_ice1712_write(ice, ICE1712_IREG_CAP_COUNT_HI, period_size >> 8);
673 snd_ice1712_write(ice, ICE1712_IREG_CAP_COUNT_LO, period_size & 0xff);
674 snd_ice1712_write(ice, ICE1712_IREG_CAP_CTRL, tmp);
675 spin_unlock_irq(&ice->reg_lock);
676 snd_ac97_set_rate(ice->ac97, AC97_PCM_LR_ADC_RATE, runtime->rate);
682 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
686 if (!(snd_ice1712_read(ice, ICE1712_IREG_PBK_CTRL) & 1))
688 ptr = runtime->buffer_size - inw(ice->ddma_port + 4);
696 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
700 if (!(snd_ice1712_ds_read(ice, substream->number * 2, ICE1712_DSC_CONTROL) & 1))
702 if (ice->playback_con_active_buf[substream->number])
706 ptr = snd_ice1712_ds_read(ice, substream->number * 2, addr) -
707 ice->playback_con_virt_addr[substream->number];
715 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
718 if (!(snd_ice1712_read(ice, ICE1712_IREG_CAP_CTRL) & 1))
720 ptr = inl(ICEREG(ice, CONCAP_ADDR)) - ice->capture_con_virt_addr;
785 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
787 ice->playback_con_substream = substream;
795 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
798 ice->playback_con_substream_ds[substream->number] = substream;
800 spin_lock_irq(&ice->reg_lock);
801 tmp = inw(ICEDS(ice, INTMASK)) & ~(1 << (substream->number * 2));
802 outw(tmp, ICEDS(ice, INTMASK));
803 spin_unlock_irq(&ice->reg_lock);
810 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
812 ice->capture_con_substream = substream;
814 runtime->hw.rates = ice->ac97->rates[AC97_RATES_ADC];
822 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
824 ice->playback_con_substream = NULL;
830 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
833 spin_lock_irq(&ice->reg_lock);
834 tmp = inw(ICEDS(ice, INTMASK)) | (3 << (substream->number * 2));
835 outw(tmp, ICEDS(ice, INTMASK));
836 spin_unlock_irq(&ice->reg_lock);
837 ice->playback_con_substream_ds[substream->number] = NULL;
843 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
845 ice->capture_con_substream = NULL;
882 static int __devinit snd_ice1712_pcm(struct snd_ice1712 *ice, int device, struct snd_pcm **rpcm)
889 err = snd_pcm_new(ice->card, "ICE1712 consumer", device, 1, 1, &pcm);
896 pcm->private_data = ice;
899 ice->pcm = pcm;
902 snd_dma_pci_data(ice->pci), 64*1024, 64*1024);
912 static int __devinit snd_ice1712_pcm_ds(struct snd_ice1712 *ice, int device, struct snd_pcm **rpcm)
919 err = snd_pcm_new(ice->card, "ICE1712 consumer (DS)", device, 6, 0, &pcm);
925 pcm->private_data = ice;
928 ice->pcm_ds = pcm;
931 snd_dma_pci_data(ice->pci), 64*1024, 128*1024);
955 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
966 spin_lock(&ice->reg_lock);
967 old = inl(ICEMT(ice, PLAYBACK_CONTROL));
972 outl(old, ICEMT(ice, PLAYBACK_CONTROL));
973 spin_unlock(&ice->reg_lock);
984 if (s == ice->playback_pro_substream) {
987 } else if (s == ice->capture_pro_substream) {
992 spin_lock(&ice->reg_lock);
993 old = inl(ICEMT(ice, PLAYBACK_CONTROL));
998 outl(old, ICEMT(ice, PLAYBACK_CONTROL));
999 spin_unlock(&ice->reg_lock);
1010 static void snd_ice1712_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate, int force)
1037 spin_lock_irqsave(&ice->reg_lock, flags);
1038 if (inb(ICEMT(ice, PLAYBACK_CONTROL)) & (ICE1712_CAPTURE_START_SHADOW|
1042 spin_unlock_irqrestore(&ice->reg_lock, flags);
1045 if (!force && is_pro_rate_locked(ice))
1048 old = inb(ICEMT(ice, RATE));
1051 outb(val, ICEMT(ice, RATE));
1052 spin_unlock_irqrestore(&ice->reg_lock, flags);
1054 if (ice->gpio.set_pro_rate)
1055 ice->gpio.set_pro_rate(ice, rate);
1056 for (i = 0; i < ice->akm_codecs; i++) {
1057 if (ice->akm[i].ops.set_rate_val)
1058 ice->akm[i].ops.set_rate_val(&ice->akm[i], rate);
1060 if (ice->spdif.ops.setup_rate)
1061 ice->spdif.ops.setup_rate(ice, rate);
1066 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
1068 ice->playback_pro_size = snd_pcm_lib_buffer_bytes(substream);
1069 spin_lock_irq(&ice->reg_lock);
1070 outl(substream->runtime->dma_addr, ICEMT(ice, PLAYBACK_ADDR));
1071 outw((ice->playback_pro_size >> 2) - 1, ICEMT(ice, PLAYBACK_SIZE));
1072 outw((snd_pcm_lib_period_bytes(substream) >> 2) - 1, ICEMT(ice, PLAYBACK_COUNT));
1073 spin_unlock_irq(&ice->reg_lock);
1081 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
1083 snd_ice1712_set_pro_rate(ice, params_rate(hw_params), 0);
1089 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
1091 ice->capture_pro_size = snd_pcm_lib_buffer_bytes(substream);
1092 spin_lock_irq(&ice->reg_lock);
1093 outl(substream->runtime->dma_addr, ICEMT(ice, CAPTURE_ADDR));
1094 outw((ice->capture_pro_size >> 2) - 1, ICEMT(ice, CAPTURE_SIZE));
1095 outw((snd_pcm_lib_period_bytes(substream) >> 2) - 1, ICEMT(ice, CAPTURE_COUNT));
1096 spin_unlock_irq(&ice->reg_lock);
1103 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
1105 snd_ice1712_set_pro_rate(ice, params_rate(hw_params), 0);
1111 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
1114 if (!(inl(ICEMT(ice, PLAYBACK_CONTROL)) & ICE1712_PLAYBACK_START))
1116 ptr = ice->playback_pro_size - (inw(ICEMT(ice, PLAYBACK_SIZE)) << 2);
1124 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
1127 if (!(inl(ICEMT(ice, PLAYBACK_CONTROL)) & ICE1712_CAPTURE_START_SHADOW))
1129 ptr = ice->capture_pro_size - (inw(ICEMT(ice, CAPTURE_SIZE)) << 2);
1176 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
1178 ice->playback_pro_substream = substream;
1183 if (is_pro_rate_locked(ice)) {
1188 if (ice->spdif.ops.open)
1189 ice->spdif.ops.open(ice, substream);
1196 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
1199 ice->capture_pro_substream = substream;
1204 if (is_pro_rate_locked(ice)) {
1214 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
1217 snd_ice1712_set_pro_rate(ice, PRO_RATE_DEFAULT, 0);
1218 ice->playback_pro_substream = NULL;
1219 if (ice->spdif.ops.close)
1220 ice->spdif.ops.close(ice, substream);
1227 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
1230 snd_ice1712_set_pro_rate(ice, PRO_RATE_DEFAULT, 0);
1231 ice->capture_pro_substream = NULL;
1257 static int __devinit snd_ice1712_pcm_profi(struct snd_ice1712 *ice, int device, struct snd_pcm **rpcm)
1264 err = snd_pcm_new(ice->card, "ICE1712 multi", device, 1, 1, &pcm);
1271 pcm->private_data = ice;
1276 snd_dma_pci_data(ice->pci), 256*1024, 256*1024);
1278 ice->pcm_pro = pcm;
1282 if (ice->cs8427) {
1284 err = snd_cs8427_iec958_build(ice->cs8427,
1291 err = snd_ice1712_build_pro_mixer(ice);
1301 static void snd_ice1712_update_volume(struct snd_ice1712 *ice, int index)
1303 unsigned int vol = ice->pro_volumes[index];
1308 outb(index, ICEMT(ice, MONITOR_INDEX));
1309 outw(val, ICEMT(ice, MONITOR_VOLUME));
1316 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1320 spin_lock_irq(&ice->reg_lock);
1322 !((ice->pro_volumes[priv_idx] >> 15) & 1);
1324 !((ice->pro_volumes[priv_idx] >> 31) & 1);
1325 spin_unlock_irq(&ice->reg_lock);
1331 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1338 spin_lock_irq(&ice->reg_lock);
1339 nval |= ice->pro_volumes[priv_idx] & ~0x80008000;
1340 change = nval != ice->pro_volumes[priv_idx];
1341 ice->pro_volumes[priv_idx] = nval;
1342 snd_ice1712_update_volume(ice, priv_idx);
1343 spin_unlock_irq(&ice->reg_lock);
1358 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1362 spin_lock_irq(&ice->reg_lock);
1364 (ice->pro_volumes[priv_idx] >> 0) & 127;
1366 (ice->pro_volumes[priv_idx] >> 16) & 127;
1367 spin_unlock_irq(&ice->reg_lock);
1373 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1380 spin_lock_irq(&ice->reg_lock);
1381 nval |= ice->pro_volumes[priv_idx] & ~0x007f007f;
1382 change = nval != ice->pro_volumes[priv_idx];
1383 ice->pro_volumes[priv_idx] = nval;
1384 snd_ice1712_update_volume(ice, priv_idx);
1385 spin_unlock_irq(&ice->reg_lock);
1456 static int __devinit snd_ice1712_build_pro_mixer(struct snd_ice1712 *ice)
1458 struct snd_card *card = ice->card;
1464 err = snd_ctl_add(card, snd_ctl_new1(&snd_ice1712_multi_playback_ctrls[idx], ice));
1469 if (ice->num_total_adcs > 0) {
1471 tmp.count = ice->num_total_adcs;
1472 err = snd_ctl_add(card, snd_ctl_new1(&tmp, ice));
1477 err = snd_ctl_add(card, snd_ctl_new1(&snd_ice1712_multi_capture_spdif_switch, ice));
1481 if (ice->num_total_adcs > 0) {
1483 tmp.count = ice->num_total_adcs;
1484 err = snd_ctl_add(card, snd_ctl_new1(&tmp, ice));
1489 err = snd_ctl_add(card, snd_ctl_new1(&snd_ice1712_multi_capture_spdif_volume, ice));
1495 ice->pro_volumes[idx] = 0x80008000; /* mute */
1496 snd_ice1712_update_volume(ice, idx);
1498 for (idx = 10; idx < 10 + ice->num_total_adcs; idx++) {
1499 ice->pro_volumes[idx] = 0x80008000; /* mute */
1500 snd_ice1712_update_volume(ice, idx);
1503 ice->pro_volumes[idx] = 0x80008000; /* mute */
1504 snd_ice1712_update_volume(ice, idx);
1511 struct snd_ice1712 *ice = ac97->private_data;
1512 ice->ac97 = NULL;
1515 static int __devinit snd_ice1712_ac97_mixer(struct snd_ice1712 *ice)
1529 if (ice_has_con_ac97(ice)) {
1530 err = snd_ac97_bus(ice->card, bus_num++, &con_ops, NULL, &pbus);
1534 ac97.private_data = ice;
1536 err = snd_ac97_mixer(pbus, &ac97, &ice->ac97);
1540 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_mixer_digmix_route_ac97, ice));
1547 if (!(ice->eeprom.data[ICE_EEP1_ACLINK] & ICE1712_CFG_PRO_I2S)) {
1548 err = snd_ac97_bus(ice->card, bus_num, &pro_ops, NULL, &pbus);
1552 ac97.private_data = ice;
1554 err = snd_ac97_mixer(pbus, &ac97, &ice->ac97);
1561 strcat(ice->card->mixername, "ICE1712 - multitrack");
1569 static inline unsigned int eeprom_double(struct snd_ice1712 *ice, int idx)
1571 return (unsigned int)ice->eeprom.data[idx] | ((unsigned int)ice->eeprom.data[idx + 1] << 8);
1577 struct snd_ice1712 *ice = entry->private_data;
1580 snd_iprintf(buffer, "%s\n\n", ice->card->longname);
1583 snd_iprintf(buffer, " Subvendor : 0x%x\n", ice->eeprom.subvendor);
1584 snd_iprintf(buffer, " Size : %i bytes\n", ice->eeprom.size);
1585 snd_iprintf(buffer, " Version : %i\n", ice->eeprom.version);
1586 snd_iprintf(buffer, " Codec : 0x%x\n", ice->eeprom.data[ICE_EEP1_CODEC]);
1587 snd_iprintf(buffer, " ACLink : 0x%x\n", ice->eeprom.data[ICE_EEP1_ACLINK]);
1588 snd_iprintf(buffer, " I2S ID : 0x%x\n", ice->eeprom.data[ICE_EEP1_I2SID]);
1589 snd_iprintf(buffer, " S/PDIF : 0x%x\n", ice->eeprom.data[ICE_EEP1_SPDIF]);
1590 snd_iprintf(buffer, " GPIO mask : 0x%x\n", ice->eeprom.gpiomask);
1591 snd_iprintf(buffer, " GPIO state : 0x%x\n", ice->eeprom.gpiostate);
1592 snd_iprintf(buffer, " GPIO direction : 0x%x\n", ice->eeprom.gpiodir);
1593 snd_iprintf(buffer, " AC'97 main : 0x%x\n", eeprom_double(ice, ICE_EEP1_AC97_MAIN_LO));
1594 snd_iprintf(buffer, " AC'97 pcm : 0x%x\n", eeprom_double(ice, ICE_EEP1_AC97_PCM_LO));
1595 snd_iprintf(buffer, " AC'97 record : 0x%x\n", eeprom_double(ice, ICE_EEP1_AC97_REC_LO));
1596 snd_iprintf(buffer, " AC'97 record src : 0x%x\n", ice->eeprom.data[ICE_EEP1_AC97_RECSRC]);
1598 snd_iprintf(buffer, " DAC ID #%i : 0x%x\n", idx, ice->eeprom.data[ICE_EEP1_DAC_ID + idx]);
1600 snd_iprintf(buffer, " ADC ID #%i : 0x%x\n", idx, ice->eeprom.data[ICE_EEP1_ADC_ID + idx]);
1601 for (idx = 0x1c; idx < ice->eeprom.size; idx++)
1602 snd_iprintf(buffer, " Extra #%02i : 0x%x\n", idx, ice->eeprom.data[idx]);
1605 snd_iprintf(buffer, " PSDOUT03 : 0x%04x\n", (unsigned)inw(ICEMT(ice, ROUTE_PSDOUT03)));
1606 snd_iprintf(buffer, " CAPTURE : 0x%08x\n", inl(ICEMT(ice, ROUTE_CAPTURE)));
1607 snd_iprintf(buffer, " SPDOUT : 0x%04x\n", (unsigned)inw(ICEMT(ice, ROUTE_SPDOUT)));
1608 snd_iprintf(buffer, " RATE : 0x%02x\n", (unsigned)inb(ICEMT(ice, RATE)));
1609 snd_iprintf(buffer, " GPIO_DATA : 0x%02x\n", (unsigned)snd_ice1712_get_gpio_data(ice));
1610 snd_iprintf(buffer, " GPIO_WRITE_MASK : 0x%02x\n", (unsigned)snd_ice1712_read(ice, ICE1712_IREG_GPIO_WRITE_MASK));
1611 snd_iprintf(buffer, " GPIO_DIRECTION : 0x%02x\n", (unsigned)snd_ice1712_read(ice, ICE1712_IREG_GPIO_DIRECTION));
1614 static void __devinit snd_ice1712_proc_init(struct snd_ice1712 *ice)
1618 if (!snd_card_proc_new(ice->card, "ice1712", &entry))
1619 snd_info_set_text_ops(entry, ice, snd_ice1712_proc_read);
1637 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1639 memcpy(ucontrol->value.bytes.data, &ice->eeprom, sizeof(ice->eeprom));
1664 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1665 if (ice->spdif.ops.default_get)
1666 ice->spdif.ops.default_get(ice, ucontrol);
1673 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1674 if (ice->spdif.ops.default_put)
1675 return ice->spdif.ops.default_put(ice, ucontrol);
1691 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1692 if (ice->spdif.ops.default_get) {
1713 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1714 if (ice->spdif.ops.default_get) {
1751 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1752 if (ice->spdif.ops.stream_get)
1753 ice->spdif.ops.stream_get(ice, ucontrol);
1760 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1761 if (ice->spdif.ops.stream_put)
1762 return ice->spdif.ops.stream_put(ice, ucontrol);
1780 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1784 snd_ice1712_save_gpio_status(ice);
1786 (snd_ice1712_gpio_read(ice) & mask ? 1 : 0) ^ invert;
1787 snd_ice1712_restore_gpio_status(ice);
1794 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1802 snd_ice1712_save_gpio_status(ice);
1803 val = snd_ice1712_gpio_read(ice);
1806 snd_ice1712_gpio_write(ice, nval);
1807 snd_ice1712_restore_gpio_status(ice);
1845 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1851 spin_lock_irq(&ice->reg_lock);
1852 if (is_spdif_master(ice)) {
1855 val = xlate[inb(ICEMT(ice, RATE)) & 15];
1862 spin_unlock_irq(&ice->reg_lock);
1869 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1877 spin_lock_irq(&ice->reg_lock);
1878 oval = inb(ICEMT(ice, RATE));
1880 outb(oval | ICE1712_SPDIF_MASTER, ICEMT(ice, RATE));
1883 spin_unlock_irq(&ice->reg_lock);
1884 snd_ice1712_set_pro_rate(ice, PRO_RATE_DEFAULT, 1);
1885 spin_lock_irq(&ice->reg_lock);
1887 change = inb(ICEMT(ice, RATE)) != oval;
1888 spin_unlock_irq(&ice->reg_lock);
1891 (inb(ICEMT(ice, RATE)) & ICE1712_SPDIF_MASTER))
1892 snd_ice1712_set_input_clock_source(ice, is_spdif_master(ice));
1988 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1992 spin_lock_irq(&ice->reg_lock);
1995 spin_unlock_irq(&ice->reg_lock);
2019 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
2023 spin_lock_irq(&ice->reg_lock);
2026 spin_unlock_irq(&ice->reg_lock);
2065 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
2069 spin_lock_irq(&ice->reg_lock);
2070 val = inw(ICEMT(ice, ROUTE_PSDOUT03));
2071 cval = inl(ICEMT(ice, ROUTE_CAPTURE));
2072 spin_unlock_irq(&ice->reg_lock);
2091 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
2106 spin_lock_irq(&ice->reg_lock);
2107 val = old_val = inw(ICEMT(ice, ROUTE_PSDOUT03));
2112 outw(val, ICEMT(ice, ROUTE_PSDOUT03));
2113 spin_unlock_irq(&ice->reg_lock);
2118 spin_lock_irq(&ice->reg_lock);
2119 val = old_val = inl(ICEMT(ice, ROUTE_CAPTURE));
2132 outl(val, ICEMT(ice, ROUTE_CAPTURE));
2134 spin_unlock_irq(&ice->reg_lock);
2141 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
2144 val = inw(ICEMT(ice, ROUTE_SPDOUT));
2161 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
2167 spin_lock_irq(&ice->reg_lock);
2168 val = old_val = inw(ICEMT(ice, ROUTE_SPDOUT));
2192 outw(val, ICEMT(ice, ROUTE_SPDOUT));
2193 spin_unlock_irq(&ice->reg_lock);
2228 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
2230 ucontrol->value.integer.value[0] = inb(ICEMT(ice, MONITOR_RATE));
2237 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
2240 spin_lock_irq(&ice->reg_lock);
2241 change = inb(ICEMT(ice, MONITOR_RATE)) != ucontrol->value.integer.value[0];
2242 outb(ucontrol->value.integer.value[0], ICEMT(ice, MONITOR_RATE));
2243 spin_unlock_irq(&ice->reg_lock);
2268 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
2271 spin_lock_irq(&ice->reg_lock);
2273 outb(idx, ICEMT(ice, MONITOR_PEAKINDEX));
2274 ucontrol->value.integer.value[idx] = inb(ICEMT(ice, MONITOR_PEAKDATA));
2276 spin_unlock_irq(&ice->reg_lock);
2302 static unsigned char __devinit snd_ice1712_read_i2c(struct snd_ice1712 *ice,
2308 outb(addr, ICEREG(ice, I2C_BYTE_ADDR));
2309 outb(dev & ~ICE1712_I2C_WRITE, ICEREG(ice, I2C_DEV_ADDR));
2310 while (t-- > 0 && (inb(ICEREG(ice, I2C_CTRL)) & ICE1712_I2C_BUSY)) ;
2311 return inb(ICEREG(ice, I2C_DATA));
2314 static int __devinit snd_ice1712_read_eeprom(struct snd_ice1712 *ice,
2322 ice->eeprom.subvendor = 0;
2323 if ((inb(ICEREG(ice, I2C_CTRL)) & ICE1712_I2C_EEPROM) != 0)
2324 ice->eeprom.subvendor = (snd_ice1712_read_i2c(ice, dev, 0x00) << 0) |
2325 (snd_ice1712_read_i2c(ice, dev, 0x01) << 8) |
2326 (snd_ice1712_read_i2c(ice, dev, 0x02) << 16) |
2327 (snd_ice1712_read_i2c(ice, dev, 0x03) << 24);
2328 if (ice->eeprom.subvendor == 0 ||
2329 ice->eeprom.subvendor == (unsigned int)-1) {
2332 pci_read_config_word(ice->pci, PCI_SUBSYSTEM_VENDOR_ID, &vendor);
2333 pci_read_config_word(ice->pci, PCI_SUBSYSTEM_ID, &device);
2334 ice->eeprom.subvendor = ((unsigned int)swab16(vendor) << 16) | swab16(device);
2335 if (ice->eeprom.subvendor == 0 || ice->eeprom.subvendor == (unsigned int)-1) {
2345 ice->eeprom.subvendor = c->subvendor;
2346 } else if (c->subvendor != ice->eeprom.subvendor)
2352 ice->eeprom.version = 1;
2353 ice->eeprom.size = c->eeprom_size + 6;
2354 memcpy(ice->eeprom.data, c->eeprom_data, c->eeprom_size);
2359 ice->eeprom.subvendor);
2362 ice->eeprom.size = snd_ice1712_read_i2c(ice, dev, 0x04);
2363 if (ice->eeprom.size < 6)
2364 ice->eeprom.size = 32;
2365 else if (ice->eeprom.size > 32) {
2366 snd_printk(KERN_ERR "invalid EEPROM (size = %i)\n", ice->eeprom.size);
2369 ice->eeprom.version = snd_ice1712_read_i2c(ice, dev, 0x05);
2370 if (ice->eeprom.version != 1) {
2372 ice->eeprom.version);
2375 size = ice->eeprom.size - 6;
2377 ice->eeprom.data[i] = snd_ice1712_read_i2c(ice, dev, i + 6);
2380 ice->eeprom.gpiomask = ice->eeprom.data[ICE_EEP1_GPIO_MASK];
2381 ice->eeprom.gpiostate = ice->eeprom.data[ICE_EEP1_GPIO_STATE];
2382 ice->eeprom.gpiodir = ice->eeprom.data[ICE_EEP1_GPIO_DIR];
2389 static int __devinit snd_ice1712_chip_init(struct snd_ice1712 *ice)
2391 outb(ICE1712_RESET | ICE1712_NATIVE, ICEREG(ice, CONTROL));
2393 outb(ICE1712_NATIVE, ICEREG(ice, CONTROL));
2395 if (ice->eeprom.subvendor == ICE1712_SUBDEVICE_DMX6FIRE &&
2396 !ice->dxr_enable)
2401 ice->eeprom.data[ICE_EEP1_CODEC] = 0x3a;
2402 pci_write_config_byte(ice->pci, 0x60, ice->eeprom.data[ICE_EEP1_CODEC]);
2403 pci_write_config_byte(ice->pci, 0x61, ice->eeprom.data[ICE_EEP1_ACLINK]);
2404 pci_write_config_byte(ice->pci, 0x62, ice->eeprom.data[ICE_EEP1_I2SID]);
2405 pci_write_config_byte(ice->pci, 0x63, ice->eeprom.data[ICE_EEP1_SPDIF]);
2406 if (ice->eeprom.subvendor != ICE1712_SUBDEVICE_STDSP24) {
2407 ice->gpio.write_mask = ice->eeprom.gpiomask;
2408 ice->gpio.direction = ice->eeprom.gpiodir;
2409 snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK,
2410 ice->eeprom.gpiomask);
2411 snd_ice1712_write(ice, ICE1712_IREG_GPIO_DIRECTION,
2412 ice->eeprom.gpiodir);
2413 snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA,
2414 ice->eeprom.gpiostate);
2416 ice->gpio.write_mask = 0xc0;
2417 ice->gpio.direction = 0xff;
2418 snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, 0xc0);
2419 snd_ice1712_write(ice, ICE1712_IREG_GPIO_DIRECTION, 0xff);
2420 snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA,
2423 snd_ice1712_write(ice, ICE1712_IREG_PRO_POWERDOWN, 0);
2424 if (!(ice->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_NO_CON_AC97)) {
2425 outb(ICE1712_AC97_WARM, ICEREG(ice, AC97_CMD));
2427 outb(0, ICEREG(ice, AC97_CMD));
2429 snd_ice1712_write(ice, ICE1712_IREG_CONSUMER_POWERDOWN, 0);
2431 snd_ice1712_set_pro_rate(ice, 48000, 1);
2436 int __devinit snd_ice1712_spdif_build_controls(struct snd_ice1712 *ice)
2441 if (snd_BUG_ON(!ice->pcm_pro))
2443 err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_ice1712_spdif_default, ice));
2446 kctl->id.device = ice->pcm_pro->device;
2447 err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_ice1712_spdif_maskc, ice));
2450 kctl->id.device = ice->pcm_pro->device;
2451 err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_ice1712_spdif_maskp, ice));
2454 kctl->id.device = ice->pcm_pro->device;
2455 err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_ice1712_spdif_stream, ice));
2458 kctl->id.device = ice->pcm_pro->device;
2459 ice->spdif.stream_ctl = kctl;
2464 static int __devinit snd_ice1712_build_controls(struct snd_ice1712 *ice)
2468 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_eeprom, ice));
2471 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_pro_internal_clock, ice));
2474 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_pro_internal_clock_default, ice));
2478 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_pro_rate_locking, ice));
2481 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_pro_rate_reset, ice));
2485 if (ice->num_total_dacs > 0) {
2487 tmp.count = ice->num_total_dacs;
2488 err = snd_ctl_add(ice->card, snd_ctl_new1(&tmp, ice));
2493 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_mixer_pro_spdif_route, ice));
2497 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_mixer_pro_volume_rate, ice));
2500 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_mixer_pro_peak, ice));
2507 static int snd_ice1712_free(struct snd_ice1712 *ice)
2509 if (!ice->port)
2512 outb(0xc0, ICEMT(ice, IRQ));
2513 outb(0xff, ICEREG(ice, IRQMASK));
2516 if (ice->irq >= 0)
2517 free_irq(ice->irq, ice);
2519 if (ice->port)
2520 pci_release_regions(ice->pci);
2521 snd_ice1712_akm4xxx_free(ice);
2522 pci_disable_device(ice->pci);
2523 kfree(ice->spec);
2524 kfree(ice);
2530 struct snd_ice1712 *ice = device->device_data;
2531 return snd_ice1712_free(ice);
2542 struct snd_ice1712 *ice;
2562 ice = kzalloc(sizeof(*ice), GFP_KERNEL);
2563 if (ice == NULL) {
2567 ice->omni = omni ? 1 : 0;
2572 ice->cs8427_timeout = cs8427_timeout;
2573 ice->dxr_enable = dxr_enable;
2574 spin_lock_init(&ice->reg_lock);
2575 mutex_init(&ice->gpio_mutex);
2576 mutex_init(&ice->i2c_mutex);
2577 mutex_init(&ice->open_mutex);
2578 ice->gpio.set_mask = snd_ice1712_set_gpio_mask;
2579 ice->gpio.get_mask = snd_ice1712_get_gpio_mask;
2580 ice->gpio.set_dir = snd_ice1712_set_gpio_dir;
2581 ice->gpio.get_dir = snd_ice1712_get_gpio_dir;
2582 ice->gpio.set_data = snd_ice1712_set_gpio_data;
2583 ice->gpio.get_data = snd_ice1712_get_gpio_data;
2585 ice->spdif.cs8403_bits =
2586 ice->spdif.cs8403_stream_bits = (0x01 | /* consumer format */
2589 ice->card = card;
2590 ice->pci = pci;
2591 ice->irq = -1;
2593 pci_write_config_word(ice->pci, 0x40, 0x807f);
2594 pci_write_config_word(ice->pci, 0x42, 0x0006);
2595 snd_ice1712_proc_init(ice);
2600 kfree(ice);
2604 ice->port = pci_resource_start(pci, 0);
2605 ice->ddma_port = pci_resource_start(pci, 1);
2606 ice->dmapath_port = pci_resource_start(pci, 2);
2607 ice->profi_port = pci_resource_start(pci, 3);
2610 "ICE1712", ice)) {
2612 snd_ice1712_free(ice);
2616 ice->irq = pci->irq;
2618 if (snd_ice1712_read_eeprom(ice, modelname) < 0) {
2619 snd_ice1712_free(ice);
2622 if (snd_ice1712_chip_init(ice) < 0) {
2623 snd_ice1712_free(ice);
2628 outb(((ice->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_2xMPU401) == 0 ?
2630 ((ice->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_NO_CON_AC97) ?
2632 ICEREG(ice, IRQMASK));
2633 outb(0x00, ICEMT(ice, IRQ));
2635 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, ice, &ops);
2637 snd_ice1712_free(ice);
2643 *r_ice1712 = ice;
2661 struct snd_ice1712 *ice;
2680 cs8427_timeout[dev], dxr_enable[dev], &ice);
2688 if (c->subvendor == ice->eeprom.subvendor) {
2693 err = c->chip_init(ice);
2706 err = snd_ice1712_pcm_profi(ice, pcm_dev++, NULL);
2712 if (ice_has_con_ac97(ice)) {
2713 err = snd_ice1712_pcm(ice, pcm_dev++, NULL);
2720 err = snd_ice1712_ac97_mixer(ice);
2726 err = snd_ice1712_build_controls(ice);
2733 err = c->build_controls(ice);
2740 if (ice_has_con_ac97(ice)) {
2741 err = snd_ice1712_pcm_ds(ice, pcm_dev++, NULL);
2750 ICEREG(ice, MPU1_CTRL),
2752 ice->irq, 0, &ice->rmidi[0]);
2759 snprintf(ice->rmidi[0]->name,
2760 sizeof(ice->rmidi[0]->name),
2763 if (ice->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_2xMPU401) {
2766 ICEREG(ice, MPU2_CTRL),
2768 ice->irq, 0, &ice->rmidi[1]);
2776 snprintf(ice->rmidi[1]->name,
2777 sizeof(ice->rmidi[1]->name),
2783 snd_ice1712_set_input_clock_source(ice, 0);
2786 card->shortname, ice->port, ice->irq);