From b30cf6743b028d0f74355a1af75212781da73f5e Mon Sep 17 00:00:00 2001 From: haojl2 Date: Thu, 24 Oct 2019 18:10:14 +0800 Subject: [PATCH] goodix_gtx8_v1430_mmi: support DRM notification chain TP: In new qcom platform, LCD send notification though DRM chain, not fb. Register DRM notification chain for TP suspend/resume. Change-Id: Ib34bc796553cc3aa3411788de88049296f0a9bd7 Signed-off-by: haojl2 Reviewed-on: https://gerrit.mot.com/1442728 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Konstantin Makariev Submit-Approved: Jira Key --- .../goodix_gtx8_v1430_mmi/goodix_ts_core.c | 43 +++++++++++++++++-- .../goodix_gtx8_v1430_mmi/goodix_ts_core.h | 5 ++- .../goodix_gtx8_v1430_mmi/goodix_ts_i2c.c | 5 +++ 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/drivers/input/touchscreen/goodix_gtx8_v1430_mmi/goodix_ts_core.c b/drivers/input/touchscreen/goodix_gtx8_v1430_mmi/goodix_ts_core.c index c6e7d288285f..f1a22a5e0508 100644 --- a/drivers/input/touchscreen/goodix_gtx8_v1430_mmi/goodix_ts_core.c +++ b/drivers/input/touchscreen/goodix_gtx8_v1430_mmi/goodix_ts_core.c @@ -1902,7 +1902,37 @@ out: return 0; } -#ifdef CONFIG_FB +#if defined(CONFIG_DRM) +int goodix_ts_fb_notifier_callback(struct notifier_block *self, + unsigned long event, void *data) +{ + struct goodix_ts_core *core_data = + container_of(self, struct goodix_ts_core, fb_notifier); + struct goodix_ts_board_data *ts_bdata = board_data(core_data); + struct msm_drm_notifier *evdata = data; + + if (!evdata || (evdata->id != ts_bdata->ctrl_dsi)) + return 0; + + ts_info("Notifier's event = %ld", event); + if ((event == MSM_DRM_EARLY_EVENT_BLANK || event == MSM_DRM_EVENT_BLANK) && + evdata && evdata->data && core_data) { + int *blank = evdata->data; + pr_debug("drm notification: event = %lu blank = %d\n", event, *blank); + if (event == MSM_DRM_EARLY_EVENT_BLANK) { + if (*blank != MSM_DRM_BLANK_POWERDOWN) + return 0; + ts_info("TP Suspend"); + goodix_ts_suspend(core_data); + } else if (*blank == MSM_DRM_BLANK_UNBLANK) { + ts_info("TP Resume"); + goodix_ts_resume(core_data); + } + } + + return 0; +} +#elif defined(CONFIG_FB) /** * goodix_ts_fb_notifier_callback - Framebuffer notifier callback * Called by kernel during framebuffer blanck/unblank phrase @@ -2049,7 +2079,14 @@ int goodix_ts_stage2_init(struct goodix_ts_core *core_data) } ts_info("success register irq"); -#ifdef CONFIG_FB +#ifdef CONFIG_DRM + core_data->fb_notifier.notifier_call = goodix_ts_fb_notifier_callback; + if (!msm_drm_register_client(&core_data->fb_notifier)) + ts_info("registered DRM notifier"); + else + ts_err("%s: Unable to register DRM notifier", + __func__); +#elif defined(CONFIG_FB) core_data->fb_notifier.notifier_call = goodix_ts_fb_notifier_callback; if (fb_register_client(&core_data->fb_notifier)) ts_err("Failed to register fb notifier client:%d", r); @@ -2177,7 +2214,7 @@ static int goodix_ts_remove(struct platform_device *pdev) #ifdef CONFIG_PM static const struct dev_pm_ops dev_pm_ops = { -#if !defined(CONFIG_FB) && !defined(CONFIG_HAS_EARLYSUSPEND) +#if !defined(CONFIG_FB) && !defined(CONFIG_DRM) && !defined(CONFIG_HAS_EARLYSUSPEND) .suspend = goodix_ts_pm_suspend, .resume = goodix_ts_pm_resume, #endif diff --git a/drivers/input/touchscreen/goodix_gtx8_v1430_mmi/goodix_ts_core.h b/drivers/input/touchscreen/goodix_gtx8_v1430_mmi/goodix_ts_core.h index ac6af18cf48e..4a3f71b0da3f 100644 --- a/drivers/input/touchscreen/goodix_gtx8_v1430_mmi/goodix_ts_core.h +++ b/drivers/input/touchscreen/goodix_gtx8_v1430_mmi/goodix_ts_core.h @@ -44,7 +44,9 @@ #ifdef CONFIG_HAS_EARLYSUSPEND #include #endif -#ifdef CONFIG_FB +#ifdef CONFIG_DRM +#include +#elif defined(CONFIG_FB) #include #include #endif @@ -116,6 +118,7 @@ struct goodix_ts_board_data { unsigned int reset_gpio; unsigned int irq_gpio; int irq; + int ctrl_dsi; unsigned int irq_flags; unsigned int power_on_delay_us; diff --git a/drivers/input/touchscreen/goodix_gtx8_v1430_mmi/goodix_ts_i2c.c b/drivers/input/touchscreen/goodix_gtx8_v1430_mmi/goodix_ts_i2c.c index 72dbc6e1eb59..f0b308935ffa 100644 --- a/drivers/input/touchscreen/goodix_gtx8_v1430_mmi/goodix_ts_i2c.c +++ b/drivers/input/touchscreen/goodix_gtx8_v1430_mmi/goodix_ts_i2c.c @@ -214,6 +214,11 @@ static int goodix_parse_dt(struct device_node *node, return r; } + r = of_property_read_u32(node, "goodix,control-dsi", + &board_data->ctrl_dsi); + if (!r) + ts_info("control DSI %d", board_data->ctrl_dsi); + /* key map */ prop = of_find_property(node, "goodix,panel-key-map", NULL); if (prop && prop->length) {