Skip to contentSkip to conversation

ASoC: tas2781: Support dsp firmware Alpha and Beta seaies

PATCH RESEND In review Shenghao Ding 4 participants 5 messages Mar 13, 2025 – Mar 19, 2025

Subsystems (3)
lore
Share & tools
lore

Shenghao Ding

author maintainer
#0 lore raw

PATCH RESEND v5 1/1 ASoC: tas2781: Support dsp firmware Alpha and Beta seaies

For calibration, basic version does not contain any calibration addresses, it depends on calibration tool to convey the addresses to the driver. Since Alpha and Beta firmware, all the calibration addresses are saved into the firmware.

---
v5:
- Instead of the lengthy approach, just replace if-continue with else if, has reduced this by 2/3 of LoCs
- Use proper error code in fw_parse_fct_param_address()
- return directly in tasdevice_dspfw_ready()
- drop Unneeded assignment
v4:
- drop unnecceary "unsigned short size;" and "char *data;" in struct fct_param_address
- replace strstr() with strncmp() in fct_param_address_parser()
- replace hex_parse_u8() with memcpy()
- replace hex_parse_u24() with direct assignment
- drop hex_parse_u8() & hex_parse_u24()
- Just return directly and use proper error codes and drop "goto out" and "out:" label in fw_parse_fct_param_address
- fixed indentation issues in cali_reg_update
- fixed the logical splits in tas2781_calib_stop_put()
- return -ENOMEM if kmemdup fails in fw_parse_fct_param_address()
- remove unnecessary "out:" label
v3:
- Merge the 4 patches into one patch
v2:

 - | Reported-by: kernel test robot <[email protected]>
   | Closes:
   | https://urldefense.com/v3/__https://lore.kernel.org/oe-kbuild-all/2025
   | [email protected]/__;!!G3vK!WriwhtbQGlg6p00bcWutlhb-y9vS
   | pDrSu5_g9oOzzGOoABdirEARTntFzyX6Ss3UPRDxi_E-IA$
 - | Reported-by: kernel test robot <[email protected]>
   | Closes:
   | https://urldefense.com/v3/__https://lore.kernel.org/oe-kbuild-all/2025
   | [email protected]/__;!!G3vK!VtEdfur3fZklvPVfHFFfFP60Ub2E
   | JYvmjSUZ65lJ6BsQPJDl1fjYRDqh3c6Q5y6sA70ssXDG5g$

v1:
- update the year from 2024 to 2025 in the files.
- Add dspbin_type to distinguish different dspbin types, such as TASDEV_BASIC, TASDEV_ALPHA, and TASDEV_BETA.
- Add struct bulk_reg_val alp_cali_bckp to store the value of pilot tone threshold only for TASDEV_ALPHA & TASDEV_BETA firmware.
- Add the declaration of (*fw_parse_fct_param_address)() to parse the addresses of calibration params.
- Add the minimum version of TASDEV_ALPHA and TASDEV_BETA firmware.
- Add the definition of struct fct_param_address.
- update the year from 2024 to 2025.
- release the memory to save calibration addresses in tasdevice_dsp_remove().
- Add TASDEV_ALPHA and TASDEV_BETA firmware checking code.
- Add fct_param_address_parser for Alpha and Beta firmware.
- Add an extra branch to handle calibration address for TASDEV_ALPHA and TASDEV_BETA firmware.

---
 include/sound/tas2781-dsp.h       |  30 ++++-
 include/sound/tas2781.h           |  11 ++
 sound/pci/hda/tas2781_spi_fwlib.c |   8 +-
 sound/soc/codecs/tas2781-fmwlib.c | 190 ++++++++++++++++++++++----
 sound/soc/codecs/tas2781-i2c.c    | 215 ++++++++++++++++++++++--------
 5 files changed, 368 insertions(+), 86 deletions(-)
include/sound/tas2781-dsp.h +27 -3
index 3cda9da14f6d..c3a9efa73d5d 100644
@@ -2,7 +2,7 @@
 //
 // ALSA SoC Texas Instruments TAS2781 Audio Smart Amplifier
 //
-// Copyright (C) 2022 - 2024 Texas Instruments Incorporated
+// Copyright (C) 2022 - 2025 Texas Instruments Incorporated
 // https://www.ti.com
 //
 // The TAS2781 driver implements a flexible and configurable
@@ -30,8 +30,10 @@
 #define PRE_DEVICE_C				0x12
 #define PRE_DEVICE_D				0x16
 
-#define PPC3_VERSION				0x4100
-#define PPC3_VERSION_TAS2781			0x14600
+#define PPC3_VERSION_BASE			0x4100
+#define PPC3_VERSION_TAS2781_BASIC_MIN		0x14600
+#define PPC3_VERSION_TAS2781_ALPHA_MIN		0x4a00
+#define PPC3_VERSION_TAS2781_BETA_MIN		0x19400
 #define TASDEVICE_DEVICE_SUM			8
 #define TASDEVICE_CONFIG_SUM			64
 
@@ -106,6 +108,27 @@ struct tasdevice_calibration {
 	struct tasdevice_data dev_data;
 };
 
+struct fct_param_address {
+	/* Thermal data for PG 1.0 device */
+	unsigned char thr[3];
+	/* Thermal data for PG 2.0 device */
+	unsigned char thr2[3];
+	/* Pilot tone enable flag, usually the sine wave */
+	unsigned char plt_flg[3];
+	/* Pilot tone gain for calibration */
+	unsigned char sin_gn[3];
+	/* Pilot tone gain for calibration */
+	unsigned char sin_gn2[3];
+	/* high 32-bit of real-time spk impedance */
+	unsigned char r0_reg[3];
+	/* check spk connection */
+	unsigned char tf_reg[3];
+	/* check spk resonant frequency */
+	unsigned char a1_reg[3];
+	/* check spk resonant frequency */
+	unsigned char a2_reg[3];
+};
+
 struct tasdevice_fw {
 	struct tasdevice_dspfw_hdr fw_hdr;
 	unsigned short nr_programs;
@@ -114,6 +137,7 @@ struct tasdevice_fw {
 	struct tasdevice_config *configs;
 	unsigned short nr_calibrations;
 	struct tasdevice_calibration *calibrations;
+	struct fct_param_address fct_par_addr;
 	struct device *dev;
 };
 
include/sound/tas2781.h +11 -0
index 4d9a37544354..eff011444cc8 100644
@@ -113,6 +113,12 @@ enum audio_device {
 	TAS2781,
 };
 
+enum dspbin_type {
+	TASDEV_BASIC,
+	TASDEV_ALPHA,
+	TASDEV_BETA,
+};
+
 enum device_catlog_id {
 	LENOVO = 0,
 	OTHERS
@@ -127,6 +133,7 @@ struct bulk_reg_val {
 
 struct tasdevice {
 	struct bulk_reg_val *cali_data_backup;
+	struct bulk_reg_val alp_cali_bckp;
 	struct tasdevice_fw *cali_data_fmw;
 	unsigned int dev_addr;
 	unsigned int err_code;
@@ -171,6 +178,7 @@ struct tasdevice_priv {
 	unsigned char dev_name[32];
 	const char *name_prefix;
 	unsigned char ndev;
+	unsigned int dspbin_typ;
 	unsigned int magic_num;
 	unsigned int chip_id;
 	unsigned int sysclk;
@@ -196,6 +204,9 @@ struct tasdevice_priv {
 	int (*fw_parse_configuration_data)(struct tasdevice_priv *tas_priv,
 		struct tasdevice_fw *tas_fmw,
 		const struct firmware *fmw, int offset);
+	int (*fw_parse_fct_param_address)(struct tasdevice_priv *tas_priv,
+		struct tasdevice_fw *tas_fmw,
+		const struct firmware *fmw, int offset);
 	int (*tasdevice_load_block)(struct tasdevice_priv *tas_priv,
 		struct tasdev_blk *block);
 
sound/pci/hda/tas2781_spi_fwlib.c +4 -4
index 0e2acbc3c900..19a693d58ee8 100644
@@ -2,7 +2,7 @@
 //
 // TAS2781 HDA SPI driver
 //
-// Copyright 2024 Texas Instruments, Inc.
+// Copyright 2024 - 2025 Texas Instruments, Inc.
 //
 // Author: Baojun Xu <[email protected]>
 
@@ -370,10 +370,10 @@ static unsigned char map_dev_idx(struct tasdevice_fw *tas_fmw,
 	int i, n = ARRAY_SIZE(non_ppc3_mapping_table);
 	unsigned char dev_idx = 0;
 
-	if (fw_fixed_hdr->ppcver >= PPC3_VERSION_TAS2781) {
+	if (fw_fixed_hdr->ppcver >= PPC3_VERSION_TAS2781_BASIC_MIN) {
 		p = (struct blktyp_devidx_map *)ppc3_tas2781_mapping_table;
 		n = ARRAY_SIZE(ppc3_tas2781_mapping_table);
-	} else if (fw_fixed_hdr->ppcver >= PPC3_VERSION) {
+	} else if (fw_fixed_hdr->ppcver >= PPC3_VERSION_BASE) {
 		p = (struct blktyp_devidx_map *)ppc3_mapping_table;
 		n = ARRAY_SIZE(ppc3_mapping_table);
 	}
@@ -1605,7 +1605,7 @@ static int dspfw_default_callback(struct tasdevice_priv *tas_priv,
 	int rc = 0;
 
 	if (drv_ver == 0x100) {
-		if (ppcver >= PPC3_VERSION) {
+		if (ppcver >= PPC3_VERSION_BASE) {
 			tas_priv->fw_parse_variable_header =
 				fw_parse_variable_header_kernel;
 			tas_priv->fw_parse_program_data =
sound/soc/codecs/tas2781-fmwlib.c +163 -27

261 lines not on this page · raw message

sound/soc/codecs/tas2781-i2c.c +163 -52

341 lines not on this page · raw message

Signature · 1 line
2.34.1
Reviewed-by on v5 1/1
#1 lore raw
Quoted 4 lines · Shenghao Ding

For calibration, basic version does not contain any calibration addresses, it depends on calibration tool to convey the addresses to the driver. Since Alpha and Beta firmware, all the calibration addresses are saved into the firmware.

I believe there is a lot of room to improve in this patch and in the entire driver, but this probably is needed to unblock the users. So, from my point of view if it's working, it's good enough to go.

FWIW,

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer Reviewed-by on v5 1/1
#2 lore raw
In reply to Shenghao Ding
Quoted 4 lines · Shenghao Ding

For calibration, basic version does not contain any calibration addresses, it depends on calibration tool to convey the addresses to the driver. Since Alpha and Beta firmware, all the calibration addresses are saved into the firmware.

Takashi, this depends on changes in your tree due to the HDA bit - can you apply it please?

author maintainer
#3 lore raw

Hi Tiwai
There's one change in the HAD tree. Would you be so kind and apply it? Looking forward to your feedback. Thanks.

Quoted 21 lines

-----Original Message-----
From: Mark Brown <[email protected]>
Sent: Friday, March 14, 2025 6:27 AM
To: Ding, Shenghao <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Xu, Baojun <[email protected]>
Subject: [EXTERNAL] Re: [RESEND PATCH v5] ASoC: tas2781: Support dsp firmware Alpha and Beta seaies

Quoted 2 lines · Shenghao Ding

For calibration, basic version does not contain any calibration addresses, it depends on calibration tool to convey the addresses to the

driver.

Quoted 2 lines

Since Alpha and Beta firmware, all the calibration addresses are saved into the firmware.

Takashi, this depends on changes in your tree due to the HDA bit - can you apply it please?

#4 lore raw
In reply to Mark Brown
Quoted 11 lines · Mark Brown
Quoted 4 lines · Shenghao Ding

For calibration, basic version does not contain any calibration addresses, it depends on calibration tool to convey the addresses to the driver. Since Alpha and Beta firmware, all the calibration addresses are saved into the firmware.

Takashi, this depends on changes in your tree due to the HDA bit - can you apply it please?

Sorry I overlooked it. Now applied.

thanks,

Takashi