From 2450a249e7c8bc41a8b7e101df2bed155dc58222 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Tue, 10 Feb 2015 17:26:24 +0900 Subject: [PATCH] evas/software_x11: Restore legacy compatibility with old SLP DRM I really REAAALLLY doubt that was necessary, but I'm still adding these few changes for legacy compatibility. This lib seriously should have had a stable API. --- .../evas/engines/software_x11/evas_xlib_swapper.c | 82 ++++++++++++++++------ 1 file changed, 60 insertions(+), 22 deletions(-) diff --git a/src/modules/evas/engines/software_x11/evas_xlib_swapper.c b/src/modules/evas/engines/software_x11/evas_xlib_swapper.c index 5710128..bb05dd6 100644 --- a/src/modules/evas/engines/software_x11/evas_xlib_swapper.c +++ b/src/modules/evas/engines/software_x11/evas_xlib_swapper.c @@ -300,12 +300,6 @@ evas_xlib_swapper_bit_order_get(X_Swapper *swp) #else - - - - - - // DRM/DRI buffer swapping+access (driver specific) ///////////////////// static Eina_Bool tried = EINA_FALSE; @@ -335,12 +329,19 @@ typedef union _tbm_bo_handle uint64_t u64; } tbm_bo_handle; + static tbm_bo (*sym_tbm_bo_import) (tbm_bufmgr bufmgr, unsigned int key) = NULL; static tbm_bo_handle (*sym_tbm_bo_map) (tbm_bo bo, int device, int opt) = NULL; static int (*sym_tbm_bo_unmap) (tbm_bo bo) = NULL; static void (*sym_tbm_bo_unref) (tbm_bo bo) = NULL; static tbm_bufmgr (*sym_tbm_bufmgr_init) (int fd) = NULL; static void (*sym_tbm_bufmgr_deinit) (tbm_bufmgr bufmgr) = NULL; + +// legacy compatibility +static void *(*sym_drm_slp_bo_map) (tbm_bo bo, int device, int opt) = NULL; +static int (*sym_drm_slp_bo_unmap) (tbm_bo bo, int device) = NULL; +static tbm_bufmgr (*sym_drm_slp_bufmgr_init) (int fd, void *arg) = NULL; + //////////////////////////////////// // libdri2.so.0 #define DRI2BufferBackLeft 1 @@ -400,7 +401,7 @@ static void (*sym_XFixesDestroyRegion) (Display *dpy, XID region) = NULL; typedef struct { unsigned int name; - tbm_bo buf_bo; + tbm_bo buf_bo; } Buffer; struct _X_Swapper @@ -409,7 +410,7 @@ struct _X_Swapper Drawable draw; Visual *vis; int w, h, depth; - tbm_bo buf_bo; + tbm_bo buf_bo; DRI2Buffer *buf; void *buf_data; int buf_w, buf_h; @@ -426,6 +427,7 @@ static int dri2_major = 0, dri2_minor = 0; static int drm_fd = -1; static tbm_bufmgr bufmgr = NULL; static int swap_debug = -1; +static Eina_Bool slp_mode = EINA_FALSE; static Eina_Bool _drm_init(Display *disp, int scr) @@ -448,11 +450,14 @@ _drm_init(Display *disp, int scr) if (swap_debug) ERR("Can't load libdrm.so.2"); goto err; } + slp_mode = EINA_FALSE; tbm_lib = dlopen("libtbm.so.1", RTLD_NOW | RTLD_LOCAL); if (!tbm_lib) { if (swap_debug) ERR("Can't load libtbm.so.1"); - goto err; + tbm_lib = dlopen("libdrm_slp.so.1", RTLD_NOW | RTLD_LOCAL); + if (tbm_lib) slp_mode = EINA_TRUE; + else goto err; } dri_lib = dlopen("libdri2.so.0", RTLD_NOW | RTLD_LOCAL); if (!dri_lib) @@ -477,12 +482,32 @@ _drm_init(Display *disp, int scr) SYM(drm_lib, drmGetMagic); - SYM(tbm_lib, tbm_bo_import); - SYM(tbm_lib, tbm_bo_map); - SYM(tbm_lib, tbm_bo_unmap); - SYM(tbm_lib, tbm_bo_unref); - SYM(tbm_lib, tbm_bufmgr_init); - SYM(tbm_lib, tbm_bufmgr_deinit); + if (!slp_mode) + { + SYM(tbm_lib, tbm_bo_import); + SYM(tbm_lib, tbm_bo_map); + SYM(tbm_lib, tbm_bo_unmap); + SYM(tbm_lib, tbm_bo_unref); + SYM(tbm_lib, tbm_bufmgr_init); + SYM(tbm_lib, tbm_bufmgr_deinit); + } + else + { + // Looking up the legacy DRM SLP symbols. I don't believe this will + // ever happen, this code is here "just in case". + sym_tbm_bo_import = dlsym(tbm_lib, "drm_slp_bo_import"); + sym_drm_slp_bo_map = dlsym(tbm_lib, "drm_slp_bo_map"); + sym_drm_slp_bo_unmap = dlsym(tbm_lib, "drm_slp_bo_unmap"); + sym_tbm_bo_unref = dlsym(tbm_lib, "drm_slp_bo_unref"); + sym_drm_slp_bufmgr_init = dlsym(tbm_lib, "drm_slp_bufmgr_init"); + sym_tbm_bufmgr_deinit = dlsym(tbm_lib, "drm_slp_bufmgr_destroy"); + if (!sym_tbm_bo_import || !sym_drm_slp_bo_map || !sym_drm_slp_bo_unmap || + !sym_tbm_bo_unref || !sym_drm_slp_bufmgr_init || !sym_tbm_bufmgr_deinit) + { + ERR("Can't load symbols from libdrm_slp.so.1"); + goto err; + } + } SYM(dri_lib, DRI2GetBuffers); SYM(dri_lib, DRI2QueryExtension); @@ -545,7 +570,11 @@ _drm_init(Display *disp, int scr) goto err; } - if (!(bufmgr = sym_tbm_bufmgr_init(drm_fd))) + if (!slp_mode) + bufmgr = sym_tbm_bufmgr_init(drm_fd); + else + bufmgr = sym_drm_slp_bufmgr_init(drm_fd, NULL); + if (!bufmgr) { if (swap_debug) ERR("DRM bufmgr init failed"); goto err; @@ -757,11 +786,17 @@ evas_xlib_swapper_buffer_map(X_Swapper *swp, int *bpl, int *w, int *h) } } - tbm_bo_handle bo_handle; - - bo_handle = sym_tbm_bo_map (swp->buf_bo, TBM_DEVICE_CPU, TBM_OPTION_READ | TBM_OPTION_WRITE); - /* If device is DEFAULT, 2D, 3D, MM,then swp->buf_data = bo_handle.u32 */ - swp->buf_data = bo_handle.ptr; + if (!slp_mode) + { + tbm_bo_handle bo_handle; + bo_handle = sym_tbm_bo_map(swp->buf_bo, TBM_DEVICE_CPU, TBM_OPTION_READ | TBM_OPTION_WRITE); + /* If device is DEFAULT, 2D, 3D, MM,then swp->buf_data = bo_handle.u32 */ + swp->buf_data = bo_handle.ptr; + } + else + { + swp->buf_data = sym_drm_slp_bo_map(swp->buf_bo, TBM_DEVICE_CPU, TBM_OPTION_READ | TBM_OPTION_WRITE); + } if (!swp->buf_data) { @@ -786,7 +821,10 @@ void evas_xlib_swapper_buffer_unmap(X_Swapper *swp) { if (!swp->mapped) return; - sym_tbm_bo_unmap(swp->buf_bo); + if (!slp_mode) + sym_tbm_bo_unmap(swp->buf_bo); + else + sym_drm_slp_bo_unmap(swp->buf_bo, TBM_DEVICE_CPU); if (swap_debug) printf("Unmap buffer name %i\n", swp->buf->name); free(swp->buf); swp->buf = NULL; -- 2.7.4