]> git.karo-electronics.de Git - linux-beck.git/commitdiff
Input: synaptics-rmi4 - stop scanning PDT after two empty pages
authorNick Dyer <nick@shmanahar.org>
Tue, 8 Nov 2016 01:33:07 +0000 (17:33 -0800)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Wed, 9 Nov 2016 00:23:21 +0000 (16:23 -0800)
We have encountered some RMI4 firmwares where there are blank pages in
between PDT pages which contain functions. This change makes them
correctly enumerate all functions on the device.

Tested on S7817 (has empty page 2).

Signed-off-by: Nick Dyer <nick@shmanahar.org>
[Tested successfully on S7817 and S7300 Synaptics touch controllers]
Tested-by: Chris Healy <cphealy@gmail.com>
Reviewed-by: Andrew Duggan <aduggan@synaptics.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/rmi4/rmi_driver.c

index c83bce89028b2a2d270ffa3aed232788b8b491b6..81e20f1f7ec3a941a09fbf278e06e5e5b7e683fe 100644 (file)
@@ -423,6 +423,7 @@ static void rmi_driver_copy_pdt_to_fd(const struct pdt_entry *pdt,
 
 static int rmi_scan_pdt_page(struct rmi_device *rmi_dev,
                             int page,
+                            int *empty_pages,
                             void *ctx,
                             int (*callback)(struct rmi_device *rmi_dev,
                                             void *ctx,
@@ -450,7 +451,16 @@ static int rmi_scan_pdt_page(struct rmi_device *rmi_dev,
                        return retval;
        }
 
-       return (data->f01_bootloader_mode || addr == pdt_start) ?
+       /*
+        * Count number of empty PDT pages. If a gap of two pages
+        * or more is found, stop scanning.
+        */
+       if (addr == pdt_start)
+               ++*empty_pages;
+       else
+               *empty_pages = 0;
+
+       return (data->f01_bootloader_mode || *empty_pages >= 2) ?
                                        RMI_SCAN_DONE : RMI_SCAN_CONTINUE;
 }
 
@@ -460,10 +470,12 @@ static int rmi_scan_pdt(struct rmi_device *rmi_dev, void *ctx,
                                        const struct pdt_entry *entry))
 {
        int page;
+       int empty_pages = 0;
        int retval = RMI_SCAN_DONE;
 
        for (page = 0; page <= RMI4_MAX_PAGE; page++) {
-               retval = rmi_scan_pdt_page(rmi_dev, page, ctx, callback);
+               retval = rmi_scan_pdt_page(rmi_dev, page, &empty_pages,
+                                          ctx, callback);
                if (retval != RMI_SCAN_CONTINUE)
                        break;
        }