hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
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
/*
 * cyttsp5_mta.c
 * Parade TrueTouch(TM) Standard Product V5 Multi-Touch Protocol A Module.
 * For use with Parade touchscreen controllers.
 * Supported parts include:
 * CYTMA5XX
 * CYTMA448
 * CYTMA445A
 * CYTT21XXX
 * CYTT31XXX
 *
 * Copyright (C) 2015 Parade Technologies
 * Copyright (C) 2012-2015 Cypress Semiconductor
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2, and only version 2, as published by the
 * Free Software Foundation.
 *
 * 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.
 *
 * Contact Parade Technologies at www.paradetech.com <ttdrivers@paradetech.com>
 *
 */
 
#include "cyttsp5_regs.h"
 
static void cyttsp5_final_sync(struct input_dev *input, int max_slots,
       int mt_sync_count, unsigned long *ids)
{
   if (mt_sync_count)
       input_sync(input);
}
 
static void cyttsp5_input_sync(struct input_dev *input)
{
   input_mt_sync(input);
}
 
static void cyttsp5_input_report(struct input_dev *input, int sig,
       int t, int type)
{
   if (type == CY_OBJ_STANDARD_FINGER || type == CY_OBJ_GLOVE
           || type == CY_OBJ_HOVER) {
       input_report_key(input, BTN_TOOL_FINGER, CY_BTN_PRESSED);
       input_report_key(input, BTN_TOOL_PEN, CY_BTN_RELEASED);
   } else if (type == CY_OBJ_STYLUS) {
       input_report_key(input, BTN_TOOL_PEN, CY_BTN_PRESSED);
       input_report_key(input, BTN_TOOL_FINGER, CY_BTN_RELEASED);
   }
 
   if (type != CY_OBJ_HOVER)
       input_report_key(input, BTN_TOUCH, CY_BTN_PRESSED);
 
   input_report_abs(input, sig, t);
}
 
static void cyttsp5_report_slot_liftoff(struct cyttsp5_mt_data *md,
       int max_slots)
{
   input_report_key(md->input, BTN_TOUCH, CY_BTN_RELEASED);
   input_report_key(md->input, BTN_TOOL_FINGER, CY_BTN_RELEASED);
   input_report_key(md->input, BTN_TOOL_PEN, CY_BTN_RELEASED);
 
}
 
static int cyttsp5_input_register_device(struct input_dev *input, int max_slots)
{
   __set_bit(BTN_TOUCH, input->keybit);
   __set_bit(BTN_TOOL_FINGER, input->keybit);
   __set_bit(BTN_TOOL_PEN, input->keybit);
   return input_register_device(input);
}
 
void cyttsp5_init_function_ptrs(struct cyttsp5_mt_data *md)
{
   md->mt_function.report_slot_liftoff = cyttsp5_report_slot_liftoff;
   md->mt_function.final_sync = cyttsp5_final_sync;
   md->mt_function.input_sync = cyttsp5_input_sync;
   md->mt_function.input_report = cyttsp5_input_report;
   md->mt_function.input_register_device = cyttsp5_input_register_device;
}