patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / sound / pci / rme9652 / hdsp.c
index f3224e6..c91602c 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/interrupt.h>
 #include <linux/slab.h>
 #include <linux/pci.h>
+#include <linux/moduleparam.h>
 
 #include <sound/core.h>
 #include <sound/control.h>
@@ -35,7 +36,6 @@
 #include <sound/asoundef.h>
 #include <sound/rawmidi.h>
 #include <sound/hwdep.h>
-#define SNDRV_GET_ID
 #include <sound/initval.h>
 #include <sound/hdsp.h>
 
@@ -48,20 +48,21 @@ static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;   /* ID for this card */
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;     /* Enable this card */
 static int precise_ptr[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = 0 }; /* Enable precise pointer */
 static int line_outs_monitor[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = 0}; /* Send all inputs/playback to line outs */
+static int boot_devs;
 
-MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
+module_param_array(index, int, boot_devs, 0444);
 MODULE_PARM_DESC(index, "Index value for RME Hammerfall DSP interface.");
 MODULE_PARM_SYNTAX(index, SNDRV_INDEX_DESC);
-MODULE_PARM(id, "1-" __MODULE_STRING(SNDRV_CARDS) "s");
+module_param_array(id, charp, boot_devs, 0444);
 MODULE_PARM_DESC(id, "ID string for RME Hammerfall DSP interface.");
 MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC);
-MODULE_PARM(enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
+module_param_array(enable, bool, boot_devs, 0444);
 MODULE_PARM_DESC(enable, "Enable/disable specific Hammerfall DSP soundcards.");
 MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC);
-MODULE_PARM(precise_ptr, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
+module_param_array(precise_ptr, bool, boot_devs, 0444);
 MODULE_PARM_DESC(precise_ptr, "Enable precise pointer (doesn't work reliably).");
 MODULE_PARM_SYNTAX(precise_ptr, SNDRV_ENABLED "," SNDRV_BOOLEAN_FALSE_DESC);
-MODULE_PARM(line_outs_monitor,"1-" __MODULE_STRING(SNDRV_CARDS) "i");
+module_param_array(line_outs_monitor, bool, boot_devs, 0444);
 MODULE_PARM_DESC(line_outs_monitor, "Send all input and playback streams to line outs by default.");
 MODULE_PARM_SYNTAX(line_outs_monitor, SNDRV_ENABLED "," SNDRV_BOOLEAN_FALSE_DESC);
 MODULE_AUTHOR("Paul Davis <paul@linuxaudiosystems.com>, Marcus Andersson, Thomas Charbonnel <thomas@undata.org>");
@@ -634,6 +635,7 @@ static inline int hdsp_playback_to_output_key (hdsp_t *hdsp, int in, int out)
        case 0xa:
                return (64 * out) + (32 + (in));
        case 0x96:
+       case 0x97:
                return (32 * out) + (16 + (in));
        default:
                return (52 * out) + (26 + (in));
@@ -646,6 +648,7 @@ static inline int hdsp_input_to_output_key (hdsp_t *hdsp, int in, int out)
        case 0xa:
                return (64 * out) + in;
        case 0x96:
+       case 0x97:
                return (32 * out) + in;
        default:
                return (52 * out) + in;
@@ -1247,9 +1250,9 @@ static inline void snd_hdsp_midi_write_byte (hdsp_t *hdsp, int id, int val)
 {
        /* the hardware already does the relevant bit-mask with 0xff */
        if (id) {
-               return hdsp_write(hdsp, HDSP_midiDataOut1, val);
+               hdsp_write(hdsp, HDSP_midiDataOut1, val);
        } else {
-               return hdsp_write(hdsp, HDSP_midiDataOut0, val);
+               hdsp_write(hdsp, HDSP_midiDataOut0, val);
        }
 }
 
@@ -3831,7 +3834,7 @@ static char *hdsp_channel_buffer_location(hdsp_t *hdsp,
 }
 
 static int snd_hdsp_playback_copy(snd_pcm_substream_t *substream, int channel,
-                                 snd_pcm_uframes_t pos, void *src, snd_pcm_uframes_t count)
+                                 snd_pcm_uframes_t pos, void __user *src, snd_pcm_uframes_t count)
 {
        hdsp_t *hdsp = _snd_pcm_substream_chip(substream);
        char *channel_buf;
@@ -3846,7 +3849,7 @@ static int snd_hdsp_playback_copy(snd_pcm_substream_t *substream, int channel,
 }
 
 static int snd_hdsp_capture_copy(snd_pcm_substream_t *substream, int channel,
-                                snd_pcm_uframes_t pos, void *dst, snd_pcm_uframes_t count)
+                                snd_pcm_uframes_t pos, void __user *dst, snd_pcm_uframes_t count)
 {
        hdsp_t *hdsp = _snd_pcm_substream_chip(substream);
        char *channel_buf;
@@ -4120,10 +4123,10 @@ static int snd_hdsp_prepare(snd_pcm_substream_t *substream)
                return -EIO;
        }
 
-       spin_lock_irq(&hdsp->lock);
+       spin_lock(&hdsp->lock);
        if (!hdsp->running)
                hdsp_reset_hw_pointer(hdsp);
-       spin_unlock_irq(&hdsp->lock);
+       spin_unlock(&hdsp->lock);
        return result;
 }
 
@@ -4528,10 +4531,11 @@ static int snd_hdsp_hwdep_dummy_op(snd_hwdep_t *hw, struct file *file)
 static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int cmd, unsigned long arg)
 {
        hdsp_t *hdsp = (hdsp_t *)hw->private_data;      
+       void __user *argp = (void __user *)arg;
 
        switch (cmd) {
        case SNDRV_HDSP_IOCTL_GET_PEAK_RMS: {
-               hdsp_peak_rms_t *peak_rms;
+               hdsp_peak_rms_t __user *peak_rms;
                int i;
                
                if (hdsp->io_type == H9652) {
@@ -4539,38 +4543,38 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int
                        int doublespeed = 0;
                        if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DoubleSpeedStatus)
                                doublespeed = 1;
-                       peak_rms = (hdsp_peak_rms_t *)arg;
+                       peak_rms = (hdsp_peak_rms_t __user *)arg;
                        for (i = 0; i < 26; ++i) {
                                if (!(doublespeed && (i & 4))) {
-                                       if (copy_to_user_fromio((void *)peak_rms->input_peaks+i*4, hdsp->iobase+HDSP_9652_peakBase-i*4, 4) != 0)
+                                       if (copy_to_user_fromio((void __user *)peak_rms->input_peaks+i*4, hdsp->iobase+HDSP_9652_peakBase-i*4, 4) != 0)
                                                return -EFAULT;
-                                       if (copy_to_user_fromio((void *)peak_rms->playback_peaks+i*4, hdsp->iobase+HDSP_9652_peakBase-(doublespeed ? 14 : 26)*4-i*4, 4) != 0)
+                                       if (copy_to_user_fromio((void __user *)peak_rms->playback_peaks+i*4, hdsp->iobase+HDSP_9652_peakBase-(doublespeed ? 14 : 26)*4-i*4, 4) != 0)
                                                return -EFAULT;
-                                       if (copy_to_user_fromio((void *)peak_rms->output_peaks+i*4, hdsp->iobase+HDSP_9652_peakBase-2*(doublespeed ? 14 : 26)*4-i*4, 4) != 0)
+                                       if (copy_to_user_fromio((void __user *)peak_rms->output_peaks+i*4, hdsp->iobase+HDSP_9652_peakBase-2*(doublespeed ? 14 : 26)*4-i*4, 4) != 0)
                                                return -EFAULT;
                                        rms_low = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+i*8) & 0xFFFFFF00;
                                        rms_high = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+i*8+4) & 0xFFFFFF00;
                                        rms_high += (rms_low >> 24);
                                        rms_low <<= 8;
-                                       if (copy_to_user((void *)peak_rms->input_rms+i*8, &rms_low, 4) != 0)
+                                       if (copy_to_user((void __user *)peak_rms->input_rms+i*8, &rms_low, 4) != 0)
                                                return -EFAULT;
-                                       if (copy_to_user((void *)peak_rms->input_rms+i*8+4, &rms_high, 4) != 0)
+                                       if (copy_to_user((void __user *)peak_rms->input_rms+i*8+4, &rms_high, 4) != 0)
                                                return -EFAULT;                                 
                                        rms_low = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+(doublespeed ? 14 : 26)*8+i*8) & 0xFFFFFF00;
                                        rms_high = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+(doublespeed ? 14 : 26)*8+i*8+4) & 0xFFFFFF00;
                                        rms_high += (rms_low >> 24);
                                        rms_low <<= 8;
-                                       if (copy_to_user((void *)peak_rms->playback_rms+i*8, &rms_low, 4) != 0)
+                                       if (copy_to_user((void __user *)peak_rms->playback_rms+i*8, &rms_low, 4) != 0)
                                                return -EFAULT;
-                                       if (copy_to_user((void *)peak_rms->playback_rms+i*8+4, &rms_high, 4) != 0)
+                                       if (copy_to_user((void __user *)peak_rms->playback_rms+i*8+4, &rms_high, 4) != 0)
                                                return -EFAULT;                                 
                                        rms_low = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+2*(doublespeed ? 14 : 26)*8+i*8) & 0xFFFFFF00;
                                        rms_high = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+2*(doublespeed ? 14 : 26)*8+i*8+4) & 0xFFFFFF00;
                                        rms_high += (rms_low >> 24);
                                        rms_low <<= 8;
-                                       if (copy_to_user((void *)peak_rms->output_rms+i*8, &rms_low, 4) != 0)
+                                       if (copy_to_user((void __user *)peak_rms->output_rms+i*8, &rms_low, 4) != 0)
                                                return -EFAULT;
-                                       if (copy_to_user((void *)peak_rms->output_rms+i*8+4, &rms_high, 4) != 0)
+                                       if (copy_to_user((void __user *)peak_rms->output_rms+i*8+4, &rms_high, 4) != 0)
                                                return -EFAULT;                                 
                                }
                        }
@@ -4583,25 +4587,25 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int
                        if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DoubleSpeedStatus)
                                doublespeed = 1;
                        m = (hdsp_9632_meters_t *)(hdsp->iobase+HDSP_9632_metersBase);
-                       peak_rms = (hdsp_peak_rms_t *)arg;
+                       peak_rms = (hdsp_peak_rms_t __user *)arg;
                        for (i = 0, j = 0; i < 16; ++i, ++j) {
-                               if (copy_to_user((void *)peak_rms->input_peaks+i*4, &(m->input_peak[j]), 4) != 0)
+                               if (copy_to_user((void __user *)peak_rms->input_peaks+i*4, &(m->input_peak[j]), 4) != 0)
                                        return -EFAULT;
-                               if (copy_to_user((void *)peak_rms->playback_peaks+i*4, &(m->playback_peak[j]), 4) != 0)
+                               if (copy_to_user((void __user *)peak_rms->playback_peaks+i*4, &(m->playback_peak[j]), 4) != 0)
                                        return -EFAULT;
-                               if (copy_to_user((void *)peak_rms->output_peaks+i*4, &(m->output_peak[j]), 4) != 0)
+                               if (copy_to_user((void __user *)peak_rms->output_peaks+i*4, &(m->output_peak[j]), 4) != 0)
                                        return -EFAULT;
-                               if (copy_to_user((void *)peak_rms->input_rms+i*8, &(m->input_rms_low[j]), 4) != 0)
+                               if (copy_to_user((void __user *)peak_rms->input_rms+i*8, &(m->input_rms_low[j]), 4) != 0)
                                        return -EFAULT;
-                               if (copy_to_user((void *)peak_rms->playback_rms+i*8, &(m->playback_rms_low[j]), 4) != 0)
+                               if (copy_to_user((void __user *)peak_rms->playback_rms+i*8, &(m->playback_rms_low[j]), 4) != 0)
                                        return -EFAULT;
-                               if (copy_to_user((void *)peak_rms->output_rms+i*8, &(m->output_rms_low[j]), 4) != 0)
+                               if (copy_to_user((void __user *)peak_rms->output_rms+i*8, &(m->output_rms_low[j]), 4) != 0)
                                        return -EFAULT;
-                               if (copy_to_user((void *)peak_rms->input_rms+i*8+4, &(m->input_rms_high[j]), 4) != 0)
+                               if (copy_to_user((void __user *)peak_rms->input_rms+i*8+4, &(m->input_rms_high[j]), 4) != 0)
                                        return -EFAULT;
-                               if (copy_to_user((void *)peak_rms->playback_rms+i*8+4, &(m->playback_rms_high[j]), 4) != 0)
+                               if (copy_to_user((void __user *)peak_rms->playback_rms+i*8+4, &(m->playback_rms_high[j]), 4) != 0)
                                        return -EFAULT;
-                               if (copy_to_user((void *)peak_rms->output_rms+i*8+4, &(m->output_rms_high[j]), 4) != 0)
+                               if (copy_to_user((void __user *)peak_rms->output_rms+i*8+4, &(m->output_rms_high[j]), 4) != 0)
                                        return -EFAULT;
                                if (doublespeed && i == 3) i += 4;
                        }
@@ -4611,25 +4615,25 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int
                        snd_printk("firmware needs to be uploaded to the card.\n");     
                        return -EINVAL;
                }
-               peak_rms = (hdsp_peak_rms_t *)arg;
+               peak_rms = (hdsp_peak_rms_t __user *)arg;
                for (i = 0; i < 26; ++i) {
-                   if (copy_to_user((void *)peak_rms->playback_peaks+i*4, (void *)hdsp->iobase+HDSP_playbackPeakLevel+i*4, 4) != 0)
+                   if (copy_to_user((void __user *)peak_rms->playback_peaks+i*4, (void *)hdsp->iobase+HDSP_playbackPeakLevel+i*4, 4) != 0)
                            return -EFAULT;
-                   if (copy_to_user((void *)peak_rms->input_peaks+i*4, (void *)hdsp->iobase+HDSP_inputPeakLevel+i*4, 4) != 0)
+                   if (copy_to_user((void __user *)peak_rms->input_peaks+i*4, (void *)hdsp->iobase+HDSP_inputPeakLevel+i*4, 4) != 0)
                            return -EFAULT;
                }
                for (i = 0; i < 26; ++i) {
-                       if (copy_to_user((void *)peak_rms->playback_rms+i*8+4, (void *)hdsp->iobase+HDSP_playbackRmsLevel+i*8, 4) != 0)
+                       if (copy_to_user((void __user *)peak_rms->playback_rms+i*8+4, (void *)hdsp->iobase+HDSP_playbackRmsLevel+i*8, 4) != 0)
                                return -EFAULT;
-                       if (copy_to_user((void *)peak_rms->playback_rms+i*8, (void *)hdsp->iobase+HDSP_playbackRmsLevel+i*8+4, 4) != 0)
+                       if (copy_to_user((void __user *)peak_rms->playback_rms+i*8, (void *)hdsp->iobase+HDSP_playbackRmsLevel+i*8+4, 4) != 0)
                                return -EFAULT;
-                       if (copy_to_user((void *)peak_rms->input_rms+i*8+4, (void *)hdsp->iobase+HDSP_inputRmsLevel+i*8, 4) != 0)
+                       if (copy_to_user((void __user *)peak_rms->input_rms+i*8+4, (void *)hdsp->iobase+HDSP_inputRmsLevel+i*8, 4) != 0)
                                return -EFAULT;
-                       if (copy_to_user((void *)peak_rms->input_rms+i*8, (void *)hdsp->iobase+HDSP_inputRmsLevel+i*8+4, 4) != 0)
+                       if (copy_to_user((void __user *)peak_rms->input_rms+i*8, (void *)hdsp->iobase+HDSP_inputRmsLevel+i*8+4, 4) != 0)
                                return -EFAULT;
                }
                for (i = 0; i < 28; ++i) {
-                   if (copy_to_user((void *)peak_rms->output_peaks+i*4, (void *)hdsp->iobase+HDSP_outputPeakLevel+i*4, 4) != 0)
+                   if (copy_to_user((void __user *)peak_rms->output_peaks+i*4, (void *)hdsp->iobase+HDSP_outputPeakLevel+i*4, 4) != 0)
                            return -EFAULT;
                }
                break;
@@ -4677,7 +4681,7 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int
                        info.analog_extension_board = (unsigned char)hdsp_aeb(hdsp);
                }
                spin_unlock_irqrestore(&hdsp->lock, flags);
-               if (copy_to_user((void *)arg, &info, sizeof(info)))
+               if (copy_to_user(argp, &info, sizeof(info)))
                        return -EFAULT;
                break;
        }
@@ -4687,7 +4691,7 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int
                if (hdsp->io_type != H9632) return -EINVAL;
                h9632_aeb.aebi = hdsp->ss_in_channels - H9632_SS_CHANNELS;
                h9632_aeb.aebo = hdsp->ss_out_channels - H9632_SS_CHANNELS;
-               if (copy_to_user((void *)arg, &h9632_aeb, sizeof(h9632_aeb)))
+               if (copy_to_user(argp, &h9632_aeb, sizeof(h9632_aeb)))
                        return -EFAULT;
                break;
        }
@@ -4703,14 +4707,14 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int
                }
                hdsp_version.io_type = hdsp->io_type;
                hdsp_version.firmware_rev = hdsp->firmware_rev;
-               if ((err = copy_to_user((void *)arg, &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 *firmware;
-               unsigned long *firmware_data;
+               hdsp_firmware_t __user *firmware;
+               unsigned long __user *firmware_data;
                int err;
                
                if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL;
@@ -4718,7 +4722,7 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int
                if (hdsp->io_type == Undefined) return -EINVAL;
 
                snd_printk("initializing firmware upload\n");
-               firmware = (hdsp_firmware_t *)arg;
+               firmware = (hdsp_firmware_t __user *)argp;
 
                if (get_user(firmware_data, &firmware->firmware_data)) {
                        return -EFAULT;
@@ -4751,9 +4755,7 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int
                break;
        }
        case SNDRV_HDSP_IOCTL_GET_MIXER: {
-               hdsp_mixer_t *mixer;
-               
-               mixer = (hdsp_mixer_t *)arg;
+               hdsp_mixer_t __user *mixer = (hdsp_mixer_t __user *)argp;
                if (copy_to_user(mixer->matrix, hdsp->mixer_matrix, sizeof(unsigned short)*HDSP_MATRIX_MIXER_SIZE))
                        return -EFAULT;
                break;
@@ -5018,6 +5020,7 @@ static int __devinit snd_hdsp_create(snd_card_t *card,
                is_9652 = 1;
                break;
        case 0x96:
+       case 0x97:
                hdsp->card_name = "RME HDSP 9632";
                hdsp->max_channels = 16;
                is_9632 = 1;
@@ -5198,14 +5201,7 @@ static struct pci_driver driver = {
 
 static int __init alsa_card_hdsp_init(void)
 {
-       if (pci_module_init(&driver) < 0) {
-#ifdef MODULE
-               printk(KERN_ERR "RME Hammerfall-DSP: no cards found\n");
-#endif
-               return -ENODEV;
-       }
-
-       return 0;
+       return pci_module_init(&driver);
 }
 
 static void __exit alsa_card_hdsp_exit(void)
@@ -5215,24 +5211,3 @@ static void __exit alsa_card_hdsp_exit(void)
 
 module_init(alsa_card_hdsp_init)
 module_exit(alsa_card_hdsp_exit)
-
-#ifndef MODULE
-
-/* format is: snd-hdsp=enable,index,id */
-
-static int __init alsa_card_hdsp_setup(char *str)
-{
-       static unsigned __initdata nr_dev = 0;
-
-       if (nr_dev >= SNDRV_CARDS)
-               return 0;
-       (void)(get_option(&str,&enable[nr_dev]) == 2 &&
-              get_option(&str,&index[nr_dev]) == 2 &&
-              get_id(&str,&id[nr_dev]) == 2);
-       nr_dev++;
-       return 1;
-}
-
-__setup("snd-hdsp=", alsa_card_hdsp_setup);
-
-#endif /* ifndef MODULE */