All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: "Pierre-Louis Bossart" <pierre-louis.bossart@linux.intel.com>
Cc: "Akshu Agrawal" <Akshu.Agrawal@amd.com>,
	"moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER
	MANAGEM..."  <alsa-devel@alsa-project.org>,
	<Alexander.Deucher@amd.com>, <djkurtz@chromium.org>,
	"Liam Girdwood" <lgirdwood@gmail.com>,
	"Mark Brown" <broonie@kernel.org>,
	"open list" <linux-kernel@vger.kernel.org>
Subject: Re: [alsa-devel] [PATCH] ASoC: soc-pcm: Use delay set in pointer function
Date: Mon, 30 Jul 2018 17:32:21 +0200	[thread overview]
Message-ID: <s5hy3dsviwq.wl-tiwai@suse.de> (raw)
In-Reply-To: <dd4d3dc6-88f3-d53f-cd5c-5035c80be3da@linux.intel.com>

On Mon, 30 Jul 2018 17:15:44 +0200,
Pierre-Louis Bossart wrote:
> 
> On 7/27/18 11:28 PM, Agrawal, Akshu wrote:
> >
> >
> > On 7/27/2018 8:39 PM, Pierre-Louis Bossart wrote:
> >> On 7/27/18 5:13 AM, Akshu Agrawal wrote:
> >>> 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
> >>>
> >>> Also, in some cases cpu dai used is generic and the pcm
> >>> driver needs to set delay.
> >>>
> >>> This delay was getting lost and was overwritten by delays
> >>> from codec or cpu dai delay function if exposed.
> >>
> >> Humm, yes the runtime->delay set in the .pointer function would be lost
> >> without this change, but the delay would still be provided in the
> >> followup call to .delay.
> >> With your change, the same delay will be accounted for twice?
> >>
> >
> > It will not be accounted twice because no driver which is setting
> > runtime->delay is defining .delay op for cpu_dai. Vice versa is also
> > true, the drivers which define .delay for cpu_dai don't set
> > runtime->delay. And I think this is expected from drivers else it would
> > be a bug from their side.
> 
> what do you mean my 'no driver'? Can you clarify if this is based on
> analysis of the code or by-design. I don't recall having seen any
> guidelines on this topic, and it's quite likely that different people
> have different interpretation on how delay is supposed to be reported.

Currently the problem seems to be the ambiguity of delay callback.

Through a quick glance, Akshu's patch looks correct to me.  The delay
value that was calculated in some drivers aren't taken properly
because the current soc_pcm_pointer() presumes that the delay
calculation is provided *only* by delay callback.  The two drivers
suggested in the patch set runtime->delay in its pointer callback, and
these values are gone.

That said, if delay callback of CPU dai provides the additional delay,
the patch does correct thing.  OTOH, if CPU dai provides the base
delay instead, we need to clarify that it's rather a must; the delay
calculation in pointer callback becomes bogus in this scenario.


thanks,

Takashi

> 
> >
> > .delay for codec_dai anyway is different and has to be accounted for.
> >
> > Thanks,
> > Akshu
> >>>
> >>> Signed-off-by: Akshu Agrawal <akshu.agrawal@amd.com>
> >>> ---
> >>>    sound/soc/soc-pcm.c | 5 ++++-
> >>>    1 file changed, 4 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
> >>> index 98be04b..b1a2bc2 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 delay */
> >>> +	runtime->delay = 0;
> >>> +
> >>>    	for_each_rtdcom(rtd, rtdcom) {
> >>>    		component = rtdcom->component;
> >>>    @@ -1203,7 +1206,7 @@ static snd_pcm_uframes_t
> >>> soc_pcm_pointer(struct snd_pcm_substream *substream)
> >>>    	}
> >>>    	delay += codec_delay;
> >>>    -	runtime->delay = delay;
> >>> +	runtime->delay += delay;
> >>>       	return offset;
> >>>    }
> >>>
> >>
> > _______________________________________________
> > Alsa-devel mailing list
> > Alsa-devel@alsa-project.org
> > http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> >
> 
> 

WARNING: multiple messages have this Message-ID (diff)
From: Takashi Iwai <tiwai@suse.de>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Akshu Agrawal <Akshu.Agrawal@amd.com>,
	"moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER
	MANAGEM..." <alsa-devel@alsa-project.org>,
	Alexander.Deucher@amd.com, djkurtz@chromium.org,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [alsa-devel] [PATCH] ASoC: soc-pcm: Use delay set in pointer function
Date: Mon, 30 Jul 2018 17:32:21 +0200	[thread overview]
Message-ID: <s5hy3dsviwq.wl-tiwai@suse.de> (raw)
In-Reply-To: <dd4d3dc6-88f3-d53f-cd5c-5035c80be3da@linux.intel.com>

On Mon, 30 Jul 2018 17:15:44 +0200,
Pierre-Louis Bossart wrote:
> 
> On 7/27/18 11:28 PM, Agrawal, Akshu wrote:
> >
> >
> > On 7/27/2018 8:39 PM, Pierre-Louis Bossart wrote:
> >> On 7/27/18 5:13 AM, Akshu Agrawal wrote:
> >>> 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
> >>>
> >>> Also, in some cases cpu dai used is generic and the pcm
> >>> driver needs to set delay.
> >>>
> >>> This delay was getting lost and was overwritten by delays
> >>> from codec or cpu dai delay function if exposed.
> >>
> >> Humm, yes the runtime->delay set in the .pointer function would be lost
> >> without this change, but the delay would still be provided in the
> >> followup call to .delay.
> >> With your change, the same delay will be accounted for twice?
> >>
> >
> > It will not be accounted twice because no driver which is setting
> > runtime->delay is defining .delay op for cpu_dai. Vice versa is also
> > true, the drivers which define .delay for cpu_dai don't set
> > runtime->delay. And I think this is expected from drivers else it would
> > be a bug from their side.
> 
> what do you mean my 'no driver'? Can you clarify if this is based on
> analysis of the code or by-design. I don't recall having seen any
> guidelines on this topic, and it's quite likely that different people
> have different interpretation on how delay is supposed to be reported.

Currently the problem seems to be the ambiguity of delay callback.

Through a quick glance, Akshu's patch looks correct to me.  The delay
value that was calculated in some drivers aren't taken properly
because the current soc_pcm_pointer() presumes that the delay
calculation is provided *only* by delay callback.  The two drivers
suggested in the patch set runtime->delay in its pointer callback, and
these values are gone.

That said, if delay callback of CPU dai provides the additional delay,
the patch does correct thing.  OTOH, if CPU dai provides the base
delay instead, we need to clarify that it's rather a must; the delay
calculation in pointer callback becomes bogus in this scenario.


thanks,

Takashi

> 
> >
> > .delay for codec_dai anyway is different and has to be accounted for.
> >
> > Thanks,
> > Akshu
> >>>
> >>> Signed-off-by: Akshu Agrawal <akshu.agrawal@amd.com>
> >>> ---
> >>>    sound/soc/soc-pcm.c | 5 ++++-
> >>>    1 file changed, 4 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
> >>> index 98be04b..b1a2bc2 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 delay */
> >>> +	runtime->delay = 0;
> >>> +
> >>>    	for_each_rtdcom(rtd, rtdcom) {
> >>>    		component = rtdcom->component;
> >>>    @@ -1203,7 +1206,7 @@ static snd_pcm_uframes_t
> >>> soc_pcm_pointer(struct snd_pcm_substream *substream)
> >>>    	}
> >>>    	delay += codec_delay;
> >>>    -	runtime->delay = delay;
> >>> +	runtime->delay += delay;
> >>>       	return offset;
> >>>    }
> >>>
> >>
> > _______________________________________________
> > Alsa-devel mailing list
> > Alsa-devel@alsa-project.org
> > http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> >
> 
> 

  reply	other threads:[~2018-07-30 15:32 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-27 10:13 [PATCH] ASoC: soc-pcm: Use delay set in pointer function Akshu Agrawal
2018-07-27 10:13 ` Akshu Agrawal
2018-07-27 15:09 ` [alsa-devel] " Pierre-Louis Bossart
2018-07-27 15:09   ` Pierre-Louis Bossart
2018-07-28  4:28   ` Agrawal, Akshu
2018-07-28  4:28     ` Agrawal, Akshu
2018-07-30 15:15     ` [alsa-devel] " Pierre-Louis Bossart
2018-07-30 15:15       ` Pierre-Louis Bossart
2018-07-30 15:32       ` Takashi Iwai [this message]
2018-07-30 15:32         ` Takashi Iwai
2018-07-30 15:50         ` Mark Brown
2018-07-30 15:50           ` Mark Brown
2018-07-31  1:25           ` [alsa-devel] " Agrawal, Akshu
2018-07-31  1:25             ` Agrawal, Akshu
2018-07-31  5:30             ` [alsa-devel] " Takashi Iwai
2018-07-31  5:30               ` Takashi Iwai
2018-07-31  9:06               ` Agrawal, Akshu
2018-07-31  9:06                 ` Agrawal, Akshu
2018-07-31  9:25                 ` [alsa-devel] " Takashi Iwai
2018-07-31  9:25                   ` Takashi Iwai
2018-07-31 10:19                   ` Mark Brown
2018-07-31 10:19                     ` Mark Brown
2018-07-31 10:32                     ` [alsa-devel] " Takashi Iwai
2018-07-31 10:32                       ` Takashi Iwai
2018-07-31 13:12                       ` Mark Brown
2018-07-31 13:12                         ` Mark Brown
2018-07-31 13:29                         ` [alsa-devel] " Takashi Iwai
2018-07-31 13:29                           ` Takashi Iwai
2018-07-31 13:51                           ` Mark Brown
2018-07-31 13:51                             ` Mark Brown
2018-07-31 13:56                             ` [alsa-devel] " Takashi Iwai
2018-07-31 13:56                               ` Takashi Iwai
2018-07-31 14:40                               ` Mark Brown
2018-07-31 14:40                                 ` Mark Brown
2018-08-01  4:01                                 ` [alsa-devel] " Agrawal, Akshu
2018-08-01  4:01                                   ` Agrawal, Akshu
2018-07-31 10:03               ` [alsa-devel] " Mark Brown
2018-07-31 10:03                 ` Mark Brown
2018-07-30 10:54 ` Mark Brown
2018-07-30 10:54   ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hy3dsviwq.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=Akshu.Agrawal@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=djkurtz@chromium.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pierre-louis.bossart@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.