xref: /linux/drivers/input/rmi4/rmi_2d_sensor.h (revision aaa27982b3bcc3cce6a1d835673adccd75903a2e)
1ff8f8370SAndrew Duggan /*
2ff8f8370SAndrew Duggan  * Copyright (c) 2011-2016 Synaptics Incorporated
3ff8f8370SAndrew Duggan  * Copyright (c) 2011 Unixphere
4ff8f8370SAndrew Duggan  *
5ff8f8370SAndrew Duggan  * This program is free software; you can redistribute it and/or modify it
6ff8f8370SAndrew Duggan  * under the terms of the GNU General Public License version 2 as published by
7ff8f8370SAndrew Duggan  * the Free Software Foundation.
8ff8f8370SAndrew Duggan  */
9ff8f8370SAndrew Duggan 
10ff8f8370SAndrew Duggan #ifndef _RMI_2D_SENSOR_H
11ff8f8370SAndrew Duggan #define _RMI_2D_SENSOR_H
12ff8f8370SAndrew Duggan 
13ff8f8370SAndrew Duggan enum rmi_2d_sensor_object_type {
14ff8f8370SAndrew Duggan 	RMI_2D_OBJECT_NONE,
15ff8f8370SAndrew Duggan 	RMI_2D_OBJECT_FINGER,
16ff8f8370SAndrew Duggan 	RMI_2D_OBJECT_STYLUS,
17ff8f8370SAndrew Duggan 	RMI_2D_OBJECT_PALM,
18ff8f8370SAndrew Duggan 	RMI_2D_OBJECT_UNCLASSIFIED,
19ff8f8370SAndrew Duggan };
20ff8f8370SAndrew Duggan 
21ff8f8370SAndrew Duggan struct rmi_2d_sensor_abs_object {
22ff8f8370SAndrew Duggan 	enum rmi_2d_sensor_object_type type;
23ff8f8370SAndrew Duggan 	int mt_tool;
24ff8f8370SAndrew Duggan 	u16 x;
25ff8f8370SAndrew Duggan 	u16 y;
26ff8f8370SAndrew Duggan 	u8 z;
27ff8f8370SAndrew Duggan 	u8 wx;
28ff8f8370SAndrew Duggan 	u8 wy;
29ff8f8370SAndrew Duggan };
30ff8f8370SAndrew Duggan 
31ff8f8370SAndrew Duggan /**
32ff8f8370SAndrew Duggan  * @axis_align - controls parameters that are useful in system prototyping
33ff8f8370SAndrew Duggan  * and bring up.
34ff8f8370SAndrew Duggan  * @max_x - The maximum X coordinate that will be reported by this sensor.
35ff8f8370SAndrew Duggan  * @max_y - The maximum Y coordinate that will be reported by this sensor.
36ff8f8370SAndrew Duggan  * @nbr_fingers - How many fingers can this sensor report?
37ff8f8370SAndrew Duggan  * @data_pkt - buffer for data reported by this sensor.
38ff8f8370SAndrew Duggan  * @pkt_size - number of bytes in that buffer.
39ff8f8370SAndrew Duggan  * @attn_size - Size of the HID attention report (only contains abs data).
40ff8f8370SAndrew Duggan  * position when two fingers are on the device.  When this is true, we
41ff8f8370SAndrew Duggan  * assume we have one of those sensors and report events appropriately.
42ff8f8370SAndrew Duggan  * @sensor_type - indicates whether we're touchscreen or touchpad.
43ff8f8370SAndrew Duggan  * @input - input device for absolute pointing stream
44ff8f8370SAndrew Duggan  * @input_phys - buffer for the absolute phys name for this sensor.
45ff8f8370SAndrew Duggan  */
46ff8f8370SAndrew Duggan struct rmi_2d_sensor {
47ff8f8370SAndrew Duggan 	struct rmi_2d_axis_alignment axis_align;
48ff8f8370SAndrew Duggan 	struct input_mt_pos *tracking_pos;
49ff8f8370SAndrew Duggan 	int *tracking_slots;
50ff8f8370SAndrew Duggan 	bool kernel_tracking;
51ff8f8370SAndrew Duggan 	struct rmi_2d_sensor_abs_object *objs;
52ff8f8370SAndrew Duggan 	int dmax;
53ff8f8370SAndrew Duggan 	u16 min_x;
54ff8f8370SAndrew Duggan 	u16 max_x;
55ff8f8370SAndrew Duggan 	u16 min_y;
56ff8f8370SAndrew Duggan 	u16 max_y;
57ff8f8370SAndrew Duggan 	u8 nbr_fingers;
58ff8f8370SAndrew Duggan 	u8 *data_pkt;
59ff8f8370SAndrew Duggan 	int pkt_size;
60ff8f8370SAndrew Duggan 	int attn_size;
61ff8f8370SAndrew Duggan 	bool topbuttonpad;
62ff8f8370SAndrew Duggan 	enum rmi_sensor_type sensor_type;
63ff8f8370SAndrew Duggan 	struct input_dev *input;
64ff8f8370SAndrew Duggan 	struct rmi_function *fn;
65ff8f8370SAndrew Duggan 	char input_phys[32];
66ff8f8370SAndrew Duggan 	u8 report_abs;
67ff8f8370SAndrew Duggan 	u8 report_rel;
68ff8f8370SAndrew Duggan 	u8 x_mm;
69ff8f8370SAndrew Duggan 	u8 y_mm;
70ff8f8370SAndrew Duggan };
71ff8f8370SAndrew Duggan 
72*aaa27982SAndrew Duggan int rmi_2d_sensor_of_probe(struct device *dev,
73*aaa27982SAndrew Duggan 				struct rmi_2d_sensor_platform_data *pdata);
74*aaa27982SAndrew Duggan 
75ff8f8370SAndrew Duggan void rmi_2d_sensor_abs_process(struct rmi_2d_sensor *sensor,
76ff8f8370SAndrew Duggan 				struct rmi_2d_sensor_abs_object *obj,
77ff8f8370SAndrew Duggan 				int slot);
78ff8f8370SAndrew Duggan 
79ff8f8370SAndrew Duggan void rmi_2d_sensor_abs_report(struct rmi_2d_sensor *sensor,
80ff8f8370SAndrew Duggan 				struct rmi_2d_sensor_abs_object *obj,
81ff8f8370SAndrew Duggan 				int slot);
82ff8f8370SAndrew Duggan 
83ff8f8370SAndrew Duggan void rmi_2d_sensor_rel_report(struct rmi_2d_sensor *sensor, int x, int y);
84ff8f8370SAndrew Duggan 
85ff8f8370SAndrew Duggan int rmi_2d_sensor_configure_input(struct rmi_function *fn,
86ff8f8370SAndrew Duggan 					struct rmi_2d_sensor *sensor);
87ff8f8370SAndrew Duggan #endif /* _RMI_2D_SENSOR_H */
88