asoc: lpass-cdc: Add support for unified compander

On lpass-cdc 2.5 support unified compander. Update macros
to align to this feature.

Change-Id: Id444116511db48e8f20948ed7fc4af4fca87b8e4
Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org>
This commit is contained in:
Laxminath Kasam
2020-10-21 17:18:37 +05:30
committed by Gerrit - the friendly Code Review server
parent eca32d433e
commit ab521cd5c8
5 changed files with 218 additions and 67 deletions

View File

@@ -16,6 +16,7 @@
#include <asoc/msm-cdc-pinctrl.h>
#include "lpass-cdc.h"
#include "lpass-cdc-comp.h"
#include "lpass-cdc-registers.h"
#include "lpass-cdc-wsa-macro.h"
#include "lpass-cdc-clk-rsc.h"
@@ -107,6 +108,32 @@ enum {
INTn_2_INP_SEL_RX3,
};
enum {
WSA_MODE_21DB,
WSA_MODE_19P5DB,
WSA_MODE_18DB,
WSA_MODE_16P5DB,
WSA_MODE_15DB,
WSA_MODE_13P5DB,
WSA_MODE_12DB,
WSA_MODE_10P5DB,
WSA_MODE_9DB,
WSA_MODE_MAX
};
static u8 comp_setting_table[WSA_MODE_MAX][COMP_MAX_SETTING] =
{
{0x00, 0x10, 0x06, 0x18, 0x24, 0x2A, 0x2A, 0x2A, 0x00, 0x2A, 0x2A, 0xB0}, /* WSA_MODE_21DB */
{0x00, 0x10, 0x06, 0x18, 0x24, 0x2A, 0x2A, 0x2A, 0xFD, 0x2A, 0x2A, 0xB0}, /* WSA_MODE_19PDB -1.5DB*/
{0x00, 0x10, 0x06, 0x12, 0x1E, 0x24, 0x24, 0x24, 0xFA, 0x24, 0x2A, 0xB0}, /* WSA_MODE_18DB -3DB*/
{0x00, 0x10, 0x06, 0x0C, 0x18, 0x21, 0x21, 0x21, 0xFA, 0x21, 0x2A, 0xB0}, /* WSA_MODE_16P5DB -3DB*/
{0x00, 0x10, 0x06, 0x0C, 0x18, 0x21, 0x21, 0x21, 0xFA, 0x21, 0x2A, 0xB0}, /* WSA_MODE_15DB -3DB -->TODO: NEED UPDATE ENTRIES */
{0x00, 0x10, 0x06, 0x12, 0x1B, 0x1B, 0x1B, 0x1B, 0xFA, 0x1B, 0x2A, 0xB0}, /* WSA_MODE_13P5DB -3DB */
{0x00, 0x10, 0x06, 0x12, 0x18, 0x18, 0x18, 0x18, 0xFA, 0x18, 0x2A, 0xB0}, /* WSA_MODE_12DB -3DB */
{0x00, 0x10, 0x06, 0x12, 0x18, 0x18, 0x18, 0x18, 0xFA, 0x18, 0x2A, 0xB0}, /* WSA_MODE_10P5DB -3DB --> NEED Update entries */
{0x00, 0x10, 0x06, 0x12, 0x18, 0x18, 0x18, 0x18, 0xFA, 0x18, 0x2A, 0xB0}, /* WSA_MODE_9DB -3DB --> NEED Update entries */
};
struct interp_sample_rate {
int sample_rate;
int rate_val;
@@ -210,6 +237,7 @@ enum {
struct lpass_cdc_wsa_macro_priv {
struct device *dev;
int comp_enabled[LPASS_CDC_WSA_MACRO_COMP_MAX];
int comp_mode[LPASS_CDC_WSA_MACRO_COMP_MAX];
int ec_hq[LPASS_CDC_WSA_MACRO_RX1 + 1];
u16 prim_int_users[LPASS_CDC_WSA_MACRO_RX1 + 1];
u16 wsa_mclk_users;
@@ -284,6 +312,11 @@ static const char * const lpass_cdc_wsa_macro_vbat_bcl_gsm_mode_text[] = {
"OFF", "ON"
};
static const char * const lpass_cdc_wsa_macro_comp_mode_text[] = {
"G_21_DB", "G_19P5_DB", "G_18_DB", "G_16P5_DB", "G_15_DB",
"G_13P5_DB", "G_12_DB", "G_10P5_DB", "G_9_DB"
};
static const struct snd_kcontrol_new wsa_int0_vbat_mix_switch[] = {
SOC_DAPM_SINGLE("WSA RX0 VBAT Enable", SND_SOC_NOPM, 0, 1, 0)
};
@@ -298,6 +331,8 @@ static SOC_ENUM_SINGLE_EXT_DECL(lpass_cdc_wsa_macro_spkr_boost_stage_enum,
lpass_cdc_wsa_macro_speaker_boost_stage_text);
static SOC_ENUM_SINGLE_EXT_DECL(lpass_cdc_wsa_macro_vbat_bcl_gsm_mode_enum,
lpass_cdc_wsa_macro_vbat_bcl_gsm_mode_text);
static SOC_ENUM_SINGLE_EXT_DECL(lpass_cdc_wsa_macro_comp_mode_enum,
lpass_cdc_wsa_macro_comp_mode_text);
/* RX INT0 */
static const struct soc_enum rx0_prim_inp0_chain_enum =
@@ -1312,9 +1347,10 @@ static int lpass_cdc_wsa_macro_enable_mix_path(struct snd_soc_dapm_widget *w,
static int lpass_cdc_wsa_macro_config_compander(struct snd_soc_component *component,
int comp, int event)
{
u16 comp_ctl0_reg, rx_path_cfg0_reg;
u16 comp_ctl0_reg, comp_ctl8_reg, rx_path_cfg0_reg;
struct device *wsa_dev = NULL;
struct lpass_cdc_wsa_macro_priv *wsa_priv = NULL;
u16 mode = 0;
if (!lpass_cdc_wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__))
return -EINVAL;
@@ -1325,12 +1361,18 @@ static int lpass_cdc_wsa_macro_config_compander(struct snd_soc_component *compon
if (!wsa_priv->comp_enabled[comp])
return 0;
mode = wsa_priv->comp_mode[comp];
comp_ctl0_reg = LPASS_CDC_WSA_COMPANDER0_CTL0 +
(comp * LPASS_CDC_WSA_MACRO_RX_COMP_OFFSET);
comp_ctl8_reg = LPASS_CDC_WSA_COMPANDER0_CTL8 +
(comp * LPASS_CDC_WSA_MACRO_RX_COMP_OFFSET);
rx_path_cfg0_reg = LPASS_CDC_WSA_RX0_RX_PATH_CFG0 +
(comp * LPASS_CDC_WSA_MACRO_RX_PATH_OFFSET);
if (SND_SOC_DAPM_EVENT_ON(event)) {
lpass_cdc_update_compander_setting(component,
comp_ctl8_reg,
comp_setting_table[mode]);
/* Enable Compander Clock */
snd_soc_component_update_bits(component, comp_ctl0_reg,
0x01, 0x01);
@@ -2134,6 +2176,54 @@ static int lpass_cdc_wsa_macro_ear_spkr_pa_gain_put(struct snd_kcontrol *kcontro
return 0;
}
static int lpass_cdc_wsa_macro_comp_mode_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 lpass_cdc_wsa_macro_priv *wsa_priv = NULL;
u16 idx = 0;
if (!lpass_cdc_wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__))
return -EINVAL;
if (strnstr(kcontrol->id.name, "RX0", sizeof("WSA_RX0")))
idx = LPASS_CDC_WSA_MACRO_COMP1;
if (strnstr(kcontrol->id.name, "RX1", sizeof("WSA_RX1")))
idx = LPASS_CDC_WSA_MACRO_COMP2;
ucontrol->value.integer.value[0] = wsa_priv->comp_mode[idx];
dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
__func__, ucontrol->value.integer.value[0]);
return 0;
}
static int lpass_cdc_wsa_macro_comp_mode_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 lpass_cdc_wsa_macro_priv *wsa_priv = NULL;
u16 idx = 0;
if (!lpass_cdc_wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__))
return -EINVAL;
if (strnstr(kcontrol->id.name, "RX0", sizeof("WSA_RX0")))
idx = LPASS_CDC_WSA_MACRO_COMP1;
if (strnstr(kcontrol->id.name, "RX1", sizeof("WSA_RX1")))
idx = LPASS_CDC_WSA_MACRO_COMP2;
wsa_priv->comp_mode[idx] = ucontrol->value.integer.value[0];
dev_dbg(component->dev, "%s: comp_mode = %d\n", __func__,
wsa_priv->comp_mode[idx]);
return 0;
}
static int lpass_cdc_wsa_macro_spkr_left_boost_stage_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
@@ -2375,6 +2465,12 @@ static const struct snd_kcontrol_new lpass_cdc_wsa_macro_snd_controls[] = {
SOC_ENUM_EXT("GSM mode Enable", lpass_cdc_wsa_macro_vbat_bcl_gsm_mode_enum,
lpass_cdc_wsa_macro_vbat_bcl_gsm_mode_func_get,
lpass_cdc_wsa_macro_vbat_bcl_gsm_mode_func_put),
SOC_ENUM_EXT("WSA_RX0 comp_mode", lpass_cdc_wsa_macro_comp_mode_enum,
lpass_cdc_wsa_macro_comp_mode_get,
lpass_cdc_wsa_macro_comp_mode_put),
SOC_ENUM_EXT("WSA_RX1 comp_mode", lpass_cdc_wsa_macro_comp_mode_enum,
lpass_cdc_wsa_macro_comp_mode_get,
lpass_cdc_wsa_macro_comp_mode_put),
SOC_SINGLE_EXT("WSA_Softclip0 Enable", SND_SOC_NOPM,
LPASS_CDC_WSA_MACRO_SOFTCLIP0, 1, 0,
lpass_cdc_wsa_macro_soft_clip_enable_get,