summaryrefslogtreecommitdiff
path: root/src/lib/ecore_drm
diff options
context:
space:
mode:
authorChris Michael <cpmichael@osg.samsung.com>2016-01-21 11:20:29 -0500
committerChris Michael <cpmichael@osg.samsung.com>2016-01-21 11:20:29 -0500
commitcddc7ba445035040ee31685c1920327ca26f47d7 (patch)
treef861ad6d726b3d26b9629c2f9d644e6ed9fa395f /src/lib/ecore_drm
parent479bf37aecd60d519aa323eb3f2a93e1b0f3faa6 (diff)
ecore-drm: Refactor logind code to use tty functions
This patch cleans up some of the logind code to make use of the existing tty functions as they both did the same thing @fix Signed-off-by: Chris Michael <cpmichael@osg.samsung.com>
Diffstat (limited to 'src/lib/ecore_drm')
-rw-r--r--src/lib/ecore_drm/ecore_drm_logind.c78
1 files changed, 4 insertions, 74 deletions
diff --git a/src/lib/ecore_drm/ecore_drm_logind.c b/src/lib/ecore_drm/ecore_drm_logind.c
index 47cb92f..0797d02 100644
--- a/src/lib/ecore_drm/ecore_drm_logind.c
+++ b/src/lib/ecore_drm/ecore_drm_logind.c
@@ -27,77 +27,15 @@ _ecore_drm_logind_vt_get(Ecore_Drm_Device *dev)
27static Eina_Bool 27static Eina_Bool
28_ecore_drm_logind_vt_setup(Ecore_Drm_Device *dev) 28_ecore_drm_logind_vt_setup(Ecore_Drm_Device *dev)
29{ 29{
30 struct stat st;
31 char buff[64]; 30 char buff[64];
32 struct vt_mode vtmode = { 0, 0, SIGUSR1, SIGUSR2, 0 };
33 31
34 snprintf(buff, sizeof(buff), "/dev/tty%d", dev->vt); 32 snprintf(buff, sizeof(buff), "/dev/tty%d", dev->vt);
35 buff[sizeof(buff) - 1] = 0; 33 buff[sizeof(buff) - 1] = 0;
36 34
37 dev->tty.fd = open(buff, (O_RDWR | O_CLOEXEC | O_NONBLOCK)); 35 if (!ecore_drm_tty_open(dev, buff))
38 if (dev->tty.fd < 0) 36 return EINA_FALSE;
39 {
40 ERR("Could not open VT %s %m", buff);
41 return EINA_FALSE;
42 }
43
44 if ((fstat(dev->tty.fd, &st) == -1) ||
45 (major(st.st_rdev) != TTY_MAJOR) ||
46 (minor(st.st_rdev) <= 0) || (minor(st.st_rdev) >= 64))
47 {
48 ERR("TTY %s is not a virtual terminal", buff);
49 goto stat_err;
50 }
51
52 if (ioctl(dev->tty.fd, KDGKBMODE, &dev->tty.kbd_mode) < 0)
53 {
54 ERR("Could not read keyboard mode of %s: %m", buff);
55 dev->tty.kbd_mode = K_UNICODE;
56 }
57 else if (dev->tty.kbd_mode == K_OFF)
58 dev->tty.kbd_mode = K_UNICODE;
59
60 if ((ioctl(dev->tty.fd, KDSKBMUTE, 1) < 0) &&
61 (ioctl(dev->tty.fd, KDSKBMODE, K_OFF) < 0))
62 {
63 ERR("Could not set K_OFF keyboard mode on %s: %m", buff);
64 goto stat_err;
65 }
66
67 if (ioctl(dev->tty.fd, KDSETMODE, KD_GRAPHICS) < 0)
68 {
69 ERR("Could not set KD_GRAPHICS mode on %s: %m", buff);
70 goto kbdmode_err;
71 }
72
73 vtmode.mode = VT_PROCESS;
74 vtmode.waitv = 0;
75 vtmode.relsig = SIGUSR1;
76 vtmode.acqsig = SIGUSR2;
77
78 if (ioctl(dev->tty.fd, VT_SETMODE, &vtmode) < 0)
79 {
80 ERR("Could not take over virtual terminal: %m");
81 goto mode_err;
82 }
83 37
84 return EINA_TRUE; 38 return EINA_TRUE;
85
86mode_err:
87 ioctl(dev->tty.fd, KDSETMODE, KD_TEXT);
88kbdmode_err:
89 ioctl(dev->tty.fd, KDSKBMUTE, 0);
90 ioctl(dev->tty.fd, KDSKBMODE, dev->tty.kbd_mode);
91stat_err:
92 close(dev->tty.fd);
93 return EINA_FALSE;
94}
95
96static void
97_ecore_drm_logind_vt_destroy(Ecore_Drm_Device *dev)
98{
99 _ecore_drm_logind_restore(dev);
100 close(dev->tty.fd);
101} 39}
102 40
103static Eina_Bool 41static Eina_Bool
@@ -252,7 +190,7 @@ _ecore_drm_logind_disconnect(Ecore_Drm_Device *dev)
252 if (active_hdlr) ecore_event_handler_del(active_hdlr); 190 if (active_hdlr) ecore_event_handler_del(active_hdlr);
253 active_hdlr = NULL; 191 active_hdlr = NULL;
254 192
255 _ecore_drm_logind_vt_destroy(dev); 193 ecore_drm_tty_close(dev);
256 _ecore_drm_dbus_session_release(); 194 _ecore_drm_dbus_session_release();
257 _ecore_drm_dbus_shutdown(); 195 _ecore_drm_dbus_shutdown();
258} 196}
@@ -260,15 +198,7 @@ _ecore_drm_logind_disconnect(Ecore_Drm_Device *dev)
260void 198void
261_ecore_drm_logind_restore(Ecore_Drm_Device *dev) 199_ecore_drm_logind_restore(Ecore_Drm_Device *dev)
262{ 200{
263 struct vt_mode vtmode = { 0, 0, SIGUSR1, SIGUSR2, 0 }; 201 _ecore_drm_tty_restore(dev);
264
265 if ((!dev) || (dev->tty.fd < 0)) return;
266
267 ioctl(dev->tty.fd, KDSETMODE, KD_TEXT);
268 ioctl(dev->tty.fd, KDSKBMUTE, 0);
269 ioctl(dev->tty.fd, KDSKBMODE, dev->tty.kbd_mode);
270 vtmode.mode = VT_AUTO;
271 ioctl(dev->tty.fd, VT_SETMODE, &vtmode);
272} 202}
273 203
274Eina_Bool 204Eina_Bool