* [PATCH v3 1/2] ASoC: rt1320-sdw: kcontrol for brown-out feature update
@ 2026-04-08 5:37 jack.yu
2026-04-08 5:37 ` [PATCH v3 2/2] ASoC: rt1320-sdw: Add an approach to get new hardware advance gain jack.yu
2026-04-08 12:49 ` [PATCH v3 1/2] ASoC: rt1320-sdw: kcontrol for brown-out feature update Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: jack.yu @ 2026-04-08 5:37 UTC (permalink / raw)
To: broonie, lgirdwood
Cc: alsa-devel, lars, flove, oder_chiou, shumingf, derek.fang,
Jack Yu
From: Jack Yu <jack.yu@realtek.com>
Create a kcontrol to enable or disable brown-out dynamically.
Signed-off-by: Jack Yu <jack.yu@realtek.com>
---
sound/soc/codecs/rt1320-sdw.c | 40 +++++++++++++++++++++++++++++++++++
sound/soc/codecs/rt1320-sdw.h | 1 +
2 files changed, 41 insertions(+)
diff --git a/sound/soc/codecs/rt1320-sdw.c b/sound/soc/codecs/rt1320-sdw.c
index 8bb7e8497c72..84e8768f7881 100644
--- a/sound/soc/codecs/rt1320-sdw.c
+++ b/sound/soc/codecs/rt1320-sdw.c
@@ -2486,6 +2486,43 @@ 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;
+
+ if (!rt1320->hw_init)
+ return 0;
+
+ ret = pm_runtime_resume(component->dev);
+ if (ret < 0 && ret != -EACCES)
+ return ret;
+
+ 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 0;
+}
+
+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 +2582,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 +2943,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);
diff --git a/sound/soc/codecs/rt1320-sdw.h b/sound/soc/codecs/rt1320-sdw.h
index 5a9f496dd848..4a1d3fc4c8ee 100644
--- a/sound/soc/codecs/rt1320-sdw.h
+++ b/sound/soc/codecs/rt1320-sdw.h
@@ -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];
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v3 2/2] ASoC: rt1320-sdw: Add an approach to get new hardware advance gain
2026-04-08 5:37 [PATCH v3 1/2] ASoC: rt1320-sdw: kcontrol for brown-out feature update jack.yu
@ 2026-04-08 5:37 ` jack.yu
2026-04-08 12:49 ` [PATCH v3 1/2] ASoC: rt1320-sdw: kcontrol for brown-out feature update Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: jack.yu @ 2026-04-08 5:37 UTC (permalink / raw)
To: broonie, lgirdwood
Cc: alsa-devel, lars, flove, oder_chiou, shumingf, derek.fang,
Jack Yu
From: Jack Yu <jack.yu@realtek.com>
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.
Signed-off-by: Jack Yu <jack.yu@realtek.com>
---
sound/soc/codecs/rt1320-sdw.c | 21 +++++++++++++++++++--
sound/soc/codecs/rt1320-sdw.h | 13 +++++++++++++
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/rt1320-sdw.c b/sound/soc/codecs/rt1320-sdw.c
index 84e8768f7881..b5b72fb87de2 100644
--- a/sound/soc/codecs/rt1320-sdw.c
+++ b/sound/soc/codecs/rt1320-sdw.c
@@ -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 */
diff --git a/sound/soc/codecs/rt1320-sdw.h b/sound/soc/codecs/rt1320-sdw.h
index 4a1d3fc4c8ee..a7b573883dd0 100644
--- a/sound/soc/codecs/rt1320-sdw.h
+++ b/sound/soc/codecs/rt1320-sdw.h
@@ -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;
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3 1/2] ASoC: rt1320-sdw: kcontrol for brown-out feature update
2026-04-08 5:37 [PATCH v3 1/2] ASoC: rt1320-sdw: kcontrol for brown-out feature update jack.yu
2026-04-08 5:37 ` [PATCH v3 2/2] ASoC: rt1320-sdw: Add an approach to get new hardware advance gain jack.yu
@ 2026-04-08 12:49 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2026-04-08 12:49 UTC (permalink / raw)
To: jack.yu
Cc: lgirdwood, alsa-devel, lars, flove, oder_chiou, shumingf,
derek.fang
[-- Attachment #1: Type: text/plain, Size: 522 bytes --]
On Wed, Apr 08, 2026 at 01:37:15PM +0800, jack.yu@realtek.com wrote:
> +static int rt1320_brown_out_put(struct snd_kcontrol *kcontrol,
> + struct snd_ctl_elem_value *ucontrol)
> + 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 0;
This doesn't return 1 when the value changes, so you'll be missing an
event. mixer-test should tell you about this.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-08 12:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-08 5:37 [PATCH v3 1/2] ASoC: rt1320-sdw: kcontrol for brown-out feature update jack.yu
2026-04-08 5:37 ` [PATCH v3 2/2] ASoC: rt1320-sdw: Add an approach to get new hardware advance gain jack.yu
2026-04-08 12:49 ` [PATCH v3 1/2] ASoC: rt1320-sdw: kcontrol for brown-out feature update Mark Brown
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.