* [PATCH] Coping with short replies in usbmixer
@ 2007-05-11 20:28 thomas
2007-05-14 9:10 ` Takashi Iwai
0 siblings, 1 reply; 4+ messages in thread
From: thomas @ 2007-05-11 20:28 UTC (permalink / raw)
To: alsa-devel
[-- Attachment #1: Type: text/plain, Size: 912 bytes --]
Hi,
while trying to find out why a USB handset (Yealink P1K) frequently gets
muted when changing volume, I found that short USB responses cause the
problem.
The function get_ctl_value(..) in usbmixer.c requests the state of a
certain control and retries up to 10 times if an error occurs. However a
short USB response is not treated as an error as neither the transfer
flag URB_SHORT_NOT_OK is set nor is the return value of
snd_usb_ctl_msg(..) compared with the requested amount of data. As a
result the function get_ctl_value(..) might not retry the USB request
but returns an unpredictable result without reporting an error.
The attached patch forces the number of returned bytes to be at least
val_len. It was generated from kernel version 2.6.21. If there are any
issues with the patch please let me know. Otherwise I would be happy if
it could be applied to the ALSA sources.
Regards,
-Thomas
[-- Attachment #2: usbmixer.patch --]
[-- Type: text/x-patch, Size: 556 bytes --]
diff -rup a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c
--- a/sound/usb/usbmixer.c 2007-05-11 21:58:33.000000000 +0200
+++ b/sound/usb/usbmixer.c 2007-05-11 21:59:14.000000000 +0200
@@ -360,7 +360,7 @@ static int get_ctl_value(struct usb_mixe
request,
USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
validx, cval->mixer->ctrlif | (cval->id << 8),
- buf, val_len, 100) >= 0) {
+ buf, val_len, 100) >= val_len) {
*value_ret = convert_signed_value(cval, snd_usb_combine_bytes(buf, val_len));
return 0;
}
[-- Attachment #3: Type: text/plain, Size: 160 bytes --]
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Coping with short replies in usbmixer
2007-05-11 20:28 thomas
@ 2007-05-14 9:10 ` Takashi Iwai
0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2007-05-14 9:10 UTC (permalink / raw)
To: thomas@devbase.at; +Cc: alsa-devel
At Fri, 11 May 2007 22:28:16 +0200,
thomas@devbase.at wrote:
>
> Hi,
> while trying to find out why a USB handset (Yealink P1K) frequently gets
> muted when changing volume, I found that short USB responses cause the
> problem.
>
> The function get_ctl_value(..) in usbmixer.c requests the state of a
> certain control and retries up to 10 times if an error occurs. However a
> short USB response is not treated as an error as neither the transfer
> flag URB_SHORT_NOT_OK is set nor is the return value of
> snd_usb_ctl_msg(..) compared with the requested amount of data. As a
> result the function get_ctl_value(..) might not retry the USB request
> but returns an unpredictable result without reporting an error.
>
> The attached patch forces the number of returned bytes to be at least
> val_len. It was generated from kernel version 2.6.21. If there are any
> issues with the patch please let me know. Otherwise I would be happy if
> it could be applied to the ALSA sources.
> Regards,
> -Thomas
Thanks, the patch looks good.
Could you give a sign-off to merge to the upstream?
Takashi
> [2 usbmixer.patch <text/x-patch (7bit)>]
> diff -rup a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c
> --- a/sound/usb/usbmixer.c 2007-05-11 21:58:33.000000000 +0200
> +++ b/sound/usb/usbmixer.c 2007-05-11 21:59:14.000000000 +0200
> @@ -360,7 +360,7 @@ static int get_ctl_value(struct usb_mixe
> request,
> USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
> validx, cval->mixer->ctrlif | (cval->id << 8),
> - buf, val_len, 100) >= 0) {
> + buf, val_len, 100) >= val_len) {
> *value_ret = convert_signed_value(cval, snd_usb_combine_bytes(buf, val_len));
> return 0;
> }
> [3 <text/plain; us-ascii (7bit)>]
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Coping with short replies in usbmixer
@ 2007-05-14 17:54 Thomas Reitmayr
2007-05-15 10:40 ` Takashi Iwai
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Reitmayr @ 2007-05-14 17:54 UTC (permalink / raw)
To: alsa-devel
Hi,
here is it again and signed off.
This patch makes sure that short USB replies are treated as an
error when requesting the value of a certain mixer control.
Signed-off-by: Thomas Reitmayr <thomas@devbase.at>
---
sound/usb/usbmixer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff -rup a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c
--- a/sound/usb/usbmixer.c 2007-05-11 21:58:33.000000000 +0200
+++ b/sound/usb/usbmixer.c 2007-05-11 21:59:14.000000000 +0200
@@ -360,7 +360,7 @@ static int get_ctl_value(struct usb_mixe
request,
USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
validx, cval->mixer->ctrlif | (cval->id << 8),
- buf, val_len, 100) >= 0) {
+ buf, val_len, 100) >= val_len) {
*value_ret = convert_signed_value(cval, snd_usb_combine_bytes(buf, val_len));
return 0;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Coping with short replies in usbmixer
2007-05-14 17:54 [PATCH] Coping with short replies in usbmixer Thomas Reitmayr
@ 2007-05-15 10:40 ` Takashi Iwai
0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2007-05-15 10:40 UTC (permalink / raw)
To: Thomas Reitmayr; +Cc: alsa-devel
At Mon, 14 May 2007 19:54:34 +0200,
Thomas Reitmayr wrote:
>
> Hi,
> here is it again and signed off.
>
> This patch makes sure that short USB replies are treated as an
> error when requesting the value of a certain mixer control.
>
> Signed-off-by: Thomas Reitmayr <thomas@devbase.at>
Thanks, now applied to ALSA tree.
Takashi
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-05-15 10:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-14 17:54 [PATCH] Coping with short replies in usbmixer Thomas Reitmayr
2007-05-15 10:40 ` Takashi Iwai
-- strict thread matches above, loose matches on Subject: below --
2007-05-11 20:28 thomas
2007-05-14 9:10 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).