From: Jorge Sanjuan <jorge.sanjuan@codethink.co.uk>
To: tiwai@suse.de
Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/5] ALSA: usb-audio: Processing Unit controls parsing in UAC2
Date: Wed, 11 Jul 2018 13:37:52 +0100 [thread overview]
Message-ID: <20180711123755.27182-3-jorge.sanjuan@codethink.co.uk> (raw)
In-Reply-To: <20180711123755.27182-1-jorge.sanjuan@codethink.co.uk>
Current support for UAC2 Processing Units does the parsing
as one control per bit in the bitmap. However, the UAC2 spec
defines the controls as bit pairs where b01 means read-only
and b11 means read/write control.
This patch fixes that and uses the helper functions for checking
controls readability/writability when the control is defined as
bit pairs (UAC2 and UAC3).
Signed-off-by: Jorge Sanjuan <jorge.sanjuan@codethink.co.uk>
---
sound/usb/mixer.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index a51f2320a3dd..bfb3484096a6 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -2300,8 +2300,16 @@ static int build_audio_procunit(struct mixer_build *state, int unitid,
for (valinfo = info->values; valinfo->control; valinfo++) {
__u8 *controls = uac_processing_unit_bmControls(desc, state->mixer->protocol);
- if (!(controls[valinfo->control / 8] & (1 << ((valinfo->control % 8) - 1))))
- continue;
+ if (state->mixer->protocol == UAC_VERSION_1) {
+ if (!(controls[valinfo->control / 8] &
+ (1 << ((valinfo->control % 8) - 1))))
+ continue;
+ } else { /* UAC_VERSION_2/3 */
+ if (!uac_v2v3_control_is_readable(controls[valinfo->control / 8],
+ valinfo->control))
+ continue;
+ }
+
map = find_map(state->map, unitid, valinfo->control);
if (check_ignored_ctl(map))
continue;
@@ -2313,6 +2321,11 @@ static int build_audio_procunit(struct mixer_build *state, int unitid,
cval->val_type = valinfo->val_type;
cval->channels = 1;
+ if (state->mixer->protocol > UAC_VERSION_1 &&
+ !uac_v2v3_control_is_writeable(controls[valinfo->control / 8],
+ valinfo->control))
+ cval->master_readonly = 1;
+
/* get min/max values */
if (type == UAC_PROCESS_UP_DOWNMIX && cval->control == UAC_UD_MODE_SELECT) {
__u8 *control_spec = uac_processing_unit_specific(desc, state->mixer->protocol);
--
2.11.0
next prev parent reply other threads:[~2018-07-11 12:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-11 12:37 [PATCH 0/5] UAC3: Add Selectors and Processing Units Jorge Sanjuan
2018-07-11 12:37 ` [PATCH 1/5] ALSA: usb-audio: Add support for Selector Units in UAC3 Jorge Sanjuan
2018-07-11 12:37 ` Jorge Sanjuan [this message]
2018-07-11 12:37 ` [PATCH 3/5] ALSA: usb-audio: Add support for Processing " Jorge Sanjuan
2018-07-11 12:37 ` [PATCH 4/5] ALSA: usb-audio: Unify virtual type units type to UAC3 values Jorge Sanjuan
2018-07-11 12:37 ` [PATCH 5/5] ALSA: usb-audio: Tidy up logic for Processing Unit min/max values Jorge Sanjuan
2018-07-16 14:38 ` [PATCH 0/5] UAC3: Add Selectors and Processing Units Takashi Iwai
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=20180711123755.27182-3-jorge.sanjuan@codethink.co.uk \
--to=jorge.sanjuan@codethink.co.uk \
--cc=alsa-devel@alsa-project.org \
--cc=linux-kernel@vger.kernel.org \
--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 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).