Merge branch 'linux-3.4.35' into rel-17
[linux-2.6.git] / sound / pci / rme96.c
index 0eddeb1..ba89415 100644 (file)
  *
  */      
 
-#include <sound/driver.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
-#include <linux/moduleparam.h>
+#include <linux/module.h>
 
 #include <sound/core.h>
 #include <sound/info.h>
@@ -55,7 +53,7 @@ MODULE_SUPPORTED_DEVICE("{{RME,Digi96},"
 
 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 bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;    /* Enable this card */
 
 module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for RME Digi96 soundcard.");
@@ -152,7 +150,7 @@ MODULE_PARM_DESC(enable, "Enable RME Digi96 soundcard.");
 #define RME96_RCR_BITPOS_F1 28
 #define RME96_RCR_BITPOS_F2 29
 
-/* Additonal register bits */
+/* Additional register bits */
 #define RME96_AR_WSEL       (1 << 0)
 #define RME96_AR_ANALOG     (1 << 1)
 #define RME96_AR_FREQPAD_0  (1 << 2)
@@ -201,7 +199,7 @@ MODULE_PARM_DESC(enable, "Enable RME Digi96 soundcard.");
 #define RME96_AD1855_VOL_BITS 10
 
 
-typedef struct snd_rme96 {
+struct rme96 {
        spinlock_t    lock;
        int irq;
        unsigned long port;
@@ -216,8 +214,8 @@ typedef struct snd_rme96 {
 
        u8 rev; /* card revision number */
 
-       snd_pcm_substream_t *playback_substream;
-       snd_pcm_substream_t *capture_substream;
+       struct snd_pcm_substream *playback_substream;
+       struct snd_pcm_substream *capture_substream;
 
        int playback_frlog; /* log2 of framesize */
        int capture_frlog;
@@ -225,22 +223,18 @@ typedef struct snd_rme96 {
         size_t playback_periodsize; /* in bytes, zero if not used */
        size_t capture_periodsize; /* in bytes, zero if not used */
 
-       snd_card_t         *card;
-       snd_pcm_t          *spdif_pcm;
-       snd_pcm_t          *adat_pcm; 
+       struct snd_card *card;
+       struct snd_pcm *spdif_pcm;
+       struct snd_pcm *adat_pcm; 
        struct pci_dev     *pci;
-       snd_kcontrol_t     *spdif_ctl;
-} rme96_t;
-
-static struct pci_device_id snd_rme96_ids[] = {
-       { PCI_VENDOR_ID_XILINX, PCI_DEVICE_ID_RME_DIGI96,
-         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },
-       { PCI_VENDOR_ID_XILINX, PCI_DEVICE_ID_RME_DIGI96_8,
-         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },
-       { PCI_VENDOR_ID_XILINX, PCI_DEVICE_ID_RME_DIGI96_8_PRO,
-         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },
-       { PCI_VENDOR_ID_XILINX, PCI_DEVICE_ID_RME_DIGI96_8_PAD_OR_PST,
-         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, 
+       struct snd_kcontrol   *spdif_ctl;
+};
+
+static DEFINE_PCI_DEVICE_TABLE(snd_rme96_ids) = {
+       { PCI_VDEVICE(XILINX, PCI_DEVICE_ID_RME_DIGI96), 0, },
+       { PCI_VDEVICE(XILINX, PCI_DEVICE_ID_RME_DIGI96_8), 0, },
+       { PCI_VDEVICE(XILINX, PCI_DEVICE_ID_RME_DIGI96_8_PRO), 0, },
+       { PCI_VDEVICE(XILINX, PCI_DEVICE_ID_RME_DIGI96_8_PAD_OR_PST), 0, },
        { 0, }
 };
 
@@ -257,70 +251,56 @@ MODULE_DEVICE_TABLE(pci, snd_rme96_ids);
 #define        RME96_185X_MAX_OUT(rme96) ((1 << (RME96_DAC_IS_1852(rme96) ? RME96_AD1852_VOL_BITS : RME96_AD1855_VOL_BITS)) - 1)
 
 static int
-snd_rme96_playback_prepare(snd_pcm_substream_t *substream);
+snd_rme96_playback_prepare(struct snd_pcm_substream *substream);
 
 static int
-snd_rme96_capture_prepare(snd_pcm_substream_t *substream);
+snd_rme96_capture_prepare(struct snd_pcm_substream *substream);
 
 static int
-snd_rme96_playback_trigger(snd_pcm_substream_t *substream, 
+snd_rme96_playback_trigger(struct snd_pcm_substream *substream, 
                           int cmd);
 
 static int
-snd_rme96_capture_trigger(snd_pcm_substream_t *substream, 
+snd_rme96_capture_trigger(struct snd_pcm_substream *substream, 
                          int cmd);
 
 static snd_pcm_uframes_t
-snd_rme96_playback_pointer(snd_pcm_substream_t *substream);
+snd_rme96_playback_pointer(struct snd_pcm_substream *substream);
 
 static snd_pcm_uframes_t
-snd_rme96_capture_pointer(snd_pcm_substream_t *substream);
+snd_rme96_capture_pointer(struct snd_pcm_substream *substream);
 
 static void __devinit 
-snd_rme96_proc_init(rme96_t *rme96);
+snd_rme96_proc_init(struct rme96 *rme96);
 
 static int
-snd_rme96_create_switches(snd_card_t *card,
-                         rme96_t *rme96);
+snd_rme96_create_switches(struct snd_card *card,
+                         struct rme96 *rme96);
 
 static int
-snd_rme96_getinputtype(rme96_t *rme96);
+snd_rme96_getinputtype(struct rme96 *rme96);
 
 static inline unsigned int
-snd_rme96_playback_ptr(rme96_t *rme96)
+snd_rme96_playback_ptr(struct rme96 *rme96)
 {
        return (readl(rme96->iobase + RME96_IO_GET_PLAY_POS)
                & RME96_RCR_AUDIO_ADDR_MASK) >> rme96->playback_frlog;
 }
 
 static inline unsigned int
-snd_rme96_capture_ptr(rme96_t *rme96)
+snd_rme96_capture_ptr(struct rme96 *rme96)
 {
        return (readl(rme96->iobase + RME96_IO_GET_REC_POS)
                & RME96_RCR_AUDIO_ADDR_MASK) >> rme96->capture_frlog;
 }
 
 static int
-snd_rme96_ratecode(int rate)
-{
-    switch (rate) {
-    case 32000: return SNDRV_PCM_RATE_32000;
-    case 44100: return SNDRV_PCM_RATE_44100;
-    case 48000: return SNDRV_PCM_RATE_48000;
-    case 64000: return SNDRV_PCM_RATE_64000;
-    case 88200: return SNDRV_PCM_RATE_88200;
-    case 96000: return SNDRV_PCM_RATE_96000;
-    }
-    return 0;
-}
-
-static int
-snd_rme96_playback_silence(snd_pcm_substream_t *substream,
+snd_rme96_playback_silence(struct snd_pcm_substream *substream,
                           int channel, /* not used (interleaved data) */
                           snd_pcm_uframes_t pos,
                           snd_pcm_uframes_t count)
 {
-       rme96_t *rme96 = snd_pcm_substream_chip(substream);
+       struct rme96 *rme96 = snd_pcm_substream_chip(substream);
        count <<= rme96->playback_frlog;
        pos <<= rme96->playback_frlog;
        memset_io(rme96->iobase + RME96_IO_PLAY_BUFFER + pos,
@@ -329,13 +309,13 @@ snd_rme96_playback_silence(snd_pcm_substream_t *substream,
 }
 
 static int
-snd_rme96_playback_copy(snd_pcm_substream_t *substream,
+snd_rme96_playback_copy(struct snd_pcm_substream *substream,
                        int channel, /* not used (interleaved data) */
                        snd_pcm_uframes_t pos,
                        void __user *src,
                        snd_pcm_uframes_t count)
 {
-       rme96_t *rme96 = snd_pcm_substream_chip(substream);
+       struct rme96 *rme96 = snd_pcm_substream_chip(substream);
        count <<= rme96->playback_frlog;
        pos <<= rme96->playback_frlog;
        copy_from_user_toio(rme96->iobase + RME96_IO_PLAY_BUFFER + pos, src,
@@ -344,13 +324,13 @@ snd_rme96_playback_copy(snd_pcm_substream_t *substream,
 }
 
 static int
-snd_rme96_capture_copy(snd_pcm_substream_t *substream,
+snd_rme96_capture_copy(struct snd_pcm_substream *substream,
                       int channel, /* not used (interleaved data) */
                       snd_pcm_uframes_t pos,
                       void __user *dst,
                       snd_pcm_uframes_t count)
 {
-       rme96_t *rme96 = snd_pcm_substream_chip(substream);
+       struct rme96 *rme96 = snd_pcm_substream_chip(substream);
        count <<= rme96->capture_frlog;
        pos <<= rme96->capture_frlog;
        copy_to_user_fromio(dst, rme96->iobase + RME96_IO_REC_BUFFER + pos,
@@ -359,9 +339,9 @@ snd_rme96_capture_copy(snd_pcm_substream_t *substream,
 }
 
 /*
- * Digital output capabilites (S/PDIF)
+ * Digital output capabilities (S/PDIF)
  */
-static snd_pcm_hardware_t snd_rme96_playback_spdif_info =
+static struct snd_pcm_hardware snd_rme96_playback_spdif_info =
 {
        .info =              (SNDRV_PCM_INFO_MMAP_IOMEM |
                              SNDRV_PCM_INFO_MMAP_VALID |
@@ -388,9 +368,9 @@ static snd_pcm_hardware_t snd_rme96_playback_spdif_info =
 };
 
 /*
- * Digital input capabilites (S/PDIF)
+ * Digital input capabilities (S/PDIF)
  */
-static snd_pcm_hardware_t snd_rme96_capture_spdif_info =
+static struct snd_pcm_hardware snd_rme96_capture_spdif_info =
 {
        .info =              (SNDRV_PCM_INFO_MMAP_IOMEM |
                              SNDRV_PCM_INFO_MMAP_VALID |
@@ -417,9 +397,9 @@ static snd_pcm_hardware_t snd_rme96_capture_spdif_info =
 };
 
 /*
- * Digital output capabilites (ADAT)
+ * Digital output capabilities (ADAT)
  */
-static snd_pcm_hardware_t snd_rme96_playback_adat_info =
+static struct snd_pcm_hardware snd_rme96_playback_adat_info =
 {
        .info =              (SNDRV_PCM_INFO_MMAP_IOMEM |
                              SNDRV_PCM_INFO_MMAP_VALID |
@@ -442,9 +422,9 @@ static snd_pcm_hardware_t snd_rme96_playback_adat_info =
 };
 
 /*
- * Digital input capabilites (ADAT)
+ * Digital input capabilities (ADAT)
  */
-static snd_pcm_hardware_t snd_rme96_capture_adat_info =
+static struct snd_pcm_hardware snd_rme96_capture_adat_info =
 {
        .info =              (SNDRV_PCM_INFO_MMAP_IOMEM |
                              SNDRV_PCM_INFO_MMAP_VALID |
@@ -479,7 +459,7 @@ static snd_pcm_hardware_t snd_rme96_capture_adat_info =
  * the volume.
  */
 static void
-snd_rme96_write_SPI(rme96_t *rme96, u16 val)
+snd_rme96_write_SPI(struct rme96 *rme96, u16 val)
 {
        int i;
 
@@ -506,7 +486,7 @@ snd_rme96_write_SPI(rme96_t *rme96, u16 val)
 }
 
 static void
-snd_rme96_apply_dac_volume(rme96_t *rme96)
+snd_rme96_apply_dac_volume(struct rme96 *rme96)
 {
        if (RME96_DAC_IS_1852(rme96)) {
                snd_rme96_write_SPI(rme96, (rme96->vol[0] << 2) | 0x0);
@@ -518,7 +498,7 @@ snd_rme96_apply_dac_volume(rme96_t *rme96)
 }
 
 static void
-snd_rme96_reset_dac(rme96_t *rme96)
+snd_rme96_reset_dac(struct rme96 *rme96)
 {
        writel(rme96->wcreg | RME96_WCR_PD,
               rme96->iobase + RME96_IO_CONTROL_REGISTER);
@@ -526,14 +506,14 @@ snd_rme96_reset_dac(rme96_t *rme96)
 }
 
 static int
-snd_rme96_getmontracks(rme96_t *rme96)
+snd_rme96_getmontracks(struct rme96 *rme96)
 {
        return ((rme96->wcreg >> RME96_WCR_BITPOS_MONITOR_0) & 1) +
                (((rme96->wcreg >> RME96_WCR_BITPOS_MONITOR_1) & 1) << 1);
 }
 
 static int
-snd_rme96_setmontracks(rme96_t *rme96,
+snd_rme96_setmontracks(struct rme96 *rme96,
                       int montracks)
 {
        if (montracks & 1) {
@@ -551,14 +531,14 @@ snd_rme96_setmontracks(rme96_t *rme96,
 }
 
 static int
-snd_rme96_getattenuation(rme96_t *rme96)
+snd_rme96_getattenuation(struct rme96 *rme96)
 {
        return ((rme96->wcreg >> RME96_WCR_BITPOS_GAIN_0) & 1) +
                (((rme96->wcreg >> RME96_WCR_BITPOS_GAIN_1) & 1) << 1);
 }
 
 static int
-snd_rme96_setattenuation(rme96_t *rme96,
+snd_rme96_setattenuation(struct rme96 *rme96,
                         int attenuation)
 {
        switch (attenuation) {
@@ -586,7 +566,7 @@ snd_rme96_setattenuation(rme96_t *rme96,
 }
 
 static int
-snd_rme96_capture_getrate(rme96_t *rme96,
+snd_rme96_capture_getrate(struct rme96 *rme96,
                          int *is_adat)
 {      
        int n, rate;
@@ -649,7 +629,7 @@ snd_rme96_capture_getrate(rme96_t *rme96,
 }
 
 static int
-snd_rme96_playback_getrate(rme96_t *rme96)
+snd_rme96_playback_getrate(struct rme96 *rme96)
 {
        int rate, dummy;
 
@@ -679,7 +659,7 @@ snd_rme96_playback_getrate(rme96_t *rme96)
 }
 
 static int
-snd_rme96_playback_setrate(rme96_t *rme96,
+snd_rme96_playback_setrate(struct rme96 *rme96,
                           int rate)
 {
        int ds;
@@ -731,7 +711,7 @@ snd_rme96_playback_setrate(rme96_t *rme96,
 }
 
 static int
-snd_rme96_capture_analog_setrate(rme96_t *rme96,
+snd_rme96_capture_analog_setrate(struct rme96 *rme96,
                                 int rate)
 {
        switch (rate) {
@@ -773,7 +753,7 @@ snd_rme96_capture_analog_setrate(rme96_t *rme96,
 }
 
 static int
-snd_rme96_setclockmode(rme96_t *rme96,
+snd_rme96_setclockmode(struct rme96 *rme96,
                       int mode)
 {
        switch (mode) {
@@ -801,7 +781,7 @@ snd_rme96_setclockmode(rme96_t *rme96,
 }
 
 static int
-snd_rme96_getclockmode(rme96_t *rme96)
+snd_rme96_getclockmode(struct rme96 *rme96)
 {
        if (rme96->areg & RME96_AR_WSEL) {
                return RME96_CLOCKMODE_WORDCLOCK;
@@ -811,7 +791,7 @@ snd_rme96_getclockmode(rme96_t *rme96)
 }
 
 static int
-snd_rme96_setinputtype(rme96_t *rme96,
+snd_rme96_setinputtype(struct rme96 *rme96,
                       int type)
 {
        int n;
@@ -872,7 +852,7 @@ snd_rme96_setinputtype(rme96_t *rme96,
 }
 
 static int
-snd_rme96_getinputtype(rme96_t *rme96)
+snd_rme96_getinputtype(struct rme96 *rme96)
 {
        if (rme96->areg & RME96_AR_ANALOG) {
                return RME96_INPUT_ANALOG;
@@ -882,7 +862,7 @@ snd_rme96_getinputtype(rme96_t *rme96)
 }
 
 static void
-snd_rme96_setframelog(rme96_t *rme96,
+snd_rme96_setframelog(struct rme96 *rme96,
                      int n_channels,
                      int is_playback)
 {
@@ -904,7 +884,7 @@ snd_rme96_setframelog(rme96_t *rme96,
 }
 
 static int
-snd_rme96_playback_setformat(rme96_t *rme96,
+snd_rme96_playback_setformat(struct rme96 *rme96,
                             int format)
 {
        switch (format) {
@@ -922,7 +902,7 @@ snd_rme96_playback_setformat(rme96_t *rme96,
 }
 
 static int
-snd_rme96_capture_setformat(rme96_t *rme96,
+snd_rme96_capture_setformat(struct rme96 *rme96,
                            int format)
 {
        switch (format) {
@@ -940,7 +920,7 @@ snd_rme96_capture_setformat(rme96_t *rme96,
 }
 
 static void
-snd_rme96_set_period_properties(rme96_t *rme96,
+snd_rme96_set_period_properties(struct rme96 *rme96,
                                size_t period_bytes)
 {
        switch (period_bytes) {
@@ -959,11 +939,11 @@ snd_rme96_set_period_properties(rme96_t *rme96,
 }
 
 static int
-snd_rme96_playback_hw_params(snd_pcm_substream_t *substream,
-                            snd_pcm_hw_params_t *params)
+snd_rme96_playback_hw_params(struct snd_pcm_substream *substream,
+                            struct snd_pcm_hw_params *params)
 {
-       rme96_t *rme96 = snd_pcm_substream_chip(substream);
-       snd_pcm_runtime_t *runtime = substream->runtime;
+       struct rme96 *rme96 = snd_pcm_substream_chip(substream);
+       struct snd_pcm_runtime *runtime = substream->runtime;
        int err, rate, dummy;
 
        runtime->dma_area = (void __force *)(rme96->iobase +
@@ -1012,11 +992,11 @@ snd_rme96_playback_hw_params(snd_pcm_substream_t *substream,
 }
 
 static int
-snd_rme96_capture_hw_params(snd_pcm_substream_t *substream,
-                           snd_pcm_hw_params_t *params)
+snd_rme96_capture_hw_params(struct snd_pcm_substream *substream,
+                           struct snd_pcm_hw_params *params)
 {
-       rme96_t *rme96 = snd_pcm_substream_chip(substream);
-       snd_pcm_runtime_t *runtime = substream->runtime;
+       struct rme96 *rme96 = snd_pcm_substream_chip(substream);
+       struct snd_pcm_runtime *runtime = substream->runtime;
        int err, isadat, rate;
        
        runtime->dma_area = (void __force *)(rme96->iobase +
@@ -1066,7 +1046,7 @@ snd_rme96_capture_hw_params(snd_pcm_substream_t *substream,
 }
 
 static void
-snd_rme96_playback_start(rme96_t *rme96,
+snd_rme96_playback_start(struct rme96 *rme96,
                         int from_pause)
 {
        if (!from_pause) {
@@ -1078,7 +1058,7 @@ snd_rme96_playback_start(rme96_t *rme96,
 }
 
 static void
-snd_rme96_capture_start(rme96_t *rme96,
+snd_rme96_capture_start(struct rme96 *rme96,
                        int from_pause)
 {
        if (!from_pause) {
@@ -1090,7 +1070,7 @@ snd_rme96_capture_start(rme96_t *rme96,
 }
 
 static void
-snd_rme96_playback_stop(rme96_t *rme96)
+snd_rme96_playback_stop(struct rme96 *rme96)
 {
        /*
         * Check if there is an unconfirmed IRQ, if so confirm it, or else
@@ -1105,7 +1085,7 @@ snd_rme96_playback_stop(rme96_t *rme96)
 }
 
 static void
-snd_rme96_capture_stop(rme96_t *rme96)
+snd_rme96_capture_stop(struct rme96 *rme96)
 {
        rme96->rcreg = readl(rme96->iobase + RME96_IO_CONTROL_REGISTER);
        if (rme96->rcreg & RME96_RCR_IRQ_2) {
@@ -1117,10 +1097,9 @@ snd_rme96_capture_stop(rme96_t *rme96)
 
 static irqreturn_t
 snd_rme96_interrupt(int irq,
-                   void *dev_id,
-                   struct pt_regs *regs)
+                   void *dev_id)
 {
-       rme96_t *rme96 = (rme96_t *)dev_id;
+       struct rme96 *rme96 = (struct rme96 *)dev_id;
 
        rme96->rcreg = readl(rme96->iobase + RME96_IO_CONTROL_REGISTER);
        /* fastpath out, to ease interrupt sharing */
@@ -1145,20 +1124,37 @@ snd_rme96_interrupt(int irq,
 
 static unsigned int period_bytes[] = { RME96_SMALL_BLOCK_SIZE, RME96_LARGE_BLOCK_SIZE };
 
-static snd_pcm_hw_constraint_list_t hw_constraints_period_bytes = {
+static struct snd_pcm_hw_constraint_list hw_constraints_period_bytes = {
        .count = ARRAY_SIZE(period_bytes),
        .list = period_bytes,
        .mask = 0
 };
 
+static void
+rme96_set_buffer_size_constraint(struct rme96 *rme96,
+                                struct snd_pcm_runtime *runtime)
+{
+       unsigned int size;
+
+       snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
+                                    RME96_BUFFER_SIZE, RME96_BUFFER_SIZE);
+       if ((size = rme96->playback_periodsize) != 0 ||
+           (size = rme96->capture_periodsize) != 0)
+               snd_pcm_hw_constraint_minmax(runtime,
+                                            SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
+                                            size, size);
+       else
+               snd_pcm_hw_constraint_list(runtime, 0,
+                                          SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
+                                          &hw_constraints_period_bytes);
+}
+
 static int
-snd_rme96_playback_spdif_open(snd_pcm_substream_t *substream)
+snd_rme96_playback_spdif_open(struct snd_pcm_substream *substream)
 {
         int rate, dummy;
-       rme96_t *rme96 = snd_pcm_substream_chip(substream);
-       snd_pcm_runtime_t *runtime = substream->runtime;
-
-       snd_pcm_set_sync(substream);
+       struct rme96 *rme96 = snd_pcm_substream_chip(substream);
+       struct snd_pcm_runtime *runtime = substream->runtime;
 
        spin_lock_irq(&rme96->lock);    
         if (rme96->playback_substream != NULL) {
@@ -1176,12 +1172,11 @@ snd_rme96_playback_spdif_open(snd_pcm_substream_t *substream)
            (rate = snd_rme96_capture_getrate(rme96, &dummy)) > 0)
        {
                 /* slave clock */
-                runtime->hw.rates = snd_rme96_ratecode(rate);
+                runtime->hw.rates = snd_pcm_rate_to_rate_bit(rate);
                 runtime->hw.rate_min = rate;
                 runtime->hw.rate_max = rate;
        }        
-       snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, RME96_BUFFER_SIZE, RME96_BUFFER_SIZE);
-       snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, &hw_constraints_period_bytes);
+       rme96_set_buffer_size_constraint(rme96, runtime);
 
        rme96->wcreg_spdif_stream = rme96->wcreg_spdif;
        rme96->spdif_ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
@@ -1191,13 +1186,11 @@ snd_rme96_playback_spdif_open(snd_pcm_substream_t *substream)
 }
 
 static int
-snd_rme96_capture_spdif_open(snd_pcm_substream_t *substream)
+snd_rme96_capture_spdif_open(struct snd_pcm_substream *substream)
 {
         int isadat, rate;
-       rme96_t *rme96 = snd_pcm_substream_chip(substream);
-       snd_pcm_runtime_t *runtime = substream->runtime;
-
-       snd_pcm_set_sync(substream);
+       struct rme96 *rme96 = snd_pcm_substream_chip(substream);
+       struct snd_pcm_runtime *runtime = substream->runtime;
 
        runtime->hw = snd_rme96_capture_spdif_info;
         if (snd_rme96_getinputtype(rme96) != RME96_INPUT_ANALOG &&
@@ -1206,7 +1199,7 @@ snd_rme96_capture_spdif_open(snd_pcm_substream_t *substream)
                 if (isadat) {
                         return -EIO;
                 }
-                runtime->hw.rates = snd_rme96_ratecode(rate);
+                runtime->hw.rates = snd_pcm_rate_to_rate_bit(rate);
                 runtime->hw.rate_min = rate;
                 runtime->hw.rate_max = rate;
         }
@@ -1219,21 +1212,17 @@ snd_rme96_capture_spdif_open(snd_pcm_substream_t *substream)
        rme96->capture_substream = substream;
        spin_unlock_irq(&rme96->lock);
        
-       snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, RME96_BUFFER_SIZE, RME96_BUFFER_SIZE);
-       snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, &hw_constraints_period_bytes);
-
+       rme96_set_buffer_size_constraint(rme96, runtime);
        return 0;
 }
 
 static int
-snd_rme96_playback_adat_open(snd_pcm_substream_t *substream)
+snd_rme96_playback_adat_open(struct snd_pcm_substream *substream)
 {
         int rate, dummy;
-       rme96_t *rme96 = snd_pcm_substream_chip(substream);
-       snd_pcm_runtime_t *runtime = substream->runtime;        
+       struct rme96 *rme96 = snd_pcm_substream_chip(substream);
+       struct snd_pcm_runtime *runtime = substream->runtime;        
        
-       snd_pcm_set_sync(substream);
-
        spin_lock_irq(&rme96->lock);    
         if (rme96->playback_substream != NULL) {
                spin_unlock_irq(&rme96->lock);
@@ -1250,23 +1239,20 @@ snd_rme96_playback_adat_open(snd_pcm_substream_t *substream)
            (rate = snd_rme96_capture_getrate(rme96, &dummy)) > 0)
        {
                 /* slave clock */
-                runtime->hw.rates = snd_rme96_ratecode(rate);
+                runtime->hw.rates = snd_pcm_rate_to_rate_bit(rate);
                 runtime->hw.rate_min = rate;
                 runtime->hw.rate_max = rate;
        }        
-       snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, RME96_BUFFER_SIZE, RME96_BUFFER_SIZE);
-       snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, &hw_constraints_period_bytes);
+       rme96_set_buffer_size_constraint(rme96, runtime);
        return 0;
 }
 
 static int
-snd_rme96_capture_adat_open(snd_pcm_substream_t *substream)
+snd_rme96_capture_adat_open(struct snd_pcm_substream *substream)
 {
         int isadat, rate;
-       rme96_t *rme96 = snd_pcm_substream_chip(substream);
-       snd_pcm_runtime_t *runtime = substream->runtime;
-
-       snd_pcm_set_sync(substream);
+       struct rme96 *rme96 = snd_pcm_substream_chip(substream);
+       struct snd_pcm_runtime *runtime = substream->runtime;
 
        runtime->hw = snd_rme96_capture_adat_info;
         if (snd_rme96_getinputtype(rme96) == RME96_INPUT_ANALOG) {
@@ -1278,7 +1264,7 @@ snd_rme96_capture_adat_open(snd_pcm_substream_t *substream)
                 if (!isadat) {
                         return -EIO;
                 }
-                runtime->hw.rates = snd_rme96_ratecode(rate);
+                runtime->hw.rates = snd_pcm_rate_to_rate_bit(rate);
                 runtime->hw.rate_min = rate;
                 runtime->hw.rate_max = rate;
         }
@@ -1291,15 +1277,14 @@ snd_rme96_capture_adat_open(snd_pcm_substream_t *substream)
        rme96->capture_substream = substream;
        spin_unlock_irq(&rme96->lock);
 
-       snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, RME96_BUFFER_SIZE, RME96_BUFFER_SIZE);
-       snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, &hw_constraints_period_bytes);
+       rme96_set_buffer_size_constraint(rme96, runtime);
        return 0;
 }
 
 static int
-snd_rme96_playback_close(snd_pcm_substream_t *substream)
+snd_rme96_playback_close(struct snd_pcm_substream *substream)
 {
-       rme96_t *rme96 = snd_pcm_substream_chip(substream);
+       struct rme96 *rme96 = snd_pcm_substream_chip(substream);
        int spdif = 0;
 
        spin_lock_irq(&rme96->lock);    
@@ -1319,9 +1304,9 @@ snd_rme96_playback_close(snd_pcm_substream_t *substream)
 }
 
 static int
-snd_rme96_capture_close(snd_pcm_substream_t *substream)
+snd_rme96_capture_close(struct snd_pcm_substream *substream)
 {
-       rme96_t *rme96 = snd_pcm_substream_chip(substream);
+       struct rme96 *rme96 = snd_pcm_substream_chip(substream);
        
        spin_lock_irq(&rme96->lock);    
        if (RME96_ISRECORDING(rme96)) {
@@ -1334,9 +1319,9 @@ snd_rme96_capture_close(snd_pcm_substream_t *substream)
 }
 
 static int
-snd_rme96_playback_prepare(snd_pcm_substream_t *substream)
+snd_rme96_playback_prepare(struct snd_pcm_substream *substream)
 {
-       rme96_t *rme96 = snd_pcm_substream_chip(substream);
+       struct rme96 *rme96 = snd_pcm_substream_chip(substream);
        
        spin_lock_irq(&rme96->lock);    
        if (RME96_ISPLAYING(rme96)) {
@@ -1348,9 +1333,9 @@ snd_rme96_playback_prepare(snd_pcm_substream_t *substream)
 }
 
 static int
-snd_rme96_capture_prepare(snd_pcm_substream_t *substream)
+snd_rme96_capture_prepare(struct snd_pcm_substream *substream)
 {
-       rme96_t *rme96 = snd_pcm_substream_chip(substream);
+       struct rme96 *rme96 = snd_pcm_substream_chip(substream);
        
        spin_lock_irq(&rme96->lock);    
        if (RME96_ISRECORDING(rme96)) {
@@ -1362,10 +1347,10 @@ snd_rme96_capture_prepare(snd_pcm_substream_t *substream)
 }
 
 static int
-snd_rme96_playback_trigger(snd_pcm_substream_t *substream, 
+snd_rme96_playback_trigger(struct snd_pcm_substream *substream, 
                           int cmd)
 {
-       rme96_t *rme96 = snd_pcm_substream_chip(substream);
+       struct rme96 *rme96 = snd_pcm_substream_chip(substream);
 
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_START:
@@ -1405,10 +1390,10 @@ snd_rme96_playback_trigger(snd_pcm_substream_t *substream,
 }
 
 static int
-snd_rme96_capture_trigger(snd_pcm_substream_t *substream, 
+snd_rme96_capture_trigger(struct snd_pcm_substream *substream, 
                          int cmd)
 {
-       rme96_t *rme96 = snd_pcm_substream_chip(substream);
+       struct rme96 *rme96 = snd_pcm_substream_chip(substream);
 
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_START:
@@ -1449,20 +1434,20 @@ snd_rme96_capture_trigger(snd_pcm_substream_t *substream,
 }
 
 static snd_pcm_uframes_t
-snd_rme96_playback_pointer(snd_pcm_substream_t *substream)
+snd_rme96_playback_pointer(struct snd_pcm_substream *substream)
 {
-       rme96_t *rme96 = snd_pcm_substream_chip(substream);
+       struct rme96 *rme96 = snd_pcm_substream_chip(substream);
        return snd_rme96_playback_ptr(rme96);
 }
 
 static snd_pcm_uframes_t
-snd_rme96_capture_pointer(snd_pcm_substream_t *substream)
+snd_rme96_capture_pointer(struct snd_pcm_substream *substream)
 {
-       rme96_t *rme96 = snd_pcm_substream_chip(substream);
+       struct rme96 *rme96 = snd_pcm_substream_chip(substream);
        return snd_rme96_capture_ptr(rme96);
 }
 
-static snd_pcm_ops_t snd_rme96_playback_spdif_ops = {
+static struct snd_pcm_ops snd_rme96_playback_spdif_ops = {
        .open =         snd_rme96_playback_spdif_open,
        .close =        snd_rme96_playback_close,
        .ioctl =        snd_pcm_lib_ioctl,
@@ -1475,7 +1460,7 @@ static snd_pcm_ops_t snd_rme96_playback_spdif_ops = {
        .mmap =         snd_pcm_lib_mmap_iomem,
 };
 
-static snd_pcm_ops_t snd_rme96_capture_spdif_ops = {
+static struct snd_pcm_ops snd_rme96_capture_spdif_ops = {
        .open =         snd_rme96_capture_spdif_open,
        .close =        snd_rme96_capture_close,
        .ioctl =        snd_pcm_lib_ioctl,
@@ -1487,7 +1472,7 @@ static snd_pcm_ops_t snd_rme96_capture_spdif_ops = {
        .mmap =         snd_pcm_lib_mmap_iomem,
 };
 
-static snd_pcm_ops_t snd_rme96_playback_adat_ops = {
+static struct snd_pcm_ops snd_rme96_playback_adat_ops = {
        .open =         snd_rme96_playback_adat_open,
        .close =        snd_rme96_playback_close,
        .ioctl =        snd_pcm_lib_ioctl,
@@ -1500,7 +1485,7 @@ static snd_pcm_ops_t snd_rme96_playback_adat_ops = {
        .mmap =         snd_pcm_lib_mmap_iomem,
 };
 
-static snd_pcm_ops_t snd_rme96_capture_adat_ops = {
+static struct snd_pcm_ops snd_rme96_capture_adat_ops = {
        .open =         snd_rme96_capture_adat_open,
        .close =        snd_rme96_capture_close,
        .ioctl =        snd_pcm_lib_ioctl,
@@ -1515,7 +1500,7 @@ static snd_pcm_ops_t snd_rme96_capture_adat_ops = {
 static void
 snd_rme96_free(void *private_data)
 {
-       rme96_t *rme96 = (rme96_t *)private_data;
+       struct rme96 *rme96 = (struct rme96 *)private_data;
 
        if (rme96 == NULL) {
                return;
@@ -1540,21 +1525,21 @@ snd_rme96_free(void *private_data)
 }
 
 static void
-snd_rme96_free_spdif_pcm(snd_pcm_t *pcm)
+snd_rme96_free_spdif_pcm(struct snd_pcm *pcm)
 {
-       rme96_t *rme96 = (rme96_t *) pcm->private_data;
+       struct rme96 *rme96 = pcm->private_data;
        rme96->spdif_pcm = NULL;
 }
 
 static void
-snd_rme96_free_adat_pcm(snd_pcm_t *pcm)
+snd_rme96_free_adat_pcm(struct snd_pcm *pcm)
 {
-       rme96_t *rme96 = (rme96_t *) pcm->private_data;
+       struct rme96 *rme96 = pcm->private_data;
        rme96->adat_pcm = NULL;
 }
 
 static int __devinit
-snd_rme96_create(rme96_t *rme96)
+snd_rme96_create(struct rme96 *rme96)
 {
        struct pci_dev *pci = rme96->pci;
        int err;
@@ -1569,17 +1554,19 @@ snd_rme96_create(rme96_t *rme96)
                return err;
        rme96->port = pci_resource_start(rme96->pci, 0);
 
-       if (request_irq(pci->irq, snd_rme96_interrupt, SA_INTERRUPT|SA_SHIRQ, "RME96", (void *)rme96)) {
+       rme96->iobase = ioremap_nocache(rme96->port, RME96_IO_SIZE);
+       if (!rme96->iobase) {
+               snd_printk(KERN_ERR "unable to remap memory region 0x%lx-0x%lx\n", rme96->port, rme96->port + RME96_IO_SIZE - 1);
+               return -ENOMEM;
+       }
+
+       if (request_irq(pci->irq, snd_rme96_interrupt, IRQF_SHARED,
+                       KBUILD_MODNAME, rme96)) {
                snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
                return -EBUSY;
        }
        rme96->irq = pci->irq;
 
-       if ((rme96->iobase = ioremap_nocache(rme96->port, RME96_IO_SIZE)) == 0) {
-               snd_printk(KERN_ERR "unable to remap memory region 0x%lx-0x%lx\n", rme96->port, rme96->port + RME96_IO_SIZE - 1);
-               return -ENOMEM;
-       }
-
        /* read the card's revision number */
        pci_read_config_byte(pci, 8, &rme96->rev);      
        
@@ -1671,10 +1658,10 @@ snd_rme96_create(rme96_t *rme96)
  */
 
 static void 
-snd_rme96_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer)
+snd_rme96_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
 {
        int n;
-       rme96_t *rme96 = (rme96_t *)entry->private_data;
+       struct rme96 *rme96 = entry->private_data;
        
        rme96->rcreg = readl(rme96->iobase + RME96_IO_CONTROL_REGISTER);
 
@@ -1800,31 +1787,24 @@ snd_rme96_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer)
 }
 
 static void __devinit 
-snd_rme96_proc_init(rme96_t *rme96)
+snd_rme96_proc_init(struct rme96 *rme96)
 {
-       snd_info_entry_t *entry;
+       struct snd_info_entry *entry;
 
        if (! snd_card_proc_new(rme96->card, "rme96", &entry))
-               snd_info_set_text_ops(entry, rme96, 1024, snd_rme96_proc_read);
+               snd_info_set_text_ops(entry, rme96, snd_rme96_proc_read);
 }
 
 /*
  * control interface
  */
 
+#define snd_rme96_info_loopback_control                snd_ctl_boolean_mono_info
+
 static int
-snd_rme96_info_loopback_control(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
-{
-       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
-       uinfo->count = 1;
-       uinfo->value.integer.min = 0;
-       uinfo->value.integer.max = 1;
-       return 0;
-}
-static int
-snd_rme96_get_loopback_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+snd_rme96_get_loopback_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       rme96_t *rme96 = snd_kcontrol_chip(kcontrol);
+       struct rme96 *rme96 = snd_kcontrol_chip(kcontrol);
        
        spin_lock_irq(&rme96->lock);
        ucontrol->value.integer.value[0] = rme96->wcreg & RME96_WCR_SEL ? 0 : 1;
@@ -1832,9 +1812,9 @@ snd_rme96_get_loopback_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
        return 0;
 }
 static int
-snd_rme96_put_loopback_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+snd_rme96_put_loopback_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       rme96_t *rme96 = snd_kcontrol_chip(kcontrol);
+       struct rme96 *rme96 = snd_kcontrol_chip(kcontrol);
        unsigned int val;
        int change;
        
@@ -1849,10 +1829,10 @@ snd_rme96_put_loopback_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
 }
 
 static int
-snd_rme96_info_inputtype_control(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+snd_rme96_info_inputtype_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        static char *_texts[5] = { "Optical", "Coaxial", "Internal", "XLR", "Analog" };
-       rme96_t *rme96 = snd_kcontrol_chip(kcontrol);
+       struct rme96 *rme96 = snd_kcontrol_chip(kcontrol);
        char *texts[5] = { _texts[0], _texts[1], _texts[2], _texts[3], _texts[4] };
        
        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
@@ -1886,9 +1866,9 @@ snd_rme96_info_inputtype_control(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *
        return 0;
 }
 static int
-snd_rme96_get_inputtype_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+snd_rme96_get_inputtype_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       rme96_t *rme96 = snd_kcontrol_chip(kcontrol);
+       struct rme96 *rme96 = snd_kcontrol_chip(kcontrol);
        unsigned int items = 3;
        
        spin_lock_irq(&rme96->lock);
@@ -1925,9 +1905,9 @@ snd_rme96_get_inputtype_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
        return 0;
 }
 static int
-snd_rme96_put_inputtype_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+snd_rme96_put_inputtype_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       rme96_t *rme96 = snd_kcontrol_chip(kcontrol);
+       struct rme96 *rme96 = snd_kcontrol_chip(kcontrol);
        unsigned int val;
        int change, items = 3;
        
@@ -1967,7 +1947,7 @@ snd_rme96_put_inputtype_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
 }
 
 static int
-snd_rme96_info_clockmode_control(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+snd_rme96_info_clockmode_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        static char *texts[3] = { "AutoSync", "Internal", "Word" };
        
@@ -1981,9 +1961,9 @@ snd_rme96_info_clockmode_control(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *
        return 0;
 }
 static int
-snd_rme96_get_clockmode_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+snd_rme96_get_clockmode_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       rme96_t *rme96 = snd_kcontrol_chip(kcontrol);
+       struct rme96 *rme96 = snd_kcontrol_chip(kcontrol);
        
        spin_lock_irq(&rme96->lock);
        ucontrol->value.enumerated.item[0] = snd_rme96_getclockmode(rme96);
@@ -1991,9 +1971,9 @@ snd_rme96_get_clockmode_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
        return 0;
 }
 static int
-snd_rme96_put_clockmode_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+snd_rme96_put_clockmode_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       rme96_t *rme96 = snd_kcontrol_chip(kcontrol);
+       struct rme96 *rme96 = snd_kcontrol_chip(kcontrol);
        unsigned int val;
        int change;
        
@@ -2006,7 +1986,7 @@ snd_rme96_put_clockmode_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
 }
 
 static int
-snd_rme96_info_attenuation_control(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+snd_rme96_info_attenuation_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        static char *texts[4] = { "0 dB", "-6 dB", "-12 dB", "-18 dB" };
        
@@ -2020,9 +2000,9 @@ snd_rme96_info_attenuation_control(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t
        return 0;
 }
 static int
-snd_rme96_get_attenuation_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+snd_rme96_get_attenuation_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       rme96_t *rme96 = snd_kcontrol_chip(kcontrol);
+       struct rme96 *rme96 = snd_kcontrol_chip(kcontrol);
        
        spin_lock_irq(&rme96->lock);
        ucontrol->value.enumerated.item[0] = snd_rme96_getattenuation(rme96);
@@ -2030,9 +2010,9 @@ snd_rme96_get_attenuation_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
        return 0;
 }
 static int
-snd_rme96_put_attenuation_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+snd_rme96_put_attenuation_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       rme96_t *rme96 = snd_kcontrol_chip(kcontrol);
+       struct rme96 *rme96 = snd_kcontrol_chip(kcontrol);
        unsigned int val;
        int change;
        
@@ -2046,7 +2026,7 @@ snd_rme96_put_attenuation_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
 }
 
 static int
-snd_rme96_info_montracks_control(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+snd_rme96_info_montracks_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        static char *texts[4] = { "1+2", "3+4", "5+6", "7+8" };
        
@@ -2060,9 +2040,9 @@ snd_rme96_info_montracks_control(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *
        return 0;
 }
 static int
-snd_rme96_get_montracks_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+snd_rme96_get_montracks_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       rme96_t *rme96 = snd_kcontrol_chip(kcontrol);
+       struct rme96 *rme96 = snd_kcontrol_chip(kcontrol);
        
        spin_lock_irq(&rme96->lock);
        ucontrol->value.enumerated.item[0] = snd_rme96_getmontracks(rme96);
@@ -2070,9 +2050,9 @@ snd_rme96_get_montracks_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
        return 0;
 }
 static int
-snd_rme96_put_montracks_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+snd_rme96_put_montracks_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       rme96_t *rme96 = snd_kcontrol_chip(kcontrol);
+       struct rme96 *rme96 = snd_kcontrol_chip(kcontrol);
        unsigned int val;
        int change;
        
@@ -2084,7 +2064,7 @@ snd_rme96_put_montracks_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
        return change;
 }
 
-static u32 snd_rme96_convert_from_aes(snd_aes_iec958_t *aes)
+static u32 snd_rme96_convert_from_aes(struct snd_aes_iec958 *aes)
 {
        u32 val = 0;
        val |= (aes->status[0] & IEC958_AES0_PROFESSIONAL) ? RME96_WCR_PRO : 0;
@@ -2096,7 +2076,7 @@ static u32 snd_rme96_convert_from_aes(snd_aes_iec958_t *aes)
        return val;
 }
 
-static void snd_rme96_convert_to_aes(snd_aes_iec958_t *aes, u32 val)
+static void snd_rme96_convert_to_aes(struct snd_aes_iec958 *aes, u32 val)
 {
        aes->status[0] = ((val & RME96_WCR_PRO) ? IEC958_AES0_PROFESSIONAL : 0) |
                         ((val & RME96_WCR_DOLBY) ? IEC958_AES0_NONAUDIO : 0);
@@ -2106,24 +2086,24 @@ static void snd_rme96_convert_to_aes(snd_aes_iec958_t *aes, u32 val)
                aes->status[0] |= (val & RME96_WCR_EMP) ? IEC958_AES0_CON_EMPHASIS_5015 : 0;
 }
 
-static int snd_rme96_control_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_rme96_control_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
        uinfo->count = 1;
        return 0;
 }
 
-static int snd_rme96_control_spdif_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_rme96_control_spdif_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       rme96_t *rme96 = snd_kcontrol_chip(kcontrol);
+       struct rme96 *rme96 = snd_kcontrol_chip(kcontrol);
        
        snd_rme96_convert_to_aes(&ucontrol->value.iec958, rme96->wcreg_spdif);
        return 0;
 }
 
-static int snd_rme96_control_spdif_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_rme96_control_spdif_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       rme96_t *rme96 = snd_kcontrol_chip(kcontrol);
+       struct rme96 *rme96 = snd_kcontrol_chip(kcontrol);
        int change;
        u32 val;
        
@@ -2135,24 +2115,24 @@ static int snd_rme96_control_spdif_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_v
        return change;
 }
 
-static int snd_rme96_control_spdif_stream_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_rme96_control_spdif_stream_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
        uinfo->count = 1;
        return 0;
 }
 
-static int snd_rme96_control_spdif_stream_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_rme96_control_spdif_stream_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       rme96_t *rme96 = snd_kcontrol_chip(kcontrol);
+       struct rme96 *rme96 = snd_kcontrol_chip(kcontrol);
        
        snd_rme96_convert_to_aes(&ucontrol->value.iec958, rme96->wcreg_spdif_stream);
        return 0;
 }
 
-static int snd_rme96_control_spdif_stream_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_rme96_control_spdif_stream_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       rme96_t *rme96 = snd_kcontrol_chip(kcontrol);
+       struct rme96 *rme96 = snd_kcontrol_chip(kcontrol);
        int change;
        u32 val;
        
@@ -2167,23 +2147,23 @@ static int snd_rme96_control_spdif_stream_put(snd_kcontrol_t * kcontrol, snd_ctl
        return change;
 }
 
-static int snd_rme96_control_spdif_mask_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_rme96_control_spdif_mask_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
        uinfo->count = 1;
        return 0;
 }
 
-static int snd_rme96_control_spdif_mask_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_rme96_control_spdif_mask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
        ucontrol->value.iec958.status[0] = kcontrol->private_value;
        return 0;
 }
 
 static int
-snd_rme96_dac_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+snd_rme96_dac_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
-       rme96_t *rme96 = snd_kcontrol_chip(kcontrol);
+       struct rme96 *rme96 = snd_kcontrol_chip(kcontrol);
        
         uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
         uinfo->count = 2;
@@ -2193,9 +2173,9 @@ snd_rme96_dac_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
 }
 
 static int
-snd_rme96_dac_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u)
+snd_rme96_dac_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *u)
 {
-       rme96_t *rme96 = snd_kcontrol_chip(kcontrol);
+       struct rme96 *rme96 = snd_kcontrol_chip(kcontrol);
 
        spin_lock_irq(&rme96->lock);
         u->value.integer.value[0] = rme96->vol[0];
@@ -2206,32 +2186,35 @@ snd_rme96_dac_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u)
 }
 
 static int
-snd_rme96_dac_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u)
+snd_rme96_dac_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *u)
 {
-       rme96_t *rme96 = snd_kcontrol_chip(kcontrol);
+       struct rme96 *rme96 = snd_kcontrol_chip(kcontrol);
         int change = 0;
+       unsigned int vol, maxvol;
 
-       if (!RME96_HAS_ANALOG_OUT(rme96)) {
+
+       if (!RME96_HAS_ANALOG_OUT(rme96))
                return -EINVAL;
-       }
+       maxvol = RME96_185X_MAX_OUT(rme96);
        spin_lock_irq(&rme96->lock);
-        if (u->value.integer.value[0] != rme96->vol[0]) {
-               rme96->vol[0] = u->value.integer.value[0];
-                change = 1;
-        }
-        if (u->value.integer.value[1] != rme96->vol[1]) {
-               rme96->vol[1] = u->value.integer.value[1];
-                change = 1;
-        }
-       if (change) {
-               snd_rme96_apply_dac_volume(rme96);
+       vol = u->value.integer.value[0];
+       if (vol != rme96->vol[0] && vol <= maxvol) {
+               rme96->vol[0] = vol;
+               change = 1;
        }
+       vol = u->value.integer.value[1];
+       if (vol != rme96->vol[1] && vol <= maxvol) {
+               rme96->vol[1] = vol;
+               change = 1;
+       }
+       if (change)
+               snd_rme96_apply_dac_volume(rme96);
        spin_unlock_irq(&rme96->lock);
 
         return change;
 }
 
-static snd_kcontrol_new_t snd_rme96_controls[] = {
+static struct snd_kcontrol_new snd_rme96_controls[] = {
 {
        .iface =        SNDRV_CTL_ELEM_IFACE_PCM,
        .name =         SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),
@@ -2312,11 +2295,11 @@ static snd_kcontrol_new_t snd_rme96_controls[] = {
 };
 
 static int
-snd_rme96_create_switches(snd_card_t *card,
-                         rme96_t *rme96)
+snd_rme96_create_switches(struct snd_card *card,
+                         struct rme96 *rme96)
 {
        int idx, err;
-       snd_kcontrol_t *kctl;
+       struct snd_kcontrol *kctl;
 
        for (idx = 0; idx < 7; idx++) {
                if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_rme96_controls[idx], rme96))) < 0)
@@ -2338,7 +2321,7 @@ snd_rme96_create_switches(snd_card_t *card,
  * Card initialisation
  */
 
-static void snd_rme96_card_free(snd_card_t *card)
+static void snd_rme96_card_free(struct snd_card *card)
 {
        snd_rme96_free(card->private_data);
 }
@@ -2348,8 +2331,8 @@ snd_rme96_probe(struct pci_dev *pci,
                const struct pci_device_id *pci_id)
 {
        static int dev;
-       rme96_t *rme96;
-       snd_card_t *card;
+       struct rme96 *rme96;
+       struct snd_card *card;
        int err;
        u8 val;
 
@@ -2360,11 +2343,12 @@ snd_rme96_probe(struct pci_dev *pci,
                dev++;
                return -ENOENT;
        }
-       if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE,
-                                sizeof(rme96_t))) == NULL)
-               return -ENOMEM;
+       err = snd_card_create(index[dev], id[dev], THIS_MODULE,
+                             sizeof(struct rme96), &card);
+       if (err < 0)
+               return err;
        card->private_free = snd_rme96_card_free;
-       rme96 = (rme96_t *)card->private_data;  
+       rme96 = card->private_data;
        rme96->card = card;
        rme96->pci = pci;
        snd_card_set_dev(card, &pci->dev);
@@ -2412,8 +2396,7 @@ static void __devexit snd_rme96_remove(struct pci_dev *pci)
 }
 
 static struct pci_driver driver = {
-       .name = "RME Digi96",
-       .owner = THIS_MODULE,
+       .name = KBUILD_MODNAME,
        .id_table = snd_rme96_ids,
        .probe = snd_rme96_probe,
        .remove = __devexit_p(snd_rme96_remove),