All of lore.kernel.org
 help / color / mirror / Atom feed
From: Russell King - ARM Linux admin <linux@armlinux.org.uk>
To: Jyri Sarha <jsarha@ti.com>
Cc: Sven Van Asbroeck <thesven73@gmail.com>,
	alsa-devel@alsa-project.org, Liam Girdwood <lgirdwood@gmail.com>,
	Takashi Iwai <tiwai@suse.com>,
	Peter Ujfalusi <peter.ujfalusi@ti.com>,
	Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH RFC 2/3] ASoC: hdmi-codec: add support for bclk_ratio
Date: Wed, 27 Feb 2019 11:47:47 +0000	[thread overview]
Message-ID: <20190227114747.rjvkbewiloysdi3g@shell.armlinux.org.uk> (raw)
In-Reply-To: <f48bdac0-06ea-03e6-8794-bfb547ec1ed5@ti.com>

On Mon, Feb 25, 2019 at 10:58:34PM +0200, Jyri Sarha wrote:
> I think there are other options too. The obvious one would be passing
> the blck_ratio callback trough HDMI-codec to HDMI-bridge-driver, but
> yes, I do not like that either.
> 
> The other would be changing the implicit bclk_ratio to 2 x sample-width,
> and accepting blck_ratios of 36 and 40 in tda998x, and set CTS_N_M = 3
> and CTS_N_K = 2 for them too.

To put a bit of further information out there...

I really don't like that idea - what if we have a transmitter that
really does use a bclk_ratio of 36 or 40?  That would mess up the
CTS calculation in the TDA998x.

The equation I've come up to fit what we know for TDA998x is:

	k = m * bclk_ratio / 128

where k and m are parameters that we values we select for TDA998x.
This reflects the entire clock regeneration system including the sink.
The possible values of k are 1, 2, 3, 4, or 8.  m are 1, 2, 4, or 8.
I also have this equation which defines the fs regenerated at the sink:

	fso = bclk_ratio * fsi * m / (128 * k)

If we did have a ratio of 36 or 40, the first equation above fails
since k is not one of the possible integers.  If we round down and use
e.g. 2 for the 36fs case, then we'd actually end up with a sample
frequency on the sink of 1.125x faster than it should be, and the sink
would suffer starvation of audio samples.  If we rounded up to 3, then
the sample frequency will be 3/4 of it's true value, so the sink will
overflow and would have to discard audio samples.

We know this happens, because that's the root of the problem at hand:
wrongly setting the m and k values for the bclk_ratio being supplied
to the TDA998x causes audio to be corrupted when reproduced by the
sink.

Given that, we do need some way to validate the bclk_ratio when it is
set, and not during hw_params which would (a) lead to ALSA devices
failing when userspace is negotiating the parameters and (b) gives no
way in the kernel for set_bclk_ratio() to discover whether a particular
ratio is supported by the codec.

So, I think there's three possible ways around this:
1. adding a set_bclk_ratio() method to hdmi_codec_ops
2. calling hw_params() when our set_bclk_ratio() method is called
   (what if the rest of the format isn't set or incompatible, which
   may cause the hw_params() method to fail?)
3. adding a list of acceptable bclk_ratio values to hdmi_codec_pdata

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up

  parent reply	other threads:[~2019-02-27 11:48 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-22 21:26 [PATCH RFC 0/3] tda998x updates for DAI formats and bclk_ratio Russell King - ARM Linux admin
2019-02-22 21:27 ` [PATCH RFC 1/3] drm/i2c: tda998x: implement different I2S flavours Russell King
2019-02-25 13:26   ` Jyri Sarha
2019-02-25 13:28   ` Peter Ujfalusi
2019-02-25 13:40     ` Russell King - ARM Linux admin
2019-02-25 16:23   ` Sven Van Asbroeck
2019-02-22 21:27 ` [PATCH RFC 2/3] ASoC: hdmi-codec: add support for bclk_ratio Russell King
2019-02-25 13:45   ` Jyri Sarha
2019-02-25 14:03     ` Russell King - ARM Linux admin
2019-02-25 20:58       ` Jyri Sarha
2019-02-25 23:01         ` Russell King - ARM Linux admin
2019-02-27 11:47         ` Russell King - ARM Linux admin [this message]
2019-02-27 17:48           ` Jyri Sarha
2019-02-27 18:00             ` Russell King - ARM Linux admin
2019-02-27 20:24               ` Jyri Sarha
2019-02-27 18:01       ` Sven Van Asbroeck
2019-02-27 19:56         ` Russell King - ARM Linux admin
2019-02-27 20:22           ` Sven Van Asbroeck
2019-02-27 20:24           ` Russell King - ARM Linux admin
2019-03-01 12:36     ` Mark Brown
2019-03-01 14:05       ` Jyri Sarha
2019-03-01 14:59         ` Russell King - ARM Linux admin
2019-03-01 16:35           ` Jyri Sarha
2019-03-04 16:59       ` Sven Van Asbroeck
2019-03-04 17:32         ` Jyri Sarha
2019-02-22 21:27 ` [PATCH RFC 3/3] drm/i2c: tda998x: " Russell King
2019-02-25 13:47   ` Jyri Sarha
2019-02-25 16:26   ` Sven Van Asbroeck

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=20190227114747.rjvkbewiloysdi3g@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=jsarha@ti.com \
    --cc=lgirdwood@gmail.com \
    --cc=peter.ujfalusi@ti.com \
    --cc=thesven73@gmail.com \
    --cc=tiwai@suse.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.