summaryrefslogtreecommitdiff
path: root/touch/fst2/fts.h
blob: 2efe06ef3868729d1a5343aec8740c6b7e7d9d81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/*
  *
  **************************************************************************
  **                        STMicroelectronics				  **
  **************************************************************************
  *                                                                        *
  * FTS Capacitive touch screen controller (FingerTipS)		           *
  *                                                                        *
  **************************************************************************
  **************************************************************************
  *
  */

/*!
  * \file fts.h
  * \brief Contains all the definitions and structs used generally by the driver
  */

#ifndef _LINUX_FTS_H_
#define _LINUX_FTS_H_

#include <linux/device.h>
#include "fts_lib/fts_io.h"

#if IS_ENABLED(CONFIG_GOOG_TOUCH_INTERFACE)
#include <goog_touch_interface.h>
#endif

#define LOG_PREFIX "[FTS] "

#define LOGD(fmt, args...) \
	pr_debug(LOG_PREFIX fmt, ##args)

#define LOGI(fmt, args...) \
	pr_info(LOG_PREFIX fmt, ##args)

#define LOGW(fmt, args...) \
	pr_warn(LOG_PREFIX fmt, ##args)

#define LOGE(fmt, args...) \
	pr_err(LOG_PREFIX fmt, ##args)

#define FTS_TS_DRV_NAME		"fst2"
#define FTS_TS_DRV_VERSION	"6.0.3"
#define FTS_TS_DRV_VER		0x06000004

#define PINCTRL_STATE_ACTIVE    "pmx_ts_active"
#define PINCTRL_STATE_SUSPEND   "pmx_ts_suspend"
#define PINCTRL_STATE_RELEASE   "pmx_ts_release"

#define MAX_PROBE_RETRY 3
#define MAX_FIFO_EVENT	32 /* /< max number of events that the FIFO can
				 * collect  */
#define EVENT_DATA_SIZE (FIFO_EVENT_SIZE * MAX_FIFO_EVENT) /* /< event data
                                                            * buffer size */
/* **** PANEL SPECIFICATION **** */
#define X_AXIS_MAX	2207	/* /< Max X coordinate of the display */
#define X_AXIS_MIN	0	/* /< min X coordinate of the display */
#define Y_AXIS_MAX	1839	/* /< Max Y coordinate of the display */
#define Y_AXIS_MIN	0	/* /< min Y coordinate of the display */

#define PRESSURE_MIN	0	/* /< min value of pressure reported */
#define PRESSURE_MAX	127	/* /< Max value of pressure reported */

#define DISTANCE_MIN	0	/* /< min distance between the tool and the
				 * display */
#define DISTANCE_MAX	127	/* /< Max distance between the tool and the
				 * display */

#define TOUCH_ID_MAX	10	/* /< Max number of simoultaneous touches
				 * reported */
#define PEN_ID_MAX	4	/* /< Max number of simoultaneous pen
				 * touches reported */

#define ABS_MAJOR_MIN(scale) (PRESSURE_MIN * scale)	/* /< MIN value of
					 * Major axis reported */
#define ABS_MINOR_MIN(scale) (PRESSURE_MIN * scale)	/* /< MIN value of
					 * Minor axis reported */
#define ABS_MAJOR_MAX(scale) (PRESSURE_MAX * scale)	/* /< MAX value of
					 * Major axis reported */
#define ABS_MINOR_MAX(scale) (PRESSURE_MAX * scale)	/* /< MAX value of
					 * Minor axis reported */
/* **** END **** */

/* Touch Types */
#define TOUCH_TYPE_FINGER_HOVER		0x00	/* /< Finger hover */
#define TOUCH_TYPE_FINGER			0x01	/* /< Finger touch */
#define TOUCH_TYPE_GLOVE			0x02	/* /< Glove touch */
#define TOUCH_TYPE_LARGE			0x03	/* /< Large touch */

/*
  * Forward declaration
  */
struct fts_ts_info;

/*
  * Dispatch event handler
  */
typedef void (*event_dispatch_handler_t)
	(struct fts_ts_info *info, unsigned char *data);

/**
  * Struct which contains information about the HW platform and set up
  */
struct fts_hw_platform_data {
	int (*power)(bool on);
	int irq_gpio;
	int reset_gpio;
	struct drm_panel *panel;
	u8 mm2px;
};
/**
  * Struct contains FTS capacitive touch screen device information
  */
struct fts_ts_info {
	struct device            *dev;	/* /< Pointer to the structure device */
#ifdef I2C_INTERFACE
	struct i2c_client        *client;	/* /< I2C client structure */
#else
	struct spi_device        *client;	/* /< SPI client structure */
#endif
	struct fts_hw_platform_data *board;	/* /< HW info retrieved from
						 * device tree */
	struct regulator *vdd_reg;	/* /< DVDD power regulator */
	struct regulator *avdd_reg;	/* /< AVDD power regulator */

	struct pinctrl       *ts_pinctrl;		/* touch pin control state holder */
	struct pinctrl_state *pinctrl_state_active;	/* Active pin state*/
	struct pinctrl_state *pinctrl_state_suspend;	/* Suspend pin state*/
	struct pinctrl_state *pinctrl_state_release;	/* Release pin state*/

	ktime_t timestamp; /* time that the event was first received from the
		touch IC, acquired during hard interrupt, in CLOCK_MONOTONIC */
	struct mutex fts_int_mutex;
	bool irq_enabled;	/* Interrupt state */

	struct input_dev *input_dev; /* /< Input device structure */
#if IS_ENABLED(CONFIG_GOOG_TOUCH_INTERFACE)
	struct goog_touch_interface *gti;
#endif
	event_dispatch_handler_t *event_dispatch_table;
	int resume_bit;	/* /< Indicate if screen off/on */
	unsigned int mode;	/* /< Device operating mode (bitmask: msb
				 * indicate if active or lpm) */
	unsigned long touch_id;	/* /< Bitmask for touch id (mapped to input
				 * slots) */
	bool sensor_sleep;	/* /< if true suspend was called while if false
				 * resume was called */
#ifndef FW_UPDATE_ON_PROBE
	struct delayed_work fwu_work;	/* /< Delayed work thread for fw update
					 * process */
	struct workqueue_struct  *fwu_workqueue;/* /< Fw update work
							 * queue */
#endif
	bool dma_mode;
	unsigned char evt_data[EVENT_DATA_SIZE];
#if IS_ENABLED(CONFIG_GOOG_TOUCH_INTERFACE)
	int16_t *mutual_data;
	int mutual_data_size;
	int16_t *self_data;
	int self_data_size;
	int16_t *fw_ms_data;
#endif
};

extern int fts_proc_init(struct fts_ts_info *info);
extern int fts_proc_remove(void);
int fts_system_reset(struct fts_ts_info *info, int poll_event);
int fts_set_interrupt(struct fts_ts_info *info, bool enable);

#endif