OSDN Git Service

goodix_ta: boost fingerprint hal priority when screen is off
authorDemon Singur <demonsingur@gmail.com>
Fri, 4 May 2018 15:29:57 +0000 (15:29 +0000)
committerArian <arian.kulmer@web.de>
Tue, 19 Nov 2019 15:24:31 +0000 (16:24 +0100)
Give fingerprint hal the priority -1 when the screen is off to
speed up fingerprint processing, and then reset its priority back to
normal when the screen is on.

Change-Id: I0e144fdfcef8c96478593a4396a51a431af83989

drivers/input/fingerprint/goodix_ta/gf_spi.c
drivers/input/fingerprint/goodix_ta/gf_spi.h

index 21ef982..537a6c7 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/gpio.h>
 #include <linux/of_gpio.h>
 #include <linux/fb.h>
+#include <linux/sched.h>
 
 #include "gf_spi.h"
 
@@ -135,6 +136,8 @@ static int gf_open(struct inode *inode, struct file *filp)
        struct gf_device *gf_dev = &gf;
        int rc;
 
+       gf_dev->process = current;
+
        /*
         * If this is not the first user, skip hardware configuration.
         */
@@ -221,12 +224,26 @@ static void gf_event_worker(struct work_struct *work)
        struct gf_device *gf_dev = container_of(work, typeof(*gf_dev), event_work);
        char temp[4] = {0x0};
 
+       /*
+        * If no process has opened the char device then no one is
+        * listening for the netlink event.
+        */
+       if (!gf_dev->process)
+               return;
+
        switch (gf_dev->event) {
+       /*
+        * Elevate the fingerprint process priority when screen is off to ensure
+        * the fingerprint sensor is responsive and that the haptic
+        * response on successful verification always fires.
+        */
        case GF_NET_EVENT_FB_BLACK:
                gf_dev->display_on = false;
+               set_user_nice(gf_dev->process, MIN_NICE);
                break;
        case GF_NET_EVENT_FB_UNBLACK:
                gf_dev->display_on = true;
+               set_user_nice(gf_dev->process, 0);
                break;
        /*
         * IRQs are followed by fingerprint procesing, hold a wakelock to make
@@ -292,6 +309,7 @@ static int gf_probe(struct platform_device *pdev)
        int major;
        int rc = 0;
 
+       gf_dev->process = NULL;
        gf_dev->display_on = true;
        gf_dev->irq_enabled = false;
 
index bdaa812..0b78e27 100644 (file)
@@ -56,6 +56,8 @@ struct gf_device {
 
        unsigned users;
        int irq;
+
+       struct task_struct *process;
 };
 
 void sendnlmsg(char *message);