input: sec_ts: bind input_open/close to display state
authorJesse Chan <jc@lineageos.org>
Tue, 17 Apr 2018 23:53:13 +0000 (16:53 -0700)
committerivanmeler <i_ivan@windowslive.com>
Thu, 5 May 2022 06:14:59 +0000 (06:14 +0000)
drivers/input/input.c
drivers/input/touchscreen/sec_ts/sec_ts.c
drivers/input/touchscreen/sec_ts/sec_ts.h
drivers/input/touchscreen/sec_ts_y661/sec_ts.c
drivers/input/touchscreen/sec_ts_y661/sec_ts.h

index 05540dcfa3879d7cc0acf95f38559ba36336d073..a3d19a432f1e0e2b67833aa1c4f3ab708c4cd5d6 100644 (file)
@@ -1107,7 +1107,7 @@ void input_close_device(struct input_handle *handle)
        mutex_unlock(&dev->mutex);
 }
 EXPORT_SYMBOL(input_close_device);
-static int input_enable_device(struct input_dev *dev)
+int input_enable_device(struct input_dev *dev)
 {
        int retval;
 
@@ -1132,7 +1132,7 @@ out:
        return retval;
 }
 
-static int input_disable_device(struct input_dev *dev)
+int input_disable_device(struct input_dev *dev)
 {
        int retval;
 
index f7b27625526a50e87774cbb742eda6724c856437..cf497af934818a755044ec458a39ae8843153684 100644 (file)
@@ -43,6 +43,13 @@ extern void epen_disable_mode(int mode);
 #endif
 #endif
 
+#if defined(CONFIG_FB)
+static int touch_fb_notifier_callback(struct notifier_block *self,
+               unsigned long event, void *data);
+extern int input_enable_device(struct input_dev *dev);
+extern int input_disable_device(struct input_dev *dev);
+#endif
+
 int sec_ts_read_information(struct sec_ts_data *ts);
 
 #ifdef CONFIG_SECURE_TOUCH
@@ -2347,6 +2354,16 @@ static int sec_ts_probe(struct i2c_client *client, const struct i2c_device_id *i
                        __func__, client->irq);
 #endif
 
+#ifdef CONFIG_FB
+       ts->fb_notif.notifier_call = touch_fb_notifier_callback;
+       ret = fb_register_client(&ts->fb_notif);
+       if (ret < 0) {
+               input_err(true, &ts->client->dev, "%s: Failed to register fb client\n",
+                       __func__);
+               goto err_fb_client;
+       }
+#endif
+
        /* need remove below resource @ remove driver */
 #if !defined(CONFIG_SAMSUNG_PRODUCT_SHIP)
        sec_ts_raw_device_init(ts);
@@ -2393,6 +2410,11 @@ static int sec_ts_probe(struct i2c_client *client, const struct i2c_device_id *i
        sec_ts_fn_remove(ts);
        free_irq(client->irq, ts);
 #endif
+#ifdef CONFIG_FB
+       fb_unregister_client(&ts->fb_notif);
+
+err_fb_client:
+#endif
 err_irq:
        if (ts->plat_data->support_dex) {
                input_unregister_device(ts->input_dev_pad);
@@ -2832,6 +2854,12 @@ static int sec_ts_remove(struct i2c_client *client)
 
        input_info(true, &ts->client->dev, "%s\n", __func__);
 
+#if defined(CONFIG_FB)
+       if (fb_unregister_client(&ts->fb_notif))
+               input_info(true, &ts->client->dev,
+                       "%s: Error occured while unregistering fb_notifier.\n", __func__);
+#endif
+
        cancel_delayed_work_sync(&ts->work_read_info);
        flush_delayed_work(&ts->work_read_info);
 
@@ -3073,6 +3101,27 @@ static int sec_ts_pm_resume(struct device *dev)
 
        return 0;
 }
+
+#if defined(CONFIG_FB)
+static int touch_fb_notifier_callback(struct notifier_block *self,
+               unsigned long event, void *data)
+{
+       struct sec_ts_data *ts =
+               container_of(self, struct sec_ts_data, fb_notif);
+       struct fb_event *ev = (struct fb_event *)data;
+
+       if (ev && ev->data && event == FB_EVENT_BLANK) {
+               int *blank = (int *)ev->data;
+
+               if (*blank == FB_BLANK_UNBLANK)
+                       input_enable_device(ts->input_dev);
+               else
+                       input_disable_device(ts->input_dev);
+       }
+
+       return 0;
+}
+#endif
 #endif
 
 #ifdef CONFIG_TRUSTONIC_TRUSTED_UI
index b9219343a7ac6b69c8987456a56b61753b97c062..d090462654a4fe78040cce32bb517da4723efa80 100644 (file)
 #include <linux/vmalloc.h>
 #include <linux/wakelock.h>
 
+#if defined(CONFIG_FB)
+#include <linux/notifier.h>
+#include <linux/fb.h>
+#endif
+
 #if defined(CONFIG_TRUSTONIC_TRUSTED_UI)
 #include <linux/t-base-tui.h>
 #endif
@@ -676,6 +681,10 @@ struct sec_ts_data {
        volatile u8 touch_noise_status;
        volatile bool input_closed;
 
+#if defined(CONFIG_FB)
+       struct notifier_block fb_notif;
+#endif
+
        int touch_count;
        int tx_count;
        int rx_count;
index 597419bed5251f2b48da6ed3d468e0f753d8c98d..00e833222b2bd060fd47787b41479d910e5c75b3 100644 (file)
@@ -39,6 +39,13 @@ static void sec_ts_input_close(struct input_dev *dev);
 extern void epen_disable_mode(int mode);
 #endif
 
+#if defined(CONFIG_FB)
+static int touch_fb_notifier_callback(struct notifier_block *self,
+               unsigned long event, void *data);
+extern int input_enable_device(struct input_dev *dev);
+extern int input_disable_device(struct input_dev *dev);
+#endif
+
 int sec_ts_read_information(struct sec_ts_data *ts);
 
 #ifdef CONFIG_SECURE_TOUCH
@@ -2336,6 +2343,16 @@ static int sec_ts_probe(struct i2c_client *client, const struct i2c_device_id *i
                        __func__, client->irq);
 #endif
 
+#ifdef CONFIG_FB
+       ts->fb_notif.notifier_call = touch_fb_notifier_callback;
+       ret = fb_register_client(&ts->fb_notif);
+       if (ret < 0) {
+               input_err(true, &ts->client->dev, "%s: Failed to register fb client\n",
+                       __func__);
+               goto err_fb_client;
+       }
+#endif
+
        /* need remove below resource @ remove driver */
 #if !defined(CONFIG_SAMSUNG_PRODUCT_SHIP)
        sec_ts_raw_device_init(ts);
@@ -2382,6 +2399,11 @@ static int sec_ts_probe(struct i2c_client *client, const struct i2c_device_id *i
        sec_ts_fn_remove(ts);
        free_irq(client->irq, ts);
 #endif
+#ifdef CONFIG_FB
+       fb_unregister_client(&ts->fb_notif);
+
+err_fb_client:
+#endif
 err_irq:
        if (ts->plat_data->support_dex) {
                input_unregister_device(ts->input_dev_pad);
@@ -2813,6 +2835,12 @@ static int sec_ts_remove(struct i2c_client *client)
 
        input_info(true, &ts->client->dev, "%s\n", __func__);
 
+#if defined(CONFIG_FB)
+       if (fb_unregister_client(&ts->fb_notif))
+               input_info(true, &ts->client->dev,
+                       "%s: Error occured while unregistering fb_notifier.\n", __func__);
+#endif
+
        cancel_delayed_work_sync(&ts->work_read_info);
        flush_delayed_work(&ts->work_read_info);
 
@@ -3054,6 +3082,27 @@ static int sec_ts_pm_resume(struct device *dev)
 
        return 0;
 }
+
+#if defined(CONFIG_FB)
+static int touch_fb_notifier_callback(struct notifier_block *self,
+               unsigned long event, void *data)
+{
+       struct sec_ts_data *ts =
+               container_of(self, struct sec_ts_data, fb_notif);
+       struct fb_event *ev = (struct fb_event *)data;
+
+       if (ev && ev->data && event == FB_EVENT_BLANK) {
+               int *blank = (int *)ev->data;
+
+               if (*blank == FB_BLANK_UNBLANK)
+                       input_enable_device(ts->input_dev);
+               else
+                       input_disable_device(ts->input_dev);
+       }
+
+       return 0;
+}
+#endif
 #endif
 
 #ifdef CONFIG_TRUSTONIC_TRUSTED_UI
index b7a946ee4c9121b1177e9e51d5b0e05163ed9bde..c2488afd86ed94d9a79ac36c25ec59f061723f2f 100644 (file)
 #include <linux/wakelock.h>
 #include <linux/workqueue.h>
 
+#if defined(CONFIG_FB)
+#include <linux/notifier.h>
+#include <linux/fb.h>
+#endif
+
 #if defined(CONFIG_TRUSTONIC_TRUSTED_UI)
 #include <linux/t-base-tui.h>
 #endif
@@ -677,6 +682,10 @@ struct sec_ts_data {
        volatile u8 touch_noise_status;
        volatile bool input_closed;
 
+#if defined(CONFIG_FB)
+       struct notifier_block fb_notif;
+#endif
+
        int touch_count;
        int tx_count;
        int rx_count;