• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/src/linux/linux-2.6/sound/pci/ice1712/

Lines Matching refs:ice

117 static int snd_ice1712_build_pro_mixer(struct snd_ice1712 *ice);
118 static int snd_ice1712_build_controls(struct snd_ice1712 *ice);
129 static inline int is_spdif_master(struct snd_ice1712 *ice)
131 return (inb(ICEMT(ice, RATE)) & ICE1712_SPDIF_MASTER) ? 1 : 0;
134 static inline int is_pro_rate_locked(struct snd_ice1712 *ice)
136 return is_spdif_master(ice) || PRO_RATE_LOCKED;
139 static inline void snd_ice1712_ds_write(struct snd_ice1712 * ice, u8 channel, u8 addr, u32 data)
141 outb((channel << 4) | addr, ICEDS(ice, INDEX));
142 outl(data, ICEDS(ice, DATA));
145 static inline u32 snd_ice1712_ds_read(struct snd_ice1712 * ice, u8 channel, u8 addr)
147 outb((channel << 4) | addr, ICEDS(ice, INDEX));
148 return inl(ICEDS(ice, DATA));
155 struct snd_ice1712 *ice = ac97->private_data;
160 old_cmd = inb(ICEREG(ice, AC97_CMD));
167 outb(reg, ICEREG(ice, AC97_INDEX));
168 outw(val, ICEREG(ice, AC97_DATA));
170 outb(old_cmd | ICE1712_AC97_WRITE, ICEREG(ice, AC97_CMD));
172 if ((inb(ICEREG(ice, AC97_CMD)) & ICE1712_AC97_WRITE) == 0)
179 struct snd_ice1712 *ice = ac97->private_data;
184 old_cmd = inb(ICEREG(ice, AC97_CMD));
191 outb(reg, ICEREG(ice, AC97_INDEX));
192 outb(old_cmd | ICE1712_AC97_READ, ICEREG(ice, AC97_CMD));
194 if ((inb(ICEREG(ice, AC97_CMD)) & ICE1712_AC97_READ) == 0)
198 return inw(ICEREG(ice, AC97_DATA));
209 struct snd_ice1712 *ice = ac97->private_data;
214 old_cmd = inb(ICEMT(ice, AC97_CMD));
221 outb(reg, ICEMT(ice, AC97_INDEX));
222 outw(val, ICEMT(ice, AC97_DATA));
224 outb(old_cmd | ICE1712_AC97_WRITE, ICEMT(ice, AC97_CMD));
226 if ((inb(ICEMT(ice, AC97_CMD)) & ICE1712_AC97_WRITE) == 0)
234 struct snd_ice1712 *ice = ac97->private_data;
239 old_cmd = inb(ICEMT(ice, AC97_CMD));
246 outb(reg, ICEMT(ice, AC97_INDEX));
247 outb(old_cmd | ICE1712_AC97_READ, ICEMT(ice, AC97_CMD));
249 if ((inb(ICEMT(ice, AC97_CMD)) & ICE1712_AC97_READ) == 0)
253 return inw(ICEMT(ice, AC97_DATA));
270 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
272 ucontrol->value.integer.value[0] = inb(ICEMT(ice, MONITOR_ROUTECTRL)) & ICE1712_ROUTE_AC97 ? 1 : 0;
278 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
281 spin_lock_irq(&ice->reg_lock);
282 val = inb(ICEMT(ice, MONITOR_ROUTECTRL));
285 outb(nval, ICEMT(ice, MONITOR_ROUTECTRL));
286 spin_unlock_irq(&ice->reg_lock);
302 static void snd_ice1712_set_gpio_dir(struct snd_ice1712 *ice, unsigned int data)
304 snd_ice1712_write(ice, ICE1712_IREG_GPIO_DIRECTION, data);
305 inb(ICEREG(ice, DATA)); /* dummy read for pci-posting */
308 static void snd_ice1712_set_gpio_mask(struct snd_ice1712 *ice, unsigned int data)
310 snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, data);
311 inb(ICEREG(ice, DATA)); /* dummy read for pci-posting */
314 static unsigned int snd_ice1712_get_gpio_data(struct snd_ice1712 *ice)
316 return snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA);
319 static void snd_ice1712_set_gpio_data(struct snd_ice1712 *ice, unsigned int val)
321 snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, val);
322 inb(ICEREG(ice, DATA)); /* dummy read for pci-posting */
335 static int snd_ice1712_cs8427_set_input_clock(struct snd_ice1712 *ice, int spdif_clock)
341 snd_i2c_lock(ice->i2c);
342 if (snd_i2c_sendbytes(ice->cs8427, reg, 1) != 1) {
343 snd_i2c_unlock(ice->i2c);
346 if (snd_i2c_readbytes(ice->cs8427, &val, 1) != 1) {
347 snd_i2c_unlock(ice->i2c);
357 if (snd_i2c_sendbytes(ice->cs8427, reg, 2) != 2) {
363 snd_i2c_unlock(ice->i2c);
370 static void open_cs8427(struct snd_ice1712 *ice, struct snd_pcm_substream *substream)
372 snd_cs8427_iec958_active(ice->cs8427, 1);
375 static void close_cs8427(struct snd_ice1712 *ice, struct snd_pcm_substream *substream)
377 snd_cs8427_iec958_active(ice->cs8427, 0);
380 static void setup_cs8427(struct snd_ice1712 *ice, int rate)
382 snd_cs8427_iec958_pcm(ice->cs8427, rate);
388 int __devinit snd_ice1712_init_cs8427(struct snd_ice1712 *ice, int addr)
392 if ((err = snd_cs8427_create(ice->i2c, addr,
393 (ice->cs8427_timeout * HZ) / 1000,
394 &ice->cs8427)) < 0) {
398 ice->spdif.ops.open = open_cs8427;
399 ice->spdif.ops.close = close_cs8427;
400 ice->spdif.ops.setup_rate = setup_cs8427;
404 static void snd_ice1712_set_input_clock_source(struct snd_ice1712 *ice, int spdif_is_master)
407 if (ice->cs8427)
408 snd_ice1712_cs8427_set_input_clock(ice, spdif_is_master);
412 for (i = 0; i < ice->akm_codecs; i++) {
413 if (ice->akm[i].ops.set_rate_val)
414 ice->akm[i].ops.set_rate_val(&ice->akm[i], 0);
425 struct snd_ice1712 *ice = dev_id;
430 status = inb(ICEREG(ice, IRQSTAT));
435 if (ice->rmidi[0])
436 snd_mpu401_uart_interrupt(irq, ice->rmidi[0]->private_data);
437 outb(ICE1712_IRQ_MPU1, ICEREG(ice, IRQSTAT));
441 outb(ICE1712_IRQ_TIMER, ICEREG(ice, IRQSTAT));
443 if (ice->rmidi[1])
444 snd_mpu401_uart_interrupt(irq, ice->rmidi[1]->private_data);
445 outb(ICE1712_IRQ_MPU2, ICEREG(ice, IRQSTAT));
449 unsigned char mtstat = inb(ICEMT(ice, IRQ));
451 if (ice->playback_pro_substream)
452 snd_pcm_period_elapsed(ice->playback_pro_substream);
453 outb(ICE1712_MULTI_PBKSTATUS, ICEMT(ice, IRQ));
456 if (ice->capture_pro_substream)
457 snd_pcm_period_elapsed(ice->capture_pro_substream);
458 outb(ICE1712_MULTI_CAPSTATUS, ICEMT(ice, IRQ));
462 outb(ICE1712_IRQ_FM, ICEREG(ice, IRQSTAT));
467 pbkstatus = inw(ICEDS(ice, INTSTAT));
472 if ((substream = ice->playback_con_substream_ds[idx]) != NULL)
474 outw(3 << (idx * 2), ICEDS(ice, INTSTAT));
476 outb(ICE1712_IRQ_PBKDS, ICEREG(ice, IRQSTAT));
479 if (ice->capture_con_substream)
480 snd_pcm_period_elapsed(ice->capture_con_substream);
481 outb(ICE1712_IRQ_CONCAP, ICEREG(ice, IRQSTAT));
484 if (ice->playback_con_substream)
485 snd_pcm_period_elapsed(ice->playback_con_substream);
486 outb(ICE1712_IRQ_CONPBK, ICEREG(ice, IRQSTAT));
515 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
519 spin_lock(&ice->reg_lock);
520 tmp = snd_ice1712_read(ice, ICE1712_IREG_PBK_CTRL);
532 snd_ice1712_write(ice, ICE1712_IREG_PBK_CTRL, tmp);
533 spin_unlock(&ice->reg_lock);
540 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
544 spin_lock(&ice->reg_lock);
545 tmp = snd_ice1712_ds_read(ice, substream->number * 2, ICE1712_DSC_CONTROL);
557 snd_ice1712_ds_write(ice, substream->number * 2, ICE1712_DSC_CONTROL, tmp);
558 spin_unlock(&ice->reg_lock);
565 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
569 spin_lock(&ice->reg_lock);
570 tmp = snd_ice1712_read(ice, ICE1712_IREG_CAP_CTRL);
578 snd_ice1712_write(ice, ICE1712_IREG_CAP_CTRL, tmp);
579 spin_unlock(&ice->reg_lock);
585 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
599 spin_lock_irq(&ice->reg_lock);
600 outb(0, ice->ddma_port + 15);
601 outb(ICE1712_DMA_MODE_WRITE | ICE1712_DMA_AUTOINIT, ice->ddma_port + 0x0b);
602 outl(runtime->dma_addr, ice->ddma_port + 0);
603 outw(buf_size, ice->ddma_port + 4);
604 snd_ice1712_write(ice, ICE1712_IREG_PBK_RATE_LO, rate & 0xff);
605 snd_ice1712_write(ice, ICE1712_IREG_PBK_RATE_MID, (rate >> 8) & 0xff);
606 snd_ice1712_write(ice, ICE1712_IREG_PBK_RATE_HI, (rate >> 16) & 0xff);
607 snd_ice1712_write(ice, ICE1712_IREG_PBK_CTRL, tmp);
608 snd_ice1712_write(ice, ICE1712_IREG_PBK_COUNT_LO, period_size & 0xff);
609 snd_ice1712_write(ice, ICE1712_IREG_PBK_COUNT_HI, period_size >> 8);
610 snd_ice1712_write(ice, ICE1712_IREG_PBK_LEFT, 0);
611 snd_ice1712_write(ice, ICE1712_IREG_PBK_RIGHT, 0);
612 spin_unlock_irq(&ice->reg_lock);
618 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
632 ice->playback_con_active_buf[substream->number] = 0;
633 ice->playback_con_virt_addr[substream->number] = runtime->dma_addr;
635 spin_lock_irq(&ice->reg_lock);
636 snd_ice1712_ds_write(ice, chn, ICE1712_DSC_ADDR0, runtime->dma_addr);
637 snd_ice1712_ds_write(ice, chn, ICE1712_DSC_COUNT0, period_size);
638 snd_ice1712_ds_write(ice, chn, ICE1712_DSC_ADDR1, runtime->dma_addr + (runtime->periods > 1 ? period_size + 1 : 0));
639 snd_ice1712_ds_write(ice, chn, ICE1712_DSC_COUNT1, period_size);
640 snd_ice1712_ds_write(ice, chn, ICE1712_DSC_RATE, rate);
641 snd_ice1712_ds_write(ice, chn, ICE1712_DSC_VOLUME, 0);
642 snd_ice1712_ds_write(ice, chn, ICE1712_DSC_CONTROL, tmp);
644 snd_ice1712_ds_write(ice, chn + 1, ICE1712_DSC_RATE, rate);
645 snd_ice1712_ds_write(ice, chn + 1, ICE1712_DSC_VOLUME, 0);
647 spin_unlock_irq(&ice->reg_lock);
653 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
665 spin_lock_irq(&ice->reg_lock);
666 outl(ice->capture_con_virt_addr = runtime->dma_addr, ICEREG(ice, CONCAP_ADDR));
667 outw(buf_size, ICEREG(ice, CONCAP_COUNT));
668 snd_ice1712_write(ice, ICE1712_IREG_CAP_COUNT_HI, period_size >> 8);
669 snd_ice1712_write(ice, ICE1712_IREG_CAP_COUNT_LO, period_size & 0xff);
670 snd_ice1712_write(ice, ICE1712_IREG_CAP_CTRL, tmp);
671 spin_unlock_irq(&ice->reg_lock);
672 snd_ac97_set_rate(ice->ac97, AC97_PCM_LR_ADC_RATE, runtime->rate);
678 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
682 if (!(snd_ice1712_read(ice, ICE1712_IREG_PBK_CTRL) & 1))
684 ptr = runtime->buffer_size - inw(ice->ddma_port + 4);
692 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
696 if (!(snd_ice1712_ds_read(ice, substream->number * 2, ICE1712_DSC_CONTROL) & 1))
698 if (ice->playback_con_active_buf[substream->number])
702 ptr = snd_ice1712_ds_read(ice, substream->number * 2, addr) -
703 ice->playback_con_virt_addr[substream->number];
711 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
714 if (!(snd_ice1712_read(ice, ICE1712_IREG_CAP_CTRL) & 1))
716 ptr = inl(ICEREG(ice, CONCAP_ADDR)) - ice->capture_con_virt_addr;
784 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
786 ice->playback_con_substream = substream;
794 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
797 ice->playback_con_substream_ds[substream->number] = substream;
799 spin_lock_irq(&ice->reg_lock);
800 tmp = inw(ICEDS(ice, INTMASK)) & ~(1 << (substream->number * 2));
801 outw(tmp, ICEDS(ice, INTMASK));
802 spin_unlock_irq(&ice->reg_lock);
809 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
811 ice->capture_con_substream = substream;
813 runtime->hw.rates = ice->ac97->rates[AC97_RATES_ADC];
821 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
823 ice->playback_con_substream = NULL;
829 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
832 spin_lock_irq(&ice->reg_lock);
833 tmp = inw(ICEDS(ice, INTMASK)) | (3 << (substream->number * 2));
834 outw(tmp, ICEDS(ice, INTMASK));
835 spin_unlock_irq(&ice->reg_lock);
836 ice->playback_con_substream_ds[substream->number] = NULL;
842 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
844 ice->capture_con_substream = NULL;
881 static int __devinit snd_ice1712_pcm(struct snd_ice1712 * ice, int device, struct snd_pcm ** rpcm)
888 err = snd_pcm_new(ice->card, "ICE1712 consumer", device, 1, 1, &pcm);
895 pcm->private_data = ice;
898 ice->pcm = pcm;
901 snd_dma_pci_data(ice->pci), 64*1024, 64*1024);
911 static int __devinit snd_ice1712_pcm_ds(struct snd_ice1712 * ice, int device, struct snd_pcm ** rpcm)
918 err = snd_pcm_new(ice->card, "ICE1712 consumer (DS)", device, 6, 0, &pcm);
924 pcm->private_data = ice;
927 ice->pcm_ds = pcm;
930 snd_dma_pci_data(ice->pci), 64*1024, 128*1024);
954 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
965 spin_lock(&ice->reg_lock);
966 old = inl(ICEMT(ice, PLAYBACK_CONTROL));
971 outl(old, ICEMT(ice, PLAYBACK_CONTROL));
972 spin_unlock(&ice->reg_lock);
983 if (s == ice->playback_pro_substream) {
986 } else if (s == ice->capture_pro_substream) {
991 spin_lock(&ice->reg_lock);
992 old = inl(ICEMT(ice, PLAYBACK_CONTROL));
997 outl(old, ICEMT(ice, PLAYBACK_CONTROL));
998 spin_unlock(&ice->reg_lock);
1009 static void snd_ice1712_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate, int force)
1036 spin_lock_irqsave(&ice->reg_lock, flags);
1037 if (inb(ICEMT(ice, PLAYBACK_CONTROL)) & (ICE1712_CAPTURE_START_SHADOW|
1041 spin_unlock_irqrestore(&ice->reg_lock, flags);
1044 if (!force && is_pro_rate_locked(ice))
1047 old = inb(ICEMT(ice, RATE));
1050 outb(val, ICEMT(ice, RATE));
1051 spin_unlock_irqrestore(&ice->reg_lock, flags);
1053 if (ice->gpio.set_pro_rate)
1054 ice->gpio.set_pro_rate(ice, rate);
1055 for (i = 0; i < ice->akm_codecs; i++) {
1056 if (ice->akm[i].ops.set_rate_val)
1057 ice->akm[i].ops.set_rate_val(&ice->akm[i], rate);
1059 if (ice->spdif.ops.setup_rate)
1060 ice->spdif.ops.setup_rate(ice, rate);
1065 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
1067 ice->playback_pro_size = snd_pcm_lib_buffer_bytes(substream);
1068 spin_lock_irq(&ice->reg_lock);
1069 outl(substream->runtime->dma_addr, ICEMT(ice, PLAYBACK_ADDR));
1070 outw((ice->playback_pro_size >> 2) - 1, ICEMT(ice, PLAYBACK_SIZE));
1071 outw((snd_pcm_lib_period_bytes(substream) >> 2) - 1, ICEMT(ice, PLAYBACK_COUNT));
1072 spin_unlock_irq(&ice->reg_lock);
1080 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
1082 snd_ice1712_set_pro_rate(ice, params_rate(hw_params), 0);
1088 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
1090 ice->capture_pro_size = snd_pcm_lib_buffer_bytes(substream);
1091 spin_lock_irq(&ice->reg_lock);
1092 outl(substream->runtime->dma_addr, ICEMT(ice, CAPTURE_ADDR));
1093 outw((ice->capture_pro_size >> 2) - 1, ICEMT(ice, CAPTURE_SIZE));
1094 outw((snd_pcm_lib_period_bytes(substream) >> 2) - 1, ICEMT(ice, CAPTURE_COUNT));
1095 spin_unlock_irq(&ice->reg_lock);
1102 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
1104 snd_ice1712_set_pro_rate(ice, params_rate(hw_params), 0);
1110 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
1113 if (!(inl(ICEMT(ice, PLAYBACK_CONTROL)) & ICE1712_PLAYBACK_START))
1115 ptr = ice->playback_pro_size - (inw(ICEMT(ice, PLAYBACK_SIZE)) << 2);
1123 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
1126 if (!(inl(ICEMT(ice, PLAYBACK_CONTROL)) & ICE1712_CAPTURE_START_SHADOW))
1128 ptr = ice->capture_pro_size - (inw(ICEMT(ice, CAPTURE_SIZE)) << 2);
1177 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
1179 ice->playback_pro_substream = substream;
1185 if (ice->spdif.ops.open)
1186 ice->spdif.ops.open(ice, substream);
1193 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
1196 ice->capture_pro_substream = substream;
1206 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
1209 snd_ice1712_set_pro_rate(ice, PRO_RATE_DEFAULT, 0);
1210 ice->playback_pro_substream = NULL;
1211 if (ice->spdif.ops.close)
1212 ice->spdif.ops.close(ice, substream);
1219 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
1222 snd_ice1712_set_pro_rate(ice, PRO_RATE_DEFAULT, 0);
1223 ice->capture_pro_substream = NULL;
1249 static int __devinit snd_ice1712_pcm_profi(struct snd_ice1712 * ice, int device, struct snd_pcm ** rpcm)
1256 err = snd_pcm_new(ice->card, "ICE1712 multi", device, 1, 1, &pcm);
1263 pcm->private_data = ice;
1268 snd_dma_pci_data(ice->pci), 256*1024, 256*1024);
1270 ice->pcm_pro = pcm;
1274 if (ice->cs8427) {
1276 err = snd_cs8427_iec958_build(ice->cs8427,
1283 if ((err = snd_ice1712_build_pro_mixer(ice)) < 0)
1292 static void snd_ice1712_update_volume(struct snd_ice1712 *ice, int index)
1294 unsigned int vol = ice->pro_volumes[index];
1299 outb(index, ICEMT(ice, MONITOR_INDEX));
1300 outw(val, ICEMT(ice, MONITOR_VOLUME));
1314 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1317 spin_lock_irq(&ice->reg_lock);
1318 ucontrol->value.integer.value[0] = !((ice->pro_volumes[index] >> 15) & 1);
1319 ucontrol->value.integer.value[1] = !((ice->pro_volumes[index] >> 31) & 1);
1320 spin_unlock_irq(&ice->reg_lock);
1326 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1332 spin_lock_irq(&ice->reg_lock);
1333 nval |= ice->pro_volumes[index] & ~0x80008000;
1334 change = nval != ice->pro_volumes[index];
1335 ice->pro_volumes[index] = nval;
1336 snd_ice1712_update_volume(ice, index);
1337 spin_unlock_irq(&ice->reg_lock);
1352 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1355 spin_lock_irq(&ice->reg_lock);
1356 ucontrol->value.integer.value[0] = (ice->pro_volumes[index] >> 0) & 127;
1357 ucontrol->value.integer.value[1] = (ice->pro_volumes[index] >> 16) & 127;
1358 spin_unlock_irq(&ice->reg_lock);
1364 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1370 spin_lock_irq(&ice->reg_lock);
1371 nval |= ice->pro_volumes[index] & ~0x007f007f;
1372 change = nval != ice->pro_volumes[index];
1373 ice->pro_volumes[index] = nval;
1374 snd_ice1712_update_volume(ice, index);
1375 spin_unlock_irq(&ice->reg_lock);
1446 static int __devinit snd_ice1712_build_pro_mixer(struct snd_ice1712 *ice)
1448 struct snd_card *card = ice->card;
1454 err = snd_ctl_add(card, snd_ctl_new1(&snd_ice1712_multi_playback_ctrls[idx], ice));
1459 if (ice->num_total_adcs > 0) {
1461 tmp.count = ice->num_total_adcs;
1462 err = snd_ctl_add(card, snd_ctl_new1(&tmp, ice));
1467 err = snd_ctl_add(card, snd_ctl_new1(&snd_ice1712_multi_capture_spdif_switch, ice));
1471 if (ice->num_total_adcs > 0) {
1473 tmp.count = ice->num_total_adcs;
1474 err = snd_ctl_add(card, snd_ctl_new1(&tmp, ice));
1479 err = snd_ctl_add(card, snd_ctl_new1(&snd_ice1712_multi_capture_spdif_volume, ice));
1485 ice->pro_volumes[idx] = 0x80008000; /* mute */
1486 snd_ice1712_update_volume(ice, idx);
1488 for (idx = 10; idx < 10 + ice->num_total_adcs; idx++) {
1489 ice->pro_volumes[idx] = 0x80008000; /* mute */
1490 snd_ice1712_update_volume(ice, idx);
1493 ice->pro_volumes[idx] = 0x80008000; /* mute */
1494 snd_ice1712_update_volume(ice, idx);
1501 struct snd_ice1712 *ice = ac97->private_data;
1502 ice->ac97 = NULL;
1505 static int __devinit snd_ice1712_ac97_mixer(struct snd_ice1712 * ice)
1519 if (ice_has_con_ac97(ice)) {
1520 if ((err = snd_ac97_bus(ice->card, bus_num++, &con_ops, NULL, &pbus)) < 0)
1523 ac97.private_data = ice;
1525 if ((err = snd_ac97_mixer(pbus, &ac97, &ice->ac97)) < 0)
1528 if ((err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_mixer_digmix_route_ac97, ice))) < 0)
1534 if (! (ice->eeprom.data[ICE_EEP1_ACLINK] & ICE1712_CFG_PRO_I2S)) {
1535 if ((err = snd_ac97_bus(ice->card, bus_num, &pro_ops, NULL, &pbus)) < 0)
1538 ac97.private_data = ice;
1540 if ((err = snd_ac97_mixer(pbus, &ac97, &ice->ac97)) < 0)
1546 strcat(ice->card->mixername, "ICE1712 - multitrack");
1554 static inline unsigned int eeprom_double(struct snd_ice1712 *ice, int idx)
1556 return (unsigned int)ice->eeprom.data[idx] | ((unsigned int)ice->eeprom.data[idx + 1] << 8);
1562 struct snd_ice1712 *ice = entry->private_data;
1565 snd_iprintf(buffer, "%s\n\n", ice->card->longname);
1568 snd_iprintf(buffer, " Subvendor : 0x%x\n", ice->eeprom.subvendor);
1569 snd_iprintf(buffer, " Size : %i bytes\n", ice->eeprom.size);
1570 snd_iprintf(buffer, " Version : %i\n", ice->eeprom.version);
1571 snd_iprintf(buffer, " Codec : 0x%x\n", ice->eeprom.data[ICE_EEP1_CODEC]);
1572 snd_iprintf(buffer, " ACLink : 0x%x\n", ice->eeprom.data[ICE_EEP1_ACLINK]);
1573 snd_iprintf(buffer, " I2S ID : 0x%x\n", ice->eeprom.data[ICE_EEP1_I2SID]);
1574 snd_iprintf(buffer, " S/PDIF : 0x%x\n", ice->eeprom.data[ICE_EEP1_SPDIF]);
1575 snd_iprintf(buffer, " GPIO mask : 0x%x\n", ice->eeprom.gpiomask);
1576 snd_iprintf(buffer, " GPIO state : 0x%x\n", ice->eeprom.gpiostate);
1577 snd_iprintf(buffer, " GPIO direction : 0x%x\n", ice->eeprom.gpiodir);
1578 snd_iprintf(buffer, " AC'97 main : 0x%x\n", eeprom_double(ice, ICE_EEP1_AC97_MAIN_LO));
1579 snd_iprintf(buffer, " AC'97 pcm : 0x%x\n", eeprom_double(ice, ICE_EEP1_AC97_PCM_LO));
1580 snd_iprintf(buffer, " AC'97 record : 0x%x\n", eeprom_double(ice, ICE_EEP1_AC97_REC_LO));
1581 snd_iprintf(buffer, " AC'97 record src : 0x%x\n", ice->eeprom.data[ICE_EEP1_AC97_RECSRC]);
1583 snd_iprintf(buffer, " DAC ID #%i : 0x%x\n", idx, ice->eeprom.data[ICE_EEP1_DAC_ID + idx]);
1585 snd_iprintf(buffer, " ADC ID #%i : 0x%x\n", idx, ice->eeprom.data[ICE_EEP1_ADC_ID + idx]);
1586 for (idx = 0x1c; idx < ice->eeprom.size; idx++)
1587 snd_iprintf(buffer, " Extra #%02i : 0x%x\n", idx, ice->eeprom.data[idx]);
1590 snd_iprintf(buffer, " PSDOUT03 : 0x%04x\n", (unsigned)inw(ICEMT(ice, ROUTE_PSDOUT03)));
1591 snd_iprintf(buffer, " CAPTURE : 0x%08x\n", inl(ICEMT(ice, ROUTE_CAPTURE)));
1592 snd_iprintf(buffer, " SPDOUT : 0x%04x\n", (unsigned)inw(ICEMT(ice, ROUTE_SPDOUT)));
1593 snd_iprintf(buffer, " RATE : 0x%02x\n", (unsigned)inb(ICEMT(ice, RATE)));
1594 snd_iprintf(buffer, " GPIO_DATA : 0x%02x\n", (unsigned)snd_ice1712_get_gpio_data(ice));
1595 snd_iprintf(buffer, " GPIO_WRITE_MASK : 0x%02x\n", (unsigned)snd_ice1712_read(ice, ICE1712_IREG_GPIO_WRITE_MASK));
1596 snd_iprintf(buffer, " GPIO_DIRECTION : 0x%02x\n", (unsigned)snd_ice1712_read(ice, ICE1712_IREG_GPIO_DIRECTION));
1599 static void __devinit snd_ice1712_proc_init(struct snd_ice1712 * ice)
1603 if (! snd_card_proc_new(ice->card, "ice1712", &entry))
1604 snd_info_set_text_ops(entry, ice, snd_ice1712_proc_read);
1622 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1624 memcpy(ucontrol->value.bytes.data, &ice->eeprom, sizeof(ice->eeprom));
1649 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1650 if (ice->spdif.ops.default_get)
1651 ice->spdif.ops.default_get(ice, ucontrol);
1658 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1659 if (ice->spdif.ops.default_put)
1660 return ice->spdif.ops.default_put(ice, ucontrol);
1676 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1677 if (ice->spdif.ops.default_get) {
1698 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1699 if (ice->spdif.ops.default_get) {
1736 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1737 if (ice->spdif.ops.stream_get)
1738 ice->spdif.ops.stream_get(ice, ucontrol);
1745 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1746 if (ice->spdif.ops.stream_put)
1747 return ice->spdif.ops.stream_put(ice, ucontrol);
1775 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1779 snd_ice1712_save_gpio_status(ice);
1781 (snd_ice1712_gpio_read(ice) & mask ? 1 : 0) ^ invert;
1782 snd_ice1712_restore_gpio_status(ice);
1789 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1797 snd_ice1712_save_gpio_status(ice);
1798 val = snd_ice1712_gpio_read(ice);
1801 snd_ice1712_gpio_write(ice, nval);
1802 snd_ice1712_restore_gpio_status(ice);
1840 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1846 spin_lock_irq(&ice->reg_lock);
1847 if (is_spdif_master(ice)) {
1850 val = xlate[inb(ICEMT(ice, RATE)) & 15];
1857 spin_unlock_irq(&ice->reg_lock);
1864 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1872 spin_lock_irq(&ice->reg_lock);
1873 oval = inb(ICEMT(ice, RATE));
1875 outb(oval | ICE1712_SPDIF_MASTER, ICEMT(ice, RATE));
1878 spin_unlock_irq(&ice->reg_lock);
1879 snd_ice1712_set_pro_rate(ice, PRO_RATE_DEFAULT, 1);
1880 spin_lock_irq(&ice->reg_lock);
1882 change = inb(ICEMT(ice, RATE)) != oval;
1883 spin_unlock_irq(&ice->reg_lock);
1886 (inb(ICEMT(ice, RATE)) & ICE1712_SPDIF_MASTER))
1887 snd_ice1712_set_input_clock_source(ice, is_spdif_master(ice));
1991 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1995 spin_lock_irq(&ice->reg_lock);
1998 spin_unlock_irq(&ice->reg_lock);
2030 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
2034 spin_lock_irq(&ice->reg_lock);
2037 spin_unlock_irq(&ice->reg_lock);
2076 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
2080 spin_lock_irq(&ice->reg_lock);
2081 val = inw(ICEMT(ice, ROUTE_PSDOUT03));
2082 cval = inl(ICEMT(ice, ROUTE_CAPTURE));
2083 spin_unlock_irq(&ice->reg_lock);
2102 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
2117 spin_lock_irq(&ice->reg_lock);
2118 val = old_val = inw(ICEMT(ice, ROUTE_PSDOUT03));
2123 outw(val, ICEMT(ice, ROUTE_PSDOUT03));
2124 spin_unlock_irq(&ice->reg_lock);
2129 spin_lock_irq(&ice->reg_lock);
2130 val = old_val = inl(ICEMT(ice, ROUTE_CAPTURE));
2143 outl(val, ICEMT(ice, ROUTE_CAPTURE));
2145 spin_unlock_irq(&ice->reg_lock);
2152 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
2155 val = inw(ICEMT(ice, ROUTE_SPDOUT));
2172 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
2178 spin_lock_irq(&ice->reg_lock);
2179 val = old_val = inw(ICEMT(ice, ROUTE_SPDOUT));
2203 outw(val, ICEMT(ice, ROUTE_SPDOUT));
2204 spin_unlock_irq(&ice->reg_lock);
2239 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
2241 ucontrol->value.integer.value[0] = inb(ICEMT(ice, MONITOR_RATE));
2248 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
2251 spin_lock_irq(&ice->reg_lock);
2252 change = inb(ICEMT(ice, MONITOR_RATE)) != ucontrol->value.integer.value[0];
2253 outb(ucontrol->value.integer.value[0], ICEMT(ice, MONITOR_RATE));
2254 spin_unlock_irq(&ice->reg_lock);
2279 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
2282 spin_lock_irq(&ice->reg_lock);
2284 outb(idx, ICEMT(ice, MONITOR_PEAKINDEX));
2285 ucontrol->value.integer.value[idx] = inb(ICEMT(ice, MONITOR_PEAKDATA));
2287 spin_unlock_irq(&ice->reg_lock);
2313 static unsigned char __devinit snd_ice1712_read_i2c(struct snd_ice1712 *ice,
2319 outb(addr, ICEREG(ice, I2C_BYTE_ADDR));
2320 outb(dev & ~ICE1712_I2C_WRITE, ICEREG(ice, I2C_DEV_ADDR));
2321 while (t-- > 0 && (inb(ICEREG(ice, I2C_CTRL)) & ICE1712_I2C_BUSY)) ;
2322 return inb(ICEREG(ice, I2C_DATA));
2325 static int __devinit snd_ice1712_read_eeprom(struct snd_ice1712 *ice,
2333 ice->eeprom.subvendor = 0;
2334 if ((inb(ICEREG(ice, I2C_CTRL)) & ICE1712_I2C_EEPROM) != 0)
2335 ice->eeprom.subvendor = (snd_ice1712_read_i2c(ice, dev, 0x00) << 0) |
2336 (snd_ice1712_read_i2c(ice, dev, 0x01) << 8) |
2337 (snd_ice1712_read_i2c(ice, dev, 0x02) << 16) |
2338 (snd_ice1712_read_i2c(ice, dev, 0x03) << 24);
2339 if (ice->eeprom.subvendor == 0 ||
2340 ice->eeprom.subvendor == (unsigned int)-1) {
2343 pci_read_config_word(ice->pci, PCI_SUBSYSTEM_VENDOR_ID, &vendor);
2344 pci_read_config_word(ice->pci, PCI_SUBSYSTEM_ID, &device);
2345 ice->eeprom.subvendor = ((unsigned int)swab16(vendor) << 16) | swab16(device);
2346 if (ice->eeprom.subvendor == 0 || ice->eeprom.subvendor == (unsigned int)-1) {
2356 ice->eeprom.subvendor = c->subvendor;
2357 } else if (c->subvendor != ice->eeprom.subvendor)
2363 ice->eeprom.version = 1;
2364 ice->eeprom.size = c->eeprom_size + 6;
2365 memcpy(ice->eeprom.data, c->eeprom_data, c->eeprom_size);
2370 ice->eeprom.subvendor);
2373 ice->eeprom.size = snd_ice1712_read_i2c(ice, dev, 0x04);
2374 if (ice->eeprom.size < 6)
2375 ice->eeprom.size = 32;
2376 else if (ice->eeprom.size > 32) {
2377 snd_printk(KERN_ERR "invalid EEPROM (size = %i)\n", ice->eeprom.size);
2380 ice->eeprom.version = snd_ice1712_read_i2c(ice, dev, 0x05);
2381 if (ice->eeprom.version != 1) {
2383 ice->eeprom.version);
2386 size = ice->eeprom.size - 6;
2388 ice->eeprom.data[i] = snd_ice1712_read_i2c(ice, dev, i + 6);
2391 ice->eeprom.gpiomask = ice->eeprom.data[ICE_EEP1_GPIO_MASK];
2392 ice->eeprom.gpiostate = ice->eeprom.data[ICE_EEP1_GPIO_STATE];
2393 ice->eeprom.gpiodir = ice->eeprom.data[ICE_EEP1_GPIO_DIR];
2400 static int __devinit snd_ice1712_chip_init(struct snd_ice1712 *ice)
2402 outb(ICE1712_RESET | ICE1712_NATIVE, ICEREG(ice, CONTROL));
2404 outb(ICE1712_NATIVE, ICEREG(ice, CONTROL));
2406 if (ice->eeprom.subvendor == ICE1712_SUBDEVICE_DMX6FIRE &&
2407 !ice->dxr_enable)
2412 ice->eeprom.data[ICE_EEP1_CODEC] = 0x3a;
2413 pci_write_config_byte(ice->pci, 0x60, ice->eeprom.data[ICE_EEP1_CODEC]);
2414 pci_write_config_byte(ice->pci, 0x61, ice->eeprom.data[ICE_EEP1_ACLINK]);
2415 pci_write_config_byte(ice->pci, 0x62, ice->eeprom.data[ICE_EEP1_I2SID]);
2416 pci_write_config_byte(ice->pci, 0x63, ice->eeprom.data[ICE_EEP1_SPDIF]);
2417 if (ice->eeprom.subvendor != ICE1712_SUBDEVICE_STDSP24) {
2418 ice->gpio.write_mask = ice->eeprom.gpiomask;
2419 ice->gpio.direction = ice->eeprom.gpiodir;
2420 snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK,
2421 ice->eeprom.gpiomask);
2422 snd_ice1712_write(ice, ICE1712_IREG_GPIO_DIRECTION,
2423 ice->eeprom.gpiodir);
2424 snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA,
2425 ice->eeprom.gpiostate);
2427 ice->gpio.write_mask = 0xc0;
2428 ice->gpio.direction = 0xff;
2429 snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, 0xc0);
2430 snd_ice1712_write(ice, ICE1712_IREG_GPIO_DIRECTION, 0xff);
2431 snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA,
2434 snd_ice1712_write(ice, ICE1712_IREG_PRO_POWERDOWN, 0);
2435 if (!(ice->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_NO_CON_AC97)) {
2436 outb(ICE1712_AC97_WARM, ICEREG(ice, AC97_CMD));
2438 outb(0, ICEREG(ice, AC97_CMD));
2440 snd_ice1712_write(ice, ICE1712_IREG_CONSUMER_POWERDOWN, 0);
2442 snd_ice1712_set_pro_rate(ice, 48000, 1);
2447 int __devinit snd_ice1712_spdif_build_controls(struct snd_ice1712 *ice)
2452 snd_assert(ice->pcm_pro != NULL, return -EIO);
2453 err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_ice1712_spdif_default, ice));
2456 kctl->id.device = ice->pcm_pro->device;
2457 err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_ice1712_spdif_maskc, ice));
2460 kctl->id.device = ice->pcm_pro->device;
2461 err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_ice1712_spdif_maskp, ice));
2464 kctl->id.device = ice->pcm_pro->device;
2465 err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_ice1712_spdif_stream, ice));
2468 kctl->id.device = ice->pcm_pro->device;
2469 ice->spdif.stream_ctl = kctl;
2474 static int __devinit snd_ice1712_build_controls(struct snd_ice1712 *ice)
2478 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_eeprom, ice));
2481 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_pro_internal_clock, ice));
2484 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_pro_internal_clock_default, ice));
2488 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_pro_rate_locking, ice));
2491 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_pro_rate_reset, ice));
2495 if (ice->num_total_dacs > 0) {
2497 tmp.count = ice->num_total_dacs;
2498 err = snd_ctl_add(ice->card, snd_ctl_new1(&tmp, ice));
2503 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_mixer_pro_spdif_route, ice));
2507 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_mixer_pro_volume_rate, ice));
2510 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_mixer_pro_peak, ice));
2517 static int snd_ice1712_free(struct snd_ice1712 *ice)
2519 if (! ice->port)
2522 outb(0xc0, ICEMT(ice, IRQ));
2523 outb(0xff, ICEREG(ice, IRQMASK));
2526 if (ice->irq >= 0) {
2527 synchronize_irq(ice->irq);
2528 free_irq(ice->irq, ice);
2530 if (ice->port)
2531 pci_release_regions(ice->pci);
2532 snd_ice1712_akm4xxx_free(ice);
2533 pci_disable_device(ice->pci);
2534 kfree(ice);
2540 struct snd_ice1712 *ice = device->device_data;
2541 return snd_ice1712_free(ice);
2552 struct snd_ice1712 *ice;
2571 ice = kzalloc(sizeof(*ice), GFP_KERNEL);
2572 if (ice == NULL) {
2576 ice->omni = omni ? 1 : 0;
2581 ice->cs8427_timeout = cs8427_timeout;
2582 ice->dxr_enable = dxr_enable;
2583 spin_lock_init(&ice->reg_lock);
2584 mutex_init(&ice->gpio_mutex);
2585 mutex_init(&ice->i2c_mutex);
2586 mutex_init(&ice->open_mutex);
2587 ice->gpio.set_mask = snd_ice1712_set_gpio_mask;
2588 ice->gpio.set_dir = snd_ice1712_set_gpio_dir;
2589 ice->gpio.set_data = snd_ice1712_set_gpio_data;
2590 ice->gpio.get_data = snd_ice1712_get_gpio_data;
2592 ice->spdif.cs8403_bits =
2593 ice->spdif.cs8403_stream_bits = (0x01 | /* consumer format */
2596 ice->card = card;
2597 ice->pci = pci;
2598 ice->irq = -1;
2600 pci_write_config_word(ice->pci, 0x40, 0x807f);
2601 pci_write_config_word(ice->pci, 0x42, 0x0006);
2602 snd_ice1712_proc_init(ice);
2606 kfree(ice);
2610 ice->port = pci_resource_start(pci, 0);
2611 ice->ddma_port = pci_resource_start(pci, 1);
2612 ice->dmapath_port = pci_resource_start(pci, 2);
2613 ice->profi_port = pci_resource_start(pci, 3);
2616 "ICE1712", ice)) {
2618 snd_ice1712_free(ice);
2622 ice->irq = pci->irq;
2624 if (snd_ice1712_read_eeprom(ice, modelname) < 0) {
2625 snd_ice1712_free(ice);
2628 if (snd_ice1712_chip_init(ice) < 0) {
2629 snd_ice1712_free(ice);
2634 outb(((ice->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_2xMPU401) == 0 ?
2636 ((ice->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_NO_CON_AC97) ?
2638 ICEREG(ice, IRQMASK));
2639 outb(0x00, ICEMT(ice, IRQ));
2641 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, ice, &ops)) < 0) {
2642 snd_ice1712_free(ice);
2648 *r_ice1712 = ice;
2666 struct snd_ice1712 *ice;
2686 &ice)) < 0) {
2693 if (c->subvendor == ice->eeprom.subvendor) {
2698 if ((err = c->chip_init(ice)) < 0) {
2710 if ((err = snd_ice1712_pcm_profi(ice, pcm_dev++, NULL)) < 0) {
2715 if (ice_has_con_ac97(ice))
2716 if ((err = snd_ice1712_pcm(ice, pcm_dev++, NULL)) < 0) {
2721 if ((err = snd_ice1712_ac97_mixer(ice)) < 0) {
2726 if ((err = snd_ice1712_build_controls(ice)) < 0) {
2732 if ((err = c->build_controls(ice)) < 0) {
2738 if (ice_has_con_ac97(ice))
2739 if ((err = snd_ice1712_pcm_ds(ice, pcm_dev++, NULL)) < 0) {
2746 ICEREG(ice, MPU1_CTRL),
2749 ice->irq, 0,
2750 &ice->rmidi[0])) < 0) {
2756 snprintf(ice->rmidi[0]->name,
2757 sizeof(ice->rmidi[0]->name),
2760 if (ice->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_2xMPU401) {
2763 ICEREG(ice, MPU2_CTRL),
2766 ice->irq, 0,
2767 &ice->rmidi[1])) < 0) {
2773 snprintf(ice->rmidi[1]->name,
2774 sizeof(ice->rmidi[1]->name),
2780 snd_ice1712_set_input_clock_source(ice, 0);
2783 card->shortname, ice->port, ice->irq);