ASoC: Handle ignore_pmdown_time for CODEC to CODEC links
authorLars-Peter Clausen <lars@metafoo.de>
Wed, 5 Mar 2014 12:17:42 +0000 (13:17 +0100)
committerMark Brown <broonie@linaro.org>
Thu, 6 Mar 2014 09:04:55 +0000 (17:04 +0800)
For CODEC to CODEC links we should only immediately power down if both CODECs
are configured to ignore the power down delay. Factor the logic for this
into a helper function that can be used for both compressed and normal PCMs.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
include/sound/soc.h
sound/soc/soc-compress.c
sound/soc/soc-pcm.c

index 9a001472b96a4bf8a11c8c129543060fdb75c869..93c31c70b90a4c3e71dbd2e55ab53418671f85d7 100644 (file)
@@ -413,6 +413,8 @@ struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card,
 struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card,
                const char *dai_link);
 
+bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd);
+
 /* Utility functions to get clock rates from various things */
 int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
 int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params);
index 5e9690c85d8f5c9afc248830ce6007d0890f19dc..ef585af4081b0b83d4b9471bee097df4673071e9 100644 (file)
@@ -235,8 +235,7 @@ static int soc_compr_free(struct snd_compr_stream *cstream)
        cpu_dai->runtime = NULL;
 
        if (cstream->direction == SND_COMPRESS_PLAYBACK) {
-               if (!rtd->pmdown_time || codec->ignore_pmdown_time ||
-                   rtd->dai_link->ignore_pmdown_time) {
+               if (snd_soc_runtime_ignore_pmdown_time(rtd)) {
                        snd_soc_dapm_stream_event(rtd,
                                        SNDRV_PCM_STREAM_PLAYBACK,
                                        SND_SOC_DAPM_STREAM_STOP);
index 47e1ce771e65e0403e1ab743c677083c98452a8c..f098c8007cbe336a83f325a72613798012794253 100644 (file)
 
 #define DPCM_MAX_BE_USERS      8
 
+/**
+ * snd_soc_runtime_ignore_pmdown_time() - Check whether to ignore the power down delay
+ * @rtd: The ASoC PCM runtime that should be checked.
+ *
+ * This function checks whether the power down delay should be ignored for a
+ * specific PCM runtime. Returns true if the delay is 0, if it the DAI link has
+ * been configured to ignore the delay, or if none of the components benefits
+ * from having the delay.
+ */
+bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd)
+{
+       bool ignore = true;
+
+       if (!rtd->pmdown_time || rtd->dai_link->ignore_pmdown_time)
+               return true;
+
+       if (rtd->cpu_dai->codec)
+               ignore &= rtd->cpu_dai->codec->ignore_pmdown_time;
+
+       ignore &= rtd->codec_dai->codec->ignore_pmdown_time;
+
+       return ignore;
+}
+
 /**
  * snd_soc_set_runtime_hwparams - set the runtime hardware parameters
  * @substream: the pcm substream
@@ -496,8 +520,7 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
        cpu_dai->runtime = NULL;
 
        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-               if (!rtd->pmdown_time || codec->ignore_pmdown_time ||
-                   rtd->dai_link->ignore_pmdown_time) {
+               if (snd_soc_runtime_ignore_pmdown_time(rtd)) {
                        /* powered down playback stream now */
                        snd_soc_dapm_stream_event(rtd,
                                                  SNDRV_PCM_STREAM_PLAYBACK,