Merge tag 'pwm/for-4.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry...
[deliverable/linux.git] / sound / usb / quirks.c
index c458d60d50300823e03e39109b715c94bf44cbbf..fb62bce2435c0e370d2fc55d2113cd1f4187fd8f 100644 (file)
@@ -167,19 +167,20 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip,
        stream = (fp->endpoint & USB_DIR_IN)
                ? SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK;
        err = snd_usb_add_audio_stream(chip, stream, fp);
-       if (err < 0) {
-               kfree(fp);
-               kfree(rate_table);
-               return err;
-       }
+       if (err < 0)
+               goto error;
        if (fp->iface != get_iface_desc(&iface->altsetting[0])->bInterfaceNumber ||
            fp->altset_idx >= iface->num_altsetting) {
-               kfree(fp);
-               kfree(rate_table);
-               return -EINVAL;
+               err = -EINVAL;
+               goto error;
        }
        alts = &iface->altsetting[fp->altset_idx];
        altsd = get_iface_desc(alts);
+       if (altsd->bNumEndpoints < 1) {
+               err = -EINVAL;
+               goto error;
+       }
+
        fp->protocol = altsd->bInterfaceProtocol;
 
        if (fp->datainterval == 0)
@@ -190,6 +191,11 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip,
        snd_usb_init_pitch(chip, fp->iface, alts, fp);
        snd_usb_init_sample_rate(chip, fp->iface, alts, fp, fp->rate_max);
        return 0;
+
+ error:
+       kfree(fp);
+       kfree(rate_table);
+       return err;
 }
 
 static int create_auto_pcm_quirk(struct snd_usb_audio *chip,
@@ -446,8 +452,9 @@ static int create_uaxx_quirk(struct snd_usb_audio *chip,
                const struct snd_usb_audio_quirk *quirk =
                        chip->usb_id == USB_ID(0x0582, 0x002b)
                        ? &ua700_quirk : &uaxx_quirk;
-               return snd_usbmidi_create(chip->card, iface,
-                                         &chip->midi_list, quirk);
+               return __snd_usbmidi_create(chip->card, iface,
+                                         &chip->midi_list, quirk,
+                                         chip->usb_id);
        }
 
        if (altsd->bNumEndpoints != 1)
@@ -974,11 +981,9 @@ int snd_usb_apply_interface_quirk(struct snd_usb_audio *chip,
 
 int snd_usb_apply_boot_quirk(struct usb_device *dev,
                             struct usb_interface *intf,
-                            const struct snd_usb_audio_quirk *quirk)
+                            const struct snd_usb_audio_quirk *quirk,
+                            unsigned int id)
 {
-       u32 id = USB_ID(le16_to_cpu(dev->descriptor.idVendor),
-                       le16_to_cpu(dev->descriptor.idProduct));
-
        switch (id) {
        case USB_ID(0x041e, 0x3000):
                /* SB Extigy needs special boot-up sequence */
@@ -1121,6 +1126,7 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip)
        switch (chip->usb_id) {
        case USB_ID(0x045E, 0x075D): /* MS Lifecam Cinema  */
        case USB_ID(0x045E, 0x076D): /* MS Lifecam HD-5000 */
+       case USB_ID(0x045E, 0x076E): /* MS Lifecam HD-5001 */
        case USB_ID(0x045E, 0x076F): /* MS Lifecam HD-6000 */
        case USB_ID(0x045E, 0x0772): /* MS Lifecam Studio */
        case USB_ID(0x045E, 0x0779): /* MS Lifecam HD-3000 */
@@ -1184,7 +1190,7 @@ void snd_usb_endpoint_start_quirk(struct snd_usb_endpoint *ep)
         * "Playback Design" products send bogus feedback data at the start
         * of the stream. Ignore them.
         */
-       if ((le16_to_cpu(ep->chip->dev->descriptor.idVendor) == 0x23ba) &&
+       if (USB_ID_VENDOR(ep->chip->usb_id) == 0x23ba &&
            ep->type == SND_USB_ENDPOINT_TYPE_SYNC)
                ep->skip_packets = 4;
 
@@ -1203,11 +1209,15 @@ void snd_usb_endpoint_start_quirk(struct snd_usb_endpoint *ep)
 
 void snd_usb_set_interface_quirk(struct usb_device *dev)
 {
+       struct snd_usb_audio *chip = dev_get_drvdata(&dev->dev);
+
+       if (!chip)
+               return;
        /*
         * "Playback Design" products need a 50ms delay after setting the
         * USB interface.
         */
-       switch (le16_to_cpu(dev->descriptor.idVendor)) {
+       switch (USB_ID_VENDOR(chip->usb_id)) {
        case 0x23ba: /* Playback Design */
        case 0x0644: /* TEAC Corp. */
                mdelay(50);
@@ -1215,15 +1225,20 @@ void snd_usb_set_interface_quirk(struct usb_device *dev)
        }
 }
 
+/* quirk applied after snd_usb_ctl_msg(); not applied during boot quirks */
 void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe,
                           __u8 request, __u8 requesttype, __u16 value,
                           __u16 index, void *data, __u16 size)
 {
+       struct snd_usb_audio *chip = dev_get_drvdata(&dev->dev);
+
+       if (!chip)
+               return;
        /*
         * "Playback Design" products need a 20ms delay after each
         * class compliant request
         */
-       if ((le16_to_cpu(dev->descriptor.idVendor) == 0x23ba) &&
+       if (USB_ID_VENDOR(chip->usb_id) == 0x23ba &&
            (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
                mdelay(20);
 
@@ -1231,23 +1246,21 @@ void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe,
         * "TEAC Corp." products need a 20ms delay after each
         * class compliant request
         */
-       if ((le16_to_cpu(dev->descriptor.idVendor) == 0x0644) &&
+       if (USB_ID_VENDOR(chip->usb_id) == 0x0644 &&
            (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
                mdelay(20);
 
        /* Marantz/Denon devices with USB DAC functionality need a delay
         * after each class compliant request
         */
-       if (is_marantz_denon_dac(USB_ID(le16_to_cpu(dev->descriptor.idVendor),
-                                       le16_to_cpu(dev->descriptor.idProduct)))
+       if (is_marantz_denon_dac(chip->usb_id)
            && (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
                mdelay(20);
 
        /* Zoom R16/24 needs a tiny delay here, otherwise requests like
         * get/set frequency return as failed despite actually succeeding.
         */
-       if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1686) &&
-           (le16_to_cpu(dev->descriptor.idProduct) == 0x00dd) &&
+       if (chip->usb_id == USB_ID(0x1686, 0x00dd) &&
            (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
                mdelay(1);
 }
@@ -1264,7 +1277,7 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
                                        unsigned int sample_bytes)
 {
        /* Playback Designs */
-       if (le16_to_cpu(chip->dev->descriptor.idVendor) == 0x23ba) {
+       if (USB_ID_VENDOR(chip->usb_id) == 0x23ba) {
                switch (fp->altsetting) {
                case 1:
                        fp->dsd_dop = true;
This page took 0.031224 seconds and 5 git commands to generate.