Skip to content

Commit d0f6165

Browse files
krzkbroonie
authored andcommitted
ASoC: codecs: lpass-rx-macro: Fix playback 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 "RX_MACRO RX0 MUX"-like kcontrols which use "rx_macro_mux_text" array. That "rx_macro_mux_text" array used first three entries of DAI IDs enum, with value '0' being invalid. The value passed tp "RX_MACRO 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 headset playback on the Qualcomm SM8750 MTP8750 board. It seems it also fixes recording silence (instead of actual sound) via headset, even though that's different macro codec. 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: <20250901074403.137263-2-krzysztof.kozlowski@linaro.org> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 68f27f7 commit d0f6165

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ static struct interp_sample_rate sr_val_tbl[] = {
618618
{176400, 0xB}, {352800, 0xC},
619619
};
620620

621+
/* Matches also rx_macro_mux_text */
621622
enum {
622623
RX_MACRO_AIF1_PB,
623624
RX_MACRO_AIF2_PB,
@@ -722,6 +723,7 @@ static const char * const rx_int2_2_interp_mux_text[] = {
722723
"ZERO", "RX INT2_2 MUX",
723724
};
724725

726+
/* Order must match RX_MACRO_MAX_DAIS enum (offset by 1) */
725727
static const char *const rx_macro_mux_text[] = {
726728
"ZERO", "AIF1_PB", "AIF2_PB", "AIF3_PB", "AIF4_PB"
727729
};
@@ -2474,6 +2476,7 @@ static int rx_macro_mux_put(struct snd_kcontrol *kcontrol,
24742476
struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
24752477
struct snd_soc_dapm_update *update = NULL;
24762478
u32 rx_port_value = ucontrol->value.enumerated.item[0];
2479+
unsigned int dai_id;
24772480
u32 aif_rst;
24782481
struct rx_macro *rx = snd_soc_component_get_drvdata(component);
24792482

@@ -2490,19 +2493,24 @@ static int rx_macro_mux_put(struct snd_kcontrol *kcontrol,
24902493

24912494
switch (rx_port_value) {
24922495
case 0:
2493-
if (rx->active_ch_cnt[aif_rst]) {
2494-
clear_bit(widget->shift,
2495-
&rx->active_ch_mask[aif_rst]);
2496-
rx->active_ch_cnt[aif_rst]--;
2496+
/*
2497+
* active_ch_cnt and active_ch_mask use DAI IDs (RX_MACRO_MAX_DAIS).
2498+
* active_ch_cnt == 0 was tested in if() above.
2499+
*/
2500+
dai_id = aif_rst - 1;
2501+
if (rx->active_ch_cnt[dai_id]) {
2502+
clear_bit(widget->shift, &rx->active_ch_mask[dai_id]);
2503+
rx->active_ch_cnt[dai_id]--;
24972504
}
24982505
break;
24992506
case 1:
25002507
case 2:
25012508
case 3:
25022509
case 4:
2503-
set_bit(widget->shift,
2504-
&rx->active_ch_mask[rx_port_value]);
2505-
rx->active_ch_cnt[rx_port_value]++;
2510+
/* active_ch_cnt and active_ch_mask use DAI IDs (WSA_MACRO_MAX_DAIS). */
2511+
dai_id = rx_port_value - 1;
2512+
set_bit(widget->shift, &rx->active_ch_mask[dai_id]);
2513+
rx->active_ch_cnt[dai_id]++;
25062514
break;
25072515
default:
25082516
dev_err(component->dev,

0 commit comments

Comments
 (0)