All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] ASoC: pcm3168a: add TDM support
@ 2018-10-12  6:29 Kuninori Morimoto
  2018-10-12  6:31 ` [PATCH 1/3] ASoC: pcm3168a: add HW constraint for non RIGHT_J Kuninori Morimoto
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Kuninori Morimoto @ 2018-10-12  6:29 UTC (permalink / raw)
  To: Mark Brown, Jaroslav Kysela; +Cc: Linux-ALSA


Hi Mark, Jaroslav

These patches adds missing TDM support,
and necessary patches for it.

Kuninori Morimoto (3):
  ASoC: pcm3168a: add HW constraint for non RIGHT_J
  ASoC: pcm3168a: add hw constraint for channel
  ASoC: pcm3168a: add I2S/Left_J TDM support

 sound/soc/codecs/pcm3168a.c | 75 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)

-- 
2.7.4



Best regards
---
Kuninori Morimoto

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

* [PATCH 1/3] ASoC: pcm3168a: add HW constraint for non RIGHT_J
  2018-10-12  6:29 [PATCH 0/3] ASoC: pcm3168a: add TDM support Kuninori Morimoto
@ 2018-10-12  6:31 ` Kuninori Morimoto
  2018-10-12 17:00   ` Applied "ASoC: pcm3168a: add HW constraint for non RIGHT_J" to the asoc tree Mark Brown
  2018-10-12  6:31 ` [PATCH 2/3] ASoC: pcm3168a: add hw constraint for channel Kuninori Morimoto
  2018-10-12  6:31 ` [PATCH 3/3] ASoC: pcm3168a: add I2S/Left_J TDM support Kuninori Morimoto
  2 siblings, 1 reply; 7+ messages in thread
From: Kuninori Morimoto @ 2018-10-12  6:31 UTC (permalink / raw)
  To: Mark Brown, Jaroslav Kysela; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

RIGHT_J only can handle 16bit data bits.
Current driver just errored if user requests non RIGHT_J
+ 16bit combination. But it is not useful for user.
This patch adds HW constraint for it, and avoid
error on such situation.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/codecs/pcm3168a.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/sound/soc/codecs/pcm3168a.c b/sound/soc/codecs/pcm3168a.c
index 3356c91..233a8df5 100644
--- a/sound/soc/codecs/pcm3168a.c
+++ b/sound/soc/codecs/pcm3168a.c
@@ -476,7 +476,43 @@ static int pcm3168a_hw_params(struct snd_pcm_substream *substream,
 	return 0;
 }
 
+static int pcm3168a_startup(struct snd_pcm_substream *substream,
+			    struct snd_soc_dai *dai)
+{
+	struct snd_soc_component *component = dai->component;
+	struct pcm3168a_priv *pcm3168a = snd_soc_component_get_drvdata(component);
+	bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
+	unsigned int fmt;
+	unsigned int sample_min;
+
+	if (tx)
+		fmt = pcm3168a->dac_fmt;
+	else
+		fmt = pcm3168a->adc_fmt;
+
+	/*
+	 * Available Data Bits
+	 *
+	 * RIGHT_J : 24 / 16
+	 * LEFT_J  : 24
+	 * I2S     : 24
+	 */
+	switch (fmt) {
+	case PCM3168A_FMT_RIGHT_J:
+		sample_min  = 16;
+		break;
+	default:
+		sample_min  = 24;
+	}
+
+	snd_pcm_hw_constraint_minmax(substream->runtime,
+				     SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
+				     sample_min, 32);
+
+	return 0;
+}
 static const struct snd_soc_dai_ops pcm3168a_dac_dai_ops = {
+	.startup	= pcm3168a_startup,
 	.set_fmt	= pcm3168a_set_dai_fmt_dac,
 	.set_sysclk	= pcm3168a_set_dai_sysclk,
 	.hw_params	= pcm3168a_hw_params,
-- 
2.7.4

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

* [PATCH 2/3] ASoC: pcm3168a: add hw constraint for channel
  2018-10-12  6:29 [PATCH 0/3] ASoC: pcm3168a: add TDM support Kuninori Morimoto
  2018-10-12  6:31 ` [PATCH 1/3] ASoC: pcm3168a: add HW constraint for non RIGHT_J Kuninori Morimoto
@ 2018-10-12  6:31 ` Kuninori Morimoto
  2018-10-12 17:00   ` Applied "ASoC: pcm3168a: add hw constraint for channel" to the asoc tree Mark Brown
  2018-10-12  6:31 ` [PATCH 3/3] ASoC: pcm3168a: add I2S/Left_J TDM support Kuninori Morimoto
  2 siblings, 1 reply; 7+ messages in thread
From: Kuninori Morimoto @ 2018-10-12  6:31 UTC (permalink / raw)
  To: Mark Brown, Jaroslav Kysela; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

LEFT_J / I2S only can use TDM.
This patch adds channel constraint for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/codecs/pcm3168a.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/sound/soc/codecs/pcm3168a.c b/sound/soc/codecs/pcm3168a.c
index 233a8df5..f0e2b88 100644
--- a/sound/soc/codecs/pcm3168a.c
+++ b/sound/soc/codecs/pcm3168a.c
@@ -484,6 +484,7 @@ static int pcm3168a_startup(struct snd_pcm_substream *substream,
 	bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
 	unsigned int fmt;
 	unsigned int sample_min;
+	unsigned int channel_max;
 
 	if (tx)
 		fmt = pcm3168a->dac_fmt;
@@ -496,19 +497,38 @@ static int pcm3168a_startup(struct snd_pcm_substream *substream,
 	 * RIGHT_J : 24 / 16
 	 * LEFT_J  : 24
 	 * I2S     : 24
+	 *
+	 * TDM available
+	 *
+	 * I2S
+	 * LEFT_J
 	 */
 	switch (fmt) {
 	case PCM3168A_FMT_RIGHT_J:
 		sample_min  = 16;
+		channel_max =  2;
+		break;
+	case PCM3168A_FMT_LEFT_J:
+		sample_min  = 24;
+		channel_max =  8;
+		break;
+	case PCM3168A_FMT_I2S:
+		sample_min  = 24;
+		channel_max =  8;
 		break;
 	default:
 		sample_min  = 24;
+		channel_max =  2;
 	}
 
 	snd_pcm_hw_constraint_minmax(substream->runtime,
 				     SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
 				     sample_min, 32);
 
+	snd_pcm_hw_constraint_minmax(substream->runtime,
+				     SNDRV_PCM_HW_PARAM_CHANNELS,
+				     2, channel_max);
+
 	return 0;
 }
 static const struct snd_soc_dai_ops pcm3168a_dac_dai_ops = {
-- 
2.7.4

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

* [PATCH 3/3] ASoC: pcm3168a: add I2S/Left_J TDM support
  2018-10-12  6:29 [PATCH 0/3] ASoC: pcm3168a: add TDM support Kuninori Morimoto
  2018-10-12  6:31 ` [PATCH 1/3] ASoC: pcm3168a: add HW constraint for non RIGHT_J Kuninori Morimoto
  2018-10-12  6:31 ` [PATCH 2/3] ASoC: pcm3168a: add hw constraint for channel Kuninori Morimoto
@ 2018-10-12  6:31 ` Kuninori Morimoto
  2018-10-12 17:00   ` Applied "ASoC: pcm3168a: add I2S/Left_J TDM support" to the asoc tree Mark Brown
  2 siblings, 1 reply; 7+ messages in thread
From: Kuninori Morimoto @ 2018-10-12  6:31 UTC (permalink / raw)
  To: Mark Brown, Jaroslav Kysela; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

pcm3168a is supporting TDM on I2S/Left_J, but there is no
settings for it. This patch add it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/codecs/pcm3168a.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/sound/soc/codecs/pcm3168a.c b/sound/soc/codecs/pcm3168a.c
index f0e2b88..63aa025 100644
--- a/sound/soc/codecs/pcm3168a.c
+++ b/sound/soc/codecs/pcm3168a.c
@@ -33,6 +33,8 @@
 #define PCM3168A_FMT_RIGHT_J_16		0x3
 #define PCM3168A_FMT_DSP_A		0x4
 #define PCM3168A_FMT_DSP_B		0x5
+#define PCM3168A_FMT_I2S_TDM		0x6
+#define PCM3168A_FMT_LEFT_J_TDM		0x7
 #define PCM3168A_FMT_DSP_MASK		0x4
 
 #define PCM3168A_NUM_SUPPLIES 6
@@ -401,9 +403,11 @@ static int pcm3168a_hw_params(struct snd_pcm_substream *substream,
 	bool tx, master_mode;
 	u32 val, mask, shift, reg;
 	unsigned int rate, fmt, ratio, max_ratio;
+	unsigned int chan;
 	int i, min_frame_size;
 
 	rate = params_rate(params);
+	chan = params_channels(params);
 
 	ratio = pcm3168a->sysclk / rate;
 
@@ -456,6 +460,21 @@ static int pcm3168a_hw_params(struct snd_pcm_substream *substream,
 		return -EINVAL;
 	}
 
+	/* for TDM */
+	if (chan > 2) {
+		switch (fmt) {
+		case PCM3168A_FMT_I2S:
+			fmt = PCM3168A_FMT_I2S_TDM;
+			break;
+		case PCM3168A_FMT_LEFT_J:
+			fmt = PCM3168A_FMT_LEFT_J_TDM;
+			break;
+		default:
+			dev_err(component->dev, "TDM is supported under I2S/Left_J only\n");
+			return -EINVAL;
+		}
+	}
+
 	if (master_mode)
 		val = ((i + 1) << shift);
 	else
-- 
2.7.4

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

* Applied "ASoC: pcm3168a: add I2S/Left_J TDM support" to the asoc tree
  2018-10-12  6:31 ` [PATCH 3/3] ASoC: pcm3168a: add I2S/Left_J TDM support Kuninori Morimoto
@ 2018-10-12 17:00   ` Mark Brown
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2018-10-12 17:00 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: alsa-devel, Mark Brown

The patch

   ASoC: pcm3168a: add I2S/Left_J TDM support

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

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 471a7ba89158c6d52dae69636c94c4aa1a6b7b22 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Date: Fri, 12 Oct 2018 06:31:49 +0000
Subject: [PATCH] ASoC: pcm3168a: add I2S/Left_J TDM support

pcm3168a is supporting TDM on I2S/Left_J, but there is no
settings for it. This patch add it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/codecs/pcm3168a.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/sound/soc/codecs/pcm3168a.c b/sound/soc/codecs/pcm3168a.c
index f0e2b886323e..63aa02592bc0 100644
--- a/sound/soc/codecs/pcm3168a.c
+++ b/sound/soc/codecs/pcm3168a.c
@@ -33,6 +33,8 @@
 #define PCM3168A_FMT_RIGHT_J_16		0x3
 #define PCM3168A_FMT_DSP_A		0x4
 #define PCM3168A_FMT_DSP_B		0x5
+#define PCM3168A_FMT_I2S_TDM		0x6
+#define PCM3168A_FMT_LEFT_J_TDM		0x7
 #define PCM3168A_FMT_DSP_MASK		0x4
 
 #define PCM3168A_NUM_SUPPLIES 6
@@ -401,9 +403,11 @@ static int pcm3168a_hw_params(struct snd_pcm_substream *substream,
 	bool tx, master_mode;
 	u32 val, mask, shift, reg;
 	unsigned int rate, fmt, ratio, max_ratio;
+	unsigned int chan;
 	int i, min_frame_size;
 
 	rate = params_rate(params);
+	chan = params_channels(params);
 
 	ratio = pcm3168a->sysclk / rate;
 
@@ -456,6 +460,21 @@ static int pcm3168a_hw_params(struct snd_pcm_substream *substream,
 		return -EINVAL;
 	}
 
+	/* for TDM */
+	if (chan > 2) {
+		switch (fmt) {
+		case PCM3168A_FMT_I2S:
+			fmt = PCM3168A_FMT_I2S_TDM;
+			break;
+		case PCM3168A_FMT_LEFT_J:
+			fmt = PCM3168A_FMT_LEFT_J_TDM;
+			break;
+		default:
+			dev_err(component->dev, "TDM is supported under I2S/Left_J only\n");
+			return -EINVAL;
+		}
+	}
+
 	if (master_mode)
 		val = ((i + 1) << shift);
 	else
-- 
2.19.0

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

* Applied "ASoC: pcm3168a: add hw constraint for channel" to the asoc tree
  2018-10-12  6:31 ` [PATCH 2/3] ASoC: pcm3168a: add hw constraint for channel Kuninori Morimoto
@ 2018-10-12 17:00   ` Mark Brown
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2018-10-12 17:00 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: alsa-devel, Mark Brown

The patch

   ASoC: pcm3168a: add hw constraint for channel

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

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 594680ea4a394f19d38a39a7d7c673fbad02a3d6 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Date: Fri, 12 Oct 2018 06:31:18 +0000
Subject: [PATCH] ASoC: pcm3168a: add hw constraint for channel

LEFT_J / I2S only can use TDM.
This patch adds channel constraint for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/codecs/pcm3168a.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/sound/soc/codecs/pcm3168a.c b/sound/soc/codecs/pcm3168a.c
index 233a8df5d7a5..f0e2b886323e 100644
--- a/sound/soc/codecs/pcm3168a.c
+++ b/sound/soc/codecs/pcm3168a.c
@@ -484,6 +484,7 @@ static int pcm3168a_startup(struct snd_pcm_substream *substream,
 	bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
 	unsigned int fmt;
 	unsigned int sample_min;
+	unsigned int channel_max;
 
 	if (tx)
 		fmt = pcm3168a->dac_fmt;
@@ -496,19 +497,38 @@ static int pcm3168a_startup(struct snd_pcm_substream *substream,
 	 * RIGHT_J : 24 / 16
 	 * LEFT_J  : 24
 	 * I2S     : 24
+	 *
+	 * TDM available
+	 *
+	 * I2S
+	 * LEFT_J
 	 */
 	switch (fmt) {
 	case PCM3168A_FMT_RIGHT_J:
 		sample_min  = 16;
+		channel_max =  2;
+		break;
+	case PCM3168A_FMT_LEFT_J:
+		sample_min  = 24;
+		channel_max =  8;
+		break;
+	case PCM3168A_FMT_I2S:
+		sample_min  = 24;
+		channel_max =  8;
 		break;
 	default:
 		sample_min  = 24;
+		channel_max =  2;
 	}
 
 	snd_pcm_hw_constraint_minmax(substream->runtime,
 				     SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
 				     sample_min, 32);
 
+	snd_pcm_hw_constraint_minmax(substream->runtime,
+				     SNDRV_PCM_HW_PARAM_CHANNELS,
+				     2, channel_max);
+
 	return 0;
 }
 static const struct snd_soc_dai_ops pcm3168a_dac_dai_ops = {
-- 
2.19.0

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

* Applied "ASoC: pcm3168a: add HW constraint for non RIGHT_J" to the asoc tree
  2018-10-12  6:31 ` [PATCH 1/3] ASoC: pcm3168a: add HW constraint for non RIGHT_J Kuninori Morimoto
@ 2018-10-12 17:00   ` Mark Brown
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2018-10-12 17:00 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: alsa-devel, Mark Brown

The patch

   ASoC: pcm3168a: add HW constraint for non RIGHT_J

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

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 3809688980205622f75ed5d5890759430da4e7e4 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Date: Fri, 12 Oct 2018 06:31:00 +0000
Subject: [PATCH] ASoC: pcm3168a: add HW constraint for non RIGHT_J

RIGHT_J only can handle 16bit data bits.
Current driver just errored if user requests non RIGHT_J
+ 16bit combination. But it is not useful for user.
This patch adds HW constraint for it, and avoid
error on such situation.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/codecs/pcm3168a.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/sound/soc/codecs/pcm3168a.c b/sound/soc/codecs/pcm3168a.c
index 3356c91f55b0..233a8df5d7a5 100644
--- a/sound/soc/codecs/pcm3168a.c
+++ b/sound/soc/codecs/pcm3168a.c
@@ -476,7 +476,43 @@ static int pcm3168a_hw_params(struct snd_pcm_substream *substream,
 	return 0;
 }
 
+static int pcm3168a_startup(struct snd_pcm_substream *substream,
+			    struct snd_soc_dai *dai)
+{
+	struct snd_soc_component *component = dai->component;
+	struct pcm3168a_priv *pcm3168a = snd_soc_component_get_drvdata(component);
+	bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
+	unsigned int fmt;
+	unsigned int sample_min;
+
+	if (tx)
+		fmt = pcm3168a->dac_fmt;
+	else
+		fmt = pcm3168a->adc_fmt;
+
+	/*
+	 * Available Data Bits
+	 *
+	 * RIGHT_J : 24 / 16
+	 * LEFT_J  : 24
+	 * I2S     : 24
+	 */
+	switch (fmt) {
+	case PCM3168A_FMT_RIGHT_J:
+		sample_min  = 16;
+		break;
+	default:
+		sample_min  = 24;
+	}
+
+	snd_pcm_hw_constraint_minmax(substream->runtime,
+				     SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
+				     sample_min, 32);
+
+	return 0;
+}
 static const struct snd_soc_dai_ops pcm3168a_dac_dai_ops = {
+	.startup	= pcm3168a_startup,
 	.set_fmt	= pcm3168a_set_dai_fmt_dac,
 	.set_sysclk	= pcm3168a_set_dai_sysclk,
 	.hw_params	= pcm3168a_hw_params,
-- 
2.19.0

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

end of thread, other threads:[~2018-10-12 17:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-12  6:29 [PATCH 0/3] ASoC: pcm3168a: add TDM support Kuninori Morimoto
2018-10-12  6:31 ` [PATCH 1/3] ASoC: pcm3168a: add HW constraint for non RIGHT_J Kuninori Morimoto
2018-10-12 17:00   ` Applied "ASoC: pcm3168a: add HW constraint for non RIGHT_J" to the asoc tree Mark Brown
2018-10-12  6:31 ` [PATCH 2/3] ASoC: pcm3168a: add hw constraint for channel Kuninori Morimoto
2018-10-12 17:00   ` Applied "ASoC: pcm3168a: add hw constraint for channel" to the asoc tree Mark Brown
2018-10-12  6:31 ` [PATCH 3/3] ASoC: pcm3168a: add I2S/Left_J TDM support Kuninori Morimoto
2018-10-12 17:00   ` Applied "ASoC: pcm3168a: add I2S/Left_J TDM support" to the asoc tree Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.