mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-21 08:53:41 +00:00
Merge remote-tracking branches 'asoc/topic/rt298', 'asoc/topic/rt5514', 'asoc/topic/rt5616', 'asoc/topic/rt5631' and 'asoc/topic/rt5640' into asoc-next
This commit is contained in:
commit
bffd6430c6
@ -290,9 +290,10 @@ static int rt298_jack_detect(struct rt298_priv *rt298, bool *hp, bool *mic)
|
||||
regmap_read(rt298->regmap, RT298_GET_MIC1_SENSE, &buf);
|
||||
*mic = buf & 0x80000000;
|
||||
}
|
||||
|
||||
snd_soc_dapm_disable_pin(dapm, "HV");
|
||||
snd_soc_dapm_disable_pin(dapm, "VREF");
|
||||
if (!*mic) {
|
||||
snd_soc_dapm_disable_pin(dapm, "HV");
|
||||
snd_soc_dapm_disable_pin(dapm, "VREF");
|
||||
}
|
||||
if (!*hp)
|
||||
snd_soc_dapm_disable_pin(dapm, "LDO1");
|
||||
snd_soc_dapm_sync(dapm);
|
||||
|
@ -470,9 +470,9 @@ static int __maybe_unused rt5514_suspend(struct device *dev)
|
||||
|
||||
static int __maybe_unused rt5514_resume(struct device *dev)
|
||||
{
|
||||
struct snd_soc_platform *platform = snd_soc_lookup_platform(dev);
|
||||
struct snd_soc_component *component = snd_soc_lookup_component(dev, DRV_NAME);
|
||||
struct rt5514_dsp *rt5514_dsp =
|
||||
snd_soc_platform_get_drvdata(platform);
|
||||
snd_soc_component_get_drvdata(component);
|
||||
int irq = to_spi_device(dev)->irq;
|
||||
u8 buf[8];
|
||||
|
||||
|
@ -327,14 +327,13 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol,
|
||||
{
|
||||
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
|
||||
struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
|
||||
struct snd_soc_codec *codec = rt5514->codec;
|
||||
const struct firmware *fw = NULL;
|
||||
u8 buf[8];
|
||||
|
||||
if (ucontrol->value.integer.value[0] == rt5514->dsp_enabled)
|
||||
return 0;
|
||||
|
||||
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) {
|
||||
if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
|
||||
rt5514->dsp_enabled = ucontrol->value.integer.value[0];
|
||||
|
||||
if (rt5514->dsp_enabled) {
|
||||
@ -342,11 +341,11 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol,
|
||||
!IS_ERR(rt5514->dsp_calib_clk)) {
|
||||
if (clk_set_rate(rt5514->dsp_calib_clk,
|
||||
rt5514->pdata.dsp_calib_clk_rate))
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"Can't set rate for mclk");
|
||||
|
||||
if (clk_prepare_enable(rt5514->dsp_calib_clk))
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"Can't enable dsp_calib_clk");
|
||||
|
||||
rt5514_calibration(rt5514, true);
|
||||
@ -354,11 +353,11 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol,
|
||||
msleep(20);
|
||||
#if IS_ENABLED(CONFIG_SND_SOC_RT5514_SPI)
|
||||
rt5514_spi_burst_read(RT5514_PLL3_CALIB_CTRL6 |
|
||||
RT5514_DSP_MAPPING,
|
||||
(u8 *)&buf, sizeof(buf));
|
||||
RT5514_DSP_MAPPING, buf, sizeof(buf));
|
||||
#else
|
||||
dev_err(codec->dev, "There is no SPI driver for"
|
||||
dev_err(component->dev, "There is no SPI driver for"
|
||||
" loading the firmware\n");
|
||||
memset(buf, 0, sizeof(buf));
|
||||
#endif
|
||||
rt5514->pll3_cal_value = buf[0] | buf[1] << 8 |
|
||||
buf[2] << 16 | buf[3] << 24;
|
||||
@ -369,26 +368,26 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol,
|
||||
|
||||
rt5514_enable_dsp_prepare(rt5514);
|
||||
|
||||
request_firmware(&fw, RT5514_FIRMWARE1, codec->dev);
|
||||
request_firmware(&fw, RT5514_FIRMWARE1, component->dev);
|
||||
if (fw) {
|
||||
#if IS_ENABLED(CONFIG_SND_SOC_RT5514_SPI)
|
||||
rt5514_spi_burst_write(0x4ff60000, fw->data,
|
||||
((fw->size/8)+1)*8);
|
||||
#else
|
||||
dev_err(codec->dev, "There is no SPI driver for"
|
||||
dev_err(component->dev, "There is no SPI driver for"
|
||||
" loading the firmware\n");
|
||||
#endif
|
||||
release_firmware(fw);
|
||||
fw = NULL;
|
||||
}
|
||||
|
||||
request_firmware(&fw, RT5514_FIRMWARE2, codec->dev);
|
||||
request_firmware(&fw, RT5514_FIRMWARE2, component->dev);
|
||||
if (fw) {
|
||||
#if IS_ENABLED(CONFIG_SND_SOC_RT5514_SPI)
|
||||
rt5514_spi_burst_write(0x4ffc0000, fw->data,
|
||||
((fw->size/8)+1)*8);
|
||||
#else
|
||||
dev_err(codec->dev, "There is no SPI driver for"
|
||||
dev_err(component->dev, "There is no SPI driver for"
|
||||
" loading the firmware\n");
|
||||
#endif
|
||||
release_firmware(fw);
|
||||
@ -492,7 +491,7 @@ static const struct snd_kcontrol_new rt5514_sto2_dmic_mux =
|
||||
* Choose divider parameter that gives the highest possible DMIC frequency in
|
||||
* 1MHz - 3MHz range.
|
||||
*/
|
||||
static int rt5514_calc_dmic_clk(struct snd_soc_codec *codec, int rate)
|
||||
static int rt5514_calc_dmic_clk(struct snd_soc_component *component, int rate)
|
||||
{
|
||||
int div[] = {2, 3, 4, 8, 12, 16, 24, 32};
|
||||
int i;
|
||||
@ -508,20 +507,20 @@ static int rt5514_calc_dmic_clk(struct snd_soc_codec *codec, int rate)
|
||||
return i;
|
||||
}
|
||||
|
||||
dev_warn(codec->dev, "Base clock rate %d is too high\n", rate);
|
||||
dev_warn(component->dev, "Base clock rate %d is too high\n", rate);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int rt5514_set_dmic_clk(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 rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
|
||||
struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
|
||||
int idx;
|
||||
|
||||
idx = rt5514_calc_dmic_clk(codec, rt5514->sysclk);
|
||||
idx = rt5514_calc_dmic_clk(component, rt5514->sysclk);
|
||||
if (idx < 0)
|
||||
dev_err(codec->dev, "Failed to set DMIC clock\n");
|
||||
dev_err(component->dev, "Failed to set DMIC clock\n");
|
||||
else
|
||||
regmap_update_bits(rt5514->regmap, RT5514_CLK_CTRL1,
|
||||
RT5514_CLK_DMIC_OUT_SEL_MASK,
|
||||
@ -536,8 +535,8 @@ static int rt5514_set_dmic_clk(struct snd_soc_dapm_widget *w,
|
||||
static int rt5514_is_sys_clk_from_pll(struct snd_soc_dapm_widget *source,
|
||||
struct snd_soc_dapm_widget *sink)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
|
||||
struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm);
|
||||
struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
if (rt5514->sysclk_src == RT5514_SCLK_S_PLL1)
|
||||
return 1;
|
||||
@ -548,8 +547,8 @@ static int rt5514_is_sys_clk_from_pll(struct snd_soc_dapm_widget *source,
|
||||
static int rt5514_i2s_use_asrc(struct snd_soc_dapm_widget *source,
|
||||
struct snd_soc_dapm_widget *sink)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
|
||||
struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm);
|
||||
struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
return (rt5514->sysclk > rt5514->lrck * 384);
|
||||
}
|
||||
@ -751,21 +750,21 @@ static const struct snd_soc_dapm_route rt5514_dapm_routes[] = {
|
||||
static int rt5514_hw_params(struct snd_pcm_substream *substream,
|
||||
struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = dai->component;
|
||||
struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
|
||||
int pre_div, bclk_ms, frame_size;
|
||||
unsigned int val_len = 0;
|
||||
|
||||
rt5514->lrck = params_rate(params);
|
||||
pre_div = rl6231_get_clk_info(rt5514->sysclk, rt5514->lrck);
|
||||
if (pre_div < 0) {
|
||||
dev_err(codec->dev, "Unsupported clock setting\n");
|
||||
dev_err(component->dev, "Unsupported clock setting\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
frame_size = snd_soc_params_to_frame_size(params);
|
||||
if (frame_size < 0) {
|
||||
dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size);
|
||||
dev_err(component->dev, "Unsupported frame size: %d\n", frame_size);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@ -808,8 +807,8 @@ static int rt5514_hw_params(struct snd_pcm_substream *substream,
|
||||
|
||||
static int rt5514_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = dai->component;
|
||||
struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
|
||||
unsigned int reg_val = 0;
|
||||
|
||||
switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
|
||||
@ -862,8 +861,8 @@ static int rt5514_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
|
||||
static int rt5514_set_dai_sysclk(struct snd_soc_dai *dai,
|
||||
int clk_id, unsigned int freq, int dir)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = dai->component;
|
||||
struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
|
||||
unsigned int reg_val = 0;
|
||||
|
||||
if (freq == rt5514->sysclk && clk_id == rt5514->sysclk_src)
|
||||
@ -879,7 +878,7 @@ static int rt5514_set_dai_sysclk(struct snd_soc_dai *dai,
|
||||
break;
|
||||
|
||||
default:
|
||||
dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id);
|
||||
dev_err(component->dev, "Invalid clock id (%d)\n", clk_id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@ -897,13 +896,13 @@ static int rt5514_set_dai_sysclk(struct snd_soc_dai *dai,
|
||||
static int rt5514_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
|
||||
unsigned int freq_in, unsigned int freq_out)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = dai->component;
|
||||
struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
|
||||
struct rl6231_pll_code pll_code;
|
||||
int ret;
|
||||
|
||||
if (!freq_in || !freq_out) {
|
||||
dev_dbg(codec->dev, "PLL disabled\n");
|
||||
dev_dbg(component->dev, "PLL disabled\n");
|
||||
|
||||
rt5514->pll_in = 0;
|
||||
rt5514->pll_out = 0;
|
||||
@ -930,17 +929,17 @@ static int rt5514_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
|
||||
break;
|
||||
|
||||
default:
|
||||
dev_err(codec->dev, "Unknown PLL source %d\n", source);
|
||||
dev_err(component->dev, "Unknown PLL source %d\n", source);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = rl6231_pll_calc(freq_in, freq_out, &pll_code);
|
||||
if (ret < 0) {
|
||||
dev_err(codec->dev, "Unsupport input clock %d\n", freq_in);
|
||||
dev_err(component->dev, "Unsupport input clock %d\n", freq_in);
|
||||
return ret;
|
||||
}
|
||||
|
||||
dev_dbg(codec->dev, "bypass=%d m=%d n=%d k=%d\n",
|
||||
dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n",
|
||||
pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code),
|
||||
pll_code.n_code, pll_code.k_code);
|
||||
|
||||
@ -961,8 +960,8 @@ static int rt5514_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
|
||||
static int rt5514_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
|
||||
unsigned int rx_mask, int slots, int slot_width)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = dai->component;
|
||||
struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
|
||||
unsigned int val = 0, val2 = 0;
|
||||
|
||||
if (rx_mask || tx_mask)
|
||||
@ -1047,10 +1046,10 @@ static int rt5514_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rt5514_set_bias_level(struct snd_soc_codec *codec,
|
||||
static int rt5514_set_bias_level(struct snd_soc_component *component,
|
||||
enum snd_soc_bias_level level)
|
||||
{
|
||||
struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec);
|
||||
struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
|
||||
int ret;
|
||||
|
||||
switch (level) {
|
||||
@ -1058,7 +1057,7 @@ static int rt5514_set_bias_level(struct snd_soc_codec *codec,
|
||||
if (IS_ERR(rt5514->mclk))
|
||||
break;
|
||||
|
||||
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_ON) {
|
||||
if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) {
|
||||
clk_disable_unprepare(rt5514->mclk);
|
||||
} else {
|
||||
ret = clk_prepare_enable(rt5514->mclk);
|
||||
@ -1068,7 +1067,7 @@ static int rt5514_set_bias_level(struct snd_soc_codec *codec,
|
||||
break;
|
||||
|
||||
case SND_SOC_BIAS_STANDBY:
|
||||
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) {
|
||||
if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
|
||||
/*
|
||||
* If the DSP is enabled in start of recording, the DSP
|
||||
* should be disabled, and sync back to normal recording
|
||||
@ -1092,13 +1091,13 @@ static int rt5514_set_bias_level(struct snd_soc_codec *codec,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rt5514_probe(struct snd_soc_codec *codec)
|
||||
static int rt5514_probe(struct snd_soc_component *component)
|
||||
{
|
||||
struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec);
|
||||
struct platform_device *pdev = container_of(codec->dev,
|
||||
struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
|
||||
struct platform_device *pdev = container_of(component->dev,
|
||||
struct platform_device, dev);
|
||||
|
||||
rt5514->mclk = devm_clk_get(codec->dev, "mclk");
|
||||
rt5514->mclk = devm_clk_get(component->dev, "mclk");
|
||||
if (PTR_ERR(rt5514->mclk) == -EPROBE_DEFER)
|
||||
return -EPROBE_DEFER;
|
||||
|
||||
@ -1109,7 +1108,7 @@ static int rt5514_probe(struct snd_soc_codec *codec)
|
||||
return -EPROBE_DEFER;
|
||||
}
|
||||
|
||||
rt5514->codec = codec;
|
||||
rt5514->component = component;
|
||||
rt5514->pll3_cal_value = 0x0078b000;
|
||||
|
||||
return 0;
|
||||
@ -1162,18 +1161,18 @@ static struct snd_soc_dai_driver rt5514_dai[] = {
|
||||
}
|
||||
};
|
||||
|
||||
static const struct snd_soc_codec_driver soc_codec_dev_rt5514 = {
|
||||
.probe = rt5514_probe,
|
||||
.idle_bias_off = true,
|
||||
.set_bias_level = rt5514_set_bias_level,
|
||||
.component_driver = {
|
||||
.controls = rt5514_snd_controls,
|
||||
.num_controls = ARRAY_SIZE(rt5514_snd_controls),
|
||||
.dapm_widgets = rt5514_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(rt5514_dapm_widgets),
|
||||
.dapm_routes = rt5514_dapm_routes,
|
||||
.num_dapm_routes = ARRAY_SIZE(rt5514_dapm_routes),
|
||||
},
|
||||
static const struct snd_soc_component_driver soc_component_dev_rt5514 = {
|
||||
.probe = rt5514_probe,
|
||||
.set_bias_level = rt5514_set_bias_level,
|
||||
.controls = rt5514_snd_controls,
|
||||
.num_controls = ARRAY_SIZE(rt5514_snd_controls),
|
||||
.dapm_widgets = rt5514_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(rt5514_dapm_widgets),
|
||||
.dapm_routes = rt5514_dapm_routes,
|
||||
.num_dapm_routes = ARRAY_SIZE(rt5514_dapm_routes),
|
||||
.use_pmdown_time = 1,
|
||||
.endianness = 1,
|
||||
.non_legacy_dai_naming = 1,
|
||||
};
|
||||
|
||||
static const struct regmap_config rt5514_i2c_regmap = {
|
||||
@ -1313,17 +1312,11 @@ static int rt5514_i2c_probe(struct i2c_client *i2c,
|
||||
if (ret != 0)
|
||||
dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret);
|
||||
|
||||
return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5514,
|
||||
return devm_snd_soc_register_component(&i2c->dev,
|
||||
&soc_component_dev_rt5514,
|
||||
rt5514_dai, ARRAY_SIZE(rt5514_dai));
|
||||
}
|
||||
|
||||
static int rt5514_i2c_remove(struct i2c_client *i2c)
|
||||
{
|
||||
snd_soc_unregister_codec(&i2c->dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct dev_pm_ops rt5514_i2_pm_ops = {
|
||||
SET_SYSTEM_SLEEP_PM_OPS(NULL, rt5514_i2c_resume)
|
||||
};
|
||||
@ -1336,7 +1329,6 @@ static struct i2c_driver rt5514_i2c_driver = {
|
||||
.pm = &rt5514_i2_pm_ops,
|
||||
},
|
||||
.probe = rt5514_i2c_probe,
|
||||
.remove = rt5514_i2c_remove,
|
||||
.id_table = rt5514_i2c_id,
|
||||
};
|
||||
module_i2c_driver(rt5514_i2c_driver);
|
||||
|
@ -272,7 +272,7 @@ enum {
|
||||
|
||||
struct rt5514_priv {
|
||||
struct rt5514_platform_data pdata;
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
struct regmap *i2c_regmap, *regmap;
|
||||
struct clk *mclk, *dsp_calib_clk;
|
||||
int sysclk;
|
||||
|
@ -142,7 +142,7 @@ static const struct reg_default rt5616_reg[] = {
|
||||
};
|
||||
|
||||
struct rt5616_priv {
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
struct delayed_work patch_work;
|
||||
struct regmap *regmap;
|
||||
struct clk *mclk;
|
||||
@ -351,7 +351,7 @@ static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source,
|
||||
{
|
||||
unsigned int val;
|
||||
|
||||
val = snd_soc_read(snd_soc_dapm_to_codec(source->dapm), RT5616_GLB_CLK);
|
||||
val = snd_soc_component_read32(snd_soc_dapm_to_component(source->dapm), RT5616_GLB_CLK);
|
||||
val &= RT5616_SCLK_SRC_MASK;
|
||||
if (val == RT5616_SCLK_SRC_PLL1)
|
||||
return 1;
|
||||
@ -466,16 +466,16 @@ static const struct snd_kcontrol_new rt5616_lout_mix[] = {
|
||||
static int rt5616_adc_event(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
|
||||
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_POST_PMU:
|
||||
snd_soc_update_bits(codec, RT5616_ADC_DIG_VOL,
|
||||
snd_soc_component_update_bits(component, RT5616_ADC_DIG_VOL,
|
||||
RT5616_L_MUTE | RT5616_R_MUTE, 0);
|
||||
break;
|
||||
|
||||
case SND_SOC_DAPM_POST_PMD:
|
||||
snd_soc_update_bits(codec, RT5616_ADC_DIG_VOL,
|
||||
snd_soc_component_update_bits(component, RT5616_ADC_DIG_VOL,
|
||||
RT5616_L_MUTE | RT5616_R_MUTE,
|
||||
RT5616_L_MUTE | RT5616_R_MUTE);
|
||||
break;
|
||||
@ -490,51 +490,51 @@ static int rt5616_adc_event(struct snd_soc_dapm_widget *w,
|
||||
static int rt5616_charge_pump_event(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
|
||||
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_POST_PMU:
|
||||
/* depop parameters */
|
||||
snd_soc_update_bits(codec, RT5616_DEPOP_M2,
|
||||
snd_soc_component_update_bits(component, RT5616_DEPOP_M2,
|
||||
RT5616_DEPOP_MASK, RT5616_DEPOP_MAN);
|
||||
snd_soc_update_bits(codec, RT5616_DEPOP_M1,
|
||||
snd_soc_component_update_bits(component, RT5616_DEPOP_M1,
|
||||
RT5616_HP_CP_MASK | RT5616_HP_SG_MASK |
|
||||
RT5616_HP_CB_MASK, RT5616_HP_CP_PU |
|
||||
RT5616_HP_SG_DIS | RT5616_HP_CB_PU);
|
||||
snd_soc_write(codec, RT5616_PR_BASE +
|
||||
snd_soc_component_write(component, RT5616_PR_BASE +
|
||||
RT5616_HP_DCC_INT1, 0x9f00);
|
||||
/* headphone amp power on */
|
||||
snd_soc_update_bits(codec, RT5616_PWR_ANLG1,
|
||||
snd_soc_component_update_bits(component, RT5616_PWR_ANLG1,
|
||||
RT5616_PWR_FV1 | RT5616_PWR_FV2, 0);
|
||||
snd_soc_update_bits(codec, RT5616_PWR_VOL,
|
||||
snd_soc_component_update_bits(component, RT5616_PWR_VOL,
|
||||
RT5616_PWR_HV_L | RT5616_PWR_HV_R,
|
||||
RT5616_PWR_HV_L | RT5616_PWR_HV_R);
|
||||
snd_soc_update_bits(codec, RT5616_PWR_ANLG1,
|
||||
snd_soc_component_update_bits(component, RT5616_PWR_ANLG1,
|
||||
RT5616_PWR_HP_L | RT5616_PWR_HP_R |
|
||||
RT5616_PWR_HA, RT5616_PWR_HP_L |
|
||||
RT5616_PWR_HP_R | RT5616_PWR_HA);
|
||||
msleep(50);
|
||||
snd_soc_update_bits(codec, RT5616_PWR_ANLG1,
|
||||
snd_soc_component_update_bits(component, RT5616_PWR_ANLG1,
|
||||
RT5616_PWR_FV1 | RT5616_PWR_FV2,
|
||||
RT5616_PWR_FV1 | RT5616_PWR_FV2);
|
||||
|
||||
snd_soc_update_bits(codec, RT5616_CHARGE_PUMP,
|
||||
snd_soc_component_update_bits(component, RT5616_CHARGE_PUMP,
|
||||
RT5616_PM_HP_MASK, RT5616_PM_HP_HV);
|
||||
snd_soc_update_bits(codec, RT5616_PR_BASE +
|
||||
snd_soc_component_update_bits(component, RT5616_PR_BASE +
|
||||
RT5616_CHOP_DAC_ADC, 0x0200, 0x0200);
|
||||
snd_soc_update_bits(codec, RT5616_DEPOP_M1,
|
||||
snd_soc_component_update_bits(component, RT5616_DEPOP_M1,
|
||||
RT5616_HP_CO_MASK | RT5616_HP_SG_MASK,
|
||||
RT5616_HP_CO_EN | RT5616_HP_SG_EN);
|
||||
break;
|
||||
case SND_SOC_DAPM_PRE_PMD:
|
||||
snd_soc_update_bits(codec, RT5616_PR_BASE +
|
||||
snd_soc_component_update_bits(component, RT5616_PR_BASE +
|
||||
RT5616_CHOP_DAC_ADC, 0x0200, 0x0);
|
||||
snd_soc_update_bits(codec, RT5616_DEPOP_M1,
|
||||
snd_soc_component_update_bits(component, RT5616_DEPOP_M1,
|
||||
RT5616_HP_SG_MASK | RT5616_HP_L_SMT_MASK |
|
||||
RT5616_HP_R_SMT_MASK, RT5616_HP_SG_DIS |
|
||||
RT5616_HP_L_SMT_DIS | RT5616_HP_R_SMT_DIS);
|
||||
/* headphone amp power down */
|
||||
snd_soc_update_bits(codec, RT5616_DEPOP_M1,
|
||||
snd_soc_component_update_bits(component, RT5616_DEPOP_M1,
|
||||
RT5616_SMT_TRIG_MASK |
|
||||
RT5616_HP_CD_PD_MASK | RT5616_HP_CO_MASK |
|
||||
RT5616_HP_CP_MASK | RT5616_HP_SG_MASK |
|
||||
@ -542,7 +542,7 @@ static int rt5616_charge_pump_event(struct snd_soc_dapm_widget *w,
|
||||
RT5616_SMT_TRIG_DIS | RT5616_HP_CD_PD_EN |
|
||||
RT5616_HP_CO_DIS | RT5616_HP_CP_PD |
|
||||
RT5616_HP_SG_EN | RT5616_HP_CB_PD);
|
||||
snd_soc_update_bits(codec, RT5616_PWR_ANLG1,
|
||||
snd_soc_component_update_bits(component, RT5616_PWR_ANLG1,
|
||||
RT5616_PWR_HP_L | RT5616_PWR_HP_R |
|
||||
RT5616_PWR_HA, 0);
|
||||
break;
|
||||
@ -556,61 +556,61 @@ static int rt5616_charge_pump_event(struct snd_soc_dapm_widget *w,
|
||||
static int rt5616_hp_event(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
|
||||
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_POST_PMU:
|
||||
/* headphone unmute sequence */
|
||||
snd_soc_update_bits(codec, RT5616_DEPOP_M3,
|
||||
snd_soc_component_update_bits(component, RT5616_DEPOP_M3,
|
||||
RT5616_CP_FQ1_MASK | RT5616_CP_FQ2_MASK |
|
||||
RT5616_CP_FQ3_MASK,
|
||||
RT5616_CP_FQ_192_KHZ << RT5616_CP_FQ1_SFT |
|
||||
RT5616_CP_FQ_12_KHZ << RT5616_CP_FQ2_SFT |
|
||||
RT5616_CP_FQ_192_KHZ << RT5616_CP_FQ3_SFT);
|
||||
snd_soc_write(codec, RT5616_PR_BASE +
|
||||
snd_soc_component_write(component, RT5616_PR_BASE +
|
||||
RT5616_MAMP_INT_REG2, 0xfc00);
|
||||
snd_soc_update_bits(codec, RT5616_DEPOP_M1,
|
||||
snd_soc_component_update_bits(component, RT5616_DEPOP_M1,
|
||||
RT5616_SMT_TRIG_MASK, RT5616_SMT_TRIG_EN);
|
||||
snd_soc_update_bits(codec, RT5616_DEPOP_M1,
|
||||
snd_soc_component_update_bits(component, RT5616_DEPOP_M1,
|
||||
RT5616_RSTN_MASK, RT5616_RSTN_EN);
|
||||
snd_soc_update_bits(codec, RT5616_DEPOP_M1,
|
||||
snd_soc_component_update_bits(component, RT5616_DEPOP_M1,
|
||||
RT5616_RSTN_MASK | RT5616_HP_L_SMT_MASK |
|
||||
RT5616_HP_R_SMT_MASK, RT5616_RSTN_DIS |
|
||||
RT5616_HP_L_SMT_EN | RT5616_HP_R_SMT_EN);
|
||||
snd_soc_update_bits(codec, RT5616_HP_VOL,
|
||||
snd_soc_component_update_bits(component, RT5616_HP_VOL,
|
||||
RT5616_L_MUTE | RT5616_R_MUTE, 0);
|
||||
msleep(100);
|
||||
snd_soc_update_bits(codec, RT5616_DEPOP_M1,
|
||||
snd_soc_component_update_bits(component, RT5616_DEPOP_M1,
|
||||
RT5616_HP_SG_MASK | RT5616_HP_L_SMT_MASK |
|
||||
RT5616_HP_R_SMT_MASK, RT5616_HP_SG_DIS |
|
||||
RT5616_HP_L_SMT_DIS | RT5616_HP_R_SMT_DIS);
|
||||
msleep(20);
|
||||
snd_soc_update_bits(codec, RT5616_HP_CALIB_AMP_DET,
|
||||
snd_soc_component_update_bits(component, RT5616_HP_CALIB_AMP_DET,
|
||||
RT5616_HPD_PS_MASK, RT5616_HPD_PS_EN);
|
||||
break;
|
||||
|
||||
case SND_SOC_DAPM_PRE_PMD:
|
||||
/* headphone mute sequence */
|
||||
snd_soc_update_bits(codec, RT5616_DEPOP_M3,
|
||||
snd_soc_component_update_bits(component, RT5616_DEPOP_M3,
|
||||
RT5616_CP_FQ1_MASK | RT5616_CP_FQ2_MASK |
|
||||
RT5616_CP_FQ3_MASK,
|
||||
RT5616_CP_FQ_96_KHZ << RT5616_CP_FQ1_SFT |
|
||||
RT5616_CP_FQ_12_KHZ << RT5616_CP_FQ2_SFT |
|
||||
RT5616_CP_FQ_96_KHZ << RT5616_CP_FQ3_SFT);
|
||||
snd_soc_write(codec, RT5616_PR_BASE +
|
||||
snd_soc_component_write(component, RT5616_PR_BASE +
|
||||
RT5616_MAMP_INT_REG2, 0xfc00);
|
||||
snd_soc_update_bits(codec, RT5616_DEPOP_M1,
|
||||
snd_soc_component_update_bits(component, RT5616_DEPOP_M1,
|
||||
RT5616_HP_SG_MASK, RT5616_HP_SG_EN);
|
||||
snd_soc_update_bits(codec, RT5616_DEPOP_M1,
|
||||
snd_soc_component_update_bits(component, RT5616_DEPOP_M1,
|
||||
RT5616_RSTP_MASK, RT5616_RSTP_EN);
|
||||
snd_soc_update_bits(codec, RT5616_DEPOP_M1,
|
||||
snd_soc_component_update_bits(component, RT5616_DEPOP_M1,
|
||||
RT5616_RSTP_MASK | RT5616_HP_L_SMT_MASK |
|
||||
RT5616_HP_R_SMT_MASK, RT5616_RSTP_DIS |
|
||||
RT5616_HP_L_SMT_EN | RT5616_HP_R_SMT_EN);
|
||||
snd_soc_update_bits(codec, RT5616_HP_CALIB_AMP_DET,
|
||||
snd_soc_component_update_bits(component, RT5616_HP_CALIB_AMP_DET,
|
||||
RT5616_HPD_PS_MASK, RT5616_HPD_PS_DIS);
|
||||
msleep(90);
|
||||
snd_soc_update_bits(codec, RT5616_HP_VOL,
|
||||
snd_soc_component_update_bits(component, RT5616_HP_VOL,
|
||||
RT5616_L_MUTE | RT5616_R_MUTE,
|
||||
RT5616_L_MUTE | RT5616_R_MUTE);
|
||||
msleep(30);
|
||||
@ -626,21 +626,21 @@ static int rt5616_hp_event(struct snd_soc_dapm_widget *w,
|
||||
static int rt5616_lout_event(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
|
||||
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_POST_PMU:
|
||||
snd_soc_update_bits(codec, RT5616_PWR_ANLG1,
|
||||
snd_soc_component_update_bits(component, RT5616_PWR_ANLG1,
|
||||
RT5616_PWR_LM, RT5616_PWR_LM);
|
||||
snd_soc_update_bits(codec, RT5616_LOUT_CTRL1,
|
||||
snd_soc_component_update_bits(component, RT5616_LOUT_CTRL1,
|
||||
RT5616_L_MUTE | RT5616_R_MUTE, 0);
|
||||
break;
|
||||
|
||||
case SND_SOC_DAPM_PRE_PMD:
|
||||
snd_soc_update_bits(codec, RT5616_LOUT_CTRL1,
|
||||
snd_soc_component_update_bits(component, RT5616_LOUT_CTRL1,
|
||||
RT5616_L_MUTE | RT5616_R_MUTE,
|
||||
RT5616_L_MUTE | RT5616_R_MUTE);
|
||||
snd_soc_update_bits(codec, RT5616_PWR_ANLG1,
|
||||
snd_soc_component_update_bits(component, RT5616_PWR_ANLG1,
|
||||
RT5616_PWR_LM, 0);
|
||||
break;
|
||||
|
||||
@ -654,16 +654,16 @@ static int rt5616_lout_event(struct snd_soc_dapm_widget *w,
|
||||
static int rt5616_bst1_event(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
|
||||
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_POST_PMU:
|
||||
snd_soc_update_bits(codec, RT5616_PWR_ANLG2,
|
||||
snd_soc_component_update_bits(component, RT5616_PWR_ANLG2,
|
||||
RT5616_PWR_BST1_OP2, RT5616_PWR_BST1_OP2);
|
||||
break;
|
||||
|
||||
case SND_SOC_DAPM_PRE_PMD:
|
||||
snd_soc_update_bits(codec, RT5616_PWR_ANLG2,
|
||||
snd_soc_component_update_bits(component, RT5616_PWR_ANLG2,
|
||||
RT5616_PWR_BST1_OP2, 0);
|
||||
break;
|
||||
|
||||
@ -677,16 +677,16 @@ static int rt5616_bst1_event(struct snd_soc_dapm_widget *w,
|
||||
static int rt5616_bst2_event(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
|
||||
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_POST_PMU:
|
||||
snd_soc_update_bits(codec, RT5616_PWR_ANLG2,
|
||||
snd_soc_component_update_bits(component, RT5616_PWR_ANLG2,
|
||||
RT5616_PWR_BST2_OP2, RT5616_PWR_BST2_OP2);
|
||||
break;
|
||||
|
||||
case SND_SOC_DAPM_PRE_PMD:
|
||||
snd_soc_update_bits(codec, RT5616_PWR_ANLG2,
|
||||
snd_soc_component_update_bits(component, RT5616_PWR_ANLG2,
|
||||
RT5616_PWR_BST2_OP2, 0);
|
||||
break;
|
||||
|
||||
@ -960,8 +960,8 @@ static int rt5616_hw_params(struct snd_pcm_substream *substream,
|
||||
struct snd_pcm_hw_params *params,
|
||||
struct snd_soc_dai *dai)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct rt5616_priv *rt5616 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = dai->component;
|
||||
struct rt5616_priv *rt5616 = snd_soc_component_get_drvdata(component);
|
||||
unsigned int val_len = 0, val_clk, mask_clk;
|
||||
int pre_div, bclk_ms, frame_size;
|
||||
|
||||
@ -970,12 +970,12 @@ static int rt5616_hw_params(struct snd_pcm_substream *substream,
|
||||
pre_div = rl6231_get_clk_info(rt5616->sysclk, rt5616->lrck[dai->id]);
|
||||
|
||||
if (pre_div < 0) {
|
||||
dev_err(codec->dev, "Unsupported clock setting\n");
|
||||
dev_err(component->dev, "Unsupported clock setting\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
frame_size = snd_soc_params_to_frame_size(params);
|
||||
if (frame_size < 0) {
|
||||
dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size);
|
||||
dev_err(component->dev, "Unsupported frame size: %d\n", frame_size);
|
||||
return -EINVAL;
|
||||
}
|
||||
bclk_ms = frame_size > 32 ? 1 : 0;
|
||||
@ -1004,17 +1004,17 @@ static int rt5616_hw_params(struct snd_pcm_substream *substream,
|
||||
|
||||
mask_clk = RT5616_I2S_PD1_MASK;
|
||||
val_clk = pre_div << RT5616_I2S_PD1_SFT;
|
||||
snd_soc_update_bits(codec, RT5616_I2S1_SDP,
|
||||
snd_soc_component_update_bits(component, RT5616_I2S1_SDP,
|
||||
RT5616_I2S_DL_MASK, val_len);
|
||||
snd_soc_update_bits(codec, RT5616_ADDA_CLK1, mask_clk, val_clk);
|
||||
snd_soc_component_update_bits(component, RT5616_ADDA_CLK1, mask_clk, val_clk);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rt5616_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct rt5616_priv *rt5616 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = dai->component;
|
||||
struct rt5616_priv *rt5616 = snd_soc_component_get_drvdata(component);
|
||||
unsigned int reg_val = 0;
|
||||
|
||||
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
|
||||
@ -1055,7 +1055,7 @@ static int rt5616_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
snd_soc_update_bits(codec, RT5616_I2S1_SDP,
|
||||
snd_soc_component_update_bits(component, RT5616_I2S1_SDP,
|
||||
RT5616_I2S_MS_MASK | RT5616_I2S_BP_MASK |
|
||||
RT5616_I2S_DF_MASK, reg_val);
|
||||
|
||||
@ -1065,8 +1065,8 @@ static int rt5616_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
|
||||
static int rt5616_set_dai_sysclk(struct snd_soc_dai *dai,
|
||||
int clk_id, unsigned int freq, int dir)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct rt5616_priv *rt5616 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = dai->component;
|
||||
struct rt5616_priv *rt5616 = snd_soc_component_get_drvdata(component);
|
||||
unsigned int reg_val = 0;
|
||||
|
||||
if (freq == rt5616->sysclk && clk_id == rt5616->sysclk_src)
|
||||
@ -1080,11 +1080,11 @@ static int rt5616_set_dai_sysclk(struct snd_soc_dai *dai,
|
||||
reg_val |= RT5616_SCLK_SRC_PLL1;
|
||||
break;
|
||||
default:
|
||||
dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id);
|
||||
dev_err(component->dev, "Invalid clock id (%d)\n", clk_id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
snd_soc_update_bits(codec, RT5616_GLB_CLK,
|
||||
snd_soc_component_update_bits(component, RT5616_GLB_CLK,
|
||||
RT5616_SCLK_SRC_MASK, reg_val);
|
||||
rt5616->sysclk = freq;
|
||||
rt5616->sysclk_src = clk_id;
|
||||
@ -1097,8 +1097,8 @@ static int rt5616_set_dai_sysclk(struct snd_soc_dai *dai,
|
||||
static int rt5616_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
|
||||
unsigned int freq_in, unsigned int freq_out)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct rt5616_priv *rt5616 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = dai->component;
|
||||
struct rt5616_priv *rt5616 = snd_soc_component_get_drvdata(component);
|
||||
struct rl6231_pll_code pll_code;
|
||||
int ret;
|
||||
|
||||
@ -1107,11 +1107,11 @@ static int rt5616_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
|
||||
return 0;
|
||||
|
||||
if (!freq_in || !freq_out) {
|
||||
dev_dbg(codec->dev, "PLL disabled\n");
|
||||
dev_dbg(component->dev, "PLL disabled\n");
|
||||
|
||||
rt5616->pll_in = 0;
|
||||
rt5616->pll_out = 0;
|
||||
snd_soc_update_bits(codec, RT5616_GLB_CLK,
|
||||
snd_soc_component_update_bits(component, RT5616_GLB_CLK,
|
||||
RT5616_SCLK_SRC_MASK,
|
||||
RT5616_SCLK_SRC_MCLK);
|
||||
return 0;
|
||||
@ -1119,34 +1119,34 @@ static int rt5616_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
|
||||
|
||||
switch (source) {
|
||||
case RT5616_PLL1_S_MCLK:
|
||||
snd_soc_update_bits(codec, RT5616_GLB_CLK,
|
||||
snd_soc_component_update_bits(component, RT5616_GLB_CLK,
|
||||
RT5616_PLL1_SRC_MASK,
|
||||
RT5616_PLL1_SRC_MCLK);
|
||||
break;
|
||||
case RT5616_PLL1_S_BCLK1:
|
||||
case RT5616_PLL1_S_BCLK2:
|
||||
snd_soc_update_bits(codec, RT5616_GLB_CLK,
|
||||
snd_soc_component_update_bits(component, RT5616_GLB_CLK,
|
||||
RT5616_PLL1_SRC_MASK,
|
||||
RT5616_PLL1_SRC_BCLK1);
|
||||
break;
|
||||
default:
|
||||
dev_err(codec->dev, "Unknown PLL source %d\n", source);
|
||||
dev_err(component->dev, "Unknown PLL source %d\n", source);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = rl6231_pll_calc(freq_in, freq_out, &pll_code);
|
||||
if (ret < 0) {
|
||||
dev_err(codec->dev, "Unsupport input clock %d\n", freq_in);
|
||||
dev_err(component->dev, "Unsupport input clock %d\n", freq_in);
|
||||
return ret;
|
||||
}
|
||||
|
||||
dev_dbg(codec->dev, "bypass=%d m=%d n=%d k=%d\n",
|
||||
dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n",
|
||||
pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code),
|
||||
pll_code.n_code, pll_code.k_code);
|
||||
|
||||
snd_soc_write(codec, RT5616_PLL_CTRL1,
|
||||
snd_soc_component_write(component, RT5616_PLL_CTRL1,
|
||||
pll_code.n_code << RT5616_PLL_N_SFT | pll_code.k_code);
|
||||
snd_soc_write(codec, RT5616_PLL_CTRL2,
|
||||
snd_soc_component_write(component, RT5616_PLL_CTRL2,
|
||||
(pll_code.m_bp ? 0 : pll_code.m_code) <<
|
||||
RT5616_PLL_M_SFT |
|
||||
pll_code.m_bp << RT5616_PLL_M_BP_SFT);
|
||||
@ -1158,10 +1158,10 @@ static int rt5616_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rt5616_set_bias_level(struct snd_soc_codec *codec,
|
||||
static int rt5616_set_bias_level(struct snd_soc_component *component,
|
||||
enum snd_soc_bias_level level)
|
||||
{
|
||||
struct rt5616_priv *rt5616 = snd_soc_codec_get_drvdata(codec);
|
||||
struct rt5616_priv *rt5616 = snd_soc_component_get_drvdata(component);
|
||||
int ret;
|
||||
|
||||
switch (level) {
|
||||
@ -1180,7 +1180,7 @@ static int rt5616_set_bias_level(struct snd_soc_codec *codec,
|
||||
if (IS_ERR(rt5616->mclk))
|
||||
break;
|
||||
|
||||
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_ON) {
|
||||
if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) {
|
||||
clk_disable_unprepare(rt5616->mclk);
|
||||
} else {
|
||||
ret = clk_prepare_enable(rt5616->mclk);
|
||||
@ -1190,30 +1190,30 @@ static int rt5616_set_bias_level(struct snd_soc_codec *codec,
|
||||
break;
|
||||
|
||||
case SND_SOC_BIAS_STANDBY:
|
||||
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) {
|
||||
snd_soc_update_bits(codec, RT5616_PWR_ANLG1,
|
||||
if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
|
||||
snd_soc_component_update_bits(component, RT5616_PWR_ANLG1,
|
||||
RT5616_PWR_VREF1 | RT5616_PWR_MB |
|
||||
RT5616_PWR_BG | RT5616_PWR_VREF2,
|
||||
RT5616_PWR_VREF1 | RT5616_PWR_MB |
|
||||
RT5616_PWR_BG | RT5616_PWR_VREF2);
|
||||
mdelay(10);
|
||||
snd_soc_update_bits(codec, RT5616_PWR_ANLG1,
|
||||
snd_soc_component_update_bits(component, RT5616_PWR_ANLG1,
|
||||
RT5616_PWR_FV1 | RT5616_PWR_FV2,
|
||||
RT5616_PWR_FV1 | RT5616_PWR_FV2);
|
||||
snd_soc_update_bits(codec, RT5616_D_MISC,
|
||||
snd_soc_component_update_bits(component, RT5616_D_MISC,
|
||||
RT5616_D_GATE_EN,
|
||||
RT5616_D_GATE_EN);
|
||||
}
|
||||
break;
|
||||
|
||||
case SND_SOC_BIAS_OFF:
|
||||
snd_soc_update_bits(codec, RT5616_D_MISC, RT5616_D_GATE_EN, 0);
|
||||
snd_soc_write(codec, RT5616_PWR_DIG1, 0x0000);
|
||||
snd_soc_write(codec, RT5616_PWR_DIG2, 0x0000);
|
||||
snd_soc_write(codec, RT5616_PWR_VOL, 0x0000);
|
||||
snd_soc_write(codec, RT5616_PWR_MIXER, 0x0000);
|
||||
snd_soc_write(codec, RT5616_PWR_ANLG1, 0x0000);
|
||||
snd_soc_write(codec, RT5616_PWR_ANLG2, 0x0000);
|
||||
snd_soc_component_update_bits(component, RT5616_D_MISC, RT5616_D_GATE_EN, 0);
|
||||
snd_soc_component_write(component, RT5616_PWR_DIG1, 0x0000);
|
||||
snd_soc_component_write(component, RT5616_PWR_DIG2, 0x0000);
|
||||
snd_soc_component_write(component, RT5616_PWR_VOL, 0x0000);
|
||||
snd_soc_component_write(component, RT5616_PWR_MIXER, 0x0000);
|
||||
snd_soc_component_write(component, RT5616_PWR_ANLG1, 0x0000);
|
||||
snd_soc_component_write(component, RT5616_PWR_ANLG2, 0x0000);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1223,24 +1223,24 @@ static int rt5616_set_bias_level(struct snd_soc_codec *codec,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rt5616_probe(struct snd_soc_codec *codec)
|
||||
static int rt5616_probe(struct snd_soc_component *component)
|
||||
{
|
||||
struct rt5616_priv *rt5616 = snd_soc_codec_get_drvdata(codec);
|
||||
struct rt5616_priv *rt5616 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
/* Check if MCLK provided */
|
||||
rt5616->mclk = devm_clk_get(codec->dev, "mclk");
|
||||
rt5616->mclk = devm_clk_get(component->dev, "mclk");
|
||||
if (PTR_ERR(rt5616->mclk) == -EPROBE_DEFER)
|
||||
return -EPROBE_DEFER;
|
||||
|
||||
rt5616->codec = codec;
|
||||
rt5616->component = component;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int rt5616_suspend(struct snd_soc_codec *codec)
|
||||
static int rt5616_suspend(struct snd_soc_component *component)
|
||||
{
|
||||
struct rt5616_priv *rt5616 = snd_soc_codec_get_drvdata(codec);
|
||||
struct rt5616_priv *rt5616 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
regcache_cache_only(rt5616->regmap, true);
|
||||
regcache_mark_dirty(rt5616->regmap);
|
||||
@ -1248,9 +1248,9 @@ static int rt5616_suspend(struct snd_soc_codec *codec)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rt5616_resume(struct snd_soc_codec *codec)
|
||||
static int rt5616_resume(struct snd_soc_component *component)
|
||||
{
|
||||
struct rt5616_priv *rt5616 = snd_soc_codec_get_drvdata(codec);
|
||||
struct rt5616_priv *rt5616 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
regcache_cache_only(rt5616->regmap, false);
|
||||
regcache_sync(rt5616->regmap);
|
||||
@ -1294,20 +1294,20 @@ static struct snd_soc_dai_driver rt5616_dai[] = {
|
||||
},
|
||||
};
|
||||
|
||||
static const struct snd_soc_codec_driver soc_codec_dev_rt5616 = {
|
||||
.probe = rt5616_probe,
|
||||
.suspend = rt5616_suspend,
|
||||
.resume = rt5616_resume,
|
||||
.set_bias_level = rt5616_set_bias_level,
|
||||
.idle_bias_off = true,
|
||||
.component_driver = {
|
||||
.controls = rt5616_snd_controls,
|
||||
.num_controls = ARRAY_SIZE(rt5616_snd_controls),
|
||||
.dapm_widgets = rt5616_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(rt5616_dapm_widgets),
|
||||
.dapm_routes = rt5616_dapm_routes,
|
||||
.num_dapm_routes = ARRAY_SIZE(rt5616_dapm_routes),
|
||||
},
|
||||
static const struct snd_soc_component_driver soc_component_dev_rt5616 = {
|
||||
.probe = rt5616_probe,
|
||||
.suspend = rt5616_suspend,
|
||||
.resume = rt5616_resume,
|
||||
.set_bias_level = rt5616_set_bias_level,
|
||||
.controls = rt5616_snd_controls,
|
||||
.num_controls = ARRAY_SIZE(rt5616_snd_controls),
|
||||
.dapm_widgets = rt5616_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(rt5616_dapm_widgets),
|
||||
.dapm_routes = rt5616_dapm_routes,
|
||||
.num_dapm_routes = ARRAY_SIZE(rt5616_dapm_routes),
|
||||
.use_pmdown_time = 1,
|
||||
.endianness = 1,
|
||||
.non_legacy_dai_naming = 1,
|
||||
};
|
||||
|
||||
static const struct regmap_config rt5616_regmap = {
|
||||
@ -1387,14 +1387,13 @@ static int rt5616_i2c_probe(struct i2c_client *i2c,
|
||||
regmap_update_bits(rt5616->regmap, RT5616_PWR_ANLG1,
|
||||
RT5616_PWR_LDO_DVO_MASK, RT5616_PWR_LDO_DVO_1_2V);
|
||||
|
||||
return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5616,
|
||||
return devm_snd_soc_register_component(&i2c->dev,
|
||||
&soc_component_dev_rt5616,
|
||||
rt5616_dai, ARRAY_SIZE(rt5616_dai));
|
||||
}
|
||||
|
||||
static int rt5616_i2c_remove(struct i2c_client *i2c)
|
||||
{
|
||||
snd_soc_unregister_codec(&i2c->dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -71,30 +71,30 @@ static const struct reg_default rt5631_reg[] = {
|
||||
/**
|
||||
* rt5631_write_index - write index register of 2nd layer
|
||||
*/
|
||||
static void rt5631_write_index(struct snd_soc_codec *codec,
|
||||
static void rt5631_write_index(struct snd_soc_component *component,
|
||||
unsigned int reg, unsigned int value)
|
||||
{
|
||||
snd_soc_write(codec, RT5631_INDEX_ADD, reg);
|
||||
snd_soc_write(codec, RT5631_INDEX_DATA, value);
|
||||
snd_soc_component_write(component, RT5631_INDEX_ADD, reg);
|
||||
snd_soc_component_write(component, RT5631_INDEX_DATA, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* rt5631_read_index - read index register of 2nd layer
|
||||
*/
|
||||
static unsigned int rt5631_read_index(struct snd_soc_codec *codec,
|
||||
static unsigned int rt5631_read_index(struct snd_soc_component *component,
|
||||
unsigned int reg)
|
||||
{
|
||||
unsigned int value;
|
||||
|
||||
snd_soc_write(codec, RT5631_INDEX_ADD, reg);
|
||||
value = snd_soc_read(codec, RT5631_INDEX_DATA);
|
||||
snd_soc_component_write(component, RT5631_INDEX_ADD, reg);
|
||||
value = snd_soc_component_read32(component, RT5631_INDEX_DATA);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static int rt5631_reset(struct snd_soc_codec *codec)
|
||||
static int rt5631_reset(struct snd_soc_component *component)
|
||||
{
|
||||
return snd_soc_write(codec, RT5631_RESET, 0);
|
||||
return snd_soc_component_write(component, RT5631_RESET, 0);
|
||||
}
|
||||
|
||||
static bool rt5631_volatile_register(struct device *dev, unsigned int reg)
|
||||
@ -187,8 +187,8 @@ static const DECLARE_TLV_DB_RANGE(mic_bst_tlv,
|
||||
static int rt5631_dmic_get(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
|
||||
struct rt5631_priv *rt5631 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
ucontrol->value.integer.value[0] = rt5631->dmic_used_flag;
|
||||
|
||||
@ -198,8 +198,8 @@ static int rt5631_dmic_get(struct snd_kcontrol *kcontrol,
|
||||
static int rt5631_dmic_put(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
|
||||
struct rt5631_priv *rt5631 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
rt5631->dmic_used_flag = ucontrol->value.integer.value[0];
|
||||
return 0;
|
||||
@ -286,78 +286,78 @@ static const struct snd_kcontrol_new rt5631_snd_controls[] = {
|
||||
static int check_sysclk1_source(struct snd_soc_dapm_widget *source,
|
||||
struct snd_soc_dapm_widget *sink)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm);
|
||||
unsigned int reg;
|
||||
|
||||
reg = snd_soc_read(codec, RT5631_GLOBAL_CLK_CTRL);
|
||||
reg = snd_soc_component_read32(component, RT5631_GLOBAL_CLK_CTRL);
|
||||
return reg & RT5631_SYSCLK_SOUR_SEL_PLL;
|
||||
}
|
||||
|
||||
static int check_dmic_used(struct snd_soc_dapm_widget *source,
|
||||
struct snd_soc_dapm_widget *sink)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
|
||||
struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm);
|
||||
struct rt5631_priv *rt5631 = snd_soc_component_get_drvdata(component);
|
||||
return rt5631->dmic_used_flag;
|
||||
}
|
||||
|
||||
static int check_dacl_to_outmixl(struct snd_soc_dapm_widget *source,
|
||||
struct snd_soc_dapm_widget *sink)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm);
|
||||
unsigned int reg;
|
||||
|
||||
reg = snd_soc_read(codec, RT5631_OUTMIXER_L_CTRL);
|
||||
reg = snd_soc_component_read32(component, RT5631_OUTMIXER_L_CTRL);
|
||||
return !(reg & RT5631_M_DAC_L_TO_OUTMIXER_L);
|
||||
}
|
||||
|
||||
static int check_dacr_to_outmixr(struct snd_soc_dapm_widget *source,
|
||||
struct snd_soc_dapm_widget *sink)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm);
|
||||
unsigned int reg;
|
||||
|
||||
reg = snd_soc_read(codec, RT5631_OUTMIXER_R_CTRL);
|
||||
reg = snd_soc_component_read32(component, RT5631_OUTMIXER_R_CTRL);
|
||||
return !(reg & RT5631_M_DAC_R_TO_OUTMIXER_R);
|
||||
}
|
||||
|
||||
static int check_dacl_to_spkmixl(struct snd_soc_dapm_widget *source,
|
||||
struct snd_soc_dapm_widget *sink)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm);
|
||||
unsigned int reg;
|
||||
|
||||
reg = snd_soc_read(codec, RT5631_SPK_MIXER_CTRL);
|
||||
reg = snd_soc_component_read32(component, RT5631_SPK_MIXER_CTRL);
|
||||
return !(reg & RT5631_M_DAC_L_TO_SPKMIXER_L);
|
||||
}
|
||||
|
||||
static int check_dacr_to_spkmixr(struct snd_soc_dapm_widget *source,
|
||||
struct snd_soc_dapm_widget *sink)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm);
|
||||
unsigned int reg;
|
||||
|
||||
reg = snd_soc_read(codec, RT5631_SPK_MIXER_CTRL);
|
||||
reg = snd_soc_component_read32(component, RT5631_SPK_MIXER_CTRL);
|
||||
return !(reg & RT5631_M_DAC_R_TO_SPKMIXER_R);
|
||||
}
|
||||
|
||||
static int check_adcl_select(struct snd_soc_dapm_widget *source,
|
||||
struct snd_soc_dapm_widget *sink)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm);
|
||||
unsigned int reg;
|
||||
|
||||
reg = snd_soc_read(codec, RT5631_ADC_REC_MIXER);
|
||||
reg = snd_soc_component_read32(component, RT5631_ADC_REC_MIXER);
|
||||
return !(reg & RT5631_M_MIC1_TO_RECMIXER_L);
|
||||
}
|
||||
|
||||
static int check_adcr_select(struct snd_soc_dapm_widget *source,
|
||||
struct snd_soc_dapm_widget *sink)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm);
|
||||
unsigned int reg;
|
||||
|
||||
reg = snd_soc_read(codec, RT5631_ADC_REC_MIXER);
|
||||
reg = snd_soc_component_read32(component, RT5631_ADC_REC_MIXER);
|
||||
return !(reg & RT5631_M_MIC2_TO_RECMIXER_R);
|
||||
}
|
||||
|
||||
@ -367,36 +367,36 @@ static int check_adcr_select(struct snd_soc_dapm_widget *source,
|
||||
*
|
||||
* When power on/off headphone, the depop sequence is done by hardware.
|
||||
*/
|
||||
static void onebit_depop_power_stage(struct snd_soc_codec *codec, int enable)
|
||||
static void onebit_depop_power_stage(struct snd_soc_component *component, int enable)
|
||||
{
|
||||
unsigned int soft_vol, hp_zc;
|
||||
|
||||
/* enable one-bit depop function */
|
||||
snd_soc_update_bits(codec, RT5631_DEPOP_FUN_CTRL_2,
|
||||
snd_soc_component_update_bits(component, RT5631_DEPOP_FUN_CTRL_2,
|
||||
RT5631_EN_ONE_BIT_DEPOP, 0);
|
||||
|
||||
/* keep soft volume and zero crossing setting */
|
||||
soft_vol = snd_soc_read(codec, RT5631_SOFT_VOL_CTRL);
|
||||
snd_soc_write(codec, RT5631_SOFT_VOL_CTRL, 0);
|
||||
hp_zc = snd_soc_read(codec, RT5631_INT_ST_IRQ_CTRL_2);
|
||||
snd_soc_write(codec, RT5631_INT_ST_IRQ_CTRL_2, hp_zc & 0xf7ff);
|
||||
soft_vol = snd_soc_component_read32(component, RT5631_SOFT_VOL_CTRL);
|
||||
snd_soc_component_write(component, RT5631_SOFT_VOL_CTRL, 0);
|
||||
hp_zc = snd_soc_component_read32(component, RT5631_INT_ST_IRQ_CTRL_2);
|
||||
snd_soc_component_write(component, RT5631_INT_ST_IRQ_CTRL_2, hp_zc & 0xf7ff);
|
||||
if (enable) {
|
||||
/* config one-bit depop parameter */
|
||||
rt5631_write_index(codec, RT5631_TEST_MODE_CTRL, 0x84c0);
|
||||
rt5631_write_index(codec, RT5631_SPK_INTL_CTRL, 0x309f);
|
||||
rt5631_write_index(codec, RT5631_CP_INTL_REG2, 0x6530);
|
||||
rt5631_write_index(component, RT5631_TEST_MODE_CTRL, 0x84c0);
|
||||
rt5631_write_index(component, RT5631_SPK_INTL_CTRL, 0x309f);
|
||||
rt5631_write_index(component, RT5631_CP_INTL_REG2, 0x6530);
|
||||
/* power on capless block */
|
||||
snd_soc_write(codec, RT5631_DEPOP_FUN_CTRL_2,
|
||||
snd_soc_component_write(component, RT5631_DEPOP_FUN_CTRL_2,
|
||||
RT5631_EN_CAP_FREE_DEPOP);
|
||||
} else {
|
||||
/* power off capless block */
|
||||
snd_soc_write(codec, RT5631_DEPOP_FUN_CTRL_2, 0);
|
||||
snd_soc_component_write(component, RT5631_DEPOP_FUN_CTRL_2, 0);
|
||||
msleep(100);
|
||||
}
|
||||
|
||||
/* recover soft volume and zero crossing setting */
|
||||
snd_soc_write(codec, RT5631_SOFT_VOL_CTRL, soft_vol);
|
||||
snd_soc_write(codec, RT5631_INT_ST_IRQ_CTRL_2, hp_zc);
|
||||
snd_soc_component_write(component, RT5631_SOFT_VOL_CTRL, soft_vol);
|
||||
snd_soc_component_write(component, RT5631_INT_ST_IRQ_CTRL_2, hp_zc);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -405,36 +405,36 @@ static void onebit_depop_power_stage(struct snd_soc_codec *codec, int enable)
|
||||
*
|
||||
* When mute/unmute headphone, the depop sequence is done by hardware.
|
||||
*/
|
||||
static void onebit_depop_mute_stage(struct snd_soc_codec *codec, int enable)
|
||||
static void onebit_depop_mute_stage(struct snd_soc_component *component, int enable)
|
||||
{
|
||||
unsigned int soft_vol, hp_zc;
|
||||
|
||||
/* enable one-bit depop function */
|
||||
snd_soc_update_bits(codec, RT5631_DEPOP_FUN_CTRL_2,
|
||||
snd_soc_component_update_bits(component, RT5631_DEPOP_FUN_CTRL_2,
|
||||
RT5631_EN_ONE_BIT_DEPOP, 0);
|
||||
|
||||
/* keep soft volume and zero crossing setting */
|
||||
soft_vol = snd_soc_read(codec, RT5631_SOFT_VOL_CTRL);
|
||||
snd_soc_write(codec, RT5631_SOFT_VOL_CTRL, 0);
|
||||
hp_zc = snd_soc_read(codec, RT5631_INT_ST_IRQ_CTRL_2);
|
||||
snd_soc_write(codec, RT5631_INT_ST_IRQ_CTRL_2, hp_zc & 0xf7ff);
|
||||
soft_vol = snd_soc_component_read32(component, RT5631_SOFT_VOL_CTRL);
|
||||
snd_soc_component_write(component, RT5631_SOFT_VOL_CTRL, 0);
|
||||
hp_zc = snd_soc_component_read32(component, RT5631_INT_ST_IRQ_CTRL_2);
|
||||
snd_soc_component_write(component, RT5631_INT_ST_IRQ_CTRL_2, hp_zc & 0xf7ff);
|
||||
if (enable) {
|
||||
schedule_timeout_uninterruptible(msecs_to_jiffies(10));
|
||||
/* config one-bit depop parameter */
|
||||
rt5631_write_index(codec, RT5631_SPK_INTL_CTRL, 0x307f);
|
||||
snd_soc_update_bits(codec, RT5631_HP_OUT_VOL,
|
||||
rt5631_write_index(component, RT5631_SPK_INTL_CTRL, 0x307f);
|
||||
snd_soc_component_update_bits(component, RT5631_HP_OUT_VOL,
|
||||
RT5631_L_MUTE | RT5631_R_MUTE, 0);
|
||||
msleep(300);
|
||||
} else {
|
||||
snd_soc_update_bits(codec, RT5631_HP_OUT_VOL,
|
||||
snd_soc_component_update_bits(component, RT5631_HP_OUT_VOL,
|
||||
RT5631_L_MUTE | RT5631_R_MUTE,
|
||||
RT5631_L_MUTE | RT5631_R_MUTE);
|
||||
msleep(100);
|
||||
}
|
||||
|
||||
/* recover soft volume and zero crossing setting */
|
||||
snd_soc_write(codec, RT5631_SOFT_VOL_CTRL, soft_vol);
|
||||
snd_soc_write(codec, RT5631_INT_ST_IRQ_CTRL_2, hp_zc);
|
||||
snd_soc_component_write(component, RT5631_SOFT_VOL_CTRL, soft_vol);
|
||||
snd_soc_component_write(component, RT5631_INT_ST_IRQ_CTRL_2, hp_zc);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -443,70 +443,70 @@ static void onebit_depop_mute_stage(struct snd_soc_codec *codec, int enable)
|
||||
*
|
||||
* When power on/off headphone, the depop sequence is done in step by step.
|
||||
*/
|
||||
static void depop_seq_power_stage(struct snd_soc_codec *codec, int enable)
|
||||
static void depop_seq_power_stage(struct snd_soc_component *component, int enable)
|
||||
{
|
||||
unsigned int soft_vol, hp_zc;
|
||||
|
||||
/* depop control by register */
|
||||
snd_soc_update_bits(codec, RT5631_DEPOP_FUN_CTRL_2,
|
||||
snd_soc_component_update_bits(component, RT5631_DEPOP_FUN_CTRL_2,
|
||||
RT5631_EN_ONE_BIT_DEPOP, RT5631_EN_ONE_BIT_DEPOP);
|
||||
|
||||
/* keep soft volume and zero crossing setting */
|
||||
soft_vol = snd_soc_read(codec, RT5631_SOFT_VOL_CTRL);
|
||||
snd_soc_write(codec, RT5631_SOFT_VOL_CTRL, 0);
|
||||
hp_zc = snd_soc_read(codec, RT5631_INT_ST_IRQ_CTRL_2);
|
||||
snd_soc_write(codec, RT5631_INT_ST_IRQ_CTRL_2, hp_zc & 0xf7ff);
|
||||
soft_vol = snd_soc_component_read32(component, RT5631_SOFT_VOL_CTRL);
|
||||
snd_soc_component_write(component, RT5631_SOFT_VOL_CTRL, 0);
|
||||
hp_zc = snd_soc_component_read32(component, RT5631_INT_ST_IRQ_CTRL_2);
|
||||
snd_soc_component_write(component, RT5631_INT_ST_IRQ_CTRL_2, hp_zc & 0xf7ff);
|
||||
if (enable) {
|
||||
/* config depop sequence parameter */
|
||||
rt5631_write_index(codec, RT5631_SPK_INTL_CTRL, 0x303e);
|
||||
rt5631_write_index(component, RT5631_SPK_INTL_CTRL, 0x303e);
|
||||
|
||||
/* power on headphone and charge pump */
|
||||
snd_soc_update_bits(codec, RT5631_PWR_MANAG_ADD3,
|
||||
snd_soc_component_update_bits(component, RT5631_PWR_MANAG_ADD3,
|
||||
RT5631_PWR_CHARGE_PUMP | RT5631_PWR_HP_L_AMP |
|
||||
RT5631_PWR_HP_R_AMP,
|
||||
RT5631_PWR_CHARGE_PUMP | RT5631_PWR_HP_L_AMP |
|
||||
RT5631_PWR_HP_R_AMP);
|
||||
|
||||
/* power on soft generator and depop mode2 */
|
||||
snd_soc_write(codec, RT5631_DEPOP_FUN_CTRL_1,
|
||||
snd_soc_component_write(component, RT5631_DEPOP_FUN_CTRL_1,
|
||||
RT5631_POW_ON_SOFT_GEN | RT5631_EN_DEPOP2_FOR_HP);
|
||||
msleep(100);
|
||||
|
||||
/* stop depop mode */
|
||||
snd_soc_update_bits(codec, RT5631_PWR_MANAG_ADD3,
|
||||
snd_soc_component_update_bits(component, RT5631_PWR_MANAG_ADD3,
|
||||
RT5631_PWR_HP_DEPOP_DIS, RT5631_PWR_HP_DEPOP_DIS);
|
||||
} else {
|
||||
/* config depop sequence parameter */
|
||||
rt5631_write_index(codec, RT5631_SPK_INTL_CTRL, 0x303F);
|
||||
snd_soc_write(codec, RT5631_DEPOP_FUN_CTRL_1,
|
||||
rt5631_write_index(component, RT5631_SPK_INTL_CTRL, 0x303F);
|
||||
snd_soc_component_write(component, RT5631_DEPOP_FUN_CTRL_1,
|
||||
RT5631_POW_ON_SOFT_GEN | RT5631_EN_MUTE_UNMUTE_DEPOP |
|
||||
RT5631_PD_HPAMP_L_ST_UP | RT5631_PD_HPAMP_R_ST_UP);
|
||||
msleep(75);
|
||||
snd_soc_write(codec, RT5631_DEPOP_FUN_CTRL_1,
|
||||
snd_soc_component_write(component, RT5631_DEPOP_FUN_CTRL_1,
|
||||
RT5631_POW_ON_SOFT_GEN | RT5631_PD_HPAMP_L_ST_UP |
|
||||
RT5631_PD_HPAMP_R_ST_UP);
|
||||
|
||||
/* start depop mode */
|
||||
snd_soc_update_bits(codec, RT5631_PWR_MANAG_ADD3,
|
||||
snd_soc_component_update_bits(component, RT5631_PWR_MANAG_ADD3,
|
||||
RT5631_PWR_HP_DEPOP_DIS, 0);
|
||||
|
||||
/* config depop sequence parameter */
|
||||
snd_soc_write(codec, RT5631_DEPOP_FUN_CTRL_1,
|
||||
snd_soc_component_write(component, RT5631_DEPOP_FUN_CTRL_1,
|
||||
RT5631_POW_ON_SOFT_GEN | RT5631_EN_DEPOP2_FOR_HP |
|
||||
RT5631_PD_HPAMP_L_ST_UP | RT5631_PD_HPAMP_R_ST_UP);
|
||||
msleep(80);
|
||||
snd_soc_write(codec, RT5631_DEPOP_FUN_CTRL_1,
|
||||
snd_soc_component_write(component, RT5631_DEPOP_FUN_CTRL_1,
|
||||
RT5631_POW_ON_SOFT_GEN);
|
||||
|
||||
/* power down headphone and charge pump */
|
||||
snd_soc_update_bits(codec, RT5631_PWR_MANAG_ADD3,
|
||||
snd_soc_component_update_bits(component, RT5631_PWR_MANAG_ADD3,
|
||||
RT5631_PWR_CHARGE_PUMP | RT5631_PWR_HP_L_AMP |
|
||||
RT5631_PWR_HP_R_AMP, 0);
|
||||
}
|
||||
|
||||
/* recover soft volume and zero crossing setting */
|
||||
snd_soc_write(codec, RT5631_SOFT_VOL_CTRL, soft_vol);
|
||||
snd_soc_write(codec, RT5631_INT_ST_IRQ_CTRL_2, hp_zc);
|
||||
snd_soc_component_write(component, RT5631_SOFT_VOL_CTRL, soft_vol);
|
||||
snd_soc_component_write(component, RT5631_INT_ST_IRQ_CTRL_2, hp_zc);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -515,75 +515,75 @@ static void depop_seq_power_stage(struct snd_soc_codec *codec, int enable)
|
||||
*
|
||||
* When mute/unmute headphone, the depop sequence is done in step by step.
|
||||
*/
|
||||
static void depop_seq_mute_stage(struct snd_soc_codec *codec, int enable)
|
||||
static void depop_seq_mute_stage(struct snd_soc_component *component, int enable)
|
||||
{
|
||||
unsigned int soft_vol, hp_zc;
|
||||
|
||||
/* depop control by register */
|
||||
snd_soc_update_bits(codec, RT5631_DEPOP_FUN_CTRL_2,
|
||||
snd_soc_component_update_bits(component, RT5631_DEPOP_FUN_CTRL_2,
|
||||
RT5631_EN_ONE_BIT_DEPOP, RT5631_EN_ONE_BIT_DEPOP);
|
||||
|
||||
/* keep soft volume and zero crossing setting */
|
||||
soft_vol = snd_soc_read(codec, RT5631_SOFT_VOL_CTRL);
|
||||
snd_soc_write(codec, RT5631_SOFT_VOL_CTRL, 0);
|
||||
hp_zc = snd_soc_read(codec, RT5631_INT_ST_IRQ_CTRL_2);
|
||||
snd_soc_write(codec, RT5631_INT_ST_IRQ_CTRL_2, hp_zc & 0xf7ff);
|
||||
soft_vol = snd_soc_component_read32(component, RT5631_SOFT_VOL_CTRL);
|
||||
snd_soc_component_write(component, RT5631_SOFT_VOL_CTRL, 0);
|
||||
hp_zc = snd_soc_component_read32(component, RT5631_INT_ST_IRQ_CTRL_2);
|
||||
snd_soc_component_write(component, RT5631_INT_ST_IRQ_CTRL_2, hp_zc & 0xf7ff);
|
||||
if (enable) {
|
||||
schedule_timeout_uninterruptible(msecs_to_jiffies(10));
|
||||
|
||||
/* config depop sequence parameter */
|
||||
rt5631_write_index(codec, RT5631_SPK_INTL_CTRL, 0x302f);
|
||||
snd_soc_write(codec, RT5631_DEPOP_FUN_CTRL_1,
|
||||
rt5631_write_index(component, RT5631_SPK_INTL_CTRL, 0x302f);
|
||||
snd_soc_component_write(component, RT5631_DEPOP_FUN_CTRL_1,
|
||||
RT5631_POW_ON_SOFT_GEN | RT5631_EN_MUTE_UNMUTE_DEPOP |
|
||||
RT5631_EN_HP_R_M_UN_MUTE_DEPOP |
|
||||
RT5631_EN_HP_L_M_UN_MUTE_DEPOP);
|
||||
|
||||
snd_soc_update_bits(codec, RT5631_HP_OUT_VOL,
|
||||
snd_soc_component_update_bits(component, RT5631_HP_OUT_VOL,
|
||||
RT5631_L_MUTE | RT5631_R_MUTE, 0);
|
||||
msleep(160);
|
||||
} else {
|
||||
/* config depop sequence parameter */
|
||||
rt5631_write_index(codec, RT5631_SPK_INTL_CTRL, 0x302f);
|
||||
snd_soc_write(codec, RT5631_DEPOP_FUN_CTRL_1,
|
||||
rt5631_write_index(component, RT5631_SPK_INTL_CTRL, 0x302f);
|
||||
snd_soc_component_write(component, RT5631_DEPOP_FUN_CTRL_1,
|
||||
RT5631_POW_ON_SOFT_GEN | RT5631_EN_MUTE_UNMUTE_DEPOP |
|
||||
RT5631_EN_HP_R_M_UN_MUTE_DEPOP |
|
||||
RT5631_EN_HP_L_M_UN_MUTE_DEPOP);
|
||||
|
||||
snd_soc_update_bits(codec, RT5631_HP_OUT_VOL,
|
||||
snd_soc_component_update_bits(component, RT5631_HP_OUT_VOL,
|
||||
RT5631_L_MUTE | RT5631_R_MUTE,
|
||||
RT5631_L_MUTE | RT5631_R_MUTE);
|
||||
msleep(150);
|
||||
}
|
||||
|
||||
/* recover soft volume and zero crossing setting */
|
||||
snd_soc_write(codec, RT5631_SOFT_VOL_CTRL, soft_vol);
|
||||
snd_soc_write(codec, RT5631_INT_ST_IRQ_CTRL_2, hp_zc);
|
||||
snd_soc_component_write(component, RT5631_SOFT_VOL_CTRL, soft_vol);
|
||||
snd_soc_component_write(component, RT5631_INT_ST_IRQ_CTRL_2, hp_zc);
|
||||
}
|
||||
|
||||
static int hp_event(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
||||
struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
|
||||
struct rt5631_priv *rt5631 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_PRE_PMD:
|
||||
if (rt5631->codec_version) {
|
||||
onebit_depop_mute_stage(codec, 0);
|
||||
onebit_depop_power_stage(codec, 0);
|
||||
onebit_depop_mute_stage(component, 0);
|
||||
onebit_depop_power_stage(component, 0);
|
||||
} else {
|
||||
depop_seq_mute_stage(codec, 0);
|
||||
depop_seq_power_stage(codec, 0);
|
||||
depop_seq_mute_stage(component, 0);
|
||||
depop_seq_power_stage(component, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case SND_SOC_DAPM_POST_PMU:
|
||||
if (rt5631->codec_version) {
|
||||
onebit_depop_power_stage(codec, 1);
|
||||
onebit_depop_mute_stage(codec, 1);
|
||||
onebit_depop_power_stage(component, 1);
|
||||
onebit_depop_mute_stage(component, 1);
|
||||
} else {
|
||||
depop_seq_power_stage(codec, 1);
|
||||
depop_seq_mute_stage(codec, 1);
|
||||
depop_seq_power_stage(component, 1);
|
||||
depop_seq_mute_stage(component, 1);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -597,20 +597,20 @@ static int hp_event(struct snd_soc_dapm_widget *w,
|
||||
static int set_dmic_params(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 rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
|
||||
struct rt5631_priv *rt5631 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
switch (rt5631->rx_rate) {
|
||||
case 44100:
|
||||
case 48000:
|
||||
snd_soc_update_bits(codec, RT5631_DIG_MIC_CTRL,
|
||||
snd_soc_component_update_bits(component, RT5631_DIG_MIC_CTRL,
|
||||
RT5631_DMIC_CLK_CTRL_MASK,
|
||||
RT5631_DMIC_CLK_CTRL_TO_32FS);
|
||||
break;
|
||||
|
||||
case 32000:
|
||||
case 22050:
|
||||
snd_soc_update_bits(codec, RT5631_DIG_MIC_CTRL,
|
||||
snd_soc_component_update_bits(component, RT5631_DIG_MIC_CTRL,
|
||||
RT5631_DMIC_CLK_CTRL_MASK,
|
||||
RT5631_DMIC_CLK_CTRL_TO_64FS);
|
||||
break;
|
||||
@ -618,7 +618,7 @@ static int set_dmic_params(struct snd_soc_dapm_widget *w,
|
||||
case 16000:
|
||||
case 11025:
|
||||
case 8000:
|
||||
snd_soc_update_bits(codec, RT5631_DIG_MIC_CTRL,
|
||||
snd_soc_component_update_bits(component, RT5631_DIG_MIC_CTRL,
|
||||
RT5631_DMIC_CLK_CTRL_MASK,
|
||||
RT5631_DMIC_CLK_CTRL_TO_128FS);
|
||||
break;
|
||||
@ -1352,16 +1352,16 @@ static int get_coeff(int mclk, int rate, int timesofbclk)
|
||||
static int rt5631_hifi_pcm_params(struct snd_pcm_substream *substream,
|
||||
struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = dai->component;
|
||||
struct rt5631_priv *rt5631 = snd_soc_component_get_drvdata(component);
|
||||
int timesofbclk = 32, coeff;
|
||||
unsigned int iface = 0;
|
||||
|
||||
dev_dbg(codec->dev, "enter %s\n", __func__);
|
||||
dev_dbg(component->dev, "enter %s\n", __func__);
|
||||
|
||||
rt5631->bclk_rate = snd_soc_params_to_bclk(params);
|
||||
if (rt5631->bclk_rate < 0) {
|
||||
dev_err(codec->dev, "Fail to get BCLK rate\n");
|
||||
dev_err(component->dev, "Fail to get BCLK rate\n");
|
||||
return rt5631->bclk_rate;
|
||||
}
|
||||
rt5631->rx_rate = params_rate(params);
|
||||
@ -1373,7 +1373,7 @@ static int rt5631_hifi_pcm_params(struct snd_pcm_substream *substream,
|
||||
coeff = get_coeff(rt5631->sysclk, rt5631->rx_rate,
|
||||
timesofbclk);
|
||||
if (coeff < 0) {
|
||||
dev_err(codec->dev, "Fail to get coeff\n");
|
||||
dev_err(component->dev, "Fail to get coeff\n");
|
||||
return coeff;
|
||||
}
|
||||
|
||||
@ -1393,9 +1393,9 @@ static int rt5631_hifi_pcm_params(struct snd_pcm_substream *substream,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
snd_soc_update_bits(codec, RT5631_SDP_CTRL,
|
||||
snd_soc_component_update_bits(component, RT5631_SDP_CTRL,
|
||||
RT5631_SDP_I2S_DL_MASK, iface);
|
||||
snd_soc_write(codec, RT5631_STEREO_AD_DA_CLK_CTRL,
|
||||
snd_soc_component_write(component, RT5631_STEREO_AD_DA_CLK_CTRL,
|
||||
coeff_div[coeff].reg_val);
|
||||
|
||||
return 0;
|
||||
@ -1404,11 +1404,11 @@ static int rt5631_hifi_pcm_params(struct snd_pcm_substream *substream,
|
||||
static int rt5631_hifi_codec_set_dai_fmt(struct snd_soc_dai *codec_dai,
|
||||
unsigned int fmt)
|
||||
{
|
||||
struct snd_soc_codec *codec = codec_dai->codec;
|
||||
struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = codec_dai->component;
|
||||
struct rt5631_priv *rt5631 = snd_soc_component_get_drvdata(component);
|
||||
unsigned int iface = 0;
|
||||
|
||||
dev_dbg(codec->dev, "enter %s\n", __func__);
|
||||
dev_dbg(component->dev, "enter %s\n", __func__);
|
||||
|
||||
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
|
||||
case SND_SOC_DAIFMT_CBM_CFM:
|
||||
@ -1448,7 +1448,7 @@ static int rt5631_hifi_codec_set_dai_fmt(struct snd_soc_dai *codec_dai,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
snd_soc_write(codec, RT5631_SDP_CTRL, iface);
|
||||
snd_soc_component_write(component, RT5631_SDP_CTRL, iface);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1456,10 +1456,10 @@ static int rt5631_hifi_codec_set_dai_fmt(struct snd_soc_dai *codec_dai,
|
||||
static int rt5631_hifi_codec_set_dai_sysclk(struct snd_soc_dai *codec_dai,
|
||||
int clk_id, unsigned int freq, int dir)
|
||||
{
|
||||
struct snd_soc_codec *codec = codec_dai->codec;
|
||||
struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = codec_dai->component;
|
||||
struct rt5631_priv *rt5631 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
dev_dbg(codec->dev, "enter %s, syclk=%d\n", __func__, freq);
|
||||
dev_dbg(component->dev, "enter %s, syclk=%d\n", __func__, freq);
|
||||
|
||||
if ((freq >= (256 * 8000)) && (freq <= (512 * 96000))) {
|
||||
rt5631->sysclk = freq;
|
||||
@ -1472,16 +1472,16 @@ static int rt5631_hifi_codec_set_dai_sysclk(struct snd_soc_dai *codec_dai,
|
||||
static int rt5631_codec_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
|
||||
int source, unsigned int freq_in, unsigned int freq_out)
|
||||
{
|
||||
struct snd_soc_codec *codec = codec_dai->codec;
|
||||
struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = codec_dai->component;
|
||||
struct rt5631_priv *rt5631 = snd_soc_component_get_drvdata(component);
|
||||
int i, ret = -EINVAL;
|
||||
|
||||
dev_dbg(codec->dev, "enter %s\n", __func__);
|
||||
dev_dbg(component->dev, "enter %s\n", __func__);
|
||||
|
||||
if (!freq_in || !freq_out) {
|
||||
dev_dbg(codec->dev, "PLL disabled\n");
|
||||
dev_dbg(component->dev, "PLL disabled\n");
|
||||
|
||||
snd_soc_update_bits(codec, RT5631_GLOBAL_CLK_CTRL,
|
||||
snd_soc_component_update_bits(component, RT5631_GLOBAL_CLK_CTRL,
|
||||
RT5631_SYSCLK_SOUR_SEL_MASK,
|
||||
RT5631_SYSCLK_SOUR_SEL_MCLK);
|
||||
|
||||
@ -1492,13 +1492,13 @@ static int rt5631_codec_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
|
||||
for (i = 0; i < ARRAY_SIZE(codec_master_pll_div); i++)
|
||||
if (freq_in == codec_master_pll_div[i].pll_in &&
|
||||
freq_out == codec_master_pll_div[i].pll_out) {
|
||||
dev_info(codec->dev,
|
||||
dev_info(component->dev,
|
||||
"change PLL in master mode\n");
|
||||
snd_soc_write(codec, RT5631_PLL_CTRL,
|
||||
snd_soc_component_write(component, RT5631_PLL_CTRL,
|
||||
codec_master_pll_div[i].reg_val);
|
||||
schedule_timeout_uninterruptible(
|
||||
msecs_to_jiffies(20));
|
||||
snd_soc_update_bits(codec,
|
||||
snd_soc_component_update_bits(component,
|
||||
RT5631_GLOBAL_CLK_CTRL,
|
||||
RT5631_SYSCLK_SOUR_SEL_MASK |
|
||||
RT5631_PLLCLK_SOUR_SEL_MASK,
|
||||
@ -1511,13 +1511,13 @@ static int rt5631_codec_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
|
||||
for (i = 0; i < ARRAY_SIZE(codec_slave_pll_div); i++)
|
||||
if (freq_in == codec_slave_pll_div[i].pll_in &&
|
||||
freq_out == codec_slave_pll_div[i].pll_out) {
|
||||
dev_info(codec->dev,
|
||||
dev_info(component->dev,
|
||||
"change PLL in slave mode\n");
|
||||
snd_soc_write(codec, RT5631_PLL_CTRL,
|
||||
snd_soc_component_write(component, RT5631_PLL_CTRL,
|
||||
codec_slave_pll_div[i].reg_val);
|
||||
schedule_timeout_uninterruptible(
|
||||
msecs_to_jiffies(20));
|
||||
snd_soc_update_bits(codec,
|
||||
snd_soc_component_update_bits(component,
|
||||
RT5631_GLOBAL_CLK_CTRL,
|
||||
RT5631_SYSCLK_SOUR_SEL_MASK |
|
||||
RT5631_PLLCLK_SOUR_SEL_MASK,
|
||||
@ -1531,26 +1531,26 @@ static int rt5631_codec_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int rt5631_set_bias_level(struct snd_soc_codec *codec,
|
||||
static int rt5631_set_bias_level(struct snd_soc_component *component,
|
||||
enum snd_soc_bias_level level)
|
||||
{
|
||||
struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec);
|
||||
struct rt5631_priv *rt5631 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
switch (level) {
|
||||
case SND_SOC_BIAS_ON:
|
||||
case SND_SOC_BIAS_PREPARE:
|
||||
snd_soc_update_bits(codec, RT5631_PWR_MANAG_ADD2,
|
||||
snd_soc_component_update_bits(component, RT5631_PWR_MANAG_ADD2,
|
||||
RT5631_PWR_MICBIAS1_VOL | RT5631_PWR_MICBIAS2_VOL,
|
||||
RT5631_PWR_MICBIAS1_VOL | RT5631_PWR_MICBIAS2_VOL);
|
||||
break;
|
||||
|
||||
case SND_SOC_BIAS_STANDBY:
|
||||
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) {
|
||||
snd_soc_update_bits(codec, RT5631_PWR_MANAG_ADD3,
|
||||
if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
|
||||
snd_soc_component_update_bits(component, RT5631_PWR_MANAG_ADD3,
|
||||
RT5631_PWR_VREF | RT5631_PWR_MAIN_BIAS,
|
||||
RT5631_PWR_VREF | RT5631_PWR_MAIN_BIAS);
|
||||
msleep(80);
|
||||
snd_soc_update_bits(codec, RT5631_PWR_MANAG_ADD3,
|
||||
snd_soc_component_update_bits(component, RT5631_PWR_MANAG_ADD3,
|
||||
RT5631_PWR_FAST_VREF_CTRL,
|
||||
RT5631_PWR_FAST_VREF_CTRL);
|
||||
regcache_cache_only(rt5631->regmap, false);
|
||||
@ -1559,10 +1559,10 @@ static int rt5631_set_bias_level(struct snd_soc_codec *codec,
|
||||
break;
|
||||
|
||||
case SND_SOC_BIAS_OFF:
|
||||
snd_soc_write(codec, RT5631_PWR_MANAG_ADD1, 0x0000);
|
||||
snd_soc_write(codec, RT5631_PWR_MANAG_ADD2, 0x0000);
|
||||
snd_soc_write(codec, RT5631_PWR_MANAG_ADD3, 0x0000);
|
||||
snd_soc_write(codec, RT5631_PWR_MANAG_ADD4, 0x0000);
|
||||
snd_soc_component_write(component, RT5631_PWR_MANAG_ADD1, 0x0000);
|
||||
snd_soc_component_write(component, RT5631_PWR_MANAG_ADD2, 0x0000);
|
||||
snd_soc_component_write(component, RT5631_PWR_MANAG_ADD3, 0x0000);
|
||||
snd_soc_component_write(component, RT5631_PWR_MANAG_ADD4, 0x0000);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1572,48 +1572,48 @@ static int rt5631_set_bias_level(struct snd_soc_codec *codec,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rt5631_probe(struct snd_soc_codec *codec)
|
||||
static int rt5631_probe(struct snd_soc_component *component)
|
||||
{
|
||||
struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec);
|
||||
struct rt5631_priv *rt5631 = snd_soc_component_get_drvdata(component);
|
||||
unsigned int val;
|
||||
|
||||
val = rt5631_read_index(codec, RT5631_ADDA_MIXER_INTL_REG3);
|
||||
val = rt5631_read_index(component, RT5631_ADDA_MIXER_INTL_REG3);
|
||||
if (val & 0x0002)
|
||||
rt5631->codec_version = 1;
|
||||
else
|
||||
rt5631->codec_version = 0;
|
||||
|
||||
rt5631_reset(codec);
|
||||
snd_soc_update_bits(codec, RT5631_PWR_MANAG_ADD3,
|
||||
rt5631_reset(component);
|
||||
snd_soc_component_update_bits(component, RT5631_PWR_MANAG_ADD3,
|
||||
RT5631_PWR_VREF | RT5631_PWR_MAIN_BIAS,
|
||||
RT5631_PWR_VREF | RT5631_PWR_MAIN_BIAS);
|
||||
msleep(80);
|
||||
snd_soc_update_bits(codec, RT5631_PWR_MANAG_ADD3,
|
||||
snd_soc_component_update_bits(component, RT5631_PWR_MANAG_ADD3,
|
||||
RT5631_PWR_FAST_VREF_CTRL, RT5631_PWR_FAST_VREF_CTRL);
|
||||
/* enable HP zero cross */
|
||||
snd_soc_write(codec, RT5631_INT_ST_IRQ_CTRL_2, 0x0f18);
|
||||
snd_soc_component_write(component, RT5631_INT_ST_IRQ_CTRL_2, 0x0f18);
|
||||
/* power off ClassD auto Recovery */
|
||||
if (rt5631->codec_version)
|
||||
snd_soc_update_bits(codec, RT5631_INT_ST_IRQ_CTRL_2,
|
||||
snd_soc_component_update_bits(component, RT5631_INT_ST_IRQ_CTRL_2,
|
||||
0x2000, 0x2000);
|
||||
else
|
||||
snd_soc_update_bits(codec, RT5631_INT_ST_IRQ_CTRL_2,
|
||||
snd_soc_component_update_bits(component, RT5631_INT_ST_IRQ_CTRL_2,
|
||||
0x2000, 0);
|
||||
/* DMIC */
|
||||
if (rt5631->dmic_used_flag) {
|
||||
snd_soc_update_bits(codec, RT5631_GPIO_CTRL,
|
||||
snd_soc_component_update_bits(component, RT5631_GPIO_CTRL,
|
||||
RT5631_GPIO_PIN_FUN_SEL_MASK |
|
||||
RT5631_GPIO_DMIC_FUN_SEL_MASK,
|
||||
RT5631_GPIO_PIN_FUN_SEL_GPIO_DIMC |
|
||||
RT5631_GPIO_DMIC_FUN_SEL_DIMC);
|
||||
snd_soc_update_bits(codec, RT5631_DIG_MIC_CTRL,
|
||||
snd_soc_component_update_bits(component, RT5631_DIG_MIC_CTRL,
|
||||
RT5631_DMIC_L_CH_LATCH_MASK |
|
||||
RT5631_DMIC_R_CH_LATCH_MASK,
|
||||
RT5631_DMIC_L_CH_LATCH_FALLING |
|
||||
RT5631_DMIC_R_CH_LATCH_RISING);
|
||||
}
|
||||
|
||||
snd_soc_codec_init_bias_level(codec, SND_SOC_BIAS_STANDBY);
|
||||
snd_soc_component_init_bias_level(component, SND_SOC_BIAS_STANDBY);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1653,18 +1653,20 @@ static struct snd_soc_dai_driver rt5631_dai[] = {
|
||||
},
|
||||
};
|
||||
|
||||
static const struct snd_soc_codec_driver soc_codec_dev_rt5631 = {
|
||||
.probe = rt5631_probe,
|
||||
.set_bias_level = rt5631_set_bias_level,
|
||||
.suspend_bias_off = true,
|
||||
.component_driver = {
|
||||
.controls = rt5631_snd_controls,
|
||||
.num_controls = ARRAY_SIZE(rt5631_snd_controls),
|
||||
.dapm_widgets = rt5631_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(rt5631_dapm_widgets),
|
||||
.dapm_routes = rt5631_dapm_routes,
|
||||
.num_dapm_routes = ARRAY_SIZE(rt5631_dapm_routes),
|
||||
},
|
||||
static const struct snd_soc_component_driver soc_component_dev_rt5631 = {
|
||||
.probe = rt5631_probe,
|
||||
.set_bias_level = rt5631_set_bias_level,
|
||||
.controls = rt5631_snd_controls,
|
||||
.num_controls = ARRAY_SIZE(rt5631_snd_controls),
|
||||
.dapm_widgets = rt5631_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(rt5631_dapm_widgets),
|
||||
.dapm_routes = rt5631_dapm_routes,
|
||||
.num_dapm_routes = ARRAY_SIZE(rt5631_dapm_routes),
|
||||
.suspend_bias_off = 1,
|
||||
.idle_bias_on = 1,
|
||||
.use_pmdown_time = 1,
|
||||
.endianness = 1,
|
||||
.non_legacy_dai_naming = 1,
|
||||
};
|
||||
|
||||
static const struct i2c_device_id rt5631_i2c_id[] = {
|
||||
@ -1712,14 +1714,14 @@ static int rt5631_i2c_probe(struct i2c_client *i2c,
|
||||
if (IS_ERR(rt5631->regmap))
|
||||
return PTR_ERR(rt5631->regmap);
|
||||
|
||||
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5631,
|
||||
ret = devm_snd_soc_register_component(&i2c->dev,
|
||||
&soc_component_dev_rt5631,
|
||||
rt5631_dai, ARRAY_SIZE(rt5631_dai));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int rt5631_i2c_remove(struct i2c_client *client)
|
||||
{
|
||||
snd_soc_unregister_codec(&client->dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -166,9 +166,9 @@ static const struct reg_default rt5640_reg[] = {
|
||||
{ 0xff, 0x6231 },
|
||||
};
|
||||
|
||||
static int rt5640_reset(struct snd_soc_codec *codec)
|
||||
static int rt5640_reset(struct snd_soc_component *component)
|
||||
{
|
||||
return snd_soc_write(codec, RT5640_RESET, 0);
|
||||
return snd_soc_component_write(component, RT5640_RESET, 0);
|
||||
}
|
||||
|
||||
static bool rt5640_volatile_register(struct device *dev, unsigned int reg)
|
||||
@ -461,17 +461,17 @@ static const struct snd_kcontrol_new rt5640_specific_snd_controls[] = {
|
||||
static int set_dmic_clk(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 rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
|
||||
struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component);
|
||||
int idx, rate;
|
||||
|
||||
rate = rt5640->sysclk / rl6231_get_pre_div(rt5640->regmap,
|
||||
RT5640_ADDA_CLK1, RT5640_I2S_PD1_SFT);
|
||||
idx = rl6231_calc_dmic_clk(rate);
|
||||
if (idx < 0)
|
||||
dev_err(codec->dev, "Failed to set DMIC clock\n");
|
||||
dev_err(component->dev, "Failed to set DMIC clock\n");
|
||||
else
|
||||
snd_soc_update_bits(codec, RT5640_DMIC, RT5640_DMIC_CLK_MASK,
|
||||
snd_soc_component_update_bits(component, RT5640_DMIC, RT5640_DMIC_CLK_MASK,
|
||||
idx << RT5640_DMIC_CLK_SFT);
|
||||
return idx;
|
||||
}
|
||||
@ -479,10 +479,10 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w,
|
||||
static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source,
|
||||
struct snd_soc_dapm_widget *sink)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm);
|
||||
unsigned int val;
|
||||
|
||||
val = snd_soc_read(codec, RT5640_GLB_CLK);
|
||||
val = snd_soc_component_read32(component, RT5640_GLB_CLK);
|
||||
val &= RT5640_SCLK_SRC_MASK;
|
||||
if (val == RT5640_SCLK_SRC_PLL1)
|
||||
return 1;
|
||||
@ -493,8 +493,8 @@ static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source,
|
||||
static int is_using_asrc(struct snd_soc_dapm_widget *source,
|
||||
struct snd_soc_dapm_widget *sink)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
|
||||
struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm);
|
||||
struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
if (!rt5640->asrc_en)
|
||||
return 0;
|
||||
@ -930,9 +930,9 @@ static SOC_ENUM_SINGLE_DECL(rt5640_sdi_sel_enum, RT5640_I2S2_SDP,
|
||||
static const struct snd_kcontrol_new rt5640_sdi_mux =
|
||||
SOC_DAPM_ENUM("SDI select", rt5640_sdi_sel_enum);
|
||||
|
||||
static void hp_amp_power_on(struct snd_soc_codec *codec)
|
||||
static void hp_amp_power_on(struct snd_soc_component *component)
|
||||
{
|
||||
struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
|
||||
struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
/* depop parameters */
|
||||
regmap_update_bits(rt5640->regmap, RT5640_PR_BASE +
|
||||
@ -956,9 +956,9 @@ static void hp_amp_power_on(struct snd_soc_codec *codec)
|
||||
RT5640_PWR_FV1 | RT5640_PWR_FV2);
|
||||
}
|
||||
|
||||
static void rt5640_pmu_depop(struct snd_soc_codec *codec)
|
||||
static void rt5640_pmu_depop(struct snd_soc_component *component)
|
||||
{
|
||||
struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
|
||||
struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
regmap_update_bits(rt5640->regmap, RT5640_DEPOP_M2,
|
||||
RT5640_DEPOP_MASK | RT5640_DIG_DP_MASK,
|
||||
@ -984,12 +984,12 @@ static void rt5640_pmu_depop(struct snd_soc_codec *codec)
|
||||
static int rt5640_hp_event(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
||||
struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
|
||||
struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_POST_PMU:
|
||||
rt5640_pmu_depop(codec);
|
||||
rt5640_pmu_depop(component);
|
||||
rt5640->hp_mute = 0;
|
||||
break;
|
||||
|
||||
@ -1008,22 +1008,22 @@ static int rt5640_hp_event(struct snd_soc_dapm_widget *w,
|
||||
static int rt5640_lout_event(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
|
||||
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_POST_PMU:
|
||||
hp_amp_power_on(codec);
|
||||
snd_soc_update_bits(codec, RT5640_PWR_ANLG1,
|
||||
hp_amp_power_on(component);
|
||||
snd_soc_component_update_bits(component, RT5640_PWR_ANLG1,
|
||||
RT5640_PWR_LM, RT5640_PWR_LM);
|
||||
snd_soc_update_bits(codec, RT5640_OUTPUT,
|
||||
snd_soc_component_update_bits(component, RT5640_OUTPUT,
|
||||
RT5640_L_MUTE | RT5640_R_MUTE, 0);
|
||||
break;
|
||||
|
||||
case SND_SOC_DAPM_PRE_PMD:
|
||||
snd_soc_update_bits(codec, RT5640_OUTPUT,
|
||||
snd_soc_component_update_bits(component, RT5640_OUTPUT,
|
||||
RT5640_L_MUTE | RT5640_R_MUTE,
|
||||
RT5640_L_MUTE | RT5640_R_MUTE);
|
||||
snd_soc_update_bits(codec, RT5640_PWR_ANLG1,
|
||||
snd_soc_component_update_bits(component, RT5640_PWR_ANLG1,
|
||||
RT5640_PWR_LM, 0);
|
||||
break;
|
||||
|
||||
@ -1037,11 +1037,11 @@ static int rt5640_lout_event(struct snd_soc_dapm_widget *w,
|
||||
static int rt5640_hp_power_event(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
|
||||
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_POST_PMU:
|
||||
hp_amp_power_on(codec);
|
||||
hp_amp_power_on(component);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
@ -1053,8 +1053,8 @@ static int rt5640_hp_power_event(struct snd_soc_dapm_widget *w,
|
||||
static int rt5640_hp_post_event(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
||||
struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
|
||||
struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_POST_PMU:
|
||||
@ -1671,14 +1671,14 @@ static const struct snd_soc_dapm_route rt5639_specific_dapm_routes[] = {
|
||||
{"IF2 DAC R", NULL, "DAC R2 Power"},
|
||||
};
|
||||
|
||||
static int get_sdp_info(struct snd_soc_codec *codec, int dai_id)
|
||||
static int get_sdp_info(struct snd_soc_component *component, int dai_id)
|
||||
{
|
||||
int ret = 0, val;
|
||||
|
||||
if (codec == NULL)
|
||||
if (component == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
val = snd_soc_read(codec, RT5640_I2S1_SDP);
|
||||
val = snd_soc_component_read32(component, RT5640_I2S1_SDP);
|
||||
val = (val & RT5640_I2S_IF_MASK) >> RT5640_I2S_IF_SFT;
|
||||
switch (dai_id) {
|
||||
case RT5640_AIF1:
|
||||
@ -1722,21 +1722,21 @@ static int get_sdp_info(struct snd_soc_codec *codec, int dai_id)
|
||||
static int rt5640_hw_params(struct snd_pcm_substream *substream,
|
||||
struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = dai->component;
|
||||
struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component);
|
||||
unsigned int val_len = 0, val_clk, mask_clk;
|
||||
int dai_sel, pre_div, bclk_ms, frame_size;
|
||||
|
||||
rt5640->lrck[dai->id] = params_rate(params);
|
||||
pre_div = rl6231_get_clk_info(rt5640->sysclk, rt5640->lrck[dai->id]);
|
||||
if (pre_div < 0) {
|
||||
dev_err(codec->dev, "Unsupported clock setting %d for DAI %d\n",
|
||||
dev_err(component->dev, "Unsupported clock setting %d for DAI %d\n",
|
||||
rt5640->lrck[dai->id], dai->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
frame_size = snd_soc_params_to_frame_size(params);
|
||||
if (frame_size < 0) {
|
||||
dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size);
|
||||
dev_err(component->dev, "Unsupported frame size: %d\n", frame_size);
|
||||
return frame_size;
|
||||
}
|
||||
if (frame_size > 32)
|
||||
@ -1766,26 +1766,26 @@ static int rt5640_hw_params(struct snd_pcm_substream *substream,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
dai_sel = get_sdp_info(codec, dai->id);
|
||||
dai_sel = get_sdp_info(component, dai->id);
|
||||
if (dai_sel < 0) {
|
||||
dev_err(codec->dev, "Failed to get sdp info: %d\n", dai_sel);
|
||||
dev_err(component->dev, "Failed to get sdp info: %d\n", dai_sel);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (dai_sel & RT5640_U_IF1) {
|
||||
mask_clk = RT5640_I2S_BCLK_MS1_MASK | RT5640_I2S_PD1_MASK;
|
||||
val_clk = bclk_ms << RT5640_I2S_BCLK_MS1_SFT |
|
||||
pre_div << RT5640_I2S_PD1_SFT;
|
||||
snd_soc_update_bits(codec, RT5640_I2S1_SDP,
|
||||
snd_soc_component_update_bits(component, RT5640_I2S1_SDP,
|
||||
RT5640_I2S_DL_MASK, val_len);
|
||||
snd_soc_update_bits(codec, RT5640_ADDA_CLK1, mask_clk, val_clk);
|
||||
snd_soc_component_update_bits(component, RT5640_ADDA_CLK1, mask_clk, val_clk);
|
||||
}
|
||||
if (dai_sel & RT5640_U_IF2) {
|
||||
mask_clk = RT5640_I2S_BCLK_MS2_MASK | RT5640_I2S_PD2_MASK;
|
||||
val_clk = bclk_ms << RT5640_I2S_BCLK_MS2_SFT |
|
||||
pre_div << RT5640_I2S_PD2_SFT;
|
||||
snd_soc_update_bits(codec, RT5640_I2S2_SDP,
|
||||
snd_soc_component_update_bits(component, RT5640_I2S2_SDP,
|
||||
RT5640_I2S_DL_MASK, val_len);
|
||||
snd_soc_update_bits(codec, RT5640_ADDA_CLK1, mask_clk, val_clk);
|
||||
snd_soc_component_update_bits(component, RT5640_ADDA_CLK1, mask_clk, val_clk);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -1793,8 +1793,8 @@ static int rt5640_hw_params(struct snd_pcm_substream *substream,
|
||||
|
||||
static int rt5640_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = dai->component;
|
||||
struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component);
|
||||
unsigned int reg_val = 0;
|
||||
int dai_sel;
|
||||
|
||||
@ -1836,18 +1836,18 @@ static int rt5640_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
dai_sel = get_sdp_info(codec, dai->id);
|
||||
dai_sel = get_sdp_info(component, dai->id);
|
||||
if (dai_sel < 0) {
|
||||
dev_err(codec->dev, "Failed to get sdp info: %d\n", dai_sel);
|
||||
dev_err(component->dev, "Failed to get sdp info: %d\n", dai_sel);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (dai_sel & RT5640_U_IF1) {
|
||||
snd_soc_update_bits(codec, RT5640_I2S1_SDP,
|
||||
snd_soc_component_update_bits(component, RT5640_I2S1_SDP,
|
||||
RT5640_I2S_MS_MASK | RT5640_I2S_BP_MASK |
|
||||
RT5640_I2S_DF_MASK, reg_val);
|
||||
}
|
||||
if (dai_sel & RT5640_U_IF2) {
|
||||
snd_soc_update_bits(codec, RT5640_I2S2_SDP,
|
||||
snd_soc_component_update_bits(component, RT5640_I2S2_SDP,
|
||||
RT5640_I2S_MS_MASK | RT5640_I2S_BP_MASK |
|
||||
RT5640_I2S_DF_MASK, reg_val);
|
||||
}
|
||||
@ -1858,8 +1858,8 @@ static int rt5640_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
|
||||
static int rt5640_set_dai_sysclk(struct snd_soc_dai *dai,
|
||||
int clk_id, unsigned int freq, int dir)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = dai->component;
|
||||
struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component);
|
||||
unsigned int reg_val = 0;
|
||||
|
||||
if (freq == rt5640->sysclk && clk_id == rt5640->sysclk_src)
|
||||
@ -1876,10 +1876,10 @@ static int rt5640_set_dai_sysclk(struct snd_soc_dai *dai,
|
||||
reg_val |= RT5640_SCLK_SRC_RCCLK;
|
||||
break;
|
||||
default:
|
||||
dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id);
|
||||
dev_err(component->dev, "Invalid clock id (%d)\n", clk_id);
|
||||
return -EINVAL;
|
||||
}
|
||||
snd_soc_update_bits(codec, RT5640_GLB_CLK,
|
||||
snd_soc_component_update_bits(component, RT5640_GLB_CLK,
|
||||
RT5640_SCLK_SRC_MASK, reg_val);
|
||||
rt5640->sysclk = freq;
|
||||
rt5640->sysclk_src = clk_id;
|
||||
@ -1891,8 +1891,8 @@ static int rt5640_set_dai_sysclk(struct snd_soc_dai *dai,
|
||||
static int rt5640_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
|
||||
unsigned int freq_in, unsigned int freq_out)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = dai->component;
|
||||
struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component);
|
||||
struct rl6231_pll_code pll_code;
|
||||
int ret;
|
||||
|
||||
@ -1901,46 +1901,46 @@ static int rt5640_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
|
||||
return 0;
|
||||
|
||||
if (!freq_in || !freq_out) {
|
||||
dev_dbg(codec->dev, "PLL disabled\n");
|
||||
dev_dbg(component->dev, "PLL disabled\n");
|
||||
|
||||
rt5640->pll_in = 0;
|
||||
rt5640->pll_out = 0;
|
||||
snd_soc_update_bits(codec, RT5640_GLB_CLK,
|
||||
snd_soc_component_update_bits(component, RT5640_GLB_CLK,
|
||||
RT5640_SCLK_SRC_MASK, RT5640_SCLK_SRC_MCLK);
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (source) {
|
||||
case RT5640_PLL1_S_MCLK:
|
||||
snd_soc_update_bits(codec, RT5640_GLB_CLK,
|
||||
snd_soc_component_update_bits(component, RT5640_GLB_CLK,
|
||||
RT5640_PLL1_SRC_MASK, RT5640_PLL1_SRC_MCLK);
|
||||
break;
|
||||
case RT5640_PLL1_S_BCLK1:
|
||||
snd_soc_update_bits(codec, RT5640_GLB_CLK,
|
||||
snd_soc_component_update_bits(component, RT5640_GLB_CLK,
|
||||
RT5640_PLL1_SRC_MASK, RT5640_PLL1_SRC_BCLK1);
|
||||
break;
|
||||
case RT5640_PLL1_S_BCLK2:
|
||||
snd_soc_update_bits(codec, RT5640_GLB_CLK,
|
||||
snd_soc_component_update_bits(component, RT5640_GLB_CLK,
|
||||
RT5640_PLL1_SRC_MASK, RT5640_PLL1_SRC_BCLK2);
|
||||
break;
|
||||
default:
|
||||
dev_err(codec->dev, "Unknown PLL source %d\n", source);
|
||||
dev_err(component->dev, "Unknown PLL source %d\n", source);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = rl6231_pll_calc(freq_in, freq_out, &pll_code);
|
||||
if (ret < 0) {
|
||||
dev_err(codec->dev, "Unsupport input clock %d\n", freq_in);
|
||||
dev_err(component->dev, "Unsupport input clock %d\n", freq_in);
|
||||
return ret;
|
||||
}
|
||||
|
||||
dev_dbg(codec->dev, "bypass=%d m=%d n=%d k=%d\n",
|
||||
dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n",
|
||||
pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code),
|
||||
pll_code.n_code, pll_code.k_code);
|
||||
|
||||
snd_soc_write(codec, RT5640_PLL_CTRL1,
|
||||
snd_soc_component_write(component, RT5640_PLL_CTRL1,
|
||||
pll_code.n_code << RT5640_PLL_N_SFT | pll_code.k_code);
|
||||
snd_soc_write(codec, RT5640_PLL_CTRL2,
|
||||
snd_soc_component_write(component, RT5640_PLL_CTRL2,
|
||||
(pll_code.m_bp ? 0 : pll_code.m_code) << RT5640_PLL_M_SFT |
|
||||
pll_code.m_bp << RT5640_PLL_M_BP_SFT);
|
||||
|
||||
@ -1951,10 +1951,10 @@ static int rt5640_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rt5640_set_bias_level(struct snd_soc_codec *codec,
|
||||
static int rt5640_set_bias_level(struct snd_soc_component *component,
|
||||
enum snd_soc_bias_level level)
|
||||
{
|
||||
struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
|
||||
struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component);
|
||||
int ret;
|
||||
|
||||
switch (level) {
|
||||
@ -1972,7 +1972,7 @@ static int rt5640_set_bias_level(struct snd_soc_codec *codec,
|
||||
if (IS_ERR(rt5640->mclk))
|
||||
break;
|
||||
|
||||
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_ON) {
|
||||
if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) {
|
||||
clk_disable_unprepare(rt5640->mclk);
|
||||
} else {
|
||||
ret = clk_prepare_enable(rt5640->mclk);
|
||||
@ -1982,33 +1982,33 @@ static int rt5640_set_bias_level(struct snd_soc_codec *codec,
|
||||
break;
|
||||
|
||||
case SND_SOC_BIAS_STANDBY:
|
||||
if (SND_SOC_BIAS_OFF == snd_soc_codec_get_bias_level(codec)) {
|
||||
snd_soc_update_bits(codec, RT5640_PWR_ANLG1,
|
||||
if (SND_SOC_BIAS_OFF == snd_soc_component_get_bias_level(component)) {
|
||||
snd_soc_component_update_bits(component, RT5640_PWR_ANLG1,
|
||||
RT5640_PWR_VREF1 | RT5640_PWR_MB |
|
||||
RT5640_PWR_BG | RT5640_PWR_VREF2,
|
||||
RT5640_PWR_VREF1 | RT5640_PWR_MB |
|
||||
RT5640_PWR_BG | RT5640_PWR_VREF2);
|
||||
usleep_range(10000, 15000);
|
||||
snd_soc_update_bits(codec, RT5640_PWR_ANLG1,
|
||||
snd_soc_component_update_bits(component, RT5640_PWR_ANLG1,
|
||||
RT5640_PWR_FV1 | RT5640_PWR_FV2,
|
||||
RT5640_PWR_FV1 | RT5640_PWR_FV2);
|
||||
snd_soc_update_bits(codec, RT5640_DUMMY1,
|
||||
snd_soc_component_update_bits(component, RT5640_DUMMY1,
|
||||
0x0301, 0x0301);
|
||||
snd_soc_update_bits(codec, RT5640_MICBIAS,
|
||||
snd_soc_component_update_bits(component, RT5640_MICBIAS,
|
||||
0x0030, 0x0030);
|
||||
}
|
||||
break;
|
||||
|
||||
case SND_SOC_BIAS_OFF:
|
||||
snd_soc_write(codec, RT5640_DEPOP_M1, 0x0004);
|
||||
snd_soc_write(codec, RT5640_DEPOP_M2, 0x1100);
|
||||
snd_soc_update_bits(codec, RT5640_DUMMY1, 0x1, 0);
|
||||
snd_soc_write(codec, RT5640_PWR_DIG1, 0x0000);
|
||||
snd_soc_write(codec, RT5640_PWR_DIG2, 0x0000);
|
||||
snd_soc_write(codec, RT5640_PWR_VOL, 0x0000);
|
||||
snd_soc_write(codec, RT5640_PWR_MIXER, 0x0000);
|
||||
snd_soc_write(codec, RT5640_PWR_ANLG1, 0x0000);
|
||||
snd_soc_write(codec, RT5640_PWR_ANLG2, 0x0000);
|
||||
snd_soc_component_write(component, RT5640_DEPOP_M1, 0x0004);
|
||||
snd_soc_component_write(component, RT5640_DEPOP_M2, 0x1100);
|
||||
snd_soc_component_update_bits(component, RT5640_DUMMY1, 0x1, 0);
|
||||
snd_soc_component_write(component, RT5640_PWR_DIG1, 0x0000);
|
||||
snd_soc_component_write(component, RT5640_PWR_DIG2, 0x0000);
|
||||
snd_soc_component_write(component, RT5640_PWR_VOL, 0x0000);
|
||||
snd_soc_component_write(component, RT5640_PWR_MIXER, 0x0000);
|
||||
snd_soc_component_write(component, RT5640_PWR_ANLG1, 0x0000);
|
||||
snd_soc_component_write(component, RT5640_PWR_ANLG2, 0x0000);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -2018,10 +2018,10 @@ static int rt5640_set_bias_level(struct snd_soc_codec *codec,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rt5640_dmic_enable(struct snd_soc_codec *codec,
|
||||
int rt5640_dmic_enable(struct snd_soc_component *component,
|
||||
bool dmic1_data_pin, bool dmic2_data_pin)
|
||||
{
|
||||
struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
|
||||
struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
regmap_update_bits(rt5640->regmap, RT5640_GPIO_CTRL1,
|
||||
RT5640_GP2_PIN_MASK, RT5640_GP2_PIN_DMIC1_SCL);
|
||||
@ -2044,10 +2044,10 @@ int rt5640_dmic_enable(struct snd_soc_codec *codec,
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(rt5640_dmic_enable);
|
||||
|
||||
int rt5640_sel_asrc_clk_src(struct snd_soc_codec *codec,
|
||||
int rt5640_sel_asrc_clk_src(struct snd_soc_component *component,
|
||||
unsigned int filter_mask, unsigned int clk_src)
|
||||
{
|
||||
struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
|
||||
struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component);
|
||||
unsigned int asrc2_mask = 0;
|
||||
unsigned int asrc2_value = 0;
|
||||
|
||||
@ -2099,43 +2099,43 @@ int rt5640_sel_asrc_clk_src(struct snd_soc_codec *codec,
|
||||
| (clk_src << RT5640_MAD_R_M_SFT);
|
||||
}
|
||||
|
||||
snd_soc_update_bits(codec, RT5640_ASRC_2,
|
||||
snd_soc_component_update_bits(component, RT5640_ASRC_2,
|
||||
asrc2_mask, asrc2_value);
|
||||
|
||||
if (snd_soc_read(codec, RT5640_ASRC_2)) {
|
||||
if (snd_soc_component_read32(component, RT5640_ASRC_2)) {
|
||||
rt5640->asrc_en = true;
|
||||
snd_soc_update_bits(codec, RT5640_JD_CTRL, 0x3, 0x3);
|
||||
snd_soc_component_update_bits(component, RT5640_JD_CTRL, 0x3, 0x3);
|
||||
} else {
|
||||
rt5640->asrc_en = false;
|
||||
snd_soc_update_bits(codec, RT5640_JD_CTRL, 0x3, 0x0);
|
||||
snd_soc_component_update_bits(component, RT5640_JD_CTRL, 0x3, 0x0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(rt5640_sel_asrc_clk_src);
|
||||
|
||||
static int rt5640_probe(struct snd_soc_codec *codec)
|
||||
static int rt5640_probe(struct snd_soc_component *component)
|
||||
{
|
||||
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
|
||||
struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
|
||||
struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
/* Check if MCLK provided */
|
||||
rt5640->mclk = devm_clk_get(codec->dev, "mclk");
|
||||
rt5640->mclk = devm_clk_get(component->dev, "mclk");
|
||||
if (PTR_ERR(rt5640->mclk) == -EPROBE_DEFER)
|
||||
return -EPROBE_DEFER;
|
||||
|
||||
rt5640->codec = codec;
|
||||
rt5640->component = component;
|
||||
|
||||
snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF);
|
||||
snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF);
|
||||
|
||||
snd_soc_update_bits(codec, RT5640_DUMMY1, 0x0301, 0x0301);
|
||||
snd_soc_update_bits(codec, RT5640_MICBIAS, 0x0030, 0x0030);
|
||||
snd_soc_update_bits(codec, RT5640_DSP_PATH2, 0xfc00, 0x0c00);
|
||||
snd_soc_component_update_bits(component, RT5640_DUMMY1, 0x0301, 0x0301);
|
||||
snd_soc_component_update_bits(component, RT5640_MICBIAS, 0x0030, 0x0030);
|
||||
snd_soc_component_update_bits(component, RT5640_DSP_PATH2, 0xfc00, 0x0c00);
|
||||
|
||||
switch (snd_soc_read(codec, RT5640_RESET) & RT5640_ID_MASK) {
|
||||
switch (snd_soc_component_read32(component, RT5640_RESET) & RT5640_ID_MASK) {
|
||||
case RT5640_ID_5640:
|
||||
case RT5640_ID_5642:
|
||||
snd_soc_add_codec_controls(codec,
|
||||
snd_soc_add_component_controls(component,
|
||||
rt5640_specific_snd_controls,
|
||||
ARRAY_SIZE(rt5640_specific_snd_controls));
|
||||
snd_soc_dapm_new_controls(dapm,
|
||||
@ -2154,32 +2154,30 @@ static int rt5640_probe(struct snd_soc_codec *codec)
|
||||
ARRAY_SIZE(rt5639_specific_dapm_routes));
|
||||
break;
|
||||
default:
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"The driver is for RT5639 RT5640 or RT5642 only\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
if (rt5640->pdata.dmic_en)
|
||||
rt5640_dmic_enable(codec, rt5640->pdata.dmic1_data_pin,
|
||||
rt5640_dmic_enable(component, rt5640->pdata.dmic1_data_pin,
|
||||
rt5640->pdata.dmic2_data_pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rt5640_remove(struct snd_soc_codec *codec)
|
||||
static void rt5640_remove(struct snd_soc_component *component)
|
||||
{
|
||||
rt5640_reset(codec);
|
||||
|
||||
return 0;
|
||||
rt5640_reset(component);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int rt5640_suspend(struct snd_soc_codec *codec)
|
||||
static int rt5640_suspend(struct snd_soc_component *component)
|
||||
{
|
||||
struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
|
||||
struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF);
|
||||
rt5640_reset(codec);
|
||||
snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF);
|
||||
rt5640_reset(component);
|
||||
regcache_cache_only(rt5640->regmap, true);
|
||||
regcache_mark_dirty(rt5640->regmap);
|
||||
if (gpio_is_valid(rt5640->pdata.ldo1_en))
|
||||
@ -2188,9 +2186,9 @@ static int rt5640_suspend(struct snd_soc_codec *codec)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rt5640_resume(struct snd_soc_codec *codec)
|
||||
static int rt5640_resume(struct snd_soc_component *component)
|
||||
{
|
||||
struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
|
||||
struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
if (gpio_is_valid(rt5640->pdata.ldo1_en)) {
|
||||
gpio_set_value_cansleep(rt5640->pdata.ldo1_en, 1);
|
||||
@ -2259,21 +2257,22 @@ static struct snd_soc_dai_driver rt5640_dai[] = {
|
||||
},
|
||||
};
|
||||
|
||||
static const struct snd_soc_codec_driver soc_codec_dev_rt5640 = {
|
||||
.probe = rt5640_probe,
|
||||
.remove = rt5640_remove,
|
||||
.suspend = rt5640_suspend,
|
||||
.resume = rt5640_resume,
|
||||
.set_bias_level = rt5640_set_bias_level,
|
||||
.idle_bias_off = true,
|
||||
.component_driver = {
|
||||
.controls = rt5640_snd_controls,
|
||||
.num_controls = ARRAY_SIZE(rt5640_snd_controls),
|
||||
.dapm_widgets = rt5640_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(rt5640_dapm_widgets),
|
||||
.dapm_routes = rt5640_dapm_routes,
|
||||
.num_dapm_routes = ARRAY_SIZE(rt5640_dapm_routes),
|
||||
},
|
||||
static const struct snd_soc_component_driver soc_component_dev_rt5640 = {
|
||||
.probe = rt5640_probe,
|
||||
.remove = rt5640_remove,
|
||||
.suspend = rt5640_suspend,
|
||||
.resume = rt5640_resume,
|
||||
.set_bias_level = rt5640_set_bias_level,
|
||||
.controls = rt5640_snd_controls,
|
||||
.num_controls = ARRAY_SIZE(rt5640_snd_controls),
|
||||
.dapm_widgets = rt5640_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(rt5640_dapm_widgets),
|
||||
.dapm_routes = rt5640_dapm_routes,
|
||||
.num_dapm_routes = ARRAY_SIZE(rt5640_dapm_routes),
|
||||
.use_pmdown_time = 1,
|
||||
.endianness = 1,
|
||||
.non_legacy_dai_naming = 1,
|
||||
|
||||
};
|
||||
|
||||
static const struct regmap_config rt5640_regmap = {
|
||||
@ -2427,17 +2426,11 @@ static int rt5640_i2c_probe(struct i2c_client *i2c,
|
||||
|
||||
rt5640->hp_mute = 1;
|
||||
|
||||
return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5640,
|
||||
return devm_snd_soc_register_component(&i2c->dev,
|
||||
&soc_component_dev_rt5640,
|
||||
rt5640_dai, ARRAY_SIZE(rt5640_dai));
|
||||
}
|
||||
|
||||
static int rt5640_i2c_remove(struct i2c_client *i2c)
|
||||
{
|
||||
snd_soc_unregister_codec(&i2c->dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct i2c_driver rt5640_i2c_driver = {
|
||||
.driver = {
|
||||
.name = "rt5640",
|
||||
@ -2445,7 +2438,6 @@ static struct i2c_driver rt5640_i2c_driver = {
|
||||
.of_match_table = of_match_ptr(rt5640_of_match),
|
||||
},
|
||||
.probe = rt5640_i2c_probe,
|
||||
.remove = rt5640_i2c_remove,
|
||||
.id_table = rt5640_i2c_id,
|
||||
};
|
||||
module_i2c_driver(rt5640_i2c_driver);
|
||||
|
@ -2102,7 +2102,7 @@ enum {
|
||||
};
|
||||
|
||||
struct rt5640_priv {
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
struct rt5640_platform_data pdata;
|
||||
struct regmap *regmap;
|
||||
struct clk *mclk;
|
||||
@ -2121,9 +2121,9 @@ struct rt5640_priv {
|
||||
bool asrc_en;
|
||||
};
|
||||
|
||||
int rt5640_dmic_enable(struct snd_soc_codec *codec,
|
||||
int rt5640_dmic_enable(struct snd_soc_component *component,
|
||||
bool dmic1_data_pin, bool dmic2_data_pin);
|
||||
int rt5640_sel_asrc_clk_src(struct snd_soc_codec *codec,
|
||||
int rt5640_sel_asrc_clk_src(struct snd_soc_component *component,
|
||||
unsigned int filter_mask, unsigned int clk_src);
|
||||
|
||||
#endif
|
||||
|
@ -131,7 +131,7 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = {
|
||||
static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime)
|
||||
{
|
||||
int ret;
|
||||
struct snd_soc_codec *codec = runtime->codec;
|
||||
struct snd_soc_component *component = runtime->codec_dai->component;
|
||||
struct snd_soc_card *card = runtime->card;
|
||||
const struct snd_soc_dapm_route *custom_map;
|
||||
int num_routes;
|
||||
@ -165,7 +165,7 @@ static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime)
|
||||
return ret;
|
||||
|
||||
if (byt_rt5640_quirk & BYT_RT5640_DMIC_EN) {
|
||||
ret = rt5640_dmic_enable(codec, 0, 0);
|
||||
ret = rt5640_dmic_enable(component, 0, 0);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
@ -444,14 +444,14 @@ static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime)
|
||||
{
|
||||
struct snd_soc_card *card = runtime->card;
|
||||
struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card);
|
||||
struct snd_soc_codec *codec = runtime->codec;
|
||||
struct snd_soc_component *component = runtime->codec_dai->component;
|
||||
const struct snd_soc_dapm_route *custom_map;
|
||||
int num_routes;
|
||||
int ret;
|
||||
|
||||
card->dapm.idle_bias_off = true;
|
||||
|
||||
rt5640_sel_asrc_clk_src(codec,
|
||||
rt5640_sel_asrc_clk_src(component,
|
||||
RT5640_DA_STEREO_FILTER |
|
||||
RT5640_DA_MONO_L_FILTER |
|
||||
RT5640_DA_MONO_R_FILTER |
|
||||
@ -522,12 +522,12 @@ static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime)
|
||||
return ret;
|
||||
|
||||
if (byt_rt5640_quirk & BYT_RT5640_DIFF_MIC) {
|
||||
snd_soc_update_bits(codec, RT5640_IN1_IN2, RT5640_IN_DF1,
|
||||
snd_soc_component_update_bits(component, RT5640_IN1_IN2, RT5640_IN_DF1,
|
||||
RT5640_IN_DF1);
|
||||
}
|
||||
|
||||
if (byt_rt5640_quirk & BYT_RT5640_DMIC_EN) {
|
||||
ret = rt5640_dmic_enable(codec, 0, 0);
|
||||
ret = rt5640_dmic_enable(component, 0, 0);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user