Skip to content

Commit d75a170

Browse files
committed
ALSA: usb-audio: Fix UAC2/3 effect unit parsing
We've got a regression report about M-Audio Fast Track C400 device, and the git bisection resulted in the commit e0ccdef ("ALSA: usb-audio: Clean up check_input_term()"). This commit was about the rewrite of the input terminal parser, and it's not too obvious from the change what really broke. The answer is: it's the interpretation of UAC2/3 effect units. In the original code, UAC2 effect unit is as if through UAC1 processing unit because both UAC1 PU and UAC2/3 EU share the same number (0x07). The old code went through a complex switch-case fallthrough, finally bailing out in the middle: if (protocol == UAC_VERSION_2 && hdr[2] == UAC2_EFFECT_UNIT) { /* UAC2/UAC1 unit IDs overlap here in an * uncompatible way. Ignore this unit for now. */ return 0; } ... and this special handling was missing in the new code; the new code treats UAC2/3 effect unit as if it were equivalent with the processing unit. Actually, the old code was too confusing. The effect unit has an incompatible unit description with the processing unit, so we shouldn't have dealt with EU in the same way. This patch addresses the regression by changing the effect unit handling to the own parser function. The own parser function makes the clear distinct with PU, so it improves the readability, too. The EU parser just sets the type and the id like the old kernels. Once when the proper effect unit support is added, we can revisit this parser function, but for now, let's keep this simple setup as is. Fixes: e0ccdef ("ALSA: usb-audio: Clean up check_input_term()") Cc: <[email protected]> BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=206147 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 74f7347 commit d75a170

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

sound/usb/mixer.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,15 @@ static int parse_term_proc_unit(struct mixer_build *state,
897897
return 0;
898898
}
899899

900+
static int parse_term_effect_unit(struct mixer_build *state,
901+
struct usb_audio_term *term,
902+
void *p1, int id)
903+
{
904+
term->type = UAC3_EFFECT_UNIT << 16; /* virtual type */
905+
term->id = id;
906+
return 0;
907+
}
908+
900909
static int parse_term_uac2_clock_source(struct mixer_build *state,
901910
struct usb_audio_term *term,
902911
void *p1, int id)
@@ -981,8 +990,7 @@ static int __check_input_term(struct mixer_build *state, int id,
981990
UAC3_PROCESSING_UNIT);
982991
case PTYPE(UAC_VERSION_2, UAC2_EFFECT_UNIT):
983992
case PTYPE(UAC_VERSION_3, UAC3_EFFECT_UNIT):
984-
return parse_term_proc_unit(state, term, p1, id,
985-
UAC3_EFFECT_UNIT);
993+
return parse_term_effect_unit(state, term, p1, id);
986994
case PTYPE(UAC_VERSION_1, UAC1_EXTENSION_UNIT):
987995
case PTYPE(UAC_VERSION_2, UAC2_EXTENSION_UNIT_V2):
988996
case PTYPE(UAC_VERSION_3, UAC3_EXTENSION_UNIT):

0 commit comments

Comments
 (0)