From: <jack.yu@realtek.com>
To: <broonie@kernel.org>, <lgirdwood@gmail.com>
Cc: <alsa-devel@alsa-project.org>, <lars@metafoo.de>,
<flove@realtek.com>, <oder_chiou@realtek.com>,
<shumingf@realtek.com>, <derek.fang@realtek.com>,
Jack Yu <jack.yu@realtek.com>
Subject: [PATCH v3 1/2] ASoC: rt1320-sdw: kcontrol for brown-out feature update
Date: Wed, 8 Apr 2026 13:37:15 +0800 [thread overview]
Message-ID: <20260408053716.3757937-1-jack.yu@realtek.com> (raw)
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
next reply other threads:[~2026-04-08 5:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-08 5:37 jack.yu [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260408053716.3757937-1-jack.yu@realtek.com \
--to=jack.yu@realtek.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=derek.fang@realtek.com \
--cc=flove@realtek.com \
--cc=lars@metafoo.de \
--cc=lgirdwood@gmail.com \
--cc=oder_chiou@realtek.com \
--cc=shumingf@realtek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox