diff options
Diffstat (limited to 'sound/usb')
-rw-r--r-- | sound/usb/caiaq/Makefile | 4 | ||||
-rw-r--r-- | sound/usb/caiaq/audio.c (renamed from sound/usb/caiaq/caiaq-audio.c) | 24 | ||||
-rw-r--r-- | sound/usb/caiaq/audio.h (renamed from sound/usb/caiaq/caiaq-audio.h) | 0 | ||||
-rw-r--r-- | sound/usb/caiaq/control.c (renamed from sound/usb/caiaq/caiaq-control.c) | 10 | ||||
-rw-r--r-- | sound/usb/caiaq/control.h (renamed from sound/usb/caiaq/caiaq-control.h) | 0 | ||||
-rw-r--r-- | sound/usb/caiaq/device.c (renamed from sound/usb/caiaq/caiaq-device.c) | 25 | ||||
-rw-r--r-- | sound/usb/caiaq/device.h (renamed from sound/usb/caiaq/caiaq-device.h) | 0 | ||||
-rw-r--r-- | sound/usb/caiaq/input.c (renamed from sound/usb/caiaq/caiaq-input.c) | 11 | ||||
-rw-r--r-- | sound/usb/caiaq/input.h (renamed from sound/usb/caiaq/caiaq-input.h) | 0 | ||||
-rw-r--r-- | sound/usb/caiaq/midi.c (renamed from sound/usb/caiaq/caiaq-midi.c) | 13 | ||||
-rw-r--r-- | sound/usb/caiaq/midi.h (renamed from sound/usb/caiaq/caiaq-midi.h) | 0 | ||||
-rw-r--r-- | sound/usb/usx2y/us122l.c | 22 | ||||
-rw-r--r-- | sound/usb/usx2y/usX2Yhwdep.c | 13 | ||||
-rw-r--r-- | sound/usb/usx2y/usb_stream.c | 67 | ||||
-rw-r--r-- | sound/usb/usx2y/usbusx2yaudio.c | 3 |
15 files changed, 81 insertions, 111 deletions
diff --git a/sound/usb/caiaq/Makefile b/sound/usb/caiaq/Makefile index 23dadd5a11c..388999653aa 100644 --- a/sound/usb/caiaq/Makefile +++ b/sound/usb/caiaq/Makefile @@ -1,4 +1,4 @@ -snd-usb-caiaq-y := caiaq-device.o caiaq-audio.o caiaq-midi.o caiaq-control.o -snd-usb-caiaq-$(CONFIG_SND_USB_CAIAQ_INPUT) += caiaq-input.o +snd-usb-caiaq-y := device.o audio.o midi.o control.o +snd-usb-caiaq-$(CONFIG_SND_USB_CAIAQ_INPUT) += input.o obj-$(CONFIG_SND_USB_CAIAQ) += snd-usb-caiaq.o diff --git a/sound/usb/caiaq/caiaq-audio.c b/sound/usb/caiaq/audio.c index 08d51e0c9fe..b13ce767ac7 100644 --- a/sound/usb/caiaq/caiaq-audio.c +++ b/sound/usb/caiaq/audio.c @@ -16,20 +16,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include <linux/spinlock.h> #include <linux/init.h> -#include <linux/module.h> -#include <linux/moduleparam.h> -#include <linux/interrupt.h> #include <linux/usb.h> -#include <linux/spinlock.h> #include <sound/core.h> -#include <sound/initval.h> #include <sound/pcm.h> -#include <sound/rawmidi.h> -#include <linux/input.h> -#include "caiaq-device.h" -#include "caiaq-audio.h" +#include "device.h" +#include "audio.h" #define N_URBS 32 #define CLOCK_DRIFT_TOLERANCE 5 @@ -201,11 +195,14 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream) debug("%s(%p)\n", __func__, substream); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + dev->period_out_count[index] = BYTES_PER_SAMPLE + 1; dev->audio_out_buf_pos[index] = BYTES_PER_SAMPLE + 1; - else + } else { + dev->period_in_count[index] = BYTES_PER_SAMPLE; dev->audio_in_buf_pos[index] = BYTES_PER_SAMPLE; - + } + if (dev->streaming) return 0; @@ -306,8 +303,7 @@ static void check_for_elapsed_periods(struct snd_usb_caiaqdev *dev, if (!sub) continue; - pb = frames_to_bytes(sub->runtime, - sub->runtime->period_size); + pb = snd_pcm_lib_period_bytes(sub); cnt = (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) ? &dev->period_out_count[stream] : &dev->period_in_count[stream]; diff --git a/sound/usb/caiaq/caiaq-audio.h b/sound/usb/caiaq/audio.h index 8ab1f8d9529..8ab1f8d9529 100644 --- a/sound/usb/caiaq/caiaq-audio.h +++ b/sound/usb/caiaq/audio.h diff --git a/sound/usb/caiaq/caiaq-control.c b/sound/usb/caiaq/control.c index e92c2bbf4fe..537102ba6b9 100644 --- a/sound/usb/caiaq/caiaq-control.c +++ b/sound/usb/caiaq/control.c @@ -18,17 +18,13 @@ */ #include <linux/init.h> -#include <linux/interrupt.h> #include <linux/usb.h> +#include <sound/control.h> #include <sound/core.h> -#include <sound/initval.h> #include <sound/pcm.h> -#include <sound/rawmidi.h> -#include <sound/control.h> -#include <linux/input.h> -#include "caiaq-device.h" -#include "caiaq-control.h" +#include "device.h" +#include "control.h" #define CNT_INTVAL 0x10000 diff --git a/sound/usb/caiaq/caiaq-control.h b/sound/usb/caiaq/control.h index 2e7ab1aa4fb..2e7ab1aa4fb 100644 --- a/sound/usb/caiaq/caiaq-control.h +++ b/sound/usb/caiaq/control.h diff --git a/sound/usb/caiaq/caiaq-device.c b/sound/usb/caiaq/device.c index cf573a982fd..515de1cd2a3 100644 --- a/sound/usb/caiaq/caiaq-device.c +++ b/sound/usb/caiaq/device.c @@ -19,30 +19,23 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <linux/init.h> -#include <linux/module.h> #include <linux/moduleparam.h> #include <linux/interrupt.h> +#include <linux/module.h> +#include <linux/init.h> #include <linux/usb.h> -#include <linux/input.h> -#include <linux/spinlock.h> -#include <sound/core.h> #include <sound/initval.h> +#include <sound/core.h> #include <sound/pcm.h> -#include <sound/rawmidi.h> -#include <sound/control.h> - -#include "caiaq-device.h" -#include "caiaq-audio.h" -#include "caiaq-midi.h" -#include "caiaq-control.h" -#ifdef CONFIG_SND_USB_CAIAQ_INPUT -#include "caiaq-input.h" -#endif +#include "device.h" +#include "audio.h" +#include "midi.h" +#include "control.h" +#include "input.h" MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); -MODULE_DESCRIPTION("caiaq USB audio, version 1.3.13"); +MODULE_DESCRIPTION("caiaq USB audio, version 1.3.14"); MODULE_LICENSE("GPL"); MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2}," "{Native Instruments, RigKontrol3}," diff --git a/sound/usb/caiaq/caiaq-device.h b/sound/usb/caiaq/device.h index 4cce1ad7493..4cce1ad7493 100644 --- a/sound/usb/caiaq/caiaq-device.h +++ b/sound/usb/caiaq/device.h diff --git a/sound/usb/caiaq/caiaq-input.c b/sound/usb/caiaq/input.c index f743847a5e5..a48d309bd94 100644 --- a/sound/usb/caiaq/caiaq-input.c +++ b/sound/usb/caiaq/input.c @@ -17,17 +17,12 @@ */ #include <linux/init.h> -#include <linux/module.h> -#include <linux/moduleparam.h> -#include <linux/input.h> #include <linux/usb.h> #include <linux/usb/input.h> -#include <linux/spinlock.h> -#include <sound/core.h> -#include <sound/rawmidi.h> #include <sound/pcm.h> -#include "caiaq-device.h" -#include "caiaq-input.h" + +#include "device.h" +#include "input.h" static unsigned short keycode_ak1[] = { KEY_C, KEY_B, KEY_A }; static unsigned short keycode_rk2[] = { KEY_1, KEY_2, KEY_3, KEY_4, diff --git a/sound/usb/caiaq/caiaq-input.h b/sound/usb/caiaq/input.h index ced53557786..ced53557786 100644 --- a/sound/usb/caiaq/caiaq-input.h +++ b/sound/usb/caiaq/input.h diff --git a/sound/usb/caiaq/caiaq-midi.c b/sound/usb/caiaq/midi.c index f19fd360c93..8fa8cd88d76 100644 --- a/sound/usb/caiaq/caiaq-midi.c +++ b/sound/usb/caiaq/midi.c @@ -16,20 +16,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <linux/init.h> -#include <linux/module.h> -#include <linux/moduleparam.h> -#include <linux/interrupt.h> #include <linux/usb.h> -#include <linux/input.h> -#include <linux/spinlock.h> -#include <sound/core.h> #include <sound/rawmidi.h> +#include <sound/core.h> #include <sound/pcm.h> -#include "caiaq-device.h" -#include "caiaq-midi.h" - +#include "device.h" +#include "midi.h" static int snd_usb_caiaq_midi_input_open(struct snd_rawmidi_substream *substream) { diff --git a/sound/usb/caiaq/caiaq-midi.h b/sound/usb/caiaq/midi.h index 9d16db027fc..9d16db027fc 100644 --- a/sound/usb/caiaq/caiaq-midi.h +++ b/sound/usb/caiaq/midi.h diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c index 98276aafefe..a5aae9d67f3 100644 --- a/sound/usb/usx2y/us122l.c +++ b/sound/usb/usx2y/us122l.c @@ -349,14 +349,10 @@ static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, if (cmd != SNDRV_USB_STREAM_IOCTL_SET_PARAMS) return -ENOTTY; - cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); - if (!cfg) - return -ENOMEM; + cfg = memdup_user((void *)arg, sizeof(*cfg)); + if (IS_ERR(cfg)) + return PTR_ERR(cfg); - if (copy_from_user(cfg, (void *)arg, sizeof(*cfg))) { - err = -EFAULT; - goto free; - } if (cfg->version != USB_STREAM_INTERFACE_VERSION) { err = -ENXIO; goto free; @@ -478,6 +474,14 @@ static bool us122l_create_card(struct snd_card *card) return true; } +static void snd_us122l_free(struct snd_card *card) +{ + struct us122l *us122l = US122L(card); + int index = us122l->chip.index; + if (index >= 0 && index < SNDRV_CARDS) + snd_us122l_card_used[index] = 0; +} + static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp) { int dev; @@ -494,7 +498,7 @@ static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp) if (err < 0) return err; snd_us122l_card_used[US122L(card)->chip.index = dev] = 1; - + card->private_free = snd_us122l_free; US122L(card)->chip.dev = device; US122L(card)->chip.card = card; mutex_init(&US122L(card)->mutex); @@ -588,7 +592,7 @@ static void snd_us122l_disconnect(struct usb_interface *intf) } usb_put_intf(intf); - usb_put_dev(US122L(card)->chip.dev); + usb_put_dev(us122l->chip.dev); while (atomic_read(&us122l->mmap_count)) msleep(500); diff --git a/sound/usb/usx2y/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c index 4af8740db71..f3d8f71265d 100644 --- a/sound/usb/usx2y/usX2Yhwdep.c +++ b/sound/usb/usx2y/usX2Yhwdep.c @@ -203,13 +203,12 @@ static int snd_usX2Y_hwdep_dsp_load(struct snd_hwdep *hw, if (access_ok(VERIFY_READ, dsp->image, dsp->length)) { struct usb_device* dev = priv->chip.dev; - char *buf = kmalloc(dsp->length, GFP_KERNEL); - if (!buf) - return -ENOMEM; - if (copy_from_user(buf, dsp->image, dsp->length)) { - kfree(buf); - return -EFAULT; - } + char *buf; + + buf = memdup_user(dsp->image, dsp->length); + if (IS_ERR(buf)) + return PTR_ERR(buf); + err = usb_set_interface(dev, 0, 1); if (err) snd_printk(KERN_ERR "usb_set_interface error \n"); diff --git a/sound/usb/usx2y/usb_stream.c b/sound/usb/usx2y/usb_stream.c index 24393dafcb6..12ae0340adc 100644 --- a/sound/usb/usx2y/usb_stream.c +++ b/sound/usb/usx2y/usb_stream.c @@ -33,32 +33,26 @@ static unsigned usb_stream_next_packet_size(struct usb_stream_kernel *sk) static void playback_prep_freqn(struct usb_stream_kernel *sk, struct urb *urb) { struct usb_stream *s = sk->s; - unsigned l = 0; - int pack; - - urb->iso_frame_desc[0].offset = 0; - urb->iso_frame_desc[0].length = usb_stream_next_packet_size(sk); - sk->out_phase = sk->out_phase_peeked; - urb->transfer_buffer_length = urb->iso_frame_desc[0].length; - - for (pack = 1; pack < sk->n_o_ps; pack++) { - l = usb_stream_next_packet_size(sk); - if (s->idle_outsize + urb->transfer_buffer_length + l > - s->period_size) + int pack, lb = 0; + + for (pack = 0; pack < sk->n_o_ps; pack++) { + int l = usb_stream_next_packet_size(sk); + if (s->idle_outsize + lb + l > s->period_size) goto check; sk->out_phase = sk->out_phase_peeked; - urb->iso_frame_desc[pack].offset = urb->transfer_buffer_length; + urb->iso_frame_desc[pack].offset = lb; urb->iso_frame_desc[pack].length = l; - urb->transfer_buffer_length += l; + lb += l; } - snd_printdd(KERN_DEBUG "%i\n", urb->transfer_buffer_length); + snd_printdd(KERN_DEBUG "%i\n", lb); check: urb->number_of_packets = pack; - s->idle_outsize += urb->transfer_buffer_length - s->period_size; + urb->transfer_buffer_length = lb; + s->idle_outsize += lb - s->period_size; snd_printdd(KERN_DEBUG "idle=%i ul=%i ps=%i\n", s->idle_outsize, - urb->transfer_buffer_length, s->period_size); + lb, s->period_size); } static void init_pipe_urbs(struct usb_stream_kernel *sk, unsigned use_packsize, @@ -282,21 +276,20 @@ static int usb_stream_prepare_playback(struct usb_stream_kernel *sk, struct usb_stream *s = sk->s; struct urb *io; struct usb_iso_packet_descriptor *id, *od; - int p, l = 0; + int p = 0, lb = 0, l = 0; io = sk->idle_outurb; od = io->iso_frame_desc; - io->transfer_buffer_length = 0; - for (p = 0; s->sync_packet < 0; ++p, ++s->sync_packet) { + for (; s->sync_packet < 0; ++p, ++s->sync_packet) { struct urb *ii = sk->completed_inurb; id = ii->iso_frame_desc + ii->number_of_packets + s->sync_packet; l = id->actual_length; od[p].length = l; - od[p].offset = io->transfer_buffer_length; - io->transfer_buffer_length += l; + od[p].offset = lb; + lb += l; } for (; @@ -304,38 +297,38 @@ static int usb_stream_prepare_playback(struct usb_stream_kernel *sk, ++p, ++s->sync_packet) { l = inurb->iso_frame_desc[s->sync_packet].actual_length; - if (s->idle_outsize + io->transfer_buffer_length + l > - s->period_size) + if (s->idle_outsize + lb + l > s->period_size) goto check_ok; od[p].length = l; - od[p].offset = io->transfer_buffer_length; - io->transfer_buffer_length += l; + od[p].offset = lb; + lb += l; } check_ok: s->sync_packet -= inurb->number_of_packets; - if (s->sync_packet < -2 || s->sync_packet > 0) { + if (unlikely(s->sync_packet < -2 || s->sync_packet > 0)) { snd_printk(KERN_WARNING "invalid sync_packet = %i;" " p=%i nop=%i %i %x %x %x > %x\n", s->sync_packet, p, inurb->number_of_packets, - s->idle_outsize + io->transfer_buffer_length + l, - s->idle_outsize, io->transfer_buffer_length, l, + s->idle_outsize + lb + l, + s->idle_outsize, lb, l, s->period_size); return -1; } - if (io->transfer_buffer_length % s->cfg.frame_size) { + if (unlikely(lb % s->cfg.frame_size)) { snd_printk(KERN_WARNING"invalid outsize = %i\n", - io->transfer_buffer_length); + lb); return -1; } - s->idle_outsize += io->transfer_buffer_length - s->period_size; + s->idle_outsize += lb - s->period_size; io->number_of_packets = p; - if (s->idle_outsize > 0) { - snd_printk(KERN_WARNING "idle=%i\n", s->idle_outsize); - return -1; - } - return 0; + io->transfer_buffer_length = lb; + if (s->idle_outsize <= 0) + return 0; + + snd_printk(KERN_WARNING "idle=%i\n", s->idle_outsize); + return -1; } static void prepare_inurb(int number_of_packets, struct urb *iu) diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c index 9a608fa8515..dd1ab617784 100644 --- a/sound/usb/usx2y/usbusx2yaudio.c +++ b/sound/usb/usx2y/usbusx2yaudio.c @@ -870,7 +870,8 @@ static struct snd_pcm_hardware snd_usX2Y_2c = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | - SNDRV_PCM_INFO_MMAP_VALID), + SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_BATCH), .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_3LE, .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000, .rate_min = 44100, |