Skip to content

Commit 9004a45

Browse files
krzkbroonie
authored andcommitted
ASoC: codecs: lpass-wsa-macro: Fix speaker quality distortion
Commit bb4a0f4 ("ASoC: codecs: lpass: Drop unused AIF_INVALID first DAI identifier") removed first entry in enum with DAI identifiers, because it looked unused. Turns out that there is a relation between DAI ID and "WSA RX0 Mux"-like kcontrols (which use "rx_mux_text" array). That "rx_mux_text" array used first three entries of DAI IDs enum, with value '0' being invalid. The value passed tp "WSA RX0 Mux"-like kcontrols was used as DAI ID and set to configure active channel count and mask, which are arrays indexed by DAI ID. After removal of first AIF_INVALID DAI identifier, this kcontrol was updating wrong entries in active channel count and mask arrays which was visible in reduced quality (distortions) during speaker playback on several boards like Lenovo T14s laptop and Qualcomm SM8550-based boards. Reported-by: Alexey Klimov <alexey.klimov@linaro.org> Fixes: bb4a0f4 ("ASoC: codecs: lpass: Drop unused AIF_INVALID first DAI identifier") Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com> Tested-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com> Message-ID: <20250831151401.30897-2-krzysztof.kozlowski@linaro.org> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent d0f6165 commit 9004a45

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

sound/soc/codecs/lpass-wsa-macro.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ static struct interp_sample_rate int_mix_sample_rate_val[] = {
368368
{192000, 0x6}, /* 192K */
369369
};
370370

371+
/* Matches also rx_mux_text */
371372
enum {
372373
WSA_MACRO_AIF1_PB,
373374
WSA_MACRO_AIF_MIX1_PB,
@@ -465,6 +466,7 @@ static const char *const rx_mix_ec_text[] = {
465466
"ZERO", "RX_MIX_TX0", "RX_MIX_TX1"
466467
};
467468

469+
/* Order must match WSA_MACRO_MAX_DAIS enum (offset by 1) */
468470
static const char *const rx_mux_text[] = {
469471
"ZERO", "AIF1_PB", "AIF_MIX1_PB"
470472
};
@@ -2207,6 +2209,7 @@ static int wsa_macro_rx_mux_put(struct snd_kcontrol *kcontrol,
22072209
u32 rx_port_value = ucontrol->value.integer.value[0];
22082210
u32 bit_input;
22092211
u32 aif_rst;
2212+
unsigned int dai_id;
22102213
struct wsa_macro *wsa = snd_soc_component_get_drvdata(component);
22112214

22122215
aif_rst = wsa->rx_port_value[widget->shift];
@@ -2224,17 +2227,22 @@ static int wsa_macro_rx_mux_put(struct snd_kcontrol *kcontrol,
22242227

22252228
switch (rx_port_value) {
22262229
case 0:
2227-
if (wsa->active_ch_cnt[aif_rst]) {
2228-
clear_bit(bit_input,
2229-
&wsa->active_ch_mask[aif_rst]);
2230-
wsa->active_ch_cnt[aif_rst]--;
2230+
/*
2231+
* active_ch_cnt and active_ch_mask use DAI IDs (WSA_MACRO_MAX_DAIS).
2232+
* active_ch_cnt == 0 was tested in if() above.
2233+
*/
2234+
dai_id = aif_rst - 1;
2235+
if (wsa->active_ch_cnt[dai_id]) {
2236+
clear_bit(bit_input, &wsa->active_ch_mask[dai_id]);
2237+
wsa->active_ch_cnt[dai_id]--;
22312238
}
22322239
break;
22332240
case 1:
22342241
case 2:
2235-
set_bit(bit_input,
2236-
&wsa->active_ch_mask[rx_port_value]);
2237-
wsa->active_ch_cnt[rx_port_value]++;
2242+
/* active_ch_cnt and active_ch_mask use DAI IDs (WSA_MACRO_MAX_DAIS). */
2243+
dai_id = rx_port_value - 1;
2244+
set_bit(bit_input, &wsa->active_ch_mask[dai_id]);
2245+
wsa->active_ch_cnt[dai_id]++;
22382246
break;
22392247
default:
22402248
dev_err(component->dev,

0 commit comments

Comments
 (0)