aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorDaniel Mack <daniel@caiaq.de>2010-06-11 11:34:22 -0400
committerTakashi Iwai <tiwai@suse.de>2010-06-11 12:06:35 -0400
commite8bdb6bbab60a8731f21823c86391f176d052348 (patch)
tree3ee6716941a195b4a1110ff5320c3ab9f29c77a7 /sound
parent67c103664a06fa590f2990c01773dfa1dffcefdc (diff)
ALSA: usb-audio: fix UAC2 control value queries
For RANGE requests, we should only query as much bytes as we're in fact interested in. For CUR requests, we shouldn't confuse the firmware with an overlong request but just ask for 2 bytes. This might need fixing in the future as it's not entirely clear when to dispatch 1-byte, 2-byte and 4-byte request blocks. For now, we assume everything is coded in 16bit - this works for all firmware implementations I've seen. Signed-off-by: Daniel Mack <daniel@caiaq.de> Reported-by: Alex Lee <alexlee188@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/usb/mixer.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index a060d005e209..6939d0f517d9 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -297,20 +297,27 @@ static int get_ctl_value_v1(struct usb_mixer_elem_info *cval, int request, int v
297 297
298static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret) 298static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret)
299{ 299{
300 unsigned char buf[14]; /* enough space for one range of 4 bytes */ 300 unsigned char buf[2 + 3*sizeof(__u16)]; /* enough space for one range */
301 unsigned char *val; 301 unsigned char *val;
302 int ret; 302 int ret, size;
303 __u8 bRequest; 303 __u8 bRequest;
304 304
305 bRequest = (request == UAC_GET_CUR) ? 305 if (request == UAC_GET_CUR) {
306 UAC2_CS_CUR : UAC2_CS_RANGE; 306 bRequest = UAC2_CS_CUR;
307 size = sizeof(__u16);
308 } else {
309 bRequest = UAC2_CS_RANGE;
310 size = sizeof(buf);
311 }
312
313 memset(buf, 0, sizeof(buf));
307 314
308 ret = snd_usb_ctl_msg(cval->mixer->chip->dev, 315 ret = snd_usb_ctl_msg(cval->mixer->chip->dev,
309 usb_rcvctrlpipe(cval->mixer->chip->dev, 0), 316 usb_rcvctrlpipe(cval->mixer->chip->dev, 0),
310 bRequest, 317 bRequest,
311 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, 318 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
312 validx, cval->mixer->ctrlif | (cval->id << 8), 319 validx, cval->mixer->ctrlif | (cval->id << 8),
313 buf, sizeof(buf), 1000); 320 buf, size, 1000);
314 321
315 if (ret < 0) { 322 if (ret < 0) {
316 snd_printk(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n", 323 snd_printk(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n",
@@ -318,6 +325,8 @@ static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int v
318 return ret; 325 return ret;
319 } 326 }
320 327
328 /* FIXME: how should we handle multiple triplets here? */
329
321 switch (request) { 330 switch (request) {
322 case UAC_GET_CUR: 331 case UAC_GET_CUR:
323 val = buf; 332 val = buf;