Lines Matching +full:ramp +full:- +full:up

1 // SPDX-License-Identifier: GPL-2.0-only
3 * wm8350.c -- WM8350 ALSA SoC audio driver
5 * Copyright (C) 2007-12 Wolfson Microelectronics PLC.
48 u16 ramp;
73 * Ramp OUT1 PGA volume to minimise pops at stream startup and shutdown.
77 struct wm8350_output *out1 = &wm8350_data->out1;
78 struct wm8350 *wm8350 = wm8350_data->wm8350;
86 if (out1->ramp == WM8350_RAMP_UP) {
87 /* ramp step up */
88 if (val < out1->left_vol) {
95 } else if (out1->ramp == WM8350_RAMP_DOWN) {
96 /* ramp step down */
98 val--;
110 if (out1->ramp == WM8350_RAMP_UP) {
111 /* ramp step up */
112 if (val < out1->right_vol) {
119 } else if (out1->ramp == WM8350_RAMP_DOWN) {
120 /* ramp step down */
122 val--;
138 * Ramp OUT2 PGA volume to minimise pops at stream startup and shutdown.
142 struct wm8350_output *out2 = &wm8350_data->out2;
143 struct wm8350 *wm8350 = wm8350_data->wm8350;
150 if (out2->ramp == WM8350_RAMP_UP) {
151 /* ramp step up */
152 if (val < out2->left_vol) {
159 } else if (out2->ramp == WM8350_RAMP_DOWN) {
160 /* ramp step down */
162 val--;
174 if (out2->ramp == WM8350_RAMP_UP) {
175 /* ramp step up */
176 if (val < out2->right_vol) {
183 } else if (out2->ramp == WM8350_RAMP_DOWN) {
184 /* ramp step down */
186 val--;
211 struct wm8350_output *out1 = &wm8350_data->out1,
212 *out2 = &wm8350_data->out2;
215 /* do we need to ramp at all ? */
216 if (out1->ramp == WM8350_RAMP_NONE && out2->ramp == WM8350_RAMP_NONE)
219 /* PGA volumes have 6 bits of resolution to ramp */
223 if (out1->ramp != WM8350_RAMP_NONE)
225 if (out2->ramp != WM8350_RAMP_NONE)
228 /* ramp finished ? */
232 /* we need to delay longer on the up ramp */
233 if (out1->ramp == WM8350_RAMP_UP ||
234 out2->ramp == WM8350_RAMP_UP) {
246 out1->ramp = WM8350_RAMP_NONE;
247 out2->ramp = WM8350_RAMP_NONE;
257 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
261 switch (w->shift) {
264 out = &wm8350_data->out1;
268 out = &wm8350_data->out2;
272 WARN(1, "Invalid shift %d\n", w->shift);
273 return -1;
278 out->ramp = WM8350_RAMP_UP;
279 out->active = 1;
281 schedule_delayed_work(&wm8350_data->pga_work,
286 out->ramp = WM8350_RAMP_DOWN;
287 out->active = 0;
289 schedule_delayed_work(&wm8350_data->pga_work,
304 (struct soc_mixer_control *)kcontrol->private_value;
306 unsigned int reg = mc->reg;
314 out = &wm8350_priv->out1;
317 out = &wm8350_priv->out2;
324 out->left_vol = ucontrol->value.integer.value[0];
325 out->right_vol = ucontrol->value.integer.value[1];
326 if (!out->active)
345 struct wm8350_output *out1 = &wm8350_priv->out1;
346 struct wm8350_output *out2 = &wm8350_priv->out2;
348 (struct soc_mixer_control *)kcontrol->private_value;
349 unsigned int reg = mc->reg;
354 ucontrol->value.integer.value[0] = out1->left_vol;
355 ucontrol->value.integer.value[1] = out1->right_vol;
359 ucontrol->value.integer.value[0] = out2->left_vol;
360 ucontrol->value.integer.value[1] = out2->right_vol;
389 static DECLARE_TLV_DB_SCALE(pre_amp_tlv, -1200, 3525, 0);
390 static DECLARE_TLV_DB_SCALE(out_pga_tlv, -5700, 600, 0);
391 static DECLARE_TLV_DB_SCALE(dac_pcm_tlv, -7163, 36, 1);
392 static DECLARE_TLV_DB_SCALE(adc_pcm_tlv, -12700, 50, 1);
393 static DECLARE_TLV_DB_SCALE(out_mix_tlv, -1500, 300, 1);
396 0, 12, TLV_DB_SCALE_ITEM(-3600, 300, 1),
754 struct snd_soc_component *component = codec_dai->component;
756 struct wm8350 *wm8350 = wm8350_data->wm8350;
789 struct snd_soc_component *component = codec_dai->component;
829 return -EINVAL;
837 struct snd_soc_component *component = codec_dai->component;
857 return -EINVAL;
877 return -EINVAL;
894 return -EINVAL;
908 struct snd_soc_component *component = codec_dai->component;
910 struct wm8350 *wm8350 = wm8350_data->wm8350;
934 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
948 struct snd_soc_component *component = dai->component;
980 fll_div->div = 0x4;
982 fll_div->div = 0x3;
984 fll_div->div = 0x2;
986 fll_div->div = 0x1;
989 return -EINVAL;
993 fll_div->ratio = 1;
995 fll_div->ratio = 8;
997 t1 = output * (1 << (fll_div->div + 1));
998 t2 = input * fll_div->ratio;
1000 fll_div->n = t1 / t2;
1014 fll_div->k = K;
1016 fll_div->k = 0;
1025 struct snd_soc_component *component = codec_dai->component;
1027 struct wm8350 *wm8350 = priv->wm8350;
1032 if (freq_in == priv->fll_freq_in && freq_out == priv->fll_freq_out)
1035 /* power down FLL - we need to do this for reconfiguration */
1045 dev_dbg(wm8350->dev,
1050 /* set up N.K & dividers */
1069 priv->fll_freq_out = freq_out;
1070 priv->fll_freq_in = freq_in;
1079 struct wm8350 *wm8350 = priv->wm8350;
1081 wm8350->codec.platform_data;
1091 platform->codec_current_on << 14);
1103 ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies),
1104 priv->supplies);
1118 platform->dis_out1 |
1119 (platform->dis_out2 << 2) |
1120 (platform->dis_out3 << 4) |
1121 (platform->dis_out4 << 6));
1125 (platform->
1130 (platform->vmid_s_curve << 8));
1132 /* ramp up vmid */
1134 (platform->
1141 (platform->
1148 (platform->codec_current_standby << 14);
1166 (platform->
1183 (platform->vmid_s_curve << 8));
1192 (platform->
1196 (platform->vmid_s_curve << 8) |
1197 platform->dis_out1 |
1198 (platform->dis_out2 << 2) |
1199 (platform->dis_out3 << 4) |
1200 (platform->dis_out4 << 6));
1210 (platform->drain_msecs));
1215 /* disable anti-pop */
1231 regulator_bulk_disable(ARRAY_SIZE(priv->supplies),
1232 priv->supplies);
1242 struct wm8350 *wm8350 = priv->wm8350;
1248 report = jack->report;
1252 snd_soc_jack_report(jack->jack, report, jack->report);
1261 wm8350_hp_work(priv, &priv->hpl, WM8350_JACK_L_LVL);
1269 wm8350_hp_work(priv, &priv->hpr, WM8350_JACK_R_LVL);
1275 struct wm8350 *wm8350 = priv->wm8350;
1281 if (device_may_wakeup(wm8350->dev))
1282 pm_wakeup_event(wm8350->dev, 250);
1285 &priv->hpl.work, msecs_to_jiffies(200));
1293 struct wm8350 *wm8350 = priv->wm8350;
1299 if (device_may_wakeup(wm8350->dev))
1300 pm_wakeup_event(wm8350->dev, 250);
1303 &priv->hpr.work, msecs_to_jiffies(200));
1309 * wm8350_hp_jack_detect - Enable headphone jack detection.
1323 struct wm8350 *wm8350 = priv->wm8350;
1328 priv->hpl.jack = jack;
1329 priv->hpl.report = report;
1334 priv->hpr.jack = jack;
1335 priv->hpr.report = report;
1340 return -EINVAL;
1367 struct wm8350 *wm8350 = priv->wm8350;
1377 report |= priv->mic.short_report;
1379 report |= priv->mic.report;
1381 snd_soc_jack_report(priv->mic.jack, report,
1382 priv->mic.report | priv->mic.short_report);
1388 * wm8350_mic_jack_detect - Enable microphone jack detection.
1403 struct wm8350 *wm8350 = priv->wm8350;
1405 priv->mic.jack = jack;
1406 priv->mic.report = detect_report;
1407 priv->mic.short_report = short_report;
1439 .name = "wm8350-hifi",
1459 struct wm8350 *wm8350 = dev_get_platdata(component->dev);
1465 if (wm8350->codec.platform_data == NULL) {
1466 dev_err(component->dev, "No audio platform data supplied\n");
1467 return -EINVAL;
1470 priv = devm_kzalloc(component->dev, sizeof(struct wm8350_data),
1473 return -ENOMEM;
1475 snd_soc_component_init_regmap(component, wm8350->regmap);
1478 priv->wm8350 = wm8350;
1481 priv->supplies[i].supply = supply_names[i];
1483 ret = devm_regulator_bulk_get(wm8350->dev, ARRAY_SIZE(priv->supplies),
1484 priv->supplies);
1491 INIT_DELAYED_WORK(&priv->pga_work, wm8350_pga_work);
1492 INIT_DELAYED_WORK(&priv->hpl.work, wm8350_hpl_work);
1493 INIT_DELAYED_WORK(&priv->hpr.work, wm8350_hpr_work);
1504 out1 = &priv->out1;
1505 out2 = &priv->out2;
1506 out1->left_vol = (wm8350_reg_read(wm8350, WM8350_LOUT1_VOLUME) &
1508 out1->right_vol = (wm8350_reg_read(wm8350, WM8350_ROUT1_VOLUME) &
1510 out2->left_vol = (wm8350_reg_read(wm8350, WM8350_LOUT2_VOLUME) &
1512 out2->right_vol = (wm8350_reg_read(wm8350, WM8350_ROUT2_VOLUME) &
1577 struct wm8350 *wm8350 = dev_get_platdata(component->dev);
1588 priv->hpl.jack = NULL;
1589 priv->hpr.jack = NULL;
1590 priv->mic.jack = NULL;
1592 cancel_delayed_work_sync(&priv->hpl.work);
1593 cancel_delayed_work_sync(&priv->hpr.work);
1597 flush_delayed_work(&priv->pga_work);
1620 return devm_snd_soc_register_component(&pdev->dev,
1627 .name = "wm8350-codec",
1637 MODULE_ALIAS("platform:wm8350-codec");