H A D | via82xx.c | 139 #define VIADEV_REG(viadev, x) ((viadev)->port + VIA_REG_##x) 324 struct viadev { struct 383 struct viadev devs[VIA_MAX_DEVS]; 425 static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substream, build_via_table() 496 static int clean_via_table(struct viadev *dev, struct snd_pcm_substream *substream, clean_via_table() 607 static void snd_via82xx_channel_reset(struct via82xx *chip, struct viadev *viadev) snd_via82xx_channel_reset() argument 610 VIADEV_REG(viadev, OFFSET_CONTROL)); snd_via82xx_channel_reset() 611 inb(VIADEV_REG(viadev, OFFSET_CONTROL)); snd_via82xx_channel_reset() 614 outb(0x00, VIADEV_REG(viadev, OFFSET_CONTROL)); snd_via82xx_channel_reset() 616 outb(0x03, VIADEV_REG(viadev, OFFSET_STATUS)); snd_via82xx_channel_reset() 617 outb(0x00, VIADEV_REG(viadev, OFFSET_TYPE)); /* for via686 */ snd_via82xx_channel_reset() 618 // outl(0, VIADEV_REG(viadev, OFFSET_CURR_PTR)); snd_via82xx_channel_reset() 619 viadev->lastpos = 0; snd_via82xx_channel_reset() 620 viadev->hwptr_done = 0; snd_via82xx_channel_reset() 645 struct viadev *viadev = &chip->devs[i]; snd_via686_interrupt() local 646 unsigned char c_status = inb(VIADEV_REG(viadev, OFFSET_STATUS)); snd_via686_interrupt() 649 if (viadev->substream && viadev->running) { snd_via686_interrupt() 656 viadev->hwptr_done = 0; snd_via686_interrupt() 658 viadev->hwptr_done += viadev->fragsize; snd_via686_interrupt() 659 viadev->in_interrupt = c_status; snd_via686_interrupt() 661 snd_pcm_period_elapsed(viadev->substream); snd_via686_interrupt() 663 viadev->in_interrupt = 0; snd_via686_interrupt() 665 outb(c_status, VIADEV_REG(viadev, OFFSET_STATUS)); /* ack */ snd_via686_interrupt() 686 struct viadev *viadev = &chip->devs[i]; snd_via8233_interrupt() local 690 shadow_status = (status >> viadev->shadow_shift) & snd_via8233_interrupt() 697 substream = viadev->substream; snd_via8233_interrupt() 698 if (substream && viadev->running) { snd_via8233_interrupt() 705 viadev->hwptr_done = 0; snd_via8233_interrupt() 707 viadev->hwptr_done += viadev->fragsize; snd_via8233_interrupt() 708 viadev->in_interrupt = c_status; snd_via8233_interrupt() 710 viadev->in_interrupt |= VIA_REG_STAT_ACTIVE; snd_via8233_interrupt() 716 viadev->in_interrupt = 0; snd_via8233_interrupt() 718 outb(c_status, VIADEV_REG(viadev, OFFSET_STATUS)); /* ack */ snd_via8233_interrupt() 735 struct viadev *viadev = substream->runtime->private_data; snd_via82xx_pcm_trigger() local 746 viadev->running = 1; snd_via82xx_pcm_trigger() 751 viadev->running = 0; snd_via82xx_pcm_trigger() 755 viadev->running = 0; snd_via82xx_pcm_trigger() 758 viadev->running = 1; snd_via82xx_pcm_trigger() 763 outb(val, VIADEV_REG(viadev, OFFSET_CONTROL)); snd_via82xx_pcm_trigger() 765 snd_via82xx_channel_reset(chip, viadev); snd_via82xx_pcm_trigger() 778 #define check_invalid_pos(viadev,pos) \ 779 ((pos) < viadev->lastpos && ((pos) >= viadev->bufsize2 ||\ 780 viadev->lastpos < viadev->bufsize2)) 783 struct viadev *viadev, calc_linear_pos() 789 size = viadev->idx_table[idx].size; calc_linear_pos() 790 base = viadev->idx_table[idx].offset; calc_linear_pos() 792 if (res >= viadev->bufsize) calc_linear_pos() 793 res -= viadev->bufsize; calc_linear_pos() 800 res = viadev->lastpos; calc_linear_pos() 807 int delta = res - viadev->lastpos; calc_linear_pos() 809 delta += viadev->bufsize; calc_linear_pos() 810 if ((unsigned int)delta > viadev->fragsize) calc_linear_pos() 813 if (check_invalid_pos(viadev, res)) { calc_linear_pos() 817 idx, viadev->tbl_entries, calc_linear_pos() 818 viadev->lastpos, viadev->bufsize2, calc_linear_pos() 819 viadev->idx_table[idx].offset, calc_linear_pos() 820 viadev->idx_table[idx].size, count); calc_linear_pos() 824 if (check_invalid_pos(viadev, res)) { calc_linear_pos() 827 res = viadev->lastpos; calc_linear_pos() 840 struct viadev *viadev = substream->runtime->private_data; snd_via686_pcm_pointer() local 843 if (snd_BUG_ON(!viadev->tbl_entries)) snd_via686_pcm_pointer() 845 if (!(inb(VIADEV_REG(viadev, OFFSET_STATUS)) & VIA_REG_STAT_ACTIVE)) snd_via686_pcm_pointer() 849 count = inl(VIADEV_REG(viadev, OFFSET_CURR_COUNT)) & 0xffffff; snd_via686_pcm_pointer() 853 ptr = inl(VIADEV_REG(viadev, OFFSET_CURR_PTR)); snd_via686_pcm_pointer() 854 if (ptr <= (unsigned int)viadev->table.addr) snd_via686_pcm_pointer() 857 idx = ((ptr - (unsigned int)viadev->table.addr) / 8 - 1) % viadev->tbl_entries; snd_via686_pcm_pointer() 858 res = calc_linear_pos(chip, viadev, idx, count); snd_via686_pcm_pointer() 859 viadev->lastpos = res; /* remember the last position */ snd_via686_pcm_pointer() 871 struct viadev *viadev = substream->runtime->private_data; snd_via8233_pcm_pointer() local 875 if (snd_BUG_ON(!viadev->tbl_entries)) snd_via8233_pcm_pointer() 879 count = inl(VIADEV_REG(viadev, OFFSET_CURR_COUNT)); snd_via8233_pcm_pointer() 880 status = viadev->in_interrupt; snd_via8233_pcm_pointer() 882 status = inb(VIADEV_REG(viadev, OFFSET_STATUS)); snd_via8233_pcm_pointer() 895 if (idx >= viadev->tbl_entries) { snd_via8233_pcm_pointer() 899 viadev->tbl_entries); snd_via8233_pcm_pointer() 901 res = viadev->lastpos; snd_via8233_pcm_pointer() 904 res = calc_linear_pos(chip, viadev, idx, count); snd_via8233_pcm_pointer() 907 res = viadev->hwptr_done; snd_via8233_pcm_pointer() 908 if (!viadev->in_interrupt) { snd_via8233_pcm_pointer() 913 res += viadev->fragsize; snd_via8233_pcm_pointer() 918 viadev->lastpos = res; snd_via8233_pcm_pointer() 933 struct viadev *viadev = substream->runtime->private_data; snd_via82xx_hw_params() local 939 err = build_via_table(viadev, substream, chip->pci, snd_via82xx_hw_params() 955 struct viadev *viadev = substream->runtime->private_data; snd_via82xx_hw_free() local 957 clean_via_table(viadev, substream, chip->pci); snd_via82xx_hw_free() 966 static void snd_via82xx_set_table_ptr(struct via82xx *chip, struct viadev *viadev) snd_via82xx_set_table_ptr() argument 969 outl((u32)viadev->table.addr, VIADEV_REG(viadev, OFFSET_TABLE_PTR)); snd_via82xx_set_table_ptr() 977 static void via686_setup_format(struct via82xx *chip, struct viadev *viadev, via686_setup_format() argument 980 snd_via82xx_channel_reset(chip, viadev); via686_setup_format() 982 snd_via82xx_set_table_ptr(chip, viadev); via686_setup_format() 986 ((viadev->reg_offset & 0x10) == 0 ? VIA_REG_TYPE_INT_LSAMPLE : 0) | via686_setup_format() 988 VIA_REG_TYPE_INT_FLAG, VIADEV_REG(viadev, OFFSET_TYPE)); via686_setup_format() 994 struct viadev *viadev = substream->runtime->private_data; snd_via686_playback_prepare() local 999 via686_setup_format(chip, viadev, runtime); snd_via686_playback_prepare() 1006 struct viadev *viadev = substream->runtime->private_data; snd_via686_capture_prepare() local 1010 via686_setup_format(chip, viadev, runtime); snd_via686_capture_prepare() 1040 struct viadev *viadev = substream->runtime->private_data; snd_via8233_playback_prepare() local 1051 if (chip->spdif_on && viadev->reg_offset == 0x30) snd_via8233_playback_prepare() 1060 snd_via82xx_channel_reset(chip, viadev); snd_via8233_playback_prepare() 1061 snd_via82xx_set_table_ptr(chip, viadev); snd_via8233_playback_prepare() 1062 outb(chip->playback_volume[viadev->reg_offset / 0x10][0], snd_via8233_playback_prepare() 1063 VIADEV_REG(viadev, OFS_PLAYBACK_VOLUME_L)); snd_via8233_playback_prepare() 1064 outb(chip->playback_volume[viadev->reg_offset / 0x10][1], snd_via8233_playback_prepare() 1065 VIADEV_REG(viadev, OFS_PLAYBACK_VOLUME_R)); snd_via8233_playback_prepare() 1070 VIADEV_REG(viadev, OFFSET_STOP_IDX)); snd_via8233_playback_prepare() 1082 struct viadev *viadev = substream->runtime->private_data; snd_via8233_multi_prepare() local 1093 snd_via82xx_channel_reset(chip, viadev); snd_via8233_multi_prepare() 1094 snd_via82xx_set_table_ptr(chip, viadev); snd_via8233_multi_prepare() 1099 outb(fmt, VIADEV_REG(viadev, OFS_MULTPLAY_FORMAT)); snd_via8233_multi_prepare() 1119 outl(0xff000000 | slots, VIADEV_REG(viadev, OFFSET_STOP_IDX)); snd_via8233_multi_prepare() 1131 struct viadev *viadev = substream->runtime->private_data; snd_via8233_capture_prepare() local 1137 snd_via82xx_channel_reset(chip, viadev); snd_via8233_capture_prepare() 1138 snd_via82xx_set_table_ptr(chip, viadev); snd_via8233_capture_prepare() 1139 outb(VIA_REG_CAPTURE_FIFO_ENABLE, VIADEV_REG(viadev, OFS_CAPTURE_FIFO)); snd_via8233_capture_prepare() 1143 VIADEV_REG(viadev, OFFSET_STOP_IDX)); snd_via8233_capture_prepare() 1178 static int snd_via82xx_pcm_open(struct via82xx *chip, struct viadev *viadev, snd_via82xx_pcm_open() argument 1189 ratep = &chip->rates[viadev->direction]; snd_via82xx_pcm_open() 1192 if (chip->spdif_on && viadev->reg_offset == 0x30) { snd_via82xx_pcm_open() 1196 } else if (chip->dxs_fixed && viadev->reg_offset < 0x40) { snd_via82xx_pcm_open() 1200 } else if (chip->dxs_src && viadev->reg_offset < 0x40) { snd_via82xx_pcm_open() 1208 int idx = viadev->direction ? AC97_RATES_ADC : AC97_RATES_FRONT_DAC; snd_via82xx_pcm_open() 1229 runtime->private_data = viadev; snd_via82xx_pcm_open() 1230 viadev->substream = substream; snd_via82xx_pcm_open() 1242 struct viadev *viadev = &chip->devs[chip->playback_devno + substream->number]; snd_via686_playback_open() local 1245 if ((err = snd_via82xx_pcm_open(chip, viadev, substream)) < 0) snd_via686_playback_open() 1256 struct viadev *viadev; snd_via8233_playback_open() local 1260 viadev = &chip->devs[chip->playback_devno + substream->number]; snd_via8233_playback_open() 1261 if ((err = snd_via82xx_pcm_open(chip, viadev, substream)) < 0) snd_via8233_playback_open() 1263 stream = viadev->reg_offset / 0x10; snd_via8233_playback_open() 1284 struct viadev *viadev = &chip->devs[chip->multi_devno]; snd_via8233_multi_open() local 1298 if ((err = snd_via82xx_pcm_open(chip, viadev, substream)) < 0) snd_via8233_multi_open() 1314 struct viadev *viadev = &chip->devs[chip->capture_devno + substream->pcm->device]; snd_via82xx_capture_open() local 1316 return snd_via82xx_pcm_open(chip, viadev, substream); snd_via82xx_capture_open() 1325 struct viadev *viadev = substream->runtime->private_data; snd_via82xx_pcm_close() local 1329 ratep = &chip->rates[viadev->direction]; snd_via82xx_pcm_close() 1336 if (! viadev->direction) { snd_via82xx_pcm_close() 1347 viadev->substream = NULL; snd_via82xx_pcm_close() 1354 struct viadev *viadev = substream->runtime->private_data; snd_via8233_playback_close() local 1357 stream = viadev->reg_offset / 0x10; snd_via8233_playback_close() 782 calc_linear_pos(struct via82xx *chip, struct viadev *viadev, unsigned int idx, unsigned int count) calc_linear_pos() argument
|