ASoC: sun4i-i2s: Change SR and WSS computation
authorMaxime Ripard <maxime.ripard@bootlin.com>
Wed, 5 Jun 2019 10:08:01 +0000 (12:08 +0200)
committerMark Brown <broonie@kernel.org>
Thu, 6 Jun 2019 16:39:29 +0000 (17:39 +0100)
commit619c15f7fac98fbeaae02d76a5529f5026a2b6d7
treeeabc0f618dfdb2c7bc02fd5b08a659d65adfdddb
parent9b8e8b893ff52264df2b54a6820ae3c4bb820624
ASoC: sun4i-i2s: Change SR and WSS computation

The current computation for the SR (sample resolution) and the WSS (word
slot size) register parameters is based on a switch returning the matching
parameters for a given params width.

Later SoCs (A83t, H3, A64) changed that calculation, which was loosely the
same with an offset. Therefore, an offset was added to adjust those
parameters.

However, the calculation is a bit less trivial than initially thought.
Indeed, while we assumed that SR and WSS were always the same, on older
SoCs, SR will max at 24 (since those SoCs do not support 32 bits formats),
but the word size can be 32.

Newer SoCs can also support a much larger range (8 bits to 32 bits, by
increments of 4) of size than the older SoCs could.

Finally, the A64 and A83t were never adjusted to have that offset in the
first place, and were therefore broken from that point of view.

In order to fix all those issues, let's introduce two functions, get_wss
and get_sr, with their respective implementations for all the SoCs
supported so far.

Fixes: 21faaea1343f ("ASoC: sun4i-i2s: Add support for A83T")
Fixes: 66ecce332538 ("ASoC: sun4i-i2s: Add compatibility with A64 codec I2S")
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sunxi/sun4i-i2s.c