All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 1/4] rename tas2764 to tas27xx
@ 2022-03-30 14:45 Raphael-Xu
  2022-03-30 14:45 ` [PATCH v5 2/4] update tas27xx.h to support either TAS2764 or TAS2780 Raphael-Xu
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Raphael-Xu @ 2022-03-30 14:45 UTC (permalink / raw)
  To: broonie; +Cc: navada, alsa-devel, shenghao-ding, raphael-xu, Raphael-Xu

Signed-off-by: Raphael-Xu <13691752556@139.com>
---
 sound/soc/codecs/Kconfig                  | 6 +++---
 sound/soc/codecs/Makefile                 | 4 ++--
 sound/soc/codecs/{tas2764.c => tas27xx.c} | 0
 sound/soc/codecs/{tas2764.h => tas27xx.h} | 0
 4 files changed, 5 insertions(+), 5 deletions(-)
 rename sound/soc/codecs/{tas2764.c => tas27xx.c} (100%)
 rename sound/soc/codecs/{tas2764.h => tas27xx.h} (100%)

diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index f46a22660103..2c4595f6f7ec 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -213,7 +213,7 @@ config SND_SOC_ALL_CODECS
 	imply SND_SOC_STI_SAS
 	imply SND_SOC_TAS2552
 	imply SND_SOC_TAS2562
-	imply SND_SOC_TAS2764
+	imply SND_SOC_TAS27XX
 	imply SND_SOC_TAS2770
 	imply SND_SOC_TAS5086
 	imply SND_SOC_TAS571X
@@ -1472,8 +1472,8 @@ config SND_SOC_TAS2562
 	tristate "Texas Instruments TAS2562 Mono Audio amplifier"
 	depends on I2C
 
-config SND_SOC_TAS2764
-	tristate "Texas Instruments TAS2764 Mono Audio amplifier"
+config SND_SOC_TAS27XX
+	tristate "Texas Instruments TAS2764/TAS2780 Mono Audio amplifier"
 	depends on I2C
 
 config SND_SOC_TAS2770
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 8637e9e869e3..15ceb95d42f5 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -337,7 +337,7 @@ snd-soc-simple-amplifier-objs := simple-amplifier.o
 snd-soc-tpa6130a2-objs := tpa6130a2.o
 snd-soc-tas2552-objs := tas2552.o
 snd-soc-tas2562-objs := tas2562.o
-snd-soc-tas2764-objs := tas2764.o
+snd-soc-tas27xx-objs := tas27xx.o
 # Mux
 snd-soc-simple-mux-objs := simple-mux.o
 
@@ -574,7 +574,7 @@ obj-$(CONFIG_SND_SOC_STAC9766)	+= snd-soc-stac9766.o
 obj-$(CONFIG_SND_SOC_STI_SAS)	+= snd-soc-sti-sas.o
 obj-$(CONFIG_SND_SOC_TAS2552)	+= snd-soc-tas2552.o
 obj-$(CONFIG_SND_SOC_TAS2562)	+= snd-soc-tas2562.o
-obj-$(CONFIG_SND_SOC_TAS2764)	+= snd-soc-tas2764.o
+obj-$(CONFIG_SND_SOC_TAS27XX)	+= snd-soc-tas27xx.o
 obj-$(CONFIG_SND_SOC_TAS5086)	+= snd-soc-tas5086.o
 obj-$(CONFIG_SND_SOC_TAS571X)	+= snd-soc-tas571x.o
 obj-$(CONFIG_SND_SOC_TAS5720)	+= snd-soc-tas5720.o
diff --git a/sound/soc/codecs/tas2764.c b/sound/soc/codecs/tas27xx.c
similarity index 100%
rename from sound/soc/codecs/tas2764.c
rename to sound/soc/codecs/tas27xx.c
diff --git a/sound/soc/codecs/tas2764.h b/sound/soc/codecs/tas27xx.h
similarity index 100%
rename from sound/soc/codecs/tas2764.h
rename to sound/soc/codecs/tas27xx.h
-- 
2.35.1



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

* [PATCH v5 2/4] update tas27xx.h to support either TAS2764 or TAS2780
  2022-03-30 14:45 [PATCH v5 1/4] rename tas2764 to tas27xx Raphael-Xu
@ 2022-03-30 14:45 ` Raphael-Xu
  2022-03-31 12:12   ` Mark Brown
  2022-03-30 14:45 ` [PATCH v5 3/4] rename variables from tas2764 to tas27xx Raphael-Xu
  2022-03-30 14:45 ` [PATCH v5 4/4] update tas27xx.c to support either TAS2764 or TAS2780 Raphael-Xu
  2 siblings, 1 reply; 10+ messages in thread
From: Raphael-Xu @ 2022-03-30 14:45 UTC (permalink / raw)
  To: broonie; +Cc: navada, alsa-devel, shenghao-ding, raphael-xu, Raphael-Xu

Signed-off-by: Raphael-Xu <13691752556@139.com>
---
 sound/soc/codecs/tas27xx.h | 131 ++++++++++++++++++++-----------------
 1 file changed, 70 insertions(+), 61 deletions(-)

diff --git a/sound/soc/codecs/tas27xx.h b/sound/soc/codecs/tas27xx.h
index 67d6fd903c42..95923e437a38 100644
--- a/sound/soc/codecs/tas27xx.h
+++ b/sound/soc/codecs/tas27xx.h
@@ -1,92 +1,101 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
- * tas2764.h - ALSA SoC Texas Instruments TAS2764 Mono Audio Amplifier
+ * tas27xx.h - ALSA SoC Texas Instruments TAS2764/TAS2780 Mono Audio Amplifier
  *
- * Copyright (C) 2020 Texas Instruments Incorporated -  https://www.ti.com
+ * Copyright (C) 2020-2022 Texas Instruments Incorporated - https://www.ti.com
  *
- * Author: Dan Murphy <dmurphy@ti.com>
+ * Author: Raphael Xu <raphael-xu@ti.com>
  */
 
-#ifndef __TAS2764__
-#define __TAS2764__
+#ifndef __TAS27XX_H__
+#define __TAS27XX_H__
 
 /* Book Control Register */
-#define TAS2764_BOOKCTL_PAGE	0
-#define TAS2764_BOOKCTL_REG	127
-#define TAS2764_REG(page, reg)	((page * 128) + reg)
+#define TAS27XX_BOOKCTL_PAGE	0
+#define TAS27XX_BOOKCTL_REG	127
+#define TAS27XX_REG(page, reg)	((page * 128) + reg)
 
 /* Page */
-#define TAS2764_PAGE		TAS2764_REG(0X0, 0x00)
-#define TAS2764_PAGE_PAGE_MASK	255
+#define TAS27XX_PAGE		TAS27XX_REG(0X0, 0x00)
+#define TAS27XX_PAGE_PAGE_MASK	255
 
 /* Software Reset */
-#define TAS2764_SW_RST	TAS2764_REG(0X0, 0x01)
-#define TAS2764_RST	BIT(0)
+#define TAS27XX_SW_RST	TAS27XX_REG(0X0, 0x01)
+#define TAS27XX_RST	BIT(0)
 
 /* Power Control */
-#define TAS2764_PWR_CTRL		TAS2764_REG(0X0, 0x02)
-#define TAS2764_PWR_CTRL_MASK		GENMASK(1, 0)
-#define TAS2764_PWR_CTRL_ACTIVE		0x0
-#define TAS2764_PWR_CTRL_MUTE		BIT(0)
-#define TAS2764_PWR_CTRL_SHUTDOWN	BIT(1)
+#define TAS27XX_PWR_CTRL		TAS27XX_REG(0X0, 0x02)
+#define TAS27XX_PWR_CTRL_MASK		GENMASK(1, 0)
+#define TAS27XX_PWR_CTRL_ACTIVE		0x0
+#define TAS27XX_PWR_CTRL_MUTE		BIT(0)
+#define TAS27XX_PWR_CTRL_SHUTDOWN	BIT(1)
 
-#define TAS2764_VSENSE_POWER_EN		3
-#define TAS2764_ISENSE_POWER_EN		4
+#define TAS27XX_VSENSE_POWER_EN		3
+#define TAS27XX_ISENSE_POWER_EN		4
 
 /* Digital Volume Control */
-#define TAS2764_DVC	TAS2764_REG(0X0, 0x1a)
-#define TAS2764_DVC_MAX	0xc9
+#define TAS27XX_DVC	TAS27XX_REG(0X0, 0x1a)
+#define TAS27XX_DVC_MAX	0xc9
 
-#define TAS2764_CHNL_0  TAS2764_REG(0X0, 0x03)
+#define TAS27XX_CHNL_0  TAS27XX_REG(0X0, 0x03)
 
 /* TDM Configuration Reg0 */
-#define TAS2764_TDM_CFG0		TAS2764_REG(0X0, 0x08)
-#define TAS2764_TDM_CFG0_SMP_MASK	BIT(5)
-#define TAS2764_TDM_CFG0_SMP_48KHZ	0x0
-#define TAS2764_TDM_CFG0_SMP_44_1KHZ	BIT(5)
-#define TAS2764_TDM_CFG0_MASK		GENMASK(3, 1)
-#define TAS2764_TDM_CFG0_44_1_48KHZ	BIT(3)
-#define TAS2764_TDM_CFG0_88_2_96KHZ	(BIT(3) | BIT(1))
+#define TAS27XX_TDM_CFG0		TAS27XX_REG(0X0, 0x08)
+#define TAS27XX_TDM_CFG0_SMP_MASK	BIT(5)
+#define TAS27XX_TDM_CFG0_SMP_48KHZ	0x0
+#define TAS27XX_TDM_CFG0_SMP_44_1KHZ	BIT(5)
+#define TAS27XX_TDM_CFG0_MASK		GENMASK(3, 1)
+#define TAS27XX_TDM_CFG0_44_1_48KHZ	BIT(3)
+#define TAS27XX_TDM_CFG0_88_2_96KHZ	(BIT(3) | BIT(1))
 
 /* TDM Configuration Reg1 */
-#define TAS2764_TDM_CFG1		TAS2764_REG(0X0, 0x09)
-#define TAS2764_TDM_CFG1_MASK		GENMASK(5, 1)
-#define TAS2764_TDM_CFG1_51_SHIFT	1
-#define TAS2764_TDM_CFG1_RX_MASK	BIT(0)
-#define TAS2764_TDM_CFG1_RX_RISING	0x0
-#define TAS2764_TDM_CFG1_RX_FALLING	BIT(0)
+#define TAS27XX_TDM_CFG1		TAS27XX_REG(0X0, 0x09)
+#define TAS27XX_TDM_CFG1_MASK		GENMASK(5, 1)
+#define TAS27XX_TDM_CFG1_51_SHIFT	1
+#define TAS27XX_TDM_CFG1_RX_MASK	BIT(0)
+#define TAS27XX_TDM_CFG1_RX_RISING	0x0
+#define TAS27XX_TDM_CFG1_RX_FALLING	BIT(0)
 
 /* TDM Configuration Reg2 */
-#define TAS2764_TDM_CFG2		TAS2764_REG(0X0, 0x0a)
-#define TAS2764_TDM_CFG2_RXW_MASK	GENMASK(3, 2)
-#define TAS2764_TDM_CFG2_RXW_16BITS	0x0
-#define TAS2764_TDM_CFG2_RXW_24BITS	BIT(3)
-#define TAS2764_TDM_CFG2_RXW_32BITS	(BIT(3) | BIT(2))
-#define TAS2764_TDM_CFG2_RXS_MASK	GENMASK(1, 0)
-#define TAS2764_TDM_CFG2_RXS_16BITS	0x0
-#define TAS2764_TDM_CFG2_RXS_24BITS	BIT(0)
-#define TAS2764_TDM_CFG2_RXS_32BITS	BIT(1)
-#define TAS2764_TDM_CFG2_SCFG_MASK	GENMASK(5, 4)
-#define TAS2764_TDM_CFG2_SCFG_I2S	0x0
-#define TAS2764_TDM_CFG2_SCFG_LEFT_J	BIT(4)
-#define TAS2764_TDM_CFG2_SCFG_RIGHT_J	BIT(5)
+#define TAS27XX_TDM_CFG2		TAS27XX_REG(0X0, 0x0a)
+#define TAS27XX_TDM_CFG2_RXW_MASK	GENMASK(3, 2)
+#define TAS27XX_TDM_CFG2_RXW_16BITS	0x0
+#define TAS27XX_TDM_CFG2_RXW_24BITS	BIT(3)
+#define TAS27XX_TDM_CFG2_RXW_32BITS	(BIT(3) | BIT(2))
+#define TAS27XX_TDM_CFG2_RXS_MASK	GENMASK(1, 0)
+#define TAS27XX_TDM_CFG2_RXS_16BITS	0x0
+#define TAS27XX_TDM_CFG2_RXS_24BITS	BIT(0)
+#define TAS27XX_TDM_CFG2_RXS_32BITS	BIT(1)
+#define TAS27XX_TDM_CFG2_SCFG_MASK	GENMASK(5, 4)
+#define TAS27XX_TDM_CFG2_SCFG_I2S	0x0
+#define TAS27XX_TDM_CFG2_SCFG_LEFT_J	BIT(4)
+#define TAS27XX_TDM_CFG2_SCFG_RIGHT_J	BIT(5)
 
 /* TDM Configuration Reg3 */
-#define TAS2764_TDM_CFG3		TAS2764_REG(0X0, 0x0c)
-#define TAS2764_TDM_CFG3_RXS_MASK	GENMASK(7, 4)
-#define TAS2764_TDM_CFG3_RXS_SHIFT	0x4
-#define TAS2764_TDM_CFG3_MASK		GENMASK(3, 0)
+#define TAS27XX_TDM_CFG3		TAS27XX_REG(0X0, 0x0c)
+#define TAS27XX_TDM_CFG3_RXS_MASK	GENMASK(7, 4)
+#define TAS27XX_TDM_CFG3_RXS_SHIFT	0x4
+#define TAS27XX_TDM_CFG3_MASK		GENMASK(3, 0)
+
+/* TDM Configuration Reg4 */
+#define TAS27XX_TDM_CFG4		TAS27XX_REG(0X0, 0x0d)
+#define TAS27XX_TDM_CFG4_TX_OFFSET_MASK	GENMASK(3, 1)
 
 /* TDM Configuration Reg5 */
-#define TAS2764_TDM_CFG5		TAS2764_REG(0X0, 0x0e)
-#define TAS2764_TDM_CFG5_VSNS_MASK	BIT(6)
-#define TAS2764_TDM_CFG5_VSNS_ENABLE	BIT(6)
-#define TAS2764_TDM_CFG5_50_MASK	GENMASK(5, 0)
+#define TAS27XX_TDM_CFG5		TAS27XX_REG(0X0, 0x0e)
+#define TAS27XX_TDM_CFG5_VSNS_MASK	BIT(6)
+#define TAS27XX_TDM_CFG5_VSNS_ENABLE	BIT(6)
+#define TAS27XX_TDM_CFG5_50_MASK	GENMASK(5, 0)
 
 /* TDM Configuration Reg6 */
-#define TAS2764_TDM_CFG6		TAS2764_REG(0X0, 0x0f)
-#define TAS2764_TDM_CFG6_ISNS_MASK	BIT(6)
-#define TAS2764_TDM_CFG6_ISNS_ENABLE	BIT(6)
-#define TAS2764_TDM_CFG6_50_MASK	GENMASK(5, 0)
+#define TAS27XX_TDM_CFG6		TAS27XX_REG(0X0, 0x0f)
+#define TAS27XX_TDM_CFG6_ISNS_MASK	BIT(6)
+#define TAS27XX_TDM_CFG6_ISNS_ENABLE	BIT(6)
+#define TAS27XX_TDM_CFG6_50_MASK	GENMASK(5, 0)
+
+/* INT&CLK CFG */
+#define TAS27XX_CLK_CFG			TAS27XX_REG(0X0, 0x5c)
+#define TAS27XX_CLK_CFG_MASK		GENMASK(7, 6)
+#define TAS27XX_CLK_CFG_ENABLE		(BIT(7) | BIT(6))
 
-#endif /* __TAS2764__ */
+#endif /* __TAS27XX_H__ */
-- 
2.35.1



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

* [PATCH v5 3/4] rename variables from tas2764 to tas27xx
  2022-03-30 14:45 [PATCH v5 1/4] rename tas2764 to tas27xx Raphael-Xu
  2022-03-30 14:45 ` [PATCH v5 2/4] update tas27xx.h to support either TAS2764 or TAS2780 Raphael-Xu
@ 2022-03-30 14:45 ` Raphael-Xu
  2022-03-30 14:45 ` [PATCH v5 4/4] update tas27xx.c to support either TAS2764 or TAS2780 Raphael-Xu
  2 siblings, 0 replies; 10+ messages in thread
From: Raphael-Xu @ 2022-03-30 14:45 UTC (permalink / raw)
  To: broonie; +Cc: navada, alsa-devel, shenghao-ding, raphael-xu, Raphael-Xu

Signed-off-by: Raphael-Xu <13691752556@139.com>
---
 sound/soc/codecs/tas27xx.c | 500 +++++++++++++++++++------------------
 1 file changed, 257 insertions(+), 243 deletions(-)

diff --git a/sound/soc/codecs/tas27xx.c b/sound/soc/codecs/tas27xx.c
index 9265af41c235..8118429bb2f5 100644
--- a/sound/soc/codecs/tas27xx.c
+++ b/sound/soc/codecs/tas27xx.c
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 //
-// Driver for the Texas Instruments TAS2764 CODEC
+// Driver for the Texas Instruments TAS27XX CODEC
 // Copyright (C) 2020 Texas Instruments Inc.
 
 #include <linux/module.h>
@@ -23,9 +23,9 @@
 #include <sound/initval.h>
 #include <sound/tlv.h>
 
-#include "tas2764.h"
+#include "tas27xx.h"
 
-struct tas2764_priv {
+struct tas27xx_priv {
 	struct snd_soc_component *component;
 	struct gpio_desc *reset_gpio;
 	struct gpio_desc *sdz_gpio;
@@ -36,43 +36,44 @@ struct tas2764_priv {
 	int i_sense_slot;
 };
 
-static void tas2764_reset(struct tas2764_priv *tas2764)
+static void tas27xx_reset(struct tas27xx_priv *tas27xx)
 {
-	if (tas2764->reset_gpio) {
-		gpiod_set_value_cansleep(tas2764->reset_gpio, 0);
+	if (tas27xx->reset_gpio) {
+		gpiod_set_value_cansleep(tas27xx->reset_gpio, 0);
 		msleep(20);
-		gpiod_set_value_cansleep(tas2764->reset_gpio, 1);
+		gpiod_set_value_cansleep(tas27xx->reset_gpio, 1);
 	}
 
-	snd_soc_component_write(tas2764->component, TAS2764_SW_RST,
-				TAS2764_RST);
+	snd_soc_component_write(tas27xx->component, TAS27XX_SW_RST,
+				TAS27XX_RST);
 }
 
-static int tas2764_set_bias_level(struct snd_soc_component *component,
+static int tas27xx_set_bias_level(struct snd_soc_component *component,
 				 enum snd_soc_bias_level level)
 {
-	struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component);
+	struct tas27xx_priv *tas27xx = 
+		snd_soc_component_get_drvdata(component);
 
 	switch (level) {
 	case SND_SOC_BIAS_ON:
-		snd_soc_component_update_bits(component, TAS2764_PWR_CTRL,
-					      TAS2764_PWR_CTRL_MASK,
-					      TAS2764_PWR_CTRL_ACTIVE);
+		snd_soc_component_update_bits(component, TAS27XX_PWR_CTRL,
+					      TAS27XX_PWR_CTRL_MASK,
+					      TAS27XX_PWR_CTRL_ACTIVE);
 		break;
 	case SND_SOC_BIAS_STANDBY:
 	case SND_SOC_BIAS_PREPARE:
-		snd_soc_component_update_bits(component, TAS2764_PWR_CTRL,
-					      TAS2764_PWR_CTRL_MASK,
-					      TAS2764_PWR_CTRL_MUTE);
+		snd_soc_component_update_bits(component, TAS27XX_PWR_CTRL,
+					      TAS27XX_PWR_CTRL_MASK,
+					      TAS27XX_PWR_CTRL_MUTE);
 		break;
 	case SND_SOC_BIAS_OFF:
-		snd_soc_component_update_bits(component, TAS2764_PWR_CTRL,
-					      TAS2764_PWR_CTRL_MASK,
-					      TAS2764_PWR_CTRL_SHUTDOWN);
+		snd_soc_component_update_bits(component, TAS27XX_PWR_CTRL,
+					      TAS27XX_PWR_CTRL_MASK,
+					      TAS27XX_PWR_CTRL_SHUTDOWN);
 		break;
 
 	default:
-		dev_err(tas2764->dev,
+		dev_err(tas27xx->dev,
 				"wrong power level setting %d\n", level);
 		return -EINVAL;
 	}
@@ -81,81 +82,87 @@ static int tas2764_set_bias_level(struct snd_soc_component *component,
 }
 
 #ifdef CONFIG_PM
-static int tas2764_codec_suspend(struct snd_soc_component *component)
+static int tas27xx_codec_suspend(struct snd_soc_component *component)
 {
-	struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component);
+	struct tas27xx_priv *tas27xx = 
+		snd_soc_component_get_drvdata(component);
 	int ret;
 
-	ret = snd_soc_component_update_bits(component, TAS2764_PWR_CTRL,
-					    TAS2764_PWR_CTRL_MASK,
-					    TAS2764_PWR_CTRL_SHUTDOWN);
+	ret = snd_soc_component_update_bits(component, TAS27XX_PWR_CTRL,
+					    TAS27XX_PWR_CTRL_MASK,
+					    TAS27XX_PWR_CTRL_SHUTDOWN);
 
 	if (ret < 0)
 		return ret;
 
-	if (tas2764->sdz_gpio)
-		gpiod_set_value_cansleep(tas2764->sdz_gpio, 0);
+	if (tas27xx->sdz_gpio)
+		gpiod_set_value_cansleep(tas27xx->sdz_gpio, 0);
 
-	regcache_cache_only(tas2764->regmap, true);
-	regcache_mark_dirty(tas2764->regmap);
+	regcache_cache_only(tas27xx->regmap, true);
+	regcache_mark_dirty(tas27xx->regmap);
 
 	return 0;
 }
 
-static int tas2764_codec_resume(struct snd_soc_component *component)
+static int tas27xx_codec_resume(struct snd_soc_component *component)
 {
-	struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component);
+	struct tas27xx_priv *tas27xx = 
+		snd_soc_component_get_drvdata(component);
 	int ret;
 
-	if (tas2764->sdz_gpio)
-		gpiod_set_value_cansleep(tas2764->sdz_gpio, 1);
+	if (tas27xx->sdz_gpio)
+		gpiod_set_value_cansleep(tas27xx->sdz_gpio, 1);
 
-	ret = snd_soc_component_update_bits(component, TAS2764_PWR_CTRL,
-					    TAS2764_PWR_CTRL_MASK,
-					    TAS2764_PWR_CTRL_ACTIVE);
+	ret = snd_soc_component_update_bits(component, TAS27XX_PWR_CTRL,
+					    TAS27XX_PWR_CTRL_MASK,
+					    TAS27XX_PWR_CTRL_ACTIVE);
 
 	if (ret < 0)
 		return ret;
 
-	regcache_cache_only(tas2764->regmap, false);
+	regcache_cache_only(tas27xx->regmap, false);
 
-	return regcache_sync(tas2764->regmap);
+	return regcache_sync(tas27xx->regmap);
 }
 #else
-#define tas2764_codec_suspend NULL
-#define tas2764_codec_resume NULL
+#define tas27xx_codec_suspend NULL
+#define tas27xx_codec_resume NULL
 #endif
 
-static const char * const tas2764_ASI1_src[] = {
+static const char * const tas27xx_ASI1_src[] = {
 	"I2C offset", "Left", "Right", "LeftRightDiv2",
 };
 
 static SOC_ENUM_SINGLE_DECL(
-	tas2764_ASI1_src_enum, TAS2764_TDM_CFG2, 4, tas2764_ASI1_src);
+	tas27xx_ASI1_src_enum, TAS27XX_TDM_CFG2, 4, tas27xx_ASI1_src);
 
-static const struct snd_kcontrol_new tas2764_asi1_mux =
-	SOC_DAPM_ENUM("ASI1 Source", tas2764_ASI1_src_enum);
+static const struct snd_kcontrol_new tas27xx_asi1_mux =
+	SOC_DAPM_ENUM("ASI1 Source", tas27xx_ASI1_src_enum);
 
-static int tas2764_dac_event(struct snd_soc_dapm_widget *w,
+static int tas27xx_dac_event(struct snd_soc_dapm_widget *w,
 			     struct snd_kcontrol *kcontrol, int event)
 {
-	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
-	struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component);
+	struct snd_soc_component *component = 
+		snd_soc_dapm_to_component(w->dapm);
+	struct tas27xx_priv *tas27xx = 
+		snd_soc_component_get_drvdata(component);
 	int ret;
 
 	switch (event) {
 	case SND_SOC_DAPM_POST_PMU:
-		ret = snd_soc_component_update_bits(component, TAS2764_PWR_CTRL,
-						    TAS2764_PWR_CTRL_MASK,
-						    TAS2764_PWR_CTRL_MUTE);
+		ret = snd_soc_component_update_bits(component, 
+						TAS27XX_PWR_CTRL,
+						TAS27XX_PWR_CTRL_MASK,
+						TAS27XX_PWR_CTRL_MUTE);
 		break;
 	case SND_SOC_DAPM_PRE_PMD:
-		ret = snd_soc_component_update_bits(component, TAS2764_PWR_CTRL,
-						    TAS2764_PWR_CTRL_MASK,
-						    TAS2764_PWR_CTRL_SHUTDOWN);
+		ret = snd_soc_component_update_bits(component, 
+						TAS27XX_PWR_CTRL,
+						TAS27XX_PWR_CTRL_MASK,
+						TAS27XX_PWR_CTRL_SHUTDOWN);
 		break;
 	default:
-		dev_err(tas2764->dev, "Unsupported event\n");
+		dev_err(tas27xx->dev, "Unsupported event\n");
 		return -EINVAL;
 	}
 
@@ -166,25 +173,27 @@ static int tas2764_dac_event(struct snd_soc_dapm_widget *w,
 }
 
 static const struct snd_kcontrol_new isense_switch =
-	SOC_DAPM_SINGLE("Switch", TAS2764_PWR_CTRL, TAS2764_ISENSE_POWER_EN, 1, 1);
+	SOC_DAPM_SINGLE("Switch", TAS27XX_PWR_CTRL, 
+			TAS27XX_ISENSE_POWER_EN, 1, 1);
 static const struct snd_kcontrol_new vsense_switch =
-	SOC_DAPM_SINGLE("Switch", TAS2764_PWR_CTRL, TAS2764_VSENSE_POWER_EN, 1, 1);
+	SOC_DAPM_SINGLE("Switch", TAS27XX_PWR_CTRL, 
+			TAS27XX_VSENSE_POWER_EN, 1, 1);
 
-static const struct snd_soc_dapm_widget tas2764_dapm_widgets[] = {
+static const struct snd_soc_dapm_widget tas27xx_dapm_widgets[] = {
 	SND_SOC_DAPM_AIF_IN("ASI1", "ASI1 Playback", 0, SND_SOC_NOPM, 0, 0),
-	SND_SOC_DAPM_MUX("ASI1 Sel", SND_SOC_NOPM, 0, 0, &tas2764_asi1_mux),
-	SND_SOC_DAPM_SWITCH("ISENSE", TAS2764_PWR_CTRL, TAS2764_ISENSE_POWER_EN,
-			    1, &isense_switch),
-	SND_SOC_DAPM_SWITCH("VSENSE", TAS2764_PWR_CTRL, TAS2764_VSENSE_POWER_EN,
-			    1, &vsense_switch),
-	SND_SOC_DAPM_DAC_E("DAC", NULL, SND_SOC_NOPM, 0, 0, tas2764_dac_event,
+	SND_SOC_DAPM_MUX("ASI1 Sel", SND_SOC_NOPM, 0, 0, &tas27xx_asi1_mux),
+	SND_SOC_DAPM_SWITCH("ISENSE", TAS27XX_PWR_CTRL, 
+		TAS27XX_ISENSE_POWER_EN, 1, &isense_switch),
+	SND_SOC_DAPM_SWITCH("VSENSE", TAS27XX_PWR_CTRL, 
+		TAS27XX_VSENSE_POWER_EN, 1, &vsense_switch),
+	SND_SOC_DAPM_DAC_E("DAC", NULL, SND_SOC_NOPM, 0, 0, tas27xx_dac_event,
 			   SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
 	SND_SOC_DAPM_OUTPUT("OUT"),
 	SND_SOC_DAPM_SIGGEN("VMON"),
 	SND_SOC_DAPM_SIGGEN("IMON")
 };
 
-static const struct snd_soc_dapm_route tas2764_audio_map[] = {
+static const struct snd_soc_dapm_route tas27xx_audio_map[] = {
 	{"ASI1 Sel", "I2C offset", "ASI1"},
 	{"ASI1 Sel", "Left", "ASI1"},
 	{"ASI1 Sel", "Right", "ASI1"},
@@ -195,14 +204,14 @@ static const struct snd_soc_dapm_route tas2764_audio_map[] = {
 	{"VSENSE", "Switch", "VMON"},
 };
 
-static int tas2764_mute(struct snd_soc_dai *dai, int mute, int direction)
+static int tas27xx_mute(struct snd_soc_dai *dai, int mute, int direction)
 {
 	struct snd_soc_component *component = dai->component;
 	int ret;
 
-	ret = snd_soc_component_update_bits(component, TAS2764_PWR_CTRL,
-					    TAS2764_PWR_CTRL_MASK,
-					    mute ? TAS2764_PWR_CTRL_MUTE : 0);
+	ret = snd_soc_component_update_bits(component, TAS27XX_PWR_CTRL,
+					    TAS27XX_PWR_CTRL_MASK,
+					    mute ? TAS27XX_PWR_CTRL_MUTE : 0);
 
 	if (ret < 0)
 		return ret;
@@ -210,9 +219,9 @@ static int tas2764_mute(struct snd_soc_dai *dai, int mute, int direction)
 	return 0;
 }
 
-static int tas2764_set_bitwidth(struct tas2764_priv *tas2764, int bitwidth)
+static int tas27xx_set_bitwidth(struct tas27xx_priv *tas27xx, int bitwidth)
 {
-	struct snd_soc_component *component = tas2764->component;
+	struct snd_soc_component *component = tas27xx->component;
 	int sense_en;
 	int val;
 	int ret;
@@ -220,21 +229,21 @@ static int tas2764_set_bitwidth(struct tas2764_priv *tas2764, int bitwidth)
 	switch (bitwidth) {
 	case SNDRV_PCM_FORMAT_S16_LE:
 		ret = snd_soc_component_update_bits(component,
-						    TAS2764_TDM_CFG2,
-						    TAS2764_TDM_CFG2_RXW_MASK,
-						    TAS2764_TDM_CFG2_RXW_16BITS);
+					TAS27XX_TDM_CFG2,
+					TAS27XX_TDM_CFG2_RXW_MASK,
+					TAS27XX_TDM_CFG2_RXW_16BITS);
 		break;
 	case SNDRV_PCM_FORMAT_S24_LE:
 		ret = snd_soc_component_update_bits(component,
-						    TAS2764_TDM_CFG2,
-						    TAS2764_TDM_CFG2_RXW_MASK,
-						    TAS2764_TDM_CFG2_RXW_24BITS);
+					TAS27XX_TDM_CFG2,
+					TAS27XX_TDM_CFG2_RXW_MASK,
+					TAS27XX_TDM_CFG2_RXW_24BITS);
 		break;
 	case SNDRV_PCM_FORMAT_S32_LE:
 		ret = snd_soc_component_update_bits(component,
-						    TAS2764_TDM_CFG2,
-						    TAS2764_TDM_CFG2_RXW_MASK,
-						    TAS2764_TDM_CFG2_RXW_32BITS);
+					TAS27XX_TDM_CFG2,
+					TAS27XX_TDM_CFG2_RXW_MASK,
+					TAS27XX_TDM_CFG2_RXW_32BITS);
 		break;
 
 	default:
@@ -244,65 +253,64 @@ static int tas2764_set_bitwidth(struct tas2764_priv *tas2764, int bitwidth)
 	if (ret < 0)
 		return ret;
 
-	val = snd_soc_component_read(tas2764->component, TAS2764_PWR_CTRL);
+	val = snd_soc_component_read(tas27xx->component, TAS27XX_PWR_CTRL);
 	if (val < 0)
 		return val;
 
-	if (val & (1 << TAS2764_VSENSE_POWER_EN))
+	if (val & (1 << TAS27XX_VSENSE_POWER_EN))
 		sense_en = 0;
 	else
-		sense_en = TAS2764_TDM_CFG5_VSNS_ENABLE;
+		sense_en = TAS27XX_TDM_CFG5_VSNS_ENABLE;
 
-	ret = snd_soc_component_update_bits(tas2764->component, TAS2764_TDM_CFG5,
-					    TAS2764_TDM_CFG5_VSNS_ENABLE,
-					    sense_en);
+	ret = snd_soc_component_update_bits(tas27xx->component, 
+		TAS27XX_TDM_CFG5, TAS27XX_TDM_CFG5_VSNS_ENABLE, sense_en);
 	if (ret < 0)
 		return ret;
 
-	if (val & (1 << TAS2764_ISENSE_POWER_EN))
+	if (val & (1 << TAS27XX_ISENSE_POWER_EN))
 		sense_en = 0;
 	else
-		sense_en = TAS2764_TDM_CFG6_ISNS_ENABLE;
+		sense_en = TAS27XX_TDM_CFG6_ISNS_ENABLE;
 
-	ret = snd_soc_component_update_bits(tas2764->component, TAS2764_TDM_CFG6,
-					    TAS2764_TDM_CFG6_ISNS_ENABLE,
-					    sense_en);
+	ret = snd_soc_component_update_bits(tas27xx->component, 
+		TAS27XX_TDM_CFG6, TAS27XX_TDM_CFG6_ISNS_ENABLE, sense_en);
 	if (ret < 0)
 		return ret;
 
 	return 0;
 }
 
-static int tas2764_set_samplerate(struct tas2764_priv *tas2764, int samplerate)
+static int tas27xx_set_samplerate(
+	struct tas27xx_priv *tas27xx, int samplerate)
 {
-	struct snd_soc_component *component = tas2764->component;
+	struct snd_soc_component *component = tas27xx->component;
 	int ramp_rate_val;
 	int ret;
 
 	switch (samplerate) {
 	case 48000:
-		ramp_rate_val = TAS2764_TDM_CFG0_SMP_48KHZ |
-				TAS2764_TDM_CFG0_44_1_48KHZ;
+		ramp_rate_val = TAS27XX_TDM_CFG0_SMP_48KHZ |
+				TAS27XX_TDM_CFG0_44_1_48KHZ;
 		break;
 	case 44100:
-		ramp_rate_val = TAS2764_TDM_CFG0_SMP_44_1KHZ |
-				TAS2764_TDM_CFG0_44_1_48KHZ;
+		ramp_rate_val = TAS27XX_TDM_CFG0_SMP_44_1KHZ |
+				TAS27XX_TDM_CFG0_44_1_48KHZ;
 		break;
 	case 96000:
-		ramp_rate_val = TAS2764_TDM_CFG0_SMP_48KHZ |
-				TAS2764_TDM_CFG0_88_2_96KHZ;
+		ramp_rate_val = TAS27XX_TDM_CFG0_SMP_48KHZ |
+				TAS27XX_TDM_CFG0_88_2_96KHZ;
 		break;
 	case 88200:
-		ramp_rate_val = TAS2764_TDM_CFG0_SMP_44_1KHZ |
-				TAS2764_TDM_CFG0_88_2_96KHZ;
+		ramp_rate_val = TAS27XX_TDM_CFG0_SMP_44_1KHZ |
+				TAS27XX_TDM_CFG0_88_2_96KHZ;
 		break;
 	default:
 		return -EINVAL;
 	}
 
-	ret = snd_soc_component_update_bits(component, TAS2764_TDM_CFG0,
-					    TAS2764_TDM_CFG0_SMP_MASK |
-					    TAS2764_TDM_CFG0_MASK,
+	ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG0,
+					    TAS27XX_TDM_CFG0_SMP_MASK |
+					    TAS27XX_TDM_CFG0_MASK,
 					    ramp_rate_val);
 	if (ret < 0)
 		return ret;
@@ -310,43 +318,45 @@ static int tas2764_set_samplerate(struct tas2764_priv *tas2764, int samplerate)
 	return 0;
 }
 
-static int tas2764_hw_params(struct snd_pcm_substream *substream,
+static int tas27xx_hw_params(struct snd_pcm_substream *substream,
 			     struct snd_pcm_hw_params *params,
 			     struct snd_soc_dai *dai)
 {
 	struct snd_soc_component *component = dai->component;
-	struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component);
+	struct tas27xx_priv *tas27xx = 
+		snd_soc_component_get_drvdata(component);
 	int ret;
 
-	ret = tas2764_set_bitwidth(tas2764, params_format(params));
+	ret = tas27xx_set_bitwidth(tas27xx, params_format(params));
 	if (ret < 0)
 		return ret;
 
-	return tas2764_set_samplerate(tas2764, params_rate(params));
+	return tas27xx_set_samplerate(tas27xx, params_rate(params));
 }
 
-static int tas2764_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
+static int tas27xx_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
 {
 	struct snd_soc_component *component = dai->component;
-	struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component);
+	struct tas27xx_priv *tas27xx = 
+		snd_soc_component_get_drvdata(component);
 	u8 tdm_rx_start_slot = 0, asi_cfg_1 = 0;
 	int iface;
 	int ret;
 
 	switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
 	case SND_SOC_DAIFMT_NB_NF:
-		asi_cfg_1 = TAS2764_TDM_CFG1_RX_RISING;
+		asi_cfg_1 = TAS27XX_TDM_CFG1_RX_RISING;
 		break;
 	case SND_SOC_DAIFMT_IB_NF:
-		asi_cfg_1 = TAS2764_TDM_CFG1_RX_FALLING;
+		asi_cfg_1 = TAS27XX_TDM_CFG1_RX_FALLING;
 		break;
 	default:
-		dev_err(tas2764->dev, "ASI format Inverse is not found\n");
+		dev_err(tas27xx->dev, "ASI format Inverse is not found\n");
 		return -EINVAL;
 	}
 
-	ret = snd_soc_component_update_bits(component, TAS2764_TDM_CFG1,
-					    TAS2764_TDM_CFG1_RX_MASK,
+	ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG1,
+					    TAS27XX_TDM_CFG1_RX_MASK,
 					    asi_cfg_1);
 	if (ret < 0)
 		return ret;
@@ -354,41 +364,42 @@ static int tas2764_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
 	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
 	case SND_SOC_DAIFMT_I2S:
 	case SND_SOC_DAIFMT_DSP_A:
-		iface = TAS2764_TDM_CFG2_SCFG_I2S;
+		iface = TAS27XX_TDM_CFG2_SCFG_I2S;
 		tdm_rx_start_slot = 1;
 		break;
 	case SND_SOC_DAIFMT_DSP_B:
 	case SND_SOC_DAIFMT_LEFT_J:
-		iface = TAS2764_TDM_CFG2_SCFG_LEFT_J;
+		iface = TAS27XX_TDM_CFG2_SCFG_LEFT_J;
 		tdm_rx_start_slot = 0;
 		break;
 	default:
-		dev_err(tas2764->dev,
+		dev_err(tas27xx->dev,
 			"DAI Format is not found, fmt=0x%x\n", fmt);
 		return -EINVAL;
 	}
 
-	ret = snd_soc_component_update_bits(component, TAS2764_TDM_CFG1,
-					    TAS2764_TDM_CFG1_MASK,
-					    (tdm_rx_start_slot << TAS2764_TDM_CFG1_51_SHIFT));
+	ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG1,
+		TAS27XX_TDM_CFG1_MASK,
+		(tdm_rx_start_slot << TAS27XX_TDM_CFG1_51_SHIFT));
 	if (ret < 0)
 		return ret;
 
-	ret = snd_soc_component_update_bits(component, TAS2764_TDM_CFG2,
-					    TAS2764_TDM_CFG2_SCFG_MASK, iface);
+	ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG2,
+		TAS27XX_TDM_CFG2_SCFG_MASK, iface);
 	if (ret < 0)
 		return ret;
 
 	return 0;
 }
 
-static int tas2764_set_dai_tdm_slot(struct snd_soc_dai *dai,
+static int tas27xx_set_dai_tdm_slot(struct snd_soc_dai *dai,
 				unsigned int tx_mask,
 				unsigned int rx_mask,
 				int slots, int slot_width)
 {
 	struct snd_soc_component *component = dai->component;
-	struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component);
+	struct tas27xx_priv *tas27xx = 
+		snd_soc_component_get_drvdata(component);
 	int left_slot, right_slot;
 	int slots_cfg;
 	int slot_size;
@@ -416,159 +427,162 @@ static int tas2764_set_dai_tdm_slot(struct snd_soc_dai *dai,
 	if (tx_mask != 0 || left_slot >= slots || right_slot >= slots)
 		return -EINVAL;
 
-	slots_cfg = (right_slot << TAS2764_TDM_CFG3_RXS_SHIFT) | left_slot;
+	slots_cfg = (right_slot << TAS27XX_TDM_CFG3_RXS_SHIFT) | left_slot;
 
-	ret = snd_soc_component_write(component, TAS2764_TDM_CFG3, slots_cfg);
+	ret = snd_soc_component_write(component, TAS27XX_TDM_CFG3, slots_cfg);
 	if (ret)
 		return ret;
 
 	switch (slot_width) {
 	case 16:
-		slot_size = TAS2764_TDM_CFG2_RXS_16BITS;
+		slot_size = TAS27XX_TDM_CFG2_RXS_16BITS;
 		break;
 	case 24:
-		slot_size = TAS2764_TDM_CFG2_RXS_24BITS;
+		slot_size = TAS27XX_TDM_CFG2_RXS_24BITS;
 		break;
 	case 32:
-		slot_size = TAS2764_TDM_CFG2_RXS_32BITS;
+		slot_size = TAS27XX_TDM_CFG2_RXS_32BITS;
 		break;
 	default:
 		return -EINVAL;
 	}
 
-	ret = snd_soc_component_update_bits(component, TAS2764_TDM_CFG2,
-					    TAS2764_TDM_CFG2_RXS_MASK,
+	ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG2,
+					    TAS27XX_TDM_CFG2_RXS_MASK,
 					    slot_size);
 	if (ret < 0)
 		return ret;
 
-	ret = snd_soc_component_update_bits(component, TAS2764_TDM_CFG5,
-					    TAS2764_TDM_CFG5_50_MASK,
-					    tas2764->v_sense_slot);
+	ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG5,
+					    TAS27XX_TDM_CFG5_50_MASK,
+					    tas27xx->v_sense_slot);
 	if (ret < 0)
 		return ret;
 
-	ret = snd_soc_component_update_bits(component, TAS2764_TDM_CFG6,
-					    TAS2764_TDM_CFG6_50_MASK,
-					    tas2764->i_sense_slot);
+	ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG6,
+					    TAS27XX_TDM_CFG6_50_MASK,
+					    tas27xx->i_sense_slot);
 	if (ret < 0)
 		return ret;
 
 	return 0;
 }
 
-static const struct snd_soc_dai_ops tas2764_dai_ops = {
-	.mute_stream = tas2764_mute,
-	.hw_params  = tas2764_hw_params,
-	.set_fmt    = tas2764_set_fmt,
-	.set_tdm_slot = tas2764_set_dai_tdm_slot,
+static const struct snd_soc_dai_ops tas27xx_dai_ops = {
+	.mute_stream = tas27xx_mute,
+	.hw_params  = tas27xx_hw_params,
+	.set_fmt    = tas27xx_set_fmt,
+	.set_tdm_slot = tas27xx_set_dai_tdm_slot,
 	.no_capture_mute = 1,
 };
 
-#define TAS2764_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
+#define TAS27XX_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
 			 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
 
-#define TAS2764_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\
+#define TAS27XX_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\
 		       SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_88200)
 
-static struct snd_soc_dai_driver tas2764_dai_driver[] = {
+static struct snd_soc_dai_driver tas27xx_dai_driver[] = {
 	{
-		.name = "tas2764 ASI1",
+		.name = "tas27xx ASI1",
 		.id = 0,
 		.playback = {
 			.stream_name    = "ASI1 Playback",
 			.channels_min   = 2,
 			.channels_max   = 2,
-			.rates      = TAS2764_RATES,
-			.formats    = TAS2764_FORMATS,
+			.rates      = TAS27XX_RATES,
+			.formats    = TAS27XX_FORMATS,
 		},
 		.capture = {
 			.stream_name    = "ASI1 Capture",
 			.channels_min   = 0,
 			.channels_max   = 2,
-			.rates = TAS2764_RATES,
-			.formats = TAS2764_FORMATS,
+			.rates = TAS27XX_RATES,
+			.formats = TAS27XX_FORMATS,
 		},
-		.ops = &tas2764_dai_ops,
+		.ops = &tas27xx_dai_ops,
 		.symmetric_rate = 1,
 	},
 };
 
-static int tas2764_codec_probe(struct snd_soc_component *component)
+static int tas27xx_codec_probe(struct snd_soc_component *component)
 {
-	struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component);
+	struct tas27xx_priv *tas27xx = 
+		snd_soc_component_get_drvdata(component);
 	int ret;
 
-	tas2764->component = component;
+	tas27xx->component = component;
 
-	if (tas2764->sdz_gpio)
-		gpiod_set_value_cansleep(tas2764->sdz_gpio, 1);
+	if (tas27xx->sdz_gpio)
+		gpiod_set_value_cansleep(tas27xx->sdz_gpio, 1);
 
-	tas2764_reset(tas2764);
+	tas27xx_reset(tas27xx);
 
-	ret = snd_soc_component_update_bits(tas2764->component, TAS2764_TDM_CFG5,
-					    TAS2764_TDM_CFG5_VSNS_ENABLE, 0);
+	ret = snd_soc_component_update_bits(tas27xx->component, 
+						TAS27XX_TDM_CFG5,
+					    TAS27XX_TDM_CFG5_VSNS_ENABLE, 0);
 	if (ret < 0)
 		return ret;
 
-	ret = snd_soc_component_update_bits(tas2764->component, TAS2764_TDM_CFG6,
-					    TAS2764_TDM_CFG6_ISNS_ENABLE, 0);
+	ret = snd_soc_component_update_bits(tas27xx->component, 
+						TAS27XX_TDM_CFG6,
+					    TAS27XX_TDM_CFG6_ISNS_ENABLE, 0);
 	if (ret < 0)
 		return ret;
 
-	ret = snd_soc_component_update_bits(component, TAS2764_PWR_CTRL,
-					    TAS2764_PWR_CTRL_MASK,
-					    TAS2764_PWR_CTRL_MUTE);
+	ret = snd_soc_component_update_bits(component, TAS27XX_PWR_CTRL,
+					    TAS27XX_PWR_CTRL_MASK,
+					    TAS27XX_PWR_CTRL_MUTE);
 	if (ret < 0)
 		return ret;
 
 	return 0;
 }
 
-static DECLARE_TLV_DB_SCALE(tas2764_digital_tlv, 1100, 50, 0);
-static DECLARE_TLV_DB_SCALE(tas2764_playback_volume, -10000, 50, 0);
+static DECLARE_TLV_DB_SCALE(tas27xx_digital_tlv, 1100, 50, 0);
+static DECLARE_TLV_DB_SCALE(tas27xx_playback_volume, -10000, 50, 0);
 
-static const struct snd_kcontrol_new tas2764_snd_controls[] = {
-	SOC_SINGLE_TLV("Speaker Volume", TAS2764_DVC, 0,
-		       TAS2764_DVC_MAX, 1, tas2764_playback_volume),
-	SOC_SINGLE_TLV("Amp Gain Volume", TAS2764_CHNL_0, 0, 0x14, 0,
-		       tas2764_digital_tlv),
+static const struct snd_kcontrol_new tas27xx_snd_controls[] = {
+	SOC_SINGLE_TLV("Speaker Volume", TAS27XX_DVC, 0,
+		       TAS27XX_DVC_MAX, 1, tas27xx_playback_volume),
+	SOC_SINGLE_TLV("Amp Gain Volume", TAS27XX_CHNL_0, 0, 0x14, 0,
+		       tas27xx_digital_tlv),
 };
 
-static const struct snd_soc_component_driver soc_component_driver_tas2764 = {
-	.probe			= tas2764_codec_probe,
-	.suspend		= tas2764_codec_suspend,
-	.resume			= tas2764_codec_resume,
-	.set_bias_level		= tas2764_set_bias_level,
-	.controls		= tas2764_snd_controls,
-	.num_controls		= ARRAY_SIZE(tas2764_snd_controls),
-	.dapm_widgets		= tas2764_dapm_widgets,
-	.num_dapm_widgets	= ARRAY_SIZE(tas2764_dapm_widgets),
-	.dapm_routes		= tas2764_audio_map,
-	.num_dapm_routes	= ARRAY_SIZE(tas2764_audio_map),
+static const struct snd_soc_component_driver soc_component_driver_tas27xx = {
+	.probe			= tas27xx_codec_probe,
+	.suspend		= tas27xx_codec_suspend,
+	.resume			= tas27xx_codec_resume,
+	.set_bias_level		= tas27xx_set_bias_level,
+	.controls		= tas27xx_snd_controls,
+	.num_controls		= ARRAY_SIZE(tas27xx_snd_controls),
+	.dapm_widgets		= tas27xx_dapm_widgets,
+	.num_dapm_widgets	= ARRAY_SIZE(tas27xx_dapm_widgets),
+	.dapm_routes		= tas27xx_audio_map,
+	.num_dapm_routes	= ARRAY_SIZE(tas27xx_audio_map),
 	.idle_bias_on		= 1,
 	.endianness		= 1,
 	.non_legacy_dai_naming	= 1,
 };
 
-static const struct reg_default tas2764_reg_defaults[] = {
-	{ TAS2764_PAGE, 0x00 },
-	{ TAS2764_SW_RST, 0x00 },
-	{ TAS2764_PWR_CTRL, 0x1a },
-	{ TAS2764_DVC, 0x00 },
-	{ TAS2764_CHNL_0, 0x00 },
-	{ TAS2764_TDM_CFG0, 0x09 },
-	{ TAS2764_TDM_CFG1, 0x02 },
-	{ TAS2764_TDM_CFG2, 0x0a },
-	{ TAS2764_TDM_CFG3, 0x10 },
-	{ TAS2764_TDM_CFG5, 0x42 },
+static const struct reg_default tas27xx_reg_defaults[] = {
+	{ TAS27XX_PAGE, 0x00 },
+	{ TAS27XX_SW_RST, 0x00 },
+	{ TAS27XX_PWR_CTRL, 0x1a },
+	{ TAS27XX_DVC, 0x00 },
+	{ TAS27XX_CHNL_0, 0x00 },
+	{ TAS27XX_TDM_CFG0, 0x09 },
+	{ TAS27XX_TDM_CFG1, 0x02 },
+	{ TAS27XX_TDM_CFG2, 0x0a },
+	{ TAS27XX_TDM_CFG3, 0x10 },
+	{ TAS27XX_TDM_CFG5, 0x42 },
 };
 
-static const struct regmap_range_cfg tas2764_regmap_ranges[] = {
+static const struct regmap_range_cfg tas27xx_regmap_ranges[] = {
 	{
 		.range_min = 0,
 		.range_max = 1 * 128,
-		.selector_reg = TAS2764_PAGE,
+		.selector_reg = TAS27XX_PAGE,
 		.selector_mask = 0xff,
 		.selector_shift = 0,
 		.window_start = 0,
@@ -576,113 +590,113 @@ static const struct regmap_range_cfg tas2764_regmap_ranges[] = {
 	},
 };
 
-static const struct regmap_config tas2764_i2c_regmap = {
+static const struct regmap_config tas27xx_i2c_regmap = {
 	.reg_bits = 8,
 	.val_bits = 8,
-	.reg_defaults = tas2764_reg_defaults,
-	.num_reg_defaults = ARRAY_SIZE(tas2764_reg_defaults),
+	.reg_defaults = tas27xx_reg_defaults,
+	.num_reg_defaults = ARRAY_SIZE(tas27xx_reg_defaults),
 	.cache_type = REGCACHE_RBTREE,
-	.ranges = tas2764_regmap_ranges,
-	.num_ranges = ARRAY_SIZE(tas2764_regmap_ranges),
+	.ranges = tas27xx_regmap_ranges,
+	.num_ranges = ARRAY_SIZE(tas27xx_regmap_ranges),
 	.max_register = 1 * 128,
 };
 
-static int tas2764_parse_dt(struct device *dev, struct tas2764_priv *tas2764)
+static int tas27xx_parse_dt(struct device *dev, struct tas27xx_priv *tas27xx)
 {
 	int ret = 0;
 
-	tas2764->reset_gpio = devm_gpiod_get_optional(tas2764->dev, "reset",
+	tas27xx->reset_gpio = devm_gpiod_get_optional(tas27xx->dev, "reset",
 						      GPIOD_OUT_HIGH);
-	if (IS_ERR(tas2764->reset_gpio)) {
-		if (PTR_ERR(tas2764->reset_gpio) == -EPROBE_DEFER) {
-			tas2764->reset_gpio = NULL;
+	if (IS_ERR(tas27xx->reset_gpio)) {
+		if (PTR_ERR(tas27xx->reset_gpio) == -EPROBE_DEFER) {
+			tas27xx->reset_gpio = NULL;
 			return -EPROBE_DEFER;
 		}
 	}
 
-	tas2764->sdz_gpio = devm_gpiod_get_optional(dev, "shutdown", GPIOD_OUT_HIGH);
-	if (IS_ERR(tas2764->sdz_gpio)) {
-		if (PTR_ERR(tas2764->sdz_gpio) == -EPROBE_DEFER)
+	tas27xx->sdz_gpio = devm_gpiod_get_optional(dev, "shutdown", 
+		GPIOD_OUT_HIGH);
+	if (IS_ERR(tas27xx->sdz_gpio)) {
+		if (PTR_ERR(tas27xx->sdz_gpio) == -EPROBE_DEFER)
 			return -EPROBE_DEFER;
 
-		tas2764->sdz_gpio = NULL;
+		tas27xx->sdz_gpio = NULL;
 	}
 
 	ret = fwnode_property_read_u32(dev->fwnode, "ti,imon-slot-no",
-				       &tas2764->i_sense_slot);
+				       &tas27xx->i_sense_slot);
 	if (ret)
-		tas2764->i_sense_slot = 0;
+		tas27xx->i_sense_slot = 0;
 
 	ret = fwnode_property_read_u32(dev->fwnode, "ti,vmon-slot-no",
-				       &tas2764->v_sense_slot);
+				       &tas27xx->v_sense_slot);
 	if (ret)
-		tas2764->v_sense_slot = 2;
+		tas27xx->v_sense_slot = 2;
 
 	return 0;
 }
 
-static int tas2764_i2c_probe(struct i2c_client *client,
+static int tas27xx_i2c_probe(struct i2c_client *client,
 			const struct i2c_device_id *id)
 {
-	struct tas2764_priv *tas2764;
+	struct tas27xx_priv *tas27xx;
 	int result;
 
-	tas2764 = devm_kzalloc(&client->dev, sizeof(struct tas2764_priv),
+	tas27xx = devm_kzalloc(&client->dev, sizeof(struct tas27xx_priv),
 			       GFP_KERNEL);
-	if (!tas2764)
+	if (!tas27xx)
 		return -ENOMEM;
 
-	tas2764->dev = &client->dev;
-	i2c_set_clientdata(client, tas2764);
-	dev_set_drvdata(&client->dev, tas2764);
+	tas27xx->dev = &client->dev;
+	i2c_set_clientdata(client, tas27xx);
+	dev_set_drvdata(&client->dev, tas27xx);
 
-	tas2764->regmap = devm_regmap_init_i2c(client, &tas2764_i2c_regmap);
-	if (IS_ERR(tas2764->regmap)) {
-		result = PTR_ERR(tas2764->regmap);
+	tas27xx->regmap = devm_regmap_init_i2c(client, &tas27xx_i2c_regmap);
+	if (IS_ERR(tas27xx->regmap)) {
+		result = PTR_ERR(tas27xx->regmap);
 		dev_err(&client->dev, "Failed to allocate register map: %d\n",
 					result);
 		return result;
 	}
 
 	if (client->dev.of_node) {
-		result = tas2764_parse_dt(&client->dev, tas2764);
+		result = tas27xx_parse_dt(&client->dev, tas27xx);
 		if (result) {
-			dev_err(tas2764->dev, "%s: Failed to parse devicetree\n",
-				__func__);
+			dev_err(tas27xx->dev, 
+				"%s: Failed to parse devicetree\n", __func__);
 			return result;
 		}
 	}
 
-	return devm_snd_soc_register_component(tas2764->dev,
-					       &soc_component_driver_tas2764,
-					       tas2764_dai_driver,
-					       ARRAY_SIZE(tas2764_dai_driver));
+	return devm_snd_soc_register_component(tas27xx->dev,
+		&soc_component_driver_tas27xx, tas27xx_dai_driver,
+		ARRAY_SIZE(tas27xx_dai_driver));
 }
 
-static const struct i2c_device_id tas2764_i2c_id[] = {
-	{ "tas2764", 0},
+static const struct i2c_device_id tas27xx_i2c_id[] = {
+	{ "tas2764", TAS2764},
 	{ }
 };
-MODULE_DEVICE_TABLE(i2c, tas2764_i2c_id);
+MODULE_DEVICE_TABLE(i2c, tas27xx_i2c_id);
 
 #if defined(CONFIG_OF)
-static const struct of_device_id tas2764_of_match[] = {
+static const struct of_device_id tas27xx_of_match[] = {
 	{ .compatible = "ti,tas2764" },
 	{},
 };
-MODULE_DEVICE_TABLE(of, tas2764_of_match);
+MODULE_DEVICE_TABLE(of, tas27xx_of_match);
 #endif
 
-static struct i2c_driver tas2764_i2c_driver = {
+static struct i2c_driver tas27xx_i2c_driver = {
 	.driver = {
-		.name   = "tas2764",
-		.of_match_table = of_match_ptr(tas2764_of_match),
+		.name   = "tas27xx",
+		.of_match_table = of_match_ptr(tas27xx_of_match),
 	},
-	.probe      = tas2764_i2c_probe,
-	.id_table   = tas2764_i2c_id,
+	.probe      = tas27xx_i2c_probe,
+	.id_table   = tas27xx_i2c_id,
 };
-module_i2c_driver(tas2764_i2c_driver);
+module_i2c_driver(tas27xx_i2c_driver);
 
 MODULE_AUTHOR("Dan Murphy <dmurphy@ti.com>");
-MODULE_DESCRIPTION("TAS2764 I2C Smart Amplifier driver");
+MODULE_DESCRIPTION("TAS27XX I2C Smart Amplifier driver");
 MODULE_LICENSE("GPL v2");
-- 
2.35.1



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

* [PATCH v5 4/4] update tas27xx.c to support either TAS2764 or TAS2780
  2022-03-30 14:45 [PATCH v5 1/4] rename tas2764 to tas27xx Raphael-Xu
  2022-03-30 14:45 ` [PATCH v5 2/4] update tas27xx.h to support either TAS2764 or TAS2780 Raphael-Xu
  2022-03-30 14:45 ` [PATCH v5 3/4] rename variables from tas2764 to tas27xx Raphael-Xu
@ 2022-03-30 14:45 ` Raphael-Xu
  2022-03-30 17:25   ` Amadeusz Sławiński
                     ` (3 more replies)
  2 siblings, 4 replies; 10+ messages in thread
From: Raphael-Xu @ 2022-03-30 14:45 UTC (permalink / raw)
  To: broonie; +Cc: navada, alsa-devel, shenghao-ding, raphael-xu, Raphael-Xu

Signed-off-by: Raphael-Xu <13691752556@139.com>
---
 sound/soc/codecs/tas27xx.c | 378 ++++++++++++++++++++++++++-----------
 1 file changed, 263 insertions(+), 115 deletions(-)

diff --git a/sound/soc/codecs/tas27xx.c b/sound/soc/codecs/tas27xx.c
index 8118429bb2f5..bb845d4797ce 100644
--- a/sound/soc/codecs/tas27xx.c
+++ b/sound/soc/codecs/tas27xx.c
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
-//
-// Driver for the Texas Instruments TAS27XX CODEC
-// Copyright (C) 2020 Texas Instruments Inc.
+// Driver for the Texas Instruments TAS2764/TAS2780 Mono
+//		Audio amplifier
+// Copyright (C) 2022 Texas Instruments Inc.
 
 #include <linux/module.h>
 #include <linux/moduleparam.h>
@@ -12,16 +12,15 @@
 #include <linux/i2c.h>
 #include <linux/gpio.h>
 #include <linux/gpio/consumer.h>
-#include <linux/regulator/consumer.h>
 #include <linux/regmap.h>
 #include <linux/of.h>
 #include <linux/of_gpio.h>
-#include <linux/slab.h>
 #include <sound/soc.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/initval.h>
 #include <sound/tlv.h>
+#include <linux/version.h>
 
 #include "tas27xx.h"
 
@@ -31,9 +30,16 @@ struct tas27xx_priv {
 	struct gpio_desc *sdz_gpio;
 	struct regmap *regmap;
 	struct device *dev;
-	
+	struct mutex codec_lock;
 	int v_sense_slot;
 	int i_sense_slot;
+	int device_id;
+	bool mb_power_up;
+};
+
+enum tas27xx {
+	TAS2764 = 0,
+	TAS2780 = 1,
 };
 
 static void tas27xx_reset(struct tas27xx_priv *tas27xx)
@@ -53,32 +59,52 @@ static int tas27xx_set_bias_level(struct snd_soc_component *component,
 {
 	struct tas27xx_priv *tas27xx = 
 		snd_soc_component_get_drvdata(component);
-
+	int ret = 0;
+	
+	mutex_lock(&tas27xx->codec_lock);
 	switch (level) {
 	case SND_SOC_BIAS_ON:
-		snd_soc_component_update_bits(component, TAS27XX_PWR_CTRL,
-					      TAS27XX_PWR_CTRL_MASK,
-					      TAS27XX_PWR_CTRL_ACTIVE);
+		ret = snd_soc_component_update_bits(component, 
+					TAS27XX_PWR_CTRL,
+					TAS27XX_PWR_CTRL_MASK,
+					TAS27XX_PWR_CTRL_ACTIVE);
+		if (ret >= 0) {
+			tas27xx->mb_power_up = true;
+			ret = 0;
+		}
 		break;
 	case SND_SOC_BIAS_STANDBY:
 	case SND_SOC_BIAS_PREPARE:
-		snd_soc_component_update_bits(component, TAS27XX_PWR_CTRL,
-					      TAS27XX_PWR_CTRL_MASK,
-					      TAS27XX_PWR_CTRL_MUTE);
+		ret = snd_soc_component_update_bits(component,
+			TAS27XX_PWR_CTRL,
+			TAS27XX_PWR_CTRL_MASK,
+			TAS27XX_PWR_CTRL_MUTE);
+		if (ret >= 0) {
+			tas27xx->mb_power_up = true;
+			ret = 0;
+		}
 		break;
 	case SND_SOC_BIAS_OFF:
-		snd_soc_component_update_bits(component, TAS27XX_PWR_CTRL,
-					      TAS27XX_PWR_CTRL_MASK,
-					      TAS27XX_PWR_CTRL_SHUTDOWN);
+		ret = snd_soc_component_update_bits(component,
+			TAS27XX_PWR_CTRL,
+			TAS27XX_PWR_CTRL_MASK,
+			TAS27XX_PWR_CTRL_SHUTDOWN);
+		if (ret >= 0) {
+			tas27xx->mb_power_up = false;
+			ret = 0;
+		}
 		break;
 
 	default:
 		dev_err(tas27xx->dev,
-				"wrong power level setting %d\n", level);
-		return -EINVAL;
+			"wrong power level setting %d\n", level);
+		ret = -EINVAL;
 	}
-
-	return 0;
+	if (ret < 0)
+		pr_err("%s:%u:errCode:0x%0x:set BIAS error\n",
+			__func__, __LINE__, ret);
+	mutex_unlock(&tas27xx->codec_lock);
+	return ret;
 }
 
 #ifdef CONFIG_PM
@@ -86,30 +112,37 @@ static int tas27xx_codec_suspend(struct snd_soc_component *component)
 {
 	struct tas27xx_priv *tas27xx = 
 		snd_soc_component_get_drvdata(component);
-	int ret;
+	int ret = 0;
 
+	mutex_lock(&tas27xx->codec_lock);
 	ret = snd_soc_component_update_bits(component, TAS27XX_PWR_CTRL,
 					    TAS27XX_PWR_CTRL_MASK,
 					    TAS27XX_PWR_CTRL_SHUTDOWN);
 
-	if (ret < 0)
-		return ret;
-
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%0x:power down error\n",
+			__func__, __LINE__, ret);
+		goto EXIT;
+	}
+	ret = 0;
+	tas27xx->mb_power_up = false;
 	if (tas27xx->sdz_gpio)
 		gpiod_set_value_cansleep(tas27xx->sdz_gpio, 0);
 
 	regcache_cache_only(tas27xx->regmap, true);
 	regcache_mark_dirty(tas27xx->regmap);
-
-	return 0;
+EXIT:
+	mutex_unlock(&tas27xx->codec_lock);
+	return ret;
 }
 
 static int tas27xx_codec_resume(struct snd_soc_component *component)
 {
 	struct tas27xx_priv *tas27xx = 
 		snd_soc_component_get_drvdata(component);
-	int ret;
+	int ret = 0;
 
+	mutex_lock(&tas27xx->codec_lock);
 	if (tas27xx->sdz_gpio)
 		gpiod_set_value_cansleep(tas27xx->sdz_gpio, 1);
 
@@ -117,16 +150,19 @@ static int tas27xx_codec_resume(struct snd_soc_component *component)
 					    TAS27XX_PWR_CTRL_MASK,
 					    TAS27XX_PWR_CTRL_ACTIVE);
 
-	if (ret < 0)
-		return ret;
-
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%0x:power down error\n",
+			__func__, __LINE__, ret);
+		goto EXIT;
+	}
+	ret = 0;
+	tas27xx->mb_power_up = false;
 	regcache_cache_only(tas27xx->regmap, false);
-
-	return regcache_sync(tas27xx->regmap);
+	ret = regcache_sync(tas27xx->regmap);
+EXIT:
+	mutex_unlock(&tas27xx->codec_lock);
+	return ret;
 }
-#else
-#define tas27xx_codec_suspend NULL
-#define tas27xx_codec_resume NULL
 #endif
 
 static const char * const tas27xx_ASI1_src[] = {
@@ -146,8 +182,9 @@ static int tas27xx_dac_event(struct snd_soc_dapm_widget *w,
 		snd_soc_dapm_to_component(w->dapm);
 	struct tas27xx_priv *tas27xx = 
 		snd_soc_component_get_drvdata(component);
-	int ret;
+	int ret = 0;
 
+	mutex_lock(&tas27xx->codec_lock);
 	switch (event) {
 	case SND_SOC_DAPM_POST_PMU:
 		ret = snd_soc_component_update_bits(component, 
@@ -163,13 +200,16 @@ static int tas27xx_dac_event(struct snd_soc_dapm_widget *w,
 		break;
 	default:
 		dev_err(tas27xx->dev, "Unsupported event\n");
-		return -EINVAL;
+			ret = -EINVAL;
 	}
-
-	if (ret < 0)
-		return ret;
-
-	return 0;
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%0x:PWR_CTRL error\n",
+			__func__, __LINE__, ret);
+	} else {
+		ret = 0;
+	}
+	mutex_unlock(&tas27xx->codec_lock);
+	return ret;
 }
 
 static const struct snd_kcontrol_new isense_switch =
@@ -207,55 +247,96 @@ static const struct snd_soc_dapm_route tas27xx_audio_map[] = {
 static int tas27xx_mute(struct snd_soc_dai *dai, int mute, int direction)
 {
 	struct snd_soc_component *component = dai->component;
-	int ret;
+	struct tas27xx_priv *tas27xx =
+		snd_soc_component_get_drvdata(component);
+	int ret = 0;
+	
+	mutex_lock(&tas27xx->codec_lock);
 
+	if (mute == 0) {
+		ret = snd_soc_component_update_bits(component,
+			TAS27XX_CLK_CFG,
+			TAS27XX_CLK_CFG_MASK,
+			TAS27XX_CLK_CFG_ENABLE);
+		if (ret < 0) {
+			dev_err(tas27xx->dev,
+				"%s:%u: Failed to CLK_CFG_ENABLE\n",
+				__func__, __LINE__);
+			goto EXIT;
+		}
+		usleep_range(2000, 2000);
+	}
 	ret = snd_soc_component_update_bits(component, TAS27XX_PWR_CTRL,
-					    TAS27XX_PWR_CTRL_MASK,
-					    mute ? TAS27XX_PWR_CTRL_MUTE : 0);
-
-	if (ret < 0)
-		return ret;
+		TAS27XX_PWR_CTRL_MASK,
+		mute ? TAS27XX_PWR_CTRL_MUTE : 0);
+	if (ret >= 0) {
+		tas27xx->mb_power_up = mute?false:true;
+		ret = 0;
+	}
 
-	return 0;
+	if (ret < 0) {
+		pr_err("%s:%u: Failed to set powercontrol\n",
+			__func__, __LINE__);
+	}
+EXIT:
+	mutex_unlock(&tas27xx->codec_lock);
+	return ret;
 }
 
 static int tas27xx_set_bitwidth(struct tas27xx_priv *tas27xx, int bitwidth)
 {
 	struct snd_soc_component *component = tas27xx->component;
-	int sense_en;
-	int val;
-	int ret;
+	int sense_en, val, ret, slot_size;
 
+	mutex_lock(&tas27xx->codec_lock);
 	switch (bitwidth) {
 	case SNDRV_PCM_FORMAT_S16_LE:
 		ret = snd_soc_component_update_bits(component,
-					TAS27XX_TDM_CFG2,
-					TAS27XX_TDM_CFG2_RXW_MASK,
-					TAS27XX_TDM_CFG2_RXW_16BITS);
+			TAS27XX_TDM_CFG2,
+			TAS27XX_TDM_CFG2_RXW_MASK,
+			TAS27XX_TDM_CFG2_RXW_16BITS);
+		slot_size = TAS27XX_TDM_CFG2_RXS_16BITS;
 		break;
 	case SNDRV_PCM_FORMAT_S24_LE:
 		ret = snd_soc_component_update_bits(component,
 					TAS27XX_TDM_CFG2,
 					TAS27XX_TDM_CFG2_RXW_MASK,
 					TAS27XX_TDM_CFG2_RXW_24BITS);
+		slot_size = TAS27XX_TDM_CFG2_RXS_24BITS;
 		break;
 	case SNDRV_PCM_FORMAT_S32_LE:
 		ret = snd_soc_component_update_bits(component,
 					TAS27XX_TDM_CFG2,
 					TAS27XX_TDM_CFG2_RXW_MASK,
 					TAS27XX_TDM_CFG2_RXW_32BITS);
+		slot_size = TAS27XX_TDM_CFG2_RXS_32BITS;
 		break;
 
 	default:
-		return -EINVAL;
+		ret = -EINVAL;
 	}
 
-	if (ret < 0)
-		return ret;
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%x set bitwidth error\n",
+			__func__, __LINE__, ret);
+		goto EXIT;
+	}
+
+	ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG2,
+		TAS27XX_TDM_CFG2_RXS_MASK, slot_size);
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%x set RX slot size error\n",
+			__func__, __LINE__, ret);
+		goto EXIT;
+	}
 
 	val = snd_soc_component_read(tas27xx->component, TAS27XX_PWR_CTRL);
-	if (val < 0)
-		return val;
+	if (val < 0) {
+		pr_err("%s:%u:errCode:0x%x read PWR_CTRL error\n",
+			__func__, __LINE__, val);
+		ret = val;
+		goto EXIT;
+	}
 
 	if (val & (1 << TAS27XX_VSENSE_POWER_EN))
 		sense_en = 0;
@@ -264,8 +345,11 @@ static int tas27xx_set_bitwidth(struct tas27xx_priv *tas27xx, int bitwidth)
 
 	ret = snd_soc_component_update_bits(tas27xx->component, 
 		TAS27XX_TDM_CFG5, TAS27XX_TDM_CFG5_VSNS_ENABLE, sense_en);
-	if (ret < 0)
-		return ret;
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%x enable vSNS error\n",
+			__func__, __LINE__, ret);
+		goto EXIT;
+	}
 
 	if (val & (1 << TAS27XX_ISENSE_POWER_EN))
 		sense_en = 0;
@@ -274,10 +358,14 @@ static int tas27xx_set_bitwidth(struct tas27xx_priv *tas27xx, int bitwidth)
 
 	ret = snd_soc_component_update_bits(tas27xx->component, 
 		TAS27XX_TDM_CFG6, TAS27XX_TDM_CFG6_ISNS_ENABLE, sense_en);
-	if (ret < 0)
-		return ret;
-
-	return 0;
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%x enable iSNS error\n",
+			__func__, __LINE__, ret);
+	}
+	ret = 0;
+EXIT:
+	mutex_unlock(&tas27xx->codec_lock);
+	return ret;
 }
 
 static int tas27xx_set_samplerate(
@@ -307,15 +395,20 @@ static int tas27xx_set_samplerate(
 	default:
 		return -EINVAL;
 	}
-
+	mutex_lock(&tas27xx->codec_lock);
 	ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG0,
 					    TAS27XX_TDM_CFG0_SMP_MASK |
 					    TAS27XX_TDM_CFG0_MASK,
 					    ramp_rate_val);
-	if (ret < 0)
-		return ret;
-
-	return 0;
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%x Failed to set ramp_rate_val\n",
+			__func__, __LINE__, ret);
+		goto EXIT;
+	}
+	ret = 0;
+EXIT:
+	mutex_unlock(&tas27xx->codec_lock);
+	return ret;
 }
 
 static int tas27xx_hw_params(struct snd_pcm_substream *substream,
@@ -341,7 +434,7 @@ static int tas27xx_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
 		snd_soc_component_get_drvdata(component);
 	u8 tdm_rx_start_slot = 0, asi_cfg_1 = 0;
 	int iface;
-	int ret;
+	int ret = 0;
 
 	switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
 	case SND_SOC_DAIFMT_NB_NF:
@@ -354,12 +447,15 @@ static int tas27xx_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
 		dev_err(tas27xx->dev, "ASI format Inverse is not found\n");
 		return -EINVAL;
 	}
-
+	mutex_lock(&tas27xx->codec_lock);
 	ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG1,
 					    TAS27XX_TDM_CFG1_RX_MASK,
 					    asi_cfg_1);
-	if (ret < 0)
-		return ret;
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%x Failed to set asi_cfg_1\n",
+			__func__, __LINE__, ret);
+		goto EXIT;
+	}
 
 	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
 	case SND_SOC_DAIFMT_I2S:
@@ -373,23 +469,32 @@ static int tas27xx_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
 		tdm_rx_start_slot = 0;
 		break;
 	default:
-		dev_err(tas27xx->dev,
-			"DAI Format is not found, fmt=0x%x\n", fmt);
-		return -EINVAL;
+		pr_err("%s:%u:DAI Format is not found, fmt=0x%x\n",
+			__func__, __LINE__, fmt);
+		ret = -EINVAL;
+		goto EXIT;
 	}
 
 	ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG1,
 		TAS27XX_TDM_CFG1_MASK,
 		(tdm_rx_start_slot << TAS27XX_TDM_CFG1_51_SHIFT));
-	if (ret < 0)
-		return ret;
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%x Failed to set tdm_rx_start_slot\n",
+			__func__, __LINE__, ret);
+		goto EXIT;
+	}
 
 	ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG2,
 		TAS27XX_TDM_CFG2_SCFG_MASK, iface);
-	if (ret < 0)
-		return ret;
-
-	return 0;
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%x Failed to set iface\n",
+			__func__, __LINE__, ret);
+		goto EXIT;
+	}
+	ret = 0;
+EXIT:
+	mutex_unlock(&tas27xx->codec_lock);
+	return ret;
 }
 
 static int tas27xx_set_dai_tdm_slot(struct snd_soc_dai *dai,
@@ -403,7 +508,7 @@ static int tas27xx_set_dai_tdm_slot(struct snd_soc_dai *dai,
 	int left_slot, right_slot;
 	int slots_cfg;
 	int slot_size;
-	int ret;
+	int ret = 0;
 
 	if (tx_mask == 0 || rx_mask != 0)
 		return -EINVAL;
@@ -428,10 +533,13 @@ static int tas27xx_set_dai_tdm_slot(struct snd_soc_dai *dai,
 		return -EINVAL;
 
 	slots_cfg = (right_slot << TAS27XX_TDM_CFG3_RXS_SHIFT) | left_slot;
-
+	mutex_lock(&tas27xx->codec_lock);
 	ret = snd_soc_component_write(component, TAS27XX_TDM_CFG3, slots_cfg);
-	if (ret)
-		return ret;
+	if (ret) {
+		pr_err("%s:%u:errCode:0x%x Failed to set slots_cfg\n",
+			__func__, __LINE__, ret);
+		goto EXIT;
+	}
 
 	switch (slot_width) {
 	case 16:
@@ -444,28 +552,40 @@ static int tas27xx_set_dai_tdm_slot(struct snd_soc_dai *dai,
 		slot_size = TAS27XX_TDM_CFG2_RXS_32BITS;
 		break;
 	default:
-		return -EINVAL;
+		ret = -EINVAL;
+		goto EXIT;
 	}
 
 	ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG2,
 					    TAS27XX_TDM_CFG2_RXS_MASK,
 					    slot_size);
-	if (ret < 0)
-		return ret;
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%x Failed to set slot_size\n",
+			__func__, __LINE__, ret);
+		goto EXIT;
+	}
 
 	ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG5,
 					    TAS27XX_TDM_CFG5_50_MASK,
 					    tas27xx->v_sense_slot);
-	if (ret < 0)
-		return ret;
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%x Failed to set v_sense_slot\n",
+			__func__, __LINE__, ret);
+		goto EXIT;
+	}
 
 	ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG6,
 					    TAS27XX_TDM_CFG6_50_MASK,
 					    tas27xx->i_sense_slot);
-	if (ret < 0)
-		return ret;
-
-	return 0;
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%x Failed to set i_sense_slot\n",
+			__func__, __LINE__, ret);
+		goto EXIT;
+	}
+	ret = 0;
+EXIT:
+	mutex_unlock(&tas27xx->codec_lock);
+	return ret;
 }
 
 static const struct snd_soc_dai_ops tas27xx_dai_ops = {
@@ -495,13 +615,13 @@ static struct snd_soc_dai_driver tas27xx_dai_driver[] = {
 		},
 		.capture = {
 			.stream_name    = "ASI1 Capture",
-			.channels_min   = 0,
+			.channels_min   = 1,
 			.channels_max   = 2,
 			.rates = TAS27XX_RATES,
 			.formats = TAS27XX_FORMATS,
 		},
 		.ops = &tas27xx_dai_ops,
-		.symmetric_rate = 1,
+		.symmetric_rates = 1,
 	},
 };
 
@@ -509,7 +629,7 @@ static int tas27xx_codec_probe(struct snd_soc_component *component)
 {
 	struct tas27xx_priv *tas27xx = 
 		snd_soc_component_get_drvdata(component);
-	int ret;
+	int ret = 0;
 
 	tas27xx->component = component;
 
@@ -518,25 +638,39 @@ static int tas27xx_codec_probe(struct snd_soc_component *component)
 
 	tas27xx_reset(tas27xx);
 
-	ret = snd_soc_component_update_bits(tas27xx->component, 
-						TAS27XX_TDM_CFG5,
+	ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG5,
 					    TAS27XX_TDM_CFG5_VSNS_ENABLE, 0);
-	if (ret < 0)
-		return ret;
-
-	ret = snd_soc_component_update_bits(tas27xx->component, 
-						TAS27XX_TDM_CFG6,
+	if (ret < 0) {
+		dev_err(tas27xx->dev, "%s:%u: Failed to enable vSNS\n",
+			__func__, __LINE__);
+		goto EXIT;
+	}
+	ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG6,
 					    TAS27XX_TDM_CFG6_ISNS_ENABLE, 0);
-	if (ret < 0)
-		return ret;
-
+	if (ret < 0) {
+		dev_err(tas27xx->dev, "%s:%u: Failed to enable iSNS\n",
+			__func__, __LINE__);
+		goto EXIT;
+	}
 	ret = snd_soc_component_update_bits(component, TAS27XX_PWR_CTRL,
 					    TAS27XX_PWR_CTRL_MASK,
 					    TAS27XX_PWR_CTRL_MUTE);
-	if (ret < 0)
-		return ret;
+	if (ret < 0) {
+		dev_err(tas27xx->dev, "%s:%u: Failed to PWR_CTRL_MUTE\n",
+			__func__, __LINE__);
+		goto EXIT;
+	}
 
-	return 0;
+	ret = snd_soc_component_write(component, TAS27XX_PWR_CTRL, 0x02);
+
+	if (ret < 0) {
+		dev_err(tas27xx->dev, "%s:%u: Failed to initial active\n",
+			__func__, __LINE__);
+		goto EXIT;
+	}
+	ret = 0;
+EXIT:
+	return ret;
 }
 
 static DECLARE_TLV_DB_SCALE(tas27xx_digital_tlv, 1100, 50, 0);
@@ -551,8 +685,10 @@ static const struct snd_kcontrol_new tas27xx_snd_controls[] = {
 
 static const struct snd_soc_component_driver soc_component_driver_tas27xx = {
 	.probe			= tas27xx_codec_probe,
+#ifdef CONFIG_PM
 	.suspend		= tas27xx_codec_suspend,
 	.resume			= tas27xx_codec_resume,
+#endif
 	.set_bias_level		= tas27xx_set_bias_level,
 	.controls		= tas27xx_snd_controls,
 	.num_controls		= ARRAY_SIZE(tas27xx_snd_controls),
@@ -590,6 +726,12 @@ static const struct regmap_range_cfg tas27xx_regmap_ranges[] = {
 	},
 };
 
+static bool tas27xx_volatile(struct device *dev,
+	unsigned int reg)
+{
+		return true;
+}
+
 static const struct regmap_config tas27xx_i2c_regmap = {
 	.reg_bits = 8,
 	.val_bits = 8,
@@ -599,6 +741,7 @@ static const struct regmap_config tas27xx_i2c_regmap = {
 	.ranges = tas27xx_regmap_ranges,
 	.num_ranges = ARRAY_SIZE(tas27xx_regmap_ranges),
 	.max_register = 1 * 128,
+	.volatile_reg = tas27xx_volatile,
 };
 
 static int tas27xx_parse_dt(struct device *dev, struct tas27xx_priv *tas27xx)
@@ -646,7 +789,7 @@ static int tas27xx_i2c_probe(struct i2c_client *client,
 			       GFP_KERNEL);
 	if (!tas27xx)
 		return -ENOMEM;
-
+	mutex_init(&tas27xx->codec_lock);
 	tas27xx->dev = &client->dev;
 	i2c_set_clientdata(client, tas27xx);
 	dev_set_drvdata(&client->dev, tas27xx);
@@ -668,6 +811,9 @@ static int tas27xx_i2c_probe(struct i2c_client *client,
 		}
 	}
 
+	tas27xx->device_id = id->driver_data;
+	dev_info(tas27xx->dev, "chip_id: %u\n", tas27xx->device_id);
+
 	return devm_snd_soc_register_component(tas27xx->dev,
 		&soc_component_driver_tas27xx, tas27xx_dai_driver,
 		ARRAY_SIZE(tas27xx_dai_driver));
@@ -675,6 +821,7 @@ static int tas27xx_i2c_probe(struct i2c_client *client,
 
 static const struct i2c_device_id tas27xx_i2c_id[] = {
 	{ "tas2764", TAS2764},
+	{ "tas2780", TAS2780},
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, tas27xx_i2c_id);
@@ -682,6 +829,7 @@ MODULE_DEVICE_TABLE(i2c, tas27xx_i2c_id);
 #if defined(CONFIG_OF)
 static const struct of_device_id tas27xx_of_match[] = {
 	{ .compatible = "ti,tas2764" },
+	{ .compatible = "ti,tas2780" },
 	{},
 };
 MODULE_DEVICE_TABLE(of, tas27xx_of_match);
@@ -697,6 +845,6 @@ static struct i2c_driver tas27xx_i2c_driver = {
 };
 module_i2c_driver(tas27xx_i2c_driver);
 
-MODULE_AUTHOR("Dan Murphy <dmurphy@ti.com>");
+MODULE_AUTHOR("Raphael Xu <raphael-xu@ti.com>");
 MODULE_DESCRIPTION("TAS27XX I2C Smart Amplifier driver");
 MODULE_LICENSE("GPL v2");
-- 
2.35.1



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

* Re: [PATCH v5 4/4] update tas27xx.c to support either TAS2764 or TAS2780
  2022-03-30 14:45 ` [PATCH v5 4/4] update tas27xx.c to support either TAS2764 or TAS2780 Raphael-Xu
@ 2022-03-30 17:25   ` Amadeusz Sławiński
  2022-03-30 17:35   ` kernel test robot
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Amadeusz Sławiński @ 2022-03-30 17:25 UTC (permalink / raw)
  To: Raphael-Xu, broonie; +Cc: alsa-devel, raphael-xu, shenghao-ding, navada

On 3/30/2022 4:45 PM, Raphael-Xu wrote:

Missing commit message in this patch and previous one. Even one sentence 
explaining what you are doing and why is better then nothing.

Overall the series looks a lot better now, I still wonder if changing 
coding style makes sense, but ultimately it's your code, so as long as 
it patches checkpatch I will leave decision to Mark.

And there are few nitpicks, below in this patch.

> Signed-off-by: Raphael-Xu <13691752556@139.com>
> ---
>   sound/soc/codecs/tas27xx.c | 378 ++++++++++++++++++++++++++-----------
>   1 file changed, 263 insertions(+), 115 deletions(-)
> 
> diff --git a/sound/soc/codecs/tas27xx.c b/sound/soc/codecs/tas27xx.c
> index 8118429bb2f5..bb845d4797ce 100644
> --- a/sound/soc/codecs/tas27xx.c
> +++ b/sound/soc/codecs/tas27xx.c

...

> @@ -146,8 +182,9 @@ static int tas27xx_dac_event(struct snd_soc_dapm_widget *w,
>   		snd_soc_dapm_to_component(w->dapm);
>   	struct tas27xx_priv *tas27xx =
>   		snd_soc_component_get_drvdata(component);
> -	int ret;
> +	int ret = 0;
>   
> +	mutex_lock(&tas27xx->codec_lock);
>   	switch (event) {
>   	case SND_SOC_DAPM_POST_PMU:
>   		ret = snd_soc_component_update_bits(component,
> @@ -163,13 +200,16 @@ static int tas27xx_dac_event(struct snd_soc_dapm_widget *w,
>   		break;
>   	default:
>   		dev_err(tas27xx->dev, "Unsupported event\n");
> -		return -EINVAL;
> +			ret = -EINVAL;

There seems to be one tab to many here.

>   	}
> -
> -	if (ret < 0)
> -		return ret;
> -
> -	return 0;
> +	if (ret < 0) {
> +		pr_err("%s:%u:errCode:0x%0x:PWR_CTRL error\n",
> +			__func__, __LINE__, ret);
> +	} else {
> +		ret = 0;
> +	}
> +	mutex_unlock(&tas27xx->codec_lock);
> +	return ret;
>   }
>   
>   static const struct snd_kcontrol_new isense_switch =
> @@ -207,55 +247,96 @@ static const struct snd_soc_dapm_route tas27xx_audio_map[] = {
>   static int tas27xx_mute(struct snd_soc_dai *dai, int mute, int direction)
>   {
>   	struct snd_soc_component *component = dai->component;
> -	int ret;
> +	struct tas27xx_priv *tas27xx =
> +		snd_soc_component_get_drvdata(component);
> +	int ret = 0;
> +	
> +	mutex_lock(&tas27xx->codec_lock);
>   
> +	if (mute == 0) {

alternatively if (!mute), but you can leave as is

> +		ret = snd_soc_component_update_bits(component,
> +			TAS27XX_CLK_CFG,
> +			TAS27XX_CLK_CFG_MASK,
> +			TAS27XX_CLK_CFG_ENABLE);
> +		if (ret < 0) {
> +			dev_err(tas27xx->dev,
> +				"%s:%u: Failed to CLK_CFG_ENABLE\n",
> +				__func__, __LINE__);
> +			goto EXIT;
> +		}
> +		usleep_range(2000, 2000);
> +	}
>   	ret = snd_soc_component_update_bits(component, TAS27XX_PWR_CTRL,
> -					    TAS27XX_PWR_CTRL_MASK,
> -					    mute ? TAS27XX_PWR_CTRL_MUTE : 0);
> -
> -	if (ret < 0)
> -		return ret;
> +		TAS27XX_PWR_CTRL_MASK,
> +		mute ? TAS27XX_PWR_CTRL_MUTE : 0);
> +	if (ret >= 0) {
> +		tas27xx->mb_power_up = mute?false:true;
> +		ret = 0;
> +	}
>   
> -	return 0;
> +	if (ret < 0) {

You could probably just use } else { here with above if.

> +		pr_err("%s:%u: Failed to set powercontrol\n",
> +			__func__, __LINE__);
> +	}
> +EXIT:
> +	mutex_unlock(&tas27xx->codec_lock);
> +	return ret;
>   }
>   

...

>   
>   static const struct snd_soc_dai_ops tas27xx_dai_ops = {
> @@ -495,13 +615,13 @@ static struct snd_soc_dai_driver tas27xx_dai_driver[] = {
>   		},
>   		.capture = {
>   			.stream_name    = "ASI1 Capture",
> -			.channels_min   = 0,
> +			.channels_min   = 1,
>   			.channels_max   = 2,
>   			.rates = TAS27XX_RATES,
>   			.formats = TAS27XX_FORMATS,
>   		},
>   		.ops = &tas27xx_dai_ops,
> -		.symmetric_rate = 1,
> +		.symmetric_rates = 1,

I'm pretty sure struct snd_soc_dai_driver uses .symmetric_rate, so this 
change would result in build failure?

>   	},
>   };
>   
> @@ -509,7 +629,7 @@ static int tas27xx_codec_probe(struct snd_soc_component *component)
>   {
>   	struct tas27xx_priv *tas27xx =
>   		snd_soc_component_get_drvdata(component);
> -	int ret;
> +	int ret = 0;
>   
>   	tas27xx->component = component;
>   

...

>   
>   static DECLARE_TLV_DB_SCALE(tas27xx_digital_tlv, 1100, 50, 0);
> @@ -551,8 +685,10 @@ static const struct snd_kcontrol_new tas27xx_snd_controls[] = {
>   
>   static const struct snd_soc_component_driver soc_component_driver_tas27xx = {
>   	.probe			= tas27xx_codec_probe,
> +#ifdef CONFIG_PM
>   	.suspend		= tas27xx_codec_suspend,
>   	.resume			= tas27xx_codec_resume,
> +#endif
>   	.set_bias_level		= tas27xx_set_bias_level,
>   	.controls		= tas27xx_snd_controls,
>   	.num_controls		= ARRAY_SIZE(tas27xx_snd_controls),
> @@ -590,6 +726,12 @@ static const struct regmap_range_cfg tas27xx_regmap_ranges[] = {
>   	},
>   };
>   
> +static bool tas27xx_volatile(struct device *dev,
> +	unsigned int reg)
> +{
> +		return true;
> +}
> +

This seems bit weird, are all registers considered volatile?

>   static const struct regmap_config tas27xx_i2c_regmap = {
>   	.reg_bits = 8,
>   	.val_bits = 8,
> @@ -599,6 +741,7 @@ static const struct regmap_config tas27xx_i2c_regmap = {
>   	.ranges = tas27xx_regmap_ranges,
>   	.num_ranges = ARRAY_SIZE(tas27xx_regmap_ranges),
>   	.max_register = 1 * 128,
> +	.volatile_reg = tas27xx_volatile,
>   };
>   
>   static int tas27xx_parse_dt(struct device *dev, struct tas27xx_priv *tas27xx)

...

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

* Re: [PATCH v5 4/4] update tas27xx.c to support either TAS2764 or TAS2780
  2022-03-30 14:45 ` [PATCH v5 4/4] update tas27xx.c to support either TAS2764 or TAS2780 Raphael-Xu
  2022-03-30 17:25   ` Amadeusz Sławiński
@ 2022-03-30 17:35   ` kernel test robot
  2022-03-30 18:36     ` kernel test robot
  2022-03-31  3:59   ` kernel test robot
  3 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2022-03-30 17:35 UTC (permalink / raw)
  To: Raphael-Xu, broonie
  Cc: alsa-devel, kbuild-all, shenghao-ding, navada, raphael-xu,
	Raphael-Xu

Hi Raphael-Xu,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on broonie-sound/for-next]
[also build test WARNING on v5.17 next-20220330]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Raphael-Xu/rename-tas2764-to-tas27xx/20220330-224947
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20220331/202203310140.Sc6ERGdm-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/5e87128eec39d187eaf11069178b39d935600c2e
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Raphael-Xu/rename-tas2764-to-tas27xx/20220330-224947
        git checkout 5e87128eec39d187eaf11069178b39d935600c2e
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=alpha SHELL=/bin/bash sound/soc/codecs/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   sound/soc/codecs/tas27xx.c:624:18: error: 'struct snd_soc_dai_driver' has no member named 'symmetric_rates'; did you mean 'symmetric_rate'?
     624 |                 .symmetric_rates = 1,
         |                  ^~~~~~~~~~~~~~~
         |                  symmetric_rate
>> sound/soc/codecs/tas27xx.c:624:36: warning: initialization of 'const struct snd_soc_cdai_ops *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     624 |                 .symmetric_rates = 1,
         |                                    ^
   sound/soc/codecs/tas27xx.c:624:36: note: (near initialization for 'tas27xx_dai_driver[0].cops')


vim +624 sound/soc/codecs/tas27xx.c

   598	
   599	#define TAS27XX_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
   600				 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
   601	
   602	#define TAS27XX_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\
   603			       SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_88200)
   604	
   605	static struct snd_soc_dai_driver tas27xx_dai_driver[] = {
   606		{
   607			.name = "tas27xx ASI1",
   608			.id = 0,
   609			.playback = {
   610				.stream_name    = "ASI1 Playback",
   611				.channels_min   = 2,
   612				.channels_max   = 2,
   613				.rates      = TAS27XX_RATES,
   614				.formats    = TAS27XX_FORMATS,
   615			},
   616			.capture = {
   617				.stream_name    = "ASI1 Capture",
   618				.channels_min   = 1,
   619				.channels_max   = 2,
   620				.rates = TAS27XX_RATES,
   621				.formats = TAS27XX_FORMATS,
   622			},
   623			.ops = &tas27xx_dai_ops,
 > 624			.symmetric_rates = 1,
   625		},
   626	};
   627	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

* Re: [PATCH v5 4/4] update tas27xx.c to support either TAS2764 or TAS2780
  2022-03-30 14:45 ` [PATCH v5 4/4] update tas27xx.c to support either TAS2764 or TAS2780 Raphael-Xu
@ 2022-03-30 18:36     ` kernel test robot
  2022-03-30 17:35   ` kernel test robot
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2022-03-30 18:36 UTC (permalink / raw)
  To: Raphael-Xu, broonie
  Cc: alsa-devel, kbuild-all, llvm, shenghao-ding, navada, raphael-xu,
	Raphael-Xu

Hi Raphael-Xu,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on broonie-sound/for-next]
[also build test ERROR on v5.17 next-20220330]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Raphael-Xu/rename-tas2764-to-tas27xx/20220330-224947
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: arm-randconfig-r012-20220330 (https://download.01.org/0day-ci/archive/20220331/202203310255.mwJuw0DH-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 0f6d9501cf49ce02937099350d08f20c4af86f3d)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # https://github.com/intel-lab-lkp/linux/commit/5e87128eec39d187eaf11069178b39d935600c2e
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Raphael-Xu/rename-tas2764-to-tas27xx/20220330-224947
        git checkout 5e87128eec39d187eaf11069178b39d935600c2e
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash sound/soc/codecs/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> sound/soc/codecs/tas27xx.c:624:4: error: field designator 'symmetric_rates' does not refer to any field in type 'struct snd_soc_dai_driver'; did you mean 'symmetric_rate'?
                   .symmetric_rates = 1,
                    ^~~~~~~~~~~~~~~
                    symmetric_rate
   include/sound/soc-dai.h:411:15: note: 'symmetric_rate' declared here
           unsigned int symmetric_rate:1;
                        ^
>> sound/soc/codecs/tas27xx.c:819:3: error: invalid application of 'sizeof' to an incomplete type 'struct snd_soc_dai_driver[]'
                   ARRAY_SIZE(tas27xx_dai_driver));
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kernel.h:55:32: note: expanded from macro 'ARRAY_SIZE'
   #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
                                  ^~~~~
   2 errors generated.


vim +624 sound/soc/codecs/tas27xx.c

   598	
   599	#define TAS27XX_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
   600				 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
   601	
   602	#define TAS27XX_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\
   603			       SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_88200)
   604	
   605	static struct snd_soc_dai_driver tas27xx_dai_driver[] = {
   606		{
   607			.name = "tas27xx ASI1",
   608			.id = 0,
   609			.playback = {
   610				.stream_name    = "ASI1 Playback",
   611				.channels_min   = 2,
   612				.channels_max   = 2,
   613				.rates      = TAS27XX_RATES,
   614				.formats    = TAS27XX_FORMATS,
   615			},
   616			.capture = {
   617				.stream_name    = "ASI1 Capture",
   618				.channels_min   = 1,
   619				.channels_max   = 2,
   620				.rates = TAS27XX_RATES,
   621				.formats = TAS27XX_FORMATS,
   622			},
   623			.ops = &tas27xx_dai_ops,
 > 624			.symmetric_rates = 1,
   625		},
   626	};
   627	
   628	static int tas27xx_codec_probe(struct snd_soc_component *component)
   629	{
   630		struct tas27xx_priv *tas27xx = 
   631			snd_soc_component_get_drvdata(component);
   632		int ret = 0;
   633	
   634		tas27xx->component = component;
   635	
   636		if (tas27xx->sdz_gpio)
   637			gpiod_set_value_cansleep(tas27xx->sdz_gpio, 1);
   638	
   639		tas27xx_reset(tas27xx);
   640	
   641		ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG5,
   642						    TAS27XX_TDM_CFG5_VSNS_ENABLE, 0);
   643		if (ret < 0) {
   644			dev_err(tas27xx->dev, "%s:%u: Failed to enable vSNS\n",
   645				__func__, __LINE__);
   646			goto EXIT;
   647		}
   648		ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG6,
   649						    TAS27XX_TDM_CFG6_ISNS_ENABLE, 0);
   650		if (ret < 0) {
   651			dev_err(tas27xx->dev, "%s:%u: Failed to enable iSNS\n",
   652				__func__, __LINE__);
   653			goto EXIT;
   654		}
   655		ret = snd_soc_component_update_bits(component, TAS27XX_PWR_CTRL,
   656						    TAS27XX_PWR_CTRL_MASK,
   657						    TAS27XX_PWR_CTRL_MUTE);
   658		if (ret < 0) {
   659			dev_err(tas27xx->dev, "%s:%u: Failed to PWR_CTRL_MUTE\n",
   660				__func__, __LINE__);
   661			goto EXIT;
   662		}
   663	
   664		ret = snd_soc_component_write(component, TAS27XX_PWR_CTRL, 0x02);
   665	
   666		if (ret < 0) {
   667			dev_err(tas27xx->dev, "%s:%u: Failed to initial active\n",
   668				__func__, __LINE__);
   669			goto EXIT;
   670		}
   671		ret = 0;
   672	EXIT:
   673		return ret;
   674	}
   675	
   676	static DECLARE_TLV_DB_SCALE(tas27xx_digital_tlv, 1100, 50, 0);
   677	static DECLARE_TLV_DB_SCALE(tas27xx_playback_volume, -10000, 50, 0);
   678	
   679	static const struct snd_kcontrol_new tas27xx_snd_controls[] = {
   680		SOC_SINGLE_TLV("Speaker Volume", TAS27XX_DVC, 0,
   681			       TAS27XX_DVC_MAX, 1, tas27xx_playback_volume),
   682		SOC_SINGLE_TLV("Amp Gain Volume", TAS27XX_CHNL_0, 0, 0x14, 0,
   683			       tas27xx_digital_tlv),
   684	};
   685	
   686	static const struct snd_soc_component_driver soc_component_driver_tas27xx = {
   687		.probe			= tas27xx_codec_probe,
   688	#ifdef CONFIG_PM
   689		.suspend		= tas27xx_codec_suspend,
   690		.resume			= tas27xx_codec_resume,
   691	#endif
   692		.set_bias_level		= tas27xx_set_bias_level,
   693		.controls		= tas27xx_snd_controls,
   694		.num_controls		= ARRAY_SIZE(tas27xx_snd_controls),
   695		.dapm_widgets		= tas27xx_dapm_widgets,
   696		.num_dapm_widgets	= ARRAY_SIZE(tas27xx_dapm_widgets),
   697		.dapm_routes		= tas27xx_audio_map,
   698		.num_dapm_routes	= ARRAY_SIZE(tas27xx_audio_map),
   699		.idle_bias_on		= 1,
   700		.endianness		= 1,
   701		.non_legacy_dai_naming	= 1,
   702	};
   703	
   704	static const struct reg_default tas27xx_reg_defaults[] = {
   705		{ TAS27XX_PAGE, 0x00 },
   706		{ TAS27XX_SW_RST, 0x00 },
   707		{ TAS27XX_PWR_CTRL, 0x1a },
   708		{ TAS27XX_DVC, 0x00 },
   709		{ TAS27XX_CHNL_0, 0x00 },
   710		{ TAS27XX_TDM_CFG0, 0x09 },
   711		{ TAS27XX_TDM_CFG1, 0x02 },
   712		{ TAS27XX_TDM_CFG2, 0x0a },
   713		{ TAS27XX_TDM_CFG3, 0x10 },
   714		{ TAS27XX_TDM_CFG5, 0x42 },
   715	};
   716	
   717	static const struct regmap_range_cfg tas27xx_regmap_ranges[] = {
   718		{
   719			.range_min = 0,
   720			.range_max = 1 * 128,
   721			.selector_reg = TAS27XX_PAGE,
   722			.selector_mask = 0xff,
   723			.selector_shift = 0,
   724			.window_start = 0,
   725			.window_len = 128,
   726		},
   727	};
   728	
   729	static bool tas27xx_volatile(struct device *dev,
   730		unsigned int reg)
   731	{
   732			return true;
   733	}
   734	
   735	static const struct regmap_config tas27xx_i2c_regmap = {
   736		.reg_bits = 8,
   737		.val_bits = 8,
   738		.reg_defaults = tas27xx_reg_defaults,
   739		.num_reg_defaults = ARRAY_SIZE(tas27xx_reg_defaults),
   740		.cache_type = REGCACHE_RBTREE,
   741		.ranges = tas27xx_regmap_ranges,
   742		.num_ranges = ARRAY_SIZE(tas27xx_regmap_ranges),
   743		.max_register = 1 * 128,
   744		.volatile_reg = tas27xx_volatile,
   745	};
   746	
   747	static int tas27xx_parse_dt(struct device *dev, struct tas27xx_priv *tas27xx)
   748	{
   749		int ret = 0;
   750	
   751		tas27xx->reset_gpio = devm_gpiod_get_optional(tas27xx->dev, "reset",
   752							      GPIOD_OUT_HIGH);
   753		if (IS_ERR(tas27xx->reset_gpio)) {
   754			if (PTR_ERR(tas27xx->reset_gpio) == -EPROBE_DEFER) {
   755				tas27xx->reset_gpio = NULL;
   756				return -EPROBE_DEFER;
   757			}
   758		}
   759	
   760		tas27xx->sdz_gpio = devm_gpiod_get_optional(dev, "shutdown", 
   761			GPIOD_OUT_HIGH);
   762		if (IS_ERR(tas27xx->sdz_gpio)) {
   763			if (PTR_ERR(tas27xx->sdz_gpio) == -EPROBE_DEFER)
   764				return -EPROBE_DEFER;
   765	
   766			tas27xx->sdz_gpio = NULL;
   767		}
   768	
   769		ret = fwnode_property_read_u32(dev->fwnode, "ti,imon-slot-no",
   770					       &tas27xx->i_sense_slot);
   771		if (ret)
   772			tas27xx->i_sense_slot = 0;
   773	
   774		ret = fwnode_property_read_u32(dev->fwnode, "ti,vmon-slot-no",
   775					       &tas27xx->v_sense_slot);
   776		if (ret)
   777			tas27xx->v_sense_slot = 2;
   778	
   779		return 0;
   780	}
   781	
   782	static int tas27xx_i2c_probe(struct i2c_client *client,
   783				const struct i2c_device_id *id)
   784	{
   785		struct tas27xx_priv *tas27xx;
   786		int result;
   787	
   788		tas27xx = devm_kzalloc(&client->dev, sizeof(struct tas27xx_priv),
   789				       GFP_KERNEL);
   790		if (!tas27xx)
   791			return -ENOMEM;
   792		mutex_init(&tas27xx->codec_lock);
   793		tas27xx->dev = &client->dev;
   794		i2c_set_clientdata(client, tas27xx);
   795		dev_set_drvdata(&client->dev, tas27xx);
   796	
   797		tas27xx->regmap = devm_regmap_init_i2c(client, &tas27xx_i2c_regmap);
   798		if (IS_ERR(tas27xx->regmap)) {
   799			result = PTR_ERR(tas27xx->regmap);
   800			dev_err(&client->dev, "Failed to allocate register map: %d\n",
   801						result);
   802			return result;
   803		}
   804	
   805		if (client->dev.of_node) {
   806			result = tas27xx_parse_dt(&client->dev, tas27xx);
   807			if (result) {
   808				dev_err(tas27xx->dev, 
   809					"%s: Failed to parse devicetree\n", __func__);
   810				return result;
   811			}
   812		}
   813	
   814		tas27xx->device_id = id->driver_data;
   815		dev_info(tas27xx->dev, "chip_id: %u\n", tas27xx->device_id);
   816	
   817		return devm_snd_soc_register_component(tas27xx->dev,
   818			&soc_component_driver_tas27xx, tas27xx_dai_driver,
 > 819			ARRAY_SIZE(tas27xx_dai_driver));
   820	}
   821	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

* Re: [PATCH v5 4/4] update tas27xx.c to support either TAS2764 or TAS2780
@ 2022-03-30 18:36     ` kernel test robot
  0 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2022-03-30 18:36 UTC (permalink / raw)
  To: Raphael-Xu, broonie
  Cc: llvm, kbuild-all, navada, alsa-devel, shenghao-ding, raphael-xu,
	Raphael-Xu

Hi Raphael-Xu,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on broonie-sound/for-next]
[also build test ERROR on v5.17 next-20220330]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Raphael-Xu/rename-tas2764-to-tas27xx/20220330-224947
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: arm-randconfig-r012-20220330 (https://download.01.org/0day-ci/archive/20220331/202203310255.mwJuw0DH-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 0f6d9501cf49ce02937099350d08f20c4af86f3d)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # https://github.com/intel-lab-lkp/linux/commit/5e87128eec39d187eaf11069178b39d935600c2e
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Raphael-Xu/rename-tas2764-to-tas27xx/20220330-224947
        git checkout 5e87128eec39d187eaf11069178b39d935600c2e
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash sound/soc/codecs/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> sound/soc/codecs/tas27xx.c:624:4: error: field designator 'symmetric_rates' does not refer to any field in type 'struct snd_soc_dai_driver'; did you mean 'symmetric_rate'?
                   .symmetric_rates = 1,
                    ^~~~~~~~~~~~~~~
                    symmetric_rate
   include/sound/soc-dai.h:411:15: note: 'symmetric_rate' declared here
           unsigned int symmetric_rate:1;
                        ^
>> sound/soc/codecs/tas27xx.c:819:3: error: invalid application of 'sizeof' to an incomplete type 'struct snd_soc_dai_driver[]'
                   ARRAY_SIZE(tas27xx_dai_driver));
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kernel.h:55:32: note: expanded from macro 'ARRAY_SIZE'
   #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
                                  ^~~~~
   2 errors generated.


vim +624 sound/soc/codecs/tas27xx.c

   598	
   599	#define TAS27XX_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
   600				 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
   601	
   602	#define TAS27XX_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\
   603			       SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_88200)
   604	
   605	static struct snd_soc_dai_driver tas27xx_dai_driver[] = {
   606		{
   607			.name = "tas27xx ASI1",
   608			.id = 0,
   609			.playback = {
   610				.stream_name    = "ASI1 Playback",
   611				.channels_min   = 2,
   612				.channels_max   = 2,
   613				.rates      = TAS27XX_RATES,
   614				.formats    = TAS27XX_FORMATS,
   615			},
   616			.capture = {
   617				.stream_name    = "ASI1 Capture",
   618				.channels_min   = 1,
   619				.channels_max   = 2,
   620				.rates = TAS27XX_RATES,
   621				.formats = TAS27XX_FORMATS,
   622			},
   623			.ops = &tas27xx_dai_ops,
 > 624			.symmetric_rates = 1,
   625		},
   626	};
   627	
   628	static int tas27xx_codec_probe(struct snd_soc_component *component)
   629	{
   630		struct tas27xx_priv *tas27xx = 
   631			snd_soc_component_get_drvdata(component);
   632		int ret = 0;
   633	
   634		tas27xx->component = component;
   635	
   636		if (tas27xx->sdz_gpio)
   637			gpiod_set_value_cansleep(tas27xx->sdz_gpio, 1);
   638	
   639		tas27xx_reset(tas27xx);
   640	
   641		ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG5,
   642						    TAS27XX_TDM_CFG5_VSNS_ENABLE, 0);
   643		if (ret < 0) {
   644			dev_err(tas27xx->dev, "%s:%u: Failed to enable vSNS\n",
   645				__func__, __LINE__);
   646			goto EXIT;
   647		}
   648		ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG6,
   649						    TAS27XX_TDM_CFG6_ISNS_ENABLE, 0);
   650		if (ret < 0) {
   651			dev_err(tas27xx->dev, "%s:%u: Failed to enable iSNS\n",
   652				__func__, __LINE__);
   653			goto EXIT;
   654		}
   655		ret = snd_soc_component_update_bits(component, TAS27XX_PWR_CTRL,
   656						    TAS27XX_PWR_CTRL_MASK,
   657						    TAS27XX_PWR_CTRL_MUTE);
   658		if (ret < 0) {
   659			dev_err(tas27xx->dev, "%s:%u: Failed to PWR_CTRL_MUTE\n",
   660				__func__, __LINE__);
   661			goto EXIT;
   662		}
   663	
   664		ret = snd_soc_component_write(component, TAS27XX_PWR_CTRL, 0x02);
   665	
   666		if (ret < 0) {
   667			dev_err(tas27xx->dev, "%s:%u: Failed to initial active\n",
   668				__func__, __LINE__);
   669			goto EXIT;
   670		}
   671		ret = 0;
   672	EXIT:
   673		return ret;
   674	}
   675	
   676	static DECLARE_TLV_DB_SCALE(tas27xx_digital_tlv, 1100, 50, 0);
   677	static DECLARE_TLV_DB_SCALE(tas27xx_playback_volume, -10000, 50, 0);
   678	
   679	static const struct snd_kcontrol_new tas27xx_snd_controls[] = {
   680		SOC_SINGLE_TLV("Speaker Volume", TAS27XX_DVC, 0,
   681			       TAS27XX_DVC_MAX, 1, tas27xx_playback_volume),
   682		SOC_SINGLE_TLV("Amp Gain Volume", TAS27XX_CHNL_0, 0, 0x14, 0,
   683			       tas27xx_digital_tlv),
   684	};
   685	
   686	static const struct snd_soc_component_driver soc_component_driver_tas27xx = {
   687		.probe			= tas27xx_codec_probe,
   688	#ifdef CONFIG_PM
   689		.suspend		= tas27xx_codec_suspend,
   690		.resume			= tas27xx_codec_resume,
   691	#endif
   692		.set_bias_level		= tas27xx_set_bias_level,
   693		.controls		= tas27xx_snd_controls,
   694		.num_controls		= ARRAY_SIZE(tas27xx_snd_controls),
   695		.dapm_widgets		= tas27xx_dapm_widgets,
   696		.num_dapm_widgets	= ARRAY_SIZE(tas27xx_dapm_widgets),
   697		.dapm_routes		= tas27xx_audio_map,
   698		.num_dapm_routes	= ARRAY_SIZE(tas27xx_audio_map),
   699		.idle_bias_on		= 1,
   700		.endianness		= 1,
   701		.non_legacy_dai_naming	= 1,
   702	};
   703	
   704	static const struct reg_default tas27xx_reg_defaults[] = {
   705		{ TAS27XX_PAGE, 0x00 },
   706		{ TAS27XX_SW_RST, 0x00 },
   707		{ TAS27XX_PWR_CTRL, 0x1a },
   708		{ TAS27XX_DVC, 0x00 },
   709		{ TAS27XX_CHNL_0, 0x00 },
   710		{ TAS27XX_TDM_CFG0, 0x09 },
   711		{ TAS27XX_TDM_CFG1, 0x02 },
   712		{ TAS27XX_TDM_CFG2, 0x0a },
   713		{ TAS27XX_TDM_CFG3, 0x10 },
   714		{ TAS27XX_TDM_CFG5, 0x42 },
   715	};
   716	
   717	static const struct regmap_range_cfg tas27xx_regmap_ranges[] = {
   718		{
   719			.range_min = 0,
   720			.range_max = 1 * 128,
   721			.selector_reg = TAS27XX_PAGE,
   722			.selector_mask = 0xff,
   723			.selector_shift = 0,
   724			.window_start = 0,
   725			.window_len = 128,
   726		},
   727	};
   728	
   729	static bool tas27xx_volatile(struct device *dev,
   730		unsigned int reg)
   731	{
   732			return true;
   733	}
   734	
   735	static const struct regmap_config tas27xx_i2c_regmap = {
   736		.reg_bits = 8,
   737		.val_bits = 8,
   738		.reg_defaults = tas27xx_reg_defaults,
   739		.num_reg_defaults = ARRAY_SIZE(tas27xx_reg_defaults),
   740		.cache_type = REGCACHE_RBTREE,
   741		.ranges = tas27xx_regmap_ranges,
   742		.num_ranges = ARRAY_SIZE(tas27xx_regmap_ranges),
   743		.max_register = 1 * 128,
   744		.volatile_reg = tas27xx_volatile,
   745	};
   746	
   747	static int tas27xx_parse_dt(struct device *dev, struct tas27xx_priv *tas27xx)
   748	{
   749		int ret = 0;
   750	
   751		tas27xx->reset_gpio = devm_gpiod_get_optional(tas27xx->dev, "reset",
   752							      GPIOD_OUT_HIGH);
   753		if (IS_ERR(tas27xx->reset_gpio)) {
   754			if (PTR_ERR(tas27xx->reset_gpio) == -EPROBE_DEFER) {
   755				tas27xx->reset_gpio = NULL;
   756				return -EPROBE_DEFER;
   757			}
   758		}
   759	
   760		tas27xx->sdz_gpio = devm_gpiod_get_optional(dev, "shutdown", 
   761			GPIOD_OUT_HIGH);
   762		if (IS_ERR(tas27xx->sdz_gpio)) {
   763			if (PTR_ERR(tas27xx->sdz_gpio) == -EPROBE_DEFER)
   764				return -EPROBE_DEFER;
   765	
   766			tas27xx->sdz_gpio = NULL;
   767		}
   768	
   769		ret = fwnode_property_read_u32(dev->fwnode, "ti,imon-slot-no",
   770					       &tas27xx->i_sense_slot);
   771		if (ret)
   772			tas27xx->i_sense_slot = 0;
   773	
   774		ret = fwnode_property_read_u32(dev->fwnode, "ti,vmon-slot-no",
   775					       &tas27xx->v_sense_slot);
   776		if (ret)
   777			tas27xx->v_sense_slot = 2;
   778	
   779		return 0;
   780	}
   781	
   782	static int tas27xx_i2c_probe(struct i2c_client *client,
   783				const struct i2c_device_id *id)
   784	{
   785		struct tas27xx_priv *tas27xx;
   786		int result;
   787	
   788		tas27xx = devm_kzalloc(&client->dev, sizeof(struct tas27xx_priv),
   789				       GFP_KERNEL);
   790		if (!tas27xx)
   791			return -ENOMEM;
   792		mutex_init(&tas27xx->codec_lock);
   793		tas27xx->dev = &client->dev;
   794		i2c_set_clientdata(client, tas27xx);
   795		dev_set_drvdata(&client->dev, tas27xx);
   796	
   797		tas27xx->regmap = devm_regmap_init_i2c(client, &tas27xx_i2c_regmap);
   798		if (IS_ERR(tas27xx->regmap)) {
   799			result = PTR_ERR(tas27xx->regmap);
   800			dev_err(&client->dev, "Failed to allocate register map: %d\n",
   801						result);
   802			return result;
   803		}
   804	
   805		if (client->dev.of_node) {
   806			result = tas27xx_parse_dt(&client->dev, tas27xx);
   807			if (result) {
   808				dev_err(tas27xx->dev, 
   809					"%s: Failed to parse devicetree\n", __func__);
   810				return result;
   811			}
   812		}
   813	
   814		tas27xx->device_id = id->driver_data;
   815		dev_info(tas27xx->dev, "chip_id: %u\n", tas27xx->device_id);
   816	
   817		return devm_snd_soc_register_component(tas27xx->dev,
   818			&soc_component_driver_tas27xx, tas27xx_dai_driver,
 > 819			ARRAY_SIZE(tas27xx_dai_driver));
   820	}
   821	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

* Re: [PATCH v5 4/4] update tas27xx.c to support either TAS2764 or TAS2780
  2022-03-30 14:45 ` [PATCH v5 4/4] update tas27xx.c to support either TAS2764 or TAS2780 Raphael-Xu
                     ` (2 preceding siblings ...)
  2022-03-30 18:36     ` kernel test robot
@ 2022-03-31  3:59   ` kernel test robot
  3 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2022-03-31  3:59 UTC (permalink / raw)
  To: Raphael-Xu, broonie
  Cc: alsa-devel, kbuild-all, shenghao-ding, navada, raphael-xu,
	Raphael-Xu

Hi Raphael-Xu,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on broonie-sound/for-next]
[also build test ERROR on v5.17 next-20220330]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Raphael-Xu/rename-tas2764-to-tas27xx/20220330-224947
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: m68k-allmodconfig (https://download.01.org/0day-ci/archive/20220331/202203311144.77JqF9D6-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/5e87128eec39d187eaf11069178b39d935600c2e
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Raphael-Xu/rename-tas2764-to-tas27xx/20220330-224947
        git checkout 5e87128eec39d187eaf11069178b39d935600c2e
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=m68k SHELL=/bin/bash sound/soc/codecs/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

>> sound/soc/codecs/tas27xx.c:624:18: error: 'struct snd_soc_dai_driver' has no member named 'symmetric_rates'; did you mean 'symmetric_rate'?
     624 |                 .symmetric_rates = 1,
         |                  ^~~~~~~~~~~~~~~
         |                  symmetric_rate
>> sound/soc/codecs/tas27xx.c:624:36: warning: initialization of 'const struct snd_soc_cdai_ops *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     624 |                 .symmetric_rates = 1,
         |                                    ^
   sound/soc/codecs/tas27xx.c:624:36: note: (near initialization for 'tas27xx_dai_driver[0].cops')


vim +624 sound/soc/codecs/tas27xx.c

   598	
   599	#define TAS27XX_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
   600				 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
   601	
   602	#define TAS27XX_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\
   603			       SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_88200)
   604	
   605	static struct snd_soc_dai_driver tas27xx_dai_driver[] = {
   606		{
   607			.name = "tas27xx ASI1",
   608			.id = 0,
   609			.playback = {
   610				.stream_name    = "ASI1 Playback",
   611				.channels_min   = 2,
   612				.channels_max   = 2,
   613				.rates      = TAS27XX_RATES,
   614				.formats    = TAS27XX_FORMATS,
   615			},
   616			.capture = {
   617				.stream_name    = "ASI1 Capture",
   618				.channels_min   = 1,
   619				.channels_max   = 2,
   620				.rates = TAS27XX_RATES,
   621				.formats = TAS27XX_FORMATS,
   622			},
   623			.ops = &tas27xx_dai_ops,
 > 624			.symmetric_rates = 1,
   625		},
   626	};
   627	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

* Re: [PATCH v5 2/4] update tas27xx.h to support either TAS2764 or TAS2780
  2022-03-30 14:45 ` [PATCH v5 2/4] update tas27xx.h to support either TAS2764 or TAS2780 Raphael-Xu
@ 2022-03-31 12:12   ` Mark Brown
  0 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2022-03-31 12:12 UTC (permalink / raw)
  To: Raphael-Xu; +Cc: navada, alsa-devel, shenghao-ding, raphael-xu

[-- Attachment #1: Type: text/plain, Size: 767 bytes --]

On Wed, Mar 30, 2022 at 10:45:24PM +0800, Raphael-Xu wrote:

>  /* Book Control Register */
> -#define TAS2764_BOOKCTL_PAGE	0
> -#define TAS2764_BOOKCTL_REG	127
> -#define TAS2764_REG(page, reg)	((page * 128) + reg)
> +#define TAS27XX_BOOKCTL_PAGE	0
> +#define TAS27XX_BOOKCTL_REG	127
> +#define TAS27XX_REG(page, reg)	((page * 128) + reg)

You should ensure that each patch is individually buildable - this helps
people who want to do things like bisecting for problems.  This means
that you shouldn't go file by file but instead logical change by logical
change.  I think all you need to do here is just make patches 2 and 3
into a single patch.

Otherwise this looks basically good, please update for the above and
also the small issues that Amadeusz pointed out.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2022-03-31 12:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-30 14:45 [PATCH v5 1/4] rename tas2764 to tas27xx Raphael-Xu
2022-03-30 14:45 ` [PATCH v5 2/4] update tas27xx.h to support either TAS2764 or TAS2780 Raphael-Xu
2022-03-31 12:12   ` Mark Brown
2022-03-30 14:45 ` [PATCH v5 3/4] rename variables from tas2764 to tas27xx Raphael-Xu
2022-03-30 14:45 ` [PATCH v5 4/4] update tas27xx.c to support either TAS2764 or TAS2780 Raphael-Xu
2022-03-30 17:25   ` Amadeusz Sławiński
2022-03-30 17:35   ` kernel test robot
2022-03-30 18:36   ` kernel test robot
2022-03-30 18:36     ` kernel test robot
2022-03-31  3:59   ` kernel test robot

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.