From 19c335cd7f53d759ec04e96e0d96ed7258f4521c Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Thu, 24 Mar 2016 10:45:11 +0100 Subject: add drm support, console switching fixes --- vt.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'vt.c') diff --git a/vt.c b/vt.c index c03f4f0..da77813 100644 --- a/vt.c +++ b/vt.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -25,7 +26,10 @@ extern int debug; static int switch_last; static int console_switch_state = CONSOLE_ACTIVE; +static bool console_switching_active; +static int kd_mode; static struct vt_mode vt_mode; +static struct vt_mode vt_omode; static int orig_vt_no = 0; static void (*console_redraw)(void); @@ -82,15 +86,42 @@ int console_switch_init(void (*redraw)(void)) vt_mode.relsig = SIGUSR1; vt_mode.acqsig = SIGUSR2; + if (-1 == ioctl(STDIN_FILENO, VT_GETMODE, &vt_omode)) { + perror("ioctl VT_GETMODE"); + exit(1); + } if (-1 == ioctl(STDIN_FILENO, VT_SETMODE, &vt_mode)) { perror("ioctl VT_SETMODE"); exit(1); } + if (-1 == ioctl(STDIN_FILENO, KDGETMODE, &kd_mode)) { + perror("ioctl KDGETMODE"); + exit(1); + } + if (-1 == ioctl(STDIN_FILENO, KDSETMODE, KD_GRAPHICS)) { + perror("ioctl KDSETMODE"); + exit(1); + } + console_switching_active = true; return 0; } +void console_switch_cleanup(void) +{ + if (!console_switching_active) + return; + + if (-1 == ioctl(STDIN_FILENO, KDSETMODE, kd_mode)) + perror("ioctl KDSETMODE"); + if (-1 == ioctl(STDIN_FILENO, VT_SETMODE, &vt_omode)) + perror("ioctl VT_SETMODE"); + console_switching_active = false; +} + int check_console_switch(void) { + if (!console_switching_active) + return 0; if (switch_last == console_switch_state) return 0; -- cgit