Lines Matching +full:mic +full:- +full:pos
1 // SPDX-License-Identifier: GPL-2.0-or-later
31 static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
36 static int buggy_irq = -1; /* auto-check */
38 static int spdif_aclink = -1;
39 static int inside_vm = -1;
46 MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (0 = allowlist + auto-detect, 1 = force autodetect)…
56 MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link.");
75 ICH_REG_##name##_BDBAR = base + 0x0, /* dword - buffer descriptor list base address */ \
76 ICH_REG_##name##_CIV = base + 0x04, /* byte - current index value */ \
77 ICH_REG_##name##_LVI = base + 0x05, /* byte - last valid index */ \
78 ICH_REG_##name##_SR = base + 0x06, /* byte - status register */ \
79 ICH_REG_##name##_PICB = base + 0x08, /* word - position in current buffer */ \
80 ICH_REG_##name##_PIV = base + 0x0a, /* byte - prefetched index value */ \
81 ICH_REG_##name##_CR = base + 0x0b, /* byte - control register */ \
88 DEFINE_REGSET(MC, 0x20); /* Mic in */
91 DEFINE_REGSET(MC2, 0x40); /* Mic in 2 */
119 #define ICH_REG_GLOB_CNT 0x2c /* dword - global control */
121 #define ICH_PCM_SPDIF_NONE 0x00000000 /* reserved - undefined */
125 #define ICH_PCM_20BIT 0x00400000 /* 20-bit samples (ICH4) */
142 #define ICH_REG_GLOB_STA 0x30 /* dword - global status */
147 #define ICH_P2INT 0x02000000 /* ICH4: PCM2-In interrupt */
148 #define ICH_M2INT 0x01000000 /* ICH4: Mic2-In interrupt */
150 #define ICH_SAMPLE_16_20 0x00400000 /* ICH4: 16- and 20-bit samples */
151 #define ICH_MULTICHAN_CAP 0x00300000 /* ICH4: multi-channel capability bits (RO) */
164 #define ICH_MCINT 0x00000080 /* MIC capture interrupt */
171 #define ICH_REG_ACC_SEMA 0x34 /* byte - codec write semaphore */
174 #define ICH_DI2L_MASK 0x000000c0 /* PCM In 2, Mic In 2 data in line */
176 #define ICH_DI1L_MASK 0x00000030 /* PCM In 1, Mic In 1 data in line */
191 DEFINE_REGSET(AL_MC, 0x60); /* Ali Mic in */
271 #define ICH_ALI_IF_SPDF_SRC (3<<12) /* 00 = PCM, 01 = AC97-in, 10 = spdif-in, 11 = i2s */
272 #define ICH_ALI_IF_AC97_OUT (3<<8) /* 00 = PCM, 10 = spdif-in, 11 = i2s */
306 #define get_ichdev(substream) (substream->runtime->private_data)
367 int spdif_idx; /* SPDIF BAR index; *_SPBAR or -1 if use PCMOUT */
416 * Lowlevel I/O - busmaster
421 return ioread8(chip->bmaddr + offset); in igetbyte()
426 return ioread16(chip->bmaddr + offset); in igetword()
431 return ioread32(chip->bmaddr + offset); in igetdword()
436 iowrite8(val, chip->bmaddr + offset); in iputbyte()
441 iowrite16(val, chip->bmaddr + offset); in iputword()
446 iowrite32(val, chip->bmaddr + offset); in iputdword()
450 * Lowlevel I/O - AC'97 registers
455 return ioread16(chip->addr + offset); in iagetword()
460 iowrite16(val, chip->addr + offset); in iaputword()
476 return -EIO; in snd_intel8x0_codec_semaphore()
477 if (chip->in_sdin_init) { in snd_intel8x0_codec_semaphore()
480 codec = chip->codec_isr_bits; in snd_intel8x0_codec_semaphore()
482 codec = chip->codec_bit[chip->ac97_sdin[codec]]; in snd_intel8x0_codec_semaphore()
487 return -EIO; in snd_intel8x0_codec_semaphore()
489 if (chip->buggy_semaphore) in snd_intel8x0_codec_semaphore()
498 } while (time--); in snd_intel8x0_codec_semaphore()
503 dev_err(chip->card->dev, in snd_intel8x0_codec_semaphore()
508 return -EBUSY; in snd_intel8x0_codec_semaphore()
515 struct intel8x0 *chip = ac97->private_data; in snd_intel8x0_codec_write()
517 if (snd_intel8x0_codec_semaphore(chip, ac97->num) < 0) { in snd_intel8x0_codec_write()
518 if (! chip->in_ac97_init) in snd_intel8x0_codec_write()
519 dev_err(chip->card->dev, in snd_intel8x0_codec_write()
521 ac97->num, reg); in snd_intel8x0_codec_write()
523 iaputword(chip, reg + ac97->num * 0x80, val); in snd_intel8x0_codec_write()
529 struct intel8x0 *chip = ac97->private_data; in snd_intel8x0_codec_read()
533 if (snd_intel8x0_codec_semaphore(chip, ac97->num) < 0) { in snd_intel8x0_codec_read()
534 if (! chip->in_ac97_init) in snd_intel8x0_codec_read()
535 dev_err(chip->card->dev, in snd_intel8x0_codec_read()
537 ac97->num, reg); in snd_intel8x0_codec_read()
540 res = iagetword(chip, reg + ac97->num * 0x80); in snd_intel8x0_codec_read()
545 ~(chip->codec_ready_bits | ICH_GSCI)); in snd_intel8x0_codec_read()
546 if (! chip->in_ac97_init) in snd_intel8x0_codec_read()
547 dev_err(chip->card->dev, in snd_intel8x0_codec_read()
549 ac97->num, reg); in snd_intel8x0_codec_read()
567 ~(chip->codec_ready_bits | ICH_GSCI)); in snd_intel8x0_codec_read_test()
583 if (! chip->in_ac97_init) in snd_intel8x0_ali_codec_ready()
584 dev_warn(chip->card->dev, "AC97 codec ready timeout.\n"); in snd_intel8x0_ali_codec_ready()
585 return -EBUSY; in snd_intel8x0_ali_codec_ready()
591 if (chip->buggy_semaphore) in snd_intel8x0_ali_codec_semaphore()
593 while (--time && (igetdword(chip, ICHREG(ALI_CAS)) & ALI_CAS_SEM_BUSY)) in snd_intel8x0_ali_codec_semaphore()
595 if (! time && ! chip->in_ac97_init) in snd_intel8x0_ali_codec_semaphore()
596 dev_warn(chip->card->dev, "ali_codec_semaphore timeout\n"); in snd_intel8x0_ali_codec_semaphore()
602 struct intel8x0 *chip = ac97->private_data; in snd_intel8x0_ali_codec_read()
608 if (ac97->num) in snd_intel8x0_ali_codec_read()
621 struct intel8x0 *chip = ac97->private_data; in snd_intel8x0_ali_codec_write()
626 if (ac97->num) in snd_intel8x0_ali_codec_write()
639 __le32 *bdbar = ichdev->bdbar; in snd_intel8x0_setup_periods()
640 unsigned long port = ichdev->reg_offset; in snd_intel8x0_setup_periods()
642 iputdword(chip, port + ICH_REG_OFF_BDBAR, ichdev->bdbar_addr); in snd_intel8x0_setup_periods()
643 if (ichdev->size == ichdev->fragsize) { in snd_intel8x0_setup_periods()
644 ichdev->ack_reload = ichdev->ack = 2; in snd_intel8x0_setup_periods()
645 ichdev->fragsize1 = ichdev->fragsize >> 1; in snd_intel8x0_setup_periods()
647 bdbar[idx + 0] = cpu_to_le32(ichdev->physbuf); in snd_intel8x0_setup_periods()
649 ichdev->fragsize1 >> ichdev->pos_shift); in snd_intel8x0_setup_periods()
650 bdbar[idx + 2] = cpu_to_le32(ichdev->physbuf + (ichdev->size >> 1)); in snd_intel8x0_setup_periods()
652 ichdev->fragsize1 >> ichdev->pos_shift); in snd_intel8x0_setup_periods()
654 ichdev->frags = 2; in snd_intel8x0_setup_periods()
656 ichdev->ack_reload = ichdev->ack = 1; in snd_intel8x0_setup_periods()
657 ichdev->fragsize1 = ichdev->fragsize; in snd_intel8x0_setup_periods()
659 bdbar[idx + 0] = cpu_to_le32(ichdev->physbuf + in snd_intel8x0_setup_periods()
660 (((idx >> 1) * ichdev->fragsize) % in snd_intel8x0_setup_periods()
661 ichdev->size)); in snd_intel8x0_setup_periods()
663 ichdev->fragsize >> ichdev->pos_shift); in snd_intel8x0_setup_periods()
665 dev_dbg(chip->card->dev, "bdbar[%i] = 0x%x [0x%x]\n", in snd_intel8x0_setup_periods()
669 ichdev->frags = ichdev->size / ichdev->fragsize; in snd_intel8x0_setup_periods()
671 iputbyte(chip, port + ICH_REG_OFF_LVI, ichdev->lvi = ICH_REG_LVI_MASK); in snd_intel8x0_setup_periods()
672 ichdev->civ = 0; in snd_intel8x0_setup_periods()
674 ichdev->lvi_frag = ICH_REG_LVI_MASK % ichdev->frags; in snd_intel8x0_setup_periods()
675 ichdev->position = 0; in snd_intel8x0_setup_periods()
677 dev_dbg(chip->card->dev, in snd_intel8x0_setup_periods()
679 ichdev->lvi_frag, ichdev->frags, ichdev->fragsize, in snd_intel8x0_setup_periods()
680 ichdev->fragsize1); in snd_intel8x0_setup_periods()
683 iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI); in snd_intel8x0_setup_periods()
692 unsigned long port = ichdev->reg_offset; in snd_intel8x0_update()
697 if (!(ichdev->prepared || chip->in_measurement) || ichdev->suspended) in snd_intel8x0_update()
700 spin_lock_irqsave(&chip->reg_lock, flags); in snd_intel8x0_update()
701 status = igetbyte(chip, port + ichdev->roff_sr); in snd_intel8x0_update()
705 } else if (civ == ichdev->civ) { in snd_intel8x0_update()
708 ichdev->civ++; in snd_intel8x0_update()
709 ichdev->civ &= ICH_REG_LVI_MASK; in snd_intel8x0_update()
711 step = civ - ichdev->civ; in snd_intel8x0_update()
715 // snd_printd("step = %d, %d -> %d\n", step, ichdev->civ, civ); in snd_intel8x0_update()
716 ichdev->civ = civ; in snd_intel8x0_update()
719 ichdev->position += step * ichdev->fragsize1; in snd_intel8x0_update()
720 if (! chip->in_measurement) in snd_intel8x0_update()
721 ichdev->position %= ichdev->size; in snd_intel8x0_update()
722 ichdev->lvi += step; in snd_intel8x0_update()
723 ichdev->lvi &= ICH_REG_LVI_MASK; in snd_intel8x0_update()
724 iputbyte(chip, port + ICH_REG_OFF_LVI, ichdev->lvi); in snd_intel8x0_update()
726 ichdev->lvi_frag++; in snd_intel8x0_update()
727 ichdev->lvi_frag %= ichdev->frags; in snd_intel8x0_update()
728 …ichdev->bdbar[ichdev->lvi * 2] = cpu_to_le32(ichdev->physbuf + ichdev->lvi_frag * ichdev->fragsize… in snd_intel8x0_update()
730 dev_dbg(chip->card->dev, in snd_intel8x0_update()
732 ichdev->lvi * 2, ichdev->bdbar[ichdev->lvi * 2], in snd_intel8x0_update()
733 ichdev->bdbar[ichdev->lvi * 2 + 1], inb(ICH_REG_OFF_PIV + port), in snd_intel8x0_update()
736 if (--ichdev->ack == 0) { in snd_intel8x0_update()
737 ichdev->ack = ichdev->ack_reload; in snd_intel8x0_update()
741 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_intel8x0_update()
742 if (ack && ichdev->substream) { in snd_intel8x0_update()
743 snd_pcm_period_elapsed(ichdev->substream); in snd_intel8x0_update()
745 iputbyte(chip, port + ichdev->roff_sr, in snd_intel8x0_update()
756 status = igetdword(chip, chip->int_sta_reg); in snd_intel8x0_interrupt()
760 if ((status & chip->int_sta_mask) == 0) { in snd_intel8x0_interrupt()
763 iputdword(chip, chip->int_sta_reg, status); in snd_intel8x0_interrupt()
764 if (! chip->buggy_irq) in snd_intel8x0_interrupt()
770 for (i = 0; i < chip->bdbars_count; i++) { in snd_intel8x0_interrupt()
771 ichdev = &chip->ichd[i]; in snd_intel8x0_interrupt()
772 if (status & ichdev->int_sta_mask) in snd_intel8x0_interrupt()
777 iputdword(chip, chip->int_sta_reg, status & chip->int_sta_mask); in snd_intel8x0_interrupt()
791 unsigned long port = ichdev->reg_offset; in snd_intel8x0_pcm_trigger()
795 ichdev->suspended = 0; in snd_intel8x0_pcm_trigger()
800 ichdev->last_pos = ichdev->position; in snd_intel8x0_pcm_trigger()
803 ichdev->suspended = 1; in snd_intel8x0_pcm_trigger()
812 return -EINVAL; in snd_intel8x0_pcm_trigger()
817 while (!(igetbyte(chip, port + ichdev->roff_sr) & ICH_DCH)) ; in snd_intel8x0_pcm_trigger()
828 unsigned long port = ichdev->reg_offset; in snd_intel8x0_ali_trigger()
837 ichdev->suspended = 0; in snd_intel8x0_ali_trigger()
841 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_intel8x0_ali_trigger()
843 fifo = igetdword(chip, fiforeg[ichdev->ali_slot / 4]); in snd_intel8x0_ali_trigger()
844 fifo &= ~(0xff << (ichdev->ali_slot % 4)); in snd_intel8x0_ali_trigger()
845 fifo |= 0x83 << (ichdev->ali_slot % 4); in snd_intel8x0_ali_trigger()
846 iputdword(chip, fiforeg[ichdev->ali_slot / 4], fifo); in snd_intel8x0_ali_trigger()
849 val &= ~(1 << (ichdev->ali_slot + 16)); /* clear PAUSE flag */ in snd_intel8x0_ali_trigger()
851 iputdword(chip, ICHREG(ALI_DMACR), val | (1 << ichdev->ali_slot)); in snd_intel8x0_ali_trigger()
854 ichdev->suspended = 1; in snd_intel8x0_ali_trigger()
859 iputdword(chip, ICHREG(ALI_DMACR), val | (1 << (ichdev->ali_slot + 16))); in snd_intel8x0_ali_trigger()
871 igetdword(chip, ICHREG(ALI_INTERRUPTSR)) & ichdev->int_sta_mask); in snd_intel8x0_ali_trigger()
874 return -EINVAL; in snd_intel8x0_ali_trigger()
887 if (ichdev->pcm_open_flag) { in snd_intel8x0_hw_params()
888 snd_ac97_pcm_close(ichdev->pcm); in snd_intel8x0_hw_params()
889 ichdev->pcm_open_flag = 0; in snd_intel8x0_hw_params()
890 ichdev->prepared = 0; in snd_intel8x0_hw_params()
892 err = snd_ac97_pcm_open(ichdev->pcm, params_rate(hw_params), in snd_intel8x0_hw_params()
894 ichdev->pcm->r[dbl].slots); in snd_intel8x0_hw_params()
896 ichdev->pcm_open_flag = 1; in snd_intel8x0_hw_params()
898 if (ichdev->ichd == ICHD_PCMOUT && chip->spdif_idx < 0) in snd_intel8x0_hw_params()
899 snd_ac97_set_rate(ichdev->pcm->r[0].codec[0], AC97_SPDIF, in snd_intel8x0_hw_params()
909 if (ichdev->pcm_open_flag) { in snd_intel8x0_hw_free()
910 snd_ac97_pcm_close(ichdev->pcm); in snd_intel8x0_hw_free()
911 ichdev->pcm_open_flag = 0; in snd_intel8x0_hw_free()
912 ichdev->prepared = 0; in snd_intel8x0_hw_free()
921 int dbl = runtime->rate > 48000; in snd_intel8x0_setup_pcm_out()
923 spin_lock_irq(&chip->reg_lock); in snd_intel8x0_setup_pcm_out()
924 switch (chip->device_type) { in snd_intel8x0_setup_pcm_out()
928 if (runtime->channels == 4 || dbl) in snd_intel8x0_setup_pcm_out()
930 else if (runtime->channels == 6) in snd_intel8x0_setup_pcm_out()
937 if (runtime->channels == 4 || dbl) in snd_intel8x0_setup_pcm_out()
939 else if (runtime->channels == 6) in snd_intel8x0_setup_pcm_out()
946 if (runtime->channels == 4 || dbl) in snd_intel8x0_setup_pcm_out()
948 else if (runtime->channels == 6) in snd_intel8x0_setup_pcm_out()
950 else if (runtime->channels == 8) in snd_intel8x0_setup_pcm_out()
952 if (chip->device_type == DEVICE_NFORCE) { in snd_intel8x0_setup_pcm_out()
958 spin_unlock_irq(&chip->reg_lock); in snd_intel8x0_setup_pcm_out()
960 spin_lock_irq(&chip->reg_lock); in snd_intel8x0_setup_pcm_out()
962 } else if (chip->device_type == DEVICE_INTEL_ICH4) { in snd_intel8x0_setup_pcm_out()
963 if (runtime->sample_bits > 16) in snd_intel8x0_setup_pcm_out()
969 spin_unlock_irq(&chip->reg_lock); in snd_intel8x0_setup_pcm_out()
975 struct snd_pcm_runtime *runtime = substream->runtime; in snd_intel8x0_pcm_prepare()
978 ichdev->physbuf = runtime->dma_addr; in snd_intel8x0_pcm_prepare()
979 ichdev->size = snd_pcm_lib_buffer_bytes(substream); in snd_intel8x0_pcm_prepare()
980 ichdev->fragsize = snd_pcm_lib_period_bytes(substream); in snd_intel8x0_pcm_prepare()
981 if (ichdev->ichd == ICHD_PCMOUT) { in snd_intel8x0_pcm_prepare()
983 if (chip->device_type == DEVICE_INTEL_ICH4) in snd_intel8x0_pcm_prepare()
984 ichdev->pos_shift = (runtime->sample_bits > 16) ? 2 : 1; in snd_intel8x0_pcm_prepare()
987 ichdev->prepared = 1; in snd_intel8x0_pcm_prepare()
999 spin_lock(&chip->reg_lock); in snd_intel8x0_pcm_pointer()
1001 civ = igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV); in snd_intel8x0_pcm_pointer()
1002 ptr1 = igetword(chip, ichdev->reg_offset + ichdev->roff_picb); in snd_intel8x0_pcm_pointer()
1003 position = ichdev->position; in snd_intel8x0_pcm_pointer()
1008 if (civ != igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV)) in snd_intel8x0_pcm_pointer()
1017 if (chip->inside_vm) in snd_intel8x0_pcm_pointer()
1019 if (ptr1 == igetword(chip, ichdev->reg_offset + ichdev->roff_picb)) in snd_intel8x0_pcm_pointer()
1021 } while (timeout--); in snd_intel8x0_pcm_pointer()
1022 ptr = ichdev->last_pos; in snd_intel8x0_pcm_pointer()
1024 ptr1 <<= ichdev->pos_shift; in snd_intel8x0_pcm_pointer()
1025 ptr = ichdev->fragsize1 - ptr1; in snd_intel8x0_pcm_pointer()
1027 if (ptr < ichdev->last_pos) { in snd_intel8x0_pcm_pointer()
1029 pos_base = position / ichdev->fragsize1; in snd_intel8x0_pcm_pointer()
1030 last_base = ichdev->last_pos / ichdev->fragsize1; in snd_intel8x0_pcm_pointer()
1035 ptr = ichdev->last_pos; in snd_intel8x0_pcm_pointer()
1038 ichdev->last_pos = ptr; in snd_intel8x0_pcm_pointer()
1039 spin_unlock(&chip->reg_lock); in snd_intel8x0_pcm_pointer()
1040 if (ptr >= ichdev->size) in snd_intel8x0_pcm_pointer()
1042 return bytes_to_frames(substream->runtime, ptr); in snd_intel8x0_pcm_pointer()
1099 struct snd_pcm_runtime *runtime = substream->runtime; in snd_intel8x0_pcm_open()
1102 ichdev->substream = substream; in snd_intel8x0_pcm_open()
1103 runtime->hw = snd_intel8x0_stream; in snd_intel8x0_pcm_open()
1104 runtime->hw.rates = ichdev->pcm->rates; in snd_intel8x0_pcm_open()
1106 if (chip->device_type == DEVICE_SIS) { in snd_intel8x0_pcm_open()
1107 runtime->hw.buffer_bytes_max = 64*1024; in snd_intel8x0_pcm_open()
1108 runtime->hw.period_bytes_max = 64*1024; in snd_intel8x0_pcm_open()
1113 runtime->private_data = ichdev; in snd_intel8x0_pcm_open()
1120 struct snd_pcm_runtime *runtime = substream->runtime; in snd_intel8x0_playback_open()
1123 err = snd_intel8x0_pcm_open(substream, &chip->ichd[ICHD_PCMOUT]); in snd_intel8x0_playback_open()
1127 if (chip->multi8) { in snd_intel8x0_playback_open()
1128 runtime->hw.channels_max = 8; in snd_intel8x0_playback_open()
1132 } else if (chip->multi6) { in snd_intel8x0_playback_open()
1133 runtime->hw.channels_max = 6; in snd_intel8x0_playback_open()
1136 } else if (chip->multi4) { in snd_intel8x0_playback_open()
1137 runtime->hw.channels_max = 4; in snd_intel8x0_playback_open()
1141 if (chip->dra) { in snd_intel8x0_playback_open()
1144 if (chip->smp20bit) { in snd_intel8x0_playback_open()
1145 runtime->hw.formats |= SNDRV_PCM_FMTBIT_S32_LE; in snd_intel8x0_playback_open()
1155 chip->ichd[ICHD_PCMOUT].substream = NULL; in snd_intel8x0_playback_close()
1163 return snd_intel8x0_pcm_open(substream, &chip->ichd[ICHD_PCMIN]); in snd_intel8x0_capture_open()
1170 chip->ichd[ICHD_PCMIN].substream = NULL; in snd_intel8x0_capture_close()
1178 return snd_intel8x0_pcm_open(substream, &chip->ichd[ICHD_MIC]); in snd_intel8x0_mic_open()
1185 chip->ichd[ICHD_MIC].substream = NULL; in snd_intel8x0_mic_close()
1193 return snd_intel8x0_pcm_open(substream, &chip->ichd[ICHD_MIC2]); in snd_intel8x0_mic2_open()
1200 chip->ichd[ICHD_MIC2].substream = NULL; in snd_intel8x0_mic2_close()
1208 return snd_intel8x0_pcm_open(substream, &chip->ichd[ICHD_PCM2IN]); in snd_intel8x0_capture2_open()
1215 chip->ichd[ICHD_PCM2IN].substream = NULL; in snd_intel8x0_capture2_close()
1222 int idx = chip->device_type == DEVICE_NFORCE ? NVD_SPBAR : ICHD_SPBAR; in snd_intel8x0_spdif_open()
1224 return snd_intel8x0_pcm_open(substream, &chip->ichd[idx]); in snd_intel8x0_spdif_open()
1230 int idx = chip->device_type == DEVICE_NFORCE ? NVD_SPBAR : ICHD_SPBAR; in snd_intel8x0_spdif_close()
1232 chip->ichd[idx].substream = NULL; in snd_intel8x0_spdif_close()
1241 spin_lock_irq(&chip->reg_lock); in snd_intel8x0_ali_ac97spdifout_open()
1246 spin_unlock_irq(&chip->reg_lock); in snd_intel8x0_ali_ac97spdifout_open()
1248 return snd_intel8x0_pcm_open(substream, &chip->ichd[ALID_AC97SPDIFOUT]); in snd_intel8x0_ali_ac97spdifout_open()
1256 chip->ichd[ALID_AC97SPDIFOUT].substream = NULL; in snd_intel8x0_ali_ac97spdifout_close()
1257 spin_lock_irq(&chip->reg_lock); in snd_intel8x0_ali_ac97spdifout_close()
1261 spin_unlock_irq(&chip->reg_lock); in snd_intel8x0_ali_ac97spdifout_close()
1271 return snd_intel8x0_pcm_open(substream, &chip->ichd[ALID_SPDIFIN]);
1278 chip->ichd[ALID_SPDIFIN].substream = NULL;
1286 return snd_intel8x0_pcm_open(substream, &chip->ichd[ALID_SPDIFOUT]);
1293 chip->ichd[ALID_SPDIFOUT].substream = NULL;
1430 ((chip)->fix_nocache ? SNDRV_DMA_TYPE_DEV_WC : SNDRV_DMA_TYPE_DEV)
1439 if (rec->suffix) in snd_intel8x0_pcm1()
1440 sprintf(name, "Intel ICH - %s", rec->suffix); in snd_intel8x0_pcm1()
1443 err = snd_pcm_new(chip->card, name, device, in snd_intel8x0_pcm1()
1444 rec->playback_ops ? 1 : 0, in snd_intel8x0_pcm1()
1445 rec->capture_ops ? 1 : 0, &pcm); in snd_intel8x0_pcm1()
1449 if (rec->playback_ops) in snd_intel8x0_pcm1()
1450 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, rec->playback_ops); in snd_intel8x0_pcm1()
1451 if (rec->capture_ops) in snd_intel8x0_pcm1()
1452 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, rec->capture_ops); in snd_intel8x0_pcm1()
1454 pcm->private_data = chip; in snd_intel8x0_pcm1()
1455 pcm->info_flags = 0; in snd_intel8x0_pcm1()
1456 if (rec->suffix) in snd_intel8x0_pcm1()
1457 sprintf(pcm->name, "%s - %s", chip->card->shortname, rec->suffix); in snd_intel8x0_pcm1()
1459 strcpy(pcm->name, chip->card->shortname); in snd_intel8x0_pcm1()
1460 chip->pcm[device] = pcm; in snd_intel8x0_pcm1()
1463 &chip->pci->dev, in snd_intel8x0_pcm1()
1464 rec->prealloc_size, rec->prealloc_max_size); in snd_intel8x0_pcm1()
1466 if (rec->playback_ops && in snd_intel8x0_pcm1()
1467 rec->playback_ops->open == snd_intel8x0_playback_open) { in snd_intel8x0_pcm1()
1470 if (chip->multi8) in snd_intel8x0_pcm1()
1472 else if (chip->multi6) in snd_intel8x0_pcm1()
1474 else if (chip->multi4) in snd_intel8x0_pcm1()
1481 chmap->channel_mask = SND_PCM_CHMAP_MASK_2468; in snd_intel8x0_pcm1()
1482 chip->ac97[0]->chmaps[SNDRV_PCM_STREAM_PLAYBACK] = chmap; in snd_intel8x0_pcm1()
1496 .suffix = "MIC ADC",
1533 .suffix = "MIC ADC",
1556 .suffix = "MIC ADC",
1585 switch (chip->device_type) { in snd_intel8x0_pcm()
1590 tblsize--; in snd_intel8x0_pcm()
1596 tblsize--; in snd_intel8x0_pcm()
1611 if (i > 0 && rec->ac97_idx) { in snd_intel8x0_pcm()
1613 if (! chip->ichd[rec->ac97_idx].pcm) in snd_intel8x0_pcm()
1622 chip->pcm_devs = device; in snd_intel8x0_pcm()
1633 struct intel8x0 *chip = bus->private_data; in snd_intel8x0_mixer_free_ac97_bus()
1634 chip->ac97_bus = NULL; in snd_intel8x0_mixer_free_ac97_bus()
1639 struct intel8x0 *chip = ac97->private_data; in snd_intel8x0_mixer_free_ac97()
1640 chip->ac97[ac97->num] = NULL; in snd_intel8x0_mixer_free_ac97()
1673 /* MIC IN #1 */
1702 /* MIC IN #2 */
1747 .name = "MS-9128",
1945 .name = "Sony VAIO VGN-T350P", /*AD1981B*/
1951 .name = "Sony VAIO VGN-B1VP", /*AD1981B*/
1963 .name = "Fujitsu-Siemens E4010",
1969 .name = "Fujitsu-Siemens T3010",
1993 .name = "Fujitsu-Siemens 4010",
1999 .name = "Fujitsu-Siemens Celsius H320",
2005 .name = "Fujitsu-Siemens Celsius", /* AD1981? */
2023 .name = "Panasonic CF-R4",
2029 .name = "Fujitsu-Siemens Scenic", /* AD1981? */
2059 .name = "Fujitsu-Siemens D1522", /* AD1981 */
2138 chip->spdif_idx = -1; /* use PCMOUT (or disabled) */ in snd_intel8x0_mixer()
2140 switch (chip->device_type) { in snd_intel8x0_mixer()
2142 chip->spdif_idx = NVD_SPBAR; in snd_intel8x0_mixer()
2145 chip->spdif_idx = ALID_AC97SPDIFOUT; in snd_intel8x0_mixer()
2148 chip->spdif_idx = ICHD_SPBAR; in snd_intel8x0_mixer()
2153 chip->in_ac97_init = 1; in snd_intel8x0_mixer()
2159 if (chip->xbox) in snd_intel8x0_mixer()
2161 if (chip->device_type != DEVICE_ALI) { in snd_intel8x0_mixer()
2164 chip->in_sdin_init = 1; in snd_intel8x0_mixer()
2166 for (i = 0; i < chip->max_codecs; i++) { in snd_intel8x0_mixer()
2167 if (! (glob_sta & chip->codec_bit[i])) in snd_intel8x0_mixer()
2169 if (chip->device_type == DEVICE_INTEL_ICH4) { in snd_intel8x0_mixer()
2171 chip->ac97_sdin[codecs] = in snd_intel8x0_mixer()
2173 if (snd_BUG_ON(chip->ac97_sdin[codecs] >= 3)) in snd_intel8x0_mixer()
2174 chip->ac97_sdin[codecs] = 0; in snd_intel8x0_mixer()
2176 chip->ac97_sdin[codecs] = i; in snd_intel8x0_mixer()
2179 chip->in_sdin_init = 0; in snd_intel8x0_mixer()
2196 err = snd_ac97_bus(chip->card, 0, ops, chip, &pbus); in snd_intel8x0_mixer()
2199 pbus->private_free = snd_intel8x0_mixer_free_ac97_bus; in snd_intel8x0_mixer()
2201 pbus->clock = ac97_clock; in snd_intel8x0_mixer()
2203 if (chip->device_type == DEVICE_ALI) in snd_intel8x0_mixer()
2204 pbus->no_vra = 1; in snd_intel8x0_mixer()
2206 pbus->dra = 1; in snd_intel8x0_mixer()
2207 chip->ac97_bus = pbus; in snd_intel8x0_mixer()
2208 chip->ncodecs = codecs; in snd_intel8x0_mixer()
2210 ac97.pci = chip->pci; in snd_intel8x0_mixer()
2213 err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i]); in snd_intel8x0_mixer()
2215 if (err != -EACCES) in snd_intel8x0_mixer()
2216 dev_err(chip->card->dev, in snd_intel8x0_mixer()
2223 snd_ac97_tune_hardware(chip->ac97[0], ac97_quirks, quirk_override); in snd_intel8x0_mixer()
2225 if (chip->device_type == DEVICE_INTEL_ICH4) in snd_intel8x0_mixer()
2226 pbus->isdin = 1; in snd_intel8x0_mixer()
2229 if (chip->device_type != DEVICE_INTEL_ICH4) in snd_intel8x0_mixer()
2230 i -= 2; /* do not allocate PCM2IN and MIC2 */ in snd_intel8x0_mixer()
2231 if (chip->spdif_idx < 0) in snd_intel8x0_mixer()
2232 i--; /* do not allocate S/PDIF */ in snd_intel8x0_mixer()
2236 chip->ichd[ICHD_PCMOUT].pcm = &pbus->pcms[0]; in snd_intel8x0_mixer()
2237 chip->ichd[ICHD_PCMIN].pcm = &pbus->pcms[1]; in snd_intel8x0_mixer()
2238 chip->ichd[ICHD_MIC].pcm = &pbus->pcms[2]; in snd_intel8x0_mixer()
2239 if (chip->spdif_idx >= 0) in snd_intel8x0_mixer()
2240 chip->ichd[chip->spdif_idx].pcm = &pbus->pcms[3]; in snd_intel8x0_mixer()
2241 if (chip->device_type == DEVICE_INTEL_ICH4) { in snd_intel8x0_mixer()
2242 chip->ichd[ICHD_PCM2IN].pcm = &pbus->pcms[4]; in snd_intel8x0_mixer()
2243 chip->ichd[ICHD_MIC2].pcm = &pbus->pcms[5]; in snd_intel8x0_mixer()
2246 if (chip->device_type == DEVICE_INTEL_ICH4) { in snd_intel8x0_mixer()
2247 struct ac97_pcm *pcm = chip->ichd[ICHD_PCM2IN].pcm; in snd_intel8x0_mixer()
2252 tmp |= chip->ac97_sdin[0] << ICH_DI1L_SHIFT; in snd_intel8x0_mixer()
2254 if (pcm->r[0].codec[i]) { in snd_intel8x0_mixer()
2255 tmp |= chip->ac97_sdin[pcm->r[0].codec[1]->num] << ICH_DI2L_SHIFT; in snd_intel8x0_mixer()
2264 if (pbus->pcms[0].r[0].slots & (1 << AC97_SLOT_PCM_SLEFT)) { in snd_intel8x0_mixer()
2265 chip->multi4 = 1; in snd_intel8x0_mixer()
2266 if (pbus->pcms[0].r[0].slots & (1 << AC97_SLOT_LFE)) { in snd_intel8x0_mixer()
2267 chip->multi6 = 1; in snd_intel8x0_mixer()
2268 if (chip->ac97[0]->flags & AC97_HAS_8CH) in snd_intel8x0_mixer()
2269 chip->multi8 = 1; in snd_intel8x0_mixer()
2272 if (pbus->pcms[0].r[1].rslots[0]) { in snd_intel8x0_mixer()
2273 chip->dra = 1; in snd_intel8x0_mixer()
2275 if (chip->device_type == DEVICE_INTEL_ICH4) { in snd_intel8x0_mixer()
2277 chip->smp20bit = 1; in snd_intel8x0_mixer()
2279 if (chip->device_type == DEVICE_NFORCE && !spdif_aclink) { in snd_intel8x0_mixer()
2281 chip->ichd[chip->spdif_idx].pcm->rates = SNDRV_PCM_RATE_48000; in snd_intel8x0_mixer()
2283 if (chip->device_type == DEVICE_INTEL_ICH4 && !spdif_aclink) { in snd_intel8x0_mixer()
2289 snd_ac97_update_bits(chip->ac97[0], AC97_EXTENDED_STATUS, 0x03 << 4, 0x03 << 4); in snd_intel8x0_mixer()
2291 chip->in_ac97_init = 0; in snd_intel8x0_mixer()
2295 /* clear the cold-reset bit for the next chance */ in snd_intel8x0_mixer()
2296 if (chip->device_type != DEVICE_ALI) in snd_intel8x0_mixer()
2330 if (snd_pci_quirk_lookup(chip->pci, ich_chip_reset_mode)) in snd_intel8x0_ich_chip_cold_reset()
2331 return -EIO; in snd_intel8x0_ich_chip_cold_reset()
2336 /* do cold reset - the full ac97 powerdown may leave the controller in snd_intel8x0_ich_chip_cold_reset()
2347 (!snd_pci_quirk_lookup(chip->pci, ich_chip_reset_mode))
2369 dev_err(chip->card->dev, "AC'97 warm reset still in progress? [0x%x]\n", in snd_intel8x0_ich_chip_reset()
2371 return -EIO; in snd_intel8x0_ich_chip_reset()
2384 if (chip->device_type == DEVICE_NFORCE) in snd_intel8x0_ich_chip_init()
2404 chip->codec_isr_bits; in snd_intel8x0_ich_chip_init()
2411 dev_err(chip->card->dev, in snd_intel8x0_ich_chip_init()
2414 return -EIO; in snd_intel8x0_ich_chip_init()
2419 while (status != chip->codec_isr_bits && in snd_intel8x0_ich_chip_init()
2423 chip->codec_isr_bits; in snd_intel8x0_ich_chip_init()
2430 for (i = 0; i < chip->ncodecs; i++) in snd_intel8x0_ich_chip_init()
2431 if (chip->ac97[i]) in snd_intel8x0_ich_chip_init()
2432 status |= chip->codec_bit[chip->ac97_sdin[i]]; in snd_intel8x0_ich_chip_init()
2437 chip->codec_isr_bits; in snd_intel8x0_ich_chip_init()
2444 if (chip->device_type == DEVICE_SIS) { in snd_intel8x0_ich_chip_init()
2448 if (chip->device_type == DEVICE_NFORCE && !spdif_aclink) { in snd_intel8x0_ich_chip_init()
2451 pci_read_config_dword(chip->pci, 0x4c, &val); in snd_intel8x0_ich_chip_init()
2453 pci_write_config_dword(chip->pci, 0x4c, val); in snd_intel8x0_ich_chip_init()
2476 dev_err(chip->card->dev, "AC'97 reset failed.\n"); in snd_intel8x0_ali_chip_init()
2478 return -EIO; in snd_intel8x0_ali_chip_init()
2498 if (chip->device_type != DEVICE_ALI) { in snd_intel8x0_chip_init()
2510 for (i = 0; i < chip->bdbars_count; i++) in snd_intel8x0_chip_init()
2511 iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, 0x00); in snd_intel8x0_chip_init()
2513 for (i = 0; i < chip->bdbars_count; i++) in snd_intel8x0_chip_init()
2514 iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, ICH_RESETREGS); in snd_intel8x0_chip_init()
2515 for (i = 0; i < chip->bdbars_count; i++) { in snd_intel8x0_chip_init()
2517 while (--timeout != 0) { in snd_intel8x0_chip_init()
2518 if ((igetbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset) & ICH_RESETREGS) == 0) in snd_intel8x0_chip_init()
2522 dev_err(chip->card->dev, "reset of registers failed?\n"); in snd_intel8x0_chip_init()
2525 for (i = 0; i < chip->bdbars_count; i++) in snd_intel8x0_chip_init()
2526 iputdword(chip, ICH_REG_OFF_BDBAR + chip->ichd[i].reg_offset, in snd_intel8x0_chip_init()
2527 chip->ichd[i].bdbar_addr); in snd_intel8x0_chip_init()
2533 struct intel8x0 *chip = card->private_data; in snd_intel8x0_free()
2536 if (chip->irq < 0) in snd_intel8x0_free()
2539 for (i = 0; i < chip->bdbars_count; i++) in snd_intel8x0_free()
2540 iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, 0x00); in snd_intel8x0_free()
2542 for (i = 0; i < chip->bdbars_count; i++) in snd_intel8x0_free()
2543 iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, ICH_RESETREGS); in snd_intel8x0_free()
2544 if (chip->device_type == DEVICE_NFORCE && !spdif_aclink) { in snd_intel8x0_free()
2547 pci_read_config_dword(chip->pci, 0x4c, &val); in snd_intel8x0_free()
2549 pci_write_config_dword(chip->pci, 0x4c, val); in snd_intel8x0_free()
2551 /* --- */ in snd_intel8x0_free()
2554 if (chip->irq >= 0) in snd_intel8x0_free()
2555 free_irq(chip->irq, chip); in snd_intel8x0_free()
2565 struct intel8x0 *chip = card->private_data; in intel8x0_suspend()
2569 for (i = 0; i < chip->ncodecs; i++) in intel8x0_suspend()
2570 snd_ac97_suspend(chip->ac97[i]); in intel8x0_suspend()
2571 if (chip->device_type == DEVICE_INTEL_ICH4) in intel8x0_suspend()
2572 chip->sdm_saved = igetbyte(chip, ICHREG(SDM)); in intel8x0_suspend()
2574 if (chip->irq >= 0) { in intel8x0_suspend()
2575 free_irq(chip->irq, chip); in intel8x0_suspend()
2576 chip->irq = -1; in intel8x0_suspend()
2577 card->sync_irq = -1; in intel8x0_suspend()
2586 struct intel8x0 *chip = card->private_data; in intel8x0_resume()
2590 if (request_irq(pci->irq, snd_intel8x0_interrupt, in intel8x0_resume()
2593 pci->irq); in intel8x0_resume()
2595 return -EIO; in intel8x0_resume()
2597 chip->irq = pci->irq; in intel8x0_resume()
2598 card->sync_irq = chip->irq; in intel8x0_resume()
2600 /* re-initialize mixer stuff */ in intel8x0_resume()
2601 if (chip->device_type == DEVICE_INTEL_ICH4 && !spdif_aclink) { in intel8x0_resume()
2603 iputbyte(chip, ICHREG(SDM), chip->sdm_saved); in intel8x0_resume()
2610 for (i = 0; i < chip->ncodecs; i++) in intel8x0_resume()
2611 snd_ac97_resume(chip->ac97[i]); in intel8x0_resume()
2614 for (i = 0; i < chip->bdbars_count; i++) { in intel8x0_resume()
2615 struct ichdev *ichdev = &chip->ichd[i]; in intel8x0_resume()
2616 unsigned long port = ichdev->reg_offset; in intel8x0_resume()
2617 if (! ichdev->substream || ! ichdev->suspended) in intel8x0_resume()
2619 if (ichdev->ichd == ICHD_PCMOUT) in intel8x0_resume()
2620 snd_intel8x0_setup_pcm_out(chip, ichdev->substream->runtime); in intel8x0_resume()
2621 iputdword(chip, port + ICH_REG_OFF_BDBAR, ichdev->bdbar_addr); in intel8x0_resume()
2622 iputbyte(chip, port + ICH_REG_OFF_LVI, ichdev->lvi); in intel8x0_resume()
2623 iputbyte(chip, port + ICH_REG_OFF_CIV, ichdev->civ); in intel8x0_resume()
2624 iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI); in intel8x0_resume()
2644 unsigned long pos, pos1, t; in intel8x0_measure_ac97_clock() local
2648 if (chip->ac97_bus->clock != 48000) in intel8x0_measure_ac97_clock()
2650 if (chip->inside_vm && !ac97_clock) in intel8x0_measure_ac97_clock()
2654 subs = chip->pcm[0]->streams[0].substream; in intel8x0_measure_ac97_clock()
2655 if (! subs || subs->dma_buffer.bytes < INTEL8X0_TESTBUF_SIZE) { in intel8x0_measure_ac97_clock()
2656 dev_warn(chip->card->dev, in intel8x0_measure_ac97_clock()
2657 "no playback buffer allocated - aborting measure ac97 clock\n"); in intel8x0_measure_ac97_clock()
2660 ichdev = &chip->ichd[ICHD_PCMOUT]; in intel8x0_measure_ac97_clock()
2661 ichdev->physbuf = subs->dma_buffer.addr; in intel8x0_measure_ac97_clock()
2662 ichdev->size = ichdev->fragsize = INTEL8X0_TESTBUF_SIZE; in intel8x0_measure_ac97_clock()
2663 ichdev->substream = NULL; /* don't process interrupts */ in intel8x0_measure_ac97_clock()
2666 if (snd_ac97_set_rate(chip->ac97[0], AC97_PCM_FRONT_DAC_RATE, 48000) < 0) { in intel8x0_measure_ac97_clock()
2667 dev_err(chip->card->dev, "cannot set ac97 rate: clock = %d\n", in intel8x0_measure_ac97_clock()
2668 chip->ac97_bus->clock); in intel8x0_measure_ac97_clock()
2672 port = ichdev->reg_offset; in intel8x0_measure_ac97_clock()
2673 spin_lock_irq(&chip->reg_lock); in intel8x0_measure_ac97_clock()
2674 chip->in_measurement = 1; in intel8x0_measure_ac97_clock()
2676 if (chip->device_type != DEVICE_ALI) in intel8x0_measure_ac97_clock()
2680 iputdword(chip, ICHREG(ALI_DMACR), 1 << ichdev->ali_slot); in intel8x0_measure_ac97_clock()
2683 spin_unlock_irq(&chip->reg_lock); in intel8x0_measure_ac97_clock()
2685 spin_lock_irq(&chip->reg_lock); in intel8x0_measure_ac97_clock()
2688 civ = igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV); in intel8x0_measure_ac97_clock()
2689 pos1 = igetword(chip, ichdev->reg_offset + ichdev->roff_picb); in intel8x0_measure_ac97_clock()
2694 if (civ == igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV) && in intel8x0_measure_ac97_clock()
2695 pos1 == igetword(chip, ichdev->reg_offset + ichdev->roff_picb)) in intel8x0_measure_ac97_clock()
2697 } while (timeout--); in intel8x0_measure_ac97_clock()
2699 pos = 0; in intel8x0_measure_ac97_clock()
2701 pos = ichdev->fragsize1; in intel8x0_measure_ac97_clock()
2702 pos -= pos1 << ichdev->pos_shift; in intel8x0_measure_ac97_clock()
2703 pos += ichdev->position; in intel8x0_measure_ac97_clock()
2705 chip->in_measurement = 0; in intel8x0_measure_ac97_clock()
2708 if (chip->device_type == DEVICE_ALI) { in intel8x0_measure_ac97_clock()
2709 iputdword(chip, ICHREG(ALI_DMACR), 1 << (ichdev->ali_slot + 16)); in intel8x0_measure_ac97_clock()
2715 while (!(igetbyte(chip, port + ichdev->roff_sr) & ICH_DCH)) in intel8x0_measure_ac97_clock()
2719 spin_unlock_irq(&chip->reg_lock); in intel8x0_measure_ac97_clock()
2721 if (pos == 0) { in intel8x0_measure_ac97_clock()
2722 dev_err(chip->card->dev, in intel8x0_measure_ac97_clock()
2723 "measure - unreliable DMA position..\n"); in intel8x0_measure_ac97_clock()
2733 pos /= 4; in intel8x0_measure_ac97_clock()
2735 dev_info(chip->card->dev, in intel8x0_measure_ac97_clock()
2736 "%s: measured %lu usecs (%lu samples)\n", __func__, t, pos); in intel8x0_measure_ac97_clock()
2738 dev_err(chip->card->dev, "?? calculation error..\n"); in intel8x0_measure_ac97_clock()
2741 pos *= 1000; in intel8x0_measure_ac97_clock()
2742 pos = (pos / t) * 1000 + ((pos % t) * 1000) / t; in intel8x0_measure_ac97_clock()
2743 if (pos < 40000 || pos >= 60000) { in intel8x0_measure_ac97_clock()
2745 dev_info(chip->card->dev, "measured clock %ld rejected\n", pos); in intel8x0_measure_ac97_clock()
2747 } else if (pos > 40500 && pos < 41500) in intel8x0_measure_ac97_clock()
2748 /* first exception - 41000Hz reference clock */ in intel8x0_measure_ac97_clock()
2749 chip->ac97_bus->clock = 41000; in intel8x0_measure_ac97_clock()
2750 else if (pos > 43600 && pos < 44600) in intel8x0_measure_ac97_clock()
2751 /* second exception - 44100HZ reference clock */ in intel8x0_measure_ac97_clock()
2752 chip->ac97_bus->clock = 44100; in intel8x0_measure_ac97_clock()
2753 else if (pos < 47500 || pos > 48500) in intel8x0_measure_ac97_clock()
2755 chip->ac97_bus->clock = (chip->ac97_bus->clock * 48000) / pos; in intel8x0_measure_ac97_clock()
2757 dev_info(chip->card->dev, "clocking to %d\n", chip->ac97_bus->clock); in intel8x0_measure_ac97_clock()
2758 snd_ac97_update_power(chip->ac97[0], AC97_PCM_FRONT_DAC_RATE, 0); in intel8x0_measure_ac97_clock()
2773 struct pci_dev *pci = chip->pci; in intel8x0_in_clock_list()
2779 dev_info(chip->card->dev, "allow list rate for %04x:%04x is %i\n", in intel8x0_in_clock_list()
2780 pci->subsystem_vendor, pci->subsystem_device, wl->value); in intel8x0_in_clock_list()
2781 chip->ac97_bus->clock = wl->value; in intel8x0_in_clock_list()
2788 struct intel8x0 *chip = entry->private_data; in snd_intel8x0_proc_read()
2792 if (chip->device_type == DEVICE_ALI) in snd_intel8x0_proc_read()
2797 if (chip->device_type == DEVICE_INTEL_ICH4) in snd_intel8x0_proc_read()
2800 if (tmp & chip->codec_isr_bits) { in snd_intel8x0_proc_read()
2805 for (i = 0; i < chip->max_codecs; i++) in snd_intel8x0_proc_read()
2806 if (tmp & chip->codec_bit[i]) in snd_intel8x0_proc_read()
2811 if (chip->device_type == DEVICE_INTEL_ICH4 || in snd_intel8x0_proc_read()
2812 chip->device_type == DEVICE_SIS) in snd_intel8x0_proc_read()
2814 chip->ac97_sdin[0], in snd_intel8x0_proc_read()
2815 chip->ac97_sdin[1], in snd_intel8x0_proc_read()
2816 chip->ac97_sdin[2]); in snd_intel8x0_proc_read()
2821 snd_card_ro_proc_new(chip->card, "intel8x0", chip, in snd_intel8x0_proc_init()
2850 if (pci->subsystem_vendor == PCI_SUBVENDOR_ID_REDHAT_QUMRANET && in snd_intel8x0_inside_vm()
2851 pci->subsystem_device == PCI_SUBDEVICE_ID_QEMU) { in snd_intel8x0_inside_vm()
2855 } else if (pci->subsystem_vendor == 0x1ab8) { in snd_intel8x0_inside_vm()
2863 dev_info(&pci->dev, "%s optimization\n", msg); in snd_intel8x0_inside_vm()
2872 struct intel8x0 *chip = card->private_data; in snd_intel8x0_init()
2913 spin_lock_init(&chip->reg_lock); in snd_intel8x0_init()
2914 chip->device_type = device_type; in snd_intel8x0_init()
2915 chip->card = card; in snd_intel8x0_init()
2916 chip->pci = pci; in snd_intel8x0_init()
2917 chip->irq = -1; in snd_intel8x0_init()
2920 chip->buggy_irq = buggy_irq; in snd_intel8x0_init()
2921 chip->buggy_semaphore = buggy_semaphore; in snd_intel8x0_init()
2923 chip->xbox = 1; in snd_intel8x0_init()
2925 chip->inside_vm = snd_intel8x0_inside_vm(pci); in snd_intel8x0_init()
2930 * is to set the pages as non-cached. For details, see the errata in in snd_intel8x0_init()
2933 if (pci->vendor == PCI_VENDOR_ID_INTEL && in snd_intel8x0_init()
2934 pci->device == PCI_DEVICE_ID_INTEL_440MX) in snd_intel8x0_init()
2935 chip->fix_nocache = 1; /* enable workaround */ in snd_intel8x0_init()
2937 err = pci_request_regions(pci, card->shortname); in snd_intel8x0_init()
2943 chip->bmaddr = pcim_iomap(pci, 0, 0); in snd_intel8x0_init()
2946 chip->addr = pcim_iomap(pci, 2, 0); in snd_intel8x0_init()
2948 chip->addr = pcim_iomap(pci, 0, 0); in snd_intel8x0_init()
2950 chip->bmaddr = pcim_iomap(pci, 3, 0); in snd_intel8x0_init()
2952 chip->bmaddr = pcim_iomap(pci, 1, 0); in snd_intel8x0_init()
2955 chip->bdbars_count = bdbars[device_type]; in snd_intel8x0_init()
2969 for (i = 0; i < chip->bdbars_count; i++) { in snd_intel8x0_init()
2970 ichdev = &chip->ichd[i]; in snd_intel8x0_init()
2971 ichdev->ichd = i; in snd_intel8x0_init()
2972 ichdev->reg_offset = tbl[i].offset; in snd_intel8x0_init()
2973 ichdev->int_sta_mask = tbl[i].int_sta_mask; in snd_intel8x0_init()
2976 ichdev->roff_sr = ICH_REG_OFF_PICB; in snd_intel8x0_init()
2977 ichdev->roff_picb = ICH_REG_OFF_SR; in snd_intel8x0_init()
2979 ichdev->roff_sr = ICH_REG_OFF_SR; in snd_intel8x0_init()
2980 ichdev->roff_picb = ICH_REG_OFF_PICB; in snd_intel8x0_init()
2983 ichdev->ali_slot = (ichdev->reg_offset - 0x40) / 0x10; in snd_intel8x0_init()
2985 ichdev->pos_shift = (device_type == DEVICE_SIS) ? 0 : 1; in snd_intel8x0_init()
2990 chip->bdbars = snd_devm_alloc_pages(&pci->dev, intel8x0_dma_type(chip), in snd_intel8x0_init()
2991 chip->bdbars_count * sizeof(u32) * in snd_intel8x0_init()
2993 if (!chip->bdbars) in snd_intel8x0_init()
2994 return -ENOMEM; in snd_intel8x0_init()
2999 for (i = 0; i < chip->bdbars_count; i++) { in snd_intel8x0_init()
3000 ichdev = &chip->ichd[i]; in snd_intel8x0_init()
3001 ichdev->bdbar = ((__le32 *)chip->bdbars->area) + in snd_intel8x0_init()
3003 ichdev->bdbar_addr = chip->bdbars->addr + in snd_intel8x0_init()
3005 int_sta_masks |= ichdev->int_sta_mask; in snd_intel8x0_init()
3007 chip->int_sta_reg = device_type == DEVICE_ALI ? in snd_intel8x0_init()
3009 chip->int_sta_mask = int_sta_masks; in snd_intel8x0_init()
3013 switch(chip->device_type) { in snd_intel8x0_init()
3016 chip->max_codecs = 3; in snd_intel8x0_init()
3017 chip->codec_bit = ich_codec_bits; in snd_intel8x0_init()
3018 chip->codec_ready_bits = ICH_PRI | ICH_SRI | ICH_TRI; in snd_intel8x0_init()
3022 chip->max_codecs = 3; in snd_intel8x0_init()
3023 chip->codec_bit = sis_codec_bits; in snd_intel8x0_init()
3024 chip->codec_ready_bits = ICH_PRI | ICH_SRI | ICH_SIS_TRI; in snd_intel8x0_init()
3028 chip->max_codecs = 2; in snd_intel8x0_init()
3029 chip->codec_bit = ich_codec_bits; in snd_intel8x0_init()
3030 chip->codec_ready_bits = ICH_PRI | ICH_SRI; in snd_intel8x0_init()
3033 for (i = 0; i < chip->max_codecs; i++) in snd_intel8x0_init()
3034 chip->codec_isr_bits |= chip->codec_bit[i]; in snd_intel8x0_init()
3042 * re-acquired in PM callbacks. in snd_intel8x0_init()
3045 if (request_irq(pci->irq, snd_intel8x0_interrupt, in snd_intel8x0_init()
3047 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); in snd_intel8x0_init()
3048 return -EBUSY; in snd_intel8x0_init()
3050 chip->irq = pci->irq; in snd_intel8x0_init()
3051 card->sync_irq = chip->irq; in snd_intel8x0_init()
3053 card->private_free = snd_intel8x0_free; in snd_intel8x0_init()
3062 { PCI_DEVICE_ID_INTEL_82801AA_5, "Intel 82801AA-ICH" },
3063 { PCI_DEVICE_ID_INTEL_82801AB_5, "Intel 82901AB-ICH0" },
3064 { PCI_DEVICE_ID_INTEL_82801BA_4, "Intel 82801BA-ICH2" },
3066 { PCI_DEVICE_ID_INTEL_82801CA_5, "Intel 82801CA-ICH3" },
3067 { PCI_DEVICE_ID_INTEL_82801DB_5, "Intel 82801DB-ICH4" },
3092 /* look up allow/deny list for SPDIF over ac-link */
3099 if (w->value) in check_default_spdif_aclink()
3100 dev_dbg(&pci->dev, in check_default_spdif_aclink()
3101 "Using SPDIF over AC-Link for %s\n", in check_default_spdif_aclink()
3104 dev_dbg(&pci->dev, in check_default_spdif_aclink()
3107 return w->value; in check_default_spdif_aclink()
3120 err = snd_devm_card_new(&pci->dev, index, id, THIS_MODULE, in __snd_intel8x0_probe()
3124 chip = card->private_data; in __snd_intel8x0_probe()
3129 strcpy(card->driver, "ICH"); in __snd_intel8x0_probe()
3131 switch (pci_id->driver_data) { in __snd_intel8x0_probe()
3133 strcpy(card->driver, "NFORCE"); in __snd_intel8x0_probe()
3136 strcpy(card->driver, "ICH4"); in __snd_intel8x0_probe()
3140 strcpy(card->shortname, "Intel ICH"); in __snd_intel8x0_probe()
3141 for (name = shortnames; name->id; name++) { in __snd_intel8x0_probe()
3142 if (pci->device == name->id) { in __snd_intel8x0_probe()
3143 strcpy(card->shortname, name->s); in __snd_intel8x0_probe()
3152 if (pci_id->driver_data == DEVICE_NFORCE) in __snd_intel8x0_probe()
3158 err = snd_intel8x0_init(card, pci, pci_id->driver_data); in __snd_intel8x0_probe()
3171 snprintf(card->longname, sizeof(card->longname), in __snd_intel8x0_probe()
3172 "%s with %s at irq %i", card->shortname, in __snd_intel8x0_probe()
3173 snd_ac97_get_short_name(chip->ac97[0]), chip->irq); in __snd_intel8x0_probe()
3195 return snd_card_free_on_error(&pci->dev, __snd_intel8x0_probe(pci, pci_id)); in snd_intel8x0_probe()