ANDROID: usb: gadget: f_audio_source: disable the CPU C-states upon playback
authorKonrad Leszczynski <konrad.leszczynski@intel.com>
Wed, 24 Feb 2016 10:47:12 +0000 (10:47 +0000)
committerAmit Pundir <amit.pundir@linaro.org>
Thu, 25 May 2017 11:07:25 +0000 (16:37 +0530)
Due to the issue with the isoc transfers being interrupted
by the CPU going into the idle state, the C-states will be
disabled for the playback time.

Change-Id: If4e52673606923d7e33a1d1dbe0192b8ad24f78c
Signed-off-by: Konrad Leszczynski <konrad.leszczynski@intel.com>
Signed-off-by: Russ Weight <russell.h.weight@intel.com>
drivers/usb/gadget/function/f_audio_source.c

index db7903d19c435e4c5b08c09270baa44c5c48b6b2..8124af33b7383b394974ae666ae5c230585653a9 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/device.h>
 #include <linux/usb/audio.h>
 #include <linux/wait.h>
+#include <linux/pm_qos.h>
 #include <sound/core.h>
 #include <sound/initval.h>
 #include <sound/pcm.h>
@@ -268,6 +269,8 @@ struct audio_dev {
        /* number of frames sent since start_time */
        s64                             frames_sent;
        struct audio_source_config      *config;
+       /* for creating and issuing QoS requests */
+       struct pm_qos_request pm_qos;
 };
 
 static inline struct audio_dev *func_to_audio(struct usb_function *f)
@@ -740,6 +743,10 @@ static int audio_pcm_open(struct snd_pcm_substream *substream)
        runtime->hw.channels_max = 2;
 
        audio->substream = substream;
+
+       /* Add the QoS request and set the latency to 0 */
+       pm_qos_add_request(&audio->pm_qos, PM_QOS_CPU_DMA_LATENCY, 0);
+
        return 0;
 }
 
@@ -749,6 +756,10 @@ static int audio_pcm_close(struct snd_pcm_substream *substream)
        unsigned long flags;
 
        spin_lock_irqsave(&audio->lock, flags);
+
+       /* Remove the QoS request */
+       pm_qos_remove_request(&audio->pm_qos);
+
        audio->substream = NULL;
        spin_unlock_irqrestore(&audio->lock, flags);