From: Jordan Crouse <[EMAIL PROTECTED]>

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.

Signed-off-by:  Jordan Crouse <[EMAIL PROTECTED]>
---

 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 */


_______________________________________________
Devel mailing list
[email protected]
http://mailman.laptop.org/mailman/listinfo/devel

Reply via email to