blob: 25b44fa1ee158b10caec1ca92486a69c8e544d63 [file] [log] [blame]
xjb04a4022021-11-25 15:01:52 +08001/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (C) 2019 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/* SW ENV define */
15#define NO_KEY (0x0)
16#define UP_KEY (0x01)
17#define MD_KEY (0x02)
18#define DW_KEY (0x04)
19#define AS_KEY (0x08)
20
21#define HEADSET_MODE_1 (1)
22#define HEADSET_MODE_2 (2)
23#define HEADSET_MODE_6 (6)
24
25/* IOCTL */
26#define ACCDET_IOC_MAGIC 'A'
27#define ACCDET_INIT _IO(ACCDET_IOC_MAGIC, 0)
28#define SET_CALL_STATE _IO(ACCDET_IOC_MAGIC, 1)
29#define GET_BUTTON_STATUS _IO(ACCDET_IOC_MAGIC, 2)
30
31/* 400us, Accdet irq clear timeout */
32#define ACCDET_TIME_OUT 0x61A80
33
34/* cable type recognized by accdet, and report to WiredAccessoryManager */
35enum accdet_report_state {
36 NO_DEVICE = 0,
37 HEADSET_MIC = 1,
38 HEADSET_NO_MIC = 2,
39 HEADSET_FIVE_POLE = 3,
40 LINE_OUT_DEVICE = 4,
41};
42
43/* accdet status got from accdet FSM */
44enum accdet_status {
45 PLUG_OUT = 0,
46 MIC_BIAS = 1,
47 HOOK_SWITCH = 2,
48 BI_MIC_BIAS = 3,
49 LINE_OUT = 4,
50 STAND_BY = 5
51};
52
53enum accdet_eint_ID {
54 NO_PMIC_EINT = 0,
55 PMIC_EINT0 = 1,
56 PMIC_EINT1 = 2,
57 PMIC_BIEINT = 3,
58};
59
60/* EINT state when moisture enable */
61enum eint_moisture_status {
62 M_PLUG_IN = 0,
63 M_WATER_IN = 1,
64 M_HP_PLUG_IN = 2,
65 M_PLUG_OUT = 3,
66 M_NO_ACT = 4,
67 M_UNKNOWN = 5,
68};
69
70struct three_key_threshold {
71 unsigned int mid;
72 unsigned int up;
73 unsigned int down;
74};
75struct four_key_threshold {
76 unsigned int mid;
77 unsigned int voice;
78 unsigned int up;
79 unsigned int down;
80};
81
82struct pwm_deb_settings {
83 unsigned int pwm_width;
84 unsigned int pwm_thresh;
85 unsigned int fall_delay;
86 unsigned int rise_delay;
87 unsigned int debounce0;
88 unsigned int debounce1;
89 unsigned int debounce3;
90 unsigned int debounce4;
91 unsigned int eint_pwm_width;
92 unsigned int eint_pwm_thresh;
93 unsigned int eint_debounce0;
94 unsigned int eint_debounce1;
95 unsigned int eint_debounce2;
96 unsigned int eint_debounce3;
97 unsigned int eint_inverter_debounce;
98
99};
100
101struct head_dts_data {
102 unsigned int mic_vol;
103 unsigned int mic_mode;
104 unsigned int plugout_deb;
105 unsigned int eint_pol;
106 struct pwm_deb_settings pwm_deb;
107 struct three_key_threshold three_key;
108 struct four_key_threshold four_key;
109 unsigned int moisture_detect_enable;
110 unsigned int eint_detect_mode;
111 unsigned int eint_use_ext_res;
112 unsigned int moisture_detect_mode;
113 unsigned int moisture_comp_vth;
114 unsigned int moisture_comp_vref2;
115 unsigned int moisture_use_ext_res;
116};
117
118enum {
119 accdet_state000 = 0,
120 accdet_state001,
121 accdet_state010,
122 accdet_state011,
123 accdet_auxadc,
124 eint_state000,
125 eint_state001,
126 eint_state010,
127 eint_state011,
128 eint_inverter_state000,
129};
130
131/* just be called by audio module for DC trim */
132extern void accdet_late_init(unsigned long data);
133extern const struct file_operations *accdet_get_fops(void);
134extern void mt_accdet_suspend(void);
135extern void mt_accdet_resume(void);
136extern void accdet_set_debounce(int state, unsigned int debounce);
137
138#endif