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