1#ifndef __USBAUDIO_H
2#define __USBAUDIO_H
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28#define USB_SUBCLASS_AUDIO_CONTROL 0x01
29#define USB_SUBCLASS_AUDIO_STREAMING 0x02
30#define USB_SUBCLASS_MIDI_STREAMING 0x03
31#define USB_SUBCLASS_VENDOR_SPEC 0xff
32
33#define HEADER 0x01
34#define INPUT_TERMINAL 0x02
35#define OUTPUT_TERMINAL 0x03
36#define MIXER_UNIT 0x04
37#define SELECTOR_UNIT 0x05
38#define FEATURE_UNIT 0x06
39#define PROCESSING_UNIT 0x07
40#define EXTENSION_UNIT 0x08
41
42#define AS_GENERAL 0x01
43#define FORMAT_TYPE 0x02
44#define FORMAT_SPECIFIC 0x03
45
46#define EP_GENERAL 0x01
47
48#define MS_GENERAL 0x01
49#define MIDI_IN_JACK 0x02
50#define MIDI_OUT_JACK 0x03
51
52
53#define EP_ATTR_MASK 0x0c
54#define EP_ATTR_ASYNC 0x04
55#define EP_ATTR_ADAPTIVE 0x08
56#define EP_ATTR_SYNC 0x0c
57
58
59#define EP_CS_ATTR_SAMPLE_RATE 0x01
60#define EP_CS_ATTR_PITCH_CONTROL 0x02
61#define EP_CS_ATTR_FILL_MAX 0x80
62
63
64
65#define SET_CUR 0x01
66#define GET_CUR 0x81
67#define SET_MIN 0x02
68#define GET_MIN 0x82
69#define SET_MAX 0x03
70#define GET_MAX 0x83
71#define SET_RES 0x04
72#define GET_RES 0x84
73#define SET_MEM 0x05
74#define GET_MEM 0x85
75#define GET_STAT 0xff
76
77
78
79#define COPY_PROTECT_CONTROL 0x01
80
81
82
83#define SAMPLING_FREQ_CONTROL 0x01
84#define PITCH_CONTROL 0x02
85
86
87#define USB_FORMAT_TYPE_I 0x01
88#define USB_FORMAT_TYPE_II 0x02
89#define USB_FORMAT_TYPE_III 0x03
90
91
92#define USB_AUDIO_FORMAT_PCM 0x01
93#define USB_AUDIO_FORMAT_PCM8 0x02
94#define USB_AUDIO_FORMAT_IEEE_FLOAT 0x03
95#define USB_AUDIO_FORMAT_ALAW 0x04
96#define USB_AUDIO_FORMAT_MU_LAW 0x05
97
98
99#define USB_AUDIO_FORMAT_MPEG 0x1001
100#define USB_AUDIO_FORMAT_AC3 0x1002
101
102
103#define USB_AUDIO_FORMAT_IEC1937_AC3 0x2001
104#define USB_AUDIO_FORMAT_IEC1937_MPEG1_LAYER1 0x2002
105#define USB_AUDIO_FORMAT_IEC1937_MPEG2_NOEXT 0x2003
106#define USB_AUDIO_FORMAT_IEC1937_MPEG2_EXT 0x2004
107#define USB_AUDIO_FORMAT_IEC1937_MPEG2_LAYER1_LS 0x2005
108#define USB_AUDIO_FORMAT_IEC1937_MPEG2_LAYER23_LS 0x2006
109
110
111
112#define MIDI_MAX_ENDPOINTS 2
113
114
115#define USB_ID(vendor, product) (((vendor) << 16) | (product))
116#define USB_ID_VENDOR(id) ((id) >> 16)
117#define USB_ID_PRODUCT(id) ((u16)(id))
118
119
120
121
122struct snd_usb_audio {
123 int index;
124 struct usb_device *dev;
125 struct snd_card *card;
126 u32 usb_id;
127 int shutdown;
128 int num_interfaces;
129 int num_suspended_intf;
130
131 struct list_head pcm_list;
132 int pcm_devs;
133
134 struct list_head midi_list;
135 int next_midi_device;
136
137 struct list_head mixer_list;
138};
139
140
141
142
143
144
145#define QUIRK_NO_INTERFACE -2
146#define QUIRK_ANY_INTERFACE -1
147
148enum quirk_type {
149 QUIRK_IGNORE_INTERFACE,
150 QUIRK_COMPOSITE,
151 QUIRK_MIDI_STANDARD_INTERFACE,
152 QUIRK_MIDI_FIXED_ENDPOINT,
153 QUIRK_MIDI_YAMAHA,
154 QUIRK_MIDI_MIDIMAN,
155 QUIRK_MIDI_NOVATION,
156 QUIRK_MIDI_FASTLANE,
157 QUIRK_MIDI_EMAGIC,
158 QUIRK_MIDI_CME,
159 QUIRK_MIDI_US122L,
160 QUIRK_AUDIO_STANDARD_INTERFACE,
161 QUIRK_AUDIO_FIXED_ENDPOINT,
162 QUIRK_AUDIO_EDIROL_UA1000,
163 QUIRK_AUDIO_EDIROL_UA101,
164 QUIRK_AUDIO_EDIROL_UAXX,
165
166 QUIRK_TYPE_COUNT
167};
168
169struct snd_usb_audio_quirk {
170 const char *vendor_name;
171 const char *product_name;
172 int16_t ifnum;
173 uint16_t type;
174 const void *data;
175};
176
177
178struct snd_usb_midi_endpoint_info {
179 int8_t out_ep;
180 uint8_t out_interval;
181 int8_t in_ep;
182 uint8_t in_interval;
183 uint16_t out_cables;
184 uint16_t in_cables;
185};
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213#define combine_word(s) ((*(s)) | ((unsigned int)(s)[1] << 8))
214#define combine_triple(s) (combine_word(s) | ((unsigned int)(s)[2] << 16))
215#define combine_quad(s) (combine_triple(s) | ((unsigned int)(s)[3] << 24))
216
217unsigned int snd_usb_combine_bytes(unsigned char *bytes, int size);
218
219void *snd_usb_find_desc(void *descstart, int desclen, void *after, u8 dtype);
220void *snd_usb_find_csint_desc(void *descstart, int desclen, void *after, u8 dsubtype);
221
222int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe,
223 __u8 request, __u8 requesttype, __u16 value, __u16 index,
224 void *data, __u16 size, int timeout);
225
226int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif,
227 int ignore_error);
228void snd_usb_mixer_disconnect(struct list_head *p);
229
230int snd_usb_create_midi_interface(struct snd_usb_audio *chip, struct usb_interface *iface,
231 const struct snd_usb_audio_quirk *quirk);
232void snd_usbmidi_input_stop(struct list_head* p);
233void snd_usbmidi_input_start(struct list_head* p);
234void snd_usbmidi_disconnect(struct list_head *p);
235
236
237
238
239
240#ifndef get_iface_desc
241#define get_iface_desc(iface) (&(iface)->desc)
242#define get_endpoint(alt,ep) (&(alt)->endpoint[ep].desc)
243#define get_ep_desc(ep) (&(ep)->desc)
244#define get_cfg_desc(cfg) (&(cfg)->desc)
245#endif
246
247#ifndef snd_usb_get_speed
248#define snd_usb_get_speed(dev) ((dev)->speed)
249#endif
250
251#endif
252