All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Make genaral and simple for new sof machine driver
@ 2021-10-25 11:38 David Lin
  2021-10-25 11:38 ` [PATCH 1/2] ASoC: nau8825: add set_jack coponment support David Lin
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: David Lin @ 2021-10-25 11:38 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, WTLI, SJLIN0, KCHSU0, lgirdwood, YHCHuang,
	mac.chiang, CTLIN0

The series of features will make general and simple for new sof machine driver.

David Lin (2):
  ASoC: nau8825: add set_jack coponment support
  ASoC: nau8825: add clock management for power saving

 sound/soc/codecs/nau8825.c | 48 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 46 insertions(+), 2 deletions(-)



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

* [PATCH 1/2] ASoC: nau8825: add set_jack coponment support
  2021-10-25 11:38 [PATCH 0/2] Make genaral and simple for new sof machine driver David Lin
@ 2021-10-25 11:38 ` David Lin
  2021-10-25 12:15   ` Mark Brown
  2021-10-25 12:26   ` Mark Brown
  2021-10-25 11:38 ` [PATCH 2/2] ASoC: nau8825: add clock management for power saving David Lin
  2021-10-27 17:29 ` [PATCH 0/2] Make genaral and simple for new sof machine driver Mark Brown
  2 siblings, 2 replies; 8+ messages in thread
From: David Lin @ 2021-10-25 11:38 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, WTLI, SJLIN0, KCHSU0, lgirdwood, YHCHuang,
	mac.chiang, CTLIN0

Use set_jack ops to set jack for new machine drivers. Meanwhile,
the old machine drivers can still call previous export function
"nau8825_enable_jack_detect".

Signed-off-by: David Lin <CTLIN0@nuvoton.com>
Signed-off-by: Mac Chiang <mac.chiang@intel.com>
---
 sound/soc/codecs/nau8825.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c
index 67de0e49ccf4..e7a6bd918be3 100644
--- a/sound/soc/codecs/nau8825.c
+++ b/sound/soc/codecs/nau8825.c
@@ -1434,6 +1434,12 @@ int nau8825_enable_jack_detect(struct snd_soc_component *component,
 
 	nau8825->jack = jack;
 
+	if (!nau8825->jack) {
+		regmap_update_bits(regmap, NAU8825_REG_HSD_CTRL,
+				   NAU8825_HSD_AUTO_MODE | NAU8825_SPKR_DWN1R |
+				   NAU8825_SPKR_DWN1L, 0);
+		return 0;
+	}
 	/* Ground HP Outputs[1:0], needed for headset auto detection
 	 * Enable Automatic Mic/Gnd switching reading on insert interrupt[6]
 	 */
@@ -2416,6 +2422,12 @@ static int __maybe_unused nau8825_resume(struct snd_soc_component *component)
 	return 0;
 }
 
+static int nau8825_set_jack(struct snd_soc_component *component,
+			    struct snd_soc_jack *jack, void *data)
+{
+	return nau8825_enable_jack_detect(component, jack);
+}
+
 static const struct snd_soc_component_driver nau8825_component_driver = {
 	.probe			= nau8825_component_probe,
 	.remove			= nau8825_component_remove,
@@ -2430,6 +2442,7 @@ static const struct snd_soc_component_driver nau8825_component_driver = {
 	.num_dapm_widgets	= ARRAY_SIZE(nau8825_dapm_widgets),
 	.dapm_routes		= nau8825_dapm_routes,
 	.num_dapm_routes	= ARRAY_SIZE(nau8825_dapm_routes),
+	.set_jack		= nau8825_set_jack,
 	.suspend_bias_off	= 1,
 	.idle_bias_on		= 1,
 	.use_pmdown_time	= 1,
-- 
2.25.1


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

* [PATCH 2/2] ASoC: nau8825: add clock management for power saving
  2021-10-25 11:38 [PATCH 0/2] Make genaral and simple for new sof machine driver David Lin
  2021-10-25 11:38 ` [PATCH 1/2] ASoC: nau8825: add set_jack coponment support David Lin
@ 2021-10-25 11:38 ` David Lin
  2021-10-27 17:29 ` [PATCH 0/2] Make genaral and simple for new sof machine driver Mark Brown
  2 siblings, 0 replies; 8+ messages in thread
From: David Lin @ 2021-10-25 11:38 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, WTLI, SJLIN0, KCHSU0, lgirdwood, YHCHuang,
	mac.chiang, CTLIN0

Adjust dapm widget to manage clock from power event for power saving.

Signed-off-by: David Lin <CTLIN0@nuvoton.com>
Signed-off-by: Mac Chiang <mac.chiang@intel.com>
---
 sound/soc/codecs/nau8825.c | 35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c
index e7a6bd918be3..7734bc35ab21 100644
--- a/sound/soc/codecs/nau8825.c
+++ b/sound/soc/codecs/nau8825.c
@@ -47,6 +47,7 @@
 
 static int nau8825_configure_sysclk(struct nau8825 *nau8825,
 		int clk_id, unsigned int freq);
+static bool nau8825_is_jack_inserted(struct regmap *regmap);
 
 struct nau8825_fll {
 	int mclk_src;
@@ -981,6 +982,31 @@ static int nau8825_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 nau8825 *nau8825 = snd_soc_component_get_drvdata(component);
+	struct regmap *regmap = nau8825->regmap;
+
+	if (SND_SOC_DAPM_EVENT_OFF(event)) {
+		dev_dbg(nau8825->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 (nau8825_is_jack_inserted(regmap)) {
+			nau8825_configure_sysclk(nau8825,
+						 NAU8825_CLK_INTERNAL, 0);
+		} else {
+			nau8825_configure_sysclk(nau8825, NAU8825_CLK_DIS, 0);
+		}
+	}
+
+	return 0;
+}
+
 static int nau8825_biq_coeff_get(struct snd_kcontrol *kcontrol,
 				     struct snd_ctl_elem_value *ucontrol)
 {
@@ -1094,6 +1120,9 @@ static const struct snd_kcontrol_new nau8825_dacr_mux =
 static const struct snd_soc_dapm_widget nau8825_dapm_widgets[] = {
 	SND_SOC_DAPM_AIF_OUT("AIFTX", "Capture", 0, NAU8825_REG_I2S_PCM_CTRL2,
 		15, 1),
+	SND_SOC_DAPM_AIF_IN("AIFRX", "Playback", 0, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_SUPPLY("System Clock", SND_SOC_NOPM, 0, 0,
+			    system_clock_control, SND_SOC_DAPM_POST_PMD),
 
 	SND_SOC_DAPM_INPUT("MIC"),
 	SND_SOC_DAPM_MICBIAS("MICBIAS", NAU8825_REG_MIC_BIAS, 8, 0),
@@ -1182,9 +1211,11 @@ static const struct snd_soc_dapm_route nau8825_dapm_routes[] = {
 	{"ADC", NULL, "ADC Clock"},
 	{"ADC", NULL, "ADC Power"},
 	{"AIFTX", NULL, "ADC"},
+	{"AIFTX", NULL, "System Clock"},
 
-	{"DDACL", NULL, "Playback"},
-	{"DDACR", NULL, "Playback"},
+	{"AIFRX", NULL, "System Clock"},
+	{"DDACL", NULL, "AIFRX"},
+	{"DDACR", NULL, "AIFRX"},
 	{"DDACL", NULL, "DDAC Clock"},
 	{"DDACR", NULL, "DDAC Clock"},
 	{"DACL Mux", "DACL", "DDACL"},
-- 
2.25.1


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

* Re: [PATCH 1/2] ASoC: nau8825: add set_jack coponment support
  2021-10-25 11:38 ` [PATCH 1/2] ASoC: nau8825: add set_jack coponment support David Lin
@ 2021-10-25 12:15   ` Mark Brown
  2021-10-26  8:19     ` AS50 CTLin0
  2021-10-25 12:26   ` Mark Brown
  1 sibling, 1 reply; 8+ messages in thread
From: Mark Brown @ 2021-10-25 12:15 UTC (permalink / raw)
  To: David Lin
  Cc: alsa-devel, WTLI, SJLIN0, KCHSU0, lgirdwood, YHCHuang, mac.chiang

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

On Mon, Oct 25, 2021 at 07:38:57PM +0800, David Lin wrote:
> Use set_jack ops to set jack for new machine drivers. Meanwhile,
> the old machine drivers can still call previous export function
> "nau8825_enable_jack_detect".
> 
> Signed-off-by: David Lin <CTLIN0@nuvoton.com>
> Signed-off-by: Mac Chiang <mac.chiang@intel.com>
> ---
>  sound/soc/codecs/nau8825.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c
> index 67de0e49ccf4..e7a6bd918be3 100644
> --- a/sound/soc/codecs/nau8825.c
> +++ b/sound/soc/codecs/nau8825.c
> @@ -1434,6 +1434,12 @@ int nau8825_enable_jack_detect(struct snd_soc_component *component,
>  
>  	nau8825->jack = jack;
>  
> +	if (!nau8825->jack) {
> +		regmap_update_bits(regmap, NAU8825_REG_HSD_CTRL,
> +				   NAU8825_HSD_AUTO_MODE | NAU8825_SPKR_DWN1R |
> +				   NAU8825_SPKR_DWN1L, 0);

This looks like a separate change to support disabling jack detect which
should be in a separate commit.

> +		return 0;
> +	}
>  	/* Ground HP Outputs[1:0], needed for headset auto detection

Should really be a blank line here.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 1/2] ASoC: nau8825: add set_jack coponment support
  2021-10-25 11:38 ` [PATCH 1/2] ASoC: nau8825: add set_jack coponment support David Lin
  2021-10-25 12:15   ` Mark Brown
@ 2021-10-25 12:26   ` Mark Brown
  2021-10-26  8:25     ` AS50 CTLin0
  1 sibling, 1 reply; 8+ messages in thread
From: Mark Brown @ 2021-10-25 12:26 UTC (permalink / raw)
  To: David Lin
  Cc: alsa-devel, WTLI, SJLIN0, KCHSU0, lgirdwood, YHCHuang, mac.chiang

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

On Mon, Oct 25, 2021 at 07:38:57PM +0800, David Lin wrote:
> Use set_jack ops to set jack for new machine drivers. Meanwhile,
> the old machine drivers can still call previous export function
> "nau8825_enable_jack_detect".
> 
> Signed-off-by: David Lin <CTLIN0@nuvoton.com>
> Signed-off-by: Mac Chiang <mac.chiang@intel.com>
> ---

One other thing, sorry - your signoff should generally come last.  If
Mac wrote this then the commit should say it comes from them, if you
worked on it together then Co-developed-by is usually used.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 1/2] ASoC: nau8825: add set_jack coponment support
  2021-10-25 12:15   ` Mark Brown
@ 2021-10-26  8:19     ` AS50 CTLin0
  0 siblings, 0 replies; 8+ messages in thread
From: AS50 CTLin0 @ 2021-10-26  8:19 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, WTLI, SJLIN0, KCHSU0, lgirdwood, YHCHuang, mac.chiang

On 2021/10/25 下午 08:15, Mark Brown wrote:
> On Mon, Oct 25, 2021 at 07:38:57PM +0800, David Lin wrote:
>> Use set_jack ops to set jack for new machine drivers. Meanwhile,
>> the old machine drivers can still call previous export function
>> "nau8825_enable_jack_detect".
>>
>> Signed-off-by: David Lin <CTLIN0@nuvoton.com>
>> Signed-off-by: Mac Chiang <mac.chiang@intel.com>
>> ---
>>   sound/soc/codecs/nau8825.c | 13 +++++++++++++
>>   1 file changed, 13 insertions(+)
>>
>> diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c
>> index 67de0e49ccf4..e7a6bd918be3 100644
>> --- a/sound/soc/codecs/nau8825.c
>> +++ b/sound/soc/codecs/nau8825.c
>> @@ -1434,6 +1434,12 @@ int nau8825_enable_jack_detect(struct snd_soc_component *component,
>>
>>      nau8825->jack = jack;
>>
>> +    if (!nau8825->jack) {
>> +            regmap_update_bits(regmap, NAU8825_REG_HSD_CTRL,
>> +                               NAU8825_HSD_AUTO_MODE | NAU8825_SPKR_DWN1R |
>> +                               NAU8825_SPKR_DWN1L, 0);
> This looks like a separate change to support disabling jack detect which
> should be in a separate commit.
I will separate it from this patch.
>
>> +            return 0;
>> +    }
>>      /* Ground HP Outputs[1:0], needed for headset auto detection
> Should really be a blank line here.
I will fix it.
________________________________
________________________________
 The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.

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

* Re: [PATCH 1/2] ASoC: nau8825: add set_jack coponment support
  2021-10-25 12:26   ` Mark Brown
@ 2021-10-26  8:25     ` AS50 CTLin0
  0 siblings, 0 replies; 8+ messages in thread
From: AS50 CTLin0 @ 2021-10-26  8:25 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, WTLI, SJLIN0, KCHSU0, lgirdwood, YHCHuang, mac.chiang

On 2021/10/25 下午 08:26, Mark Brown wrote:
> On Mon, Oct 25, 2021 at 07:38:57PM +0800, David Lin wrote:
>> Use set_jack ops to set jack for new machine drivers. Meanwhile,
>> the old machine drivers can still call previous export function
>> "nau8825_enable_jack_detect".
>>
>> Signed-off-by: David Lin <CTLIN0@nuvoton.com>
>> Signed-off-by: Mac Chiang <mac.chiang@intel.com>
>> ---
> One other thing, sorry - your signoff should generally come last.  If
> Mac wrote this then the commit should say it comes from them, if you
> worked on it together then Co-developed-by is usually used.
Thanks for your suggestion. I will update on next submission.
________________________________
________________________________
 The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.

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

* Re: [PATCH 0/2] Make genaral and simple for new sof machine driver
  2021-10-25 11:38 [PATCH 0/2] Make genaral and simple for new sof machine driver David Lin
  2021-10-25 11:38 ` [PATCH 1/2] ASoC: nau8825: add set_jack coponment support David Lin
  2021-10-25 11:38 ` [PATCH 2/2] ASoC: nau8825: add clock management for power saving David Lin
@ 2021-10-27 17:29 ` Mark Brown
  2 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2021-10-27 17:29 UTC (permalink / raw)
  To: David Lin
  Cc: alsa-devel, WTLI, SJLIN0, KCHSU0, lgirdwood, YHCHuang, mac.chiang

On Mon, 25 Oct 2021 19:38:56 +0800, David Lin wrote:
> The series of features will make general and simple for new sof machine driver.
> 
> David Lin (2):
>   ASoC: nau8825: add set_jack coponment support
>   ASoC: nau8825: add clock management for power saving
> 
> sound/soc/codecs/nau8825.c | 48 ++++++++++++++++++++++++++++++++++++--
>  1 file changed, 46 insertions(+), 2 deletions(-)
> 
> [...]

Applied to

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

Thanks!

[1/2] ASoC: nau8825: add set_jack coponment support
      commit: c6167e10e76fb97d37613004046e66027b3a569b
[2/2] ASoC: nau8825: add clock management for power saving
      commit: 6133148ca08a097ed8c57d7f5a7826723273049b

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

end of thread, other threads:[~2021-10-27 17:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-25 11:38 [PATCH 0/2] Make genaral and simple for new sof machine driver David Lin
2021-10-25 11:38 ` [PATCH 1/2] ASoC: nau8825: add set_jack coponment support David Lin
2021-10-25 12:15   ` Mark Brown
2021-10-26  8:19     ` AS50 CTLin0
2021-10-25 12:26   ` Mark Brown
2021-10-26  8:25     ` AS50 CTLin0
2021-10-25 11:38 ` [PATCH 2/2] ASoC: nau8825: add clock management for power saving David Lin
2021-10-27 17:29 ` [PATCH 0/2] Make genaral and simple for new sof machine driver 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.