]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #ifndef __USBAUDIO_H |
2 | #define __USBAUDIO_H | |
3 | /* | |
4 | * (Tentative) USB Audio Driver for ALSA | |
5 | * | |
6 | * Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de> | |
7 | * | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; either version 2 of the License, or | |
12 | * (at your option) any later version. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
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 | ||
1da177e4 LT |
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 | |
8fee4aff DM |
39 | #define PROCESSING_UNIT_V1 0x07 |
40 | #define EXTENSION_UNIT_V1 0x08 | |
41 | ||
42 | /* audio class v2 */ | |
43 | #define EFFECT_UNIT 0x07 | |
44 | #define PROCESSING_UNIT_V2 0x08 | |
45 | #define EXTENSION_UNIT_V2 0x09 | |
46 | #define CLOCK_SOURCE 0x0a | |
47 | #define CLOCK_SELECTOR 0x0b | |
48 | #define CLOCK_MULTIPLIER 0x0c | |
49 | #define SAMPLE_RATE_CONVERTER 0x0d | |
1da177e4 LT |
50 | |
51 | #define AS_GENERAL 0x01 | |
52 | #define FORMAT_TYPE 0x02 | |
53 | #define FORMAT_SPECIFIC 0x03 | |
54 | ||
55 | #define EP_GENERAL 0x01 | |
56 | ||
57 | #define MS_GENERAL 0x01 | |
58 | #define MIDI_IN_JACK 0x02 | |
59 | #define MIDI_OUT_JACK 0x03 | |
60 | ||
61 | /* endpoint attributes */ | |
62 | #define EP_ATTR_MASK 0x0c | |
63 | #define EP_ATTR_ASYNC 0x04 | |
64 | #define EP_ATTR_ADAPTIVE 0x08 | |
65 | #define EP_ATTR_SYNC 0x0c | |
66 | ||
67 | /* cs endpoint attributes */ | |
68 | #define EP_CS_ATTR_SAMPLE_RATE 0x01 | |
69 | #define EP_CS_ATTR_PITCH_CONTROL 0x02 | |
70 | #define EP_CS_ATTR_FILL_MAX 0x80 | |
71 | ||
8fee4aff | 72 | /* Audio Class specific Request Codes (v1) */ |
1da177e4 LT |
73 | |
74 | #define SET_CUR 0x01 | |
75 | #define GET_CUR 0x81 | |
76 | #define SET_MIN 0x02 | |
77 | #define GET_MIN 0x82 | |
78 | #define SET_MAX 0x03 | |
79 | #define GET_MAX 0x83 | |
80 | #define SET_RES 0x04 | |
81 | #define GET_RES 0x84 | |
82 | #define SET_MEM 0x05 | |
83 | #define GET_MEM 0x85 | |
84 | #define GET_STAT 0xff | |
85 | ||
8fee4aff DM |
86 | /* Audio Class specific Request Codes (v2) */ |
87 | #define CS_CUR 0x01 | |
88 | #define CS_RANGE 0x02 | |
89 | ||
1da177e4 LT |
90 | /* Terminal Control Selectors */ |
91 | ||
92 | #define COPY_PROTECT_CONTROL 0x01 | |
93 | ||
94 | /* Endpoint Control Selectors */ | |
95 | ||
96 | #define SAMPLING_FREQ_CONTROL 0x01 | |
97 | #define PITCH_CONTROL 0x02 | |
98 | ||
99 | /* Format Types */ | |
100 | #define USB_FORMAT_TYPE_I 0x01 | |
101 | #define USB_FORMAT_TYPE_II 0x02 | |
102 | #define USB_FORMAT_TYPE_III 0x03 | |
103 | ||
104 | /* type I */ | |
105 | #define USB_AUDIO_FORMAT_PCM 0x01 | |
106 | #define USB_AUDIO_FORMAT_PCM8 0x02 | |
107 | #define USB_AUDIO_FORMAT_IEEE_FLOAT 0x03 | |
108 | #define USB_AUDIO_FORMAT_ALAW 0x04 | |
109 | #define USB_AUDIO_FORMAT_MU_LAW 0x05 | |
110 | ||
111 | /* type II */ | |
112 | #define USB_AUDIO_FORMAT_MPEG 0x1001 | |
113 | #define USB_AUDIO_FORMAT_AC3 0x1002 | |
114 | ||
115 | /* type III */ | |
116 | #define USB_AUDIO_FORMAT_IEC1937_AC3 0x2001 | |
117 | #define USB_AUDIO_FORMAT_IEC1937_MPEG1_LAYER1 0x2002 | |
118 | #define USB_AUDIO_FORMAT_IEC1937_MPEG2_NOEXT 0x2003 | |
119 | #define USB_AUDIO_FORMAT_IEC1937_MPEG2_EXT 0x2004 | |
120 | #define USB_AUDIO_FORMAT_IEC1937_MPEG2_LAYER1_LS 0x2005 | |
121 | #define USB_AUDIO_FORMAT_IEC1937_MPEG2_LAYER23_LS 0x2006 | |
122 | ||
123 | ||
124 | /* maximum number of endpoints per interface */ | |
125 | #define MIDI_MAX_ENDPOINTS 2 | |
126 | ||
27d10f56 CL |
127 | /* handling of USB vendor/product ID pairs as 32-bit numbers */ |
128 | #define USB_ID(vendor, product) (((vendor) << 16) | (product)) | |
129 | #define USB_ID_VENDOR(id) ((id) >> 16) | |
130 | #define USB_ID_PRODUCT(id) ((u16)(id)) | |
131 | ||
1da177e4 LT |
132 | /* |
133 | */ | |
134 | ||
1da177e4 LT |
135 | struct snd_usb_audio { |
136 | int index; | |
137 | struct usb_device *dev; | |
86e07d34 | 138 | struct snd_card *card; |
27d10f56 | 139 | u32 usb_id; |
1da177e4 | 140 | int shutdown; |
98e89f60 | 141 | unsigned int txfr_quirk:1; /* Subframe boundaries on transfers */ |
1da177e4 | 142 | int num_interfaces; |
f85bf29c | 143 | int num_suspended_intf; |
1da177e4 LT |
144 | |
145 | struct list_head pcm_list; /* list of pcm streams */ | |
146 | int pcm_devs; | |
147 | ||
148 | struct list_head midi_list; /* list of midi interfaces */ | |
1da177e4 | 149 | |
84957a8a | 150 | struct list_head mixer_list; /* list of mixer interfaces */ |
1da177e4 LT |
151 | }; |
152 | ||
153 | /* | |
154 | * Information about devices with broken descriptors | |
155 | */ | |
156 | ||
157 | /* special values for .ifnum */ | |
158 | #define QUIRK_NO_INTERFACE -2 | |
159 | #define QUIRK_ANY_INTERFACE -1 | |
160 | ||
854af957 CL |
161 | enum quirk_type { |
162 | QUIRK_IGNORE_INTERFACE, | |
163 | QUIRK_COMPOSITE, | |
164 | QUIRK_MIDI_STANDARD_INTERFACE, | |
165 | QUIRK_MIDI_FIXED_ENDPOINT, | |
166 | QUIRK_MIDI_YAMAHA, | |
167 | QUIRK_MIDI_MIDIMAN, | |
168 | QUIRK_MIDI_NOVATION, | |
55de5ef9 | 169 | QUIRK_MIDI_FASTLANE, |
854af957 | 170 | QUIRK_MIDI_EMAGIC, |
cc7a59bd | 171 | QUIRK_MIDI_CME, |
030a07e4 | 172 | QUIRK_MIDI_US122L, |
854af957 CL |
173 | QUIRK_AUDIO_STANDARD_INTERFACE, |
174 | QUIRK_AUDIO_FIXED_ENDPOINT, | |
854af957 | 175 | QUIRK_AUDIO_EDIROL_UA1000, |
310e0dc0 | 176 | QUIRK_AUDIO_EDIROL_UAXX, |
52a7a583 | 177 | QUIRK_AUDIO_ALIGN_TRANSFER, |
854af957 CL |
178 | |
179 | QUIRK_TYPE_COUNT | |
180 | }; | |
1da177e4 | 181 | |
1da177e4 LT |
182 | struct snd_usb_audio_quirk { |
183 | const char *vendor_name; | |
184 | const char *product_name; | |
185 | int16_t ifnum; | |
854af957 | 186 | uint16_t type; |
1da177e4 LT |
187 | const void *data; |
188 | }; | |
189 | ||
190 | /* data for QUIRK_MIDI_FIXED_ENDPOINT */ | |
191 | struct snd_usb_midi_endpoint_info { | |
192 | int8_t out_ep; /* ep number, 0 autodetect */ | |
193 | uint8_t out_interval; /* interval for interrupt endpoints */ | |
194 | int8_t in_ep; | |
195 | uint8_t in_interval; | |
196 | uint16_t out_cables; /* bitmask */ | |
197 | uint16_t in_cables; /* bitmask */ | |
198 | }; | |
199 | ||
200 | /* for QUIRK_MIDI_YAMAHA, data is NULL */ | |
201 | ||
202 | /* for QUIRK_MIDI_MIDIMAN, data points to a snd_usb_midi_endpoint_info | |
203 | * structure (out_cables and in_cables only) */ | |
204 | ||
205 | /* for QUIRK_COMPOSITE, data points to an array of snd_usb_audio_quirk | |
206 | * structures, terminated with .ifnum = -1 */ | |
207 | ||
208 | /* for QUIRK_AUDIO_FIXED_ENDPOINT, data points to an audioformat structure */ | |
209 | ||
210 | /* for QUIRK_AUDIO/MIDI_STANDARD_INTERFACE, data is NULL */ | |
211 | ||
212 | /* for QUIRK_AUDIO_EDIROL_UA700_UA25/UA1000, data is NULL */ | |
213 | ||
214 | /* for QUIRK_IGNORE_INTERFACE, data is NULL */ | |
215 | ||
6155aff8 | 216 | /* for QUIRK_MIDI_NOVATION and _RAW, data is NULL */ |
1da177e4 LT |
217 | |
218 | /* for QUIRK_MIDI_EMAGIC, data points to a snd_usb_midi_endpoint_info | |
219 | * structure (out_cables and in_cables only) */ | |
220 | ||
cc7a59bd | 221 | /* for QUIRK_MIDI_CME, data is NULL */ |
f38275fe | 222 | |
1da177e4 LT |
223 | /* |
224 | */ | |
225 | ||
7d2b451e SK |
226 | /*E-mu USB samplerate control quirk*/ |
227 | enum { | |
228 | EMU_QUIRK_SR_44100HZ = 0, | |
229 | EMU_QUIRK_SR_48000HZ, | |
230 | EMU_QUIRK_SR_88200HZ, | |
231 | EMU_QUIRK_SR_96000HZ, | |
232 | EMU_QUIRK_SR_176400HZ, | |
233 | EMU_QUIRK_SR_192000HZ | |
234 | }; | |
235 | ||
f4950882 | 236 | #define combine_word(s) ((*(s)) | ((unsigned int)(s)[1] << 8)) |
1da177e4 LT |
237 | #define combine_triple(s) (combine_word(s) | ((unsigned int)(s)[2] << 16)) |
238 | #define combine_quad(s) (combine_triple(s) | ((unsigned int)(s)[3] << 24)) | |
239 | ||
240 | unsigned int snd_usb_combine_bytes(unsigned char *bytes, int size); | |
241 | ||
242 | void *snd_usb_find_desc(void *descstart, int desclen, void *after, u8 dtype); | |
243 | void *snd_usb_find_csint_desc(void *descstart, int desclen, void *after, u8 dsubtype); | |
244 | ||
86e07d34 TI |
245 | int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe, |
246 | __u8 request, __u8 requesttype, __u16 value, __u16 index, | |
247 | void *data, __u16 size, int timeout); | |
1da177e4 | 248 | |
7a9b8063 TI |
249 | int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif, |
250 | int ignore_error); | |
84957a8a | 251 | void snd_usb_mixer_disconnect(struct list_head *p); |
1da177e4 | 252 | |
d82af9f9 CL |
253 | int snd_usbmidi_create(struct snd_card *card, |
254 | struct usb_interface *iface, | |
255 | struct list_head *midi_list, | |
256 | const struct snd_usb_audio_quirk *quirk); | |
1da177e4 LT |
257 | void snd_usbmidi_input_stop(struct list_head* p); |
258 | void snd_usbmidi_input_start(struct list_head* p); | |
ee733397 | 259 | void snd_usbmidi_disconnect(struct list_head *p); |
1da177e4 | 260 | |
7d2b451e SK |
261 | void snd_emuusb_set_samplerate(struct snd_usb_audio *chip, |
262 | unsigned char samplerate_id); | |
263 | ||
1da177e4 LT |
264 | /* |
265 | * retrieve usb_interface descriptor from the host interface | |
266 | * (conditional for compatibility with the older API) | |
267 | */ | |
268 | #ifndef get_iface_desc | |
269 | #define get_iface_desc(iface) (&(iface)->desc) | |
270 | #define get_endpoint(alt,ep) (&(alt)->endpoint[ep].desc) | |
271 | #define get_ep_desc(ep) (&(ep)->desc) | |
272 | #define get_cfg_desc(cfg) (&(cfg)->desc) | |
273 | #endif | |
274 | ||
1da177e4 LT |
275 | #ifndef snd_usb_get_speed |
276 | #define snd_usb_get_speed(dev) ((dev)->speed) | |
277 | #endif | |
278 | ||
279 | #endif /* __USBAUDIO_H */ |