Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1570574

[PATCH v3 4/8] ASoC: sun8i-codec-analog: Add amplifier event to fix first delay

From Mylène Josserand <mylene.josserand@free-electrons.com>
Newsgroups linux.kernel
Subject [PATCH v3 4/8] ASoC: sun8i-codec-analog: Add amplifier event to fix first delay
Date 2017-01-31 11:20 +0100
Message-ID <t5DHB-7V9-49@gated-at.bofh.it> (permalink)
References <t5DxU-7RQ-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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>
---
 sound/soc/sunxi/sun8i-codec-analog.c | 30 ++++++++++++++++++++++++++++--
 1 file 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[] = {
 		      sun8i_codec_hp_src_enum),
 };
 
+static int sun8i_headphone_amp_event(struct snd_soc_dapm_widget *w,
+				     struct snd_kcontrol *k, int event)
+{
+	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
+
+	if (SND_SOC_DAPM_EVENT_ON(event)) {
+		snd_soc_component_update_bits(component, SUN8I_ADDA_PAEN_HP_CTRL,
+					      BIT(SUN8I_ADDA_PAEN_HP_CTRL_HPPAEN),
+					      BIT(SUN8I_ADDA_PAEN_HP_CTRL_HPPAEN));
+		/*
+		 * Need a delay to have the amplifier up. 700ms seems the best
+		 * compromise between the time to let the amplifier up and the
+		 * time not to feel this delay while playing a sound.
+		 */
+		msleep(700);
+	} else if (SND_SOC_DAPM_EVENT_OFF(event)) {
+		snd_soc_component_update_bits(component, SUN8I_ADDA_PAEN_HP_CTRL,
+					      BIT(SUN8I_ADDA_PAEN_HP_CTRL_HPPAEN),
+					      0x0);
+	}
+
+	return 0;
+}
+
 static const struct snd_soc_dapm_widget sun8i_codec_headphone_widgets[] = {
 	SND_SOC_DAPM_MUX("Headphone Source Playback Route",
 			 SND_SOC_NOPM, 0, 0, sun8i_codec_hp_src),
-	SND_SOC_DAPM_OUT_DRV("Headphone Amp", SUN8I_ADDA_PAEN_HP_CTRL,
-			     SUN8I_ADDA_PAEN_HP_CTRL_HPPAEN, 0, NULL, 0),
+	SND_SOC_DAPM_OUT_DRV_E("Headphone Amp", SUN8I_ADDA_PAEN_HP_CTRL,
+			       SUN8I_ADDA_PAEN_HP_CTRL_HPPAEN, 0, NULL, 0,
+			       sun8i_headphone_amp_event,
+			       SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
 	SND_SOC_DAPM_SUPPLY("HPCOM Protection", SUN8I_ADDA_PAEN_HP_CTRL,
 			    SUN8I_ADDA_PAEN_HP_CTRL_COMPTEN, 0, NULL, 0),
 	SND_SOC_DAPM_REG(snd_soc_dapm_supply, "HPCOM", SUN8I_ADDA_PAEN_HP_CTRL,
-- 
2.11.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v3 0/8] Add sun8i A33 audio driver Mylène Josserand          <mylene.josserand@free-electrons.com> - 2017-01-31 11:10 +0100
  [PATCH v3 8/8] ARM: dts: sun8i: sinlinx: Enable audio nodes Mylène Josserand          <mylene.josserand@free-electrons.com> - 2017-01-31 11:10 +0100
  [PATCH v3 1/8] ASoC: sun4i-i2s: Update binding documentation to include A31 Mylène Josserand          <mylene.josserand@free-electrons.com> - 2017-01-31 11:10 +0100
    Re: [PATCH v3 1/8] ASoC: sun4i-i2s: Update binding documentation to  include A31 Maxime Ripard <maxime.ripard@free-electrons.com> - 2017-01-31 12:10 +0100
    Re: [PATCH v3 1/8] ASoC: sun4i-i2s: Update binding documentation to  include A31 Mark Brown <broonie@kernel.org> - 2017-02-01 00:00 +0100
      Re: [PATCH v3 1/8] ASoC: sun4i-i2s: Update binding documentation to  include A31 Mylene Josserand <mylene.josserand@free-electrons.com> - 2017-02-01 08:50 +0100
        Re: [PATCH v3 1/8] ASoC: sun4i-i2s: Update binding documentation to  include A31 Mark Brown <broonie@kernel.org> - 2017-02-01 13:10 +0100
          Re: [PATCH v3 1/8] ASoC: sun4i-i2s: Update binding documentation to  include A31 Mylene Josserand <mylene.josserand@free-electrons.com> - 2017-02-01 16:20 +0100
    Re: [PATCH v3 1/8] ASoC: sun4i-i2s: Update binding documentation to  include A31 Rob Herring <robh@kernel.org> - 2017-02-01 18:30 +0100
  [PATCH v3 7/8] ARM: dts: sun8i: parrot: Enable audio nodes Mylène Josserand          <mylene.josserand@free-electrons.com> - 2017-01-31 11:10 +0100
  [PATCH v3 3/8] ASoC: Add sun8i digital audio codec Mylène Josserand          <mylene.josserand@free-electrons.com> - 2017-01-31 11:10 +0100
    Re: [PATCH v3 3/8] ASoC: Add sun8i digital audio codec Maxime Ripard <maxime.ripard@free-electrons.com> - 2017-01-31 11:40 +0100
    Re: [PATCH v3 3/8] ASoC: Add sun8i digital audio codec kbuild test robot <lkp@intel.com> - 2017-01-31 12:40 +0100
    [PATCH] ASoC: fix platform_no_drv_owner.cocci warnings kbuild test robot <lkp@intel.com> - 2017-01-31 12:40 +0100
  [PATCH v3 2/8] ASoC: sun4i-i2s: Add quirks to handle a31 compatible Mylène Josserand          <mylene.josserand@free-electrons.com> - 2017-01-31 11:10 +0100
    Re: [PATCH v3 2/8] ASoC: sun4i-i2s: Add quirks to handle a31  compatible Maxime Ripard <maxime.ripard@free-electrons.com> - 2017-01-31 11:40 +0100
  [PATCH v3 6/8] ARM: dts: sun8i: Add audio codec, dai and card for A33 Mylène Josserand          <mylene.josserand@free-electrons.com> - 2017-01-31 11:20 +0100
  [PATCH v3 5/8] ASoC: codecs: Add sun8i-a33 binding documentation Mylène Josserand          <mylene.josserand@free-electrons.com> - 2017-01-31 11:20 +0100
    Re: [PATCH v3 5/8] ASoC: codecs: Add sun8i-a33 binding documentation Maxime Ripard <maxime.ripard@free-electrons.com> - 2017-01-31 11:50 +0100
    Re: [PATCH v3 5/8] ASoC: codecs: Add sun8i-a33 binding documentation Rob Herring <robh@kernel.org> - 2017-02-01 18:40 +0100
  [PATCH v3 4/8] ASoC: sun8i-codec-analog: Add amplifier event to fix first delay Mylène Josserand          <mylene.josserand@free-electrons.com> - 2017-01-31 11:20 +0100
    Re: [PATCH v3 4/8] ASoC: sun8i-codec-analog: Add amplifier event to  fix first delay Maxime Ripard <maxime.ripard@free-electrons.com> - 2017-01-31 11:40 +0100

csiph-web