Commit a5d6d28e authored by Yassine Oudjana's avatar Yassine Oudjana Committed by Mark Brown

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: default avatarYassine Oudjana <y.oudjana@protonmail.com>
Link: https://lore.kernel.org/r/20220622061745.35399-1-y.oudjana@protonmail.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 7d90c8e6
......@@ -342,7 +342,7 @@ struct wcd9335_codec {
struct regulator_bulk_data supplies[WCD9335_MAX_SUPPLY];
unsigned int rx_port_value[WCD9335_RX_MAX];
unsigned int tx_port_value;
unsigned int tx_port_value[WCD9335_TX_MAX];
int hph_l_gain;
int hph_r_gain;
u32 rx_bias_count;
......@@ -1334,8 +1334,13 @@ static int slim_tx_mixer_get(struct snd_kcontrol *kc,
struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kc);
struct wcd9335_codec *wcd = dev_get_drvdata(dapm->dev);
struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kc);
struct soc_mixer_control *mixer =
(struct soc_mixer_control *)kc->private_value;
int dai_id = widget->shift;
int port_id = mixer->shift;
ucontrol->value.integer.value[0] = wcd->tx_port_value;
ucontrol->value.integer.value[0] = wcd->tx_port_value[port_id] == dai_id;
return 0;
}
......@@ -1358,12 +1363,12 @@ static int slim_tx_mixer_put(struct snd_kcontrol *kc,
case AIF2_CAP:
case AIF3_CAP:
/* only add to the list if value not set */
if (enable && !(wcd->tx_port_value & BIT(port_id))) {
wcd->tx_port_value |= BIT(port_id);
if (enable && wcd->tx_port_value[port_id] != dai_id) {
wcd->tx_port_value[port_id] = dai_id;
list_add_tail(&wcd->tx_chs[port_id].list,
&wcd->dai[dai_id].slim_ch_list);
} else if (!enable && (wcd->tx_port_value & BIT(port_id))) {
wcd->tx_port_value &= ~BIT(port_id);
} else if (!enable && wcd->tx_port_value[port_id] == dai_id) {
wcd->tx_port_value[port_id] = -1;
list_del_init(&wcd->tx_chs[port_id].list);
}
break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment