ASoC: rt1320-sdw: kcontrol for brown-out feature update
Subsystems (3)
PATCH v4 2/2 ASoC: rt1320-sdw: Add an approach to get new hardware advance gain
In reply to [email protected]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 | 21 +++++++++++++++++++-- sound/soc/codecs/rt1320-sdw.h | 13 +++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-)
sound/soc/codecs/rt1320-sdw.c +19 -2
@@ -1013,13 +1013,30 @@ 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; +unsigned int HwAdvGain;int ret; +/* Get new hardware advance gain by ID 1300 */ +rt1320_fw_param_protocol (rt1320,RT1320_GET_PARAM ,1300 , + &audDriverDataHwSwGain,sizeof (audDriverDataHwSwGain)); + 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); +/* 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
@@ -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
PATCH v4 1/2 ASoC: rt1320-sdw: kcontrol for brown-out feature update
From: Jack Yu <[email protected]>
Create a kcontrol to enable or disable brown-out dynamically.
--- sound/soc/codecs/rt1320-sdw.c | 42 +++++++++++++++++++++++++++++++++++ sound/soc/codecs/rt1320-sdw.h | 1 + 2 files changed, 43 insertions(+)
sound/soc/codecs/rt1320-sdw.c +42 -0
@@ -2486,6 +2486,45 @@ static int rt1320_rae_update_put(struct snd_kcontrol *kcontrol,return 0 ; } +static int rt1320_brown_out_put (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) +{ +struct snd_soc_component *component =snd_kcontrol_chip (kcontrol); +struct rt1320_sdw_priv *rt1320 =snd_soc_component_get_drvdata (component); +int ret, changed =0 ; + +if (!rt1320->hw_init) +return 0 ; + + ret =pm_runtime_resume (component->dev); +if (ret <0 && ret != -EACCES ) +return ret; + +if (rt1320->brown_out != ucontrol->value.integer.value[0 ]) { + changed =1 ; + rt1320->brown_out = ucontrol->value.integer.value[0 ]; + } + +if (rt1320->brown_out ==0 ) +regmap_write (rt1320->regmap,0xdb03 ,0x00 ); +else +regmap_write (rt1320->regmap,0xdb03 ,0xf0 ); + + +return changed; +} + +static int rt1320_brown_out_get (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) +{ +struct snd_soc_component *component =snd_kcontrol_chip (kcontrol); +struct rt1320_sdw_priv *rt1320 =snd_soc_component_get_drvdata (component); + + ucontrol->value.integer.value[0 ] = rt1320->brown_out; + +return 0 ; +} +static int rt1320_r0_temperature_get (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {
@@ -2545,6 +2584,8 @@ static const struct snd_kcontrol_new rt1320_snd_controls[] = { rt1320_r0_temperature_get, rt1320_r0_temperature_put), SOC_SINGLE_EXT("RAE Update", SND_SOC_NOPM, 0, 1, 0, rt1320_rae_update_get, rt1320_rae_update_put), + SOC_SINGLE_EXT("Brown Out Switch", SND_SOC_NOPM, 0, 1, 0, + rt1320_brown_out_get, rt1320_brown_out_put), }; static const struct snd_kcontrol_new rt1320_spk_l_dac =
@@ -2904,6 +2945,7 @@ static int rt1320_sdw_init(struct device *dev, struct regmap *regmap, rt1320->fu_dapm_mute = true; rt1320->fu_mixer_mute[0 ] = rt1320->fu_mixer_mute[1 ] = rt1320->fu_mixer_mute[2 ] = rt1320->fu_mixer_mute[3 ] = true; + rt1320->brown_out =1 ;INIT_WORK (&rt1320->load_dspfw_work, rt1320_load_dspfw_work);
sound/soc/codecs/rt1320-sdw.h +1 -0
@@ -159,6 +159,7 @@ struct rt1320_sdw_priv {bool hw_init;bool first_hw_init;int version_id; +int brown_out;unsigned int dev_id;bool fu_dapm_mute;bool fu_mixer_mute[4 ];
Signature · 1 line
2.53.0
Mark Brown
maintainerRe: [PATCH v4 2/2] ASoC: rt1320-sdw: Add an approach to get new hardware advance gain
In reply to [email protected]sound/soc/codecs/rt1320-sdw.c static void rt1320_set_advancemode(struct rt1320_sdw_priv *rt1320) · line 1023
Quoted 10 lines · On Thu, Apr 09, 2026 at 02:01:02PM +0800, [email protected] wrote:
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 +4
-0+/* Get new hardware advance gain by ID 1300 */ +rt1320_fw_param_protocol (rt1320,RT1320_GET_PARAM ,1300 , + &audDriverDataHwSwGain,sizeof (audDriverDataHwSwGain)); + HwAdvGain = audDriverDataHwSwGain.HwAdvGain;
If this is intended to support a fallback in case param 1300 isn't supported shouldn't we have an error check here in case the call to the firmware fails? The parameters are just read onto a stack variable so we're not relying on them being left at 0 on error...
Mark Brown
maintainerRe: (subset) [PATCH v4 1/2] ASoC: rt1320-sdw: kcontrol for brown-out feature update
In reply to [email protected]Quoted 1 line · On Thu, 09 Apr 2026 14:01:01 +0800, [email protected] wrote:
ASoC: rt1320-sdw: kcontrol for brown-out feature update
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.1
Thanks!
[1/2] ASoC: rt1320-sdw: kcontrol for brown-out feature update
https://git.kernel.org/broonie/sound/c/fbb1f8ba4e2d
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