123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- diff -Naurp a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
- --- a/drivers/input/touchscreen/atmel_mxt_ts.c 2018-01-20 11:42:13.000000000 +0100
- +++ b/drivers/input/touchscreen/atmel_mxt_ts.c 2018-01-25 09:03:33.876115406 +0100
- @@ -24,6 +24,7 @@
- #include <linux/i2c.h>
- #include <linux/platform_data/atmel_mxt_ts.h>
- #include <linux/input/mt.h>
- +#include <linux/input/touchscreen.h>
- #include <linux/interrupt.h>
- #include <linux/of.h>
- #include <linux/slab.h>
- @@ -216,6 +217,9 @@ struct mxt_data {
- unsigned int irq;
- unsigned int max_x;
- unsigned int max_y;
- + bool invert_x;
- + bool invert_y;
- + bool swap_x_y;
- bool xy_switch;
- bool in_bootloader;
- u16 mem_size;
- @@ -257,6 +261,22 @@ struct mxt_data {
- struct completion crc_completion;
- };
-
- +static void mxt_apply_prop_to_x_y(const struct mxt_data *data,
- + int *x, int *y)
- +{
- + if (data->invert_x)
- + *x = data->max_x - *x;
- +
- + if (data->invert_y)
- + *y = data->max_y - *y;
- +
- + if (data->swap_x_y)
- + swap(*x, *y);
- +}
- +
- +
- +
- +
- static size_t mxt_obj_size(const struct mxt_object *obj)
- {
- return obj->size_minus_one + 1;
- @@ -741,6 +761,8 @@ static void mxt_proc_t9_message(struct m
-
- /* Touch active */
- input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, 1);
- + mxt_apply_prop_to_x_y(data, &x, &y);
- +
- input_report_abs(input_dev, ABS_MT_POSITION_X, x);
- input_report_abs(input_dev, ABS_MT_POSITION_Y, y);
- input_report_abs(input_dev, ABS_MT_PRESSURE, amplitude);
- @@ -760,8 +782,8 @@ static void mxt_proc_t100_message(struct
- int id;
- u8 status;
- u8 type = 0;
- - u16 x;
- - u16 y;
- + /*u16*/ int x;
- + /*u16*/ int y;
- int distance = 0;
- int tool = 0;
- u8 major = 0;
- @@ -845,6 +867,7 @@ static void mxt_proc_t100_message(struct
- id, type, x, y, major, pressure, orientation);
-
- input_mt_report_slot_state(input_dev, tool, 1);
- + mxt_apply_prop_to_x_y(data, &x, &y);
- input_report_abs(input_dev, ABS_MT_POSITION_X, x);
- input_report_abs(input_dev, ABS_MT_POSITION_Y, y);
- input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, major);
- @@ -1778,7 +1801,8 @@ static int mxt_initialize_input_device(s
- int error;
- unsigned int num_mt_slots;
- unsigned int mt_flags = 0;
- -
- + struct device_node *np = dev->of_node;
- +
- switch (data->multitouch) {
- case MXT_TOUCH_MULTI_T9:
- num_mt_slots = data->T9_reportid_max - data->T9_reportid_min + 1;
- @@ -1818,6 +1842,7 @@ static int mxt_initialize_input_device(s
- return -ENOMEM;
- }
-
- +
- input_dev->name = "Atmel maXTouch Touchscreen";
- input_dev->phys = data->phys;
- input_dev->id.bustype = BUS_I2C;
- @@ -1908,6 +1933,17 @@ static int mxt_initialize_input_device(s
-
- data->input_dev = input_dev;
-
- + if (np) {
- + data->invert_x = of_property_read_bool(np, "invert_x")?1:0;
- + data->invert_y = of_property_read_bool(np, "invert_y")?1:0;
- + data->swap_x_y = of_property_read_bool(np, "swap_x_y")?1:0;
- +
- + dev_info(dev, "loaded toucscreen properties\n");
- + dev_info(dev, "touchscreen-inverted-x %d\n", data->invert_x);
- + dev_info(dev, "touchscreen-inverted-y %d\n", data->invert_y);
- + dev_info(dev, "touchscreen-swap-x-y %d\n", data->swap_x_y);
- + }
- +
- return 0;
-
- err_free_mem:
|