From: Daniel Mack <daniel@caiaq.de>
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de, gregkh@suse.de, clemens@ladisch.de
Subject: [PATCH 8/9] ALSA: usb-audio: clean up find_audio_control_unit()
Date: Mon, 31 May 2010 13:35:43 +0200 [thread overview]
Message-ID: <1275305744-6590-8-git-send-email-daniel@caiaq.de> (raw)
In-Reply-To: <1275305744-6590-1-git-send-email-daniel@caiaq.de>
Use a struct to parse the audio units, and return usable descriptors
for all types. There's no need to limit the result set, except for some
kind of sanity check.
Signed-off-by: Daniel Mack <daniel@caiaq.de>
---
sound/usb/mixer.c | 20 +++++++++++---------
1 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 8be6bf2..cb34536 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -165,22 +165,24 @@ static int check_mapped_selector_name(struct mixer_build *state, int unitid,
/*
* find an audio control unit with the given unit id
- * this doesn't return any clock related units, so they need to be handled elsewhere
*/
static void *find_audio_control_unit(struct mixer_build *state, unsigned char unit)
{
- unsigned char *p;
+ /* we just parse the header */
+ struct uac_feature_unit_descriptor *hdr = NULL;
- p = NULL;
- while ((p = snd_usb_find_desc(state->buffer, state->buflen, p,
- USB_DT_CS_INTERFACE)) != NULL) {
- if (p[0] >= 4 && p[2] >= UAC_INPUT_TERMINAL && p[2] <= UAC2_EXTENSION_UNIT_V2 && p[3] == unit)
- return p;
+ while ((hdr = snd_usb_find_desc(state->buffer, state->buflen, hdr,
+ USB_DT_CS_INTERFACE)) != NULL) {
+ if (hdr->bLength >= 4 &&
+ hdr->bDescriptorSubtype >= UAC_INPUT_TERMINAL &&
+ hdr->bDescriptorSubtype <= UAC2_SAMPLE_RATE_CONVERTER &&
+ hdr->bUnitID == unit)
+ return hdr;
}
+
return NULL;
}
-
/*
* copy a string with the given id
*/
--
1.7.1
next prev parent reply other threads:[~2010-05-31 11:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-31 11:35 [PATCH 1/9] ALSA: usb-audio: UAC2: clean up parsing of bmaControls Daniel Mack
2010-05-31 11:35 ` [PATCH 2/9] ALSA: usb-audio: support partially write-protected UAC2 controls Daniel Mack
2010-05-31 11:35 ` [PATCH 3/9] include/linux/usb/audio-v2.h: add more UAC2 details Daniel Mack
2010-05-31 11:35 ` [PATCH 4/9] ALSA: usb-audio: fix selector unit string index accessor Daniel Mack
2010-05-31 11:35 ` [PATCH 5/9] ALSA: usb-audio: parse clock topology of UAC2 devices Daniel Mack
2010-05-31 12:51 ` Daniel Mack
2010-05-31 11:35 ` [PATCH 6/9] ALSA: usb-audio: unify constants from specification Daniel Mack
2010-05-31 11:35 ` [PATCH 7/9] ALSA: usb-audio: add UAC2 sepecific Feature Unit controls Daniel Mack
2010-05-31 11:35 ` Daniel Mack [this message]
2010-05-31 11:35 ` [PATCH 9/9] ALSA: usb-audio: export UAC2 clock selectors as mixer controls Daniel Mack
2010-05-31 16:35 ` [PATCH 1/9] ALSA: usb-audio: UAC2: clean up parsing of bmaControls Takashi Iwai
2010-05-31 16:47 ` Daniel Mack
2010-05-31 20:35 ` 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=1275305744-6590-8-git-send-email-daniel@caiaq.de \
--to=daniel@caiaq.de \
--cc=alsa-devel@alsa-project.org \
--cc=clemens@ladisch.de \
--cc=gregkh@suse.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 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).