diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 83d3d271ca15..dedbd7ccfe6e 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -45,5 +45,10 @@ if FB || SGI_NEWPORT_CONSOLE endif +config PANEL_NOTIFICATIONS + bool 'Panel notifications' + default n + ---help--- + Panel notifications framework endmenu diff --git a/drivers/video/Makefile b/drivers/video/Makefile index df7650adede9..46fd2cfb6a50 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile @@ -13,3 +13,4 @@ obj-$(CONFIG_VIDEOMODE_HELPERS) += display_timing.o videomode.o ifeq ($(CONFIG_OF),y) obj-$(CONFIG_VIDEOMODE_HELPERS) += of_display_timing.o of_videomode.o endif +obj-$(CONFIG_PANEL_NOTIFICATIONS) += panel_notifier.o diff --git a/drivers/video/panel_notifier.c b/drivers/video/panel_notifier.c new file mode 100644 index 000000000000..595727db83a4 --- /dev/null +++ b/drivers/video/panel_notifier.c @@ -0,0 +1,34 @@ +/* Copyright (c) 2016, Motorola Mobility, LLC. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include + +static BLOCKING_NOTIFIER_HEAD(panel_notifier_list); + +int panel_notify(unsigned int event, void *data) +{ + return blocking_notifier_call_chain(&panel_notifier_list, event, data); +} +EXPORT_SYMBOL_GPL(panel_notify); + +int panel_register_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_register(&panel_notifier_list, nb); +} +EXPORT_SYMBOL_GPL(panel_register_notifier); + +int panel_unregister_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_unregister(&panel_notifier_list, nb); +} +EXPORT_SYMBOL_GPL(panel_unregister_notifier); diff --git a/include/linux/panel_notifier.h b/include/linux/panel_notifier.h new file mode 100644 index 000000000000..2905be449d13 --- /dev/null +++ b/include/linux/panel_notifier.h @@ -0,0 +1,49 @@ +/* Copyright (c) 2016, Motorola Mobility, LLC. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef __PANEL_NOTIFIER_H__ +#define __PANEL_NOTIFIER_H__ + +#include + +enum panel_event { + PANEL_EVENT_PRE_DISPLAY_OFF, + PANEL_EVENT_PRE_DISPLAY_ON, + PANEL_EVENT_DISPLAY_OFF, + PANEL_EVENT_DISPLAY_ON, +}; + +#ifdef CONFIG_PANEL_NOTIFICATIONS + +int panel_register_notifier(struct notifier_block *nb); +int panel_unregister_notifier(struct notifier_block *nb); +int panel_notify(unsigned int event, void *data); + +#else + +#include +static inline int panel_register_notifier(struct notifier_block *nb) +{ + return -ENOSYS; +} +static inline int panel_unregister_notifier(struct notifier_block *nb) +{ + return -ENOSYS; +} +static inline int panel_notify(unsigned int event, void *data) +{ + return -ENOSYS; +} + +#endif +#endif