Commit 49df1e39 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Mark Brown

ASoC: rsnd: Calculate DALIGN inversion at run-time

There is no need to store the inverted DALIGN values in the table, as
they can easily be calculated at run-time.  This also protects against
the introduction of inconsistencies between normal and inverted values
by a future table modification.

Reorder the two subexpressions in the AND check, to perform the least
expensive check first.
Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: default avatarEugeniu Rosca <erosca@de.adit-jv.com>
Acked-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/20191202155834.22582-1-geert+renesas@glider.beSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 3176f94c
...@@ -376,20 +376,15 @@ u32 rsnd_get_adinr_bit(struct rsnd_mod *mod, struct rsnd_dai_stream *io) ...@@ -376,20 +376,15 @@ u32 rsnd_get_adinr_bit(struct rsnd_mod *mod, struct rsnd_dai_stream *io)
*/ */
u32 rsnd_get_dalign(struct rsnd_mod *mod, struct rsnd_dai_stream *io) u32 rsnd_get_dalign(struct rsnd_mod *mod, struct rsnd_dai_stream *io)
{ {
static const u32 dalign_values[8][2] = { static const u32 dalign_values[8] = {
{0x76543210, 0x67452301}, 0x76543210, 0x00000032, 0x00007654, 0x00000076,
{0x00000032, 0x00000023}, 0xfedcba98, 0x000000ba, 0x0000fedc, 0x000000fe,
{0x00007654, 0x00006745},
{0x00000076, 0x00000067},
{0xfedcba98, 0xefcdab89},
{0x000000ba, 0x000000ab},
{0x0000fedc, 0x0000efcd},
{0x000000fe, 0x000000ef},
}; };
int id = 0, inv; int id = 0;
struct rsnd_mod *ssiu = rsnd_io_to_mod_ssiu(io); struct rsnd_mod *ssiu = rsnd_io_to_mod_ssiu(io);
struct rsnd_mod *target; struct rsnd_mod *target;
struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
u32 dalign;
/* /*
* *Hardware* L/R and *Software* L/R are inverted for 16bit data. * *Hardware* L/R and *Software* L/R are inverted for 16bit data.
...@@ -425,15 +420,15 @@ u32 rsnd_get_dalign(struct rsnd_mod *mod, struct rsnd_dai_stream *io) ...@@ -425,15 +420,15 @@ u32 rsnd_get_dalign(struct rsnd_mod *mod, struct rsnd_dai_stream *io)
if (mod == ssiu) if (mod == ssiu)
id = rsnd_mod_id_sub(mod); id = rsnd_mod_id_sub(mod);
/* Non target mod or non 16bit needs normal DALIGN */ dalign = dalign_values[id];
if ((snd_pcm_format_width(runtime->format) != 16) ||
(mod != target)) if (mod == target && snd_pcm_format_width(runtime->format) == 16) {
inv = 0;
/* Target mod needs inverted DALIGN when 16bit */ /* Target mod needs inverted DALIGN when 16bit */
else dalign = (dalign & 0xf0f0f0f0) >> 4 |
inv = 1; (dalign & 0x0f0f0f0f) << 4;
}
return dalign_values[id][inv]; return dalign;
} }
u32 rsnd_get_busif_shift(struct rsnd_dai_stream *io, struct rsnd_mod *mod) u32 rsnd_get_busif_shift(struct rsnd_dai_stream *io, struct rsnd_mod *mod)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment