1 /*
2 * cyttsp5_mtb.c
3 * Parade TrueTouch(TM) Standard Product V5 Multi-Touch Protocol B Module.
4 * For use with Parade touchscreen controllers.
5 * Supported parts include:
6 * CYTMA5XX
7 * CYTMA448
8 * CYTMA445A
9 * CYTT21XXX
10 * CYTT31XXX
11 *
12 * Copyright (C) 2015 Parade Technologies
13 * Copyright (C) 2012-2015 Cypress Semiconductor
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * version 2, and only version 2, as published by the
18 * Free Software Foundation.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * Contact Parade Technologies at www.paradetech.com <ttdrivers@paradetech.com>
26 *
27 */
28
29 #include "cyttsp5_regs.h"
30 #include <linux/input/mt.h>
31 #include <linux/version.h>
32
cyttsp5_final_sync(struct input_dev * input,int max_slots,int mt_sync_count,unsigned long * ids)33 static void cyttsp5_final_sync(struct input_dev *input, int max_slots,
34 int mt_sync_count, unsigned long *ids)
35 {
36 int t;
37
38 for (t = 0; t < max_slots; t++) {
39 if (test_bit(t, ids))
40 continue;
41 input_mt_slot(input, t);
42 input_mt_report_slot_state(input, MT_TOOL_FINGER, false);
43 }
44
45 input_sync(input);
46 }
47
cyttsp5_input_report(struct input_dev * input,int sig,int t,int type)48 static void cyttsp5_input_report(struct input_dev *input, int sig,
49 int t, int type)
50 {
51 input_mt_slot(input, t);
52
53 if (type == CY_OBJ_STANDARD_FINGER || type == CY_OBJ_GLOVE
54 || type == CY_OBJ_HOVER)
55 input_mt_report_slot_state(input, MT_TOOL_FINGER, true);
56 else if (type == CY_OBJ_STYLUS)
57 input_mt_report_slot_state(input, MT_TOOL_PEN, true);
58 }
59
cyttsp5_report_slot_liftoff(struct cyttsp5_mt_data * md,int max_slots)60 static void cyttsp5_report_slot_liftoff(struct cyttsp5_mt_data *md,
61 int max_slots)
62 {
63 int t;
64
65 if (md->num_prv_rec == 0)
66 return;
67
68 for (t = 0; t < max_slots; t++) {
69 input_mt_slot(md->input, t);
70 input_mt_report_slot_state(md->input,
71 MT_TOOL_FINGER, false);
72 }
73 }
74
cyttsp5_input_register_device(struct input_dev * input,int max_slots)75 static int cyttsp5_input_register_device(struct input_dev *input, int max_slots)
76 {
77 #if (KERNEL_VERSION(3, 7, 0) <= LINUX_VERSION_CODE)
78 input_mt_init_slots(input, max_slots, 0);
79 #else
80 input_mt_init_slots(input, max_slots);
81 #endif
82 return input_register_device(input);
83 }
84
cyttsp5_init_function_ptrs(struct cyttsp5_mt_data * md)85 void cyttsp5_init_function_ptrs(struct cyttsp5_mt_data *md)
86 {
87 md->mt_function.report_slot_liftoff = cyttsp5_report_slot_liftoff;
88 md->mt_function.final_sync = cyttsp5_final_sync;
89 md->mt_function.input_sync = NULL;
90 md->mt_function.input_report = cyttsp5_input_report;
91 md->mt_function.input_register_device = cyttsp5_input_register_device;
92 }
93
94