* [PATCH 0/4] ASoC: tas2764: Random patches from the Asahi Linux tree
@ 2025-02-08 1:03 broonie
2025-02-08 1:03 ` [PATCH 1/4] ASoC: tas2764: Power up/down amp on mute ops broonie
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: broonie @ 2025-02-08 1:03 UTC (permalink / raw)
To: Shenghao Ding, Kevin Lu, Baojun Xu, Liam Girdwood,
Jaroslav Kysela, Takashi Iwai, Dan Murphy, Hector Martin,
Martin Povišer
Cc: linux-sound, linux-kernel, devicetree, Mark Brown
This is a random subset of the patches for the tas2764 driver that I
found in the Asahi Linux tree which seemed to be clear fixes and
improvements which apply easily to mainline without much effort, there's
a bunch more work on the driver that should also be applicable.
I've only build tested this.
Signed-off-by: Mark Brown <broonie@kernel.org>
---
Hector Martin (4):
ASoC: tas2764: Power up/down amp on mute ops
ASoC: tas2764: Wait for ramp-down after shutdown
ASoC: tas2764: Mark SW_RESET as volatile
ASoC: tas2764: Add reg defaults for TAS2764_INT_CLK_CFG
sound/soc/codecs/tas2764.c | 61 +++++++++++++++++++++++-----------------------
1 file changed, 31 insertions(+), 30 deletions(-)
---
base-commit: 2014c95afecee3e76ca4a56956a936e23283f05b
change-id: 20250207-asoc-tas2764-f128ee84f68e
Best regards,
--
Mark Brown <broonie@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/4] ASoC: tas2764: Power up/down amp on mute ops
2025-02-08 1:03 [PATCH 0/4] ASoC: tas2764: Random patches from the Asahi Linux tree broonie
@ 2025-02-08 1:03 ` broonie
2025-02-08 1:03 ` [PATCH 2/4] ASoC: tas2764: Wait for ramp-down after shutdown broonie
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: broonie @ 2025-02-08 1:03 UTC (permalink / raw)
To: Shenghao Ding, Kevin Lu, Baojun Xu, Liam Girdwood,
Jaroslav Kysela, Takashi Iwai, Dan Murphy, Hector Martin,
Martin Povišer
Cc: linux-sound, linux-kernel, devicetree, Mark Brown
From: Hector Martin <marcan@marcan.st>
The ASoC convention is that clocks are removed after codec mute, and
power up/down is more about top level power management. For these chips,
the "mute" state still expects a TDM clock, and yanking the clock in
this state will trigger clock errors. So, do the full
shutdown<->mute<->active transition on the mute operation, so the amp is
in software shutdown by the time the clocks are removed.
This fixes TDM clock errors when streams are stopped.
Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
sound/soc/codecs/tas2764.c | 51 +++++++++++++++++++---------------------------
1 file changed, 21 insertions(+), 30 deletions(-)
diff --git a/sound/soc/codecs/tas2764.c b/sound/soc/codecs/tas2764.c
index d482cd194c08..60d660a88fab 100644
--- a/sound/soc/codecs/tas2764.c
+++ b/sound/soc/codecs/tas2764.c
@@ -180,33 +180,6 @@ static SOC_ENUM_SINGLE_DECL(
static const struct snd_kcontrol_new tas2764_asi1_mux =
SOC_DAPM_ENUM("ASI1 Source", tas2764_ASI1_src_enum);
-static int tas2764_dac_event(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *kcontrol, int event)
-{
- struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
- struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component);
- int ret;
-
- switch (event) {
- case SND_SOC_DAPM_POST_PMU:
- tas2764->dac_powered = true;
- ret = tas2764_update_pwr_ctrl(tas2764);
- break;
- case SND_SOC_DAPM_PRE_PMD:
- tas2764->dac_powered = false;
- ret = tas2764_update_pwr_ctrl(tas2764);
- break;
- default:
- dev_err(tas2764->dev, "Unsupported event\n");
- return -EINVAL;
- }
-
- if (ret < 0)
- return ret;
-
- return 0;
-}
-
static const struct snd_kcontrol_new isense_switch =
SOC_DAPM_SINGLE("Switch", TAS2764_PWR_CTRL, TAS2764_ISENSE_POWER_EN, 1, 1);
static const struct snd_kcontrol_new vsense_switch =
@@ -219,8 +192,7 @@ static const struct snd_soc_dapm_widget tas2764_dapm_widgets[] = {
1, &isense_switch),
SND_SOC_DAPM_SWITCH("VSENSE", TAS2764_PWR_CTRL, TAS2764_VSENSE_POWER_EN,
1, &vsense_switch),
- SND_SOC_DAPM_DAC_E("DAC", NULL, SND_SOC_NOPM, 0, 0, tas2764_dac_event,
- SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
+ SND_SOC_DAPM_DAC("DAC", NULL, SND_SOC_NOPM, 0, 0),
SND_SOC_DAPM_OUTPUT("OUT"),
SND_SOC_DAPM_SIGGEN("VMON"),
SND_SOC_DAPM_SIGGEN("IMON")
@@ -241,9 +213,28 @@ static int tas2764_mute(struct snd_soc_dai *dai, int mute, int direction)
{
struct tas2764_priv *tas2764 =
snd_soc_component_get_drvdata(dai->component);
+ int ret;
+
+ if (!mute) {
+ tas2764->dac_powered = true;
+ ret = tas2764_update_pwr_ctrl(tas2764);
+ if (ret)
+ return ret;
+ }
tas2764->unmuted = !mute;
- return tas2764_update_pwr_ctrl(tas2764);
+ ret = tas2764_update_pwr_ctrl(tas2764);
+ if (ret)
+ return ret;
+
+ if (mute) {
+ tas2764->dac_powered = false;
+ ret = tas2764_update_pwr_ctrl(tas2764);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
}
static int tas2764_set_bitwidth(struct tas2764_priv *tas2764, int bitwidth)
--
2.39.5
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/4] ASoC: tas2764: Wait for ramp-down after shutdown
2025-02-08 1:03 [PATCH 0/4] ASoC: tas2764: Random patches from the Asahi Linux tree broonie
2025-02-08 1:03 ` [PATCH 1/4] ASoC: tas2764: Power up/down amp on mute ops broonie
@ 2025-02-08 1:03 ` broonie
2025-02-08 1:03 ` [PATCH 3/4] ASoC: tas2764: Mark SW_RESET as volatile broonie
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: broonie @ 2025-02-08 1:03 UTC (permalink / raw)
To: Shenghao Ding, Kevin Lu, Baojun Xu, Liam Girdwood,
Jaroslav Kysela, Takashi Iwai, Dan Murphy, Hector Martin,
Martin Povišer
Cc: linux-sound, linux-kernel, devicetree, Mark Brown
From: Hector Martin <marcan@marcan.st>
When we shut down the amp, we need to wait for the built-in ramp-down
before we can remove the TDM clocks. There is no documented status
regiter to poll, so the best we can do is a delay. Datasheet says 5.9ms
for ramp-down and 1.5ms between shutdown and next startup, so let's do
6ms after mute and 2ms after shutdown. That gives us a cumulative 8ms
for ramp-down and guaratees the required minimum shutdown time.
Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
sound/soc/codecs/tas2764.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/sound/soc/codecs/tas2764.c b/sound/soc/codecs/tas2764.c
index 60d660a88fab..0b033ab51f7f 100644
--- a/sound/soc/codecs/tas2764.c
+++ b/sound/soc/codecs/tas2764.c
@@ -142,6 +142,8 @@ static int tas2764_codec_suspend(struct snd_soc_component *component)
regcache_cache_only(tas2764->regmap, true);
regcache_mark_dirty(tas2764->regmap);
+ usleep_range(6000, 7000);
+
return 0;
}
@@ -228,10 +230,16 @@ static int tas2764_mute(struct snd_soc_dai *dai, int mute, int direction)
return ret;
if (mute) {
+ /* Wait for ramp-down */
+ usleep_range(6000, 7000);
+
tas2764->dac_powered = false;
ret = tas2764_update_pwr_ctrl(tas2764);
if (ret)
return ret;
+
+ /* Wait a bit after shutdown */
+ usleep_range(2000, 3000);
}
return 0;
--
2.39.5
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/4] ASoC: tas2764: Mark SW_RESET as volatile
2025-02-08 1:03 [PATCH 0/4] ASoC: tas2764: Random patches from the Asahi Linux tree broonie
2025-02-08 1:03 ` [PATCH 1/4] ASoC: tas2764: Power up/down amp on mute ops broonie
2025-02-08 1:03 ` [PATCH 2/4] ASoC: tas2764: Wait for ramp-down after shutdown broonie
@ 2025-02-08 1:03 ` broonie
2025-02-08 1:03 ` [PATCH 4/4] ASoC: tas2764: Add reg defaults for TAS2764_INT_CLK_CFG broonie
2025-02-17 14:32 ` [PATCH 0/4] ASoC: tas2764: Random patches from the Asahi Linux tree Mark Brown
4 siblings, 0 replies; 6+ messages in thread
From: broonie @ 2025-02-08 1:03 UTC (permalink / raw)
To: Shenghao Ding, Kevin Lu, Baojun Xu, Liam Girdwood,
Jaroslav Kysela, Takashi Iwai, Dan Murphy, Hector Martin,
Martin Povišer
Cc: linux-sound, linux-kernel, devicetree, Mark Brown
From: Hector Martin <marcan@marcan.st>
Since the bit is self-clearing.
Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
sound/soc/codecs/tas2764.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/sound/soc/codecs/tas2764.c b/sound/soc/codecs/tas2764.c
index 0b033ab51f7f..d01333c7dd93 100644
--- a/sound/soc/codecs/tas2764.c
+++ b/sound/soc/codecs/tas2764.c
@@ -642,6 +642,7 @@ static const struct regmap_range_cfg tas2764_regmap_ranges[] = {
static bool tas2764_volatile_register(struct device *dev, unsigned int reg)
{
switch (reg) {
+ case TAS2764_SW_RST:
case TAS2764_INT_LTCH0 ... TAS2764_INT_LTCH4:
case TAS2764_INT_CLK_CFG:
return true;
--
2.39.5
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 4/4] ASoC: tas2764: Add reg defaults for TAS2764_INT_CLK_CFG
2025-02-08 1:03 [PATCH 0/4] ASoC: tas2764: Random patches from the Asahi Linux tree broonie
` (2 preceding siblings ...)
2025-02-08 1:03 ` [PATCH 3/4] ASoC: tas2764: Mark SW_RESET as volatile broonie
@ 2025-02-08 1:03 ` broonie
2025-02-17 14:32 ` [PATCH 0/4] ASoC: tas2764: Random patches from the Asahi Linux tree Mark Brown
4 siblings, 0 replies; 6+ messages in thread
From: broonie @ 2025-02-08 1:03 UTC (permalink / raw)
To: Shenghao Ding, Kevin Lu, Baojun Xu, Liam Girdwood,
Jaroslav Kysela, Takashi Iwai, Dan Murphy, Hector Martin,
Martin Povišer
Cc: linux-sound, linux-kernel, devicetree, Mark Brown
From: Hector Martin <marcan@marcan.st>
Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
sound/soc/codecs/tas2764.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/sound/soc/codecs/tas2764.c b/sound/soc/codecs/tas2764.c
index d01333c7dd93..49d32e957789 100644
--- a/sound/soc/codecs/tas2764.c
+++ b/sound/soc/codecs/tas2764.c
@@ -625,6 +625,7 @@ static const struct reg_default tas2764_reg_defaults[] = {
{ TAS2764_TDM_CFG2, 0x0a },
{ TAS2764_TDM_CFG3, 0x10 },
{ TAS2764_TDM_CFG5, 0x42 },
+ { TAS2764_INT_CLK_CFG, 0x19 },
};
static const struct regmap_range_cfg tas2764_regmap_ranges[] = {
--
2.39.5
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/4] ASoC: tas2764: Random patches from the Asahi Linux tree
2025-02-08 1:03 [PATCH 0/4] ASoC: tas2764: Random patches from the Asahi Linux tree broonie
` (3 preceding siblings ...)
2025-02-08 1:03 ` [PATCH 4/4] ASoC: tas2764: Add reg defaults for TAS2764_INT_CLK_CFG broonie
@ 2025-02-17 14:32 ` Mark Brown
4 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2025-02-17 14:32 UTC (permalink / raw)
To: Shenghao Ding, Kevin Lu, Baojun Xu, Liam Girdwood,
Jaroslav Kysela, Takashi Iwai, Dan Murphy, Hector Martin,
Martin Povišer, broonie
Cc: linux-sound, linux-kernel, devicetree
On Sat, 08 Feb 2025 01:03:23 +0000, broonie@kernel.org wrote:
> This is a random subset of the patches for the tas2764 driver that I
> found in the Asahi Linux tree which seemed to be clear fixes and
> improvements which apply easily to mainline without much effort, there's
> a bunch more work on the driver that should also be applicable.
>
> I've only build tested this.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/4] ASoC: tas2764: Power up/down amp on mute ops
commit: 1c3b5f37409682184669457a5bdf761268eafbe5
[2/4] ASoC: tas2764: Wait for ramp-down after shutdown
commit: 08a66f55f7246d477b19620a953476dfc02beefc
[3/4] ASoC: tas2764: Mark SW_RESET as volatile
commit: f37f1748564ac51d32f7588bd7bfc99913ccab8e
[4/4] ASoC: tas2764: Add reg defaults for TAS2764_INT_CLK_CFG
commit: d64c4c3d1c578f98d70db1c5e2535b47adce9d07
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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-02-17 14:32 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-08 1:03 [PATCH 0/4] ASoC: tas2764: Random patches from the Asahi Linux tree broonie
2025-02-08 1:03 ` [PATCH 1/4] ASoC: tas2764: Power up/down amp on mute ops broonie
2025-02-08 1:03 ` [PATCH 2/4] ASoC: tas2764: Wait for ramp-down after shutdown broonie
2025-02-08 1:03 ` [PATCH 3/4] ASoC: tas2764: Mark SW_RESET as volatile broonie
2025-02-08 1:03 ` [PATCH 4/4] ASoC: tas2764: Add reg defaults for TAS2764_INT_CLK_CFG broonie
2025-02-17 14:32 ` [PATCH 0/4] ASoC: tas2764: Random patches from the Asahi Linux tree Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®