ecore-drm: restore VT to text mode when close tty.

Summary: if ecore-drm failed to be run after changing tty mode, need to restore VT to text mode.

Test Plan:
- run enlightenment(drm backend) without systemd.
after changing tty graphics mode, if it's failed to be run by any reason,
you'll see black screen and coulnd't control session.

@fix

Reviewers: devilhorns

Reviewed By: devilhorns

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D1764
This commit is contained in:
Seunghun Lee 2014-12-10 08:03:44 -05:00 committed by Chris Michael
parent 7ac4020874
commit fed49b9709
1 changed files with 20 additions and 0 deletions

View File

@ -254,6 +254,24 @@ ecore_drm_tty_open(Ecore_Drm_Device *dev, const char *name)
return EINA_TRUE;
}
static void
_ecore_drm_tty_restore(Ecore_Drm_Device *dev)
{
int fd = dev->tty.fd;
struct vt_mode mode = { 0 };
if (fd < 0) return;
if (ioctl(fd, KDSETMODE, KD_TEXT))
ERR("Could not set KD_TEXT mode on tty: %m\n");
ecore_drm_device_master_drop(dev);
mode.mode = VT_AUTO;
if (ioctl(fd, VT_SETMODE, &mode) < 0)
ERR("Could not reset VT handling\n");
}
/**
* Close an already opened tty
*
@ -269,6 +287,8 @@ ecore_drm_tty_close(Ecore_Drm_Device *dev)
/* check for valid device */
if ((!dev) || (!dev->drm.name)) return EINA_FALSE;
_ecore_drm_tty_restore(dev);
close(dev->tty.fd);
dev->tty.fd = -1;