public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Shuming Fan <shumingf@realtek.com>,
	Sasha Levin <sashal@kernel.org>,
	oder_chiou@realtek.com, lgirdwood@gmail.com, broonie@kernel.org,
	perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org
Subject: [PATCH AUTOSEL 6.4 12/17] ASoC: rt1308-sdw: fix random louder sound
Date: Tue, 29 Aug 2023 09:31:59 -0400	[thread overview]
Message-ID: <20230829133211.519957-12-sashal@kernel.org> (raw)
In-Reply-To: <20230829133211.519957-1-sashal@kernel.org>

From: Shuming Fan <shumingf@realtek.com>

[ Upstream commit 37aba3190891d4de189bd5192ee95220e295f34d ]

This patch uses a vendor register to check whether the system hibernated ever.
The driver will only set the preset when the driver brings up or the system hibernated.
It will avoid the unknown issue that makes the speaker output louder and can't control the volume.

Signed-off-by: Shuming Fan <shumingf@realtek.com
Link: https://lore.kernel.org/r/20230811093822.37573-1-shumingf@realtek.com
Signed-off-by: Mark Brown <broonie@kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 sound/soc/codecs/rt1308-sdw.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/rt1308-sdw.c b/sound/soc/codecs/rt1308-sdw.c
index 1797af824f60b..e2699c0b117be 100644
--- a/sound/soc/codecs/rt1308-sdw.c
+++ b/sound/soc/codecs/rt1308-sdw.c
@@ -52,6 +52,7 @@ static bool rt1308_volatile_register(struct device *dev, unsigned int reg)
 	case 0x300a:
 	case 0xc000:
 	case 0xc710:
+	case 0xcf01:
 	case 0xc860 ... 0xc863:
 	case 0xc870 ... 0xc873:
 		return true;
@@ -213,7 +214,7 @@ static int rt1308_io_init(struct device *dev, struct sdw_slave *slave)
 {
 	struct rt1308_sdw_priv *rt1308 = dev_get_drvdata(dev);
 	int ret = 0;
-	unsigned int tmp;
+	unsigned int tmp, hibernation_flag;
 
 	if (rt1308->hw_init)
 		return 0;
@@ -242,6 +243,10 @@ static int rt1308_io_init(struct device *dev, struct sdw_slave *slave)
 
 	pm_runtime_get_noresume(&slave->dev);
 
+	regmap_read(rt1308->regmap, 0xcf01, &hibernation_flag);
+	if ((hibernation_flag != 0x00) && rt1308->first_hw_init)
+		goto _preset_ready_;
+
 	/* sw reset */
 	regmap_write(rt1308->regmap, RT1308_SDW_RESET, 0);
 
@@ -282,6 +287,12 @@ static int rt1308_io_init(struct device *dev, struct sdw_slave *slave)
 	regmap_write(rt1308->regmap, 0xc100, 0xd7);
 	regmap_write(rt1308->regmap, 0xc101, 0xd7);
 
+	/* apply BQ params */
+	rt1308_apply_bq_params(rt1308);
+
+	regmap_write(rt1308->regmap, 0xcf01, 0x01);
+
+_preset_ready_:
 	if (rt1308->first_hw_init) {
 		regcache_cache_bypass(rt1308->regmap, false);
 		regcache_mark_dirty(rt1308->regmap);
-- 
2.40.1


  parent reply	other threads:[~2023-08-29 13:34 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-29 13:31 [PATCH AUTOSEL 6.4 01/17] arm64: dts: rockchip: correct wifi interrupt flag in eaidk-610 Sasha Levin
2023-08-29 13:31 ` [PATCH AUTOSEL 6.4 02/17] arm64: dts: rockchip: correct wifi interrupt flag in Rock Pi 4B Sasha Levin
2023-08-29 13:31 ` [PATCH AUTOSEL 6.4 03/17] arm64: dts: rockchip: correct wifi interrupt flag in Box Demo Sasha Levin
2023-08-29 13:31 ` [PATCH AUTOSEL 6.4 04/17] vhost-scsi: Fix alignment handling with windows Sasha Levin
2023-08-29 13:31 ` [PATCH AUTOSEL 6.4 05/17] vdpa/mlx5: Correct default number of queues when MQ is on Sasha Levin
2023-08-29 13:31 ` [PATCH AUTOSEL 6.4 06/17] virtio-mem: remove unsafe unplug in Big Block Mode (BBM) Sasha Levin
2023-08-29 13:31 ` [PATCH AUTOSEL 6.4 07/17] virtio-mem: convert most offline_and_remove_memory() errors to -EBUSY Sasha Levin
2023-08-29 13:31 ` [PATCH AUTOSEL 6.4 08/17] virtio-mem: keep retrying on offline_and_remove_memory() errors in Sub Block Mode (SBM) Sasha Levin
2023-08-29 13:31 ` [PATCH AUTOSEL 6.4 09/17] virtio-mem: check if the config changed before fake offlining memory Sasha Levin
2023-08-29 13:31 ` [PATCH AUTOSEL 6.4 10/17] ALSA: hda/cs8409: Support new Dell Dolphin Variants Sasha Levin
2023-08-29 13:31 ` [PATCH AUTOSEL 6.4 11/17] ARM: dts: integrator: fix PCI bus dtc warnings Sasha Levin
2023-08-29 13:31 ` Sasha Levin [this message]
2023-08-29 13:32 ` [PATCH AUTOSEL 6.4 13/17] i2c: imx-lpi2c: return -EINVAL when i2c peripheral clk doesn't work Sasha Levin
2023-08-29 13:32 ` [PATCH AUTOSEL 6.4 14/17] fbdev: goldfishfb: Do not check 0 for platform_get_irq() Sasha Levin
2023-08-29 13:32 ` [PATCH AUTOSEL 6.4 15/17] broadcom: b44: Use b44_writephy() return value Sasha Levin
2023-08-29 13:32 ` [PATCH AUTOSEL 6.4 16/17] gpiolib: fix reference leaks when removing GPIO chips still in use Sasha Levin
2023-08-29 13:32 ` [PATCH AUTOSEL 6.4 17/17] drm/amd/pm: Fix temperature unit of SMU v13.0.6 Sasha Levin

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=20230829133211.519957-12-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oder_chiou@realtek.com \
    --cc=perex@perex.cz \
    --cc=shumingf@realtek.com \
    --cc=stable@vger.kernel.org \
    --cc=tiwai@suse.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