1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef TOUCH_FT5406_H
10 #define TOUCH_FT5406_H
11 
12 #define FTS_REG_IDX_MAX    3
13 
14 /* register address */
15 #define FTS_REG_FW_VER          0xA6    // FW version
16 #define FTS_REG_FW_MIN_VER      0xB2    // FW min version
17 #define FTS_REG_FW_SUB_MIN_VER  0xB3    // FW sub min version
18 #define FTS_REG_STATUS          0x02
19 #define FTS_REG_X_H             0x03
20 
21 /* the config for parsing event buffer */
22 #define HALF_BYTE_MASK     0x0F
23 #define HALF_BYTE_OFFSET   4
24 #define SIX_BIT_OFFSET     6
25 #define ONE_BYTE_OFFSET    8
26 
27 /* the FT5406 driver ic can support 5 points,
28  * use 2 points default.
29  */
30 #define MAX_SUPPORT_POINT 5
31 
32 /* buffer size of one event */
33 #define FT_POINT_SIZE     6
34 
35 /* read data buffer len
36  * each point info occupy 6 bytes.
37  */
38 #define POINT_BUFFER_LEN (FT_POINT_SIZE)
39 
40 /* point data position, base on TD_STATUS */
41 #define FT_POINT_NUM_POS  2
42 #define FT_EVENT_POS      0
43 #define FT_X_H_POS        0
44 #define FT_X_L_POS        1
45 #define FT_Y_H_POS        2
46 #define FT_FINGER_POS     2
47 #define FT_Y_L_POS        3
48 
49 #define KEY_CODE_4TH      3
50 
51 #define POLL_INTERVAL_MS  17 /* 17ms = 60fps */
52 
53 typedef struct {
54     void *data;
55     struct timer_list timer;
56     struct work_struct work_poll;
57 } FT5406TouchData;
58 #endif