aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDaniel Mack <daniel@caiaq.de>2010-02-22 17:49:09 -0500
committerTakashi Iwai <tiwai@suse.de>2010-02-23 02:40:12 -0500
commit28e1b773083d349d5223f586a39fa30f5d0f1c36 (patch)
tree4793eb1d87a094cf3642600ac3b201f81bab7e54 /include
parent40717382e0c1f572553e4fdefb489db4b95a5e7e (diff)
ALSA: usbaudio: parse USB descriptors with structs
In preparation of support for v2.0 audio class, use the structs from linux/usb/audio.h and add some new ones to describe the fields that are actually parsed by the descriptor decoders. Also, factor out code from usb_create_streams(). This makes it easier to adopt the new iteration logic needed for v2.0. Signed-off-by: Daniel Mack <daniel@caiaq.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'include')
-rw-r--r--include/linux/usb/audio.h32
1 files changed, 28 insertions, 4 deletions
diff --git a/include/linux/usb/audio.h b/include/linux/usb/audio.h
index eaf9dffe0a01..44f82d8e09c5 100644
--- a/include/linux/usb/audio.h
+++ b/include/linux/usb/audio.h
@@ -81,7 +81,7 @@
81 81
82/* Terminal Control Selectors */ 82/* Terminal Control Selectors */
83/* 4.3.2 Class-Specific AC Interface Descriptor */ 83/* 4.3.2 Class-Specific AC Interface Descriptor */
84struct uac_ac_header_descriptor { 84struct uac_ac_header_descriptor_v1 {
85 __u8 bLength; /* 8 + n */ 85 __u8 bLength; /* 8 + n */
86 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ 86 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
87 __u8 bDescriptorSubtype; /* UAC_MS_HEADER */ 87 __u8 bDescriptorSubtype; /* UAC_MS_HEADER */
@@ -95,7 +95,7 @@ struct uac_ac_header_descriptor {
95 95
96/* As above, but more useful for defining your own descriptors: */ 96/* As above, but more useful for defining your own descriptors: */
97#define DECLARE_UAC_AC_HEADER_DESCRIPTOR(n) \ 97#define DECLARE_UAC_AC_HEADER_DESCRIPTOR(n) \
98struct uac_ac_header_descriptor_##n { \ 98struct uac_ac_header_descriptor_v1_##n { \
99 __u8 bLength; \ 99 __u8 bLength; \
100 __u8 bDescriptorType; \ 100 __u8 bDescriptorType; \
101 __u8 bDescriptorSubtype; \ 101 __u8 bDescriptorSubtype; \
@@ -131,7 +131,7 @@ struct uac_input_terminal_descriptor {
131#define UAC_INPUT_TERMINAL_PROC_MICROPHONE_ARRAY 0x206 131#define UAC_INPUT_TERMINAL_PROC_MICROPHONE_ARRAY 0x206
132 132
133/* 4.3.2.2 Output Terminal Descriptor */ 133/* 4.3.2.2 Output Terminal Descriptor */
134struct uac_output_terminal_descriptor { 134struct uac_output_terminal_descriptor_v1 {
135 __u8 bLength; /* in bytes: 9 */ 135 __u8 bLength; /* in bytes: 9 */
136 __u8 bDescriptorType; /* CS_INTERFACE descriptor type */ 136 __u8 bDescriptorType; /* CS_INTERFACE descriptor type */
137 __u8 bDescriptorSubtype; /* OUTPUT_TERMINAL descriptor subtype */ 137 __u8 bDescriptorSubtype; /* OUTPUT_TERMINAL descriptor subtype */
@@ -171,7 +171,7 @@ struct uac_feature_unit_descriptor_##ch { \
171} __attribute__ ((packed)) 171} __attribute__ ((packed))
172 172
173/* 4.5.2 Class-Specific AS Interface Descriptor */ 173/* 4.5.2 Class-Specific AS Interface Descriptor */
174struct uac_as_header_descriptor { 174struct uac_as_header_descriptor_v1 {
175 __u8 bLength; /* in bytes: 7 */ 175 __u8 bLength; /* in bytes: 7 */
176 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ 176 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
177 __u8 bDescriptorSubtype; /* AS_GENERAL */ 177 __u8 bDescriptorSubtype; /* AS_GENERAL */
@@ -232,6 +232,19 @@ struct uac_format_type_i_discrete_descriptor_##n { \
232 232
233#define UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(n) (8 + (n * 3)) 233#define UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(n) (8 + (n * 3))
234 234
235/* Formats - Audio Data Format Type I Codes */
236
237struct uac_format_type_ii_discrete_descriptor {
238 __u8 bLength;
239 __u8 bDescriptorType;
240 __u8 bDescriptorSubtype;
241 __u8 bFormatType;
242 __le16 wMaxBitRate;
243 __le16 wSamplesPerFrame;
244 __u8 bSamFreqType;
245 __u8 tSamFreq[][3];
246} __attribute__((packed));
247
235/* Formats - A.2 Format Type Codes */ 248/* Formats - A.2 Format Type Codes */
236#define UAC_FORMAT_TYPE_UNDEFINED 0x0 249#define UAC_FORMAT_TYPE_UNDEFINED 0x0
237#define UAC_FORMAT_TYPE_I 0x1 250#define UAC_FORMAT_TYPE_I 0x1
@@ -253,6 +266,17 @@ struct uac_iso_endpoint_descriptor {
253#define UAC_EP_CS_ATTR_FILL_MAX 0x80 266#define UAC_EP_CS_ATTR_FILL_MAX 0x80
254 267
255/* A.10.2 Feature Unit Control Selectors */ 268/* A.10.2 Feature Unit Control Selectors */
269
270struct uac_feature_unit_descriptor {
271 __u8 bLength;
272 __u8 bDescriptorType;
273 __u8 bDescriptorSubtype;
274 __u8 bUnitID;
275 __u8 bSourceID;
276 __u8 bControlSize;
277 __u8 controls[0]; /* variable length */
278} __attribute__((packed));
279
256#define UAC_FU_CONTROL_UNDEFINED 0x00 280#define UAC_FU_CONTROL_UNDEFINED 0x00
257#define UAC_MUTE_CONTROL 0x01 281#define UAC_MUTE_CONTROL 0x01
258#define UAC_VOLUME_CONTROL 0x02 282#define UAC_VOLUME_CONTROL 0x02