1 /*
2 * cyttsp5_mta.c
3 * Parade TrueTouch(TM) Standard Product V5 Multi-Touch Protocol A 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
cyttsp5_final_sync(struct input_dev * input,int max_slots,int mt_sync_count,unsigned long * ids)31 static void cyttsp5_final_sync(struct input_dev *input, int max_slots,
32 int mt_sync_count, unsigned long *ids)
33 {
34 if (mt_sync_count)
35 input_sync(input);
36 }
37
cyttsp5_input_sync(struct input_dev * input)38 static void cyttsp5_input_sync(struct input_dev *input)
39 {
40 input_mt_sync(input);
41 }
42
cyttsp5_input_report(struct input_dev * input,int sig,int t,int type)43 static void cyttsp5_input_report(struct input_dev *input, int sig,
44 int t, int type)
45 {
46 if (type == CY_OBJ_STANDARD_FINGER || type == CY_OBJ_GLOVE
47 || type == CY_OBJ_HOVER) {
48 input_report_key(input, BTN_TOOL_FINGER, CY_BTN_PRESSED);
49 input_report_key(input, BTN_TOOL_PEN, CY_BTN_RELEASED);
50 } else if (type == CY_OBJ_STYLUS) {
51 input_report_key(input, BTN_TOOL_PEN, CY_BTN_PRESSED);
52 input_report_key(input, BTN_TOOL_FINGER, CY_BTN_RELEASED);
53 }
54
55 if (type != CY_OBJ_HOVER)
56 input_report_key(input, BTN_TOUCH, CY_BTN_PRESSED);
57
58 input_report_abs(input, sig, t);
59 }
60
cyttsp5_report_slot_liftoff(struct cyttsp5_mt_data * md,int max_slots)61 static void cyttsp5_report_slot_liftoff(struct cyttsp5_mt_data *md,
62 int max_slots)
63 {
64 input_report_key(md->input, BTN_TOUCH, CY_BTN_RELEASED);
65 input_report_key(md->input, BTN_TOOL_FINGER, CY_BTN_RELEASED);
66 input_report_key(md->input, BTN_TOOL_PEN, CY_BTN_RELEASED);
67
68 }
69
cyttsp5_input_register_device(struct input_dev * input,int max_slots)70 static int cyttsp5_input_register_device(struct input_dev *input, int max_slots)
71 {
72 __set_bit(BTN_TOUCH, input->keybit);
73 __set_bit(BTN_TOOL_FINGER, input->keybit);
74 __set_bit(BTN_TOOL_PEN, input->keybit);
75 return input_register_device(input);
76 }
77
cyttsp5_init_function_ptrs(struct cyttsp5_mt_data * md)78 void cyttsp5_init_function_ptrs(struct cyttsp5_mt_data *md)
79 {
80 md->mt_function.report_slot_liftoff = cyttsp5_report_slot_liftoff;
81 md->mt_function.final_sync = cyttsp5_final_sync;
82 md->mt_function.input_sync = cyttsp5_input_sync;
83 md->mt_function.input_report = cyttsp5_input_report;
84 md->mt_function.input_register_device = cyttsp5_input_register_device;
85 }
86