diff options
author | Hans de Goede <hdegoede@redhat.com> | 2018-05-08 17:35:51 +0200 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2018-05-11 04:23:19 +0200 |
commit | 8210804bcf40b837f8560c99efb315c0bbfc8c7b (patch) | |
tree | 0dc6e2dda128071badb53928018fa7ac0b6aadf2 /sound/soc/codecs/rt5640.h | |
parent | ASoC: rt5640: Allow specifying dmic data pins through device-properties (diff) | |
download | linux-8210804bcf40b837f8560c99efb315c0bbfc8c7b.tar.xz linux-8210804bcf40b837f8560c99efb315c0bbfc8c7b.zip |
ASoC: rt5640: Add jack-detect support
Add jack-detect support, loosely based on earlier work on this by:
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Francisco mendez <francisco.mendez@intel.com>
Note getting the OVCD to work reliable was sort of finicky, so there are
quite a few comments on this to hopefully avoid people breaking it in the
future.
This (and the follow-up button press support) has been tested on the
following devices:
Acer Iconia Tab 8 W1-810
Asus T100CHI
Asus T100TA
Asus T200TA
Axxo WT1011
Chuwi Vi8
Dell Venue 8 Pro 5830
HP Pavilion X2 10-n000nd
HP Stream 7
I.T. Works TW891
Lamina I8270
MSI S100
Peaq C1010
Pipo W4
PoV MobiiTAB-P800W (v2.0)
Toshiba Click Mini L9W-B
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=196377
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/codecs/rt5640.h')
-rw-r--r-- | sound/soc/codecs/rt5640.h | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/sound/soc/codecs/rt5640.h b/sound/soc/codecs/rt5640.h index 2db6586f5ab4..9d08471734b3 100644 --- a/sound/soc/codecs/rt5640.h +++ b/sound/soc/codecs/rt5640.h @@ -13,6 +13,8 @@ #define _RT5640_H #include <linux/clk.h> +#include <linux/workqueue.h> +#include <dt-bindings/sound/rt5640.h> /* Info */ #define RT5640_RESET 0x00 @@ -145,6 +147,7 @@ /* Index of Codec Private Register definition */ +#define RT5640_BIAS_CUR4 0x15 #define RT5640_CHPUMP_INT_REG1 0x24 #define RT5640_MAMP_INT_REG2 0x37 #define RT5640_3D_SPK 0x63 @@ -1606,10 +1609,17 @@ #define RT5640_MB2_OC_P_SFT 6 #define RT5640_MB2_OC_P_NOR (0x0 << 6) #define RT5640_MB2_OC_P_INV (0x1 << 6) -#define RT5640_MB1_OC_CLR (0x1 << 3) -#define RT5640_MB1_OC_CLR_SFT 3 -#define RT5640_MB2_OC_CLR (0x1 << 2) -#define RT5640_MB2_OC_CLR_SFT 2 +#define RT5640_MB1_OC_STATUS (0x1 << 3) +#define RT5640_MB1_OC_STATUS_SFT 3 +#define RT5640_MB2_OC_STATUS (0x1 << 2) +#define RT5640_MB2_OC_STATUS_SFT 2 + +/* GPIO and Internal Status (0xbf) */ +#define RT5640_GPIO1_STATUS (0x1 << 8) +#define RT5640_GPIO2_STATUS (0x1 << 7) +#define RT5640_JD_STATUS (0x1 << 4) +#define RT5640_OVT_STATUS (0x1 << 3) +#define RT5640_CLS_D_OVCD_STATUS (0x1 << 0) /* GPIO Control 1 (0xc0) */ #define RT5640_GP1_PIN_MASK (0x1 << 15) @@ -1977,6 +1987,15 @@ #define RT5640_MCLK_DET (0x1 << 11) /* Codec Private Register definition */ + +/* MIC Over current threshold scale factor (0x15) */ +#define RT5640_MIC_OVCD_SF_MASK (0x3 << 8) +#define RT5640_MIC_OVCD_SF_SFT 8 +#define RT5640_MIC_OVCD_SF_0P5 (0x0 << 8) +#define RT5640_MIC_OVCD_SF_0P75 (0x1 << 8) +#define RT5640_MIC_OVCD_SF_1P0 (0x2 << 8) +#define RT5640_MIC_OVCD_SF_1P5 (0x3 << 8) + /* 3D Speaker Control (0x63) */ #define RT5640_3D_SPK_MASK (0x1 << 15) #define RT5640_3D_SPK_SFT 15 @@ -2106,6 +2125,7 @@ struct rt5640_priv { struct clk *mclk; int ldo1_en; /* GPIO for LDO1_EN */ + int irq; int sysclk; int sysclk_src; int lrck[RT5640_AIFS]; @@ -2118,6 +2138,14 @@ struct rt5640_priv { bool hp_mute; bool asrc_en; + + /* Jack detect data */ + struct work_struct jack_work; + struct snd_soc_jack *jack; + unsigned int jd_src; + bool jd_inverted; + unsigned int ovcd_th; + unsigned int ovcd_sf; }; int rt5640_dmic_enable(struct snd_soc_component *component, |