Skip to contentSkip to conversation

ASoC: rt1320-sdw: Add an approach to get new hardware advance gain

PATCH In review [email protected] 2 participants 2 messages Apr 10

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

PATCH v5 1/1 ASoC: rt1320-sdw: Add an approach to get new hardware advance gain

From: Jack Yu <[email protected]>

Add an approach to get new hardware advance gain, and if there is no advance gain with this approach, we can still get advance gain with original method.

---
 sound/soc/codecs/rt1320-sdw.c | 25 +++++++++++++++++++++++--
 sound/soc/codecs/rt1320-sdw.h | 13 +++++++++++++
 2 files changed, 36 insertions(+), 2 deletions(-)
sound/soc/codecs/rt1320-sdw.c +23 -2
index 168d2f391723..b0aeeab26bd9 100644
@@ -1013,13 +1013,34 @@ static void rt1320_set_advancemode(struct rt1320_sdw_priv *rt1320)
 	struct device *dev = &rt1320->sdw_slave->dev;
 	struct rt1320_datafixpoint r0_data[2];
 	unsigned short l_advancegain, r_advancegain;
+	FwPara_Get_HwSwGain audDriverDataHwSwGain = {0};
+	unsigned int HwAdvGain = 0;
 	int ret;
 
+	 /* Get new hardware advance gain by ID 1300 */
+	ret = rt1320_fw_param_protocol(rt1320, RT1320_GET_PARAM, 1300,
+		&audDriverDataHwSwGain, sizeof(audDriverDataHwSwGain));
+	if (ret == 0) {
+		HwAdvGain = audDriverDataHwSwGain.HwAdvGain;
+		dev_dbg(dev, "%s, HwAdvGain=%d\n", __func__, HwAdvGain);
+		dev_dbg(dev, "%s, HwBasGain=%d\n", __func__, audDriverDataHwSwGain.HwBasGain);
+		dev_dbg(dev, "%s, SwAdvGain=%d\n", __func__, audDriverDataHwSwGain.SwAdvGain);
+		dev_dbg(dev, "%s, SwBasGain=%d\n", __func__, audDriverDataHwSwGain.SwBasGain);
+	} else {
+		dev_dbg(dev, "%s: param 1300 not supported, ret=%d\n", __func__, ret);
+	}
+
 	/* Get advance gain/r0 */
 	rt1320_fw_param_protocol(rt1320, RT1320_GET_PARAM, 6, &r0_data[0], sizeof(struct rt1320_datafixpoint));
 	rt1320_fw_param_protocol(rt1320, RT1320_GET_PARAM, 7, &r0_data[1], sizeof(struct rt1320_datafixpoint));
-	l_advancegain = r0_data[0].advancegain;
-	r_advancegain = r0_data[1].advancegain;
+
+	if (HwAdvGain != 0) {
+		l_advancegain = HwAdvGain & 0xffff;
+		r_advancegain = (HwAdvGain >> 16) & 0xffff;
+	} else {
+		l_advancegain = r0_data[0].advancegain;
+		r_advancegain = r0_data[1].advancegain;
+	}
 	dev_dbg(dev, "%s, LR advanceGain=0x%x 0x%x\n", __func__, l_advancegain, r_advancegain);
 
 	/* set R0 and enable protection by SetParameter id 6, 7 */
sound/soc/codecs/rt1320-sdw.h +13 -0
index 4a1d3fc4c8ee..a7b573883dd0 100644
@@ -121,6 +121,19 @@ struct rt1320_datafixpoint {
 	int invrs;
 };
 
+typedef struct FwPara_HwSwGain {
+	unsigned int SwAdvGain;
+	unsigned int SwBasGain;
+	unsigned int HwAdvGain;
+	unsigned int HwBasGain;
+	unsigned int reserve0;
+	unsigned int reserve1;
+	unsigned int reserve2;
+	unsigned int reserve3;
+	unsigned int reserve4;
+	unsigned int reserve5;
+} __attribute__((packed)) FwPara_Get_HwSwGain;
+
 struct rt1320_paramcmd {
 	unsigned char moudleid;
 	unsigned char commandtype;
Signature · 1 line
2.53.0
maintainer
#1 lore raw
Quoted 1 line · On Fri, 10 Apr 2026 14:42:25 +0800, [email protected] wrote:

ASoC: rt1320-sdw: Add an approach to get new hardware advance gain

Applied to

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

Thanks!

[1/1] ASoC: rt1320-sdw: Add an approach to get new hardware advance gain

      https://git.kernel.org/broonie/sound/c/2603ea46ce5c

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark