ASoC: da7219: Add Jack insertion detection polarity selection
Subsystems (3)
PATCH 1/1 ASoC: da7219: Add Jack insertion detection polarity selection
Add the selection of DA7219 Jack insertion detection polarity
- Default polarity (Low)
- Inverted polarity (High)
--- sound/soc/codecs/Kconfig | 24 +++++++++++++++++++++++- sound/soc/codecs/da7219-aad.c | 16 ++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-)
sound/soc/codecs/Kconfig +23 -1
@@ -967,9 +967,31 @@ config SND_SOC_DA7218 depends on I2C config SND_SOC_DA7219 - tristate + tristate "Dialog DA7219 CODEC" depends on I2C +if SND_SOC_DA7219 + +choice + bool "DA7219 Jack insertion detection polarity selection" + default DA7219_DEFAULT_JACK_INSERTION_POLARITY if (SND_SOC_DA7219) + +config DA7219_DEFAULT_JACK_INSERTION_POLARITY + bool "Default polarity" + depends on SND_SOC_DA7219 + help + Select this option if your DA7219 codec with default Jack insertion detection polarity (Low). + +config DA7219_INVERTED_JACK_INSERTION_POLARITY + bool "Inverted polarity" + depends on SND_SOC_DA7219 + help + Select this option if your DA7219 codec with inverted Jack insertion detection polarity (High). + +endchoice + +endif # SND_SOC_DA7219 + config SND_SOC_DA732X tristate depends on I2C
sound/soc/codecs/da7219-aad.c +16 -0
@@ -879,6 +879,18 @@ static void da7219_aad_handle_gnd_switch_time(struct snd_soc_component *componen } } +static void da7219_aad_handle_polarity (struct snd_soc_component *component) +{ +snd_soc_component_write (component,0xF0 ,0x8B ); + +if (IS_ENABLED (CONFIG_DA7219_DEFAULT_JACK_INSERTION_POLARITY )) +snd_soc_component_write (component,0x75 ,0x80 ); +else if (IS_ENABLED (CONFIG_DA7219_INVERTED_JACK_INSERTION_POLARITY )) +snd_soc_component_write (component,0x75 ,0x00 ); + +snd_soc_component_write (component,0xF0 ,0x00 ); +} +/* * Suspend/Resume */
@@ -955,8 +967,12 @@ int da7219_aad_init(struct snd_soc_component *component)snd_soc_component_update_bits (component,DA7219_ACCDET_CONFIG_1 ,DA7219_BUTTON_CONFIG_MASK ,0 ); +/* Handle the default ground switch delay time */ da7219_aad_handle_gnd_switch_time (component); +/* Handle the Jack insertion detection polarity */ +da7219_aad_handle_polarity (component); + da7219_aad->aad_wq =create_singlethread_workqueue ("da7219-aad" );if (!da7219_aad->aad_wq) {dev_err (component->dev,"Failed to create aad workqueue\n" );
Signature · 1 line
2.17.1
Mark Brown
maintainerQuoted 5 lines · David Rau
sound/soc/codecs/Kconfig +5
-0+choice + bool "DA7219 Jack insertion detection polarity selection" + default DA7219_DEFAULT_JACK_INSERTION_POLARITY if (SND_SOC_DA7219) + +config DA7219_DEFAULT_JACK_INSERTION_POLARITY
sound/soc/codecs/Kconfig config SND_SOC_DA7218 · line 989
Quoted 10 lines
sound/soc/codecs/Kconfig +10
-0+ bool "Default polarity" + depends on SND_SOC_DA7219 + help + Select this option if your DA7219 codec with default Jack insertion detection polarity (Low). + +config DA7219_INVERTED_JACK_INSERTION_POLARITY + bool "Inverted polarity" + depends on SND_SOC_DA7219 + help + Select this option if your DA7219 codec with inverted Jack insertion detection polarity (High).
I would expect these things to be fixed for a given board and therefore configured with a DT property rather than a kernel config. It should be possible to use the same kernel on multiple boards.
Quoted 47 lines
sound/soc/codecs/Kconfig +5
-0+ +endchoice + +endif # SND_SOC_DA7219 + config SND_SOC_DA732X tristate depends on I2Csound/soc/codecs/da7219-aad.c +16
-0@@ -879,6 +879,18 @@ static void da7219_aad_handle_gnd_switch_time(struct snd_soc_component *componen } } +static void da7219_aad_handle_polarity (struct snd_soc_component *component) +{ +snd_soc_component_write (component,0xF0 ,0x8B ); + +if (IS_ENABLED (CONFIG_DA7219_DEFAULT_JACK_INSERTION_POLARITY )) +snd_soc_component_write (component,0x75 ,0x80 ); +else if (IS_ENABLED (CONFIG_DA7219_INVERTED_JACK_INSERTION_POLARITY )) +snd_soc_component_write (component,0x75 ,0x00 ); + +snd_soc_component_write (component,0xF0 ,0x00 ); +} +/* * Suspend/Resume */ @@ -955,8 +967,12 @@ int da7219_aad_init(struct snd_soc_component *component)snd_soc_component_update_bits (component,DA7219_ACCDET_CONFIG_1 ,DA7219_BUTTON_CONFIG_MASK ,0 ); +/* Handle the default ground switch delay time */ da7219_aad_handle_gnd_switch_time (component); +/* Handle the Jack insertion detection polarity */ +da7219_aad_handle_polarity (component); + da7219_aad->aad_wq =create_singlethread_workqueue ("da7219-aad" );if (!da7219_aad->aad_wq) {dev_err (component->dev,"Failed to create aad workqueue\n" );Signature · 1 line
2.17.1
-----Original Message-----
From: Mark Brown <[email protected]>
Sent: Thursday, May 4, 2023 21:39
To: David.Rau.opensource <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] ASoC: da7219: Add Jack insertion detection polarity selection
Quoted 16 lines · David Rau
sound/soc/codecs/Kconfig +15
-0+choice + bool "DA7219 Jack insertion detection polarity selection" + default DA7219_DEFAULT_JACK_INSERTION_POLARITY if (SND_SOC_DA7219) + +config DA7219_DEFAULT_JACK_INSERTION_POLARITY + bool "Default polarity" + depends on SND_SOC_DA7219 + help + Select this option if your DA7219 codec with default Jack insertion detection polarity (Low). + +config DA7219_INVERTED_JACK_INSERTION_POLARITY + bool "Inverted polarity" + depends on SND_SOC_DA7219 + help + Select this option if your DA7219 codec with inverted Jack insertion detection polarity (High).
Quoted 1 line
I would expect these things to be fixed for a given board and therefore configured with a DT property rather than a kernel config. It should be possible to use the same kernel on multiple boards.
Thanks for the kind suggestion.
Now I am working on another implementation that retrieve DT data for multiple boards like you said.
Quoted 47 lines
sound/soc/codecs/Kconfig +5
-0+ +endchoice + +endif # SND_SOC_DA7219 + config SND_SOC_DA732X tristate depends on I2C(quoted diff) +0
-0
b/sound/soc/codecs/da7219-aad.cindex993a0d00bc48..9d16112cff6b100644sound/soc/codecs/da7219-aad.c +15
-1@@ -879,6 +879,18 @@ static void da7219_aad_handle_gnd_switch_time(struct snd_soc_component *componen } } +static void da7219_aad_handle_polarity (struct snd_soc_component +*component) { +snd_soc_component_write (component,0xF0 ,0x8B ); + +if (IS_ENABLED (CONFIG_DA7219_DEFAULT_JACK_INSERTION_POLARITY )) +snd_soc_component_write (component,0x75 ,0x80 ); +else if (IS_ENABLED (CONFIG_DA7219_INVERTED_JACK_INSERTION_POLARITY )) +snd_soc_component_write (component,0x75 ,0x00 ); + +snd_soc_component_write (component,0xF0 ,0x00 ); } +/* * Suspend/Resume */ @@ -955,8 +967,12 @@ int da7219_aad_init(struct snd_soc_component *component)snd_soc_component_update_bits (component,DA7219_ACCDET_CONFIG_1 ,DA7219_BUTTON_CONFIG_MASK ,0 ); +/* Handle the default ground switch delay time */ da7219_aad_handle_gnd_switch_time (component); +/* Handle the Jack insertion detection polarity */ +da7219_aad_handle_polarity (component); + da7219_aad->aad_wq =create_singlethread_workqueue ("da7219-aad" );if (!da7219_aad->aad_wq) {dev_err (component->dev,"Failed to create aad workqueue\n" ); --2.17.1