diff options
Diffstat (limited to 'sound/soc/codecs/wm5110.c')
-rw-r--r-- | sound/soc/codecs/wm5110.c | 222 |
1 files changed, 107 insertions, 115 deletions
diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c index fb0cf9c61f48..fb9835dcd836 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]; @@ -159,8 +161,8 @@ static const struct reg_default wm5110_sysclk_reve_patch[] = { static int wm5110_sysclk_ev(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 arizona *arizona = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct arizona *arizona = dev_get_drvdata(component->dev->parent); struct regmap *regmap = arizona->regmap; const struct reg_default *patch = NULL; int i, patch_size; @@ -196,14 +198,14 @@ static int wm5110_sysclk_ev(struct snd_soc_dapm_widget *w, static int wm5110_adsp_power_ev(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 arizona *arizona = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct arizona *arizona = dev_get_drvdata(component->dev->parent); unsigned int v; int ret; ret = regmap_read(arizona->regmap, ARIZONA_SYSTEM_CLOCK_1, &v); if (ret != 0) { - dev_err(codec->dev, "Failed to read SYSCLK state: %d\n", ret); + dev_err(component->dev, "Failed to read SYSCLK state: %d\n", ret); return ret; } @@ -286,10 +288,10 @@ static const struct reg_sequence wm5110_dre_right_enable[] = { static int wm5110_hp_pre_enable(struct snd_soc_dapm_widget *w) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->arizona; - unsigned int val = snd_soc_read(codec, ARIZONA_DRE_ENABLE); + unsigned int val = snd_soc_component_read32(component, ARIZONA_DRE_ENABLE); const struct reg_sequence *wseq; int nregs; @@ -323,26 +325,32 @@ static int wm5110_hp_pre_enable(struct snd_soc_dapm_widget *w) static int wm5110_hp_pre_disable(struct snd_soc_dapm_widget *w) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); - unsigned int val = snd_soc_read(codec, ARIZONA_DRE_ENABLE); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); + unsigned int val = snd_soc_component_read32(component, ARIZONA_DRE_ENABLE); switch (w->shift) { case ARIZONA_OUT1L_ENA_SHIFT: if (!(val & ARIZONA_DRE1L_ENA_MASK)) { - snd_soc_update_bits(codec, ARIZONA_SPARE_TRIGGERS, - ARIZONA_WS_TRG1, ARIZONA_WS_TRG1); - snd_soc_update_bits(codec, ARIZONA_SPARE_TRIGGERS, - ARIZONA_WS_TRG1, 0); + snd_soc_component_update_bits(component, + ARIZONA_SPARE_TRIGGERS, + ARIZONA_WS_TRG1, + ARIZONA_WS_TRG1); + snd_soc_component_update_bits(component, + ARIZONA_SPARE_TRIGGERS, + ARIZONA_WS_TRG1, 0); priv->out_down_delay += 27; } break; case ARIZONA_OUT1R_ENA_SHIFT: if (!(val & ARIZONA_DRE1R_ENA_MASK)) { - snd_soc_update_bits(codec, ARIZONA_SPARE_TRIGGERS, - ARIZONA_WS_TRG2, ARIZONA_WS_TRG2); - snd_soc_update_bits(codec, ARIZONA_SPARE_TRIGGERS, - ARIZONA_WS_TRG2, 0); + snd_soc_component_update_bits(component, + ARIZONA_SPARE_TRIGGERS, + ARIZONA_WS_TRG2, + ARIZONA_WS_TRG2); + snd_soc_component_update_bits(component, + ARIZONA_SPARE_TRIGGERS, + ARIZONA_WS_TRG2, 0); priv->out_down_delay += 27; } break; @@ -356,8 +364,8 @@ static int wm5110_hp_pre_disable(struct snd_soc_dapm_widget *w) static int wm5110_hp_ev(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 arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); switch (priv->arizona->rev) { case 0 ... 3: @@ -395,9 +403,9 @@ static int wm5110_clear_pga_volume(struct arizona *arizona, int output) static int wm5110_put_dre(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct arizona *arizona = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct arizona *arizona = dev_get_drvdata(component->dev->parent); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; unsigned int ena, dre; @@ -456,8 +464,8 @@ err: static int wm5110_in_pga_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int ret; /* @@ -476,8 +484,8 @@ static int wm5110_in_pga_get(struct snd_kcontrol *kcontrol, static int wm5110_in_pga_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int ret; /* @@ -496,9 +504,9 @@ static int wm5110_in_pga_put(struct snd_kcontrol *kcontrol, static int wm5110_in_analog_ev(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 arizona_priv *priv = snd_soc_codec_get_drvdata(codec); - struct wm5110_priv *wm5110 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); + struct wm5110_priv *wm5110 = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->arizona; unsigned int reg, mask; struct reg_sequence analog_seq[] = { @@ -517,9 +525,9 @@ static int wm5110_in_analog_ev(struct snd_soc_dapm_widget *w, wm5110->in_post_pending++; return 0; case SND_SOC_DAPM_PRE_PMU: - wm5110->in_pga_cache[w->shift] = snd_soc_read(codec, reg); + wm5110->in_pga_cache[w->shift] = snd_soc_component_read32(component, reg); - snd_soc_update_bits(codec, reg, mask, + snd_soc_component_update_bits(component, reg, mask, 0x40 << ARIZONA_IN1L_PGA_VOL_SHIFT); wm5110->in_pre_pending--; @@ -536,8 +544,8 @@ static int wm5110_in_analog_ev(struct snd_soc_dapm_widget *w, break; case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, reg, mask, - wm5110->in_pga_cache[w->shift]); + snd_soc_component_update_bits(component, reg, mask, + wm5110->in_pga_cache[w->shift]); wm5110->in_post_pending--; if (wm5110->in_post_pending == 0) @@ -555,13 +563,13 @@ static int wm5110_in_analog_ev(struct snd_soc_dapm_widget *w, static int wm5110_in_ev(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 arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->arizona; switch (arizona->rev) { case 0 ... 4: - if (arizona_input_analog(codec, w->shift)) + if (arizona_input_analog(component, w->shift)) wm5110_in_analog_ev(w, kcontrol, event); break; @@ -861,14 +869,14 @@ SOC_DOUBLE("SPKDAT2 Switch", ARIZONA_PDM_SPK2_CTRL_1, ARIZONA_SPK2L_MUTE_SHIFT, ARIZONA_SPK2R_MUTE_SHIFT, 1, 1), SOC_DOUBLE_EXT("HPOUT1 DRE Switch", ARIZONA_DRE_ENABLE, - ARIZONA_DRE1L_ENA_SHIFT, ARIZONA_DRE1R_ENA_SHIFT, 1, 0, - snd_soc_get_volsw, wm5110_put_dre), + ARIZONA_DRE1L_ENA_SHIFT, ARIZONA_DRE1R_ENA_SHIFT, 1, 0, + snd_soc_get_volsw, wm5110_put_dre), SOC_DOUBLE_EXT("HPOUT2 DRE Switch", ARIZONA_DRE_ENABLE, - ARIZONA_DRE2L_ENA_SHIFT, ARIZONA_DRE2R_ENA_SHIFT, 1, 0, - snd_soc_get_volsw, wm5110_put_dre), + ARIZONA_DRE2L_ENA_SHIFT, ARIZONA_DRE2R_ENA_SHIFT, 1, 0, + snd_soc_get_volsw, wm5110_put_dre), SOC_DOUBLE_EXT("HPOUT3 DRE Switch", ARIZONA_DRE_ENABLE, - ARIZONA_DRE3L_ENA_SHIFT, ARIZONA_DRE3R_ENA_SHIFT, 1, 0, - snd_soc_get_volsw, wm5110_put_dre), + ARIZONA_DRE3L_ENA_SHIFT, ARIZONA_DRE3R_ENA_SHIFT, 1, 0, + snd_soc_get_volsw, wm5110_put_dre), SOC_ENUM("Output Ramp Up", arizona_out_vi_ramp), SOC_ENUM("Output Ramp Down", arizona_out_vd_ramp), @@ -1034,7 +1042,7 @@ ARIZONA_MUX_ENUMS(ISRC3DEC2, ARIZONA_ISRC3DEC2MIX_INPUT_1_SOURCE); ARIZONA_MUX_ENUMS(ISRC3DEC3, ARIZONA_ISRC3DEC3MIX_INPUT_1_SOURCE); ARIZONA_MUX_ENUMS(ISRC3DEC4, ARIZONA_ISRC3DEC4MIX_INPUT_1_SOURCE); -static const char *wm5110_aec_loopback_texts[] = { +static const char * const wm5110_aec_loopback_texts[] = { "HPOUT1L", "HPOUT1R", "HPOUT2L", "HPOUT2R", "HPOUT3L", "HPOUT3R", "SPKOUTL", "SPKOUTR", "SPKDAT1L", "SPKDAT1R", "SPKDAT2L", "SPKDAT2R", }; @@ -1272,18 +1280,17 @@ SND_SOC_DAPM_PGA("ISRC3DEC4", ARIZONA_ISRC_3_CTRL_3, ARIZONA_ISRC3_DEC3_ENA_SHIFT, 0, NULL, 0), SND_SOC_DAPM_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1, - ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0, - &wm5110_aec_loopback_mux), + ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0, &wm5110_aec_loopback_mux), SND_SOC_DAPM_SUPPLY("RXANC NG External Clock", SND_SOC_NOPM, - ARIZONA_EXT_NG_SEL_SET_SHIFT, 0, arizona_anc_ev, - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), + ARIZONA_EXT_NG_SEL_SET_SHIFT, 0, arizona_anc_ev, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), SND_SOC_DAPM_PGA("RXANCL NG External", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_PGA("RXANCR NG External", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_SUPPLY("RXANC NG Clock", SND_SOC_NOPM, - ARIZONA_CLK_NG_ENA_SET_SHIFT, 0, arizona_anc_ev, - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), + ARIZONA_CLK_NG_ENA_SET_SHIFT, 0, arizona_anc_ev, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), SND_SOC_DAPM_PGA("RXANCL NG Internal", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_PGA("RXANCR NG Internal", SND_SOC_NOPM, 0, 0, NULL, 0), @@ -2032,10 +2039,10 @@ static const struct snd_soc_dapm_route wm5110_dapm_routes[] = { { "DSP3 Voice Trigger", "Switch", "DSP3" }, }; -static int wm5110_set_fll(struct snd_soc_codec *codec, int fll_id, int source, - unsigned int Fref, unsigned int Fout) +static int wm5110_set_fll(struct snd_soc_component *component, int fll_id, + int source, unsigned int Fref, unsigned int Fout) { - struct wm5110_priv *wm5110 = snd_soc_codec_get_drvdata(codec); + struct wm5110_priv *wm5110 = snd_soc_component_get_drvdata(component); switch (fll_id) { case WM5110_FLL1: @@ -2229,7 +2236,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; @@ -2275,33 +2283,32 @@ static irqreturn_t wm5110_adsp2_irq(int irq, void *data) return IRQ_HANDLED; } -static int wm5110_codec_probe(struct snd_soc_codec *codec) +static int wm5110_component_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); - struct wm5110_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct wm5110_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->core.arizona; int i, ret; arizona->dapm = dapm; - snd_soc_codec_init_regmap(codec, arizona->regmap); + snd_soc_component_init_regmap(component, arizona->regmap); - ret = arizona_init_spk(codec); + ret = arizona_init_spk(component); if (ret < 0) return ret; - arizona_init_gpio(codec); - arizona_init_mono(codec); + arizona_init_gpio(component); + arizona_init_mono(component); for (i = 0; i < WM5110_NUM_ADSP; ++i) { - ret = wm_adsp2_codec_probe(&priv->core.adsp[i], codec); + ret = wm_adsp2_component_probe(&priv->core.adsp[i], component); if (ret) goto err_adsp2_codec_probe; } - ret = snd_soc_add_codec_controls(codec, - arizona_adsp2_rate_controls, - WM5110_NUM_ADSP); + ret = snd_soc_add_component_controls(component, + arizona_adsp2_rate_controls, + WM5110_NUM_ADSP); if (ret) goto err_adsp2_codec_probe; @@ -2311,22 +2318,20 @@ static int wm5110_codec_probe(struct snd_soc_codec *codec) err_adsp2_codec_probe: for (--i; i >= 0; --i) - wm_adsp2_codec_remove(&priv->core.adsp[i], codec); + wm_adsp2_component_remove(&priv->core.adsp[i], component); return ret; } -static int wm5110_codec_remove(struct snd_soc_codec *codec) +static void wm5110_component_remove(struct snd_soc_component *component) { - struct wm5110_priv *priv = snd_soc_codec_get_drvdata(codec); + struct wm5110_priv *priv = snd_soc_component_get_drvdata(component); int i; for (i = 0; i < WM5110_NUM_ADSP; ++i) - wm_adsp2_codec_remove(&priv->core.adsp[i], codec); + wm_adsp2_component_remove(&priv->core.adsp[i], component); priv->core.arizona->dapm = NULL; - - return 0; } #define WM5110_DIG_VU 0x0200 @@ -2346,37 +2351,32 @@ static unsigned int wm5110_digital_vu[] = { ARIZONA_DAC_DIGITAL_VOLUME_6R, }; -static const struct snd_soc_codec_driver soc_codec_dev_wm5110 = { - .probe = wm5110_codec_probe, - .remove = wm5110_codec_remove, - - .idle_bias_off = true, - - .set_sysclk = arizona_set_sysclk, - .set_pll = wm5110_set_fll, - - .component_driver = { - .controls = wm5110_snd_controls, - .num_controls = ARRAY_SIZE(wm5110_snd_controls), - .dapm_widgets = wm5110_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm5110_dapm_widgets), - .dapm_routes = wm5110_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm5110_dapm_routes), - }, -}; - -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 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 const struct snd_soc_component_driver soc_component_dev_wm5110 = { + .probe = wm5110_component_probe, + .remove = wm5110_component_remove, + .set_sysclk = arizona_set_sysclk, + .set_pll = wm5110_set_fll, + .name = DRV_NAME, + .compr_ops = &wm5110_compr_ops, + .controls = wm5110_snd_controls, + .num_controls = ARRAY_SIZE(wm5110_snd_controls), + .dapm_widgets = wm5110_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm5110_dapm_widgets), + .dapm_routes = wm5110_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm5110_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int wm5110_probe(struct platform_device *pdev) @@ -2464,23 +2464,17 @@ 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); + ret = devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_wm5110, + wm5110_dai, + ARRAY_SIZE(wm5110_dai)); if (ret < 0) { - dev_err(&pdev->dev, "Failed to register platform: %d\n", ret); + dev_err(&pdev->dev, "Failed to register component: %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; - } - return ret; -err_platform: - snd_soc_unregister_platform(&pdev->dev); err_spk_irqs: arizona_free_spk_irqs(arizona); err_dsp_irq: @@ -2495,8 +2489,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); for (i = 0; i < WM5110_NUM_ADSP; i++) |