cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

mt6359-accdet.h (2837B)


      1/* SPDX-License-Identifier: GPL-2.0 */
      2/*
      3 * Copyright (C) 2021 MediaTek Inc.
      4 * Author: Argus Lin <argus.lin@mediatek.com>
      5 */
      6
      7#ifndef _ACCDET_H_
      8#define _ACCDET_H_
      9
     10#include <linux/ctype.h>
     11#include <linux/string.h>
     12
     13#define ACCDET_DEVNAME "accdet"
     14
     15#define HEADSET_MODE_1		(1)
     16#define HEADSET_MODE_2		(2)
     17#define HEADSET_MODE_6		(6)
     18
     19#define MT6359_ACCDET_NUM_BUTTONS 4
     20#define MT6359_ACCDET_JACK_MASK (SND_JACK_HEADPHONE | \
     21				SND_JACK_HEADSET | \
     22				SND_JACK_BTN_0 | \
     23				SND_JACK_BTN_1 | \
     24				SND_JACK_BTN_2 | \
     25				SND_JACK_BTN_3)
     26#define MT6359_ACCDET_BTN_MASK (SND_JACK_BTN_0 | \
     27				SND_JACK_BTN_1 | \
     28				SND_JACK_BTN_2 | \
     29				SND_JACK_BTN_3)
     30
     31enum eint_moisture_status {
     32	M_PLUG_IN =		0,
     33	M_WATER_IN =		1,
     34	M_HP_PLUG_IN =		2,
     35	M_PLUG_OUT =		3,
     36	M_NO_ACT =		4,
     37	M_UNKNOWN =		5,
     38};
     39
     40enum {
     41	accdet_state000 = 0,
     42	accdet_state001,
     43	accdet_state010,
     44	accdet_state011,
     45	accdet_auxadc,
     46	eint_state000,
     47	eint_state001,
     48	eint_state010,
     49	eint_state011,
     50	eint_inverter_state000,
     51};
     52
     53struct three_key_threshold {
     54	unsigned int mid;
     55	unsigned int up;
     56	unsigned int down;
     57};
     58
     59struct four_key_threshold {
     60	unsigned int mid;
     61	unsigned int voice;
     62	unsigned int up;
     63	unsigned int down;
     64};
     65
     66struct pwm_deb_settings {
     67	unsigned int pwm_width;
     68	unsigned int pwm_thresh;
     69	unsigned int fall_delay;
     70	unsigned int rise_delay;
     71	unsigned int debounce0;
     72	unsigned int debounce1;
     73	unsigned int debounce3;
     74	unsigned int debounce4;
     75	unsigned int eint_pwm_width;
     76	unsigned int eint_pwm_thresh;
     77	unsigned int eint_debounce0;
     78	unsigned int eint_debounce1;
     79	unsigned int eint_debounce2;
     80	unsigned int eint_debounce3;
     81	unsigned int eint_inverter_debounce;
     82
     83};
     84
     85struct dts_data {
     86	unsigned int mic_vol;
     87	unsigned int mic_mode;
     88	unsigned int plugout_deb;
     89	unsigned int eint_pol;
     90	struct pwm_deb_settings *pwm_deb;
     91	struct three_key_threshold three_key;
     92	struct four_key_threshold four_key;
     93	unsigned int moisture_detect_enable;
     94	unsigned int eint_detect_mode;
     95	unsigned int eint_use_ext_res;
     96	unsigned int eint_comp_vth;
     97	unsigned int moisture_detect_mode;
     98	unsigned int moisture_comp_vth;
     99	unsigned int moisture_comp_vref2;
    100	unsigned int moisture_use_ext_res;
    101};
    102
    103struct mt6359_accdet {
    104	struct snd_soc_jack *jack;
    105	struct device *dev;
    106	struct regmap *regmap;
    107	struct dts_data *data;
    108	unsigned int caps;
    109	int accdet_irq;
    110	int accdet_eint0;
    111	int accdet_eint1;
    112	struct mutex res_lock; /* lock protection */
    113	bool jack_plugged;
    114	unsigned int jack_type;
    115	unsigned int btn_type;
    116	unsigned int accdet_status;
    117	unsigned int pre_accdet_status;
    118	unsigned int cali_voltage;
    119	unsigned int jd_sts;
    120	struct work_struct accdet_work;
    121	struct workqueue_struct *accdet_workqueue;
    122	struct work_struct jd_work;
    123	struct workqueue_struct *jd_workqueue;
    124};
    125
    126int mt6359_accdet_enable_jack_detect(struct snd_soc_component *component,
    127				     struct snd_soc_jack *jack);
    128#endif