diff --git a/src/modules/evas/engines/gl_drm/Evas_Engine_GL_Drm.h b/src/modules/evas/engines/gl_drm/Evas_Engine_GL_Drm.h index 3f41beeca9..6c0b04596f 100644 --- a/src/modules/evas/engines/gl_drm/Evas_Engine_GL_Drm.h +++ b/src/modules/evas/engines/gl_drm/Evas_Engine_GL_Drm.h @@ -2,6 +2,7 @@ # define _EVAS_ENGINE_GL_DRM_H # include +# include typedef struct _Evas_Engine_Info_GL_Drm Evas_Engine_Info_GL_Drm; @@ -24,6 +25,7 @@ struct _Evas_Engine_Info_GL_Drm Eina_Bool own_fd : 1; Eina_Bool own_tty : 1; int output, plane; + Ecore_Drm_Device *dev; } info; struct diff --git a/src/modules/evas/engines/gl_drm/evas_drm.c b/src/modules/evas/engines/gl_drm/evas_drm.c index 3fcbd0c74f..2fe0d5f951 100644 --- a/src/modules/evas/engines/gl_drm/evas_drm.c +++ b/src/modules/evas/engines/gl_drm/evas_drm.c @@ -1,10 +1,6 @@ #include "evas_engine.h" -#include -#include #include -static Evas_Engine_Info_GL_Drm *siginfo; - static void _evas_drm_fb_destroy_callback(struct gbm_bo *bo, void *data) { @@ -15,63 +11,6 @@ _evas_drm_fb_destroy_callback(struct gbm_bo *bo, void *data) drmModeRmFB(gbm_device_get_fd(gbm), buffer->fb); } -static int -_evas_drm_tty_open(Evas_Engine_Info_GL_Drm *info) -{ - int tty = STDIN_FILENO; - - /* check if the current stdin is a valid tty */ - if (!isatty(tty)) - { - /* if not, try to open the curren tty */ - if ((tty = open("/dev/tty", (O_RDWR | O_CLOEXEC))) < 0) - { - int tty0 = -1, num = -1; - char name[16]; - - /* if that fails, try tty0 */ - if ((tty0 = open("/dev/tty0", (O_WRONLY | O_CLOEXEC))) < 0) - { - CRI("Could not open tty0: %m"); - return -1; - } - - /* try to find a non-opened tty */ - if ((ioctl(tty0, VT_OPENQRY, &num) < 0) || (num < 0)) - { - CRI("Could not find a non-opened tty"); - close(tty0); - return -1; - } - - snprintf(name, sizeof(name), "/dev/tty%d", num); - - /* try to open this tty */ - if ((tty = open(name, (O_RDWR | O_CLOEXEC))) < 0) - { - CRI("Could not open tty: %s", name); - close(tty0); - return -1; - } - - /* set flag that evas should close this tty */ - info->info.own_tty = EINA_TRUE; - - /* close /dev/tty0 */ - close(tty0); - } - } - else - { - /* set flag that evas should close this tty */ - info->info.own_tty = EINA_TRUE; - } - - DBG("Opened Tty %d", tty); - - return tty; -} - static int _evas_drm_crtc_find(int fd, drmModeRes *res, drmModeConnector *conn) { @@ -131,103 +70,6 @@ _evas_drm_crtc_buffer_get(int fd, int crtc_id) return id; } -static void -_evas_drm_tty_sigusr1(int x EINA_UNUSED, siginfo_t *info EINA_UNUSED, void *data EINA_UNUSED) -{ - Evas_Engine_Info_GL_Drm *einfo; - - DBG("Caught SIGUSR1"); - - if (!(einfo = siginfo)) return; - - /* TODO: set canvas to not render */ - - DBG("\tDrop Master & Release VT"); - - /* drop drm master */ - if (einfo->info.own_fd) - { - if (drmDropMaster(einfo->info.fd) != 0) - WRN("Could not drop drm master: %m"); - } - - /* release vt */ - if (einfo->info.own_tty) - { - if (ioctl(einfo->info.tty, VT_RELDISP, 1) < 0) - WRN("Could not release vt: %m"); - } -} - -static void -_evas_drm_tty_sigusr2(int x EINA_UNUSED, siginfo_t *info EINA_UNUSED, void *data EINA_UNUSED) -{ - Evas_Engine_Info_GL_Drm *einfo; - - DBG("Caught SIGUSR2"); - - if (!(einfo = siginfo)) return; - - /* TODO: set canvas to render again */ - - DBG("\tAcquire VT & Set Master"); - - /* acquire vt */ - if (einfo->info.own_tty) - { - if (ioctl(einfo->info.tty, VT_RELDISP, VT_ACKACQ) < 0) - WRN("Could not acquire vt: %m"); - } - - /* set master */ - if (einfo->info.own_fd) - { - if (drmSetMaster(einfo->info.fd) != 0) - WRN("Could not set drm master: %m"); - } -} - -static Eina_Bool -_evas_drm_tty_setup(Evas_Engine_Info_GL_Drm *info) -{ - struct vt_mode vtmode = { 0 }; - struct sigaction sig; - - /* check for valid tty */ - if (info->info.tty < 0) return EINA_FALSE; - - /* setup tty rel/acq signals */ - vtmode.mode = VT_PROCESS; - vtmode.waitv = 0; - vtmode.relsig = SIGUSR1; - vtmode.acqsig = SIGUSR2; - if (ioctl(info->info.tty, VT_SETMODE, &vtmode) < 0) - { - CRI("Could not set tty mode: %m"); - return EINA_FALSE; - } - - /* store info struct - * - * NB: REALLY hate to store this here, but sigaction signal handlers cannot - * pass any 'user data' to the signal handlers :( - */ - siginfo = info; - - /* setup signal handlers for above signals */ - sig.sa_sigaction = _evas_drm_tty_sigusr1; - sig.sa_flags = (SA_NODEFER | SA_SIGINFO | SA_RESTART); - sigemptyset(&sig.sa_mask); - sigaction(SIGUSR1, &sig, NULL); - - sig.sa_sigaction = _evas_drm_tty_sigusr2; - sig.sa_flags = (SA_NODEFER | SA_SIGINFO | SA_RESTART); - sigemptyset(&sig.sa_mask); - sigaction(SIGUSR2, &sig, NULL); - - return EINA_TRUE; -} - static void _evas_drm_outbuf_page_flip(int fd EINA_UNUSED, unsigned int seq EINA_UNUSED, unsigned int tv_sec EINA_UNUSED, unsigned int tv_usec EINA_UNUSED, void *data) { @@ -298,60 +140,6 @@ _evas_drm_outbuf_planes_setup(Outbuf *ob, drmModePlaneResPtr pres) return EINA_TRUE; } -Eina_Bool -evas_drm_init(Evas_Engine_Info_GL_Drm *info) -{ - /* check for valid engine info */ - if (!info) return EINA_FALSE; - - setvbuf(stdout, NULL, _IONBF, 0); - - /* check if we already opened the tty */ - if (info->info.tty < 0) - { - /* try to open the current tty */ - if ((info->info.tty = _evas_drm_tty_open(info)) < 0) - { - /* check if we already opened the card. if so, close it */ - if ((info->info.fd >= 0) && (info->info.own_fd)) - { - close(info->info.fd); - info->info.fd = -1; - } - - return EINA_FALSE; - } - } - - /* with the tty opened, we need to set it up */ - if (!_evas_drm_tty_setup(info)) - { - /* setup of tty failed, close it */ - if ((info->info.tty >= 0) && (info->info.own_tty)) - close(info->info.tty); - - return EINA_FALSE; - } - - return EINA_TRUE; -} - -Eina_Bool -evas_drm_shutdown(Evas_Engine_Info_GL_Drm *info) -{ - /* check for valid engine info */ - if (!info) return EINA_TRUE; - - /* check if we already opened the tty. if so, close it */ - if ((info->info.tty >= 0) && (info->info.own_tty)) - { - close(info->info.tty); - info->info.tty = -1; - } - - return EINA_TRUE; -} - Eina_Bool evas_drm_gbm_init(Evas_Engine_Info_GL_Drm *info, int w, int h) { diff --git a/src/modules/evas/engines/gl_drm/evas_engine.c b/src/modules/evas/engines/gl_drm/evas_engine.c index 0bf0d0eb9b..85891ae744 100644 --- a/src/modules/evas/engines/gl_drm/evas_engine.c +++ b/src/modules/evas/engines/gl_drm/evas_engine.c @@ -1,6 +1,5 @@ #include "evas_common_private.h" /* Also includes international specific stuff */ #include "evas_engine.h" -#include #ifdef HAVE_DLSYM # include /* dlopen,dlclose,etc */ @@ -94,7 +93,6 @@ static int evgl_eng_rotation_angle_get(void *data); static void _re_winfree(Render_Engine *re); /* local variables */ -static Ecore_Drm_Device *drm_dev = NULL; static Eina_Bool initted = EINA_FALSE; static int gl_wins = 0; @@ -112,9 +110,9 @@ _drm_device_shutdown(Evas_Engine_Info_GL_Drm *info) /* check if we already opened the card. if so, close it */ if ((info->info.fd >= 0) && (info->info.own_fd)) { - ecore_drm_device_close(drm_dev); + ecore_drm_device_close(info->info.dev); info->info.fd = -1; - ecore_drm_device_free(drm_dev); + ecore_drm_device_free(info->info.dev); } } @@ -616,38 +614,33 @@ eng_setup(Evas *eo_e, void *in) if (!ecore_drm_init()) return 0; /* try getting the default drm device */ - if (!(drm_dev = ecore_drm_device_find(NULL, NULL))) + if (!(info->info.dev = ecore_drm_device_find(NULL, NULL))) { _drm_device_shutdown(info); return 0; } /* check if we already opened the drm device with ecore_evas */ - if (info->info.fd < 0) - { - /* try to open the drm ourselfs (most likely because we get called from expedite) */ - if (!ecore_drm_device_open(drm_dev)) - { - _drm_device_shutdown(info); - return 0; - } - info->info.own_fd = EINA_TRUE; - info->info.fd = ecore_drm_device_fd_get(drm_dev); - } - /* try to init drm (this includes openening tty) */ - /* FIXME replace with ecore_drm_tty */ - if (!evas_drm_init(info)) + /* try to open the drm ourselfs (most likely because we get called from expedite) */ + if (!ecore_drm_device_open(info->info.dev)) { _drm_device_shutdown(info); return 0; } + info->info.own_fd = EINA_TRUE; + info->info.fd = ecore_drm_device_fd_get(info->info.dev); + + if (info->info.tty < 0) + { + info->info.own_tty = EINA_TRUE; + info->info.tty = ecore_drm_tty_get(info->info.dev); + } } if (!(info->info.gbm) || !(info->info.surface)) { if (!evas_drm_gbm_init(info, epd->output.w, epd->output.h)) { - evas_drm_shutdown(info); _drm_device_shutdown(info); return 0; } @@ -670,9 +663,6 @@ eng_setup(Evas *eo_e, void *in) { /* shutdown destroy gbm surface & shutdown gbm device */ evas_drm_gbm_shutdown(info); - /* shutdown tty */ - /* FIXME use ecore_drm_tty */ - evas_drm_shutdown(info); _drm_device_shutdown(info); free(re); return 0; @@ -701,9 +691,6 @@ eng_setup(Evas *eo_e, void *in) eng_window_free(ob); /* shutdown destroy gbm surface & shutdown gbm device */ evas_drm_gbm_shutdown(info); - /* shutdown tty */ - /* FIXME use ecore_drm_tty */ - evas_drm_shutdown(info); _drm_device_shutdown(info); free(re); return 0; @@ -823,9 +810,6 @@ eng_setup(Evas *eo_e, void *in) eng_window_free(eng_get_ob(re)); gl_wins--; evas_drm_gbm_shutdown(info); - /* shutdown tty */ - /* FIXME use ecore_drm_tty */ - evas_drm_shutdown(info); _drm_device_shutdown(info); } free(re); @@ -859,9 +843,6 @@ eng_output_free(void *data) if (gl_wins == 1) glsym_evgl_engine_shutdown(re); evas_drm_gbm_shutdown(eng_get_ob(re)->info); - /* shutdown tty */ - /* FIXME use ecore_drm_tty */ - evas_drm_shutdown(eng_get_ob(re)->info); _drm_device_shutdown(eng_get_ob(re)->info); //evas_render_engine_software_generic_clean() frees ob. diff --git a/src/modules/evas/engines/gl_drm/evas_engine.h b/src/modules/evas/engines/gl_drm/evas_engine.h index 8f9aa5a01f..3e07f0876c 100644 --- a/src/modules/evas/engines/gl_drm/evas_engine.h +++ b/src/modules/evas/engines/gl_drm/evas_engine.h @@ -179,9 +179,6 @@ _re_wincheck(Outbuf *ob) return EINA_FALSE; } -//TODO: Need to split below evas_drm_... apis -Eina_Bool evas_drm_init(Evas_Engine_Info_GL_Drm *info); -Eina_Bool evas_drm_shutdown(Evas_Engine_Info_GL_Drm *info); Eina_Bool evas_drm_gbm_init(Evas_Engine_Info_GL_Drm *info, int w, int h); Eina_Bool evas_drm_gbm_shutdown(Evas_Engine_Info_GL_Drm *info); Eina_Bool evas_drm_outbuf_setup(Outbuf *ob);