ALSA: usb-audio: parse clock topology of UAC2 devices
[safe/jmp/linux-2.6] / sound / usb / format.c
index fe29d61..5367cd1 100644 (file)
@@ -29,6 +29,7 @@
 #include "quirks.h"
 #include "helper.h"
 #include "debug.h"
+#include "clock.h"
 
 /*
  * parse the audio format type I descriptor
@@ -215,15 +216,17 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip,
        struct usb_device *dev = chip->dev;
        unsigned char tmp[2], *data;
        int i, nr_rates, data_size, ret = 0;
+       int clock = snd_usb_clock_find_source(chip, chip->ctrl_intf, fp->clock);
 
        /* get the number of sample rates first by only fetching 2 bytes */
        ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE,
                              USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
-                             UAC2_CS_CONTROL_SAM_FREQ << 8, chip->clock_id << 8,
+                             UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8,
                              tmp, sizeof(tmp), 1000);
 
        if (ret < 0) {
-               snd_printk(KERN_ERR "unable to retrieve number of sample rates\n");
+               snd_printk(KERN_ERR "%s(): unable to retrieve number of sample rates (clock %d)\n",
+                               __func__, clock);
                goto err;
        }
 
@@ -237,12 +240,13 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip,
 
        /* now get the full information */
        ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE,
-                              USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
-                              UAC2_CS_CONTROL_SAM_FREQ << 8, chip->clock_id << 8,
-                              data, data_size, 1000);
+                             USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
+                             UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8,
+                             data, data_size, 1000);
 
        if (ret < 0) {
-               snd_printk(KERN_ERR "unable to retrieve sample rate range\n");
+               snd_printk(KERN_ERR "%s(): unable to retrieve sample rate range (clock %d)\n",
+                               __func__, clock);
                ret = -EINVAL;
                goto err_free;
        }