greybus: audio: acquire wakelock during active playback
authorVaibhav Agarwal <vaibhav.agarwal@linaro.org>
Fri, 22 Apr 2016 18:13:19 +0000 (11:13 -0700)
committerAkash Choudhari <akashtc@google.com>
Fri, 22 Apr 2016 18:29:21 +0000 (11:29 -0700)
use pm_stay_awake & pm_relax to avoid suspend sequence during
active playback

testing Done:
Music Playback ongoing
$ cat /sys/devices/soc.0/qcom,ara-codec.82/power/wakeup_active
1
Music Playback stopped
$ cat /sys/devices/soc.0/qcom,ara-codec.82/power/wakeup_active
0

Tested-by: David Lin <dtwlin@google.com>
Reviewed-by: David Lin <dtwlin@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Akash Choudhari <akashtc@google.com>
Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
drivers/staging/greybus/audio_codec.c

index ba3bd36f0c0a4804869dd702af5ea387f59276fa..9ed35c4da2803aaca5d172b72e53f52030b3b525 100644 (file)
@@ -7,6 +7,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/pm_runtime.h>
 #include <sound/soc.h>
 #include <sound/pcm_params.h>
 #include <uapi/linux/input.h>
@@ -388,6 +389,8 @@ static int gbcodec_startup(struct snd_pcm_substream *substream,
        codec->stream[substream->stream].state = state;
        codec->stream[substream->stream].dai_name = dai->name;
        mutex_unlock(&codec->lock);
+       /* to prevent suspend in case of active audio */
+       pm_stay_awake(dai->dev);
 
        return ret;
 }
@@ -470,6 +473,7 @@ static void gbcodec_shutdown(struct snd_pcm_substream *substream,
        codec->stream[substream->stream].state = state;
        codec->stream[substream->stream].dai_name = NULL;
        mutex_unlock(&codec->lock);
+       pm_relax(dai->dev);
        return;
 }
 
@@ -1094,7 +1098,7 @@ static int gbcodec_probe(struct snd_soc_codec *codec)
        snd_soc_codec_set_drvdata(codec, info);
        gbcodec = info;
 
-       /* Empty function for now */
+        device_init_wakeup(codec->dev, 1);
        return 0;
 }