Thomas Gleixner | 1a59d1b8 | 2019-05-27 08:55:05 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 2 | /* |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 3 | */ |
| 4 | |
| 5 | #include <linux/init.h> |
Stephen Rothwell | 36db045 | 2010-03-29 16:02:50 +1100 | [diff] [blame] | 6 | #include <linux/slab.h> |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 7 | #include <linux/usb.h> |
| 8 | #include <linux/usb/audio.h> |
Clemens Ladisch | aafe77c | 2013-03-31 23:43:12 +0200 | [diff] [blame] | 9 | #include <linux/usb/midi.h> |
Linus Walleij | ad43d528 | 2018-11-02 22:11:33 +0100 | [diff] [blame] | 10 | #include <linux/bits.h> |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 11 | |
Daniel Mack | 9e38658 | 2011-05-25 09:09:01 +0200 | [diff] [blame] | 12 | #include <sound/control.h> |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 13 | #include <sound/core.h> |
| 14 | #include <sound/info.h> |
| 15 | #include <sound/pcm.h> |
| 16 | |
| 17 | #include "usbaudio.h" |
| 18 | #include "card.h" |
Daniel Mack | f0b5e63 | 2010-03-11 21:13:23 +0100 | [diff] [blame] | 19 | #include "mixer.h" |
Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 20 | #include "mixer_quirks.h" |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 21 | #include "midi.h" |
| 22 | #include "quirks.h" |
| 23 | #include "helper.h" |
| 24 | #include "endpoint.h" |
| 25 | #include "pcm.h" |
Daniel Mack | 3d8d4dc | 2010-06-16 17:57:31 +0200 | [diff] [blame] | 26 | #include "clock.h" |
Daniel Mack | e8e8bab | 2011-09-12 18:54:12 +0200 | [diff] [blame] | 27 | #include "stream.h" |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 28 | |
| 29 | /* |
| 30 | * handle the quirks for the contained interfaces |
| 31 | */ |
| 32 | static int create_composite_quirk(struct snd_usb_audio *chip, |
| 33 | struct usb_interface *iface, |
| 34 | struct usb_driver *driver, |
Takashi Iwai | 85a8181 | 2014-11-10 07:41:59 +0100 | [diff] [blame] | 35 | const struct snd_usb_audio_quirk *quirk_comp) |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 36 | { |
| 37 | int probed_ifnum = get_iface_desc(iface->altsetting)->bInterfaceNumber; |
Takashi Iwai | 85a8181 | 2014-11-10 07:41:59 +0100 | [diff] [blame] | 38 | const struct snd_usb_audio_quirk *quirk; |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 39 | int err; |
| 40 | |
Takashi Iwai | 85a8181 | 2014-11-10 07:41:59 +0100 | [diff] [blame] | 41 | for (quirk = quirk_comp->data; quirk->ifnum >= 0; ++quirk) { |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 42 | iface = usb_ifnum_to_if(chip->dev, quirk->ifnum); |
| 43 | if (!iface) |
| 44 | continue; |
| 45 | if (quirk->ifnum != probed_ifnum && |
| 46 | usb_interface_claimed(iface)) |
| 47 | continue; |
| 48 | err = snd_usb_create_quirk(chip, iface, driver, quirk); |
| 49 | if (err < 0) |
| 50 | return err; |
Takashi Iwai | d4b8fc6 | 2014-11-09 18:21:23 +0100 | [diff] [blame] | 51 | } |
| 52 | |
Takashi Iwai | 85a8181 | 2014-11-10 07:41:59 +0100 | [diff] [blame] | 53 | for (quirk = quirk_comp->data; quirk->ifnum >= 0; ++quirk) { |
Takashi Iwai | d4b8fc6 | 2014-11-09 18:21:23 +0100 | [diff] [blame] | 54 | iface = usb_ifnum_to_if(chip->dev, quirk->ifnum); |
| 55 | if (!iface) |
| 56 | continue; |
| 57 | if (quirk->ifnum != probed_ifnum && |
Takashi Iwai | 5fb4541 | 2021-04-06 13:35:34 +0200 | [diff] [blame] | 58 | !usb_interface_claimed(iface)) { |
| 59 | err = usb_driver_claim_interface(driver, iface, |
| 60 | USB_AUDIO_IFACE_UNUSED); |
| 61 | if (err < 0) |
| 62 | return err; |
| 63 | } |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 64 | } |
Takashi Iwai | d4b8fc6 | 2014-11-09 18:21:23 +0100 | [diff] [blame] | 65 | |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 66 | return 0; |
| 67 | } |
| 68 | |
| 69 | static int ignore_interface_quirk(struct snd_usb_audio *chip, |
| 70 | struct usb_interface *iface, |
| 71 | struct usb_driver *driver, |
| 72 | const struct snd_usb_audio_quirk *quirk) |
| 73 | { |
| 74 | return 0; |
| 75 | } |
| 76 | |
| 77 | |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 78 | static int create_any_midi_quirk(struct snd_usb_audio *chip, |
| 79 | struct usb_interface *intf, |
| 80 | struct usb_driver *driver, |
| 81 | const struct snd_usb_audio_quirk *quirk) |
| 82 | { |
| 83 | return snd_usbmidi_create(chip->card, intf, &chip->midi_list, quirk); |
| 84 | } |
| 85 | |
| 86 | /* |
| 87 | * create a stream for an interface with proper descriptors |
| 88 | */ |
| 89 | static int create_standard_audio_quirk(struct snd_usb_audio *chip, |
| 90 | struct usb_interface *iface, |
| 91 | struct usb_driver *driver, |
| 92 | const struct snd_usb_audio_quirk *quirk) |
| 93 | { |
| 94 | struct usb_host_interface *alts; |
| 95 | struct usb_interface_descriptor *altsd; |
| 96 | int err; |
| 97 | |
| 98 | alts = &iface->altsetting[0]; |
| 99 | altsd = get_iface_desc(alts); |
Daniel Mack | e8e8bab | 2011-09-12 18:54:12 +0200 | [diff] [blame] | 100 | err = snd_usb_parse_audio_interface(chip, altsd->bInterfaceNumber); |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 101 | if (err < 0) { |
Takashi Iwai | 0ba41d9 | 2014-02-26 13:02:17 +0100 | [diff] [blame] | 102 | usb_audio_err(chip, "cannot setup if %d: error %d\n", |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 103 | altsd->bInterfaceNumber, err); |
| 104 | return err; |
| 105 | } |
| 106 | /* reset the current interface */ |
| 107 | usb_set_interface(chip->dev, altsd->bInterfaceNumber, 0); |
| 108 | return 0; |
| 109 | } |
| 110 | |
Takashi Iwai | b2345a8 | 2021-01-08 08:52:15 +0100 | [diff] [blame] | 111 | /* create the audio stream and the corresponding endpoints from the fixed |
| 112 | * audioformat object; this is used for quirks with the fixed EPs |
| 113 | */ |
| 114 | static int add_audio_stream_from_fixed_fmt(struct snd_usb_audio *chip, |
| 115 | struct audioformat *fp) |
| 116 | { |
| 117 | int stream, err; |
| 118 | |
| 119 | stream = (fp->endpoint & USB_DIR_IN) ? |
| 120 | SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK; |
| 121 | |
| 122 | snd_usb_audioformat_set_sync_ep(chip, fp); |
| 123 | |
| 124 | err = snd_usb_add_audio_stream(chip, stream, fp); |
| 125 | if (err < 0) |
| 126 | return err; |
| 127 | |
| 128 | err = snd_usb_add_endpoint(chip, fp->endpoint, |
| 129 | SND_USB_ENDPOINT_TYPE_DATA); |
| 130 | if (err < 0) |
| 131 | return err; |
| 132 | |
| 133 | if (fp->sync_ep) { |
| 134 | err = snd_usb_add_endpoint(chip, fp->sync_ep, |
| 135 | fp->implicit_fb ? |
| 136 | SND_USB_ENDPOINT_TYPE_DATA : |
| 137 | SND_USB_ENDPOINT_TYPE_SYNC); |
| 138 | if (err < 0) |
| 139 | return err; |
| 140 | } |
| 141 | |
| 142 | return 0; |
| 143 | } |
| 144 | |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 145 | /* |
| 146 | * create a stream for an endpoint/altsetting without proper descriptors |
| 147 | */ |
| 148 | static int create_fixed_stream_quirk(struct snd_usb_audio *chip, |
| 149 | struct usb_interface *iface, |
| 150 | struct usb_driver *driver, |
| 151 | const struct snd_usb_audio_quirk *quirk) |
| 152 | { |
| 153 | struct audioformat *fp; |
| 154 | struct usb_host_interface *alts; |
Eldad Zack | 42d4ab8 | 2013-07-09 20:36:15 +0200 | [diff] [blame] | 155 | struct usb_interface_descriptor *altsd; |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 156 | unsigned *rate_table = NULL; |
Takashi Iwai | b2345a8 | 2021-01-08 08:52:15 +0100 | [diff] [blame] | 157 | int err; |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 158 | |
| 159 | fp = kmemdup(quirk->data, sizeof(*fp), GFP_KERNEL); |
Markus Elfring | 9ecb240 | 2017-08-11 18:38:25 +0200 | [diff] [blame] | 160 | if (!fp) |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 161 | return -ENOMEM; |
Markus Elfring | 9ecb240 | 2017-08-11 18:38:25 +0200 | [diff] [blame] | 162 | |
Vladis Dronov | 836b34a | 2016-03-31 12:05:43 -0400 | [diff] [blame] | 163 | INIT_LIST_HEAD(&fp->list); |
Xi Wang | 8866f40 | 2012-02-14 05:18:48 -0500 | [diff] [blame] | 164 | if (fp->nr_rates > MAX_NR_RATES) { |
| 165 | kfree(fp); |
| 166 | return -EINVAL; |
| 167 | } |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 168 | if (fp->nr_rates > 0) { |
Thomas Meyer | 43df2a5 | 2011-11-10 19:38:43 +0100 | [diff] [blame] | 169 | rate_table = kmemdup(fp->rate_table, |
| 170 | sizeof(int) * fp->nr_rates, GFP_KERNEL); |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 171 | if (!rate_table) { |
| 172 | kfree(fp); |
| 173 | return -ENOMEM; |
| 174 | } |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 175 | fp->rate_table = rate_table; |
| 176 | } |
| 177 | |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 178 | if (fp->iface != get_iface_desc(&iface->altsetting[0])->bInterfaceNumber || |
| 179 | fp->altset_idx >= iface->num_altsetting) { |
Takashi Iwai | 902eb7f | 2016-03-15 12:14:49 +0100 | [diff] [blame] | 180 | err = -EINVAL; |
| 181 | goto error; |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 182 | } |
| 183 | alts = &iface->altsetting[fp->altset_idx]; |
Eldad Zack | 42d4ab8 | 2013-07-09 20:36:15 +0200 | [diff] [blame] | 184 | altsd = get_iface_desc(alts); |
Takashi Iwai | eae4d05 | 2021-01-08 08:52:18 +0100 | [diff] [blame] | 185 | if (altsd->bNumEndpoints <= fp->ep_idx) { |
Takashi Iwai | 902eb7f | 2016-03-15 12:14:49 +0100 | [diff] [blame] | 186 | err = -EINVAL; |
| 187 | goto error; |
Takashi Iwai | 0f886ca | 2016-03-15 12:09:10 +0100 | [diff] [blame] | 188 | } |
| 189 | |
Eldad Zack | 42d4ab8 | 2013-07-09 20:36:15 +0200 | [diff] [blame] | 190 | fp->protocol = altsd->bInterfaceProtocol; |
| 191 | |
Mark Hills | 59ea586 | 2013-03-17 11:07:54 +0000 | [diff] [blame] | 192 | if (fp->datainterval == 0) |
| 193 | fp->datainterval = snd_usb_parse_datainterval(chip, alts); |
| 194 | if (fp->maxpacksize == 0) |
Takashi Iwai | eae4d05 | 2021-01-08 08:52:18 +0100 | [diff] [blame] | 195 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, fp->ep_idx)->wMaxPacketSize); |
Takashi Iwai | b2345a8 | 2021-01-08 08:52:15 +0100 | [diff] [blame] | 196 | if (!fp->fmt_type) |
| 197 | fp->fmt_type = UAC_FORMAT_TYPE_I; |
| 198 | |
| 199 | err = add_audio_stream_from_fixed_fmt(chip, fp); |
| 200 | if (err < 0) |
| 201 | goto error; |
| 202 | |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 203 | usb_set_interface(chip->dev, fp->iface, 0); |
Takashi Iwai | 73037c8 | 2020-11-23 09:53:26 +0100 | [diff] [blame] | 204 | snd_usb_init_pitch(chip, fp); |
Takashi Iwai | 953a446 | 2020-11-23 09:53:25 +0100 | [diff] [blame] | 205 | snd_usb_init_sample_rate(chip, fp, fp->rate_max); |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 206 | return 0; |
Takashi Iwai | 902eb7f | 2016-03-15 12:14:49 +0100 | [diff] [blame] | 207 | |
| 208 | error: |
Vladis Dronov | 836b34a | 2016-03-31 12:05:43 -0400 | [diff] [blame] | 209 | list_del(&fp->list); /* unlink for avoiding double-free */ |
Takashi Iwai | 902eb7f | 2016-03-15 12:14:49 +0100 | [diff] [blame] | 210 | kfree(fp); |
| 211 | kfree(rate_table); |
| 212 | return err; |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 213 | } |
| 214 | |
Clemens Ladisch | aafe77c | 2013-03-31 23:43:12 +0200 | [diff] [blame] | 215 | static int create_auto_pcm_quirk(struct snd_usb_audio *chip, |
| 216 | struct usb_interface *iface, |
| 217 | struct usb_driver *driver) |
| 218 | { |
| 219 | struct usb_host_interface *alts; |
| 220 | struct usb_interface_descriptor *altsd; |
| 221 | struct usb_endpoint_descriptor *epd; |
| 222 | struct uac1_as_header_descriptor *ashd; |
| 223 | struct uac_format_type_i_discrete_descriptor *fmtd; |
| 224 | |
| 225 | /* |
| 226 | * Most Roland/Yamaha audio streaming interfaces have more or less |
| 227 | * standard descriptors, but older devices might lack descriptors, and |
| 228 | * future ones might change, so ensure that we fail silently if the |
| 229 | * interface doesn't look exactly right. |
| 230 | */ |
| 231 | |
| 232 | /* must have a non-zero altsetting for streaming */ |
| 233 | if (iface->num_altsetting < 2) |
| 234 | return -ENODEV; |
| 235 | alts = &iface->altsetting[1]; |
| 236 | altsd = get_iface_desc(alts); |
| 237 | |
| 238 | /* must have an isochronous endpoint for streaming */ |
| 239 | if (altsd->bNumEndpoints < 1) |
| 240 | return -ENODEV; |
| 241 | epd = get_endpoint(alts, 0); |
| 242 | if (!usb_endpoint_xfer_isoc(epd)) |
| 243 | return -ENODEV; |
| 244 | |
| 245 | /* must have format descriptors */ |
| 246 | ashd = snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, |
| 247 | UAC_AS_GENERAL); |
| 248 | fmtd = snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, |
| 249 | UAC_FORMAT_TYPE); |
| 250 | if (!ashd || ashd->bLength < 7 || |
| 251 | !fmtd || fmtd->bLength < 8) |
| 252 | return -ENODEV; |
| 253 | |
| 254 | return create_standard_audio_quirk(chip, iface, driver, NULL); |
| 255 | } |
| 256 | |
| 257 | static int create_yamaha_midi_quirk(struct snd_usb_audio *chip, |
| 258 | struct usb_interface *iface, |
| 259 | struct usb_driver *driver, |
| 260 | struct usb_host_interface *alts) |
| 261 | { |
| 262 | static const struct snd_usb_audio_quirk yamaha_midi_quirk = { |
| 263 | .type = QUIRK_MIDI_YAMAHA |
| 264 | }; |
| 265 | struct usb_midi_in_jack_descriptor *injd; |
| 266 | struct usb_midi_out_jack_descriptor *outjd; |
| 267 | |
| 268 | /* must have some valid jack descriptors */ |
| 269 | injd = snd_usb_find_csint_desc(alts->extra, alts->extralen, |
| 270 | NULL, USB_MS_MIDI_IN_JACK); |
| 271 | outjd = snd_usb_find_csint_desc(alts->extra, alts->extralen, |
| 272 | NULL, USB_MS_MIDI_OUT_JACK); |
| 273 | if (!injd && !outjd) |
| 274 | return -ENODEV; |
Takashi Iwai | cc9dbfa | 2019-11-13 12:12:59 +0100 | [diff] [blame] | 275 | if ((injd && !snd_usb_validate_midi_desc(injd)) || |
| 276 | (outjd && !snd_usb_validate_midi_desc(outjd))) |
Takashi Iwai | 57f8770 | 2019-08-20 17:17:09 +0200 | [diff] [blame] | 277 | return -ENODEV; |
Clemens Ladisch | aafe77c | 2013-03-31 23:43:12 +0200 | [diff] [blame] | 278 | if (injd && (injd->bLength < 5 || |
| 279 | (injd->bJackType != USB_MS_EMBEDDED && |
| 280 | injd->bJackType != USB_MS_EXTERNAL))) |
| 281 | return -ENODEV; |
| 282 | if (outjd && (outjd->bLength < 6 || |
| 283 | (outjd->bJackType != USB_MS_EMBEDDED && |
| 284 | outjd->bJackType != USB_MS_EXTERNAL))) |
| 285 | return -ENODEV; |
| 286 | return create_any_midi_quirk(chip, iface, driver, &yamaha_midi_quirk); |
| 287 | } |
| 288 | |
| 289 | static int create_roland_midi_quirk(struct snd_usb_audio *chip, |
| 290 | struct usb_interface *iface, |
| 291 | struct usb_driver *driver, |
| 292 | struct usb_host_interface *alts) |
| 293 | { |
| 294 | static const struct snd_usb_audio_quirk roland_midi_quirk = { |
| 295 | .type = QUIRK_MIDI_ROLAND |
| 296 | }; |
| 297 | u8 *roland_desc = NULL; |
| 298 | |
| 299 | /* might have a vendor-specific descriptor <06 24 F1 02 ...> */ |
| 300 | for (;;) { |
| 301 | roland_desc = snd_usb_find_csint_desc(alts->extra, |
| 302 | alts->extralen, |
| 303 | roland_desc, 0xf1); |
| 304 | if (!roland_desc) |
| 305 | return -ENODEV; |
| 306 | if (roland_desc[0] < 6 || roland_desc[3] != 2) |
| 307 | continue; |
| 308 | return create_any_midi_quirk(chip, iface, driver, |
| 309 | &roland_midi_quirk); |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | static int create_std_midi_quirk(struct snd_usb_audio *chip, |
| 314 | struct usb_interface *iface, |
| 315 | struct usb_driver *driver, |
| 316 | struct usb_host_interface *alts) |
| 317 | { |
| 318 | struct usb_ms_header_descriptor *mshd; |
| 319 | struct usb_ms_endpoint_descriptor *msepd; |
| 320 | |
| 321 | /* must have the MIDIStreaming interface header descriptor*/ |
| 322 | mshd = (struct usb_ms_header_descriptor *)alts->extra; |
| 323 | if (alts->extralen < 7 || |
| 324 | mshd->bLength < 7 || |
| 325 | mshd->bDescriptorType != USB_DT_CS_INTERFACE || |
| 326 | mshd->bDescriptorSubtype != USB_MS_HEADER) |
| 327 | return -ENODEV; |
| 328 | /* must have the MIDIStreaming endpoint descriptor*/ |
| 329 | msepd = (struct usb_ms_endpoint_descriptor *)alts->endpoint[0].extra; |
| 330 | if (alts->endpoint[0].extralen < 4 || |
| 331 | msepd->bLength < 4 || |
| 332 | msepd->bDescriptorType != USB_DT_CS_ENDPOINT || |
| 333 | msepd->bDescriptorSubtype != UAC_MS_GENERAL || |
| 334 | msepd->bNumEmbMIDIJack < 1 || |
| 335 | msepd->bNumEmbMIDIJack > 16) |
| 336 | return -ENODEV; |
| 337 | |
| 338 | return create_any_midi_quirk(chip, iface, driver, NULL); |
| 339 | } |
| 340 | |
| 341 | static int create_auto_midi_quirk(struct snd_usb_audio *chip, |
| 342 | struct usb_interface *iface, |
| 343 | struct usb_driver *driver) |
| 344 | { |
| 345 | struct usb_host_interface *alts; |
| 346 | struct usb_interface_descriptor *altsd; |
| 347 | struct usb_endpoint_descriptor *epd; |
| 348 | int err; |
| 349 | |
| 350 | alts = &iface->altsetting[0]; |
| 351 | altsd = get_iface_desc(alts); |
| 352 | |
| 353 | /* must have at least one bulk/interrupt endpoint for streaming */ |
| 354 | if (altsd->bNumEndpoints < 1) |
| 355 | return -ENODEV; |
| 356 | epd = get_endpoint(alts, 0); |
Clemens Ladisch | aa773bf | 2013-08-11 14:13:13 +0200 | [diff] [blame] | 357 | if (!usb_endpoint_xfer_bulk(epd) && |
Clemens Ladisch | aafe77c | 2013-03-31 23:43:12 +0200 | [diff] [blame] | 358 | !usb_endpoint_xfer_int(epd)) |
| 359 | return -ENODEV; |
| 360 | |
| 361 | switch (USB_ID_VENDOR(chip->usb_id)) { |
| 362 | case 0x0499: /* Yamaha */ |
| 363 | err = create_yamaha_midi_quirk(chip, iface, driver, alts); |
Clemens Ladisch | aa773bf | 2013-08-11 14:13:13 +0200 | [diff] [blame] | 364 | if (err != -ENODEV) |
Clemens Ladisch | aafe77c | 2013-03-31 23:43:12 +0200 | [diff] [blame] | 365 | return err; |
| 366 | break; |
| 367 | case 0x0582: /* Roland */ |
| 368 | err = create_roland_midi_quirk(chip, iface, driver, alts); |
Clemens Ladisch | aa773bf | 2013-08-11 14:13:13 +0200 | [diff] [blame] | 369 | if (err != -ENODEV) |
Clemens Ladisch | aafe77c | 2013-03-31 23:43:12 +0200 | [diff] [blame] | 370 | return err; |
| 371 | break; |
| 372 | } |
| 373 | |
| 374 | return create_std_midi_quirk(chip, iface, driver, alts); |
| 375 | } |
| 376 | |
| 377 | static int create_autodetect_quirk(struct snd_usb_audio *chip, |
| 378 | struct usb_interface *iface, |
Clemens Ladisch | b1ce7ba | 2013-04-04 21:43:57 +0200 | [diff] [blame] | 379 | struct usb_driver *driver) |
Clemens Ladisch | aafe77c | 2013-03-31 23:43:12 +0200 | [diff] [blame] | 380 | { |
| 381 | int err; |
| 382 | |
| 383 | err = create_auto_pcm_quirk(chip, iface, driver); |
| 384 | if (err == -ENODEV) |
| 385 | err = create_auto_midi_quirk(chip, iface, driver); |
| 386 | return err; |
| 387 | } |
| 388 | |
Clemens Ladisch | b1ce7ba | 2013-04-04 21:43:57 +0200 | [diff] [blame] | 389 | static int create_autodetect_quirks(struct snd_usb_audio *chip, |
| 390 | struct usb_interface *iface, |
| 391 | struct usb_driver *driver, |
| 392 | const struct snd_usb_audio_quirk *quirk) |
| 393 | { |
| 394 | int probed_ifnum = get_iface_desc(iface->altsetting)->bInterfaceNumber; |
| 395 | int ifcount, ifnum, err; |
| 396 | |
| 397 | err = create_autodetect_quirk(chip, iface, driver); |
| 398 | if (err < 0) |
| 399 | return err; |
| 400 | |
| 401 | /* |
| 402 | * ALSA PCM playback/capture devices cannot be registered in two steps, |
| 403 | * so we have to claim the other corresponding interface here. |
| 404 | */ |
| 405 | ifcount = chip->dev->actconfig->desc.bNumInterfaces; |
| 406 | for (ifnum = 0; ifnum < ifcount; ifnum++) { |
| 407 | if (ifnum == probed_ifnum || quirk->ifnum >= 0) |
| 408 | continue; |
| 409 | iface = usb_ifnum_to_if(chip->dev, ifnum); |
| 410 | if (!iface || |
| 411 | usb_interface_claimed(iface) || |
| 412 | get_iface_desc(iface->altsetting)->bInterfaceClass != |
| 413 | USB_CLASS_VENDOR_SPEC) |
| 414 | continue; |
| 415 | |
| 416 | err = create_autodetect_quirk(chip, iface, driver); |
Takashi Iwai | 5fb4541 | 2021-04-06 13:35:34 +0200 | [diff] [blame] | 417 | if (err >= 0) { |
| 418 | err = usb_driver_claim_interface(driver, iface, |
| 419 | USB_AUDIO_IFACE_UNUSED); |
| 420 | if (err < 0) |
| 421 | return err; |
| 422 | } |
Clemens Ladisch | b1ce7ba | 2013-04-04 21:43:57 +0200 | [diff] [blame] | 423 | } |
| 424 | |
| 425 | return 0; |
| 426 | } |
| 427 | |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 428 | /* |
| 429 | * Create a stream for an Edirol UA-700/UA-25/UA-4FX interface. |
| 430 | * The only way to detect the sample rate is by looking at wMaxPacketSize. |
| 431 | */ |
| 432 | static int create_uaxx_quirk(struct snd_usb_audio *chip, |
| 433 | struct usb_interface *iface, |
| 434 | struct usb_driver *driver, |
| 435 | const struct snd_usb_audio_quirk *quirk) |
| 436 | { |
| 437 | static const struct audioformat ua_format = { |
Clemens Ladisch | 015eb0b | 2010-03-04 19:46:15 +0100 | [diff] [blame] | 438 | .formats = SNDRV_PCM_FMTBIT_S24_3LE, |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 439 | .channels = 2, |
| 440 | .fmt_type = UAC_FORMAT_TYPE_I, |
| 441 | .altsetting = 1, |
| 442 | .altset_idx = 1, |
| 443 | .rates = SNDRV_PCM_RATE_CONTINUOUS, |
| 444 | }; |
| 445 | struct usb_host_interface *alts; |
| 446 | struct usb_interface_descriptor *altsd; |
| 447 | struct audioformat *fp; |
Takashi Iwai | b2345a8 | 2021-01-08 08:52:15 +0100 | [diff] [blame] | 448 | int err; |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 449 | |
| 450 | /* both PCM and MIDI interfaces have 2 or more altsettings */ |
| 451 | if (iface->num_altsetting < 2) |
| 452 | return -ENXIO; |
| 453 | alts = &iface->altsetting[1]; |
| 454 | altsd = get_iface_desc(alts); |
| 455 | |
| 456 | if (altsd->bNumEndpoints == 2) { |
| 457 | static const struct snd_usb_midi_endpoint_info ua700_ep = { |
| 458 | .out_cables = 0x0003, |
| 459 | .in_cables = 0x0003 |
| 460 | }; |
| 461 | static const struct snd_usb_audio_quirk ua700_quirk = { |
| 462 | .type = QUIRK_MIDI_FIXED_ENDPOINT, |
| 463 | .data = &ua700_ep |
| 464 | }; |
| 465 | static const struct snd_usb_midi_endpoint_info uaxx_ep = { |
| 466 | .out_cables = 0x0001, |
| 467 | .in_cables = 0x0001 |
| 468 | }; |
| 469 | static const struct snd_usb_audio_quirk uaxx_quirk = { |
| 470 | .type = QUIRK_MIDI_FIXED_ENDPOINT, |
| 471 | .data = &uaxx_ep |
| 472 | }; |
| 473 | const struct snd_usb_audio_quirk *quirk = |
| 474 | chip->usb_id == USB_ID(0x0582, 0x002b) |
| 475 | ? &ua700_quirk : &uaxx_quirk; |
Takashi Iwai | 79289e2 | 2016-01-11 11:33:34 +0100 | [diff] [blame] | 476 | return __snd_usbmidi_create(chip->card, iface, |
| 477 | &chip->midi_list, quirk, |
| 478 | chip->usb_id); |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 479 | } |
| 480 | |
| 481 | if (altsd->bNumEndpoints != 1) |
| 482 | return -ENXIO; |
| 483 | |
Thomas Meyer | 43df2a5 | 2011-11-10 19:38:43 +0100 | [diff] [blame] | 484 | fp = kmemdup(&ua_format, sizeof(*fp), GFP_KERNEL); |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 485 | if (!fp) |
| 486 | return -ENOMEM; |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 487 | |
| 488 | fp->iface = altsd->bInterfaceNumber; |
| 489 | fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; |
| 490 | fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; |
| 491 | fp->datainterval = 0; |
| 492 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); |
Vladis Dronov | 836b34a | 2016-03-31 12:05:43 -0400 | [diff] [blame] | 493 | INIT_LIST_HEAD(&fp->list); |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 494 | |
| 495 | switch (fp->maxpacksize) { |
| 496 | case 0x120: |
| 497 | fp->rate_max = fp->rate_min = 44100; |
| 498 | break; |
| 499 | case 0x138: |
| 500 | case 0x140: |
| 501 | fp->rate_max = fp->rate_min = 48000; |
| 502 | break; |
| 503 | case 0x258: |
| 504 | case 0x260: |
| 505 | fp->rate_max = fp->rate_min = 96000; |
| 506 | break; |
| 507 | default: |
Takashi Iwai | 0ba41d9 | 2014-02-26 13:02:17 +0100 | [diff] [blame] | 508 | usb_audio_err(chip, "unknown sample rate\n"); |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 509 | kfree(fp); |
| 510 | return -ENXIO; |
| 511 | } |
| 512 | |
Takashi Iwai | b2345a8 | 2021-01-08 08:52:15 +0100 | [diff] [blame] | 513 | err = add_audio_stream_from_fixed_fmt(chip, fp); |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 514 | if (err < 0) { |
Vladis Dronov | 836b34a | 2016-03-31 12:05:43 -0400 | [diff] [blame] | 515 | list_del(&fp->list); /* unlink for avoiding double-free */ |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 516 | kfree(fp); |
| 517 | return err; |
| 518 | } |
| 519 | usb_set_interface(chip->dev, fp->iface, 0); |
| 520 | return 0; |
| 521 | } |
| 522 | |
| 523 | /* |
Daniel Mack | 014950b | 2011-05-25 09:09:02 +0200 | [diff] [blame] | 524 | * Create a standard mixer for the specified interface. |
| 525 | */ |
| 526 | static int create_standard_mixer_quirk(struct snd_usb_audio *chip, |
| 527 | struct usb_interface *iface, |
| 528 | struct usb_driver *driver, |
| 529 | const struct snd_usb_audio_quirk *quirk) |
| 530 | { |
| 531 | if (quirk->ifnum < 0) |
| 532 | return 0; |
| 533 | |
Takashi Iwai | 3c69dc9 | 2021-07-29 09:44:01 +0200 | [diff] [blame] | 534 | return snd_usb_create_mixer(chip, quirk->ifnum); |
Daniel Mack | 014950b | 2011-05-25 09:09:02 +0200 | [diff] [blame] | 535 | } |
| 536 | |
| 537 | /* |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 538 | * audio-interface quirks |
| 539 | * |
| 540 | * returns zero if no standard audio/MIDI parsing is needed. |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 541 | * returns a positive value if standard audio/midi interfaces are parsed |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 542 | * after this. |
| 543 | * returns a negative value at error. |
| 544 | */ |
| 545 | int snd_usb_create_quirk(struct snd_usb_audio *chip, |
| 546 | struct usb_interface *iface, |
| 547 | struct usb_driver *driver, |
| 548 | const struct snd_usb_audio_quirk *quirk) |
| 549 | { |
| 550 | typedef int (*quirk_func_t)(struct snd_usb_audio *, |
| 551 | struct usb_interface *, |
| 552 | struct usb_driver *, |
| 553 | const struct snd_usb_audio_quirk *); |
| 554 | static const quirk_func_t quirk_funcs[] = { |
| 555 | [QUIRK_IGNORE_INTERFACE] = ignore_interface_quirk, |
| 556 | [QUIRK_COMPOSITE] = create_composite_quirk, |
Clemens Ladisch | b1ce7ba | 2013-04-04 21:43:57 +0200 | [diff] [blame] | 557 | [QUIRK_AUTODETECT] = create_autodetect_quirks, |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 558 | [QUIRK_MIDI_STANDARD_INTERFACE] = create_any_midi_quirk, |
| 559 | [QUIRK_MIDI_FIXED_ENDPOINT] = create_any_midi_quirk, |
| 560 | [QUIRK_MIDI_YAMAHA] = create_any_midi_quirk, |
Clemens Ladisch | aafe77c | 2013-03-31 23:43:12 +0200 | [diff] [blame] | 561 | [QUIRK_MIDI_ROLAND] = create_any_midi_quirk, |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 562 | [QUIRK_MIDI_MIDIMAN] = create_any_midi_quirk, |
| 563 | [QUIRK_MIDI_NOVATION] = create_any_midi_quirk, |
Clemens Ladisch | c7f5721 | 2010-10-22 18:20:48 +0200 | [diff] [blame] | 564 | [QUIRK_MIDI_RAW_BYTES] = create_any_midi_quirk, |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 565 | [QUIRK_MIDI_EMAGIC] = create_any_midi_quirk, |
| 566 | [QUIRK_MIDI_CME] = create_any_midi_quirk, |
Krzysztof Foltman | 4434ade | 2010-05-20 20:31:10 +0100 | [diff] [blame] | 567 | [QUIRK_MIDI_AKAI] = create_any_midi_quirk, |
Kristian Amlie | 1ef0e0a | 2011-08-26 13:19:49 +0200 | [diff] [blame] | 568 | [QUIRK_MIDI_FTDI] = create_any_midi_quirk, |
Clemens Ladisch | 1ca8b20 | 2015-11-15 22:38:29 +0100 | [diff] [blame] | 569 | [QUIRK_MIDI_CH345] = create_any_midi_quirk, |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 570 | [QUIRK_AUDIO_STANDARD_INTERFACE] = create_standard_audio_quirk, |
| 571 | [QUIRK_AUDIO_FIXED_ENDPOINT] = create_fixed_stream_quirk, |
| 572 | [QUIRK_AUDIO_EDIROL_UAXX] = create_uaxx_quirk, |
Daniel Mack | 014950b | 2011-05-25 09:09:02 +0200 | [diff] [blame] | 573 | [QUIRK_AUDIO_STANDARD_MIXER] = create_standard_mixer_quirk, |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 574 | }; |
| 575 | |
| 576 | if (quirk->type < QUIRK_TYPE_COUNT) { |
| 577 | return quirk_funcs[quirk->type](chip, iface, driver, quirk); |
| 578 | } else { |
Takashi Iwai | 0ba41d9 | 2014-02-26 13:02:17 +0100 | [diff] [blame] | 579 | usb_audio_err(chip, "invalid quirk type %d\n", quirk->type); |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 580 | return -ENXIO; |
| 581 | } |
| 582 | } |
| 583 | |
| 584 | /* |
| 585 | * boot quirks |
| 586 | */ |
| 587 | |
| 588 | #define EXTIGY_FIRMWARE_SIZE_OLD 794 |
| 589 | #define EXTIGY_FIRMWARE_SIZE_NEW 483 |
| 590 | |
| 591 | static int snd_usb_extigy_boot_quirk(struct usb_device *dev, struct usb_interface *intf) |
| 592 | { |
| 593 | struct usb_host_config *config = dev->actconfig; |
| 594 | int err; |
| 595 | |
| 596 | if (le16_to_cpu(get_cfg_desc(config)->wTotalLength) == EXTIGY_FIRMWARE_SIZE_OLD || |
| 597 | le16_to_cpu(get_cfg_desc(config)->wTotalLength) == EXTIGY_FIRMWARE_SIZE_NEW) { |
Takashi Iwai | 0ba41d9 | 2014-02-26 13:02:17 +0100 | [diff] [blame] | 598 | dev_dbg(&dev->dev, "sending Extigy boot sequence...\n"); |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 599 | /* Send message to force it to reconnect with full interface. */ |
| 600 | err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev,0), |
Clemens Ladisch | 17d900c | 2011-09-26 21:15:27 +0200 | [diff] [blame] | 601 | 0x10, 0x43, 0x0001, 0x000a, NULL, 0); |
Takashi Iwai | 0ba41d9 | 2014-02-26 13:02:17 +0100 | [diff] [blame] | 602 | if (err < 0) |
| 603 | dev_dbg(&dev->dev, "error sending boot message: %d\n", err); |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 604 | err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, |
| 605 | &dev->descriptor, sizeof(dev->descriptor)); |
| 606 | config = dev->actconfig; |
Takashi Iwai | 0ba41d9 | 2014-02-26 13:02:17 +0100 | [diff] [blame] | 607 | if (err < 0) |
| 608 | dev_dbg(&dev->dev, "error usb_get_descriptor: %d\n", err); |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 609 | err = usb_reset_configuration(dev); |
Takashi Iwai | 0ba41d9 | 2014-02-26 13:02:17 +0100 | [diff] [blame] | 610 | if (err < 0) |
| 611 | dev_dbg(&dev->dev, "error usb_reset_configuration: %d\n", err); |
| 612 | dev_dbg(&dev->dev, "extigy_boot: new boot length = %d\n", |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 613 | le16_to_cpu(get_cfg_desc(config)->wTotalLength)); |
| 614 | return -ENODEV; /* quit this anyway */ |
| 615 | } |
| 616 | return 0; |
| 617 | } |
| 618 | |
| 619 | static int snd_usb_audigy2nx_boot_quirk(struct usb_device *dev) |
| 620 | { |
| 621 | u8 buf = 1; |
| 622 | |
| 623 | snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), 0x2a, |
| 624 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER, |
Clemens Ladisch | 17d900c | 2011-09-26 21:15:27 +0200 | [diff] [blame] | 625 | 0, 0, &buf, 1); |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 626 | if (buf == 0) { |
| 627 | snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), 0x29, |
| 628 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, |
Clemens Ladisch | 17d900c | 2011-09-26 21:15:27 +0200 | [diff] [blame] | 629 | 1, 2000, NULL, 0); |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 630 | return -ENODEV; |
| 631 | } |
| 632 | return 0; |
| 633 | } |
| 634 | |
Guillaume Pellerin | 0f5733b | 2011-07-12 18:13:46 +0200 | [diff] [blame] | 635 | static int snd_usb_fasttrackpro_boot_quirk(struct usb_device *dev) |
| 636 | { |
| 637 | int err; |
| 638 | |
| 639 | if (dev->actconfig->desc.bConfigurationValue == 1) { |
Takashi Iwai | 0ba41d9 | 2014-02-26 13:02:17 +0100 | [diff] [blame] | 640 | dev_info(&dev->dev, |
Guillaume Pellerin | 0f5733b | 2011-07-12 18:13:46 +0200 | [diff] [blame] | 641 | "Fast Track Pro switching to config #2\n"); |
| 642 | /* This function has to be available by the usb core module. |
| 643 | * if it is not avialable the boot quirk has to be left out |
| 644 | * and the configuration has to be set by udev or hotplug |
| 645 | * rules |
| 646 | */ |
| 647 | err = usb_driver_set_configuration(dev, 2); |
David Henningsson | b98ae27 | 2013-01-04 17:02:18 +0100 | [diff] [blame] | 648 | if (err < 0) |
Takashi Iwai | 0ba41d9 | 2014-02-26 13:02:17 +0100 | [diff] [blame] | 649 | dev_dbg(&dev->dev, |
| 650 | "error usb_driver_set_configuration: %d\n", |
| 651 | err); |
David Henningsson | b98ae27 | 2013-01-04 17:02:18 +0100 | [diff] [blame] | 652 | /* Always return an error, so that we stop creating a device |
| 653 | that will just be destroyed and recreated with a new |
| 654 | configuration */ |
| 655 | return -ENODEV; |
Guillaume Pellerin | 0f5733b | 2011-07-12 18:13:46 +0200 | [diff] [blame] | 656 | } else |
Takashi Iwai | 0ba41d9 | 2014-02-26 13:02:17 +0100 | [diff] [blame] | 657 | dev_info(&dev->dev, "Fast Track Pro config OK\n"); |
Guillaume Pellerin | 0f5733b | 2011-07-12 18:13:46 +0200 | [diff] [blame] | 658 | |
| 659 | return 0; |
| 660 | } |
| 661 | |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 662 | /* |
| 663 | * C-Media CM106/CM106+ have four 16-bit internal registers that are nicely |
| 664 | * documented in the device's data sheet. |
| 665 | */ |
| 666 | static int snd_usb_cm106_write_int_reg(struct usb_device *dev, int reg, u16 value) |
| 667 | { |
| 668 | u8 buf[4]; |
| 669 | buf[0] = 0x20; |
| 670 | buf[1] = value & 0xff; |
| 671 | buf[2] = (value >> 8) & 0xff; |
| 672 | buf[3] = reg; |
| 673 | return snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), USB_REQ_SET_CONFIGURATION, |
| 674 | USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_ENDPOINT, |
Clemens Ladisch | 17d900c | 2011-09-26 21:15:27 +0200 | [diff] [blame] | 675 | 0, 0, &buf, 4); |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 676 | } |
| 677 | |
| 678 | static int snd_usb_cm106_boot_quirk(struct usb_device *dev) |
| 679 | { |
| 680 | /* |
| 681 | * Enable line-out driver mode, set headphone source to front |
| 682 | * channels, enable stereo mic. |
| 683 | */ |
| 684 | return snd_usb_cm106_write_int_reg(dev, 2, 0x8004); |
| 685 | } |
| 686 | |
| 687 | /* |
Linus Walleij | ad43d528 | 2018-11-02 22:11:33 +0100 | [diff] [blame] | 688 | * CM6206 registers from the CM6206 datasheet rev 2.1 |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 689 | */ |
Linus Walleij | ad43d528 | 2018-11-02 22:11:33 +0100 | [diff] [blame] | 690 | #define CM6206_REG0_DMA_MASTER BIT(15) |
| 691 | #define CM6206_REG0_SPDIFO_RATE_48K (2 << 12) |
| 692 | #define CM6206_REG0_SPDIFO_RATE_96K (7 << 12) |
| 693 | /* Bit 4 thru 11 is the S/PDIF category code */ |
| 694 | #define CM6206_REG0_SPDIFO_CAT_CODE_GENERAL (0 << 4) |
| 695 | #define CM6206_REG0_SPDIFO_EMPHASIS_CD BIT(3) |
| 696 | #define CM6206_REG0_SPDIFO_COPYRIGHT_NA BIT(2) |
| 697 | #define CM6206_REG0_SPDIFO_NON_AUDIO BIT(1) |
| 698 | #define CM6206_REG0_SPDIFO_PRO_FORMAT BIT(0) |
| 699 | |
| 700 | #define CM6206_REG1_TEST_SEL_CLK BIT(14) |
| 701 | #define CM6206_REG1_PLLBIN_EN BIT(13) |
| 702 | #define CM6206_REG1_SOFT_MUTE_EN BIT(12) |
| 703 | #define CM6206_REG1_GPIO4_OUT BIT(11) |
| 704 | #define CM6206_REG1_GPIO4_OE BIT(10) |
| 705 | #define CM6206_REG1_GPIO3_OUT BIT(9) |
| 706 | #define CM6206_REG1_GPIO3_OE BIT(8) |
| 707 | #define CM6206_REG1_GPIO2_OUT BIT(7) |
| 708 | #define CM6206_REG1_GPIO2_OE BIT(6) |
| 709 | #define CM6206_REG1_GPIO1_OUT BIT(5) |
| 710 | #define CM6206_REG1_GPIO1_OE BIT(4) |
| 711 | #define CM6206_REG1_SPDIFO_INVALID BIT(3) |
| 712 | #define CM6206_REG1_SPDIF_LOOP_EN BIT(2) |
| 713 | #define CM6206_REG1_SPDIFO_DIS BIT(1) |
| 714 | #define CM6206_REG1_SPDIFI_MIX BIT(0) |
| 715 | |
| 716 | #define CM6206_REG2_DRIVER_ON BIT(15) |
| 717 | #define CM6206_REG2_HEADP_SEL_SIDE_CHANNELS (0 << 13) |
| 718 | #define CM6206_REG2_HEADP_SEL_SURROUND_CHANNELS (1 << 13) |
| 719 | #define CM6206_REG2_HEADP_SEL_CENTER_SUBW (2 << 13) |
| 720 | #define CM6206_REG2_HEADP_SEL_FRONT_CHANNELS (3 << 13) |
| 721 | #define CM6206_REG2_MUTE_HEADPHONE_RIGHT BIT(12) |
| 722 | #define CM6206_REG2_MUTE_HEADPHONE_LEFT BIT(11) |
| 723 | #define CM6206_REG2_MUTE_REAR_SURROUND_RIGHT BIT(10) |
| 724 | #define CM6206_REG2_MUTE_REAR_SURROUND_LEFT BIT(9) |
| 725 | #define CM6206_REG2_MUTE_SIDE_SURROUND_RIGHT BIT(8) |
| 726 | #define CM6206_REG2_MUTE_SIDE_SURROUND_LEFT BIT(7) |
| 727 | #define CM6206_REG2_MUTE_SUBWOOFER BIT(6) |
| 728 | #define CM6206_REG2_MUTE_CENTER BIT(5) |
| 729 | #define CM6206_REG2_MUTE_RIGHT_FRONT BIT(3) |
| 730 | #define CM6206_REG2_MUTE_LEFT_FRONT BIT(3) |
| 731 | #define CM6206_REG2_EN_BTL BIT(2) |
| 732 | #define CM6206_REG2_MCUCLKSEL_1_5_MHZ (0) |
| 733 | #define CM6206_REG2_MCUCLKSEL_3_MHZ (1) |
| 734 | #define CM6206_REG2_MCUCLKSEL_6_MHZ (2) |
| 735 | #define CM6206_REG2_MCUCLKSEL_12_MHZ (3) |
| 736 | |
| 737 | /* Bit 11..13 sets the sensitivity to FLY tuner volume control VP/VD signal */ |
| 738 | #define CM6206_REG3_FLYSPEED_DEFAULT (2 << 11) |
| 739 | #define CM6206_REG3_VRAP25EN BIT(10) |
| 740 | #define CM6206_REG3_MSEL1 BIT(9) |
| 741 | #define CM6206_REG3_SPDIFI_RATE_44_1K BIT(0 << 7) |
| 742 | #define CM6206_REG3_SPDIFI_RATE_48K BIT(2 << 7) |
| 743 | #define CM6206_REG3_SPDIFI_RATE_32K BIT(3 << 7) |
| 744 | #define CM6206_REG3_PINSEL BIT(6) |
| 745 | #define CM6206_REG3_FOE BIT(5) |
| 746 | #define CM6206_REG3_ROE BIT(4) |
| 747 | #define CM6206_REG3_CBOE BIT(3) |
| 748 | #define CM6206_REG3_LOSE BIT(2) |
| 749 | #define CM6206_REG3_HPOE BIT(1) |
| 750 | #define CM6206_REG3_SPDIFI_CANREC BIT(0) |
| 751 | |
| 752 | #define CM6206_REG5_DA_RSTN BIT(13) |
| 753 | #define CM6206_REG5_AD_RSTN BIT(12) |
| 754 | #define CM6206_REG5_SPDIFO_AD2SPDO BIT(12) |
| 755 | #define CM6206_REG5_SPDIFO_SEL_FRONT (0 << 9) |
| 756 | #define CM6206_REG5_SPDIFO_SEL_SIDE_SUR (1 << 9) |
| 757 | #define CM6206_REG5_SPDIFO_SEL_CEN_LFE (2 << 9) |
| 758 | #define CM6206_REG5_SPDIFO_SEL_REAR_SUR (3 << 9) |
| 759 | #define CM6206_REG5_CODECM BIT(8) |
| 760 | #define CM6206_REG5_EN_HPF BIT(7) |
| 761 | #define CM6206_REG5_T_SEL_DSDA4 BIT(6) |
| 762 | #define CM6206_REG5_T_SEL_DSDA3 BIT(5) |
| 763 | #define CM6206_REG5_T_SEL_DSDA2 BIT(4) |
| 764 | #define CM6206_REG5_T_SEL_DSDA1 BIT(3) |
| 765 | #define CM6206_REG5_T_SEL_DSDAD_NORMAL 0 |
| 766 | #define CM6206_REG5_T_SEL_DSDAD_FRONT 4 |
| 767 | #define CM6206_REG5_T_SEL_DSDAD_S_SURROUND 5 |
| 768 | #define CM6206_REG5_T_SEL_DSDAD_CEN_LFE 6 |
| 769 | #define CM6206_REG5_T_SEL_DSDAD_R_SURROUND 7 |
| 770 | |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 771 | static int snd_usb_cm6206_boot_quirk(struct usb_device *dev) |
| 772 | { |
Daniel Mack | dac8f84 | 2011-08-06 00:23:18 +0200 | [diff] [blame] | 773 | int err = 0, reg; |
Linus Walleij | ad43d528 | 2018-11-02 22:11:33 +0100 | [diff] [blame] | 774 | int val[] = { |
| 775 | /* |
| 776 | * Values here are chosen based on sniffing USB traffic |
| 777 | * under Windows. |
| 778 | * |
| 779 | * REG0: DAC is master, sample rate 48kHz, no copyright |
| 780 | */ |
| 781 | CM6206_REG0_SPDIFO_RATE_48K | |
| 782 | CM6206_REG0_SPDIFO_COPYRIGHT_NA, |
| 783 | /* |
| 784 | * REG1: PLL binary search enable, soft mute enable. |
| 785 | */ |
| 786 | CM6206_REG1_PLLBIN_EN | |
Amadeusz Sławiński | f5c9571 | 2019-01-08 21:03:11 +0100 | [diff] [blame] | 787 | CM6206_REG1_SOFT_MUTE_EN, |
Linus Walleij | ad43d528 | 2018-11-02 22:11:33 +0100 | [diff] [blame] | 788 | /* |
| 789 | * REG2: enable output drivers, |
| 790 | * select front channels to the headphone output, |
| 791 | * then mute the headphone channels, run the MCU |
| 792 | * at 1.5 MHz. |
| 793 | */ |
| 794 | CM6206_REG2_DRIVER_ON | |
| 795 | CM6206_REG2_HEADP_SEL_FRONT_CHANNELS | |
| 796 | CM6206_REG2_MUTE_HEADPHONE_RIGHT | |
| 797 | CM6206_REG2_MUTE_HEADPHONE_LEFT, |
| 798 | /* |
| 799 | * REG3: default flyspeed, set 2.5V mic bias |
| 800 | * enable all line out ports and enable SPDIF |
| 801 | */ |
| 802 | CM6206_REG3_FLYSPEED_DEFAULT | |
| 803 | CM6206_REG3_VRAP25EN | |
| 804 | CM6206_REG3_FOE | |
| 805 | CM6206_REG3_ROE | |
| 806 | CM6206_REG3_CBOE | |
| 807 | CM6206_REG3_LOSE | |
| 808 | CM6206_REG3_HPOE | |
| 809 | CM6206_REG3_SPDIFI_CANREC, |
| 810 | /* REG4 is just a bunch of GPIO lines */ |
| 811 | 0x0000, |
| 812 | /* REG5: de-assert AD/DA reset signals */ |
| 813 | CM6206_REG5_DA_RSTN | |
| 814 | CM6206_REG5_AD_RSTN }; |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 815 | |
| 816 | for (reg = 0; reg < ARRAY_SIZE(val); reg++) { |
| 817 | err = snd_usb_cm106_write_int_reg(dev, reg, val[reg]); |
| 818 | if (err < 0) |
| 819 | return err; |
| 820 | } |
| 821 | |
| 822 | return err; |
| 823 | } |
| 824 | |
Takashi Iwai | 19570d7 | 2013-12-19 14:32:53 +0100 | [diff] [blame] | 825 | /* quirk for Plantronics GameCom 780 with CM6302 chip */ |
| 826 | static int snd_usb_gamecon780_boot_quirk(struct usb_device *dev) |
| 827 | { |
| 828 | /* set the initial volume and don't change; other values are either |
| 829 | * too loud or silent due to firmware bug (bko#65251) |
| 830 | */ |
Paul S McSpadden | 542baf9 | 2014-08-03 17:47:36 -0500 | [diff] [blame] | 831 | u8 buf[2] = { 0x74, 0xe3 }; |
Takashi Iwai | 19570d7 | 2013-12-19 14:32:53 +0100 | [diff] [blame] | 832 | return snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR, |
| 833 | USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT, |
| 834 | UAC_FU_VOLUME << 8, 9 << 8, buf, 2); |
| 835 | } |
| 836 | |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 837 | /* |
Mark Hills | 5e21233 | 2013-03-17 11:07:53 +0000 | [diff] [blame] | 838 | * Novation Twitch DJ controller |
Eduard Gilmutdinov | 11e424e | 2013-12-20 14:06:58 +0600 | [diff] [blame] | 839 | * Focusrite Novation Saffire 6 USB audio card |
Mark Hills | 5e21233 | 2013-03-17 11:07:53 +0000 | [diff] [blame] | 840 | */ |
Eduard Gilmutdinov | 11e424e | 2013-12-20 14:06:58 +0600 | [diff] [blame] | 841 | static int snd_usb_novation_boot_quirk(struct usb_device *dev) |
Mark Hills | 5e21233 | 2013-03-17 11:07:53 +0000 | [diff] [blame] | 842 | { |
| 843 | /* preemptively set up the device because otherwise the |
| 844 | * raw MIDI endpoints are not active */ |
| 845 | usb_set_interface(dev, 0, 1); |
| 846 | return 0; |
| 847 | } |
| 848 | |
| 849 | /* |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 850 | * This call will put the synth in "USB send" mode, i.e it will send MIDI |
| 851 | * messages through USB (this is disabled at startup). The synth will |
| 852 | * acknowledge by sending a sysex on endpoint 0x85 and by displaying a USB |
| 853 | * sign on its LCD. Values here are chosen based on sniffing USB traffic |
| 854 | * under Windows. |
| 855 | */ |
| 856 | static int snd_usb_accessmusic_boot_quirk(struct usb_device *dev) |
| 857 | { |
| 858 | int err, actual_length; |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 859 | /* "midi send" enable */ |
| 860 | static const u8 seq[] = { 0x4e, 0x73, 0x52, 0x01 }; |
Takashi Iwai | 801ebf1 | 2019-06-24 15:08:28 +0200 | [diff] [blame] | 861 | void *buf; |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 862 | |
Greg Kroah-Hartman | fcc2cc1 | 2020-09-14 17:37:46 +0200 | [diff] [blame] | 863 | if (usb_pipe_type_check(dev, usb_sndintpipe(dev, 0x05))) |
Takashi Iwai | 801ebf1 | 2019-06-24 15:08:28 +0200 | [diff] [blame] | 864 | return -EINVAL; |
| 865 | buf = kmemdup(seq, ARRAY_SIZE(seq), GFP_KERNEL); |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 866 | if (!buf) |
| 867 | return -ENOMEM; |
| 868 | err = usb_interrupt_msg(dev, usb_sndintpipe(dev, 0x05), buf, |
| 869 | ARRAY_SIZE(seq), &actual_length, 1000); |
| 870 | kfree(buf); |
| 871 | if (err < 0) |
| 872 | return err; |
| 873 | |
| 874 | return 0; |
| 875 | } |
| 876 | |
| 877 | /* |
Daniel Mack | 54a8c50 | 2011-02-11 11:08:06 +0000 | [diff] [blame] | 878 | * Some sound cards from Native Instruments are in fact compliant to the USB |
| 879 | * audio standard of version 2 and other approved USB standards, even though |
| 880 | * they come up as vendor-specific device when first connected. |
| 881 | * |
| 882 | * However, they can be told to come up with a new set of descriptors |
| 883 | * upon their next enumeration, and the interfaces announced by the new |
| 884 | * descriptors will then be handled by the kernel's class drivers. As the |
| 885 | * product ID will also change, no further checks are required. |
| 886 | */ |
| 887 | |
| 888 | static int snd_usb_nativeinstruments_boot_quirk(struct usb_device *dev) |
| 889 | { |
Takashi Iwai | 801ebf1 | 2019-06-24 15:08:28 +0200 | [diff] [blame] | 890 | int ret; |
| 891 | |
Takashi Iwai | 801ebf1 | 2019-06-24 15:08:28 +0200 | [diff] [blame] | 892 | ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), |
Daniel Mack | 54a8c50 | 2011-02-11 11:08:06 +0000 | [diff] [blame] | 893 | 0xaf, USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
Eldad Zack | 889d668 | 2013-04-05 20:49:46 +0200 | [diff] [blame] | 894 | 1, 0, NULL, 0, 1000); |
Daniel Mack | 54a8c50 | 2011-02-11 11:08:06 +0000 | [diff] [blame] | 895 | |
| 896 | if (ret < 0) |
| 897 | return ret; |
| 898 | |
| 899 | usb_reset_device(dev); |
| 900 | |
| 901 | /* return -EAGAIN, so the creation of an audio interface for this |
| 902 | * temporary device is aborted. The device will reconnect with a |
| 903 | * new product ID */ |
| 904 | return -EAGAIN; |
| 905 | } |
| 906 | |
Damien Zammit | cb99864 | 2012-12-19 11:27:22 +0100 | [diff] [blame] | 907 | static void mbox2_setup_48_24_magic(struct usb_device *dev) |
| 908 | { |
| 909 | u8 srate[3]; |
| 910 | u8 temp[12]; |
| 911 | |
| 912 | /* Choose 48000Hz permanently */ |
| 913 | srate[0] = 0x80; |
| 914 | srate[1] = 0xbb; |
| 915 | srate[2] = 0x00; |
| 916 | |
| 917 | /* Send the magic! */ |
| 918 | snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), |
| 919 | 0x01, 0x22, 0x0100, 0x0085, &temp, 0x0003); |
| 920 | snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), |
| 921 | 0x81, 0xa2, 0x0100, 0x0085, &srate, 0x0003); |
| 922 | snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), |
| 923 | 0x81, 0xa2, 0x0100, 0x0086, &srate, 0x0003); |
| 924 | snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), |
| 925 | 0x81, 0xa2, 0x0100, 0x0003, &srate, 0x0003); |
| 926 | return; |
| 927 | } |
| 928 | |
| 929 | /* Digidesign Mbox 2 needs to load firmware onboard |
| 930 | * and driver must wait a few seconds for initialisation. |
| 931 | */ |
| 932 | |
| 933 | #define MBOX2_FIRMWARE_SIZE 646 |
| 934 | #define MBOX2_BOOT_LOADING 0x01 /* Hard coded into the device */ |
| 935 | #define MBOX2_BOOT_READY 0x02 /* Hard coded into the device */ |
| 936 | |
Damien Zammit | b7b435e | 2013-01-04 09:51:44 +0100 | [diff] [blame] | 937 | static int snd_usb_mbox2_boot_quirk(struct usb_device *dev) |
Damien Zammit | cb99864 | 2012-12-19 11:27:22 +0100 | [diff] [blame] | 938 | { |
| 939 | struct usb_host_config *config = dev->actconfig; |
| 940 | int err; |
Jiri Slaby | 4909a0c | 2013-02-17 14:33:04 +0100 | [diff] [blame] | 941 | u8 bootresponse[0x12]; |
Damien Zammit | cb99864 | 2012-12-19 11:27:22 +0100 | [diff] [blame] | 942 | int fwsize; |
| 943 | int count; |
| 944 | |
| 945 | fwsize = le16_to_cpu(get_cfg_desc(config)->wTotalLength); |
| 946 | |
| 947 | if (fwsize != MBOX2_FIRMWARE_SIZE) { |
Takashi Iwai | 0ba41d9 | 2014-02-26 13:02:17 +0100 | [diff] [blame] | 948 | dev_err(&dev->dev, "Invalid firmware size=%d.\n", fwsize); |
Damien Zammit | cb99864 | 2012-12-19 11:27:22 +0100 | [diff] [blame] | 949 | return -ENODEV; |
| 950 | } |
| 951 | |
Takashi Iwai | 0ba41d9 | 2014-02-26 13:02:17 +0100 | [diff] [blame] | 952 | dev_dbg(&dev->dev, "Sending Digidesign Mbox 2 boot sequence...\n"); |
Damien Zammit | cb99864 | 2012-12-19 11:27:22 +0100 | [diff] [blame] | 953 | |
| 954 | count = 0; |
Damien Zammit | b7b435e | 2013-01-04 09:51:44 +0100 | [diff] [blame] | 955 | bootresponse[0] = MBOX2_BOOT_LOADING; |
| 956 | while ((bootresponse[0] == MBOX2_BOOT_LOADING) && (count < 10)) { |
Damien Zammit | cb99864 | 2012-12-19 11:27:22 +0100 | [diff] [blame] | 957 | msleep(500); /* 0.5 second delay */ |
| 958 | snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), |
| 959 | /* Control magic - load onboard firmware */ |
| 960 | 0x85, 0xc0, 0x0001, 0x0000, &bootresponse, 0x0012); |
Damien Zammit | b7b435e | 2013-01-04 09:51:44 +0100 | [diff] [blame] | 961 | if (bootresponse[0] == MBOX2_BOOT_READY) |
Damien Zammit | cb99864 | 2012-12-19 11:27:22 +0100 | [diff] [blame] | 962 | break; |
Takashi Iwai | 0ba41d9 | 2014-02-26 13:02:17 +0100 | [diff] [blame] | 963 | dev_dbg(&dev->dev, "device not ready, resending boot sequence...\n"); |
Damien Zammit | cb99864 | 2012-12-19 11:27:22 +0100 | [diff] [blame] | 964 | count++; |
| 965 | } |
| 966 | |
Damien Zammit | b7b435e | 2013-01-04 09:51:44 +0100 | [diff] [blame] | 967 | if (bootresponse[0] != MBOX2_BOOT_READY) { |
Takashi Iwai | 0ba41d9 | 2014-02-26 13:02:17 +0100 | [diff] [blame] | 968 | dev_err(&dev->dev, "Unknown bootresponse=%d, or timed out, ignoring device.\n", bootresponse[0]); |
Damien Zammit | cb99864 | 2012-12-19 11:27:22 +0100 | [diff] [blame] | 969 | return -ENODEV; |
| 970 | } |
| 971 | |
Takashi Iwai | 0ba41d9 | 2014-02-26 13:02:17 +0100 | [diff] [blame] | 972 | dev_dbg(&dev->dev, "device initialised!\n"); |
Damien Zammit | cb99864 | 2012-12-19 11:27:22 +0100 | [diff] [blame] | 973 | |
| 974 | err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, |
| 975 | &dev->descriptor, sizeof(dev->descriptor)); |
| 976 | config = dev->actconfig; |
| 977 | if (err < 0) |
Takashi Iwai | 0ba41d9 | 2014-02-26 13:02:17 +0100 | [diff] [blame] | 978 | dev_dbg(&dev->dev, "error usb_get_descriptor: %d\n", err); |
Damien Zammit | cb99864 | 2012-12-19 11:27:22 +0100 | [diff] [blame] | 979 | |
| 980 | err = usb_reset_configuration(dev); |
| 981 | if (err < 0) |
Takashi Iwai | 0ba41d9 | 2014-02-26 13:02:17 +0100 | [diff] [blame] | 982 | dev_dbg(&dev->dev, "error usb_reset_configuration: %d\n", err); |
| 983 | dev_dbg(&dev->dev, "mbox2_boot: new boot length = %d\n", |
Damien Zammit | cb99864 | 2012-12-19 11:27:22 +0100 | [diff] [blame] | 984 | le16_to_cpu(get_cfg_desc(config)->wTotalLength)); |
| 985 | |
| 986 | mbox2_setup_48_24_magic(dev); |
| 987 | |
Takashi Iwai | 0ba41d9 | 2014-02-26 13:02:17 +0100 | [diff] [blame] | 988 | dev_info(&dev->dev, "Digidesign Mbox 2: 24bit 48kHz"); |
Damien Zammit | cb99864 | 2012-12-19 11:27:22 +0100 | [diff] [blame] | 989 | |
| 990 | return 0; /* Successful boot */ |
| 991 | } |
| 992 | |
Alberto Aguirre | 16bafa7 | 2018-05-08 17:14:13 -0500 | [diff] [blame] | 993 | static int snd_usb_axefx3_boot_quirk(struct usb_device *dev) |
| 994 | { |
| 995 | int err; |
| 996 | |
| 997 | dev_dbg(&dev->dev, "Waiting for Axe-Fx III to boot up...\n"); |
| 998 | |
| 999 | /* If the Axe-Fx III has not fully booted, it will timeout when trying |
| 1000 | * to enable the audio streaming interface. A more generous timeout is |
| 1001 | * used here to detect when the Axe-Fx III has finished booting as the |
| 1002 | * set interface message will be acked once it has |
| 1003 | */ |
| 1004 | err = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), |
| 1005 | USB_REQ_SET_INTERFACE, USB_RECIP_INTERFACE, |
| 1006 | 1, 1, NULL, 0, 120000); |
| 1007 | if (err < 0) { |
| 1008 | dev_err(&dev->dev, |
| 1009 | "failed waiting for Axe-Fx III to boot: %d\n", err); |
| 1010 | return err; |
| 1011 | } |
| 1012 | |
| 1013 | dev_dbg(&dev->dev, "Axe-Fx III is now ready\n"); |
| 1014 | |
| 1015 | err = usb_set_interface(dev, 1, 0); |
| 1016 | if (err < 0) |
| 1017 | dev_dbg(&dev->dev, |
| 1018 | "error stopping Axe-Fx III interface: %d\n", err); |
| 1019 | |
| 1020 | return 0; |
| 1021 | } |
| 1022 | |
Manuel Reinhardt | a634090 | 2019-02-28 20:34:04 +0100 | [diff] [blame] | 1023 | |
| 1024 | #define MICROBOOK_BUF_SIZE 128 |
| 1025 | |
| 1026 | static int snd_usb_motu_microbookii_communicate(struct usb_device *dev, u8 *buf, |
| 1027 | int buf_size, int *length) |
| 1028 | { |
| 1029 | int err, actual_length; |
| 1030 | |
Greg Kroah-Hartman | fcc2cc1 | 2020-09-14 17:37:46 +0200 | [diff] [blame] | 1031 | if (usb_pipe_type_check(dev, usb_sndintpipe(dev, 0x01))) |
Takashi Iwai | 801ebf1 | 2019-06-24 15:08:28 +0200 | [diff] [blame] | 1032 | return -EINVAL; |
Manuel Reinhardt | a634090 | 2019-02-28 20:34:04 +0100 | [diff] [blame] | 1033 | err = usb_interrupt_msg(dev, usb_sndintpipe(dev, 0x01), buf, *length, |
| 1034 | &actual_length, 1000); |
| 1035 | if (err < 0) |
| 1036 | return err; |
| 1037 | |
| 1038 | print_hex_dump(KERN_DEBUG, "MicroBookII snd: ", DUMP_PREFIX_NONE, 16, 1, |
| 1039 | buf, actual_length, false); |
| 1040 | |
| 1041 | memset(buf, 0, buf_size); |
| 1042 | |
Greg Kroah-Hartman | fcc2cc1 | 2020-09-14 17:37:46 +0200 | [diff] [blame] | 1043 | if (usb_pipe_type_check(dev, usb_rcvintpipe(dev, 0x82))) |
Takashi Iwai | 801ebf1 | 2019-06-24 15:08:28 +0200 | [diff] [blame] | 1044 | return -EINVAL; |
Manuel Reinhardt | a634090 | 2019-02-28 20:34:04 +0100 | [diff] [blame] | 1045 | err = usb_interrupt_msg(dev, usb_rcvintpipe(dev, 0x82), buf, buf_size, |
| 1046 | &actual_length, 1000); |
| 1047 | if (err < 0) |
| 1048 | return err; |
| 1049 | |
| 1050 | print_hex_dump(KERN_DEBUG, "MicroBookII rcv: ", DUMP_PREFIX_NONE, 16, 1, |
| 1051 | buf, actual_length, false); |
| 1052 | |
| 1053 | *length = actual_length; |
| 1054 | return 0; |
| 1055 | } |
| 1056 | |
| 1057 | static int snd_usb_motu_microbookii_boot_quirk(struct usb_device *dev) |
| 1058 | { |
| 1059 | int err, actual_length, poll_attempts = 0; |
| 1060 | static const u8 set_samplerate_seq[] = { 0x00, 0x00, 0x00, 0x00, |
| 1061 | 0x00, 0x00, 0x0b, 0x14, |
| 1062 | 0x00, 0x00, 0x00, 0x01 }; |
| 1063 | static const u8 poll_ready_seq[] = { 0x00, 0x04, 0x00, 0x00, |
| 1064 | 0x00, 0x00, 0x0b, 0x18 }; |
| 1065 | u8 *buf = kzalloc(MICROBOOK_BUF_SIZE, GFP_KERNEL); |
| 1066 | |
| 1067 | if (!buf) |
| 1068 | return -ENOMEM; |
| 1069 | |
| 1070 | dev_info(&dev->dev, "Waiting for MOTU Microbook II to boot up...\n"); |
| 1071 | |
| 1072 | /* First we tell the device which sample rate to use. */ |
| 1073 | memcpy(buf, set_samplerate_seq, sizeof(set_samplerate_seq)); |
| 1074 | actual_length = sizeof(set_samplerate_seq); |
| 1075 | err = snd_usb_motu_microbookii_communicate(dev, buf, MICROBOOK_BUF_SIZE, |
| 1076 | &actual_length); |
| 1077 | |
| 1078 | if (err < 0) { |
| 1079 | dev_err(&dev->dev, |
| 1080 | "failed setting the sample rate for Motu MicroBook II: %d\n", |
| 1081 | err); |
| 1082 | goto free_buf; |
| 1083 | } |
| 1084 | |
| 1085 | /* Then we poll every 100 ms until the device informs of its readiness. */ |
| 1086 | while (true) { |
| 1087 | if (++poll_attempts > 100) { |
| 1088 | dev_err(&dev->dev, |
| 1089 | "failed booting Motu MicroBook II: timeout\n"); |
| 1090 | err = -ENODEV; |
| 1091 | goto free_buf; |
| 1092 | } |
| 1093 | |
| 1094 | memset(buf, 0, MICROBOOK_BUF_SIZE); |
| 1095 | memcpy(buf, poll_ready_seq, sizeof(poll_ready_seq)); |
| 1096 | |
| 1097 | actual_length = sizeof(poll_ready_seq); |
| 1098 | err = snd_usb_motu_microbookii_communicate( |
| 1099 | dev, buf, MICROBOOK_BUF_SIZE, &actual_length); |
| 1100 | if (err < 0) { |
| 1101 | dev_err(&dev->dev, |
| 1102 | "failed booting Motu MicroBook II: communication error %d\n", |
| 1103 | err); |
| 1104 | goto free_buf; |
| 1105 | } |
| 1106 | |
| 1107 | /* the device signals its readiness through a message of the |
| 1108 | * form |
| 1109 | * XX 06 00 00 00 00 0b 18 00 00 00 01 |
| 1110 | * If the device is not yet ready to accept audio data, the |
| 1111 | * last byte of that sequence is 00. |
| 1112 | */ |
| 1113 | if (actual_length == 12 && buf[actual_length - 1] == 1) |
| 1114 | break; |
| 1115 | |
| 1116 | msleep(100); |
| 1117 | } |
| 1118 | |
| 1119 | dev_info(&dev->dev, "MOTU MicroBook II ready\n"); |
| 1120 | |
| 1121 | free_buf: |
| 1122 | kfree(buf); |
| 1123 | return err; |
| 1124 | } |
| 1125 | |
Alexander Tsoy | 73ac9f5 | 2020-01-12 13:23:58 +0300 | [diff] [blame] | 1126 | static int snd_usb_motu_m_series_boot_quirk(struct usb_device *dev) |
| 1127 | { |
Alexander Tsoy | 73ac9f5 | 2020-01-12 13:23:58 +0300 | [diff] [blame] | 1128 | msleep(2000); |
| 1129 | |
Alexander Tsoy | 73ac9f5 | 2020-01-12 13:23:58 +0300 | [diff] [blame] | 1130 | return 0; |
| 1131 | } |
| 1132 | |
Daniel Mack | 54a8c50 | 2011-02-11 11:08:06 +0000 | [diff] [blame] | 1133 | /* |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1134 | * Setup quirks |
| 1135 | */ |
Guillaume Pellerin | 0f5733b | 2011-07-12 18:13:46 +0200 | [diff] [blame] | 1136 | #define MAUDIO_SET 0x01 /* parse device_setup */ |
| 1137 | #define MAUDIO_SET_COMPATIBLE 0x80 /* use only "win-compatible" interfaces */ |
| 1138 | #define MAUDIO_SET_DTS 0x02 /* enable DTS Digital Output */ |
Alexander Tsoy | 5ff40e6 | 2020-06-29 06:26:07 +0300 | [diff] [blame] | 1139 | #define MAUDIO_SET_96K 0x04 /* 48-96kHz rate if set, 8-48kHz otherwise */ |
Guillaume Pellerin | 0f5733b | 2011-07-12 18:13:46 +0200 | [diff] [blame] | 1140 | #define MAUDIO_SET_24B 0x08 /* 24bits sample if set, 16bits otherwise */ |
| 1141 | #define MAUDIO_SET_DI 0x10 /* enable Digital Input */ |
| 1142 | #define MAUDIO_SET_MASK 0x1f /* bit mask for setup value */ |
Alexander Tsoy | 5ff40e6 | 2020-06-29 06:26:07 +0300 | [diff] [blame] | 1143 | #define MAUDIO_SET_24B_48K_DI 0x19 /* 24bits+48kHz+Digital Input */ |
| 1144 | #define MAUDIO_SET_24B_48K_NOTDI 0x09 /* 24bits+48kHz+No Digital Input */ |
| 1145 | #define MAUDIO_SET_16B_48K_DI 0x11 /* 16bits+48kHz+Digital Input */ |
| 1146 | #define MAUDIO_SET_16B_48K_NOTDI 0x01 /* 16bits+48kHz+No Digital Input */ |
Guillaume Pellerin | 0f5733b | 2011-07-12 18:13:46 +0200 | [diff] [blame] | 1147 | |
| 1148 | static int quattro_skip_setting_quirk(struct snd_usb_audio *chip, |
| 1149 | int iface, int altno) |
| 1150 | { |
| 1151 | /* Reset ALL ifaces to 0 altsetting. |
| 1152 | * Call it for every possible altsetting of every interface. |
| 1153 | */ |
| 1154 | usb_set_interface(chip->dev, iface, 0); |
| 1155 | if (chip->setup & MAUDIO_SET) { |
| 1156 | if (chip->setup & MAUDIO_SET_COMPATIBLE) { |
| 1157 | if (iface != 1 && iface != 2) |
| 1158 | return 1; /* skip all interfaces but 1 and 2 */ |
| 1159 | } else { |
| 1160 | unsigned int mask; |
| 1161 | if (iface == 1 || iface == 2) |
| 1162 | return 1; /* skip interfaces 1 and 2 */ |
| 1163 | if ((chip->setup & MAUDIO_SET_96K) && altno != 1) |
| 1164 | return 1; /* skip this altsetting */ |
| 1165 | mask = chip->setup & MAUDIO_SET_MASK; |
| 1166 | if (mask == MAUDIO_SET_24B_48K_DI && altno != 2) |
| 1167 | return 1; /* skip this altsetting */ |
| 1168 | if (mask == MAUDIO_SET_24B_48K_NOTDI && altno != 3) |
| 1169 | return 1; /* skip this altsetting */ |
| 1170 | if (mask == MAUDIO_SET_16B_48K_NOTDI && altno != 4) |
| 1171 | return 1; /* skip this altsetting */ |
| 1172 | } |
| 1173 | } |
Takashi Iwai | 0ba41d9 | 2014-02-26 13:02:17 +0100 | [diff] [blame] | 1174 | usb_audio_dbg(chip, |
Guillaume Pellerin | 0f5733b | 2011-07-12 18:13:46 +0200 | [diff] [blame] | 1175 | "using altsetting %d for interface %d config %d\n", |
| 1176 | altno, iface, chip->setup); |
| 1177 | return 0; /* keep this altsetting */ |
| 1178 | } |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1179 | |
| 1180 | static int audiophile_skip_setting_quirk(struct snd_usb_audio *chip, |
| 1181 | int iface, |
| 1182 | int altno) |
| 1183 | { |
| 1184 | /* Reset ALL ifaces to 0 altsetting. |
| 1185 | * Call it for every possible altsetting of every interface. |
| 1186 | */ |
| 1187 | usb_set_interface(chip->dev, iface, 0); |
| 1188 | |
Guillaume Pellerin | 0f5733b | 2011-07-12 18:13:46 +0200 | [diff] [blame] | 1189 | if (chip->setup & MAUDIO_SET) { |
| 1190 | unsigned int mask; |
| 1191 | if ((chip->setup & MAUDIO_SET_DTS) && altno != 6) |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1192 | return 1; /* skip this altsetting */ |
Guillaume Pellerin | 0f5733b | 2011-07-12 18:13:46 +0200 | [diff] [blame] | 1193 | if ((chip->setup & MAUDIO_SET_96K) && altno != 1) |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1194 | return 1; /* skip this altsetting */ |
Guillaume Pellerin | 0f5733b | 2011-07-12 18:13:46 +0200 | [diff] [blame] | 1195 | mask = chip->setup & MAUDIO_SET_MASK; |
| 1196 | if (mask == MAUDIO_SET_24B_48K_DI && altno != 2) |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1197 | return 1; /* skip this altsetting */ |
Guillaume Pellerin | 0f5733b | 2011-07-12 18:13:46 +0200 | [diff] [blame] | 1198 | if (mask == MAUDIO_SET_24B_48K_NOTDI && altno != 3) |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1199 | return 1; /* skip this altsetting */ |
Guillaume Pellerin | 0f5733b | 2011-07-12 18:13:46 +0200 | [diff] [blame] | 1200 | if (mask == MAUDIO_SET_16B_48K_DI && altno != 4) |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1201 | return 1; /* skip this altsetting */ |
Guillaume Pellerin | 0f5733b | 2011-07-12 18:13:46 +0200 | [diff] [blame] | 1202 | if (mask == MAUDIO_SET_16B_48K_NOTDI && altno != 5) |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1203 | return 1; /* skip this altsetting */ |
| 1204 | } |
| 1205 | |
| 1206 | return 0; /* keep this altsetting */ |
| 1207 | } |
| 1208 | |
Guillaume Pellerin | 0f5733b | 2011-07-12 18:13:46 +0200 | [diff] [blame] | 1209 | static int fasttrackpro_skip_setting_quirk(struct snd_usb_audio *chip, |
| 1210 | int iface, int altno) |
| 1211 | { |
| 1212 | /* Reset ALL ifaces to 0 altsetting. |
| 1213 | * Call it for every possible altsetting of every interface. |
| 1214 | */ |
| 1215 | usb_set_interface(chip->dev, iface, 0); |
| 1216 | |
| 1217 | /* possible configuration where both inputs and only one output is |
| 1218 | *used is not supported by the current setup |
| 1219 | */ |
| 1220 | if (chip->setup & (MAUDIO_SET | MAUDIO_SET_24B)) { |
| 1221 | if (chip->setup & MAUDIO_SET_96K) { |
| 1222 | if (altno != 3 && altno != 6) |
| 1223 | return 1; |
| 1224 | } else if (chip->setup & MAUDIO_SET_DI) { |
| 1225 | if (iface == 4) |
| 1226 | return 1; /* no analog input */ |
| 1227 | if (altno != 2 && altno != 5) |
| 1228 | return 1; /* enable only altsets 2 and 5 */ |
| 1229 | } else { |
| 1230 | if (iface == 5) |
| 1231 | return 1; /* disable digialt input */ |
| 1232 | if (altno != 2 && altno != 5) |
| 1233 | return 1; /* enalbe only altsets 2 and 5 */ |
| 1234 | } |
| 1235 | } else { |
| 1236 | /* keep only 16-Bit mode */ |
| 1237 | if (altno != 1) |
| 1238 | return 1; |
| 1239 | } |
| 1240 | |
Takashi Iwai | 0ba41d9 | 2014-02-26 13:02:17 +0100 | [diff] [blame] | 1241 | usb_audio_dbg(chip, |
Guillaume Pellerin | 0f5733b | 2011-07-12 18:13:46 +0200 | [diff] [blame] | 1242 | "using altsetting %d for interface %d config %d\n", |
| 1243 | altno, iface, chip->setup); |
| 1244 | return 0; /* keep this altsetting */ |
| 1245 | } |
| 1246 | |
Nick Kossifidis | 8dc5efe | 2020-02-15 03:23:35 +0200 | [diff] [blame] | 1247 | static int s1810c_skip_setting_quirk(struct snd_usb_audio *chip, |
| 1248 | int iface, int altno) |
| 1249 | { |
| 1250 | /* |
| 1251 | * Altno settings: |
| 1252 | * |
| 1253 | * Playback (Interface 1): |
| 1254 | * 1: 6 Analog + 2 S/PDIF |
| 1255 | * 2: 6 Analog + 2 S/PDIF |
| 1256 | * 3: 6 Analog |
| 1257 | * |
| 1258 | * Capture (Interface 2): |
| 1259 | * 1: 8 Analog + 2 S/PDIF + 8 ADAT |
| 1260 | * 2: 8 Analog + 2 S/PDIF + 4 ADAT |
| 1261 | * 3: 8 Analog |
| 1262 | */ |
| 1263 | |
| 1264 | /* |
| 1265 | * I'll leave 2 as the default one and |
| 1266 | * use device_setup to switch to the |
| 1267 | * other two. |
| 1268 | */ |
| 1269 | if ((chip->setup == 0 || chip->setup > 2) && altno != 2) |
| 1270 | return 1; |
| 1271 | else if (chip->setup == 1 && altno != 1) |
| 1272 | return 1; |
| 1273 | else if (chip->setup == 2 && altno != 3) |
| 1274 | return 1; |
| 1275 | |
| 1276 | return 0; |
| 1277 | } |
| 1278 | |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1279 | int snd_usb_apply_interface_quirk(struct snd_usb_audio *chip, |
| 1280 | int iface, |
| 1281 | int altno) |
| 1282 | { |
| 1283 | /* audiophile usb: skip altsets incompatible with device_setup */ |
| 1284 | if (chip->usb_id == USB_ID(0x0763, 0x2003)) |
| 1285 | return audiophile_skip_setting_quirk(chip, iface, altno); |
Guillaume Pellerin | 0f5733b | 2011-07-12 18:13:46 +0200 | [diff] [blame] | 1286 | /* quattro usb: skip altsets incompatible with device_setup */ |
| 1287 | if (chip->usb_id == USB_ID(0x0763, 0x2001)) |
| 1288 | return quattro_skip_setting_quirk(chip, iface, altno); |
| 1289 | /* fasttrackpro usb: skip altsets incompatible with device_setup */ |
| 1290 | if (chip->usb_id == USB_ID(0x0763, 0x2012)) |
| 1291 | return fasttrackpro_skip_setting_quirk(chip, iface, altno); |
Nick Kossifidis | 8dc5efe | 2020-02-15 03:23:35 +0200 | [diff] [blame] | 1292 | /* presonus studio 1810c: skip altsets incompatible with device_setup */ |
Takashi Iwai | 1e583ae | 2021-12-02 09:38:33 +0100 | [diff] [blame] | 1293 | if (chip->usb_id == USB_ID(0x194f, 0x010c)) |
Nick Kossifidis | 8dc5efe | 2020-02-15 03:23:35 +0200 | [diff] [blame] | 1294 | return s1810c_skip_setting_quirk(chip, iface, altno); |
| 1295 | |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1296 | |
| 1297 | return 0; |
| 1298 | } |
| 1299 | |
| 1300 | int snd_usb_apply_boot_quirk(struct usb_device *dev, |
| 1301 | struct usb_interface *intf, |
Takashi Iwai | 79289e2 | 2016-01-11 11:33:34 +0100 | [diff] [blame] | 1302 | const struct snd_usb_audio_quirk *quirk, |
| 1303 | unsigned int id) |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1304 | { |
Daniel Mack | 3347b26 | 2011-02-11 11:34:12 +0000 | [diff] [blame] | 1305 | switch (id) { |
| 1306 | case USB_ID(0x041e, 0x3000): |
| 1307 | /* SB Extigy needs special boot-up sequence */ |
| 1308 | /* if more models come, this will go to the quirk list. */ |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1309 | return snd_usb_extigy_boot_quirk(dev, intf); |
| 1310 | |
Daniel Mack | 3347b26 | 2011-02-11 11:34:12 +0000 | [diff] [blame] | 1311 | case USB_ID(0x041e, 0x3020): |
| 1312 | /* SB Audigy 2 NX needs its own boot-up magic, too */ |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1313 | return snd_usb_audigy2nx_boot_quirk(dev); |
| 1314 | |
Daniel Mack | 3347b26 | 2011-02-11 11:34:12 +0000 | [diff] [blame] | 1315 | case USB_ID(0x10f5, 0x0200): |
| 1316 | /* C-Media CM106 / Turtle Beach Audio Advantage Roadie */ |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1317 | return snd_usb_cm106_boot_quirk(dev); |
| 1318 | |
Daniel Mack | 3347b26 | 2011-02-11 11:34:12 +0000 | [diff] [blame] | 1319 | case USB_ID(0x0d8c, 0x0102): |
| 1320 | /* C-Media CM6206 / CM106-Like Sound Device */ |
Wolfgang Breyha | 8129e79 | 2011-04-28 16:18:40 +0200 | [diff] [blame] | 1321 | case USB_ID(0x0ccd, 0x00b1): /* Terratec Aureon 7.1 USB */ |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1322 | return snd_usb_cm6206_boot_quirk(dev); |
| 1323 | |
Damien Zammit | cb99864 | 2012-12-19 11:27:22 +0100 | [diff] [blame] | 1324 | case USB_ID(0x0dba, 0x3000): |
| 1325 | /* Digidesign Mbox 2 */ |
| 1326 | return snd_usb_mbox2_boot_quirk(dev); |
| 1327 | |
Eduard Gilmutdinov | 11e424e | 2013-12-20 14:06:58 +0600 | [diff] [blame] | 1328 | case USB_ID(0x1235, 0x0010): /* Focusrite Novation Saffire 6 USB */ |
| 1329 | case USB_ID(0x1235, 0x0018): /* Focusrite Novation Twitch */ |
| 1330 | return snd_usb_novation_boot_quirk(dev); |
Mark Hills | 5e21233 | 2013-03-17 11:07:53 +0000 | [diff] [blame] | 1331 | |
Daniel Mack | 3347b26 | 2011-02-11 11:34:12 +0000 | [diff] [blame] | 1332 | case USB_ID(0x133e, 0x0815): |
| 1333 | /* Access Music VirusTI Desktop */ |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1334 | return snd_usb_accessmusic_boot_quirk(dev); |
| 1335 | |
Daniel Mack | 759e890f | 2011-05-18 11:28:41 +0200 | [diff] [blame] | 1336 | case USB_ID(0x17cc, 0x1000): /* Komplete Audio 6 */ |
Daniel Mack | 3347b26 | 2011-02-11 11:34:12 +0000 | [diff] [blame] | 1337 | case USB_ID(0x17cc, 0x1010): /* Traktor Audio 6 */ |
| 1338 | case USB_ID(0x17cc, 0x1020): /* Traktor Audio 10 */ |
Daniel Mack | 54a8c50 | 2011-02-11 11:08:06 +0000 | [diff] [blame] | 1339 | return snd_usb_nativeinstruments_boot_quirk(dev); |
Guillaume Pellerin | 0f5733b | 2011-07-12 18:13:46 +0200 | [diff] [blame] | 1340 | case USB_ID(0x0763, 0x2012): /* M-Audio Fast Track Pro USB */ |
| 1341 | return snd_usb_fasttrackpro_boot_quirk(dev); |
Takashi Iwai | 19570d7 | 2013-12-19 14:32:53 +0100 | [diff] [blame] | 1342 | case USB_ID(0x047f, 0xc010): /* Plantronics Gamecom 780 */ |
| 1343 | return snd_usb_gamecon780_boot_quirk(dev); |
Alberto Aguirre | 16bafa7 | 2018-05-08 17:14:13 -0500 | [diff] [blame] | 1344 | case USB_ID(0x2466, 0x8010): /* Fractal Audio Axe-Fx 3 */ |
| 1345 | return snd_usb_axefx3_boot_quirk(dev); |
Manuel Reinhardt | a634090 | 2019-02-28 20:34:04 +0100 | [diff] [blame] | 1346 | case USB_ID(0x07fd, 0x0004): /* MOTU MicroBook II */ |
Alexander Tsoy | 2edb84e | 2020-02-29 18:18:15 +0300 | [diff] [blame] | 1347 | /* |
| 1348 | * For some reason interface 3 with vendor-spec class is |
| 1349 | * detected on MicroBook IIc. |
| 1350 | */ |
| 1351 | if (get_iface_desc(intf->altsetting)->bInterfaceClass == |
| 1352 | USB_CLASS_VENDOR_SPEC && |
| 1353 | get_iface_desc(intf->altsetting)->bInterfaceNumber < 3) |
| 1354 | return snd_usb_motu_microbookii_boot_quirk(dev); |
| 1355 | break; |
Daniel Mack | 3347b26 | 2011-02-11 11:34:12 +0000 | [diff] [blame] | 1356 | } |
Daniel Mack | 54a8c50 | 2011-02-11 11:08:06 +0000 | [diff] [blame] | 1357 | |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1358 | return 0; |
| 1359 | } |
| 1360 | |
Alexander Tsoy | 73ac9f5 | 2020-01-12 13:23:58 +0300 | [diff] [blame] | 1361 | int snd_usb_apply_boot_quirk_once(struct usb_device *dev, |
| 1362 | struct usb_interface *intf, |
| 1363 | const struct snd_usb_audio_quirk *quirk, |
| 1364 | unsigned int id) |
| 1365 | { |
| 1366 | switch (id) { |
| 1367 | case USB_ID(0x07fd, 0x0008): /* MOTU M Series */ |
| 1368 | return snd_usb_motu_m_series_boot_quirk(dev); |
| 1369 | } |
| 1370 | |
| 1371 | return 0; |
| 1372 | } |
| 1373 | |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1374 | /* |
| 1375 | * check if the device uses big-endian samples |
| 1376 | */ |
Takashi Iwai | cab941b | 2020-11-23 09:53:33 +0100 | [diff] [blame] | 1377 | int snd_usb_is_big_endian_format(struct snd_usb_audio *chip, |
| 1378 | const struct audioformat *fp) |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1379 | { |
Adam Buchbinder | 48fc7f7 | 2012-09-19 21:48:00 -0400 | [diff] [blame] | 1380 | /* it depends on altsetting whether the device is big-endian or not */ |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1381 | switch (chip->usb_id) { |
| 1382 | case USB_ID(0x0763, 0x2001): /* M-Audio Quattro: captured data only */ |
Guillaume Pellerin | 0f5733b | 2011-07-12 18:13:46 +0200 | [diff] [blame] | 1383 | if (fp->altsetting == 2 || fp->altsetting == 3 || |
| 1384 | fp->altsetting == 5 || fp->altsetting == 6) |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1385 | return 1; |
| 1386 | break; |
| 1387 | case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */ |
| 1388 | if (chip->setup == 0x00 || |
Guillaume Pellerin | 0f5733b | 2011-07-12 18:13:46 +0200 | [diff] [blame] | 1389 | fp->altsetting == 1 || fp->altsetting == 2 || |
| 1390 | fp->altsetting == 3) |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1391 | return 1; |
Guillaume Pellerin | 0f5733b | 2011-07-12 18:13:46 +0200 | [diff] [blame] | 1392 | break; |
| 1393 | case USB_ID(0x0763, 0x2012): /* M-Audio Fast Track Pro */ |
| 1394 | if (fp->altsetting == 2 || fp->altsetting == 3 || |
| 1395 | fp->altsetting == 5 || fp->altsetting == 6) |
| 1396 | return 1; |
| 1397 | break; |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1398 | } |
| 1399 | return 0; |
| 1400 | } |
| 1401 | |
| 1402 | /* |
Joseph Teichman | 1cdfa9f | 2011-02-08 01:22:36 -0500 | [diff] [blame] | 1403 | * For E-Mu 0404USB/0202USB/TrackerPre/0204 sample rate should be set for device, |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1404 | * not for interface. |
| 1405 | */ |
| 1406 | |
| 1407 | enum { |
| 1408 | EMU_QUIRK_SR_44100HZ = 0, |
| 1409 | EMU_QUIRK_SR_48000HZ, |
| 1410 | EMU_QUIRK_SR_88200HZ, |
| 1411 | EMU_QUIRK_SR_96000HZ, |
| 1412 | EMU_QUIRK_SR_176400HZ, |
| 1413 | EMU_QUIRK_SR_192000HZ |
| 1414 | }; |
| 1415 | |
| 1416 | static void set_format_emu_quirk(struct snd_usb_substream *subs, |
Takashi Iwai | cab941b | 2020-11-23 09:53:33 +0100 | [diff] [blame] | 1417 | const struct audioformat *fmt) |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1418 | { |
| 1419 | unsigned char emu_samplerate_id = 0; |
| 1420 | |
| 1421 | /* When capture is active |
| 1422 | * sample rate shouldn't be changed |
| 1423 | * by playback substream |
| 1424 | */ |
| 1425 | if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK) { |
Takashi Iwai | 6aa719d | 2020-11-23 09:53:36 +0100 | [diff] [blame] | 1426 | if (subs->stream->substream[SNDRV_PCM_STREAM_CAPTURE].cur_audiofmt) |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1427 | return; |
| 1428 | } |
| 1429 | |
| 1430 | switch (fmt->rate_min) { |
| 1431 | case 48000: |
| 1432 | emu_samplerate_id = EMU_QUIRK_SR_48000HZ; |
| 1433 | break; |
| 1434 | case 88200: |
| 1435 | emu_samplerate_id = EMU_QUIRK_SR_88200HZ; |
| 1436 | break; |
| 1437 | case 96000: |
| 1438 | emu_samplerate_id = EMU_QUIRK_SR_96000HZ; |
| 1439 | break; |
| 1440 | case 176400: |
| 1441 | emu_samplerate_id = EMU_QUIRK_SR_176400HZ; |
| 1442 | break; |
| 1443 | case 192000: |
| 1444 | emu_samplerate_id = EMU_QUIRK_SR_192000HZ; |
| 1445 | break; |
| 1446 | default: |
| 1447 | emu_samplerate_id = EMU_QUIRK_SR_44100HZ; |
| 1448 | break; |
| 1449 | } |
| 1450 | snd_emuusb_set_samplerate(subs->stream->chip, emu_samplerate_id); |
Calvin Owens | 1539d4f | 2013-04-12 22:33:59 -0500 | [diff] [blame] | 1451 | subs->pkt_offset_adj = (emu_samplerate_id >= EMU_QUIRK_SR_176400HZ) ? 4 : 0; |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1452 | } |
| 1453 | |
Olivia Mackintosh | 3b85f5f | 2021-02-02 13:42:26 +0000 | [diff] [blame] | 1454 | static int pioneer_djm_set_format_quirk(struct snd_usb_substream *subs, |
| 1455 | u16 windex) |
| 1456 | { |
| 1457 | unsigned int cur_rate = subs->data_endpoint->cur_rate; |
| 1458 | u8 sr[3]; |
| 1459 | // Convert to little endian |
| 1460 | sr[0] = cur_rate & 0xff; |
| 1461 | sr[1] = (cur_rate >> 8) & 0xff; |
| 1462 | sr[2] = (cur_rate >> 16) & 0xff; |
| 1463 | usb_set_interface(subs->dev, 0, 1); |
| 1464 | // we should derive windex from fmt-sync_ep but it's not set |
| 1465 | snd_usb_ctl_msg(subs->stream->chip->dev, |
Nicolas MURE | 2c91190 | 2021-03-01 15:29:27 +0100 | [diff] [blame] | 1466 | usb_sndctrlpipe(subs->stream->chip->dev, 0), |
Olivia Mackintosh | 3b85f5f | 2021-02-02 13:42:26 +0000 | [diff] [blame] | 1467 | 0x01, 0x22, 0x0100, windex, &sr, 0x0003); |
| 1468 | return 0; |
| 1469 | } |
| 1470 | |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1471 | void snd_usb_set_format_quirk(struct snd_usb_substream *subs, |
Takashi Iwai | cab941b | 2020-11-23 09:53:33 +0100 | [diff] [blame] | 1472 | const struct audioformat *fmt) |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1473 | { |
| 1474 | switch (subs->stream->chip->usb_id) { |
| 1475 | case USB_ID(0x041e, 0x3f02): /* E-Mu 0202 USB */ |
| 1476 | case USB_ID(0x041e, 0x3f04): /* E-Mu 0404 USB */ |
| 1477 | case USB_ID(0x041e, 0x3f0a): /* E-Mu Tracker Pre */ |
Joseph Teichman | 1cdfa9f | 2011-02-08 01:22:36 -0500 | [diff] [blame] | 1478 | case USB_ID(0x041e, 0x3f19): /* E-Mu 0204 USB */ |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1479 | set_format_emu_quirk(subs, fmt); |
| 1480 | break; |
Hector Martin | 1b7ecc2 | 2020-08-10 17:24:00 +0900 | [diff] [blame] | 1481 | case USB_ID(0x534d, 0x2109): /* MacroSilicon MS2109 */ |
| 1482 | subs->stream_offset_adj = 2; |
| 1483 | break; |
Olivia Mackintosh | 3b85f5f | 2021-02-02 13:42:26 +0000 | [diff] [blame] | 1484 | case USB_ID(0x2b73, 0x0013): /* Pioneer DJM-450 */ |
| 1485 | pioneer_djm_set_format_quirk(subs, 0x0082); |
| 1486 | break; |
Olivia Mackintosh | e7df7df | 2021-04-18 17:59:01 +0100 | [diff] [blame] | 1487 | case USB_ID(0x08e4, 0x017f): /* Pioneer DJM-750 */ |
Nicolas MURE | 1a2a94a | 2021-03-01 16:27:28 +0100 | [diff] [blame] | 1488 | case USB_ID(0x08e4, 0x0163): /* Pioneer DJM-850 */ |
| 1489 | pioneer_djm_set_format_quirk(subs, 0x0086); |
| 1490 | break; |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 1491 | } |
| 1492 | } |
| 1493 | |
Takashi Iwai | d767aba | 2020-11-23 09:53:24 +0100 | [diff] [blame] | 1494 | int snd_usb_select_mode_quirk(struct snd_usb_audio *chip, |
Takashi Iwai | cab941b | 2020-11-23 09:53:33 +0100 | [diff] [blame] | 1495 | const struct audioformat *fmt) |
Jurgen Kramer | 6874daa | 2014-11-28 17:32:54 +0100 | [diff] [blame] | 1496 | { |
Takashi Iwai | d767aba | 2020-11-23 09:53:24 +0100 | [diff] [blame] | 1497 | struct usb_device *dev = chip->dev; |
Jurgen Kramer | 6874daa | 2014-11-28 17:32:54 +0100 | [diff] [blame] | 1498 | int err; |
| 1499 | |
Takashi Iwai | 2de00d5 | 2021-07-29 09:38:53 +0200 | [diff] [blame] | 1500 | if (chip->quirk_flags & QUIRK_FLAG_ITF_USB_DSD_DAC) { |
Jurgen Kramer | 6874daa | 2014-11-28 17:32:54 +0100 | [diff] [blame] | 1501 | /* First switch to alt set 0, otherwise the mode switch cmd |
| 1502 | * will not be accepted by the DAC |
| 1503 | */ |
| 1504 | err = usb_set_interface(dev, fmt->iface, 0); |
| 1505 | if (err < 0) |
| 1506 | return err; |
| 1507 | |
Jia-Ju Bai | df3f034 | 2018-07-27 16:55:28 +0800 | [diff] [blame] | 1508 | msleep(20); /* Delay needed after setting the interface */ |
Jurgen Kramer | 6874daa | 2014-11-28 17:32:54 +0100 | [diff] [blame] | 1509 | |
Nobutaka Okabe | 7f38ca0 | 2016-12-13 01:24:08 +0900 | [diff] [blame] | 1510 | /* Vendor mode switch cmd is required. */ |
Nobutaka Okabe | f3b906d | 2018-03-23 19:21:13 +0900 | [diff] [blame] | 1511 | if (fmt->formats & SNDRV_PCM_FMTBIT_DSD_U32_BE) { |
| 1512 | /* DSD mode (DSD_U32) requested */ |
Nobutaka Okabe | 7f38ca0 | 2016-12-13 01:24:08 +0900 | [diff] [blame] | 1513 | err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), 0, |
| 1514 | USB_DIR_OUT|USB_TYPE_VENDOR|USB_RECIP_INTERFACE, |
| 1515 | 1, 1, NULL, 0); |
| 1516 | if (err < 0) |
| 1517 | return err; |
Nobutaka Okabe | 7f38ca0 | 2016-12-13 01:24:08 +0900 | [diff] [blame] | 1518 | |
Nobutaka Okabe | f3b906d | 2018-03-23 19:21:13 +0900 | [diff] [blame] | 1519 | } else { |
| 1520 | /* PCM or DOP mode (S32) requested */ |
| 1521 | /* PCM mode (S16) requested */ |
Nobutaka Okabe | 7f38ca0 | 2016-12-13 01:24:08 +0900 | [diff] [blame] | 1522 | err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), 0, |
| 1523 | USB_DIR_OUT|USB_TYPE_VENDOR|USB_RECIP_INTERFACE, |
| 1524 | 0, 1, NULL, 0); |
| 1525 | if (err < 0) |
| 1526 | return err; |
Nobutaka Okabe | f3b906d | 2018-03-23 19:21:13 +0900 | [diff] [blame] | 1527 | |
Nobutaka Okabe | 7f38ca0 | 2016-12-13 01:24:08 +0900 | [diff] [blame] | 1528 | } |
Jia-Ju Bai | df3f034 | 2018-07-27 16:55:28 +0800 | [diff] [blame] | 1529 | msleep(20); |
Jurgen Kramer | 6874daa | 2014-11-28 17:32:54 +0100 | [diff] [blame] | 1530 | } |
| 1531 | return 0; |
| 1532 | } |
| 1533 | |
Daniel Mack | 2b58fd5 | 2012-09-04 10:23:07 +0200 | [diff] [blame] | 1534 | void snd_usb_endpoint_start_quirk(struct snd_usb_endpoint *ep) |
| 1535 | { |
| 1536 | /* |
| 1537 | * "Playback Design" products send bogus feedback data at the start |
| 1538 | * of the stream. Ignore them. |
| 1539 | */ |
Takashi Iwai | 79289e2 | 2016-01-11 11:33:34 +0100 | [diff] [blame] | 1540 | if (USB_ID_VENDOR(ep->chip->usb_id) == 0x23ba && |
Daniel Mack | 2b58fd5 | 2012-09-04 10:23:07 +0200 | [diff] [blame] | 1541 | ep->type == SND_USB_ENDPOINT_TYPE_SYNC) |
| 1542 | ep->skip_packets = 4; |
Eldad Zack | 83e3acd | 2013-01-13 23:02:03 +0100 | [diff] [blame] | 1543 | |
| 1544 | /* |
Matt Gruskin | e9a25e0 | 2013-02-09 12:56:35 -0500 | [diff] [blame] | 1545 | * M-Audio Fast Track C400/C600 - when packets are not skipped, real |
Alexander Tsoy | 5ff40e6 | 2020-06-29 06:26:07 +0300 | [diff] [blame] | 1546 | * world latency varies by approx. +/- 50 frames (at 96kHz) each time |
Matt Gruskin | e9a25e0 | 2013-02-09 12:56:35 -0500 | [diff] [blame] | 1547 | * the stream is (re)started. When skipping packets 16 at endpoint |
| 1548 | * start up, the real world latency is stable within +/- 1 frame (also |
Eldad Zack | 83e3acd | 2013-01-13 23:02:03 +0100 | [diff] [blame] | 1549 | * across power cycles). |
| 1550 | */ |
Matt Gruskin | e9a25e0 | 2013-02-09 12:56:35 -0500 | [diff] [blame] | 1551 | if ((ep->chip->usb_id == USB_ID(0x0763, 0x2030) || |
| 1552 | ep->chip->usb_id == USB_ID(0x0763, 0x2031)) && |
Eldad Zack | 83e3acd | 2013-01-13 23:02:03 +0100 | [diff] [blame] | 1553 | ep->type == SND_USB_ENDPOINT_TYPE_DATA) |
| 1554 | ep->skip_packets = 16; |
Daniel Mack | 9abc134 | 2016-08-22 08:53:36 +0200 | [diff] [blame] | 1555 | |
| 1556 | /* Work around devices that report unreasonable feedback data */ |
Daniel Mack | ca0dd27 | 2016-08-22 08:53:37 +0200 | [diff] [blame] | 1557 | if ((ep->chip->usb_id == USB_ID(0x0644, 0x8038) || /* TEAC UD-H01 */ |
| 1558 | ep->chip->usb_id == USB_ID(0x1852, 0x5034)) && /* T+A Dac8 */ |
Daniel Mack | 9abc134 | 2016-08-22 08:53:36 +0200 | [diff] [blame] | 1559 | ep->syncmaxsize == 4) |
Daniel Mack | ca0dd27 | 2016-08-22 08:53:37 +0200 | [diff] [blame] | 1560 | ep->tenor_fb_quirk = 1; |
Daniel Mack | 2b58fd5 | 2012-09-04 10:23:07 +0200 | [diff] [blame] | 1561 | } |
| 1562 | |
Takashi Iwai | 79289e2 | 2016-01-11 11:33:34 +0100 | [diff] [blame] | 1563 | /* quirk applied after snd_usb_ctl_msg(); not applied during boot quirks */ |
Daniel Mack | 2b58fd5 | 2012-09-04 10:23:07 +0200 | [diff] [blame] | 1564 | void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe, |
| 1565 | __u8 request, __u8 requesttype, __u16 value, |
| 1566 | __u16 index, void *data, __u16 size) |
| 1567 | { |
Takashi Iwai | 79289e2 | 2016-01-11 11:33:34 +0100 | [diff] [blame] | 1568 | struct snd_usb_audio *chip = dev_get_drvdata(&dev->dev); |
| 1569 | |
Takashi Iwai | f748385 | 2021-07-29 09:38:54 +0200 | [diff] [blame] | 1570 | if (!chip || (requesttype & USB_TYPE_MASK) != USB_TYPE_CLASS) |
Takashi Iwai | 79289e2 | 2016-01-11 11:33:34 +0100 | [diff] [blame] | 1571 | return; |
Jurgen Kramer | 6e84a8d | 2014-11-15 14:01:21 +0100 | [diff] [blame] | 1572 | |
Takashi Iwai | f748385 | 2021-07-29 09:38:54 +0200 | [diff] [blame] | 1573 | if (chip->quirk_flags & QUIRK_FLAG_CTL_MSG_DELAY) |
Jia-Ju Bai | df3f034 | 2018-07-27 16:55:28 +0800 | [diff] [blame] | 1574 | msleep(20); |
Takashi Iwai | f748385 | 2021-07-29 09:38:54 +0200 | [diff] [blame] | 1575 | else if (chip->quirk_flags & QUIRK_FLAG_CTL_MSG_DELAY_1M) |
Jia-Ju Bai | df3f034 | 2018-07-27 16:55:28 +0800 | [diff] [blame] | 1576 | usleep_range(1000, 2000); |
Takashi Iwai | f748385 | 2021-07-29 09:38:54 +0200 | [diff] [blame] | 1577 | else if (chip->quirk_flags & QUIRK_FLAG_CTL_MSG_DELAY_5M) |
Macpaul Lin | a32a1fc | 2020-06-23 19:03:23 +0800 | [diff] [blame] | 1578 | usleep_range(5000, 6000); |
Daniel Mack | 2b58fd5 | 2012-09-04 10:23:07 +0200 | [diff] [blame] | 1579 | } |
| 1580 | |
Daniel Mack | 126825e | 2013-04-17 00:01:40 +0800 | [diff] [blame] | 1581 | /* |
| 1582 | * snd_usb_interface_dsd_format_quirks() is called from format.c to |
| 1583 | * augment the PCM format bit-field for DSD types. The UAC standards |
| 1584 | * don't have a designated bit field to denote DSD-capable interfaces, |
| 1585 | * hence all hardware that is known to support this format has to be |
| 1586 | * listed here. |
| 1587 | */ |
| 1588 | u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, |
| 1589 | struct audioformat *fp, |
| 1590 | unsigned int sample_bytes) |
| 1591 | { |
Nobutaka Okabe | f3b906d | 2018-03-23 19:21:13 +0900 | [diff] [blame] | 1592 | struct usb_interface *iface; |
| 1593 | |
Daniel Mack | 126825e | 2013-04-17 00:01:40 +0800 | [diff] [blame] | 1594 | /* Playback Designs */ |
Jussi Laako | eb7505d | 2019-08-28 00:08:46 +0300 | [diff] [blame] | 1595 | if (USB_ID_VENDOR(chip->usb_id) == 0x23ba && |
| 1596 | USB_ID_PRODUCT(chip->usb_id) < 0x0110) { |
Daniel Mack | 126825e | 2013-04-17 00:01:40 +0800 | [diff] [blame] | 1597 | switch (fp->altsetting) { |
| 1598 | case 1: |
| 1599 | fp->dsd_dop = true; |
| 1600 | return SNDRV_PCM_FMTBIT_DSD_U16_LE; |
| 1601 | case 2: |
| 1602 | fp->dsd_bitrev = true; |
| 1603 | return SNDRV_PCM_FMTBIT_DSD_U8; |
| 1604 | case 3: |
| 1605 | fp->dsd_bitrev = true; |
| 1606 | return SNDRV_PCM_FMTBIT_DSD_U16_LE; |
| 1607 | } |
| 1608 | } |
| 1609 | |
Jurgen Kramer | 848f3a8 | 2014-09-05 18:14:46 +0200 | [diff] [blame] | 1610 | /* XMOS based USB DACs */ |
| 1611 | switch (chip->usb_id) { |
Daniel Mack | f656891 | 2018-04-20 22:29:41 +0200 | [diff] [blame] | 1612 | case USB_ID(0x1511, 0x0037): /* AURALiC VEGA */ |
Daniel Mack | f656891 | 2018-04-20 22:29:41 +0200 | [diff] [blame] | 1613 | case USB_ID(0x2522, 0x0012): /* LH Labs VI DAC Infinity */ |
Jussi Laako | 9bb201a | 2017-10-15 12:41:32 +0300 | [diff] [blame] | 1614 | case USB_ID(0x2772, 0x0230): /* Pro-Ject Pre Box S2 Digital */ |
Jurgen Kramer | 848f3a8 | 2014-09-05 18:14:46 +0200 | [diff] [blame] | 1615 | if (fp->altsetting == 2) |
Jussi Laako | d42472e | 2014-11-21 16:04:46 +0200 | [diff] [blame] | 1616 | return SNDRV_PCM_FMTBIT_DSD_U32_BE; |
Jurgen Kramer | 848f3a8 | 2014-09-05 18:14:46 +0200 | [diff] [blame] | 1617 | break; |
Jurgen Kramer | 3b7e5c7 | 2015-06-05 09:42:49 +0200 | [diff] [blame] | 1618 | |
Daniel Mack | f656891 | 2018-04-20 22:29:41 +0200 | [diff] [blame] | 1619 | case USB_ID(0x0d8c, 0x0316): /* Hegel HD12 DSD */ |
Jussi Laako | 202e69e | 2019-01-29 00:47:01 +0200 | [diff] [blame] | 1620 | case USB_ID(0x10cb, 0x0103): /* The Bit Opus #3; with fp->dsd_raw */ |
Takashi Iwai | 547d2c9 | 2020-04-30 14:47:55 +0200 | [diff] [blame] | 1621 | case USB_ID(0x16d0, 0x06b2): /* NuPrime DAC-10 */ |
Jussi Laako | 202e69e | 2019-01-29 00:47:01 +0200 | [diff] [blame] | 1622 | case USB_ID(0x16d0, 0x09dd): /* Encore mDSD */ |
Daniel Mack | f656891 | 2018-04-20 22:29:41 +0200 | [diff] [blame] | 1623 | case USB_ID(0x16d0, 0x0733): /* Furutech ADL Stratos */ |
| 1624 | case USB_ID(0x16d0, 0x09db): /* NuPrime Audio DAC-9 */ |
| 1625 | case USB_ID(0x1db5, 0x0003): /* Bryston BDA3 */ |
Daniel Mack | f656891 | 2018-04-20 22:29:41 +0200 | [diff] [blame] | 1626 | case USB_ID(0x22e1, 0xca01): /* HDTA Serenade DSD */ |
| 1627 | case USB_ID(0x249c, 0x9326): /* M2Tech Young MkIII */ |
Jurgen Kramer | ad678b4 | 2016-01-29 14:59:25 +0100 | [diff] [blame] | 1628 | case USB_ID(0x2616, 0x0106): /* PS Audio NuWave DAC */ |
Daniel Mack | f656891 | 2018-04-20 22:29:41 +0200 | [diff] [blame] | 1629 | case USB_ID(0x2622, 0x0041): /* Audiolab M-DAC+ */ |
| 1630 | case USB_ID(0x27f7, 0x3002): /* W4S DAC-2v2SE */ |
| 1631 | case USB_ID(0x29a2, 0x0086): /* Mutec MC3+ USB */ |
| 1632 | case USB_ID(0x6b42, 0x0042): /* MSB Technology */ |
Jurgen Kramer | 848f3a8 | 2014-09-05 18:14:46 +0200 | [diff] [blame] | 1633 | if (fp->altsetting == 3) |
Jussi Laako | d42472e | 2014-11-21 16:04:46 +0200 | [diff] [blame] | 1634 | return SNDRV_PCM_FMTBIT_DSD_U32_BE; |
Jurgen Kramer | 848f3a8 | 2014-09-05 18:14:46 +0200 | [diff] [blame] | 1635 | break; |
Jussi Laako | 3eff682 | 2016-12-17 23:51:41 +0200 | [diff] [blame] | 1636 | |
Daniel Mack | 7c74866 | 2018-02-11 09:50:27 -0400 | [diff] [blame] | 1637 | /* Amanero Combo384 USB based DACs with native DSD support */ |
| 1638 | case USB_ID(0x16d0, 0x071a): /* Amanero - Combo384 */ |
| 1639 | case USB_ID(0x2ab6, 0x0004): /* T+A DAC8DSD-V2.0, MP1000E-V2.0, MP2000R-V2.0, MP2500R-V2.0, MP3100HV-V2.0 */ |
| 1640 | case USB_ID(0x2ab6, 0x0005): /* T+A USB HD Audio 1 */ |
| 1641 | case USB_ID(0x2ab6, 0x0006): /* T+A USB HD Audio 2 */ |
Jussi Laako | 3eff682 | 2016-12-17 23:51:41 +0200 | [diff] [blame] | 1642 | if (fp->altsetting == 2) { |
Johan Hovold | f83914f | 2017-05-12 14:34:37 +0200 | [diff] [blame] | 1643 | switch (le16_to_cpu(chip->dev->descriptor.bcdDevice)) { |
Jussi Laako | 3eff682 | 2016-12-17 23:51:41 +0200 | [diff] [blame] | 1644 | case 0x199: |
| 1645 | return SNDRV_PCM_FMTBIT_DSD_U32_LE; |
| 1646 | case 0x19b: |
Jussi Laako | f5ce817 | 2017-11-01 23:32:33 +0200 | [diff] [blame] | 1647 | case 0x203: |
Jussi Laako | 3eff682 | 2016-12-17 23:51:41 +0200 | [diff] [blame] | 1648 | return SNDRV_PCM_FMTBIT_DSD_U32_BE; |
| 1649 | default: |
| 1650 | break; |
| 1651 | } |
| 1652 | } |
| 1653 | break; |
Jussi Laako | ed993c6 | 2017-08-18 10:42:14 +0300 | [diff] [blame] | 1654 | case USB_ID(0x16d0, 0x0a23): |
| 1655 | if (fp->altsetting == 2) |
| 1656 | return SNDRV_PCM_FMTBIT_DSD_U32_BE; |
| 1657 | break; |
Jussi Laako | 3eff682 | 2016-12-17 23:51:41 +0200 | [diff] [blame] | 1658 | |
Jurgen Kramer | 848f3a8 | 2014-09-05 18:14:46 +0200 | [diff] [blame] | 1659 | default: |
| 1660 | break; |
| 1661 | } |
| 1662 | |
Nobutaka Okabe | f3b906d | 2018-03-23 19:21:13 +0900 | [diff] [blame] | 1663 | /* ITF-USB DSD based DACs */ |
Takashi Iwai | 2de00d5 | 2021-07-29 09:38:53 +0200 | [diff] [blame] | 1664 | if (chip->quirk_flags & QUIRK_FLAG_ITF_USB_DSD_DAC) { |
Nobutaka Okabe | f3b906d | 2018-03-23 19:21:13 +0900 | [diff] [blame] | 1665 | iface = usb_ifnum_to_if(chip->dev, fp->iface); |
Jurgen Kramer | 7a2e9dd | 2014-11-28 17:32:53 +0100 | [diff] [blame] | 1666 | |
Nobutaka Okabe | f3b906d | 2018-03-23 19:21:13 +0900 | [diff] [blame] | 1667 | /* Altsetting 2 support native DSD if the num of altsets is |
| 1668 | * three (0-2), |
| 1669 | * Altsetting 3 support native DSD if the num of altsets is |
| 1670 | * four (0-3). |
| 1671 | */ |
| 1672 | if (fp->altsetting == iface->num_altsetting - 1) |
Nobutaka Okabe | 7f38ca0 | 2016-12-13 01:24:08 +0900 | [diff] [blame] | 1673 | return SNDRV_PCM_FMTBIT_DSD_U32_BE; |
| 1674 | } |
| 1675 | |
Takashi Iwai | 68e851e | 2021-07-29 09:44:02 +0200 | [diff] [blame] | 1676 | /* Mostly generic method to detect many DSD-capable implementations */ |
| 1677 | if ((chip->quirk_flags & QUIRK_FLAG_DSD_RAW) && fp->dsd_raw) |
| 1678 | return SNDRV_PCM_FMTBIT_DSD_U32_BE; |
Jussi Laako | 3a572d9 | 2018-06-13 01:43:01 +0300 | [diff] [blame] | 1679 | |
Daniel Mack | 126825e | 2013-04-17 00:01:40 +0800 | [diff] [blame] | 1680 | return 0; |
| 1681 | } |
Ruslan Bilovol | ceb18f5 | 2018-03-19 03:46:02 +0200 | [diff] [blame] | 1682 | |
| 1683 | void snd_usb_audioformat_attributes_quirk(struct snd_usb_audio *chip, |
| 1684 | struct audioformat *fp, |
| 1685 | int stream) |
| 1686 | { |
| 1687 | switch (chip->usb_id) { |
| 1688 | case USB_ID(0x0a92, 0x0053): /* AudioTrak Optoplay */ |
| 1689 | /* Optoplay sets the sample rate attribute although |
| 1690 | * it seems not supporting it in fact. |
| 1691 | */ |
| 1692 | fp->attributes &= ~UAC_EP_CS_ATTR_SAMPLE_RATE; |
| 1693 | break; |
| 1694 | case USB_ID(0x041e, 0x3020): /* Creative SB Audigy 2 NX */ |
| 1695 | case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */ |
| 1696 | /* doesn't set the sample rate attribute, but supports it */ |
| 1697 | fp->attributes |= UAC_EP_CS_ATTR_SAMPLE_RATE; |
| 1698 | break; |
| 1699 | case USB_ID(0x0763, 0x2001): /* M-Audio Quattro USB */ |
| 1700 | case USB_ID(0x0763, 0x2012): /* M-Audio Fast Track Pro USB */ |
| 1701 | case USB_ID(0x047f, 0x0ca1): /* plantronics headset */ |
| 1702 | case USB_ID(0x077d, 0x07af): /* Griffin iMic (note that there is |
| 1703 | an older model 77d:223) */ |
| 1704 | /* |
| 1705 | * plantronics headset and Griffin iMic have set adaptive-in |
| 1706 | * although it's really not... |
| 1707 | */ |
| 1708 | fp->ep_attr &= ~USB_ENDPOINT_SYNCTYPE; |
| 1709 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) |
| 1710 | fp->ep_attr |= USB_ENDPOINT_SYNC_ADAPTIVE; |
| 1711 | else |
| 1712 | fp->ep_attr |= USB_ENDPOINT_SYNC_SYNC; |
| 1713 | break; |
Alexander Tsoy | 2edb84e | 2020-02-29 18:18:15 +0300 | [diff] [blame] | 1714 | case USB_ID(0x07fd, 0x0004): /* MOTU MicroBook IIc */ |
| 1715 | /* |
| 1716 | * MaxPacketsOnly attribute is erroneously set in endpoint |
| 1717 | * descriptors. As a result this card produces noise with |
Alexander Tsoy | 5ff40e6 | 2020-06-29 06:26:07 +0300 | [diff] [blame] | 1718 | * all sample rates other than 96 kHz. |
Alexander Tsoy | 2edb84e | 2020-02-29 18:18:15 +0300 | [diff] [blame] | 1719 | */ |
| 1720 | fp->attributes &= ~UAC_EP_CS_ATTR_FILL_MAX; |
| 1721 | break; |
Marco Giunta | 2966492 | 2021-10-18 18:25:52 +0200 | [diff] [blame] | 1722 | case USB_ID(0x1224, 0x2a25): /* Jieli Technology USB PHY 2.0 */ |
| 1723 | /* mic works only when ep packet size is set to wMaxPacketSize */ |
| 1724 | fp->attributes |= UAC_EP_CS_ATTR_FILL_MAX; |
| 1725 | break; |
| 1726 | |
Ruslan Bilovol | ceb18f5 | 2018-03-19 03:46:02 +0200 | [diff] [blame] | 1727 | } |
| 1728 | } |
Chris Wulff | 55f7326 | 2020-03-14 12:54:49 -0400 | [diff] [blame] | 1729 | |
Takashi Iwai | d8695bc | 2020-03-25 11:33:19 +0100 | [diff] [blame] | 1730 | /* |
| 1731 | * registration quirk: |
| 1732 | * the registration is skipped if a device matches with the given ID, |
| 1733 | * unless the interface reaches to the defined one. This is for delaying |
| 1734 | * the registration until the last known interface, so that the card and |
| 1735 | * devices appear at the same time. |
| 1736 | */ |
| 1737 | |
| 1738 | struct registration_quirk { |
| 1739 | unsigned int usb_id; /* composed via USB_ID() */ |
| 1740 | unsigned int interface; /* the interface to trigger register */ |
| 1741 | }; |
| 1742 | |
| 1743 | #define REG_QUIRK_ENTRY(vendor, product, iface) \ |
| 1744 | { .usb_id = USB_ID(vendor, product), .interface = (iface) } |
| 1745 | |
| 1746 | static const struct registration_quirk registration_quirks[] = { |
| 1747 | REG_QUIRK_ENTRY(0x0951, 0x16d8, 2), /* Kingston HyperX AMP */ |
Emmanuel Pescosta | fd60e06 | 2020-04-04 17:38:43 +0200 | [diff] [blame] | 1748 | REG_QUIRK_ENTRY(0x0951, 0x16ed, 2), /* Kingston HyperX Cloud Alpha S */ |
Christoffer Nielsen | 7309460 | 2020-06-19 13:48:22 +0200 | [diff] [blame] | 1749 | REG_QUIRK_ENTRY(0x0951, 0x16ea, 2), /* Kingston HyperX Cloud Flight S */ |
Alexander Tsoy | b0084af | 2021-07-22 02:56:05 +0300 | [diff] [blame] | 1750 | REG_QUIRK_ENTRY(0x0ecb, 0x1f46, 2), /* JBL Quantum 600 */ |
Alexander Tsoy | c8b177b | 2021-08-31 03:25:31 +0300 | [diff] [blame] | 1751 | REG_QUIRK_ENTRY(0x0ecb, 0x1f47, 2), /* JBL Quantum 800 */ |
Alexander Tsoy | 763d92e | 2021-10-30 20:43:08 +0300 | [diff] [blame] | 1752 | REG_QUIRK_ENTRY(0x0ecb, 0x1f4c, 2), /* JBL Quantum 400 */ |
Alexander Tsoy | b0084af | 2021-07-22 02:56:05 +0300 | [diff] [blame] | 1753 | REG_QUIRK_ENTRY(0x0ecb, 0x2039, 2), /* JBL Quantum 400 */ |
Alexander Tsoy | 4b0556b | 2021-07-27 12:33:26 +0300 | [diff] [blame] | 1754 | REG_QUIRK_ENTRY(0x0ecb, 0x203c, 2), /* JBL Quantum 600 */ |
Alexander Tsoy | b0084af | 2021-07-22 02:56:05 +0300 | [diff] [blame] | 1755 | REG_QUIRK_ENTRY(0x0ecb, 0x203e, 2), /* JBL Quantum 800 */ |
Takashi Iwai | d8695bc | 2020-03-25 11:33:19 +0100 | [diff] [blame] | 1756 | { 0 } /* terminator */ |
| 1757 | }; |
| 1758 | |
| 1759 | /* return true if skipping registration */ |
| 1760 | bool snd_usb_registration_quirk(struct snd_usb_audio *chip, int iface) |
Chris Wulff | 55f7326 | 2020-03-14 12:54:49 -0400 | [diff] [blame] | 1761 | { |
Takashi Iwai | d8695bc | 2020-03-25 11:33:19 +0100 | [diff] [blame] | 1762 | const struct registration_quirk *q; |
| 1763 | |
| 1764 | for (q = registration_quirks; q->usb_id; q++) |
| 1765 | if (chip->usb_id == q->usb_id) |
| 1766 | return iface != q->interface; |
| 1767 | |
Chris Wulff | 55f7326 | 2020-03-14 12:54:49 -0400 | [diff] [blame] | 1768 | /* Register as normal */ |
Takashi Iwai | d8695bc | 2020-03-25 11:33:19 +0100 | [diff] [blame] | 1769 | return false; |
Chris Wulff | 55f7326 | 2020-03-14 12:54:49 -0400 | [diff] [blame] | 1770 | } |
Takashi Iwai | 4d4dee0 | 2021-07-29 09:38:47 +0200 | [diff] [blame] | 1771 | |
| 1772 | /* |
| 1773 | * driver behavior quirk flags |
| 1774 | */ |
| 1775 | struct usb_audio_quirk_flags_table { |
| 1776 | u32 id; |
| 1777 | u32 flags; |
| 1778 | }; |
| 1779 | |
| 1780 | #define DEVICE_FLG(vid, pid, _flags) \ |
| 1781 | { .id = USB_ID(vid, pid), .flags = (_flags) } |
| 1782 | #define VENDOR_FLG(vid, _flags) DEVICE_FLG(vid, 0, _flags) |
| 1783 | |
| 1784 | static const struct usb_audio_quirk_flags_table quirk_flags_table[] = { |
| 1785 | /* Device matches */ |
Takashi Iwai | 3c69dc9 | 2021-07-29 09:44:01 +0200 | [diff] [blame] | 1786 | DEVICE_FLG(0x041e, 0x3000, /* Creative SB Extigy */ |
| 1787 | QUIRK_FLAG_IGNORE_CTL_ERROR), |
Takashi Iwai | 4d4dee0 | 2021-07-29 09:38:47 +0200 | [diff] [blame] | 1788 | DEVICE_FLG(0x041e, 0x4080, /* Creative Live Cam VF0610 */ |
| 1789 | QUIRK_FLAG_GET_SAMPLE_RATE), |
| 1790 | DEVICE_FLG(0x046d, 0x084c, /* Logitech ConferenceCam Connect */ |
Takashi Iwai | f748385 | 2021-07-29 09:38:54 +0200 | [diff] [blame] | 1791 | QUIRK_FLAG_GET_SAMPLE_RATE | QUIRK_FLAG_CTL_MSG_DELAY_1M), |
Takashi Iwai | 3c69dc9 | 2021-07-29 09:44:01 +0200 | [diff] [blame] | 1792 | DEVICE_FLG(0x046d, 0x0991, /* Logitech QuickCam Pro */ |
| 1793 | QUIRK_FLAG_CTL_MSG_DELAY_1M | QUIRK_FLAG_IGNORE_CTL_ERROR), |
| 1794 | DEVICE_FLG(0x046d, 0x09a4, /* Logitech QuickCam E 3500 */ |
| 1795 | QUIRK_FLAG_CTL_MSG_DELAY_1M | QUIRK_FLAG_IGNORE_CTL_ERROR), |
Takashi Iwai | 4d4dee0 | 2021-07-29 09:38:47 +0200 | [diff] [blame] | 1796 | DEVICE_FLG(0x04d8, 0xfeea, /* Benchmark DAC1 Pre */ |
| 1797 | QUIRK_FLAG_GET_SAMPLE_RATE), |
Takashi Iwai | f21dca8 | 2021-07-29 09:38:52 +0200 | [diff] [blame] | 1798 | DEVICE_FLG(0x04e8, 0xa051, /* Samsung USBC Headset (AKG) */ |
Takashi Iwai | f748385 | 2021-07-29 09:38:54 +0200 | [diff] [blame] | 1799 | QUIRK_FLAG_SKIP_CLOCK_SELECTOR | QUIRK_FLAG_CTL_MSG_DELAY_5M), |
Takashi Iwai | 6e41340 | 2021-08-24 07:57:20 +0200 | [diff] [blame] | 1800 | DEVICE_FLG(0x054c, 0x0b8c, /* Sony WALKMAN NW-A45 DAC */ |
| 1801 | QUIRK_FLAG_SET_IFACE_FIRST), |
Takashi Iwai | 4d4dee0 | 2021-07-29 09:38:47 +0200 | [diff] [blame] | 1802 | DEVICE_FLG(0x0556, 0x0014, /* Phoenix Audio TMX320VC */ |
| 1803 | QUIRK_FLAG_GET_SAMPLE_RATE), |
| 1804 | DEVICE_FLG(0x05a3, 0x9420, /* ELP HD USB Camera */ |
| 1805 | QUIRK_FLAG_GET_SAMPLE_RATE), |
| 1806 | DEVICE_FLG(0x05a7, 0x1020, /* Bose Companion 5 */ |
| 1807 | QUIRK_FLAG_GET_SAMPLE_RATE), |
Takashi Iwai | af158a7 | 2021-07-29 09:38:49 +0200 | [diff] [blame] | 1808 | DEVICE_FLG(0x05e1, 0x0408, /* Syntek STK1160 */ |
| 1809 | QUIRK_FLAG_ALIGN_TRANSFER), |
Takashi Iwai | ce47d47 | 2021-07-29 09:38:48 +0200 | [diff] [blame] | 1810 | DEVICE_FLG(0x05e1, 0x0480, /* Hauppauge Woodbury */ |
Takashi Iwai | af158a7 | 2021-07-29 09:38:49 +0200 | [diff] [blame] | 1811 | QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER), |
Takashi Iwai | 2de00d5 | 2021-07-29 09:38:53 +0200 | [diff] [blame] | 1812 | DEVICE_FLG(0x0644, 0x8043, /* TEAC UD-501/UD-501V2/UD-503/NT-503 */ |
Takashi Iwai | 1f074fe | 2021-07-29 09:38:55 +0200 | [diff] [blame] | 1813 | QUIRK_FLAG_ITF_USB_DSD_DAC | QUIRK_FLAG_CTL_MSG_DELAY | |
| 1814 | QUIRK_FLAG_IFACE_DELAY), |
Takashi Iwai | 2de00d5 | 2021-07-29 09:38:53 +0200 | [diff] [blame] | 1815 | DEVICE_FLG(0x0644, 0x8044, /* Esoteric D-05X */ |
Takashi Iwai | 1f074fe | 2021-07-29 09:38:55 +0200 | [diff] [blame] | 1816 | QUIRK_FLAG_ITF_USB_DSD_DAC | QUIRK_FLAG_CTL_MSG_DELAY | |
| 1817 | QUIRK_FLAG_IFACE_DELAY), |
Takashi Iwai | 2de00d5 | 2021-07-29 09:38:53 +0200 | [diff] [blame] | 1818 | DEVICE_FLG(0x0644, 0x804a, /* TEAC UD-301 */ |
Takashi Iwai | 1f074fe | 2021-07-29 09:38:55 +0200 | [diff] [blame] | 1819 | QUIRK_FLAG_ITF_USB_DSD_DAC | QUIRK_FLAG_CTL_MSG_DELAY | |
| 1820 | QUIRK_FLAG_IFACE_DELAY), |
Takashi Iwai | 3c69dc9 | 2021-07-29 09:44:01 +0200 | [diff] [blame] | 1821 | DEVICE_FLG(0x06f8, 0xb000, /* Hercules DJ Console (Windows Edition) */ |
| 1822 | QUIRK_FLAG_IGNORE_CTL_ERROR), |
| 1823 | DEVICE_FLG(0x06f8, 0xd002, /* Hercules DJ Console (Macintosh Edition) */ |
| 1824 | QUIRK_FLAG_IGNORE_CTL_ERROR), |
Takashi Iwai | 4d4dee0 | 2021-07-29 09:38:47 +0200 | [diff] [blame] | 1825 | DEVICE_FLG(0x074d, 0x3553, /* Outlaw RR2150 (Micronas UAC3553B) */ |
| 1826 | QUIRK_FLAG_GET_SAMPLE_RATE), |
Takashi Iwai | 3c69dc9 | 2021-07-29 09:44:01 +0200 | [diff] [blame] | 1827 | DEVICE_FLG(0x08bb, 0x2702, /* LineX FM Transmitter */ |
| 1828 | QUIRK_FLAG_IGNORE_CTL_ERROR), |
Takashi Iwai | f748385 | 2021-07-29 09:38:54 +0200 | [diff] [blame] | 1829 | DEVICE_FLG(0x0951, 0x16ad, /* Kingston HyperX */ |
| 1830 | QUIRK_FLAG_CTL_MSG_DELAY_1M), |
| 1831 | DEVICE_FLG(0x0b0e, 0x0349, /* Jabra 550a */ |
| 1832 | QUIRK_FLAG_CTL_MSG_DELAY_1M), |
Takashi Iwai | ce47d47 | 2021-07-29 09:38:48 +0200 | [diff] [blame] | 1833 | DEVICE_FLG(0x0fd9, 0x0008, /* Hauppauge HVR-950Q */ |
Takashi Iwai | af158a7 | 2021-07-29 09:38:49 +0200 | [diff] [blame] | 1834 | QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER), |
Takashi Iwai | 4d4dee0 | 2021-07-29 09:38:47 +0200 | [diff] [blame] | 1835 | DEVICE_FLG(0x1395, 0x740a, /* Sennheiser DECT */ |
| 1836 | QUIRK_FLAG_GET_SAMPLE_RATE), |
Takashi Iwai | 3c69dc9 | 2021-07-29 09:44:01 +0200 | [diff] [blame] | 1837 | DEVICE_FLG(0x13e5, 0x0001, /* Serato Phono */ |
| 1838 | QUIRK_FLAG_IGNORE_CTL_ERROR), |
Takashi Iwai | 2de00d5 | 2021-07-29 09:38:53 +0200 | [diff] [blame] | 1839 | DEVICE_FLG(0x154e, 0x1002, /* Denon DCD-1500RE */ |
Takashi Iwai | f748385 | 2021-07-29 09:38:54 +0200 | [diff] [blame] | 1840 | QUIRK_FLAG_ITF_USB_DSD_DAC | QUIRK_FLAG_CTL_MSG_DELAY), |
Takashi Iwai | 2de00d5 | 2021-07-29 09:38:53 +0200 | [diff] [blame] | 1841 | DEVICE_FLG(0x154e, 0x1003, /* Denon DA-300USB */ |
Takashi Iwai | f748385 | 2021-07-29 09:38:54 +0200 | [diff] [blame] | 1842 | QUIRK_FLAG_ITF_USB_DSD_DAC | QUIRK_FLAG_CTL_MSG_DELAY), |
Takashi Iwai | 2de00d5 | 2021-07-29 09:38:53 +0200 | [diff] [blame] | 1843 | DEVICE_FLG(0x154e, 0x3005, /* Marantz HD-DAC1 */ |
Takashi Iwai | f748385 | 2021-07-29 09:38:54 +0200 | [diff] [blame] | 1844 | QUIRK_FLAG_ITF_USB_DSD_DAC | QUIRK_FLAG_CTL_MSG_DELAY), |
Takashi Iwai | 2de00d5 | 2021-07-29 09:38:53 +0200 | [diff] [blame] | 1845 | DEVICE_FLG(0x154e, 0x3006, /* Marantz SA-14S1 */ |
Takashi Iwai | f748385 | 2021-07-29 09:38:54 +0200 | [diff] [blame] | 1846 | QUIRK_FLAG_ITF_USB_DSD_DAC | QUIRK_FLAG_CTL_MSG_DELAY), |
Takashi Iwai | f21dca8 | 2021-07-29 09:38:52 +0200 | [diff] [blame] | 1847 | DEVICE_FLG(0x154e, 0x500e, /* Denon DN-X1600 */ |
| 1848 | QUIRK_FLAG_IGNORE_CLOCK_SOURCE), |
Takashi Iwai | c1b034a | 2021-07-29 09:38:50 +0200 | [diff] [blame] | 1849 | DEVICE_FLG(0x1686, 0x00dd, /* Zoom R16/24 */ |
Takashi Iwai | f748385 | 2021-07-29 09:38:54 +0200 | [diff] [blame] | 1850 | QUIRK_FLAG_TX_LENGTH | QUIRK_FLAG_CTL_MSG_DELAY_1M), |
Takashi Iwai | 44e6fc6 | 2021-07-29 09:44:00 +0200 | [diff] [blame] | 1851 | DEVICE_FLG(0x17aa, 0x1046, /* Lenovo ThinkStation P620 Rear Line-in, Line-out and Microphone */ |
| 1852 | QUIRK_FLAG_DISABLE_AUTOSUSPEND), |
| 1853 | DEVICE_FLG(0x17aa, 0x104d, /* Lenovo ThinkStation P620 Internal Speaker + Front Headset */ |
| 1854 | QUIRK_FLAG_DISABLE_AUTOSUSPEND), |
Takashi Iwai | 2de00d5 | 2021-07-29 09:38:53 +0200 | [diff] [blame] | 1855 | DEVICE_FLG(0x1852, 0x5065, /* Luxman DA-06 */ |
Takashi Iwai | f748385 | 2021-07-29 09:38:54 +0200 | [diff] [blame] | 1856 | QUIRK_FLAG_ITF_USB_DSD_DAC | QUIRK_FLAG_CTL_MSG_DELAY), |
Takashi Iwai | 4d4dee0 | 2021-07-29 09:38:47 +0200 | [diff] [blame] | 1857 | DEVICE_FLG(0x1901, 0x0191, /* GE B850V3 CP2114 audio interface */ |
| 1858 | QUIRK_FLAG_GET_SAMPLE_RATE), |
Takashi Iwai | ce47d47 | 2021-07-29 09:38:48 +0200 | [diff] [blame] | 1859 | DEVICE_FLG(0x2040, 0x7200, /* Hauppauge HVR-950Q */ |
Takashi Iwai | af158a7 | 2021-07-29 09:38:49 +0200 | [diff] [blame] | 1860 | QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER), |
Takashi Iwai | ce47d47 | 2021-07-29 09:38:48 +0200 | [diff] [blame] | 1861 | DEVICE_FLG(0x2040, 0x7201, /* Hauppauge HVR-950Q-MXL */ |
Takashi Iwai | af158a7 | 2021-07-29 09:38:49 +0200 | [diff] [blame] | 1862 | QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER), |
Takashi Iwai | ce47d47 | 2021-07-29 09:38:48 +0200 | [diff] [blame] | 1863 | DEVICE_FLG(0x2040, 0x7210, /* Hauppauge HVR-950Q */ |
Takashi Iwai | af158a7 | 2021-07-29 09:38:49 +0200 | [diff] [blame] | 1864 | QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER), |
Takashi Iwai | ce47d47 | 2021-07-29 09:38:48 +0200 | [diff] [blame] | 1865 | DEVICE_FLG(0x2040, 0x7211, /* Hauppauge HVR-950Q-MXL */ |
Takashi Iwai | af158a7 | 2021-07-29 09:38:49 +0200 | [diff] [blame] | 1866 | QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER), |
Takashi Iwai | ce47d47 | 2021-07-29 09:38:48 +0200 | [diff] [blame] | 1867 | DEVICE_FLG(0x2040, 0x7213, /* Hauppauge HVR-950Q */ |
Takashi Iwai | af158a7 | 2021-07-29 09:38:49 +0200 | [diff] [blame] | 1868 | QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER), |
Takashi Iwai | ce47d47 | 2021-07-29 09:38:48 +0200 | [diff] [blame] | 1869 | DEVICE_FLG(0x2040, 0x7217, /* Hauppauge HVR-950Q */ |
Takashi Iwai | af158a7 | 2021-07-29 09:38:49 +0200 | [diff] [blame] | 1870 | QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER), |
Takashi Iwai | ce47d47 | 2021-07-29 09:38:48 +0200 | [diff] [blame] | 1871 | DEVICE_FLG(0x2040, 0x721b, /* Hauppauge HVR-950Q */ |
Takashi Iwai | af158a7 | 2021-07-29 09:38:49 +0200 | [diff] [blame] | 1872 | QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER), |
Takashi Iwai | ce47d47 | 2021-07-29 09:38:48 +0200 | [diff] [blame] | 1873 | DEVICE_FLG(0x2040, 0x721e, /* Hauppauge HVR-950Q */ |
Takashi Iwai | af158a7 | 2021-07-29 09:38:49 +0200 | [diff] [blame] | 1874 | QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER), |
Takashi Iwai | ce47d47 | 2021-07-29 09:38:48 +0200 | [diff] [blame] | 1875 | DEVICE_FLG(0x2040, 0x721f, /* Hauppauge HVR-950Q */ |
Takashi Iwai | af158a7 | 2021-07-29 09:38:49 +0200 | [diff] [blame] | 1876 | QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER), |
Takashi Iwai | ce47d47 | 2021-07-29 09:38:48 +0200 | [diff] [blame] | 1877 | DEVICE_FLG(0x2040, 0x7240, /* Hauppauge HVR-850 */ |
Takashi Iwai | af158a7 | 2021-07-29 09:38:49 +0200 | [diff] [blame] | 1878 | QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER), |
Takashi Iwai | ce47d47 | 2021-07-29 09:38:48 +0200 | [diff] [blame] | 1879 | DEVICE_FLG(0x2040, 0x7260, /* Hauppauge HVR-950Q */ |
Takashi Iwai | af158a7 | 2021-07-29 09:38:49 +0200 | [diff] [blame] | 1880 | QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER), |
Takashi Iwai | ce47d47 | 2021-07-29 09:38:48 +0200 | [diff] [blame] | 1881 | DEVICE_FLG(0x2040, 0x7270, /* Hauppauge HVR-950Q */ |
Takashi Iwai | af158a7 | 2021-07-29 09:38:49 +0200 | [diff] [blame] | 1882 | QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER), |
Takashi Iwai | ce47d47 | 2021-07-29 09:38:48 +0200 | [diff] [blame] | 1883 | DEVICE_FLG(0x2040, 0x7280, /* Hauppauge HVR-950Q */ |
Takashi Iwai | af158a7 | 2021-07-29 09:38:49 +0200 | [diff] [blame] | 1884 | QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER), |
Takashi Iwai | ce47d47 | 2021-07-29 09:38:48 +0200 | [diff] [blame] | 1885 | DEVICE_FLG(0x2040, 0x7281, /* Hauppauge HVR-950Q-MXL */ |
Takashi Iwai | af158a7 | 2021-07-29 09:38:49 +0200 | [diff] [blame] | 1886 | QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER), |
Takashi Iwai | ce47d47 | 2021-07-29 09:38:48 +0200 | [diff] [blame] | 1887 | DEVICE_FLG(0x2040, 0x8200, /* Hauppauge Woodbury */ |
Takashi Iwai | af158a7 | 2021-07-29 09:38:49 +0200 | [diff] [blame] | 1888 | QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER), |
Takashi Iwai | 4d4dee0 | 2021-07-29 09:38:47 +0200 | [diff] [blame] | 1889 | DEVICE_FLG(0x21b4, 0x0081, /* AudioQuest DragonFly */ |
| 1890 | QUIRK_FLAG_GET_SAMPLE_RATE), |
Takashi Iwai | df0380b | 2021-11-02 17:18:59 +0100 | [diff] [blame] | 1891 | DEVICE_FLG(0x2708, 0x0002, /* Audient iD14 */ |
| 1892 | QUIRK_FLAG_IGNORE_CTL_ERROR), |
Takashi Iwai | 4d4dee0 | 2021-07-29 09:38:47 +0200 | [diff] [blame] | 1893 | DEVICE_FLG(0x2912, 0x30c8, /* Audioengine D1 */ |
| 1894 | QUIRK_FLAG_GET_SAMPLE_RATE), |
Greg Kroah-Hartman | 22390ce | 2021-10-14 13:17:50 +0200 | [diff] [blame] | 1895 | DEVICE_FLG(0x30be, 0x0101, /* Schiit Hel */ |
| 1896 | QUIRK_FLAG_IGNORE_CTL_ERROR), |
Takashi Iwai | 4d4dee0 | 2021-07-29 09:38:47 +0200 | [diff] [blame] | 1897 | DEVICE_FLG(0x413c, 0xa506, /* Dell AE515 sound bar */ |
| 1898 | QUIRK_FLAG_GET_SAMPLE_RATE), |
Takashi Iwai | af158a7 | 2021-07-29 09:38:49 +0200 | [diff] [blame] | 1899 | DEVICE_FLG(0x534d, 0x2109, /* MacroSilicon MS2109 */ |
| 1900 | QUIRK_FLAG_ALIGN_TRANSFER), |
Marco Giunta | 2966492 | 2021-10-18 18:25:52 +0200 | [diff] [blame] | 1901 | DEVICE_FLG(0x1224, 0x2a25, /* Jieli Technology USB PHY 2.0 */ |
| 1902 | QUIRK_FLAG_GET_SAMPLE_RATE), |
Takashi Iwai | 4d4dee0 | 2021-07-29 09:38:47 +0200 | [diff] [blame] | 1903 | |
| 1904 | /* Vendor matches */ |
| 1905 | VENDOR_FLG(0x045e, /* MS Lifecam */ |
| 1906 | QUIRK_FLAG_GET_SAMPLE_RATE), |
Takashi Iwai | f748385 | 2021-07-29 09:38:54 +0200 | [diff] [blame] | 1907 | VENDOR_FLG(0x046d, /* Logitech */ |
| 1908 | QUIRK_FLAG_CTL_MSG_DELAY_1M), |
Takashi Iwai | 4d4dee0 | 2021-07-29 09:38:47 +0200 | [diff] [blame] | 1909 | VENDOR_FLG(0x047f, /* Plantronics */ |
Takashi Iwai | f748385 | 2021-07-29 09:38:54 +0200 | [diff] [blame] | 1910 | QUIRK_FLAG_GET_SAMPLE_RATE | QUIRK_FLAG_CTL_MSG_DELAY), |
| 1911 | VENDOR_FLG(0x0644, /* TEAC Corp. */ |
Takashi Iwai | 1f074fe | 2021-07-29 09:38:55 +0200 | [diff] [blame] | 1912 | QUIRK_FLAG_CTL_MSG_DELAY | QUIRK_FLAG_IFACE_DELAY), |
Takashi Iwai | 8bfe17a | 2021-07-29 09:43:59 +0200 | [diff] [blame] | 1913 | VENDOR_FLG(0x07fd, /* MOTU */ |
| 1914 | QUIRK_FLAG_VALIDATE_RATES), |
Takashi Iwai | 5963e52 | 2021-10-04 09:40:50 +0200 | [diff] [blame] | 1915 | VENDOR_FLG(0x1235, /* Focusrite Novation */ |
| 1916 | QUIRK_FLAG_VALIDATE_RATES), |
Takashi Iwai | 68e851e | 2021-07-29 09:44:02 +0200 | [diff] [blame] | 1917 | VENDOR_FLG(0x152a, /* Thesycon devices */ |
| 1918 | QUIRK_FLAG_DSD_RAW), |
Takashi Iwai | 4d4dee0 | 2021-07-29 09:38:47 +0200 | [diff] [blame] | 1919 | VENDOR_FLG(0x1de7, /* Phoenix Audio */ |
| 1920 | QUIRK_FLAG_GET_SAMPLE_RATE), |
Takashi Iwai | 68e851e | 2021-07-29 09:44:02 +0200 | [diff] [blame] | 1921 | VENDOR_FLG(0x20b1, /* XMOS based devices */ |
| 1922 | QUIRK_FLAG_DSD_RAW), |
| 1923 | VENDOR_FLG(0x22d9, /* Oppo */ |
| 1924 | QUIRK_FLAG_DSD_RAW), |
Takashi Iwai | f748385 | 2021-07-29 09:38:54 +0200 | [diff] [blame] | 1925 | VENDOR_FLG(0x23ba, /* Playback Design */ |
Takashi Iwai | 68e851e | 2021-07-29 09:44:02 +0200 | [diff] [blame] | 1926 | QUIRK_FLAG_CTL_MSG_DELAY | QUIRK_FLAG_IFACE_DELAY | |
| 1927 | QUIRK_FLAG_DSD_RAW), |
| 1928 | VENDOR_FLG(0x25ce, /* Mytek devices */ |
| 1929 | QUIRK_FLAG_DSD_RAW), |
| 1930 | VENDOR_FLG(0x278b, /* Rotel? */ |
| 1931 | QUIRK_FLAG_DSD_RAW), |
| 1932 | VENDOR_FLG(0x292b, /* Gustard/Ess based devices */ |
| 1933 | QUIRK_FLAG_DSD_RAW), |
| 1934 | VENDOR_FLG(0x2972, /* FiiO devices */ |
| 1935 | QUIRK_FLAG_DSD_RAW), |
| 1936 | VENDOR_FLG(0x2ab6, /* T+A devices */ |
| 1937 | QUIRK_FLAG_DSD_RAW), |
| 1938 | VENDOR_FLG(0x3353, /* Khadas devices */ |
| 1939 | QUIRK_FLAG_DSD_RAW), |
| 1940 | VENDOR_FLG(0x3842, /* EVGA */ |
| 1941 | QUIRK_FLAG_DSD_RAW), |
| 1942 | VENDOR_FLG(0xc502, /* HiBy devices */ |
| 1943 | QUIRK_FLAG_DSD_RAW), |
Takashi Iwai | 4d4dee0 | 2021-07-29 09:38:47 +0200 | [diff] [blame] | 1944 | |
| 1945 | {} /* terminator */ |
| 1946 | }; |
| 1947 | |
| 1948 | void snd_usb_init_quirk_flags(struct snd_usb_audio *chip) |
| 1949 | { |
| 1950 | const struct usb_audio_quirk_flags_table *p; |
| 1951 | |
| 1952 | for (p = quirk_flags_table; p->id; p++) { |
| 1953 | if (chip->usb_id == p->id || |
| 1954 | (!USB_ID_PRODUCT(p->id) && |
| 1955 | USB_ID_VENDOR(chip->usb_id) == USB_ID_VENDOR(p->id))) { |
| 1956 | usb_audio_dbg(chip, |
| 1957 | "Set quirk_flags 0x%x for device %04x:%04x\n", |
| 1958 | p->flags, USB_ID_VENDOR(chip->usb_id), |
| 1959 | USB_ID_PRODUCT(chip->usb_id)); |
| 1960 | chip->quirk_flags |= p->flags; |
| 1961 | return; |
| 1962 | } |
| 1963 | } |
| 1964 | } |