From 34fe6bac73d68481e2d109e9c1f5c284a0420a4b Mon Sep 17 00:00:00 2001 From: Ben Fennema Date: Wed, 14 Dec 2022 09:52:38 -0800 Subject: Update to qcom drm framework for 5.15 panel_notifier_callback updated to take a struct panel_event_notification. Bug: 262578089 Change-Id: Ief7d29938a1e5c996b67a63eb41dc306779ecefc Signed-off-by: Ben Fennema --- ots_pat9126/pat9126.c | 150 +++++++++++++++++++++++++------------------------- 1 file changed, 76 insertions(+), 74 deletions(-) (limited to 'ots_pat9126/pat9126.c') diff --git a/ots_pat9126/pat9126.c b/ots_pat9126/pat9126.c index 288e8f0..9b1079c 100644 --- a/ots_pat9126/pat9126.c +++ b/ots_pat9126/pat9126.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include struct pixart_pat9126_data { struct i2c_client *client; @@ -40,12 +40,12 @@ struct pixart_pat9126_data { u32 vdd_sleep_load; u32 vld_sleep_load; int state; - int display_mode; struct work_struct work; struct workqueue_struct *workqueue; struct delayed_work polling_work; struct delayed_work resume_work; - struct notifier_block drm_panel_notif; + struct drm_panel *active_panel; + void *notifier_cookie; struct mutex mtx; struct regulator *vdd_supply; struct regulator *vld_supply; @@ -65,10 +65,8 @@ struct rw_reg_info { struct rw_reg_info pat9126_reg_info; /* Declaration of suspend and resume functions */ -static struct drm_panel *active_panel; -static int pat9126_drm_panel_notifier_callback(struct notifier_block *self, - unsigned long event, - void *data); +static void pat9126_drm_panel_notifier_callback(enum panel_event_notifier_tag tag, + struct panel_event_notification *notification, void *data); static int pat9126_display_suspend(struct device *dev); static int pat9126_display_resume(struct device *dev); @@ -825,29 +823,60 @@ static int pat9126_parse_dt(struct device *dev, return 0; } -static int pat9126_check_dt(struct device_node *np) +static int pat9126_register_panel_notifier(struct pixart_pat9126_data *data) { - int i; - int count; - struct device_node *node; + struct device_node *np = data->client->dev.of_node; + struct device_node *pnode; struct drm_panel *panel; + void *cookie = NULL; + int i, count, rc; - count = of_count_phandle_with_args(np, "panel", NULL); - if (count <= 0) { + count = of_count_phandle_with_args(np, "display-panels", NULL); + if (count <= 0) return 0; - } for (i = 0; i < count; i++) { - node = of_parse_phandle(np, "panel", i); - panel = of_drm_find_panel(node); - of_node_put(node); + pnode = of_parse_phandle(np, "display-panels", i); + if (!pnode) + return -ENODEV; + + panel = of_drm_find_panel(pnode); + of_node_put(pnode); if (!IS_ERR(panel)) { - active_panel = panel; - return 0; + data->active_panel = panel; + break; } } - return PTR_ERR(panel); + if (!data->active_panel) { + rc = PTR_ERR(panel); + if (rc != -EPROBE_DEFER) + pr_err("failed to find active panel, rc=%d\n", rc); + + return rc; + } + + cookie = panel_event_notifier_register( + PANEL_EVENT_NOTIFICATION_PRIMARY, + PANEL_EVENT_NOTIFIER_CLIENT_SECONDARY_TOUCH, + data->active_panel, + &pat9126_drm_panel_notifier_callback, + data); + if (IS_ERR(cookie)) { + rc = PTR_ERR(cookie); + pr_err("failed to register panel event notifier, rc=%d\n", rc); + return rc; + } + + pr_debug("register panel notifier successful\n"); + data->notifier_cookie = cookie; + return 0; +} + +static void pat9126_unregister_panel_notifier(struct pixart_pat9126_data *data) +{ + if (data->notifier_cookie) + panel_event_notifier_unregister(data->notifier_cookie); } static int pat9126_i2c_probe(struct i2c_client *client, @@ -861,14 +890,6 @@ static int pat9126_i2c_probe(struct i2c_client *client, struct device_node *dp = NULL; dp = client->dev.of_node; - ret = pat9126_check_dt(dp); - if (ret) { - if (ret == -EPROBE_DEFER) { - return -EPROBE_DEFER; - } - return -ENODEV; - } - ret = i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE); if (ret < 0) { dev_err(dev, "I2C not supported\n"); @@ -935,15 +956,11 @@ static int pat9126_i2c_probe(struct i2c_client *client, mutex_init(&data->mtx); data->state = PAT9126_STATE_ON; - data->display_mode = DRM_PANEL_BLANK_UNBLANK; - data->drm_panel_notif.notifier_call = pat9126_drm_panel_notifier_callback; - - if (active_panel) { - ret = drm_panel_notifier_register(active_panel, &data->drm_panel_notif); - if (ret) { - dev_err(dev, "register drm_panel_notifier failed, errno:%d\n", ret); - goto err_regulators; - } + + ret = pat9126_register_panel_notifier(data); + if (ret) { + dev_err(dev, "register panel_notifier failed, errno:%d\n", ret); + goto err_regulators; } INIT_DELAYED_WORK(&data->polling_work, pat9126_work_handler); @@ -968,6 +985,7 @@ static int pat9126_i2c_probe(struct i2c_client *client, return 0; err_sysfs_create: + disable_irq(client->irq); err_request_threaded_irq: cancel_work_sync(&data->work); destroy_workqueue(data->workqueue); @@ -985,54 +1003,38 @@ static int pat9126_i2c_remove(struct i2c_client *client) dev_dbg(dev, "%s\n", __func__); if (data) { - if (active_panel) { - ret = drm_panel_notifier_unregister(active_panel, - &data->drm_panel_notif); - if (ret) { - dev_dbg(dev, "[PAT9126]: unregister " - "drm_panel_notifier failed, " - "errno:%d\n", ret); - } - } + pat9126_unregister_panel_notifier(data); + pat9126_disable_regulators(data); } - pat9126_disable_regulators(data); return ret; } -static int pat9126_drm_panel_notifier_callback(struct notifier_block *nb, - unsigned long event, - void *arg) +static void pat9126_drm_panel_notifier_callback(enum panel_event_notifier_tag tag, + struct panel_event_notification *notification, void *data) { - struct drm_panel_notifier *evdata = arg; - int *blank; - struct pixart_pat9126_data *data = - container_of(nb, struct pixart_pat9126_data, drm_panel_notif); + struct pixart_pat9126_data *pat9126 = data; - if (!evdata) { - return 0; + if (!notification) { + return; } - if (!(event == DRM_PANEL_EARLY_EVENT_BLANK || - event == DRM_PANEL_EVENT_BLANK)) { - return 0; + switch (notification->notif_type) { + case DRM_PANEL_EVENT_UNBLANK: + if (!notification->notif_data.early_trigger) + pat9126_display_resume(&pat9126->client->dev); + break; + + case DRM_PANEL_EVENT_BLANK: + case DRM_PANEL_EVENT_BLANK_LP: + if (notification->notif_data.early_trigger) + pat9126_display_suspend(&pat9126->client->dev); + break; + default: + break; } - if (evdata->data && data) { - blank = evdata->data; - if (event == DRM_PANEL_EARLY_EVENT_BLANK) { - if ((*blank == DRM_PANEL_BLANK_POWERDOWN) || - (*blank == DRM_PANEL_BLANK_LP)) { - pat9126_display_suspend(&data->client->dev); - } - } else if (event == DRM_PANEL_EVENT_BLANK) { - if (*blank == DRM_PANEL_BLANK_UNBLANK) { - pat9126_display_resume(&data->client->dev); - } - } - } - - return 0; + return; } static int pat9126_display_suspend(struct device *dev) -- cgit v1.2.3