Skip to content

Commit a5d6d28

Browse files
Tooniisbroonie
authored andcommitted
ASoC: wcd9335: Use int array instead of bitmask for TX mixers
Currently slim_tx_mixer_get reports all TX mixers as enabled when at least one is, due to it reading the entire tx_port_value bitmask without testing the specific bit corresponding to a TX port. Furthermore, using the same bitmask for all capture DAIs makes setting one mixer affect them all. To prevent this, and since the SLIM TX muxes effectively only connect to one of the mixers at a time, turn tx_port_value into an int array storing the DAI index each of the ports is connected to. Signed-off-by: Yassine Oudjana <y.oudjana@protonmail.com> Link: https://lore.kernel.org/r/20220622061745.35399-1-y.oudjana@protonmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 7d90c8e commit a5d6d28

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

sound/soc/codecs/wcd9335.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ struct wcd9335_codec {
342342
struct regulator_bulk_data supplies[WCD9335_MAX_SUPPLY];
343343

344344
unsigned int rx_port_value[WCD9335_RX_MAX];
345-
unsigned int tx_port_value;
345+
unsigned int tx_port_value[WCD9335_TX_MAX];
346346
int hph_l_gain;
347347
int hph_r_gain;
348348
u32 rx_bias_count;
@@ -1334,8 +1334,13 @@ static int slim_tx_mixer_get(struct snd_kcontrol *kc,
13341334

13351335
struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kc);
13361336
struct wcd9335_codec *wcd = dev_get_drvdata(dapm->dev);
1337+
struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kc);
1338+
struct soc_mixer_control *mixer =
1339+
(struct soc_mixer_control *)kc->private_value;
1340+
int dai_id = widget->shift;
1341+
int port_id = mixer->shift;
13371342

1338-
ucontrol->value.integer.value[0] = wcd->tx_port_value;
1343+
ucontrol->value.integer.value[0] = wcd->tx_port_value[port_id] == dai_id;
13391344

13401345
return 0;
13411346
}
@@ -1358,12 +1363,12 @@ static int slim_tx_mixer_put(struct snd_kcontrol *kc,
13581363
case AIF2_CAP:
13591364
case AIF3_CAP:
13601365
/* only add to the list if value not set */
1361-
if (enable && !(wcd->tx_port_value & BIT(port_id))) {
1362-
wcd->tx_port_value |= BIT(port_id);
1366+
if (enable && wcd->tx_port_value[port_id] != dai_id) {
1367+
wcd->tx_port_value[port_id] = dai_id;
13631368
list_add_tail(&wcd->tx_chs[port_id].list,
13641369
&wcd->dai[dai_id].slim_ch_list);
1365-
} else if (!enable && (wcd->tx_port_value & BIT(port_id))) {
1366-
wcd->tx_port_value &= ~BIT(port_id);
1370+
} else if (!enable && wcd->tx_port_value[port_id] == dai_id) {
1371+
wcd->tx_port_value[port_id] = -1;
13671372
list_del_init(&wcd->tx_chs[port_id].list);
13681373
}
13691374
break;

0 commit comments

Comments
 (0)