alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Jerome Brunet <jbrunet@baylibre.com>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	alsa-devel@alsa-project.org
Cc: tiwai@suse.de, broonie@kernel.org
Subject: Re: [PATCH] ASoC: core: use less strict tests for dailink capabilities
Date: Fri, 24 Jul 2020 10:31:43 +0200	[thread overview]
Message-ID: <1jlfj98gb4.fsf@starbuckisacylon.baylibre.com> (raw)
In-Reply-To: <20200723180533.220312-1-pierre-louis.bossart@linux.intel.com>


On Thu 23 Jul 2020 at 20:05, Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> wrote:

> Previous updates to set dailink capabilities and check dailink
> capabilities were based on a flawed assumption that all dais support
> the same capabilities as the dailink. This is true for TDM
> configurations

Actually it is not true for TDM either, having codecs with different
playback/capture caps is valid with TDM as well

> but existing configurations use an amplifier and a
> capture device on the same dailink, and the tests would prevent the
> card from probing.
>
> This patch modifies the snd_soc_dai_link_set_capabilities()
> helper so that the dpcm_playback (resp. dpcm_capture) dailink
> capabilities are set if at least one dai supports playback (resp. capture).
>
> Likewise the checks are modified so that an error is reported only
> when dpcm_playback (resp. dpcm_capture) is set but none of the CPU
> DAIs support playback (resp. capture).

This was not is the original proposal you sent ...

>
> Fixes: 25612477d20b5 ('ASoC: soc-dai: set dai_link dpcm_ flags with a helper')
> Fixes: b73287f0b0745 ('ASoC: soc-pcm: dpcm: fix playback/capture checks')
> Suggested-by: Jerome Brunet <jbrunet@baylibre.com>
> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> ---
>  sound/soc/soc-dai.c | 16 +++++++++-------
>  sound/soc/soc-pcm.c | 42 ++++++++++++++++++++++++------------------
>  2 files changed, 33 insertions(+), 25 deletions(-)
>
> diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
> index 98f0c98b06bb..ef1700e5e1bf 100644
> --- a/sound/soc/soc-dai.c
> +++ b/sound/soc/soc-dai.c
> @@ -402,28 +402,30 @@ void snd_soc_dai_link_set_capabilities(struct snd_soc_dai_link *dai_link)
>  	struct snd_soc_dai_link_component *codec;
>  	struct snd_soc_dai *dai;
>  	bool supported[SNDRV_PCM_STREAM_LAST + 1];
> +	bool supported_cpu;
> +	bool supported_codec;
>  	int direction;
>  	int i;
>  
>  	for_each_pcm_streams(direction) {
> -		supported[direction] = true;
> +		supported_cpu = false;
> +		supported_codec = false;
>  
>  		for_each_link_cpus(dai_link, i, cpu) {
>  			dai = snd_soc_find_dai(cpu);
> -			if (!dai || !snd_soc_dai_stream_valid(dai, direction)) {
> -				supported[direction] = false;
> +			if (dai && snd_soc_dai_stream_valid(dai, direction)) {
> +				supported_cpu = true;
>  				break;
>  			}
>  		}
> -		if (!supported[direction])
> -			continue;
>  		for_each_link_codecs(dai_link, i, codec) {
>  			dai = snd_soc_find_dai(codec);
> -			if (!dai || !snd_soc_dai_stream_valid(dai, direction)) {
> -				supported[direction] = false;
> +			if (dai && snd_soc_dai_stream_valid(dai, direction)) {
> +				supported_codec = true;
>  				break;
>  			}
>  		}
> +		supported[direction] = supported_cpu && supported_codec;
>  	}
>  
>  	dai_link->dpcm_playback = supported[SNDRV_PCM_STREAM_PLAYBACK];
> diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
> index f2c7c85ad40c..aac61df0c50e 100644
> --- a/sound/soc/soc-pcm.c
> +++ b/sound/soc/soc-pcm.c
> @@ -2743,30 +2743,36 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
>  		if (rtd->dai_link->dpcm_playback) {
>  			stream = SNDRV_PCM_STREAM_PLAYBACK;
>  
> -			for_each_rtd_cpu_dais(rtd, i, cpu_dai)
> -				if (!snd_soc_dai_stream_valid(cpu_dai,
> -							      stream)) {
> -					dev_err(rtd->card->dev,
> -						"CPU DAI %s for rtd %s does not support playback\n",
> -						cpu_dai->name,
> -						rtd->dai_link->stream_name);
> -					return -EINVAL;
> +			for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
> +				if (snd_soc_dai_stream_valid(cpu_dai, stream)) {
> +					playback = 1;
> +					break;
>  				}
> -			playback = 1;
> +			}
> +
> +			if (!playback) {
> +				dev_err(rtd->card->dev,
> +					"No CPU DAIs support playback for stream %s\n",
> +					rtd->dai_link->stream_name);
> +				return -EINVAL;
> +			}

Again, this is changing the original meaning of the flag from "playback
allowed" to "playback required".

This patch (or the orignal) does not explain why this change of meaning
is necessary ? The point I was making here [0] still stands.

If your evil plan is to get rid of 2 of the 4 flags, why go through the
trouble of the changing the meaning and effect of one them ?

[0]: https://lore.kernel.org/r/1j1rla9s22.fsf@starbuckisacylon.baylibre.com

>  		}
>  		if (rtd->dai_link->dpcm_capture) {
>  			stream = SNDRV_PCM_STREAM_CAPTURE;
>  
> -			for_each_rtd_cpu_dais(rtd, i, cpu_dai)
> -				if (!snd_soc_dai_stream_valid(cpu_dai,
> -							      stream)) {
> -					dev_err(rtd->card->dev,
> -						"CPU DAI %s for rtd %s does not support capture\n",
> -						cpu_dai->name,
> -						rtd->dai_link->stream_name);
> -					return -EINVAL;
> +			for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
> +				if (snd_soc_dai_stream_valid(cpu_dai, stream)) {
> +					capture = 1;
> +					break;
>  				}
> -			capture = 1;
> +			}
> +
> +			if (!capture) {
> +				dev_err(rtd->card->dev,
> +					"No CPU DAIs support capture for stream %s\n",
> +					rtd->dai_link->stream_name);
> +				return -EINVAL;
> +			}
>  		}
>  	} else {
>  		/* Adapt stream for codec2codec links */


  reply	other threads:[~2020-07-24  8:32 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-23 18:05 [PATCH] ASoC: core: use less strict tests for dailink capabilities Pierre-Louis Bossart
2020-07-24  8:31 ` Jerome Brunet [this message]
2020-07-24 19:05   ` Pierre-Louis Bossart
2020-07-27  9:42     ` Jerome Brunet
2020-07-27 14:13       ` Pierre-Louis Bossart
2020-07-27 15:15         ` Jerome Brunet
2020-07-27 15:26           ` Pierre-Louis Bossart
2020-07-29 15:46 ` [PATCH] ASoC: core: restore dpcm flags semantics Jerome Brunet
2020-07-29 15:56   ` Pierre-Louis Bossart
2020-07-30  9:04     ` Jerome Brunet
2020-07-30 16:06       ` Pierre-Louis Bossart
2020-07-30 18:52         ` Mark Brown
2020-07-31 12:16           ` Jerome Brunet
2020-07-31 17:42             ` Mark Brown
2020-07-31  8:06         ` Jerome Brunet
2020-07-30 18:12       ` Mark Brown
2020-07-31 18:54 ` [PATCH] ASoC: core: use less strict tests for dailink capabilities 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=1jlfj98gb4.fsf@starbuckisacylon.baylibre.com \
    --to=jbrunet@baylibre.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=tiwai@suse.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 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).