diff mbox series

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

Message ID 20211025113857.3860951-2-CTLIN0@nuvoton.com (mailing list archive)
State Superseded
Commit c6167e10e76fb97d37613004046e66027b3a569b
Headers show
Series Make genaral and simple for new sof machine driver | expand

Commit Message

David Lin Oct. 25, 2021, 11:38 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".

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(+)

Comments

Mark Brown Oct. 25, 2021, 12:15 p.m. UTC | #1
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.
Mark Brown Oct. 25, 2021, 12:26 p.m. UTC | #2
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.
David Lin Oct. 26, 2021, 8:19 a.m. UTC | #3
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.
David Lin Oct. 26, 2021, 8:25 a.m. UTC | #4
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.
diff mbox series

Patch

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,