sound: use DEFINE_PCI_DEVICE_TABLE
[safe/jmp/linux-2.6] / sound / pci / ice1712 / ice1712.c
index 6682e1f..4fc6d8b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *   ALSA driver for ICEnsemble ICE1712 (Envy24)
  *
- *     Copyright (c) 2000 Jaroslav Kysela <perex@suse.cz>
+ *     Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz>
  *
  *   This program is free software; you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@
  *   along with this program; if not, write to the Free Software
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  *
- */      
+ */
 
 /*
   NOTES:
@@ -35,7 +35,7 @@
  *
  *  2002.11.26 James Stafford <jstafford@ampltd.com>
  *     Added support for VT1724 (Envy24HT)
- *     I have left out support for 176.4 and 192 KHz for the moment. 
+ *     I have left out support for 176.4 and 192 KHz for the moment.
  *  I also haven't done anything with the internal S/PDIF transmitter or the MPU-401
  *
  *  2003.02.20  Taksahi Iwai <tiwai@suse.de>
  */
 
 
-#include <sound/driver.h>
-#include <asm/io.h>
+#include <linux/io.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/pci.h>
+#include <linux/dma-mapping.h>
 #include <linux/slab.h>
 #include <linux/moduleparam.h>
 #include <linux/mutex.h>
+
 #include <sound/core.h>
 #include <sound/cs8427.h>
 #include <sound/info.h>
-#include <sound/mpu401.h>
 #include <sound/initval.h>
+#include <sound/tlv.h>
 
 #include <sound/asoundef.h>
 
@@ -71,7 +72,7 @@
 #include "ews.h"
 #include "hoontech.h"
 
-MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
+MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_DESCRIPTION("ICEnsemble ICE1712 (Envy24)");
 MODULE_LICENSE("GPL");
 MODULE_SUPPORTED_DEVICE("{"
@@ -83,10 +84,11 @@ MODULE_SUPPORTED_DEVICE("{"
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
-static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;             /* Enable this card */
+static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card */
 static char *model[SNDRV_CARDS];
-static int omni[SNDRV_CARDS];  /* Delta44 & 66 Omni I/O support */
+static int omni[SNDRV_CARDS];                          /* Delta44 & 66 Omni I/O support */
 static int cs8427_timeout[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 500}; /* CS8427 S/PDIF transciever reset timeout value in msec */
+static int dxr_enable[SNDRV_CARDS];                    /* DXR enable for DMX6FIRE */
 
 module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for ICE1712 soundcard.");
@@ -100,10 +102,12 @@ module_param_array(cs8427_timeout, int, NULL, 0444);
 MODULE_PARM_DESC(cs8427_timeout, "Define reset timeout for cs8427 chip in msec resolution.");
 module_param_array(model, charp, NULL, 0444);
 MODULE_PARM_DESC(model, "Use the given board model.");
+module_param_array(dxr_enable, int, NULL, 0444);
+MODULE_PARM_DESC(dxr_enable, "Enable DXR support for Terratec DMX6FIRE.");
 
 
-static struct pci_device_id snd_ice1712_ids[] = {
-       { PCI_VENDOR_ID_ICE, PCI_DEVICE_ID_ICE_1712, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },   /* ICE1712 */
+static DEFINE_PCI_DEVICE_TABLE(snd_ice1712_ids) = {
+       { PCI_VDEVICE(ICE, PCI_DEVICE_ID_ICE_1712), 0 },   /* ICE1712 */
        { 0, }
 };
 
@@ -119,7 +123,7 @@ static unsigned int PRO_RATE_DEFAULT = 44100;
 /*
  *  Basic I/O
  */
+
 /* check whether the clock mode is spdif-in */
 static inline int is_spdif_master(struct snd_ice1712 *ice)
 {
@@ -131,13 +135,13 @@ static inline int is_pro_rate_locked(struct snd_ice1712 *ice)
        return is_spdif_master(ice) || PRO_RATE_LOCKED;
 }
 
-static inline void snd_ice1712_ds_write(struct snd_ice1712 * ice, u8 channel, u8 addr, u32 data)
+static inline void snd_ice1712_ds_write(struct snd_ice1712 *ice, u8 channel, u8 addr, u32 data)
 {
        outb((channel << 4) | addr, ICEDS(ice, INDEX));
        outl(data, ICEDS(ice, DATA));
 }
 
-static inline u32 snd_ice1712_ds_read(struct snd_ice1712 * ice, u8 channel, u8 addr)
+static inline u32 snd_ice1712_ds_read(struct snd_ice1712 *ice, u8 channel, u8 addr)
 {
        outb((channel << 4) | addr, ICEDS(ice, INDEX));
        return inl(ICEDS(ice, DATA));
@@ -251,19 +255,12 @@ static unsigned short snd_ice1712_pro_ac97_read(struct snd_ac97 *ac97,
 /*
  * consumer ac97 digital mix
  */
-static int snd_ice1712_digmix_route_ac97_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
-{
-       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
-       uinfo->count = 1;
-       uinfo->value.integer.min = 0;
-       uinfo->value.integer.max = 1;
-       return 0;
-}
+#define snd_ice1712_digmix_route_ac97_info     snd_ctl_boolean_mono_info
 
 static int snd_ice1712_digmix_route_ac97_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
        struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
-       
+
        ucontrol->value.integer.value[0] = inb(ICEMT(ice, MONITOR_ROUTECTRL)) & ICE1712_ROUTE_AC97 ? 1 : 0;
        return 0;
 }
@@ -272,11 +269,12 @@ static int snd_ice1712_digmix_route_ac97_put(struct snd_kcontrol *kcontrol, stru
 {
        struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
        unsigned char val, nval;
-       
+
        spin_lock_irq(&ice->reg_lock);
        val = inb(ICEMT(ice, MONITOR_ROUTECTRL));
        nval = val & ~ICE1712_ROUTE_AC97;
-       if (ucontrol->value.integer.value[0]) nval |= ICE1712_ROUTE_AC97;
+       if (ucontrol->value.integer.value[0])
+               nval |= ICE1712_ROUTE_AC97;
        outb(nval, ICEMT(ice, MONITOR_ROUTECTRL));
        spin_unlock_irq(&ice->reg_lock);
        return val != nval;
@@ -300,6 +298,16 @@ static void snd_ice1712_set_gpio_dir(struct snd_ice1712 *ice, unsigned int data)
        inb(ICEREG(ice, DATA)); /* dummy read for pci-posting */
 }
 
+static unsigned int snd_ice1712_get_gpio_dir(struct snd_ice1712 *ice)
+{
+       return snd_ice1712_read(ice, ICE1712_IREG_GPIO_DIRECTION);
+}
+
+static unsigned int snd_ice1712_get_gpio_mask(struct snd_ice1712 *ice)
+{
+       return snd_ice1712_read(ice, ICE1712_IREG_GPIO_WRITE_MASK);
+}
+
 static void snd_ice1712_set_gpio_mask(struct snd_ice1712 *ice, unsigned int data)
 {
        snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, data);
@@ -332,7 +340,7 @@ static int snd_ice1712_cs8427_set_input_clock(struct snd_ice1712 *ice, int spdif
        unsigned char reg[2] = { 0x80 | 4, 0 };   /* CS8427 auto increment | register number 4 + data */
        unsigned char val, nval;
        int res = 0;
-       
+
        snd_i2c_lock(ice->i2c);
        if (snd_i2c_sendbytes(ice->cs8427, reg, 1) != 1) {
                snd_i2c_unlock(ice->i2c);
@@ -384,9 +392,9 @@ int __devinit snd_ice1712_init_cs8427(struct snd_ice1712 *ice, int addr)
 {
        int err;
 
-       if ((err = snd_cs8427_create(ice->i2c, addr,
-                                    (ice->cs8427_timeout * HZ) / 1000,
-                                    &ice->cs8427)) < 0) {
+       err = snd_cs8427_create(ice->i2c, addr,
+               (ice->cs8427_timeout * HZ) / 1000, &ice->cs8427);
+       if (err < 0) {
                snd_printk(KERN_ERR "CS8427 initialization failed\n");
                return err;
        }
@@ -398,9 +406,9 @@ int __devinit snd_ice1712_init_cs8427(struct snd_ice1712 *ice, int addr)
 
 static void snd_ice1712_set_input_clock_source(struct snd_ice1712 *ice, int spdif_is_master)
 {
-        /* change CS8427 clock source too */
-        if (ice->cs8427)
-                snd_ice1712_cs8427_set_input_clock(ice, spdif_is_master);
+       /* change CS8427 clock source too */
+       if (ice->cs8427)
+               snd_ice1712_cs8427_set_input_clock(ice, spdif_is_master);
        /* notify ak4524 chip as well */
        if (spdif_is_master) {
                unsigned int i;
@@ -415,7 +423,7 @@ static void snd_ice1712_set_input_clock_source(struct snd_ice1712 *ice, int spdi
  *  Interrupt handler
  */
 
-static irqreturn_t snd_ice1712_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_ice1712_interrupt(int irq, void *dev_id)
 {
        struct snd_ice1712 *ice = dev_id;
        unsigned char status;
@@ -428,7 +436,7 @@ static irqreturn_t snd_ice1712_interrupt(int irq, void *dev_id, struct pt_regs *
                handled = 1;
                if (status & ICE1712_IRQ_MPU1) {
                        if (ice->rmidi[0])
-                               snd_mpu401_uart_interrupt(irq, ice->rmidi[0]->private_data, regs);
+                               snd_mpu401_uart_interrupt(irq, ice->rmidi[0]->private_data);
                        outb(ICE1712_IRQ_MPU1, ICEREG(ice, IRQSTAT));
                        status &= ~ICE1712_IRQ_MPU1;
                }
@@ -436,7 +444,7 @@ static irqreturn_t snd_ice1712_interrupt(int irq, void *dev_id, struct pt_regs *
                        outb(ICE1712_IRQ_TIMER, ICEREG(ice, IRQSTAT));
                if (status & ICE1712_IRQ_MPU2) {
                        if (ice->rmidi[1])
-                               snd_mpu401_uart_interrupt(irq, ice->rmidi[1]->private_data, regs);
+                               snd_mpu401_uart_interrupt(irq, ice->rmidi[1]->private_data);
                        outb(ICE1712_IRQ_MPU2, ICEREG(ice, IRQSTAT));
                        status &= ~ICE1712_IRQ_MPU2;
                }
@@ -460,11 +468,12 @@ static irqreturn_t snd_ice1712_interrupt(int irq, void *dev_id, struct pt_regs *
                        u16 pbkstatus;
                        struct snd_pcm_substream *substream;
                        pbkstatus = inw(ICEDS(ice, INTSTAT));
-                       //printk("pbkstatus = 0x%x\n", pbkstatus);
+                       /* printk(KERN_DEBUG "pbkstatus = 0x%x\n", pbkstatus); */
                        for (idx = 0; idx < 6; idx++) {
                                if ((pbkstatus & (3 << (idx * 2))) == 0)
                                        continue;
-                               if ((substream = ice->playback_con_substream_ds[idx]) != NULL)
+                               substream = ice->playback_con_substream_ds[idx];
+                               if (substream != NULL)
                                        snd_pcm_period_elapsed(substream);
                                outw(3 << (idx * 2), ICEDS(ice, INTSTAT));
                        }
@@ -510,7 +519,7 @@ static int snd_ice1712_playback_trigger(struct snd_pcm_substream *substream,
        struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
        int result = 0;
        u32 tmp;
-       
+
        spin_lock(&ice->reg_lock);
        tmp = snd_ice1712_read(ice, ICE1712_IREG_PBK_CTRL);
        if (cmd == SNDRV_PCM_TRIGGER_START) {
@@ -535,7 +544,7 @@ static int snd_ice1712_playback_ds_trigger(struct snd_pcm_substream *substream,
        struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
        int result = 0;
        u32 tmp;
-       
+
        spin_lock(&ice->reg_lock);
        tmp = snd_ice1712_ds_read(ice, substream->number * 2, ICE1712_DSC_CONTROL);
        if (cmd == SNDRV_PCM_TRIGGER_START) {
@@ -560,7 +569,7 @@ static int snd_ice1712_capture_trigger(struct snd_pcm_substream *substream,
        struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
        int result = 0;
        u8 tmp;
-       
+
        spin_lock(&ice->reg_lock);
        tmp = snd_ice1712_read(ice, ICE1712_IREG_CAP_CTRL);
        if (cmd == SNDRV_PCM_TRIGGER_START) {
@@ -714,8 +723,7 @@ static snd_pcm_uframes_t snd_ice1712_capture_pointer(struct snd_pcm_substream *s
        return bytes_to_frames(substream->runtime, ptr);
 }
 
-static struct snd_pcm_hardware snd_ice1712_playback =
-{
+static const struct snd_pcm_hardware snd_ice1712_playback = {
        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
                                 SNDRV_PCM_INFO_BLOCK_TRANSFER |
                                 SNDRV_PCM_INFO_MMAP_VALID |
@@ -734,8 +742,7 @@ static struct snd_pcm_hardware snd_ice1712_playback =
        .fifo_size =            0,
 };
 
-static struct snd_pcm_hardware snd_ice1712_playback_ds =
-{
+static const struct snd_pcm_hardware snd_ice1712_playback_ds = {
        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
                                 SNDRV_PCM_INFO_BLOCK_TRANSFER |
                                 SNDRV_PCM_INFO_MMAP_VALID |
@@ -754,8 +761,7 @@ static struct snd_pcm_hardware snd_ice1712_playback_ds =
        .fifo_size =            0,
 };
 
-static struct snd_pcm_hardware snd_ice1712_capture =
-{
+static const struct snd_pcm_hardware snd_ice1712_capture = {
        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
                                 SNDRV_PCM_INFO_BLOCK_TRANSFER |
                                 SNDRV_PCM_INFO_MMAP_VALID),
@@ -791,7 +797,7 @@ static int snd_ice1712_playback_ds_open(struct snd_pcm_substream *substream)
 
        ice->playback_con_substream_ds[substream->number] = substream;
        runtime->hw = snd_ice1712_playback_ds;
-       spin_lock_irq(&ice->reg_lock); 
+       spin_lock_irq(&ice->reg_lock);
        tmp = inw(ICEDS(ice, INTMASK)) & ~(1 << (substream->number * 2));
        outw(tmp, ICEDS(ice, INTMASK));
        spin_unlock_irq(&ice->reg_lock);
@@ -824,7 +830,7 @@ static int snd_ice1712_playback_ds_close(struct snd_pcm_substream *substream)
        struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
        u32 tmp;
 
-       spin_lock_irq(&ice->reg_lock); 
+       spin_lock_irq(&ice->reg_lock);
        tmp = inw(ICEDS(ice, INTMASK)) | (3 << (substream->number * 2));
        outw(tmp, ICEDS(ice, INTMASK));
        spin_unlock_irq(&ice->reg_lock);
@@ -873,7 +879,7 @@ static struct snd_pcm_ops snd_ice1712_capture_ops = {
        .pointer =      snd_ice1712_capture_pointer,
 };
 
-static int __devinit snd_ice1712_pcm(struct snd_ice1712 * ice, int device, struct snd_pcm ** rpcm)
+static int __devinit snd_ice1712_pcm(struct snd_ice1712 *ice, int device, struct snd_pcm **rpcm)
 {
        struct snd_pcm *pcm;
        int err;
@@ -903,7 +909,7 @@ static int __devinit snd_ice1712_pcm(struct snd_ice1712 * ice, int device, struc
        return 0;
 }
 
-static int __devinit snd_ice1712_pcm_ds(struct snd_ice1712 * ice, int device, struct snd_pcm ** rpcm)
+static int __devinit snd_ice1712_pcm_ds(struct snd_ice1712 *ice, int device, struct snd_pcm **rpcm)
 {
        struct snd_pcm *pcm;
        int err;
@@ -972,11 +978,9 @@ static int snd_ice1712_pro_trigger(struct snd_pcm_substream *substream,
        {
                unsigned int what = 0;
                unsigned int old;
-               struct list_head *pos;
                struct snd_pcm_substream *s;
 
-               snd_pcm_group_for_each(pos, substream) {
-                       s = snd_pcm_group_substream_entry(pos);
+               snd_pcm_group_for_each_entry(s, substream) {
                        if (s == ice->playback_pro_substream) {
                                what |= ICE1712_PLAYBACK_START;
                                snd_pcm_trigger_done(s, substream);
@@ -1034,14 +1038,14 @@ static void snd_ice1712_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate,
        if (inb(ICEMT(ice, PLAYBACK_CONTROL)) & (ICE1712_CAPTURE_START_SHADOW|
                                                 ICE1712_PLAYBACK_PAUSE|
                                                 ICE1712_PLAYBACK_START)) {
-             __out:
+__out:
                spin_unlock_irqrestore(&ice->reg_lock, flags);
                return;
        }
        if (!force && is_pro_rate_locked(ice))
                goto __out;
 
-        old = inb(ICEMT(ice, RATE));
+       old = inb(ICEMT(ice, RATE));
        if (!force && old == val)
                goto __out;
        outb(val, ICEMT(ice, RATE));
@@ -1128,8 +1132,7 @@ static snd_pcm_uframes_t snd_ice1712_capture_pro_pointer(struct snd_pcm_substrea
        return bytes_to_frames(substream->runtime, ptr);
 }
 
-static struct snd_pcm_hardware snd_ice1712_playback_pro =
-{
+static const struct snd_pcm_hardware snd_ice1712_playback_pro = {
        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
                                 SNDRV_PCM_INFO_BLOCK_TRANSFER |
                                 SNDRV_PCM_INFO_MMAP_VALID |
@@ -1148,8 +1151,7 @@ static struct snd_pcm_hardware snd_ice1712_playback_pro =
        .fifo_size =            0,
 };
 
-static struct snd_pcm_hardware snd_ice1712_capture_pro =
-{
+static const struct snd_pcm_hardware snd_ice1712_capture_pro = {
        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
                                 SNDRV_PCM_INFO_BLOCK_TRANSFER |
                                 SNDRV_PCM_INFO_MMAP_VALID |
@@ -1178,6 +1180,10 @@ static int snd_ice1712_playback_pro_open(struct snd_pcm_substream *substream)
        snd_pcm_set_sync(substream);
        snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
        snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates);
+       if (is_pro_rate_locked(ice)) {
+               runtime->hw.rate_min = PRO_RATE_DEFAULT;
+               runtime->hw.rate_max = PRO_RATE_DEFAULT;
+       }
 
        if (ice->spdif.ops.open)
                ice->spdif.ops.open(ice, substream);
@@ -1195,6 +1201,11 @@ static int snd_ice1712_capture_pro_open(struct snd_pcm_substream *substream)
        snd_pcm_set_sync(substream);
        snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
        snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates);
+       if (is_pro_rate_locked(ice)) {
+               runtime->hw.rate_min = PRO_RATE_DEFAULT;
+               runtime->hw.rate_max = PRO_RATE_DEFAULT;
+       }
+
        return 0;
 }
 
@@ -1243,7 +1254,7 @@ static struct snd_pcm_ops snd_ice1712_capture_pro_ops = {
        .pointer =      snd_ice1712_capture_pro_pointer,
 };
 
-static int __devinit snd_ice1712_pcm_profi(struct snd_ice1712 * ice, int device, struct snd_pcm ** rpcm)
+static int __devinit snd_ice1712_pcm_profi(struct snd_ice1712 *ice, int device, struct snd_pcm **rpcm)
 {
        struct snd_pcm *pcm;
        int err;
@@ -1267,7 +1278,7 @@ static int __devinit snd_ice1712_pcm_profi(struct snd_ice1712 * ice, int device,
        ice->pcm_pro = pcm;
        if (rpcm)
                *rpcm = pcm;
-       
+
        if (ice->cs8427) {
                /* assign channels to iec958 */
                err = snd_cs8427_iec958_build(ice->cs8427,
@@ -1277,7 +1288,8 @@ static int __devinit snd_ice1712_pcm_profi(struct snd_ice1712 * ice, int device,
                        return err;
        }
 
-       if ((err = snd_ice1712_build_pro_mixer(ice)) < 0)
+       err = snd_ice1712_build_pro_mixer(ice);
+       if (err < 0)
                return err;
        return 0;
 }
@@ -1297,23 +1309,19 @@ static void snd_ice1712_update_volume(struct snd_ice1712 *ice, int index)
        outw(val, ICEMT(ice, MONITOR_VOLUME));
 }
 
-static int snd_ice1712_pro_mixer_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
-{
-       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
-       uinfo->count = 2;
-       uinfo->value.integer.min = 0;
-       uinfo->value.integer.max = 1;
-       return 0;
-}
+#define snd_ice1712_pro_mixer_switch_info      snd_ctl_boolean_stereo_info
 
 static int snd_ice1712_pro_mixer_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
        struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
-       int index = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + kcontrol->private_value;
-       
+       int priv_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) +
+               kcontrol->private_value;
+
        spin_lock_irq(&ice->reg_lock);
-       ucontrol->value.integer.value[0] = !((ice->pro_volumes[index] >> 15) & 1);
-       ucontrol->value.integer.value[1] = !((ice->pro_volumes[index] >> 31) & 1);
+       ucontrol->value.integer.value[0] =
+               !((ice->pro_volumes[priv_idx] >> 15) & 1);
+       ucontrol->value.integer.value[1] =
+               !((ice->pro_volumes[priv_idx] >> 31) & 1);
        spin_unlock_irq(&ice->reg_lock);
        return 0;
 }
@@ -1321,16 +1329,17 @@ static int snd_ice1712_pro_mixer_switch_get(struct snd_kcontrol *kcontrol, struc
 static int snd_ice1712_pro_mixer_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
        struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
-       int index = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + kcontrol->private_value;
+       int priv_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) +
+               kcontrol->private_value;
        unsigned int nval, change;
 
        nval = (ucontrol->value.integer.value[0] ? 0 : 0x00008000) |
               (ucontrol->value.integer.value[1] ? 0 : 0x80000000);
        spin_lock_irq(&ice->reg_lock);
-       nval |= ice->pro_volumes[index] & ~0x80008000;
-       change = nval != ice->pro_volumes[index];
-       ice->pro_volumes[index] = nval;
-       snd_ice1712_update_volume(ice, index);
+       nval |= ice->pro_volumes[priv_idx] & ~0x80008000;
+       change = nval != ice->pro_volumes[priv_idx];
+       ice->pro_volumes[priv_idx] = nval;
+       snd_ice1712_update_volume(ice, priv_idx);
        spin_unlock_irq(&ice->reg_lock);
        return change;
 }
@@ -1347,11 +1356,14 @@ static int snd_ice1712_pro_mixer_volume_info(struct snd_kcontrol *kcontrol, stru
 static int snd_ice1712_pro_mixer_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
        struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
-       int index = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + kcontrol->private_value;
-       
+       int priv_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) +
+               kcontrol->private_value;
+
        spin_lock_irq(&ice->reg_lock);
-       ucontrol->value.integer.value[0] = (ice->pro_volumes[index] >> 0) & 127;
-       ucontrol->value.integer.value[1] = (ice->pro_volumes[index] >> 16) & 127;
+       ucontrol->value.integer.value[0] =
+               (ice->pro_volumes[priv_idx] >> 0) & 127;
+       ucontrol->value.integer.value[1] =
+               (ice->pro_volumes[priv_idx] >> 16) & 127;
        spin_unlock_irq(&ice->reg_lock);
        return 0;
 }
@@ -1359,20 +1371,22 @@ static int snd_ice1712_pro_mixer_volume_get(struct snd_kcontrol *kcontrol, struc
 static int snd_ice1712_pro_mixer_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
        struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
-       int index = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + kcontrol->private_value;
+       int priv_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) +
+               kcontrol->private_value;
        unsigned int nval, change;
 
        nval = (ucontrol->value.integer.value[0] & 127) |
               ((ucontrol->value.integer.value[1] & 127) << 16);
        spin_lock_irq(&ice->reg_lock);
-       nval |= ice->pro_volumes[index] & ~0x007f007f;
-       change = nval != ice->pro_volumes[index];
-       ice->pro_volumes[index] = nval;
-       snd_ice1712_update_volume(ice, index);
+       nval |= ice->pro_volumes[priv_idx] & ~0x007f007f;
+       change = nval != ice->pro_volumes[priv_idx];
+       ice->pro_volumes[priv_idx] = nval;
+       snd_ice1712_update_volume(ice, priv_idx);
        spin_unlock_irq(&ice->reg_lock);
        return change;
 }
 
+static const DECLARE_TLV_DB_SCALE(db_scale_playback, -14400, 150, 0);
 
 static struct snd_kcontrol_new snd_ice1712_multi_playback_ctrls[] __devinitdata = {
        {
@@ -1386,12 +1400,15 @@ static struct snd_kcontrol_new snd_ice1712_multi_playback_ctrls[] __devinitdata
        },
        {
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
+                          SNDRV_CTL_ELEM_ACCESS_TLV_READ),
                .name = "Multi Playback Volume",
                .info = snd_ice1712_pro_mixer_volume_info,
                .get = snd_ice1712_pro_mixer_volume_get,
                .put = snd_ice1712_pro_mixer_volume_put,
                .private_value = 0,
                .count = 10,
+               .tlv = { .p = db_scale_playback }
        },
 };
 
@@ -1406,7 +1423,7 @@ static struct snd_kcontrol_new snd_ice1712_multi_capture_analog_switch __devinit
 
 static struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_switch __devinitdata = {
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-       .name = SNDRV_CTL_NAME_IEC958("Multi ",CAPTURE,SWITCH),
+       .name = SNDRV_CTL_NAME_IEC958("Multi ", CAPTURE, SWITCH),
        .info = snd_ice1712_pro_mixer_switch_info,
        .get = snd_ice1712_pro_mixer_switch_get,
        .put = snd_ice1712_pro_mixer_switch_put,
@@ -1416,16 +1433,19 @@ static struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_switch __devinitd
 
 static struct snd_kcontrol_new snd_ice1712_multi_capture_analog_volume __devinitdata = {
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+       .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
+                  SNDRV_CTL_ELEM_ACCESS_TLV_READ),
        .name = "H/W Multi Capture Volume",
        .info = snd_ice1712_pro_mixer_volume_info,
        .get = snd_ice1712_pro_mixer_volume_get,
        .put = snd_ice1712_pro_mixer_volume_put,
        .private_value = 10,
+       .tlv = { .p = db_scale_playback }
 };
 
 static struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_volume __devinitdata = {
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-       .name = SNDRV_CTL_NAME_IEC958("Multi ",CAPTURE,VOLUME),
+       .name = SNDRV_CTL_NAME_IEC958("Multi ", CAPTURE, VOLUME),
        .info = snd_ice1712_pro_mixer_volume_info,
        .get = snd_ice1712_pro_mixer_volume_get,
        .put = snd_ice1712_pro_mixer_volume_put,
@@ -1445,7 +1465,7 @@ static int __devinit snd_ice1712_build_pro_mixer(struct snd_ice1712 *ice)
                if (err < 0)
                        return err;
        }
-       
+
        if (ice->num_total_adcs > 0) {
                struct snd_kcontrol_new tmp = snd_ice1712_multi_capture_analog_switch;
                tmp.count = ice->num_total_adcs;
@@ -1492,7 +1512,7 @@ static void snd_ice1712_mixer_free_ac97(struct snd_ac97 *ac97)
        ice->ac97 = NULL;
 }
 
-static int __devinit snd_ice1712_ac97_mixer(struct snd_ice1712 * ice)
+static int __devinit snd_ice1712_ac97_mixer(struct snd_ice1712 *ice)
 {
        int err, bus_num = 0;
        struct snd_ac97_template ac97;
@@ -1507,27 +1527,32 @@ static int __devinit snd_ice1712_ac97_mixer(struct snd_ice1712 * ice)
        };
 
        if (ice_has_con_ac97(ice)) {
-               if ((err = snd_ac97_bus(ice->card, bus_num++, &con_ops, NULL, &pbus)) < 0)
+               err = snd_ac97_bus(ice->card, bus_num++, &con_ops, NULL, &pbus);
+               if (err < 0)
                        return err;
                memset(&ac97, 0, sizeof(ac97));
                ac97.private_data = ice;
                ac97.private_free = snd_ice1712_mixer_free_ac97;
-               if ((err = snd_ac97_mixer(pbus, &ac97, &ice->ac97)) < 0)
+               err = snd_ac97_mixer(pbus, &ac97, &ice->ac97);
+               if (err < 0)
                        printk(KERN_WARNING "ice1712: cannot initialize ac97 for consumer, skipped\n");
                else {
-                       if ((err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_mixer_digmix_route_ac97, ice))) < 0)
+                       err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_mixer_digmix_route_ac97, ice));
+                       if (err < 0)
                                return err;
                        return 0;
                }
        }
 
-       if (! (ice->eeprom.data[ICE_EEP1_ACLINK] & ICE1712_CFG_PRO_I2S)) {
-               if ((err = snd_ac97_bus(ice->card, bus_num, &pro_ops, NULL, &pbus)) < 0)
+       if (!(ice->eeprom.data[ICE_EEP1_ACLINK] & ICE1712_CFG_PRO_I2S)) {
+               err = snd_ac97_bus(ice->card, bus_num, &pro_ops, NULL, &pbus);
+               if (err < 0)
                        return err;
                memset(&ac97, 0, sizeof(ac97));
                ac97.private_data = ice;
                ac97.private_free = snd_ice1712_mixer_free_ac97;
-               if ((err = snd_ac97_mixer(pbus, &ac97, &ice->ac97)) < 0)
+               err = snd_ac97_mixer(pbus, &ac97, &ice->ac97);
+               if (err < 0)
                        printk(KERN_WARNING "ice1712: cannot initialize pro ac97, skipped\n");
                else
                        return 0;
@@ -1546,7 +1571,7 @@ static inline unsigned int eeprom_double(struct snd_ice1712 *ice, int idx)
        return (unsigned int)ice->eeprom.data[idx] | ((unsigned int)ice->eeprom.data[idx + 1] << 8);
 }
 
-static void snd_ice1712_proc_read(struct snd_info_entry *entry, 
+static void snd_ice1712_proc_read(struct snd_info_entry *entry,
                                  struct snd_info_buffer *buffer)
 {
        struct snd_ice1712 *ice = entry->private_data;
@@ -1581,14 +1606,17 @@ static void snd_ice1712_proc_read(struct snd_info_entry *entry,
        snd_iprintf(buffer, "  CAPTURE          : 0x%08x\n", inl(ICEMT(ice, ROUTE_CAPTURE)));
        snd_iprintf(buffer, "  SPDOUT           : 0x%04x\n", (unsigned)inw(ICEMT(ice, ROUTE_SPDOUT)));
        snd_iprintf(buffer, "  RATE             : 0x%02x\n", (unsigned)inb(ICEMT(ice, RATE)));
+       snd_iprintf(buffer, "  GPIO_DATA        : 0x%02x\n", (unsigned)snd_ice1712_get_gpio_data(ice));
+       snd_iprintf(buffer, "  GPIO_WRITE_MASK  : 0x%02x\n", (unsigned)snd_ice1712_read(ice, ICE1712_IREG_GPIO_WRITE_MASK));
+       snd_iprintf(buffer, "  GPIO_DIRECTION   : 0x%02x\n", (unsigned)snd_ice1712_read(ice, ICE1712_IREG_GPIO_DIRECTION));
 }
 
-static void __devinit snd_ice1712_proc_init(struct snd_ice1712 * ice)
+static void __devinit snd_ice1712_proc_init(struct snd_ice1712 *ice)
 {
        struct snd_info_entry *entry;
 
-       if (! snd_card_proc_new(ice->card, "ice1712", &entry))
-               snd_info_set_text_ops(entry, ice, 1024, snd_ice1712_proc_read);
+       if (!snd_card_proc_new(ice->card, "ice1712", &entry))
+               snd_info_set_text_ops(entry, ice, snd_ice1712_proc_read);
 }
 
 /*
@@ -1607,7 +1635,7 @@ static int snd_ice1712_eeprom_get(struct snd_kcontrol *kcontrol,
                                  struct snd_ctl_elem_value *ucontrol)
 {
        struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
-       
+
        memcpy(ucontrol->value.bytes.data, &ice->eeprom, sizeof(ice->eeprom));
        return 0;
 }
@@ -1635,7 +1663,7 @@ static int snd_ice1712_spdif_default_get(struct snd_kcontrol *kcontrol,
 {
        struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
        if (ice->spdif.ops.default_get)
-               ice->spdif.ops.default_get(ice, ucontrol); 
+               ice->spdif.ops.default_get(ice, ucontrol);
        return 0;
 }
 
@@ -1651,7 +1679,7 @@ static int snd_ice1712_spdif_default_put(struct snd_kcontrol *kcontrol,
 static struct snd_kcontrol_new snd_ice1712_spdif_default __devinitdata =
 {
        .iface =        SNDRV_CTL_ELEM_IFACE_PCM,
-       .name =         SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),
+       .name =         SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT),
        .info =         snd_ice1712_spdif_info,
        .get =          snd_ice1712_spdif_default_get,
        .put =          snd_ice1712_spdif_default_put
@@ -1703,7 +1731,7 @@ static struct snd_kcontrol_new snd_ice1712_spdif_maskc __devinitdata =
 {
        .access =       SNDRV_CTL_ELEM_ACCESS_READ,
        .iface =        SNDRV_CTL_ELEM_IFACE_PCM,
-       .name =         SNDRV_CTL_NAME_IEC958("",PLAYBACK,CON_MASK),
+       .name =         SNDRV_CTL_NAME_IEC958("", PLAYBACK, CON_MASK),
        .info =         snd_ice1712_spdif_info,
        .get =          snd_ice1712_spdif_maskc_get,
 };
@@ -1712,7 +1740,7 @@ static struct snd_kcontrol_new snd_ice1712_spdif_maskp __devinitdata =
 {
        .access =       SNDRV_CTL_ELEM_ACCESS_READ,
        .iface =        SNDRV_CTL_ELEM_IFACE_PCM,
-       .name =         SNDRV_CTL_NAME_IEC958("",PLAYBACK,PRO_MASK),
+       .name =         SNDRV_CTL_NAME_IEC958("", PLAYBACK, PRO_MASK),
        .info =         snd_ice1712_spdif_info,
        .get =          snd_ice1712_spdif_maskp_get,
 };
@@ -1740,29 +1768,19 @@ static struct snd_kcontrol_new snd_ice1712_spdif_stream __devinitdata =
        .access =       (SNDRV_CTL_ELEM_ACCESS_READWRITE |
                         SNDRV_CTL_ELEM_ACCESS_INACTIVE),
        .iface =        SNDRV_CTL_ELEM_IFACE_PCM,
-       .name =         SNDRV_CTL_NAME_IEC958("",PLAYBACK,PCM_STREAM),
+       .name =         SNDRV_CTL_NAME_IEC958("", PLAYBACK, PCM_STREAM),
        .info =         snd_ice1712_spdif_info,
        .get =          snd_ice1712_spdif_stream_get,
        .put =          snd_ice1712_spdif_stream_put
 };
 
-int snd_ice1712_gpio_info(struct snd_kcontrol *kcontrol,
-                         struct snd_ctl_elem_info *uinfo)
-{
-       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
-       uinfo->count = 1;
-       uinfo->value.integer.min = 0;
-       uinfo->value.integer.max = 1;
-       return 0;
-}
-
 int snd_ice1712_gpio_get(struct snd_kcontrol *kcontrol,
                         struct snd_ctl_elem_value *ucontrol)
 {
        struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
        unsigned char mask = kcontrol->private_value & 0xff;
        int invert = (kcontrol->private_value & (1<<24)) ? 1 : 0;
-       
+
        snd_ice1712_save_gpio_status(ice);
        ucontrol->value.integer.value[0] =
                (snd_ice1712_gpio_read(ice) & mask ? 1 : 0) ^ invert;
@@ -1796,7 +1814,7 @@ int snd_ice1712_gpio_put(struct snd_kcontrol *kcontrol,
 static int snd_ice1712_pro_internal_clock_info(struct snd_kcontrol *kcontrol,
                                               struct snd_ctl_elem_info *uinfo)
 {
-       static char *texts[] = {
+       static const char * const texts[] = {
                "8000",         /* 0: 6 */
                "9600",         /* 1: 3 */
                "11025",        /* 2: 10 */
@@ -1825,11 +1843,11 @@ static int snd_ice1712_pro_internal_clock_get(struct snd_kcontrol *kcontrol,
                                              struct snd_ctl_elem_value *ucontrol)
 {
        struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
-       static unsigned char xlate[16] = {
+       static const unsigned char xlate[16] = {
                9, 6, 3, 1, 7, 4, 0, 12, 8, 5, 2, 11, 255, 255, 255, 10
        };
        unsigned char val;
-       
+
        spin_lock_irq(&ice->reg_lock);
        if (is_spdif_master(ice)) {
                ucontrol->value.enumerated.item[0] = 13;
@@ -1849,8 +1867,8 @@ static int snd_ice1712_pro_internal_clock_put(struct snd_kcontrol *kcontrol,
                                              struct snd_ctl_elem_value *ucontrol)
 {
        struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
-       static unsigned int xrate[13] = {
-               8000, 9600, 11025, 12000, 1600, 22050, 24000,
+       static const unsigned int xrate[13] = {
+               8000, 9600, 11025, 12000, 16000, 22050, 24000,
                32000, 44100, 48000, 64000, 88200, 96000
        };
        unsigned char oval;
@@ -1871,7 +1889,7 @@ static int snd_ice1712_pro_internal_clock_put(struct snd_kcontrol *kcontrol,
 
        if ((oval & ICE1712_SPDIF_MASTER) !=
            (inb(ICEMT(ice, RATE)) & ICE1712_SPDIF_MASTER))
-               snd_ice1712_set_input_clock_source(ice, is_spdif_master(ice));
+               snd_ice1712_set_input_clock_source(ice, is_spdif_master(ice));
 
        return change;
 }
@@ -1887,7 +1905,7 @@ static struct snd_kcontrol_new snd_ice1712_pro_internal_clock __devinitdata = {
 static int snd_ice1712_pro_internal_clock_default_info(struct snd_kcontrol *kcontrol,
                                                       struct snd_ctl_elem_info *uinfo)
 {
-       static char *texts[] = {
+       static const char * const texts[] = {
                "8000",         /* 0: 6 */
                "9600",         /* 1: 3 */
                "11025",        /* 2: 10 */
@@ -1901,7 +1919,7 @@ static int snd_ice1712_pro_internal_clock_default_info(struct snd_kcontrol *kcon
                "64000",        /* 10: 15 */
                "88200",        /* 11: 11 */
                "96000",        /* 12: 7 */
-               // "IEC958 Input",      /* 13: -- */
+               /* "IEC958 Input",      13: -- */
        };
        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
        uinfo->count = 1;
@@ -1916,8 +1934,8 @@ static int snd_ice1712_pro_internal_clock_default_get(struct snd_kcontrol *kcont
                                                      struct snd_ctl_elem_value *ucontrol)
 {
        int val;
-       static unsigned int xrate[13] = {
-               8000, 9600, 11025, 12000, 1600, 22050, 24000,
+       static const unsigned int xrate[13] = {
+               8000, 9600, 11025, 12000, 16000, 22050, 24000,
                32000, 44100, 48000, 64000, 88200, 96000
        };
 
@@ -1933,8 +1951,8 @@ static int snd_ice1712_pro_internal_clock_default_get(struct snd_kcontrol *kcont
 static int snd_ice1712_pro_internal_clock_default_put(struct snd_kcontrol *kcontrol,
                                                      struct snd_ctl_elem_value *ucontrol)
 {
-       static unsigned int xrate[13] = {
-               8000, 9600, 11025, 12000, 1600, 22050, 24000,
+       static const unsigned int xrate[13] = {
+               8000, 9600, 11025, 12000, 16000, 22050, 24000,
                32000, 44100, 48000, 64000, 88200, 96000
        };
        unsigned char oval;
@@ -1955,15 +1973,7 @@ static struct snd_kcontrol_new snd_ice1712_pro_internal_clock_default __devinitd
        .put = snd_ice1712_pro_internal_clock_default_put
 };
 
-static int snd_ice1712_pro_rate_locking_info(struct snd_kcontrol *kcontrol,
-                                            struct snd_ctl_elem_info *uinfo)
-{
-       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
-       uinfo->count = 1;
-       uinfo->value.integer.min = 0;
-       uinfo->value.integer.max = 1;
-       return 0;
-}
+#define snd_ice1712_pro_rate_locking_info      snd_ctl_boolean_mono_info
 
 static int snd_ice1712_pro_rate_locking_get(struct snd_kcontrol *kcontrol,
                                            struct snd_ctl_elem_value *ucontrol)
@@ -1994,15 +2004,7 @@ static struct snd_kcontrol_new snd_ice1712_pro_rate_locking __devinitdata = {
        .put = snd_ice1712_pro_rate_locking_put
 };
 
-static int snd_ice1712_pro_rate_reset_info(struct snd_kcontrol *kcontrol,
-                                          struct snd_ctl_elem_info *uinfo)
-{
-       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
-       uinfo->count = 1;
-       uinfo->value.integer.min = 0;
-       uinfo->value.integer.max = 1;
-       return 0;
-}
+#define snd_ice1712_pro_rate_reset_info                snd_ctl_boolean_mono_info
 
 static int snd_ice1712_pro_rate_reset_get(struct snd_kcontrol *kcontrol,
                                          struct snd_ctl_elem_value *ucontrol)
@@ -2039,14 +2041,14 @@ static struct snd_kcontrol_new snd_ice1712_pro_rate_reset __devinitdata = {
 static int snd_ice1712_pro_route_info(struct snd_kcontrol *kcontrol,
                                      struct snd_ctl_elem_info *uinfo)
 {
-       static char *texts[] = {
+       static const char * const texts[] = {
                "PCM Out", /* 0 */
                "H/W In 0", "H/W In 1", "H/W In 2", "H/W In 3", /* 1-4 */
                "H/W In 4", "H/W In 5", "H/W In 6", "H/W In 7", /* 5-8 */
                "IEC958 In L", "IEC958 In R", /* 9-10 */
                "Digital Mixer", /* 11 - optional */
        };
-       
+
        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
        uinfo->count = 1;
        uinfo->value.enumerated.items =
@@ -2090,7 +2092,7 @@ static int snd_ice1712_pro_route_analog_put(struct snd_kcontrol *kcontrol,
        int change, shift;
        int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
        unsigned int val, old_val, nval;
-       
+
        /* update PSDOUT */
        if (ucontrol->value.enumerated.item[0] >= 11)
                nval = idx < 2 ? 1 : 0; /* dig mixer (or pcm) */
@@ -2160,7 +2162,7 @@ static int snd_ice1712_pro_route_spdif_put(struct snd_kcontrol *kcontrol,
        int change, shift;
        int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
        unsigned int val, old_val, nval;
-       
+
        /* update SPDOUT */
        spin_lock_irq(&ice->reg_lock);
        val = old_val = inw(ICEMT(ice, ROUTE_SPDOUT));
@@ -2202,7 +2204,7 @@ static struct snd_kcontrol_new snd_ice1712_mixer_pro_analog_route __devinitdata
 
 static struct snd_kcontrol_new snd_ice1712_mixer_pro_spdif_route __devinitdata = {
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-       .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route",
+       .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, NONE) "Route",
        .info = snd_ice1712_pro_route_info,
        .get = snd_ice1712_pro_route_spdif_get,
        .put = snd_ice1712_pro_route_spdif_put,
@@ -2224,7 +2226,7 @@ static int snd_ice1712_pro_volume_rate_get(struct snd_kcontrol *kcontrol,
                                           struct snd_ctl_elem_value *ucontrol)
 {
        struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
-       
+
        ucontrol->value.integer.value[0] = inb(ICEMT(ice, MONITOR_RATE));
        return 0;
 }
@@ -2265,7 +2267,7 @@ static int snd_ice1712_pro_peak_get(struct snd_kcontrol *kcontrol,
 {
        struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
        int idx;
-       
+
        spin_lock_irq(&ice->reg_lock);
        for (idx = 0; idx < 22; idx++) {
                outb(idx, ICEMT(ice, MONITOR_PEAKINDEX));
@@ -2276,7 +2278,7 @@ static int snd_ice1712_pro_peak_get(struct snd_kcontrol *kcontrol,
 }
 
 static struct snd_kcontrol_new snd_ice1712_mixer_pro_peak __devinitdata = {
-       .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+       .iface = SNDRV_CTL_ELEM_IFACE_PCM,
        .name = "Multi Track Peak",
        .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
        .info = snd_ice1712_pro_peak_info,
@@ -2314,14 +2316,14 @@ static int __devinit snd_ice1712_read_eeprom(struct snd_ice1712 *ice,
 {
        int dev = 0xa0;         /* EEPROM device address */
        unsigned int i, size;
-       struct snd_ice1712_card_info **tbl, *c;
+       struct snd_ice1712_card_info * const *tbl, *c;
 
-       if (! modelname || ! *modelname) {
+       if (!modelname || !*modelname) {
                ice->eeprom.subvendor = 0;
                if ((inb(ICEREG(ice, I2C_CTRL)) & ICE1712_I2C_EEPROM) != 0)
                        ice->eeprom.subvendor = (snd_ice1712_read_i2c(ice, dev, 0x00) << 0) |
-                               (snd_ice1712_read_i2c(ice, dev, 0x01) << 8) | 
-                               (snd_ice1712_read_i2c(ice, dev, 0x02) << 16) | 
+                               (snd_ice1712_read_i2c(ice, dev, 0x01) << 8) |
+                               (snd_ice1712_read_i2c(ice, dev, 0x02) << 16) |
                                (snd_ice1712_read_i2c(ice, dev, 0x03) << 24);
                if (ice->eeprom.subvendor == 0 ||
                    ice->eeprom.subvendor == (unsigned int)-1) {
@@ -2338,12 +2340,12 @@ static int __devinit snd_ice1712_read_eeprom(struct snd_ice1712 *ice,
        }
        for (tbl = card_tables; *tbl; tbl++) {
                for (c = *tbl; c->subvendor; c++) {
-                       if (modelname && c->model && ! strcmp(modelname, c->model)) {
+                       if (modelname && c->model && !strcmp(modelname, c->model)) {
                                printk(KERN_INFO "ice1712: Using board model %s\n", c->name);
                                ice->eeprom.subvendor = c->subvendor;
                        } else if (c->subvendor != ice->eeprom.subvendor)
                                continue;
-                       if (! c->eeprom_size || ! c->eeprom_data)
+                       if (!c->eeprom_size || !c->eeprom_data)
                                goto found;
                        /* if the EEPROM is given by the driver, use it */
                        snd_printdd("using the defined eeprom..\n");
@@ -2390,6 +2392,13 @@ static int __devinit snd_ice1712_chip_init(struct snd_ice1712 *ice)
        udelay(200);
        outb(ICE1712_NATIVE, ICEREG(ice, CONTROL));
        udelay(200);
+       if (ice->eeprom.subvendor == ICE1712_SUBDEVICE_DMX6FIRE &&
+           !ice->dxr_enable)
+               /*  Set eeprom value to limit active ADCs and DACs to 6;
+                *  Also disable AC97 as no hardware in standard 6fire card/box
+                *  Note: DXR extensions are not currently supported
+                */
+               ice->eeprom.data[ICE_EEP1_CODEC] = 0x3a;
        pci_write_config_byte(ice->pci, 0x60, ice->eeprom.data[ICE_EEP1_CODEC]);
        pci_write_config_byte(ice->pci, 0x61, ice->eeprom.data[ICE_EEP1_ACLINK]);
        pci_write_config_byte(ice->pci, 0x62, ice->eeprom.data[ICE_EEP1_I2SID]);
@@ -2429,7 +2438,8 @@ int __devinit snd_ice1712_spdif_build_controls(struct snd_ice1712 *ice)
        int err;
        struct snd_kcontrol *kctl;
 
-       snd_assert(ice->pcm_pro != NULL, return -EIO);
+       if (snd_BUG_ON(!ice->pcm_pro))
+               return -EIO;
        err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_ice1712_spdif_default, ice));
        if (err < 0)
                return err;
@@ -2496,21 +2506,21 @@ static int __devinit snd_ice1712_build_controls(struct snd_ice1712 *ice)
 
 static int snd_ice1712_free(struct snd_ice1712 *ice)
 {
-       if (! ice->port)
+       if (!ice->port)
                goto __hw_end;
        /* mask all interrupts */
        outb(0xc0, ICEMT(ice, IRQ));
        outb(0xff, ICEREG(ice, IRQMASK));
        /* --- */
-      __hw_end:
-       if (ice->irq >= 0) {
-               synchronize_irq(ice->irq);
+__hw_end:
+       if (ice->irq >= 0)
                free_irq(ice->irq, ice);
-       }
+
        if (ice->port)
                pci_release_regions(ice->pci);
        snd_ice1712_akm4xxx_free(ice);
        pci_disable_device(ice->pci);
+       kfree(ice->spec);
        kfree(ice);
        return 0;
 }
@@ -2526,7 +2536,8 @@ static int __devinit snd_ice1712_create(struct snd_card *card,
                                        const char *modelname,
                                        int omni,
                                        int cs8427_timeout,
-                                       struct snd_ice1712 ** r_ice1712)
+                                       int dxr_enable,
+                                       struct snd_ice1712 **r_ice1712)
 {
        struct snd_ice1712 *ice;
        int err;
@@ -2536,12 +2547,13 @@ static int __devinit snd_ice1712_create(struct snd_card *card,
 
        *r_ice1712 = NULL;
 
-        /* enable PCI device */
-       if ((err = pci_enable_device(pci)) < 0)
+       /* enable PCI device */
+       err = pci_enable_device(pci);
+       if (err < 0)
                return err;
        /* check, if we can restrict PCI DMA transfers to 28 bits */
-       if (pci_set_dma_mask(pci, 0x0fffffff) < 0 ||
-           pci_set_consistent_dma_mask(pci, 0x0fffffff) < 0) {
+       if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 ||
+           pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) {
                snd_printk(KERN_ERR "architecture does not support 28bit PCI busmaster DMA\n");
                pci_disable_device(pci);
                return -ENXIO;
@@ -2558,12 +2570,15 @@ static int __devinit snd_ice1712_create(struct snd_card *card,
        else if (cs8427_timeout > 1000)
                cs8427_timeout = 1000;
        ice->cs8427_timeout = cs8427_timeout;
+       ice->dxr_enable = dxr_enable;
        spin_lock_init(&ice->reg_lock);
        mutex_init(&ice->gpio_mutex);
        mutex_init(&ice->i2c_mutex);
        mutex_init(&ice->open_mutex);
        ice->gpio.set_mask = snd_ice1712_set_gpio_mask;
+       ice->gpio.get_mask = snd_ice1712_get_gpio_mask;
        ice->gpio.set_dir = snd_ice1712_set_gpio_dir;
+       ice->gpio.get_dir = snd_ice1712_get_gpio_dir;
        ice->gpio.set_data = snd_ice1712_set_gpio_data;
        ice->gpio.get_data = snd_ice1712_get_gpio_data;
 
@@ -2580,7 +2595,8 @@ static int __devinit snd_ice1712_create(struct snd_card *card,
        snd_ice1712_proc_init(ice);
        synchronize_irq(pci->irq);
 
-       if ((err = pci_request_regions(pci, "ICE1712")) < 0) {
+       err = pci_request_regions(pci, "ICE1712");
+       if (err < 0) {
                kfree(ice);
                pci_disable_device(pci);
                return err;
@@ -2590,13 +2606,13 @@ static int __devinit snd_ice1712_create(struct snd_card *card,
        ice->dmapath_port = pci_resource_start(pci, 2);
        ice->profi_port = pci_resource_start(pci, 3);
 
-       if (request_irq(pci->irq, snd_ice1712_interrupt, SA_INTERRUPT|SA_SHIRQ,
+       if (request_irq(pci->irq, snd_ice1712_interrupt, IRQF_SHARED,
                        "ICE1712", ice)) {
                snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
                snd_ice1712_free(ice);
                return -EIO;
        }
-       
+
        ice->irq = pci->irq;
 
        if (snd_ice1712_read_eeprom(ice, modelname) < 0) {
@@ -2616,9 +2632,10 @@ static int __devinit snd_ice1712_create(struct snd_card *card,
             ICEREG(ice, IRQMASK));
        outb(0x00, ICEMT(ice, IRQ));
 
-       if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, ice, &ops)) < 0) {
+       err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, ice, &ops);
+       if (err < 0) {
                snd_ice1712_free(ice);
-               return err;
+               return err;
        }
 
        snd_card_set_dev(card, &pci->dev);
@@ -2643,7 +2660,7 @@ static int __devinit snd_ice1712_probe(struct pci_dev *pci,
        struct snd_card *card;
        struct snd_ice1712 *ice;
        int pcm_dev = 0, err;
-       struct snd_ice1712_card_info **tbl, *c;
+       struct snd_ice1712_card_info * const *tbl, *c;
 
        if (dev >= SNDRV_CARDS)
                return -ENODEV;
@@ -2652,15 +2669,16 @@ static int __devinit snd_ice1712_probe(struct pci_dev *pci,
                return -ENOENT;
        }
 
-       card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
-       if (card == NULL)
-               return -ENOMEM;
+       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       if (err < 0)
+               return err;
 
        strcpy(card->driver, "ICE1712");
        strcpy(card->shortname, "ICEnsemble ICE1712");
-       
-       if ((err = snd_ice1712_create(card, pci, model[dev], omni[dev],
-                                     cs8427_timeout[dev], &ice)) < 0) {
+
+       err = snd_ice1712_create(card, pci, model[dev], omni[dev],
+               cs8427_timeout[dev], dxr_enable[dev], &ice);
+       if (err < 0) {
                snd_card_free(card);
                return err;
        }
@@ -2672,7 +2690,8 @@ static int __devinit snd_ice1712_probe(struct pci_dev *pci,
                                if (c->driver) /* specific driver? */
                                        strcpy(card->driver, c->driver);
                                if (c->chip_init) {
-                                       if ((err = c->chip_init(ice)) < 0) {
+                                       err = c->chip_init(ice);
+                                       if (err < 0) {
                                                snd_card_free(card);
                                                return err;
                                        }
@@ -2684,57 +2703,81 @@ static int __devinit snd_ice1712_probe(struct pci_dev *pci,
        c = &no_matched;
  __found:
 
-       if ((err = snd_ice1712_pcm_profi(ice, pcm_dev++, NULL)) < 0) {
+       err = snd_ice1712_pcm_profi(ice, pcm_dev++, NULL);
+       if (err < 0) {
                snd_card_free(card);
                return err;
        }
-       
-       if (ice_has_con_ac97(ice))
-               if ((err = snd_ice1712_pcm(ice, pcm_dev++, NULL)) < 0) {
+
+       if (ice_has_con_ac97(ice)) {
+               err = snd_ice1712_pcm(ice, pcm_dev++, NULL);
+               if (err < 0) {
                        snd_card_free(card);
                        return err;
                }
+       }
 
-       if ((err = snd_ice1712_ac97_mixer(ice)) < 0) {
+       err = snd_ice1712_ac97_mixer(ice);
+       if (err < 0) {
                snd_card_free(card);
                return err;
        }
 
-       if ((err = snd_ice1712_build_controls(ice)) < 0) {
+       err = snd_ice1712_build_controls(ice);
+       if (err < 0) {
                snd_card_free(card);
                return err;
        }
 
        if (c->build_controls) {
-               if ((err = c->build_controls(ice)) < 0) {
+               err = c->build_controls(ice);
+               if (err < 0) {
                        snd_card_free(card);
                        return err;
                }
        }
 
-       if (ice_has_con_ac97(ice))
-               if ((err = snd_ice1712_pcm_ds(ice, pcm_dev++, NULL)) < 0) {
+       if (ice_has_con_ac97(ice)) {
+               err = snd_ice1712_pcm_ds(ice, pcm_dev++, NULL);
+               if (err < 0) {
                        snd_card_free(card);
                        return err;
                }
+       }
 
-       if (! c->no_mpu401) {
-               if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_ICE1712,
-                                              ICEREG(ice, MPU1_CTRL), 1,
-                                              ice->irq, 0,
-                                              &ice->rmidi[0])) < 0) {
+       if (!c->no_mpu401) {
+               err = snd_mpu401_uart_new(card, 0, MPU401_HW_ICE1712,
+                       ICEREG(ice, MPU1_CTRL),
+                       (c->mpu401_1_info_flags | MPU401_INFO_INTEGRATED),
+                       ice->irq, 0, &ice->rmidi[0]);
+               if (err < 0) {
                        snd_card_free(card);
                        return err;
                }
-
-               if (ice->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_2xMPU401)
-                       if ((err = snd_mpu401_uart_new(card, 1, MPU401_HW_ICE1712,
-                                                      ICEREG(ice, MPU2_CTRL), 1,
-                                                      ice->irq, 0,
-                                                      &ice->rmidi[1])) < 0) {
+               if (c->mpu401_1_name)
+                       /*  Prefered name available in card_info */
+                       snprintf(ice->rmidi[0]->name,
+                                sizeof(ice->rmidi[0]->name),
+                                "%s %d", c->mpu401_1_name, card->number);
+
+               if (ice->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_2xMPU401) {
+                       /*  2nd port used  */
+                       err = snd_mpu401_uart_new(card, 1, MPU401_HW_ICE1712,
+                               ICEREG(ice, MPU2_CTRL),
+                               (c->mpu401_2_info_flags | MPU401_INFO_INTEGRATED),
+                               ice->irq, 0, &ice->rmidi[1]);
+
+                       if (err < 0) {
                                snd_card_free(card);
                                return err;
                        }
+                       if (c->mpu401_2_name)
+                               /*  Prefered name available in card_info */
+                               snprintf(ice->rmidi[1]->name,
+                                        sizeof(ice->rmidi[1]->name),
+                                        "%s %d", c->mpu401_2_name,
+                                        card->number);
+               }
        }
 
        snd_ice1712_set_input_clock_source(ice, 0);
@@ -2742,7 +2785,8 @@ static int __devinit snd_ice1712_probe(struct pci_dev *pci,
        sprintf(card->longname, "%s at 0x%lx, irq %i",
                card->shortname, ice->port, ice->irq);
 
-       if ((err = snd_card_register(card)) < 0) {
+       err = snd_card_register(card);
+       if (err < 0) {
                snd_card_free(card);
                return err;
        }