summaryrefslogtreecommitdiff
path: root/drivers/input/touchscreen/focaltech_touch/focaltech_point_report_check.c
blob: 0fa561748f75f21b67b922f40962116e24f691e5 (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
/*
 *
 * FocalTech TouchScreen driver.
 *
 * Copyright (c) 2010-2016, 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: WangTao
*
*   Created: 2016-11-16
*
*  Abstract: point report check function
*
*   Version: v1.0
*
* Revision History:
*        v1.0:
*            First release. By WangTao 2016-11-16
*****************************************************************************/

/*****************************************************************************
* 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

/*****************************************************************************
* Private enumerations, structures and unions using typedef
*****************************************************************************/

/*****************************************************************************
* Static variables
*****************************************************************************/
static struct delayed_work fts_point_report_check_work;
static struct workqueue_struct *fts_point_report_check_workqueue;

/*****************************************************************************
* Global variable or extern global variabls/functions
*****************************************************************************/

/*****************************************************************************
* Static function prototypes
*****************************************************************************/

/*****************************************************************************
* functions body
*****************************************************************************/

/*****************************************************************************
*  Name: fts_point_report_check_func
*  Brief:
*  Input:
*  Output:
*  Return:
*****************************************************************************/
static void fts_point_report_check_func(struct work_struct *work)
{

#if FTS_MT_PROTOCOL_B_EN
	unsigned int finger_count = 0;

	FTS_FUNC_ENTER();

	for (finger_count = 0; finger_count < FTS_MAX_POINTS; finger_count++) {
		input_mt_slot(fts_input_dev, finger_count);
		input_mt_report_slot_state(fts_input_dev, MT_TOOL_FINGER,
					   false);
	}
#else
	input_mt_sync(fts_input_dev);
#endif
	input_report_key(fts_input_dev, BTN_TOUCH, 0);
	input_sync(fts_input_dev);

	FTS_FUNC_EXIT();
}

void fts_point_report_check_queue_work(void)
{

	cancel_delayed_work(&fts_point_report_check_work);
	queue_delayed_work(fts_point_report_check_workqueue,
			   &fts_point_report_check_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(void)
{
	FTS_FUNC_ENTER();

	INIT_DELAYED_WORK(&fts_point_report_check_work,
			  fts_point_report_check_func);
	fts_point_report_check_workqueue =
	    create_workqueue("fts_point_report_check_func_wq");
	if (fts_point_report_check_workqueue == NULL) {
		FTS_ERROR("[POINT_REPORT]: Failed to create"
				"fts_point_report_check_workqueue!!");
	} else {
		FTS_DEBUG("[POINT_REPORT]: Success to create"
				"fts_point_report_check_workqueue!!");
	}

	FTS_FUNC_EXIT();

	return 0;
}

/*****************************************************************************
*  Name: fts_point_report_check_exit
*  Brief:
*  Input:
*  Output:
*  Return:
*****************************************************************************/
int fts_point_report_check_exit(void)
{
	FTS_FUNC_ENTER();

	destroy_workqueue(fts_point_report_check_workqueue);

	FTS_FUNC_EXIT();
	return 0;
}
#endif /* FTS_POINT_REPORT_CHECK_EN */