input: eeti_egalax_i2c: never report ABS_MT_TOUCH_MAJOR with 0
[firefly-linux-kernel-4.4.55.git] / drivers / input / touchscreen / synaptics_i2c_rmi.c
index e1c3848b3703d784b4195ca7c33a19710d8f673c..5729602cbb63a474c5fa2457d37862e5c9cfb9f5 100644 (file)
@@ -44,6 +44,7 @@ struct synaptics_ts_data {
        int snap_down[2];
        int snap_up[2];
        uint32_t flags;
+       int reported_finger_count;
        int8_t sensitivity_adjust;
        int (*power)(int on);
        struct early_suspend early_suspend;
@@ -205,6 +206,26 @@ static void synaptics_ts_work_func(struct work_struct *work)
                                        input_report_abs(ts->input_dev, ABS_HAT0X, pos[1][0]);
                                        input_report_abs(ts->input_dev, ABS_HAT0Y, pos[1][1]);
                                }
+
+                               if (!finger)
+                                       z = 0;
+                               input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, z);
+                               input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, w);
+                               input_report_abs(ts->input_dev, ABS_MT_POSITION_X, pos[0][0]);
+                               input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, pos[0][1]);
+                               input_mt_sync(ts->input_dev);
+                               if (finger2_pressed) {
+                                       input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, z);
+                                       input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, w);
+                                       input_report_abs(ts->input_dev, ABS_MT_POSITION_X, pos[1][0]);
+                                       input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, pos[1][1]);
+                                       input_mt_sync(ts->input_dev);
+                               } else if (ts->reported_finger_count > 1) {
+                                       input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0);
+                                       input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0);
+                                       input_mt_sync(ts->input_dev);
+                               }
+                               ts->reported_finger_count = finger;
                                input_sync(ts->input_dev);
                        }
                }
@@ -245,6 +266,7 @@ static int synaptics_ts_probe(
        uint16_t max_x, max_y;
        int fuzz_x, fuzz_y, fuzz_p, fuzz_w;
        struct synaptics_i2c_rmi_platform_data *pdata;
+       unsigned long irqflags;
        int inactive_area_left;
        int inactive_area_right;
        int inactive_area_top;
@@ -324,6 +346,7 @@ static int synaptics_ts_probe(
                        pdata++;
                ts->flags = pdata->flags;
                ts->sensitivity_adjust = pdata->sensitivity_adjust;
+               irqflags = pdata->irqflags;
                inactive_area_left = pdata->inactive_left;
                inactive_area_right = pdata->inactive_right;
                inactive_area_top = pdata->inactive_top;
@@ -341,6 +364,7 @@ static int synaptics_ts_probe(
                fuzz_p = pdata->fuzz_p;
                fuzz_w = pdata->fuzz_w;
        } else {
+               irqflags = 0;
                inactive_area_left = 0;
                inactive_area_right = 0;
                inactive_area_top = 0;
@@ -481,6 +505,10 @@ static int synaptics_ts_probe(
        input_set_abs_params(ts->input_dev, ABS_TOOL_WIDTH, 0, 15, fuzz_w, 0);
        input_set_abs_params(ts->input_dev, ABS_HAT0X, -inactive_area_left, max_x + inactive_area_right, fuzz_x, 0);
        input_set_abs_params(ts->input_dev, ABS_HAT0Y, -inactive_area_top, max_y + inactive_area_bottom, fuzz_y, 0);
+       input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X, -inactive_area_left, max_x + inactive_area_right, fuzz_x, 0);
+       input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y, -inactive_area_top, max_y + inactive_area_bottom, fuzz_y, 0);
+       input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, fuzz_p, 0);
+       input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 15, fuzz_w, 0);
        /* ts->input_dev->name = ts->keypad_info->name; */
        ret = input_register_device(ts->input_dev);
        if (ret) {
@@ -488,7 +516,7 @@ static int synaptics_ts_probe(
                goto err_input_register_device_failed;
        }
        if (client->irq) {
-               ret = request_irq(client->irq, synaptics_ts_irq_handler, 0, client->name, ts);
+               ret = request_irq(client->irq, synaptics_ts_irq_handler, irqflags, client->name, ts);
                if (ret == 0) {
                        ret = i2c_smbus_write_byte_data(ts->client, 0xf1, 0x01); /* enable abs int */
                        if (ret)