Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
[firefly-linux-kernel-4.4.55.git] / drivers / hid / hid-rmi.c
index e2a43a1d3aa3ab1fefc8559422c5dfb164ed5ef4..368ffdf2c0a3af086d9242f00476f598a3fffdf9 100644 (file)
@@ -751,6 +751,8 @@ static int rmi_populate_f11(struct hid_device *hdev)
        bool has_gestures;
        bool has_rel;
        bool has_data40 = false;
+       bool has_dribble = false;
+       bool has_palm_detect = false;
        unsigned x_size, y_size;
        u16 query_offset;
 
@@ -792,6 +794,14 @@ static int rmi_populate_f11(struct hid_device *hdev)
        has_rel = !!(buf[0] & BIT(3));
        has_gestures = !!(buf[0] & BIT(5));
 
+       ret = rmi_read(hdev, data->f11.query_base_addr + 5, buf);
+       if (ret) {
+               hid_err(hdev, "can not get absolute data sources: %d.\n", ret);
+               return ret;
+       }
+
+       has_dribble = !!(buf[0] & BIT(4));
+
        /*
         * At least 4 queries are guaranteed to be present in F11
         * +1 for query 5 which is present since absolute events are
@@ -811,6 +821,7 @@ static int rmi_populate_f11(struct hid_device *hdev)
                                ret);
                        return ret;
                }
+               has_palm_detect = !!(buf[0] & BIT(0));
                has_query10 = !!(buf[0] & BIT(2));
 
                query_offset += 2; /* query 7 and 8 are present */
@@ -897,17 +908,38 @@ static int rmi_populate_f11(struct hid_device *hdev)
         * retrieve the ctrl registers
         * the ctrl register has a size of 20 but a fw bug split it into 16 + 4,
         * and there is no way to know if the first 20 bytes are here or not.
-        * We use only the first 10 bytes, so get only them.
+        * We use only the first 12 bytes, so get only them.
         */
-       ret = rmi_read_block(hdev, data->f11.control_base_addr, buf, 10);
+       ret = rmi_read_block(hdev, data->f11.control_base_addr, buf, 12);
        if (ret) {
-               hid_err(hdev, "can not read ctrl block of size 10: %d.\n", ret);
+               hid_err(hdev, "can not read ctrl block of size 11: %d.\n", ret);
                return ret;
        }
 
        data->max_x = buf[6] | (buf[7] << 8);
        data->max_y = buf[8] | (buf[9] << 8);
 
+       if (has_dribble) {
+               buf[0] = buf[0] & ~BIT(6);
+               ret = rmi_write(hdev, data->f11.control_base_addr, buf);
+               if (ret) {
+                       hid_err(hdev, "can not write to control reg 0: %d.\n",
+                               ret);
+                       return ret;
+               }
+       }
+
+       if (has_palm_detect) {
+               buf[11] = buf[11] & ~BIT(0);
+               ret = rmi_write(hdev, data->f11.control_base_addr + 11,
+                               &buf[11]);
+               if (ret) {
+                       hid_err(hdev, "can not write to control reg 11: %d.\n",
+                               ret);
+                       return ret;
+               }
+       }
+
        return 0;
 }