ASoC: codec: Update codec driver to component driver
Some alsa API are removed in kernel-4.19 which would cause codec driver compile failure. Update codec driver to fix it. Change-Id: Ie358ec1863082166958059c179300b453d2a03ad Signed-off-by: Meng Wang <mengw@codeaurora.org>
这个提交包含在:

提交者
Gerrit - the friendly Code Review server

父节点
ee084a068e
当前提交
15c825d077
@@ -10,11 +10,12 @@
|
||||
#include <linux/of_device.h>
|
||||
#include <sound/soc.h>
|
||||
|
||||
extern int aqt_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec,
|
||||
extern int aqt_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
|
||||
int volt, int micb_num);
|
||||
extern int aqt_cdc_mclk_enable(struct snd_soc_codec *codec, bool enable);
|
||||
extern int aqt_cdc_mclk_enable(struct snd_soc_component *component,
|
||||
bool enable);
|
||||
extern int aqt_get_micb_vout_ctl_val(u32 micb_mv);
|
||||
extern int aqt_micbias_control(struct snd_soc_codec *codec, int micb_num,
|
||||
int req, bool is_dapm);
|
||||
extern int aqt_micbias_control(struct snd_soc_component *component,
|
||||
int micb_num, int req, bool is_dapm);
|
||||
|
||||
#endif /* AQT1000_API_H */
|
||||
|
@@ -136,7 +136,7 @@ static const struct aqt_imped_val imped_index[] = {
|
||||
{13, 9},
|
||||
};
|
||||
|
||||
static void (*clsh_state_fp[NUM_CLSH_STATES])(struct snd_soc_codec *,
|
||||
static void (*clsh_state_fp[NUM_CLSH_STATES])(struct snd_soc_component *,
|
||||
struct aqt_clsh_cdc_data *,
|
||||
u8 req_state, bool en, int mode);
|
||||
|
||||
@@ -169,12 +169,13 @@ ret:
|
||||
|
||||
/*
|
||||
* Function: aqt_clsh_imped_config
|
||||
* Params: codec, imped, reset
|
||||
* Params: component, imped, reset
|
||||
* Description:
|
||||
* This function updates HPHL and HPHR gain settings
|
||||
* according to the impedance value.
|
||||
*/
|
||||
void aqt_clsh_imped_config(struct snd_soc_codec *codec, int imped, bool reset)
|
||||
void aqt_clsh_imped_config(struct snd_soc_component *component,
|
||||
int imped, bool reset)
|
||||
{
|
||||
int i;
|
||||
int index = 0;
|
||||
@@ -189,7 +190,7 @@ void aqt_clsh_imped_config(struct snd_soc_codec *codec, int imped, bool reset)
|
||||
/* reset = 1, which means request is to reset the register values */
|
||||
if (reset) {
|
||||
for (i = 0; i < MAX_IMPED_PARAMS; i++)
|
||||
snd_soc_update_bits(codec,
|
||||
snd_soc_component_update_bits(component,
|
||||
imped_table_ptr[index][i].reg,
|
||||
imped_table_ptr[index][i].mask, 0);
|
||||
return;
|
||||
@@ -205,7 +206,7 @@ void aqt_clsh_imped_config(struct snd_soc_codec *codec, int imped, bool reset)
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < MAX_IMPED_PARAMS; i++)
|
||||
snd_soc_update_bits(codec,
|
||||
snd_soc_component_update_bits(component,
|
||||
imped_table_ptr[index][i].reg,
|
||||
imped_table_ptr[index][i].mask,
|
||||
imped_table_ptr[index][i].val);
|
||||
@@ -242,22 +243,23 @@ static const char *const state_to_str[] = {
|
||||
};
|
||||
|
||||
static inline void
|
||||
aqt_enable_clsh_block(struct snd_soc_codec *codec,
|
||||
aqt_enable_clsh_block(struct snd_soc_component *component,
|
||||
struct aqt_clsh_cdc_data *clsh_d, bool enable)
|
||||
{
|
||||
if ((enable && ++clsh_d->clsh_users == 1) ||
|
||||
(!enable && --clsh_d->clsh_users == 0))
|
||||
snd_soc_update_bits(codec, AQT1000_CDC_CLSH_CRC, 0x01,
|
||||
(u8) enable);
|
||||
snd_soc_component_update_bits(component, AQT1000_CDC_CLSH_CRC,
|
||||
0x01, (u8) enable);
|
||||
if (clsh_d->clsh_users < 0)
|
||||
clsh_d->clsh_users = 0;
|
||||
dev_dbg(codec->dev, "%s: clsh_users %d, enable %d", __func__,
|
||||
dev_dbg(component->dev, "%s: clsh_users %d, enable %d", __func__,
|
||||
clsh_d->clsh_users, enable);
|
||||
}
|
||||
|
||||
static inline bool aqt_clsh_enable_status(struct snd_soc_codec *codec)
|
||||
static inline bool aqt_clsh_enable_status(struct snd_soc_component *component)
|
||||
{
|
||||
return snd_soc_read(codec, AQT1000_CDC_CLSH_CRC) & 0x01;
|
||||
return snd_soc_component_read32(
|
||||
component, AQT1000_CDC_CLSH_CRC) & 0x01;
|
||||
}
|
||||
|
||||
static inline int aqt_clsh_get_int_mode(struct aqt_clsh_cdc_data *clsh_d,
|
||||
@@ -284,87 +286,106 @@ static inline void aqt_clsh_set_int_mode(struct aqt_clsh_cdc_data *clsh_d,
|
||||
clsh_d->interpolator_modes[ffs(clsh_state)] = mode;
|
||||
}
|
||||
|
||||
static inline void aqt_clsh_set_buck_mode(struct snd_soc_codec *codec,
|
||||
static inline void aqt_clsh_set_buck_mode(struct snd_soc_component *component,
|
||||
int mode)
|
||||
{
|
||||
if (mode == CLS_H_HIFI || mode == CLS_H_LOHIFI ||
|
||||
mode == CLS_AB_HIFI || mode == CLS_AB)
|
||||
snd_soc_update_bits(codec, AQT1000_ANA_RX_SUPPLIES,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_ANA_RX_SUPPLIES,
|
||||
0x08, 0x08); /* set to HIFI */
|
||||
else
|
||||
snd_soc_update_bits(codec, AQT1000_ANA_RX_SUPPLIES,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_ANA_RX_SUPPLIES,
|
||||
0x08, 0x00); /* set to default */
|
||||
}
|
||||
|
||||
static inline void aqt_clsh_set_flyback_mode(struct snd_soc_codec *codec,
|
||||
int mode)
|
||||
static inline void aqt_clsh_set_flyback_mode(
|
||||
struct snd_soc_component *component, int mode)
|
||||
{
|
||||
if (mode == CLS_H_HIFI || mode == CLS_H_LOHIFI ||
|
||||
mode == CLS_AB_HIFI || mode == CLS_AB)
|
||||
snd_soc_update_bits(codec, AQT1000_ANA_RX_SUPPLIES,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_ANA_RX_SUPPLIES,
|
||||
0x04, 0x04); /* set to HIFI */
|
||||
else
|
||||
snd_soc_update_bits(codec, AQT1000_ANA_RX_SUPPLIES,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_ANA_RX_SUPPLIES,
|
||||
0x04, 0x00); /* set to Default */
|
||||
}
|
||||
|
||||
static inline void aqt_clsh_gm3_boost_disable(struct snd_soc_codec *codec,
|
||||
int mode)
|
||||
static inline void aqt_clsh_gm3_boost_disable(
|
||||
struct snd_soc_component *component, int mode)
|
||||
{
|
||||
if (mode == CLS_H_HIFI || mode == CLS_H_LOHIFI ||
|
||||
mode == CLS_AB_HIFI || mode == CLS_AB) {
|
||||
snd_soc_update_bits(codec, AQT1000_HPH_CNP_WG_CTL,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_HPH_CNP_WG_CTL,
|
||||
0x80, 0x0); /* disable GM3 Boost */
|
||||
snd_soc_update_bits(codec, AQT1000_FLYBACK_VNEG_CTRL_4,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_FLYBACK_VNEG_CTRL_4,
|
||||
0xF0, 0x80);
|
||||
} else {
|
||||
snd_soc_update_bits(codec, AQT1000_HPH_CNP_WG_CTL,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_HPH_CNP_WG_CTL,
|
||||
0x80, 0x80); /* set to Default */
|
||||
snd_soc_update_bits(codec, AQT1000_FLYBACK_VNEG_CTRL_4,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_FLYBACK_VNEG_CTRL_4,
|
||||
0xF0, 0x70);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void aqt_clsh_flyback_dac_ctl(struct snd_soc_codec *codec,
|
||||
int vref)
|
||||
static inline void aqt_clsh_flyback_dac_ctl(
|
||||
struct snd_soc_component *component, int vref)
|
||||
{
|
||||
snd_soc_update_bits(codec, AQT1000_FLYBACK_VNEGDAC_CTRL_2,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_FLYBACK_VNEGDAC_CTRL_2,
|
||||
0xE0, (vref << 5));
|
||||
}
|
||||
|
||||
static inline void aqt_clsh_mode_vref_ctl(struct snd_soc_codec *codec,
|
||||
static inline void aqt_clsh_mode_vref_ctl(struct snd_soc_component *component,
|
||||
int vref_ctl)
|
||||
{
|
||||
if (vref_ctl == I2C) {
|
||||
snd_soc_update_bits(codec, AQT1000_CLASSH_MODE_3, 0x02, 0x02);
|
||||
snd_soc_update_bits(codec, AQT1000_CLASSH_MODE_2, 0xFF, 0x1C);
|
||||
snd_soc_component_update_bits(component, AQT1000_CLASSH_MODE_3,
|
||||
0x02, 0x02);
|
||||
snd_soc_component_update_bits(component, AQT1000_CLASSH_MODE_2,
|
||||
0xFF, 0x1C);
|
||||
} else {
|
||||
snd_soc_update_bits(codec, AQT1000_CLASSH_MODE_2, 0xFF, 0x3A);
|
||||
snd_soc_update_bits(codec, AQT1000_CLASSH_MODE_3, 0x02, 0x00);
|
||||
snd_soc_component_update_bits(component, AQT1000_CLASSH_MODE_2,
|
||||
0xFF, 0x3A);
|
||||
snd_soc_component_update_bits(component, AQT1000_CLASSH_MODE_3,
|
||||
0x02, 0x00);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void aqt_clsh_buck_current_bias_ctl(struct snd_soc_codec *codec,
|
||||
bool enable)
|
||||
static inline void aqt_clsh_buck_current_bias_ctl(
|
||||
struct snd_soc_component *component, bool enable)
|
||||
{
|
||||
if (enable) {
|
||||
snd_soc_update_bits(codec, AQT1000_BUCK_5V_IBIAS_CTL_4,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_BUCK_5V_IBIAS_CTL_4,
|
||||
0x70, (I_2UA << 4));
|
||||
snd_soc_update_bits(codec, AQT1000_BUCK_5V_IBIAS_CTL_4,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_BUCK_5V_IBIAS_CTL_4,
|
||||
0x07, I_0P25UA);
|
||||
snd_soc_update_bits(codec, AQT1000_BUCK_5V_CTRL_CCL_2,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_BUCK_5V_CTRL_CCL_2,
|
||||
0x3F, 0x3F);
|
||||
} else {
|
||||
snd_soc_update_bits(codec, AQT1000_BUCK_5V_IBIAS_CTL_4,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_BUCK_5V_IBIAS_CTL_4,
|
||||
0x70, (I_1UA << 4));
|
||||
snd_soc_update_bits(codec, AQT1000_BUCK_5V_IBIAS_CTL_4,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_BUCK_5V_IBIAS_CTL_4,
|
||||
0x07, I_1UA);
|
||||
snd_soc_update_bits(codec, AQT1000_BUCK_5V_CTRL_CCL_2,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_BUCK_5V_CTRL_CCL_2,
|
||||
0x3F, 0x20);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void aqt_clsh_rdac_hd2_ctl(struct snd_soc_codec *codec,
|
||||
static inline void aqt_clsh_rdac_hd2_ctl(struct snd_soc_component *component,
|
||||
u8 hd2_div_ctl, u8 state)
|
||||
{
|
||||
u16 reg = 0;
|
||||
@@ -374,34 +395,41 @@ static inline void aqt_clsh_rdac_hd2_ctl(struct snd_soc_codec *codec,
|
||||
else if (state == AQT_CLSH_STATE_HPHR)
|
||||
reg = AQT1000_HPH_NEW_INT_RDAC_HD2_CTL_R;
|
||||
else
|
||||
dev_err(codec->dev, "%s: Invalid state: %d\n",
|
||||
dev_err(component->dev, "%s: Invalid state: %d\n",
|
||||
__func__, state);
|
||||
if (!reg)
|
||||
snd_soc_update_bits(codec, reg, 0x0F, hd2_div_ctl);
|
||||
snd_soc_component_update_bits(component, reg,
|
||||
0x0F, hd2_div_ctl);
|
||||
}
|
||||
|
||||
static inline void aqt_clsh_force_iq_ctl(struct snd_soc_codec *codec,
|
||||
static inline void aqt_clsh_force_iq_ctl(struct snd_soc_component *component,
|
||||
int mode)
|
||||
{
|
||||
if (mode == CLS_H_LOHIFI || mode == CLS_AB) {
|
||||
snd_soc_update_bits(codec, AQT1000_HPH_NEW_INT_PA_MISC2,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_HPH_NEW_INT_PA_MISC2,
|
||||
0x20, 0x20);
|
||||
snd_soc_update_bits(codec, AQT1000_RX_BIAS_HPH_LOWPOWER,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_RX_BIAS_HPH_LOWPOWER,
|
||||
0xF0, 0xC0);
|
||||
snd_soc_update_bits(codec, AQT1000_HPH_PA_CTL1,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_HPH_PA_CTL1,
|
||||
0x0E, 0x02);
|
||||
} else {
|
||||
|
||||
snd_soc_update_bits(codec, AQT1000_HPH_NEW_INT_PA_MISC2,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_HPH_NEW_INT_PA_MISC2,
|
||||
0x20, 0x0);
|
||||
snd_soc_update_bits(codec, AQT1000_RX_BIAS_HPH_LOWPOWER,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_RX_BIAS_HPH_LOWPOWER,
|
||||
0xF0, 0x80);
|
||||
snd_soc_update_bits(codec, AQT1000_HPH_PA_CTL1,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_HPH_PA_CTL1,
|
||||
0x0E, 0x06);
|
||||
}
|
||||
}
|
||||
|
||||
static void aqt_clsh_buck_ctrl(struct snd_soc_codec *codec,
|
||||
static void aqt_clsh_buck_ctrl(struct snd_soc_component *component,
|
||||
struct aqt_clsh_cdc_data *clsh_d,
|
||||
int mode,
|
||||
bool enable)
|
||||
@@ -409,9 +437,10 @@ static void aqt_clsh_buck_ctrl(struct snd_soc_codec *codec,
|
||||
/* enable/disable buck */
|
||||
if ((enable && (++clsh_d->buck_users == 1)) ||
|
||||
(!enable && (--clsh_d->buck_users == 0)))
|
||||
snd_soc_update_bits(codec, AQT1000_ANA_RX_SUPPLIES,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_ANA_RX_SUPPLIES,
|
||||
(1 << 7), (enable << 7));
|
||||
dev_dbg(codec->dev, "%s: buck_users %d, enable %d, mode: %s",
|
||||
dev_dbg(component->dev, "%s: buck_users %d, enable %d, mode: %s",
|
||||
__func__, clsh_d->buck_users, enable, mode_to_str(mode));
|
||||
/*
|
||||
* 500us sleep is required after buck enable/disable
|
||||
@@ -420,7 +449,7 @@ static void aqt_clsh_buck_ctrl(struct snd_soc_codec *codec,
|
||||
usleep_range(500, 500 + AQT_USLEEP_RANGE);
|
||||
}
|
||||
|
||||
static void aqt_clsh_flyback_ctrl(struct snd_soc_codec *codec,
|
||||
static void aqt_clsh_flyback_ctrl(struct snd_soc_component *component,
|
||||
struct aqt_clsh_cdc_data *clsh_d,
|
||||
int mode,
|
||||
bool enable)
|
||||
@@ -428,12 +457,13 @@ static void aqt_clsh_flyback_ctrl(struct snd_soc_codec *codec,
|
||||
/* enable/disable flyback */
|
||||
if ((enable && (++clsh_d->flyback_users == 1)) ||
|
||||
(!enable && (--clsh_d->flyback_users == 0))) {
|
||||
snd_soc_update_bits(codec, AQT1000_ANA_RX_SUPPLIES,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_ANA_RX_SUPPLIES,
|
||||
(1 << 6), (enable << 6));
|
||||
/* 100usec delay is needed as per HW requirement */
|
||||
usleep_range(100, 110);
|
||||
}
|
||||
dev_dbg(codec->dev, "%s: flyback_users %d, enable %d, mode: %s",
|
||||
dev_dbg(component->dev, "%s: flyback_users %d, enable %d, mode: %s",
|
||||
__func__, clsh_d->flyback_users, enable, mode_to_str(mode));
|
||||
/*
|
||||
* 500us sleep is required after flyback enable/disable
|
||||
@@ -442,7 +472,7 @@ static void aqt_clsh_flyback_ctrl(struct snd_soc_codec *codec,
|
||||
usleep_range(500, 500 + AQT_USLEEP_RANGE);
|
||||
}
|
||||
|
||||
static void aqt_clsh_set_hph_mode(struct snd_soc_codec *codec,
|
||||
static void aqt_clsh_set_hph_mode(struct snd_soc_component *component,
|
||||
int mode)
|
||||
{
|
||||
u8 val = 0;
|
||||
@@ -487,21 +517,22 @@ static void aqt_clsh_set_hph_mode(struct snd_soc_codec *codec,
|
||||
if (mode == CLS_H_LOHIFI || mode == CLS_AB)
|
||||
val = 0x04;
|
||||
|
||||
snd_soc_update_bits(codec, AQT1000_ANA_HPH, 0x0C, val);
|
||||
snd_soc_component_update_bits(component, AQT1000_ANA_HPH, 0x0C, val);
|
||||
}
|
||||
|
||||
static void aqt_clsh_set_buck_regulator_mode(struct snd_soc_codec *codec,
|
||||
int mode)
|
||||
static void aqt_clsh_set_buck_regulator_mode(
|
||||
struct snd_soc_component *component, int mode)
|
||||
{
|
||||
snd_soc_update_bits(codec, AQT1000_ANA_RX_SUPPLIES,
|
||||
snd_soc_component_update_bits(component, AQT1000_ANA_RX_SUPPLIES,
|
||||
0x02, 0x00);
|
||||
}
|
||||
|
||||
static void aqt_clsh_state_hph_st(struct snd_soc_codec *codec,
|
||||
static void aqt_clsh_state_hph_st(struct snd_soc_component *component,
|
||||
struct aqt_clsh_cdc_data *clsh_d,
|
||||
u8 req_state, bool is_enable, int mode)
|
||||
{
|
||||
dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode),
|
||||
dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__,
|
||||
mode_to_str(mode),
|
||||
is_enable ? "enable" : "disable");
|
||||
|
||||
if (mode == CLS_AB || mode == CLS_AB_HIFI)
|
||||
@@ -509,158 +540,163 @@ static void aqt_clsh_state_hph_st(struct snd_soc_codec *codec,
|
||||
|
||||
if (is_enable) {
|
||||
if (req_state == AQT_CLSH_STATE_HPHL)
|
||||
snd_soc_update_bits(codec,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_CDC_RX1_RX_PATH_CFG0,
|
||||
0x40, 0x40);
|
||||
if (req_state == AQT_CLSH_STATE_HPHR)
|
||||
snd_soc_update_bits(codec,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_CDC_RX2_RX_PATH_CFG0,
|
||||
0x40, 0x40);
|
||||
} else {
|
||||
if (req_state == AQT_CLSH_STATE_HPHL)
|
||||
snd_soc_update_bits(codec,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_CDC_RX1_RX_PATH_CFG0,
|
||||
0x40, 0x00);
|
||||
if (req_state == AQT_CLSH_STATE_HPHR)
|
||||
snd_soc_update_bits(codec,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_CDC_RX2_RX_PATH_CFG0,
|
||||
0x40, 0x00);
|
||||
}
|
||||
}
|
||||
|
||||
static void aqt_clsh_state_hph_r(struct snd_soc_codec *codec,
|
||||
static void aqt_clsh_state_hph_r(struct snd_soc_component *component,
|
||||
struct aqt_clsh_cdc_data *clsh_d,
|
||||
u8 req_state, bool is_enable, int mode)
|
||||
{
|
||||
dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode),
|
||||
dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__,
|
||||
mode_to_str(mode),
|
||||
is_enable ? "enable" : "disable");
|
||||
|
||||
if (mode == CLS_H_NORMAL) {
|
||||
dev_err(codec->dev, "%s: Normal mode not applicable for hph_r\n",
|
||||
dev_err(component->dev, "%s: Normal mode not applicable for hph_r\n",
|
||||
__func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_enable) {
|
||||
if (mode != CLS_AB && mode != CLS_AB_HIFI) {
|
||||
aqt_enable_clsh_block(codec, clsh_d, true);
|
||||
aqt_enable_clsh_block(component, clsh_d, true);
|
||||
/*
|
||||
* These K1 values depend on the Headphone Impedance
|
||||
* For now it is assumed to be 16 ohm
|
||||
*/
|
||||
snd_soc_update_bits(codec, AQT1000_CDC_CLSH_K1_MSB,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_CDC_CLSH_K1_MSB,
|
||||
0x0F, 0x00);
|
||||
snd_soc_update_bits(codec, AQT1000_CDC_CLSH_K1_LSB,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_CDC_CLSH_K1_LSB,
|
||||
0xFF, 0xC0);
|
||||
snd_soc_update_bits(codec,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_CDC_RX2_RX_PATH_CFG0,
|
||||
0x40, 0x40);
|
||||
}
|
||||
aqt_clsh_set_buck_regulator_mode(codec, mode);
|
||||
aqt_clsh_set_flyback_mode(codec, mode);
|
||||
aqt_clsh_gm3_boost_disable(codec, mode);
|
||||
aqt_clsh_flyback_dac_ctl(codec, VREF_N0P9V);
|
||||
aqt_clsh_mode_vref_ctl(codec, I2C);
|
||||
aqt_clsh_force_iq_ctl(codec, mode);
|
||||
aqt_clsh_rdac_hd2_ctl(codec, P82_0P77, req_state);
|
||||
aqt_clsh_flyback_ctrl(codec, clsh_d, mode, true);
|
||||
aqt_clsh_flyback_dac_ctl(codec, VREF_N1P827V);
|
||||
aqt_clsh_set_buck_mode(codec, mode);
|
||||
aqt_clsh_buck_ctrl(codec, clsh_d, mode, true);
|
||||
aqt_clsh_mode_vref_ctl(codec, CONTROLLER);
|
||||
aqt_clsh_buck_current_bias_ctl(codec, true);
|
||||
aqt_clsh_set_hph_mode(codec, mode);
|
||||
aqt_clsh_set_buck_regulator_mode(component, mode);
|
||||
aqt_clsh_set_flyback_mode(component, mode);
|
||||
aqt_clsh_gm3_boost_disable(component, mode);
|
||||
aqt_clsh_flyback_dac_ctl(component, VREF_N0P9V);
|
||||
aqt_clsh_mode_vref_ctl(component, I2C);
|
||||
aqt_clsh_force_iq_ctl(component, mode);
|
||||
aqt_clsh_rdac_hd2_ctl(component, P82_0P77, req_state);
|
||||
aqt_clsh_flyback_ctrl(component, clsh_d, mode, true);
|
||||
aqt_clsh_flyback_dac_ctl(component, VREF_N1P827V);
|
||||
aqt_clsh_set_buck_mode(component, mode);
|
||||
aqt_clsh_buck_ctrl(component, clsh_d, mode, true);
|
||||
aqt_clsh_mode_vref_ctl(component, CONTROLLER);
|
||||
aqt_clsh_buck_current_bias_ctl(component, true);
|
||||
aqt_clsh_set_hph_mode(component, mode);
|
||||
} else {
|
||||
aqt_clsh_set_hph_mode(codec, CLS_H_NORMAL);
|
||||
aqt_clsh_buck_current_bias_ctl(codec, false);
|
||||
aqt_clsh_set_hph_mode(component, CLS_H_NORMAL);
|
||||
aqt_clsh_buck_current_bias_ctl(component, false);
|
||||
|
||||
if (mode != CLS_AB && mode != CLS_AB_HIFI) {
|
||||
snd_soc_update_bits(codec,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_CDC_RX2_RX_PATH_CFG0,
|
||||
0x40, 0x00);
|
||||
aqt_enable_clsh_block(codec, clsh_d, false);
|
||||
aqt_enable_clsh_block(component, clsh_d, false);
|
||||
}
|
||||
/* buck and flyback set to default mode and disable */
|
||||
aqt_clsh_buck_ctrl(codec, clsh_d, CLS_H_NORMAL, false);
|
||||
aqt_clsh_flyback_ctrl(codec, clsh_d, CLS_H_NORMAL, false);
|
||||
aqt_clsh_rdac_hd2_ctl(codec, P5_0P35, req_state);
|
||||
aqt_clsh_force_iq_ctl(codec, CLS_H_NORMAL);
|
||||
aqt_clsh_gm3_boost_disable(codec, CLS_H_NORMAL);
|
||||
aqt_clsh_set_flyback_mode(codec, CLS_H_NORMAL);
|
||||
aqt_clsh_set_buck_mode(codec, CLS_H_NORMAL);
|
||||
aqt_clsh_set_buck_regulator_mode(codec, CLS_H_NORMAL);
|
||||
aqt_clsh_buck_ctrl(component, clsh_d, CLS_H_NORMAL, false);
|
||||
aqt_clsh_flyback_ctrl(component, clsh_d, CLS_H_NORMAL, false);
|
||||
aqt_clsh_rdac_hd2_ctl(component, P5_0P35, req_state);
|
||||
aqt_clsh_force_iq_ctl(component, CLS_H_NORMAL);
|
||||
aqt_clsh_gm3_boost_disable(component, CLS_H_NORMAL);
|
||||
aqt_clsh_set_flyback_mode(component, CLS_H_NORMAL);
|
||||
aqt_clsh_set_buck_mode(component, CLS_H_NORMAL);
|
||||
aqt_clsh_set_buck_regulator_mode(component, CLS_H_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
static void aqt_clsh_state_hph_l(struct snd_soc_codec *codec,
|
||||
static void aqt_clsh_state_hph_l(struct snd_soc_component *component,
|
||||
struct aqt_clsh_cdc_data *clsh_d,
|
||||
u8 req_state, bool is_enable, int mode)
|
||||
{
|
||||
dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode),
|
||||
is_enable ? "enable" : "disable");
|
||||
dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__,
|
||||
mode_to_str(mode), is_enable ? "enable" : "disable");
|
||||
|
||||
if (mode == CLS_H_NORMAL) {
|
||||
dev_err(codec->dev, "%s: Normal mode not applicable for hph_l\n",
|
||||
dev_err(component->dev, "%s: Normal mode not applicable for hph_l\n",
|
||||
__func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_enable) {
|
||||
if (mode != CLS_AB && mode != CLS_AB_HIFI) {
|
||||
aqt_enable_clsh_block(codec, clsh_d, true);
|
||||
aqt_enable_clsh_block(component, clsh_d, true);
|
||||
/*
|
||||
* These K1 values depend on the Headphone Impedance
|
||||
* For now it is assumed to be 16 ohm
|
||||
*/
|
||||
snd_soc_update_bits(codec, AQT1000_CDC_CLSH_K1_MSB,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_CDC_CLSH_K1_MSB,
|
||||
0x0F, 0x00);
|
||||
snd_soc_update_bits(codec, AQT1000_CDC_CLSH_K1_LSB,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_CDC_CLSH_K1_LSB,
|
||||
0xFF, 0xC0);
|
||||
snd_soc_update_bits(codec,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_CDC_RX1_RX_PATH_CFG0,
|
||||
0x40, 0x40);
|
||||
}
|
||||
aqt_clsh_set_buck_regulator_mode(codec, mode);
|
||||
aqt_clsh_set_flyback_mode(codec, mode);
|
||||
aqt_clsh_gm3_boost_disable(codec, mode);
|
||||
aqt_clsh_flyback_dac_ctl(codec, VREF_N0P9V);
|
||||
aqt_clsh_mode_vref_ctl(codec, I2C);
|
||||
aqt_clsh_force_iq_ctl(codec, mode);
|
||||
aqt_clsh_rdac_hd2_ctl(codec, P82_0P77, req_state);
|
||||
aqt_clsh_flyback_ctrl(codec, clsh_d, mode, true);
|
||||
aqt_clsh_flyback_dac_ctl(codec, VREF_N1P827V);
|
||||
aqt_clsh_set_buck_mode(codec, mode);
|
||||
aqt_clsh_buck_ctrl(codec, clsh_d, mode, true);
|
||||
aqt_clsh_mode_vref_ctl(codec, CONTROLLER);
|
||||
aqt_clsh_buck_current_bias_ctl(codec, true);
|
||||
aqt_clsh_set_hph_mode(codec, mode);
|
||||
aqt_clsh_set_buck_regulator_mode(component, mode);
|
||||
aqt_clsh_set_flyback_mode(component, mode);
|
||||
aqt_clsh_gm3_boost_disable(component, mode);
|
||||
aqt_clsh_flyback_dac_ctl(component, VREF_N0P9V);
|
||||
aqt_clsh_mode_vref_ctl(component, I2C);
|
||||
aqt_clsh_force_iq_ctl(component, mode);
|
||||
aqt_clsh_rdac_hd2_ctl(component, P82_0P77, req_state);
|
||||
aqt_clsh_flyback_ctrl(component, clsh_d, mode, true);
|
||||
aqt_clsh_flyback_dac_ctl(component, VREF_N1P827V);
|
||||
aqt_clsh_set_buck_mode(component, mode);
|
||||
aqt_clsh_buck_ctrl(component, clsh_d, mode, true);
|
||||
aqt_clsh_mode_vref_ctl(component, CONTROLLER);
|
||||
aqt_clsh_buck_current_bias_ctl(component, true);
|
||||
aqt_clsh_set_hph_mode(component, mode);
|
||||
} else {
|
||||
aqt_clsh_set_hph_mode(codec, CLS_H_NORMAL);
|
||||
aqt_clsh_buck_current_bias_ctl(codec, false);
|
||||
aqt_clsh_set_hph_mode(component, CLS_H_NORMAL);
|
||||
aqt_clsh_buck_current_bias_ctl(component, false);
|
||||
|
||||
if (mode != CLS_AB && mode != CLS_AB_HIFI) {
|
||||
snd_soc_update_bits(codec,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_CDC_RX1_RX_PATH_CFG0,
|
||||
0x40, 0x00);
|
||||
aqt_enable_clsh_block(codec, clsh_d, false);
|
||||
aqt_enable_clsh_block(component, clsh_d, false);
|
||||
}
|
||||
/* set buck and flyback to Default Mode */
|
||||
aqt_clsh_buck_ctrl(codec, clsh_d, CLS_H_NORMAL, false);
|
||||
aqt_clsh_flyback_ctrl(codec, clsh_d, CLS_H_NORMAL, false);
|
||||
aqt_clsh_rdac_hd2_ctl(codec, P5_0P35, req_state);
|
||||
aqt_clsh_force_iq_ctl(codec, CLS_H_NORMAL);
|
||||
aqt_clsh_gm3_boost_disable(codec, CLS_H_NORMAL);
|
||||
aqt_clsh_set_flyback_mode(codec, CLS_H_NORMAL);
|
||||
aqt_clsh_set_buck_mode(codec, CLS_H_NORMAL);
|
||||
aqt_clsh_set_buck_regulator_mode(codec, CLS_H_NORMAL);
|
||||
aqt_clsh_buck_ctrl(component, clsh_d, CLS_H_NORMAL, false);
|
||||
aqt_clsh_flyback_ctrl(component, clsh_d, CLS_H_NORMAL, false);
|
||||
aqt_clsh_rdac_hd2_ctl(component, P5_0P35, req_state);
|
||||
aqt_clsh_force_iq_ctl(component, CLS_H_NORMAL);
|
||||
aqt_clsh_gm3_boost_disable(component, CLS_H_NORMAL);
|
||||
aqt_clsh_set_flyback_mode(component, CLS_H_NORMAL);
|
||||
aqt_clsh_set_buck_mode(component, CLS_H_NORMAL);
|
||||
aqt_clsh_set_buck_regulator_mode(component, CLS_H_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
static void aqt_clsh_state_err(struct snd_soc_codec *codec,
|
||||
static void aqt_clsh_state_err(struct snd_soc_component *component,
|
||||
struct aqt_clsh_cdc_data *clsh_d,
|
||||
u8 req_state, bool is_enable, int mode)
|
||||
{
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s Wrong request for class H state machine requested to %s %s",
|
||||
__func__, is_enable ? "enable" : "disable",
|
||||
state_to_str[req_state]);
|
||||
@@ -687,14 +723,14 @@ static bool aqt_clsh_is_state_valid(u8 state)
|
||||
|
||||
/*
|
||||
* Function: aqt_clsh_fsm
|
||||
* Params: codec, cdc_clsh_d, req_state, req_type, clsh_event
|
||||
* Params: component, cdc_clsh_d, req_state, req_type, clsh_event
|
||||
* Description:
|
||||
* This function handles PRE DAC and POST DAC conditions of different devices
|
||||
* and updates class H configuration of different combination of devices
|
||||
* based on validity of their states. cdc_clsh_d will contain current
|
||||
* class h state information
|
||||
*/
|
||||
void aqt_clsh_fsm(struct snd_soc_codec *codec,
|
||||
void aqt_clsh_fsm(struct snd_soc_component *component,
|
||||
struct aqt_clsh_cdc_data *cdc_clsh_d,
|
||||
u8 clsh_event, u8 req_state,
|
||||
int int_mode)
|
||||
@@ -707,22 +743,22 @@ void aqt_clsh_fsm(struct snd_soc_codec *codec,
|
||||
new_state = old_state | req_state;
|
||||
|
||||
if (!aqt_clsh_is_state_valid(new_state)) {
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s: Class-H not a valid new state: %s\n",
|
||||
__func__, state_to_str[new_state]);
|
||||
return;
|
||||
}
|
||||
if (new_state == old_state) {
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s: Class-H already in requested state: %s\n",
|
||||
__func__, state_to_str[new_state]);
|
||||
return;
|
||||
}
|
||||
cdc_clsh_d->state = new_state;
|
||||
aqt_clsh_set_int_mode(cdc_clsh_d, req_state, int_mode);
|
||||
(*clsh_state_fp[new_state]) (codec, cdc_clsh_d, req_state,
|
||||
(*clsh_state_fp[new_state]) (component, cdc_clsh_d, req_state,
|
||||
CLSH_REQ_ENABLE, int_mode);
|
||||
dev_dbg(codec->dev,
|
||||
dev_dbg(component->dev,
|
||||
"%s: ClassH state transition from %s to %s\n",
|
||||
__func__, state_to_str[old_state],
|
||||
state_to_str[cdc_clsh_d->state]);
|
||||
@@ -732,23 +768,23 @@ void aqt_clsh_fsm(struct snd_soc_codec *codec,
|
||||
new_state = old_state & (~req_state);
|
||||
if (new_state < NUM_CLSH_STATES) {
|
||||
if (!aqt_clsh_is_state_valid(old_state)) {
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s:Invalid old state:%s\n",
|
||||
__func__, state_to_str[old_state]);
|
||||
return;
|
||||
}
|
||||
if (new_state == old_state) {
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s: Class-H already in requested state: %s\n",
|
||||
__func__,state_to_str[new_state]);
|
||||
return;
|
||||
}
|
||||
(*clsh_state_fp[old_state]) (codec, cdc_clsh_d,
|
||||
(*clsh_state_fp[old_state]) (component, cdc_clsh_d,
|
||||
req_state, CLSH_REQ_DISABLE,
|
||||
int_mode);
|
||||
cdc_clsh_d->state = new_state;
|
||||
aqt_clsh_set_int_mode(cdc_clsh_d, req_state, CLS_NONE);
|
||||
dev_dbg(codec->dev, "%s: ClassH state transition from %s to %s\n",
|
||||
dev_dbg(component->dev, "%s: ClassH state transition from %s to %s\n",
|
||||
__func__, state_to_str[old_state],
|
||||
state_to_str[cdc_clsh_d->state]);
|
||||
}
|
||||
|
@@ -94,14 +94,14 @@ struct aqt_reg_mask_val {
|
||||
u8 val;
|
||||
};
|
||||
|
||||
extern void aqt_clsh_fsm(struct snd_soc_codec *codec,
|
||||
extern void aqt_clsh_fsm(struct snd_soc_component *component,
|
||||
struct aqt_clsh_cdc_data *cdc_clsh_d,
|
||||
u8 clsh_event, u8 req_state,
|
||||
int int_mode);
|
||||
|
||||
extern void aqt_clsh_init(struct aqt_clsh_cdc_data *clsh);
|
||||
extern int aqt_clsh_get_clsh_state(struct aqt_clsh_cdc_data *clsh);
|
||||
extern void aqt_clsh_imped_config(struct snd_soc_codec *codec, int imped,
|
||||
bool reset);
|
||||
extern void aqt_clsh_imped_config(struct snd_soc_component *component,
|
||||
int imped, bool reset);
|
||||
|
||||
#endif /* _AQT1000_CLSH_H */
|
||||
|
@@ -154,6 +154,7 @@ static struct irq_chip aqt_irq_chip = {
|
||||
};
|
||||
|
||||
static struct lock_class_key aqt_irq_lock_class;
|
||||
static struct lock_class_key aqt_irq_lock_requested_class;
|
||||
|
||||
static int aqt_irq_map(struct irq_domain *irqd, unsigned int virq,
|
||||
irq_hw_number_t hw)
|
||||
@@ -162,7 +163,8 @@ static int aqt_irq_map(struct irq_domain *irqd, unsigned int virq,
|
||||
|
||||
irq_set_chip_data(virq, data);
|
||||
irq_set_chip_and_handler(virq, &aqt_irq_chip, handle_simple_irq);
|
||||
irq_set_lockdep_class(virq, &aqt_irq_lock_class);
|
||||
irq_set_lockdep_class(virq, &aqt_irq_lock_class,
|
||||
&aqt_irq_lock_requested_class);
|
||||
irq_set_nested_thread(virq, 1);
|
||||
irq_set_noprobe(virq);
|
||||
|
||||
|
@@ -153,19 +153,19 @@ struct aqt_mbhc_zdet_param {
|
||||
u16 btn7;
|
||||
};
|
||||
|
||||
static int aqt_mbhc_request_irq(struct snd_soc_codec *codec,
|
||||
static int aqt_mbhc_request_irq(struct snd_soc_component *component,
|
||||
int irq, irq_handler_t handler,
|
||||
const char *name, void *data)
|
||||
{
|
||||
struct aqt1000 *aqt = dev_get_drvdata(codec->dev);
|
||||
struct aqt1000 *aqt = dev_get_drvdata(component->dev);
|
||||
|
||||
return aqt_request_irq(aqt, irq, name, handler, data);
|
||||
}
|
||||
|
||||
static void aqt_mbhc_irq_control(struct snd_soc_codec *codec,
|
||||
static void aqt_mbhc_irq_control(struct snd_soc_component *component,
|
||||
int irq, bool enable)
|
||||
{
|
||||
struct aqt1000 *aqt = dev_get_drvdata(codec->dev);
|
||||
struct aqt1000 *aqt = dev_get_drvdata(component->dev);
|
||||
|
||||
if (enable)
|
||||
aqt_enable_irq(aqt, irq);
|
||||
@@ -173,44 +173,49 @@ static void aqt_mbhc_irq_control(struct snd_soc_codec *codec,
|
||||
aqt_disable_irq(aqt, irq);
|
||||
}
|
||||
|
||||
static int aqt_mbhc_free_irq(struct snd_soc_codec *codec,
|
||||
static int aqt_mbhc_free_irq(struct snd_soc_component *component,
|
||||
int irq, void *data)
|
||||
{
|
||||
struct aqt1000 *aqt = dev_get_drvdata(codec->dev);
|
||||
struct aqt1000 *aqt = dev_get_drvdata(component->dev);
|
||||
|
||||
aqt_free_irq(aqt, irq, data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void aqt_mbhc_clk_setup(struct snd_soc_codec *codec,
|
||||
static void aqt_mbhc_clk_setup(struct snd_soc_component *component,
|
||||
bool enable)
|
||||
{
|
||||
if (enable)
|
||||
snd_soc_update_bits(codec, AQT1000_MBHC_NEW_CTL_1,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_MBHC_NEW_CTL_1,
|
||||
0x80, 0x80);
|
||||
else
|
||||
snd_soc_update_bits(codec, AQT1000_MBHC_NEW_CTL_1,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_MBHC_NEW_CTL_1,
|
||||
0x80, 0x00);
|
||||
}
|
||||
|
||||
static int aqt_mbhc_btn_to_num(struct snd_soc_codec *codec)
|
||||
static int aqt_mbhc_btn_to_num(struct snd_soc_component *component)
|
||||
{
|
||||
return snd_soc_read(codec, AQT1000_ANA_MBHC_RESULT_3) & 0x7;
|
||||
return snd_soc_component_read32(component,
|
||||
AQT1000_ANA_MBHC_RESULT_3) & 0x7;
|
||||
}
|
||||
|
||||
static void aqt_mbhc_mbhc_bias_control(struct snd_soc_codec *codec,
|
||||
static void aqt_mbhc_mbhc_bias_control(struct snd_soc_component *component,
|
||||
bool enable)
|
||||
{
|
||||
if (enable)
|
||||
snd_soc_update_bits(codec, AQT1000_ANA_MBHC_ELECT,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_ANA_MBHC_ELECT,
|
||||
0x01, 0x01);
|
||||
else
|
||||
snd_soc_update_bits(codec, AQT1000_ANA_MBHC_ELECT,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_ANA_MBHC_ELECT,
|
||||
0x01, 0x00);
|
||||
}
|
||||
|
||||
static void aqt_mbhc_program_btn_thr(struct snd_soc_codec *codec,
|
||||
static void aqt_mbhc_program_btn_thr(struct snd_soc_component *component,
|
||||
s16 *btn_low, s16 *btn_high,
|
||||
int num_btn, bool is_micbias)
|
||||
{
|
||||
@@ -218,24 +223,25 @@ static void aqt_mbhc_program_btn_thr(struct snd_soc_codec *codec,
|
||||
int vth;
|
||||
|
||||
if (num_btn > WCD_MBHC_DEF_BUTTONS) {
|
||||
dev_err(codec->dev, "%s: invalid number of buttons: %d\n",
|
||||
dev_err(component->dev, "%s: invalid number of buttons: %d\n",
|
||||
__func__, num_btn);
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < num_btn; i++) {
|
||||
vth = ((btn_high[i] * 2) / 25) & 0x3F;
|
||||
snd_soc_update_bits(codec, AQT1000_ANA_MBHC_BTN0 + i,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_ANA_MBHC_BTN0 + i,
|
||||
0xFC, vth << 2);
|
||||
dev_dbg(codec->dev, "%s: btn_high[%d]: %d, vth: %d\n",
|
||||
dev_dbg(component->dev, "%s: btn_high[%d]: %d, vth: %d\n",
|
||||
__func__, i, btn_high[i], vth);
|
||||
}
|
||||
}
|
||||
|
||||
static bool aqt_mbhc_lock_sleep(struct wcd_mbhc *mbhc, bool lock)
|
||||
{
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct aqt1000 *aqt = dev_get_drvdata(codec->dev);
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
struct aqt1000 *aqt = dev_get_drvdata(component->dev);
|
||||
bool ret = 0;
|
||||
|
||||
dev_dbg(aqt->dev, "%s: lock: %d\n", __func__, lock);
|
||||
@@ -264,7 +270,8 @@ static bool aqt_mbhc_micb_en_status(struct wcd_mbhc *mbhc, int micb_num)
|
||||
u8 val;
|
||||
|
||||
if (micb_num == MIC_BIAS_1) {
|
||||
val = ((snd_soc_read(mbhc->codec, AQT1000_ANA_MICB1) & 0xC0)
|
||||
val = ((snd_soc_component_read32(
|
||||
mbhc->component, AQT1000_ANA_MICB1) & 0xC0)
|
||||
>> 6);
|
||||
if (val == 0x01)
|
||||
return true;
|
||||
@@ -272,12 +279,13 @@ static bool aqt_mbhc_micb_en_status(struct wcd_mbhc *mbhc, int micb_num)
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool aqt_mbhc_hph_pa_on_status(struct snd_soc_codec *codec)
|
||||
static bool aqt_mbhc_hph_pa_on_status(struct snd_soc_component *component)
|
||||
{
|
||||
return (snd_soc_read(codec, AQT1000_ANA_HPH) & 0xC0) ? true : false;
|
||||
return (snd_soc_component_read32(component, AQT1000_ANA_HPH) & 0xC0) ?
|
||||
true : false;
|
||||
}
|
||||
|
||||
static void aqt_mbhc_hph_l_pull_up_control(struct snd_soc_codec *codec,
|
||||
static void aqt_mbhc_hph_l_pull_up_control(struct snd_soc_component *component,
|
||||
int pull_up_cur)
|
||||
{
|
||||
/* Default pull up current to 2uA */
|
||||
@@ -285,14 +293,15 @@ static void aqt_mbhc_hph_l_pull_up_control(struct snd_soc_codec *codec,
|
||||
pull_up_cur == HS_PULLUP_I_DEFAULT)
|
||||
pull_up_cur = HS_PULLUP_I_2P0_UA;
|
||||
|
||||
dev_dbg(codec->dev, "%s: HS pull up current:%d\n",
|
||||
dev_dbg(component->dev, "%s: HS pull up current:%d\n",
|
||||
__func__, pull_up_cur);
|
||||
|
||||
snd_soc_update_bits(codec, AQT1000_MBHC_NEW_INT_MECH_DET_CURRENT,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_MBHC_NEW_INT_MECH_DET_CURRENT,
|
||||
0x1F, pull_up_cur);
|
||||
}
|
||||
|
||||
static int aqt_mbhc_request_micbias(struct snd_soc_codec *codec,
|
||||
static int aqt_mbhc_request_micbias(struct snd_soc_component *component,
|
||||
int micb_num, int req)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -302,32 +311,36 @@ static int aqt_mbhc_request_micbias(struct snd_soc_codec *codec,
|
||||
* is vote to enable mclk
|
||||
*/
|
||||
if (req == MICB_ENABLE)
|
||||
aqt_cdc_mclk_enable(codec, true);
|
||||
aqt_cdc_mclk_enable(component, true);
|
||||
|
||||
ret = aqt_micbias_control(codec, micb_num, req, false);
|
||||
ret = aqt_micbias_control(component, micb_num, req, false);
|
||||
|
||||
/*
|
||||
* Release vote for mclk while requesting for
|
||||
* micbias disable
|
||||
*/
|
||||
if (req == MICB_DISABLE)
|
||||
aqt_cdc_mclk_enable(codec, false);
|
||||
aqt_cdc_mclk_enable(component, false);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void aqt_mbhc_micb_ramp_control(struct snd_soc_codec *codec,
|
||||
static void aqt_mbhc_micb_ramp_control(struct snd_soc_component *component,
|
||||
bool enable)
|
||||
{
|
||||
if (enable) {
|
||||
snd_soc_update_bits(codec, AQT1000_ANA_MICB1_RAMP,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_ANA_MICB1_RAMP,
|
||||
0x1C, 0x0C);
|
||||
snd_soc_update_bits(codec, AQT1000_ANA_MICB1_RAMP,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_ANA_MICB1_RAMP,
|
||||
0x80, 0x80);
|
||||
} else {
|
||||
snd_soc_update_bits(codec, AQT1000_ANA_MICB1_RAMP,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_ANA_MICB1_RAMP,
|
||||
0x80, 0x00);
|
||||
snd_soc_update_bits(codec, AQT1000_ANA_MICB1_RAMP,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_ANA_MICB1_RAMP,
|
||||
0x1C, 0x00);
|
||||
}
|
||||
}
|
||||
@@ -337,26 +350,27 @@ static struct firmware_cal *aqt_get_hwdep_fw_cal(struct wcd_mbhc *mbhc,
|
||||
{
|
||||
struct aqt1000_mbhc *aqt_mbhc;
|
||||
struct firmware_cal *hwdep_cal;
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
|
||||
aqt_mbhc = container_of(mbhc, struct aqt1000_mbhc, wcd_mbhc);
|
||||
|
||||
if (!codec) {
|
||||
if (!component) {
|
||||
pr_err("%s: NULL codec pointer\n", __func__);
|
||||
return NULL;
|
||||
}
|
||||
hwdep_cal = wcdcal_get_fw_cal(aqt_mbhc->fw_data, type);
|
||||
if (!hwdep_cal)
|
||||
dev_err(codec->dev, "%s: cal not sent by %d\n",
|
||||
dev_err(component->dev, "%s: cal not sent by %d\n",
|
||||
__func__, type);
|
||||
|
||||
return hwdep_cal;
|
||||
}
|
||||
|
||||
static int aqt_mbhc_micb_ctrl_threshold_mic(struct snd_soc_codec *codec,
|
||||
static int aqt_mbhc_micb_ctrl_threshold_mic(
|
||||
struct snd_soc_component *component,
|
||||
int micb_num, bool req_en)
|
||||
{
|
||||
struct aqt1000_pdata *pdata = dev_get_platdata(codec->dev);
|
||||
struct aqt1000_pdata *pdata = dev_get_platdata(component->dev);
|
||||
int rc, micb_mv;
|
||||
|
||||
if (micb_num != MIC_BIAS_1)
|
||||
@@ -372,7 +386,7 @@ static int aqt_mbhc_micb_ctrl_threshold_mic(struct snd_soc_codec *codec,
|
||||
|
||||
micb_mv = req_en ? WCD_MBHC_THR_HS_MICB_MV : pdata->micbias.micb1_mv;
|
||||
|
||||
rc = aqt_mbhc_micb_adjust_voltage(codec, micb_mv, MIC_BIAS_1);
|
||||
rc = aqt_mbhc_micb_adjust_voltage(component, micb_mv, MIC_BIAS_1);
|
||||
|
||||
return rc;
|
||||
}
|
||||
@@ -433,25 +447,26 @@ ramp_down:
|
||||
}
|
||||
}
|
||||
|
||||
static void aqt_mbhc_zdet_ramp(struct snd_soc_codec *codec,
|
||||
static void aqt_mbhc_zdet_ramp(struct snd_soc_component *component,
|
||||
struct aqt_mbhc_zdet_param *zdet_param,
|
||||
int32_t *zl, int32_t *zr, s16 *d1_a)
|
||||
{
|
||||
struct aqt1000 *aqt = dev_get_drvdata(codec->dev);
|
||||
struct aqt1000 *aqt = dev_get_drvdata(component->dev);
|
||||
int32_t zdet = 0;
|
||||
|
||||
snd_soc_update_bits(codec, AQT1000_MBHC_NEW_ZDET_ANA_CTL, 0x70,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_MBHC_NEW_ZDET_ANA_CTL, 0x70,
|
||||
zdet_param->ldo_ctl << 4);
|
||||
snd_soc_update_bits(codec, AQT1000_ANA_MBHC_BTN5, 0xFC,
|
||||
zdet_param->btn5);
|
||||
snd_soc_update_bits(codec, AQT1000_ANA_MBHC_BTN6, 0xFC,
|
||||
zdet_param->btn6);
|
||||
snd_soc_update_bits(codec, AQT1000_ANA_MBHC_BTN7, 0xFC,
|
||||
zdet_param->btn7);
|
||||
snd_soc_update_bits(codec, AQT1000_MBHC_NEW_ZDET_ANA_CTL, 0x0F,
|
||||
zdet_param->noff);
|
||||
snd_soc_update_bits(codec, AQT1000_MBHC_NEW_ZDET_RAMP_CTL, 0x0F,
|
||||
zdet_param->nshift);
|
||||
snd_soc_component_update_bits(component, AQT1000_ANA_MBHC_BTN5,
|
||||
0xFC, zdet_param->btn5);
|
||||
snd_soc_component_update_bits(component, AQT1000_ANA_MBHC_BTN6,
|
||||
0xFC, zdet_param->btn6);
|
||||
snd_soc_component_update_bits(component, AQT1000_ANA_MBHC_BTN7,
|
||||
0xFC, zdet_param->btn7);
|
||||
snd_soc_component_update_bits(component, AQT1000_MBHC_NEW_ZDET_ANA_CTL,
|
||||
0x0F, zdet_param->noff);
|
||||
snd_soc_component_update_bits(component, AQT1000_MBHC_NEW_ZDET_RAMP_CTL,
|
||||
0x0F, zdet_param->nshift);
|
||||
|
||||
if (!zl)
|
||||
goto z_right;
|
||||
@@ -481,17 +496,17 @@ z_right:
|
||||
*zr = zdet;
|
||||
}
|
||||
|
||||
static inline void aqt_wcd_mbhc_qfuse_cal(struct snd_soc_codec *codec,
|
||||
static inline void aqt_wcd_mbhc_qfuse_cal(struct snd_soc_component *component,
|
||||
int32_t *z_val, int flag_l_r)
|
||||
{
|
||||
s16 q1;
|
||||
int q1_cal;
|
||||
|
||||
if (*z_val < (AQT_ZDET_VAL_400/1000))
|
||||
q1 = snd_soc_read(codec,
|
||||
q1 = snd_soc_component_read32(component,
|
||||
AQT1000_CHIP_CFG0_EFUSE_VAL_OUT1 + (2 * flag_l_r));
|
||||
else
|
||||
q1 = snd_soc_read(codec,
|
||||
q1 = snd_soc_component_read32(component,
|
||||
AQT1000_CHIP_CFG0_EFUSE_VAL_OUT2 + (2 * flag_l_r));
|
||||
if (q1 & 0x80)
|
||||
q1_cal = (10000 - ((q1 & 0x7F) * 25));
|
||||
@@ -504,8 +519,8 @@ static inline void aqt_wcd_mbhc_qfuse_cal(struct snd_soc_codec *codec,
|
||||
static void aqt_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl,
|
||||
uint32_t *zr)
|
||||
{
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct aqt1000 *aqt = dev_get_drvdata(codec->dev);
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
struct aqt1000 *aqt = dev_get_drvdata(component->dev);
|
||||
s16 reg0, reg1, reg2, reg3, reg4;
|
||||
int32_t z1L, z1R, z1Ls;
|
||||
int zMono, z_diff1, z_diff2;
|
||||
@@ -527,13 +542,15 @@ static void aqt_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl,
|
||||
|
||||
WCD_MBHC_RSC_ASSERT_LOCKED(mbhc);
|
||||
|
||||
reg0 = snd_soc_read(codec, AQT1000_ANA_MBHC_BTN5);
|
||||
reg1 = snd_soc_read(codec, AQT1000_ANA_MBHC_BTN6);
|
||||
reg2 = snd_soc_read(codec, AQT1000_ANA_MBHC_BTN7);
|
||||
reg3 = snd_soc_read(codec, AQT1000_MBHC_CTL_CLK);
|
||||
reg4 = snd_soc_read(codec, AQT1000_MBHC_NEW_ZDET_ANA_CTL);
|
||||
reg0 = snd_soc_component_read32(component, AQT1000_ANA_MBHC_BTN5);
|
||||
reg1 = snd_soc_component_read32(component, AQT1000_ANA_MBHC_BTN6);
|
||||
reg2 = snd_soc_component_read32(component, AQT1000_ANA_MBHC_BTN7);
|
||||
reg3 = snd_soc_component_read32(component, AQT1000_MBHC_CTL_CLK);
|
||||
reg4 = snd_soc_component_read32(component,
|
||||
AQT1000_MBHC_NEW_ZDET_ANA_CTL);
|
||||
|
||||
if (snd_soc_read(codec, AQT1000_ANA_MBHC_ELECT) & 0x80) {
|
||||
if (snd_soc_component_read32(component,
|
||||
AQT1000_ANA_MBHC_ELECT) & 0x80) {
|
||||
is_fsm_disable = true;
|
||||
regmap_update_bits(aqt->regmap,
|
||||
AQT1000_ANA_MBHC_ELECT, 0x80, 0x00);
|
||||
@@ -551,7 +568,7 @@ static void aqt_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl,
|
||||
/* First get impedance on Left */
|
||||
d1 = d1_a[1];
|
||||
zdet_param_ptr = &zdet_param[1];
|
||||
aqt_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1);
|
||||
aqt_mbhc_zdet_ramp(component, zdet_param_ptr, &z1L, NULL, d1);
|
||||
|
||||
if (!AQT_MBHC_IS_SECOND_RAMP_REQUIRED(z1L))
|
||||
goto left_ch_impedance;
|
||||
@@ -567,7 +584,7 @@ static void aqt_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl,
|
||||
zdet_param_ptr = &zdet_param[3];
|
||||
d1 = d1_a[3];
|
||||
}
|
||||
aqt_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1);
|
||||
aqt_mbhc_zdet_ramp(component, zdet_param_ptr, &z1L, NULL, d1);
|
||||
|
||||
left_ch_impedance:
|
||||
if ((z1L == AQT_ZDET_FLOATING_IMPEDANCE) ||
|
||||
@@ -577,13 +594,13 @@ left_ch_impedance:
|
||||
d1 = d1_a[1];
|
||||
} else {
|
||||
*zl = z1L/1000;
|
||||
aqt_wcd_mbhc_qfuse_cal(codec, zl, 0);
|
||||
aqt_wcd_mbhc_qfuse_cal(component, zl, 0);
|
||||
}
|
||||
dev_dbg(codec->dev, "%s: impedance on HPH_L = %d(ohms)\n",
|
||||
dev_dbg(component->dev, "%s: impedance on HPH_L = %d(ohms)\n",
|
||||
__func__, *zl);
|
||||
|
||||
/* Start of right impedance ramp and calculation */
|
||||
aqt_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1);
|
||||
aqt_mbhc_zdet_ramp(component, zdet_param_ptr, NULL, &z1R, d1);
|
||||
if (AQT_MBHC_IS_SECOND_RAMP_REQUIRED(z1R)) {
|
||||
if (((z1R > AQT_ZDET_VAL_1200) &&
|
||||
(zdet_param_ptr->noff == 0x6)) ||
|
||||
@@ -601,7 +618,7 @@ left_ch_impedance:
|
||||
zdet_param_ptr = &zdet_param[3];
|
||||
d1 = d1_a[3];
|
||||
}
|
||||
aqt_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1);
|
||||
aqt_mbhc_zdet_ramp(component, zdet_param_ptr, NULL, &z1R, d1);
|
||||
}
|
||||
right_ch_impedance:
|
||||
if ((z1R == AQT_ZDET_FLOATING_IMPEDANCE) ||
|
||||
@@ -609,15 +626,15 @@ right_ch_impedance:
|
||||
*zr = AQT_ZDET_FLOATING_IMPEDANCE;
|
||||
} else {
|
||||
*zr = z1R/1000;
|
||||
aqt_wcd_mbhc_qfuse_cal(codec, zr, 1);
|
||||
aqt_wcd_mbhc_qfuse_cal(component, zr, 1);
|
||||
}
|
||||
dev_dbg(codec->dev, "%s: impedance on HPH_R = %d(ohms)\n",
|
||||
dev_dbg(component->dev, "%s: impedance on HPH_R = %d(ohms)\n",
|
||||
__func__, *zr);
|
||||
|
||||
/* Mono/stereo detection */
|
||||
if ((*zl == AQT_ZDET_FLOATING_IMPEDANCE) &&
|
||||
(*zr == AQT_ZDET_FLOATING_IMPEDANCE)) {
|
||||
dev_dbg(codec->dev,
|
||||
dev_dbg(component->dev,
|
||||
"%s: plug type is invalid or extension cable\n",
|
||||
__func__);
|
||||
goto zdet_complete;
|
||||
@@ -626,40 +643,44 @@ right_ch_impedance:
|
||||
(*zr == AQT_ZDET_FLOATING_IMPEDANCE) ||
|
||||
((*zl < WCD_MONO_HS_MIN_THR) && (*zr > WCD_MONO_HS_MIN_THR)) ||
|
||||
((*zl > WCD_MONO_HS_MIN_THR) && (*zr < WCD_MONO_HS_MIN_THR))) {
|
||||
dev_dbg(codec->dev,
|
||||
dev_dbg(component->dev,
|
||||
"%s: Mono plug type with one ch floating or shorted to GND\n",
|
||||
__func__);
|
||||
mbhc->hph_type = WCD_MBHC_HPH_MONO;
|
||||
goto zdet_complete;
|
||||
}
|
||||
snd_soc_update_bits(codec, AQT1000_HPH_R_ATEST, 0x02, 0x02);
|
||||
snd_soc_update_bits(codec, AQT1000_HPH_PA_CTL2, 0x40, 0x01);
|
||||
snd_soc_component_update_bits(component, AQT1000_HPH_R_ATEST,
|
||||
0x02, 0x02);
|
||||
snd_soc_component_update_bits(component, AQT1000_HPH_PA_CTL2,
|
||||
0x40, 0x01);
|
||||
if (*zl < (AQT_ZDET_VAL_32/1000))
|
||||
aqt_mbhc_zdet_ramp(codec, &zdet_param[0], &z1Ls, NULL, d1);
|
||||
aqt_mbhc_zdet_ramp(component, &zdet_param[0], &z1Ls, NULL, d1);
|
||||
else
|
||||
aqt_mbhc_zdet_ramp(codec, &zdet_param[1], &z1Ls, NULL, d1);
|
||||
snd_soc_update_bits(codec, AQT1000_HPH_PA_CTL2, 0x40, 0x00);
|
||||
snd_soc_update_bits(codec, AQT1000_HPH_R_ATEST, 0x02, 0x00);
|
||||
aqt_mbhc_zdet_ramp(component, &zdet_param[1], &z1Ls, NULL, d1);
|
||||
snd_soc_component_update_bits(component, AQT1000_HPH_PA_CTL2,
|
||||
0x40, 0x00);
|
||||
snd_soc_component_update_bits(component, AQT1000_HPH_R_ATEST,
|
||||
0x02, 0x00);
|
||||
z1Ls /= 1000;
|
||||
aqt_wcd_mbhc_qfuse_cal(codec, &z1Ls, 0);
|
||||
aqt_wcd_mbhc_qfuse_cal(component, &z1Ls, 0);
|
||||
/* Parallel of left Z and 9 ohm pull down resistor */
|
||||
zMono = ((*zl) * 9) / ((*zl) + 9);
|
||||
z_diff1 = (z1Ls > zMono) ? (z1Ls - zMono) : (zMono - z1Ls);
|
||||
z_diff2 = ((*zl) > z1Ls) ? ((*zl) - z1Ls) : (z1Ls - (*zl));
|
||||
if ((z_diff1 * (*zl + z1Ls)) > (z_diff2 * (z1Ls + zMono))) {
|
||||
dev_dbg(codec->dev, "%s: stereo plug type detected\n",
|
||||
dev_dbg(component->dev, "%s: stereo plug type detected\n",
|
||||
__func__);
|
||||
mbhc->hph_type = WCD_MBHC_HPH_STEREO;
|
||||
} else {
|
||||
dev_dbg(codec->dev, "%s: MONO plug type detected\n",
|
||||
dev_dbg(component->dev, "%s: MONO plug type detected\n",
|
||||
__func__);
|
||||
mbhc->hph_type = WCD_MBHC_HPH_MONO;
|
||||
}
|
||||
|
||||
zdet_complete:
|
||||
snd_soc_write(codec, AQT1000_ANA_MBHC_BTN5, reg0);
|
||||
snd_soc_write(codec, AQT1000_ANA_MBHC_BTN6, reg1);
|
||||
snd_soc_write(codec, AQT1000_ANA_MBHC_BTN7, reg2);
|
||||
snd_soc_component_write(component, AQT1000_ANA_MBHC_BTN5, reg0);
|
||||
snd_soc_component_write(component, AQT1000_ANA_MBHC_BTN6, reg1);
|
||||
snd_soc_component_write(component, AQT1000_ANA_MBHC_BTN7, reg2);
|
||||
/* Turn on 100k pull down on HPHL */
|
||||
regmap_update_bits(aqt->regmap,
|
||||
AQT1000_ANA_MBHC_MECH, 0x01, 0x01);
|
||||
@@ -669,77 +690,83 @@ zdet_complete:
|
||||
regmap_update_bits(aqt->regmap,
|
||||
AQT1000_ANA_MBHC_MECH, 0x80, 0x80);
|
||||
|
||||
snd_soc_write(codec, AQT1000_MBHC_NEW_ZDET_ANA_CTL, reg4);
|
||||
snd_soc_write(codec, AQT1000_MBHC_CTL_CLK, reg3);
|
||||
snd_soc_component_write(component, AQT1000_MBHC_NEW_ZDET_ANA_CTL,
|
||||
reg4);
|
||||
snd_soc_component_write(component, AQT1000_MBHC_CTL_CLK, reg3);
|
||||
if (is_fsm_disable)
|
||||
regmap_update_bits(aqt->regmap,
|
||||
AQT1000_ANA_MBHC_ELECT, 0x80, 0x80);
|
||||
}
|
||||
|
||||
static void aqt_mbhc_gnd_det_ctrl(struct snd_soc_codec *codec, bool enable)
|
||||
static void aqt_mbhc_gnd_det_ctrl(struct snd_soc_component *component,
|
||||
bool enable)
|
||||
{
|
||||
if (enable) {
|
||||
snd_soc_update_bits(codec, AQT1000_ANA_MBHC_MECH,
|
||||
snd_soc_component_update_bits(component, AQT1000_ANA_MBHC_MECH,
|
||||
0x02, 0x02);
|
||||
snd_soc_update_bits(codec, AQT1000_ANA_MBHC_MECH,
|
||||
snd_soc_component_update_bits(component, AQT1000_ANA_MBHC_MECH,
|
||||
0x40, 0x40);
|
||||
} else {
|
||||
snd_soc_update_bits(codec, AQT1000_ANA_MBHC_MECH,
|
||||
snd_soc_component_update_bits(component, AQT1000_ANA_MBHC_MECH,
|
||||
0x40, 0x00);
|
||||
snd_soc_update_bits(codec, AQT1000_ANA_MBHC_MECH,
|
||||
snd_soc_component_update_bits(component, AQT1000_ANA_MBHC_MECH,
|
||||
0x02, 0x00);
|
||||
}
|
||||
}
|
||||
|
||||
static void aqt_mbhc_hph_pull_down_ctrl(struct snd_soc_codec *codec,
|
||||
static void aqt_mbhc_hph_pull_down_ctrl(struct snd_soc_component *component,
|
||||
bool enable)
|
||||
{
|
||||
if (enable) {
|
||||
snd_soc_update_bits(codec, AQT1000_HPH_PA_CTL2,
|
||||
snd_soc_component_update_bits(component, AQT1000_HPH_PA_CTL2,
|
||||
0x40, 0x40);
|
||||
snd_soc_update_bits(codec, AQT1000_HPH_PA_CTL2,
|
||||
snd_soc_component_update_bits(component, AQT1000_HPH_PA_CTL2,
|
||||
0x10, 0x10);
|
||||
} else {
|
||||
snd_soc_update_bits(codec, AQT1000_HPH_PA_CTL2,
|
||||
snd_soc_component_update_bits(component, AQT1000_HPH_PA_CTL2,
|
||||
0x40, 0x00);
|
||||
snd_soc_update_bits(codec, AQT1000_HPH_PA_CTL2,
|
||||
snd_soc_component_update_bits(component, AQT1000_HPH_PA_CTL2,
|
||||
0x10, 0x00);
|
||||
}
|
||||
}
|
||||
|
||||
static void aqt_mbhc_moisture_config(struct wcd_mbhc *mbhc)
|
||||
{
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
|
||||
if ((mbhc->moist_rref == R_OFF) ||
|
||||
(mbhc->mbhc_cfg->enable_usbc_analog)) {
|
||||
snd_soc_update_bits(codec, AQT1000_MBHC_NEW_CTL_2,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_MBHC_NEW_CTL_2,
|
||||
0x0C, R_OFF << 2);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Do not enable moisture detection if jack type is NC */
|
||||
if (!mbhc->hphl_swh) {
|
||||
dev_dbg(codec->dev, "%s: disable moisture detection for NC\n",
|
||||
dev_dbg(component->dev, "%s: disable moisture detection for NC\n",
|
||||
__func__);
|
||||
snd_soc_update_bits(codec, AQT1000_MBHC_NEW_CTL_2,
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_MBHC_NEW_CTL_2,
|
||||
0x0C, R_OFF << 2);
|
||||
return;
|
||||
}
|
||||
|
||||
snd_soc_update_bits(codec, AQT1000_MBHC_NEW_CTL_2,
|
||||
snd_soc_component_update_bits(component, AQT1000_MBHC_NEW_CTL_2,
|
||||
0x0C, mbhc->moist_rref << 2);
|
||||
}
|
||||
|
||||
static void aqt_update_anc_state(struct snd_soc_codec *codec, bool enable,
|
||||
int anc_num)
|
||||
static void aqt_update_anc_state(struct snd_soc_component *component,
|
||||
bool enable, int anc_num)
|
||||
{
|
||||
if (enable)
|
||||
snd_soc_update_bits(codec, AQT1000_CDC_RX1_RX_PATH_CFG0 +
|
||||
(20 * anc_num), 0x10, 0x10);
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_CDC_RX1_RX_PATH_CFG0 + (20 * anc_num),
|
||||
0x10, 0x10);
|
||||
else
|
||||
snd_soc_update_bits(codec, AQT1000_CDC_RX1_RX_PATH_CFG0 +
|
||||
(20 * anc_num), 0x10, 0x00);
|
||||
snd_soc_component_update_bits(component,
|
||||
AQT1000_CDC_RX1_RX_PATH_CFG0 + (20 * anc_num),
|
||||
0x10, 0x00);
|
||||
}
|
||||
|
||||
static bool aqt_is_anc_on(struct wcd_mbhc *mbhc)
|
||||
@@ -748,9 +775,11 @@ static bool aqt_is_anc_on(struct wcd_mbhc *mbhc)
|
||||
u16 ancl, ancr;
|
||||
|
||||
ancl =
|
||||
(snd_soc_read(mbhc->codec, AQT1000_CDC_RX1_RX_PATH_CFG0)) & 0x10;
|
||||
(snd_soc_component_read32(mbhc->component,
|
||||
AQT1000_CDC_RX1_RX_PATH_CFG0)) & 0x10;
|
||||
ancr =
|
||||
(snd_soc_read(mbhc->codec, AQT1000_CDC_RX2_RX_PATH_CFG0)) & 0x10;
|
||||
(snd_soc_component_read32(mbhc->component,
|
||||
AQT1000_CDC_RX2_RX_PATH_CFG0)) & 0x10;
|
||||
|
||||
anc_on = !!(ancl | ancr);
|
||||
|
||||
@@ -785,20 +814,23 @@ static const struct wcd_mbhc_cb mbhc_cb = {
|
||||
static int aqt_get_hph_type(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct aqt1000 *aqt = snd_soc_component_get_drvdata(component);
|
||||
struct aqt1000_mbhc *aqt_mbhc = aqt->mbhc;
|
||||
struct wcd_mbhc *mbhc;
|
||||
|
||||
if (!aqt_mbhc) {
|
||||
dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__);
|
||||
dev_err(component->dev, "%s: mbhc not initialized!\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mbhc = &aqt_mbhc->wcd_mbhc;
|
||||
|
||||
ucontrol->value.integer.value[0] = (u32) mbhc->hph_type;
|
||||
dev_dbg(codec->dev, "%s: hph_type = %u\n", __func__, mbhc->hph_type);
|
||||
dev_dbg(component->dev, "%s: hph_type = %u\n", __func__,
|
||||
mbhc->hph_type);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -809,19 +841,22 @@ static int aqt_hph_impedance_get(struct snd_kcontrol *kcontrol,
|
||||
uint32_t zl, zr;
|
||||
bool hphr;
|
||||
struct soc_multi_mixer_control *mc;
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct aqt1000 *aqt = snd_soc_component_get_drvdata(component);
|
||||
struct aqt1000_mbhc *aqt_mbhc = aqt->mbhc;
|
||||
|
||||
if (!aqt_mbhc) {
|
||||
dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__);
|
||||
dev_err(component->dev, "%s: mbhc not initialized!\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mc = (struct soc_multi_mixer_control *)(kcontrol->private_value);
|
||||
hphr = mc->shift;
|
||||
wcd_mbhc_get_impedance(&aqt_mbhc->wcd_mbhc, &zl, &zr);
|
||||
dev_dbg(codec->dev, "%s: zl=%u(ohms), zr=%u(ohms)\n", __func__, zl, zr);
|
||||
dev_dbg(component->dev, "%s: zl=%u(ohms), zr=%u(ohms)\n", __func__,
|
||||
zl, zr);
|
||||
ucontrol->value.integer.value[0] = hphr ? zr : zl;
|
||||
|
||||
return 0;
|
||||
@@ -864,22 +899,22 @@ EXPORT_SYMBOL(aqt_mbhc_get_impedance);
|
||||
|
||||
/*
|
||||
* aqt_mbhc_hs_detect: starts mbhc insertion/removal functionality
|
||||
* @codec: handle to snd_soc_codec *
|
||||
* @component: handle to snd_soc_component *
|
||||
* @mbhc_cfg: handle to mbhc configuration structure
|
||||
* return 0 if mbhc_start is success or error code in case of failure
|
||||
*/
|
||||
int aqt_mbhc_hs_detect(struct snd_soc_codec *codec,
|
||||
int aqt_mbhc_hs_detect(struct snd_soc_component *component,
|
||||
struct wcd_mbhc_config *mbhc_cfg)
|
||||
{
|
||||
struct aqt1000 *aqt;
|
||||
struct aqt1000_mbhc *aqt_mbhc;
|
||||
|
||||
if (!codec) {
|
||||
if (!component) {
|
||||
pr_err("%s: codec is NULL\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
aqt = snd_soc_codec_get_drvdata(codec);
|
||||
aqt = snd_soc_component_get_drvdata(component);
|
||||
if (!aqt) {
|
||||
pr_err("%s: aqt is NULL\n", __func__);
|
||||
return -EINVAL;
|
||||
@@ -887,7 +922,8 @@ int aqt_mbhc_hs_detect(struct snd_soc_codec *codec,
|
||||
|
||||
aqt_mbhc = aqt->mbhc;
|
||||
if (!aqt_mbhc) {
|
||||
dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__);
|
||||
dev_err(component->dev, "%s: mbhc not initialized!\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -897,19 +933,19 @@ EXPORT_SYMBOL(aqt_mbhc_hs_detect);
|
||||
|
||||
/*
|
||||
* aqt_mbhc_hs_detect_exit: stop mbhc insertion/removal functionality
|
||||
* @codec: handle to snd_soc_codec *
|
||||
* @component: handle to snd_soc_component *
|
||||
*/
|
||||
void aqt_mbhc_hs_detect_exit(struct snd_soc_codec *codec)
|
||||
void aqt_mbhc_hs_detect_exit(struct snd_soc_component *component)
|
||||
{
|
||||
struct aqt1000 *aqt;
|
||||
struct aqt1000_mbhc *aqt_mbhc;
|
||||
|
||||
if (!codec) {
|
||||
if (!component) {
|
||||
pr_err("%s: codec is NULL\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
aqt = snd_soc_codec_get_drvdata(codec);
|
||||
aqt = snd_soc_component_get_drvdata(component);
|
||||
if (!aqt) {
|
||||
pr_err("%s: aqt is NULL\n", __func__);
|
||||
return;
|
||||
@@ -917,7 +953,8 @@ void aqt_mbhc_hs_detect_exit(struct snd_soc_codec *codec)
|
||||
|
||||
aqt_mbhc = aqt->mbhc;
|
||||
if (!aqt_mbhc) {
|
||||
dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__);
|
||||
dev_err(component->dev, "%s: mbhc not initialized!\n",
|
||||
__func__);
|
||||
return;
|
||||
}
|
||||
wcd_mbhc_stop(&aqt_mbhc->wcd_mbhc);
|
||||
@@ -927,17 +964,17 @@ EXPORT_SYMBOL(aqt_mbhc_hs_detect_exit);
|
||||
/*
|
||||
* aqt_mbhc_post_ssr_init: initialize mbhc for aqt post subsystem restart
|
||||
* @mbhc: poniter to aqt_mbhc structure
|
||||
* @codec: handle to snd_soc_codec *
|
||||
* @component: handle to snd_soc_component *
|
||||
*
|
||||
* return 0 if mbhc_init is success or error code in case of failure
|
||||
*/
|
||||
int aqt_mbhc_post_ssr_init(struct aqt1000_mbhc *mbhc,
|
||||
struct snd_soc_codec *codec)
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
int ret;
|
||||
struct wcd_mbhc *wcd_mbhc;
|
||||
|
||||
if (!mbhc || !codec)
|
||||
if (!mbhc || !component)
|
||||
return -EINVAL;
|
||||
|
||||
wcd_mbhc = &mbhc->wcd_mbhc;
|
||||
@@ -947,10 +984,10 @@ int aqt_mbhc_post_ssr_init(struct aqt1000_mbhc *mbhc,
|
||||
}
|
||||
|
||||
wcd_mbhc_deinit(wcd_mbhc);
|
||||
ret = wcd_mbhc_init(wcd_mbhc, codec, &mbhc_cb, &intr_ids,
|
||||
ret = wcd_mbhc_init(wcd_mbhc, component, &mbhc_cb, &intr_ids,
|
||||
wcd_mbhc_registers, AQT_ZDET_SUPPORTED);
|
||||
if (ret) {
|
||||
dev_err(codec->dev, "%s: mbhc initialization failed\n",
|
||||
dev_err(component->dev, "%s: mbhc initialization failed\n",
|
||||
__func__);
|
||||
goto done;
|
||||
}
|
||||
@@ -963,29 +1000,30 @@ EXPORT_SYMBOL(aqt_mbhc_post_ssr_init);
|
||||
/*
|
||||
* aqt_mbhc_init: initialize mbhc for aqt
|
||||
* @mbhc: poniter to aqt_mbhc struct pointer to store the configs
|
||||
* @codec: handle to snd_soc_codec *
|
||||
* @component: handle to snd_soc_component *
|
||||
* @fw_data: handle to firmware data
|
||||
*
|
||||
* return 0 if mbhc_init is success or error code in case of failure
|
||||
*/
|
||||
int aqt_mbhc_init(struct aqt1000_mbhc **mbhc, struct snd_soc_codec *codec,
|
||||
int aqt_mbhc_init(struct aqt1000_mbhc **mbhc,
|
||||
struct snd_soc_component *component,
|
||||
struct fw_info *fw_data)
|
||||
{
|
||||
struct aqt1000_mbhc *aqt_mbhc;
|
||||
struct wcd_mbhc *wcd_mbhc;
|
||||
int ret;
|
||||
|
||||
if (!codec) {
|
||||
if (!component) {
|
||||
pr_err("%s: codec is NULL\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
aqt_mbhc = devm_kzalloc(codec->dev, sizeof(struct aqt1000_mbhc),
|
||||
aqt_mbhc = devm_kzalloc(component->dev, sizeof(struct aqt1000_mbhc),
|
||||
GFP_KERNEL);
|
||||
if (!aqt_mbhc)
|
||||
return -ENOMEM;
|
||||
|
||||
aqt_mbhc->aqt = dev_get_drvdata(codec->dev);
|
||||
aqt_mbhc->aqt = dev_get_drvdata(component->dev);
|
||||
aqt_mbhc->fw_data = fw_data;
|
||||
BLOCKING_INIT_NOTIFIER_HEAD(&aqt_mbhc->notifier);
|
||||
wcd_mbhc = &aqt_mbhc->wcd_mbhc;
|
||||
@@ -999,43 +1037,43 @@ int aqt_mbhc_init(struct aqt1000_mbhc **mbhc, struct snd_soc_codec *codec,
|
||||
/* Setting default mbhc detection logic to ADC */
|
||||
wcd_mbhc->mbhc_detection_logic = WCD_DETECTION_ADC;
|
||||
|
||||
ret = wcd_mbhc_init(wcd_mbhc, codec, &mbhc_cb,
|
||||
ret = wcd_mbhc_init(wcd_mbhc, component, &mbhc_cb,
|
||||
&intr_ids, wcd_mbhc_registers,
|
||||
AQT_ZDET_SUPPORTED);
|
||||
if (ret) {
|
||||
dev_err(codec->dev, "%s: mbhc initialization failed\n",
|
||||
dev_err(component->dev, "%s: mbhc initialization failed\n",
|
||||
__func__);
|
||||
goto err;
|
||||
}
|
||||
|
||||
(*mbhc) = aqt_mbhc;
|
||||
snd_soc_add_codec_controls(codec, impedance_detect_controls,
|
||||
snd_soc_add_component_controls(component, impedance_detect_controls,
|
||||
ARRAY_SIZE(impedance_detect_controls));
|
||||
snd_soc_add_codec_controls(codec, hph_type_detect_controls,
|
||||
snd_soc_add_component_controls(component, hph_type_detect_controls,
|
||||
ARRAY_SIZE(hph_type_detect_controls));
|
||||
|
||||
return 0;
|
||||
err:
|
||||
devm_kfree(codec->dev, aqt_mbhc);
|
||||
devm_kfree(component->dev, aqt_mbhc);
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(aqt_mbhc_init);
|
||||
|
||||
/*
|
||||
* aqt_mbhc_deinit: deinitialize mbhc for aqt
|
||||
* @codec: handle to snd_soc_codec *
|
||||
* @component: handle to snd_soc_component *
|
||||
*/
|
||||
void aqt_mbhc_deinit(struct snd_soc_codec *codec)
|
||||
void aqt_mbhc_deinit(struct snd_soc_component *component)
|
||||
{
|
||||
struct aqt1000 *aqt;
|
||||
struct aqt1000_mbhc *aqt_mbhc;
|
||||
|
||||
if (!codec) {
|
||||
pr_err("%s: codec is NULL\n", __func__);
|
||||
if (!component) {
|
||||
pr_err("%s: component is NULL\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
aqt = snd_soc_codec_get_drvdata(codec);
|
||||
aqt = snd_soc_component_get_drvdata(component);
|
||||
if (!aqt) {
|
||||
pr_err("%s: aqt is NULL\n", __func__);
|
||||
return;
|
||||
@@ -1044,7 +1082,7 @@ void aqt_mbhc_deinit(struct snd_soc_codec *codec)
|
||||
aqt_mbhc = aqt->mbhc;
|
||||
if (aqt_mbhc) {
|
||||
wcd_mbhc_deinit(&aqt_mbhc->wcd_mbhc);
|
||||
devm_kfree(codec->dev, aqt_mbhc);
|
||||
devm_kfree(component->dev, aqt_mbhc);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL(aqt_mbhc_deinit);
|
||||
|
@@ -15,36 +15,36 @@ struct aqt1000_mbhc {
|
||||
|
||||
#if IS_ENABLED(CONFIG_SND_SOC_AQT1000)
|
||||
extern int aqt_mbhc_init(struct aqt1000_mbhc **mbhc,
|
||||
struct snd_soc_codec *codec,
|
||||
struct snd_soc_component *component,
|
||||
struct fw_info *fw_data);
|
||||
extern void aqt_mbhc_hs_detect_exit(struct snd_soc_codec *codec);
|
||||
extern int aqt_mbhc_hs_detect(struct snd_soc_codec *codec,
|
||||
extern void aqt_mbhc_hs_detect_exit(struct snd_soc_component *component);
|
||||
extern int aqt_mbhc_hs_detect(struct snd_soc_component *component,
|
||||
struct wcd_mbhc_config *mbhc_cfg);
|
||||
extern void aqt_mbhc_deinit(struct snd_soc_codec *codec);
|
||||
extern void aqt_mbhc_deinit(struct snd_soc_component *component);
|
||||
extern int aqt_mbhc_post_ssr_init(struct aqt1000_mbhc *mbhc,
|
||||
struct snd_soc_codec *codec);
|
||||
struct snd_soc_component *component);
|
||||
extern int aqt_mbhc_get_impedance(struct aqt1000_mbhc *aqt_mbhc,
|
||||
uint32_t *zl, uint32_t *zr);
|
||||
#else
|
||||
static inline int aqt_mbhc_init(struct aqt1000_mbhc **mbhc,
|
||||
struct snd_soc_codec *codec,
|
||||
struct snd_soc_component *component,
|
||||
struct fw_info *fw_data)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static inline void aqt_mbhc_hs_detect_exit(struct snd_soc_codec *codec)
|
||||
static inline void aqt_mbhc_hs_detect_exit(struct snd_soc_component *component)
|
||||
{
|
||||
}
|
||||
static inline int aqt_mbhc_hs_detect(struct snd_soc_codec *codec,
|
||||
static inline int aqt_mbhc_hs_detect(struct snd_soc_component *component,
|
||||
struct wcd_mbhc_config *mbhc_cfg)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static inline void aqt_mbhc_deinit(struct snd_soc_codec *codec)
|
||||
static inline void aqt_mbhc_deinit(struct snd_soc_component *component)
|
||||
{
|
||||
}
|
||||
static inline int aqt_mbhc_post_ssr_init(struct aqt1000_mbhc *mbhc,
|
||||
struct snd_soc_codec *codec)
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
文件差异内容过多而无法显示
加载差异
@@ -145,7 +145,7 @@ struct aqt1000 {
|
||||
|
||||
u32 mclk_rate;
|
||||
struct regmap *regmap;
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
bool dev_up;
|
||||
bool prev_pg_valid;
|
||||
u8 prev_pg;
|
||||
|
@@ -10,6 +10,7 @@
|
||||
#include <linux/clk.h>
|
||||
#include <linux/clk-provider.h>
|
||||
#include "../../../drivers/clk/qcom/common.h"
|
||||
#include <linux/pinctrl/consumer.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <dt-bindings/clock/qcom,audio-ext-clk.h>
|
||||
#include <dsp/q6afe-v2.h>
|
||||
|
@@ -16,13 +16,15 @@
|
||||
#include "bolero-cdc.h"
|
||||
#include "internal.h"
|
||||
|
||||
#define DRV_NAME "bolero_codec"
|
||||
|
||||
#define BOLERO_VERSION_1_0 0x0001
|
||||
#define BOLERO_VERSION_1_1 0x0002
|
||||
#define BOLERO_VERSION_1_2 0x0003
|
||||
#define BOLERO_VERSION_ENTRY_SIZE 32
|
||||
#define BOLERO_CDC_STRING_LEN 80
|
||||
|
||||
static struct snd_soc_codec_driver bolero;
|
||||
static const struct snd_soc_component_driver bolero;
|
||||
|
||||
/* pm runtime auto suspend timer in msecs */
|
||||
#define BOLERO_AUTO_SUSPEND_DELAY 100 /* delay in msec */
|
||||
@@ -145,17 +147,20 @@ static int bolero_cdc_update_wcd_event(void *handle, u16 event, u32 data)
|
||||
switch (event) {
|
||||
case WCD_BOLERO_EVT_RX_MUTE:
|
||||
if (priv->macro_params[RX_MACRO].event_handler)
|
||||
priv->macro_params[RX_MACRO].event_handler(priv->codec,
|
||||
priv->macro_params[RX_MACRO].event_handler(
|
||||
priv->component,
|
||||
BOLERO_MACRO_EVT_RX_MUTE, data);
|
||||
break;
|
||||
case WCD_BOLERO_EVT_IMPED_TRUE:
|
||||
if (priv->macro_params[RX_MACRO].event_handler)
|
||||
priv->macro_params[RX_MACRO].event_handler(priv->codec,
|
||||
priv->macro_params[RX_MACRO].event_handler(
|
||||
priv->component,
|
||||
BOLERO_MACRO_EVT_IMPED_TRUE, data);
|
||||
break;
|
||||
case WCD_BOLERO_EVT_IMPED_FALSE:
|
||||
if (priv->macro_params[RX_MACRO].event_handler)
|
||||
priv->macro_params[RX_MACRO].event_handler(priv->codec,
|
||||
priv->macro_params[RX_MACRO].event_handler(
|
||||
priv->component,
|
||||
BOLERO_MACRO_EVT_IMPED_FALSE, data);
|
||||
break;
|
||||
default:
|
||||
@@ -367,7 +372,7 @@ int bolero_register_macro(struct device *dev, u16 macro_id,
|
||||
bolero_mclk_mux_tbl[VA_MACRO][MCLK_MUX0] = VA_MACRO;
|
||||
priv->current_mclk_mux_macro[VA_MACRO] = VA_MACRO;
|
||||
}
|
||||
ret = snd_soc_register_codec(dev->parent, &bolero,
|
||||
ret = snd_soc_register_component(dev->parent, &bolero,
|
||||
priv->bolero_dais, priv->num_dais);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "%s: register codec failed\n", __func__);
|
||||
@@ -418,7 +423,7 @@ void bolero_unregister_macro(struct device *dev, u16 macro_id)
|
||||
|
||||
/* UNREGISTER CODEC HERE */
|
||||
if (priv->num_macros - 1 == priv->num_macros_registered)
|
||||
snd_soc_unregister_codec(dev->parent);
|
||||
snd_soc_unregister_component(dev->parent);
|
||||
}
|
||||
EXPORT_SYMBOL(bolero_unregister_macro);
|
||||
|
||||
@@ -568,7 +573,8 @@ static int bolero_ssr_enable(struct device *dev, void *data)
|
||||
}
|
||||
|
||||
if (priv->macro_params[VA_MACRO].event_handler)
|
||||
priv->macro_params[VA_MACRO].event_handler(priv->codec,
|
||||
priv->macro_params[VA_MACRO].event_handler(
|
||||
priv->component,
|
||||
BOLERO_MACRO_EVT_WAIT_VA_CLK_RESET, 0x0);
|
||||
|
||||
regcache_cache_only(priv->regmap, false);
|
||||
@@ -576,7 +582,8 @@ static int bolero_ssr_enable(struct device *dev, void *data)
|
||||
for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++) {
|
||||
if (!priv->macro_params[macro_idx].event_handler)
|
||||
continue;
|
||||
priv->macro_params[macro_idx].event_handler(priv->codec,
|
||||
priv->macro_params[macro_idx].event_handler(
|
||||
priv->component,
|
||||
BOLERO_MACRO_EVT_SSR_UP, 0x0);
|
||||
}
|
||||
mutex_lock(&priv->clk_lock);
|
||||
@@ -601,7 +608,8 @@ static void bolero_ssr_disable(struct device *dev, void *data)
|
||||
for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++) {
|
||||
if (!priv->macro_params[macro_idx].event_handler)
|
||||
continue;
|
||||
priv->macro_params[macro_idx].event_handler(priv->codec,
|
||||
priv->macro_params[macro_idx].event_handler(
|
||||
priv->component,
|
||||
BOLERO_MACRO_EVT_SSR_DOWN, 0x0);
|
||||
}
|
||||
bolero_cdc_notifier_call(priv, BOLERO_WCD_EVT_SSR_DOWN);
|
||||
@@ -619,7 +627,7 @@ static const struct snd_event_ops bolero_ssr_ops = {
|
||||
/*
|
||||
* bolero_info_create_codec_entry - creates bolero module
|
||||
* @codec_root: The parent directory
|
||||
* @codec: Codec instance
|
||||
* @component: Codec component instance
|
||||
*
|
||||
* Creates bolero module and version entry under the given
|
||||
* parent directory.
|
||||
@@ -627,26 +635,26 @@ static const struct snd_event_ops bolero_ssr_ops = {
|
||||
* Return: 0 on success or negative error code on failure.
|
||||
*/
|
||||
int bolero_info_create_codec_entry(struct snd_info_entry *codec_root,
|
||||
struct snd_soc_codec *codec)
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
struct snd_info_entry *version_entry;
|
||||
struct bolero_priv *priv;
|
||||
struct snd_soc_card *card;
|
||||
|
||||
if (!codec_root || !codec)
|
||||
if (!codec_root || !component)
|
||||
return -EINVAL;
|
||||
|
||||
priv = snd_soc_codec_get_drvdata(codec);
|
||||
priv = snd_soc_component_get_drvdata(component);
|
||||
if (priv->entry) {
|
||||
dev_dbg(priv->dev,
|
||||
"%s:bolero module already created\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
card = codec->component.card;
|
||||
card = component->card;
|
||||
priv->entry = snd_info_create_subdir(codec_root->module,
|
||||
"bolero", codec_root);
|
||||
if (!priv->entry) {
|
||||
dev_dbg(codec->dev, "%s: failed to create bolero entry\n",
|
||||
dev_dbg(component->dev, "%s: failed to create bolero entry\n",
|
||||
__func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
@@ -654,7 +662,7 @@ int bolero_info_create_codec_entry(struct snd_info_entry *codec_root,
|
||||
"version",
|
||||
priv->entry);
|
||||
if (!version_entry) {
|
||||
dev_err(codec->dev, "%s: failed to create bolero version entry\n",
|
||||
dev_err(component->dev, "%s: failed to create bolero version entry\n",
|
||||
__func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
@@ -677,52 +685,56 @@ EXPORT_SYMBOL(bolero_info_create_codec_entry);
|
||||
/**
|
||||
* bolero_register_wake_irq - Register wake irq of Tx macro
|
||||
*
|
||||
* @codec: codec ptr.
|
||||
* @component: codec component ptr.
|
||||
* @ipc_wakeup: bool to identify ipc_wakeup to be used or HW interrupt line.
|
||||
*
|
||||
* Return: 0 on success or negative error code on failure.
|
||||
*/
|
||||
int bolero_register_wake_irq(struct snd_soc_codec *codec, u32 ipc_wakeup)
|
||||
int bolero_register_wake_irq(struct snd_soc_component *component,
|
||||
u32 ipc_wakeup)
|
||||
{
|
||||
struct bolero_priv *priv = NULL;
|
||||
|
||||
if (!codec)
|
||||
if (!component)
|
||||
return -EINVAL;
|
||||
|
||||
priv = snd_soc_codec_get_drvdata(codec);
|
||||
priv = snd_soc_component_get_drvdata(component);
|
||||
if (!priv)
|
||||
return -EINVAL;
|
||||
|
||||
if (!bolero_is_valid_codec_dev(priv->dev)) {
|
||||
dev_err(codec->dev, "%s: invalid codec\n", __func__);
|
||||
dev_err(component->dev, "%s: invalid codec\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (priv->macro_params[TX_MACRO].reg_wake_irq)
|
||||
priv->macro_params[TX_MACRO].reg_wake_irq(codec, ipc_wakeup);
|
||||
priv->macro_params[TX_MACRO].reg_wake_irq(
|
||||
component, ipc_wakeup);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(bolero_register_wake_irq);
|
||||
|
||||
static int bolero_soc_codec_probe(struct snd_soc_codec *codec)
|
||||
static int bolero_soc_codec_probe(struct snd_soc_component *component)
|
||||
{
|
||||
struct bolero_priv *priv = dev_get_drvdata(codec->dev);
|
||||
struct bolero_priv *priv = dev_get_drvdata(component->dev);
|
||||
int macro_idx, ret = 0;
|
||||
|
||||
snd_soc_component_init_regmap(component, priv->regmap);
|
||||
|
||||
/* call init for supported macros */
|
||||
for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++) {
|
||||
if (priv->macro_params[macro_idx].init) {
|
||||
ret = priv->macro_params[macro_idx].init(codec);
|
||||
ret = priv->macro_params[macro_idx].init(component);
|
||||
if (ret < 0) {
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s: init for macro %d failed\n",
|
||||
__func__, macro_idx);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
}
|
||||
priv->codec = codec;
|
||||
priv->component = component;
|
||||
/*
|
||||
* In order for the ADIE RTC to differentiate between targets
|
||||
* version info is used.
|
||||
@@ -741,42 +753,36 @@ static int bolero_soc_codec_probe(struct snd_soc_codec *codec)
|
||||
if (!ret) {
|
||||
snd_event_notify(priv->dev, SND_EVENT_UP);
|
||||
} else {
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s: Registration with SND event FWK failed ret = %d\n",
|
||||
__func__, ret);
|
||||
goto err;
|
||||
}
|
||||
|
||||
dev_dbg(codec->dev, "%s: bolero soc codec probe success\n", __func__);
|
||||
dev_dbg(component->dev, "%s: bolero soc codec probe success\n",
|
||||
__func__);
|
||||
err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int bolero_soc_codec_remove(struct snd_soc_codec *codec)
|
||||
static void bolero_soc_codec_remove(struct snd_soc_component *component)
|
||||
{
|
||||
struct bolero_priv *priv = dev_get_drvdata(codec->dev);
|
||||
struct bolero_priv *priv = dev_get_drvdata(component->dev);
|
||||
int macro_idx;
|
||||
|
||||
snd_event_client_deregister(priv->dev);
|
||||
/* call exit for supported macros */
|
||||
for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++)
|
||||
if (priv->macro_params[macro_idx].exit)
|
||||
priv->macro_params[macro_idx].exit(codec);
|
||||
priv->macro_params[macro_idx].exit(component);
|
||||
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
static struct regmap *bolero_get_regmap(struct device *dev)
|
||||
{
|
||||
struct bolero_priv *priv = dev_get_drvdata(dev);
|
||||
|
||||
return priv->regmap;
|
||||
}
|
||||
|
||||
static struct snd_soc_codec_driver bolero = {
|
||||
static const struct snd_soc_component_driver bolero = {
|
||||
.name = DRV_NAME,
|
||||
.probe = bolero_soc_codec_probe,
|
||||
.remove = bolero_soc_codec_remove,
|
||||
.get_regmap = bolero_get_regmap,
|
||||
};
|
||||
|
||||
static void bolero_add_child_devices(struct work_struct *work)
|
||||
|
@@ -42,15 +42,15 @@ enum {
|
||||
};
|
||||
|
||||
struct macro_ops {
|
||||
int (*init)(struct snd_soc_codec *codec);
|
||||
int (*exit)(struct snd_soc_codec *codec);
|
||||
int (*init)(struct snd_soc_component *component);
|
||||
int (*exit)(struct snd_soc_component *component);
|
||||
u16 num_dais;
|
||||
struct device *dev;
|
||||
struct snd_soc_dai_driver *dai_ptr;
|
||||
int (*mclk_fn)(struct device *dev, bool enable);
|
||||
int (*event_handler)(struct snd_soc_codec *codec, u16 event,
|
||||
int (*event_handler)(struct snd_soc_component *component, u16 event,
|
||||
u32 data);
|
||||
int (*reg_wake_irq)(struct snd_soc_codec *codec, u32 data);
|
||||
int (*reg_wake_irq)(struct snd_soc_component *component, u32 data);
|
||||
char __iomem *io_base;
|
||||
};
|
||||
|
||||
@@ -64,8 +64,8 @@ int bolero_request_clock(struct device *dev, u16 macro_id,
|
||||
bool enable);
|
||||
int bolero_info_create_codec_entry(
|
||||
struct snd_info_entry *codec_root,
|
||||
struct snd_soc_codec *codec);
|
||||
int bolero_register_wake_irq(struct snd_soc_codec *codec, u32 data);
|
||||
struct snd_soc_component *component);
|
||||
int bolero_register_wake_irq(struct snd_soc_component *component, u32 data);
|
||||
void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n);
|
||||
int bolero_runtime_resume(struct device *dev);
|
||||
int bolero_runtime_suspend(struct device *dev);
|
||||
@@ -96,7 +96,7 @@ static inline int bolero_request_clock(struct device *dev, u16 macro_id,
|
||||
|
||||
static int bolero_info_create_codec_entry(
|
||||
struct snd_info_entry *codec_root,
|
||||
struct snd_soc_codec *codec)
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ static inline void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n)
|
||||
{
|
||||
}
|
||||
|
||||
static inline int bolero_register_wake_irq(struct snd_soc_codec *codec,
|
||||
static inline int bolero_register_wake_irq(struct snd_soc_component *component,
|
||||
u32 data)
|
||||
static inline int bolero_runtime_resume(struct device *dev)
|
||||
{
|
||||
|
@@ -41,7 +41,7 @@ struct wcd_ctrl_platform_data {
|
||||
|
||||
struct bolero_priv {
|
||||
struct device *dev;
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
struct regmap *regmap;
|
||||
struct mutex io_lock;
|
||||
struct mutex clk_lock;
|
||||
|
文件差异内容过多而无法显示
加载差异
@@ -130,7 +130,7 @@ struct tx_macro_priv {
|
||||
struct clk *tx_npl_clk;
|
||||
struct mutex mclk_lock;
|
||||
struct mutex swr_clk_lock;
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
struct device_node *tx_swr_gpio_p;
|
||||
struct tx_macro_swr_ctrl_data *swr_ctrl_data;
|
||||
struct tx_macro_swr_ctrl_platform_data swr_plat_data;
|
||||
@@ -150,28 +150,28 @@ struct tx_macro_priv {
|
||||
int child_count;
|
||||
};
|
||||
|
||||
static bool tx_macro_get_data(struct snd_soc_codec *codec,
|
||||
static bool tx_macro_get_data(struct snd_soc_component *component,
|
||||
struct device **tx_dev,
|
||||
struct tx_macro_priv **tx_priv,
|
||||
const char *func_name)
|
||||
{
|
||||
*tx_dev = bolero_get_device_ptr(codec->dev, TX_MACRO);
|
||||
*tx_dev = bolero_get_device_ptr(component->dev, TX_MACRO);
|
||||
if (!(*tx_dev)) {
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s: null device for macro!\n", func_name);
|
||||
return false;
|
||||
}
|
||||
|
||||
*tx_priv = dev_get_drvdata((*tx_dev));
|
||||
if (!(*tx_priv)) {
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s: priv is null for macro!\n", func_name);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(*tx_priv)->codec) {
|
||||
dev_err(codec->dev,
|
||||
"%s: tx_priv->codec not initialized!\n", func_name);
|
||||
if (!(*tx_priv)->component) {
|
||||
dev_err(component->dev,
|
||||
"%s: tx_priv->component not initialized!\n", func_name);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -245,12 +245,13 @@ exit:
|
||||
static int tx_macro_mclk_event(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_dapm_to_component(w->dapm);
|
||||
int ret = 0;
|
||||
struct device *tx_dev = NULL;
|
||||
struct tx_macro_priv *tx_priv = NULL;
|
||||
|
||||
if (!tx_macro_get_data(codec, &tx_dev, &tx_priv, __func__))
|
||||
if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
|
||||
return -EINVAL;
|
||||
|
||||
dev_dbg(tx_dev, "%s: event = %d\n", __func__, event);
|
||||
@@ -296,13 +297,13 @@ exit:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int tx_macro_event_handler(struct snd_soc_codec *codec, u16 event,
|
||||
u32 data)
|
||||
static int tx_macro_event_handler(struct snd_soc_component *component,
|
||||
u16 event, u32 data)
|
||||
{
|
||||
struct device *tx_dev = NULL;
|
||||
struct tx_macro_priv *tx_priv = NULL;
|
||||
|
||||
if (!tx_macro_get_data(codec, &tx_dev, &tx_priv, __func__))
|
||||
if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
|
||||
return -EINVAL;
|
||||
|
||||
switch (event) {
|
||||
@@ -323,7 +324,7 @@ static int tx_macro_event_handler(struct snd_soc_codec *codec, u16 event,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tx_macro_reg_wake_irq(struct snd_soc_codec *codec,
|
||||
static int tx_macro_reg_wake_irq(struct snd_soc_component *component,
|
||||
u32 data)
|
||||
{
|
||||
struct device *tx_dev = NULL;
|
||||
@@ -331,7 +332,7 @@ static int tx_macro_reg_wake_irq(struct snd_soc_codec *codec,
|
||||
u32 ipc_wakeup = data;
|
||||
int ret = 0;
|
||||
|
||||
if (!tx_macro_get_data(codec, &tx_dev, &tx_priv, __func__))
|
||||
if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
|
||||
return -EINVAL;
|
||||
|
||||
ret = swrm_wcd_notify(
|
||||
@@ -346,7 +347,7 @@ static void tx_macro_tx_hpf_corner_freq_callback(struct work_struct *work)
|
||||
struct delayed_work *hpf_delayed_work = NULL;
|
||||
struct hpf_work *hpf_work = NULL;
|
||||
struct tx_macro_priv *tx_priv = NULL;
|
||||
struct snd_soc_codec *codec = NULL;
|
||||
struct snd_soc_component *component = NULL;
|
||||
u16 dec_cfg_reg = 0, hpf_gate_reg = 0;
|
||||
u8 hpf_cut_off_freq = 0;
|
||||
u16 adc_mux_reg = 0, adc_n = 0, adc_reg = 0;
|
||||
@@ -354,7 +355,7 @@ static void tx_macro_tx_hpf_corner_freq_callback(struct work_struct *work)
|
||||
hpf_delayed_work = to_delayed_work(work);
|
||||
hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork);
|
||||
tx_priv = hpf_work->tx_priv;
|
||||
codec = tx_priv->codec;
|
||||
component = tx_priv->component;
|
||||
hpf_cut_off_freq = hpf_work->hpf_cut_off_freq;
|
||||
|
||||
dec_cfg_reg = BOLERO_CDC_TX0_TX_PATH_CFG0 +
|
||||
@@ -362,34 +363,35 @@ static void tx_macro_tx_hpf_corner_freq_callback(struct work_struct *work)
|
||||
hpf_gate_reg = BOLERO_CDC_TX0_TX_PATH_SEC2 +
|
||||
TX_MACRO_TX_PATH_OFFSET * hpf_work->decimator;
|
||||
|
||||
dev_dbg(codec->dev, "%s: decimator %u hpf_cut_of_freq 0x%x\n",
|
||||
dev_dbg(component->dev, "%s: decimator %u hpf_cut_of_freq 0x%x\n",
|
||||
__func__, hpf_work->decimator, hpf_cut_off_freq);
|
||||
|
||||
adc_mux_reg = BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG1 +
|
||||
TX_MACRO_ADC_MUX_CFG_OFFSET * hpf_work->decimator;
|
||||
if (snd_soc_read(codec, adc_mux_reg) & SWR_MIC) {
|
||||
if (snd_soc_component_read32(component, adc_mux_reg) & SWR_MIC) {
|
||||
adc_reg = BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG0 +
|
||||
TX_MACRO_ADC_MUX_CFG_OFFSET * hpf_work->decimator;
|
||||
adc_n = snd_soc_read(codec, adc_reg) &
|
||||
adc_n = snd_soc_component_read32(component, adc_reg) &
|
||||
TX_MACRO_SWR_MIC_MUX_SEL_MASK;
|
||||
if (adc_n >= BOLERO_ADC_MAX)
|
||||
goto tx_hpf_set;
|
||||
/* analog mic clear TX hold */
|
||||
bolero_clear_amic_tx_hold(codec->dev, adc_n);
|
||||
bolero_clear_amic_tx_hold(component->dev, adc_n);
|
||||
}
|
||||
tx_hpf_set:
|
||||
snd_soc_update_bits(codec, dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK,
|
||||
snd_soc_component_update_bits(component,
|
||||
dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK,
|
||||
hpf_cut_off_freq << 5);
|
||||
snd_soc_update_bits(codec, hpf_gate_reg, 0x03, 0x02);
|
||||
snd_soc_component_update_bits(component, hpf_gate_reg, 0x03, 0x02);
|
||||
/* Minimum 1 clk cycle delay is required as per HW spec */
|
||||
usleep_range(1000, 1010);
|
||||
snd_soc_update_bits(codec, hpf_gate_reg, 0x03, 0x01);
|
||||
snd_soc_component_update_bits(component, hpf_gate_reg, 0x03, 0x01);
|
||||
}
|
||||
|
||||
static void tx_macro_mute_update_callback(struct work_struct *work)
|
||||
{
|
||||
struct tx_mute_work *tx_mute_dwork = NULL;
|
||||
struct snd_soc_codec *codec = NULL;
|
||||
struct snd_soc_component *component = NULL;
|
||||
struct tx_macro_priv *tx_priv = NULL;
|
||||
struct delayed_work *delayed_work = NULL;
|
||||
u16 tx_vol_ctl_reg = 0;
|
||||
@@ -398,13 +400,13 @@ static void tx_macro_mute_update_callback(struct work_struct *work)
|
||||
delayed_work = to_delayed_work(work);
|
||||
tx_mute_dwork = container_of(delayed_work, struct tx_mute_work, dwork);
|
||||
tx_priv = tx_mute_dwork->tx_priv;
|
||||
codec = tx_priv->codec;
|
||||
component = tx_priv->component;
|
||||
decimator = tx_mute_dwork->decimator;
|
||||
|
||||
tx_vol_ctl_reg =
|
||||
BOLERO_CDC_TX0_TX_PATH_CTL +
|
||||
TX_MACRO_TX_PATH_OFFSET * decimator;
|
||||
snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00);
|
||||
snd_soc_component_update_bits(component, tx_vol_ctl_reg, 0x10, 0x00);
|
||||
dev_dbg(tx_priv->dev, "%s: decimator %u unmute\n",
|
||||
__func__, decimator);
|
||||
}
|
||||
@@ -414,7 +416,8 @@ static int tx_macro_put_dec_enum(struct snd_kcontrol *kcontrol,
|
||||
{
|
||||
struct snd_soc_dapm_widget *widget =
|
||||
snd_soc_dapm_kcontrol_widget(kcontrol);
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_dapm_to_component(widget->dapm);
|
||||
struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
|
||||
unsigned int val = 0;
|
||||
u16 mic_sel_reg = 0;
|
||||
@@ -423,7 +426,7 @@ static int tx_macro_put_dec_enum(struct snd_kcontrol *kcontrol,
|
||||
if (val > e->items - 1)
|
||||
return -EINVAL;
|
||||
|
||||
dev_dbg(codec->dev, "%s: wname: %s, val: 0x%x\n", __func__,
|
||||
dev_dbg(component->dev, "%s: wname: %s, val: 0x%x\n", __func__,
|
||||
widget->name, val);
|
||||
|
||||
switch (e->reg) {
|
||||
@@ -452,23 +455,26 @@ static int tx_macro_put_dec_enum(struct snd_kcontrol *kcontrol,
|
||||
mic_sel_reg = BOLERO_CDC_TX7_TX_PATH_CFG0;
|
||||
break;
|
||||
default:
|
||||
dev_err(codec->dev, "%s: e->reg: 0x%x not expected\n",
|
||||
dev_err(component->dev, "%s: e->reg: 0x%x not expected\n",
|
||||
__func__, e->reg);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (strnstr(widget->name, "SMIC", strlen(widget->name))) {
|
||||
if (val != 0) {
|
||||
if (val < 5)
|
||||
snd_soc_update_bits(codec, mic_sel_reg,
|
||||
snd_soc_component_update_bits(component,
|
||||
mic_sel_reg,
|
||||
1 << 7, 0x0 << 7);
|
||||
else
|
||||
snd_soc_update_bits(codec, mic_sel_reg,
|
||||
snd_soc_component_update_bits(component,
|
||||
mic_sel_reg,
|
||||
1 << 7, 0x1 << 7);
|
||||
}
|
||||
} else {
|
||||
/* DMIC selected */
|
||||
if (val != 0)
|
||||
snd_soc_update_bits(codec, mic_sel_reg, 1 << 7, 1 << 7);
|
||||
snd_soc_component_update_bits(component, mic_sel_reg,
|
||||
1 << 7, 1 << 7);
|
||||
}
|
||||
|
||||
return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
|
||||
@@ -479,7 +485,8 @@ static int tx_macro_tx_mixer_get(struct snd_kcontrol *kcontrol,
|
||||
{
|
||||
struct snd_soc_dapm_widget *widget =
|
||||
snd_soc_dapm_kcontrol_widget(kcontrol);
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_dapm_to_component(widget->dapm);
|
||||
struct soc_multi_mixer_control *mixer =
|
||||
((struct soc_multi_mixer_control *)kcontrol->private_value);
|
||||
u32 dai_id = widget->shift;
|
||||
@@ -487,7 +494,7 @@ static int tx_macro_tx_mixer_get(struct snd_kcontrol *kcontrol,
|
||||
struct device *tx_dev = NULL;
|
||||
struct tx_macro_priv *tx_priv = NULL;
|
||||
|
||||
if (!tx_macro_get_data(codec, &tx_dev, &tx_priv, __func__))
|
||||
if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
|
||||
return -EINVAL;
|
||||
|
||||
if (test_bit(dec_id, &tx_priv->active_ch_mask[dai_id]))
|
||||
@@ -502,7 +509,8 @@ static int tx_macro_tx_mixer_put(struct snd_kcontrol *kcontrol,
|
||||
{
|
||||
struct snd_soc_dapm_widget *widget =
|
||||
snd_soc_dapm_kcontrol_widget(kcontrol);
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_dapm_to_component(widget->dapm);
|
||||
struct snd_soc_dapm_update *update = NULL;
|
||||
struct soc_multi_mixer_control *mixer =
|
||||
((struct soc_multi_mixer_control *)kcontrol->private_value);
|
||||
@@ -512,7 +520,7 @@ static int tx_macro_tx_mixer_put(struct snd_kcontrol *kcontrol,
|
||||
struct device *tx_dev = NULL;
|
||||
struct tx_macro_priv *tx_priv = NULL;
|
||||
|
||||
if (!tx_macro_get_data(codec, &tx_dev, &tx_priv, __func__))
|
||||
if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
|
||||
return -EINVAL;
|
||||
|
||||
if (enable) {
|
||||
@@ -530,7 +538,8 @@ static int tx_macro_tx_mixer_put(struct snd_kcontrol *kcontrol,
|
||||
static int tx_macro_enable_dmic(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_dapm_to_component(w->dapm);
|
||||
u8 dmic_clk_en = 0x01;
|
||||
u16 dmic_clk_reg = 0;
|
||||
s32 *dmic_clk_cnt = NULL;
|
||||
@@ -540,18 +549,18 @@ static int tx_macro_enable_dmic(struct snd_soc_dapm_widget *w,
|
||||
struct device *tx_dev = NULL;
|
||||
struct tx_macro_priv *tx_priv = NULL;
|
||||
|
||||
if (!tx_macro_get_data(codec, &tx_dev, &tx_priv, __func__))
|
||||
if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
|
||||
return -EINVAL;
|
||||
|
||||
wname = strpbrk(w->name, "01234567");
|
||||
if (!wname) {
|
||||
dev_err(codec->dev, "%s: widget not found\n", __func__);
|
||||
dev_err(component->dev, "%s: widget not found\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = kstrtouint(wname, 10, &dmic);
|
||||
if (ret < 0) {
|
||||
dev_err(codec->dev, "%s: Invalid DMIC line on the codec\n",
|
||||
dev_err(component->dev, "%s: Invalid DMIC line on the codec\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -578,30 +587,31 @@ static int tx_macro_enable_dmic(struct snd_soc_dapm_widget *w,
|
||||
dmic_clk_reg = BOLERO_CDC_VA_TOP_CSR_DMIC3_CTL;
|
||||
break;
|
||||
default:
|
||||
dev_err(codec->dev, "%s: Invalid DMIC Selection\n",
|
||||
dev_err(component->dev, "%s: Invalid DMIC Selection\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
dev_dbg(codec->dev, "%s: event %d DMIC%d dmic_clk_cnt %d\n",
|
||||
dev_dbg(component->dev, "%s: event %d DMIC%d dmic_clk_cnt %d\n",
|
||||
__func__, event, dmic, *dmic_clk_cnt);
|
||||
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_PRE_PMU:
|
||||
(*dmic_clk_cnt)++;
|
||||
if (*dmic_clk_cnt == 1) {
|
||||
snd_soc_update_bits(codec, BOLERO_CDC_VA_TOP_CSR_DMIC_CFG,
|
||||
snd_soc_component_update_bits(component,
|
||||
BOLERO_CDC_VA_TOP_CSR_DMIC_CFG,
|
||||
0x80, 0x00);
|
||||
|
||||
snd_soc_update_bits(codec, dmic_clk_reg,
|
||||
snd_soc_component_update_bits(component, dmic_clk_reg,
|
||||
0x0E, tx_priv->dmic_clk_div << 0x1);
|
||||
snd_soc_update_bits(codec, dmic_clk_reg,
|
||||
snd_soc_component_update_bits(component, dmic_clk_reg,
|
||||
dmic_clk_en, dmic_clk_en);
|
||||
}
|
||||
break;
|
||||
case SND_SOC_DAPM_POST_PMD:
|
||||
(*dmic_clk_cnt)--;
|
||||
if (*dmic_clk_cnt == 0)
|
||||
snd_soc_update_bits(codec, dmic_clk_reg,
|
||||
snd_soc_component_update_bits(component, dmic_clk_reg,
|
||||
dmic_clk_en, 0);
|
||||
break;
|
||||
}
|
||||
@@ -612,7 +622,8 @@ static int tx_macro_enable_dmic(struct snd_soc_dapm_widget *w,
|
||||
static int tx_macro_enable_dec(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_dapm_to_component(w->dapm);
|
||||
unsigned int decimator = 0;
|
||||
u16 tx_vol_ctl_reg = 0;
|
||||
u16 dec_cfg_reg = 0;
|
||||
@@ -622,12 +633,12 @@ static int tx_macro_enable_dec(struct snd_soc_dapm_widget *w,
|
||||
struct device *tx_dev = NULL;
|
||||
struct tx_macro_priv *tx_priv = NULL;
|
||||
|
||||
if (!tx_macro_get_data(codec, &tx_dev, &tx_priv, __func__))
|
||||
if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
|
||||
return -EINVAL;
|
||||
|
||||
decimator = w->shift;
|
||||
|
||||
dev_dbg(codec->dev, "%s(): widget = %s decimator = %u\n", __func__,
|
||||
dev_dbg(component->dev, "%s(): widget = %s decimator = %u\n", __func__,
|
||||
w->name, decimator);
|
||||
|
||||
tx_vol_ctl_reg = BOLERO_CDC_TX0_TX_PATH_CTL +
|
||||
@@ -642,21 +653,27 @@ static int tx_macro_enable_dec(struct snd_soc_dapm_widget *w,
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_PRE_PMU:
|
||||
/* Enable TX PGA Mute */
|
||||
snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10);
|
||||
snd_soc_component_update_bits(component,
|
||||
tx_vol_ctl_reg, 0x10, 0x10);
|
||||
break;
|
||||
case SND_SOC_DAPM_POST_PMU:
|
||||
snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x20, 0x20);
|
||||
snd_soc_update_bits(codec, hpf_gate_reg, 0x01, 0x00);
|
||||
snd_soc_component_update_bits(component,
|
||||
tx_vol_ctl_reg, 0x20, 0x20);
|
||||
snd_soc_component_update_bits(component,
|
||||
hpf_gate_reg, 0x01, 0x00);
|
||||
|
||||
hpf_cut_off_freq = (snd_soc_read(codec, dec_cfg_reg) &
|
||||
hpf_cut_off_freq = (
|
||||
snd_soc_component_read32(component, dec_cfg_reg) &
|
||||
TX_HPF_CUT_OFF_FREQ_MASK) >> 5;
|
||||
|
||||
tx_priv->tx_hpf_work[decimator].hpf_cut_off_freq =
|
||||
hpf_cut_off_freq;
|
||||
|
||||
if (hpf_cut_off_freq != CF_MIN_3DB_150HZ)
|
||||
snd_soc_update_bits(codec, dec_cfg_reg,
|
||||
snd_soc_component_update_bits(component, dec_cfg_reg,
|
||||
TX_HPF_CUT_OFF_FREQ_MASK,
|
||||
CF_MIN_3DB_150HZ << 5);
|
||||
|
||||
/* schedule work queue to Remove Mute */
|
||||
schedule_delayed_work(&tx_priv->tx_mute_dwork[decimator].dwork,
|
||||
msecs_to_jiffies(tx_unmute_delay));
|
||||
@@ -665,35 +682,42 @@ static int tx_macro_enable_dec(struct snd_soc_dapm_widget *w,
|
||||
schedule_delayed_work(
|
||||
&tx_priv->tx_hpf_work[decimator].dwork,
|
||||
msecs_to_jiffies(300));
|
||||
snd_soc_update_bits(codec, hpf_gate_reg, 0x02, 0x02);
|
||||
snd_soc_component_update_bits(component,
|
||||
hpf_gate_reg, 0x02, 0x02);
|
||||
/*
|
||||
* Minimum 1 clk cycle delay is required as per HW spec
|
||||
*/
|
||||
usleep_range(1000, 1010);
|
||||
snd_soc_update_bits(codec, hpf_gate_reg, 0x02, 0x00);
|
||||
snd_soc_component_update_bits(component,
|
||||
hpf_gate_reg, 0x02, 0x00);
|
||||
}
|
||||
/* apply gain after decimator is enabled */
|
||||
snd_soc_write(codec, tx_gain_ctl_reg,
|
||||
snd_soc_read(codec, tx_gain_ctl_reg));
|
||||
snd_soc_component_write(component, tx_gain_ctl_reg,
|
||||
snd_soc_component_read32(component,
|
||||
tx_gain_ctl_reg));
|
||||
break;
|
||||
case SND_SOC_DAPM_PRE_PMD:
|
||||
hpf_cut_off_freq =
|
||||
tx_priv->tx_hpf_work[decimator].hpf_cut_off_freq;
|
||||
snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10);
|
||||
snd_soc_component_update_bits(component,
|
||||
tx_vol_ctl_reg, 0x10, 0x10);
|
||||
if (cancel_delayed_work_sync(
|
||||
&tx_priv->tx_hpf_work[decimator].dwork)) {
|
||||
if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) {
|
||||
snd_soc_update_bits(codec, dec_cfg_reg,
|
||||
snd_soc_component_update_bits(
|
||||
component, dec_cfg_reg,
|
||||
TX_HPF_CUT_OFF_FREQ_MASK,
|
||||
hpf_cut_off_freq << 5);
|
||||
snd_soc_update_bits(codec, hpf_gate_reg,
|
||||
snd_soc_component_update_bits(component,
|
||||
hpf_gate_reg,
|
||||
0x02, 0x02);
|
||||
/*
|
||||
* Minimum 1 clk cycle delay is required
|
||||
* as per HW spec
|
||||
*/
|
||||
usleep_range(1000, 1010);
|
||||
snd_soc_update_bits(codec, hpf_gate_reg,
|
||||
snd_soc_component_update_bits(component,
|
||||
hpf_gate_reg,
|
||||
0x02, 0x00);
|
||||
}
|
||||
}
|
||||
@@ -701,8 +725,10 @@ static int tx_macro_enable_dec(struct snd_soc_dapm_widget *w,
|
||||
&tx_priv->tx_mute_dwork[decimator].dwork);
|
||||
break;
|
||||
case SND_SOC_DAPM_POST_PMD:
|
||||
snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x20, 0x00);
|
||||
snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00);
|
||||
snd_soc_component_update_bits(component, tx_vol_ctl_reg,
|
||||
0x20, 0x00);
|
||||
snd_soc_component_update_bits(component, tx_vol_ctl_reg,
|
||||
0x10, 0x00);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
@@ -719,14 +745,14 @@ static int tx_macro_hw_params(struct snd_pcm_substream *substream,
|
||||
struct snd_soc_dai *dai)
|
||||
{
|
||||
int tx_fs_rate = -EINVAL;
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct snd_soc_component *component = dai->component;
|
||||
u32 decimator = 0;
|
||||
u32 sample_rate = 0;
|
||||
u16 tx_fs_reg = 0;
|
||||
struct device *tx_dev = NULL;
|
||||
struct tx_macro_priv *tx_priv = NULL;
|
||||
|
||||
if (!tx_macro_get_data(codec, &tx_dev, &tx_priv, __func__))
|
||||
if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
|
||||
return -EINVAL;
|
||||
|
||||
pr_debug("%s: dai_name = %s DAI-ID %x rate %d num_ch %d\n", __func__,
|
||||
@@ -757,7 +783,7 @@ static int tx_macro_hw_params(struct snd_pcm_substream *substream,
|
||||
tx_fs_rate = 7;
|
||||
break;
|
||||
default:
|
||||
dev_err(codec->dev, "%s: Invalid TX sample rate: %d\n",
|
||||
dev_err(component->dev, "%s: Invalid TX sample rate: %d\n",
|
||||
__func__, params_rate(params));
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -766,12 +792,12 @@ static int tx_macro_hw_params(struct snd_pcm_substream *substream,
|
||||
if (decimator >= 0) {
|
||||
tx_fs_reg = BOLERO_CDC_TX0_TX_PATH_CTL +
|
||||
TX_MACRO_TX_PATH_OFFSET * decimator;
|
||||
dev_dbg(codec->dev, "%s: set DEC%u rate to %u\n",
|
||||
dev_dbg(component->dev, "%s: set DEC%u rate to %u\n",
|
||||
__func__, decimator, sample_rate);
|
||||
snd_soc_update_bits(codec, tx_fs_reg, 0x0F,
|
||||
tx_fs_rate);
|
||||
snd_soc_component_update_bits(component, tx_fs_reg,
|
||||
0x0F, tx_fs_rate);
|
||||
} else {
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s: ERROR: Invalid decimator: %d\n",
|
||||
__func__, decimator);
|
||||
return -EINVAL;
|
||||
@@ -784,11 +810,11 @@ static int tx_macro_get_channel_map(struct snd_soc_dai *dai,
|
||||
unsigned int *tx_num, unsigned int *tx_slot,
|
||||
unsigned int *rx_num, unsigned int *rx_slot)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct snd_soc_component *component = dai->component;
|
||||
struct device *tx_dev = NULL;
|
||||
struct tx_macro_priv *tx_priv = NULL;
|
||||
|
||||
if (!tx_macro_get_data(codec, &tx_dev, &tx_priv, __func__))
|
||||
if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
|
||||
return -EINVAL;
|
||||
|
||||
switch (dai->id) {
|
||||
@@ -1483,22 +1509,23 @@ undefined_rate:
|
||||
return dmic_sample_rate;
|
||||
}
|
||||
|
||||
static int tx_macro_init(struct snd_soc_codec *codec)
|
||||
static int tx_macro_init(struct snd_soc_component *component)
|
||||
{
|
||||
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
|
||||
struct snd_soc_dapm_context *dapm =
|
||||
snd_soc_component_get_dapm(component);
|
||||
int ret = 0, i = 0;
|
||||
struct device *tx_dev = NULL;
|
||||
struct tx_macro_priv *tx_priv = NULL;
|
||||
|
||||
tx_dev = bolero_get_device_ptr(codec->dev, TX_MACRO);
|
||||
tx_dev = bolero_get_device_ptr(component->dev, TX_MACRO);
|
||||
if (!tx_dev) {
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s: null device for macro!\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
tx_priv = dev_get_drvdata(tx_dev);
|
||||
if (!tx_priv) {
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s: priv is null for macro!\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -1522,7 +1549,7 @@ static int tx_macro_init(struct snd_soc_codec *codec)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = snd_soc_add_codec_controls(codec, tx_macro_snd_controls,
|
||||
ret = snd_soc_add_component_controls(component, tx_macro_snd_controls,
|
||||
ARRAY_SIZE(tx_macro_snd_controls));
|
||||
if (ret < 0) {
|
||||
dev_err(tx_dev, "%s: Failed to add snd_ctls\n", __func__);
|
||||
@@ -1558,20 +1585,20 @@ static int tx_macro_init(struct snd_soc_codec *codec)
|
||||
INIT_DELAYED_WORK(&tx_priv->tx_mute_dwork[i].dwork,
|
||||
tx_macro_mute_update_callback);
|
||||
}
|
||||
tx_priv->codec = codec;
|
||||
tx_priv->component = component;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tx_macro_deinit(struct snd_soc_codec *codec)
|
||||
static int tx_macro_deinit(struct snd_soc_component *component)
|
||||
{
|
||||
struct device *tx_dev = NULL;
|
||||
struct tx_macro_priv *tx_priv = NULL;
|
||||
|
||||
if (!tx_macro_get_data(codec, &tx_dev, &tx_priv, __func__))
|
||||
if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
|
||||
return -EINVAL;
|
||||
|
||||
tx_priv->codec = NULL;
|
||||
tx_priv->component = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -95,7 +95,7 @@ struct va_macro_priv {
|
||||
bool va_without_decimation;
|
||||
struct clk *va_core_clk;
|
||||
struct mutex mclk_lock;
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
struct hpf_work va_hpf_work[VA_MACRO_NUM_DECIMATORS];
|
||||
struct va_mute_work va_mute_dwork[VA_MACRO_NUM_DECIMATORS];
|
||||
unsigned long active_ch_mask[VA_MACRO_MAX_DAIS];
|
||||
@@ -113,20 +113,20 @@ struct va_macro_priv {
|
||||
int micb_users;
|
||||
};
|
||||
|
||||
static bool va_macro_get_data(struct snd_soc_codec *codec,
|
||||
static bool va_macro_get_data(struct snd_soc_component *component,
|
||||
struct device **va_dev,
|
||||
struct va_macro_priv **va_priv,
|
||||
const char *func_name)
|
||||
{
|
||||
*va_dev = bolero_get_device_ptr(codec->dev, VA_MACRO);
|
||||
*va_dev = bolero_get_device_ptr(component->dev, VA_MACRO);
|
||||
if (!(*va_dev)) {
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s: null device for macro!\n", func_name);
|
||||
return false;
|
||||
}
|
||||
*va_priv = dev_get_drvdata((*va_dev));
|
||||
if (!(*va_priv) || !(*va_priv)->codec) {
|
||||
dev_err(codec->dev,
|
||||
if (!(*va_priv) || !(*va_priv)->component) {
|
||||
dev_err(component->dev,
|
||||
"%s: priv is null for macro!\n", func_name);
|
||||
return false;
|
||||
}
|
||||
@@ -200,14 +200,14 @@ exit:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int va_macro_event_handler(struct snd_soc_codec *codec, u16 event,
|
||||
u32 data)
|
||||
static int va_macro_event_handler(struct snd_soc_component *component,
|
||||
u16 event, u32 data)
|
||||
{
|
||||
struct device *va_dev = NULL;
|
||||
struct va_macro_priv *va_priv = NULL;
|
||||
int retry_cnt = MAX_RETRY_ATTEMPTS;
|
||||
|
||||
if (!va_macro_get_data(codec, &va_dev, &va_priv, __func__))
|
||||
if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
|
||||
return -EINVAL;
|
||||
|
||||
switch (event) {
|
||||
@@ -237,12 +237,13 @@ static int va_macro_event_handler(struct snd_soc_codec *codec, u16 event,
|
||||
static int va_macro_mclk_event(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_dapm_to_component(w->dapm);
|
||||
int ret = 0;
|
||||
struct device *va_dev = NULL;
|
||||
struct va_macro_priv *va_priv = NULL;
|
||||
|
||||
if (!va_macro_get_data(codec, &va_dev, &va_priv, __func__))
|
||||
if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
|
||||
return -EINVAL;
|
||||
|
||||
dev_dbg(va_dev, "%s: event = %d\n", __func__, event);
|
||||
@@ -285,14 +286,14 @@ static void va_macro_tx_hpf_corner_freq_callback(struct work_struct *work)
|
||||
struct delayed_work *hpf_delayed_work;
|
||||
struct hpf_work *hpf_work;
|
||||
struct va_macro_priv *va_priv;
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
u16 dec_cfg_reg, hpf_gate_reg;
|
||||
u8 hpf_cut_off_freq;
|
||||
|
||||
hpf_delayed_work = to_delayed_work(work);
|
||||
hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork);
|
||||
va_priv = hpf_work->va_priv;
|
||||
codec = va_priv->codec;
|
||||
component = va_priv->component;
|
||||
hpf_cut_off_freq = hpf_work->hpf_cut_off_freq;
|
||||
|
||||
dec_cfg_reg = BOLERO_CDC_VA_TX0_TX_PATH_CFG0 +
|
||||
@@ -303,18 +304,19 @@ static void va_macro_tx_hpf_corner_freq_callback(struct work_struct *work)
|
||||
dev_dbg(va_priv->dev, "%s: decimator %u hpf_cut_of_freq 0x%x\n",
|
||||
__func__, hpf_work->decimator, hpf_cut_off_freq);
|
||||
|
||||
snd_soc_update_bits(codec, dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK,
|
||||
snd_soc_component_update_bits(component,
|
||||
dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK,
|
||||
hpf_cut_off_freq << 5);
|
||||
snd_soc_update_bits(codec, hpf_gate_reg, 0x03, 0x02);
|
||||
snd_soc_component_update_bits(component, hpf_gate_reg, 0x03, 0x02);
|
||||
/* Minimum 1 clk cycle delay is required as per HW spec */
|
||||
usleep_range(1000, 1010);
|
||||
snd_soc_update_bits(codec, hpf_gate_reg, 0x03, 0x01);
|
||||
snd_soc_component_update_bits(component, hpf_gate_reg, 0x03, 0x01);
|
||||
}
|
||||
|
||||
static void va_macro_mute_update_callback(struct work_struct *work)
|
||||
{
|
||||
struct va_mute_work *va_mute_dwork;
|
||||
struct snd_soc_codec *codec = NULL;
|
||||
struct snd_soc_component *component = NULL;
|
||||
struct va_macro_priv *va_priv;
|
||||
struct delayed_work *delayed_work;
|
||||
u16 tx_vol_ctl_reg, decimator;
|
||||
@@ -322,13 +324,13 @@ static void va_macro_mute_update_callback(struct work_struct *work)
|
||||
delayed_work = to_delayed_work(work);
|
||||
va_mute_dwork = container_of(delayed_work, struct va_mute_work, dwork);
|
||||
va_priv = va_mute_dwork->va_priv;
|
||||
codec = va_priv->codec;
|
||||
component = va_priv->component;
|
||||
decimator = va_mute_dwork->decimator;
|
||||
|
||||
tx_vol_ctl_reg =
|
||||
BOLERO_CDC_VA_TX0_TX_PATH_CTL +
|
||||
VA_MACRO_TX_PATH_OFFSET * decimator;
|
||||
snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00);
|
||||
snd_soc_component_update_bits(component, tx_vol_ctl_reg, 0x10, 0x00);
|
||||
dev_dbg(va_priv->dev, "%s: decimator %u unmute\n",
|
||||
__func__, decimator);
|
||||
}
|
||||
@@ -338,7 +340,8 @@ static int va_macro_put_dec_enum(struct snd_kcontrol *kcontrol,
|
||||
{
|
||||
struct snd_soc_dapm_widget *widget =
|
||||
snd_soc_dapm_kcontrol_widget(kcontrol);
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_dapm_to_component(widget->dapm);
|
||||
struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
|
||||
unsigned int val;
|
||||
u16 mic_sel_reg;
|
||||
@@ -347,7 +350,7 @@ static int va_macro_put_dec_enum(struct snd_kcontrol *kcontrol,
|
||||
if (val > e->items - 1)
|
||||
return -EINVAL;
|
||||
|
||||
dev_dbg(codec->dev, "%s: wname: %s, val: 0x%x\n", __func__,
|
||||
dev_dbg(component->dev, "%s: wname: %s, val: 0x%x\n", __func__,
|
||||
widget->name, val);
|
||||
|
||||
switch (e->reg) {
|
||||
@@ -376,13 +379,14 @@ static int va_macro_put_dec_enum(struct snd_kcontrol *kcontrol,
|
||||
mic_sel_reg = BOLERO_CDC_VA_TX7_TX_PATH_CFG0;
|
||||
break;
|
||||
default:
|
||||
dev_err(codec->dev, "%s: e->reg: 0x%x not expected\n",
|
||||
dev_err(component->dev, "%s: e->reg: 0x%x not expected\n",
|
||||
__func__, e->reg);
|
||||
return -EINVAL;
|
||||
}
|
||||
/* DMIC selected */
|
||||
if (val != 0)
|
||||
snd_soc_update_bits(codec, mic_sel_reg, 1 << 7, 1 << 7);
|
||||
snd_soc_component_update_bits(component, mic_sel_reg,
|
||||
1 << 7, 1 << 7);
|
||||
|
||||
return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
|
||||
}
|
||||
@@ -392,7 +396,8 @@ static int va_macro_tx_mixer_get(struct snd_kcontrol *kcontrol,
|
||||
{
|
||||
struct snd_soc_dapm_widget *widget =
|
||||
snd_soc_dapm_kcontrol_widget(kcontrol);
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_dapm_to_component(widget->dapm);
|
||||
struct soc_multi_mixer_control *mixer =
|
||||
((struct soc_multi_mixer_control *)kcontrol->private_value);
|
||||
u32 dai_id = widget->shift;
|
||||
@@ -400,7 +405,7 @@ static int va_macro_tx_mixer_get(struct snd_kcontrol *kcontrol,
|
||||
struct device *va_dev = NULL;
|
||||
struct va_macro_priv *va_priv = NULL;
|
||||
|
||||
if (!va_macro_get_data(codec, &va_dev, &va_priv, __func__))
|
||||
if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
|
||||
return -EINVAL;
|
||||
|
||||
if (test_bit(dec_id, &va_priv->active_ch_mask[dai_id]))
|
||||
@@ -415,7 +420,8 @@ static int va_macro_tx_mixer_put(struct snd_kcontrol *kcontrol,
|
||||
{
|
||||
struct snd_soc_dapm_widget *widget =
|
||||
snd_soc_dapm_kcontrol_widget(kcontrol);
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_dapm_to_component(widget->dapm);
|
||||
struct snd_soc_dapm_update *update = NULL;
|
||||
struct soc_multi_mixer_control *mixer =
|
||||
((struct soc_multi_mixer_control *)kcontrol->private_value);
|
||||
@@ -425,7 +431,7 @@ static int va_macro_tx_mixer_put(struct snd_kcontrol *kcontrol,
|
||||
struct device *va_dev = NULL;
|
||||
struct va_macro_priv *va_priv = NULL;
|
||||
|
||||
if (!va_macro_get_data(codec, &va_dev, &va_priv, __func__))
|
||||
if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
|
||||
return -EINVAL;
|
||||
|
||||
if (enable) {
|
||||
@@ -444,7 +450,8 @@ static int va_macro_tx_mixer_put(struct snd_kcontrol *kcontrol,
|
||||
static int va_macro_enable_dmic(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_dapm_to_component(w->dapm);
|
||||
u8 dmic_clk_en = 0x01;
|
||||
u16 dmic_clk_reg;
|
||||
s32 *dmic_clk_cnt;
|
||||
@@ -454,7 +461,7 @@ static int va_macro_enable_dmic(struct snd_soc_dapm_widget *w,
|
||||
struct device *va_dev = NULL;
|
||||
struct va_macro_priv *va_priv = NULL;
|
||||
|
||||
if (!va_macro_get_data(codec, &va_dev, &va_priv, __func__))
|
||||
if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
|
||||
return -EINVAL;
|
||||
|
||||
wname = strpbrk(w->name, "01234567");
|
||||
@@ -503,21 +510,21 @@ static int va_macro_enable_dmic(struct snd_soc_dapm_widget *w,
|
||||
case SND_SOC_DAPM_PRE_PMU:
|
||||
(*dmic_clk_cnt)++;
|
||||
if (*dmic_clk_cnt == 1) {
|
||||
snd_soc_update_bits(codec,
|
||||
snd_soc_component_update_bits(component,
|
||||
BOLERO_CDC_VA_TOP_CSR_DMIC_CFG,
|
||||
0x80, 0x00);
|
||||
snd_soc_update_bits(codec, dmic_clk_reg,
|
||||
snd_soc_component_update_bits(component, dmic_clk_reg,
|
||||
VA_MACRO_TX_DMIC_CLK_DIV_MASK,
|
||||
va_priv->dmic_clk_div <<
|
||||
VA_MACRO_TX_DMIC_CLK_DIV_SHFT);
|
||||
snd_soc_update_bits(codec, dmic_clk_reg,
|
||||
snd_soc_component_update_bits(component, dmic_clk_reg,
|
||||
dmic_clk_en, dmic_clk_en);
|
||||
}
|
||||
break;
|
||||
case SND_SOC_DAPM_POST_PMD:
|
||||
(*dmic_clk_cnt)--;
|
||||
if (*dmic_clk_cnt == 0) {
|
||||
snd_soc_update_bits(codec, dmic_clk_reg,
|
||||
snd_soc_component_update_bits(component, dmic_clk_reg,
|
||||
dmic_clk_en, 0);
|
||||
}
|
||||
break;
|
||||
@@ -529,7 +536,8 @@ static int va_macro_enable_dmic(struct snd_soc_dapm_widget *w,
|
||||
static int va_macro_enable_dec(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_dapm_to_component(w->dapm);
|
||||
unsigned int decimator;
|
||||
u16 tx_vol_ctl_reg, dec_cfg_reg, hpf_gate_reg;
|
||||
u16 tx_gain_ctl_reg;
|
||||
@@ -537,7 +545,7 @@ static int va_macro_enable_dec(struct snd_soc_dapm_widget *w,
|
||||
struct device *va_dev = NULL;
|
||||
struct va_macro_priv *va_priv = NULL;
|
||||
|
||||
if (!va_macro_get_data(codec, &va_dev, &va_priv, __func__))
|
||||
if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
|
||||
return -EINVAL;
|
||||
|
||||
decimator = w->shift;
|
||||
@@ -557,28 +565,34 @@ static int va_macro_enable_dec(struct snd_soc_dapm_widget *w,
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_PRE_PMU:
|
||||
/* Enable TX PGA Mute */
|
||||
snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10);
|
||||
snd_soc_component_update_bits(component,
|
||||
tx_vol_ctl_reg, 0x10, 0x10);
|
||||
break;
|
||||
case SND_SOC_DAPM_POST_PMU:
|
||||
/* Enable TX CLK */
|
||||
snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x20, 0x20);
|
||||
snd_soc_update_bits(codec, hpf_gate_reg, 0x01, 0x00);
|
||||
snd_soc_component_update_bits(component,
|
||||
tx_vol_ctl_reg, 0x20, 0x20);
|
||||
snd_soc_component_update_bits(component,
|
||||
hpf_gate_reg, 0x01, 0x00);
|
||||
|
||||
hpf_cut_off_freq = (snd_soc_read(codec, dec_cfg_reg) &
|
||||
hpf_cut_off_freq = (snd_soc_component_read32(
|
||||
component, dec_cfg_reg) &
|
||||
TX_HPF_CUT_OFF_FREQ_MASK) >> 5;
|
||||
va_priv->va_hpf_work[decimator].hpf_cut_off_freq =
|
||||
hpf_cut_off_freq;
|
||||
|
||||
if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) {
|
||||
snd_soc_update_bits(codec, dec_cfg_reg,
|
||||
snd_soc_component_update_bits(component, dec_cfg_reg,
|
||||
TX_HPF_CUT_OFF_FREQ_MASK,
|
||||
CF_MIN_3DB_150HZ << 5);
|
||||
snd_soc_update_bits(codec, hpf_gate_reg, 0x02, 0x02);
|
||||
snd_soc_component_update_bits(component,
|
||||
hpf_gate_reg, 0x02, 0x02);
|
||||
/*
|
||||
* Minimum 1 clk cycle delay is required as per HW spec
|
||||
*/
|
||||
usleep_range(1000, 1010);
|
||||
snd_soc_update_bits(codec, hpf_gate_reg, 0x02, 0x00);
|
||||
snd_soc_component_update_bits(component,
|
||||
hpf_gate_reg, 0x02, 0x00);
|
||||
}
|
||||
/* schedule work queue to Remove Mute */
|
||||
schedule_delayed_work(&va_priv->va_mute_dwork[decimator].dwork,
|
||||
@@ -589,27 +603,31 @@ static int va_macro_enable_dec(struct snd_soc_dapm_widget *w,
|
||||
&va_priv->va_hpf_work[decimator].dwork,
|
||||
msecs_to_jiffies(300));
|
||||
/* apply gain after decimator is enabled */
|
||||
snd_soc_write(codec, tx_gain_ctl_reg,
|
||||
snd_soc_read(codec, tx_gain_ctl_reg));
|
||||
snd_soc_component_write(component, tx_gain_ctl_reg,
|
||||
snd_soc_component_read32(component, tx_gain_ctl_reg));
|
||||
break;
|
||||
case SND_SOC_DAPM_PRE_PMD:
|
||||
hpf_cut_off_freq =
|
||||
va_priv->va_hpf_work[decimator].hpf_cut_off_freq;
|
||||
snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10);
|
||||
snd_soc_component_update_bits(component, tx_vol_ctl_reg,
|
||||
0x10, 0x10);
|
||||
if (cancel_delayed_work_sync(
|
||||
&va_priv->va_hpf_work[decimator].dwork)) {
|
||||
if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) {
|
||||
snd_soc_update_bits(codec, dec_cfg_reg,
|
||||
snd_soc_component_update_bits(component,
|
||||
dec_cfg_reg,
|
||||
TX_HPF_CUT_OFF_FREQ_MASK,
|
||||
hpf_cut_off_freq << 5);
|
||||
snd_soc_update_bits(codec, hpf_gate_reg,
|
||||
snd_soc_component_update_bits(component,
|
||||
hpf_gate_reg,
|
||||
0x02, 0x02);
|
||||
/*
|
||||
* Minimum 1 clk cycle delay is required
|
||||
* as per HW spec
|
||||
*/
|
||||
usleep_range(1000, 1010);
|
||||
snd_soc_update_bits(codec, hpf_gate_reg,
|
||||
snd_soc_component_update_bits(component,
|
||||
hpf_gate_reg,
|
||||
0x02, 0x00);
|
||||
}
|
||||
}
|
||||
@@ -618,8 +636,10 @@ static int va_macro_enable_dec(struct snd_soc_dapm_widget *w,
|
||||
break;
|
||||
case SND_SOC_DAPM_POST_PMD:
|
||||
/* Disable TX CLK */
|
||||
snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x20, 0x00);
|
||||
snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00);
|
||||
snd_soc_component_update_bits(component, tx_vol_ctl_reg,
|
||||
0x20, 0x00);
|
||||
snd_soc_component_update_bits(component, tx_vol_ctl_reg,
|
||||
0x10, 0x00);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
@@ -628,12 +648,13 @@ static int va_macro_enable_dec(struct snd_soc_dapm_widget *w,
|
||||
static int va_macro_enable_micbias(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_dapm_to_component(w->dapm);
|
||||
struct device *va_dev = NULL;
|
||||
struct va_macro_priv *va_priv = NULL;
|
||||
int ret = 0;
|
||||
|
||||
if (!va_macro_get_data(codec, &va_dev, &va_priv, __func__))
|
||||
if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
|
||||
return -EINVAL;
|
||||
|
||||
if (!va_priv->micb_supply) {
|
||||
@@ -695,13 +716,13 @@ static int va_macro_hw_params(struct snd_pcm_substream *substream,
|
||||
struct snd_soc_dai *dai)
|
||||
{
|
||||
int tx_fs_rate = -EINVAL;
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct snd_soc_component *component = dai->component;
|
||||
u32 decimator, sample_rate;
|
||||
u16 tx_fs_reg = 0;
|
||||
struct device *va_dev = NULL;
|
||||
struct va_macro_priv *va_priv = NULL;
|
||||
|
||||
if (!va_macro_get_data(codec, &va_dev, &va_priv, __func__))
|
||||
if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
|
||||
return -EINVAL;
|
||||
|
||||
dev_dbg(va_dev,
|
||||
@@ -744,8 +765,8 @@ static int va_macro_hw_params(struct snd_pcm_substream *substream,
|
||||
VA_MACRO_TX_PATH_OFFSET * decimator;
|
||||
dev_dbg(va_dev, "%s: set DEC%u rate to %u\n",
|
||||
__func__, decimator, sample_rate);
|
||||
snd_soc_update_bits(codec, tx_fs_reg, 0x0F,
|
||||
tx_fs_rate);
|
||||
snd_soc_component_update_bits(component, tx_fs_reg,
|
||||
0x0F, tx_fs_rate);
|
||||
} else {
|
||||
dev_err(va_dev,
|
||||
"%s: ERROR: Invalid decimator: %d\n",
|
||||
@@ -760,11 +781,11 @@ static int va_macro_get_channel_map(struct snd_soc_dai *dai,
|
||||
unsigned int *tx_num, unsigned int *tx_slot,
|
||||
unsigned int *rx_num, unsigned int *rx_slot)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct snd_soc_component *component = dai->component;
|
||||
struct device *va_dev = NULL;
|
||||
struct va_macro_priv *va_priv = NULL;
|
||||
|
||||
if (!va_macro_get_data(codec, &va_dev, &va_priv, __func__))
|
||||
if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
|
||||
return -EINVAL;
|
||||
|
||||
switch (dai->id) {
|
||||
@@ -1393,22 +1414,23 @@ undefined_rate:
|
||||
return dmic_sample_rate;
|
||||
}
|
||||
|
||||
static int va_macro_init(struct snd_soc_codec *codec)
|
||||
static int va_macro_init(struct snd_soc_component *component)
|
||||
{
|
||||
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
|
||||
struct snd_soc_dapm_context *dapm =
|
||||
snd_soc_component_get_dapm(component);
|
||||
int ret, i;
|
||||
struct device *va_dev = NULL;
|
||||
struct va_macro_priv *va_priv = NULL;
|
||||
|
||||
va_dev = bolero_get_device_ptr(codec->dev, VA_MACRO);
|
||||
va_dev = bolero_get_device_ptr(component->dev, VA_MACRO);
|
||||
if (!va_dev) {
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s: null device for macro!\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
va_priv = dev_get_drvdata(va_dev);
|
||||
if (!va_priv) {
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s: priv is null for macro!\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -1422,7 +1444,7 @@ static int va_macro_init(struct snd_soc_codec *codec)
|
||||
__func__);
|
||||
return ret;
|
||||
}
|
||||
va_priv->codec = codec;
|
||||
va_priv->component = component;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1445,7 +1467,7 @@ static int va_macro_init(struct snd_soc_codec *codec)
|
||||
dev_err(va_dev, "%s: Failed to add widgets\n", __func__);
|
||||
return ret;
|
||||
}
|
||||
ret = snd_soc_add_codec_controls(codec, va_macro_snd_controls,
|
||||
ret = snd_soc_add_component_controls(component, va_macro_snd_controls,
|
||||
ARRAY_SIZE(va_macro_snd_controls));
|
||||
if (ret < 0) {
|
||||
dev_err(va_dev, "%s: Failed to add snd_ctls\n", __func__);
|
||||
@@ -1481,20 +1503,20 @@ static int va_macro_init(struct snd_soc_codec *codec)
|
||||
INIT_DELAYED_WORK(&va_priv->va_mute_dwork[i].dwork,
|
||||
va_macro_mute_update_callback);
|
||||
}
|
||||
va_priv->codec = codec;
|
||||
va_priv->component = component;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int va_macro_deinit(struct snd_soc_codec *codec)
|
||||
static int va_macro_deinit(struct snd_soc_component *component)
|
||||
{
|
||||
struct device *va_dev = NULL;
|
||||
struct va_macro_priv *va_priv = NULL;
|
||||
|
||||
if (!va_macro_get_data(codec, &va_dev, &va_priv, __func__))
|
||||
if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
|
||||
return -EINVAL;
|
||||
|
||||
va_priv->codec = NULL;
|
||||
va_priv->component = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
文件差异内容过多而无法显示
加载差异
@@ -21,15 +21,18 @@ enum {
|
||||
|
||||
|
||||
#if IS_ENABLED(CONFIG_WSA_MACRO)
|
||||
extern int wsa_macro_set_spkr_mode(struct snd_soc_codec *codec, int mode);
|
||||
extern int wsa_macro_set_spkr_gain_offset(struct snd_soc_codec *codec,
|
||||
extern int wsa_macro_set_spkr_mode(struct snd_soc_component *component,
|
||||
int mode);
|
||||
extern int wsa_macro_set_spkr_gain_offset(struct snd_soc_component *component,
|
||||
int offset);
|
||||
#else /* CONFIG_WSA_MACRO */
|
||||
static inline int wsa_macro_set_spkr_mode(struct snd_soc_codec *codec, int mode)
|
||||
static inline int wsa_macro_set_spkr_mode(struct snd_soc_component *component,
|
||||
int mode)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static inline int wsa_macro_set_spkr_gain_offset(struct snd_soc_codec *codec,
|
||||
static inline int wsa_macro_set_spkr_gain_offset(
|
||||
struct snd_soc_component *component,
|
||||
int offset);
|
||||
{
|
||||
return 0;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __CPE_CORE_H__
|
||||
@@ -107,35 +107,37 @@ struct wcd_cpe_lsm_ops {
|
||||
u8 size, u8 *payload));
|
||||
|
||||
int (*lsm_dealloc_session)
|
||||
(void *core_handle, struct cpe_lsm_session *);
|
||||
(void *core_handle, struct cpe_lsm_session *session);
|
||||
|
||||
int (*lsm_open_tx)(void *core_handle,
|
||||
struct cpe_lsm_session *, u16, u16);
|
||||
struct cpe_lsm_session *session, u16 app_id,
|
||||
u16 sample_rate);
|
||||
|
||||
int (*lsm_close_tx)(void *core_handle,
|
||||
struct cpe_lsm_session *);
|
||||
struct cpe_lsm_session *session);
|
||||
|
||||
int (*lsm_shmem_alloc)(void *core_handle,
|
||||
struct cpe_lsm_session *, u32 size);
|
||||
struct cpe_lsm_session *session, u32 size);
|
||||
|
||||
int (*lsm_shmem_dealloc)(void *core_handle,
|
||||
struct cpe_lsm_session *);
|
||||
struct cpe_lsm_session *session);
|
||||
|
||||
int (*lsm_register_snd_model)(void *core_handle,
|
||||
struct cpe_lsm_session *,
|
||||
enum lsm_detection_mode, bool);
|
||||
struct cpe_lsm_session *session,
|
||||
enum lsm_detection_mode,
|
||||
bool detect_failure);
|
||||
|
||||
int (*lsm_deregister_snd_model)(void *core_handle,
|
||||
struct cpe_lsm_session *);
|
||||
struct cpe_lsm_session *session);
|
||||
|
||||
int (*lsm_get_afe_out_port_id)(void *core_handle,
|
||||
struct cpe_lsm_session *session);
|
||||
|
||||
int (*lsm_start)(void *core_handle,
|
||||
struct cpe_lsm_session *);
|
||||
struct cpe_lsm_session *session);
|
||||
|
||||
int (*lsm_stop)(void *core_handle,
|
||||
struct cpe_lsm_session *);
|
||||
struct cpe_lsm_session *session);
|
||||
|
||||
int (*lsm_lab_control)(void *core_handle,
|
||||
struct cpe_lsm_session *session,
|
||||
@@ -156,7 +158,7 @@ struct wcd_cpe_lsm_ops {
|
||||
struct lsm_params_info *p_info,
|
||||
void *data, uint32_t param_type);
|
||||
void (*lsm_get_snd_model_offset)
|
||||
(void *core_handle, struct cpe_lsm_session *,
|
||||
(void *core_handle, struct cpe_lsm_session *session,
|
||||
size_t *offset);
|
||||
int (*lsm_set_media_fmt_params)(void *core_handle,
|
||||
struct cpe_lsm_session *session,
|
||||
@@ -168,7 +170,7 @@ struct wcd_cpe_lsm_ops {
|
||||
#if IS_ENABLED(CONFIG_SND_SOC_WCD_CPE)
|
||||
int wcd_cpe_get_lsm_ops(struct wcd_cpe_lsm_ops *lsm_ops);
|
||||
int wcd_cpe_get_afe_ops(struct wcd_cpe_afe_ops *afe_ops);
|
||||
void *wcd_cpe_get_core_handle(struct snd_soc_codec *codec);
|
||||
void *wcd_cpe_get_core_handle(struct snd_soc_component *component);
|
||||
#else /* CONFIG_SND_SOC_WCD_CPE */
|
||||
static inline int wcd_cpe_get_lsm_ops(struct wcd_cpe_lsm_ops *lsm_ops)
|
||||
{
|
||||
@@ -178,7 +180,7 @@ static inline int wcd_cpe_get_afe_ops(struct wcd_cpe_afe_ops *afe_ops)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static inline void *wcd_cpe_get_core_handle(struct snd_soc_codec *codec)
|
||||
static inline void *wcd_cpe_get_core_handle(struct snd_soc_component *component)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
@@ -19,6 +19,8 @@
|
||||
#include <linux/debugfs.h>
|
||||
#include "csra66x0.h"
|
||||
|
||||
#define DRV_NAME "csra66x0_codec"
|
||||
|
||||
/* CSRA66X0 register default values */
|
||||
static struct reg_default csra66x0_reg_defaults[] = {
|
||||
{CSRA66X0_AUDIO_IF_RX_CONFIG1, 0x00},
|
||||
@@ -247,7 +249,7 @@ static bool csra66x0_readable_registers(struct device *dev, unsigned int reg)
|
||||
/* codec private data */
|
||||
struct csra66x0_priv {
|
||||
struct regmap *regmap;
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
int spk_volume_ch1;
|
||||
int spk_volume_ch2;
|
||||
int irq;
|
||||
@@ -312,7 +314,7 @@ static ssize_t debugfs_codec_write_op(struct file *filp,
|
||||
{
|
||||
struct csra66x0_priv *csra66x0 =
|
||||
(struct csra66x0_priv *) filp->private_data;
|
||||
struct snd_soc_codec *codec = csra66x0->codec;
|
||||
struct snd_soc_component *component = csra66x0->component;
|
||||
char lbuf[32];
|
||||
int rc;
|
||||
u32 param[2];
|
||||
@@ -328,46 +330,47 @@ static ssize_t debugfs_codec_write_op(struct file *filp,
|
||||
rc = debugfs_get_parameters(lbuf, param, 2);
|
||||
if ((param[0] < CSRA66X0_AUDIO_IF_RX_CONFIG1)
|
||||
|| (param[0] > CSRA66X0_MAX_REGISTER_ADDR)) {
|
||||
dev_err(codec->dev, "%s: register address 0x%04X out of range\n",
|
||||
dev_err(component->dev, "%s: register address 0x%04X out of range\n",
|
||||
__func__, param[0]);
|
||||
return -EINVAL;
|
||||
}
|
||||
if ((param[1] < 0) || (param[1] > 255)) {
|
||||
dev_err(codec->dev, "%s: register data 0x%02X out of range\n",
|
||||
dev_err(component->dev, "%s: register data 0x%02X out of range\n",
|
||||
__func__, param[1]);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (rc == 0)
|
||||
{
|
||||
rc = cnt;
|
||||
dev_info(codec->dev, "%s: reg[0x%04X]=0x%02X\n",
|
||||
dev_info(component->dev, "%s: reg[0x%04X]=0x%02X\n",
|
||||
__func__, param[0], param[1]);
|
||||
snd_soc_write(codec, param[0], param[1]);
|
||||
snd_soc_component_write(component, param[0], param[1]);
|
||||
} else {
|
||||
dev_err(codec->dev, "%s: write to register addr=0x%04X failed\n",
|
||||
dev_err(component->dev, "%s: write to register addr=0x%04X failed\n",
|
||||
__func__, param[0]);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
static ssize_t debugfs_csra66x0_reg_show(struct snd_soc_codec *codec,
|
||||
static ssize_t debugfs_csra66x0_reg_show(struct snd_soc_component *component,
|
||||
char __user *ubuf, size_t count, loff_t *ppos)
|
||||
{
|
||||
int i, reg_val, len;
|
||||
ssize_t total = 0;
|
||||
char tmp_buf[20];
|
||||
|
||||
if (!ubuf || !ppos || !codec || *ppos < 0)
|
||||
if (!ubuf || !ppos || !component || *ppos < 0)
|
||||
return -EINVAL;
|
||||
|
||||
for (i = ((int) *ppos + CSRA66X0_BASE);
|
||||
i <= CSRA66X0_MAX_REGISTER_ADDR; i++) {
|
||||
reg_val = snd_soc_read(codec, i);
|
||||
reg_val = snd_soc_component_read32(component, i);
|
||||
len = snprintf(tmp_buf, 20, "0x%04X: 0x%02X\n", i, (reg_val & 0xFF));
|
||||
if ((total + len) >= count - 1)
|
||||
break;
|
||||
if (copy_to_user((ubuf + total), tmp_buf, len)) {
|
||||
dev_err(codec->dev, "%s: fail to copy reg dump\n", __func__);
|
||||
dev_err(component->dev, "%s: fail to copy reg dump\n",
|
||||
__func__);
|
||||
total = -EFAULT;
|
||||
goto copy_err;
|
||||
}
|
||||
@@ -384,12 +387,12 @@ static ssize_t debugfs_codec_read_op(struct file *filp,
|
||||
{
|
||||
struct csra66x0_priv *csra66x0 =
|
||||
(struct csra66x0_priv *) filp->private_data;
|
||||
struct snd_soc_codec *codec = csra66x0->codec;
|
||||
struct snd_soc_component *component = csra66x0->component;
|
||||
ssize_t ret_cnt;
|
||||
|
||||
if (!filp || !ppos || !ubuf || *ppos < 0)
|
||||
return -EINVAL;
|
||||
ret_cnt = debugfs_csra66x0_reg_show(codec, ubuf, cnt, ppos);
|
||||
ret_cnt = debugfs_csra66x0_reg_show(component, ubuf, cnt, ppos);
|
||||
return ret_cnt;
|
||||
}
|
||||
|
||||
@@ -415,16 +418,17 @@ static int csra66x0_get_volume(struct snd_kcontrol *kcontrol,
|
||||
{
|
||||
struct soc_mixer_control *mc =
|
||||
(struct soc_mixer_control *)kcontrol->private_value;
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
unsigned int reg_l = mc->reg;
|
||||
unsigned int reg_r = mc->rreg;
|
||||
unsigned int val_l, val_r;
|
||||
|
||||
val_l = (snd_soc_read(codec, reg_l) & 0xff) |
|
||||
((snd_soc_read(codec,
|
||||
val_l = (snd_soc_component_read32(component, reg_l) & 0xff) |
|
||||
((snd_soc_component_read32(component,
|
||||
CSRA66X0_CH1_VOLUME_1_FA) & (0x01)) << 8);
|
||||
val_r = (snd_soc_read(codec, reg_r) & 0xff) |
|
||||
((snd_soc_read(codec,
|
||||
val_r = (snd_soc_component_read32(component, reg_r) & 0xff) |
|
||||
((snd_soc_component_read32(component,
|
||||
CSRA66X0_CH2_VOLUME_1_FA) & (0x01)) << 8);
|
||||
ucontrol->value.integer.value[0] = val_l;
|
||||
ucontrol->value.integer.value[1] = val_r;
|
||||
@@ -436,8 +440,10 @@ static int csra66x0_set_volume(struct snd_kcontrol *kcontrol,
|
||||
{
|
||||
struct soc_mixer_control *mc =
|
||||
(struct soc_mixer_control *)kcontrol->private_value;
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct csra66x0_priv *csra66x0 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct csra66x0_priv *csra66x0 =
|
||||
snd_soc_component_get_drvdata(component);
|
||||
unsigned int reg_l = mc->reg;
|
||||
unsigned int reg_r = mc->rreg;
|
||||
unsigned int val_l[2];
|
||||
@@ -449,10 +455,10 @@ static int csra66x0_set_volume(struct snd_kcontrol *kcontrol,
|
||||
val_l[1] = (csra66x0->spk_volume_ch1 & SPK_VOLUME_MSB_MSK) ? 1 : 0;
|
||||
val_r[0] = csra66x0->spk_volume_ch2 & SPK_VOLUME_LSB_MSK;
|
||||
val_r[1] = (csra66x0->spk_volume_ch2 & SPK_VOLUME_MSB_MSK) ? 1 : 0;
|
||||
snd_soc_write(codec, reg_l, val_l[0]);
|
||||
snd_soc_write(codec, reg_r, val_r[0]);
|
||||
snd_soc_write(codec, CSRA66X0_CH1_VOLUME_1_FA, val_l[1]);
|
||||
snd_soc_write(codec, CSRA66X0_CH2_VOLUME_1_FA, val_r[1]);
|
||||
snd_soc_component_write(component, reg_l, val_l[0]);
|
||||
snd_soc_component_write(component, reg_r, val_r[0]);
|
||||
snd_soc_component_write(component, CSRA66X0_CH1_VOLUME_1_FA, val_l[1]);
|
||||
snd_soc_component_write(component, CSRA66X0_CH2_VOLUME_1_FA, val_r[1]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -526,51 +532,66 @@ static const struct snd_soc_dapm_route csra66x0_dapm_routes[] = {
|
||||
|
||||
static int csra66x0_init(struct csra66x0_priv *csra66x0)
|
||||
{
|
||||
struct snd_soc_codec *codec = csra66x0->codec;
|
||||
struct snd_soc_component *component = csra66x0->component;
|
||||
|
||||
dev_dbg(codec->dev, "%s: initialize %s\n",
|
||||
__func__, codec->component.name);
|
||||
dev_dbg(component->dev, "%s: initialize %s\n",
|
||||
__func__, component->name);
|
||||
/* config */
|
||||
snd_soc_write(codec, CSRA66X0_CHIP_STATE_CTRL_FA, CONFIG_STATE);
|
||||
snd_soc_component_write(component, CSRA66X0_CHIP_STATE_CTRL_FA,
|
||||
CONFIG_STATE);
|
||||
/* settle time in HW is min. 500ms before proceeding */
|
||||
msleep(500);
|
||||
|
||||
/* setup */
|
||||
snd_soc_write(codec, CSRA66X0_MISC_CONTROL_STATUS_0, 0x09);
|
||||
snd_soc_write(codec, CSRA66X0_TEMP_PROT_BACKOFF, 0x0C);
|
||||
snd_soc_write(codec, CSRA66X0_EXT_PA_PROTECT_POLARITY, 0x03);
|
||||
snd_soc_write(codec, CSRA66X0_PWM_OUTPUT_CONFIG, 0xC8);
|
||||
snd_soc_component_write(component, CSRA66X0_MISC_CONTROL_STATUS_0,
|
||||
0x09);
|
||||
snd_soc_component_write(component, CSRA66X0_TEMP_PROT_BACKOFF, 0x0C);
|
||||
snd_soc_component_write(component, CSRA66X0_EXT_PA_PROTECT_POLARITY,
|
||||
0x03);
|
||||
snd_soc_component_write(component, CSRA66X0_PWM_OUTPUT_CONFIG, 0xC8);
|
||||
csra66x0->spk_volume_ch1 = SPK_VOLUME_M20DB;
|
||||
csra66x0->spk_volume_ch2 = SPK_VOLUME_M20DB;
|
||||
snd_soc_write(codec, CSRA66X0_CH1_VOLUME_0_FA, SPK_VOLUME_M20DB_LSB);
|
||||
snd_soc_write(codec, CSRA66X0_CH2_VOLUME_0_FA, SPK_VOLUME_M20DB_LSB);
|
||||
snd_soc_write(codec, CSRA66X0_CH1_VOLUME_1_FA, SPK_VOLUME_M20DB_MSB);
|
||||
snd_soc_write(codec, CSRA66X0_CH2_VOLUME_1_FA, SPK_VOLUME_M20DB_MSB);
|
||||
snd_soc_component_write(component, CSRA66X0_CH1_VOLUME_0_FA,
|
||||
SPK_VOLUME_M20DB_LSB);
|
||||
snd_soc_component_write(component, CSRA66X0_CH2_VOLUME_0_FA,
|
||||
SPK_VOLUME_M20DB_LSB);
|
||||
snd_soc_component_write(component, CSRA66X0_CH1_VOLUME_1_FA,
|
||||
SPK_VOLUME_M20DB_MSB);
|
||||
snd_soc_component_write(component, CSRA66X0_CH2_VOLUME_1_FA,
|
||||
SPK_VOLUME_M20DB_MSB);
|
||||
|
||||
snd_soc_write(codec, CSRA66X0_DEAD_TIME_CTRL, 0x0);
|
||||
snd_soc_write(codec, CSRA66X0_DEAD_TIME_THRESHOLD_0, 0xE7);
|
||||
snd_soc_write(codec, CSRA66X0_DEAD_TIME_THRESHOLD_1, 0x26);
|
||||
snd_soc_write(codec, CSRA66X0_DEAD_TIME_THRESHOLD_2, 0x40);
|
||||
snd_soc_component_write(component, CSRA66X0_DEAD_TIME_CTRL, 0x0);
|
||||
snd_soc_component_write(component, CSRA66X0_DEAD_TIME_THRESHOLD_0,
|
||||
0xE7);
|
||||
snd_soc_component_write(component, CSRA66X0_DEAD_TIME_THRESHOLD_1,
|
||||
0x26);
|
||||
snd_soc_component_write(component, CSRA66X0_DEAD_TIME_THRESHOLD_2,
|
||||
0x40);
|
||||
|
||||
snd_soc_write(codec, CSRA66X0_MIN_MODULATION_PULSE_WIDTH, 0x7A);
|
||||
snd_soc_write(codec, CSRA66X0_CH1_HARD_CLIP_THRESH, 0x00);
|
||||
snd_soc_write(codec, CSRA66X0_CH2_HARD_CLIP_THRESH, 0x00);
|
||||
snd_soc_component_write(component, CSRA66X0_MIN_MODULATION_PULSE_WIDTH,
|
||||
0x7A);
|
||||
snd_soc_component_write(component, CSRA66X0_CH1_HARD_CLIP_THRESH, 0x00);
|
||||
snd_soc_component_write(component, CSRA66X0_CH2_HARD_CLIP_THRESH, 0x00);
|
||||
|
||||
snd_soc_write(codec, CSRA66X0_CH1_DCA_THRESH, 0x40);
|
||||
snd_soc_write(codec, CSRA66X0_CH2_DCA_THRESH, 0x40);
|
||||
snd_soc_write(codec, CSRA66X0_DCA_ATTACK_RATE, 0x00);
|
||||
snd_soc_write(codec, CSRA66X0_DCA_RELEASE_RATE, 0x00);
|
||||
snd_soc_component_write(component, CSRA66X0_CH1_DCA_THRESH, 0x40);
|
||||
snd_soc_component_write(component, CSRA66X0_CH2_DCA_THRESH, 0x40);
|
||||
snd_soc_component_write(component, CSRA66X0_DCA_ATTACK_RATE, 0x00);
|
||||
snd_soc_component_write(component, CSRA66X0_DCA_RELEASE_RATE, 0x00);
|
||||
|
||||
if (csra66x0->irq) {
|
||||
snd_soc_write(codec, CSRA66X0_PIO0_SELECT, 0x1);
|
||||
snd_soc_component_write(component, CSRA66X0_PIO0_SELECT, 0x1);
|
||||
if (csra66x0->irq_active_low)
|
||||
snd_soc_write(codec, CSRA66X0_IRQ_OUTPUT_POLARITY, 0x0);
|
||||
snd_soc_component_write(component,
|
||||
CSRA66X0_IRQ_OUTPUT_POLARITY, 0x0);
|
||||
else
|
||||
snd_soc_write(codec, CSRA66X0_IRQ_OUTPUT_POLARITY, 0x1);
|
||||
snd_soc_component_write(component,
|
||||
CSRA66X0_IRQ_OUTPUT_POLARITY, 0x1);
|
||||
|
||||
snd_soc_write(codec, CSRA66X0_IRQ_OUTPUT_ENABLE, 0x01);
|
||||
snd_soc_component_write(component,
|
||||
CSRA66X0_IRQ_OUTPUT_ENABLE, 0x01);
|
||||
} else {
|
||||
snd_soc_write(codec, CSRA66X0_IRQ_OUTPUT_ENABLE, 0x00);
|
||||
snd_soc_component_write(component,
|
||||
CSRA66X0_IRQ_OUTPUT_ENABLE, 0x00);
|
||||
}
|
||||
/* settle time in HW is min. 500ms before slave initializing */
|
||||
msleep(500);
|
||||
@@ -579,37 +600,39 @@ static int csra66x0_init(struct csra66x0_priv *csra66x0)
|
||||
|
||||
static int csra66x0_reset(struct csra66x0_priv *csra66x0)
|
||||
{
|
||||
struct snd_soc_codec *codec = csra66x0->codec;
|
||||
struct snd_soc_component *component = csra66x0->component;
|
||||
u16 val;
|
||||
|
||||
val = snd_soc_read(codec, CSRA66X0_FAULT_STATUS_FA);
|
||||
val = snd_soc_component_read32(component, CSRA66X0_FAULT_STATUS_FA);
|
||||
if (val & FAULT_STATUS_INTERNAL)
|
||||
dev_dbg(codec->dev, "%s: FAULT_STATUS_INTERNAL 0x%X\n",
|
||||
dev_dbg(component->dev, "%s: FAULT_STATUS_INTERNAL 0x%X\n",
|
||||
__func__, val);
|
||||
if (val & FAULT_STATUS_OTP_INTEGRITY)
|
||||
dev_dbg(codec->dev, "%s: FAULT_STATUS_OTP_INTEGRITY 0x%X\n",
|
||||
dev_dbg(component->dev, "%s: FAULT_STATUS_OTP_INTEGRITY 0x%X\n",
|
||||
__func__, val);
|
||||
if (val & FAULT_STATUS_PADS2)
|
||||
dev_dbg(codec->dev, "%s: FAULT_STATUS_PADS2 0x%X\n",
|
||||
dev_dbg(component->dev, "%s: FAULT_STATUS_PADS2 0x%X\n",
|
||||
__func__, val);
|
||||
if (val & FAULT_STATUS_SMPS)
|
||||
dev_dbg(codec->dev, "%s: FAULT_STATUS_SMPS 0x%X\n",
|
||||
dev_dbg(component->dev, "%s: FAULT_STATUS_SMPS 0x%X\n",
|
||||
__func__, val);
|
||||
if (val & FAULT_STATUS_TEMP)
|
||||
dev_dbg(codec->dev, "%s: FAULT_STATUS_TEMP 0x%X\n",
|
||||
dev_dbg(component->dev, "%s: FAULT_STATUS_TEMP 0x%X\n",
|
||||
__func__, val);
|
||||
if (val & FAULT_STATUS_PROTECT)
|
||||
dev_dbg(codec->dev, "%s: FAULT_STATUS_PROTECT 0x%X\n",
|
||||
dev_dbg(component->dev, "%s: FAULT_STATUS_PROTECT 0x%X\n",
|
||||
__func__, val);
|
||||
|
||||
dev_dbg(codec->dev, "%s: reset %s\n",
|
||||
__func__, codec->component.name);
|
||||
dev_dbg(component->dev, "%s: reset %s\n",
|
||||
__func__, component->name);
|
||||
/* clear fault state and re-init */
|
||||
snd_soc_write(codec, CSRA66X0_FAULT_STATUS_FA, 0x00);
|
||||
snd_soc_write(codec, CSRA66X0_IRQ_OUTPUT_STATUS_FA, 0x00);
|
||||
snd_soc_component_write(component, CSRA66X0_FAULT_STATUS_FA, 0x00);
|
||||
snd_soc_component_write(component, CSRA66X0_IRQ_OUTPUT_STATUS_FA, 0x00);
|
||||
/* apply reset to CSRA66X0 */
|
||||
val = snd_soc_read(codec, CSRA66X0_MISC_CONTROL_STATUS_1_FA);
|
||||
snd_soc_write(codec, CSRA66X0_MISC_CONTROL_STATUS_1_FA, val | 0x08);
|
||||
val = snd_soc_component_read32(component,
|
||||
CSRA66X0_MISC_CONTROL_STATUS_1_FA);
|
||||
snd_soc_component_write(component, CSRA66X0_MISC_CONTROL_STATUS_1_FA,
|
||||
val | 0x08);
|
||||
/* wait 500ms after reset to recover CSRA66X0 */
|
||||
msleep(500);
|
||||
return 0;
|
||||
@@ -617,51 +640,58 @@ static int csra66x0_reset(struct csra66x0_priv *csra66x0)
|
||||
|
||||
static int csra66x0_msconfig(struct csra66x0_priv *csra66x0)
|
||||
{
|
||||
struct snd_soc_codec *codec = csra66x0->codec;
|
||||
struct snd_soc_component *component = csra66x0->component;
|
||||
|
||||
dev_dbg(codec->dev, "%s: configure %s\n",
|
||||
__func__, codec->component.name);
|
||||
dev_dbg(component->dev, "%s: configure %s\n",
|
||||
__func__, component->name);
|
||||
/* config */
|
||||
snd_soc_write(codec, CSRA66X0_CHIP_STATE_CTRL_FA,
|
||||
snd_soc_component_write(component, CSRA66X0_CHIP_STATE_CTRL_FA,
|
||||
CONFIG_STATE);
|
||||
/* settle time in HW is min. 500ms before proceeding */
|
||||
msleep(500);
|
||||
snd_soc_write(codec, CSRA66X0_PIO7_SELECT, 0x04);
|
||||
snd_soc_write(codec, CSRA66X0_PIO8_SELECT, 0x04);
|
||||
snd_soc_component_write(component, CSRA66X0_PIO7_SELECT, 0x04);
|
||||
snd_soc_component_write(component, CSRA66X0_PIO8_SELECT, 0x04);
|
||||
if (csra66x0->is_master) {
|
||||
/* Master specific config */
|
||||
snd_soc_write(codec, CSRA66X0_PIO_PULL_EN0, 0xFF);
|
||||
snd_soc_write(codec, CSRA66X0_PIO_PULL_DIR0, 0x80);
|
||||
snd_soc_write(codec, CSRA66X0_PIO_PULL_EN1, 0x01);
|
||||
snd_soc_write(codec, CSRA66X0_PIO_PULL_DIR1, 0x01);
|
||||
snd_soc_component_write(component,
|
||||
CSRA66X0_PIO_PULL_EN0, 0xFF);
|
||||
snd_soc_component_write(component,
|
||||
CSRA66X0_PIO_PULL_DIR0, 0x80);
|
||||
snd_soc_component_write(component,
|
||||
CSRA66X0_PIO_PULL_EN1, 0x01);
|
||||
snd_soc_component_write(component,
|
||||
CSRA66X0_PIO_PULL_DIR1, 0x01);
|
||||
} else {
|
||||
/* Slave specific config */
|
||||
snd_soc_write(codec, CSRA66X0_PIO_PULL_EN0, 0x7F);
|
||||
snd_soc_write(codec, CSRA66X0_PIO_PULL_EN1, 0x00);
|
||||
snd_soc_component_write(component,
|
||||
CSRA66X0_PIO_PULL_EN0, 0x7F);
|
||||
snd_soc_component_write(component,
|
||||
CSRA66X0_PIO_PULL_EN1, 0x00);
|
||||
}
|
||||
snd_soc_write(codec, CSRA66X0_DCA_CTRL, 0x05);
|
||||
snd_soc_component_write(component, CSRA66X0_DCA_CTRL, 0x05);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int csra66x0_soc_probe(struct snd_soc_codec *codec)
|
||||
static int csra66x0_soc_probe(struct snd_soc_component *component)
|
||||
{
|
||||
struct csra66x0_priv *csra66x0 = snd_soc_codec_get_drvdata(codec);
|
||||
struct csra66x0_priv *csra66x0 =
|
||||
snd_soc_component_get_drvdata(component);
|
||||
struct snd_soc_dapm_context *dapm;
|
||||
char name[50];
|
||||
unsigned int i, max_num_cluster_devices;
|
||||
|
||||
csra66x0->codec = codec;
|
||||
csra66x0->component = component;
|
||||
if (csra66x0->in_cluster) {
|
||||
dapm = snd_soc_codec_get_dapm(codec);
|
||||
dev_dbg(codec->dev, "%s: assign prefix %s to codec device %s\n",
|
||||
__func__, codec->component.name_prefix,
|
||||
codec->component.name);
|
||||
dapm = snd_soc_component_get_dapm(component);
|
||||
dev_dbg(component->dev, "%s: assign prefix %s to codec device %s\n",
|
||||
__func__, component->name_prefix,
|
||||
component->name);
|
||||
|
||||
/* add device to cluster table */
|
||||
max_num_cluster_devices = sizeof(csra_clust_dev_tbl)/
|
||||
sizeof(csra_clust_dev_tbl[0]);
|
||||
for (i = 0; i < max_num_cluster_devices; i++) {
|
||||
if (!strncmp(codec->component.name_prefix,
|
||||
if (!strncmp(component->name_prefix,
|
||||
csra_clust_dev_tbl[i].csra66x0_prefix,
|
||||
strlen(
|
||||
csra_clust_dev_tbl[i].csra66x0_prefix))) {
|
||||
@@ -669,10 +699,10 @@ static int csra66x0_soc_probe(struct snd_soc_codec *codec)
|
||||
break;
|
||||
}
|
||||
if (i == max_num_cluster_devices-1)
|
||||
dev_warn(codec->dev,
|
||||
dev_warn(component->dev,
|
||||
"%s: Unknown prefix %s of cluster device %s\n",
|
||||
__func__, codec->component.name_prefix,
|
||||
codec->component.name);
|
||||
__func__, component->name_prefix,
|
||||
component->name);
|
||||
}
|
||||
|
||||
/* master slave config */
|
||||
@@ -694,53 +724,45 @@ static int csra66x0_soc_probe(struct snd_soc_codec *codec)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int csra66x0_soc_remove(struct snd_soc_codec *codec)
|
||||
static void csra66x0_soc_remove(struct snd_soc_component *component)
|
||||
{
|
||||
snd_soc_write(codec, CSRA66X0_CHIP_STATE_CTRL_FA, STDBY_STATE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int csra66x0_soc_suspend(struct snd_soc_codec *codec)
|
||||
{
|
||||
u16 state_reg = snd_soc_read(codec, CSRA66X0_CHIP_STATE_CTRL_FA) & 0xFC;
|
||||
|
||||
snd_soc_write(codec, CSRA66X0_CHIP_STATE_CTRL_FA, state_reg |
|
||||
snd_soc_component_write(component, CSRA66X0_CHIP_STATE_CTRL_FA,
|
||||
STDBY_STATE);
|
||||
return;
|
||||
}
|
||||
|
||||
static int csra66x0_soc_suspend(struct snd_soc_component *component)
|
||||
{
|
||||
u16 state_reg = snd_soc_component_read32(component,
|
||||
CSRA66X0_CHIP_STATE_CTRL_FA) & 0xFC;
|
||||
|
||||
snd_soc_component_write(component, CSRA66X0_CHIP_STATE_CTRL_FA,
|
||||
state_reg | STDBY_STATE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int csra66x0_soc_resume(struct snd_soc_codec *codec)
|
||||
static int csra66x0_soc_resume(struct snd_soc_component *component)
|
||||
{
|
||||
u16 state_reg = snd_soc_read(codec, CSRA66X0_CHIP_STATE_CTRL_FA) & 0xFC;
|
||||
u16 state_reg = snd_soc_component_read32(
|
||||
component, CSRA66X0_CHIP_STATE_CTRL_FA) & 0xFC;
|
||||
|
||||
snd_soc_write(codec, CSRA66X0_CHIP_STATE_CTRL_FA, state_reg |
|
||||
RUN_STATE);
|
||||
snd_soc_component_write(component, CSRA66X0_CHIP_STATE_CTRL_FA,
|
||||
state_reg | RUN_STATE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct regmap *csra66x0_get_regmap(struct device *dev)
|
||||
{
|
||||
struct csra66x0_priv *csra66x0_ctrl = dev_get_drvdata(dev);
|
||||
|
||||
if (!csra66x0_ctrl)
|
||||
return NULL;
|
||||
return csra66x0_ctrl->regmap;
|
||||
}
|
||||
|
||||
static struct snd_soc_codec_driver soc_codec_drv_csra66x0 = {
|
||||
static const struct snd_soc_component_driver soc_codec_drv_csra66x0 = {
|
||||
.name = DRV_NAME,
|
||||
.probe = csra66x0_soc_probe,
|
||||
.remove = csra66x0_soc_remove,
|
||||
.suspend = csra66x0_soc_suspend,
|
||||
.resume = csra66x0_soc_resume,
|
||||
.get_regmap = csra66x0_get_regmap,
|
||||
.component_driver = {
|
||||
.controls = csra66x0_snd_controls,
|
||||
.num_controls = ARRAY_SIZE(csra66x0_snd_controls),
|
||||
.dapm_widgets = csra66x0_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(csra66x0_dapm_widgets),
|
||||
.dapm_routes = csra66x0_dapm_routes,
|
||||
.num_dapm_routes = ARRAY_SIZE(csra66x0_dapm_routes),
|
||||
},
|
||||
};
|
||||
|
||||
static struct regmap_config csra66x0_regmap_config = {
|
||||
@@ -758,19 +780,20 @@ static struct regmap_config csra66x0_regmap_config = {
|
||||
static irqreturn_t csra66x0_irq(int irq, void *data)
|
||||
{
|
||||
struct csra66x0_priv *csra66x0 = (struct csra66x0_priv *) data;
|
||||
struct snd_soc_codec *codec = csra66x0->codec;
|
||||
struct snd_soc_component *component = csra66x0->component;
|
||||
u16 val;
|
||||
unsigned int i, max_num_cluster_devices;
|
||||
|
||||
/* Treat interrupt before codec is initialized as spurious */
|
||||
if (codec == NULL)
|
||||
/* Treat interrupt before component is initialized as spurious */
|
||||
if (component == NULL)
|
||||
return IRQ_NONE;
|
||||
|
||||
dev_dbg(codec->dev, "%s: csra66x0_interrupt triggered by %s\n",
|
||||
__func__, codec->component.name);
|
||||
dev_dbg(component->dev, "%s: csra66x0_interrupt triggered by %s\n",
|
||||
__func__, component->name);
|
||||
|
||||
/* fault indication */
|
||||
val = snd_soc_read(codec, CSRA66X0_IRQ_OUTPUT_STATUS_FA) & 0x1;
|
||||
val = snd_soc_component_read32(component, CSRA66X0_IRQ_OUTPUT_STATUS_FA)
|
||||
& 0x1;
|
||||
if (!val)
|
||||
return IRQ_HANDLED;
|
||||
|
||||
@@ -780,7 +803,7 @@ static irqreturn_t csra66x0_irq(int irq, void *data)
|
||||
sizeof(csra_clust_dev_tbl) /
|
||||
sizeof(csra_clust_dev_tbl[0]);
|
||||
for (i = 0; i < max_num_cluster_devices; i++) {
|
||||
if (i >= codec->component.card->num_aux_devs)
|
||||
if (i >= component->card->num_aux_devs)
|
||||
break;
|
||||
if (csra_clust_dev_tbl[i].csra66x0_ptr == NULL)
|
||||
continue;
|
||||
@@ -790,7 +813,7 @@ static irqreturn_t csra66x0_irq(int irq, void *data)
|
||||
}
|
||||
/* reset all master codecs */
|
||||
for (i = 0; i < max_num_cluster_devices; i++) {
|
||||
if (i >= codec->component.card->num_aux_devs)
|
||||
if (i >= component->card->num_aux_devs)
|
||||
break;
|
||||
if (csra_clust_dev_tbl[i].csra66x0_ptr == NULL)
|
||||
continue;
|
||||
@@ -800,7 +823,7 @@ static irqreturn_t csra66x0_irq(int irq, void *data)
|
||||
}
|
||||
/* recover all codecs */
|
||||
for (i = 0; i < max_num_cluster_devices; i++) {
|
||||
if (i >= codec->component.card->num_aux_devs)
|
||||
if (i >= component->card->num_aux_devs)
|
||||
break;
|
||||
if (csra_clust_dev_tbl[i].csra66x0_ptr == NULL)
|
||||
continue;
|
||||
@@ -958,7 +981,7 @@ static int csra66x0_i2c_probe(struct i2c_client *client_i2c,
|
||||
#endif /* CONFIG_DEBUG_FS */
|
||||
|
||||
/* register codec */
|
||||
ret = snd_soc_register_codec(&client_i2c->dev,
|
||||
ret = snd_soc_register_component(&client_i2c->dev,
|
||||
&soc_codec_drv_csra66x0, NULL, 0);
|
||||
if (ret != 0) {
|
||||
dev_err(&client_i2c->dev, "%s %d: Failed to register codec: %d\n",
|
||||
@@ -985,7 +1008,7 @@ static int csra66x0_i2c_remove(struct i2c_client *i2c_client)
|
||||
debugfs_remove_recursive(csra66x0->debugfs_dir);
|
||||
#endif
|
||||
}
|
||||
snd_soc_unregister_codec(&i2c_client->dev);
|
||||
snd_soc_unregister_component(&i2c_client->dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -21,6 +21,8 @@
|
||||
#include <linux/workqueue.h>
|
||||
#include "ep92.h"
|
||||
|
||||
#define DRV_NAME "ep92_codec"
|
||||
|
||||
#define EP92_POLL_INTERVAL_OFF_MSEC 200
|
||||
#define EP92_POLL_INTERVAL_ON_MSEC 20
|
||||
#define EP92_SYSFS_ENTRY_MAX_LEN 64
|
||||
@@ -91,7 +93,7 @@ static bool ep92_readable_registers(struct device *dev, unsigned int reg)
|
||||
/* codec private data */
|
||||
struct ep92_pdata {
|
||||
struct regmap *regmap;
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
struct timer_list timer;
|
||||
struct work_struct read_status_worker;
|
||||
int irq;
|
||||
@@ -169,7 +171,7 @@ static ssize_t debugfs_codec_write_op(struct file *filp,
|
||||
const char __user *ubuf, size_t cnt, loff_t *ppos)
|
||||
{
|
||||
struct ep92_pdata *ep92 = (struct ep92_pdata *) filp->private_data;
|
||||
struct snd_soc_codec *codec = ep92->codec;
|
||||
struct snd_soc_component *component = ep92->component;
|
||||
char lbuf[32];
|
||||
int rc;
|
||||
u32 param[2];
|
||||
@@ -185,45 +187,45 @@ static ssize_t debugfs_codec_write_op(struct file *filp,
|
||||
rc = debugfs_get_parameters(lbuf, param, 2);
|
||||
if ((param[0] < EP92_ISP_MODE_ENTER_ISP)
|
||||
|| (param[0] > EP92_GENERAL_CONTROL_4)) {
|
||||
dev_err(codec->dev, "%s: reg address 0x%02X out of range\n",
|
||||
dev_err(component->dev, "%s: reg address 0x%02X out of range\n",
|
||||
__func__, param[0]);
|
||||
return -EINVAL;
|
||||
}
|
||||
if ((param[1] < 0) || (param[1] > 255)) {
|
||||
dev_err(codec->dev, "%s: reg data 0x%02X out of range\n",
|
||||
dev_err(component->dev, "%s: reg data 0x%02X out of range\n",
|
||||
__func__, param[1]);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (rc == 0) {
|
||||
rc = cnt;
|
||||
dev_info(codec->dev, "%s: reg[0x%02X]=0x%02X\n",
|
||||
dev_info(component->dev, "%s: reg[0x%02X]=0x%02X\n",
|
||||
__func__, param[0], param[1]);
|
||||
snd_soc_write(codec, param[0], param[1]);
|
||||
snd_soc_component_write(component, param[0], param[1]);
|
||||
} else {
|
||||
dev_err(codec->dev, "%s: write to register addr=0x%02X failed\n",
|
||||
dev_err(component->dev, "%s: write to register addr=0x%02X failed\n",
|
||||
__func__, param[0]);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
static ssize_t debugfs_ep92_reg_show(struct snd_soc_codec *codec,
|
||||
static ssize_t debugfs_ep92_reg_show(struct snd_soc_component *component,
|
||||
char __user *ubuf, size_t count, loff_t *ppos)
|
||||
{
|
||||
int i, reg_val, len;
|
||||
ssize_t total = 0;
|
||||
char tmp_buf[20];
|
||||
|
||||
if (!ubuf || !ppos || !codec || *ppos < 0)
|
||||
if (!ubuf || !ppos || !component || *ppos < 0)
|
||||
return -EINVAL;
|
||||
|
||||
for (i = (int) *ppos / 11; i <= EP92_MAX_REGISTER_ADDR; i++) {
|
||||
reg_val = snd_soc_read(codec, i);
|
||||
reg_val = snd_soc_component_read32(component, i);
|
||||
len = snprintf(tmp_buf, 20, "0x%02X: 0x%02X\n", i,
|
||||
(reg_val & 0xFF));
|
||||
if ((total + len) > count)
|
||||
break;
|
||||
if (copy_to_user((ubuf + total), tmp_buf, len)) {
|
||||
dev_err(codec->dev, "%s: fail to copy reg dump\n",
|
||||
dev_err(component->dev, "%s: fail to copy reg dump\n",
|
||||
__func__);
|
||||
total = -EFAULT;
|
||||
goto copy_err;
|
||||
@@ -240,12 +242,12 @@ static ssize_t debugfs_codec_read_op(struct file *filp,
|
||||
char __user *ubuf, size_t cnt, loff_t *ppos)
|
||||
{
|
||||
struct ep92_pdata *ep92 = (struct ep92_pdata *) filp->private_data;
|
||||
struct snd_soc_codec *codec = ep92->codec;
|
||||
struct snd_soc_component *component = ep92->component;
|
||||
ssize_t ret_cnt;
|
||||
|
||||
if (!filp || !ppos || !ubuf || *ppos < 0)
|
||||
return -EINVAL;
|
||||
ret_cnt = debugfs_ep92_reg_show(codec, ubuf, cnt, ppos);
|
||||
ret_cnt = debugfs_ep92_reg_show(component, ubuf, cnt, ppos);
|
||||
return ret_cnt;
|
||||
}
|
||||
|
||||
@@ -263,7 +265,8 @@ static int ep92_send_uevent(struct ep92_pdata *ep92, char *event)
|
||||
if (!event || !ep92)
|
||||
return -EINVAL;
|
||||
|
||||
return kobject_uevent_env(&ep92->codec->dev->kobj, KOBJ_CHANGE, env);
|
||||
return kobject_uevent_env(&ep92->component->dev->kobj,
|
||||
KOBJ_CHANGE, env);
|
||||
}
|
||||
|
||||
static int ep92_startup(struct snd_pcm_substream *substream,
|
||||
@@ -320,14 +323,15 @@ static struct snd_soc_dai_driver ep92_dai[] = {
|
||||
},
|
||||
};
|
||||
|
||||
static void ep92_read_general_control(struct snd_soc_codec *codec,
|
||||
static void ep92_read_general_control(struct snd_soc_component *component,
|
||||
struct ep92_pdata *ep92)
|
||||
{
|
||||
u8 old, change;
|
||||
int val;
|
||||
|
||||
old = ep92->gi.tx_info;
|
||||
ep92->gi.tx_info = snd_soc_read(codec, EP92_BI_GENERAL_INFO_0);
|
||||
ep92->gi.tx_info = snd_soc_component_read32(component,
|
||||
EP92_BI_GENERAL_INFO_0);
|
||||
if (ep92->gi.tx_info == 0xff) {
|
||||
pr_debug("ep92 EP92_BI_GENERAL_INFO_0 read 0xff\n");
|
||||
ep92->gi.tx_info = old;
|
||||
@@ -358,7 +362,8 @@ static void ep92_read_general_control(struct snd_soc_codec *codec,
|
||||
}
|
||||
|
||||
old = ep92->gi.video_latency;
|
||||
ep92->gi.video_latency = snd_soc_read(codec, EP92_BI_GENERAL_INFO_4);
|
||||
ep92->gi.video_latency = snd_soc_component_read32(component,
|
||||
EP92_BI_GENERAL_INFO_4);
|
||||
if (ep92->gi.video_latency == 0xff) {
|
||||
pr_debug("ep92 EP92_BI_GENERAL_INFO_4 read 0xff\n");
|
||||
ep92->gi.video_latency = old;
|
||||
@@ -373,7 +378,8 @@ static void ep92_read_general_control(struct snd_soc_codec *codec,
|
||||
}
|
||||
|
||||
old = ep92->gc.ctl;
|
||||
ep92->gc.ctl = snd_soc_read(codec, EP92_GENERAL_CONTROL_0);
|
||||
ep92->gc.ctl = snd_soc_component_read32(component,
|
||||
EP92_GENERAL_CONTROL_0);
|
||||
if (ep92->gc.ctl == 0xff) {
|
||||
pr_debug("ep92 EP92_GENERAL_CONTROL_0 read 0xff\n");
|
||||
ep92->gc.ctl = old;
|
||||
@@ -416,7 +422,8 @@ static void ep92_read_general_control(struct snd_soc_codec *codec,
|
||||
}
|
||||
|
||||
old = ep92->gc.rx_sel;
|
||||
ep92->gc.rx_sel = snd_soc_read(codec, EP92_GENERAL_CONTROL_1);
|
||||
ep92->gc.rx_sel = snd_soc_component_read32(component,
|
||||
EP92_GENERAL_CONTROL_1);
|
||||
if (ep92->gc.rx_sel == 0xff) {
|
||||
pr_debug("ep92 EP92_GENERAL_CONTROL_1 read 0xff\n");
|
||||
ep92->gc.rx_sel = old;
|
||||
@@ -429,7 +436,8 @@ static void ep92_read_general_control(struct snd_soc_codec *codec,
|
||||
}
|
||||
|
||||
old = ep92->gc.cec_volume;
|
||||
ep92->gc.cec_volume = snd_soc_read(codec, EP92_GENERAL_CONTROL_3);
|
||||
ep92->gc.cec_volume = snd_soc_component_read32(component,
|
||||
EP92_GENERAL_CONTROL_3);
|
||||
if (ep92->gc.cec_volume == 0xff) {
|
||||
pr_debug("ep92 EP92_GENERAL_CONTROL_3 read 0xff\n");
|
||||
ep92->gc.cec_volume = old;
|
||||
@@ -442,7 +450,8 @@ static void ep92_read_general_control(struct snd_soc_codec *codec,
|
||||
}
|
||||
|
||||
old = ep92->gc.link;
|
||||
ep92->gc.link = snd_soc_read(codec, EP92_GENERAL_CONTROL_4);
|
||||
ep92->gc.link = snd_soc_component_read32(component,
|
||||
EP92_GENERAL_CONTROL_4);
|
||||
if (ep92->gc.link == 0xff) {
|
||||
pr_debug("ep92 EP92_GENERAL_CONTROL_4 read 0xff\n");
|
||||
ep92->gc.link = old;
|
||||
@@ -524,7 +533,7 @@ static void ep92_read_general_control(struct snd_soc_codec *codec,
|
||||
}
|
||||
}
|
||||
|
||||
static void ep92_read_audio_info(struct snd_soc_codec *codec,
|
||||
static void ep92_read_audio_info(struct snd_soc_component *component,
|
||||
struct ep92_pdata *ep92)
|
||||
{
|
||||
u8 old, change;
|
||||
@@ -532,7 +541,7 @@ static void ep92_read_audio_info(struct snd_soc_codec *codec,
|
||||
bool send_uevent = false;
|
||||
|
||||
old = ep92->ai.system_status_0;
|
||||
ep92->ai.system_status_0 = snd_soc_read(codec,
|
||||
ep92->ai.system_status_0 = snd_soc_component_read32(component,
|
||||
EP92_AUDIO_INFO_SYSTEM_STATUS_0);
|
||||
if (ep92->ai.system_status_0 == 0xff) {
|
||||
pr_debug("ep92 EP92_AUDIO_INFO_SYSTEM_STATUS_0 read 0xff\n");
|
||||
@@ -558,7 +567,7 @@ static void ep92_read_audio_info(struct snd_soc_codec *codec,
|
||||
}
|
||||
|
||||
old = ep92->ai.audio_status;
|
||||
ep92->ai.audio_status = snd_soc_read(codec,
|
||||
ep92->ai.audio_status = snd_soc_component_read32(component,
|
||||
EP92_AUDIO_INFO_AUDIO_STATUS);
|
||||
if (ep92->ai.audio_status == 0xff) {
|
||||
pr_debug("ep92 EP92_AUDIO_INFO_AUDIO_STATUS read 0xff\n");
|
||||
@@ -575,7 +584,7 @@ static void ep92_read_audio_info(struct snd_soc_codec *codec,
|
||||
new_mode = ep92->old_mode;
|
||||
if (ep92->ai.audio_status & EP92_AI_STD_ADO_MASK) {
|
||||
old = ep92->ai.cs[0];
|
||||
ep92->ai.cs[0] = snd_soc_read(codec,
|
||||
ep92->ai.cs[0] = snd_soc_component_read32(component,
|
||||
EP92_AUDIO_INFO_CHANNEL_STATUS_0);
|
||||
if (ep92->ai.cs[0] == 0xff) {
|
||||
pr_debug("ep92 EP92_AUDIO_INFO_CHANNEL_STATUS_0 read 0xff\n");
|
||||
@@ -595,7 +604,8 @@ static void ep92_read_audio_info(struct snd_soc_codec *codec,
|
||||
ep92->old_mode = new_mode;
|
||||
|
||||
old = ep92->ai.cc;
|
||||
ep92->ai.cc = snd_soc_read(codec, EP92_AUDIO_INFO_ADO_INFO_FRAME_1);
|
||||
ep92->ai.cc = snd_soc_component_read32(component,
|
||||
EP92_AUDIO_INFO_ADO_INFO_FRAME_1);
|
||||
if (ep92->ai.cc == 0xff) {
|
||||
pr_debug("ep92 EP92_AUDIO_INFO_ADO_INFO_FRAME_1 read 0xff\n");
|
||||
ep92->ai.cc = old;
|
||||
@@ -610,7 +620,8 @@ static void ep92_read_audio_info(struct snd_soc_codec *codec,
|
||||
}
|
||||
|
||||
old = ep92->ai.ca;
|
||||
ep92->ai.ca = snd_soc_read(codec, EP92_AUDIO_INFO_ADO_INFO_FRAME_4);
|
||||
ep92->ai.ca = snd_soc_component_read32(component,
|
||||
EP92_AUDIO_INFO_ADO_INFO_FRAME_4);
|
||||
if (ep92->ai.ca == 0xff) {
|
||||
pr_debug("ep92 EP92_AUDIO_INFO_ADO_INFO_FRAME_4 read 0xff\n");
|
||||
ep92->ai.ca = old;
|
||||
@@ -626,42 +637,33 @@ static void ep92_read_audio_info(struct snd_soc_codec *codec,
|
||||
ep92_send_uevent(ep92, "EP92EVT_AUDIO=MEDIA_CONFIG_CHANGE");
|
||||
}
|
||||
|
||||
static void ep92_init(struct snd_soc_codec *codec, struct ep92_pdata *ep92)
|
||||
static void ep92_init(struct snd_soc_component *component,
|
||||
struct ep92_pdata *ep92)
|
||||
{
|
||||
/* update the format information in mixer controls */
|
||||
ep92_read_general_control(codec, ep92);
|
||||
ep92_read_audio_info(codec, ep92);
|
||||
ep92_read_general_control(component, ep92);
|
||||
ep92_read_audio_info(component, ep92);
|
||||
}
|
||||
|
||||
static int ep92_probe(struct snd_soc_codec *codec)
|
||||
static int ep92_probe(struct snd_soc_component *component)
|
||||
{
|
||||
struct ep92_pdata *ep92 = snd_soc_codec_get_drvdata(codec);
|
||||
struct ep92_pdata *ep92 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
ep92->codec = codec;
|
||||
ep92_init(codec, ep92);
|
||||
ep92->component = component;
|
||||
ep92_init(component, ep92);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ep92_remove(struct snd_soc_codec *codec)
|
||||
static void ep92_remove(struct snd_soc_component *component)
|
||||
{
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
static struct regmap *ep92_get_regmap(struct device *dev)
|
||||
{
|
||||
struct ep92_pdata *ep92_ctrl = dev_get_drvdata(dev);
|
||||
|
||||
if (!ep92_ctrl)
|
||||
return NULL;
|
||||
|
||||
return ep92_ctrl->regmap;
|
||||
}
|
||||
|
||||
static struct snd_soc_codec_driver soc_codec_drv_ep92 = {
|
||||
static const struct snd_soc_component_driver soc_codec_drv_ep92 = {
|
||||
.name = DRV_NAME,
|
||||
.probe = ep92_probe,
|
||||
.remove = ep92_remove,
|
||||
.get_regmap = ep92_get_regmap,
|
||||
};
|
||||
|
||||
static struct regmap_config ep92_regmap_config = {
|
||||
@@ -680,18 +682,19 @@ void ep92_read_status(struct work_struct *work)
|
||||
{
|
||||
struct ep92_pdata *ep92 = container_of(work, struct ep92_pdata,
|
||||
read_status_worker);
|
||||
struct snd_soc_codec *codec = ep92->codec;
|
||||
struct snd_soc_component *component = ep92->component;
|
||||
u8 val;
|
||||
|
||||
/* No polling before codec is initialized */
|
||||
if (codec == NULL)
|
||||
if (component == NULL)
|
||||
return;
|
||||
|
||||
/* check ADO_CHF that is set when audio format has changed */
|
||||
val = snd_soc_read(codec, EP92_BI_GENERAL_INFO_1);
|
||||
val = snd_soc_component_read32(component, EP92_BI_GENERAL_INFO_1);
|
||||
if (val == 0xff) {
|
||||
/* workaround for Nak'ed first read */
|
||||
val = snd_soc_read(codec, EP92_BI_GENERAL_INFO_1);
|
||||
val = snd_soc_component_read32(component,
|
||||
EP92_BI_GENERAL_INFO_1);
|
||||
if (val == 0xff)
|
||||
return; /* assume device not present */
|
||||
}
|
||||
@@ -703,22 +706,22 @@ void ep92_read_status(struct work_struct *work)
|
||||
pr_debug("ep92 CEC change trigger.\n");
|
||||
|
||||
/* check for general control changes */
|
||||
ep92_read_general_control(codec, ep92);
|
||||
ep92_read_general_control(component, ep92);
|
||||
|
||||
/* update the format information in mixer controls */
|
||||
ep92_read_audio_info(codec, ep92);
|
||||
ep92_read_audio_info(component, ep92);
|
||||
}
|
||||
|
||||
static irqreturn_t ep92_irq(int irq, void *data)
|
||||
{
|
||||
struct ep92_pdata *ep92 = data;
|
||||
struct snd_soc_codec *codec = ep92->codec;
|
||||
struct snd_soc_component *component = ep92->component;
|
||||
|
||||
/* Treat interrupt before codec is initialized as spurious */
|
||||
if (codec == NULL)
|
||||
if (component == NULL)
|
||||
return IRQ_NONE;
|
||||
|
||||
dev_dbg(codec->dev, "ep92_interrupt\n");
|
||||
dev_dbg(component->dev, "ep92_interrupt\n");
|
||||
|
||||
schedule_work(&ep92->read_status_worker);
|
||||
|
||||
@@ -1038,10 +1041,11 @@ static ssize_t ep92_sysfs_wta_arc_disable(struct device *dev,
|
||||
goto end;
|
||||
}
|
||||
|
||||
reg = snd_soc_read(ep92->codec, EP92_GENERAL_CONTROL_2);
|
||||
reg = snd_soc_component_read32(ep92->component,
|
||||
EP92_GENERAL_CONTROL_2);
|
||||
reg &= ~EP92_GC_ARC_DIS_MASK;
|
||||
reg |= ((val << EP92_GC_ARC_DIS_SHIFT) & EP92_GC_ARC_DIS_MASK);
|
||||
snd_soc_write(ep92->codec, EP92_GENERAL_CONTROL_2, reg);
|
||||
snd_soc_component_write(ep92->component, EP92_GENERAL_CONTROL_2, reg);
|
||||
ep92->gc.ctl2 &= ~EP92_GC_ARC_DIS_MASK;
|
||||
ep92->gc.ctl2 |= (val << EP92_GC_ARC_DIS_SHIFT) & EP92_GC_ARC_DIS_MASK;
|
||||
|
||||
@@ -1092,10 +1096,10 @@ static ssize_t ep92_sysfs_wta_power(struct device *dev,
|
||||
goto end;
|
||||
}
|
||||
|
||||
reg = snd_soc_read(ep92->codec, EP92_GENERAL_CONTROL_0);
|
||||
reg = snd_soc_component_read32(ep92->component, EP92_GENERAL_CONTROL_0);
|
||||
reg &= ~EP92_GC_POWER_MASK;
|
||||
reg |= (val << EP92_GC_POWER_SHIFT) & EP92_GC_POWER_MASK;
|
||||
snd_soc_write(ep92->codec, EP92_GENERAL_CONTROL_0, reg);
|
||||
snd_soc_component_write(ep92->component, EP92_GENERAL_CONTROL_0, reg);
|
||||
ep92->gc.ctl &= ~EP92_GC_POWER_MASK;
|
||||
ep92->gc.ctl |= (val << EP92_GC_POWER_SHIFT) & EP92_GC_POWER_MASK;
|
||||
|
||||
@@ -1146,10 +1150,11 @@ static ssize_t ep92_sysfs_wta_audio_path(struct device *dev,
|
||||
goto end;
|
||||
}
|
||||
|
||||
reg = snd_soc_read(ep92->codec, EP92_GENERAL_CONTROL_0);
|
||||
reg = snd_soc_component_read32(ep92->component,
|
||||
EP92_GENERAL_CONTROL_0);
|
||||
reg &= ~EP92_GC_AUDIO_PATH_MASK;
|
||||
reg |= (val << EP92_GC_AUDIO_PATH_SHIFT) & EP92_GC_AUDIO_PATH_MASK;
|
||||
snd_soc_write(ep92->codec, EP92_GENERAL_CONTROL_0, reg);
|
||||
snd_soc_component_write(ep92->component, EP92_GENERAL_CONTROL_0, reg);
|
||||
ep92->gc.ctl &= ~EP92_GC_AUDIO_PATH_MASK;
|
||||
ep92->gc.ctl |= (val << EP92_GC_AUDIO_PATH_SHIFT) &
|
||||
EP92_GC_AUDIO_PATH_MASK;
|
||||
@@ -1201,10 +1206,11 @@ static ssize_t ep92_sysfs_wta_src_sel(struct device *dev,
|
||||
goto end;
|
||||
}
|
||||
|
||||
reg = snd_soc_read(ep92->codec, EP92_GENERAL_CONTROL_1);
|
||||
reg = snd_soc_component_read32(ep92->component,
|
||||
EP92_GENERAL_CONTROL_1);
|
||||
reg &= ~EP92_GC_RX_SEL_MASK;
|
||||
reg |= (val << EP92_GC_RX_SEL_SHIFT) & EP92_GC_RX_SEL_MASK;
|
||||
snd_soc_write(ep92->codec, EP92_GENERAL_CONTROL_1, reg);
|
||||
snd_soc_component_write(ep92->component, EP92_GENERAL_CONTROL_1, reg);
|
||||
ep92->gc.rx_sel &= ~EP92_GC_RX_SEL_MASK;
|
||||
ep92->gc.rx_sel |= (val << EP92_GC_RX_SEL_SHIFT) & EP92_GC_RX_SEL_MASK;
|
||||
|
||||
@@ -1255,10 +1261,10 @@ static ssize_t ep92_sysfs_wta_arc_enable(struct device *dev,
|
||||
goto end;
|
||||
}
|
||||
|
||||
reg = snd_soc_read(ep92->codec, EP92_GENERAL_CONTROL_0);
|
||||
reg = snd_soc_component_read32(ep92->component, EP92_GENERAL_CONTROL_0);
|
||||
reg &= ~EP92_GC_AUDIO_PATH_MASK;
|
||||
reg |= (val << EP92_GC_AUDIO_PATH_SHIFT) & EP92_GC_AUDIO_PATH_MASK;
|
||||
snd_soc_write(ep92->codec, EP92_GENERAL_CONTROL_0, reg);
|
||||
snd_soc_component_write(ep92->component, EP92_GENERAL_CONTROL_0, reg);
|
||||
ep92->gc.ctl &= ~EP92_GC_AUDIO_PATH_MASK;
|
||||
ep92->gc.ctl |= (val << EP92_GC_AUDIO_PATH_SHIFT) &
|
||||
EP92_GC_AUDIO_PATH_MASK;
|
||||
@@ -1310,10 +1316,10 @@ static ssize_t ep92_sysfs_wta_cec_mute(struct device *dev,
|
||||
goto end;
|
||||
}
|
||||
|
||||
reg = snd_soc_read(ep92->codec, EP92_GENERAL_CONTROL_0);
|
||||
reg = snd_soc_component_read32(ep92->component, EP92_GENERAL_CONTROL_0);
|
||||
reg &= ~EP92_GC_CEC_MUTE_MASK;
|
||||
reg |= (val << EP92_GC_CEC_MUTE_SHIFT) & EP92_GC_CEC_MUTE_MASK;
|
||||
snd_soc_write(ep92->codec, EP92_GENERAL_CONTROL_0, reg);
|
||||
snd_soc_component_write(ep92->component, EP92_GENERAL_CONTROL_0, reg);
|
||||
ep92->gc.ctl &= ~EP92_GC_CEC_MUTE_MASK;
|
||||
ep92->gc.ctl |= (val << EP92_GC_CEC_MUTE_SHIFT) &
|
||||
EP92_GC_CEC_MUTE_MASK;
|
||||
@@ -1367,7 +1373,7 @@ static ssize_t ep92_sysfs_wta_cec_volume(struct device *dev,
|
||||
}
|
||||
|
||||
reg = val & EP92_GC_CEC_VOLUME_MASK;
|
||||
snd_soc_write(ep92->codec, EP92_GENERAL_CONTROL_3, reg);
|
||||
snd_soc_component_write(ep92->component, EP92_GENERAL_CONTROL_3, reg);
|
||||
ep92->gc.cec_volume = val & EP92_GC_CEC_VOLUME_MASK;
|
||||
|
||||
rc = strnlen(buf, EP92_SYSFS_ENTRY_MAX_LEN);
|
||||
@@ -1524,7 +1530,7 @@ static int ep92_i2c_probe(struct i2c_client *client,
|
||||
#endif /* CONFIG_DEBUG_FS */
|
||||
|
||||
/* register codec */
|
||||
ret = snd_soc_register_codec(&client->dev, &soc_codec_drv_ep92,
|
||||
ret = snd_soc_register_component(&client->dev, &soc_codec_drv_ep92,
|
||||
ep92_dai, ARRAY_SIZE(ep92_dai));
|
||||
if (ret) {
|
||||
dev_err(&client->dev,
|
||||
@@ -1542,7 +1548,7 @@ static int ep92_i2c_probe(struct i2c_client *client,
|
||||
return 0;
|
||||
|
||||
err_sysfs:
|
||||
snd_soc_unregister_codec(&client->dev);
|
||||
snd_soc_unregister_component(&client->dev);
|
||||
err_reg:
|
||||
if (ep92->irq == 0)
|
||||
del_timer(&ep92->timer);
|
||||
@@ -1563,7 +1569,7 @@ static int ep92_i2c_remove(struct i2c_client *client)
|
||||
debugfs_remove_recursive(ep92->debugfs_dir);
|
||||
#endif
|
||||
}
|
||||
snd_soc_unregister_codec(&client->dev);
|
||||
snd_soc_unregister_component(&client->dev);
|
||||
|
||||
ep92_sysfs_remove(client, ep92);
|
||||
|
||||
|
@@ -11,6 +11,8 @@
|
||||
#include <sound/soc.h>
|
||||
#include <linux/msm_ext_display.h>
|
||||
|
||||
#define DRV_NAME "HDMI_codec"
|
||||
|
||||
#define MSM_EXT_DISP_PCM_RATES SNDRV_PCM_RATE_48000
|
||||
#define AUD_EXT_DISP_ACK_DISCONNECT (AUDIO_ACK_CONNECT ^ AUDIO_ACK_CONNECT)
|
||||
#define AUD_EXT_DISP_ACK_CONNECT (AUDIO_ACK_CONNECT)
|
||||
@@ -64,29 +66,30 @@ struct msm_ext_disp_audio_codec_rx_data {
|
||||
static int msm_ext_disp_edid_ctl_info(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_info *uinfo)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct msm_ext_disp_audio_codec_rx_data *codec_data;
|
||||
struct msm_ext_disp_audio_edid_blk edid_blk;
|
||||
int rc = 0;
|
||||
struct msm_ext_disp_codec_id codec_info;
|
||||
int dai_id = kcontrol->private_value;
|
||||
|
||||
codec_data = snd_soc_codec_get_drvdata(codec);
|
||||
codec_data = snd_soc_component_get_drvdata(component);
|
||||
|
||||
if (!codec_data) {
|
||||
dev_err(codec->dev, "%s: codec_data is NULL\n", __func__);
|
||||
dev_err(component->dev, "%s: codec_data is NULL\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!codec_data->ext_disp_ops.get_audio_edid_blk) {
|
||||
dev_dbg(codec->dev, "%s: get_audio_edid_blk() is NULL\n",
|
||||
dev_dbg(component->dev, "%s: get_audio_edid_blk() is NULL\n",
|
||||
__func__);
|
||||
uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
|
||||
uinfo->count = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
dev_dbg(codec->dev, "%s: DP ctl id %d Stream id %d\n", __func__,
|
||||
dev_dbg(component->dev, "%s: DP ctl id %d Stream id %d\n", __func__,
|
||||
codec_data->ctl[dai_id], codec_data->stream[dai_id]);
|
||||
|
||||
mutex_lock(&codec_data->dp_ops_lock);
|
||||
@@ -100,28 +103,29 @@ static int msm_ext_disp_edid_ctl_info(struct snd_kcontrol *kcontrol,
|
||||
edid_blk.spk_alloc_data_blk_size;
|
||||
}
|
||||
|
||||
dev_dbg(codec->dev, "%s: count: %d\n", __func__, uinfo->count);
|
||||
dev_dbg(component->dev, "%s: count: %d\n", __func__, uinfo->count);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int msm_ext_disp_edid_get(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol) {
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct msm_ext_disp_audio_codec_rx_data *codec_data;
|
||||
struct msm_ext_disp_audio_edid_blk edid_blk;
|
||||
struct msm_ext_disp_codec_id codec_info;
|
||||
int rc = 0;
|
||||
int dai_id = kcontrol->private_value;
|
||||
|
||||
codec_data = snd_soc_codec_get_drvdata(codec);
|
||||
codec_data = snd_soc_component_get_drvdata(component);
|
||||
if (!codec_data || !codec_data->ext_disp_ops.get_audio_edid_blk) {
|
||||
dev_err(codec->dev, "%s: codec_data or get_audio_edid_blk() is NULL\n",
|
||||
dev_err(component->dev, "%s: codec_data or get_audio_edid_blk() is NULL\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
dev_dbg(codec->dev, "%s: DP ctl id %d Stream id %d\n", __func__,
|
||||
dev_dbg(component->dev, "%s: DP ctl id %d Stream id %d\n", __func__,
|
||||
codec_data->ctl[dai_id], codec_data->stream[dai_id]);
|
||||
|
||||
mutex_lock(&codec_data->dp_ops_lock);
|
||||
@@ -133,7 +137,7 @@ static int msm_ext_disp_edid_get(struct snd_kcontrol *kcontrol,
|
||||
if (sizeof(ucontrol->value.bytes.data) <
|
||||
(edid_blk.audio_data_blk_size +
|
||||
edid_blk.spk_alloc_data_blk_size)) {
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s: Not enough memory to copy EDID data\n",
|
||||
__func__);
|
||||
return -ENOMEM;
|
||||
@@ -147,7 +151,7 @@ static int msm_ext_disp_edid_get(struct snd_kcontrol *kcontrol,
|
||||
edid_blk.spk_alloc_data_blk,
|
||||
edid_blk.spk_alloc_data_blk_size);
|
||||
|
||||
dev_dbg(codec->dev, "%s: data_blk_size:%d, spk_alloc_data_blk_size:%d\n",
|
||||
dev_dbg(component->dev, "%s: data_blk_size:%d, spk_alloc_data_blk_size:%d\n",
|
||||
__func__, edid_blk.audio_data_blk_size,
|
||||
edid_blk.spk_alloc_data_blk_size);
|
||||
}
|
||||
@@ -158,7 +162,8 @@ static int msm_ext_disp_edid_get(struct snd_kcontrol *kcontrol,
|
||||
static int msm_ext_disp_audio_type_get(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct msm_ext_disp_audio_codec_rx_data *codec_data;
|
||||
enum msm_ext_disp_cable_state cable_state;
|
||||
enum msm_ext_disp_type disp_type;
|
||||
@@ -166,16 +171,16 @@ static int msm_ext_disp_audio_type_get(struct snd_kcontrol *kcontrol,
|
||||
int rc = 0;
|
||||
int dai_id = ((struct soc_enum *) kcontrol->private_value)->shift_l;
|
||||
|
||||
codec_data = snd_soc_codec_get_drvdata(codec);
|
||||
codec_data = snd_soc_component_get_drvdata(component);
|
||||
if (!codec_data ||
|
||||
!codec_data->ext_disp_ops.get_audio_edid_blk ||
|
||||
!codec_data->ext_disp_ops.get_intf_id) {
|
||||
dev_err(codec->dev, "%s: codec_data, get_audio_edid_blk() or get_intf_id is NULL\n",
|
||||
dev_err(component->dev, "%s: codec_data, get_audio_edid_blk() or get_intf_id is NULL\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
dev_dbg(codec->dev, "%s: DP ctl id %d Stream id %d\n", __func__,
|
||||
dev_dbg(component->dev, "%s: DP ctl id %d Stream id %d\n", __func__,
|
||||
codec_data->ctl[dai_id], codec_data->stream[dai_id]);
|
||||
|
||||
mutex_lock(&codec_data->dp_ops_lock);
|
||||
@@ -183,7 +188,7 @@ static int msm_ext_disp_audio_type_get(struct snd_kcontrol *kcontrol,
|
||||
cable_state = codec_data->ext_disp_ops.cable_status(
|
||||
codec_data->ext_disp_core_pdev, 1);
|
||||
if (cable_state < 0) {
|
||||
dev_err(codec->dev, "%s: Error retrieving cable state from ext_disp, err:%d\n",
|
||||
dev_err(component->dev, "%s: Error retrieving cable state from ext_disp, err:%d\n",
|
||||
__func__, cable_state);
|
||||
rc = cable_state;
|
||||
goto cable_err;
|
||||
@@ -191,7 +196,7 @@ static int msm_ext_disp_audio_type_get(struct snd_kcontrol *kcontrol,
|
||||
|
||||
codec_data->cable_status = cable_state;
|
||||
if (cable_state == EXT_DISPLAY_CABLE_DISCONNECT) {
|
||||
dev_err(codec->dev, "%s: Display cable disconnected\n",
|
||||
dev_err(component->dev, "%s: Display cable disconnected\n",
|
||||
__func__);
|
||||
ucontrol->value.integer.value[0] = 0;
|
||||
rc = 0;
|
||||
@@ -213,14 +218,14 @@ static int msm_ext_disp_audio_type_get(struct snd_kcontrol *kcontrol,
|
||||
break;
|
||||
default:
|
||||
rc = -EINVAL;
|
||||
dev_err(codec->dev, "%s: Invalid disp_type:%d\n",
|
||||
dev_err(component->dev, "%s: Invalid disp_type:%d\n",
|
||||
__func__, disp_type);
|
||||
goto done;
|
||||
}
|
||||
dev_dbg(codec->dev, "%s: Display type: %d\n",
|
||||
dev_dbg(component->dev, "%s: Display type: %d\n",
|
||||
__func__, disp_type);
|
||||
} else {
|
||||
dev_err(codec->dev, "%s: Error retrieving disp_type from ext_disp, err:%d\n",
|
||||
dev_err(component->dev, "%s: Error retrieving disp_type from ext_disp, err:%d\n",
|
||||
__func__, disp_type);
|
||||
rc = disp_type;
|
||||
}
|
||||
@@ -235,24 +240,25 @@ done:
|
||||
static int msm_ext_disp_audio_ack_set(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct msm_ext_disp_audio_codec_rx_data *codec_data;
|
||||
u32 ack_state = 0;
|
||||
struct msm_ext_disp_codec_id codec_info;
|
||||
int rc = 0;
|
||||
int dai_id = ((struct soc_enum *) kcontrol->private_value)->shift_l;
|
||||
|
||||
codec_data = snd_soc_codec_get_drvdata(codec);
|
||||
codec_data = snd_soc_component_get_drvdata(component);
|
||||
if (!codec_data ||
|
||||
!codec_data->ext_disp_ops.acknowledge) {
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s: codec_data or ops acknowledge() is NULL\n",
|
||||
__func__);
|
||||
rc = -EINVAL;
|
||||
goto done;
|
||||
}
|
||||
|
||||
dev_dbg(codec->dev, "%s: DP ctl id %d Stream id %d\n", __func__,
|
||||
dev_dbg(component->dev, "%s: DP ctl id %d Stream id %d\n", __func__,
|
||||
codec_data->ctl[dai_id], codec_data->stream[dai_id]);
|
||||
|
||||
switch (ucontrol->value.enumerated.item[0]) {
|
||||
@@ -267,12 +273,12 @@ static int msm_ext_disp_audio_ack_set(struct snd_kcontrol *kcontrol,
|
||||
break;
|
||||
default:
|
||||
rc = -EINVAL;
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s: invalid value %d for mixer ctl\n",
|
||||
__func__, ucontrol->value.enumerated.item[0]);
|
||||
goto done;
|
||||
}
|
||||
dev_dbg(codec->dev, "%s: control %d, ack set value 0x%x\n",
|
||||
dev_dbg(component->dev, "%s: control %d, ack set value 0x%x\n",
|
||||
__func__, ucontrol->value.enumerated.item[0], ack_state);
|
||||
|
||||
mutex_lock(&codec_data->dp_ops_lock);
|
||||
@@ -281,7 +287,7 @@ static int msm_ext_disp_audio_ack_set(struct snd_kcontrol *kcontrol,
|
||||
codec_data->ext_disp_core_pdev, ack_state);
|
||||
mutex_unlock(&codec_data->dp_ops_lock);
|
||||
if (rc < 0) {
|
||||
dev_err(codec->dev, "%s: error from acknowledge(), err:%d\n",
|
||||
dev_err(component->dev, "%s: error from acknowledge(), err:%d\n",
|
||||
__func__, rc);
|
||||
}
|
||||
|
||||
@@ -292,14 +298,15 @@ done:
|
||||
static int msm_ext_disp_audio_device_set(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct msm_ext_disp_audio_codec_rx_data *codec_data;
|
||||
int rc = 0;
|
||||
int dai_id = ((struct soc_enum *) kcontrol->private_value)->shift_l;
|
||||
|
||||
codec_data = snd_soc_codec_get_drvdata(codec);
|
||||
codec_data = snd_soc_component_get_drvdata(component);
|
||||
if (!codec_data) {
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s: codec_data or ops acknowledge() is NULL\n",
|
||||
__func__);
|
||||
rc = -EINVAL;
|
||||
@@ -371,7 +378,7 @@ static int msm_ext_disp_audio_codec_rx_dai_startup(
|
||||
int ret = 0;
|
||||
struct msm_ext_disp_codec_id codec_info;
|
||||
struct msm_ext_disp_audio_codec_rx_data *codec_data =
|
||||
dev_get_drvdata(dai->codec->dev);
|
||||
dev_get_drvdata(dai->component->dev);
|
||||
|
||||
if (!codec_data || !codec_data->ext_disp_ops.cable_status) {
|
||||
dev_err(dai->dev, "%s() codec_data or cable_status is null\n",
|
||||
@@ -379,7 +386,8 @@ static int msm_ext_disp_audio_codec_rx_dai_startup(
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
dev_dbg(dai->codec->dev, "%s: DP ctl id %d Stream id %d\n", __func__,
|
||||
dev_dbg(dai->component->dev, "%s: DP ctl id %d Stream id %d\n",
|
||||
__func__,
|
||||
codec_data->ctl[dai->id], codec_data->stream[dai->id]);
|
||||
|
||||
mutex_lock(&codec_data->dp_ops_lock);
|
||||
@@ -417,7 +425,7 @@ static int msm_ext_disp_audio_codec_rx_dai_hw_params(
|
||||
struct msm_ext_disp_audio_setup_params audio_setup_params = {0};
|
||||
|
||||
struct msm_ext_disp_audio_codec_rx_data *codec_data =
|
||||
dev_get_drvdata(dai->codec->dev);
|
||||
dev_get_drvdata(dai->component->dev);
|
||||
|
||||
if (!codec_data || !codec_data->ext_disp_ops.audio_info_setup) {
|
||||
dev_err(dai->dev, "%s: codec_data or audio_info_setup is null\n",
|
||||
@@ -425,7 +433,8 @@ static int msm_ext_disp_audio_codec_rx_dai_hw_params(
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
dev_dbg(dai->codec->dev, "%s: DP ctl id %d Stream id %d\n", __func__,
|
||||
dev_dbg(dai->component->dev, "%s: DP ctl id %d Stream id %d\n",
|
||||
__func__,
|
||||
codec_data->ctl[dai->id], codec_data->stream[dai->id]);
|
||||
|
||||
if (codec_data->cable_status < 0) {
|
||||
@@ -507,7 +516,7 @@ static void msm_ext_disp_audio_codec_rx_dai_shutdown(
|
||||
struct msm_ext_disp_codec_id codec_info;
|
||||
|
||||
struct msm_ext_disp_audio_codec_rx_data *codec_data =
|
||||
dev_get_drvdata(dai->codec->dev);
|
||||
dev_get_drvdata(dai->component->dev);
|
||||
|
||||
if (!codec_data || !codec_data->ext_disp_ops.teardown_done ||
|
||||
!codec_data->ext_disp_ops.cable_status) {
|
||||
@@ -516,7 +525,8 @@ static void msm_ext_disp_audio_codec_rx_dai_shutdown(
|
||||
return;
|
||||
}
|
||||
|
||||
dev_dbg(dai->codec->dev, "%s: DP ctl id %d Stream id %d\n", __func__,
|
||||
dev_dbg(dai->component->dev, "%s: DP ctl id %d Stream id %d\n",
|
||||
__func__,
|
||||
codec_data->ctl[dai->id], codec_data->stream[dai->id]);
|
||||
|
||||
mutex_lock(&codec_data->dp_ops_lock);
|
||||
@@ -534,7 +544,8 @@ static void msm_ext_disp_audio_codec_rx_dai_shutdown(
|
||||
mutex_unlock(&codec_data->dp_ops_lock);
|
||||
}
|
||||
|
||||
static int msm_ext_disp_audio_codec_rx_probe(struct snd_soc_codec *codec)
|
||||
static int msm_ext_disp_audio_codec_rx_probe(
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
struct msm_ext_disp_audio_codec_rx_data *codec_data;
|
||||
struct device_node *of_node_parent = NULL;
|
||||
@@ -543,14 +554,14 @@ static int msm_ext_disp_audio_codec_rx_probe(struct snd_soc_codec *codec)
|
||||
GFP_KERNEL);
|
||||
|
||||
if (!codec_data) {
|
||||
dev_err(codec->dev, "%s(): fail to allocate dai data\n",
|
||||
dev_err(component->dev, "%s(): fail to allocate dai data\n",
|
||||
__func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
of_node_parent = of_get_parent(codec->dev->of_node);
|
||||
of_node_parent = of_get_parent(component->dev->of_node);
|
||||
if (!of_node_parent) {
|
||||
dev_err(codec->dev, "%s(): Parent device tree node not found\n",
|
||||
dev_err(component->dev, "%s(): Parent device tree node not found\n",
|
||||
__func__);
|
||||
kfree(codec_data);
|
||||
return -ENODEV;
|
||||
@@ -558,37 +569,39 @@ static int msm_ext_disp_audio_codec_rx_probe(struct snd_soc_codec *codec)
|
||||
|
||||
codec_data->ext_disp_core_pdev = of_find_device_by_node(of_node_parent);
|
||||
if (!codec_data->ext_disp_core_pdev) {
|
||||
dev_err(codec->dev, "%s(): can't get parent pdev\n", __func__);
|
||||
dev_err(component->dev, "%s(): can't get parent pdev\n",
|
||||
__func__);
|
||||
kfree(codec_data);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
if (msm_ext_disp_register_audio_codec(codec_data->ext_disp_core_pdev,
|
||||
&codec_data->ext_disp_ops)) {
|
||||
dev_err(codec->dev, "%s(): can't register with ext disp core",
|
||||
dev_err(component->dev, "%s(): can't register with ext disp core",
|
||||
__func__);
|
||||
kfree(codec_data);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
mutex_init(&codec_data->dp_ops_lock);
|
||||
dev_set_drvdata(codec->dev, codec_data);
|
||||
dev_set_drvdata(component->dev, codec_data);
|
||||
|
||||
dev_dbg(codec->dev, "%s(): registered %s with ext disp core\n",
|
||||
__func__, codec->component.name);
|
||||
dev_dbg(component->dev, "%s(): registered %s with ext disp core\n",
|
||||
__func__, component->name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int msm_ext_disp_audio_codec_rx_remove(struct snd_soc_codec *codec)
|
||||
static void msm_ext_disp_audio_codec_rx_remove(
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
struct msm_ext_disp_audio_codec_rx_data *codec_data;
|
||||
|
||||
codec_data = dev_get_drvdata(codec->dev);
|
||||
codec_data = dev_get_drvdata(component->dev);
|
||||
mutex_destroy(&codec_data->dp_ops_lock);
|
||||
kfree(codec_data);
|
||||
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
static struct snd_soc_dai_ops msm_ext_disp_audio_codec_rx_dai_ops = {
|
||||
@@ -648,13 +661,12 @@ static struct snd_soc_dai_driver msm_ext_disp_audio_codec_rx_dais[] = {
|
||||
},
|
||||
};
|
||||
|
||||
static struct snd_soc_codec_driver msm_ext_disp_audio_codec_rx_soc_driver = {
|
||||
static const struct snd_soc_component_driver msm_ext_disp_codec_rx_driver = {
|
||||
.name = DRV_NAME,
|
||||
.probe = msm_ext_disp_audio_codec_rx_probe,
|
||||
.remove = msm_ext_disp_audio_codec_rx_remove,
|
||||
.component_driver = {
|
||||
.controls = msm_ext_disp_codec_rx_controls,
|
||||
.num_controls = ARRAY_SIZE(msm_ext_disp_codec_rx_controls),
|
||||
},
|
||||
};
|
||||
|
||||
static int msm_ext_disp_audio_codec_rx_plat_probe(
|
||||
@@ -663,8 +675,8 @@ static int msm_ext_disp_audio_codec_rx_plat_probe(
|
||||
dev_dbg(&pdev->dev, "%s(): dev name %s\n", __func__,
|
||||
dev_name(&pdev->dev));
|
||||
|
||||
return snd_soc_register_codec(&pdev->dev,
|
||||
&msm_ext_disp_audio_codec_rx_soc_driver,
|
||||
return snd_soc_register_component(&pdev->dev,
|
||||
&msm_ext_disp_codec_rx_driver,
|
||||
msm_ext_disp_audio_codec_rx_dais,
|
||||
ARRAY_SIZE(msm_ext_disp_audio_codec_rx_dais));
|
||||
}
|
||||
@@ -672,7 +684,7 @@ static int msm_ext_disp_audio_codec_rx_plat_probe(
|
||||
static int msm_ext_disp_audio_codec_rx_plat_remove(
|
||||
struct platform_device *pdev)
|
||||
{
|
||||
snd_soc_unregister_codec(&pdev->dev);
|
||||
snd_soc_unregister_component(&pdev->dev);
|
||||
return 0;
|
||||
}
|
||||
static const struct of_device_id msm_ext_disp_audio_codec_rx_dt_match[] = {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/* Copyright (c) 2011-2014, 2017 The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2011-2014, 2017-2018 The Linux Foundation. All rights reserved.
|
||||
|
||||
*/
|
||||
#include <linux/platform_device.h>
|
||||
@@ -10,6 +10,8 @@
|
||||
#include <sound/pcm.h>
|
||||
#include <sound/soc.h>
|
||||
|
||||
#define DRV_NAME "msm-stub-codec"
|
||||
|
||||
/* A dummy driver useful only to advertise hardware parameters */
|
||||
static struct snd_soc_dai_driver msm_stub_dais[] = {
|
||||
{
|
||||
@@ -35,19 +37,21 @@ static struct snd_soc_dai_driver msm_stub_dais[] = {
|
||||
},
|
||||
};
|
||||
|
||||
static struct snd_soc_codec_driver soc_msm_stub = {};
|
||||
static const struct snd_soc_component_driver soc_msm_stub = {
|
||||
.name = DRV_NAME,
|
||||
};
|
||||
|
||||
static int msm_stub_dev_probe(struct platform_device *pdev)
|
||||
{
|
||||
dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev));
|
||||
|
||||
return snd_soc_register_codec(&pdev->dev,
|
||||
return snd_soc_register_component(&pdev->dev,
|
||||
&soc_msm_stub, msm_stub_dais, ARRAY_SIZE(msm_stub_dais));
|
||||
}
|
||||
|
||||
static int msm_stub_dev_remove(struct platform_device *pdev)
|
||||
{
|
||||
snd_soc_unregister_codec(&pdev->dev);
|
||||
snd_soc_unregister_component(&pdev->dev);
|
||||
return 0;
|
||||
}
|
||||
static const struct of_device_id msm_stub_codec_dt_match[] = {
|
||||
|
@@ -13,7 +13,7 @@
|
||||
|
||||
#define WCD_USLEEP_RANGE 50
|
||||
|
||||
static void (*clsh_state_fp[NUM_CLSH_STATES])(struct snd_soc_codec *,
|
||||
static void (*clsh_state_fp[NUM_CLSH_STATES])(struct snd_soc_component *,
|
||||
struct wcd_clsh_cdc_info *,
|
||||
u8 req_state, bool en, int mode);
|
||||
|
||||
@@ -103,66 +103,82 @@ static inline void wcd_clsh_set_int_mode(struct wcd_clsh_cdc_info *clsh_d,
|
||||
clsh_d->interpolator_modes[ffs(clsh_state)] = mode;
|
||||
}
|
||||
|
||||
static inline void wcd_clsh_set_buck_mode(struct snd_soc_codec *codec,
|
||||
static inline void wcd_clsh_set_buck_mode(struct snd_soc_component *component,
|
||||
int mode)
|
||||
{
|
||||
if (mode == CLS_H_HIFI || mode == CLS_H_LOHIFI ||
|
||||
mode == CLS_AB_HIFI)
|
||||
snd_soc_update_bits(codec, WCD9XXX_ANA_RX_SUPPLIES,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD9XXX_ANA_RX_SUPPLIES,
|
||||
0x08, 0x08); /* set to HIFI */
|
||||
else
|
||||
snd_soc_update_bits(codec, WCD9XXX_ANA_RX_SUPPLIES,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD9XXX_ANA_RX_SUPPLIES,
|
||||
0x08, 0x00); /* set to default */
|
||||
}
|
||||
|
||||
static inline void wcd_clsh_set_flyback_mode(struct snd_soc_codec *codec,
|
||||
static inline void wcd_clsh_set_flyback_mode(
|
||||
struct snd_soc_component *component,
|
||||
int mode)
|
||||
{
|
||||
if (mode == CLS_H_HIFI || mode == CLS_H_LOHIFI ||
|
||||
mode == CLS_AB_HIFI) {
|
||||
snd_soc_update_bits(codec, WCD9XXX_ANA_RX_SUPPLIES,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD9XXX_ANA_RX_SUPPLIES,
|
||||
0x04, 0x04);
|
||||
snd_soc_update_bits(codec, WCD9XXX_FLYBACK_VNEG_CTRL_4,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD9XXX_FLYBACK_VNEG_CTRL_4,
|
||||
0xF0, 0x80);
|
||||
} else {
|
||||
snd_soc_update_bits(codec, WCD9XXX_ANA_RX_SUPPLIES,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD9XXX_ANA_RX_SUPPLIES,
|
||||
0x04, 0x00); /* set to Default */
|
||||
snd_soc_update_bits(codec, WCD9XXX_FLYBACK_VNEG_CTRL_4,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD9XXX_FLYBACK_VNEG_CTRL_4,
|
||||
0xF0, 0x70);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void wcd_clsh_force_iq_ctl(struct snd_soc_codec *codec,
|
||||
static inline void wcd_clsh_force_iq_ctl(struct snd_soc_component *component,
|
||||
int mode, bool enable)
|
||||
{
|
||||
if (enable) {
|
||||
snd_soc_update_bits(codec, WCD9XXX_FLYBACK_VNEGDAC_CTRL_2,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD9XXX_FLYBACK_VNEGDAC_CTRL_2,
|
||||
0xE0, 0xA0);
|
||||
/* 100usec delay is needed as per HW requirement */
|
||||
usleep_range(100, 110);
|
||||
snd_soc_update_bits(codec, WCD9XXX_CLASSH_MODE_3,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD9XXX_CLASSH_MODE_3,
|
||||
0x02, 0x02);
|
||||
snd_soc_update_bits(codec, WCD9XXX_CLASSH_MODE_2,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD9XXX_CLASSH_MODE_2,
|
||||
0xFF, 0x1C);
|
||||
if (mode == CLS_H_LOHIFI) {
|
||||
snd_soc_update_bits(codec, WCD9XXX_HPH_NEW_INT_PA_MISC2,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD9XXX_HPH_NEW_INT_PA_MISC2,
|
||||
0x20, 0x20);
|
||||
snd_soc_update_bits(codec, WCD9XXX_RX_BIAS_HPH_LOWPOWER,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD9XXX_RX_BIAS_HPH_LOWPOWER,
|
||||
0xF0, 0xC0);
|
||||
snd_soc_update_bits(codec, WCD9XXX_HPH_PA_CTL1,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD9XXX_HPH_PA_CTL1,
|
||||
0x0E, 0x02);
|
||||
}
|
||||
} else {
|
||||
snd_soc_update_bits(codec, WCD9XXX_HPH_NEW_INT_PA_MISC2,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD9XXX_HPH_NEW_INT_PA_MISC2,
|
||||
0x20, 0x00);
|
||||
snd_soc_update_bits(codec, WCD9XXX_RX_BIAS_HPH_LOWPOWER,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD9XXX_RX_BIAS_HPH_LOWPOWER,
|
||||
0xF0, 0x80);
|
||||
snd_soc_update_bits(codec, WCD9XXX_HPH_PA_CTL1,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD9XXX_HPH_PA_CTL1,
|
||||
0x0E, 0x06);
|
||||
}
|
||||
}
|
||||
|
||||
static void wcd_clsh_buck_ctrl(struct snd_soc_codec *codec,
|
||||
static void wcd_clsh_buck_ctrl(struct snd_soc_component *component,
|
||||
struct wcd_clsh_cdc_info *clsh_d,
|
||||
int mode,
|
||||
bool enable)
|
||||
@@ -170,7 +186,8 @@ static void wcd_clsh_buck_ctrl(struct snd_soc_codec *codec,
|
||||
/* enable/disable buck */
|
||||
if ((enable && (++clsh_d->buck_users == 1)) ||
|
||||
(!enable && (--clsh_d->buck_users == 0))) {
|
||||
snd_soc_update_bits(codec, WCD9XXX_ANA_RX_SUPPLIES,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD9XXX_ANA_RX_SUPPLIES,
|
||||
(1 << 7), (enable << 7));
|
||||
/*
|
||||
* 500us sleep is required after buck enable/disable
|
||||
@@ -179,18 +196,21 @@ static void wcd_clsh_buck_ctrl(struct snd_soc_codec *codec,
|
||||
usleep_range(500, 510);
|
||||
if (mode == CLS_H_LOHIFI || mode == CLS_H_ULP ||
|
||||
mode == CLS_H_HIFI || mode == CLS_H_LP)
|
||||
snd_soc_update_bits(codec, WCD9XXX_CLASSH_MODE_3,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD9XXX_CLASSH_MODE_3,
|
||||
0x02, 0x00);
|
||||
|
||||
snd_soc_update_bits(codec, WCD9XXX_CLASSH_MODE_2, 0xFF, 0x3A);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD9XXX_CLASSH_MODE_2,
|
||||
0xFF, 0x3A);
|
||||
/* 500usec delay is needed as per HW requirement */
|
||||
usleep_range(500, 500 + WCD_USLEEP_RANGE);
|
||||
}
|
||||
dev_dbg(codec->dev, "%s: buck_users %d, enable %d, mode: %s\n",
|
||||
dev_dbg(component->dev, "%s: buck_users %d, enable %d, mode: %s\n",
|
||||
__func__, clsh_d->buck_users, enable, mode_to_str(mode));
|
||||
}
|
||||
|
||||
static void wcd_clsh_flyback_ctrl(struct snd_soc_codec *codec,
|
||||
static void wcd_clsh_flyback_ctrl(struct snd_soc_component *component,
|
||||
struct wcd_clsh_cdc_info *clsh_d,
|
||||
int mode,
|
||||
bool enable)
|
||||
@@ -198,23 +218,25 @@ static void wcd_clsh_flyback_ctrl(struct snd_soc_codec *codec,
|
||||
/* enable/disable flyback */
|
||||
if ((enable && (++clsh_d->flyback_users == 1)) ||
|
||||
(!enable && (--clsh_d->flyback_users == 0))) {
|
||||
snd_soc_update_bits(codec, WCD9XXX_ANA_RX_SUPPLIES,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD9XXX_ANA_RX_SUPPLIES,
|
||||
(1 << 6), (enable << 6));
|
||||
/*
|
||||
* 100us sleep is required after flyback enable/disable
|
||||
* as per HW requirement
|
||||
*/
|
||||
usleep_range(100, 110);
|
||||
snd_soc_update_bits(codec, WCD9XXX_FLYBACK_VNEGDAC_CTRL_2,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD9XXX_FLYBACK_VNEGDAC_CTRL_2,
|
||||
0xE0, 0xE0);
|
||||
/* 500usec delay is needed as per HW requirement */
|
||||
usleep_range(500, 500 + WCD_USLEEP_RANGE);
|
||||
}
|
||||
dev_dbg(codec->dev, "%s: flyback_users %d, enable %d, mode: %s\n",
|
||||
dev_dbg(component->dev, "%s: flyback_users %d, enable %d, mode: %s\n",
|
||||
__func__, clsh_d->flyback_users, enable, mode_to_str(mode));
|
||||
}
|
||||
|
||||
static void wcd_clsh_set_hph_mode(struct snd_soc_codec *codec,
|
||||
static void wcd_clsh_set_hph_mode(struct snd_soc_component *component,
|
||||
int mode)
|
||||
{
|
||||
u8 val = 0;
|
||||
@@ -236,185 +258,189 @@ static void wcd_clsh_set_hph_mode(struct snd_soc_codec *codec,
|
||||
val = 0x04;
|
||||
break;
|
||||
default:
|
||||
dev_err(codec->dev, "%s:Invalid mode %d\n", __func__, mode);
|
||||
dev_err(component->dev, "%s:Invalid mode %d\n", __func__, mode);
|
||||
return;
|
||||
};
|
||||
|
||||
snd_soc_update_bits(codec, WCD9XXX_ANA_HPH, 0x0C, val);
|
||||
snd_soc_component_update_bits(component, WCD9XXX_ANA_HPH, 0x0C, val);
|
||||
}
|
||||
|
||||
static void wcd_clsh_set_flyback_current(struct snd_soc_codec *codec, int mode)
|
||||
static void wcd_clsh_set_flyback_current(struct snd_soc_component *component,
|
||||
int mode)
|
||||
{
|
||||
|
||||
snd_soc_update_bits(codec, WCD9XXX_RX_BIAS_FLYB_BUFF, 0x0F, 0x0A);
|
||||
snd_soc_update_bits(codec, WCD9XXX_RX_BIAS_FLYB_BUFF, 0xF0, 0xA0);
|
||||
snd_soc_component_update_bits(component, WCD9XXX_RX_BIAS_FLYB_BUFF,
|
||||
0x0F, 0x0A);
|
||||
snd_soc_component_update_bits(component, WCD9XXX_RX_BIAS_FLYB_BUFF,
|
||||
0xF0, 0xA0);
|
||||
/* Sleep needed to avoid click and pop as per HW requirement */
|
||||
usleep_range(100, 110);
|
||||
}
|
||||
|
||||
static void wcd_clsh_set_buck_regulator_mode(struct snd_soc_codec *codec,
|
||||
static void wcd_clsh_set_buck_regulator_mode(
|
||||
struct snd_soc_component *component,
|
||||
int mode)
|
||||
{
|
||||
snd_soc_update_bits(codec, WCD9XXX_ANA_RX_SUPPLIES,
|
||||
snd_soc_component_update_bits(component, WCD9XXX_ANA_RX_SUPPLIES,
|
||||
0x02, 0x00);
|
||||
}
|
||||
|
||||
static void wcd_clsh_state_ear_aux(struct snd_soc_codec *codec,
|
||||
static void wcd_clsh_state_ear_aux(struct snd_soc_component *component,
|
||||
struct wcd_clsh_cdc_info *clsh_d,
|
||||
u8 req_state, bool is_enable, int mode)
|
||||
{
|
||||
dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode),
|
||||
is_enable ? "enable" : "disable");
|
||||
dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__,
|
||||
mode_to_str(mode), is_enable ? "enable" : "disable");
|
||||
}
|
||||
|
||||
static void wcd_clsh_state_hph_aux(struct snd_soc_codec *codec,
|
||||
static void wcd_clsh_state_hph_aux(struct snd_soc_component *component,
|
||||
struct wcd_clsh_cdc_info *clsh_d,
|
||||
u8 req_state, bool is_enable, int mode)
|
||||
{
|
||||
dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode),
|
||||
is_enable ? "enable" : "disable");
|
||||
dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__,
|
||||
mode_to_str(mode), is_enable ? "enable" : "disable");
|
||||
}
|
||||
|
||||
static void wcd_clsh_state_hph_ear(struct snd_soc_codec *codec,
|
||||
static void wcd_clsh_state_hph_ear(struct snd_soc_component *component,
|
||||
struct wcd_clsh_cdc_info *clsh_d,
|
||||
u8 req_state, bool is_enable, int mode)
|
||||
{
|
||||
dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode),
|
||||
is_enable ? "enable" : "disable");
|
||||
dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__,
|
||||
mode_to_str(mode), is_enable ? "enable" : "disable");
|
||||
}
|
||||
|
||||
static void wcd_clsh_state_hph_st(struct snd_soc_codec *codec,
|
||||
static void wcd_clsh_state_hph_st(struct snd_soc_component *component,
|
||||
struct wcd_clsh_cdc_info *clsh_d,
|
||||
u8 req_state, bool is_enable, int mode)
|
||||
{
|
||||
dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode),
|
||||
is_enable ? "enable" : "disable");
|
||||
dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__,
|
||||
mode_to_str(mode), is_enable ? "enable" : "disable");
|
||||
}
|
||||
|
||||
static void wcd_clsh_state_hph_r(struct snd_soc_codec *codec,
|
||||
static void wcd_clsh_state_hph_r(struct snd_soc_component *component,
|
||||
struct wcd_clsh_cdc_info *clsh_d,
|
||||
u8 req_state, bool is_enable, int mode)
|
||||
{
|
||||
dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode),
|
||||
is_enable ? "enable" : "disable");
|
||||
dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__,
|
||||
mode_to_str(mode), is_enable ? "enable" : "disable");
|
||||
|
||||
if (mode == CLS_H_NORMAL) {
|
||||
dev_dbg(codec->dev, "%s: Normal mode not applicable for hph_r\n",
|
||||
dev_dbg(component->dev, "%s: Normal mode not applicable for hph_r\n",
|
||||
__func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_enable) {
|
||||
wcd_clsh_set_buck_regulator_mode(codec, mode);
|
||||
wcd_clsh_set_flyback_mode(codec, mode);
|
||||
wcd_clsh_force_iq_ctl(codec, mode, true);
|
||||
wcd_clsh_flyback_ctrl(codec, clsh_d, mode, true);
|
||||
wcd_clsh_set_flyback_current(codec, mode);
|
||||
wcd_clsh_set_buck_mode(codec, mode);
|
||||
wcd_clsh_buck_ctrl(codec, clsh_d, mode, true);
|
||||
wcd_clsh_set_hph_mode(codec, mode);
|
||||
wcd_clsh_set_buck_regulator_mode(component, mode);
|
||||
wcd_clsh_set_flyback_mode(component, mode);
|
||||
wcd_clsh_force_iq_ctl(component, mode, true);
|
||||
wcd_clsh_flyback_ctrl(component, clsh_d, mode, true);
|
||||
wcd_clsh_set_flyback_current(component, mode);
|
||||
wcd_clsh_set_buck_mode(component, mode);
|
||||
wcd_clsh_buck_ctrl(component, clsh_d, mode, true);
|
||||
wcd_clsh_set_hph_mode(component, mode);
|
||||
} else {
|
||||
wcd_clsh_set_hph_mode(codec, CLS_H_NORMAL);
|
||||
wcd_clsh_set_hph_mode(component, CLS_H_NORMAL);
|
||||
|
||||
/* buck and flyback set to default mode and disable */
|
||||
wcd_clsh_flyback_ctrl(codec, clsh_d, CLS_H_NORMAL, false);
|
||||
wcd_clsh_buck_ctrl(codec, clsh_d, CLS_H_NORMAL, false);
|
||||
wcd_clsh_force_iq_ctl(codec, CLS_H_NORMAL, false);
|
||||
wcd_clsh_set_flyback_mode(codec, CLS_H_NORMAL);
|
||||
wcd_clsh_set_buck_mode(codec, CLS_H_NORMAL);
|
||||
wcd_clsh_flyback_ctrl(component, clsh_d, CLS_H_NORMAL, false);
|
||||
wcd_clsh_buck_ctrl(component, clsh_d, CLS_H_NORMAL, false);
|
||||
wcd_clsh_force_iq_ctl(component, CLS_H_NORMAL, false);
|
||||
wcd_clsh_set_flyback_mode(component, CLS_H_NORMAL);
|
||||
wcd_clsh_set_buck_mode(component, CLS_H_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
static void wcd_clsh_state_hph_l(struct snd_soc_codec *codec,
|
||||
static void wcd_clsh_state_hph_l(struct snd_soc_component *component,
|
||||
struct wcd_clsh_cdc_info *clsh_d,
|
||||
u8 req_state, bool is_enable, int mode)
|
||||
{
|
||||
dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode),
|
||||
is_enable ? "enable" : "disable");
|
||||
dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__,
|
||||
mode_to_str(mode), is_enable ? "enable" : "disable");
|
||||
|
||||
if (mode == CLS_H_NORMAL) {
|
||||
dev_dbg(codec->dev, "%s: Normal mode not applicable for hph_l\n",
|
||||
dev_dbg(component->dev, "%s: Normal mode not applicable for hph_l\n",
|
||||
__func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_enable) {
|
||||
wcd_clsh_set_buck_regulator_mode(codec, mode);
|
||||
wcd_clsh_set_flyback_mode(codec, mode);
|
||||
wcd_clsh_force_iq_ctl(codec, mode, true);
|
||||
wcd_clsh_flyback_ctrl(codec, clsh_d, mode, true);
|
||||
wcd_clsh_set_flyback_current(codec, mode);
|
||||
wcd_clsh_set_buck_mode(codec, mode);
|
||||
wcd_clsh_buck_ctrl(codec, clsh_d, mode, true);
|
||||
wcd_clsh_set_hph_mode(codec, mode);
|
||||
wcd_clsh_set_buck_regulator_mode(component, mode);
|
||||
wcd_clsh_set_flyback_mode(component, mode);
|
||||
wcd_clsh_force_iq_ctl(component, mode, true);
|
||||
wcd_clsh_flyback_ctrl(component, clsh_d, mode, true);
|
||||
wcd_clsh_set_flyback_current(component, mode);
|
||||
wcd_clsh_set_buck_mode(component, mode);
|
||||
wcd_clsh_buck_ctrl(component, clsh_d, mode, true);
|
||||
wcd_clsh_set_hph_mode(component, mode);
|
||||
} else {
|
||||
wcd_clsh_set_hph_mode(codec, CLS_H_NORMAL);
|
||||
wcd_clsh_set_hph_mode(component, CLS_H_NORMAL);
|
||||
|
||||
/* set buck and flyback to Default Mode */
|
||||
wcd_clsh_flyback_ctrl(codec, clsh_d, CLS_H_NORMAL, false);
|
||||
wcd_clsh_buck_ctrl(codec, clsh_d, CLS_H_NORMAL, false);
|
||||
wcd_clsh_force_iq_ctl(codec, CLS_H_NORMAL, false);
|
||||
wcd_clsh_set_flyback_mode(codec, CLS_H_NORMAL);
|
||||
wcd_clsh_set_buck_mode(codec, CLS_H_NORMAL);
|
||||
wcd_clsh_flyback_ctrl(component, clsh_d, CLS_H_NORMAL, false);
|
||||
wcd_clsh_buck_ctrl(component, clsh_d, CLS_H_NORMAL, false);
|
||||
wcd_clsh_force_iq_ctl(component, CLS_H_NORMAL, false);
|
||||
wcd_clsh_set_flyback_mode(component, CLS_H_NORMAL);
|
||||
wcd_clsh_set_buck_mode(component, CLS_H_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
static void wcd_clsh_state_aux(struct snd_soc_codec *codec,
|
||||
static void wcd_clsh_state_aux(struct snd_soc_component *component,
|
||||
struct wcd_clsh_cdc_info *clsh_d,
|
||||
u8 req_state, bool is_enable, int mode)
|
||||
{
|
||||
dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode),
|
||||
is_enable ? "enable" : "disable");
|
||||
dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__,
|
||||
mode_to_str(mode), is_enable ? "enable" : "disable");
|
||||
|
||||
if (is_enable) {
|
||||
wcd_clsh_set_buck_mode(codec, mode);
|
||||
wcd_clsh_set_flyback_mode(codec, mode);
|
||||
wcd_clsh_flyback_ctrl(codec, clsh_d, mode, true);
|
||||
wcd_clsh_set_flyback_current(codec, mode);
|
||||
wcd_clsh_buck_ctrl(codec, clsh_d, mode, true);
|
||||
wcd_clsh_set_buck_mode(component, mode);
|
||||
wcd_clsh_set_flyback_mode(component, mode);
|
||||
wcd_clsh_flyback_ctrl(component, clsh_d, mode, true);
|
||||
wcd_clsh_set_flyback_current(component, mode);
|
||||
wcd_clsh_buck_ctrl(component, clsh_d, mode, true);
|
||||
} else {
|
||||
wcd_clsh_buck_ctrl(codec, clsh_d, mode, false);
|
||||
wcd_clsh_flyback_ctrl(codec, clsh_d, mode, false);
|
||||
wcd_clsh_set_flyback_mode(codec, CLS_H_NORMAL);
|
||||
wcd_clsh_set_buck_mode(codec, CLS_H_NORMAL);
|
||||
wcd_clsh_buck_ctrl(component, clsh_d, mode, false);
|
||||
wcd_clsh_flyback_ctrl(component, clsh_d, mode, false);
|
||||
wcd_clsh_set_flyback_mode(component, CLS_H_NORMAL);
|
||||
wcd_clsh_set_buck_mode(component, CLS_H_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
static void wcd_clsh_state_ear(struct snd_soc_codec *codec,
|
||||
static void wcd_clsh_state_ear(struct snd_soc_component *component,
|
||||
struct wcd_clsh_cdc_info *clsh_d,
|
||||
u8 req_state, bool is_enable, int mode)
|
||||
{
|
||||
dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode),
|
||||
dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__,
|
||||
mode_to_str(mode),
|
||||
is_enable ? "enable" : "disable");
|
||||
|
||||
if (is_enable) {
|
||||
wcd_clsh_set_buck_regulator_mode(codec, mode);
|
||||
wcd_clsh_set_flyback_mode(codec, mode);
|
||||
wcd_clsh_force_iq_ctl(codec, mode, true);
|
||||
wcd_clsh_flyback_ctrl(codec, clsh_d, mode, true);
|
||||
wcd_clsh_set_flyback_current(codec, mode);
|
||||
wcd_clsh_set_buck_mode(codec, mode);
|
||||
wcd_clsh_buck_ctrl(codec, clsh_d, mode, true);
|
||||
wcd_clsh_set_hph_mode(codec, mode);
|
||||
wcd_clsh_set_buck_regulator_mode(component, mode);
|
||||
wcd_clsh_set_flyback_mode(component, mode);
|
||||
wcd_clsh_force_iq_ctl(component, mode, true);
|
||||
wcd_clsh_flyback_ctrl(component, clsh_d, mode, true);
|
||||
wcd_clsh_set_flyback_current(component, mode);
|
||||
wcd_clsh_set_buck_mode(component, mode);
|
||||
wcd_clsh_buck_ctrl(component, clsh_d, mode, true);
|
||||
wcd_clsh_set_hph_mode(component, mode);
|
||||
} else {
|
||||
wcd_clsh_set_hph_mode(codec, CLS_H_NORMAL);
|
||||
wcd_clsh_set_hph_mode(component, CLS_H_NORMAL);
|
||||
|
||||
/* set buck and flyback to Default Mode */
|
||||
wcd_clsh_flyback_ctrl(codec, clsh_d, CLS_H_NORMAL, false);
|
||||
wcd_clsh_buck_ctrl(codec, clsh_d, CLS_H_NORMAL, false);
|
||||
wcd_clsh_force_iq_ctl(codec, CLS_H_NORMAL, false);
|
||||
wcd_clsh_set_flyback_mode(codec, CLS_H_NORMAL);
|
||||
wcd_clsh_set_buck_mode(codec, CLS_H_NORMAL);
|
||||
wcd_clsh_flyback_ctrl(component, clsh_d, CLS_H_NORMAL, false);
|
||||
wcd_clsh_buck_ctrl(component, clsh_d, CLS_H_NORMAL, false);
|
||||
wcd_clsh_force_iq_ctl(component, CLS_H_NORMAL, false);
|
||||
wcd_clsh_set_flyback_mode(component, CLS_H_NORMAL);
|
||||
wcd_clsh_set_buck_mode(component, CLS_H_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
static void wcd_clsh_state_err(struct snd_soc_codec *codec,
|
||||
static void wcd_clsh_state_err(struct snd_soc_component *component,
|
||||
struct wcd_clsh_cdc_info *clsh_d,
|
||||
u8 req_state, bool is_enable, int mode)
|
||||
{
|
||||
char msg[128];
|
||||
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s Wrong request for class H state machine requested to %s %s\n",
|
||||
__func__, is_enable ? "enable" : "disable",
|
||||
state_to_str(req_state, msg, sizeof(msg)));
|
||||
@@ -447,14 +473,14 @@ static bool wcd_clsh_is_state_valid(u8 state)
|
||||
|
||||
/*
|
||||
* Function: wcd_cls_h_fsm
|
||||
* Params: codec, cdc_clsh_d, req_state, req_type, clsh_event
|
||||
* Params: component, cdc_clsh_d, req_state, req_type, clsh_event
|
||||
* Description:
|
||||
* This function handles PRE DAC and POST DAC conditions of different devices
|
||||
* and updates class H configuration of different combination of devices
|
||||
* based on validity of their states. cdc_clsh_d will contain current
|
||||
* class h state information
|
||||
*/
|
||||
void wcd_cls_h_fsm(struct snd_soc_codec *codec,
|
||||
void wcd_cls_h_fsm(struct snd_soc_component *component,
|
||||
struct wcd_clsh_cdc_info *cdc_clsh_d,
|
||||
u8 clsh_event, u8 req_state,
|
||||
int int_mode)
|
||||
@@ -468,14 +494,14 @@ void wcd_cls_h_fsm(struct snd_soc_codec *codec,
|
||||
new_state = old_state | req_state;
|
||||
|
||||
if (!wcd_clsh_is_state_valid(new_state)) {
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s: Class-H not a valid new state: %s\n",
|
||||
__func__,
|
||||
state_to_str(new_state, msg0, sizeof(msg0)));
|
||||
return;
|
||||
}
|
||||
if (new_state == old_state) {
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s: Class-H already in requested state: %s\n",
|
||||
__func__,
|
||||
state_to_str(new_state, msg0, sizeof(msg0)));
|
||||
@@ -483,9 +509,9 @@ void wcd_cls_h_fsm(struct snd_soc_codec *codec,
|
||||
}
|
||||
cdc_clsh_d->state = new_state;
|
||||
wcd_clsh_set_int_mode(cdc_clsh_d, req_state, int_mode);
|
||||
(*clsh_state_fp[new_state]) (codec, cdc_clsh_d, req_state,
|
||||
(*clsh_state_fp[new_state]) (component, cdc_clsh_d, req_state,
|
||||
CLSH_REQ_ENABLE, int_mode);
|
||||
dev_dbg(codec->dev,
|
||||
dev_dbg(component->dev,
|
||||
"%s: ClassH state transition from %s to %s\n",
|
||||
__func__, state_to_str(old_state, msg0, sizeof(msg0)),
|
||||
state_to_str(cdc_clsh_d->state, msg1, sizeof(msg1)));
|
||||
@@ -495,7 +521,7 @@ void wcd_cls_h_fsm(struct snd_soc_codec *codec,
|
||||
new_state = old_state & (~req_state);
|
||||
if (new_state < NUM_CLSH_STATES) {
|
||||
if (!wcd_clsh_is_state_valid(old_state)) {
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s:Invalid old state:%s\n",
|
||||
__func__,
|
||||
state_to_str(old_state, msg0,
|
||||
@@ -503,19 +529,19 @@ void wcd_cls_h_fsm(struct snd_soc_codec *codec,
|
||||
return;
|
||||
}
|
||||
if (new_state == old_state) {
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s: Class-H already in requested state: %s\n",
|
||||
__func__,
|
||||
state_to_str(new_state, msg0,
|
||||
sizeof(msg0)));
|
||||
return;
|
||||
}
|
||||
(*clsh_state_fp[old_state]) (codec, cdc_clsh_d,
|
||||
(*clsh_state_fp[old_state]) (component, cdc_clsh_d,
|
||||
req_state, CLSH_REQ_DISABLE,
|
||||
int_mode);
|
||||
cdc_clsh_d->state = new_state;
|
||||
wcd_clsh_set_int_mode(cdc_clsh_d, req_state, CLS_NONE);
|
||||
dev_dbg(codec->dev, "%s: ClassH state transition from %s to %s\n",
|
||||
dev_dbg(component->dev, "%s: ClassH state transition from %s to %s\n",
|
||||
__func__, state_to_str(old_state, msg0,
|
||||
sizeof(msg0)),
|
||||
state_to_str(cdc_clsh_d->state, msg1,
|
||||
|
@@ -74,14 +74,14 @@ struct wcd_clsh_cdc_info {
|
||||
};
|
||||
|
||||
#ifdef CONFIG_SND_SOC_WCD9XXX_V2
|
||||
extern void wcd_cls_h_fsm(struct snd_soc_codec *codec,
|
||||
extern void wcd_cls_h_fsm(struct snd_soc_component *component,
|
||||
struct wcd_clsh_cdc_info *cdc_clsh_d,
|
||||
u8 clsh_event, u8 req_state,
|
||||
int int_mode);
|
||||
|
||||
extern void wcd_cls_h_init(struct wcd_clsh_cdc_info *clsh);
|
||||
#else
|
||||
extern void wcd_cls_h_fsm(struct snd_soc_codec *codec,
|
||||
extern void wcd_cls_h_fsm(struct snd_soc_component *component,
|
||||
struct wcd_clsh_cdc_info *cdc_clsh_d,
|
||||
u8 clsh_event, u8 req_state,
|
||||
int int_mode)
|
||||
|
@@ -112,12 +112,14 @@ static struct irq_chip wcd_irq_chip = {
|
||||
};
|
||||
|
||||
static struct lock_class_key wcd_irq_lock_class;
|
||||
static struct lock_class_key wcd_irq_lock_requested_class;
|
||||
|
||||
static int wcd_irq_chip_map(struct irq_domain *irqd, unsigned int virq,
|
||||
irq_hw_number_t hw)
|
||||
{
|
||||
irq_set_chip_and_handler(virq, &wcd_irq_chip, handle_simple_irq);
|
||||
irq_set_lockdep_class(virq, &wcd_irq_lock_class);
|
||||
irq_set_lockdep_class(virq, &wcd_irq_lock_class,
|
||||
&wcd_irq_lock_requested_class);
|
||||
irq_set_nested_thread(virq, 1);
|
||||
irq_set_noprobe(virq);
|
||||
|
||||
|
@@ -193,7 +193,7 @@ static bool wcd_mbhc_adc_detect_anc_plug_type(struct wcd_mbhc *mbhc)
|
||||
wcd_mbhc_hs_elec_irq(mbhc, WCD_MBHC_ELEC_HS_INS, false);
|
||||
|
||||
WCD_MBHC_REG_READ(WCD_MBHC_FSM_EN, fsm_en);
|
||||
mbhc->mbhc_cb->mbhc_micbias_control(mbhc->codec,
|
||||
mbhc->mbhc_cb->mbhc_micbias_control(mbhc->component,
|
||||
mbhc->mbhc_cfg->anc_micbias,
|
||||
MICB_ENABLE);
|
||||
|
||||
@@ -254,7 +254,7 @@ done:
|
||||
/* Restore electrical detection */
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ELECT_SCHMT_ISRC, elect_ctl);
|
||||
|
||||
mbhc->mbhc_cb->mbhc_micbias_control(mbhc->codec,
|
||||
mbhc->mbhc_cb->mbhc_micbias_control(mbhc->component,
|
||||
mbhc->mbhc_cfg->anc_micbias,
|
||||
MICB_DISABLE);
|
||||
pr_debug("%s: anc mic %sfound\n", __func__,
|
||||
@@ -283,7 +283,7 @@ static int wcd_check_cross_conn(struct wcd_mbhc *mbhc)
|
||||
|
||||
/* If PA is enabled, dont check for cross-connection */
|
||||
if (mbhc->mbhc_cb->hph_pa_on_status)
|
||||
if (mbhc->mbhc_cb->hph_pa_on_status(mbhc->codec))
|
||||
if (mbhc->mbhc_cb->hph_pa_on_status(mbhc->component))
|
||||
return -EINVAL;
|
||||
|
||||
/* Read legacy electircal detection and disable */
|
||||
@@ -349,15 +349,15 @@ static bool wcd_mbhc_adc_check_for_spl_headset(struct wcd_mbhc *mbhc,
|
||||
bool spl_hs = false;
|
||||
int output_mv = 0;
|
||||
int adc_threshold = 0, adc_hph_threshold = 0;
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
struct wcd9xxx_pdata *pdata = dev_get_platdata(component->dev->parent);
|
||||
|
||||
pr_debug("%s: enter\n", __func__);
|
||||
if (!mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic)
|
||||
goto exit;
|
||||
|
||||
/* Bump up MB2 to 2.7V */
|
||||
mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->codec,
|
||||
mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->component,
|
||||
mbhc->mbhc_cfg->mbhc_micbias, true);
|
||||
usleep_range(10000, 10100);
|
||||
|
||||
@@ -391,7 +391,7 @@ static bool wcd_mbhc_adc_check_for_spl_headset(struct wcd_mbhc *mbhc,
|
||||
|
||||
/* MB2 back to 1.8v if the type is not special headset */
|
||||
if (spl_hs_cnt && (*spl_hs_cnt != WCD_MBHC_SPL_HS_CNT)) {
|
||||
mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->codec,
|
||||
mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->component,
|
||||
mbhc->mbhc_cfg->mbhc_micbias, false);
|
||||
/* Add 10ms delay for micbias to settle */
|
||||
usleep_range(10000, 10100);
|
||||
@@ -412,8 +412,8 @@ static bool wcd_is_special_headset(struct wcd_mbhc *mbhc)
|
||||
bool is_spl_hs = false;
|
||||
int output_mv = 0;
|
||||
int adc_threshold = 0;
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
struct wcd9xxx_pdata *pdata = dev_get_platdata(component->dev->parent);
|
||||
|
||||
/*
|
||||
* Increase micbias to 2.7V to detect headsets with
|
||||
@@ -425,7 +425,7 @@ static bool wcd_is_special_headset(struct wcd_mbhc *mbhc)
|
||||
__func__);
|
||||
return false;
|
||||
} else if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic) {
|
||||
ret = mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->codec,
|
||||
ret = mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->component,
|
||||
MIC_BIAS_2, true);
|
||||
if (ret) {
|
||||
pr_err("%s: mbhc_micb_ctrl_thr_mic failed, ret: %d\n",
|
||||
@@ -470,7 +470,8 @@ static bool wcd_is_special_headset(struct wcd_mbhc *mbhc)
|
||||
}
|
||||
if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic &&
|
||||
!mbhc->micbias_enable)
|
||||
mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->codec, MIC_BIAS_2,
|
||||
mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->component,
|
||||
MIC_BIAS_2,
|
||||
false);
|
||||
pr_debug("%s: leave, micb_enable: %d\n", __func__,
|
||||
mbhc->micbias_enable);
|
||||
@@ -530,18 +531,18 @@ static void wcd_cancel_hs_detect_plug(struct wcd_mbhc *mbhc,
|
||||
/* called under codec_resource_lock acquisition */
|
||||
static void wcd_mbhc_adc_detect_plug_type(struct wcd_mbhc *mbhc)
|
||||
{
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
|
||||
pr_debug("%s: enter\n", __func__);
|
||||
WCD_MBHC_RSC_ASSERT_LOCKED(mbhc);
|
||||
|
||||
if (mbhc->mbhc_cb->hph_pull_down_ctrl)
|
||||
mbhc->mbhc_cb->hph_pull_down_ctrl(codec, false);
|
||||
mbhc->mbhc_cb->hph_pull_down_ctrl(component, false);
|
||||
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_DETECTION_DONE, 0);
|
||||
|
||||
if (mbhc->mbhc_cb->mbhc_micbias_control) {
|
||||
mbhc->mbhc_cb->mbhc_micbias_control(codec, MIC_BIAS_2,
|
||||
mbhc->mbhc_cb->mbhc_micbias_control(component, MIC_BIAS_2,
|
||||
MICB_ENABLE);
|
||||
} else {
|
||||
pr_err("%s: Mic Bias is not enabled\n", __func__);
|
||||
@@ -558,10 +559,10 @@ static void wcd_micbias_disable(struct wcd_mbhc *mbhc)
|
||||
{
|
||||
if (mbhc->micbias_enable) {
|
||||
mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(
|
||||
mbhc->codec, MIC_BIAS_2, false);
|
||||
mbhc->component, MIC_BIAS_2, false);
|
||||
if (mbhc->mbhc_cb->set_micbias_value)
|
||||
mbhc->mbhc_cb->set_micbias_value(
|
||||
mbhc->codec);
|
||||
mbhc->component);
|
||||
mbhc->micbias_enable = false;
|
||||
}
|
||||
}
|
||||
@@ -596,7 +597,7 @@ static int wcd_mbhc_get_plug_from_adc(struct wcd_mbhc *mbhc, int adc_result)
|
||||
static void wcd_correct_swch_plug(struct work_struct *work)
|
||||
{
|
||||
struct wcd_mbhc *mbhc;
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
enum wcd_mbhc_plug_type plug_type = MBHC_PLUG_TYPE_INVALID;
|
||||
unsigned long timeout;
|
||||
bool wrk_complete = false;
|
||||
@@ -612,7 +613,7 @@ static void wcd_correct_swch_plug(struct work_struct *work)
|
||||
pr_debug("%s: enter\n", __func__);
|
||||
|
||||
mbhc = container_of(work, struct wcd_mbhc, correct_plug_swch);
|
||||
codec = mbhc->codec;
|
||||
component = mbhc->component;
|
||||
|
||||
WCD_MBHC_RSC_LOCK(mbhc);
|
||||
/* Mask ADC COMPLETE interrupt */
|
||||
@@ -703,7 +704,8 @@ correct_plug_type:
|
||||
}
|
||||
|
||||
if (mbhc->mbhc_cb->hph_pa_on_status)
|
||||
is_pa_on = mbhc->mbhc_cb->hph_pa_on_status(mbhc->codec);
|
||||
is_pa_on = mbhc->mbhc_cb->hph_pa_on_status(
|
||||
mbhc->component);
|
||||
|
||||
if ((output_mv <= WCD_MBHC_ADC_HS_THRESHOLD_MV) &&
|
||||
(!is_pa_on)) {
|
||||
@@ -750,7 +752,7 @@ correct_plug_type:
|
||||
* otherwise report unsupported plug
|
||||
*/
|
||||
if (mbhc->mbhc_cfg->swap_gnd_mic &&
|
||||
mbhc->mbhc_cfg->swap_gnd_mic(codec,
|
||||
mbhc->mbhc_cfg->swap_gnd_mic(component,
|
||||
true)) {
|
||||
pr_debug("%s: US_EU gpio present,flip switch\n"
|
||||
, __func__);
|
||||
@@ -858,7 +860,7 @@ enable_supply:
|
||||
exit:
|
||||
if (mbhc->mbhc_cb->mbhc_micbias_control &&
|
||||
!mbhc->micbias_enable)
|
||||
mbhc->mbhc_cb->mbhc_micbias_control(codec, MIC_BIAS_2,
|
||||
mbhc->mbhc_cb->mbhc_micbias_control(component, MIC_BIAS_2,
|
||||
MICB_DISABLE);
|
||||
|
||||
/*
|
||||
@@ -870,14 +872,14 @@ exit:
|
||||
mbhc->micbias_enable) {
|
||||
if (mbhc->mbhc_cb->mbhc_micbias_control)
|
||||
mbhc->mbhc_cb->mbhc_micbias_control(
|
||||
codec, MIC_BIAS_2,
|
||||
component, MIC_BIAS_2,
|
||||
MICB_DISABLE);
|
||||
if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic)
|
||||
mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(
|
||||
codec,
|
||||
component,
|
||||
MIC_BIAS_2, false);
|
||||
if (mbhc->mbhc_cb->set_micbias_value) {
|
||||
mbhc->mbhc_cb->set_micbias_value(codec);
|
||||
mbhc->mbhc_cb->set_micbias_value(component);
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MICB_CTRL, 0);
|
||||
}
|
||||
mbhc->micbias_enable = false;
|
||||
@@ -905,7 +907,7 @@ exit:
|
||||
}
|
||||
|
||||
if (mbhc->mbhc_cb->hph_pull_down_ctrl)
|
||||
mbhc->mbhc_cb->hph_pull_down_ctrl(codec, true);
|
||||
mbhc->mbhc_cb->hph_pull_down_ctrl(component, true);
|
||||
|
||||
mbhc->mbhc_cb->lock_sleep(mbhc, false);
|
||||
pr_debug("%s: leave\n", __func__);
|
||||
@@ -953,7 +955,7 @@ static irqreturn_t wcd_mbhc_adc_hs_rem_irq(int irq, void *data)
|
||||
|
||||
if (mbhc->mbhc_cfg->moisture_en) {
|
||||
if (mbhc->mbhc_cb->hph_pa_on_status)
|
||||
if (mbhc->mbhc_cb->hph_pa_on_status(mbhc->codec)) {
|
||||
if (mbhc->mbhc_cb->hph_pa_on_status(mbhc->component)) {
|
||||
hphpa_on = true;
|
||||
WCD_MBHC_REG_UPDATE_BITS(
|
||||
WCD_MBHC_HPHL_PA_EN, 0);
|
||||
|
@@ -48,7 +48,7 @@ static bool wcd_mbhc_detect_anc_plug_type(struct wcd_mbhc *mbhc)
|
||||
if (val)
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 0);
|
||||
|
||||
mbhc->mbhc_cb->mbhc_micbias_control(mbhc->codec,
|
||||
mbhc->mbhc_cb->mbhc_micbias_control(mbhc->component,
|
||||
mbhc->mbhc_cfg->anc_micbias,
|
||||
MICB_ENABLE);
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MUX_CTL, 0x2);
|
||||
@@ -103,7 +103,7 @@ exit:
|
||||
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ANC_DET_EN, 0);
|
||||
|
||||
mbhc->mbhc_cb->mbhc_micbias_control(mbhc->codec,
|
||||
mbhc->mbhc_cb->mbhc_micbias_control(mbhc->component,
|
||||
mbhc->mbhc_cfg->anc_micbias,
|
||||
MICB_DISABLE);
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MUX_CTL, 0x0);
|
||||
@@ -127,7 +127,7 @@ static int wcd_check_cross_conn(struct wcd_mbhc *mbhc)
|
||||
|
||||
/* If PA is enabled, dont check for cross-connection */
|
||||
if (mbhc->mbhc_cb->hph_pa_on_status)
|
||||
if (mbhc->mbhc_cb->hph_pa_on_status(mbhc->codec))
|
||||
if (mbhc->mbhc_cb->hph_pa_on_status(mbhc->component))
|
||||
return false;
|
||||
|
||||
WCD_MBHC_REG_READ(WCD_MBHC_ELECT_SCHMT_ISRC, reg1);
|
||||
@@ -168,7 +168,7 @@ static int wcd_check_cross_conn(struct wcd_mbhc *mbhc)
|
||||
|
||||
static bool wcd_is_special_headset(struct wcd_mbhc *mbhc)
|
||||
{
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
int delay = 0, rc;
|
||||
bool ret = false;
|
||||
u16 hs_comp_res;
|
||||
@@ -184,7 +184,7 @@ static bool wcd_is_special_headset(struct wcd_mbhc *mbhc)
|
||||
__func__);
|
||||
return false;
|
||||
} else if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic) {
|
||||
rc = mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(codec,
|
||||
rc = mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(component,
|
||||
MIC_BIAS_2, true);
|
||||
if (rc) {
|
||||
pr_err("%s: Micbias control for thr mic failed, rc: %d\n",
|
||||
@@ -206,17 +206,17 @@ static bool wcd_is_special_headset(struct wcd_mbhc *mbhc)
|
||||
}
|
||||
delay = delay + 50;
|
||||
if (mbhc->mbhc_cb->mbhc_common_micb_ctrl) {
|
||||
mbhc->mbhc_cb->mbhc_common_micb_ctrl(codec,
|
||||
mbhc->mbhc_cb->mbhc_common_micb_ctrl(component,
|
||||
MBHC_COMMON_MICB_PRECHARGE,
|
||||
true);
|
||||
mbhc->mbhc_cb->mbhc_common_micb_ctrl(codec,
|
||||
mbhc->mbhc_cb->mbhc_common_micb_ctrl(component,
|
||||
MBHC_COMMON_MICB_SET_VAL,
|
||||
true);
|
||||
}
|
||||
/* Wait for 50msec for MICBIAS to settle down */
|
||||
msleep(50);
|
||||
if (mbhc->mbhc_cb->set_auto_zeroing)
|
||||
mbhc->mbhc_cb->set_auto_zeroing(codec, true);
|
||||
mbhc->mbhc_cb->set_auto_zeroing(component, true);
|
||||
/* Wait for 50msec for FSM to update result values */
|
||||
msleep(50);
|
||||
WCD_MBHC_REG_READ(WCD_MBHC_HS_COMP_RESULT, hs_comp_res);
|
||||
@@ -237,17 +237,17 @@ static bool wcd_is_special_headset(struct wcd_mbhc *mbhc)
|
||||
ret = true;
|
||||
}
|
||||
if (mbhc->mbhc_cb->mbhc_common_micb_ctrl)
|
||||
mbhc->mbhc_cb->mbhc_common_micb_ctrl(codec,
|
||||
mbhc->mbhc_cb->mbhc_common_micb_ctrl(component,
|
||||
MBHC_COMMON_MICB_PRECHARGE,
|
||||
false);
|
||||
if (mbhc->mbhc_cb->set_micbias_value && !mbhc->micbias_enable)
|
||||
mbhc->mbhc_cb->set_micbias_value(codec);
|
||||
mbhc->mbhc_cb->set_micbias_value(component);
|
||||
if (mbhc->mbhc_cb->set_auto_zeroing)
|
||||
mbhc->mbhc_cb->set_auto_zeroing(codec, false);
|
||||
mbhc->mbhc_cb->set_auto_zeroing(component, false);
|
||||
|
||||
if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic &&
|
||||
!mbhc->micbias_enable)
|
||||
mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(codec, MIC_BIAS_2,
|
||||
mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(component, MIC_BIAS_2,
|
||||
false);
|
||||
|
||||
pr_debug("%s: leave, micb_enable: %d\n", __func__,
|
||||
@@ -282,7 +282,7 @@ static void wcd_enable_mbhc_supply(struct wcd_mbhc *mbhc,
|
||||
enum wcd_mbhc_plug_type plug_type)
|
||||
{
|
||||
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
|
||||
/*
|
||||
* Do not disable micbias if recording is going on or
|
||||
@@ -294,7 +294,7 @@ static void wcd_enable_mbhc_supply(struct wcd_mbhc *mbhc,
|
||||
*/
|
||||
if (det_extn_cable_en && mbhc->is_extn_cable &&
|
||||
mbhc->mbhc_cb && mbhc->mbhc_cb->extn_use_mb &&
|
||||
mbhc->mbhc_cb->extn_use_mb(codec)) {
|
||||
mbhc->mbhc_cb->extn_use_mb(component)) {
|
||||
if (plug_type == MBHC_PLUG_TYPE_HEADPHONE ||
|
||||
plug_type == MBHC_PLUG_TYPE_HEADSET)
|
||||
wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);
|
||||
@@ -340,7 +340,7 @@ static bool wcd_mbhc_check_for_spl_headset(struct wcd_mbhc *mbhc,
|
||||
}
|
||||
|
||||
/* Bump up MB2 to 2.7v */
|
||||
mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->codec,
|
||||
mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->component,
|
||||
mbhc->mbhc_cfg->mbhc_micbias, true);
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 0);
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 1);
|
||||
@@ -356,7 +356,7 @@ static bool wcd_mbhc_check_for_spl_headset(struct wcd_mbhc *mbhc,
|
||||
|
||||
/* MB2 back to 1.8v */
|
||||
if (*spl_hs_cnt != WCD_MBHC_SPL_HS_CNT) {
|
||||
mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->codec,
|
||||
mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->component,
|
||||
mbhc->mbhc_cfg->mbhc_micbias, false);
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 0);
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 1);
|
||||
@@ -399,24 +399,24 @@ static void wcd_cancel_hs_detect_plug(struct wcd_mbhc *mbhc,
|
||||
/* called under codec_resource_lock acquisition */
|
||||
static void wcd_mbhc_detect_plug_type(struct wcd_mbhc *mbhc)
|
||||
{
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
bool micbias1 = false;
|
||||
|
||||
pr_debug("%s: enter\n", __func__);
|
||||
WCD_MBHC_RSC_ASSERT_LOCKED(mbhc);
|
||||
|
||||
if (mbhc->mbhc_cb->hph_pull_down_ctrl)
|
||||
mbhc->mbhc_cb->hph_pull_down_ctrl(codec, false);
|
||||
mbhc->mbhc_cb->hph_pull_down_ctrl(component, false);
|
||||
|
||||
if (mbhc->mbhc_cb->micbias_enable_status)
|
||||
micbias1 = mbhc->mbhc_cb->micbias_enable_status(mbhc,
|
||||
MIC_BIAS_1);
|
||||
|
||||
if (mbhc->mbhc_cb->set_cap_mode)
|
||||
mbhc->mbhc_cb->set_cap_mode(codec, micbias1, true);
|
||||
mbhc->mbhc_cb->set_cap_mode(component, micbias1, true);
|
||||
|
||||
if (mbhc->mbhc_cb->mbhc_micbias_control)
|
||||
mbhc->mbhc_cb->mbhc_micbias_control(codec, MIC_BIAS_2,
|
||||
mbhc->mbhc_cb->mbhc_micbias_control(component, MIC_BIAS_2,
|
||||
MICB_ENABLE);
|
||||
else
|
||||
wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);
|
||||
@@ -430,7 +430,7 @@ static void wcd_mbhc_detect_plug_type(struct wcd_mbhc *mbhc)
|
||||
static void wcd_correct_swch_plug(struct work_struct *work)
|
||||
{
|
||||
struct wcd_mbhc *mbhc;
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
enum wcd_mbhc_plug_type plug_type = MBHC_PLUG_TYPE_INVALID;
|
||||
unsigned long timeout;
|
||||
u16 hs_comp_res = 0, hphl_sch = 0, mic_sch = 0, btn_result = 0;
|
||||
@@ -448,7 +448,7 @@ static void wcd_correct_swch_plug(struct work_struct *work)
|
||||
pr_debug("%s: enter\n", __func__);
|
||||
|
||||
mbhc = container_of(work, struct wcd_mbhc, correct_plug_swch);
|
||||
codec = mbhc->codec;
|
||||
component = mbhc->component;
|
||||
|
||||
/*
|
||||
* Enable micbias/pullup for detection in correct work.
|
||||
@@ -528,10 +528,10 @@ correct_plug_type:
|
||||
if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic &&
|
||||
mbhc->micbias_enable) {
|
||||
mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(
|
||||
mbhc->codec, MIC_BIAS_2, false);
|
||||
mbhc->component, MIC_BIAS_2, false);
|
||||
if (mbhc->mbhc_cb->set_micbias_value)
|
||||
mbhc->mbhc_cb->set_micbias_value(
|
||||
mbhc->codec);
|
||||
mbhc->component);
|
||||
mbhc->micbias_enable = false;
|
||||
}
|
||||
goto exit;
|
||||
@@ -554,10 +554,10 @@ correct_plug_type:
|
||||
if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic &&
|
||||
mbhc->micbias_enable) {
|
||||
mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(
|
||||
mbhc->codec, MIC_BIAS_2, false);
|
||||
mbhc->component, MIC_BIAS_2, false);
|
||||
if (mbhc->mbhc_cb->set_micbias_value)
|
||||
mbhc->mbhc_cb->set_micbias_value(
|
||||
mbhc->codec);
|
||||
mbhc->component);
|
||||
mbhc->micbias_enable = false;
|
||||
}
|
||||
goto exit;
|
||||
@@ -566,7 +566,7 @@ correct_plug_type:
|
||||
|
||||
pr_debug("%s: hs_comp_res: %x\n", __func__, hs_comp_res);
|
||||
if (mbhc->mbhc_cb->hph_pa_on_status)
|
||||
is_pa_on = mbhc->mbhc_cb->hph_pa_on_status(codec);
|
||||
is_pa_on = mbhc->mbhc_cb->hph_pa_on_status(component);
|
||||
|
||||
/*
|
||||
* instead of hogging system by contineous polling, wait for
|
||||
@@ -627,7 +627,7 @@ correct_plug_type:
|
||||
* otherwise report unsupported plug
|
||||
*/
|
||||
if (mbhc->mbhc_cfg->swap_gnd_mic &&
|
||||
mbhc->mbhc_cfg->swap_gnd_mic(codec,
|
||||
mbhc->mbhc_cfg->swap_gnd_mic(component,
|
||||
true)) {
|
||||
pr_debug("%s: US_EU gpio present,flip switch\n"
|
||||
, __func__);
|
||||
@@ -733,7 +733,7 @@ enable_supply:
|
||||
exit:
|
||||
if (mbhc->mbhc_cb->mbhc_micbias_control &&
|
||||
!mbhc->micbias_enable)
|
||||
mbhc->mbhc_cb->mbhc_micbias_control(codec, MIC_BIAS_2,
|
||||
mbhc->mbhc_cb->mbhc_micbias_control(component, MIC_BIAS_2,
|
||||
MICB_DISABLE);
|
||||
|
||||
/*
|
||||
@@ -745,14 +745,14 @@ exit:
|
||||
mbhc->micbias_enable) {
|
||||
if (mbhc->mbhc_cb->mbhc_micbias_control)
|
||||
mbhc->mbhc_cb->mbhc_micbias_control(
|
||||
codec, MIC_BIAS_2,
|
||||
component, MIC_BIAS_2,
|
||||
MICB_DISABLE);
|
||||
if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic)
|
||||
mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(
|
||||
codec,
|
||||
component,
|
||||
MIC_BIAS_2, false);
|
||||
if (mbhc->mbhc_cb->set_micbias_value) {
|
||||
mbhc->mbhc_cb->set_micbias_value(codec);
|
||||
mbhc->mbhc_cb->set_micbias_value(component);
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MICB_CTRL, 0);
|
||||
}
|
||||
mbhc->micbias_enable = false;
|
||||
@@ -774,10 +774,10 @@ exit:
|
||||
WCD_MBHC_RSC_UNLOCK(mbhc);
|
||||
}
|
||||
if (mbhc->mbhc_cb->set_cap_mode)
|
||||
mbhc->mbhc_cb->set_cap_mode(codec, micbias1, micbias2);
|
||||
mbhc->mbhc_cb->set_cap_mode(component, micbias1, micbias2);
|
||||
|
||||
if (mbhc->mbhc_cb->hph_pull_down_ctrl)
|
||||
mbhc->mbhc_cb->hph_pull_down_ctrl(codec, true);
|
||||
mbhc->mbhc_cb->hph_pull_down_ctrl(component, true);
|
||||
|
||||
mbhc->mbhc_cb->lock_sleep(mbhc, false);
|
||||
pr_debug("%s: leave\n", __func__);
|
||||
@@ -833,7 +833,8 @@ static irqreturn_t wcd_mbhc_hs_rem_irq(int irq, void *data)
|
||||
if (mbhc->mbhc_cfg->moisture_en) {
|
||||
if (mbhc->mbhc_cb->hph_pa_on_status)
|
||||
if (
|
||||
mbhc->mbhc_cb->hph_pa_on_status(mbhc->codec)) {
|
||||
mbhc->mbhc_cb->hph_pa_on_status(
|
||||
mbhc->component)) {
|
||||
hphpa_on = true;
|
||||
WCD_MBHC_REG_UPDATE_BITS(
|
||||
WCD_MBHC_HPHL_PA_EN, 0);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
#ifndef __WCD_MBHC_V2_API_H__
|
||||
#define __WCD_MBHC_V2_API_H__
|
||||
@@ -10,7 +10,7 @@
|
||||
int wcd_mbhc_start(struct wcd_mbhc *mbhc,
|
||||
struct wcd_mbhc_config *mbhc_cfg);
|
||||
void wcd_mbhc_stop(struct wcd_mbhc *mbhc);
|
||||
int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec,
|
||||
int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_component *component,
|
||||
const struct wcd_mbhc_cb *mbhc_cb,
|
||||
const struct wcd_mbhc_intr *mbhc_cdc_intr_ids,
|
||||
struct wcd_mbhc_register *wcd_mbhc_regs,
|
||||
@@ -23,7 +23,7 @@ void wcd_mbhc_deinit(struct wcd_mbhc *mbhc);
|
||||
static inline void wcd_mbhc_stop(struct wcd_mbhc *mbhc)
|
||||
{
|
||||
}
|
||||
int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec,
|
||||
int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_component *component,
|
||||
const struct wcd_mbhc_cb *mbhc_cb,
|
||||
const struct wcd_mbhc_intr *mbhc_cdc_intr_ids,
|
||||
struct wcd_mbhc_register *wcd_mbhc_regs,
|
||||
|
@@ -36,9 +36,9 @@ EXPORT_SYMBOL(wcd_mbhc_jack_report);
|
||||
static void __hphocp_off_report(struct wcd_mbhc *mbhc, u32 jack_status,
|
||||
int irq)
|
||||
{
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
|
||||
dev_dbg(codec->dev, "%s: clear ocp status %x\n",
|
||||
dev_dbg(component->dev, "%s: clear ocp status %x\n",
|
||||
__func__, jack_status);
|
||||
|
||||
if (mbhc->hph_status & jack_status) {
|
||||
@@ -55,7 +55,7 @@ static void __hphocp_off_report(struct wcd_mbhc *mbhc, u32 jack_status,
|
||||
mbhc->hphlocp_cnt = 0;
|
||||
else
|
||||
mbhc->hphrocp_cnt = 0;
|
||||
mbhc->mbhc_cb->irq_control(codec, irq, true);
|
||||
mbhc->mbhc_cb->irq_control(component, irq, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,21 +74,21 @@ static void hphlocp_off_report(struct wcd_mbhc *mbhc, u32 jack_status)
|
||||
static void wcd_program_hs_vref(struct wcd_mbhc *mbhc)
|
||||
{
|
||||
struct wcd_mbhc_plug_type_cfg *plug_type_cfg;
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
u32 reg_val;
|
||||
|
||||
plug_type_cfg = WCD_MBHC_CAL_PLUG_TYPE_PTR(mbhc->mbhc_cfg->calibration);
|
||||
reg_val = ((plug_type_cfg->v_hs_max - HS_VREF_MIN_VAL) / 100);
|
||||
|
||||
dev_dbg(codec->dev, "%s: reg_val = %x\n", __func__, reg_val);
|
||||
dev_dbg(component->dev, "%s: reg_val = %x\n", __func__, reg_val);
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HS_VREF, reg_val);
|
||||
}
|
||||
|
||||
static void wcd_program_btn_threshold(const struct wcd_mbhc *mbhc, bool micbias)
|
||||
{
|
||||
struct wcd_mbhc_btn_detect_cfg *btn_det;
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct snd_soc_card *card = codec->component.card;
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
struct snd_soc_card *card = component->card;
|
||||
s16 *btn_low, *btn_high;
|
||||
|
||||
if (mbhc->mbhc_cfg->calibration == NULL) {
|
||||
@@ -101,8 +101,8 @@ static void wcd_program_btn_threshold(const struct wcd_mbhc *mbhc, bool micbias)
|
||||
btn_high = ((void *)&btn_det->_v_btn_low) +
|
||||
(sizeof(btn_det->_v_btn_low[0]) * btn_det->num_btn);
|
||||
|
||||
mbhc->mbhc_cb->set_btn_thr(codec, btn_low, btn_high, btn_det->num_btn,
|
||||
micbias);
|
||||
mbhc->mbhc_cb->set_btn_thr(component, btn_low, btn_high,
|
||||
btn_det->num_btn, micbias);
|
||||
}
|
||||
|
||||
void wcd_enable_curr_micbias(const struct wcd_mbhc *mbhc,
|
||||
@@ -203,7 +203,7 @@ static int wcd_event_notify(struct notifier_block *self, unsigned long val,
|
||||
{
|
||||
struct wcd_mbhc *mbhc = (struct wcd_mbhc *)data;
|
||||
enum wcd_notify_event event = (enum wcd_notify_event)val;
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
bool micbias2 = false;
|
||||
bool micbias1 = false;
|
||||
u8 fsm_en = 0;
|
||||
@@ -227,10 +227,10 @@ static int wcd_event_notify(struct notifier_block *self, unsigned long val,
|
||||
if (!mbhc->micbias_enable)
|
||||
goto out_micb_en;
|
||||
if (mbhc->mbhc_cb->mbhc_common_micb_ctrl) {
|
||||
mbhc->mbhc_cb->mbhc_common_micb_ctrl(codec,
|
||||
mbhc->mbhc_cb->mbhc_common_micb_ctrl(component,
|
||||
MBHC_COMMON_MICB_PRECHARGE,
|
||||
true);
|
||||
mbhc->mbhc_cb->mbhc_common_micb_ctrl(codec,
|
||||
mbhc->mbhc_cb->mbhc_common_micb_ctrl(component,
|
||||
MBHC_COMMON_MICB_SET_VAL,
|
||||
true);
|
||||
/*
|
||||
@@ -240,9 +240,9 @@ static int wcd_event_notify(struct notifier_block *self, unsigned long val,
|
||||
msleep(50);
|
||||
}
|
||||
if (mbhc->mbhc_cb->set_auto_zeroing)
|
||||
mbhc->mbhc_cb->set_auto_zeroing(codec, true);
|
||||
mbhc->mbhc_cb->set_auto_zeroing(component, true);
|
||||
if (mbhc->mbhc_cb->mbhc_common_micb_ctrl)
|
||||
mbhc->mbhc_cb->mbhc_common_micb_ctrl(codec,
|
||||
mbhc->mbhc_cb->mbhc_common_micb_ctrl(component,
|
||||
MBHC_COMMON_MICB_PRECHARGE,
|
||||
false);
|
||||
out_micb_en:
|
||||
@@ -258,7 +258,7 @@ out_micb_en:
|
||||
}
|
||||
/* configure cap settings properly when micbias is enabled */
|
||||
if (mbhc->mbhc_cb->set_cap_mode)
|
||||
mbhc->mbhc_cb->set_cap_mode(codec, micbias1, true);
|
||||
mbhc->mbhc_cb->set_cap_mode(component, micbias1, true);
|
||||
break;
|
||||
case WCD_EVENT_PRE_MICBIAS_2_OFF:
|
||||
/*
|
||||
@@ -289,9 +289,9 @@ out_micb_en:
|
||||
}
|
||||
|
||||
if (mbhc->mbhc_cb->set_auto_zeroing)
|
||||
mbhc->mbhc_cb->set_auto_zeroing(codec, false);
|
||||
mbhc->mbhc_cb->set_auto_zeroing(component, false);
|
||||
if (mbhc->mbhc_cb->set_micbias_value && !mbhc->micbias_enable)
|
||||
mbhc->mbhc_cb->set_micbias_value(codec);
|
||||
mbhc->mbhc_cb->set_micbias_value(component);
|
||||
/* Enable PULL UP if PA's are enabled */
|
||||
if ((test_bit(WCD_MBHC_EVENT_PA_HPHL, &mbhc->event_state)) ||
|
||||
(test_bit(WCD_MBHC_EVENT_PA_HPHR,
|
||||
@@ -304,7 +304,7 @@ out_micb_en:
|
||||
|
||||
/* configure cap settings properly when micbias is disabled */
|
||||
if (mbhc->mbhc_cb->set_cap_mode)
|
||||
mbhc->mbhc_cb->set_cap_mode(codec, micbias1, false);
|
||||
mbhc->mbhc_cb->set_cap_mode(component, micbias1, false);
|
||||
break;
|
||||
case WCD_EVENT_PRE_HPHL_PA_OFF:
|
||||
mutex_lock(&mbhc->hphl_pa_lock);
|
||||
@@ -363,12 +363,12 @@ out_micb_en:
|
||||
wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_PULLUP);
|
||||
break;
|
||||
case WCD_EVENT_OCP_OFF:
|
||||
mbhc->mbhc_cb->irq_control(mbhc->codec,
|
||||
mbhc->mbhc_cb->irq_control(mbhc->component,
|
||||
mbhc->intr_ids->hph_left_ocp,
|
||||
false);
|
||||
break;
|
||||
case WCD_EVENT_OCP_ON:
|
||||
mbhc->mbhc_cb->irq_control(mbhc->codec,
|
||||
mbhc->mbhc_cb->irq_control(mbhc->component,
|
||||
mbhc->intr_ids->hph_left_ocp,
|
||||
true);
|
||||
break;
|
||||
@@ -441,7 +441,8 @@ static void wcd_mbhc_clr_and_turnon_hph_padac(struct wcd_mbhc *mbhc)
|
||||
pr_debug("%s: HPHL ANC clear flag and enable ANC_EN\n",
|
||||
__func__);
|
||||
if (mbhc->mbhc_cb->update_anc_state)
|
||||
mbhc->mbhc_cb->update_anc_state(mbhc->codec, true, 0);
|
||||
mbhc->mbhc_cb->update_anc_state(mbhc->component,
|
||||
true, 0);
|
||||
}
|
||||
|
||||
if (test_and_clear_bit(WCD_MBHC_ANC1_OFF_ACK,
|
||||
@@ -450,7 +451,8 @@ static void wcd_mbhc_clr_and_turnon_hph_padac(struct wcd_mbhc *mbhc)
|
||||
pr_debug("%s: HPHR ANC clear flag and enable ANC_EN\n",
|
||||
__func__);
|
||||
if (mbhc->mbhc_cb->update_anc_state)
|
||||
mbhc->mbhc_cb->update_anc_state(mbhc->codec, true, 1);
|
||||
mbhc->mbhc_cb->update_anc_state(mbhc->component,
|
||||
true, 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -493,8 +495,10 @@ static void wcd_mbhc_set_and_turnoff_hph_padac(struct wcd_mbhc *mbhc)
|
||||
set_bit(WCD_MBHC_ANC0_OFF_ACK, &mbhc->hph_anc_state);
|
||||
set_bit(WCD_MBHC_ANC1_OFF_ACK, &mbhc->hph_anc_state);
|
||||
if (mbhc->mbhc_cb->update_anc_state) {
|
||||
mbhc->mbhc_cb->update_anc_state(mbhc->codec, false, 0);
|
||||
mbhc->mbhc_cb->update_anc_state(mbhc->codec, false, 1);
|
||||
mbhc->mbhc_cb->update_anc_state(mbhc->component,
|
||||
false, 0);
|
||||
mbhc->mbhc_cb->update_anc_state(mbhc->component,
|
||||
false, 1);
|
||||
} else {
|
||||
pr_debug("%s ANC is off\n", __func__);
|
||||
}
|
||||
@@ -534,7 +538,7 @@ void wcd_mbhc_hs_elec_irq(struct wcd_mbhc *mbhc, int irq_type,
|
||||
pr_debug("%s: irq: %d, enable: %d, intr_status:%lu\n",
|
||||
__func__, irq, enable, mbhc->intr_status);
|
||||
if ((test_bit(irq_type, &mbhc->intr_status)) != enable) {
|
||||
mbhc->mbhc_cb->irq_control(mbhc->codec, irq, enable);
|
||||
mbhc->mbhc_cb->irq_control(mbhc->component, irq, enable);
|
||||
if (enable)
|
||||
set_bit(irq_type, &mbhc->intr_status);
|
||||
else
|
||||
@@ -546,7 +550,7 @@ EXPORT_SYMBOL(wcd_mbhc_hs_elec_irq);
|
||||
void wcd_mbhc_report_plug(struct wcd_mbhc *mbhc, int insertion,
|
||||
enum snd_jack_types jack_type)
|
||||
{
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
bool is_pa_on = false;
|
||||
u8 fsm_en = 0;
|
||||
|
||||
@@ -575,14 +579,14 @@ void wcd_mbhc_report_plug(struct wcd_mbhc *mbhc, int insertion,
|
||||
if (mbhc->micbias_enable) {
|
||||
if (mbhc->mbhc_cb->mbhc_micbias_control)
|
||||
mbhc->mbhc_cb->mbhc_micbias_control(
|
||||
codec, MIC_BIAS_2,
|
||||
component, MIC_BIAS_2,
|
||||
MICB_DISABLE);
|
||||
if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic)
|
||||
mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(
|
||||
codec,
|
||||
component,
|
||||
MIC_BIAS_2, false);
|
||||
if (mbhc->mbhc_cb->set_micbias_value) {
|
||||
mbhc->mbhc_cb->set_micbias_value(codec);
|
||||
mbhc->mbhc_cb->set_micbias_value(component);
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MICB_CTRL, 0);
|
||||
}
|
||||
mbhc->micbias_enable = false;
|
||||
@@ -614,15 +618,15 @@ void wcd_mbhc_report_plug(struct wcd_mbhc *mbhc, int insertion,
|
||||
mbhc->hph_status == SND_JACK_HEADSET) {
|
||||
if (mbhc->mbhc_cb->mbhc_micbias_control)
|
||||
mbhc->mbhc_cb->mbhc_micbias_control(
|
||||
codec, MIC_BIAS_2,
|
||||
component, MIC_BIAS_2,
|
||||
MICB_DISABLE);
|
||||
if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic)
|
||||
mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(
|
||||
codec,
|
||||
component,
|
||||
MIC_BIAS_2, false);
|
||||
if (mbhc->mbhc_cb->set_micbias_value) {
|
||||
mbhc->mbhc_cb->set_micbias_value(
|
||||
codec);
|
||||
component);
|
||||
WCD_MBHC_REG_UPDATE_BITS(
|
||||
WCD_MBHC_MICB_CTRL, 0);
|
||||
}
|
||||
@@ -672,7 +676,7 @@ void wcd_mbhc_report_plug(struct wcd_mbhc *mbhc, int insertion,
|
||||
mbhc->current_plug = MBHC_PLUG_TYPE_ANC_HEADPHONE;
|
||||
|
||||
if (mbhc->mbhc_cb->hph_pa_on_status)
|
||||
is_pa_on = mbhc->mbhc_cb->hph_pa_on_status(codec);
|
||||
is_pa_on = mbhc->mbhc_cb->hph_pa_on_status(component);
|
||||
|
||||
if (mbhc->impedance_detect &&
|
||||
mbhc->mbhc_cb->compute_impedance &&
|
||||
@@ -876,10 +880,10 @@ static void wcd_mbhc_swch_irq_handler(struct wcd_mbhc *mbhc)
|
||||
{
|
||||
bool detection_type = 0;
|
||||
bool micbias1 = false;
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
enum snd_jack_types jack_type;
|
||||
|
||||
dev_dbg(codec->dev, "%s: enter\n", __func__);
|
||||
dev_dbg(component->dev, "%s: enter\n", __func__);
|
||||
WCD_MBHC_RSC_LOCK(mbhc);
|
||||
mbhc->in_swch_irq_handler = true;
|
||||
|
||||
@@ -915,10 +919,10 @@ static void wcd_mbhc_swch_irq_handler(struct wcd_mbhc *mbhc)
|
||||
goto done;
|
||||
|
||||
/* Make sure MASTER_BIAS_CTL is enabled */
|
||||
mbhc->mbhc_cb->mbhc_bias(codec, true);
|
||||
mbhc->mbhc_cb->mbhc_bias(component, true);
|
||||
|
||||
if (mbhc->mbhc_cb->mbhc_common_micb_ctrl)
|
||||
mbhc->mbhc_cb->mbhc_common_micb_ctrl(codec,
|
||||
mbhc->mbhc_cb->mbhc_common_micb_ctrl(component,
|
||||
MBHC_COMMON_MICB_TAIL_CURR, true);
|
||||
|
||||
if (!mbhc->mbhc_cfg->hs_ext_micbias &&
|
||||
@@ -927,13 +931,13 @@ static void wcd_mbhc_swch_irq_handler(struct wcd_mbhc *mbhc)
|
||||
* Enable Tx2 RBias if the headset
|
||||
* is using internal micbias
|
||||
*/
|
||||
mbhc->mbhc_cb->micb_internal(codec, 1, true);
|
||||
mbhc->mbhc_cb->micb_internal(component, 1, true);
|
||||
|
||||
/* Remove micbias pulldown */
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_PULLDOWN_CTRL, 0);
|
||||
/* Apply trim if needed on the device */
|
||||
if (mbhc->mbhc_cb->trim_btn_reg)
|
||||
mbhc->mbhc_cb->trim_btn_reg(codec);
|
||||
mbhc->mbhc_cb->trim_btn_reg(component);
|
||||
/* Enable external voltage source to micbias if present */
|
||||
if (mbhc->mbhc_cb->enable_mb_source)
|
||||
mbhc->mbhc_cb->enable_mb_source(mbhc, true);
|
||||
@@ -950,11 +954,11 @@ static void wcd_mbhc_swch_irq_handler(struct wcd_mbhc *mbhc)
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 0);
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_BTN_ISRC_CTL, 0);
|
||||
if (mbhc->mbhc_cb->mbhc_common_micb_ctrl)
|
||||
mbhc->mbhc_cb->mbhc_common_micb_ctrl(codec,
|
||||
mbhc->mbhc_cb->mbhc_common_micb_ctrl(component,
|
||||
MBHC_COMMON_MICB_TAIL_CURR, false);
|
||||
|
||||
if (mbhc->mbhc_cb->set_cap_mode)
|
||||
mbhc->mbhc_cb->set_cap_mode(codec, micbias1, false);
|
||||
mbhc->mbhc_cb->set_cap_mode(component, micbias1, false);
|
||||
|
||||
mbhc->btn_press_intr = false;
|
||||
mbhc->is_btn_press = false;
|
||||
@@ -968,7 +972,8 @@ static void wcd_mbhc_swch_irq_handler(struct wcd_mbhc *mbhc)
|
||||
case MBHC_PLUG_TYPE_HEADSET:
|
||||
/* make sure to turn off Rbias */
|
||||
if (mbhc->mbhc_cb->micb_internal)
|
||||
mbhc->mbhc_cb->micb_internal(codec, 1, false);
|
||||
mbhc->mbhc_cb->micb_internal(component,
|
||||
1, false);
|
||||
/* Pulldown micbias */
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_PULLDOWN_CTRL, 1);
|
||||
jack_type = SND_JACK_HEADSET;
|
||||
@@ -998,7 +1003,8 @@ static void wcd_mbhc_swch_irq_handler(struct wcd_mbhc *mbhc)
|
||||
if (mbhc->mbhc_cfg->enable_usbc_analog) {
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_L_DET_EN, 0);
|
||||
if (mbhc->mbhc_cb->clk_setup)
|
||||
mbhc->mbhc_cb->clk_setup(mbhc->codec, false);
|
||||
mbhc->mbhc_cb->clk_setup(
|
||||
mbhc->component, false);
|
||||
}
|
||||
|
||||
if (mbhc->mbhc_cfg->moisture_en &&
|
||||
@@ -1050,7 +1056,7 @@ int wcd_mbhc_get_button_mask(struct wcd_mbhc *mbhc)
|
||||
int mask = 0;
|
||||
int btn;
|
||||
|
||||
btn = mbhc->mbhc_cb->map_btn_code_to_num(mbhc->codec);
|
||||
btn = mbhc->mbhc_cb->map_btn_code_to_num(mbhc->component);
|
||||
|
||||
switch (btn) {
|
||||
case 0:
|
||||
@@ -1265,7 +1271,7 @@ static irqreturn_t wcd_mbhc_hphl_ocp_irq(int irq, void *data)
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_OCP_FSM_EN, 0);
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_OCP_FSM_EN, 1);
|
||||
} else {
|
||||
mbhc->mbhc_cb->irq_control(mbhc->codec,
|
||||
mbhc->mbhc_cb->irq_control(mbhc->component,
|
||||
mbhc->intr_ids->hph_left_ocp,
|
||||
false);
|
||||
mbhc->hph_status |= SND_JACK_OC_HPHL;
|
||||
@@ -1308,7 +1314,7 @@ static irqreturn_t wcd_mbhc_hphr_ocp_irq(int irq, void *data)
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_OCP_FSM_EN, 0);
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_OCP_FSM_EN, 1);
|
||||
} else {
|
||||
mbhc->mbhc_cb->irq_control(mbhc->codec,
|
||||
mbhc->mbhc_cb->irq_control(mbhc->component,
|
||||
mbhc->intr_ids->hph_right_ocp,
|
||||
false);
|
||||
mbhc->hph_status |= SND_JACK_OC_HPHR;
|
||||
@@ -1322,17 +1328,17 @@ done:
|
||||
static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc)
|
||||
{
|
||||
int ret = 0;
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
|
||||
pr_debug("%s: enter\n", __func__);
|
||||
WCD_MBHC_RSC_LOCK(mbhc);
|
||||
|
||||
/* enable HS detection */
|
||||
if (mbhc->mbhc_cb->hph_pull_up_control_v2)
|
||||
mbhc->mbhc_cb->hph_pull_up_control_v2(codec,
|
||||
mbhc->mbhc_cb->hph_pull_up_control_v2(component,
|
||||
HS_PULLUP_I_DEFAULT);
|
||||
else if (mbhc->mbhc_cb->hph_pull_up_control)
|
||||
mbhc->mbhc_cb->hph_pull_up_control(codec, I_DEFAULT);
|
||||
mbhc->mbhc_cb->hph_pull_up_control(component, I_DEFAULT);
|
||||
else
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HS_L_DET_PULL_UP_CTRL, 3);
|
||||
|
||||
@@ -1350,10 +1356,10 @@ static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc)
|
||||
mbhc->gnd_swh = 0;
|
||||
|
||||
if (mbhc->mbhc_cb->hph_pull_up_control_v2)
|
||||
mbhc->mbhc_cb->hph_pull_up_control_v2(codec,
|
||||
mbhc->mbhc_cb->hph_pull_up_control_v2(component,
|
||||
HS_PULLUP_I_OFF);
|
||||
else if (mbhc->mbhc_cb->hph_pull_up_control)
|
||||
mbhc->mbhc_cb->hph_pull_up_control(codec, I_OFF);
|
||||
mbhc->mbhc_cb->hph_pull_up_control(component, I_OFF);
|
||||
else
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HS_L_DET_PULL_UP_CTRL,
|
||||
0);
|
||||
@@ -1363,7 +1369,7 @@ static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc)
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_GND_PLUG_TYPE, mbhc->gnd_swh);
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_SW_HPH_LP_100K_TO_GND, 1);
|
||||
if (mbhc->mbhc_cfg->gnd_det_en && mbhc->mbhc_cb->mbhc_gnd_det_ctrl)
|
||||
mbhc->mbhc_cb->mbhc_gnd_det_ctrl(codec, true);
|
||||
mbhc->mbhc_cb->mbhc_gnd_det_ctrl(component, true);
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HS_L_DET_PULL_UP_COMP_CTRL, 1);
|
||||
|
||||
/*
|
||||
@@ -1389,15 +1395,15 @@ static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc)
|
||||
|
||||
/* Enable micbias ramp */
|
||||
if (mbhc->mbhc_cb->mbhc_micb_ramp_control)
|
||||
mbhc->mbhc_cb->mbhc_micb_ramp_control(codec, true);
|
||||
mbhc->mbhc_cb->mbhc_micb_ramp_control(component, true);
|
||||
/* enable bias */
|
||||
mbhc->mbhc_cb->mbhc_bias(codec, true);
|
||||
mbhc->mbhc_cb->mbhc_bias(component, true);
|
||||
/* enable MBHC clock */
|
||||
if (mbhc->mbhc_cb->clk_setup) {
|
||||
if (mbhc->mbhc_cfg->enable_usbc_analog)
|
||||
mbhc->mbhc_cb->clk_setup(codec, false);
|
||||
mbhc->mbhc_cb->clk_setup(component, false);
|
||||
else
|
||||
mbhc->mbhc_cb->clk_setup(codec, true);
|
||||
mbhc->mbhc_cb->clk_setup(component, true);
|
||||
}
|
||||
|
||||
/* program HS_VREF value */
|
||||
@@ -1417,7 +1423,7 @@ static void wcd_mbhc_fw_read(struct work_struct *work)
|
||||
{
|
||||
struct delayed_work *dwork;
|
||||
struct wcd_mbhc *mbhc;
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
const struct firmware *fw;
|
||||
struct firmware_cal *fw_data = NULL;
|
||||
int ret = -1, retry = 0;
|
||||
@@ -1425,7 +1431,7 @@ static void wcd_mbhc_fw_read(struct work_struct *work)
|
||||
|
||||
dwork = to_delayed_work(work);
|
||||
mbhc = container_of(dwork, struct wcd_mbhc, mbhc_firmware_dwork);
|
||||
codec = mbhc->codec;
|
||||
component = mbhc->component;
|
||||
|
||||
while (retry < FW_READ_ATTEMPTS) {
|
||||
retry++;
|
||||
@@ -1436,7 +1442,7 @@ static void wcd_mbhc_fw_read(struct work_struct *work)
|
||||
WCD9XXX_MBHC_CAL);
|
||||
if (!fw_data)
|
||||
ret = request_firmware(&fw, "wcd9320/wcd9320_mbhc.bin",
|
||||
codec->dev);
|
||||
component->dev);
|
||||
/*
|
||||
* if request_firmware and hwdep cal both fail then
|
||||
* sleep for 4sec for the userspace to send data to kernel
|
||||
@@ -1557,11 +1563,11 @@ static int wcd_mbhc_usbc_ana_event_handler(struct notifier_block *nb,
|
||||
if (!mbhc)
|
||||
return -EINVAL;
|
||||
|
||||
dev_dbg(mbhc->codec->dev, "%s: mode = %lu\n", __func__, mode);
|
||||
dev_dbg(mbhc->component->dev, "%s: mode = %lu\n", __func__, mode);
|
||||
|
||||
if (mode == POWER_SUPPLY_TYPEC_SINK_AUDIO_ADAPTER) {
|
||||
if (mbhc->mbhc_cb->clk_setup)
|
||||
mbhc->mbhc_cb->clk_setup(mbhc->codec, true);
|
||||
mbhc->mbhc_cb->clk_setup(mbhc->component, true);
|
||||
/* insertion detected, enable L_DET_EN */
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_L_DET_EN, 1);
|
||||
}
|
||||
@@ -1571,20 +1577,20 @@ static int wcd_mbhc_usbc_ana_event_handler(struct notifier_block *nb,
|
||||
int wcd_mbhc_start(struct wcd_mbhc *mbhc, struct wcd_mbhc_config *mbhc_cfg)
|
||||
{
|
||||
int rc = 0;
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
struct snd_soc_card *card;
|
||||
const char *usb_c_dt = "qcom,msm-mbhc-usbc-audio-supported";
|
||||
|
||||
if (!mbhc || !mbhc_cfg)
|
||||
return -EINVAL;
|
||||
|
||||
codec = mbhc->codec;
|
||||
card = codec->component.card;
|
||||
component = mbhc->component;
|
||||
card = component->card;
|
||||
|
||||
/* update the mbhc config */
|
||||
mbhc->mbhc_cfg = mbhc_cfg;
|
||||
|
||||
dev_dbg(mbhc->codec->dev, "%s: enter\n", __func__);
|
||||
dev_dbg(mbhc->component->dev, "%s: enter\n", __func__);
|
||||
|
||||
/* check if USB C analog is defined on device tree */
|
||||
mbhc_cfg->enable_usbc_analog = 0;
|
||||
@@ -1602,7 +1608,7 @@ int wcd_mbhc_start(struct wcd_mbhc *mbhc, struct wcd_mbhc_config *mbhc_cfg)
|
||||
|
||||
/* Parse fsa switch handle */
|
||||
if (mbhc_cfg->enable_usbc_analog) {
|
||||
dev_dbg(mbhc->codec->dev, "%s: usbc analog enabled\n",
|
||||
dev_dbg(mbhc->component->dev, "%s: usbc analog enabled\n",
|
||||
__func__);
|
||||
mbhc->swap_thr = GND_MIC_USBC_SWAP_THRESHOLD;
|
||||
mbhc->fsa_np = of_parse_phandle(card->dev->of_node,
|
||||
@@ -1645,7 +1651,7 @@ int wcd_mbhc_start(struct wcd_mbhc *mbhc, struct wcd_mbhc_config *mbhc_cfg)
|
||||
|
||||
return rc;
|
||||
err:
|
||||
dev_dbg(mbhc->codec->dev, "%s: leave %d\n", __func__, rc);
|
||||
dev_dbg(mbhc->component->dev, "%s: leave %d\n", __func__, rc);
|
||||
return rc;
|
||||
}
|
||||
EXPORT_SYMBOL(wcd_mbhc_start);
|
||||
@@ -1656,15 +1662,15 @@ void wcd_mbhc_stop(struct wcd_mbhc *mbhc)
|
||||
|
||||
if (mbhc->current_plug != MBHC_PLUG_TYPE_NONE) {
|
||||
if (mbhc->mbhc_cb && mbhc->mbhc_cb->skip_imped_detect)
|
||||
mbhc->mbhc_cb->skip_imped_detect(mbhc->codec);
|
||||
mbhc->mbhc_cb->skip_imped_detect(mbhc->component);
|
||||
}
|
||||
mbhc->current_plug = MBHC_PLUG_TYPE_NONE;
|
||||
mbhc->hph_status = 0;
|
||||
if (mbhc->mbhc_cb && mbhc->mbhc_cb->irq_control) {
|
||||
mbhc->mbhc_cb->irq_control(mbhc->codec,
|
||||
mbhc->mbhc_cb->irq_control(mbhc->component,
|
||||
mbhc->intr_ids->hph_left_ocp,
|
||||
false);
|
||||
mbhc->mbhc_cb->irq_control(mbhc->codec,
|
||||
mbhc->mbhc_cb->irq_control(mbhc->component,
|
||||
mbhc->intr_ids->hph_right_ocp,
|
||||
false);
|
||||
}
|
||||
@@ -1688,7 +1694,7 @@ EXPORT_SYMBOL(wcd_mbhc_stop);
|
||||
*
|
||||
* NOTE: mbhc->mbhc_cfg is not YET configure so shouldn't be used
|
||||
*/
|
||||
int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec,
|
||||
int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_component *component,
|
||||
const struct wcd_mbhc_cb *mbhc_cb,
|
||||
const struct wcd_mbhc_intr *mbhc_cdc_intr_ids,
|
||||
struct wcd_mbhc_register *wcd_mbhc_regs,
|
||||
@@ -1698,7 +1704,7 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec,
|
||||
int hph_swh = 0;
|
||||
int gnd_swh = 0;
|
||||
u32 hph_moist_config[3];
|
||||
struct snd_soc_card *card = codec->component.card;
|
||||
struct snd_soc_card *card = component->card;
|
||||
const char *hph_switch = "qcom,msm-mbhc-hphl-swh";
|
||||
const char *gnd_switch = "qcom,msm-mbhc-gnd-swh";
|
||||
const char *hs_thre = "qcom,msm-mbhc-hs-mic-max-threshold-mv";
|
||||
@@ -1750,7 +1756,7 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec,
|
||||
mbhc->in_swch_irq_handler = false;
|
||||
mbhc->current_plug = MBHC_PLUG_TYPE_NONE;
|
||||
mbhc->is_btn_press = false;
|
||||
mbhc->codec = codec;
|
||||
mbhc->component = component;
|
||||
mbhc->intr_ids = mbhc_cdc_intr_ids;
|
||||
mbhc->impedance_detect = impedance_det_en;
|
||||
mbhc->hphl_swh = hph_swh;
|
||||
@@ -1770,7 +1776,7 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec,
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!mbhc->wcd_mbhc_regs) {
|
||||
dev_err(codec->dev, "%s: mbhc registers are not defined\n",
|
||||
dev_err(component->dev, "%s: mbhc registers are not defined\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -1780,14 +1786,14 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec,
|
||||
!mbhc_cb->free_irq || !mbhc_cb->map_btn_code_to_num ||
|
||||
!mbhc_cb->lock_sleep || !mbhc_cb->mbhc_bias ||
|
||||
!mbhc_cb->set_btn_thr) {
|
||||
dev_err(codec->dev, "%s: required mbhc callbacks are not defined\n",
|
||||
dev_err(component->dev, "%s: required mbhc callbacks are not defined\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* No need to create new sound card jacks if is is already created */
|
||||
if (mbhc->headset_jack.jack == NULL) {
|
||||
ret = snd_soc_card_jack_new(codec->component.card,
|
||||
ret = snd_soc_card_jack_new(component->card,
|
||||
"Headset Jack", WCD_MBHC_JACK_MASK,
|
||||
&mbhc->headset_jack, NULL, 0);
|
||||
if (ret) {
|
||||
@@ -1795,7 +1801,7 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec,
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = snd_soc_card_jack_new(codec->component.card,
|
||||
ret = snd_soc_card_jack_new(component->card,
|
||||
"Button Jack",
|
||||
WCD_MBHC_JACK_BUTTON_MASK,
|
||||
&mbhc->button_jack, NULL, 0);
|
||||
@@ -1857,7 +1863,8 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec,
|
||||
pr_err("%s: mbhc function pointer is NULL\n", __func__);
|
||||
goto err_mbhc_sw_irq;
|
||||
}
|
||||
ret = mbhc->mbhc_cb->request_irq(codec, mbhc->intr_ids->mbhc_sw_intr,
|
||||
ret = mbhc->mbhc_cb->request_irq(component,
|
||||
mbhc->intr_ids->mbhc_sw_intr,
|
||||
wcd_mbhc_mech_plug_detect_irq,
|
||||
"mbhc sw intr", mbhc);
|
||||
if (ret) {
|
||||
@@ -1866,7 +1873,7 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec,
|
||||
goto err_mbhc_sw_irq;
|
||||
}
|
||||
|
||||
ret = mbhc->mbhc_cb->request_irq(codec,
|
||||
ret = mbhc->mbhc_cb->request_irq(component,
|
||||
mbhc->intr_ids->mbhc_btn_press_intr,
|
||||
wcd_mbhc_btn_press_handler,
|
||||
"Button Press detect", mbhc);
|
||||
@@ -1876,7 +1883,7 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec,
|
||||
goto err_btn_press_irq;
|
||||
}
|
||||
|
||||
ret = mbhc->mbhc_cb->request_irq(codec,
|
||||
ret = mbhc->mbhc_cb->request_irq(component,
|
||||
mbhc->intr_ids->mbhc_btn_release_intr,
|
||||
wcd_mbhc_release_handler,
|
||||
"Button Release detect", mbhc);
|
||||
@@ -1886,7 +1893,7 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec,
|
||||
goto err_btn_release_irq;
|
||||
}
|
||||
|
||||
ret = mbhc->mbhc_cb->request_irq(codec,
|
||||
ret = mbhc->mbhc_cb->request_irq(component,
|
||||
mbhc->intr_ids->mbhc_hs_ins_intr,
|
||||
mbhc->mbhc_fn->wcd_mbhc_hs_ins_irq,
|
||||
"Elect Insert", mbhc);
|
||||
@@ -1895,11 +1902,11 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec,
|
||||
mbhc->intr_ids->mbhc_hs_ins_intr);
|
||||
goto err_mbhc_hs_ins_irq;
|
||||
}
|
||||
mbhc->mbhc_cb->irq_control(codec, mbhc->intr_ids->mbhc_hs_ins_intr,
|
||||
mbhc->mbhc_cb->irq_control(component, mbhc->intr_ids->mbhc_hs_ins_intr,
|
||||
false);
|
||||
clear_bit(WCD_MBHC_ELEC_HS_INS, &mbhc->intr_status);
|
||||
|
||||
ret = mbhc->mbhc_cb->request_irq(codec,
|
||||
ret = mbhc->mbhc_cb->request_irq(component,
|
||||
mbhc->intr_ids->mbhc_hs_rem_intr,
|
||||
mbhc->mbhc_fn->wcd_mbhc_hs_rem_irq,
|
||||
"Elect Remove", mbhc);
|
||||
@@ -1908,11 +1915,12 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec,
|
||||
mbhc->intr_ids->mbhc_hs_rem_intr);
|
||||
goto err_mbhc_hs_rem_irq;
|
||||
}
|
||||
mbhc->mbhc_cb->irq_control(codec, mbhc->intr_ids->mbhc_hs_rem_intr,
|
||||
mbhc->mbhc_cb->irq_control(component, mbhc->intr_ids->mbhc_hs_rem_intr,
|
||||
false);
|
||||
clear_bit(WCD_MBHC_ELEC_HS_REM, &mbhc->intr_status);
|
||||
|
||||
ret = mbhc->mbhc_cb->request_irq(codec, mbhc->intr_ids->hph_left_ocp,
|
||||
ret = mbhc->mbhc_cb->request_irq(component,
|
||||
mbhc->intr_ids->hph_left_ocp,
|
||||
wcd_mbhc_hphl_ocp_irq, "HPH_L OCP detect",
|
||||
mbhc);
|
||||
if (ret) {
|
||||
@@ -1921,7 +1929,8 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec,
|
||||
goto err_hphl_ocp_irq;
|
||||
}
|
||||
|
||||
ret = mbhc->mbhc_cb->request_irq(codec, mbhc->intr_ids->hph_right_ocp,
|
||||
ret = mbhc->mbhc_cb->request_irq(component,
|
||||
mbhc->intr_ids->hph_right_ocp,
|
||||
wcd_mbhc_hphr_ocp_irq, "HPH_R OCP detect",
|
||||
mbhc);
|
||||
if (ret) {
|
||||
@@ -1935,19 +1944,22 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec,
|
||||
return ret;
|
||||
|
||||
err_hphr_ocp_irq:
|
||||
mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->hph_left_ocp, mbhc);
|
||||
mbhc->mbhc_cb->free_irq(component, mbhc->intr_ids->hph_left_ocp, mbhc);
|
||||
err_hphl_ocp_irq:
|
||||
mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_hs_rem_intr, mbhc);
|
||||
mbhc->mbhc_cb->free_irq(component, mbhc->intr_ids->mbhc_hs_rem_intr,
|
||||
mbhc);
|
||||
err_mbhc_hs_rem_irq:
|
||||
mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_hs_ins_intr, mbhc);
|
||||
mbhc->mbhc_cb->free_irq(component, mbhc->intr_ids->mbhc_hs_ins_intr,
|
||||
mbhc);
|
||||
err_mbhc_hs_ins_irq:
|
||||
mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_btn_release_intr,
|
||||
mbhc->mbhc_cb->free_irq(component,
|
||||
mbhc->intr_ids->mbhc_btn_release_intr,
|
||||
mbhc);
|
||||
err_btn_release_irq:
|
||||
mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_btn_press_intr,
|
||||
mbhc->mbhc_cb->free_irq(component, mbhc->intr_ids->mbhc_btn_press_intr,
|
||||
mbhc);
|
||||
err_btn_press_irq:
|
||||
mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_sw_intr, mbhc);
|
||||
mbhc->mbhc_cb->free_irq(component, mbhc->intr_ids->mbhc_sw_intr, mbhc);
|
||||
err_mbhc_sw_irq:
|
||||
if (mbhc->mbhc_cb->register_notifier)
|
||||
mbhc->mbhc_cb->register_notifier(mbhc, &mbhc->nblock, false);
|
||||
@@ -1960,17 +1972,20 @@ EXPORT_SYMBOL(wcd_mbhc_init);
|
||||
|
||||
void wcd_mbhc_deinit(struct wcd_mbhc *mbhc)
|
||||
{
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
|
||||
mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_sw_intr, mbhc);
|
||||
mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_btn_press_intr,
|
||||
mbhc->mbhc_cb->free_irq(component, mbhc->intr_ids->mbhc_sw_intr, mbhc);
|
||||
mbhc->mbhc_cb->free_irq(component, mbhc->intr_ids->mbhc_btn_press_intr,
|
||||
mbhc);
|
||||
mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_btn_release_intr,
|
||||
mbhc->mbhc_cb->free_irq(component,
|
||||
mbhc->intr_ids->mbhc_btn_release_intr,
|
||||
mbhc);
|
||||
mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_hs_ins_intr, mbhc);
|
||||
mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_hs_rem_intr, mbhc);
|
||||
mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->hph_left_ocp, mbhc);
|
||||
mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->hph_right_ocp, mbhc);
|
||||
mbhc->mbhc_cb->free_irq(component, mbhc->intr_ids->mbhc_hs_ins_intr,
|
||||
mbhc);
|
||||
mbhc->mbhc_cb->free_irq(component, mbhc->intr_ids->mbhc_hs_rem_intr,
|
||||
mbhc);
|
||||
mbhc->mbhc_cb->free_irq(component, mbhc->intr_ids->hph_left_ocp, mbhc);
|
||||
mbhc->mbhc_cb->free_irq(component, mbhc->intr_ids->hph_right_ocp, mbhc);
|
||||
if (mbhc->mbhc_cb && mbhc->mbhc_cb->register_notifier)
|
||||
mbhc->mbhc_cb->register_notifier(mbhc, &mbhc->nblock, false);
|
||||
if (mbhc->mbhc_fn->wcd_cancel_hs_detect_plug) {
|
||||
|
@@ -51,7 +51,7 @@
|
||||
#define WCD_MBHC_REG_UPDATE_BITS(function, val) \
|
||||
do { \
|
||||
if (mbhc->wcd_mbhc_regs[function].reg) { \
|
||||
snd_soc_update_bits(mbhc->codec, \
|
||||
snd_soc_component_update_bits(mbhc->component, \
|
||||
mbhc->wcd_mbhc_regs[function].reg, \
|
||||
mbhc->wcd_mbhc_regs[function].mask, \
|
||||
val << (mbhc->wcd_mbhc_regs[function].offset)); \
|
||||
@@ -61,7 +61,7 @@ do { \
|
||||
#define WCD_MBHC_REG_READ(function, val) \
|
||||
do { \
|
||||
if (mbhc->wcd_mbhc_regs[function].reg) { \
|
||||
val = (((snd_soc_read(mbhc->codec, \
|
||||
val = (((snd_soc_component_read32(mbhc->component, \
|
||||
mbhc->wcd_mbhc_regs[function].reg)) & \
|
||||
(mbhc->wcd_mbhc_regs[function].mask)) >> \
|
||||
(mbhc->wcd_mbhc_regs[function].offset)); \
|
||||
@@ -420,7 +420,7 @@ struct wcd_mbhc_config {
|
||||
void *calibration;
|
||||
bool detect_extn_cable;
|
||||
bool mono_stero_detection;
|
||||
bool (*swap_gnd_mic)(struct snd_soc_codec *codec, bool active);
|
||||
bool (*swap_gnd_mic)(struct snd_soc_component *component, bool active);
|
||||
bool hs_ext_micbias;
|
||||
bool gnd_det_en;
|
||||
int key_code[WCD_MBHC_KEYCODE_NUM];
|
||||
@@ -452,53 +452,64 @@ struct wcd_mbhc_register {
|
||||
};
|
||||
|
||||
struct wcd_mbhc_cb {
|
||||
int (*enable_mb_source)(struct wcd_mbhc *, bool);
|
||||
void (*trim_btn_reg)(struct snd_soc_codec *);
|
||||
void (*compute_impedance)(struct wcd_mbhc *, uint32_t *, uint32_t *);
|
||||
void (*set_micbias_value)(struct snd_soc_codec *);
|
||||
void (*set_auto_zeroing)(struct snd_soc_codec *, bool);
|
||||
struct firmware_cal * (*get_hwdep_fw_cal)(struct wcd_mbhc *,
|
||||
int (*enable_mb_source)(struct wcd_mbhc *mbhc, bool turn_on);
|
||||
void (*trim_btn_reg)(struct snd_soc_component *component);
|
||||
void (*compute_impedance)(struct wcd_mbhc *mbhc,
|
||||
uint32_t *zl, uint32_t *zr);
|
||||
void (*set_micbias_value)(struct snd_soc_component *component);
|
||||
void (*set_auto_zeroing)(struct snd_soc_component *component,
|
||||
bool enable);
|
||||
struct firmware_cal * (*get_hwdep_fw_cal)(struct wcd_mbhc *mbhc,
|
||||
enum wcd_cal_type);
|
||||
void (*set_cap_mode)(struct snd_soc_codec *, bool, bool);
|
||||
int (*register_notifier)(struct wcd_mbhc *,
|
||||
void (*set_cap_mode)(struct snd_soc_component *component,
|
||||
bool micbias1, bool micbias2);
|
||||
int (*register_notifier)(struct wcd_mbhc *mbhc,
|
||||
struct notifier_block *nblock,
|
||||
bool enable);
|
||||
int (*request_irq)(struct snd_soc_codec *,
|
||||
int, irq_handler_t, const char *, void *);
|
||||
void (*irq_control)(struct snd_soc_codec *,
|
||||
int (*request_irq)(struct snd_soc_component *component,
|
||||
int irq, irq_handler_t handler,
|
||||
const char *name, void *data);
|
||||
void (*irq_control)(struct snd_soc_component *component,
|
||||
int irq, bool enable);
|
||||
int (*free_irq)(struct snd_soc_codec *,
|
||||
int irq, void *);
|
||||
void (*clk_setup)(struct snd_soc_codec *, bool);
|
||||
int (*map_btn_code_to_num)(struct snd_soc_codec *);
|
||||
bool (*lock_sleep)(struct wcd_mbhc *, bool);
|
||||
bool (*micbias_enable_status)(struct wcd_mbhc *, int);
|
||||
void (*mbhc_bias)(struct snd_soc_codec *, bool);
|
||||
void (*mbhc_common_micb_ctrl)(struct snd_soc_codec *,
|
||||
int event, bool);
|
||||
void (*micb_internal)(struct snd_soc_codec *,
|
||||
int micb_num, bool);
|
||||
bool (*hph_pa_on_status)(struct snd_soc_codec *);
|
||||
void (*set_btn_thr)(struct snd_soc_codec *, s16 *, s16 *,
|
||||
int num_btn, bool);
|
||||
void (*hph_pull_up_control)(struct snd_soc_codec *,
|
||||
int (*free_irq)(struct snd_soc_component *component,
|
||||
int irq, void *data);
|
||||
void (*clk_setup)(struct snd_soc_component *component, bool enable);
|
||||
int (*map_btn_code_to_num)(struct snd_soc_component *component);
|
||||
bool (*lock_sleep)(struct wcd_mbhc *mbhc, bool lock);
|
||||
bool (*micbias_enable_status)(struct wcd_mbhc *mbhc, int micb_num);
|
||||
void (*mbhc_bias)(struct snd_soc_component *component, bool enable);
|
||||
void (*mbhc_common_micb_ctrl)(struct snd_soc_component *component,
|
||||
int event, bool enable);
|
||||
void (*micb_internal)(struct snd_soc_component *component,
|
||||
int micb_num, bool enable);
|
||||
bool (*hph_pa_on_status)(struct snd_soc_component *component);
|
||||
void (*set_btn_thr)(struct snd_soc_component *component,
|
||||
s16 *btn_low, s16 *btn_high,
|
||||
int num_btn, bool is_micbias);
|
||||
void (*hph_pull_up_control)(struct snd_soc_component *component,
|
||||
enum mbhc_hs_pullup_iref);
|
||||
int (*mbhc_micbias_control)(struct snd_soc_codec *, int, int req);
|
||||
void (*mbhc_micb_ramp_control)(struct snd_soc_codec *, bool);
|
||||
void (*skip_imped_detect)(struct snd_soc_codec *);
|
||||
bool (*extn_use_mb)(struct snd_soc_codec *);
|
||||
int (*mbhc_micb_ctrl_thr_mic)(struct snd_soc_codec *, int, bool);
|
||||
void (*mbhc_gnd_det_ctrl)(struct snd_soc_codec *, bool);
|
||||
void (*hph_pull_down_ctrl)(struct snd_soc_codec *, bool);
|
||||
void (*mbhc_moisture_config)(struct wcd_mbhc *);
|
||||
bool (*hph_register_recovery)(struct wcd_mbhc *);
|
||||
void (*update_anc_state)(struct snd_soc_codec *codec,
|
||||
int (*mbhc_micbias_control)(struct snd_soc_component *component,
|
||||
int micb_num, int req);
|
||||
void (*mbhc_micb_ramp_control)(struct snd_soc_component *component,
|
||||
bool enable);
|
||||
void (*skip_imped_detect)(struct snd_soc_component *component);
|
||||
bool (*extn_use_mb)(struct snd_soc_component *component);
|
||||
int (*mbhc_micb_ctrl_thr_mic)(struct snd_soc_component *component,
|
||||
int micb_num, bool req_en);
|
||||
void (*mbhc_gnd_det_ctrl)(struct snd_soc_component *component,
|
||||
bool enable);
|
||||
void (*hph_pull_down_ctrl)(struct snd_soc_component *component,
|
||||
bool enable);
|
||||
void (*mbhc_moisture_config)(struct wcd_mbhc *mbhc);
|
||||
bool (*hph_register_recovery)(struct wcd_mbhc *mbhc);
|
||||
void (*update_anc_state)(struct snd_soc_component *component,
|
||||
bool enable, int anc_num);
|
||||
bool (*is_anc_on)(struct wcd_mbhc *mbhc);
|
||||
void (*hph_pull_up_control_v2)(struct snd_soc_codec *, int);
|
||||
bool (*mbhc_get_moisture_status)(struct wcd_mbhc *);
|
||||
void (*mbhc_moisture_polling_ctrl)(struct wcd_mbhc *, bool);
|
||||
void (*mbhc_moisture_detect_en)(struct wcd_mbhc *, bool);
|
||||
void (*hph_pull_up_control_v2)(struct snd_soc_component *component,
|
||||
int pull_up_cur);
|
||||
bool (*mbhc_get_moisture_status)(struct wcd_mbhc *mbhc);
|
||||
void (*mbhc_moisture_polling_ctrl)(struct wcd_mbhc *mbhc, bool enable);
|
||||
void (*mbhc_moisture_detect_en)(struct wcd_mbhc *mbhc, bool enable);
|
||||
};
|
||||
|
||||
struct wcd_mbhc_fn {
|
||||
@@ -544,7 +555,7 @@ struct wcd_mbhc {
|
||||
bool is_btn_already_regd;
|
||||
bool extn_cable_hph_rem;
|
||||
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
/* Work to perform MBHC Firmware Read */
|
||||
struct delayed_work mbhc_firmware_dwork;
|
||||
const struct firmware *mbhc_fw;
|
||||
|
文件差异内容过多而无法显示
加载差异
@@ -1,6 +1,6 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
#ifndef WCD9335_H
|
||||
#define WCD9335_H
|
||||
@@ -130,94 +130,101 @@ enum {
|
||||
};
|
||||
|
||||
#if IS_ENABLED(CONFIG_SND_SOC_WCD9335)
|
||||
extern void *tasha_get_afe_config(struct snd_soc_codec *codec,
|
||||
extern void *tasha_get_afe_config(struct snd_soc_component *component,
|
||||
enum afe_config_type config_type);
|
||||
extern int tasha_cdc_mclk_enable(struct snd_soc_codec *codec, int enable,
|
||||
bool dapm);
|
||||
extern int tasha_cdc_mclk_tx_enable(struct snd_soc_codec *codec, int enable,
|
||||
bool dapm);
|
||||
extern int tasha_enable_efuse_sensing(struct snd_soc_codec *codec);
|
||||
extern int tasha_mbhc_hs_detect(struct snd_soc_codec *codec,
|
||||
extern int tasha_cdc_mclk_enable(struct snd_soc_component *component,
|
||||
int enable, bool dapm);
|
||||
extern int tasha_cdc_mclk_tx_enable(struct snd_soc_component *component,
|
||||
int enable, bool dapm);
|
||||
extern int tasha_enable_efuse_sensing(struct snd_soc_component *component);
|
||||
extern int tasha_mbhc_hs_detect(struct snd_soc_component *component,
|
||||
struct wcd_mbhc_config *mbhc_cfg);
|
||||
extern void tasha_mbhc_hs_detect_exit(struct snd_soc_codec *codec);
|
||||
extern void tasha_mbhc_hs_detect_exit(struct snd_soc_component *component);
|
||||
extern void tasha_mbhc_zdet_gpio_ctrl(
|
||||
int (*zdet_gpio_cb)(struct snd_soc_codec *codec, bool high),
|
||||
struct snd_soc_codec *codec);
|
||||
int (*zdet_gpio_cb)(struct snd_soc_component *component,
|
||||
bool high), struct snd_soc_component *component);
|
||||
extern int tasha_codec_info_create_codec_entry(
|
||||
struct snd_info_entry *codec_root,
|
||||
struct snd_soc_codec *codec);
|
||||
struct snd_soc_component *component);
|
||||
extern void tasha_event_register(
|
||||
int (*machine_event_cb)(struct snd_soc_codec *codec,
|
||||
int (*machine_event_cb)(struct snd_soc_component *component,
|
||||
enum wcd9335_codec_event),
|
||||
struct snd_soc_codec *codec);
|
||||
extern int tasha_codec_enable_standalone_micbias(struct snd_soc_codec *codec,
|
||||
struct snd_soc_component *component);
|
||||
extern int tasha_codec_enable_standalone_micbias(
|
||||
struct snd_soc_component *component,
|
||||
int micb_num,
|
||||
bool enable);
|
||||
extern int tasha_set_spkr_mode(struct snd_soc_codec *codec, int mode);
|
||||
extern int tasha_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset);
|
||||
extern int tasha_set_spkr_mode(struct snd_soc_component *component, int mode);
|
||||
extern int tasha_set_spkr_gain_offset(struct snd_soc_component *component,
|
||||
int offset);
|
||||
extern enum codec_variant tasha_codec_ver(void);
|
||||
#else /* CONFIG_SND_SOC_WCD9335 */
|
||||
static inline void *tasha_get_afe_config(struct snd_soc_codec *codec,
|
||||
static inline void *tasha_get_afe_config(struct snd_soc_component *component,
|
||||
enum afe_config_type config_type)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
static inline int tasha_cdc_mclk_enable(struct snd_soc_codec *codec,
|
||||
static inline int tasha_cdc_mclk_enable(struct snd_soc_component *component,
|
||||
int enable,
|
||||
bool dapm)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static inline int tasha_cdc_mclk_tx_enable(struct snd_soc_codec *codec,
|
||||
static inline int tasha_cdc_mclk_tx_enable(struct snd_soc_component *component,
|
||||
int enable,
|
||||
bool dapm)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static inline int tasha_enable_efuse_sensing(struct snd_soc_codec *codec)
|
||||
static inline int tasha_enable_efuse_sensing(
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static inline int tasha_mbhc_hs_detect(struct snd_soc_codec *codec,
|
||||
static inline int tasha_mbhc_hs_detect(struct snd_soc_component *component,
|
||||
struct wcd_mbhc_config *mbhc_cfg)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static inline void tasha_mbhc_hs_detect_exit(struct snd_soc_codec *codec)
|
||||
static inline void tasha_mbhc_hs_detect_exit(
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
|
||||
}
|
||||
static inline void tasha_mbhc_zdet_gpio_ctrl(
|
||||
int (*zdet_gpio_cb)(struct snd_soc_codec *codec, bool high),
|
||||
struct snd_soc_codec *codec)
|
||||
int (*zdet_gpio_cb)(struct snd_soc_component *component,
|
||||
bool high),
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
|
||||
}
|
||||
static inline int tasha_codec_info_create_codec_entry(
|
||||
struct snd_info_entry *codec_root,
|
||||
struct snd_soc_codec *codec)
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static inline void tasha_event_register(
|
||||
int (*machine_event_cb)(struct snd_soc_codec *codec,
|
||||
int (*machine_event_cb)(struct snd_soc_component *component,
|
||||
enum wcd9335_codec_event),
|
||||
struct snd_soc_codec *codec)
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
|
||||
}
|
||||
static inline int tasha_codec_enable_standalone_micbias(
|
||||
struct snd_soc_codec *codec,
|
||||
struct snd_soc_component *component,
|
||||
int micb_num,
|
||||
bool enable)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static inline int tasha_set_spkr_mode(struct snd_soc_codec *codec, int mode)
|
||||
static inline int tasha_set_spkr_mode(struct snd_soc_component *component,
|
||||
int mode)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static inline int tasha_set_spkr_gain_offset(struct snd_soc_codec *codec,
|
||||
static inline int tasha_set_spkr_gain_offset(
|
||||
struct snd_soc_component *component,
|
||||
int offset)
|
||||
{
|
||||
return 0;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
@@ -162,15 +162,15 @@ int tavil_dsd_set_out_select(struct tavil_dsd_config *dsd_conf,
|
||||
int interp_num)
|
||||
{
|
||||
unsigned int reg, val;
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
|
||||
if (!dsd_conf || !dsd_conf->codec)
|
||||
if (!dsd_conf || !dsd_conf->component)
|
||||
return -EINVAL;
|
||||
|
||||
codec = dsd_conf->codec;
|
||||
component = dsd_conf->component;
|
||||
|
||||
if (!is_valid_dsd_interpolator(interp_num)) {
|
||||
dev_err(codec->dev, "%s: Invalid Interpolator: %d for DSD\n",
|
||||
dev_err(component->dev, "%s: Invalid Interpolator: %d for DSD\n",
|
||||
__func__, interp_num);
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -196,7 +196,7 @@ int tavil_dsd_set_out_select(struct tavil_dsd_config *dsd_conf,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
snd_soc_update_bits(codec, reg, 0x02, val);
|
||||
snd_soc_component_update_bits(component, reg, 0x02, val);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -210,16 +210,20 @@ EXPORT_SYMBOL(tavil_dsd_set_out_select);
|
||||
*/
|
||||
void tavil_dsd_reset(struct tavil_dsd_config *dsd_conf)
|
||||
{
|
||||
if (!dsd_conf || !dsd_conf->codec)
|
||||
if (!dsd_conf || !dsd_conf->component)
|
||||
return;
|
||||
|
||||
snd_soc_update_bits(dsd_conf->codec, WCD934X_CDC_DSD0_PATH_CTL,
|
||||
snd_soc_component_update_bits(dsd_conf->component,
|
||||
WCD934X_CDC_DSD0_PATH_CTL,
|
||||
0x02, 0x02);
|
||||
snd_soc_update_bits(dsd_conf->codec, WCD934X_CDC_DSD0_PATH_CTL,
|
||||
snd_soc_component_update_bits(dsd_conf->component,
|
||||
WCD934X_CDC_DSD0_PATH_CTL,
|
||||
0x01, 0x00);
|
||||
snd_soc_update_bits(dsd_conf->codec, WCD934X_CDC_DSD1_PATH_CTL,
|
||||
snd_soc_component_update_bits(dsd_conf->component,
|
||||
WCD934X_CDC_DSD1_PATH_CTL,
|
||||
0x02, 0x02);
|
||||
snd_soc_update_bits(dsd_conf->codec, WCD934X_CDC_DSD1_PATH_CTL,
|
||||
snd_soc_component_update_bits(dsd_conf->component,
|
||||
WCD934X_CDC_DSD1_PATH_CTL,
|
||||
0x01, 0x00);
|
||||
}
|
||||
EXPORT_SYMBOL(tavil_dsd_reset);
|
||||
@@ -240,17 +244,17 @@ void tavil_dsd_set_interp_rate(struct tavil_dsd_config *dsd_conf, u16 rx_port,
|
||||
u8 val0, val1;
|
||||
u8 dsd0_out_sel, dsd1_out_sel;
|
||||
u16 int_fs_reg, interp_num = 0;
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
|
||||
if (!dsd_conf || !dsd_conf->codec)
|
||||
if (!dsd_conf || !dsd_conf->component)
|
||||
return;
|
||||
|
||||
codec = dsd_conf->codec;
|
||||
component = dsd_conf->component;
|
||||
|
||||
dsd_inp_sel = DSD_INP_SEL_RX0 + rx_port - WCD934X_RX_PORT_START_NUMBER;
|
||||
|
||||
val0 = snd_soc_read(codec, WCD934X_CDC_DSD0_CFG0);
|
||||
val1 = snd_soc_read(codec, WCD934X_CDC_DSD1_CFG0);
|
||||
val0 = snd_soc_component_read32(component, WCD934X_CDC_DSD0_CFG0);
|
||||
val1 = snd_soc_component_read32(component, WCD934X_CDC_DSD1_CFG0);
|
||||
dsd0_inp = (val0 & 0x3C) >> 2;
|
||||
dsd1_inp = (val1 & 0x3C) >> 2;
|
||||
dsd0_out_sel = (val0 & 0x02) >> 1;
|
||||
@@ -270,23 +274,24 @@ void tavil_dsd_set_interp_rate(struct tavil_dsd_config *dsd_conf, u16 rx_port,
|
||||
|
||||
if (interp_num) {
|
||||
int_fs_reg = WCD934X_CDC_RX0_RX_PATH_CTL + 20 * interp_num;
|
||||
if ((snd_soc_read(codec, int_fs_reg) & 0x0f) < 0x09) {
|
||||
dev_dbg(codec->dev, "%s: Set Interp %d to sample_rate val 0x%x\n",
|
||||
if ((snd_soc_component_read32(component, int_fs_reg) & 0x0f) <
|
||||
0x09) {
|
||||
dev_dbg(component->dev, "%s: Set Interp %d to sample_rate val 0x%x\n",
|
||||
__func__, interp_num, sample_rate_val);
|
||||
snd_soc_update_bits(codec, int_fs_reg, 0x0F,
|
||||
sample_rate_val);
|
||||
snd_soc_component_update_bits(component, int_fs_reg,
|
||||
0x0F, sample_rate_val);
|
||||
}
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL(tavil_dsd_set_interp_rate);
|
||||
|
||||
static int tavil_set_dsd_mode(struct snd_soc_codec *codec, int dsd_num,
|
||||
static int tavil_set_dsd_mode(struct snd_soc_component *component, int dsd_num,
|
||||
u8 *pcm_rate_val)
|
||||
{
|
||||
unsigned int dsd_out_sel_reg;
|
||||
u8 dsd_mode;
|
||||
u32 sample_rate;
|
||||
struct tavil_dsd_config *dsd_conf = tavil_get_dsd_config(codec);
|
||||
struct tavil_dsd_config *dsd_conf = tavil_get_dsd_config(component);
|
||||
|
||||
if (!dsd_conf)
|
||||
return -EINVAL;
|
||||
@@ -307,17 +312,19 @@ static int tavil_set_dsd_mode(struct snd_soc_codec *codec, int dsd_num,
|
||||
*pcm_rate_val = 0xc;
|
||||
break;
|
||||
default:
|
||||
dev_err(codec->dev, "%s: Invalid DSD rate: %d\n",
|
||||
dev_err(component->dev, "%s: Invalid DSD rate: %d\n",
|
||||
__func__, sample_rate);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
snd_soc_update_bits(codec, dsd_out_sel_reg, 0x01, dsd_mode);
|
||||
snd_soc_component_update_bits(component, dsd_out_sel_reg,
|
||||
0x01, dsd_mode);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void tavil_dsd_data_pull(struct snd_soc_codec *codec, int dsd_num,
|
||||
static void tavil_dsd_data_pull(struct snd_soc_component *component,
|
||||
int dsd_num,
|
||||
u8 pcm_rate_val, bool enable)
|
||||
{
|
||||
u8 clk_en, mute_en;
|
||||
@@ -332,37 +339,41 @@ static void tavil_dsd_data_pull(struct snd_soc_codec *codec, int dsd_num,
|
||||
}
|
||||
|
||||
if (dsd_num & 0x01) {
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_RX7_RX_PATH_MIX_CTL,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_RX7_RX_PATH_MIX_CTL,
|
||||
0x20, clk_en);
|
||||
dsd_inp_sel = (snd_soc_read(codec, WCD934X_CDC_DSD0_CFG0) &
|
||||
dsd_inp_sel = (snd_soc_component_read32(
|
||||
component, WCD934X_CDC_DSD0_CFG0) &
|
||||
0x3C) >> 2;
|
||||
dsd_inp_sel = (enable) ? dsd_inp_sel : 0;
|
||||
if (dsd_inp_sel < 9) {
|
||||
snd_soc_update_bits(codec,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_RX_INP_MUX_RX_INT7_CFG1,
|
||||
0x0F, dsd_inp_sel);
|
||||
snd_soc_update_bits(codec,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_RX7_RX_PATH_MIX_CTL,
|
||||
0x0F, pcm_rate_val);
|
||||
snd_soc_update_bits(codec,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_RX7_RX_PATH_MIX_CTL,
|
||||
0x10, mute_en);
|
||||
}
|
||||
}
|
||||
if (dsd_num & 0x02) {
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_RX8_RX_PATH_MIX_CTL,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_RX8_RX_PATH_MIX_CTL,
|
||||
0x20, clk_en);
|
||||
dsd_inp_sel = (snd_soc_read(codec, WCD934X_CDC_DSD1_CFG0) &
|
||||
dsd_inp_sel = (snd_soc_component_read32(
|
||||
component, WCD934X_CDC_DSD1_CFG0) &
|
||||
0x3C) >> 2;
|
||||
dsd_inp_sel = (enable) ? dsd_inp_sel : 0;
|
||||
if (dsd_inp_sel < 9) {
|
||||
snd_soc_update_bits(codec,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_RX_INP_MUX_RX_INT8_CFG1,
|
||||
0x0F, dsd_inp_sel);
|
||||
snd_soc_update_bits(codec,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_RX8_RX_PATH_MIX_CTL,
|
||||
0x0F, pcm_rate_val);
|
||||
snd_soc_update_bits(codec,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_RX8_RX_PATH_MIX_CTL,
|
||||
0x10, mute_en);
|
||||
}
|
||||
@@ -371,84 +382,98 @@ static void tavil_dsd_data_pull(struct snd_soc_codec *codec, int dsd_num,
|
||||
|
||||
static void tavil_dsd_update_volume(struct tavil_dsd_config *dsd_conf)
|
||||
{
|
||||
snd_soc_update_bits(dsd_conf->codec, WCD934X_CDC_TOP_TOP_CFG0,
|
||||
snd_soc_component_update_bits(dsd_conf->component,
|
||||
WCD934X_CDC_TOP_TOP_CFG0,
|
||||
0x01, 0x01);
|
||||
snd_soc_update_bits(dsd_conf->codec, WCD934X_CDC_TOP_TOP_CFG0,
|
||||
snd_soc_component_update_bits(dsd_conf->component,
|
||||
WCD934X_CDC_TOP_TOP_CFG0,
|
||||
0x01, 0x00);
|
||||
}
|
||||
|
||||
static int tavil_enable_dsd(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
||||
struct tavil_dsd_config *dsd_conf = tavil_get_dsd_config(codec);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_dapm_to_component(w->dapm);
|
||||
struct tavil_dsd_config *dsd_conf = tavil_get_dsd_config(component);
|
||||
int rc, clk_users;
|
||||
int interp_idx;
|
||||
u8 pcm_rate_val;
|
||||
|
||||
if (!dsd_conf) {
|
||||
dev_err(codec->dev, "%s: null dsd_config pointer\n", __func__);
|
||||
dev_err(component->dev, "%s: null dsd_config pointer\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
dev_dbg(codec->dev, "%s: DSD%d, event: %d\n", __func__,
|
||||
dev_dbg(component->dev, "%s: DSD%d, event: %d\n", __func__,
|
||||
w->shift, event);
|
||||
|
||||
if (w->shift == DSD0) {
|
||||
/* Read out select */
|
||||
if (snd_soc_read(codec, WCD934X_CDC_DSD0_CFG0) & 0x02)
|
||||
if (snd_soc_component_read32(
|
||||
component, WCD934X_CDC_DSD0_CFG0) & 0x02)
|
||||
interp_idx = INTERP_LO1;
|
||||
else
|
||||
interp_idx = INTERP_HPHL;
|
||||
} else if (w->shift == DSD1) {
|
||||
/* Read out select */
|
||||
if (snd_soc_read(codec, WCD934X_CDC_DSD1_CFG0) & 0x02)
|
||||
if (snd_soc_component_read32(
|
||||
component, WCD934X_CDC_DSD1_CFG0) & 0x02)
|
||||
interp_idx = INTERP_LO2;
|
||||
else
|
||||
interp_idx = INTERP_HPHR;
|
||||
} else {
|
||||
dev_err(codec->dev, "%s: Unsupported DSD:%d\n",
|
||||
dev_err(component->dev, "%s: Unsupported DSD:%d\n",
|
||||
__func__, w->shift);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_PRE_PMU:
|
||||
clk_users = tavil_codec_enable_interp_clk(codec, event,
|
||||
clk_users = tavil_codec_enable_interp_clk(component, event,
|
||||
interp_idx);
|
||||
|
||||
rc = tavil_set_dsd_mode(codec, w->shift, &pcm_rate_val);
|
||||
rc = tavil_set_dsd_mode(component, w->shift, &pcm_rate_val);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
tavil_dsd_data_pull(codec, (1 << w->shift), pcm_rate_val,
|
||||
tavil_dsd_data_pull(component, (1 << w->shift), pcm_rate_val,
|
||||
true);
|
||||
|
||||
snd_soc_update_bits(codec,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_CLK_RST_CTRL_DSD_CONTROL, 0x01,
|
||||
0x01);
|
||||
if (w->shift == DSD0) {
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DSD0_PATH_CTL,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DSD0_PATH_CTL,
|
||||
0x02, 0x02);
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DSD0_PATH_CTL,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DSD0_PATH_CTL,
|
||||
0x02, 0x00);
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DSD0_PATH_CTL,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DSD0_PATH_CTL,
|
||||
0x01, 0x01);
|
||||
/* Apply Gain */
|
||||
snd_soc_write(codec, WCD934X_CDC_DSD0_CFG1,
|
||||
snd_soc_component_write(component,
|
||||
WCD934X_CDC_DSD0_CFG1,
|
||||
dsd_conf->volume[DSD0]);
|
||||
if (dsd_conf->version == TAVIL_VERSION_1_1)
|
||||
tavil_dsd_update_volume(dsd_conf);
|
||||
|
||||
} else if (w->shift == DSD1) {
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DSD1_PATH_CTL,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DSD1_PATH_CTL,
|
||||
0x02, 0x02);
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DSD1_PATH_CTL,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DSD1_PATH_CTL,
|
||||
0x02, 0x00);
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DSD1_PATH_CTL,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DSD1_PATH_CTL,
|
||||
0x01, 0x01);
|
||||
/* Apply Gain */
|
||||
snd_soc_write(codec, WCD934X_CDC_DSD1_CFG1,
|
||||
snd_soc_component_write(component,
|
||||
WCD934X_CDC_DSD1_CFG1,
|
||||
dsd_conf->volume[DSD1]);
|
||||
if (dsd_conf->version == TAVIL_VERSION_1_1)
|
||||
tavil_dsd_update_volume(dsd_conf);
|
||||
@@ -457,14 +482,15 @@ static int tavil_enable_dsd(struct snd_soc_dapm_widget *w,
|
||||
usleep_range(10000, 10100);
|
||||
|
||||
if (clk_users > 1) {
|
||||
snd_soc_update_bits(codec, WCD934X_ANA_RX_SUPPLIES,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_ANA_RX_SUPPLIES,
|
||||
0x02, 0x02);
|
||||
if (w->shift == DSD0)
|
||||
snd_soc_update_bits(codec,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DSD0_CFG2,
|
||||
0x04, 0x00);
|
||||
if (w->shift == DSD1)
|
||||
snd_soc_update_bits(codec,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DSD1_CFG2,
|
||||
0x04, 0x00);
|
||||
|
||||
@@ -472,25 +498,31 @@ static int tavil_enable_dsd(struct snd_soc_dapm_widget *w,
|
||||
break;
|
||||
case SND_SOC_DAPM_POST_PMD:
|
||||
if (w->shift == DSD0) {
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DSD0_CFG2,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DSD0_CFG2,
|
||||
0x04, 0x04);
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DSD0_PATH_CTL,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DSD0_PATH_CTL,
|
||||
0x01, 0x00);
|
||||
} else if (w->shift == DSD1) {
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DSD1_CFG2,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DSD1_CFG2,
|
||||
0x04, 0x04);
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DSD1_PATH_CTL,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DSD1_PATH_CTL,
|
||||
0x01, 0x00);
|
||||
}
|
||||
|
||||
tavil_codec_enable_interp_clk(codec, event, interp_idx);
|
||||
tavil_codec_enable_interp_clk(component, event, interp_idx);
|
||||
|
||||
if (!(snd_soc_read(codec, WCD934X_CDC_DSD0_PATH_CTL) & 0x01) &&
|
||||
!(snd_soc_read(codec, WCD934X_CDC_DSD1_PATH_CTL) & 0x01)) {
|
||||
snd_soc_update_bits(codec,
|
||||
if (!(snd_soc_component_read32(
|
||||
component, WCD934X_CDC_DSD0_PATH_CTL) & 0x01) &&
|
||||
!(snd_soc_component_read32(
|
||||
component, WCD934X_CDC_DSD1_PATH_CTL) & 0x01)) {
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_CLK_RST_CTRL_DSD_CONTROL,
|
||||
0x01, 0x00);
|
||||
tavil_dsd_data_pull(codec, 0x03, 0x04, false);
|
||||
tavil_dsd_data_pull(component, 0x03, 0x04, false);
|
||||
tavil_dsd_reset(dsd_conf);
|
||||
}
|
||||
break;
|
||||
@@ -513,8 +545,9 @@ static int tavil_dsd_vol_info(struct snd_kcontrol *kcontrol,
|
||||
static int tavil_dsd_vol_put(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct tavil_dsd_config *dsd_conf = tavil_get_dsd_config(codec);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct tavil_dsd_config *dsd_conf = tavil_get_dsd_config(component);
|
||||
int nv[DSD_MAX], cv[DSD_MAX];
|
||||
int step_size, nv1;
|
||||
int i, dsd_idx;
|
||||
@@ -537,7 +570,7 @@ static int tavil_dsd_vol_put(struct snd_kcontrol *kcontrol,
|
||||
if (cv[dsd_idx] == nv[dsd_idx])
|
||||
continue;
|
||||
|
||||
dev_dbg(codec->dev, "%s: DSD%d cur.vol: %d, new vol: %d\n",
|
||||
dev_dbg(component->dev, "%s: DSD%d cur.vol: %d, new vol: %d\n",
|
||||
__func__, dsd_idx, cv[dsd_idx], nv[dsd_idx]);
|
||||
|
||||
step_size = (nv[dsd_idx] - cv[dsd_idx]) /
|
||||
@@ -547,7 +580,7 @@ static int tavil_dsd_vol_put(struct snd_kcontrol *kcontrol,
|
||||
|
||||
for (i = 0; i < DSD_VOLUME_STEPS; i++) {
|
||||
nv1 += step_size;
|
||||
snd_soc_write(codec,
|
||||
snd_soc_component_write(component,
|
||||
WCD934X_CDC_DSD0_CFG1 + 16 * dsd_idx,
|
||||
nv1);
|
||||
if (dsd_conf->version == TAVIL_VERSION_1_1)
|
||||
@@ -559,7 +592,7 @@ static int tavil_dsd_vol_put(struct snd_kcontrol *kcontrol,
|
||||
DSD_VOLUME_USLEEP_MARGIN_US));
|
||||
}
|
||||
if (nv1 != nv[dsd_idx]) {
|
||||
snd_soc_write(codec,
|
||||
snd_soc_component_write(component,
|
||||
WCD934X_CDC_DSD0_CFG1 + 16 * dsd_idx,
|
||||
nv[dsd_idx]);
|
||||
|
||||
@@ -579,8 +612,9 @@ done:
|
||||
static int tavil_dsd_vol_get(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct tavil_dsd_config *dsd_conf = tavil_get_dsd_config(codec);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct tavil_dsd_config *dsd_conf = tavil_get_dsd_config(component);
|
||||
|
||||
if (dsd_conf) {
|
||||
ucontrol->value.integer.value[0] = dsd_conf->volume[DSD0];
|
||||
@@ -618,45 +652,63 @@ static const struct snd_soc_dapm_widget tavil_dsd_widgets[] = {
|
||||
/**
|
||||
* tavil_dsd_post_ssr_init - DSD intialization after subsystem restart
|
||||
*
|
||||
* @codec: pointer to snd_soc_codec
|
||||
* @component: pointer to snd_soc_component
|
||||
*
|
||||
* Returns 0 on success or error on failure
|
||||
*/
|
||||
int tavil_dsd_post_ssr_init(struct tavil_dsd_config *dsd_conf)
|
||||
{
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
|
||||
if (!dsd_conf || !dsd_conf->codec)
|
||||
if (!dsd_conf || !dsd_conf->component)
|
||||
return -EINVAL;
|
||||
|
||||
codec = dsd_conf->codec;
|
||||
component = dsd_conf->component;
|
||||
/* Disable DSD Interrupts */
|
||||
snd_soc_update_bits(codec, WCD934X_INTR_CODEC_MISC_MASK, 0x08, 0x08);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_INTR_CODEC_MISC_MASK,
|
||||
0x08, 0x08);
|
||||
|
||||
/* DSD registers init */
|
||||
if (dsd_conf->version == TAVIL_VERSION_1_0) {
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DSD0_CFG2, 0x02, 0x00);
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DSD1_CFG2, 0x02, 0x00);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DSD0_CFG2,
|
||||
0x02, 0x00);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DSD1_CFG2,
|
||||
0x02, 0x00);
|
||||
}
|
||||
/* DSD0: Mute EN */
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DSD0_CFG2, 0x04, 0x04);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DSD0_CFG2,
|
||||
0x04, 0x04);
|
||||
/* DSD1: Mute EN */
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DSD1_CFG2, 0x04, 0x04);
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG3, 0x10,
|
||||
0x10);
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG3, 0x10,
|
||||
0x10);
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG0, 0x0E,
|
||||
0x0A);
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG0, 0x0E,
|
||||
0x0A);
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG1, 0x07,
|
||||
0x04);
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG1, 0x07,
|
||||
0x04);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DSD1_CFG2,
|
||||
0x04, 0x04);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG3,
|
||||
0x10, 0x10);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG3,
|
||||
0x10, 0x10);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG0,
|
||||
0x0E, 0x0A);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG0,
|
||||
0x0E, 0x0A);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG1,
|
||||
0x07, 0x04);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG1,
|
||||
0x07, 0x04);
|
||||
|
||||
/* Enable DSD Interrupts */
|
||||
snd_soc_update_bits(codec, WCD934X_INTR_CODEC_MISC_MASK, 0x08, 0x00);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_INTR_CODEC_MISC_MASK,
|
||||
0x08, 0x00);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -665,60 +717,71 @@ EXPORT_SYMBOL(tavil_dsd_post_ssr_init);
|
||||
/**
|
||||
* tavil_dsd_init - DSD intialization
|
||||
*
|
||||
* @codec: pointer to snd_soc_codec
|
||||
* @component: pointer to snd_soc_component
|
||||
*
|
||||
* Returns pointer to tavil_dsd_config for success or NULL for failure
|
||||
*/
|
||||
struct tavil_dsd_config *tavil_dsd_init(struct snd_soc_codec *codec)
|
||||
struct tavil_dsd_config *tavil_dsd_init(struct snd_soc_component *component)
|
||||
{
|
||||
struct snd_soc_dapm_context *dapm;
|
||||
struct tavil_dsd_config *dsd_conf;
|
||||
u8 val;
|
||||
|
||||
if (!codec)
|
||||
if (!component)
|
||||
return NULL;
|
||||
|
||||
dapm = snd_soc_codec_get_dapm(codec);
|
||||
dapm = snd_soc_component_get_dapm(component);
|
||||
|
||||
/* Read efuse register to check if DSD is supported */
|
||||
val = snd_soc_read(codec, WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT14);
|
||||
val = snd_soc_component_read32(component,
|
||||
WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT14);
|
||||
if (val & 0x80) {
|
||||
dev_info(codec->dev, "%s: DSD unsupported for this codec version\n",
|
||||
dev_info(component->dev, "%s: DSD unsupported for this codec version\n",
|
||||
__func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dsd_conf = devm_kzalloc(codec->dev, sizeof(struct tavil_dsd_config),
|
||||
dsd_conf = devm_kzalloc(component->dev, sizeof(struct tavil_dsd_config),
|
||||
GFP_KERNEL);
|
||||
if (!dsd_conf)
|
||||
return NULL;
|
||||
|
||||
dsd_conf->codec = codec;
|
||||
dsd_conf->component = component;
|
||||
|
||||
/* Read version */
|
||||
dsd_conf->version = snd_soc_read(codec,
|
||||
dsd_conf->version = snd_soc_component_read32(component,
|
||||
WCD934X_CHIP_TIER_CTRL_CHIP_ID_BYTE0);
|
||||
/* DSD registers init */
|
||||
if (dsd_conf->version == TAVIL_VERSION_1_0) {
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DSD0_CFG2, 0x02, 0x00);
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DSD1_CFG2, 0x02, 0x00);
|
||||
snd_soc_component_update_bits(component, WCD934X_CDC_DSD0_CFG2,
|
||||
0x02, 0x00);
|
||||
snd_soc_component_update_bits(component, WCD934X_CDC_DSD1_CFG2,
|
||||
0x02, 0x00);
|
||||
}
|
||||
/* DSD0: Mute EN */
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DSD0_CFG2, 0x04, 0x04);
|
||||
snd_soc_component_update_bits(component, WCD934X_CDC_DSD0_CFG2,
|
||||
0x04, 0x04);
|
||||
/* DSD1: Mute EN */
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DSD1_CFG2, 0x04, 0x04);
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG3, 0x10,
|
||||
0x10);
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG3, 0x10,
|
||||
0x10);
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG0, 0x0E,
|
||||
0x0A);
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG0, 0x0E,
|
||||
0x0A);
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG1, 0x07,
|
||||
0x04);
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG1, 0x07,
|
||||
0x04);
|
||||
snd_soc_component_update_bits(component, WCD934X_CDC_DSD1_CFG2,
|
||||
0x04, 0x04);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG3,
|
||||
0x10, 0x10);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG3,
|
||||
0x10, 0x10);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG0,
|
||||
0x0E, 0x0A);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG0,
|
||||
0x0E, 0x0A);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG1,
|
||||
0x07, 0x04);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG1,
|
||||
0x07, 0x04);
|
||||
|
||||
snd_soc_dapm_new_controls(dapm, tavil_dsd_widgets,
|
||||
ARRAY_SIZE(tavil_dsd_widgets));
|
||||
@@ -730,11 +793,12 @@ struct tavil_dsd_config *tavil_dsd_init(struct snd_soc_codec *codec)
|
||||
dsd_conf->volume[DSD0] = DSD_VOLUME_MAX_0dB;
|
||||
dsd_conf->volume[DSD1] = DSD_VOLUME_MAX_0dB;
|
||||
|
||||
snd_soc_add_codec_controls(codec, tavil_dsd_vol_controls,
|
||||
snd_soc_add_component_controls(component, tavil_dsd_vol_controls,
|
||||
ARRAY_SIZE(tavil_dsd_vol_controls));
|
||||
|
||||
/* Enable DSD Interrupts */
|
||||
snd_soc_update_bits(codec, WCD934X_INTR_CODEC_MISC_MASK, 0x08, 0x00);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_INTR_CODEC_MISC_MASK, 0x08, 0x00);
|
||||
|
||||
return dsd_conf;
|
||||
}
|
||||
@@ -747,18 +811,19 @@ EXPORT_SYMBOL(tavil_dsd_init);
|
||||
*/
|
||||
void tavil_dsd_deinit(struct tavil_dsd_config *dsd_conf)
|
||||
{
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
|
||||
if (!dsd_conf)
|
||||
return;
|
||||
|
||||
codec = dsd_conf->codec;
|
||||
component = dsd_conf->component;
|
||||
|
||||
mutex_destroy(&dsd_conf->vol_mutex);
|
||||
|
||||
/* Disable DSD Interrupts */
|
||||
snd_soc_update_bits(codec, WCD934X_INTR_CODEC_MISC_MASK, 0x08, 0x08);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_INTR_CODEC_MISC_MASK, 0x08, 0x08);
|
||||
|
||||
devm_kfree(codec->dev, dsd_conf);
|
||||
devm_kfree(component->dev, dsd_conf);
|
||||
}
|
||||
EXPORT_SYMBOL(tavil_dsd_deinit);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __WCD934X_DSD_H__
|
||||
@@ -27,7 +27,7 @@ enum {
|
||||
};
|
||||
|
||||
struct tavil_dsd_config {
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
unsigned int dsd_interp_mixer[INTERP_MAX];
|
||||
u32 base_sample_rate[DSD_MAX];
|
||||
int volume[DSD_MAX];
|
||||
@@ -45,7 +45,7 @@ int tavil_dsd_set_out_select(struct tavil_dsd_config *dsd_conf,
|
||||
void tavil_dsd_reset(struct tavil_dsd_config *dsd_conf);
|
||||
void tavil_dsd_set_interp_rate(struct tavil_dsd_config *dsd_conf, u16 rx_port,
|
||||
u32 sample_rate, u8 sample_rate_val);
|
||||
struct tavil_dsd_config *tavil_dsd_init(struct snd_soc_codec *codec);
|
||||
struct tavil_dsd_config *tavil_dsd_init(struct snd_soc_component *component);
|
||||
void tavil_dsd_deinit(struct tavil_dsd_config *dsd_config);
|
||||
int tavil_dsd_post_ssr_init(struct tavil_dsd_config *dsd_config);
|
||||
#else
|
||||
@@ -74,7 +74,7 @@ void tavil_dsd_set_interp_rate(struct tavil_dsd_config *dsd_conf, u16 rx_port,
|
||||
u32 sample_rate, u8 sample_rate_val)
|
||||
{ }
|
||||
|
||||
struct tavil_dsd_config *tavil_dsd_init(struct snd_soc_codec *codec)
|
||||
struct tavil_dsd_config *tavil_dsd_init(struct snd_soc_component *component)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
文件差异内容过多而无法显示
加载差异
@@ -17,9 +17,9 @@ enum cdc_ssr_event {
|
||||
|
||||
struct wcd_dsp_cdc_cb {
|
||||
/* Callback to enable codec clock */
|
||||
int (*cdc_clk_en)(struct snd_soc_codec *, bool);
|
||||
int (*cdc_clk_en)(struct snd_soc_component *component, bool enable);
|
||||
/* Callback to vote and unvote for SVS2 mode */
|
||||
void (*cdc_vote_svs)(struct snd_soc_codec *, bool);
|
||||
void (*cdc_vote_svs)(struct snd_soc_component *component, bool enable);
|
||||
};
|
||||
|
||||
struct wcd_dsp_irq_info {
|
||||
@@ -61,7 +61,7 @@ struct wdsp_ssr_entry {
|
||||
|
||||
struct wcd_dsp_cntl {
|
||||
/* Handle to codec */
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
|
||||
/* Clk rate of the codec clock */
|
||||
u32 clk_rate;
|
||||
@@ -109,7 +109,7 @@ struct wcd_dsp_cntl {
|
||||
#endif
|
||||
};
|
||||
|
||||
void wcd_dsp_cntl_init(struct snd_soc_codec *codec,
|
||||
void wcd_dsp_cntl_init(struct snd_soc_component *component,
|
||||
struct wcd_dsp_params *params,
|
||||
struct wcd_dsp_cntl **cntl);
|
||||
void wcd_dsp_cntl_deinit(struct wcd_dsp_cntl **cntl);
|
||||
|
@@ -169,21 +169,21 @@ struct tavil_mbhc_zdet_param {
|
||||
u16 btn7;
|
||||
};
|
||||
|
||||
static int tavil_mbhc_request_irq(struct snd_soc_codec *codec,
|
||||
static int tavil_mbhc_request_irq(struct snd_soc_component *component,
|
||||
int irq, irq_handler_t handler,
|
||||
const char *name, void *data)
|
||||
{
|
||||
struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
|
||||
struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent);
|
||||
struct wcd9xxx_core_resource *core_res =
|
||||
&wcd9xxx->core_res;
|
||||
|
||||
return wcd9xxx_request_irq(core_res, irq, handler, name, data);
|
||||
}
|
||||
|
||||
static void tavil_mbhc_irq_control(struct snd_soc_codec *codec,
|
||||
static void tavil_mbhc_irq_control(struct snd_soc_component *component,
|
||||
int irq, bool enable)
|
||||
{
|
||||
struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
|
||||
struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent);
|
||||
struct wcd9xxx_core_resource *core_res =
|
||||
&wcd9xxx->core_res;
|
||||
if (enable)
|
||||
@@ -192,10 +192,10 @@ static void tavil_mbhc_irq_control(struct snd_soc_codec *codec,
|
||||
wcd9xxx_disable_irq(core_res, irq);
|
||||
}
|
||||
|
||||
static int tavil_mbhc_free_irq(struct snd_soc_codec *codec,
|
||||
static int tavil_mbhc_free_irq(struct snd_soc_component *component,
|
||||
int irq, void *data)
|
||||
{
|
||||
struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
|
||||
struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent);
|
||||
struct wcd9xxx_core_resource *core_res =
|
||||
&wcd9xxx->core_res;
|
||||
|
||||
@@ -203,27 +203,28 @@ static int tavil_mbhc_free_irq(struct snd_soc_codec *codec,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void tavil_mbhc_clk_setup(struct snd_soc_codec *codec,
|
||||
static void tavil_mbhc_clk_setup(struct snd_soc_component *component,
|
||||
bool enable)
|
||||
{
|
||||
if (enable)
|
||||
snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_1,
|
||||
snd_soc_component_update_bits(component, WCD934X_MBHC_NEW_CTL_1,
|
||||
0x80, 0x80);
|
||||
else
|
||||
snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_1,
|
||||
snd_soc_component_update_bits(component, WCD934X_MBHC_NEW_CTL_1,
|
||||
0x80, 0x00);
|
||||
}
|
||||
|
||||
static int tavil_mbhc_btn_to_num(struct snd_soc_codec *codec)
|
||||
static int tavil_mbhc_btn_to_num(struct snd_soc_component *component)
|
||||
{
|
||||
return snd_soc_read(codec, WCD934X_ANA_MBHC_RESULT_3) & 0x7;
|
||||
return snd_soc_component_read32(component, WCD934X_ANA_MBHC_RESULT_3) &
|
||||
0x7;
|
||||
}
|
||||
|
||||
static int tavil_enable_ext_mb_source(struct wcd_mbhc *mbhc,
|
||||
bool turn_on)
|
||||
{
|
||||
struct wcd934x_mbhc *wcd934x_mbhc;
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
struct wcd934x_on_demand_supply *supply;
|
||||
int ret = 0;
|
||||
|
||||
@@ -231,20 +232,21 @@ static int tavil_enable_ext_mb_source(struct wcd_mbhc *mbhc,
|
||||
|
||||
supply = &wcd934x_mbhc->on_demand_list[WCD934X_ON_DEMAND_MICBIAS];
|
||||
if (!supply->supply) {
|
||||
dev_dbg(codec->dev, "%s: warning supply not present ond for %s\n",
|
||||
dev_dbg(component->dev, "%s: warning supply not present ond for %s\n",
|
||||
__func__, "onDemand Micbias");
|
||||
return ret;
|
||||
}
|
||||
|
||||
dev_dbg(codec->dev, "%s turn_on: %d count: %d\n", __func__, turn_on,
|
||||
dev_dbg(component->dev, "%s turn_on: %d count: %d\n", __func__, turn_on,
|
||||
supply->ondemand_supply_count);
|
||||
|
||||
if (turn_on) {
|
||||
if (!(supply->ondemand_supply_count)) {
|
||||
ret = snd_soc_dapm_force_enable_pin(
|
||||
snd_soc_codec_get_dapm(codec),
|
||||
snd_soc_component_get_dapm(component),
|
||||
"MICBIAS_REGULATOR");
|
||||
snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
|
||||
snd_soc_dapm_sync(
|
||||
snd_soc_component_get_dapm(component));
|
||||
}
|
||||
supply->ondemand_supply_count++;
|
||||
} else {
|
||||
@@ -252,34 +254,34 @@ static int tavil_enable_ext_mb_source(struct wcd_mbhc *mbhc,
|
||||
supply->ondemand_supply_count--;
|
||||
if (!(supply->ondemand_supply_count)) {
|
||||
ret = snd_soc_dapm_disable_pin(
|
||||
snd_soc_codec_get_dapm(codec),
|
||||
snd_soc_component_get_dapm(component),
|
||||
"MICBIAS_REGULATOR");
|
||||
snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
|
||||
snd_soc_dapm_sync(snd_soc_component_get_dapm(component));
|
||||
}
|
||||
}
|
||||
|
||||
if (ret)
|
||||
dev_err(codec->dev, "%s: Failed to %s external micbias source\n",
|
||||
dev_err(component->dev, "%s: Failed to %s external micbias source\n",
|
||||
__func__, turn_on ? "enable" : "disabled");
|
||||
else
|
||||
dev_dbg(codec->dev, "%s: %s external micbias source\n",
|
||||
dev_dbg(component->dev, "%s: %s external micbias source\n",
|
||||
__func__, turn_on ? "Enabled" : "Disabled");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void tavil_mbhc_mbhc_bias_control(struct snd_soc_codec *codec,
|
||||
static void tavil_mbhc_mbhc_bias_control(struct snd_soc_component *component,
|
||||
bool enable)
|
||||
{
|
||||
if (enable)
|
||||
snd_soc_update_bits(codec, WCD934X_ANA_MBHC_ELECT,
|
||||
snd_soc_component_update_bits(component, WCD934X_ANA_MBHC_ELECT,
|
||||
0x01, 0x01);
|
||||
else
|
||||
snd_soc_update_bits(codec, WCD934X_ANA_MBHC_ELECT,
|
||||
snd_soc_component_update_bits(component, WCD934X_ANA_MBHC_ELECT,
|
||||
0x01, 0x00);
|
||||
}
|
||||
|
||||
static void tavil_mbhc_program_btn_thr(struct snd_soc_codec *codec,
|
||||
static void tavil_mbhc_program_btn_thr(struct snd_soc_component *component,
|
||||
s16 *btn_low, s16 *btn_high,
|
||||
int num_btn, bool is_micbias)
|
||||
{
|
||||
@@ -287,7 +289,7 @@ static void tavil_mbhc_program_btn_thr(struct snd_soc_codec *codec,
|
||||
int vth;
|
||||
|
||||
if (num_btn > WCD_MBHC_DEF_BUTTONS) {
|
||||
dev_err(codec->dev, "%s: invalid number of buttons: %d\n",
|
||||
dev_err(component->dev, "%s: invalid number of buttons: %d\n",
|
||||
__func__, num_btn);
|
||||
return;
|
||||
}
|
||||
@@ -299,17 +301,18 @@ static void tavil_mbhc_program_btn_thr(struct snd_soc_codec *codec,
|
||||
*/
|
||||
for (i = 0; i < num_btn; i++) {
|
||||
vth = ((btn_high[i] * 2) / 25) & 0x3F;
|
||||
snd_soc_update_bits(codec, WCD934X_ANA_MBHC_BTN0 + i,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_ANA_MBHC_BTN0 + i,
|
||||
0xFC, vth << 2);
|
||||
dev_dbg(codec->dev, "%s: btn_high[%d]: %d, vth: %d\n",
|
||||
dev_dbg(component->dev, "%s: btn_high[%d]: %d, vth: %d\n",
|
||||
__func__, i, btn_high[i], vth);
|
||||
}
|
||||
}
|
||||
|
||||
static bool tavil_mbhc_lock_sleep(struct wcd_mbhc *mbhc, bool lock)
|
||||
{
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent);
|
||||
struct wcd9xxx_core_resource *core_res =
|
||||
&wcd9xxx->core_res;
|
||||
bool ret = 0;
|
||||
@@ -343,20 +346,22 @@ static bool tavil_mbhc_micb_en_status(struct wcd_mbhc *mbhc, int micb_num)
|
||||
u8 val;
|
||||
|
||||
if (micb_num == MIC_BIAS_2) {
|
||||
val = (snd_soc_read(mbhc->codec, WCD934X_ANA_MICB2) >> 6);
|
||||
val = (snd_soc_component_read32(
|
||||
mbhc->component, WCD934X_ANA_MICB2) >> 6);
|
||||
if (val == 0x01)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool tavil_mbhc_hph_pa_on_status(struct snd_soc_codec *codec)
|
||||
static bool tavil_mbhc_hph_pa_on_status(struct snd_soc_component *component)
|
||||
{
|
||||
return (snd_soc_read(codec, WCD934X_ANA_HPH) & 0xC0) ? true : false;
|
||||
return (snd_soc_component_read32(component, WCD934X_ANA_HPH) & 0xC0) ?
|
||||
true : false;
|
||||
}
|
||||
|
||||
static void tavil_mbhc_hph_l_pull_up_control(
|
||||
struct snd_soc_codec *codec,
|
||||
struct snd_soc_component *component,
|
||||
enum mbhc_hs_pullup_iref pull_up_cur)
|
||||
{
|
||||
/* Default pull up current to 2uA */
|
||||
@@ -364,14 +369,15 @@ static void tavil_mbhc_hph_l_pull_up_control(
|
||||
pull_up_cur == I_DEFAULT)
|
||||
pull_up_cur = I_2P0_UA;
|
||||
|
||||
dev_dbg(codec->dev, "%s: HS pull up current:%d\n",
|
||||
dev_dbg(component->dev, "%s: HS pull up current:%d\n",
|
||||
__func__, pull_up_cur);
|
||||
|
||||
snd_soc_update_bits(codec, WCD934X_MBHC_NEW_PLUG_DETECT_CTL,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_MBHC_NEW_PLUG_DETECT_CTL,
|
||||
0xC0, pull_up_cur << 6);
|
||||
}
|
||||
|
||||
static int tavil_mbhc_request_micbias(struct snd_soc_codec *codec,
|
||||
static int tavil_mbhc_request_micbias(struct snd_soc_component *component,
|
||||
int micb_num, int req)
|
||||
{
|
||||
int ret;
|
||||
@@ -381,32 +387,32 @@ static int tavil_mbhc_request_micbias(struct snd_soc_codec *codec,
|
||||
* is vote to enable mclk
|
||||
*/
|
||||
if (req == MICB_ENABLE)
|
||||
tavil_cdc_mclk_enable(codec, true);
|
||||
tavil_cdc_mclk_enable(component, true);
|
||||
|
||||
ret = tavil_micbias_control(codec, micb_num, req, false);
|
||||
ret = tavil_micbias_control(component, micb_num, req, false);
|
||||
|
||||
/*
|
||||
* Release vote for mclk while requesting for
|
||||
* micbias disable
|
||||
*/
|
||||
if (req == MICB_DISABLE)
|
||||
tavil_cdc_mclk_enable(codec, false);
|
||||
tavil_cdc_mclk_enable(component, false);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void tavil_mbhc_micb_ramp_control(struct snd_soc_codec *codec,
|
||||
static void tavil_mbhc_micb_ramp_control(struct snd_soc_component *component,
|
||||
bool enable)
|
||||
{
|
||||
if (enable) {
|
||||
snd_soc_update_bits(codec, WCD934X_ANA_MICB2_RAMP,
|
||||
snd_soc_component_update_bits(component, WCD934X_ANA_MICB2_RAMP,
|
||||
0x1C, 0x0C);
|
||||
snd_soc_update_bits(codec, WCD934X_ANA_MICB2_RAMP,
|
||||
snd_soc_component_update_bits(component, WCD934X_ANA_MICB2_RAMP,
|
||||
0x80, 0x80);
|
||||
} else {
|
||||
snd_soc_update_bits(codec, WCD934X_ANA_MICB2_RAMP,
|
||||
snd_soc_component_update_bits(component, WCD934X_ANA_MICB2_RAMP,
|
||||
0x80, 0x00);
|
||||
snd_soc_update_bits(codec, WCD934X_ANA_MICB2_RAMP,
|
||||
snd_soc_component_update_bits(component, WCD934X_ANA_MICB2_RAMP,
|
||||
0x1C, 0x00);
|
||||
}
|
||||
}
|
||||
@@ -416,26 +422,27 @@ static struct firmware_cal *tavil_get_hwdep_fw_cal(struct wcd_mbhc *mbhc,
|
||||
{
|
||||
struct wcd934x_mbhc *wcd934x_mbhc;
|
||||
struct firmware_cal *hwdep_cal;
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
|
||||
wcd934x_mbhc = container_of(mbhc, struct wcd934x_mbhc, wcd_mbhc);
|
||||
|
||||
if (!codec) {
|
||||
pr_err("%s: NULL codec pointer\n", __func__);
|
||||
if (!component) {
|
||||
pr_err("%s: NULL component pointer\n", __func__);
|
||||
return NULL;
|
||||
}
|
||||
hwdep_cal = wcdcal_get_fw_cal(wcd934x_mbhc->fw_data, type);
|
||||
if (!hwdep_cal)
|
||||
dev_err(codec->dev, "%s: cal not sent by %d\n",
|
||||
dev_err(component->dev, "%s: cal not sent by %d\n",
|
||||
__func__, type);
|
||||
|
||||
return hwdep_cal;
|
||||
}
|
||||
|
||||
static int tavil_mbhc_micb_ctrl_threshold_mic(struct snd_soc_codec *codec,
|
||||
static int tavil_mbhc_micb_ctrl_threshold_mic(
|
||||
struct snd_soc_component *component,
|
||||
int micb_num, bool req_en)
|
||||
{
|
||||
struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
|
||||
struct wcd9xxx_pdata *pdata = dev_get_platdata(component->dev->parent);
|
||||
int rc, micb_mv;
|
||||
|
||||
if (micb_num != MIC_BIAS_2)
|
||||
@@ -451,7 +458,7 @@ static int tavil_mbhc_micb_ctrl_threshold_mic(struct snd_soc_codec *codec,
|
||||
|
||||
micb_mv = req_en ? WCD_MBHC_THR_HS_MICB_MV : pdata->micbias.micb2_mv;
|
||||
|
||||
rc = tavil_mbhc_micb_adjust_voltage(codec, micb_mv, MIC_BIAS_2);
|
||||
rc = tavil_mbhc_micb_adjust_voltage(component, micb_mv, MIC_BIAS_2);
|
||||
|
||||
return rc;
|
||||
}
|
||||
@@ -512,25 +519,25 @@ ramp_down:
|
||||
}
|
||||
}
|
||||
|
||||
static void tavil_mbhc_zdet_ramp(struct snd_soc_codec *codec,
|
||||
static void tavil_mbhc_zdet_ramp(struct snd_soc_component *component,
|
||||
struct tavil_mbhc_zdet_param *zdet_param,
|
||||
int32_t *zl, int32_t *zr, s16 *d1_a)
|
||||
{
|
||||
struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
|
||||
struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent);
|
||||
int32_t zdet = 0;
|
||||
|
||||
snd_soc_update_bits(codec, WCD934X_MBHC_NEW_ZDET_ANA_CTL, 0x70,
|
||||
zdet_param->ldo_ctl << 4);
|
||||
snd_soc_update_bits(codec, WCD934X_ANA_MBHC_BTN5, 0xFC,
|
||||
snd_soc_component_update_bits(component, WCD934X_MBHC_NEW_ZDET_ANA_CTL,
|
||||
0x70, zdet_param->ldo_ctl << 4);
|
||||
snd_soc_component_update_bits(component, WCD934X_ANA_MBHC_BTN5, 0xFC,
|
||||
zdet_param->btn5);
|
||||
snd_soc_update_bits(codec, WCD934X_ANA_MBHC_BTN6, 0xFC,
|
||||
snd_soc_component_update_bits(component, WCD934X_ANA_MBHC_BTN6, 0xFC,
|
||||
zdet_param->btn6);
|
||||
snd_soc_update_bits(codec, WCD934X_ANA_MBHC_BTN7, 0xFC,
|
||||
snd_soc_component_update_bits(component, WCD934X_ANA_MBHC_BTN7, 0xFC,
|
||||
zdet_param->btn7);
|
||||
snd_soc_update_bits(codec, WCD934X_MBHC_NEW_ZDET_ANA_CTL, 0x0F,
|
||||
zdet_param->noff);
|
||||
snd_soc_update_bits(codec, WCD934X_MBHC_NEW_ZDET_RAMP_CTL, 0x0F,
|
||||
zdet_param->nshift);
|
||||
snd_soc_component_update_bits(component, WCD934X_MBHC_NEW_ZDET_ANA_CTL,
|
||||
0x0F, zdet_param->noff);
|
||||
snd_soc_component_update_bits(component, WCD934X_MBHC_NEW_ZDET_RAMP_CTL,
|
||||
0x0F, zdet_param->nshift);
|
||||
|
||||
if (!zl)
|
||||
goto z_right;
|
||||
@@ -560,17 +567,17 @@ z_right:
|
||||
*zr = zdet;
|
||||
}
|
||||
|
||||
static inline void tavil_wcd_mbhc_qfuse_cal(struct snd_soc_codec *codec,
|
||||
static inline void tavil_wcd_mbhc_qfuse_cal(struct snd_soc_component *component,
|
||||
int32_t *z_val, int flag_l_r)
|
||||
{
|
||||
s16 q1;
|
||||
int q1_cal;
|
||||
|
||||
if (*z_val < (TAVIL_ZDET_VAL_400/1000))
|
||||
q1 = snd_soc_read(codec,
|
||||
q1 = snd_soc_component_read32(component,
|
||||
WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT1 + (2 * flag_l_r));
|
||||
else
|
||||
q1 = snd_soc_read(codec,
|
||||
q1 = snd_soc_component_read32(component,
|
||||
WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT2 + (2 * flag_l_r));
|
||||
if (q1 & 0x80)
|
||||
q1_cal = (10000 - ((q1 & 0x7F) * 25));
|
||||
@@ -583,8 +590,8 @@ static inline void tavil_wcd_mbhc_qfuse_cal(struct snd_soc_codec *codec,
|
||||
static void tavil_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl,
|
||||
uint32_t *zr)
|
||||
{
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent);
|
||||
s16 reg0, reg1, reg2, reg3, reg4;
|
||||
int32_t z1L, z1R, z1Ls;
|
||||
int zMono, z_diff1, z_diff2;
|
||||
@@ -606,13 +613,15 @@ static void tavil_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl,
|
||||
|
||||
WCD_MBHC_RSC_ASSERT_LOCKED(mbhc);
|
||||
|
||||
reg0 = snd_soc_read(codec, WCD934X_ANA_MBHC_BTN5);
|
||||
reg1 = snd_soc_read(codec, WCD934X_ANA_MBHC_BTN6);
|
||||
reg2 = snd_soc_read(codec, WCD934X_ANA_MBHC_BTN7);
|
||||
reg3 = snd_soc_read(codec, WCD934X_MBHC_CTL_CLK);
|
||||
reg4 = snd_soc_read(codec, WCD934X_MBHC_NEW_ZDET_ANA_CTL);
|
||||
reg0 = snd_soc_component_read32(component, WCD934X_ANA_MBHC_BTN5);
|
||||
reg1 = snd_soc_component_read32(component, WCD934X_ANA_MBHC_BTN6);
|
||||
reg2 = snd_soc_component_read32(component, WCD934X_ANA_MBHC_BTN7);
|
||||
reg3 = snd_soc_component_read32(component, WCD934X_MBHC_CTL_CLK);
|
||||
reg4 = snd_soc_component_read32(component,
|
||||
WCD934X_MBHC_NEW_ZDET_ANA_CTL);
|
||||
|
||||
if (snd_soc_read(codec, WCD934X_ANA_MBHC_ELECT) & 0x80) {
|
||||
if (snd_soc_component_read32(component, WCD934X_ANA_MBHC_ELECT) &
|
||||
0x80) {
|
||||
is_fsm_disable = true;
|
||||
regmap_update_bits(wcd9xxx->regmap,
|
||||
WCD934X_ANA_MBHC_ELECT, 0x80, 0x00);
|
||||
@@ -630,7 +639,7 @@ static void tavil_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl,
|
||||
/* First get impedance on Left */
|
||||
d1 = d1_a[1];
|
||||
zdet_param_ptr = &zdet_param[1];
|
||||
tavil_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1);
|
||||
tavil_mbhc_zdet_ramp(component, zdet_param_ptr, &z1L, NULL, d1);
|
||||
|
||||
if (!TAVIL_MBHC_IS_SECOND_RAMP_REQUIRED(z1L))
|
||||
goto left_ch_impedance;
|
||||
@@ -646,7 +655,7 @@ static void tavil_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl,
|
||||
zdet_param_ptr = &zdet_param[3];
|
||||
d1 = d1_a[3];
|
||||
}
|
||||
tavil_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1);
|
||||
tavil_mbhc_zdet_ramp(component, zdet_param_ptr, &z1L, NULL, d1);
|
||||
|
||||
left_ch_impedance:
|
||||
if ((z1L == TAVIL_ZDET_FLOATING_IMPEDANCE) ||
|
||||
@@ -656,13 +665,13 @@ left_ch_impedance:
|
||||
d1 = d1_a[1];
|
||||
} else {
|
||||
*zl = z1L/1000;
|
||||
tavil_wcd_mbhc_qfuse_cal(codec, zl, 0);
|
||||
tavil_wcd_mbhc_qfuse_cal(component, zl, 0);
|
||||
}
|
||||
dev_dbg(codec->dev, "%s: impedance on HPH_L = %d(ohms)\n",
|
||||
dev_dbg(component->dev, "%s: impedance on HPH_L = %d(ohms)\n",
|
||||
__func__, *zl);
|
||||
|
||||
/* Start of right impedance ramp and calculation */
|
||||
tavil_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1);
|
||||
tavil_mbhc_zdet_ramp(component, zdet_param_ptr, NULL, &z1R, d1);
|
||||
if (TAVIL_MBHC_IS_SECOND_RAMP_REQUIRED(z1R)) {
|
||||
if (((z1R > TAVIL_ZDET_VAL_1200) &&
|
||||
(zdet_param_ptr->noff == 0x6)) ||
|
||||
@@ -680,7 +689,7 @@ left_ch_impedance:
|
||||
zdet_param_ptr = &zdet_param[3];
|
||||
d1 = d1_a[3];
|
||||
}
|
||||
tavil_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1);
|
||||
tavil_mbhc_zdet_ramp(component, zdet_param_ptr, NULL, &z1R, d1);
|
||||
}
|
||||
right_ch_impedance:
|
||||
if ((z1R == TAVIL_ZDET_FLOATING_IMPEDANCE) ||
|
||||
@@ -688,15 +697,15 @@ right_ch_impedance:
|
||||
*zr = TAVIL_ZDET_FLOATING_IMPEDANCE;
|
||||
} else {
|
||||
*zr = z1R/1000;
|
||||
tavil_wcd_mbhc_qfuse_cal(codec, zr, 1);
|
||||
tavil_wcd_mbhc_qfuse_cal(component, zr, 1);
|
||||
}
|
||||
dev_dbg(codec->dev, "%s: impedance on HPH_R = %d(ohms)\n",
|
||||
dev_dbg(component->dev, "%s: impedance on HPH_R = %d(ohms)\n",
|
||||
__func__, *zr);
|
||||
|
||||
/* Mono/stereo detection */
|
||||
if ((*zl == TAVIL_ZDET_FLOATING_IMPEDANCE) &&
|
||||
(*zr == TAVIL_ZDET_FLOATING_IMPEDANCE)) {
|
||||
dev_dbg(codec->dev,
|
||||
dev_dbg(component->dev,
|
||||
"%s: plug type is invalid or extension cable\n",
|
||||
__func__);
|
||||
goto zdet_complete;
|
||||
@@ -705,40 +714,46 @@ right_ch_impedance:
|
||||
(*zr == TAVIL_ZDET_FLOATING_IMPEDANCE) ||
|
||||
((*zl < WCD_MONO_HS_MIN_THR) && (*zr > WCD_MONO_HS_MIN_THR)) ||
|
||||
((*zl > WCD_MONO_HS_MIN_THR) && (*zr < WCD_MONO_HS_MIN_THR))) {
|
||||
dev_dbg(codec->dev,
|
||||
dev_dbg(component->dev,
|
||||
"%s: Mono plug type with one ch floating or shorted to GND\n",
|
||||
__func__);
|
||||
mbhc->hph_type = WCD_MBHC_HPH_MONO;
|
||||
goto zdet_complete;
|
||||
}
|
||||
snd_soc_update_bits(codec, WCD934X_HPH_R_ATEST, 0x02, 0x02);
|
||||
snd_soc_update_bits(codec, WCD934X_HPH_PA_CTL2, 0x40, 0x01);
|
||||
snd_soc_component_update_bits(component, WCD934X_HPH_R_ATEST,
|
||||
0x02, 0x02);
|
||||
snd_soc_component_update_bits(component, WCD934X_HPH_PA_CTL2,
|
||||
0x40, 0x01);
|
||||
if (*zl < (TAVIL_ZDET_VAL_32/1000))
|
||||
tavil_mbhc_zdet_ramp(codec, &zdet_param[0], &z1Ls, NULL, d1);
|
||||
tavil_mbhc_zdet_ramp(component, &zdet_param[0],
|
||||
&z1Ls, NULL, d1);
|
||||
else
|
||||
tavil_mbhc_zdet_ramp(codec, &zdet_param[1], &z1Ls, NULL, d1);
|
||||
snd_soc_update_bits(codec, WCD934X_HPH_PA_CTL2, 0x40, 0x00);
|
||||
snd_soc_update_bits(codec, WCD934X_HPH_R_ATEST, 0x02, 0x00);
|
||||
tavil_mbhc_zdet_ramp(component, &zdet_param[1],
|
||||
&z1Ls, NULL, d1);
|
||||
snd_soc_component_update_bits(component, WCD934X_HPH_PA_CTL2,
|
||||
0x40, 0x00);
|
||||
snd_soc_component_update_bits(component, WCD934X_HPH_R_ATEST,
|
||||
0x02, 0x00);
|
||||
z1Ls /= 1000;
|
||||
tavil_wcd_mbhc_qfuse_cal(codec, &z1Ls, 0);
|
||||
tavil_wcd_mbhc_qfuse_cal(component, &z1Ls, 0);
|
||||
/* Parallel of left Z and 9 ohm pull down resistor */
|
||||
zMono = ((*zl) * 9) / ((*zl) + 9);
|
||||
z_diff1 = (z1Ls > zMono) ? (z1Ls - zMono) : (zMono - z1Ls);
|
||||
z_diff2 = ((*zl) > z1Ls) ? ((*zl) - z1Ls) : (z1Ls - (*zl));
|
||||
if ((z_diff1 * (*zl + z1Ls)) > (z_diff2 * (z1Ls + zMono))) {
|
||||
dev_dbg(codec->dev, "%s: stereo plug type detected\n",
|
||||
dev_dbg(component->dev, "%s: stereo plug type detected\n",
|
||||
__func__);
|
||||
mbhc->hph_type = WCD_MBHC_HPH_STEREO;
|
||||
} else {
|
||||
dev_dbg(codec->dev, "%s: MONO plug type detected\n",
|
||||
dev_dbg(component->dev, "%s: MONO plug type detected\n",
|
||||
__func__);
|
||||
mbhc->hph_type = WCD_MBHC_HPH_MONO;
|
||||
}
|
||||
|
||||
zdet_complete:
|
||||
snd_soc_write(codec, WCD934X_ANA_MBHC_BTN5, reg0);
|
||||
snd_soc_write(codec, WCD934X_ANA_MBHC_BTN6, reg1);
|
||||
snd_soc_write(codec, WCD934X_ANA_MBHC_BTN7, reg2);
|
||||
snd_soc_component_write(component, WCD934X_ANA_MBHC_BTN5, reg0);
|
||||
snd_soc_component_write(component, WCD934X_ANA_MBHC_BTN6, reg1);
|
||||
snd_soc_component_write(component, WCD934X_ANA_MBHC_BTN7, reg2);
|
||||
/* Turn on 100k pull down on HPHL */
|
||||
regmap_update_bits(wcd9xxx->regmap,
|
||||
WCD934X_ANA_MBHC_MECH, 0x01, 0x01);
|
||||
@@ -748,96 +763,99 @@ zdet_complete:
|
||||
regmap_update_bits(wcd9xxx->regmap,
|
||||
WCD934X_ANA_MBHC_MECH, 0x80, 0x80);
|
||||
|
||||
snd_soc_write(codec, WCD934X_MBHC_NEW_ZDET_ANA_CTL, reg4);
|
||||
snd_soc_write(codec, WCD934X_MBHC_CTL_CLK, reg3);
|
||||
snd_soc_component_write(component, WCD934X_MBHC_NEW_ZDET_ANA_CTL, reg4);
|
||||
snd_soc_component_write(component, WCD934X_MBHC_CTL_CLK, reg3);
|
||||
if (is_fsm_disable)
|
||||
regmap_update_bits(wcd9xxx->regmap,
|
||||
WCD934X_ANA_MBHC_ELECT, 0x80, 0x80);
|
||||
}
|
||||
|
||||
static void tavil_mbhc_gnd_det_ctrl(struct snd_soc_codec *codec, bool enable)
|
||||
static void tavil_mbhc_gnd_det_ctrl(struct snd_soc_component *component,
|
||||
bool enable)
|
||||
{
|
||||
if (enable) {
|
||||
snd_soc_update_bits(codec, WCD934X_ANA_MBHC_MECH,
|
||||
snd_soc_component_update_bits(component, WCD934X_ANA_MBHC_MECH,
|
||||
0x02, 0x02);
|
||||
snd_soc_update_bits(codec, WCD934X_ANA_MBHC_MECH,
|
||||
snd_soc_component_update_bits(component, WCD934X_ANA_MBHC_MECH,
|
||||
0x40, 0x40);
|
||||
} else {
|
||||
snd_soc_update_bits(codec, WCD934X_ANA_MBHC_MECH,
|
||||
snd_soc_component_update_bits(component, WCD934X_ANA_MBHC_MECH,
|
||||
0x40, 0x00);
|
||||
snd_soc_update_bits(codec, WCD934X_ANA_MBHC_MECH,
|
||||
snd_soc_component_update_bits(component, WCD934X_ANA_MBHC_MECH,
|
||||
0x02, 0x00);
|
||||
}
|
||||
}
|
||||
|
||||
static void tavil_mbhc_hph_pull_down_ctrl(struct snd_soc_codec *codec,
|
||||
static void tavil_mbhc_hph_pull_down_ctrl(struct snd_soc_component *component,
|
||||
bool enable)
|
||||
{
|
||||
if (enable) {
|
||||
snd_soc_update_bits(codec, WCD934X_HPH_PA_CTL2,
|
||||
snd_soc_component_update_bits(component, WCD934X_HPH_PA_CTL2,
|
||||
0x40, 0x40);
|
||||
snd_soc_update_bits(codec, WCD934X_HPH_PA_CTL2,
|
||||
snd_soc_component_update_bits(component, WCD934X_HPH_PA_CTL2,
|
||||
0x10, 0x10);
|
||||
} else {
|
||||
snd_soc_update_bits(codec, WCD934X_HPH_PA_CTL2,
|
||||
snd_soc_component_update_bits(component, WCD934X_HPH_PA_CTL2,
|
||||
0x40, 0x00);
|
||||
snd_soc_update_bits(codec, WCD934X_HPH_PA_CTL2,
|
||||
snd_soc_component_update_bits(component, WCD934X_HPH_PA_CTL2,
|
||||
0x10, 0x00);
|
||||
}
|
||||
}
|
||||
static void tavil_mbhc_moisture_config(struct wcd_mbhc *mbhc)
|
||||
{
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
|
||||
if ((mbhc->moist_rref == R_OFF) ||
|
||||
(mbhc->mbhc_cfg->enable_usbc_analog)) {
|
||||
snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_2,
|
||||
snd_soc_component_update_bits(component, WCD934X_MBHC_NEW_CTL_2,
|
||||
0x0C, R_OFF << 2);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Donot enable moisture detection if jack type is NC */
|
||||
if (!mbhc->hphl_swh) {
|
||||
dev_dbg(codec->dev, "%s: disable moisture detection for NC\n",
|
||||
dev_dbg(component->dev, "%s: disable moisture detection for NC\n",
|
||||
__func__);
|
||||
snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_2,
|
||||
snd_soc_component_update_bits(component, WCD934X_MBHC_NEW_CTL_2,
|
||||
0x0C, R_OFF << 2);
|
||||
return;
|
||||
}
|
||||
|
||||
snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_2,
|
||||
snd_soc_component_update_bits(component, WCD934X_MBHC_NEW_CTL_2,
|
||||
0x0C, mbhc->moist_rref << 2);
|
||||
}
|
||||
|
||||
static bool tavil_hph_register_recovery(struct wcd_mbhc *mbhc)
|
||||
{
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(codec);
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(component);
|
||||
|
||||
if (!wcd934x_mbhc)
|
||||
return false;
|
||||
|
||||
wcd934x_mbhc->is_hph_recover = false;
|
||||
snd_soc_dapm_force_enable_pin(snd_soc_codec_get_dapm(codec),
|
||||
snd_soc_dapm_force_enable_pin(snd_soc_component_get_dapm(component),
|
||||
"RESET_HPH_REGISTERS");
|
||||
snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
|
||||
snd_soc_dapm_sync(snd_soc_component_get_dapm(component));
|
||||
|
||||
snd_soc_dapm_disable_pin(snd_soc_codec_get_dapm(codec),
|
||||
snd_soc_dapm_disable_pin(snd_soc_component_get_dapm(component),
|
||||
"RESET_HPH_REGISTERS");
|
||||
snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec));
|
||||
snd_soc_dapm_sync(snd_soc_component_get_dapm(component));
|
||||
|
||||
return wcd934x_mbhc->is_hph_recover;
|
||||
}
|
||||
|
||||
static void tavil_update_anc_state(struct snd_soc_codec *codec, bool enable,
|
||||
int anc_num)
|
||||
static void tavil_update_anc_state(struct snd_soc_component *component,
|
||||
bool enable, int anc_num)
|
||||
{
|
||||
if (enable)
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_RX1_RX_PATH_CFG0 +
|
||||
(20 * anc_num), 0x10, 0x10);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_RX1_RX_PATH_CFG0 + (20 * anc_num),
|
||||
0x10, 0x10);
|
||||
else
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_RX1_RX_PATH_CFG0 +
|
||||
(20 * anc_num), 0x10, 0x00);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_RX1_RX_PATH_CFG0 + (20 * anc_num),
|
||||
0x10, 0x00);
|
||||
}
|
||||
|
||||
static bool tavil_is_anc_on(struct wcd_mbhc *mbhc)
|
||||
@@ -846,9 +864,11 @@ static bool tavil_is_anc_on(struct wcd_mbhc *mbhc)
|
||||
u16 ancl, ancr;
|
||||
|
||||
ancl =
|
||||
(snd_soc_read(mbhc->codec, WCD934X_CDC_RX1_RX_PATH_CFG0)) & 0x10;
|
||||
(snd_soc_component_read32(
|
||||
mbhc->component, WCD934X_CDC_RX1_RX_PATH_CFG0)) & 0x10;
|
||||
ancr =
|
||||
(snd_soc_read(mbhc->codec, WCD934X_CDC_RX2_RX_PATH_CFG0)) & 0x10;
|
||||
(snd_soc_component_read32(
|
||||
mbhc->component, WCD934X_CDC_RX2_RX_PATH_CFG0)) & 0x10;
|
||||
|
||||
anc_on = !!(ancl | ancr);
|
||||
|
||||
@@ -883,11 +903,11 @@ static const struct wcd_mbhc_cb mbhc_cb = {
|
||||
};
|
||||
|
||||
static struct regulator *tavil_codec_find_ondemand_regulator(
|
||||
struct snd_soc_codec *codec, const char *name)
|
||||
struct snd_soc_component *component, const char *name)
|
||||
{
|
||||
int i;
|
||||
struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
|
||||
struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent);
|
||||
struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent);
|
||||
struct wcd9xxx_pdata *pdata = dev_get_platdata(component->dev->parent);
|
||||
|
||||
for (i = 0; i < wcd9xxx->num_of_supplies; ++i) {
|
||||
if (pdata->regulator[i].ondemand &&
|
||||
@@ -896,7 +916,7 @@ static struct regulator *tavil_codec_find_ondemand_regulator(
|
||||
return wcd9xxx->supplies[i].consumer;
|
||||
}
|
||||
|
||||
dev_dbg(codec->dev, "Warning: regulator not found:%s\n",
|
||||
dev_dbg(component->dev, "Warning: regulator not found:%s\n",
|
||||
name);
|
||||
return NULL;
|
||||
}
|
||||
@@ -904,19 +924,22 @@ static struct regulator *tavil_codec_find_ondemand_regulator(
|
||||
static int tavil_get_hph_type(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(codec);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(component);
|
||||
struct wcd_mbhc *mbhc;
|
||||
|
||||
if (!wcd934x_mbhc) {
|
||||
dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__);
|
||||
dev_err(component->dev, "%s: mbhc not initialized!\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mbhc = &wcd934x_mbhc->wcd_mbhc;
|
||||
|
||||
ucontrol->value.integer.value[0] = (u32) mbhc->hph_type;
|
||||
dev_dbg(codec->dev, "%s: hph_type = %u\n", __func__, mbhc->hph_type);
|
||||
dev_dbg(component->dev, "%s: hph_type = %u\n", __func__,
|
||||
mbhc->hph_type);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -927,18 +950,21 @@ static int tavil_hph_impedance_get(struct snd_kcontrol *kcontrol,
|
||||
uint32_t zl, zr;
|
||||
bool hphr;
|
||||
struct soc_multi_mixer_control *mc;
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(codec);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(component);
|
||||
|
||||
if (!wcd934x_mbhc) {
|
||||
dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__);
|
||||
dev_err(component->dev, "%s: mbhc not initialized!\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mc = (struct soc_multi_mixer_control *)(kcontrol->private_value);
|
||||
hphr = mc->shift;
|
||||
wcd_mbhc_get_impedance(&wcd934x_mbhc->wcd_mbhc, &zl, &zr);
|
||||
dev_dbg(codec->dev, "%s: zl=%u(ohms), zr=%u(ohms)\n", __func__, zl, zr);
|
||||
dev_dbg(component->dev, "%s: zl=%u(ohms), zr=%u(ohms)\n", __func__,
|
||||
zl, zr);
|
||||
ucontrol->value.integer.value[0] = hphr ? zr : zl;
|
||||
|
||||
return 0;
|
||||
@@ -981,17 +1007,18 @@ EXPORT_SYMBOL(tavil_mbhc_get_impedance);
|
||||
|
||||
/*
|
||||
* tavil_mbhc_hs_detect: starts mbhc insertion/removal functionality
|
||||
* @codec: handle to snd_soc_codec *
|
||||
* @component: handle to snd_soc_component *
|
||||
* @mbhc_cfg: handle to mbhc configuration structure
|
||||
* return 0 if mbhc_start is success or error code in case of failure
|
||||
*/
|
||||
int tavil_mbhc_hs_detect(struct snd_soc_codec *codec,
|
||||
int tavil_mbhc_hs_detect(struct snd_soc_component *component,
|
||||
struct wcd_mbhc_config *mbhc_cfg)
|
||||
{
|
||||
struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(codec);
|
||||
struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(component);
|
||||
|
||||
if (!wcd934x_mbhc) {
|
||||
dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__);
|
||||
dev_err(component->dev, "%s: mbhc not initialized!\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -1001,14 +1028,15 @@ EXPORT_SYMBOL(tavil_mbhc_hs_detect);
|
||||
|
||||
/*
|
||||
* tavil_mbhc_hs_detect_exit: stop mbhc insertion/removal functionality
|
||||
* @codec: handle to snd_soc_codec *
|
||||
* @component: handle to snd_soc_component *
|
||||
*/
|
||||
void tavil_mbhc_hs_detect_exit(struct snd_soc_codec *codec)
|
||||
void tavil_mbhc_hs_detect_exit(struct snd_soc_component *component)
|
||||
{
|
||||
struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(codec);
|
||||
struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(component);
|
||||
|
||||
if (!wcd934x_mbhc) {
|
||||
dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__);
|
||||
dev_err(component->dev, "%s: mbhc not initialized!\n",
|
||||
__func__);
|
||||
return;
|
||||
}
|
||||
wcd_mbhc_stop(&wcd934x_mbhc->wcd_mbhc);
|
||||
@@ -1018,17 +1046,17 @@ EXPORT_SYMBOL(tavil_mbhc_hs_detect_exit);
|
||||
/*
|
||||
* tavil_mbhc_post_ssr_init: initialize mbhc for tavil post subsystem restart
|
||||
* @mbhc: poniter to wcd934x_mbhc structure
|
||||
* @codec: handle to snd_soc_codec *
|
||||
* @component: handle to snd_soc_component *
|
||||
*
|
||||
* return 0 if mbhc_init is success or error code in case of failure
|
||||
*/
|
||||
int tavil_mbhc_post_ssr_init(struct wcd934x_mbhc *mbhc,
|
||||
struct snd_soc_codec *codec)
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
int ret;
|
||||
struct wcd_mbhc *wcd_mbhc;
|
||||
|
||||
if (!mbhc || !codec)
|
||||
if (!mbhc || !component)
|
||||
return -EINVAL;
|
||||
|
||||
wcd_mbhc = &mbhc->wcd_mbhc;
|
||||
@@ -1037,18 +1065,20 @@ int tavil_mbhc_post_ssr_init(struct wcd934x_mbhc *mbhc,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
tavil_mbhc_hs_detect_exit(codec);
|
||||
tavil_mbhc_hs_detect_exit(component);
|
||||
wcd_mbhc_deinit(wcd_mbhc);
|
||||
ret = wcd_mbhc_init(wcd_mbhc, codec, &mbhc_cb, &intr_ids,
|
||||
ret = wcd_mbhc_init(wcd_mbhc, component, &mbhc_cb, &intr_ids,
|
||||
wcd_mbhc_registers, TAVIL_ZDET_SUPPORTED);
|
||||
if (ret) {
|
||||
dev_err(codec->dev, "%s: mbhc initialization failed\n",
|
||||
dev_err(component->dev, "%s: mbhc initialization failed\n",
|
||||
__func__);
|
||||
goto done;
|
||||
}
|
||||
if (wcd_mbhc->mbhc_detection_logic == WCD_DETECTION_LEGACY) {
|
||||
snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_1, 0x04, 0x04);
|
||||
snd_soc_update_bits(codec, WCD934X_MBHC_CTL_BCS, 0x01, 0x01);
|
||||
snd_soc_component_update_bits(component, WCD934X_MBHC_NEW_CTL_1,
|
||||
0x04, 0x04);
|
||||
snd_soc_component_update_bits(component, WCD934X_MBHC_CTL_BCS,
|
||||
0x01, 0x01);
|
||||
}
|
||||
|
||||
done:
|
||||
@@ -1059,12 +1089,13 @@ EXPORT_SYMBOL(tavil_mbhc_post_ssr_init);
|
||||
/*
|
||||
* tavil_mbhc_init: initialize mbhc for tavil
|
||||
* @mbhc: poniter to wcd934x_mbhc struct pointer to store the configs
|
||||
* @codec: handle to snd_soc_codec *
|
||||
* @component: handle to snd_soc_component *
|
||||
* @fw_data: handle to firmware data
|
||||
*
|
||||
* return 0 if mbhc_init is success or error code in case of failure
|
||||
*/
|
||||
int tavil_mbhc_init(struct wcd934x_mbhc **mbhc, struct snd_soc_codec *codec,
|
||||
int tavil_mbhc_init(struct wcd934x_mbhc **mbhc,
|
||||
struct snd_soc_component *component,
|
||||
struct fw_info *fw_data)
|
||||
{
|
||||
struct regulator *supply;
|
||||
@@ -1072,12 +1103,12 @@ int tavil_mbhc_init(struct wcd934x_mbhc **mbhc, struct snd_soc_codec *codec,
|
||||
struct wcd_mbhc *wcd_mbhc;
|
||||
int ret;
|
||||
|
||||
wcd934x_mbhc = devm_kzalloc(codec->dev, sizeof(struct wcd934x_mbhc),
|
||||
wcd934x_mbhc = devm_kzalloc(component->dev, sizeof(struct wcd934x_mbhc),
|
||||
GFP_KERNEL);
|
||||
if (!wcd934x_mbhc)
|
||||
return -ENOMEM;
|
||||
|
||||
wcd934x_mbhc->wcd9xxx = dev_get_drvdata(codec->dev->parent);
|
||||
wcd934x_mbhc->wcd9xxx = dev_get_drvdata(component->dev->parent);
|
||||
wcd934x_mbhc->fw_data = fw_data;
|
||||
BLOCKING_INIT_NOTIFIER_HEAD(&wcd934x_mbhc->notifier);
|
||||
wcd_mbhc = &wcd934x_mbhc->wcd_mbhc;
|
||||
@@ -1091,16 +1122,16 @@ int tavil_mbhc_init(struct wcd934x_mbhc **mbhc, struct snd_soc_codec *codec,
|
||||
/* Setting default mbhc detection logic to ADC for Tavil */
|
||||
wcd_mbhc->mbhc_detection_logic = WCD_DETECTION_ADC;
|
||||
|
||||
ret = wcd_mbhc_init(wcd_mbhc, codec, &mbhc_cb,
|
||||
ret = wcd_mbhc_init(wcd_mbhc, component, &mbhc_cb,
|
||||
&intr_ids, wcd_mbhc_registers,
|
||||
TAVIL_ZDET_SUPPORTED);
|
||||
if (ret) {
|
||||
dev_err(codec->dev, "%s: mbhc initialization failed\n",
|
||||
dev_err(component->dev, "%s: mbhc initialization failed\n",
|
||||
__func__);
|
||||
goto err;
|
||||
}
|
||||
|
||||
supply = tavil_codec_find_ondemand_regulator(codec,
|
||||
supply = tavil_codec_find_ondemand_regulator(component,
|
||||
on_demand_supply_name[WCD934X_ON_DEMAND_MICBIAS]);
|
||||
if (supply) {
|
||||
wcd934x_mbhc->on_demand_list[
|
||||
@@ -1112,34 +1143,36 @@ int tavil_mbhc_init(struct wcd934x_mbhc **mbhc, struct snd_soc_codec *codec,
|
||||
}
|
||||
|
||||
(*mbhc) = wcd934x_mbhc;
|
||||
snd_soc_add_codec_controls(codec, impedance_detect_controls,
|
||||
snd_soc_add_component_controls(component, impedance_detect_controls,
|
||||
ARRAY_SIZE(impedance_detect_controls));
|
||||
snd_soc_add_codec_controls(codec, hph_type_detect_controls,
|
||||
snd_soc_add_component_controls(component, hph_type_detect_controls,
|
||||
ARRAY_SIZE(hph_type_detect_controls));
|
||||
|
||||
if (wcd_mbhc->mbhc_detection_logic == WCD_DETECTION_LEGACY) {
|
||||
snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_1, 0x04, 0x04);
|
||||
snd_soc_update_bits(codec, WCD934X_MBHC_CTL_BCS, 0x01, 0x01);
|
||||
snd_soc_component_update_bits(component, WCD934X_MBHC_NEW_CTL_1,
|
||||
0x04, 0x04);
|
||||
snd_soc_component_update_bits(component, WCD934X_MBHC_CTL_BCS,
|
||||
0x01, 0x01);
|
||||
}
|
||||
|
||||
return 0;
|
||||
err:
|
||||
devm_kfree(codec->dev, wcd934x_mbhc);
|
||||
devm_kfree(component->dev, wcd934x_mbhc);
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(tavil_mbhc_init);
|
||||
|
||||
/*
|
||||
* tavil_mbhc_deinit: deinitialize mbhc for tavil
|
||||
* @codec: handle to snd_soc_codec *
|
||||
* @component: handle to snd_soc_component *
|
||||
*/
|
||||
void tavil_mbhc_deinit(struct snd_soc_codec *codec)
|
||||
void tavil_mbhc_deinit(struct snd_soc_component *component)
|
||||
{
|
||||
struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(codec);
|
||||
struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(component);
|
||||
|
||||
if (wcd934x_mbhc) {
|
||||
wcd_mbhc_deinit(&wcd934x_mbhc->wcd_mbhc);
|
||||
devm_kfree(codec->dev, wcd934x_mbhc);
|
||||
devm_kfree(component->dev, wcd934x_mbhc);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL(tavil_mbhc_deinit);
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
#ifndef __WCD934X_MBHC_H__
|
||||
#define __WCD934X_MBHC_H__
|
||||
@@ -29,36 +29,37 @@ struct wcd934x_mbhc {
|
||||
|
||||
#if IS_ENABLED(CONFIG_SND_SOC_WCD934X_MBHC)
|
||||
extern int tavil_mbhc_init(struct wcd934x_mbhc **mbhc,
|
||||
struct snd_soc_codec *codec,
|
||||
struct snd_soc_component *component,
|
||||
struct fw_info *fw_data);
|
||||
extern void tavil_mbhc_hs_detect_exit(struct snd_soc_codec *codec);
|
||||
extern int tavil_mbhc_hs_detect(struct snd_soc_codec *codec,
|
||||
extern void tavil_mbhc_hs_detect_exit(struct snd_soc_component *component);
|
||||
extern int tavil_mbhc_hs_detect(struct snd_soc_component *component,
|
||||
struct wcd_mbhc_config *mbhc_cfg);
|
||||
extern void tavil_mbhc_deinit(struct snd_soc_codec *codec);
|
||||
extern void tavil_mbhc_deinit(struct snd_soc_component *component);
|
||||
extern int tavil_mbhc_post_ssr_init(struct wcd934x_mbhc *mbhc,
|
||||
struct snd_soc_codec *codec);
|
||||
struct snd_soc_component *component);
|
||||
extern int tavil_mbhc_get_impedance(struct wcd934x_mbhc *wcd934x_mbhc,
|
||||
uint32_t *zl, uint32_t *zr);
|
||||
#else
|
||||
static inline int tavil_mbhc_init(struct wcd934x_mbhc **mbhc,
|
||||
struct snd_soc_codec *codec,
|
||||
struct snd_soc_component *component,
|
||||
struct fw_info *fw_data)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static inline void tavil_mbhc_hs_detect_exit(struct snd_soc_codec *codec)
|
||||
static inline void tavil_mbhc_hs_detect_exit(
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
}
|
||||
static inline int tavil_mbhc_hs_detect(struct snd_soc_codec *codec,
|
||||
static inline int tavil_mbhc_hs_detect(struct snd_soc_component *component,
|
||||
struct wcd_mbhc_config *mbhc_cfg)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static inline void tavil_mbhc_deinit(struct snd_soc_codec *codec)
|
||||
static inline void tavil_mbhc_deinit(struct snd_soc_component *component)
|
||||
{
|
||||
}
|
||||
static inline int tavil_mbhc_post_ssr_init(struct wcd934x_mbhc *mbhc,
|
||||
struct snd_soc_codec *codec)
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
文件差异内容过多而无法显示
加载差异
@@ -127,47 +127,54 @@ struct tavil_reg_mask_val {
|
||||
};
|
||||
|
||||
#if IS_ENABLED(CONFIG_SND_SOC_WCD934X)
|
||||
extern void *tavil_get_afe_config(struct snd_soc_codec *codec,
|
||||
extern void *tavil_get_afe_config(struct snd_soc_component *component,
|
||||
enum afe_config_type config_type);
|
||||
extern int tavil_cdc_mclk_enable(struct snd_soc_codec *codec, bool enable);
|
||||
extern int tavil_cdc_mclk_tx_enable(struct snd_soc_codec *codec, bool enable);
|
||||
extern int tavil_set_spkr_mode(struct snd_soc_codec *codec, int mode);
|
||||
extern int tavil_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset);
|
||||
extern int tavil_cdc_mclk_enable(struct snd_soc_component *component,
|
||||
bool enable);
|
||||
extern int tavil_cdc_mclk_tx_enable(struct snd_soc_component *component,
|
||||
bool enable);
|
||||
extern int tavil_set_spkr_mode(struct snd_soc_component *component, int mode);
|
||||
extern int tavil_set_spkr_gain_offset(struct snd_soc_component *component,
|
||||
int offset);
|
||||
extern struct wcd_dsp_cntl *tavil_get_wcd_dsp_cntl(struct device *dev);
|
||||
extern int wcd934x_get_micb_vout_ctl_val(u32 micb_mv);
|
||||
extern int tavil_micbias_control(struct snd_soc_codec *codec,
|
||||
extern int tavil_micbias_control(struct snd_soc_component *component,
|
||||
int micb_num,
|
||||
int req, bool is_dapm);
|
||||
extern int tavil_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec,
|
||||
extern int tavil_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
|
||||
int req_volt,
|
||||
int micb_num);
|
||||
extern struct wcd934x_mbhc *tavil_soc_get_mbhc(struct snd_soc_codec *codec);
|
||||
extern int tavil_codec_enable_interp_clk(struct snd_soc_codec *codec,
|
||||
extern struct wcd934x_mbhc *tavil_soc_get_mbhc(
|
||||
struct snd_soc_component *component);
|
||||
extern int tavil_codec_enable_interp_clk(struct snd_soc_component *component,
|
||||
int event, int intp_idx);
|
||||
extern struct tavil_dsd_config *tavil_get_dsd_config(
|
||||
struct snd_soc_codec *codec);
|
||||
struct snd_soc_component *component);
|
||||
extern int tavil_codec_info_create_codec_entry(
|
||||
struct snd_info_entry *codec_root,
|
||||
struct snd_soc_codec *codec);
|
||||
struct snd_soc_component *component);
|
||||
#else
|
||||
extern void *tavil_get_afe_config(struct snd_soc_codec *codec,
|
||||
extern void *tavil_get_afe_config(struct snd_soc_component *component,
|
||||
enum afe_config_type config_type)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
extern int tavil_cdc_mclk_enable(struct snd_soc_codec *codec, bool enable)
|
||||
extern int tavil_cdc_mclk_enable(struct snd_soc_component *component,
|
||||
bool enable)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
extern int tavil_cdc_mclk_tx_enable(struct snd_soc_codec *codec, bool enable)
|
||||
extern int tavil_cdc_mclk_tx_enable(struct snd_soc_component *component,
|
||||
bool enable)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
extern int tavil_set_spkr_mode(struct snd_soc_codec *codec, int mode)
|
||||
extern int tavil_set_spkr_mode(struct snd_soc_component *component, int mode)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
extern int tavil_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset)
|
||||
extern int tavil_set_spkr_gain_offset(struct snd_soc_component *component,
|
||||
int offset)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -179,35 +186,36 @@ extern int wcd934x_get_micb_vout_ctl_val(u32 micb_mv)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
extern int tavil_micbias_control(struct snd_soc_codec *codec,
|
||||
extern int tavil_micbias_control(struct snd_soc_component *component,
|
||||
int micb_num,
|
||||
int req, bool is_dapm)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
extern int tavil_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec,
|
||||
extern int tavil_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
|
||||
int req_volt,
|
||||
int micb_num)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
extern struct wcd934x_mbhc *tavil_soc_get_mbhc(struct snd_soc_codec *codec)
|
||||
extern struct wcd934x_mbhc *tavil_soc_get_mbhc(
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
extern int tavil_codec_enable_interp_clk(struct snd_soc_codec *codec,
|
||||
extern int tavil_codec_enable_interp_clk(struct snd_soc_component *component,
|
||||
int event, int intp_idx)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
extern struct tavil_dsd_config *tavil_get_dsd_config(
|
||||
struct snd_soc_codec *codec)
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
extern int tavil_codec_info_create_codec_entry(
|
||||
struct snd_info_entry *codec_root,
|
||||
struct snd_soc_codec *codec)
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@@ -30,7 +30,7 @@ struct wcd937x_priv {
|
||||
struct device *dev;
|
||||
|
||||
int variant;
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
struct device_node *rst_np;
|
||||
struct regmap *regmap;
|
||||
|
||||
@@ -160,10 +160,11 @@ enum {
|
||||
WCD937X_NUM_IRQS,
|
||||
};
|
||||
|
||||
extern struct wcd937x_mbhc *wcd937x_soc_get_mbhc(struct snd_soc_codec *codec);
|
||||
extern int wcd937x_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec,
|
||||
extern struct wcd937x_mbhc *wcd937x_soc_get_mbhc(
|
||||
struct snd_soc_component *component);
|
||||
extern int wcd937x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
|
||||
int volt, int micb_num);
|
||||
extern int wcd937x_get_micb_vout_ctl_val(u32 micb_mv);
|
||||
extern int wcd937x_micbias_control(struct snd_soc_codec *codec, int micb_num,
|
||||
int req, bool is_dapm);
|
||||
extern int wcd937x_micbias_control(struct snd_soc_component *component,
|
||||
int micb_num, int req, bool is_dapm);
|
||||
#endif
|
||||
|
@@ -157,19 +157,19 @@ struct wcd937x_mbhc_zdet_param {
|
||||
u16 btn7;
|
||||
};
|
||||
|
||||
static int wcd937x_mbhc_request_irq(struct snd_soc_codec *codec,
|
||||
static int wcd937x_mbhc_request_irq(struct snd_soc_component *component,
|
||||
int irq, irq_handler_t handler,
|
||||
const char *name, void *data)
|
||||
{
|
||||
struct wcd937x_priv *wcd937x = dev_get_drvdata(codec->dev);
|
||||
struct wcd937x_priv *wcd937x = dev_get_drvdata(component->dev);
|
||||
|
||||
return wcd_request_irq(&wcd937x->irq_info, irq, name, handler, data);
|
||||
}
|
||||
|
||||
static void wcd937x_mbhc_irq_control(struct snd_soc_codec *codec,
|
||||
static void wcd937x_mbhc_irq_control(struct snd_soc_component *component,
|
||||
int irq, bool enable)
|
||||
{
|
||||
struct wcd937x_priv *wcd937x = dev_get_drvdata(codec->dev);
|
||||
struct wcd937x_priv *wcd937x = dev_get_drvdata(component->dev);
|
||||
|
||||
if (enable)
|
||||
wcd_enable_irq(&wcd937x->irq_info, irq);
|
||||
@@ -177,44 +177,45 @@ static void wcd937x_mbhc_irq_control(struct snd_soc_codec *codec,
|
||||
wcd_disable_irq(&wcd937x->irq_info, irq);
|
||||
}
|
||||
|
||||
static int wcd937x_mbhc_free_irq(struct snd_soc_codec *codec,
|
||||
static int wcd937x_mbhc_free_irq(struct snd_soc_component *component,
|
||||
int irq, void *data)
|
||||
{
|
||||
struct wcd937x_priv *wcd937x = dev_get_drvdata(codec->dev);
|
||||
struct wcd937x_priv *wcd937x = dev_get_drvdata(component->dev);
|
||||
|
||||
wcd_free_irq(&wcd937x->irq_info, irq, data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void wcd937x_mbhc_clk_setup(struct snd_soc_codec *codec,
|
||||
static void wcd937x_mbhc_clk_setup(struct snd_soc_component *component,
|
||||
bool enable)
|
||||
{
|
||||
if (enable)
|
||||
snd_soc_update_bits(codec, WCD937X_MBHC_NEW_CTL_1,
|
||||
snd_soc_component_update_bits(component, WCD937X_MBHC_NEW_CTL_1,
|
||||
0x80, 0x80);
|
||||
else
|
||||
snd_soc_update_bits(codec, WCD937X_MBHC_NEW_CTL_1,
|
||||
snd_soc_component_update_bits(component, WCD937X_MBHC_NEW_CTL_1,
|
||||
0x80, 0x00);
|
||||
}
|
||||
|
||||
static int wcd937x_mbhc_btn_to_num(struct snd_soc_codec *codec)
|
||||
static int wcd937x_mbhc_btn_to_num(struct snd_soc_component *component)
|
||||
{
|
||||
return snd_soc_read(codec, WCD937X_ANA_MBHC_RESULT_3) & 0x7;
|
||||
return snd_soc_component_read32(component, WCD937X_ANA_MBHC_RESULT_3) &
|
||||
0x7;
|
||||
}
|
||||
|
||||
static void wcd937x_mbhc_mbhc_bias_control(struct snd_soc_codec *codec,
|
||||
static void wcd937x_mbhc_mbhc_bias_control(struct snd_soc_component *component,
|
||||
bool enable)
|
||||
{
|
||||
if (enable)
|
||||
snd_soc_update_bits(codec, WCD937X_ANA_MBHC_ELECT,
|
||||
snd_soc_component_update_bits(component, WCD937X_ANA_MBHC_ELECT,
|
||||
0x01, 0x01);
|
||||
else
|
||||
snd_soc_update_bits(codec, WCD937X_ANA_MBHC_ELECT,
|
||||
snd_soc_component_update_bits(component, WCD937X_ANA_MBHC_ELECT,
|
||||
0x01, 0x00);
|
||||
}
|
||||
|
||||
static void wcd937x_mbhc_program_btn_thr(struct snd_soc_codec *codec,
|
||||
static void wcd937x_mbhc_program_btn_thr(struct snd_soc_component *component,
|
||||
s16 *btn_low, s16 *btn_high,
|
||||
int num_btn, bool is_micbias)
|
||||
{
|
||||
@@ -222,16 +223,17 @@ static void wcd937x_mbhc_program_btn_thr(struct snd_soc_codec *codec,
|
||||
int vth;
|
||||
|
||||
if (num_btn > WCD_MBHC_DEF_BUTTONS) {
|
||||
dev_err(codec->dev, "%s: invalid number of buttons: %d\n",
|
||||
dev_err(component->dev, "%s: invalid number of buttons: %d\n",
|
||||
__func__, num_btn);
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < num_btn; i++) {
|
||||
vth = ((btn_high[i] * 2) / 25) & 0x3F;
|
||||
snd_soc_update_bits(codec, WCD937X_ANA_MBHC_BTN0 + i,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD937X_ANA_MBHC_BTN0 + i,
|
||||
0xFC, vth << 2);
|
||||
dev_dbg(codec->dev, "%s: btn_high[%d]: %d, vth: %d\n",
|
||||
dev_dbg(component->dev, "%s: btn_high[%d]: %d, vth: %d\n",
|
||||
__func__, i, btn_high[i], vth);
|
||||
}
|
||||
}
|
||||
@@ -262,7 +264,8 @@ static bool wcd937x_mbhc_micb_en_status(struct wcd_mbhc *mbhc, int micb_num)
|
||||
u8 val = 0;
|
||||
|
||||
if (micb_num == MIC_BIAS_2) {
|
||||
val = ((snd_soc_read(mbhc->codec, WCD937X_ANA_MICB2) & 0xC0)
|
||||
val = ((snd_soc_component_read32(mbhc->component,
|
||||
WCD937X_ANA_MICB2) & 0xC0)
|
||||
>> 6);
|
||||
if (val == 0x01)
|
||||
return true;
|
||||
@@ -270,12 +273,14 @@ static bool wcd937x_mbhc_micb_en_status(struct wcd_mbhc *mbhc, int micb_num)
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool wcd937x_mbhc_hph_pa_on_status(struct snd_soc_codec *codec)
|
||||
static bool wcd937x_mbhc_hph_pa_on_status(struct snd_soc_component *component)
|
||||
{
|
||||
return (snd_soc_read(codec, WCD937X_ANA_HPH) & 0xC0) ? true : false;
|
||||
return (snd_soc_component_read32(component, WCD937X_ANA_HPH) & 0xC0) ?
|
||||
true : false;
|
||||
}
|
||||
|
||||
static void wcd937x_mbhc_hph_l_pull_up_control(struct snd_soc_codec *codec,
|
||||
static void wcd937x_mbhc_hph_l_pull_up_control(
|
||||
struct snd_soc_component *component,
|
||||
int pull_up_cur)
|
||||
{
|
||||
/* Default pull up current to 2uA */
|
||||
@@ -283,35 +288,36 @@ static void wcd937x_mbhc_hph_l_pull_up_control(struct snd_soc_codec *codec,
|
||||
pull_up_cur == HS_PULLUP_I_DEFAULT)
|
||||
pull_up_cur = HS_PULLUP_I_2P0_UA;
|
||||
|
||||
dev_dbg(codec->dev, "%s: HS pull up current:%d\n",
|
||||
dev_dbg(component->dev, "%s: HS pull up current:%d\n",
|
||||
__func__, pull_up_cur);
|
||||
|
||||
snd_soc_update_bits(codec, WCD937X_MBHC_NEW_INT_MECH_DET_CURRENT,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD937X_MBHC_NEW_INT_MECH_DET_CURRENT,
|
||||
0x1F, pull_up_cur);
|
||||
}
|
||||
|
||||
static int wcd937x_mbhc_request_micbias(struct snd_soc_codec *codec,
|
||||
static int wcd937x_mbhc_request_micbias(struct snd_soc_component *component,
|
||||
int micb_num, int req)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ret = wcd937x_micbias_control(codec, micb_num, req, false);
|
||||
ret = wcd937x_micbias_control(component, micb_num, req, false);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void wcd937x_mbhc_micb_ramp_control(struct snd_soc_codec *codec,
|
||||
static void wcd937x_mbhc_micb_ramp_control(struct snd_soc_component *component,
|
||||
bool enable)
|
||||
{
|
||||
if (enable) {
|
||||
snd_soc_update_bits(codec, WCD937X_ANA_MICB2_RAMP,
|
||||
snd_soc_component_update_bits(component, WCD937X_ANA_MICB2_RAMP,
|
||||
0x1C, 0x0C);
|
||||
snd_soc_update_bits(codec, WCD937X_ANA_MICB2_RAMP,
|
||||
snd_soc_component_update_bits(component, WCD937X_ANA_MICB2_RAMP,
|
||||
0x80, 0x80);
|
||||
} else {
|
||||
snd_soc_update_bits(codec, WCD937X_ANA_MICB2_RAMP,
|
||||
snd_soc_component_update_bits(component, WCD937X_ANA_MICB2_RAMP,
|
||||
0x80, 0x00);
|
||||
snd_soc_update_bits(codec, WCD937X_ANA_MICB2_RAMP,
|
||||
snd_soc_component_update_bits(component, WCD937X_ANA_MICB2_RAMP,
|
||||
0x1C, 0x00);
|
||||
}
|
||||
}
|
||||
@@ -321,26 +327,27 @@ static struct firmware_cal *wcd937x_get_hwdep_fw_cal(struct wcd_mbhc *mbhc,
|
||||
{
|
||||
struct wcd937x_mbhc *wcd937x_mbhc;
|
||||
struct firmware_cal *hwdep_cal;
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
|
||||
wcd937x_mbhc = container_of(mbhc, struct wcd937x_mbhc, wcd_mbhc);
|
||||
|
||||
if (!codec) {
|
||||
pr_err("%s: NULL codec pointer\n", __func__);
|
||||
if (!component) {
|
||||
pr_err("%s: NULL component pointer\n", __func__);
|
||||
return NULL;
|
||||
}
|
||||
hwdep_cal = wcdcal_get_fw_cal(wcd937x_mbhc->fw_data, type);
|
||||
if (!hwdep_cal)
|
||||
dev_err(codec->dev, "%s: cal not sent by %d\n",
|
||||
dev_err(component->dev, "%s: cal not sent by %d\n",
|
||||
__func__, type);
|
||||
|
||||
return hwdep_cal;
|
||||
}
|
||||
|
||||
static int wcd937x_mbhc_micb_ctrl_threshold_mic(struct snd_soc_codec *codec,
|
||||
static int wcd937x_mbhc_micb_ctrl_threshold_mic(
|
||||
struct snd_soc_component *component,
|
||||
int micb_num, bool req_en)
|
||||
{
|
||||
struct wcd937x_pdata *pdata = dev_get_platdata(codec->dev);
|
||||
struct wcd937x_pdata *pdata = dev_get_platdata(component->dev);
|
||||
int rc, micb_mv;
|
||||
|
||||
if (micb_num != MIC_BIAS_2)
|
||||
@@ -355,7 +362,7 @@ static int wcd937x_mbhc_micb_ctrl_threshold_mic(struct snd_soc_codec *codec,
|
||||
|
||||
micb_mv = req_en ? WCD_MBHC_THR_HS_MICB_MV : pdata->micbias.micb2_mv;
|
||||
|
||||
rc = wcd937x_mbhc_micb_adjust_voltage(codec, micb_mv, MIC_BIAS_2);
|
||||
rc = wcd937x_mbhc_micb_adjust_voltage(component, micb_mv, MIC_BIAS_2);
|
||||
|
||||
return rc;
|
||||
}
|
||||
@@ -418,25 +425,25 @@ ramp_down:
|
||||
}
|
||||
}
|
||||
|
||||
static void wcd937x_mbhc_zdet_ramp(struct snd_soc_codec *codec,
|
||||
static void wcd937x_mbhc_zdet_ramp(struct snd_soc_component *component,
|
||||
struct wcd937x_mbhc_zdet_param *zdet_param,
|
||||
int32_t *zl, int32_t *zr, s16 *d1_a)
|
||||
{
|
||||
struct wcd937x_priv *wcd937x = dev_get_drvdata(codec->dev);
|
||||
struct wcd937x_priv *wcd937x = dev_get_drvdata(component->dev);
|
||||
int32_t zdet = 0;
|
||||
|
||||
snd_soc_update_bits(codec, WCD937X_MBHC_NEW_ZDET_ANA_CTL, 0x70,
|
||||
zdet_param->ldo_ctl << 4);
|
||||
snd_soc_update_bits(codec, WCD937X_ANA_MBHC_BTN5, 0xFC,
|
||||
snd_soc_component_update_bits(component, WCD937X_MBHC_NEW_ZDET_ANA_CTL,
|
||||
0x70, zdet_param->ldo_ctl << 4);
|
||||
snd_soc_component_update_bits(component, WCD937X_ANA_MBHC_BTN5, 0xFC,
|
||||
zdet_param->btn5);
|
||||
snd_soc_update_bits(codec, WCD937X_ANA_MBHC_BTN6, 0xFC,
|
||||
snd_soc_component_update_bits(component, WCD937X_ANA_MBHC_BTN6, 0xFC,
|
||||
zdet_param->btn6);
|
||||
snd_soc_update_bits(codec, WCD937X_ANA_MBHC_BTN7, 0xFC,
|
||||
snd_soc_component_update_bits(component, WCD937X_ANA_MBHC_BTN7, 0xFC,
|
||||
zdet_param->btn7);
|
||||
snd_soc_update_bits(codec, WCD937X_MBHC_NEW_ZDET_ANA_CTL, 0x0F,
|
||||
zdet_param->noff);
|
||||
snd_soc_update_bits(codec, WCD937X_MBHC_NEW_ZDET_RAMP_CTL, 0x0F,
|
||||
zdet_param->nshift);
|
||||
snd_soc_component_update_bits(component, WCD937X_MBHC_NEW_ZDET_ANA_CTL,
|
||||
0x0F, zdet_param->noff);
|
||||
snd_soc_component_update_bits(component, WCD937X_MBHC_NEW_ZDET_RAMP_CTL,
|
||||
0x0F, zdet_param->nshift);
|
||||
|
||||
if (!zl)
|
||||
goto z_right;
|
||||
@@ -466,17 +473,18 @@ z_right:
|
||||
*zr = zdet;
|
||||
}
|
||||
|
||||
static inline void wcd937x_wcd_mbhc_qfuse_cal(struct snd_soc_codec *codec,
|
||||
static inline void wcd937x_wcd_mbhc_qfuse_cal(
|
||||
struct snd_soc_component *component,
|
||||
int32_t *z_val, int flag_l_r)
|
||||
{
|
||||
s16 q1;
|
||||
int q1_cal;
|
||||
|
||||
if (*z_val < (WCD937X_ZDET_VAL_400/1000))
|
||||
q1 = snd_soc_read(codec,
|
||||
q1 = snd_soc_component_read32(component,
|
||||
WCD937X_DIGITAL_EFUSE_REG_23 + (2 * flag_l_r));
|
||||
else
|
||||
q1 = snd_soc_read(codec,
|
||||
q1 = snd_soc_component_read32(component,
|
||||
WCD937X_DIGITAL_EFUSE_REG_24 + (2 * flag_l_r));
|
||||
if (q1 & 0x80)
|
||||
q1_cal = (10000 - ((q1 & 0x7F) * 25));
|
||||
@@ -489,8 +497,8 @@ static inline void wcd937x_wcd_mbhc_qfuse_cal(struct snd_soc_codec *codec,
|
||||
static void wcd937x_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl,
|
||||
uint32_t *zr)
|
||||
{
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct wcd937x_priv *wcd937x = dev_get_drvdata(codec->dev);
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
struct wcd937x_priv *wcd937x = dev_get_drvdata(component->dev);
|
||||
s16 reg0, reg1, reg2, reg3, reg4;
|
||||
int32_t z1L, z1R, z1Ls;
|
||||
int zMono, z_diff1, z_diff2;
|
||||
@@ -512,13 +520,15 @@ static void wcd937x_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl,
|
||||
|
||||
WCD_MBHC_RSC_ASSERT_LOCKED(mbhc);
|
||||
|
||||
reg0 = snd_soc_read(codec, WCD937X_ANA_MBHC_BTN5);
|
||||
reg1 = snd_soc_read(codec, WCD937X_ANA_MBHC_BTN6);
|
||||
reg2 = snd_soc_read(codec, WCD937X_ANA_MBHC_BTN7);
|
||||
reg3 = snd_soc_read(codec, WCD937X_MBHC_CTL_CLK);
|
||||
reg4 = snd_soc_read(codec, WCD937X_MBHC_NEW_ZDET_ANA_CTL);
|
||||
reg0 = snd_soc_component_read32(component, WCD937X_ANA_MBHC_BTN5);
|
||||
reg1 = snd_soc_component_read32(component, WCD937X_ANA_MBHC_BTN6);
|
||||
reg2 = snd_soc_component_read32(component, WCD937X_ANA_MBHC_BTN7);
|
||||
reg3 = snd_soc_component_read32(component, WCD937X_MBHC_CTL_CLK);
|
||||
reg4 = snd_soc_component_read32(component,
|
||||
WCD937X_MBHC_NEW_ZDET_ANA_CTL);
|
||||
|
||||
if (snd_soc_read(codec, WCD937X_ANA_MBHC_ELECT) & 0x80) {
|
||||
if (snd_soc_component_read32(component, WCD937X_ANA_MBHC_ELECT) &
|
||||
0x80) {
|
||||
is_fsm_disable = true;
|
||||
regmap_update_bits(wcd937x->regmap,
|
||||
WCD937X_ANA_MBHC_ELECT, 0x80, 0x00);
|
||||
@@ -536,7 +546,7 @@ static void wcd937x_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl,
|
||||
/* First get impedance on Left */
|
||||
d1 = d1_a[1];
|
||||
zdet_param_ptr = &zdet_param[1];
|
||||
wcd937x_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1);
|
||||
wcd937x_mbhc_zdet_ramp(component, zdet_param_ptr, &z1L, NULL, d1);
|
||||
|
||||
if (!WCD937X_MBHC_IS_SECOND_RAMP_REQUIRED(z1L))
|
||||
goto left_ch_impedance;
|
||||
@@ -553,7 +563,7 @@ static void wcd937x_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl,
|
||||
zdet_param_ptr = &zdet_param[3];
|
||||
d1 = d1_a[3];
|
||||
}
|
||||
wcd937x_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1);
|
||||
wcd937x_mbhc_zdet_ramp(component, zdet_param_ptr, &z1L, NULL, d1);
|
||||
|
||||
left_ch_impedance:
|
||||
if ((z1L == WCD937X_ZDET_FLOATING_IMPEDANCE) ||
|
||||
@@ -563,13 +573,13 @@ left_ch_impedance:
|
||||
d1 = d1_a[1];
|
||||
} else {
|
||||
*zl = z1L/1000;
|
||||
wcd937x_wcd_mbhc_qfuse_cal(codec, zl, 0);
|
||||
wcd937x_wcd_mbhc_qfuse_cal(component, zl, 0);
|
||||
}
|
||||
dev_dbg(codec->dev, "%s: impedance on HPH_L = %d(ohms)\n",
|
||||
dev_dbg(component->dev, "%s: impedance on HPH_L = %d(ohms)\n",
|
||||
__func__, *zl);
|
||||
|
||||
/* Start of right impedance ramp and calculation */
|
||||
wcd937x_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1);
|
||||
wcd937x_mbhc_zdet_ramp(component, zdet_param_ptr, NULL, &z1R, d1);
|
||||
if (WCD937X_MBHC_IS_SECOND_RAMP_REQUIRED(z1R)) {
|
||||
if (((z1R > WCD937X_ZDET_VAL_1200) &&
|
||||
(zdet_param_ptr->noff == 0x6)) ||
|
||||
@@ -587,7 +597,8 @@ left_ch_impedance:
|
||||
zdet_param_ptr = &zdet_param[3];
|
||||
d1 = d1_a[3];
|
||||
}
|
||||
wcd937x_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1);
|
||||
wcd937x_mbhc_zdet_ramp(component, zdet_param_ptr, NULL,
|
||||
&z1R, d1);
|
||||
}
|
||||
right_ch_impedance:
|
||||
if ((z1R == WCD937X_ZDET_FLOATING_IMPEDANCE) ||
|
||||
@@ -595,15 +606,15 @@ right_ch_impedance:
|
||||
*zr = WCD937X_ZDET_FLOATING_IMPEDANCE;
|
||||
} else {
|
||||
*zr = z1R/1000;
|
||||
wcd937x_wcd_mbhc_qfuse_cal(codec, zr, 1);
|
||||
wcd937x_wcd_mbhc_qfuse_cal(component, zr, 1);
|
||||
}
|
||||
dev_dbg(codec->dev, "%s: impedance on HPH_R = %d(ohms)\n",
|
||||
dev_dbg(component->dev, "%s: impedance on HPH_R = %d(ohms)\n",
|
||||
__func__, *zr);
|
||||
|
||||
/* Mono/stereo detection */
|
||||
if ((*zl == WCD937X_ZDET_FLOATING_IMPEDANCE) &&
|
||||
(*zr == WCD937X_ZDET_FLOATING_IMPEDANCE)) {
|
||||
dev_dbg(codec->dev,
|
||||
dev_dbg(component->dev,
|
||||
"%s: plug type is invalid or extension cable\n",
|
||||
__func__);
|
||||
goto zdet_complete;
|
||||
@@ -612,40 +623,46 @@ right_ch_impedance:
|
||||
(*zr == WCD937X_ZDET_FLOATING_IMPEDANCE) ||
|
||||
((*zl < WCD_MONO_HS_MIN_THR) && (*zr > WCD_MONO_HS_MIN_THR)) ||
|
||||
((*zl > WCD_MONO_HS_MIN_THR) && (*zr < WCD_MONO_HS_MIN_THR))) {
|
||||
dev_dbg(codec->dev,
|
||||
dev_dbg(component->dev,
|
||||
"%s: Mono plug type with one ch floating or shorted to GND\n",
|
||||
__func__);
|
||||
mbhc->hph_type = WCD_MBHC_HPH_MONO;
|
||||
goto zdet_complete;
|
||||
}
|
||||
snd_soc_update_bits(codec, WCD937X_HPH_R_ATEST, 0x02, 0x02);
|
||||
snd_soc_update_bits(codec, WCD937X_HPH_PA_CTL2, 0x40, 0x01);
|
||||
snd_soc_component_update_bits(component, WCD937X_HPH_R_ATEST,
|
||||
0x02, 0x02);
|
||||
snd_soc_component_update_bits(component, WCD937X_HPH_PA_CTL2,
|
||||
0x40, 0x01);
|
||||
if (*zl < (WCD937X_ZDET_VAL_32/1000))
|
||||
wcd937x_mbhc_zdet_ramp(codec, &zdet_param[0], &z1Ls, NULL, d1);
|
||||
wcd937x_mbhc_zdet_ramp(component, &zdet_param[0], &z1Ls,
|
||||
NULL, d1);
|
||||
else
|
||||
wcd937x_mbhc_zdet_ramp(codec, &zdet_param[1], &z1Ls, NULL, d1);
|
||||
snd_soc_update_bits(codec, WCD937X_HPH_PA_CTL2, 0x40, 0x00);
|
||||
snd_soc_update_bits(codec, WCD937X_HPH_R_ATEST, 0x02, 0x00);
|
||||
wcd937x_mbhc_zdet_ramp(component, &zdet_param[1], &z1Ls,
|
||||
NULL, d1);
|
||||
snd_soc_component_update_bits(component, WCD937X_HPH_PA_CTL2,
|
||||
0x40, 0x00);
|
||||
snd_soc_component_update_bits(component, WCD937X_HPH_R_ATEST,
|
||||
0x02, 0x00);
|
||||
z1Ls /= 1000;
|
||||
wcd937x_wcd_mbhc_qfuse_cal(codec, &z1Ls, 0);
|
||||
wcd937x_wcd_mbhc_qfuse_cal(component, &z1Ls, 0);
|
||||
/* Parallel of left Z and 9 ohm pull down resistor */
|
||||
zMono = ((*zl) * 9) / ((*zl) + 9);
|
||||
z_diff1 = (z1Ls > zMono) ? (z1Ls - zMono) : (zMono - z1Ls);
|
||||
z_diff2 = ((*zl) > z1Ls) ? ((*zl) - z1Ls) : (z1Ls - (*zl));
|
||||
if ((z_diff1 * (*zl + z1Ls)) > (z_diff2 * (z1Ls + zMono))) {
|
||||
dev_dbg(codec->dev, "%s: stereo plug type detected\n",
|
||||
dev_dbg(component->dev, "%s: stereo plug type detected\n",
|
||||
__func__);
|
||||
mbhc->hph_type = WCD_MBHC_HPH_STEREO;
|
||||
} else {
|
||||
dev_dbg(codec->dev, "%s: MONO plug type detected\n",
|
||||
dev_dbg(component->dev, "%s: MONO plug type detected\n",
|
||||
__func__);
|
||||
mbhc->hph_type = WCD_MBHC_HPH_MONO;
|
||||
}
|
||||
|
||||
zdet_complete:
|
||||
snd_soc_write(codec, WCD937X_ANA_MBHC_BTN5, reg0);
|
||||
snd_soc_write(codec, WCD937X_ANA_MBHC_BTN6, reg1);
|
||||
snd_soc_write(codec, WCD937X_ANA_MBHC_BTN7, reg2);
|
||||
snd_soc_component_write(component, WCD937X_ANA_MBHC_BTN5, reg0);
|
||||
snd_soc_component_write(component, WCD937X_ANA_MBHC_BTN6, reg1);
|
||||
snd_soc_component_write(component, WCD937X_ANA_MBHC_BTN7, reg2);
|
||||
/* Turn on 100k pull down on HPHL */
|
||||
regmap_update_bits(wcd937x->regmap,
|
||||
WCD937X_ANA_MBHC_MECH, 0x01, 0x01);
|
||||
@@ -655,97 +672,98 @@ zdet_complete:
|
||||
regmap_update_bits(wcd937x->regmap,
|
||||
WCD937X_ANA_MBHC_MECH, 0x80, 0x80);
|
||||
|
||||
snd_soc_write(codec, WCD937X_MBHC_NEW_ZDET_ANA_CTL, reg4);
|
||||
snd_soc_write(codec, WCD937X_MBHC_CTL_CLK, reg3);
|
||||
snd_soc_component_write(component, WCD937X_MBHC_NEW_ZDET_ANA_CTL, reg4);
|
||||
snd_soc_component_write(component, WCD937X_MBHC_CTL_CLK, reg3);
|
||||
if (is_fsm_disable)
|
||||
regmap_update_bits(wcd937x->regmap,
|
||||
WCD937X_ANA_MBHC_ELECT, 0x80, 0x80);
|
||||
}
|
||||
|
||||
static void wcd937x_mbhc_gnd_det_ctrl(struct snd_soc_codec *codec, bool enable)
|
||||
static void wcd937x_mbhc_gnd_det_ctrl(struct snd_soc_component *component,
|
||||
bool enable)
|
||||
{
|
||||
if (enable) {
|
||||
snd_soc_update_bits(codec, WCD937X_ANA_MBHC_MECH,
|
||||
snd_soc_component_update_bits(component, WCD937X_ANA_MBHC_MECH,
|
||||
0x02, 0x02);
|
||||
snd_soc_update_bits(codec, WCD937X_ANA_MBHC_MECH,
|
||||
snd_soc_component_update_bits(component, WCD937X_ANA_MBHC_MECH,
|
||||
0x40, 0x40);
|
||||
} else {
|
||||
snd_soc_update_bits(codec, WCD937X_ANA_MBHC_MECH,
|
||||
snd_soc_component_update_bits(component, WCD937X_ANA_MBHC_MECH,
|
||||
0x40, 0x00);
|
||||
snd_soc_update_bits(codec, WCD937X_ANA_MBHC_MECH,
|
||||
snd_soc_component_update_bits(component, WCD937X_ANA_MBHC_MECH,
|
||||
0x02, 0x00);
|
||||
}
|
||||
}
|
||||
|
||||
static void wcd937x_mbhc_hph_pull_down_ctrl(struct snd_soc_codec *codec,
|
||||
static void wcd937x_mbhc_hph_pull_down_ctrl(struct snd_soc_component *component,
|
||||
bool enable)
|
||||
{
|
||||
if (enable) {
|
||||
snd_soc_update_bits(codec, WCD937X_HPH_PA_CTL2,
|
||||
snd_soc_component_update_bits(component, WCD937X_HPH_PA_CTL2,
|
||||
0x40, 0x40);
|
||||
snd_soc_update_bits(codec, WCD937X_HPH_PA_CTL2,
|
||||
snd_soc_component_update_bits(component, WCD937X_HPH_PA_CTL2,
|
||||
0x10, 0x10);
|
||||
} else {
|
||||
snd_soc_update_bits(codec, WCD937X_HPH_PA_CTL2,
|
||||
snd_soc_component_update_bits(component, WCD937X_HPH_PA_CTL2,
|
||||
0x40, 0x00);
|
||||
snd_soc_update_bits(codec, WCD937X_HPH_PA_CTL2,
|
||||
snd_soc_component_update_bits(component, WCD937X_HPH_PA_CTL2,
|
||||
0x10, 0x00);
|
||||
}
|
||||
}
|
||||
|
||||
static void wcd937x_mbhc_moisture_config(struct wcd_mbhc *mbhc)
|
||||
{
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
|
||||
if ((mbhc->moist_rref == R_OFF) ||
|
||||
(mbhc->mbhc_cfg->enable_usbc_analog)) {
|
||||
snd_soc_update_bits(codec, WCD937X_MBHC_NEW_CTL_2,
|
||||
snd_soc_component_update_bits(component, WCD937X_MBHC_NEW_CTL_2,
|
||||
0x0C, R_OFF << 2);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Do not enable moisture detection if jack type is NC */
|
||||
if (!mbhc->hphl_swh) {
|
||||
dev_dbg(codec->dev, "%s: disable moisture detection for NC\n",
|
||||
dev_dbg(component->dev, "%s: disable moisture detection for NC\n",
|
||||
__func__);
|
||||
snd_soc_update_bits(codec, WCD937X_MBHC_NEW_CTL_2,
|
||||
snd_soc_component_update_bits(component, WCD937X_MBHC_NEW_CTL_2,
|
||||
0x0C, R_OFF << 2);
|
||||
return;
|
||||
}
|
||||
|
||||
snd_soc_update_bits(codec, WCD937X_MBHC_NEW_CTL_2,
|
||||
snd_soc_component_update_bits(component, WCD937X_MBHC_NEW_CTL_2,
|
||||
0x0C, mbhc->moist_rref << 2);
|
||||
}
|
||||
|
||||
static void wcd937x_mbhc_moisture_detect_en(struct wcd_mbhc *mbhc, bool enable)
|
||||
{
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
|
||||
if (enable)
|
||||
snd_soc_update_bits(codec, WCD937X_MBHC_NEW_CTL_2,
|
||||
snd_soc_component_update_bits(component, WCD937X_MBHC_NEW_CTL_2,
|
||||
0x0C, mbhc->moist_rref << 2);
|
||||
else
|
||||
snd_soc_update_bits(codec, WCD937X_MBHC_NEW_CTL_2,
|
||||
snd_soc_component_update_bits(component, WCD937X_MBHC_NEW_CTL_2,
|
||||
0x0C, R_OFF << 2);
|
||||
}
|
||||
|
||||
static bool wcd937x_mbhc_get_moisture_status(struct wcd_mbhc *mbhc)
|
||||
{
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
bool ret = false;
|
||||
|
||||
if ((mbhc->moist_rref == R_OFF) ||
|
||||
(mbhc->mbhc_cfg->enable_usbc_analog)) {
|
||||
snd_soc_update_bits(codec, WCD937X_MBHC_NEW_CTL_2,
|
||||
snd_soc_component_update_bits(component, WCD937X_MBHC_NEW_CTL_2,
|
||||
0x0C, R_OFF << 2);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Do not enable moisture detection if jack type is NC */
|
||||
if (!mbhc->hphl_swh) {
|
||||
dev_dbg(codec->dev, "%s: disable moisture detection for NC\n",
|
||||
dev_dbg(component->dev, "%s: disable moisture detection for NC\n",
|
||||
__func__);
|
||||
snd_soc_update_bits(codec, WCD937X_MBHC_NEW_CTL_2,
|
||||
snd_soc_component_update_bits(component, WCD937X_MBHC_NEW_CTL_2,
|
||||
0x0C, R_OFF << 2);
|
||||
goto done;
|
||||
}
|
||||
@@ -753,12 +771,13 @@ static bool wcd937x_mbhc_get_moisture_status(struct wcd_mbhc *mbhc)
|
||||
/* If moisture_en is already enabled, then skip to plug type
|
||||
* detection.
|
||||
*/
|
||||
if ((snd_soc_read(codec, WCD937X_MBHC_NEW_CTL_2) & 0x0C))
|
||||
if ((snd_soc_component_read32(component, WCD937X_MBHC_NEW_CTL_2) &
|
||||
0x0C))
|
||||
goto done;
|
||||
|
||||
wcd937x_mbhc_moisture_detect_en(mbhc, true);
|
||||
/* Read moisture comparator status */
|
||||
ret = ((snd_soc_read(codec, WCD937X_MBHC_NEW_FSM_STATUS)
|
||||
ret = ((snd_soc_component_read32(component, WCD937X_MBHC_NEW_FSM_STATUS)
|
||||
& 0x20) ? 0 : 1);
|
||||
|
||||
done:
|
||||
@@ -769,9 +788,9 @@ done:
|
||||
static void wcd937x_mbhc_moisture_polling_ctrl(struct wcd_mbhc *mbhc,
|
||||
bool enable)
|
||||
{
|
||||
struct snd_soc_codec *codec = mbhc->codec;
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
|
||||
snd_soc_update_bits(codec,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD937X_MBHC_NEW_INT_MOISTURE_DET_POLLING_CTRL,
|
||||
0x04, (enable << 2));
|
||||
}
|
||||
@@ -805,19 +824,22 @@ static const struct wcd_mbhc_cb mbhc_cb = {
|
||||
static int wcd937x_get_hph_type(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct wcd937x_mbhc *wcd937x_mbhc = wcd937x_soc_get_mbhc(codec);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct wcd937x_mbhc *wcd937x_mbhc = wcd937x_soc_get_mbhc(component);
|
||||
struct wcd_mbhc *mbhc;
|
||||
|
||||
if (!wcd937x_mbhc) {
|
||||
dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__);
|
||||
dev_err(component->dev, "%s: mbhc not initialized!\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mbhc = &wcd937x_mbhc->wcd_mbhc;
|
||||
|
||||
ucontrol->value.integer.value[0] = (u32) mbhc->hph_type;
|
||||
dev_dbg(codec->dev, "%s: hph_type = %u\n", __func__, mbhc->hph_type);
|
||||
dev_dbg(component->dev, "%s: hph_type = %u\n", __func__,
|
||||
mbhc->hph_type);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -828,18 +850,21 @@ static int wcd937x_hph_impedance_get(struct snd_kcontrol *kcontrol,
|
||||
uint32_t zl, zr;
|
||||
bool hphr;
|
||||
struct soc_multi_mixer_control *mc;
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct wcd937x_mbhc *wcd937x_mbhc = wcd937x_soc_get_mbhc(codec);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct wcd937x_mbhc *wcd937x_mbhc = wcd937x_soc_get_mbhc(component);
|
||||
|
||||
if (!wcd937x_mbhc) {
|
||||
dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__);
|
||||
dev_err(component->dev, "%s: mbhc not initialized!\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mc = (struct soc_multi_mixer_control *)(kcontrol->private_value);
|
||||
hphr = mc->shift;
|
||||
wcd_mbhc_get_impedance(&wcd937x_mbhc->wcd_mbhc, &zl, &zr);
|
||||
dev_dbg(codec->dev, "%s: zl=%u(ohms), zr=%u(ohms)\n", __func__, zl, zr);
|
||||
dev_dbg(component->dev, "%s: zl=%u(ohms), zr=%u(ohms)\n", __func__,
|
||||
zl, zr);
|
||||
ucontrol->value.integer.value[0] = hphr ? zr : zl;
|
||||
|
||||
return 0;
|
||||
@@ -883,22 +908,22 @@ EXPORT_SYMBOL(wcd937x_mbhc_get_impedance);
|
||||
|
||||
/*
|
||||
* wcd937x_mbhc_hs_detect: starts mbhc insertion/removal functionality
|
||||
* @codec: handle to snd_soc_codec *
|
||||
* @component: handle to snd_soc_component *
|
||||
* @mbhc_cfg: handle to mbhc configuration structure
|
||||
* return 0 if mbhc_start is success or error code in case of failure
|
||||
*/
|
||||
int wcd937x_mbhc_hs_detect(struct snd_soc_codec *codec,
|
||||
int wcd937x_mbhc_hs_detect(struct snd_soc_component *component,
|
||||
struct wcd_mbhc_config *mbhc_cfg)
|
||||
{
|
||||
struct wcd937x_priv *wcd937x = NULL;
|
||||
struct wcd937x_mbhc *wcd937x_mbhc = NULL;
|
||||
|
||||
if (!codec) {
|
||||
pr_err("%s: codec is NULL\n", __func__);
|
||||
if (!component) {
|
||||
pr_err("%s: component is NULL\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
wcd937x = snd_soc_codec_get_drvdata(codec);
|
||||
wcd937x = snd_soc_component_get_drvdata(component);
|
||||
if (!wcd937x) {
|
||||
pr_err("%s: wcd937x is NULL\n", __func__);
|
||||
return -EINVAL;
|
||||
@@ -906,7 +931,8 @@ int wcd937x_mbhc_hs_detect(struct snd_soc_codec *codec,
|
||||
|
||||
wcd937x_mbhc = wcd937x->mbhc;
|
||||
if (!wcd937x_mbhc) {
|
||||
dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__);
|
||||
dev_err(component->dev, "%s: mbhc not initialized!\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -916,19 +942,19 @@ EXPORT_SYMBOL(wcd937x_mbhc_hs_detect);
|
||||
|
||||
/*
|
||||
* wcd937x_mbhc_hs_detect_exit: stop mbhc insertion/removal functionality
|
||||
* @codec: handle to snd_soc_codec *
|
||||
* @component: handle to snd_soc_component *
|
||||
*/
|
||||
void wcd937x_mbhc_hs_detect_exit(struct snd_soc_codec *codec)
|
||||
void wcd937x_mbhc_hs_detect_exit(struct snd_soc_component *component)
|
||||
{
|
||||
struct wcd937x_priv *wcd937x = NULL;
|
||||
struct wcd937x_mbhc *wcd937x_mbhc = NULL;
|
||||
|
||||
if (!codec) {
|
||||
pr_err("%s: codec is NULL\n", __func__);
|
||||
if (!component) {
|
||||
pr_err("%s: component is NULL\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
wcd937x = snd_soc_codec_get_drvdata(codec);
|
||||
wcd937x = snd_soc_component_get_drvdata(component);
|
||||
if (!wcd937x) {
|
||||
pr_err("%s: wcd937x is NULL\n", __func__);
|
||||
return;
|
||||
@@ -936,7 +962,8 @@ void wcd937x_mbhc_hs_detect_exit(struct snd_soc_codec *codec)
|
||||
|
||||
wcd937x_mbhc = wcd937x->mbhc;
|
||||
if (!wcd937x_mbhc) {
|
||||
dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__);
|
||||
dev_err(component->dev, "%s: mbhc not initialized!\n",
|
||||
__func__);
|
||||
return;
|
||||
}
|
||||
wcd_mbhc_stop(&wcd937x_mbhc->wcd_mbhc);
|
||||
@@ -947,17 +974,17 @@ EXPORT_SYMBOL(wcd937x_mbhc_hs_detect_exit);
|
||||
* wcd937x_mbhc_post_ssr_init: initialize mbhc for
|
||||
* wcd937x post subsystem restart
|
||||
* @mbhc: poniter to wcd937x_mbhc structure
|
||||
* @codec: handle to snd_soc_codec *
|
||||
* @component: handle to snd_soc_component *
|
||||
*
|
||||
* return 0 if mbhc_init is success or error code in case of failure
|
||||
*/
|
||||
int wcd937x_mbhc_post_ssr_init(struct wcd937x_mbhc *mbhc,
|
||||
struct snd_soc_codec *codec)
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
int ret = 0;
|
||||
struct wcd_mbhc *wcd_mbhc = NULL;
|
||||
|
||||
if (!mbhc || !codec)
|
||||
if (!mbhc || !component)
|
||||
return -EINVAL;
|
||||
|
||||
wcd_mbhc = &mbhc->wcd_mbhc;
|
||||
@@ -966,14 +993,14 @@ int wcd937x_mbhc_post_ssr_init(struct wcd937x_mbhc *mbhc,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
wcd937x_mbhc_hs_detect_exit(codec);
|
||||
wcd937x_mbhc_hs_detect_exit(component);
|
||||
wcd_mbhc_deinit(wcd_mbhc);
|
||||
snd_soc_update_bits(codec, WCD937X_ANA_MBHC_MECH,
|
||||
snd_soc_component_update_bits(component, WCD937X_ANA_MBHC_MECH,
|
||||
0x20, 0x20);
|
||||
ret = wcd_mbhc_init(wcd_mbhc, codec, &mbhc_cb, &intr_ids,
|
||||
ret = wcd_mbhc_init(wcd_mbhc, component, &mbhc_cb, &intr_ids,
|
||||
wcd_mbhc_registers, WCD937X_ZDET_SUPPORTED);
|
||||
if (ret) {
|
||||
dev_err(codec->dev, "%s: mbhc initialization failed\n",
|
||||
dev_err(component->dev, "%s: mbhc initialization failed\n",
|
||||
__func__);
|
||||
goto done;
|
||||
}
|
||||
@@ -986,24 +1013,25 @@ EXPORT_SYMBOL(wcd937x_mbhc_post_ssr_init);
|
||||
/*
|
||||
* wcd937x_mbhc_init: initialize mbhc for wcd937x
|
||||
* @mbhc: poniter to wcd937x_mbhc struct pointer to store the configs
|
||||
* @codec: handle to snd_soc_codec *
|
||||
* @component: handle to snd_soc_component *
|
||||
* @fw_data: handle to firmware data
|
||||
*
|
||||
* return 0 if mbhc_init is success or error code in case of failure
|
||||
*/
|
||||
int wcd937x_mbhc_init(struct wcd937x_mbhc **mbhc, struct snd_soc_codec *codec,
|
||||
int wcd937x_mbhc_init(struct wcd937x_mbhc **mbhc,
|
||||
struct snd_soc_component *component,
|
||||
struct fw_info *fw_data)
|
||||
{
|
||||
struct wcd937x_mbhc *wcd937x_mbhc = NULL;
|
||||
struct wcd_mbhc *wcd_mbhc = NULL;
|
||||
int ret = 0;
|
||||
|
||||
if (!codec) {
|
||||
pr_err("%s: codec is NULL\n", __func__);
|
||||
if (!component) {
|
||||
pr_err("%s: component is NULL\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
wcd937x_mbhc = devm_kzalloc(codec->dev, sizeof(struct wcd937x_mbhc),
|
||||
wcd937x_mbhc = devm_kzalloc(component->dev, sizeof(struct wcd937x_mbhc),
|
||||
GFP_KERNEL);
|
||||
if (!wcd937x_mbhc)
|
||||
return -ENOMEM;
|
||||
@@ -1021,43 +1049,43 @@ int wcd937x_mbhc_init(struct wcd937x_mbhc **mbhc, struct snd_soc_codec *codec,
|
||||
/* Setting default mbhc detection logic to ADC */
|
||||
wcd_mbhc->mbhc_detection_logic = WCD_DETECTION_ADC;
|
||||
|
||||
ret = wcd_mbhc_init(wcd_mbhc, codec, &mbhc_cb,
|
||||
ret = wcd_mbhc_init(wcd_mbhc, component, &mbhc_cb,
|
||||
&intr_ids, wcd_mbhc_registers,
|
||||
WCD937X_ZDET_SUPPORTED);
|
||||
if (ret) {
|
||||
dev_err(codec->dev, "%s: mbhc initialization failed\n",
|
||||
dev_err(component->dev, "%s: mbhc initialization failed\n",
|
||||
__func__);
|
||||
goto err;
|
||||
}
|
||||
|
||||
(*mbhc) = wcd937x_mbhc;
|
||||
snd_soc_add_codec_controls(codec, impedance_detect_controls,
|
||||
snd_soc_add_component_controls(component, impedance_detect_controls,
|
||||
ARRAY_SIZE(impedance_detect_controls));
|
||||
snd_soc_add_codec_controls(codec, hph_type_detect_controls,
|
||||
snd_soc_add_component_controls(component, hph_type_detect_controls,
|
||||
ARRAY_SIZE(hph_type_detect_controls));
|
||||
|
||||
return 0;
|
||||
err:
|
||||
devm_kfree(codec->dev, wcd937x_mbhc);
|
||||
devm_kfree(component->dev, wcd937x_mbhc);
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(wcd937x_mbhc_init);
|
||||
|
||||
/*
|
||||
* wcd937x_mbhc_deinit: deinitialize mbhc for wcd937x
|
||||
* @codec: handle to snd_soc_codec *
|
||||
* @component: handle to snd_soc_component *
|
||||
*/
|
||||
void wcd937x_mbhc_deinit(struct snd_soc_codec *codec)
|
||||
void wcd937x_mbhc_deinit(struct snd_soc_component *component)
|
||||
{
|
||||
struct wcd937x_priv *wcd937x;
|
||||
struct wcd937x_mbhc *wcd937x_mbhc;
|
||||
|
||||
if (!codec) {
|
||||
pr_err("%s: codec is NULL\n", __func__);
|
||||
if (!component) {
|
||||
pr_err("%s: component is NULL\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
wcd937x = snd_soc_codec_get_drvdata(codec);
|
||||
wcd937x = snd_soc_component_get_drvdata(component);
|
||||
if (!wcd937x) {
|
||||
pr_err("%s: wcd937x is NULL\n", __func__);
|
||||
return;
|
||||
@@ -1066,7 +1094,7 @@ void wcd937x_mbhc_deinit(struct snd_soc_codec *codec)
|
||||
wcd937x_mbhc = wcd937x->mbhc;
|
||||
if (wcd937x_mbhc) {
|
||||
wcd_mbhc_deinit(&wcd937x_mbhc->wcd_mbhc);
|
||||
devm_kfree(codec->dev, wcd937x_mbhc);
|
||||
devm_kfree(component->dev, wcd937x_mbhc);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL(wcd937x_mbhc_deinit);
|
||||
|
@@ -13,36 +13,37 @@ struct wcd937x_mbhc {
|
||||
|
||||
#if IS_ENABLED(CONFIG_SND_SOC_WCD937X)
|
||||
extern int wcd937x_mbhc_init(struct wcd937x_mbhc **mbhc,
|
||||
struct snd_soc_codec *codec,
|
||||
struct snd_soc_component *component,
|
||||
struct fw_info *fw_data);
|
||||
extern void wcd937x_mbhc_hs_detect_exit(struct snd_soc_codec *codec);
|
||||
extern int wcd937x_mbhc_hs_detect(struct snd_soc_codec *codec,
|
||||
extern void wcd937x_mbhc_hs_detect_exit(struct snd_soc_component *component);
|
||||
extern int wcd937x_mbhc_hs_detect(struct snd_soc_component *component,
|
||||
struct wcd_mbhc_config *mbhc_cfg);
|
||||
extern void wcd937x_mbhc_deinit(struct snd_soc_codec *codec);
|
||||
extern void wcd937x_mbhc_deinit(struct snd_soc_component *component);
|
||||
extern int wcd937x_mbhc_post_ssr_init(struct wcd937x_mbhc *mbhc,
|
||||
struct snd_soc_codec *codec);
|
||||
struct snd_soc_component *component);
|
||||
extern int wcd937x_mbhc_get_impedance(struct wcd937x_mbhc *wcd937x_mbhc,
|
||||
uint32_t *zl, uint32_t *zr);
|
||||
#else
|
||||
static inline int wcd937x_mbhc_init(struct wcd937x_mbhc **mbhc,
|
||||
struct snd_soc_codec *codec,
|
||||
struct snd_soc_component *component,
|
||||
struct fw_info *fw_data)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static inline void wcd937x_mbhc_hs_detect_exit(struct snd_soc_codec *codec)
|
||||
static inline void wcd937x_mbhc_hs_detect_exit(
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
}
|
||||
static inline int wcd937x_mbhc_hs_detect(struct snd_soc_codec *codec,
|
||||
static inline int wcd937x_mbhc_hs_detect(struct snd_soc_component *component,
|
||||
struct wcd_mbhc_config *mbhc_cfg)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static inline void wcd937x_mbhc_deinit(struct snd_soc_codec *codec)
|
||||
static inline void wcd937x_mbhc_deinit(struct snd_soc_component *component)
|
||||
{
|
||||
}
|
||||
static inline int wcd937x_mbhc_post_ssr_init(struct wcd937x_mbhc *mbhc,
|
||||
struct snd_soc_codec *codec)
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
文件差异内容过多而无法显示
加载差异
@@ -7,10 +7,10 @@
|
||||
|
||||
#ifdef CONFIG_SND_SOC_WCD937X
|
||||
extern int wcd937x_info_create_codec_entry(struct snd_info_entry *codec_root,
|
||||
struct snd_soc_codec *codec);
|
||||
struct snd_soc_component *component);
|
||||
#else
|
||||
extern int wcd937x_info_create_codec_entry(struct snd_info_entry *codec_root,
|
||||
struct snd_soc_codec *codec)
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
文件差异内容过多而无法显示
加载差异
@@ -1,6 +1,6 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef _WCD9XXX_COMMON_V2
|
||||
@@ -141,15 +141,15 @@ struct wcd_reg_mask_val {
|
||||
u8 val;
|
||||
};
|
||||
|
||||
extern void wcd_clsh_fsm(struct snd_soc_codec *codec,
|
||||
extern void wcd_clsh_fsm(struct snd_soc_component *component,
|
||||
struct wcd_clsh_cdc_data *cdc_clsh_d,
|
||||
u8 clsh_event, u8 req_state,
|
||||
int int_mode);
|
||||
|
||||
extern void wcd_clsh_init(struct wcd_clsh_cdc_data *clsh);
|
||||
extern int wcd_clsh_get_clsh_state(struct wcd_clsh_cdc_data *clsh);
|
||||
extern void wcd_clsh_imped_config(struct snd_soc_codec *codec, int imped,
|
||||
bool reset);
|
||||
extern void wcd_clsh_imped_config(struct snd_soc_component *component,
|
||||
int imped, bool reset);
|
||||
|
||||
enum {
|
||||
RESERVED = 0,
|
||||
|
@@ -9,7 +9,7 @@
|
||||
#include <linux/regmap.h>
|
||||
#include "core.h"
|
||||
|
||||
typedef int (*regmap_patch_fptr)(struct regmap *, int);
|
||||
typedef int (*regmap_patch_fptr)(struct regmap *regmap, int version);
|
||||
|
||||
extern struct regmap_config wcd934x_regmap_config;
|
||||
extern int wcd934x_regmap_register_patch(struct regmap *regmap,
|
||||
|
@@ -49,8 +49,9 @@ static int wcd_resmgr_codec_reg_update_bits(struct wcd9xxx_resmgr_v2 *resmgr,
|
||||
if (reg == WCD93XX_CLK_SYS_MCLK_PRG)
|
||||
return 0;
|
||||
}
|
||||
if (resmgr->codec) {
|
||||
ret = snd_soc_update_bits(resmgr->codec, reg, mask, val);
|
||||
if (resmgr->component) {
|
||||
ret = snd_soc_component_update_bits(resmgr->component, reg,
|
||||
mask, val);
|
||||
} else if (resmgr->core_res->wcd_core_regmap) {
|
||||
ret = regmap_update_bits_check(
|
||||
resmgr->core_res->wcd_core_regmap,
|
||||
@@ -77,8 +78,8 @@ static int wcd_resmgr_codec_reg_read(struct wcd9xxx_resmgr_v2 *resmgr,
|
||||
if (reg == WCD93XX_CLK_SYS_MCLK_PRG)
|
||||
return 0;
|
||||
}
|
||||
if (resmgr->codec) {
|
||||
val = snd_soc_read(resmgr->codec, reg);
|
||||
if (resmgr->component) {
|
||||
val = snd_soc_component_read32(resmgr->component, reg);
|
||||
} else if (resmgr->core_res->wcd_core_regmap) {
|
||||
ret = regmap_read(resmgr->core_res->wcd_core_regmap,
|
||||
reg, &val);
|
||||
@@ -114,8 +115,8 @@ static void wcd_resmgr_cdc_specific_get_clk(struct wcd9xxx_resmgr_v2 *resmgr,
|
||||
if (resmgr->resmgr_cb &&
|
||||
resmgr->resmgr_cb->cdc_rco_ctrl) {
|
||||
while (clk_users--)
|
||||
resmgr->resmgr_cb->cdc_rco_ctrl(resmgr->codec,
|
||||
true);
|
||||
resmgr->resmgr_cb->cdc_rco_ctrl(
|
||||
resmgr->component, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -608,11 +609,11 @@ EXPORT_SYMBOL(wcd_resmgr_disable_clk_block);
|
||||
* wcd_resmgr_init: initialize wcd resource manager
|
||||
* @core_res: handle to struct wcd9xxx_core_resource
|
||||
*
|
||||
* Early init call without a handle to snd_soc_codec *
|
||||
* Early init call without a handle to snd_soc_component *
|
||||
*/
|
||||
struct wcd9xxx_resmgr_v2 *wcd_resmgr_init(
|
||||
struct wcd9xxx_core_resource *core_res,
|
||||
struct snd_soc_codec *codec)
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
struct wcd9xxx_resmgr_v2 *resmgr;
|
||||
struct wcd9xxx *wcd9xxx;
|
||||
@@ -634,7 +635,7 @@ struct wcd9xxx_resmgr_v2 *wcd_resmgr_init(
|
||||
resmgr->clk_mclk_users = 0;
|
||||
resmgr->clk_rco_users = 0;
|
||||
resmgr->master_bias_users = 0;
|
||||
resmgr->codec = codec;
|
||||
resmgr->component = component;
|
||||
resmgr->core_res = core_res;
|
||||
resmgr->sido_input_src = SIDO_SOURCE_INTERNAL;
|
||||
resmgr->codec_type = wcd9xxx->type;
|
||||
@@ -658,24 +659,24 @@ EXPORT_SYMBOL(wcd_resmgr_remove);
|
||||
* wcd_resmgr_post_init: post init call to assign codec handle
|
||||
* @resmgr: handle to struct wcd9xxx_resmgr_v2 created during early init
|
||||
* @resmgr_cb: codec callback function for resmgr
|
||||
* @codec: handle to struct snd_soc_codec
|
||||
* @component: handle to struct snd_soc_component
|
||||
*/
|
||||
int wcd_resmgr_post_init(struct wcd9xxx_resmgr_v2 *resmgr,
|
||||
const struct wcd_resmgr_cb *resmgr_cb,
|
||||
struct snd_soc_codec *codec)
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
if (!resmgr) {
|
||||
pr_err("%s: resmgr not allocated\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!codec) {
|
||||
if (!component) {
|
||||
pr_err("%s: Codec memory is NULL, nothing to post init\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
resmgr->codec = codec;
|
||||
resmgr->component = component;
|
||||
resmgr->resmgr_cb = resmgr_cb;
|
||||
|
||||
return 0;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
#ifndef __WCD9XXX_COMMON_V2_H__
|
||||
#define __WCD9XXX_COMMON_V2_H__
|
||||
@@ -20,11 +20,11 @@ enum {
|
||||
};
|
||||
|
||||
struct wcd_resmgr_cb {
|
||||
int (*cdc_rco_ctrl)(struct snd_soc_codec *, bool);
|
||||
int (*cdc_rco_ctrl)(struct snd_soc_component *component, bool enable);
|
||||
};
|
||||
|
||||
struct wcd9xxx_resmgr_v2 {
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
struct wcd9xxx_core_resource *core_res;
|
||||
|
||||
int master_bias_users;
|
||||
@@ -66,11 +66,11 @@ int wcd_resmgr_enable_master_bias(struct wcd9xxx_resmgr_v2 *resmgr);
|
||||
int wcd_resmgr_disable_master_bias(struct wcd9xxx_resmgr_v2 *resmgr);
|
||||
struct wcd9xxx_resmgr_v2 *wcd_resmgr_init(
|
||||
struct wcd9xxx_core_resource *core_res,
|
||||
struct snd_soc_codec *codec);
|
||||
struct snd_soc_component *component);
|
||||
void wcd_resmgr_remove(struct wcd9xxx_resmgr_v2 *resmgr);
|
||||
int wcd_resmgr_post_init(struct wcd9xxx_resmgr_v2 *resmgr,
|
||||
const struct wcd_resmgr_cb *resmgr_cb,
|
||||
struct snd_soc_codec *codec);
|
||||
struct snd_soc_component *component);
|
||||
int wcd_resmgr_enable_clk_block(struct wcd9xxx_resmgr_v2 *resmgr,
|
||||
enum wcd_clock_type type);
|
||||
int wcd_resmgr_disable_clk_block(struct wcd9xxx_resmgr_v2 *resmgr,
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __WCD9XXX_UTILS_H__
|
||||
@@ -20,10 +20,10 @@ int wcd9xxx_reset(struct device *dev);
|
||||
int wcd9xxx_reset_low(struct device *dev);
|
||||
int wcd9xxx_get_codec_info(struct device *dev);
|
||||
|
||||
typedef int (*codec_bringup_fn)(struct wcd9xxx *);
|
||||
typedef int (*codec_bringdown_fn)(struct wcd9xxx *);
|
||||
typedef int (*codec_type_fn)(struct wcd9xxx *,
|
||||
struct wcd9xxx_codec_type *);
|
||||
typedef int (*codec_bringup_fn)(struct wcd9xxx *dev);
|
||||
typedef int (*codec_bringdown_fn)(struct wcd9xxx *dev);
|
||||
typedef int (*codec_type_fn)(struct wcd9xxx *dev,
|
||||
struct wcd9xxx_codec_type *wcd_type);
|
||||
|
||||
codec_bringdown_fn wcd9xxx_bringdown_fn(int type);
|
||||
codec_bringup_fn wcd9xxx_bringup_fn(int type);
|
||||
|
@@ -92,7 +92,7 @@ struct cpe_lsm_ids {
|
||||
static struct wcd_cpe_core *core_d;
|
||||
static struct cpe_lsm_session
|
||||
*lsm_sessions[WCD_CPE_LSM_MAX_SESSIONS + 1];
|
||||
struct wcd_cpe_core * (*wcd_get_cpe_core)(struct snd_soc_codec *);
|
||||
struct wcd_cpe_core * (*wcd_get_cpe_core)(struct snd_soc_component *component);
|
||||
static struct wcd_cmi_afe_port_data afe_ports[WCD_CPE_AFE_MAX_PORTS + 1];
|
||||
static void wcd_cpe_svc_event_cb(const struct cpe_svc_notification *param);
|
||||
static int wcd_cpe_setup_irqs(struct wcd_cpe_core *core);
|
||||
@@ -370,7 +370,7 @@ static int wcd_cpe_enable_cpe_clks(struct wcd_cpe_core *core, bool enable)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = core->cpe_cdc_cb->cdc_clk_en(core->codec, enable);
|
||||
ret = core->cpe_cdc_cb->cdc_clk_en(core->component, enable);
|
||||
if (ret) {
|
||||
dev_err(core->dev, "%s: Failed to enable RCO\n",
|
||||
__func__);
|
||||
@@ -385,7 +385,7 @@ static int wcd_cpe_enable_cpe_clks(struct wcd_cpe_core *core, bool enable)
|
||||
* and be disabled at the last time.
|
||||
*/
|
||||
if (core->cpe_clk_ref == 0) {
|
||||
ret = core->cpe_cdc_cb->cpe_clk_en(core->codec, enable);
|
||||
ret = core->cpe_cdc_cb->cpe_clk_en(core->component, enable);
|
||||
if (ret) {
|
||||
dev_err(core->dev,
|
||||
"%s: cpe_clk_en() failed, err = %d\n",
|
||||
@@ -402,7 +402,7 @@ static int wcd_cpe_enable_cpe_clks(struct wcd_cpe_core *core, bool enable)
|
||||
cpe_clk_fail:
|
||||
/* Release the codec clk if CPE clk enable failed */
|
||||
if (enable) {
|
||||
ret1 = core->cpe_cdc_cb->cdc_clk_en(core->codec, !enable);
|
||||
ret1 = core->cpe_cdc_cb->cdc_clk_en(core->component, !enable);
|
||||
if (ret1)
|
||||
dev_err(core->dev,
|
||||
"%s: Fail to release codec clk, err = %d\n",
|
||||
@@ -434,7 +434,7 @@ static int wcd_cpe_bus_vote_max_bw(struct wcd_cpe_core *core,
|
||||
if (core->cpe_cdc_cb->bus_vote_bw) {
|
||||
dev_dbg(core->dev, "%s: %s cdc bus max bandwidth\n",
|
||||
__func__, vote ? "Vote" : "Unvote");
|
||||
core->cpe_cdc_cb->bus_vote_bw(core->codec, vote);
|
||||
core->cpe_cdc_cb->bus_vote_bw(core->component, vote);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -454,7 +454,7 @@ static int wcd_cpe_load_fw(struct wcd_cpe_core *core,
|
||||
{
|
||||
|
||||
int ret, phdr_idx;
|
||||
struct snd_soc_codec *codec = NULL;
|
||||
struct snd_soc_component *component = NULL;
|
||||
struct wcd9xxx *wcd9xxx = NULL;
|
||||
const struct elf32_hdr *ehdr;
|
||||
const struct elf32_phdr *phdr;
|
||||
@@ -469,8 +469,8 @@ static int wcd_cpe_load_fw(struct wcd_cpe_core *core,
|
||||
core);
|
||||
return -EINVAL;
|
||||
}
|
||||
codec = core->codec;
|
||||
wcd9xxx = dev_get_drvdata(codec->dev->parent);
|
||||
component = core->component;
|
||||
wcd9xxx = dev_get_drvdata(component->dev->parent);
|
||||
snprintf(mdt_name, sizeof(mdt_name), "%s.mdt", core->fname);
|
||||
ret = request_firmware(&fw, mdt_name, core->dev);
|
||||
if (ret < 0) {
|
||||
@@ -617,32 +617,32 @@ static void wcd_cpe_load_fw_image(struct work_struct *work)
|
||||
|
||||
/*
|
||||
* wcd_cpe_get_core_handle: get the handle to wcd_cpe_core
|
||||
* @codec: codec from which this handle is to be obtained
|
||||
* @component: codec from which this handle is to be obtained
|
||||
* Codec driver should provide a callback function to obtain
|
||||
* handle to wcd_cpe_core during initialization of wcd_cpe_core
|
||||
*/
|
||||
void *wcd_cpe_get_core_handle(
|
||||
struct snd_soc_codec *codec)
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
struct wcd_cpe_core *core = NULL;
|
||||
|
||||
if (!codec) {
|
||||
if (!component) {
|
||||
pr_err("%s: Invalid codec handle\n",
|
||||
__func__);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!wcd_get_cpe_core) {
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s: codec callback not available\n",
|
||||
__func__);
|
||||
goto done;
|
||||
}
|
||||
|
||||
core = wcd_get_cpe_core(codec);
|
||||
core = wcd_get_cpe_core(component);
|
||||
|
||||
if (!core)
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s: handle to core not available\n",
|
||||
__func__);
|
||||
done:
|
||||
@@ -1018,7 +1018,7 @@ static void wcd_cpe_ssr_work(struct work_struct *work)
|
||||
if (core->ssr_type == WCD_CPE_SSR_EVENT) {
|
||||
if (CPE_ERR_IRQ_CB(core))
|
||||
core->cpe_cdc_cb->cpe_err_irq_control(
|
||||
core->codec,
|
||||
core->component,
|
||||
CPE_ERR_IRQ_STATUS,
|
||||
&status);
|
||||
if (status & core->irq_info.cpe_fatal_irqs)
|
||||
@@ -1080,7 +1080,7 @@ static void wcd_cpe_ssr_work(struct work_struct *work)
|
||||
* error interrupts are cleared
|
||||
*/
|
||||
if (CPE_ERR_IRQ_CB(core))
|
||||
core->cpe_cdc_cb->cpe_err_irq_control(core->codec,
|
||||
core->cpe_cdc_cb->cpe_err_irq_control(core->component,
|
||||
CPE_ERR_IRQ_CLEAR, NULL);
|
||||
|
||||
err_ret:
|
||||
@@ -1178,7 +1178,7 @@ static irqreturn_t svass_exception_irq(int irq, void *data)
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
core->cpe_cdc_cb->cpe_err_irq_control(core->codec,
|
||||
core->cpe_cdc_cb->cpe_err_irq_control(core->component,
|
||||
CPE_ERR_IRQ_STATUS, &status);
|
||||
|
||||
while (status != 0) {
|
||||
@@ -1198,18 +1198,18 @@ static irqreturn_t svass_exception_irq(int irq, void *data)
|
||||
* Mask the interrupt that was raised to
|
||||
* avoid spurious interrupts
|
||||
*/
|
||||
core->cpe_cdc_cb->cpe_err_irq_control(core->codec,
|
||||
core->cpe_cdc_cb->cpe_err_irq_control(core->component,
|
||||
CPE_ERR_IRQ_MASK, &status);
|
||||
|
||||
/* Clear only the interrupt that was raised */
|
||||
core->cpe_cdc_cb->cpe_err_irq_control(core->codec,
|
||||
core->cpe_cdc_cb->cpe_err_irq_control(core->component,
|
||||
CPE_ERR_IRQ_CLEAR, &status);
|
||||
dev_err(core->dev,
|
||||
"%s: err_interrupt status = 0x%x\n",
|
||||
__func__, status);
|
||||
|
||||
/* Read status for pending interrupts */
|
||||
core->cpe_cdc_cb->cpe_err_irq_control(core->codec,
|
||||
core->cpe_cdc_cb->cpe_err_irq_control(core->component,
|
||||
CPE_ERR_IRQ_STATUS, &status);
|
||||
}
|
||||
|
||||
@@ -1329,7 +1329,7 @@ static void wcd_cpe_deinitialize_afe_port_data(void)
|
||||
*/
|
||||
static void wcd_cpe_svc_event_cb(const struct cpe_svc_notification *param)
|
||||
{
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
struct wcd_cpe_core *core;
|
||||
struct cpe_svc_boot_event *boot_data;
|
||||
bool active_sessions;
|
||||
@@ -1339,14 +1339,14 @@ static void wcd_cpe_svc_event_cb(const struct cpe_svc_notification *param)
|
||||
return;
|
||||
}
|
||||
|
||||
codec = param->private_data;
|
||||
if (!codec) {
|
||||
component = param->private_data;
|
||||
if (!component) {
|
||||
pr_err("%s: Invalid handle to codec\n",
|
||||
__func__);
|
||||
return;
|
||||
}
|
||||
|
||||
core = wcd_cpe_get_core_handle(codec);
|
||||
core = wcd_cpe_get_core_handle(component);
|
||||
if (!core) {
|
||||
pr_err("%s: Invalid handle to core\n",
|
||||
__func__);
|
||||
@@ -1422,8 +1422,8 @@ static void wcd_cpe_svc_event_cb(const struct cpe_svc_notification *param)
|
||||
static void wcd_cpe_cleanup_irqs(struct wcd_cpe_core *core)
|
||||
{
|
||||
|
||||
struct snd_soc_codec *codec = core->codec;
|
||||
struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
|
||||
struct snd_soc_component *component = core->component;
|
||||
struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent);
|
||||
struct wcd9xxx_core_resource *core_res = &wcd9xxx->core_res;
|
||||
|
||||
wcd9xxx_free_irq(core_res,
|
||||
@@ -1444,8 +1444,8 @@ static void wcd_cpe_cleanup_irqs(struct wcd_cpe_core *core)
|
||||
static int wcd_cpe_setup_irqs(struct wcd_cpe_core *core)
|
||||
{
|
||||
int ret;
|
||||
struct snd_soc_codec *codec = core->codec;
|
||||
struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
|
||||
struct snd_soc_component *component = core->component;
|
||||
struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent);
|
||||
struct wcd9xxx_core_resource *core_res = &wcd9xxx->core_res;
|
||||
|
||||
ret = wcd9xxx_request_irq(core_res,
|
||||
@@ -1461,14 +1461,14 @@ static int wcd_cpe_setup_irqs(struct wcd_cpe_core *core)
|
||||
/* Make sure all error interrupts are cleared */
|
||||
if (CPE_ERR_IRQ_CB(core))
|
||||
core->cpe_cdc_cb->cpe_err_irq_control(
|
||||
core->codec,
|
||||
core->component,
|
||||
CPE_ERR_IRQ_CLEAR,
|
||||
NULL);
|
||||
|
||||
/* Enable required error interrupts */
|
||||
if (CPE_ERR_IRQ_CB(core))
|
||||
core->cpe_cdc_cb->cpe_err_irq_control(
|
||||
core->codec,
|
||||
core->component,
|
||||
CPE_ERR_IRQ_UNMASK,
|
||||
NULL);
|
||||
|
||||
@@ -1854,27 +1854,27 @@ done:
|
||||
}
|
||||
|
||||
static int wcd_cpe_validate_params(
|
||||
struct snd_soc_codec *codec,
|
||||
struct snd_soc_component *component,
|
||||
struct wcd_cpe_params *params)
|
||||
{
|
||||
|
||||
if (!codec) {
|
||||
if (!component) {
|
||||
pr_err("%s: Invalid codec\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!params) {
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s: No params supplied for codec %s\n",
|
||||
__func__, codec->component.name);
|
||||
__func__, component->name);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!params->codec || !params->get_cpe_core ||
|
||||
if (!params->component || !params->get_cpe_core ||
|
||||
!params->cdc_cb) {
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s: Invalid params for codec %s\n",
|
||||
__func__, codec->component.name);
|
||||
__func__, component->name);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -1884,14 +1884,14 @@ static int wcd_cpe_validate_params(
|
||||
/*
|
||||
* wcd_cpe_init: Initialize CPE related structures
|
||||
* @img_fname: filename for firmware image
|
||||
* @codec: handle to codec requesting for image download
|
||||
* @component: handle to codec requesting for image download
|
||||
* @params: parameter structure passed from caller
|
||||
*
|
||||
* This API will initialize the cpe core but will not
|
||||
* download the image or boot the cpe core.
|
||||
*/
|
||||
struct wcd_cpe_core *wcd_cpe_init(const char *img_fname,
|
||||
struct snd_soc_codec *codec,
|
||||
struct snd_soc_component *component,
|
||||
struct wcd_cpe_params *params)
|
||||
{
|
||||
struct wcd_cpe_core *core;
|
||||
@@ -1904,7 +1904,7 @@ struct wcd_cpe_core *wcd_cpe_init(const char *img_fname,
|
||||
const struct cpe_svc_hw_cfg *hw_info;
|
||||
int id = 0;
|
||||
|
||||
if (wcd_cpe_validate_params(codec, params))
|
||||
if (wcd_cpe_validate_params(component, params))
|
||||
return NULL;
|
||||
|
||||
core = kzalloc(sizeof(struct wcd_cpe_core), GFP_KERNEL);
|
||||
@@ -1916,8 +1916,8 @@ struct wcd_cpe_core *wcd_cpe_init(const char *img_fname,
|
||||
|
||||
wcd_get_cpe_core = params->get_cpe_core;
|
||||
|
||||
core->codec = params->codec;
|
||||
core->dev = params->codec->dev;
|
||||
core->component = params->component;
|
||||
core->dev = params->component->dev;
|
||||
core->cpe_debug_mode = params->dbg_mode;
|
||||
|
||||
core->cdc_info.major_version = params->cdc_major_ver;
|
||||
@@ -1969,7 +1969,7 @@ struct wcd_cpe_core *wcd_cpe_init(const char *img_fname,
|
||||
goto fail_cpe_register;
|
||||
}
|
||||
|
||||
card = codec->component.card->snd_card;
|
||||
card = component->card->snd_card;
|
||||
snprintf(proc_name, (sizeof("cpe") + sizeof("_state") +
|
||||
sizeof(id) - 2), "%s%d%s", cpe_name, id, state_name);
|
||||
entry = snd_info_create_card_entry(card, proc_name,
|
||||
@@ -3248,10 +3248,10 @@ static int wcd_cpe_lsm_get_afe_out_port_id(void *core_handle,
|
||||
struct cpe_lsm_session *session)
|
||||
{
|
||||
struct wcd_cpe_core *core = core_handle;
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
int rc = 0;
|
||||
|
||||
if (!core || !core->codec) {
|
||||
if (!core || !core->component) {
|
||||
pr_err("%s: Invalid handle to %s\n",
|
||||
__func__,
|
||||
(!core) ? "core" : "codec");
|
||||
@@ -3275,8 +3275,8 @@ static int wcd_cpe_lsm_get_afe_out_port_id(void *core_handle,
|
||||
goto done;
|
||||
}
|
||||
|
||||
codec = core->codec;
|
||||
rc = core->cpe_cdc_cb->get_afe_out_port_id(codec,
|
||||
component = core->component;
|
||||
rc = core->cpe_cdc_cb->get_afe_out_port_id(component,
|
||||
&session->afe_out_port_id);
|
||||
if (rc) {
|
||||
dev_err(core->dev,
|
||||
@@ -3667,11 +3667,11 @@ static int wcd_cpe_lab_ch_setup(void *core_handle,
|
||||
enum wcd_cpe_event event)
|
||||
{
|
||||
struct wcd_cpe_core *core = core_handle;
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
int rc = 0;
|
||||
u8 cpe_intr_bits;
|
||||
|
||||
if (!core || !core->codec) {
|
||||
if (!core || !core->component) {
|
||||
pr_err("%s: Invalid handle to %s\n",
|
||||
__func__,
|
||||
(!core) ? "core" : "codec");
|
||||
@@ -3689,14 +3689,14 @@ static int wcd_cpe_lab_ch_setup(void *core_handle,
|
||||
goto done;
|
||||
}
|
||||
|
||||
codec = core->codec;
|
||||
component = core->component;
|
||||
dev_dbg(core->dev,
|
||||
"%s: event = 0x%x\n",
|
||||
__func__, event);
|
||||
|
||||
switch (event) {
|
||||
case WCD_CPE_PRE_ENABLE:
|
||||
rc = core->cpe_cdc_cb->cdc_ext_clk(codec, true, false);
|
||||
rc = core->cpe_cdc_cb->cdc_ext_clk(component, true, false);
|
||||
if (rc) {
|
||||
dev_err(core->dev,
|
||||
"%s: failed to enable cdc clk, err = %d\n",
|
||||
@@ -3704,13 +3704,14 @@ static int wcd_cpe_lab_ch_setup(void *core_handle,
|
||||
goto done;
|
||||
}
|
||||
|
||||
rc = core->cpe_cdc_cb->lab_cdc_ch_ctl(codec,
|
||||
rc = core->cpe_cdc_cb->lab_cdc_ch_ctl(component,
|
||||
true);
|
||||
if (rc) {
|
||||
dev_err(core->dev,
|
||||
"%s: failed to enable cdc port, err = %d\n",
|
||||
__func__, rc);
|
||||
rc = core->cpe_cdc_cb->cdc_ext_clk(codec, false, false);
|
||||
rc = core->cpe_cdc_cb->cdc_ext_clk(
|
||||
component, false, false);
|
||||
goto done;
|
||||
}
|
||||
|
||||
@@ -3731,11 +3732,11 @@ static int wcd_cpe_lab_ch_setup(void *core_handle,
|
||||
cpe_intr_bits = ~(core->irq_info.cpe_fatal_irqs & 0xFF);
|
||||
if (CPE_ERR_IRQ_CB(core))
|
||||
core->cpe_cdc_cb->cpe_err_irq_control(
|
||||
core->codec,
|
||||
core->component,
|
||||
CPE_ERR_IRQ_MASK,
|
||||
&cpe_intr_bits);
|
||||
|
||||
rc = core->cpe_cdc_cb->lab_cdc_ch_ctl(codec,
|
||||
rc = core->cpe_cdc_cb->lab_cdc_ch_ctl(component,
|
||||
false);
|
||||
if (rc)
|
||||
dev_err(core->dev,
|
||||
@@ -3757,7 +3758,7 @@ static int wcd_cpe_lab_ch_setup(void *core_handle,
|
||||
"%s: Failed to disable lab\n", __func__);
|
||||
|
||||
/* Continue with disabling even if toggle lab fails */
|
||||
rc = core->cpe_cdc_cb->cdc_ext_clk(codec, false, false);
|
||||
rc = core->cpe_cdc_cb->cdc_ext_clk(component, false, false);
|
||||
if (rc)
|
||||
dev_err(core->dev,
|
||||
"%s: failed to disable cdc clk, err = %d\n",
|
||||
@@ -3767,7 +3768,7 @@ static int wcd_cpe_lab_ch_setup(void *core_handle,
|
||||
cpe_intr_bits = ~(core->irq_info.cpe_fatal_irqs & 0xFF);
|
||||
if (CPE_ERR_IRQ_CB(core))
|
||||
core->cpe_cdc_cb->cpe_err_irq_control(
|
||||
core->codec,
|
||||
core->component,
|
||||
CPE_ERR_IRQ_UNMASK,
|
||||
&cpe_intr_bits);
|
||||
break;
|
||||
@@ -3907,7 +3908,7 @@ done:
|
||||
/*
|
||||
* wcd_cpe_get_lsm_ops: register lsm driver to codec
|
||||
* @lsm_ops: structure with lsm callbacks
|
||||
* @codec: codec to which this lsm driver is registered to
|
||||
* @component: codec to which this lsm driver is registered to
|
||||
*/
|
||||
int wcd_cpe_get_lsm_ops(struct wcd_cpe_lsm_ops *lsm_ops)
|
||||
{
|
||||
|
@@ -50,18 +50,20 @@ enum cpe_err_irq_cntl_type {
|
||||
|
||||
struct wcd_cpe_cdc_cb {
|
||||
/* codec provided callback to enable RCO */
|
||||
int (*cdc_clk_en)(struct snd_soc_codec *, bool);
|
||||
int (*cdc_clk_en)(struct snd_soc_component *cpmponent, bool enable);
|
||||
|
||||
/* callback for FLL setup for codec */
|
||||
int (*cpe_clk_en)(struct snd_soc_codec *, bool);
|
||||
int (*cdc_ext_clk)(struct snd_soc_codec *codec, int enable, bool dapm);
|
||||
int (*lab_cdc_ch_ctl)(struct snd_soc_codec *codec, u8 event);
|
||||
int (*get_afe_out_port_id)(struct snd_soc_codec *codec, u16 *port_id);
|
||||
int (*bus_vote_bw)(struct snd_soc_codec *codec,
|
||||
int (*cpe_clk_en)(struct snd_soc_component *component, bool enable);
|
||||
int (*cdc_ext_clk)(struct snd_soc_component *component, int enable,
|
||||
bool dapm);
|
||||
int (*lab_cdc_ch_ctl)(struct snd_soc_component *component, u8 event);
|
||||
int (*get_afe_out_port_id)(struct snd_soc_component *component,
|
||||
u16 *port_id);
|
||||
int (*bus_vote_bw)(struct snd_soc_component *component,
|
||||
bool vote);
|
||||
|
||||
/* Callback to control the cpe error interrupt mask/status/clear */
|
||||
int (*cpe_err_irq_control)(struct snd_soc_codec *codec,
|
||||
int (*cpe_err_irq_control)(struct snd_soc_component *component,
|
||||
enum cpe_err_irq_cntl_type cntl_type,
|
||||
u8 *status);
|
||||
};
|
||||
@@ -114,7 +116,7 @@ struct wcd_cpe_core {
|
||||
void *cmi_afe_handle;
|
||||
|
||||
/* handle to codec */
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
|
||||
/* codec device */
|
||||
struct device *dev;
|
||||
@@ -200,9 +202,9 @@ struct wcd_cpe_core {
|
||||
};
|
||||
|
||||
struct wcd_cpe_params {
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
struct wcd_cpe_core * (*get_cpe_core)(
|
||||
struct snd_soc_codec *);
|
||||
struct snd_soc_component *component);
|
||||
const struct wcd_cpe_cdc_cb *cdc_cb;
|
||||
int dbg_mode;
|
||||
u16 cdc_major_ver;
|
||||
@@ -218,7 +220,7 @@ struct wcd_cpe_params {
|
||||
int wcd_cpe_ssr_event(void *core_handle,
|
||||
enum wcd_cpe_ssr_state_event event);
|
||||
struct wcd_cpe_core *wcd_cpe_init(const char *img_fname,
|
||||
struct snd_soc_codec *codec, struct wcd_cpe_params *params);
|
||||
struct snd_soc_component *component, struct wcd_cpe_params *params);
|
||||
#else /* CONFIG_SND_SOC_WCD_CPE */
|
||||
static inline int wcd_cpe_ssr_event(void *core_handle,
|
||||
enum wcd_cpe_ssr_state_event event)
|
||||
@@ -226,7 +228,7 @@ static inline int wcd_cpe_ssr_event(void *core_handle,
|
||||
return 0;
|
||||
}
|
||||
static inline struct wcd_cpe_core *wcd_cpe_init(const char *img_fname,
|
||||
struct snd_soc_codec *codec,
|
||||
struct snd_soc_component *component,
|
||||
struct wcd_cpe_params *params)
|
||||
{
|
||||
return NULL;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2015, 2017-2018 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
*/
|
||||
#include <linux/kernel.h>
|
||||
@@ -152,7 +152,8 @@ static int wcdcal_hwdep_release(struct snd_hwdep *hw, struct file *file)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wcd_cal_create_hwdep(void *data, int node, struct snd_soc_codec *codec)
|
||||
int wcd_cal_create_hwdep(void *data, int node,
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
char hwname[40];
|
||||
struct snd_hwdep *hwdep;
|
||||
@@ -160,23 +161,23 @@ int wcd_cal_create_hwdep(void *data, int node, struct snd_soc_codec *codec)
|
||||
struct fw_info *fw_data = data;
|
||||
int err, cal_bit;
|
||||
|
||||
if (!fw_data || !codec) {
|
||||
if (!fw_data || !component) {
|
||||
pr_err("%s: wrong arguments passed\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
fw = fw_data->fw;
|
||||
snprintf(hwname, strlen("Codec %s"), "Codec %s",
|
||||
codec->component.name);
|
||||
err = snd_hwdep_new(codec->component.card->snd_card,
|
||||
component->name);
|
||||
err = snd_hwdep_new(component->card->snd_card,
|
||||
hwname, node, &hwdep);
|
||||
if (err < 0) {
|
||||
dev_err(codec->dev, "%s: new hwdep failed %d\n",
|
||||
dev_err(component->dev, "%s: new hwdep failed %d\n",
|
||||
__func__, err);
|
||||
return err;
|
||||
}
|
||||
snprintf(hwdep->name, strlen("Codec %s"), "Codec %s",
|
||||
codec->component.name);
|
||||
component->name);
|
||||
hwdep->iface = SNDRV_HWDEP_IFACE_AUDIO_CODEC;
|
||||
hwdep->private_data = fw_data;
|
||||
hwdep->ops.ioctl_compat = wcdcal_hwdep_ioctl_compat;
|
||||
@@ -188,12 +189,9 @@ int wcd_cal_create_hwdep(void *data, int node, struct snd_soc_codec *codec)
|
||||
set_bit(WCDCAL_UNINITIALISED,
|
||||
&fw_data->wcdcal_state[cal_bit]);
|
||||
fw[cal_bit] = kzalloc(sizeof *(fw[cal_bit]), GFP_KERNEL);
|
||||
if (!fw[cal_bit]) {
|
||||
dev_err(codec->dev, "%s: no memory for %s cal\n",
|
||||
__func__, cal_name_info[cal_bit]);
|
||||
if (!fw[cal_bit])
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
for_each_set_bit(cal_bit, fw_data->cal_bit, WCD9XXX_MAX_CAL) {
|
||||
fw[cal_bit]->data = kzalloc(cal_size_info[cal_bit],
|
||||
GFP_KERNEL);
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright (c) 2014, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2014, 2018, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
#ifndef __WCD9XXX_HWDEP_H__
|
||||
#define __WCD9XXX_HWDEP_H__
|
||||
@@ -26,7 +26,8 @@ struct firmware_cal {
|
||||
};
|
||||
|
||||
struct snd_soc_codec;
|
||||
int wcd_cal_create_hwdep(void *fw, int node, struct snd_soc_codec *codec);
|
||||
int wcd_cal_create_hwdep(void *fw, int node,
|
||||
struct snd_soc_component *component);
|
||||
struct firmware_cal *wcdcal_get_fw_cal(struct fw_info *fw_data,
|
||||
enum wcd_cal_type type);
|
||||
#endif /* __WCD9XXX_HWDEP_H__ */
|
||||
|
@@ -30,7 +30,7 @@ int wsa881x_get_temp(struct thermal_zone_device *thermal,
|
||||
int *temp)
|
||||
{
|
||||
struct wsa881x_tz_priv *pdata;
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
struct wsa_temp_register reg;
|
||||
int dmeas, d1, d2;
|
||||
int ret = 0;
|
||||
@@ -44,8 +44,8 @@ int wsa881x_get_temp(struct thermal_zone_device *thermal,
|
||||
|
||||
if (thermal->devdata) {
|
||||
pdata = thermal->devdata;
|
||||
if (pdata->codec) {
|
||||
codec = pdata->codec;
|
||||
if (pdata->component) {
|
||||
component = pdata->component;
|
||||
} else {
|
||||
pr_err("%s: codec is NULL\n", __func__);
|
||||
return -EINVAL;
|
||||
@@ -70,7 +70,7 @@ int wsa881x_get_temp(struct thermal_zone_device *thermal,
|
||||
|
||||
temp_retry:
|
||||
if (pdata->wsa_temp_reg_read) {
|
||||
ret = pdata->wsa_temp_reg_read(codec, ®);
|
||||
ret = pdata->wsa_temp_reg_read(component, ®);
|
||||
if (ret) {
|
||||
pr_err("%s: temp read failed: %d, current temp: %d\n",
|
||||
__func__, ret, pdata->curr_temp);
|
||||
|
@@ -15,11 +15,11 @@ struct wsa_temp_register {
|
||||
u8 dmeas_msb;
|
||||
u8 dmeas_lsb;
|
||||
};
|
||||
typedef int32_t (*wsa_temp_register_read)(struct snd_soc_codec *codec,
|
||||
typedef int32_t (*wsa_temp_register_read)(struct snd_soc_component *component,
|
||||
struct wsa_temp_register *wsa_temp_reg);
|
||||
struct wsa881x_tz_priv {
|
||||
struct thermal_zone_device *tz_dev;
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
struct wsa_temp_register *wsa_temp_reg;
|
||||
char name[80];
|
||||
wsa_temp_register_read wsa_temp_reg_read;
|
||||
|
@@ -28,6 +28,7 @@
|
||||
#include "wsa881x.h"
|
||||
#include "wsa881x-temp-sensor.h"
|
||||
|
||||
#define DRV_NAME "wsa-codec"
|
||||
#define WSA881X_NUM_RETRY 5
|
||||
|
||||
enum {
|
||||
@@ -80,7 +81,7 @@ struct wsa881x_priv {
|
||||
struct regmap *regmap;
|
||||
struct device *dev;
|
||||
struct swr_device *swr_slave;
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
bool comp_enable;
|
||||
bool boost_enable;
|
||||
bool visense_enable;
|
||||
@@ -127,7 +128,7 @@ static struct dentry *debugfs_reg_dump;
|
||||
static unsigned int read_data;
|
||||
static unsigned int devnum;
|
||||
|
||||
static int32_t wsa881x_resource_acquire(struct snd_soc_codec *codec,
|
||||
static int32_t wsa881x_resource_acquire(struct snd_soc_component *component,
|
||||
bool enable);
|
||||
|
||||
static const char * const wsa_pa_gain_text[] = {
|
||||
@@ -142,12 +143,14 @@ static const struct soc_enum wsa_pa_gain_enum =
|
||||
static int wsa_pa_gain_get(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component);
|
||||
|
||||
ucontrol->value.integer.value[0] = wsa881x->pa_gain;
|
||||
|
||||
dev_dbg(codec->dev, "%s: PA gain = 0x%x\n", __func__, wsa881x->pa_gain);
|
||||
dev_dbg(component->dev, "%s: PA gain = 0x%x\n", __func__,
|
||||
wsa881x->pa_gain);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -155,10 +158,11 @@ static int wsa_pa_gain_get(struct snd_kcontrol *kcontrol,
|
||||
static int wsa_pa_gain_put(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component);
|
||||
|
||||
dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
|
||||
dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
|
||||
__func__, ucontrol->value.integer.value[0]);
|
||||
|
||||
wsa881x->pa_gain = ucontrol->value.integer.value[0];
|
||||
@@ -170,8 +174,9 @@ static int wsa881x_get_mute(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component);
|
||||
|
||||
ucontrol->value.integer.value[0] = wsa881x->pa_mute;
|
||||
|
||||
@@ -181,15 +186,17 @@ static int wsa881x_get_mute(struct snd_kcontrol *kcontrol,
|
||||
static int wsa881x_set_mute(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component);
|
||||
int value = ucontrol->value.integer.value[0];
|
||||
|
||||
dev_dbg(codec->dev, "%s: mute current %d, new %d\n",
|
||||
dev_dbg(component->dev, "%s: mute current %d, new %d\n",
|
||||
__func__, wsa881x->pa_mute, value);
|
||||
|
||||
if (value)
|
||||
snd_soc_update_bits(codec, WSA881X_SPKR_DRV_EN, 0x80, 0x00);
|
||||
snd_soc_component_update_bits(component, WSA881X_SPKR_DRV_EN,
|
||||
0x80, 0x00);
|
||||
wsa881x->pa_mute = value;
|
||||
|
||||
return 0;
|
||||
@@ -199,12 +206,13 @@ static int wsa881x_get_t0_init(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component);
|
||||
struct wsa881x_tz_priv *pdata = &wsa881x->tz_pdata;
|
||||
|
||||
ucontrol->value.integer.value[0] = pdata->t0_init;
|
||||
dev_dbg(codec->dev, "%s: t0 init %d\n", __func__, pdata->t0_init);
|
||||
dev_dbg(component->dev, "%s: t0 init %d\n", __func__, pdata->t0_init);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -212,12 +220,13 @@ static int wsa881x_get_t0_init(struct snd_kcontrol *kcontrol,
|
||||
static int wsa881x_set_t0_init(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component);
|
||||
struct wsa881x_tz_priv *pdata = &wsa881x->tz_pdata;
|
||||
|
||||
pdata->t0_init = ucontrol->value.integer.value[0];
|
||||
dev_dbg(codec->dev, "%s: t0 init %d\n", __func__, pdata->t0_init);
|
||||
dev_dbg(component->dev, "%s: t0 init %d\n", __func__, pdata->t0_init);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -286,7 +295,7 @@ static struct snd_info_entry_ops wsa881x_codec_info_ops = {
|
||||
/*
|
||||
* wsa881x_codec_info_create_codec_entry - creates wsa881x module
|
||||
* @codec_root: The parent directory
|
||||
* @codec: Codec instance
|
||||
* @component: Codec instance
|
||||
*
|
||||
* Creates wsa881x module and version entry under the given
|
||||
* parent directory.
|
||||
@@ -294,18 +303,18 @@ static struct snd_info_entry_ops wsa881x_codec_info_ops = {
|
||||
* Return: 0 on success or negative error code on failure.
|
||||
*/
|
||||
int wsa881x_codec_info_create_codec_entry(struct snd_info_entry *codec_root,
|
||||
struct snd_soc_codec *codec)
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
struct snd_info_entry *version_entry;
|
||||
struct wsa881x_priv *wsa881x;
|
||||
struct snd_soc_card *card;
|
||||
char name[80];
|
||||
|
||||
if (!codec_root || !codec)
|
||||
if (!codec_root || !component)
|
||||
return -EINVAL;
|
||||
|
||||
wsa881x = snd_soc_codec_get_drvdata(codec);
|
||||
card = codec->component.card;
|
||||
wsa881x = snd_soc_component_get_drvdata(component);
|
||||
card = component->card;
|
||||
snprintf(name, sizeof(name), "%s.%x", "wsa881x",
|
||||
(u32)wsa881x->swr_slave->addr);
|
||||
|
||||
@@ -313,7 +322,7 @@ int wsa881x_codec_info_create_codec_entry(struct snd_info_entry *codec_root,
|
||||
(const char *)name,
|
||||
codec_root);
|
||||
if (!wsa881x->entry) {
|
||||
dev_dbg(codec->dev, "%s: failed to create wsa881x entry\n",
|
||||
dev_dbg(component->dev, "%s: failed to create wsa881x entry\n",
|
||||
__func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
@@ -322,7 +331,7 @@ int wsa881x_codec_info_create_codec_entry(struct snd_info_entry *codec_root,
|
||||
"version",
|
||||
wsa881x->entry);
|
||||
if (!version_entry) {
|
||||
dev_dbg(codec->dev, "%s: failed to create wsa881x version entry\n",
|
||||
dev_dbg(component->dev, "%s: failed to create wsa881x version entry\n",
|
||||
__func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
@@ -530,13 +539,15 @@ static const struct reg_sequence wsa881x_vi_txfe_en_2_0[] = {
|
||||
{WSA881X_SPKR_PROT_FE_GAIN, 0x47, 0},
|
||||
};
|
||||
|
||||
static int wsa881x_boost_ctrl(struct snd_soc_codec *codec, bool enable)
|
||||
static int wsa881x_boost_ctrl(struct snd_soc_component *component, bool enable)
|
||||
{
|
||||
dev_dbg(codec->dev, "%s: enable:%d\n", __func__, enable);
|
||||
dev_dbg(component->dev, "%s: enable:%d\n", __func__, enable);
|
||||
if (enable)
|
||||
snd_soc_update_bits(codec, WSA881X_BOOST_EN_CTL, 0x80, 0x80);
|
||||
snd_soc_component_update_bits(component, WSA881X_BOOST_EN_CTL,
|
||||
0x80, 0x80);
|
||||
else
|
||||
snd_soc_update_bits(codec, WSA881X_BOOST_EN_CTL, 0x80, 0x00);
|
||||
snd_soc_component_update_bits(component, WSA881X_BOOST_EN_CTL,
|
||||
0x80, 0x00);
|
||||
/*
|
||||
* 1.5ms sleep is needed after boost enable/disable as per
|
||||
* HW requirement
|
||||
@@ -545,13 +556,13 @@ static int wsa881x_boost_ctrl(struct snd_soc_codec *codec, bool enable)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wsa881x_visense_txfe_ctrl(struct snd_soc_codec *codec, bool enable,
|
||||
u8 isense1_gain, u8 isense2_gain,
|
||||
u8 vsense_gain)
|
||||
static int wsa881x_visense_txfe_ctrl(struct snd_soc_component *component,
|
||||
bool enable, u8 isense1_gain,
|
||||
u8 isense2_gain, u8 vsense_gain)
|
||||
{
|
||||
struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component);
|
||||
|
||||
dev_dbg(codec->dev,
|
||||
dev_dbg(component->dev,
|
||||
"%s: enable:%d, isense1 gain: %d, isense2 gain: %d, vsense_gain %d\n",
|
||||
__func__, enable, isense1_gain, isense2_gain, vsense_gain);
|
||||
|
||||
@@ -560,45 +571,51 @@ static int wsa881x_visense_txfe_ctrl(struct snd_soc_codec *codec, bool enable,
|
||||
wsa881x_vi_txfe_en_2_0,
|
||||
ARRAY_SIZE(wsa881x_vi_txfe_en_2_0));
|
||||
} else {
|
||||
snd_soc_update_bits(codec, WSA881X_SPKR_PROT_FE_VSENSE_VCM,
|
||||
snd_soc_component_update_bits(component,
|
||||
WSA881X_SPKR_PROT_FE_VSENSE_VCM,
|
||||
0x08, 0x08);
|
||||
/*
|
||||
* 200us sleep is needed after visense txfe disable as per
|
||||
* HW requirement.
|
||||
*/
|
||||
usleep_range(200, 210);
|
||||
snd_soc_update_bits(codec, WSA881X_SPKR_PROT_FE_GAIN,
|
||||
snd_soc_component_update_bits(component,
|
||||
WSA881X_SPKR_PROT_FE_GAIN,
|
||||
0x01, 0x00);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wsa881x_visense_adc_ctrl(struct snd_soc_codec *codec, bool enable)
|
||||
static int wsa881x_visense_adc_ctrl(struct snd_soc_component *component,
|
||||
bool enable)
|
||||
{
|
||||
|
||||
dev_dbg(codec->dev, "%s: enable:%d\n", __func__, enable);
|
||||
snd_soc_update_bits(codec, WSA881X_ADC_EN_MODU_V, (0x01 << 7),
|
||||
(enable << 7));
|
||||
snd_soc_update_bits(codec, WSA881X_ADC_EN_MODU_I, (0x01 << 7),
|
||||
(enable << 7));
|
||||
dev_dbg(component->dev, "%s: enable:%d\n", __func__, enable);
|
||||
snd_soc_component_update_bits(component, WSA881X_ADC_EN_MODU_V,
|
||||
(0x01 << 7), (enable << 7));
|
||||
snd_soc_component_update_bits(component, WSA881X_ADC_EN_MODU_I,
|
||||
(0x01 << 7), (enable << 7));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void wsa881x_bandgap_ctrl(struct snd_soc_codec *codec, bool enable)
|
||||
static void wsa881x_bandgap_ctrl(struct snd_soc_component *component,
|
||||
bool enable)
|
||||
{
|
||||
struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component);
|
||||
|
||||
dev_dbg(codec->dev, "%s: enable:%d, bg_count:%d\n", __func__,
|
||||
dev_dbg(component->dev, "%s: enable:%d, bg_count:%d\n", __func__,
|
||||
enable, wsa881x->bg_cnt);
|
||||
mutex_lock(&wsa881x->bg_lock);
|
||||
if (enable) {
|
||||
++wsa881x->bg_cnt;
|
||||
if (wsa881x->bg_cnt == 1) {
|
||||
snd_soc_update_bits(codec, WSA881X_TEMP_OP,
|
||||
snd_soc_component_update_bits(component,
|
||||
WSA881X_TEMP_OP,
|
||||
0x08, 0x08);
|
||||
/* 400usec sleep is needed as per HW requirement */
|
||||
usleep_range(400, 410);
|
||||
snd_soc_update_bits(codec, WSA881X_TEMP_OP,
|
||||
snd_soc_component_update_bits(component,
|
||||
WSA881X_TEMP_OP,
|
||||
0x04, 0x04);
|
||||
}
|
||||
} else {
|
||||
@@ -606,33 +623,39 @@ static void wsa881x_bandgap_ctrl(struct snd_soc_codec *codec, bool enable)
|
||||
if (wsa881x->bg_cnt <= 0) {
|
||||
WARN_ON(wsa881x->bg_cnt < 0);
|
||||
wsa881x->bg_cnt = 0;
|
||||
snd_soc_update_bits(codec, WSA881X_TEMP_OP, 0x04, 0x00);
|
||||
snd_soc_update_bits(codec, WSA881X_TEMP_OP, 0x08, 0x00);
|
||||
snd_soc_component_update_bits(component,
|
||||
WSA881X_TEMP_OP, 0x04, 0x00);
|
||||
snd_soc_component_update_bits(component,
|
||||
WSA881X_TEMP_OP, 0x08, 0x00);
|
||||
}
|
||||
}
|
||||
mutex_unlock(&wsa881x->bg_lock);
|
||||
}
|
||||
|
||||
static void wsa881x_clk_ctrl(struct snd_soc_codec *codec, bool enable)
|
||||
static void wsa881x_clk_ctrl(struct snd_soc_component *component, bool enable)
|
||||
{
|
||||
struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component);
|
||||
|
||||
dev_dbg(codec->dev, "%s: enable:%d, clk_count:%d\n", __func__,
|
||||
dev_dbg(component->dev, "%s: enable:%d, clk_count:%d\n", __func__,
|
||||
enable, wsa881x->clk_cnt);
|
||||
mutex_lock(&wsa881x->res_lock);
|
||||
if (enable) {
|
||||
++wsa881x->clk_cnt;
|
||||
if (wsa881x->clk_cnt == 1) {
|
||||
snd_soc_write(codec, WSA881X_CDC_DIG_CLK_CTL, 0x01);
|
||||
snd_soc_write(codec, WSA881X_CDC_ANA_CLK_CTL, 0x01);
|
||||
snd_soc_component_write(component,
|
||||
WSA881X_CDC_DIG_CLK_CTL, 0x01);
|
||||
snd_soc_component_write(component,
|
||||
WSA881X_CDC_ANA_CLK_CTL, 0x01);
|
||||
}
|
||||
} else {
|
||||
--wsa881x->clk_cnt;
|
||||
if (wsa881x->clk_cnt <= 0) {
|
||||
WARN_ON(wsa881x->clk_cnt < 0);
|
||||
wsa881x->clk_cnt = 0;
|
||||
snd_soc_write(codec, WSA881X_CDC_DIG_CLK_CTL, 0x00);
|
||||
snd_soc_write(codec, WSA881X_CDC_ANA_CLK_CTL, 0x00);
|
||||
snd_soc_component_write(component,
|
||||
WSA881X_CDC_DIG_CLK_CTL, 0x00);
|
||||
snd_soc_component_write(component,
|
||||
WSA881X_CDC_ANA_CLK_CTL, 0x00);
|
||||
}
|
||||
}
|
||||
mutex_unlock(&wsa881x->res_lock);
|
||||
@@ -642,8 +665,9 @@ static int wsa881x_get_compander(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component);
|
||||
|
||||
ucontrol->value.integer.value[0] = wsa881x->comp_enable;
|
||||
return 0;
|
||||
@@ -652,11 +676,12 @@ static int wsa881x_get_compander(struct snd_kcontrol *kcontrol,
|
||||
static int wsa881x_set_compander(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component);
|
||||
int value = ucontrol->value.integer.value[0];
|
||||
|
||||
dev_dbg(codec->dev, "%s: Compander enable current %d, new %d\n",
|
||||
dev_dbg(component->dev, "%s: Compander enable current %d, new %d\n",
|
||||
__func__, wsa881x->comp_enable, value);
|
||||
wsa881x->comp_enable = value;
|
||||
return 0;
|
||||
@@ -666,8 +691,9 @@ static int wsa881x_get_boost(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component);
|
||||
|
||||
ucontrol->value.integer.value[0] = wsa881x->boost_enable;
|
||||
return 0;
|
||||
@@ -676,11 +702,12 @@ static int wsa881x_get_boost(struct snd_kcontrol *kcontrol,
|
||||
static int wsa881x_set_boost(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component);
|
||||
int value = ucontrol->value.integer.value[0];
|
||||
|
||||
dev_dbg(codec->dev, "%s: Boost enable current %d, new %d\n",
|
||||
dev_dbg(component->dev, "%s: Boost enable current %d, new %d\n",
|
||||
__func__, wsa881x->boost_enable, value);
|
||||
wsa881x->boost_enable = value;
|
||||
return 0;
|
||||
@@ -690,8 +717,9 @@ static int wsa881x_get_visense(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component);
|
||||
|
||||
ucontrol->value.integer.value[0] = wsa881x->visense_enable;
|
||||
return 0;
|
||||
@@ -700,11 +728,12 @@ static int wsa881x_get_visense(struct snd_kcontrol *kcontrol,
|
||||
static int wsa881x_set_visense(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component);
|
||||
int value = ucontrol->value.integer.value[0];
|
||||
|
||||
dev_dbg(codec->dev, "%s: VIsense enable current %d, new %d\n",
|
||||
dev_dbg(component->dev, "%s: VIsense enable current %d, new %d\n",
|
||||
__func__, wsa881x->visense_enable, value);
|
||||
wsa881x->visense_enable = value;
|
||||
return 0;
|
||||
@@ -713,14 +742,15 @@ static int wsa881x_set_visense(struct snd_kcontrol *kcontrol,
|
||||
static int wsa881x_set_boost_level(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
u8 wsa_boost_level = 0;
|
||||
|
||||
dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
|
||||
dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
|
||||
__func__, ucontrol->value.integer.value[0]);
|
||||
|
||||
wsa_boost_level = ucontrol->value.integer.value[0];
|
||||
snd_soc_update_bits(codec, WSA881X_BOOST_PRESET_OUT1,
|
||||
snd_soc_component_update_bits(component, WSA881X_BOOST_PRESET_OUT1,
|
||||
0xff, wsa_boost_level);
|
||||
|
||||
return 0;
|
||||
@@ -729,12 +759,14 @@ static int wsa881x_set_boost_level(struct snd_kcontrol *kcontrol,
|
||||
static int wsa881x_get_boost_level(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
u8 wsa_boost_level = 0;
|
||||
|
||||
wsa_boost_level = snd_soc_read(codec, WSA881X_BOOST_PRESET_OUT1);
|
||||
wsa_boost_level = snd_soc_component_read32(component,
|
||||
WSA881X_BOOST_PRESET_OUT1);
|
||||
ucontrol->value.integer.value[0] = wsa_boost_level;
|
||||
dev_dbg(codec->dev, "%s: boost level = 0x%x\n", __func__,
|
||||
dev_dbg(component->dev, "%s: boost level = 0x%x\n", __func__,
|
||||
wsa_boost_level);
|
||||
|
||||
return 0;
|
||||
@@ -758,11 +790,11 @@ static const struct snd_kcontrol_new swr_dac_port[] = {
|
||||
SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0)
|
||||
};
|
||||
|
||||
static int wsa881x_set_port(struct snd_soc_codec *codec, int port_idx,
|
||||
static int wsa881x_set_port(struct snd_soc_component *component, int port_idx,
|
||||
u8 *port_id, u8 *num_ch, u8 *ch_mask, u32 *ch_rate,
|
||||
u8 *port_type)
|
||||
{
|
||||
struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component);
|
||||
|
||||
*port_id = wsa881x->port[port_idx].port_id;
|
||||
*num_ch = wsa881x->port[port_idx].num_ch;
|
||||
@@ -775,8 +807,9 @@ static int wsa881x_set_port(struct snd_soc_codec *codec, int port_idx,
|
||||
static int wsa881x_enable_swr_dac_port(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_dapm_to_component(w->dapm);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component);
|
||||
u8 port_id[WSA881X_MAX_SWR_PORTS];
|
||||
u8 num_ch[WSA881X_MAX_SWR_PORTS];
|
||||
u8 ch_mask[WSA881X_MAX_SWR_PORTS];
|
||||
@@ -784,35 +817,35 @@ static int wsa881x_enable_swr_dac_port(struct snd_soc_dapm_widget *w,
|
||||
u8 port_type[WSA881X_MAX_SWR_PORTS];
|
||||
u8 num_port = 0;
|
||||
|
||||
dev_dbg(codec->dev, "%s: event %d name %s\n", __func__,
|
||||
dev_dbg(component->dev, "%s: event %d name %s\n", __func__,
|
||||
event, w->name);
|
||||
if (wsa881x == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_PRE_PMU:
|
||||
wsa881x_set_port(codec, SWR_DAC_PORT,
|
||||
wsa881x_set_port(component, SWR_DAC_PORT,
|
||||
&port_id[num_port], &num_ch[num_port],
|
||||
&ch_mask[num_port], &ch_rate[num_port],
|
||||
&port_type[num_port]);
|
||||
++num_port;
|
||||
|
||||
if (wsa881x->comp_enable) {
|
||||
wsa881x_set_port(codec, SWR_COMP_PORT,
|
||||
wsa881x_set_port(component, SWR_COMP_PORT,
|
||||
&port_id[num_port], &num_ch[num_port],
|
||||
&ch_mask[num_port], &ch_rate[num_port],
|
||||
&port_type[num_port]);
|
||||
++num_port;
|
||||
}
|
||||
if (wsa881x->boost_enable) {
|
||||
wsa881x_set_port(codec, SWR_BOOST_PORT,
|
||||
wsa881x_set_port(component, SWR_BOOST_PORT,
|
||||
&port_id[num_port], &num_ch[num_port],
|
||||
&ch_mask[num_port], &ch_rate[num_port],
|
||||
&port_type[num_port]);
|
||||
++num_port;
|
||||
}
|
||||
if (wsa881x->visense_enable) {
|
||||
wsa881x_set_port(codec, SWR_VISENSE_PORT,
|
||||
wsa881x_set_port(component, SWR_VISENSE_PORT,
|
||||
&port_id[num_port], &num_ch[num_port],
|
||||
&ch_mask[num_port], &ch_rate[num_port],
|
||||
&port_type[num_port]);
|
||||
@@ -827,28 +860,28 @@ static int wsa881x_enable_swr_dac_port(struct snd_soc_dapm_widget *w,
|
||||
case SND_SOC_DAPM_PRE_PMD:
|
||||
break;
|
||||
case SND_SOC_DAPM_POST_PMD:
|
||||
wsa881x_set_port(codec, SWR_DAC_PORT,
|
||||
wsa881x_set_port(component, SWR_DAC_PORT,
|
||||
&port_id[num_port], &num_ch[num_port],
|
||||
&ch_mask[num_port], &ch_rate[num_port],
|
||||
&port_type[num_port]);
|
||||
++num_port;
|
||||
|
||||
if (wsa881x->comp_enable) {
|
||||
wsa881x_set_port(codec, SWR_COMP_PORT,
|
||||
wsa881x_set_port(component, SWR_COMP_PORT,
|
||||
&port_id[num_port], &num_ch[num_port],
|
||||
&ch_mask[num_port], &ch_rate[num_port],
|
||||
&port_type[num_port]);
|
||||
++num_port;
|
||||
}
|
||||
if (wsa881x->boost_enable) {
|
||||
wsa881x_set_port(codec, SWR_BOOST_PORT,
|
||||
wsa881x_set_port(component, SWR_BOOST_PORT,
|
||||
&port_id[num_port], &num_ch[num_port],
|
||||
&ch_mask[num_port], &ch_rate[num_port],
|
||||
&port_type[num_port]);
|
||||
++num_port;
|
||||
}
|
||||
if (wsa881x->visense_enable) {
|
||||
wsa881x_set_port(codec, SWR_VISENSE_PORT,
|
||||
wsa881x_set_port(component, SWR_VISENSE_PORT,
|
||||
&port_id[num_port], &num_ch[num_port],
|
||||
&ch_mask[num_port], &ch_rate[num_port],
|
||||
&port_type[num_port]);
|
||||
@@ -866,40 +899,41 @@ static int wsa881x_enable_swr_dac_port(struct snd_soc_dapm_widget *w,
|
||||
static int wsa881x_rdac_event(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_dapm_to_component(w->dapm);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component);
|
||||
|
||||
dev_dbg(codec->dev, "%s: %s %d boost %d visense %d\n", __func__,
|
||||
dev_dbg(component->dev, "%s: %s %d boost %d visense %d\n", __func__,
|
||||
w->name, event, wsa881x->boost_enable,
|
||||
wsa881x->visense_enable);
|
||||
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_PRE_PMU:
|
||||
mutex_lock(&wsa881x->temp_lock);
|
||||
wsa881x_resource_acquire(codec, ENABLE);
|
||||
wsa881x_resource_acquire(component, ENABLE);
|
||||
mutex_unlock(&wsa881x->temp_lock);
|
||||
wsa881x_boost_ctrl(codec, ENABLE);
|
||||
wsa881x_boost_ctrl(component, ENABLE);
|
||||
break;
|
||||
case SND_SOC_DAPM_POST_PMD:
|
||||
swr_slvdev_datapath_control(wsa881x->swr_slave,
|
||||
wsa881x->swr_slave->dev_num,
|
||||
false);
|
||||
wsa881x_boost_ctrl(codec, DISABLE);
|
||||
wsa881x_boost_ctrl(component, DISABLE);
|
||||
mutex_lock(&wsa881x->temp_lock);
|
||||
wsa881x_resource_acquire(codec, DISABLE);
|
||||
wsa881x_resource_acquire(component, DISABLE);
|
||||
mutex_unlock(&wsa881x->temp_lock);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wsa881x_ramp_pa_gain(struct snd_soc_codec *codec,
|
||||
static int wsa881x_ramp_pa_gain(struct snd_soc_component *component,
|
||||
int min_gain, int max_gain, int udelay)
|
||||
{
|
||||
int val;
|
||||
|
||||
for (val = min_gain; max_gain <= val; val--) {
|
||||
snd_soc_update_bits(codec, WSA881X_SPKR_DRV_GAIN,
|
||||
snd_soc_component_update_bits(component, WSA881X_SPKR_DRV_GAIN,
|
||||
0xF0, val << 4);
|
||||
/*
|
||||
* 1ms delay is needed for every step change in gain as per
|
||||
@@ -914,20 +948,22 @@ static void wsa881x_ocp_ctl_work(struct work_struct *work)
|
||||
{
|
||||
struct wsa881x_priv *wsa881x;
|
||||
struct delayed_work *dwork;
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
int temp_val;
|
||||
|
||||
dwork = to_delayed_work(work);
|
||||
wsa881x = container_of(dwork, struct wsa881x_priv, ocp_ctl_work);
|
||||
|
||||
codec = wsa881x->codec;
|
||||
component = wsa881x->component;
|
||||
wsa881x_get_temp(wsa881x->tz_pdata.tz_dev, &temp_val);
|
||||
dev_dbg(codec->dev, " temp = %d\n", temp_val);
|
||||
dev_dbg(component->dev, " temp = %d\n", temp_val);
|
||||
|
||||
if (temp_val <= WSA881X_OCP_CTL_TEMP_CELSIUS)
|
||||
snd_soc_update_bits(codec, WSA881X_SPKR_OCP_CTL, 0xC0, 0x00);
|
||||
snd_soc_component_update_bits(component, WSA881X_SPKR_OCP_CTL,
|
||||
0xC0, 0x00);
|
||||
else
|
||||
snd_soc_update_bits(codec, WSA881X_SPKR_OCP_CTL, 0xC0, 0xC0);
|
||||
snd_soc_component_update_bits(component, WSA881X_SPKR_OCP_CTL,
|
||||
0xC0, 0xC0);
|
||||
|
||||
schedule_delayed_work(&wsa881x->ocp_ctl_work,
|
||||
msecs_to_jiffies(wsa881x_ocp_poll_timer_sec * 1000));
|
||||
@@ -936,14 +972,16 @@ static void wsa881x_ocp_ctl_work(struct work_struct *work)
|
||||
static int wsa881x_spkr_pa_event(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_dapm_to_component(w->dapm);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component);
|
||||
int min_gain, max_gain;
|
||||
|
||||
dev_dbg(codec->dev, "%s: %s %d\n", __func__, w->name, event);
|
||||
dev_dbg(component->dev, "%s: %s %d\n", __func__, w->name, event);
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_PRE_PMU:
|
||||
snd_soc_update_bits(codec, WSA881X_SPKR_OCP_CTL, 0xC0, 0x80);
|
||||
snd_soc_component_update_bits(component, WSA881X_SPKR_OCP_CTL,
|
||||
0xC0, 0x80);
|
||||
regmap_multi_reg_write(wsa881x->regmap,
|
||||
wsa881x_pre_pmu_pa_2_0,
|
||||
ARRAY_SIZE(wsa881x_pre_pmu_pa_2_0));
|
||||
@@ -952,10 +990,12 @@ static int wsa881x_spkr_pa_event(struct snd_soc_dapm_widget *w,
|
||||
true);
|
||||
/* Set register mode if compander is not enabled */
|
||||
if (!wsa881x->comp_enable)
|
||||
snd_soc_update_bits(codec, WSA881X_SPKR_DRV_GAIN,
|
||||
snd_soc_component_update_bits(component,
|
||||
WSA881X_SPKR_DRV_GAIN,
|
||||
0x08, 0x08);
|
||||
else
|
||||
snd_soc_update_bits(codec, WSA881X_SPKR_DRV_GAIN,
|
||||
snd_soc_component_update_bits(component,
|
||||
WSA881X_SPKR_DRV_GAIN,
|
||||
0x08, 0x00);
|
||||
|
||||
break;
|
||||
@@ -975,14 +1015,16 @@ static int wsa881x_spkr_pa_event(struct snd_soc_dapm_widget *w,
|
||||
* as per HW requirement.
|
||||
*/
|
||||
usleep_range(1000, 1010);
|
||||
wsa881x_ramp_pa_gain(codec, min_gain, max_gain, 1000);
|
||||
wsa881x_ramp_pa_gain(component, min_gain, max_gain,
|
||||
1000);
|
||||
}
|
||||
if (wsa881x->visense_enable) {
|
||||
wsa881x_visense_txfe_ctrl(codec, ENABLE,
|
||||
wsa881x_visense_txfe_ctrl(component, ENABLE,
|
||||
0x00, 0x03, 0x01);
|
||||
snd_soc_update_bits(codec, WSA881X_ADC_EN_SEL_IBAIS,
|
||||
snd_soc_component_update_bits(component,
|
||||
WSA881X_ADC_EN_SEL_IBAIS,
|
||||
0x07, 0x01);
|
||||
wsa881x_visense_adc_ctrl(codec, ENABLE);
|
||||
wsa881x_visense_adc_ctrl(component, ENABLE);
|
||||
}
|
||||
schedule_delayed_work(&wsa881x->ocp_ctl_work,
|
||||
msecs_to_jiffies(WSA881X_OCP_CTL_TIMER_SEC * 1000));
|
||||
@@ -992,12 +1034,13 @@ static int wsa881x_spkr_pa_event(struct snd_soc_dapm_widget *w,
|
||||
break;
|
||||
case SND_SOC_DAPM_POST_PMD:
|
||||
if (wsa881x->visense_enable) {
|
||||
wsa881x_visense_adc_ctrl(codec, DISABLE);
|
||||
wsa881x_visense_txfe_ctrl(codec, DISABLE,
|
||||
wsa881x_visense_adc_ctrl(component, DISABLE);
|
||||
wsa881x_visense_txfe_ctrl(component, DISABLE,
|
||||
0x00, 0x01, 0x01);
|
||||
}
|
||||
cancel_delayed_work_sync(&wsa881x->ocp_ctl_work);
|
||||
snd_soc_update_bits(codec, WSA881X_SPKR_OCP_CTL, 0xC0, 0xC0);
|
||||
snd_soc_component_update_bits(component, WSA881X_SPKR_OCP_CTL,
|
||||
0xC0, 0xC0);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
@@ -1029,16 +1072,16 @@ static const struct snd_soc_dapm_route wsa881x_audio_map[] = {
|
||||
{"SPKR", NULL, "SPKR PGA"},
|
||||
};
|
||||
|
||||
int wsa881x_set_channel_map(struct snd_soc_codec *codec, u8 *port, u8 num_port,
|
||||
unsigned int *ch_mask, unsigned int *ch_rate,
|
||||
u8 *port_type)
|
||||
int wsa881x_set_channel_map(struct snd_soc_component *component, u8 *port,
|
||||
u8 num_port, unsigned int *ch_mask,
|
||||
unsigned int *ch_rate, u8 *port_type)
|
||||
{
|
||||
struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component);
|
||||
int i;
|
||||
|
||||
if (!port || !ch_mask || !ch_rate ||
|
||||
(num_port > WSA881X_MAX_SWR_PORTS)) {
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s: Invalid port=%pK, ch_mask=%pK, ch_rate=%pK\n",
|
||||
__func__, port, ch_mask, ch_rate);
|
||||
return -EINVAL;
|
||||
@@ -1055,70 +1098,91 @@ int wsa881x_set_channel_map(struct snd_soc_codec *codec, u8 *port, u8 num_port,
|
||||
}
|
||||
EXPORT_SYMBOL(wsa881x_set_channel_map);
|
||||
|
||||
static void wsa881x_init(struct snd_soc_codec *codec)
|
||||
static void wsa881x_init(struct snd_soc_component *component)
|
||||
{
|
||||
struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component);
|
||||
|
||||
wsa881x->version = snd_soc_read(codec, WSA881X_CHIP_ID1);
|
||||
wsa881x->version =
|
||||
snd_soc_component_read32(component, WSA881X_CHIP_ID1);
|
||||
wsa881x_regmap_defaults(wsa881x->regmap, wsa881x->version);
|
||||
/* Enable software reset output from soundwire slave */
|
||||
snd_soc_update_bits(codec, WSA881X_SWR_RESET_EN, 0x07, 0x07);
|
||||
snd_soc_component_update_bits(component, WSA881X_SWR_RESET_EN,
|
||||
0x07, 0x07);
|
||||
/* Bring out of analog reset */
|
||||
snd_soc_update_bits(codec, WSA881X_CDC_RST_CTL, 0x02, 0x02);
|
||||
snd_soc_component_update_bits(component, WSA881X_CDC_RST_CTL,
|
||||
0x02, 0x02);
|
||||
/* Bring out of digital reset */
|
||||
snd_soc_update_bits(codec, WSA881X_CDC_RST_CTL, 0x01, 0x01);
|
||||
snd_soc_component_update_bits(component, WSA881X_CDC_RST_CTL,
|
||||
0x01, 0x01);
|
||||
|
||||
snd_soc_update_bits(codec, WSA881X_CLOCK_CONFIG, 0x10, 0x10);
|
||||
snd_soc_update_bits(codec, WSA881X_SPKR_OCP_CTL, 0x02, 0x02);
|
||||
snd_soc_update_bits(codec, WSA881X_SPKR_MISC_CTL1, 0xC0, 0x80);
|
||||
snd_soc_update_bits(codec, WSA881X_SPKR_MISC_CTL1, 0x06, 0x06);
|
||||
snd_soc_update_bits(codec, WSA881X_SPKR_BIAS_INT, 0xFF, 0x00);
|
||||
snd_soc_update_bits(codec, WSA881X_SPKR_PA_INT, 0xF0, 0x40);
|
||||
snd_soc_update_bits(codec, WSA881X_SPKR_PA_INT, 0x0E, 0x0E);
|
||||
snd_soc_update_bits(codec, WSA881X_BOOST_LOOP_STABILITY,
|
||||
snd_soc_component_update_bits(component, WSA881X_CLOCK_CONFIG,
|
||||
0x10, 0x10);
|
||||
snd_soc_component_update_bits(component, WSA881X_SPKR_OCP_CTL,
|
||||
0x02, 0x02);
|
||||
snd_soc_component_update_bits(component, WSA881X_SPKR_MISC_CTL1,
|
||||
0xC0, 0x80);
|
||||
snd_soc_component_update_bits(component, WSA881X_SPKR_MISC_CTL1,
|
||||
0x06, 0x06);
|
||||
snd_soc_component_update_bits(component, WSA881X_SPKR_BIAS_INT,
|
||||
0xFF, 0x00);
|
||||
snd_soc_component_update_bits(component, WSA881X_SPKR_PA_INT,
|
||||
0xF0, 0x40);
|
||||
snd_soc_component_update_bits(component, WSA881X_SPKR_PA_INT,
|
||||
0x0E, 0x0E);
|
||||
snd_soc_component_update_bits(component, WSA881X_BOOST_LOOP_STABILITY,
|
||||
0x03, 0x03);
|
||||
snd_soc_update_bits(codec, WSA881X_BOOST_MISC2_CTL, 0xFF, 0x14);
|
||||
snd_soc_update_bits(codec, WSA881X_BOOST_START_CTL, 0x80, 0x80);
|
||||
snd_soc_update_bits(codec, WSA881X_BOOST_START_CTL, 0x03, 0x00);
|
||||
snd_soc_update_bits(codec, WSA881X_BOOST_SLOPE_COMP_ISENSE_FB,
|
||||
0x0C, 0x04);
|
||||
snd_soc_update_bits(codec, WSA881X_BOOST_SLOPE_COMP_ISENSE_FB,
|
||||
snd_soc_component_update_bits(component, WSA881X_BOOST_MISC2_CTL,
|
||||
0xFF, 0x14);
|
||||
snd_soc_component_update_bits(component, WSA881X_BOOST_START_CTL,
|
||||
0x80, 0x80);
|
||||
snd_soc_component_update_bits(component, WSA881X_BOOST_START_CTL,
|
||||
0x03, 0x00);
|
||||
if (snd_soc_read(codec, WSA881X_OTP_REG_0))
|
||||
snd_soc_update_bits(codec, WSA881X_BOOST_PRESET_OUT1,
|
||||
snd_soc_component_update_bits(component,
|
||||
WSA881X_BOOST_SLOPE_COMP_ISENSE_FB,
|
||||
0x0C, 0x04);
|
||||
snd_soc_component_update_bits(component,
|
||||
WSA881X_BOOST_SLOPE_COMP_ISENSE_FB,
|
||||
0x03, 0x00);
|
||||
if (snd_soc_component_read32(component, WSA881X_OTP_REG_0))
|
||||
snd_soc_component_update_bits(component,
|
||||
WSA881X_BOOST_PRESET_OUT1,
|
||||
0xF0, 0x70);
|
||||
snd_soc_update_bits(codec, WSA881X_BOOST_PRESET_OUT2,
|
||||
snd_soc_component_update_bits(component, WSA881X_BOOST_PRESET_OUT2,
|
||||
0xF0, 0x30);
|
||||
snd_soc_update_bits(codec, WSA881X_SPKR_DRV_EN, 0x08, 0x08);
|
||||
snd_soc_update_bits(codec, WSA881X_BOOST_CURRENT_LIMIT,
|
||||
snd_soc_component_update_bits(component, WSA881X_SPKR_DRV_EN,
|
||||
0x08, 0x08);
|
||||
snd_soc_component_update_bits(component, WSA881X_BOOST_CURRENT_LIMIT,
|
||||
0x0F, 0x08);
|
||||
snd_soc_update_bits(codec, WSA881X_SPKR_OCP_CTL, 0x30, 0x30);
|
||||
snd_soc_update_bits(codec, WSA881X_SPKR_OCP_CTL, 0x0C, 0x00);
|
||||
snd_soc_update_bits(codec, WSA881X_OTP_REG_28, 0x3F, 0x3A);
|
||||
snd_soc_update_bits(codec, WSA881X_BONGO_RESRV_REG1,
|
||||
snd_soc_component_update_bits(component, WSA881X_SPKR_OCP_CTL,
|
||||
0x30, 0x30);
|
||||
snd_soc_component_update_bits(component, WSA881X_SPKR_OCP_CTL,
|
||||
0x0C, 0x00);
|
||||
snd_soc_component_update_bits(component, WSA881X_OTP_REG_28,
|
||||
0x3F, 0x3A);
|
||||
snd_soc_component_update_bits(component, WSA881X_BONGO_RESRV_REG1,
|
||||
0xFF, 0xB2);
|
||||
snd_soc_update_bits(codec, WSA881X_BONGO_RESRV_REG2,
|
||||
snd_soc_component_update_bits(component, WSA881X_BONGO_RESRV_REG2,
|
||||
0xFF, 0x05);
|
||||
}
|
||||
|
||||
static int32_t wsa881x_resource_acquire(struct snd_soc_codec *codec,
|
||||
static int32_t wsa881x_resource_acquire(struct snd_soc_component *component,
|
||||
bool enable)
|
||||
{
|
||||
wsa881x_clk_ctrl(codec, enable);
|
||||
wsa881x_bandgap_ctrl(codec, enable);
|
||||
wsa881x_clk_ctrl(component, enable);
|
||||
wsa881x_bandgap_ctrl(component, enable);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t wsa881x_temp_reg_read(struct snd_soc_codec *codec,
|
||||
static int32_t wsa881x_temp_reg_read(struct snd_soc_component *component,
|
||||
struct wsa_temp_register *wsa_temp_reg)
|
||||
{
|
||||
struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component);
|
||||
struct swr_device *dev;
|
||||
u8 retry = WSA881X_NUM_RETRY;
|
||||
u8 devnum = 0;
|
||||
|
||||
if (!wsa881x) {
|
||||
dev_err(codec->dev, "%s: wsa881x is NULL\n", __func__);
|
||||
dev_err(component->dev, "%s: wsa881x is NULL\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
dev = wsa881x->swr_slave;
|
||||
@@ -1129,7 +1193,7 @@ static int32_t wsa881x_temp_reg_read(struct snd_soc_codec *codec,
|
||||
usleep_range(1000, 1100);
|
||||
}
|
||||
if (retry == 0) {
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"%s get devnum %d for dev addr %lx failed\n",
|
||||
__func__, devnum, dev->addr);
|
||||
return -EINVAL;
|
||||
@@ -1137,81 +1201,78 @@ static int32_t wsa881x_temp_reg_read(struct snd_soc_codec *codec,
|
||||
}
|
||||
wsa881x_regcache_sync(wsa881x);
|
||||
mutex_lock(&wsa881x->temp_lock);
|
||||
wsa881x_resource_acquire(codec, ENABLE);
|
||||
wsa881x_resource_acquire(component, ENABLE);
|
||||
|
||||
snd_soc_update_bits(codec, WSA881X_TADC_VALUE_CTL, 0x01, 0x00);
|
||||
wsa_temp_reg->dmeas_msb = snd_soc_read(codec, WSA881X_TEMP_MSB);
|
||||
wsa_temp_reg->dmeas_lsb = snd_soc_read(codec, WSA881X_TEMP_LSB);
|
||||
snd_soc_update_bits(codec, WSA881X_TADC_VALUE_CTL, 0x01, 0x01);
|
||||
wsa_temp_reg->d1_msb = snd_soc_read(codec, WSA881X_OTP_REG_1);
|
||||
wsa_temp_reg->d1_lsb = snd_soc_read(codec, WSA881X_OTP_REG_2);
|
||||
wsa_temp_reg->d2_msb = snd_soc_read(codec, WSA881X_OTP_REG_3);
|
||||
wsa_temp_reg->d2_lsb = snd_soc_read(codec, WSA881X_OTP_REG_4);
|
||||
snd_soc_component_update_bits(component, WSA881X_TADC_VALUE_CTL,
|
||||
0x01, 0x00);
|
||||
wsa_temp_reg->dmeas_msb = snd_soc_component_read32(
|
||||
component, WSA881X_TEMP_MSB);
|
||||
wsa_temp_reg->dmeas_lsb = snd_soc_component_read32(
|
||||
component, WSA881X_TEMP_LSB);
|
||||
snd_soc_component_update_bits(component, WSA881X_TADC_VALUE_CTL,
|
||||
0x01, 0x01);
|
||||
wsa_temp_reg->d1_msb = snd_soc_component_read32(
|
||||
component, WSA881X_OTP_REG_1);
|
||||
wsa_temp_reg->d1_lsb = snd_soc_component_read32(
|
||||
component, WSA881X_OTP_REG_2);
|
||||
wsa_temp_reg->d2_msb = snd_soc_component_read32(
|
||||
component, WSA881X_OTP_REG_3);
|
||||
wsa_temp_reg->d2_lsb = snd_soc_component_read32(
|
||||
component, WSA881X_OTP_REG_4);
|
||||
|
||||
wsa881x_resource_acquire(codec, DISABLE);
|
||||
wsa881x_resource_acquire(component, DISABLE);
|
||||
mutex_unlock(&wsa881x->temp_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wsa881x_probe(struct snd_soc_codec *codec)
|
||||
static int wsa881x_probe(struct snd_soc_component *component)
|
||||
{
|
||||
struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component);
|
||||
struct swr_device *dev;
|
||||
|
||||
if (!wsa881x)
|
||||
return -EINVAL;
|
||||
snd_soc_component_init_regmap(component, wsa881x->regmap);
|
||||
|
||||
dev = wsa881x->swr_slave;
|
||||
wsa881x->codec = codec;
|
||||
wsa881x->component = component;
|
||||
mutex_init(&wsa881x->bg_lock);
|
||||
wsa881x_init(codec);
|
||||
wsa881x_init(component);
|
||||
snprintf(wsa881x->tz_pdata.name, sizeof(wsa881x->tz_pdata.name),
|
||||
"%s.%x", "wsatz", (u8)dev->addr);
|
||||
wsa881x->bg_cnt = 0;
|
||||
wsa881x->clk_cnt = 0;
|
||||
wsa881x->tz_pdata.codec = codec;
|
||||
wsa881x->tz_pdata.component = component;
|
||||
wsa881x->tz_pdata.wsa_temp_reg_read = wsa881x_temp_reg_read;
|
||||
wsa881x_init_thermal(&wsa881x->tz_pdata);
|
||||
snd_soc_add_codec_controls(codec, wsa_snd_controls,
|
||||
snd_soc_add_component_controls(component, wsa_snd_controls,
|
||||
ARRAY_SIZE(wsa_snd_controls));
|
||||
INIT_DELAYED_WORK(&wsa881x->ocp_ctl_work, wsa881x_ocp_ctl_work);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wsa881x_remove(struct snd_soc_codec *codec)
|
||||
static void wsa881x_remove(struct snd_soc_component *component)
|
||||
{
|
||||
struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec);
|
||||
struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component);
|
||||
|
||||
if (wsa881x->tz_pdata.tz_dev)
|
||||
wsa881x_deinit_thermal(wsa881x->tz_pdata.tz_dev);
|
||||
mutex_destroy(&wsa881x->bg_lock);
|
||||
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
static struct regmap *wsa881x_get_regmap(struct device *dev)
|
||||
{
|
||||
struct wsa881x_priv *control = swr_get_dev_data(to_swr_device(dev));
|
||||
|
||||
if (!control)
|
||||
return NULL;
|
||||
|
||||
return control->regmap;
|
||||
}
|
||||
|
||||
static struct snd_soc_codec_driver soc_codec_dev_wsa881x = {
|
||||
static const struct snd_soc_component_driver soc_codec_dev_wsa881x = {
|
||||
.name = DRV_NAME,
|
||||
.probe = wsa881x_probe,
|
||||
.remove = wsa881x_remove,
|
||||
.get_regmap = wsa881x_get_regmap,
|
||||
.component_driver = {
|
||||
.controls = wsa881x_snd_controls,
|
||||
.num_controls = ARRAY_SIZE(wsa881x_snd_controls),
|
||||
.dapm_widgets = wsa881x_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(wsa881x_dapm_widgets),
|
||||
.dapm_routes = wsa881x_audio_map,
|
||||
.num_dapm_routes = ARRAY_SIZE(wsa881x_audio_map),
|
||||
},
|
||||
};
|
||||
|
||||
static int wsa881x_gpio_ctrl(struct wsa881x_priv *wsa881x, bool enable)
|
||||
@@ -1361,7 +1422,7 @@ static int wsa881x_swr_probe(struct swr_device *pdev)
|
||||
goto dev_err;
|
||||
}
|
||||
|
||||
ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wsa881x,
|
||||
ret = snd_soc_register_component(&pdev->dev, &soc_codec_dev_wsa881x,
|
||||
NULL, 0);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "%s: Codec registration failed\n",
|
||||
@@ -1394,7 +1455,7 @@ static int wsa881x_swr_remove(struct swr_device *pdev)
|
||||
debugfs_wsa881x_dent = NULL;
|
||||
mutex_destroy(&wsa881x->res_lock);
|
||||
mutex_destroy(&wsa881x->temp_lock);
|
||||
snd_soc_unregister_codec(&pdev->dev);
|
||||
snd_soc_unregister_component(&pdev->dev);
|
||||
if (wsa881x->pd_gpio)
|
||||
gpio_free(wsa881x->pd_gpio);
|
||||
swr_set_dev_data(pdev, NULL);
|
||||
|
@@ -13,28 +13,28 @@
|
||||
#define WSA881X_MAX_SWR_PORTS 4
|
||||
|
||||
#if IS_ENABLED(CONFIG_SND_SOC_WSA881X)
|
||||
extern int wsa881x_set_channel_map(struct snd_soc_codec *codec, u8 *port,
|
||||
u8 num_port, unsigned int *ch_mask,
|
||||
extern int wsa881x_set_channel_map(struct snd_soc_component *component,
|
||||
u8 *port, u8 num_port, unsigned int *ch_mask,
|
||||
unsigned int *ch_rate, u8 *port_type);
|
||||
|
||||
extern const u8 wsa881x_reg_readable[WSA881X_CACHE_SIZE];
|
||||
extern struct regmap_config wsa881x_regmap_config;
|
||||
extern int wsa881x_codec_info_create_codec_entry(
|
||||
struct snd_info_entry *codec_root,
|
||||
struct snd_soc_codec *codec);
|
||||
struct snd_soc_component *component);
|
||||
void wsa881x_regmap_defaults(struct regmap *regmap, u8 version);
|
||||
|
||||
#else
|
||||
extern int wsa881x_set_channel_map(struct snd_soc_codec *codec, u8 *port,
|
||||
u8 num_port, unsigned int *ch_mask,
|
||||
unsigned int *ch_rate, u8 *port_type);
|
||||
extern int wsa881x_set_channel_map(struct snd_soc_component *component,
|
||||
u8 *port, u8 num_port, unsigned int *ch_mask,
|
||||
unsigned int *ch_rate, u8 *port_type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern int wsa881x_codec_info_create_codec_entry(
|
||||
struct snd_info_entry *codec_root,
|
||||
struct snd_soc_codec *codec)
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
在新工单中引用
屏蔽一个用户