diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2016-03-24 10:45:11 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2016-03-24 10:45:11 +0100 |
commit | 19c335cd7f53d759ec04e96e0d96ed7258f4521c (patch) | |
tree | df8b7c68932407313dcbfbf3867e6c4656a9fe48 /vt.c | |
parent | 0aa8fef0aeca565aa87fb658fcfdc3e5f713079b (diff) | |
download | fbida-19c335cd7f53d759ec04e96e0d96ed7258f4521c.tar.gz |
add drm support, console switching fixes
Diffstat (limited to 'vt.c')
-rw-r--r-- | vt.c | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -1,5 +1,6 @@ #include <stdio.h> #include <stdlib.h> +#include <stdbool.h> #include <unistd.h> #include <string.h> #include <fcntl.h> @@ -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; |