linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: rsnd: fix DALIGN register for SSIU
@ 2019-11-18 14:01 Eugeniu Rosca
  2019-11-19  0:46 ` Kuninori Morimoto
  0 siblings, 1 reply; 4+ messages in thread
From: Eugeniu Rosca @ 2019-11-18 14:01 UTC (permalink / raw)
  To: Kuninori Morimoto, Jiada Wang, Mark Brown, alsa-devel, linux-kernel
  Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Eugeniu Rosca,
	Eugeniu Rosca, Nilkanth Ahirrao, Hiroyuki Yokoyama,
	Andrew Gabbasov

From: Nilkanth Ahirrao <anilkanth@jp.adit-jv.com>

The current driver only sets 0x76543210 and 0x67452301 for DALIGN.
This doesn’t work well for TDM split and ex-split mode for all SSIU.
This patch programs the DALIGN registers based on the SSIU number.

Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Cc: Jiada Wang <jiada_wang@mentor.com>
Cc: Andrew Gabbasov <andrew_gabbasov@mentor.com>
Fixes: a914e44693d41b ("ASoC: rsnd: more clear rsnd_get_dalign() for DALIGN")
Signed-off-by: Nilkanth Ahirrao <anilkanth@jp.adit-jv.com>
[erosca: Adjust Fixes: tag, reformat patch description]
Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
---
 sound/soc/sh/rcar/core.c | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index e9596c2096cd..ae05ed08a2b3 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -376,6 +376,16 @@ 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)
 {
+	static const u32 dalign_values[8][2] = {
+		{0x76543210, 0x67452301},
+		{0x00000032, 0x00000023},
+		{0x00007654, 0x00006745},
+		{0x00000076, 0x00000067},
+		{0xfedcba98, 0xefcdab89},
+		{0x000000ba, 0x000000ab},
+		{0x0000fedc, 0x0000efcd},
+		{0x000000fe, 0x000000ef},
+	};
 	struct rsnd_mod *ssiu = rsnd_io_to_mod_ssiu(io);
 	struct rsnd_mod *target;
 	struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
@@ -413,11 +423,18 @@ u32 rsnd_get_dalign(struct rsnd_mod *mod, struct rsnd_dai_stream *io)
 
 	/* Non target mod or non 16bit needs normal DALIGN */
 	if ((snd_pcm_format_width(runtime->format) != 16) ||
-	    (mod != target))
-		return 0x76543210;
+	    (mod != target)) {
+		if (mod == ssiu)
+			return dalign_values[rsnd_mod_id_sub(mod)][0];
+		else
+			return 0x76543210;
 	/* Target mod needs inverted DALIGN when 16bit */
-	else
-		return 0x67452301;
+	} else {
+		if (mod == ssiu)
+			return dalign_values[rsnd_mod_id_sub(mod)][1];
+		else
+			return 0x67452301;
+	}
 }
 
 u32 rsnd_get_busif_shift(struct rsnd_dai_stream *io, struct rsnd_mod *mod)
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: rsnd: fix DALIGN register for SSIU
  2019-11-18 14:01 [PATCH] ASoC: rsnd: fix DALIGN register for SSIU Eugeniu Rosca
@ 2019-11-19  0:46 ` Kuninori Morimoto
  2019-11-19 10:43   ` Eugeniu Rosca
  0 siblings, 1 reply; 4+ messages in thread
From: Kuninori Morimoto @ 2019-11-19  0:46 UTC (permalink / raw)
  To: Eugeniu Rosca
  Cc: Jiada Wang, Mark Brown, alsa-devel, linux-kernel, Liam Girdwood,
	Jaroslav Kysela, Takashi Iwai, Eugeniu Rosca, Nilkanth Ahirrao,
	Hiroyuki Yokoyama, Andrew Gabbasov


Hi Eugeniu

Thank you for your patch.

> From: Nilkanth Ahirrao <anilkanth@jp.adit-jv.com>
> 
> The current driver only sets 0x76543210 and 0x67452301 for DALIGN.
> This doesn’t work well for TDM split and ex-split mode for all SSIU.
> This patch programs the DALIGN registers based on the SSIU number.
> 
> Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> Cc: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
> Cc: Jiada Wang <jiada_wang@mentor.com>
> Cc: Andrew Gabbasov <andrew_gabbasov@mentor.com>
> Fixes: a914e44693d41b ("ASoC: rsnd: more clear rsnd_get_dalign() for DALIGN")
> Signed-off-by: Nilkanth Ahirrao <anilkanth@jp.adit-jv.com>
> [erosca: Adjust Fixes: tag, reformat patch description]
> Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
> ---
>  sound/soc/sh/rcar/core.c | 25 +++++++++++++++++++++----
>  1 file changed, 21 insertions(+), 4 deletions(-)
> 
> diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
> index e9596c2096cd..ae05ed08a2b3 100644
> --- a/sound/soc/sh/rcar/core.c
> +++ b/sound/soc/sh/rcar/core.c
> @@ -376,6 +376,16 @@ 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)
>  {
> +	static const u32 dalign_values[8][2] = {
> +		{0x76543210, 0x67452301},
> +		{0x00000032, 0x00000023},
> +		{0x00007654, 0x00006745},
> +		{0x00000076, 0x00000067},
> +		{0xfedcba98, 0xefcdab89},
> +		{0x000000ba, 0x000000ab},
> +		{0x0000fedc, 0x0000efcd},
> +		{0x000000fe, 0x000000ef},
> +	};
>  	struct rsnd_mod *ssiu = rsnd_io_to_mod_ssiu(io);
>  	struct rsnd_mod *target;
>  	struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
> @@ -413,11 +423,18 @@ u32 rsnd_get_dalign(struct rsnd_mod *mod, struct rsnd_dai_stream *io)
>  
>  	/* Non target mod or non 16bit needs normal DALIGN */
>  	if ((snd_pcm_format_width(runtime->format) != 16) ||
> -	    (mod != target))
> -		return 0x76543210;
> +	    (mod != target)) {
> +		if (mod == ssiu)
> +			return dalign_values[rsnd_mod_id_sub(mod)][0];
> +		else
> +			return 0x76543210;
>  	/* Target mod needs inverted DALIGN when 16bit */
> -	else
> -		return 0x67452301;
> +	} else {
> +		if (mod == ssiu)
> +			return dalign_values[rsnd_mod_id_sub(mod)][1];
> +		else
> +			return 0x67452301;
> +	}
>  }

Basically I have no objection.
But we can reuse dalign_values[0][x] value ?

	id  = 0;
	if ((snd_pcm_format_width(runtime->format) != 16) ||
	    (mod != target)) {
		inv = 0;
		if (mod == ssiu))
			id = rsnd_mod_id_sub(mod);
	/* Target mod needs inverted DALIGN when 16bit */
	} else {
		inv = 1;
		if (mod == ssiu)
			id = rsnd_mod_id_sub(mod);
	}

	return dalign_values[id][inv];

Thank you for your help !!
Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: rsnd: fix DALIGN register for SSIU
  2019-11-19  0:46 ` Kuninori Morimoto
@ 2019-11-19 10:43   ` Eugeniu Rosca
  2019-11-21 11:18     ` Eugeniu Rosca
  0 siblings, 1 reply; 4+ messages in thread
From: Eugeniu Rosca @ 2019-11-19 10:43 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: Eugeniu Rosca, Jiada Wang, Mark Brown, alsa-devel, linux-kernel,
	Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Eugeniu Rosca,
	Nilkanth Ahirrao, Andrew Gabbasov

Hello Morimoto-san,

On Tue, Nov 19, 2019 at 09:46:12AM +0900, Kuninori Morimoto wrote:

[..]

> Basically I have no objection.
> But we can reuse dalign_values[0][x] value ?
> 
> 	id  = 0;
> 	if ((snd_pcm_format_width(runtime->format) != 16) ||
> 	    (mod != target)) {
> 		inv = 0;
> 		if (mod == ssiu))
> 			id = rsnd_mod_id_sub(mod);
> 	/* Target mod needs inverted DALIGN when 16bit */
> 	} else {
> 		inv = 1;
> 		if (mod == ssiu)
> 			id = rsnd_mod_id_sub(mod);
> 	}
> 
> 	return dalign_values[id][inv];

Thank you for your review comment.
We will soon push a v2.

-- 
Best Regards,
Eugeniu

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: rsnd: fix DALIGN register for SSIU
  2019-11-19 10:43   ` Eugeniu Rosca
@ 2019-11-21 11:18     ` Eugeniu Rosca
  0 siblings, 0 replies; 4+ messages in thread
From: Eugeniu Rosca @ 2019-11-21 11:18 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: Eugeniu Rosca, Jiada Wang, Mark Brown, alsa-devel, linux-kernel,
	Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Eugeniu Rosca,
	Nilkanth Ahirrao, Andrew Gabbasov

Superseded by v2:
https://lore.kernel.org/alsa-devel/20191121111023.10976-1-erosca@de.adit-jv.com/

-- 
Best Regards,
Eugeniu

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-11-21 11:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-18 14:01 [PATCH] ASoC: rsnd: fix DALIGN register for SSIU Eugeniu Rosca
2019-11-19  0:46 ` Kuninori Morimoto
2019-11-19 10:43   ` Eugeniu Rosca
2019-11-21 11:18     ` Eugeniu Rosca

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).