More line6 driver code reorg and cleanups
cover More line6 driver code reorg and cleanups
Hi,
here is a series of patches I hacked quickly after merging line6 stuff into sound git tree. There are two significant changes:
- Split to each driver and renames: now there are 4 card modules, snd-usb-pod, snd-usb-podhd, snd-usb-toneport and snd-usb-variax, while snd-usb-line6 serves as a common helper module.
- Many codes restrucruring, especially cleanup of the resource management; the destructor is solely called from card's private_free now
The current merged code is found in topic/line6 branch of sound.git tree while this development code is found in test/line6 branch. The devel branch hasn't been merged to linux-next yet, I'm waiting for any good/bad test results. So, give me any feedback. Thanks!
(BTW, the next step would be to straighten the init code in pod.c,
etc instead of (ab)using the system timer. Instead, it should be a flat function with wait_event() of such.)
Takashi
PATCH 1/17 ALSA: line6: Split to each driver
Split to each individual driver for POD, PODHD, TonePort and Variax with a core LINE6 helper module. The new modules follow the standard ALSA naming rule with snd prefix: snd-usb-pod, snd-usb-podhd, snd-usb-toneport and snd-usb-variax, together with the corresponding CONFIG_SND_USB_* Kconfig items.
--- sound/usb/Makefile | 2 +- sound/usb/line6/Kconfig | 36 ++-- sound/usb/line6/Makefile | 21 ++- sound/usb/line6/audio.c | 3 + sound/usb/line6/capture.c | 1 - sound/usb/line6/driver.c | 452 ++++----------------------------------------- sound/usb/line6/driver.h | 39 ++-- sound/usb/line6/midi.c | 3 +- sound/usb/line6/pcm.c | 6 +- sound/usb/line6/playback.c | 1 - sound/usb/line6/pod.c | 224 +++++++++++++++++++++- sound/usb/line6/pod.h | 92 --------- sound/usb/line6/podhd.c | 124 ++++++++++++- sound/usb/line6/podhd.h | 29 --- sound/usb/line6/toneport.c | 188 ++++++++++++++++++- sound/usb/line6/toneport.h | 51 ----- sound/usb/line6/variax.c | 133 ++++++++++++- sound/usb/line6/variax.h | 70 ------- 18 files changed, 748 insertions(+), 727 deletions(-) delete mode 100644 sound/usb/line6/pod.h delete mode 100644 sound/usb/line6/podhd.h delete mode 100644 sound/usb/line6/toneport.h delete mode 100644 sound/usb/line6/variax.h
sound/usb/Makefile +1 -1
@@ -25,4 +25,4 @@ obj-$(CONFIG_SND_USB_USX2Y) += snd-usbmidi-lib.o obj-$(CONFIG_SND_USB_US122L) += snd-usbmidi-lib.o obj-$(CONFIG_SND) += misc/ usx2y/ caiaq/ 6fire/ hiface/ bcd2000/ -obj-$(CONFIG_LINE6_USB) += line6/ +obj-$(CONFIG_SND_USB_LINE6) += line6/
sound/usb/line6/Kconfig +25 -11
@@ -1,12 +1,14 @@ -menuconfig LINE6_USB - tristate "Line6 USB support" - depends on USB && SND +config SND_USB_LINE6 + tristate select SND_RAWMIDI select SND_PCM + +config SND_USB_POD + tristate "Line6 POD USB support" + select SND_USB_LINE6 help - This is a driver for the guitar amp, cab, and effects modeller - PODxt Pro by Line6 (and similar devices), supporting the - following features: + This is a driver for PODxt and other similar devices, + supporting the following features: * Reading/writing individual parameters * Reading/writing complete channel, effects setup, and amp setup data
@@ -18,14 +20,27 @@ menuconfig LINE6_USB * Signal routing (record clean/processed guitar signal, re-amping) - Preliminary support for the Variax Workbench and TonePort - devices is included. +config SND_USB_PODHD + tristate "Line6 POD HD300/400/500 USB support" + select SND_USB_LINE6 + help + This is a driver for POD HD300, 400 and 500 devices. -if LINE6_USB +config SND_USB_TONEPORT + tristate "TonePort GX, UX1 and UX2 USB support" + select SND_USB_LINE6 + help + This is a driver for TonePort GX, UX1 and UX2 devices. + +config SND_USB_VARIAX + tristate "Variax Workbench USB support" + select SND_USB_LINE6 + help + This is a driver for Variax Workbench device. config LINE6_USB_IMPULSE_RESPONSE bool "measure impulse response" - default n + depends on SND_USB_LINE6 help Say Y here to add code to measure the impulse response of a Line6 device. This is more accurate than user-space methods since it
@@ -35,4 +50,3 @@ config LINE6_USB_IMPULSE_RESPONSE If unsure, say N. -endif # LINE6_USB
sound/usb/line6/Makefile +13 -8
@@ -1,14 +1,19 @@ -obj-$(CONFIG_LINE6_USB) += line6usb.o - -line6usb-y := \ +snd-usb-line6-y := \ audio.o \ capture.o \ driver.o \ midi.o \ midibuf.o \ pcm.o \ - playback.o \ - pod.o \ - toneport.o \ - variax.o \ - podhd.o + playback.o + +snd-usb-pod-y := pod.o +snd-usb-podhd-y := podhd.o +snd-usb-toneport-y := toneport.o +snd-usb-variax-y := variax.o + +obj-$(CONFIG_SND_USB_LINE6) += snd-usb-line6.o +obj-$(CONFIG_SND_USB_POD) += snd-usb-pod.o +obj-$(CONFIG_SND_USB_PODHD) += snd-usb-podhd.o +obj-$(CONFIG_SND_USB_TONEPORT) += snd-usb-toneport.o +obj-$(CONFIG_SND_USB_VARIAX) += snd-usb-variax.o
sound/usb/line6/audio.c +3 -0
@@ -40,6 +40,7 @@ int line6_init_audio(struct usb_line6 *line6) dev_name(line6->ifcdev));return 0 ; } +EXPORT_SYMBOL_GPL (line6_init_audio);/* Register the Line6 USB audio system.
@@ -54,6 +55,7 @@ int line6_register_audio(struct usb_line6 *line6)return 0 ; } +EXPORT_SYMBOL_GPL (line6_register_audio);/* Cleanup the Line6 USB audio system.
@@ -69,3 +71,4 @@ void line6_cleanup_audio(struct usb_line6 *line6)snd_card_free (card); line6->card =NULL ; } +EXPORT_SYMBOL_GPL (line6_cleanup_audio);
sound/usb/line6/capture.c +0 -1
@@ -18,7 +18,6 @@#include "capture.h" #include "driver.h" #include "pcm.h" -#include "pod.h" /* Find a free URB and submit it.
sound/usb/line6/driver.c +34 -418
622 lines not on this page · raw message
sound/usb/line6/driver.h +11 -28
@@ -20,29 +20,6 @@#define DRIVER_NAME "line6usb" -enum line6_device_type { -LINE6_BASSPODXT , -LINE6_BASSPODXTLIVE , -LINE6_BASSPODXTPRO , -LINE6_GUITARPORT , -LINE6_POCKETPOD , -LINE6_PODHD300 , -LINE6_PODHD400 , -LINE6_PODHD500_0 , -LINE6_PODHD500_1 , -LINE6_PODSTUDIO_GX , -LINE6_PODSTUDIO_UX1 , -LINE6_PODSTUDIO_UX2 , -LINE6_PODXT , -LINE6_PODXTLIVE_POD , -LINE6_PODXTLIVE_VARIAX , -LINE6_PODXTPRO , -LINE6_TONEPORT_GX , -LINE6_TONEPORT_UX1 , -LINE6_TONEPORT_UX2 , -LINE6_VARIAX -}; -#define LINE6_TIMEOUT 1#define LINE6_BUFSIZE_LISTEN 32#define LINE6_MESSAGE_MAXLEN 256
@@ -135,11 +112,6 @@ struct usb_line6 {struct usb_device *usbdev;/** -Device type. -*/ -enum line6_device_type type; - -/** Properties. */ const struct line6_properties *properties;
@@ -225,4 +197,15 @@ extern int line6_version_request_async(struct usb_line6 *line6);extern int line6_write_data (struct usb_line6 *line6,int address,void *data,size_t datalen); +int line6_probe (struct usb_interface *interface, +struct usb_line6 *line6, +const struct line6_properties *properties, +int (*private_init)(struct usb_interface *,struct usb_line6 *)); +void line6_disconnect (struct usb_interface *interface); + +#ifdef CONFIG_PM +int line6_suspend (struct usb_interface *interface,pm_message_t message); +int line6_resume (struct usb_interface *interface); +#endif +#endif
sound/usb/line6/midi.c +2 -1
@@ -11,13 +11,13 @@#include <linux/slab.h> #include <linux/usb.h> +#include <linux/export.h> #include <sound/core.h> #include <sound/rawmidi.h> #include "audio.h" #include "driver.h" #include "midi.h" -#include "pod.h" #include "usbdefs.h" #define line6_rawmidi_substream_midi (substream) \
@@ -319,3 +319,4 @@ int line6_init_midi(struct usb_line6 *line6)spin_lock_init (&line6midi->midi_transmit_lock);return 0 ; } +EXPORT_SYMBOL_GPL (line6_init_midi);
sound/usb/line6/pcm.c +5 -1
@@ -10,6 +10,7 @@*/ #include <linux/slab.h> +#include <linux/export.h> #include <sound/core.h> #include <sound/control.h> #include <sound/pcm.h>
@@ -19,7 +20,6 @@#include "capture.h" #include "driver.h" #include "playback.h" -#include "pod.h" #ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE
@@ -195,6 +195,7 @@ pcm_acquire_error:line6_pcm_release (line6pcm, flags_final & channels);return err; } +EXPORT_SYMBOL_GPL (line6_pcm_acquire);int line6_pcm_release (struct snd_line6_pcm *line6pcm,int channels) {
@@ -223,6 +224,7 @@ int line6_pcm_release(struct snd_line6_pcm *line6pcm, int channels)return 0 ; } +EXPORT_SYMBOL_GPL (line6_pcm_release);/* trigger callback */ int snd_line6_trigger (struct snd_pcm_substream *substream,int cmd)
@@ -408,6 +410,7 @@ void line6_pcm_disconnect(struct snd_line6_pcm *line6pcm)line6_unlink_wait_clear_audio_out_urbs (line6pcm);line6_unlink_wait_clear_audio_in_urbs (line6pcm); } +EXPORT_SYMBOL_GPL (line6_pcm_disconnect);/* Create and register the PCM device and mixer entries.
@@ -490,6 +493,7 @@ int line6_init_pcm(struct usb_line6 *line6,return 0 ; } +EXPORT_SYMBOL_GPL (line6_init_pcm);/* prepare pcm callback */ int snd_line6_prepare (struct snd_pcm_substream *substream)
sound/usb/line6/playback.c +0 -1
@@ -18,7 +18,6 @@#include "capture.h" #include "driver.h" #include "pcm.h" -#include "pod.h" #include "playback.h" /*
sound/usb/line6/pod.c +222 -2
245 lines not on this page · raw message
sound/usb/line6/pod.h deleted +0 -92
92 lines not on this page · raw message
sound/usb/line6/podhd.c +122 -2
148 lines not on this page · raw message
sound/usb/line6/podhd.h deleted +0 -29
@@ -1,29 +0,0 @@ -/* -* Line6 Pod HD -* -* Copyright (C) 2011 Stefan Hajnoczi <[email protected]> -* -* 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 the Free Software Foundation, version 2. -* -*/ - -#ifndef PODHD_H -#define PODHD_H - -#include <linux/usb.h> - -#include "driver.h" - -struct usb_line6_podhd { -/** -Generic Line6 USB data. -*/ -struct usb_line6 line6; -}; - -extern int line6_podhd_init (struct usb_interface *interface, -struct usb_line6 *line6); - -#endif /* PODHD_H */
sound/usb/line6/toneport.c +179 -9
238 lines not on this page · raw message
sound/usb/line6/toneport.h deleted +0 -51
51 lines not on this page · raw message
sound/usb/line6/variax.c +131 -2
151 lines not on this page · raw message
sound/usb/line6/variax.h deleted +0 -70
70 lines not on this page · raw message
Signature · 1 line
2.2.1
Re: [PATCH 01/17] ALSA: line6: Split to each driver
Quoted 18 lines · Takashi Iwai
sound/usb/line6/driver.c +5
-8-static int line6_probe (struct usb_interface *interface, -const struct usb_device_id *id) +int line6_probe (struct usb_interface *interface, +struct usb_line6 *line6, +const struct line6_properties *properties, +int (*private_init)(struct usb_interface *,struct usb_line6 *)) { -enum line6_device_type devtype;struct usb_device *usbdev; -struct usb_line6 *line6; -const struct line6_properties *properties;int interface_number; -int size =0 ;int ret; -if (interface ==NULL ) -return -ENODEV ; +if (!interface) {
sound/usb/line6/driver.c static void line6_destruct(struct usb_interface *interface) · line 530
Quoted 10 lines
sound/usb/line6/driver.c +7
-2+ ret = -ENODEV ; + goto err_put; + } usbdev =interface_to_usbdev (interface); -if (usbdev ==NULL ) -return -ENODEV ; +if (!usbdev) { + ret = -ENODEV ; + goto err_put; + }
These NULL checks are unnecessary, right? We could just assign `usbdev' at declaration and be done with it. But maybe that should be another patch.
Chris
Re: [PATCH 01/17] ALSA: line6: Split to each driver
At Mon, 19 Jan 2015 12:00:01 -0600,
Quoted 26 lines · Chris Rorvick
Quoted 24 lines · Takashi Iwai
sound/usb/line6/driver.c +8
-10-static int line6_probe (struct usb_interface *interface, -const struct usb_device_id *id) +int line6_probe (struct usb_interface *interface, +struct usb_line6 *line6, +const struct line6_properties *properties, +int (*private_init)(struct usb_interface *,struct usb_line6 *)) { -enum line6_device_type devtype;struct usb_device *usbdev; -struct usb_line6 *line6; -const struct line6_properties *properties;int interface_number; -int size =0 ;int ret; -if (interface ==NULL ) -return -ENODEV ; +if (!interface) { + ret = -ENODEV ; + goto err_put; + } usbdev =interface_to_usbdev (interface); -if (usbdev ==NULL ) -return -ENODEV ;
Quoted 8 lines
sound/usb/line6/driver.c static void line6_destruct(struct usb_interface *interface) · line 530
Quoted 4 lines
sound/usb/line6/driver.c +4
-0+if (!usbdev) { + ret = -ENODEV ; + goto err_put; + }These NULL checks are unnecessary, right? We could just assign `usbdev' at declaration and be done with it. But maybe that should be another patch.
Right, the cleanup can be done later, as this patch is merely a transition.
Takashi
Re: [PATCH 01/17] ALSA: line6: Split to each driver
Sounds good. I like the approach. I was futzing around with how to do this, though I didn't spend too much time on it because I was antici- pating more patches from you that would be difficult to merge. Using the private_init callback is a nice idea and makes a necessarily large change pretty easy to understand.
Chris
Quoted 42 lines · Takashi Iwai
At Mon, 19 Jan 2015 12:00:01 -0600,
Quoted 26 lines · Chris Rorvick
Quoted 24 lines · Takashi Iwai
sound/usb/line6/driver.c +8
-10-static int line6_probe (struct usb_interface *interface, -const struct usb_device_id *id) +int line6_probe (struct usb_interface *interface, +struct usb_line6 *line6, +const struct line6_properties *properties, +int (*private_init)(struct usb_interface *,struct usb_line6 *)) { -enum line6_device_type devtype;struct usb_device *usbdev; -struct usb_line6 *line6; -const struct line6_properties *properties;int interface_number; -int size =0 ;int ret; -if (interface ==NULL ) -return -ENODEV ; +if (!interface) { + ret = -ENODEV ; + goto err_put; + } usbdev =interface_to_usbdev (interface); -if (usbdev ==NULL ) -return -ENODEV ;Quoted 8 lines
sound/usb/line6/driver.c static void line6_destruct(struct usb_interface *interface) · line 530
Quoted 4 lines
sound/usb/line6/driver.c +4
-0+if (!usbdev) { + ret = -ENODEV ; + goto err_put; + }These NULL checks are unnecessary, right? We could just assign `usbdev' at declaration and be done with it. But maybe that should be another patch.
Right, the cleanup can be done later, as this patch is merely a transition.
Takashi
PATCH 2/17 ALSA: line6: Handle impulse response via control API
In reply to Takashi IwaiInstead of sysfs and the conditional build with Kconfig, implement the handling of the impulse response controls via control API, and always enable the build. Two new controls, "Impulse Response Volume" and "Impulse Response Period" are added as a replacement for the former sysfs files.
--- sound/usb/line6/Kconfig | 12 ---- sound/usb/line6/capture.c | 4 -- sound/usb/line6/pcm.c | 157 ++++++++++++++++++++++----------------------- sound/usb/line6/pcm.h | 18 ------ sound/usb/line6/playback.c | 8 --- 5 files changed, 75 insertions(+), 124 deletions(-)
sound/usb/line6/Kconfig +0 -12
@@ -38,15 +38,3 @@ config SND_USB_VARIAX help This is a driver for Variax Workbench device. -config LINE6_USB_IMPULSE_RESPONSE - bool "measure impulse response" - depends on SND_USB_LINE6 - help - Say Y here to add code to measure the impulse response of a Line6 - device. This is more accurate than user-space methods since it - bypasses any PCM data buffering (e.g., by ALSA or jack). This is - useful for assessing the performance of new devices, but is not - required for normal operation. - - If unsure, say N. -
sound/usb/line6/capture.c +0 -4
@@ -244,9 +244,7 @@ static void audio_in_callback(struct urb *urb) line6pcm->prev_fbuf = fbuf; line6pcm->prev_fsize = fsize; -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE if (!(line6pcm->flags &LINE6_BITS_PCM_IMPULSE )) -#endif if (test_bit (LINE6_INDEX_PCM_ALSA_CAPTURE_STREAM , &line6pcm->flags) && (fsize >0 ))line6_capture_copy (line6pcm, fbuf, fsize);
@@ -262,9 +260,7 @@ static void audio_in_callback(struct urb *urb)if (!shutdown) {submit_audio_in_urb (line6pcm); -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE if (!(line6pcm->flags &LINE6_BITS_PCM_IMPULSE )) -#endif if (test_bit (LINE6_INDEX_PCM_ALSA_CAPTURE_STREAM , &line6pcm->flags))line6_capture_check_period (line6pcm, length);
sound/usb/line6/pcm.c +75 -82
217 lines not on this page · raw message
sound/usb/line6/pcm.h +0 -18
@@ -35,9 +35,7 @@/* in a "full speed" device (such as the PODxt Pro) this means 1ms */ #define LINE6_ISO_INTERVAL 1 -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE #define LINE6_IMPULSE_DEFAULT_PERIOD 100 -#endif /* Get substream from Line6 PCM data structure
@@ -89,12 +87,10 @@ enum {LINE6_INDEX_PCM_MONITOR_PLAYBACK_STREAM ,LINE6_INDEX_PCM_MONITOR_CAPTURE_BUFFER ,LINE6_INDEX_PCM_MONITOR_CAPTURE_STREAM , -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSELINE6_INDEX_PCM_IMPULSE_PLAYBACK_BUFFER ,LINE6_INDEX_PCM_IMPULSE_PLAYBACK_STREAM ,LINE6_INDEX_PCM_IMPULSE_CAPTURE_BUFFER ,LINE6_INDEX_PCM_IMPULSE_CAPTURE_STREAM , -#endifLINE6_INDEX_PAUSE_PLAYBACK , LINE6_INDEX_PREPARED,
@@ -109,12 +105,10 @@ enum {LINE6_BIT (PCM_MONITOR_PLAYBACK_STREAM ),LINE6_BIT (PCM_MONITOR_CAPTURE_BUFFER ),LINE6_BIT (PCM_MONITOR_CAPTURE_STREAM ), -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSELINE6_BIT (PCM_IMPULSE_PLAYBACK_BUFFER ),LINE6_BIT (PCM_IMPULSE_PLAYBACK_STREAM ),LINE6_BIT (PCM_IMPULSE_CAPTURE_BUFFER ),LINE6_BIT (PCM_IMPULSE_CAPTURE_STREAM ), -#endifLINE6_BIT (PAUSE_PLAYBACK ), LINE6_BIT(PREPARED),
@@ -133,40 +127,30 @@ enum {LINE6_BIT_PCM_MONITOR_CAPTURE_BUFFER |LINE6_BIT_PCM_MONITOR_CAPTURE_STREAM , -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE LINE6_BITS_PCM_IMPULSE =LINE6_BIT_PCM_IMPULSE_PLAYBACK_BUFFER |LINE6_BIT_PCM_IMPULSE_PLAYBACK_STREAM |LINE6_BIT_PCM_IMPULSE_CAPTURE_BUFFER |LINE6_BIT_PCM_IMPULSE_CAPTURE_STREAM , -#endif/* combined bit masks (by direction): */ LINE6_BITS_PLAYBACK_BUFFER = -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSELINE6_BIT_PCM_IMPULSE_PLAYBACK_BUFFER | -#endifLINE6_BIT_PCM_ALSA_PLAYBACK_BUFFER |LINE6_BIT_PCM_MONITOR_PLAYBACK_BUFFER ,LINE6_BITS_PLAYBACK_STREAM = -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSELINE6_BIT_PCM_IMPULSE_PLAYBACK_STREAM | -#endifLINE6_BIT_PCM_ALSA_PLAYBACK_STREAM |LINE6_BIT_PCM_MONITOR_PLAYBACK_STREAM ,LINE6_BITS_CAPTURE_BUFFER = -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSELINE6_BIT_PCM_IMPULSE_CAPTURE_BUFFER | -#endifLINE6_BIT_PCM_ALSA_CAPTURE_BUFFER |LINE6_BIT_PCM_MONITOR_CAPTURE_BUFFER ,LINE6_BITS_CAPTURE_STREAM = -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSELINE6_BIT_PCM_IMPULSE_CAPTURE_STREAM | -#endifLINE6_BIT_PCM_ALSA_CAPTURE_STREAM | LINE6_BIT_PCM_MONITOR_CAPTURE_STREAM,
@@ -338,7 +322,6 @@ struct snd_line6_pcm {*/ int volume_monitor; -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE /** Volume of impulse response test signal (if zero, test is disabled). */
@@ -353,7 +336,6 @@ struct snd_line6_pcm {Counter for impulse response test signal. */ int impulse_count; -#endif /** Several status bits (see LINE6_BIT_*).
sound/usb/line6/playback.c +0 -8
@@ -60,8 +60,6 @@ static void change_volume(struct urb *urb_out, int volume[], } } -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE -/* Create signal for impulse response test. */
@@ -105,8 +103,6 @@ static void create_impulse_test_signal(struct snd_line6_pcm *line6pcm, } } -#endif -/* Add signal to buffer for software monitoring. */
@@ -243,7 +239,6 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm)change_volume (urb_out, line6pcm->volume_playback, bytes_per_frame);if (line6pcm->prev_fbuf !=NULL ) { -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE if (line6pcm->flags &LINE6_BITS_PCM_IMPULSE ) {create_impulse_test_signal (line6pcm, urb_out, bytes_per_frame);
@@ -257,7 +252,6 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) urb_out->transfer_buffer_length); } }else { -#endif if (! (line6pcm->line6-> properties->capabilities & LINE6_CAP_HWMON)
@@ -266,9 +260,7 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm)add_monitor_signal (urb_out, line6pcm->prev_fbuf, line6pcm->volume_monitor, bytes_per_frame); -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE } -#endif } ret =usb_submit_urb (urb_out,GFP_ATOMIC );
Signature · 1 line
2.2.1
PATCH 3/17 ALSA: line6: Drop superfluous snd_device for PCM
In reply to Takashi IwaiInstead of handling the card-specific resource in snd_device, attach it into pcm->private_data and release it directly in private_free. This simplifies the code and structure.
--- sound/usb/line6/pcm.c | 53 ++++++++++++++++++--------------------------------- 1 file changed, 19 insertions(+), 34 deletions(-)
sound/usb/line6/pcm.c +19 -34
@@ -351,24 +351,21 @@ static void line6_cleanup_pcm(struct snd_pcm *pcm)usb_free_urb (line6pcm->urb_audio_in[i]); } } +kfree (line6pcm); }/* create a PCM device */ -static int snd_line6_new_pcm (struct snd_line6_pcm *line6pcm) +static int snd_line6_new_pcm (struct usb_line6 *line6,struct snd_pcm **pcm_ret) {struct snd_pcm *pcm;int err; - err =snd_pcm_new (line6pcm->line6->card, - (char *)line6pcm->line6->properties->name, -0 ,1 ,1 , &pcm); + err =snd_pcm_new (line6->card, (char *)line6->properties->name, +0 ,1 ,1 , pcm_ret);if (err <0 )return err; - - pcm->private_data = line6pcm; - pcm->private_free = line6_cleanup_pcm; - line6pcm->pcm = pcm; -strcpy (pcm->name, line6pcm->line6->properties->name); + pcm = *pcm_ret; +strcpy (pcm->name, line6->properties->name);/* set operators */ snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
@@ -380,13 +377,6 @@ static int snd_line6_new_pcm(struct snd_line6_pcm *line6pcm)snd_dma_continuous_data (GFP_KERNEL ),64 *1024 , 128 * 1024); - -return 0 ; -} - -/* PCM device destructor */ -static int snd_line6_pcm_free (struct snd_device *device) -{return 0 ; }
@@ -423,23 +413,25 @@ EXPORT_SYMBOL_GPL(line6_pcm_disconnect);int line6_init_pcm (struct usb_line6 *line6,struct line6_pcm_properties *properties) { -static struct snd_device_ops pcm_ops = { - .dev_free = snd_line6_pcm_free, - }; -int i, err;unsigned ep_read = line6->properties->ep_audio_r;unsigned ep_write = line6->properties->ep_audio_w; +struct snd_pcm *pcm;struct snd_line6_pcm *line6pcm;if (!(line6->properties->capabilities &LINE6_CAP_PCM ))return 0 ;/* skip PCM initialization and report success */ - line6pcm =kzalloc (sizeof (*line6pcm),GFP_KERNEL ); + err =snd_line6_new_pcm (line6, &pcm); +if (err <0 ) +return err; -if (line6pcm ==NULL ) + line6pcm =kzalloc (sizeof (*line6pcm),GFP_KERNEL ); +if (!line6pcm)return -ENOMEM ; + line6pcm->pcm = pcm; + line6pcm->properties = properties; line6pcm->volume_playback[0 ] = line6pcm->volume_playback[1 ] =255 ; line6pcm->volume_monitor =255 ; line6pcm->line6 = line6;
@@ -451,23 +443,16 @@ int line6_init_pcm(struct usb_line6 *line6,usb_maxpacket (line6->usbdev, usb_sndisocpipe(line6->usbdev, ep_write), 1)); - line6pcm->properties = properties; - line6->line6pcm = line6pcm; - -/* PCM device: */ - err =snd_device_new (line6->card,SNDRV_DEV_PCM , line6, &pcm_ops); -if (err <0 ) -return err; - - err =snd_line6_new_pcm (line6pcm); -if (err <0 ) -return err; -spin_lock_init (&line6pcm->lock_audio_out);spin_lock_init (&line6pcm->lock_audio_in);spin_lock_init (&line6pcm->lock_trigger); line6pcm->impulse_period =LINE6_IMPULSE_DEFAULT_PERIOD ; + line6->line6pcm = line6pcm; + + pcm->private_data = line6pcm; + pcm->private_free = line6_cleanup_pcm; + err =line6_create_audio_out_urbs (line6pcm);if (err <0 )return err;
Signature · 1 line
2.2.1
PATCH 4/17 ALSA: line6: Drop superfluous snd_device for rawmidi
In reply to Takashi IwaiLike the previous fix for PCM, attach the card-specific resource into rawmidi->private_data instead of handling in a snd_device object. This simplifies the code and structure.
--- sound/usb/line6/midi.c | 65 ++++++++++++++++++-------------------------------- 1 file changed, 23 insertions(+), 42 deletions(-)
sound/usb/line6/midi.c +23 -42
@@ -223,28 +223,20 @@ static struct snd_rawmidi_ops line6_midi_input_ops = { .trigger = line6_midi_input_trigger, }; -/* -Cleanup the Line6 MIDI device. -*/ -static void line6_cleanup_midi (struct snd_rawmidi *rmidi) -{ -} -/* Create a MIDI device */ -static int snd_line6_new_midi (struct snd_line6_midi *line6midi) +static int snd_line6_new_midi (struct usb_line6 *line6, +struct snd_rawmidi **rmidi_ret) {struct snd_rawmidi *rmidi;int err; - err =snd_rawmidi_new (line6midi->line6->card,"Line6 MIDI" ,0 ,1 ,1 , - &rmidi); + err =snd_rawmidi_new (line6->card,"Line6 MIDI" ,0 ,1 ,1 , rmidi_ret);if (err <0 )return err; - rmidi->private_data = line6midi; - rmidi->private_free = line6_cleanup_midi; -strcpy (rmidi->id, line6midi->line6->properties->id); -strcpy (rmidi->name, line6midi->line6->properties->name); + rmidi = *rmidi_ret; +strcpy (rmidi->id, line6->properties->id); +strcpy (rmidi->name, line6->properties->name); rmidi->info_flags = SNDRV_RAWMIDI_INFO_OUTPUT |
@@ -258,13 +250,13 @@ static int snd_line6_new_midi(struct snd_line6_midi *line6midi) }/* MIDI device destructor */ -static int snd_line6_midi_free (struct snd_device *device) +static void snd_line6_midi_free (struct snd_rawmidi *rmidi) { -struct snd_line6_midi *line6midi = device->device_data; +struct snd_line6_midi *line6midi = rmidi->private_data;line6_midibuf_destroy (&line6midi->midibuf_in);line6_midibuf_destroy (&line6midi->midibuf_out); -return 0 ; +kfree (line6midi); }/*
@@ -272,11 +264,8 @@ static int snd_line6_midi_free(struct snd_device *device)*/ int line6_init_midi (struct usb_line6 *line6) { -static struct snd_device_ops midi_ops = { - .dev_free = snd_line6_midi_free, - }; -int err; +struct snd_rawmidi *rmidi;struct snd_line6_midi *line6midi;if (!(line6->properties->capabilities &LINE6_CAP_CONTROL )) {
@@ -284,39 +273,31 @@ int line6_init_midi(struct usb_line6 *line6)return 0 ; } - line6midi =kzalloc (sizeof (struct snd_line6_midi ),GFP_KERNEL ); + err =snd_line6_new_midi (line6, &rmidi); +if (err <0 ) +return err; -if (line6midi ==NULL ) + line6midi =kzalloc (sizeof (struct snd_line6_midi ),GFP_KERNEL ); +if (!line6midi)return -ENOMEM ; - err =line6_midibuf_init (&line6midi->midibuf_in,MIDI_BUFFER_SIZE ,0 ); -if (err <0 ) { -kfree (line6midi); -return err; - } - - err =line6_midibuf_init (&line6midi->midibuf_out,MIDI_BUFFER_SIZE ,1 ); -if (err <0 ) { -kfree (line6midi->midibuf_in.buf); -kfree (line6midi); -return err; - } + rmidi->private_data = line6midi; + rmidi->private_free = snd_line6_midi_free; +init_waitqueue_head (&line6midi->send_wait); +spin_lock_init (&line6midi->send_urb_lock); +spin_lock_init (&line6midi->midi_transmit_lock); line6midi->line6 = line6; - line6->line6midi = line6midi; - err =snd_device_new (line6->card,SNDRV_DEV_RAWMIDI , line6midi, - &midi_ops); + err =line6_midibuf_init (&line6midi->midibuf_in,MIDI_BUFFER_SIZE ,0 );if (err <0 )return err; - err =snd_line6_new_midi (line6midi); + err =line6_midibuf_init (&line6midi->midibuf_out,MIDI_BUFFER_SIZE ,1 );if (err <0 )return err; -init_waitqueue_head (&line6midi->send_wait); -spin_lock_init (&line6midi->send_urb_lock); -spin_lock_init (&line6midi->midi_transmit_lock); + line6->line6midi = line6midi;return 0 ; }EXPORT_SYMBOL_GPL (line6_init_midi);
Signature · 1 line
2.2.1
PATCH 5/17 ALSA: line6: Drop invalid SNDRV_PCM_INFO_RESUME flag
In reply to Takashi IwaiThe line6 drivers don't support the full resume although they set SNDRV_PCM_INFO_RESUME. These flags have to be dropped to inform properly to the user-space.
Also, drop the CONFIG_PM in trigger callbacks, too, which are rather superfluous.
--- sound/usb/line6/capture.c | 4 ---- sound/usb/line6/playback.c | 4 ---- sound/usb/line6/pod.c | 6 ------ sound/usb/line6/podhd.c | 6 ------ sound/usb/line6/toneport.c | 6 ------ 5 files changed, 26 deletions(-)
sound/usb/line6/capture.c +0 -4
@@ -342,9 +342,7 @@ int snd_line6_capture_trigger(struct snd_line6_pcm *line6pcm, int cmd)switch (cmd) {case SNDRV_PCM_TRIGGER_START : -#ifdef CONFIG_PM case SNDRV_PCM_TRIGGER_RESUME : -#endif err =line6_pcm_acquire (line6pcm,LINE6_BIT_PCM_ALSA_CAPTURE_STREAM );
@@ -354,9 +352,7 @@ int snd_line6_capture_trigger(struct snd_line6_pcm *line6pcm, int cmd)break ;case SNDRV_PCM_TRIGGER_STOP : -#ifdef CONFIG_PM case SNDRV_PCM_TRIGGER_SUSPEND : -#endif err =line6_pcm_release (line6pcm,LINE6_BIT_PCM_ALSA_CAPTURE_STREAM );
sound/usb/line6/playback.c +0 -4
@@ -490,9 +490,7 @@ int snd_line6_playback_trigger(struct snd_line6_pcm *line6pcm, int cmd)switch (cmd) {case SNDRV_PCM_TRIGGER_START : -#ifdef CONFIG_PM case SNDRV_PCM_TRIGGER_RESUME : -#endif err =line6_pcm_acquire (line6pcm,LINE6_BIT_PCM_ALSA_PLAYBACK_STREAM );
@@ -502,9 +500,7 @@ int snd_line6_playback_trigger(struct snd_line6_pcm *line6pcm, int cmd)break ;case SNDRV_PCM_TRIGGER_STOP : -#ifdef CONFIG_PM case SNDRV_PCM_TRIGGER_SUSPEND : -#endif err =line6_pcm_release (line6pcm,LINE6_BIT_PCM_ALSA_PLAYBACK_STREAM );
sound/usb/line6/pod.c +0 -6
@@ -153,9 +153,6 @@ static struct line6_pcm_properties pod_pcm_properties = {SNDRV_PCM_INFO_BLOCK_TRANSFER |SNDRV_PCM_INFO_MMAP_VALID |SNDRV_PCM_INFO_PAUSE | -#ifdef CONFIG_PM - SNDRV_PCM_INFO_RESUME | -#endif SNDRV_PCM_INFO_SYNC_START), .formats = SNDRV_PCM_FMTBIT_S24_3LE, .rates = SNDRV_PCM_RATE_KNOT,
@@ -173,9 +170,6 @@ static struct line6_pcm_properties pod_pcm_properties = {SNDRV_PCM_INFO_INTERLEAVED |SNDRV_PCM_INFO_BLOCK_TRANSFER |SNDRV_PCM_INFO_MMAP_VALID | -#ifdef CONFIG_PM - SNDRV_PCM_INFO_RESUME | -#endif SNDRV_PCM_INFO_SYNC_START), .formats = SNDRV_PCM_FMTBIT_S24_3LE, .rates = SNDRV_PCM_RATE_KNOT,
sound/usb/line6/podhd.c +0 -6
@@ -50,9 +50,6 @@ static struct line6_pcm_properties podhd_pcm_properties = {SNDRV_PCM_INFO_BLOCK_TRANSFER |SNDRV_PCM_INFO_MMAP_VALID |SNDRV_PCM_INFO_PAUSE | -#ifdef CONFIG_PM - SNDRV_PCM_INFO_RESUME | -#endif SNDRV_PCM_INFO_SYNC_START), .formats = SNDRV_PCM_FMTBIT_S24_3LE, .rates = SNDRV_PCM_RATE_48000,
@@ -70,9 +67,6 @@ static struct line6_pcm_properties podhd_pcm_properties = {SNDRV_PCM_INFO_INTERLEAVED |SNDRV_PCM_INFO_BLOCK_TRANSFER |SNDRV_PCM_INFO_MMAP_VALID | -#ifdef CONFIG_PM - SNDRV_PCM_INFO_RESUME | -#endif SNDRV_PCM_INFO_SYNC_START), .formats = SNDRV_PCM_FMTBIT_S24_3LE, .rates = SNDRV_PCM_RATE_48000,
sound/usb/line6/toneport.c +0 -6
@@ -83,9 +83,6 @@ static struct line6_pcm_properties toneport_pcm_properties = {SNDRV_PCM_INFO_BLOCK_TRANSFER |SNDRV_PCM_INFO_MMAP_VALID |SNDRV_PCM_INFO_PAUSE | -#ifdef CONFIG_PM - SNDRV_PCM_INFO_RESUME | -#endif SNDRV_PCM_INFO_SYNC_START), .formats = SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_KNOT,
@@ -103,9 +100,6 @@ static struct line6_pcm_properties toneport_pcm_properties = {SNDRV_PCM_INFO_INTERLEAVED |SNDRV_PCM_INFO_BLOCK_TRANSFER |SNDRV_PCM_INFO_MMAP_VALID | -#ifdef CONFIG_PM - SNDRV_PCM_INFO_RESUME | -#endif SNDRV_PCM_INFO_SYNC_START), .formats = SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_KNOT,
Signature · 1 line
2.2.1
PATCH 6/17 ALSA: line6: Drop usb_device sysfs symlink
In reply to Takashi IwaiIt's non-standard and rather superfluous.
--- sound/usb/line6/driver.c | 9 --------- 1 file changed, 9 deletions(-)
sound/usb/line6/driver.c +0 -9
@@ -611,11 +611,6 @@ int line6_probe(struct usb_interface *interface,if (ret <0 ) goto err_destruct; - ret =sysfs_create_link (&interface->dev.kobj, &usbdev->dev.kobj, -"usb_device" ); -if (ret <0 ) - goto err_destruct; -/* creation of additional special files should go here */ dev_info(&interface->dev, "Line6 %s now attached\n",
@@ -649,10 +644,6 @@ void line6_disconnect(struct usb_interface *interface)if (usbdev ==NULL )return ; -/* removal of additional special files should go here */ - -sysfs_remove_link (&interface->dev.kobj,"usb_device" ); - interface_number = interface->cur_altsetting->desc.bInterfaceNumber; line6 =usb_get_intfdata (interface);
Signature · 1 line
2.2.1
PATCH 7/17 ALSA: line6: Remove superfluous out-of-memory error messages
In reply to Takashi IwaiKernel already shows the error in the common path.
--- sound/usb/line6/capture.c | 4 +--- sound/usb/line6/driver.c | 6 +----- sound/usb/line6/midi.c | 5 +---- sound/usb/line6/playback.c | 4 +--- sound/usb/line6/variax.c | 4 +--- 5 files changed, 5 insertions(+), 18 deletions(-)
sound/usb/line6/capture.c +1 -3
@@ -402,10 +402,8 @@ int line6_create_audio_in_urbs(struct snd_line6_pcm *line6pcm) urb = line6pcm->urb_audio_in[i] =usb_alloc_urb (LINE6_ISO_PACKETS ,GFP_KERNEL ); -if (urb ==NULL ) { -dev_err (line6->ifcdev,"Out of memory\n" ); +if (urb ==NULL )return -ENOMEM ; - } urb->dev = line6->usbdev; urb->pipe =
sound/usb/line6/driver.c +1 -5
@@ -190,7 +190,6 @@ int line6_send_raw_message_async(struct usb_line6 *line6, const char *buffer,if (urb ==NULL ) {kfree (msg); -dev_err (line6->ifcdev,"Out of memory\n" );return -ENOMEM ; }
@@ -215,10 +214,8 @@ int line6_version_request_async(struct usb_line6 *line6) buffer =kmemdup (line6_request_version,sizeof (line6_request_version),GFP_ATOMIC ); -if (buffer ==NULL ) { -dev_err (line6->ifcdev,"Out of memory" ); +if (buffer ==NULL )return -ENOMEM ; - } retval =line6_send_raw_message_async (line6, buffer,sizeof (line6_request_version));
@@ -593,7 +590,6 @@ int line6_probe(struct usb_interface *interface, line6->urb_listen =usb_alloc_urb (0 ,GFP_KERNEL );if (line6->urb_listen ==NULL ) { -dev_err (&interface->dev,"Out of memory\n" ); ret = -ENOMEM ; goto err_destruct; }
sound/usb/line6/midi.c +1 -4
@@ -121,16 +121,13 @@ static int send_midi_async(struct usb_line6 *line6, unsigned char *data, urb =usb_alloc_urb (0 ,GFP_ATOMIC ); -if (urb ==NULL ) { -dev_err (line6->ifcdev,"Out of memory\n" ); +if (urb ==NULL )return -ENOMEM ; - } transfer_buffer =kmemdup (data, length,GFP_ATOMIC );if (transfer_buffer ==NULL ) {usb_free_urb (urb); -dev_err (line6->ifcdev,"Out of memory\n" );return -ENOMEM ; }
sound/usb/line6/playback.c +1 -3
@@ -558,10 +558,8 @@ int line6_create_audio_out_urbs(struct snd_line6_pcm *line6pcm) urb = line6pcm->urb_audio_out[i] =usb_alloc_urb (LINE6_ISO_PACKETS ,GFP_KERNEL ); -if (urb ==NULL ) { -dev_err (line6->ifcdev,"Out of memory\n" ); +if (urb ==NULL )return -ENOMEM ; - } urb->dev = line6->usbdev; urb->pipe =
sound/usb/line6/variax.c +1 -3
@@ -260,10 +260,8 @@ static int variax_try_init(struct usb_interface *interface, variax->buffer_activate =kmemdup (variax_activate,sizeof (variax_activate),GFP_KERNEL ); -if (variax->buffer_activate ==NULL ) { -dev_err (&interface->dev,"Out of memory\n" ); +if (variax->buffer_activate ==NULL )return -ENOMEM ; - }/* initialize audio system: */ err =line6_init_audio (&variax->line6);
Signature · 1 line
2.2.1
PATCH 8/17 ALSA: line6: Don't handle PCM trigger for other cards
In reply to Takashi IwaiOtherwise it oopses.
--- sound/usb/line6/pcm.c | 2 ++ 1 file changed, 2 insertions(+)
sound/usb/line6/pcm.c +2 -0
@@ -233,6 +233,8 @@ int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd)clear_bit (LINE6_INDEX_PREPARED , &line6pcm->flags);snd_pcm_group_for_each_entry (s, substream) { +if (s->pcm->card != substream->pcm->card) +continue ;switch (s->stream) {case SNDRV_PCM_STREAM_PLAYBACK : err =snd_line6_playback_trigger (line6pcm, cmd);
Signature · 1 line
2.2.1
PATCH 9/17 ALSA: line6: Drop superfluous irqsave/irqrestore in PCM trigger callback
In reply to Takashi Iwai--- sound/usb/line6/pcm.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
sound/usb/line6/pcm.c +4 -7
@@ -227,9 +227,8 @@ int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd)struct snd_line6_pcm *line6pcm =snd_pcm_substream_chip (substream);struct snd_pcm_substream *s;int err; -unsigned long flags; -spin_lock_irqsave (&line6pcm->lock_trigger, flags); +spin_lock (&line6pcm->lock_trigger);clear_bit (LINE6_INDEX_PREPARED , &line6pcm->flags);snd_pcm_group_for_each_entry (s, substream) {
@@ -240,8 +239,7 @@ int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd) err =snd_line6_playback_trigger (line6pcm, cmd);if (err <0 ) { -spin_unlock_irqrestore (&line6pcm->lock_trigger, - flags); +spin_unlock (&line6pcm->lock_trigger);return err; }
@@ -251,8 +249,7 @@ int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd) err =snd_line6_capture_trigger (line6pcm, cmd);if (err <0 ) { -spin_unlock_irqrestore (&line6pcm->lock_trigger, - flags); +spin_unlock (&line6pcm->lock_trigger);return err; }
@@ -264,7 +261,7 @@ int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd) } } -spin_unlock_irqrestore (&line6pcm->lock_trigger, flags); +spin_unlock (&line6pcm->lock_trigger);return 0 ; }
Signature · 1 line
2.2.1
PATCH 10/17 ALSA: line6: Reorganize card resource handling
In reply to Takashi IwaiThis is a fairly big rewrite regarding the card resource management in line6 drivers:
- The card creation is moved into line6_probe(). This adds the global destructor to private_free, so that each driver doesn't have to call it any longer.
- The USB disconnect callback handles the card release, thus each driver needs to concentrate on only its own resources. No need to snd_card_*() call in the destructor.
- Fix the potential stall in disconnection by removing
snd_card_free(). It's replaced with snd_card_free_when_closed()
for asynchronous release.
- The only remaining operation for the card in each driver is the call of snd_card_register(). All the rest are dealt in the common module by itself.
- These ended up with removal of audio.[ch] as a result of a reduction of one layer. Each driver just needs to call line6_probe().
--- sound/usb/line6/Makefile | 1 - sound/usb/line6/audio.c | 74 ----------------------------------------- sound/usb/line6/audio.h | 21 ------------ sound/usb/line6/capture.c | 1 - sound/usb/line6/driver.c | 82 +++++++++++++++++++++++++++------------------- sound/usb/line6/midi.c | 1 - sound/usb/line6/pcm.c | 1 - sound/usb/line6/playback.c | 1 - sound/usb/line6/pod.c | 60 +++++---------------------------- sound/usb/line6/podhd.c | 75 ++++-------------------------------------- sound/usb/line6/toneport.c | 65 ++++-------------------------------- sound/usb/line6/variax.c | 58 ++++++++------------------------ 12 files changed, 85 insertions(+), 355 deletions(-) delete mode 100644 sound/usb/line6/audio.c delete mode 100644 sound/usb/line6/audio.h
sound/usb/line6/Makefile +0 -1
@@ -1,5 +1,4 @@ snd-usb-line6-y := \ - audio.o \ capture.o \ driver.o \ midi.o \
sound/usb/line6/audio.c deleted +0 -74
74 lines not on this page · raw message
sound/usb/line6/audio.h deleted +0 -21
@@ -1,21 +0,0 @@ -/* -* Line6 Linux USB driver - 0.9.1beta -* -* Copyright (C) 2004-2010 Markus Grabner ([email protected]) -* -* 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 the Free Software Foundation, version 2. -* -*/ - -#ifndef AUDIO_H -#define AUDIO_H - -#include "driver.h" - -extern void line6_cleanup_audio (struct usb_line6 *); -extern int line6_init_audio (struct usb_line6 *); -extern int line6_register_audio (struct usb_line6 *); - -#endif
sound/usb/line6/capture.c +0 -1
@@ -14,7 +14,6 @@#include <sound/pcm.h> #include <sound/pcm_params.h> -#include "audio.h" #include "capture.h" #include "driver.h" #include "pcm.h"
sound/usb/line6/driver.c +49 -33
139 lines not on this page · raw message
sound/usb/line6/midi.c +0 -1
@@ -15,7 +15,6 @@#include <sound/core.h> #include <sound/rawmidi.h> -#include "audio.h" #include "driver.h" #include "midi.h" #include "usbdefs.h"
sound/usb/line6/pcm.c +0 -1
@@ -16,7 +16,6 @@#include <sound/pcm.h> #include <sound/pcm_params.h> -#include "audio.h" #include "capture.h" #include "driver.h" #include "playback.h"
sound/usb/line6/playback.c +0 -1
@@ -14,7 +14,6 @@#include <sound/pcm.h> #include <sound/pcm_params.h> -#include "audio.h" #include "capture.h" #include "driver.h" #include "pcm.h"
sound/usb/line6/pod.c +9 -51
121 lines not on this page · raw message
sound/usb/line6/podhd.c +7 -68
117 lines not on this page · raw message
sound/usb/line6/toneport.c +7 -58
118 lines not on this page · raw message
sound/usb/line6/variax.c +13 -45
109 lines not on this page · raw message
Signature · 1 line
2.2.1
Re: [PATCH 10/17] ALSA: line6: Reorganize card resource handling
Quoted 15 lines · Takashi Iwai
This is a fairly big rewrite regarding the card resource management in line6 drivers:
- The card creation is moved into
line6_probe(). This adds the global destructor toprivate_free, so that each driver doesn't have to call it any longer.- The USB disconnect callback handles the card release, thus each driver needs to concentrate on only its own resources. No need to snd_card_*() call in the destructor.
- Fix the potential stall in disconnection by removing
snd_card_free(). It's replaced withsnd_card_free_when_closed()
for asynchronous release.
Quoted 6 lines
- The only remaining operation for the card in each driver is the call of
snd_card_register(). All the rest are dealt in the common module by itself.- These ended up with removal of audio.[ch] as a result of a reduction of one layer. Each driver just needs to call
line6_probe().
Nice looking diff --stat. :-)
Seems like this could be nicely split up into a few patches to make it a bit easier to review. I'd be happy to take a stab at that if you thought it was worth it. Otherwise, looks good to me.
Chris
Re: [PATCH 10/17] ALSA: line6: Reorganize card resource handling
At Tue, 20 Jan 2015 00:14:08 -0600,
Quoted 21 lines · Chris Rorvick
Quoted 19 lines · Takashi Iwai
This is a fairly big rewrite regarding the card resource management in line6 drivers:
- The card creation is moved into
line6_probe(). This adds the global destructor toprivate_free, so that each driver doesn't have to call it any longer.- The USB disconnect callback handles the card release, thus each driver needs to concentrate on only its own resources. No need to snd_card_*() call in the destructor.
- Fix the potential stall in disconnection by removing
snd_card_free(). It's replaced withsnd_card_free_when_closed()
for asynchronous release.- The only remaining operation for the card in each driver is the call of
snd_card_register(). All the rest are dealt in the common module by itself.
Quoted 8 lines
Quoted 2 lines
- These ended up with removal of audio.[ch] as a result of a reduction of one layer. Each driver just needs to call
line6_probe().Nice looking diff --stat. :-)
Seems like this could be nicely split up into a few patches to make it a bit easier to review. I'd be happy to take a stab at that if you thought it was worth it. Otherwise, looks good to me.
It's not trivial to split, unfortunately, because all the above are related tightly together and the code has been already split to individual drivers.
Despite the code reduction, what the patch is doing is fairly straightforward if you know of the standard snd_card creation and destruction procedure.
Takashi
PATCH 11/17 ALSA: line6: Remove driver version string
In reply to Takashi IwaiThis is rather useless for a driver that has been already merged into the official tree.
--- sound/usb/line6/driver.c | 2 -- 1 file changed, 2 deletions(-)
sound/usb/line6/driver.c +0 -2
@@ -27,7 +27,6 @@#define DRIVER_AUTHOR "Markus Grabner <[email protected]>"#define DRIVER_DESC "Line6 USB Driver" -#define DRIVER_VERSION "0.9.1beta" DRIVER_REVISION/* This is Line6's MIDI manufacturer ID.
@@ -729,4 +728,3 @@ EXPORT_SYMBOL_GPL(line6_resume);MODULE_AUTHOR (DRIVER_AUTHOR );MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" ); -MODULE_VERSION (DRIVER_VERSION );
Signature · 1 line
2.2.1
PATCH 12/17 ALSA: line6: Drop MISSING_CASE macro
In reply to Takashi IwaiSuch a debug is needed in the core code, not in each lowlevel driver.
--- sound/usb/line6/driver.h | 4 ---- sound/usb/line6/pcm.c | 3 --- 2 files changed, 7 deletions(-)
sound/usb/line6/driver.h +0 -4
@@ -48,10 +48,6 @@#define LINE6_CHANNEL_MASK 0x0f -#define MISSING_CASE \ - pr_err("line6usb driver bug: missing case in %s:%d\n", \ - __FILE__, __LINE__) -#define CHECK_RETURN (x) \ do { \ err = x; \
sound/usb/line6/pcm.c +0 -3
@@ -488,9 +488,6 @@ int snd_line6_prepare(struct snd_pcm_substream *substream)line6_unlink_wait_clear_audio_in_urbs (line6pcm);break ; - -default : -MISSING_CASE ; }if (!test_and_set_bit (LINE6_INDEX_PREPARED , &line6pcm->flags)) {
Signature · 1 line
2.2.1
PATCH 13/17 ALSA: line6: Remove CHECK_RETURN macro
In reply to Takashi IwaiSuch a macro doesn't improve readability.
--- sound/usb/line6/driver.h | 7 ------- sound/usb/line6/pod.c | 12 +++++++++--- sound/usb/line6/toneport.c | 10 ++++++---- 3 files changed, 15 insertions(+), 14 deletions(-)
sound/usb/line6/driver.h +0 -7
@@ -48,13 +48,6 @@#define LINE6_CHANNEL_MASK 0x0f -#define CHECK_RETURN (x) \ -do { \ - err = x; \ - if (err < 0) \ - return err; \ -} while (0) -#define CHECK_STARTUP_PROGRESS (x, n) \ do { \ if ((x) >= (n)) \
sound/usb/line6/pod.c +9 -3
@@ -429,9 +429,15 @@ static int pod_create_files2(struct device *dev) {int err; -CHECK_RETURN (device_create_file (dev, &dev_attr_device_id)); -CHECK_RETURN (device_create_file (dev, &dev_attr_firmware_version)); -CHECK_RETURN (device_create_file (dev, &dev_attr_serial_number)); + err =device_create_file (dev, &dev_attr_device_id); +if (err <0 ) +return err; + err =device_create_file (dev, &dev_attr_firmware_version); +if (err <0 ) +return err; + err =device_create_file (dev, &dev_attr_serial_number); +if (err <0 ) +return err;return 0 ; }
sound/usb/line6/toneport.c +6 -4
@@ -431,10 +431,12 @@ static int toneport_init(struct usb_interface *interface,line6_read_data (line6,0x80c2 , &toneport->firmware_version,1 );if (toneport_has_led (toneport->type)) { -CHECK_RETURN (device_create_file - (&interface->dev, &dev_attr_led_red)); -CHECK_RETURN (device_create_file - (&interface->dev, &dev_attr_led_green)); + err =device_create_file (&interface->dev, &dev_attr_led_red); +if (err <0 ) +return err; + err =device_create_file (&interface->dev, &dev_attr_led_green); +if (err <0 ) +return err; }toneport_setup (toneport);
Signature · 1 line
2.2.1
PATCH 14/17 ALSA: line6: Remove superfluous disconnect call in suspend handler
In reply to Takashi IwaiCalling line6_pcm_disconnect() at suspend callback is superfluous and rather confusing. Let's get rid of it.
--- sound/usb/line6/driver.c | 1 - 1 file changed, 1 deletion(-)
sound/usb/line6/driver.c +0 -1
@@ -700,7 +700,6 @@ int line6_suspend(struct usb_interface *interface, pm_message_t message)if (line6pcm !=NULL ) {snd_pcm_suspend_all (line6pcm->pcm); -line6_pcm_disconnect (line6pcm); line6pcm->flags =0 ; }
Signature · 1 line
2.2.1
PATCH 15/17 ALSA: line6: Sync PCM stop at disconnect
In reply to Takashi IwaiCall line6_pcm_disconnect() at disconnect to make sure that all URBs are cleared. Also reduce the superfluous snd_pcm_stop() calls from the function (and remove the unused function) since the streams are guaranteed to be stopped at this point via snd_card_disconnect().
--- sound/usb/line6/driver.c | 2 ++ sound/usb/line6/pcm.c | 19 +------------------ 2 files changed, 3 insertions(+), 18 deletions(-)
sound/usb/line6/driver.c +2 -0
@@ -670,6 +670,8 @@ void line6_disconnect(struct usb_interface *interface)dev_err (line6->ifcdev,"driver bug: inconsistent usb device\n" );snd_card_disconnect (line6->card); +if (line6->line6pcm) +line6_pcm_disconnect (line6->line6pcm);if (line6->disconnect) line6->disconnect (interface);
sound/usb/line6/pcm.c +1 -18
@@ -379,30 +379,13 @@ static int snd_line6_new_pcm(struct usb_line6 *line6, struct snd_pcm **pcm_ret) }/* -Stop substream if still running. -*/ -static void pcm_disconnect_substream (struct snd_pcm_substream *substream) -{ -if (substream->runtime &&snd_pcm_running (substream)) { -snd_pcm_stream_lock_irq (substream); -snd_pcm_stop (substream,SNDRV_PCM_STATE_DISCONNECTED ); -snd_pcm_stream_unlock_irq (substream); - } -} - -/* -Stop PCM stream. +Sync with PCM stream stops. */ void line6_pcm_disconnect (struct snd_line6_pcm *line6pcm) { -pcm_disconnect_substream (get_substream - (line6pcm,SNDRV_PCM_STREAM_CAPTURE )); -pcm_disconnect_substream (get_substream - (line6pcm,SNDRV_PCM_STREAM_PLAYBACK ));line6_unlink_wait_clear_audio_out_urbs (line6pcm);line6_unlink_wait_clear_audio_in_urbs (line6pcm); } -EXPORT_SYMBOL_GPL (line6_pcm_disconnect);/* Create and register the PCM device and mixer entries.
Signature · 1 line
2.2.1
PATCH 16/17 ALSA: line6: Make line6_send_raw_message() static
In reply to Takashi IwaiIt's used only locally.
--- sound/usb/line6/driver.c | 4 ++-- sound/usb/line6/driver.h | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-)
sound/usb/line6/driver.c +2 -2
@@ -88,8 +88,8 @@ static void line6_stop_listen(struct usb_line6 *line6)/* Send raw message in pieces of wMaxPacketSize bytes. */ -int line6_send_raw_message (struct usb_line6 *line6,const char *buffer, -int size) +static int line6_send_raw_message (struct usb_line6 *line6,const char *buffer, +int size) {int i, done =0 ;
sound/usb/line6/driver.h +0 -2
@@ -169,8 +169,6 @@ extern int line6_read_data(struct usb_line6 *line6, int address, void *data,extern int line6_read_serial_number (struct usb_line6 *line6,int *serial_number);extern int line6_send_program (struct usb_line6 *line6,u8 value); -extern int line6_send_raw_message (struct usb_line6 *line6,const char *buffer, -int size);extern int line6_send_raw_message_async (struct usb_line6 *line6,const char *buffer,int size); extern int line6_send_sysex_message(struct usb_line6 *line6,
Signature · 1 line
2.2.1
PATCH 17/17 ALSA: line6: Drop line6_send_program() and line6_transmit_parameter()
In reply to Takashi IwaiBoth functions are used nowhere.
--- sound/usb/line6/driver.c | 59 ------------------------------------------------ sound/usb/line6/driver.h | 3 --- 2 files changed, 62 deletions(-)
sound/usb/line6/driver.c +0 -59
@@ -299,65 +299,6 @@ static void line6_data_received(struct urb *urb) }/* -Send channel number (i.e., switch to a different sound). -*/ -int line6_send_program (struct usb_line6 *line6,u8 value) -{ -int retval; -unsigned char *buffer; -int partial; - - buffer =kmalloc (2 ,GFP_KERNEL ); -if (!buffer) -return -ENOMEM ; - - buffer[0 ] =LINE6_PROGRAM_CHANGE |LINE6_CHANNEL_HOST ; - buffer[1 ] = value; - - retval =usb_interrupt_msg (line6->usbdev, -usb_sndintpipe (line6->usbdev, - line6->properties->ep_ctrl_w), - buffer,2 , &partial,LINE6_TIMEOUT *HZ ); - -if (retval) -dev_err (line6->ifcdev,"usb_interrupt_msg failed (%d)\n" , - retval); - -kfree (buffer); -return retval; -} - -/* -Transmit Line6 control parameter. -*/ -int line6_transmit_parameter (struct usb_line6 *line6,int param,u8 value) -{ -int retval; -unsigned char *buffer; -int partial; - - buffer =kmalloc (3 ,GFP_KERNEL ); -if (!buffer) -return -ENOMEM ; - - buffer[0 ] =LINE6_PARAM_CHANGE |LINE6_CHANNEL_HOST ; - buffer[1 ] = param; - buffer[2 ] = value; - - retval =usb_interrupt_msg (line6->usbdev, -usb_sndintpipe (line6->usbdev, - line6->properties->ep_ctrl_w), - buffer,3 , &partial,LINE6_TIMEOUT *HZ ); - -if (retval) -dev_err (line6->ifcdev,"usb_interrupt_msg failed (%d)\n" , - retval); - -kfree (buffer); -return retval; -} - -/* Read data from device. */ int line6_read_data(struct usb_line6 *line6, int address, void *data,
sound/usb/line6/driver.h +0 -3
@@ -168,7 +168,6 @@ extern int line6_read_data(struct usb_line6 *line6, int address, void *data, size_t datalen);extern int line6_read_serial_number (struct usb_line6 *line6,int *serial_number); -extern int line6_send_program (struct usb_line6 *line6,u8 value);extern int line6_send_raw_message_async (struct usb_line6 *line6,const char *buffer,int size); extern int line6_send_sysex_message(struct usb_line6 *line6,
@@ -178,8 +177,6 @@ extern ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr,extern void line6_start_timer (struct timer_list *timer,unsigned int msecs,void (*function)(unsigned long ),unsigned long data); -extern int line6_transmit_parameter (struct usb_line6 *line6,int param, -u8 value);extern int line6_version_request_async (struct usb_line6 *line6);extern int line6_write_data (struct usb_line6 *line6,int address,void *data,size_t datalen);
Signature · 1 line
2.2.1
Quoted 4 lines · Takashi Iwai
The current merged code is found in topic/line6 branch of sound.git tree while this development code is found in test/line6 branch. The devel branch hasn't been merged to linux-next yet, I'm waiting for any good/bad test results. So, give me any feedback. Thanks!
Looks good to me. I tried it out briefly with a TonePort UX2 without issue.
Quoted 3 lines
(BTW, the next step would be to straighten the init code in
pod.c,
etc instead of (ab)using the system timer. Instead, it should be a flat function withwait_event()of such.)
Are you planning on doing this? Otherwise I can probably poke at it this week.
Thanks!
Chris
At Tue, 20 Jan 2015 00:24:24 -0600,
Quoted 11 lines · Chris Rorvick
Quoted 4 lines · Takashi Iwai
The current merged code is found in topic/line6 branch of sound.git tree while this development code is found in test/line6 branch. The devel branch hasn't been merged to linux-next yet, I'm waiting for any good/bad test results. So, give me any feedback. Thanks!
Looks good to me. I tried it out briefly with a TonePort UX2 without issue.
Tested-by Chris Rorvick <[email protected]>
Added your tag now.
Quoted 6 lines
Quoted 3 lines
(BTW, the next step would be to straighten the init code in
pod.c,
etc instead of (ab)using the system timer. Instead, it should be a flat function withwait_event()of such.)Are you planning on doing this? Otherwise I can probably poke at it this week.
I'd like to leave to you since such a change is more sensitive wrt timing and needs definitely the real hardware testing.
thanks,
Takashi