From 3c8a7d12dee6db25100a2035fd559ff7e38cbf56 Mon Sep 17 00:00:00 2001 From: Shashank Babu Chinta Venkata Date: Wed, 16 Oct 2019 10:56:43 -0700 Subject: [PATCH] ANDROID: driver: gpu: drm: add notifier for panel related events Add support for notfier of panel blank/unblank events. This allows external drivers such as touch, backlight drivers etc to subscribe to panel related events. Signed-off-by: Shashank Babu Chinta Venkata Bug: 139653858 Change-Id: I3ac644c1c931b959a511ee4a999a417a4b7bdcd1 --- drivers/gpu/drm/drm_panel.c | 22 ++++++++++++++++++++++ include/drm/drm_connector.h | 9 +++++++++ include/drm/drm_panel.h | 31 +++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c index 1d9a9d2fe0e0..a561ad15edea 100644 --- a/drivers/gpu/drm/drm_panel.c +++ b/drivers/gpu/drm/drm_panel.c @@ -48,6 +48,7 @@ static LIST_HEAD(panel_list); void drm_panel_init(struct drm_panel *panel) { INIT_LIST_HEAD(&panel->list); + BLOCKING_INIT_NOTIFIER_HEAD(&panel->nh); } EXPORT_SYMBOL(drm_panel_init); @@ -169,6 +170,27 @@ struct drm_panel *of_drm_find_panel(const struct device_node *np) EXPORT_SYMBOL(of_drm_find_panel); #endif +int drm_panel_notifier_register(struct drm_panel *panel, + struct notifier_block *nb) +{ + return blocking_notifier_chain_register(&panel->nh, nb); +} +EXPORT_SYMBOL(drm_panel_notifier_register); + +int drm_panel_notifier_unregister(struct drm_panel *panel, + struct notifier_block *nb) +{ + return blocking_notifier_chain_unregister(&panel->nh, nb); +} +EXPORT_SYMBOL(drm_panel_notifier_unregister); + +int drm_panel_notifier_call_chain(struct drm_panel *panel, + unsigned long val, void *v) +{ + return blocking_notifier_call_chain(&panel->nh, val, v); +} +EXPORT_SYMBOL(drm_panel_notifier_call_chain); + MODULE_AUTHOR("Thierry Reding "); MODULE_DESCRIPTION("DRM panel infrastructure"); MODULE_LICENSE("GPL and additional rights"); diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index cce2001c1407..7e067d09ccea 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -39,6 +39,7 @@ struct drm_encoder; struct drm_property; struct drm_property_blob; struct drm_printer; +struct drm_panel; struct edid; enum drm_connector_force { @@ -497,6 +498,7 @@ struct drm_connector_state { struct drm_writeback_job *writeback_job; /** + * @hdr_output_metadata: * DRM blob property for HDR output metadata */ @@ -1174,6 +1176,13 @@ struct drm_connector { /* HDR metdata */ struct hdr_output_metadata hdr_output_metadata; struct hdr_sink_metadata hdr_sink_metadata; + + /** + * @panel: + * + * Can find the panel which connected to drm_connector. + */ + struct drm_panel *panel; }; #define obj_to_connector(x) container_of(x, struct drm_connector, base) diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h index 675aa1e876ce..8e874b67e201 100644 --- a/include/drm/drm_panel.h +++ b/include/drm/drm_panel.h @@ -27,6 +27,23 @@ #include #include #include +#include + +/* A hardware display blank change occurred */ +#define DRM_PANEL_EVENT_BLANK 0x01 +/* A hardware display blank early change occurred */ +#define DRM_PANEL_EARLY_EVENT_BLANK 0x02 + +enum { + /* panel: power on */ + DRM_PANEL_BLANK_UNBLANK, + /* panel: power off */ + DRM_PANEL_BLANK_POWERDOWN, +}; + +struct drm_panel_notifier { + void *data; +}; struct device_node; struct drm_connector; @@ -94,6 +111,13 @@ struct drm_panel { const struct drm_panel_funcs *funcs; struct list_head list; + + /** + * @nh: + * + * panel notifier list head + */ + struct blocking_notifier_head nh; }; /** @@ -195,6 +219,13 @@ void drm_panel_remove(struct drm_panel *panel); int drm_panel_attach(struct drm_panel *panel, struct drm_connector *connector); int drm_panel_detach(struct drm_panel *panel); +int drm_panel_notifier_register(struct drm_panel *panel, + struct notifier_block *nb); +int drm_panel_notifier_unregister(struct drm_panel *panel, + struct notifier_block *nb); +int drm_panel_notifier_call_chain(struct drm_panel *panel, + unsigned long val, void *v); + #if defined(CONFIG_OF) && defined(CONFIG_DRM_PANEL) struct drm_panel *of_drm_find_panel(const struct device_node *np); #else