162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (c) 2011-2016 Synaptics Incorporated
462306a36Sopenharmony_ci * Copyright (c) 2011 Unixphere
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#ifndef _RMI_2D_SENSOR_H
862306a36Sopenharmony_ci#define _RMI_2D_SENSOR_H
962306a36Sopenharmony_ci
1062306a36Sopenharmony_cienum rmi_2d_sensor_object_type {
1162306a36Sopenharmony_ci	RMI_2D_OBJECT_NONE,
1262306a36Sopenharmony_ci	RMI_2D_OBJECT_FINGER,
1362306a36Sopenharmony_ci	RMI_2D_OBJECT_STYLUS,
1462306a36Sopenharmony_ci	RMI_2D_OBJECT_PALM,
1562306a36Sopenharmony_ci	RMI_2D_OBJECT_UNCLASSIFIED,
1662306a36Sopenharmony_ci};
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_cistruct rmi_2d_sensor_abs_object {
1962306a36Sopenharmony_ci	enum rmi_2d_sensor_object_type type;
2062306a36Sopenharmony_ci	int mt_tool;
2162306a36Sopenharmony_ci	u16 x;
2262306a36Sopenharmony_ci	u16 y;
2362306a36Sopenharmony_ci	u8 z;
2462306a36Sopenharmony_ci	u8 wx;
2562306a36Sopenharmony_ci	u8 wy;
2662306a36Sopenharmony_ci};
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci/**
2962306a36Sopenharmony_ci * @axis_align - controls parameters that are useful in system prototyping
3062306a36Sopenharmony_ci * and bring up.
3162306a36Sopenharmony_ci * @max_x - The maximum X coordinate that will be reported by this sensor.
3262306a36Sopenharmony_ci * @max_y - The maximum Y coordinate that will be reported by this sensor.
3362306a36Sopenharmony_ci * @nbr_fingers - How many fingers can this sensor report?
3462306a36Sopenharmony_ci * @data_pkt - buffer for data reported by this sensor.
3562306a36Sopenharmony_ci * @pkt_size - number of bytes in that buffer.
3662306a36Sopenharmony_ci * @attn_size - Size of the HID attention report (only contains abs data).
3762306a36Sopenharmony_ci * position when two fingers are on the device.  When this is true, we
3862306a36Sopenharmony_ci * assume we have one of those sensors and report events appropriately.
3962306a36Sopenharmony_ci * @sensor_type - indicates whether we're touchscreen or touchpad.
4062306a36Sopenharmony_ci * @input - input device for absolute pointing stream
4162306a36Sopenharmony_ci * @input_phys - buffer for the absolute phys name for this sensor.
4262306a36Sopenharmony_ci */
4362306a36Sopenharmony_cistruct rmi_2d_sensor {
4462306a36Sopenharmony_ci	struct rmi_2d_axis_alignment axis_align;
4562306a36Sopenharmony_ci	struct input_mt_pos *tracking_pos;
4662306a36Sopenharmony_ci	int *tracking_slots;
4762306a36Sopenharmony_ci	bool kernel_tracking;
4862306a36Sopenharmony_ci	struct rmi_2d_sensor_abs_object *objs;
4962306a36Sopenharmony_ci	int dmax;
5062306a36Sopenharmony_ci	u16 min_x;
5162306a36Sopenharmony_ci	u16 max_x;
5262306a36Sopenharmony_ci	u16 min_y;
5362306a36Sopenharmony_ci	u16 max_y;
5462306a36Sopenharmony_ci	u8 nbr_fingers;
5562306a36Sopenharmony_ci	u8 *data_pkt;
5662306a36Sopenharmony_ci	int pkt_size;
5762306a36Sopenharmony_ci	int attn_size;
5862306a36Sopenharmony_ci	bool topbuttonpad;
5962306a36Sopenharmony_ci	enum rmi_sensor_type sensor_type;
6062306a36Sopenharmony_ci	struct input_dev *input;
6162306a36Sopenharmony_ci	struct rmi_function *fn;
6262306a36Sopenharmony_ci	char input_phys[32];
6362306a36Sopenharmony_ci	u8 report_abs;
6462306a36Sopenharmony_ci	u8 report_rel;
6562306a36Sopenharmony_ci	u8 x_mm;
6662306a36Sopenharmony_ci	u8 y_mm;
6762306a36Sopenharmony_ci	enum rmi_reg_state dribble;
6862306a36Sopenharmony_ci	enum rmi_reg_state palm_detect;
6962306a36Sopenharmony_ci};
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ciint rmi_2d_sensor_of_probe(struct device *dev,
7262306a36Sopenharmony_ci				struct rmi_2d_sensor_platform_data *pdata);
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_civoid rmi_2d_sensor_abs_process(struct rmi_2d_sensor *sensor,
7562306a36Sopenharmony_ci				struct rmi_2d_sensor_abs_object *obj,
7662306a36Sopenharmony_ci				int slot);
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_civoid rmi_2d_sensor_abs_report(struct rmi_2d_sensor *sensor,
7962306a36Sopenharmony_ci				struct rmi_2d_sensor_abs_object *obj,
8062306a36Sopenharmony_ci				int slot);
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_civoid rmi_2d_sensor_rel_report(struct rmi_2d_sensor *sensor, int x, int y);
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ciint rmi_2d_sensor_configure_input(struct rmi_function *fn,
8562306a36Sopenharmony_ci					struct rmi_2d_sensor *sensor);
8662306a36Sopenharmony_ci#endif /* _RMI_2D_SENSOR_H */
87