hc
2023-03-21 4b55d97acc464242bcd6a8ae77b8ff37c22dec58
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
/*
 *
 * FocalTech TouchScreen driver.
 *
 * Copyright (c) 2012-2018, FocalTech Systems, Ltd., all rights reserved.
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * 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.
 *
 */
 
/*****************************************************************************
*
* File Name: focaltech_point_report_check.c
*
* Author: Focaltech Driver Team
*
* Created: 2016-11-16
*
* Abstract: point report check function
*
* Version: v1.0
*
* Revision History:
*
*****************************************************************************/
 
/*****************************************************************************
* Included header files
*****************************************************************************/
#include "focaltech_core.h"
 
#if FTS_POINT_REPORT_CHECK_EN
/*****************************************************************************
* Private constant and macro definitions using #define
*****************************************************************************/
#define POINT_REPORT_CHECK_WAIT_TIME              200    /* unit:ms */
 
/*****************************************************************************
* functions body
*****************************************************************************/
/*****************************************************************************
*  Name: fts_prc_func
*  Brief: fts point report check work func, report whole up of points
*  Input:
*  Output:
*  Return:
*****************************************************************************/
static void fts_prc_func(struct work_struct *work)
{
    struct fts_ts_data *ts_data = container_of(work,
                                  struct fts_ts_data, prc_work.work);
    struct input_dev *input_dev = ts_data->input_dev;
 
#if FTS_MT_PROTOCOL_B_EN
    u32 finger_count = 0;
#endif
 
    FTS_FUNC_ENTER();
    mutex_lock(&ts_data->report_mutex);
 
#if FTS_MT_PROTOCOL_B_EN
    for (finger_count = 0; finger_count < ts_data->pdata->max_touch_number; finger_count++) {
        input_mt_slot(input_dev, finger_count);
        input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, false);
    }
#else
    input_mt_sync(input_dev);
#endif
    input_report_key(input_dev, BTN_TOUCH, 0);
    input_sync(input_dev);
 
    mutex_unlock(&ts_data->report_mutex);
 
    FTS_FUNC_EXIT();
}
 
/*****************************************************************************
*  Name: fts_prc_queue_work
*  Brief: fts point report check queue work, call it when interrupt comes
*  Input:
*  Output:
*  Return:
*****************************************************************************/
void fts_prc_queue_work(struct fts_ts_data *ts_data)
{
    cancel_delayed_work(&ts_data->prc_work);
    queue_delayed_work(ts_data->ts_workqueue, &ts_data->prc_work,
                       msecs_to_jiffies(POINT_REPORT_CHECK_WAIT_TIME));
}
 
/*****************************************************************************
*  Name: fts_point_report_check_init
*  Brief:
*  Input:
*  Output:
*  Return: < 0: Fail to create esd check queue
*****************************************************************************/
int fts_point_report_check_init(struct fts_ts_data *ts_data)
{
    FTS_FUNC_ENTER();
 
    if (ts_data->ts_workqueue) {
        INIT_DELAYED_WORK(&ts_data->prc_work, fts_prc_func);
    } else {
        FTS_ERROR("fts workqueue is NULL, can't run point report check function");
        return -EINVAL;
    }
 
    FTS_FUNC_EXIT();
    return 0;
}
 
/*****************************************************************************
*  Name: fts_point_report_check_exit
*  Brief:
*  Input:
*  Output:
*  Return:
*****************************************************************************/
int fts_point_report_check_exit(struct fts_ts_data *ts_data)
{
    FTS_FUNC_ENTER();
 
    FTS_FUNC_EXIT();
    return 0;
}
#endif /* FTS_POINT_REPORT_CHECK_EN */