summaryrefslogtreecommitdiff
path: root/drivers/input
diff options
context:
space:
mode:
authorMohan Pallaka <mpallaka@codeaurora.org>2013-05-10 15:34:44 +0530
committerGerrit - the friendly Code Review server <code-review@localhost>2016-08-05 08:27:46 -0700
commit3274081bed1a84bab74d1b9462e91530cb910d94 (patch)
tree464d7942c1b1ac20477c06747b92065cc0d1e3fe /drivers/input
parent95c648643d88d524b042961beda59f76254f6d28 (diff)
input: ft5x06_ts: Add support for FB notifications
Add support for FB notifications to trigger suspend/resume based on FB blank/unblank events. Change-Id: I79abc586ad8c14a25afd56559c579a1415df9f0e Signed-off-by: Mohan Pallaka <mpallaka@codeaurora.org> Signed-off-by: Shantanu Jain <shjain@codeaurora.org>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/touchscreen/ft5x06_ts.c48
1 files changed, 42 insertions, 6 deletions
diff --git a/drivers/input/touchscreen/ft5x06_ts.c b/drivers/input/touchscreen/ft5x06_ts.c
index 79aadf4507b9..6cf3be21f042 100644
--- a/drivers/input/touchscreen/ft5x06_ts.c
+++ b/drivers/input/touchscreen/ft5x06_ts.c
@@ -28,7 +28,11 @@
#include <linux/regulator/consumer.h>
#include <linux/input/ft5x06_ts.h>
-#ifdef CONFIG_HAS_EARLYSUSPEND
+#if defined(CONFIG_FB)
+#include <linux/notifier.h>
+#include <linux/fb.h>
+
+#elif defined(CONFIG_HAS_EARLYSUSPEND)
#include <linux/earlysuspend.h>
/* Early-suspend level */
#define FT5X06_SUSPEND_LEVEL 1
@@ -89,7 +93,9 @@ struct ft5x06_ts_data {
const struct ft5x06_ts_platform_data *pdata;
struct regulator *vdd;
struct regulator *vcc_i2c;
-#ifdef CONFIG_HAS_EARLYSUSPEND
+#if defined(CONFIG_FB)
+ struct notifier_block fb_notif;
+#elif defined(CONFIG_HAS_EARLYSUSPEND)
struct early_suspend early_suspend;
#endif
};
@@ -376,7 +382,27 @@ static int ft5x06_ts_resume(struct device *dev)
return 0;
}
-#ifdef CONFIG_HAS_EARLYSUSPEND
+#if defined(CONFIG_FB)
+static int fb_notifier_callback(struct notifier_block *self,
+ unsigned long event, void *data)
+{
+ struct fb_event *evdata = data;
+ int *blank;
+ struct ft5x06_ts_data *ft5x06_data =
+ container_of(self, struct ft5x06_ts_data, fb_notif);
+
+ if (evdata && evdata->data && event == FB_EVENT_BLANK &&
+ ft5x06_data && ft5x06_data->client) {
+ blank = evdata->data;
+ if (*blank == FB_BLANK_UNBLANK)
+ ft5x06_ts_resume(&ft5x06_data->client->dev);
+ else if (*blank == FB_BLANK_POWERDOWN)
+ ft5x06_ts_suspend(&ft5x06_data->client->dev);
+ }
+
+ return 0;
+}
+#elif defined(CONFIG_HAS_EARLYSUSPEND)
static void ft5x06_ts_early_suspend(struct early_suspend *handler)
{
struct ft5x06_ts_data *data = container_of(handler,
@@ -397,7 +423,7 @@ static void ft5x06_ts_late_resume(struct early_suspend *handler)
#endif
static const struct dev_pm_ops ft5x06_ts_pm_ops = {
-#ifndef CONFIG_HAS_EARLYSUSPEND
+#if (!defined(CONFIG_FB) && !defined(CONFIG_HAS_EARLYSUSPEND))
.suspend = ft5x06_ts_suspend,
.resume = ft5x06_ts_resume,
#endif
@@ -689,8 +715,15 @@ static int ft5x06_ts_probe(struct i2c_client *client,
dev_err(&client->dev, "request irq failed\n");
goto free_reset_gpio;
}
+#if defined(CONFIG_FB)
+ data->fb_notif.notifier_call = fb_notifier_callback;
-#ifdef CONFIG_HAS_EARLYSUSPEND
+ err = fb_register_client(&data->fb_notif);
+
+ if (err)
+ dev_err(&client->dev, "Unable to register fb_notifier: %d\n",
+ err);
+#elif defined(CONFIG_HAS_EARLYSUSPEND)
data->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN +
FT5X06_SUSPEND_LEVEL;
data->early_suspend.suspend = ft5x06_ts_early_suspend;
@@ -730,7 +763,10 @@ static int ft5x06_ts_remove(struct i2c_client *client)
{
struct ft5x06_ts_data *data = i2c_get_clientdata(client);
-#ifdef CONFIG_HAS_EARLYSUSPEND
+#if defined(CONFIG_FB)
+ if (fb_unregister_client(&data->fb_notif))
+ dev_err(&client->dev, "Error occurred while unregistering fb_notifier.\n");
+#elif defined(CONFIG_HAS_EARLYSUSPEND)
unregister_early_suspend(&data->early_suspend);
#endif
free_irq(client->irq, data);