compositor: put console into KD_GRAPHICS mode at vt enter time

This will keep the kernel from changing graphics state out from under us
(e.g. blanking).
This commit is contained in:
Jesse Barnes 2010-11-08 11:51:12 -08:00 committed by Kristian Høgsberg
parent 2b43bd73a0
commit f2912fa85f
1 changed files with 12 additions and 0 deletions

View 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;