Skip to contentSkip to conversation

ALSA: usb-audio: Fix missing endian conversion

PATCH In review Takashi Iwai 2 participants 2 messages Apr 23, 2018 – Apr 24, 2018 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: usb-audio: Fix missing endian conversion

The UAC2 jack detection support introduced the bmControls checks in a couple of places, but they forgot the endian conversion; the bmControls of UAC2 terminal descriptor is __le16, not a byte like in UAC1.

Fixes 5a222e849452 ("ALSA: usb-audio: UAC2 jack detection")
---
 sound/usb/mixer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/usb/mixer.c +2 -2
index 301ad61ed426..f78b500b3c0e 100644
@@ -1859,7 +1859,7 @@ static int parse_audio_input_terminal(struct mixer_build *state, int unitid,
 	check_input_term(state, d->bTerminalID, &iterm);
 	if (state->mixer->protocol == UAC_VERSION_2) {
 		/* Check for jack detection. */
-		if (uac_v2v3_control_is_readable(d->bmControls,
+		if (uac_v2v3_control_is_readable(le16_to_cpu(d->bmControls),
 						 UAC2_TE_CONNECTOR)) {
 			build_connector_control(state, &iterm, true);
 		}
@@ -2561,7 +2561,7 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer)
 			if (err < 0 && err != -EINVAL)
 				return err;
 
-			if (uac_v2v3_control_is_readable(desc->bmControls,
+			if (uac_v2v3_control_is_readable(le16_to_cpu(desc->bmControls),
 							 UAC2_TE_CONNECTOR)) {
 				build_connector_control(&state, &state.oterm,
 							false);
Signature · 1 line
2.16.3
Tested-by on v1 1/1
#1 lore raw
Quoted 8 lines · Takashi Iwai

The UAC2 jack detection support introduced the bmControls checks in a couple of places, but they forgot the endian conversion; the bmControls of UAC2 terminal descriptor is __le16, not a byte like in UAC1.

Fixes 5a222e849452 ("ALSA: usb-audio: UAC2 jack detection")
Quoted 28 lines
---
 sound/usb/mixer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/usb/mixer.c +2 -3
index 301ad61ed426..f78b500b3c0e 100644
@@ -1859,7 +1859,7 @@ static int parse_audio_input_terminal(struct mixer_build *state, int unitid,
        check_input_term(state, d->bTerminalID, &iterm);
        if (state->mixer->protocol == UAC_VERSION_2) {
                /* Check for jack detection. */
-               if (uac_v2v3_control_is_readable(d->bmControls,
+               if (uac_v2v3_control_is_readable(le16_to_cpu(d->bmControls),
                                                 UAC2_TE_CONNECTOR)) {
                        build_connector_control(state, &iterm, true);
                }
@@ -2561,7 +2561,7 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer)
                        if (err < 0 && err != -EINVAL)
                                return err;
 
-                       if (uac_v2v3_control_is_readable(desc->bmControls,
+                       if (uac_v2v3_control_is_readable(le16_to_cpu(desc->bmControls),
                                                         UAC2_TE_CONNECTOR)) {
                                build_connector_control(&state, &state.oterm,
                                                        false);
--
Quoted 2 lines

2.16.3

Tests fine, thank you. Did you intentionally leave the UAC2_CS_CONTROL_CLOCK_VALID reading at line 1575 for another patch?