ASoC: max98095: add jack detection
PATCH v2 1/1 ASoC: max98095: add jack detection
This change adds the logic to support using the jack detect mechanism built in to the codec to detect both when a jack was inserted and what type of jack is present.
This change also supports the use of an external mechanism for headphone detection. If this mechanism exists, when the max98095_jack_detect function is called, the hp_jack is simply passed NULL.
This change supports both simple headphones, powered headphones, microphones and headsets with both headphones and a mic.
v2:
- Removed useless function for irq_handler
- removed enable/disable irq
- Added pdata entry for jack detections slew rate
- get irq directly from dev
--- include/sound/max98095.h | 12 +++ sound/soc/codecs/max98095.c | 158 ++++++++++++++++++++++++++++++++++++++++++- sound/soc/codecs/max98095.h | 22 ++++++ 3 files changed, 191 insertions(+), 1 deletions(-)
include/sound/max98095.h +12 -0
@@ -49,6 +49,18 @@ struct max98095_pdata {*/ unsigned int digmic_left_mode:1; unsigned int digmic_right_mode:1; + +/* Pin5 is the mechanical method of sensing jack insertion +* but it is something that might not be supported. +* 0 = PIN5 not supported +* 1 = PIN5 supported +*/ + int jack_detect_pin5en:1; + +/* Slew amount for jack detection. Calculated as 4 * (delay + 1). +* Default delay is 24 to get a time of 100ms. +*/ + unsigned int jack_detect_delay; };#endif
sound/soc/codecs/max98095.c +157 -1
223 lines not on this page · raw message
sound/soc/codecs/max98095.h +22 -0
@@ -175,11 +175,23 @@/* MAX98095 Registers Bit Fields */ +/* M98095_007_JACK_AUTO_STS */ +#define M98095_MIC_IN (1<<3) +#define M98095_LO_IN (1<<5) +#define M98095_HP_IN (1<<6) +#define M98095_DDONE (1<<7) +/* M98095_00F_HOST_CFG */ #define M98095_SEG (1<<0)#define M98095_XTEN (1<<1)#define M98095_MDLLEN (1<<2) +/* M98095_013_JACK_INT_EN */ +#define M98095_IMIC_IN (1<<3) +#define M98095_ILO_IN (1<<5) +#define M98095_IHP_IN (1<<6) +#define M98095_IDDONE (1<<7) +/* M98095_027_DAI1_CLKMODE, M98095_031_DAI2_CLKMODE, M98095_03B_DAI3_CLKMODE */ #define M98095_CLKMODE_MASK 0xFF
@@ -255,6 +267,10 @@#define M98095_EQ2EN (1<<1)#define M98095_EQ1EN (1<<0) +/* M98095_089_JACK_DET_AUTO */ +#define M98095_PIN5EN (1<<2) +#define M98095_JDEN (1<<7) +/* M98095_090_PWR_EN_IN */ #define M98095_INEN (1<<7)#define M98095_MB2EN (1<<3)
@@ -296,4 +312,10 @@#define M98095_174_DAI1_BQ_BASE 0x74#define M98095_17E_DAI2_BQ_BASE 0x7E +/* Default Delay used in Slew Rate Calculation for Jack detection */ +#define M98095_DEFAULT_SLEW_DELAY 0x18 + +extern int max98095_jack_detect (struct snd_soc_codec *codec, +struct snd_soc_jack *hp_jack,struct snd_soc_jack *mic_jack); +#endif
Signature · 1 line
1.7.0.4
Mark Brown
AppliedQuoted 5 lines · Rhyland Klein
v2:
- Removed useless function forirq_handler
- removed enable/disable irq
- Added pdata entry for jack detections slew rate
- get irq directly from dev
Applied, but always include this stuff after the --- as it shouldn't end up in git (see SubmittingPatches).