Lines Matching +full:x +full:- +full:y

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2011-2016 Synaptics Incorporated
16 #define RMI_2D_REL_POS_MIN -128
26 struct rmi_2d_axis_alignment *axis_align = &sensor->axis_align; in rmi_2d_sensor_abs_process()
29 if (obj->type == RMI_2D_OBJECT_NONE) in rmi_2d_sensor_abs_process()
32 if (axis_align->flip_x) in rmi_2d_sensor_abs_process()
33 obj->x = sensor->max_x - obj->x; in rmi_2d_sensor_abs_process()
35 if (axis_align->flip_y) in rmi_2d_sensor_abs_process()
36 obj->y = sensor->max_y - obj->y; in rmi_2d_sensor_abs_process()
38 if (axis_align->swap_axes) in rmi_2d_sensor_abs_process()
39 swap(obj->x, obj->y); in rmi_2d_sensor_abs_process()
42 * Here checking if X offset or y offset are specified is in rmi_2d_sensor_abs_process()
49 obj->x += axis_align->offset_x; in rmi_2d_sensor_abs_process()
50 obj->y += axis_align->offset_y; in rmi_2d_sensor_abs_process()
52 obj->x = max(axis_align->clip_x_low, obj->x); in rmi_2d_sensor_abs_process()
53 obj->y = max(axis_align->clip_y_low, obj->y); in rmi_2d_sensor_abs_process()
55 if (axis_align->clip_x_high) in rmi_2d_sensor_abs_process()
56 obj->x = min(sensor->max_x, obj->x); in rmi_2d_sensor_abs_process()
58 if (axis_align->clip_y_high) in rmi_2d_sensor_abs_process()
59 obj->y = min(sensor->max_y, obj->y); in rmi_2d_sensor_abs_process()
61 sensor->tracking_pos[slot].x = obj->x; in rmi_2d_sensor_abs_process()
62 sensor->tracking_pos[slot].y = obj->y; in rmi_2d_sensor_abs_process()
70 struct rmi_2d_axis_alignment *axis_align = &sensor->axis_align; in rmi_2d_sensor_abs_report()
71 struct input_dev *input = sensor->input; in rmi_2d_sensor_abs_report()
74 if (sensor->kernel_tracking) in rmi_2d_sensor_abs_report()
75 input_mt_slot(input, sensor->tracking_slots[slot]); in rmi_2d_sensor_abs_report()
79 input_mt_report_slot_state(input, obj->mt_tool, in rmi_2d_sensor_abs_report()
80 obj->type != RMI_2D_OBJECT_NONE); in rmi_2d_sensor_abs_report()
82 if (obj->type != RMI_2D_OBJECT_NONE) { in rmi_2d_sensor_abs_report()
83 obj->x = sensor->tracking_pos[slot].x; in rmi_2d_sensor_abs_report()
84 obj->y = sensor->tracking_pos[slot].y; in rmi_2d_sensor_abs_report()
86 if (axis_align->swap_axes) in rmi_2d_sensor_abs_report()
87 swap(obj->wx, obj->wy); in rmi_2d_sensor_abs_report()
89 wide = (obj->wx > obj->wy); in rmi_2d_sensor_abs_report()
90 major = max(obj->wx, obj->wy); in rmi_2d_sensor_abs_report()
91 minor = min(obj->wx, obj->wy); in rmi_2d_sensor_abs_report()
93 if (obj->type == RMI_2D_OBJECT_STYLUS) { in rmi_2d_sensor_abs_report()
98 input_event(sensor->input, EV_ABS, ABS_MT_POSITION_X, obj->x); in rmi_2d_sensor_abs_report()
99 input_event(sensor->input, EV_ABS, ABS_MT_POSITION_Y, obj->y); in rmi_2d_sensor_abs_report()
100 input_event(sensor->input, EV_ABS, ABS_MT_ORIENTATION, wide); in rmi_2d_sensor_abs_report()
101 input_event(sensor->input, EV_ABS, ABS_MT_PRESSURE, obj->z); in rmi_2d_sensor_abs_report()
102 input_event(sensor->input, EV_ABS, ABS_MT_TOUCH_MAJOR, major); in rmi_2d_sensor_abs_report()
103 input_event(sensor->input, EV_ABS, ABS_MT_TOUCH_MINOR, minor); in rmi_2d_sensor_abs_report()
105 rmi_dbg(RMI_DEBUG_2D_SENSOR, &sensor->input->dev, in rmi_2d_sensor_abs_report()
106 "%s: obj[%d]: type: 0x%02x X: %d Y: %d Z: %d WX: %d WY: %d\n", in rmi_2d_sensor_abs_report()
107 __func__, slot, obj->type, obj->x, obj->y, obj->z, in rmi_2d_sensor_abs_report()
108 obj->wx, obj->wy); in rmi_2d_sensor_abs_report()
113 void rmi_2d_sensor_rel_report(struct rmi_2d_sensor *sensor, int x, int y) in rmi_2d_sensor_rel_report() argument
115 struct rmi_2d_axis_alignment *axis_align = &sensor->axis_align; in rmi_2d_sensor_rel_report()
117 x = min(RMI_2D_REL_POS_MAX, max(RMI_2D_REL_POS_MIN, (int)x)); in rmi_2d_sensor_rel_report()
118 y = min(RMI_2D_REL_POS_MAX, max(RMI_2D_REL_POS_MIN, (int)y)); in rmi_2d_sensor_rel_report()
120 if (axis_align->flip_x) in rmi_2d_sensor_rel_report()
121 x = min(RMI_2D_REL_POS_MAX, -x); in rmi_2d_sensor_rel_report()
123 if (axis_align->flip_y) in rmi_2d_sensor_rel_report()
124 y = min(RMI_2D_REL_POS_MAX, -y); in rmi_2d_sensor_rel_report()
126 if (axis_align->swap_axes) in rmi_2d_sensor_rel_report()
127 swap(x, y); in rmi_2d_sensor_rel_report()
129 if (x || y) { in rmi_2d_sensor_rel_report()
130 input_report_rel(sensor->input, REL_X, x); in rmi_2d_sensor_rel_report()
131 input_report_rel(sensor->input, REL_Y, y); in rmi_2d_sensor_rel_report()
138 struct input_dev *input = sensor->input; in rmi_2d_sensor_set_input_params()
144 if (sensor->report_abs) { in rmi_2d_sensor_set_input_params()
145 sensor->min_x = sensor->axis_align.clip_x_low; in rmi_2d_sensor_set_input_params()
146 if (sensor->axis_align.clip_x_high) in rmi_2d_sensor_set_input_params()
147 sensor->max_x = min(sensor->max_x, in rmi_2d_sensor_set_input_params()
148 sensor->axis_align.clip_x_high); in rmi_2d_sensor_set_input_params()
150 sensor->min_y = sensor->axis_align.clip_y_low; in rmi_2d_sensor_set_input_params()
151 if (sensor->axis_align.clip_y_high) in rmi_2d_sensor_set_input_params()
152 sensor->max_y = min(sensor->max_y, in rmi_2d_sensor_set_input_params()
153 sensor->axis_align.clip_y_high); in rmi_2d_sensor_set_input_params()
155 set_bit(EV_ABS, input->evbit); in rmi_2d_sensor_set_input_params()
157 max_x = sensor->max_x; in rmi_2d_sensor_set_input_params()
158 max_y = sensor->max_y; in rmi_2d_sensor_set_input_params()
159 if (sensor->axis_align.swap_axes) in rmi_2d_sensor_set_input_params()
164 if (sensor->x_mm && sensor->y_mm) { in rmi_2d_sensor_set_input_params()
165 res_x = (sensor->max_x - sensor->min_x) / sensor->x_mm; in rmi_2d_sensor_set_input_params()
166 res_y = (sensor->max_y - sensor->min_y) / sensor->y_mm; in rmi_2d_sensor_set_input_params()
167 if (sensor->axis_align.swap_axes) in rmi_2d_sensor_set_input_params()
176 if (!sensor->dmax) in rmi_2d_sensor_set_input_params()
177 sensor->dmax = DMAX * res_x; in rmi_2d_sensor_set_input_params()
187 if (sensor->sensor_type == rmi_sensor_touchpad) in rmi_2d_sensor_set_input_params()
192 if (sensor->kernel_tracking) in rmi_2d_sensor_set_input_params()
195 input_mt_init_slots(input, sensor->nbr_fingers, input_flags); in rmi_2d_sensor_set_input_params()
198 if (sensor->report_rel) { in rmi_2d_sensor_set_input_params()
199 set_bit(EV_REL, input->evbit); in rmi_2d_sensor_set_input_params()
200 set_bit(REL_X, input->relbit); in rmi_2d_sensor_set_input_params()
201 set_bit(REL_Y, input->relbit); in rmi_2d_sensor_set_input_params()
204 if (sensor->topbuttonpad) in rmi_2d_sensor_set_input_params()
205 set_bit(INPUT_PROP_TOPBUTTONPAD, input->propbit); in rmi_2d_sensor_set_input_params()
211 struct rmi_device *rmi_dev = fn->rmi_dev; in rmi_2d_sensor_configure_input()
212 struct rmi_driver_data *drv_data = dev_get_drvdata(&rmi_dev->dev); in rmi_2d_sensor_configure_input()
214 if (!drv_data->input) in rmi_2d_sensor_configure_input()
215 return -ENODEV; in rmi_2d_sensor_configure_input()
217 sensor->input = drv_data->input; in rmi_2d_sensor_configure_input()
231 pdata->axis_align.swap_axes = of_property_read_bool(dev->of_node, in rmi_2d_sensor_of_probe()
232 "touchscreen-swapped-x-y"); in rmi_2d_sensor_of_probe()
234 pdata->axis_align.flip_x = of_property_read_bool(dev->of_node, in rmi_2d_sensor_of_probe()
235 "touchscreen-inverted-x"); in rmi_2d_sensor_of_probe()
237 pdata->axis_align.flip_y = of_property_read_bool(dev->of_node, in rmi_2d_sensor_of_probe()
238 "touchscreen-inverted-y"); in rmi_2d_sensor_of_probe()
240 retval = rmi_of_property_read_u32(dev, &val, "syna,clip-x-low", 1); in rmi_2d_sensor_of_probe()
244 pdata->axis_align.clip_x_low = val; in rmi_2d_sensor_of_probe()
246 retval = rmi_of_property_read_u32(dev, &val, "syna,clip-y-low", 1); in rmi_2d_sensor_of_probe()
250 pdata->axis_align.clip_y_low = val; in rmi_2d_sensor_of_probe()
252 retval = rmi_of_property_read_u32(dev, &val, "syna,clip-x-high", 1); in rmi_2d_sensor_of_probe()
256 pdata->axis_align.clip_x_high = val; in rmi_2d_sensor_of_probe()
258 retval = rmi_of_property_read_u32(dev, &val, "syna,clip-y-high", 1); in rmi_2d_sensor_of_probe()
262 pdata->axis_align.clip_y_high = val; in rmi_2d_sensor_of_probe()
264 retval = rmi_of_property_read_u32(dev, &val, "syna,offset-x", 1); in rmi_2d_sensor_of_probe()
268 pdata->axis_align.offset_x = val; in rmi_2d_sensor_of_probe()
270 retval = rmi_of_property_read_u32(dev, &val, "syna,offset-y", 1); in rmi_2d_sensor_of_probe()
274 pdata->axis_align.offset_y = val; in rmi_2d_sensor_of_probe()
276 retval = rmi_of_property_read_u32(dev, &val, "syna,delta-x-threshold", in rmi_2d_sensor_of_probe()
281 pdata->axis_align.delta_x_threshold = val; in rmi_2d_sensor_of_probe()
283 retval = rmi_of_property_read_u32(dev, &val, "syna,delta-y-threshold", in rmi_2d_sensor_of_probe()
288 pdata->axis_align.delta_y_threshold = val; in rmi_2d_sensor_of_probe()
290 retval = rmi_of_property_read_u32(dev, (u32 *)&pdata->sensor_type, in rmi_2d_sensor_of_probe()
291 "syna,sensor-type", 1); in rmi_2d_sensor_of_probe()
295 retval = rmi_of_property_read_u32(dev, &val, "touchscreen-x-mm", 1); in rmi_2d_sensor_of_probe()
299 pdata->x_mm = val; in rmi_2d_sensor_of_probe()
301 retval = rmi_of_property_read_u32(dev, &val, "touchscreen-y-mm", 1); in rmi_2d_sensor_of_probe()
305 pdata->y_mm = val; in rmi_2d_sensor_of_probe()
308 "syna,disable-report-mask", 1); in rmi_2d_sensor_of_probe()
312 pdata->disable_report_mask = val; in rmi_2d_sensor_of_probe()
314 retval = rmi_of_property_read_u32(dev, &val, "syna,rezero-wait-ms", in rmi_2d_sensor_of_probe()
319 pdata->rezero_wait = val; in rmi_2d_sensor_of_probe()
327 return -ENODEV; in rmi_2d_sensor_of_probe()