Lines Matching +full:adc +full:- +full:use +full:- +full:res
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 */ \
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) */
171 #define ICH_REG_ACC_SEMA 0x34 /* byte - codec write semaphore */
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()
530 unsigned short res; in snd_intel8x0_codec_read() local
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()
538 res = 0xffff; 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()
550 res = 0xffff; in snd_intel8x0_codec_read()
553 return res; 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()
707 ichdev->civ++; in snd_intel8x0_update()
708 ichdev->civ &= ICH_REG_LVI_MASK; in snd_intel8x0_update()
710 step = civ - ichdev->civ; in snd_intel8x0_update()
713 ichdev->civ = civ; in snd_intel8x0_update()
716 ichdev->position += step * ichdev->fragsize1; in snd_intel8x0_update()
717 if (! chip->in_measurement) in snd_intel8x0_update()
718 ichdev->position %= ichdev->size; in snd_intel8x0_update()
719 ichdev->lvi += step; in snd_intel8x0_update()
720 ichdev->lvi &= ICH_REG_LVI_MASK; in snd_intel8x0_update()
721 iputbyte(chip, port + ICH_REG_OFF_LVI, ichdev->lvi); in snd_intel8x0_update()
723 ichdev->lvi_frag++; in snd_intel8x0_update()
724 ichdev->lvi_frag %= ichdev->frags; in snd_intel8x0_update()
725 …ichdev->bdbar[ichdev->lvi * 2] = cpu_to_le32(ichdev->physbuf + ichdev->lvi_frag * ichdev->fragsize… in snd_intel8x0_update()
727 dev_dbg(chip->card->dev, in snd_intel8x0_update()
729 ichdev->lvi * 2, ichdev->bdbar[ichdev->lvi * 2], in snd_intel8x0_update()
730 ichdev->bdbar[ichdev->lvi * 2 + 1], inb(ICH_REG_OFF_PIV + port), in snd_intel8x0_update()
733 if (--ichdev->ack == 0) { in snd_intel8x0_update()
734 ichdev->ack = ichdev->ack_reload; in snd_intel8x0_update()
738 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_intel8x0_update()
739 if (ack && ichdev->substream) { in snd_intel8x0_update()
740 snd_pcm_period_elapsed(ichdev->substream); in snd_intel8x0_update()
742 iputbyte(chip, port + ichdev->roff_sr, in snd_intel8x0_update()
753 status = igetdword(chip, chip->int_sta_reg); in snd_intel8x0_interrupt()
757 if ((status & chip->int_sta_mask) == 0) { in snd_intel8x0_interrupt()
760 iputdword(chip, chip->int_sta_reg, status); in snd_intel8x0_interrupt()
761 if (! chip->buggy_irq) in snd_intel8x0_interrupt()
767 for (i = 0; i < chip->bdbars_count; i++) { in snd_intel8x0_interrupt()
768 ichdev = &chip->ichd[i]; in snd_intel8x0_interrupt()
769 if (status & ichdev->int_sta_mask) in snd_intel8x0_interrupt()
774 iputdword(chip, chip->int_sta_reg, status & chip->int_sta_mask); in snd_intel8x0_interrupt()
788 unsigned long port = ichdev->reg_offset; in snd_intel8x0_pcm_trigger()
792 ichdev->suspended = 0; in snd_intel8x0_pcm_trigger()
797 ichdev->last_pos = ichdev->position; in snd_intel8x0_pcm_trigger()
800 ichdev->suspended = 1; in snd_intel8x0_pcm_trigger()
809 return -EINVAL; in snd_intel8x0_pcm_trigger()
814 while (!(igetbyte(chip, port + ichdev->roff_sr) & ICH_DCH)) ; in snd_intel8x0_pcm_trigger()
825 unsigned long port = ichdev->reg_offset; in snd_intel8x0_ali_trigger()
834 ichdev->suspended = 0; in snd_intel8x0_ali_trigger()
838 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_intel8x0_ali_trigger()
840 fifo = igetdword(chip, fiforeg[ichdev->ali_slot / 4]); in snd_intel8x0_ali_trigger()
841 fifo &= ~(0xff << (ichdev->ali_slot % 4)); in snd_intel8x0_ali_trigger()
842 fifo |= 0x83 << (ichdev->ali_slot % 4); in snd_intel8x0_ali_trigger()
843 iputdword(chip, fiforeg[ichdev->ali_slot / 4], fifo); in snd_intel8x0_ali_trigger()
846 val &= ~(1 << (ichdev->ali_slot + 16)); /* clear PAUSE flag */ in snd_intel8x0_ali_trigger()
848 iputdword(chip, ICHREG(ALI_DMACR), val | (1 << ichdev->ali_slot)); in snd_intel8x0_ali_trigger()
851 ichdev->suspended = 1; in snd_intel8x0_ali_trigger()
856 iputdword(chip, ICHREG(ALI_DMACR), val | (1 << (ichdev->ali_slot + 16))); in snd_intel8x0_ali_trigger()
868 igetdword(chip, ICHREG(ALI_INTERRUPTSR)) & ichdev->int_sta_mask); in snd_intel8x0_ali_trigger()
871 return -EINVAL; in snd_intel8x0_ali_trigger()
884 if (ichdev->pcm_open_flag) { in snd_intel8x0_hw_params()
885 snd_ac97_pcm_close(ichdev->pcm); in snd_intel8x0_hw_params()
886 ichdev->pcm_open_flag = 0; in snd_intel8x0_hw_params()
887 ichdev->prepared = 0; in snd_intel8x0_hw_params()
889 err = snd_ac97_pcm_open(ichdev->pcm, params_rate(hw_params), in snd_intel8x0_hw_params()
891 ichdev->pcm->r[dbl].slots); in snd_intel8x0_hw_params()
893 ichdev->pcm_open_flag = 1; in snd_intel8x0_hw_params()
895 if (ichdev->ichd == ICHD_PCMOUT && chip->spdif_idx < 0) in snd_intel8x0_hw_params()
896 snd_ac97_set_rate(ichdev->pcm->r[0].codec[0], AC97_SPDIF, in snd_intel8x0_hw_params()
906 if (ichdev->pcm_open_flag) { in snd_intel8x0_hw_free()
907 snd_ac97_pcm_close(ichdev->pcm); in snd_intel8x0_hw_free()
908 ichdev->pcm_open_flag = 0; in snd_intel8x0_hw_free()
909 ichdev->prepared = 0; in snd_intel8x0_hw_free()
918 int dbl = runtime->rate > 48000; in snd_intel8x0_setup_pcm_out()
920 spin_lock_irq(&chip->reg_lock); in snd_intel8x0_setup_pcm_out()
921 switch (chip->device_type) { in snd_intel8x0_setup_pcm_out()
925 if (runtime->channels == 4 || dbl) in snd_intel8x0_setup_pcm_out()
927 else if (runtime->channels == 6) in snd_intel8x0_setup_pcm_out()
934 if (runtime->channels == 4 || dbl) in snd_intel8x0_setup_pcm_out()
936 else if (runtime->channels == 6) in snd_intel8x0_setup_pcm_out()
943 if (runtime->channels == 4 || dbl) in snd_intel8x0_setup_pcm_out()
945 else if (runtime->channels == 6) in snd_intel8x0_setup_pcm_out()
947 else if (runtime->channels == 8) in snd_intel8x0_setup_pcm_out()
949 if (chip->device_type == DEVICE_NFORCE) { in snd_intel8x0_setup_pcm_out()
955 spin_unlock_irq(&chip->reg_lock); in snd_intel8x0_setup_pcm_out()
957 spin_lock_irq(&chip->reg_lock); in snd_intel8x0_setup_pcm_out()
959 } else if (chip->device_type == DEVICE_INTEL_ICH4) { in snd_intel8x0_setup_pcm_out()
960 if (runtime->sample_bits > 16) in snd_intel8x0_setup_pcm_out()
966 spin_unlock_irq(&chip->reg_lock); in snd_intel8x0_setup_pcm_out()
972 struct snd_pcm_runtime *runtime = substream->runtime; in snd_intel8x0_pcm_prepare()
975 ichdev->physbuf = runtime->dma_addr; in snd_intel8x0_pcm_prepare()
976 ichdev->size = snd_pcm_lib_buffer_bytes(substream); in snd_intel8x0_pcm_prepare()
977 ichdev->fragsize = snd_pcm_lib_period_bytes(substream); in snd_intel8x0_pcm_prepare()
978 if (ichdev->ichd == ICHD_PCMOUT) { in snd_intel8x0_pcm_prepare()
980 if (chip->device_type == DEVICE_INTEL_ICH4) in snd_intel8x0_pcm_prepare()
981 ichdev->pos_shift = (runtime->sample_bits > 16) ? 2 : 1; in snd_intel8x0_pcm_prepare()
984 ichdev->prepared = 1; in snd_intel8x0_pcm_prepare()
996 spin_lock(&chip->reg_lock); in snd_intel8x0_pcm_pointer()
998 civ = igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV); in snd_intel8x0_pcm_pointer()
999 ptr1 = igetword(chip, ichdev->reg_offset + ichdev->roff_picb); in snd_intel8x0_pcm_pointer()
1000 position = ichdev->position; in snd_intel8x0_pcm_pointer()
1005 if (civ != igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV)) in snd_intel8x0_pcm_pointer()
1014 if (chip->inside_vm) in snd_intel8x0_pcm_pointer()
1016 if (ptr1 == igetword(chip, ichdev->reg_offset + ichdev->roff_picb)) in snd_intel8x0_pcm_pointer()
1018 } while (timeout--); in snd_intel8x0_pcm_pointer()
1019 ptr = ichdev->last_pos; in snd_intel8x0_pcm_pointer()
1021 ptr1 <<= ichdev->pos_shift; in snd_intel8x0_pcm_pointer()
1022 ptr = ichdev->fragsize1 - ptr1; in snd_intel8x0_pcm_pointer()
1024 if (ptr < ichdev->last_pos) { in snd_intel8x0_pcm_pointer()
1026 pos_base = position / ichdev->fragsize1; in snd_intel8x0_pcm_pointer()
1027 last_base = ichdev->last_pos / ichdev->fragsize1; in snd_intel8x0_pcm_pointer()
1032 ptr = ichdev->last_pos; in snd_intel8x0_pcm_pointer()
1035 ichdev->last_pos = ptr; in snd_intel8x0_pcm_pointer()
1036 spin_unlock(&chip->reg_lock); in snd_intel8x0_pcm_pointer()
1037 if (ptr >= ichdev->size) in snd_intel8x0_pcm_pointer()
1039 return bytes_to_frames(substream->runtime, ptr); in snd_intel8x0_pcm_pointer()
1096 struct snd_pcm_runtime *runtime = substream->runtime; in snd_intel8x0_pcm_open()
1099 ichdev->substream = substream; in snd_intel8x0_pcm_open()
1100 runtime->hw = snd_intel8x0_stream; in snd_intel8x0_pcm_open()
1101 runtime->hw.rates = ichdev->pcm->rates; in snd_intel8x0_pcm_open()
1103 if (chip->device_type == DEVICE_SIS) { in snd_intel8x0_pcm_open()
1104 runtime->hw.buffer_bytes_max = 64*1024; in snd_intel8x0_pcm_open()
1105 runtime->hw.period_bytes_max = 64*1024; in snd_intel8x0_pcm_open()
1110 runtime->private_data = ichdev; in snd_intel8x0_pcm_open()
1117 struct snd_pcm_runtime *runtime = substream->runtime; in snd_intel8x0_playback_open()
1120 err = snd_intel8x0_pcm_open(substream, &chip->ichd[ICHD_PCMOUT]); in snd_intel8x0_playback_open()
1124 if (chip->multi8) { in snd_intel8x0_playback_open()
1125 runtime->hw.channels_max = 8; in snd_intel8x0_playback_open()
1129 } else if (chip->multi6) { in snd_intel8x0_playback_open()
1130 runtime->hw.channels_max = 6; in snd_intel8x0_playback_open()
1133 } else if (chip->multi4) { in snd_intel8x0_playback_open()
1134 runtime->hw.channels_max = 4; in snd_intel8x0_playback_open()
1138 if (chip->dra) { in snd_intel8x0_playback_open()
1141 if (chip->smp20bit) { in snd_intel8x0_playback_open()
1142 runtime->hw.formats |= SNDRV_PCM_FMTBIT_S32_LE; in snd_intel8x0_playback_open()
1152 chip->ichd[ICHD_PCMOUT].substream = NULL; in snd_intel8x0_playback_close()
1160 return snd_intel8x0_pcm_open(substream, &chip->ichd[ICHD_PCMIN]); in snd_intel8x0_capture_open()
1167 chip->ichd[ICHD_PCMIN].substream = NULL; in snd_intel8x0_capture_close()
1175 return snd_intel8x0_pcm_open(substream, &chip->ichd[ICHD_MIC]); in snd_intel8x0_mic_open()
1182 chip->ichd[ICHD_MIC].substream = NULL; in snd_intel8x0_mic_close()
1190 return snd_intel8x0_pcm_open(substream, &chip->ichd[ICHD_MIC2]); in snd_intel8x0_mic2_open()
1197 chip->ichd[ICHD_MIC2].substream = NULL; in snd_intel8x0_mic2_close()
1205 return snd_intel8x0_pcm_open(substream, &chip->ichd[ICHD_PCM2IN]); in snd_intel8x0_capture2_open()
1212 chip->ichd[ICHD_PCM2IN].substream = NULL; in snd_intel8x0_capture2_close()
1219 int idx = chip->device_type == DEVICE_NFORCE ? NVD_SPBAR : ICHD_SPBAR; in snd_intel8x0_spdif_open()
1221 return snd_intel8x0_pcm_open(substream, &chip->ichd[idx]); in snd_intel8x0_spdif_open()
1227 int idx = chip->device_type == DEVICE_NFORCE ? NVD_SPBAR : ICHD_SPBAR; in snd_intel8x0_spdif_close()
1229 chip->ichd[idx].substream = NULL; in snd_intel8x0_spdif_close()
1238 spin_lock_irq(&chip->reg_lock); in snd_intel8x0_ali_ac97spdifout_open()
1243 spin_unlock_irq(&chip->reg_lock); in snd_intel8x0_ali_ac97spdifout_open()
1245 return snd_intel8x0_pcm_open(substream, &chip->ichd[ALID_AC97SPDIFOUT]); in snd_intel8x0_ali_ac97spdifout_open()
1253 chip->ichd[ALID_AC97SPDIFOUT].substream = NULL; in snd_intel8x0_ali_ac97spdifout_close()
1254 spin_lock_irq(&chip->reg_lock); in snd_intel8x0_ali_ac97spdifout_close()
1258 spin_unlock_irq(&chip->reg_lock); in snd_intel8x0_ali_ac97spdifout_close()
1268 return snd_intel8x0_pcm_open(substream, &chip->ichd[ALID_SPDIFIN]);
1275 chip->ichd[ALID_SPDIFIN].substream = NULL;
1283 return snd_intel8x0_pcm_open(substream, &chip->ichd[ALID_SPDIFOUT]);
1290 chip->ichd[ALID_SPDIFOUT].substream = NULL;
1427 ((chip)->fix_nocache ? SNDRV_DMA_TYPE_DEV_WC : SNDRV_DMA_TYPE_DEV)
1436 if (rec->suffix) in snd_intel8x0_pcm1()
1437 sprintf(name, "Intel ICH - %s", rec->suffix); in snd_intel8x0_pcm1()
1440 err = snd_pcm_new(chip->card, name, device, in snd_intel8x0_pcm1()
1441 rec->playback_ops ? 1 : 0, in snd_intel8x0_pcm1()
1442 rec->capture_ops ? 1 : 0, &pcm); in snd_intel8x0_pcm1()
1446 if (rec->playback_ops) in snd_intel8x0_pcm1()
1447 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, rec->playback_ops); in snd_intel8x0_pcm1()
1448 if (rec->capture_ops) in snd_intel8x0_pcm1()
1449 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, rec->capture_ops); in snd_intel8x0_pcm1()
1451 pcm->private_data = chip; in snd_intel8x0_pcm1()
1452 pcm->info_flags = 0; in snd_intel8x0_pcm1()
1453 if (rec->suffix) in snd_intel8x0_pcm1()
1454 sprintf(pcm->name, "%s - %s", chip->card->shortname, rec->suffix); in snd_intel8x0_pcm1()
1456 strcpy(pcm->name, chip->card->shortname); in snd_intel8x0_pcm1()
1457 chip->pcm[device] = pcm; in snd_intel8x0_pcm1()
1460 &chip->pci->dev, in snd_intel8x0_pcm1()
1461 rec->prealloc_size, rec->prealloc_max_size); in snd_intel8x0_pcm1()
1463 if (rec->playback_ops && in snd_intel8x0_pcm1()
1464 rec->playback_ops->open == snd_intel8x0_playback_open) { in snd_intel8x0_pcm1()
1467 if (chip->multi8) in snd_intel8x0_pcm1()
1469 else if (chip->multi6) in snd_intel8x0_pcm1()
1471 else if (chip->multi4) in snd_intel8x0_pcm1()
1478 chmap->channel_mask = SND_PCM_CHMAP_MASK_2468; in snd_intel8x0_pcm1()
1479 chip->ac97[0]->chmaps[SNDRV_PCM_STREAM_PLAYBACK] = chmap; in snd_intel8x0_pcm1()
1493 .suffix = "MIC ADC",
1500 .suffix = "MIC2 ADC",
1530 .suffix = "MIC ADC",
1553 .suffix = "MIC ADC",
1582 switch (chip->device_type) { in snd_intel8x0_pcm()
1587 tblsize--; in snd_intel8x0_pcm()
1593 tblsize--; in snd_intel8x0_pcm()
1608 if (i > 0 && rec->ac97_idx) { in snd_intel8x0_pcm()
1610 if (! chip->ichd[rec->ac97_idx].pcm) in snd_intel8x0_pcm()
1619 chip->pcm_devs = device; in snd_intel8x0_pcm()
1630 struct intel8x0 *chip = bus->private_data; in snd_intel8x0_mixer_free_ac97_bus()
1631 chip->ac97_bus = NULL; in snd_intel8x0_mixer_free_ac97_bus()
1636 struct intel8x0 *chip = ac97->private_data; in snd_intel8x0_mixer_free_ac97()
1637 chip->ac97[ac97->num] = NULL; in snd_intel8x0_mixer_free_ac97()
1744 .name = "MS-9128",
1942 .name = "Sony VAIO VGN-T350P", /*AD1981B*/
1948 .name = "Sony VAIO VGN-B1VP", /*AD1981B*/
1960 .name = "Fujitsu-Siemens E4010",
1966 .name = "Fujitsu-Siemens T3010",
1990 .name = "Fujitsu-Siemens 4010",
1996 .name = "Fujitsu-Siemens Celsius H320",
2002 .name = "Fujitsu-Siemens Celsius", /* AD1981? */
2020 .name = "Panasonic CF-R4",
2026 .name = "Fujitsu-Siemens Scenic", /* AD1981? */
2056 .name = "Fujitsu-Siemens D1522", /* AD1981 */
2135 chip->spdif_idx = -1; /* use PCMOUT (or disabled) */ in snd_intel8x0_mixer()
2137 switch (chip->device_type) { in snd_intel8x0_mixer()
2139 chip->spdif_idx = NVD_SPBAR; in snd_intel8x0_mixer()
2142 chip->spdif_idx = ALID_AC97SPDIFOUT; in snd_intel8x0_mixer()
2145 chip->spdif_idx = ICHD_SPBAR; in snd_intel8x0_mixer()
2150 chip->in_ac97_init = 1; in snd_intel8x0_mixer()
2156 if (chip->xbox) in snd_intel8x0_mixer()
2158 if (chip->device_type != DEVICE_ALI) { in snd_intel8x0_mixer()
2161 chip->in_sdin_init = 1; in snd_intel8x0_mixer()
2163 for (i = 0; i < chip->max_codecs; i++) { in snd_intel8x0_mixer()
2164 if (! (glob_sta & chip->codec_bit[i])) in snd_intel8x0_mixer()
2166 if (chip->device_type == DEVICE_INTEL_ICH4) { in snd_intel8x0_mixer()
2168 chip->ac97_sdin[codecs] = in snd_intel8x0_mixer()
2170 if (snd_BUG_ON(chip->ac97_sdin[codecs] >= 3)) in snd_intel8x0_mixer()
2171 chip->ac97_sdin[codecs] = 0; in snd_intel8x0_mixer()
2173 chip->ac97_sdin[codecs] = i; in snd_intel8x0_mixer()
2176 chip->in_sdin_init = 0; in snd_intel8x0_mixer()
2193 err = snd_ac97_bus(chip->card, 0, ops, chip, &pbus); in snd_intel8x0_mixer()
2196 pbus->private_free = snd_intel8x0_mixer_free_ac97_bus; in snd_intel8x0_mixer()
2198 pbus->clock = ac97_clock; in snd_intel8x0_mixer()
2200 if (chip->device_type == DEVICE_ALI) in snd_intel8x0_mixer()
2201 pbus->no_vra = 1; in snd_intel8x0_mixer()
2203 pbus->dra = 1; in snd_intel8x0_mixer()
2204 chip->ac97_bus = pbus; in snd_intel8x0_mixer()
2205 chip->ncodecs = codecs; in snd_intel8x0_mixer()
2207 ac97.pci = chip->pci; in snd_intel8x0_mixer()
2210 err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i]); in snd_intel8x0_mixer()
2212 if (err != -EACCES) in snd_intel8x0_mixer()
2213 dev_err(chip->card->dev, in snd_intel8x0_mixer()
2220 snd_ac97_tune_hardware(chip->ac97[0], ac97_quirks, quirk_override); in snd_intel8x0_mixer()
2222 if (chip->device_type == DEVICE_INTEL_ICH4) in snd_intel8x0_mixer()
2223 pbus->isdin = 1; in snd_intel8x0_mixer()
2226 if (chip->device_type != DEVICE_INTEL_ICH4) in snd_intel8x0_mixer()
2227 i -= 2; /* do not allocate PCM2IN and MIC2 */ in snd_intel8x0_mixer()
2228 if (chip->spdif_idx < 0) in snd_intel8x0_mixer()
2229 i--; /* do not allocate S/PDIF */ in snd_intel8x0_mixer()
2233 chip->ichd[ICHD_PCMOUT].pcm = &pbus->pcms[0]; in snd_intel8x0_mixer()
2234 chip->ichd[ICHD_PCMIN].pcm = &pbus->pcms[1]; in snd_intel8x0_mixer()
2235 chip->ichd[ICHD_MIC].pcm = &pbus->pcms[2]; in snd_intel8x0_mixer()
2236 if (chip->spdif_idx >= 0) in snd_intel8x0_mixer()
2237 chip->ichd[chip->spdif_idx].pcm = &pbus->pcms[3]; in snd_intel8x0_mixer()
2238 if (chip->device_type == DEVICE_INTEL_ICH4) { in snd_intel8x0_mixer()
2239 chip->ichd[ICHD_PCM2IN].pcm = &pbus->pcms[4]; in snd_intel8x0_mixer()
2240 chip->ichd[ICHD_MIC2].pcm = &pbus->pcms[5]; in snd_intel8x0_mixer()
2243 if (chip->device_type == DEVICE_INTEL_ICH4) { in snd_intel8x0_mixer()
2244 struct ac97_pcm *pcm = chip->ichd[ICHD_PCM2IN].pcm; in snd_intel8x0_mixer()
2249 tmp |= chip->ac97_sdin[0] << ICH_DI1L_SHIFT; in snd_intel8x0_mixer()
2251 if (pcm->r[0].codec[i]) { in snd_intel8x0_mixer()
2252 tmp |= chip->ac97_sdin[pcm->r[0].codec[1]->num] << ICH_DI2L_SHIFT; in snd_intel8x0_mixer()
2261 if (pbus->pcms[0].r[0].slots & (1 << AC97_SLOT_PCM_SLEFT)) { in snd_intel8x0_mixer()
2262 chip->multi4 = 1; in snd_intel8x0_mixer()
2263 if (pbus->pcms[0].r[0].slots & (1 << AC97_SLOT_LFE)) { in snd_intel8x0_mixer()
2264 chip->multi6 = 1; in snd_intel8x0_mixer()
2265 if (chip->ac97[0]->flags & AC97_HAS_8CH) in snd_intel8x0_mixer()
2266 chip->multi8 = 1; in snd_intel8x0_mixer()
2269 if (pbus->pcms[0].r[1].rslots[0]) { in snd_intel8x0_mixer()
2270 chip->dra = 1; in snd_intel8x0_mixer()
2272 if (chip->device_type == DEVICE_INTEL_ICH4) { in snd_intel8x0_mixer()
2274 chip->smp20bit = 1; in snd_intel8x0_mixer()
2276 if (chip->device_type == DEVICE_NFORCE && !spdif_aclink) { in snd_intel8x0_mixer()
2278 chip->ichd[chip->spdif_idx].pcm->rates = SNDRV_PCM_RATE_48000; in snd_intel8x0_mixer()
2280 if (chip->device_type == DEVICE_INTEL_ICH4 && !spdif_aclink) { in snd_intel8x0_mixer()
2281 /* use slot 10/11 for SPDIF */ in snd_intel8x0_mixer()
2286 snd_ac97_update_bits(chip->ac97[0], AC97_EXTENDED_STATUS, 0x03 << 4, 0x03 << 4); in snd_intel8x0_mixer()
2288 chip->in_ac97_init = 0; in snd_intel8x0_mixer()
2292 /* clear the cold-reset bit for the next chance */ in snd_intel8x0_mixer()
2293 if (chip->device_type != DEVICE_ALI) in snd_intel8x0_mixer()
2327 if (snd_pci_quirk_lookup(chip->pci, ich_chip_reset_mode)) in snd_intel8x0_ich_chip_cold_reset()
2328 return -EIO; in snd_intel8x0_ich_chip_cold_reset()
2333 /* do cold reset - the full ac97 powerdown may leave the controller in snd_intel8x0_ich_chip_cold_reset()
2344 (!snd_pci_quirk_lookup(chip->pci, ich_chip_reset_mode))
2366 dev_err(chip->card->dev, "AC'97 warm reset still in progress? [0x%x]\n", in snd_intel8x0_ich_chip_reset()
2368 return -EIO; in snd_intel8x0_ich_chip_reset()
2381 if (chip->device_type == DEVICE_NFORCE) in snd_intel8x0_ich_chip_init()
2401 chip->codec_isr_bits; in snd_intel8x0_ich_chip_init()
2408 dev_err(chip->card->dev, in snd_intel8x0_ich_chip_init()
2411 return -EIO; in snd_intel8x0_ich_chip_init()
2416 while (status != chip->codec_isr_bits && in snd_intel8x0_ich_chip_init()
2420 chip->codec_isr_bits; in snd_intel8x0_ich_chip_init()
2427 for (i = 0; i < chip->ncodecs; i++) in snd_intel8x0_ich_chip_init()
2428 if (chip->ac97[i]) in snd_intel8x0_ich_chip_init()
2429 status |= chip->codec_bit[chip->ac97_sdin[i]]; in snd_intel8x0_ich_chip_init()
2434 chip->codec_isr_bits; in snd_intel8x0_ich_chip_init()
2441 if (chip->device_type == DEVICE_SIS) { in snd_intel8x0_ich_chip_init()
2445 if (chip->device_type == DEVICE_NFORCE && !spdif_aclink) { in snd_intel8x0_ich_chip_init()
2448 pci_read_config_dword(chip->pci, 0x4c, &val); in snd_intel8x0_ich_chip_init()
2450 pci_write_config_dword(chip->pci, 0x4c, val); in snd_intel8x0_ich_chip_init()
2473 dev_err(chip->card->dev, "AC'97 reset failed.\n"); in snd_intel8x0_ali_chip_init()
2475 return -EIO; in snd_intel8x0_ali_chip_init()
2495 if (chip->device_type != DEVICE_ALI) { in snd_intel8x0_chip_init()
2507 for (i = 0; i < chip->bdbars_count; i++) in snd_intel8x0_chip_init()
2508 iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, 0x00); 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, ICH_RESETREGS); in snd_intel8x0_chip_init()
2512 for (i = 0; i < chip->bdbars_count; i++) { in snd_intel8x0_chip_init()
2514 while (--timeout != 0) { in snd_intel8x0_chip_init()
2515 if ((igetbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset) & ICH_RESETREGS) == 0) in snd_intel8x0_chip_init()
2519 dev_err(chip->card->dev, "reset of registers failed?\n"); in snd_intel8x0_chip_init()
2522 for (i = 0; i < chip->bdbars_count; i++) in snd_intel8x0_chip_init()
2523 iputdword(chip, ICH_REG_OFF_BDBAR + chip->ichd[i].reg_offset, in snd_intel8x0_chip_init()
2524 chip->ichd[i].bdbar_addr); in snd_intel8x0_chip_init()
2530 struct intel8x0 *chip = card->private_data; in snd_intel8x0_free()
2533 if (chip->irq < 0) in snd_intel8x0_free()
2536 for (i = 0; i < chip->bdbars_count; i++) in snd_intel8x0_free()
2537 iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, 0x00); 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, ICH_RESETREGS); in snd_intel8x0_free()
2541 if (chip->device_type == DEVICE_NFORCE && !spdif_aclink) { in snd_intel8x0_free()
2544 pci_read_config_dword(chip->pci, 0x4c, &val); in snd_intel8x0_free()
2546 pci_write_config_dword(chip->pci, 0x4c, val); in snd_intel8x0_free()
2548 /* --- */ in snd_intel8x0_free()
2551 if (chip->irq >= 0) in snd_intel8x0_free()
2552 free_irq(chip->irq, chip); in snd_intel8x0_free()
2561 struct intel8x0 *chip = card->private_data; in intel8x0_suspend()
2565 for (i = 0; i < chip->ncodecs; i++) in intel8x0_suspend()
2566 snd_ac97_suspend(chip->ac97[i]); in intel8x0_suspend()
2567 if (chip->device_type == DEVICE_INTEL_ICH4) in intel8x0_suspend()
2568 chip->sdm_saved = igetbyte(chip, ICHREG(SDM)); in intel8x0_suspend()
2570 if (chip->irq >= 0) { in intel8x0_suspend()
2571 free_irq(chip->irq, chip); in intel8x0_suspend()
2572 chip->irq = -1; in intel8x0_suspend()
2573 card->sync_irq = -1; in intel8x0_suspend()
2582 struct intel8x0 *chip = card->private_data; in intel8x0_resume()
2586 if (request_irq(pci->irq, snd_intel8x0_interrupt, in intel8x0_resume()
2589 pci->irq); in intel8x0_resume()
2591 return -EIO; in intel8x0_resume()
2593 chip->irq = pci->irq; in intel8x0_resume()
2594 card->sync_irq = chip->irq; in intel8x0_resume()
2596 /* re-initialize mixer stuff */ in intel8x0_resume()
2597 if (chip->device_type == DEVICE_INTEL_ICH4 && !spdif_aclink) { in intel8x0_resume()
2599 iputbyte(chip, ICHREG(SDM), chip->sdm_saved); in intel8x0_resume()
2600 /* use slot 10/11 for SPDIF */ in intel8x0_resume()
2606 for (i = 0; i < chip->ncodecs; i++) in intel8x0_resume()
2607 snd_ac97_resume(chip->ac97[i]); in intel8x0_resume()
2610 for (i = 0; i < chip->bdbars_count; i++) { in intel8x0_resume()
2611 struct ichdev *ichdev = &chip->ichd[i]; in intel8x0_resume()
2612 unsigned long port = ichdev->reg_offset; in intel8x0_resume()
2613 if (! ichdev->substream || ! ichdev->suspended) in intel8x0_resume()
2615 if (ichdev->ichd == ICHD_PCMOUT) in intel8x0_resume()
2616 snd_intel8x0_setup_pcm_out(chip, ichdev->substream->runtime); in intel8x0_resume()
2617 iputdword(chip, port + ICH_REG_OFF_BDBAR, ichdev->bdbar_addr); in intel8x0_resume()
2618 iputbyte(chip, port + ICH_REG_OFF_LVI, ichdev->lvi); in intel8x0_resume()
2619 iputbyte(chip, port + ICH_REG_OFF_CIV, ichdev->civ); in intel8x0_resume()
2620 iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI); in intel8x0_resume()
2640 if (chip->ac97_bus->clock != 48000) in intel8x0_measure_ac97_clock()
2642 if (chip->inside_vm && !ac97_clock) in intel8x0_measure_ac97_clock()
2646 subs = chip->pcm[0]->streams[0].substream; in intel8x0_measure_ac97_clock()
2647 if (! subs || subs->dma_buffer.bytes < INTEL8X0_TESTBUF_SIZE) { in intel8x0_measure_ac97_clock()
2648 dev_warn(chip->card->dev, in intel8x0_measure_ac97_clock()
2649 "no playback buffer allocated - aborting measure ac97 clock\n"); in intel8x0_measure_ac97_clock()
2652 ichdev = &chip->ichd[ICHD_PCMOUT]; in intel8x0_measure_ac97_clock()
2653 ichdev->physbuf = subs->dma_buffer.addr; in intel8x0_measure_ac97_clock()
2654 ichdev->size = ichdev->fragsize = INTEL8X0_TESTBUF_SIZE; in intel8x0_measure_ac97_clock()
2655 ichdev->substream = NULL; /* don't process interrupts */ in intel8x0_measure_ac97_clock()
2658 if (snd_ac97_set_rate(chip->ac97[0], AC97_PCM_FRONT_DAC_RATE, 48000) < 0) { in intel8x0_measure_ac97_clock()
2659 dev_err(chip->card->dev, "cannot set ac97 rate: clock = %d\n", in intel8x0_measure_ac97_clock()
2660 chip->ac97_bus->clock); in intel8x0_measure_ac97_clock()
2664 port = ichdev->reg_offset; in intel8x0_measure_ac97_clock()
2665 spin_lock_irq(&chip->reg_lock); in intel8x0_measure_ac97_clock()
2666 chip->in_measurement = 1; in intel8x0_measure_ac97_clock()
2668 if (chip->device_type != DEVICE_ALI) in intel8x0_measure_ac97_clock()
2672 iputdword(chip, ICHREG(ALI_DMACR), 1 << ichdev->ali_slot); in intel8x0_measure_ac97_clock()
2675 spin_unlock_irq(&chip->reg_lock); in intel8x0_measure_ac97_clock()
2677 spin_lock_irq(&chip->reg_lock); in intel8x0_measure_ac97_clock()
2680 civ = igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV); in intel8x0_measure_ac97_clock()
2681 pos1 = igetword(chip, ichdev->reg_offset + ichdev->roff_picb); in intel8x0_measure_ac97_clock()
2686 if (civ == igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV) && in intel8x0_measure_ac97_clock()
2687 pos1 == igetword(chip, ichdev->reg_offset + ichdev->roff_picb)) in intel8x0_measure_ac97_clock()
2689 } while (timeout--); in intel8x0_measure_ac97_clock()
2693 pos = ichdev->fragsize1; in intel8x0_measure_ac97_clock()
2694 pos -= pos1 << ichdev->pos_shift; in intel8x0_measure_ac97_clock()
2695 pos += ichdev->position; in intel8x0_measure_ac97_clock()
2697 chip->in_measurement = 0; in intel8x0_measure_ac97_clock()
2700 if (chip->device_type == DEVICE_ALI) { in intel8x0_measure_ac97_clock()
2701 iputdword(chip, ICHREG(ALI_DMACR), 1 << (ichdev->ali_slot + 16)); in intel8x0_measure_ac97_clock()
2707 while (!(igetbyte(chip, port + ichdev->roff_sr) & ICH_DCH)) in intel8x0_measure_ac97_clock()
2711 spin_unlock_irq(&chip->reg_lock); in intel8x0_measure_ac97_clock()
2714 dev_err(chip->card->dev, in intel8x0_measure_ac97_clock()
2715 "measure - unreliable DMA position..\n"); in intel8x0_measure_ac97_clock()
2727 dev_info(chip->card->dev, in intel8x0_measure_ac97_clock()
2730 dev_err(chip->card->dev, "?? calculation error..\n"); in intel8x0_measure_ac97_clock()
2737 dev_info(chip->card->dev, "measured clock %ld rejected\n", pos); in intel8x0_measure_ac97_clock()
2740 /* first exception - 41000Hz reference clock */ in intel8x0_measure_ac97_clock()
2741 chip->ac97_bus->clock = 41000; in intel8x0_measure_ac97_clock()
2743 /* second exception - 44100HZ reference clock */ in intel8x0_measure_ac97_clock()
2744 chip->ac97_bus->clock = 44100; in intel8x0_measure_ac97_clock()
2747 chip->ac97_bus->clock = (chip->ac97_bus->clock * 48000) / pos; in intel8x0_measure_ac97_clock()
2749 dev_info(chip->card->dev, "clocking to %d\n", chip->ac97_bus->clock); in intel8x0_measure_ac97_clock()
2750 snd_ac97_update_power(chip->ac97[0], AC97_PCM_FRONT_DAC_RATE, 0); in intel8x0_measure_ac97_clock()
2765 struct pci_dev *pci = chip->pci; in intel8x0_in_clock_list()
2771 dev_info(chip->card->dev, "allow list rate for %04x:%04x is %i\n", in intel8x0_in_clock_list()
2772 pci->subsystem_vendor, pci->subsystem_device, wl->value); in intel8x0_in_clock_list()
2773 chip->ac97_bus->clock = wl->value; in intel8x0_in_clock_list()
2780 struct intel8x0 *chip = entry->private_data; in snd_intel8x0_proc_read()
2784 if (chip->device_type == DEVICE_ALI) in snd_intel8x0_proc_read()
2789 if (chip->device_type == DEVICE_INTEL_ICH4) in snd_intel8x0_proc_read()
2792 if (tmp & chip->codec_isr_bits) { in snd_intel8x0_proc_read()
2797 for (i = 0; i < chip->max_codecs; i++) in snd_intel8x0_proc_read()
2798 if (tmp & chip->codec_bit[i]) in snd_intel8x0_proc_read()
2803 if (chip->device_type == DEVICE_INTEL_ICH4 || in snd_intel8x0_proc_read()
2804 chip->device_type == DEVICE_SIS) in snd_intel8x0_proc_read()
2806 chip->ac97_sdin[0], in snd_intel8x0_proc_read()
2807 chip->ac97_sdin[1], in snd_intel8x0_proc_read()
2808 chip->ac97_sdin[2]); in snd_intel8x0_proc_read()
2813 snd_card_ro_proc_new(chip->card, "intel8x0", chip, in snd_intel8x0_proc_init()
2842 if (pci->subsystem_vendor == PCI_SUBVENDOR_ID_REDHAT_QUMRANET && in snd_intel8x0_inside_vm()
2843 pci->subsystem_device == PCI_SUBDEVICE_ID_QEMU) { in snd_intel8x0_inside_vm()
2847 } else if (pci->subsystem_vendor == 0x1ab8) { in snd_intel8x0_inside_vm()
2855 dev_info(&pci->dev, "%s optimization\n", msg); in snd_intel8x0_inside_vm()
2864 struct intel8x0 *chip = card->private_data; in snd_intel8x0_init()
2905 spin_lock_init(&chip->reg_lock); in snd_intel8x0_init()
2906 chip->device_type = device_type; in snd_intel8x0_init()
2907 chip->card = card; in snd_intel8x0_init()
2908 chip->pci = pci; in snd_intel8x0_init()
2909 chip->irq = -1; in snd_intel8x0_init()
2912 chip->buggy_irq = buggy_irq; in snd_intel8x0_init()
2913 chip->buggy_semaphore = buggy_semaphore; in snd_intel8x0_init()
2915 chip->xbox = 1; in snd_intel8x0_init()
2917 chip->inside_vm = snd_intel8x0_inside_vm(pci); in snd_intel8x0_init()
2922 * is to set the pages as non-cached. For details, see the errata in in snd_intel8x0_init()
2925 if (pci->vendor == PCI_VENDOR_ID_INTEL && in snd_intel8x0_init()
2926 pci->device == PCI_DEVICE_ID_INTEL_440MX) in snd_intel8x0_init()
2927 chip->fix_nocache = 1; /* enable workaround */ in snd_intel8x0_init()
2929 err = pci_request_regions(pci, card->shortname); in snd_intel8x0_init()
2935 chip->bmaddr = pcim_iomap(pci, 0, 0); in snd_intel8x0_init()
2938 chip->addr = pcim_iomap(pci, 2, 0); in snd_intel8x0_init()
2940 chip->addr = pcim_iomap(pci, 0, 0); in snd_intel8x0_init()
2942 chip->bmaddr = pcim_iomap(pci, 3, 0); in snd_intel8x0_init()
2944 chip->bmaddr = pcim_iomap(pci, 1, 0); in snd_intel8x0_init()
2947 chip->bdbars_count = bdbars[device_type]; in snd_intel8x0_init()
2961 for (i = 0; i < chip->bdbars_count; i++) { in snd_intel8x0_init()
2962 ichdev = &chip->ichd[i]; in snd_intel8x0_init()
2963 ichdev->ichd = i; in snd_intel8x0_init()
2964 ichdev->reg_offset = tbl[i].offset; in snd_intel8x0_init()
2965 ichdev->int_sta_mask = tbl[i].int_sta_mask; in snd_intel8x0_init()
2968 ichdev->roff_sr = ICH_REG_OFF_PICB; in snd_intel8x0_init()
2969 ichdev->roff_picb = ICH_REG_OFF_SR; in snd_intel8x0_init()
2971 ichdev->roff_sr = ICH_REG_OFF_SR; in snd_intel8x0_init()
2972 ichdev->roff_picb = ICH_REG_OFF_PICB; in snd_intel8x0_init()
2975 ichdev->ali_slot = (ichdev->reg_offset - 0x40) / 0x10; in snd_intel8x0_init()
2977 ichdev->pos_shift = (device_type == DEVICE_SIS) ? 0 : 1; in snd_intel8x0_init()
2982 chip->bdbars = snd_devm_alloc_pages(&pci->dev, intel8x0_dma_type(chip), in snd_intel8x0_init()
2983 chip->bdbars_count * sizeof(u32) * in snd_intel8x0_init()
2985 if (!chip->bdbars) in snd_intel8x0_init()
2986 return -ENOMEM; in snd_intel8x0_init()
2991 for (i = 0; i < chip->bdbars_count; i++) { in snd_intel8x0_init()
2992 ichdev = &chip->ichd[i]; in snd_intel8x0_init()
2993 ichdev->bdbar = ((__le32 *)chip->bdbars->area) + in snd_intel8x0_init()
2995 ichdev->bdbar_addr = chip->bdbars->addr + in snd_intel8x0_init()
2997 int_sta_masks |= ichdev->int_sta_mask; in snd_intel8x0_init()
2999 chip->int_sta_reg = device_type == DEVICE_ALI ? in snd_intel8x0_init()
3001 chip->int_sta_mask = int_sta_masks; in snd_intel8x0_init()
3005 switch(chip->device_type) { in snd_intel8x0_init()
3008 chip->max_codecs = 3; in snd_intel8x0_init()
3009 chip->codec_bit = ich_codec_bits; in snd_intel8x0_init()
3010 chip->codec_ready_bits = ICH_PRI | ICH_SRI | ICH_TRI; in snd_intel8x0_init()
3014 chip->max_codecs = 3; in snd_intel8x0_init()
3015 chip->codec_bit = sis_codec_bits; in snd_intel8x0_init()
3016 chip->codec_ready_bits = ICH_PRI | ICH_SRI | ICH_SIS_TRI; in snd_intel8x0_init()
3020 chip->max_codecs = 2; in snd_intel8x0_init()
3021 chip->codec_bit = ich_codec_bits; in snd_intel8x0_init()
3022 chip->codec_ready_bits = ICH_PRI | ICH_SRI; in snd_intel8x0_init()
3025 for (i = 0; i < chip->max_codecs; i++) in snd_intel8x0_init()
3026 chip->codec_isr_bits |= chip->codec_bit[i]; in snd_intel8x0_init()
3033 /* NOTE: we don't use devm version here since it's released / in snd_intel8x0_init()
3034 * re-acquired in PM callbacks. in snd_intel8x0_init()
3037 if (request_irq(pci->irq, snd_intel8x0_interrupt, in snd_intel8x0_init()
3039 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); in snd_intel8x0_init()
3040 return -EBUSY; in snd_intel8x0_init()
3042 chip->irq = pci->irq; in snd_intel8x0_init()
3043 card->sync_irq = chip->irq; in snd_intel8x0_init()
3045 card->private_free = snd_intel8x0_free; in snd_intel8x0_init()
3054 { PCI_DEVICE_ID_INTEL_82801AA_5, "Intel 82801AA-ICH" },
3055 { PCI_DEVICE_ID_INTEL_82801AB_5, "Intel 82901AB-ICH0" },
3056 { PCI_DEVICE_ID_INTEL_82801BA_4, "Intel 82801BA-ICH2" },
3058 { PCI_DEVICE_ID_INTEL_82801CA_5, "Intel 82801CA-ICH3" },
3059 { PCI_DEVICE_ID_INTEL_82801DB_5, "Intel 82801DB-ICH4" },
3084 /* look up allow/deny list for SPDIF over ac-link */
3091 if (w->value) in check_default_spdif_aclink()
3092 dev_dbg(&pci->dev, in check_default_spdif_aclink()
3093 "Using SPDIF over AC-Link for %s\n", in check_default_spdif_aclink()
3096 dev_dbg(&pci->dev, in check_default_spdif_aclink()
3099 return w->value; in check_default_spdif_aclink()
3112 err = snd_devm_card_new(&pci->dev, index, id, THIS_MODULE, in __snd_intel8x0_probe()
3116 chip = card->private_data; in __snd_intel8x0_probe()
3121 strcpy(card->driver, "ICH"); in __snd_intel8x0_probe()
3123 switch (pci_id->driver_data) { in __snd_intel8x0_probe()
3125 strcpy(card->driver, "NFORCE"); in __snd_intel8x0_probe()
3128 strcpy(card->driver, "ICH4"); in __snd_intel8x0_probe()
3132 strcpy(card->shortname, "Intel ICH"); in __snd_intel8x0_probe()
3133 for (name = shortnames; name->id; name++) { in __snd_intel8x0_probe()
3134 if (pci->device == name->id) { in __snd_intel8x0_probe()
3135 strcpy(card->shortname, name->s); in __snd_intel8x0_probe()
3144 if (pci_id->driver_data == DEVICE_NFORCE) in __snd_intel8x0_probe()
3150 err = snd_intel8x0_init(card, pci, pci_id->driver_data); in __snd_intel8x0_probe()
3163 snprintf(card->longname, sizeof(card->longname), in __snd_intel8x0_probe()
3164 "%s with %s at irq %i", card->shortname, in __snd_intel8x0_probe()
3165 snd_ac97_get_short_name(chip->ac97[0]), chip->irq); in __snd_intel8x0_probe()
3187 return snd_card_free_on_error(&pci->dev, __snd_intel8x0_probe(pci, pci_id)); in snd_intel8x0_probe()