ASoC: da7219: Add Jack insertion detection polarity selection
Subsystems (4)
PATCH 1/1 ASoC: da7219: Add Jack insertion detection polarity selection
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.
--- .../devicetree/bindings/sound/da7219.txt | 3 ++ include/sound/da7219-aad.h | 6 ++++ sound/soc/codecs/da7219-aad.c | 34 +++++++++++++++++++ 3 files changed, 43 insertions(+)
Documentation/devicetree/bindings/sound/da7219.txt +3 -0
@@ -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>;
include/sound/da7219-aad.h +6 -0
@@ -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;
sound/soc/codecs/da7219-aad.c +34 -0
@@ -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 ; + } } }
Signature · 1 line
2.17.1
Quoted 10 lines · 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 <[email protected]>--- .../devicetree/bindings/sound/da7219.txt | 3 ++
Bindings are always separate patches.
Consider also converting them to DT schema first.
Documentation/devicetree/bindings/sound/da7219.txt
Quoted 8 lines
include/sound/da7219-aad.h | 6 ++++ sound/soc/codecs/da7219-aad.c | 34 +++++++++++++++++++ 3 files changed, 43 insertions(+)Documentation/devicetree/bindings/sound/da7219.txt +0
-0
Best regards,
Krzysztof
-----Original Message-----
From: Krzysztof Kozlowski <[email protected]>
Sent: Saturday, May 13, 2023 00:18
To: David.Rau.opensource <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] ASoC: da7219: Add Jack insertion detection polarity selection
Quoted 7 lines · 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.
Quoted 6 lines
Signed-off-by David Rau <[email protected]>--- .../devicetree/bindings/sound/da7219.txt | 3 ++Bindings are always separate patches.
Consider also converting them to DT schema first.
Well noted and thanks for the kind suggestions.
I will submit the binding change and driver code in different patch.
Documentation/devicetree/bindings/sound/da7219.txt
Quoted 9 lines
include/sound/da7219-aad.h | 6 ++++ sound/soc/codecs/da7219-aad.c | 34 +++++++++++++++++++ 3 files changed, 43 insertions(+)Documentation/devicetree/bindings/sound/da7219.txt +0
-0
Best regards,
Krzysztof