summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-02-10 17:26:24 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-02-10 17:42:01 +0900
commit2450a249e7c8bc41a8b7e101df2bed155dc58222 (patch)
treedaf0ed6f69f011aa14bdee7a900394c5150ce7ff /src/modules
parent21bc9bee48f06d73e81cac6050b8fe558843e1b6 (diff)
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.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/evas/engines/software_x11/evas_xlib_swapper.c82
1 files 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 57101283e4..bb05dd6b8b 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)
300#else 300#else
301 301
302 302
303
304
305
306
307
308
309// DRM/DRI buffer swapping+access (driver specific) ///////////////////// 303// DRM/DRI buffer swapping+access (driver specific) /////////////////////
310 304
311static Eina_Bool tried = EINA_FALSE; 305static Eina_Bool tried = EINA_FALSE;
@@ -335,12 +329,19 @@ typedef union _tbm_bo_handle
335 uint64_t u64; 329 uint64_t u64;
336} tbm_bo_handle; 330} tbm_bo_handle;
337 331
332
338static tbm_bo (*sym_tbm_bo_import) (tbm_bufmgr bufmgr, unsigned int key) = NULL; 333static tbm_bo (*sym_tbm_bo_import) (tbm_bufmgr bufmgr, unsigned int key) = NULL;
339static tbm_bo_handle (*sym_tbm_bo_map) (tbm_bo bo, int device, int opt) = NULL; 334static tbm_bo_handle (*sym_tbm_bo_map) (tbm_bo bo, int device, int opt) = NULL;
340static int (*sym_tbm_bo_unmap) (tbm_bo bo) = NULL; 335static int (*sym_tbm_bo_unmap) (tbm_bo bo) = NULL;
341static void (*sym_tbm_bo_unref) (tbm_bo bo) = NULL; 336static void (*sym_tbm_bo_unref) (tbm_bo bo) = NULL;
342static tbm_bufmgr (*sym_tbm_bufmgr_init) (int fd) = NULL; 337static tbm_bufmgr (*sym_tbm_bufmgr_init) (int fd) = NULL;
343static void (*sym_tbm_bufmgr_deinit) (tbm_bufmgr bufmgr) = NULL; 338static void (*sym_tbm_bufmgr_deinit) (tbm_bufmgr bufmgr) = NULL;
339
340// legacy compatibility
341static void *(*sym_drm_slp_bo_map) (tbm_bo bo, int device, int opt) = NULL;
342static int (*sym_drm_slp_bo_unmap) (tbm_bo bo, int device) = NULL;
343static tbm_bufmgr (*sym_drm_slp_bufmgr_init) (int fd, void *arg) = NULL;
344
344//////////////////////////////////// 345////////////////////////////////////
345// libdri2.so.0 346// libdri2.so.0
346#define DRI2BufferBackLeft 1 347#define DRI2BufferBackLeft 1
@@ -400,7 +401,7 @@ static void (*sym_XFixesDestroyRegion) (Display *dpy, XID region) = NULL;
400typedef struct 401typedef struct
401{ 402{
402 unsigned int name; 403 unsigned int name;
403 tbm_bo buf_bo; 404 tbm_bo buf_bo;
404} Buffer; 405} Buffer;
405 406
406struct _X_Swapper 407struct _X_Swapper
@@ -409,7 +410,7 @@ struct _X_Swapper
409 Drawable draw; 410 Drawable draw;
410 Visual *vis; 411 Visual *vis;
411 int w, h, depth; 412 int w, h, depth;
412 tbm_bo buf_bo; 413 tbm_bo buf_bo;
413 DRI2Buffer *buf; 414 DRI2Buffer *buf;
414 void *buf_data; 415 void *buf_data;
415 int buf_w, buf_h; 416 int buf_w, buf_h;
@@ -426,6 +427,7 @@ static int dri2_major = 0, dri2_minor = 0;
426static int drm_fd = -1; 427static int drm_fd = -1;
427static tbm_bufmgr bufmgr = NULL; 428static tbm_bufmgr bufmgr = NULL;
428static int swap_debug = -1; 429static int swap_debug = -1;
430static Eina_Bool slp_mode = EINA_FALSE;
429 431
430static Eina_Bool 432static Eina_Bool
431_drm_init(Display *disp, int scr) 433_drm_init(Display *disp, int scr)
@@ -448,11 +450,14 @@ _drm_init(Display *disp, int scr)
448 if (swap_debug) ERR("Can't load libdrm.so.2"); 450 if (swap_debug) ERR("Can't load libdrm.so.2");
449 goto err; 451 goto err;
450 } 452 }
453 slp_mode = EINA_FALSE;
451 tbm_lib = dlopen("libtbm.so.1", RTLD_NOW | RTLD_LOCAL); 454 tbm_lib = dlopen("libtbm.so.1", RTLD_NOW | RTLD_LOCAL);
452 if (!tbm_lib) 455 if (!tbm_lib)
453 { 456 {
454 if (swap_debug) ERR("Can't load libtbm.so.1"); 457 if (swap_debug) ERR("Can't load libtbm.so.1");
455 goto err; 458 tbm_lib = dlopen("libdrm_slp.so.1", RTLD_NOW | RTLD_LOCAL);
459 if (tbm_lib) slp_mode = EINA_TRUE;
460 else goto err;
456 } 461 }
457 dri_lib = dlopen("libdri2.so.0", RTLD_NOW | RTLD_LOCAL); 462 dri_lib = dlopen("libdri2.so.0", RTLD_NOW | RTLD_LOCAL);
458 if (!dri_lib) 463 if (!dri_lib)
@@ -477,12 +482,32 @@ _drm_init(Display *disp, int scr)
477 482
478 SYM(drm_lib, drmGetMagic); 483 SYM(drm_lib, drmGetMagic);
479 484
480 SYM(tbm_lib, tbm_bo_import); 485 if (!slp_mode)
481 SYM(tbm_lib, tbm_bo_map); 486 {
482 SYM(tbm_lib, tbm_bo_unmap); 487 SYM(tbm_lib, tbm_bo_import);
483 SYM(tbm_lib, tbm_bo_unref); 488 SYM(tbm_lib, tbm_bo_map);
484 SYM(tbm_lib, tbm_bufmgr_init); 489 SYM(tbm_lib, tbm_bo_unmap);
485 SYM(tbm_lib, tbm_bufmgr_deinit); 490 SYM(tbm_lib, tbm_bo_unref);
491 SYM(tbm_lib, tbm_bufmgr_init);
492 SYM(tbm_lib, tbm_bufmgr_deinit);
493 }
494 else
495 {
496 // Looking up the legacy DRM SLP symbols. I don't believe this will
497 // ever happen, this code is here "just in case".
498 sym_tbm_bo_import = dlsym(tbm_lib, "drm_slp_bo_import");
499 sym_drm_slp_bo_map = dlsym(tbm_lib, "drm_slp_bo_map");
500 sym_drm_slp_bo_unmap = dlsym(tbm_lib, "drm_slp_bo_unmap");
501 sym_tbm_bo_unref = dlsym(tbm_lib, "drm_slp_bo_unref");
502 sym_drm_slp_bufmgr_init = dlsym(tbm_lib, "drm_slp_bufmgr_init");
503 sym_tbm_bufmgr_deinit = dlsym(tbm_lib, "drm_slp_bufmgr_destroy");
504 if (!sym_tbm_bo_import || !sym_drm_slp_bo_map || !sym_drm_slp_bo_unmap ||
505 !sym_tbm_bo_unref || !sym_drm_slp_bufmgr_init || !sym_tbm_bufmgr_deinit)
506 {
507 ERR("Can't load symbols from libdrm_slp.so.1");
508 goto err;
509 }
510 }
486 511
487 SYM(dri_lib, DRI2GetBuffers); 512 SYM(dri_lib, DRI2GetBuffers);
488 SYM(dri_lib, DRI2QueryExtension); 513 SYM(dri_lib, DRI2QueryExtension);
@@ -545,7 +570,11 @@ _drm_init(Display *disp, int scr)
545 goto err; 570 goto err;
546 } 571 }
547 572
548 if (!(bufmgr = sym_tbm_bufmgr_init(drm_fd))) 573 if (!slp_mode)
574 bufmgr = sym_tbm_bufmgr_init(drm_fd);
575 else
576 bufmgr = sym_drm_slp_bufmgr_init(drm_fd, NULL);
577 if (!bufmgr)
549 { 578 {
550 if (swap_debug) ERR("DRM bufmgr init failed"); 579 if (swap_debug) ERR("DRM bufmgr init failed");
551 goto err; 580 goto err;
@@ -757,11 +786,17 @@ evas_xlib_swapper_buffer_map(X_Swapper *swp, int *bpl, int *w, int *h)
757 } 786 }
758 } 787 }
759 788
760 tbm_bo_handle bo_handle; 789 if (!slp_mode)
761 790 {
762 bo_handle = sym_tbm_bo_map (swp->buf_bo, TBM_DEVICE_CPU, TBM_OPTION_READ | TBM_OPTION_WRITE); 791 tbm_bo_handle bo_handle;
763 /* If device is DEFAULT, 2D, 3D, MM,then swp->buf_data = bo_handle.u32 */ 792 bo_handle = sym_tbm_bo_map(swp->buf_bo, TBM_DEVICE_CPU, TBM_OPTION_READ | TBM_OPTION_WRITE);
764 swp->buf_data = bo_handle.ptr; 793 /* If device is DEFAULT, 2D, 3D, MM,then swp->buf_data = bo_handle.u32 */
794 swp->buf_data = bo_handle.ptr;
795 }
796 else
797 {
798 swp->buf_data = sym_drm_slp_bo_map(swp->buf_bo, TBM_DEVICE_CPU, TBM_OPTION_READ | TBM_OPTION_WRITE);
799 }
765 800
766 if (!swp->buf_data) 801 if (!swp->buf_data)
767 { 802 {
@@ -786,7 +821,10 @@ void
786evas_xlib_swapper_buffer_unmap(X_Swapper *swp) 821evas_xlib_swapper_buffer_unmap(X_Swapper *swp)
787{ 822{
788 if (!swp->mapped) return; 823 if (!swp->mapped) return;
789 sym_tbm_bo_unmap(swp->buf_bo); 824 if (!slp_mode)
825 sym_tbm_bo_unmap(swp->buf_bo);
826 else
827 sym_drm_slp_bo_unmap(swp->buf_bo, TBM_DEVICE_CPU);
790 if (swap_debug) printf("Unmap buffer name %i\n", swp->buf->name); 828 if (swap_debug) printf("Unmap buffer name %i\n", swp->buf->name);
791 free(swp->buf); 829 free(swp->buf);
792 swp->buf = NULL; 830 swp->buf = NULL;