* [PATCH] ASoC: da7219: Add Jack insertion detection polarity selection
@ 2023-05-12 8:10 David Rau
2023-05-12 16:18 ` Krzysztof Kozlowski
0 siblings, 1 reply; 4+ messages in thread
From: David Rau @ 2023-05-12 8:10 UTC (permalink / raw)
To: broonie
Cc: support.opensource, lgirdwood, perex, tiwai, robh+dt,
krzysztof.kozlowski+dt, conor+dt, devicetree, alsa-devel,
linux-kernel, David Rau
DA7219 can support 2 kinds of insertion detection polarity
- Default polarity (Low)
- Inverted polarity (High)
This patch adds support for selecting insertion detection
polarity to the DT binding.
Signed-off-by: David Rau <David.Rau.opensource@dm.renesas.com>
---
.../devicetree/bindings/sound/da7219.txt | 3 ++
include/sound/da7219-aad.h | 6 ++++
sound/soc/codecs/da7219-aad.c | 34 +++++++++++++++++++
3 files changed, 43 insertions(+)
diff --git a/Documentation/devicetree/bindings/sound/da7219.txt b/Documentation/devicetree/bindings/sound/da7219.txt
index add1caf26ac2..357d1f61de1d 100644
--- a/Documentation/devicetree/bindings/sound/da7219.txt
+++ b/Documentation/devicetree/bindings/sound/da7219.txt
@@ -52,6 +52,8 @@ Optional properties:
[<200>, <500>, <750>, <1000>]
- dlg,jack-ins-deb : Debounce time for jack insertion (ms)
[<5>, <10>, <20>, <50>, <100>, <200>, <500>, <1000>]
+- dlg,jack-ins-det-pty : Polarity for jack insertion detection
+ ["low", "high"]
- dlg,jack-det-rate: Jack type detection latency (3/4 pole)
["32ms_64ms", "64ms_128ms", "128ms_256ms", "256ms_512ms"]
- dlg,jack-rem-deb : Debounce time for jack removal (ms)
@@ -98,6 +100,7 @@ Example:
dlg,btn-cfg = <50>;
dlg,mic-det-thr = <500>;
dlg,jack-ins-deb = <20>;
+ dlg,jack-ins-det-pty = "low";
dlg,jack-det-rate = "32ms_64ms";
dlg,jack-rem-deb = <1>;
diff --git a/include/sound/da7219-aad.h b/include/sound/da7219-aad.h
index 24ee7baa2589..41320522daa2 100644
--- a/include/sound/da7219-aad.h
+++ b/include/sound/da7219-aad.h
@@ -44,6 +44,11 @@ enum da7219_aad_jack_ins_deb {
DA7219_AAD_JACK_INS_DEB_1S,
};
+enum da7219_aad_jack_ins_det_pty {
+ DA7219_AAD_JACK_INS_DET_PTY_LOW = 0,
+ DA7219_AAD_JACK_INS_DET_PTY_HIGH,
+};
+
enum da7219_aad_jack_det_rate {
DA7219_AAD_JACK_DET_RATE_32_64MS = 0,
DA7219_AAD_JACK_DET_RATE_64_128MS,
@@ -80,6 +85,7 @@ struct da7219_aad_pdata {
enum da7219_aad_btn_cfg btn_cfg;
enum da7219_aad_mic_det_thr mic_det_thr;
enum da7219_aad_jack_ins_deb jack_ins_deb;
+ enum da7219_aad_jack_ins_det_pty jack_ins_det_pty;
enum da7219_aad_jack_det_rate jack_det_rate;
enum da7219_aad_jack_rem_deb jack_rem_deb;
diff --git a/sound/soc/codecs/da7219-aad.c b/sound/soc/codecs/da7219-aad.c
index 993a0d00bc48..a61dc965f4fc 100644
--- a/sound/soc/codecs/da7219-aad.c
+++ b/sound/soc/codecs/da7219-aad.c
@@ -571,6 +571,19 @@ static enum da7219_aad_jack_ins_deb
}
}
+static enum da7219_aad_jack_ins_det_pty
+ da7219_aad_fw_jack_ins_det_pty(struct device *dev, const char *str)
+{
+ if (!strcmp(str, "low")) {
+ return DA7219_AAD_JACK_INS_DET_PTY_LOW;
+ } else if (!strcmp(str, "high")) {
+ return DA7219_AAD_JACK_INS_DET_PTY_HIGH;
+ } else {
+ dev_warn(dev, "Invalid jack insertion detection polarity");
+ return DA7219_AAD_JACK_INS_DET_PTY_LOW;
+ }
+}
+
static enum da7219_aad_jack_det_rate
da7219_aad_fw_jack_det_rate(struct device *dev, const char *str)
{
@@ -688,6 +701,12 @@ static struct da7219_aad_pdata *da7219_aad_fw_to_pdata(struct device *dev)
else
aad_pdata->jack_ins_deb = DA7219_AAD_JACK_INS_DEB_20MS;
+ if (!fwnode_property_read_string(aad_np, "dlg,jack-ins-det-pty", &fw_str))
+ aad_pdata->jack_ins_det_pty =
+ da7219_aad_fw_jack_ins_det_pty(dev, fw_str);
+ else
+ aad_pdata->jack_ins_det_pty = DA7219_AAD_JACK_INS_DET_PTY_LOW;
+
if (!fwnode_property_read_string(aad_np, "dlg,jack-det-rate", &fw_str))
aad_pdata->jack_det_rate =
da7219_aad_fw_jack_det_rate(dev, fw_str);
@@ -849,6 +868,21 @@ static void da7219_aad_handle_pdata(struct snd_soc_component *component)
mask |= DA7219_ADC_1_BIT_REPEAT_MASK;
}
snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_7, mask, cfg);
+
+ switch (aad_pdata->jack_ins_det_pty) {
+ case DA7219_AAD_JACK_INS_DET_PTY_LOW:
+ snd_soc_component_write(component, 0xF0, 0x8B);
+ snd_soc_component_write(component, 0x75, 0x80);
+ snd_soc_component_write(component, 0xF0, 0x00);
+ break;
+ case DA7219_AAD_JACK_INS_DET_PTY_HIGH:
+ snd_soc_component_write(component, 0xF0, 0x8B);
+ snd_soc_component_write(component, 0x75, 0x00);
+ snd_soc_component_write(component, 0xF0, 0x00);
+ break;
+ default:
+ break;
+ }
}
}
--
2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ASoC: da7219: Add Jack insertion detection polarity selection
2023-05-12 8:10 [PATCH] ASoC: da7219: Add Jack insertion detection polarity selection David Rau
@ 2023-05-12 16:18 ` Krzysztof Kozlowski
0 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2023-05-12 16:18 UTC (permalink / raw)
To: David Rau, broonie
Cc: support.opensource, lgirdwood, perex, tiwai, robh+dt,
krzysztof.kozlowski+dt, conor+dt, devicetree, alsa-devel,
linux-kernel
On 12/05/2023 10:10, David Rau wrote:
> DA7219 can support 2 kinds of insertion detection polarity
> - Default polarity (Low)
> - Inverted polarity (High)
>
> This patch adds support for selecting insertion detection
> polarity to the DT binding.
>
> Signed-off-by: David Rau <David.Rau.opensource@dm.renesas.com>
> ---
> .../devicetree/bindings/sound/da7219.txt | 3 ++
Bindings are always separate patches.
Consider also converting them to DT schema first.
> include/sound/da7219-aad.h | 6 ++++
> sound/soc/codecs/da7219-aad.c | 34 +++++++++++++++++++
> 3 files changed, 43 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/sound/da7219.txt b/Documentation/devicetree/bindings/sound/da7219.txt
> index add1caf26ac2..357d1f61de1d 100644
> --- a/Documentation/devicetree/bindings/sound/da7219.txt
> +++ b/Documentation/devicetree/bindings/sound/da7219.txt
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ASoC: da7219: Add Jack insertion detection polarity selection
2023-05-04 8:22 David Rau
@ 2023-05-04 13:39 ` Mark Brown
0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2023-05-04 13:39 UTC (permalink / raw)
To: David Rau
Cc: support.opensource, lgirdwood, perex, tiwai, alsa-devel, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2423 bytes --]
On Thu, May 04, 2023 at 08:22:18AM +0000, David Rau wrote:
> +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).
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.
> +
> +endchoice
> +
> +endif # SND_SOC_DA7219
> +
> config SND_SOC_DA732X
> tristate
> depends on I2C
> diff --git a/sound/soc/codecs/da7219-aad.c b/sound/soc/codecs/da7219-aad.c
> index 993a0d00bc48..9d16112cff6b 100644
> --- a/sound/soc/codecs/da7219-aad.c
> +++ b/sound/soc/codecs/da7219-aad.c
> @@ -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
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] ASoC: da7219: Add Jack insertion detection polarity selection
@ 2023-05-04 8:22 David Rau
2023-05-04 13:39 ` Mark Brown
0 siblings, 1 reply; 4+ messages in thread
From: David Rau @ 2023-05-04 8:22 UTC (permalink / raw)
To: broonie
Cc: support.opensource, lgirdwood, perex, tiwai, alsa-devel,
linux-kernel, David Rau
Add the selection of DA7219 Jack insertion detection polarity
- Default polarity (Low)
- Inverted polarity (High)
Signed-off-by: David Rau <David.Rau.opensource@dm.renesas.com>
---
sound/soc/codecs/Kconfig | 24 +++++++++++++++++++++++-
sound/soc/codecs/da7219-aad.c | 16 ++++++++++++++++
2 files changed, 39 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 79d2362ad055..96f934ad52e7 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -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
diff --git a/sound/soc/codecs/da7219-aad.c b/sound/soc/codecs/da7219-aad.c
index 993a0d00bc48..9d16112cff6b 100644
--- a/sound/soc/codecs/da7219-aad.c
+++ b/sound/soc/codecs/da7219-aad.c
@@ -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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-05-12 16:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-12 8:10 [PATCH] ASoC: da7219: Add Jack insertion detection polarity selection David Rau
2023-05-12 16:18 ` Krzysztof Kozlowski
-- strict thread matches above, loose matches on Subject: below --
2023-05-04 8:22 David Rau
2023-05-04 13:39 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®