[PATCH 0/3] Make genaral and simple for new sof machine driver
The series of features will make general and simple for new sof machine driver.
David Lin (3): ASoC: nau8825: add set_jack coponment support ASoC: nau8825: add disable jack detection support ASoC: nau8825: add clock management for power saving
sound/soc/codecs/nau8825.c | 49 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-)
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".
Co-developed-by: Mac Chiang mac.chiang@intel.com Signed-off-by: Mac Chiang mac.chiang@intel.com Signed-off-by: David Lin CTLIN0@nuvoton.com --- sound/soc/codecs/nau8825.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c index 67de0e49ccf4..c845f19b7c41 100644 --- a/sound/soc/codecs/nau8825.c +++ b/sound/soc/codecs/nau8825.c @@ -2416,6 +2416,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 +2436,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,
typo in commit subject: coponment -> component
please use scripts/checkpatch.pl --strict --codespell
On 10/26/21 9:51 PM, 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".
Co-developed-by: Mac Chiang mac.chiang@intel.com Signed-off-by: Mac Chiang mac.chiang@intel.com Signed-off-by: David Lin CTLIN0@nuvoton.com
sound/soc/codecs/nau8825.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c index 67de0e49ccf4..c845f19b7c41 100644 --- a/sound/soc/codecs/nau8825.c +++ b/sound/soc/codecs/nau8825.c @@ -2416,6 +2416,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);
+}
in some cases, this function can be called with a NULL jack argument. See other codec drivers, e.g.
int arizona_jack_set_jack(struct snd_soc_component *component, struct snd_soc_jack *jack, void *data) { struct arizona_priv *info = snd_soc_component_get_drvdata(component);
if (jack) return arizona_jack_enable_jack_detect(info, jack); else return arizona_jack_disable_jack_detect(info); }
On 2021/10/27 下午 10:02, Pierre-Louis Bossart wrote:
typo in commit subject: coponment -> component
please use scripts/checkpatch.pl --strict --codespell
I will be more carefully for next. I appreciate your kindly guide.
On 10/26/21 9:51 PM, 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".
Co-developed-by: Mac Chiang mac.chiang@intel.com Signed-off-by: Mac Chiang mac.chiang@intel.com Signed-off-by: David Lin CTLIN0@nuvoton.com
sound/soc/codecs/nau8825.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c index 67de0e49ccf4..c845f19b7c41 100644 --- a/sound/soc/codecs/nau8825.c +++ b/sound/soc/codecs/nau8825.c @@ -2416,6 +2416,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);
+}
in some cases, this function can be called with a NULL jack argument. See other codec drivers, e.g.
int arizona_jack_set_jack(struct snd_soc_component *component, struct snd_soc_jack *jack, void *data) { struct arizona_priv *info = snd_soc_component_get_drvdata(component);
if (jack) return arizona_jack_enable_jack_detect(info, jack); else return arizona_jack_disable_jack_detect(info);
}
I have caught these information from some codec driver, even sof machine driver also use snd_soc_component_set_jack to replace previous export function for jack setting.
________________________________ ________________________________ 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.
A feature for disabling jack detection support.
Co-developed-by: Mac Chiang mac.chiang@intel.com Signed-off-by: Mac Chiang mac.chiang@intel.com Signed-off-by: David Lin CTLIN0@nuvoton.com --- sound/soc/codecs/nau8825.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c index c845f19b7c41..a356f26735bd 100644 --- a/sound/soc/codecs/nau8825.c +++ b/sound/soc/codecs/nau8825.c @@ -1434,6 +1434,13 @@ 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] */
On 10/26/21 9:51 PM, David Lin wrote:
A feature for disabling jack detection support.
Co-developed-by: Mac Chiang mac.chiang@intel.com Signed-off-by: Mac Chiang mac.chiang@intel.com Signed-off-by: David Lin CTLIN0@nuvoton.com
sound/soc/codecs/nau8825.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c index c845f19b7c41..a356f26735bd 100644 --- a/sound/soc/codecs/nau8825.c +++ b/sound/soc/codecs/nau8825.c @@ -1434,6 +1434,13 @@ 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;
- }
oh, so you've addressed my comment from the first patch but it might be clearer to follow the flow from other codec drivers and test the jack argument at a higher level, then you have an enable/disable parameter.
/* Ground HP Outputs[1:0], needed for headset auto detection * Enable Automatic Mic/Gnd switching reading on insert interrupt[6] */
On 2021/10/27 下午 10:05, Pierre-Louis Bossart wrote:
On 10/26/21 9:51 PM, David Lin wrote:
A feature for disabling jack detection support.
Co-developed-by: Mac Chiang mac.chiang@intel.com Signed-off-by: Mac Chiang mac.chiang@intel.com Signed-off-by: David Lin CTLIN0@nuvoton.com
sound/soc/codecs/nau8825.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c index c845f19b7c41..a356f26735bd 100644 --- a/sound/soc/codecs/nau8825.c +++ b/sound/soc/codecs/nau8825.c @@ -1434,6 +1434,13 @@ 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;
- }
oh, so you've addressed my comment from the first patch but it might be clearer to follow the flow from other codec drivers and test the jack argument at a higher level, then you have an enable/disable parameter.
Yes, I understand your thinking. You consider more clearly logic and readable for overall code.
Your suggestion make me with one target follow. I can do more plan for next.
/* Ground HP Outputs[1:0], needed for headset auto detection * Enable Automatic Mic/Gnd switching reading on insert interrupt[6] */
________________________________ ________________________________ 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.
Adjust dapm widget to manage clock from power event for power saving.
Co-developed-by: Mac Chiang mac.chiang@intel.com Signed-off-by: Mac Chiang mac.chiang@intel.com Signed-off-by: David Lin CTLIN0@nuvoton.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 a356f26735bd..eed017d5df4b 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"},
On Wed, 27 Oct 2021 10:51:40 +0800, David Lin wrote:
The series of features will make general and simple for new sof machine driver.
David Lin (3): ASoC: nau8825: add set_jack coponment support ASoC: nau8825: add disable jack detection support ASoC: nau8825: add clock management for power saving
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/3] ASoC: nau8825: add set_jack coponment support commit: c6167e10e76fb97d37613004046e66027b3a569b [2/3] ASoC: nau8825: add disable jack detection support (no commit info) [3/3] 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
participants (4)
-
AS50 CTLin0
-
David Lin
-
Mark Brown
-
Pierre-Louis Bossart