aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMylène Josserand <mylene.josserand@free-electrons.com>2017-02-02 04:24:18 -0500
committerMark Brown <broonie@kernel.org>2017-02-03 07:02:06 -0500
commitbf14da7e55169964a1e6f35dc9d7428dc9e9013c (patch)
tree1eafd9d4e920143aff76b8fa6ff4f8f37d8daf11
parent1bd92af877abfeddcc4b83a35482ed4139591acf (diff)
ASoC: sun8i-codec-analog: Add amplifier event to fix first delay
When playing a sound for the first time, a short delay, where the audio file is not played, can be noticed. On a second play (right after), the sound is played correctly. If we wait a short time (~5 sec which corresponds to the aplay timeout), the delay is back. This patch fixes it by using an event on headphone amplifier. It allows to keep the amplifier enable while playing a sound. A delay of 700ms allows to wait that the amplifier is powered-up before playing the sound. Signed-off-by: Mylène Josserand <mylene.josserand@free-electrons.com> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/sunxi/sun8i-codec-analog.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/sound/soc/sunxi/sun8i-codec-analog.c b/sound/soc/sunxi/sun8i-codec-analog.c
index af02290ebe49..72331332b72e 100644
--- a/sound/soc/sunxi/sun8i-codec-analog.c
+++ b/sound/soc/sunxi/sun8i-codec-analog.c
@@ -398,11 +398,37 @@ static const struct snd_kcontrol_new sun8i_codec_hp_src[] = {
398 sun8i_codec_hp_src_enum), 398 sun8i_codec_hp_src_enum),
399}; 399};
400 400
401static int sun8i_headphone_amp_event(struct snd_soc_dapm_widget *w,
402 struct snd_kcontrol *k, int event)
403{
404 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
405
406 if (SND_SOC_DAPM_EVENT_ON(event)) {
407 snd_soc_component_update_bits(component, SUN8I_ADDA_PAEN_HP_CTRL,
408 BIT(SUN8I_ADDA_PAEN_HP_CTRL_HPPAEN),
409 BIT(SUN8I_ADDA_PAEN_HP_CTRL_HPPAEN));
410 /*
411 * Need a delay to have the amplifier up. 700ms seems the best
412 * compromise between the time to let the amplifier up and the
413 * time not to feel this delay while playing a sound.
414 */
415 msleep(700);
416 } else if (SND_SOC_DAPM_EVENT_OFF(event)) {
417 snd_soc_component_update_bits(component, SUN8I_ADDA_PAEN_HP_CTRL,
418 BIT(SUN8I_ADDA_PAEN_HP_CTRL_HPPAEN),
419 0x0);
420 }
421
422 return 0;
423}
424
401static const struct snd_soc_dapm_widget sun8i_codec_headphone_widgets[] = { 425static const struct snd_soc_dapm_widget sun8i_codec_headphone_widgets[] = {
402 SND_SOC_DAPM_MUX("Headphone Source Playback Route", 426 SND_SOC_DAPM_MUX("Headphone Source Playback Route",
403 SND_SOC_NOPM, 0, 0, sun8i_codec_hp_src), 427 SND_SOC_NOPM, 0, 0, sun8i_codec_hp_src),
404 SND_SOC_DAPM_OUT_DRV("Headphone Amp", SUN8I_ADDA_PAEN_HP_CTRL, 428 SND_SOC_DAPM_OUT_DRV_E("Headphone Amp", SUN8I_ADDA_PAEN_HP_CTRL,
405 SUN8I_ADDA_PAEN_HP_CTRL_HPPAEN, 0, NULL, 0), 429 SUN8I_ADDA_PAEN_HP_CTRL_HPPAEN, 0, NULL, 0,
430 sun8i_headphone_amp_event,
431 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
406 SND_SOC_DAPM_SUPPLY("HPCOM Protection", SUN8I_ADDA_PAEN_HP_CTRL, 432 SND_SOC_DAPM_SUPPLY("HPCOM Protection", SUN8I_ADDA_PAEN_HP_CTRL,
407 SUN8I_ADDA_PAEN_HP_CTRL_COMPTEN, 0, NULL, 0), 433 SUN8I_ADDA_PAEN_HP_CTRL_COMPTEN, 0, NULL, 0),
408 SND_SOC_DAPM_REG(snd_soc_dapm_supply, "HPCOM", SUN8I_ADDA_PAEN_HP_CTRL, 434 SND_SOC_DAPM_REG(snd_soc_dapm_supply, "HPCOM", SUN8I_ADDA_PAEN_HP_CTRL,