[alsa-devel] [PATCH] ASoC: rsnd: fixup 6ch settings to 8ch
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
rsnd need to use 8ch clock settings for 6ch for TDM. Otherwise, it can't work correctly. This patch fixup it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/sh/rcar/core.c | 18 +++++++++++++----- sound/soc/sh/rcar/rsnd.h | 1 + sound/soc/sh/rcar/ssi.c | 2 ++ 3 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 4fe83e61..37cb615 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -300,6 +300,18 @@ int rsnd_runtime_channel_after_ctu_with_params(struct rsnd_dai_stream *io, return chan; }
+int rsnd_channel_normalization(int chan) +{ + if ((chan > 8) || (chan < 0)) + return 0; + + /* TDM Extend Mode needs 8ch */ + if (chan == 6) + chan = 8; + + return chan; +} + int rsnd_runtime_channel_for_ssi_with_params(struct rsnd_dai_stream *io, struct snd_pcm_hw_params *params) { @@ -312,11 +324,7 @@ int rsnd_runtime_channel_for_ssi_with_params(struct rsnd_dai_stream *io, if (rsnd_runtime_is_multi_ssi(io)) chan /= rsnd_rdai_ssi_lane_get(rdai);
- /* TDM Extend Mode needs 8ch */ - if (chan == 6) - chan = 8; - - return chan; + return rsnd_channel_normalization(chan); }
int rsnd_runtime_is_multi_ssi(struct rsnd_dai_stream *io) diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 0e6ef4e1..7727add 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -446,6 +446,7 @@ void rsnd_parse_connect_common(struct rsnd_dai *rdai, struct device_node *playback, struct device_node *capture);
+int rsnd_channel_normalization(int chan); #define rsnd_runtime_channel_original(io) \ rsnd_runtime_channel_original_with_params(io, NULL) int rsnd_runtime_channel_original_with_params(struct rsnd_dai_stream *io, diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index f5afab6..44bda21 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -303,6 +303,8 @@ static int rsnd_ssi_master_clk_start(struct rsnd_mod *mod, if (rsnd_runtime_is_tdm_split(io)) chan = rsnd_io_converted_chan(io);
+ chan = rsnd_channel_normalization(chan); + main_rate = rsnd_ssi_clk_query(rdai, rate, chan, &idx); if (!main_rate) { dev_err(dev, "unsupported clock rate\n");
The patch
ASoC: rsnd: fixup 6ch settings to 8ch
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.1
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
From 66287def435315d9d8de740da4c543e37630b897 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Thu, 25 Apr 2019 15:16:58 +0900 Subject: [PATCH] ASoC: rsnd: fixup 6ch settings to 8ch
rsnd need to use 8ch clock settings for 6ch for TDM. Otherwise, it can't work correctly. This patch fixup it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/sh/rcar/core.c | 18 +++++++++++++----- sound/soc/sh/rcar/rsnd.h | 1 + sound/soc/sh/rcar/ssi.c | 2 ++ 3 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 4fe83e611c01..37cb61553d5f 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -300,6 +300,18 @@ int rsnd_runtime_channel_after_ctu_with_params(struct rsnd_dai_stream *io, return chan; }
+int rsnd_channel_normalization(int chan) +{ + if ((chan > 8) || (chan < 0)) + return 0; + + /* TDM Extend Mode needs 8ch */ + if (chan == 6) + chan = 8; + + return chan; +} + int rsnd_runtime_channel_for_ssi_with_params(struct rsnd_dai_stream *io, struct snd_pcm_hw_params *params) { @@ -312,11 +324,7 @@ int rsnd_runtime_channel_for_ssi_with_params(struct rsnd_dai_stream *io, if (rsnd_runtime_is_multi_ssi(io)) chan /= rsnd_rdai_ssi_lane_get(rdai);
- /* TDM Extend Mode needs 8ch */ - if (chan == 6) - chan = 8; - - return chan; + return rsnd_channel_normalization(chan); }
int rsnd_runtime_is_multi_ssi(struct rsnd_dai_stream *io) diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 0e6ef4e18400..7727add3eb1a 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -446,6 +446,7 @@ void rsnd_parse_connect_common(struct rsnd_dai *rdai, struct device_node *playback, struct device_node *capture);
+int rsnd_channel_normalization(int chan); #define rsnd_runtime_channel_original(io) \ rsnd_runtime_channel_original_with_params(io, NULL) int rsnd_runtime_channel_original_with_params(struct rsnd_dai_stream *io, diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index f5afab631abb..44bda210256e 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -303,6 +303,8 @@ static int rsnd_ssi_master_clk_start(struct rsnd_mod *mod, if (rsnd_runtime_is_tdm_split(io)) chan = rsnd_io_converted_chan(io);
+ chan = rsnd_channel_normalization(chan); + main_rate = rsnd_ssi_clk_query(rdai, rate, chan, &idx); if (!main_rate) { dev_err(dev, "unsupported clock rate\n");
The patch
ASoC: rsnd: fixup 6ch settings to 8ch
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.1
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
From 66287def435315d9d8de740da4c543e37630b897 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Thu, 25 Apr 2019 15:16:58 +0900 Subject: [PATCH] ASoC: rsnd: fixup 6ch settings to 8ch
rsnd need to use 8ch clock settings for 6ch for TDM. Otherwise, it can't work correctly. This patch fixup it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/sh/rcar/core.c | 18 +++++++++++++----- sound/soc/sh/rcar/rsnd.h | 1 + sound/soc/sh/rcar/ssi.c | 2 ++ 3 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 4fe83e611c01..37cb61553d5f 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -300,6 +300,18 @@ int rsnd_runtime_channel_after_ctu_with_params(struct rsnd_dai_stream *io, return chan; }
+int rsnd_channel_normalization(int chan) +{ + if ((chan > 8) || (chan < 0)) + return 0; + + /* TDM Extend Mode needs 8ch */ + if (chan == 6) + chan = 8; + + return chan; +} + int rsnd_runtime_channel_for_ssi_with_params(struct rsnd_dai_stream *io, struct snd_pcm_hw_params *params) { @@ -312,11 +324,7 @@ int rsnd_runtime_channel_for_ssi_with_params(struct rsnd_dai_stream *io, if (rsnd_runtime_is_multi_ssi(io)) chan /= rsnd_rdai_ssi_lane_get(rdai);
- /* TDM Extend Mode needs 8ch */ - if (chan == 6) - chan = 8; - - return chan; + return rsnd_channel_normalization(chan); }
int rsnd_runtime_is_multi_ssi(struct rsnd_dai_stream *io) diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 0e6ef4e18400..7727add3eb1a 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -446,6 +446,7 @@ void rsnd_parse_connect_common(struct rsnd_dai *rdai, struct device_node *playback, struct device_node *capture);
+int rsnd_channel_normalization(int chan); #define rsnd_runtime_channel_original(io) \ rsnd_runtime_channel_original_with_params(io, NULL) int rsnd_runtime_channel_original_with_params(struct rsnd_dai_stream *io, diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index f5afab631abb..44bda210256e 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -303,6 +303,8 @@ static int rsnd_ssi_master_clk_start(struct rsnd_mod *mod, if (rsnd_runtime_is_tdm_split(io)) chan = rsnd_io_converted_chan(io);
+ chan = rsnd_channel_normalization(chan); + main_rate = rsnd_ssi_clk_query(rdai, rate, chan, &idx); if (!main_rate) { dev_err(dev, "unsupported clock rate\n");
Hello Morimoto-san,
We've been reviewing this patch in the context of Renesas-Yocto-v3.21.0 BSP integration, where it is contained as commit [1].
On Thu, Apr 25, 2019 at 03:16:58PM +0900, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
rsnd need to use 8ch clock settings for 6ch for TDM. Otherwise, it can't work correctly. This patch fixup it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
sound/soc/sh/rcar/core.c | 18 +++++++++++++----- sound/soc/sh/rcar/rsnd.h | 1 + sound/soc/sh/rcar/ssi.c | 2 ++ 3 files changed, 16 insertions(+), 5 deletions(-)
[..]
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index f5afab6..44bda21 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -303,6 +303,8 @@ static int rsnd_ssi_master_clk_start(struct rsnd_mod *mod, if (rsnd_runtime_is_tdm_split(io)) chan = rsnd_io_converted_chan(io);
- chan = rsnd_channel_normalization(chan);
Since the "chan" value is already normalized by calling: => rsnd_ssi_master_clk_start() => chan = rsnd_runtime_channel_for_ssi(io) => rsnd_runtime_channel_for_ssi_with_params() => rsnd_channel_normalization()
I was wondering if it is really required to call rsnd_channel_normalization() second time in ssi.c for fixing the issue described in this patch?
main_rate = rsnd_ssi_clk_query(rdai, rate, chan, &idx); if (!main_rate) { dev_err(dev, "unsupported clock rate\n");
[1] https://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas-bsp.git/commit... ("ASoC: rsnd: fixup 6ch settings to 8ch")
Hi Eugeniu
We've been reviewing this patch in the context of Renesas-Yocto-v3.21.0 BSP integration, where it is contained as commit [1].
OK, now, you are using BSP.
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index f5afab6..44bda21 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -303,6 +303,8 @@ static int rsnd_ssi_master_clk_start(struct rsnd_mod *mod, if (rsnd_runtime_is_tdm_split(io)) chan = rsnd_io_converted_chan(io);
- chan = rsnd_channel_normalization(chan);
Since the "chan" value is already normalized by calling: => rsnd_ssi_master_clk_start() => chan = rsnd_runtime_channel_for_ssi(io) => rsnd_runtime_channel_for_ssi_with_params() => rsnd_channel_normalization()
I was wondering if it is really required to call rsnd_channel_normalization() second time in ssi.c for fixing the issue described in this patch?
Please compare BSP and upstream patch.
BSP https://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas-bsp.git/commit...
upstream https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i...
I don't know detail of BSP side, but I guess it doesn't have TDM Split support (?). Because of that, it doesn't have (A) code.
int rsnd_ssi_master_clk_start(xxx) { ... int chan = rsnd_runtime_channel_for_ssi(io); ... if (rsnd_runtime_is_tdm_split(io)) (A) chan = rsnd_io_converted_chan(io);
chan = rsnd_channel_normalization(chan); ... }
Thank you for your help !! Best regards --- Kuninori Morimoto
Hi Morimoto-san,
Thanks for the prompt reply.
On Tue, Aug 27, 2019 at 09:42:49AM +0900, Kuninori Morimoto wrote:
Hi Eugeniu
We've been reviewing this patch in the context of Renesas-Yocto-v3.21.0 BSP integration, where it is contained as commit [1].
OK, now, you are using BSP.
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index f5afab6..44bda21 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -303,6 +303,8 @@ static int rsnd_ssi_master_clk_start(struct rsnd_mod *mod, if (rsnd_runtime_is_tdm_split(io)) chan = rsnd_io_converted_chan(io);
- chan = rsnd_channel_normalization(chan);
Since the "chan" value is already normalized by calling: => rsnd_ssi_master_clk_start() => chan = rsnd_runtime_channel_for_ssi(io) => rsnd_runtime_channel_for_ssi_with_params() => rsnd_channel_normalization()
I was wondering if it is really required to call rsnd_channel_normalization() second time in ssi.c for fixing the issue described in this patch?
Please compare BSP and upstream patch.
BSP https://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas-bsp.git/commit...
upstream https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i...
I don't know detail of BSP side, but I guess it doesn't have TDM Split support (?). Because of that, it doesn't have (A) code.
int rsnd_ssi_master_clk_start(xxx) { ... int chan = rsnd_runtime_channel_for_ssi(io); ... if (rsnd_runtime_is_tdm_split(io)) (A) chan = rsnd_io_converted_chan(io);
chan = rsnd_channel_normalization(chan); ...
}
We've made the same observation. The BSP backport seems to be a NOOP for rsnd_ssi_master_clk_start() due to lack of TDM split support.
However, my question touched a different aspect of the patch. The comment added by commit [1] and preserved by commit [2] both suggest that is solely 'TDM Extend' mode which needs 6-to-8 channel adjustment. Your comment sounds like this also applies to 'TDM Split'?
Or for 'TDM Split' we only care to sanitize the channel value (i.e. make sure it is in the 0..8 range)?
[1] v4.5-rc1 commit 8ec85e7f7e9a2f ("ASoC: rsnd: ssi enables non-stereo sound") [..] /* TDM Extend Mode needs 8ch */ if (chan == 6) chan = 8; [..]
[2] v5.2-rc1 commit 66287def435315 ("ASoC: rsnd: fixup 6ch settings to 8ch")
Hi Eugeniu
However, my question touched a different aspect of the patch. The comment added by commit [1] and preserved by commit [2] both suggest that is solely 'TDM Extend' mode which needs 6-to-8 channel adjustment. Your comment sounds like this also applies to 'TDM Split'?
Or for 'TDM Split' we only care to sanitize the channel value (i.e. make sure it is in the 0..8 range)?
For "TDM Extend mode", we need to use 8ch clock for 6ch sound. See Figure 41.12 "TDM Extend Mode Operation with 8-channel Data in Serial Bus and 6-channel Data Inside the SoC (SSI0)"
For "TDM Split mode", it is 4ch or 8ch (4ch is not supported on this driver). See Figure 41.17 "TDM Split Mode (Stereo × 4)"
Around here is very confusable, thus, Unfortunately, it is not perfect implementation. It works for existing Renesas board, but maybe just luck (?).
Thank you for your help !! Best regards --- Kuninori Morimoto
Hello Morimoto-san,
On Tue, Aug 27, 2019 at 05:28:37PM +0900, Kuninori Morimoto wrote:
For "TDM Extend mode", we need to use 8ch clock for 6ch sound. See Figure 41.12 "TDM Extend Mode Operation with 8-channel Data in Serial Bus and 6-channel Data Inside the SoC (SSI0)"
For "TDM Split mode", it is 4ch or 8ch (4ch is not supported on this driver). See Figure 41.17 "TDM Split Mode (Stereo × 4)"
Many thanks for the helpful comments.
participants (3)
-
Eugeniu Rosca
-
Kuninori Morimoto
-
Mark Brown