18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2011-2016 Synaptics Incorporated
48c2ecf20Sopenharmony_ci * Copyright (c) 2011 Unixphere
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef _RMI_2D_SENSOR_H
88c2ecf20Sopenharmony_ci#define _RMI_2D_SENSOR_H
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_cienum rmi_2d_sensor_object_type {
118c2ecf20Sopenharmony_ci	RMI_2D_OBJECT_NONE,
128c2ecf20Sopenharmony_ci	RMI_2D_OBJECT_FINGER,
138c2ecf20Sopenharmony_ci	RMI_2D_OBJECT_STYLUS,
148c2ecf20Sopenharmony_ci	RMI_2D_OBJECT_PALM,
158c2ecf20Sopenharmony_ci	RMI_2D_OBJECT_UNCLASSIFIED,
168c2ecf20Sopenharmony_ci};
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_cistruct rmi_2d_sensor_abs_object {
198c2ecf20Sopenharmony_ci	enum rmi_2d_sensor_object_type type;
208c2ecf20Sopenharmony_ci	int mt_tool;
218c2ecf20Sopenharmony_ci	u16 x;
228c2ecf20Sopenharmony_ci	u16 y;
238c2ecf20Sopenharmony_ci	u8 z;
248c2ecf20Sopenharmony_ci	u8 wx;
258c2ecf20Sopenharmony_ci	u8 wy;
268c2ecf20Sopenharmony_ci};
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci/**
298c2ecf20Sopenharmony_ci * @axis_align - controls parameters that are useful in system prototyping
308c2ecf20Sopenharmony_ci * and bring up.
318c2ecf20Sopenharmony_ci * @max_x - The maximum X coordinate that will be reported by this sensor.
328c2ecf20Sopenharmony_ci * @max_y - The maximum Y coordinate that will be reported by this sensor.
338c2ecf20Sopenharmony_ci * @nbr_fingers - How many fingers can this sensor report?
348c2ecf20Sopenharmony_ci * @data_pkt - buffer for data reported by this sensor.
358c2ecf20Sopenharmony_ci * @pkt_size - number of bytes in that buffer.
368c2ecf20Sopenharmony_ci * @attn_size - Size of the HID attention report (only contains abs data).
378c2ecf20Sopenharmony_ci * position when two fingers are on the device.  When this is true, we
388c2ecf20Sopenharmony_ci * assume we have one of those sensors and report events appropriately.
398c2ecf20Sopenharmony_ci * @sensor_type - indicates whether we're touchscreen or touchpad.
408c2ecf20Sopenharmony_ci * @input - input device for absolute pointing stream
418c2ecf20Sopenharmony_ci * @input_phys - buffer for the absolute phys name for this sensor.
428c2ecf20Sopenharmony_ci */
438c2ecf20Sopenharmony_cistruct rmi_2d_sensor {
448c2ecf20Sopenharmony_ci	struct rmi_2d_axis_alignment axis_align;
458c2ecf20Sopenharmony_ci	struct input_mt_pos *tracking_pos;
468c2ecf20Sopenharmony_ci	int *tracking_slots;
478c2ecf20Sopenharmony_ci	bool kernel_tracking;
488c2ecf20Sopenharmony_ci	struct rmi_2d_sensor_abs_object *objs;
498c2ecf20Sopenharmony_ci	int dmax;
508c2ecf20Sopenharmony_ci	u16 min_x;
518c2ecf20Sopenharmony_ci	u16 max_x;
528c2ecf20Sopenharmony_ci	u16 min_y;
538c2ecf20Sopenharmony_ci	u16 max_y;
548c2ecf20Sopenharmony_ci	u8 nbr_fingers;
558c2ecf20Sopenharmony_ci	u8 *data_pkt;
568c2ecf20Sopenharmony_ci	int pkt_size;
578c2ecf20Sopenharmony_ci	int attn_size;
588c2ecf20Sopenharmony_ci	bool topbuttonpad;
598c2ecf20Sopenharmony_ci	enum rmi_sensor_type sensor_type;
608c2ecf20Sopenharmony_ci	struct input_dev *input;
618c2ecf20Sopenharmony_ci	struct rmi_function *fn;
628c2ecf20Sopenharmony_ci	char input_phys[32];
638c2ecf20Sopenharmony_ci	u8 report_abs;
648c2ecf20Sopenharmony_ci	u8 report_rel;
658c2ecf20Sopenharmony_ci	u8 x_mm;
668c2ecf20Sopenharmony_ci	u8 y_mm;
678c2ecf20Sopenharmony_ci	enum rmi_reg_state dribble;
688c2ecf20Sopenharmony_ci	enum rmi_reg_state palm_detect;
698c2ecf20Sopenharmony_ci};
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ciint rmi_2d_sensor_of_probe(struct device *dev,
728c2ecf20Sopenharmony_ci				struct rmi_2d_sensor_platform_data *pdata);
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_civoid rmi_2d_sensor_abs_process(struct rmi_2d_sensor *sensor,
758c2ecf20Sopenharmony_ci				struct rmi_2d_sensor_abs_object *obj,
768c2ecf20Sopenharmony_ci				int slot);
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_civoid rmi_2d_sensor_abs_report(struct rmi_2d_sensor *sensor,
798c2ecf20Sopenharmony_ci				struct rmi_2d_sensor_abs_object *obj,
808c2ecf20Sopenharmony_ci				int slot);
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_civoid rmi_2d_sensor_rel_report(struct rmi_2d_sensor *sensor, int x, int y);
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ciint rmi_2d_sensor_configure_input(struct rmi_function *fn,
858c2ecf20Sopenharmony_ci					struct rmi_2d_sensor *sensor);
868c2ecf20Sopenharmony_ci#endif /* _RMI_2D_SENSOR_H */
87