From 29c5b8fd8c07a42b07383c5fac47173d882f74b2 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Thu, 8 Feb 2018 14:35:30 +0000 Subject: [PATCH 001/102] ASoC: Intel: Skylake: make function skl_clk_round_rate static The function skl_clk_round_rate is local to the source and does not need to be in global scope, so make it static. Cleans up sparse warning: sound/soc/intel/skylake/skl-ssp-clk.c:250:6: warning: symbol 'skl_clk_round_rate' was not declared. Should it be static? Signed-off-by: Colin Ian King Reviewed-by: Takashi Sakamoto Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-ssp-clk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/intel/skylake/skl-ssp-clk.c b/sound/soc/intel/skylake/skl-ssp-clk.c index 7fbddf5e3b00..cda1b5fa7436 100644 --- a/sound/soc/intel/skylake/skl-ssp-clk.c +++ b/sound/soc/intel/skylake/skl-ssp-clk.c @@ -247,8 +247,8 @@ static unsigned long skl_clk_recalc_rate(struct clk_hw *hw, } /* Not supported by clk driver. Implemented to satisfy clk fw */ -long skl_clk_round_rate(struct clk_hw *hw, unsigned long rate, - unsigned long *parent_rate) +static long skl_clk_round_rate(struct clk_hw *hw, unsigned long rate, + unsigned long *parent_rate) { return rate; } From 17b52010b50b505fc083ce3b8fb4978e6b543411 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:44:39 +0000 Subject: [PATCH 002/102] ASoC: rt5651: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 220 +++++++++++++------------- sound/soc/codecs/rt5651.h | 4 +- sound/soc/intel/boards/bytcr_rt5651.c | 2 +- 3 files changed, 113 insertions(+), 113 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 831b297978a4..3a844725684b 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -384,17 +384,17 @@ static const struct snd_kcontrol_new rt5651_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 rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); int idx, rate; rate = rt5651->sysclk / rl6231_get_pre_div(rt5651->regmap, RT5651_ADDA_CLK1, RT5651_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, RT5651_DMIC, RT5651_DMIC_CLK_MASK, + snd_soc_component_update_bits(component, RT5651_DMIC, RT5651_DMIC_CLK_MASK, idx << RT5651_DMIC_CLK_SFT); return idx; @@ -403,10 +403,10 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w, static int is_sysclk_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, RT5651_GLB_CLK); + val = snd_soc_component_read32(component, RT5651_GLB_CLK); val &= RT5651_SCLK_SRC_MASK; if (val == RT5651_SCLK_SRC_PLL1) return 1; @@ -703,8 +703,8 @@ static const struct snd_kcontrol_new rt5651_pdm_r_mux = static int rt5651_amp_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 rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -741,8 +741,8 @@ static int rt5651_amp_power_event(struct snd_soc_dapm_widget *w, static int rt5651_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 rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -786,8 +786,8 @@ static int rt5651_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 rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -806,16 +806,16 @@ static int rt5651_hp_post_event(struct snd_soc_dapm_widget *w, static int rt5651_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, RT5651_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5651_PWR_ANLG2, RT5651_PWR_BST1_OP2, RT5651_PWR_BST1_OP2); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, RT5651_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5651_PWR_ANLG2, RT5651_PWR_BST1_OP2, 0); break; @@ -829,16 +829,16 @@ static int rt5651_bst1_event(struct snd_soc_dapm_widget *w, static int rt5651_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, RT5651_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5651_PWR_ANLG2, RT5651_PWR_BST2_OP2, RT5651_PWR_BST2_OP2); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, RT5651_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5651_PWR_ANLG2, RT5651_PWR_BST2_OP2, 0); break; @@ -852,16 +852,16 @@ static int rt5651_bst2_event(struct snd_soc_dapm_widget *w, static int rt5651_bst3_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, RT5651_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5651_PWR_ANLG2, RT5651_PWR_BST3_OP2, RT5651_PWR_BST3_OP2); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, RT5651_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5651_PWR_ANLG2, RT5651_PWR_BST3_OP2, 0); break; @@ -1313,8 +1313,8 @@ static const struct snd_soc_dapm_route rt5651_dapm_routes[] = { static int rt5651_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 rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); unsigned int val_len = 0, val_clk, mask_clk; int pre_div, bclk_ms, frame_size; @@ -1322,12 +1322,12 @@ static int rt5651_hw_params(struct snd_pcm_substream *substream, pre_div = rl6231_get_clk_info(rt5651->sysclk, rt5651->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; @@ -1358,19 +1358,19 @@ static int rt5651_hw_params(struct snd_pcm_substream *substream, case RT5651_AIF1: mask_clk = RT5651_I2S_PD1_MASK; val_clk = pre_div << RT5651_I2S_PD1_SFT; - snd_soc_update_bits(codec, RT5651_I2S1_SDP, + snd_soc_component_update_bits(component, RT5651_I2S1_SDP, RT5651_I2S_DL_MASK, val_len); - snd_soc_update_bits(codec, RT5651_ADDA_CLK1, mask_clk, val_clk); + snd_soc_component_update_bits(component, RT5651_ADDA_CLK1, mask_clk, val_clk); break; case RT5651_AIF2: mask_clk = RT5651_I2S_BCLK_MS2_MASK | RT5651_I2S_PD2_MASK; val_clk = pre_div << RT5651_I2S_PD2_SFT; - snd_soc_update_bits(codec, RT5651_I2S2_SDP, + snd_soc_component_update_bits(component, RT5651_I2S2_SDP, RT5651_I2S_DL_MASK, val_len); - snd_soc_update_bits(codec, RT5651_ADDA_CLK1, mask_clk, val_clk); + snd_soc_component_update_bits(component, RT5651_ADDA_CLK1, mask_clk, val_clk); break; default: - dev_err(codec->dev, "Wrong dai->id: %d\n", dai->id); + dev_err(component->dev, "Wrong dai->id: %d\n", dai->id); return -EINVAL; } @@ -1379,8 +1379,8 @@ static int rt5651_hw_params(struct snd_pcm_substream *substream, static int rt5651_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -1423,17 +1423,17 @@ static int rt5651_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) switch (dai->id) { case RT5651_AIF1: - snd_soc_update_bits(codec, RT5651_I2S1_SDP, + snd_soc_component_update_bits(component, RT5651_I2S1_SDP, RT5651_I2S_MS_MASK | RT5651_I2S_BP_MASK | RT5651_I2S_DF_MASK, reg_val); break; case RT5651_AIF2: - snd_soc_update_bits(codec, RT5651_I2S2_SDP, + snd_soc_component_update_bits(component, RT5651_I2S2_SDP, RT5651_I2S_MS_MASK | RT5651_I2S_BP_MASK | RT5651_I2S_DF_MASK, reg_val); break; default: - dev_err(codec->dev, "Wrong dai->id: %d\n", dai->id); + dev_err(component->dev, "Wrong dai->id: %d\n", dai->id); return -EINVAL; } return 0; @@ -1442,8 +1442,8 @@ static int rt5651_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int rt5651_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; if (freq == rt5651->sysclk && clk_id == rt5651->sysclk_src) @@ -1460,10 +1460,10 @@ static int rt5651_set_dai_sysclk(struct snd_soc_dai *dai, reg_val |= RT5651_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, RT5651_GLB_CLK, + snd_soc_component_update_bits(component, RT5651_GLB_CLK, RT5651_SCLK_SRC_MASK, reg_val); rt5651->sysclk = freq; rt5651->sysclk_src = clk_id; @@ -1476,8 +1476,8 @@ static int rt5651_set_dai_sysclk(struct snd_soc_dai *dai, static int rt5651_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 rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); struct rl6231_pll_code pll_code; int ret; @@ -1486,46 +1486,46 @@ static int rt5651_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"); rt5651->pll_in = 0; rt5651->pll_out = 0; - snd_soc_update_bits(codec, RT5651_GLB_CLK, + snd_soc_component_update_bits(component, RT5651_GLB_CLK, RT5651_SCLK_SRC_MASK, RT5651_SCLK_SRC_MCLK); return 0; } switch (source) { case RT5651_PLL1_S_MCLK: - snd_soc_update_bits(codec, RT5651_GLB_CLK, + snd_soc_component_update_bits(component, RT5651_GLB_CLK, RT5651_PLL1_SRC_MASK, RT5651_PLL1_SRC_MCLK); break; case RT5651_PLL1_S_BCLK1: - snd_soc_update_bits(codec, RT5651_GLB_CLK, + snd_soc_component_update_bits(component, RT5651_GLB_CLK, RT5651_PLL1_SRC_MASK, RT5651_PLL1_SRC_BCLK1); break; case RT5651_PLL1_S_BCLK2: - snd_soc_update_bits(codec, RT5651_GLB_CLK, + snd_soc_component_update_bits(component, RT5651_GLB_CLK, RT5651_PLL1_SRC_MASK, RT5651_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, RT5651_PLL_CTRL1, + snd_soc_component_write(component, RT5651_PLL_CTRL1, pll_code.n_code << RT5651_PLL_N_SFT | pll_code.k_code); - snd_soc_write(codec, RT5651_PLL_CTRL2, + snd_soc_component_write(component, RT5651_PLL_CTRL2, (pll_code.m_bp ? 0 : pll_code.m_code) << RT5651_PLL_M_SFT | pll_code.m_bp << RT5651_PLL_M_BP_SFT); @@ -1536,45 +1536,45 @@ static int rt5651_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, return 0; } -static int rt5651_set_bias_level(struct snd_soc_codec *codec, +static int rt5651_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_PREPARE: - if (SND_SOC_BIAS_STANDBY == snd_soc_codec_get_bias_level(codec)) { - snd_soc_update_bits(codec, RT5651_PWR_ANLG1, + if (SND_SOC_BIAS_STANDBY == snd_soc_component_get_bias_level(component)) { + snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, RT5651_PWR_VREF1 | RT5651_PWR_MB | RT5651_PWR_BG | RT5651_PWR_VREF2, RT5651_PWR_VREF1 | RT5651_PWR_MB | RT5651_PWR_BG | RT5651_PWR_VREF2); usleep_range(10000, 15000); - snd_soc_update_bits(codec, RT5651_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, RT5651_PWR_FV1 | RT5651_PWR_FV2, RT5651_PWR_FV1 | RT5651_PWR_FV2); - snd_soc_update_bits(codec, RT5651_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, RT5651_PWR_LDO_DVO_MASK, RT5651_PWR_LDO_DVO_1_2V); - snd_soc_update_bits(codec, RT5651_D_MISC, 0x1, 0x1); - if (snd_soc_read(codec, RT5651_PLL_MODE_1) & 0x9200) - snd_soc_update_bits(codec, RT5651_D_MISC, + snd_soc_component_update_bits(component, RT5651_D_MISC, 0x1, 0x1); + if (snd_soc_component_read32(component, RT5651_PLL_MODE_1) & 0x9200) + snd_soc_component_update_bits(component, RT5651_D_MISC, 0xc00, 0xc00); } break; case SND_SOC_BIAS_STANDBY: - snd_soc_write(codec, RT5651_D_MISC, 0x0010); - snd_soc_write(codec, RT5651_PWR_DIG1, 0x0000); - snd_soc_write(codec, RT5651_PWR_DIG2, 0x0000); - snd_soc_write(codec, RT5651_PWR_VOL, 0x0000); - snd_soc_write(codec, RT5651_PWR_MIXER, 0x0000); + snd_soc_component_write(component, RT5651_D_MISC, 0x0010); + snd_soc_component_write(component, RT5651_PWR_DIG1, 0x0000); + snd_soc_component_write(component, RT5651_PWR_DIG2, 0x0000); + snd_soc_component_write(component, RT5651_PWR_VOL, 0x0000); + snd_soc_component_write(component, RT5651_PWR_MIXER, 0x0000); if (rt5651->pdata.jd_src) { - snd_soc_write(codec, RT5651_PWR_ANLG2, 0x0204); - snd_soc_write(codec, RT5651_PWR_ANLG1, 0x0002); + snd_soc_component_write(component, RT5651_PWR_ANLG2, 0x0204); + snd_soc_component_write(component, RT5651_PWR_ANLG1, 0x0002); } else { - snd_soc_write(codec, RT5651_PWR_ANLG1, 0x0000); - snd_soc_write(codec, RT5651_PWR_ANLG2, 0x0000); + snd_soc_component_write(component, RT5651_PWR_ANLG1, 0x0000); + snd_soc_component_write(component, RT5651_PWR_ANLG2, 0x0000); } break; @@ -1585,24 +1585,24 @@ static int rt5651_set_bias_level(struct snd_soc_codec *codec, return 0; } -static int rt5651_probe(struct snd_soc_codec *codec) +static int rt5651_probe(struct snd_soc_component *component) { - struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); - rt5651->codec = codec; + rt5651->component = component; - snd_soc_update_bits(codec, RT5651_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, RT5651_PWR_VREF1 | RT5651_PWR_MB | RT5651_PWR_BG | RT5651_PWR_VREF2, RT5651_PWR_VREF1 | RT5651_PWR_MB | RT5651_PWR_BG | RT5651_PWR_VREF2); usleep_range(10000, 15000); - snd_soc_update_bits(codec, RT5651_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, RT5651_PWR_FV1 | RT5651_PWR_FV2, RT5651_PWR_FV1 | RT5651_PWR_FV2); - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); if (rt5651->pdata.jd_src) { snd_soc_dapm_force_enable_pin(dapm, "JD Power"); @@ -1617,21 +1617,21 @@ static int rt5651_probe(struct snd_soc_codec *codec) } #ifdef CONFIG_PM -static int rt5651_suspend(struct snd_soc_codec *codec) +static int rt5651_suspend(struct snd_soc_component *component) { - struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt5651->regmap, true); regcache_mark_dirty(rt5651->regmap); return 0; } -static int rt5651_resume(struct snd_soc_codec *codec) +static int rt5651_resume(struct snd_soc_component *component) { - struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt5651->regmap, false); - snd_soc_cache_sync(codec); + snd_soc_component_cache_sync(component); return 0; } @@ -1692,20 +1692,20 @@ static struct snd_soc_dai_driver rt5651_dai[] = { }, }; -static const struct snd_soc_codec_driver soc_codec_dev_rt5651 = { - .probe = rt5651_probe, - .suspend = rt5651_suspend, - .resume = rt5651_resume, - .set_bias_level = rt5651_set_bias_level, - .idle_bias_off = true, - .component_driver = { - .controls = rt5651_snd_controls, - .num_controls = ARRAY_SIZE(rt5651_snd_controls), - .dapm_widgets = rt5651_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(rt5651_dapm_widgets), - .dapm_routes = rt5651_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(rt5651_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_rt5651 = { + .probe = rt5651_probe, + .suspend = rt5651_suspend, + .resume = rt5651_resume, + .set_bias_level = rt5651_set_bias_level, + .controls = rt5651_snd_controls, + .num_controls = ARRAY_SIZE(rt5651_snd_controls), + .dapm_widgets = rt5651_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt5651_dapm_widgets), + .dapm_routes = rt5651_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(rt5651_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config rt5651_regmap = { @@ -1794,16 +1794,16 @@ static irqreturn_t rt5651_irq(int irq, void *data) return IRQ_HANDLED; } -static int rt5651_jack_detect(struct snd_soc_codec *codec, int jack_insert) +static int rt5651_jack_detect(struct snd_soc_component *component, int jack_insert) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int jack_type; if (jack_insert) { snd_soc_dapm_force_enable_pin(dapm, "LDO"); snd_soc_dapm_sync(dapm); - snd_soc_update_bits(codec, RT5651_MICBIAS, + snd_soc_component_update_bits(component, RT5651_MICBIAS, RT5651_MIC1_OVCD_MASK | RT5651_MIC1_OVTH_MASK | RT5651_PWR_CLK12M_MASK | @@ -1813,16 +1813,16 @@ static int rt5651_jack_detect(struct snd_soc_codec *codec, int jack_insert) RT5651_PWR_MB_PU | RT5651_PWR_CLK12M_PU); msleep(100); - if (snd_soc_read(codec, RT5651_IRQ_CTRL2) & RT5651_MB1_OC_CLR) + if (snd_soc_component_read32(component, RT5651_IRQ_CTRL2) & RT5651_MB1_OC_CLR) jack_type = SND_JACK_HEADPHONE; else jack_type = SND_JACK_HEADSET; - snd_soc_update_bits(codec, RT5651_IRQ_CTRL2, + snd_soc_component_update_bits(component, RT5651_IRQ_CTRL2, RT5651_MB1_OC_CLR, 0); } else { /* jack out */ jack_type = 0; - snd_soc_update_bits(codec, RT5651_MICBIAS, + snd_soc_component_update_bits(component, RT5651_MICBIAS, RT5651_MIC1_OVCD_MASK, RT5651_MIC1_OVCD_DIS); } @@ -1837,32 +1837,32 @@ static void rt5651_jack_detect_work(struct work_struct *work) int report, val = 0; - if (!rt5651->codec) + if (!rt5651->component) return; switch (rt5651->pdata.jd_src) { case RT5651_JD1_1: - val = snd_soc_read(rt5651->codec, RT5651_INT_IRQ_ST) & 0x1000; + val = snd_soc_component_read32(rt5651->component, RT5651_INT_IRQ_ST) & 0x1000; break; case RT5651_JD1_2: - val = snd_soc_read(rt5651->codec, RT5651_INT_IRQ_ST) & 0x2000; + val = snd_soc_component_read32(rt5651->component, RT5651_INT_IRQ_ST) & 0x2000; break; case RT5651_JD2: - val = snd_soc_read(rt5651->codec, RT5651_INT_IRQ_ST) & 0x4000; + val = snd_soc_component_read32(rt5651->component, RT5651_INT_IRQ_ST) & 0x4000; break; default: break; } - report = rt5651_jack_detect(rt5651->codec, !val); + report = rt5651_jack_detect(rt5651->component, !val); snd_soc_jack_report(rt5651->hp_jack, report, SND_JACK_HEADSET); } -int rt5651_set_jack_detect(struct snd_soc_codec *codec, +int rt5651_set_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *hp_jack) { - struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); rt5651->hp_jack = hp_jack; rt5651_irq(0, rt5651); @@ -1979,7 +1979,8 @@ static int rt5651_i2c_probe(struct i2c_client *i2c, } } - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5651, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_rt5651, rt5651_dai, ARRAY_SIZE(rt5651_dai)); return ret; @@ -1990,7 +1991,6 @@ static int rt5651_i2c_remove(struct i2c_client *i2c) struct rt5651_priv *rt5651 = i2c_get_clientdata(i2c); cancel_delayed_work_sync(&rt5651->jack_detect_work); - snd_soc_unregister_codec(&i2c->dev); return 0; } diff --git a/sound/soc/codecs/rt5651.h b/sound/soc/codecs/rt5651.h index 4f8b202121d7..1ef38429e6a0 100644 --- a/sound/soc/codecs/rt5651.h +++ b/sound/soc/codecs/rt5651.h @@ -2059,7 +2059,7 @@ struct rt5651_pll_code { }; struct rt5651_priv { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct rt5651_platform_data pdata; struct regmap *regmap; struct snd_soc_jack *hp_jack; @@ -2079,6 +2079,6 @@ struct rt5651_priv { bool hp_mute; }; -int rt5651_set_jack_detect(struct snd_soc_codec *codec, +int rt5651_set_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *hp_jack); #endif /* __RT5651_H__ */ diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 456526a93dd5..b6bf92191b9a 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -296,7 +296,7 @@ static const struct dmi_system_id byt_rt5651_quirk_table[] = { static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) { struct snd_soc_card *card = runtime->card; - struct snd_soc_codec *codec = runtime->codec; + struct snd_soc_component *codec = runtime->codec_dai->component; struct byt_rt5651_private *priv = snd_soc_card_get_drvdata(card); const struct snd_soc_dapm_route *custom_map; int num_routes; From 4510112217116d97df02121d3e1442858efb4897 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:36:54 +0000 Subject: [PATCH 003/102] ASoC: hdac_hdmi/nau8825/rt286/rt298/rt5663/da7219: replace codec to component Now we can replace Codec to Component. Let's do it. Because intal/rockchip boards are using multi-codecs in 1 driver, we need to update these all related drivers in same time. Otherwise compile error/warning happen Note: hdac_hdmi xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 nau8825 xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 rt286 xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 rt298 xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 rt5663 xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 da7219 xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/da7219-aad.c | 236 +++---- sound/soc/codecs/da7219-aad.h | 12 +- sound/soc/codecs/da7219.c | 307 ++++----- sound/soc/codecs/da7219.h | 2 +- sound/soc/codecs/hdac_hdmi.c | 47 +- sound/soc/codecs/hdac_hdmi.h | 2 +- sound/soc/codecs/nau8825.c | 107 ++-- sound/soc/codecs/nau8825.h | 2 +- sound/soc/codecs/rt286.c | 198 +++--- sound/soc/codecs/rt286.h | 2 +- sound/soc/codecs/rt298.c | 210 +++--- sound/soc/codecs/rt298.h | 2 +- sound/soc/codecs/rt5663.c | 598 +++++++++--------- sound/soc/codecs/rt5663.h | 4 +- sound/soc/intel/boards/broadwell.c | 14 +- sound/soc/intel/boards/bxt_da7219_max98357a.c | 12 +- sound/soc/intel/boards/bxt_rt298.c | 12 +- sound/soc/intel/boards/kbl_rt5663_max98927.c | 14 +- .../intel/boards/kbl_rt5663_rt5514_max98927.c | 14 +- .../soc/intel/boards/skl_nau88l25_max98357a.c | 12 +- sound/soc/intel/boards/skl_nau88l25_ssm4567.c | 12 +- sound/soc/intel/boards/skl_rt286.c | 12 +- sound/soc/rockchip/rk3399_gru_sound.c | 4 +- 23 files changed, 913 insertions(+), 922 deletions(-) diff --git a/sound/soc/codecs/da7219-aad.c b/sound/soc/codecs/da7219-aad.c index 1d1d10dd92ae..a49ab751a036 100644 --- a/sound/soc/codecs/da7219-aad.c +++ b/sound/soc/codecs/da7219-aad.c @@ -32,9 +32,9 @@ * Detection control */ -void da7219_aad_jack_det(struct snd_soc_codec *codec, struct snd_soc_jack *jack) +void da7219_aad_jack_det(struct snd_soc_component *component, struct snd_soc_jack *jack) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); da7219->aad->jack = jack; da7219->aad->jack_inserted = false; @@ -43,7 +43,7 @@ void da7219_aad_jack_det(struct snd_soc_codec *codec, struct snd_soc_jack *jack) snd_soc_jack_report(jack, 0, DA7219_AAD_REPORT_ALL_MASK); /* Enable/Disable jack detection */ - snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_1, + snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_1, DA7219_ACCDET_EN_MASK, (jack ? DA7219_ACCDET_EN_MASK : 0)); } @@ -57,17 +57,17 @@ static void da7219_aad_btn_det_work(struct work_struct *work) { struct da7219_aad_priv *da7219_aad = container_of(work, struct da7219_aad_priv, btn_det_work); - struct snd_soc_codec *codec = da7219_aad->codec; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_component *component = da7219_aad->component; + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); u8 statusa, micbias_ctrl; bool micbias_up = false; int retries = 0; /* Drive headphones/lineout */ - snd_soc_update_bits(codec, DA7219_HP_L_CTRL, + snd_soc_component_update_bits(component, DA7219_HP_L_CTRL, DA7219_HP_L_AMP_OE_MASK, DA7219_HP_L_AMP_OE_MASK); - snd_soc_update_bits(codec, DA7219_HP_R_CTRL, + snd_soc_component_update_bits(component, DA7219_HP_R_CTRL, DA7219_HP_R_AMP_OE_MASK, DA7219_HP_R_AMP_OE_MASK); @@ -76,7 +76,7 @@ static void da7219_aad_btn_det_work(struct work_struct *work) snd_soc_dapm_sync(dapm); do { - statusa = snd_soc_read(codec, DA7219_ACCDET_STATUS_A); + statusa = snd_soc_component_read32(component, DA7219_ACCDET_STATUS_A); if (statusa & DA7219_MICBIAS_UP_STS_MASK) micbias_up = true; else if (retries++ < DA7219_AAD_MICBIAS_CHK_RETRIES) @@ -84,7 +84,7 @@ static void da7219_aad_btn_det_work(struct work_struct *work) } while ((!micbias_up) && (retries < DA7219_AAD_MICBIAS_CHK_RETRIES)); if (retries >= DA7219_AAD_MICBIAS_CHK_RETRIES) - dev_warn(codec->dev, "Mic bias status check timed out"); + dev_warn(component->dev, "Mic bias status check timed out"); /* * Mic bias pulse required to enable mic, must be done before enabling @@ -92,16 +92,16 @@ static void da7219_aad_btn_det_work(struct work_struct *work) */ if (da7219_aad->micbias_pulse_lvl && da7219_aad->micbias_pulse_time) { /* Pulse higher level voltage */ - micbias_ctrl = snd_soc_read(codec, DA7219_MICBIAS_CTRL); - snd_soc_update_bits(codec, DA7219_MICBIAS_CTRL, + micbias_ctrl = snd_soc_component_read32(component, DA7219_MICBIAS_CTRL); + snd_soc_component_update_bits(component, DA7219_MICBIAS_CTRL, DA7219_MICBIAS1_LEVEL_MASK, da7219_aad->micbias_pulse_lvl); msleep(da7219_aad->micbias_pulse_time); - snd_soc_write(codec, DA7219_MICBIAS_CTRL, micbias_ctrl); + snd_soc_component_write(component, DA7219_MICBIAS_CTRL, micbias_ctrl); } - snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_1, + snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_1, DA7219_BUTTON_CONFIG_MASK, da7219_aad->btn_cfg); } @@ -110,9 +110,9 @@ static void da7219_aad_hptest_work(struct work_struct *work) { struct da7219_aad_priv *da7219_aad = container_of(work, struct da7219_aad_priv, hptest_work); - struct snd_soc_codec *codec = da7219_aad->codec; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = da7219_aad->component; + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); u16 tonegen_freq_hptest; u8 pll_srm_sts, pll_ctrl, gain_ramp_ctrl, accdet_cfg8; @@ -127,7 +127,7 @@ static void da7219_aad_hptest_work(struct work_struct *work) if (da7219->mclk) { ret = clk_prepare_enable(da7219->mclk); if (ret) { - dev_err(codec->dev, "Failed to enable mclk - %d\n", ret); + dev_err(component->dev, "Failed to enable mclk - %d\n", ret); mutex_unlock(&da7219->pll_lock); mutex_unlock(&da7219->ctrl_lock); snd_soc_dapm_mutex_unlock(dapm); @@ -142,90 +142,90 @@ static void da7219_aad_hptest_work(struct work_struct *work) * If MCLK is present, but PLL is not enabled then we enable it here to * ensure a consistent detection procedure. */ - pll_srm_sts = snd_soc_read(codec, DA7219_PLL_SRM_STS); + pll_srm_sts = snd_soc_component_read32(component, DA7219_PLL_SRM_STS); if (pll_srm_sts & DA7219_PLL_SRM_STS_MCLK) { tonegen_freq_hptest = cpu_to_le16(DA7219_AAD_HPTEST_RAMP_FREQ); - pll_ctrl = snd_soc_read(codec, DA7219_PLL_CTRL); + pll_ctrl = snd_soc_component_read32(component, DA7219_PLL_CTRL); if ((pll_ctrl & DA7219_PLL_MODE_MASK) == DA7219_PLL_MODE_BYPASS) - da7219_set_pll(codec, DA7219_SYSCLK_PLL, + da7219_set_pll(component, DA7219_SYSCLK_PLL, DA7219_PLL_FREQ_OUT_98304); } else { tonegen_freq_hptest = cpu_to_le16(DA7219_AAD_HPTEST_RAMP_FREQ_INT_OSC); } /* Ensure gain ramping at fastest rate */ - gain_ramp_ctrl = snd_soc_read(codec, DA7219_GAIN_RAMP_CTRL); - snd_soc_write(codec, DA7219_GAIN_RAMP_CTRL, DA7219_GAIN_RAMP_RATE_X8); + gain_ramp_ctrl = snd_soc_component_read32(component, DA7219_GAIN_RAMP_CTRL); + snd_soc_component_write(component, DA7219_GAIN_RAMP_CTRL, DA7219_GAIN_RAMP_RATE_X8); /* Bypass cache so it saves current settings */ regcache_cache_bypass(da7219->regmap, true); /* Make sure Tone Generator is disabled */ - snd_soc_write(codec, DA7219_TONE_GEN_CFG1, 0); + snd_soc_component_write(component, DA7219_TONE_GEN_CFG1, 0); /* Enable HPTest block, 1KOhms check */ - snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_8, + snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_8, DA7219_HPTEST_EN_MASK | DA7219_HPTEST_RES_SEL_MASK, DA7219_HPTEST_EN_MASK | DA7219_HPTEST_RES_SEL_1KOHMS); /* Set gains to 0db */ - snd_soc_write(codec, DA7219_DAC_L_GAIN, DA7219_DAC_DIGITAL_GAIN_0DB); - snd_soc_write(codec, DA7219_DAC_R_GAIN, DA7219_DAC_DIGITAL_GAIN_0DB); - snd_soc_write(codec, DA7219_HP_L_GAIN, DA7219_HP_AMP_GAIN_0DB); - snd_soc_write(codec, DA7219_HP_R_GAIN, DA7219_HP_AMP_GAIN_0DB); + snd_soc_component_write(component, DA7219_DAC_L_GAIN, DA7219_DAC_DIGITAL_GAIN_0DB); + snd_soc_component_write(component, DA7219_DAC_R_GAIN, DA7219_DAC_DIGITAL_GAIN_0DB); + snd_soc_component_write(component, DA7219_HP_L_GAIN, DA7219_HP_AMP_GAIN_0DB); + snd_soc_component_write(component, DA7219_HP_R_GAIN, DA7219_HP_AMP_GAIN_0DB); /* Disable DAC filters, EQs and soft mute */ - snd_soc_update_bits(codec, DA7219_DAC_FILTERS1, DA7219_HPF_MODE_MASK, + snd_soc_component_update_bits(component, DA7219_DAC_FILTERS1, DA7219_HPF_MODE_MASK, 0); - snd_soc_update_bits(codec, DA7219_DAC_FILTERS4, DA7219_DAC_EQ_EN_MASK, + snd_soc_component_update_bits(component, DA7219_DAC_FILTERS4, DA7219_DAC_EQ_EN_MASK, 0); - snd_soc_update_bits(codec, DA7219_DAC_FILTERS5, + snd_soc_component_update_bits(component, DA7219_DAC_FILTERS5, DA7219_DAC_SOFTMUTE_EN_MASK, 0); /* Enable HP left & right paths */ - snd_soc_update_bits(codec, DA7219_CP_CTRL, DA7219_CP_EN_MASK, + snd_soc_component_update_bits(component, DA7219_CP_CTRL, DA7219_CP_EN_MASK, DA7219_CP_EN_MASK); - snd_soc_update_bits(codec, DA7219_DIG_ROUTING_DAC, + snd_soc_component_update_bits(component, DA7219_DIG_ROUTING_DAC, DA7219_DAC_L_SRC_MASK | DA7219_DAC_R_SRC_MASK, DA7219_DAC_L_SRC_TONEGEN | DA7219_DAC_R_SRC_TONEGEN); - snd_soc_update_bits(codec, DA7219_DAC_L_CTRL, + snd_soc_component_update_bits(component, DA7219_DAC_L_CTRL, DA7219_DAC_L_EN_MASK | DA7219_DAC_L_MUTE_EN_MASK, DA7219_DAC_L_EN_MASK); - snd_soc_update_bits(codec, DA7219_DAC_R_CTRL, + snd_soc_component_update_bits(component, DA7219_DAC_R_CTRL, DA7219_DAC_R_EN_MASK | DA7219_DAC_R_MUTE_EN_MASK, DA7219_DAC_R_EN_MASK); - snd_soc_update_bits(codec, DA7219_MIXOUT_L_SELECT, + snd_soc_component_update_bits(component, DA7219_MIXOUT_L_SELECT, DA7219_MIXOUT_L_MIX_SELECT_MASK, DA7219_MIXOUT_L_MIX_SELECT_MASK); - snd_soc_update_bits(codec, DA7219_MIXOUT_R_SELECT, + snd_soc_component_update_bits(component, DA7219_MIXOUT_R_SELECT, DA7219_MIXOUT_R_MIX_SELECT_MASK, DA7219_MIXOUT_R_MIX_SELECT_MASK); - snd_soc_update_bits(codec, DA7219_DROUTING_ST_OUTFILT_1L, + snd_soc_component_update_bits(component, DA7219_DROUTING_ST_OUTFILT_1L, DA7219_OUTFILT_ST_1L_SRC_MASK, DA7219_DMIX_ST_SRC_OUTFILT1L); - snd_soc_update_bits(codec, DA7219_DROUTING_ST_OUTFILT_1R, + snd_soc_component_update_bits(component, DA7219_DROUTING_ST_OUTFILT_1R, DA7219_OUTFILT_ST_1R_SRC_MASK, DA7219_DMIX_ST_SRC_OUTFILT1R); - snd_soc_update_bits(codec, DA7219_MIXOUT_L_CTRL, + snd_soc_component_update_bits(component, DA7219_MIXOUT_L_CTRL, DA7219_MIXOUT_L_AMP_EN_MASK, DA7219_MIXOUT_L_AMP_EN_MASK); - snd_soc_update_bits(codec, DA7219_MIXOUT_R_CTRL, + snd_soc_component_update_bits(component, DA7219_MIXOUT_R_CTRL, DA7219_MIXOUT_R_AMP_EN_MASK, DA7219_MIXOUT_R_AMP_EN_MASK); - snd_soc_update_bits(codec, DA7219_HP_L_CTRL, + snd_soc_component_update_bits(component, DA7219_HP_L_CTRL, DA7219_HP_L_AMP_OE_MASK | DA7219_HP_L_AMP_EN_MASK, DA7219_HP_L_AMP_OE_MASK | DA7219_HP_L_AMP_EN_MASK); - snd_soc_update_bits(codec, DA7219_HP_R_CTRL, + snd_soc_component_update_bits(component, DA7219_HP_R_CTRL, DA7219_HP_R_AMP_OE_MASK | DA7219_HP_R_AMP_EN_MASK, DA7219_HP_R_AMP_OE_MASK | DA7219_HP_R_AMP_EN_MASK); msleep(DA7219_SETTLING_DELAY); - snd_soc_update_bits(codec, DA7219_HP_L_CTRL, + snd_soc_component_update_bits(component, DA7219_HP_L_CTRL, DA7219_HP_L_AMP_MUTE_EN_MASK | DA7219_HP_L_AMP_MIN_GAIN_EN_MASK, 0); - snd_soc_update_bits(codec, DA7219_HP_R_CTRL, + snd_soc_component_update_bits(component, DA7219_HP_R_CTRL, DA7219_HP_R_AMP_MUTE_EN_MASK | DA7219_HP_R_AMP_MIN_GAIN_EN_MASK, 0); @@ -237,26 +237,26 @@ static void da7219_aad_hptest_work(struct work_struct *work) msleep(DA7219_AAD_HPTEST_INT_OSC_PATH_DELAY); /* Configure & start Tone Generator */ - snd_soc_write(codec, DA7219_TONE_GEN_ON_PER, DA7219_BEEP_ON_PER_MASK); + snd_soc_component_write(component, DA7219_TONE_GEN_ON_PER, DA7219_BEEP_ON_PER_MASK); regmap_raw_write(da7219->regmap, DA7219_TONE_GEN_FREQ1_L, &tonegen_freq_hptest, sizeof(tonegen_freq_hptest)); - snd_soc_update_bits(codec, DA7219_TONE_GEN_CFG2, + snd_soc_component_update_bits(component, DA7219_TONE_GEN_CFG2, DA7219_SWG_SEL_MASK | DA7219_TONE_GEN_GAIN_MASK, DA7219_SWG_SEL_SRAMP | DA7219_TONE_GEN_GAIN_MINUS_15DB); - snd_soc_write(codec, DA7219_TONE_GEN_CFG1, DA7219_START_STOPN_MASK); + snd_soc_component_write(component, DA7219_TONE_GEN_CFG1, DA7219_START_STOPN_MASK); msleep(DA7219_AAD_HPTEST_PERIOD); /* Grab comparator reading */ - accdet_cfg8 = snd_soc_read(codec, DA7219_ACCDET_CONFIG_8); + accdet_cfg8 = snd_soc_component_read32(component, DA7219_ACCDET_CONFIG_8); if (accdet_cfg8 & DA7219_HPTEST_COMP_MASK) report |= SND_JACK_HEADPHONE; else report |= SND_JACK_LINEOUT; /* Stop tone generator */ - snd_soc_write(codec, DA7219_TONE_GEN_CFG1, 0); + snd_soc_component_write(component, DA7219_TONE_GEN_CFG1, 0); msleep(DA7219_AAD_HPTEST_PERIOD); @@ -294,7 +294,7 @@ static void da7219_aad_hptest_work(struct work_struct *work) regcache_cache_bypass(da7219->regmap, false); /* Disable HPTest block */ - snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_8, + snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_8, DA7219_HPTEST_EN_MASK, 0); /* @@ -305,18 +305,18 @@ static void da7219_aad_hptest_work(struct work_struct *work) msleep(DA7219_AAD_HPTEST_INT_OSC_PATH_DELAY); /* Restore gain ramping rate */ - snd_soc_write(codec, DA7219_GAIN_RAMP_CTRL, gain_ramp_ctrl); + snd_soc_component_write(component, DA7219_GAIN_RAMP_CTRL, gain_ramp_ctrl); /* Drive Headphones/lineout */ - snd_soc_update_bits(codec, DA7219_HP_L_CTRL, DA7219_HP_L_AMP_OE_MASK, + snd_soc_component_update_bits(component, DA7219_HP_L_CTRL, DA7219_HP_L_AMP_OE_MASK, DA7219_HP_L_AMP_OE_MASK); - snd_soc_update_bits(codec, DA7219_HP_R_CTRL, DA7219_HP_R_AMP_OE_MASK, + snd_soc_component_update_bits(component, DA7219_HP_R_CTRL, DA7219_HP_R_AMP_OE_MASK, DA7219_HP_R_AMP_OE_MASK); /* Restore PLL to previous configuration, if re-configured */ if ((pll_srm_sts & DA7219_PLL_SRM_STS_MCLK) && ((pll_ctrl & DA7219_PLL_MODE_MASK) == DA7219_PLL_MODE_BYPASS)) - da7219_set_pll(codec, DA7219_SYSCLK_MCLK, 0); + da7219_set_pll(component, DA7219_SYSCLK_MCLK, 0); /* Remove MCLK, if previously enabled */ if (da7219->mclk) @@ -343,9 +343,9 @@ static void da7219_aad_hptest_work(struct work_struct *work) static irqreturn_t da7219_aad_irq_thread(int irq, void *data) { struct da7219_aad_priv *da7219_aad = data; - struct snd_soc_codec *codec = da7219_aad->codec; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = da7219_aad->component; + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); u8 events[DA7219_AAD_IRQ_REG_MAX]; u8 statusa; int i, report = 0, mask = 0; @@ -358,13 +358,13 @@ static irqreturn_t da7219_aad_irq_thread(int irq, void *data) return IRQ_NONE; /* Read status register for jack insertion & type status */ - statusa = snd_soc_read(codec, DA7219_ACCDET_STATUS_A); + statusa = snd_soc_component_read32(component, DA7219_ACCDET_STATUS_A); /* Clear events */ regmap_bulk_write(da7219->regmap, DA7219_ACCDET_IRQ_EVENT_A, events, DA7219_AAD_IRQ_REG_MAX); - dev_dbg(codec->dev, "IRQ events = 0x%x|0x%x, status = 0x%x\n", + dev_dbg(component->dev, "IRQ events = 0x%x|0x%x, status = 0x%x\n", events[DA7219_AAD_IRQ_REG_A], events[DA7219_AAD_IRQ_REG_B], statusa); @@ -430,13 +430,13 @@ static irqreturn_t da7219_aad_irq_thread(int irq, void *data) da7219_aad->jack_inserted = false; /* Un-drive headphones/lineout */ - snd_soc_update_bits(codec, DA7219_HP_R_CTRL, + snd_soc_component_update_bits(component, DA7219_HP_R_CTRL, DA7219_HP_R_AMP_OE_MASK, 0); - snd_soc_update_bits(codec, DA7219_HP_L_CTRL, + snd_soc_component_update_bits(component, DA7219_HP_L_CTRL, DA7219_HP_L_AMP_OE_MASK, 0); /* Ensure button detection disabled */ - snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_1, + snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_1, DA7219_BUTTON_CONFIG_MASK, 0); /* Disable mic bias */ @@ -459,7 +459,7 @@ static irqreturn_t da7219_aad_irq_thread(int irq, void *data) */ static enum da7219_aad_micbias_pulse_lvl - da7219_aad_fw_micbias_pulse_lvl(struct snd_soc_codec *codec, u32 val) + da7219_aad_fw_micbias_pulse_lvl(struct snd_soc_component *component, u32 val) { switch (val) { case 2800: @@ -467,13 +467,13 @@ static enum da7219_aad_micbias_pulse_lvl case 2900: return DA7219_AAD_MICBIAS_PULSE_LVL_2_9V; default: - dev_warn(codec->dev, "Invalid micbias pulse level"); + dev_warn(component->dev, "Invalid micbias pulse level"); return DA7219_AAD_MICBIAS_PULSE_LVL_OFF; } } static enum da7219_aad_btn_cfg - da7219_aad_fw_btn_cfg(struct snd_soc_codec *codec, u32 val) + da7219_aad_fw_btn_cfg(struct snd_soc_component *component, u32 val) { switch (val) { case 2: @@ -491,13 +491,13 @@ static enum da7219_aad_btn_cfg case 500: return DA7219_AAD_BTN_CFG_500MS; default: - dev_warn(codec->dev, "Invalid button config"); + dev_warn(component->dev, "Invalid button config"); return DA7219_AAD_BTN_CFG_10MS; } } static enum da7219_aad_mic_det_thr - da7219_aad_fw_mic_det_thr(struct snd_soc_codec *codec, u32 val) + da7219_aad_fw_mic_det_thr(struct snd_soc_component *component, u32 val) { switch (val) { case 200: @@ -509,13 +509,13 @@ static enum da7219_aad_mic_det_thr case 1000: return DA7219_AAD_MIC_DET_THR_1000_OHMS; default: - dev_warn(codec->dev, "Invalid mic detect threshold"); + dev_warn(component->dev, "Invalid mic detect threshold"); return DA7219_AAD_MIC_DET_THR_500_OHMS; } } static enum da7219_aad_jack_ins_deb - da7219_aad_fw_jack_ins_deb(struct snd_soc_codec *codec, u32 val) + da7219_aad_fw_jack_ins_deb(struct snd_soc_component *component, u32 val) { switch (val) { case 5: @@ -535,13 +535,13 @@ static enum da7219_aad_jack_ins_deb case 1000: return DA7219_AAD_JACK_INS_DEB_1S; default: - dev_warn(codec->dev, "Invalid jack insert debounce"); + dev_warn(component->dev, "Invalid jack insert debounce"); return DA7219_AAD_JACK_INS_DEB_20MS; } } static enum da7219_aad_jack_det_rate - da7219_aad_fw_jack_det_rate(struct snd_soc_codec *codec, const char *str) + da7219_aad_fw_jack_det_rate(struct snd_soc_component *component, const char *str) { if (!strcmp(str, "32ms_64ms")) { return DA7219_AAD_JACK_DET_RATE_32_64MS; @@ -552,13 +552,13 @@ static enum da7219_aad_jack_det_rate } else if (!strcmp(str, "256ms_512ms")) { return DA7219_AAD_JACK_DET_RATE_256_512MS; } else { - dev_warn(codec->dev, "Invalid jack detect rate"); + dev_warn(component->dev, "Invalid jack detect rate"); return DA7219_AAD_JACK_DET_RATE_256_512MS; } } static enum da7219_aad_jack_rem_deb - da7219_aad_fw_jack_rem_deb(struct snd_soc_codec *codec, u32 val) + da7219_aad_fw_jack_rem_deb(struct snd_soc_component *component, u32 val) { switch (val) { case 1: @@ -570,13 +570,13 @@ static enum da7219_aad_jack_rem_deb case 20: return DA7219_AAD_JACK_REM_DEB_20MS; default: - dev_warn(codec->dev, "Invalid jack removal debounce"); + dev_warn(component->dev, "Invalid jack removal debounce"); return DA7219_AAD_JACK_REM_DEB_1MS; } } static enum da7219_aad_btn_avg - da7219_aad_fw_btn_avg(struct snd_soc_codec *codec, u32 val) + da7219_aad_fw_btn_avg(struct snd_soc_component *component, u32 val) { switch (val) { case 1: @@ -588,13 +588,13 @@ static enum da7219_aad_btn_avg case 8: return DA7219_AAD_BTN_AVG_8; default: - dev_warn(codec->dev, "Invalid button average value"); + dev_warn(component->dev, "Invalid button average value"); return DA7219_AAD_BTN_AVG_2; } } static enum da7219_aad_adc_1bit_rpt - da7219_aad_fw_adc_1bit_rpt(struct snd_soc_codec *codec, u32 val) + da7219_aad_fw_adc_1bit_rpt(struct snd_soc_component *component, u32 val) { switch (val) { case 1: @@ -606,14 +606,14 @@ static enum da7219_aad_adc_1bit_rpt case 8: return DA7219_AAD_ADC_1BIT_RPT_8; default: - dev_warn(codec->dev, "Invalid ADC 1-bit repeat value"); + dev_warn(component->dev, "Invalid ADC 1-bit repeat value"); return DA7219_AAD_ADC_1BIT_RPT_1; } } -static struct da7219_aad_pdata *da7219_aad_fw_to_pdata(struct snd_soc_codec *codec) +static struct da7219_aad_pdata *da7219_aad_fw_to_pdata(struct snd_soc_component *component) { - struct device *dev = codec->dev; + struct device *dev = component->dev; struct i2c_client *i2c = to_i2c_client(dev); struct fwnode_handle *aad_np; struct da7219_aad_pdata *aad_pdata; @@ -624,7 +624,7 @@ static struct da7219_aad_pdata *da7219_aad_fw_to_pdata(struct snd_soc_codec *cod if (!aad_np) return NULL; - aad_pdata = devm_kzalloc(codec->dev, sizeof(*aad_pdata), GFP_KERNEL); + aad_pdata = devm_kzalloc(dev, sizeof(*aad_pdata), GFP_KERNEL); if (!aad_pdata) return NULL; @@ -633,7 +633,7 @@ static struct da7219_aad_pdata *da7219_aad_fw_to_pdata(struct snd_soc_codec *cod if (fwnode_property_read_u32(aad_np, "dlg,micbias-pulse-lvl", &fw_val32) >= 0) aad_pdata->micbias_pulse_lvl = - da7219_aad_fw_micbias_pulse_lvl(codec, fw_val32); + da7219_aad_fw_micbias_pulse_lvl(component, fw_val32); else aad_pdata->micbias_pulse_lvl = DA7219_AAD_MICBIAS_PULSE_LVL_OFF; @@ -642,31 +642,31 @@ static struct da7219_aad_pdata *da7219_aad_fw_to_pdata(struct snd_soc_codec *cod aad_pdata->micbias_pulse_time = fw_val32; if (fwnode_property_read_u32(aad_np, "dlg,btn-cfg", &fw_val32) >= 0) - aad_pdata->btn_cfg = da7219_aad_fw_btn_cfg(codec, fw_val32); + aad_pdata->btn_cfg = da7219_aad_fw_btn_cfg(component, fw_val32); else aad_pdata->btn_cfg = DA7219_AAD_BTN_CFG_10MS; if (fwnode_property_read_u32(aad_np, "dlg,mic-det-thr", &fw_val32) >= 0) aad_pdata->mic_det_thr = - da7219_aad_fw_mic_det_thr(codec, fw_val32); + da7219_aad_fw_mic_det_thr(component, fw_val32); else aad_pdata->mic_det_thr = DA7219_AAD_MIC_DET_THR_500_OHMS; if (fwnode_property_read_u32(aad_np, "dlg,jack-ins-deb", &fw_val32) >= 0) aad_pdata->jack_ins_deb = - da7219_aad_fw_jack_ins_deb(codec, fw_val32); + da7219_aad_fw_jack_ins_deb(component, fw_val32); else aad_pdata->jack_ins_deb = DA7219_AAD_JACK_INS_DEB_20MS; if (!fwnode_property_read_string(aad_np, "dlg,jack-det-rate", &fw_str)) aad_pdata->jack_det_rate = - da7219_aad_fw_jack_det_rate(codec, fw_str); + da7219_aad_fw_jack_det_rate(component, fw_str); else aad_pdata->jack_det_rate = DA7219_AAD_JACK_DET_RATE_256_512MS; if (fwnode_property_read_u32(aad_np, "dlg,jack-rem-deb", &fw_val32) >= 0) aad_pdata->jack_rem_deb = - da7219_aad_fw_jack_rem_deb(codec, fw_val32); + da7219_aad_fw_jack_rem_deb(component, fw_val32); else aad_pdata->jack_rem_deb = DA7219_AAD_JACK_REM_DEB_1MS; @@ -691,22 +691,22 @@ static struct da7219_aad_pdata *da7219_aad_fw_to_pdata(struct snd_soc_codec *cod aad_pdata->c_mic_btn_thr = 0x3E; if (fwnode_property_read_u32(aad_np, "dlg,btn-avg", &fw_val32) >= 0) - aad_pdata->btn_avg = da7219_aad_fw_btn_avg(codec, fw_val32); + aad_pdata->btn_avg = da7219_aad_fw_btn_avg(component, fw_val32); else aad_pdata->btn_avg = DA7219_AAD_BTN_AVG_2; if (fwnode_property_read_u32(aad_np, "dlg,adc-1bit-rpt", &fw_val32) >= 0) aad_pdata->adc_1bit_rpt = - da7219_aad_fw_adc_1bit_rpt(codec, fw_val32); + da7219_aad_fw_adc_1bit_rpt(component, fw_val32); else aad_pdata->adc_1bit_rpt = DA7219_AAD_ADC_1BIT_RPT_1; return aad_pdata; } -static void da7219_aad_handle_pdata(struct snd_soc_codec *codec) +static void da7219_aad_handle_pdata(struct snd_soc_component *component) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); struct da7219_aad_priv *da7219_aad = da7219->aad; struct da7219_pdata *pdata = da7219->pdata; @@ -752,7 +752,7 @@ static void da7219_aad_handle_pdata(struct snd_soc_codec *codec) DA7219_MIC_DET_THRESH_SHIFT); mask |= DA7219_MIC_DET_THRESH_MASK; } - snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_1, mask, cfg); + snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_1, mask, cfg); cfg = 0; mask = 0; @@ -787,15 +787,15 @@ static void da7219_aad_handle_pdata(struct snd_soc_codec *codec) DA7219_JACKDET_REM_DEB_SHIFT); mask |= DA7219_JACKDET_REM_DEB_MASK; } - snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_2, mask, cfg); + snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_2, mask, cfg); - snd_soc_write(codec, DA7219_ACCDET_CONFIG_3, + snd_soc_component_write(component, DA7219_ACCDET_CONFIG_3, aad_pdata->a_d_btn_thr); - snd_soc_write(codec, DA7219_ACCDET_CONFIG_4, + snd_soc_component_write(component, DA7219_ACCDET_CONFIG_4, aad_pdata->d_b_btn_thr); - snd_soc_write(codec, DA7219_ACCDET_CONFIG_5, + snd_soc_component_write(component, DA7219_ACCDET_CONFIG_5, aad_pdata->b_c_btn_thr); - snd_soc_write(codec, DA7219_ACCDET_CONFIG_6, + snd_soc_component_write(component, DA7219_ACCDET_CONFIG_6, aad_pdata->c_mic_btn_thr); cfg = 0; @@ -818,7 +818,7 @@ static void da7219_aad_handle_pdata(struct snd_soc_codec *codec) DA7219_ADC_1_BIT_REPEAT_SHIFT); mask |= DA7219_ADC_1_BIT_REPEAT_MASK; } - snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_7, mask, cfg); + snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_7, mask, cfg); } } @@ -827,16 +827,16 @@ static void da7219_aad_handle_pdata(struct snd_soc_codec *codec) * Suspend/Resume */ -void da7219_aad_suspend(struct snd_soc_codec *codec) +void da7219_aad_suspend(struct snd_soc_component *component) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); struct da7219_aad_priv *da7219_aad = da7219->aad; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); u8 micbias_ctrl; if (da7219_aad->jack) { /* Disable jack detection during suspend */ - snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_1, + snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_1, DA7219_ACCDET_EN_MASK, 0); /* @@ -846,7 +846,7 @@ void da7219_aad_suspend(struct snd_soc_codec *codec) * suspend then this will be dealt with through the IRQ handler. */ if (da7219_aad->jack_inserted) { - micbias_ctrl = snd_soc_read(codec, DA7219_MICBIAS_CTRL); + micbias_ctrl = snd_soc_component_read32(component, DA7219_MICBIAS_CTRL); if (micbias_ctrl & DA7219_MICBIAS1_EN_MASK) { snd_soc_dapm_disable_pin(dapm, "Mic Bias"); snd_soc_dapm_sync(dapm); @@ -856,11 +856,11 @@ void da7219_aad_suspend(struct snd_soc_codec *codec) } } -void da7219_aad_resume(struct snd_soc_codec *codec) +void da7219_aad_resume(struct snd_soc_component *component) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); struct da7219_aad_priv *da7219_aad = da7219->aad; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); if (da7219_aad->jack) { /* Re-enable micbias if previously enabled for 4-pole jack */ @@ -872,7 +872,7 @@ void da7219_aad_resume(struct snd_soc_codec *codec) } /* Re-enable jack detection */ - snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_1, + snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_1, DA7219_ACCDET_EN_MASK, DA7219_ACCDET_EN_MASK); } @@ -883,28 +883,28 @@ void da7219_aad_resume(struct snd_soc_codec *codec) * Init/Exit */ -int da7219_aad_init(struct snd_soc_codec *codec) +int da7219_aad_init(struct snd_soc_component *component) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); struct da7219_aad_priv *da7219_aad; u8 mask[DA7219_AAD_IRQ_REG_MAX]; int ret; - da7219_aad = devm_kzalloc(codec->dev, sizeof(*da7219_aad), GFP_KERNEL); + da7219_aad = devm_kzalloc(component->dev, sizeof(*da7219_aad), GFP_KERNEL); if (!da7219_aad) return -ENOMEM; da7219->aad = da7219_aad; - da7219_aad->codec = codec; + da7219_aad->component = component; /* Handle any DT/ACPI/platform data */ if (da7219->pdata && !da7219->pdata->aad_pdata) - da7219->pdata->aad_pdata = da7219_aad_fw_to_pdata(codec); + da7219->pdata->aad_pdata = da7219_aad_fw_to_pdata(component); - da7219_aad_handle_pdata(codec); + da7219_aad_handle_pdata(component); /* Disable button detection */ - snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_1, + snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_1, DA7219_BUTTON_CONFIG_MASK, 0); INIT_WORK(&da7219_aad->btn_det_work, da7219_aad_btn_det_work); @@ -915,7 +915,7 @@ int da7219_aad_init(struct snd_soc_codec *codec) IRQF_TRIGGER_LOW | IRQF_ONESHOT, "da7219-aad", da7219_aad); if (ret) { - dev_err(codec->dev, "Failed to request IRQ: %d\n", ret); + dev_err(component->dev, "Failed to request IRQ: %d\n", ret); return ret; } @@ -928,9 +928,9 @@ int da7219_aad_init(struct snd_soc_codec *codec) } EXPORT_SYMBOL_GPL(da7219_aad_init); -void da7219_aad_exit(struct snd_soc_codec *codec) +void da7219_aad_exit(struct snd_soc_component *component) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); struct da7219_aad_priv *da7219_aad = da7219->aad; u8 mask[DA7219_AAD_IRQ_REG_MAX]; diff --git a/sound/soc/codecs/da7219-aad.h b/sound/soc/codecs/da7219-aad.h index 117a3d7ccd31..b9c4a27e8e61 100644 --- a/sound/soc/codecs/da7219-aad.h +++ b/sound/soc/codecs/da7219-aad.h @@ -189,7 +189,7 @@ enum da7219_aad_event_regs { /* Private data */ struct da7219_aad_priv { - struct snd_soc_codec *codec; + struct snd_soc_component *component; int irq; u8 micbias_pulse_lvl; @@ -206,14 +206,14 @@ struct da7219_aad_priv { }; /* AAD control */ -void da7219_aad_jack_det(struct snd_soc_codec *codec, struct snd_soc_jack *jack); +void da7219_aad_jack_det(struct snd_soc_component *component, struct snd_soc_jack *jack); /* Suspend/Resume */ -void da7219_aad_suspend(struct snd_soc_codec *codec); -void da7219_aad_resume(struct snd_soc_codec *codec); +void da7219_aad_suspend(struct snd_soc_component *component); +void da7219_aad_resume(struct snd_soc_component *component); /* Init/Exit */ -int da7219_aad_init(struct snd_soc_codec *codec); -void da7219_aad_exit(struct snd_soc_codec *codec); +int da7219_aad_init(struct snd_soc_component *component); +void da7219_aad_exit(struct snd_soc_component *component); #endif /* __DA7219_AAD_H */ diff --git a/sound/soc/codecs/da7219.c b/sound/soc/codecs/da7219.c index 6f088536df32..5e043d082f4b 100644 --- a/sound/soc/codecs/da7219.c +++ b/sound/soc/codecs/da7219.c @@ -256,8 +256,8 @@ static const struct soc_enum da7219_cp_track_mode = static int da7219_volsw_locked_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); int ret; mutex_lock(&da7219->ctrl_lock); @@ -270,8 +270,8 @@ static int da7219_volsw_locked_get(struct snd_kcontrol *kcontrol, static int da7219_volsw_locked_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); int ret; mutex_lock(&da7219->ctrl_lock); @@ -284,8 +284,8 @@ static int da7219_volsw_locked_put(struct snd_kcontrol *kcontrol, static int da7219_enum_locked_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); int ret; mutex_lock(&da7219->ctrl_lock); @@ -298,8 +298,8 @@ static int da7219_enum_locked_get(struct snd_kcontrol *kcontrol, static int da7219_enum_locked_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); int ret; mutex_lock(&da7219->ctrl_lock); @@ -310,55 +310,55 @@ static int da7219_enum_locked_put(struct snd_kcontrol *kcontrol, } /* ALC */ -static void da7219_alc_calib(struct snd_soc_codec *codec) +static void da7219_alc_calib(struct snd_soc_component *component) { u8 mic_ctrl, mixin_ctrl, adc_ctrl, calib_ctrl; /* Save current state of mic control register */ - mic_ctrl = snd_soc_read(codec, DA7219_MIC_1_CTRL); + mic_ctrl = snd_soc_component_read32(component, DA7219_MIC_1_CTRL); /* Save current state of input mixer control register */ - mixin_ctrl = snd_soc_read(codec, DA7219_MIXIN_L_CTRL); + mixin_ctrl = snd_soc_component_read32(component, DA7219_MIXIN_L_CTRL); /* Save current state of input ADC control register */ - adc_ctrl = snd_soc_read(codec, DA7219_ADC_L_CTRL); + adc_ctrl = snd_soc_component_read32(component, DA7219_ADC_L_CTRL); /* Enable then Mute MIC PGAs */ - snd_soc_update_bits(codec, DA7219_MIC_1_CTRL, DA7219_MIC_1_AMP_EN_MASK, + snd_soc_component_update_bits(component, DA7219_MIC_1_CTRL, DA7219_MIC_1_AMP_EN_MASK, DA7219_MIC_1_AMP_EN_MASK); - snd_soc_update_bits(codec, DA7219_MIC_1_CTRL, + snd_soc_component_update_bits(component, DA7219_MIC_1_CTRL, DA7219_MIC_1_AMP_MUTE_EN_MASK, DA7219_MIC_1_AMP_MUTE_EN_MASK); /* Enable input mixers unmuted */ - snd_soc_update_bits(codec, DA7219_MIXIN_L_CTRL, + snd_soc_component_update_bits(component, DA7219_MIXIN_L_CTRL, DA7219_MIXIN_L_AMP_EN_MASK | DA7219_MIXIN_L_AMP_MUTE_EN_MASK, DA7219_MIXIN_L_AMP_EN_MASK); /* Enable input filters unmuted */ - snd_soc_update_bits(codec, DA7219_ADC_L_CTRL, + snd_soc_component_update_bits(component, DA7219_ADC_L_CTRL, DA7219_ADC_L_MUTE_EN_MASK | DA7219_ADC_L_EN_MASK, DA7219_ADC_L_EN_MASK); /* Perform auto calibration */ - snd_soc_update_bits(codec, DA7219_ALC_CTRL1, + snd_soc_component_update_bits(component, DA7219_ALC_CTRL1, DA7219_ALC_AUTO_CALIB_EN_MASK, DA7219_ALC_AUTO_CALIB_EN_MASK); do { - calib_ctrl = snd_soc_read(codec, DA7219_ALC_CTRL1); + calib_ctrl = snd_soc_component_read32(component, DA7219_ALC_CTRL1); } while (calib_ctrl & DA7219_ALC_AUTO_CALIB_EN_MASK); /* If auto calibration fails, disable DC offset, hybrid ALC */ if (calib_ctrl & DA7219_ALC_CALIB_OVERFLOW_MASK) { - dev_warn(codec->dev, + dev_warn(component->dev, "ALC auto calibration failed with overflow\n"); - snd_soc_update_bits(codec, DA7219_ALC_CTRL1, + snd_soc_component_update_bits(component, DA7219_ALC_CTRL1, DA7219_ALC_OFFSET_EN_MASK | DA7219_ALC_SYNC_MODE_MASK, 0); } else { /* Enable DC offset cancellation, hybrid mode */ - snd_soc_update_bits(codec, DA7219_ALC_CTRL1, + snd_soc_component_update_bits(component, DA7219_ALC_CTRL1, DA7219_ALC_OFFSET_EN_MASK | DA7219_ALC_SYNC_MODE_MASK, DA7219_ALC_OFFSET_EN_MASK | @@ -366,20 +366,20 @@ static void da7219_alc_calib(struct snd_soc_codec *codec) } /* Restore input filter control register to original state */ - snd_soc_write(codec, DA7219_ADC_L_CTRL, adc_ctrl); + snd_soc_component_write(component, DA7219_ADC_L_CTRL, adc_ctrl); /* Restore input mixer control registers to original state */ - snd_soc_write(codec, DA7219_MIXIN_L_CTRL, mixin_ctrl); + snd_soc_component_write(component, DA7219_MIXIN_L_CTRL, mixin_ctrl); /* Restore MIC control registers to original states */ - snd_soc_write(codec, DA7219_MIC_1_CTRL, mic_ctrl); + snd_soc_component_write(component, DA7219_MIC_1_CTRL, mic_ctrl); } static int da7219_mixin_gain_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); int ret; ret = snd_soc_put_volsw(kcontrol, ucontrol); @@ -389,7 +389,7 @@ static int da7219_mixin_gain_put(struct snd_kcontrol *kcontrol, * make sure calibrated offsets are updated. */ if ((ret == 1) && (da7219->alc_en)) - da7219_alc_calib(codec); + da7219_alc_calib(component); return ret; } @@ -397,13 +397,13 @@ static int da7219_mixin_gain_put(struct snd_kcontrol *kcontrol, static int da7219_alc_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); /* Force ALC offset calibration if enabling ALC */ if ((ucontrol->value.integer.value[0]) && (!da7219->alc_en)) { - da7219_alc_calib(codec); + da7219_alc_calib(component); da7219->alc_en = true; } else { da7219->alc_en = false; @@ -416,8 +416,8 @@ static int da7219_alc_sw_put(struct snd_kcontrol *kcontrol, static int da7219_tonegen_freq_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mixer_ctrl = (struct soc_mixer_control *) kcontrol->private_value; unsigned int reg = mixer_ctrl->reg; @@ -443,8 +443,8 @@ static int da7219_tonegen_freq_get(struct snd_kcontrol *kcontrol, static int da7219_tonegen_freq_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mixer_ctrl = (struct soc_mixer_control *) kcontrol->private_value; unsigned int reg = mixer_ctrl->reg; @@ -769,8 +769,8 @@ static const struct snd_kcontrol_new da7219_st_out_filtr_mix_controls[] = { static int da7219_dai_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 da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); u8 pll_ctrl, pll_status; int i = 0; bool srm_lock = false; @@ -779,22 +779,22 @@ static int da7219_dai_event(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_PRE_PMU: if (da7219->master) /* Enable DAI clks for master mode */ - snd_soc_update_bits(codec, DA7219_DAI_CLK_MODE, + snd_soc_component_update_bits(component, DA7219_DAI_CLK_MODE, DA7219_DAI_CLK_EN_MASK, DA7219_DAI_CLK_EN_MASK); /* PC synchronised to DAI */ - snd_soc_update_bits(codec, DA7219_PC_COUNT, + snd_soc_component_update_bits(component, DA7219_PC_COUNT, DA7219_PC_FREERUN_MASK, 0); /* Slave mode, if SRM not enabled no need for status checks */ - pll_ctrl = snd_soc_read(codec, DA7219_PLL_CTRL); + pll_ctrl = snd_soc_component_read32(component, DA7219_PLL_CTRL); if ((pll_ctrl & DA7219_PLL_MODE_MASK) != DA7219_PLL_MODE_SRM) return 0; /* Check SRM has locked */ do { - pll_status = snd_soc_read(codec, DA7219_PLL_SRM_STS); + pll_status = snd_soc_component_read32(component, DA7219_PLL_SRM_STS); if (pll_status & DA7219_PLL_SRM_STS_SRM_LOCK) { srm_lock = true; } else { @@ -804,18 +804,18 @@ static int da7219_dai_event(struct snd_soc_dapm_widget *w, } while ((i < DA7219_SRM_CHECK_RETRIES) & (!srm_lock)); if (!srm_lock) - dev_warn(codec->dev, "SRM failed to lock\n"); + dev_warn(component->dev, "SRM failed to lock\n"); return 0; case SND_SOC_DAPM_POST_PMD: /* PC free-running */ - snd_soc_update_bits(codec, DA7219_PC_COUNT, + snd_soc_component_update_bits(component, DA7219_PC_COUNT, DA7219_PC_FREERUN_MASK, DA7219_PC_FREERUN_MASK); /* Disable DAI clks if in master mode */ if (da7219->master) - snd_soc_update_bits(codec, DA7219_DAI_CLK_MODE, + snd_soc_component_update_bits(component, DA7219_DAI_CLK_MODE, DA7219_DAI_CLK_EN_MASK, 0); return 0; default: @@ -841,7 +841,7 @@ static int da7219_settling_event(struct snd_soc_dapm_widget *w, static int da7219_mixout_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); u8 hp_ctrl, min_gain_mask; switch (w->reg) { @@ -860,7 +860,7 @@ static int da7219_mixout_event(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_PRE_PMD: /* Enable minimum gain on HP to avoid pops */ - snd_soc_update_bits(codec, hp_ctrl, min_gain_mask, + snd_soc_component_update_bits(component, hp_ctrl, min_gain_mask, min_gain_mask); msleep(DA7219_MIN_GAIN_DELAY); @@ -868,7 +868,7 @@ static int da7219_mixout_event(struct snd_soc_dapm_widget *w, break; case SND_SOC_DAPM_POST_PMU: /* Remove minimum gain on HP */ - snd_soc_update_bits(codec, hp_ctrl, min_gain_mask, 0); + snd_soc_component_update_bits(component, hp_ctrl, min_gain_mask, 0); break; } @@ -879,22 +879,22 @@ static int da7219_mixout_event(struct snd_soc_dapm_widget *w, static int da7219_gain_ramp_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 da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMD: /* Ensure nominal gain ramping for DAPM sequence */ da7219->gain_ramp_ctrl = - snd_soc_read(codec, DA7219_GAIN_RAMP_CTRL); - snd_soc_write(codec, DA7219_GAIN_RAMP_CTRL, + snd_soc_component_read32(component, DA7219_GAIN_RAMP_CTRL); + snd_soc_component_write(component, DA7219_GAIN_RAMP_CTRL, DA7219_GAIN_RAMP_RATE_NOMINAL); break; case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMD: /* Restore previous gain ramp settings */ - snd_soc_write(codec, DA7219_GAIN_RAMP_CTRL, + snd_soc_component_write(component, DA7219_GAIN_RAMP_CTRL, da7219->gain_ramp_ctrl); break; } @@ -1116,8 +1116,8 @@ static const struct snd_soc_dapm_route da7219_audio_map[] = { static int da7219_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 da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); int ret = 0; if ((da7219->clk_src == clk_id) && (da7219->mclk_rate == freq)) @@ -1133,12 +1133,12 @@ static int da7219_set_dai_sysclk(struct snd_soc_dai *codec_dai, switch (clk_id) { case DA7219_CLKSRC_MCLK_SQR: - snd_soc_update_bits(codec, DA7219_PLL_CTRL, + snd_soc_component_update_bits(component, DA7219_PLL_CTRL, DA7219_PLL_MCLK_SQR_EN_MASK, DA7219_PLL_MCLK_SQR_EN_MASK); break; case DA7219_CLKSRC_MCLK: - snd_soc_update_bits(codec, DA7219_PLL_CTRL, + snd_soc_component_update_bits(component, DA7219_PLL_CTRL, DA7219_PLL_MCLK_SQR_EN_MASK, 0); break; default: @@ -1167,9 +1167,9 @@ static int da7219_set_dai_sysclk(struct snd_soc_dai *codec_dai, return 0; } -int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout) +int da7219_set_pll(struct snd_soc_component *component, int source, unsigned int fout) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); u8 pll_ctrl, indiv_bits, indiv; u8 pll_frac_top, pll_frac_bot, pll_integer; @@ -1178,7 +1178,7 @@ int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout) /* Verify 2MHz - 54MHz MCLK provided, and set input divider */ if (da7219->mclk_rate < 2000000) { - dev_err(codec->dev, "PLL input clock %d below valid range\n", + dev_err(component->dev, "PLL input clock %d below valid range\n", da7219->mclk_rate); return -EINVAL; } else if (da7219->mclk_rate <= 4500000) { @@ -1197,7 +1197,7 @@ int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout) indiv_bits = DA7219_PLL_INDIV_36_TO_54_MHZ; indiv = DA7219_PLL_INDIV_36_TO_54_MHZ_VAL; } else { - dev_err(codec->dev, "PLL input clock %d above valid range\n", + dev_err(component->dev, "PLL input clock %d above valid range\n", da7219->mclk_rate); return -EINVAL; } @@ -1208,7 +1208,7 @@ int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout) switch (source) { case DA7219_SYSCLK_MCLK: pll_ctrl |= DA7219_PLL_MODE_BYPASS; - snd_soc_update_bits(codec, DA7219_PLL_CTRL, + snd_soc_component_update_bits(component, DA7219_PLL_CTRL, DA7219_PLL_INDIV_MASK | DA7219_PLL_MODE_MASK, pll_ctrl); return 0; @@ -1219,7 +1219,7 @@ int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout) pll_ctrl |= DA7219_PLL_MODE_SRM; break; default: - dev_err(codec->dev, "Invalid PLL config\n"); + dev_err(component->dev, "Invalid PLL config\n"); return -EINVAL; } @@ -1231,10 +1231,10 @@ int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout) pll_frac_bot = (frac_div) & DA7219_BYTE_MASK; /* Write PLL config & dividers */ - snd_soc_write(codec, DA7219_PLL_FRAC_TOP, pll_frac_top); - snd_soc_write(codec, DA7219_PLL_FRAC_BOT, pll_frac_bot); - snd_soc_write(codec, DA7219_PLL_INTEGER, pll_integer); - snd_soc_update_bits(codec, DA7219_PLL_CTRL, + snd_soc_component_write(component, DA7219_PLL_FRAC_TOP, pll_frac_top); + snd_soc_component_write(component, DA7219_PLL_FRAC_BOT, pll_frac_bot); + snd_soc_component_write(component, DA7219_PLL_INTEGER, pll_integer); + snd_soc_component_update_bits(component, DA7219_PLL_CTRL, DA7219_PLL_INDIV_MASK | DA7219_PLL_MODE_MASK, pll_ctrl); @@ -1244,12 +1244,12 @@ int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout) static int da7219_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int fref, unsigned int fout) { - struct snd_soc_codec *codec = codec_dai->codec; - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); int ret; mutex_lock(&da7219->pll_lock); - ret = da7219_set_pll(codec, source, fout); + ret = da7219_set_pll(component, source, fout); mutex_unlock(&da7219->pll_lock); return ret; @@ -1257,8 +1257,8 @@ static int da7219_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, static int da7219_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); u8 dai_clk_mode = 0, dai_ctrl = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -1335,11 +1335,11 @@ static int da7219_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) /* By default 64 BCLKs per WCLK is supported */ dai_clk_mode |= DA7219_DAI_BCLKS_PER_WCLK_64; - snd_soc_update_bits(codec, DA7219_DAI_CLK_MODE, + snd_soc_component_update_bits(component, DA7219_DAI_CLK_MODE, DA7219_DAI_BCLKS_PER_WCLK_MASK | DA7219_DAI_CLK_POL_MASK | DA7219_DAI_WCLK_POL_MASK, dai_clk_mode); - snd_soc_update_bits(codec, DA7219_DAI_CTRL, DA7219_DAI_FORMAT_MASK, + snd_soc_component_update_bits(component, DA7219_DAI_CTRL, DA7219_DAI_FORMAT_MASK, dai_ctrl); return 0; @@ -1349,18 +1349,18 @@ static int da7219_set_dai_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 da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); u8 dai_bclks_per_wclk; u16 offset; u32 frame_size; /* No channels enabled so disable TDM, revert to 64-bit frames */ if (!tx_mask) { - snd_soc_update_bits(codec, DA7219_DAI_TDM_CTRL, + snd_soc_component_update_bits(component, DA7219_DAI_TDM_CTRL, DA7219_DAI_TDM_CH_EN_MASK | DA7219_DAI_TDM_MODE_EN_MASK, 0); - snd_soc_update_bits(codec, DA7219_DAI_CLK_MODE, + snd_soc_component_update_bits(component, DA7219_DAI_CLK_MODE, DA7219_DAI_BCLKS_PER_WCLK_MASK, DA7219_DAI_BCLKS_PER_WCLK_64); return 0; @@ -1368,14 +1368,14 @@ static int da7219_set_dai_tdm_slot(struct snd_soc_dai *dai, /* Check we have valid slots */ if (fls(tx_mask) > DA7219_DAI_TDM_MAX_SLOTS) { - dev_err(codec->dev, "Invalid number of slots, max = %d\n", + dev_err(component->dev, "Invalid number of slots, max = %d\n", DA7219_DAI_TDM_MAX_SLOTS); return -EINVAL; } /* Check we have a valid offset given */ if (rx_mask > DA7219_DAI_OFFSET_MAX) { - dev_err(codec->dev, "Invalid slot offset, max = %d\n", + dev_err(component->dev, "Invalid slot offset, max = %d\n", DA7219_DAI_OFFSET_MAX); return -EINVAL; } @@ -1396,11 +1396,11 @@ static int da7219_set_dai_tdm_slot(struct snd_soc_dai *dai, dai_bclks_per_wclk = DA7219_DAI_BCLKS_PER_WCLK_256; break; default: - dev_err(codec->dev, "Invalid frame size %d\n", frame_size); + dev_err(component->dev, "Invalid frame size %d\n", frame_size); return -EINVAL; } - snd_soc_update_bits(codec, DA7219_DAI_CLK_MODE, + snd_soc_component_update_bits(component, DA7219_DAI_CLK_MODE, DA7219_DAI_BCLKS_PER_WCLK_MASK, dai_bclks_per_wclk); @@ -1408,7 +1408,7 @@ static int da7219_set_dai_tdm_slot(struct snd_soc_dai *dai, regmap_bulk_write(da7219->regmap, DA7219_DAI_OFFSET_LOWER, &offset, sizeof(offset)); - snd_soc_update_bits(codec, DA7219_DAI_TDM_CTRL, + snd_soc_component_update_bits(component, DA7219_DAI_TDM_CTRL, DA7219_DAI_TDM_CH_EN_MASK | DA7219_DAI_TDM_MODE_EN_MASK, (tx_mask << DA7219_DAI_TDM_CH_EN_SHIFT) | @@ -1421,7 +1421,7 @@ static int da7219_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 snd_soc_component *component = dai->component; u8 dai_ctrl = 0, fs; unsigned int channels; @@ -1444,7 +1444,7 @@ static int da7219_hw_params(struct snd_pcm_substream *substream, channels = params_channels(params); if ((channels < 1) || (channels > DA7219_DAI_CH_NUM_MAX)) { - dev_err(codec->dev, + dev_err(component->dev, "Invalid number of channels, only 1 to %d supported\n", DA7219_DAI_CH_NUM_MAX); return -EINVAL; @@ -1489,11 +1489,11 @@ static int da7219_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, DA7219_DAI_CTRL, + snd_soc_component_update_bits(component, DA7219_DAI_CTRL, DA7219_DAI_WORD_LENGTH_MASK | DA7219_DAI_CH_NUM_MASK, dai_ctrl); - snd_soc_write(codec, DA7219_SR, fs); + snd_soc_component_write(component, DA7219_SR, fs); return 0; } @@ -1585,9 +1585,9 @@ static enum da7219_mic_amp_in_sel } } -static struct da7219_pdata *da7219_fw_to_pdata(struct snd_soc_codec *codec) +static struct da7219_pdata *da7219_fw_to_pdata(struct snd_soc_component *component) { - struct device *dev = codec->dev; + struct device *dev = component->dev; struct da7219_pdata *pdata; const char *of_str; u32 of_val32; @@ -1616,10 +1616,10 @@ static struct da7219_pdata *da7219_fw_to_pdata(struct snd_soc_codec *codec) * Codec driver functions */ -static int da7219_set_bias_level(struct snd_soc_codec *codec, +static int da7219_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); int ret; switch (level) { @@ -1627,11 +1627,11 @@ static int da7219_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_PREPARE: /* Enable MCLK for transition to ON state */ - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) { if (da7219->mclk) { ret = clk_prepare_enable(da7219->mclk); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to enable mclk\n"); return ret; } @@ -1640,13 +1640,13 @@ static int da7219_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) /* Master bias */ - snd_soc_update_bits(codec, DA7219_REFERENCES, + snd_soc_component_update_bits(component, DA7219_REFERENCES, DA7219_BIAS_EN_MASK, DA7219_BIAS_EN_MASK); - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_PREPARE) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_PREPARE) { /* Remove MCLK */ if (da7219->mclk) clk_disable_unprepare(da7219->mclk); @@ -1655,7 +1655,7 @@ static int da7219_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_OFF: /* Only disable master bias if we're not a wake-up source */ if (!da7219->wakeup_source) - snd_soc_update_bits(codec, DA7219_REFERENCES, + snd_soc_component_update_bits(component, DA7219_REFERENCES, DA7219_BIAS_EN_MASK, 0); break; @@ -1670,9 +1670,9 @@ static const char *da7219_supply_names[DA7219_NUM_SUPPLIES] = { [DA7219_SUPPLY_VDDIO] = "VDDIO", }; -static int da7219_handle_supplies(struct snd_soc_codec *codec) +static int da7219_handle_supplies(struct snd_soc_component *component) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); struct regulator *vddio; u8 io_voltage_lvl = DA7219_IO_VOLTAGE_LEVEL_2_5V_3_6V; int i, ret; @@ -1681,10 +1681,10 @@ static int da7219_handle_supplies(struct snd_soc_codec *codec) for (i = 0; i < DA7219_NUM_SUPPLIES; ++i) da7219->supplies[i].supply = da7219_supply_names[i]; - ret = devm_regulator_bulk_get(codec->dev, DA7219_NUM_SUPPLIES, + ret = devm_regulator_bulk_get(component->dev, DA7219_NUM_SUPPLIES, da7219->supplies); if (ret) { - dev_err(codec->dev, "Failed to get supplies"); + dev_err(component->dev, "Failed to get supplies"); return ret; } @@ -1692,29 +1692,29 @@ static int da7219_handle_supplies(struct snd_soc_codec *codec) vddio = da7219->supplies[DA7219_SUPPLY_VDDIO].consumer; ret = regulator_get_voltage(vddio); if (ret < 1200000) - dev_warn(codec->dev, "Invalid VDDIO voltage\n"); + dev_warn(component->dev, "Invalid VDDIO voltage\n"); else if (ret < 2800000) io_voltage_lvl = DA7219_IO_VOLTAGE_LEVEL_1_2V_2_8V; /* Enable main supplies */ ret = regulator_bulk_enable(DA7219_NUM_SUPPLIES, da7219->supplies); if (ret) { - dev_err(codec->dev, "Failed to enable supplies"); + dev_err(component->dev, "Failed to enable supplies"); return ret; } /* Ensure device in active mode */ - snd_soc_write(codec, DA7219_SYSTEM_ACTIVE, DA7219_SYSTEM_ACTIVE_MASK); + snd_soc_component_write(component, DA7219_SYSTEM_ACTIVE, DA7219_SYSTEM_ACTIVE_MASK); /* Update IO voltage level range */ - snd_soc_write(codec, DA7219_IO_CTRL, io_voltage_lvl); + snd_soc_component_write(component, DA7219_IO_CTRL, io_voltage_lvl); return 0; } -static void da7219_handle_pdata(struct snd_soc_codec *codec) +static void da7219_handle_pdata(struct snd_soc_component *component) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); struct da7219_pdata *pdata = da7219->pdata; if (pdata) { @@ -1735,14 +1735,14 @@ static void da7219_handle_pdata(struct snd_soc_codec *codec) break; } - snd_soc_write(codec, DA7219_MICBIAS_CTRL, micbias_lvl); + snd_soc_component_write(component, DA7219_MICBIAS_CTRL, micbias_lvl); /* Mic */ switch (pdata->mic_amp_in_sel) { case DA7219_MIC_AMP_IN_SEL_DIFF: case DA7219_MIC_AMP_IN_SEL_SE_P: case DA7219_MIC_AMP_IN_SEL_SE_N: - snd_soc_write(codec, DA7219_MIC_1_SELECT, + snd_soc_component_write(component, DA7219_MIC_1_SELECT, pdata->mic_amp_in_sel); break; } @@ -1753,9 +1753,9 @@ static struct reg_sequence da7219_rev_aa_patch[] = { { DA7219_REFERENCES, 0x08 }, }; -static int da7219_probe(struct snd_soc_codec *codec) +static int da7219_probe(struct snd_soc_component *component) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); unsigned int rev; int ret; @@ -1763,13 +1763,13 @@ static int da7219_probe(struct snd_soc_codec *codec) mutex_init(&da7219->pll_lock); /* Regulator configuration */ - ret = da7219_handle_supplies(codec); + ret = da7219_handle_supplies(component); if (ret) return ret; ret = regmap_read(da7219->regmap, DA7219_CHIP_REVISION, &rev); if (ret) { - dev_err(codec->dev, "Failed to read chip revision: %d\n", ret); + dev_err(component->dev, "Failed to read chip revision: %d\n", ret); goto err_disable_reg; } @@ -1778,7 +1778,7 @@ static int da7219_probe(struct snd_soc_codec *codec) ret = regmap_register_patch(da7219->regmap, da7219_rev_aa_patch, ARRAY_SIZE(da7219_rev_aa_patch)); if (ret) { - dev_err(codec->dev, "Failed to register AA patch: %d\n", + dev_err(component->dev, "Failed to register AA patch: %d\n", ret); goto err_disable_reg; } @@ -1788,14 +1788,14 @@ static int da7219_probe(struct snd_soc_codec *codec) } /* Handle DT/ACPI/Platform data */ - da7219->pdata = dev_get_platdata(codec->dev); + da7219->pdata = dev_get_platdata(component->dev); if (!da7219->pdata) - da7219->pdata = da7219_fw_to_pdata(codec); + da7219->pdata = da7219_fw_to_pdata(component); - da7219_handle_pdata(codec); + da7219_handle_pdata(component); /* Check if MCLK provided */ - da7219->mclk = devm_clk_get(codec->dev, "mclk"); + da7219->mclk = devm_clk_get(component->dev, "mclk"); if (IS_ERR(da7219->mclk)) { if (PTR_ERR(da7219->mclk) != -ENOENT) { ret = PTR_ERR(da7219->mclk); @@ -1806,39 +1806,39 @@ static int da7219_probe(struct snd_soc_codec *codec) } /* Default PC counter to free-running */ - snd_soc_update_bits(codec, DA7219_PC_COUNT, DA7219_PC_FREERUN_MASK, + snd_soc_component_update_bits(component, DA7219_PC_COUNT, DA7219_PC_FREERUN_MASK, DA7219_PC_FREERUN_MASK); /* Default gain ramping */ - snd_soc_update_bits(codec, DA7219_MIXIN_L_CTRL, + snd_soc_component_update_bits(component, DA7219_MIXIN_L_CTRL, DA7219_MIXIN_L_AMP_RAMP_EN_MASK, DA7219_MIXIN_L_AMP_RAMP_EN_MASK); - snd_soc_update_bits(codec, DA7219_ADC_L_CTRL, DA7219_ADC_L_RAMP_EN_MASK, + snd_soc_component_update_bits(component, DA7219_ADC_L_CTRL, DA7219_ADC_L_RAMP_EN_MASK, DA7219_ADC_L_RAMP_EN_MASK); - snd_soc_update_bits(codec, DA7219_DAC_L_CTRL, DA7219_DAC_L_RAMP_EN_MASK, + snd_soc_component_update_bits(component, DA7219_DAC_L_CTRL, DA7219_DAC_L_RAMP_EN_MASK, DA7219_DAC_L_RAMP_EN_MASK); - snd_soc_update_bits(codec, DA7219_DAC_R_CTRL, DA7219_DAC_R_RAMP_EN_MASK, + snd_soc_component_update_bits(component, DA7219_DAC_R_CTRL, DA7219_DAC_R_RAMP_EN_MASK, DA7219_DAC_R_RAMP_EN_MASK); - snd_soc_update_bits(codec, DA7219_HP_L_CTRL, + snd_soc_component_update_bits(component, DA7219_HP_L_CTRL, DA7219_HP_L_AMP_RAMP_EN_MASK, DA7219_HP_L_AMP_RAMP_EN_MASK); - snd_soc_update_bits(codec, DA7219_HP_R_CTRL, + snd_soc_component_update_bits(component, DA7219_HP_R_CTRL, DA7219_HP_R_AMP_RAMP_EN_MASK, DA7219_HP_R_AMP_RAMP_EN_MASK); /* Default minimum gain on HP to avoid pops during DAPM sequencing */ - snd_soc_update_bits(codec, DA7219_HP_L_CTRL, + snd_soc_component_update_bits(component, DA7219_HP_L_CTRL, DA7219_HP_L_AMP_MIN_GAIN_EN_MASK, DA7219_HP_L_AMP_MIN_GAIN_EN_MASK); - snd_soc_update_bits(codec, DA7219_HP_R_CTRL, + snd_soc_component_update_bits(component, DA7219_HP_R_CTRL, DA7219_HP_R_AMP_MIN_GAIN_EN_MASK, DA7219_HP_R_AMP_MIN_GAIN_EN_MASK); /* Default infinite tone gen, start/stop by Kcontrol */ - snd_soc_write(codec, DA7219_TONE_GEN_CYCLES, DA7219_BEEP_CYCLES_MASK); + snd_soc_component_write(component, DA7219_TONE_GEN_CYCLES, DA7219_BEEP_CYCLES_MASK); /* Initialise AAD block */ - ret = da7219_aad_init(codec); + ret = da7219_aad_init(component); if (ret) goto err_disable_reg; @@ -1850,39 +1850,39 @@ err_disable_reg: return ret; } -static int da7219_remove(struct snd_soc_codec *codec) +static void da7219_remove(struct snd_soc_component *component) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); - da7219_aad_exit(codec); + da7219_aad_exit(component); /* Supplies */ - return regulator_bulk_disable(DA7219_NUM_SUPPLIES, da7219->supplies); + regulator_bulk_disable(DA7219_NUM_SUPPLIES, da7219->supplies); } #ifdef CONFIG_PM -static int da7219_suspend(struct snd_soc_codec *codec) +static int da7219_suspend(struct snd_soc_component *component) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); /* Suspend AAD if we're not a wake-up source */ if (!da7219->wakeup_source) - da7219_aad_suspend(codec); + da7219_aad_suspend(component); - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); return 0; } -static int da7219_resume(struct snd_soc_codec *codec) +static int da7219_resume(struct snd_soc_component *component) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); /* Resume AAD if previously suspended */ if (!da7219->wakeup_source) - da7219_aad_resume(codec); + da7219_aad_resume(component); return 0; } @@ -1891,21 +1891,22 @@ static int da7219_resume(struct snd_soc_codec *codec) #define da7219_resume NULL #endif -static const struct snd_soc_codec_driver soc_codec_dev_da7219 = { +static const struct snd_soc_component_driver soc_component_dev_da7219 = { .probe = da7219_probe, .remove = da7219_remove, .suspend = da7219_suspend, .resume = da7219_resume, .set_bias_level = da7219_set_bias_level, - - .component_driver = { - .controls = da7219_snd_controls, - .num_controls = ARRAY_SIZE(da7219_snd_controls), - .dapm_widgets = da7219_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(da7219_dapm_widgets), - .dapm_routes = da7219_audio_map, - .num_dapm_routes = ARRAY_SIZE(da7219_audio_map), - }, + .controls = da7219_snd_controls, + .num_controls = ARRAY_SIZE(da7219_snd_controls), + .dapm_widgets = da7219_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(da7219_dapm_widgets), + .dapm_routes = da7219_audio_map, + .num_dapm_routes = ARRAY_SIZE(da7219_audio_map), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; @@ -2090,7 +2091,7 @@ static int da7219_i2c_probe(struct i2c_client *i2c, } } - /* Soft reset codec */ + /* Soft reset component */ regmap_write_bits(da7219->regmap, DA7219_ACCDET_CONFIG_1, DA7219_ACCDET_EN_MASK, 0); regmap_write_bits(da7219->regmap, DA7219_CIF_CTRL, @@ -2101,10 +2102,11 @@ static int da7219_i2c_probe(struct i2c_client *i2c, regcache_cache_bypass(da7219->regmap, false); - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_da7219, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_da7219, &da7219_dai, 1); if (ret < 0) { - dev_err(&i2c->dev, "Failed to register da7219 codec: %d\n", + dev_err(&i2c->dev, "Failed to register da7219 component: %d\n", ret); } return ret; @@ -2112,7 +2114,6 @@ static int da7219_i2c_probe(struct i2c_client *i2c, static int da7219_i2c_remove(struct i2c_client *client) { - snd_soc_unregister_codec(&client->dev); return 0; } diff --git a/sound/soc/codecs/da7219.h b/sound/soc/codecs/da7219.h index 8d6c3c8c8026..1acb34cd12ad 100644 --- a/sound/soc/codecs/da7219.h +++ b/sound/soc/codecs/da7219.h @@ -822,6 +822,6 @@ struct da7219_priv { u8 gain_ramp_ctrl; }; -int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout); +int da7219_set_pll(struct snd_soc_component *component, int source, unsigned int fout); #endif /* __DA7219_H */ diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index dba6f4c5074a..0758927d1e06 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c @@ -1536,7 +1536,7 @@ static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe) struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); struct hdac_hdmi_pin *pin = NULL; struct hdac_hdmi_port *hport = NULL; - struct snd_soc_codec *codec = edev->scodec; + struct snd_soc_component *component = edev->scodec; int i; /* Don't know how this mapping is derived */ @@ -1551,7 +1551,7 @@ static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe) * connection states are updated in anyway at the end of the resume, * we can skip it when received during PM process. */ - if (snd_power_get_state(codec->component.card->snd_card) != + if (snd_power_get_state(component->card->snd_card) != SNDRV_CTL_POWER_D0) return; @@ -1609,10 +1609,10 @@ static int create_fill_jack_kcontrols(struct snd_soc_card *card, char kc_name[NAME_SIZE], xname[NAME_SIZE]; char *name; int i = 0, j; - struct snd_soc_codec *codec = edev->scodec; + struct snd_soc_component *component = edev->scodec; struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); - kc = devm_kcalloc(codec->dev, hdmi->num_ports, + kc = devm_kcalloc(component->dev, hdmi->num_ports, sizeof(*kc), GFP_KERNEL); if (!kc) @@ -1622,11 +1622,11 @@ static int create_fill_jack_kcontrols(struct snd_soc_card *card, for (j = 0; j < pin->num_ports; j++) { snprintf(xname, sizeof(xname), "hif%d-%d Jack", pin->nid, pin->ports[j].id); - name = devm_kstrdup(codec->dev, xname, GFP_KERNEL); + name = devm_kstrdup(component->dev, xname, GFP_KERNEL); if (!name) return -ENOMEM; snprintf(kc_name, sizeof(kc_name), "%s Switch", xname); - kc[i].name = devm_kstrdup(codec->dev, kc_name, + kc[i].name = devm_kstrdup(component->dev, kc_name, GFP_KERNEL); if (!kc[i].name) return -ENOMEM; @@ -1644,10 +1644,10 @@ static int create_fill_jack_kcontrols(struct snd_soc_card *card, return snd_soc_add_card_controls(card, kc, i); } -int hdac_hdmi_jack_port_init(struct snd_soc_codec *codec, +int hdac_hdmi_jack_port_init(struct snd_soc_component *component, struct snd_soc_dapm_context *dapm) { - struct hdac_ext_device *edev = snd_soc_codec_get_drvdata(codec); + struct hdac_ext_device *edev = snd_soc_component_get_drvdata(component); struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); struct hdac_hdmi_pin *pin; struct snd_soc_dapm_widget *widgets; @@ -1722,8 +1722,8 @@ EXPORT_SYMBOL_GPL(hdac_hdmi_jack_port_init); int hdac_hdmi_jack_init(struct snd_soc_dai *dai, int device, struct snd_soc_jack *jack) { - struct snd_soc_codec *codec = dai->codec; - struct hdac_ext_device *edev = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct hdac_ext_device *edev = snd_soc_component_get_drvdata(component); struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); struct hdac_hdmi_pcm *pcm; struct snd_pcm *snd_pcm; @@ -1784,16 +1784,16 @@ static void hdac_hdmi_present_sense_all_pins(struct hdac_ext_device *edev, } } -static int hdmi_codec_probe(struct snd_soc_codec *codec) +static int hdmi_codec_probe(struct snd_soc_component *component) { - struct hdac_ext_device *edev = snd_soc_codec_get_drvdata(codec); + struct hdac_ext_device *edev = snd_soc_component_get_drvdata(component); struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(&codec->component); + snd_soc_component_get_dapm(component); struct hdac_ext_link *hlink = NULL; int ret; - edev->scodec = codec; + edev->scodec = component; /* * hold the ref while we probe, also no need to drop the ref on @@ -1834,12 +1834,11 @@ static int hdmi_codec_probe(struct snd_soc_codec *codec) return 0; } -static int hdmi_codec_remove(struct snd_soc_codec *codec) +static void hdmi_codec_remove(struct snd_soc_component *component) { - struct hdac_ext_device *edev = snd_soc_codec_get_drvdata(codec); + struct hdac_ext_device *edev = snd_soc_component_get_drvdata(component); pm_runtime_disable(&edev->hdev.dev); - return 0; } #ifdef CONFIG_PM @@ -1891,10 +1890,12 @@ static void hdmi_codec_complete(struct device *dev) #define hdmi_codec_complete NULL #endif -static const struct snd_soc_codec_driver hdmi_hda_codec = { - .probe = hdmi_codec_probe, - .remove = hdmi_codec_remove, - .idle_bias_off = true, +static const struct snd_soc_component_driver hdmi_hda_codec = { + .probe = hdmi_codec_probe, + .remove = hdmi_codec_remove, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static void hdac_hdmi_get_chmap(struct hdac_device *hdev, int pcm_idx, @@ -2042,7 +2043,7 @@ static int hdac_hdmi_dev_probe(struct hdac_ext_device *edev) snd_hdac_refresh_widgets(hdev, true); /* ASoC specific initialization */ - ret = snd_soc_register_codec(&hdev->dev, &hdmi_hda_codec, + ret = devm_snd_soc_register_component(&hdev->dev, &hdmi_hda_codec, hdmi_dais, num_dais); snd_hdac_ext_bus_link_put(edev->ebus, hlink); @@ -2059,8 +2060,6 @@ static int hdac_hdmi_dev_remove(struct hdac_ext_device *edev) struct hdac_hdmi_port *port, *port_next; int i; - snd_soc_unregister_codec(&edev->hdev.dev); - list_for_each_entry_safe(pcm, pcm_next, &hdmi->pcm_list, head) { pcm->cvt = NULL; if (list_empty(&pcm->port_list)) diff --git a/sound/soc/codecs/hdac_hdmi.h b/sound/soc/codecs/hdac_hdmi.h index b5b57a5cbbfd..4fa2fc9ee893 100644 --- a/sound/soc/codecs/hdac_hdmi.h +++ b/sound/soc/codecs/hdac_hdmi.h @@ -5,6 +5,6 @@ int hdac_hdmi_jack_init(struct snd_soc_dai *dai, int pcm, struct snd_soc_jack *jack); -int hdac_hdmi_jack_port_init(struct snd_soc_codec *codec, +int hdac_hdmi_jack_port_init(struct snd_soc_component *component, struct snd_soc_dapm_context *dapm); #endif /* __HDAC_HDMI_H__ */ diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c index a1b697b6fb64..dc6ea4987b7d 100644 --- a/sound/soc/codecs/nau8825.c +++ b/sound/soc/codecs/nau8825.c @@ -914,8 +914,8 @@ static bool nau8825_volatile_reg(struct device *dev, unsigned int reg) static int nau8825_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 nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -938,8 +938,8 @@ static int nau8825_adc_event(struct snd_soc_dapm_widget *w, static int nau8825_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 nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -962,8 +962,8 @@ static int nau8825_pump_event(struct snd_soc_dapm_widget *w, static int nau8825_output_dac_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 nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -1244,8 +1244,8 @@ static int nau8825_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 nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); unsigned int val_len = 0, osr, ctrl_val, bclk_fs, bclk_div; nau8825_sema_acquire(nau8825, 3 * HZ); @@ -1329,8 +1329,8 @@ static int nau8825_hw_params(struct snd_pcm_substream *substream, static int nau8825_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); unsigned int ctrl1_val = 0, ctrl2_val = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -1427,10 +1427,10 @@ static struct snd_soc_dai_driver nau8825_dai = { * events will be routed to the given jack. Jack can be null to stop * reporting. */ -int nau8825_enable_jack_detect(struct snd_soc_codec *codec, +int nau8825_enable_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *jack) { - struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); + struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); struct regmap *regmap = nau8825->regmap; nau8825->jack = jack; @@ -1952,24 +1952,22 @@ static const struct regmap_config nau8825_regmap_config = { .num_reg_defaults = ARRAY_SIZE(nau8825_reg_defaults), }; -static int nau8825_codec_probe(struct snd_soc_codec *codec) +static int nau8825_component_probe(struct snd_soc_component *component) { - struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); nau8825->dapm = dapm; return 0; } -static int nau8825_codec_remove(struct snd_soc_codec *codec) +static void nau8825_component_remove(struct snd_soc_component *component) { - struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); + struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); /* Cancel and reset cross tak suppresstion detection funciton */ nau8825_xtalk_cancel(nau8825); - - return 0; } /** @@ -2084,20 +2082,20 @@ static void nau8825_fll_apply(struct nau8825 *nau8825, } /* freq_out must be 256*Fs in order to achieve the best performance */ -static int nau8825_set_pll(struct snd_soc_codec *codec, int pll_id, int source, +static int nau8825_set_pll(struct snd_soc_component *component, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); + struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); struct nau8825_fll fll_param; int ret, fs; fs = freq_out / 256; ret = nau8825_calc_fll_param(freq_in, fs, &fll_param); if (ret < 0) { - dev_err(codec->dev, "Unsupported input clock %d\n", freq_in); + dev_err(component->dev, "Unsupported input clock %d\n", freq_in); return ret; } - dev_dbg(codec->dev, "mclk_src=%x ratio=%x fll_frac=%x fll_int=%x clk_ref_div=%x\n", + dev_dbg(component->dev, "mclk_src=%x ratio=%x fll_frac=%x fll_int=%x clk_ref_div=%x\n", fll_param.mclk_src, fll_param.ratio, fll_param.fll_frac, fll_param.fll_int, fll_param.clk_ref_div); @@ -2298,10 +2296,10 @@ static int nau8825_configure_sysclk(struct nau8825 *nau8825, int clk_id, return 0; } -static int nau8825_set_sysclk(struct snd_soc_codec *codec, int clk_id, +static int nau8825_set_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { - struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); + struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); return nau8825_configure_sysclk(nau8825, clk_id, freq); } @@ -2331,10 +2329,10 @@ static int nau8825_resume_setup(struct nau8825 *nau8825) return 0; } -static int nau8825_set_bias_level(struct snd_soc_codec *codec, +static int nau8825_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); + struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); int ret; switch (level) { @@ -2345,11 +2343,11 @@ static int nau8825_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 (nau8825->mclk_freq) { ret = clk_prepare_enable(nau8825->mclk); if (ret) { - dev_err(nau8825->dev, "Unable to prepare codec mclk\n"); + dev_err(nau8825->dev, "Unable to prepare component mclk\n"); return ret; } } @@ -2383,12 +2381,12 @@ static int nau8825_set_bias_level(struct snd_soc_codec *codec, return 0; } -static int __maybe_unused nau8825_suspend(struct snd_soc_codec *codec) +static int __maybe_unused nau8825_suspend(struct snd_soc_component *component) { - struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); + struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); disable_irq(nau8825->irq); - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); /* Power down codec power; don't suppoet button wakeup */ snd_soc_dapm_disable_pin(nau8825->dapm, "SAR"); snd_soc_dapm_disable_pin(nau8825->dapm, "MICBIAS"); @@ -2399,9 +2397,9 @@ static int __maybe_unused nau8825_suspend(struct snd_soc_codec *codec) return 0; } -static int __maybe_unused nau8825_resume(struct snd_soc_codec *codec) +static int __maybe_unused nau8825_resume(struct snd_soc_component *component) { - struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); + struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); int ret; regcache_cache_only(nau8825->regmap, false); @@ -2415,24 +2413,25 @@ static int __maybe_unused nau8825_resume(struct snd_soc_codec *codec) return 0; } -static const struct snd_soc_codec_driver nau8825_codec_driver = { - .probe = nau8825_codec_probe, - .remove = nau8825_codec_remove, - .set_sysclk = nau8825_set_sysclk, - .set_pll = nau8825_set_pll, - .set_bias_level = nau8825_set_bias_level, - .suspend_bias_off = true, - .suspend = nau8825_suspend, - .resume = nau8825_resume, - - .component_driver = { - .controls = nau8825_controls, - .num_controls = ARRAY_SIZE(nau8825_controls), - .dapm_widgets = nau8825_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(nau8825_dapm_widgets), - .dapm_routes = nau8825_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(nau8825_dapm_routes), - }, +static const struct snd_soc_component_driver nau8825_component_driver = { + .probe = nau8825_component_probe, + .remove = nau8825_component_remove, + .set_sysclk = nau8825_set_sysclk, + .set_pll = nau8825_set_pll, + .set_bias_level = nau8825_set_bias_level, + .suspend = nau8825_suspend, + .resume = nau8825_resume, + .controls = nau8825_controls, + .num_controls = ARRAY_SIZE(nau8825_controls), + .dapm_widgets = nau8825_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(nau8825_dapm_widgets), + .dapm_routes = nau8825_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(nau8825_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static void nau8825_reset_chip(struct regmap *regmap) @@ -2619,13 +2618,13 @@ static int nau8825_i2c_probe(struct i2c_client *i2c, if (i2c->irq) nau8825_setup_irq(nau8825); - return snd_soc_register_codec(&i2c->dev, &nau8825_codec_driver, + return devm_snd_soc_register_component(&i2c->dev, + &nau8825_component_driver, &nau8825_dai, 1); } static int nau8825_i2c_remove(struct i2c_client *client) { - snd_soc_unregister_codec(&client->dev); return 0; } diff --git a/sound/soc/codecs/nau8825.h b/sound/soc/codecs/nau8825.h index f7e732125882..f6074c618569 100644 --- a/sound/soc/codecs/nau8825.h +++ b/sound/soc/codecs/nau8825.h @@ -480,7 +480,7 @@ struct nau8825 { bool xtalk_baktab_initialized; /* True if initialized. */ }; -int nau8825_enable_jack_detect(struct snd_soc_codec *codec, +int nau8825_enable_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *jack); diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c index af6325c78292..e1643571d643 100644 --- a/sound/soc/codecs/rt286.c +++ b/sound/soc/codecs/rt286.c @@ -40,7 +40,7 @@ struct rt286_priv { struct reg_default *index_cache; int index_cache_size; struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct rt286_platform_data pdata; struct i2c_client *i2c; struct snd_soc_jack *jack; @@ -187,13 +187,13 @@ static bool rt286_readable_register(struct device *dev, unsigned int reg) } #ifdef CONFIG_PM -static void rt286_index_sync(struct snd_soc_codec *codec) +static void rt286_index_sync(struct snd_soc_component *component) { - struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); + struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component); int i; for (i = 0; i < INDEX_CACHE_SIZE; i++) { - snd_soc_write(codec, rt286->index_cache[i].reg, + snd_soc_component_write(component, rt286->index_cache[i].reg, rt286->index_cache[i].def); } } @@ -220,10 +220,10 @@ static int rt286_jack_detect(struct rt286_priv *rt286, bool *hp, bool *mic) *hp = false; *mic = false; - if (!rt286->codec) + if (!rt286->component) return -EINVAL; - dapm = snd_soc_codec_get_dapm(rt286->codec); + dapm = snd_soc_component_get_dapm(rt286->component); if (rt286->pdata.cbj_en) { regmap_read(rt286->regmap, RT286_GET_HP_SENSE, &buf); @@ -305,10 +305,10 @@ static void rt286_jack_detect_work(struct work_struct *work) SND_JACK_MICROPHONE | SND_JACK_HEADPHONE); } -int rt286_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) +int rt286_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component); rt286->jack = jack; @@ -334,8 +334,8 @@ EXPORT_SYMBOL_GPL(rt286_mic_detect); static int is_mclk_mode(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 rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component); if (rt286->clk_id == RT286_SCLK_S_MCLK) return 1; @@ -434,15 +434,15 @@ SOC_DAPM_ENUM("SPO source", rt286_spo_enum); static int rt286_spk_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_write(codec, + snd_soc_component_write(component, RT286_SPK_EAPD, RT286_SET_EAPD_HIGH); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_write(codec, + snd_soc_component_write(component, RT286_SPK_EAPD, RT286_SET_EAPD_LOW); break; @@ -456,14 +456,14 @@ static int rt286_spk_event(struct snd_soc_dapm_widget *w, static int rt286_set_dmic1_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_write(codec, RT286_SET_PIN_DMIC1, 0x20); + snd_soc_component_write(component, RT286_SET_PIN_DMIC1, 0x20); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_write(codec, RT286_SET_PIN_DMIC1, 0); + snd_soc_component_write(component, RT286_SET_PIN_DMIC1, 0); break; default: return 0; @@ -475,14 +475,14 @@ static int rt286_set_dmic1_event(struct snd_soc_dapm_widget *w, static int rt286_ldo2_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, RT286_POWER_CTRL2, 0x38, 0x08); + snd_soc_component_update_bits(component, RT286_POWER_CTRL2, 0x38, 0x08); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, RT286_POWER_CTRL2, 0x38, 0x30); + snd_soc_component_update_bits(component, RT286_POWER_CTRL2, 0x38, 0x30); break; default: return 0; @@ -494,19 +494,19 @@ static int rt286_ldo2_event(struct snd_soc_dapm_widget *w, static int rt286_mic1_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_PRE_PMU: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_A_BIAS_CTRL3, 0xc000, 0x8000); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_A_BIAS_CTRL2, 0xc000, 0x8000); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_A_BIAS_CTRL3, 0xc000, 0x0000); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_A_BIAS_CTRL2, 0xc000, 0x0000); break; default: @@ -674,8 +674,8 @@ static int rt286_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 rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component); unsigned int val = 0; int d_len_code; @@ -687,7 +687,7 @@ static int rt286_hw_params(struct snd_pcm_substream *substream, case 48000: break; default: - dev_err(codec->dev, "Unsupported sample rate %d\n", + dev_err(component->dev, "Unsupported sample rate %d\n", params_rate(params)); return -EINVAL; } @@ -695,7 +695,7 @@ static int rt286_hw_params(struct snd_pcm_substream *substream, case 12288000: case 24576000: if (params_rate(params) != 48000) { - dev_err(codec->dev, "Sys_clk is not matched (%d %d)\n", + dev_err(component->dev, "Sys_clk is not matched (%d %d)\n", params_rate(params), rt286->sys_clk); return -EINVAL; } @@ -703,7 +703,7 @@ static int rt286_hw_params(struct snd_pcm_substream *substream, case 11289600: case 22579200: if (params_rate(params) != 44100) { - dev_err(codec->dev, "Sys_clk is not matched (%d %d)\n", + dev_err(component->dev, "Sys_clk is not matched (%d %d)\n", params_rate(params), rt286->sys_clk); return -EINVAL; } @@ -714,7 +714,7 @@ static int rt286_hw_params(struct snd_pcm_substream *substream, /* bit 3:0 Number of Channel */ val |= (params_channels(params) - 1); } else { - dev_err(codec->dev, "Unsupported channels %d\n", + dev_err(component->dev, "Unsupported channels %d\n", params_channels(params)); return -EINVAL; } @@ -745,27 +745,27 @@ static int rt286_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL1, 0x0018, d_len_code << 3); - dev_dbg(codec->dev, "format val = 0x%x\n", val); + dev_dbg(component->dev, "format val = 0x%x\n", val); - snd_soc_update_bits(codec, RT286_DAC_FORMAT, 0x407f, val); - snd_soc_update_bits(codec, RT286_ADC_FORMAT, 0x407f, val); + snd_soc_component_update_bits(component, RT286_DAC_FORMAT, 0x407f, val); + snd_soc_component_update_bits(component, RT286_ADC_FORMAT, 0x407f, val); return 0; } static int rt286_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL1, 0x800, 0x800); break; case SND_SOC_DAIFMT_CBS_CFS: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL1, 0x800, 0x0); break; default: @@ -774,27 +774,27 @@ static int rt286_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL1, 0x300, 0x0); break; case SND_SOC_DAIFMT_LEFT_J: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL1, 0x300, 0x1 << 8); break; case SND_SOC_DAIFMT_DSP_A: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL1, 0x300, 0x2 << 8); break; case SND_SOC_DAIFMT_DSP_B: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL1, 0x300, 0x3 << 8); break; default: return -EINVAL; } /* bit 15 Stream Type 0:PCM 1:Non-PCM */ - snd_soc_update_bits(codec, RT286_DAC_FORMAT, 0x8000, 0); - snd_soc_update_bits(codec, RT286_ADC_FORMAT, 0x8000, 0); + snd_soc_component_update_bits(component, RT286_DAC_FORMAT, 0x8000, 0); + snd_soc_component_update_bits(component, RT286_ADC_FORMAT, 0x8000, 0); return 0; } @@ -802,58 +802,58 @@ static int rt286_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int rt286_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s freq=%d\n", __func__, freq); + dev_dbg(component->dev, "%s freq=%d\n", __func__, freq); if (RT286_SCLK_S_MCLK == clk_id) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL2, 0x0100, 0x0); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_PLL_CTRL1, 0x20, 0x20); } else { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL2, 0x0100, 0x0100); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_PLL_CTRL, 0x4, 0x4); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_PLL_CTRL1, 0x20, 0x0); } switch (freq) { case 19200000: if (RT286_SCLK_S_MCLK == clk_id) { - dev_err(codec->dev, "Should not use MCLK\n"); + dev_err(component->dev, "Should not use MCLK\n"); return -EINVAL; } - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL2, 0x40, 0x40); break; case 24000000: if (RT286_SCLK_S_MCLK == clk_id) { - dev_err(codec->dev, "Should not use MCLK\n"); + dev_err(component->dev, "Should not use MCLK\n"); return -EINVAL; } - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL2, 0x40, 0x0); break; case 12288000: case 11289600: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL2, 0x8, 0x0); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_CLK_DIV, 0xfc1e, 0x0004); break; case 24576000: case 22579200: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL2, 0x8, 0x8); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_CLK_DIV, 0xfc1e, 0x5406); break; default: - dev_err(codec->dev, "Unsupported system clock\n"); + dev_err(component->dev, "Unsupported system clock\n"); return -EINVAL; } @@ -865,42 +865,42 @@ static int rt286_set_dai_sysclk(struct snd_soc_dai *dai, static int rt286_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; - dev_dbg(codec->dev, "%s ratio=%d\n", __func__, ratio); + dev_dbg(component->dev, "%s ratio=%d\n", __func__, ratio); if (50 == ratio) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL1, 0x1000, 0x1000); else - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL1, 0x1000, 0x0); return 0; } -static int rt286_set_bias_level(struct snd_soc_codec *codec, +static int rt286_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { case SND_SOC_BIAS_PREPARE: - if (SND_SOC_BIAS_STANDBY == snd_soc_codec_get_bias_level(codec)) { - snd_soc_write(codec, + if (SND_SOC_BIAS_STANDBY == snd_soc_component_get_bias_level(component)) { + snd_soc_component_write(component, RT286_SET_AUDIO_POWER, AC_PWRST_D0); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_DC_GAIN, 0x200, 0x200); } break; case SND_SOC_BIAS_ON: mdelay(10); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_DC_GAIN, 0x200, 0x0); break; case SND_SOC_BIAS_STANDBY: - snd_soc_write(codec, + snd_soc_component_write(component, RT286_SET_AUDIO_POWER, AC_PWRST_D3); break; @@ -937,11 +937,11 @@ static irqreturn_t rt286_irq(int irq, void *data) return IRQ_HANDLED; } -static int rt286_probe(struct snd_soc_codec *codec) +static int rt286_probe(struct snd_soc_component *component) { - struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); + struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component); - rt286->codec = codec; + rt286->component = component; if (rt286->i2c->irq) { regmap_update_bits(rt286->regmap, @@ -956,19 +956,17 @@ static int rt286_probe(struct snd_soc_codec *codec) return 0; } -static int rt286_remove(struct snd_soc_codec *codec) +static void rt286_remove(struct snd_soc_component *component) { - struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); + struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component); cancel_delayed_work_sync(&rt286->jack_detect_work); - - return 0; } #ifdef CONFIG_PM -static int rt286_suspend(struct snd_soc_codec *codec) +static int rt286_suspend(struct snd_soc_component *component) { - struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); + struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt286->regmap, true); regcache_mark_dirty(rt286->regmap); @@ -976,12 +974,12 @@ static int rt286_suspend(struct snd_soc_codec *codec) return 0; } -static int rt286_resume(struct snd_soc_codec *codec) +static int rt286_resume(struct snd_soc_component *component) { - struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); + struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt286->regmap, false); - rt286_index_sync(codec); + rt286_index_sync(component); regcache_sync(rt286->regmap); return 0; @@ -1046,21 +1044,21 @@ static struct snd_soc_dai_driver rt286_dai[] = { }; -static const struct snd_soc_codec_driver soc_codec_dev_rt286 = { - .probe = rt286_probe, - .remove = rt286_remove, - .suspend = rt286_suspend, - .resume = rt286_resume, - .set_bias_level = rt286_set_bias_level, - .idle_bias_off = true, - .component_driver = { - .controls = rt286_snd_controls, - .num_controls = ARRAY_SIZE(rt286_snd_controls), - .dapm_widgets = rt286_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(rt286_dapm_widgets), - .dapm_routes = rt286_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(rt286_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_rt286 = { + .probe = rt286_probe, + .remove = rt286_remove, + .suspend = rt286_suspend, + .resume = rt286_resume, + .set_bias_level = rt286_set_bias_level, + .controls = rt286_snd_controls, + .num_controls = ARRAY_SIZE(rt286_snd_controls), + .dapm_widgets = rt286_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt286_dapm_widgets), + .dapm_routes = rt286_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(rt286_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config rt286_regmap = { @@ -1243,7 +1241,8 @@ static int rt286_i2c_probe(struct i2c_client *i2c, } } - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt286, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_rt286, rt286_dai, ARRAY_SIZE(rt286_dai)); return ret; @@ -1255,7 +1254,6 @@ static int rt286_i2c_remove(struct i2c_client *i2c) if (i2c->irq) free_irq(i2c->irq, rt286); - snd_soc_unregister_codec(&i2c->dev); return 0; } diff --git a/sound/soc/codecs/rt286.h b/sound/soc/codecs/rt286.h index 7130edb152ef..c63d0e79ba86 100644 --- a/sound/soc/codecs/rt286.h +++ b/sound/soc/codecs/rt286.h @@ -199,7 +199,7 @@ enum { RT286_AIFS, }; -int rt286_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack); +int rt286_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack); #endif /* __RT286_H__ */ diff --git a/sound/soc/codecs/rt298.c b/sound/soc/codecs/rt298.c index ce963768449f..7bf4b31bdf55 100644 --- a/sound/soc/codecs/rt298.c +++ b/sound/soc/codecs/rt298.c @@ -39,7 +39,7 @@ struct rt298_priv { struct reg_default *index_cache; int index_cache_size; struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct rt298_platform_data pdata; struct i2c_client *i2c; struct snd_soc_jack *jack; @@ -194,13 +194,13 @@ static bool rt298_readable_register(struct device *dev, unsigned int reg) } #ifdef CONFIG_PM -static void rt298_index_sync(struct snd_soc_codec *codec) +static void rt298_index_sync(struct snd_soc_component *component) { - struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); + struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component); int i; for (i = 0; i < INDEX_CACHE_SIZE; i++) { - snd_soc_write(codec, rt298->index_cache[i].reg, + snd_soc_component_write(component, rt298->index_cache[i].reg, rt298->index_cache[i].def); } } @@ -227,10 +227,10 @@ static int rt298_jack_detect(struct rt298_priv *rt298, bool *hp, bool *mic) *hp = false; *mic = false; - if (!rt298->codec) + if (!rt298->component) return -EINVAL; - dapm = snd_soc_codec_get_dapm(rt298->codec); + dapm = snd_soc_component_get_dapm(rt298->component); if (rt298->pdata.cbj_en) { regmap_read(rt298->regmap, RT298_GET_HP_SENSE, &buf); @@ -323,9 +323,9 @@ static void rt298_jack_detect_work(struct work_struct *work) SND_JACK_MICROPHONE | SND_JACK_HEADPHONE); } -int rt298_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) +int rt298_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack) { - struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); + struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component); struct snd_soc_dapm_context *dapm; bool hp = false; bool mic = false; @@ -334,7 +334,7 @@ int rt298_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) /* If jack in NULL, disable HS jack */ if (!jack) { regmap_update_bits(rt298->regmap, RT298_IRQ_CTRL, 0x2, 0x0); - dapm = snd_soc_codec_get_dapm(codec); + dapm = snd_soc_component_get_dapm(component); snd_soc_dapm_disable_pin(dapm, "LDO1"); snd_soc_dapm_sync(dapm); return 0; @@ -360,8 +360,8 @@ EXPORT_SYMBOL_GPL(rt298_mic_detect); static int is_mclk_mode(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 rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component); if (rt298->clk_id == RT298_SCLK_S_MCLK) return 1; @@ -458,15 +458,15 @@ SOC_DAPM_ENUM("SPO source", rt298_spo_enum); static int rt298_spk_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_write(codec, + snd_soc_component_write(component, RT298_SPK_EAPD, RT298_SET_EAPD_HIGH); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_write(codec, + snd_soc_component_write(component, RT298_SPK_EAPD, RT298_SET_EAPD_LOW); break; @@ -480,14 +480,14 @@ static int rt298_spk_event(struct snd_soc_dapm_widget *w, static int rt298_set_dmic1_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_write(codec, RT298_SET_PIN_DMIC1, 0x20); + snd_soc_component_write(component, RT298_SET_PIN_DMIC1, 0x20); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_write(codec, RT298_SET_PIN_DMIC1, 0); + snd_soc_component_write(component, RT298_SET_PIN_DMIC1, 0); break; default: return 0; @@ -499,39 +499,39 @@ static int rt298_set_dmic1_event(struct snd_soc_dapm_widget *w, static int rt298_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); unsigned int nid; nid = (w->reg >> 20) & 0xff; switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, nid, 0), 0x7080, 0x7000); /* If MCLK doesn't exist, reset AD filter */ - if (!(snd_soc_read(codec, RT298_VAD_CTRL) & 0x200)) { + if (!(snd_soc_component_read32(component, RT298_VAD_CTRL) & 0x200)) { pr_info("NO MCLK\n"); switch (nid) { case RT298_ADC_IN1: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_D_FILTER_CTRL, 0x2, 0x2); mdelay(10); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_D_FILTER_CTRL, 0x2, 0x0); break; case RT298_ADC_IN2: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_D_FILTER_CTRL, 0x4, 0x4); mdelay(10); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_D_FILTER_CTRL, 0x4, 0x0); break; } } break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, nid, 0), 0x7080, 0x7080); break; @@ -545,19 +545,19 @@ static int rt298_adc_event(struct snd_soc_dapm_widget *w, static int rt298_mic1_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_PRE_PMU: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_A_BIAS_CTRL3, 0xc000, 0x8000); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_A_BIAS_CTRL2, 0xc000, 0x8000); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_A_BIAS_CTRL3, 0xc000, 0x0000); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_A_BIAS_CTRL2, 0xc000, 0x0000); break; default: @@ -745,8 +745,8 @@ static int rt298_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 rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component); unsigned int val = 0; int d_len_code; @@ -756,7 +756,7 @@ static int rt298_hw_params(struct snd_pcm_substream *substream, case 48000: break; default: - dev_err(codec->dev, "Unsupported sample rate %d\n", + dev_err(component->dev, "Unsupported sample rate %d\n", params_rate(params)); return -EINVAL; } @@ -764,7 +764,7 @@ static int rt298_hw_params(struct snd_pcm_substream *substream, case 12288000: case 24576000: if (params_rate(params) != 48000) { - dev_err(codec->dev, "Sys_clk is not matched (%d %d)\n", + dev_err(component->dev, "Sys_clk is not matched (%d %d)\n", params_rate(params), rt298->sys_clk); return -EINVAL; } @@ -772,7 +772,7 @@ static int rt298_hw_params(struct snd_pcm_substream *substream, case 11289600: case 22579200: if (params_rate(params) != 44100) { - dev_err(codec->dev, "Sys_clk is not matched (%d %d)\n", + dev_err(component->dev, "Sys_clk is not matched (%d %d)\n", params_rate(params), rt298->sys_clk); return -EINVAL; } @@ -783,7 +783,7 @@ static int rt298_hw_params(struct snd_pcm_substream *substream, /* bit 3:0 Number of Channel */ val |= (params_channels(params) - 1); } else { - dev_err(codec->dev, "Unsupported channels %d\n", + dev_err(component->dev, "Unsupported channels %d\n", params_channels(params)); return -EINVAL; } @@ -814,27 +814,27 @@ static int rt298_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL1, 0x0018, d_len_code << 3); - dev_dbg(codec->dev, "format val = 0x%x\n", val); + dev_dbg(component->dev, "format val = 0x%x\n", val); - snd_soc_update_bits(codec, RT298_DAC_FORMAT, 0x407f, val); - snd_soc_update_bits(codec, RT298_ADC_FORMAT, 0x407f, val); + snd_soc_component_update_bits(component, RT298_DAC_FORMAT, 0x407f, val); + snd_soc_component_update_bits(component, RT298_ADC_FORMAT, 0x407f, val); return 0; } static int rt298_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL1, 0x800, 0x800); break; case SND_SOC_DAIFMT_CBS_CFS: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL1, 0x800, 0x0); break; default: @@ -843,27 +843,27 @@ static int rt298_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL1, 0x300, 0x0); break; case SND_SOC_DAIFMT_LEFT_J: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL1, 0x300, 0x1 << 8); break; case SND_SOC_DAIFMT_DSP_A: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL1, 0x300, 0x2 << 8); break; case SND_SOC_DAIFMT_DSP_B: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL1, 0x300, 0x3 << 8); break; default: return -EINVAL; } /* bit 15 Stream Type 0:PCM 1:Non-PCM */ - snd_soc_update_bits(codec, RT298_DAC_FORMAT, 0x8000, 0); - snd_soc_update_bits(codec, RT298_ADC_FORMAT, 0x8000, 0); + snd_soc_component_update_bits(component, RT298_DAC_FORMAT, 0x8000, 0); + snd_soc_component_update_bits(component, RT298_ADC_FORMAT, 0x8000, 0); return 0; } @@ -871,56 +871,56 @@ static int rt298_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int rt298_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s freq=%d\n", __func__, freq); + dev_dbg(component->dev, "%s freq=%d\n", __func__, freq); if (RT298_SCLK_S_MCLK == clk_id) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL2, 0x0100, 0x0); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_PLL_CTRL1, 0x20, 0x20); } else { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL2, 0x0100, 0x0100); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_PLL_CTRL1, 0x20, 0x0); } switch (freq) { case 19200000: if (RT298_SCLK_S_MCLK == clk_id) { - dev_err(codec->dev, "Should not use MCLK\n"); + dev_err(component->dev, "Should not use MCLK\n"); return -EINVAL; } - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL2, 0x40, 0x40); break; case 24000000: if (RT298_SCLK_S_MCLK == clk_id) { - dev_err(codec->dev, "Should not use MCLK\n"); + dev_err(component->dev, "Should not use MCLK\n"); return -EINVAL; } - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL2, 0x40, 0x0); break; case 12288000: case 11289600: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL2, 0x8, 0x0); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_CLK_DIV, 0xfc1e, 0x0004); break; case 24576000: case 22579200: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL2, 0x8, 0x8); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_CLK_DIV, 0xfc1e, 0x5406); break; default: - dev_err(codec->dev, "Unsupported system clock\n"); + dev_err(component->dev, "Unsupported system clock\n"); return -EINVAL; } @@ -932,39 +932,39 @@ static int rt298_set_dai_sysclk(struct snd_soc_dai *dai, static int rt298_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; - dev_dbg(codec->dev, "%s ratio=%d\n", __func__, ratio); + dev_dbg(component->dev, "%s ratio=%d\n", __func__, ratio); if (50 == ratio) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL1, 0x1000, 0x1000); else - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL1, 0x1000, 0x0); return 0; } -static int rt298_set_bias_level(struct snd_soc_codec *codec, +static int rt298_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { case SND_SOC_BIAS_PREPARE: if (SND_SOC_BIAS_STANDBY == - snd_soc_codec_get_bias_level(codec)) { - snd_soc_write(codec, + snd_soc_component_get_bias_level(component)) { + snd_soc_component_write(component, RT298_SET_AUDIO_POWER, AC_PWRST_D0); - snd_soc_update_bits(codec, 0x0d, 0x200, 0x200); - snd_soc_update_bits(codec, 0x52, 0x80, 0x0); + snd_soc_component_update_bits(component, 0x0d, 0x200, 0x200); + snd_soc_component_update_bits(component, 0x52, 0x80, 0x0); mdelay(20); - snd_soc_update_bits(codec, 0x0d, 0x200, 0x0); - snd_soc_update_bits(codec, 0x52, 0x80, 0x80); + snd_soc_component_update_bits(component, 0x0d, 0x200, 0x0); + snd_soc_component_update_bits(component, 0x52, 0x80, 0x80); } break; case SND_SOC_BIAS_STANDBY: - snd_soc_write(codec, + snd_soc_component_write(component, RT298_SET_AUDIO_POWER, AC_PWRST_D3); break; @@ -1003,11 +1003,11 @@ static irqreturn_t rt298_irq(int irq, void *data) return IRQ_HANDLED; } -static int rt298_probe(struct snd_soc_codec *codec) +static int rt298_probe(struct snd_soc_component *component) { - struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); + struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component); - rt298->codec = codec; + rt298->component = component; if (rt298->i2c->irq) { regmap_update_bits(rt298->regmap, @@ -1022,19 +1022,17 @@ static int rt298_probe(struct snd_soc_codec *codec) return 0; } -static int rt298_remove(struct snd_soc_codec *codec) +static void rt298_remove(struct snd_soc_component *component) { - struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); + struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component); cancel_delayed_work_sync(&rt298->jack_detect_work); - - return 0; } #ifdef CONFIG_PM -static int rt298_suspend(struct snd_soc_codec *codec) +static int rt298_suspend(struct snd_soc_component *component) { - struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); + struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component); rt298->is_hp_in = -1; regcache_cache_only(rt298->regmap, true); @@ -1043,12 +1041,12 @@ static int rt298_suspend(struct snd_soc_codec *codec) return 0; } -static int rt298_resume(struct snd_soc_codec *codec) +static int rt298_resume(struct snd_soc_component *component) { - struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); + struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt298->regmap, false); - rt298_index_sync(codec); + rt298_index_sync(component); regcache_sync(rt298->regmap); return 0; @@ -1113,21 +1111,21 @@ static struct snd_soc_dai_driver rt298_dai[] = { }; -static const struct snd_soc_codec_driver soc_codec_dev_rt298 = { - .probe = rt298_probe, - .remove = rt298_remove, - .suspend = rt298_suspend, - .resume = rt298_resume, - .set_bias_level = rt298_set_bias_level, - .idle_bias_off = true, - .component_driver = { - .controls = rt298_snd_controls, - .num_controls = ARRAY_SIZE(rt298_snd_controls), - .dapm_widgets = rt298_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(rt298_dapm_widgets), - .dapm_routes = rt298_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(rt298_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_rt298 = { + .probe = rt298_probe, + .remove = rt298_remove, + .suspend = rt298_suspend, + .resume = rt298_resume, + .set_bias_level = rt298_set_bias_level, + .controls = rt298_snd_controls, + .num_controls = ARRAY_SIZE(rt298_snd_controls), + .dapm_widgets = rt298_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt298_dapm_widgets), + .dapm_routes = rt298_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(rt298_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config rt298_regmap = { @@ -1288,7 +1286,8 @@ static int rt298_i2c_probe(struct i2c_client *i2c, } } - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt298, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_rt298, rt298_dai, ARRAY_SIZE(rt298_dai)); return ret; @@ -1300,7 +1299,6 @@ static int rt298_i2c_remove(struct i2c_client *i2c) if (i2c->irq) free_irq(i2c->irq, rt298); - snd_soc_unregister_codec(&i2c->dev); return 0; } diff --git a/sound/soc/codecs/rt298.h b/sound/soc/codecs/rt298.h index 3638f3d61209..b4db935359fa 100644 --- a/sound/soc/codecs/rt298.h +++ b/sound/soc/codecs/rt298.h @@ -210,7 +210,7 @@ enum { RT298_AIFS, }; -int rt298_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack); +int rt298_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack); #endif /* __RT298_H__ */ diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c index d329bf719d80..20c0aeea6ca3 100644 --- a/sound/soc/codecs/rt5663.c +++ b/sound/soc/codecs/rt5663.c @@ -49,7 +49,7 @@ struct impedance_mapping_table { }; struct rt5663_priv { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct rt5663_platform_data pdata; struct regmap *regmap; struct delayed_work jack_detect_work, jd_unplug_work; @@ -1384,57 +1384,57 @@ static const char * const rt5663_if1_adc_data_select[] = { static SOC_ENUM_SINGLE_DECL(rt5663_if1_adc_enum, RT5663_TDM_2, RT5663_DATA_SWAP_ADCDAT1_SHIFT, rt5663_if1_adc_data_select); -static void rt5663_enable_push_button_irq(struct snd_soc_codec *codec, +static void rt5663_enable_push_button_irq(struct snd_soc_component *component, bool enable) { - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); if (enable) { - snd_soc_update_bits(codec, RT5663_IL_CMD_6, + snd_soc_component_update_bits(component, RT5663_IL_CMD_6, RT5663_EN_4BTN_INL_MASK, RT5663_EN_4BTN_INL_EN); /* reset in-line command */ - snd_soc_update_bits(codec, RT5663_IL_CMD_6, + snd_soc_component_update_bits(component, RT5663_IL_CMD_6, RT5663_RESET_4BTN_INL_MASK, RT5663_RESET_4BTN_INL_RESET); - snd_soc_update_bits(codec, RT5663_IL_CMD_6, + snd_soc_component_update_bits(component, RT5663_IL_CMD_6, RT5663_RESET_4BTN_INL_MASK, RT5663_RESET_4BTN_INL_NOR); switch (rt5663->codec_ver) { case CODEC_VER_1: - snd_soc_update_bits(codec, RT5663_IRQ_3, + snd_soc_component_update_bits(component, RT5663_IRQ_3, RT5663_V2_EN_IRQ_INLINE_MASK, RT5663_V2_EN_IRQ_INLINE_NOR); break; case CODEC_VER_0: - snd_soc_update_bits(codec, RT5663_IRQ_2, + snd_soc_component_update_bits(component, RT5663_IRQ_2, RT5663_EN_IRQ_INLINE_MASK, RT5663_EN_IRQ_INLINE_NOR); break; default: - dev_err(codec->dev, "Unknown CODEC Version\n"); + dev_err(component->dev, "Unknown CODEC Version\n"); } } else { switch (rt5663->codec_ver) { case CODEC_VER_1: - snd_soc_update_bits(codec, RT5663_IRQ_3, + snd_soc_component_update_bits(component, RT5663_IRQ_3, RT5663_V2_EN_IRQ_INLINE_MASK, RT5663_V2_EN_IRQ_INLINE_BYP); break; case CODEC_VER_0: - snd_soc_update_bits(codec, RT5663_IRQ_2, + snd_soc_component_update_bits(component, RT5663_IRQ_2, RT5663_EN_IRQ_INLINE_MASK, RT5663_EN_IRQ_INLINE_BYP); break; default: - dev_err(codec->dev, "Unknown CODEC Version\n"); + dev_err(component->dev, "Unknown CODEC Version\n"); } - snd_soc_update_bits(codec, RT5663_IL_CMD_6, + snd_soc_component_update_bits(component, RT5663_IL_CMD_6, RT5663_EN_4BTN_INL_MASK, RT5663_EN_4BTN_INL_DIS); /* reset in-line command */ - snd_soc_update_bits(codec, RT5663_IL_CMD_6, + snd_soc_component_update_bits(component, RT5663_IL_CMD_6, RT5663_RESET_4BTN_INL_MASK, RT5663_RESET_4BTN_INL_RESET); - snd_soc_update_bits(codec, RT5663_IL_CMD_6, + snd_soc_component_update_bits(component, RT5663_IL_CMD_6, RT5663_RESET_4BTN_INL_MASK, RT5663_RESET_4BTN_INL_NOR); } @@ -1442,7 +1442,7 @@ static void rt5663_enable_push_button_irq(struct snd_soc_codec *codec, /** * rt5663_v2_jack_detect - Detect headset. - * @codec: SoC audio codec device. + * @component: SoC audio component device. * @jack_insert: Jack insert or not. * * Detect whether is headset or not when jack inserted. @@ -1450,41 +1450,41 @@ static void rt5663_enable_push_button_irq(struct snd_soc_codec *codec, * Returns detect status. */ -static int rt5663_v2_jack_detect(struct snd_soc_codec *codec, int jack_insert) +static int rt5663_v2_jack_detect(struct snd_soc_component *component, int jack_insert) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); int val, i = 0, sleep_time[5] = {300, 150, 100, 50, 30}; - dev_dbg(codec->dev, "%s jack_insert:%d\n", __func__, jack_insert); + dev_dbg(component->dev, "%s jack_insert:%d\n", __func__, jack_insert); if (jack_insert) { - snd_soc_write(codec, RT5663_CBJ_TYPE_2, 0x8040); - snd_soc_write(codec, RT5663_CBJ_TYPE_3, 0x1484); + snd_soc_component_write(component, RT5663_CBJ_TYPE_2, 0x8040); + snd_soc_component_write(component, RT5663_CBJ_TYPE_3, 0x1484); snd_soc_dapm_force_enable_pin(dapm, "MICBIAS1"); snd_soc_dapm_force_enable_pin(dapm, "MICBIAS2"); snd_soc_dapm_force_enable_pin(dapm, "Mic Det Power"); snd_soc_dapm_force_enable_pin(dapm, "CBJ Power"); snd_soc_dapm_sync(dapm); - snd_soc_update_bits(codec, RT5663_RC_CLK, + snd_soc_component_update_bits(component, RT5663_RC_CLK, RT5663_DIG_1M_CLK_MASK, RT5663_DIG_1M_CLK_EN); - snd_soc_update_bits(codec, RT5663_RECMIX, 0x8, 0x8); + snd_soc_component_update_bits(component, RT5663_RECMIX, 0x8, 0x8); while (i < 5) { msleep(sleep_time[i]); - val = snd_soc_read(codec, RT5663_CBJ_TYPE_2) & 0x0003; + val = snd_soc_component_read32(component, RT5663_CBJ_TYPE_2) & 0x0003; if (val == 0x1 || val == 0x2 || val == 0x3) break; - dev_dbg(codec->dev, "%s: MX-0011 val=%x sleep %d\n", + dev_dbg(component->dev, "%s: MX-0011 val=%x sleep %d\n", __func__, val, sleep_time[i]); i++; } - dev_dbg(codec->dev, "%s val = %d\n", __func__, val); + dev_dbg(component->dev, "%s val = %d\n", __func__, val); switch (val) { case 1: case 2: rt5663->jack_type = SND_JACK_HEADSET; - rt5663_enable_push_button_irq(codec, true); + rt5663_enable_push_button_irq(component, true); break; default: snd_soc_dapm_disable_pin(dapm, "MICBIAS1"); @@ -1496,10 +1496,10 @@ static int rt5663_v2_jack_detect(struct snd_soc_codec *codec, int jack_insert) break; } } else { - snd_soc_update_bits(codec, RT5663_RECMIX, 0x8, 0x0); + snd_soc_component_update_bits(component, RT5663_RECMIX, 0x8, 0x0); if (rt5663->jack_type == SND_JACK_HEADSET) { - rt5663_enable_push_button_irq(codec, false); + rt5663_enable_push_button_irq(component, false); snd_soc_dapm_disable_pin(dapm, "MICBIAS1"); snd_soc_dapm_disable_pin(dapm, "MICBIAS2"); snd_soc_dapm_disable_pin(dapm, "Mic Det Power"); @@ -1509,60 +1509,60 @@ static int rt5663_v2_jack_detect(struct snd_soc_codec *codec, int jack_insert) rt5663->jack_type = 0; } - dev_dbg(codec->dev, "jack_type = %d\n", rt5663->jack_type); + dev_dbg(component->dev, "jack_type = %d\n", rt5663->jack_type); return rt5663->jack_type; } /** * rt5663_jack_detect - Detect headset. - * @codec: SoC audio codec device. + * @component: SoC audio component device. * @jack_insert: Jack insert or not. * * Detect whether is headset or not when jack inserted. * * Returns detect status. */ -static int rt5663_jack_detect(struct snd_soc_codec *codec, int jack_insert) +static int rt5663_jack_detect(struct snd_soc_component *component, int jack_insert) { - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); int val, i = 0; - dev_dbg(codec->dev, "%s jack_insert:%d\n", __func__, jack_insert); + dev_dbg(component->dev, "%s jack_insert:%d\n", __func__, jack_insert); if (jack_insert) { - snd_soc_update_bits(codec, RT5663_DIG_MISC, + snd_soc_component_update_bits(component, RT5663_DIG_MISC, RT5663_DIG_GATE_CTRL_MASK, RT5663_DIG_GATE_CTRL_EN); - snd_soc_update_bits(codec, RT5663_HP_CHARGE_PUMP_1, + snd_soc_component_update_bits(component, RT5663_HP_CHARGE_PUMP_1, RT5663_SI_HP_MASK | RT5663_OSW_HP_L_MASK | RT5663_OSW_HP_R_MASK, RT5663_SI_HP_EN | RT5663_OSW_HP_L_DIS | RT5663_OSW_HP_R_DIS); - snd_soc_update_bits(codec, RT5663_DUMMY_1, + snd_soc_component_update_bits(component, RT5663_DUMMY_1, RT5663_EMB_CLK_MASK | RT5663_HPA_CPL_BIAS_MASK | RT5663_HPA_CPR_BIAS_MASK, RT5663_EMB_CLK_EN | RT5663_HPA_CPL_BIAS_1 | RT5663_HPA_CPR_BIAS_1); - snd_soc_update_bits(codec, RT5663_CBJ_1, + snd_soc_component_update_bits(component, RT5663_CBJ_1, RT5663_INBUF_CBJ_BST1_MASK | RT5663_CBJ_SENSE_BST1_MASK, RT5663_INBUF_CBJ_BST1_ON | RT5663_CBJ_SENSE_BST1_L); - snd_soc_update_bits(codec, RT5663_IL_CMD_2, + snd_soc_component_update_bits(component, RT5663_IL_CMD_2, RT5663_PWR_MIC_DET_MASK, RT5663_PWR_MIC_DET_ON); /* BST1 power on for JD */ - snd_soc_update_bits(codec, RT5663_PWR_ANLG_2, + snd_soc_component_update_bits(component, RT5663_PWR_ANLG_2, RT5663_PWR_BST1_MASK, RT5663_PWR_BST1_ON); - snd_soc_update_bits(codec, RT5663_EM_JACK_TYPE_1, + snd_soc_component_update_bits(component, RT5663_EM_JACK_TYPE_1, RT5663_CBJ_DET_MASK | RT5663_EXT_JD_MASK | RT5663_POL_EXT_JD_MASK, RT5663_CBJ_DET_EN | RT5663_EXT_JD_EN | RT5663_POL_EXT_JD_EN); - snd_soc_update_bits(codec, RT5663_PWR_ANLG_1, + snd_soc_component_update_bits(component, RT5663_PWR_ANLG_1, RT5663_PWR_MB_MASK | RT5663_LDO1_DVO_MASK | RT5663_AMP_HP_MASK, RT5663_PWR_MB | RT5663_LDO1_DVO_0_9V | RT5663_AMP_HP_3X); - snd_soc_update_bits(codec, RT5663_AUTO_1MRC_CLK, + snd_soc_component_update_bits(component, RT5663_AUTO_1MRC_CLK, RT5663_IRQ_POW_SAV_MASK, RT5663_IRQ_POW_SAV_EN); - snd_soc_update_bits(codec, RT5663_IRQ_1, + snd_soc_component_update_bits(component, RT5663_IRQ_1, RT5663_EN_IRQ_JD1_MASK, RT5663_EN_IRQ_JD1_EN); - snd_soc_update_bits(codec, RT5663_EM_JACK_TYPE_1, + snd_soc_component_update_bits(component, RT5663_EM_JACK_TYPE_1, RT5663_EM_JD_MASK, RT5663_EM_JD_RST); - snd_soc_update_bits(codec, RT5663_EM_JACK_TYPE_1, + snd_soc_component_update_bits(component, RT5663_EM_JACK_TYPE_1, RT5663_EM_JD_MASK, RT5663_EM_JD_NOR); while (true) { @@ -1577,10 +1577,10 @@ static int rt5663_jack_detect(struct snd_soc_codec *codec, int jack_insert) i++; } - val = snd_soc_read(codec, RT5663_EM_JACK_TYPE_2) & 0x0003; - dev_dbg(codec->dev, "%s val = %d\n", __func__, val); + val = snd_soc_component_read32(component, RT5663_EM_JACK_TYPE_2) & 0x0003; + dev_dbg(component->dev, "%s val = %d\n", __func__, val); - snd_soc_update_bits(codec, RT5663_HP_CHARGE_PUMP_1, + snd_soc_component_update_bits(component, RT5663_HP_CHARGE_PUMP_1, RT5663_OSW_HP_L_MASK | RT5663_OSW_HP_R_MASK, RT5663_OSW_HP_L_EN | RT5663_OSW_HP_R_EN); @@ -1588,7 +1588,7 @@ static int rt5663_jack_detect(struct snd_soc_codec *codec, int jack_insert) case 1: case 2: rt5663->jack_type = SND_JACK_HEADSET; - rt5663_enable_push_button_irq(codec, true); + rt5663_enable_push_button_irq(component, true); if (rt5663->pdata.impedance_sensing_num) break; @@ -1636,17 +1636,17 @@ static int rt5663_jack_detect(struct snd_soc_codec *codec, int jack_insert) } } else { if (rt5663->jack_type == SND_JACK_HEADSET) - rt5663_enable_push_button_irq(codec, false); + rt5663_enable_push_button_irq(component, false); rt5663->jack_type = 0; } - dev_dbg(codec->dev, "jack_type = %d\n", rt5663->jack_type); + dev_dbg(component->dev, "jack_type = %d\n", rt5663->jack_type); return rt5663->jack_type; } -static int rt5663_impedance_sensing(struct snd_soc_codec *codec) +static int rt5663_impedance_sensing(struct snd_soc_component *component) { - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); unsigned int value, i, reg84, reg26, reg2fa, reg91, reg10, reg80; for (i = 0; i < rt5663->pdata.impedance_sensing_num; i++) { @@ -1655,59 +1655,59 @@ static int rt5663_impedance_sensing(struct snd_soc_codec *codec) } if (rt5663->jack_type == SND_JACK_HEADSET) { - snd_soc_write(codec, RT5663_MIC_DECRO_2, + snd_soc_component_write(component, RT5663_MIC_DECRO_2, rt5663->imp_table[i].dc_offset_l_manual_mic >> 16); - snd_soc_write(codec, RT5663_MIC_DECRO_3, + snd_soc_component_write(component, RT5663_MIC_DECRO_3, rt5663->imp_table[i].dc_offset_l_manual_mic & 0xffff); - snd_soc_write(codec, RT5663_MIC_DECRO_5, + snd_soc_component_write(component, RT5663_MIC_DECRO_5, rt5663->imp_table[i].dc_offset_r_manual_mic >> 16); - snd_soc_write(codec, RT5663_MIC_DECRO_6, + snd_soc_component_write(component, RT5663_MIC_DECRO_6, rt5663->imp_table[i].dc_offset_r_manual_mic & 0xffff); } else { - snd_soc_write(codec, RT5663_MIC_DECRO_2, + snd_soc_component_write(component, RT5663_MIC_DECRO_2, rt5663->imp_table[i].dc_offset_l_manual >> 16); - snd_soc_write(codec, RT5663_MIC_DECRO_3, + snd_soc_component_write(component, RT5663_MIC_DECRO_3, rt5663->imp_table[i].dc_offset_l_manual & 0xffff); - snd_soc_write(codec, RT5663_MIC_DECRO_5, + snd_soc_component_write(component, RT5663_MIC_DECRO_5, rt5663->imp_table[i].dc_offset_r_manual >> 16); - snd_soc_write(codec, RT5663_MIC_DECRO_6, + snd_soc_component_write(component, RT5663_MIC_DECRO_6, rt5663->imp_table[i].dc_offset_r_manual & 0xffff); } - reg84 = snd_soc_read(codec, RT5663_ASRC_2); - reg26 = snd_soc_read(codec, RT5663_STO1_ADC_MIXER); - reg2fa = snd_soc_read(codec, RT5663_DUMMY_1); - reg91 = snd_soc_read(codec, RT5663_HP_CHARGE_PUMP_1); - reg10 = snd_soc_read(codec, RT5663_RECMIX); - reg80 = snd_soc_read(codec, RT5663_GLB_CLK); + reg84 = snd_soc_component_read32(component, RT5663_ASRC_2); + reg26 = snd_soc_component_read32(component, RT5663_STO1_ADC_MIXER); + reg2fa = snd_soc_component_read32(component, RT5663_DUMMY_1); + reg91 = snd_soc_component_read32(component, RT5663_HP_CHARGE_PUMP_1); + reg10 = snd_soc_component_read32(component, RT5663_RECMIX); + reg80 = snd_soc_component_read32(component, RT5663_GLB_CLK); - snd_soc_update_bits(codec, RT5663_STO_DRE_1, 0x8000, 0); - snd_soc_write(codec, RT5663_ASRC_2, 0); - snd_soc_write(codec, RT5663_STO1_ADC_MIXER, 0x4040); - snd_soc_update_bits(codec, RT5663_PWR_ANLG_1, + snd_soc_component_update_bits(component, RT5663_STO_DRE_1, 0x8000, 0); + snd_soc_component_write(component, RT5663_ASRC_2, 0); + snd_soc_component_write(component, RT5663_STO1_ADC_MIXER, 0x4040); + snd_soc_component_update_bits(component, RT5663_PWR_ANLG_1, RT5663_PWR_VREF1_MASK | RT5663_PWR_VREF2_MASK | RT5663_PWR_FV1_MASK | RT5663_PWR_FV2_MASK, RT5663_PWR_VREF1 | RT5663_PWR_VREF2); usleep_range(10000, 10005); - snd_soc_update_bits(codec, RT5663_PWR_ANLG_1, + snd_soc_component_update_bits(component, RT5663_PWR_ANLG_1, RT5663_PWR_FV1_MASK | RT5663_PWR_FV2_MASK, RT5663_PWR_FV1 | RT5663_PWR_FV2); - snd_soc_update_bits(codec, RT5663_GLB_CLK, RT5663_SCLK_SRC_MASK, + snd_soc_component_update_bits(component, RT5663_GLB_CLK, RT5663_SCLK_SRC_MASK, RT5663_SCLK_SRC_RCCLK); - snd_soc_update_bits(codec, RT5663_RC_CLK, RT5663_DIG_25M_CLK_MASK, + snd_soc_component_update_bits(component, RT5663_RC_CLK, RT5663_DIG_25M_CLK_MASK, RT5663_DIG_25M_CLK_EN); - snd_soc_update_bits(codec, RT5663_ADDA_CLK_1, RT5663_I2S_PD1_MASK, 0); - snd_soc_write(codec, RT5663_PRE_DIV_GATING_1, 0xff00); - snd_soc_write(codec, RT5663_PRE_DIV_GATING_2, 0xfffc); - snd_soc_write(codec, RT5663_HP_CHARGE_PUMP_1, 0x1232); - snd_soc_write(codec, RT5663_HP_LOGIC_2, 0x0005); - snd_soc_write(codec, RT5663_DEPOP_2, 0x3003); - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0030, 0x0030); - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0003, 0x0003); - snd_soc_update_bits(codec, RT5663_PWR_DIG_2, + snd_soc_component_update_bits(component, RT5663_ADDA_CLK_1, RT5663_I2S_PD1_MASK, 0); + snd_soc_component_write(component, RT5663_PRE_DIV_GATING_1, 0xff00); + snd_soc_component_write(component, RT5663_PRE_DIV_GATING_2, 0xfffc); + snd_soc_component_write(component, RT5663_HP_CHARGE_PUMP_1, 0x1232); + snd_soc_component_write(component, RT5663_HP_LOGIC_2, 0x0005); + snd_soc_component_write(component, RT5663_DEPOP_2, 0x3003); + snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x0030, 0x0030); + snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x0003, 0x0003); + snd_soc_component_update_bits(component, RT5663_PWR_DIG_2, RT5663_PWR_ADC_S1F | RT5663_PWR_DAC_S1F, RT5663_PWR_ADC_S1F | RT5663_PWR_DAC_S1F); - snd_soc_update_bits(codec, RT5663_PWR_DIG_1, + snd_soc_component_update_bits(component, RT5663_PWR_DIG_1, RT5663_PWR_DAC_L1 | RT5663_PWR_DAC_R1 | RT5663_PWR_LDO_DACREF_MASK | RT5663_PWR_ADC_L1 | RT5663_PWR_ADC_R1, @@ -1715,71 +1715,71 @@ static int rt5663_impedance_sensing(struct snd_soc_codec *codec) RT5663_PWR_LDO_DACREF_ON | RT5663_PWR_ADC_L1 | RT5663_PWR_ADC_R1); msleep(40); - snd_soc_update_bits(codec, RT5663_PWR_ANLG_2, + snd_soc_component_update_bits(component, RT5663_PWR_ANLG_2, RT5663_PWR_RECMIX1 | RT5663_PWR_RECMIX2, RT5663_PWR_RECMIX1 | RT5663_PWR_RECMIX2); msleep(30); - snd_soc_write(codec, RT5663_HP_CHARGE_PUMP_2, 0x1371); - snd_soc_write(codec, RT5663_STO_DAC_MIXER, 0); - snd_soc_write(codec, RT5663_BYPASS_STO_DAC, 0x000c); - snd_soc_write(codec, RT5663_HP_BIAS, 0xafaa); - snd_soc_write(codec, RT5663_CHARGE_PUMP_1, 0x2224); - snd_soc_write(codec, RT5663_HP_OUT_EN, 0x8088); - snd_soc_write(codec, RT5663_CHOP_ADC, 0x3000); - snd_soc_write(codec, RT5663_ADDA_RST, 0xc000); - snd_soc_write(codec, RT5663_STO1_HPF_ADJ1, 0x3320); - snd_soc_write(codec, RT5663_HP_CALIB_2, 0x00c9); - snd_soc_write(codec, RT5663_DUMMY_1, 0x004c); - snd_soc_write(codec, RT5663_ANA_BIAS_CUR_1, 0x7733); - snd_soc_write(codec, RT5663_CHARGE_PUMP_2, 0x7777); - snd_soc_write(codec, RT5663_STO_DRE_9, 0x0007); - snd_soc_write(codec, RT5663_STO_DRE_10, 0x0007); - snd_soc_write(codec, RT5663_DUMMY_2, 0x02a4); - snd_soc_write(codec, RT5663_RECMIX, 0x0005); - snd_soc_write(codec, RT5663_HP_IMP_SEN_1, 0x4334); - snd_soc_update_bits(codec, RT5663_IRQ_3, 0x0004, 0x0004); - snd_soc_write(codec, RT5663_HP_LOGIC_1, 0x2200); - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x3000, 0x3000); - snd_soc_write(codec, RT5663_HP_LOGIC_1, 0x6200); + snd_soc_component_write(component, RT5663_HP_CHARGE_PUMP_2, 0x1371); + snd_soc_component_write(component, RT5663_STO_DAC_MIXER, 0); + snd_soc_component_write(component, RT5663_BYPASS_STO_DAC, 0x000c); + snd_soc_component_write(component, RT5663_HP_BIAS, 0xafaa); + snd_soc_component_write(component, RT5663_CHARGE_PUMP_1, 0x2224); + snd_soc_component_write(component, RT5663_HP_OUT_EN, 0x8088); + snd_soc_component_write(component, RT5663_CHOP_ADC, 0x3000); + snd_soc_component_write(component, RT5663_ADDA_RST, 0xc000); + snd_soc_component_write(component, RT5663_STO1_HPF_ADJ1, 0x3320); + snd_soc_component_write(component, RT5663_HP_CALIB_2, 0x00c9); + snd_soc_component_write(component, RT5663_DUMMY_1, 0x004c); + snd_soc_component_write(component, RT5663_ANA_BIAS_CUR_1, 0x7733); + snd_soc_component_write(component, RT5663_CHARGE_PUMP_2, 0x7777); + snd_soc_component_write(component, RT5663_STO_DRE_9, 0x0007); + snd_soc_component_write(component, RT5663_STO_DRE_10, 0x0007); + snd_soc_component_write(component, RT5663_DUMMY_2, 0x02a4); + snd_soc_component_write(component, RT5663_RECMIX, 0x0005); + snd_soc_component_write(component, RT5663_HP_IMP_SEN_1, 0x4334); + snd_soc_component_update_bits(component, RT5663_IRQ_3, 0x0004, 0x0004); + snd_soc_component_write(component, RT5663_HP_LOGIC_1, 0x2200); + snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x3000, 0x3000); + snd_soc_component_write(component, RT5663_HP_LOGIC_1, 0x6200); for (i = 0; i < 100; i++) { msleep(20); - if (snd_soc_read(codec, RT5663_INT_ST_1) & 0x2) + if (snd_soc_component_read32(component, RT5663_INT_ST_1) & 0x2) break; } - value = snd_soc_read(codec, RT5663_HP_IMP_SEN_4); + value = snd_soc_component_read32(component, RT5663_HP_IMP_SEN_4); - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x3000, 0); - snd_soc_write(codec, RT5663_INT_ST_1, 0); - snd_soc_write(codec, RT5663_HP_LOGIC_1, 0); - snd_soc_update_bits(codec, RT5663_RC_CLK, RT5663_DIG_25M_CLK_MASK, + snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x3000, 0); + snd_soc_component_write(component, RT5663_INT_ST_1, 0); + snd_soc_component_write(component, RT5663_HP_LOGIC_1, 0); + snd_soc_component_update_bits(component, RT5663_RC_CLK, RT5663_DIG_25M_CLK_MASK, RT5663_DIG_25M_CLK_DIS); - snd_soc_write(codec, RT5663_GLB_CLK, reg80); - snd_soc_write(codec, RT5663_RECMIX, reg10); - snd_soc_write(codec, RT5663_DUMMY_2, 0x00a4); - snd_soc_write(codec, RT5663_DUMMY_1, reg2fa); - snd_soc_write(codec, RT5663_HP_CALIB_2, 0x00c8); - snd_soc_write(codec, RT5663_STO1_HPF_ADJ1, 0xb320); - snd_soc_write(codec, RT5663_ADDA_RST, 0xe400); - snd_soc_write(codec, RT5663_CHOP_ADC, 0x2000); - snd_soc_write(codec, RT5663_HP_OUT_EN, 0x0008); - snd_soc_update_bits(codec, RT5663_PWR_ANLG_2, + snd_soc_component_write(component, RT5663_GLB_CLK, reg80); + snd_soc_component_write(component, RT5663_RECMIX, reg10); + snd_soc_component_write(component, RT5663_DUMMY_2, 0x00a4); + snd_soc_component_write(component, RT5663_DUMMY_1, reg2fa); + snd_soc_component_write(component, RT5663_HP_CALIB_2, 0x00c8); + snd_soc_component_write(component, RT5663_STO1_HPF_ADJ1, 0xb320); + snd_soc_component_write(component, RT5663_ADDA_RST, 0xe400); + snd_soc_component_write(component, RT5663_CHOP_ADC, 0x2000); + snd_soc_component_write(component, RT5663_HP_OUT_EN, 0x0008); + snd_soc_component_update_bits(component, RT5663_PWR_ANLG_2, RT5663_PWR_RECMIX1 | RT5663_PWR_RECMIX2, 0); - snd_soc_update_bits(codec, RT5663_PWR_DIG_1, + snd_soc_component_update_bits(component, RT5663_PWR_DIG_1, RT5663_PWR_DAC_L1 | RT5663_PWR_DAC_R1 | RT5663_PWR_LDO_DACREF_MASK | RT5663_PWR_ADC_L1 | RT5663_PWR_ADC_R1, 0); - snd_soc_update_bits(codec, RT5663_PWR_DIG_2, + snd_soc_component_update_bits(component, RT5663_PWR_DIG_2, RT5663_PWR_ADC_S1F | RT5663_PWR_DAC_S1F, 0); - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0003, 0); - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0030, 0); - snd_soc_write(codec, RT5663_HP_LOGIC_2, 0); - snd_soc_write(codec, RT5663_HP_CHARGE_PUMP_1, reg91); - snd_soc_update_bits(codec, RT5663_PWR_ANLG_1, + snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x0003, 0); + snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x0030, 0); + snd_soc_component_write(component, RT5663_HP_LOGIC_2, 0); + snd_soc_component_write(component, RT5663_HP_CHARGE_PUMP_1, reg91); + snd_soc_component_update_bits(component, RT5663_PWR_ANLG_1, RT5663_PWR_VREF1_MASK | RT5663_PWR_VREF2_MASK, 0); - snd_soc_write(codec, RT5663_STO1_ADC_MIXER, reg26); - snd_soc_write(codec, RT5663_ASRC_2, reg84); + snd_soc_component_write(component, RT5663_STO1_ADC_MIXER, reg26); + snd_soc_component_write(component, RT5663_ASRC_2, reg84); for (i = 0; i < rt5663->pdata.impedance_sensing_num; i++) { if (value >= rt5663->imp_table[i].imp_min && @@ -1787,42 +1787,42 @@ static int rt5663_impedance_sensing(struct snd_soc_codec *codec) break; } - snd_soc_update_bits(codec, RT5663_STO_DRE_9, RT5663_DRE_GAIN_HP_MASK, + snd_soc_component_update_bits(component, RT5663_STO_DRE_9, RT5663_DRE_GAIN_HP_MASK, rt5663->imp_table[i].vol); - snd_soc_update_bits(codec, RT5663_STO_DRE_10, RT5663_DRE_GAIN_HP_MASK, + snd_soc_component_update_bits(component, RT5663_STO_DRE_10, RT5663_DRE_GAIN_HP_MASK, rt5663->imp_table[i].vol); if (rt5663->jack_type == SND_JACK_HEADSET) { - snd_soc_write(codec, RT5663_MIC_DECRO_2, + snd_soc_component_write(component, RT5663_MIC_DECRO_2, rt5663->imp_table[i].dc_offset_l_manual_mic >> 16); - snd_soc_write(codec, RT5663_MIC_DECRO_3, + snd_soc_component_write(component, RT5663_MIC_DECRO_3, rt5663->imp_table[i].dc_offset_l_manual_mic & 0xffff); - snd_soc_write(codec, RT5663_MIC_DECRO_5, + snd_soc_component_write(component, RT5663_MIC_DECRO_5, rt5663->imp_table[i].dc_offset_r_manual_mic >> 16); - snd_soc_write(codec, RT5663_MIC_DECRO_6, + snd_soc_component_write(component, RT5663_MIC_DECRO_6, rt5663->imp_table[i].dc_offset_r_manual_mic & 0xffff); } else { - snd_soc_write(codec, RT5663_MIC_DECRO_2, + snd_soc_component_write(component, RT5663_MIC_DECRO_2, rt5663->imp_table[i].dc_offset_l_manual >> 16); - snd_soc_write(codec, RT5663_MIC_DECRO_3, + snd_soc_component_write(component, RT5663_MIC_DECRO_3, rt5663->imp_table[i].dc_offset_l_manual & 0xffff); - snd_soc_write(codec, RT5663_MIC_DECRO_5, + snd_soc_component_write(component, RT5663_MIC_DECRO_5, rt5663->imp_table[i].dc_offset_r_manual >> 16); - snd_soc_write(codec, RT5663_MIC_DECRO_6, + snd_soc_component_write(component, RT5663_MIC_DECRO_6, rt5663->imp_table[i].dc_offset_r_manual & 0xffff); } return 0; } -static int rt5663_button_detect(struct snd_soc_codec *codec) +static int rt5663_button_detect(struct snd_soc_component *component) { int btn_type, val; - val = snd_soc_read(codec, RT5663_IL_CMD_5); - dev_dbg(codec->dev, "%s: val=0x%x\n", __func__, val); + val = snd_soc_component_read32(component, RT5663_IL_CMD_5); + dev_dbg(component->dev, "%s: val=0x%x\n", __func__, val); btn_type = val & 0xfff0; - snd_soc_write(codec, RT5663_IL_CMD_5, val); + snd_soc_component_write(component, RT5663_IL_CMD_5, val); return btn_type; } @@ -1840,10 +1840,10 @@ static irqreturn_t rt5663_irq(int irq, void *data) return IRQ_HANDLED; } -int rt5663_set_jack_detect(struct snd_soc_codec *codec, +int rt5663_set_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *hs_jack) { - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); rt5663->hs_jack = hs_jack; @@ -1853,12 +1853,12 @@ int rt5663_set_jack_detect(struct snd_soc_codec *codec, } EXPORT_SYMBOL_GPL(rt5663_set_jack_detect); -static bool rt5663_check_jd_status(struct snd_soc_codec *codec) +static bool rt5663_check_jd_status(struct snd_soc_component *component) { - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); - int val = snd_soc_read(codec, RT5663_INT_ST_1); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); + int val = snd_soc_component_read32(component, RT5663_INT_ST_1); - dev_dbg(codec->dev, "%s val=%x\n", __func__, val); + dev_dbg(component->dev, "%s val=%x\n", __func__, val); /* JD1 */ switch (rt5663->codec_ver) { @@ -1867,7 +1867,7 @@ static bool rt5663_check_jd_status(struct snd_soc_codec *codec) case CODEC_VER_0: return !(val & 0x1000); default: - dev_err(codec->dev, "Unknown CODEC Version\n"); + dev_err(component->dev, "Unknown CODEC Version\n"); } return false; @@ -1877,28 +1877,28 @@ static void rt5663_jack_detect_work(struct work_struct *work) { struct rt5663_priv *rt5663 = container_of(work, struct rt5663_priv, jack_detect_work.work); - struct snd_soc_codec *codec = rt5663->codec; + struct snd_soc_component *component = rt5663->component; int btn_type, report = 0; - if (!codec) + if (!component) return; - if (rt5663_check_jd_status(codec)) { + if (rt5663_check_jd_status(component)) { /* jack in */ if (rt5663->jack_type == 0) { /* jack was out, report jack type */ switch (rt5663->codec_ver) { case CODEC_VER_1: report = rt5663_v2_jack_detect( - rt5663->codec, 1); + rt5663->component, 1); break; case CODEC_VER_0: - report = rt5663_jack_detect(rt5663->codec, 1); + report = rt5663_jack_detect(rt5663->component, 1); if (rt5663->pdata.impedance_sensing_num) - rt5663_impedance_sensing(rt5663->codec); + rt5663_impedance_sensing(rt5663->component); break; default: - dev_err(codec->dev, "Unknown CODEC Version\n"); + dev_err(component->dev, "Unknown CODEC Version\n"); } /* Delay the jack insert report to avoid pop noise */ @@ -1906,7 +1906,7 @@ static void rt5663_jack_detect_work(struct work_struct *work) } else { /* jack is already in, report button event */ report = SND_JACK_HEADSET; - btn_type = rt5663_button_detect(rt5663->codec); + btn_type = rt5663_button_detect(rt5663->component); /** * rt5663 can report three kinds of button behavior, * one click, double click and hold. However, @@ -1939,7 +1939,7 @@ static void rt5663_jack_detect_work(struct work_struct *work) break; default: btn_type = 0; - dev_err(rt5663->codec->dev, + dev_err(rt5663->component->dev, "Unexpected button code 0x%04x\n", btn_type); break; @@ -1959,16 +1959,16 @@ static void rt5663_jack_detect_work(struct work_struct *work) /* jack out */ switch (rt5663->codec_ver) { case CODEC_VER_1: - report = rt5663_v2_jack_detect(rt5663->codec, 0); + report = rt5663_v2_jack_detect(rt5663->component, 0); break; case CODEC_VER_0: - report = rt5663_jack_detect(rt5663->codec, 0); + report = rt5663_jack_detect(rt5663->component, 0); break; default: - dev_err(codec->dev, "Unknown CODEC Version\n"); + dev_err(component->dev, "Unknown CODEC Version\n"); } } - dev_dbg(codec->dev, "%s jack report: 0x%04x\n", __func__, report); + dev_dbg(component->dev, "%s jack report: 0x%04x\n", __func__, report); snd_soc_jack_report(rt5663->hs_jack, report, SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2 | SND_JACK_BTN_3); @@ -1978,22 +1978,22 @@ static void rt5663_jd_unplug_work(struct work_struct *work) { struct rt5663_priv *rt5663 = container_of(work, struct rt5663_priv, jd_unplug_work.work); - struct snd_soc_codec *codec = rt5663->codec; + struct snd_soc_component *component = rt5663->component; - if (!codec) + if (!component) return; - if (!rt5663_check_jd_status(codec)) { + if (!rt5663_check_jd_status(component)) { /* jack out */ switch (rt5663->codec_ver) { case CODEC_VER_1: - rt5663_v2_jack_detect(rt5663->codec, 0); + rt5663_v2_jack_detect(rt5663->component, 0); break; case CODEC_VER_0: - rt5663_jack_detect(rt5663->codec, 0); + rt5663_jack_detect(rt5663->component, 0); break; default: - dev_err(codec->dev, "Unknown CODEC Version\n"); + dev_err(component->dev, "Unknown CODEC Version\n"); } snd_soc_jack_report(rt5663->hs_jack, 0, SND_JACK_HEADSET | @@ -2047,9 +2047,9 @@ static int rt5663_is_sys_clk_from_pll(struct snd_soc_dapm_widget *w, struct snd_soc_dapm_widget *sink) { unsigned int val; - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); - val = snd_soc_read(codec, RT5663_GLB_CLK); + val = snd_soc_component_read32(component, RT5663_GLB_CLK); val &= RT5663_SCLK_SRC_MASK; if (val == RT5663_SCLK_SRC_PLL1) return 1; @@ -2061,8 +2061,8 @@ static int rt5663_is_using_asrc(struct snd_soc_dapm_widget *w, struct snd_soc_dapm_widget *sink) { unsigned int reg, shift, val; - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); if (rt5663->codec_ver == CODEC_VER_1) { switch (w->shift) { @@ -2092,7 +2092,7 @@ static int rt5663_is_using_asrc(struct snd_soc_dapm_widget *w, } } - val = (snd_soc_read(codec, reg) >> shift) & 0x7; + val = (snd_soc_component_read32(component, reg) >> shift) & 0x7; if (val) return 1; @@ -2103,23 +2103,23 @@ static int rt5663_is_using_asrc(struct snd_soc_dapm_widget *w, static int rt5663_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 rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); int da_asrc_en, ad_asrc_en; - da_asrc_en = (snd_soc_read(codec, RT5663_ASRC_2) & + da_asrc_en = (snd_soc_component_read32(component, RT5663_ASRC_2) & RT5663_DA_STO1_TRACK_MASK) ? 1 : 0; switch (rt5663->codec_ver) { case CODEC_VER_1: - ad_asrc_en = (snd_soc_read(codec, RT5663_ASRC_3) & + ad_asrc_en = (snd_soc_component_read32(component, RT5663_ASRC_3) & RT5663_V2_AD_STO1_TRACK_MASK) ? 1 : 0; break; case CODEC_VER_0: - ad_asrc_en = (snd_soc_read(codec, RT5663_ASRC_2) & + ad_asrc_en = (snd_soc_component_read32(component, RT5663_ASRC_2) & RT5663_AD_STO1_TRACK_MASK) ? 1 : 0; break; default: - dev_err(codec->dev, "Unknown CODEC Version\n"); + dev_err(component->dev, "Unknown CODEC Version\n"); return 1; } @@ -2127,14 +2127,14 @@ static int rt5663_i2s_use_asrc(struct snd_soc_dapm_widget *source, if (rt5663->sysclk > rt5663->lrck * 384) return 1; - dev_err(codec->dev, "sysclk < 384 x fs, disable i2s asrc\n"); + dev_err(component->dev, "sysclk < 384 x fs, disable i2s asrc\n"); return 0; } /** * rt5663_sel_asrc_clk_src - select ASRC clock source for a set of filters - * @codec: SoC audio codec device. + * @component: SoC audio component device. * @filter_mask: mask of filters. * @clk_src: clock source * @@ -2146,10 +2146,10 @@ static int rt5663_i2s_use_asrc(struct snd_soc_dapm_widget *source, * set of filters specified by the mask. And the codec driver will turn on ASRC * for these filters if ASRC is selected as their clock source. */ -int rt5663_sel_asrc_clk_src(struct snd_soc_codec *codec, +int rt5663_sel_asrc_clk_src(struct snd_soc_component *component, unsigned int filter_mask, unsigned int clk_src) { - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); unsigned int asrc2_mask = 0; unsigned int asrc2_value = 0; unsigned int asrc3_mask = 0; @@ -2180,16 +2180,16 @@ int rt5663_sel_asrc_clk_src(struct snd_soc_codec *codec, asrc2_value |= clk_src << RT5663_AD_STO1_TRACK_SHIFT; break; default: - dev_err(codec->dev, "Unknown CODEC Version\n"); + dev_err(component->dev, "Unknown CODEC Version\n"); } } if (asrc2_mask) - snd_soc_update_bits(codec, RT5663_ASRC_2, asrc2_mask, + snd_soc_component_update_bits(component, RT5663_ASRC_2, asrc2_mask, asrc2_value); if (asrc3_mask) - snd_soc_update_bits(codec, RT5663_ASRC_3, asrc3_mask, + snd_soc_component_update_bits(component, RT5663_ASRC_3, asrc3_mask, asrc3_value); return 0; @@ -2295,42 +2295,42 @@ static const struct snd_kcontrol_new rt5663_alg_dacr_mux = static int rt5663_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 rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: if (rt5663->codec_ver == CODEC_VER_1) { - snd_soc_update_bits(codec, RT5663_HP_CHARGE_PUMP_1, + snd_soc_component_update_bits(component, RT5663_HP_CHARGE_PUMP_1, RT5663_SEL_PM_HP_SHIFT, RT5663_SEL_PM_HP_HIGH); - snd_soc_update_bits(codec, RT5663_HP_LOGIC_2, + snd_soc_component_update_bits(component, RT5663_HP_LOGIC_2, RT5663_HP_SIG_SRC1_MASK, RT5663_HP_SIG_SRC1_SILENCE); } else { - snd_soc_write(codec, RT5663_DEPOP_2, 0x3003); - snd_soc_update_bits(codec, RT5663_HP_CHARGE_PUMP_1, + snd_soc_component_write(component, RT5663_DEPOP_2, 0x3003); + snd_soc_component_update_bits(component, RT5663_HP_CHARGE_PUMP_1, RT5663_OVCD_HP_MASK, RT5663_OVCD_HP_DIS); - snd_soc_write(codec, RT5663_HP_CHARGE_PUMP_2, 0x1371); - snd_soc_write(codec, RT5663_HP_BIAS, 0xabba); - snd_soc_write(codec, RT5663_CHARGE_PUMP_1, 0x2224); - snd_soc_write(codec, RT5663_ANA_BIAS_CUR_1, 0x7766); - snd_soc_write(codec, RT5663_HP_BIAS, 0xafaa); - snd_soc_write(codec, RT5663_CHARGE_PUMP_2, 0x7777); - snd_soc_update_bits(codec, RT5663_STO_DRE_1, 0x8000, + snd_soc_component_write(component, RT5663_HP_CHARGE_PUMP_2, 0x1371); + snd_soc_component_write(component, RT5663_HP_BIAS, 0xabba); + snd_soc_component_write(component, RT5663_CHARGE_PUMP_1, 0x2224); + snd_soc_component_write(component, RT5663_ANA_BIAS_CUR_1, 0x7766); + snd_soc_component_write(component, RT5663_HP_BIAS, 0xafaa); + snd_soc_component_write(component, RT5663_CHARGE_PUMP_2, 0x7777); + snd_soc_component_update_bits(component, RT5663_STO_DRE_1, 0x8000, 0x8000); - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x3000, + snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x3000, 0x3000); } break; case SND_SOC_DAPM_PRE_PMD: if (rt5663->codec_ver == CODEC_VER_1) { - snd_soc_update_bits(codec, RT5663_HP_LOGIC_2, + snd_soc_component_update_bits(component, RT5663_HP_LOGIC_2, RT5663_HP_SIG_SRC1_MASK, RT5663_HP_SIG_SRC1_REG); } else { - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x3000, 0x0); - snd_soc_update_bits(codec, RT5663_HP_CHARGE_PUMP_1, + snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x3000, 0x0); + snd_soc_component_update_bits(component, RT5663_HP_CHARGE_PUMP_1, RT5663_OVCD_HP_MASK, RT5663_OVCD_HP_EN); } break; @@ -2345,23 +2345,23 @@ static int rt5663_hp_event(struct snd_soc_dapm_widget *w, static int rt5663_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 rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: if (rt5663->codec_ver == CODEC_VER_0) { - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0030, + snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x0030, 0x0030); - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0003, + snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x0003, 0x0003); } break; case SND_SOC_DAPM_POST_PMD: if (rt5663->codec_ver == CODEC_VER_0) { - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0003, 0); - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0030, 0); + snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x0003, 0); + snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x0030, 0); } break; @@ -2375,17 +2375,17 @@ static int rt5663_charge_pump_event(struct snd_soc_dapm_widget *w, static int rt5663_bst2_power(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, RT5663_PWR_ANLG_2, + snd_soc_component_update_bits(component, RT5663_PWR_ANLG_2, RT5663_PWR_BST2_MASK | RT5663_PWR_BST2_OP_MASK, RT5663_PWR_BST2 | RT5663_PWR_BST2_OP); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, RT5663_PWR_ANLG_2, + snd_soc_component_update_bits(component, RT5663_PWR_ANLG_2, RT5663_PWR_BST2_MASK | RT5663_PWR_BST2_OP_MASK, 0); break; @@ -2399,17 +2399,17 @@ static int rt5663_bst2_power(struct snd_soc_dapm_widget *w, static int rt5663_pre_div_power(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_write(codec, RT5663_PRE_DIV_GATING_1, 0xff00); - snd_soc_write(codec, RT5663_PRE_DIV_GATING_2, 0xfffc); + snd_soc_component_write(component, RT5663_PRE_DIV_GATING_1, 0xff00); + snd_soc_component_write(component, RT5663_PRE_DIV_GATING_2, 0xfffc); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_write(codec, RT5663_PRE_DIV_GATING_1, 0x0000); - snd_soc_write(codec, RT5663_PRE_DIV_GATING_2, 0x0000); + snd_soc_component_write(component, RT5663_PRE_DIV_GATING_1, 0x0000); + snd_soc_component_write(component, RT5663_PRE_DIV_GATING_2, 0x0000); break; default: @@ -2731,8 +2731,8 @@ static const struct snd_soc_dapm_route rt5663_specific_dapm_routes[] = { static int rt5663_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 rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); unsigned int val_len = 0; int pre_div; @@ -2743,7 +2743,7 @@ static int rt5663_hw_params(struct snd_pcm_substream *substream, pre_div = rl6231_get_clk_info(rt5663->sysclk, rt5663->lrck); 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", rt5663->lrck, dai->id); return -EINVAL; } @@ -2767,10 +2767,10 @@ static int rt5663_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, RT5663_I2S1_SDP, + snd_soc_component_update_bits(component, RT5663_I2S1_SDP, RT5663_I2S_DL_MASK, val_len); - snd_soc_update_bits(codec, RT5663_ADDA_CLK_1, + snd_soc_component_update_bits(component, RT5663_ADDA_CLK_1, RT5663_I2S_PD1_MASK, pre_div << RT5663_I2S_PD1_SHIFT); return 0; @@ -2778,7 +2778,7 @@ static int rt5663_hw_params(struct snd_pcm_substream *substream, static int rt5663_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int reg_val = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -2817,7 +2817,7 @@ static int rt5663_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } - snd_soc_update_bits(codec, RT5663_I2S1_SDP, RT5663_I2S_MS_MASK | + snd_soc_component_update_bits(component, RT5663_I2S1_SDP, RT5663_I2S_MS_MASK | RT5663_I2S_BP_MASK | RT5663_I2S_DF_MASK, reg_val); return 0; @@ -2826,8 +2826,8 @@ static int rt5663_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int rt5663_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; if (freq == rt5663->sysclk && clk_id == rt5663->sysclk_src) @@ -2844,15 +2844,15 @@ static int rt5663_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, reg_val |= RT5663_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, RT5663_GLB_CLK, RT5663_SCLK_SRC_MASK, + snd_soc_component_update_bits(component, RT5663_GLB_CLK, RT5663_SCLK_SRC_MASK, reg_val); rt5663->sysclk = freq; rt5663->sysclk_src = clk_id; - dev_dbg(codec->dev, "Sysclk is %dHz and clock id is %d\n", + dev_dbg(component->dev, "Sysclk is %dHz and clock id is %d\n", freq, clk_id); return 0; @@ -2861,8 +2861,8 @@ static int rt5663_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, static int rt5663_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 rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); struct rl6231_pll_code pll_code; int ret; int mask, shift, val; @@ -2872,11 +2872,11 @@ static int rt5663_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"); rt5663->pll_in = 0; rt5663->pll_out = 0; - snd_soc_update_bits(codec, RT5663_GLB_CLK, + snd_soc_component_update_bits(component, RT5663_GLB_CLK, RT5663_SCLK_SRC_MASK, RT5663_SCLK_SRC_MCLK); return 0; } @@ -2891,7 +2891,7 @@ static int rt5663_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, shift = RT5663_PLL1_SRC_SHIFT; break; default: - dev_err(codec->dev, "Unknown CODEC Version\n"); + dev_err(component->dev, "Unknown CODEC Version\n"); return -EINVAL; } @@ -2903,24 +2903,24 @@ static int rt5663_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, val = 0x1; break; default: - dev_err(codec->dev, "Unknown PLL source %d\n", source); + dev_err(component->dev, "Unknown PLL source %d\n", source); return -EINVAL; } - snd_soc_update_bits(codec, RT5663_GLB_CLK, mask, (val << shift)); + snd_soc_component_update_bits(component, RT5663_GLB_CLK, mask, (val << shift)); 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", pll_code.m_bp, + 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, RT5663_PLL_1, + snd_soc_component_write(component, RT5663_PLL_1, pll_code.n_code << RT5663_PLL_N_SHIFT | pll_code.k_code); - snd_soc_write(codec, RT5663_PLL_2, + snd_soc_component_write(component, RT5663_PLL_2, (pll_code.m_bp ? 0 : pll_code.m_code) << RT5663_PLL_M_SHIFT | pll_code.m_bp << RT5663_PLL_M_BP_SHIFT); @@ -2934,8 +2934,8 @@ static int rt5663_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, static int rt5663_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 rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); unsigned int val = 0, reg; if (rx_mask || tx_mask) @@ -2987,11 +2987,11 @@ static int rt5663_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, reg = RT5663_TDM_1; break; default: - dev_err(codec->dev, "Unknown CODEC Version\n"); + dev_err(component->dev, "Unknown CODEC Version\n"); return -EINVAL; } - snd_soc_update_bits(codec, reg, RT5663_TDM_MODE_MASK | + snd_soc_component_update_bits(component, reg, RT5663_TDM_MODE_MASK | RT5663_TDM_IN_CH_MASK | RT5663_TDM_OUT_CH_MASK | RT5663_TDM_IN_LEN_MASK | RT5663_TDM_OUT_LEN_MASK, val); @@ -3000,11 +3000,11 @@ static int rt5663_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, static int rt5663_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) { - struct snd_soc_codec *codec = dai->codec; - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); unsigned int reg; - dev_dbg(codec->dev, "%s ratio = %d\n", __func__, ratio); + dev_dbg(component->dev, "%s ratio = %d\n", __func__, ratio); if (rt5663->codec_ver == CODEC_VER_1) reg = RT5663_TDM_9; @@ -3013,51 +3013,51 @@ static int rt5663_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) switch (ratio) { case 32: - snd_soc_update_bits(codec, reg, + snd_soc_component_update_bits(component, reg, RT5663_TDM_LENGTN_MASK, RT5663_TDM_LENGTN_16); break; case 40: - snd_soc_update_bits(codec, reg, + snd_soc_component_update_bits(component, reg, RT5663_TDM_LENGTN_MASK, RT5663_TDM_LENGTN_20); break; case 48: - snd_soc_update_bits(codec, reg, + snd_soc_component_update_bits(component, reg, RT5663_TDM_LENGTN_MASK, RT5663_TDM_LENGTN_24); break; case 64: - snd_soc_update_bits(codec, reg, + snd_soc_component_update_bits(component, reg, RT5663_TDM_LENGTN_MASK, RT5663_TDM_LENGTN_32); break; default: - dev_err(codec->dev, "Invalid ratio!\n"); + dev_err(component->dev, "Invalid ratio!\n"); return -EINVAL; } return 0; } -static int rt5663_set_bias_level(struct snd_soc_codec *codec, +static int rt5663_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: - snd_soc_update_bits(codec, RT5663_PWR_ANLG_1, + snd_soc_component_update_bits(component, RT5663_PWR_ANLG_1, RT5663_PWR_FV1_MASK | RT5663_PWR_FV2_MASK, RT5663_PWR_FV1 | RT5663_PWR_FV2); break; case SND_SOC_BIAS_PREPARE: if (rt5663->codec_ver == CODEC_VER_1) { - snd_soc_update_bits(codec, RT5663_DIG_MISC, + snd_soc_component_update_bits(component, RT5663_DIG_MISC, RT5663_DIG_GATE_CTRL_MASK, RT5663_DIG_GATE_CTRL_EN); - snd_soc_update_bits(codec, RT5663_SIG_CLK_DET, + snd_soc_component_update_bits(component, RT5663_SIG_CLK_DET, RT5663_EN_ANA_CLK_DET_MASK | RT5663_PWR_CLK_DET_MASK, RT5663_EN_ANA_CLK_DET_AUTO | @@ -3067,17 +3067,17 @@ static int rt5663_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_STANDBY: if (rt5663->codec_ver == CODEC_VER_1) - snd_soc_update_bits(codec, RT5663_DIG_MISC, + snd_soc_component_update_bits(component, RT5663_DIG_MISC, RT5663_DIG_GATE_CTRL_MASK, RT5663_DIG_GATE_CTRL_DIS); - snd_soc_update_bits(codec, RT5663_PWR_ANLG_1, + snd_soc_component_update_bits(component, RT5663_PWR_ANLG_1, RT5663_PWR_VREF1_MASK | RT5663_PWR_VREF2_MASK | RT5663_PWR_FV1_MASK | RT5663_PWR_FV2_MASK | RT5663_PWR_MB_MASK, RT5663_PWR_VREF1 | RT5663_PWR_VREF2 | RT5663_PWR_MB); usleep_range(10000, 10005); if (rt5663->codec_ver == CODEC_VER_1) { - snd_soc_update_bits(codec, RT5663_SIG_CLK_DET, + snd_soc_component_update_bits(component, RT5663_SIG_CLK_DET, RT5663_EN_ANA_CLK_DET_MASK | RT5663_PWR_CLK_DET_MASK, RT5663_EN_ANA_CLK_DET_DIS | @@ -3086,7 +3086,7 @@ static int rt5663_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, RT5663_PWR_ANLG_1, + snd_soc_component_update_bits(component, RT5663_PWR_ANLG_1, RT5663_PWR_VREF1_MASK | RT5663_PWR_VREF2_MASK | RT5663_PWR_FV1 | RT5663_PWR_FV2, 0x0); break; @@ -3098,12 +3098,12 @@ static int rt5663_set_bias_level(struct snd_soc_codec *codec, return 0; } -static int rt5663_probe(struct snd_soc_codec *codec) +static int rt5663_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); - rt5663->codec = codec; + rt5663->component = component; switch (rt5663->codec_ver) { case CODEC_VER_1: @@ -3113,7 +3113,7 @@ static int rt5663_probe(struct snd_soc_codec *codec) snd_soc_dapm_add_routes(dapm, rt5663_v2_specific_dapm_routes, ARRAY_SIZE(rt5663_v2_specific_dapm_routes)); - snd_soc_add_codec_controls(codec, rt5663_v2_specific_controls, + snd_soc_add_component_controls(component, rt5663_v2_specific_controls, ARRAY_SIZE(rt5663_v2_specific_controls)); break; case CODEC_VER_0: @@ -3123,11 +3123,11 @@ static int rt5663_probe(struct snd_soc_codec *codec) snd_soc_dapm_add_routes(dapm, rt5663_specific_dapm_routes, ARRAY_SIZE(rt5663_specific_dapm_routes)); - snd_soc_add_codec_controls(codec, rt5663_specific_controls, + snd_soc_add_component_controls(component, rt5663_specific_controls, ARRAY_SIZE(rt5663_specific_controls)); if (!rt5663->imp_table) - snd_soc_add_codec_controls(codec, rt5663_hpvol_controls, + snd_soc_add_component_controls(component, rt5663_hpvol_controls, ARRAY_SIZE(rt5663_hpvol_controls)); break; } @@ -3135,19 +3135,17 @@ static int rt5663_probe(struct snd_soc_codec *codec) return 0; } -static int rt5663_remove(struct snd_soc_codec *codec) +static void rt5663_remove(struct snd_soc_component *component) { - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); regmap_write(rt5663->regmap, RT5663_RESET, 0); - - return 0; } #ifdef CONFIG_PM -static int rt5663_suspend(struct snd_soc_codec *codec) +static int rt5663_suspend(struct snd_soc_component *component) { - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt5663->regmap, true); regcache_mark_dirty(rt5663->regmap); @@ -3155,9 +3153,9 @@ static int rt5663_suspend(struct snd_soc_codec *codec) return 0; } -static int rt5663_resume(struct snd_soc_codec *codec) +static int rt5663_resume(struct snd_soc_component *component) { - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt5663->regmap, false); regcache_sync(rt5663->regmap); @@ -3206,21 +3204,22 @@ static struct snd_soc_dai_driver rt5663_dai[] = { }, }; -static const struct snd_soc_codec_driver soc_codec_dev_rt5663 = { - .probe = rt5663_probe, - .remove = rt5663_remove, - .suspend = rt5663_suspend, - .resume = rt5663_resume, - .set_bias_level = rt5663_set_bias_level, - .idle_bias_off = true, - .component_driver = { - .controls = rt5663_snd_controls, - .num_controls = ARRAY_SIZE(rt5663_snd_controls), - .dapm_widgets = rt5663_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(rt5663_dapm_widgets), - .dapm_routes = rt5663_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(rt5663_dapm_routes), - } +static const struct snd_soc_component_driver soc_component_dev_rt5663 = { + .probe = rt5663_probe, + .remove = rt5663_remove, + .suspend = rt5663_suspend, + .resume = rt5663_resume, + .set_bias_level = rt5663_set_bias_level, + .controls = rt5663_snd_controls, + .num_controls = ARRAY_SIZE(rt5663_snd_controls), + .dapm_widgets = rt5663_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt5663_dapm_widgets), + .dapm_routes = rt5663_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(rt5663_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, + }; static const struct regmap_config rt5663_v2_regmap = { @@ -3610,7 +3609,8 @@ static int rt5663_i2c_probe(struct i2c_client *i2c, __func__, ret); } - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5663, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_rt5663, rt5663_dai, ARRAY_SIZE(rt5663_dai)); if (ret) { @@ -3628,8 +3628,6 @@ static int rt5663_i2c_remove(struct i2c_client *i2c) if (i2c->irq) free_irq(i2c->irq, rt5663); - snd_soc_unregister_codec(&i2c->dev); - return 0; } diff --git a/sound/soc/codecs/rt5663.h b/sound/soc/codecs/rt5663.h index 03adc8004ba9..865203cc2034 100644 --- a/sound/soc/codecs/rt5663.h +++ b/sound/soc/codecs/rt5663.h @@ -1125,9 +1125,9 @@ enum { RT5663_AD_STEREO_FILTER = 0x2, }; -int rt5663_set_jack_detect(struct snd_soc_codec *codec, +int rt5663_set_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *hs_jack); -int rt5663_sel_asrc_clk_src(struct snd_soc_codec *codec, +int rt5663_sel_asrc_clk_src(struct snd_soc_component *component, unsigned int filter_mask, unsigned int clk_src); #endif /* __RT5663_H__ */ diff --git a/sound/soc/intel/boards/broadwell.c b/sound/soc/intel/boards/broadwell.c index 6dcbbcefc25b..370cd916faba 100644 --- a/sound/soc/intel/boards/broadwell.c +++ b/sound/soc/intel/boards/broadwell.c @@ -78,7 +78,7 @@ static const struct snd_soc_dapm_route broadwell_rt286_map[] = { static int broadwell_rt286_codec_init(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; int ret = 0; ret = snd_soc_card_jack_new(rtd->card, "Headset", SND_JACK_HEADSET | SND_JACK_BTN_0, &broadwell_headset, @@ -86,7 +86,7 @@ static int broadwell_rt286_codec_init(struct snd_soc_pcm_runtime *rtd) if (ret) return ret; - rt286_mic_detect(codec, &broadwell_headset); + rt286_mic_detect(component, &broadwell_headset); return 0; } @@ -224,10 +224,9 @@ static int broadwell_suspend(struct snd_soc_card *card){ list_for_each_entry(component, &card->component_dev_list, card_list) { if (!strcmp(component->name, "i2c-INT343A:00")) { - struct snd_soc_codec *codec = snd_soc_component_to_codec(component); - dev_dbg(codec->dev, "disabling jack detect before going to suspend.\n"); - rt286_mic_detect(codec, NULL); + dev_dbg(component->dev, "disabling jack detect before going to suspend.\n"); + rt286_mic_detect(component, NULL); break; } } @@ -239,10 +238,9 @@ static int broadwell_resume(struct snd_soc_card *card){ list_for_each_entry(component, &card->component_dev_list, card_list) { if (!strcmp(component->name, "i2c-INT343A:00")) { - struct snd_soc_codec *codec = snd_soc_component_to_codec(component); - dev_dbg(codec->dev, "enabling jack detect for resume.\n"); - rt286_mic_detect(codec, &broadwell_headset); + dev_dbg(component->dev, "enabling jack detect for resume.\n"); + rt286_mic_detect(component, &broadwell_headset); break; } } diff --git a/sound/soc/intel/boards/bxt_da7219_max98357a.c b/sound/soc/intel/boards/bxt_da7219_max98357a.c index f8a91a6f2a17..668c0934e942 100644 --- a/sound/soc/intel/boards/bxt_da7219_max98357a.c +++ b/sound/soc/intel/boards/bxt_da7219_max98357a.c @@ -169,7 +169,7 @@ static int broxton_da7219_codec_init(struct snd_soc_pcm_runtime *rtd) { int ret; struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; /* Configure sysclk for codec */ ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK, 19200000, @@ -192,7 +192,7 @@ static int broxton_da7219_codec_init(struct snd_soc_pcm_runtime *rtd) return ret; } - da7219_aad_jack_det(codec, &broxton_headset); + da7219_aad_jack_det(component, &broxton_headset); snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); @@ -522,12 +522,12 @@ static int bxt_card_late_probe(struct snd_soc_card *card) { struct bxt_card_private *ctx = snd_soc_card_get_drvdata(card); struct bxt_hdmi_pcm *pcm; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; int err, i = 0; char jack_name[NAME_SIZE]; list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { - codec = pcm->codec_dai->codec; + component = pcm->codec_dai->component; snprintf(jack_name, sizeof(jack_name), "HDMI/DP, pcm=%d Jack", pcm->device); err = snd_soc_card_jack_new(card, jack_name, @@ -545,10 +545,10 @@ static int bxt_card_late_probe(struct snd_soc_card *card) i++; } - if (!codec) + if (!component) return -EINVAL; - return hdac_hdmi_jack_port_init(codec, &card->dapm); + return hdac_hdmi_jack_port_init(component, &card->dapm); } /* broxton audio machine driver for SPT + da7219 */ diff --git a/sound/soc/intel/boards/bxt_rt298.c b/sound/soc/intel/boards/bxt_rt298.c index 7843104fadcb..875d85119c66 100644 --- a/sound/soc/intel/boards/bxt_rt298.c +++ b/sound/soc/intel/boards/bxt_rt298.c @@ -167,7 +167,7 @@ static int broxton_rt298_fe_init(struct snd_soc_pcm_runtime *rtd) static int broxton_rt298_codec_init(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; int ret = 0; ret = snd_soc_card_jack_new(rtd->card, "Headset", @@ -178,7 +178,7 @@ static int broxton_rt298_codec_init(struct snd_soc_pcm_runtime *rtd) if (ret) return ret; - rt298_mic_detect(codec, &broxton_headset); + rt298_mic_detect(component, &broxton_headset); snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); @@ -496,12 +496,12 @@ static int bxt_card_late_probe(struct snd_soc_card *card) { struct bxt_rt286_private *ctx = snd_soc_card_get_drvdata(card); struct bxt_hdmi_pcm *pcm; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; int err, i = 0; char jack_name[NAME_SIZE]; list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { - codec = pcm->codec_dai->codec; + component = pcm->codec_dai->component; snprintf(jack_name, sizeof(jack_name), "HDMI/DP, pcm=%d Jack", pcm->device); err = snd_soc_card_jack_new(card, jack_name, @@ -519,10 +519,10 @@ static int bxt_card_late_probe(struct snd_soc_card *card) i++; } - if (!codec) + if (!component) return -EINVAL; - return hdac_hdmi_jack_port_init(codec, &card->dapm); + return hdac_hdmi_jack_port_init(component, &card->dapm); } diff --git a/sound/soc/intel/boards/kbl_rt5663_max98927.c b/sound/soc/intel/boards/kbl_rt5663_max98927.c index f5df6bca3156..3c9585eb6860 100644 --- a/sound/soc/intel/boards/kbl_rt5663_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_max98927.c @@ -272,7 +272,7 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd) { int ret; struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(rtd->card); - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; struct snd_soc_jack *jack; /* @@ -294,7 +294,7 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd) snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP); snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); - rt5663_set_jack_detect(codec, &ctx->kabylake_headset); + rt5663_set_jack_detect(component, &ctx->kabylake_headset); return ret; } @@ -448,7 +448,7 @@ static int kabylake_rt5663_hw_params(struct snd_pcm_substream *substream, int ret; /* use ASRC for internal clocks, as PLL rate isn't multiple of BCLK */ - rt5663_sel_asrc_clk_src(codec_dai->codec, + rt5663_sel_asrc_clk_src(codec_dai->component, RT5663_DA_STEREO_FILTER | RT5663_AD_STEREO_FILTER, RT5663_CLK_SEL_I2S1_ASRC); @@ -898,12 +898,12 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) { struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(card); struct kbl_hdmi_pcm *pcm; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; int err, i = 0; char jack_name[NAME_SIZE]; list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { - codec = pcm->codec_dai->codec; + component = pcm->codec_dai->component; snprintf(jack_name, sizeof(jack_name), "HDMI/DP, pcm=%d Jack", pcm->device); err = snd_soc_card_jack_new(card, jack_name, @@ -921,10 +921,10 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) i++; } - if (!codec) + if (!component) return -EINVAL; - return hdac_hdmi_jack_port_init(codec, &card->dapm); + return hdac_hdmi_jack_port_init(component, &card->dapm); } /* kabylake audio machine driver for SPT + RT5663 */ diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c index 90ea98f01c4c..69c3d8446f06 100644 --- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c @@ -178,7 +178,7 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd) { int ret; struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card); - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; struct snd_soc_jack *jack; /* @@ -200,7 +200,7 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd) snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP); snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); - rt5663_set_jack_detect(codec, &ctx->kabylake_headset); + rt5663_set_jack_detect(component, &ctx->kabylake_headset); ret = snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "DMIC"); if (ret) @@ -333,7 +333,7 @@ static int kabylake_rt5663_hw_params(struct snd_pcm_substream *substream, int ret; /* use ASRC for internal clocks, as PLL rate isn't multiple of BCLK */ - rt5663_sel_asrc_clk_src(codec_dai->codec, + rt5663_sel_asrc_clk_src(codec_dai->component, RT5663_DA_STEREO_FILTER | RT5663_AD_STEREO_FILTER, RT5663_CLK_SEL_I2S1_ASRC); @@ -599,12 +599,12 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) { struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card); struct kbl_hdmi_pcm *pcm; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; int err, i = 0; char jack_name[NAME_SIZE]; list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { - codec = pcm->codec_dai->codec; + component = pcm->codec_dai->component; snprintf(jack_name, sizeof(jack_name), "HDMI/DP,pcm=%d Jack", pcm->device); err = snd_soc_card_jack_new(card, jack_name, @@ -620,10 +620,10 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) i++; } - if (!codec) + if (!component) return -EINVAL; - return hdac_hdmi_jack_port_init(codec, &card->dapm); + return hdac_hdmi_jack_port_init(component, &card->dapm); } /* diff --git a/sound/soc/intel/boards/skl_nau88l25_max98357a.c b/sound/soc/intel/boards/skl_nau88l25_max98357a.c index 1b5a689dc99b..9a7a0646bffe 100644 --- a/sound/soc/intel/boards/skl_nau88l25_max98357a.c +++ b/sound/soc/intel/boards/skl_nau88l25_max98357a.c @@ -165,7 +165,7 @@ static int skylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd) { int ret; - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; /* * Headset buttons map to the google Reference headset. @@ -180,7 +180,7 @@ static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd) return ret; } - nau8825_enable_jack_detect(codec, &skylake_headset); + nau8825_enable_jack_detect(component, &skylake_headset); snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); @@ -592,12 +592,12 @@ static int skylake_card_late_probe(struct snd_soc_card *card) { struct skl_nau8825_private *ctx = snd_soc_card_get_drvdata(card); struct skl_hdmi_pcm *pcm; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; int err, i = 0; char jack_name[NAME_SIZE]; list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { - codec = pcm->codec_dai->codec; + component = pcm->codec_dai->component; snprintf(jack_name, sizeof(jack_name), "HDMI/DP, pcm=%d Jack", pcm->device); err = snd_soc_card_jack_new(card, jack_name, @@ -616,10 +616,10 @@ static int skylake_card_late_probe(struct snd_soc_card *card) i++; } - if (!codec) + if (!component) return -EINVAL; - return hdac_hdmi_jack_port_init(codec, &card->dapm); + return hdac_hdmi_jack_port_init(component, &card->dapm); } /* skylake audio machine driver for SPT + NAU88L25 */ diff --git a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c index 7bea4bc77481..212ac8971e55 100644 --- a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c +++ b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c @@ -195,7 +195,7 @@ static int skylake_ssm4567_codec_init(struct snd_soc_pcm_runtime *rtd) static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd) { int ret; - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; /* * 4 buttons here map to the google Reference headset @@ -210,7 +210,7 @@ static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd) return ret; } - nau8825_enable_jack_detect(codec, &skylake_headset); + nau8825_enable_jack_detect(component, &skylake_headset); snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); @@ -643,12 +643,12 @@ static int skylake_card_late_probe(struct snd_soc_card *card) { struct skl_nau88125_private *ctx = snd_soc_card_get_drvdata(card); struct skl_hdmi_pcm *pcm; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; int err, i = 0; char jack_name[NAME_SIZE]; list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { - codec = pcm->codec_dai->codec; + component = pcm->codec_dai->component; snprintf(jack_name, sizeof(jack_name), "HDMI/DP, pcm=%d Jack", pcm->device); err = snd_soc_card_jack_new(card, jack_name, @@ -667,10 +667,10 @@ static int skylake_card_late_probe(struct snd_soc_card *card) i++; } - if (!codec) + if (!component) return -EINVAL; - return hdac_hdmi_jack_port_init(codec, &card->dapm); + return hdac_hdmi_jack_port_init(component, &card->dapm); } /* skylake audio machine driver for SPT + NAU88L25 */ diff --git a/sound/soc/intel/boards/skl_rt286.c b/sound/soc/intel/boards/skl_rt286.c index 2bc4cfca594e..737d5615b0ef 100644 --- a/sound/soc/intel/boards/skl_rt286.c +++ b/sound/soc/intel/boards/skl_rt286.c @@ -130,7 +130,7 @@ static int skylake_rt286_fe_init(struct snd_soc_pcm_runtime *rtd) static int skylake_rt286_codec_init(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; int ret; ret = snd_soc_card_jack_new(rtd->card, "Headset", @@ -141,7 +141,7 @@ static int skylake_rt286_codec_init(struct snd_soc_pcm_runtime *rtd) if (ret) return ret; - rt286_mic_detect(codec, &skylake_headset); + rt286_mic_detect(component, &skylake_headset); snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); @@ -478,12 +478,12 @@ static int skylake_card_late_probe(struct snd_soc_card *card) { struct skl_rt286_private *ctx = snd_soc_card_get_drvdata(card); struct skl_hdmi_pcm *pcm; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; int err, i = 0; char jack_name[NAME_SIZE]; list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { - codec = pcm->codec_dai->codec; + component = pcm->codec_dai->component; snprintf(jack_name, sizeof(jack_name), "HDMI/DP, pcm=%d Jack", pcm->device); err = snd_soc_card_jack_new(card, jack_name, @@ -501,10 +501,10 @@ static int skylake_card_late_probe(struct snd_soc_card *card) i++; } - if (!codec) + if (!component) return -EINVAL; - return hdac_hdmi_jack_port_init(codec, &card->dapm); + return hdac_hdmi_jack_port_init(component, &card->dapm); } /* skylake audio machine driver for SPT + RT286S */ diff --git a/sound/soc/rockchip/rk3399_gru_sound.c b/sound/soc/rockchip/rk3399_gru_sound.c index 214bfc78cf5c..9a10181a0811 100644 --- a/sound/soc/rockchip/rk3399_gru_sound.c +++ b/sound/soc/rockchip/rk3399_gru_sound.c @@ -176,7 +176,7 @@ static int rockchip_sound_da7219_hw_params(struct snd_pcm_substream *substream, static int rockchip_sound_da7219_init(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_codec *codec = rtd->codec_dais[0]->codec; + struct snd_soc_component *component = rtd->codec_dais[0]->component; struct snd_soc_dai *codec_dai = rtd->codec_dai; int ret; @@ -215,7 +215,7 @@ static int rockchip_sound_da7219_init(struct snd_soc_pcm_runtime *rtd) snd_jack_set_key( rockchip_sound_jack.jack, SND_JACK_BTN_3, KEY_VOICECOMMAND); - da7219_aad_jack_det(codec, &rockchip_sound_jack); + da7219_aad_jack_det(component, &rockchip_sound_jack); return 0; } From bbf4d71aa9e21e8ee05e16cbb2cd2999252ce930 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:40:28 +0000 Subject: [PATCH 004/102] ASoC: remove rtd->platform checck Now, we are ready to replace rtd->platform to rtdcom list. From this patch, rtd->platform check is no longer needed. It will be replaced into rtdcom. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 96c44f6576c9..9558125b448d 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1162,11 +1162,6 @@ static int soc_bind_dai_link(struct snd_soc_card *card, rtd->platform = platform; } - if (!rtd->platform) { - dev_err(card->dev, "ASoC: platform %s not registered\n", - dai_link->platform_name); - goto _err_defer; - } soc_add_pcm_runtime(card, rtd); return 0; From 2d59ebd3e2531c48298e7bee6e621e04fccc4a72 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:40:52 +0000 Subject: [PATCH 005/102] ASoC: soc-utils: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/soc-utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c index bcd3da2739e2..e237858c9ed4 100644 --- a/sound/soc/soc-utils.c +++ b/sound/soc/soc-utils.c @@ -284,7 +284,7 @@ static const struct snd_pcm_ops dummy_dma_ops = { .ioctl = snd_pcm_lib_ioctl, }; -static const struct snd_soc_platform_driver dummy_platform = { +static const struct snd_soc_component_driver dummy_platform = { .ops = &dummy_dma_ops, }; @@ -342,7 +342,8 @@ static int snd_soc_dummy_probe(struct platform_device *pdev) if (ret < 0) return ret; - ret = snd_soc_register_platform(&pdev->dev, &dummy_platform); + ret = devm_snd_soc_register_component(&pdev->dev, &dummy_platform, + NULL, 0); if (ret < 0) { snd_soc_unregister_codec(&pdev->dev); return ret; @@ -353,7 +354,6 @@ static int snd_soc_dummy_probe(struct platform_device *pdev) static int snd_soc_dummy_remove(struct platform_device *pdev) { - snd_soc_unregister_platform(&pdev->dev); snd_soc_unregister_codec(&pdev->dev); return 0; From be7ee5f32a9a4eba881d18e85d58e9a03a9cca99 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:41:09 +0000 Subject: [PATCH 006/102] ASoC: soc-generic-dmaengine-pcm: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- include/sound/dmaengine_pcm.h | 2 + sound/soc/soc-generic-dmaengine-pcm.c | 55 ++++++++++++++++----------- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/include/sound/dmaengine_pcm.h b/include/sound/dmaengine_pcm.h index 67be2445941a..8a5a8404966e 100644 --- a/include/sound/dmaengine_pcm.h +++ b/include/sound/dmaengine_pcm.h @@ -161,4 +161,6 @@ int snd_dmaengine_pcm_prepare_slave_config(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct dma_slave_config *slave_config); +#define SND_DMAENGINE_PCM_DRV_NAME "snd_dmaengine_pcm" + #endif diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c index d53786498b61..c07d5c79ca91 100644 --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c @@ -33,13 +33,13 @@ struct dmaengine_pcm { struct dma_chan *chan[SNDRV_PCM_STREAM_LAST + 1]; const struct snd_dmaengine_pcm_config *config; - struct snd_soc_platform platform; + struct snd_soc_component component; unsigned int flags; }; -static struct dmaengine_pcm *soc_platform_to_pcm(struct snd_soc_platform *p) +static struct dmaengine_pcm *soc_component_to_pcm(struct snd_soc_component *p) { - return container_of(p, struct dmaengine_pcm, platform); + return container_of(p, struct dmaengine_pcm, component); } static struct device *dmaengine_dma_dev(struct dmaengine_pcm *pcm, @@ -88,7 +88,9 @@ static int dmaengine_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, SND_DMAENGINE_PCM_DRV_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream); int (*prepare_slave_config)(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, @@ -119,7 +121,9 @@ static int dmaengine_pcm_hw_params(struct snd_pcm_substream *substream, static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, SND_DMAENGINE_PCM_DRV_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); struct device *dma_dev = dmaengine_dma_dev(pcm, substream); struct dma_chan *chan = pcm->chan[substream->stream]; struct snd_dmaengine_dai_dma_data *dma_data; @@ -206,7 +210,9 @@ static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substrea static int dmaengine_pcm_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, SND_DMAENGINE_PCM_DRV_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); struct dma_chan *chan = pcm->chan[substream->stream]; int ret; @@ -221,7 +227,9 @@ static struct dma_chan *dmaengine_pcm_compat_request_channel( struct snd_soc_pcm_runtime *rtd, struct snd_pcm_substream *substream) { - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, SND_DMAENGINE_PCM_DRV_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); struct snd_dmaengine_dai_dma_data *dma_data; dma_filter_fn fn = NULL; @@ -260,9 +268,11 @@ static bool dmaengine_pcm_can_report_residue(struct device *dev, static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd) { - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, SND_DMAENGINE_PCM_DRV_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); const struct snd_dmaengine_pcm_config *config = pcm->config; - struct device *dev = rtd->platform->dev; + struct device *dev = component->dev; struct snd_dmaengine_dai_dma_data *dma_data; struct snd_pcm_substream *substream; size_t prealloc_buffer_size; @@ -296,7 +306,7 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd) } if (!pcm->chan[i]) { - dev_err(rtd->platform->dev, + dev_err(component->dev, "Missing dma channel for stream: %d\n", i); return -EINVAL; } @@ -320,7 +330,9 @@ static snd_pcm_uframes_t dmaengine_pcm_pointer( struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, SND_DMAENGINE_PCM_DRV_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); if (pcm->flags & SND_DMAENGINE_PCM_FLAG_NO_RESIDUE) return snd_dmaengine_pcm_pointer_no_residue(substream); @@ -338,10 +350,9 @@ static const struct snd_pcm_ops dmaengine_pcm_ops = { .pointer = dmaengine_pcm_pointer, }; -static const struct snd_soc_platform_driver dmaengine_pcm_platform = { - .component_driver = { - .probe_order = SND_SOC_COMP_ORDER_LATE, - }, +static const struct snd_soc_component_driver dmaengine_pcm_component = { + .name = SND_DMAENGINE_PCM_DRV_NAME, + .probe_order = SND_SOC_COMP_ORDER_LATE, .ops = &dmaengine_pcm_ops, .pcm_new = dmaengine_pcm_new, }; @@ -438,8 +449,8 @@ int snd_dmaengine_pcm_register(struct device *dev, if (ret) goto err_free_dma; - ret = snd_soc_add_platform(dev, &pcm->platform, - &dmaengine_pcm_platform); + ret = snd_soc_add_component(dev, &pcm->component, + &dmaengine_pcm_component, NULL, 0); if (ret) goto err_free_dma; @@ -461,16 +472,16 @@ EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_register); */ void snd_dmaengine_pcm_unregister(struct device *dev) { - struct snd_soc_platform *platform; + struct snd_soc_component *component; struct dmaengine_pcm *pcm; - platform = snd_soc_lookup_platform(dev); - if (!platform) + component = snd_soc_lookup_component(dev, SND_DMAENGINE_PCM_DRV_NAME); + if (!component) return; - pcm = soc_platform_to_pcm(platform); + pcm = soc_component_to_pcm(component); - snd_soc_remove_platform(platform); + snd_soc_unregister_component(dev); dmaengine_pcm_release_chan(pcm); kfree(pcm); } From 6840962b0a19c2716f01f4274f24e153c8ca045c Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:41:28 +0000 Subject: [PATCH 007/102] ASoC: intel: atom: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Tested-by: "Kp, Jeeja" Signed-off-by: Mark Brown --- sound/soc/intel/atom/sst-atom-controls.c | 36 +++++++++---------- .../intel/atom/sst-mfld-platform-compress.c | 4 +-- sound/soc/intel/atom/sst-mfld-platform-pcm.c | 32 +++++------------ sound/soc/intel/atom/sst-mfld-platform.h | 4 ++- 4 files changed, 32 insertions(+), 44 deletions(-) diff --git a/sound/soc/intel/atom/sst-atom-controls.c b/sound/soc/intel/atom/sst-atom-controls.c index 0f3604b55942..3672d36b4b66 100644 --- a/sound/soc/intel/atom/sst-atom-controls.c +++ b/sound/soc/intel/atom/sst-atom-controls.c @@ -1414,11 +1414,11 @@ static int sst_fill_module_list(struct snd_kcontrol *kctl, * name. First part of control name contains the pipe name (widget name). */ static int sst_fill_widget_module_info(struct snd_soc_dapm_widget *w, - struct snd_soc_platform *platform) + struct snd_soc_component *component) { struct snd_kcontrol *kctl; int index, ret = 0; - struct snd_card *card = platform->component.card->snd_card; + struct snd_card *card = component->card->snd_card; char *idx; down_read(&card->controls_rwsem); @@ -1468,13 +1468,13 @@ static int sst_fill_widget_module_info(struct snd_soc_dapm_widget *w, /** * sst_fill_linked_widgets - fill the parent pointer for the linked widget */ -static void sst_fill_linked_widgets(struct snd_soc_platform *platform, +static void sst_fill_linked_widgets(struct snd_soc_component *component, struct sst_ids *ids) { struct snd_soc_dapm_widget *w; unsigned int len = strlen(ids->parent_wname); - list_for_each_entry(w, &platform->component.card->widgets, list) { + list_for_each_entry(w, &component->card->widgets, list) { if (!strncmp(ids->parent_wname, w->name, len)) { ids->parent_w = w; break; @@ -1485,41 +1485,41 @@ static void sst_fill_linked_widgets(struct snd_soc_platform *platform, /** * sst_map_modules_to_pipe - fill algo/gains list for all pipes */ -static int sst_map_modules_to_pipe(struct snd_soc_platform *platform) +static int sst_map_modules_to_pipe(struct snd_soc_component *component) { struct snd_soc_dapm_widget *w; int ret = 0; - list_for_each_entry(w, &platform->component.card->widgets, list) { + list_for_each_entry(w, &component->card->widgets, list) { if (is_sst_dapm_widget(w) && (w->priv)) { struct sst_ids *ids = w->priv; - dev_dbg(platform->dev, "widget type=%d name=%s\n", + dev_dbg(component->dev, "widget type=%d name=%s\n", w->id, w->name); INIT_LIST_HEAD(&ids->algo_list); INIT_LIST_HEAD(&ids->gain_list); - ret = sst_fill_widget_module_info(w, platform); + ret = sst_fill_widget_module_info(w, component); if (ret < 0) return ret; /* fill linked widgets */ if (ids->parent_wname != NULL) - sst_fill_linked_widgets(platform, ids); + sst_fill_linked_widgets(component, ids); } } return 0; } -int sst_dsp_init_v2_dpcm(struct snd_soc_platform *platform) +int sst_dsp_init_v2_dpcm(struct snd_soc_component *component) { int i, ret = 0; struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(&platform->component); - struct sst_data *drv = snd_soc_platform_get_drvdata(platform); + snd_soc_component_get_dapm(component); + struct sst_data *drv = snd_soc_component_get_drvdata(component); unsigned int gains = ARRAY_SIZE(sst_gain_controls)/3; - drv->byte_stream = devm_kzalloc(platform->dev, + drv->byte_stream = devm_kzalloc(component->dev, SST_MAX_BIN_BYTES, GFP_KERNEL); if (!drv->byte_stream) return -ENOMEM; @@ -1537,26 +1537,26 @@ int sst_dsp_init_v2_dpcm(struct snd_soc_platform *platform) sst_gains[i].ramp_duration = SST_GAIN_RAMP_DURATION_DEFAULT; } - ret = snd_soc_add_platform_controls(platform, sst_gain_controls, + ret = snd_soc_add_component_controls(component, sst_gain_controls, ARRAY_SIZE(sst_gain_controls)); if (ret) return ret; /* Initialize algo control params */ - ret = sst_algo_control_init(platform->dev); + ret = sst_algo_control_init(component->dev); if (ret) return ret; - ret = snd_soc_add_platform_controls(platform, sst_algo_controls, + ret = snd_soc_add_component_controls(component, sst_algo_controls, ARRAY_SIZE(sst_algo_controls)); if (ret) return ret; - ret = snd_soc_add_platform_controls(platform, sst_slot_controls, + ret = snd_soc_add_component_controls(component, sst_slot_controls, ARRAY_SIZE(sst_slot_controls)); if (ret) return ret; - ret = sst_map_modules_to_pipe(platform); + ret = sst_map_modules_to_pipe(component); return ret; } diff --git a/sound/soc/intel/atom/sst-mfld-platform-compress.c b/sound/soc/intel/atom/sst-mfld-platform-compress.c index 1dbcab5a6ff0..6a44b19423cf 100644 --- a/sound/soc/intel/atom/sst-mfld-platform-compress.c +++ b/sound/soc/intel/atom/sst-mfld-platform-compress.c @@ -107,8 +107,8 @@ static int sst_platform_compr_set_params(struct snd_compr_stream *cstream, struct snd_sst_params str_params; struct sst_compress_cb cb; struct snd_soc_pcm_runtime *rtd = cstream->private_data; - struct snd_soc_platform *platform = rtd->platform; - struct sst_data *ctx = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_data *ctx = snd_soc_component_get_drvdata(component); stream = cstream->runtime->private_data; /* construct fw structure for this*/ diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c index 43e7fdd19f29..6c36da560877 100644 --- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c +++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c @@ -697,26 +697,22 @@ static int sst_pcm_new(struct snd_soc_pcm_runtime *rtd) return retval; } -static int sst_soc_probe(struct snd_soc_platform *platform) +static int sst_soc_probe(struct snd_soc_component *component) { - struct sst_data *drv = dev_get_drvdata(platform->dev); + struct sst_data *drv = dev_get_drvdata(component->dev); - drv->soc_card = platform->component.card; - return sst_dsp_init_v2_dpcm(platform); + drv->soc_card = component->card; + return sst_dsp_init_v2_dpcm(component); } -static const struct snd_soc_platform_driver sst_soc_platform_drv = { +static const struct snd_soc_component_driver sst_soc_platform_drv = { + .name = DRV_NAME, .probe = sst_soc_probe, .ops = &sst_platform_ops, .compr_ops = &sst_platform_compr_ops, .pcm_new = sst_pcm_new, }; -static const struct snd_soc_component_driver sst_component = { - .name = "sst", -}; - - static int sst_platform_probe(struct platform_device *pdev) { struct sst_data *drv; @@ -740,26 +736,16 @@ static int sst_platform_probe(struct platform_device *pdev) mutex_init(&drv->lock); dev_set_drvdata(&pdev->dev, drv); - ret = snd_soc_register_platform(&pdev->dev, &sst_soc_platform_drv); - if (ret) { - dev_err(&pdev->dev, "registering soc platform failed\n"); - return ret; - } - - ret = snd_soc_register_component(&pdev->dev, &sst_component, + ret = devm_snd_soc_register_component(&pdev->dev, &sst_soc_platform_drv, sst_platform_dai, ARRAY_SIZE(sst_platform_dai)); - if (ret) { + if (ret) dev_err(&pdev->dev, "registering cpu dais failed\n"); - snd_soc_unregister_platform(&pdev->dev); - } + return ret; } static int sst_platform_remove(struct platform_device *pdev) { - - snd_soc_unregister_component(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); dev_dbg(&pdev->dev, "sst_platform_remove success\n"); return 0; } diff --git a/sound/soc/intel/atom/sst-mfld-platform.h b/sound/soc/intel/atom/sst-mfld-platform.h index 31a58c25472c..5f729df57bb5 100644 --- a/sound/soc/intel/atom/sst-mfld-platform.h +++ b/sound/soc/intel/atom/sst-mfld-platform.h @@ -27,6 +27,8 @@ extern struct sst_device *sst; extern const struct snd_compr_ops sst_platform_compr_ops; +#define DRV_NAME "sst" + #define SST_MONO 1 #define SST_STEREO 2 #define SST_MAX_CAP 5 @@ -155,7 +157,7 @@ struct sst_device { struct sst_data; -int sst_dsp_init_v2_dpcm(struct snd_soc_platform *platform); +int sst_dsp_init_v2_dpcm(struct snd_soc_component *component); int sst_send_pipe_gains(struct snd_soc_dai *dai, int stream, int mute); int send_ssp_cmd(struct snd_soc_dai *dai, const char *id, bool enable); int sst_handle_vb_timer(struct snd_soc_dai *dai, bool enable); From 56b03b4c4f5e8e1a44328b2df75bfb31fc4c3609 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:41:43 +0000 Subject: [PATCH 008/102] ASoC: intel: skylake: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Tested-by: "Kp, Jeeja" Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-debug.c | 2 +- sound/soc/intel/skylake/skl-pcm.c | 52 +++++++++----------------- sound/soc/intel/skylake/skl-topology.c | 26 ++++++------- sound/soc/intel/skylake/skl-topology.h | 2 +- sound/soc/intel/skylake/skl.h | 2 +- 5 files changed, 34 insertions(+), 50 deletions(-) diff --git a/sound/soc/intel/skylake/skl-debug.c b/sound/soc/intel/skylake/skl-debug.c index dc20d91f62e6..a016455a6ddb 100644 --- a/sound/soc/intel/skylake/skl-debug.c +++ b/sound/soc/intel/skylake/skl-debug.c @@ -231,7 +231,7 @@ struct skl_debug *skl_debugfs_init(struct skl *skl) /* create the debugfs dir with platform component's debugfs as parent */ d->fs = debugfs_create_dir("dsp", - skl->platform->component.debugfs_root); + skl->component->debugfs_root); if (IS_ERR(d->fs) || !d->fs) { dev_err(&skl->pci->dev, "debugfs root creation failed\n"); return NULL; diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c index e46828533826..36a521562cf7 100644 --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c @@ -1313,23 +1313,23 @@ static int skl_populate_modules(struct skl *skl) return ret; } -static int skl_platform_soc_probe(struct snd_soc_platform *platform) +static int skl_platform_soc_probe(struct snd_soc_component *component) { - struct hdac_ext_bus *ebus = dev_get_drvdata(platform->dev); + struct hdac_ext_bus *ebus = dev_get_drvdata(component->dev); struct skl *skl = ebus_to_skl(ebus); const struct skl_dsp_ops *ops; int ret; - pm_runtime_get_sync(platform->dev); + pm_runtime_get_sync(component->dev); if ((ebus_to_hbus(ebus))->ppcap) { - skl->platform = platform; + skl->component = component; /* init debugfs */ skl->debugfs = skl_debugfs_init(skl); - ret = skl_tplg_init(platform, ebus); + ret = skl_tplg_init(component, ebus); if (ret < 0) { - dev_err(platform->dev, "Failed to init topology!\n"); + dev_err(component->dev, "Failed to init topology!\n"); return ret; } @@ -1339,17 +1339,17 @@ static int skl_platform_soc_probe(struct snd_soc_platform *platform) return -EIO; if (skl->skl_sst->is_first_boot == false) { - dev_err(platform->dev, "DSP reports first boot done!!!\n"); + dev_err(component->dev, "DSP reports first boot done!!!\n"); return -EIO; } /* disable dynamic clock gating during fw and lib download */ - skl->skl_sst->enable_miscbdcge(platform->dev, false); + skl->skl_sst->enable_miscbdcge(component->dev, false); - ret = ops->init_fw(platform->dev, skl->skl_sst); - skl->skl_sst->enable_miscbdcge(platform->dev, true); + ret = ops->init_fw(component->dev, skl->skl_sst); + skl->skl_sst->enable_miscbdcge(component->dev, true); if (ret < 0) { - dev_err(platform->dev, "Failed to boot first fw: %d\n", ret); + dev_err(component->dev, "Failed to boot first fw: %d\n", ret); return ret; } skl_populate_modules(skl); @@ -1362,22 +1362,20 @@ static int skl_platform_soc_probe(struct snd_soc_platform *platform) skl->cfg.astate_cfg); } } - pm_runtime_mark_last_busy(platform->dev); - pm_runtime_put_autosuspend(platform->dev); + pm_runtime_mark_last_busy(component->dev); + pm_runtime_put_autosuspend(component->dev); return 0; } -static const struct snd_soc_platform_driver skl_platform_drv = { + +static const struct snd_soc_component_driver skl_component = { + .name = "pcm", .probe = skl_platform_soc_probe, .ops = &skl_platform_ops, .pcm_new = skl_pcm_new, .pcm_free = skl_pcm_free, }; -static const struct snd_soc_component_driver skl_component = { - .name = "pcm", -}; - int skl_platform_register(struct device *dev) { int ret; @@ -1389,12 +1387,6 @@ int skl_platform_register(struct device *dev) INIT_LIST_HEAD(&skl->ppl_list); INIT_LIST_HEAD(&skl->bind_list); - ret = snd_soc_register_platform(dev, &skl_platform_drv); - if (ret) { - dev_err(dev, "soc platform registration failed %d\n", ret); - return ret; - } - skl->dais = kmemdup(skl_platform_dai, sizeof(skl_platform_dai), GFP_KERNEL); if (!skl->dais) { @@ -1416,18 +1408,12 @@ int skl_platform_register(struct device *dev) num_dais += ARRAY_SIZE(skl_fe_dai); } - ret = snd_soc_register_component(dev, &skl_component, + ret = devm_snd_soc_register_component(dev, &skl_component, skl->dais, num_dais); - if (ret) { + if (ret) dev_err(dev, "soc component registration failed %d\n", ret); - goto err; - } - - return 0; err: - snd_soc_unregister_platform(dev); return ret; - } int skl_platform_unregister(struct device *dev) @@ -1443,8 +1429,6 @@ int skl_platform_unregister(struct device *dev) } } - snd_soc_unregister_component(dev); - snd_soc_unregister_platform(dev); kfree(skl->dais); return 0; diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index 73af6e19ebbd..515e4b6d1950 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c @@ -2710,15 +2710,15 @@ static int skl_tplg_get_pvt_data(struct snd_soc_tplg_dapm_widget *tplg_w, return 0; } -static void skl_clear_pin_config(struct snd_soc_platform *platform, +static void skl_clear_pin_config(struct snd_soc_component *component, struct snd_soc_dapm_widget *w) { int i; struct skl_module_cfg *mconfig; struct skl_pipe *pipe; - if (!strncmp(w->dapm->component->name, platform->component.name, - strlen(platform->component.name))) { + if (!strncmp(w->dapm->component->name, component->name, + strlen(component->name))) { mconfig = w->priv; pipe = mconfig->pipe; for (i = 0; i < mconfig->module->max_input_pins; i++) { @@ -2737,14 +2737,14 @@ static void skl_clear_pin_config(struct snd_soc_platform *platform, void skl_cleanup_resources(struct skl *skl) { struct skl_sst *ctx = skl->skl_sst; - struct snd_soc_platform *soc_platform = skl->platform; + struct snd_soc_component *soc_component = skl->component; struct snd_soc_dapm_widget *w; struct snd_soc_card *card; - if (soc_platform == NULL) + if (soc_component == NULL) return; - card = soc_platform->component.card; + card = soc_component->card; if (!card || !card->instantiated) return; @@ -2753,7 +2753,7 @@ void skl_cleanup_resources(struct skl *skl) list_for_each_entry(w, &card->widgets, list) { if (is_skl_dsp_widget_type(w) && (w->priv != NULL)) - skl_clear_pin_config(soc_platform, w); + skl_clear_pin_config(soc_component, w); } skl_clear_module_cnt(ctx->dsp); @@ -3400,19 +3400,19 @@ static struct snd_soc_tplg_ops skl_tplg_ops = { * widgets in a pipelines, so this helper - skl_tplg_create_pipe_widget_list() * helps to get the SKL type widgets in that pipeline */ -static int skl_tplg_create_pipe_widget_list(struct snd_soc_platform *platform) +static int skl_tplg_create_pipe_widget_list(struct snd_soc_component *component) { struct snd_soc_dapm_widget *w; struct skl_module_cfg *mcfg = NULL; struct skl_pipe_module *p_module = NULL; struct skl_pipe *pipe; - list_for_each_entry(w, &platform->component.card->widgets, list) { + list_for_each_entry(w, &component->card->widgets, list) { if (is_skl_dsp_widget_type(w) && w->priv != NULL) { mcfg = w->priv; pipe = mcfg->pipe; - p_module = devm_kzalloc(platform->dev, + p_module = devm_kzalloc(component->dev, sizeof(*p_module), GFP_KERNEL); if (!p_module) return -ENOMEM; @@ -3455,7 +3455,7 @@ static void skl_tplg_set_pipe_type(struct skl *skl, struct skl_pipe *pipe) /* * SKL topology init routine */ -int skl_tplg_init(struct snd_soc_platform *platform, struct hdac_ext_bus *ebus) +int skl_tplg_init(struct snd_soc_component *component, struct hdac_ext_bus *ebus) { int ret; const struct firmware *fw; @@ -3479,7 +3479,7 @@ int skl_tplg_init(struct snd_soc_platform *platform, struct hdac_ext_bus *ebus) * The complete tplg for SKL is loaded as index 0, we don't use * any other index */ - ret = snd_soc_tplg_component_load(&platform->component, + ret = snd_soc_tplg_component_load(component, &skl_tplg_ops, fw, 0); if (ret < 0) { dev_err(bus->dev, "tplg component load failed%d\n", ret); @@ -3491,7 +3491,7 @@ int skl_tplg_init(struct snd_soc_platform *platform, struct hdac_ext_bus *ebus) skl->resource.max_mem = SKL_FW_MAX_MEM; skl->tplg = fw; - ret = skl_tplg_create_pipe_widget_list(platform); + ret = skl_tplg_create_pipe_widget_list(component); if (ret < 0) return ret; diff --git a/sound/soc/intel/skylake/skl-topology.h b/sound/soc/intel/skylake/skl-topology.h index b6496513fe55..87c946835705 100644 --- a/sound/soc/intel/skylake/skl-topology.h +++ b/sound/soc/intel/skylake/skl-topology.h @@ -460,7 +460,7 @@ int skl_dsp_set_dma_control(struct skl_sst *ctx, u32 *caps, u32 caps_size, u32 node_id); void skl_tplg_set_be_dmic_config(struct snd_soc_dai *dai, struct skl_pipe_params *params, int stream); -int skl_tplg_init(struct snd_soc_platform *platform, +int skl_tplg_init(struct snd_soc_component *component, struct hdac_ext_bus *ebus); struct skl_module_cfg *skl_tplg_fe_get_cpr_module( struct snd_soc_dai *dai, int stream); diff --git a/sound/soc/intel/skylake/skl.h b/sound/soc/intel/skylake/skl.h index 2d13f3fd988a..ca46ad1d0a08 100644 --- a/sound/soc/intel/skylake/skl.h +++ b/sound/soc/intel/skylake/skl.h @@ -74,7 +74,7 @@ struct skl { struct platform_device *dmic_dev; struct platform_device *i2s_dev; struct platform_device *clk_dev; - struct snd_soc_platform *platform; + struct snd_soc_component *component; struct snd_soc_dai_driver *dais; struct nhlt_acpi_table *nhlt; /* nhlt ptr */ From 81dc5f3d806ad50283b4b58abebd08ef65817f87 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:42:02 +0000 Subject: [PATCH 009/102] ASoC: intel: baytrail: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/intel/baytrail/sst-baytrail-pcm.c | 66 ++++++++------------- 1 file changed, 25 insertions(+), 41 deletions(-) diff --git a/sound/soc/intel/baytrail/sst-baytrail-pcm.c b/sound/soc/intel/baytrail/sst-baytrail-pcm.c index c54529320f07..aabb35bf6b96 100644 --- a/sound/soc/intel/baytrail/sst-baytrail-pcm.c +++ b/sound/soc/intel/baytrail/sst-baytrail-pcm.c @@ -23,6 +23,7 @@ #include "../common/sst-dsp-priv.h" #include "../common/sst-dsp.h" +#define DRV_NAME "byt-dai" #define BYT_PCM_COUNT 2 static const struct snd_pcm_hardware sst_byt_pcm_hardware = { @@ -69,8 +70,8 @@ static int sst_byt_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream]; struct sst_byt *byt = pdata->byt; u32 rate, bits; @@ -141,8 +142,8 @@ static int sst_byt_pcm_hw_free(struct snd_pcm_substream *substream) static int sst_byt_pcm_restore_stream_context(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream]; struct sst_byt *byt = pdata->byt; int ret; @@ -174,8 +175,8 @@ static void sst_byt_pcm_work(struct work_struct *work) static int sst_byt_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream]; struct sst_byt *byt = pdata->byt; @@ -216,8 +217,8 @@ static u32 byt_notify_pointer(struct sst_byt_stream *stream, void *data) struct snd_pcm_substream *substream = pcm_data->substream; struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt *byt = pdata->byt; u32 pos, hw_pos; @@ -238,8 +239,8 @@ static snd_pcm_uframes_t sst_byt_pcm_pointer(struct snd_pcm_substream *substream { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream]; dev_dbg(rtd->dev, "PCM: DMA pointer %u bytes\n", pcm_data->hw_ptr); @@ -250,8 +251,8 @@ static snd_pcm_uframes_t sst_byt_pcm_pointer(struct snd_pcm_substream *substream static int sst_byt_pcm_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream]; struct sst_byt *byt = pdata->byt; @@ -278,8 +279,8 @@ static int sst_byt_pcm_open(struct snd_pcm_substream *substream) static int sst_byt_pcm_close(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream]; struct sst_byt *byt = pdata->byt; int ret; @@ -324,8 +325,8 @@ static int sst_byt_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_pcm *pcm = rtd->pcm; size_t size; - struct snd_soc_platform *platform = rtd->platform; - struct sst_pdata *pdata = dev_get_platdata(platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_pdata *pdata = dev_get_platdata(component->dev); int ret = 0; if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream || @@ -366,21 +367,21 @@ static struct snd_soc_dai_driver byt_dais[] = { }, }; -static int sst_byt_pcm_probe(struct snd_soc_platform *platform) +static int sst_byt_pcm_probe(struct snd_soc_component *component) { - struct sst_pdata *plat_data = dev_get_platdata(platform->dev); + struct sst_pdata *plat_data = dev_get_platdata(component->dev); struct sst_byt_priv_data *priv_data; int i; if (!plat_data) return -ENODEV; - priv_data = devm_kzalloc(platform->dev, sizeof(*priv_data), + priv_data = devm_kzalloc(component->dev, sizeof(*priv_data), GFP_KERNEL); if (!priv_data) return -ENOMEM; priv_data->byt = plat_data->dsp; - snd_soc_platform_set_drvdata(platform, priv_data); + snd_soc_component_set_drvdata(component, priv_data); for (i = 0; i < BYT_PCM_COUNT; i++) { mutex_init(&priv_data->pcm[i].mutex); @@ -390,22 +391,13 @@ static int sst_byt_pcm_probe(struct snd_soc_platform *platform) return 0; } -static int sst_byt_pcm_remove(struct snd_soc_platform *platform) -{ - return 0; -} - -static const struct snd_soc_platform_driver byt_soc_platform = { +static const struct snd_soc_component_driver byt_dai_component = { + .name = DRV_NAME, .probe = sst_byt_pcm_probe, - .remove = sst_byt_pcm_remove, .ops = &sst_byt_pcm_ops, .pcm_new = sst_byt_pcm_new, }; -static const struct snd_soc_component_driver byt_dai_component = { - .name = "byt-dai", -}; - #ifdef CONFIG_PM static int sst_byt_pcm_dev_suspend_late(struct device *dev) { @@ -461,19 +453,13 @@ static int sst_byt_pcm_dev_probe(struct platform_device *pdev) if (ret < 0) return -ENODEV; - ret = snd_soc_register_platform(&pdev->dev, &byt_soc_platform); + ret = devm_snd_soc_register_component(&pdev->dev, &byt_dai_component, + byt_dais, ARRAY_SIZE(byt_dais)); if (ret < 0) goto err_plat; - ret = snd_soc_register_component(&pdev->dev, &byt_dai_component, - byt_dais, ARRAY_SIZE(byt_dais)); - if (ret < 0) - goto err_comp; - return 0; -err_comp: - snd_soc_unregister_platform(&pdev->dev); err_plat: sst_byt_dsp_free(&pdev->dev, sst_pdata); return ret; @@ -483,8 +469,6 @@ static int sst_byt_pcm_dev_remove(struct platform_device *pdev) { struct sst_pdata *sst_pdata = dev_get_platdata(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); - snd_soc_unregister_component(&pdev->dev); sst_byt_dsp_free(&pdev->dev, sst_pdata); return 0; From 2ee178dbeb3974676b23751d602f79cc276f46e4 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:42:21 +0000 Subject: [PATCH 010/102] ASoC: intel: haswell: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/intel/boards/bdw-rt5677.c | 3 +- sound/soc/intel/boards/broadwell.c | 3 +- sound/soc/intel/boards/haswell.c | 3 +- sound/soc/intel/haswell/sst-haswell-ipc.h | 2 + sound/soc/intel/haswell/sst-haswell-pcm.c | 118 ++++++++++------------ 5 files changed, 60 insertions(+), 69 deletions(-) diff --git a/sound/soc/intel/boards/bdw-rt5677.c b/sound/soc/intel/boards/bdw-rt5677.c index 058b8ccedf02..8999f8de119c 100644 --- a/sound/soc/intel/boards/bdw-rt5677.c +++ b/sound/soc/intel/boards/bdw-rt5677.c @@ -183,7 +183,8 @@ static const struct snd_soc_ops bdw_rt5677_ops = { static int bdw_rt5677_rtd_init(struct snd_soc_pcm_runtime *rtd) { - struct sst_pdata *pdata = dev_get_platdata(rtd->platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_pdata *pdata = dev_get_platdata(component->dev); struct sst_hsw *broadwell = pdata->dsp; int ret; diff --git a/sound/soc/intel/boards/broadwell.c b/sound/soc/intel/boards/broadwell.c index 6dcbbcefc25b..249b8a3290b8 100644 --- a/sound/soc/intel/boards/broadwell.c +++ b/sound/soc/intel/boards/broadwell.c @@ -132,7 +132,8 @@ static const struct snd_soc_ops broadwell_rt286_ops = { static int broadwell_rtd_init(struct snd_soc_pcm_runtime *rtd) { - struct sst_pdata *pdata = dev_get_platdata(rtd->platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_pdata *pdata = dev_get_platdata(component->dev); struct sst_hsw *broadwell = pdata->dsp; int ret; diff --git a/sound/soc/intel/boards/haswell.c b/sound/soc/intel/boards/haswell.c index 3c5160779204..eab1f439dd3f 100644 --- a/sound/soc/intel/boards/haswell.c +++ b/sound/soc/intel/boards/haswell.c @@ -87,7 +87,8 @@ static const struct snd_soc_ops haswell_rt5640_ops = { static int haswell_rtd_init(struct snd_soc_pcm_runtime *rtd) { - struct sst_pdata *pdata = dev_get_platdata(rtd->platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_pdata *pdata = dev_get_platdata(component->dev); struct sst_hsw *haswell = pdata->dsp; int ret; diff --git a/sound/soc/intel/haswell/sst-haswell-ipc.h b/sound/soc/intel/haswell/sst-haswell-ipc.h index 06d71aefa1fe..fbc14df139e4 100644 --- a/sound/soc/intel/haswell/sst-haswell-ipc.h +++ b/sound/soc/intel/haswell/sst-haswell-ipc.h @@ -22,6 +22,8 @@ #include #include +#define DRV_NAME "haswell-dai" + #define SST_HSW_NO_CHANNELS 4 #define SST_HSW_MAX_DX_REGIONS 14 #define SST_HSW_DX_CONTEXT_SIZE (640 * 1024) diff --git a/sound/soc/intel/haswell/sst-haswell-pcm.c b/sound/soc/intel/haswell/sst-haswell-pcm.c index c044400540ec..fe2c826e710c 100644 --- a/sound/soc/intel/haswell/sst-haswell-pcm.c +++ b/sound/soc/intel/haswell/sst-haswell-pcm.c @@ -181,11 +181,11 @@ static inline unsigned int hsw_ipc_to_mixer(u32 value) static int hsw_stream_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(platform); + snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; u32 volume; @@ -230,11 +230,11 @@ static int hsw_stream_volume_put(struct snd_kcontrol *kcontrol, static int hsw_stream_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(platform); + snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; u32 volume; @@ -273,8 +273,8 @@ static int hsw_stream_volume_get(struct snd_kcontrol *kcontrol, static int hsw_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); - struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; u32 volume; @@ -302,8 +302,8 @@ static int hsw_volume_put(struct snd_kcontrol *kcontrol, static int hsw_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); - struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; unsigned int volume = 0; @@ -322,8 +322,8 @@ static int hsw_volume_get(struct snd_kcontrol *kcontrol, static int hsw_waves_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); - struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; enum sst_hsw_module_id id = SST_HSW_MODULE_WAVES; @@ -336,8 +336,8 @@ static int hsw_waves_switch_get(struct snd_kcontrol *kcontrol, static int hsw_waves_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); - struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; int ret = 0; enum sst_hsw_module_id id = SST_HSW_MODULE_WAVES; @@ -370,8 +370,8 @@ static int hsw_waves_switch_put(struct snd_kcontrol *kcontrol, static int hsw_waves_param_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); - struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; /* return a matching line from param buffer */ @@ -381,8 +381,8 @@ static int hsw_waves_param_get(struct snd_kcontrol *kcontrol, static int hsw_waves_param_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); - struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; int ret; enum sst_hsw_module_id id = SST_HSW_MODULE_WAVES; @@ -472,8 +472,8 @@ static int hsw_pcm_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; - struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; struct sst_module *module_data; @@ -674,8 +674,8 @@ static int hsw_pcm_hw_free(struct snd_pcm_substream *substream) static int hsw_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw_stream *sst_stream; struct sst_hsw *hsw = pdata->hsw; @@ -718,8 +718,8 @@ static u32 hsw_notify_pointer(struct sst_hsw_stream *stream, void *data) struct snd_pcm_substream *substream = pcm_data->substream; struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; u32 pos; snd_pcm_uframes_t position = bytes_to_frames(runtime, @@ -783,8 +783,8 @@ static snd_pcm_uframes_t hsw_pcm_pointer(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; - struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; snd_pcm_uframes_t offset; @@ -807,8 +807,8 @@ static snd_pcm_uframes_t hsw_pcm_pointer(struct snd_pcm_substream *substream) static int hsw_pcm_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; int dai; @@ -840,8 +840,8 @@ static int hsw_pcm_open(struct snd_pcm_substream *substream) static int hsw_pcm_close(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; int ret, dai; @@ -942,9 +942,9 @@ static void hsw_pcm_free_modules(struct hsw_priv_data *pdata) static int hsw_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_pcm *pcm = rtd->pcm; - struct snd_soc_platform *platform = rtd->platform; - struct sst_pdata *pdata = dev_get_platdata(platform->dev); - struct hsw_priv_data *priv_data = dev_get_drvdata(platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_pdata *pdata = dev_get_platdata(component->dev); + struct hsw_priv_data *priv_data = dev_get_drvdata(component->dev); struct device *dev = pdata->dma_dev; int ret = 0; @@ -1052,23 +1052,23 @@ static const struct snd_soc_dapm_route graph[] = { {"Analog Capture", NULL, "SSP0 CODEC IN"}, }; -static int hsw_pcm_probe(struct snd_soc_platform *platform) +static int hsw_pcm_probe(struct snd_soc_component *component) { - struct hsw_priv_data *priv_data = snd_soc_platform_get_drvdata(platform); - struct sst_pdata *pdata = dev_get_platdata(platform->dev); + struct hsw_priv_data *priv_data = snd_soc_component_get_drvdata(component); + struct sst_pdata *pdata = dev_get_platdata(component->dev); struct device *dma_dev, *dev; int i, ret = 0; if (!pdata) return -ENODEV; - dev = platform->dev; + dev = component->dev; dma_dev = pdata->dma_dev; priv_data->hsw = pdata->dsp; - priv_data->dev = platform->dev; + priv_data->dev = dev; priv_data->pm_state = HSW_PM_STATE_D0; - priv_data->soc_card = platform->component.card; + priv_data->soc_card = component->card; /* allocate DSP buffer page tables */ for (i = 0; i < ARRAY_SIZE(hsw_dais); i++) { @@ -1098,11 +1098,10 @@ static int hsw_pcm_probe(struct snd_soc_platform *platform) goto err; /* enable runtime PM with auto suspend */ - pm_runtime_set_autosuspend_delay(platform->dev, - SST_RUNTIME_SUSPEND_DELAY); - pm_runtime_use_autosuspend(platform->dev); - pm_runtime_enable(platform->dev); - pm_runtime_idle(platform->dev); + pm_runtime_set_autosuspend_delay(dev, SST_RUNTIME_SUSPEND_DELAY); + pm_runtime_use_autosuspend(dev); + pm_runtime_enable(dev); + pm_runtime_idle(dev); return 0; @@ -1116,13 +1115,13 @@ err: return ret; } -static int hsw_pcm_remove(struct snd_soc_platform *platform) +static void hsw_pcm_remove(struct snd_soc_component *component) { struct hsw_priv_data *priv_data = - snd_soc_platform_get_drvdata(platform); + snd_soc_component_get_drvdata(component); int i; - pm_runtime_disable(platform->dev); + pm_runtime_disable(component->dev); hsw_pcm_free_modules(priv_data); for (i = 0; i < ARRAY_SIZE(hsw_dais); i++) { @@ -1131,24 +1130,19 @@ static int hsw_pcm_remove(struct snd_soc_platform *platform) if (hsw_dais[i].capture.channels_min) snd_dma_free_pages(&priv_data->dmab[i][1]); } - - return 0; } -static const struct snd_soc_platform_driver hsw_soc_platform = { +static const struct snd_soc_component_driver hsw_dai_component = { + .name = DRV_NAME, .probe = hsw_pcm_probe, .remove = hsw_pcm_remove, .ops = &hsw_pcm_ops, .pcm_new = hsw_pcm_new, -}; - -static const struct snd_soc_component_driver hsw_dai_component = { - .name = "haswell-dai", - .controls = hsw_volume_controls, - .num_controls = ARRAY_SIZE(hsw_volume_controls), - .dapm_widgets = widgets, + .controls = hsw_volume_controls, + .num_controls = ARRAY_SIZE(hsw_volume_controls), + .dapm_widgets = widgets, .num_dapm_widgets = ARRAY_SIZE(widgets), - .dapm_routes = graph, + .dapm_routes = graph, .num_dapm_routes = ARRAY_SIZE(graph), }; @@ -1172,19 +1166,13 @@ static int hsw_pcm_dev_probe(struct platform_device *pdev) priv_data->hsw = sst_pdata->dsp; platform_set_drvdata(pdev, priv_data); - ret = snd_soc_register_platform(&pdev->dev, &hsw_soc_platform); + ret = devm_snd_soc_register_component(&pdev->dev, &hsw_dai_component, + hsw_dais, ARRAY_SIZE(hsw_dais)); if (ret < 0) goto err_plat; - ret = snd_soc_register_component(&pdev->dev, &hsw_dai_component, - hsw_dais, ARRAY_SIZE(hsw_dais)); - if (ret < 0) - goto err_comp; - return 0; -err_comp: - snd_soc_unregister_platform(&pdev->dev); err_plat: sst_hsw_dsp_free(&pdev->dev, sst_pdata); return 0; @@ -1194,8 +1182,6 @@ static int hsw_pcm_dev_remove(struct platform_device *pdev) { struct sst_pdata *sst_pdata = dev_get_platdata(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); - snd_soc_unregister_component(&pdev->dev); sst_hsw_dsp_free(&pdev->dev, sst_pdata); return 0; From 540b925af4c0456adf220dea991d91bf05ad77c0 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:42:37 +0000 Subject: [PATCH 011/102] ASoC: bcm: cygnus: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/bcm/cygnus-pcm.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sound/soc/bcm/cygnus-pcm.c b/sound/soc/bcm/cygnus-pcm.c index d616e096462e..123ecf5479d7 100644 --- a/sound/soc/bcm/cygnus-pcm.c +++ b/sound/soc/bcm/cygnus-pcm.c @@ -820,7 +820,7 @@ static int cygnus_dma_new(struct snd_soc_pcm_runtime *rtd) return 0; } -static struct snd_soc_platform_driver cygnus_soc_platform = { +static struct snd_soc_component_driver cygnus_soc_platform = { .ops = &cygnus_pcm_ops, .pcm_new = cygnus_dma_new, .pcm_free = cygnus_dma_free_dma_buffers, @@ -840,7 +840,8 @@ int cygnus_soc_platform_register(struct device *dev, return rc; } - rc = snd_soc_register_platform(dev, &cygnus_soc_platform); + rc = devm_snd_soc_register_component(dev, &cygnus_soc_platform, + NULL, 0); if (rc) { dev_err(dev, "%s failed\n", __func__); return rc; @@ -851,8 +852,6 @@ int cygnus_soc_platform_register(struct device *dev, int cygnus_soc_platform_unregister(struct device *dev) { - snd_soc_unregister_platform(dev); - return 0; } From 019ea01b7c510803d2f1ca8315916084887463c9 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:42:53 +0000 Subject: [PATCH 012/102] ASoC: sh: rsnd: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 64d5ecb86528..b4007669c704 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -1337,7 +1337,7 @@ int rsnd_kctrl_new(struct rsnd_mod *mod, } /* - * snd_soc_platform + * snd_soc_component */ #define PREALLOC_BUFFER (32 * 1024) @@ -1364,12 +1364,9 @@ static int rsnd_pcm_new(struct snd_soc_pcm_runtime *rtd) PREALLOC_BUFFER, PREALLOC_BUFFER_MAX); } -static const struct snd_soc_platform_driver rsnd_soc_platform = { +static const struct snd_soc_component_driver rsnd_soc_component = { .ops = &rsnd_pcm_ops, .pcm_new = rsnd_pcm_new, -}; - -static const struct snd_soc_component_driver rsnd_soc_component = { .name = "rsnd", }; @@ -1478,17 +1475,11 @@ static int rsnd_probe(struct platform_device *pdev) /* * asoc register */ - ret = snd_soc_register_platform(dev, &rsnd_soc_platform); - if (ret < 0) { - dev_err(dev, "cannot snd soc register\n"); - return ret; - } - - ret = snd_soc_register_component(dev, &rsnd_soc_component, + ret = devm_snd_soc_register_component(dev, &rsnd_soc_component, priv->daidrv, rsnd_rdai_nr(priv)); if (ret < 0) { dev_err(dev, "cannot snd dai register\n"); - goto exit_snd_soc; + goto exit_snd_probe; } pm_runtime_enable(dev); @@ -1496,8 +1487,6 @@ static int rsnd_probe(struct platform_device *pdev) dev_info(dev, "probed\n"); return ret; -exit_snd_soc: - snd_soc_unregister_platform(dev); exit_snd_probe: for_each_rsnd_dai(rdai, priv, i) { rsnd_dai_call(remove, &rdai->playback, priv); @@ -1535,9 +1524,6 @@ static int rsnd_remove(struct platform_device *pdev) for (i = 0; i < ARRAY_SIZE(remove_func); i++) remove_func[i](priv); - snd_soc_unregister_component(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); - return ret; } From eb5d510c869b95d3e219d4b01156f9095ec162f6 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:43:10 +0000 Subject: [PATCH 013/102] ASoC: sh: dma-sh7760: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/dma-sh7760.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/sh/dma-sh7760.c b/sound/soc/sh/dma-sh7760.c index 1e7d417b53ef..2dc3b762fdd9 100644 --- a/sound/soc/sh/dma-sh7760.c +++ b/sound/soc/sh/dma-sh7760.c @@ -320,14 +320,15 @@ static int camelot_pcm_new(struct snd_soc_pcm_runtime *rtd) return 0; } -static const struct snd_soc_platform_driver sh7760_soc_platform = { +static const struct snd_soc_component_driver sh7760_soc_component = { .ops = &camelot_pcm_ops, .pcm_new = camelot_pcm_new, }; static int sh7760_soc_platform_probe(struct platform_device *pdev) { - return devm_snd_soc_register_platform(&pdev->dev, &sh7760_soc_platform); + return devm_snd_soc_register_component(&pdev->dev, &sh7760_soc_component, + NULL, 0); } static struct platform_driver sh7760_pcm_driver = { From f5a82fa6016ad1c2a3f45a4d44eab2ac48daf130 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:43:26 +0000 Subject: [PATCH 014/102] ASoC: sh: fsi: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/fsi.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c index c3aaf4788557..3bae06dd121f 100644 --- a/sound/soc/sh/fsi.c +++ b/sound/soc/sh/fsi.c @@ -1764,7 +1764,7 @@ static const struct snd_pcm_ops fsi_pcm_ops = { }; /* - * snd_soc_platform + * snd_soc_component */ #define PREALLOC_BUFFER (32 * 1024) @@ -1818,13 +1818,10 @@ static struct snd_soc_dai_driver fsi_soc_dai[] = { }, }; -static const struct snd_soc_platform_driver fsi_soc_platform = { - .ops = &fsi_pcm_ops, - .pcm_new = fsi_pcm_new, -}; - static const struct snd_soc_component_driver fsi_soc_component = { .name = "fsi", + .ops = &fsi_pcm_ops, + .pcm_new = fsi_pcm_new, }; /* @@ -2007,23 +2004,15 @@ static int fsi_probe(struct platform_device *pdev) goto exit_fsib; } - ret = snd_soc_register_platform(&pdev->dev, &fsi_soc_platform); - if (ret < 0) { - dev_err(&pdev->dev, "cannot snd soc register\n"); - goto exit_fsib; - } - - ret = snd_soc_register_component(&pdev->dev, &fsi_soc_component, + ret = devm_snd_soc_register_component(&pdev->dev, &fsi_soc_component, fsi_soc_dai, ARRAY_SIZE(fsi_soc_dai)); if (ret < 0) { dev_err(&pdev->dev, "cannot snd component register\n"); - goto exit_snd_soc; + goto exit_fsib; } return ret; -exit_snd_soc: - snd_soc_unregister_platform(&pdev->dev); exit_fsib: pm_runtime_disable(&pdev->dev); fsi_stream_remove(&master->fsib); @@ -2041,9 +2030,6 @@ static int fsi_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); - snd_soc_unregister_component(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); - fsi_stream_remove(&master->fsia); fsi_stream_remove(&master->fsib); From be3eabe99803b2526f8829b7c7225763f0703b1f Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:43:45 +0000 Subject: [PATCH 015/102] ASoC: sh: siu: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/siu.h | 2 +- sound/soc/sh/siu_dai.c | 10 +--------- sound/soc/sh/siu_pcm.c | 9 ++++++--- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/sound/soc/sh/siu.h b/sound/soc/sh/siu.h index 83c3430ad797..6088d627c0e4 100644 --- a/sound/soc/sh/siu.h +++ b/sound/soc/sh/siu.h @@ -183,7 +183,7 @@ static inline u32 siu_read32(u32 __iomem *addr) #define SIU_BRGBSEL (0x108 / sizeof(u32)) #define SIU_BRRB (0x10c / sizeof(u32)) -extern struct snd_soc_platform_driver siu_platform; +extern struct snd_soc_component_driver siu_component; extern struct siu_info *siu_i2s_data; int siu_init_port(int port, struct siu_port **port_info, struct snd_card *card); diff --git a/sound/soc/sh/siu_dai.c b/sound/soc/sh/siu_dai.c index 160502947da2..ee2211635e92 100644 --- a/sound/soc/sh/siu_dai.c +++ b/sound/soc/sh/siu_dai.c @@ -727,10 +727,6 @@ static struct snd_soc_dai_driver siu_i2s_dai = { .ops = &siu_dai_ops, }; -static const struct snd_soc_component_driver siu_i2s_component = { - .name = "siu-i2s", -}; - static int siu_probe(struct platform_device *pdev) { const struct firmware *fw_entry; @@ -786,15 +782,11 @@ static int siu_probe(struct platform_device *pdev) dev_set_drvdata(&pdev->dev, info); /* register using ARRAY version so we can keep dai name */ - ret = devm_snd_soc_register_component(&pdev->dev, &siu_i2s_component, + ret = devm_snd_soc_register_component(&pdev->dev, &siu_component, &siu_i2s_dai, 1); if (ret < 0) return ret; - ret = devm_snd_soc_register_platform(&pdev->dev, &siu_platform); - if (ret < 0) - return ret; - pm_runtime_enable(&pdev->dev); return 0; diff --git a/sound/soc/sh/siu_pcm.c b/sound/soc/sh/siu_pcm.c index 3118cb0ee3f2..172909570ed5 100644 --- a/sound/soc/sh/siu_pcm.c +++ b/sound/soc/sh/siu_pcm.c @@ -35,6 +35,7 @@ #include "siu.h" +#define DRV_NAME "siu-i2s" #define GET_MAX_PERIODS(buf_bytes, period_bytes) \ ((buf_bytes) / (period_bytes)) #define PERIOD_OFFSET(buf_addr, period_num, period_bytes) \ @@ -340,7 +341,8 @@ static int siu_pcm_open(struct snd_pcm_substream *ss) { /* Playback / Capture */ struct snd_soc_pcm_runtime *rtd = ss->private_data; - struct siu_platform *pdata = rtd->platform->dev->platform_data; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct siu_platform *pdata = component->dev->platform_data; struct siu_info *info = siu_i2s_data; struct siu_port *port_info = siu_port_info(ss); struct siu_stream *siu_stream; @@ -604,9 +606,10 @@ static const struct snd_pcm_ops siu_pcm_ops = { .pointer = siu_pcm_pointer_dma, }; -struct snd_soc_platform_driver siu_platform = { +struct snd_soc_component_driver siu_component = { + .name = DRV_NAME, .ops = &siu_pcm_ops, .pcm_new = siu_pcm_new, .pcm_free = siu_pcm_free, }; -EXPORT_SYMBOL_GPL(siu_platform); +EXPORT_SYMBOL_GPL(siu_component); From 6dea9df84aa2c2c1c645fac933adf1c4e0c20ac7 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:44:05 +0000 Subject: [PATCH 016/102] ASoC: atmel: replace platform to component Now platform can be replaced to component, let's do it. To avoid complex operation, this patch adds device pointer to atmel_classd. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/atmel/atmel-classd.c | 4 +++- sound/soc/atmel/atmel-pcm-pdc.c | 6 +++--- sound/soc/atmel/atmel-pdmic.c | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/sound/soc/atmel/atmel-classd.c b/sound/soc/atmel/atmel-classd.c index ebabed69f0e6..6bc2b729495c 100644 --- a/sound/soc/atmel/atmel-classd.c +++ b/sound/soc/atmel/atmel-classd.c @@ -32,6 +32,7 @@ struct atmel_classd { struct regmap *regmap; struct clk *pclk; struct clk *gclk; + struct device *dev; int irq; const struct atmel_classd_pdata *pdata; }; @@ -165,7 +166,7 @@ atmel_classd_platform_configure_dma(struct snd_pcm_substream *substream, struct atmel_classd *dd = snd_soc_card_get_drvdata(rtd->card); if (params_physical_width(params) != 16) { - dev_err(rtd->platform->dev, + dev_err(dd->dev, "only supports 16-bit audio data\n"); return -EINVAL; } @@ -587,6 +588,7 @@ static int atmel_classd_probe(struct platform_device *pdev) } dd->phy_base = res->start; + dd->dev = dev; dd->regmap = devm_regmap_init_mmio(dev, io_base, &atmel_classd_regmap_config); diff --git a/sound/soc/atmel/atmel-pcm-pdc.c b/sound/soc/atmel/atmel-pcm-pdc.c index 91b7069c3499..99ca23d527c9 100644 --- a/sound/soc/atmel/atmel-pcm-pdc.c +++ b/sound/soc/atmel/atmel-pcm-pdc.c @@ -393,7 +393,7 @@ static const struct snd_pcm_ops atmel_pcm_ops = { .mmap = atmel_pcm_mmap, }; -static struct snd_soc_platform_driver atmel_soc_platform = { +static struct snd_soc_component_driver atmel_soc_platform = { .ops = &atmel_pcm_ops, .pcm_new = atmel_pcm_new, .pcm_free = atmel_pcm_free, @@ -401,13 +401,13 @@ static struct snd_soc_platform_driver atmel_soc_platform = { int atmel_pcm_pdc_platform_register(struct device *dev) { - return snd_soc_register_platform(dev, &atmel_soc_platform); + return devm_snd_soc_register_component(dev, &atmel_soc_platform, + NULL, 0); } EXPORT_SYMBOL(atmel_pcm_pdc_platform_register); void atmel_pcm_pdc_platform_unregister(struct device *dev) { - snd_soc_unregister_platform(dev); } EXPORT_SYMBOL(atmel_pcm_pdc_platform_unregister); diff --git a/sound/soc/atmel/atmel-pdmic.c b/sound/soc/atmel/atmel-pdmic.c index 8e3d34be9e69..4eea738c1047 100644 --- a/sound/soc/atmel/atmel-pdmic.c +++ b/sound/soc/atmel/atmel-pdmic.c @@ -32,6 +32,7 @@ struct atmel_pdmic { struct regmap *regmap; struct clk *pclk; struct clk *gclk; + struct device *dev; int irq; struct snd_pcm_substream *substream; const struct atmel_pdmic_pdata *pdata; @@ -206,7 +207,7 @@ atmel_pdmic_platform_configure_dma(struct snd_pcm_substream *substream, ret = snd_hwparams_to_dma_slave_config(substream, params, slave_config); if (ret) { - dev_err(rtd->platform->dev, + dev_err(dd->dev, "hw params to dma slave configure failed\n"); return ret; } @@ -596,6 +597,7 @@ static int atmel_pdmic_probe(struct platform_device *pdev) return -ENOMEM; dd->pdata = pdata; + dd->dev = dev; dd->irq = platform_get_irq(pdev, 0); if (dd->irq < 0) { From a1042a42bc5cc03969be40521c0e163be187ec8f Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:44:23 +0000 Subject: [PATCH 017/102] ASoC: amd: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Tested-by: Mukunda,Vijendar Signed-off-by: Mark Brown --- sound/soc/amd/acp-pcm-dma.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index c33a512283a4..78d7b6238376 100644 --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c @@ -23,6 +23,8 @@ #include #include "acp.h" +#define DRV_NAME "acp_audio_dma" + #define PLAYBACK_MIN_NUM_PERIODS 2 #define PLAYBACK_MAX_NUM_PERIODS 2 #define PLAYBACK_MAX_PERIOD_SIZE 16384 @@ -702,8 +704,8 @@ static int acp_dma_open(struct snd_pcm_substream *substream) int ret = 0; struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *prtd = substream->private_data; - struct audio_drv_data *intr_data = dev_get_drvdata(prtd->platform->dev); - + struct snd_soc_component *component = snd_soc_rtdcom_lookup(prtd, DRV_NAME); + struct audio_drv_data *intr_data = dev_get_drvdata(component->dev); struct audio_substream_data *adata = kzalloc(sizeof(struct audio_substream_data), GFP_KERNEL); if (adata == NULL) @@ -730,7 +732,7 @@ static int acp_dma_open(struct snd_pcm_substream *substream) ret = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); if (ret < 0) { - dev_err(prtd->platform->dev, "set integer constraint failed\n"); + dev_err(component->dev, "set integer constraint failed\n"); kfree(adata); return ret; } @@ -778,7 +780,8 @@ static int acp_dma_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_runtime *runtime; struct audio_substream_data *rtd; struct snd_soc_pcm_runtime *prtd = substream->private_data; - struct audio_drv_data *adata = dev_get_drvdata(prtd->platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(prtd, DRV_NAME); + struct audio_drv_data *adata = dev_get_drvdata(component->dev); runtime = substream->runtime; rtd = runtime->private_data; @@ -907,6 +910,7 @@ static int acp_dma_trigger(struct snd_pcm_substream *substream, int cmd) struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *prtd = substream->private_data; struct audio_substream_data *rtd = runtime->private_data; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(prtd, DRV_NAME); if (!rtd) return -EINVAL; @@ -924,7 +928,7 @@ static int acp_dma_trigger(struct snd_pcm_substream *substream, int cmd) while (acp_reg_read(rtd->acp_mmio, mmACP_DMA_CH_STS) & BIT(SYSRAM_TO_ACP_CH_NUM)) { if (!loops--) { - dev_err(prtd->platform->dev, + dev_err(component->dev, "acp dma start timeout\n"); return -ETIMEDOUT; } @@ -970,7 +974,8 @@ static int acp_dma_trigger(struct snd_pcm_substream *substream, int cmd) static int acp_dma_new(struct snd_soc_pcm_runtime *rtd) { int ret; - struct audio_drv_data *adata = dev_get_drvdata(rtd->platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct audio_drv_data *adata = dev_get_drvdata(component->dev); switch (adata->asic_type) { case CHIP_STONEY: @@ -987,7 +992,7 @@ static int acp_dma_new(struct snd_soc_pcm_runtime *rtd) break; } if (ret < 0) - dev_err(rtd->platform->dev, + dev_err(component->dev, "buffer preallocation failer error:%d\n", ret); return ret; } @@ -998,7 +1003,8 @@ static int acp_dma_close(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct audio_substream_data *rtd = runtime->private_data; struct snd_soc_pcm_runtime *prtd = substream->private_data; - struct audio_drv_data *adata = dev_get_drvdata(prtd->platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(prtd, DRV_NAME); + struct audio_drv_data *adata = dev_get_drvdata(component->dev); kfree(rtd); @@ -1044,7 +1050,8 @@ static const struct snd_pcm_ops acp_dma_ops = { .prepare = acp_dma_prepare, }; -static struct snd_soc_platform_driver acp_asoc_platform = { +static struct snd_soc_component_driver acp_asoc_platform = { + .name = DRV_NAME, .ops = &acp_dma_ops, .pcm_new = acp_dma_new, }; @@ -1102,7 +1109,8 @@ static int acp_audio_probe(struct platform_device *pdev) return status; } - status = snd_soc_register_platform(&pdev->dev, &acp_asoc_platform); + status = devm_snd_soc_register_component(&pdev->dev, + &acp_asoc_platform, NULL, 0); if (status != 0) { dev_err(&pdev->dev, "Fail to register ALSA platform device\n"); return status; @@ -1123,7 +1131,6 @@ static int acp_audio_remove(struct platform_device *pdev) status = acp_deinit(adata->acp_mmio); if (status) dev_err(&pdev->dev, "ACP Deinit failed status:%d\n", status); - snd_soc_unregister_platform(&pdev->dev); pm_runtime_disable(&pdev->dev); return 0; From 48102b0426f6d134ebd9f2624d5d42d9e7a8a9fd Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:44:44 +0000 Subject: [PATCH 018/102] ASoC: cs47l24: replace platform to component Now platform can be replaced to component, let's do it. This patch merges cs47l24_compr_platform into soc_codec_dev_cs47l24 Signed-off-by: Kuninori Morimoto Acked-by: Charles Keepax Tested-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/cs47l24.c | 42 +++++++++++++++----------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/sound/soc/codecs/cs47l24.c b/sound/soc/codecs/cs47l24.c index be2750680838..3f34de5f800e 100644 --- a/sound/soc/codecs/cs47l24.c +++ b/sound/soc/codecs/cs47l24.c @@ -33,6 +33,8 @@ #include "wm_adsp.h" #include "cs47l24.h" +#define DRV_NAME "cs47l24-codec" + struct cs47l24_priv { struct arizona_priv core; struct arizona_fll fll[2]; @@ -1069,7 +1071,8 @@ static struct snd_soc_dai_driver cs47l24_dai[] = { static int cs47l24_open(struct snd_compr_stream *stream) { struct snd_soc_pcm_runtime *rtd = stream->private_data; - struct cs47l24_priv *priv = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct cs47l24_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->core.arizona; int n_adsp; @@ -1177,6 +1180,16 @@ static unsigned int cs47l24_digital_vu[] = { ARIZONA_DAC_DIGITAL_VOLUME_4L, }; +static struct snd_compr_ops cs47l24_compr_ops = { + .open = cs47l24_open, + .free = wm_adsp_compr_free, + .set_params = wm_adsp_compr_set_params, + .get_caps = wm_adsp_compr_get_caps, + .trigger = wm_adsp_compr_trigger, + .pointer = wm_adsp_compr_pointer, + .copy = wm_adsp_compr_copy, +}; + static const struct snd_soc_codec_driver soc_codec_dev_cs47l24 = { .probe = cs47l24_codec_probe, .remove = cs47l24_codec_remove, @@ -1187,6 +1200,8 @@ static const struct snd_soc_codec_driver soc_codec_dev_cs47l24 = { .set_pll = cs47l24_set_fll, .component_driver = { + .name = DRV_NAME, + .compr_ops = &cs47l24_compr_ops, .controls = cs47l24_snd_controls, .num_controls = ARRAY_SIZE(cs47l24_snd_controls), .dapm_widgets = cs47l24_dapm_widgets, @@ -1196,20 +1211,6 @@ static const struct snd_soc_codec_driver soc_codec_dev_cs47l24 = { }, }; -static const struct snd_compr_ops cs47l24_compr_ops = { - .open = cs47l24_open, - .free = wm_adsp_compr_free, - .set_params = wm_adsp_compr_set_params, - .get_caps = wm_adsp_compr_get_caps, - .trigger = wm_adsp_compr_trigger, - .pointer = wm_adsp_compr_pointer, - .copy = wm_adsp_compr_copy, -}; - -static const struct snd_soc_platform_driver cs47l24_compr_platform = { - .compr_ops = &cs47l24_compr_ops, -}; - static int cs47l24_probe(struct platform_device *pdev) { struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); @@ -1298,23 +1299,15 @@ static int cs47l24_probe(struct platform_device *pdev) if (ret < 0) goto err_dsp_irq; - ret = snd_soc_register_platform(&pdev->dev, &cs47l24_compr_platform); - if (ret < 0) { - dev_err(&pdev->dev, "Failed to register platform: %d\n", ret); - goto err_spk_irqs; - } - ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_cs47l24, cs47l24_dai, ARRAY_SIZE(cs47l24_dai)); if (ret < 0) { dev_err(&pdev->dev, "Failed to register codec: %d\n", ret); - goto err_platform; + goto err_spk_irqs; } return ret; -err_platform: - snd_soc_unregister_platform(&pdev->dev); err_spk_irqs: arizona_free_spk_irqs(arizona); err_dsp_irq: @@ -1328,7 +1321,6 @@ static int cs47l24_remove(struct platform_device *pdev) struct cs47l24_priv *cs47l24 = platform_get_drvdata(pdev); struct arizona *arizona = cs47l24->core.arizona; - snd_soc_unregister_platform(&pdev->dev); snd_soc_unregister_codec(&pdev->dev); pm_runtime_disable(&pdev->dev); From 9fe3b2bac02c6d06724d526b0245568bca49349f Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:45:13 +0000 Subject: [PATCH 019/102] ASoC: rt5514-spi: replace platform to component Now platform can be replaced to component, let's do it. This patch merges rt5514_spi_dai_component into rt5514_spi_component Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/rt5514-spi.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/sound/soc/codecs/rt5514-spi.c b/sound/soc/codecs/rt5514-spi.c index 2144edca97b0..84184d90385b 100644 --- a/sound/soc/codecs/rt5514-spi.c +++ b/sound/soc/codecs/rt5514-spi.c @@ -35,6 +35,8 @@ #include "rt5514-spi.h" +#define DRV_NAME "rt5514-spi" + static struct spi_device *rt5514_spi; struct rt5514_dsp { @@ -211,8 +213,9 @@ static int rt5514_spi_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct rt5514_dsp *rt5514_dsp = - snd_soc_platform_get_drvdata(rtd->platform); + snd_soc_component_get_drvdata(component); int ret; u8 buf[8]; @@ -235,8 +238,9 @@ static int rt5514_spi_hw_params(struct snd_pcm_substream *substream, static int rt5514_spi_hw_free(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct rt5514_dsp *rt5514_dsp = - snd_soc_platform_get_drvdata(rtd->platform); + snd_soc_component_get_drvdata(component); mutex_lock(&rt5514_dsp->dma_lock); rt5514_dsp->substream = NULL; @@ -252,8 +256,9 @@ static snd_pcm_uframes_t rt5514_spi_pcm_pointer( { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct rt5514_dsp *rt5514_dsp = - snd_soc_platform_get_drvdata(rtd->platform); + snd_soc_component_get_drvdata(component); return bytes_to_frames(runtime, rt5514_dsp->dma_offset); } @@ -267,18 +272,18 @@ static const struct snd_pcm_ops rt5514_spi_pcm_ops = { .page = snd_pcm_lib_get_vmalloc_page, }; -static int rt5514_spi_pcm_probe(struct snd_soc_platform *platform) +static int rt5514_spi_pcm_probe(struct snd_soc_component *component) { struct rt5514_dsp *rt5514_dsp; int ret; - rt5514_dsp = devm_kzalloc(platform->dev, sizeof(*rt5514_dsp), + rt5514_dsp = devm_kzalloc(component->dev, sizeof(*rt5514_dsp), GFP_KERNEL); rt5514_dsp->dev = &rt5514_spi->dev; mutex_init(&rt5514_dsp->dma_lock); INIT_DELAYED_WORK(&rt5514_dsp->copy_work, rt5514_spi_copy_work); - snd_soc_platform_set_drvdata(platform, rt5514_dsp); + snd_soc_component_set_drvdata(component, rt5514_dsp); if (rt5514_spi->irq) { ret = devm_request_threaded_irq(&rt5514_spi->dev, @@ -296,15 +301,12 @@ static int rt5514_spi_pcm_probe(struct snd_soc_platform *platform) return 0; } -static const struct snd_soc_platform_driver rt5514_spi_platform = { +static const struct snd_soc_component_driver rt5514_spi_component = { + .name = DRV_NAME, .probe = rt5514_spi_pcm_probe, .ops = &rt5514_spi_pcm_ops, }; -static const struct snd_soc_component_driver rt5514_spi_dai_component = { - .name = "rt5514-spi-dai", -}; - /** * rt5514_spi_burst_read - Read data from SPI by rt5514 address. * @addr: Start address. @@ -445,14 +447,8 @@ static int rt5514_spi_probe(struct spi_device *spi) rt5514_spi = spi; - ret = devm_snd_soc_register_platform(&spi->dev, &rt5514_spi_platform); - if (ret < 0) { - dev_err(&spi->dev, "Failed to register platform.\n"); - return ret; - } - ret = devm_snd_soc_register_component(&spi->dev, - &rt5514_spi_dai_component, + &rt5514_spi_component, &rt5514_spi_dai, 1); if (ret < 0) { dev_err(&spi->dev, "Failed to register component.\n"); From 0a2b051bf63916a5f567cbdbeb86b1da6e28c4d2 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:45:30 +0000 Subject: [PATCH 020/102] ASoC: wm5110: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Acked-by: Charles Keepax Tested-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm5110.c | 42 ++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c index fb0cf9c61f48..d5ece6c6fcb6 100644 --- a/sound/soc/codecs/wm5110.c +++ b/sound/soc/codecs/wm5110.c @@ -35,6 +35,8 @@ #define WM5110_NUM_ADSP 4 +#define DRV_NAME "wm5110-codec" + struct wm5110_priv { struct arizona_priv core; struct arizona_fll fll[2]; @@ -2229,7 +2231,8 @@ static struct snd_soc_dai_driver wm5110_dai[] = { static int wm5110_open(struct snd_compr_stream *stream) { struct snd_soc_pcm_runtime *rtd = stream->private_data; - struct wm5110_priv *priv = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct wm5110_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->core.arizona; int n_adsp; @@ -2346,6 +2349,16 @@ static unsigned int wm5110_digital_vu[] = { ARIZONA_DAC_DIGITAL_VOLUME_6R, }; +static struct snd_compr_ops wm5110_compr_ops = { + .open = wm5110_open, + .free = wm_adsp_compr_free, + .set_params = wm_adsp_compr_set_params, + .get_caps = wm_adsp_compr_get_caps, + .trigger = wm_adsp_compr_trigger, + .pointer = wm_adsp_compr_pointer, + .copy = wm_adsp_compr_copy, +}; + static const struct snd_soc_codec_driver soc_codec_dev_wm5110 = { .probe = wm5110_codec_probe, .remove = wm5110_codec_remove, @@ -2356,6 +2369,8 @@ static const struct snd_soc_codec_driver soc_codec_dev_wm5110 = { .set_pll = wm5110_set_fll, .component_driver = { + .name = DRV_NAME, + .compr_ops = &wm5110_compr_ops, .controls = wm5110_snd_controls, .num_controls = ARRAY_SIZE(wm5110_snd_controls), .dapm_widgets = wm5110_dapm_widgets, @@ -2365,20 +2380,6 @@ static const struct snd_soc_codec_driver soc_codec_dev_wm5110 = { }, }; -static const struct snd_compr_ops wm5110_compr_ops = { - .open = wm5110_open, - .free = wm_adsp_compr_free, - .set_params = wm_adsp_compr_set_params, - .get_caps = wm_adsp_compr_get_caps, - .trigger = wm_adsp_compr_trigger, - .pointer = wm_adsp_compr_pointer, - .copy = wm_adsp_compr_copy, -}; - -static const struct snd_soc_platform_driver wm5110_compr_platform = { - .compr_ops = &wm5110_compr_ops, -}; - static int wm5110_probe(struct platform_device *pdev) { struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); @@ -2464,23 +2465,15 @@ static int wm5110_probe(struct platform_device *pdev) if (ret < 0) goto err_dsp_irq; - ret = snd_soc_register_platform(&pdev->dev, &wm5110_compr_platform); - if (ret < 0) { - dev_err(&pdev->dev, "Failed to register platform: %d\n", ret); - goto err_spk_irqs; - } - ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm5110, wm5110_dai, ARRAY_SIZE(wm5110_dai)); if (ret < 0) { dev_err(&pdev->dev, "Failed to register codec: %d\n", ret); - goto err_platform; + goto err_spk_irqs; } return ret; -err_platform: - snd_soc_unregister_platform(&pdev->dev); err_spk_irqs: arizona_free_spk_irqs(arizona); err_dsp_irq: @@ -2495,7 +2488,6 @@ static int wm5110_remove(struct platform_device *pdev) struct arizona *arizona = wm5110->core.arizona; int i; - snd_soc_unregister_platform(&pdev->dev); snd_soc_unregister_codec(&pdev->dev); pm_runtime_disable(&pdev->dev); From a20863256f88513b3ba97484179911c2b9aa5dfd Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:45:48 +0000 Subject: [PATCH 021/102] ASoC: wm5102: replace platform to component Now platform can be replaced to component, let's do it. This patch merges wm5102_compr_platform into soc_codec_dev_wm5102 Signed-off-by: Kuninori Morimoto Acked-by: Charles Keepax Tested-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm5102.c | 42 ++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c index fc066caa1918..a568050090ad 100644 --- a/sound/soc/codecs/wm5102.c +++ b/sound/soc/codecs/wm5102.c @@ -34,6 +34,8 @@ #include "wm5102.h" #include "wm_adsp.h" +#define DRV_NAME "wm5102-codec" + struct wm5102_priv { struct arizona_priv core; struct arizona_fll fll[2]; @@ -1910,7 +1912,8 @@ static struct snd_soc_dai_driver wm5102_dai[] = { static int wm5102_open(struct snd_compr_stream *stream) { struct snd_soc_pcm_runtime *rtd = stream->private_data; - struct wm5102_priv *priv = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct wm5102_priv *priv = snd_soc_component_get_drvdata(component); return wm_adsp_compr_open(&priv->core.adsp[0], stream); } @@ -1992,6 +1995,16 @@ static unsigned int wm5102_digital_vu[] = { ARIZONA_DAC_DIGITAL_VOLUME_5R, }; +static struct snd_compr_ops wm5102_compr_ops = { + .open = wm5102_open, + .free = wm_adsp_compr_free, + .set_params = wm_adsp_compr_set_params, + .get_caps = wm_adsp_compr_get_caps, + .trigger = wm_adsp_compr_trigger, + .pointer = wm_adsp_compr_pointer, + .copy = wm_adsp_compr_copy, +}; + static const struct snd_soc_codec_driver soc_codec_dev_wm5102 = { .probe = wm5102_codec_probe, .remove = wm5102_codec_remove, @@ -2002,6 +2015,8 @@ static const struct snd_soc_codec_driver soc_codec_dev_wm5102 = { .set_pll = wm5102_set_fll, .component_driver = { + .name = DRV_NAME, + .compr_ops = &wm5102_compr_ops, .controls = wm5102_snd_controls, .num_controls = ARRAY_SIZE(wm5102_snd_controls), .dapm_widgets = wm5102_dapm_widgets, @@ -2011,20 +2026,6 @@ static const struct snd_soc_codec_driver soc_codec_dev_wm5102 = { }, }; -static const struct snd_compr_ops wm5102_compr_ops = { - .open = wm5102_open, - .free = wm_adsp_compr_free, - .set_params = wm_adsp_compr_set_params, - .get_caps = wm_adsp_compr_get_caps, - .trigger = wm_adsp_compr_trigger, - .pointer = wm_adsp_compr_pointer, - .copy = wm_adsp_compr_copy, -}; - -static const struct snd_soc_platform_driver wm5102_compr_platform = { - .compr_ops = &wm5102_compr_ops, -}; - static int wm5102_probe(struct platform_device *pdev) { struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); @@ -2109,23 +2110,15 @@ static int wm5102_probe(struct platform_device *pdev) if (ret < 0) goto err_dsp_irq; - ret = snd_soc_register_platform(&pdev->dev, &wm5102_compr_platform); - if (ret < 0) { - dev_err(&pdev->dev, "Failed to register platform: %d\n", ret); - goto err_spk_irqs; - } - ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm5102, wm5102_dai, ARRAY_SIZE(wm5102_dai)); if (ret < 0) { dev_err(&pdev->dev, "Failed to register codec: %d\n", ret); - goto err_platform; + goto err_spk_irqs; } return ret; -err_platform: - snd_soc_unregister_platform(&pdev->dev); err_spk_irqs: arizona_free_spk_irqs(arizona); err_dsp_irq: @@ -2139,7 +2132,6 @@ static int wm5102_remove(struct platform_device *pdev) struct wm5102_priv *wm5102 = platform_get_drvdata(pdev); struct arizona *arizona = wm5102->core.arizona; - snd_soc_unregister_platform(&pdev->dev); snd_soc_unregister_codec(&pdev->dev); pm_runtime_disable(&pdev->dev); From a49cb31cc7c84eab032c790df476f57ad14c8eeb Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:46:04 +0000 Subject: [PATCH 022/102] ASoC: davinci-i2s: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/davinci/davinci-i2s.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c index 384961651904..807040bb3921 100644 --- a/sound/soc/davinci/davinci-i2s.c +++ b/sound/soc/davinci/davinci-i2s.c @@ -34,6 +34,7 @@ #include "edma-pcm.h" #include "davinci-i2s.h" +#define DRV_NAME "davinci-i2s" /* * NOTE: terminology here is confusing. @@ -190,7 +191,7 @@ static void davinci_mcbsp_start(struct davinci_mcbsp_dev *dev, struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_platform *platform = rtd->platform; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); int playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK); u32 spcr; u32 mask = playback ? DAVINCI_MCBSP_SPCR_XRST : DAVINCI_MCBSP_SPCR_RRST; @@ -211,8 +212,8 @@ static void davinci_mcbsp_start(struct davinci_mcbsp_dev *dev, if (playback) { /* Stop the DMA to avoid data loss */ /* while the transmitter is out of reset to handle XSYNCERR */ - if (platform->driver->ops->trigger) { - int ret = platform->driver->ops->trigger(substream, + if (component->driver->ops->trigger) { + int ret = component->driver->ops->trigger(substream, SNDRV_PCM_TRIGGER_STOP); if (ret < 0) printk(KERN_DEBUG "Playback DMA stop failed\n"); @@ -233,8 +234,8 @@ static void davinci_mcbsp_start(struct davinci_mcbsp_dev *dev, toggle_clock(dev, playback); /* Restart the DMA */ - if (platform->driver->ops->trigger) { - int ret = platform->driver->ops->trigger(substream, + if (component->driver->ops->trigger) { + int ret = component->driver->ops->trigger(substream, SNDRV_PCM_TRIGGER_START); if (ret < 0) printk(KERN_DEBUG "Playback DMA start failed\n"); @@ -651,7 +652,7 @@ static struct snd_soc_dai_driver davinci_i2s_dai = { }; static const struct snd_soc_component_driver davinci_i2s_component = { - .name = "davinci-i2s", + .name = DRV_NAME, }; static int davinci_i2s_probe(struct platform_device *pdev) From 4cb1ea925e66a2a04bcaf880f62bce425ddb9f94 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:46:22 +0000 Subject: [PATCH 023/102] ASoC: fsl: dma: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_dma.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c index 8c2981b70f64..fce2010d3c53 100644 --- a/sound/soc/fsl/fsl_dma.c +++ b/sound/soc/fsl/fsl_dma.c @@ -37,6 +37,8 @@ #include "fsl_dma.h" #include "fsl_ssi.h" /* For the offset of stx0 and srx0 */ +#define DRV_NAME "fsl_dma" + /* * The formats that the DMA controller supports, which is anything * that is 8, 16, or 32 bits. @@ -56,7 +58,7 @@ SNDRV_PCM_FMTBIT_U32_LE | \ SNDRV_PCM_FMTBIT_U32_BE) struct dma_object { - struct snd_soc_platform_driver dai; + struct snd_soc_component_driver dai; dma_addr_t ssi_stx_phys; dma_addr_t ssi_srx_phys; unsigned int ssi_fifo_depth; @@ -203,7 +205,8 @@ static irqreturn_t fsl_dma_isr(int irq, void *dev_id) struct fsl_dma_private *dma_private = dev_id; struct snd_pcm_substream *substream = dma_private->substream; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct device *dev = rtd->platform->dev; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct device *dev = component->dev; struct ccsr_dma_channel __iomem *dma_channel = dma_private->dma_channel; irqreturn_t ret = IRQ_NONE; u32 sr, sr2 = 0; @@ -385,9 +388,10 @@ static int fsl_dma_open(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct device *dev = rtd->platform->dev; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct device *dev = component->dev; struct dma_object *dma = - container_of(rtd->platform->driver, struct dma_object, dai); + container_of(component->driver, struct dma_object, dai); struct fsl_dma_private *dma_private; struct ccsr_dma_channel __iomem *dma_channel; dma_addr_t ld_buf_phys; @@ -539,7 +543,8 @@ static int fsl_dma_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_runtime *runtime = substream->runtime; struct fsl_dma_private *dma_private = runtime->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct device *dev = rtd->platform->dev; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct device *dev = component->dev; /* Number of bits per sample */ unsigned int sample_bits = @@ -702,7 +707,8 @@ static snd_pcm_uframes_t fsl_dma_pointer(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct fsl_dma_private *dma_private = runtime->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct device *dev = rtd->platform->dev; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct device *dev = component->dev; struct ccsr_dma_channel __iomem *dma_channel = dma_private->dma_channel; dma_addr_t position; snd_pcm_uframes_t frames; @@ -799,9 +805,10 @@ static int fsl_dma_close(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct fsl_dma_private *dma_private = runtime->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct device *dev = rtd->platform->dev; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct device *dev = component->dev; struct dma_object *dma = - container_of(rtd->platform->driver, struct dma_object, dai); + container_of(component->driver, struct dma_object, dai); if (dma_private) { if (dma_private->irq) @@ -908,6 +915,7 @@ static int fsl_soc_dma_probe(struct platform_device *pdev) return -ENOMEM; } + dma->dai.name = DRV_NAME; dma->dai.ops = &fsl_dma_ops; dma->dai.pcm_new = fsl_dma_new; dma->dai.pcm_free = fsl_dma_free_dma_buffers; @@ -925,7 +933,7 @@ static int fsl_soc_dma_probe(struct platform_device *pdev) of_node_put(ssi_np); - ret = snd_soc_register_platform(&pdev->dev, &dma->dai); + ret = devm_snd_soc_register_component(&pdev->dev, &dma->dai, NULL, 0); if (ret) { dev_err(&pdev->dev, "could not register platform\n"); kfree(dma); @@ -944,7 +952,6 @@ static int fsl_soc_dma_remove(struct platform_device *pdev) { struct dma_object *dma = dev_get_drvdata(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); iounmap(dma->channel); irq_dispose_mapping(dma->irq); kfree(dma); From 7f1106616ab634c6b827ce7abf1331a2a817de40 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:46:46 +0000 Subject: [PATCH 024/102] ASoC: fsl: asrc: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Tested-by: Nicolin Chen Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_asrc.c | 10 ---------- sound/soc/fsl/fsl_asrc.h | 3 ++- sound/soc/fsl/fsl_asrc_dma.c | 14 +++++++++----- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c index 806d39927318..adfb8135d739 100644 --- a/sound/soc/fsl/fsl_asrc.c +++ b/sound/soc/fsl/fsl_asrc.c @@ -582,10 +582,6 @@ static struct snd_soc_dai_driver fsl_asrc_dai = { .ops = &fsl_asrc_dai_ops, }; -static const struct snd_soc_component_driver fsl_asrc_component = { - .name = "fsl-asrc-dai", -}; - static bool fsl_asrc_readable_reg(struct device *dev, unsigned int reg) { switch (reg) { @@ -927,12 +923,6 @@ static int fsl_asrc_probe(struct platform_device *pdev) return ret; } - ret = devm_snd_soc_register_platform(&pdev->dev, &fsl_asrc_platform); - if (ret) { - dev_err(&pdev->dev, "failed to register ASoC platform\n"); - return ret; - } - return 0; } diff --git a/sound/soc/fsl/fsl_asrc.h b/sound/soc/fsl/fsl_asrc.h index 2c5856ac5bc3..d558dd5499a5 100644 --- a/sound/soc/fsl/fsl_asrc.h +++ b/sound/soc/fsl/fsl_asrc.h @@ -462,6 +462,7 @@ struct fsl_asrc { u32 regcache_cfg; }; -extern struct snd_soc_platform_driver fsl_asrc_platform; +#define DRV_NAME "fsl-asrc-dai" +extern struct snd_soc_component_driver fsl_asrc_component; struct dma_chan *fsl_asrc_get_dma_channel(struct fsl_asrc_pair *pair, bool dir); #endif /* _FSL_ASRC_H */ diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c index e1b97e59275a..565e16d8fe85 100644 --- a/sound/soc/fsl/fsl_asrc_dma.c +++ b/sound/soc/fsl/fsl_asrc_dma.c @@ -64,7 +64,8 @@ static int fsl_asrc_dma_prepare_and_submit(struct snd_pcm_substream *substream) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; struct fsl_asrc_pair *pair = runtime->private_data; - struct device *dev = rtd->platform->dev; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct device *dev = component->dev; unsigned long flags = DMA_CTRL_ACK; /* Prepare and submit Front-End DMA channel */ @@ -137,12 +138,13 @@ static int fsl_asrc_dma_hw_params(struct snd_pcm_substream *substream, bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; struct snd_dmaengine_dai_dma_data *dma_params_fe = NULL; struct snd_dmaengine_dai_dma_data *dma_params_be = NULL; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct snd_pcm_runtime *runtime = substream->runtime; struct fsl_asrc_pair *pair = runtime->private_data; struct fsl_asrc *asrc_priv = pair->asrc_priv; struct dma_slave_config config_fe, config_be; enum asrc_pair_index index = pair->index; - struct device *dev = rtd->platform->dev; + struct device *dev = component->dev; int stream = substream->stream; struct imx_dma_data *tmp_data; struct snd_soc_dpcm *dpcm; @@ -274,7 +276,8 @@ static int fsl_asrc_dma_startup(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; - struct device *dev = rtd->platform->dev; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct device *dev = component->dev; struct fsl_asrc *asrc_priv = dev_get_drvdata(dev); struct fsl_asrc_pair *pair; @@ -381,9 +384,10 @@ static void fsl_asrc_dma_pcm_free(struct snd_pcm *pcm) } } -struct snd_soc_platform_driver fsl_asrc_platform = { +struct snd_soc_component_driver fsl_asrc_component = { + .name = DRV_NAME, .ops = &fsl_asrc_dma_pcm_ops, .pcm_new = fsl_asrc_dma_pcm_new, .pcm_free = fsl_asrc_dma_pcm_free, }; -EXPORT_SYMBOL_GPL(fsl_asrc_platform); +EXPORT_SYMBOL_GPL(fsl_asrc_component); From 1d0a01f2d4051bc62ba5e0d73ed99272414045ba Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:47:02 +0000 Subject: [PATCH 025/102] ASoC: fsl: imx: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/fsl/imx-pcm-fiq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/fsl/imx-pcm-fiq.c b/sound/soc/fsl/imx-pcm-fiq.c index 4e5fefee111e..0578f3486847 100644 --- a/sound/soc/fsl/imx-pcm-fiq.c +++ b/sound/soc/fsl/imx-pcm-fiq.c @@ -341,7 +341,7 @@ static void imx_pcm_fiq_free(struct snd_pcm *pcm) imx_pcm_free(pcm); } -static const struct snd_soc_platform_driver imx_soc_platform_fiq = { +static const struct snd_soc_component_driver imx_soc_component_fiq = { .ops = &imx_pcm_ops, .pcm_new = imx_pcm_fiq_new, .pcm_free = imx_pcm_fiq_free, @@ -368,7 +368,8 @@ int imx_pcm_fiq_init(struct platform_device *pdev, params->dma_params_tx->maxburst = 4; params->dma_params_rx->maxburst = 6; - ret = snd_soc_register_platform(&pdev->dev, &imx_soc_platform_fiq); + ret = devm_snd_soc_register_component(&pdev->dev, &imx_soc_component_fiq, + NULL, 0); if (ret) goto failed_register; @@ -384,7 +385,6 @@ EXPORT_SYMBOL_GPL(imx_pcm_fiq_init); void imx_pcm_fiq_exit(struct platform_device *pdev) { - snd_soc_unregister_platform(&pdev->dev); } EXPORT_SYMBOL_GPL(imx_pcm_fiq_exit); From 60bceb8029e26c49549a276d5d67198cdfb57b5d Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:47:19 +0000 Subject: [PATCH 026/102] ASoC: fsl: mpc5200: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/fsl/mpc5200_dma.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c index e63029f1aabc..c1a4544eb16b 100644 --- a/sound/soc/fsl/mpc5200_dma.c +++ b/sound/soc/fsl/mpc5200_dma.c @@ -22,6 +22,8 @@ #include "mpc5200_dma.h" +#define DRV_NAME "mpc5200_dma" + /* * Interrupt handlers */ @@ -300,12 +302,13 @@ static const struct snd_pcm_ops psc_dma_ops = { static int psc_dma_new(struct snd_soc_pcm_runtime *rtd) { struct snd_card *card = rtd->card->snd_card; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct snd_soc_dai *dai = rtd->cpu_dai; struct snd_pcm *pcm = rtd->pcm; size_t size = psc_dma_hardware.buffer_bytes_max; int rc; - dev_dbg(rtd->platform->dev, "psc_dma_new(card=%p, dai=%p, pcm=%p)\n", + dev_dbg(component->dev, "psc_dma_new(card=%p, dai=%p, pcm=%p)\n", card, dai, pcm); rc = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); @@ -341,10 +344,11 @@ static int psc_dma_new(struct snd_soc_pcm_runtime *rtd) static void psc_dma_free(struct snd_pcm *pcm) { struct snd_soc_pcm_runtime *rtd = pcm->private_data; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct snd_pcm_substream *substream; int stream; - dev_dbg(rtd->platform->dev, "psc_dma_free(pcm=%p)\n", pcm); + dev_dbg(component->dev, "psc_dma_free(pcm=%p)\n", pcm); for (stream = 0; stream < 2; stream++) { substream = pcm->streams[stream].substream; @@ -356,7 +360,8 @@ static void psc_dma_free(struct snd_pcm *pcm) } } -static const struct snd_soc_platform_driver mpc5200_audio_dma_platform = { +static const struct snd_soc_component_driver mpc5200_audio_dma_component = { + .name = DRV_NAME, .ops = &psc_dma_ops, .pcm_new = &psc_dma_new, .pcm_free = &psc_dma_free, @@ -468,7 +473,8 @@ int mpc5200_audio_dma_create(struct platform_device *op) dev_set_drvdata(&op->dev, psc_dma); /* Tell the ASoC OF helpers about it */ - return snd_soc_register_platform(&op->dev, &mpc5200_audio_dma_platform); + return devm_snd_soc_register_component(&op->dev, + &mpc5200_audio_dma_component, NULL, 0); out_irq: free_irq(psc_dma->irq, psc_dma); free_irq(psc_dma->capture.irq, &psc_dma->capture); @@ -487,8 +493,6 @@ int mpc5200_audio_dma_destroy(struct platform_device *op) dev_dbg(&op->dev, "mpc5200_audio_dma_destroy()\n"); - snd_soc_unregister_platform(&op->dev); - bcom_gen_bd_rx_release(psc_dma->capture.bcom_task); bcom_gen_bd_tx_release(psc_dma->playback.bcom_task); From ddce03ceea3c84bbfca6f465853b543b32184ec2 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:47:38 +0000 Subject: [PATCH 027/102] ASoC: dwc-pcm: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/dwc/dwc-pcm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/dwc/dwc-pcm.c b/sound/soc/dwc/dwc-pcm.c index 406fd867117b..2cc9632024fc 100644 --- a/sound/soc/dwc/dwc-pcm.c +++ b/sound/soc/dwc/dwc-pcm.c @@ -269,7 +269,7 @@ static const struct snd_pcm_ops dw_pcm_ops = { .pointer = dw_pcm_pointer, }; -static const struct snd_soc_platform_driver dw_pcm_platform = { +static const struct snd_soc_component_driver dw_pcm_component = { .pcm_new = dw_pcm_new, .pcm_free = dw_pcm_free, .ops = &dw_pcm_ops, @@ -277,5 +277,6 @@ static const struct snd_soc_platform_driver dw_pcm_platform = { int dw_pcm_register(struct platform_device *pdev) { - return devm_snd_soc_register_platform(&pdev->dev, &dw_pcm_platform); + return devm_snd_soc_register_component(&pdev->dev, &dw_pcm_component, + NULL, 0); } From f98fc0f8154ed17a00a588f1a95f02cb3e33b0d0 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:48:03 +0000 Subject: [PATCH 028/102] ASoC: kirkwood: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/kirkwood/kirkwood-dma.c | 3 ++- sound/soc/kirkwood/kirkwood-i2s.c | 20 ++------------------ sound/soc/kirkwood/kirkwood.h | 4 +++- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/sound/soc/kirkwood/kirkwood-dma.c b/sound/soc/kirkwood/kirkwood-dma.c index 505b0ff03c3b..c6a58520d377 100644 --- a/sound/soc/kirkwood/kirkwood-dma.c +++ b/sound/soc/kirkwood/kirkwood-dma.c @@ -318,7 +318,8 @@ static void kirkwood_dma_free_dma_buffers(struct snd_pcm *pcm) } } -const struct snd_soc_platform_driver kirkwood_soc_platform = { +const struct snd_soc_component_driver kirkwood_soc_component = { + .name = DRV_NAME, .ops = &kirkwood_dma_ops, .pcm_new = kirkwood_dma_new, .pcm_free = kirkwood_dma_free_dma_buffers, diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c index 105a73cc5158..9a2777b72dcd 100644 --- a/sound/soc/kirkwood/kirkwood-i2s.c +++ b/sound/soc/kirkwood/kirkwood-i2s.c @@ -26,8 +26,6 @@ #include "kirkwood.h" -#define DRV_NAME "mvebu-audio" - #define KIRKWOOD_I2S_FORMATS \ (SNDRV_PCM_FMTBIT_S16_LE | \ SNDRV_PCM_FMTBIT_S24_LE | \ @@ -524,10 +522,6 @@ static struct snd_soc_dai_driver kirkwood_i2s_dai_extclk[2] = { }, }; -static const struct snd_soc_component_driver kirkwood_i2s_component = { - .name = DRV_NAME, -}; - static int kirkwood_i2s_dev_probe(struct platform_device *pdev) { struct kirkwood_asoc_platform_data *data = pdev->dev.platform_data; @@ -601,24 +595,17 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev) priv->ctl_rec |= KIRKWOOD_RECCTL_BURST_128; } - err = snd_soc_register_component(&pdev->dev, &kirkwood_i2s_component, + err = devm_snd_soc_register_component(&pdev->dev, &kirkwood_soc_component, soc_dai, 2); if (err) { dev_err(&pdev->dev, "snd_soc_register_component failed\n"); goto err_component; } - err = snd_soc_register_platform(&pdev->dev, &kirkwood_soc_platform); - if (err) { - dev_err(&pdev->dev, "snd_soc_register_platform failed\n"); - goto err_platform; - } - kirkwood_i2s_init(priv); return 0; - err_platform: - snd_soc_unregister_component(&pdev->dev); + err_component: if (!IS_ERR(priv->extclk)) clk_disable_unprepare(priv->extclk); @@ -631,9 +618,6 @@ static int kirkwood_i2s_dev_remove(struct platform_device *pdev) { struct kirkwood_dma_data *priv = dev_get_drvdata(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); - snd_soc_unregister_component(&pdev->dev); - if (!IS_ERR(priv->extclk)) clk_disable_unprepare(priv->extclk); clk_disable_unprepare(priv->clk); diff --git a/sound/soc/kirkwood/kirkwood.h b/sound/soc/kirkwood/kirkwood.h index 783cb1a4f30e..c13ee5f69446 100644 --- a/sound/soc/kirkwood/kirkwood.h +++ b/sound/soc/kirkwood/kirkwood.h @@ -12,6 +12,8 @@ #ifndef _KIRKWOOD_AUDIO_H #define _KIRKWOOD_AUDIO_H +#define DRV_NAME "mvebu-audio" + #define KIRKWOOD_RECORD_WIN 0 #define KIRKWOOD_PLAYBACK_WIN 1 #define KIRKWOOD_MAX_AUDIO_WIN 2 @@ -143,6 +145,6 @@ struct kirkwood_dma_data { int burst; }; -extern const struct snd_soc_platform_driver kirkwood_soc_platform; +extern const struct snd_soc_component_driver kirkwood_soc_component; #endif From 797d16971a2a4fc3aafc4e5ff13c7ebfae4bf91b Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:48:18 +0000 Subject: [PATCH 029/102] ASoC: pxa: mmp: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/pxa/mmp-pcm.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sound/soc/pxa/mmp-pcm.c b/sound/soc/pxa/mmp-pcm.c index 624d9bd5dadd..d2d4652de32c 100644 --- a/sound/soc/pxa/mmp-pcm.c +++ b/sound/soc/pxa/mmp-pcm.c @@ -25,6 +25,8 @@ #include #include +#define DRV_NAME "mmp-pcm" + struct mmp_dma_data { int ssp_id; struct resource *dma_res; @@ -100,7 +102,8 @@ static bool filter(struct dma_chan *chan, void *param) static int mmp_pcm_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct platform_device *pdev = to_platform_device(rtd->platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct platform_device *pdev = to_platform_device(component->dev); struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct mmp_dma_data dma_data; struct resource *r; @@ -211,7 +214,8 @@ err: return ret; } -static const struct snd_soc_platform_driver mmp_soc_platform = { +static const struct snd_soc_component_driver mmp_soc_component = { + .name = DRV_NAME, .ops = &mmp_pcm_ops, .pcm_new = mmp_pcm_new, .pcm_free = mmp_pcm_free_dma_buffers, @@ -231,7 +235,8 @@ static int mmp_pcm_probe(struct platform_device *pdev) mmp_pcm_hardware[SNDRV_PCM_STREAM_CAPTURE].period_bytes_max = pdata->period_max_capture; } - return devm_snd_soc_register_platform(&pdev->dev, &mmp_soc_platform); + return devm_snd_soc_register_component(&pdev->dev, &mmp_soc_component, + NULL, 0); } static struct platform_driver mmp_pcm_driver = { From 0717e66f404123be9c58d8a6559e975acc17fcdd Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:48:35 +0000 Subject: [PATCH 030/102] ASoC: pxa: pxa2xx: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/pxa/pxa2xx-pcm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/pxa/pxa2xx-pcm.c b/sound/soc/pxa/pxa2xx-pcm.c index e64958d8bff0..8b6a70e94c01 100644 --- a/sound/soc/pxa/pxa2xx-pcm.c +++ b/sound/soc/pxa/pxa2xx-pcm.c @@ -84,7 +84,7 @@ static int pxa2xx_soc_pcm_new(struct snd_soc_pcm_runtime *rtd) return ret; } -static const struct snd_soc_platform_driver pxa2xx_soc_platform = { +static const struct snd_soc_component_driver pxa2xx_soc_platform = { .ops = &pxa2xx_pcm_ops, .pcm_new = pxa2xx_soc_pcm_new, .pcm_free = pxa2xx_pcm_free_dma_buffers, @@ -92,7 +92,8 @@ static const struct snd_soc_platform_driver pxa2xx_soc_platform = { static int pxa2xx_soc_platform_probe(struct platform_device *pdev) { - return devm_snd_soc_register_platform(&pdev->dev, &pxa2xx_soc_platform); + return devm_snd_soc_register_component(&pdev->dev, &pxa2xx_soc_platform, + NULL, 0); } #ifdef CONFIG_OF From 121de3b4bee60a817aee2e61df26108ccd6dd6c6 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:48:52 +0000 Subject: [PATCH 031/102] ASoC: qcom: lpass-platform: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/qcom/lpass-platform.c | 42 ++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/sound/soc/qcom/lpass-platform.c b/sound/soc/qcom/lpass-platform.c index caf71aab8196..31fe78aa207f 100644 --- a/sound/soc/qcom/lpass-platform.c +++ b/sound/soc/qcom/lpass-platform.c @@ -24,6 +24,8 @@ #include "lpass-lpaif-reg.h" #include "lpass.h" +#define DRV_NAME "lpass-platform" + struct lpass_pcm_data { int dma_ch; int i2s_port; @@ -61,8 +63,8 @@ static int lpass_platform_pcmops_open(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; struct snd_soc_dai *cpu_dai = soc_runtime->cpu_dai; - struct lpass_data *drvdata = - snd_soc_platform_get_drvdata(soc_runtime->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(soc_runtime, DRV_NAME); + struct lpass_data *drvdata = snd_soc_component_get_drvdata(component); struct lpass_variant *v = drvdata->variant; int ret, dma_ch, dir = substream->stream; struct lpass_pcm_data *data; @@ -115,8 +117,8 @@ static int lpass_platform_pcmops_close(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; - struct lpass_data *drvdata = - snd_soc_platform_get_drvdata(soc_runtime->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(soc_runtime, DRV_NAME); + struct lpass_data *drvdata = snd_soc_component_get_drvdata(component); struct lpass_variant *v = drvdata->variant; struct lpass_pcm_data *data; @@ -132,8 +134,8 @@ static int lpass_platform_pcmops_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; - struct lpass_data *drvdata = - snd_soc_platform_get_drvdata(soc_runtime->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(soc_runtime, DRV_NAME); + struct lpass_data *drvdata = snd_soc_component_get_drvdata(component); struct snd_pcm_runtime *rt = substream->runtime; struct lpass_pcm_data *pcm_data = rt->private_data; struct lpass_variant *v = drvdata->variant; @@ -225,8 +227,8 @@ static int lpass_platform_pcmops_hw_params(struct snd_pcm_substream *substream, static int lpass_platform_pcmops_hw_free(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; - struct lpass_data *drvdata = - snd_soc_platform_get_drvdata(soc_runtime->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(soc_runtime, DRV_NAME); + struct lpass_data *drvdata = snd_soc_component_get_drvdata(component); struct snd_pcm_runtime *rt = substream->runtime; struct lpass_pcm_data *pcm_data = rt->private_data; struct lpass_variant *v = drvdata->variant; @@ -246,8 +248,8 @@ static int lpass_platform_pcmops_prepare(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; - struct lpass_data *drvdata = - snd_soc_platform_get_drvdata(soc_runtime->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(soc_runtime, DRV_NAME); + struct lpass_data *drvdata = snd_soc_component_get_drvdata(component); struct snd_pcm_runtime *rt = substream->runtime; struct lpass_pcm_data *pcm_data = rt->private_data; struct lpass_variant *v = drvdata->variant; @@ -298,8 +300,8 @@ static int lpass_platform_pcmops_trigger(struct snd_pcm_substream *substream, int cmd) { struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; - struct lpass_data *drvdata = - snd_soc_platform_get_drvdata(soc_runtime->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(soc_runtime, DRV_NAME); + struct lpass_data *drvdata = snd_soc_component_get_drvdata(component); struct snd_pcm_runtime *rt = substream->runtime; struct lpass_pcm_data *pcm_data = rt->private_data; struct lpass_variant *v = drvdata->variant; @@ -372,8 +374,8 @@ static snd_pcm_uframes_t lpass_platform_pcmops_pointer( struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; - struct lpass_data *drvdata = - snd_soc_platform_get_drvdata(soc_runtime->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(soc_runtime, DRV_NAME); + struct lpass_data *drvdata = snd_soc_component_get_drvdata(component); struct snd_pcm_runtime *rt = substream->runtime; struct lpass_pcm_data *pcm_data = rt->private_data; struct lpass_variant *v = drvdata->variant; @@ -509,13 +511,14 @@ static int lpass_platform_pcm_new(struct snd_soc_pcm_runtime *soc_runtime) { struct snd_pcm *pcm = soc_runtime->pcm; struct snd_pcm_substream *psubstream, *csubstream; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(soc_runtime, DRV_NAME); int ret = -EINVAL; size_t size = lpass_platform_pcm_hardware.buffer_bytes_max; psubstream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; if (psubstream) { ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, - soc_runtime->platform->dev, + component->dev, size, &psubstream->dma_buffer); if (ret) { dev_err(soc_runtime->dev, "Cannot allocate buffer(s)\n"); @@ -526,7 +529,7 @@ static int lpass_platform_pcm_new(struct snd_soc_pcm_runtime *soc_runtime) csubstream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; if (csubstream) { ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, - soc_runtime->platform->dev, + component->dev, size, &csubstream->dma_buffer); if (ret) { dev_err(soc_runtime->dev, "Cannot allocate buffer(s)\n"); @@ -555,7 +558,8 @@ static void lpass_platform_pcm_free(struct snd_pcm *pcm) } } -static const struct snd_soc_platform_driver lpass_platform_driver = { +static const struct snd_soc_component_driver lpass_component_driver = { + .name = DRV_NAME, .pcm_new = lpass_platform_pcm_new, .pcm_free = lpass_platform_pcm_free, .ops = &lpass_platform_pcm_ops, @@ -591,8 +595,8 @@ int asoc_qcom_lpass_platform_register(struct platform_device *pdev) } - return devm_snd_soc_register_platform(&pdev->dev, - &lpass_platform_driver); + return devm_snd_soc_register_component(&pdev->dev, + &lpass_component_driver, NULL, 0); } EXPORT_SYMBOL_GPL(asoc_qcom_lpass_platform_register); From 17d619da7b4e6ee2b5b54a9e3e321679963afa4d Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:49:08 +0000 Subject: [PATCH 032/102] ASoC: samsung: idma: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/samsung/idma.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/samsung/idma.c b/sound/soc/samsung/idma.c index a635df61f928..b1f09b942410 100644 --- a/sound/soc/samsung/idma.c +++ b/sound/soc/samsung/idma.c @@ -399,7 +399,7 @@ void idma_reg_addr_init(void __iomem *regs, dma_addr_t addr) } EXPORT_SYMBOL_GPL(idma_reg_addr_init); -static const struct snd_soc_platform_driver asoc_idma_platform = { +static const struct snd_soc_component_driver asoc_idma_platform = { .ops = &idma_ops, .pcm_new = idma_new, .pcm_free = idma_free, @@ -411,7 +411,8 @@ static int asoc_idma_platform_probe(struct platform_device *pdev) if (idma_irq < 0) return idma_irq; - return devm_snd_soc_register_platform(&pdev->dev, &asoc_idma_platform); + return devm_snd_soc_register_component(&pdev->dev, &asoc_idma_platform, + NULL, 0); } static struct platform_driver asoc_idma_driver = { From 80f23c295b0bb64a65cd19aa5f09104d21bfa165 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:49:25 +0000 Subject: [PATCH 033/102] ASoC: xtfpga-i2s: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/xtensa/xtfpga-i2s.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/sound/soc/xtensa/xtfpga-i2s.c b/sound/soc/xtensa/xtfpga-i2s.c index 2472144b329e..503560916620 100644 --- a/sound/soc/xtensa/xtfpga-i2s.c +++ b/sound/soc/xtensa/xtfpga-i2s.c @@ -483,13 +483,10 @@ static const struct snd_pcm_ops xtfpga_pcm_ops = { .pointer = xtfpga_pcm_pointer, }; -static const struct snd_soc_platform_driver xtfpga_soc_platform = { - .pcm_new = xtfpga_pcm_new, - .ops = &xtfpga_pcm_ops, -}; - static const struct snd_soc_component_driver xtfpga_i2s_component = { .name = DRV_NAME, + .pcm_new = xtfpga_pcm_new, + .ops = &xtfpga_pcm_ops, }; static const struct snd_soc_dai_ops xtfpga_i2s_dai_ops = { @@ -591,18 +588,13 @@ static int xtfpga_i2s_probe(struct platform_device *pdev) goto err; } - err = snd_soc_register_platform(&pdev->dev, &xtfpga_soc_platform); - if (err < 0) { - dev_err(&pdev->dev, "couldn't register platform\n"); - goto err; - } err = devm_snd_soc_register_component(&pdev->dev, &xtfpga_i2s_component, xtfpga_i2s_dai, ARRAY_SIZE(xtfpga_i2s_dai)); if (err < 0) { dev_err(&pdev->dev, "couldn't register component\n"); - goto err_unregister_platform; + goto err; } pm_runtime_enable(&pdev->dev); @@ -615,8 +607,6 @@ static int xtfpga_i2s_probe(struct platform_device *pdev) err_pm_disable: pm_runtime_disable(&pdev->dev); -err_unregister_platform: - snd_soc_unregister_platform(&pdev->dev); err: dev_err(&pdev->dev, "%s: err = %d\n", __func__, err); return err; @@ -626,7 +616,6 @@ static int xtfpga_i2s_remove(struct platform_device *pdev) { struct xtfpga_i2s *i2s = dev_get_drvdata(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); if (i2s->regmap && !IS_ERR(i2s->regmap)) { regmap_write(i2s->regmap, XTFPGA_I2S_CONFIG, 0); regmap_write(i2s->regmap, XTFPGA_I2S_INT_MASK, 0); From 825f90183bdb6cf02a818a699137191806e088a2 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:49:43 +0000 Subject: [PATCH 034/102] ASoC: blackfin: bf5xx-ac97-pcm: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/blackfin/bf5xx-ac97-pcm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/blackfin/bf5xx-ac97-pcm.c b/sound/soc/blackfin/bf5xx-ac97-pcm.c index 8c1d1983b8f9..08bceb519c29 100644 --- a/sound/soc/blackfin/bf5xx-ac97-pcm.c +++ b/sound/soc/blackfin/bf5xx-ac97-pcm.c @@ -453,7 +453,7 @@ static int bf5xx_pcm_ac97_new(struct snd_soc_pcm_runtime *rtd) return ret; } -static struct snd_soc_platform_driver bf5xx_ac97_soc_platform = { +static struct snd_soc_component_driver bf5xx_ac97_soc_component = { .ops = &bf5xx_pcm_ac97_ops, .pcm_new = bf5xx_pcm_ac97_new, .pcm_free = bf5xx_pcm_free_dma_buffers, @@ -461,8 +461,8 @@ static struct snd_soc_platform_driver bf5xx_ac97_soc_platform = { static int bf5xx_soc_platform_probe(struct platform_device *pdev) { - return devm_snd_soc_register_platform(&pdev->dev, - &bf5xx_ac97_soc_platform); + return devm_snd_soc_register_component(&pdev->dev, + &bf5xx_ac97_soc_component, NULL, 0); } static struct platform_driver bf5xx_pcm_driver = { From abd5ef092aeec03e5c3ce8b20945c6df634b3726 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:50:02 +0000 Subject: [PATCH 035/102] ASoC: blackfin: bf5xx-i2s-pcm: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/blackfin/bf5xx-i2s-pcm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/blackfin/bf5xx-i2s-pcm.c b/sound/soc/blackfin/bf5xx-i2s-pcm.c index 51cae76f14e6..6712b01dabd1 100644 --- a/sound/soc/blackfin/bf5xx-i2s-pcm.c +++ b/sound/soc/blackfin/bf5xx-i2s-pcm.c @@ -347,15 +347,15 @@ static int bf5xx_pcm_i2s_new(struct snd_soc_pcm_runtime *rtd) SNDRV_DMA_TYPE_DEV, card->dev, size, size); } -static struct snd_soc_platform_driver bf5xx_i2s_soc_platform = { +static struct snd_soc_component_driver bf5xx_i2s_soc_component = { .ops = &bf5xx_pcm_i2s_ops, .pcm_new = bf5xx_pcm_i2s_new, }; static int bfin_i2s_soc_platform_probe(struct platform_device *pdev) { - return devm_snd_soc_register_platform(&pdev->dev, - &bf5xx_i2s_soc_platform); + return devm_snd_soc_register_component(&pdev->dev, + &bf5xx_i2s_soc_component, NULL, 0); } static struct platform_driver bfin_i2s_pcm_driver = { From 703c13e447f84a7ed8315938719540ea05ad5045 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:50:19 +0000 Subject: [PATCH 036/102] ASoC: omap-pcm: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/omap/omap-pcm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c index aca2c43d0f03..778cc8f75b6a 100644 --- a/sound/soc/omap/omap-pcm.c +++ b/sound/soc/omap/omap-pcm.c @@ -243,7 +243,7 @@ out: return ret; } -static const struct snd_soc_platform_driver omap_soc_platform = { +static const struct snd_soc_component_driver omap_soc_component = { .ops = &omap_pcm_ops, .pcm_new = omap_pcm_new, .pcm_free = omap_pcm_free_dma_buffers, @@ -252,7 +252,8 @@ static const struct snd_soc_platform_driver omap_soc_platform = { int omap_pcm_platform_register(struct device *dev) { omap_pcm_limit_supported_formats(); - return devm_snd_soc_register_platform(dev, &omap_soc_platform); + return devm_snd_soc_register_component(dev, &omap_soc_component, + NULL, 0); } EXPORT_SYMBOL_GPL(omap_pcm_platform_register); From abf33c7a536f97b78cce6d016768af2253810a15 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:50:37 +0000 Subject: [PATCH 037/102] ASoC: au1x: dbdma2: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/au1x/dbdma2.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sound/soc/au1x/dbdma2.c b/sound/soc/au1x/dbdma2.c index 6a035ca0f521..fb650659c3a3 100644 --- a/sound/soc/au1x/dbdma2.c +++ b/sound/soc/au1x/dbdma2.c @@ -32,6 +32,8 @@ /*#define PCM_DEBUG*/ +#define DRV_NAME "dbdma2" + #define MSG(x...) printk(KERN_INFO "au1xpsc_pcm: " x) #ifdef PCM_DEBUG #define DBG MSG @@ -187,8 +189,8 @@ out: static inline struct au1xpsc_audio_dmadata *to_dmadata(struct snd_pcm_substream *ss) { struct snd_soc_pcm_runtime *rtd = ss->private_data; - struct au1xpsc_audio_dmadata *pcd = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct au1xpsc_audio_dmadata *pcd = snd_soc_component_get_drvdata(component); return &pcd[ss->stream]; } @@ -327,7 +329,8 @@ static int au1xpsc_pcm_new(struct snd_soc_pcm_runtime *rtd) } /* au1xpsc audio platform */ -static struct snd_soc_platform_driver au1xpsc_soc_platform = { +static struct snd_soc_component_driver au1xpsc_soc_component = { + .name = DRV_NAME, .ops = &au1xpsc_pcm_ops, .pcm_new = au1xpsc_pcm_new, }; @@ -344,8 +347,8 @@ static int au1xpsc_pcm_drvprobe(struct platform_device *pdev) platform_set_drvdata(pdev, dmadata); - return devm_snd_soc_register_platform(&pdev->dev, - &au1xpsc_soc_platform); + return devm_snd_soc_register_component(&pdev->dev, + &au1xpsc_soc_component, NULL, 0); } static struct platform_driver au1xpsc_pcm_driver = { From 781a9fcccae535d3f46cd05177366c7e67aa01ef Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:50:54 +0000 Subject: [PATCH 038/102] ASoC: au1x: dma: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/au1x/dma.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sound/soc/au1x/dma.c b/sound/soc/au1x/dma.c index 19457e2b351e..efff1e293a1b 100644 --- a/sound/soc/au1x/dma.c +++ b/sound/soc/au1x/dma.c @@ -21,6 +21,8 @@ #include "psc.h" +#define DRV_NAME "au1x_dma" + struct pcm_period { u32 start; u32 relative_end; /* relative to start of buffer */ @@ -174,7 +176,8 @@ static const struct snd_pcm_hardware alchemy_pcm_hardware = { static inline struct alchemy_pcm_ctx *ss_to_ctx(struct snd_pcm_substream *ss) { struct snd_soc_pcm_runtime *rtd = ss->private_data; - return snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + return snd_soc_component_get_drvdata(component); } static inline struct audio_stream *ss_to_as(struct snd_pcm_substream *ss) @@ -297,7 +300,8 @@ static int alchemy_pcm_new(struct snd_soc_pcm_runtime *rtd) return 0; } -static struct snd_soc_platform_driver alchemy_pcm_soc_platform = { +static struct snd_soc_component_driver alchemy_pcm_soc_component = { + .name = DRV_NAME, .ops = &alchemy_pcm_ops, .pcm_new = alchemy_pcm_new, }; @@ -312,8 +316,8 @@ static int alchemy_pcm_drvprobe(struct platform_device *pdev) platform_set_drvdata(pdev, ctx); - return devm_snd_soc_register_platform(&pdev->dev, - &alchemy_pcm_soc_platform); + return devm_snd_soc_register_component(&pdev->dev, + &alchemy_pcm_soc_component, NULL, 0); } static struct platform_driver alchemy_pcmdma_driver = { From bab9dc53d5bfbfa057e02c5edd97787829ee0b31 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:51:09 +0000 Subject: [PATCH 039/102] ASoC: nuc900-pcm: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/nuc900/nuc900-pcm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/nuc900/nuc900-pcm.c b/sound/soc/nuc900/nuc900-pcm.c index bd6dfa218d59..ad8392a87df9 100644 --- a/sound/soc/nuc900/nuc900-pcm.c +++ b/sound/soc/nuc900/nuc900-pcm.c @@ -299,14 +299,15 @@ static int nuc900_dma_new(struct snd_soc_pcm_runtime *rtd) return 0; } -static const struct snd_soc_platform_driver nuc900_soc_platform = { +static const struct snd_soc_component_driver nuc900_soc_component = { .ops = &nuc900_dma_ops, .pcm_new = nuc900_dma_new, }; static int nuc900_soc_platform_probe(struct platform_device *pdev) { - return devm_snd_soc_register_platform(&pdev->dev, &nuc900_soc_platform); + return devm_snd_soc_register_component(&pdev->dev, &nuc900_soc_component, + NULL, 0); } static struct platform_driver nuc900_pcm_driver = { From e049cf4e6adcb14e34c37123a67158a7e671d000 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:51:26 +0000 Subject: [PATCH 040/102] ASoC: txx9aclc: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/txx9/txx9aclc.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/sound/soc/txx9/txx9aclc.c b/sound/soc/txx9/txx9aclc.c index a2bb68fea5a3..8d31fe628e2f 100644 --- a/sound/soc/txx9/txx9aclc.c +++ b/sound/soc/txx9/txx9aclc.c @@ -23,6 +23,8 @@ #include #include "txx9aclc.h" +#define DRV_NAME "txx9aclc" + static struct txx9aclc_soc_device { struct txx9aclc_dmadata dmadata[2]; } txx9aclc_soc_device; @@ -53,6 +55,7 @@ static int txx9aclc_pcm_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct txx9aclc_dmadata *dmadata = runtime->private_data; int ret; @@ -60,13 +63,13 @@ static int txx9aclc_pcm_hw_params(struct snd_pcm_substream *substream, if (ret < 0) return ret; - dev_dbg(rtd->platform->dev, + dev_dbg(component->dev, "runtime->dma_area = %#lx dma_addr = %#lx dma_bytes = %zd " "runtime->min_align %ld\n", (unsigned long)runtime->dma_area, (unsigned long)runtime->dma_addr, runtime->dma_bytes, runtime->min_align); - dev_dbg(rtd->platform->dev, + dev_dbg(component->dev, "periods %d period_bytes %d stream %d\n", params_periods(params), params_period_bytes(params), substream->stream); @@ -287,7 +290,8 @@ static int txx9aclc_pcm_new(struct snd_soc_pcm_runtime *rtd) struct snd_card *card = rtd->card->snd_card; struct snd_soc_dai *dai = rtd->cpu_dai; struct snd_pcm *pcm = rtd->pcm; - struct platform_device *pdev = to_platform_device(rtd->platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct platform_device *pdev = to_platform_device(component->dev); struct txx9aclc_soc_device *dev; struct resource *r; int i; @@ -371,15 +375,15 @@ static int txx9aclc_dma_init(struct txx9aclc_soc_device *dev, return 0; } -static int txx9aclc_pcm_probe(struct snd_soc_platform *platform) +static int txx9aclc_pcm_probe(struct snd_soc_component *component) { - snd_soc_platform_set_drvdata(platform, &txx9aclc_soc_device); + snd_soc_component_set_drvdata(component, &txx9aclc_soc_device); return 0; } -static int txx9aclc_pcm_remove(struct snd_soc_platform *platform) +static void txx9aclc_pcm_remove(struct snd_soc_component *component) { - struct txx9aclc_soc_device *dev = snd_soc_platform_get_drvdata(platform); + struct txx9aclc_soc_device *dev = snd_soc_component_get_drvdata(component); struct txx9aclc_plat_drvdata *drvdata = txx9aclc_drvdata; void __iomem *base = drvdata->base; int i; @@ -400,10 +404,10 @@ static int txx9aclc_pcm_remove(struct snd_soc_platform *platform) } dev->dmadata[i].dma_chan = NULL; } - return 0; } -static const struct snd_soc_platform_driver txx9aclc_soc_platform = { +static const struct snd_soc_component_driver txx9aclc_soc_component = { + .name = DRV_NAME, .probe = txx9aclc_pcm_probe, .remove = txx9aclc_pcm_remove, .ops = &txx9aclc_pcm_ops, @@ -412,8 +416,8 @@ static const struct snd_soc_platform_driver txx9aclc_soc_platform = { static int txx9aclc_soc_platform_probe(struct platform_device *pdev) { - return devm_snd_soc_register_platform(&pdev->dev, - &txx9aclc_soc_platform); + return devm_snd_soc_register_component(&pdev->dev, + &txx9aclc_soc_component, NULL, 0); } static struct platform_driver txx9aclc_pcm_driver = { From f1b5bf07365d4d6599ce90f49ef96dd8833fbd90 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:51:42 +0000 Subject: [PATCH 041/102] ASoC: mt2701/mt8173: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Tested-by: Garlic Tseng Signed-off-by: Mark Brown --- sound/soc/mediatek/common/mtk-afe-fe-dai.c | 16 ++++-- .../mediatek/common/mtk-afe-platform-driver.c | 9 ++-- .../mediatek/common/mtk-afe-platform-driver.h | 3 +- sound/soc/mediatek/mt2701/mt2701-afe-pcm.c | 50 ++++++++++++------- sound/soc/mediatek/mt8173/mt8173-afe-pcm.c | 42 +++++++++------- 5 files changed, 73 insertions(+), 47 deletions(-) diff --git a/sound/soc/mediatek/common/mtk-afe-fe-dai.c b/sound/soc/mediatek/common/mtk-afe-fe-dai.c index ac231d33d8fe..c91e5f4cd902 100644 --- a/sound/soc/mediatek/common/mtk-afe-fe-dai.c +++ b/sound/soc/mediatek/common/mtk-afe-fe-dai.c @@ -18,6 +18,7 @@ #include #include #include +#include "mtk-afe-platform-driver.h" #include "mtk-afe-fe-dai.h" #include "mtk-base-afe.h" @@ -43,7 +44,8 @@ int mtk_afe_fe_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct snd_pcm_runtime *runtime = substream->runtime; int memif_num = rtd->cpu_dai->id; struct mtk_base_afe_memif *memif = &afe->memif[memif_num]; @@ -105,7 +107,8 @@ void mtk_afe_fe_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; int irq_id; @@ -128,7 +131,8 @@ int mtk_afe_fe_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; int msb_at_bit33 = 0; int ret, fs = 0; @@ -192,7 +196,8 @@ int mtk_afe_fe_trigger(struct snd_pcm_substream *substream, int cmd, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime * const runtime = substream->runtime; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; struct mtk_base_afe_irq *irqs = &afe->irqs[memif->irq_usage]; const struct mtk_base_irq_data *irq_data = irqs->irq_data; @@ -255,7 +260,8 @@ int mtk_afe_fe_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; int hd_audio = 0; diff --git a/sound/soc/mediatek/common/mtk-afe-platform-driver.c b/sound/soc/mediatek/common/mtk-afe-platform-driver.c index 82d439c15f4e..53215b52e4f2 100644 --- a/sound/soc/mediatek/common/mtk-afe-platform-driver.c +++ b/sound/soc/mediatek/common/mtk-afe-platform-driver.c @@ -25,7 +25,8 @@ static snd_pcm_uframes_t mtk_afe_pcm_pointer (struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; const struct mtk_base_memif_data *memif_data = memif->data; struct regmap *regmap = afe->regmap; @@ -65,7 +66,8 @@ static int mtk_afe_pcm_new(struct snd_soc_pcm_runtime *rtd) size_t size; struct snd_card *card = rtd->card->snd_card; struct snd_pcm *pcm = rtd->pcm; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); size = afe->mtk_afe_hardware->buffer_bytes_max; return snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, @@ -77,7 +79,8 @@ static void mtk_afe_pcm_free(struct snd_pcm *pcm) snd_pcm_lib_preallocate_free_for_all(pcm); } -const struct snd_soc_platform_driver mtk_afe_pcm_platform = { +const struct snd_soc_component_driver mtk_afe_pcm_platform = { + .name = AFE_PCM_NAME, .ops = &mtk_afe_pcm_ops, .pcm_new = mtk_afe_pcm_new, .pcm_free = mtk_afe_pcm_free, diff --git a/sound/soc/mediatek/common/mtk-afe-platform-driver.h b/sound/soc/mediatek/common/mtk-afe-platform-driver.h index a973fc9253b4..8dcdbed959ea 100644 --- a/sound/soc/mediatek/common/mtk-afe-platform-driver.h +++ b/sound/soc/mediatek/common/mtk-afe-platform-driver.h @@ -17,7 +17,8 @@ #ifndef _MTK_AFE_PLATFORM_DRIVER_H_ #define _MTK_AFE_PLATFORM_DRIVER_H_ -extern const struct snd_soc_platform_driver mtk_afe_pcm_platform; +#define AFE_PCM_NAME "mtk-afe-pcm" +extern const struct snd_soc_component_driver mtk_afe_pcm_platform; #endif diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c index d68b53f7cefe..f7e0702d92f8 100644 --- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c +++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c @@ -93,7 +93,8 @@ static int mt2701_afe_i2s_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id); if (i2s_num < 0) @@ -108,7 +109,8 @@ static int mt2701_afe_i2s_path_shutdown(struct snd_pcm_substream *substream, int dir_invert) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt2701_afe_private *afe_priv = afe->platform_priv; struct mt2701_i2s_path *i2s_path = &afe_priv->i2s_path[i2s_num]; const struct mt2701_i2s_data *i2s_data; @@ -144,7 +146,8 @@ static void mt2701_afe_i2s_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt2701_afe_private *afe_priv = afe->platform_priv; int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id); struct mt2701_i2s_path *i2s_path; @@ -176,7 +179,8 @@ static int mt2701_i2s_path_prepare_enable(struct snd_pcm_substream *substream, int dir_invert) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt2701_afe_private *afe_priv = afe->platform_priv; struct mt2701_i2s_path *i2s_path = &afe_priv->i2s_path[i2s_num]; const struct mt2701_i2s_data *i2s_data; @@ -247,7 +251,8 @@ static int mt2701_afe_i2s_prepare(struct snd_pcm_substream *substream, { int clk_domain; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt2701_afe_private *afe_priv = afe->platform_priv; int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id); struct mt2701_i2s_path *i2s_path; @@ -312,7 +317,8 @@ static int mt2701_btmrg_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt2701_afe_private *afe_priv = afe->platform_priv; int ret; @@ -329,7 +335,8 @@ static int mt2701_btmrg_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); int stream_fs; u32 val, msk; @@ -372,7 +379,8 @@ static void mt2701_btmrg_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt2701_afe_private *afe_priv = afe->platform_priv; /* if the other direction stream is not occupied */ @@ -392,7 +400,8 @@ static int mt2701_simple_fe_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); int stream_dir = substream->stream; int memif_num = rtd->cpu_dai->id; struct mtk_base_afe_memif *memif_tmp; @@ -414,7 +423,8 @@ static int mt2701_simple_fe_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); int stream_dir = substream->stream; /* single DL use PAIR_INTERLEAVE */ @@ -431,7 +441,8 @@ static int mt2701_dlm_fe_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mtk_base_afe_memif *memif_tmp; const struct mtk_base_memif_data *memif_data; int i; @@ -458,7 +469,8 @@ static void mt2701_dlm_fe_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); const struct mtk_base_memif_data *memif_data; int i; @@ -477,7 +489,8 @@ static int mt2701_dlm_fe_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); int channels = params_channels(params); regmap_update_bits(afe->regmap, @@ -500,7 +513,8 @@ static int mt2701_dlm_fe_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mtk_base_afe_memif *memif_tmp = &afe->memif[MT2701_MEMIF_DL1]; switch (cmd) { @@ -1517,7 +1531,8 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev) } pm_runtime_get_sync(dev); - ret = snd_soc_register_platform(dev, &mtk_afe_pcm_platform); + ret = devm_snd_soc_register_component(&pdev->dev, &mtk_afe_pcm_platform, + NULL, 0); if (ret) { dev_warn(dev, "err_platform\n"); goto err_platform; @@ -1526,13 +1541,11 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev) ret = mt2701_afe_add_component(afe); if (ret) { dev_warn(dev, "err_dai_component\n"); - goto err_dai_component; + goto err_platform; } return 0; -err_dai_component: - snd_soc_unregister_platform(dev); err_platform: pm_runtime_put_sync(dev); err_pm_disable: @@ -1549,7 +1562,6 @@ static int mt2701_afe_pcm_dev_remove(struct platform_device *pdev) mt2701_afe_runtime_suspend(&pdev->dev); snd_soc_unregister_component(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); return 0; } diff --git a/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c b/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c index c7f7f8add5d9..65d1433a0944 100644 --- a/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c +++ b/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c @@ -304,7 +304,8 @@ static int mt8173_afe_i2s_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); if (dai->active) return 0; @@ -318,7 +319,8 @@ static void mt8173_afe_i2s_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); if (dai->active) return; @@ -334,7 +336,8 @@ static int mt8173_afe_i2s_prepare(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime * const runtime = substream->runtime; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt8173_afe_private *afe_priv = afe->platform_priv; int ret; @@ -356,7 +359,8 @@ static int mt8173_afe_hdmi_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt8173_afe_private *afe_priv = afe->platform_priv; if (dai->active) @@ -371,7 +375,8 @@ static void mt8173_afe_hdmi_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt8173_afe_private *afe_priv = afe->platform_priv; if (dai->active) @@ -386,7 +391,8 @@ static int mt8173_afe_hdmi_prepare(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime * const runtime = substream->runtime; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt8173_afe_private *afe_priv = afe->platform_priv; unsigned int val; @@ -449,7 +455,8 @@ static int mt8173_afe_hdmi_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); dev_info(afe->dev, "%s cmd=%d %s\n", __func__, cmd, dai->name); @@ -498,7 +505,8 @@ static int mt8173_memif_fs(struct snd_pcm_substream *substream, unsigned int rate) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; int fs; @@ -1172,31 +1180,29 @@ static int mt8173_afe_pcm_dev_probe(struct platform_device *pdev) afe->runtime_resume = mt8173_afe_runtime_resume; afe->runtime_suspend = mt8173_afe_runtime_suspend; - ret = snd_soc_register_platform(&pdev->dev, &mtk_afe_pcm_platform); + ret = devm_snd_soc_register_component(&pdev->dev, + &mtk_afe_pcm_platform, + NULL, 0); if (ret) goto err_pm_disable; - ret = snd_soc_register_component(&pdev->dev, + ret = devm_snd_soc_register_component(&pdev->dev, &mt8173_afe_pcm_dai_component, mt8173_afe_pcm_dais, ARRAY_SIZE(mt8173_afe_pcm_dais)); if (ret) - goto err_platform; + goto err_pm_disable; - ret = snd_soc_register_component(&pdev->dev, + ret = devm_snd_soc_register_component(&pdev->dev, &mt8173_afe_hdmi_dai_component, mt8173_afe_hdmi_dais, ARRAY_SIZE(mt8173_afe_hdmi_dais)); if (ret) - goto err_comp; + goto err_pm_disable; dev_info(&pdev->dev, "MT8173 AFE driver initialized.\n"); return 0; -err_comp: - snd_soc_unregister_component(&pdev->dev); -err_platform: - snd_soc_unregister_platform(&pdev->dev); err_pm_disable: pm_runtime_disable(&pdev->dev); return ret; @@ -1207,8 +1213,6 @@ static int mt8173_afe_pcm_dev_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); if (!pm_runtime_status_suspended(&pdev->dev)) mt8173_afe_runtime_suspend(&pdev->dev); - snd_soc_unregister_component(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); return 0; } From 66bf428e555cdbf77c5a9cffefd8fca4af76ce9d Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:51:58 +0000 Subject: [PATCH 042/102] ASoC: stm: stm32_adfsdm: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/stm/stm32_adfsdm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/soc/stm/stm32_adfsdm.c b/sound/soc/stm/stm32_adfsdm.c index 7306e3eca9e1..db73fef3e500 100644 --- a/sound/soc/stm/stm32_adfsdm.c +++ b/sound/soc/stm/stm32_adfsdm.c @@ -281,7 +281,7 @@ static void stm32_adfsdm_pcm_free(struct snd_pcm *pcm) } } -static struct snd_soc_platform_driver stm32_adfsdm_soc_platform = { +static struct snd_soc_component_driver stm32_adfsdm_soc_platform = { .ops = &stm32_adfsdm_pcm_ops, .pcm_new = stm32_adfsdm_pcm_new, .pcm_free = stm32_adfsdm_pcm_free, @@ -322,8 +322,9 @@ static int stm32_adfsdm_probe(struct platform_device *pdev) if (IS_ERR(priv->iio_cb)) return PTR_ERR(priv->iio_cb); - ret = devm_snd_soc_register_platform(&pdev->dev, - &stm32_adfsdm_soc_platform); + ret = devm_snd_soc_register_component(&pdev->dev, + &stm32_adfsdm_soc_platform, + NULL, 0); if (ret < 0) dev_err(&pdev->dev, "%s: Failed to register PCM platform\n", __func__); From 03a0ddeda7ebafea8e99078581a50d856e3587a4 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:58:01 +0000 Subject: [PATCH 043/102] ASoC: soc-utils: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/soc-utils.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c index e237858c9ed4..2d9e98bd1530 100644 --- a/sound/soc/soc-utils.c +++ b/sound/soc/soc-utils.c @@ -288,7 +288,12 @@ static const struct snd_soc_component_driver dummy_platform = { .ops = &dummy_dma_ops, }; -static const struct snd_soc_codec_driver dummy_codec; +static const struct snd_soc_component_driver dummy_codec = { + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, +}; #define STUB_RATES SNDRV_PCM_RATE_8000_192000 #define STUB_FORMATS (SNDRV_PCM_FMTBIT_S8 | \ @@ -338,33 +343,22 @@ static int snd_soc_dummy_probe(struct platform_device *pdev) { int ret; - ret = snd_soc_register_codec(&pdev->dev, &dummy_codec, &dummy_dai, 1); + ret = devm_snd_soc_register_component(&pdev->dev, + &dummy_codec, &dummy_dai, 1); if (ret < 0) return ret; ret = devm_snd_soc_register_component(&pdev->dev, &dummy_platform, NULL, 0); - if (ret < 0) { - snd_soc_unregister_codec(&pdev->dev); - return ret; - } return ret; } -static int snd_soc_dummy_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - - return 0; -} - static struct platform_driver soc_dummy_driver = { .driver = { .name = "snd-soc-dummy", }, .probe = snd_soc_dummy_probe, - .remove = snd_soc_dummy_remove, }; static struct platform_device *soc_dummy_dev; From 09787492537462e3c7b8f67b30ff9704062f97cc Mon Sep 17 00:00:00 2001 From: Abhijeet Kumar Date: Tue, 23 Jan 2018 23:00:51 +0530 Subject: [PATCH 044/102] ALSA: hda: Copying sync power state helper to core The current sync_power_state is local to hda code, moving it core so that other users apart from hda legacy can use it. The helper function ensures the actual state reaches the target state. Signed-off-by: Abhijeet Kumar Signed-off-by: Takashi Iwai --- include/sound/hdaudio.h | 2 ++ sound/hda/hdac_device.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h index 68169e3749de..4c93ff5301bd 100644 --- a/include/sound/hdaudio.h +++ b/include/sound/hdaudio.h @@ -146,6 +146,8 @@ int snd_hdac_codec_write(struct hdac_device *hdac, hda_nid_t nid, int flags, unsigned int verb, unsigned int parm); bool snd_hdac_check_power_state(struct hdac_device *hdac, hda_nid_t nid, unsigned int target_state); +unsigned int snd_hdac_sync_power_state(struct hdac_device *hdac, + hda_nid_t nid, unsigned int target_state); /** * snd_hdac_read_parm - read a codec parameter * @codec: the codec object diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c index 06f845e293cb..7ba100bb1c3f 100644 --- a/sound/hda/hdac_device.c +++ b/sound/hda/hdac_device.c @@ -3,6 +3,7 @@ */ #include +#include #include #include #include @@ -1064,3 +1065,37 @@ bool snd_hdac_check_power_state(struct hdac_device *hdac, return (state == target_state); } EXPORT_SYMBOL_GPL(snd_hdac_check_power_state); +/** + * snd_hdac_sync_power_state - wait until actual power state matches + * with the target state + * + * @hdac: the HDAC device + * @nid: NID to send the command + * @target_state: target state to check for + * + * Return power state or PS_ERROR if codec rejects GET verb. + */ +unsigned int snd_hdac_sync_power_state(struct hdac_device *codec, + hda_nid_t nid, unsigned int power_state) +{ + unsigned long end_time = jiffies + msecs_to_jiffies(500); + unsigned int state, actual_state, count; + + for (count = 0; count < 500; count++) { + state = snd_hdac_codec_read(codec, nid, 0, + AC_VERB_GET_POWER_STATE, 0); + if (state & AC_PWRST_ERROR) { + msleep(20); + break; + } + actual_state = (state >> 4) & 0x0f; + if (actual_state == power_state) + break; + if (time_after_eq(jiffies, end_time)) + break; + /* wait until the codec reachs to the target state */ + msleep(1); + } + return state; +} +EXPORT_SYMBOL_GPL(snd_hdac_sync_power_state); From 3b5b899ca67db07a4c4825911072221f99e157e2 Mon Sep 17 00:00:00 2001 From: Abhijeet Kumar Date: Tue, 23 Jan 2018 23:00:52 +0530 Subject: [PATCH 045/102] ALSA: hda: Make use of core codec functions to sync power state Since sync_power_state is moved to core it's better to use the helper function to ensure the actual power state reaches target instead of using the local helper functions already exsisting in hda code. Signed-off-by: Abhijeet Kumar Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 28 +--------------------------- sound/pci/hda/hda_local.h | 6 +++++- 2 files changed, 6 insertions(+), 28 deletions(-) diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index e018ecbf78a8..5bc3a7468e17 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -2702,32 +2702,6 @@ void snd_hda_codec_set_power_to_all(struct hda_codec *codec, hda_nid_t fg, } EXPORT_SYMBOL_GPL(snd_hda_codec_set_power_to_all); -/* - * wait until the state is reached, returns the current state - */ -static unsigned int hda_sync_power_state(struct hda_codec *codec, - hda_nid_t fg, - unsigned int power_state) -{ - unsigned long end_time = jiffies + msecs_to_jiffies(500); - unsigned int state, actual_state; - - for (;;) { - state = snd_hda_codec_read(codec, fg, 0, - AC_VERB_GET_POWER_STATE, 0); - if (state & AC_PWRST_ERROR) - break; - actual_state = (state >> 4) & 0x0f; - if (actual_state == power_state) - break; - if (time_after_eq(jiffies, end_time)) - break; - /* wait until the codec reachs to the target state */ - msleep(1); - } - return state; -} - /** * snd_hda_codec_eapd_power_filter - A power filter callback for EAPD * @codec: the HDA codec @@ -2790,7 +2764,7 @@ static unsigned int hda_set_power_state(struct hda_codec *codec, state); snd_hda_codec_set_power_to_all(codec, fg, power_state); } - state = hda_sync_power_state(codec, fg, power_state); + state = snd_hda_sync_power_state(codec, fg, power_state); if (!(state & AC_PWRST_ERROR)) break; } diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 5b5c324c99b9..321e78baa63c 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h @@ -622,7 +622,11 @@ snd_hda_check_power_state(struct hda_codec *codec, hda_nid_t nid, { return snd_hdac_check_power_state(&codec->core, nid, target_state); } - +static inline bool snd_hda_sync_power_state(struct hda_codec *codec, + hda_nid_t nid, unsigned int target_state) +{ + return snd_hdac_sync_power_state(&codec->core, nid, target_state); +} unsigned int snd_hda_codec_eapd_power_filter(struct hda_codec *codec, hda_nid_t nid, unsigned int power_state); From 753597fbb7031ff147d4f2862426699e4ad8efca Mon Sep 17 00:00:00 2001 From: Abhijeet Kumar Date: Thu, 15 Feb 2018 14:05:38 +0530 Subject: [PATCH 046/102] ASoC: hdac_hdmi : Ensuring proper setting of output widget power state In usecases like hot plug-unplug DP panel or modeset during a playback, sometimes we observe no audio after codec resets. During no audio condition, we have noticed that the power state of the pin or the connector is D3. Optimizing the way we set the power mitigates the issue. With this changes the verb is sent to set the power state and waits until actual state reaches target state. Thus ensuring power state is set. Signed-off-by: Abhijeet Kumar Signed-off-by: Mark Brown --- sound/soc/codecs/hdac_hdmi.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index 0758927d1e06..60bea9d69fc0 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c @@ -718,10 +718,22 @@ static struct hdac_hdmi_pcm *hdac_hdmi_get_pcm(struct hdac_ext_device *edev, static void hdac_hdmi_set_power_state(struct hdac_ext_device *edev, hda_nid_t nid, unsigned int pwr_state) { + int count; + unsigned int state; + if (get_wcaps(&edev->hdev, nid) & AC_WCAP_POWER) { - if (!snd_hdac_check_power_state(&edev->hdev, nid, pwr_state)) - snd_hdac_codec_write(&edev->hdev, nid, 0, - AC_VERB_SET_POWER_STATE, pwr_state); + if (!snd_hdac_check_power_state(&edev->hdac, nid, pwr_state)) { + for (count = 0; count < 10; count++) { + snd_hdac_codec_read(&edev->hdac, nid, 0, + AC_VERB_SET_POWER_STATE, + pwr_state); + state = snd_hdac_sync_power_state(&edev->hdac, + nid, pwr_state); + if (!(state & AC_PWRST_ERROR)) + break; + } + } + } } From 0b9751c7179b8ec7a33addc3a8b2b1639d4678cb Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Thu, 15 Feb 2018 17:14:16 +0000 Subject: [PATCH 047/102] ASoC: Intel: Fix build One of the recently introduced commits hadn't been build tested, fix that. Reported-by: kbuild test robot Signed-off-by: Mark Brown --- sound/soc/codecs/hdac_hdmi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index 60bea9d69fc0..84f7a7a36e4b 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c @@ -722,12 +722,12 @@ static void hdac_hdmi_set_power_state(struct hdac_ext_device *edev, unsigned int state; if (get_wcaps(&edev->hdev, nid) & AC_WCAP_POWER) { - if (!snd_hdac_check_power_state(&edev->hdac, nid, pwr_state)) { + if (!snd_hdac_check_power_state(&edev->hdev, nid, pwr_state)) { for (count = 0; count < 10; count++) { - snd_hdac_codec_read(&edev->hdac, nid, 0, + snd_hdac_codec_read(&edev->hdev, nid, 0, AC_VERB_SET_POWER_STATE, pwr_state); - state = snd_hdac_sync_power_state(&edev->hdac, + state = snd_hdac_sync_power_state(&edev->hdev, nid, pwr_state); if (!(state & AC_PWRST_ERROR)) break; From b3ea70ee64ea50d6719f09f781ff11ac9c86d0c2 Mon Sep 17 00:00:00 2001 From: Naveen Manohar Date: Mon, 5 Feb 2018 09:59:56 +0530 Subject: [PATCH 048/102] ASoC: Intel: Add Kabylake-y Dialog Maxim machine driver This patch adds Kabylake-y I2S machine driver which uses DA7219 as headset on ssp1 and MAX98357A codec as speaker on ssp0. Signed-off-by: Naveen Manohar Signed-off-by: Mark Brown --- sound/soc/intel/boards/Kconfig | 14 + sound/soc/intel/boards/Makefile | 2 + sound/soc/intel/boards/kbl_da7219_max98357a.c | 613 ++++++++++++++++++ 3 files changed, 629 insertions(+) create mode 100644 sound/soc/intel/boards/kbl_da7219_max98357a.c diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig index fefb1ee9fec6..eedc83b96fbb 100644 --- a/sound/soc/intel/boards/Kconfig +++ b/sound/soc/intel/boards/Kconfig @@ -256,6 +256,20 @@ config SND_SOC_INTEL_KBL_RT5663_RT5514_MAX98927_MACH create an alsa sound card for RT5663 + RT5514 + MAX98927. Say Y or m if you have such a device. This is a recommended option. If unsure select "N". + +config SND_SOC_INTEL_KBL_DA7219_MAX98357A_MACH + tristate "KBL with DA7219 and MAX98357A in I2S Mode" + depends on MFD_INTEL_LPSS && I2C && ACPI + select SND_SOC_DA7219 + select SND_SOC_MAX98357A + select SND_SOC_DMIC + select SND_SOC_HDAC_HDMI + help + This adds support for ASoC Onboard Codec I2S machine driver. This will + create an alsa sound card for DA7219 + MAX98357A I2S audio codec. + Say Y if you have such a device. + If unsure select "N". + endif ## SND_SOC_INTEL_SKYLAKE endif ## SND_SOC_INTEL_MACH diff --git a/sound/soc/intel/boards/Makefile b/sound/soc/intel/boards/Makefile index 69d2dfaeb00c..6fae506c40fa 100644 --- a/sound/soc/intel/boards/Makefile +++ b/sound/soc/intel/boards/Makefile @@ -14,6 +14,7 @@ snd-soc-sst-cht-bsw-max98090_ti-objs := cht_bsw_max98090_ti.o snd-soc-sst-byt-cht-da7213-objs := bytcht_da7213.o snd-soc-sst-byt-cht-es8316-objs := bytcht_es8316.o snd-soc-sst-byt-cht-nocodec-objs := bytcht_nocodec.o +snd-soc-kbl_da7219_max98357a-objs := kbl_da7219_max98357a.o snd-soc-kbl_rt5663_max98927-objs := kbl_rt5663_max98927.o snd-soc-kbl_rt5663_rt5514_max98927-objs := kbl_rt5663_rt5514_max98927.o snd-soc-skl_rt286-objs := skl_rt286.o @@ -35,6 +36,7 @@ obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_MAX98090_TI_MACH) += snd-soc-sst-cht-bsw-max9 obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_DA7213_MACH) += snd-soc-sst-byt-cht-da7213.o obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_ES8316_MACH) += snd-soc-sst-byt-cht-es8316.o obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH) += snd-soc-sst-byt-cht-nocodec.o +obj-$(CONFIG_SND_SOC_INTEL_KBL_DA7219_MAX98357A_MACH) += snd-soc-kbl_da7219_max98357a.o obj-$(CONFIG_SND_SOC_INTEL_KBL_RT5663_MAX98927_MACH) += snd-soc-kbl_rt5663_max98927.o obj-$(CONFIG_SND_SOC_INTEL_KBL_RT5663_RT5514_MAX98927_MACH) += snd-soc-kbl_rt5663_rt5514_max98927.o obj-$(CONFIG_SND_SOC_INTEL_SKL_RT286_MACH) += snd-soc-skl_rt286.o diff --git a/sound/soc/intel/boards/kbl_da7219_max98357a.c b/sound/soc/intel/boards/kbl_da7219_max98357a.c new file mode 100644 index 000000000000..d689124f6687 --- /dev/null +++ b/sound/soc/intel/boards/kbl_da7219_max98357a.c @@ -0,0 +1,613 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright(c) 2017-18 Intel Corporation. + +/* + * Intel Kabylake I2S Machine Driver with MAX98357A & DA7219 Codecs + * + * Modified from: + * Intel Kabylake I2S Machine driver supporting MAXIM98927 and + * RT5663 codecs + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../codecs/da7219.h" +#include "../../codecs/hdac_hdmi.h" +#include "../skylake/skl.h" +#include "../../codecs/da7219-aad.h" + +#define KBL_DIALOG_CODEC_DAI "da7219-hifi" +#define KBL_MAXIM_CODEC_DAI "HiFi" +#define MAXIM_DEV0_NAME "MX98357A:00" +#define DUAL_CHANNEL 2 +#define QUAD_CHANNEL 4 + +static struct snd_soc_card *kabylake_audio_card; +static struct snd_soc_jack skylake_hdmi[3]; + +struct kbl_hdmi_pcm { + struct list_head head; + struct snd_soc_dai *codec_dai; + int device; +}; + +struct kbl_codec_private { + struct snd_soc_jack kabylake_headset; + struct list_head hdmi_pcm_list; +}; + +enum { + KBL_DPCM_AUDIO_PB = 0, + KBL_DPCM_AUDIO_CP, + KBL_DPCM_AUDIO_DMIC_CP, + KBL_DPCM_AUDIO_HDMI1_PB, + KBL_DPCM_AUDIO_HDMI2_PB, + KBL_DPCM_AUDIO_HDMI3_PB, +}; + +static int platform_clock_control(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *k, int event) +{ + struct snd_soc_dapm_context *dapm = w->dapm; + struct snd_soc_card *card = dapm->card; + struct snd_soc_dai *codec_dai; + int ret = 0; + + codec_dai = snd_soc_card_get_codec_dai(card, KBL_DIALOG_CODEC_DAI); + if (!codec_dai) { + dev_err(card->dev, "Codec dai not found; Unable to set/unset codec pll\n"); + return -EIO; + } + + /* Configure sysclk for codec */ + ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK, 24576000, + SND_SOC_CLOCK_IN); + if (ret) { + dev_err(card->dev, "can't set codec sysclk configuration\n"); + return ret; + } + + if (SND_SOC_DAPM_EVENT_OFF(event)) { + ret = snd_soc_dai_set_pll(codec_dai, 0, + DA7219_SYSCLK_MCLK, 0, 0); + if (ret) + dev_err(card->dev, "failed to stop PLL: %d\n", ret); + } else if (SND_SOC_DAPM_EVENT_ON(event)) { + ret = snd_soc_dai_set_pll(codec_dai, 0, DA7219_SYSCLK_PLL_SRM, + 0, DA7219_PLL_FREQ_OUT_98304); + if (ret) + dev_err(card->dev, "failed to start PLL: %d\n", ret); + } + + return ret; +} + +static const struct snd_kcontrol_new kabylake_controls[] = { + SOC_DAPM_PIN_SWITCH("Headphone Jack"), + SOC_DAPM_PIN_SWITCH("Headset Mic"), + SOC_DAPM_PIN_SWITCH("Spk"), +}; + +static const struct snd_soc_dapm_widget kabylake_widgets[] = { + SND_SOC_DAPM_HP("Headphone Jack", NULL), + SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_SPK("Spk", NULL), + SND_SOC_DAPM_MIC("SoC DMIC", NULL), + SND_SOC_DAPM_SPK("DP", NULL), + SND_SOC_DAPM_SPK("HDMI", NULL), + SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, + platform_clock_control, SND_SOC_DAPM_PRE_PMU | + SND_SOC_DAPM_POST_PMD), +}; + +static const struct snd_soc_dapm_route kabylake_map[] = { + { "Headphone Jack", NULL, "HPL" }, + { "Headphone Jack", NULL, "HPR" }, + + /* speaker */ + { "Spk", NULL, "Speaker" }, + + /* other jacks */ + { "MIC", NULL, "Headset Mic" }, + { "DMic", NULL, "SoC DMIC" }, + + { "HDMI", NULL, "hif5 Output" }, + { "DP", NULL, "hif6 Output" }, + + /* CODEC BE connections */ + { "HiFi Playback", NULL, "ssp0 Tx" }, + { "ssp0 Tx", NULL, "codec0_out" }, + + { "Playback", NULL, "ssp1 Tx" }, + { "ssp1 Tx", NULL, "codec1_out" }, + + { "codec0_in", NULL, "ssp1 Rx" }, + { "ssp1 Rx", NULL, "Capture" }, + + /* DMIC */ + { "dmic01_hifi", NULL, "DMIC01 Rx" }, + { "DMIC01 Rx", NULL, "DMIC AIF" }, + + { "hifi1", NULL, "iDisp1 Tx" }, + { "iDisp1 Tx", NULL, "iDisp1_out" }, + { "hifi2", NULL, "iDisp2 Tx" }, + { "iDisp2 Tx", NULL, "iDisp2_out" }, + { "hifi3", NULL, "iDisp3 Tx"}, + { "iDisp3 Tx", NULL, "iDisp3_out"}, + + { "Headphone Jack", NULL, "Platform Clock" }, + { "Headset Mic", NULL, "Platform Clock" }, +}; + +static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params) +{ + struct snd_interval *rate = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_RATE); + struct snd_interval *channels = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_CHANNELS); + struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); + + /* The ADSP will convert the FE rate to 48k, stereo */ + rate->min = rate->max = 48000; + channels->min = channels->max = DUAL_CHANNEL; + + /* set SSP to 24 bit */ + snd_mask_none(fmt); + snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE); + + return 0; +} + +static int kabylake_da7219_codec_init(struct snd_soc_pcm_runtime *rtd) +{ + struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card); + struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_jack *jack; + int ret; + + /* + * Headset buttons map to the google Reference headset. + * These can be configured by userspace. + */ + ret = snd_soc_card_jack_new(kabylake_audio_card, "Headset Jack", + SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3 | SND_JACK_LINEOUT, + &ctx->kabylake_headset, NULL, 0); + if (ret) { + dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret); + return ret; + } + + jack = &ctx->kabylake_headset; + + snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_MEDIA); + snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOLUMEUP); + snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN); + snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOICECOMMAND); + da7219_aad_jack_det(codec, &ctx->kabylake_headset); + + ret = snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); + if (ret) + dev_err(rtd->dev, "SoC DMIC - Ignore suspend failed %d\n", ret); + + return ret; +} + +static int kabylake_hdmi_init(struct snd_soc_pcm_runtime *rtd, int device) +{ + struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card); + struct snd_soc_dai *dai = rtd->codec_dai; + struct kbl_hdmi_pcm *pcm; + + pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); + if (!pcm) + return -ENOMEM; + + pcm->device = device; + pcm->codec_dai = dai; + + list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); + + return 0; +} + +static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd) +{ + return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI1_PB); +} + +static int kabylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd) +{ + return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI2_PB); +} + +static int kabylake_hdmi3_init(struct snd_soc_pcm_runtime *rtd) +{ + return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI3_PB); +} + +static int kabylake_da7219_fe_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_dapm_context *dapm; + struct snd_soc_component *component = rtd->cpu_dai->component; + + dapm = snd_soc_component_get_dapm(component); + snd_soc_dapm_ignore_suspend(dapm, "Reference Capture"); + + return 0; +} + +static const unsigned int rates[] = { + 48000, +}; + +static const struct snd_pcm_hw_constraint_list constraints_rates = { + .count = ARRAY_SIZE(rates), + .list = rates, + .mask = 0, +}; + +static const unsigned int channels[] = { + DUAL_CHANNEL, +}; + +static const struct snd_pcm_hw_constraint_list constraints_channels = { + .count = ARRAY_SIZE(channels), + .list = channels, + .mask = 0, +}; + +static unsigned int channels_quad[] = { + QUAD_CHANNEL, +}; + +static struct snd_pcm_hw_constraint_list constraints_channels_quad = { + .count = ARRAY_SIZE(channels_quad), + .list = channels_quad, + .mask = 0, +}; + +static int kbl_fe_startup(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + + /* + * On this platform for PCM device we support, + * 48Khz + * stereo + * 16 bit audio + */ + + runtime->hw.channels_max = DUAL_CHANNEL; + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, + &constraints_channels); + + runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE; + snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16); + + snd_pcm_hw_constraint_list(runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); + + return 0; +} + +static const struct snd_soc_ops kabylake_da7219_fe_ops = { + .startup = kbl_fe_startup, +}; + +static int kabylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params) +{ + struct snd_interval *channels = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_CHANNELS); + + /* + * set BE channel constraint as user FE channels + */ + + if (params_channels(params) == 2) + channels->min = channels->max = 2; + else + channels->min = channels->max = 4; + + return 0; +} + +static int kabylake_dmic_startup(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + + runtime->hw.channels_min = runtime->hw.channels_max = QUAD_CHANNEL; + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, + &constraints_channels_quad); + + return snd_pcm_hw_constraint_list(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); +} + +static struct snd_soc_ops kabylake_dmic_ops = { + .startup = kabylake_dmic_startup, +}; + +static const unsigned int rates_16000[] = { + 16000, +}; + +static const struct snd_pcm_hw_constraint_list constraints_16000 = { + .count = ARRAY_SIZE(rates_16000), + .list = rates_16000, +}; + +static const unsigned int ch_mono[] = { + 1, +}; + +/* kabylake digital audio interface glue - connects codec <--> CPU */ +static struct snd_soc_dai_link kabylake_dais[] = { + /* Front End DAI links */ + [KBL_DPCM_AUDIO_PB] = { + .name = "Kbl Audio Port", + .stream_name = "Audio", + .cpu_dai_name = "System Pin", + .platform_name = "0000:00:1f.3", + .dynamic = 1, + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .nonatomic = 1, + .init = kabylake_da7219_fe_init, + .trigger = { + SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, + .dpcm_playback = 1, + .ops = &kabylake_da7219_fe_ops, + }, + [KBL_DPCM_AUDIO_CP] = { + .name = "Kbl Audio Capture Port", + .stream_name = "Audio Record", + .cpu_dai_name = "System Pin", + .platform_name = "0000:00:1f.3", + .dynamic = 1, + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .nonatomic = 1, + .trigger = { + SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, + .dpcm_capture = 1, + }, + [KBL_DPCM_AUDIO_DMIC_CP] = { + .name = "Kbl Audio DMIC cap", + .stream_name = "dmiccap", + .cpu_dai_name = "DMIC Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:1f.3", + .init = NULL, + .dpcm_capture = 1, + .nonatomic = 1, + .dynamic = 1, + .ops = &kabylake_dmic_ops, + }, + [KBL_DPCM_AUDIO_HDMI1_PB] = { + .name = "Kbl HDMI Port1", + .stream_name = "Hdmi1", + .cpu_dai_name = "HDMI1 Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:1f.3", + .dpcm_playback = 1, + .init = NULL, + .trigger = { + SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, + .nonatomic = 1, + .dynamic = 1, + }, + [KBL_DPCM_AUDIO_HDMI2_PB] = { + .name = "Kbl HDMI Port2", + .stream_name = "Hdmi2", + .cpu_dai_name = "HDMI2 Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:1f.3", + .dpcm_playback = 1, + .init = NULL, + .trigger = { + SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, + .nonatomic = 1, + .dynamic = 1, + }, + [KBL_DPCM_AUDIO_HDMI3_PB] = { + .name = "Kbl HDMI Port3", + .stream_name = "Hdmi3", + .cpu_dai_name = "HDMI3 Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:1f.3", + .trigger = { + SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, + .dpcm_playback = 1, + .init = NULL, + .nonatomic = 1, + .dynamic = 1, + }, + + /* Back End DAI links */ + { + /* SSP0 - Codec */ + .name = "SSP0-Codec", + .id = 0, + .cpu_dai_name = "SSP0 Pin", + .platform_name = "0000:00:1f.3", + .no_pcm = 1, + .codec_name = MAXIM_DEV0_NAME, + .codec_dai_name = KBL_MAXIM_CODEC_DAI, + .dai_fmt = SND_SOC_DAIFMT_I2S | + SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, + .ignore_pmdown_time = 1, + .be_hw_params_fixup = kabylake_ssp_fixup, + .dpcm_playback = 1, + }, + { + /* SSP1 - Codec */ + .name = "SSP1-Codec", + .id = 1, + .cpu_dai_name = "SSP1 Pin", + .platform_name = "0000:00:1f.3", + .no_pcm = 1, + .codec_name = "i2c-DLGS7219:00", + .codec_dai_name = KBL_DIALOG_CODEC_DAI, + .init = kabylake_da7219_codec_init, + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, + .ignore_pmdown_time = 1, + .be_hw_params_fixup = kabylake_ssp_fixup, + .dpcm_playback = 1, + .dpcm_capture = 1, + }, + { + .name = "dmic01", + .id = 2, + .cpu_dai_name = "DMIC01 Pin", + .codec_name = "dmic-codec", + .codec_dai_name = "dmic-hifi", + .platform_name = "0000:00:1f.3", + .be_hw_params_fixup = kabylake_dmic_fixup, + .ignore_suspend = 1, + .dpcm_capture = 1, + .no_pcm = 1, + }, + { + .name = "iDisp1", + .id = 3, + .cpu_dai_name = "iDisp1 Pin", + .codec_name = "ehdaudio0D2", + .codec_dai_name = "intel-hdmi-hifi1", + .platform_name = "0000:00:1f.3", + .dpcm_playback = 1, + .init = kabylake_hdmi1_init, + .no_pcm = 1, + }, + { + .name = "iDisp2", + .id = 4, + .cpu_dai_name = "iDisp2 Pin", + .codec_name = "ehdaudio0D2", + .codec_dai_name = "intel-hdmi-hifi2", + .platform_name = "0000:00:1f.3", + .init = kabylake_hdmi2_init, + .dpcm_playback = 1, + .no_pcm = 1, + }, + { + .name = "iDisp3", + .id = 5, + .cpu_dai_name = "iDisp3 Pin", + .codec_name = "ehdaudio0D2", + .codec_dai_name = "intel-hdmi-hifi3", + .platform_name = "0000:00:1f.3", + .init = kabylake_hdmi3_init, + .dpcm_playback = 1, + .no_pcm = 1, + }, +}; + +#define NAME_SIZE 32 +static int kabylake_card_late_probe(struct snd_soc_card *card) +{ + struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card); + struct kbl_hdmi_pcm *pcm; + struct snd_soc_codec *codec = NULL; + int err, i = 0; + char jack_name[NAME_SIZE]; + + list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { + codec = pcm->codec_dai->codec; + snprintf(jack_name, sizeof(jack_name), + "HDMI/DP, pcm=%d Jack", pcm->device); + err = snd_soc_card_jack_new(card, jack_name, + SND_JACK_AVOUT, &skylake_hdmi[i], + NULL, 0); + + if (err) + return err; + + err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device, + &skylake_hdmi[i]); + if (err < 0) + return err; + + i++; + + } + + if (!codec) + return -EINVAL; + + return hdac_hdmi_jack_port_init(codec, &card->dapm); +} + +/* kabylake audio machine driver for SPT + DA7219 */ +static struct snd_soc_card kabylake_audio_card_da7219_m98357a = { + .name = "kblda7219max", + .owner = THIS_MODULE, + .dai_link = kabylake_dais, + .num_links = ARRAY_SIZE(kabylake_dais), + .controls = kabylake_controls, + .num_controls = ARRAY_SIZE(kabylake_controls), + .dapm_widgets = kabylake_widgets, + .num_dapm_widgets = ARRAY_SIZE(kabylake_widgets), + .dapm_routes = kabylake_map, + .num_dapm_routes = ARRAY_SIZE(kabylake_map), + .fully_routed = true, + .late_probe = kabylake_card_late_probe, +}; + +static int kabylake_audio_probe(struct platform_device *pdev) +{ + struct kbl_codec_private *ctx; + + ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC); + if (!ctx) + return -ENOMEM; + + INIT_LIST_HEAD(&ctx->hdmi_pcm_list); + + kabylake_audio_card = + (struct snd_soc_card *)pdev->id_entry->driver_data; + + kabylake_audio_card->dev = &pdev->dev; + snd_soc_card_set_drvdata(kabylake_audio_card, ctx); + return devm_snd_soc_register_card(&pdev->dev, kabylake_audio_card); +} + +static const struct platform_device_id kbl_board_ids[] = { + { + .name = "kbl_da7219_max98357a", + .driver_data = + (kernel_ulong_t)&kabylake_audio_card_da7219_m98357a, + }, + { } +}; + +static struct platform_driver kabylake_audio = { + .probe = kabylake_audio_probe, + .driver = { + .name = "kbl_da7219_max98357a", + .pm = &snd_soc_pm_ops, + }, + .id_table = kbl_board_ids, +}; + +module_platform_driver(kabylake_audio) + +/* Module information */ +MODULE_DESCRIPTION("Audio Machine driver-DA7219 & MAX98357A in I2S mode"); +MODULE_AUTHOR("Naveen Manohar "); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:kbl_da7219_max98357a"); From ea954fbc35e655c77c11389124a29aae873e5ca6 Mon Sep 17 00:00:00 2001 From: Naveen Manohar Date: Mon, 5 Feb 2018 09:59:57 +0530 Subject: [PATCH 049/102] ASoC: Intel: Add Kabylake Dialog+Maxim machine driver entry Adds Kabylake kbl_da7219_max98357a_i2s machine driver entry into machine table Signed-off-by: Naveen Manohar Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c index 32ce64c6b2dc..aa9edc84eefb 100644 --- a/sound/soc/intel/skylake/skl.c +++ b/sound/soc/intel/skylake/skl.c @@ -1017,6 +1017,11 @@ static struct snd_soc_acpi_codecs kbl_5663_5514_codecs = { .codecs = {"10EC5663", "10EC5514"} }; +static struct snd_soc_acpi_codecs kbl_7219_98357_codecs = { + .num_codecs = 1, + .codecs = {"MX98357A"} +}; + static struct skl_machine_pdata cnl_pdata = { .use_tplg_pcm = true, }; @@ -1105,6 +1110,14 @@ static struct snd_soc_acpi_mach sst_kbl_devdata[] = { .drv_name = "kbl_rt5663", .fw_filename = "intel/dsp_fw_kbl.bin", }, + { + .id = "DLGS7219", + .drv_name = "kbl_da7219_max98357a", + .fw_filename = "intel/dsp_fw_kbl.bin", + .machine_quirk = snd_soc_acpi_codec_list, + .quirk_data = &kbl_7219_98357_codecs, + .pdata = &skl_dmic_data + }, {} }; From 257aaceb63eb2337e50cd9f9008d11df2cb86207 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 19 Feb 2018 04:15:38 +0000 Subject: [PATCH 050/102] ASoC: intel: kbl_da7219_max98357: replace codec to component Now we can replace Codec to Component. Let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/intel/boards/kbl_da7219_max98357a.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sound/soc/intel/boards/kbl_da7219_max98357a.c b/sound/soc/intel/boards/kbl_da7219_max98357a.c index d689124f6687..e84baafd5f63 100644 --- a/sound/soc/intel/boards/kbl_da7219_max98357a.c +++ b/sound/soc/intel/boards/kbl_da7219_max98357a.c @@ -168,7 +168,7 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, static int kabylake_da7219_codec_init(struct snd_soc_pcm_runtime *rtd) { struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card); - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; struct snd_soc_jack *jack; int ret; @@ -191,7 +191,7 @@ static int kabylake_da7219_codec_init(struct snd_soc_pcm_runtime *rtd) snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOLUMEUP); snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN); snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOICECOMMAND); - da7219_aad_jack_det(codec, &ctx->kabylake_headset); + da7219_aad_jack_det(component, &ctx->kabylake_headset); ret = snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); if (ret) @@ -522,12 +522,12 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) { struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card); struct kbl_hdmi_pcm *pcm; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; int err, i = 0; char jack_name[NAME_SIZE]; list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { - codec = pcm->codec_dai->codec; + component = pcm->codec_dai->component; snprintf(jack_name, sizeof(jack_name), "HDMI/DP, pcm=%d Jack", pcm->device); err = snd_soc_card_jack_new(card, jack_name, @@ -546,10 +546,10 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) } - if (!codec) + if (!component) return -EINVAL; - return hdac_hdmi_jack_port_init(codec, &card->dapm); + return hdac_hdmi_jack_port_init(component, &card->dapm); } /* kabylake audio machine driver for SPT + DA7219 */ From 6f5062773747b3d3eb9f957030ac1be98e983ac2 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 18 Feb 2018 23:01:38 +0100 Subject: [PATCH 051/102] ASoC: Intel: sst: Fix error-code check in sst_pause_stream() The value returned by sst_prepare_and_post_msg() is a negated SST_ERR_* value, so we must check for -SST_ERR_INVALID_STREAM_ID. Note that sst_pause_resume() already has the correct check. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/atom/sst/sst_stream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/intel/atom/sst/sst_stream.c b/sound/soc/intel/atom/sst/sst_stream.c index 7ee6aeb7e0af..b082b0922a7a 100644 --- a/sound/soc/intel/atom/sst/sst_stream.c +++ b/sound/soc/intel/atom/sst/sst_stream.c @@ -253,7 +253,7 @@ int sst_pause_stream(struct intel_sst_drv *sst_drv_ctx, int str_id) if (retval == 0) { str_info->prev = str_info->status; str_info->status = STREAM_PAUSED; - } else if (retval == SST_ERR_INVALID_STREAM_ID) { + } else if (retval == -SST_ERR_INVALID_STREAM_ID) { retval = -EINVAL; mutex_lock(&sst_drv_ctx->sst_lock); sst_clean_stream(str_info); From bd47469c9985b50831a55bdda5a36f4672452764 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 18 Feb 2018 23:01:39 +0100 Subject: [PATCH 052/102] ASoC: Intel: sst: Remove 2 unused members from stream_info struct Remove the unused ops and str_id members from the stream_info struct. While at it also remove some kernel-doc comments for members which have already been removed in the past. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/atom/sst/sst.h | 7 ------- sound/soc/intel/atom/sst/sst_pvt.c | 1 - 2 files changed, 8 deletions(-) diff --git a/sound/soc/intel/atom/sst/sst.h b/sound/soc/intel/atom/sst/sst.h index e02e2b4cc08f..1f3107909044 100644 --- a/sound/soc/intel/atom/sst/sst.h +++ b/sound/soc/intel/atom/sst/sst.h @@ -181,21 +181,15 @@ struct sst_block { * * @status : stream current state * @prev : stream prev state - * @ops : stream operation pb/cp/drm... - * @bufs: stream buffer list * @lock : stream mutex for protecting state * @pcm_substream : PCM substream * @period_elapsed : PCM period elapsed callback * @sfreq : stream sampling freq - * @str_type : stream type * @cumm_bytes : cummulative bytes decoded - * @str_type : stream type - * @src : stream source */ struct stream_info { unsigned int status; unsigned int prev; - unsigned int ops; struct mutex lock; void *pcm_substream; @@ -212,7 +206,6 @@ struct stream_info { unsigned int num_ch; unsigned int pipe_id; - unsigned int str_id; unsigned int task_id; }; diff --git a/sound/soc/intel/atom/sst/sst_pvt.c b/sound/soc/intel/atom/sst/sst_pvt.c index b1e6b8f34a6a..d7d38b0f68db 100644 --- a/sound/soc/intel/atom/sst/sst_pvt.c +++ b/sound/soc/intel/atom/sst/sst_pvt.c @@ -365,7 +365,6 @@ void sst_init_stream(struct stream_info *stream, { stream->status = STREAM_INIT; stream->prev = STREAM_UN_INIT; - stream->ops = ops; } int sst_validate_strid( From 8cf732bbd8d6bc9a28ac48c7bac0ccc9f55cb151 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 18 Feb 2018 23:01:40 +0100 Subject: [PATCH 053/102] ASoC: Intel: sst: Remove unnecessary sst_init_stream() function sst_init_stream() has only one caller and all its function arguments are unused. Inline it on the one call site and remove it. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/atom/sst/sst.h | 2 -- sound/soc/intel/atom/sst/sst_pvt.c | 7 ------- sound/soc/intel/atom/sst/sst_stream.c | 5 ++--- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/sound/soc/intel/atom/sst/sst.h b/sound/soc/intel/atom/sst/sst.h index 1f3107909044..164b0f674c20 100644 --- a/sound/soc/intel/atom/sst/sst.h +++ b/sound/soc/intel/atom/sst/sst.h @@ -494,8 +494,6 @@ int sst_prepare_and_post_msg(struct intel_sst_drv *sst, void sst_process_pending_msg(struct work_struct *work); int sst_assign_pvt_id(struct intel_sst_drv *sst_drv_ctx); -void sst_init_stream(struct stream_info *stream, - int codec, int sst_id, int ops, u8 slot); int sst_validate_strid(struct intel_sst_drv *sst_drv_ctx, int str_id); struct stream_info *get_stream_info(struct intel_sst_drv *sst_drv_ctx, int str_id); diff --git a/sound/soc/intel/atom/sst/sst_pvt.c b/sound/soc/intel/atom/sst/sst_pvt.c index d7d38b0f68db..af93244b4868 100644 --- a/sound/soc/intel/atom/sst/sst_pvt.c +++ b/sound/soc/intel/atom/sst/sst_pvt.c @@ -360,13 +360,6 @@ int sst_assign_pvt_id(struct intel_sst_drv *drv) return local; } -void sst_init_stream(struct stream_info *stream, - int codec, int sst_id, int ops, u8 slot) -{ - stream->status = STREAM_INIT; - stream->prev = STREAM_UN_INIT; -} - int sst_validate_strid( struct intel_sst_drv *sst_drv_ctx, int str_id) { diff --git a/sound/soc/intel/atom/sst/sst_stream.c b/sound/soc/intel/atom/sst/sst_stream.c index b082b0922a7a..7cf5dd1993bc 100644 --- a/sound/soc/intel/atom/sst/sst_stream.c +++ b/sound/soc/intel/atom/sst/sst_stream.c @@ -83,6 +83,8 @@ int sst_alloc_stream_mrfld(struct intel_sst_drv *sst_drv_ctx, void *params) pipe_id = str_params->device_type; task_id = str_params->task; + sst_drv_ctx->streams[str_id].status = STREAM_INIT; + sst_drv_ctx->streams[str_id].prev = STREAM_UN_INIT; sst_drv_ctx->streams[str_id].pipe_id = pipe_id; sst_drv_ctx->streams[str_id].task_id = task_id; sst_drv_ctx->streams[str_id].num_ch = num_ch; @@ -100,9 +102,6 @@ int sst_alloc_stream_mrfld(struct intel_sst_drv *sst_drv_ctx, void *params) pipe_id, task_id); /* allocate device type context */ - sst_init_stream(&sst_drv_ctx->streams[str_id], alloc_param.codec_type, - str_id, alloc_param.operation, 0); - dev_dbg(sst_drv_ctx->dev, "Alloc for str %d pipe %#x\n", str_id, pipe_id); ret = sst_prepare_and_post_msg(sst_drv_ctx, task_id, IPC_CMD, From de9833476de7eb1d4b8bdc599cbbd616fb0e1a28 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 18 Feb 2018 23:01:41 +0100 Subject: [PATCH 054/102] ASoC: Intel: sst: Remove unused STREAM_DECODE and STREAM_RESET states STREAM_DECODE is completely unused, status == STREAM_RESET was checked for, but never set, remove both. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/atom/sst/sst.h | 4 +--- sound/soc/intel/atom/sst/sst_drv_interface.c | 19 ------------------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/sound/soc/intel/atom/sst/sst.h b/sound/soc/intel/atom/sst/sst.h index 164b0f674c20..f4fd442080b2 100644 --- a/sound/soc/intel/atom/sst/sst.h +++ b/sound/soc/intel/atom/sst/sst.h @@ -65,9 +65,7 @@ enum sst_stream_states { STREAM_UN_INIT = 0, /* Freed/Not used stream */ STREAM_RUNNING = 1, /* Running */ STREAM_PAUSED = 2, /* Paused stream */ - STREAM_DECODE = 3, /* stream is in decoding only state */ - STREAM_INIT = 4, /* stream init, waiting for data */ - STREAM_RESET = 5, /* force reset on recovery */ + STREAM_INIT = 3, /* stream init, waiting for data */ }; enum sst_ram_type { diff --git a/sound/soc/intel/atom/sst/sst_drv_interface.c b/sound/soc/intel/atom/sst/sst_drv_interface.c index 71af5449be90..6a8b253c58d2 100644 --- a/sound/soc/intel/atom/sst/sst_drv_interface.c +++ b/sound/soc/intel/atom/sst/sst_drv_interface.c @@ -238,16 +238,7 @@ static int sst_cdev_close(struct device *dev, unsigned int str_id) return -EINVAL; } - if (stream->status == STREAM_RESET) { - dev_dbg(dev, "stream in reset state...\n"); - stream->status = STREAM_UN_INIT; - - retval = 0; - goto put; - } - retval = sst_free_stream(ctx, str_id); -put: stream->compr_cb_param = NULL; stream->compr_cb = NULL; @@ -256,7 +247,6 @@ put: dev_dbg(dev, "End\n"); return retval; - } static int sst_cdev_ack(struct device *dev, unsigned int str_id, @@ -486,16 +476,7 @@ static int sst_close_pcm_stream(struct device *dev, unsigned int str_id) return -EINVAL; } - if (stream->status == STREAM_RESET) { - /* silently fail here as we have cleaned the stream earlier */ - dev_dbg(ctx->dev, "stream in reset state...\n"); - - retval = 0; - goto put; - } - retval = free_stream_context(ctx, str_id); -put: stream->pcm_substream = NULL; stream->status = STREAM_UN_INIT; stream->period_elapsed = NULL; From 473858cad1ea3d4e6c287bad23961cd5fb7382d9 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 18 Feb 2018 23:01:42 +0100 Subject: [PATCH 055/102] ASoC: Intel: sst: Add sst_realloc_stream() function Move the struct snd_sst_alloc_mrfld alloc parameters from the stack into struct stream_info and add a new sst_realloc_stream() function which can re-alloc a stream with the same parameters as before. This is a preparation patch for fixing suspend/resume issues with some SST / DSP firmware versions. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/atom/sst/sst.h | 3 + sound/soc/intel/atom/sst/sst_stream.c | 92 ++++++++++++++++----------- 2 files changed, 58 insertions(+), 37 deletions(-) diff --git a/sound/soc/intel/atom/sst/sst.h b/sound/soc/intel/atom/sst/sst.h index f4fd442080b2..a357cd615b59 100644 --- a/sound/soc/intel/atom/sst/sst.h +++ b/sound/soc/intel/atom/sst/sst.h @@ -180,6 +180,7 @@ struct sst_block { * @status : stream current state * @prev : stream prev state * @lock : stream mutex for protecting state + * @alloc_param : parameters used for stream (re-)allocation * @pcm_substream : PCM substream * @period_elapsed : PCM period elapsed callback * @sfreq : stream sampling freq @@ -189,6 +190,7 @@ struct stream_info { unsigned int status; unsigned int prev; struct mutex lock; + struct snd_sst_alloc_mrfld alloc_param; void *pcm_substream; void (*period_elapsed)(void *pcm_substream); @@ -429,6 +431,7 @@ struct intel_sst_ops { void (*post_download)(struct intel_sst_drv *sst); }; +int sst_realloc_stream(struct intel_sst_drv *sst_drv_ctx, int str_id); int sst_pause_stream(struct intel_sst_drv *sst_drv_ctx, int id); int sst_resume_stream(struct intel_sst_drv *sst_drv_ctx, int id); int sst_drop_stream(struct intel_sst_drv *sst_drv_ctx, int id); diff --git a/sound/soc/intel/atom/sst/sst_stream.c b/sound/soc/intel/atom/sst/sst_stream.c index 7cf5dd1993bc..fcedaa237505 100644 --- a/sound/soc/intel/atom/sst/sst_stream.c +++ b/sound/soc/intel/atom/sst/sst_stream.c @@ -35,29 +35,31 @@ int sst_alloc_stream_mrfld(struct intel_sst_drv *sst_drv_ctx, void *params) { - struct snd_sst_alloc_mrfld alloc_param; + struct snd_pcm_params *pcm_params; struct snd_sst_params *str_params; struct snd_sst_tstamp fw_tstamp; struct stream_info *str_info; - struct snd_sst_alloc_response *response; - unsigned int str_id, pipe_id, task_id; - int i, num_ch, ret = 0; - void *data = NULL; + int i, num_ch, str_id; dev_dbg(sst_drv_ctx->dev, "Enter\n"); str_params = (struct snd_sst_params *)params; - memset(&alloc_param, 0, sizeof(alloc_param)); - alloc_param.operation = str_params->ops; - alloc_param.codec_type = str_params->codec; - alloc_param.sg_count = str_params->aparams.sg_count; - alloc_param.ring_buf_info[0].addr = - str_params->aparams.ring_buf_info[0].addr; - alloc_param.ring_buf_info[0].size = - str_params->aparams.ring_buf_info[0].size; - alloc_param.frag_size = str_params->aparams.frag_size; + str_id = str_params->stream_id; + str_info = get_stream_info(sst_drv_ctx, str_id); + if (!str_info) + return -EINVAL; - memcpy(&alloc_param.codec_params, &str_params->sparams, + memset(&str_info->alloc_param, 0, sizeof(str_info->alloc_param)); + str_info->alloc_param.operation = str_params->ops; + str_info->alloc_param.codec_type = str_params->codec; + str_info->alloc_param.sg_count = str_params->aparams.sg_count; + str_info->alloc_param.ring_buf_info[0].addr = + str_params->aparams.ring_buf_info[0].addr; + str_info->alloc_param.ring_buf_info[0].size = + str_params->aparams.ring_buf_info[0].size; + str_info->alloc_param.frag_size = str_params->aparams.frag_size; + + memcpy(&str_info->alloc_param.codec_params, &str_params->sparams, sizeof(struct snd_sst_stream_params)); /* @@ -67,46 +69,62 @@ int sst_alloc_stream_mrfld(struct intel_sst_drv *sst_drv_ctx, void *params) * Currently hardcoding as per FW reqm. */ num_ch = sst_get_num_channel(str_params); + pcm_params = &str_info->alloc_param.codec_params.uc.pcm_params; for (i = 0; i < 8; i++) { if (i < num_ch) - alloc_param.codec_params.uc.pcm_params.channel_map[i] = i; + pcm_params->channel_map[i] = i; else - alloc_param.codec_params.uc.pcm_params.channel_map[i] = 0xFF; + pcm_params->channel_map[i] = 0xff; } - str_id = str_params->stream_id; - str_info = get_stream_info(sst_drv_ctx, str_id); - if (str_info == NULL) { - dev_err(sst_drv_ctx->dev, "get stream info returned null\n"); - return -EINVAL; - } - - pipe_id = str_params->device_type; - task_id = str_params->task; sst_drv_ctx->streams[str_id].status = STREAM_INIT; sst_drv_ctx->streams[str_id].prev = STREAM_UN_INIT; - sst_drv_ctx->streams[str_id].pipe_id = pipe_id; - sst_drv_ctx->streams[str_id].task_id = task_id; + sst_drv_ctx->streams[str_id].pipe_id = str_params->device_type; + sst_drv_ctx->streams[str_id].task_id = str_params->task; sst_drv_ctx->streams[str_id].num_ch = num_ch; if (sst_drv_ctx->info.lpe_viewpt_rqd) - alloc_param.ts = sst_drv_ctx->info.mailbox_start + + str_info->alloc_param.ts = sst_drv_ctx->info.mailbox_start + sst_drv_ctx->tstamp + (str_id * sizeof(fw_tstamp)); else - alloc_param.ts = sst_drv_ctx->mailbox_add + + str_info->alloc_param.ts = sst_drv_ctx->mailbox_add + sst_drv_ctx->tstamp + (str_id * sizeof(fw_tstamp)); dev_dbg(sst_drv_ctx->dev, "alloc tstamp location = 0x%x\n", - alloc_param.ts); + str_info->alloc_param.ts); dev_dbg(sst_drv_ctx->dev, "assigned pipe id 0x%x to task %d\n", - pipe_id, task_id); + str_info->pipe_id, str_info->task_id); + + return sst_realloc_stream(sst_drv_ctx, str_id); +} + +/** + * sst_realloc_stream - Send msg for (re-)allocating a stream using the + * @sst_drv_ctx intel_sst_drv context pointer + * @str_id: stream ID + * + * Send a msg for (re-)allocating a stream using the parameters previously + * passed to sst_alloc_stream_mrfld() for the same stream ID. + * Return: 0 or negative errno value. + */ +int sst_realloc_stream(struct intel_sst_drv *sst_drv_ctx, int str_id) +{ + struct snd_sst_alloc_response *response; + struct stream_info *str_info; + void *data = NULL; + int ret; + + str_info = get_stream_info(sst_drv_ctx, str_id); + if (!str_info) + return -EINVAL; - /* allocate device type context */ dev_dbg(sst_drv_ctx->dev, "Alloc for str %d pipe %#x\n", - str_id, pipe_id); - ret = sst_prepare_and_post_msg(sst_drv_ctx, task_id, IPC_CMD, - IPC_IA_ALLOC_STREAM_MRFLD, pipe_id, sizeof(alloc_param), - &alloc_param, &data, true, true, false, true); + str_id, str_info->pipe_id); + + ret = sst_prepare_and_post_msg(sst_drv_ctx, str_info->task_id, IPC_CMD, + IPC_IA_ALLOC_STREAM_MRFLD, str_info->pipe_id, + sizeof(str_info->alloc_param), &str_info->alloc_param, + &data, true, true, false, true); if (ret < 0) { dev_err(sst_drv_ctx->dev, "FW alloc failed ret %d\n", ret); From bf642bf57398572327072d306e26e38aebd94fa7 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 18 Feb 2018 23:01:43 +0100 Subject: [PATCH 056/102] ASoC: Intel: sst: Free streams on suspend, re-alloc on resume The Bay Trail SST-DSP firmware version looses track of all streams over a suspend/resume, failing any attempts to resume and/or free streams, with a SST_ERR_INVALID_STREAM_ID error. This commit adds support for free-ing the streams on suspend and re-allocating them on resume, fixing suspend/resume issues on devices using this firmware version. This new behavior gets triggered by a new flag in sst_platform_info which only gets set on Bay Trail platforms. This has been tested on the following devices: -Asus T100TA, Bay Trail + ALC5642 codec -Ployer MOMO7W, Bay Trail CR + ALC5652 codec Tested-by: Hans de Goede Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- arch/x86/include/asm/platform_sst_audio.h | 1 + sound/soc/intel/atom/sst/sst.c | 24 ++++++++++++++++++++++- sound/soc/intel/atom/sst/sst.h | 4 ++++ sound/soc/intel/atom/sst/sst_acpi.c | 3 ++- sound/soc/intel/atom/sst/sst_stream.c | 24 ++++++++++++++++++++++- 5 files changed, 53 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/platform_sst_audio.h b/arch/x86/include/asm/platform_sst_audio.h index 5973a2f3db3d..059823bb8af7 100644 --- a/arch/x86/include/asm/platform_sst_audio.h +++ b/arch/x86/include/asm/platform_sst_audio.h @@ -135,6 +135,7 @@ struct sst_platform_info { const struct sst_res_info *res_info; const struct sst_lib_dnld_info *lib_info; const char *platform; + bool streams_lost_on_suspend; }; int add_sst_platform_device(void); #endif diff --git a/sound/soc/intel/atom/sst/sst.c b/sound/soc/intel/atom/sst/sst.c index 8afdff457579..0962bc9adc62 100644 --- a/sound/soc/intel/atom/sst/sst.c +++ b/sound/soc/intel/atom/sst/sst.c @@ -449,6 +449,13 @@ static int intel_sst_suspend(struct device *dev) dev_err(dev, "stream %d is running, can't suspend, abort\n", i); return -EBUSY; } + + if (ctx->pdata->streams_lost_on_suspend) { + stream->resume_status = stream->status; + stream->resume_prev = stream->prev; + if (stream->status != STREAM_UN_INIT) + sst_free_stream(ctx, i); + } } synchronize_irq(ctx->irq_num); flush_workqueue(ctx->post_msg_wq); @@ -509,8 +516,8 @@ static int intel_sst_resume(struct device *dev) { struct intel_sst_drv *ctx = dev_get_drvdata(dev); struct sst_fw_save *fw_save = ctx->fw_save; - int ret = 0; struct sst_block *block; + int i, ret = 0; if (!fw_save) return 0; @@ -550,6 +557,21 @@ static int intel_sst_resume(struct device *dev) sst_set_fw_state_locked(ctx, SST_FW_RUNNING); } + if (ctx->pdata->streams_lost_on_suspend) { + for (i = 1; i <= ctx->info.max_streams; i++) { + struct stream_info *stream = &ctx->streams[i]; + + if (stream->resume_status != STREAM_UN_INIT) { + dev_dbg(ctx->dev, "Re-allocing stream %d status %d prev %d\n", + i, stream->resume_status, + stream->resume_prev); + sst_realloc_stream(ctx, i); + stream->status = stream->resume_status; + stream->prev = stream->resume_prev; + } + } + } + sst_free_block(ctx, block); return ret; } diff --git a/sound/soc/intel/atom/sst/sst.h b/sound/soc/intel/atom/sst/sst.h index a357cd615b59..b2a705dc9304 100644 --- a/sound/soc/intel/atom/sst/sst.h +++ b/sound/soc/intel/atom/sst/sst.h @@ -179,6 +179,8 @@ struct sst_block { * * @status : stream current state * @prev : stream prev state + * @resume_status : stream current state to restore on resume + * @resume_prev : stream prev state to restore on resume * @lock : stream mutex for protecting state * @alloc_param : parameters used for stream (re-)allocation * @pcm_substream : PCM substream @@ -189,6 +191,8 @@ struct sst_block { struct stream_info { unsigned int status; unsigned int prev; + unsigned int resume_status; + unsigned int resume_prev; struct mutex lock; struct snd_sst_alloc_mrfld alloc_param; diff --git a/sound/soc/intel/atom/sst/sst_acpi.c b/sound/soc/intel/atom/sst/sst_acpi.c index 6cd481bec275..c90b04cc071d 100644 --- a/sound/soc/intel/atom/sst/sst_acpi.c +++ b/sound/soc/intel/atom/sst/sst_acpi.c @@ -143,10 +143,11 @@ static struct sst_platform_info byt_rvp_platform_data = { .lib_info = &byt_lib_dnld_info, .res_info = &byt_rvp_res_info, .platform = "sst-mfld-platform", + .streams_lost_on_suspend = true, }; /* Cherryview (Cherrytrail and Braswell) uses same mrfld dpcm fw as Baytrail, - * so pdata is same as Baytrail. + * so pdata is same as Baytrail, minus the streams_lost_on_suspend quirk. */ static struct sst_platform_info chv_platform_data = { .probe_data = &byt_fwparse_info, diff --git a/sound/soc/intel/atom/sst/sst_stream.c b/sound/soc/intel/atom/sst/sst_stream.c index fcedaa237505..107271f7dd63 100644 --- a/sound/soc/intel/atom/sst/sst_stream.c +++ b/sound/soc/intel/atom/sst/sst_stream.c @@ -302,7 +302,29 @@ int sst_resume_stream(struct intel_sst_drv *sst_drv_ctx, int str_id) return -EINVAL; if (str_info->status == STREAM_RUNNING) return 0; - if (str_info->status == STREAM_PAUSED) { + + if (str_info->resume_status == STREAM_PAUSED && + str_info->resume_prev == STREAM_RUNNING) { + /* + * Stream was running before suspend and re-created on resume, + * start it to get back to running state. + */ + dev_dbg(sst_drv_ctx->dev, "restart recreated stream after resume\n"); + str_info->status = STREAM_RUNNING; + str_info->prev = STREAM_PAUSED; + retval = sst_start_stream(sst_drv_ctx, str_id); + str_info->resume_status = STREAM_UN_INIT; + } else if (str_info->resume_status == STREAM_PAUSED && + str_info->resume_prev == STREAM_INIT) { + /* + * Stream was idle before suspend and re-created on resume, + * keep it as is. + */ + dev_dbg(sst_drv_ctx->dev, "leaving recreated stream idle after resume\n"); + str_info->status = STREAM_INIT; + str_info->prev = STREAM_PAUSED; + str_info->resume_status = STREAM_UN_INIT; + } else if (str_info->status == STREAM_PAUSED) { retval = sst_prepare_and_post_msg(sst_drv_ctx, str_info->task_id, IPC_CMD, IPC_IA_RESUME_STREAM_MRFLD, str_info->pipe_id, 0, NULL, NULL, From 256ac58a7ea343600bd6d0e3df3eb7eebb2d65e0 Mon Sep 17 00:00:00 2001 From: Naveen Manohar Date: Mon, 19 Feb 2018 08:15:02 +0530 Subject: [PATCH 057/102] ASoC: Intel: kbl: Enable mclk and ssp sclk early for rt5663 rt5663 requires mclk/sclk early to synchronize its internal clocks. Enable these clocks early. Signed-off-by: Naveen Manohar Signed-off-by: Kevin Cheng Signed-off-by: Mark Brown --- sound/soc/intel/boards/kbl_rt5663_max98927.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sound/soc/intel/boards/kbl_rt5663_max98927.c b/sound/soc/intel/boards/kbl_rt5663_max98927.c index 3c9585eb6860..0e6b7e79441c 100644 --- a/sound/soc/intel/boards/kbl_rt5663_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_max98927.c @@ -204,13 +204,18 @@ static const struct snd_soc_dapm_widget kabylake_5663_widgets[] = { SND_SOC_DAPM_MIC("Headset Mic", NULL), SND_SOC_DAPM_SPK("DP", NULL), SND_SOC_DAPM_SPK("HDMI", NULL), + SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, + platform_clock_control, SND_SOC_DAPM_PRE_PMU | + SND_SOC_DAPM_POST_PMD), }; static const struct snd_soc_dapm_route kabylake_5663_map[] = { + { "Headphone Jack", NULL, "Platform Clock" }, { "Headphone Jack", NULL, "HPOL" }, { "Headphone Jack", NULL, "HPOR" }, /* other jacks */ + { "Headset Mic", NULL, "Platform Clock" }, { "IN1P", NULL, "Headset Mic" }, { "IN1N", NULL, "Headset Mic" }, From 5b00ce63e07fac692400db80d3e1fbd1f1f65701 Mon Sep 17 00:00:00 2001 From: John Hsu Date: Tue, 6 Feb 2018 15:02:43 +0800 Subject: [PATCH 058/102] ASoC: Intel: add nau8824 sound card Create sound card with NAU88L24 codec in Intel Cherryview-based platforms, Cherrytrail and Braswell. Signed-off-by: John Hsu Signed-off-by: Mark Brown --- sound/soc/intel/boards/Kconfig | 11 + sound/soc/intel/boards/Makefile | 2 + sound/soc/intel/boards/cht_bsw_nau8824.c | 282 ++++++++++++++++++ .../intel/common/soc-acpi-intel-cht-match.c | 9 + 4 files changed, 304 insertions(+) create mode 100644 sound/soc/intel/boards/cht_bsw_nau8824.c diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig index eedc83b96fbb..24797482a3d2 100644 --- a/sound/soc/intel/boards/Kconfig +++ b/sound/soc/intel/boards/Kconfig @@ -125,6 +125,17 @@ config SND_SOC_INTEL_CHT_BSW_MAX98090_TI_MACH Say Y or m if you have such a device. This is a recommended option. If unsure select "N". +config SND_SOC_INTEL_CHT_BSW_NAU8824_MACH + tristate "Cherrytrail & Braswell with NAU88L24 codec" + depends on X86_INTEL_LPSS && I2C && ACPI + select SND_SOC_ACPI + select SND_SOC_NAU8824 + help + This adds support for ASoC machine driver for Intel(R) Cherrytrail & Braswell + platforms with NAU88L24 audio codec. + Say Y or m if you have such a device. This is a recommended option. + If unsure select "N". + config SND_SOC_INTEL_BYT_CHT_DA7213_MACH tristate "Baytrail & Cherrytrail with DA7212/7213 codec" depends on X86_INTEL_LPSS && I2C && ACPI diff --git a/sound/soc/intel/boards/Makefile b/sound/soc/intel/boards/Makefile index 6fae506c40fa..92b5507291af 100644 --- a/sound/soc/intel/boards/Makefile +++ b/sound/soc/intel/boards/Makefile @@ -11,6 +11,7 @@ snd-soc-sst-bytcr-rt5651-objs := bytcr_rt5651.o snd-soc-sst-cht-bsw-rt5672-objs := cht_bsw_rt5672.o snd-soc-sst-cht-bsw-rt5645-objs := cht_bsw_rt5645.o snd-soc-sst-cht-bsw-max98090_ti-objs := cht_bsw_max98090_ti.o +snd-soc-sst-cht-bsw-nau8824-objs := cht_bsw_nau8824.o snd-soc-sst-byt-cht-da7213-objs := bytcht_da7213.o snd-soc-sst-byt-cht-es8316-objs := bytcht_es8316.o snd-soc-sst-byt-cht-nocodec-objs := bytcht_nocodec.o @@ -33,6 +34,7 @@ obj-$(CONFIG_SND_SOC_INTEL_BYTCR_RT5651_MACH) += snd-soc-sst-bytcr-rt5651.o obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_RT5672_MACH) += snd-soc-sst-cht-bsw-rt5672.o obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_RT5645_MACH) += snd-soc-sst-cht-bsw-rt5645.o obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_MAX98090_TI_MACH) += snd-soc-sst-cht-bsw-max98090_ti.o +obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_NAU8824_MACH) += snd-soc-sst-cht-bsw-nau8824.o obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_DA7213_MACH) += snd-soc-sst-byt-cht-da7213.o obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_ES8316_MACH) += snd-soc-sst-byt-cht-es8316.o obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH) += snd-soc-sst-byt-cht-nocodec.o diff --git a/sound/soc/intel/boards/cht_bsw_nau8824.c b/sound/soc/intel/boards/cht_bsw_nau8824.c new file mode 100644 index 000000000000..08d0b8128fab --- /dev/null +++ b/sound/soc/intel/boards/cht_bsw_nau8824.c @@ -0,0 +1,282 @@ +/* + * cht-bsw-nau8824.c - ASoc Machine driver for Intel Cherryview-based + * platforms Cherrytrail and Braswell, with nau8824 codec. + * + * Copyright (C) 2018 Intel Corp + * Copyright (C) 2018 Nuvoton Technology Corp + * + * Author: Wang, Joseph C + * Co-author: John Hsu + * This file is based on cht_bsw_rt5672.c and cht-bsw-max98090.c + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "../atom/sst-atom-controls.h" +#include "../../codecs/nau8824.h" + +struct cht_mc_private { + struct snd_soc_jack jack; +}; + +static struct snd_soc_jack_pin cht_bsw_jack_pins[] = { + { + .pin = "Headphone", + .mask = SND_JACK_HEADPHONE, + }, + { + .pin = "Headset Mic", + .mask = SND_JACK_MICROPHONE, + }, +}; + +static const struct snd_soc_dapm_widget cht_dapm_widgets[] = { + SND_SOC_DAPM_HP("Headphone", NULL), + SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_MIC("Int Mic", NULL), + SND_SOC_DAPM_SPK("Ext Spk", NULL), +}; + +static const struct snd_soc_dapm_route cht_audio_map[] = { + {"Ext Spk", NULL, "SPKOUTL"}, + {"Ext Spk", NULL, "SPKOUTR"}, + {"Headphone", NULL, "HPOL"}, + {"Headphone", NULL, "HPOR"}, + {"MIC1", NULL, "Int Mic"}, + {"MIC2", NULL, "Int Mic"}, + {"HSMIC1", NULL, "Headset Mic"}, + {"HSMIC2", NULL, "Headset Mic"}, + {"Playback", NULL, "ssp2 Tx"}, + {"ssp2 Tx", NULL, "codec_out0"}, + {"ssp2 Tx", NULL, "codec_out1"}, + {"codec_in0", NULL, "ssp2 Rx" }, + {"codec_in1", NULL, "ssp2 Rx" }, + {"ssp2 Rx", NULL, "Capture"}, +}; + +static const struct snd_kcontrol_new cht_mc_controls[] = { + SOC_DAPM_PIN_SWITCH("Headphone"), + SOC_DAPM_PIN_SWITCH("Headset Mic"), + SOC_DAPM_PIN_SWITCH("Int Mic"), + SOC_DAPM_PIN_SWITCH("Ext Spk"), +}; + +static int cht_aif1_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + int ret; + + ret = snd_soc_dai_set_sysclk(codec_dai, NAU8824_CLK_FLL_FS, 0, + SND_SOC_CLOCK_IN); + if (ret < 0) { + dev_err(codec_dai->dev, "can't set FS clock %d\n", ret); + return ret; + } + ret = snd_soc_dai_set_pll(codec_dai, 0, 0, params_rate(params), + params_rate(params) * 256); + if (ret < 0) { + dev_err(codec_dai->dev, "can't set FLL: %d\n", ret); + return ret; + } + + return 0; +} + +static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) +{ + struct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card); + struct snd_soc_jack *jack = &ctx->jack; + struct snd_soc_codec *codec = runtime->codec; + struct snd_soc_dai *codec_dai = runtime->codec_dai; + int ret, jack_type; + + /* TDM 4 slots 24 bit, set Rx & Tx bitmask to 4 active slots */ + ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xf, 0x1, 4, 24); + if (ret < 0) { + dev_err(runtime->dev, "can't set codec TDM slot %d\n", ret); + return ret; + } + + /* NAU88L24 supports 4 butons headset detection + * KEY_MEDIA + * KEY_VOICECOMMAND + * KEY_VOLUMEUP + * KEY_VOLUMEDOWN + */ + jack_type = SND_JACK_HEADPHONE | SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3; + ret = snd_soc_card_jack_new(runtime->card, "Headset", jack_type, jack, + cht_bsw_jack_pins, ARRAY_SIZE(cht_bsw_jack_pins)); + if (ret) { + dev_err(runtime->dev, + "Headset Jack creation failed %d\n", ret); + return ret; + } + snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_MEDIA); + snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND); + snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP); + snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); + + nau8824_enable_jack_detect(codec, jack); + + return ret; +} + +static int cht_codec_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params) +{ + struct snd_interval *rate = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_RATE); + struct snd_interval *channels = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_CHANNELS); + struct snd_mask *fmt = + hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); + + /* The DSP will covert the FE rate to 48k, stereo, 24bits */ + rate->min = rate->max = 48000; + channels->min = channels->max = 2; + + /* set SSP2 to 24-bit */ + snd_mask_none(fmt); + params_set_format(params, SNDRV_PCM_FORMAT_S24_LE); + + return 0; +} + +static int cht_aif1_startup(struct snd_pcm_substream *substream) +{ + return snd_pcm_hw_constraint_single(substream->runtime, + SNDRV_PCM_HW_PARAM_RATE, 48000); +} + +static const struct snd_soc_ops cht_aif1_ops = { + .startup = cht_aif1_startup, +}; + +static const struct snd_soc_ops cht_be_ssp2_ops = { + .hw_params = cht_aif1_hw_params, +}; + +static struct snd_soc_dai_link cht_dailink[] = { + /* Front End DAI links */ + [MERR_DPCM_AUDIO] = { + .name = "Audio Port", + .stream_name = "Audio", + .cpu_dai_name = "media-cpu-dai", + .codec_dai_name = "snd-soc-dummy-dai", + .codec_name = "snd-soc-dummy", + .platform_name = "sst-mfld-platform", + .nonatomic = true, + .dynamic = 1, + .dpcm_playback = 1, + .dpcm_capture = 1, + .ops = &cht_aif1_ops, + }, + [MERR_DPCM_DEEP_BUFFER] = { + .name = "Deep-Buffer Audio Port", + .stream_name = "Deep-Buffer Audio", + .cpu_dai_name = "deepbuffer-cpu-dai", + .codec_dai_name = "snd-soc-dummy-dai", + .codec_name = "snd-soc-dummy", + .platform_name = "sst-mfld-platform", + .nonatomic = true, + .dynamic = 1, + .dpcm_playback = 1, + .ops = &cht_aif1_ops, + }, + [MERR_DPCM_COMPR] = { + .name = "Compressed Port", + .stream_name = "Compress", + .cpu_dai_name = "compress-cpu-dai", + .codec_dai_name = "snd-soc-dummy-dai", + .codec_name = "snd-soc-dummy", + .platform_name = "sst-mfld-platform", + }, + /* Back End DAI links */ + { + /* SSP2 - Codec */ + .name = "SSP2-Codec", + .id = 1, + .cpu_dai_name = "ssp2-port", + .platform_name = "sst-mfld-platform", + .no_pcm = 1, + .codec_dai_name = NAU8824_CODEC_DAI, + .codec_name = "i2c-10508824:00", + .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_IB_NF + | SND_SOC_DAIFMT_CBS_CFS, + .init = cht_codec_init, + .be_hw_params_fixup = cht_codec_fixup, + .dpcm_playback = 1, + .dpcm_capture = 1, + .ops = &cht_be_ssp2_ops, + }, +}; + +/* SoC card */ +static struct snd_soc_card snd_soc_card_cht = { + .name = "chtnau8824", + .owner = THIS_MODULE, + .dai_link = cht_dailink, + .num_links = ARRAY_SIZE(cht_dailink), + .dapm_widgets = cht_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(cht_dapm_widgets), + .dapm_routes = cht_audio_map, + .num_dapm_routes = ARRAY_SIZE(cht_audio_map), + .controls = cht_mc_controls, + .num_controls = ARRAY_SIZE(cht_mc_controls), +}; + +static int snd_cht_mc_probe(struct platform_device *pdev) +{ + struct cht_mc_private *drv; + int ret_val; + + drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_ATOMIC); + if (!drv) + return -ENOMEM; + snd_soc_card_set_drvdata(&snd_soc_card_cht, drv); + + /* register the soc card */ + snd_soc_card_cht.dev = &pdev->dev; + ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht); + if (ret_val) { + dev_err(&pdev->dev, + "snd_soc_register_card failed %d\n", ret_val); + return ret_val; + } + platform_set_drvdata(pdev, &snd_soc_card_cht); + + return ret_val; +} + +static struct platform_driver snd_cht_mc_driver = { + .driver = { + .name = "cht-bsw-nau8824", + }, + .probe = snd_cht_mc_probe, +}; + +module_platform_driver(snd_cht_mc_driver); + +MODULE_DESCRIPTION("ASoC Intel(R) Baytrail CR Machine driver"); +MODULE_AUTHOR("Wang, Joseph C "); +MODULE_AUTHOR("John Hsu "); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:cht-bsw-nau8824"); diff --git a/sound/soc/intel/common/soc-acpi-intel-cht-match.c b/sound/soc/intel/common/soc-acpi-intel-cht-match.c index b50a0d53846b..ad1eb2d644be 100644 --- a/sound/soc/intel/common/soc-acpi-intel-cht-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-cht-match.c @@ -117,6 +117,15 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_cherrytrail_machines[] = { .sof_tplg_filename = "intel/reef-cht-max98090.tplg", .asoc_plat_name = "sst-mfld-platform", }, + { + .id = "10508824", + .drv_name = "cht-bsw-nau8824", + .fw_filename = "intel/fw_sst_22a8.bin", + .board = "cht-bsw", + .sof_fw_filename = "intel/reef-cht.ri", + .sof_tplg_filename = "intel/reef-cht-nau8824.tplg", + .asoc_plat_name = "sst-mfld-platform", + }, { .id = "DLGS7212", .drv_name = "bytcht_da7213", From 54e3a3a152a6f466f3a94b28be10f08b86905bc0 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:42 +0100 Subject: [PATCH 059/102] ASoC: rt5651: Remove unused rt5651_platform_data There are no in tree users of platform-data for the rt5651 codec driver, so lets remove support for it. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- include/sound/rt5651.h | 8 ------- sound/soc/codecs/rt5651.c | 47 ++++++++------------------------------- sound/soc/codecs/rt5651.h | 2 +- 3 files changed, 10 insertions(+), 47 deletions(-) diff --git a/include/sound/rt5651.h b/include/sound/rt5651.h index 18b79a761f10..1612462bf5ad 100644 --- a/include/sound/rt5651.h +++ b/include/sound/rt5651.h @@ -18,12 +18,4 @@ enum rt5651_jd_src { RT5651_JD2, }; -struct rt5651_platform_data { - /* IN2 can optionally be differential */ - bool in2_diff; - - bool dmic_en; - enum rt5651_jd_src jd_src; -}; - #endif diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 3a844725684b..eecd6e662210 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -33,8 +33,6 @@ #include "rt5651.h" #define RT5651_JD_MAP(quirk) ((quirk) & GENMASK(7, 0)) -#define RT5651_IN2_DIFF BIT(16) -#define RT5651_DMIC_EN BIT(17) #define RT5651_DEVICE_ID_VALUE 0x6281 @@ -1569,7 +1567,7 @@ static int rt5651_set_bias_level(struct snd_soc_component *component, snd_soc_component_write(component, RT5651_PWR_DIG2, 0x0000); snd_soc_component_write(component, RT5651_PWR_VOL, 0x0000); snd_soc_component_write(component, RT5651_PWR_MIXER, 0x0000); - if (rt5651->pdata.jd_src) { + if (rt5651->jd_src) { snd_soc_component_write(component, RT5651_PWR_ANLG2, 0x0204); snd_soc_component_write(component, RT5651_PWR_ANLG1, 0x0002); } else { @@ -1604,7 +1602,7 @@ static int rt5651_probe(struct snd_soc_component *component) snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); - if (rt5651->pdata.jd_src) { + if (rt5651->jd_src) { snd_soc_dapm_force_enable_pin(dapm, "JD Power"); snd_soc_dapm_force_enable_pin(dapm, "LDO"); snd_soc_dapm_sync(dapm); @@ -1764,26 +1762,6 @@ static const struct dmi_system_id rt5651_quirk_table[] = { {} }; -static int rt5651_parse_dt(struct rt5651_priv *rt5651, struct device_node *np) -{ - if (of_property_read_bool(np, "realtek,in2-differential")) - rt5651_quirk |= RT5651_IN2_DIFF; - if (of_property_read_bool(np, "realtek,dmic-en")) - rt5651_quirk |= RT5651_DMIC_EN; - - return 0; -} - -static void rt5651_set_pdata(struct rt5651_priv *rt5651) -{ - if (rt5651_quirk & RT5651_IN2_DIFF) - rt5651->pdata.in2_diff = true; - if (rt5651_quirk & RT5651_DMIC_EN) - rt5651->pdata.dmic_en = true; - if (RT5651_JD_MAP(rt5651_quirk)) - rt5651->pdata.jd_src = RT5651_JD_MAP(rt5651_quirk); -} - static irqreturn_t rt5651_irq(int irq, void *data) { struct rt5651_priv *rt5651 = data; @@ -1840,7 +1818,7 @@ static void rt5651_jack_detect_work(struct work_struct *work) if (!rt5651->component) return; - switch (rt5651->pdata.jd_src) { + switch (rt5651->jd_src) { case RT5651_JD1_1: val = snd_soc_component_read32(rt5651->component, RT5651_INT_IRQ_ST) & 0x1000; break; @@ -1874,7 +1852,6 @@ EXPORT_SYMBOL_GPL(rt5651_set_jack_detect); static int rt5651_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { - struct rt5651_platform_data *pdata = dev_get_platdata(&i2c->dev); struct rt5651_priv *rt5651; int ret; @@ -1885,14 +1862,8 @@ static int rt5651_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, rt5651); - if (pdata) - rt5651->pdata = *pdata; - else if (i2c->dev.of_node) - rt5651_parse_dt(rt5651, i2c->dev.of_node); - else - dmi_check_system(rt5651_quirk_table); - - rt5651_set_pdata(rt5651); + dmi_check_system(rt5651_quirk_table); + rt5651->jd_src = RT5651_JD_MAP(rt5651_quirk); rt5651->regmap = devm_regmap_init_i2c(i2c, &rt5651_regmap); if (IS_ERR(rt5651->regmap)) { @@ -1916,23 +1887,23 @@ static int rt5651_i2c_probe(struct i2c_client *i2c, if (ret != 0) dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret); - if (rt5651->pdata.in2_diff) + if (device_property_read_bool(&i2c->dev, "realtek,in2-differential")) regmap_update_bits(rt5651->regmap, RT5651_IN1_IN2, RT5651_IN_DF2, RT5651_IN_DF2); - if (rt5651->pdata.dmic_en) + if (device_property_read_bool(&i2c->dev, "realtek,dmic-en")) regmap_update_bits(rt5651->regmap, RT5651_GPIO_CTRL1, RT5651_GP2_PIN_MASK, RT5651_GP2_PIN_DMIC1_SCL); rt5651->hp_mute = 1; - if (rt5651->pdata.jd_src) { + if (rt5651->jd_src) { /* IRQ output on GPIO1 */ regmap_update_bits(rt5651->regmap, RT5651_GPIO_CTRL1, RT5651_GP1_PIN_MASK, RT5651_GP1_PIN_IRQ); - switch (rt5651->pdata.jd_src) { + switch (rt5651->jd_src) { case RT5651_JD1_1: regmap_update_bits(rt5651->regmap, RT5651_JD_CTRL2, RT5651_JD_TRG_SEL_MASK, diff --git a/sound/soc/codecs/rt5651.h b/sound/soc/codecs/rt5651.h index 1ef38429e6a0..148e139e6a26 100644 --- a/sound/soc/codecs/rt5651.h +++ b/sound/soc/codecs/rt5651.h @@ -2060,10 +2060,10 @@ struct rt5651_pll_code { struct rt5651_priv { struct snd_soc_component *component; - struct rt5651_platform_data pdata; struct regmap *regmap; struct snd_soc_jack *hp_jack; struct delayed_work jack_detect_work; + enum rt5651_jd_src jd_src; int sysclk; int sysclk_src; From f06da4fdb5fc2b78d52f62c32aec65b7819178b0 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:43 +0100 Subject: [PATCH 060/102] ASoC: rt5651: Move all jack-detect initialization to rt5651_set_jack_detect Move all jack-detect initialization to rt5651_set_jack_detect. The main reason to do this is so that platform code can setup jack-detect properties after the device has been probed, which unfortunately is necessary on some platforms. This has 2 additional advantages: 1) Grouping all jack-detect init together makes it easier to follow what is happening and results in a small reduction in the number of loc. 2) Before we would register the irq handler before rt5651->hp_jack was assigned, leading to a potential NULL deref if the jack_detect work runs before the machine driver has called set_jack. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 119 ++++++++++++++++++-------------------- sound/soc/codecs/rt5651.h | 1 + 2 files changed, 58 insertions(+), 62 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index eecd6e662210..390cab134ba0 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1586,7 +1586,6 @@ static int rt5651_set_bias_level(struct snd_soc_component *component, static int rt5651_probe(struct snd_soc_component *component) { struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); rt5651->component = component; @@ -1602,15 +1601,6 @@ static int rt5651_probe(struct snd_soc_component *component) snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); - if (rt5651->jd_src) { - snd_soc_dapm_force_enable_pin(dapm, "JD Power"); - snd_soc_dapm_force_enable_pin(dapm, "LDO"); - snd_soc_dapm_sync(dapm); - - regmap_update_bits(rt5651->regmap, RT5651_MICBIAS, - 0x38, 0x38); - } - return 0; } @@ -1840,10 +1830,65 @@ static void rt5651_jack_detect_work(struct work_struct *work) int rt5651_set_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *hp_jack) { + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); + int ret; + + if (!rt5651->irq) + return -EINVAL; + + /* IRQ output on GPIO1 */ + snd_soc_component_update_bits(component, RT5651_GPIO_CTRL1, + RT5651_GP1_PIN_MASK, RT5651_GP1_PIN_IRQ); + + /* Select jack detect source */ + switch (rt5651->jd_src) { + case RT5651_JD1_1: + snd_soc_component_update_bits(component, RT5651_JD_CTRL2, + RT5651_JD_TRG_SEL_MASK, RT5651_JD_TRG_SEL_JD1_1); + snd_soc_component_update_bits(component, RT5651_IRQ_CTRL1, + RT5651_JD1_1_IRQ_EN, RT5651_JD1_1_IRQ_EN); + break; + case RT5651_JD1_2: + snd_soc_component_update_bits(component, RT5651_JD_CTRL2, + RT5651_JD_TRG_SEL_MASK, RT5651_JD_TRG_SEL_JD1_2); + snd_soc_component_update_bits(component, RT5651_IRQ_CTRL1, + RT5651_JD1_2_IRQ_EN, RT5651_JD1_2_IRQ_EN); + break; + case RT5651_JD2: + snd_soc_component_update_bits(component, RT5651_JD_CTRL2, + RT5651_JD_TRG_SEL_MASK, RT5651_JD_TRG_SEL_JD2); + snd_soc_component_update_bits(component, RT5651_IRQ_CTRL1, + RT5651_JD2_IRQ_EN, RT5651_JD2_IRQ_EN); + break; + case RT5651_JD_NULL: + return 0; + default: + dev_err(component->dev, "Currently only JD1_1 / JD1_2 / JD2 are supported\n"); + return -EINVAL; + } + + snd_soc_dapm_force_enable_pin(dapm, "JD Power"); + snd_soc_dapm_force_enable_pin(dapm, "LDO"); + snd_soc_dapm_sync(dapm); + + snd_soc_component_update_bits(component, RT5651_MICBIAS, 0x38, 0x38); rt5651->hp_jack = hp_jack; - rt5651_irq(0, rt5651); + + ret = devm_request_threaded_irq(component->dev, rt5651->irq, NULL, + rt5651_irq, + IRQF_TRIGGER_RISING | + IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, "rt5651", rt5651); + if (ret) { + dev_err(component->dev, "Failed to reguest IRQ: %d\n", ret); + return ret; + } + + /* sync initial jack state */ + queue_delayed_work(system_power_efficient_wq, + &rt5651->jack_detect_work, 0); return 0; } @@ -1895,61 +1940,11 @@ static int rt5651_i2c_probe(struct i2c_client *i2c, regmap_update_bits(rt5651->regmap, RT5651_GPIO_CTRL1, RT5651_GP2_PIN_MASK, RT5651_GP2_PIN_DMIC1_SCL); + rt5651->irq = i2c->irq; rt5651->hp_mute = 1; - if (rt5651->jd_src) { - - /* IRQ output on GPIO1 */ - regmap_update_bits(rt5651->regmap, RT5651_GPIO_CTRL1, - RT5651_GP1_PIN_MASK, RT5651_GP1_PIN_IRQ); - - switch (rt5651->jd_src) { - case RT5651_JD1_1: - regmap_update_bits(rt5651->regmap, RT5651_JD_CTRL2, - RT5651_JD_TRG_SEL_MASK, - RT5651_JD_TRG_SEL_JD1_1); - regmap_update_bits(rt5651->regmap, RT5651_IRQ_CTRL1, - RT5651_JD1_1_IRQ_EN, - RT5651_JD1_1_IRQ_EN); - break; - case RT5651_JD1_2: - regmap_update_bits(rt5651->regmap, RT5651_JD_CTRL2, - RT5651_JD_TRG_SEL_MASK, - RT5651_JD_TRG_SEL_JD1_2); - regmap_update_bits(rt5651->regmap, RT5651_IRQ_CTRL1, - RT5651_JD1_2_IRQ_EN, - RT5651_JD1_2_IRQ_EN); - break; - case RT5651_JD2: - regmap_update_bits(rt5651->regmap, RT5651_JD_CTRL2, - RT5651_JD_TRG_SEL_MASK, - RT5651_JD_TRG_SEL_JD2); - regmap_update_bits(rt5651->regmap, RT5651_IRQ_CTRL1, - RT5651_JD2_IRQ_EN, - RT5651_JD2_IRQ_EN); - break; - case RT5651_JD_NULL: - break; - default: - dev_warn(&i2c->dev, "Currently only JD1_1 / JD1_2 / JD2 are supported\n"); - break; - } - } - INIT_DELAYED_WORK(&rt5651->jack_detect_work, rt5651_jack_detect_work); - if (i2c->irq) { - ret = devm_request_threaded_irq(&i2c->dev, i2c->irq, NULL, - rt5651_irq, - IRQF_TRIGGER_RISING | - IRQF_TRIGGER_FALLING | - IRQF_ONESHOT, "rt5651", rt5651); - if (ret) { - dev_err(&i2c->dev, "Failed to reguest IRQ: %d\n", ret); - return ret; - } - } - ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_rt5651, rt5651_dai, ARRAY_SIZE(rt5651_dai)); diff --git a/sound/soc/codecs/rt5651.h b/sound/soc/codecs/rt5651.h index 148e139e6a26..8f128d057ff0 100644 --- a/sound/soc/codecs/rt5651.h +++ b/sound/soc/codecs/rt5651.h @@ -2065,6 +2065,7 @@ struct rt5651_priv { struct delayed_work jack_detect_work; enum rt5651_jd_src jd_src; + int irq; int sysclk; int sysclk_src; int lrck[RT5651_AIFS]; From d8b8c878e86593ad8bd86676a2a4c2be58a8b889 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:44 +0100 Subject: [PATCH 061/102] ASoC: rt5651: Move 2 functions higher up in rt5651.c Move 2 functions higher up in rt5651.c, this is a preparation patch to avoid needing forward declarations when moving over from a codec private function to the standard snd_soc_component_set_jack(). This commit purely moves these 2 functions up, not a single line is changed. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 154 +++++++++++++++++++------------------- 1 file changed, 77 insertions(+), 77 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 390cab134ba0..c9698229fc33 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1583,6 +1583,83 @@ static int rt5651_set_bias_level(struct snd_soc_component *component, return 0; } +static irqreturn_t rt5651_irq(int irq, void *data) +{ + struct rt5651_priv *rt5651 = data; + + queue_delayed_work(system_power_efficient_wq, + &rt5651->jack_detect_work, msecs_to_jiffies(250)); + + return IRQ_HANDLED; +} + +int rt5651_set_jack_detect(struct snd_soc_component *component, + struct snd_soc_jack *hp_jack) +{ + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); + int ret; + + if (!rt5651->irq) + return -EINVAL; + + /* IRQ output on GPIO1 */ + snd_soc_component_update_bits(component, RT5651_GPIO_CTRL1, + RT5651_GP1_PIN_MASK, RT5651_GP1_PIN_IRQ); + + /* Select jack detect source */ + switch (rt5651->jd_src) { + case RT5651_JD1_1: + snd_soc_component_update_bits(component, RT5651_JD_CTRL2, + RT5651_JD_TRG_SEL_MASK, RT5651_JD_TRG_SEL_JD1_1); + snd_soc_component_update_bits(component, RT5651_IRQ_CTRL1, + RT5651_JD1_1_IRQ_EN, RT5651_JD1_1_IRQ_EN); + break; + case RT5651_JD1_2: + snd_soc_component_update_bits(component, RT5651_JD_CTRL2, + RT5651_JD_TRG_SEL_MASK, RT5651_JD_TRG_SEL_JD1_2); + snd_soc_component_update_bits(component, RT5651_IRQ_CTRL1, + RT5651_JD1_2_IRQ_EN, RT5651_JD1_2_IRQ_EN); + break; + case RT5651_JD2: + snd_soc_component_update_bits(component, RT5651_JD_CTRL2, + RT5651_JD_TRG_SEL_MASK, RT5651_JD_TRG_SEL_JD2); + snd_soc_component_update_bits(component, RT5651_IRQ_CTRL1, + RT5651_JD2_IRQ_EN, RT5651_JD2_IRQ_EN); + break; + case RT5651_JD_NULL: + return 0; + default: + dev_err(component->dev, "Currently only JD1_1 / JD1_2 / JD2 are supported\n"); + return -EINVAL; + } + + snd_soc_dapm_force_enable_pin(dapm, "JD Power"); + snd_soc_dapm_force_enable_pin(dapm, "LDO"); + snd_soc_dapm_sync(dapm); + + snd_soc_component_update_bits(component, RT5651_MICBIAS, 0x38, 0x38); + + rt5651->hp_jack = hp_jack; + + ret = devm_request_threaded_irq(component->dev, rt5651->irq, NULL, + rt5651_irq, + IRQF_TRIGGER_RISING | + IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, "rt5651", rt5651); + if (ret) { + dev_err(component->dev, "Failed to reguest IRQ: %d\n", ret); + return ret; + } + + /* sync initial jack state */ + queue_delayed_work(system_power_efficient_wq, + &rt5651->jack_detect_work, 0); + + return 0; +} +EXPORT_SYMBOL_GPL(rt5651_set_jack_detect); + static int rt5651_probe(struct snd_soc_component *component) { struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); @@ -1752,16 +1829,6 @@ static const struct dmi_system_id rt5651_quirk_table[] = { {} }; -static irqreturn_t rt5651_irq(int irq, void *data) -{ - struct rt5651_priv *rt5651 = data; - - queue_delayed_work(system_power_efficient_wq, - &rt5651->jack_detect_work, msecs_to_jiffies(250)); - - return IRQ_HANDLED; -} - static int rt5651_jack_detect(struct snd_soc_component *component, int jack_insert) { struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); @@ -1827,73 +1894,6 @@ static void rt5651_jack_detect_work(struct work_struct *work) snd_soc_jack_report(rt5651->hp_jack, report, SND_JACK_HEADSET); } -int rt5651_set_jack_detect(struct snd_soc_component *component, - struct snd_soc_jack *hp_jack) -{ - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); - struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); - int ret; - - if (!rt5651->irq) - return -EINVAL; - - /* IRQ output on GPIO1 */ - snd_soc_component_update_bits(component, RT5651_GPIO_CTRL1, - RT5651_GP1_PIN_MASK, RT5651_GP1_PIN_IRQ); - - /* Select jack detect source */ - switch (rt5651->jd_src) { - case RT5651_JD1_1: - snd_soc_component_update_bits(component, RT5651_JD_CTRL2, - RT5651_JD_TRG_SEL_MASK, RT5651_JD_TRG_SEL_JD1_1); - snd_soc_component_update_bits(component, RT5651_IRQ_CTRL1, - RT5651_JD1_1_IRQ_EN, RT5651_JD1_1_IRQ_EN); - break; - case RT5651_JD1_2: - snd_soc_component_update_bits(component, RT5651_JD_CTRL2, - RT5651_JD_TRG_SEL_MASK, RT5651_JD_TRG_SEL_JD1_2); - snd_soc_component_update_bits(component, RT5651_IRQ_CTRL1, - RT5651_JD1_2_IRQ_EN, RT5651_JD1_2_IRQ_EN); - break; - case RT5651_JD2: - snd_soc_component_update_bits(component, RT5651_JD_CTRL2, - RT5651_JD_TRG_SEL_MASK, RT5651_JD_TRG_SEL_JD2); - snd_soc_component_update_bits(component, RT5651_IRQ_CTRL1, - RT5651_JD2_IRQ_EN, RT5651_JD2_IRQ_EN); - break; - case RT5651_JD_NULL: - return 0; - default: - dev_err(component->dev, "Currently only JD1_1 / JD1_2 / JD2 are supported\n"); - return -EINVAL; - } - - snd_soc_dapm_force_enable_pin(dapm, "JD Power"); - snd_soc_dapm_force_enable_pin(dapm, "LDO"); - snd_soc_dapm_sync(dapm); - - snd_soc_component_update_bits(component, RT5651_MICBIAS, 0x38, 0x38); - - rt5651->hp_jack = hp_jack; - - ret = devm_request_threaded_irq(component->dev, rt5651->irq, NULL, - rt5651_irq, - IRQF_TRIGGER_RISING | - IRQF_TRIGGER_FALLING | - IRQF_ONESHOT, "rt5651", rt5651); - if (ret) { - dev_err(component->dev, "Failed to reguest IRQ: %d\n", ret); - return ret; - } - - /* sync initial jack state */ - queue_delayed_work(system_power_efficient_wq, - &rt5651->jack_detect_work, 0); - - return 0; -} -EXPORT_SYMBOL_GPL(rt5651_set_jack_detect); - static int rt5651_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { From 6f0b819ae2b36614a514824c622ac0e02650b718 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:45 +0100 Subject: [PATCH 062/102] ASoC: rt5651: Use standard component set_jack callback Use the standard component set_jack callback instead of defining a codec private API for this. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 6 +++--- sound/soc/codecs/rt5651.h | 2 -- sound/soc/intel/boards/bytcr_rt5651.c | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index c9698229fc33..030889143249 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1593,8 +1593,8 @@ static irqreturn_t rt5651_irq(int irq, void *data) return IRQ_HANDLED; } -int rt5651_set_jack_detect(struct snd_soc_component *component, - struct snd_soc_jack *hp_jack) +static int rt5651_set_jack(struct snd_soc_component *component, + struct snd_soc_jack *hp_jack, void *data) { struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); @@ -1658,7 +1658,6 @@ int rt5651_set_jack_detect(struct snd_soc_component *component, return 0; } -EXPORT_SYMBOL_GPL(rt5651_set_jack_detect); static int rt5651_probe(struct snd_soc_component *component) { @@ -1762,6 +1761,7 @@ static const struct snd_soc_component_driver soc_component_dev_rt5651 = { .suspend = rt5651_suspend, .resume = rt5651_resume, .set_bias_level = rt5651_set_bias_level, + .set_jack = rt5651_set_jack, .controls = rt5651_snd_controls, .num_controls = ARRAY_SIZE(rt5651_snd_controls), .dapm_widgets = rt5651_dapm_widgets, diff --git a/sound/soc/codecs/rt5651.h b/sound/soc/codecs/rt5651.h index 8f128d057ff0..f3158488fc89 100644 --- a/sound/soc/codecs/rt5651.h +++ b/sound/soc/codecs/rt5651.h @@ -2080,6 +2080,4 @@ struct rt5651_priv { bool hp_mute; }; -int rt5651_set_jack_detect(struct snd_soc_component *component, - struct snd_soc_jack *hp_jack); #endif /* __RT5651_H__ */ diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index b6bf92191b9a..afb27e5e6756 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -370,7 +370,7 @@ static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) return ret; } - rt5651_set_jack_detect(codec, &priv->jack); + snd_soc_component_set_jack(codec, &priv->jack, NULL); return ret; } From 5f293d4354f8aae3c8617f83a3cbd30047676b4d Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:46 +0100 Subject: [PATCH 063/102] ASoC: rt5651: Add rt5651_apply_properties() helper function Move the applying of the differential input and dmic properties to a new rt5651_apply_properties() helper function. This new function can be called by platform code which attaches properties after probe() has run to apply these new properties. Note this also moves the time when we apply these properties for DT platforms from i2c-probe to snd-component-probe time, this should not result in any functional difference. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 22 ++++++++++++++-------- sound/soc/codecs/rt5651.h | 2 ++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 030889143249..4d93248b6401 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1659,6 +1659,18 @@ static int rt5651_set_jack(struct snd_soc_component *component, return 0; } +void rt5651_apply_properties(struct snd_soc_component *component) +{ + if (device_property_read_bool(component->dev, "realtek,in2-differential")) + snd_soc_component_update_bits(component, RT5651_IN1_IN2, + RT5651_IN_DF2, RT5651_IN_DF2); + + if (device_property_read_bool(component->dev, "realtek,dmic-en")) + snd_soc_component_update_bits(component, RT5651_GPIO_CTRL1, + RT5651_GP2_PIN_MASK, RT5651_GP2_PIN_DMIC1_SCL); +} +EXPORT_SYMBOL_GPL(rt5651_apply_properties); + static int rt5651_probe(struct snd_soc_component *component) { struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); @@ -1677,6 +1689,8 @@ static int rt5651_probe(struct snd_soc_component *component) snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); + rt5651_apply_properties(component); + return 0; } @@ -1932,14 +1946,6 @@ static int rt5651_i2c_probe(struct i2c_client *i2c, if (ret != 0) dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret); - if (device_property_read_bool(&i2c->dev, "realtek,in2-differential")) - regmap_update_bits(rt5651->regmap, RT5651_IN1_IN2, - RT5651_IN_DF2, RT5651_IN_DF2); - - if (device_property_read_bool(&i2c->dev, "realtek,dmic-en")) - regmap_update_bits(rt5651->regmap, RT5651_GPIO_CTRL1, - RT5651_GP2_PIN_MASK, RT5651_GP2_PIN_DMIC1_SCL); - rt5651->irq = i2c->irq; rt5651->hp_mute = 1; diff --git a/sound/soc/codecs/rt5651.h b/sound/soc/codecs/rt5651.h index f3158488fc89..7d9d5fa09d6f 100644 --- a/sound/soc/codecs/rt5651.h +++ b/sound/soc/codecs/rt5651.h @@ -2080,4 +2080,6 @@ struct rt5651_priv { bool hp_mute; }; +void rt5651_apply_properties(struct snd_soc_component *component); + #endif /* __RT5651_H__ */ From d082174c99e77beb06a51c90ac61934554e516e1 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:48 +0100 Subject: [PATCH 064/102] ASoC: rt5651: Remove is_sys_clk_from_pll() is_sys_clk_from_pll() is used as a snd_soc_dapm_route.connected callback, checking RT5651_GBL_CLK to determine if the sys-clk is PLL1 and thus the PWR_PLL bit in reg PWR_ANLG2 must be set. RT5651_GBL_CLK is changed by rt5651_set_dai_sysclk(), which gets called by the pre_pmu / post_pmd functions of the "Platform Clock" dapm-supply. This creates an ordering issue, during a dapm transition first all connected() callbacks are called to build a list of supplies to enable and then the complete list is walked to enable the supplies. Since the connected() check happens before enabling any supplies, is_sys_clk_from_pll() ends up deciding if the PWR_PLL bit should be set based on the state the "Platform Clock" supply had *before* the transition. This sometimes results in PWR_PLL being off, even though *after* the transition PLL1 is configured as sys-clk. This commit removes is_sys_clk_from_pll() instead simply setting / clearing PWR_PLL in rt5651_set_dai_sysclk() based on the selected sys-clk, which fixes this and as a bonus results in a nice cleanup. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 4d93248b6401..8548f9406520 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -398,20 +398,6 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w, return idx; } -static int is_sysclk_from_pll(struct snd_soc_dapm_widget *source, - struct snd_soc_dapm_widget *sink) -{ - struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); - unsigned int val; - - val = snd_soc_component_read32(component, RT5651_GLB_CLK); - val &= RT5651_SCLK_SRC_MASK; - if (val == RT5651_SCLK_SRC_PLL1) - return 1; - else - return 0; -} - /* Digital Mixer */ static const struct snd_kcontrol_new rt5651_sto1_adc_l_mix[] = { SOC_DAPM_SINGLE("ADC1 Switch", RT5651_STO1_ADC_MIXER, @@ -883,8 +869,6 @@ static const struct snd_soc_dapm_widget rt5651_dapm_widgets[] = { SND_SOC_DAPM_SUPPLY_S("ADC ASRC", 1, RT5651_PLL_MODE_2, 11, 0, NULL, 0), - SND_SOC_DAPM_SUPPLY("PLL1", RT5651_PWR_ANLG2, - RT5651_PWR_PLL_BIT, 0, NULL, 0), /* Input Side */ SND_SOC_DAPM_SUPPLY("JD Power", RT5651_PWR_ANLG2, RT5651_PWM_JD_M_BIT, 0, NULL, 0), @@ -1167,7 +1151,6 @@ static const struct snd_soc_dapm_route rt5651_dapm_routes[] = { {"Stereo1 ADC MIXL", "ADC1 Switch", "Stereo1 ADC L1 Mux"}, {"Stereo1 ADC MIXL", "ADC2 Switch", "Stereo1 ADC L2 Mux"}, {"Stereo1 ADC MIXL", NULL, "Stereo1 Filter"}, - {"Stereo1 Filter", NULL, "PLL1", is_sysclk_from_pll}, {"Stereo1 Filter", NULL, "ADC ASRC"}, {"Stereo1 ADC MIXR", "ADC1 Switch", "Stereo1 ADC R1 Mux"}, @@ -1177,7 +1160,6 @@ static const struct snd_soc_dapm_route rt5651_dapm_routes[] = { {"Stereo2 ADC MIXL", "ADC1 Switch", "Stereo2 ADC L1 Mux"}, {"Stereo2 ADC MIXL", "ADC2 Switch", "Stereo2 ADC L2 Mux"}, {"Stereo2 ADC MIXL", NULL, "Stereo2 Filter"}, - {"Stereo2 Filter", NULL, "PLL1", is_sysclk_from_pll}, {"Stereo2 Filter", NULL, "ADC ASRC"}, {"Stereo2 ADC MIXR", "ADC1 Switch", "Stereo2 ADC R1 Mux"}, @@ -1244,10 +1226,8 @@ static const struct snd_soc_dapm_route rt5651_dapm_routes[] = { {"PDM R Mux", "DD MIX", "DAC MIXR"}, {"DAC L1", NULL, "Stereo DAC MIXL"}, - {"DAC L1", NULL, "PLL1", is_sysclk_from_pll}, {"DAC L1", NULL, "DAC L1 Power"}, {"DAC R1", NULL, "Stereo DAC MIXR"}, - {"DAC R1", NULL, "PLL1", is_sysclk_from_pll}, {"DAC R1", NULL, "DAC R1 Power"}, {"DD MIXL", "DAC L1 Switch", "DAC MIXL"}, @@ -1443,6 +1423,7 @@ static int rt5651_set_dai_sysclk(struct snd_soc_dai *dai, struct snd_soc_component *component = dai->component; struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; + unsigned int pll_bit = 0; if (freq == rt5651->sysclk && clk_id == rt5651->sysclk_src) return 0; @@ -1453,6 +1434,7 @@ static int rt5651_set_dai_sysclk(struct snd_soc_dai *dai, break; case RT5651_SCLK_S_PLL1: reg_val |= RT5651_SCLK_SRC_PLL1; + pll_bit |= RT5651_PWR_PLL; break; case RT5651_SCLK_S_RCCLK: reg_val |= RT5651_SCLK_SRC_RCCLK; @@ -1461,6 +1443,8 @@ static int rt5651_set_dai_sysclk(struct snd_soc_dai *dai, dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); return -EINVAL; } + snd_soc_component_update_bits(component, RT5651_PWR_ANLG2, + RT5651_PWR_PLL, pll_bit); snd_soc_component_update_bits(component, RT5651_GLB_CLK, RT5651_SCLK_SRC_MASK, reg_val); rt5651->sysclk = freq; From 984c803f9a2ad6f1d2bea0b7ef2e3c18d69fbdfd Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:49 +0100 Subject: [PATCH 065/102] ASoC: rt5651: Fix bias_level confusion The rt5651_set_bias_level() function was turning everything off at SND_SOC_BIAS_STANDBY, rather then at SND_SOC_BIAS_OFF, requiring the bias- level to be raised to SND_SOC_BIAS_PREPARE before turning anything on. This is not how the bias-levels are supposed to work, this commit fixes this by turning everything off at the SND_SOC_BIAS_OFF level and enabling the pwr-bits needed for minimum functionality at SND_SOC_BIAS_STANDBY. This fixes the minimum set of pwr-bits not getting enabled when force-enabling some dapm-supplies (e.g. for jack type detection), which raises the bias-level to standby. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 8548f9406520..c565607f95f7 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1526,6 +1526,13 @@ static int rt5651_set_bias_level(struct snd_soc_component *component, switch (level) { case SND_SOC_BIAS_PREPARE: if (SND_SOC_BIAS_STANDBY == snd_soc_component_get_bias_level(component)) { + if (snd_soc_component_read32(component, RT5651_PLL_MODE_1) & 0x9200) + snd_soc_component_update_bits(component, RT5651_D_MISC, + 0xc00, 0xc00); + } + break; + case SND_SOC_BIAS_STANDBY: + if (SND_SOC_BIAS_OFF == snd_soc_component_get_bias_level(component)) { snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, RT5651_PWR_VREF1 | RT5651_PWR_MB | RT5651_PWR_BG | RT5651_PWR_VREF2, @@ -1539,13 +1546,10 @@ static int rt5651_set_bias_level(struct snd_soc_component *component, RT5651_PWR_LDO_DVO_MASK, RT5651_PWR_LDO_DVO_1_2V); snd_soc_component_update_bits(component, RT5651_D_MISC, 0x1, 0x1); - if (snd_soc_component_read32(component, RT5651_PLL_MODE_1) & 0x9200) - snd_soc_component_update_bits(component, RT5651_D_MISC, - 0xc00, 0xc00); } break; - case SND_SOC_BIAS_STANDBY: + case SND_SOC_BIAS_OFF: snd_soc_component_write(component, RT5651_D_MISC, 0x0010); snd_soc_component_write(component, RT5651_PWR_DIG1, 0x0000); snd_soc_component_write(component, RT5651_PWR_DIG2, 0x0000); From bba4e685dae8643469ca6fac22f10ca81554586e Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:50 +0100 Subject: [PATCH 066/102] ASoC: rt5651: Do not modify the LDO voltage control bits from set_bias_level() The PWR_ANLG1 reg not only contains various power on/off bits, it also contains 2 bits which select if the LDO generates 1.0, 1.1 or 1.2V. Note there is a separate on/off bit for the LDO. rt5651_set_bias_level(BIAS_OFF) used to unconditionally clear the entire register, when jack-detection support was introduced a special case for jack-detect was added which hard-codes a register value to keep the LDO voltage at 1.2 volt. This commit removes the jack-detect special case, instead simply always leaving the LDO voltage control bits as is on BIAS_OFF. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index c565607f95f7..c93539ee2200 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1555,11 +1555,12 @@ static int rt5651_set_bias_level(struct snd_soc_component *component, snd_soc_component_write(component, RT5651_PWR_DIG2, 0x0000); snd_soc_component_write(component, RT5651_PWR_VOL, 0x0000); snd_soc_component_write(component, RT5651_PWR_MIXER, 0x0000); + /* Do not touch the LDO voltage select bits on bias-off */ + snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, + ~RT5651_PWR_LDO_DVO_MASK, 0); if (rt5651->jd_src) { snd_soc_component_write(component, RT5651_PWR_ANLG2, 0x0204); - snd_soc_component_write(component, RT5651_PWR_ANLG1, 0x0002); } else { - snd_soc_component_write(component, RT5651_PWR_ANLG1, 0x0000); snd_soc_component_write(component, RT5651_PWR_ANLG2, 0x0000); } break; From 887fcc6f0514380f17d5016dd8cdfc4d9a4437ee Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:51 +0100 Subject: [PATCH 067/102] ASoC: rt5651: Do not modify jd and PLL power bits from set_bias_level() rt5651_set_bias_level(BIAS_OFF) used to unconditionally clear the entire register, including the jack-detect and PLL power bits. When jack-detection support was introduced a special case for jack-detect was added which hard-codes a register value to keep both on. This commit removes the jack-detect special case, instead simply leaving these bits as is on BIAS_OFF. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index c93539ee2200..d4fb16686889 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1521,8 +1521,6 @@ static int rt5651_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, static int rt5651_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); - switch (level) { case SND_SOC_BIAS_PREPARE: if (SND_SOC_BIAS_STANDBY == snd_soc_component_get_bias_level(component)) { @@ -1558,11 +1556,9 @@ static int rt5651_set_bias_level(struct snd_soc_component *component, /* Do not touch the LDO voltage select bits on bias-off */ snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, ~RT5651_PWR_LDO_DVO_MASK, 0); - if (rt5651->jd_src) { - snd_soc_component_write(component, RT5651_PWR_ANLG2, 0x0204); - } else { - snd_soc_component_write(component, RT5651_PWR_ANLG2, 0x0000); - } + /* Leave PLL1 and jack-detect power as is, all others off */ + snd_soc_component_update_bits(component, RT5651_PWR_ANLG2, + ~(RT5651_PWR_PLL | RT5651_PWR_JD_M), 0); break; default: From a25fe11746846f5dd3286cf690b470e3d049797f Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:52 +0100 Subject: [PATCH 068/102] ASoC: rt5651: Remove programming of PWR regs before force_bias_level() call Remove the setup of the PWR_ANLG1 reg which was done directly before calling snd_soc_component_force_bias_level(SND_SOC_BIAS_OFF), as the latter will override any settings done to PWR_ANLG1 immediately anyways. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index d4fb16686889..74f83af3b6be 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1662,16 +1662,6 @@ static int rt5651_probe(struct snd_soc_component *component) rt5651->component = component; - snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, - RT5651_PWR_VREF1 | RT5651_PWR_MB | - RT5651_PWR_BG | RT5651_PWR_VREF2, - RT5651_PWR_VREF1 | RT5651_PWR_MB | - RT5651_PWR_BG | RT5651_PWR_VREF2); - usleep_range(10000, 15000); - snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, - RT5651_PWR_FV1 | RT5651_PWR_FV2, - RT5651_PWR_FV1 | RT5651_PWR_FV2); - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); rt5651_apply_properties(component); From 3d7719d3cc8efe88be4c72cb7cbb0d866ed7d1b2 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:53 +0100 Subject: [PATCH 069/102] ASoC: rt5651: Only configure LDO voltage once at boot Now that rt5651_set_bias_level(BIAS_OFF) no longer modifies the LDO voltage selection bits, there is no need to set them each time we move to standby. Instead configure them once at component-probe() time. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 74f83af3b6be..9460bdcad349 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1540,9 +1540,6 @@ static int rt5651_set_bias_level(struct snd_soc_component *component, snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, RT5651_PWR_FV1 | RT5651_PWR_FV2, RT5651_PWR_FV1 | RT5651_PWR_FV2); - snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, - RT5651_PWR_LDO_DVO_MASK, - RT5651_PWR_LDO_DVO_1_2V); snd_soc_component_update_bits(component, RT5651_D_MISC, 0x1, 0x1); } break; @@ -1662,6 +1659,9 @@ static int rt5651_probe(struct snd_soc_component *component) rt5651->component = component; + snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, + RT5651_PWR_LDO_DVO_MASK, RT5651_PWR_LDO_DVO_1_2V); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); rt5651_apply_properties(component); From 57d9d7c32fc24ca4de49392fec1fdd3db1f58e92 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:54 +0100 Subject: [PATCH 070/102] ASoC: rt5651: Remove "JD Power" dapm supply Remove the "JD power" dapm supply which gets force-enabled once when using jack-detect and never gets disabled again. Since the PWR_JD_M bit simply needs to be always on when using jack-detect there is no need to have it tracked by dapm, instead we can simply set it to 1 once when initializing the jack-detection. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 9460bdcad349..cbf9f56ecb14 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -869,10 +869,6 @@ static const struct snd_soc_dapm_widget rt5651_dapm_widgets[] = { SND_SOC_DAPM_SUPPLY_S("ADC ASRC", 1, RT5651_PLL_MODE_2, 11, 0, NULL, 0), - /* Input Side */ - SND_SOC_DAPM_SUPPLY("JD Power", RT5651_PWR_ANLG2, - RT5651_PWM_JD_M_BIT, 0, NULL, 0), - /* micbias */ SND_SOC_DAPM_SUPPLY("LDO", RT5651_PWR_ANLG1, RT5651_PWR_LDO_BIT, 0, NULL, 0), @@ -1616,7 +1612,10 @@ static int rt5651_set_jack(struct snd_soc_component *component, return -EINVAL; } - snd_soc_dapm_force_enable_pin(dapm, "JD Power"); + /* Enable jack detect power */ + snd_soc_component_update_bits(component, RT5651_PWR_ANLG2, + RT5651_PWR_JD_M, RT5651_PWR_JD_M); + snd_soc_dapm_force_enable_pin(dapm, "LDO"); snd_soc_dapm_sync(dapm); From 1310e737a68741c9b06cf63be0084bae6018b308 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:55 +0100 Subject: [PATCH 071/102] ASoC: rt5651: Enable LDO and micbias1 supplies for jack-type detection To determine if a plugged in jack is a headset (speakers + mic) or headphones (mic contact shorted to ground) we use the micbias1 OVer Current Detect (OVCD) functionality. For this to work we need to have a micbias current to actually cause an overcurrent condition when headphones are plugged in, so jack-type detection requires both the LDO and micbias1 supplies to be on. Before this commit there were 2 issues with the handling of this: 1) The LDO supply was force-enabled twice and never disabled again even though it only needs to be forced on when doing jack-type detection 2) micbias1 was not force-enabled, and thus may be off when doing jack-type detection This commit fixes both by force-enabling the LDO and micbias1 supplies before checking for an overcurrent condition and disabling them afterwards. Note that both supplies will still get turned on normally (and OVCD will protect against overcurrent) when the micbias1 is enabled normally because the user has activated a sound stream recording from the mic. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index cbf9f56ecb14..be942886700d 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1561,6 +1561,28 @@ static int rt5651_set_bias_level(struct snd_soc_component *component, return 0; } +static void rt5651_enable_micbias1_for_ovcd(struct snd_soc_component *component) +{ + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + + snd_soc_dapm_mutex_lock(dapm); + snd_soc_dapm_force_enable_pin_unlocked(dapm, "LDO"); + snd_soc_dapm_force_enable_pin_unlocked(dapm, "micbias1"); + snd_soc_dapm_sync_unlocked(dapm); + snd_soc_dapm_mutex_unlock(dapm); +} + +static void rt5651_disable_micbias1_for_ovcd(struct snd_soc_component *component) +{ + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + + snd_soc_dapm_mutex_lock(dapm); + snd_soc_dapm_disable_pin_unlocked(dapm, "micbias1"); + snd_soc_dapm_disable_pin_unlocked(dapm, "LDO"); + snd_soc_dapm_sync_unlocked(dapm); + snd_soc_dapm_mutex_unlock(dapm); +} + static irqreturn_t rt5651_irq(int irq, void *data) { struct rt5651_priv *rt5651 = data; @@ -1574,7 +1596,6 @@ static irqreturn_t rt5651_irq(int irq, void *data) static int rt5651_set_jack(struct snd_soc_component *component, struct snd_soc_jack *hp_jack, void *data) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); int ret; @@ -1616,9 +1637,6 @@ static int rt5651_set_jack(struct snd_soc_component *component, snd_soc_component_update_bits(component, RT5651_PWR_ANLG2, RT5651_PWR_JD_M, RT5651_PWR_JD_M); - snd_soc_dapm_force_enable_pin(dapm, "LDO"); - snd_soc_dapm_sync(dapm); - snd_soc_component_update_bits(component, RT5651_MICBIAS, 0x38, 0x38); rt5651->hp_jack = hp_jack; @@ -1819,13 +1837,10 @@ static const struct dmi_system_id rt5651_quirk_table[] = { static int rt5651_jack_detect(struct snd_soc_component *component, int jack_insert) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int jack_type; if (jack_insert) { - snd_soc_dapm_force_enable_pin(dapm, "LDO"); - snd_soc_dapm_sync(dapm); - + rt5651_enable_micbias1_for_ovcd(component); snd_soc_component_update_bits(component, RT5651_MICBIAS, RT5651_MIC1_OVCD_MASK | RT5651_MIC1_OVTH_MASK | @@ -1842,6 +1857,7 @@ static int rt5651_jack_detect(struct snd_soc_component *component, int jack_inse jack_type = SND_JACK_HEADSET; snd_soc_component_update_bits(component, RT5651_IRQ_CTRL2, RT5651_MB1_OC_CLR, 0); + rt5651_disable_micbias1_for_ovcd(component); } else { /* jack out */ jack_type = 0; From 9e1795925d0e967d2a0191b1487b5caf0693f2ae Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:56 +0100 Subject: [PATCH 072/102] ASoC: rt5651: Only configure OVCD once at set_jack time Only configure OVCD once at set_jack time, rather then configuring it on every jack-insertion event and switch to using bit field defines instead of hardcoding a magic value. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index be942886700d..41d7c192ac03 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1637,7 +1637,15 @@ static int rt5651_set_jack(struct snd_soc_component *component, snd_soc_component_update_bits(component, RT5651_PWR_ANLG2, RT5651_PWR_JD_M, RT5651_PWR_JD_M); - snd_soc_component_update_bits(component, RT5651_MICBIAS, 0x38, 0x38); + snd_soc_component_update_bits(component, RT5651_MICBIAS, + RT5651_MIC1_OVCD_MASK | + RT5651_MIC1_OVTH_MASK | + RT5651_PWR_CLK12M_MASK | + RT5651_PWR_MB_MASK, + RT5651_MIC1_OVCD_DIS | + RT5651_MIC1_OVTH_600UA | + RT5651_PWR_MB_PU | + RT5651_PWR_CLK12M_PU); rt5651->hp_jack = hp_jack; @@ -1842,14 +1850,8 @@ static int rt5651_jack_detect(struct snd_soc_component *component, int jack_inse if (jack_insert) { rt5651_enable_micbias1_for_ovcd(component); snd_soc_component_update_bits(component, RT5651_MICBIAS, - RT5651_MIC1_OVCD_MASK | - RT5651_MIC1_OVTH_MASK | - RT5651_PWR_CLK12M_MASK | - RT5651_PWR_MB_MASK, - RT5651_MIC1_OVCD_EN | - RT5651_MIC1_OVTH_600UA | - RT5651_PWR_MB_PU | - RT5651_PWR_CLK12M_PU); + RT5651_MIC1_OVCD_MASK, + RT5651_MIC1_OVCD_EN); msleep(100); if (snd_soc_component_read32(component, RT5651_IRQ_CTRL2) & RT5651_MB1_OC_CLR) jack_type = SND_JACK_HEADPHONE; From f1088d4b813fb4d20fc9e8e8db5ca252923f25eb Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:57 +0100 Subject: [PATCH 073/102] ASoC: rt5651: Always keep OVCD enabled OVCD is not only useful for jack-type detection, but is also useful to protect against over-current faults in general, so always keep OVCD enabled, instead of only enabling it for jack-type detection. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 41d7c192ac03..55bcc74e344f 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1642,7 +1642,7 @@ static int rt5651_set_jack(struct snd_soc_component *component, RT5651_MIC1_OVTH_MASK | RT5651_PWR_CLK12M_MASK | RT5651_PWR_MB_MASK, - RT5651_MIC1_OVCD_DIS | + RT5651_MIC1_OVCD_EN | RT5651_MIC1_OVTH_600UA | RT5651_PWR_MB_PU | RT5651_PWR_CLK12M_PU); @@ -1849,9 +1849,6 @@ static int rt5651_jack_detect(struct snd_soc_component *component, int jack_inse if (jack_insert) { rt5651_enable_micbias1_for_ovcd(component); - snd_soc_component_update_bits(component, RT5651_MICBIAS, - RT5651_MIC1_OVCD_MASK, - RT5651_MIC1_OVCD_EN); msleep(100); if (snd_soc_component_read32(component, RT5651_IRQ_CTRL2) & RT5651_MB1_OC_CLR) jack_type = SND_JACK_HEADPHONE; @@ -1862,10 +1859,6 @@ static int rt5651_jack_detect(struct snd_soc_component *component, int jack_inse rt5651_disable_micbias1_for_ovcd(component); } else { /* jack out */ jack_type = 0; - - snd_soc_component_update_bits(component, RT5651_MICBIAS, - RT5651_MIC1_OVCD_MASK, - RT5651_MIC1_OVCD_DIS); } return jack_type; From cb1f904d91c52bc4e03e11eb161288c40c655095 Mon Sep 17 00:00:00 2001 From: Guneshwor Singh Date: Sat, 27 Jan 2018 09:50:21 +0530 Subject: [PATCH 074/102] ASoC: Intel: Skylake: Refine skl widget type check The current check is not effective when all the widgets of a card are involved since other widgets also can be of same type. So, make widget type check more stringent by checking dev pointer additionally. Signed-off-by: Guneshwor Singh Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-topology.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index 73af6e19ebbd..dbe6a19b84f5 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c @@ -94,8 +94,12 @@ void skl_tplg_d0i3_put(struct skl *skl, enum d0i3_capability caps) * SKL DSP driver modelling uses only few DAPM widgets so for rest we will * ignore. This helpers checks if the SKL driver handles this widget type */ -static int is_skl_dsp_widget_type(struct snd_soc_dapm_widget *w) +static int is_skl_dsp_widget_type(struct snd_soc_dapm_widget *w, + struct device *dev) { + if (w->dapm->dev != dev) + return false; + switch (w->id) { case snd_soc_dapm_dai_link: case snd_soc_dapm_dai_in: @@ -969,7 +973,7 @@ static int skl_tplg_bind_sinks(struct snd_soc_dapm_widget *w, next_sink = p->sink; - if (!is_skl_dsp_widget_type(p->sink)) + if (!is_skl_dsp_widget_type(p->sink, ctx->dev)) return skl_tplg_bind_sinks(p->sink, skl, src_w, src_mconfig); /* @@ -978,7 +982,7 @@ static int skl_tplg_bind_sinks(struct snd_soc_dapm_widget *w, * they are ones used for SKL so check that first */ if ((p->sink->priv != NULL) && - is_skl_dsp_widget_type(p->sink)) { + is_skl_dsp_widget_type(p->sink, ctx->dev)) { sink = p->sink; sink_mconfig = sink->priv; @@ -1092,7 +1096,7 @@ static struct snd_soc_dapm_widget *skl_get_src_dsp_widget( * ones used for SKL so check that first */ if ((p->source->priv != NULL) && - is_skl_dsp_widget_type(p->source)) { + is_skl_dsp_widget_type(p->source, ctx->dev)) { return p->source; } } @@ -1654,7 +1658,7 @@ skl_tplg_fe_get_cpr_module(struct snd_soc_dai *dai, int stream) w = dai->playback_widget; snd_soc_dapm_widget_for_each_sink_path(w, p) { if (p->connect && p->sink->power && - !is_skl_dsp_widget_type(p->sink)) + !is_skl_dsp_widget_type(p->sink, dai->dev)) continue; if (p->sink->priv) { @@ -1667,7 +1671,7 @@ skl_tplg_fe_get_cpr_module(struct snd_soc_dai *dai, int stream) w = dai->capture_widget; snd_soc_dapm_widget_for_each_source_path(w, p) { if (p->connect && p->source->power && - !is_skl_dsp_widget_type(p->source)) + !is_skl_dsp_widget_type(p->source, dai->dev)) continue; if (p->source->priv) { @@ -1819,7 +1823,7 @@ static int skl_tplg_be_set_src_pipe_params(struct snd_soc_dai *dai, int ret = -EIO; snd_soc_dapm_widget_for_each_source_path(w, p) { - if (p->connect && is_skl_dsp_widget_type(p->source) && + if (p->connect && is_skl_dsp_widget_type(p->source, dai->dev) && p->source->priv) { ret = skl_tplg_be_fill_pipe_params(dai, @@ -1844,7 +1848,7 @@ static int skl_tplg_be_set_sink_pipe_params(struct snd_soc_dai *dai, int ret = -EIO; snd_soc_dapm_widget_for_each_sink_path(w, p) { - if (p->connect && is_skl_dsp_widget_type(p->sink) && + if (p->connect && is_skl_dsp_widget_type(p->sink, dai->dev) && p->sink->priv) { ret = skl_tplg_be_fill_pipe_params(dai, @@ -2752,7 +2756,7 @@ void skl_cleanup_resources(struct skl *skl) skl->resource.mcps = 0; list_for_each_entry(w, &card->widgets, list) { - if (is_skl_dsp_widget_type(w) && (w->priv != NULL)) + if (is_skl_dsp_widget_type(w, ctx->dev) && w->priv != NULL) skl_clear_pin_config(soc_platform, w); } @@ -3408,7 +3412,7 @@ static int skl_tplg_create_pipe_widget_list(struct snd_soc_platform *platform) struct skl_pipe *pipe; list_for_each_entry(w, &platform->component.card->widgets, list) { - if (is_skl_dsp_widget_type(w) && w->priv != NULL) { + if (is_skl_dsp_widget_type(w, platform->dev) && w->priv) { mcfg = w->priv; pipe = mcfg->pipe; From 66b4860641cd459cd5e189ed5db6e9f339c31a0f Mon Sep 17 00:00:00 2001 From: "Pawse, GuruprasadX" Date: Sat, 27 Jan 2018 09:50:22 +0530 Subject: [PATCH 075/102] ASoC: Intel: Skylake: Add BE DAI for WoV usecase Currently DMIC capture and WoV usecase uses same BE DAI but operate at different sampling rates, this results in config mismatch for WoV when DMIC is already running in parallel. DMIC has two slots which can operate with some constraints, so add BE DAI for DMICvoice pin which can used for WoV usecases to capture 4ch, 16KHz, 16bit data. Signed-off-by: Pawse, GuruprasadX Signed-off-by: Guneshwor Singh Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-pcm.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c index e46828533826..2685d511c06f 100644 --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c @@ -958,6 +958,17 @@ static struct snd_soc_dai_driver skl_platform_dai[] = { .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE, }, }, +{ + .name = "DMIC16k Pin", + .ops = &skl_dmic_dai_ops, + .capture = { + .stream_name = "DMIC16k Rx", + .channels_min = HDA_MONO, + .channels_max = HDA_QUAD, + .rates = SNDRV_PCM_RATE_16000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + }, +}, { .name = "HD-Codec Pin", .ops = &skl_link_dai_ops, From 8913f97d2317f363d4d525fdbff5817942bda6d1 Mon Sep 17 00:00:00 2001 From: "Pawse, GuruprasadX" Date: Sat, 27 Jan 2018 09:50:23 +0530 Subject: [PATCH 076/102] ASoC: Intel: board: Add BE DAI link for WoV and update DAPM machine map. Create BE DAI link for WoV and accordingly update the DAPM machine map Signed-off-by: Pawse, GuruprasadX Signed-off-by: Guneshwor Singh Signed-off-by: Mark Brown --- sound/soc/intel/boards/bxt_rt298.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sound/soc/intel/boards/bxt_rt298.c b/sound/soc/intel/boards/bxt_rt298.c index 875d85119c66..c7e9024e65ef 100644 --- a/sound/soc/intel/boards/bxt_rt298.c +++ b/sound/soc/intel/boards/bxt_rt298.c @@ -146,6 +146,9 @@ static const struct snd_soc_dapm_route geminilake_rt298_map[] = { { "dmic01_hifi", NULL, "DMIC01 Rx" }, { "DMIC01 Rx", NULL, "Capture" }, + { "dmic_voice", NULL, "DMIC16k Rx" }, + { "DMIC16k Rx", NULL, "Capture" }, + { "hifi3", NULL, "iDisp3 Tx"}, { "iDisp3 Tx", NULL, "iDisp3_out"}, { "hifi2", NULL, "iDisp2 Tx"}, @@ -456,6 +459,18 @@ static struct snd_soc_dai_link broxton_rt298_dais[] = { .dpcm_capture = 1, .no_pcm = 1, }, + { + .name = "dmic16k", + .id = 2, + .cpu_dai_name = "DMIC16k Pin", + .codec_name = "dmic-codec", + .codec_dai_name = "dmic-hifi", + .platform_name = "0000:00:0e.0", + .be_hw_params_fixup = broxton_dmic_fixup, + .ignore_suspend = 1, + .dpcm_capture = 1, + .no_pcm = 1, + }, { .name = "iDisp1", .id = 3, From f7a9f77256e7fbd6150651bfab44f60c39f0b7a2 Mon Sep 17 00:00:00 2001 From: Sriram Periyasamy Date: Sat, 27 Jan 2018 09:50:24 +0530 Subject: [PATCH 077/102] ASoC: Intel: Skylake: Find module id from UUID for bind params Module id is a property of firmware manifest and can vary across platforms. So use the uuid to find module id dynamically for bind params like kpb post bind params. Signed-off-by: Sriram Periyasamy Signed-off-by: Guneshwor Singh Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-pcm.c | 2 + sound/soc/intel/skylake/skl-topology.c | 83 +++++++++++++++++++++++++- sound/soc/intel/skylake/skl-topology.h | 13 +++- 3 files changed, 96 insertions(+), 2 deletions(-) diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c index 2685d511c06f..91d858e25fce 100644 --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c @@ -1318,6 +1318,8 @@ static int skl_populate_modules(struct skl *skl) "query module info failed\n"); return ret; } + + skl_tplg_add_moduleid_in_bind_params(skl, w); } } diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index dbe6a19b84f5..17da3b58c214 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c @@ -830,7 +830,7 @@ static int skl_fill_sink_instance_id(struct skl_sst *ctx, u32 *params, if (mcfg->m_type == SKL_MODULE_TYPE_KPB) { struct skl_kpb_params *kpb_params = (struct skl_kpb_params *)params; - struct skl_mod_inst_map *inst = kpb_params->map; + struct skl_mod_inst_map *inst = kpb_params->u.map; for (i = 0; i < kpb_params->num_modules; i++) { pvt_id = skl_get_pvt_instance_id_map(ctx, inst->mod_id, @@ -915,6 +915,87 @@ static int skl_tplg_set_module_bind_params(struct snd_soc_dapm_widget *w, return 0; } +static int skl_get_module_id(struct skl_sst *ctx, uuid_le *uuid) +{ + struct uuid_module *module; + + list_for_each_entry(module, &ctx->uuid_list, list) { + if (uuid_le_cmp(*uuid, module->uuid) == 0) + return module->id; + } + + return -EINVAL; +} + +static int skl_tplg_find_moduleid_from_uuid(struct skl *skl, + const struct snd_kcontrol_new *k) +{ + struct soc_bytes_ext *sb = (void *) k->private_value; + struct skl_algo_data *bc = (struct skl_algo_data *)sb->dobj.private; + struct skl_kpb_params *uuid_params, *params; + struct hdac_bus *bus = ebus_to_hbus(skl_to_ebus(skl)); + int i, size, module_id; + + if (bc->set_params == SKL_PARAM_BIND && bc->max) { + uuid_params = (struct skl_kpb_params *)bc->params; + size = uuid_params->num_modules * + sizeof(struct skl_mod_inst_map) + + sizeof(uuid_params->num_modules); + + params = devm_kzalloc(bus->dev, size, GFP_KERNEL); + if (!params) + return -ENOMEM; + + params->num_modules = uuid_params->num_modules; + + for (i = 0; i < uuid_params->num_modules; i++) { + module_id = skl_get_module_id(skl->skl_sst, + &uuid_params->u.map_uuid[i].mod_uuid); + if (module_id < 0) { + devm_kfree(bus->dev, params); + return -EINVAL; + } + + params->u.map[i].mod_id = module_id; + params->u.map[i].inst_id = + uuid_params->u.map_uuid[i].inst_id; + } + + devm_kfree(bus->dev, bc->params); + bc->params = (char *)params; + bc->max = size; + } + + return 0; +} + +/* + * Retrieve the module id from UUID mentioned in the + * post bind params + */ +void skl_tplg_add_moduleid_in_bind_params(struct skl *skl, + struct snd_soc_dapm_widget *w) +{ + struct skl_module_cfg *mconfig = w->priv; + int i; + + /* + * Post bind params are used for only for KPB + * to set copier instances to drain the data + * in fast mode + */ + if (mconfig->m_type != SKL_MODULE_TYPE_KPB) + return; + + for (i = 0; i < w->num_kcontrols; i++) + if ((w->kcontrol_news[i].access & + SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) && + (skl_tplg_find_moduleid_from_uuid(skl, + &w->kcontrol_news[i]) < 0)) + dev_err(skl->skl_sst->dev, + "%s: invalid kpb post bind params\n", + __func__); +} static int skl_tplg_module_add_deferred_bind(struct skl *skl, struct skl_module_cfg *src, struct skl_module_cfg *dst) diff --git a/sound/soc/intel/skylake/skl-topology.h b/sound/soc/intel/skylake/skl-topology.h index b6496513fe55..a467129cc705 100644 --- a/sound/soc/intel/skylake/skl-topology.h +++ b/sound/soc/intel/skylake/skl-topology.h @@ -221,9 +221,18 @@ struct skl_mod_inst_map { u16 inst_id; }; +struct skl_uuid_inst_map { + u16 inst_id; + u16 reserved; + uuid_le mod_uuid; +} __packed; + struct skl_kpb_params { u32 num_modules; - struct skl_mod_inst_map map[0]; + union { + struct skl_mod_inst_map map[0]; + struct skl_uuid_inst_map map_uuid[0]; + } u; }; struct skl_module_inst_id { @@ -505,4 +514,6 @@ int skl_pcm_link_dma_prepare(struct device *dev, int skl_dai_load(struct snd_soc_component *cmp, struct snd_soc_dai_driver *pcm_dai); +void skl_tplg_add_moduleid_in_bind_params(struct skl *skl, + struct snd_soc_dapm_widget *w); #endif From 3bf045d15f52529e8abe26543dbe22af44efb41a Mon Sep 17 00:00:00 2001 From: John Hsu Date: Fri, 2 Mar 2018 10:45:14 +0800 Subject: [PATCH 078/102] ASoC: Intel: fix argument error in nau8824 machine Fix the error: passing argument 1 of 'nau8824_enable_jack_detect' from incompatible pointer type nau8824_enable_jack_detect(codec, jack); ^~~~~ Which expects 'struct snd_soc_component *' but argument is of type 'struct snd_soc_codec *' Reported-by: Stephen Rothwell Signed-off-by: John Hsu Signed-off-by: Mark Brown --- sound/soc/intel/boards/cht_bsw_nau8824.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/intel/boards/cht_bsw_nau8824.c b/sound/soc/intel/boards/cht_bsw_nau8824.c index 08d0b8128fab..680f2b3a24f9 100644 --- a/sound/soc/intel/boards/cht_bsw_nau8824.c +++ b/sound/soc/intel/boards/cht_bsw_nau8824.c @@ -103,8 +103,8 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) { struct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card); struct snd_soc_jack *jack = &ctx->jack; - struct snd_soc_codec *codec = runtime->codec; struct snd_soc_dai *codec_dai = runtime->codec_dai; + struct snd_soc_component *component = codec_dai->component; int ret, jack_type; /* TDM 4 slots 24 bit, set Rx & Tx bitmask to 4 active slots */ @@ -134,7 +134,7 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP); snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); - nau8824_enable_jack_detect(codec, jack); + nau8824_enable_jack_detect(component, jack); return ret; } From 12af5004145a3fa53246cca4cbb2c57d18dde202 Mon Sep 17 00:00:00 2001 From: Abhijeet Kumar Date: Sun, 4 Mar 2018 01:16:39 +0530 Subject: [PATCH 079/102] ASoC: Intel: Skylake: Fix typo Spelling mistake in state. So fixing it. Signed-off-by: Abhijeet Kumar Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-messages.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/intel/skylake/skl-messages.c b/sound/soc/intel/skylake/skl-messages.c index 60d76adade43..f161907859f3 100644 --- a/sound/soc/intel/skylake/skl-messages.c +++ b/sound/soc/intel/skylake/skl-messages.c @@ -1210,7 +1210,7 @@ out: static int skl_set_pipe_state(struct skl_sst *ctx, struct skl_pipe *pipe, enum skl_ipc_pipeline_state state) { - dev_dbg(ctx->dev, "%s: pipe_satate = %d\n", __func__, state); + dev_dbg(ctx->dev, "%s: pipe_state = %d\n", __func__, state); return skl_ipc_set_pipeline_state(&ctx->ipc, pipe->ppl_id, state); } From 1cf5b50426136fe54380a7dd1ca7eb49973cae5a Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:35:49 +0100 Subject: [PATCH 080/102] ASoC: rt5651: Make rt5651_apply_properties() private The idea behind exporting rt5651_apply_properties(), was for it to be used on platforms where the platform code may need to add device-properties, rather then relying only on properties set by the firmware. The platform code could then call rt5651_apply_properties() after adding properties to make sure that the codec driver was aware of the new properties. But this is not necessary, as long as we do all property parsing from the codec component-driver's probe function (or later) then the machine driver can attach properties before calling snd_soc_register_card and calling rt5651_apply_properties() for ordering reasons is not necessary. This commit makes rt5651_apply_properties() private and adds 2 comments documenting that all property parsing must be done from the codec component-driver's probe function. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 14 ++++++++++++-- sound/soc/codecs/rt5651.h | 2 -- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 55bcc74e344f..767a05e009df 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1666,7 +1666,14 @@ static int rt5651_set_jack(struct snd_soc_component *component, return 0; } -void rt5651_apply_properties(struct snd_soc_component *component) +/* + * Note on some platforms the platform code may need to add device-properties, + * rather then relying only on properties set by the firmware. Therefor the + * property parsing MUST be done from the component driver's probe function, + * rather then from the i2c driver's probe function, so that the platform-code + * can attach extra properties before calling snd_soc_register_card(). + */ +static void rt5651_apply_properties(struct snd_soc_component *component) { if (device_property_read_bool(component->dev, "realtek,in2-differential")) snd_soc_component_update_bits(component, RT5651_IN1_IN2, @@ -1676,7 +1683,6 @@ void rt5651_apply_properties(struct snd_soc_component *component) snd_soc_component_update_bits(component, RT5651_GPIO_CTRL1, RT5651_GP2_PIN_MASK, RT5651_GP2_PIN_DMIC1_SCL); } -EXPORT_SYMBOL_GPL(rt5651_apply_properties); static int rt5651_probe(struct snd_soc_component *component) { @@ -1893,6 +1899,10 @@ static void rt5651_jack_detect_work(struct work_struct *work) snd_soc_jack_report(rt5651->hp_jack, report, SND_JACK_HEADSET); } +/* + * Note this function MUST not look at device-properties, see the comment + * above rt5651_apply_properties(). + */ static int rt5651_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { diff --git a/sound/soc/codecs/rt5651.h b/sound/soc/codecs/rt5651.h index 7d9d5fa09d6f..f3158488fc89 100644 --- a/sound/soc/codecs/rt5651.h +++ b/sound/soc/codecs/rt5651.h @@ -2080,6 +2080,4 @@ struct rt5651_priv { bool hp_mute; }; -void rt5651_apply_properties(struct snd_soc_component *component); - #endif /* __RT5651_H__ */ From 9db7d4b32cbccb5807e2e1f22e2fafc80034ee6d Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:35:50 +0100 Subject: [PATCH 081/102] ASoC: rt5651: Add devicetree-bindings for jack-detect Add new properties to the rt5651 dt-bindings for configuring the jack-detect source and over-current detect settings. Cc: devicetree@vger.kernel.org Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- .../devicetree/bindings/sound/rt5651.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/rt5651.txt b/Documentation/devicetree/bindings/sound/rt5651.txt index 3875233095f5..7890aa9477f8 100644 --- a/Documentation/devicetree/bindings/sound/rt5651.txt +++ b/Documentation/devicetree/bindings/sound/rt5651.txt @@ -16,6 +16,23 @@ Optional properties: - realtek,dmic-en Boolean. true if dmic is used. +- realtek,jack-detect-source + u32. Valid values: + 1: Use JD1_1 pin for jack-dectect + 2: Use JD1_2 pin for jack-dectect + 3: Use JD2 pin for jack-dectect + +- realtek,over-current-threshold-microamp + u32, micbias over-current detection threshold in µA, valid values are + 600, 1500 and 2000µA. + +- realtek,over-current-scale-factor + u32, micbias over-current detection scale-factor, valid values are: + 0: Scale current by 0.5 + 1: Scale current by 0.75 + 2: Scale current by 1.0 + 3: Scale current by 1.5 + Pins on the device (for linking into audio routes) for RT5651: * DMIC L1 From f0c2a330d99ef81519dc809d8b6a7dafe39b0933 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:35:51 +0100 Subject: [PATCH 082/102] ASoC: rt5651: Configure jack-detect source through a device-property Configure the jack-detect source through a device-property which can be set by code outside of the codec driver. Rather then putting platform specific DMI quirks inside the generic codec driver. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- include/sound/rt5651.h | 4 ++++ sound/soc/codecs/rt5651.c | 33 +++++++-------------------------- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/include/sound/rt5651.h b/include/sound/rt5651.h index 1612462bf5ad..725b36c329d0 100644 --- a/include/sound/rt5651.h +++ b/include/sound/rt5651.h @@ -11,6 +11,10 @@ #ifndef __LINUX_SND_RT5651_H #define __LINUX_SND_RT5651_H +/* + * Note these MUST match the values from the DT binding: + * Documentation/devicetree/bindings/sound/rt5651.txt + */ enum rt5651_jd_src { RT5651_JD_NULL, RT5651_JD1_1, diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 767a05e009df..50e1c501b6b9 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -32,8 +31,6 @@ #include "rl6231.h" #include "rt5651.h" -#define RT5651_JD_MAP(quirk) ((quirk) & GENMASK(7, 0)) - #define RT5651_DEVICE_ID_VALUE 0x6281 #define RT5651_PR_RANGE_BASE (0xff + 1) @@ -41,8 +38,6 @@ #define RT5651_PR_BASE (RT5651_PR_RANGE_BASE + (0 * RT5651_PR_SPACING)) -static unsigned long rt5651_quirk; - static const struct regmap_range_cfg rt5651_ranges[] = { { .name = "PR", .range_min = RT5651_PR_BASE, .range_max = RT5651_PR_BASE + 0xb4, @@ -1675,6 +1670,9 @@ static int rt5651_set_jack(struct snd_soc_component *component, */ static void rt5651_apply_properties(struct snd_soc_component *component) { + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); + u32 val; + if (device_property_read_bool(component->dev, "realtek,in2-differential")) snd_soc_component_update_bits(component, RT5651_IN1_IN2, RT5651_IN_DF2, RT5651_IN_DF2); @@ -1682,6 +1680,10 @@ static void rt5651_apply_properties(struct snd_soc_component *component) if (device_property_read_bool(component->dev, "realtek,dmic-en")) snd_soc_component_update_bits(component, RT5651_GPIO_CTRL1, RT5651_GP2_PIN_MASK, RT5651_GP2_PIN_DMIC1_SCL); + + if (device_property_read_u32(component->dev, + "realtek,jack-detect-source", &val) == 0) + rt5651->jd_src = val; } static int rt5651_probe(struct snd_soc_component *component) @@ -1831,24 +1833,6 @@ static const struct i2c_device_id rt5651_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, rt5651_i2c_id); -static int rt5651_quirk_cb(const struct dmi_system_id *id) -{ - rt5651_quirk = (unsigned long) id->driver_data; - return 1; -} - -static const struct dmi_system_id rt5651_quirk_table[] = { - { - .callback = rt5651_quirk_cb, - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "KIANO"), - DMI_MATCH(DMI_PRODUCT_NAME, "KIANO SlimNote 14.2"), - }, - .driver_data = (unsigned long *) RT5651_JD1_1, - }, - {} -}; - static int rt5651_jack_detect(struct snd_soc_component *component, int jack_insert) { int jack_type; @@ -1916,9 +1900,6 @@ static int rt5651_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, rt5651); - dmi_check_system(rt5651_quirk_table); - rt5651->jd_src = RT5651_JD_MAP(rt5651_quirk); - rt5651->regmap = devm_regmap_init_i2c(i2c, &rt5651_regmap); if (IS_ERR(rt5651->regmap)) { ret = PTR_ERR(rt5651->regmap); From 583a9debd71e21a317b1fc7b293c22c49b33d9e4 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:35:52 +0100 Subject: [PATCH 083/102] ASoC: rt5651: Allow specifying over-current threshold through a device-property OVer-Current-Detection (OVCD) for the micbias current is used to detect if an inserted jack is a headset or headphones (mic shorted to ground). Some boards may need different values for the OVCD current threshold because of a resistor on the board in serial with or parallel to the jack mic contact. This commit adds support for configuring the OCVD current threshold through the "realtek,over-current-threshold-microamp" device-property. Note this commit changes the default value from 600uA to 2000uA, because testing has shown 600uA to be a poor default. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 22 +++++++++++++++++++++- sound/soc/codecs/rt5651.h | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 50e1c501b6b9..7ff1bc892cfd 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1638,7 +1638,7 @@ static int rt5651_set_jack(struct snd_soc_component *component, RT5651_PWR_CLK12M_MASK | RT5651_PWR_MB_MASK, RT5651_MIC1_OVCD_EN | - RT5651_MIC1_OVTH_600UA | + rt5651->ovcd_th | RT5651_PWR_MB_PU | RT5651_PWR_CLK12M_PU); @@ -1684,6 +1684,26 @@ static void rt5651_apply_properties(struct snd_soc_component *component) if (device_property_read_u32(component->dev, "realtek,jack-detect-source", &val) == 0) rt5651->jd_src = val; + + rt5651->ovcd_th = RT5651_MIC1_OVTH_2000UA; + + if (device_property_read_u32(component->dev, + "realtek,over-current-threshold-microamp", &val) == 0) { + switch (val) { + case 600: + rt5651->ovcd_th = RT5651_MIC1_OVTH_600UA; + break; + case 1500: + rt5651->ovcd_th = RT5651_MIC1_OVTH_1500UA; + break; + case 2000: + rt5651->ovcd_th = RT5651_MIC1_OVTH_2000UA; + break; + default: + dev_warn(component->dev, "Warning: Invalid over-current-threshold-microamp value: %d, defaulting to 2000uA\n", + val); + } + } } static int rt5651_probe(struct snd_soc_component *component) diff --git a/sound/soc/codecs/rt5651.h b/sound/soc/codecs/rt5651.h index f3158488fc89..9cd5c279d0d6 100644 --- a/sound/soc/codecs/rt5651.h +++ b/sound/soc/codecs/rt5651.h @@ -2064,6 +2064,7 @@ struct rt5651_priv { struct snd_soc_jack *hp_jack; struct delayed_work jack_detect_work; enum rt5651_jd_src jd_src; + unsigned int ovcd_th; int irq; int sysclk; From e6eb0207597afa1cdd4914a17a727b101cc859ff Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:35:53 +0100 Subject: [PATCH 084/102] ASoC: rt5651: Allow specifying the OVCD scale-factor through a device-property OVer-Current-Detection (OVCD) for the micbias current is used to detect if an inserted jack is a headset or headphones (mic shorted to ground). The threshold for at which current the OVCD triggers on the rt5651 is not only controlled by setting the absolute current limit, but also by setting a scale factor which applies to the limit. Testing has shown that we need to set both (depending on the board). This commit adds support for the sofar unused OVCD scale-factor register and adds support for specifying non-default values for it through the "realtek,over-current-scale-factor" device-property. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- include/sound/rt5651.h | 11 +++++++++++ sound/soc/codecs/rt5651.c | 19 +++++++++++++++++++ sound/soc/codecs/rt5651.h | 11 +++++++++++ 3 files changed, 41 insertions(+) diff --git a/include/sound/rt5651.h b/include/sound/rt5651.h index 725b36c329d0..6403b862fb9a 100644 --- a/include/sound/rt5651.h +++ b/include/sound/rt5651.h @@ -22,4 +22,15 @@ enum rt5651_jd_src { RT5651_JD2, }; +/* + * Note these MUST match the values from the DT binding: + * Documentation/devicetree/bindings/sound/rt5651.txt + */ +enum rt5651_ovcd_sf { + RT5651_OVCD_SF_0P5, + RT5651_OVCD_SF_0P75, + RT5651_OVCD_SF_1P0, + RT5651_OVCD_SF_1P5, +}; + #endif diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 7ff1bc892cfd..486817809b7b 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1632,6 +1632,10 @@ static int rt5651_set_jack(struct snd_soc_component *component, snd_soc_component_update_bits(component, RT5651_PWR_ANLG2, RT5651_PWR_JD_M, RT5651_PWR_JD_M); + /* Set OVCD threshold current and scale-factor */ + snd_soc_component_write(component, RT5651_PR_BASE + RT5651_BIAS_CUR4, + 0xa800 | rt5651->ovcd_sf); + snd_soc_component_update_bits(component, RT5651_MICBIAS, RT5651_MIC1_OVCD_MASK | RT5651_MIC1_OVTH_MASK | @@ -1685,7 +1689,13 @@ static void rt5651_apply_properties(struct snd_soc_component *component) "realtek,jack-detect-source", &val) == 0) rt5651->jd_src = val; + /* + * Testing on various boards has shown that good defaults for the OVCD + * threshold and scale-factor are 2000µA and 0.75. For an effective + * limit of 1500µA, this seems to be more reliable then 1500µA and 1.0. + */ rt5651->ovcd_th = RT5651_MIC1_OVTH_2000UA; + rt5651->ovcd_sf = RT5651_MIC_OVCD_SF_0P75; if (device_property_read_u32(component->dev, "realtek,over-current-threshold-microamp", &val) == 0) { @@ -1704,6 +1714,15 @@ static void rt5651_apply_properties(struct snd_soc_component *component) val); } } + + if (device_property_read_u32(component->dev, + "realtek,over-current-scale-factor", &val) == 0) { + if (val <= RT5651_OVCD_SF_1P5) + rt5651->ovcd_sf = val << RT5651_MIC_OVCD_SF_SFT; + else + dev_warn(component->dev, "Warning: Invalid over-current-scale-factor value: %d, defaulting to 0.75\n", + val); + } } static int rt5651_probe(struct snd_soc_component *component) diff --git a/sound/soc/codecs/rt5651.h b/sound/soc/codecs/rt5651.h index 9cd5c279d0d6..71738ab93fb9 100644 --- a/sound/soc/codecs/rt5651.h +++ b/sound/soc/codecs/rt5651.h @@ -138,6 +138,7 @@ /* Index of Codec Private Register definition */ #define RT5651_BIAS_CUR1 0x12 #define RT5651_BIAS_CUR3 0x14 +#define RT5651_BIAS_CUR4 0x15 #define RT5651_CLSD_INT_REG1 0x1c #define RT5651_CHPUMP_INT_REG1 0x24 #define RT5651_MAMP_INT_REG2 0x37 @@ -1966,6 +1967,15 @@ #define RT5651_D_GATE_EN_SFT 0 /* Codec Private Register definition */ + +/* MIC Over current threshold scale factor (0x15) */ +#define RT5651_MIC_OVCD_SF_MASK (0x3 << 8) +#define RT5651_MIC_OVCD_SF_SFT 8 +#define RT5651_MIC_OVCD_SF_0P5 (0x0 << 8) +#define RT5651_MIC_OVCD_SF_0P75 (0x1 << 8) +#define RT5651_MIC_OVCD_SF_1P0 (0x2 << 8) +#define RT5651_MIC_OVCD_SF_1P5 (0x3 << 8) + /* 3D Speaker Control (0x63) */ #define RT5651_3D_SPK_MASK (0x1 << 15) #define RT5651_3D_SPK_SFT 15 @@ -2065,6 +2075,7 @@ struct rt5651_priv { struct delayed_work jack_detect_work; enum rt5651_jd_src jd_src; unsigned int ovcd_th; + unsigned int ovcd_sf; int irq; int sysclk; From 1b1ad83539a701a6bdcb25dc9160386e71f6016e Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:35:54 +0100 Subject: [PATCH 085/102] ASoC: rt5651: Enable sticky mode for OVCD When the mic-gnd contacts are short-circuited by a headphones plug, the hardware periodically retries if it can apply the bias-current leading to the OVCD status flip-flopping 1-0-1 with it being 0 about 10% of the time. This commit enables the sticky bit for the OVCD status to deal with this. This commit also introduces 2 helper functions to deal with the OVCD status bit, this may seem a bit overkill now, but these will also be used in future patches. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 486817809b7b..62918f7e8270 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1578,6 +1578,22 @@ static void rt5651_disable_micbias1_for_ovcd(struct snd_soc_component *component snd_soc_dapm_mutex_unlock(dapm); } +static void rt5651_clear_micbias1_ovcd(struct snd_soc_component *component) +{ + snd_soc_component_update_bits(component, RT5651_IRQ_CTRL2, + RT5651_MB1_OC_CLR, 0); +} + +static bool rt5651_micbias1_ovcd(struct snd_soc_component *component) +{ + int val; + + val = snd_soc_component_read32(component, RT5651_IRQ_CTRL2); + dev_dbg(component->dev, "irq ctrl2 %#04x\n", val); + + return (val & RT5651_MB1_OC_CLR); +} + static irqreturn_t rt5651_irq(int irq, void *data) { struct rt5651_priv *rt5651 = data; @@ -1646,6 +1662,18 @@ static int rt5651_set_jack(struct snd_soc_component *component, RT5651_PWR_MB_PU | RT5651_PWR_CLK12M_PU); + /* + * The over-current-detect is only reliable in detecting the absence + * of over-current, when the mic-contact in the jack is short-circuited, + * the hardware periodically retries if it can apply the bias-current + * leading to the ovcd status flip-flopping 1-0-1 with it being 0 about + * 10% of the time, as we poll the ovcd status bit we might hit that + * 10%, so we enable sticky mode and when checking OVCD we clear the + * status, msleep() a bit and then check to get a reliable reading. + */ + snd_soc_component_update_bits(component, RT5651_IRQ_CTRL2, + RT5651_MB1_OC_STKY_MASK, RT5651_MB1_OC_STKY_EN); + rt5651->hp_jack = hp_jack; ret = devm_request_threaded_irq(component->dev, rt5651->irq, NULL, @@ -1878,13 +1906,12 @@ static int rt5651_jack_detect(struct snd_soc_component *component, int jack_inse if (jack_insert) { rt5651_enable_micbias1_for_ovcd(component); + rt5651_clear_micbias1_ovcd(component); msleep(100); - if (snd_soc_component_read32(component, RT5651_IRQ_CTRL2) & RT5651_MB1_OC_CLR) + if (rt5651_micbias1_ovcd(component)) jack_type = SND_JACK_HEADPHONE; else jack_type = SND_JACK_HEADSET; - snd_soc_component_update_bits(component, RT5651_IRQ_CTRL2, - RT5651_MB1_OC_CLR, 0); rt5651_disable_micbias1_for_ovcd(component); } else { /* jack out */ jack_type = 0; From 4b4a373c0212e084045530e47071374a87a3761e Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:35:55 +0100 Subject: [PATCH 086/102] ASoC: rt5651: Enable Platform Clock during jack-type detect When using RCCLK instead of MCLK / PLL1 the OVCD status often gets stuck at its last value, which breaks jack-type detection. This commit fixes this by force-enabling the platform clock when doing jack-type detection. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 62918f7e8270..873af6798d7a 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1563,6 +1563,8 @@ static void rt5651_enable_micbias1_for_ovcd(struct snd_soc_component *component) snd_soc_dapm_mutex_lock(dapm); snd_soc_dapm_force_enable_pin_unlocked(dapm, "LDO"); snd_soc_dapm_force_enable_pin_unlocked(dapm, "micbias1"); + /* OVCD is unreliable when used with RCCLK as sysclk-source */ + snd_soc_dapm_force_enable_pin_unlocked(dapm, "Platform Clock"); snd_soc_dapm_sync_unlocked(dapm); snd_soc_dapm_mutex_unlock(dapm); } @@ -1572,6 +1574,7 @@ static void rt5651_disable_micbias1_for_ovcd(struct snd_soc_component *component struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); snd_soc_dapm_mutex_lock(dapm); + snd_soc_dapm_disable_pin_unlocked(dapm, "Platform Clock"); snd_soc_dapm_disable_pin_unlocked(dapm, "micbias1"); snd_soc_dapm_disable_pin_unlocked(dapm, "LDO"); snd_soc_dapm_sync_unlocked(dapm); From 0fe9474598890b4bd8a7228c9b1872ed7fe3c2c5 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:35:56 +0100 Subject: [PATCH 087/102] ASoC: rt5651: Add rt5651_jack_inserted() helper Add rt5651_jack_inserted() helper to get the jack-detect switch status, This is a preparation patch for rewriting the jack type-detection to make it more reliable. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 45 ++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 873af6798d7a..41fc574dbc3d 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1597,6 +1597,31 @@ static bool rt5651_micbias1_ovcd(struct snd_soc_component *component) return (val & RT5651_MB1_OC_CLR); } +static bool rt5651_jack_inserted(struct snd_soc_component *component) +{ + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); + int val; + + val = snd_soc_component_read32(component, RT5651_INT_IRQ_ST); + dev_dbg(component->dev, "irq status %#04x\n", val); + + switch (rt5651->jd_src) { + case RT5651_JD1_1: + val &= 0x1000; + break; + case RT5651_JD1_2: + val &= 0x2000; + break; + case RT5651_JD2: + val &= 0x4000; + break; + default: + break; + } + + return val == 0; +} + static irqreturn_t rt5651_irq(int irq, void *data) { struct rt5651_priv *rt5651 = data; @@ -1927,27 +1952,13 @@ static void rt5651_jack_detect_work(struct work_struct *work) { struct rt5651_priv *rt5651 = container_of(work, struct rt5651_priv, jack_detect_work.work); - - int report, val = 0; + int report, jack_inserted; if (!rt5651->component) return; - switch (rt5651->jd_src) { - case RT5651_JD1_1: - val = snd_soc_component_read32(rt5651->component, RT5651_INT_IRQ_ST) & 0x1000; - break; - case RT5651_JD1_2: - val = snd_soc_component_read32(rt5651->component, RT5651_INT_IRQ_ST) & 0x2000; - break; - case RT5651_JD2: - val = snd_soc_component_read32(rt5651->component, RT5651_INT_IRQ_ST) & 0x4000; - break; - default: - break; - } - - report = rt5651_jack_detect(rt5651->component, !val); + jack_inserted = rt5651_jack_inserted(rt5651->component); + report = rt5651_jack_detect(rt5651->component, jack_inserted); snd_soc_jack_report(rt5651->hp_jack, report, SND_JACK_HEADSET); } From ee68096826fa16bca2f7bb555b3e0cbbe798d330 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:35:57 +0100 Subject: [PATCH 088/102] ASoC: rt5651: Rewrite jack-type detection We get the insertion event before the jack is fully inserted at which point the second ring on a TRRS connector may short the 2nd ring and sleeve contacts. Testing has shown that this short-circuit may happen as late as 500ms after the insertion event, but it never lasts longer then 300ms. This commit changes the detection algorithm to require 5 identical OVCD values in a row at 100 ms intervals to fix the jack-type sometimes getting mis-detected. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 110 ++++++++++++++++++++++++-------------- sound/soc/codecs/rt5651.h | 2 +- 2 files changed, 70 insertions(+), 42 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 41fc574dbc3d..3b9f5384fe7d 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1622,12 +1622,76 @@ static bool rt5651_jack_inserted(struct snd_soc_component *component) return val == 0; } +/* Jack detect timings */ +#define JACK_SETTLE_TIME 100 /* milli seconds */ +#define JACK_DETECT_COUNT 5 +#define JACK_DETECT_MAXCOUNT 20 /* Aprox. 2 seconds worth of tries */ + +static int rt5651_detect_headset(struct snd_soc_component *component) +{ + int i, headset_count = 0, headphone_count = 0; + + /* + * We get the insertion event before the jack is fully inserted at which + * point the second ring on a TRRS connector may short the 2nd ring and + * sleeve contacts, also the overcurrent detection is not entirely + * reliable. So we try several times with a wait in between until we + * detect the same type JACK_DETECT_COUNT times in a row. + */ + for (i = 0; i < JACK_DETECT_MAXCOUNT; i++) { + /* Clear any previous over-current status flag */ + rt5651_clear_micbias1_ovcd(component); + + msleep(JACK_SETTLE_TIME); + + /* Check the jack is still connected before checking ovcd */ + if (!rt5651_jack_inserted(component)) + return 0; + + if (rt5651_micbias1_ovcd(component)) { + /* + * Over current detected, there is a short between the + * 2nd ring contact and the ground, so a TRS connector + * without a mic contact and thus plain headphones. + */ + dev_dbg(component->dev, "mic-gnd shorted\n"); + headset_count = 0; + headphone_count++; + if (headphone_count == JACK_DETECT_COUNT) + return SND_JACK_HEADPHONE; + } else { + dev_dbg(component->dev, "mic-gnd open\n"); + headphone_count = 0; + headset_count++; + if (headset_count == JACK_DETECT_COUNT) + return SND_JACK_HEADSET; + } + } + + dev_err(component->dev, "Error detecting headset vs headphones, bad contact?, assuming headphones\n"); + return SND_JACK_HEADPHONE; +} + +static void rt5651_jack_detect_work(struct work_struct *work) +{ + struct rt5651_priv *rt5651 = + container_of(work, struct rt5651_priv, jack_detect_work); + int report = 0; + + if (rt5651_jack_inserted(rt5651->component)) { + rt5651_enable_micbias1_for_ovcd(rt5651->component); + report = rt5651_detect_headset(rt5651->component); + rt5651_disable_micbias1_for_ovcd(rt5651->component); + } + + snd_soc_jack_report(rt5651->hp_jack, report, SND_JACK_HEADSET); +} + static irqreturn_t rt5651_irq(int irq, void *data) { struct rt5651_priv *rt5651 = data; - queue_delayed_work(system_power_efficient_wq, - &rt5651->jack_detect_work, msecs_to_jiffies(250)); + queue_work(system_power_efficient_wq, &rt5651->jack_detect_work); return IRQ_HANDLED; } @@ -1715,8 +1779,7 @@ static int rt5651_set_jack(struct snd_soc_component *component, } /* sync initial jack state */ - queue_delayed_work(system_power_efficient_wq, - &rt5651->jack_detect_work, 0); + queue_work(system_power_efficient_wq, &rt5651->jack_detect_work); return 0; } @@ -1928,41 +1991,6 @@ static const struct i2c_device_id rt5651_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, rt5651_i2c_id); -static int rt5651_jack_detect(struct snd_soc_component *component, int jack_insert) -{ - int jack_type; - - if (jack_insert) { - rt5651_enable_micbias1_for_ovcd(component); - rt5651_clear_micbias1_ovcd(component); - msleep(100); - if (rt5651_micbias1_ovcd(component)) - jack_type = SND_JACK_HEADPHONE; - else - jack_type = SND_JACK_HEADSET; - rt5651_disable_micbias1_for_ovcd(component); - } else { /* jack out */ - jack_type = 0; - } - - return jack_type; -} - -static void rt5651_jack_detect_work(struct work_struct *work) -{ - struct rt5651_priv *rt5651 = - container_of(work, struct rt5651_priv, jack_detect_work.work); - int report, jack_inserted; - - if (!rt5651->component) - return; - - jack_inserted = rt5651_jack_inserted(rt5651->component); - report = rt5651_jack_detect(rt5651->component, jack_inserted); - - snd_soc_jack_report(rt5651->hp_jack, report, SND_JACK_HEADSET); -} - /* * Note this function MUST not look at device-properties, see the comment * above rt5651_apply_properties(). @@ -2005,7 +2033,7 @@ static int rt5651_i2c_probe(struct i2c_client *i2c, rt5651->irq = i2c->irq; rt5651->hp_mute = 1; - INIT_DELAYED_WORK(&rt5651->jack_detect_work, rt5651_jack_detect_work); + INIT_WORK(&rt5651->jack_detect_work, rt5651_jack_detect_work); ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_rt5651, @@ -2018,7 +2046,7 @@ static int rt5651_i2c_remove(struct i2c_client *i2c) { struct rt5651_priv *rt5651 = i2c_get_clientdata(i2c); - cancel_delayed_work_sync(&rt5651->jack_detect_work); + cancel_work_sync(&rt5651->jack_detect_work); return 0; } diff --git a/sound/soc/codecs/rt5651.h b/sound/soc/codecs/rt5651.h index 71738ab93fb9..f20c9be94fb2 100644 --- a/sound/soc/codecs/rt5651.h +++ b/sound/soc/codecs/rt5651.h @@ -2072,7 +2072,7 @@ struct rt5651_priv { struct snd_soc_component *component; struct regmap *regmap; struct snd_soc_jack *hp_jack; - struct delayed_work jack_detect_work; + struct work_struct jack_detect_work; enum rt5651_jd_src jd_src; unsigned int ovcd_th; unsigned int ovcd_sf; From e39cacc1b7de2a6d72ce49043c9cfd7dd129135a Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:35:58 +0100 Subject: [PATCH 089/102] ASoC: Intel: bytcr_rt5651: Not being able to find the codec ACPI-dev is an error If we cannot find the codec ACPI-dev, then the snd-soc-core will not be able to find the codec either and snd_soc_register_card() will just keep exiting with -EPROBE_DEFER, filling the log with errors each time the probe gets retried. Instead simply log an error from the machine driver and exit with -ENODEV. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 456526a93dd5..105339c5b693 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -540,12 +540,13 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) /* fixup codec name based on HID */ i2c_name = acpi_dev_get_first_match_name(mach->id, NULL, -1); - if (i2c_name) { - snprintf(byt_rt5651_codec_name, sizeof(byt_rt5651_codec_name), - "%s%s", "i2c-", i2c_name); - - byt_rt5651_dais[dai_index].codec_name = byt_rt5651_codec_name; + if (!i2c_name) { + dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id); + return -ENODEV; } + snprintf(byt_rt5651_codec_name, sizeof(byt_rt5651_codec_name), + "%s%s", "i2c-", i2c_name); + byt_rt5651_dais[dai_index].codec_name = byt_rt5651_codec_name; /* check quirks before creating card */ dmi_check_system(byt_rt5651_quirk_table); From 46058aeb6b10ab6620caa25984a3a4ee37d0fd56 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:35:59 +0100 Subject: [PATCH 090/102] ASoC: Intel: bytcr_rt5651: Pass jack-src info via device-properties This commit add support for a new BYT_RT5651_JDSRC quirk, sets this quirk for the KIANO SlimNote 14.2 laptop and uses the new "realtek, jack-detect-source" property to pass this info to the codec driver. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 54 +++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 6288c27d87ce..499e405e591b 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -18,8 +18,10 @@ */ #include +#include #include #include +#include #include #include #include @@ -42,10 +44,21 @@ enum { BYT_RT5651_IN3_MAP, }; -#define BYT_RT5651_MAP(quirk) ((quirk) & GENMASK(7, 0)) -#define BYT_RT5651_DMIC_EN BIT(16) -#define BYT_RT5651_MCLK_EN BIT(17) -#define BYT_RT5651_MCLK_25MHZ BIT(18) +enum { + BYT_RT5651_JD_NULL = (RT5651_JD_NULL << 4), + BYT_RT5651_JD1_1 = (RT5651_JD1_1 << 4), + BYT_RT5651_JD1_2 = (RT5651_JD1_2 << 4), + BYT_RT5651_JD2 = (RT5651_JD2 << 4), +}; + +#define BYT_RT5651_MAP(quirk) ((quirk) & GENMASK(3, 0)) +#define BYT_RT5651_JDSRC(quirk) (((quirk) & GENMASK(7, 4)) >> 4) +#define BYT_RT5651_DMIC_EN BIT(16) +#define BYT_RT5651_MCLK_EN BIT(17) +#define BYT_RT5651_MCLK_25MHZ BIT(18) + +/* jack-detect-source + terminating empty entry */ +#define MAX_NO_PROPS 2 struct byt_rt5651_private { struct clk *mclk; @@ -66,6 +79,9 @@ static void log_quirks(struct device *dev) dev_info(dev, "quirk IN2_MAP enabled"); if (BYT_RT5651_MAP(byt_rt5651_quirk) == BYT_RT5651_IN3_MAP) dev_info(dev, "quirk IN3_MAP enabled"); + if (BYT_RT5651_JDSRC(byt_rt5651_quirk)) + dev_info(dev, "quirk realtek,jack-detect-source %ld\n", + BYT_RT5651_JDSRC(byt_rt5651_quirk)); if (byt_rt5651_quirk & BYT_RT5651_DMIC_EN) dev_info(dev, "quirk DMIC enabled"); if (byt_rt5651_quirk & BYT_RT5651_MCLK_EN) @@ -288,11 +304,35 @@ static const struct dmi_system_id byt_rt5651_quirk_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "KIANO SlimNote 14.2"), }, .driver_data = (void *)(BYT_RT5651_MCLK_EN | + BYT_RT5651_JD1_1 | BYT_RT5651_IN1_IN2_MAP), }, {} }; +/* + * Note this MUST be called before snd_soc_register_card(), so that the props + * are in place before the codec component driver's probe function parses them. + */ +static int byt_rt5651_add_codec_device_props(const char *i2c_dev_name) +{ + struct property_entry props[MAX_NO_PROPS] = {}; + struct device *i2c_dev; + int ret, cnt = 0; + + i2c_dev = bus_find_device_by_name(&i2c_bus_type, NULL, i2c_dev_name); + if (!i2c_dev) + return -EPROBE_DEFER; + + props[cnt++] = PROPERTY_ENTRY_U32("realtek,jack-detect-source", + BYT_RT5651_JDSRC(byt_rt5651_quirk)); + + ret = device_add_properties(i2c_dev, props); + put_device(i2c_dev); + + return ret; +} + static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) { struct snd_soc_card *card = runtime->card; @@ -550,6 +590,12 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) /* check quirks before creating card */ dmi_check_system(byt_rt5651_quirk_table); + + /* Must be called before register_card, also see declaration comment. */ + ret_val = byt_rt5651_add_codec_device_props(byt_rt5651_codec_name); + if (ret_val) + return ret_val; + log_quirks(&pdev->dev); if (byt_rt5651_quirk & BYT_RT5651_MCLK_EN) { From c2f26938d2a456dcf429385617e58cfd510a64a8 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:36:00 +0100 Subject: [PATCH 091/102] ASoC: Intel: bytcr_rt5651: Actually honor the DMIC_EN quirk if specified Before this commit it was possible to set the DMIC_EN quirk in the machine driver, but it would never be passed to the codec driver so it was a nop. This commit adds code to actually pass the quirk to the codec driver. Since the DMIC_EN quirk was ignored before, this commit removes it from the default quirk settings, to avoid this causing an unexpected functional change. If we really want the DMIC_EN behavior anywhere it should be specifically enabled by follow up commits. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 499e405e591b..a874bba3aec0 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -57,8 +57,8 @@ enum { #define BYT_RT5651_MCLK_EN BIT(17) #define BYT_RT5651_MCLK_25MHZ BIT(18) -/* jack-detect-source + terminating empty entry */ -#define MAX_NO_PROPS 2 +/* jack-detect-source + dmic-en + terminating empty entry */ +#define MAX_NO_PROPS 3 struct byt_rt5651_private { struct clk *mclk; @@ -66,7 +66,6 @@ struct byt_rt5651_private { }; static unsigned long byt_rt5651_quirk = BYT_RT5651_DMIC_MAP | - BYT_RT5651_DMIC_EN | BYT_RT5651_MCLK_EN; static void log_quirks(struct device *dev) @@ -327,6 +326,9 @@ static int byt_rt5651_add_codec_device_props(const char *i2c_dev_name) props[cnt++] = PROPERTY_ENTRY_U32("realtek,jack-detect-source", BYT_RT5651_JDSRC(byt_rt5651_quirk)); + if (byt_rt5651_quirk & BYT_RT5651_DMIC_EN) + props[cnt++] = PROPERTY_ENTRY_BOOL("realtek,dmic-en"); + ret = device_add_properties(i2c_dev, props); put_device(i2c_dev); From aed859a2c7ac8c44ba9b3a6f82b5f08da8a0a975 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:36:01 +0100 Subject: [PATCH 092/102] ASoC: Intel: bytcr_rt5651: Only create jack if we have a jack-detect source Only create the jack if we have a valid jack-detect source and properly check the snd_soc_component_set_jack() return value. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index a874bba3aec0..56f1f076d92c 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -404,17 +404,21 @@ static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) dev_err(card->dev, "unable to set MCLK rate\n"); } - ret = snd_soc_card_jack_new(runtime->card, "Headset", + if (BYT_RT5651_JDSRC(byt_rt5651_quirk)) { + ret = snd_soc_card_jack_new(runtime->card, "Headset", SND_JACK_HEADSET, &priv->jack, bytcr_jack_pins, ARRAY_SIZE(bytcr_jack_pins)); - if (ret) { - dev_err(runtime->dev, "Headset jack creation failed %d\n", ret); - return ret; + if (ret) { + dev_err(runtime->dev, "jack creation failed %d\n", ret); + return ret; + } + + ret = snd_soc_component_set_jack(codec, &priv->jack, NULL); + if (ret) + return ret; } - snd_soc_component_set_jack(codec, &priv->jack, NULL); - - return ret; + return 0; } static const struct snd_soc_pcm_stream byt_rt5651_dai_params = { From 8ffaa6a136e6f30e053e78fb9742c7748bef8576 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:36:02 +0100 Subject: [PATCH 093/102] ASoC: Intel: bytcr_rt5651: Add quirk micbias OVCD configuration Add support for setting the micbias OVCD limits device-properties through quirks. And set the limits for this to 2000uA with a scale-factor of 0.75 for the KIANO SlimNote 14.2 device, which is the only device on which jack-detection is currently enabled. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 34 ++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 56f1f076d92c..91b5841af622 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -51,14 +51,29 @@ enum { BYT_RT5651_JD2 = (RT5651_JD2 << 4), }; +enum { + BYT_RT5651_OVCD_TH_600UA = (6 << 8), + BYT_RT5651_OVCD_TH_1500UA = (15 << 8), + BYT_RT5651_OVCD_TH_2000UA = (20 << 8), +}; + +enum { + BYT_RT5651_OVCD_SF_0P5 = (RT5651_OVCD_SF_0P5 << 13), + BYT_RT5651_OVCD_SF_0P75 = (RT5651_OVCD_SF_0P75 << 13), + BYT_RT5651_OVCD_SF_1P0 = (RT5651_OVCD_SF_1P0 << 13), + BYT_RT5651_OVCD_SF_1P5 = (RT5651_OVCD_SF_1P5 << 13), +}; + #define BYT_RT5651_MAP(quirk) ((quirk) & GENMASK(3, 0)) #define BYT_RT5651_JDSRC(quirk) (((quirk) & GENMASK(7, 4)) >> 4) +#define BYT_RT5651_OVCD_TH(quirk) (((quirk) & GENMASK(12, 8)) >> 8) +#define BYT_RT5651_OVCD_SF(quirk) (((quirk) & GENMASK(14, 13)) >> 13) #define BYT_RT5651_DMIC_EN BIT(16) #define BYT_RT5651_MCLK_EN BIT(17) #define BYT_RT5651_MCLK_25MHZ BIT(18) -/* jack-detect-source + dmic-en + terminating empty entry */ -#define MAX_NO_PROPS 3 +/* jack-detect-source + dmic-en + ovcd-th + -sf + terminating empty entry */ +#define MAX_NO_PROPS 5 struct byt_rt5651_private { struct clk *mclk; @@ -78,9 +93,14 @@ static void log_quirks(struct device *dev) dev_info(dev, "quirk IN2_MAP enabled"); if (BYT_RT5651_MAP(byt_rt5651_quirk) == BYT_RT5651_IN3_MAP) dev_info(dev, "quirk IN3_MAP enabled"); - if (BYT_RT5651_JDSRC(byt_rt5651_quirk)) + if (BYT_RT5651_JDSRC(byt_rt5651_quirk)) { dev_info(dev, "quirk realtek,jack-detect-source %ld\n", BYT_RT5651_JDSRC(byt_rt5651_quirk)); + dev_info(dev, "quirk realtek,over-current-threshold-microamp %ld\n", + BYT_RT5651_OVCD_TH(byt_rt5651_quirk) * 100); + dev_info(dev, "quirk realtek,over-current-scale-factor %ld\n", + BYT_RT5651_OVCD_SF(byt_rt5651_quirk)); + } if (byt_rt5651_quirk & BYT_RT5651_DMIC_EN) dev_info(dev, "quirk DMIC enabled"); if (byt_rt5651_quirk & BYT_RT5651_MCLK_EN) @@ -304,6 +324,8 @@ static const struct dmi_system_id byt_rt5651_quirk_table[] = { }, .driver_data = (void *)(BYT_RT5651_MCLK_EN | BYT_RT5651_JD1_1 | + BYT_RT5651_OVCD_TH_2000UA | + BYT_RT5651_OVCD_SF_0P75 | BYT_RT5651_IN1_IN2_MAP), }, {} @@ -326,6 +348,12 @@ static int byt_rt5651_add_codec_device_props(const char *i2c_dev_name) props[cnt++] = PROPERTY_ENTRY_U32("realtek,jack-detect-source", BYT_RT5651_JDSRC(byt_rt5651_quirk)); + props[cnt++] = PROPERTY_ENTRY_U32("realtek,over-current-threshold-microamp", + BYT_RT5651_OVCD_TH(byt_rt5651_quirk) * 100); + + props[cnt++] = PROPERTY_ENTRY_U32("realtek,over-current-scale-factor", + BYT_RT5651_OVCD_SF(byt_rt5651_quirk)); + if (byt_rt5651_quirk & BYT_RT5651_DMIC_EN) props[cnt++] = PROPERTY_ENTRY_BOOL("realtek,dmic-en"); From aeec6cc0821573920d559f7d6297ea5dd3fbbd17 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:36:03 +0100 Subject: [PATCH 094/102] ASoC: Intel: bytcr_rt5651: Configure PLL1 before using it When platform_clock_control() first selects PLL1 as sysclk the PLL_CTRL registers have not been setup yet and we effectively have an invalid clock configuration until byt_rt5651_aif1_hw_params() gets called. Add a new byt_rt5651_prepare_and_enable_pll1() helper and use that from both platform_clock_control() and byt_rt5651_aif1_hw_params() to fix this. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 73 +++++++++++++-------------- 1 file changed, 35 insertions(+), 38 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 91b5841af622..af30c730f432 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -111,6 +111,38 @@ static void log_quirks(struct device *dev) #define BYT_CODEC_DAI1 "rt5651-aif1" +static int byt_rt5651_prepare_and_enable_pll1(struct snd_soc_dai *codec_dai, + int rate, int bclk_ratio) +{ + int clk_id, clk_freq, ret; + + /* Configure the PLL before selecting it */ + if (!(byt_rt5651_quirk & BYT_RT5651_MCLK_EN)) { + clk_id = RT5651_PLL1_S_BCLK1, + clk_freq = rate * bclk_ratio; + } else { + clk_id = RT5651_PLL1_S_MCLK; + if (byt_rt5651_quirk & BYT_RT5651_MCLK_25MHZ) + clk_freq = 25000000; + else + clk_freq = 19200000; + } + ret = snd_soc_dai_set_pll(codec_dai, 0, clk_id, clk_freq, rate * 512); + if (ret < 0) { + dev_err(codec_dai->codec->dev, "can't set pll: %d\n", ret); + return ret; + } + + ret = snd_soc_dai_set_sysclk(codec_dai, RT5651_SCLK_S_PLL1, + rate * 512, SND_SOC_CLOCK_IN); + if (ret < 0) { + dev_err(codec_dai->codec->dev, "can't set clock %d\n", ret); + return ret; + } + + return 0; +} + static int platform_clock_control(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, int event) { @@ -136,9 +168,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w, return ret; } } - ret = snd_soc_dai_set_sysclk(codec_dai, RT5651_SCLK_S_PLL1, - 48000 * 512, - SND_SOC_CLOCK_IN); + ret = byt_rt5651_prepare_and_enable_pll1(codec_dai, 48000, 50); } else { /* * Set codec clock source to internal clock before @@ -252,44 +282,11 @@ static int byt_rt5651_aif1_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; - int ret; + int rate = params_rate(params); snd_soc_dai_set_bclk_ratio(codec_dai, 50); - ret = snd_soc_dai_set_sysclk(codec_dai, RT5651_SCLK_S_PLL1, - params_rate(params) * 512, - SND_SOC_CLOCK_IN); - if (ret < 0) { - dev_err(rtd->dev, "can't set codec clock %d\n", ret); - return ret; - } - - if (!(byt_rt5651_quirk & BYT_RT5651_MCLK_EN)) { - /* 2x25 bit slots on SSP2 */ - ret = snd_soc_dai_set_pll(codec_dai, 0, - RT5651_PLL1_S_BCLK1, - params_rate(params) * 50, - params_rate(params) * 512); - } else { - if (byt_rt5651_quirk & BYT_RT5651_MCLK_25MHZ) { - ret = snd_soc_dai_set_pll(codec_dai, 0, - RT5651_PLL1_S_MCLK, - 25000000, - params_rate(params) * 512); - } else { - ret = snd_soc_dai_set_pll(codec_dai, 0, - RT5651_PLL1_S_MCLK, - 19200000, - params_rate(params) * 512); - } - } - - if (ret < 0) { - dev_err(rtd->dev, "can't set codec pll: %d\n", ret); - return ret; - } - - return 0; + return byt_rt5651_prepare_and_enable_pll1(codec_dai, rate, 50); } static int byt_rt5651_quirk_cb(const struct dmi_system_id *id) From 3fdae070e6fcd9f9ca0745fd69d40085625a45f5 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:36:04 +0100 Subject: [PATCH 095/102] ASoC: Intel: bytcr_rt5651: Drop snd_soc_dai_set_bclk_ratio() call Drop the snd_soc_dai_set_bclk_ratio() call, the rt5651 dai does not have a set_bclk_ratio() op, so it is a nop (and returns -EINVAL). Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index af30c730f432..1c771930772d 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -284,8 +284,6 @@ static int byt_rt5651_aif1_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *codec_dai = rtd->codec_dai; int rate = params_rate(params); - snd_soc_dai_set_bclk_ratio(codec_dai, 50); - return byt_rt5651_prepare_and_enable_pll1(codec_dai, rate, 50); } From 7f2e2299cf169d8c517fbe2bcff3ca7bc8fa5f5c Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:36:05 +0100 Subject: [PATCH 096/102] ASoC: Intel: bytcr_rt5651: Rename IN3_MAP to IN1_HS_IN3_MAP All the mappings are named for where the internal mic is routed and in that sense the newly added in3_map really is the same as in1_map, what makes it different is that it maps the headset mic at IN3 rather then at IN2. Rename in3_map to in1_hs_in3_map to better reflect what it actually does. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 1c771930772d..7d5764d23c51 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -41,7 +41,7 @@ enum { BYT_RT5651_IN1_MAP, BYT_RT5651_IN2_MAP, BYT_RT5651_IN1_IN2_MAP, - BYT_RT5651_IN3_MAP, + BYT_RT5651_IN1_HS_IN3_MAP, }; enum { @@ -91,8 +91,8 @@ static void log_quirks(struct device *dev) dev_info(dev, "quirk IN1_MAP enabled"); if (BYT_RT5651_MAP(byt_rt5651_quirk) == BYT_RT5651_IN2_MAP) dev_info(dev, "quirk IN2_MAP enabled"); - if (BYT_RT5651_MAP(byt_rt5651_quirk) == BYT_RT5651_IN3_MAP) - dev_info(dev, "quirk IN3_MAP enabled"); + if (BYT_RT5651_MAP(byt_rt5651_quirk) == BYT_RT5651_IN1_HS_IN3_MAP) + dev_info(dev, "quirk IN1_HS_IN3_MAP enabled"); if (BYT_RT5651_JDSRC(byt_rt5651_quirk)) { dev_info(dev, "quirk realtek,jack-detect-source %ld\n", BYT_RT5651_JDSRC(byt_rt5651_quirk)); @@ -235,8 +235,8 @@ static const struct snd_soc_dapm_route byt_rt5651_intmic_dmic_map[] = { static const struct snd_soc_dapm_route byt_rt5651_intmic_in1_map[] = { {"Internal Mic", NULL, "micbias1"}, - {"IN2P", NULL, "Headset Mic"}, {"IN1P", NULL, "Internal Mic"}, + {"IN2P", NULL, "Headset Mic"}, }; static const struct snd_soc_dapm_route byt_rt5651_intmic_in2_map[] = { @@ -252,10 +252,10 @@ static const struct snd_soc_dapm_route byt_rt5651_intmic_in1_in2_map[] = { {"IN3P", NULL, "Headset Mic"}, }; -static const struct snd_soc_dapm_route byt_rt5651_intmic_in3_map[] = { +static const struct snd_soc_dapm_route byt_rt5651_intmic_in1_hs_in3_map[] = { {"Internal Mic", NULL, "micbias1"}, - {"IN3P", NULL, "Headset Mic"}, {"IN1P", NULL, "Internal Mic"}, + {"IN3P", NULL, "Headset Mic"}, }; static const struct snd_kcontrol_new byt_rt5651_controls[] = { @@ -300,7 +300,7 @@ static const struct dmi_system_id byt_rt5651_quirk_table[] = { DMI_MATCH(DMI_SYS_VENDOR, "Circuitco"), DMI_MATCH(DMI_PRODUCT_NAME, "Minnowboard Max B3 PLATFORM"), }, - .driver_data = (void *)(BYT_RT5651_IN3_MAP), + .driver_data = (void *)(BYT_RT5651_IN1_HS_IN3_MAP), }, { .callback = byt_rt5651_quirk_cb, @@ -309,7 +309,7 @@ static const struct dmi_system_id byt_rt5651_quirk_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "Minnowboard Turbot"), }, .driver_data = (void *)(BYT_RT5651_MCLK_EN | - BYT_RT5651_IN3_MAP), + BYT_RT5651_IN1_HS_IN3_MAP), }, { .callback = byt_rt5651_quirk_cb, @@ -382,9 +382,9 @@ static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) custom_map = byt_rt5651_intmic_in1_in2_map; num_routes = ARRAY_SIZE(byt_rt5651_intmic_in1_in2_map); break; - case BYT_RT5651_IN3_MAP: - custom_map = byt_rt5651_intmic_in3_map; - num_routes = ARRAY_SIZE(byt_rt5651_intmic_in3_map); + case BYT_RT5651_IN1_HS_IN3_MAP: + custom_map = byt_rt5651_intmic_in1_hs_in3_map; + num_routes = ARRAY_SIZE(byt_rt5651_intmic_in1_hs_in3_map); break; default: custom_map = byt_rt5651_intmic_dmic_map; From f026e06317804f305d4665d266191e07e2bf6394 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:36:06 +0100 Subject: [PATCH 097/102] ASoC: Intel: bytcr_rt5651: Add new IN2_HS_IN3 input map and a quirk using it Add a new IN2_HS_IN3 input map and add a quirk for the input mapping and jack-detect source for the Chuwi Vi8 Plus tablet, which uses this new map. Note the Chuwi Vi8 Plus lists an extra GPIO in its codecs ACPI resources which needs to be driven high to enable the external speaker amplifier, this is not supported yet and will be fixed in a future patch. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 7d5764d23c51..b798ebb18bf1 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -42,6 +42,7 @@ enum { BYT_RT5651_IN2_MAP, BYT_RT5651_IN1_IN2_MAP, BYT_RT5651_IN1_HS_IN3_MAP, + BYT_RT5651_IN2_HS_IN3_MAP, }; enum { @@ -93,6 +94,8 @@ static void log_quirks(struct device *dev) dev_info(dev, "quirk IN2_MAP enabled"); if (BYT_RT5651_MAP(byt_rt5651_quirk) == BYT_RT5651_IN1_HS_IN3_MAP) dev_info(dev, "quirk IN1_HS_IN3_MAP enabled"); + if (BYT_RT5651_MAP(byt_rt5651_quirk) == BYT_RT5651_IN2_HS_IN3_MAP) + dev_info(dev, "quirk IN2_HS_IN3_MAP enabled"); if (BYT_RT5651_JDSRC(byt_rt5651_quirk)) { dev_info(dev, "quirk realtek,jack-detect-source %ld\n", BYT_RT5651_JDSRC(byt_rt5651_quirk)); @@ -258,6 +261,12 @@ static const struct snd_soc_dapm_route byt_rt5651_intmic_in1_hs_in3_map[] = { {"IN3P", NULL, "Headset Mic"}, }; +static const struct snd_soc_dapm_route byt_rt5651_intmic_in2_hs_in3_map[] = { + {"Internal Mic", NULL, "micbias1"}, + {"IN2P", NULL, "Internal Mic"}, + {"IN3P", NULL, "Headset Mic"}, +}; + static const struct snd_kcontrol_new byt_rt5651_controls[] = { SOC_DAPM_PIN_SWITCH("Headphone"), SOC_DAPM_PIN_SWITCH("Headset Mic"), @@ -323,6 +332,19 @@ static const struct dmi_system_id byt_rt5651_quirk_table[] = { BYT_RT5651_OVCD_SF_0P75 | BYT_RT5651_IN1_IN2_MAP), }, + { + /* Chuwi Vi8 Plus (CWI519) */ + .callback = byt_rt5651_quirk_cb, + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Hampoo"), + DMI_MATCH(DMI_PRODUCT_NAME, "D2D3_Vi8A1"), + }, + .driver_data = (void *)(BYT_RT5651_MCLK_EN | + BYT_RT5651_JD1_1 | + BYT_RT5651_OVCD_TH_2000UA | + BYT_RT5651_OVCD_SF_0P75 | + BYT_RT5651_IN2_HS_IN3_MAP), + }, {} }; @@ -386,6 +408,10 @@ static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) custom_map = byt_rt5651_intmic_in1_hs_in3_map; num_routes = ARRAY_SIZE(byt_rt5651_intmic_in1_hs_in3_map); break; + case BYT_RT5651_IN2_HS_IN3_MAP: + custom_map = byt_rt5651_intmic_in2_hs_in3_map; + num_routes = ARRAY_SIZE(byt_rt5651_intmic_in2_hs_in3_map); + break; default: custom_map = byt_rt5651_intmic_dmic_map; num_routes = ARRAY_SIZE(byt_rt5651_intmic_dmic_map); From 8a880a2014e3ab50e66252335bd71d61b0487a30 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:36:07 +0100 Subject: [PATCH 098/102] ASoC: Intel: bytcr_rt5651: Add support for Bay Trail CR / SSP0 using boards Despite its name being prefixed with bytcr, before this commit the bytcr_rt5651 machine driver could not work with Bay Trail CR boards, as those only have SSP0 and it only supported SSP0-AIF1 setups. This commit adds support for this, autodetecting AIF1 vs AIF2 based on BIOS tables. While at it also add support for SSP2-AIF2 setups, as that requires only minimal extra code on top of the code adding SSP0-AIF1 / SSP0-AIF2 support. Note this code is all copy-pasted from bytcr_rt5640.c. I've looked into merging the 2 machine drivers into 1 to avoid copy-pasting, but there are enough subtile differences to make this hard *and* with all the quirks the machine driver already is full with if (variant-foo) then ... else ... constructs adding more of these is going to make the code unreadable. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 217 ++++++++++++++++++++++++-- 1 file changed, 201 insertions(+), 16 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index b798ebb18bf1..103c4b0e6505 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -72,6 +73,9 @@ enum { #define BYT_RT5651_DMIC_EN BIT(16) #define BYT_RT5651_MCLK_EN BIT(17) #define BYT_RT5651_MCLK_25MHZ BIT(18) +#define BYT_RT5651_SSP2_AIF2 BIT(19) /* default is using AIF1 */ +#define BYT_RT5651_SSP0_AIF1 BIT(20) +#define BYT_RT5651_SSP0_AIF2 BIT(21) /* jack-detect-source + dmic-en + ovcd-th + -sf + terminating empty entry */ #define MAX_NO_PROPS 5 @@ -81,8 +85,7 @@ struct byt_rt5651_private { struct snd_soc_jack jack; }; -static unsigned long byt_rt5651_quirk = BYT_RT5651_DMIC_MAP | - BYT_RT5651_MCLK_EN; +static unsigned long byt_rt5651_quirk = BYT_RT5651_MCLK_EN; static void log_quirks(struct device *dev) { @@ -110,9 +113,16 @@ static void log_quirks(struct device *dev) dev_info(dev, "quirk MCLK_EN enabled"); if (byt_rt5651_quirk & BYT_RT5651_MCLK_25MHZ) dev_info(dev, "quirk MCLK_25MHZ enabled"); + if (byt_rt5651_quirk & BYT_RT5651_SSP2_AIF2) + dev_info(dev, "quirk SSP2_AIF2 enabled\n"); + if (byt_rt5651_quirk & BYT_RT5651_SSP0_AIF1) + dev_info(dev, "quirk SSP0_AIF1 enabled\n"); + if (byt_rt5651_quirk & BYT_RT5651_SSP0_AIF2) + dev_info(dev, "quirk SSP0_AIF2 enabled\n"); } #define BYT_CODEC_DAI1 "rt5651-aif1" +#define BYT_CODEC_DAI2 "rt5651-aif2" static int byt_rt5651_prepare_and_enable_pll1(struct snd_soc_dai *codec_dai, int rate, int bclk_ratio) @@ -156,6 +166,8 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w, int ret; codec_dai = snd_soc_card_get_codec_dai(card, BYT_CODEC_DAI1); + if (!codec_dai) + codec_dai = snd_soc_card_get_codec_dai(card, BYT_CODEC_DAI2); if (!codec_dai) { dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n"); @@ -213,13 +225,6 @@ static const struct snd_soc_dapm_route byt_rt5651_audio_map[] = { {"Speaker", NULL, "Platform Clock"}, {"Line In", NULL, "Platform Clock"}, - {"AIF1 Playback", NULL, "ssp2 Tx"}, - {"ssp2 Tx", NULL, "codec_out0"}, - {"ssp2 Tx", NULL, "codec_out1"}, - {"codec_in0", NULL, "ssp2 Rx"}, - {"codec_in1", NULL, "ssp2 Rx"}, - {"ssp2 Rx", NULL, "AIF1 Capture"}, - {"Headset Mic", NULL, "micbias1"}, /* lowercase for rt5651 */ {"Headphone", NULL, "HPOL"}, {"Headphone", NULL, "HPOR"}, @@ -267,6 +272,42 @@ static const struct snd_soc_dapm_route byt_rt5651_intmic_in2_hs_in3_map[] = { {"IN3P", NULL, "Headset Mic"}, }; +static const struct snd_soc_dapm_route byt_rt5651_ssp0_aif1_map[] = { + {"ssp0 Tx", NULL, "modem_out"}, + {"modem_in", NULL, "ssp0 Rx"}, + + {"AIF1 Playback", NULL, "ssp0 Tx"}, + {"ssp0 Rx", NULL, "AIF1 Capture"}, +}; + +static const struct snd_soc_dapm_route byt_rt5651_ssp0_aif2_map[] = { + {"ssp0 Tx", NULL, "modem_out"}, + {"modem_in", NULL, "ssp0 Rx"}, + + {"AIF2 Playback", NULL, "ssp0 Tx"}, + {"ssp0 Rx", NULL, "AIF2 Capture"}, +}; + +static const struct snd_soc_dapm_route byt_rt5651_ssp2_aif1_map[] = { + {"ssp2 Tx", NULL, "codec_out0"}, + {"ssp2 Tx", NULL, "codec_out1"}, + {"codec_in0", NULL, "ssp2 Rx"}, + {"codec_in1", NULL, "ssp2 Rx"}, + + {"AIF1 Playback", NULL, "ssp2 Tx"}, + {"ssp2 Rx", NULL, "AIF1 Capture"}, +}; + +static const struct snd_soc_dapm_route byt_rt5651_ssp2_aif2_map[] = { + {"ssp2 Tx", NULL, "codec_out0"}, + {"ssp2 Tx", NULL, "codec_out1"}, + {"codec_in0", NULL, "ssp2 Rx"}, + {"codec_in1", NULL, "ssp2 Rx"}, + + {"AIF2 Playback", NULL, "ssp2 Tx"}, + {"ssp2 Rx", NULL, "AIF2 Capture"}, +}; + static const struct snd_kcontrol_new byt_rt5651_controls[] = { SOC_DAPM_PIN_SWITCH("Headphone"), SOC_DAPM_PIN_SWITCH("Headset Mic"), @@ -291,9 +332,16 @@ static int byt_rt5651_aif1_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; + snd_pcm_format_t format = params_format(params); int rate = params_rate(params); + int bclk_ratio; - return byt_rt5651_prepare_and_enable_pll1(codec_dai, rate, 50); + if (format == SNDRV_PCM_FORMAT_S16_LE) + bclk_ratio = 32; + else + bclk_ratio = 50; + + return byt_rt5651_prepare_and_enable_pll1(codec_dai, rate, bclk_ratio); } static int byt_rt5651_quirk_cb(const struct dmi_system_id *id) @@ -420,6 +468,26 @@ static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) if (ret) return ret; + if (byt_rt5651_quirk & BYT_RT5651_SSP2_AIF2) { + ret = snd_soc_dapm_add_routes(&card->dapm, + byt_rt5651_ssp2_aif2_map, + ARRAY_SIZE(byt_rt5651_ssp2_aif2_map)); + } else if (byt_rt5651_quirk & BYT_RT5651_SSP0_AIF1) { + ret = snd_soc_dapm_add_routes(&card->dapm, + byt_rt5651_ssp0_aif1_map, + ARRAY_SIZE(byt_rt5651_ssp0_aif1_map)); + } else if (byt_rt5651_quirk & BYT_RT5651_SSP0_AIF2) { + ret = snd_soc_dapm_add_routes(&card->dapm, + byt_rt5651_ssp0_aif2_map, + ARRAY_SIZE(byt_rt5651_ssp0_aif2_map)); + } else { + ret = snd_soc_dapm_add_routes(&card->dapm, + byt_rt5651_ssp2_aif1_map, + ARRAY_SIZE(byt_rt5651_ssp2_aif1_map)); + } + if (ret) + return ret; + ret = snd_soc_add_card_controls(card, byt_rt5651_controls, ARRAY_SIZE(byt_rt5651_controls)); if (ret) { @@ -485,18 +553,26 @@ static int byt_rt5651_codec_fixup(struct snd_soc_pcm_runtime *rtd, SNDRV_PCM_HW_PARAM_RATE); struct snd_interval *channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); - int ret; + int ret, bits; - /* The DSP will covert the FE rate to 48k, stereo, 24bits */ + /* The DSP will covert the FE rate to 48k, stereo */ rate->min = rate->max = 48000; channels->min = channels->max = 2; - /* set SSP2 to 24-bit */ - params_set_format(params, SNDRV_PCM_FORMAT_S24_LE); + if ((byt_rt5651_quirk & BYT_RT5651_SSP0_AIF1) || + (byt_rt5651_quirk & BYT_RT5651_SSP0_AIF2)) { + /* set SSP0 to 16-bit */ + params_set_format(params, SNDRV_PCM_FORMAT_S16_LE); + bits = 16; + } else { + /* set SSP2 to 24-bit */ + params_set_format(params, SNDRV_PCM_FORMAT_S24_LE); + bits = 24; + } /* * Default mode for SSP configuration is TDM 4 slot, override config - * with explicit setting to I2S 2ch 24-bit. The word length is set with + * with explicit setting to I2S 2ch. The word length is set with * dai_set_tdm_slot() since there is no other API exposed */ ret = snd_soc_dai_set_fmt(rtd->cpu_dai, @@ -510,7 +586,7 @@ static int byt_rt5651_codec_fixup(struct snd_soc_pcm_runtime *rtd, return ret; } - ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0x3, 0x3, 2, 24); + ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0x3, 0x3, 2, bits); if (ret < 0) { dev_err(rtd->dev, "can't set I2S config, err %d\n", ret); return ret; @@ -605,12 +681,32 @@ static struct snd_soc_card byt_rt5651_card = { }; static char byt_rt5651_codec_name[SND_ACPI_I2C_ID_LEN]; +static char byt_rt5651_codec_aif_name[12]; /* = "rt5651-aif[1|2]" */ +static char byt_rt5651_cpu_dai_name[10]; /* = "ssp[0|2]-port" */ + +static bool is_valleyview(void) +{ + static const struct x86_cpu_id cpu_ids[] = { + { X86_VENDOR_INTEL, 6, 55 }, /* Valleyview, Bay Trail */ + {} + }; + + if (!x86_match_cpu(cpu_ids)) + return false; + return true; +} + +struct acpi_chan_package { /* ACPICA seems to require 64 bit integers */ + u64 aif_value; /* 1: AIF1, 2: AIF2 */ + u64 mclock_value; /* usually 25MHz (0x17d7940), ignored */ +}; static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) { struct byt_rt5651_private *priv; struct snd_soc_acpi_mach *mach; const char *i2c_name = NULL; + bool is_bytcr = false; int ret_val = 0; int dai_index = 0; int i; @@ -643,6 +739,73 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) "%s%s", "i2c-", i2c_name); byt_rt5651_dais[dai_index].codec_name = byt_rt5651_codec_name; + /* + * swap SSP0 if bytcr is detected + * (will be overridden if DMI quirk is detected) + */ + if (is_valleyview()) { + struct sst_platform_info *p_info = mach->pdata; + const struct sst_res_info *res_info = p_info->res_info; + + if (res_info->acpi_ipc_irq_index == 0) + is_bytcr = true; + } + + if (is_bytcr) { + /* + * Baytrail CR platforms may have CHAN package in BIOS, try + * to find relevant routing quirk based as done on Windows + * platforms. We have to read the information directly from the + * BIOS, at this stage the card is not created and the links + * with the codec driver/pdata are non-existent + */ + + struct acpi_chan_package chan_package; + + /* format specified: 2 64-bit integers */ + struct acpi_buffer format = {sizeof("NN"), "NN"}; + struct acpi_buffer state = {0, NULL}; + struct snd_soc_acpi_package_context pkg_ctx; + bool pkg_found = false; + + state.length = sizeof(chan_package); + state.pointer = &chan_package; + + pkg_ctx.name = "CHAN"; + pkg_ctx.length = 2; + pkg_ctx.format = &format; + pkg_ctx.state = &state; + pkg_ctx.data_valid = false; + + pkg_found = snd_soc_acpi_find_package_from_hid(mach->id, + &pkg_ctx); + if (pkg_found) { + if (chan_package.aif_value == 1) { + dev_info(&pdev->dev, "BIOS Routing: AIF1 connected\n"); + byt_rt5651_quirk |= BYT_RT5651_SSP0_AIF1; + } else if (chan_package.aif_value == 2) { + dev_info(&pdev->dev, "BIOS Routing: AIF2 connected\n"); + byt_rt5651_quirk |= BYT_RT5651_SSP0_AIF2; + } else { + dev_info(&pdev->dev, "BIOS Routing isn't valid, ignored\n"); + pkg_found = false; + } + } + + if (!pkg_found) { + /* no BIOS indications, assume SSP0-AIF2 connection */ + byt_rt5651_quirk |= BYT_RT5651_SSP0_AIF2; + } + + /* change defaults for Baytrail-CR capture */ + byt_rt5651_quirk |= BYT_RT5651_JD1_1 | + BYT_RT5651_OVCD_TH_2000UA | + BYT_RT5651_OVCD_SF_0P75 | + BYT_RT5651_IN2_HS_IN3_MAP; + } else { + byt_rt5651_quirk |= BYT_RT5651_DMIC_MAP; + } + /* check quirks before creating card */ dmi_check_system(byt_rt5651_quirk_table); @@ -653,6 +816,28 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) log_quirks(&pdev->dev); + if ((byt_rt5651_quirk & BYT_RT5651_SSP2_AIF2) || + (byt_rt5651_quirk & BYT_RT5651_SSP0_AIF2)) { + /* fixup codec aif name */ + snprintf(byt_rt5651_codec_aif_name, + sizeof(byt_rt5651_codec_aif_name), + "%s", "rt5651-aif2"); + + byt_rt5651_dais[dai_index].codec_dai_name = + byt_rt5651_codec_aif_name; + } + + if ((byt_rt5651_quirk & BYT_RT5651_SSP0_AIF1) || + (byt_rt5651_quirk & BYT_RT5651_SSP0_AIF2)) { + /* fixup cpu dai name name */ + snprintf(byt_rt5651_cpu_dai_name, + sizeof(byt_rt5651_cpu_dai_name), + "%s", "ssp0-port"); + + byt_rt5651_dais[dai_index].cpu_dai_name = + byt_rt5651_cpu_dai_name; + } + if (byt_rt5651_quirk & BYT_RT5651_MCLK_EN) { priv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3"); if (IS_ERR(priv->mclk)) { From f9877eb598d5bd2e6d9b4dc28068b66c464d1e5f Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:36:08 +0100 Subject: [PATCH 099/102] ASoC: Intel: bytcr_rt5651: Add quirk for the VIOS LTH17 laptop Add a quirk setting up jack-detect and input routing for the VIOS LTH17 laptop. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 103c4b0e6505..d5a3d48294d2 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -393,6 +393,19 @@ static const struct dmi_system_id byt_rt5651_quirk_table[] = { BYT_RT5651_OVCD_SF_0P75 | BYT_RT5651_IN2_HS_IN3_MAP), }, + { + /* VIOS LTH17 */ + .callback = byt_rt5651_quirk_cb, + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "VIOS"), + DMI_MATCH(DMI_PRODUCT_NAME, "LTH17"), + }, + .driver_data = (void *)(BYT_RT5651_MCLK_EN | + BYT_RT5651_JD1_1 | + BYT_RT5651_OVCD_TH_2000UA | + BYT_RT5651_OVCD_SF_1P0 | + BYT_RT5651_IN1_IN2_MAP), + }, {} }; From b4b6377e07727df8292539062d9a56e6bd83ba89 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:36:09 +0100 Subject: [PATCH 100/102] ASoC: Intel: bytcr_rt5651: Change defaults to enable jack-detect, analog mics Change the default quirk settings to enable jack-detect, analog mics. The old default input mapping of DMIC for non Bay Trail CR devices seems like a poor default as I'm not aware of any Intel SST + rt5651 using devices with a DMIC. All Cherry Trail devices using the bytcr_rt5651 machine driver seem to be modelled after BYT-CR devices, And the only non CR Bay Trail devices with a rt5651 codec I'm aware of are the Minnow boards for which we already have board specific quirks. So it seems better to me to use the BYT-CR defaults everywhere. This e.g. makes the Chuwi Hi8 Pro (CWI513) work ootb without needing a quirk. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index d5a3d48294d2..6efd7c9e7407 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -85,7 +85,12 @@ struct byt_rt5651_private { struct snd_soc_jack jack; }; -static unsigned long byt_rt5651_quirk = BYT_RT5651_MCLK_EN; +/* Default: jack-detect on JD1_1, internal mic on in2, headsetmic on in3 */ +static unsigned long byt_rt5651_quirk = BYT_RT5651_MCLK_EN | + BYT_RT5651_JD1_1 | + BYT_RT5651_OVCD_TH_2000UA | + BYT_RT5651_OVCD_SF_0P75 | + BYT_RT5651_IN2_HS_IN3_MAP; static void log_quirks(struct device *dev) { @@ -809,14 +814,6 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) /* no BIOS indications, assume SSP0-AIF2 connection */ byt_rt5651_quirk |= BYT_RT5651_SSP0_AIF2; } - - /* change defaults for Baytrail-CR capture */ - byt_rt5651_quirk |= BYT_RT5651_JD1_1 | - BYT_RT5651_OVCD_TH_2000UA | - BYT_RT5651_OVCD_SF_0P75 | - BYT_RT5651_IN2_HS_IN3_MAP; - } else { - byt_rt5651_quirk |= BYT_RT5651_DMIC_MAP; } /* check quirks before creating card */ From c22969d70fc9253112e88da55116e04074cdeac4 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:36:10 +0100 Subject: [PATCH 101/102] ASoC: Intel: bytcr_rt5651: Select RCCLK on init() When the BYT_RT5651_MCLK_EN quirk is set, we disable the MCLK from byt_rt5651_init(), we need to select the RCCLK as sysclk before doing this to make sure that jack-detect works directly after boot. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 6efd7c9e7407..53ce313024f1 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -457,6 +457,11 @@ static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) card->dapm.idle_bias_off = true; + /* Start with RC clk for jack-detect (we disable MCLK below) */ + if (byt_rt5651_quirk & BYT_RT5651_MCLK_EN) + snd_soc_component_update_bits(codec, RT5651_GLB_CLK, + RT5651_SCLK_SRC_MASK, RT5651_SCLK_SRC_RCCLK); + switch (BYT_RT5651_MAP(byt_rt5651_quirk)) { case BYT_RT5651_IN1_MAP: custom_map = byt_rt5651_intmic_in1_map; From fc9fdd61c4809b14faa9b84fe3d8f4167a836326 Mon Sep 17 00:00:00 2001 From: Sanyog Kale Date: Tue, 13 Mar 2018 09:02:25 +0530 Subject: [PATCH 102/102] ASoC: Intel: Skylake: Disable clock and power gating during FW/LIB download In order to achieve better DMA performance and reduce download time for firmware and library, it is recommended to disable dynamic clock and power gating. In some scenarios, DMA may wait to accumulate more data and last chunk of data never gets completed if dynamic clock and power gating is kept enabled. This patch adds support to disable/enable dynamic clock and power gating and use it during firmware and library download. Signed-off-by: Rakesh Ughreja Signed-off-by: Sanyog Kale Signed-off-by: Guneshwor Singh Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-messages.c | 7 ++++++- sound/soc/intel/skylake/skl-pcm.c | 7 ++++++- sound/soc/intel/skylake/skl-sst-ipc.h | 3 +++ sound/soc/intel/skylake/skl.c | 27 ++++++++++++++++++++++++++ sound/soc/intel/skylake/skl.h | 4 ++++ 5 files changed, 46 insertions(+), 2 deletions(-) diff --git a/sound/soc/intel/skylake/skl-messages.c b/sound/soc/intel/skylake/skl-messages.c index f161907859f3..57d4a58522a6 100644 --- a/sound/soc/intel/skylake/skl-messages.c +++ b/sound/soc/intel/skylake/skl-messages.c @@ -417,11 +417,16 @@ int skl_resume_dsp(struct skl *skl) if (skl->skl_sst->is_first_boot == true) return 0; - /* disable dynamic clock gating during fw and lib download */ + /* + * Disable dynamic clock and power gating during firmware + * and library download + */ ctx->enable_miscbdcge(ctx->dev, false); + ctx->clock_power_gating(ctx->dev, false); ret = skl_dsp_wake(ctx->dsp); ctx->enable_miscbdcge(ctx->dev, true); + ctx->clock_power_gating(ctx->dev, true); if (ret < 0) return ret; diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c index 84e40faeb869..15cb8ac3e374 100644 --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c @@ -1356,11 +1356,16 @@ static int skl_platform_soc_probe(struct snd_soc_component *component) return -EIO; } - /* disable dynamic clock gating during fw and lib download */ + /* + * Disable dynamic clock and power gating during firmware + * and library download + */ skl->skl_sst->enable_miscbdcge(component->dev, false); + skl->skl_sst->clock_power_gating(component->dev, false); ret = ops->init_fw(component->dev, skl->skl_sst); skl->skl_sst->enable_miscbdcge(component->dev, true); + skl->skl_sst->clock_power_gating(component->dev, true); if (ret < 0) { dev_err(component->dev, "Failed to boot first fw: %d\n", ret); return ret; diff --git a/sound/soc/intel/skylake/skl-sst-ipc.h b/sound/soc/intel/skylake/skl-sst-ipc.h index 55f2d2ce09df..f74f040dfd83 100644 --- a/sound/soc/intel/skylake/skl-sst-ipc.h +++ b/sound/soc/intel/skylake/skl-sst-ipc.h @@ -118,6 +118,9 @@ struct skl_sst { struct skl_d0i3_data d0i3; const struct skl_dsp_ops *dsp_ops; + + /* Callback to update dynamic clock and power gating registers */ + void (*clock_power_gating)(struct device *dev, bool enable); }; struct skl_ipc_init_instance_msg { diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c index aa9edc84eefb..abf324747b29 100644 --- a/sound/soc/intel/skylake/skl.c +++ b/sound/soc/intel/skylake/skl.c @@ -94,6 +94,32 @@ static void skl_enable_miscbdcge(struct device *dev, bool enable) update_pci_dword(pci, AZX_PCIREG_CGCTL, AZX_CGCTL_MISCBDCGE_MASK, val); } +/** + * skl_clock_power_gating: Enable/Disable clock and power gating + * + * @dev: Device pointer + * @enable: Enable/Disable flag + */ +static void skl_clock_power_gating(struct device *dev, bool enable) +{ + struct pci_dev *pci = to_pci_dev(dev); + struct hdac_ext_bus *ebus = pci_get_drvdata(pci); + struct hdac_bus *bus = ebus_to_hbus(ebus); + u32 val; + + /* Update PDCGE bit of CGCTL register */ + val = enable ? AZX_CGCTL_ADSPDCGE : 0; + update_pci_dword(pci, AZX_PCIREG_CGCTL, AZX_CGCTL_ADSPDCGE, val); + + /* Update L1SEN bit of EM2 register */ + val = enable ? AZX_REG_VS_EM2_L1SEN : 0; + snd_hdac_chip_updatel(bus, VS_EM2, AZX_REG_VS_EM2_L1SEN, val); + + /* Update ADSPPGD bit of PGCTL register */ + val = enable ? 0 : AZX_PGCTL_ADSPPGD; + update_pci_dword(pci, AZX_PCIREG_PGCTL, AZX_PGCTL_ADSPPGD, val); +} + /* * While performing reset, controller may not come back properly causing * issues, so recommendation is to set CGCTL.MISCBDCGE to 0 then do reset @@ -916,6 +942,7 @@ static int skl_probe(struct pci_dev *pci, goto out_nhlt_free; } skl->skl_sst->enable_miscbdcge = skl_enable_miscbdcge; + skl->skl_sst->clock_power_gating = skl_clock_power_gating; } if (bus->mlcap) snd_hdac_ext_bus_get_ml_capabilities(ebus); diff --git a/sound/soc/intel/skylake/skl.h b/sound/soc/intel/skylake/skl.h index ca46ad1d0a08..0d5375cbcf6e 100644 --- a/sound/soc/intel/skylake/skl.h +++ b/sound/soc/intel/skylake/skl.h @@ -33,8 +33,10 @@ #define AZX_PCIREG_PGCTL 0x44 #define AZX_PGCTL_LSRMD_MASK (1 << 4) +#define AZX_PGCTL_ADSPPGD BIT(2) #define AZX_PCIREG_CGCTL 0x48 #define AZX_CGCTL_MISCBDCGE_MASK (1 << 6) +#define AZX_CGCTL_ADSPDCGE BIT(1) /* D0I3C Register fields */ #define AZX_REG_VS_D0I3C_CIP 0x1 /* Command in progress */ #define AZX_REG_VS_D0I3C_I3 0x4 /* D0i3 enable */ @@ -43,6 +45,8 @@ #define DMA_TRANSMITION_START 2 #define DMA_TRANSMITION_STOP 3 +#define AZX_REG_VS_EM2_L1SEN BIT(13) + struct skl_dsp_resource { u32 max_mcps; u32 max_mem;