Lines Matching +full:multi +full:- +full:chip
1 // SPDX-License-Identifier: GPL-2.0-or-later
8 * Tjeerd.Mulder <Tjeerd.Mulder@fujitsu-siemens.com>
16 * - use the DSX channels for the first pcm playback.
19 * multi-channel playback is assigned to the second device
21 * - support the secondary capture (on VIA8233/C,8235)
22 * - SPDIF support
26 * the card config of alsa-lib will assign the correct
28 * - clean up the code, separate low-level initialization
32 * - Optimize position calculation for the 823x chips.
64 static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
81 MODULE_PARM_DESC(mpu_port, "MPU-401 port. (VT82C686x only)");
93 MODULE_PARM_DESC(dxs_init_volume, "initial DXS volume (0-31)");
112 #define VIA_REV_8233C 0x20 /* 2 rec, 4 pb, 1 multi-pb */
113 #define VIA_REV_8233 0x30 /* 2 rec, 4 pb, 1 multi-pb, spdif */
114 #define VIA_REV_8233A 0x40 /* 1 rec, 1 multi-pb, spdf */
115 #define VIA_REV_8235 0x50 /* 2 rec, 4 pb, 1 multi-pb, spdif */
123 #define VIAREG(via, x) ((via)->port + VIA_REG_##x)
124 #define VIADEV_REG(viadev, x) ((viadev)->port + VIA_REG_##x)
127 #define VIA_REG_OFFSET_STATUS 0x00 /* byte - channel status */
135 #define VIA_REG_OFFSET_CONTROL 0x01 /* byte - channel control */
143 #define VIA_REG_CTRL_RESET 0x01 /* RW - probably reset? undocumented */
145 #define VIA_REG_OFFSET_TYPE 0x02 /* byte - channel type (686 only) */
146 #define VIA_REG_TYPE_AUTOSTART 0x80 /* RW - autostart at EOL */
155 #define VIA_REG_OFFSET_TABLE_PTR 0x04 /* dword - channel table pointer */
156 #define VIA_REG_OFFSET_CURR_PTR 0x04 /* dword - channel current pointer */
157 #define VIA_REG_OFFSET_STOP_IDX 0x08 /* dword - stop index, channel type, sample rate */
160 #define VIA_REG_OFFSET_CURR_COUNT 0x0c /* dword - channel current count (24 bit) */
161 #define VIA_REG_OFFSET_CURR_INDEX 0x0f /* byte - channel current index (for via8233 only) */
222 /* multi-channel and capture registers for via8233 */
226 /* via8233-specific registers */
229 #define VIA_REG_OFS_MULTPLAY_FORMAT 0x02 /* byte - format and channels */
233 #define VIA_REG_OFS_CAPTURE_FIFO 0x02 /* byte - bit 6 = fifo enable */
238 #define VIA_REG_CAPTURE_CHANNEL 0x63 /* byte - input select */
251 #define VIA_ACLINK_LOWPOWER 0x02 /* low-power state */
255 #define VIA_ACLINK_CTRL_RESET 0x40 /* 0: assert, 1: de-assert */
332 #define VIA_MAX_DEVS 7 /* 4 playback, 1 multi, 2 capture */
413 struct via82xx *chip = snd_pcm_substream_chip(substream); in build_via_table() local
416 if (dev->table.area == NULL) { in build_via_table()
420 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &chip->pci->dev, in build_via_table()
422 &dev->table) < 0) in build_via_table()
423 return -ENOMEM; in build_via_table()
425 if (! dev->idx_table) { in build_via_table()
426 dev->idx_table = kmalloc_array(VIA_TABLE_SIZE, in build_via_table()
427 sizeof(*dev->idx_table), in build_via_table()
429 if (! dev->idx_table) in build_via_table()
430 return -ENOMEM; in build_via_table()
436 pgtbl = (__le32 *)dev->table.area; in build_via_table()
449 dev_err(&pci->dev, "too much table size!\n"); in build_via_table()
450 return -EINVAL; in build_via_table()
455 rest -= r; in build_via_table()
457 if (i == periods - 1) in build_via_table()
464 dev_dbg(&pci->dev, in build_via_table()
469 dev->idx_table[idx].offset = ofs; in build_via_table()
470 dev->idx_table[idx].size = r; in build_via_table()
475 dev->tbl_entries = idx; in build_via_table()
476 dev->bufsize = periods * fragsize; in build_via_table()
477 dev->bufsize2 = dev->bufsize / 2; in build_via_table()
478 dev->fragsize = fragsize; in build_via_table()
486 if (dev->table.area) { in clean_via_table()
487 snd_dma_free_pages(&dev->table); in clean_via_table()
488 dev->table.area = NULL; in clean_via_table()
490 kfree(dev->idx_table); in clean_via_table()
491 dev->idx_table = NULL; in clean_via_table()
499 static inline unsigned int snd_via82xx_codec_xread(struct via82xx *chip) in snd_via82xx_codec_xread() argument
501 return inl(VIAREG(chip, AC97)); in snd_via82xx_codec_xread()
504 static inline void snd_via82xx_codec_xwrite(struct via82xx *chip, unsigned int val) in snd_via82xx_codec_xwrite() argument
506 outl(val, VIAREG(chip, AC97)); in snd_via82xx_codec_xwrite()
509 static int snd_via82xx_codec_ready(struct via82xx *chip, int secondary) in snd_via82xx_codec_ready() argument
514 while (timeout-- > 0) { in snd_via82xx_codec_ready()
516 val = snd_via82xx_codec_xread(chip); in snd_via82xx_codec_ready()
520 dev_err(chip->card->dev, "codec_ready: codec %i is not ready [0x%x]\n", in snd_via82xx_codec_ready()
521 secondary, snd_via82xx_codec_xread(chip)); in snd_via82xx_codec_ready()
522 return -EIO; in snd_via82xx_codec_ready()
525 static int snd_via82xx_codec_valid(struct via82xx *chip, int secondary) in snd_via82xx_codec_valid() argument
532 while (timeout-- > 0) { in snd_via82xx_codec_valid()
533 val = snd_via82xx_codec_xread(chip); in snd_via82xx_codec_valid()
539 return -EIO; in snd_via82xx_codec_valid()
544 struct via82xx *chip = ac97->private_data; in snd_via82xx_codec_wait() local
546 err = snd_via82xx_codec_ready(chip, ac97->num); in snd_via82xx_codec_wait()
556 struct via82xx *chip = ac97->private_data; in snd_via82xx_codec_write() local
559 xval = !ac97->num ? VIA_REG_AC97_CODEC_ID_PRIMARY : VIA_REG_AC97_CODEC_ID_SECONDARY; in snd_via82xx_codec_write()
563 snd_via82xx_codec_xwrite(chip, xval); in snd_via82xx_codec_write()
564 snd_via82xx_codec_ready(chip, ac97->num); in snd_via82xx_codec_write()
569 struct via82xx *chip = ac97->private_data; in snd_via82xx_codec_read() local
573 xval = ac97->num << VIA_REG_AC97_CODEC_ID_SHIFT; in snd_via82xx_codec_read()
574 xval |= ac97->num ? VIA_REG_AC97_SECONDARY_VALID : VIA_REG_AC97_PRIMARY_VALID; in snd_via82xx_codec_read()
579 dev_err(chip->card->dev, in snd_via82xx_codec_read()
581 ac97->num, snd_via82xx_codec_xread(chip)); in snd_via82xx_codec_read()
584 snd_via82xx_codec_xwrite(chip, xval); in snd_via82xx_codec_read()
586 if (snd_via82xx_codec_valid(chip, ac97->num) >= 0) { in snd_via82xx_codec_read()
588 val = snd_via82xx_codec_xread(chip); in snd_via82xx_codec_read()
595 static void snd_via82xx_channel_reset(struct via82xx *chip, struct viadev *viadev) in snd_via82xx_channel_reset() argument
607 viadev->lastpos = 0; in snd_via82xx_channel_reset()
608 viadev->hwptr_done = 0; in snd_via82xx_channel_reset()
618 struct via82xx *chip = dev_id; in snd_via686_interrupt() local
622 status = inl(VIAREG(chip, SGD_SHADOW)); in snd_via686_interrupt()
623 if (! (status & chip->intr_mask)) { in snd_via686_interrupt()
624 if (chip->rmidi) in snd_via686_interrupt()
626 return snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data); in snd_via686_interrupt()
631 spin_lock(&chip->reg_lock); in snd_via686_interrupt()
632 for (i = 0; i < chip->num_devs; i++) { in snd_via686_interrupt()
633 struct viadev *viadev = &chip->devs[i]; in snd_via686_interrupt()
637 if (viadev->substream && viadev->running) { in snd_via686_interrupt()
640 * interrupts. We'll use it, when the chip returns 0 in snd_via686_interrupt()
644 viadev->hwptr_done = 0; in snd_via686_interrupt()
646 viadev->hwptr_done += viadev->fragsize; in snd_via686_interrupt()
647 viadev->in_interrupt = c_status; in snd_via686_interrupt()
648 spin_unlock(&chip->reg_lock); in snd_via686_interrupt()
649 snd_pcm_period_elapsed(viadev->substream); in snd_via686_interrupt()
650 spin_lock(&chip->reg_lock); in snd_via686_interrupt()
651 viadev->in_interrupt = 0; in snd_via686_interrupt()
655 spin_unlock(&chip->reg_lock); in snd_via686_interrupt()
664 struct via82xx *chip = dev_id; in snd_via8233_interrupt() local
670 spin_lock(&chip->reg_lock); in snd_via8233_interrupt()
671 status = inl(VIAREG(chip, SGD_SHADOW)); in snd_via8233_interrupt()
673 for (i = 0; i < chip->num_devs; i++) { in snd_via8233_interrupt()
674 struct viadev *viadev = &chip->devs[i]; in snd_via8233_interrupt()
678 shadow_status = (status >> viadev->shadow_shift) & in snd_via8233_interrupt()
685 substream = viadev->substream; in snd_via8233_interrupt()
686 if (substream && viadev->running) { in snd_via8233_interrupt()
689 * interrupts. We'll use it, when the chip returns 0 in snd_via8233_interrupt()
693 viadev->hwptr_done = 0; in snd_via8233_interrupt()
695 viadev->hwptr_done += viadev->fragsize; in snd_via8233_interrupt()
696 viadev->in_interrupt = c_status; in snd_via8233_interrupt()
698 viadev->in_interrupt |= VIA_REG_STAT_ACTIVE; in snd_via8233_interrupt()
699 spin_unlock(&chip->reg_lock); in snd_via8233_interrupt()
703 spin_lock(&chip->reg_lock); in snd_via8233_interrupt()
704 viadev->in_interrupt = 0; in snd_via8233_interrupt()
709 spin_unlock(&chip->reg_lock); in snd_via8233_interrupt()
722 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via82xx_pcm_trigger() local
723 struct viadev *viadev = substream->runtime->private_data; in snd_via82xx_pcm_trigger()
726 if (chip->chip_type != TYPE_VIA686) in snd_via82xx_pcm_trigger()
734 viadev->running = 1; in snd_via82xx_pcm_trigger()
739 viadev->running = 0; in snd_via82xx_pcm_trigger()
743 viadev->running = 0; in snd_via82xx_pcm_trigger()
746 viadev->running = 1; in snd_via82xx_pcm_trigger()
749 return -EINVAL; in snd_via82xx_pcm_trigger()
753 snd_via82xx_channel_reset(chip, viadev); in snd_via82xx_pcm_trigger()
763 * calculate the linear position at the given sg-buffer index and the rest count
767 ((pos) < viadev->lastpos && ((pos) >= viadev->bufsize2 ||\
768 viadev->lastpos < viadev->bufsize2))
770 static inline unsigned int calc_linear_pos(struct via82xx *chip, in calc_linear_pos() argument
777 size = viadev->idx_table[idx].size; in calc_linear_pos()
778 base = viadev->idx_table[idx].offset; in calc_linear_pos()
779 res = base + size - count; in calc_linear_pos()
780 if (res >= viadev->bufsize) in calc_linear_pos()
781 res -= viadev->bufsize; in calc_linear_pos()
785 dev_dbg(chip->card->dev, in calc_linear_pos()
788 res = viadev->lastpos; in calc_linear_pos()
795 int delta = res - viadev->lastpos; in calc_linear_pos()
797 delta += viadev->bufsize; in calc_linear_pos()
798 if ((unsigned int)delta > viadev->fragsize) in calc_linear_pos()
803 dev_dbg(chip->card->dev, in calc_linear_pos()
805 idx, viadev->tbl_entries, in calc_linear_pos()
806 viadev->lastpos, viadev->bufsize2, in calc_linear_pos()
807 viadev->idx_table[idx].offset, in calc_linear_pos()
808 viadev->idx_table[idx].size, count); in calc_linear_pos()
813 dev_dbg(chip->card->dev, in calc_linear_pos()
815 res = viadev->lastpos; in calc_linear_pos()
827 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via686_pcm_pointer() local
828 struct viadev *viadev = substream->runtime->private_data; in snd_via686_pcm_pointer()
831 if (snd_BUG_ON(!viadev->tbl_entries)) in snd_via686_pcm_pointer()
836 spin_lock(&chip->reg_lock); in snd_via686_pcm_pointer()
842 if (ptr <= (unsigned int)viadev->table.addr) in snd_via686_pcm_pointer()
845 idx = ((ptr - (unsigned int)viadev->table.addr) / 8 - 1) % viadev->tbl_entries; in snd_via686_pcm_pointer()
846 res = calc_linear_pos(chip, viadev, idx, count); in snd_via686_pcm_pointer()
847 viadev->lastpos = res; /* remember the last position */ in snd_via686_pcm_pointer()
848 spin_unlock(&chip->reg_lock); in snd_via686_pcm_pointer()
850 return bytes_to_frames(substream->runtime, res); in snd_via686_pcm_pointer()
858 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via8233_pcm_pointer() local
859 struct viadev *viadev = substream->runtime->private_data; in snd_via8233_pcm_pointer()
863 if (snd_BUG_ON(!viadev->tbl_entries)) in snd_via8233_pcm_pointer()
866 spin_lock(&chip->reg_lock); in snd_via8233_pcm_pointer()
868 status = viadev->in_interrupt; in snd_via8233_pcm_pointer()
874 if (chip->revision == VIA_REV_8251 && (status & VIA_REG_STAT_EOL)) in snd_via8233_pcm_pointer()
883 if (idx >= viadev->tbl_entries) { in snd_via8233_pcm_pointer()
885 dev_dbg(chip->card->dev, in snd_via8233_pcm_pointer()
887 viadev->tbl_entries); in snd_via8233_pcm_pointer()
889 res = viadev->lastpos; in snd_via8233_pcm_pointer()
892 res = calc_linear_pos(chip, viadev, idx, count); in snd_via8233_pcm_pointer()
895 res = viadev->hwptr_done; in snd_via8233_pcm_pointer()
896 if (!viadev->in_interrupt) { in snd_via8233_pcm_pointer()
901 res += viadev->fragsize; in snd_via8233_pcm_pointer()
906 viadev->lastpos = res; in snd_via8233_pcm_pointer()
907 spin_unlock(&chip->reg_lock); in snd_via8233_pcm_pointer()
909 return bytes_to_frames(substream->runtime, res); in snd_via8233_pcm_pointer()
920 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via82xx_hw_params() local
921 struct viadev *viadev = substream->runtime->private_data; in snd_via82xx_hw_params()
923 return build_via_table(viadev, substream, chip->pci, in snd_via82xx_hw_params()
934 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via82xx_hw_free() local
935 struct viadev *viadev = substream->runtime->private_data; in snd_via82xx_hw_free()
937 clean_via_table(viadev, substream, chip->pci); in snd_via82xx_hw_free()
945 static void snd_via82xx_set_table_ptr(struct via82xx *chip, struct viadev *viadev) in snd_via82xx_set_table_ptr() argument
947 snd_via82xx_codec_ready(chip, 0); in snd_via82xx_set_table_ptr()
948 outl((u32)viadev->table.addr, VIADEV_REG(viadev, OFFSET_TABLE_PTR)); in snd_via82xx_set_table_ptr()
950 snd_via82xx_codec_ready(chip, 0); in snd_via82xx_set_table_ptr()
956 static void via686_setup_format(struct via82xx *chip, struct viadev *viadev, in via686_setup_format() argument
959 snd_via82xx_channel_reset(chip, viadev); in via686_setup_format()
961 snd_via82xx_set_table_ptr(chip, viadev); in via686_setup_format()
963 (runtime->format == SNDRV_PCM_FORMAT_S16_LE ? VIA_REG_TYPE_16BIT : 0) | in via686_setup_format()
964 (runtime->channels > 1 ? VIA_REG_TYPE_STEREO : 0) | in via686_setup_format()
965 ((viadev->reg_offset & 0x10) == 0 ? VIA_REG_TYPE_INT_LSAMPLE : 0) | in via686_setup_format()
972 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via686_playback_prepare() local
973 struct viadev *viadev = substream->runtime->private_data; in snd_via686_playback_prepare()
974 struct snd_pcm_runtime *runtime = substream->runtime; in snd_via686_playback_prepare()
976 snd_ac97_set_rate(chip->ac97, AC97_PCM_FRONT_DAC_RATE, runtime->rate); in snd_via686_playback_prepare()
977 snd_ac97_set_rate(chip->ac97, AC97_SPDIF, runtime->rate); in snd_via686_playback_prepare()
978 via686_setup_format(chip, viadev, runtime); in snd_via686_playback_prepare()
984 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via686_capture_prepare() local
985 struct viadev *viadev = substream->runtime->private_data; in snd_via686_capture_prepare()
986 struct snd_pcm_runtime *runtime = substream->runtime; in snd_via686_capture_prepare()
988 snd_ac97_set_rate(chip->ac97, AC97_PCM_LR_ADC_RATE, runtime->rate); in snd_via686_capture_prepare()
989 via686_setup_format(chip, viadev, runtime); in snd_via686_capture_prepare()
1000 spin_lock_irq(&rec->lock); in via_lock_rate()
1001 if (rec->rate != rate) { in via_lock_rate()
1002 if (rec->rate && rec->used > 1) /* already set */ in via_lock_rate()
1003 changed = -EINVAL; in via_lock_rate()
1005 rec->rate = rate; in via_lock_rate()
1009 spin_unlock_irq(&rec->lock); in via_lock_rate()
1018 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via8233_playback_prepare() local
1019 struct viadev *viadev = substream->runtime->private_data; in snd_via8233_playback_prepare()
1020 struct snd_pcm_runtime *runtime = substream->runtime; in snd_via8233_playback_prepare()
1021 int ac97_rate = chip->dxs_src ? 48000 : runtime->rate; in snd_via8233_playback_prepare()
1025 rate_changed = via_lock_rate(&chip->rates[0], ac97_rate); in snd_via8233_playback_prepare()
1029 snd_ac97_set_rate(chip->ac97, AC97_PCM_FRONT_DAC_RATE, in snd_via8233_playback_prepare()
1030 chip->no_vra ? 48000 : runtime->rate); in snd_via8233_playback_prepare()
1031 if (chip->spdif_on && viadev->reg_offset == 0x30) in snd_via8233_playback_prepare()
1032 snd_ac97_set_rate(chip->ac97, AC97_SPDIF, runtime->rate); in snd_via8233_playback_prepare()
1034 if (runtime->rate == 48000) in snd_via8233_playback_prepare()
1037 rbits = (0x100000 / 48000) * runtime->rate + in snd_via8233_playback_prepare()
1038 ((0x100000 % 48000) * runtime->rate) / 48000; in snd_via8233_playback_prepare()
1040 snd_via82xx_channel_reset(chip, viadev); in snd_via8233_playback_prepare()
1041 snd_via82xx_set_table_ptr(chip, viadev); in snd_via8233_playback_prepare()
1042 outb(chip->playback_volume[viadev->reg_offset / 0x10][0], in snd_via8233_playback_prepare()
1044 outb(chip->playback_volume[viadev->reg_offset / 0x10][1], in snd_via8233_playback_prepare()
1046 outl((runtime->format == SNDRV_PCM_FORMAT_S16_LE ? VIA8233_REG_TYPE_16BIT : 0) | /* format */ in snd_via8233_playback_prepare()
1047 (runtime->channels > 1 ? VIA8233_REG_TYPE_STEREO : 0) | /* stereo */ in snd_via8233_playback_prepare()
1052 snd_via82xx_codec_ready(chip, 0); in snd_via8233_playback_prepare()
1057 * prepare callback for multi-channel playback on via823x
1061 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via8233_multi_prepare() local
1062 struct viadev *viadev = substream->runtime->private_data; in snd_via8233_multi_prepare()
1063 struct snd_pcm_runtime *runtime = substream->runtime; in snd_via8233_multi_prepare()
1067 if (via_lock_rate(&chip->rates[0], runtime->rate) < 0) in snd_via8233_multi_prepare()
1068 return -EINVAL; in snd_via8233_multi_prepare()
1069 snd_ac97_set_rate(chip->ac97, AC97_PCM_FRONT_DAC_RATE, runtime->rate); in snd_via8233_multi_prepare()
1070 snd_ac97_set_rate(chip->ac97, AC97_PCM_SURR_DAC_RATE, runtime->rate); in snd_via8233_multi_prepare()
1071 snd_ac97_set_rate(chip->ac97, AC97_PCM_LFE_DAC_RATE, runtime->rate); in snd_via8233_multi_prepare()
1072 snd_ac97_set_rate(chip->ac97, AC97_SPDIF, runtime->rate); in snd_via8233_multi_prepare()
1073 snd_via82xx_channel_reset(chip, viadev); in snd_via8233_multi_prepare()
1074 snd_via82xx_set_table_ptr(chip, viadev); in snd_via8233_multi_prepare()
1076 fmt = (runtime->format == SNDRV_PCM_FORMAT_S16_LE) ? in snd_via8233_multi_prepare()
1078 fmt |= runtime->channels << 4; in snd_via8233_multi_prepare()
1081 if (chip->revision == VIA_REV_8233A) in snd_via8233_multi_prepare()
1088 switch (runtime->channels) { in snd_via8233_multi_prepare()
1101 snd_via82xx_codec_ready(chip, 0); in snd_via8233_multi_prepare()
1110 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via8233_capture_prepare() local
1111 struct viadev *viadev = substream->runtime->private_data; in snd_via8233_capture_prepare()
1112 struct snd_pcm_runtime *runtime = substream->runtime; in snd_via8233_capture_prepare()
1114 if (via_lock_rate(&chip->rates[1], runtime->rate) < 0) in snd_via8233_capture_prepare()
1115 return -EINVAL; in snd_via8233_capture_prepare()
1116 snd_ac97_set_rate(chip->ac97, AC97_PCM_LR_ADC_RATE, runtime->rate); in snd_via8233_capture_prepare()
1117 snd_via82xx_channel_reset(chip, viadev); in snd_via8233_capture_prepare()
1118 snd_via82xx_set_table_ptr(chip, viadev); in snd_via8233_capture_prepare()
1120 outl((runtime->format == SNDRV_PCM_FORMAT_S16_LE ? VIA8233_REG_TYPE_16BIT : 0) | in snd_via8233_capture_prepare()
1121 (runtime->channels > 1 ? VIA8233_REG_TYPE_STEREO : 0) | in snd_via8233_capture_prepare()
1125 snd_via82xx_codec_ready(chip, 0); in snd_via8233_capture_prepare()
1158 static int snd_via82xx_pcm_open(struct via82xx *chip, struct viadev *viadev, in snd_via82xx_pcm_open() argument
1161 struct snd_pcm_runtime *runtime = substream->runtime; in snd_via82xx_pcm_open()
1166 runtime->hw = snd_via82xx_hw; in snd_via82xx_pcm_open()
1169 ratep = &chip->rates[viadev->direction]; in snd_via82xx_pcm_open()
1170 spin_lock_irq(&ratep->lock); in snd_via82xx_pcm_open()
1171 ratep->used++; in snd_via82xx_pcm_open()
1172 if (chip->spdif_on && viadev->reg_offset == 0x30) { in snd_via82xx_pcm_open()
1174 runtime->hw.rates = chip->ac97->rates[AC97_RATES_SPDIF]; in snd_via82xx_pcm_open()
1176 } else if (chip->dxs_fixed && viadev->reg_offset < 0x40) { in snd_via82xx_pcm_open()
1178 runtime->hw.rates = SNDRV_PCM_RATE_48000; in snd_via82xx_pcm_open()
1179 runtime->hw.rate_min = runtime->hw.rate_max = 48000; in snd_via82xx_pcm_open()
1180 } else if (chip->dxs_src && viadev->reg_offset < 0x40) { in snd_via82xx_pcm_open()
1182 runtime->hw.rates = (SNDRV_PCM_RATE_CONTINUOUS | in snd_via82xx_pcm_open()
1184 runtime->hw.rate_min = 8000; in snd_via82xx_pcm_open()
1185 runtime->hw.rate_max = 48000; in snd_via82xx_pcm_open()
1187 } else if (! ratep->rate) { in snd_via82xx_pcm_open()
1188 int idx = viadev->direction ? AC97_RATES_ADC : AC97_RATES_FRONT_DAC; in snd_via82xx_pcm_open()
1189 runtime->hw.rates = chip->ac97->rates[idx]; in snd_via82xx_pcm_open()
1193 runtime->hw.rates = SNDRV_PCM_RATE_KNOT; in snd_via82xx_pcm_open()
1194 runtime->hw.rate_max = runtime->hw.rate_min = ratep->rate; in snd_via82xx_pcm_open()
1196 spin_unlock_irq(&ratep->lock); in snd_via82xx_pcm_open()
1210 runtime->private_data = viadev; in snd_via82xx_pcm_open()
1211 viadev->substream = substream; in snd_via82xx_pcm_open()
1222 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via686_playback_open() local
1223 struct viadev *viadev = &chip->devs[chip->playback_devno + substream->number]; in snd_via686_playback_open()
1226 err = snd_via82xx_pcm_open(chip, viadev, substream); in snd_via686_playback_open()
1237 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via8233_playback_open() local
1242 viadev = &chip->devs[chip->playback_devno + substream->number]; in snd_via8233_playback_open()
1243 err = snd_via82xx_pcm_open(chip, viadev, substream); in snd_via8233_playback_open()
1246 stream = viadev->reg_offset / 0x10; in snd_via8233_playback_open()
1247 if (chip->dxs_controls[stream]) { in snd_via8233_playback_open()
1248 chip->playback_volume[stream][0] = in snd_via8233_playback_open()
1249 VIA_DXS_MAX_VOLUME - (dxs_init_volume & 31); in snd_via8233_playback_open()
1250 chip->playback_volume[stream][1] = in snd_via8233_playback_open()
1251 VIA_DXS_MAX_VOLUME - (dxs_init_volume & 31); in snd_via8233_playback_open()
1252 chip->dxs_controls[stream]->vd[0].access &= in snd_via8233_playback_open()
1254 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE | in snd_via8233_playback_open()
1256 &chip->dxs_controls[stream]->id); in snd_via8233_playback_open()
1262 * open callback for playback on via823x multi-channel
1266 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via8233_multi_open() local
1267 struct viadev *viadev = &chip->devs[chip->multi_devno]; in snd_via8233_multi_open()
1281 err = snd_via82xx_pcm_open(chip, viadev, substream); in snd_via8233_multi_open()
1284 substream->runtime->hw.channels_max = 6; in snd_via8233_multi_open()
1285 if (chip->revision == VIA_REV_8233A) in snd_via8233_multi_open()
1286 snd_pcm_hw_constraint_list(substream->runtime, 0, in snd_via8233_multi_open()
1297 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via82xx_capture_open() local
1298 struct viadev *viadev = &chip->devs[chip->capture_devno + substream->pcm->device]; in snd_via82xx_capture_open()
1300 return snd_via82xx_pcm_open(chip, viadev, substream); in snd_via82xx_capture_open()
1308 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via82xx_pcm_close() local
1309 struct viadev *viadev = substream->runtime->private_data; in snd_via82xx_pcm_close()
1313 ratep = &chip->rates[viadev->direction]; in snd_via82xx_pcm_close()
1314 spin_lock_irq(&ratep->lock); in snd_via82xx_pcm_close()
1315 ratep->used--; in snd_via82xx_pcm_close()
1316 if (! ratep->used) in snd_via82xx_pcm_close()
1317 ratep->rate = 0; in snd_via82xx_pcm_close()
1318 spin_unlock_irq(&ratep->lock); in snd_via82xx_pcm_close()
1319 if (! ratep->rate) { in snd_via82xx_pcm_close()
1320 if (! viadev->direction) { in snd_via82xx_pcm_close()
1321 snd_ac97_update_power(chip->ac97, in snd_via82xx_pcm_close()
1323 snd_ac97_update_power(chip->ac97, in snd_via82xx_pcm_close()
1325 snd_ac97_update_power(chip->ac97, in snd_via82xx_pcm_close()
1328 snd_ac97_update_power(chip->ac97, in snd_via82xx_pcm_close()
1331 viadev->substream = NULL; in snd_via82xx_pcm_close()
1337 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via8233_playback_close() local
1338 struct viadev *viadev = substream->runtime->private_data; in snd_via8233_playback_close()
1341 stream = viadev->reg_offset / 0x10; in snd_via8233_playback_close()
1342 if (chip->dxs_controls[stream]) { in snd_via8233_playback_close()
1343 chip->dxs_controls[stream]->vd[0].access |= in snd_via8233_playback_close()
1345 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_INFO, in snd_via8233_playback_close()
1346 &chip->dxs_controls[stream]->id); in snd_via8233_playback_close()
1385 /* via823x multi-channel playback callbacks */
1408 static void init_viadev(struct via82xx *chip, int idx, unsigned int reg_offset, in init_viadev() argument
1411 chip->devs[idx].reg_offset = reg_offset; in init_viadev()
1412 chip->devs[idx].shadow_shift = shadow_pos * 4; in init_viadev()
1413 chip->devs[idx].direction = direction; in init_viadev()
1414 chip->devs[idx].port = chip->port + reg_offset; in init_viadev()
1420 static int snd_via8233_pcm_new(struct via82xx *chip) in snd_via8233_pcm_new() argument
1426 chip->playback_devno = 0; /* x 4 */ in snd_via8233_pcm_new()
1427 chip->multi_devno = 4; /* x 1 */ in snd_via8233_pcm_new()
1428 chip->capture_devno = 5; /* x 2 */ in snd_via8233_pcm_new()
1429 chip->num_devs = 7; in snd_via8233_pcm_new()
1430 chip->intr_mask = 0x33033333; /* FLAG|EOL for rec0-1, mc, sdx0-3 */ in snd_via8233_pcm_new()
1433 err = snd_pcm_new(chip->card, chip->card->shortname, 0, 4, 1, &pcm); in snd_via8233_pcm_new()
1438 pcm->private_data = chip; in snd_via8233_pcm_new()
1439 strcpy(pcm->name, chip->card->shortname); in snd_via8233_pcm_new()
1440 chip->pcms[0] = pcm; in snd_via8233_pcm_new()
1443 init_viadev(chip, i, 0x10 * i, i, 0); in snd_via8233_pcm_new()
1445 init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1); in snd_via8233_pcm_new()
1448 &chip->pci->dev, in snd_via8233_pcm_new()
1457 /* PCM #1: multi-channel playback and 2nd capture */ in snd_via8233_pcm_new()
1458 err = snd_pcm_new(chip->card, chip->card->shortname, 1, 1, 1, &pcm); in snd_via8233_pcm_new()
1463 pcm->private_data = chip; in snd_via8233_pcm_new()
1464 strcpy(pcm->name, chip->card->shortname); in snd_via8233_pcm_new()
1465 chip->pcms[1] = pcm; in snd_via8233_pcm_new()
1467 init_viadev(chip, chip->multi_devno, VIA_REG_MULTPLAY_STATUS, 4, 0); in snd_via8233_pcm_new()
1469 init_viadev(chip, chip->capture_devno + 1, VIA_REG_CAPTURE_8233_STATUS + 0x10, 7, 1); in snd_via8233_pcm_new()
1472 &chip->pci->dev, in snd_via8233_pcm_new()
1480 chip->ac97->chmaps[SNDRV_PCM_STREAM_PLAYBACK] = chmap; in snd_via8233_pcm_new()
1488 static int snd_via8233a_pcm_new(struct via82xx *chip) in snd_via8233a_pcm_new() argument
1494 chip->multi_devno = 0; in snd_via8233a_pcm_new()
1495 chip->playback_devno = 1; in snd_via8233a_pcm_new()
1496 chip->capture_devno = 2; in snd_via8233a_pcm_new()
1497 chip->num_devs = 3; in snd_via8233a_pcm_new()
1498 chip->intr_mask = 0x03033000; /* FLAG|EOL for rec0, mc, sdx3 */ in snd_via8233a_pcm_new()
1500 /* PCM #0: multi-channel playback and capture */ in snd_via8233a_pcm_new()
1501 err = snd_pcm_new(chip->card, chip->card->shortname, 0, 1, 1, &pcm); in snd_via8233a_pcm_new()
1506 pcm->private_data = chip; in snd_via8233a_pcm_new()
1507 strcpy(pcm->name, chip->card->shortname); in snd_via8233a_pcm_new()
1508 chip->pcms[0] = pcm; in snd_via8233a_pcm_new()
1510 init_viadev(chip, chip->multi_devno, VIA_REG_MULTPLAY_STATUS, 4, 0); in snd_via8233a_pcm_new()
1512 init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1); in snd_via8233a_pcm_new()
1515 &chip->pci->dev, in snd_via8233a_pcm_new()
1523 chip->ac97->chmaps[SNDRV_PCM_STREAM_PLAYBACK] = chmap; in snd_via8233a_pcm_new()
1526 if (! ac97_can_spdif(chip->ac97)) in snd_via8233a_pcm_new()
1530 err = snd_pcm_new(chip->card, chip->card->shortname, 1, 1, 0, &pcm); in snd_via8233a_pcm_new()
1534 pcm->private_data = chip; in snd_via8233a_pcm_new()
1535 strcpy(pcm->name, chip->card->shortname); in snd_via8233a_pcm_new()
1536 chip->pcms[1] = pcm; in snd_via8233a_pcm_new()
1538 init_viadev(chip, chip->playback_devno, 0x30, 3, 0); in snd_via8233a_pcm_new()
1541 &chip->pci->dev, in snd_via8233a_pcm_new()
1549 static int snd_via686_pcm_new(struct via82xx *chip) in snd_via686_pcm_new() argument
1554 chip->playback_devno = 0; in snd_via686_pcm_new()
1555 chip->capture_devno = 1; in snd_via686_pcm_new()
1556 chip->num_devs = 2; in snd_via686_pcm_new()
1557 chip->intr_mask = 0x77; /* FLAG | EOL for PB, CP, FM */ in snd_via686_pcm_new()
1559 err = snd_pcm_new(chip->card, chip->card->shortname, 0, 1, 1, &pcm); in snd_via686_pcm_new()
1564 pcm->private_data = chip; in snd_via686_pcm_new()
1565 strcpy(pcm->name, chip->card->shortname); in snd_via686_pcm_new()
1566 chip->pcms[0] = pcm; in snd_via686_pcm_new()
1567 init_viadev(chip, 0, VIA_REG_PLAYBACK_STATUS, 0, 0); in snd_via686_pcm_new()
1568 init_viadev(chip, 1, VIA_REG_CAPTURE_STATUS, 0, 1); in snd_via686_pcm_new()
1571 &chip->pci->dev, in snd_via686_pcm_new()
1596 struct via82xx *chip = snd_kcontrol_chip(kcontrol); in snd_via8233_capture_source_get() local
1597 …unsigned long port = chip->port + (kcontrol->id.index ? (VIA_REG_CAPTURE_CHANNEL + 0x10) : VIA_REG… in snd_via8233_capture_source_get()
1598 ucontrol->value.enumerated.item[0] = inb(port) & VIA_REG_CAPTURE_CHANNEL_MIC ? 1 : 0; in snd_via8233_capture_source_get()
1605 struct via82xx *chip = snd_kcontrol_chip(kcontrol); in snd_via8233_capture_source_put() local
1606 …unsigned long port = chip->port + (kcontrol->id.index ? (VIA_REG_CAPTURE_CHANNEL + 0x10) : VIA_REG… in snd_via8233_capture_source_put()
1609 spin_lock_irq(&chip->reg_lock); in snd_via8233_capture_source_put()
1612 if (ucontrol->value.enumerated.item[0]) in snd_via8233_capture_source_put()
1616 spin_unlock_irq(&chip->reg_lock); in snd_via8233_capture_source_put()
1633 struct via82xx *chip = snd_kcontrol_chip(kcontrol); in snd_via8233_dxs3_spdif_get() local
1636 pci_read_config_byte(chip->pci, VIA8233_SPDIF_CTRL, &val); in snd_via8233_dxs3_spdif_get()
1637 ucontrol->value.integer.value[0] = (val & VIA8233_SPDIF_DX3) ? 1 : 0; in snd_via8233_dxs3_spdif_get()
1644 struct via82xx *chip = snd_kcontrol_chip(kcontrol); in snd_via8233_dxs3_spdif_put() local
1647 pci_read_config_byte(chip->pci, VIA8233_SPDIF_CTRL, &oval); in snd_via8233_dxs3_spdif_put()
1649 if (ucontrol->value.integer.value[0]) in snd_via8233_dxs3_spdif_put()
1652 chip->spdif_on = ucontrol->value.integer.value[0] ? 1 : 0; in snd_via8233_dxs3_spdif_put()
1654 pci_write_config_byte(chip->pci, VIA8233_SPDIF_CTRL, val); in snd_via8233_dxs3_spdif_put()
1671 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_via8233_dxs_volume_info()
1672 uinfo->count = 2; in snd_via8233_dxs_volume_info()
1673 uinfo->value.integer.min = 0; in snd_via8233_dxs_volume_info()
1674 uinfo->value.integer.max = VIA_DXS_MAX_VOLUME; in snd_via8233_dxs_volume_info()
1681 struct via82xx *chip = snd_kcontrol_chip(kcontrol); in snd_via8233_dxs_volume_get() local
1682 unsigned int idx = kcontrol->id.subdevice; in snd_via8233_dxs_volume_get()
1684 ucontrol->value.integer.value[0] = VIA_DXS_MAX_VOLUME - chip->playback_volume[idx][0]; in snd_via8233_dxs_volume_get()
1685 ucontrol->value.integer.value[1] = VIA_DXS_MAX_VOLUME - chip->playback_volume[idx][1]; in snd_via8233_dxs_volume_get()
1692 struct via82xx *chip = snd_kcontrol_chip(kcontrol); in snd_via8233_pcmdxs_volume_get() local
1693 ucontrol->value.integer.value[0] = VIA_DXS_MAX_VOLUME - chip->playback_volume_c[0]; in snd_via8233_pcmdxs_volume_get()
1694 ucontrol->value.integer.value[1] = VIA_DXS_MAX_VOLUME - chip->playback_volume_c[1]; in snd_via8233_pcmdxs_volume_get()
1701 struct via82xx *chip = snd_kcontrol_chip(kcontrol); in snd_via8233_dxs_volume_put() local
1702 unsigned int idx = kcontrol->id.subdevice; in snd_via8233_dxs_volume_put()
1703 unsigned long port = chip->port + 0x10 * idx; in snd_via8233_dxs_volume_put()
1708 val = ucontrol->value.integer.value[i]; in snd_via8233_dxs_volume_put()
1711 val = VIA_DXS_MAX_VOLUME - val; in snd_via8233_dxs_volume_put()
1712 change |= val != chip->playback_volume[idx][i]; in snd_via8233_dxs_volume_put()
1714 chip->playback_volume[idx][i] = val; in snd_via8233_dxs_volume_put()
1724 struct via82xx *chip = snd_kcontrol_chip(kcontrol); in snd_via8233_pcmdxs_volume_put() local
1730 val = ucontrol->value.integer.value[i]; in snd_via8233_pcmdxs_volume_put()
1733 val = VIA_DXS_MAX_VOLUME - val; in snd_via8233_pcmdxs_volume_put()
1734 if (val != chip->playback_volume_c[i]) { in snd_via8233_pcmdxs_volume_put()
1736 chip->playback_volume_c[i] = val; in snd_via8233_pcmdxs_volume_put()
1738 unsigned long port = chip->port + 0x10 * idx; in snd_via8233_pcmdxs_volume_put()
1739 chip->playback_volume[idx][i] = val; in snd_via8233_pcmdxs_volume_put()
1747 static const DECLARE_TLV_DB_SCALE(db_scale_dxs, -4650, 150, 1);
1779 struct via82xx *chip = bus->private_data; in snd_via82xx_mixer_free_ac97_bus() local
1780 chip->ac97_bus = NULL; in snd_via82xx_mixer_free_ac97_bus()
1785 struct via82xx *chip = ac97->private_data; in snd_via82xx_mixer_free_ac97() local
1786 chip->ac97 = NULL; in snd_via82xx_mixer_free_ac97()
1794 .name = "Soltek SL-75DRV5",
1872 static int snd_via82xx_mixer_new(struct via82xx *chip, const char *quirk_override) in snd_via82xx_mixer_new() argument
1882 err = snd_ac97_bus(chip->card, 0, &ops, chip, &chip->ac97_bus); in snd_via82xx_mixer_new()
1885 chip->ac97_bus->private_free = snd_via82xx_mixer_free_ac97_bus; in snd_via82xx_mixer_new()
1886 chip->ac97_bus->clock = chip->ac97_clock; in snd_via82xx_mixer_new()
1889 ac97.private_data = chip; in snd_via82xx_mixer_new()
1891 ac97.pci = chip->pci; in snd_via82xx_mixer_new()
1893 err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97); in snd_via82xx_mixer_new()
1897 snd_ac97_tune_hardware(chip->ac97, ac97_quirks, quirk_override); in snd_via82xx_mixer_new()
1899 if (chip->chip_type != TYPE_VIA686) { in snd_via82xx_mixer_new()
1901 snd_ac97_update_bits(chip->ac97, AC97_EXTENDED_STATUS, 0x03 << 4, 0x03 << 4); in snd_via82xx_mixer_new()
1909 static int snd_via686_create_gameport(struct via82xx *chip, unsigned char *legacy) in snd_via686_create_gameport() argument
1914 return -ENODEV; in snd_via686_create_gameport()
1916 if (!devm_request_region(chip->card->dev, JOYSTICK_ADDR, 8, in snd_via686_create_gameport()
1918 dev_warn(chip->card->dev, "cannot reserve joystick port %#x\n", in snd_via686_create_gameport()
1920 return -EBUSY; in snd_via686_create_gameport()
1923 chip->gameport = gp = gameport_allocate_port(); in snd_via686_create_gameport()
1925 dev_err(chip->card->dev, in snd_via686_create_gameport()
1927 return -ENOMEM; in snd_via686_create_gameport()
1931 gameport_set_phys(gp, "pci%s/gameport0", pci_name(chip->pci)); in snd_via686_create_gameport()
1932 gameport_set_dev_parent(gp, &chip->pci->dev); in snd_via686_create_gameport()
1933 gp->io = JOYSTICK_ADDR; in snd_via686_create_gameport()
1937 pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, *legacy); in snd_via686_create_gameport()
1939 gameport_register_port(chip->gameport); in snd_via686_create_gameport()
1944 static void snd_via686_free_gameport(struct via82xx *chip) in snd_via686_free_gameport() argument
1946 if (chip->gameport) { in snd_via686_free_gameport()
1947 gameport_unregister_port(chip->gameport); in snd_via686_free_gameport()
1948 chip->gameport = NULL; in snd_via686_free_gameport()
1952 static inline int snd_via686_create_gameport(struct via82xx *chip, unsigned char *legacy) in snd_via686_create_gameport() argument
1954 return -ENOSYS; in snd_via686_create_gameport()
1956 static inline void snd_via686_free_gameport(struct via82xx *chip) { } in snd_via686_free_gameport() argument
1964 static int snd_via8233_init_misc(struct via82xx *chip) in snd_via8233_init_misc() argument
1969 caps = chip->chip_type == TYPE_VIA8233A ? 1 : 2; in snd_via8233_init_misc()
1972 err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_via8233_capture_source, chip)); in snd_via8233_init_misc()
1976 if (ac97_can_spdif(chip->ac97)) { in snd_via8233_init_misc()
1977 err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_via8233_dxs3_spdif_control, chip)); in snd_via8233_init_misc()
1981 if (chip->chip_type != TYPE_VIA8233A) { in snd_via8233_init_misc()
1985 if (!snd_ctl_find_id_mixer(chip->card, "PCM Playback Volume")) { in snd_via8233_init_misc()
1986 dev_info(chip->card->dev, in snd_via8233_init_misc()
1988 err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_via8233_pcmdxs_volume_control, chip)); in snd_via8233_init_misc()
1998 &snd_via8233_dxs_volume_control, chip); in snd_via8233_init_misc()
2000 return -ENOMEM; in snd_via8233_init_misc()
2001 kctl->id.subdevice = i; in snd_via8233_init_misc()
2002 err = snd_ctl_add(chip->card, kctl); in snd_via8233_init_misc()
2005 chip->dxs_controls[i] = kctl; in snd_via8233_init_misc()
2010 pci_read_config_byte(chip->pci, VIA8233_SPDIF_CTRL, &val); in snd_via8233_init_misc()
2013 pci_write_config_byte(chip->pci, VIA8233_SPDIF_CTRL, val); in snd_via8233_init_misc()
2018 static int snd_via686_init_misc(struct via82xx *chip) in snd_via686_init_misc() argument
2023 legacy = chip->old_legacy; in snd_via686_init_misc()
2024 legacy_cfg = chip->old_legacy_cfg; in snd_via686_init_misc()
2027 if (chip->revision >= VIA_REV_686_H) { in snd_via686_init_misc()
2031 pci_write_config_dword(chip->pci, 0x18, mpu_port | 0x01); in snd_via686_init_misc()
2032 chip->mpu_port_saved = mpu_port; in snd_via686_init_misc()
2034 mpu_port = pci_resource_start(chip->pci, 2); in snd_via686_init_misc()
2052 chip->mpu_res = devm_request_region(&chip->pci->dev, mpu_port, in snd_via686_init_misc()
2054 if (chip->mpu_res) { in snd_via686_init_misc()
2065 pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, legacy); in snd_via686_init_misc()
2066 pci_write_config_byte(chip->pci, VIA_PNP_CONTROL, legacy_cfg); in snd_via686_init_misc()
2067 if (chip->mpu_res) { in snd_via686_init_misc()
2068 if (snd_mpu401_uart_new(chip->card, 0, MPU401_HW_VIA686A, in snd_via686_init_misc()
2070 MPU401_INFO_IRQ_HOOK, -1, in snd_via686_init_misc()
2071 &chip->rmidi) < 0) { in snd_via686_init_misc()
2072 dev_warn(chip->card->dev, in snd_via686_init_misc()
2073 "unable to initialize MPU-401 at 0x%lx, skipping\n", in snd_via686_init_misc()
2079 pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, legacy); in snd_via686_init_misc()
2082 snd_via686_create_gameport(chip, &legacy); in snd_via686_init_misc()
2084 chip->legacy_saved = legacy; in snd_via686_init_misc()
2085 chip->legacy_cfg_saved = legacy_cfg; in snd_via686_init_misc()
2097 struct via82xx *chip = entry->private_data; in snd_via82xx_proc_read() local
2100 snd_iprintf(buffer, "%s\n\n", chip->card->longname); in snd_via82xx_proc_read()
2102 snd_iprintf(buffer, "%02x: %08x\n", i, inl(chip->port + i)); in snd_via82xx_proc_read()
2106 static void snd_via82xx_proc_init(struct via82xx *chip) in snd_via82xx_proc_init() argument
2108 snd_card_ro_proc_new(chip->card, "via82xx", chip, in snd_via82xx_proc_init()
2116 static int snd_via82xx_chip_init(struct via82xx *chip) in snd_via82xx_chip_init() argument
2123 if (chip->chip_type == TYPE_VIA686) in snd_via82xx_chip_init()
2125 pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, 0); in snd_via82xx_chip_init()
2127 pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval); in snd_via82xx_chip_init()
2130 pci_write_config_byte(chip->pci, VIA_ACLINK_CTRL, in snd_via82xx_chip_init()
2135 #if 1 /* FIXME: should we do full reset here for all chip models? */ in snd_via82xx_chip_init()
2136 pci_write_config_byte(chip->pci, VIA_ACLINK_CTRL, 0x00); in snd_via82xx_chip_init()
2140 pci_write_config_byte(chip->pci, VIA_ACLINK_CTRL, in snd_via82xx_chip_init()
2145 /* note - FM data out has trouble with non VRA codecs !! */ in snd_via82xx_chip_init()
2146 pci_write_config_byte(chip->pci, VIA_ACLINK_CTRL, VIA_ACLINK_CTRL_INIT); in snd_via82xx_chip_init()
2152 pci_read_config_byte(chip->pci, VIA_ACLINK_CTRL, &pval); in snd_via82xx_chip_init()
2155 /* note - FM data out has trouble with non VRA codecs !! */ in snd_via82xx_chip_init()
2156 pci_write_config_byte(chip->pci, VIA_ACLINK_CTRL, VIA_ACLINK_CTRL_INIT); in snd_via82xx_chip_init()
2163 pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval); in snd_via82xx_chip_init()
2169 val = snd_via82xx_codec_xread(chip); in snd_via82xx_chip_init()
2171 dev_err(chip->card->dev, in snd_via82xx_chip_init()
2175 snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ | in snd_via82xx_chip_init()
2179 snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ | in snd_via82xx_chip_init()
2183 val = snd_via82xx_codec_xread(chip); in snd_via82xx_chip_init()
2185 chip->ac97_secondary = 1; in snd_via82xx_chip_init()
2195 if (chip->chip_type == TYPE_VIA686) { in snd_via82xx_chip_init()
2197 pci_write_config_byte(chip->pci, VIA_FM_NMI_CTRL, 0); in snd_via82xx_chip_init()
2199 outl(0, VIAREG(chip, GPI_INTR)); in snd_via82xx_chip_init()
2202 if (chip->chip_type != TYPE_VIA686) { in snd_via82xx_chip_init()
2216 if (chip->chip_type != TYPE_VIA8233A) { in snd_via82xx_chip_init()
2219 unsigned long port = chip->port + 0x10 * idx; in snd_via82xx_chip_init()
2221 chip->playback_volume[idx][i]=chip->playback_volume_c[i]; in snd_via82xx_chip_init()
2222 outb(chip->playback_volume_c[i], in snd_via82xx_chip_init()
2237 struct via82xx *chip = card->private_data; in snd_via82xx_suspend() local
2241 for (i = 0; i < chip->num_devs; i++) in snd_via82xx_suspend()
2242 snd_via82xx_channel_reset(chip, &chip->devs[i]); in snd_via82xx_suspend()
2243 snd_ac97_suspend(chip->ac97); in snd_via82xx_suspend()
2246 if (chip->chip_type != TYPE_VIA686) { in snd_via82xx_suspend()
2247 pci_read_config_byte(chip->pci, VIA8233_SPDIF_CTRL, &chip->spdif_ctrl_saved); in snd_via82xx_suspend()
2248 chip->capture_src_saved[0] = inb(chip->port + VIA_REG_CAPTURE_CHANNEL); in snd_via82xx_suspend()
2249 chip->capture_src_saved[1] = inb(chip->port + VIA_REG_CAPTURE_CHANNEL + 0x10); in snd_via82xx_suspend()
2258 struct via82xx *chip = card->private_data; in snd_via82xx_resume() local
2261 snd_via82xx_chip_init(chip); in snd_via82xx_resume()
2263 if (chip->chip_type == TYPE_VIA686) { in snd_via82xx_resume()
2264 if (chip->mpu_port_saved) in snd_via82xx_resume()
2265 pci_write_config_dword(chip->pci, 0x18, chip->mpu_port_saved | 0x01); in snd_via82xx_resume()
2266 pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, chip->legacy_saved); in snd_via82xx_resume()
2267 pci_write_config_byte(chip->pci, VIA_PNP_CONTROL, chip->legacy_cfg_saved); in snd_via82xx_resume()
2269 pci_write_config_byte(chip->pci, VIA8233_SPDIF_CTRL, chip->spdif_ctrl_saved); in snd_via82xx_resume()
2270 outb(chip->capture_src_saved[0], chip->port + VIA_REG_CAPTURE_CHANNEL); in snd_via82xx_resume()
2271 outb(chip->capture_src_saved[1], chip->port + VIA_REG_CAPTURE_CHANNEL + 0x10); in snd_via82xx_resume()
2274 snd_ac97_resume(chip->ac97); in snd_via82xx_resume()
2276 for (i = 0; i < chip->num_devs; i++) in snd_via82xx_resume()
2277 snd_via82xx_channel_reset(chip, &chip->devs[i]); in snd_via82xx_resume()
2287 struct via82xx *chip = card->private_data; in snd_via82xx_free() local
2291 for (i = 0; i < chip->num_devs; i++) in snd_via82xx_free()
2292 snd_via82xx_channel_reset(chip, &chip->devs[i]); in snd_via82xx_free()
2294 if (chip->chip_type == TYPE_VIA686) { in snd_via82xx_free()
2295 snd_via686_free_gameport(chip); in snd_via82xx_free()
2296 pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, chip->old_legacy); in snd_via82xx_free()
2297 pci_write_config_byte(chip->pci, VIA_PNP_CONTROL, chip->old_legacy_cfg); in snd_via82xx_free()
2307 struct via82xx *chip = card->private_data; in snd_via82xx_create() local
2314 chip->chip_type = chip_type; in snd_via82xx_create()
2315 chip->revision = revision; in snd_via82xx_create()
2317 spin_lock_init(&chip->reg_lock); in snd_via82xx_create()
2318 spin_lock_init(&chip->rates[0].lock); in snd_via82xx_create()
2319 spin_lock_init(&chip->rates[1].lock); in snd_via82xx_create()
2320 chip->card = card; in snd_via82xx_create()
2321 chip->pci = pci; in snd_via82xx_create()
2322 chip->irq = -1; in snd_via82xx_create()
2324 pci_read_config_byte(pci, VIA_FUNC_ENABLE, &chip->old_legacy); in snd_via82xx_create()
2325 pci_read_config_byte(pci, VIA_PNP_CONTROL, &chip->old_legacy_cfg); in snd_via82xx_create()
2326 pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, in snd_via82xx_create()
2327 chip->old_legacy & ~(VIA_FUNC_ENABLE_SB|VIA_FUNC_ENABLE_FM)); in snd_via82xx_create()
2329 err = pci_request_regions(pci, card->driver); in snd_via82xx_create()
2332 chip->port = pci_resource_start(pci, 0); in snd_via82xx_create()
2333 if (devm_request_irq(&pci->dev, pci->irq, in snd_via82xx_create()
2337 KBUILD_MODNAME, chip)) { in snd_via82xx_create()
2338 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); in snd_via82xx_create()
2339 return -EBUSY; in snd_via82xx_create()
2341 chip->irq = pci->irq; in snd_via82xx_create()
2342 card->sync_irq = chip->irq; in snd_via82xx_create()
2343 card->private_free = snd_via82xx_free; in snd_via82xx_create()
2345 chip->ac97_clock = ac97_clock; in snd_via82xx_create()
2347 err = snd_via82xx_chip_init(chip); in snd_via82xx_create()
2364 { VIA_REV_PRE_8233, "VIA 8233-Pre", TYPE_VIA8233 },
2383 SND_PCI_QUIRK(0x1019, 0xaa01, "ESC K8T890-A", VIA_DXS_SRC),
2393 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte GA-7VAXP", VIA_DXS_ENABLE),
2396 SND_PCI_QUIRK(0x1462, 0x7142, "MSI K8MM-V", VIA_DXS_ENABLE),
2398 SND_PCI_QUIRK(0x147b, 0x1401, "ABIT KD7(-RAID)", VIA_DXS_ENABLE),
2399 SND_PCI_QUIRK(0x147b, 0x1411, "ABIT VA-20", VIA_DXS_ENABLE),
2410 SND_PCI_QUIRK(0x1695, 0x3005, "EPoX EP-8K9A", VIA_DXS_ENABLE),
2416 SND_PCI_QUIRK(0x1919, 0x200a, "Soltek SL-K8", VIA_DXS_NO_VRA),
2427 dev_dbg(&pci->dev, "DXS allow list for %s found\n", in check_dxs_list()
2429 return w->value; in check_dxs_list()
2439 dev_info(&pci->dev, "Assuming DXS channels with 48k fixed sample rate.\n"); in check_dxs_list()
2440 dev_info(&pci->dev, " Please try dxs_support=5 option\n"); in check_dxs_list()
2441 dev_info(&pci->dev, " and report if it works on your machine.\n"); in check_dxs_list()
2442 dev_info(&pci->dev, " For more details, read ALSA-Configuration.txt.\n"); in check_dxs_list()
2450 struct via82xx *chip; in __snd_via82xx_probe() local
2455 err = snd_devm_card_new(&pci->dev, index, id, THIS_MODULE, in __snd_via82xx_probe()
2456 sizeof(*chip), &card); in __snd_via82xx_probe()
2459 chip = card->private_data; in __snd_via82xx_probe()
2461 card_type = pci_id->driver_data; in __snd_via82xx_probe()
2464 strcpy(card->driver, "VIA686A"); in __snd_via82xx_probe()
2465 sprintf(card->shortname, "VIA 82C686A/B rev%x", pci->revision); in __snd_via82xx_probe()
2470 sprintf(card->shortname, "VIA 823x rev%x", pci->revision); in __snd_via82xx_probe()
2472 if (pci->revision == via823x_cards[i].revision) { in __snd_via82xx_probe()
2474 strcpy(card->shortname, via823x_cards[i].name); in __snd_via82xx_probe()
2480 dxs_support = check_dxs_list(pci, pci->revision); in __snd_via82xx_probe()
2490 strcpy(card->driver, "VIA8233A"); in __snd_via82xx_probe()
2491 else if (pci->revision >= VIA_REV_8237) in __snd_via82xx_probe()
2492 strcpy(card->driver, "VIA8237"); /* no slog assignment */ in __snd_via82xx_probe()
2494 strcpy(card->driver, "VIA8233"); in __snd_via82xx_probe()
2497 dev_err(card->dev, "invalid card type %d\n", card_type); in __snd_via82xx_probe()
2498 return -EINVAL; in __snd_via82xx_probe()
2501 err = snd_via82xx_create(card, pci, chip_type, pci->revision, in __snd_via82xx_probe()
2505 err = snd_via82xx_mixer_new(chip, ac97_quirk); in __snd_via82xx_probe()
2510 err = snd_via686_pcm_new(chip); in __snd_via82xx_probe()
2513 err = snd_via686_init_misc(chip); in __snd_via82xx_probe()
2518 err = snd_via8233a_pcm_new(chip); in __snd_via82xx_probe()
2521 // chip->dxs_fixed = 1; /* FIXME: use 48k for DXS #3? */ in __snd_via82xx_probe()
2523 err = snd_via8233_pcm_new(chip); in __snd_via82xx_probe()
2527 chip->dxs_fixed = 1; in __snd_via82xx_probe()
2529 chip->no_vra = 1; in __snd_via82xx_probe()
2531 chip->no_vra = 1; in __snd_via82xx_probe()
2532 chip->dxs_src = 1; in __snd_via82xx_probe()
2535 err = snd_via8233_init_misc(chip); in __snd_via82xx_probe()
2541 for (i = 0; i < chip->num_devs; i++) in __snd_via82xx_probe()
2542 snd_via82xx_channel_reset(chip, &chip->devs[i]); in __snd_via82xx_probe()
2544 snprintf(card->longname, sizeof(card->longname), in __snd_via82xx_probe()
2545 "%s with %s at %#lx, irq %d", card->shortname, in __snd_via82xx_probe()
2546 snd_ac97_get_short_name(chip->ac97), chip->port, chip->irq); in __snd_via82xx_probe()
2548 snd_via82xx_proc_init(chip); in __snd_via82xx_probe()
2560 return snd_card_free_on_error(&pci->dev, __snd_via82xx_probe(pci, pci_id)); in snd_via82xx_probe()