drm/i2c: tda998x: derive CTS_N value from aclk sample rate ratio
authorRussell King <rmk+kernel@armlinux.org.uk>
Fri, 22 Feb 2019 20:53:38 +0000 (20:53 +0000)
committerRussell King <rmk+kernel@armlinux.org.uk>
Thu, 13 Jun 2019 20:54:41 +0000 (21:54 +0100)
commita03a915b8387286dfd1e7500705124414802ede7
treea7f29dcd96fd6714e0756e3e5d4b9da06d2cc2c9
parent7dad3740aeb7103817e38a191810dbb81afd692e
drm/i2c: tda998x: derive CTS_N value from aclk sample rate ratio

The TDA998x derives the CTS value using the supplied I2S bit clock
(ACLK, in TDA998x parlence) rather than 128·fs.  TDA998x uses two
constants named m and k in the CTS generator such that we have this
relationship between the I2S source ACLK and the sink fs:

128·fs_sink = ACLK·m / k

Where ACLK = aclk_ratio·fs_source.

When audio support was originally added, we supported a fixed ratio
of 64·fs, intending to support the Kirkwood I2S on Dove.  However,
when hdmi-codec support was added, this was changed to scale the
ratio with the sample width, which would've broken its use with
Kirkwood I2S.

We are now starting to see other users whose I2S blocks send at 64·fs
for 16-bit samples, so we need to reinstate the support for the fixed
ratio I2S bit clock.

This commit takes a step towards supporting these configurations by
selecting the CTS_N register m and k values based on the bit clock
ratio.  However, as the driver is not given the bit clock ratio from
ALSA, continue deriving this from the sample width.  This will be
addressed in a later commit.

Tested-by: Sven Van Asbroeck <TheSven73@gmail.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
drivers/gpu/drm/i2c/tda998x_drv.c