aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@skynet.be>2009-06-21 17:23:05 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-09-23 09:46:20 -0400
commit512ad27d8667158747de2e8da8a23e8f50e91856 (patch)
tree3c56c7265a1e2d7530ddb9c31806d3c1086ac6f5
parent315ad3028c8aae14891797040f855fc3291a076b (diff)
USB audio gadget: Prefix all macro definitions with UAC_ in linux/usb/audio.h
linux/usb/audio.h is a public header file that includes definitions exported to userspace. To avoid namespace clashes, prefix all macro definitions with UAC_. Existing macros and structures prefixed with USB_AC_ and USB_AS_ are renamed for consistency. Signed-off-by: Laurent Pinchart <laurent.pinchart@skynet.be> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/usb/gadget/audio.c24
-rw-r--r--drivers/usb/gadget/f_audio.c80
-rw-r--r--drivers/usb/gadget/gmidi.c8
-rw-r--r--include/linux/usb/audio.h258
4 files changed, 188 insertions, 182 deletions
diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c
index 9f80f4e970bd..a3a0f4a27ef0 100644
--- a/drivers/usb/gadget/audio.c
+++ b/drivers/usb/gadget/audio.c
@@ -106,20 +106,20 @@ static int audio_set_endpoint_req(struct usb_configuration *c,
106 ctrl->bRequest, w_value, len, ep); 106 ctrl->bRequest, w_value, len, ep);
107 107
108 switch (ctrl->bRequest) { 108 switch (ctrl->bRequest) {
109 case SET_CUR: 109 case UAC_SET_CUR:
110 value = 0; 110 value = 0;
111 break; 111 break;
112 112
113 case SET_MIN: 113 case UAC_SET_MIN:
114 break; 114 break;
115 115
116 case SET_MAX: 116 case UAC_SET_MAX:
117 break; 117 break;
118 118
119 case SET_RES: 119 case UAC_SET_RES:
120 break; 120 break;
121 121
122 case SET_MEM: 122 case UAC_SET_MEM:
123 break; 123 break;
124 124
125 default: 125 default:
@@ -142,13 +142,13 @@ static int audio_get_endpoint_req(struct usb_configuration *c,
142 ctrl->bRequest, w_value, len, ep); 142 ctrl->bRequest, w_value, len, ep);
143 143
144 switch (ctrl->bRequest) { 144 switch (ctrl->bRequest) {
145 case GET_CUR: 145 case UAC_GET_CUR:
146 case GET_MIN: 146 case UAC_GET_MIN:
147 case GET_MAX: 147 case UAC_GET_MAX:
148 case GET_RES: 148 case UAC_GET_RES:
149 value = 3; 149 value = 3;
150 break; 150 break;
151 case GET_MEM: 151 case UAC_GET_MEM:
152 break; 152 break;
153 default: 153 default:
154 break; 154 break;
@@ -171,11 +171,11 @@ audio_setup(struct usb_configuration *c, const struct usb_ctrlrequest *ctrl)
171 * Audio class messages; interface activation uses set_alt(). 171 * Audio class messages; interface activation uses set_alt().
172 */ 172 */
173 switch (ctrl->bRequestType) { 173 switch (ctrl->bRequestType) {
174 case USB_AUDIO_SET_ENDPOINT: 174 case USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_ENDPOINT:
175 value = audio_set_endpoint_req(c, ctrl); 175 value = audio_set_endpoint_req(c, ctrl);
176 break; 176 break;
177 177
178 case USB_AUDIO_GET_ENDPOINT: 178 case USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_ENDPOINT:
179 value = audio_get_endpoint_req(c, ctrl); 179 value = audio_get_endpoint_req(c, ctrl);
180 break; 180 break;
181 181
diff --git a/drivers/usb/gadget/f_audio.c b/drivers/usb/gadget/f_audio.c
index 76afbd1b515f..7b05b3c8c0b1 100644
--- a/drivers/usb/gadget/f_audio.c
+++ b/drivers/usb/gadget/f_audio.c
@@ -50,16 +50,16 @@ static struct usb_interface_descriptor ac_interface_desc __initdata = {
50 .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, 50 .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL,
51}; 51};
52 52
53DECLARE_USB_AC_HEADER_DESCRIPTOR(2); 53DECLARE_UAC_AC_HEADER_DESCRIPTOR(2);
54 54
55#define USB_DT_AC_HEADER_LENGH USB_DT_AC_HEADER_SIZE(F_AUDIO_NUM_INTERFACES) 55#define UAC_DT_AC_HEADER_LENGTH UAC_DT_AC_HEADER_SIZE(F_AUDIO_NUM_INTERFACES)
56/* B.3.2 Class-Specific AC Interface Descriptor */ 56/* B.3.2 Class-Specific AC Interface Descriptor */
57static struct usb_ac_header_descriptor_2 ac_header_desc = { 57static struct uac_ac_header_descriptor_2 ac_header_desc = {
58 .bLength = USB_DT_AC_HEADER_LENGH, 58 .bLength = UAC_DT_AC_HEADER_LENGTH,
59 .bDescriptorType = USB_DT_CS_INTERFACE, 59 .bDescriptorType = USB_DT_CS_INTERFACE,
60 .bDescriptorSubtype = HEADER, 60 .bDescriptorSubtype = UAC_HEADER,
61 .bcdADC = __constant_cpu_to_le16(0x0100), 61 .bcdADC = __constant_cpu_to_le16(0x0100),
62 .wTotalLength = __constant_cpu_to_le16(USB_DT_AC_HEADER_LENGH), 62 .wTotalLength = __constant_cpu_to_le16(UAC_DT_AC_HEADER_LENGTH),
63 .bInCollection = F_AUDIO_NUM_INTERFACES, 63 .bInCollection = F_AUDIO_NUM_INTERFACES,
64 .baInterfaceNr = { 64 .baInterfaceNr = {
65 [0] = F_AUDIO_AC_INTERFACE, 65 [0] = F_AUDIO_AC_INTERFACE,
@@ -68,33 +68,33 @@ static struct usb_ac_header_descriptor_2 ac_header_desc = {
68}; 68};
69 69
70#define INPUT_TERMINAL_ID 1 70#define INPUT_TERMINAL_ID 1
71static struct usb_input_terminal_descriptor input_terminal_desc = { 71static struct uac_input_terminal_descriptor input_terminal_desc = {
72 .bLength = USB_DT_AC_INPUT_TERMINAL_SIZE, 72 .bLength = UAC_DT_INPUT_TERMINAL_SIZE,
73 .bDescriptorType = USB_DT_CS_INTERFACE, 73 .bDescriptorType = USB_DT_CS_INTERFACE,
74 .bDescriptorSubtype = INPUT_TERMINAL, 74 .bDescriptorSubtype = UAC_INPUT_TERMINAL,
75 .bTerminalID = INPUT_TERMINAL_ID, 75 .bTerminalID = INPUT_TERMINAL_ID,
76 .wTerminalType = USB_AC_TERMINAL_STREAMING, 76 .wTerminalType = UAC_TERMINAL_STREAMING,
77 .bAssocTerminal = 0, 77 .bAssocTerminal = 0,
78 .wChannelConfig = 0x3, 78 .wChannelConfig = 0x3,
79}; 79};
80 80
81DECLARE_USB_AC_FEATURE_UNIT_DESCRIPTOR(0); 81DECLARE_UAC_FEATURE_UNIT_DESCRIPTOR(0);
82 82
83#define FEATURE_UNIT_ID 2 83#define FEATURE_UNIT_ID 2
84static struct usb_ac_feature_unit_descriptor_0 feature_unit_desc = { 84static struct uac_feature_unit_descriptor_0 feature_unit_desc = {
85 .bLength = USB_DT_AC_FEATURE_UNIT_SIZE(0), 85 .bLength = UAC_DT_FEATURE_UNIT_SIZE(0),
86 .bDescriptorType = USB_DT_CS_INTERFACE, 86 .bDescriptorType = USB_DT_CS_INTERFACE,
87 .bDescriptorSubtype = FEATURE_UNIT, 87 .bDescriptorSubtype = UAC_FEATURE_UNIT,
88 .bUnitID = FEATURE_UNIT_ID, 88 .bUnitID = FEATURE_UNIT_ID,
89 .bSourceID = INPUT_TERMINAL_ID, 89 .bSourceID = INPUT_TERMINAL_ID,
90 .bControlSize = 2, 90 .bControlSize = 2,
91 .bmaControls[0] = (FU_MUTE | FU_VOLUME), 91 .bmaControls[0] = (UAC_FU_MUTE | UAC_FU_VOLUME),
92}; 92};
93 93
94static struct usb_audio_control mute_control = { 94static struct usb_audio_control mute_control = {
95 .list = LIST_HEAD_INIT(mute_control.list), 95 .list = LIST_HEAD_INIT(mute_control.list),
96 .name = "Mute Control", 96 .name = "Mute Control",
97 .type = MUTE_CONTROL, 97 .type = UAC_MUTE_CONTROL,
98 /* Todo: add real Mute control code */ 98 /* Todo: add real Mute control code */
99 .set = generic_set_cmd, 99 .set = generic_set_cmd,
100 .get = generic_get_cmd, 100 .get = generic_get_cmd,
@@ -103,7 +103,7 @@ static struct usb_audio_control mute_control = {
103static struct usb_audio_control volume_control = { 103static struct usb_audio_control volume_control = {
104 .list = LIST_HEAD_INIT(volume_control.list), 104 .list = LIST_HEAD_INIT(volume_control.list),
105 .name = "Volume Control", 105 .name = "Volume Control",
106 .type = VOLUME_CONTROL, 106 .type = UAC_VOLUME_CONTROL,
107 /* Todo: add real Volume control code */ 107 /* Todo: add real Volume control code */
108 .set = generic_set_cmd, 108 .set = generic_set_cmd,
109 .get = generic_get_cmd, 109 .get = generic_get_cmd,
@@ -113,17 +113,17 @@ static struct usb_audio_control_selector feature_unit = {
113 .list = LIST_HEAD_INIT(feature_unit.list), 113 .list = LIST_HEAD_INIT(feature_unit.list),
114 .id = FEATURE_UNIT_ID, 114 .id = FEATURE_UNIT_ID,
115 .name = "Mute & Volume Control", 115 .name = "Mute & Volume Control",
116 .type = FEATURE_UNIT, 116 .type = UAC_FEATURE_UNIT,
117 .desc = (struct usb_descriptor_header *)&feature_unit_desc, 117 .desc = (struct usb_descriptor_header *)&feature_unit_desc,
118}; 118};
119 119
120#define OUTPUT_TERMINAL_ID 3 120#define OUTPUT_TERMINAL_ID 3
121static struct usb_output_terminal_descriptor output_terminal_desc = { 121static struct uac_output_terminal_descriptor output_terminal_desc = {
122 .bLength = USB_DT_AC_OUTPUT_TERMINAL_SIZE, 122 .bLength = UAC_DT_OUTPUT_TERMINAL_SIZE,
123 .bDescriptorType = USB_DT_CS_INTERFACE, 123 .bDescriptorType = USB_DT_CS_INTERFACE,
124 .bDescriptorSubtype = OUTPUT_TERMINAL, 124 .bDescriptorSubtype = UAC_OUTPUT_TERMINAL,
125 .bTerminalID = OUTPUT_TERMINAL_ID, 125 .bTerminalID = OUTPUT_TERMINAL_ID,
126 .wTerminalType = USB_AC_OUTPUT_TERMINAL_SPEAKER, 126 .wTerminalType = UAC_OUTPUT_TERMINAL_SPEAKER,
127 .bAssocTerminal = FEATURE_UNIT_ID, 127 .bAssocTerminal = FEATURE_UNIT_ID,
128 .bSourceID = FEATURE_UNIT_ID, 128 .bSourceID = FEATURE_UNIT_ID,
129}; 129};
@@ -148,22 +148,22 @@ static struct usb_interface_descriptor as_interface_alt_1_desc = {
148}; 148};
149 149
150/* B.4.2 Class-Specific AS Interface Descriptor */ 150/* B.4.2 Class-Specific AS Interface Descriptor */
151static struct usb_as_header_descriptor as_header_desc = { 151static struct uac_as_header_descriptor as_header_desc = {
152 .bLength = USB_DT_AS_HEADER_SIZE, 152 .bLength = UAC_DT_AS_HEADER_SIZE,
153 .bDescriptorType = USB_DT_CS_INTERFACE, 153 .bDescriptorType = USB_DT_CS_INTERFACE,
154 .bDescriptorSubtype = AS_GENERAL, 154 .bDescriptorSubtype = UAC_AS_GENERAL,
155 .bTerminalLink = INPUT_TERMINAL_ID, 155 .bTerminalLink = INPUT_TERMINAL_ID,
156 .bDelay = 1, 156 .bDelay = 1,
157 .wFormatTag = USB_AS_AUDIO_FORMAT_TYPE_I_PCM, 157 .wFormatTag = UAC_FORMAT_TYPE_I_PCM,
158}; 158};
159 159
160DECLARE_USB_AS_FORMAT_TYPE_I_DISCRETE_DESC(1); 160DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC(1);
161 161
162static struct usb_as_formate_type_i_discrete_descriptor_1 as_type_i_desc = { 162static struct uac_format_type_i_discrete_descriptor_1 as_type_i_desc = {
163 .bLength = USB_AS_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(1), 163 .bLength = UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(1),
164 .bDescriptorType = USB_DT_CS_INTERFACE, 164 .bDescriptorType = USB_DT_CS_INTERFACE,
165 .bDescriptorSubtype = FORMAT_TYPE, 165 .bDescriptorSubtype = UAC_FORMAT_TYPE,
166 .bFormatType = USB_AS_FORMAT_TYPE_I, 166 .bFormatType = UAC_FORMAT_TYPE_I,
167 .bSubframeSize = 2, 167 .bSubframeSize = 2,
168 .bBitResolution = 16, 168 .bBitResolution = 16,
169 .bSamFreqType = 1, 169 .bSamFreqType = 1,
@@ -181,10 +181,10 @@ static struct usb_endpoint_descriptor as_out_ep_desc __initdata = {
181}; 181};
182 182
183/* Class-specific AS ISO OUT Endpoint Descriptor */ 183/* Class-specific AS ISO OUT Endpoint Descriptor */
184static struct usb_as_iso_endpoint_descriptor as_iso_out_desc __initdata = { 184static struct uac_iso_endpoint_descriptor as_iso_out_desc __initdata = {
185 .bLength = USB_AS_ISO_ENDPOINT_DESC_SIZE, 185 .bLength = UAC_ISO_ENDPOINT_DESC_SIZE,
186 .bDescriptorType = USB_DT_CS_ENDPOINT, 186 .bDescriptorType = USB_DT_CS_ENDPOINT,
187 .bDescriptorSubtype = EP_GENERAL, 187 .bDescriptorSubtype = UAC_EP_GENERAL,
188 .bmAttributes = 1, 188 .bmAttributes = 1,
189 .bLockDelayUnits = 1, 189 .bLockDelayUnits = 1,
190 .wLockDelay = __constant_cpu_to_le16(1), 190 .wLockDelay = __constant_cpu_to_le16(1),
@@ -456,11 +456,11 @@ f_audio_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
456 * Audio class messages; interface activation uses set_alt(). 456 * Audio class messages; interface activation uses set_alt().
457 */ 457 */
458 switch (ctrl->bRequestType) { 458 switch (ctrl->bRequestType) {
459 case USB_AUDIO_SET_INTF: 459 case USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE:
460 value = audio_set_intf_req(f, ctrl); 460 value = audio_set_intf_req(f, ctrl);
461 break; 461 break;
462 462
463 case USB_AUDIO_GET_INTF: 463 case USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE:
464 value = audio_get_intf_req(f, ctrl); 464 value = audio_get_intf_req(f, ctrl);
465 break; 465 break;
466 466
@@ -642,10 +642,10 @@ int __init control_selector_init(struct f_audio *audio)
642 list_add(&mute_control.list, &feature_unit.control); 642 list_add(&mute_control.list, &feature_unit.control);
643 list_add(&volume_control.list, &feature_unit.control); 643 list_add(&volume_control.list, &feature_unit.control);
644 644
645 volume_control.data[_CUR] = 0xffc0; 645 volume_control.data[UAC__CUR] = 0xffc0;
646 volume_control.data[_MIN] = 0xe3a0; 646 volume_control.data[UAC__MIN] = 0xe3a0;
647 volume_control.data[_MAX] = 0xfff0; 647 volume_control.data[UAC__MAX] = 0xfff0;
648 volume_control.data[_RES] = 0x0030; 648 volume_control.data[UAC__RES] = 0x0030;
649 649
650 return 0; 650 return 0;
651} 651}
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c
index b9312dc6e041..d0b1e836f0e0 100644
--- a/drivers/usb/gadget/gmidi.c
+++ b/drivers/usb/gadget/gmidi.c
@@ -191,7 +191,7 @@ module_param(qlen, uint, S_IRUGO);
191#define GMIDI_MS_INTERFACE 1 191#define GMIDI_MS_INTERFACE 1
192#define GMIDI_NUM_INTERFACES 2 192#define GMIDI_NUM_INTERFACES 2
193 193
194DECLARE_USB_AC_HEADER_DESCRIPTOR(1); 194DECLARE_UAC_AC_HEADER_DESCRIPTOR(1);
195DECLARE_USB_MIDI_OUT_JACK_DESCRIPTOR(1); 195DECLARE_USB_MIDI_OUT_JACK_DESCRIPTOR(1);
196DECLARE_USB_MS_ENDPOINT_DESCRIPTOR(1); 196DECLARE_USB_MS_ENDPOINT_DESCRIPTOR(1);
197 197
@@ -237,12 +237,12 @@ static const struct usb_interface_descriptor ac_interface_desc = {
237}; 237};
238 238
239/* B.3.2 Class-Specific AC Interface Descriptor */ 239/* B.3.2 Class-Specific AC Interface Descriptor */
240static const struct usb_ac_header_descriptor_1 ac_header_desc = { 240static const struct uac_ac_header_descriptor_1 ac_header_desc = {
241 .bLength = USB_DT_AC_HEADER_SIZE(1), 241 .bLength = UAC_DT_AC_HEADER_SIZE(1),
242 .bDescriptorType = USB_DT_CS_INTERFACE, 242 .bDescriptorType = USB_DT_CS_INTERFACE,
243 .bDescriptorSubtype = USB_MS_HEADER, 243 .bDescriptorSubtype = USB_MS_HEADER,
244 .bcdADC = cpu_to_le16(0x0100), 244 .bcdADC = cpu_to_le16(0x0100),
245 .wTotalLength = cpu_to_le16(USB_DT_AC_HEADER_SIZE(1)), 245 .wTotalLength = cpu_to_le16(UAC_DT_AC_HEADER_SIZE(1)),
246 .bInCollection = 1, 246 .bInCollection = 1,
247 .baInterfaceNr = { 247 .baInterfaceNr = {
248 [0] = GMIDI_MS_INTERFACE, 248 [0] = GMIDI_MS_INTERFACE,
diff --git a/include/linux/usb/audio.h b/include/linux/usb/audio.h
index f75092aba02f..c3edfcb72c34 100644
--- a/include/linux/usb/audio.h
+++ b/include/linux/usb/audio.h
@@ -25,80 +25,77 @@
25#define USB_SUBCLASS_AUDIOSTREAMING 0x02 25#define USB_SUBCLASS_AUDIOSTREAMING 0x02
26#define USB_SUBCLASS_MIDISTREAMING 0x03 26#define USB_SUBCLASS_MIDISTREAMING 0x03
27 27
28/* A.5 Audio Class-Specific AC interface Descriptor Subtypes*/ 28/* A.5 Audio Class-Specific AC Interface Descriptor Subtypes */
29#define HEADER 0x01 29#define UAC_HEADER 0x01
30#define INPUT_TERMINAL 0x02 30#define UAC_INPUT_TERMINAL 0x02
31#define OUTPUT_TERMINAL 0x03 31#define UAC_OUTPUT_TERMINAL 0x03
32#define MIXER_UNIT 0x04 32#define UAC_MIXER_UNIT 0x04
33#define SELECTOR_UNIT 0x05 33#define UAC_SELECTOR_UNIT 0x05
34#define FEATURE_UNIT 0x06 34#define UAC_FEATURE_UNIT 0x06
35#define PROCESSING_UNIT 0x07 35#define UAC_PROCESSING_UNIT 0x07
36#define EXTENSION_UNIT 0x08 36#define UAC_EXTENSION_UNIT 0x08
37 37
38#define AS_GENERAL 0x01 38/* A.6 Audio Class-Specific AS Interface Descriptor Subtypes */
39#define FORMAT_TYPE 0x02 39#define UAC_AS_GENERAL 0x01
40#define FORMAT_SPECIFIC 0x03 40#define UAC_FORMAT_TYPE 0x02
41 41#define UAC_FORMAT_SPECIFIC 0x03
42#define EP_GENERAL 0x01 42
43 43/* A.8 Audio Class-Specific Endpoint Descriptor Subtypes */
44#define MS_GENERAL 0x01 44#define UAC_EP_GENERAL 0x01
45#define MIDI_IN_JACK 0x02 45
46#define MIDI_OUT_JACK 0x03 46/* A.9 Audio Class-Specific Request Codes */
47 47#define UAC_SET_ 0x00
48/* cs endpoint attributes */ 48#define UAC_GET_ 0x80
49#define EP_CS_ATTR_SAMPLE_RATE 0x01 49
50#define EP_CS_ATTR_PITCH_CONTROL 0x02 50#define UAC__CUR 0x1
51#define EP_CS_ATTR_FILL_MAX 0x80 51#define UAC__MIN 0x2
52 52#define UAC__MAX 0x3
53/* Audio Class specific Request Codes */ 53#define UAC__RES 0x4
54#define USB_AUDIO_SET_INTF 0x21 54#define UAC__MEM 0x5
55#define USB_AUDIO_SET_ENDPOINT 0x22 55
56#define USB_AUDIO_GET_INTF 0xa1 56#define UAC_SET_CUR (UAC_SET_ | UAC__CUR)
57#define USB_AUDIO_GET_ENDPOINT 0xa2 57#define UAC_GET_CUR (UAC_GET_ | UAC__CUR)
58 58#define UAC_SET_MIN (UAC_SET_ | UAC__MIN)
59#define SET_ 0x00 59#define UAC_GET_MIN (UAC_GET_ | UAC__MIN)
60#define GET_ 0x80 60#define UAC_SET_MAX (UAC_SET_ | UAC__MAX)
61 61#define UAC_GET_MAX (UAC_GET_ | UAC__MAX)
62#define _CUR 0x1 62#define UAC_SET_RES (UAC_SET_ | UAC__RES)
63#define _MIN 0x2 63#define UAC_GET_RES (UAC_GET_ | UAC__RES)
64#define _MAX 0x3 64#define UAC_SET_MEM (UAC_SET_ | UAC__MEM)
65#define _RES 0x4 65#define UAC_GET_MEM (UAC_GET_ | UAC__MEM)
66#define _MEM 0x5 66
67 67#define UAC_GET_STAT 0xff
68#define SET_CUR (SET_ | _CUR) 68
69#define GET_CUR (GET_ | _CUR) 69/* MIDI - A.1 MS Class-Specific Interface Descriptor Subtypes */
70#define SET_MIN (SET_ | _MIN) 70#define UAC_MS_HEADER 0x01
71#define GET_MIN (GET_ | _MIN) 71#define UAC_MIDI_IN_JACK 0x02
72#define SET_MAX (SET_ | _MAX) 72#define UAC_MIDI_OUT_JACK 0x03
73#define GET_MAX (GET_ | _MAX) 73
74#define SET_RES (SET_ | _RES) 74/* MIDI - A.1 MS Class-Specific Endpoint Descriptor Subtypes */
75#define GET_RES (GET_ | _RES) 75#define UAC_MS_GENERAL 0x01
76#define SET_MEM (SET_ | _MEM) 76
77#define GET_MEM (GET_ | _MEM) 77/* Terminals - 2.1 USB Terminal Types */
78 78#define UAC_TERMINAL_UNDEFINED 0x100
79#define GET_STAT 0xff 79#define UAC_TERMINAL_STREAMING 0x101
80 80#define UAC_TERMINAL_VENDOR_SPEC 0x1FF
81#define USB_AC_TERMINAL_UNDEFINED 0x100
82#define USB_AC_TERMINAL_STREAMING 0x101
83#define USB_AC_TERMINAL_VENDOR_SPEC 0x1FF
84 81
85/* Terminal Control Selectors */ 82/* Terminal Control Selectors */
86/* 4.3.2 Class-Specific AC Interface Descriptor */ 83/* 4.3.2 Class-Specific AC Interface Descriptor */
87struct usb_ac_header_descriptor { 84struct uac_ac_header_descriptor {
88 __u8 bLength; /* 8 + n */ 85 __u8 bLength; /* 8 + n */
89 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ 86 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
90 __u8 bDescriptorSubtype; /* USB_MS_HEADER */ 87 __u8 bDescriptorSubtype; /* UAC_MS_HEADER */
91 __le16 bcdADC; /* 0x0100 */ 88 __le16 bcdADC; /* 0x0100 */
92 __le16 wTotalLength; /* includes Unit and Terminal desc. */ 89 __le16 wTotalLength; /* includes Unit and Terminal desc. */
93 __u8 bInCollection; /* n */ 90 __u8 bInCollection; /* n */
94 __u8 baInterfaceNr[]; /* [n] */ 91 __u8 baInterfaceNr[]; /* [n] */
95} __attribute__ ((packed)); 92} __attribute__ ((packed));
96 93
97#define USB_DT_AC_HEADER_SIZE(n) (8 + (n)) 94#define UAC_DT_AC_HEADER_SIZE(n) (8 + (n))
98 95
99/* As above, but more useful for defining your own descriptors: */ 96/* As above, but more useful for defining your own descriptors: */
100#define DECLARE_USB_AC_HEADER_DESCRIPTOR(n) \ 97#define DECLARE_UAC_AC_HEADER_DESCRIPTOR(n) \
101struct usb_ac_header_descriptor_##n { \ 98struct uac_ac_header_descriptor_##n { \
102 __u8 bLength; \ 99 __u8 bLength; \
103 __u8 bDescriptorType; \ 100 __u8 bDescriptorType; \
104 __u8 bDescriptorSubtype; \ 101 __u8 bDescriptorSubtype; \
@@ -109,7 +106,7 @@ struct usb_ac_header_descriptor_##n { \
109} __attribute__ ((packed)) 106} __attribute__ ((packed))
110 107
111/* 4.3.2.1 Input Terminal Descriptor */ 108/* 4.3.2.1 Input Terminal Descriptor */
112struct usb_input_terminal_descriptor { 109struct uac_input_terminal_descriptor {
113 __u8 bLength; /* in bytes: 12 */ 110 __u8 bLength; /* in bytes: 12 */
114 __u8 bDescriptorType; /* CS_INTERFACE descriptor type */ 111 __u8 bDescriptorType; /* CS_INTERFACE descriptor type */
115 __u8 bDescriptorSubtype; /* INPUT_TERMINAL descriptor subtype */ 112 __u8 bDescriptorSubtype; /* INPUT_TERMINAL descriptor subtype */
@@ -122,18 +119,19 @@ struct usb_input_terminal_descriptor {
122 __u8 iTerminal; 119 __u8 iTerminal;
123} __attribute__ ((packed)); 120} __attribute__ ((packed));
124 121
125#define USB_DT_AC_INPUT_TERMINAL_SIZE 12 122#define UAC_DT_INPUT_TERMINAL_SIZE 12
126 123
127#define USB_AC_INPUT_TERMINAL_UNDEFINED 0x200 124/* Terminals - 2.2 Input Terminal Types */
128#define USB_AC_INPUT_TERMINAL_MICROPHONE 0x201 125#define UAC_INPUT_TERMINAL_UNDEFINED 0x200
129#define USB_AC_INPUT_TERMINAL_DESKTOP_MICROPHONE 0x202 126#define UAC_INPUT_TERMINAL_MICROPHONE 0x201
130#define USB_AC_INPUT_TERMINAL_PERSONAL_MICROPHONE 0x203 127#define UAC_INPUT_TERMINAL_DESKTOP_MICROPHONE 0x202
131#define USB_AC_INPUT_TERMINAL_OMNI_DIR_MICROPHONE 0x204 128#define UAC_INPUT_TERMINAL_PERSONAL_MICROPHONE 0x203
132#define USB_AC_INPUT_TERMINAL_MICROPHONE_ARRAY 0x205 129#define UAC_INPUT_TERMINAL_OMNI_DIR_MICROPHONE 0x204
133#define USB_AC_INPUT_TERMINAL_PROC_MICROPHONE_ARRAY 0x206 130#define UAC_INPUT_TERMINAL_MICROPHONE_ARRAY 0x205
131#define UAC_INPUT_TERMINAL_PROC_MICROPHONE_ARRAY 0x206
134 132
135/* 4.3.2.2 Output Terminal Descriptor */ 133/* 4.3.2.2 Output Terminal Descriptor */
136struct usb_output_terminal_descriptor { 134struct uac_output_terminal_descriptor {
137 __u8 bLength; /* in bytes: 9 */ 135 __u8 bLength; /* in bytes: 9 */
138 __u8 bDescriptorType; /* CS_INTERFACE descriptor type */ 136 __u8 bDescriptorType; /* CS_INTERFACE descriptor type */
139 __u8 bDescriptorSubtype; /* OUTPUT_TERMINAL descriptor subtype */ 137 __u8 bDescriptorSubtype; /* OUTPUT_TERMINAL descriptor subtype */
@@ -144,23 +142,24 @@ struct usb_output_terminal_descriptor {
144 __u8 iTerminal; 142 __u8 iTerminal;
145} __attribute__ ((packed)); 143} __attribute__ ((packed));
146 144
147#define USB_DT_AC_OUTPUT_TERMINAL_SIZE 9 145#define UAC_DT_OUTPUT_TERMINAL_SIZE 9
148 146
149#define USB_AC_OUTPUT_TERMINAL_UNDEFINED 0x300 147/* Terminals - 2.3 Output Terminal Types */
150#define USB_AC_OUTPUT_TERMINAL_SPEAKER 0x301 148#define UAC_OUTPUT_TERMINAL_UNDEFINED 0x300
151#define USB_AC_OUTPUT_TERMINAL_HEADPHONES 0x302 149#define UAC_OUTPUT_TERMINAL_SPEAKER 0x301
152#define USB_AC_OUTPUT_TERMINAL_HEAD_MOUNTED_DISPLAY_AUDIO 0x303 150#define UAC_OUTPUT_TERMINAL_HEADPHONES 0x302
153#define USB_AC_OUTPUT_TERMINAL_DESKTOP_SPEAKER 0x304 151#define UAC_OUTPUT_TERMINAL_HEAD_MOUNTED_DISPLAY_AUDIO 0x303
154#define USB_AC_OUTPUT_TERMINAL_ROOM_SPEAKER 0x305 152#define UAC_OUTPUT_TERMINAL_DESKTOP_SPEAKER 0x304
155#define USB_AC_OUTPUT_TERMINAL_COMMUNICATION_SPEAKER 0x306 153#define UAC_OUTPUT_TERMINAL_ROOM_SPEAKER 0x305
156#define USB_AC_OUTPUT_TERMINAL_LOW_FREQ_EFFECTS_SPEAKER 0x307 154#define UAC_OUTPUT_TERMINAL_COMMUNICATION_SPEAKER 0x306
155#define UAC_OUTPUT_TERMINAL_LOW_FREQ_EFFECTS_SPEAKER 0x307
157 156
158/* Set bControlSize = 2 as default setting */ 157/* Set bControlSize = 2 as default setting */
159#define USB_DT_AC_FEATURE_UNIT_SIZE(ch) (7 + ((ch) + 1) * 2) 158#define UAC_DT_FEATURE_UNIT_SIZE(ch) (7 + ((ch) + 1) * 2)
160 159
161/* As above, but more useful for defining your own descriptors: */ 160/* As above, but more useful for defining your own descriptors: */
162#define DECLARE_USB_AC_FEATURE_UNIT_DESCRIPTOR(ch) \ 161#define DECLARE_UAC_FEATURE_UNIT_DESCRIPTOR(ch) \
163struct usb_ac_feature_unit_descriptor_##ch { \ 162struct uac_feature_unit_descriptor_##ch { \
164 __u8 bLength; \ 163 __u8 bLength; \
165 __u8 bDescriptorType; \ 164 __u8 bDescriptorType; \
166 __u8 bDescriptorSubtype; \ 165 __u8 bDescriptorSubtype; \
@@ -172,7 +171,7 @@ struct usb_ac_feature_unit_descriptor_##ch { \
172} __attribute__ ((packed)) 171} __attribute__ ((packed))
173 172
174/* 4.5.2 Class-Specific AS Interface Descriptor */ 173/* 4.5.2 Class-Specific AS Interface Descriptor */
175struct usb_as_header_descriptor { 174struct uac_as_header_descriptor {
176 __u8 bLength; /* in bytes: 7 */ 175 __u8 bLength; /* in bytes: 7 */
177 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ 176 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
178 __u8 bDescriptorSubtype; /* AS_GENERAL */ 177 __u8 bDescriptorSubtype; /* AS_GENERAL */
@@ -181,16 +180,17 @@ struct usb_as_header_descriptor {
181 __le16 wFormatTag; /* The Audio Data Format */ 180 __le16 wFormatTag; /* The Audio Data Format */
182} __attribute__ ((packed)); 181} __attribute__ ((packed));
183 182
184#define USB_DT_AS_HEADER_SIZE 7 183#define UAC_DT_AS_HEADER_SIZE 7
185 184
186#define USB_AS_AUDIO_FORMAT_TYPE_I_UNDEFINED 0x0 185/* Formats - A.1.1 Audio Data Format Type I Codes */
187#define USB_AS_AUDIO_FORMAT_TYPE_I_PCM 0x1 186#define UAC_FORMAT_TYPE_I_UNDEFINED 0x0
188#define USB_AS_AUDIO_FORMAT_TYPE_I_PCM8 0x2 187#define UAC_FORMAT_TYPE_I_PCM 0x1
189#define USB_AS_AUDIO_FORMAT_TYPE_I_IEEE_FLOAT 0x3 188#define UAC_FORMAT_TYPE_I_PCM8 0x2
190#define USB_AS_AUDIO_FORMAT_TYPE_I_ALAW 0x4 189#define UAC_FORMAT_TYPE_I_IEEE_FLOAT 0x3
191#define USB_AS_AUDIO_FORMAT_TYPE_I_MULAW 0x5 190#define UAC_FORMAT_TYPE_I_ALAW 0x4
191#define UAC_FORMAT_TYPE_I_MULAW 0x5
192 192
193struct usb_as_format_type_i_continuous_descriptor { 193struct uac_format_type_i_continuous_descriptor {
194 __u8 bLength; /* in bytes: 8 + (ns * 3) */ 194 __u8 bLength; /* in bytes: 8 + (ns * 3) */
195 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ 195 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
196 __u8 bDescriptorSubtype; /* FORMAT_TYPE */ 196 __u8 bDescriptorSubtype; /* FORMAT_TYPE */
@@ -203,9 +203,9 @@ struct usb_as_format_type_i_continuous_descriptor {
203 __u8 tUpperSamFreq[3]; 203 __u8 tUpperSamFreq[3];
204} __attribute__ ((packed)); 204} __attribute__ ((packed));
205 205
206#define USB_AS_FORMAT_TYPE_I_CONTINUOUS_DESC_SIZE 14 206#define UAC_FORMAT_TYPE_I_CONTINUOUS_DESC_SIZE 14
207 207
208struct usb_as_formate_type_i_discrete_descriptor { 208struct uac_format_type_i_discrete_descriptor {
209 __u8 bLength; /* in bytes: 8 + (ns * 3) */ 209 __u8 bLength; /* in bytes: 8 + (ns * 3) */
210 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ 210 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
211 __u8 bDescriptorSubtype; /* FORMAT_TYPE */ 211 __u8 bDescriptorSubtype; /* FORMAT_TYPE */
@@ -217,8 +217,8 @@ struct usb_as_formate_type_i_discrete_descriptor {
217 __u8 tSamFreq[][3]; 217 __u8 tSamFreq[][3];
218} __attribute__ ((packed)); 218} __attribute__ ((packed));
219 219
220#define DECLARE_USB_AS_FORMAT_TYPE_I_DISCRETE_DESC(n) \ 220#define DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC(n) \
221struct usb_as_formate_type_i_discrete_descriptor_##n { \ 221struct uac_format_type_i_discrete_descriptor_##n { \
222 __u8 bLength; \ 222 __u8 bLength; \
223 __u8 bDescriptorType; \ 223 __u8 bDescriptorType; \
224 __u8 bDescriptorSubtype; \ 224 __u8 bDescriptorSubtype; \
@@ -230,14 +230,15 @@ struct usb_as_formate_type_i_discrete_descriptor_##n { \
230 __u8 tSamFreq[n][3]; \ 230 __u8 tSamFreq[n][3]; \
231} __attribute__ ((packed)) 231} __attribute__ ((packed))
232 232
233#define USB_AS_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#define USB_AS_FORMAT_TYPE_UNDEFINED 0x0 235/* Formats - A.2 Format Type Codes */
236#define USB_AS_FORMAT_TYPE_I 0x1 236#define UAC_FORMAT_TYPE_UNDEFINED 0x0
237#define USB_AS_FORMAT_TYPE_II 0x2 237#define UAC_FORMAT_TYPE_I 0x1
238#define USB_AS_FORMAT_TYPE_III 0x3 238#define UAC_FORMAT_TYPE_II 0x2
239#define UAC_FORMAT_TYPE_III 0x3
239 240
240struct usb_as_iso_endpoint_descriptor { 241struct uac_iso_endpoint_descriptor {
241 __u8 bLength; /* in bytes: 7 */ 242 __u8 bLength; /* in bytes: 7 */
242 __u8 bDescriptorType; /* USB_DT_CS_ENDPOINT */ 243 __u8 bDescriptorType; /* USB_DT_CS_ENDPOINT */
243 __u8 bDescriptorSubtype; /* EP_GENERAL */ 244 __u8 bDescriptorSubtype; /* EP_GENERAL */
@@ -245,30 +246,35 @@ struct usb_as_iso_endpoint_descriptor {
245 __u8 bLockDelayUnits; 246 __u8 bLockDelayUnits;
246 __le16 wLockDelay; 247 __le16 wLockDelay;
247}; 248};
248#define USB_AS_ISO_ENDPOINT_DESC_SIZE 7 249#define UAC_ISO_ENDPOINT_DESC_SIZE 7
249 250
250#define FU_CONTROL_UNDEFINED 0x00 251#define UAC_EP_CS_ATTR_SAMPLE_RATE 0x01
251#define MUTE_CONTROL 0x01 252#define UAC_EP_CS_ATTR_PITCH_CONTROL 0x02
252#define VOLUME_CONTROL 0x02 253#define UAC_EP_CS_ATTR_FILL_MAX 0x80
253#define BASS_CONTROL 0x03 254
254#define MID_CONTROL 0x04 255/* A.10.2 Feature Unit Control Selectors */
255#define TREBLE_CONTROL 0x05 256#define UAC_FU_CONTROL_UNDEFINED 0x00
256#define GRAPHIC_EQUALIZER_CONTROL 0x06 257#define UAC_MUTE_CONTROL 0x01
257#define AUTOMATIC_GAIN_CONTROL 0x07 258#define UAC_VOLUME_CONTROL 0x02
258#define DELAY_CONTROL 0x08 259#define UAC_BASS_CONTROL 0x03
259#define BASS_BOOST_CONTROL 0x09 260#define UAC_MID_CONTROL 0x04
260#define LOUDNESS_CONTROL 0x0a 261#define UAC_TREBLE_CONTROL 0x05
261 262#define UAC_GRAPHIC_EQUALIZER_CONTROL 0x06
262#define FU_MUTE (1 << (MUTE_CONTROL - 1)) 263#define UAC_AUTOMATIC_GAIN_CONTROL 0x07
263#define FU_VOLUME (1 << (VOLUME_CONTROL - 1)) 264#define UAC_DELAY_CONTROL 0x08
264#define FU_BASS (1 << (BASS_CONTROL - 1)) 265#define UAC_BASS_BOOST_CONTROL 0x09
265#define FU_MID (1 << (MID_CONTROL - 1)) 266#define UAC_LOUDNESS_CONTROL 0x0a
266#define FU_TREBLE (1 << (TREBLE_CONTROL - 1)) 267
267#define FU_GRAPHIC_EQ (1 << (GRAPHIC_EQUALIZER_CONTROL - 1)) 268#define UAC_FU_MUTE (1 << (UAC_MUTE_CONTROL - 1))
268#define FU_AUTO_GAIN (1 << (AUTOMATIC_GAIN_CONTROL - 1)) 269#define UAC_FU_VOLUME (1 << (UAC_VOLUME_CONTROL - 1))
269#define FU_DELAY (1 << (DELAY_CONTROL - 1)) 270#define UAC_FU_BASS (1 << (UAC_BASS_CONTROL - 1))
270#define FU_BASS_BOOST (1 << (BASS_BOOST_CONTROL - 1)) 271#define UAC_FU_MID (1 << (UAC_MID_CONTROL - 1))
271#define FU_LOUDNESS (1 << (LOUDNESS_CONTROL - 1)) 272#define UAC_FU_TREBLE (1 << (UAC_TREBLE_CONTROL - 1))
273#define UAC_FU_GRAPHIC_EQ (1 << (UAC_GRAPHIC_EQUALIZER_CONTROL - 1))
274#define UAC_FU_AUTO_GAIN (1 << (UAC_AUTOMATIC_GAIN_CONTROL - 1))
275#define UAC_FU_DELAY (1 << (UAC_DELAY_CONTROL - 1))
276#define UAC_FU_BASS_BOOST (1 << (UAC_BASS_BOOST_CONTROL - 1))
277#define UAC_FU_LOUDNESS (1 << (UAC_LOUDNESS_CONTROL - 1))
272 278
273struct usb_audio_control { 279struct usb_audio_control {
274 struct list_head list; 280 struct list_head list;