aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Mack <daniel@caiaq.de>2010-06-11 11:34:20 -0400
committerTakashi Iwai <tiwai@suse.de>2010-06-11 12:05:38 -0400
commit11bcbc443a17653c65bc20029172fae76f4bcca4 (patch)
tree29cbf68f8e64bdb237ca4e0b6a8da9e3211119b1
parentd07140ba7fe1b41713627c6dc3f169a00019fb0e (diff)
ALSA: usb-audio: fix control messages for USB_RECIP_INTERFACE
Control messages directed to an interface must have the interface number set in the lower 8 bits of wIndex. This wasn't done correctly for some clock and mixer messages. Signed-off-by: Daniel Mack <daniel@caiaq.de> Reported-by: Alex Lee <alexlee188@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/usb/clock.c12
-rw-r--r--sound/usb/format.c6
-rw-r--r--sound/usb/helper.h4
3 files changed, 16 insertions, 6 deletions
diff --git a/sound/usb/clock.c b/sound/usb/clock.c
index b7aadd614c70..b5855114667e 100644
--- a/sound/usb/clock.c
+++ b/sound/usb/clock.c
@@ -103,7 +103,8 @@ static int uac_clock_selector_get_val(struct snd_usb_audio *chip, int selector_i
103 ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), 103 ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0),
104 UAC2_CS_CUR, 104 UAC2_CS_CUR,
105 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, 105 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
106 UAC2_CX_CLOCK_SELECTOR << 8, selector_id << 8, 106 UAC2_CX_CLOCK_SELECTOR << 8,
107 snd_usb_ctrl_intf(chip) | (selector_id << 8),
107 &buf, sizeof(buf), 1000); 108 &buf, sizeof(buf), 1000);
108 109
109 if (ret < 0) 110 if (ret < 0)
@@ -120,7 +121,8 @@ static bool uac_clock_source_is_valid(struct snd_usb_audio *chip, int source_id)
120 121
121 err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR, 122 err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR,
122 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, 123 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
123 UAC2_CS_CONTROL_CLOCK_VALID << 8, source_id << 8, 124 UAC2_CS_CONTROL_CLOCK_VALID << 8,
125 snd_usb_ctrl_intf(chip) | (source_id << 8),
124 &data, sizeof(data), 1000); 126 &data, sizeof(data), 1000);
125 127
126 if (err < 0) { 128 if (err < 0) {
@@ -269,7 +271,8 @@ static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface,
269 data[3] = rate >> 24; 271 data[3] = rate >> 24;
270 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC2_CS_CUR, 272 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC2_CS_CUR,
271 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT, 273 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT,
272 UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8, 274 UAC2_CS_CONTROL_SAM_FREQ << 8,
275 snd_usb_ctrl_intf(chip) | (clock << 8),
273 data, sizeof(data), 1000)) < 0) { 276 data, sizeof(data), 1000)) < 0) {
274 snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d (v2)\n", 277 snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d (v2)\n",
275 dev->devnum, iface, fmt->altsetting, rate); 278 dev->devnum, iface, fmt->altsetting, rate);
@@ -278,7 +281,8 @@ static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface,
278 281
279 if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR, 282 if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR,
280 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, 283 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
281 UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8, 284 UAC2_CS_CONTROL_SAM_FREQ << 8,
285 snd_usb_ctrl_intf(chip) | (clock << 8),
282 data, sizeof(data), 1000)) < 0) { 286 data, sizeof(data), 1000)) < 0) {
283 snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq (v2)\n", 287 snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq (v2)\n",
284 dev->devnum, iface, fmt->altsetting); 288 dev->devnum, iface, fmt->altsetting);
diff --git a/sound/usb/format.c b/sound/usb/format.c
index df5b29fed000..8eccf17a4ac6 100644
--- a/sound/usb/format.c
+++ b/sound/usb/format.c
@@ -227,7 +227,8 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip,
227 /* get the number of sample rates first by only fetching 2 bytes */ 227 /* get the number of sample rates first by only fetching 2 bytes */
228 ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE, 228 ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE,
229 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, 229 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
230 UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8, 230 UAC2_CS_CONTROL_SAM_FREQ << 8,
231 snd_usb_ctrl_intf(chip) | (clock << 8),
231 tmp, sizeof(tmp), 1000); 232 tmp, sizeof(tmp), 1000);
232 233
233 if (ret < 0) { 234 if (ret < 0) {
@@ -247,7 +248,8 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip,
247 /* now get the full information */ 248 /* now get the full information */
248 ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE, 249 ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE,
249 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, 250 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
250 UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8, 251 UAC2_CS_CONTROL_SAM_FREQ << 8,
252 snd_usb_ctrl_intf(chip) | (clock << 8),
251 data, data_size, 1000); 253 data, data_size, 1000);
252 254
253 if (ret < 0) { 255 if (ret < 0) {
diff --git a/sound/usb/helper.h b/sound/usb/helper.h
index a6b0e51b3a9a..09bd943c43bf 100644
--- a/sound/usb/helper.h
+++ b/sound/usb/helper.h
@@ -28,5 +28,9 @@ unsigned char snd_usb_parse_datainterval(struct snd_usb_audio *chip,
28#define snd_usb_get_speed(dev) ((dev)->speed) 28#define snd_usb_get_speed(dev) ((dev)->speed)
29#endif 29#endif
30 30
31static inline int snd_usb_ctrl_intf(struct snd_usb_audio *chip)
32{
33 return get_iface_desc(chip->ctrl_intf)->bInterfaceNumber;
34}
31 35
32#endif /* __USBAUDIO_HELPER_H */ 36#endif /* __USBAUDIO_HELPER_H */