sgtl5000 latency

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

sgtl5000 latency

750 Views
dtran11
Contributor I

Using an iMX6 and SGTL5000 for audio, I noticed a 400ms delay when snd_pcm_prepare() is called. Looking at the sgtl5000.c codec driver, there is a sleep of 400ms when the power management powers up and powers down. For some reason the call to power up is always called on snd_pcm_prepare() even when the audio codec power never went down. I added a state to keep track of it in the codec driver as a workaround to not delay unless necessary. While this workaround works, I don't think it's the best solution. Does someone know why the power up section of code is always called in the driver? Thanks

+diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
+index 6668845..3aaf384 100644
+--- a/sound/soc/codecs/sgtl5000.c
++++ b/sound/soc/codecs/sgtl5000.c
+@@ -152,6 +152,8 @@ static int mic_bias_event(struct snd_soc_dapm_widget *w,
+ static int power_vag_event(struct snd_soc_dapm_widget *w,
+  struct snd_kcontrol *kcontrol, int event)
+ {
++ static bool is_power_up = false;
++
+  struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
+  const u32 mask = SGTL5000_DAC_POWERUP | SGTL5000_ADC_POWERUP;
+
+@@ -159,7 +161,12 @@ static int power_vag_event(struct snd_soc_dapm_widget *w,
+  case SND_SOC_DAPM_POST_PMU:
+   snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
+    SGTL5000_VAG_POWERUP, SGTL5000_VAG_POWERUP);
+-  msleep(400);
++
++  if (is_power_up == false)
++  {
++   msleep(400);
++   is_power_up = true;
++  }
+   break;
+
+  case SND_SOC_DAPM_PRE_PMD:
+@@ -173,6 +180,7 @@ static int power_vag_event(struct snd_soc_dapm_widget *w,
+    snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
+     SGTL5000_VAG_POWERUP, 0);
+    msleep(400);
++   is_power_up = false;
+   }
+   break;
+  default: 

0 Kudos
1 Reply

619 Views
igorpadykov
NXP Employee
NXP Employee

Hi Dat

seems power up and down is performed in driver for reducing overall board power consumption.

May be useful to check how power is handled in baremetal i.MX6 SDK sgtl5000 tests

(zip is available on https://community.nxp.com/thread/432859  )

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos