From c1fabdadbfba0dea16ed0e922374368b7c923782 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 26 Sep 2003 01:45:50 +0200 Subject: [PATCH] ALSA CVS update D:2003/09/25 19:55:42 C:RME HDSP driver,Sound Scape driver,ALSA Version A:Jaroslav Kysela F:include/hdsp.h:1.2->1.3 F:include/sscape_ioctl.h:1.1->1.2 F:include/version.h:1.23->1.24 F:isa/sscape.c:1.4->1.5 F:pci/rme9652/hdsp.c:1.43->1.44 L:- fixed firmware ioctls for sscape and hdsp drivers (ioctl out of range) L:- updated ALSA version to 0.9.7 --- include/sound/hdsp.h | 5 ++-- include/sound/sscape_ioctl.h | 6 ++--- include/sound/version.h | 6 ++--- sound/isa/sscape.c | 44 ++++++++++++++++-------------------- sound/pci/rme9652/hdsp.c | 43 +++++++++++++++++++++++------------ 5 files changed, 56 insertions(+), 48 deletions(-) diff --git a/include/sound/hdsp.h b/include/sound/hdsp.h index 84d73d20cc831..414e433991391 100644 --- a/include/sound/hdsp.h +++ b/include/sound/hdsp.h @@ -68,11 +68,10 @@ struct _snd_hdsp_config_info { typedef struct _snd_hdsp_firmware hdsp_firmware_t; struct _snd_hdsp_firmware { - unsigned long firmware_data[24413]; + unsigned long *firmware_data; /* 24413 long words */ }; -/* This ioctl is marked bad because the type is bigger than the IOCTL description */ -#define SNDRV_HDSP_IOCTL_UPLOAD_FIRMWARE _IOW_BAD('H', 0x42, hdsp_firmware_t) +#define SNDRV_HDSP_IOCTL_UPLOAD_FIRMWARE _IOW('H', 0x42, hdsp_firmware_t) typedef struct _snd_hdsp_version hdsp_version_t; diff --git a/include/sound/sscape_ioctl.h b/include/sound/sscape_ioctl.h index aadc930a6ba47..9bc2def190c7f 100644 --- a/include/sound/sscape_ioctl.h +++ b/include/sound/sscape_ioctl.h @@ -10,12 +10,10 @@ struct sscape_bootblock struct sscape_microcode { - unsigned char code[65536]; + unsigned char *code; /* 65536 chars */ }; #define SND_SSCAPE_LOAD_BOOTB _IOWR('P', 100, struct sscape_bootblock) - -/* This ioctl is marked bad because the type is bigger than the IOCTL description */ -#define SND_SSCAPE_LOAD_MCODE _IOW_BAD('P', 101, struct sscape_microcode) +#define SND_SSCAPE_LOAD_MCODE _IOW ('P', 101, struct sscape_microcode) #endif diff --git a/include/sound/version.h b/include/sound/version.h index 51f4968670a90..149ec0ebea13b 100644 --- a/include/sound/version.h +++ b/include/sound/version.h @@ -1,3 +1,3 @@ -/* include/version.h. Generated by configure. */ -#define CONFIG_SND_VERSION "0.9.6" -#define CONFIG_SND_DATE " (Wed Aug 20 20:27:13 2003 UTC)" +/* include/version.h. Generated automatically by configure. */ +#define CONFIG_SND_VERSION "0.9.7" +#define CONFIG_SND_DATE " (Thu Sep 25 19:16:36 2003 UTC)" diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c index 02d92cdf49f1e..b56036ec6e2f5 100644 --- a/sound/isa/sscape.c +++ b/sound/isa/sscape.c @@ -5,10 +5,6 @@ * This driver was written in part using information obtained from * the OSS/Free SoundScape driver, written by Hannu Savolainen. * - * FIXME (deadlock for alsa-kernel): - * - use ISA PnP scheme used by all ALSA ISA drivers - * - add non-MODULE build option - * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -455,14 +451,14 @@ static int host_startup_ack(struct soundscape *s, unsigned timeout) * Upload a byte-stream into the SoundScape using DMA channel A. */ static int upload_dma_data(struct soundscape *s, - const unsigned char *data, size_t size, - size_t dmasize) + const unsigned char *data, + size_t size) { unsigned long flags; struct dmabuf dma; int ret; - if (!get_dmabuf(&dma, dmasize)) + if (!get_dmabuf(&dma, PAGE_ALIGN(size))) return -ENOMEM; spin_lock_irqsave(&s->lock, flags); @@ -575,7 +571,7 @@ static int sscape_upload_bootblock(struct soundscape *sscape, struct sscape_boot int data = 0; int ret; - ret = upload_dma_data(sscape, bb->code, sizeof(bb->code), PAGE_SIZE); + ret = upload_dma_data(sscape, bb->code, sizeof(bb->code)); spin_lock_irqsave(&sscape->lock, flags); if (ret == 0) { @@ -602,17 +598,28 @@ static int sscape_upload_bootblock(struct soundscape *sscape, struct sscape_boot * it into a local variable then we will SMASH THE * KERNEL'S STACK! We therefore leave it in USER * SPACE, and save ourselves from copying it at all. - * - * We assume that the caller has already verified the - * userspace memory addresses. */ static int sscape_upload_microcode(struct soundscape *sscape, const struct sscape_microcode *mc) { unsigned long flags; - int ret; + char *code; + int err, ret; + + /* + * We are going to have to copy this data into a special + * DMA-able buffer before we can upload it. We shall therefore + * just check that the data pointer is valid for now. + * + * NOTE: This buffer is 64K long! That's WAY too big to + * copy into a stack-temporary anyway. + */ + if (get_user(code, &mc->code)) + return -EFAULT; + if ((err = verify_area(VERIFY_READ, code, 65536)) != 0) + return err; - if ((ret = upload_dma_data(sscape, mc->code, sizeof(mc->code), PAGE_SIZE * 16)) == 0) { + if ((ret = upload_dma_data(sscape, code, 65536)) == 0) { snd_printk(KERN_INFO "sscape: MIDI firmware loaded\n"); } @@ -696,17 +703,6 @@ static int sscape_hw_ioctl(snd_hwdep_t * hw, struct file *file, { register const struct sscape_microcode *mc = (const struct sscape_microcode *) arg; - /* - * We are going to have to copy this data into a special - * DMA-able buffer before we can upload it. We shall therefore - * just check that the data pointer is valid for now. - * - * NOTE: This buffer is 64K long! That's WAY too big to - * copy into a stack-temporary anyway. - */ - if ((err = verify_area(VERIFY_READ, mc->code, sizeof(mc->code))) != 0) - return err; - err = sscape_upload_microcode(sscape, mc); } break; diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index 6af726e1a56ca..1b6cfb696da45 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c @@ -3788,17 +3788,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; - hdsp_peak_rms_t *peak_rms; - hdsp_firmware_t *firmware; - hdsp_mixer_t *mixer; - hdsp_config_info_t info; - hdsp_version_t hdsp_version; - int i; - int err; - unsigned long flags; switch (cmd) { - case SNDRV_HDSP_IOCTL_GET_PEAK_RMS: + case SNDRV_HDSP_IOCTL_GET_PEAK_RMS: { + hdsp_peak_rms_t *peak_rms; + if (hdsp->io_type == H9652) { snd_printk("hardware metering isn't supported yet for hdsp9652 cards\n"); return -EINVAL; @@ -3824,7 +3818,12 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int return -EFAULT; } break; - case SNDRV_HDSP_IOCTL_GET_CONFIG_INFO: + } + case SNDRV_HDSP_IOCTL_GET_CONFIG_INFO: { + hdsp_config_info_t info; + unsigned long flags; + int i; + if (!(hdsp->state & HDSP_FirmwareLoaded)) { snd_printk("Firmware needs to be uploaded to the card.\n"); return -EINVAL; @@ -3854,7 +3853,11 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int if (copy_to_user((void *)arg, &info, sizeof(info))) return -EFAULT; break; - case SNDRV_HDSP_IOCTL_GET_VERSION: + } + case SNDRV_HDSP_IOCTL_GET_VERSION: { + hdsp_version_t hdsp_version; + int err; + if (hdsp->io_type == H9652) return -EINVAL; if (hdsp->io_type == Undefined) { if ((err = hdsp_get_iobox_version(hdsp)) < 0) { @@ -3867,19 +3870,27 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int return -EFAULT; } break; - case SNDRV_HDSP_IOCTL_UPLOAD_FIRMWARE: + } + case SNDRV_HDSP_IOCTL_UPLOAD_FIRMWARE: { + hdsp_firmware_t *firmware; + unsigned long *firmware_data; + int err; + if (hdsp->io_type == H9652) return -EINVAL; /* SNDRV_HDSP_IOCTL_GET_VERSION must have been called */ if (hdsp->io_type == Undefined) return -EINVAL; snd_printk("initializing firmware upload\n"); firmware = (hdsp_firmware_t *)arg; + if (get_user(firmware_data, &firmware->firmware_data)) { + return -EFAULT; + } if (hdsp_check_for_iobox (hdsp)) { return -EIO; } - if (copy_from_user(hdsp->firmware_cache, firmware->firmware_data, sizeof(unsigned long)*24413) != 0) { + if (copy_from_user(hdsp->firmware_cache, firmware_data, sizeof(unsigned long)*24413) != 0) { return -EFAULT; } @@ -3901,11 +3912,15 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int } } break; - case SNDRV_HDSP_IOCTL_GET_MIXER: + } + case SNDRV_HDSP_IOCTL_GET_MIXER: { + hdsp_mixer_t *mixer; + mixer = (hdsp_mixer_t *)arg; if (copy_to_user(mixer->matrix, hdsp->mixer_matrix, sizeof(unsigned short)*HDSP_MATRIX_MIXER_SIZE)) return -EFAULT; break; + } default: return -EINVAL; } -- 2.53.0