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>
This commit is contained in:

zatwierdzone przez
Gerrit - the friendly Code Review server

rodzic
ee084a068e
commit
15c825d077
@@ -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,17 +210,21 @@ 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,
|
||||
0x02, 0x02);
|
||||
snd_soc_update_bits(dsd_conf->codec, WCD934X_CDC_DSD0_PATH_CTL,
|
||||
0x01, 0x00);
|
||||
snd_soc_update_bits(dsd_conf->codec, WCD934X_CDC_DSD1_PATH_CTL,
|
||||
0x02, 0x02);
|
||||
snd_soc_update_bits(dsd_conf->codec, WCD934X_CDC_DSD1_PATH_CTL,
|
||||
0x01, 0x00);
|
||||
snd_soc_component_update_bits(dsd_conf->component,
|
||||
WCD934X_CDC_DSD0_PATH_CTL,
|
||||
0x02, 0x02);
|
||||
snd_soc_component_update_bits(dsd_conf->component,
|
||||
WCD934X_CDC_DSD0_PATH_CTL,
|
||||
0x01, 0x00);
|
||||
snd_soc_component_update_bits(dsd_conf->component,
|
||||
WCD934X_CDC_DSD1_PATH_CTL,
|
||||
0x02, 0x02);
|
||||
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,
|
||||
0x20, clk_en);
|
||||
dsd_inp_sel = (snd_soc_read(codec, WCD934X_CDC_DSD0_CFG0) &
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_RX7_RX_PATH_MIX_CTL,
|
||||
0x20, clk_en);
|
||||
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,
|
||||
0x20, clk_en);
|
||||
dsd_inp_sel = (snd_soc_read(codec, WCD934X_CDC_DSD1_CFG0) &
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_RX8_RX_PATH_MIX_CTL,
|
||||
0x20, clk_en);
|
||||
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,85 +382,99 @@ 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,
|
||||
0x01, 0x01);
|
||||
snd_soc_update_bits(dsd_conf->codec, WCD934X_CDC_TOP_TOP_CFG0,
|
||||
0x01, 0x00);
|
||||
snd_soc_component_update_bits(dsd_conf->component,
|
||||
WCD934X_CDC_TOP_TOP_CFG0,
|
||||
0x01, 0x01);
|
||||
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,
|
||||
0x02, 0x02);
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DSD0_PATH_CTL,
|
||||
0x02, 0x00);
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DSD0_PATH_CTL,
|
||||
0x01, 0x01);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DSD0_PATH_CTL,
|
||||
0x02, 0x02);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DSD0_PATH_CTL,
|
||||
0x02, 0x00);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DSD0_PATH_CTL,
|
||||
0x01, 0x01);
|
||||
/* Apply Gain */
|
||||
snd_soc_write(codec, WCD934X_CDC_DSD0_CFG1,
|
||||
dsd_conf->volume[DSD0]);
|
||||
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,
|
||||
0x02, 0x02);
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DSD1_PATH_CTL,
|
||||
0x02, 0x00);
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DSD1_PATH_CTL,
|
||||
0x01, 0x01);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DSD1_PATH_CTL,
|
||||
0x02, 0x02);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DSD1_PATH_CTL,
|
||||
0x02, 0x00);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DSD1_PATH_CTL,
|
||||
0x01, 0x01);
|
||||
/* Apply Gain */
|
||||
snd_soc_write(codec, WCD934X_CDC_DSD1_CFG1,
|
||||
dsd_conf->volume[DSD1]);
|
||||
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,
|
||||
0x02, 0x02);
|
||||
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,
|
||||
0x04, 0x04);
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DSD0_PATH_CTL,
|
||||
0x01, 0x00);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DSD0_CFG2,
|
||||
0x04, 0x04);
|
||||
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,
|
||||
0x04, 0x04);
|
||||
snd_soc_update_bits(codec, WCD934X_CDC_DSD1_PATH_CTL,
|
||||
0x01, 0x00);
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_CDC_DSD1_CFG2,
|
||||
0x04, 0x04);
|
||||
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;
|
||||
}
|
||||
|
Plik diff jest za duży
Load Diff
@@ -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,
|
||||
0xFC, vth << 2);
|
||||
dev_dbg(codec->dev, "%s: btn_high[%d]: %d, vth: %d\n",
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD934X_ANA_MBHC_BTN0 + i,
|
||||
0xFC, vth << 2);
|
||||
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,
|
||||
0xC0, pull_up_cur << 6);
|
||||
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,
|
||||
int micb_num, bool req_en)
|
||||
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,
|
||||
zdet_param->btn5);
|
||||
snd_soc_update_bits(codec, WCD934X_ANA_MBHC_BTN6, 0xFC,
|
||||
zdet_param->btn6);
|
||||
snd_soc_update_bits(codec, 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,
|
||||
0x70, zdet_param->ldo_ctl << 4);
|
||||
snd_soc_component_update_bits(component, WCD934X_ANA_MBHC_BTN5, 0xFC,
|
||||
zdet_param->btn5);
|
||||
snd_soc_component_update_bits(component, WCD934X_ANA_MBHC_BTN6, 0xFC,
|
||||
zdet_param->btn6);
|
||||
snd_soc_component_update_bits(component, WCD934X_ANA_MBHC_BTN7, 0xFC,
|
||||
zdet_param->btn7);
|
||||
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;
|
||||
}
|
||||
|
Plik diff jest za duży
Load Diff
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user