Skip to contentSkip to conversation

ASoC: pcm3168a: add TDM support

PATCH In review Kuninori Morimoto 2 participants 7 messages Oct 12, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover ASoC: pcm3168a: add TDM support

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(+)
Signature · 7 lines
2.7.4



Best regards
---
Kuninori Morimoto
#1 lore raw

PATCH 1/3 ASoC: pcm3168a: add HW constraint for non RIGHT_J

From: Kuninori Morimoto <[email protected]>

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.

---
 sound/soc/codecs/pcm3168a.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
sound/soc/codecs/pcm3168a.c +36 -0
index 3356c91..233a8df5 100644
@@ -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,
Signature · 1 line
2.7.4
maintainer
#2 lore raw

Applied "ASoC: pcm3168a: add HW constraint for non RIGHT_J" to the asoc tree

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

Quoted 1 line

From 3809688980205622f75ed5d5890759430da4e7e4 Mon Sep 17 00:00:00 2001

From: Kuninori Morimoto <[email protected]>
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.

---
 sound/soc/codecs/pcm3168a.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
sound/soc/codecs/pcm3168a.c +36 -0
index 3356c91f55b0..233a8df5d7a5 100644
@@ -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,
Signature · 1 line
2.19.0
#3 lore raw

PATCH 2/3 ASoC: pcm3168a: add hw constraint for channel

In reply to Kuninori Morimoto

From: Kuninori Morimoto <[email protected]>

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

---
 sound/soc/codecs/pcm3168a.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
sound/soc/codecs/pcm3168a.c +20 -0
index 233a8df5..f0e2b88 100644
@@ -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 = {
Signature · 1 line
2.7.4
maintainer
#4 lore raw

Applied "ASoC: pcm3168a: add hw constraint for channel" to the asoc tree

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

Quoted 1 line

From 594680ea4a394f19d38a39a7d7c673fbad02a3d6 Mon Sep 17 00:00:00 2001

From: Kuninori Morimoto <[email protected]>
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.

---
 sound/soc/codecs/pcm3168a.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
sound/soc/codecs/pcm3168a.c +20 -0
index 233a8df5d7a5..f0e2b886323e 100644
@@ -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 = {
Signature · 1 line
2.19.0
#5 lore raw

PATCH 3/3 ASoC: pcm3168a: add I2S/Left_J TDM support

In reply to Kuninori Morimoto

From: Kuninori Morimoto <[email protected]>

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

---
 sound/soc/codecs/pcm3168a.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
sound/soc/codecs/pcm3168a.c +19 -0
index f0e2b88..63aa025 100644
@@ -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
Signature · 1 line
2.7.4
maintainer
#6 lore raw

Applied "ASoC: pcm3168a: add I2S/Left_J TDM support" to the asoc tree

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

Quoted 1 line

From 471a7ba89158c6d52dae69636c94c4aa1a6b7b22 Mon Sep 17 00:00:00 2001

From: Kuninori Morimoto <[email protected]>
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.

---
 sound/soc/codecs/pcm3168a.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
sound/soc/codecs/pcm3168a.c +19 -0
index f0e2b886323e..63aa02592bc0 100644
@@ -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
Signature · 1 line
2.19.0