diff --git a/asoc/codecs/bolero/wsa-macro.c b/asoc/codecs/bolero/wsa-macro.c index b7f70e8a490b..198328bbe01e 100644 --- a/asoc/codecs/bolero/wsa-macro.c +++ b/asoc/codecs/bolero/wsa-macro.c @@ -235,6 +235,7 @@ struct wsa_macro_priv { [WSA_MACRO_CHILD_DEVICES_MAX]; int child_count; int ear_spkr_gain; + int wsa_spkrrecv; int spkr_gain_offset; int spkr_mode; int is_softclip_on[WSA_MACRO_SOFTCLIP_MAX]; @@ -293,6 +294,11 @@ static const struct snd_kcontrol_new wsa_int1_vbat_mix_switch[] = { SOC_DAPM_SINGLE("WSA RX1 VBAT Enable", SND_SOC_NOPM, 0, 1, 0) }; +static const char *const wsa_macro_ear_spkrrecv_text[] = { + "OFF", "ON" +}; +static SOC_ENUM_SINGLE_EXT_DECL(wsa_macro_ear_spkrrecv_enum, + wsa_macro_ear_spkrrecv_text); static SOC_ENUM_SINGLE_EXT_DECL(wsa_macro_ear_spkr_pa_gain_enum, wsa_macro_ear_spkr_pa_gain_text); static SOC_ENUM_SINGLE_EXT_DECL(wsa_macro_spkr_boost_stage_enum, @@ -1705,6 +1711,12 @@ static int wsa_macro_config_ear_spkr_gain(struct snd_soc_component *component, dev_dbg(wsa_priv->dev, "%s: RX0 Volume %d dB\n", __func__, val); } + if(wsa_priv->wsa_spkrrecv) { + snd_soc_component_update_bits(component, + BOLERO_CDC_WSA_COMPANDER0_CTL7, 0x01, 0x00); + snd_soc_component_update_bits(component, + BOLERO_CDC_WSA_COMPANDER0_CTL3, 0x80, 0x80); + } break; case SND_SOC_DAPM_POST_PMD: /* @@ -1719,6 +1731,10 @@ static int wsa_macro_config_ear_spkr_gain(struct snd_soc_component *component, dev_dbg(wsa_priv->dev, "%s: Reset RX0 Volume to 0 dB\n", __func__); } + snd_soc_component_update_bits(component, + BOLERO_CDC_WSA_COMPANDER0_CTL7, 0x01, 0x01); + snd_soc_component_update_bits(component, + BOLERO_CDC_WSA_COMPANDER0_CTL3, 0x80, 0x00); break; } @@ -2095,6 +2111,43 @@ static int wsa_macro_set_compander(struct snd_kcontrol *kcontrol, return 0; } +static int wsa_macro_ear_spkrrecv_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct device *wsa_dev = NULL; + struct wsa_macro_priv *wsa_priv = NULL; + + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) + return -EINVAL; + + ucontrol->value.integer.value[0] = wsa_priv->wsa_spkrrecv; + + dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", + __func__, ucontrol->value.integer.value[0]); + + return 0; +} + +static int wsa_macro_ear_spkrrecv_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct device *wsa_dev = NULL; + struct wsa_macro_priv *wsa_priv = NULL; + + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) + return -EINVAL; + wsa_priv->wsa_spkrrecv = ucontrol->value.integer.value[0]; + + dev_dbg(component->dev, "%s:spkrrecv status = %d\n", + __func__, wsa_priv->wsa_spkrrecv); + + return 0; +} + static int wsa_macro_ear_spkr_pa_gain_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { @@ -2360,6 +2413,9 @@ static int wsa_macro_soft_clip_enable_put(struct snd_kcontrol *kcontrol, } static const struct snd_kcontrol_new wsa_macro_snd_controls[] = { + SOC_ENUM_EXT("WSA SPKRRECV", wsa_macro_ear_spkrrecv_enum, + wsa_macro_ear_spkrrecv_get, + wsa_macro_ear_spkrrecv_put), SOC_ENUM_EXT("EAR SPKR PA Gain", wsa_macro_ear_spkr_pa_gain_enum, wsa_macro_ear_spkr_pa_gain_get, wsa_macro_ear_spkr_pa_gain_put), @@ -2752,10 +2808,10 @@ static const struct snd_soc_dapm_route wsa_audio_map[] = { static const struct wsa_macro_reg_mask_val wsa_macro_reg_init[] = { {BOLERO_CDC_WSA_BOOST0_BOOST_CFG1, 0x3F, 0x12}, {BOLERO_CDC_WSA_BOOST0_BOOST_CFG2, 0x1C, 0x08}, - {BOLERO_CDC_WSA_COMPANDER0_CTL7, 0x1E, 0x0C}, + {BOLERO_CDC_WSA_COMPANDER0_CTL7, 0x1E, 0x18}, {BOLERO_CDC_WSA_BOOST1_BOOST_CFG1, 0x3F, 0x12}, {BOLERO_CDC_WSA_BOOST1_BOOST_CFG2, 0x1C, 0x08}, - {BOLERO_CDC_WSA_COMPANDER1_CTL7, 0x1E, 0x0C}, + {BOLERO_CDC_WSA_COMPANDER1_CTL7, 0x1E, 0x18}, {BOLERO_CDC_WSA_BOOST0_BOOST_CTL, 0x70, 0x58}, {BOLERO_CDC_WSA_BOOST1_BOOST_CTL, 0x70, 0x58}, {BOLERO_CDC_WSA_RX0_RX_PATH_CFG1, 0x08, 0x08}, diff --git a/asoc/codecs/wsa883x/wsa883x.c b/asoc/codecs/wsa883x/wsa883x.c index 34e2660efaf6..574d6916bbd7 100644 --- a/asoc/codecs/wsa883x/wsa883x.c +++ b/asoc/codecs/wsa883x/wsa883x.c @@ -544,6 +544,12 @@ static const char * const wsa_dev_mode_text[] = { "speaker", "receiver", "ultrasound" }; +enum { + SPEAKER, + RECEIVER, + ULTRASOUND, +}; + static const struct soc_enum wsa_dev_mode_enum = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(wsa_dev_mode_text), wsa_dev_mode_text); @@ -1072,8 +1078,29 @@ static int wsa883x_spkr_event(struct snd_soc_dapm_widget *w, true); /* Added delay as per HW sequence */ usleep_range(250, 300); - snd_soc_component_update_bits(component, WSA883X_DRE_CTL_1, - 0x01, 0x01); + if (wsa883x->dev_mode == RECEIVER) { + snd_soc_component_update_bits(component, + WSA883X_DRE_CTL_0, + 0xF0, 0x00); + snd_soc_component_update_bits(component, + WSA883X_DRE_CTL_0, + 0x07, 0x04); + } else if (wsa883x->dev_mode == SPEAKER) { + snd_soc_component_update_bits(component, + WSA883X_DRE_CTL_0, + 0xF0, 0x90); + if (wsa883x->variant == WSA8830) + snd_soc_component_update_bits(component, + WSA883X_DRE_CTL_0, + 0x07, 0x03); + else + snd_soc_component_update_bits(component, + WSA883X_DRE_CTL_0, + 0x07, 0x02); + } + snd_soc_component_update_bits(component, + WSA883X_DRE_CTL_1, + 0x01, 0x01); /* Added delay as per HW sequence */ usleep_range(250, 300); wcd_enable_irq(&wsa883x->irq_info, WSA883X_IRQ_INT_PA_ON_ERR);