All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASOC: nau8821: add new widget to control system clock
@ 2022-07-19  8:40 Wallace Lin
  2022-07-19 17:44 ` Mark Brown
  0 siblings, 1 reply; 3+ messages in thread
From: Wallace Lin @ 2022-07-19  8:40 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, scott6986, WTLI, Wallace Lin, KCHSU0, lgirdwood,
	YHCHuang, Wallace Lin, CTLIN0, dardar923, savagecin,
	supercraig0719

From: Wallace Lin <savagecin0@gmail.com>

Add new widget to control system clock for power saving.

Signed-off-by: Wallace Lin <savagecin0@gmail.com>
Signed-off-by: Wallace Lin <sjlin0@nuvoton.com>
---
 sound/soc/codecs/nau8821.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/sound/soc/codecs/nau8821.c b/sound/soc/codecs/nau8821.c
index 2600be250a3c..83a17c48d594 100644
--- a/sound/soc/codecs/nau8821.c
+++ b/sound/soc/codecs/nau8821.c
@@ -36,6 +36,7 @@
 
 static int nau8821_configure_sysclk(struct nau8821 *nau8821,
 	int clk_id, unsigned int freq);
+static bool nau8821_is_jack_inserted(struct regmap *regmap);
 
 struct nau8821_fll {
 	int mclk_src;
@@ -495,7 +496,33 @@ static int nau8821_output_dac_event(struct snd_soc_dapm_widget *w,
 	return 0;
 }
 
+static int system_clock_control(struct snd_soc_dapm_widget *w,
+				struct snd_kcontrol *k, int  event)
+{
+	struct snd_soc_component *component =
+		snd_soc_dapm_to_component(w->dapm);
+	struct nau8821 *nau8821 = snd_soc_component_get_drvdata(component);
+
+	if (SND_SOC_DAPM_EVENT_OFF(event)) {
+		dev_dbg(nau8821->dev, "system clock control : POWER OFF\n");
+		/* Set clock source to disable or internal clock before the
+		 * playback or capture end. Codec needs clock for Jack
+		 * detection and button press if jack inserted; otherwise,
+		 * the clock should be closed.
+		 */
+		if (nau8821_is_jack_inserted(nau8821->regmap)) {
+			nau8821_configure_sysclk(nau8821,
+				NAU8821_CLK_INTERNAL, 0);
+		} else {
+			nau8821_configure_sysclk(nau8821, NAU8821_CLK_DIS, 0);
+		}
+	}
+	return 0;
+}
+
 static const struct snd_soc_dapm_widget nau8821_dapm_widgets[] = {
+	SND_SOC_DAPM_SUPPLY("System Clock", SND_SOC_NOPM, 0, 0,
+		system_clock_control, SND_SOC_DAPM_POST_PMD),
 	SND_SOC_DAPM_SUPPLY("MICBIAS", NAU8821_R74_MIC_BIAS,
 		NAU8821_MICBIAS_POWERUP_SFT, 0, NULL, 0),
 	SND_SOC_DAPM_SUPPLY("DMIC Clock", SND_SOC_NOPM, 0, 0,
@@ -607,6 +634,9 @@ static const struct snd_soc_dapm_route nau8821_dapm_routes[] = {
 	{"AIFTX", NULL, "ADCL Digital path"},
 	{"AIFTX", NULL, "ADCR Digital path"},
 
+	{"AIFTX", NULL, "System Clock"},
+	{"AIFRX", NULL, "System Clock"},
+
 	{"DDACL", NULL, "AIFRX"},
 	{"DDACR", NULL, "AIFRX"},
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ASOC: nau8821: add new widget to control system clock
  2022-07-19  8:40 [PATCH] ASOC: nau8821: add new widget to control system clock Wallace Lin
@ 2022-07-19 17:44 ` Mark Brown
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Brown @ 2022-07-19 17:44 UTC (permalink / raw)
  To: savagecin
  Cc: alsa-devel, scott6986, WTLI, sjlin0, KCHSU0, savagecin0,
	lgirdwood, YHCHuang, CTLIN0, dardar923, supercraig0719

On Tue, 19 Jul 2022 16:40:47 +0800, Wallace Lin wrote:
> From: Wallace Lin <savagecin0@gmail.com>
> 
> Add new widget to control system clock for power saving.
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASOC: nau8821: add new widget to control system clock
      commit: 0cf470c08319d9aa13e8fb3a26e44b5687bca56e

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] 3+ messages in thread

* Re: [PATCH] ASoC: nau8821: add new widget to control system clock
  2022-07-07  8:07 [PATCH] ASOC: " Wallace Lin
@ 2022-07-08 18:12 ` Mark Brown
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Brown @ 2022-07-08 18:12 UTC (permalink / raw)
  To: Wallace Lin
  Cc: alsa-devel, scott6986, WTLI, SJLIN0, KCHSU0, lgirdwood, YHCHuang,
	CTLIN0, dardar923, supercraig0719

[-- Attachment #1: Type: text/plain, Size: 893 bytes --]

On Thu, Jul 07, 2022 at 04:07:51PM +0800, Wallace Lin wrote:

> @@ -1430,6 +1460,7 @@ static const struct snd_soc_component_driver nau8821_component_driver = {
>  	.dapm_routes		= nau8821_dapm_routes,
>  	.num_dapm_routes	= ARRAY_SIZE(nau8821_dapm_routes),
>  	.suspend_bias_off	= 1,
> +	.non_legacy_dai_naming	= 1,
>  	.idle_bias_on		= 1,
>  	.use_pmdown_time	= 1,
>  	.endianness		= 1,

This isn't obviously connected with the rest of your change and breaks
the build since this flag has been removed in current code.  It should
probably just be dropped here.

Please submit patches using subject lines reflecting the style for the
subsystem, this makes it easier for people to identify relevant patches.
Look at what existing commits in the area you're changing are doing and
make sure your subject lines visually resemble what they're doing.
There's no need to resubmit to fix this alone.

[-- 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:[~2022-07-19 17:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-19  8:40 [PATCH] ASOC: nau8821: add new widget to control system clock Wallace Lin
2022-07-19 17:44 ` Mark Brown
  -- strict thread matches above, loose matches on Subject: below --
2022-07-07  8:07 [PATCH] ASOC: " Wallace Lin
2022-07-08 18:12 ` [PATCH] ASoC: nau8821: " 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.