ALSA: usb-audio: clean up find_audio_control_unit()
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> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
2e0281d15c
commit
67e1daa0bb
@ -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
|
* 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)
|
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 ((hdr = snd_usb_find_desc(state->buffer, state->buflen, hdr,
|
||||||
while ((p = snd_usb_find_desc(state->buffer, state->buflen, p,
|
USB_DT_CS_INTERFACE)) != NULL) {
|
||||||
USB_DT_CS_INTERFACE)) != NULL) {
|
if (hdr->bLength >= 4 &&
|
||||||
if (p[0] >= 4 && p[2] >= UAC_INPUT_TERMINAL && p[2] <= UAC2_EXTENSION_UNIT_V2 && p[3] == unit)
|
hdr->bDescriptorSubtype >= UAC_INPUT_TERMINAL &&
|
||||||
return p;
|
hdr->bDescriptorSubtype <= UAC2_SAMPLE_RATE_CONVERTER &&
|
||||||
|
hdr->bUnitID == unit)
|
||||||
|
return hdr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* copy a string with the given id
|
* copy a string with the given id
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user