From: Daniel Mack <daniel@caiaq.de>
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de, alexlee188@gmail.com, clemens@ladisch.de
Subject: Re: [PATCH 4/4] ALSA: usb-audio: fix UAC2 control value queries
Date: Fri, 11 Jun 2010 15:51:21 +0200 [thread overview]
Message-ID: <20100611135121.GB17833@buzzloop.caiaq.de> (raw)
In-Reply-To: <1276263191-8652-5-git-send-email-daniel@caiaq.de>
On Fri, Jun 11, 2010 at 03:33:11PM +0200, Daniel Mack wrote:
> UAC2 controls can be queried in 1-byte, 2-byte or 4-byte request blocks.
> The size is actually determined by the number of bytes requested, and as
> everything is little-endian, we can always go for the 4-byte variant.
>
> Also, the MIN, MAX and RES value computations were using a wrong offset.
>
> Signed-off-by: Daniel Mack <daniel@caiaq.de>
> Reported-by: Alex Lee <alexlee188@gmail.com>
Damn, I forgot to pick the right commit message for this patch. Below is
a new version. Sorry.
Daniel
>From 9a8be646c65df2960bda3588cbd2cea4834c7750 Mon Sep 17 00:00:00 2001
From: Daniel Mack <daniel@caiaq.de>
Date: Fri, 11 Jun 2010 13:49:56 +0200
Subject: [PATCH] ALSA: usb-audio: fix UAC2 control value queries
For RANGE requests, we should only query as much bytes as we're in face
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>
---
sound/usb/mixer.c | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index a060d00..6939d0f 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
static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret)
{
- unsigned char buf[14]; /* enough space for one range of 4 bytes */
+ unsigned char buf[2 + 3*sizeof(__u16)]; /* enough space for one range */
unsigned char *val;
- int ret;
+ int ret, size;
__u8 bRequest;
- bRequest = (request == UAC_GET_CUR) ?
- UAC2_CS_CUR : UAC2_CS_RANGE;
+ if (request == UAC_GET_CUR) {
+ bRequest = UAC2_CS_CUR;
+ size = sizeof(__u16);
+ } else {
+ bRequest = UAC2_CS_RANGE;
+ size = sizeof(buf);
+ }
+
+ memset(buf, 0, sizeof(buf));
ret = snd_usb_ctl_msg(cval->mixer->chip->dev,
usb_rcvctrlpipe(cval->mixer->chip->dev, 0),
bRequest,
USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
validx, cval->mixer->ctrlif | (cval->id << 8),
- buf, sizeof(buf), 1000);
+ buf, size, 1000);
if (ret < 0) {
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
return ret;
}
+ /* FIXME: how should we handle multiple triplets here? */
+
switch (request) {
case UAC_GET_CUR:
val = buf;
--
1.7.1
prev parent reply other threads:[~2010-06-11 13:51 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-11 13:33 usb-audio: some UAC2 fixes Daniel Mack
2010-06-11 13:33 ` [PATCH 1/4] ALSA: usb-audio: add check for faulty clock in parse_audio_format_rates_v2() Daniel Mack
2010-06-11 13:33 ` [PATCH 2/4] ALSA: usb-audio: fix control messages for USB_RECIP_INTERFACE Daniel Mack
2010-06-11 13:33 ` [PATCH 3/4] ALSA: usb-audio: parse UAC2 sample rate ranges correctly Daniel Mack
[not found] ` <AANLkTin3LMCu_f2emsh6kAT8H6G3zKF8Ud-ZUMpZjbmg@mail.gmail.com>
2010-06-11 15:04 ` Daniel Mack
2010-06-11 15:14 ` Clemens Ladisch
2010-06-11 15:18 ` Daniel Mack
2010-06-11 15:34 ` [PATCH 1/4] ALSA: usb-audio: add check for faulty clock in parse_audio_format_rates_v2() Daniel Mack
2010-06-11 16:10 ` Takashi Iwai
2010-06-11 15:34 ` [PATCH 2/4] ALSA: usb-audio: fix control messages for USB_RECIP_INTERFACE Daniel Mack
2010-06-11 15:34 ` [PATCH 3/4] ALSA: usb-audio: parse UAC2 sample rate ranges correctly Daniel Mack
2010-06-11 15:43 ` Takashi Iwai
2010-06-11 15:46 ` Daniel Mack
2010-06-11 15:54 ` Takashi Iwai
2010-06-11 15:34 ` [PATCH 4/4] ALSA: usb-audio: fix UAC2 control value queries Daniel Mack
2010-06-11 15:18 ` [PATCH 3/4] ALSA: usb-audio: parse UAC2 sample rate ranges correctly Mark Brown
2010-06-14 12:41 ` Daniel Mack
2010-06-11 13:33 ` [PATCH 4/4] ALSA: usb-audio: fix UAC2 control value queries Daniel Mack
2010-06-11 13:51 ` Daniel Mack [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100611135121.GB17833@buzzloop.caiaq.de \
--to=daniel@caiaq.de \
--cc=alexlee188@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=clemens@ladisch.de \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.