Lines Matching +full:adc +full:- +full:joystick
1 // SPDX-License-Identifier: GPL-2.0-or-later
30 MODULE_SUPPORTED_DEVICE("{{Intel,82801AA-ICH},"
31 "{Intel,82901AB-ICH0},"
32 "{Intel,82801BA-ICH2},"
33 "{Intel,82801CA-ICH3},"
34 "{Intel,82801DB-ICH4},"
54 static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
59 static int buggy_irq = -1; /* auto-check */
61 static int spdif_aclink = -1;
62 static int inside_vm = -1;
69 MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (0 = allowlist + auto-detect, 1 = force autodetect)…
79 MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link.");
86 static int joystick; variable
87 module_param(joystick, int, 0444);
98 ICH_REG_##name##_BDBAR = base + 0x0, /* dword - buffer descriptor list base address */ \
99 ICH_REG_##name##_CIV = base + 0x04, /* byte - current index value */ \
100 ICH_REG_##name##_LVI = base + 0x05, /* byte - last valid index */ \
101 ICH_REG_##name##_SR = base + 0x06, /* byte - status register */ \
102 ICH_REG_##name##_PICB = base + 0x08, /* word - position in current buffer */ \
103 ICH_REG_##name##_PIV = base + 0x0a, /* byte - prefetched index value */ \
104 ICH_REG_##name##_CR = base + 0x0b, /* byte - control register */ \
142 #define ICH_REG_GLOB_CNT 0x2c /* dword - global control */
144 #define ICH_PCM_SPDIF_NONE 0x00000000 /* reserved - undefined */
148 #define ICH_PCM_20BIT 0x00400000 /* 20-bit samples (ICH4) */
165 #define ICH_REG_GLOB_STA 0x30 /* dword - global status */
170 #define ICH_P2INT 0x02000000 /* ICH4: PCM2-In interrupt */
171 #define ICH_M2INT 0x01000000 /* ICH4: Mic2-In interrupt */
173 #define ICH_SAMPLE_16_20 0x00400000 /* ICH4: 16- and 20-bit samples */
174 #define ICH_MULTICHAN_CAP 0x00300000 /* ICH4: multi-channel capability bits (RO) */
194 #define ICH_REG_ACC_SEMA 0x34 /* byte - codec write semaphore */
294 #define ICH_ALI_IF_SPDF_SRC (3<<12) /* 00 = PCM, 01 = AC97-in, 10 = spdif-in, 11 = i2s */
295 #define ICH_ALI_IF_AC97_OUT (3<<8) /* 00 = PCM, 10 = spdif-in, 11 = i2s */
329 #define get_ichdev(substream) (substream->runtime->private_data)
389 int spdif_idx; /* SPDIF BAR index; *_SPBAR or -1 if use PCMOUT */
438 * Lowlevel I/O - busmaster
443 return ioread8(chip->bmaddr + offset); in igetbyte()
448 return ioread16(chip->bmaddr + offset); in igetword()
453 return ioread32(chip->bmaddr + offset); in igetdword()
458 iowrite8(val, chip->bmaddr + offset); in iputbyte()
463 iowrite16(val, chip->bmaddr + offset); in iputword()
468 iowrite32(val, chip->bmaddr + offset); in iputdword()
472 * Lowlevel I/O - AC'97 registers
477 return ioread16(chip->addr + offset); in iagetword()
482 iowrite16(val, chip->addr + offset); in iaputword()
498 return -EIO; in snd_intel8x0_codec_semaphore()
499 if (chip->in_sdin_init) { in snd_intel8x0_codec_semaphore()
502 codec = chip->codec_isr_bits; in snd_intel8x0_codec_semaphore()
504 codec = chip->codec_bit[chip->ac97_sdin[codec]]; in snd_intel8x0_codec_semaphore()
509 return -EIO; in snd_intel8x0_codec_semaphore()
511 if (chip->buggy_semaphore) in snd_intel8x0_codec_semaphore()
520 } while (time--); in snd_intel8x0_codec_semaphore()
525 dev_err(chip->card->dev, in snd_intel8x0_codec_semaphore()
530 return -EBUSY; in snd_intel8x0_codec_semaphore()
537 struct intel8x0 *chip = ac97->private_data; in snd_intel8x0_codec_write()
539 if (snd_intel8x0_codec_semaphore(chip, ac97->num) < 0) { in snd_intel8x0_codec_write()
540 if (! chip->in_ac97_init) in snd_intel8x0_codec_write()
541 dev_err(chip->card->dev, in snd_intel8x0_codec_write()
543 ac97->num, reg); in snd_intel8x0_codec_write()
545 iaputword(chip, reg + ac97->num * 0x80, val); in snd_intel8x0_codec_write()
551 struct intel8x0 *chip = ac97->private_data; in snd_intel8x0_codec_read()
555 if (snd_intel8x0_codec_semaphore(chip, ac97->num) < 0) { in snd_intel8x0_codec_read()
556 if (! chip->in_ac97_init) in snd_intel8x0_codec_read()
557 dev_err(chip->card->dev, in snd_intel8x0_codec_read()
559 ac97->num, reg); in snd_intel8x0_codec_read()
562 res = iagetword(chip, reg + ac97->num * 0x80); in snd_intel8x0_codec_read()
566 ~(chip->codec_ready_bits | ICH_GSCI)); in snd_intel8x0_codec_read()
567 if (! chip->in_ac97_init) in snd_intel8x0_codec_read()
568 dev_err(chip->card->dev, in snd_intel8x0_codec_read()
570 ac97->num, reg); in snd_intel8x0_codec_read()
587 ~(chip->codec_ready_bits | ICH_GSCI)); in snd_intel8x0_codec_read_test()
603 if (! chip->in_ac97_init) in snd_intel8x0_ali_codec_ready()
604 dev_warn(chip->card->dev, "AC97 codec ready timeout.\n"); in snd_intel8x0_ali_codec_ready()
605 return -EBUSY; in snd_intel8x0_ali_codec_ready()
611 if (chip->buggy_semaphore) in snd_intel8x0_ali_codec_semaphore()
613 while (--time && (igetdword(chip, ICHREG(ALI_CAS)) & ALI_CAS_SEM_BUSY)) in snd_intel8x0_ali_codec_semaphore()
615 if (! time && ! chip->in_ac97_init) in snd_intel8x0_ali_codec_semaphore()
616 dev_warn(chip->card->dev, "ali_codec_semaphore timeout\n"); in snd_intel8x0_ali_codec_semaphore()
622 struct intel8x0 *chip = ac97->private_data; in snd_intel8x0_ali_codec_read()
628 if (ac97->num) in snd_intel8x0_ali_codec_read()
641 struct intel8x0 *chip = ac97->private_data; in snd_intel8x0_ali_codec_write()
646 if (ac97->num) in snd_intel8x0_ali_codec_write()
659 __le32 *bdbar = ichdev->bdbar; in snd_intel8x0_setup_periods()
660 unsigned long port = ichdev->reg_offset; in snd_intel8x0_setup_periods()
662 iputdword(chip, port + ICH_REG_OFF_BDBAR, ichdev->bdbar_addr); in snd_intel8x0_setup_periods()
663 if (ichdev->size == ichdev->fragsize) { in snd_intel8x0_setup_periods()
664 ichdev->ack_reload = ichdev->ack = 2; in snd_intel8x0_setup_periods()
665 ichdev->fragsize1 = ichdev->fragsize >> 1; in snd_intel8x0_setup_periods()
667 bdbar[idx + 0] = cpu_to_le32(ichdev->physbuf); in snd_intel8x0_setup_periods()
669 ichdev->fragsize1 >> ichdev->pos_shift); in snd_intel8x0_setup_periods()
670 bdbar[idx + 2] = cpu_to_le32(ichdev->physbuf + (ichdev->size >> 1)); in snd_intel8x0_setup_periods()
672 ichdev->fragsize1 >> ichdev->pos_shift); in snd_intel8x0_setup_periods()
674 ichdev->frags = 2; in snd_intel8x0_setup_periods()
676 ichdev->ack_reload = ichdev->ack = 1; in snd_intel8x0_setup_periods()
677 ichdev->fragsize1 = ichdev->fragsize; in snd_intel8x0_setup_periods()
679 bdbar[idx + 0] = cpu_to_le32(ichdev->physbuf + in snd_intel8x0_setup_periods()
680 (((idx >> 1) * ichdev->fragsize) % in snd_intel8x0_setup_periods()
681 ichdev->size)); in snd_intel8x0_setup_periods()
683 ichdev->fragsize >> ichdev->pos_shift); in snd_intel8x0_setup_periods()
685 dev_dbg(chip->card->dev, "bdbar[%i] = 0x%x [0x%x]\n", in snd_intel8x0_setup_periods()
689 ichdev->frags = ichdev->size / ichdev->fragsize; in snd_intel8x0_setup_periods()
691 iputbyte(chip, port + ICH_REG_OFF_LVI, ichdev->lvi = ICH_REG_LVI_MASK); in snd_intel8x0_setup_periods()
692 ichdev->civ = 0; in snd_intel8x0_setup_periods()
694 ichdev->lvi_frag = ICH_REG_LVI_MASK % ichdev->frags; in snd_intel8x0_setup_periods()
695 ichdev->position = 0; in snd_intel8x0_setup_periods()
697 dev_dbg(chip->card->dev, in snd_intel8x0_setup_periods()
699 ichdev->lvi_frag, ichdev->frags, ichdev->fragsize, in snd_intel8x0_setup_periods()
700 ichdev->fragsize1); in snd_intel8x0_setup_periods()
703 iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI); in snd_intel8x0_setup_periods()
712 unsigned long port = ichdev->reg_offset; in snd_intel8x0_update()
717 spin_lock_irqsave(&chip->reg_lock, flags); in snd_intel8x0_update()
718 status = igetbyte(chip, port + ichdev->roff_sr); in snd_intel8x0_update()
722 } else if (civ == ichdev->civ) { in snd_intel8x0_update()
725 ichdev->civ++; in snd_intel8x0_update()
726 ichdev->civ &= ICH_REG_LVI_MASK; in snd_intel8x0_update()
728 step = civ - ichdev->civ; in snd_intel8x0_update()
732 // snd_printd("step = %d, %d -> %d\n", step, ichdev->civ, civ); in snd_intel8x0_update()
733 ichdev->civ = civ; in snd_intel8x0_update()
736 ichdev->position += step * ichdev->fragsize1; in snd_intel8x0_update()
737 if (! chip->in_measurement) in snd_intel8x0_update()
738 ichdev->position %= ichdev->size; in snd_intel8x0_update()
739 ichdev->lvi += step; in snd_intel8x0_update()
740 ichdev->lvi &= ICH_REG_LVI_MASK; in snd_intel8x0_update()
741 iputbyte(chip, port + ICH_REG_OFF_LVI, ichdev->lvi); in snd_intel8x0_update()
743 ichdev->lvi_frag++; in snd_intel8x0_update()
744 ichdev->lvi_frag %= ichdev->frags; in snd_intel8x0_update()
745 …ichdev->bdbar[ichdev->lvi * 2] = cpu_to_le32(ichdev->physbuf + ichdev->lvi_frag * ichdev->fragsize… in snd_intel8x0_update()
747 dev_dbg(chip->card->dev, in snd_intel8x0_update()
749 ichdev->lvi * 2, ichdev->bdbar[ichdev->lvi * 2], in snd_intel8x0_update()
750 ichdev->bdbar[ichdev->lvi * 2 + 1], inb(ICH_REG_OFF_PIV + port), in snd_intel8x0_update()
753 if (--ichdev->ack == 0) { in snd_intel8x0_update()
754 ichdev->ack = ichdev->ack_reload; in snd_intel8x0_update()
758 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_intel8x0_update()
759 if (ack && ichdev->substream) { in snd_intel8x0_update()
760 snd_pcm_period_elapsed(ichdev->substream); in snd_intel8x0_update()
762 iputbyte(chip, port + ichdev->roff_sr, in snd_intel8x0_update()
773 status = igetdword(chip, chip->int_sta_reg); in snd_intel8x0_interrupt()
777 if ((status & chip->int_sta_mask) == 0) { in snd_intel8x0_interrupt()
780 iputdword(chip, chip->int_sta_reg, status); in snd_intel8x0_interrupt()
781 if (! chip->buggy_irq) in snd_intel8x0_interrupt()
787 for (i = 0; i < chip->bdbars_count; i++) { in snd_intel8x0_interrupt()
788 ichdev = &chip->ichd[i]; in snd_intel8x0_interrupt()
789 if (status & ichdev->int_sta_mask) in snd_intel8x0_interrupt()
794 iputdword(chip, chip->int_sta_reg, status & chip->int_sta_mask); in snd_intel8x0_interrupt()
808 unsigned long port = ichdev->reg_offset; in snd_intel8x0_pcm_trigger()
812 ichdev->suspended = 0; in snd_intel8x0_pcm_trigger()
817 ichdev->last_pos = ichdev->position; in snd_intel8x0_pcm_trigger()
820 ichdev->suspended = 1; in snd_intel8x0_pcm_trigger()
829 return -EINVAL; in snd_intel8x0_pcm_trigger()
834 while (!(igetbyte(chip, port + ichdev->roff_sr) & ICH_DCH)) ; in snd_intel8x0_pcm_trigger()
845 unsigned long port = ichdev->reg_offset; in snd_intel8x0_ali_trigger()
854 ichdev->suspended = 0; in snd_intel8x0_ali_trigger()
858 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_intel8x0_ali_trigger()
860 fifo = igetdword(chip, fiforeg[ichdev->ali_slot / 4]); in snd_intel8x0_ali_trigger()
861 fifo &= ~(0xff << (ichdev->ali_slot % 4)); in snd_intel8x0_ali_trigger()
862 fifo |= 0x83 << (ichdev->ali_slot % 4); in snd_intel8x0_ali_trigger()
863 iputdword(chip, fiforeg[ichdev->ali_slot / 4], fifo); in snd_intel8x0_ali_trigger()
866 val &= ~(1 << (ichdev->ali_slot + 16)); /* clear PAUSE flag */ in snd_intel8x0_ali_trigger()
868 iputdword(chip, ICHREG(ALI_DMACR), val | (1 << ichdev->ali_slot)); in snd_intel8x0_ali_trigger()
871 ichdev->suspended = 1; in snd_intel8x0_ali_trigger()
876 iputdword(chip, ICHREG(ALI_DMACR), val | (1 << (ichdev->ali_slot + 16))); in snd_intel8x0_ali_trigger()
888 igetdword(chip, ICHREG(ALI_INTERRUPTSR)) & ichdev->int_sta_mask); in snd_intel8x0_ali_trigger()
891 return -EINVAL; in snd_intel8x0_ali_trigger()
904 if (ichdev->pcm_open_flag) { in snd_intel8x0_hw_params()
905 snd_ac97_pcm_close(ichdev->pcm); in snd_intel8x0_hw_params()
906 ichdev->pcm_open_flag = 0; in snd_intel8x0_hw_params()
908 err = snd_ac97_pcm_open(ichdev->pcm, params_rate(hw_params), in snd_intel8x0_hw_params()
910 ichdev->pcm->r[dbl].slots); in snd_intel8x0_hw_params()
912 ichdev->pcm_open_flag = 1; in snd_intel8x0_hw_params()
914 if (ichdev->ichd == ICHD_PCMOUT && chip->spdif_idx < 0) in snd_intel8x0_hw_params()
915 snd_ac97_set_rate(ichdev->pcm->r[0].codec[0], AC97_SPDIF, in snd_intel8x0_hw_params()
925 if (ichdev->pcm_open_flag) { in snd_intel8x0_hw_free()
926 snd_ac97_pcm_close(ichdev->pcm); in snd_intel8x0_hw_free()
927 ichdev->pcm_open_flag = 0; in snd_intel8x0_hw_free()
936 int dbl = runtime->rate > 48000; in snd_intel8x0_setup_pcm_out()
938 spin_lock_irq(&chip->reg_lock); in snd_intel8x0_setup_pcm_out()
939 switch (chip->device_type) { 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()
952 if (runtime->channels == 4 || dbl) in snd_intel8x0_setup_pcm_out()
954 else if (runtime->channels == 6) in snd_intel8x0_setup_pcm_out()
961 if (runtime->channels == 4 || dbl) in snd_intel8x0_setup_pcm_out()
963 else if (runtime->channels == 6) in snd_intel8x0_setup_pcm_out()
965 else if (runtime->channels == 8) in snd_intel8x0_setup_pcm_out()
967 if (chip->device_type == DEVICE_NFORCE) { in snd_intel8x0_setup_pcm_out()
973 spin_unlock_irq(&chip->reg_lock); in snd_intel8x0_setup_pcm_out()
975 spin_lock_irq(&chip->reg_lock); in snd_intel8x0_setup_pcm_out()
977 } else if (chip->device_type == DEVICE_INTEL_ICH4) { in snd_intel8x0_setup_pcm_out()
978 if (runtime->sample_bits > 16) in snd_intel8x0_setup_pcm_out()
984 spin_unlock_irq(&chip->reg_lock); in snd_intel8x0_setup_pcm_out()
990 struct snd_pcm_runtime *runtime = substream->runtime; in snd_intel8x0_pcm_prepare()
993 ichdev->physbuf = runtime->dma_addr; in snd_intel8x0_pcm_prepare()
994 ichdev->size = snd_pcm_lib_buffer_bytes(substream); in snd_intel8x0_pcm_prepare()
995 ichdev->fragsize = snd_pcm_lib_period_bytes(substream); in snd_intel8x0_pcm_prepare()
996 if (ichdev->ichd == ICHD_PCMOUT) { in snd_intel8x0_pcm_prepare()
998 if (chip->device_type == DEVICE_INTEL_ICH4) in snd_intel8x0_pcm_prepare()
999 ichdev->pos_shift = (runtime->sample_bits > 16) ? 2 : 1; in snd_intel8x0_pcm_prepare()
1013 spin_lock(&chip->reg_lock); in snd_intel8x0_pcm_pointer()
1015 civ = igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV); in snd_intel8x0_pcm_pointer()
1016 ptr1 = igetword(chip, ichdev->reg_offset + ichdev->roff_picb); in snd_intel8x0_pcm_pointer()
1017 position = ichdev->position; in snd_intel8x0_pcm_pointer()
1022 if (civ != igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV)) in snd_intel8x0_pcm_pointer()
1031 if (chip->inside_vm) in snd_intel8x0_pcm_pointer()
1033 if (ptr1 == igetword(chip, ichdev->reg_offset + ichdev->roff_picb)) in snd_intel8x0_pcm_pointer()
1035 } while (timeout--); in snd_intel8x0_pcm_pointer()
1036 ptr = ichdev->last_pos; in snd_intel8x0_pcm_pointer()
1038 ptr1 <<= ichdev->pos_shift; in snd_intel8x0_pcm_pointer()
1039 ptr = ichdev->fragsize1 - ptr1; in snd_intel8x0_pcm_pointer()
1041 if (ptr < ichdev->last_pos) { in snd_intel8x0_pcm_pointer()
1043 pos_base = position / ichdev->fragsize1; in snd_intel8x0_pcm_pointer()
1044 last_base = ichdev->last_pos / ichdev->fragsize1; in snd_intel8x0_pcm_pointer()
1049 ptr = ichdev->last_pos; in snd_intel8x0_pcm_pointer()
1052 ichdev->last_pos = ptr; in snd_intel8x0_pcm_pointer()
1053 spin_unlock(&chip->reg_lock); in snd_intel8x0_pcm_pointer()
1054 if (ptr >= ichdev->size) in snd_intel8x0_pcm_pointer()
1056 return bytes_to_frames(substream->runtime, ptr); in snd_intel8x0_pcm_pointer()
1113 struct snd_pcm_runtime *runtime = substream->runtime; in snd_intel8x0_pcm_open()
1116 ichdev->substream = substream; in snd_intel8x0_pcm_open()
1117 runtime->hw = snd_intel8x0_stream; in snd_intel8x0_pcm_open()
1118 runtime->hw.rates = ichdev->pcm->rates; in snd_intel8x0_pcm_open()
1120 if (chip->device_type == DEVICE_SIS) { in snd_intel8x0_pcm_open()
1121 runtime->hw.buffer_bytes_max = 64*1024; in snd_intel8x0_pcm_open()
1122 runtime->hw.period_bytes_max = 64*1024; in snd_intel8x0_pcm_open()
1126 runtime->private_data = ichdev; in snd_intel8x0_pcm_open()
1133 struct snd_pcm_runtime *runtime = substream->runtime; in snd_intel8x0_playback_open()
1136 err = snd_intel8x0_pcm_open(substream, &chip->ichd[ICHD_PCMOUT]); in snd_intel8x0_playback_open()
1140 if (chip->multi8) { in snd_intel8x0_playback_open()
1141 runtime->hw.channels_max = 8; in snd_intel8x0_playback_open()
1145 } else if (chip->multi6) { in snd_intel8x0_playback_open()
1146 runtime->hw.channels_max = 6; in snd_intel8x0_playback_open()
1149 } else if (chip->multi4) { in snd_intel8x0_playback_open()
1150 runtime->hw.channels_max = 4; in snd_intel8x0_playback_open()
1154 if (chip->dra) { in snd_intel8x0_playback_open()
1157 if (chip->smp20bit) { in snd_intel8x0_playback_open()
1158 runtime->hw.formats |= SNDRV_PCM_FMTBIT_S32_LE; in snd_intel8x0_playback_open()
1168 chip->ichd[ICHD_PCMOUT].substream = NULL; in snd_intel8x0_playback_close()
1176 return snd_intel8x0_pcm_open(substream, &chip->ichd[ICHD_PCMIN]); in snd_intel8x0_capture_open()
1183 chip->ichd[ICHD_PCMIN].substream = NULL; in snd_intel8x0_capture_close()
1191 return snd_intel8x0_pcm_open(substream, &chip->ichd[ICHD_MIC]); in snd_intel8x0_mic_open()
1198 chip->ichd[ICHD_MIC].substream = NULL; in snd_intel8x0_mic_close()
1206 return snd_intel8x0_pcm_open(substream, &chip->ichd[ICHD_MIC2]); in snd_intel8x0_mic2_open()
1213 chip->ichd[ICHD_MIC2].substream = NULL; in snd_intel8x0_mic2_close()
1221 return snd_intel8x0_pcm_open(substream, &chip->ichd[ICHD_PCM2IN]); in snd_intel8x0_capture2_open()
1228 chip->ichd[ICHD_PCM2IN].substream = NULL; in snd_intel8x0_capture2_close()
1235 int idx = chip->device_type == DEVICE_NFORCE ? NVD_SPBAR : ICHD_SPBAR; in snd_intel8x0_spdif_open()
1237 return snd_intel8x0_pcm_open(substream, &chip->ichd[idx]); in snd_intel8x0_spdif_open()
1243 int idx = chip->device_type == DEVICE_NFORCE ? NVD_SPBAR : ICHD_SPBAR; in snd_intel8x0_spdif_close()
1245 chip->ichd[idx].substream = NULL; in snd_intel8x0_spdif_close()
1254 spin_lock_irq(&chip->reg_lock); in snd_intel8x0_ali_ac97spdifout_open()
1259 spin_unlock_irq(&chip->reg_lock); in snd_intel8x0_ali_ac97spdifout_open()
1261 return snd_intel8x0_pcm_open(substream, &chip->ichd[ALID_AC97SPDIFOUT]); in snd_intel8x0_ali_ac97spdifout_open()
1269 chip->ichd[ALID_AC97SPDIFOUT].substream = NULL; in snd_intel8x0_ali_ac97spdifout_close()
1270 spin_lock_irq(&chip->reg_lock); in snd_intel8x0_ali_ac97spdifout_close()
1274 spin_unlock_irq(&chip->reg_lock); in snd_intel8x0_ali_ac97spdifout_close()
1284 return snd_intel8x0_pcm_open(substream, &chip->ichd[ALID_SPDIFIN]);
1291 chip->ichd[ALID_SPDIFIN].substream = NULL;
1299 return snd_intel8x0_pcm_open(substream, &chip->ichd[ALID_SPDIFOUT]);
1306 chip->ichd[ALID_SPDIFOUT].substream = NULL;
1443 ((chip)->fix_nocache ? SNDRV_DMA_TYPE_DEV_UC : SNDRV_DMA_TYPE_DEV)
1452 if (rec->suffix) in snd_intel8x0_pcm1()
1453 sprintf(name, "Intel ICH - %s", rec->suffix); in snd_intel8x0_pcm1()
1456 err = snd_pcm_new(chip->card, name, device, in snd_intel8x0_pcm1()
1457 rec->playback_ops ? 1 : 0, in snd_intel8x0_pcm1()
1458 rec->capture_ops ? 1 : 0, &pcm); in snd_intel8x0_pcm1()
1462 if (rec->playback_ops) in snd_intel8x0_pcm1()
1463 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, rec->playback_ops); in snd_intel8x0_pcm1()
1464 if (rec->capture_ops) in snd_intel8x0_pcm1()
1465 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, rec->capture_ops); in snd_intel8x0_pcm1()
1467 pcm->private_data = chip; in snd_intel8x0_pcm1()
1468 pcm->info_flags = 0; in snd_intel8x0_pcm1()
1469 if (rec->suffix) in snd_intel8x0_pcm1()
1470 sprintf(pcm->name, "%s - %s", chip->card->shortname, rec->suffix); in snd_intel8x0_pcm1()
1472 strcpy(pcm->name, chip->card->shortname); in snd_intel8x0_pcm1()
1473 chip->pcm[device] = pcm; in snd_intel8x0_pcm1()
1476 &chip->pci->dev, in snd_intel8x0_pcm1()
1477 rec->prealloc_size, rec->prealloc_max_size); in snd_intel8x0_pcm1()
1479 if (rec->playback_ops && in snd_intel8x0_pcm1()
1480 rec->playback_ops->open == snd_intel8x0_playback_open) { in snd_intel8x0_pcm1()
1483 if (chip->multi8) in snd_intel8x0_pcm1()
1485 else if (chip->multi6) in snd_intel8x0_pcm1()
1487 else if (chip->multi4) in snd_intel8x0_pcm1()
1494 chmap->channel_mask = SND_PCM_CHMAP_MASK_2468; in snd_intel8x0_pcm1()
1495 chip->ac97[0]->chmaps[SNDRV_PCM_STREAM_PLAYBACK] = chmap; in snd_intel8x0_pcm1()
1509 .suffix = "MIC ADC",
1516 .suffix = "MIC2 ADC",
1546 .suffix = "MIC ADC",
1569 .suffix = "MIC ADC",
1598 switch (chip->device_type) { in snd_intel8x0_pcm()
1603 tblsize--; in snd_intel8x0_pcm()
1609 tblsize--; in snd_intel8x0_pcm()
1624 if (i > 0 && rec->ac97_idx) { in snd_intel8x0_pcm()
1626 if (! chip->ichd[rec->ac97_idx].pcm) in snd_intel8x0_pcm()
1635 chip->pcm_devs = device; in snd_intel8x0_pcm()
1646 struct intel8x0 *chip = bus->private_data; in snd_intel8x0_mixer_free_ac97_bus()
1647 chip->ac97_bus = NULL; in snd_intel8x0_mixer_free_ac97_bus()
1652 struct intel8x0 *chip = ac97->private_data; in snd_intel8x0_mixer_free_ac97()
1653 chip->ac97[ac97->num] = NULL; in snd_intel8x0_mixer_free_ac97()
1760 .name = "MS-9128",
1958 .name = "Sony VAIO VGN-T350P", /*AD1981B*/
1964 .name = "Sony VAIO VGN-B1VP", /*AD1981B*/
1976 .name = "Fujitsu-Siemens E4010",
1982 .name = "Fujitsu-Siemens T3010",
2006 .name = "Fujitsu-Siemens 4010",
2012 .name = "Fujitsu-Siemens Celsius H320",
2018 .name = "Fujitsu-Siemens Celsius", /* AD1981? */
2036 .name = "Panasonic CF-R4",
2042 .name = "Fujitsu-Siemens Scenic", /* AD1981? */
2072 .name = "Fujitsu-Siemens D1522", /* AD1981 */
2151 chip->spdif_idx = -1; /* use PCMOUT (or disabled) */ in snd_intel8x0_mixer()
2153 switch (chip->device_type) { in snd_intel8x0_mixer()
2155 chip->spdif_idx = NVD_SPBAR; in snd_intel8x0_mixer()
2158 chip->spdif_idx = ALID_AC97SPDIFOUT; in snd_intel8x0_mixer()
2161 chip->spdif_idx = ICHD_SPBAR; in snd_intel8x0_mixer()
2166 chip->in_ac97_init = 1; in snd_intel8x0_mixer()
2172 if (chip->xbox) in snd_intel8x0_mixer()
2174 if (chip->device_type != DEVICE_ALI) { in snd_intel8x0_mixer()
2177 chip->in_sdin_init = 1; in snd_intel8x0_mixer()
2179 for (i = 0; i < chip->max_codecs; i++) { in snd_intel8x0_mixer()
2180 if (! (glob_sta & chip->codec_bit[i])) in snd_intel8x0_mixer()
2182 if (chip->device_type == DEVICE_INTEL_ICH4) { in snd_intel8x0_mixer()
2184 chip->ac97_sdin[codecs] = in snd_intel8x0_mixer()
2186 if (snd_BUG_ON(chip->ac97_sdin[codecs] >= 3)) in snd_intel8x0_mixer()
2187 chip->ac97_sdin[codecs] = 0; in snd_intel8x0_mixer()
2189 chip->ac97_sdin[codecs] = i; in snd_intel8x0_mixer()
2192 chip->in_sdin_init = 0; in snd_intel8x0_mixer()
2209 if ((err = snd_ac97_bus(chip->card, 0, ops, chip, &pbus)) < 0) in snd_intel8x0_mixer()
2211 pbus->private_free = snd_intel8x0_mixer_free_ac97_bus; in snd_intel8x0_mixer()
2213 pbus->clock = ac97_clock; in snd_intel8x0_mixer()
2215 if (chip->device_type == DEVICE_ALI) in snd_intel8x0_mixer()
2216 pbus->no_vra = 1; in snd_intel8x0_mixer()
2218 pbus->dra = 1; in snd_intel8x0_mixer()
2219 chip->ac97_bus = pbus; in snd_intel8x0_mixer()
2220 chip->ncodecs = codecs; in snd_intel8x0_mixer()
2222 ac97.pci = chip->pci; in snd_intel8x0_mixer()
2225 if ((err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i])) < 0) { in snd_intel8x0_mixer()
2226 if (err != -EACCES) in snd_intel8x0_mixer()
2227 dev_err(chip->card->dev, in snd_intel8x0_mixer()
2234 snd_ac97_tune_hardware(chip->ac97[0], ac97_quirks, quirk_override); in snd_intel8x0_mixer()
2236 if (chip->device_type == DEVICE_INTEL_ICH4) in snd_intel8x0_mixer()
2237 pbus->isdin = 1; in snd_intel8x0_mixer()
2240 if (chip->device_type != DEVICE_INTEL_ICH4) in snd_intel8x0_mixer()
2241 i -= 2; /* do not allocate PCM2IN and MIC2 */ in snd_intel8x0_mixer()
2242 if (chip->spdif_idx < 0) in snd_intel8x0_mixer()
2243 i--; /* do not allocate S/PDIF */ in snd_intel8x0_mixer()
2247 chip->ichd[ICHD_PCMOUT].pcm = &pbus->pcms[0]; in snd_intel8x0_mixer()
2248 chip->ichd[ICHD_PCMIN].pcm = &pbus->pcms[1]; in snd_intel8x0_mixer()
2249 chip->ichd[ICHD_MIC].pcm = &pbus->pcms[2]; in snd_intel8x0_mixer()
2250 if (chip->spdif_idx >= 0) in snd_intel8x0_mixer()
2251 chip->ichd[chip->spdif_idx].pcm = &pbus->pcms[3]; in snd_intel8x0_mixer()
2252 if (chip->device_type == DEVICE_INTEL_ICH4) { in snd_intel8x0_mixer()
2253 chip->ichd[ICHD_PCM2IN].pcm = &pbus->pcms[4]; in snd_intel8x0_mixer()
2254 chip->ichd[ICHD_MIC2].pcm = &pbus->pcms[5]; in snd_intel8x0_mixer()
2257 if (chip->device_type == DEVICE_INTEL_ICH4) { in snd_intel8x0_mixer()
2258 struct ac97_pcm *pcm = chip->ichd[ICHD_PCM2IN].pcm; in snd_intel8x0_mixer()
2263 tmp |= chip->ac97_sdin[0] << ICH_DI1L_SHIFT; in snd_intel8x0_mixer()
2265 if (pcm->r[0].codec[i]) { in snd_intel8x0_mixer()
2266 tmp |= chip->ac97_sdin[pcm->r[0].codec[1]->num] << ICH_DI2L_SHIFT; in snd_intel8x0_mixer()
2275 if (pbus->pcms[0].r[0].slots & (1 << AC97_SLOT_PCM_SLEFT)) { in snd_intel8x0_mixer()
2276 chip->multi4 = 1; in snd_intel8x0_mixer()
2277 if (pbus->pcms[0].r[0].slots & (1 << AC97_SLOT_LFE)) { in snd_intel8x0_mixer()
2278 chip->multi6 = 1; in snd_intel8x0_mixer()
2279 if (chip->ac97[0]->flags & AC97_HAS_8CH) in snd_intel8x0_mixer()
2280 chip->multi8 = 1; in snd_intel8x0_mixer()
2283 if (pbus->pcms[0].r[1].rslots[0]) { in snd_intel8x0_mixer()
2284 chip->dra = 1; in snd_intel8x0_mixer()
2286 if (chip->device_type == DEVICE_INTEL_ICH4) { in snd_intel8x0_mixer()
2288 chip->smp20bit = 1; in snd_intel8x0_mixer()
2290 if (chip->device_type == DEVICE_NFORCE && !spdif_aclink) { in snd_intel8x0_mixer()
2292 chip->ichd[chip->spdif_idx].pcm->rates = SNDRV_PCM_RATE_48000; in snd_intel8x0_mixer()
2294 if (chip->device_type == DEVICE_INTEL_ICH4 && !spdif_aclink) { in snd_intel8x0_mixer()
2300 snd_ac97_update_bits(chip->ac97[0], AC97_EXTENDED_STATUS, 0x03 << 4, 0x03 << 4); in snd_intel8x0_mixer()
2302 chip->in_ac97_init = 0; in snd_intel8x0_mixer()
2306 /* clear the cold-reset bit for the next chance */ in snd_intel8x0_mixer()
2307 if (chip->device_type != DEVICE_ALI) in snd_intel8x0_mixer()
2341 if (snd_pci_quirk_lookup(chip->pci, ich_chip_reset_mode)) in snd_intel8x0_ich_chip_cold_reset()
2342 return -EIO; in snd_intel8x0_ich_chip_cold_reset()
2347 /* do cold reset - the full ac97 powerdown may leave the controller in snd_intel8x0_ich_chip_cold_reset()
2358 (!snd_pci_quirk_lookup(chip->pci, ich_chip_reset_mode))
2380 dev_err(chip->card->dev, "AC'97 warm reset still in progress? [0x%x]\n", in snd_intel8x0_ich_chip_reset()
2382 return -EIO; in snd_intel8x0_ich_chip_reset()
2395 if (chip->device_type == DEVICE_NFORCE) in snd_intel8x0_ich_chip_init()
2415 chip->codec_isr_bits; in snd_intel8x0_ich_chip_init()
2422 dev_err(chip->card->dev, in snd_intel8x0_ich_chip_init()
2425 return -EIO; in snd_intel8x0_ich_chip_init()
2430 while (status != chip->codec_isr_bits && in snd_intel8x0_ich_chip_init()
2434 chip->codec_isr_bits; in snd_intel8x0_ich_chip_init()
2441 for (i = 0; i < chip->ncodecs; i++) in snd_intel8x0_ich_chip_init()
2442 if (chip->ac97[i]) in snd_intel8x0_ich_chip_init()
2443 status |= chip->codec_bit[chip->ac97_sdin[i]]; in snd_intel8x0_ich_chip_init()
2448 chip->codec_isr_bits; in snd_intel8x0_ich_chip_init()
2455 if (chip->device_type == DEVICE_SIS) { in snd_intel8x0_ich_chip_init()
2459 if (chip->device_type == DEVICE_NFORCE && !spdif_aclink) { in snd_intel8x0_ich_chip_init()
2462 pci_read_config_dword(chip->pci, 0x4c, &val); in snd_intel8x0_ich_chip_init()
2464 pci_write_config_dword(chip->pci, 0x4c, val); in snd_intel8x0_ich_chip_init()
2487 dev_err(chip->card->dev, "AC'97 reset failed.\n"); in snd_intel8x0_ali_chip_init()
2489 return -EIO; in snd_intel8x0_ali_chip_init()
2509 if (chip->device_type != DEVICE_ALI) { in snd_intel8x0_chip_init()
2519 for (i = 0; i < chip->bdbars_count; i++) in snd_intel8x0_chip_init()
2520 iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, 0x00); in snd_intel8x0_chip_init()
2522 for (i = 0; i < chip->bdbars_count; i++) in snd_intel8x0_chip_init()
2523 iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, ICH_RESETREGS); in snd_intel8x0_chip_init()
2524 for (i = 0; i < chip->bdbars_count; i++) { in snd_intel8x0_chip_init()
2526 while (--timeout != 0) { in snd_intel8x0_chip_init()
2527 if ((igetbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset) & ICH_RESETREGS) == 0) in snd_intel8x0_chip_init()
2531 dev_err(chip->card->dev, "reset of registers failed?\n"); in snd_intel8x0_chip_init()
2534 for (i = 0; i < chip->bdbars_count; i++) in snd_intel8x0_chip_init()
2535 iputdword(chip, ICH_REG_OFF_BDBAR + chip->ichd[i].reg_offset, in snd_intel8x0_chip_init()
2536 chip->ichd[i].bdbar_addr); in snd_intel8x0_chip_init()
2544 if (chip->irq < 0) in snd_intel8x0_free()
2547 for (i = 0; i < chip->bdbars_count; i++) in snd_intel8x0_free()
2548 iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, 0x00); in snd_intel8x0_free()
2550 for (i = 0; i < chip->bdbars_count; i++) in snd_intel8x0_free()
2551 iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, ICH_RESETREGS); in snd_intel8x0_free()
2552 if (chip->device_type == DEVICE_NFORCE && !spdif_aclink) { in snd_intel8x0_free()
2555 pci_read_config_dword(chip->pci, 0x4c, &val); in snd_intel8x0_free()
2557 pci_write_config_dword(chip->pci, 0x4c, val); in snd_intel8x0_free()
2559 /* --- */ in snd_intel8x0_free()
2562 if (chip->irq >= 0) in snd_intel8x0_free()
2563 free_irq(chip->irq, chip); in snd_intel8x0_free()
2564 if (chip->bdbars.area) in snd_intel8x0_free()
2565 snd_dma_free_pages(&chip->bdbars); in snd_intel8x0_free()
2566 if (chip->addr) in snd_intel8x0_free()
2567 pci_iounmap(chip->pci, chip->addr); in snd_intel8x0_free()
2568 if (chip->bmaddr) in snd_intel8x0_free()
2569 pci_iounmap(chip->pci, chip->bmaddr); in snd_intel8x0_free()
2570 pci_release_regions(chip->pci); in snd_intel8x0_free()
2571 pci_disable_device(chip->pci); in snd_intel8x0_free()
2583 struct intel8x0 *chip = card->private_data; in intel8x0_suspend()
2587 for (i = 0; i < chip->ncodecs; i++) in intel8x0_suspend()
2588 snd_ac97_suspend(chip->ac97[i]); in intel8x0_suspend()
2589 if (chip->device_type == DEVICE_INTEL_ICH4) in intel8x0_suspend()
2590 chip->sdm_saved = igetbyte(chip, ICHREG(SDM)); in intel8x0_suspend()
2592 if (chip->irq >= 0) { in intel8x0_suspend()
2593 free_irq(chip->irq, chip); in intel8x0_suspend()
2594 chip->irq = -1; in intel8x0_suspend()
2595 card->sync_irq = -1; in intel8x0_suspend()
2604 struct intel8x0 *chip = card->private_data; in intel8x0_resume()
2608 if (request_irq(pci->irq, snd_intel8x0_interrupt, in intel8x0_resume()
2611 pci->irq); in intel8x0_resume()
2613 return -EIO; in intel8x0_resume()
2615 chip->irq = pci->irq; in intel8x0_resume()
2616 card->sync_irq = chip->irq; in intel8x0_resume()
2618 /* re-initialize mixer stuff */ in intel8x0_resume()
2619 if (chip->device_type == DEVICE_INTEL_ICH4 && !spdif_aclink) { in intel8x0_resume()
2621 iputbyte(chip, ICHREG(SDM), chip->sdm_saved); in intel8x0_resume()
2628 for (i = 0; i < chip->ncodecs; i++) in intel8x0_resume()
2629 snd_ac97_resume(chip->ac97[i]); in intel8x0_resume()
2632 for (i = 0; i < chip->bdbars_count; i++) { in intel8x0_resume()
2633 struct ichdev *ichdev = &chip->ichd[i]; in intel8x0_resume()
2634 unsigned long port = ichdev->reg_offset; in intel8x0_resume()
2635 if (! ichdev->substream || ! ichdev->suspended) in intel8x0_resume()
2637 if (ichdev->ichd == ICHD_PCMOUT) in intel8x0_resume()
2638 snd_intel8x0_setup_pcm_out(chip, ichdev->substream->runtime); in intel8x0_resume()
2639 iputdword(chip, port + ICH_REG_OFF_BDBAR, ichdev->bdbar_addr); in intel8x0_resume()
2640 iputbyte(chip, port + ICH_REG_OFF_LVI, ichdev->lvi); in intel8x0_resume()
2641 iputbyte(chip, port + ICH_REG_OFF_CIV, ichdev->civ); in intel8x0_resume()
2642 iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI); in intel8x0_resume()
2666 if (chip->ac97_bus->clock != 48000) in intel8x0_measure_ac97_clock()
2670 subs = chip->pcm[0]->streams[0].substream; in intel8x0_measure_ac97_clock()
2671 if (! subs || subs->dma_buffer.bytes < INTEL8X0_TESTBUF_SIZE) { in intel8x0_measure_ac97_clock()
2672 dev_warn(chip->card->dev, in intel8x0_measure_ac97_clock()
2673 "no playback buffer allocated - aborting measure ac97 clock\n"); in intel8x0_measure_ac97_clock()
2676 ichdev = &chip->ichd[ICHD_PCMOUT]; in intel8x0_measure_ac97_clock()
2677 ichdev->physbuf = subs->dma_buffer.addr; in intel8x0_measure_ac97_clock()
2678 ichdev->size = ichdev->fragsize = INTEL8X0_TESTBUF_SIZE; in intel8x0_measure_ac97_clock()
2679 ichdev->substream = NULL; /* don't process interrupts */ in intel8x0_measure_ac97_clock()
2682 if (snd_ac97_set_rate(chip->ac97[0], AC97_PCM_FRONT_DAC_RATE, 48000) < 0) { in intel8x0_measure_ac97_clock()
2683 dev_err(chip->card->dev, "cannot set ac97 rate: clock = %d\n", in intel8x0_measure_ac97_clock()
2684 chip->ac97_bus->clock); in intel8x0_measure_ac97_clock()
2688 port = ichdev->reg_offset; in intel8x0_measure_ac97_clock()
2689 spin_lock_irq(&chip->reg_lock); in intel8x0_measure_ac97_clock()
2690 chip->in_measurement = 1; in intel8x0_measure_ac97_clock()
2692 if (chip->device_type != DEVICE_ALI) in intel8x0_measure_ac97_clock()
2696 iputdword(chip, ICHREG(ALI_DMACR), 1 << ichdev->ali_slot); in intel8x0_measure_ac97_clock()
2699 spin_unlock_irq(&chip->reg_lock); in intel8x0_measure_ac97_clock()
2701 spin_lock_irq(&chip->reg_lock); in intel8x0_measure_ac97_clock()
2704 civ = igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV); in intel8x0_measure_ac97_clock()
2705 pos1 = igetword(chip, ichdev->reg_offset + ichdev->roff_picb); in intel8x0_measure_ac97_clock()
2710 if (civ == igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV) && in intel8x0_measure_ac97_clock()
2711 pos1 == igetword(chip, ichdev->reg_offset + ichdev->roff_picb)) in intel8x0_measure_ac97_clock()
2713 } while (timeout--); in intel8x0_measure_ac97_clock()
2717 pos = ichdev->fragsize1; in intel8x0_measure_ac97_clock()
2718 pos -= pos1 << ichdev->pos_shift; in intel8x0_measure_ac97_clock()
2719 pos += ichdev->position; in intel8x0_measure_ac97_clock()
2721 chip->in_measurement = 0; in intel8x0_measure_ac97_clock()
2724 if (chip->device_type == DEVICE_ALI) { in intel8x0_measure_ac97_clock()
2725 iputdword(chip, ICHREG(ALI_DMACR), 1 << (ichdev->ali_slot + 16)); in intel8x0_measure_ac97_clock()
2731 while (!(igetbyte(chip, port + ichdev->roff_sr) & ICH_DCH)) in intel8x0_measure_ac97_clock()
2735 spin_unlock_irq(&chip->reg_lock); in intel8x0_measure_ac97_clock()
2738 dev_err(chip->card->dev, in intel8x0_measure_ac97_clock()
2739 "measure - unreliable DMA position..\n"); in intel8x0_measure_ac97_clock()
2751 dev_info(chip->card->dev, in intel8x0_measure_ac97_clock()
2754 dev_err(chip->card->dev, "?? calculation error..\n"); in intel8x0_measure_ac97_clock()
2761 dev_info(chip->card->dev, "measured clock %ld rejected\n", pos); in intel8x0_measure_ac97_clock()
2764 /* first exception - 41000Hz reference clock */ in intel8x0_measure_ac97_clock()
2765 chip->ac97_bus->clock = 41000; in intel8x0_measure_ac97_clock()
2767 /* second exception - 44100HZ reference clock */ in intel8x0_measure_ac97_clock()
2768 chip->ac97_bus->clock = 44100; in intel8x0_measure_ac97_clock()
2771 chip->ac97_bus->clock = (chip->ac97_bus->clock * 48000) / pos; in intel8x0_measure_ac97_clock()
2773 dev_info(chip->card->dev, "clocking to %d\n", chip->ac97_bus->clock); in intel8x0_measure_ac97_clock()
2774 snd_ac97_update_power(chip->ac97[0], AC97_PCM_FRONT_DAC_RATE, 0); in intel8x0_measure_ac97_clock()
2789 struct pci_dev *pci = chip->pci; in intel8x0_in_clock_list()
2795 dev_info(chip->card->dev, "allow list rate for %04x:%04x is %i\n", in intel8x0_in_clock_list()
2796 pci->subsystem_vendor, pci->subsystem_device, wl->value); in intel8x0_in_clock_list()
2797 chip->ac97_bus->clock = wl->value; in intel8x0_in_clock_list()
2804 struct intel8x0 *chip = entry->private_data; in snd_intel8x0_proc_read()
2808 if (chip->device_type == DEVICE_ALI) in snd_intel8x0_proc_read()
2813 if (chip->device_type == DEVICE_INTEL_ICH4) in snd_intel8x0_proc_read()
2816 if (tmp & chip->codec_isr_bits) { in snd_intel8x0_proc_read()
2821 for (i = 0; i < chip->max_codecs; i++) in snd_intel8x0_proc_read()
2822 if (tmp & chip->codec_bit[i]) in snd_intel8x0_proc_read()
2827 if (chip->device_type == DEVICE_INTEL_ICH4 || in snd_intel8x0_proc_read()
2828 chip->device_type == DEVICE_SIS) in snd_intel8x0_proc_read()
2830 chip->ac97_sdin[0], in snd_intel8x0_proc_read()
2831 chip->ac97_sdin[1], in snd_intel8x0_proc_read()
2832 chip->ac97_sdin[2]); in snd_intel8x0_proc_read()
2837 snd_card_ro_proc_new(chip->card, "intel8x0", chip, in snd_intel8x0_proc_init()
2843 struct intel8x0 *chip = device->device_data; in snd_intel8x0_dev_free()
2872 if (pci->subsystem_vendor == PCI_SUBVENDOR_ID_REDHAT_QUMRANET && in snd_intel8x0_inside_vm()
2873 pci->subsystem_device == PCI_SUBDEVICE_ID_QEMU) { in snd_intel8x0_inside_vm()
2877 } else if (pci->subsystem_vendor == 0x1ab8) { in snd_intel8x0_inside_vm()
2885 dev_info(&pci->dev, "%s optimization\n", msg); in snd_intel8x0_inside_vm()
2943 return -ENOMEM; in snd_intel8x0_create()
2945 spin_lock_init(&chip->reg_lock); in snd_intel8x0_create()
2946 chip->device_type = device_type; in snd_intel8x0_create()
2947 chip->card = card; in snd_intel8x0_create()
2948 chip->pci = pci; in snd_intel8x0_create()
2949 chip->irq = -1; in snd_intel8x0_create()
2952 chip->buggy_irq = buggy_irq; in snd_intel8x0_create()
2953 chip->buggy_semaphore = buggy_semaphore; in snd_intel8x0_create()
2955 chip->xbox = 1; in snd_intel8x0_create()
2957 chip->inside_vm = snd_intel8x0_inside_vm(pci); in snd_intel8x0_create()
2962 * is to set the pages as non-cached. For details, see the errata in in snd_intel8x0_create()
2965 if (pci->vendor == PCI_VENDOR_ID_INTEL && in snd_intel8x0_create()
2966 pci->device == PCI_DEVICE_ID_INTEL_440MX) in snd_intel8x0_create()
2967 chip->fix_nocache = 1; /* enable workaround */ in snd_intel8x0_create()
2969 if ((err = pci_request_regions(pci, card->shortname)) < 0) { in snd_intel8x0_create()
2977 chip->bmaddr = pci_iomap(pci, 0, 0); in snd_intel8x0_create()
2982 chip->addr = pci_iomap(pci, 2, 0); in snd_intel8x0_create()
2984 chip->addr = pci_iomap(pci, 0, 0); in snd_intel8x0_create()
2985 if (!chip->addr) { in snd_intel8x0_create()
2986 dev_err(card->dev, "AC'97 space ioremap problem\n"); in snd_intel8x0_create()
2988 return -EIO; in snd_intel8x0_create()
2991 chip->bmaddr = pci_iomap(pci, 3, 0); in snd_intel8x0_create()
2993 chip->bmaddr = pci_iomap(pci, 1, 0); in snd_intel8x0_create()
2996 if (!chip->bmaddr) { in snd_intel8x0_create()
2997 dev_err(card->dev, "Controller space ioremap problem\n"); in snd_intel8x0_create()
2999 return -EIO; in snd_intel8x0_create()
3001 chip->bdbars_count = bdbars[device_type]; in snd_intel8x0_create()
3015 for (i = 0; i < chip->bdbars_count; i++) { in snd_intel8x0_create()
3016 ichdev = &chip->ichd[i]; in snd_intel8x0_create()
3017 ichdev->ichd = i; in snd_intel8x0_create()
3018 ichdev->reg_offset = tbl[i].offset; in snd_intel8x0_create()
3019 ichdev->int_sta_mask = tbl[i].int_sta_mask; in snd_intel8x0_create()
3022 ichdev->roff_sr = ICH_REG_OFF_PICB; in snd_intel8x0_create()
3023 ichdev->roff_picb = ICH_REG_OFF_SR; in snd_intel8x0_create()
3025 ichdev->roff_sr = ICH_REG_OFF_SR; in snd_intel8x0_create()
3026 ichdev->roff_picb = ICH_REG_OFF_PICB; in snd_intel8x0_create()
3029 ichdev->ali_slot = (ichdev->reg_offset - 0x40) / 0x10; in snd_intel8x0_create()
3031 ichdev->pos_shift = (device_type == DEVICE_SIS) ? 0 : 1; in snd_intel8x0_create()
3036 if (snd_dma_alloc_pages(intel8x0_dma_type(chip), &pci->dev, in snd_intel8x0_create()
3037 chip->bdbars_count * sizeof(u32) * ICH_MAX_FRAGS * 2, in snd_intel8x0_create()
3038 &chip->bdbars) < 0) { in snd_intel8x0_create()
3040 dev_err(card->dev, "cannot allocate buffer descriptors\n"); in snd_intel8x0_create()
3041 return -ENOMEM; in snd_intel8x0_create()
3046 for (i = 0; i < chip->bdbars_count; i++) { in snd_intel8x0_create()
3047 ichdev = &chip->ichd[i]; in snd_intel8x0_create()
3048 ichdev->bdbar = ((__le32 *)chip->bdbars.area) + in snd_intel8x0_create()
3050 ichdev->bdbar_addr = chip->bdbars.addr + in snd_intel8x0_create()
3052 int_sta_masks |= ichdev->int_sta_mask; in snd_intel8x0_create()
3054 chip->int_sta_reg = device_type == DEVICE_ALI ? in snd_intel8x0_create()
3056 chip->int_sta_mask = int_sta_masks; in snd_intel8x0_create()
3060 switch(chip->device_type) { in snd_intel8x0_create()
3063 chip->max_codecs = 3; in snd_intel8x0_create()
3064 chip->codec_bit = ich_codec_bits; in snd_intel8x0_create()
3065 chip->codec_ready_bits = ICH_PRI | ICH_SRI | ICH_TRI; in snd_intel8x0_create()
3069 chip->max_codecs = 3; in snd_intel8x0_create()
3070 chip->codec_bit = sis_codec_bits; in snd_intel8x0_create()
3071 chip->codec_ready_bits = ICH_PRI | ICH_SRI | ICH_SIS_TRI; in snd_intel8x0_create()
3075 chip->max_codecs = 2; in snd_intel8x0_create()
3076 chip->codec_bit = ich_codec_bits; in snd_intel8x0_create()
3077 chip->codec_ready_bits = ICH_PRI | ICH_SRI; in snd_intel8x0_create()
3080 for (i = 0; i < chip->max_codecs; i++) in snd_intel8x0_create()
3081 chip->codec_isr_bits |= chip->codec_bit[i]; in snd_intel8x0_create()
3089 if (request_irq(pci->irq, snd_intel8x0_interrupt, in snd_intel8x0_create()
3091 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); in snd_intel8x0_create()
3093 return -EBUSY; in snd_intel8x0_create()
3095 chip->irq = pci->irq; in snd_intel8x0_create()
3096 card->sync_irq = chip->irq; in snd_intel8x0_create()
3111 { PCI_DEVICE_ID_INTEL_82801AA_5, "Intel 82801AA-ICH" },
3112 { PCI_DEVICE_ID_INTEL_82801AB_5, "Intel 82901AB-ICH0" },
3113 { PCI_DEVICE_ID_INTEL_82801BA_4, "Intel 82801BA-ICH2" },
3115 { PCI_DEVICE_ID_INTEL_82801CA_5, "Intel 82801CA-ICH3" },
3116 { PCI_DEVICE_ID_INTEL_82801DB_5, "Intel 82801DB-ICH4" },
3141 /* look up allow/deny list for SPDIF over ac-link */
3148 if (w->value) in check_default_spdif_aclink()
3149 dev_dbg(&pci->dev, in check_default_spdif_aclink()
3150 "Using SPDIF over AC-Link for %s\n", in check_default_spdif_aclink()
3153 dev_dbg(&pci->dev, in check_default_spdif_aclink()
3156 return w->value; in check_default_spdif_aclink()
3169 err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card); in snd_intel8x0_probe()
3176 strcpy(card->driver, "ICH"); in snd_intel8x0_probe()
3178 switch (pci_id->driver_data) { in snd_intel8x0_probe()
3180 strcpy(card->driver, "NFORCE"); in snd_intel8x0_probe()
3183 strcpy(card->driver, "ICH4"); in snd_intel8x0_probe()
3187 strcpy(card->shortname, "Intel ICH"); in snd_intel8x0_probe()
3188 for (name = shortnames; name->id; name++) { in snd_intel8x0_probe()
3189 if (pci->device == name->id) { in snd_intel8x0_probe()
3190 strcpy(card->shortname, name->s); in snd_intel8x0_probe()
3199 if (pci_id->driver_data == DEVICE_NFORCE) in snd_intel8x0_probe()
3205 if ((err = snd_intel8x0_create(card, pci, pci_id->driver_data, in snd_intel8x0_probe()
3210 card->private_data = chip; in snd_intel8x0_probe()
3223 snprintf(card->longname, sizeof(card->longname), in snd_intel8x0_probe()
3224 "%s with %s at irq %i", card->shortname, in snd_intel8x0_probe()
3225 snd_ac97_get_short_name(chip->ac97[0]), chip->irq); in snd_intel8x0_probe()