diff --git a/asoc/codecs/wsa884x/internal.h b/asoc/codecs/wsa884x/internal.h index 97afea8c52..a6d2cb774d 100644 --- a/asoc/codecs/wsa884x/internal.h +++ b/asoc/codecs/wsa884x/internal.h @@ -58,9 +58,9 @@ enum { SWR_DAC_PORT, SWR_COMP_PORT, SWR_BOOST_PORT, + SWR_PBR_PORT, SWR_VISENSE_PORT, - SWR_CPS_PORT, - SWR_PBRPORT + SWR_CPS_PORT }; struct wsa_ctrl_platform_data { @@ -91,6 +91,8 @@ struct wsa884x_priv { struct snd_soc_component *component; bool comp_enable; bool visense_enable; + bool cps_enable; + bool pbr_enable; bool ext_vdd_spk; bool dapm_bias_off; struct swr_port port[WSA884X_MAX_SWR_PORTS]; diff --git a/asoc/codecs/wsa884x/wsa884x-registers.h b/asoc/codecs/wsa884x/wsa884x-registers.h index d096d5cf96..6aba7f6d18 100644 --- a/asoc/codecs/wsa884x/wsa884x-registers.h +++ b/asoc/codecs/wsa884x/wsa884x-registers.h @@ -13,7 +13,7 @@ enum { RD_WR_REG, }; -#define WSA884X_BASE 0x0 +#define WSA884X_BASE 0x3000 #define WSA884X_REG(reg) (reg - WSA884X_BASE) #define WSA884X_BG_TSADC_BASE (WSA884X_BASE+0x01) diff --git a/asoc/codecs/wsa884x/wsa884x.c b/asoc/codecs/wsa884x/wsa884x.c index 9b667891ac..9182a493c2 100644 --- a/asoc/codecs/wsa884x/wsa884x.c +++ b/asoc/codecs/wsa884x/wsa884x.c @@ -907,6 +907,56 @@ static int wsa884x_set_visense(struct snd_kcontrol *kcontrol, return 0; } +static int wsa884x_get_pbr(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wsa884x_priv *wsa884x = snd_soc_component_get_drvdata(component); + + ucontrol->value.integer.value[0] = wsa884x->pbr_enable; + return 0; +} + +static int wsa884x_set_pbr(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wsa884x_priv *wsa884x = snd_soc_component_get_drvdata(component); + int value = ucontrol->value.integer.value[0]; + + dev_dbg(component->dev, "%s: VIsense enable current %d, new %d\n", + __func__, wsa884x->pbr_enable, value); + wsa884x->pbr_enable = value; + return 0; +} + +static int wsa884x_get_cps(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wsa884x_priv *wsa884x = snd_soc_component_get_drvdata(component); + + ucontrol->value.integer.value[0] = wsa884x->cps_enable; + return 0; +} + +static int wsa884x_set_cps(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wsa884x_priv *wsa884x = snd_soc_component_get_drvdata(component); + int value = ucontrol->value.integer.value[0]; + + dev_dbg(component->dev, "%s: VIsense enable current %d, new %d\n", + __func__, wsa884x->cps_enable, value); + wsa884x->cps_enable = value; + return 0; +} + static int wsa884x_get_ext_vdd_spk(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { @@ -959,6 +1009,12 @@ static const struct snd_kcontrol_new wsa884x_snd_controls[] = { SOC_SINGLE_EXT("VISENSE Switch", SND_SOC_NOPM, 0, 1, 0, wsa884x_get_visense, wsa884x_set_visense), + SOC_SINGLE_EXT("PBR Switch", SND_SOC_NOPM, 0, 1, 0, + wsa884x_get_pbr, wsa884x_set_pbr), + + SOC_SINGLE_EXT("CPS Switch", SND_SOC_NOPM, 0, 1, 0, + wsa884x_get_cps, wsa884x_set_cps), + SOC_SINGLE_EXT("External VDD_SPK", SND_SOC_NOPM, 0, 1, 0, wsa884x_get_ext_vdd_spk, wsa884x_put_ext_vdd_spk), }; @@ -1014,6 +1070,13 @@ static int wsa884x_enable_swr_dac_port(struct snd_soc_dapm_widget *w, &port_type[num_port]); ++num_port; } + if (wsa884x->pbr_enable) { + wsa884x_set_port(component, SWR_PBR_PORT, + &port_id[num_port], &num_ch[num_port], + &ch_mask[num_port], &ch_rate[num_port], + &port_type[num_port]); + ++num_port; + } if (wsa884x->visense_enable) { wsa884x_set_port(component, SWR_VISENSE_PORT, &port_id[num_port], &num_ch[num_port], @@ -1021,6 +1084,13 @@ static int wsa884x_enable_swr_dac_port(struct snd_soc_dapm_widget *w, &port_type[num_port]); ++num_port; } + if (wsa884x->cps_enable) { + wsa884x_set_port(component, SWR_CPS_PORT, + &port_id[num_port], &num_ch[num_port], + &ch_mask[num_port], &ch_rate[num_port], + &port_type[num_port]); + ++num_port; + } swr_connect_port(wsa884x->swr_slave, &port_id[0], num_port, &ch_mask[0], &ch_rate[0], &num_ch[0], &port_type[0]); @@ -1042,6 +1112,13 @@ static int wsa884x_enable_swr_dac_port(struct snd_soc_dapm_widget *w, &port_type[num_port]); ++num_port; } + if (wsa884x->pbr_enable) { + wsa884x_set_port(component, SWR_PBR_PORT, + &port_id[num_port], &num_ch[num_port], + &ch_mask[num_port], &ch_rate[num_port], + &port_type[num_port]); + ++num_port; + } if (wsa884x->visense_enable) { wsa884x_set_port(component, SWR_VISENSE_PORT, &port_id[num_port], &num_ch[num_port], @@ -1049,6 +1126,13 @@ static int wsa884x_enable_swr_dac_port(struct snd_soc_dapm_widget *w, &port_type[num_port]); ++num_port; } + if (wsa884x->cps_enable) { + wsa884x_set_port(component, SWR_CPS_PORT, + &port_id[num_port], &num_ch[num_port], + &ch_mask[num_port], &ch_rate[num_port], + &port_type[num_port]); + ++num_port; + } swr_disconnect_port(wsa884x->swr_slave, &port_id[0], num_port, &ch_mask[0], &port_type[0]); break; diff --git a/asoc/codecs/wsa884x/wsa884x.h b/asoc/codecs/wsa884x/wsa884x.h index 4793f43a7c..c4513bc909 100644 --- a/asoc/codecs/wsa884x/wsa884x.h +++ b/asoc/codecs/wsa884x/wsa884x.h @@ -13,7 +13,7 @@ #include "wsa884x-reg-shifts.h" -#define WSA884X_MAX_SWR_PORTS 4 +#define WSA884X_MAX_SWR_PORTS 6 #if IS_ENABLED(CONFIG_SND_SOC_WSA884X) int wsa884x_set_channel_map(struct snd_soc_component *component,