compositor: put console into KD_GRAPHICS mode at vt enter time
authorJesse Barnes <jbarnes@virtuousgeek.org>
Mon, 8 Nov 2010 19:51:12 +0000 (11:51 -0800)
committerKristian Høgsberg <krh@bitplanet.net>
Tue, 9 Nov 2010 19:25:49 +0000 (14:25 -0500)
This will keep the kernel from changing graphics state out from under us
(e.g. blanking).

compositor/compositor-drm.c

index 2018e5c..e843e14 100644 (file)
@@ -23,6 +23,7 @@
 #include <unistd.h>
 
 #include <signal.h>
+#include <linux/kd.h>
 #include <linux/vt.h>
 #include <linux/input.h>
 
@@ -509,6 +510,9 @@ static void on_enter_vt(int signal_number, void *data)
        fprintf(stderr, "enter vt\n");
 
        ioctl(ec->tty_fd, VT_RELDISP, VT_ACKACQ);
+       ret = ioctl(ec->tty_fd, KDSETMODE, KD_GRAPHICS);
+       if (ret)
+               fprintf(stderr, "failed to set KD_GRAPHICS mode on console: %m\n");
        ec->vt_active = 1;
 
        wl_list_for_each(output, &ec->base.output_list, base.link) {
@@ -535,6 +539,9 @@ static void on_leave_vt(int signal_number, void *data)
        }
 
        ioctl (ec->tty_fd, VT_RELDISP, 1);
+       ret = ioctl(ec->tty_fd, KDSETMODE, KD_TEXT);
+       if (ret)
+               fprintf(stderr, "failed to set KD_TEXT mode on console: %m\n");
        ec->vt_active = 0;
 }
 
@@ -562,6 +569,7 @@ static int setup_tty(struct drm_compositor *ec, struct wl_event_loop *loop)
 {
        struct termios raw_attributes;
        struct vt_mode mode = { 0 };
+       int ret;
 
        ec->tty_fd = open("/dev/tty0", O_RDWR | O_NOCTTY);
        if (ec->tty_fd <= 0) {
@@ -591,6 +599,10 @@ static int setup_tty(struct drm_compositor *ec, struct wl_event_loop *loop)
                wl_event_loop_add_fd(loop, ec->tty_fd,
                                     WL_EVENT_READABLE, on_tty_input, ec);
 
+       ret = ioctl(ec->tty_fd, KDSETMODE, KD_GRAPHICS);
+       if (ret)
+               fprintf(stderr, "failed to set KD_GRAPHICS mode on tty: %m\n");
+
        ec->vt_active = 1;
        mode.mode = VT_PROCESS;
        mode.relsig = SIGUSR1;