ASoC: codecs: wcd938x: fix wcd938x_get_swr_port
Subsystems (4)
PATCH 1/1 ASoC: codecs: wcd938x: fix wcd938x_get_swr_port
Controls can share the same "portidx" value (e.g. HPHL and HPHR), this leads to wcd938x_get_swr_port returning incorrect state. For example, when trying to enable both HPHL/HPHR with amixer: after enabling HPHL, HPHR will appear enabled and amixer skips writing to the control.
This could be fixed by indexing with "ch_idx" instead, but lets just get rid of port_enable[] and check the ch_mask value of the port instead.
Fixes e8ba1e05bdc0 ("ASoC: codecs: wcd938x: add basic controls")
Signed-off-by Jonathan Marek <[email protected]>
--- sound/soc/codecs/wcd938x.c | 9 ++++++--- sound/soc/codecs/wcd938x.h | 1 - 2 files changed, 6 insertions(+), 4 deletions(-)
sound/soc/codecs/wcd938x.c +6 -3
@@ -1854,14 +1854,19 @@ static int wcd938x_get_swr_port(struct snd_kcontrol *kcontrol,struct wcd938x_priv *wcd938x =snd_soc_component_get_drvdata (comp);struct wcd938x_sdw_priv *wcd;struct soc_mixer_control *mixer = (struct soc_mixer_control *)kcontrol->private_value; +struct sdw_port_config *port_config;int dai_id = mixer->shift;int portidx, ch_idx = mixer->reg; wcd = wcd938x->sdw_priv[dai_id]; portidx = wcd->ch_info[ch_idx].port_num; + port_config = &wcd->port_config[portidx -1 ]; - ucontrol->value.integer.value[0 ] = wcd->port_enable[portidx]; +if (port_config->ch_mask & wcd->ch_info[ch_idx].ch_mask) + ucontrol->value.integer.value[0 ] = true; +else + ucontrol->value.integer.value[0 ] = false;return 0 ; }
@@ -1887,8 +1892,6 @@ static int wcd938x_set_swr_port(struct snd_kcontrol *kcontrol,else enable = false; - wcd->port_enable[portidx] = enable; -wcd938x_connect_port (wcd, portidx, ch_idx, enable);return 1 ;
sound/soc/codecs/wcd938x.h +0 -1
@@ -650,7 +650,6 @@ struct wcd938x_sdw_priv {struct sdw_stream_runtime *sruntime;struct sdw_port_config port_config[WCD938X_MAX_SWR_PORTS ];const struct wcd938x_sdw_ch_info *ch_info; -bool port_enable[WCD938X_MAX_SWR_CH_IDS ];int active_ports;bool is_tx;struct wcd938x_priv *wcd938x;
Signature · 1 line
2.45.1