diff mbox series

[2/3] ASoC: nau8825: add disable jack detection support

Message ID 20211027025142.25898-3-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
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(+)

Comments

Pierre-Louis Bossart Oct. 27, 2021, 2:05 p.m. UTC | #1
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]
>  	 */
>
David Lin Oct. 28, 2021, 8:01 a.m. UTC | #2
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]
>>       */
>>
diff mbox series

Patch

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]
 	 */