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

We use this functionality already from ecore_drm. The evas version does
not even use udev to acquire the device which means we could not support
hotplugging. The only missing feature was the capability check for
DUMB_BUFFER which I added to ecore_drm now.
This commit is contained in:
Stefan Schmidt 2014-06-27 16:21:32 +02:00
parent 5a9e47d0fd
commit 31ad73efa9
4 changed files with 8 additions and 104 deletions

View File

@ -1211,9 +1211,11 @@ 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,90 +2,12 @@
#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)
{
@ -386,26 +308,15 @@ _evas_drm_outbuf_planes_setup(Outbuf *ob, drmModePlaneResPtr pres)
return EINA_TRUE;
}
Eina_Bool
evas_drm_init(Evas_Engine_Info_Drm *info, int card)
Eina_Bool
evas_drm_init(Evas_Engine_Info_Drm *info)
{
/* 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)
{
@ -430,8 +341,6 @@ evas_drm_init(Evas_Engine_Info_Drm *info, int card)
if ((info->info.tty >= 0) && (info->info.own_tty))
close(info->info.tty);
/* FIXME: Close card also ?? */
return EINA_FALSE;
}
@ -451,13 +360,6 @@ 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

@ -54,7 +54,7 @@ _output_setup(Evas_Engine_Info_Drm *info, int w, int h, int swap)
if (info->info.fd < 0)
{
/* try to init drm (this includes openening the card & tty) */
if (!evas_drm_init(info, 0))
if (!evas_drm_init(info))
{
if (re->tb) evas_common_tilebuf_free(re->tb);
free(re);

View File

@ -136,7 +136,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);
Eina_Bool evas_drm_init(Evas_Engine_Info_Drm *info, int card);
Eina_Bool evas_drm_init(Evas_Engine_Info_Drm *info);
Eina_Bool evas_drm_shutdown(Evas_Engine_Info_Drm *info);
Eina_Bool evas_drm_outbuf_setup(Outbuf *ob);