Devicetree
 help / color / mirror / Atom feed
* [PATCH v3 0/5] ASoC: pcm179x: Add support for pcm1795 and pcm1796
@ 2026-12-03  8:51 Roman Smrž
  2026-12-03  8:51 ` [PATCH v3 1/5] ASoC: dt-bindings: Add ti,pcm1795 and ti,pcm1796 Roman Smrž
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Roman Smrž @ 2026-12-03  8:51 UTC (permalink / raw)
  To: Peter Rosin, Martin Povišer, Lars-Peter Clausen,
	Nuno Sá, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Shenghao Ding, Kevin Lu,
	Baojun Xu, Sen Wang, Jaroslav Kysela, Takashi Iwai
  Cc: asahi, linux-sound, patches, devicetree, linux-kernel,
	linux-amarula, Michael Trimarchi, Krzysztof Kozlowski,
	Roman Smrž

This adds support for the PCM1795 and the PCM1796 to the pcm179x driver.

The PCM1795 is register compatible with the PCM1792A, but it encodes two
of the register 18 FMT[2:0] values differently, so the format encoding is
described with a per-codec table instead of the width switches. Only the
PCM1795 has real 32-bit formats; on the PCM1792A and the PCM1796 a 32-bit
container keeps the 24-bit code, as it always has. Left-justified, which
the driver accepted but never programmed, is added on the way.

This series is based on a work done in 2016 by my collegue:
https://lore.kernel.org/all/20160311232856.GC27257@panicking/

---
Changes in v3:
- Fixed entries in pcm179x_spi_ids.
- Use the same FORMATS list for all variants.
- Removed no longer needed startup callback previously used to apply the constraint.
- Removed no longer used format field from pcm179x_model struct.
- Added missing left justified 32-bit format for pcm1795.
- Link to v2: https://patch.msgid.link/20261016-work-v2-0-9340b9555fbb@amarulasolutions.com

Changes in v2:
- Added missing entry to spi_ids.
- Added SND_SOC_POSSIBLE_DAIFMT_LEFT_J as supported format.
- Updated description of devicetree bindings commit.
- Link to v1: https://patch.msgid.link/20261002-work-v1-0-f0e53bc7331f@amarulasolutions.com

To: Peter Rosin <peda@lysator.liu.se>
To: Martin Povišer <povik+lin@cutebit.org>
To: Lars-Peter Clausen <lars@metafoo.de>
To: Nuno Sá <nuno.sa@analog.com>
To: Liam Girdwood <lgirdwood@gmail.com>
To: Mark Brown <broonie@kernel.org>
To: Rob Herring <robh@kernel.org>
To: Krzysztof Kozlowski <krzk+dt@kernel.org>
To: Conor Dooley <conor+dt@kernel.org>
To: Shenghao Ding <shenghao-ding@ti.com>
To: Kevin Lu <kevin-lu@ti.com>
To: Baojun Xu <baojun.xu@ti.com>
To: Sen Wang <sen@ti.com>
To: Jaroslav Kysela <perex@perex.cz>
To: Takashi Iwai <tiwai@suse.com>
Cc: asahi@lists.linux.dev
Cc: linux-sound@vger.kernel.org
Cc: patches@opensource.cirrus.com
Cc: devicetree@vger.kernel.org
Cc: linux-kernel@vger.kernel.org

---
Michael Trimarchi (1):
      ASoC: dt-bindings: Add ti,pcm1795 and ti,pcm1796

Roman Smrž (4):
      ASoC: pcm179x: Refactor regmap value lookup
      ASoC: pcm179x: Add left-justified formats for pcm1792a
      ASoC: pcm179x: Add compatible string for pcm1796 and spi_ids entry
      ASoC: pcm179x: Add support for pcm1975

 .../devicetree/bindings/sound/trivial-codec.yaml   |   2 +
 sound/soc/codecs/pcm179x-i2c.c                     |   2 +
 sound/soc/codecs/pcm179x-spi.c                     |   4 +
 sound/soc/codecs/pcm179x.c                         | 103 ++++++++++++++-------
 sound/soc/codecs/pcm179x.h                         |  10 +-
 5 files changed, 88 insertions(+), 33 deletions(-)
---
base-commit: d06ce6f1eb5eeffd4ebcfde345dc34a98131d106
change-id: 20261002-work-705f20b60284

Best regards,
--  
Roman Smrž <roman@amarulasolutions.com>


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

* [PATCH v3 1/5] ASoC: dt-bindings: Add ti,pcm1795 and ti,pcm1796
  2026-12-03  8:51 [PATCH v3 0/5] ASoC: pcm179x: Add support for pcm1795 and pcm1796 Roman Smrž
@ 2026-12-03  8:51 ` Roman Smrž
  2026-12-03  8:51 ` [PATCH v3 2/5] ASoC: pcm179x: Refactor regmap value lookup Roman Smrž
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Roman Smrž @ 2026-12-03  8:51 UTC (permalink / raw)
  To: Peter Rosin, Martin Povišer, Lars-Peter Clausen,
	Nuno Sá, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Shenghao Ding, Kevin Lu,
	Baojun Xu, Sen Wang, Jaroslav Kysela, Takashi Iwai
  Cc: asahi, linux-sound, patches, devicetree, linux-kernel,
	linux-amarula, Michael Trimarchi, Krzysztof Kozlowski,
	Roman Smrž

From: Michael Trimarchi <michael@amarulasolutions.com>

The PCM1795 and PCM1796 are cost/power-reduced variants of PCM1792A.
Both are register compatible with the PCM1792A, so they belong in the
trivial codec schema.

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: Roman Smrž <roman@amarulasolutions.com>
---
 Documentation/devicetree/bindings/sound/trivial-codec.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/trivial-codec.yaml b/Documentation/devicetree/bindings/sound/trivial-codec.yaml
index 9a35dfb17349..a24a21c855e1 100644
--- a/Documentation/devicetree/bindings/sound/trivial-codec.yaml
+++ b/Documentation/devicetree/bindings/sound/trivial-codec.yaml
@@ -36,6 +36,8 @@ properties:
       - sdw3019f836300
       - ti,pcm1789
       - ti,pcm1792a
+      - ti,pcm1795
+      - ti,pcm1796
       - ti,pcm5102a
       - wlf,wm8510
       - wlf,wm8523

-- 
2.56.1


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

* [PATCH v3 2/5] ASoC: pcm179x: Refactor regmap value lookup
  2026-12-03  8:51 [PATCH v3 0/5] ASoC: pcm179x: Add support for pcm1795 and pcm1796 Roman Smrž
  2026-12-03  8:51 ` [PATCH v3 1/5] ASoC: dt-bindings: Add ti,pcm1795 and ti,pcm1796 Roman Smrž
@ 2026-12-03  8:51 ` Roman Smrž
  2026-12-03  8:51 ` [PATCH v3 3/5] ASoC: pcm179x: Add left-justified formats for pcm1792a Roman Smrž
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Roman Smrž @ 2026-12-03  8:51 UTC (permalink / raw)
  To: Peter Rosin, Martin Povišer, Lars-Peter Clausen,
	Nuno Sá, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Shenghao Ding, Kevin Lu,
	Baojun Xu, Sen Wang, Jaroslav Kysela, Takashi Iwai
  Cc: asahi, linux-sound, patches, devicetree, linux-kernel,
	linux-amarula, Roman Smrž

Use a table lookup to find values for fmt register instead of switch
statements to prepare for additional codec variants of the same family.

Signed-off-by: Roman Smrž <roman@amarulasolutions.com>
---
 sound/soc/codecs/pcm179x.c | 60 +++++++++++++++++++++++-----------------------
 1 file changed, 30 insertions(+), 30 deletions(-)

diff --git a/sound/soc/codecs/pcm179x.c b/sound/soc/codecs/pcm179x.c
index c9c4cebf92cc..31083b438b0d 100644
--- a/sound/soc/codecs/pcm179x.c
+++ b/sound/soc/codecs/pcm179x.c
@@ -65,6 +65,31 @@ struct pcm179x_private {
 	unsigned int rate;
 };
 
+struct pcm179x_fmt_table {
+	unsigned int fmt;	/* SND_SOC_DAIFMT_* */
+	unsigned int width;	/* sample width in bits */
+	unsigned int value;	/* FMT[2:0] */
+};
+
+static const struct pcm179x_fmt_table pcm1792a_fmt[] = {
+	{ SND_SOC_DAIFMT_RIGHT_J, 16, 0 },
+	{ SND_SOC_DAIFMT_RIGHT_J, 24, 2 },
+	{ SND_SOC_DAIFMT_RIGHT_J, 32, 2 },
+	{ SND_SOC_DAIFMT_I2S,     16, 4 },
+	{ SND_SOC_DAIFMT_I2S,     24, 5 },
+	{ SND_SOC_DAIFMT_I2S,     32, 5 },
+};
+
+static int pcm179x_fmt_value(struct pcm179x_private *priv, unsigned int fmt,
+			     unsigned int width)
+{
+	for (unsigned int i = 0; i < ARRAY_SIZE(pcm1792a_fmt); i++)
+		if (pcm1792a_fmt[i].fmt == fmt && pcm1792a_fmt[i].width == width)
+			return pcm1792a_fmt[i].value;
+
+	return -EINVAL;
+}
+
 static int pcm179x_set_dai_fmt(struct snd_soc_dai *codec_dai,
                              unsigned int format)
 {
@@ -96,40 +121,15 @@ static int pcm179x_hw_params(struct snd_pcm_substream *substream,
 {
 	struct snd_soc_component *component = dai->component;
 	struct pcm179x_private *priv = snd_soc_component_get_drvdata(component);
-	int val = 0, ret;
+	int val, ret;
 
 	priv->rate = params_rate(params);
 
-	switch (priv->format & SND_SOC_DAIFMT_FORMAT_MASK) {
-	case SND_SOC_DAIFMT_RIGHT_J:
-		switch (params_width(params)) {
-		case 24:
-		case 32:
-			val = 2;
-			break;
-		case 16:
-			val = 0;
-			break;
-		default:
-			return -EINVAL;
-		}
-		break;
-	case SND_SOC_DAIFMT_I2S:
-		switch (params_width(params)) {
-		case 24:
-		case 32:
-			val = 5;
-			break;
-		case 16:
-			val = 4;
-			break;
-		default:
-			return -EINVAL;
-		}
-		break;
-	default:
+	val = pcm179x_fmt_value(priv, priv->format & SND_SOC_DAIFMT_FORMAT_MASK,
+				params_width(params));
+	if (val < 0) {
 		dev_err(component->dev, "Invalid DAI format\n");
-		return -EINVAL;
+		return val;
 	}
 
 	val = val << PCM179X_FMT_SHIFT | PCM179X_ATLD_ENABLE;

-- 
2.56.1


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

* [PATCH v3 3/5] ASoC: pcm179x: Add left-justified formats for pcm1792a
  2026-12-03  8:51 [PATCH v3 0/5] ASoC: pcm179x: Add support for pcm1795 and pcm1796 Roman Smrž
  2026-12-03  8:51 ` [PATCH v3 1/5] ASoC: dt-bindings: Add ti,pcm1795 and ti,pcm1796 Roman Smrž
  2026-12-03  8:51 ` [PATCH v3 2/5] ASoC: pcm179x: Refactor regmap value lookup Roman Smrž
@ 2026-12-03  8:51 ` Roman Smrž
  2026-12-03  8:51 ` [PATCH v3 4/5] ASoC: pcm179x: Add compatible string for pcm1796 and spi_ids entry Roman Smrž
  2026-12-03  8:51 ` [PATCH v3 5/5] ASoC: pcm179x: Add support for pcm1975 Roman Smrž
  4 siblings, 0 replies; 7+ messages in thread
From: Roman Smrž @ 2026-12-03  8:51 UTC (permalink / raw)
  To: Peter Rosin, Martin Povišer, Lars-Peter Clausen,
	Nuno Sá, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Shenghao Ding, Kevin Lu,
	Baojun Xu, Sen Wang, Jaroslav Kysela, Takashi Iwai
  Cc: asahi, linux-sound, patches, devicetree, linux-kernel,
	linux-amarula, Roman Smrž

The left-justified format is supported per the datasheet, but was
missing in the table.

Signed-off-by: Roman Smrž <roman@amarulasolutions.com>
---
 sound/soc/codecs/pcm179x.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sound/soc/codecs/pcm179x.c b/sound/soc/codecs/pcm179x.c
index 31083b438b0d..559ecaa32f59 100644
--- a/sound/soc/codecs/pcm179x.c
+++ b/sound/soc/codecs/pcm179x.c
@@ -75,6 +75,8 @@ static const struct pcm179x_fmt_table pcm1792a_fmt[] = {
 	{ SND_SOC_DAIFMT_RIGHT_J, 16, 0 },
 	{ SND_SOC_DAIFMT_RIGHT_J, 24, 2 },
 	{ SND_SOC_DAIFMT_RIGHT_J, 32, 2 },
+	{ SND_SOC_DAIFMT_LEFT_J,  24, 3 },
+	{ SND_SOC_DAIFMT_LEFT_J,  32, 3 },
 	{ SND_SOC_DAIFMT_I2S,     16, 4 },
 	{ SND_SOC_DAIFMT_I2S,     24, 5 },
 	{ SND_SOC_DAIFMT_I2S,     32, 5 },
@@ -144,6 +146,7 @@ static int pcm179x_hw_params(struct snd_pcm_substream *substream,
 
 static const u64 pcm179x_selectable_formats =
 	SND_SOC_POSSIBLE_DAIFMT_I2S	|
+	SND_SOC_POSSIBLE_DAIFMT_LEFT_J  |
 	SND_SOC_POSSIBLE_DAIFMT_RIGHT_J;
 
 static const struct snd_soc_dai_ops pcm179x_dai_ops = {

-- 
2.56.1


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

* [PATCH v3 4/5] ASoC: pcm179x: Add compatible string for pcm1796 and spi_ids entry
  2026-12-03  8:51 [PATCH v3 0/5] ASoC: pcm179x: Add support for pcm1795 and pcm1796 Roman Smrž
                   ` (2 preceding siblings ...)
  2026-12-03  8:51 ` [PATCH v3 3/5] ASoC: pcm179x: Add left-justified formats for pcm1792a Roman Smrž
@ 2026-12-03  8:51 ` Roman Smrž
  2026-12-03  8:51 ` [PATCH v3 5/5] ASoC: pcm179x: Add support for pcm1975 Roman Smrž
  4 siblings, 0 replies; 7+ messages in thread
From: Roman Smrž @ 2026-12-03  8:51 UTC (permalink / raw)
  To: Peter Rosin, Martin Povišer, Lars-Peter Clausen,
	Nuno Sá, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Shenghao Ding, Kevin Lu,
	Baojun Xu, Sen Wang, Jaroslav Kysela, Takashi Iwai
  Cc: asahi, linux-sound, patches, devicetree, linux-kernel,
	linux-amarula, Roman Smrž

The PCM1796 is fully compatible with the PCM1792A.

Signed-off-by: Roman Smrž <roman@amarulasolutions.com>
---
 sound/soc/codecs/pcm179x-i2c.c | 1 +
 sound/soc/codecs/pcm179x-spi.c | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/sound/soc/codecs/pcm179x-i2c.c b/sound/soc/codecs/pcm179x-i2c.c
index 5337bcc7c62c..e81e20fadadf 100644
--- a/sound/soc/codecs/pcm179x-i2c.c
+++ b/sound/soc/codecs/pcm179x-i2c.c
@@ -32,6 +32,7 @@ static int pcm179x_i2c_probe(struct i2c_client *client)
 #ifdef CONFIG_OF
 static const struct of_device_id pcm179x_of_match[] = {
 	{ .compatible = "ti,pcm1792a", },
+	{ .compatible = "ti,pcm1796", },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, pcm179x_of_match);
diff --git a/sound/soc/codecs/pcm179x-spi.c b/sound/soc/codecs/pcm179x-spi.c
index 192fee90c971..4b873f2986c7 100644
--- a/sound/soc/codecs/pcm179x-spi.c
+++ b/sound/soc/codecs/pcm179x-spi.c
@@ -31,12 +31,14 @@ static int pcm179x_spi_probe(struct spi_device *spi)
 
 static const struct of_device_id pcm179x_of_match[] __maybe_unused = {
 	{ .compatible = "ti,pcm1792a", },
+	{ .compatible = "ti,pcm1796" },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, pcm179x_of_match);
 
 static const struct spi_device_id pcm179x_spi_ids[] = {
 	{ "pcm1792a", 0 },
+	{ "pcm1796", 0 },
 	{ "pcm179x", 0 },
 	{ },
 };

-- 
2.56.1


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

* [PATCH v3 5/5] ASoC: pcm179x: Add support for pcm1975
  2026-12-03  8:51 [PATCH v3 0/5] ASoC: pcm179x: Add support for pcm1795 and pcm1796 Roman Smrž
                   ` (3 preceding siblings ...)
  2026-12-03  8:51 ` [PATCH v3 4/5] ASoC: pcm179x: Add compatible string for pcm1796 and spi_ids entry Roman Smrž
@ 2026-12-03  8:51 ` Roman Smrž
  2026-12-03  9:10   ` sashiko-bot
  4 siblings, 1 reply; 7+ messages in thread
From: Roman Smrž @ 2026-12-03  8:51 UTC (permalink / raw)
  To: Peter Rosin, Martin Povišer, Lars-Peter Clausen,
	Nuno Sá, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Shenghao Ding, Kevin Lu,
	Baojun Xu, Sen Wang, Jaroslav Kysela, Takashi Iwai
  Cc: asahi, linux-sound, patches, devicetree, linux-kernel,
	linux-amarula, Roman Smrž

The PCM1795 is register compatible with the PCM1792A, but it encodes two
of the register 18 FMT[2:0] values differently: code 001 selects 32-bit
standard data instead of 20-bit, and code 100 selects 32-bit I2S instead
of 16-bit I2S. It has no 20-bit format at all. The PCM1796 shares the
PCM1792A encoding.

The model is read with device_get_match_data(), so each bus driver
carries the model in its own of_device_id table. The tables cannot be
moved to the common file: MODULE_DEVICE_TABLE() aliases a table that has
to be defined in the same translation unit.

Signed-off-by: Roman Smrž <roman@amarulasolutions.com>
---
 sound/soc/codecs/pcm179x-i2c.c |  3 ++-
 sound/soc/codecs/pcm179x-spi.c |  6 ++++--
 sound/soc/codecs/pcm179x.c     | 48 +++++++++++++++++++++++++++++++++++++-----
 sound/soc/codecs/pcm179x.h     | 10 +++++++--
 4 files changed, 57 insertions(+), 10 deletions(-)

diff --git a/sound/soc/codecs/pcm179x-i2c.c b/sound/soc/codecs/pcm179x-i2c.c
index e81e20fadadf..751f4b74647a 100644
--- a/sound/soc/codecs/pcm179x-i2c.c
+++ b/sound/soc/codecs/pcm179x-i2c.c
@@ -32,7 +32,8 @@ static int pcm179x_i2c_probe(struct i2c_client *client)
 #ifdef CONFIG_OF
 static const struct of_device_id pcm179x_of_match[] = {
 	{ .compatible = "ti,pcm1792a", },
-	{ .compatible = "ti,pcm1796", },
+	{ .compatible = "ti,pcm1795", .data = (void *)PCM1795, },
+	{ .compatible = "ti,pcm1796", .data = (void *)PCM1796, },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, pcm179x_of_match);
diff --git a/sound/soc/codecs/pcm179x-spi.c b/sound/soc/codecs/pcm179x-spi.c
index 4b873f2986c7..c1b8a995f2ab 100644
--- a/sound/soc/codecs/pcm179x-spi.c
+++ b/sound/soc/codecs/pcm179x-spi.c
@@ -31,14 +31,16 @@ static int pcm179x_spi_probe(struct spi_device *spi)
 
 static const struct of_device_id pcm179x_of_match[] __maybe_unused = {
 	{ .compatible = "ti,pcm1792a", },
-	{ .compatible = "ti,pcm1796" },
+	{ .compatible = "ti,pcm1795", .data = (void *)PCM1795, },
+	{ .compatible = "ti,pcm1796", .data = (void *)PCM1796, },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, pcm179x_of_match);
 
 static const struct spi_device_id pcm179x_spi_ids[] = {
 	{ "pcm1792a", 0 },
-	{ "pcm1796", 0 },
+	{ "pcm1795", PCM1795 },
+	{ "pcm1796", PCM1796 },
 	{ "pcm179x", 0 },
 	{ },
 };
diff --git a/sound/soc/codecs/pcm179x.c b/sound/soc/codecs/pcm179x.c
index 559ecaa32f59..8b21a141f665 100644
--- a/sound/soc/codecs/pcm179x.c
+++ b/sound/soc/codecs/pcm179x.c
@@ -19,6 +19,7 @@
 #include <sound/soc.h>
 #include <sound/tlv.h>
 #include <linux/of.h>
+#include <linux/property.h>
 
 #include "pcm179x.h"
 
@@ -63,6 +64,7 @@ struct pcm179x_private {
 	struct regmap *regmap;
 	unsigned int format;
 	unsigned int rate;
+	enum pcm179x_type codec_model;
 };
 
 struct pcm179x_fmt_table {
@@ -71,7 +73,17 @@ struct pcm179x_fmt_table {
 	unsigned int value;	/* FMT[2:0] */
 };
 
-static const struct pcm179x_fmt_table pcm1792a_fmt[] = {
+/*
+ * Register 18 FMT[2:0] is not encoded the same way by every model: value 001
+ * and value 100 are 20-bit and 16-bit I2S on the PCM1792A/PCM1796 but 32-bit
+ * and 32-bit I2S on the PCM1795, and neither model has a 32-bit
+ * left-justified mode.
+ *
+ * The PCM1792A/PCM1796 have no 32-bit format at all, so a 32-bit container
+ * keeps the 24-bit value and is clocked out as 24-bit data, as this driver has
+ * always done. Only the PCM1795 has real 32-bit formats.
+ */
+static const struct pcm179x_fmt_table pcm179x_fmt[] = {
 	{ SND_SOC_DAIFMT_RIGHT_J, 16, 0 },
 	{ SND_SOC_DAIFMT_RIGHT_J, 24, 2 },
 	{ SND_SOC_DAIFMT_RIGHT_J, 32, 2 },
@@ -82,12 +94,36 @@ static const struct pcm179x_fmt_table pcm1792a_fmt[] = {
 	{ SND_SOC_DAIFMT_I2S,     32, 5 },
 };
 
+static const struct pcm179x_fmt_table pcm1795_fmt[] = {
+	{ SND_SOC_DAIFMT_RIGHT_J, 16, 0 },
+	{ SND_SOC_DAIFMT_RIGHT_J, 24, 2 },
+	{ SND_SOC_DAIFMT_RIGHT_J, 32, 1 },
+	{ SND_SOC_DAIFMT_LEFT_J,  24, 3 },
+	{ SND_SOC_DAIFMT_LEFT_J,  32, 3 },
+	{ SND_SOC_DAIFMT_I2S,     24, 5 },
+	{ SND_SOC_DAIFMT_I2S,     32, 4 },
+};
+
+struct pcm179x_model {
+	const struct pcm179x_fmt_table *fmt;
+	unsigned int num_fmt;
+};
+
+static const struct pcm179x_model pcm179x_models[] = {
+	[PCM1792A] = { pcm179x_fmt, ARRAY_SIZE(pcm179x_fmt) },
+	[PCM1795] = { pcm1795_fmt, ARRAY_SIZE(pcm1795_fmt) },
+	[PCM1796] = { pcm179x_fmt, ARRAY_SIZE(pcm179x_fmt) },
+};
+
 static int pcm179x_fmt_value(struct pcm179x_private *priv, unsigned int fmt,
 			     unsigned int width)
 {
-	for (unsigned int i = 0; i < ARRAY_SIZE(pcm1792a_fmt); i++)
-		if (pcm1792a_fmt[i].fmt == fmt && pcm1792a_fmt[i].width == width)
-			return pcm1792a_fmt[i].value;
+	const struct pcm179x_model *model = &pcm179x_models[priv->codec_model];
+	const struct pcm179x_fmt_table *fmt_tbl = model->fmt;
+
+	for (unsigned int i = 0; i < model->num_fmt; i++)
+		if (fmt_tbl[i].fmt == fmt && fmt_tbl[i].width == width)
+			return fmt_tbl[i].value;
 
 	return -EINVAL;
 }
@@ -191,7 +227,7 @@ static struct snd_soc_dai_driver pcm179x_dai = {
 		.rates = SNDRV_PCM_RATE_CONTINUOUS,
 		.rate_min = 10000,
 		.rate_max = 200000,
-		.formats = PCM1792A_FORMATS, },
+		.formats = PCM179X_FORMATS, },
 	.ops = &pcm179x_dai_ops,
 };
 
@@ -226,6 +262,8 @@ int pcm179x_common_init(struct device *dev, struct regmap *regmap)
 	if (!pcm179x)
 		return -ENOMEM;
 
+	pcm179x->codec_model =
+		(enum pcm179x_type)(uintptr_t)device_get_match_data(dev);
 	pcm179x->regmap = regmap;
 	dev_set_drvdata(dev, pcm179x);
 
diff --git a/sound/soc/codecs/pcm179x.h b/sound/soc/codecs/pcm179x.h
index 0039ca8ee742..a2188425d163 100644
--- a/sound/soc/codecs/pcm179x.h
+++ b/sound/soc/codecs/pcm179x.h
@@ -8,8 +8,14 @@
 #ifndef __PCM179X_H__
 #define __PCM179X_H__
 
-#define PCM1792A_FORMATS (SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S24_LE | \
-			  SNDRV_PCM_FMTBIT_S16_LE)
+enum pcm179x_type {
+	PCM1792A,
+	PCM1795,
+	PCM1796,
+};
+
+#define PCM179X_FORMATS (SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S24_LE | \
+			 SNDRV_PCM_FMTBIT_S16_LE)
 
 extern const struct regmap_config pcm179x_regmap_config;
 

-- 
2.56.1


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

* Re: [PATCH v3 5/5] ASoC: pcm179x: Add support for pcm1975
  2026-12-03  8:51 ` [PATCH v3 5/5] ASoC: pcm179x: Add support for pcm1975 Roman Smrž
@ 2026-12-03  9:10   ` sashiko-bot
  0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-12-03  9:10 UTC (permalink / raw)
  To: Roman Smrž; +Cc: linux-sound, devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] ASoC: pcm179x: device_get_match_data() ignores SPI/I2C ID
  tables for PCM1795
- [Medium] ASoC: pcm179x: advertises S16 formats unsupported by PCM1795
  I2S and LEFT_J
- [Low] ASoC: pcm179x: commit subject misspells pcm1795 as pcm1975
--

commit 286abf7a34191f88264a3710eaa536e931b8370f
Author: Roman Smrž <roman@amarulasolutions.com>

ASoC: pcm179x: Add support for pcm1975

This commit adds support for the TI PCM1795 DAC to the pcm179x ASoC codec
driver, introducing per-model register 18 FMT[2:0] lookup tables and
resolving the codec model via device_get_match_data().

> ASoC: pcm179x: Add support for pcm1975

[Severity: Low]
This isn't a bug, but "pcm1975" in the subject is a typo for "pcm1795".

[ ... ]

> diff --git a/sound/soc/codecs/pcm179x.c b/sound/soc/codecs/pcm179x.c
> index 559ecaa32f59b..8b21a141f6657 100644
> --- a/sound/soc/codecs/pcm179x.c
> +++ b/sound/soc/codecs/pcm179x.c

[ ... ]

> @@ -191,7 +227,7 @@ static struct snd_soc_dai_driver pcm179x_dai = {
>  		.rates = SNDRV_PCM_RATE_CONTINUOUS,
>  		.rate_min = 10000,
>  		.rate_max = 200000,
> -		.formats = PCM1792A_FORMATS, },
> +		.formats = PCM179X_FORMATS, },
>  	.ops = &pcm179x_dai_ops,
>  };

[Severity: Medium]
As reported by Mark Brown on v2 [1], does pcm179x_dai still advertise
16-bit formats that PCM1795 does not support in I2S or LEFT_J mode?

PCM179X_FORMATS includes SNDRV_PCM_FMTBIT_S16_LE (expanded to S16_BE by
.endianness = 1), whereas pcm1795_fmt[] only accepts 16-bit samples in
RIGHT_J mode.  On a PCM1795 wired in I2S mode, userspace sees 16-bit as
natively supported, skips software conversion, and fails in
pcm179x_hw_params() with -EINVAL.

Constraining the advertised formats based on the model and configured DAI
format (preserving big-endian variants) would let userspace negotiate a
supported format.

> @@ -226,6 +262,8 @@ int pcm179x_common_init(struct device *dev, struct regmap *regmap)
>  	if (!pcm179x)
>  		return -ENOMEM;
>  
> +	pcm179x->codec_model =
> +		(enum pcm179x_type)(uintptr_t)device_get_match_data(dev);
>  	pcm179x->regmap = regmap;
>  	dev_set_drvdata(dev, pcm179x);

[Severity: Medium]
As reported by Mark Brown on v2 [1], does device_get_match_data() ignore
the SPI and I2C ID tables when probing without an OF node?

device_get_match_data() only queries fwnode match data, so instantiating
a PCM1795 via spi_board_info or I2C sysfs new_device returns NULL and
silently misidentifies the codec as PCM1792A.  pcm179x_hw_params() then
writes the wrong register 18 FMT[2:0] encodings (such as 5 instead of 4
for 32-bit I2S), breaking playback.  The PCM1795 and PCM1796 values added
to pcm179x_spi_ids[] are never read, and pcm179x_i2c_ids[] lacks
per-model entries so a pcm1795 I2C device cannot bind when CONFIG_OF is
disabled.

Resolving the model in pcm179x_spi_probe() and pcm179x_i2c_probe() via
spi_get_device_match_data() and i2c_get_match_data() (with per-model
entries in pcm179x_i2c_ids[]) and passing it to pcm179x_common_init()
would cover both OF and ID-table probes.

[1] https://lore.kernel.org/r/179304174310.199157.17471232393944903445.b4-review@b4

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-work-v3-0-e8a96f1c44e8@amarulasolutions.com?part=5

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

end of thread, other threads:[~2026-12-03  9:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03  8:51 [PATCH v3 0/5] ASoC: pcm179x: Add support for pcm1795 and pcm1796 Roman Smrž
2026-12-03  8:51 ` [PATCH v3 1/5] ASoC: dt-bindings: Add ti,pcm1795 and ti,pcm1796 Roman Smrž
2026-12-03  8:51 ` [PATCH v3 2/5] ASoC: pcm179x: Refactor regmap value lookup Roman Smrž
2026-12-03  8:51 ` [PATCH v3 3/5] ASoC: pcm179x: Add left-justified formats for pcm1792a Roman Smrž
2026-12-03  8:51 ` [PATCH v3 4/5] ASoC: pcm179x: Add compatible string for pcm1796 and spi_ids entry Roman Smrž
2026-12-03  8:51 ` [PATCH v3 5/5] ASoC: pcm179x: Add support for pcm1975 Roman Smrž
2026-12-03  9:10   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox