Lines Matching refs:viadev
124 #define VIADEV_REG(viadev, x) ((viadev)->port + VIA_REG_##x) argument
309 struct viadev { struct
366 struct viadev devs[VIA_MAX_DEVS];
408 static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substream, in build_via_table()
483 static int clean_via_table(struct viadev *dev, struct snd_pcm_substream *substream, in clean_via_table()
595 static void snd_via82xx_channel_reset(struct via82xx *chip, struct viadev *viadev) in snd_via82xx_channel_reset() argument
598 VIADEV_REG(viadev, OFFSET_CONTROL)); in snd_via82xx_channel_reset()
599 inb(VIADEV_REG(viadev, OFFSET_CONTROL)); in snd_via82xx_channel_reset()
602 outb(0x00, VIADEV_REG(viadev, OFFSET_CONTROL)); in snd_via82xx_channel_reset()
604 outb(0x03, VIADEV_REG(viadev, OFFSET_STATUS)); in snd_via82xx_channel_reset()
605 outb(0x00, VIADEV_REG(viadev, OFFSET_TYPE)); /* for via686 */ in snd_via82xx_channel_reset()
607 viadev->lastpos = 0; in snd_via82xx_channel_reset()
608 viadev->hwptr_done = 0; in snd_via82xx_channel_reset()
633 struct viadev *viadev = &chip->devs[i]; in snd_via686_interrupt() local
634 unsigned char c_status = inb(VIADEV_REG(viadev, OFFSET_STATUS)); in snd_via686_interrupt()
637 if (viadev->substream && viadev->running) { 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()
649 snd_pcm_period_elapsed(viadev->substream); in snd_via686_interrupt()
651 viadev->in_interrupt = 0; in snd_via686_interrupt()
653 outb(c_status, VIADEV_REG(viadev, OFFSET_STATUS)); /* ack */ in snd_via686_interrupt()
674 struct viadev *viadev = &chip->devs[i]; in snd_via8233_interrupt() local
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()
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()
704 viadev->in_interrupt = 0; in snd_via8233_interrupt()
706 outb(c_status, VIADEV_REG(viadev, OFFSET_STATUS)); /* ack */ in snd_via8233_interrupt()
723 struct viadev *viadev = substream->runtime->private_data; in snd_via82xx_pcm_trigger() local
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()
751 outb(val, VIADEV_REG(viadev, OFFSET_CONTROL)); in snd_via82xx_pcm_trigger()
753 snd_via82xx_channel_reset(chip, viadev); in snd_via82xx_pcm_trigger()
766 #define check_invalid_pos(viadev,pos) \ argument
767 ((pos) < viadev->lastpos && ((pos) >= viadev->bufsize2 ||\
768 viadev->lastpos < viadev->bufsize2))
771 struct viadev *viadev, 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()
780 if (res >= viadev->bufsize) in calc_linear_pos()
781 res -= viadev->bufsize; 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()
801 if (check_invalid_pos(viadev, res)) { 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()
812 if (check_invalid_pos(viadev, res)) { in calc_linear_pos()
815 res = viadev->lastpos; in calc_linear_pos()
828 struct viadev *viadev = substream->runtime->private_data; in snd_via686_pcm_pointer() local
831 if (snd_BUG_ON(!viadev->tbl_entries)) in snd_via686_pcm_pointer()
833 if (!(inb(VIADEV_REG(viadev, OFFSET_STATUS)) & VIA_REG_STAT_ACTIVE)) in snd_via686_pcm_pointer()
837 count = inl(VIADEV_REG(viadev, OFFSET_CURR_COUNT)) & 0xffffff; in snd_via686_pcm_pointer()
841 ptr = inl(VIADEV_REG(viadev, OFFSET_CURR_PTR)); 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()
859 struct viadev *viadev = substream->runtime->private_data; in snd_via8233_pcm_pointer() local
863 if (snd_BUG_ON(!viadev->tbl_entries)) in snd_via8233_pcm_pointer()
867 count = inl(VIADEV_REG(viadev, OFFSET_CURR_COUNT)); in snd_via8233_pcm_pointer()
868 status = viadev->in_interrupt; in snd_via8233_pcm_pointer()
870 status = inb(VIADEV_REG(viadev, OFFSET_STATUS)); in snd_via8233_pcm_pointer()
883 if (idx >= viadev->tbl_entries) { 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()
921 struct viadev *viadev = substream->runtime->private_data; in snd_via82xx_hw_params() local
923 return build_via_table(viadev, substream, chip->pci, in snd_via82xx_hw_params()
935 struct viadev *viadev = substream->runtime->private_data; in snd_via82xx_hw_free() local
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
948 outl((u32)viadev->table.addr, VIADEV_REG(viadev, OFFSET_TABLE_PTR)); 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()
965 ((viadev->reg_offset & 0x10) == 0 ? VIA_REG_TYPE_INT_LSAMPLE : 0) | in via686_setup_format()
967 VIA_REG_TYPE_INT_FLAG, VIADEV_REG(viadev, OFFSET_TYPE)); in via686_setup_format()
973 struct viadev *viadev = substream->runtime->private_data; in snd_via686_playback_prepare() local
978 via686_setup_format(chip, viadev, runtime); in snd_via686_playback_prepare()
985 struct viadev *viadev = substream->runtime->private_data; in snd_via686_capture_prepare() local
989 via686_setup_format(chip, viadev, runtime); in snd_via686_capture_prepare()
1019 struct viadev *viadev = substream->runtime->private_data; in snd_via8233_playback_prepare() local
1031 if (chip->spdif_on && viadev->reg_offset == 0x30) 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()
1043 VIADEV_REG(viadev, OFS_PLAYBACK_VOLUME_L)); in snd_via8233_playback_prepare()
1044 outb(chip->playback_volume[viadev->reg_offset / 0x10][1], in snd_via8233_playback_prepare()
1045 VIADEV_REG(viadev, OFS_PLAYBACK_VOLUME_R)); in snd_via8233_playback_prepare()
1050 VIADEV_REG(viadev, OFFSET_STOP_IDX)); in snd_via8233_playback_prepare()
1062 struct viadev *viadev = substream->runtime->private_data; in snd_via8233_multi_prepare() local
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()
1079 outb(fmt, VIADEV_REG(viadev, OFS_MULTPLAY_FORMAT)); in snd_via8233_multi_prepare()
1099 outl(0xff000000 | slots, VIADEV_REG(viadev, OFFSET_STOP_IDX)); in snd_via8233_multi_prepare()
1111 struct viadev *viadev = substream->runtime->private_data; in snd_via8233_capture_prepare() local
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()
1119 outb(VIA_REG_CAPTURE_FIFO_ENABLE, VIADEV_REG(viadev, OFS_CAPTURE_FIFO)); in snd_via8233_capture_prepare()
1123 VIADEV_REG(viadev, OFFSET_STOP_IDX)); in snd_via8233_capture_prepare()
1158 static int snd_via82xx_pcm_open(struct via82xx *chip, struct viadev *viadev, in snd_via82xx_pcm_open() argument
1169 ratep = &chip->rates[viadev->direction]; in snd_via82xx_pcm_open()
1172 if (chip->spdif_on && viadev->reg_offset == 0x30) { in snd_via82xx_pcm_open()
1176 } else if (chip->dxs_fixed && viadev->reg_offset < 0x40) { in snd_via82xx_pcm_open()
1180 } else if (chip->dxs_src && viadev->reg_offset < 0x40) { in snd_via82xx_pcm_open()
1188 int idx = viadev->direction ? AC97_RATES_ADC : AC97_RATES_FRONT_DAC; in snd_via82xx_pcm_open()
1210 runtime->private_data = viadev; in snd_via82xx_pcm_open()
1211 viadev->substream = substream; in snd_via82xx_pcm_open()
1223 struct viadev *viadev = &chip->devs[chip->playback_devno + substream->number]; in snd_via686_playback_open() local
1226 err = snd_via82xx_pcm_open(chip, viadev, substream); in snd_via686_playback_open()
1238 struct viadev *viadev; 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()
1267 struct viadev *viadev = &chip->devs[chip->multi_devno]; in snd_via8233_multi_open() local
1281 err = snd_via82xx_pcm_open(chip, viadev, substream); in snd_via8233_multi_open()
1298 struct viadev *viadev = &chip->devs[chip->capture_devno + substream->pcm->device]; in snd_via82xx_capture_open() local
1300 return snd_via82xx_pcm_open(chip, viadev, substream); in snd_via82xx_capture_open()
1309 struct viadev *viadev = substream->runtime->private_data; in snd_via82xx_pcm_close() local
1313 ratep = &chip->rates[viadev->direction]; in snd_via82xx_pcm_close()
1320 if (! viadev->direction) { in snd_via82xx_pcm_close()
1331 viadev->substream = NULL; in snd_via82xx_pcm_close()
1338 struct viadev *viadev = substream->runtime->private_data; in snd_via8233_playback_close() local
1341 stream = viadev->reg_offset / 0x10; in snd_via8233_playback_close()