summaryrefslogtreecommitdiff
path: root/bsp/x1000/drivers/touch/focaltech_ts.h
blob: 7a4622d911b8fad998233c5c4fea3b15b2224560 (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
/*
 * File      : focaltech_ts.h
 * This file is part of RT-Thread RTOS
 * COPYRIGHT (C) 2006 - 2017, RT-Thread Development Team
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Change Logs:
 * Date           Author       Notes
 * 2017-01-01     Urey      first version
 */
#ifndef _FOCALTECH_TS_H_
#define _FOCALTECH_TS_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>

/* -- dirver configure -- */
#define FTS_SLAVE_ADDR                      (0x70 >> 1)
#define CFG_MAX_TOUCH_POINTS                10
#define FTS_PRESS_MAX                       0xFF
#define FTS_PRESS                           0x08
#define FTS_NAME                            "FTS"
#define FTS_INPUT_DEV_NAME                  "focal-touchscreen"
#define FTS_MAX_ID                          0x0F
#define FTS_TOUCH_STEP                      6
#define FTS_TOUCH_X_H_POS                   3
#define FTS_TOUCH_X_L_POS                   4
#define FTS_TOUCH_Y_H_POS                   5
#define FTS_TOUCH_Y_L_POS                   6
#define FTS_TOUCH_XY_POS                    7
#define FTS_TOUCH_MISC                      8
#define FTS_TOUCH_EVENT_POS                 3
#define FTS_TOUCH_ID_POS                    5
#define FT_TOUCH_POINT_NUM                  2
#define POINT_READ_BUF                      (3 + FTS_TOUCH_STEP * CFG_MAX_TOUCH_POINTS)

/*register address*/
#define FTS_REG_CHIP_ID                     0xA3    //chip ID
#define FTS_REG_FW_VER                      0xA6
#define FTS_REG_POINT_RATE                  0x88
#define FTS_REG_THGROUP                     0x80
#define FTS_REG_VENDOR_ID                   0xA8

#define FTS_ENABLE_IRQ                      1
#define FTS_DISABLE_IRQ                     0
#define TPD_MAX_POINTS_2                    2
#define TPD_MAX_POINTS_5                    5
#define TPD_MAXPOINTS_10                    10
#define AUTO_CLB_NEED                       1
#define AUTO_CLB_NONEED                     0

#define TOUCH_SWAP_XY           1
#define TOUCH_SWAP_X            0
#define TOUCH_SWAP_Y            1

struct Upgrade_Info
{
    uint8_t  CHIP_ID;
    uint8_t  FTS_NAME_INFO[20];
    uint8_t  TPD_MAX_POINTS;
    uint8_t  AUTO_CLB;
    uint16_t delay_aa; /*delay of write FTS_UPGRADE_AA */
    uint16_t delay_55; /*delay of write FTS_UPGRADE_55 */
    uint8_t  upgrade_id_1; /*upgrade id 1 */
    uint8_t  upgrade_id_2; /*upgrade id 2 */
    uint16_t delay_readid; /*delay of read id */
    uint16_t delay_earse_flash; /*delay of earse flash*/
};

/* The platform data for the Focaltech focaltech touchscreen driver */
struct fts_platform_data
{
    uint32_t gpio_irq;                                                  /* IRQ port*/
    uint32_t irq_cfg;
    uint32_t gpio_wakeup;                                           /* Wakeup support*/
    uint32_t wakeup_cfg;
    uint32_t gpio_reset;                                                /* Reset support*/
    uint32_t reset_cfg;
    int screen_max_x;
    int screen_max_y;
    int pressure_max;
};

struct fts_event
{
    uint16_t au16_x[CFG_MAX_TOUCH_POINTS];                            /*x coordinate */
    uint16_t au16_y[CFG_MAX_TOUCH_POINTS];                            /*y coordinate */
    uint8_t  au8_touch_event[CFG_MAX_TOUCH_POINTS];                   /*touch event:0 -- down; 1-- contact; 2 -- contact */
    uint8_t  au8_finger_id[CFG_MAX_TOUCH_POINTS];                     /*touch ID */
    uint8_t  au8_finger_weight[CFG_MAX_TOUCH_POINTS];                 /*touch weight */
    uint8_t  pressure[CFG_MAX_TOUCH_POINTS];
    uint8_t  area[CFG_MAX_TOUCH_POINTS];
    uint8_t  touch_point;
    uint8_t  touch_point_num;
};

struct focal_i2c_platform_data
{
    uint16_t version;
    int abs_x_min;
    int abs_x_max;
    int abs_y_min;
    int abs_y_max;
    int intr_gpio;
    int rst_gpio;
};

struct fts_ts_data
{
    uint8_t  addr;
    uint8_t  fw_ver;     //firmware version
    uint32_t x_min,x_max;
    uint32_t y_min,y_max;
    uint32_t init_success;
    struct fts_event event;

    struct rt_i2c_bus_device *i2c_bus;
    struct rt_semaphore     sem;
    int touchs;
};

void fts_ts_interrupt_cb(struct fts_ts_data *fts_ts);
int  fts_ts_probe(struct fts_ts_data *fts_ts,struct rt_i2c_bus_device *i2c_bus, const uint8_t addr);

#ifdef __cplusplus
}
#endif

#endif /* _FOCALTECH_TS_H_ */