linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] ASoC: soc-pcm: Use delay set in component pointer function
@ 2018-08-01 10:07 Akshu Agrawal
  2018-08-01 12:03 ` Takashi Iwai
  2018-08-01 13:31 ` Applied "ASoC: soc-pcm: Use delay set in component pointer function" to the asoc tree Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Akshu Agrawal @ 2018-08-01 10:07 UTC (permalink / raw)
  Cc: djkurtz, akshu.agrawal, Alexander.Deucher, Liam Girdwood,
	Mark Brown, Jaroslav Kysela, Takashi Iwai,
	moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
	open list

Take into account the base delay set in pointer callback.

There are cases where a pointer function populates
runtime->delay, such as:
./sound/pci/hda/hda_controller.c
./sound/soc/intel/atom/sst-mfld-platform-pcm.c

This delay was getting lost and was overwritten by delays
from codec or cpu dai delay function if exposed.

Now,
Total delay = base delay + cpu_dai delay + codec_dai delay

Signed-off-by: Akshu Agrawal <akshu.agrawal@amd.com>
---
 sound/soc/soc-pcm.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 98be04b..e8b98bfd 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -1179,6 +1179,9 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream)
 	snd_pcm_sframes_t codec_delay = 0;
 	int i;
 
+	/* clearing the previous total delay */
+	runtime->delay = 0;
+
 	for_each_rtdcom(rtd, rtdcom) {
 		component = rtdcom->component;
 
@@ -1190,6 +1193,8 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream)
 		offset = component->driver->ops->pointer(substream);
 		break;
 	}
+	/* base delay if assigned in pointer callback */
+	delay = runtime->delay;
 
 	if (cpu_dai->driver->ops->delay)
 		delay += cpu_dai->driver->ops->delay(substream, cpu_dai);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] ASoC: soc-pcm: Use delay set in component pointer function
  2018-08-01 10:07 [PATCH v2] ASoC: soc-pcm: Use delay set in component pointer function Akshu Agrawal
@ 2018-08-01 12:03 ` Takashi Iwai
  2018-08-01 13:31 ` Applied "ASoC: soc-pcm: Use delay set in component pointer function" to the asoc tree Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2018-08-01 12:03 UTC (permalink / raw)
  To: Akshu Agrawal
  Cc: moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
	Alexander.Deucher, djkurtz, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, open list

On Wed, 01 Aug 2018 12:07:33 +0200,
Akshu Agrawal wrote:
> 
> Take into account the base delay set in pointer callback.
> 
> There are cases where a pointer function populates
> runtime->delay, such as:
> ./sound/pci/hda/hda_controller.c
> ./sound/soc/intel/atom/sst-mfld-platform-pcm.c
> 
> This delay was getting lost and was overwritten by delays
> from codec or cpu dai delay function if exposed.
> 
> Now,
> Total delay = base delay + cpu_dai delay + codec_dai delay
> 
> Signed-off-by: Akshu Agrawal <akshu.agrawal@amd.com>

Reviewed-by: Takashi Iwai <tiwai@suse.de>


thanks,

Takashi


> ---
>  sound/soc/soc-pcm.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
> index 98be04b..e8b98bfd 100644
> --- a/sound/soc/soc-pcm.c
> +++ b/sound/soc/soc-pcm.c
> @@ -1179,6 +1179,9 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream)
>  	snd_pcm_sframes_t codec_delay = 0;
>  	int i;
>  
> +	/* clearing the previous total delay */
> +	runtime->delay = 0;
> +
>  	for_each_rtdcom(rtd, rtdcom) {
>  		component = rtdcom->component;
>  
> @@ -1190,6 +1193,8 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream)
>  		offset = component->driver->ops->pointer(substream);
>  		break;
>  	}
> +	/* base delay if assigned in pointer callback */
> +	delay = runtime->delay;
>  
>  	if (cpu_dai->driver->ops->delay)
>  		delay += cpu_dai->driver->ops->delay(substream, cpu_dai);
> -- 
> 1.9.1
> 
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Applied "ASoC: soc-pcm: Use delay set in component pointer function" to the asoc tree
  2018-08-01 10:07 [PATCH v2] ASoC: soc-pcm: Use delay set in component pointer function Akshu Agrawal
  2018-08-01 12:03 ` Takashi Iwai
@ 2018-08-01 13:31 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2018-08-01 13:31 UTC (permalink / raw)
  To: Akshu Agrawal
  Cc: Mark Brown,
	moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
	open list, Takashi Iwai, Liam Girdwood, djkurtz, Mark Brown,
	Alexander.Deucher, akshu.agrawal, alsa-devel

The patch

   ASoC: soc-pcm: Use delay set in component pointer function

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

From 9fb4c2bf130b922c77c16a8368732699799c40de Mon Sep 17 00:00:00 2001
From: Akshu Agrawal <akshu.agrawal@amd.com>
Date: Wed, 1 Aug 2018 15:37:33 +0530
Subject: [PATCH] ASoC: soc-pcm: Use delay set in component pointer function

Take into account the base delay set in pointer callback.

There are cases where a pointer function populates
runtime->delay, such as:
./sound/pci/hda/hda_controller.c
./sound/soc/intel/atom/sst-mfld-platform-pcm.c

This delay was getting lost and was overwritten by delays
from codec or cpu dai delay function if exposed.

Now,
Total delay = base delay + cpu_dai delay + codec_dai delay

Signed-off-by: Akshu Agrawal <akshu.agrawal@amd.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/soc-pcm.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 4019bc10897c..9833e53754cb 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -1179,6 +1179,9 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream)
 	snd_pcm_sframes_t codec_delay = 0;
 	int i;
 
+	/* clearing the previous total delay */
+	runtime->delay = 0;
+
 	for_each_rtdcom(rtd, rtdcom) {
 		component = rtdcom->component;
 
@@ -1190,6 +1193,8 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream)
 		offset = component->driver->ops->pointer(substream);
 		break;
 	}
+	/* base delay if assigned in pointer callback */
+	delay = runtime->delay;
 
 	if (cpu_dai->driver->ops->delay)
 		delay += cpu_dai->driver->ops->delay(substream, cpu_dai);
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-08-01 13:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-01 10:07 [PATCH v2] ASoC: soc-pcm: Use delay set in component pointer function Akshu Agrawal
2018-08-01 12:03 ` Takashi Iwai
2018-08-01 13:31 ` Applied "ASoC: soc-pcm: Use delay set in component pointer function" to the asoc tree Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).