]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/pci/via82xx.c
[ALSA] Remove xxx_t typedefs: PCI CS46xx
[linux-2.6-omap-h63xx.git] / sound / pci / via82xx.c
index b2779fb7d1a981810907b9aa5d55d1e569f70481..f0d8c7f24f27764529553b705ce22a8e97a41027 100644 (file)
@@ -41,6 +41,9 @@
  *       device for applications.
  *     - clean up the code, separate low-level initialization
  *       routines for each chipset.
+ *
+ * Sep. 26, 2005       Karsten Wiese <annabellesgarden@yahoo.de>
+ *     - Optimize position calculation for the 823x chips. 
  */
 
 #include <sound/driver.h>
@@ -102,7 +105,7 @@ MODULE_PARM_DESC(dxs_support, "Support for DXS channels (0 = auto, 1 = enable, 2
 
 /* just for backward compatibility */
 static int enable;
-module_param(enable, int, 0444);
+module_param(enable, bool, 0444);
 
 
 /* revision numbers for via686 */
@@ -131,6 +134,7 @@ module_param(enable, int, 0444);
 /* common offsets */
 #define VIA_REG_OFFSET_STATUS          0x00    /* byte - channel status */
 #define   VIA_REG_STAT_ACTIVE          0x80    /* RO */
+#define   VIA8233_SHADOW_STAT_ACTIVE   0x08    /* RO */
 #define   VIA_REG_STAT_PAUSED          0x40    /* RO */
 #define   VIA_REG_STAT_TRIGGER_QUEUED  0x08    /* RO */
 #define   VIA_REG_STAT_STOPPED         0x04    /* RWC */
@@ -329,6 +333,9 @@ struct via_dev {
        unsigned int fragsize;
        unsigned int bufsize;
        unsigned int bufsize2;
+       int hwptr_done;         /* processed frame position in the buffer */
+       int in_interrupt;
+       int shadow_shift;
 };
 
 
@@ -361,7 +368,8 @@ struct _snd_via82xx {
        unsigned int mpu_port_saved;
 #endif
 
-       unsigned char playback_volume[2]; /* for VIA8233/C/8235; default = 0 */
+       unsigned char playback_volume[4][2]; /* for VIA8233/C/8235; default = 0 */
+       unsigned char playback_volume_c[2]; /* for VIA8233/C/8235; default = 0 */
 
        unsigned int intr_mask; /* SGD_SHADOW mask to check interrupts */
 
@@ -394,8 +402,10 @@ struct _snd_via82xx {
 };
 
 static struct pci_device_id snd_via82xx_ids[] = {
-       { 0x1106, 0x3058, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_CARD_VIA686, },    /* 686A */
-       { 0x1106, 0x3059, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_CARD_VIA8233, },   /* VT8233 */
+       /* 0x1106, 0x3058 */
+       { PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_CARD_VIA686, },     /* 686A */
+       /* 0x1106, 0x3059 */
+       { PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8233_5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_CARD_VIA8233, },      /* VT8233 */
        { 0, }
 };
 
@@ -549,7 +559,7 @@ static void snd_via82xx_codec_write(ac97_t *ac97,
 {
        via82xx_t *chip = ac97->private_data;
        unsigned int xval;
-       
+
        xval = !ac97->num ? VIA_REG_AC97_CODEC_ID_PRIMARY : VIA_REG_AC97_CODEC_ID_SECONDARY;
        xval <<= VIA_REG_AC97_CODEC_ID_SHIFT;
        xval |= reg << VIA_REG_AC97_CMD_SHIFT;
@@ -597,14 +607,15 @@ static void snd_via82xx_channel_reset(via82xx_t *chip, viadev_t *viadev)
        outb(0x00, VIADEV_REG(viadev, OFFSET_TYPE)); /* for via686 */
        // outl(0, VIADEV_REG(viadev, OFFSET_CURR_PTR));
        viadev->lastpos = 0;
+       viadev->hwptr_done = 0;
 }
 
 
 /*
  *  Interrupt handler
+ *  Used for 686 and 8233A
  */
-
-static irqreturn_t snd_via82xx_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_via686_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
        via82xx_t *chip = dev_id;
        unsigned int status;
@@ -623,13 +634,23 @@ static irqreturn_t snd_via82xx_interrupt(int irq, void *dev_id, struct pt_regs *
        for (i = 0; i < chip->num_devs; i++) {
                viadev_t *viadev = &chip->devs[i];
                unsigned char c_status = inb(VIADEV_REG(viadev, OFFSET_STATUS));
-               c_status &= (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG|VIA_REG_STAT_STOPPED);
-               if (! c_status)
+               if (! (c_status & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG|VIA_REG_STAT_STOPPED)))
                        continue;
                if (viadev->substream && viadev->running) {
+                       /*
+                        * Update hwptr_done based on 'period elapsed'
+                        * interrupts. We'll use it, when the chip returns 0 
+                        * for OFFSET_CURR_COUNT.
+                        */
+                       if (c_status & VIA_REG_STAT_EOL)
+                               viadev->hwptr_done = 0;
+                       else
+                               viadev->hwptr_done += viadev->fragsize;
+                       viadev->in_interrupt = c_status;
                        spin_unlock(&chip->reg_lock);
                        snd_pcm_period_elapsed(viadev->substream);
                        spin_lock(&chip->reg_lock);
+                       viadev->in_interrupt = 0;
                }
                outb(c_status, VIADEV_REG(viadev, OFFSET_STATUS)); /* ack */
        }
@@ -637,6 +658,60 @@ static irqreturn_t snd_via82xx_interrupt(int irq, void *dev_id, struct pt_regs *
        return IRQ_HANDLED;
 }
 
+/*
+ *  Interrupt handler
+ */
+static irqreturn_t snd_via8233_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+       via82xx_t *chip = dev_id;
+       unsigned int status;
+       unsigned int i;
+       int irqreturn = 0;
+
+       /* check status for each stream */
+       spin_lock(&chip->reg_lock);
+       status = inl(VIAREG(chip, SGD_SHADOW));
+
+       for (i = 0; i < chip->num_devs; i++) {
+               viadev_t *viadev = &chip->devs[i];
+               snd_pcm_substream_t *substream;
+               unsigned char c_status, shadow_status;
+
+               shadow_status = (status >> viadev->shadow_shift) &
+                       (VIA8233_SHADOW_STAT_ACTIVE|VIA_REG_STAT_EOL|
+                        VIA_REG_STAT_FLAG);
+               c_status = shadow_status & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG);
+               if (!c_status)
+                       continue;
+
+               substream = viadev->substream;
+               if (substream && viadev->running) {
+                       /*
+                        * Update hwptr_done based on 'period elapsed'
+                        * interrupts. We'll use it, when the chip returns 0 
+                        * for OFFSET_CURR_COUNT.
+                        */
+                       if (c_status & VIA_REG_STAT_EOL)
+                               viadev->hwptr_done = 0;
+                       else
+                               viadev->hwptr_done += viadev->fragsize;
+                       viadev->in_interrupt = c_status;
+                       if (shadow_status & VIA8233_SHADOW_STAT_ACTIVE)
+                               viadev->in_interrupt |= VIA_REG_STAT_ACTIVE;
+                       spin_unlock(&chip->reg_lock);
+
+                       snd_pcm_period_elapsed(substream);
+
+                       spin_lock(&chip->reg_lock);
+                       viadev->in_interrupt = 0;
+               }
+               outb(c_status, VIADEV_REG(viadev, OFFSET_STATUS)); /* ack */
+               irqreturn = 1;
+       }
+       spin_unlock(&chip->reg_lock);
+       return IRQ_RETVAL(irqreturn);
+}
+
 /*
  *  PCM callbacks
  */
@@ -700,6 +775,8 @@ static inline unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, u
        size = viadev->idx_table[idx].size;
        base = viadev->idx_table[idx].offset;
        res = base + size - count;
+       if (res >= viadev->bufsize)
+               res -= viadev->bufsize;
 
        /* check the validity of the calculated position */
        if (size < count) {
@@ -729,9 +806,6 @@ static inline unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, u
                        }
                }
        }
-       viadev->lastpos = res; /* remember the last position */
-       if (res >= viadev->bufsize)
-               res -= viadev->bufsize;
        return res;
 }
 
@@ -759,6 +833,7 @@ static snd_pcm_uframes_t snd_via686_pcm_pointer(snd_pcm_substream_t *substream)
        else /* CURR_PTR holds the address + 8 */
                idx = ((ptr - (unsigned int)viadev->table.addr) / 8 - 1) % viadev->tbl_entries;
        res = calc_linear_pos(viadev, idx, count);
+       viadev->lastpos = res; /* remember the last position */
        spin_unlock(&chip->reg_lock);
 
        return bytes_to_frames(substream->runtime, res);
@@ -772,30 +847,44 @@ static snd_pcm_uframes_t snd_via8233_pcm_pointer(snd_pcm_substream_t *substream)
        via82xx_t *chip = snd_pcm_substream_chip(substream);
        viadev_t *viadev = (viadev_t *)substream->runtime->private_data;
        unsigned int idx, count, res;
-       int timeout = 5000;
+       int status;
        
        snd_assert(viadev->tbl_entries, return 0);
-       if (!(inb(VIADEV_REG(viadev, OFFSET_STATUS)) & VIA_REG_STAT_ACTIVE))
-               return 0;
+
        spin_lock(&chip->reg_lock);
-       do {
-               count = inl(VIADEV_REG(viadev, OFFSET_CURR_COUNT));
-               /* some mobos read 0 count */
-               if ((count & 0xffffff) || ! viadev->running)
-                       break;
-       } while (--timeout);
-       if (! timeout)
-               snd_printd(KERN_ERR "zero position is read\n");
-       idx = count >> 24;
-       if (idx >= viadev->tbl_entries) {
+       count = inl(VIADEV_REG(viadev, OFFSET_CURR_COUNT));
+       status = viadev->in_interrupt;
+       if (!status)
+               status = inb(VIADEV_REG(viadev, OFFSET_STATUS));
+
+       if (!(status & VIA_REG_STAT_ACTIVE)) {
+               res = 0;
+               goto unlock;
+       }
+       if (count & 0xffffff) {
+               idx = count >> 24;
+               if (idx >= viadev->tbl_entries) {
 #ifdef POINTER_DEBUG
-               printk("fail: invalid idx = %i/%i\n", idx, viadev->tbl_entries);
+                       printk(KERN_DEBUG "fail: invalid idx = %i/%i\n", idx, viadev->tbl_entries);
 #endif
-               res = viadev->lastpos;
+                       res = viadev->lastpos;
+               } else {
+                       count &= 0xffffff;
+                       res = calc_linear_pos(viadev, idx, count);
+               }
        } else {
-               count &= 0xffffff;
-               res = calc_linear_pos(viadev, idx, count);
-       }
+               res = viadev->hwptr_done;
+               if (!viadev->in_interrupt) {
+                       if (status & VIA_REG_STAT_EOL) {
+                               res = 0;
+                       } else
+                               if (status & VIA_REG_STAT_FLAG) {
+                                       res += viadev->fragsize;
+                               }
+               }
+       }                           
+unlock:
+       viadev->lastpos = res;
        spin_unlock(&chip->reg_lock);
 
        return bytes_to_frames(substream->runtime, res);
@@ -937,8 +1026,8 @@ static int snd_via8233_playback_prepare(snd_pcm_substream_t *substream)
        snd_assert((rbits & ~0xfffff) == 0, return -EINVAL);
        snd_via82xx_channel_reset(chip, viadev);
        snd_via82xx_set_table_ptr(chip, viadev);
-       outb(chip->playback_volume[0], VIADEV_REG(viadev, OFS_PLAYBACK_VOLUME_L));
-       outb(chip->playback_volume[1], VIADEV_REG(viadev, OFS_PLAYBACK_VOLUME_R));
+       outb(chip->playback_volume[viadev->reg_offset / 0x10][0], VIADEV_REG(viadev, OFS_PLAYBACK_VOLUME_L));
+       outb(chip->playback_volume[viadev->reg_offset / 0x10][1], VIADEV_REG(viadev, OFS_PLAYBACK_VOLUME_R));
        outl((runtime->format == SNDRV_PCM_FORMAT_S16_LE ? VIA8233_REG_TYPE_16BIT : 0) | /* format */
             (runtime->channels > 1 ? VIA8233_REG_TYPE_STEREO : 0) | /* stereo */
             rbits | /* rate */
@@ -1240,9 +1329,10 @@ static snd_pcm_ops_t snd_via8233_capture_ops = {
 };
 
 
-static void init_viadev(via82xx_t *chip, int idx, unsigned int reg_offset, int direction)
+static void init_viadev(via82xx_t *chip, int idx, unsigned int reg_offset, int shadow_pos, int direction)
 {
        chip->devs[idx].reg_offset = reg_offset;
+       chip->devs[idx].shadow_shift = shadow_pos * 4;
        chip->devs[idx].direction = direction;
        chip->devs[idx].port = chip->port + reg_offset;
 }
@@ -1272,9 +1362,9 @@ static int __devinit snd_via8233_pcm_new(via82xx_t *chip)
        chip->pcms[0] = pcm;
        /* set up playbacks */
        for (i = 0; i < 4; i++)
-               init_viadev(chip, i, 0x10 * i, 0);
+               init_viadev(chip, i, 0x10 * i, i, 0);
        /* capture */
-       init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 1);
+       init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1);
 
        if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
                                                         snd_dma_pci_data(chip->pci), 64*1024, 128*1024)) < 0)
@@ -1290,9 +1380,9 @@ static int __devinit snd_via8233_pcm_new(via82xx_t *chip)
        strcpy(pcm->name, chip->card->shortname);
        chip->pcms[1] = pcm;
        /* set up playback */
-       init_viadev(chip, chip->multi_devno, VIA_REG_MULTPLAY_STATUS, 0);
+       init_viadev(chip, chip->multi_devno, VIA_REG_MULTPLAY_STATUS, 4, 0);
        /* set up capture */
-       init_viadev(chip, chip->capture_devno + 1, VIA_REG_CAPTURE_8233_STATUS + 0x10, 1);
+       init_viadev(chip, chip->capture_devno + 1, VIA_REG_CAPTURE_8233_STATUS + 0x10, 7, 1);
 
        if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
                                                         snd_dma_pci_data(chip->pci), 64*1024, 128*1024)) < 0)
@@ -1325,9 +1415,9 @@ static int __devinit snd_via8233a_pcm_new(via82xx_t *chip)
        strcpy(pcm->name, chip->card->shortname);
        chip->pcms[0] = pcm;
        /* set up playback */
-       init_viadev(chip, chip->multi_devno, VIA_REG_MULTPLAY_STATUS, 0);
+       init_viadev(chip, chip->multi_devno, VIA_REG_MULTPLAY_STATUS, 4, 0);
        /* capture */
-       init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 1);
+       init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1);
 
        if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
                                                         snd_dma_pci_data(chip->pci), 64*1024, 128*1024)) < 0)
@@ -1346,7 +1436,7 @@ static int __devinit snd_via8233a_pcm_new(via82xx_t *chip)
        strcpy(pcm->name, chip->card->shortname);
        chip->pcms[1] = pcm;
        /* set up playback */
-       init_viadev(chip, chip->playback_devno, 0x30, 0);
+       init_viadev(chip, chip->playback_devno, 0x30, 3, 0);
 
        if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
                                                         snd_dma_pci_data(chip->pci), 64*1024, 128*1024)) < 0)
@@ -1376,8 +1466,8 @@ static int __devinit snd_via686_pcm_new(via82xx_t *chip)
        pcm->private_data = chip;
        strcpy(pcm->name, chip->card->shortname);
        chip->pcms[0] = pcm;
-       init_viadev(chip, 0, VIA_REG_PLAYBACK_STATUS, 0);
-       init_viadev(chip, 1, VIA_REG_CAPTURE_STATUS, 1);
+       init_viadev(chip, 0, VIA_REG_PLAYBACK_STATUS, 0, 0);
+       init_viadev(chip, 1, VIA_REG_CAPTURE_STATUS, 0, 1);
 
        if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
                                                         snd_dma_pci_data(chip->pci), 64*1024, 128*1024)) < 0)
@@ -1498,12 +1588,44 @@ static int snd_via8233_dxs_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_in
 static int snd_via8233_dxs_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
 {
        via82xx_t *chip = snd_kcontrol_chip(kcontrol);
-       ucontrol->value.integer.value[0] = VIA_DXS_MAX_VOLUME - chip->playback_volume[0];
-       ucontrol->value.integer.value[1] = VIA_DXS_MAX_VOLUME - chip->playback_volume[1];
+       unsigned int idx = snd_ctl_get_ioff(kcontrol, &ucontrol->id);
+
+       ucontrol->value.integer.value[0] = VIA_DXS_MAX_VOLUME - chip->playback_volume[idx][0];
+       ucontrol->value.integer.value[1] = VIA_DXS_MAX_VOLUME - chip->playback_volume[idx][1];
+       return 0;
+}
+
+static int snd_via8233_pcmdxs_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+       via82xx_t *chip = snd_kcontrol_chip(kcontrol);
+       ucontrol->value.integer.value[0] = VIA_DXS_MAX_VOLUME - chip->playback_volume_c[0];
+       ucontrol->value.integer.value[1] = VIA_DXS_MAX_VOLUME - chip->playback_volume_c[1];
        return 0;
 }
 
 static int snd_via8233_dxs_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+       via82xx_t *chip = snd_kcontrol_chip(kcontrol);
+       unsigned int idx = snd_ctl_get_ioff(kcontrol, &ucontrol->id);
+       unsigned long port = chip->port + 0x10 * idx;
+       unsigned char val;
+       int i, change = 0;
+
+       for (i = 0; i < 2; i++) {
+               val = ucontrol->value.integer.value[i];
+               if (val > VIA_DXS_MAX_VOLUME)
+                       val = VIA_DXS_MAX_VOLUME;
+               val = VIA_DXS_MAX_VOLUME - val;
+               change |= val != chip->playback_volume[idx][i];
+               if (change) {
+                       chip->playback_volume[idx][i] = val;
+                       outb(val, port + VIA_REG_OFS_PLAYBACK_VOLUME_L + i);
+               }
+       }
+       return change;
+}
+
+static int snd_via8233_pcmdxs_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
 {
        via82xx_t *chip = snd_kcontrol_chip(kcontrol);
        unsigned int idx;
@@ -1515,11 +1637,12 @@ static int snd_via8233_dxs_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_val
                if (val > VIA_DXS_MAX_VOLUME)
                        val = VIA_DXS_MAX_VOLUME;
                val = VIA_DXS_MAX_VOLUME - val;
-               if (val != chip->playback_volume[i]) {
+               if (val != chip->playback_volume_c[i]) {
                        change = 1;
-                       chip->playback_volume[i] = val;
+                       chip->playback_volume_c[i] = val;
                        for (idx = 0; idx < 4; idx++) {
                                unsigned long port = chip->port + 0x10 * idx;
+                               chip->playback_volume[idx][i] = val;
                                outb(val, port + VIA_REG_OFS_PLAYBACK_VOLUME_L + i);
                        }
                }
@@ -1527,10 +1650,19 @@ static int snd_via8233_dxs_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_val
        return change;
 }
 
-static snd_kcontrol_new_t snd_via8233_dxs_volume_control __devinitdata = {
+static snd_kcontrol_new_t snd_via8233_pcmdxs_volume_control __devinitdata = {
        .name = "PCM Playback Volume",
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
        .info = snd_via8233_dxs_volume_info,
+       .get = snd_via8233_pcmdxs_volume_get,
+       .put = snd_via8233_pcmdxs_volume_put,
+};
+
+static snd_kcontrol_new_t snd_via8233_dxs_volume_control __devinitdata = {
+       .name = "VIA DXS Playback Volume",
+       .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+       .count = 4,
+       .info = snd_via8233_dxs_volume_info,
        .get = snd_via8233_dxs_volume_get,
        .put = snd_via8233_dxs_volume_put,
 };
@@ -1655,8 +1787,7 @@ static int __devinit snd_via686_create_gameport(via82xx_t *chip, unsigned char *
        chip->gameport = gp = gameport_allocate_port();
        if (!gp) {
                printk(KERN_ERR "via82xx: cannot allocate memory for gameport\n");
-               release_resource(r);
-               kfree_nocheck(r);
+               release_and_free_resource(r);
                return -ENOMEM;
        }
 
@@ -1682,8 +1813,7 @@ static void snd_via686_free_gameport(via82xx_t *chip)
 
                gameport_unregister_port(chip->gameport);
                chip->gameport = NULL;
-               release_resource(r);
-               kfree_nocheck(r);
+               release_and_free_resource(r);
        }
 }
 #else
@@ -1725,12 +1855,19 @@ static int __devinit snd_via8233_init_misc(via82xx_t *chip)
                strcpy(sid.name, "PCM Playback Volume");
                sid.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
                if (! snd_ctl_find_id(chip->card, &sid)) {
+                       snd_printd(KERN_INFO "Using DXS as PCM Playback\n");
+                       err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_via8233_pcmdxs_volume_control, chip));
+                       if (err < 0)
+                               return err;
+               }
+               else /* Using DXS when PCM emulation is enabled is really weird */
+               {
+                       /* Standalone DXS controls */
                        err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_via8233_dxs_volume_control, chip));
                        if (err < 0)
                                return err;
                }
        }
-
        /* select spdif data slot 10/11 */
        pci_read_config_byte(chip->pci, VIA8233_SPDIF_CTRL, &val);
        val = (val & ~VIA8233_SPDIF_SLOT_MASK) | VIA8233_SPDIF_SLOT_1011;
@@ -1890,12 +2027,11 @@ static int snd_via82xx_chip_init(via82xx_t *chip)
                pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval);
                if (pval & VIA_ACLINK_C00_READY) /* primary codec ready */
                        break;
-               set_current_state(TASK_UNINTERRUPTIBLE);
-               schedule_timeout(1);
+               schedule_timeout_uninterruptible(1);
        } while (time_before(jiffies, end_time));
 
        if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)
-               snd_printk("AC'97 codec is not ready [0x%x]\n", val);
+               snd_printk(KERN_ERR "AC'97 codec is not ready [0x%x]\n", val);
 
 #if 0 /* FIXME: we don't support the second codec yet so skip the detection now.. */
        snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ |
@@ -1910,8 +2046,7 @@ static int snd_via82xx_chip_init(via82xx_t *chip)
                        chip->ac97_secondary = 1;
                        goto __ac97_ok2;
                }
-               set_current_state(TASK_INTERRUPTIBLE);
-               schedule_timeout(1);
+               schedule_timeout_interruptible(1);
        } while (time_before(jiffies, end_time));
        /* This is ok, the most of motherboards have only one codec */
 
@@ -1943,8 +2078,10 @@ static int snd_via82xx_chip_init(via82xx_t *chip)
                int i, idx;
                for (idx = 0; idx < 4; idx++) {
                        unsigned long port = chip->port + 0x10 * idx;
-                       for (i = 0; i < 2; i++)
-                               outb(chip->playback_volume[i], port + VIA_REG_OFS_PLAYBACK_VOLUME_L + i);
+                       for (i = 0; i < 2; i++) {
+                               chip->playback_volume[idx][i]=chip->playback_volume_c[i];
+                               outb(chip->playback_volume_c[i], port + VIA_REG_OFS_PLAYBACK_VOLUME_L + i);
+                       }
                }
        }
 
@@ -2023,10 +2160,7 @@ static int snd_via82xx_free(via82xx_t *chip)
       __end_hw:
        if (chip->irq >= 0)
                free_irq(chip->irq, (void *)chip);
-       if (chip->mpu_res) {
-               release_resource(chip->mpu_res);
-               kfree_nocheck(chip->mpu_res);
-       }
+       release_and_free_resource(chip->mpu_res);
        pci_release_regions(chip->pci);
 
        if (chip->chip_type == TYPE_VIA686) {
@@ -2087,9 +2221,12 @@ static int __devinit snd_via82xx_create(snd_card_t * card,
                return err;
        }
        chip->port = pci_resource_start(pci, 0);
-       if (request_irq(pci->irq, snd_via82xx_interrupt, SA_INTERRUPT|SA_SHIRQ,
+       if (request_irq(pci->irq,
+                       chip_type == TYPE_VIA8233 ?
+                       snd_via8233_interrupt : snd_via686_interrupt,
+                       SA_INTERRUPT|SA_SHIRQ,
                        card->driver, (void *)chip)) {
-               snd_printk("unable to grab IRQ %d\n", pci->irq);
+               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
                snd_via82xx_free(chip);
                return -EBUSY;
        }
@@ -2170,6 +2307,7 @@ static int __devinit check_dxs_list(struct pci_dev *pci)
                { .subvendor = 0x1458, .subdevice = 0xa002, .action = VIA_DXS_ENABLE }, /* Gigabyte GA-7VAXP */
                { .subvendor = 0x1462, .subdevice = 0x0080, .action = VIA_DXS_SRC }, /* MSI K8T Neo-FIS2R */
                { .subvendor = 0x1462, .subdevice = 0x0430, .action = VIA_DXS_SRC }, /* MSI 7142 (K8MM-V) */
+               { .subvendor = 0x1462, .subdevice = 0x0470, .action = VIA_DXS_SRC }, /* MSI KT880 Delta-FSR */
                { .subvendor = 0x1462, .subdevice = 0x3800, .action = VIA_DXS_ENABLE }, /* MSI KT266 */
                { .subvendor = 0x1462, .subdevice = 0x5901, .action = VIA_DXS_NO_VRA }, /* MSI KT6 Delta-SR */
                { .subvendor = 0x1462, .subdevice = 0x7023, .action = VIA_DXS_NO_VRA }, /* MSI K8T Neo2-FI */
@@ -2181,6 +2319,7 @@ static int __devinit check_dxs_list(struct pci_dev *pci)
                { .subvendor = 0x147b, .subdevice = 0x1415, .action = VIA_DXS_NO_VRA }, /* Abit AV8 */
                { .subvendor = 0x14ff, .subdevice = 0x0403, .action = VIA_DXS_ENABLE }, /* Twinhead mobo */
                { .subvendor = 0x14ff, .subdevice = 0x0408, .action = VIA_DXS_SRC }, /* Twinhead laptop */
+               { .subvendor = 0x1558, .subdevice = 0x4701, .action = VIA_DXS_SRC }, /* Clevo D470 */
                { .subvendor = 0x1584, .subdevice = 0x8120, .action = VIA_DXS_ENABLE }, /* Gericom/Targa/Vobis/Uniwill laptop */
                { .subvendor = 0x1584, .subdevice = 0x8123, .action = VIA_DXS_NO_VRA }, /* Uniwill (Targa Visionary XP-210) */
                { .subvendor = 0x161f, .subdevice = 0x202b, .action = VIA_DXS_NO_VRA }, /* Amira Note book */
@@ -2340,7 +2479,6 @@ static void __devexit snd_via82xx_remove(struct pci_dev *pci)
 
 static struct pci_driver driver = {
        .name = "VIA 82xx Audio",
-       .owner = THIS_MODULE,
        .id_table = snd_via82xx_ids,
        .probe = snd_via82xx_probe,
        .remove = __devexit_p(snd_via82xx_remove),