include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / sound / soc / davinci / davinci-mcasp.c
index 0a302e1080d9ec06553d77dfb12125b4fcece380..6c80cc35ecadeb5df31c90ee03c0a375933050fc 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/device.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/clk.h>
@@ -767,14 +768,26 @@ static int davinci_mcasp_trigger(struct snd_pcm_substream *substream,
        int ret = 0;
 
        switch (cmd) {
-       case SNDRV_PCM_TRIGGER_START:
        case SNDRV_PCM_TRIGGER_RESUME:
+       case SNDRV_PCM_TRIGGER_START:
        case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+               if (!dev->clk_active) {
+                       clk_enable(dev->clk);
+                       dev->clk_active = 1;
+               }
                davinci_mcasp_start(dev, substream->stream);
                break;
 
-       case SNDRV_PCM_TRIGGER_STOP:
        case SNDRV_PCM_TRIGGER_SUSPEND:
+               davinci_mcasp_stop(dev, substream->stream);
+               if (dev->clk_active) {
+                       clk_disable(dev->clk);
+                       dev->clk_active = 0;
+               }
+
+               break;
+
+       case SNDRV_PCM_TRIGGER_STOP:
        case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
                davinci_mcasp_stop(dev, substream->stream);
                break;
@@ -866,6 +879,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
        }
 
        clk_enable(dev->clk);
+       dev->clk_active = 1;
 
        dev->base = (void __iomem *)IO_ADDRESS(mem->start);
        dev->op_mode = pdata->op_mode;