PATCH [1/2] - Console notifier chain
Jordan Crouse
jordan.crouse at amd.com
Thu Mar 1 18:11:18 EST 2007
Part of the framebuffer power management story is knowing who is actually
in charge of the graphics hardware. X very famously makes that a difficult
question to answer. This patch adds a simple notifier that will let
interested drivers know when the current VT console switches from KD_TEXT
mode to KD_GRAPHICS mode - the latter being an excellent indicator that
somebody else (probably X) is rendering the screen.
This will be used in patch #2 by the KFB driver.
Jordan
-------------- next part --------------
[PATCH] Add a notifier list for VT console modes
From: Jordan Crouse <jordan.crouse at amd.com>
Allow drivers to register for notification when the current VT console
switches from KD_TEXT to KD_GRAPHICS mode. Framebuffer drivers in
particular can use the distinction to determine who "owns" the framebuffer
and who should be responsible for saving and restoring registers during
power events.
---
drivers/char/vt_ioctl.c | 11 +++++++++++
include/linux/vt_kern.h | 19 +++++++++++++++++++
2 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/drivers/char/vt_ioctl.c b/drivers/char/vt_ioctl.c
index 3a5d301..f301102 100644
--- a/drivers/char/vt_ioctl.c
+++ b/drivers/char/vt_ioctl.c
@@ -37,6 +37,9 @@ #include <linux/selection.h>
static char vt_dont_switch;
extern struct tty_driver *console_driver;
+/* Add a notifier chain to inform drivers of a VT_TEXT/VT_GRAPHICS switch */
+RAW_NOTIFIER_HEAD(console_notifier_list);
+
#define VT_IS_IN_USE(i) (console_driver->ttys[i] && console_driver->ttys[i]->count)
#define VT_BUSY(i) (VT_IS_IN_USE(i) || i == fg_console || vc_cons[i].d == sel_cons)
@@ -491,6 +494,14 @@ #endif
vc->vc_mode = (unsigned char) arg;
if (console != fg_console)
return 0;
+
+ /* Notify listeners if the current fg_console has switched */
+
+ raw_notifier_call_chain(&console_notifier_list,
+ (arg == KD_TEXT) ?
+ CONSOLE_EVENT_SWITCH_TEXT :
+ CONSOLE_EVENT_SWITCH_GRAPHICS, 0);
+
/*
* explicitly blank/unblank the screen if switching modes
*/
diff --git a/include/linux/vt_kern.h b/include/linux/vt_kern.h
index 37a1a41..d83e89c 100644
--- a/include/linux/vt_kern.h
+++ b/include/linux/vt_kern.h
@@ -91,4 +91,23 @@ struct vt_spawn_console {
};
extern struct vt_spawn_console vt_spawn_con;
+/* A notifier list for console events */
+extern struct raw_notifier_head console_notifier_list;
+
+/* Called when the FG console switches to KD_TEXT mode */
+#define CONSOLE_EVENT_SWITCH_TEXT 0x01
+
+/* Called when the FG console switches to KD_GRAPHICS mode */
+#define CONSOLE_EVENT_SWITCH_GRAPHICS 0x02
+
+static inline int console_event_register(struct notifier_block *n)
+{
+ return raw_notifier_chain_register(&console_notifier_list, n);
+}
+
+static inline int console_event_unregister(struct notifier_block *n)
+{
+ return raw_notifier_chain_unregister(&console_notifier_list, n);
+}
+
#endif /* _VT_KERN_H */
More information about the Devel
mailing list