From: Takashi Iwai <tiwai@suse.de>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: Jean-Francois Moine <moinejf@free.fr>,
alsa-devel@alsa-project.org, Jason Cooper <jason@lakedaemon.net>,
Jassi Brar <jassi.brar@samsung.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
linux-arm-kernel@lists.infradead.org
Subject: Re: KNOT / CONTINUOUS
Date: Wed, 27 Nov 2013 08:16:41 +0100 [thread overview]
Message-ID: <s5h61rewbza.wl%tiwai@suse.de> (raw)
In-Reply-To: <5294F85C.4000105@metafoo.de>
At Tue, 26 Nov 2013 20:37:00 +0100,
Lars-Peter Clausen wrote:
>
> On 11/26/2013 08:09 PM, Jean-Francois Moine wrote:
> > On Tue, 26 Nov 2013 11:20:48 +0100
> > Takashi Iwai <tiwai@suse.de> wrote:
> >
> >> Not against the patch itself, but just found looking through it:
> >>
> >>> @@ -493,7 +497,7 @@ static struct snd_soc_dai_driver kirkwood_i2s_dai_extclk[2] = {
> >>> .rates = SNDRV_PCM_RATE_8000_192000 |
> >>> SNDRV_PCM_RATE_CONTINUOUS |
> >>> SNDRV_PCM_RATE_KNOT,
> >>
> >> Setting both CONTINUOUS and KNOT doesn't make sense.
> >
> > Hi Takashi,
> >
> > I understand 'continuous', but I could not find any clear definition of
> > 'knot'. May you explain what is its purpose?
>
> CONTINUOUS means that any rate between the specified min and max is fine, if
> no min or max is specified any rate is fine. KNOT means there are rates
> supported other than the standard rates defines by ALSA, but the other rates
> are enumerable. You'd typically specify them by explicitly listing them all
> and use a list constraint or you'd use one of the ratio constraints.
>
> >
> > BTW, if you may help me, while looking for SNDRV_PCM_RATE_KNOT,
> > I found this sequence in soc-pcm.c:
> >
> > if (codec_stream->rates
> > & (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_CONTINUOUS))
> > hw->rates |= cpu_stream->rates;
> > if (cpu_stream->rates
> > & (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_CONTINUOUS))
> > hw->rates |= codec_stream->rates;
>
> I think this code is wrong, but I don't think it is related to your problem.
It's not completely wrong, but imperfect, indeed.
Essentially, the rates bits are set by a line above the code snippet:
hw->rates = codec_stream->rates & cpu_stream->rates;
And, the code above handles exceptional rules for CONTINUOUS and
KNOT. It would work if either codec or cpu DAI has KNOT or CONTINUOUS
flag and another doesn't but only explicit rate bits, because
CONTINUOUS does allow any rates and KNOW may allow any rates.
(So, basically you need no other SNDRV_PCM_RATE_*bits if you have
CONTINUOUS or KNOT bit.) And the actual rates are limited by rate_min
and rate_max values.
It won't work properly, however, if one side has KNOT and another has
CONTINUOUS. Then it'd end up with CONTINUOUS|KNOT, which is wrong.
Instead, the following should work (if I counted all possible cases
properly):
hw->rates = codec_stream->rates & cpu_stream->rates;
if (codec_stream->rates
& (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_CONTINUOUS))
hw->rates |= cpu_stream->rates & ~SNDRV_PCM_RATE_CONTINUOUS;
if (cpu_stream->rates
& (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_CONTINUOUS))
hw->rates |= codec_stream->rates & ~SNDRV_PCM_RATE_CONTINUOUS;
The code looks tricky, so a proper comment should be added there.
Takashi
next prev parent reply other threads:[~2013-11-27 7:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-26 9:41 [PATCH] ASoC: kirkwood: Fix invalid SPDIF format Jean-Francois Moine
2013-11-26 10:20 ` Takashi Iwai
2013-11-26 19:09 ` KNOT / CONTINUOUS (was: [PATCH] ASoC: kirkwood: Fix invalid SPDIF format) Jean-Francois Moine
2013-11-26 19:32 ` Russell King - ARM Linux
2013-11-26 19:37 ` KNOT / CONTINUOUS Lars-Peter Clausen
2013-11-26 20:27 ` Lars-Peter Clausen
2013-11-27 7:16 ` Takashi Iwai [this message]
2013-11-27 16:48 ` [PATCH] ASoC: kirkwood: Fix invalid SPDIF format 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=s5h61rewbza.wl%tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=jason@lakedaemon.net \
--cc=jassi.brar@samsung.com \
--cc=lars@metafoo.de \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=moinejf@free.fr \
/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).