Cleanups for snd-usb-audio
cover Cleanups for snd-usb-audio
Hi,
I prepared a subset of my work on the generic USB audio driver that doesn't actually change any logic but just moves around major chunks of code. Can we get this merged as preparation for the more intrusive parts that follow?
Thanks,
Daniel
Daniel Mack (4):
USB: Add endpoint usage definitions to ch9.h
ALSA: snd-usb: re-order the Makefile
ALSA: snd-usb: re-order code
ALSA: snd-usb: move code from urb.c to endpoint.c
include/linux/usb/ch9.h | 17 +- sound/usb/Makefile | 12 +- sound/usb/card.c | 4 +- sound/usb/endpoint.c | 1185 +++++++++++++++++++++++++++++++++-------------- sound/usb/endpoint.h | 20 +- sound/usb/pcm.c | 2 +- sound/usb/quirks.c | 7 +- sound/usb/stream.c | 452 ++++++++++++++++++ sound/usb/stream.h | 12 + sound/usb/urb.c | 941 ------------------------------------- sound/usb/urb.h | 21 - 11 files changed, 1341 insertions(+), 1332 deletions(-) create mode 100644 sound/usb/stream.c create mode 100644 sound/usb/stream.h delete mode 100644 sound/usb/urb.c delete mode 100644 sound/usb/urb.h
Signature · 1 line
1.7.5.4
PATCH 1/4 USB: Add endpoint usage definitions to ch9.h
The endpoint usage field is described in the USB 2.0 specification, chapter 9.6.6.
Also, move the sync type fields block down by some lines to reflect the fact that these are also stuffed in bmAttributes.
--- include/linux/usb/ch9.h | 17 +++++++++++------ 1 files changed, 11 insertions(+), 6 deletions(-)
include/linux/usb/ch9.h +11 -6
@@ -377,12 +377,6 @@ struct usb_endpoint_descriptor {#define USB_ENDPOINT_NUMBER_MASK 0x0f/* in bEndpointAddress */ #define USB_ENDPOINT_DIR_MASK 0x80 -#define USB_ENDPOINT_SYNCTYPE 0x0c -#define USB_ENDPOINT_SYNC_NONE (0 << 2) -#define USB_ENDPOINT_SYNC_ASYNC (1 << 2) -#define USB_ENDPOINT_SYNC_ADAPTIVE (2 << 2) -#define USB_ENDPOINT_SYNC_SYNC (3 << 2) -#define USB_ENDPOINT_XFERTYPE_MASK 0x03/* in bmAttributes */ #define USB_ENDPOINT_XFER_CONTROL 0#define USB_ENDPOINT_XFER_ISOC 1
@@ -390,6 +384,17 @@ struct usb_endpoint_descriptor {#define USB_ENDPOINT_XFER_INT 3#define USB_ENDPOINT_MAX_ADJUSTABLE 0x80 +#define USB_ENDPOINT_SYNCTYPE 0x0c +#define USB_ENDPOINT_SYNC_NONE (0 << 2) +#define USB_ENDPOINT_SYNC_ASYNC (1 << 2) +#define USB_ENDPOINT_SYNC_ADAPTIVE (2 << 2) +#define USB_ENDPOINT_SYNC_SYNC (3 << 2) + +#define USB_ENDPOINT_USAGE_MASK 0x30 +#define USB_ENDPOINT_USAGE_DATA 0x00 +#define USB_ENDPOINT_USAGE_FEEDBACK 0x10 +#define USB_ENDPOINT_USAGE_IMPLICIT_FB 0x20/* Implicit feedback Data endpoint */ +/*-------------------------------------------------------------------------*/ /**
Signature · 1 line
1.7.5.4
Re: [PATCH 1/4] USB: Add endpoint usage definitions to ch9.h
Quoted 5 lines · Daniel Mack
The endpoint usage field is described in the USB 2.0 specification, chapter 9.6.6.
Also, move the sync type fields block down by some lines to reflect the fact that these are also stuffed in bmAttributes.
Greg - can we merge this through the ALSA tree?
Daniel
Quoted 46 lines
Signed-off-by Daniel Mack <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Takashi Iwai <[email protected]>---
include/linux/usb/ch9.h | 17 +++++++++++------1 files changed, 11 insertions(+), 6 deletions(-)include/linux/usb/ch9.h +11
-7@@ -377,12 +377,6 @@ struct usb_endpoint_descriptor { #define USB_ENDPOINT_NUMBER_MASK 0x0f /* in bEndpointAddress */ #define USB_ENDPOINT_DIR_MASK 0x80 -#define USB_ENDPOINT_SYNCTYPE 0x0c -#define USB_ENDPOINT_SYNC_NONE (0 << 2) -#define USB_ENDPOINT_SYNC_ASYNC (1 << 2) -#define USB_ENDPOINT_SYNC_ADAPTIVE (2 << 2) -#define USB_ENDPOINT_SYNC_SYNC (3 << 2) - #define USB_ENDPOINT_XFERTYPE_MASK 0x03 /* in bmAttributes */ #define USB_ENDPOINT_XFER_CONTROL 0 #define USB_ENDPOINT_XFER_ISOC 1@@ -390,6 +384,17 @@ struct usb_endpoint_descriptor { #define USB_ENDPOINT_XFER_INT 3 #define USB_ENDPOINT_MAX_ADJUSTABLE 0x80 +#define USB_ENDPOINT_SYNCTYPE 0x0c +#define USB_ENDPOINT_SYNC_NONE (0 << 2) +#define USB_ENDPOINT_SYNC_ASYNC (1 << 2) +#define USB_ENDPOINT_SYNC_ADAPTIVE (2 << 2) +#define USB_ENDPOINT_SYNC_SYNC (3 << 2) + +#define USB_ENDPOINT_USAGE_MASK 0x30 +#define USB_ENDPOINT_USAGE_DATA 0x00 +#define USB_ENDPOINT_USAGE_FEEDBACK 0x10 +#define USB_ENDPOINT_USAGE_IMPLICIT_FB 0x20/* Implicit feedback Data endpoint */ + /*-------------------------------------------------------------------------*/ /** -- 1.7.5.4
Greg KH
Acked-byRe: [PATCH 1/4] USB: Add endpoint usage definitions to ch9.h
Quoted 8 lines · Daniel Mack
Quoted 5 lines · Daniel Mack
The endpoint usage field is described in the USB 2.0 specification, chapter 9.6.6.
Also, move the sync type fields block down by some lines to reflect the fact that these are also stuffed in bmAttributes.
Greg - can we merge this through the ALSA tree?
Yes, please do:
PATCH 2/4 ALSA: snd-usb: re-order the Makefile
In reply to Daniel MackSort its entries in alphabetical order.
--- sound/usb/Makefile | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
sound/usb/Makefile +6 -6
@@ -3,16 +3,16 @@ # snd-usb-audio-objs := card.o \ + clock.o \ + endpoint.o \ + format.o \ + helper.o \ mixer.o \ mixer_quirks.o \ + pcm.o \ proc.o \ quirks.o \ - format.o \ - endpoint.o \ - urb.o \ - pcm.o \ - helper.o \ - clock.o + urb.o snd-usbmidi-lib-objs := midi.o
Signature · 1 line
1.7.5.4
PATCH 3/4 ALSA: snd-usb: re-order code
In reply to Daniel MackMove code from endpoint.c into a new file called stream.c and rename functions so that their names actually reflect what they're doing.
This way, endpoint.c will be available to functions that hold all the endpoint logic.
--- sound/usb/Makefile | 1 + sound/usb/card.c | 3 +- sound/usb/endpoint.c | 433 ----------------------------------------------- sound/usb/endpoint.h | 7 - sound/usb/quirks.c | 7 +- sound/usb/stream.c | 453 ++++++++++++++++++++++++++++++++++++++++++++++++++ sound/usb/stream.h | 12 ++ 7 files changed, 472 insertions(+), 444 deletions(-) create mode 100644 sound/usb/stream.c create mode 100644 sound/usb/stream.h
sound/usb/Makefile +1 -0
@@ -12,6 +12,7 @@ snd-usb-audio-objs := card.o \ pcm.o \ proc.o \ quirks.o \ + stream.o \ urb.o snd-usbmidi-lib-objs := midi.o
sound/usb/card.c +2 -1
@@ -68,6 +68,7 @@#include "urb.h" #include "format.h" #include "power.h" +#include "stream.h" MODULE_AUTHOR ("Takashi Iwai <[email protected]>" );MODULE_DESCRIPTION ("USB Audio" );
@@ -185,7 +186,7 @@ static int snd_usb_create_stream(struct snd_usb_audio *chip, int ctrlif, int intreturn -EINVAL ; } -if (!snd_usb_parse_audio_endpoints (chip, interface)) { +if (!snd_usb_parse_audio_interface (chip, interface)) {usb_set_interface (dev, interface,0 );/* reset the current interface */ usb_driver_claim_interface (&usb_audio_driver, iface, (void *)-1L );return -EINVAL ;
sound/usb/endpoint.c +0 -433
436 lines not on this page · raw message
sound/usb/endpoint.h +0 -7
@@ -1,11 +1,4 @@#ifndef __USBAUDIO_ENDPOINT_H#define __USBAUDIO_ENDPOINT_H -int snd_usb_parse_audio_endpoints (struct snd_usb_audio *chip, -int iface_no); - -int snd_usb_add_audio_endpoint (struct snd_usb_audio *chip, -int stream, -struct audioformat *fp); -#endif /* __USBAUDIO_ENDPOINT_H */
sound/usb/quirks.c +4 -3
@@ -34,6 +34,7 @@#include "endpoint.h" #include "pcm.h" #include "clock.h" +#include "stream.h" /* * handle the quirks for the contained interfaces
@@ -106,7 +107,7 @@ static int create_standard_audio_quirk(struct snd_usb_audio *chip, alts = &iface->altsetting[0 ]; altsd =get_iface_desc (alts); - err =snd_usb_parse_audio_endpoints (chip, altsd->bInterfaceNumber); + err =snd_usb_parse_audio_interface (chip, altsd->bInterfaceNumber);if (err <0 ) {snd_printk (KERN_ERR "cannot setup if %d: error %d\n" , altsd->bInterfaceNumber, err);
@@ -147,7 +148,7 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip, stream = (fp->endpoint &USB_DIR_IN ) ?SNDRV_PCM_STREAM_CAPTURE :SNDRV_PCM_STREAM_PLAYBACK ; - err =snd_usb_add_audio_endpoint (chip, stream, fp); + err =snd_usb_add_audio_stream (chip, stream, fp);if (err <0 ) {kfree (fp);kfree (rate_table);
@@ -254,7 +255,7 @@ static int create_uaxx_quirk(struct snd_usb_audio *chip, stream = (fp->endpoint &USB_DIR_IN ) ?SNDRV_PCM_STREAM_CAPTURE :SNDRV_PCM_STREAM_PLAYBACK ; - err =snd_usb_add_audio_endpoint (chip, stream, fp); + err =snd_usb_add_audio_stream (chip, stream, fp);if (err <0 ) {kfree (fp);return err;
sound/usb/stream.c new file +453 -0
453 lines not on this page · raw message
sound/usb/stream.h new file +12 -0
@@ -0,0 +1,12 @@ +#ifndef __USBAUDIO_STREAM_H +#define __USBAUDIO_STREAM_H + +int snd_usb_parse_audio_interface (struct snd_usb_audio *chip, +int iface_no); + +int snd_usb_add_audio_stream (struct snd_usb_audio *chip, +int stream, +struct audioformat *fp); + +#endif /* __USBAUDIO_STREAM_H */ +
Signature · 1 line
1.7.5.4
PATCH 4/4 ALSA: snd-usb: move code from urb.c to endpoint.c
In reply to Daniel MackNo code altered at this point, simply preparing for upcoming refactorizations.
--- sound/usb/Makefile | 3 +- sound/usb/card.c | 1 - sound/usb/endpoint.c | 924 +++++++++++++++++++++++++++++++++++++++++++++++++ sound/usb/endpoint.h | 17 + sound/usb/pcm.c | 2 +- sound/usb/stream.c | 1 - sound/usb/urb.c | 941 -------------------------------------------------- sound/usb/urb.h | 21 -- 8 files changed, 943 insertions(+), 967 deletions(-) delete mode 100644 sound/usb/urb.c delete mode 100644 sound/usb/urb.h
sound/usb/Makefile +1 -2
@@ -12,8 +12,7 @@ snd-usb-audio-objs := card.o \ pcm.o \ proc.o \ quirks.o \ - stream.o \ - urb.o + stream.o snd-usbmidi-lib-objs := midi.o
sound/usb/card.c +0 -1
@@ -65,7 +65,6 @@#include "helper.h" #include "debug.h" #include "pcm.h" -#include "urb.h" #include "format.h" #include "power.h" #include "stream.h"
sound/usb/endpoint.c +924 -0
927 lines not on this page · raw message
sound/usb/endpoint.h +17 -0
@@ -1,4 +1,21 @@#ifndef __USBAUDIO_ENDPOINT_H#define __USBAUDIO_ENDPOINT_H +void snd_usb_init_substream (struct snd_usb_stream *as, +int stream, +struct audioformat *fp); + +int snd_usb_init_substream_urbs (struct snd_usb_substream *subs, +unsigned int period_bytes, +unsigned int rate, +unsigned int frame_bits); + +void snd_usb_release_substream_urbs (struct snd_usb_substream *subs,int force); + +int snd_usb_substream_prepare (struct snd_usb_substream *subs, +struct snd_pcm_runtime *runtime); + +int snd_usb_substream_playback_trigger (struct snd_pcm_substream *substream,int cmd); +int snd_usb_substream_capture_trigger (struct snd_pcm_substream *substream,int cmd); +#endif /* __USBAUDIO_ENDPOINT_H */
sound/usb/pcm.c +1 -1
@@ -28,7 +28,7 @@#include "card.h" #include "quirks.h" #include "debug.h" -#include "urb.h" +#include "endpoint.h" #include "helper.h" #include "pcm.h" #include "clock.h"
sound/usb/stream.c +0 -1
@@ -29,7 +29,6 @@#include "proc.h" #include "quirks.h" #include "endpoint.h" -#include "urb.h" #include "pcm.h" #include "helper.h" #include "format.h"
sound/usb/urb.c deleted +0 -941
941 lines not on this page · raw message
sound/usb/urb.h deleted +0 -21
@@ -1,21 +0,0 @@ -#ifndef __USBAUDIO_URB_H -#define __USBAUDIO_URB_H - -void snd_usb_init_substream (struct snd_usb_stream *as, -int stream, -struct audioformat *fp); - -int snd_usb_init_substream_urbs (struct snd_usb_substream *subs, -unsigned int period_bytes, -unsigned int rate, -unsigned int frame_bits); - -void snd_usb_release_substream_urbs (struct snd_usb_substream *subs,int force); - -int snd_usb_substream_prepare (struct snd_usb_substream *subs, -struct snd_pcm_runtime *runtime); - -int snd_usb_substream_playback_trigger (struct snd_pcm_substream *substream,int cmd); -int snd_usb_substream_capture_trigger (struct snd_pcm_substream *substream,int cmd); - -#endif /* __USBAUDIO_URB_H */
Signature · 1 line
1.7.5.4
Re: [PATCH 4/4] ALSA: snd-usb: move code from urb.c to endpoint.c
At Mon, 12 Sep 2011 18:54:13 +0200,
Quoted 5 lines · Daniel Mack
No code altered at this point, simply preparing for upcoming refactorizations.
Signed-off-by Daniel Mack <[email protected]>
Quoted 12 lines
--- sound/usb/Makefile | 3 +- sound/usb/card.c | 1 - sound/usb/endpoint.c | 924 +++++++++++++++++++++++++++++++++++++++++++++++++ sound/usb/endpoint.h | 17 + sound/usb/pcm.c | 2 +- sound/usb/stream.c | 1 - sound/usb/urb.c | 941 -------------------------------------------------- sound/usb/urb.h | 21 -- 8 files changed, 943 insertions(+), 967 deletions(-) delete mode 100644 sound/usb/urb.c delete mode 100644 sound/usb/urb.h
This patch wasn't applied cleanly to my tree. urb.c was rejected. Could you refresh the patches based on the latest sound git tree?
git://github.com/tiwai/sound.git
The branch topic/misc should contain the latest status for USB.
thanks,
Takashi
Re: [PATCH 4/4] ALSA: snd-usb: move code from urb.c to endpoint.c
Quoted 20 lines · Takashi Iwai
At Mon, 12 Sep 2011 18:54:13 +0200,
Quoted 14 lines · Daniel Mack
No code altered at this point, simply preparing for upcoming refactorizations.
Signed-off-by Daniel Mack <[email protected]>---
sound/usb/Makefile | 3 +-
sound/usb/card.c | 1 -
sound/usb/endpoint.c | 924 +++++++++++++++++++++++++++++++++++++++++++++++++sound/usb/endpoint.h| 17 +
sound/usb/pcm.c | 2 +-
sound/usb/stream.c | 1 -
sound/usb/urb.c | 941 --------------------------------------------------sound/usb/urb.h| 21 --Quoted 3 lines
8 files changed, 943 insertions(+), 967 deletions(-)delete mode 100644
sound/usb/urb.c
delete mode 100644sound/usb/urb.h
Quoted 5 lines
This patch wasn't applied cleanly to my tree. urb.c was rejected. Could you refresh the patches based on the latest sound git tree?
git://github.com/tiwai/sound.gitThe branch topic/misc should contain the latest status for USB.
Ah, the reason for the conflict is that Pierre-Louis Bossart's delay information patch was merged before mine. New version coming up.
If that's easier, you can also pull from
git://github.com/zonque/linux-2.6.git usb-audio
Daniel
PATCH 4/4 ALSA: snd-usb: move code from urb.c to endpoint.c
In reply to Takashi IwaiNo code altered at this point, simply preparing for upcoming refactorizations.
--- sound/usb/Makefile | 3 +- sound/usb/card.c | 1 - sound/usb/endpoint.c | 948 +++++++++++++++++++++++++++++++++++++++++++++++++ sound/usb/endpoint.h | 17 + sound/usb/pcm.c | 2 +- sound/usb/stream.c | 1 - sound/usb/urb.c | 965 -------------------------------------------------- sound/usb/urb.h | 21 -- 8 files changed, 967 insertions(+), 991 deletions(-) delete mode 100644 sound/usb/urb.c delete mode 100644 sound/usb/urb.h
sound/usb/Makefile +1 -2
@@ -12,8 +12,7 @@ snd-usb-audio-objs := card.o \ pcm.o \ proc.o \ quirks.o \ - stream.o \ - urb.o + stream.o snd-usbmidi-lib-objs := midi.o
sound/usb/card.c +0 -1
@@ -65,7 +65,6 @@#include "helper.h" #include "debug.h" #include "pcm.h" -#include "urb.h" #include "format.h" #include "power.h" #include "stream.h"
sound/usb/endpoint.c +948 -0
951 lines not on this page · raw message
sound/usb/endpoint.h +17 -0
@@ -1,4 +1,21 @@#ifndef __USBAUDIO_ENDPOINT_H#define __USBAUDIO_ENDPOINT_H +void snd_usb_init_substream (struct snd_usb_stream *as, +int stream, +struct audioformat *fp); + +int snd_usb_init_substream_urbs (struct snd_usb_substream *subs, +unsigned int period_bytes, +unsigned int rate, +unsigned int frame_bits); + +void snd_usb_release_substream_urbs (struct snd_usb_substream *subs,int force); + +int snd_usb_substream_prepare (struct snd_usb_substream *subs, +struct snd_pcm_runtime *runtime); + +int snd_usb_substream_playback_trigger (struct snd_pcm_substream *substream,int cmd); +int snd_usb_substream_capture_trigger (struct snd_pcm_substream *substream,int cmd); +#endif /* __USBAUDIO_ENDPOINT_H */
sound/usb/pcm.c +1 -1
@@ -28,7 +28,7 @@#include "card.h" #include "quirks.h" #include "debug.h" -#include "urb.h" +#include "endpoint.h" #include "helper.h" #include "pcm.h" #include "clock.h"
sound/usb/stream.c +0 -1
@@ -29,7 +29,6 @@#include "proc.h" #include "quirks.h" #include "endpoint.h" -#include "urb.h" #include "pcm.h" #include "helper.h" #include "format.h"
sound/usb/urb.c deleted +0 -965
965 lines not on this page · raw message
sound/usb/urb.h deleted +0 -21
@@ -1,21 +0,0 @@ -#ifndef __USBAUDIO_URB_H -#define __USBAUDIO_URB_H - -void snd_usb_init_substream (struct snd_usb_stream *as, -int stream, -struct audioformat *fp); - -int snd_usb_init_substream_urbs (struct snd_usb_substream *subs, -unsigned int period_bytes, -unsigned int rate, -unsigned int frame_bits); - -void snd_usb_release_substream_urbs (struct snd_usb_substream *subs,int force); - -int snd_usb_substream_prepare (struct snd_usb_substream *subs, -struct snd_pcm_runtime *runtime); - -int snd_usb_substream_playback_trigger (struct snd_pcm_substream *substream,int cmd); -int snd_usb_substream_capture_trigger (struct snd_pcm_substream *substream,int cmd); - -#endif /* __USBAUDIO_URB_H */
Signature · 1 line
1.7.5.4
Re: [PATCH 4/4] ALSA: snd-usb: move code from urb.c to endpoint.c
At Wed, 14 Sep 2011 12:46:57 +0200,
Quoted 6 lines · Daniel Mack
No code altered at this point, simply preparing for upcoming refactorizations.
Signed-off-by Daniel Mack <[email protected]>Acked-by Clemens Ladisch <[email protected]>
Thanks, now applied cleanly.
Takashi
Quoted 3 lines · Daniel Mack
I prepared a subset of my work on the generic USB audio driver that doesn't actually change any logic but just moves around major chunks of code.
all four:
Quoted 8 lines · Clemens Ladisch
Quoted 3 lines · Daniel Mack
I prepared a subset of my work on the generic USB audio driver that doesn't actually change any logic but just moves around major chunks of code.
all four:
Acked-by Clemens Ladisch <[email protected]>
Takashi, are you ok with these changes?
Daniel
At Wed, 14 Sep 2011 10:27:09 +0200,
Quoted 7 lines · Daniel Mack
Quoted 5 lines · Clemens Ladisch
Quoted 3 lines · Daniel Mack
I prepared a subset of my work on the generic USB audio driver that doesn't actually change any logic but just moves around major chunks of code.
Quoted 5 lines
Quoted 3 lines
all four:
Acked-by Clemens Ladisch <[email protected]>Takashi, are you ok with these changes?
Yes, I'm fine with them. I'll ask Greg (he's around here for a conference) whether he doesn't mind changing usb/ch9.h, then apply to sound git tree.
thanks,
Takashi