Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: synaptics-rmi4 - fix axis-swap behavior

The documentation for the touchscreen-swapped-x-y property states that
swapping is done after inverting if both are used. RMI4 did it the other
way around, leading to inconsistent behavior with regard to other
touchscreens.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Tested-by: Nick Dyer <nick@shmanahar.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Lucas Stach and committed by
Dmitry Torokhov
645a397d fd629294

+16 -18
+16 -18
drivers/input/rmi4/rmi_2d_sensor.c
··· 32 32 if (obj->type == RMI_2D_OBJECT_NONE) 33 33 return; 34 34 35 - if (axis_align->swap_axes) 36 - swap(obj->x, obj->y); 37 - 38 35 if (axis_align->flip_x) 39 36 obj->x = sensor->max_x - obj->x; 40 37 41 38 if (axis_align->flip_y) 42 39 obj->y = sensor->max_y - obj->y; 40 + 41 + if (axis_align->swap_axes) 42 + swap(obj->x, obj->y); 43 43 44 44 /* 45 45 * Here checking if X offset or y offset are specified is ··· 120 120 x = min(RMI_2D_REL_POS_MAX, max(RMI_2D_REL_POS_MIN, (int)x)); 121 121 y = min(RMI_2D_REL_POS_MAX, max(RMI_2D_REL_POS_MIN, (int)y)); 122 122 123 - if (axis_align->swap_axes) 124 - swap(x, y); 125 - 126 123 if (axis_align->flip_x) 127 124 x = min(RMI_2D_REL_POS_MAX, -x); 128 125 129 126 if (axis_align->flip_y) 130 127 y = min(RMI_2D_REL_POS_MAX, -y); 128 + 129 + if (axis_align->swap_axes) 130 + swap(x, y); 131 131 132 132 if (x || y) { 133 133 input_report_rel(sensor->input, REL_X, x); ··· 141 141 struct input_dev *input = sensor->input; 142 142 int res_x; 143 143 int res_y; 144 + int max_x, max_y; 144 145 int input_flags = 0; 145 146 146 147 if (sensor->report_abs) { 147 - if (sensor->axis_align.swap_axes) { 148 - swap(sensor->max_x, sensor->max_y); 149 - swap(sensor->axis_align.clip_x_low, 150 - sensor->axis_align.clip_y_low); 151 - swap(sensor->axis_align.clip_x_high, 152 - sensor->axis_align.clip_y_high); 153 - } 154 - 155 148 sensor->min_x = sensor->axis_align.clip_x_low; 156 149 if (sensor->axis_align.clip_x_high) 157 150 sensor->max_x = min(sensor->max_x, ··· 156 163 sensor->axis_align.clip_y_high); 157 164 158 165 set_bit(EV_ABS, input->evbit); 159 - input_set_abs_params(input, ABS_MT_POSITION_X, 0, sensor->max_x, 160 - 0, 0); 161 - input_set_abs_params(input, ABS_MT_POSITION_Y, 0, sensor->max_y, 162 - 0, 0); 166 + 167 + max_x = sensor->max_x; 168 + max_y = sensor->max_y; 169 + if (sensor->axis_align.swap_axes) 170 + swap(max_x, max_y); 171 + input_set_abs_params(input, ABS_MT_POSITION_X, 0, max_x, 0, 0); 172 + input_set_abs_params(input, ABS_MT_POSITION_Y, 0, max_y, 0, 0); 163 173 164 174 if (sensor->x_mm && sensor->y_mm) { 165 175 res_x = (sensor->max_x - sensor->min_x) / sensor->x_mm; 166 176 res_y = (sensor->max_y - sensor->min_y) / sensor->y_mm; 177 + if (sensor->axis_align.swap_axes) 178 + swap(res_x, res_y); 167 179 168 180 input_abs_set_res(input, ABS_X, res_x); 169 181 input_abs_set_res(input, ABS_Y, res_y);