Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | /* maximum number of endpoints per interface */ |
| 25 | #define MIDI_MAX_ENDPOINTS 2 |
| 26 | |
Clemens Ladisch | 27d10f5 | 2005-05-02 08:51:26 +0200 | [diff] [blame] | 27 | /* handling of USB vendor/product ID pairs as 32-bit numbers */ |
| 28 | #define USB_ID(vendor, product) (((vendor) << 16) | (product)) |
| 29 | #define USB_ID_VENDOR(id) ((id) >> 16) |
| 30 | #define USB_ID_PRODUCT(id) ((u16)(id)) |
| 31 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | /* |
| 33 | */ |
| 34 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | struct snd_usb_audio { |
| 36 | int index; |
| 37 | struct usb_device *dev; |
Takashi Iwai | 86e07d3 | 2005-11-17 15:08:02 +0100 | [diff] [blame] | 38 | struct snd_card *card; |
Clemens Ladisch | 27d10f5 | 2005-05-02 08:51:26 +0200 | [diff] [blame] | 39 | u32 usb_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | int shutdown; |
John S. Gruber | 98e89f6 | 2009-12-27 12:19:58 -0500 | [diff] [blame] | 41 | unsigned int txfr_quirk:1; /* Subframe boundaries on transfers */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | int num_interfaces; |
Oliver Neukum | f85bf29 | 2007-12-14 14:42:41 +0100 | [diff] [blame] | 43 | int num_suspended_intf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
Daniel Mack | 53ee98f | 2010-02-22 23:49:11 +0100 | [diff] [blame] | 45 | /* for audio class v2 */ |
| 46 | int clock_id; |
| 47 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | struct list_head pcm_list; /* list of pcm streams */ |
| 49 | int pcm_devs; |
| 50 | |
| 51 | struct list_head midi_list; /* list of midi interfaces */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
Clemens Ladisch | 84957a8 | 2005-04-29 16:23:13 +0200 | [diff] [blame] | 53 | struct list_head mixer_list; /* list of mixer interfaces */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | /* |
| 57 | * Information about devices with broken descriptors |
| 58 | */ |
| 59 | |
| 60 | /* special values for .ifnum */ |
| 61 | #define QUIRK_NO_INTERFACE -2 |
| 62 | #define QUIRK_ANY_INTERFACE -1 |
| 63 | |
Clemens Ladisch | 854af95 | 2005-07-25 16:19:10 +0200 | [diff] [blame] | 64 | enum quirk_type { |
| 65 | QUIRK_IGNORE_INTERFACE, |
| 66 | QUIRK_COMPOSITE, |
| 67 | QUIRK_MIDI_STANDARD_INTERFACE, |
| 68 | QUIRK_MIDI_FIXED_ENDPOINT, |
| 69 | QUIRK_MIDI_YAMAHA, |
| 70 | QUIRK_MIDI_MIDIMAN, |
| 71 | QUIRK_MIDI_NOVATION, |
Clemens Ladisch | 55de5ef | 2009-05-27 10:49:30 +0200 | [diff] [blame] | 72 | QUIRK_MIDI_FASTLANE, |
Clemens Ladisch | 854af95 | 2005-07-25 16:19:10 +0200 | [diff] [blame] | 73 | QUIRK_MIDI_EMAGIC, |
Clemens Ladisch | cc7a59b | 2006-02-07 17:11:06 +0100 | [diff] [blame] | 74 | QUIRK_MIDI_CME, |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 75 | QUIRK_MIDI_US122L, |
Clemens Ladisch | 854af95 | 2005-07-25 16:19:10 +0200 | [diff] [blame] | 76 | QUIRK_AUDIO_STANDARD_INTERFACE, |
| 77 | QUIRK_AUDIO_FIXED_ENDPOINT, |
Pedro Lopez-Cabanillas | 310e0dc | 2008-10-04 16:27:36 +0200 | [diff] [blame] | 78 | QUIRK_AUDIO_EDIROL_UAXX, |
John S. Gruber | 52a7a58 | 2009-12-27 12:19:59 -0500 | [diff] [blame] | 79 | QUIRK_AUDIO_ALIGN_TRANSFER, |
Clemens Ladisch | 854af95 | 2005-07-25 16:19:10 +0200 | [diff] [blame] | 80 | |
| 81 | QUIRK_TYPE_COUNT |
| 82 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | struct snd_usb_audio_quirk { |
| 85 | const char *vendor_name; |
| 86 | const char *product_name; |
| 87 | int16_t ifnum; |
Clemens Ladisch | 854af95 | 2005-07-25 16:19:10 +0200 | [diff] [blame] | 88 | uint16_t type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | const void *data; |
| 90 | }; |
| 91 | |
| 92 | /* data for QUIRK_MIDI_FIXED_ENDPOINT */ |
| 93 | struct snd_usb_midi_endpoint_info { |
| 94 | int8_t out_ep; /* ep number, 0 autodetect */ |
| 95 | uint8_t out_interval; /* interval for interrupt endpoints */ |
| 96 | int8_t in_ep; |
| 97 | uint8_t in_interval; |
| 98 | uint16_t out_cables; /* bitmask */ |
| 99 | uint16_t in_cables; /* bitmask */ |
| 100 | }; |
| 101 | |
| 102 | /* for QUIRK_MIDI_YAMAHA, data is NULL */ |
| 103 | |
| 104 | /* for QUIRK_MIDI_MIDIMAN, data points to a snd_usb_midi_endpoint_info |
| 105 | * structure (out_cables and in_cables only) */ |
| 106 | |
| 107 | /* for QUIRK_COMPOSITE, data points to an array of snd_usb_audio_quirk |
| 108 | * structures, terminated with .ifnum = -1 */ |
| 109 | |
| 110 | /* for QUIRK_AUDIO_FIXED_ENDPOINT, data points to an audioformat structure */ |
| 111 | |
| 112 | /* for QUIRK_AUDIO/MIDI_STANDARD_INTERFACE, data is NULL */ |
| 113 | |
Clemens Ladisch | e584bc3 | 2010-03-01 16:20:37 +0100 | [diff] [blame] | 114 | /* for QUIRK_AUDIO_EDIROL_UAXX, data is NULL */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | |
| 116 | /* for QUIRK_IGNORE_INTERFACE, data is NULL */ |
| 117 | |
Clemens Ladisch | 6155aff | 2005-07-04 09:20:42 +0200 | [diff] [blame] | 118 | /* for QUIRK_MIDI_NOVATION and _RAW, data is NULL */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | |
| 120 | /* for QUIRK_MIDI_EMAGIC, data points to a snd_usb_midi_endpoint_info |
| 121 | * structure (out_cables and in_cables only) */ |
| 122 | |
Clemens Ladisch | cc7a59b | 2006-02-07 17:11:06 +0100 | [diff] [blame] | 123 | /* for QUIRK_MIDI_CME, data is NULL */ |
Clemens Ladisch | f38275f | 2005-07-25 16:17:29 +0200 | [diff] [blame] | 124 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | /* |
| 126 | */ |
| 127 | |
Sergiy Kovalchuk | 7d2b451 | 2009-12-27 09:13:41 -0800 | [diff] [blame] | 128 | /*E-mu USB samplerate control quirk*/ |
| 129 | enum { |
| 130 | EMU_QUIRK_SR_44100HZ = 0, |
| 131 | EMU_QUIRK_SR_48000HZ, |
| 132 | EMU_QUIRK_SR_88200HZ, |
| 133 | EMU_QUIRK_SR_96000HZ, |
| 134 | EMU_QUIRK_SR_176400HZ, |
| 135 | EMU_QUIRK_SR_192000HZ |
| 136 | }; |
| 137 | |
Julian Anastasov | f495088 | 2009-11-06 23:44:53 +0200 | [diff] [blame] | 138 | #define combine_word(s) ((*(s)) | ((unsigned int)(s)[1] << 8)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | #define combine_triple(s) (combine_word(s) | ((unsigned int)(s)[2] << 16)) |
| 140 | #define combine_quad(s) (combine_triple(s) | ((unsigned int)(s)[3] << 24)) |
| 141 | |
| 142 | unsigned int snd_usb_combine_bytes(unsigned char *bytes, int size); |
| 143 | |
| 144 | void *snd_usb_find_desc(void *descstart, int desclen, void *after, u8 dtype); |
| 145 | void *snd_usb_find_csint_desc(void *descstart, int desclen, void *after, u8 dsubtype); |
| 146 | |
Takashi Iwai | 86e07d3 | 2005-11-17 15:08:02 +0100 | [diff] [blame] | 147 | int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe, |
| 148 | __u8 request, __u8 requesttype, __u16 value, __u16 index, |
| 149 | void *data, __u16 size, int timeout); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | |
Takashi Iwai | 7a9b806 | 2008-08-13 15:40:53 +0200 | [diff] [blame] | 151 | int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif, |
| 152 | int ignore_error); |
Clemens Ladisch | 84957a8 | 2005-04-29 16:23:13 +0200 | [diff] [blame] | 153 | void snd_usb_mixer_disconnect(struct list_head *p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | |
Clemens Ladisch | d82af9f | 2009-11-16 12:23:46 +0100 | [diff] [blame] | 155 | int snd_usbmidi_create(struct snd_card *card, |
| 156 | struct usb_interface *iface, |
| 157 | struct list_head *midi_list, |
| 158 | const struct snd_usb_audio_quirk *quirk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | void snd_usbmidi_input_stop(struct list_head* p); |
| 160 | void snd_usbmidi_input_start(struct list_head* p); |
Clemens Ladisch | ee73339 | 2005-04-25 10:34:13 +0200 | [diff] [blame] | 161 | void snd_usbmidi_disconnect(struct list_head *p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | |
Sergiy Kovalchuk | 7d2b451 | 2009-12-27 09:13:41 -0800 | [diff] [blame] | 163 | void snd_emuusb_set_samplerate(struct snd_usb_audio *chip, |
| 164 | unsigned char samplerate_id); |
| 165 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | /* |
| 167 | * retrieve usb_interface descriptor from the host interface |
| 168 | * (conditional for compatibility with the older API) |
| 169 | */ |
| 170 | #ifndef get_iface_desc |
| 171 | #define get_iface_desc(iface) (&(iface)->desc) |
| 172 | #define get_endpoint(alt,ep) (&(alt)->endpoint[ep].desc) |
| 173 | #define get_ep_desc(ep) (&(ep)->desc) |
| 174 | #define get_cfg_desc(cfg) (&(cfg)->desc) |
| 175 | #endif |
| 176 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | #ifndef snd_usb_get_speed |
| 178 | #define snd_usb_get_speed(dev) ((dev)->speed) |
| 179 | #endif |
| 180 | |
| 181 | #endif /* __USBAUDIO_H */ |