asoc: lpass-cdc: Update compander zone settings for macros
Update compander settings table to calculate based on upper gain and lower gain. Change-Id: Ib423f3c14c900c0df03bc8fcab2df0f62fb614f1 Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org>
This commit is contained in:
@@ -23,14 +23,94 @@ int lpass_cdc_load_compander_coeff(struct snd_soc_component *component,
|
||||
EXPORT_SYMBOL(lpass_cdc_load_compander_coeff);
|
||||
|
||||
int lpass_cdc_update_compander_setting(struct snd_soc_component *component,
|
||||
u16 start_addr, u8 *reg_val)
|
||||
u16 start_addr,
|
||||
struct lpass_cdc_comp_setting *comp_setting)
|
||||
{
|
||||
u16 i = 0;
|
||||
int zone2_rms, zone3_rms, zone4_rms, zone5_rms, zone6_rms;
|
||||
int path_gain;
|
||||
int max_attn;
|
||||
int zone1_rms = 6;
|
||||
int upper_gain_int = comp_setting->upper_gain_int;
|
||||
int lower_gain_int = comp_setting->lower_gain_int;
|
||||
int ana_addr_map = comp_setting->ana_addr_map;
|
||||
int upper_gain_dig_int = upper_gain_int - lower_gain_int;
|
||||
|
||||
for (i = 0; i < COMP_MAX_SETTING; i++)
|
||||
snd_soc_component_write(component,
|
||||
start_addr + i * 4,
|
||||
reg_val[i]);
|
||||
/* skip comp_ctl8, comp_ctl9 default settings is fine */
|
||||
|
||||
/* apply zone settings */
|
||||
snd_soc_component_write(component,
|
||||
start_addr + 8,
|
||||
zone1_rms);
|
||||
|
||||
if (upper_gain_dig_int >= 24)
|
||||
zone2_rms = 18;
|
||||
else if (upper_gain_dig_int >= 18)
|
||||
zone2_rms = 12;
|
||||
else
|
||||
zone2_rms = upper_gain_dig_int;
|
||||
snd_soc_component_write(component,
|
||||
start_addr + 0xC,
|
||||
zone2_rms);
|
||||
|
||||
if (upper_gain_dig_int >= 66)
|
||||
zone3_rms = 33;
|
||||
else if (upper_gain_dig_int >= 36)
|
||||
zone3_rms = 30;
|
||||
else if (upper_gain_dig_int >= 30)
|
||||
zone3_rms = 24;
|
||||
else
|
||||
zone3_rms = upper_gain_dig_int;
|
||||
snd_soc_component_write(component,
|
||||
start_addr + 0x10,
|
||||
zone3_rms);
|
||||
|
||||
if (upper_gain_dig_int >= 66)
|
||||
zone4_rms = 48;
|
||||
else if (upper_gain_dig_int >= 48)
|
||||
zone4_rms = 42;
|
||||
else if (upper_gain_dig_int >= 42)
|
||||
zone4_rms = 36;
|
||||
else
|
||||
zone4_rms = upper_gain_dig_int;
|
||||
snd_soc_component_write(component,
|
||||
start_addr + 0x14,
|
||||
zone4_rms);
|
||||
|
||||
if (upper_gain_dig_int >= 69)
|
||||
zone5_rms = 63;
|
||||
else if (upper_gain_dig_int >= 66)
|
||||
zone5_rms = 60;
|
||||
else if (upper_gain_dig_int >= 60)
|
||||
zone5_rms = 54;
|
||||
else if (upper_gain_dig_int >= 54)
|
||||
zone5_rms = 48;
|
||||
else
|
||||
zone5_rms = upper_gain_dig_int;
|
||||
snd_soc_component_write(component,
|
||||
start_addr + 0x18,
|
||||
zone5_rms);
|
||||
|
||||
zone6_rms = upper_gain_dig_int;
|
||||
snd_soc_component_write(component,
|
||||
start_addr + 0x1C,
|
||||
zone6_rms);
|
||||
|
||||
if (lower_gain_int < 0)
|
||||
max_attn = 256 + lower_gain_int;
|
||||
else
|
||||
max_attn = lower_gain_int;
|
||||
snd_soc_component_write(component,
|
||||
start_addr + 0x20,
|
||||
max_attn);
|
||||
|
||||
path_gain = upper_gain_dig_int;
|
||||
snd_soc_component_write(component,
|
||||
start_addr + 0x24,
|
||||
path_gain);
|
||||
|
||||
snd_soc_component_write(component,
|
||||
start_addr + 0x28,
|
||||
ana_addr_map);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -6,18 +6,22 @@
|
||||
|
||||
#include <sound/soc.h>
|
||||
|
||||
#define COMP_MAX_SETTING 12
|
||||
|
||||
struct comp_coeff_val {
|
||||
u8 lsb;
|
||||
u8 msb;
|
||||
};
|
||||
|
||||
struct lpass_cdc_comp_setting {
|
||||
int upper_gain_int;
|
||||
int lower_gain_int;
|
||||
int ana_addr_map;
|
||||
};
|
||||
|
||||
int lpass_cdc_load_compander_coeff(struct snd_soc_component *component,
|
||||
u16 lsb_reg, u16 msb_reg,
|
||||
struct comp_coeff_val *comp_coeff_table,
|
||||
u16 arr_size);
|
||||
int lpass_cdc_update_compander_setting(struct snd_soc_component *component,
|
||||
u16 start_addr, u8 *reg_val);
|
||||
|
||||
u16 start_addr,
|
||||
struct lpass_cdc_comp_setting *comp_setting);
|
||||
#endif
|
||||
|
@@ -174,11 +174,11 @@ enum {
|
||||
RX_MODE_MAX
|
||||
};
|
||||
|
||||
static u8 comp_setting_table[RX_MODE_MAX][COMP_MAX_SETTING] =
|
||||
static struct lpass_cdc_comp_setting comp_setting_table[RX_MODE_MAX] =
|
||||
{
|
||||
{0x00, 0x10, 0x06, 0x12, 0x21, 0x30, 0x3F, 0x48, 0xC4, 0xC, 0xC, 0xB0}, /* ULP */
|
||||
{0x00, 0x00, 0x06, 0x12, 0x1E, 0x2A, 0x36, 0x3C, 0xC4, 0x0, 0xC, 0xB0}, /* LOHIFI */
|
||||
{0x00, 0x10, 0x06, 0x12, 0x1E, 0x2A, 0x30, 0x30, 0xDC, 0xC, 0xC, 0xB0}, /* EAR -36 max_attn */
|
||||
{12, -60, 12},
|
||||
{0, -60, 12},
|
||||
{12, -36, 12},
|
||||
};
|
||||
|
||||
struct lpass_cdc_rx_macro_reg_mask_val {
|
||||
@@ -1853,7 +1853,7 @@ static int lpass_cdc_rx_macro_config_compander(struct snd_soc_component *compone
|
||||
|
||||
lpass_cdc_update_compander_setting(component,
|
||||
comp_ctl8_reg,
|
||||
comp_setting_table[mode]);
|
||||
&comp_setting_table[mode]);
|
||||
|
||||
/* Enable Compander Clock */
|
||||
snd_soc_component_update_bits(component, comp_ctl0_reg,
|
||||
|
@@ -123,17 +123,17 @@ enum {
|
||||
WSA_MODE_MAX
|
||||
};
|
||||
|
||||
static u8 comp_setting_table[WSA_MODE_MAX][COMP_MAX_SETTING] =
|
||||
static struct lpass_cdc_comp_setting comp_setting_table[WSA_MODE_MAX] =
|
||||
{
|
||||
{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 */
|
||||
{42, 0, 42},
|
||||
{39, 0, 42},
|
||||
{36, 0, 42},
|
||||
{33, 0, 42},
|
||||
{30, 0, 42},
|
||||
{27, 0, 42},
|
||||
{24, 0, 42},
|
||||
{21, 0, 42},
|
||||
{18, 0, 42},
|
||||
};
|
||||
|
||||
struct interp_sample_rate {
|
||||
@@ -1269,7 +1269,7 @@ static int lpass_cdc_wsa_macro_config_compander(struct snd_soc_component *compon
|
||||
if (SND_SOC_DAPM_EVENT_ON(event)) {
|
||||
lpass_cdc_update_compander_setting(component,
|
||||
comp_ctl8_reg,
|
||||
comp_setting_table[mode]);
|
||||
&comp_setting_table[mode]);
|
||||
/* Enable Compander Clock */
|
||||
snd_soc_component_update_bits(component, comp_ctl0_reg,
|
||||
0x01, 0x01);
|
||||
|
@@ -123,17 +123,17 @@ enum {
|
||||
WSA2_MODE_MAX
|
||||
};
|
||||
|
||||
static u8 comp_setting_table[WSA2_MODE_MAX][COMP_MAX_SETTING] =
|
||||
static struct lpass_cdc_comp_setting comp_setting_table[WSA2_MODE_MAX] =
|
||||
{
|
||||
{0x00, 0x10, 0x06, 0x18, 0x24, 0x2A, 0x2A, 0x2A, 0x00, 0x2A, 0x2A, 0xB0}, /* WSA2_MODE_21DB */
|
||||
{0x00, 0x10, 0x06, 0x18, 0x24, 0x2A, 0x2A, 0x2A, 0xFD, 0x2A, 0x2A, 0xB0}, /* WSA2_MODE_19PDB -1.5DB*/
|
||||
{0x00, 0x10, 0x06, 0x12, 0x1E, 0x24, 0x24, 0x24, 0xFA, 0x24, 0x2A, 0xB0}, /* WSA2_MODE_18DB -3DB*/
|
||||
{0x00, 0x10, 0x06, 0x0C, 0x18, 0x21, 0x21, 0x21, 0xFA, 0x21, 0x2A, 0xB0}, /* WSA2_MODE_16P5DB -3DB*/
|
||||
{0x00, 0x10, 0x06, 0x0C, 0x18, 0x21, 0x21, 0x21, 0xFA, 0x21, 0x2A, 0xB0}, /* WSA2_MODE_15DB -3DB -->TODO: NEED UPDATE ENTRIES */
|
||||
{0x00, 0x10, 0x06, 0x12, 0x1B, 0x1B, 0x1B, 0x1B, 0xFA, 0x1B, 0x2A, 0xB0}, /* WSA2_MODE_13P5DB -3DB */
|
||||
{0x00, 0x10, 0x06, 0x12, 0x18, 0x18, 0x18, 0x18, 0xFA, 0x18, 0x2A, 0xB0}, /* WSA2_MODE_12DB -3DB */
|
||||
{0x00, 0x10, 0x06, 0x12, 0x18, 0x18, 0x18, 0x18, 0xFA, 0x18, 0x2A, 0xB0}, /* WSA2_MODE_10P5DB -3DB --> NEED Update entries */
|
||||
{0x00, 0x10, 0x06, 0x12, 0x18, 0x18, 0x18, 0x18, 0xFA, 0x18, 0x2A, 0xB0}, /* WSA2_MODE_9DB -3DB --> NEED Update entries */
|
||||
{42, 0, 42},
|
||||
{39, 0, 42},
|
||||
{36, 0, 42},
|
||||
{33, 0, 42},
|
||||
{30, 0, 42},
|
||||
{27, 0, 42},
|
||||
{24, 0, 42},
|
||||
{21, 0, 42},
|
||||
{18, 0, 42},
|
||||
};
|
||||
|
||||
struct interp_sample_rate {
|
||||
@@ -1266,7 +1266,7 @@ static int lpass_cdc_wsa2_macro_config_compander(struct snd_soc_component *compo
|
||||
if (SND_SOC_DAPM_EVENT_ON(event)) {
|
||||
lpass_cdc_update_compander_setting(component,
|
||||
comp_ctl8_reg,
|
||||
comp_setting_table[mode]);
|
||||
&comp_setting_table[mode]);
|
||||
/* Enable Compander Clock */
|
||||
snd_soc_component_update_bits(component, comp_ctl0_reg,
|
||||
0x01, 0x01);
|
||||
|
Reference in New Issue
Block a user