diff mbox series

[1/3] ASoC: nau8825: add set_jack coponment support

Message ID 20211027025142.25898-2-CTLIN0@nuvoton.com (mailing list archive)
State New, archived
Headers show
Series Make genaral and simple for new sof machine driver | expand

Commit Message

David Lin Oct. 27, 2021, 2:51 a.m. UTC
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(+)

Comments

Pierre-Louis Bossart Oct. 27, 2021, 2:02 p.m. UTC | #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);
}
David Lin Oct. 28, 2021, 7:43 a.m. UTC | #2
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.


>
diff mbox series

Patch

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,