All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Dong Aisheng-B29396 <B29396@freescale.com>
Cc: "alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
	"s.hauer@pengutronix.de" <s.hauer@pengutronix.de>,
	"broonie@opensource.wolfsonmicro.com"
	<broonie@opensource.wolfsonmicro.com>,
	"w.sang@pengutronix.de" <w.sang@pengutronix.de>,
	"lrg@ti.com" <lrg@ti.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [RFC PATCH 1/1] ASoC: soc-core: symmetry checking for each DAIs separately
Date: Fri, 26 Aug 2011 15:32:32 +0200	[thread overview]
Message-ID: <4E57A070.5090805@metafoo.de> (raw)
In-Reply-To: <65EE16ACC360FA4D99C96DC085B3F7722260BF@039-SN1MPN1-001.039d.mgd.msft.net>

On 08/26/2011 03:17 PM, Dong Aisheng-B29396 wrote:
>> -----Original Message-----
>> From: Lars-Peter Clausen [mailto:lars@metafoo.de]
>> Sent: Friday, August 26, 2011 7:24 PM
>> To: Dong Aisheng-B29396
>> Cc: alsa-devel@alsa-project.org; linux-arm-kernel@lists.infradead.org;
>> broonie@opensource.wolfsonmicro.com; lrg@ti.com; s.hauer@pengutronix.de;
>> w.sang@pengutronix.de
>> Subject: Re: [RFC PATCH 1/1] ASoC: soc-core: symmetry checking for each
>> DAIs separately
>>
>> On 08/26/2011 11:35 AM, Dong Aisheng wrote:
>>> [...]
>>>  	/* runtime devices */
>>> diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index
>>> 1aee9fc..3f7ded7 100644
>>> --- a/sound/soc/soc-pcm.c
>>> +++ b/sound/soc/soc-pcm.c
>>> @@ -32,33 +32,54 @@ static int soc_pcm_apply_symmetry(struct
>> snd_pcm_substream *substream)
>>>  	struct snd_soc_pcm_runtime *rtd = substream->private_data;
>>>  	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
>>>  	struct snd_soc_dai *codec_dai = rtd->codec_dai;
>>> +	unsigned int race;
>>> +	unsigned int force_rate;
>>>  	int ret;
>>>
>>> +	race = 0;
>>> +	force_rate = 0;
>>> +
>>>  	if (!codec_dai->driver->symmetric_rates &&
>>>  	    !cpu_dai->driver->symmetric_rates &&
>>>  	    !rtd->dai_link->symmetric_rates)
>>>  		return 0;
>>>
>>> +	if (codec_dai->active && codec_dai->driver->symmetric_rates ||
>>> +	     codec_dai->active && rtd->dai_link->symmetric_rates) {
>>
>> parenthesis, please, when mixing && and || in the same expression. Makes
>> it easier to comprehend and protects against accidental mistakes.
> Thanks for reminder, I will take it.
> 
>>> +		if (codec_dai->rate != 0)
>>> +			force_rate = codec_dai->rate;
>>> +		else
>>> +			race = 1;
>>> +	}
>>> +
>>> +	if (cpu_dai->active && cpu_dai->driver->symmetric_rates ||
>>> +	    codec_dai->active && rtd->dai_link->symmetric_rates) {
>>> +		if (cpu_dai->rate != 0)
>>> +			force_rate = cpu_dai->rate;
>>> +		else
>>> +			race = 1;
>>> +	}
>>> +
>>
>> If both dais are active and require symmetry we should call
>> snd_pcm_hw_constraint_minmax for both rates. This will ensure that if
>> both are already active and are running at different rates that there
>> will be no valid rate for the new pcm stream. Maybe extend this function
>> to take the dai as an parameter and call it twice, once for the codec_dai
>> and once for the cpu_dai.
>> This would allow to keep the current structure of the function.
> I was doing like the way as you said before, however, I found the question
> is that do we have to call snd_pcm_hw_constraint_minmax for the same substream
> two times?
> 
> I just thought they should be running at the same rate if both are active.
> Can you help point out in which case they may be different?
>  

This might be some rather obscure and theoretical setup but image the following
situation:

A   C
 \ / \
  B   D

The link between A and B and the link between C and D are active and running at
different rates. Activating the link between C and B should fail, since both
are already active and are running at different rates.

WARNING: multiple messages have this Message-ID (diff)
From: lars@metafoo.de (Lars-Peter Clausen)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 1/1] ASoC: soc-core: symmetry checking for each DAIs separately
Date: Fri, 26 Aug 2011 15:32:32 +0200	[thread overview]
Message-ID: <4E57A070.5090805@metafoo.de> (raw)
In-Reply-To: <65EE16ACC360FA4D99C96DC085B3F7722260BF@039-SN1MPN1-001.039d.mgd.msft.net>

On 08/26/2011 03:17 PM, Dong Aisheng-B29396 wrote:
>> -----Original Message-----
>> From: Lars-Peter Clausen [mailto:lars at metafoo.de]
>> Sent: Friday, August 26, 2011 7:24 PM
>> To: Dong Aisheng-B29396
>> Cc: alsa-devel at alsa-project.org; linux-arm-kernel at lists.infradead.org;
>> broonie at opensource.wolfsonmicro.com; lrg at ti.com; s.hauer at pengutronix.de;
>> w.sang at pengutronix.de
>> Subject: Re: [RFC PATCH 1/1] ASoC: soc-core: symmetry checking for each
>> DAIs separately
>>
>> On 08/26/2011 11:35 AM, Dong Aisheng wrote:
>>> [...]
>>>  	/* runtime devices */
>>> diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index
>>> 1aee9fc..3f7ded7 100644
>>> --- a/sound/soc/soc-pcm.c
>>> +++ b/sound/soc/soc-pcm.c
>>> @@ -32,33 +32,54 @@ static int soc_pcm_apply_symmetry(struct
>> snd_pcm_substream *substream)
>>>  	struct snd_soc_pcm_runtime *rtd = substream->private_data;
>>>  	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
>>>  	struct snd_soc_dai *codec_dai = rtd->codec_dai;
>>> +	unsigned int race;
>>> +	unsigned int force_rate;
>>>  	int ret;
>>>
>>> +	race = 0;
>>> +	force_rate = 0;
>>> +
>>>  	if (!codec_dai->driver->symmetric_rates &&
>>>  	    !cpu_dai->driver->symmetric_rates &&
>>>  	    !rtd->dai_link->symmetric_rates)
>>>  		return 0;
>>>
>>> +	if (codec_dai->active && codec_dai->driver->symmetric_rates ||
>>> +	     codec_dai->active && rtd->dai_link->symmetric_rates) {
>>
>> parenthesis, please, when mixing && and || in the same expression. Makes
>> it easier to comprehend and protects against accidental mistakes.
> Thanks for reminder, I will take it.
> 
>>> +		if (codec_dai->rate != 0)
>>> +			force_rate = codec_dai->rate;
>>> +		else
>>> +			race = 1;
>>> +	}
>>> +
>>> +	if (cpu_dai->active && cpu_dai->driver->symmetric_rates ||
>>> +	    codec_dai->active && rtd->dai_link->symmetric_rates) {
>>> +		if (cpu_dai->rate != 0)
>>> +			force_rate = cpu_dai->rate;
>>> +		else
>>> +			race = 1;
>>> +	}
>>> +
>>
>> If both dais are active and require symmetry we should call
>> snd_pcm_hw_constraint_minmax for both rates. This will ensure that if
>> both are already active and are running at different rates that there
>> will be no valid rate for the new pcm stream. Maybe extend this function
>> to take the dai as an parameter and call it twice, once for the codec_dai
>> and once for the cpu_dai.
>> This would allow to keep the current structure of the function.
> I was doing like the way as you said before, however, I found the question
> is that do we have to call snd_pcm_hw_constraint_minmax for the same substream
> two times?
> 
> I just thought they should be running at the same rate if both are active.
> Can you help point out in which case they may be different?
>  

This might be some rather obscure and theoretical setup but image the following
situation:

A   C
 \ / \
  B   D

The link between A and B and the link between C and D are active and running at
different rates. Activating the link between C and B should fail, since both
are already active and are running at different rates.

  reply	other threads:[~2011-08-26 13:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-26  9:35 [RFC PATCH 1/1] ASoC: soc-core: symmetry checking for each DAIs separately Dong Aisheng
2011-08-26  9:35 ` Dong Aisheng
2011-08-26  9:39 ` Dong Aisheng-B29396
2011-08-26  9:39   ` Dong Aisheng-B29396
2011-08-26 11:23 ` Lars-Peter Clausen
2011-08-26 11:23   ` Lars-Peter Clausen
2011-08-26 13:17   ` Dong Aisheng-B29396
2011-08-26 13:17     ` Dong Aisheng-B29396
2011-08-26 13:32     ` Lars-Peter Clausen [this message]
2011-08-26 13:32       ` Lars-Peter Clausen
2011-08-26 13:57       ` Dong Aisheng-B29396
2011-08-26 13:57         ` Dong Aisheng-B29396
2011-08-26 14:06         ` Lars-Peter Clausen
2011-08-26 14:06           ` Lars-Peter Clausen

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=4E57A070.5090805@metafoo.de \
    --to=lars@metafoo.de \
    --cc=B29396@freescale.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=lrg@ti.com \
    --cc=s.hauer@pengutronix.de \
    --cc=w.sang@pengutronix.de \
    /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.