Commit cc5117d6 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Dmitry Torokhov

Input: of_touchscreen - explicitly choose axis

The 'axis + 1' calculation is implicit and potentially error prone.
Moreover, few lines before the axis is set explicitly for both X and Y.

Do the same when retrieving different properties for X and Y.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20200303180917.12563-1-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent b9a1c116
...@@ -66,7 +66,7 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch, ...@@ -66,7 +66,7 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch,
{ {
struct device *dev = input->dev.parent; struct device *dev = input->dev.parent;
struct input_absinfo *absinfo; struct input_absinfo *absinfo;
unsigned int axis; unsigned int axis, axis_x, axis_y;
unsigned int minimum, maximum, fuzz; unsigned int minimum, maximum, fuzz;
bool data_present; bool data_present;
...@@ -74,33 +74,34 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch, ...@@ -74,33 +74,34 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch,
if (!input->absinfo) if (!input->absinfo)
return; return;
axis = multitouch ? ABS_MT_POSITION_X : ABS_X; axis_x = multitouch ? ABS_MT_POSITION_X : ABS_X;
axis_y = multitouch ? ABS_MT_POSITION_Y : ABS_Y;
data_present = touchscreen_get_prop_u32(dev, "touchscreen-min-x", data_present = touchscreen_get_prop_u32(dev, "touchscreen-min-x",
input_abs_get_min(input, axis), input_abs_get_min(input, axis_x),
&minimum) | &minimum) |
touchscreen_get_prop_u32(dev, "touchscreen-size-x", touchscreen_get_prop_u32(dev, "touchscreen-size-x",
input_abs_get_max(input, input_abs_get_max(input,
axis) + 1, axis_x) + 1,
&maximum) | &maximum) |
touchscreen_get_prop_u32(dev, "touchscreen-fuzz-x", touchscreen_get_prop_u32(dev, "touchscreen-fuzz-x",
input_abs_get_fuzz(input, axis), input_abs_get_fuzz(input, axis_x),
&fuzz); &fuzz);
if (data_present) if (data_present)
touchscreen_set_params(input, axis, minimum, maximum - 1, fuzz); touchscreen_set_params(input, axis_x, minimum, maximum - 1, fuzz);
axis = multitouch ? ABS_MT_POSITION_Y : ABS_Y;
data_present = touchscreen_get_prop_u32(dev, "touchscreen-min-y", data_present = touchscreen_get_prop_u32(dev, "touchscreen-min-y",
input_abs_get_min(input, axis), input_abs_get_min(input, axis_y),
&minimum) | &minimum) |
touchscreen_get_prop_u32(dev, "touchscreen-size-y", touchscreen_get_prop_u32(dev, "touchscreen-size-y",
input_abs_get_max(input, input_abs_get_max(input,
axis) + 1, axis_y) + 1,
&maximum) | &maximum) |
touchscreen_get_prop_u32(dev, "touchscreen-fuzz-y", touchscreen_get_prop_u32(dev, "touchscreen-fuzz-y",
input_abs_get_fuzz(input, axis), input_abs_get_fuzz(input, axis_y),
&fuzz); &fuzz);
if (data_present) if (data_present)
touchscreen_set_params(input, axis, minimum, maximum - 1, fuzz); touchscreen_set_params(input, axis_y, minimum, maximum - 1, fuzz);
axis = multitouch ? ABS_MT_PRESSURE : ABS_PRESSURE; axis = multitouch ? ABS_MT_PRESSURE : ABS_PRESSURE;
data_present = touchscreen_get_prop_u32(dev, data_present = touchscreen_get_prop_u32(dev,
...@@ -117,15 +118,13 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch, ...@@ -117,15 +118,13 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch,
if (!prop) if (!prop)
return; return;
axis = multitouch ? ABS_MT_POSITION_X : ABS_X; prop->max_x = input_abs_get_max(input, axis_x);
prop->max_y = input_abs_get_max(input, axis_y);
prop->max_x = input_abs_get_max(input, axis);
prop->max_y = input_abs_get_max(input, axis + 1);
prop->invert_x = prop->invert_x =
device_property_read_bool(dev, "touchscreen-inverted-x"); device_property_read_bool(dev, "touchscreen-inverted-x");
if (prop->invert_x) { if (prop->invert_x) {
absinfo = &input->absinfo[axis]; absinfo = &input->absinfo[axis_x];
absinfo->maximum -= absinfo->minimum; absinfo->maximum -= absinfo->minimum;
absinfo->minimum = 0; absinfo->minimum = 0;
} }
...@@ -133,7 +132,7 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch, ...@@ -133,7 +132,7 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch,
prop->invert_y = prop->invert_y =
device_property_read_bool(dev, "touchscreen-inverted-y"); device_property_read_bool(dev, "touchscreen-inverted-y");
if (prop->invert_y) { if (prop->invert_y) {
absinfo = &input->absinfo[axis + 1]; absinfo = &input->absinfo[axis_y];
absinfo->maximum -= absinfo->minimum; absinfo->maximum -= absinfo->minimum;
absinfo->minimum = 0; absinfo->minimum = 0;
} }
...@@ -141,7 +140,7 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch, ...@@ -141,7 +140,7 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch,
prop->swap_x_y = prop->swap_x_y =
device_property_read_bool(dev, "touchscreen-swapped-x-y"); device_property_read_bool(dev, "touchscreen-swapped-x-y");
if (prop->swap_x_y) if (prop->swap_x_y)
swap(input->absinfo[axis], input->absinfo[axis + 1]); swap(input->absinfo[axis_x], input->absinfo[axis_y]);
} }
EXPORT_SYMBOL(touchscreen_parse_properties); EXPORT_SYMBOL(touchscreen_parse_properties);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment