summaryrefslogtreecommitdiff
path: root/asoc/codecs/wcd9xxx-common-v2.c
diff options
context:
space:
mode:
authorMeng Wang <mengw@codeaurora.org>2018-09-06 10:49:18 +0800
committerGerrit - the friendly Code Review server <code-review@localhost>2018-12-08 03:15:55 -0800
commit15c825d077fe7c1cb3eead4db07685130b9df63e (patch)
treedbfa99b185f78ccd4af39eb9c341a9c6e9eeba45 /asoc/codecs/wcd9xxx-common-v2.c
parentee084a068eb2b4bd8fc5fbfed720f46d036113bd (diff)
downloadmsm-extra-15c825d077fe7c1cb3eead4db07685130b9df63e.tar.gz
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>
Diffstat (limited to 'asoc/codecs/wcd9xxx-common-v2.c')
-rw-r--r--asoc/codecs/wcd9xxx-common-v2.c619
1 files changed, 335 insertions, 284 deletions
diff --git a/asoc/codecs/wcd9xxx-common-v2.c b/asoc/codecs/wcd9xxx-common-v2.c
index 78cfc15a..d45a071b 100644
--- a/asoc/codecs/wcd9xxx-common-v2.c
+++ b/asoc/codecs/wcd9xxx-common-v2.c
@@ -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.
*/
#include <linux/module.h>
@@ -210,7 +210,7 @@ static const struct wcd_imped_val imped_index[] = {
{13, 9},
};
-static void (*clsh_state_fp[NUM_CLSH_STATES_V2])(struct snd_soc_codec *,
+static void (*clsh_state_fp[NUM_CLSH_STATES_V2])(struct snd_soc_component *,
struct wcd_clsh_cdc_data *,
u8 req_state, bool en, int mode);
@@ -243,12 +243,13 @@ ret:
/*
* Function: wcd_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 wcd_clsh_imped_config(struct snd_soc_codec *codec, int imped, bool reset)
+void wcd_clsh_imped_config(struct snd_soc_component *component, int imped,
+ bool reset)
{
int i;
int index = 0;
@@ -256,7 +257,7 @@ void wcd_clsh_imped_config(struct snd_soc_codec *codec, int imped, bool reset)
static const struct wcd_reg_mask_val
(*imped_table_ptr)[MAX_IMPED_PARAMS];
- struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
+ struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent);
if (IS_CODEC_TYPE(wcd9xxx, WCD934X)) {
table_size = ARRAY_SIZE(imped_table_tavil);
@@ -269,7 +270,7 @@ void wcd_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;
@@ -285,24 +286,25 @@ void wcd_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);
}
EXPORT_SYMBOL(wcd_clsh_imped_config);
-static bool is_native_44_1_active(struct snd_soc_codec *codec)
+static bool is_native_44_1_active(struct snd_soc_component *component)
{
bool native_active = false;
u8 native_clk, rx1_rate, rx2_rate;
- native_clk = snd_soc_read(codec,
+ native_clk = snd_soc_component_read32(component,
WCD9XXX_CDC_CLK_RST_CTRL_MCLK_CONTROL);
- rx1_rate = snd_soc_read(codec, WCD9XXX_CDC_RX1_RX_PATH_CTL);
- rx2_rate = snd_soc_read(codec, WCD9XXX_CDC_RX2_RX_PATH_CTL);
-
- dev_dbg(codec->dev, "%s: native_clk %x rx1_rate= %x rx2_rate= %x",
+ rx1_rate = snd_soc_component_read32(component,
+ WCD9XXX_CDC_RX1_RX_PATH_CTL);
+ rx2_rate = snd_soc_component_read32(component,
+ WCD9XXX_CDC_RX2_RX_PATH_CTL);
+ dev_dbg(component->dev, "%s: native_clk %x rx1_rate= %x rx2_rate= %x",
__func__, native_clk, rx1_rate, rx2_rate);
if ((native_clk & 0x2) &&
@@ -371,22 +373,23 @@ done:
}
static inline void
-wcd_enable_clsh_block(struct snd_soc_codec *codec,
+wcd_enable_clsh_block(struct snd_soc_component *component,
struct wcd_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, WCD9XXX_A_CDC_CLSH_CRC, 0x01,
- (u8) enable);
+ snd_soc_component_update_bits(component, WCD9XXX_A_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 wcd_clsh_enable_status(struct snd_soc_codec *codec)
+static inline bool wcd_clsh_enable_status(struct snd_soc_component *component)
{
- return snd_soc_read(codec, WCD9XXX_A_CDC_CLSH_CRC) & 0x01;
+ return snd_soc_component_read32(component, WCD9XXX_A_CDC_CLSH_CRC) &
+ 0x01;
}
static inline int wcd_clsh_get_int_mode(struct wcd_clsh_cdc_data *clsh_d,
@@ -417,34 +420,40 @@ static inline void wcd_clsh_set_int_mode(struct wcd_clsh_cdc_data *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 || mode == CLS_AB)
- snd_soc_update_bits(codec, WCD9XXX_A_ANA_RX_SUPPLIES,
- 0x08, 0x08); /* set to HIFI */
+ snd_soc_component_update_bits(component,
+ WCD9XXX_A_ANA_RX_SUPPLIES,
+ 0x08, 0x08); /* set to HIFI */
else
- snd_soc_update_bits(codec, WCD9XXX_A_ANA_RX_SUPPLIES,
- 0x08, 0x00); /* set to default */
+ snd_soc_component_update_bits(component,
+ WCD9XXX_A_ANA_RX_SUPPLIES,
+ 0x08, 0x00); /* set to default */
}
-static inline void wcd_clsh_set_flyback_mode(struct snd_soc_codec *codec,
- int mode)
+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 || mode == CLS_AB)
- snd_soc_update_bits(codec, WCD9XXX_A_ANA_RX_SUPPLIES,
- 0x04, 0x04); /* set to HIFI */
+ snd_soc_component_update_bits(component,
+ WCD9XXX_A_ANA_RX_SUPPLIES,
+ 0x04, 0x04); /* set to HIFI */
else
- snd_soc_update_bits(codec, WCD9XXX_A_ANA_RX_SUPPLIES,
- 0x04, 0x00); /* set to Default */
+ snd_soc_component_update_bits(component,
+ WCD9XXX_A_ANA_RX_SUPPLIES,
+ 0x04, 0x00); /* set to Default */
}
-static inline void wcd_clsh_gm3_boost_disable(struct snd_soc_codec *codec,
- int mode)
+static inline void wcd_clsh_gm3_boost_disable(
+ struct snd_soc_component *component,
+ int mode)
{
- struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
+ struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent);
if (!IS_CODEC_TYPE(wcd9xxx, WCD934X))
return;
@@ -452,46 +461,56 @@ static inline void wcd_clsh_gm3_boost_disable(struct snd_soc_codec *codec,
if (mode == CLS_H_HIFI || mode == CLS_H_LOHIFI ||
mode == CLS_AB_HIFI || mode == CLS_AB) {
if (TAVIL_IS_1_0(wcd9xxx))
- snd_soc_update_bits(codec, WCD9XXX_HPH_CNP_WG_CTL,
- 0x80, 0x0); /* disable GM3 Boost */
- snd_soc_update_bits(codec, WCD9XXX_FLYBACK_VNEG_CTRL_4,
- 0xF0, 0x80);
+ snd_soc_component_update_bits(component,
+ WCD9XXX_HPH_CNP_WG_CTL,
+ 0x80, 0x0); /* disable GM3 Boost */
+ snd_soc_component_update_bits(component,
+ WCD9XXX_FLYBACK_VNEG_CTRL_4,
+ 0xF0, 0x80);
} else {
- snd_soc_update_bits(codec, WCD9XXX_HPH_CNP_WG_CTL,
- 0x80, 0x80); /* set to Default */
- snd_soc_update_bits(codec, WCD9XXX_FLYBACK_VNEG_CTRL_4,
- 0xF0, 0x70);
+ snd_soc_component_update_bits(component,
+ WCD9XXX_HPH_CNP_WG_CTL,
+ 0x80, 0x80); /* set to Default */
+ 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)
{
- struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
+ struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent);
if (!IS_CODEC_TYPE(wcd9xxx, WCD934X))
return;
if (mode == CLS_H_LOHIFI || mode == CLS_AB) {
- snd_soc_update_bits(codec, WCD9XXX_HPH_NEW_INT_PA_MISC2,
- 0x20, 0x20);
- snd_soc_update_bits(codec, WCD9XXX_RX_BIAS_HPH_LOWPOWER,
- 0xF0, 0xC0);
- snd_soc_update_bits(codec, WCD9XXX_HPH_PA_CTL1,
- 0x0E, 0x02);
+ snd_soc_component_update_bits(component,
+ WCD9XXX_HPH_NEW_INT_PA_MISC2,
+ 0x20, 0x20);
+ snd_soc_component_update_bits(component,
+ WCD9XXX_RX_BIAS_HPH_LOWPOWER,
+ 0xF0, 0xC0);
+ snd_soc_component_update_bits(component,
+ WCD9XXX_HPH_PA_CTL1,
+ 0x0E, 0x02);
} else {
- snd_soc_update_bits(codec, WCD9XXX_HPH_NEW_INT_PA_MISC2,
- 0x20, 0x0);
- snd_soc_update_bits(codec, WCD9XXX_RX_BIAS_HPH_LOWPOWER,
- 0xF0, 0x80);
- snd_soc_update_bits(codec, WCD9XXX_HPH_PA_CTL1,
- 0x0E, 0x06);
+ snd_soc_component_update_bits(component,
+ WCD9XXX_HPH_NEW_INT_PA_MISC2,
+ 0x20, 0x0);
+ snd_soc_component_update_bits(component,
+ WCD9XXX_RX_BIAS_HPH_LOWPOWER,
+ 0xF0, 0x80);
+ 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_data *clsh_d,
int mode,
bool enable)
@@ -499,9 +518,10 @@ 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_A_ANA_RX_SUPPLIES,
- (1 << 7), (enable << 7));
- dev_dbg(codec->dev, "%s: buck_users %d, enable %d, mode: %s",
+ snd_soc_component_update_bits(component,
+ WCD9XXX_A_ANA_RX_SUPPLIES,
+ (1 << 7), (enable << 7));
+ 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
@@ -510,29 +530,32 @@ static void wcd_clsh_buck_ctrl(struct snd_soc_codec *codec,
usleep_range(500, 500 + WCD_USLEEP_RANGE);
}
-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_data *clsh_d,
int mode,
bool enable)
{
- struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
+ struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent);
struct wcd9xxx_reg_val bulk_reg[2];
u8 vneg[] = {0x00, 0x40};
/* enable/disable flyback */
if ((enable && (++clsh_d->flyback_users == 1)) ||
(!enable && (--clsh_d->flyback_users == 0))) {
- snd_soc_update_bits(codec, WCD9XXX_A_ANA_RX_SUPPLIES,
- (1 << 6), (enable << 6));
+ snd_soc_component_update_bits(component,
+ WCD9XXX_A_ANA_RX_SUPPLIES,
+ (1 << 6), (enable << 6));
/* 100usec delay is needed as per HW requirement */
usleep_range(100, 110);
if (enable && (TASHA_IS_1_1(wcd9xxx))) {
- wcd_clsh_set_flyback_mode(codec, CLS_H_HIFI);
- snd_soc_update_bits(codec, WCD9XXX_FLYBACK_EN,
- 0x60, 0x40);
- snd_soc_update_bits(codec, WCD9XXX_FLYBACK_EN,
- 0x10, 0x10);
- vneg[0] = snd_soc_read(codec,
+ wcd_clsh_set_flyback_mode(component, CLS_H_HIFI);
+ snd_soc_component_update_bits(component,
+ WCD9XXX_FLYBACK_EN,
+ 0x60, 0x40);
+ snd_soc_component_update_bits(component,
+ WCD9XXX_FLYBACK_EN,
+ 0x10, 0x10);
+ vneg[0] = snd_soc_component_read32(component,
WCD9XXX_A_ANA_RX_SUPPLIES);
vneg[0] &= ~(0x40);
vneg[1] = vneg[0] | 0x40;
@@ -546,13 +569,14 @@ static void wcd_clsh_flyback_ctrl(struct snd_soc_codec *codec,
usleep_range(500, 510);
wcd9xxx_slim_bulk_write(wcd9xxx, bulk_reg, 2,
false);
- snd_soc_update_bits(codec, WCD9XXX_FLYBACK_EN,
- 0x10, 0x00);
- wcd_clsh_set_flyback_mode(codec, mode);
+ snd_soc_component_update_bits(component,
+ WCD9XXX_FLYBACK_EN,
+ 0x10, 0x00);
+ wcd_clsh_set_flyback_mode(component, mode);
}
}
- 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
@@ -561,11 +585,11 @@ static void wcd_clsh_flyback_ctrl(struct snd_soc_codec *codec,
usleep_range(500, 500 + WCD_USLEEP_RANGE);
}
-static void wcd_clsh_set_gain_path(struct snd_soc_codec *codec,
+static void wcd_clsh_set_gain_path(struct snd_soc_component *component,
int mode)
{
u8 val = 0;
- struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
+ struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent);
if (!TASHA_IS_2_0(wcd9xxx))
return;
@@ -584,11 +608,13 @@ static void wcd_clsh_set_gain_path(struct snd_soc_codec *codec,
default:
return;
};
- snd_soc_update_bits(codec, WCD9XXX_HPH_L_EN, 0xC0, (val << 6));
- snd_soc_update_bits(codec, WCD9XXX_HPH_R_EN, 0xC0, (val << 6));
+ snd_soc_component_update_bits(component, WCD9XXX_HPH_L_EN,
+ 0xC0, (val << 6));
+ snd_soc_component_update_bits(component, WCD9XXX_HPH_R_EN,
+ 0xC0, (val << 6));
}
-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;
@@ -596,7 +622,7 @@ static void wcd_clsh_set_hph_mode(struct snd_soc_codec *codec,
u8 res_val = VREF_FILT_R_0OHM;
u8 ipeak = DELTA_I_50MA;
- struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
+ struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent);
switch (mode) {
case CLS_H_NORMAL:
@@ -646,97 +672,109 @@ static void wcd_clsh_set_hph_mode(struct snd_soc_codec *codec,
(mode == CLS_H_LOHIFI || mode == CLS_AB))
val = 0x04;
- snd_soc_update_bits(codec, WCD9XXX_A_ANA_HPH, 0x0C, val);
+ snd_soc_component_update_bits(component, WCD9XXX_A_ANA_HPH, 0x0C, val);
if (TASHA_IS_2_0(wcd9xxx)) {
- snd_soc_update_bits(codec, WCD9XXX_CLASSH_CTRL_VCL_2,
- 0x30, (res_val << 4));
+ snd_soc_component_update_bits(component,
+ WCD9XXX_CLASSH_CTRL_VCL_2,
+ 0x30, (res_val << 4));
if (mode != CLS_H_LP)
- snd_soc_update_bits(codec, WCD9XXX_HPH_REFBUFF_UHQA_CTL,
- 0x07, gain);
- snd_soc_update_bits(codec, WCD9XXX_CLASSH_CTRL_CCL_1,
- 0xF0, (ipeak << 4));
+ snd_soc_component_update_bits(component,
+ WCD9XXX_HPH_REFBUFF_UHQA_CTL,
+ 0x07, gain);
+ snd_soc_component_update_bits(component,
+ WCD9XXX_CLASSH_CTRL_CCL_1,
+ 0xF0, (ipeak << 4));
}
}
-static void wcd_clsh_set_flyback_vneg_ctl(struct snd_soc_codec *codec,
+static void wcd_clsh_set_flyback_vneg_ctl(struct snd_soc_component *component,
bool enable)
{
- struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
+ struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent);
if (!TASHA_IS_2_0(wcd9xxx))
return;
if (enable) {
- snd_soc_update_bits(codec, WCD9XXX_FLYBACK_VNEG_CTRL_1, 0xE0,
- 0x00);
- snd_soc_update_bits(codec, WCD9XXX_FLYBACK_VNEGDAC_CTRL_2,
- 0xE0, (0x07 << 5));
+ snd_soc_component_update_bits(component,
+ WCD9XXX_FLYBACK_VNEG_CTRL_1, 0xE0, 0x00);
+ snd_soc_component_update_bits(component,
+ WCD9XXX_FLYBACK_VNEGDAC_CTRL_2,
+ 0xE0, (0x07 << 5));
} else {
- snd_soc_update_bits(codec, WCD9XXX_FLYBACK_VNEG_CTRL_1, 0xE0,
- (0x07 << 5));
- snd_soc_update_bits(codec, WCD9XXX_FLYBACK_VNEGDAC_CTRL_2,
- 0xE0, (0x02 << 5));
+ snd_soc_component_update_bits(component,
+ WCD9XXX_FLYBACK_VNEG_CTRL_1,
+ 0xE0, (0x07 << 5));
+ snd_soc_component_update_bits(component,
+ WCD9XXX_FLYBACK_VNEGDAC_CTRL_2,
+ 0xE0, (0x02 << 5));
}
}
-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)
{
- struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent);
+ struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent);
if (!TASHA_IS_2_0(wcd9xxx))
return;
- 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,
- int mode)
+static void wcd_clsh_set_buck_regulator_mode(
+ struct snd_soc_component *component,
+ int mode)
{
- snd_soc_update_bits(codec, WCD9XXX_A_ANA_RX_SUPPLIES,
+ snd_soc_component_update_bits(component, WCD9XXX_A_ANA_RX_SUPPLIES,
0x02, 0x00);
}
-static void wcd_clsh_state_lo(struct snd_soc_codec *codec,
+static void wcd_clsh_state_lo(struct snd_soc_component *component,
struct wcd_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) {
- dev_err(codec->dev, "%s: LO cannot be in this mode: %d\n",
+ dev_err(component->dev, "%s: LO cannot be in this mode: %d\n",
__func__, mode);
return;
}
if (is_enable) {
- wcd_clsh_set_buck_regulator_mode(codec, mode);
- wcd_clsh_set_flyback_vneg_ctl(codec, true);
- 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_regulator_mode(component, mode);
+ wcd_clsh_set_flyback_vneg_ctl(component, 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_set_flyback_vneg_ctl(codec, false);
- wcd_clsh_set_buck_regulator_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);
+ wcd_clsh_set_flyback_vneg_ctl(component, false);
+ wcd_clsh_set_buck_regulator_mode(component, CLS_H_NORMAL);
}
}
-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_data *clsh_d,
u8 req_state, bool is_enable, int mode)
{
int hph_mode = 0;
- 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) {
@@ -755,37 +793,38 @@ static void wcd_clsh_state_hph_ear(struct snd_soc_codec *codec,
else
return;
if (hph_mode != CLS_AB && hph_mode != CLS_AB_HIFI
- && !is_native_44_1_active(codec))
- snd_soc_update_bits(codec,
+ && !is_native_44_1_active(component))
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_RX0_RX_PATH_CFG0,
0x40, 0x40);
}
- if (is_native_44_1_active(codec)) {
- snd_soc_write(codec, WCD9XXX_CDC_CLSH_HPH_V_PA, 0x39);
- snd_soc_update_bits(codec,
+ if (is_native_44_1_active(component)) {
+ snd_soc_component_write(component,
+ WCD9XXX_CDC_CLSH_HPH_V_PA, 0x39);
+ snd_soc_component_update_bits(component,
WCD9XXX_CDC_RX0_RX_PATH_SEC0,
0x03, 0x00);
if ((req_state == WCD_CLSH_STATE_HPHL) ||
(req_state == WCD_CLSH_STATE_HPHR))
- snd_soc_update_bits(codec,
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_RX0_RX_PATH_CFG0,
0x40, 0x00);
}
if (req_state == WCD_CLSH_STATE_HPHL)
- snd_soc_update_bits(codec,
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_RX1_RX_PATH_CFG0,
0x40, 0x40);
if (req_state == WCD_CLSH_STATE_HPHR)
- snd_soc_update_bits(codec,
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_RX2_RX_PATH_CFG0,
0x40, 0x40);
if ((req_state == WCD_CLSH_STATE_HPHL) ||
(req_state == WCD_CLSH_STATE_HPHR)) {
- wcd_clsh_set_gain_path(codec, mode);
- wcd_clsh_set_flyback_mode(codec, mode);
- wcd_clsh_set_buck_mode(codec, mode);
+ wcd_clsh_set_gain_path(component, mode);
+ wcd_clsh_set_flyback_mode(component, mode);
+ wcd_clsh_set_buck_mode(component, mode);
}
} else {
if (req_state == WCD_CLSH_STATE_EAR) {
@@ -795,54 +834,56 @@ static void wcd_clsh_state_hph_ear(struct snd_soc_codec *codec,
* and if HPH requested mode is CLS_AB then
* no need to disable EAR channel enable bit.
*/
- if (wcd_clsh_enable_status(codec))
- snd_soc_update_bits(codec,
+ if (wcd_clsh_enable_status(component))
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_RX0_RX_PATH_CFG0,
0x40, 0x00);
}
- if (is_native_44_1_active(codec)) {
- snd_soc_write(codec, WCD9XXX_CDC_CLSH_HPH_V_PA, 0x1C);
- snd_soc_update_bits(codec,
+ if (is_native_44_1_active(component)) {
+ snd_soc_component_write(component,
+ WCD9XXX_CDC_CLSH_HPH_V_PA, 0x1C);
+ snd_soc_component_update_bits(component,
WCD9XXX_CDC_RX0_RX_PATH_SEC0,
0x03, 0x01);
if (((clsh_d->state & WCD_CLSH_STATE_HPH_ST)
!= WCD_CLSH_STATE_HPH_ST) &&
((req_state == WCD_CLSH_STATE_HPHL) ||
(req_state == WCD_CLSH_STATE_HPHR)))
- snd_soc_update_bits(codec,
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_RX0_RX_PATH_CFG0,
0x40, 0x40);
}
if (req_state == WCD_CLSH_STATE_HPHL)
- snd_soc_update_bits(codec,
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_RX1_RX_PATH_CFG0,
0x40, 0x00);
if (req_state == WCD_CLSH_STATE_HPHR)
- snd_soc_update_bits(codec,
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_RX2_RX_PATH_CFG0,
0x40, 0x00);
if ((req_state & WCD_CLSH_STATE_HPH_ST) &&
- !wcd_clsh_enable_status(codec)) {
+ !wcd_clsh_enable_status(component)) {
/* If Class-H is not enabled when HPH is turned
* off, enable it as EAR is in progress
*/
- wcd_enable_clsh_block(codec, clsh_d, true);
- snd_soc_update_bits(codec,
+ wcd_enable_clsh_block(component, clsh_d, true);
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_RX0_RX_PATH_CFG0,
0x40, 0x40);
- wcd_clsh_set_flyback_mode(codec, CLS_H_NORMAL);
- wcd_clsh_set_buck_mode(codec, CLS_H_NORMAL);
+ wcd_clsh_set_flyback_mode(component, CLS_H_NORMAL);
+ wcd_clsh_set_buck_mode(component, CLS_H_NORMAL);
}
}
}
-static void wcd_clsh_state_ear_lo(struct snd_soc_codec *codec,
+static void wcd_clsh_state_ear_lo(struct snd_soc_component *component,
struct wcd_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 (is_enable) {
@@ -851,22 +892,22 @@ static void wcd_clsh_state_ear_lo(struct snd_soc_codec *codec,
*/
if (req_state == WCD_CLSH_STATE_EAR) {
/* EAR powerup.*/
- if (!wcd_clsh_enable_status(codec)) {
- wcd_enable_clsh_block(codec, clsh_d, true);
- wcd_clsh_set_buck_mode(codec, mode);
- wcd_clsh_set_flyback_mode(codec, mode);
+ if (!wcd_clsh_enable_status(component)) {
+ wcd_enable_clsh_block(component, clsh_d, true);
+ wcd_clsh_set_buck_mode(component, mode);
+ wcd_clsh_set_flyback_mode(component, mode);
}
- snd_soc_update_bits(codec,
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_RX0_RX_PATH_CFG0,
0x40, 0x40);
}
} else {
if (req_state == WCD_CLSH_STATE_EAR) {
/* EAR powerdown.*/
- wcd_enable_clsh_block(codec, clsh_d, false);
- wcd_clsh_set_buck_mode(codec, CLS_H_NORMAL);
- wcd_clsh_set_flyback_mode(codec, CLS_H_NORMAL);
- snd_soc_update_bits(codec,
+ wcd_enable_clsh_block(component, clsh_d, false);
+ wcd_clsh_set_buck_mode(component, CLS_H_NORMAL);
+ wcd_clsh_set_flyback_mode(component, CLS_H_NORMAL);
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_RX0_RX_PATH_CFG0,
0x40, 0x00);
}
@@ -876,13 +917,14 @@ static void wcd_clsh_state_ear_lo(struct snd_soc_codec *codec,
}
}
-static void wcd_clsh_state_hph_lo(struct snd_soc_codec *codec,
+static void wcd_clsh_state_hph_lo(struct snd_soc_component *component,
struct wcd_clsh_cdc_data *clsh_d,
u8 req_state, bool is_enable, int mode)
{
int hph_mode = 0;
- 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) {
@@ -895,31 +937,31 @@ static void wcd_clsh_state_hph_lo(struct snd_soc_codec *codec,
* and buck.
*/
if (req_state == WCD_CLSH_STATE_LO)
- wcd_clsh_set_buck_regulator_mode(codec, CLS_AB);
+ wcd_clsh_set_buck_regulator_mode(component, CLS_AB);
else {
- if (!wcd_clsh_enable_status(codec)) {
- wcd_enable_clsh_block(codec, clsh_d, true);
- snd_soc_update_bits(codec,
+ if (!wcd_clsh_enable_status(component)) {
+ wcd_enable_clsh_block(component, clsh_d, true);
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_CLSH_K1_MSB,
0x0F, 0x00);
- snd_soc_update_bits(codec,
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_CLSH_K1_LSB,
0xFF, 0xC0);
- wcd_clsh_set_flyback_mode(codec, mode);
- wcd_clsh_set_flyback_vneg_ctl(codec, false);
- wcd_clsh_set_buck_mode(codec, mode);
- wcd_clsh_set_hph_mode(codec, mode);
- wcd_clsh_set_gain_path(codec, mode);
+ wcd_clsh_set_flyback_mode(component, mode);
+ wcd_clsh_set_flyback_vneg_ctl(component, false);
+ wcd_clsh_set_buck_mode(component, mode);
+ wcd_clsh_set_hph_mode(component, mode);
+ wcd_clsh_set_gain_path(component, mode);
} else {
- dev_dbg(codec->dev, "%s:clsh is already enabled\n",
+ dev_dbg(component->dev, "%s:clsh is already enabled\n",
__func__);
}
if (req_state == WCD_CLSH_STATE_HPHL)
- snd_soc_update_bits(codec,
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_RX1_RX_PATH_CFG0,
0x40, 0x40);
if (req_state == WCD_CLSH_STATE_HPHR)
- snd_soc_update_bits(codec,
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_RX2_RX_PATH_CFG0,
0x40, 0x40);
}
@@ -927,11 +969,11 @@ static void wcd_clsh_state_hph_lo(struct snd_soc_codec *codec,
if ((req_state == WCD_CLSH_STATE_HPHL) ||
(req_state == WCD_CLSH_STATE_HPHR)) {
if (req_state == WCD_CLSH_STATE_HPHL)
- snd_soc_update_bits(codec,
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_RX1_RX_PATH_CFG0,
0x40, 0x00);
if (req_state == WCD_CLSH_STATE_HPHR)
- snd_soc_update_bits(codec,
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_RX2_RX_PATH_CFG0,
0x40, 0x00);
/*
@@ -941,10 +983,11 @@ static void wcd_clsh_state_hph_lo(struct snd_soc_codec *codec,
*/
if ((clsh_d->state & WCD_CLSH_STATE_HPH_ST)
!= WCD_CLSH_STATE_HPH_ST) {
- wcd_enable_clsh_block(codec, clsh_d, false);
- wcd_clsh_set_flyback_vneg_ctl(codec, true);
- wcd_clsh_set_flyback_mode(codec, CLS_H_NORMAL);
- wcd_clsh_set_buck_mode(codec, CLS_H_NORMAL);
+ wcd_enable_clsh_block(component, clsh_d, false);
+ wcd_clsh_set_flyback_vneg_ctl(component, true);
+ wcd_clsh_set_flyback_mode(
+ component, CLS_H_NORMAL);
+ wcd_clsh_set_buck_mode(component, CLS_H_NORMAL);
}
} else {
/* LO powerdown.
@@ -960,7 +1003,7 @@ static void wcd_clsh_state_hph_lo(struct snd_soc_codec *codec,
WCD_CLSH_STATE_HPHR);
else
return;
- dev_dbg(codec->dev, "%s: hph_mode = %d\n", __func__,
+ dev_dbg(component->dev, "%s: hph_mode = %d\n", __func__,
hph_mode);
if ((hph_mode == CLS_AB) ||
@@ -973,44 +1016,45 @@ static void wcd_clsh_state_hph_lo(struct snd_soc_codec *codec,
* LO ON), no need to turn on again, just set the
* regulator mode.
*/
- if (wcd_clsh_enable_status(codec)) {
- wcd_clsh_set_buck_regulator_mode(codec,
+ if (wcd_clsh_enable_status(component)) {
+ wcd_clsh_set_buck_regulator_mode(component,
hph_mode);
goto end;
} else {
- dev_dbg(codec->dev, "%s: clsh is not enabled\n",
+ dev_dbg(component->dev, "%s: clsh is not enabled\n",
__func__);
}
- wcd_enable_clsh_block(codec, clsh_d, true);
- snd_soc_update_bits(codec,
+ wcd_enable_clsh_block(component, clsh_d, true);
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_CLSH_K1_MSB,
0x0F, 0x00);
- snd_soc_update_bits(codec,
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_CLSH_K1_LSB,
0xFF, 0xC0);
- wcd_clsh_set_buck_regulator_mode(codec,
+ wcd_clsh_set_buck_regulator_mode(component,
hph_mode);
if (clsh_d->state & WCD_CLSH_STATE_HPHL)
- snd_soc_update_bits(codec,
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_RX1_RX_PATH_CFG0,
0x40, 0x40);
if (clsh_d->state & WCD_CLSH_STATE_HPHR)
- snd_soc_update_bits(codec,
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_RX2_RX_PATH_CFG0,
0x40, 0x40);
- wcd_clsh_set_hph_mode(codec, hph_mode);
+ wcd_clsh_set_hph_mode(component, hph_mode);
}
}
end:
return;
}
-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_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)
@@ -1018,183 +1062,190 @@ static void wcd_clsh_state_hph_st(struct snd_soc_codec *codec,
if (is_enable) {
if (req_state == WCD_CLSH_STATE_HPHL)
- snd_soc_update_bits(codec,
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_RX1_RX_PATH_CFG0,
0x40, 0x40);
if (req_state == WCD_CLSH_STATE_HPHR)
- snd_soc_update_bits(codec,
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_RX2_RX_PATH_CFG0,
0x40, 0x40);
} else {
if (req_state == WCD_CLSH_STATE_HPHL)
- snd_soc_update_bits(codec,
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_RX1_RX_PATH_CFG0,
0x40, 0x00);
if (req_state == WCD_CLSH_STATE_HPHR)
- snd_soc_update_bits(codec,
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_RX2_RX_PATH_CFG0,
0x40, 0x00);
}
}
-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_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) {
- wcd_enable_clsh_block(codec, clsh_d, true);
+ wcd_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, WCD9XXX_A_CDC_CLSH_K1_MSB,
- 0x0F, 0x00);
- snd_soc_update_bits(codec, WCD9XXX_A_CDC_CLSH_K1_LSB,
- 0xFF, 0xC0);
- snd_soc_update_bits(codec,
- WCD9XXX_A_CDC_RX2_RX_PATH_CFG0,
- 0x40, 0x40);
+ snd_soc_component_update_bits(component,
+ WCD9XXX_A_CDC_CLSH_K1_MSB,
+ 0x0F, 0x00);
+ snd_soc_component_update_bits(component,
+ WCD9XXX_A_CDC_CLSH_K1_LSB,
+ 0xFF, 0xC0);
+ snd_soc_component_update_bits(component,
+ WCD9XXX_A_CDC_RX2_RX_PATH_CFG0,
+ 0x40, 0x40);
}
- wcd_clsh_set_buck_regulator_mode(codec, mode);
- wcd_clsh_set_flyback_mode(codec, mode);
- wcd_clsh_gm3_boost_disable(codec, mode);
- wcd_clsh_force_iq_ctl(codec, mode);
- 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_gain_path(codec, mode);
+ wcd_clsh_set_buck_regulator_mode(component, mode);
+ wcd_clsh_set_flyback_mode(component, mode);
+ wcd_clsh_gm3_boost_disable(component, mode);
+ wcd_clsh_force_iq_ctl(component, mode);
+ 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);
+ wcd_clsh_set_gain_path(component, mode);
} else {
- wcd_clsh_set_hph_mode(codec, CLS_H_NORMAL);
+ wcd_clsh_set_hph_mode(component, CLS_H_NORMAL);
if (mode != CLS_AB && mode != CLS_AB_HIFI) {
- snd_soc_update_bits(codec,
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_RX2_RX_PATH_CFG0,
0x40, 0x00);
- wcd_enable_clsh_block(codec, clsh_d, false);
+ wcd_enable_clsh_block(component, clsh_d, false);
}
/* buck and flyback set to default mode and disable */
- wcd_clsh_buck_ctrl(codec, clsh_d, CLS_H_NORMAL, false);
- wcd_clsh_flyback_ctrl(codec, clsh_d, CLS_H_NORMAL, false);
- wcd_clsh_force_iq_ctl(codec, CLS_H_NORMAL);
- wcd_clsh_gm3_boost_disable(codec, CLS_H_NORMAL);
- wcd_clsh_set_flyback_mode(codec, CLS_H_NORMAL);
- wcd_clsh_set_buck_mode(codec, CLS_H_NORMAL);
- wcd_clsh_set_buck_regulator_mode(codec, CLS_H_NORMAL);
+ wcd_clsh_buck_ctrl(component, clsh_d, CLS_H_NORMAL, false);
+ wcd_clsh_flyback_ctrl(component, clsh_d, CLS_H_NORMAL, false);
+ wcd_clsh_force_iq_ctl(component, CLS_H_NORMAL);
+ wcd_clsh_gm3_boost_disable(component, CLS_H_NORMAL);
+ wcd_clsh_set_flyback_mode(component, CLS_H_NORMAL);
+ wcd_clsh_set_buck_mode(component, CLS_H_NORMAL);
+ wcd_clsh_set_buck_regulator_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_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_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) {
- wcd_enable_clsh_block(codec, clsh_d, true);
+ wcd_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, WCD9XXX_A_CDC_CLSH_K1_MSB,
- 0x0F, 0x00);
- snd_soc_update_bits(codec, WCD9XXX_A_CDC_CLSH_K1_LSB,
- 0xFF, 0xC0);
- snd_soc_update_bits(codec,
- WCD9XXX_A_CDC_RX1_RX_PATH_CFG0,
- 0x40, 0x40);
+ snd_soc_component_update_bits(component,
+ WCD9XXX_A_CDC_CLSH_K1_MSB,
+ 0x0F, 0x00);
+ snd_soc_component_update_bits(component,
+ WCD9XXX_A_CDC_CLSH_K1_LSB,
+ 0xFF, 0xC0);
+ snd_soc_component_update_bits(component,
+ WCD9XXX_A_CDC_RX1_RX_PATH_CFG0,
+ 0x40, 0x40);
}
- wcd_clsh_set_buck_regulator_mode(codec, mode);
- wcd_clsh_set_flyback_mode(codec, mode);
- wcd_clsh_gm3_boost_disable(codec, mode);
- wcd_clsh_force_iq_ctl(codec, mode);
- 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_gain_path(codec, mode);
+ wcd_clsh_set_buck_regulator_mode(component, mode);
+ wcd_clsh_set_flyback_mode(component, mode);
+ wcd_clsh_gm3_boost_disable(component, mode);
+ wcd_clsh_force_iq_ctl(component, mode);
+ 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);
+ wcd_clsh_set_gain_path(component, mode);
} else {
- wcd_clsh_set_hph_mode(codec, CLS_H_NORMAL);
+ wcd_clsh_set_hph_mode(component, CLS_H_NORMAL);
if (mode != CLS_AB && mode != CLS_AB_HIFI) {
- snd_soc_update_bits(codec,
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_RX1_RX_PATH_CFG0,
0x40, 0x00);
- wcd_enable_clsh_block(codec, clsh_d, false);
+ wcd_enable_clsh_block(component, clsh_d, false);
}
/* set buck and flyback to Default Mode */
- wcd_clsh_buck_ctrl(codec, clsh_d, CLS_H_NORMAL, false);
- wcd_clsh_flyback_ctrl(codec, clsh_d, CLS_H_NORMAL, false);
- wcd_clsh_force_iq_ctl(codec, CLS_H_NORMAL);
- wcd_clsh_gm3_boost_disable(codec, CLS_H_NORMAL);
- wcd_clsh_set_flyback_mode(codec, CLS_H_NORMAL);
- wcd_clsh_set_buck_mode(codec, CLS_H_NORMAL);
- wcd_clsh_set_buck_regulator_mode(codec, CLS_H_NORMAL);
+ wcd_clsh_buck_ctrl(component, clsh_d, CLS_H_NORMAL, false);
+ wcd_clsh_flyback_ctrl(component, clsh_d, CLS_H_NORMAL, false);
+ wcd_clsh_force_iq_ctl(component, CLS_H_NORMAL);
+ wcd_clsh_gm3_boost_disable(component, CLS_H_NORMAL);
+ wcd_clsh_set_flyback_mode(component, CLS_H_NORMAL);
+ wcd_clsh_set_buck_mode(component, CLS_H_NORMAL);
+ wcd_clsh_set_buck_regulator_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_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: mode: %s cannot be used for EAR\n",
+ dev_err(component->dev, "%s: mode: %s cannot be used for EAR\n",
__func__, mode_to_str(mode));
return;
}
if (is_enable) {
- wcd_enable_clsh_block(codec, clsh_d, true);
- snd_soc_update_bits(codec,
+ wcd_enable_clsh_block(component, clsh_d, true);
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_RX0_RX_PATH_CFG0,
0x40, 0x40);
- 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 {
- snd_soc_update_bits(codec,
+ snd_soc_component_update_bits(component,
WCD9XXX_A_CDC_RX0_RX_PATH_CFG0,
0x40, 0x00);
- wcd_enable_clsh_block(codec, clsh_d, false);
- 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_enable_clsh_block(component, clsh_d, false);
+ 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_err(struct snd_soc_codec *codec,
+static void wcd_clsh_state_err(struct snd_soc_component *component,
struct wcd_clsh_cdc_data *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",
__func__, is_enable ? "enable" : "disable",
state_to_str(req_state, msg, sizeof(msg)));
@@ -1231,14 +1282,14 @@ static bool wcd_clsh_is_state_valid(u8 state)
/*
* Function: wcd_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 wcd_clsh_fsm(struct snd_soc_codec *codec,
+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)
@@ -1252,14 +1303,14 @@ void wcd_clsh_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)));
@@ -1267,9 +1318,9 @@ void wcd_clsh_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)));
@@ -1279,7 +1330,7 @@ void wcd_clsh_fsm(struct snd_soc_codec *codec,
new_state = old_state & (~req_state);
if (new_state < NUM_CLSH_STATES_V2) {
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,
@@ -1287,19 +1338,19 @@ void wcd_clsh_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,