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