Skip to contentSkip to conversation

ASoC: DaVinci: Update suspend/resume support for McASP driver

PATCH Superseded Chaithrika U S 5 participants 7 messages Dec 2, 2009 – Dec 3, 2009 1 message not in the archive

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: DaVinci: Update suspend/resume support for McASP driver

Add clock enable and disable calls to resume and suspend respectively. Also add a member to the audio device data structure which tracks the clock status.

Tested on DA850/OMAP-L138 EVM. For the purpose of testing, the patches[1] which add suspend-to-RAM support to DA850/OMAP-L138 SoC were applied.

[1] http://linux.davincidsp.com/pipermail/davinci-linux-open-source/
2009-November/016958.html

---
Applies to ALSA GIT tree on branch topic/asoc at
http://git.kernel.org/?p=linux/kernel/git/tiwai/sound-2.6.git;a=shortlog;
h=topic/asoc

 sound/soc/davinci/davinci-mcasp.c |   18 ++++++++++++++++--
 sound/soc/davinci/davinci-mcasp.h |    1 +
 sound/soc/davinci/davinci-pcm.c   |    2 +-
 3 files changed, 18 insertions(+), 3 deletions(-)
sound/soc/davinci/davinci-mcasp.c +16 -2
index 0a302e1..0d263f1 100644
@@ -767,14 +767,27 @@ 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:
+		if (!dev->clk_active) {
+			clk_enable(dev->clk);
+			dev->clk_active = 1;
+		}
+
+	case SNDRV_PCM_TRIGGER_START:
 	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
 		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;
sound/soc/davinci/davinci-mcasp.h +1 -0
index 582c924..e755b51 100644
@@ -44,6 +44,7 @@ struct davinci_audio_dev {
 	int sample_rate;
 	struct clk *clk;
 	unsigned int codec_fmt;
+	u8 clk_active;
 
 	/* McASP specific data */
 	int	tdm_slots;
sound/soc/davinci/davinci-pcm.c +1 -1
index ad4d7f4..80c7fdf 100644
@@ -49,7 +49,7 @@ static void print_buf_info(int slot, char *name)
 static struct snd_pcm_hardware pcm_hardware_playback = {
 	.info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
 		 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
-		 SNDRV_PCM_INFO_PAUSE),
+		 SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
 	.formats = (SNDRV_PCM_FMTBIT_S16_LE),
 	.rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
 		  SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 |
Signature · 1 line
1.5.6
#1 lore raw

At Wed, 2 Dec 2009 12:39:00 +0530,

sound/soc/davinci/davinci-pcm.c static void print_buf_info(int slot, char *name) · line 52

Quoted 11 lines · Chaithrika U S
sound/soc/davinci/davinci-pcm.c +1 -1
index ad4d7f4..80c7fdf 100644
@@ -49,7 +49,7 @@ static void print_buf_info(int slot, char *name)
 static struct snd_pcm_hardware pcm_hardware_playback = {
 	.info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
 		 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
-		 SNDRV_PCM_INFO_PAUSE),
+		 SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),

Note that unless your driver supports the "full" resume, SNDRV_PCM_INFO_RESUME shouldn't be set. Here, the "full" resume means that the hardware gets back to a completely sane state and the PCM streams are resumed without extra PCM prepare call at PM resume. If the PCM (or whatever) needs another re-initialization (like in many cases), don't set this flag.

Just to be sure...

Takashi

#2 lore raw
Quoted 21 lines · Takashi Iwai

At Wed, 2 Dec 2009 12:39:00 +0530,

sound/soc/davinci/davinci-pcm.c static void print_buf_info(int slot, char *name) · line 52

Quoted 11 lines · Chaithrika U S
sound/soc/davinci/davinci-pcm.c +1 -1
index ad4d7f4..80c7fdf 100644
@@ -49,7 +49,7 @@ static void print_buf_info(int slot, char *name)
 static struct snd_pcm_hardware pcm_hardware_playback = {
 	.info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
 		 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
-		 SNDRV_PCM_INFO_PAUSE),
+		 SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),

Note that unless your driver supports the "full" resume, SNDRV_PCM_INFO_RESUME shouldn't be set. Here, the "full" resume means that the hardware gets back to a completely sane state and the PCM streams are resumed without extra PCM prepare call at PM resume. If the PCM (or whatever) needs another re-initialization (like in many cases), don't set this flag.

Quoted 5 lines

Just to be sure...

Takashi

PCM prepare call is not needed in this case. Testing was done with audio loopback and after a suspend/resume cycle the audio output was proper. Hope my understanding is correct. Is this test sufficient to prove that driver supports full resume?

Regards,
Chaithrika

#3 lore raw

At Thu, 3 Dec 2009 17:58:08 +0530,

Quoted 26 lines · Chaithrika U S
Quoted 24 lines · Takashi Iwai

At Wed, 2 Dec 2009 12:39:00 +0530,

sound/soc/davinci/davinci-pcm.c static void print_buf_info(int slot, char *name) · line 52

Quoted 11 lines · Chaithrika U S
sound/soc/davinci/davinci-pcm.c +1 -1
index ad4d7f4..80c7fdf 100644
@@ -49,7 +49,7 @@ static void print_buf_info(int slot, char *name)
 static struct snd_pcm_hardware pcm_hardware_playback = {
 	.info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
 		 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
-		 SNDRV_PCM_INFO_PAUSE),
+		 SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),

Note that unless your driver supports the "full" resume, SNDRV_PCM_INFO_RESUME shouldn't be set. Here, the "full" resume means that the hardware gets back to a completely sane state and the PCM streams are resumed without extra PCM prepare call at PM resume. If the PCM (or whatever) needs another re-initialization (like in many cases), don't set this flag.

Just to be sure...

Quoted 7 lines
Quoted 2 lines

Takashi

PCM prepare call is not needed in this case. Testing was done with audio loopback and after a suspend/resume cycle the audio output was proper. Hope my understanding is correct. Is this test sufficient to prove that driver supports full resume?

Yeah, if it worked with an actual app, it's fine :) That was just a slight concern.

thanks,

Takashi

#4 lore raw
Quoted 2 lines · Takashi Iwai

Yeah, if it worked with an actual app, it's fine :) That was just a slight concern.

Chaithrika, could you please fix the issue with the comment for fallthrough and resubmit?

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw
Quoted 8 lines · Mark Brown
Quoted 2 lines · Takashi Iwai

Yeah, if it worked with an actual app, it's fine :) That was just a slight concern.

Chaithrika, could you please fix the issue with the comment for fallthrough and resubmit?

Mark,

I will resubmit this patch soon.

Regards,
Chaithrika

#7 lore raw
In reply to Chaithrika U S

Hello.

Quoted 12 lines · Chaithrika U S

Add clock enable and disable calls to resume and suspend respectively. Also add a member to the audio device data structure which tracks the clock status.

Tested on DA850/OMAP-L138 EVM. For the purpose of testing, the patches[1] which add suspend-to-RAM support to DA850/OMAP-L138 SoC were applied.

[1] http://linux.davincidsp.com/pipermail/davinci-linux-open-source/
2009-November/016958.html

---

[...]

Quoted 5 lines
sound/soc/davinci/davinci-mcasp.c +0 -0
index 0a302e1..0d263f1 100644

sound/soc/davinci/davinci-mcasp.c static int davinci_mcasp_trigger(struct snd_pcm_substream *substream, · line 774

Quoted 9 lines
sound/soc/davinci/davinci-mcasp.c +4 -1
@@ -767,14 +767,27 @@ 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:
+		if (!dev->clk_active) {
+			clk_enable(dev->clk);
+			dev->clk_active = 1;
+		}

You should add a comment in the cases where *break* is ommitted
deliberately (if it indeed is), like:

		/* FALL THRU */

sound/soc/davinci/davinci-mcasp.c static int davinci_mcasp_trigger(struct snd_pcm_substream *substream, · line 780

Quoted 6 lines
sound/soc/davinci/davinci-mcasp.c +2 -0
+
+	case SNDRV_PCM_TRIGGER_START:
 	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
 		davinci_mcasp_start(dev, substream->stream);
 		break;
 

WBR, Sergei