summaryrefslogtreecommitdiff
path: root/src/lib/ecore_drm
diff options
context:
space:
mode:
authorChris Michael <cpmichael@osg.samsung.com>2016-01-21 11:38:07 -0500
committerChris Michael <cpmichael@osg.samsung.com>2016-01-21 11:38:07 -0500
commitcb983f747b72c369499f7b738973c422c7996fee (patch)
tree72b0f5b59fb105aef4dd1114b295c229f136b404 /src/lib/ecore_drm
parente0c36d27f56ae207b5a969d53bf7eba2d67e38a7 (diff)
ecore-drm: Unify and cleanup tty code
This patch brings the tty code more inline with what the logind code Was doing. It also fixes the return value from the vt_signal handler, and opens the tty in non-blocking mode now. @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_private.h1
-rw-r--r--src/lib/ecore_drm/ecore_drm_tty.c50
2 files changed, 31 insertions, 20 deletions
diff --git a/src/lib/ecore_drm/ecore_drm_private.h b/src/lib/ecore_drm/ecore_drm_private.h
index bb959e9f75..1f51d3b7df 100644
--- a/src/lib/ecore_drm/ecore_drm_private.h
+++ b/src/lib/ecore_drm/ecore_drm_private.h
@@ -263,6 +263,7 @@ void _ecore_drm_launcher_device_close(const char *device, int fd);
263int _ecore_drm_launcher_device_flags_set(int fd, int flags); 263int _ecore_drm_launcher_device_flags_set(int fd, int flags);
264 264
265Eina_Bool _ecore_drm_tty_switch(Ecore_Drm_Device *dev, int activate_vt); 265Eina_Bool _ecore_drm_tty_switch(Ecore_Drm_Device *dev, int activate_vt);
266void _ecore_drm_tty_restore(Ecore_Drm_Device *dev);
266 267
267Ecore_Drm_Evdev *_ecore_drm_evdev_device_create(Ecore_Drm_Seat *seat, struct libinput_device *device); 268Ecore_Drm_Evdev *_ecore_drm_evdev_device_create(Ecore_Drm_Seat *seat, struct libinput_device *device);
268void _ecore_drm_evdev_device_destroy(Ecore_Drm_Evdev *evdev); 269void _ecore_drm_evdev_device_destroy(Ecore_Drm_Evdev *evdev);
diff --git a/src/lib/ecore_drm/ecore_drm_tty.c b/src/lib/ecore_drm/ecore_drm_tty.c
index f88cb4b34b..cd41bb6763 100644
--- a/src/lib/ecore_drm/ecore_drm_tty.c
+++ b/src/lib/ecore_drm/ecore_drm_tty.c
@@ -17,8 +17,10 @@ _ecore_drm_tty_cb_vt_signal(void *data, int type EINA_UNUSED, void *event)
17 17
18 ev = event; 18 ev = event;
19 sig = ev->data; 19 sig = ev->data;
20 if (sig.si_code != SI_KERNEL) return ECORE_CALLBACK_RENEW; 20 if (sig.si_code != SI_KERNEL) return ECORE_CALLBACK_PASS_ON;
21 if (!(dev = data)) return ECORE_CALLBACK_RENEW; 21 if (!(dev = data)) return ECORE_CALLBACK_PASS_ON;
22
23 DBG("TTY SWITCH SIGNAL");
22 24
23 switch (ev->number) 25 switch (ev->number)
24 { 26 {
@@ -38,7 +40,7 @@ _ecore_drm_tty_cb_vt_signal(void *data, int type EINA_UNUSED, void *event)
38 break; 40 break;
39 } 41 }
40 42
41 return ECORE_CALLBACK_RENEW; 43 return ECORE_CALLBACK_PASS_ON;
42} 44}
43 45
44Eina_Bool 46Eina_Bool
@@ -55,7 +57,8 @@ _ecore_drm_tty_setup(Ecore_Drm_Device *dev)
55 struct vt_mode vtmode = { 0, 0, SIGUSR1, SIGUSR2, 0 }; 57 struct vt_mode vtmode = { 0, 0, SIGUSR1, SIGUSR2, 0 };
56 58
57 if ((fstat(dev->tty.fd, &st) == -1) || 59 if ((fstat(dev->tty.fd, &st) == -1) ||
58 (major(st.st_rdev) != TTY_MAJOR) || (minor(st.st_rdev) == 0)) 60 (major(st.st_rdev) != TTY_MAJOR) || (minor(st.st_rdev) <= 0) ||
61 (minor(st.st_rdev) >= 64))
59 { 62 {
60 ERR("Failed to get stats for tty"); 63 ERR("Failed to get stats for tty");
61 return EINA_FALSE; 64 return EINA_FALSE;
@@ -70,23 +73,25 @@ _ecore_drm_tty_setup(Ecore_Drm_Device *dev)
70 if (kmode != KD_TEXT) 73 if (kmode != KD_TEXT)
71 WRN("Virtual Terminal already in KD_GRAPHICS mode"); 74 WRN("Virtual Terminal already in KD_GRAPHICS mode");
72 75
73 if (ioctl(dev->tty.fd, VT_ACTIVATE, minor(st.st_rdev)) < 0) 76 /* if (ioctl(dev->tty.fd, VT_ACTIVATE, minor(st.st_rdev)) < 0) */
74 { 77 /* { */
75 ERR("Failed to activate vt: %m"); 78 /* ERR("Failed to activate vt: %m"); */
76 return EINA_FALSE; 79 /* return EINA_FALSE; */
77 } 80 /* } */
78 81
79 if (ioctl(dev->tty.fd, VT_WAITACTIVE, minor(st.st_rdev)) < 0) 82 /* if (ioctl(dev->tty.fd, VT_WAITACTIVE, minor(st.st_rdev)) < 0) */
80 { 83 /* { */
81 ERR("Failed to wait active: %m"); 84 /* ERR("Failed to wait active: %m"); */
82 return EINA_FALSE; 85 /* return EINA_FALSE; */
83 } 86 /* } */
84 87
85 if (ioctl(dev->tty.fd, KDGKBMODE, &kbd_mode)) 88 if (ioctl(dev->tty.fd, KDGKBMODE, &kbd_mode))
86 { 89 {
87 ERR("Could not get curent kbd mode: %m"); 90 WRN("Could not get current kbd mode: %m");
88 return EINA_FALSE; 91 dev->tty.kbd_mode = K_UNICODE;
89 } 92 }
93 else if (dev->tty.kbd_mode == K_OFF)
94 dev->tty.kbd_mode = K_UNICODE;
90 95
91 if (ioctl(dev->tty.fd, KDSKBMUTE, 1) && 96 if (ioctl(dev->tty.fd, KDSKBMUTE, 1) &&
92 ioctl(dev->tty.fd, KDSKBMODE, K_OFF)) 97 ioctl(dev->tty.fd, KDSKBMODE, K_OFF))
@@ -105,6 +110,7 @@ _ecore_drm_tty_setup(Ecore_Drm_Device *dev)
105 vtmode.waitv = 0; 110 vtmode.waitv = 0;
106 vtmode.relsig = SIGUSR1; 111 vtmode.relsig = SIGUSR1;
107 vtmode.acqsig = SIGUSR2; 112 vtmode.acqsig = SIGUSR2;
113
108 if (ioctl(dev->tty.fd, VT_SETMODE, &vtmode) < 0) 114 if (ioctl(dev->tty.fd, VT_SETMODE, &vtmode) < 0)
109 { 115 {
110 ERR("Could not set Terminal Mode: %m"); 116 ERR("Could not set Terminal Mode: %m");
@@ -115,6 +121,8 @@ _ecore_drm_tty_setup(Ecore_Drm_Device *dev)
115err_setmode: 121err_setmode:
116 ioctl(dev->tty.fd, KDSETMODE, KD_TEXT); 122 ioctl(dev->tty.fd, KDSETMODE, KD_TEXT);
117err_kmode: 123err_kmode:
124 ioctl(dev->tty.fd, KDSKBMUTE, 0);
125 ioctl(dev->tty.fd, KDSKBMODE, dev->tty.kbd_mode);
118 return EINA_FALSE; 126 return EINA_FALSE;
119} 127}
120 128
@@ -158,10 +166,10 @@ ecore_drm_tty_open(Ecore_Drm_Device *dev, const char *name)
158 { 166 {
159 DBG("Trying to Open Tty: %s", tty); 167 DBG("Trying to Open Tty: %s", tty);
160 168
161 dev->tty.fd = open(tty, (O_RDWR | O_CLOEXEC)); //O_RDWR | O_NOCTTY); 169 dev->tty.fd = open(tty, (O_RDWR | O_CLOEXEC | O_NONBLOCK));
162 if (dev->tty.fd < 0) 170 if (dev->tty.fd < 0)
163 { 171 {
164 DBG("Failed to Open Tty: %m"); 172 DBG("Failed to Open Tty %s: %m", tty);
165 return EINA_FALSE; 173 return EINA_FALSE;
166 } 174 }
167 } 175 }
@@ -193,7 +201,7 @@ ecore_drm_tty_open(Ecore_Drm_Device *dev, const char *name)
193 return EINA_TRUE; 201 return EINA_TRUE;
194} 202}
195 203
196static void 204void
197_ecore_drm_tty_restore(Ecore_Drm_Device *dev) 205_ecore_drm_tty_restore(Ecore_Drm_Device *dev)
198{ 206{
199 int fd = dev->tty.fd; 207 int fd = dev->tty.fd;
@@ -226,9 +234,11 @@ ecore_drm_tty_close(Ecore_Drm_Device *dev)
226 _ecore_drm_tty_restore(dev); 234 _ecore_drm_tty_restore(dev);
227 235
228 close(dev->tty.fd); 236 close(dev->tty.fd);
229
230 dev->tty.fd = -1; 237 dev->tty.fd = -1;
231 238
239 if (dev->tty.event_hdlr)
240 ecore_event_handler_del(dev->tty.event_hdlr);
241
232 /* clear the tty name */ 242 /* clear the tty name */
233 if (dev->tty.name) eina_stringshare_del(dev->tty.name); 243 if (dev->tty.name) eina_stringshare_del(dev->tty.name);
234 dev->tty.name = NULL; 244 dev->tty.name = NULL;