Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / sound / pci / rme9652 / hdsp.c
index 12efbf0..61f82f0 100644 (file)
@@ -370,13 +370,6 @@ MODULE_SUPPORTED_DEVICE("{{RME Hammerfall-DSP},"
 #define UNITY_GAIN                       32768
 #define MINUS_INFINITY_GAIN              0
 
-#ifndef PCI_VENDOR_ID_XILINX
-#define PCI_VENDOR_ID_XILINX           0x10ee
-#endif
-#ifndef PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP
-#define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP 0x3fc5
-#endif
-
 /* the size of a substream (1 mono data stream) */
 
 #define HDSP_CHANNEL_BUFFER_SAMPLES  (16*1024)
@@ -401,11 +394,7 @@ MODULE_SUPPORTED_DEVICE("{{RME Hammerfall-DSP},"
 #endif
 #endif
 
-typedef struct _hdsp             hdsp_t;
-typedef struct _hdsp_midi        hdsp_midi_t;
-typedef struct _hdsp_9632_meters hdsp_9632_meters_t;
-
-struct _hdsp_9632_meters {
+struct hdsp_9632_meters {
     u32 input_peak[16];
     u32 playback_peak[16];
     u32 output_peak[16];
@@ -421,23 +410,23 @@ struct _hdsp_9632_meters {
     u32 xxx_rms_high[16];
 };
 
-struct _hdsp_midi {
-    hdsp_t                  *hdsp;
+struct hdsp_midi {
+    struct hdsp             *hdsp;
     int                      id;
-    snd_rawmidi_t           *rmidi;
-    snd_rawmidi_substream_t *input;
-    snd_rawmidi_substream_t *output;
+    struct snd_rawmidi           *rmidi;
+    struct snd_rawmidi_substream *input;
+    struct snd_rawmidi_substream *output;
     char                     istimer; /* timer in use */
     struct timer_list       timer;
     spinlock_t               lock;
     int                             pending;
 };
 
-struct _hdsp {
+struct hdsp {
        spinlock_t            lock;
-       snd_pcm_substream_t  *capture_substream;
-       snd_pcm_substream_t  *playback_substream;
-        hdsp_midi_t           midi[2];
+       struct snd_pcm_substream *capture_substream;
+       struct snd_pcm_substream *playback_substream;
+        struct hdsp_midi      midi[2];
        struct tasklet_struct midi_tasklet;
        int                   use_midi_tasklet;
        int                   precise_ptr;
@@ -445,8 +434,9 @@ struct _hdsp {
        u32                   control2_register;     /* cached value */
        u32                   creg_spdif;
        u32                   creg_spdif_stream;
+       int                   clock_source_locked;
        char                 *card_name;             /* digiface/multiface */
-       HDSP_IO_Type          io_type;               /* ditto, but for code use */
+       enum HDSP_IO_Type     io_type;               /* ditto, but for code use */
         unsigned short        firmware_rev;
        unsigned short        state;                 /* stores state bits */
        u32                   firmware_cache[24413]; /* this helps recover from accidental iobox power failure */
@@ -473,11 +463,11 @@ struct _hdsp {
        int                   irq;
        unsigned long         port;
         void __iomem         *iobase;
-       snd_card_t           *card;
-       snd_pcm_t            *pcm;
-       snd_hwdep_t          *hwdep;
+       struct snd_card *card;
+       struct snd_pcm *pcm;
+       struct snd_hwdep          *hwdep;
        struct pci_dev       *pci;
-       snd_kcontrol_t       *spdif_ctl;
+       struct snd_kcontrol *spdif_ctl;
         unsigned short        mixer_matrix[HDSP_MATRIX_MIXER_SIZE];
 };
 
@@ -559,22 +549,26 @@ static int snd_hammerfall_get_buffer(struct pci_dev *pci, struct snd_dma_buffer
 {
        dmab->dev.type = SNDRV_DMA_TYPE_DEV;
        dmab->dev.dev = snd_dma_pci_data(pci);
-       if (! snd_dma_get_reserved_buf(dmab, snd_dma_pci_buf_id(pci))) {
-               if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
-                                       size, dmab) < 0)
-                       return -ENOMEM;
+       if (snd_dma_get_reserved_buf(dmab, snd_dma_pci_buf_id(pci))) {
+               if (dmab->bytes >= size)
+                       return 0;
        }
+       if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
+                               size, dmab) < 0)
+               return -ENOMEM;
        return 0;
 }
 
 static void snd_hammerfall_free_buffer(struct snd_dma_buffer *dmab, struct pci_dev *pci)
 {
-       if (dmab->area)
+       if (dmab->area) {
+               dmab->dev.dev = NULL; /* make it anonymous */
                snd_dma_reserve_buf(dmab, snd_dma_pci_buf_id(pci));
+       }
 }
 
 
-static struct pci_device_id snd_hdsp_ids[] = {
+static struct pci_device_id snd_hdsp_ids[] __devinitdata = {
        {
                .vendor = PCI_VENDOR_ID_XILINX,
                .device = PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP, 
@@ -587,17 +581,17 @@ static struct pci_device_id snd_hdsp_ids[] = {
 MODULE_DEVICE_TABLE(pci, snd_hdsp_ids);
 
 /* prototypes */
-static int snd_hdsp_create_alsa_devices(snd_card_t *card, hdsp_t *hdsp);
-static int snd_hdsp_create_pcm(snd_card_t *card, hdsp_t *hdsp);
-static int snd_hdsp_enable_io (hdsp_t *hdsp);
-static void snd_hdsp_initialize_midi_flush (hdsp_t *hdsp);
-static void snd_hdsp_initialize_channels (hdsp_t *hdsp);
-static int hdsp_fifo_wait(hdsp_t *hdsp, int count, int timeout);
-static int hdsp_autosync_ref(hdsp_t *hdsp);
-static int snd_hdsp_set_defaults(hdsp_t *hdsp);
-static void snd_hdsp_9652_enable_mixer (hdsp_t *hdsp);
-
-static int hdsp_playback_to_output_key (hdsp_t *hdsp, int in, int out)
+static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdsp);
+static int snd_hdsp_create_pcm(struct snd_card *card, struct hdsp *hdsp);
+static int snd_hdsp_enable_io (struct hdsp *hdsp);
+static void snd_hdsp_initialize_midi_flush (struct hdsp *hdsp);
+static void snd_hdsp_initialize_channels (struct hdsp *hdsp);
+static int hdsp_fifo_wait(struct hdsp *hdsp, int count, int timeout);
+static int hdsp_autosync_ref(struct hdsp *hdsp);
+static int snd_hdsp_set_defaults(struct hdsp *hdsp);
+static void snd_hdsp_9652_enable_mixer (struct hdsp *hdsp);
+
+static int hdsp_playback_to_output_key (struct hdsp *hdsp, int in, int out)
 {
        switch (hdsp->firmware_rev) {
        case 0xa:
@@ -610,7 +604,7 @@ static int hdsp_playback_to_output_key (hdsp_t *hdsp, int in, int out)
        }
 }
 
-static int hdsp_input_to_output_key (hdsp_t *hdsp, int in, int out)
+static int hdsp_input_to_output_key (struct hdsp *hdsp, int in, int out)
 {
        switch (hdsp->firmware_rev) {
        case 0xa:
@@ -623,17 +617,17 @@ static int hdsp_input_to_output_key (hdsp_t *hdsp, int in, int out)
        }
 }
 
-static void hdsp_write(hdsp_t *hdsp, int reg, int val)
+static void hdsp_write(struct hdsp *hdsp, int reg, int val)
 {
        writel(val, hdsp->iobase + reg);
 }
 
-static unsigned int hdsp_read(hdsp_t *hdsp, int reg)
+static unsigned int hdsp_read(struct hdsp *hdsp, int reg)
 {
        return readl (hdsp->iobase + reg);
 }
 
-static int hdsp_check_for_iobox (hdsp_t *hdsp)
+static int hdsp_check_for_iobox (struct hdsp *hdsp)
 {
 
        if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return 0;
@@ -646,7 +640,7 @@ static int hdsp_check_for_iobox (hdsp_t *hdsp)
 
 }
 
-static int snd_hdsp_load_firmware_from_cache(hdsp_t *hdsp) {
+static int snd_hdsp_load_firmware_from_cache(struct hdsp *hdsp) {
 
        int i;
        unsigned long flags;
@@ -673,12 +667,7 @@ static int snd_hdsp_load_firmware_from_cache(hdsp_t *hdsp) {
                        }
                }
 
-               if ((1000 / HZ) < 3000) {
-                       set_current_state(TASK_UNINTERRUPTIBLE);
-                       schedule_timeout((3000 * HZ + 999) / 1000);
-               } else {
-                       mdelay(3000);
-               }
+               ssleep(3);
                
                if (hdsp_fifo_wait (hdsp, 0, HDSP_LONG_WAIT)) {
                        snd_printk ("Hammerfall-DSP: timeout at end of firmware loading\n");
@@ -695,7 +684,7 @@ static int snd_hdsp_load_firmware_from_cache(hdsp_t *hdsp) {
                
        }
        if (hdsp->state & HDSP_InitializationComplete) {
-               snd_printk("Hammerfall-DSP: firmware loaded from cache, restoring defaults\n");
+               snd_printk(KERN_INFO "Hammerfall-DSP: firmware loaded from cache, restoring defaults\n");
                spin_lock_irqsave(&hdsp->lock, flags);
                snd_hdsp_set_defaults(hdsp);
                spin_unlock_irqrestore(&hdsp->lock, flags); 
@@ -706,15 +695,14 @@ static int snd_hdsp_load_firmware_from_cache(hdsp_t *hdsp) {
        return 0;
 }
 
-static int hdsp_get_iobox_version (hdsp_t *hdsp)
+static int hdsp_get_iobox_version (struct hdsp *hdsp)
 {
        if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) {
        
                hdsp_write (hdsp, HDSP_control2Reg, HDSP_PROGRAM);
                hdsp_write (hdsp, HDSP_fifoData, 0);
-               if (hdsp_fifo_wait (hdsp, 0, HDSP_SHORT_WAIT) < 0) {
+               if (hdsp_fifo_wait (hdsp, 0, HDSP_SHORT_WAIT) < 0)
                        return -EIO;
-               }
 
                hdsp_write (hdsp, HDSP_control2Reg, HDSP_S_LOAD);
                hdsp_write (hdsp, HDSP_fifoData, 0);
@@ -729,29 +717,37 @@ static int hdsp_get_iobox_version (hdsp_t *hdsp)
                } 
        } else {
                /* firmware was already loaded, get iobox type */
-               if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1) {
+               if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1)
                        hdsp->io_type = Multiface;
-               } else {
+               else
                        hdsp->io_type = Digiface;
-               }
        }
        return 0;
 }
 
 
-static int hdsp_check_for_firmware (hdsp_t *hdsp)
+static int hdsp_check_for_firmware (struct hdsp *hdsp, int show_err)
 {
        if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return 0;
        if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) {
-               snd_printk("Hammerfall-DSP: firmware not present.\n");
+               snd_printk(KERN_ERR "Hammerfall-DSP: firmware not present.\n");
                hdsp->state &= ~HDSP_FirmwareLoaded;
+               if (! show_err)
+                       return -EIO;
+               /* try to load firmware */
+               if (hdsp->state & HDSP_FirmwareCached) {
+                       if (snd_hdsp_load_firmware_from_cache(hdsp) != 0)
+                               snd_printk(KERN_ERR "Hammerfall-DSP: Firmware loading from cache failed, please upload manually.\n");
+               } else {
+                       snd_printk(KERN_ERR "Hammerfall-DSP: No firmware loaded nor cached, please upload firmware.\n");
+               }
                return -EIO;
        }
        return 0;
 }
 
 
-static int hdsp_fifo_wait(hdsp_t *hdsp, int count, int timeout)
+static int hdsp_fifo_wait(struct hdsp *hdsp, int count, int timeout)
 {    
        int i;
 
@@ -776,15 +772,15 @@ static int hdsp_fifo_wait(hdsp_t *hdsp, int count, int timeout)
        return -1;
 }
 
-static int hdsp_read_gain (hdsp_t *hdsp, unsigned int addr)
+static int hdsp_read_gain (struct hdsp *hdsp, unsigned int addr)
 {
-       if (addr >= HDSP_MATRIX_MIXER_SIZE) {
+       if (addr >= HDSP_MATRIX_MIXER_SIZE)
                return 0;
-       }
+
        return hdsp->mixer_matrix[addr];
 }
 
-static int hdsp_write_gain(hdsp_t *hdsp, unsigned int addr, unsigned short data)
+static int hdsp_write_gain(struct hdsp *hdsp, unsigned int addr, unsigned short data)
 {
        unsigned int ad;
 
@@ -805,13 +801,11 @@ static int hdsp_write_gain(hdsp_t *hdsp, unsigned int addr, unsigned short data)
                   memory."
                */
 
-               if (hdsp->io_type == H9632 && addr >= 512) {
+               if (hdsp->io_type == H9632 && addr >= 512)
                        return 0;
-               }
 
-               if (hdsp->io_type == H9652 && addr >= 1352) {
+               if (hdsp->io_type == H9652 && addr >= 1352)
                        return 0;
-               }
 
                hdsp->mixer_matrix[addr] = data;
 
@@ -835,9 +829,8 @@ static int hdsp_write_gain(hdsp_t *hdsp, unsigned int addr, unsigned short data)
 
                ad = (addr << 16) + data;
                
-               if (hdsp_fifo_wait(hdsp, 127, HDSP_LONG_WAIT)) {
+               if (hdsp_fifo_wait(hdsp, 127, HDSP_LONG_WAIT))
                        return -1;
-               }
 
                hdsp_write (hdsp, HDSP_fifoData, ad);
                hdsp->mixer_matrix[addr] = data;
@@ -847,21 +840,20 @@ static int hdsp_write_gain(hdsp_t *hdsp, unsigned int addr, unsigned short data)
        return 0;
 }
 
-static int snd_hdsp_use_is_exclusive(hdsp_t *hdsp)
+static int snd_hdsp_use_is_exclusive(struct hdsp *hdsp)
 {
        unsigned long flags;
        int ret = 1;
 
        spin_lock_irqsave(&hdsp->lock, flags);
        if ((hdsp->playback_pid != hdsp->capture_pid) &&
-           (hdsp->playback_pid >= 0) && (hdsp->capture_pid >= 0)) {
+           (hdsp->playback_pid >= 0) && (hdsp->capture_pid >= 0))
                ret = 0;
-       }
        spin_unlock_irqrestore(&hdsp->lock, flags);
        return ret;
 }
 
-static int hdsp_external_sample_rate (hdsp_t *hdsp)
+static int hdsp_external_sample_rate (struct hdsp *hdsp)
 {
        unsigned int status2 = hdsp_read(hdsp, HDSP_status2Register);
        unsigned int rate_bits = status2 & HDSP_systemFrequencyMask;
@@ -878,14 +870,13 @@ static int hdsp_external_sample_rate (hdsp_t *hdsp)
        }
 }
 
-static int hdsp_spdif_sample_rate(hdsp_t *hdsp)
+static int hdsp_spdif_sample_rate(struct hdsp *hdsp)
 {
        unsigned int status = hdsp_read(hdsp, HDSP_statusRegister);
        unsigned int rate_bits = (status & HDSP_spdifFrequencyMask);
 
-       if (status & HDSP_SPDIFErrorFlag) {
+       if (status & HDSP_SPDIFErrorFlag)
                return 0;
-       }
        
        switch (rate_bits) {
        case HDSP_spdifFrequency32KHz: return 32000;
@@ -910,20 +901,19 @@ static int hdsp_spdif_sample_rate(hdsp_t *hdsp)
        return 0;
 }
 
-static void hdsp_compute_period_size(hdsp_t *hdsp)
+static void hdsp_compute_period_size(struct hdsp *hdsp)
 {
        hdsp->period_bytes = 1 << ((hdsp_decode_latency(hdsp->control_register) + 8));
 }
 
-static snd_pcm_uframes_t hdsp_hw_pointer(hdsp_t *hdsp)
+static snd_pcm_uframes_t hdsp_hw_pointer(struct hdsp *hdsp)
 {
        int position;
 
        position = hdsp_read(hdsp, HDSP_statusRegister);
 
-       if (!hdsp->precise_ptr) {
+       if (!hdsp->precise_ptr)
                return (position & HDSP_BufferID) ? (hdsp->period_bytes / 4) : 0;
-       }
 
        position &= HDSP_BufferPositionMask;
        position /= 4;
@@ -931,29 +921,29 @@ static snd_pcm_uframes_t hdsp_hw_pointer(hdsp_t *hdsp)
        return position;
 }
 
-static void hdsp_reset_hw_pointer(hdsp_t *hdsp)
+static void hdsp_reset_hw_pointer(struct hdsp *hdsp)
 {
        hdsp_write (hdsp, HDSP_resetPointer, 0);
 }
 
-static void hdsp_start_audio(hdsp_t *s)
+static void hdsp_start_audio(struct hdsp *s)
 {
        s->control_register |= (HDSP_AudioInterruptEnable | HDSP_Start);
        hdsp_write(s, HDSP_controlRegister, s->control_register);
 }
 
-static void hdsp_stop_audio(hdsp_t *s)
+static void hdsp_stop_audio(struct hdsp *s)
 {
        s->control_register &= ~(HDSP_Start | HDSP_AudioInterruptEnable);
        hdsp_write(s, HDSP_controlRegister, s->control_register);
 }
 
-static void hdsp_silence_playback(hdsp_t *hdsp)
+static void hdsp_silence_playback(struct hdsp *hdsp)
 {
        memset(hdsp->playback_buffer, 0, HDSP_DMA_AREA_BYTES);
 }
 
-static int hdsp_set_interrupt_interval(hdsp_t *s, unsigned int frames)
+static int hdsp_set_interrupt_interval(struct hdsp *s, unsigned int frames)
 {
        int n;
 
@@ -978,7 +968,7 @@ static int hdsp_set_interrupt_interval(hdsp_t *s, unsigned int frames)
        return 0;
 }
 
-static int hdsp_set_rate(hdsp_t *hdsp, int rate, int called_internally)
+static int hdsp_set_rate(struct hdsp *hdsp, int rate, int called_internally)
 {
        int reject_if_open = 0;
        int current_rate;
@@ -992,19 +982,19 @@ static int hdsp_set_rate(hdsp_t *hdsp, int rate, int called_internally)
        if (!(hdsp->control_register & HDSP_ClockModeMaster)) { 
                if (called_internally) {
                        /* request from ctl or card initialization */
-                       snd_printk("Hammerfall-DSP: device is not running as a clock master: cannot set sample rate.\n");
+                       snd_printk(KERN_ERR "Hammerfall-DSP: device is not running as a clock master: cannot set sample rate.\n");
                        return -1;
                } else {                
                        /* hw_param request while in AutoSync mode */
                        int external_freq = hdsp_external_sample_rate(hdsp);
                        int spdif_freq = hdsp_spdif_sample_rate(hdsp);
                
-                       if ((spdif_freq == external_freq*2) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1)) {
-                               snd_printk("Hammerfall-DSP: Detected ADAT in double speed mode\n");
-                       } else if (hdsp->io_type == H9632 && (spdif_freq == external_freq*4) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1)) {
-                               snd_printk("Hammerfall-DSP: Detected ADAT in quad speed mode\n");                       
-                       else if (rate != external_freq) {
-                               snd_printk("Hammerfall-DSP: No AutoSync source for requested rate\n");
+                       if ((spdif_freq == external_freq*2) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1))
+                               snd_printk(KERN_INFO "Hammerfall-DSP: Detected ADAT in double speed mode\n");
+                       else if (hdsp->io_type == H9632 && (spdif_freq == external_freq*4) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1))
+                               snd_printk(KERN_INFO "Hammerfall-DSP: Detected ADAT in quad speed mode\n");                     
+                       else if (rate != external_freq) {
+                               snd_printk(KERN_INFO "Hammerfall-DSP: No AutoSync source for requested rate\n");
                                return -1;
                        }               
                }       
@@ -1022,63 +1012,53 @@ static int hdsp_set_rate(hdsp_t *hdsp, int rate, int called_internally)
           exists for externally-driven rate changes. All we can do
           is to flag rate changes in the read/write routines.  */
 
-       if (rate > 96000 && hdsp->io_type != H9632) {
+       if (rate > 96000 && hdsp->io_type != H9632)
                return -EINVAL;
-       }
        
        switch (rate) {
        case 32000:
-               if (current_rate > 48000) {
+               if (current_rate > 48000)
                        reject_if_open = 1;
-               }
                rate_bits = HDSP_Frequency32KHz;
                break;
        case 44100:
-               if (current_rate > 48000) {
+               if (current_rate > 48000)
                        reject_if_open = 1;
-               }
                rate_bits = HDSP_Frequency44_1KHz;
                break;
        case 48000:
-               if (current_rate > 48000) {
+               if (current_rate > 48000)
                        reject_if_open = 1;
-               }
                rate_bits = HDSP_Frequency48KHz;
                break;
        case 64000:
-               if (current_rate <= 48000 || current_rate > 96000) {
+               if (current_rate <= 48000 || current_rate > 96000)
                        reject_if_open = 1;
-               }
                rate_bits = HDSP_Frequency64KHz;
                break;
        case 88200:
-               if (current_rate <= 48000 || current_rate > 96000) {
+               if (current_rate <= 48000 || current_rate > 96000)
                        reject_if_open = 1;
-               }
                rate_bits = HDSP_Frequency88_2KHz;
                break;
        case 96000:
-               if (current_rate <= 48000 || current_rate > 96000) {
+               if (current_rate <= 48000 || current_rate > 96000)
                        reject_if_open = 1;
-               }
                rate_bits = HDSP_Frequency96KHz;
                break;
        case 128000:
-               if (current_rate < 128000) {
+               if (current_rate < 128000)
                        reject_if_open = 1;
-               }
                rate_bits = HDSP_Frequency128KHz;
                break;
        case 176400:
-               if (current_rate < 128000) {
+               if (current_rate < 128000)
                        reject_if_open = 1;
-               }
                rate_bits = HDSP_Frequency176_4KHz;
                break;
        case 192000:
-               if (current_rate < 128000) {
+               if (current_rate < 128000)
                        reject_if_open = 1;
-               }
                rate_bits = HDSP_Frequency192KHz;
                break;
        default:
@@ -1099,11 +1079,10 @@ static int hdsp_set_rate(hdsp_t *hdsp, int rate, int called_internally)
        if (rate >= 128000) {
                hdsp->channel_map = channel_map_H9632_qs;
        } else if (rate > 48000) {
-               if (hdsp->io_type == H9632) {
+               if (hdsp->io_type == H9632)
                        hdsp->channel_map = channel_map_H9632_ds;
-               } else {
+               else
                        hdsp->channel_map = channel_map_ds;
-               }
        } else {
                switch (hdsp->io_type) {
                case Multiface:
@@ -1131,60 +1110,54 @@ static int hdsp_set_rate(hdsp_t *hdsp, int rate, int called_internally)
    MIDI
   ----------------------------------------------------------------------------*/
 
-static unsigned char snd_hdsp_midi_read_byte (hdsp_t *hdsp, int id)
+static unsigned char snd_hdsp_midi_read_byte (struct hdsp *hdsp, int id)
 {
        /* the hardware already does the relevant bit-mask with 0xff */
-       if (id) {
+       if (id)
                return hdsp_read(hdsp, HDSP_midiDataIn1);
-       } else {
+       else
                return hdsp_read(hdsp, HDSP_midiDataIn0);
-       }
 }
 
-static void snd_hdsp_midi_write_byte (hdsp_t *hdsp, int id, int val)
+static void snd_hdsp_midi_write_byte (struct hdsp *hdsp, int id, int val)
 {
        /* the hardware already does the relevant bit-mask with 0xff */
-       if (id) {
+       if (id)
                hdsp_write(hdsp, HDSP_midiDataOut1, val);
-       } else {
+       else
                hdsp_write(hdsp, HDSP_midiDataOut0, val);
-       }
 }
 
-static int snd_hdsp_midi_input_available (hdsp_t *hdsp, int id)
+static int snd_hdsp_midi_input_available (struct hdsp *hdsp, int id)
 {
-       if (id) {
+       if (id)
                return (hdsp_read(hdsp, HDSP_midiStatusIn1) & 0xff);
-       } else {
+       else
                return (hdsp_read(hdsp, HDSP_midiStatusIn0) & 0xff);
-       }
 }
 
-static int snd_hdsp_midi_output_possible (hdsp_t *hdsp, int id)
+static int snd_hdsp_midi_output_possible (struct hdsp *hdsp, int id)
 {
        int fifo_bytes_used;
 
-       if (id) {
+       if (id)
                fifo_bytes_used = hdsp_read(hdsp, HDSP_midiStatusOut1) & 0xff;
-       } else {
+       else
                fifo_bytes_used = hdsp_read(hdsp, HDSP_midiStatusOut0) & 0xff;
-       }
 
-       if (fifo_bytes_used < 128) {
+       if (fifo_bytes_used < 128)
                return  128 - fifo_bytes_used;
-       } else {
+       else
                return 0;
-       }
 }
 
-static void snd_hdsp_flush_midi_input (hdsp_t *hdsp, int id)
+static void snd_hdsp_flush_midi_input (struct hdsp *hdsp, int id)
 {
-       while (snd_hdsp_midi_input_available (hdsp, id)) {
+       while (snd_hdsp_midi_input_available (hdsp, id))
                snd_hdsp_midi_read_byte (hdsp, id);
-       }
 }
 
-static int snd_hdsp_midi_output_write (hdsp_midi_t *hmidi)
+static int snd_hdsp_midi_output_write (struct hdsp_midi *hmidi)
 {
        unsigned long flags;
        int n_pending;
@@ -1212,7 +1185,7 @@ static int snd_hdsp_midi_output_write (hdsp_midi_t *hmidi)
        return 0;
 }
 
-static int snd_hdsp_midi_input_read (hdsp_midi_t *hmidi)
+static int snd_hdsp_midi_input_read (struct hdsp_midi *hmidi)
 {
        unsigned char buf[128]; /* this buffer is designed to match the MIDI input FIFO size */
        unsigned long flags;
@@ -1222,41 +1195,36 @@ static int snd_hdsp_midi_input_read (hdsp_midi_t *hmidi)
        spin_lock_irqsave (&hmidi->lock, flags);
        if ((n_pending = snd_hdsp_midi_input_available (hmidi->hdsp, hmidi->id)) > 0) {
                if (hmidi->input) {
-                       if (n_pending > (int)sizeof (buf)) {
+                       if (n_pending > (int)sizeof (buf))
                                n_pending = sizeof (buf);
-                       }
-                       for (i = 0; i < n_pending; ++i) {
+                       for (i = 0; i < n_pending; ++i)
                                buf[i] = snd_hdsp_midi_read_byte (hmidi->hdsp, hmidi->id);
-                       }
-                       if (n_pending) {
+                       if (n_pending)
                                snd_rawmidi_receive (hmidi->input, buf, n_pending);
-                       }
                } else {
                        /* flush the MIDI input FIFO */
-                       while (--n_pending) {
+                       while (--n_pending)
                                snd_hdsp_midi_read_byte (hmidi->hdsp, hmidi->id);
-                       }
                }
        }
        hmidi->pending = 0;
-       if (hmidi->id) {
+       if (hmidi->id)
                hmidi->hdsp->control_register |= HDSP_Midi1InterruptEnable;
-       } else {
+       else
                hmidi->hdsp->control_register |= HDSP_Midi0InterruptEnable;
-       }
        hdsp_write(hmidi->hdsp, HDSP_controlRegister, hmidi->hdsp->control_register);
        spin_unlock_irqrestore (&hmidi->lock, flags);
        return snd_hdsp_midi_output_write (hmidi);
 }
 
-static void snd_hdsp_midi_input_trigger(snd_rawmidi_substream_t * substream, int up)
+static void snd_hdsp_midi_input_trigger(struct snd_rawmidi_substream *substream, int up)
 {
-       hdsp_t *hdsp;
-       hdsp_midi_t *hmidi;
+       struct hdsp *hdsp;
+       struct hdsp_midi *hmidi;
        unsigned long flags;
        u32 ie;
 
-       hmidi = (hdsp_midi_t *) substream->rmidi->private_data;
+       hmidi = (struct hdsp_midi *) substream->rmidi->private_data;
        hdsp = hmidi->hdsp;
        ie = hmidi->id ? HDSP_Midi1InterruptEnable : HDSP_Midi0InterruptEnable;
        spin_lock_irqsave (&hdsp->lock, flags);
@@ -1276,7 +1244,7 @@ static void snd_hdsp_midi_input_trigger(snd_rawmidi_substream_t * substream, int
 
 static void snd_hdsp_midi_output_timer(unsigned long data)
 {
-       hdsp_midi_t *hmidi = (hdsp_midi_t *) data;
+       struct hdsp_midi *hmidi = (struct hdsp_midi *) data;
        unsigned long flags;
        
        snd_hdsp_midi_output_write(hmidi);
@@ -1296,12 +1264,12 @@ static void snd_hdsp_midi_output_timer(unsigned long data)
        spin_unlock_irqrestore (&hmidi->lock, flags);
 }
 
-static void snd_hdsp_midi_output_trigger(snd_rawmidi_substream_t * substream, int up)
+static void snd_hdsp_midi_output_trigger(struct snd_rawmidi_substream *substream, int up)
 {
-       hdsp_midi_t *hmidi;
+       struct hdsp_midi *hmidi;
        unsigned long flags;
 
-       hmidi = (hdsp_midi_t *) substream->rmidi->private_data;
+       hmidi = (struct hdsp_midi *) substream->rmidi->private_data;
        spin_lock_irqsave (&hmidi->lock, flags);
        if (up) {
                if (!hmidi->istimer) {
@@ -1313,20 +1281,19 @@ static void snd_hdsp_midi_output_trigger(snd_rawmidi_substream_t * substream, in
                        hmidi->istimer++;
                }
        } else {
-               if (hmidi->istimer && --hmidi->istimer <= 0) {
+               if (hmidi->istimer && --hmidi->istimer <= 0)
                        del_timer (&hmidi->timer);
-               }
        }
        spin_unlock_irqrestore (&hmidi->lock, flags);
        if (up)
                snd_hdsp_midi_output_write(hmidi);
 }
 
-static int snd_hdsp_midi_input_open(snd_rawmidi_substream_t * substream)
+static int snd_hdsp_midi_input_open(struct snd_rawmidi_substream *substream)
 {
-       hdsp_midi_t *hmidi;
+       struct hdsp_midi *hmidi;
 
-       hmidi = (hdsp_midi_t *) substream->rmidi->private_data;
+       hmidi = (struct hdsp_midi *) substream->rmidi->private_data;
        spin_lock_irq (&hmidi->lock);
        snd_hdsp_flush_midi_input (hmidi->hdsp, hmidi->id);
        hmidi->input = substream;
@@ -1335,11 +1302,11 @@ static int snd_hdsp_midi_input_open(snd_rawmidi_substream_t * substream)
        return 0;
 }
 
-static int snd_hdsp_midi_output_open(snd_rawmidi_substream_t * substream)
+static int snd_hdsp_midi_output_open(struct snd_rawmidi_substream *substream)
 {
-       hdsp_midi_t *hmidi;
+       struct hdsp_midi *hmidi;
 
-       hmidi = (hdsp_midi_t *) substream->rmidi->private_data;
+       hmidi = (struct hdsp_midi *) substream->rmidi->private_data;
        spin_lock_irq (&hmidi->lock);
        hmidi->output = substream;
        spin_unlock_irq (&hmidi->lock);
@@ -1347,13 +1314,13 @@ static int snd_hdsp_midi_output_open(snd_rawmidi_substream_t * substream)
        return 0;
 }
 
-static int snd_hdsp_midi_input_close(snd_rawmidi_substream_t * substream)
+static int snd_hdsp_midi_input_close(struct snd_rawmidi_substream *substream)
 {
-       hdsp_midi_t *hmidi;
+       struct hdsp_midi *hmidi;
 
        snd_hdsp_midi_input_trigger (substream, 0);
 
-       hmidi = (hdsp_midi_t *) substream->rmidi->private_data;
+       hmidi = (struct hdsp_midi *) substream->rmidi->private_data;
        spin_lock_irq (&hmidi->lock);
        hmidi->input = NULL;
        spin_unlock_irq (&hmidi->lock);
@@ -1361,13 +1328,13 @@ static int snd_hdsp_midi_input_close(snd_rawmidi_substream_t * substream)
        return 0;
 }
 
-static int snd_hdsp_midi_output_close(snd_rawmidi_substream_t * substream)
+static int snd_hdsp_midi_output_close(struct snd_rawmidi_substream *substream)
 {
-       hdsp_midi_t *hmidi;
+       struct hdsp_midi *hmidi;
 
        snd_hdsp_midi_output_trigger (substream, 0);
 
-       hmidi = (hdsp_midi_t *) substream->rmidi->private_data;
+       hmidi = (struct hdsp_midi *) substream->rmidi->private_data;
        spin_lock_irq (&hmidi->lock);
        hmidi->output = NULL;
        spin_unlock_irq (&hmidi->lock);
@@ -1375,21 +1342,21 @@ static int snd_hdsp_midi_output_close(snd_rawmidi_substream_t * substream)
        return 0;
 }
 
-static snd_rawmidi_ops_t snd_hdsp_midi_output =
+static struct snd_rawmidi_ops snd_hdsp_midi_output =
 {
        .open =         snd_hdsp_midi_output_open,
        .close =        snd_hdsp_midi_output_close,
        .trigger =      snd_hdsp_midi_output_trigger,
 };
 
-static snd_rawmidi_ops_t snd_hdsp_midi_input =
+static struct snd_rawmidi_ops snd_hdsp_midi_input =
 {
        .open =         snd_hdsp_midi_input_open,
        .close =        snd_hdsp_midi_input_close,
        .trigger =      snd_hdsp_midi_input_trigger,
 };
 
-static int __devinit snd_hdsp_create_midi (snd_card_t *card, hdsp_t *hdsp, int id)
+static int __devinit snd_hdsp_create_midi (struct snd_card *card, struct hdsp *hdsp, int id)
 {
        char buf[32];
 
@@ -1403,9 +1370,8 @@ static int __devinit snd_hdsp_create_midi (snd_card_t *card, hdsp_t *hdsp, int i
        spin_lock_init (&hdsp->midi[id].lock);
 
        sprintf (buf, "%s MIDI %d", card->shortname, id+1);
-       if (snd_rawmidi_new (card, buf, id, 1, 1, &hdsp->midi[id].rmidi) < 0) {
+       if (snd_rawmidi_new (card, buf, id, 1, 1, &hdsp->midi[id].rmidi) < 0)
                return -1;
-       }
 
        sprintf (hdsp->midi[id].rmidi->name, "%s MIDI %d", card->id, id+1);
        hdsp->midi[id].rmidi->private_data = &hdsp->midi[id];
@@ -1424,7 +1390,7 @@ static int __devinit snd_hdsp_create_midi (snd_card_t *card, hdsp_t *hdsp, int i
   Control Interface
   ----------------------------------------------------------------------------*/
 
-static u32 snd_hdsp_convert_from_aes(snd_aes_iec958_t *aes)
+static u32 snd_hdsp_convert_from_aes(struct snd_aes_iec958 *aes)
 {
        u32 val = 0;
        val |= (aes->status[0] & IEC958_AES0_PROFESSIONAL) ? HDSP_SPDIFProfessional : 0;
@@ -1436,7 +1402,7 @@ static u32 snd_hdsp_convert_from_aes(snd_aes_iec958_t *aes)
        return val;
 }
 
-static void snd_hdsp_convert_to_aes(snd_aes_iec958_t *aes, u32 val)
+static void snd_hdsp_convert_to_aes(struct snd_aes_iec958 *aes, u32 val)
 {
        aes->status[0] = ((val & HDSP_SPDIFProfessional) ? IEC958_AES0_PROFESSIONAL : 0) |
                         ((val & HDSP_SPDIFNonAudio) ? IEC958_AES0_NONAUDIO : 0);
@@ -1446,24 +1412,24 @@ static void snd_hdsp_convert_to_aes(snd_aes_iec958_t *aes, u32 val)
                aes->status[0] |= (val & HDSP_SPDIFEmphasis) ? IEC958_AES0_CON_EMPHASIS_5015 : 0;
 }
 
-static int snd_hdsp_control_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_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_hdsp_control_spdif_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_control_spdif_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        
        snd_hdsp_convert_to_aes(&ucontrol->value.iec958, hdsp->creg_spdif);
        return 0;
 }
 
-static int snd_hdsp_control_spdif_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_control_spdif_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        int change;
        u32 val;
        
@@ -1475,24 +1441,24 @@ static int snd_hdsp_control_spdif_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_va
        return change;
 }
 
-static int snd_hdsp_control_spdif_stream_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_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_hdsp_control_spdif_stream_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_control_spdif_stream_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        
        snd_hdsp_convert_to_aes(&ucontrol->value.iec958, hdsp->creg_spdif_stream);
        return 0;
 }
 
-static int snd_hdsp_control_spdif_stream_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_control_spdif_stream_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        int change;
        u32 val;
        
@@ -1506,33 +1472,33 @@ static int snd_hdsp_control_spdif_stream_put(snd_kcontrol_t * kcontrol, snd_ctl_
        return change;
 }
 
-static int snd_hdsp_control_spdif_mask_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_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_hdsp_control_spdif_mask_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_control_spdif_mask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
        ucontrol->value.iec958.status[0] = kcontrol->private_value;
        return 0;
 }
 
 #define HDSP_SPDIF_IN(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_PCM,  \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
   .name = xname, \
   .index = xindex, \
   .info = snd_hdsp_info_spdif_in, \
   .get = snd_hdsp_get_spdif_in, \
   .put = snd_hdsp_put_spdif_in }
 
-static unsigned int hdsp_spdif_in(hdsp_t *hdsp)
+static unsigned int hdsp_spdif_in(struct hdsp *hdsp)
 {
        return hdsp_decode_spdif_in(hdsp->control_register & HDSP_SPDIFInputMask);
 }
 
-static int hdsp_set_spdif_input(hdsp_t *hdsp, int in)
+static int hdsp_set_spdif_input(struct hdsp *hdsp, int in)
 {
        hdsp->control_register &= ~HDSP_SPDIFInputMask;
        hdsp->control_register |= hdsp_encode_spdif_in(in);
@@ -1540,10 +1506,10 @@ static int hdsp_set_spdif_input(hdsp_t *hdsp, int in)
        return 0;
 }
 
-static int snd_hdsp_info_spdif_in(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_spdif_in(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        static char *texts[4] = {"Optical", "Coaxial", "Internal", "AES"};
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
 
        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
        uinfo->count = 1;
@@ -1554,17 +1520,17 @@ static int snd_hdsp_info_spdif_in(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t
        return 0;
 }
 
-static int snd_hdsp_get_spdif_in(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_spdif_in(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        
        ucontrol->value.enumerated.item[0] = hdsp_spdif_in(hdsp);
        return 0;
 }
 
-static int snd_hdsp_put_spdif_in(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_spdif_in(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        int change;
        unsigned int val;
        
@@ -1580,27 +1546,26 @@ static int snd_hdsp_put_spdif_in(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
 }
 
 #define HDSP_SPDIF_OUT(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, .name = xname, .index = xindex, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
   .info = snd_hdsp_info_spdif_bits, \
   .get = snd_hdsp_get_spdif_out, .put = snd_hdsp_put_spdif_out }
 
-static int hdsp_spdif_out(hdsp_t *hdsp)
+static int hdsp_spdif_out(struct hdsp *hdsp)
 {
        return (hdsp->control_register & HDSP_SPDIFOpticalOut) ? 1 : 0;
 }
 
-static int hdsp_set_spdif_output(hdsp_t *hdsp, int out)
+static int hdsp_set_spdif_output(struct hdsp *hdsp, int out)
 {
-       if (out) {
+       if (out)
                hdsp->control_register |= HDSP_SPDIFOpticalOut;
-       } else {
+       else
                hdsp->control_register &= ~HDSP_SPDIFOpticalOut;
-       }
        hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
        return 0;
 }
 
-static int snd_hdsp_info_spdif_bits(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_spdif_bits(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
        uinfo->count = 1;
@@ -1609,17 +1574,17 @@ static int snd_hdsp_info_spdif_bits(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_
        return 0;
 }
 
-static int snd_hdsp_get_spdif_out(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_spdif_out(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        
        ucontrol->value.integer.value[0] = hdsp_spdif_out(hdsp);
        return 0;
 }
 
-static int snd_hdsp_put_spdif_out(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_spdif_out(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        int change;
        unsigned int val;
        
@@ -1634,37 +1599,36 @@ static int snd_hdsp_put_spdif_out(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
 }
 
 #define HDSP_SPDIF_PROFESSIONAL(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, .name = xname, .index = xindex, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
   .info = snd_hdsp_info_spdif_bits, \
   .get = snd_hdsp_get_spdif_professional, .put = snd_hdsp_put_spdif_professional }
 
-static int hdsp_spdif_professional(hdsp_t *hdsp)
+static int hdsp_spdif_professional(struct hdsp *hdsp)
 {
        return (hdsp->control_register & HDSP_SPDIFProfessional) ? 1 : 0;
 }
 
-static int hdsp_set_spdif_professional(hdsp_t *hdsp, int val)
+static int hdsp_set_spdif_professional(struct hdsp *hdsp, int val)
 {
-       if (val) {
+       if (val)
                hdsp->control_register |= HDSP_SPDIFProfessional;
-       } else {
+       else
                hdsp->control_register &= ~HDSP_SPDIFProfessional;
-       }
        hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
        return 0;
 }
 
-static int snd_hdsp_get_spdif_professional(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_spdif_professional(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        
        ucontrol->value.integer.value[0] = hdsp_spdif_professional(hdsp);
        return 0;
 }
 
-static int snd_hdsp_put_spdif_professional(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_spdif_professional(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        int change;
        unsigned int val;
        
@@ -1679,37 +1643,36 @@ static int snd_hdsp_put_spdif_professional(snd_kcontrol_t * kcontrol, snd_ctl_el
 }
 
 #define HDSP_SPDIF_EMPHASIS(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, .name = xname, .index = xindex, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
   .info = snd_hdsp_info_spdif_bits, \
   .get = snd_hdsp_get_spdif_emphasis, .put = snd_hdsp_put_spdif_emphasis }
 
-static int hdsp_spdif_emphasis(hdsp_t *hdsp)
+static int hdsp_spdif_emphasis(struct hdsp *hdsp)
 {
        return (hdsp->control_register & HDSP_SPDIFEmphasis) ? 1 : 0;
 }
 
-static int hdsp_set_spdif_emphasis(hdsp_t *hdsp, int val)
+static int hdsp_set_spdif_emphasis(struct hdsp *hdsp, int val)
 {
-       if (val) {
+       if (val)
                hdsp->control_register |= HDSP_SPDIFEmphasis;
-       } else {
+       else
                hdsp->control_register &= ~HDSP_SPDIFEmphasis;
-       }
        hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
        return 0;
 }
 
-static int snd_hdsp_get_spdif_emphasis(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_spdif_emphasis(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        
        ucontrol->value.integer.value[0] = hdsp_spdif_emphasis(hdsp);
        return 0;
 }
 
-static int snd_hdsp_put_spdif_emphasis(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_spdif_emphasis(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        int change;
        unsigned int val;
        
@@ -1724,37 +1687,36 @@ static int snd_hdsp_put_spdif_emphasis(snd_kcontrol_t * kcontrol, snd_ctl_elem_v
 }
 
 #define HDSP_SPDIF_NON_AUDIO(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, .name = xname, .index = xindex, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
   .info = snd_hdsp_info_spdif_bits, \
   .get = snd_hdsp_get_spdif_nonaudio, .put = snd_hdsp_put_spdif_nonaudio }
 
-static int hdsp_spdif_nonaudio(hdsp_t *hdsp)
+static int hdsp_spdif_nonaudio(struct hdsp *hdsp)
 {
        return (hdsp->control_register & HDSP_SPDIFNonAudio) ? 1 : 0;
 }
 
-static int hdsp_set_spdif_nonaudio(hdsp_t *hdsp, int val)
+static int hdsp_set_spdif_nonaudio(struct hdsp *hdsp, int val)
 {
-       if (val) {
+       if (val)
                hdsp->control_register |= HDSP_SPDIFNonAudio;
-       } else {
+       else
                hdsp->control_register &= ~HDSP_SPDIFNonAudio;
-       }
        hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
        return 0;
 }
 
-static int snd_hdsp_get_spdif_nonaudio(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_spdif_nonaudio(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        
        ucontrol->value.integer.value[0] = hdsp_spdif_nonaudio(hdsp);
        return 0;
 }
 
-static int snd_hdsp_put_spdif_nonaudio(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_spdif_nonaudio(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        int change;
        unsigned int val;
        
@@ -1769,7 +1731,7 @@ static int snd_hdsp_put_spdif_nonaudio(snd_kcontrol_t * kcontrol, snd_ctl_elem_v
 }
 
 #define HDSP_SPDIF_SAMPLE_RATE(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
   .name = xname, \
   .index = xindex, \
   .access = SNDRV_CTL_ELEM_ACCESS_READ, \
@@ -1777,10 +1739,10 @@ static int snd_hdsp_put_spdif_nonaudio(snd_kcontrol_t * kcontrol, snd_ctl_elem_v
   .get = snd_hdsp_get_spdif_sample_rate \
 }
 
-static int snd_hdsp_info_spdif_sample_rate(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_spdif_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        static char *texts[] = {"32000", "44100", "48000", "64000", "88200", "96000", "None", "128000", "176400", "192000"};
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
 
        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
        uinfo->count = 1;
@@ -1791,9 +1753,9 @@ static int snd_hdsp_info_spdif_sample_rate(snd_kcontrol_t *kcontrol, snd_ctl_ele
        return 0;
 }
 
-static int snd_hdsp_get_spdif_sample_rate(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_spdif_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        
        switch (hdsp_spdif_sample_rate(hdsp)) {
        case 32000:
@@ -1830,7 +1792,7 @@ static int snd_hdsp_get_spdif_sample_rate(snd_kcontrol_t * kcontrol, snd_ctl_ele
 }
 
 #define HDSP_SYSTEM_SAMPLE_RATE(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
   .name = xname, \
   .index = xindex, \
   .access = SNDRV_CTL_ELEM_ACCESS_READ, \
@@ -1838,23 +1800,23 @@ static int snd_hdsp_get_spdif_sample_rate(snd_kcontrol_t * kcontrol, snd_ctl_ele
   .get = snd_hdsp_get_system_sample_rate \
 }
 
-static int snd_hdsp_info_system_sample_rate(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_system_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
        uinfo->count = 1;
        return 0;
 }
 
-static int snd_hdsp_get_system_sample_rate(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_system_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        
        ucontrol->value.enumerated.item[0] = hdsp->system_sample_rate;
        return 0;
 }
 
 #define HDSP_AUTOSYNC_SAMPLE_RATE(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_PCM, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
   .name = xname, \
   .index = xindex, \
   .access = SNDRV_CTL_ELEM_ACCESS_READ, \
@@ -1862,9 +1824,9 @@ static int snd_hdsp_get_system_sample_rate(snd_kcontrol_t * kcontrol, snd_ctl_el
   .get = snd_hdsp_get_autosync_sample_rate \
 }
 
-static int snd_hdsp_info_autosync_sample_rate(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_autosync_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        static char *texts[] = {"32000", "44100", "48000", "64000", "88200", "96000", "None", "128000", "176400", "192000"};    
        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
        uinfo->count = 1;
@@ -1875,9 +1837,9 @@ static int snd_hdsp_info_autosync_sample_rate(snd_kcontrol_t *kcontrol, snd_ctl_
        return 0;
 }
 
-static int snd_hdsp_get_autosync_sample_rate(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_autosync_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        
        switch (hdsp_external_sample_rate(hdsp)) {
        case 32000:
@@ -1914,7 +1876,7 @@ static int snd_hdsp_get_autosync_sample_rate(snd_kcontrol_t * kcontrol, snd_ctl_
 }
 
 #define HDSP_SYSTEM_CLOCK_MODE(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
   .name = xname, \
   .index = xindex, \
   .access = SNDRV_CTL_ELEM_ACCESS_READ, \
@@ -1922,17 +1884,16 @@ static int snd_hdsp_get_autosync_sample_rate(snd_kcontrol_t * kcontrol, snd_ctl_
   .get = snd_hdsp_get_system_clock_mode \
 }
 
-static int hdsp_system_clock_mode(hdsp_t *hdsp)
+static int hdsp_system_clock_mode(struct hdsp *hdsp)
 {
-       if (hdsp->control_register & HDSP_ClockModeMaster) {
+       if (hdsp->control_register & HDSP_ClockModeMaster)
                return 0;
-       } else if (hdsp_external_sample_rate(hdsp) != hdsp->system_sample_rate) {
+       else if (hdsp_external_sample_rate(hdsp) != hdsp->system_sample_rate)
                        return 0;
-       }
        return 1;
 }
 
-static int snd_hdsp_info_system_clock_mode(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_system_clock_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        static char *texts[] = {"Master", "Slave" };
        
@@ -1945,16 +1906,16 @@ static int snd_hdsp_info_system_clock_mode(snd_kcontrol_t *kcontrol, snd_ctl_ele
        return 0;
 }
 
-static int snd_hdsp_get_system_clock_mode(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_system_clock_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        
        ucontrol->value.enumerated.item[0] = hdsp_system_clock_mode(hdsp);
        return 0;
 }
 
 #define HDSP_CLOCK_SOURCE(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_PCM, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
   .name = xname, \
   .index = xindex, \
   .info = snd_hdsp_info_clock_source, \
@@ -1962,7 +1923,7 @@ static int snd_hdsp_get_system_clock_mode(snd_kcontrol_t * kcontrol, snd_ctl_ele
   .put = snd_hdsp_put_clock_source \
 }
 
-static int hdsp_clock_source(hdsp_t *hdsp)
+static int hdsp_clock_source(struct hdsp *hdsp)
 {
        if (hdsp->control_register & HDSP_ClockModeMaster) {
                switch (hdsp->system_sample_rate) {
@@ -1992,7 +1953,7 @@ static int hdsp_clock_source(hdsp_t *hdsp)
        }
 }
 
-static int hdsp_set_clock_source(hdsp_t *hdsp, int mode)
+static int hdsp_set_clock_source(struct hdsp *hdsp, int mode)
 {
        int rate;
        switch (mode) {
@@ -2041,10 +2002,10 @@ static int hdsp_set_clock_source(hdsp_t *hdsp, int mode)
        return 0;
 }
 
-static int snd_hdsp_info_clock_source(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_clock_source(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        static char *texts[] = {"AutoSync", "Internal 32.0 kHz", "Internal 44.1 kHz", "Internal 48.0 kHz", "Internal 64.0 kHz", "Internal 88.2 kHz", "Internal 96.0 kHz", "Internal 128 kHz", "Internal 176.4 kHz", "Internal 192.0 KHz" };
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        
        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
        uinfo->count = 1;
@@ -2058,17 +2019,17 @@ static int snd_hdsp_info_clock_source(snd_kcontrol_t *kcontrol, snd_ctl_elem_inf
        return 0;
 }
 
-static int snd_hdsp_get_clock_source(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_clock_source(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        
        ucontrol->value.enumerated.item[0] = hdsp_clock_source(hdsp);
        return 0;
 }
 
-static int snd_hdsp_put_clock_source(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_clock_source(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        int change;
        int val;
        
@@ -2077,22 +2038,51 @@ static int snd_hdsp_put_clock_source(snd_kcontrol_t * kcontrol, snd_ctl_elem_val
        val = ucontrol->value.enumerated.item[0];
        if (val < 0) val = 0;
        if (hdsp->io_type == H9632) {
-           if (val > 9) val = 9;
+               if (val > 9)
+                       val = 9;
        } else {
-           if (val > 6) val = 6;
+               if (val > 6)
+                       val = 6;
        }
        spin_lock_irq(&hdsp->lock);
-       if (val != hdsp_clock_source(hdsp)) {
+       if (val != hdsp_clock_source(hdsp))
                change = (hdsp_set_clock_source(hdsp, val) == 0) ? 1 : 0;
-       } else {
+       else
                change = 0;
-       }
        spin_unlock_irq(&hdsp->lock);
        return change;
 }
 
+static int snd_hdsp_info_clock_source_lock(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;
+}
+
+static int snd_hdsp_get_clock_source_lock(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
+{
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
+       
+       ucontrol->value.integer.value[0] = hdsp->clock_source_locked;
+       return 0;
+}
+
+static int snd_hdsp_put_clock_source_lock(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
+{
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
+       int change;
+
+       change = (int)ucontrol->value.integer.value[0] != hdsp->clock_source_locked;
+       if (change)
+               hdsp->clock_source_locked = ucontrol->value.integer.value[0];
+       return change;
+}
+
 #define HDSP_DA_GAIN(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
   .name = xname, \
   .index = xindex, \
   .info = snd_hdsp_info_da_gain, \
@@ -2100,7 +2090,7 @@ static int snd_hdsp_put_clock_source(snd_kcontrol_t * kcontrol, snd_ctl_elem_val
   .put = snd_hdsp_put_da_gain \
 }
 
-static int hdsp_da_gain(hdsp_t *hdsp)
+static int hdsp_da_gain(struct hdsp *hdsp)
 {
        switch (hdsp->control_register & HDSP_DAGainMask) {
        case HDSP_DAGainHighGain:
@@ -2114,7 +2104,7 @@ static int hdsp_da_gain(hdsp_t *hdsp)
        }
 }
 
-static int hdsp_set_da_gain(hdsp_t *hdsp, int mode)
+static int hdsp_set_da_gain(struct hdsp *hdsp, int mode)
 {
        hdsp->control_register &= ~HDSP_DAGainMask;
        switch (mode) {
@@ -2135,7 +2125,7 @@ static int hdsp_set_da_gain(hdsp_t *hdsp, int mode)
        return 0;
 }
 
-static int snd_hdsp_info_da_gain(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_da_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        static char *texts[] = {"Hi Gain", "+4 dBu", "-10 dbV"};
        
@@ -2148,17 +2138,17 @@ static int snd_hdsp_info_da_gain(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *
        return 0;
 }
 
-static int snd_hdsp_get_da_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_da_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        
        ucontrol->value.enumerated.item[0] = hdsp_da_gain(hdsp);
        return 0;
 }
 
-static int snd_hdsp_put_da_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_da_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        int change;
        int val;
        
@@ -2168,17 +2158,16 @@ static int snd_hdsp_put_da_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
        if (val < 0) val = 0;
        if (val > 2) val = 2;
        spin_lock_irq(&hdsp->lock);
-       if (val != hdsp_da_gain(hdsp)) {
+       if (val != hdsp_da_gain(hdsp))
                change = (hdsp_set_da_gain(hdsp, val) == 0) ? 1 : 0;
-       } else {
+       else
                change = 0;
-       }
        spin_unlock_irq(&hdsp->lock);
        return change;
 }
 
 #define HDSP_AD_GAIN(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
   .name = xname, \
   .index = xindex, \
   .info = snd_hdsp_info_ad_gain, \
@@ -2186,7 +2175,7 @@ static int snd_hdsp_put_da_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
   .put = snd_hdsp_put_ad_gain \
 }
 
-static int hdsp_ad_gain(hdsp_t *hdsp)
+static int hdsp_ad_gain(struct hdsp *hdsp)
 {
        switch (hdsp->control_register & HDSP_ADGainMask) {
        case HDSP_ADGainMinus10dBV:
@@ -2200,7 +2189,7 @@ static int hdsp_ad_gain(hdsp_t *hdsp)
        }
 }
 
-static int hdsp_set_ad_gain(hdsp_t *hdsp, int mode)
+static int hdsp_set_ad_gain(struct hdsp *hdsp, int mode)
 {
        hdsp->control_register &= ~HDSP_ADGainMask;
        switch (mode) {
@@ -2221,7 +2210,7 @@ static int hdsp_set_ad_gain(hdsp_t *hdsp, int mode)
        return 0;
 }
 
-static int snd_hdsp_info_ad_gain(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_ad_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        static char *texts[] = {"-10 dBV", "+4 dBu", "Lo Gain"};
        
@@ -2234,17 +2223,17 @@ static int snd_hdsp_info_ad_gain(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *
        return 0;
 }
 
-static int snd_hdsp_get_ad_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_ad_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        
        ucontrol->value.enumerated.item[0] = hdsp_ad_gain(hdsp);
        return 0;
 }
 
-static int snd_hdsp_put_ad_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_ad_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        int change;
        int val;
        
@@ -2254,17 +2243,16 @@ static int snd_hdsp_put_ad_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
        if (val < 0) val = 0;
        if (val > 2) val = 2;
        spin_lock_irq(&hdsp->lock);
-       if (val != hdsp_ad_gain(hdsp)) {
+       if (val != hdsp_ad_gain(hdsp))
                change = (hdsp_set_ad_gain(hdsp, val) == 0) ? 1 : 0;
-       } else {
+       else
                change = 0;
-       }
        spin_unlock_irq(&hdsp->lock);
        return change;
 }
 
 #define HDSP_PHONE_GAIN(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
   .name = xname, \
   .index = xindex, \
   .info = snd_hdsp_info_phone_gain, \
@@ -2272,7 +2260,7 @@ static int snd_hdsp_put_ad_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
   .put = snd_hdsp_put_phone_gain \
 }
 
-static int hdsp_phone_gain(hdsp_t *hdsp)
+static int hdsp_phone_gain(struct hdsp *hdsp)
 {
        switch (hdsp->control_register & HDSP_PhoneGainMask) {
        case HDSP_PhoneGain0dB:
@@ -2286,7 +2274,7 @@ static int hdsp_phone_gain(hdsp_t *hdsp)
        }
 }
 
-static int hdsp_set_phone_gain(hdsp_t *hdsp, int mode)
+static int hdsp_set_phone_gain(struct hdsp *hdsp, int mode)
 {
        hdsp->control_register &= ~HDSP_PhoneGainMask;
        switch (mode) {
@@ -2307,7 +2295,7 @@ static int hdsp_set_phone_gain(hdsp_t *hdsp, int mode)
        return 0;
 }
 
-static int snd_hdsp_info_phone_gain(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_phone_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        static char *texts[] = {"0 dB", "-6 dB", "-12 dB"};
        
@@ -2320,17 +2308,17 @@ static int snd_hdsp_info_phone_gain(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_
        return 0;
 }
 
-static int snd_hdsp_get_phone_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_phone_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        
        ucontrol->value.enumerated.item[0] = hdsp_phone_gain(hdsp);
        return 0;
 }
 
-static int snd_hdsp_put_phone_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_phone_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        int change;
        int val;
        
@@ -2340,17 +2328,16 @@ static int snd_hdsp_put_phone_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value
        if (val < 0) val = 0;
        if (val > 2) val = 2;
        spin_lock_irq(&hdsp->lock);
-       if (val != hdsp_phone_gain(hdsp)) {
+       if (val != hdsp_phone_gain(hdsp))
                change = (hdsp_set_phone_gain(hdsp, val) == 0) ? 1 : 0;
-       } else {
+       else
                change = 0;
-       }
        spin_unlock_irq(&hdsp->lock);
        return change;
 }
 
 #define HDSP_XLR_BREAKOUT_CABLE(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
   .name = xname, \
   .index = xindex, \
   .info = snd_hdsp_info_xlr_breakout_cable, \
@@ -2358,26 +2345,24 @@ static int snd_hdsp_put_phone_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value
   .put = snd_hdsp_put_xlr_breakout_cable \
 }
 
-static int hdsp_xlr_breakout_cable(hdsp_t *hdsp)
+static int hdsp_xlr_breakout_cable(struct hdsp *hdsp)
 {
-       if (hdsp->control_register & HDSP_XLRBreakoutCable) {
+       if (hdsp->control_register & HDSP_XLRBreakoutCable)
                return 1;
-       }
        return 0;
 }
 
-static int hdsp_set_xlr_breakout_cable(hdsp_t *hdsp, int mode)
+static int hdsp_set_xlr_breakout_cable(struct hdsp *hdsp, int mode)
 {
-       if (mode) {
+       if (mode)
                hdsp->control_register |= HDSP_XLRBreakoutCable;
-       } else {
+       else
                hdsp->control_register &= ~HDSP_XLRBreakoutCable;
-       }
        hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
        return 0;
 }
 
-static int snd_hdsp_info_xlr_breakout_cable(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_xlr_breakout_cable(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
        uinfo->count = 1;
@@ -2386,17 +2371,17 @@ static int snd_hdsp_info_xlr_breakout_cable(snd_kcontrol_t *kcontrol, snd_ctl_el
        return 0;
 }
 
-static int snd_hdsp_get_xlr_breakout_cable(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_xlr_breakout_cable(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        
        ucontrol->value.enumerated.item[0] = hdsp_xlr_breakout_cable(hdsp);
        return 0;
 }
 
-static int snd_hdsp_put_xlr_breakout_cable(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_xlr_breakout_cable(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        int change;
        int val;
        
@@ -2415,7 +2400,7 @@ static int snd_hdsp_put_xlr_breakout_cable(snd_kcontrol_t * kcontrol, snd_ctl_el
    Switching this on desactivates external ADAT
 */
 #define HDSP_AEB(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
   .name = xname, \
   .index = xindex, \
   .info = snd_hdsp_info_aeb, \
@@ -2423,26 +2408,24 @@ static int snd_hdsp_put_xlr_breakout_cable(snd_kcontrol_t * kcontrol, snd_ctl_el
   .put = snd_hdsp_put_aeb \
 }
 
-static int hdsp_aeb(hdsp_t *hdsp)
+static int hdsp_aeb(struct hdsp *hdsp)
 {
-       if (hdsp->control_register & HDSP_AnalogExtensionBoard) {
+       if (hdsp->control_register & HDSP_AnalogExtensionBoard)
                return 1;
-       }
        return 0;
 }
 
-static int hdsp_set_aeb(hdsp_t *hdsp, int mode)
+static int hdsp_set_aeb(struct hdsp *hdsp, int mode)
 {
-       if (mode) {
+       if (mode)
                hdsp->control_register |= HDSP_AnalogExtensionBoard;
-       } else {
+       else
                hdsp->control_register &= ~HDSP_AnalogExtensionBoard;
-       }
        hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
        return 0;
 }
 
-static int snd_hdsp_info_aeb(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_aeb(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
        uinfo->count = 1;
@@ -2451,17 +2434,17 @@ static int snd_hdsp_info_aeb(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uin
        return 0;
 }
 
-static int snd_hdsp_get_aeb(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_aeb(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        
        ucontrol->value.enumerated.item[0] = hdsp_aeb(hdsp);
        return 0;
 }
 
-static int snd_hdsp_put_aeb(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_aeb(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        int change;
        int val;
        
@@ -2476,7 +2459,7 @@ static int snd_hdsp_put_aeb(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * uc
 }
 
 #define HDSP_PREF_SYNC_REF(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
   .name = xname, \
   .index = xindex, \
   .info = snd_hdsp_info_pref_sync_ref, \
@@ -2484,7 +2467,7 @@ static int snd_hdsp_put_aeb(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * uc
   .put = snd_hdsp_put_pref_sync_ref \
 }
 
-static int hdsp_pref_sync_ref(hdsp_t *hdsp)
+static int hdsp_pref_sync_ref(struct hdsp *hdsp)
 {
        /* Notice that this looks at the requested sync source,
           not the one actually in use.
@@ -2509,7 +2492,7 @@ static int hdsp_pref_sync_ref(hdsp_t *hdsp)
        return 0;
 }
 
-static int hdsp_set_pref_sync_ref(hdsp_t *hdsp, int pref)
+static int hdsp_set_pref_sync_ref(struct hdsp *hdsp, int pref)
 {
        hdsp->control_register &= ~HDSP_SyncRefMask;
        switch (pref) {
@@ -2538,10 +2521,10 @@ static int hdsp_set_pref_sync_ref(hdsp_t *hdsp, int pref)
        return 0;
 }
 
-static int snd_hdsp_info_pref_sync_ref(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_pref_sync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        static char *texts[] = {"Word", "IEC958", "ADAT1", "ADAT Sync", "ADAT2", "ADAT3" };
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        
        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
        uinfo->count = 1;
@@ -2568,17 +2551,17 @@ static int snd_hdsp_info_pref_sync_ref(snd_kcontrol_t *kcontrol, snd_ctl_elem_in
        return 0;
 }
 
-static int snd_hdsp_get_pref_sync_ref(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_pref_sync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        
        ucontrol->value.enumerated.item[0] = hdsp_pref_sync_ref(hdsp);
        return 0;
 }
 
-static int snd_hdsp_put_pref_sync_ref(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_pref_sync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        int change, max;
        unsigned int val;
        
@@ -2609,7 +2592,7 @@ static int snd_hdsp_put_pref_sync_ref(snd_kcontrol_t * kcontrol, snd_ctl_elem_va
 }
 
 #define HDSP_AUTOSYNC_REF(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
   .name = xname, \
   .index = xindex, \
   .access = SNDRV_CTL_ELEM_ACCESS_READ, \
@@ -2617,7 +2600,7 @@ static int snd_hdsp_put_pref_sync_ref(snd_kcontrol_t * kcontrol, snd_ctl_elem_va
   .get = snd_hdsp_get_autosync_ref, \
 }
 
-static int hdsp_autosync_ref(hdsp_t *hdsp)
+static int hdsp_autosync_ref(struct hdsp *hdsp)
 {
        /* This looks at the autosync selected sync reference */
        unsigned int status2 = hdsp_read(hdsp, HDSP_status2Register);
@@ -2643,7 +2626,7 @@ static int hdsp_autosync_ref(hdsp_t *hdsp)
        return 0;
 }
 
-static int snd_hdsp_info_autosync_ref(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_autosync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        static char *texts[] = {"Word", "ADAT Sync", "IEC958", "None", "ADAT1", "ADAT2", "ADAT3" };
        
@@ -2656,16 +2639,16 @@ static int snd_hdsp_info_autosync_ref(snd_kcontrol_t *kcontrol, snd_ctl_elem_inf
        return 0;
 }
 
-static int snd_hdsp_get_autosync_ref(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_autosync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        
        ucontrol->value.enumerated.item[0] = hdsp_autosync_ref(hdsp);
        return 0;
 }
 
 #define HDSP_LINE_OUT(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
   .name = xname, \
   .index = xindex, \
   .info = snd_hdsp_info_line_out, \
@@ -2673,23 +2656,22 @@ static int snd_hdsp_get_autosync_ref(snd_kcontrol_t * kcontrol, snd_ctl_elem_val
   .put = snd_hdsp_put_line_out \
 }
 
-static int hdsp_line_out(hdsp_t *hdsp)
+static int hdsp_line_out(struct hdsp *hdsp)
 {
        return (hdsp->control_register & HDSP_LineOut) ? 1 : 0;
 }
 
-static int hdsp_set_line_output(hdsp_t *hdsp, int out)
+static int hdsp_set_line_output(struct hdsp *hdsp, int out)
 {
-       if (out) {
+       if (out)
                hdsp->control_register |= HDSP_LineOut;
-       } else {
+       else
                hdsp->control_register &= ~HDSP_LineOut;
-       }
        hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
        return 0;
 }
 
-static int snd_hdsp_info_line_out(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_line_out(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
        uinfo->count = 1;
@@ -2698,9 +2680,9 @@ static int snd_hdsp_info_line_out(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t
        return 0;
 }
 
-static int snd_hdsp_get_line_out(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_line_out(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        
        spin_lock_irq(&hdsp->lock);
        ucontrol->value.integer.value[0] = hdsp_line_out(hdsp);
@@ -2708,9 +2690,9 @@ static int snd_hdsp_get_line_out(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
        return 0;
 }
 
-static int snd_hdsp_put_line_out(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_line_out(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        int change;
        unsigned int val;
        
@@ -2725,7 +2707,7 @@ static int snd_hdsp_put_line_out(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
 }
 
 #define HDSP_PRECISE_POINTER(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_CARD, \
   .name = xname, \
   .index = xindex, \
   .info = snd_hdsp_info_precise_pointer, \
@@ -2733,17 +2715,16 @@ static int snd_hdsp_put_line_out(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
   .put = snd_hdsp_put_precise_pointer \
 }
 
-static int hdsp_set_precise_pointer(hdsp_t *hdsp, int precise)
+static int hdsp_set_precise_pointer(struct hdsp *hdsp, int precise)
 {
-       if (precise) {
+       if (precise)
                hdsp->precise_ptr = 1;
-       } else {
+       else
                hdsp->precise_ptr = 0;
-       }
        return 0;
 }
 
-static int snd_hdsp_info_precise_pointer(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_precise_pointer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
        uinfo->count = 1;
@@ -2752,9 +2733,9 @@ static int snd_hdsp_info_precise_pointer(snd_kcontrol_t *kcontrol, snd_ctl_elem_
        return 0;
 }
 
-static int snd_hdsp_get_precise_pointer(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_precise_pointer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        
        spin_lock_irq(&hdsp->lock);
        ucontrol->value.integer.value[0] = hdsp->precise_ptr;
@@ -2762,9 +2743,9 @@ static int snd_hdsp_get_precise_pointer(snd_kcontrol_t * kcontrol, snd_ctl_elem_
        return 0;
 }
 
-static int snd_hdsp_put_precise_pointer(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_precise_pointer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        int change;
        unsigned int val;
        
@@ -2779,7 +2760,7 @@ static int snd_hdsp_put_precise_pointer(snd_kcontrol_t * kcontrol, snd_ctl_elem_
 }
 
 #define HDSP_USE_MIDI_TASKLET(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_CARD, \
   .name = xname, \
   .index = xindex, \
   .info = snd_hdsp_info_use_midi_tasklet, \
@@ -2787,17 +2768,16 @@ static int snd_hdsp_put_precise_pointer(snd_kcontrol_t * kcontrol, snd_ctl_elem_
   .put = snd_hdsp_put_use_midi_tasklet \
 }
 
-static int hdsp_set_use_midi_tasklet(hdsp_t *hdsp, int use_tasklet)
+static int hdsp_set_use_midi_tasklet(struct hdsp *hdsp, int use_tasklet)
 {
-       if (use_tasklet) {
+       if (use_tasklet)
                hdsp->use_midi_tasklet = 1;
-       } else {
+       else
                hdsp->use_midi_tasklet = 0;
-       }
        return 0;
 }
 
-static int snd_hdsp_info_use_midi_tasklet(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_use_midi_tasklet(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
        uinfo->count = 1;
@@ -2806,9 +2786,9 @@ static int snd_hdsp_info_use_midi_tasklet(snd_kcontrol_t *kcontrol, snd_ctl_elem
        return 0;
 }
 
-static int snd_hdsp_get_use_midi_tasklet(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_use_midi_tasklet(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        
        spin_lock_irq(&hdsp->lock);
        ucontrol->value.integer.value[0] = hdsp->use_midi_tasklet;
@@ -2816,9 +2796,9 @@ static int snd_hdsp_get_use_midi_tasklet(snd_kcontrol_t * kcontrol, snd_ctl_elem
        return 0;
 }
 
-static int snd_hdsp_put_use_midi_tasklet(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_use_midi_tasklet(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        int change;
        unsigned int val;
        
@@ -2836,6 +2816,7 @@ static int snd_hdsp_put_use_midi_tasklet(snd_kcontrol_t * kcontrol, snd_ctl_elem
 { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
   .name = xname, \
   .index = xindex, \
+  .device = 0, \
   .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
                 SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
   .info = snd_hdsp_info_mixer, \
@@ -2843,7 +2824,7 @@ static int snd_hdsp_put_use_midi_tasklet(snd_kcontrol_t * kcontrol, snd_ctl_elem
   .put = snd_hdsp_put_mixer \
 }
 
-static int snd_hdsp_info_mixer(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_mixer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
        uinfo->count = 3;
@@ -2853,9 +2834,9 @@ static int snd_hdsp_info_mixer(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u
        return 0;
 }
 
-static int snd_hdsp_get_mixer(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_mixer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        int source;
        int destination;
        int addr;
@@ -2863,11 +2844,10 @@ static int snd_hdsp_get_mixer(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
        source = ucontrol->value.integer.value[0];
        destination = ucontrol->value.integer.value[1];
        
-       if (source >= hdsp->max_channels) {
+       if (source >= hdsp->max_channels)
                addr = hdsp_playback_to_output_key(hdsp,source-hdsp->max_channels,destination);
-       } else {
+       else
                addr = hdsp_input_to_output_key(hdsp,source, destination);
-       }
        
        spin_lock_irq(&hdsp->lock);
        ucontrol->value.integer.value[2] = hdsp_read_gain (hdsp, addr);
@@ -2875,9 +2855,9 @@ static int snd_hdsp_get_mixer(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
        return 0;
 }
 
-static int snd_hdsp_put_mixer(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_put_mixer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
        int change;
        int source;
        int destination;
@@ -2890,11 +2870,10 @@ static int snd_hdsp_put_mixer(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
        source = ucontrol->value.integer.value[0];
        destination = ucontrol->value.integer.value[1];
 
-       if (source >= hdsp->max_channels) {
+       if (source >= hdsp->max_channels)
                addr = hdsp_playback_to_output_key(hdsp,source-hdsp->max_channels, destination);
-       } else {
+       else
                addr = hdsp_input_to_output_key(hdsp,source, destination);
-       }
 
        gain = ucontrol->value.integer.value[2];
 
@@ -2907,7 +2886,7 @@ static int snd_hdsp_put_mixer(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
 }
 
 #define HDSP_WC_SYNC_CHECK(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
   .name = xname, \
   .index = xindex, \
   .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
@@ -2915,7 +2894,7 @@ static int snd_hdsp_put_mixer(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
   .get = snd_hdsp_get_wc_sync_check \
 }
 
-static int snd_hdsp_info_sync_check(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_hdsp_info_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        static char *texts[] = {"No Lock", "Lock", "Sync" };    
        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
@@ -2927,31 +2906,29 @@ static int snd_hdsp_info_sync_check(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_
        return 0;
 }
 
-static int hdsp_wc_sync_check(hdsp_t *hdsp)
+static int hdsp_wc_sync_check(struct hdsp *hdsp)
 {
        int status2 = hdsp_read(hdsp, HDSP_status2Register);
        if (status2 & HDSP_wc_lock) {
-               if (status2 & HDSP_wc_sync) {
+               if (status2 & HDSP_wc_sync)
                        return 2;
-               } else {
+               else
                         return 1;
-               }
-       } else {                
+       } else
                return 0;
-       }
        return 0;
 }
 
-static int snd_hdsp_get_wc_sync_check(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_wc_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
 
        ucontrol->value.enumerated.item[0] = hdsp_wc_sync_check(hdsp);
        return 0;
 }
 
 #define HDSP_SPDIF_SYNC_CHECK(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
   .name = xname, \
   .index = xindex, \
   .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
@@ -2959,31 +2936,30 @@ static int snd_hdsp_get_wc_sync_check(snd_kcontrol_t * kcontrol, snd_ctl_elem_va
   .get = snd_hdsp_get_spdif_sync_check \
 }
 
-static int hdsp_spdif_sync_check(hdsp_t *hdsp)
+static int hdsp_spdif_sync_check(struct hdsp *hdsp)
 {
        int status = hdsp_read(hdsp, HDSP_statusRegister);
-       if (status & HDSP_SPDIFErrorFlag) {
+       if (status & HDSP_SPDIFErrorFlag)
                return 0;
-       } else {        
-               if (status & HDSP_SPDIFSync) {
+       else {  
+               if (status & HDSP_SPDIFSync)
                        return 2;
-               } else {
+               else
                        return 1;
-               }
        }
        return 0;
 }
 
-static int snd_hdsp_get_spdif_sync_check(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_spdif_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
 
        ucontrol->value.enumerated.item[0] = hdsp_spdif_sync_check(hdsp);
        return 0;
 }
 
 #define HDSP_ADATSYNC_SYNC_CHECK(xname, xindex) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
   .name = xname, \
   .index = xindex, \
   .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
@@ -2991,54 +2967,50 @@ static int snd_hdsp_get_spdif_sync_check(snd_kcontrol_t * kcontrol, snd_ctl_elem
   .get = snd_hdsp_get_adatsync_sync_check \
 }
 
-static int hdsp_adatsync_sync_check(hdsp_t *hdsp)
+static int hdsp_adatsync_sync_check(struct hdsp *hdsp)
 {
        int status = hdsp_read(hdsp, HDSP_statusRegister);
        if (status & HDSP_TimecodeLock) {
-               if (status & HDSP_TimecodeSync) {
+               if (status & HDSP_TimecodeSync)
                        return 2;
-               } else {
+               else
                        return 1;
-               }
-       } else {
+       } else
                return 0;
-       }
 }      
 
-static int snd_hdsp_get_adatsync_sync_check(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_adatsync_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
 
        ucontrol->value.enumerated.item[0] = hdsp_adatsync_sync_check(hdsp);
        return 0;
 }
 
 #define HDSP_ADAT_SYNC_CHECK \
-{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
   .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
   .info = snd_hdsp_info_sync_check, \
   .get = snd_hdsp_get_adat_sync_check \
 }
 
-static int hdsp_adat_sync_check(hdsp_t *hdsp, int idx)
+static int hdsp_adat_sync_check(struct hdsp *hdsp, int idx)
 {      
        int status = hdsp_read(hdsp, HDSP_statusRegister);
        
        if (status & (HDSP_Lock0>>idx)) {
-               if (status & (HDSP_Sync0>>idx)) {
+               if (status & (HDSP_Sync0>>idx))
                        return 2;
-               } else {
+               else
                        return 1;               
-               }
-       } else {
+       } else
                return 0;
-       }               
 } 
 
-static int snd_hdsp_get_adat_sync_check(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_hdsp_get_adat_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
        int offset;
-       hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
+       struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
 
        offset = ucontrol->id.index - 1;
        snd_assert(offset >= 0);
@@ -3062,14 +3034,14 @@ static int snd_hdsp_get_adat_sync_check(snd_kcontrol_t * kcontrol, snd_ctl_elem_
        return 0;
 }
 
-static snd_kcontrol_new_t snd_hdsp_9632_controls[] = {
+static struct snd_kcontrol_new snd_hdsp_9632_controls[] = {
 HDSP_DA_GAIN("DA Gain", 0),
 HDSP_AD_GAIN("AD Gain", 0),
 HDSP_PHONE_GAIN("Phones Gain", 0),
 HDSP_XLR_BREAKOUT_CABLE("XLR Breakout Cable", 0)
 };
 
-static snd_kcontrol_new_t snd_hdsp_controls[] = {
+static struct snd_kcontrol_new snd_hdsp_controls[] = {
 {
        .iface =        SNDRV_CTL_ELEM_IFACE_PCM,
        .name =         SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),
@@ -3087,7 +3059,7 @@ static snd_kcontrol_new_t snd_hdsp_controls[] = {
 },
 {
        .access =       SNDRV_CTL_ELEM_ACCESS_READ,
-       .iface =        SNDRV_CTL_ELEM_IFACE_MIXER,
+       .iface =        SNDRV_CTL_ELEM_IFACE_PCM,
        .name =         SNDRV_CTL_NAME_IEC958("",PLAYBACK,CON_MASK),
        .info =         snd_hdsp_control_spdif_mask_info,
        .get =          snd_hdsp_control_spdif_mask_get,
@@ -3097,7 +3069,7 @@ static snd_kcontrol_new_t snd_hdsp_controls[] = {
 },
 {
        .access =       SNDRV_CTL_ELEM_ACCESS_READ,
-       .iface =        SNDRV_CTL_ELEM_IFACE_MIXER,
+       .iface =        SNDRV_CTL_ELEM_IFACE_PCM,
        .name =         SNDRV_CTL_NAME_IEC958("",PLAYBACK,PRO_MASK),
        .info =         snd_hdsp_control_spdif_mask_info,
        .get =          snd_hdsp_control_spdif_mask_get,
@@ -3113,6 +3085,13 @@ HDSP_SPDIF_EMPHASIS("IEC958 Emphasis Bit", 0),
 HDSP_SPDIF_NON_AUDIO("IEC958 Non-audio Bit", 0),
 /* 'Sample Clock Source' complies with the alsa control naming scheme */ 
 HDSP_CLOCK_SOURCE("Sample Clock Source", 0),
+{
+       .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+       .name = "Sample Clock Source Locking",
+       .info = snd_hdsp_info_clock_source_lock,
+       .get = snd_hdsp_get_clock_source_lock,
+       .put = snd_hdsp_put_clock_source_lock,
+},
 HDSP_SYSTEM_CLOCK_MODE("System Clock Mode", 0),
 HDSP_PREF_SYNC_REF("Preferred Sync Reference", 0),
 HDSP_AUTOSYNC_REF("AutoSync Reference", 0),
@@ -3128,19 +3107,18 @@ HDSP_PRECISE_POINTER("Precise Pointer", 0),
 HDSP_USE_MIDI_TASKLET("Use Midi Tasklet", 0),
 };
 
-static snd_kcontrol_new_t snd_hdsp_96xx_aeb = HDSP_AEB("Analog Extension Board", 0);
-static snd_kcontrol_new_t snd_hdsp_adat_sync_check = HDSP_ADAT_SYNC_CHECK;
+static struct snd_kcontrol_new snd_hdsp_96xx_aeb = HDSP_AEB("Analog Extension Board", 0);
+static struct snd_kcontrol_new snd_hdsp_adat_sync_check = HDSP_ADAT_SYNC_CHECK;
 
-static int snd_hdsp_create_controls(snd_card_t *card, hdsp_t *hdsp)
+static int snd_hdsp_create_controls(struct snd_card *card, struct hdsp *hdsp)
 {
        unsigned int idx;
        int err;
-       snd_kcontrol_t *kctl;
+       struct snd_kcontrol *kctl;
 
        for (idx = 0; idx < ARRAY_SIZE(snd_hdsp_controls); idx++) {
-               if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_hdsp_controls[idx], hdsp))) < 0) {
+               if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_hdsp_controls[idx], hdsp))) < 0)
                        return err;
-               }
                if (idx == 1)   /* IEC958 (S/PDIF) Stream */
                        hdsp->spdif_ctl = kctl;
        }
@@ -3148,32 +3126,28 @@ static int snd_hdsp_create_controls(snd_card_t *card, hdsp_t *hdsp)
        /* ADAT SyncCheck status */
        snd_hdsp_adat_sync_check.name = "ADAT Lock Status";
        snd_hdsp_adat_sync_check.index = 1;
-       if ((err = snd_ctl_add (card, kctl = snd_ctl_new1(&snd_hdsp_adat_sync_check, hdsp)))) {
+       if ((err = snd_ctl_add (card, kctl = snd_ctl_new1(&snd_hdsp_adat_sync_check, hdsp))))
                return err;
-       }       
        if (hdsp->io_type == Digiface || hdsp->io_type == H9652) {
                for (idx = 1; idx < 3; ++idx) {
                        snd_hdsp_adat_sync_check.index = idx+1;
-                       if ((err = snd_ctl_add (card, kctl = snd_ctl_new1(&snd_hdsp_adat_sync_check, hdsp)))) {
+                       if ((err = snd_ctl_add (card, kctl = snd_ctl_new1(&snd_hdsp_adat_sync_check, hdsp))))
                                return err;
-                       }
                }
        }
        
        /* DA, AD and Phone gain and XLR breakout cable controls for H9632 cards */
        if (hdsp->io_type == H9632) {
                for (idx = 0; idx < ARRAY_SIZE(snd_hdsp_9632_controls); idx++) {
-                       if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_hdsp_9632_controls[idx], hdsp))) < 0) {
+                       if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_hdsp_9632_controls[idx], hdsp))) < 0)
                                return err;
-                       }
                }
        }
 
        /* AEB control for H96xx card */
        if (hdsp->io_type == H9632 || hdsp->io_type == H9652) {
-               if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_hdsp_96xx_aeb, hdsp))) < 0) {
+               if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_hdsp_96xx_aeb, hdsp))) < 0)
                                return err;
-               }       
        }
 
        return 0;
@@ -3184,9 +3158,9 @@ static int snd_hdsp_create_controls(snd_card_t *card, hdsp_t *hdsp)
  ------------------------------------------------------------*/
 
 static void
-snd_hdsp_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer)
+snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
 {
-       hdsp_t *hdsp = (hdsp_t *) entry->private_data;
+       struct hdsp *hdsp = (struct hdsp *) entry->private_data;
        unsigned int status;
        unsigned int status2;
        char *pref_sync_ref;
@@ -3195,12 +3169,11 @@ snd_hdsp_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer)
        char *clock_source;
        int x;
 
-       if (hdsp_check_for_iobox (hdsp)) {
+       if (hdsp_check_for_iobox (hdsp))
                snd_iprintf(buffer, "No I/O box connected.\nPlease connect one and upload firmware.\n");
                return;
-       }
 
-       if (hdsp_check_for_firmware(hdsp)) {
+       if (hdsp_check_for_firmware(hdsp, 0)) {
                if (hdsp->state & HDSP_FirmwareCached) {
                        if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) {
                                snd_iprintf(buffer, "Firmware loading from cache failed, please upload manually.\n");
@@ -3281,11 +3254,10 @@ snd_hdsp_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer)
        }
        snd_iprintf (buffer, "Sample Clock Source: %s\n", clock_source);
                        
-       if (hdsp_system_clock_mode(hdsp)) {
+       if (hdsp_system_clock_mode(hdsp))
                system_clock_mode = "Slave";
-       } else {
+       else
                system_clock_mode = "Master";
-       }
        
        switch (hdsp_pref_sync_ref (hdsp)) {
        case HDSP_SYNC_FROM_WORD:
@@ -3345,6 +3317,7 @@ snd_hdsp_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer)
        snd_iprintf (buffer, "System Clock Mode: %s\n", system_clock_mode);
 
        snd_iprintf (buffer, "System Clock Frequency: %d\n", hdsp->system_sample_rate);
+       snd_iprintf (buffer, "System Clock Locked: %s\n", hdsp->clock_source_locked ? "Yes" : "No");
                
        snd_iprintf(buffer, "\n");
 
@@ -3366,85 +3339,75 @@ snd_hdsp_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer)
                break;
        }
        
-       if (hdsp->control_register & HDSP_SPDIFOpticalOut) {
+       if (hdsp->control_register & HDSP_SPDIFOpticalOut)
                snd_iprintf(buffer, "IEC958 output: Coaxial & ADAT1\n");
-       } else {
+       else
                snd_iprintf(buffer, "IEC958 output: Coaxial only\n");
-       }
 
-       if (hdsp->control_register & HDSP_SPDIFProfessional) {
+       if (hdsp->control_register & HDSP_SPDIFProfessional)
                snd_iprintf(buffer, "IEC958 quality: Professional\n");
-       } else {
+       else
                snd_iprintf(buffer, "IEC958 quality: Consumer\n");
-       }
 
-       if (hdsp->control_register & HDSP_SPDIFEmphasis) {
+       if (hdsp->control_register & HDSP_SPDIFEmphasis)
                snd_iprintf(buffer, "IEC958 emphasis: on\n");
-       } else {
+       else
                snd_iprintf(buffer, "IEC958 emphasis: off\n");
-       }
 
-       if (hdsp->control_register & HDSP_SPDIFNonAudio) {
+       if (hdsp->control_register & HDSP_SPDIFNonAudio)
                snd_iprintf(buffer, "IEC958 NonAudio: on\n");
-       } else {
+       else
                snd_iprintf(buffer, "IEC958 NonAudio: off\n");
-       }
-       if ((x = hdsp_spdif_sample_rate (hdsp)) != 0) {
+       if ((x = hdsp_spdif_sample_rate (hdsp)) != 0)
                snd_iprintf (buffer, "IEC958 sample rate: %d\n", x);
-       } else {
+       else
                snd_iprintf (buffer, "IEC958 sample rate: Error flag set\n");
-       }
 
        snd_iprintf(buffer, "\n");
 
        /* Sync Check */
        x = status & HDSP_Sync0;
-       if (status & HDSP_Lock0) {
+       if (status & HDSP_Lock0)
                snd_iprintf(buffer, "ADAT1: %s\n", x ? "Sync" : "Lock");
-       } else {
+       else
                snd_iprintf(buffer, "ADAT1: No Lock\n");
-       }
 
        switch (hdsp->io_type) {
        case Digiface:
        case H9652:
                x = status & HDSP_Sync1;
-               if (status & HDSP_Lock1) {
+               if (status & HDSP_Lock1)
                        snd_iprintf(buffer, "ADAT2: %s\n", x ? "Sync" : "Lock");
-               } else {
+               else
                        snd_iprintf(buffer, "ADAT2: No Lock\n");
-               }
                x = status & HDSP_Sync2;
-               if (status & HDSP_Lock2) {
+               if (status & HDSP_Lock2)
                        snd_iprintf(buffer, "ADAT3: %s\n", x ? "Sync" : "Lock");
-               } else {
+               else
                        snd_iprintf(buffer, "ADAT3: No Lock\n");
-               }
+               break;
        default:
                /* relax */
                break;
        }
 
        x = status & HDSP_SPDIFSync;
-       if (status & HDSP_SPDIFErrorFlag) {
+       if (status & HDSP_SPDIFErrorFlag)
                snd_iprintf (buffer, "SPDIF: No Lock\n");
-       } else {
+       else
                snd_iprintf (buffer, "SPDIF: %s\n", x ? "Sync" : "Lock");
-       }
        
        x = status2 & HDSP_wc_sync;
-       if (status2 & HDSP_wc_lock) {
+       if (status2 & HDSP_wc_lock)
                snd_iprintf (buffer, "Word Clock: %s\n", x ? "Sync" : "Lock");
-       } else {
+       else
                snd_iprintf (buffer, "Word Clock: No Lock\n");
-       }
        
        x = status & HDSP_TimecodeSync;
-       if (status & HDSP_TimecodeLock) {
+       if (status & HDSP_TimecodeLock)
                snd_iprintf(buffer, "ADAT Sync: %s\n", x ? "Sync" : "Lock");
-       } else {
+       else
                snd_iprintf(buffer, "ADAT Sync: No Lock\n");
-       }
 
        snd_iprintf(buffer, "\n");
        
@@ -3493,31 +3456,30 @@ snd_hdsp_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer)
 
                snd_iprintf(buffer, "XLR Breakout Cable : %s\n", hdsp_xlr_breakout_cable(hdsp) ? "yes" : "no"); 
                
-               if (hdsp->control_register & HDSP_AnalogExtensionBoard) {
+               if (hdsp->control_register & HDSP_AnalogExtensionBoard)
                        snd_iprintf(buffer, "AEB : on (ADAT1 internal)\n");
-               } else {
+               else
                        snd_iprintf(buffer, "AEB : off (ADAT1 external)\n");
-               }
                snd_iprintf(buffer, "\n");
        }
 
 }
 
-static void __devinit snd_hdsp_proc_init(hdsp_t *hdsp)
+static void __devinit snd_hdsp_proc_init(struct hdsp *hdsp)
 {
-       snd_info_entry_t *entry;
+       struct snd_info_entry *entry;
 
        if (! snd_card_proc_new(hdsp->card, "hdsp", &entry))
                snd_info_set_text_ops(entry, hdsp, 1024, snd_hdsp_proc_read);
 }
 
-static void snd_hdsp_free_buffers(hdsp_t *hdsp)
+static void snd_hdsp_free_buffers(struct hdsp *hdsp)
 {
        snd_hammerfall_free_buffer(&hdsp->capture_dma_buf, hdsp->pci);
        snd_hammerfall_free_buffer(&hdsp->playback_dma_buf, hdsp->pci);
 }
 
-static int __devinit snd_hdsp_initialize_memory(hdsp_t *hdsp)
+static int __devinit snd_hdsp_initialize_memory(struct hdsp *hdsp)
 {
        unsigned long pb_bus, cb_bus;
 
@@ -3545,7 +3507,7 @@ static int __devinit snd_hdsp_initialize_memory(hdsp_t *hdsp)
        return 0;
 }
 
-static int snd_hdsp_set_defaults(hdsp_t *hdsp)
+static int snd_hdsp_set_defaults(struct hdsp *hdsp)
 {
        unsigned int i;
 
@@ -3576,25 +3538,22 @@ static int snd_hdsp_set_defaults(hdsp_t *hdsp)
 #else
        hdsp->control2_register = 0;
 #endif
-       if (hdsp->io_type == H9652) {
+       if (hdsp->io_type == H9652)
                snd_hdsp_9652_enable_mixer (hdsp);
-       } else {
-           hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register);
-       } 
+       else
+               hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register);
 
        hdsp_reset_hw_pointer(hdsp);
        hdsp_compute_period_size(hdsp);
 
        /* silence everything */
        
-       for (i = 0; i < HDSP_MATRIX_MIXER_SIZE; ++i) {
+       for (i = 0; i < HDSP_MATRIX_MIXER_SIZE; ++i)
                hdsp->mixer_matrix[i] = MINUS_INFINITY_GAIN;
-       }
 
        for (i = 0; i < ((hdsp->io_type == H9652 || hdsp->io_type == H9632) ? 1352 : HDSP_MATRIX_MIXER_SIZE); ++i) {
-               if (hdsp_write_gain (hdsp, i, MINUS_INFINITY_GAIN)) {
+               if (hdsp_write_gain (hdsp, i, MINUS_INFINITY_GAIN))
                        return -EIO;
-               }
        }
        
        /* H9632 specific defaults */
@@ -3613,19 +3572,17 @@ static int snd_hdsp_set_defaults(hdsp_t *hdsp)
 
 static void hdsp_midi_tasklet(unsigned long arg)
 {
-       hdsp_t *hdsp = (hdsp_t *)arg;
+       struct hdsp *hdsp = (struct hdsp *)arg;
        
-       if (hdsp->midi[0].pending) {
+       if (hdsp->midi[0].pending)
                snd_hdsp_midi_input_read (&hdsp->midi[0]);
-       }
-       if (hdsp->midi[1].pending) {
+       if (hdsp->midi[1].pending)
                snd_hdsp_midi_input_read (&hdsp->midi[1]);
-       }
 } 
 
 static irqreturn_t snd_hdsp_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-       hdsp_t *hdsp = (hdsp_t *) dev_id;
+       struct hdsp *hdsp = (struct hdsp *) dev_id;
        unsigned int status;
        int audio;
        int midi0;
@@ -3640,9 +3597,8 @@ static irqreturn_t snd_hdsp_interrupt(int irq, void *dev_id, struct pt_regs *reg
        midi0 = status & HDSP_midi0IRQPending;
        midi1 = status & HDSP_midi1IRQPending;
 
-       if (!audio && !midi0 && !midi1) {
+       if (!audio && !midi0 && !midi1)
                return IRQ_NONE;
-       }
 
        hdsp_write(hdsp, HDSP_interruptConfirmation, 0);
 
@@ -3650,13 +3606,11 @@ static irqreturn_t snd_hdsp_interrupt(int irq, void *dev_id, struct pt_regs *reg
        midi1status = hdsp_read (hdsp, HDSP_midiStatusIn1) & 0xff;
        
        if (audio) {
-               if (hdsp->capture_substream) {
+               if (hdsp->capture_substream)
                        snd_pcm_period_elapsed(hdsp->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream);
-               }
                
-               if (hdsp->playback_substream) {
+               if (hdsp->playback_substream)
                        snd_pcm_period_elapsed(hdsp->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream);
-               }
        }
        
        if (midi0 && midi0status) {
@@ -3686,13 +3640,13 @@ static irqreturn_t snd_hdsp_interrupt(int irq, void *dev_id, struct pt_regs *reg
        return IRQ_HANDLED;
 }
 
-static snd_pcm_uframes_t snd_hdsp_hw_pointer(snd_pcm_substream_t *substream)
+static snd_pcm_uframes_t snd_hdsp_hw_pointer(struct snd_pcm_substream *substream)
 {
-       hdsp_t *hdsp = snd_pcm_substream_chip(substream);
+       struct hdsp *hdsp = snd_pcm_substream_chip(substream);
        return hdsp_hw_pointer(hdsp);
 }
 
-static char *hdsp_channel_buffer_location(hdsp_t *hdsp,
+static char *hdsp_channel_buffer_location(struct hdsp *hdsp,
                                             int stream,
                                             int channel)
 
@@ -3701,21 +3655,19 @@ static char *hdsp_channel_buffer_location(hdsp_t *hdsp,
 
         snd_assert(channel >= 0 && channel < hdsp->max_channels, return NULL);
         
-       if ((mapped_channel = hdsp->channel_map[channel]) < 0) {
+       if ((mapped_channel = hdsp->channel_map[channel]) < 0)
                return NULL;
-       }
        
-       if (stream == SNDRV_PCM_STREAM_CAPTURE) {
+       if (stream == SNDRV_PCM_STREAM_CAPTURE)
                return hdsp->capture_buffer + (mapped_channel * HDSP_CHANNEL_BUFFER_BYTES);
-       } else {
+       else
                return hdsp->playback_buffer + (mapped_channel * HDSP_CHANNEL_BUFFER_BYTES);
-       }
 }
 
-static int snd_hdsp_playback_copy(snd_pcm_substream_t *substream, int channel,
+static int snd_hdsp_playback_copy(struct snd_pcm_substream *substream, int channel,
                                  snd_pcm_uframes_t pos, void __user *src, snd_pcm_uframes_t count)
 {
-       hdsp_t *hdsp = snd_pcm_substream_chip(substream);
+       struct hdsp *hdsp = snd_pcm_substream_chip(substream);
        char *channel_buf;
 
        snd_assert(pos + count <= HDSP_CHANNEL_BUFFER_BYTES / 4, return -EINVAL);
@@ -3727,10 +3679,10 @@ static int snd_hdsp_playback_copy(snd_pcm_substream_t *substream, int channel,
        return count;
 }
 
-static int snd_hdsp_capture_copy(snd_pcm_substream_t *substream, int channel,
+static int snd_hdsp_capture_copy(struct snd_pcm_substream *substream, int channel,
                                 snd_pcm_uframes_t pos, void __user *dst, snd_pcm_uframes_t count)
 {
-       hdsp_t *hdsp = snd_pcm_substream_chip(substream);
+       struct hdsp *hdsp = snd_pcm_substream_chip(substream);
        char *channel_buf;
 
        snd_assert(pos + count <= HDSP_CHANNEL_BUFFER_BYTES / 4, return -EINVAL);
@@ -3742,10 +3694,10 @@ static int snd_hdsp_capture_copy(snd_pcm_substream_t *substream, int channel,
        return count;
 }
 
-static int snd_hdsp_hw_silence(snd_pcm_substream_t *substream, int channel,
+static int snd_hdsp_hw_silence(struct snd_pcm_substream *substream, int channel,
                                  snd_pcm_uframes_t pos, snd_pcm_uframes_t count)
 {
-       hdsp_t *hdsp = snd_pcm_substream_chip(substream);
+       struct hdsp *hdsp = snd_pcm_substream_chip(substream);
        char *channel_buf;
 
        channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel);
@@ -3754,11 +3706,11 @@ static int snd_hdsp_hw_silence(snd_pcm_substream_t *substream, int channel,
        return count;
 }
 
-static int snd_hdsp_reset(snd_pcm_substream_t *substream)
+static int snd_hdsp_reset(struct snd_pcm_substream *substream)
 {
-       snd_pcm_runtime_t *runtime = substream->runtime;
-       hdsp_t *hdsp = snd_pcm_substream_chip(substream);
-       snd_pcm_substream_t *other;
+       struct snd_pcm_runtime *runtime = substream->runtime;
+       struct hdsp *hdsp = snd_pcm_substream_chip(substream);
+       struct snd_pcm_substream *other;
        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
                other = hdsp->capture_substream;
        else
@@ -3769,8 +3721,8 @@ static int snd_hdsp_reset(snd_pcm_substream_t *substream)
                runtime->status->hw_ptr = 0;
        if (other) {
                struct list_head *pos;
-               snd_pcm_substream_t *s;
-               snd_pcm_runtime_t *oruntime = other->runtime;
+               struct snd_pcm_substream *s;
+               struct snd_pcm_runtime *oruntime = other->runtime;
                snd_pcm_group_for_each(pos, substream) {
                        s = snd_pcm_group_substream_entry(pos);
                        if (s == other) {
@@ -3782,28 +3734,19 @@ static int snd_hdsp_reset(snd_pcm_substream_t *substream)
        return 0;
 }
 
-static int snd_hdsp_hw_params(snd_pcm_substream_t *substream,
-                                snd_pcm_hw_params_t *params)
+static int snd_hdsp_hw_params(struct snd_pcm_substream *substream,
+                                struct snd_pcm_hw_params *params)
 {
-       hdsp_t *hdsp = snd_pcm_substream_chip(substream);
+       struct hdsp *hdsp = snd_pcm_substream_chip(substream);
        int err;
        pid_t this_pid;
        pid_t other_pid;
 
-       if (hdsp_check_for_iobox (hdsp)) {
+       if (hdsp_check_for_iobox (hdsp))
                return -EIO;
-       }
 
-       if (hdsp_check_for_firmware(hdsp)) {
-               if (hdsp->state & HDSP_FirmwareCached) {
-                       if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) {
-                               snd_printk("Hammerfall-DSP: Firmware loading from cache failed, please upload manually.\n");
-                       }
-               } else {
-                       snd_printk("Hammerfall-DSP: No firmware loaded nor cached, please upload firmware.\n");
-               }
+       if (hdsp_check_for_firmware(hdsp, 1))
                return -EIO;
-       }
 
        spin_lock_irq(&hdsp->lock);
 
@@ -3849,13 +3792,14 @@ static int snd_hdsp_hw_params(snd_pcm_substream_t *substream,
         */
 
        spin_lock_irq(&hdsp->lock);
-       if ((err = hdsp_set_rate(hdsp, params_rate(params), 0)) < 0) {
-               spin_unlock_irq(&hdsp->lock);
-               _snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_RATE);
-               return err;
-       } else {
-               spin_unlock_irq(&hdsp->lock);
+       if (! hdsp->clock_source_locked) {
+               if ((err = hdsp_set_rate(hdsp, params_rate(params), 0)) < 0) {
+                       spin_unlock_irq(&hdsp->lock);
+                       _snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_RATE);
+                       return err;
+               }
        }
+       spin_unlock_irq(&hdsp->lock);
 
        if ((err = hdsp_set_interrupt_interval(hdsp, params_period_size(params))) < 0) {
                _snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE);
@@ -3865,17 +3809,16 @@ static int snd_hdsp_hw_params(snd_pcm_substream_t *substream,
        return 0;
 }
 
-static int snd_hdsp_channel_info(snd_pcm_substream_t *substream,
-                                   snd_pcm_channel_info_t *info)
+static int snd_hdsp_channel_info(struct snd_pcm_substream *substream,
+                                   struct snd_pcm_channel_info *info)
 {
-       hdsp_t *hdsp = snd_pcm_substream_chip(substream);
+       struct hdsp *hdsp = snd_pcm_substream_chip(substream);
        int mapped_channel;
 
        snd_assert(info->channel < hdsp->max_channels, return -EINVAL);
 
-       if ((mapped_channel = hdsp->channel_map[info->channel]) < 0) {
+       if ((mapped_channel = hdsp->channel_map[info->channel]) < 0)
                return -EINVAL;
-       }
 
        info->offset = mapped_channel * HDSP_CHANNEL_BUFFER_BYTES;
        info->first = 0;
@@ -3883,19 +3826,14 @@ static int snd_hdsp_channel_info(snd_pcm_substream_t *substream,
        return 0;
 }
 
-static int snd_hdsp_ioctl(snd_pcm_substream_t *substream,
+static int snd_hdsp_ioctl(struct snd_pcm_substream *substream,
                             unsigned int cmd, void *arg)
 {
        switch (cmd) {
        case SNDRV_PCM_IOCTL1_RESET:
-       {
                return snd_hdsp_reset(substream);
-       }
        case SNDRV_PCM_IOCTL1_CHANNEL_INFO:
-       {
-               snd_pcm_channel_info_t *info = arg;
-               return snd_hdsp_channel_info(substream, info);
-       }
+               return snd_hdsp_channel_info(substream, arg);
        default:
                break;
        }
@@ -3903,26 +3841,17 @@ static int snd_hdsp_ioctl(snd_pcm_substream_t *substream,
        return snd_pcm_lib_ioctl(substream, cmd, arg);
 }
 
-static int snd_hdsp_trigger(snd_pcm_substream_t *substream, int cmd)
+static int snd_hdsp_trigger(struct snd_pcm_substream *substream, int cmd)
 {
-       hdsp_t *hdsp = snd_pcm_substream_chip(substream);
-       snd_pcm_substream_t *other;
+       struct hdsp *hdsp = snd_pcm_substream_chip(substream);
+       struct snd_pcm_substream *other;
        int running;
        
-       if (hdsp_check_for_iobox (hdsp)) {
+       if (hdsp_check_for_iobox (hdsp))
                return -EIO;
-       }
 
-       if (hdsp_check_for_firmware(hdsp)) {
-               if (hdsp->state & HDSP_FirmwareCached) {
-                       if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) {
-                               snd_printk("Hammerfall-DSP: Firmware loading from cache failed, please upload manually.\n");
-                       }
-               } else {
-                       snd_printk("Hammerfall-DSP: No firmware loaded nor cached, please upload firmware.\n");
-               }
+       if (hdsp_check_for_firmware(hdsp, 1))
                return -EIO;
-       }
 
        spin_lock(&hdsp->lock);
        running = hdsp->running;
@@ -3945,7 +3874,7 @@ static int snd_hdsp_trigger(snd_pcm_substream_t *substream, int cmd)
 
        if (other) {
                struct list_head *pos;
-               snd_pcm_substream_t *s;
+               struct snd_pcm_substream *s;
                snd_pcm_group_for_each(pos, substream) {
                        s = snd_pcm_group_substream_entry(pos);
                        if (s == other) {
@@ -3982,25 +3911,16 @@ static int snd_hdsp_trigger(snd_pcm_substream_t *substream, int cmd)
        return 0;
 }
 
-static int snd_hdsp_prepare(snd_pcm_substream_t *substream)
+static int snd_hdsp_prepare(struct snd_pcm_substream *substream)
 {
-       hdsp_t *hdsp = snd_pcm_substream_chip(substream);
+       struct hdsp *hdsp = snd_pcm_substream_chip(substream);
        int result = 0;
 
-       if (hdsp_check_for_iobox (hdsp)) {
+       if (hdsp_check_for_iobox (hdsp))
                return -EIO;
-       }
 
-       if (hdsp_check_for_firmware(hdsp)) {
-               if (hdsp->state & HDSP_FirmwareCached) {
-                       if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) {
-                               snd_printk("Hammerfall-DSP: Firmware loading from cache failed, please upload manually.\n");
-                       }
-               } else {
-                       snd_printk("Hammerfall-DSP: No firmware loaded nor cached, please upload firmware.\n");
-               }
+       if (hdsp_check_for_firmware(hdsp, 1))
                return -EIO;
-       }
 
        spin_lock_irq(&hdsp->lock);
        if (!hdsp->running)
@@ -4009,7 +3929,7 @@ static int snd_hdsp_prepare(snd_pcm_substream_t *substream)
        return result;
 }
 
-static snd_pcm_hardware_t snd_hdsp_playback_subinfo =
+static struct snd_pcm_hardware snd_hdsp_playback_subinfo =
 {
        .info =                 (SNDRV_PCM_INFO_MMAP |
                                 SNDRV_PCM_INFO_MMAP_VALID |
@@ -4039,7 +3959,7 @@ static snd_pcm_hardware_t snd_hdsp_playback_subinfo =
        .fifo_size =            0
 };
 
-static snd_pcm_hardware_t snd_hdsp_capture_subinfo =
+static struct snd_pcm_hardware snd_hdsp_capture_subinfo =
 {
        .info =                 (SNDRV_PCM_INFO_MMAP |
                                 SNDRV_PCM_INFO_MMAP_VALID |
@@ -4070,7 +3990,7 @@ static snd_pcm_hardware_t snd_hdsp_capture_subinfo =
 
 static unsigned int hdsp_period_sizes[] = { 64, 128, 256, 512, 1024, 2048, 4096, 8192 };
 
-static snd_pcm_hw_constraint_list_t hdsp_hw_constraints_period_sizes = {
+static struct snd_pcm_hw_constraint_list hdsp_hw_constraints_period_sizes = {
        .count = ARRAY_SIZE(hdsp_period_sizes),
        .list = hdsp_period_sizes,
        .mask = 0
@@ -4078,17 +3998,17 @@ static snd_pcm_hw_constraint_list_t hdsp_hw_constraints_period_sizes = {
 
 static unsigned int hdsp_9632_sample_rates[] = { 32000, 44100, 48000, 64000, 88200, 96000, 128000, 176400, 192000 };
 
-static snd_pcm_hw_constraint_list_t hdsp_hw_constraints_9632_sample_rates = {
+static struct snd_pcm_hw_constraint_list hdsp_hw_constraints_9632_sample_rates = {
        .count = ARRAY_SIZE(hdsp_9632_sample_rates),
        .list = hdsp_9632_sample_rates,
        .mask = 0
 };
 
-static int snd_hdsp_hw_rule_in_channels(snd_pcm_hw_params_t *params,
-                                       snd_pcm_hw_rule_t *rule)
+static int snd_hdsp_hw_rule_in_channels(struct snd_pcm_hw_params *params,
+                                       struct snd_pcm_hw_rule *rule)
 {
-       hdsp_t *hdsp = rule->private;
-       snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
+       struct hdsp *hdsp = rule->private;
+       struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
        if (hdsp->io_type == H9632) {
                unsigned int list[3];
                list[0] = hdsp->qs_in_channels;
@@ -4103,12 +4023,12 @@ static int snd_hdsp_hw_rule_in_channels(snd_pcm_hw_params_t *params,
        }
 }
 
-static int snd_hdsp_hw_rule_out_channels(snd_pcm_hw_params_t *params,
-                                       snd_pcm_hw_rule_t *rule)
+static int snd_hdsp_hw_rule_out_channels(struct snd_pcm_hw_params *params,
+                                       struct snd_pcm_hw_rule *rule)
 {
        unsigned int list[3];
-       hdsp_t *hdsp = rule->private;
-       snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
+       struct hdsp *hdsp = rule->private;
+       struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
        if (hdsp->io_type == H9632) {
                list[0] = hdsp->qs_out_channels;
                list[1] = hdsp->ds_out_channels;
@@ -4121,28 +4041,28 @@ static int snd_hdsp_hw_rule_out_channels(snd_pcm_hw_params_t *params,
        return snd_interval_list(c, 2, list, 0);
 }
 
-static int snd_hdsp_hw_rule_in_channels_rate(snd_pcm_hw_params_t *params,
-                                            snd_pcm_hw_rule_t *rule)
+static int snd_hdsp_hw_rule_in_channels_rate(struct snd_pcm_hw_params *params,
+                                            struct snd_pcm_hw_rule *rule)
 {
-       hdsp_t *hdsp = rule->private;
-       snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
-       snd_interval_t *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
+       struct hdsp *hdsp = rule->private;
+       struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
+       struct snd_interval *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
        if (r->min > 96000 && hdsp->io_type == H9632) {
-               snd_interval_t t = {
+               struct snd_interval t = {
                        .min = hdsp->qs_in_channels,
                        .max = hdsp->qs_in_channels,
                        .integer = 1,
                };
                return snd_interval_refine(c, &t);      
        } else if (r->min > 48000 && r->max <= 96000) {
-               snd_interval_t t = {
+               struct snd_interval t = {
                        .min = hdsp->ds_in_channels,
                        .max = hdsp->ds_in_channels,
                        .integer = 1,
                };
                return snd_interval_refine(c, &t);
        } else if (r->max < 64000) {
-               snd_interval_t t = {
+               struct snd_interval t = {
                        .min = hdsp->ss_in_channels,
                        .max = hdsp->ss_in_channels,
                        .integer = 1,
@@ -4152,28 +4072,28 @@ static int snd_hdsp_hw_rule_in_channels_rate(snd_pcm_hw_params_t *params,
        return 0;
 }
 
-static int snd_hdsp_hw_rule_out_channels_rate(snd_pcm_hw_params_t *params,
-                                            snd_pcm_hw_rule_t *rule)
+static int snd_hdsp_hw_rule_out_channels_rate(struct snd_pcm_hw_params *params,
+                                            struct snd_pcm_hw_rule *rule)
 {
-       hdsp_t *hdsp = rule->private;
-       snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
-       snd_interval_t *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
+       struct hdsp *hdsp = rule->private;
+       struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
+       struct snd_interval *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
        if (r->min > 96000 && hdsp->io_type == H9632) {
-               snd_interval_t t = {
+               struct snd_interval t = {
                        .min = hdsp->qs_out_channels,
                        .max = hdsp->qs_out_channels,
                        .integer = 1,
                };
                return snd_interval_refine(c, &t);      
        } else if (r->min > 48000 && r->max <= 96000) {
-               snd_interval_t t = {
+               struct snd_interval t = {
                        .min = hdsp->ds_out_channels,
                        .max = hdsp->ds_out_channels,
                        .integer = 1,
                };
                return snd_interval_refine(c, &t);
        } else if (r->max < 64000) {
-               snd_interval_t t = {
+               struct snd_interval t = {
                        .min = hdsp->ss_out_channels,
                        .max = hdsp->ss_out_channels,
                        .integer = 1,
@@ -4183,28 +4103,28 @@ static int snd_hdsp_hw_rule_out_channels_rate(snd_pcm_hw_params_t *params,
        return 0;
 }
 
-static int snd_hdsp_hw_rule_rate_out_channels(snd_pcm_hw_params_t *params,
-                                            snd_pcm_hw_rule_t *rule)
+static int snd_hdsp_hw_rule_rate_out_channels(struct snd_pcm_hw_params *params,
+                                            struct snd_pcm_hw_rule *rule)
 {
-       hdsp_t *hdsp = rule->private;
-       snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
-       snd_interval_t *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
+       struct hdsp *hdsp = rule->private;
+       struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
+       struct snd_interval *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
        if (c->min >= hdsp->ss_out_channels) {
-               snd_interval_t t = {
+               struct snd_interval t = {
                        .min = 32000,
                        .max = 48000,
                        .integer = 1,
                };
                return snd_interval_refine(r, &t);
        } else if (c->max <= hdsp->qs_out_channels && hdsp->io_type == H9632) {
-               snd_interval_t t = {
+               struct snd_interval t = {
                        .min = 128000,
                        .max = 192000,
                        .integer = 1,
                };
                return snd_interval_refine(r, &t);
        } else if (c->max <= hdsp->ds_out_channels) {
-               snd_interval_t t = {
+               struct snd_interval t = {
                        .min = 64000,
                        .max = 96000,
                        .integer = 1,
@@ -4214,28 +4134,28 @@ static int snd_hdsp_hw_rule_rate_out_channels(snd_pcm_hw_params_t *params,
        return 0;
 }
 
-static int snd_hdsp_hw_rule_rate_in_channels(snd_pcm_hw_params_t *params,
-                                            snd_pcm_hw_rule_t *rule)
+static int snd_hdsp_hw_rule_rate_in_channels(struct snd_pcm_hw_params *params,
+                                            struct snd_pcm_hw_rule *rule)
 {
-       hdsp_t *hdsp = rule->private;
-       snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
-       snd_interval_t *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
+       struct hdsp *hdsp = rule->private;
+       struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
+       struct snd_interval *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
        if (c->min >= hdsp->ss_in_channels) {
-               snd_interval_t t = {
+               struct snd_interval t = {
                        .min = 32000,
                        .max = 48000,
                        .integer = 1,
                };
                return snd_interval_refine(r, &t);
        } else if (c->max <= hdsp->qs_in_channels && hdsp->io_type == H9632) {
-               snd_interval_t t = {
+               struct snd_interval t = {
                        .min = 128000,
                        .max = 192000,
                        .integer = 1,
                };
                return snd_interval_refine(r, &t);
        } else if (c->max <= hdsp->ds_in_channels) {
-               snd_interval_t t = {
+               struct snd_interval t = {
                        .min = 64000,
                        .max = 96000,
                        .integer = 1,
@@ -4245,25 +4165,16 @@ static int snd_hdsp_hw_rule_rate_in_channels(snd_pcm_hw_params_t *params,
        return 0;
 }
 
-static int snd_hdsp_playback_open(snd_pcm_substream_t *substream)
+static int snd_hdsp_playback_open(struct snd_pcm_substream *substream)
 {
-       hdsp_t *hdsp = snd_pcm_substream_chip(substream);
-       snd_pcm_runtime_t *runtime = substream->runtime;
+       struct hdsp *hdsp = snd_pcm_substream_chip(substream);
+       struct snd_pcm_runtime *runtime = substream->runtime;
 
-       if (hdsp_check_for_iobox (hdsp)) {
+       if (hdsp_check_for_iobox (hdsp))
                return -EIO;
-       }
 
-       if (hdsp_check_for_firmware(hdsp)) {
-               if (hdsp->state & HDSP_FirmwareCached) {
-                       if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) {
-                               snd_printk("Hammerfall-DSP: Firmware loading from cache failed, please upload manually.\n");
-                       }
-               } else {
-                       snd_printk("Hammerfall-DSP: No firmware loaded nor cached, please upload firmware.\n");
-               }
+       if (hdsp_check_for_firmware(hdsp, 1))
                return -EIO;
-       }
 
        spin_lock_irq(&hdsp->lock);
 
@@ -4280,13 +4191,17 @@ static int snd_hdsp_playback_open(snd_pcm_substream_t *substream)
 
        snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
        snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, &hdsp_hw_constraints_period_sizes);
-       if (hdsp->io_type == H9632) {
-               runtime->hw.channels_min = hdsp->qs_out_channels;
-               runtime->hw.channels_max = hdsp->ss_out_channels;
+       if (hdsp->clock_source_locked) {
+               runtime->hw.rate_min = runtime->hw.rate_max = hdsp->system_sample_rate;
+       } else if (hdsp->io_type == H9632) {
                runtime->hw.rate_max = 192000;
                runtime->hw.rates = SNDRV_PCM_RATE_KNOT;
                snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hdsp_hw_constraints_9632_sample_rates);
        }
+       if (hdsp->io_type == H9632) {
+               runtime->hw.channels_min = hdsp->qs_out_channels;
+               runtime->hw.channels_max = hdsp->ss_out_channels;
+       }       
        
        snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
                             snd_hdsp_hw_rule_out_channels, hdsp,
@@ -4305,9 +4220,9 @@ static int snd_hdsp_playback_open(snd_pcm_substream_t *substream)
        return 0;
 }
 
-static int snd_hdsp_playback_release(snd_pcm_substream_t *substream)
+static int snd_hdsp_playback_release(struct snd_pcm_substream *substream)
 {
-       hdsp_t *hdsp = snd_pcm_substream_chip(substream);
+       struct hdsp *hdsp = snd_pcm_substream_chip(substream);
 
        spin_lock_irq(&hdsp->lock);
 
@@ -4323,25 +4238,16 @@ static int snd_hdsp_playback_release(snd_pcm_substream_t *substream)
 }
 
 
-static int snd_hdsp_capture_open(snd_pcm_substream_t *substream)
+static int snd_hdsp_capture_open(struct snd_pcm_substream *substream)
 {
-       hdsp_t *hdsp = snd_pcm_substream_chip(substream);
-       snd_pcm_runtime_t *runtime = substream->runtime;
+       struct hdsp *hdsp = snd_pcm_substream_chip(substream);
+       struct snd_pcm_runtime *runtime = substream->runtime;
 
-       if (hdsp_check_for_iobox (hdsp)) {
+       if (hdsp_check_for_iobox (hdsp))
                return -EIO;
-       }
 
-       if (hdsp_check_for_firmware(hdsp)) {
-               if (hdsp->state & HDSP_FirmwareCached) {
-                       if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) {
-                               snd_printk("Hammerfall-DSP: Firmware loading from cache failed, please upload manually.\n");
-                       }
-               } else {
-                       snd_printk("Hammerfall-DSP: No firmware loaded nor cached, please upload firmware.\n");
-               }
+       if (hdsp_check_for_firmware(hdsp, 1))
                return -EIO;
-       }
 
        spin_lock_irq(&hdsp->lock);
 
@@ -4377,9 +4283,9 @@ static int snd_hdsp_capture_open(snd_pcm_substream_t *substream)
        return 0;
 }
 
-static int snd_hdsp_capture_release(snd_pcm_substream_t *substream)
+static int snd_hdsp_capture_release(struct snd_pcm_substream *substream)
 {
-       hdsp_t *hdsp = snd_pcm_substream_chip(substream);
+       struct hdsp *hdsp = snd_pcm_substream_chip(substream);
 
        spin_lock_irq(&hdsp->lock);
 
@@ -4390,7 +4296,7 @@ static int snd_hdsp_capture_release(snd_pcm_substream_t *substream)
        return 0;
 }
 
-static int snd_hdsp_hwdep_dummy_op(snd_hwdep_t *hw, struct file *file)
+static int snd_hdsp_hwdep_dummy_op(struct snd_hwdep *hw, struct file *file)
 {
        /* we have nothing to initialize but the call is required */
        return 0;
@@ -4424,7 +4330,7 @@ static inline int copy_u48_le(void __user *dest, void __iomem *src_low, void __i
        return copy_to_user(dest, &rms, 8);
 }
 
-static int hdsp_9652_get_peak(hdsp_t *hdsp, hdsp_peak_rms_t __user *peak_rms)
+static int hdsp_9652_get_peak(struct hdsp *hdsp, struct hdsp_peak_rms __user *peak_rms)
 {
        int doublespeed = 0;
        int i, j, channels, ofs;
@@ -4461,15 +4367,15 @@ static int hdsp_9652_get_peak(hdsp_t *hdsp, hdsp_peak_rms_t __user *peak_rms)
        return 0;
 }
 
-static int hdsp_9632_get_peak(hdsp_t *hdsp, hdsp_peak_rms_t __user *peak_rms)
+static int hdsp_9632_get_peak(struct hdsp *hdsp, struct hdsp_peak_rms __user *peak_rms)
 {
        int i, j;
-       hdsp_9632_meters_t __iomem *m;
+       struct hdsp_9632_meters __iomem *m;
        int doublespeed = 0;
 
        if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DoubleSpeedStatus)
                doublespeed = 1;
-       m = (hdsp_9632_meters_t __iomem *)(hdsp->iobase+HDSP_9632_metersBase);
+       m = (struct hdsp_9632_meters __iomem *)(hdsp->iobase+HDSP_9632_metersBase);
        for (i = 0, j = 0; i < 16; ++i, ++j) {
                if (copy_u32_le(&peak_rms->input_peaks[i], &m->input_peak[j]))
                        return -EFAULT;
@@ -4491,7 +4397,7 @@ static int hdsp_9632_get_peak(hdsp_t *hdsp, hdsp_peak_rms_t __user *peak_rms)
        return 0;
 }
 
-static int hdsp_get_peak(hdsp_t *hdsp, hdsp_peak_rms_t __user *peak_rms)
+static int hdsp_get_peak(struct hdsp *hdsp, struct hdsp_peak_rms __user *peak_rms)
 {
        int i;
 
@@ -4521,14 +4427,14 @@ static int hdsp_get_peak(hdsp_t *hdsp, hdsp_peak_rms_t __user *peak_rms)
        return 0;
 }
 
-static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int cmd, unsigned long arg)
+static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigned int cmd, unsigned long arg)
 {
-       hdsp_t *hdsp = (hdsp_t *)hw->private_data;      
+       struct hdsp *hdsp = (struct hdsp *)hw->private_data;    
        void __user *argp = (void __user *)arg;
 
        switch (cmd) {
        case SNDRV_HDSP_IOCTL_GET_PEAK_RMS: {
-               hdsp_peak_rms_t __user *peak_rms = (hdsp_peak_rms_t __user *)arg;
+               struct hdsp_peak_rms __user *peak_rms = (struct hdsp_peak_rms __user *)arg;
 
                if (!(hdsp->state & HDSP_FirmwareLoaded)) {
                        snd_printk(KERN_ERR "Hammerfall-DSP: firmware needs to be uploaded to the card.\n");
@@ -4545,24 +4451,22 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int
                }
        }
        case SNDRV_HDSP_IOCTL_GET_CONFIG_INFO: {
-               hdsp_config_info_t info;
+               struct hdsp_config_info info;
                unsigned long flags;
                int i;
                
                if (!(hdsp->state & HDSP_FirmwareLoaded)) {
-                       snd_printk("Hammerfall-DSP: Firmware needs to be uploaded to the card.\n");     
+                       snd_printk(KERN_ERR "Hammerfall-DSP: Firmware needs to be uploaded to the card.\n");    
                        return -EINVAL;
                }
                spin_lock_irqsave(&hdsp->lock, flags);
                info.pref_sync_ref = (unsigned char)hdsp_pref_sync_ref(hdsp);
                info.wordclock_sync_check = (unsigned char)hdsp_wc_sync_check(hdsp);
-               if (hdsp->io_type != H9632) {
+               if (hdsp->io_type != H9632)
                    info.adatsync_sync_check = (unsigned char)hdsp_adatsync_sync_check(hdsp);
-               }
                info.spdif_sync_check = (unsigned char)hdsp_spdif_sync_check(hdsp);
-               for (i = 0; i < ((hdsp->io_type != Multiface && hdsp->io_type != H9632) ? 3 : 1); ++i) {
+               for (i = 0; i < ((hdsp->io_type != Multiface && hdsp->io_type != H9632) ? 3 : 1); ++i)
                        info.adat_sync_check[i] = (unsigned char)hdsp_adat_sync_check(hdsp, i);
-               }
                info.spdif_in = (unsigned char)hdsp_spdif_in(hdsp);
                info.spdif_out = (unsigned char)hdsp_spdif_out(hdsp);
                info.spdif_professional = (unsigned char)hdsp_spdif_professional(hdsp);
@@ -4582,16 +4486,15 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int
                        info.xlr_breakout_cable = (unsigned char)hdsp_xlr_breakout_cable(hdsp);
                
                }
-               if (hdsp->io_type == H9632 || hdsp->io_type == H9652) {
+               if (hdsp->io_type == H9632 || hdsp->io_type == H9652)
                        info.analog_extension_board = (unsigned char)hdsp_aeb(hdsp);
-               }
                spin_unlock_irqrestore(&hdsp->lock, flags);
                if (copy_to_user(argp, &info, sizeof(info)))
                        return -EFAULT;
                break;
        }
        case SNDRV_HDSP_IOCTL_GET_9632_AEB: {
-               hdsp_9632_aeb_t h9632_aeb;
+               struct hdsp_9632_aeb h9632_aeb;
                
                if (hdsp->io_type != H9632) return -EINVAL;
                h9632_aeb.aebi = hdsp->ss_in_channels - H9632_SS_CHANNELS;
@@ -4601,24 +4504,22 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int
                break;
        }
        case SNDRV_HDSP_IOCTL_GET_VERSION: {
-               hdsp_version_t hdsp_version;
+               struct hdsp_version hdsp_version;
                int err;
                
                if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL;
                if (hdsp->io_type == Undefined) {
-                       if ((err = hdsp_get_iobox_version(hdsp)) < 0) {
+                       if ((err = hdsp_get_iobox_version(hdsp)) < 0)
                                return err;
-                       }
                }
                hdsp_version.io_type = hdsp->io_type;
                hdsp_version.firmware_rev = hdsp->firmware_rev;
-               if ((err = copy_to_user(argp, &hdsp_version, sizeof(hdsp_version)))) {
+               if ((err = copy_to_user(argp, &hdsp_version, sizeof(hdsp_version))))
                        return -EFAULT;
-               }
                break;
        }
        case SNDRV_HDSP_IOCTL_UPLOAD_FIRMWARE: {
-               hdsp_firmware_t __user *firmware;
+               struct hdsp_firmware __user *firmware;
                u32 __user *firmware_data;
                int err;
                
@@ -4629,44 +4530,39 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int
                if (hdsp->state & (HDSP_FirmwareCached | HDSP_FirmwareLoaded))
                        return -EBUSY;
 
-               snd_printk("Hammerfall-DSP: initializing firmware upload\n");
-               firmware = (hdsp_firmware_t __user *)argp;
+               snd_printk(KERN_INFO "Hammerfall-DSP: initializing firmware upload\n");
+               firmware = (struct hdsp_firmware __user *)argp;
 
-               if (get_user(firmware_data, &firmware->firmware_data)) {
+               if (get_user(firmware_data, &firmware->firmware_data))
                        return -EFAULT;
-               }
                
-               if (hdsp_check_for_iobox (hdsp)) {
+               if (hdsp_check_for_iobox (hdsp))
                        return -EIO;
-               }
 
-               if (copy_from_user(hdsp->firmware_cache, firmware_data, sizeof(hdsp->firmware_cache)) != 0) {
+               if (copy_from_user(hdsp->firmware_cache, firmware_data, sizeof(hdsp->firmware_cache)) != 0)
                        return -EFAULT;
-               }
                
                hdsp->state |= HDSP_FirmwareCached;
 
-               if ((err = snd_hdsp_load_firmware_from_cache(hdsp)) < 0) {
+               if ((err = snd_hdsp_load_firmware_from_cache(hdsp)) < 0)
                        return err;
-               }
                
                if (!(hdsp->state & HDSP_InitializationComplete)) {
-                       if ((err = snd_hdsp_enable_io(hdsp)) < 0) {
+                       if ((err = snd_hdsp_enable_io(hdsp)) < 0)
                                return err;
-                       }
                        
                        snd_hdsp_initialize_channels(hdsp);             
                        snd_hdsp_initialize_midi_flush(hdsp);
            
                        if ((err = snd_hdsp_create_alsa_devices(hdsp->card, hdsp)) < 0) {
-                               snd_printk("Hammerfall-DSP: error creating alsa devices\n");
-                           return err;
+                               snd_printk(KERN_ERR "Hammerfall-DSP: error creating alsa devices\n");
+                               return err;
                        }
                }
                break;
        }
        case SNDRV_HDSP_IOCTL_GET_MIXER: {
-               hdsp_mixer_t __user *mixer = (hdsp_mixer_t __user *)argp;
+               struct hdsp_mixer __user *mixer = (struct hdsp_mixer __user *)argp;
                if (copy_to_user(mixer->matrix, hdsp->mixer_matrix, sizeof(unsigned short)*HDSP_MATRIX_MIXER_SIZE))
                        return -EFAULT;
                break;
@@ -4677,7 +4573,7 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int
        return 0;
 }
 
-static snd_pcm_ops_t snd_hdsp_playback_ops = {
+static struct snd_pcm_ops snd_hdsp_playback_ops = {
        .open =         snd_hdsp_playback_open,
        .close =        snd_hdsp_playback_release,
        .ioctl =        snd_hdsp_ioctl,
@@ -4689,7 +4585,7 @@ static snd_pcm_ops_t snd_hdsp_playback_ops = {
        .silence =      snd_hdsp_hw_silence,
 };
 
-static snd_pcm_ops_t snd_hdsp_capture_ops = {
+static struct snd_pcm_ops snd_hdsp_capture_ops = {
        .open =         snd_hdsp_capture_open,
        .close =        snd_hdsp_capture_release,
        .ioctl =        snd_hdsp_ioctl,
@@ -4700,10 +4596,10 @@ static snd_pcm_ops_t snd_hdsp_capture_ops = {
        .copy =         snd_hdsp_capture_copy,
 };
 
-static int __devinit snd_hdsp_create_hwdep(snd_card_t *card,
-                                          hdsp_t *hdsp)
+static int __devinit snd_hdsp_create_hwdep(struct snd_card *card,
+                                          struct hdsp *hdsp)
 {
-       snd_hwdep_t *hw;
+       struct snd_hwdep *hw;
        int err;
        
        if ((err = snd_hwdep_new(card, "HDSP hwdep", 0, &hw)) < 0)
@@ -4720,9 +4616,9 @@ static int __devinit snd_hdsp_create_hwdep(snd_card_t *card,
        return 0;
 }
 
-static int snd_hdsp_create_pcm(snd_card_t *card, hdsp_t *hdsp)
+static int snd_hdsp_create_pcm(struct snd_card *card, struct hdsp *hdsp)
 {
-       snd_pcm_t *pcm;
+       struct snd_pcm *pcm;
        int err;
 
        if ((err = snd_pcm_new(card, hdsp->card_name, 0, 1, 1, &pcm)) < 0)
@@ -4740,18 +4636,18 @@ static int snd_hdsp_create_pcm(snd_card_t *card, hdsp_t *hdsp)
        return 0;
 }
 
-static void snd_hdsp_9652_enable_mixer (hdsp_t *hdsp)
+static void snd_hdsp_9652_enable_mixer (struct hdsp *hdsp)
 {
         hdsp->control2_register |= HDSP_9652_ENABLE_MIXER;
        hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register);
 }
 
-static int snd_hdsp_enable_io (hdsp_t *hdsp)
+static int snd_hdsp_enable_io (struct hdsp *hdsp)
 {
        int i;
        
        if (hdsp_fifo_wait (hdsp, 0, 100)) {
-               snd_printk("Hammerfall-DSP: enable_io fifo_wait failed\n");
+               snd_printk(KERN_ERR "Hammerfall-DSP: enable_io fifo_wait failed\n");
                return -EIO;
        }
        
@@ -4763,7 +4659,7 @@ static int snd_hdsp_enable_io (hdsp_t *hdsp)
        return 0;
 }
 
-static void snd_hdsp_initialize_channels(hdsp_t *hdsp)
+static void snd_hdsp_initialize_channels(struct hdsp *hdsp)
 {
        int status, aebi_channels, aebo_channels;
        
@@ -4806,36 +4702,36 @@ static void snd_hdsp_initialize_channels(hdsp_t *hdsp)
        }
 }
 
-static void snd_hdsp_initialize_midi_flush (hdsp_t *hdsp)
+static void snd_hdsp_initialize_midi_flush (struct hdsp *hdsp)
 {
        snd_hdsp_flush_midi_input (hdsp, 0);
        snd_hdsp_flush_midi_input (hdsp, 1);
 }
 
-static int snd_hdsp_create_alsa_devices(snd_card_t *card, hdsp_t *hdsp)
+static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdsp)
 {
        int err;
        
        if ((err = snd_hdsp_create_pcm(card, hdsp)) < 0) {
-               snd_printk("Hammerfall-DSP: Error creating pcm interface\n");
+               snd_printk(KERN_ERR "Hammerfall-DSP: Error creating pcm interface\n");
                return err;
        }
        
 
        if ((err = snd_hdsp_create_midi(card, hdsp, 0)) < 0) {
-               snd_printk("Hammerfall-DSP: Error creating first midi interface\n");
+               snd_printk(KERN_ERR "Hammerfall-DSP: Error creating first midi interface\n");
                return err;
        }
 
        if (hdsp->io_type == Digiface || hdsp->io_type == H9652) {
                if ((err = snd_hdsp_create_midi(card, hdsp, 1)) < 0) {
-                       snd_printk("Hammerfall-DSP: Error creating second midi interface\n");
+                       snd_printk(KERN_ERR "Hammerfall-DSP: Error creating second midi interface\n");
                        return err;
                }
        }
 
        if ((err = snd_hdsp_create_controls(card, hdsp)) < 0) {
-               snd_printk("Hammerfall-DSP: Error creating ctl interface\n");
+               snd_printk(KERN_ERR "Hammerfall-DSP: Error creating ctl interface\n");
                return err;
        }
 
@@ -4848,16 +4744,17 @@ static int snd_hdsp_create_alsa_devices(snd_card_t *card, hdsp_t *hdsp)
        hdsp->playback_substream = NULL;
 
        if ((err = snd_hdsp_set_defaults(hdsp)) < 0) {
-               snd_printk("Hammerfall-DSP: Error setting default values\n");
+               snd_printk(KERN_ERR "Hammerfall-DSP: Error setting default values\n");
                return err;
        }
        
        if (!(hdsp->state & HDSP_InitializationComplete)) {
+               strcpy(card->shortname, "Hammerfall DSP");
                sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name, 
                        hdsp->port, hdsp->irq);
            
                if ((err = snd_card_register(card)) < 0) {
-                       snd_printk("Hammerfall-DSP: error registering card\n");
+                       snd_printk(KERN_ERR "Hammerfall-DSP: error registering card\n");
                        return err;
                }
                hdsp->state |= HDSP_InitializationComplete;
@@ -4868,7 +4765,7 @@ static int snd_hdsp_create_alsa_devices(snd_card_t *card, hdsp_t *hdsp)
 
 #ifdef HDSP_FW_LOADER
 /* load firmware via hotplug fw loader */
-static int __devinit hdsp_request_fw_loader(hdsp_t *hdsp)
+static int __devinit hdsp_request_fw_loader(struct hdsp *hdsp)
 {
        const char *fwfile;
        const struct firmware *fw;
@@ -4912,19 +4809,9 @@ static int __devinit hdsp_request_fw_loader(hdsp_t *hdsp)
                release_firmware(fw);
                return -EINVAL;
        }
-#ifdef SNDRV_BIG_ENDIAN
-       {
-               int i;
-               u32 *src = (u32*)fw->data;
-               for (i = 0; i < ARRAY_SIZE(hdsp->firmware_cache); i++, src++)
-                       hdsp->firmware_cache[i] = ((*src & 0x000000ff) << 16) |
-                               ((*src & 0x0000ff00) << 8)  |
-                               ((*src & 0x00ff0000) >> 8)  |
-                               ((*src & 0xff000000) >> 16);
-       }
-#else
+
        memcpy(hdsp->firmware_cache, fw->data, sizeof(hdsp->firmware_cache));
-#endif
+
        release_firmware(fw);
                
        hdsp->state |= HDSP_FirmwareCached;
@@ -4933,18 +4820,17 @@ static int __devinit hdsp_request_fw_loader(hdsp_t *hdsp)
                return err;
                
        if (!(hdsp->state & HDSP_InitializationComplete)) {
-               if ((err = snd_hdsp_enable_io(hdsp)) < 0) {
+               if ((err = snd_hdsp_enable_io(hdsp)) < 0)
                        return err;
-               }
 
                if ((err = snd_hdsp_create_hwdep(hdsp->card, hdsp)) < 0) {
-                       snd_printk("Hammerfall-DSP: error creating hwdep device\n");
+                       snd_printk(KERN_ERR "Hammerfall-DSP: error creating hwdep device\n");
                        return err;
                }
                snd_hdsp_initialize_channels(hdsp);
                snd_hdsp_initialize_midi_flush(hdsp);
                if ((err = snd_hdsp_create_alsa_devices(hdsp->card, hdsp)) < 0) {
-                       snd_printk("Hammerfall-DSP: error creating alsa devices\n");
+                       snd_printk(KERN_ERR "Hammerfall-DSP: error creating alsa devices\n");
                        return err;
                }
        }
@@ -4952,8 +4838,8 @@ static int __devinit hdsp_request_fw_loader(hdsp_t *hdsp)
 }
 #endif
 
-static int __devinit snd_hdsp_create(snd_card_t *card,
-                                    hdsp_t *hdsp)
+static int __devinit snd_hdsp_create(struct snd_card *card,
+                                    struct hdsp *hdsp)
 {
        struct pci_dev *pci = hdsp->pci;
        int err;
@@ -4999,11 +4885,11 @@ static int __devinit snd_hdsp_create(snd_card_t *card,
        strcpy(card->driver, "H-DSP");
        strcpy(card->mixername, "Xilinx FPGA");
 
-       if (hdsp->firmware_rev < 0xa) {
+       if (hdsp->firmware_rev < 0xa)
                return -ENODEV;
-       } else if (hdsp->firmware_rev < 0x64) {
+       else if (hdsp->firmware_rev < 0x64)
                hdsp->card_name = "RME Hammerfall DSP";
-       else if (hdsp->firmware_rev < 0x96) {
+       else if (hdsp->firmware_rev < 0x96) {
                hdsp->card_name = "RME HDSP 9652";
                is_9652 = 1;
        } else {
@@ -5012,9 +4898,8 @@ static int __devinit snd_hdsp_create(snd_card_t *card,
                is_9632 = 1;    
        }
 
-       if ((err = pci_enable_device(pci)) < 0) {
+       if ((err = pci_enable_device(pci)) < 0)
                return err;
-       }
 
        pci_set_master(hdsp->pci);
 
@@ -5022,12 +4907,12 @@ static int __devinit snd_hdsp_create(snd_card_t *card,
                return err;
        hdsp->port = pci_resource_start(pci, 0);
        if ((hdsp->iobase = ioremap_nocache(hdsp->port, HDSP_IO_EXTENT)) == NULL) {
-               snd_printk("Hammerfall-DSP: unable to remap region 0x%lx-0x%lx\n", hdsp->port, hdsp->port + HDSP_IO_EXTENT - 1);
+               snd_printk(KERN_ERR "Hammerfall-DSP: unable to remap region 0x%lx-0x%lx\n", hdsp->port, hdsp->port + HDSP_IO_EXTENT - 1);
                return -EBUSY;
        }
 
        if (request_irq(pci->irq, snd_hdsp_interrupt, SA_INTERRUPT|SA_SHIRQ, "hdsp", (void *)hdsp)) {
-               snd_printk("Hammerfall-DSP: unable to use IRQ %d\n", pci->irq);
+               snd_printk(KERN_ERR "Hammerfall-DSP: unable to use IRQ %d\n", pci->irq);
                return -EBUSY;
        }
 
@@ -5035,77 +4920,63 @@ static int __devinit snd_hdsp_create(snd_card_t *card,
        hdsp->precise_ptr = 1;
        hdsp->use_midi_tasklet = 1;
 
-       if ((err = snd_hdsp_initialize_memory(hdsp)) < 0) {
+       if ((err = snd_hdsp_initialize_memory(hdsp)) < 0)
                return err;
-       }
        
        if (!is_9652 && !is_9632) {
                /* we wait 2 seconds to let freshly inserted cardbus cards do their hardware init */
-               if ((1000 / HZ) < 2000) {
-                       set_current_state(TASK_UNINTERRUPTIBLE);
-                       schedule_timeout((2000 * HZ + 999) / 1000);
-               } else {
-                       mdelay(2000);
-               }
+               ssleep(2);
 
                if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) {
 #ifdef HDSP_FW_LOADER
-                       if ((err = hdsp_request_fw_loader(hdsp)) < 0) {
+                       if ((err = hdsp_request_fw_loader(hdsp)) < 0)
                                /* we don't fail as this can happen
                                   if userspace is not ready for
                                   firmware upload
                                */
-                               snd_printk("Hammerfall-DSP: couldn't get firmware from userspace. try using hdsploader\n");
-                       } else {
+                               snd_printk(KERN_ERR "Hammerfall-DSP: couldn't get firmware from userspace. try using hdsploader\n");
+                       else
                                /* init is complete, we return */
                                return 0;
-                       }
 #endif
                        /* no iobox connected, we defer initialization */
-                       snd_printk("Hammerfall-DSP: card initialization pending : waiting for firmware\n");
-                       if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0) {
+                       snd_printk(KERN_INFO "Hammerfall-DSP: card initialization pending : waiting for firmware\n");
+                       if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0)
                                return err;
-                       }
                        return 0;
                } else {
-                       snd_printk("Hammerfall-DSP: Firmware already present, initializing card.\n");       
-                       if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1) {
+                       snd_printk(KERN_INFO "Hammerfall-DSP: Firmware already present, initializing card.\n");     
+                       if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1)
                                hdsp->io_type = Multiface;
-                       } else {
+                       else 
                                hdsp->io_type = Digiface;
-                       }
                }
        }
        
-       if ((err = snd_hdsp_enable_io(hdsp)) != 0) {
+       if ((err = snd_hdsp_enable_io(hdsp)) != 0)
                return err;
-       }
        
-       if (is_9652) {
+       if (is_9652)
                hdsp->io_type = H9652;
-       }
        
-       if (is_9632) {
+       if (is_9632)
                hdsp->io_type = H9632;
-       }
 
-       if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0) {
+       if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0)
                return err;
-       }
        
        snd_hdsp_initialize_channels(hdsp);
        snd_hdsp_initialize_midi_flush(hdsp);
 
        hdsp->state |= HDSP_FirmwareLoaded;     
 
-       if ((err = snd_hdsp_create_alsa_devices(card, hdsp)) < 0) {
+       if ((err = snd_hdsp_create_alsa_devices(card, hdsp)) < 0)
                return err;
-       }
 
        return 0;       
 }
 
-static int snd_hdsp_free(hdsp_t *hdsp)
+static int snd_hdsp_free(struct hdsp *hdsp)
 {
        if (hdsp->port) {
                /* stop the audio, and cancel all interrupts */
@@ -5129,9 +5000,9 @@ static int snd_hdsp_free(hdsp_t *hdsp)
        return 0;
 }
 
-static void snd_hdsp_card_free(snd_card_t *card)
+static void snd_hdsp_card_free(struct snd_card *card)
 {
-       hdsp_t *hdsp = (hdsp_t *) card->private_data;
+       struct hdsp *hdsp = (struct hdsp *) card->private_data;
 
        if (hdsp)
                snd_hdsp_free(hdsp);
@@ -5141,8 +5012,8 @@ static int __devinit snd_hdsp_probe(struct pci_dev *pci,
                                    const struct pci_device_id *pci_id)
 {
        static int dev;
-       hdsp_t *hdsp;
-       snd_card_t *card;
+       struct hdsp *hdsp;
+       struct snd_card *card;
        int err;
 
        if (dev >= SNDRV_CARDS)
@@ -5152,10 +5023,10 @@ static int __devinit snd_hdsp_probe(struct pci_dev *pci,
                return -ENOENT;
        }
 
-       if (!(card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(hdsp_t))))
+       if (!(card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct hdsp))))
                return -ENOMEM;
 
-       hdsp = (hdsp_t *) card->private_data;
+       hdsp = (struct hdsp *) card->private_data;
        card->private_free = snd_hdsp_card_free;
        hdsp->dev = dev;
        hdsp->pci = pci;
@@ -5194,7 +5065,7 @@ static struct pci_driver driver = {
 
 static int __init alsa_card_hdsp_init(void)
 {
-       return pci_module_init(&driver);
+       return pci_register_driver(&driver);
 }
 
 static void __exit alsa_card_hdsp_exit(void)