All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Benoit Cousson <bcousson@baylibre.com>,
	broonie@kernel.org, lgirdwood@gmail.com
Cc: Fabien Parent <fparent@baylibre.com>,
	misael.lopez@ti.com, alsa-devel@alsa-project.org
Subject: Re: [PATCH v4 4/8] ASoC: pcm: Add support for DAI multicodec
Date: Tue, 01 Jul 2014 15:32:02 +0200	[thread overview]
Message-ID: <53B2B852.5000200@metafoo.de> (raw)
In-Reply-To: <1404200881-32253-5-git-send-email-bcousson@baylibre.com>

On 07/01/2014 09:47 AM, Benoit Cousson wrote:
> Add multicodec support in soc-pcm.c

Also almost.

>
> Signed-off-by: Benoit Cousson <bcousson@baylibre.com>
> Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
> Signed-off-by: Fabien Parent <fparent@baylibre.com>
> ---
[...]
>   /**
> @@ -107,11 +115,15 @@ void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd, int stream)
>    */
>   bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd)
>   {
> +	int i, ignore = 0;

The default value for ignore needs to be 1. Also maybe make ignore a bool 
(and default true).

> +
>   	if (!rtd->pmdown_time || rtd->dai_link->ignore_pmdown_time)
>   		return true;
>
> -	return rtd->cpu_dai->component->ignore_pmdown_time &&
> -			rtd->codec_dai->component->ignore_pmdown_time;
> +	for (i = 0; (i < rtd->num_codecs) && !ignore; i++)
> +		ignore &= rtd->codec_dais[i]->component->ignore_pmdown_time;
> +
> +	return rtd->cpu_dai->component->ignore_pmdown_time && ignore;
>   }
>
>   /**
> @@ -309,14 +334,21 @@ static void soc_pcm_apply_msb(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;
> +	struct snd_soc_dai *codec_dai;
> +	int i;
>   	unsigned int bits = 0, cpu_bits;
>
>   	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
> -		bits = codec_dai->driver->playback.sig_bits;
> +		for (i = 0; i < rtd->num_codecs; i++) {
> +			codec_dai = rtd->codec_dais[i];
> +			bits = max(codec_dai->driver->playback.sig_bits, bits);
> +		}

This ignores one important thing. A sig_bits value of 0 means no 
restrictions. Which means that if at least one codec as a sig_bits value of 
0 the overall value should be 0 as well.

Something like
for (i = 0; i < rtd->num_codecs; i++) {
	codec_dai = rtd->codec_dais[i];
	if (codec_dai->driver->playback.sig_bits == 0) {
		bits = 0;
		break;
	}
	bits = max(codec_dai->driver->playback.sig_bits, bits);
}



>   		cpu_bits = cpu_dai->driver->playback.sig_bits;
>   	} else {
> -		bits = codec_dai->driver->capture.sig_bits;
> +		for (i = 0; i < rtd->num_codecs; i++) {
> +			codec_dai = rtd->codec_dais[i];
> +			bits = max(codec_dai->driver->capture.sig_bits, bits);
> +		}
>   		cpu_bits = cpu_dai->driver->capture.sig_bits;
>   	}
>
> @@ -324,32 +356,65 @@ static void soc_pcm_apply_msb(struct snd_pcm_substream *substream)
>   	soc_pcm_set_msb(substream, cpu_dai, cpu_bits);

I'm getting a warning here from the compiler that codec_dai might be 
uninitialized. It won't be since num_codecs > 0, but the compiler does not 
know that, maybe you can restructure this to avoid the warning.

>   }
>
[...]


> +	for (i = 0; i < rtd->num_codecs; i++) {
> +		struct snd_soc_dai *codec_dai = rtd->codec_dais[i];
> +		struct snd_pcm_hw_params codec_params;

> +
> +		/* copy params for each codec */
> +		memcpy(&codec_params, params, sizeof(struct snd_pcm_hw_params));

Just codec_params = *params, this is generally preferred over memcpy since 
it is type safe.

  reply	other threads:[~2014-07-01 13:32 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-01  7:47 [PATCH v4 0/8] ASoC: core: Add support for DAI multicodec Benoit Cousson
2014-07-01  7:47 ` [PATCH v4 1/8] ASoC: core: Change soc_link_dai_widgets signature for multiple codecs Benoit Cousson
2014-07-01 17:17   ` Mark Brown
2014-07-04 16:13     ` Benoit Cousson
2014-07-04 16:51       ` Mark Brown
2014-07-01  7:47 ` [PATCH v4 2/8] ASoC: pcm: Refactor soc_pcm_apply_msb for multicodecs Benoit Cousson
2014-07-01 17:20   ` Mark Brown
2014-07-01 17:31     ` Benoit Cousson
2014-07-01  7:47 ` [PATCH v4 3/8] ASoC: core: Add initial support for DAI multicodec Benoit Cousson
2014-07-01 13:19   ` Lars-Peter Clausen
2014-07-01 17:27     ` Benoit Cousson
2014-07-01  7:47 ` [PATCH v4 4/8] ASoC: pcm: Add " Benoit Cousson
2014-07-01 13:32   ` Lars-Peter Clausen [this message]
2014-07-01  7:47 ` [PATCH v4 5/8] ASoC: dapm: " Benoit Cousson
2014-07-01 13:40   ` Lars-Peter Clausen
2014-07-01  7:47 ` [PATCH v4 6/8] ASoC: compress: " Benoit Cousson
2014-07-01 13:49   ` Lars-Peter Clausen
2014-07-01 16:25     ` Vinod Koul
2014-07-01 16:42       ` Lars-Peter Clausen
2014-07-01 16:45         ` Vinod Koul
2014-07-01 17:32       ` Benoit Cousson
2014-07-01 16:41   ` Vinod Koul
2014-07-01 17:41     ` Mark Brown
2014-07-03  6:39       ` Vinod Koul
2014-07-02 12:53     ` Benoit Cousson
2014-07-03  6:41       ` Vinod Koul
2014-07-03 11:09         ` Benoit Cousson
2014-07-03 11:16           ` Mark Brown
2014-07-03 11:20           ` Lars-Peter Clausen
2014-07-03 11:39             ` Benoit Cousson
2014-07-03 11:43               ` Lars-Peter Clausen
2014-07-03 11:46                 ` Benoit Cousson
2014-07-03 12:06                   ` Vinod Koul
2014-07-03 12:18                     ` Mark Brown
2014-07-03 16:15                       ` Vinod Koul
2014-07-03 18:23                         ` Lars-Peter Clausen
2014-07-04 13:55                           ` Benoit Cousson
2014-07-03 18:38                         ` Mark Brown
2014-07-03 19:09                           ` Pierre-Louis Bossart
2014-07-01  7:48 ` [PATCH v4 7/8] ASoC: pcm: Add soc_dai_hw_params helper Benoit Cousson
2014-07-01 13:43   ` Lars-Peter Clausen
2014-07-01  7:48 ` [PATCH v4 8/8] ASoC: core: Add a warning for link_dai_widget in the multicodec case Benoit Cousson
2014-07-01 13:41   ` 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=53B2B852.5000200@metafoo.de \
    --to=lars@metafoo.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=bcousson@baylibre.com \
    --cc=broonie@kernel.org \
    --cc=fparent@baylibre.com \
    --cc=lgirdwood@gmail.com \
    --cc=misael.lopez@ti.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.