Revert "evas/drm: Make use of ecore_drm for opening DRM device"

This reverts commit 31ad73efa9.

Conflicts:
	src/modules/evas/engines/drm/evas_engine.c

Revert this commit as these functions are needed to run evas engine
standalone (expedite) on drm
This commit is contained in:
Chris Michael 2014-07-08 12:08:14 -04:00
parent e2ad7a18f9
commit ea8ffdf433
3 changed files with 103 additions and 7 deletions

View File

@ -1207,11 +1207,9 @@ modules_evas_engines_drm_module_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
-I$(top_srcdir)/src/lib/evas/include \
-I$(top_srcdir)/src/lib/evas/cserve2 \
@EVAS_CFLAGS@ \
@ECORE_DRM_CFLAGS@ \
@evas_engine_drm_cflags@
modules_evas_engines_drm_module_la_LIBADD = \
@USE_EVAS_LIBS@ \
@ECORE_DRM_LIBS@ \
@evas_engine_drm_libs@
modules_evas_engines_drm_module_la_DEPENDENCIES = @USE_EVAS_INTERNAL_LIBS@
modules_evas_engines_drm_module_la_LDFLAGS = -module @EFL_LTMODULE_FLAGS@

View File

@ -2,12 +2,90 @@
#include <linux/vt.h>
#include <linux/kd.h>
#include <sys/mman.h>
#include <Ecore_Drm.h>
/* NB: REALLY hate to store this here, but sigaction signal handlers cannot
* pass any 'user data' to the signal handlers :( */
static Evas_Engine_Info_Drm *siginfo;
static char *
_evas_drm_card_driver_get(const char *dev)
{
struct stat st;
int maj, min;
char *path, path_link[PATH_MAX + 1] = "";
char *drv;
if (stat(dev, &st) < 0) return NULL;
if (!S_ISCHR(st.st_mode)) return NULL;
maj = major(st.st_rdev);
min = minor(st.st_rdev);
asprintf(&path, "/sys/dev/char/%d:%d/device/driver", maj, min);
if (readlink(path, path_link, sizeof(path_link) - 1) < 0)
{
free(path);
return NULL;
}
free(path);
if (!(drv = strrchr(path_link, '/'))) return NULL;
return strdup(drv + strlen("/"));
}
static int
_evas_drm_card_open(int card)
{
char dev[32], *driver;
int fd = -1;
uint64_t dumb;
sprintf(dev, DRM_DEV_NAME, DRM_DIR_NAME, card);
driver = _evas_drm_card_driver_get(dev);
DBG("Drm Device Driver: %s", driver);
if ((fd = drmOpen(driver, NULL)) < 0)
{
CRI("Could not open drm device %s: %m", dev);
return -1;
}
/* if ((fd = open(dev, (O_RDWR | O_CLOEXEC))) < 0) */
/* { */
/* CRI("Could not open drm device %s: %m", dev); */
/* return -1; */
/* } */
/* drmVersionPtr ver; */
/* if ((ver = drmGetVersion(fd))) */
/* { */
/* DBG("Drm Driver Name: %s", ver->name); */
/* drmFreeVersion(ver); */
/* } */
/* check for dumb buffer support
*
* NB: This checks that we can at least support software rendering */
if ((drmGetCap(fd, DRM_CAP_DUMB_BUFFER, &dumb) < 0) || (!dumb))
{
CRI("Drm Device %s does not support software rendering", dev);
/* close the card */
close(fd);
/* return failure */
return -1;
}
DBG("Opened Drm Card %s: %d", dev, fd);
/* return opened card */
return fd;
}
static int
_evas_drm_tty_open(Evas_Engine_Info_Drm *info)
{
@ -308,15 +386,26 @@ _evas_drm_outbuf_planes_setup(Outbuf *ob, drmModePlaneResPtr pres)
return EINA_TRUE;
}
Eina_Bool
evas_drm_init(Evas_Engine_Info_Drm *info)
Eina_Bool
evas_drm_init(Evas_Engine_Info_Drm *info, int card)
{
/* check for valid engine info */
if (!info) return EINA_FALSE;
setvbuf(stdout, NULL, _IONBF, 0);
/* check if we already opened the card */
if (info->info.fd < 0)
{
/* try to open the drm card */
if ((info->info.fd = _evas_drm_card_open(card)) < 0)
return EINA_FALSE;
/* set flag to indicate that evas opened the card and we should
* be the one to close it */
info->info.own_fd = EINA_TRUE;
}
/* check if we already opened the tty */
if (info->info.tty < 0)
{
@ -341,6 +430,8 @@ evas_drm_init(Evas_Engine_Info_Drm *info)
if ((info->info.tty >= 0) && (info->info.own_tty))
close(info->info.tty);
/* FIXME: Close card also ?? */
return EINA_FALSE;
}
@ -360,6 +451,13 @@ evas_drm_shutdown(Evas_Engine_Info_Drm *info)
info->info.tty = -1;
}
/* 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_TRUE;
}

View File

@ -128,7 +128,7 @@ void evas_outbuf_update_region_push(Outbuf *ob, RGBA_Image *update, int x, int y
void evas_outbuf_update_region_free(Outbuf *ob, RGBA_Image *update);
void evas_outbuf_flush(Outbuf *ob, Tilebuf_Rect *rects, Evas_Render_Mode render_mode);
Eina_Bool evas_drm_init(Evas_Engine_Info_Drm *info);
Eina_Bool evas_drm_init(Evas_Engine_Info_Drm *info, int card);
Eina_Bool evas_drm_shutdown(Evas_Engine_Info_Drm *info);
Eina_Bool evas_drm_outbuf_setup(Outbuf *ob);