pci: hda: Limit sleep time when codec is off
Sumit Bhattacharya [Tue, 1 Dec 2015 07:17:07 +0000 (12:17 +0530)]
Limit sleep time to 10ms if none of the HDA pcm streams are
active. This will reduce suspend time for HDA when HDMI is
not connected.

Bug 200063987

Change-Id: I27a57486f51dd97dac18967e376c3c05ecd32539
Signed-off-by: Sumit Bhattacharya <sumitb@nvidia.com>
Reviewed-on: http://git-master/r/839657
Reviewed-by: Sanjay Singh Chauhan <schauhan@nvidia.com>
Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com>
GVS: Gerrit_Virtual_Submit

sound/pci/hda/hda_codec.c

index 7461cdb..8eda032 100644 (file)
@@ -3862,8 +3862,24 @@ static unsigned int hda_set_power_state(struct hda_codec *codec,
 
        /* this delay seems necessary to avoid click noise at power-down */
        if (power_state == AC_PWRST_D3) {
+#ifndef CONFIG_SND_HDA_PLATFORM_NVIDIA_TEGRA
                /* transition time less than 10ms for power down */
                msleep(codec->epss ? 10 : 100);
+#else
+               int pcm, hda_active = 0;
+
+               for (pcm = 0; pcm < codec->num_pcms; pcm++) {
+                       struct hda_pcm *cpcm = &codec->pcm_info[pcm];
+                       if (!cpcm->pcm)
+                               continue;
+                       if (cpcm->pcm->streams[0].substream_opened ||
+                           cpcm->pcm->streams[1].substream_opened) {
+                               hda_active = 1;
+                               break;
+                       }
+               }
+               msleep(codec->epss || !hda_active ? 10 : 100);
+#endif
        }
 
        /* repeat power states setting at most 10 times*/