]>
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 | ||
33 | #define CS_AUDIO_UNDEFINED 0x20 | |
34 | #define CS_AUDIO_DEVICE 0x21 | |
35 | #define CS_AUDIO_CONFIGURATION 0x22 | |
36 | #define CS_AUDIO_STRING 0x23 | |
37 | #define CS_AUDIO_INTERFACE 0x24 | |
38 | #define CS_AUDIO_ENDPOINT 0x25 | |
39 | ||
40 | #define HEADER 0x01 | |
41 | #define INPUT_TERMINAL 0x02 | |
42 | #define OUTPUT_TERMINAL 0x03 | |
43 | #define MIXER_UNIT 0x04 | |
44 | #define SELECTOR_UNIT 0x05 | |
45 | #define FEATURE_UNIT 0x06 | |
46 | #define PROCESSING_UNIT 0x07 | |
47 | #define EXTENSION_UNIT 0x08 | |
48 | ||
49 | #define AS_GENERAL 0x01 | |
50 | #define FORMAT_TYPE 0x02 | |
51 | #define FORMAT_SPECIFIC 0x03 | |
52 | ||
53 | #define EP_GENERAL 0x01 | |
54 | ||
55 | #define MS_GENERAL 0x01 | |
56 | #define MIDI_IN_JACK 0x02 | |
57 | #define MIDI_OUT_JACK 0x03 | |
58 | ||
59 | /* endpoint attributes */ | |
60 | #define EP_ATTR_MASK 0x0c | |
61 | #define EP_ATTR_ASYNC 0x04 | |
62 | #define EP_ATTR_ADAPTIVE 0x08 | |
63 | #define EP_ATTR_SYNC 0x0c | |
64 | ||
65 | /* cs endpoint attributes */ | |
66 | #define EP_CS_ATTR_SAMPLE_RATE 0x01 | |
67 | #define EP_CS_ATTR_PITCH_CONTROL 0x02 | |
68 | #define EP_CS_ATTR_FILL_MAX 0x80 | |
69 | ||
70 | /* Audio Class specific Request Codes */ | |
71 | ||
72 | #define SET_CUR 0x01 | |
73 | #define GET_CUR 0x81 | |
74 | #define SET_MIN 0x02 | |
75 | #define GET_MIN 0x82 | |
76 | #define SET_MAX 0x03 | |
77 | #define GET_MAX 0x83 | |
78 | #define SET_RES 0x04 | |
79 | #define GET_RES 0x84 | |
80 | #define SET_MEM 0x05 | |
81 | #define GET_MEM 0x85 | |
82 | #define GET_STAT 0xff | |
83 | ||
84 | /* Terminal Control Selectors */ | |
85 | ||
86 | #define COPY_PROTECT_CONTROL 0x01 | |
87 | ||
88 | /* Endpoint Control Selectors */ | |
89 | ||
90 | #define SAMPLING_FREQ_CONTROL 0x01 | |
91 | #define PITCH_CONTROL 0x02 | |
92 | ||
93 | /* Format Types */ | |
94 | #define USB_FORMAT_TYPE_I 0x01 | |
95 | #define USB_FORMAT_TYPE_II 0x02 | |
96 | #define USB_FORMAT_TYPE_III 0x03 | |
97 | ||
98 | /* type I */ | |
99 | #define USB_AUDIO_FORMAT_PCM 0x01 | |
100 | #define USB_AUDIO_FORMAT_PCM8 0x02 | |
101 | #define USB_AUDIO_FORMAT_IEEE_FLOAT 0x03 | |
102 | #define USB_AUDIO_FORMAT_ALAW 0x04 | |
103 | #define USB_AUDIO_FORMAT_MU_LAW 0x05 | |
104 | ||
105 | /* type II */ | |
106 | #define USB_AUDIO_FORMAT_MPEG 0x1001 | |
107 | #define USB_AUDIO_FORMAT_AC3 0x1002 | |
108 | ||
109 | /* type III */ | |
110 | #define USB_AUDIO_FORMAT_IEC1937_AC3 0x2001 | |
111 | #define USB_AUDIO_FORMAT_IEC1937_MPEG1_LAYER1 0x2002 | |
112 | #define USB_AUDIO_FORMAT_IEC1937_MPEG2_NOEXT 0x2003 | |
113 | #define USB_AUDIO_FORMAT_IEC1937_MPEG2_EXT 0x2004 | |
114 | #define USB_AUDIO_FORMAT_IEC1937_MPEG2_LAYER1_LS 0x2005 | |
115 | #define USB_AUDIO_FORMAT_IEC1937_MPEG2_LAYER23_LS 0x2006 | |
116 | ||
117 | ||
118 | /* maximum number of endpoints per interface */ | |
119 | #define MIDI_MAX_ENDPOINTS 2 | |
120 | ||
27d10f56 CL |
121 | /* handling of USB vendor/product ID pairs as 32-bit numbers */ |
122 | #define USB_ID(vendor, product) (((vendor) << 16) | (product)) | |
123 | #define USB_ID_VENDOR(id) ((id) >> 16) | |
124 | #define USB_ID_PRODUCT(id) ((u16)(id)) | |
125 | ||
1da177e4 LT |
126 | /* |
127 | */ | |
128 | ||
129 | typedef struct snd_usb_audio snd_usb_audio_t; | |
130 | ||
131 | struct snd_usb_audio { | |
132 | int index; | |
133 | struct usb_device *dev; | |
134 | snd_card_t *card; | |
27d10f56 | 135 | u32 usb_id; |
1da177e4 LT |
136 | int shutdown; |
137 | int num_interfaces; | |
138 | ||
139 | struct list_head pcm_list; /* list of pcm streams */ | |
140 | int pcm_devs; | |
141 | ||
142 | struct list_head midi_list; /* list of midi interfaces */ | |
143 | int next_midi_device; | |
144 | ||
84957a8a | 145 | struct list_head mixer_list; /* list of mixer interfaces */ |
1da177e4 LT |
146 | }; |
147 | ||
148 | /* | |
149 | * Information about devices with broken descriptors | |
150 | */ | |
151 | ||
152 | /* special values for .ifnum */ | |
153 | #define QUIRK_NO_INTERFACE -2 | |
154 | #define QUIRK_ANY_INTERFACE -1 | |
155 | ||
156 | /* quirk type */ | |
157 | #define QUIRK_MIDI_FIXED_ENDPOINT 0 | |
158 | #define QUIRK_MIDI_YAMAHA 1 | |
159 | #define QUIRK_MIDI_MIDIMAN 2 | |
160 | #define QUIRK_COMPOSITE 3 | |
161 | #define QUIRK_AUDIO_FIXED_ENDPOINT 4 | |
162 | #define QUIRK_AUDIO_STANDARD_INTERFACE 5 | |
163 | #define QUIRK_MIDI_STANDARD_INTERFACE 6 | |
164 | #define QUIRK_AUDIO_EDIROL_UA700_UA25 7 | |
165 | #define QUIRK_AUDIO_EDIROL_UA1000 8 | |
166 | #define QUIRK_IGNORE_INTERFACE 9 | |
167 | #define QUIRK_MIDI_NOVATION 10 | |
6155aff8 | 168 | #define QUIRK_MIDI_RAW 11 |
1da177e4 | 169 | #define QUIRK_MIDI_EMAGIC 12 |
f38275fe | 170 | #define QUIRK_MIDI_MIDITECH 13 |
1da177e4 LT |
171 | |
172 | typedef struct snd_usb_audio_quirk snd_usb_audio_quirk_t; | |
173 | typedef struct snd_usb_midi_endpoint_info snd_usb_midi_endpoint_info_t; | |
174 | ||
175 | struct snd_usb_audio_quirk { | |
176 | const char *vendor_name; | |
177 | const char *product_name; | |
178 | int16_t ifnum; | |
179 | int16_t type; | |
180 | const void *data; | |
181 | }; | |
182 | ||
183 | /* data for QUIRK_MIDI_FIXED_ENDPOINT */ | |
184 | struct snd_usb_midi_endpoint_info { | |
185 | int8_t out_ep; /* ep number, 0 autodetect */ | |
186 | uint8_t out_interval; /* interval for interrupt endpoints */ | |
187 | int8_t in_ep; | |
188 | uint8_t in_interval; | |
189 | uint16_t out_cables; /* bitmask */ | |
190 | uint16_t in_cables; /* bitmask */ | |
191 | }; | |
192 | ||
193 | /* for QUIRK_MIDI_YAMAHA, data is NULL */ | |
194 | ||
195 | /* for QUIRK_MIDI_MIDIMAN, data points to a snd_usb_midi_endpoint_info | |
196 | * structure (out_cables and in_cables only) */ | |
197 | ||
198 | /* for QUIRK_COMPOSITE, data points to an array of snd_usb_audio_quirk | |
199 | * structures, terminated with .ifnum = -1 */ | |
200 | ||
201 | /* for QUIRK_AUDIO_FIXED_ENDPOINT, data points to an audioformat structure */ | |
202 | ||
203 | /* for QUIRK_AUDIO/MIDI_STANDARD_INTERFACE, data is NULL */ | |
204 | ||
205 | /* for QUIRK_AUDIO_EDIROL_UA700_UA25/UA1000, data is NULL */ | |
206 | ||
207 | /* for QUIRK_IGNORE_INTERFACE, data is NULL */ | |
208 | ||
6155aff8 | 209 | /* for QUIRK_MIDI_NOVATION and _RAW, data is NULL */ |
1da177e4 LT |
210 | |
211 | /* for QUIRK_MIDI_EMAGIC, data points to a snd_usb_midi_endpoint_info | |
212 | * structure (out_cables and in_cables only) */ | |
213 | ||
f38275fe CL |
214 | /* for QUIRK_MIDI_MIDITECH, data is NULL */ |
215 | ||
1da177e4 LT |
216 | /* |
217 | */ | |
218 | ||
219 | #define combine_word(s) ((*s) | ((unsigned int)(s)[1] << 8)) | |
220 | #define combine_triple(s) (combine_word(s) | ((unsigned int)(s)[2] << 16)) | |
221 | #define combine_quad(s) (combine_triple(s) | ((unsigned int)(s)[3] << 24)) | |
222 | ||
223 | unsigned int snd_usb_combine_bytes(unsigned char *bytes, int size); | |
224 | ||
225 | void *snd_usb_find_desc(void *descstart, int desclen, void *after, u8 dtype); | |
226 | void *snd_usb_find_csint_desc(void *descstart, int desclen, void *after, u8 dsubtype); | |
227 | ||
228 | int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u8 requesttype, __u16 value, __u16 index, void *data, __u16 size, int timeout); | |
229 | ||
230 | int snd_usb_create_mixer(snd_usb_audio_t *chip, int ctrlif); | |
84957a8a | 231 | void snd_usb_mixer_disconnect(struct list_head *p); |
1da177e4 LT |
232 | |
233 | int snd_usb_create_midi_interface(snd_usb_audio_t *chip, struct usb_interface *iface, const snd_usb_audio_quirk_t *quirk); | |
234 | void snd_usbmidi_input_stop(struct list_head* p); | |
235 | void snd_usbmidi_input_start(struct list_head* p); | |
ee733397 | 236 | void snd_usbmidi_disconnect(struct list_head *p); |
1da177e4 LT |
237 | |
238 | /* | |
239 | * retrieve usb_interface descriptor from the host interface | |
240 | * (conditional for compatibility with the older API) | |
241 | */ | |
242 | #ifndef get_iface_desc | |
243 | #define get_iface_desc(iface) (&(iface)->desc) | |
244 | #define get_endpoint(alt,ep) (&(alt)->endpoint[ep].desc) | |
245 | #define get_ep_desc(ep) (&(ep)->desc) | |
246 | #define get_cfg_desc(cfg) (&(cfg)->desc) | |
247 | #endif | |
248 | ||
249 | #ifndef usb_pipe_needs_resubmit | |
250 | #define usb_pipe_needs_resubmit(pipe) 1 | |
251 | #endif | |
252 | ||
253 | #ifndef snd_usb_complete_callback | |
254 | #define snd_usb_complete_callback(x) (x) | |
255 | #endif | |
256 | ||
257 | #ifndef snd_usb_get_speed | |
258 | #define snd_usb_get_speed(dev) ((dev)->speed) | |
259 | #endif | |
260 | ||
261 | #endif /* __USBAUDIO_H */ |