#include "ecore_drm_private.h"
#include <dlfcn.h>
+#ifdef HAVE_TDM
+#include <tdm_helper.h>
+#endif
+
#define INSIDE(x, y, xx, yy, ww, hh) \
(((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && \
((x) >= (xx)) && ((y) >= (yy)))
{
#ifdef HAVE_TDM
int events = 0;
- drmVersionPtr ver;
/* check for valid device */
if ((!dev) || (!dev->drm.name)) return EINA_FALSE;
return EINA_FALSE;
}
- if ((ver = drmGetVersion(ecore_drm_device_fd_get(dev))))
+ /* TDM backend will set a drm master fd to TDM_DRM_MASTER_FD. */
+ dev->drm.fd = tdm_helper_get_fd("TDM_DRM_MASTER_FD");
+ if (dev->drm.fd < 0)
{
- drmFreeVersion(ver);
- dev->drm.fd = ecore_drm_device_fd_get(dev);
+ ERR("failed: no drm master fd");
+
+ /* If not set, use a tdm display fd instead of a drm master fd. */
+ dev->drm.fd = _ecore_drm_display_get_fd(dev);
}
/* try to create xkb context */
if (dev->drm.hdlr) ecore_main_fd_handler_del(dev->drm.hdlr);
dev->drm.hdlr = NULL;
-#ifdef HAVE_TDM
- /* when we use TDM, dev->drm.fd comes from TDM. It will close in TDM. */
- dev->drm.fd = -1;
-#endif
_ecore_drm_launcher_device_close(dev->drm.name, dev->drm.fd);
_ecore_drm_display_destroy(dev);
{
EINA_SAFETY_ON_NULL_RETURN_VAL(dev, -1);
-#ifdef HAVE_TDM
- return _ecore_drm_display_get_fd(dev);
-#endif
-
return dev->drm.fd;
}
_ecore_drm_display_init(Ecore_Drm_Device *dev)
{
Ecore_Drm_Hal_Display *hal_display;
+ int fd;
EINA_SAFETY_ON_NULL_RETURN_VAL(dev, EINA_FALSE);
goto fail_init;
hal_display->fd = -1;
- tdm_display_get_fd(hal_display->display, &hal_display->fd);
- if (hal_display->fd < 0)
+ tdm_display_get_fd(hal_display->display, &fd);
+ if (fd < 0)
goto fail_fd;
+ hal_display->fd = dup(fd);
+
hal_display->hdlr =
ecore_main_fd_handler_add(hal_display->fd, ECORE_FD_READ,
_ecore_drm_display_cb_event, hal_display, NULL, NULL);
return EINA_TRUE;
fail_hdlr:
+ if (hal_display->fd >= 0)
+ close(hal_display->fd);
+
+ hal_display->fd = -1;
fail_fd:
tdm_display_deinit(hal_display->display);
fail_init:
if (hal_display->hdlr) ecore_main_fd_handler_del(hal_display->hdlr);
tdm_display_deinit(hal_display->display);
+ if (hal_display->fd >= 0)
+ close(hal_display->fd);
+
free(hal_display);
dev->hal_display = NULL;
}