diff --git a/sound/soc/codecs/rt5670.c b/sound/soc/codecs/rt5670.c index c5094b4399e2..dc7df337d5f8 100644 --- a/sound/soc/codecs/rt5670.c +++ b/sound/soc/codecs/rt5670.c @@ -423,7 +423,7 @@ static bool rt5670_readable_register(struct device *dev, unsigned int reg) /** * rt5670_headset_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. @@ -431,46 +431,46 @@ static bool rt5670_readable_register(struct device *dev, unsigned int reg) * Returns detect status. */ -static int rt5670_headset_detect(struct snd_soc_codec *codec, int jack_insert) +static int rt5670_headset_detect(struct snd_soc_component *component, int jack_insert) { int val; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); if (jack_insert) { snd_soc_dapm_force_enable_pin(dapm, "Mic Det Power"); snd_soc_dapm_sync(dapm); - snd_soc_update_bits(codec, RT5670_GEN_CTRL3, 0x4, 0x0); - snd_soc_update_bits(codec, RT5670_CJ_CTRL2, + snd_soc_component_update_bits(component, RT5670_GEN_CTRL3, 0x4, 0x0); + snd_soc_component_update_bits(component, RT5670_CJ_CTRL2, RT5670_CBJ_DET_MODE | RT5670_CBJ_MN_JD, RT5670_CBJ_MN_JD); - snd_soc_write(codec, RT5670_GPIO_CTRL2, 0x0004); - snd_soc_update_bits(codec, RT5670_GPIO_CTRL1, + snd_soc_component_write(component, RT5670_GPIO_CTRL2, 0x0004); + snd_soc_component_update_bits(component, RT5670_GPIO_CTRL1, RT5670_GP1_PIN_MASK, RT5670_GP1_PIN_IRQ); - snd_soc_update_bits(codec, RT5670_CJ_CTRL1, + snd_soc_component_update_bits(component, RT5670_CJ_CTRL1, RT5670_CBJ_BST1_EN, RT5670_CBJ_BST1_EN); - snd_soc_write(codec, RT5670_JD_CTRL3, 0x00f0); - snd_soc_update_bits(codec, RT5670_CJ_CTRL2, + snd_soc_component_write(component, RT5670_JD_CTRL3, 0x00f0); + snd_soc_component_update_bits(component, RT5670_CJ_CTRL2, RT5670_CBJ_MN_JD, RT5670_CBJ_MN_JD); - snd_soc_update_bits(codec, RT5670_CJ_CTRL2, + snd_soc_component_update_bits(component, RT5670_CJ_CTRL2, RT5670_CBJ_MN_JD, 0); msleep(300); - val = snd_soc_read(codec, RT5670_CJ_CTRL3) & 0x7; + val = snd_soc_component_read32(component, RT5670_CJ_CTRL3) & 0x7; if (val == 0x1 || val == 0x2) { rt5670->jack_type = SND_JACK_HEADSET; /* for push button */ - snd_soc_update_bits(codec, RT5670_INT_IRQ_ST, 0x8, 0x8); - snd_soc_update_bits(codec, RT5670_IL_CMD, 0x40, 0x40); - snd_soc_read(codec, RT5670_IL_CMD); + snd_soc_component_update_bits(component, RT5670_INT_IRQ_ST, 0x8, 0x8); + snd_soc_component_update_bits(component, RT5670_IL_CMD, 0x40, 0x40); + snd_soc_component_read32(component, RT5670_IL_CMD); } else { - snd_soc_update_bits(codec, RT5670_GEN_CTRL3, 0x4, 0x4); + snd_soc_component_update_bits(component, RT5670_GEN_CTRL3, 0x4, 0x4); rt5670->jack_type = SND_JACK_HEADPHONE; snd_soc_dapm_disable_pin(dapm, "Mic Det Power"); snd_soc_dapm_sync(dapm); } } else { - snd_soc_update_bits(codec, RT5670_INT_IRQ_ST, 0x8, 0x0); - snd_soc_update_bits(codec, RT5670_GEN_CTRL3, 0x4, 0x4); + snd_soc_component_update_bits(component, RT5670_INT_IRQ_ST, 0x8, 0x0); + snd_soc_component_update_bits(component, RT5670_GEN_CTRL3, 0x4, 0x4); rt5670->jack_type = 0; snd_soc_dapm_disable_pin(dapm, "Mic Det Power"); snd_soc_dapm_sync(dapm); @@ -479,35 +479,35 @@ static int rt5670_headset_detect(struct snd_soc_codec *codec, int jack_insert) return rt5670->jack_type; } -void rt5670_jack_suspend(struct snd_soc_codec *codec) +void rt5670_jack_suspend(struct snd_soc_component *component) { - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); rt5670->jack_type_saved = rt5670->jack_type; - rt5670_headset_detect(codec, 0); + rt5670_headset_detect(component, 0); } EXPORT_SYMBOL_GPL(rt5670_jack_suspend); -void rt5670_jack_resume(struct snd_soc_codec *codec) +void rt5670_jack_resume(struct snd_soc_component *component) { - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); if (rt5670->jack_type_saved) - rt5670_headset_detect(codec, 1); + rt5670_headset_detect(component, 1); } EXPORT_SYMBOL_GPL(rt5670_jack_resume); -static int rt5670_button_detect(struct snd_soc_codec *codec) +static int rt5670_button_detect(struct snd_soc_component *component) { int btn_type, val; - val = snd_soc_read(codec, RT5670_IL_CMD); + val = snd_soc_component_read32(component, RT5670_IL_CMD); btn_type = val & 0xff80; - snd_soc_write(codec, RT5670_IL_CMD, val); + snd_soc_component_write(component, RT5670_IL_CMD, val); if (btn_type != 0) { msleep(20); - val = snd_soc_read(codec, RT5670_IL_CMD); - snd_soc_write(codec, RT5670_IL_CMD, val); + val = snd_soc_component_read32(component, RT5670_IL_CMD); + snd_soc_component_write(component, RT5670_IL_CMD, val); } return btn_type; @@ -521,25 +521,25 @@ static int rt5670_irq_detection(void *data) int val, btn_type, report = jack->status; if (rt5670->pdata.jd_mode == 1) /* 2 port */ - val = snd_soc_read(rt5670->codec, RT5670_A_JD_CTRL1) & 0x0070; + val = snd_soc_component_read32(rt5670->component, RT5670_A_JD_CTRL1) & 0x0070; else - val = snd_soc_read(rt5670->codec, RT5670_A_JD_CTRL1) & 0x0020; + val = snd_soc_component_read32(rt5670->component, RT5670_A_JD_CTRL1) & 0x0020; switch (val) { /* jack in */ case 0x30: /* 2 port */ case 0x0: /* 1 port or 2 port */ if (rt5670->jack_type == 0) { - report = rt5670_headset_detect(rt5670->codec, 1); + report = rt5670_headset_detect(rt5670->component, 1); /* for push button and jack out */ gpio->debounce_time = 25; break; } btn_type = 0; - if (snd_soc_read(rt5670->codec, RT5670_INT_IRQ_ST) & 0x4) { + if (snd_soc_component_read32(rt5670->component, RT5670_INT_IRQ_ST) & 0x4) { /* button pressed */ report = SND_JACK_HEADSET; - btn_type = rt5670_button_detect(rt5670->codec); + btn_type = rt5670_button_detect(rt5670->component); switch (btn_type) { case 0x2000: /* up */ report |= SND_JACK_BTN_1; @@ -551,7 +551,7 @@ static int rt5670_irq_detection(void *data) report |= SND_JACK_BTN_2; break; default: - dev_err(rt5670->codec->dev, + dev_err(rt5670->component->dev, "Unexpected button code 0x%04x\n", btn_type); break; @@ -566,8 +566,8 @@ static int rt5670_irq_detection(void *data) case 0x10: /* 2 port */ case 0x20: /* 1 port */ report = 0; - snd_soc_update_bits(rt5670->codec, RT5670_INT_IRQ_ST, 0x1, 0x0); - rt5670_headset_detect(rt5670->codec, 0); + snd_soc_component_update_bits(rt5670->component, RT5670_INT_IRQ_ST, 0x1, 0x0); + rt5670_headset_detect(rt5670->component, 0); gpio->debounce_time = 150; /* for jack in */ break; default: @@ -577,14 +577,14 @@ static int rt5670_irq_detection(void *data) return report; } -int rt5670_set_jack_detect(struct snd_soc_codec *codec, +int rt5670_set_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *jack) { - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); int ret; rt5670->jack = jack; - rt5670->hp_gpio.gpiod_dev = codec->dev; + rt5670->hp_gpio.gpiod_dev = component->dev; rt5670->hp_gpio.name = "headset"; rt5670->hp_gpio.report = SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2; @@ -596,7 +596,7 @@ int rt5670_set_jack_detect(struct snd_soc_codec *codec, ret = snd_soc_jack_add_gpios(rt5670->jack, 1, &rt5670->hp_gpio); if (ret) { - dev_err(codec->dev, "Adding jack GPIO failed\n"); + dev_err(component->dev, "Adding jack GPIO failed\n"); return ret; } @@ -699,17 +699,17 @@ static const struct snd_kcontrol_new rt5670_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 rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); int idx, rate; rate = rt5670->sysclk / rl6231_get_pre_div(rt5670->regmap, RT5670_ADDA_CLK1, RT5670_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, RT5670_DMIC_CTRL1, + snd_soc_component_update_bits(component, RT5670_DMIC_CTRL1, RT5670_DMIC_CLK_MASK, idx << RT5670_DMIC_CLK_SFT); return idx; } @@ -717,8 +717,8 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w, static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); if (rt5670->sysclk_src == RT5670_SCLK_S_PLL1) return 1; @@ -729,7 +729,7 @@ static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, static int is_using_asrc(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); unsigned int reg, shift, val; switch (source->shift) { @@ -765,7 +765,7 @@ static int is_using_asrc(struct snd_soc_dapm_widget *source, return 0; } - val = (snd_soc_read(codec, reg) >> shift) & 0xf; + val = (snd_soc_component_read32(component, reg) >> shift) & 0xf; switch (val) { case 1: case 2: @@ -781,8 +781,8 @@ static int is_using_asrc(struct snd_soc_dapm_widget *source, static int can_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 rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); if (rt5670->sysclk > rt5670->lrck[RT5670_AIF1] * 384) return 1; @@ -793,7 +793,7 @@ static int can_use_asrc(struct snd_soc_dapm_widget *source, /** * rt5670_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 * @@ -805,7 +805,7 @@ static int can_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 rt5670_sel_asrc_clk_src(struct snd_soc_codec *codec, +int rt5670_sel_asrc_clk_src(struct snd_soc_component *component, unsigned int filter_mask, unsigned int clk_src) { unsigned int asrc2_mask = 0, asrc2_value = 0; @@ -863,11 +863,11 @@ int rt5670_sel_asrc_clk_src(struct snd_soc_codec *codec, } if (asrc2_mask) - snd_soc_update_bits(codec, RT5670_ASRC_2, + snd_soc_component_update_bits(component, RT5670_ASRC_2, asrc2_mask, asrc2_value); if (asrc3_mask) - snd_soc_update_bits(codec, RT5670_ASRC_3, + snd_soc_component_update_bits(component, RT5670_ASRC_3, asrc3_mask, asrc3_value); return 0; } @@ -1421,8 +1421,8 @@ static const struct snd_kcontrol_new rt5670_vad_adc_mux = static int rt5670_hp_power_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -1457,8 +1457,8 @@ static int rt5670_hp_power_event(struct snd_soc_dapm_widget *w, static int rt5670_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 rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -1507,16 +1507,16 @@ static int rt5670_hp_event(struct snd_soc_dapm_widget *w, static int rt5670_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, RT5670_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5670_PWR_ANLG2, RT5670_PWR_BST1_P, RT5670_PWR_BST1_P); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, RT5670_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5670_PWR_ANLG2, RT5670_PWR_BST1_P, 0); break; @@ -1530,16 +1530,16 @@ static int rt5670_bst1_event(struct snd_soc_dapm_widget *w, static int rt5670_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, RT5670_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5670_PWR_ANLG2, RT5670_PWR_BST2_P, RT5670_PWR_BST2_P); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, RT5670_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5670_PWR_ANLG2, RT5670_PWR_BST2_P, 0); break; @@ -2322,21 +2322,21 @@ static const struct snd_soc_dapm_route rt5672_specific_dapm_routes[] = { static int rt5670_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 rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); unsigned int val_len = 0, val_clk, mask_clk; int pre_div, bclk_ms, frame_size; rt5670->lrck[dai->id] = params_rate(params); pre_div = rl6231_get_clk_info(rt5670->sysclk, rt5670->lrck[dai->id]); if (pre_div < 0) { - dev_err(codec->dev, "Unsupported clock setting %d for DAI %d\n", + dev_err(component->dev, "Unsupported clock setting %d for DAI %d\n", rt5670->lrck[dai->id], dai->id); return -EINVAL; } frame_size = snd_soc_params_to_frame_size(params); if (frame_size < 0) { - dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size); + dev_err(component->dev, "Unsupported frame size: %d\n", frame_size); return -EINVAL; } bclk_ms = frame_size > 32; @@ -2368,20 +2368,20 @@ static int rt5670_hw_params(struct snd_pcm_substream *substream, mask_clk = RT5670_I2S_BCLK_MS1_MASK | RT5670_I2S_PD1_MASK; val_clk = bclk_ms << RT5670_I2S_BCLK_MS1_SFT | pre_div << RT5670_I2S_PD1_SFT; - snd_soc_update_bits(codec, RT5670_I2S1_SDP, + snd_soc_component_update_bits(component, RT5670_I2S1_SDP, RT5670_I2S_DL_MASK, val_len); - snd_soc_update_bits(codec, RT5670_ADDA_CLK1, mask_clk, val_clk); + snd_soc_component_update_bits(component, RT5670_ADDA_CLK1, mask_clk, val_clk); break; case RT5670_AIF2: mask_clk = RT5670_I2S_BCLK_MS2_MASK | RT5670_I2S_PD2_MASK; val_clk = bclk_ms << RT5670_I2S_BCLK_MS2_SFT | pre_div << RT5670_I2S_PD2_SFT; - snd_soc_update_bits(codec, RT5670_I2S2_SDP, + snd_soc_component_update_bits(component, RT5670_I2S2_SDP, RT5670_I2S_DL_MASK, val_len); - snd_soc_update_bits(codec, RT5670_ADDA_CLK1, mask_clk, val_clk); + snd_soc_component_update_bits(component, RT5670_ADDA_CLK1, mask_clk, val_clk); break; default: - dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); + dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); return -EINVAL; } @@ -2390,8 +2390,8 @@ static int rt5670_hw_params(struct snd_pcm_substream *substream, static int rt5670_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -2434,26 +2434,26 @@ static int rt5670_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) switch (dai->id) { case RT5670_AIF1: - snd_soc_update_bits(codec, RT5670_I2S1_SDP, + snd_soc_component_update_bits(component, RT5670_I2S1_SDP, RT5670_I2S_MS_MASK | RT5670_I2S_BP_MASK | RT5670_I2S_DF_MASK, reg_val); break; case RT5670_AIF2: - snd_soc_update_bits(codec, RT5670_I2S2_SDP, + snd_soc_component_update_bits(component, RT5670_I2S2_SDP, RT5670_I2S_MS_MASK | RT5670_I2S_BP_MASK | RT5670_I2S_DF_MASK, reg_val); break; default: - dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); + dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); return -EINVAL; } return 0; } -static int rt5670_set_codec_sysclk(struct snd_soc_codec *codec, int clk_id, +static int rt5670_set_codec_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; switch (clk_id) { @@ -2467,16 +2467,16 @@ static int rt5670_set_codec_sysclk(struct snd_soc_codec *codec, int clk_id, reg_val |= RT5670_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, RT5670_GLB_CLK, + snd_soc_component_update_bits(component, RT5670_GLB_CLK, RT5670_SCLK_SRC_MASK, reg_val); rt5670->sysclk = freq; if (clk_id != RT5670_SCLK_S_RCCLK) rt5670->sysclk_src = clk_id; - dev_dbg(codec->dev, "Sysclk : %dHz clock id : %d\n", freq, clk_id); + dev_dbg(component->dev, "Sysclk : %dHz clock id : %d\n", freq, clk_id); return 0; } @@ -2484,8 +2484,8 @@ static int rt5670_set_codec_sysclk(struct snd_soc_codec *codec, int clk_id, static int rt5670_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 rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); struct rl6231_pll_code pll_code; int ret; @@ -2494,18 +2494,18 @@ static int rt5670_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"); rt5670->pll_in = 0; rt5670->pll_out = 0; - snd_soc_update_bits(codec, RT5670_GLB_CLK, + snd_soc_component_update_bits(component, RT5670_GLB_CLK, RT5670_SCLK_SRC_MASK, RT5670_SCLK_SRC_MCLK); return 0; } switch (source) { case RT5670_PLL1_S_MCLK: - snd_soc_update_bits(codec, RT5670_GLB_CLK, + snd_soc_component_update_bits(component, RT5670_GLB_CLK, RT5670_PLL1_SRC_MASK, RT5670_PLL1_SRC_MCLK); break; case RT5670_PLL1_S_BCLK1: @@ -2514,36 +2514,36 @@ static int rt5670_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, case RT5670_PLL1_S_BCLK4: switch (dai->id) { case RT5670_AIF1: - snd_soc_update_bits(codec, RT5670_GLB_CLK, + snd_soc_component_update_bits(component, RT5670_GLB_CLK, RT5670_PLL1_SRC_MASK, RT5670_PLL1_SRC_BCLK1); break; case RT5670_AIF2: - snd_soc_update_bits(codec, RT5670_GLB_CLK, + snd_soc_component_update_bits(component, RT5670_GLB_CLK, RT5670_PLL1_SRC_MASK, RT5670_PLL1_SRC_BCLK2); break; default: - dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); + dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); return -EINVAL; } 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, RT5670_PLL_CTRL1, + snd_soc_component_write(component, RT5670_PLL_CTRL1, pll_code.n_code << RT5670_PLL_N_SFT | pll_code.k_code); - snd_soc_write(codec, RT5670_PLL_CTRL2, + snd_soc_component_write(component, RT5670_PLL_CTRL2, (pll_code.m_bp ? 0 : pll_code.m_code) << RT5670_PLL_M_SFT | pll_code.m_bp << RT5670_PLL_M_BP_SFT); @@ -2557,7 +2557,7 @@ static int rt5670_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, static int rt5670_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 snd_soc_component *component = dai->component; unsigned int val = 0; if (rx_mask || tx_mask) @@ -2595,75 +2595,75 @@ static int rt5670_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, return -EINVAL; } - snd_soc_update_bits(codec, RT5670_TDM_CTRL_1, 0x7c00, val); + snd_soc_component_update_bits(component, RT5670_TDM_CTRL_1, 0x7c00, val); return 0; } static int rt5670_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 (dai->id != RT5670_AIF1) return 0; if ((ratio % 50) == 0) - snd_soc_update_bits(codec, RT5670_GEN_CTRL3, + snd_soc_component_update_bits(component, RT5670_GEN_CTRL3, RT5670_TDM_DATA_MODE_SEL, RT5670_TDM_DATA_MODE_50FS); else - snd_soc_update_bits(codec, RT5670_GEN_CTRL3, + snd_soc_component_update_bits(component, RT5670_GEN_CTRL3, RT5670_TDM_DATA_MODE_SEL, RT5670_TDM_DATA_MODE_NOR); return 0; } -static int rt5670_set_bias_level(struct snd_soc_codec *codec, +static int rt5670_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct rt5670_priv *rt5670 = 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, RT5670_PWR_ANLG1, + if (SND_SOC_BIAS_STANDBY == snd_soc_component_get_bias_level(component)) { + snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, RT5670_PWR_VREF1 | RT5670_PWR_MB | RT5670_PWR_BG | RT5670_PWR_VREF2, RT5670_PWR_VREF1 | RT5670_PWR_MB | RT5670_PWR_BG | RT5670_PWR_VREF2); mdelay(10); - snd_soc_update_bits(codec, RT5670_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, RT5670_PWR_FV1 | RT5670_PWR_FV2, RT5670_PWR_FV1 | RT5670_PWR_FV2); - snd_soc_update_bits(codec, RT5670_CHARGE_PUMP, + snd_soc_component_update_bits(component, RT5670_CHARGE_PUMP, RT5670_OSW_L_MASK | RT5670_OSW_R_MASK, RT5670_OSW_L_DIS | RT5670_OSW_R_DIS); - snd_soc_update_bits(codec, RT5670_DIG_MISC, 0x1, 0x1); - snd_soc_update_bits(codec, RT5670_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5670_DIG_MISC, 0x1, 0x1); + snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, RT5670_LDO_SEL_MASK, 0x5); } break; case SND_SOC_BIAS_STANDBY: - snd_soc_update_bits(codec, RT5670_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, RT5670_PWR_VREF1 | RT5670_PWR_VREF2 | RT5670_PWR_FV1 | RT5670_PWR_FV2, 0); - snd_soc_update_bits(codec, RT5670_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, RT5670_LDO_SEL_MASK, 0x3); break; case SND_SOC_BIAS_OFF: if (rt5670->pdata.jd_mode) - snd_soc_update_bits(codec, RT5670_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, RT5670_PWR_VREF1 | RT5670_PWR_MB | RT5670_PWR_BG | RT5670_PWR_VREF2 | RT5670_PWR_FV1 | RT5670_PWR_FV2, RT5670_PWR_MB | RT5670_PWR_BG); else - snd_soc_update_bits(codec, RT5670_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, RT5670_PWR_VREF1 | RT5670_PWR_MB | RT5670_PWR_BG | RT5670_PWR_VREF2 | RT5670_PWR_FV1 | RT5670_PWR_FV2, 0); - snd_soc_update_bits(codec, RT5670_DIG_MISC, 0x1, 0x0); + snd_soc_component_update_bits(component, RT5670_DIG_MISC, 0x1, 0x0); break; default: @@ -2673,12 +2673,12 @@ static int rt5670_set_bias_level(struct snd_soc_codec *codec, return 0; } -static int rt5670_probe(struct snd_soc_codec *codec) +static int rt5670_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); - switch (snd_soc_read(codec, RT5670_RESET) & RT5670_ID_MASK) { + switch (snd_soc_component_read32(component, RT5670_RESET) & RT5670_ID_MASK) { case RT5670_ID_5670: case RT5670_ID_5671: snd_soc_dapm_new_controls(dapm, @@ -2697,37 +2697,36 @@ static int rt5670_probe(struct snd_soc_codec *codec) ARRAY_SIZE(rt5672_specific_dapm_routes)); break; default: - dev_err(codec->dev, + dev_err(component->dev, "The driver is for RT5670 RT5671 or RT5672 only\n"); return -ENODEV; } - rt5670->codec = codec; + rt5670->component = component; return 0; } -static int rt5670_remove(struct snd_soc_codec *codec) +static void rt5670_remove(struct snd_soc_component *component) { - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); regmap_write(rt5670->regmap, RT5670_RESET, 0); snd_soc_jack_free_gpios(rt5670->jack, 1, &rt5670->hp_gpio); - return 0; } #ifdef CONFIG_PM -static int rt5670_suspend(struct snd_soc_codec *codec) +static int rt5670_suspend(struct snd_soc_component *component) { - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt5670->regmap, true); regcache_mark_dirty(rt5670->regmap); return 0; } -static int rt5670_resume(struct snd_soc_codec *codec) +static int rt5670_resume(struct snd_soc_component *component) { - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt5670->regmap, false); regcache_sync(rt5670->regmap); @@ -2794,22 +2793,22 @@ static struct snd_soc_dai_driver rt5670_dai[] = { }, }; -static const struct snd_soc_codec_driver soc_codec_dev_rt5670 = { - .probe = rt5670_probe, - .remove = rt5670_remove, - .suspend = rt5670_suspend, - .resume = rt5670_resume, - .set_bias_level = rt5670_set_bias_level, - .idle_bias_off = true, - .set_sysclk = rt5670_set_codec_sysclk, - .component_driver = { - .controls = rt5670_snd_controls, - .num_controls = ARRAY_SIZE(rt5670_snd_controls), - .dapm_widgets = rt5670_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(rt5670_dapm_widgets), - .dapm_routes = rt5670_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(rt5670_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_rt5670 = { + .probe = rt5670_probe, + .remove = rt5670_remove, + .suspend = rt5670_suspend, + .resume = rt5670_resume, + .set_bias_level = rt5670_set_bias_level, + .set_sysclk = rt5670_set_codec_sysclk, + .controls = rt5670_snd_controls, + .num_controls = ARRAY_SIZE(rt5670_snd_controls), + .dapm_widgets = rt5670_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt5670_dapm_widgets), + .dapm_routes = rt5670_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(rt5670_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config rt5670_regmap = { @@ -3171,7 +3170,8 @@ static int rt5670_i2c_probe(struct i2c_client *i2c, pm_runtime_enable(&i2c->dev); pm_request_idle(&i2c->dev); - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5670, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_rt5670, rt5670_dai, ARRAY_SIZE(rt5670_dai)); if (ret < 0) goto err; @@ -3188,7 +3188,6 @@ err: static int rt5670_i2c_remove(struct i2c_client *i2c) { pm_runtime_disable(&i2c->dev); - snd_soc_unregister_codec(&i2c->dev); return 0; } diff --git a/sound/soc/codecs/rt5670.h b/sound/soc/codecs/rt5670.h index 265df80d504e..97e8eebe63fa 100644 --- a/sound/soc/codecs/rt5670.h +++ b/sound/soc/codecs/rt5670.h @@ -1986,11 +1986,11 @@ enum { RT5670_DOWN_RATE_FILTER = (0x1 << 7), }; -int rt5670_sel_asrc_clk_src(struct snd_soc_codec *codec, +int rt5670_sel_asrc_clk_src(struct snd_soc_component *component, unsigned int filter_mask, unsigned int clk_src); struct rt5670_priv { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct rt5670_platform_data pdata; struct regmap *regmap; struct snd_soc_jack *jack; @@ -2012,8 +2012,8 @@ struct rt5670_priv { int jack_type_saved; }; -void rt5670_jack_suspend(struct snd_soc_codec *codec); -void rt5670_jack_resume(struct snd_soc_codec *codec); -int rt5670_set_jack_detect(struct snd_soc_codec *codec, +void rt5670_jack_suspend(struct snd_soc_component *component); +void rt5670_jack_resume(struct snd_soc_component *component); +int rt5670_set_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *jack); #endif /* __RT5670_H__ */ diff --git a/sound/soc/intel/boards/cht_bsw_rt5672.c b/sound/soc/intel/boards/cht_bsw_rt5672.c index c14a52d2f714..e68ec32720a4 100644 --- a/sound/soc/intel/boards/cht_bsw_rt5672.c +++ b/sound/soc/intel/boards/cht_bsw_rt5672.c @@ -183,10 +183,10 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) { int ret; struct snd_soc_dai *codec_dai = runtime->codec_dai; - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; struct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card); - if (devm_acpi_dev_add_driver_gpios(codec->dev, cht_rt5672_gpios)) + if (devm_acpi_dev_add_driver_gpios(component->dev, cht_rt5672_gpios)) dev_warn(runtime->dev, "Unable to add GPIO mapping table\n"); /* TDM 4 slots 24 bit, set Rx & Tx bitmask to 4 active slots */ @@ -201,7 +201,7 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) * be supported by RT5672. Otherwise, ASRC will be disabled and cause * noise. */ - rt5670_sel_asrc_clk_src(codec, + rt5670_sel_asrc_clk_src(component, RT5670_DA_STEREO_FILTER | RT5670_DA_MONO_L_FILTER | RT5670_DA_MONO_R_FILTER @@ -219,7 +219,7 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) if (ret) return ret; - rt5670_set_jack_detect(codec, &ctx->headset); + rt5670_set_jack_detect(component, &ctx->headset); if (ctx->mclk) { /* * The firmware might enable the clock at @@ -333,10 +333,9 @@ static int cht_suspend_pre(struct snd_soc_card *card) list_for_each_entry(component, &card->component_dev_list, card_list) { if (!strncmp(component->name, ctx->codec_name, sizeof(ctx->codec_name))) { - struct snd_soc_codec *codec = snd_soc_component_to_codec(component); - dev_dbg(codec->dev, "disabling jack detect before going to suspend.\n"); - rt5670_jack_suspend(codec); + dev_dbg(component->dev, "disabling jack detect before going to suspend.\n"); + rt5670_jack_suspend(component); break; } } @@ -351,10 +350,9 @@ static int cht_resume_post(struct snd_soc_card *card) list_for_each_entry(component, &card->component_dev_list, card_list) { if (!strncmp(component->name, ctx->codec_name, sizeof(ctx->codec_name))) { - struct snd_soc_codec *codec = snd_soc_component_to_codec(component); - dev_dbg(codec->dev, "enabling jack detect for resume.\n"); - rt5670_jack_resume(codec); + dev_dbg(component->dev, "enabling jack detect for resume.\n"); + rt5670_jack_resume(component); break; } }