summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorDongyeon Kim <dy5.kim@samsung.com>2015-02-10 17:00:54 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-02-10 17:05:06 +0900
commit21bc9bee48f06d73e81cac6050b8fe558843e1b6 (patch)
tree5a1cd5d3aa7edc1b461355b1061943d4c35ed079 /src/modules
parent47026701460e30a9f1b34e857372724d3d12dc0b (diff)
evas/software_x11: replace drm_slp with tbm
Summary: libdrm_slp has been replaced with libtbm, so modify xlib swapper to use tbm apis instead of drm_slp apis Test Plan: Local tests Reviewers: raster, Hermet, cedric, jpeg Reviewed By: jpeg Subscribers: cedric, wonsik Differential Revision: https://phab.enlightenment.org/D1932 Signed-off-by: Jean-Philippe Andre <jp.andre@samsung.com>
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/evas/engines/software_x11/evas_xlib_swapper.c116
1 files changed, 56 insertions, 60 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 af4c430229..57101283e4 100644
--- a/src/modules/evas/engines/software_x11/evas_xlib_swapper.c
+++ b/src/modules/evas/engines/software_x11/evas_xlib_swapper.c
@@ -306,19 +306,6 @@ evas_xlib_swapper_bit_order_get(X_Swapper *swp)
306 306
307 307
308 308
309
310
311
312
313
314
315
316
317
318
319
320
321
322// DRM/DRI buffer swapping+access (driver specific) ///////////////////// 309// DRM/DRI buffer swapping+access (driver specific) /////////////////////
323 310
324static Eina_Bool tried = EINA_FALSE; 311static Eina_Bool tried = EINA_FALSE;
@@ -330,23 +317,30 @@ typedef unsigned int drm_magic_t;
330static int (*sym_drmGetMagic) (int fd, drm_magic_t *magic) = NULL; 317static int (*sym_drmGetMagic) (int fd, drm_magic_t *magic) = NULL;
331 318
332//////////////////////////////////// 319////////////////////////////////////
333// libdrm_slp.so.1 320// libtbm.so.1
334#define DRM_SLP_DEVICE_CPU 1 321#define TBM_DEVICE_CPU 1
335#define DRM_SLP_OPTION_READ (1 << 0) 322#define TBM_OPTION_READ (1 << 0)
336#define DRM_SLP_OPTION_WRITE (1 << 1) 323#define TBM_OPTION_WRITE (1 << 1)
337static void *drm_slp_lib = NULL; 324static void *tbm_lib = NULL;
338 325
339typedef struct _drm_slp_bufmgr *drm_slp_bufmgr; 326typedef struct _tbm_bufmgr *tbm_bufmgr;
340typedef struct _drm_slp_bo *drm_slp_bo; 327typedef struct _tbm_bo *tbm_bo;
341static drm_slp_bo (*sym_drm_slp_bo_import) (drm_slp_bufmgr bufmgr, unsigned int key) = NULL; 328
342// XXXX: sym_drm_slp_bo_map() is incorrectly defined - it SHOULD return a 329typedef union _tbm_bo_handle
343// void * at least 330{
344static void *(*sym_drm_slp_bo_map) (drm_slp_bo bo, int device, int opt) = NULL; 331 void *ptr;
345static int (*sym_drm_slp_bo_unmap) (drm_slp_bo bo, int device) = NULL; 332 int32_t s32;
346static void (*sym_drm_slp_bo_unref) (drm_slp_bo bo) = NULL; 333 uint32_t u32;
347static drm_slp_bufmgr (*sym_drm_slp_bufmgr_init) (int fd, void *arg) = NULL; 334 int64_t s64;
348static void (*sym_drm_slp_bufmgr_destroy) (drm_slp_bufmgr bufmgr) = NULL; 335 uint64_t u64;
349 336} tbm_bo_handle;
337
338static 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;
340static int (*sym_tbm_bo_unmap) (tbm_bo bo) = NULL;
341static void (*sym_tbm_bo_unref) (tbm_bo bo) = NULL;
342static tbm_bufmgr (*sym_tbm_bufmgr_init) (int fd) = NULL;
343static void (*sym_tbm_bufmgr_deinit) (tbm_bufmgr bufmgr) = NULL;
350//////////////////////////////////// 344////////////////////////////////////
351// libdri2.so.0 345// libdri2.so.0
352#define DRI2BufferBackLeft 1 346#define DRI2BufferBackLeft 1
@@ -406,7 +400,7 @@ static void (*sym_XFixesDestroyRegion) (Display *dpy, XID region) = NULL;
406typedef struct 400typedef struct
407{ 401{
408 unsigned int name; 402 unsigned int name;
409 drm_slp_bo buf_bo; 403 tbm_bo buf_bo;
410} Buffer; 404} Buffer;
411 405
412struct _X_Swapper 406struct _X_Swapper
@@ -415,7 +409,7 @@ struct _X_Swapper
415 Drawable draw; 409 Drawable draw;
416 Visual *vis; 410 Visual *vis;
417 int w, h, depth; 411 int w, h, depth;
418 drm_slp_bo buf_bo; 412 tbm_bo buf_bo;
419 DRI2Buffer *buf; 413 DRI2Buffer *buf;
420 void *buf_data; 414 void *buf_data;
421 int buf_w, buf_h; 415 int buf_w, buf_h;
@@ -430,7 +424,7 @@ static int xfixes_major = 0, xfixes_minor = 0;
430static int dri2_ev_base = 0, dri2_err_base = 0; 424static int dri2_ev_base = 0, dri2_err_base = 0;
431static int dri2_major = 0, dri2_minor = 0; 425static int dri2_major = 0, dri2_minor = 0;
432static int drm_fd = -1; 426static int drm_fd = -1;
433static drm_slp_bufmgr bufmgr = NULL; 427static tbm_bufmgr bufmgr = NULL;
434static int swap_debug = -1; 428static int swap_debug = -1;
435 429
436static Eina_Bool 430static Eina_Bool
@@ -454,10 +448,10 @@ _drm_init(Display *disp, int scr)
454 if (swap_debug) ERR("Can't load libdrm.so.2"); 448 if (swap_debug) ERR("Can't load libdrm.so.2");
455 goto err; 449 goto err;
456 } 450 }
457 drm_slp_lib = dlopen("libdrm_slp.so.1", RTLD_NOW | RTLD_LOCAL); 451 tbm_lib = dlopen("libtbm.so.1", RTLD_NOW | RTLD_LOCAL);
458 if (!drm_slp_lib) 452 if (!tbm_lib)
459 { 453 {
460 if (swap_debug) ERR("Can't load libdrm_slp.so.1"); 454 if (swap_debug) ERR("Can't load libtbm.so.1");
461 goto err; 455 goto err;
462 } 456 }
463 dri_lib = dlopen("libdri2.so.0", RTLD_NOW | RTLD_LOCAL); 457 dri_lib = dlopen("libdri2.so.0", RTLD_NOW | RTLD_LOCAL);
@@ -483,12 +477,12 @@ _drm_init(Display *disp, int scr)
483 477
484 SYM(drm_lib, drmGetMagic); 478 SYM(drm_lib, drmGetMagic);
485 479
486 SYM(drm_slp_lib, drm_slp_bo_import); 480 SYM(tbm_lib, tbm_bo_import);
487 SYM(drm_slp_lib, drm_slp_bo_map); 481 SYM(tbm_lib, tbm_bo_map);
488 SYM(drm_slp_lib, drm_slp_bo_unmap); 482 SYM(tbm_lib, tbm_bo_unmap);
489 SYM(drm_slp_lib, drm_slp_bo_unref); 483 SYM(tbm_lib, tbm_bo_unref);
490 SYM(drm_slp_lib, drm_slp_bufmgr_init); 484 SYM(tbm_lib, tbm_bufmgr_init);
491 SYM(drm_slp_lib, drm_slp_bufmgr_destroy); 485 SYM(tbm_lib, tbm_bufmgr_deinit);
492 486
493 SYM(dri_lib, DRI2GetBuffers); 487 SYM(dri_lib, DRI2GetBuffers);
494 SYM(dri_lib, DRI2QueryExtension); 488 SYM(dri_lib, DRI2QueryExtension);
@@ -551,7 +545,7 @@ _drm_init(Display *disp, int scr)
551 goto err; 545 goto err;
552 } 546 }
553 547
554 if (!(bufmgr = sym_drm_slp_bufmgr_init(drm_fd, NULL))) 548 if (!(bufmgr = sym_tbm_bufmgr_init(drm_fd)))
555 { 549 {
556 if (swap_debug) ERR("DRM bufmgr init failed"); 550 if (swap_debug) ERR("DRM bufmgr init failed");
557 goto err; 551 goto err;
@@ -570,10 +564,10 @@ err:
570 dlclose(drm_lib); 564 dlclose(drm_lib);
571 drm_lib = NULL; 565 drm_lib = NULL;
572 } 566 }
573 if (drm_slp_lib) 567 if (tbm_lib)
574 { 568 {
575 dlclose(drm_slp_lib); 569 dlclose(tbm_lib);
576 drm_slp_lib = NULL; 570 tbm_lib = NULL;
577 } 571 }
578 if (dri_lib) 572 if (dri_lib)
579 { 573 {
@@ -601,13 +595,13 @@ _drm_shutdown(void)
601/* 595/*
602 if (bufmgr) 596 if (bufmgr)
603 { 597 {
604 sym_drm_slp_bufmgr_destroy(bufmgr); 598 sym_tbm_bufmgr_deinit(bufmgr);
605 bufmgr = NULL; 599 bufmgr = NULL;
606 } 600 }
607 if (drm_fd >= 0) close(drm_fd); 601 if (drm_fd >= 0) close(drm_fd);
608 drm_fd = -1; 602 drm_fd = -1;
609 dlclose(drm_slp_lib); 603 dlclose(tbm_lib);
610 drm_slp_lib = NULL; 604 tbm_lib = NULL;
611 dlclose(dri_lib); 605 dlclose(dri_lib);
612 dri_lib = NULL; 606 dri_lib = NULL;
613 dlclose(xfixes_lib); 607 dlclose(xfixes_lib);
@@ -675,7 +669,7 @@ evas_xlib_swapper_free(X_Swapper *swp)
675 EINA_LIST_FREE(swp->buf_cache, b) 669 EINA_LIST_FREE(swp->buf_cache, b)
676 { 670 {
677 if (swap_debug) printf("Cached buf name %i freed\n", b->name); 671 if (swap_debug) printf("Cached buf name %i freed\n", b->name);
678 sym_drm_slp_bo_unref(b->buf_bo); 672 sym_tbm_bo_unref(b->buf_bo);
679 free(b); 673 free(b);
680 } 674 }
681 _drm_cleanup(swp); 675 _drm_cleanup(swp);
@@ -717,7 +711,7 @@ evas_xlib_swapper_buffer_map(X_Swapper *swp, int *bpl, int *w, int *h)
717 EINA_LIST_FREE(swp->buf_cache, b) 711 EINA_LIST_FREE(swp->buf_cache, b)
718 { 712 {
719 if (swap_debug) printf("Cached buf name %i freed\n", b->name); 713 if (swap_debug) printf("Cached buf name %i freed\n", b->name);
720 sym_drm_slp_bo_unref(b->buf_bo); 714 sym_tbm_bo_unref(b->buf_bo);
721 free(b); 715 free(b);
722 } 716 }
723 } 717 }
@@ -738,7 +732,7 @@ evas_xlib_swapper_buffer_map(X_Swapper *swp, int *bpl, int *w, int *h)
738 } 732 }
739 if (!swp->buf_bo) 733 if (!swp->buf_bo)
740 { 734 {
741 swp->buf_bo = sym_drm_slp_bo_import(bufmgr, swp->buf->name); 735 swp->buf_bo = sym_tbm_bo_import(bufmgr, swp->buf->name);
742 if (!swp->buf_bo) return NULL; 736 if (!swp->buf_bo) return NULL;
743 // cache the buf entry 737 // cache the buf entry
744 b = calloc(1, sizeof(Buffer)); 738 b = calloc(1, sizeof(Buffer));
@@ -750,23 +744,25 @@ evas_xlib_swapper_buffer_map(X_Swapper *swp, int *bpl, int *w, int *h)
750 // keep bo cache no more than its max size 744 // keep bo cache no more than its max size
751 while (eina_list_count(swp->buf_cache) > MAX_BO_CACHE) 745 while (eina_list_count(swp->buf_cache) > MAX_BO_CACHE)
752 { 746 {
753 if (swap_debug) printf("Buffer cache count %i more than max %i\n", eina_list_count(swp->buf_cache) , MAX_BO_CACHE); 747 if (swap_debug) printf("Buffer cache count %i more than max %i\n", eina_list_count(swp->buf_cache), MAX_BO_CACHE);
754 l = eina_list_last(swp->buf_cache); 748 l = eina_list_last(swp->buf_cache);
755 if (l) 749 if (l)
756 { 750 {
757 b = l->data; 751 b = l->data;
758 if (swap_debug) printf("Buffer cache overfull - free name %i\n", b->name); 752 if (swap_debug) printf("Buffer cache overfull - free name %i\n", b->name);
759 swp->buf_cache = eina_list_remove_list(swp->buf_cache, l); 753 swp->buf_cache = eina_list_remove_list(swp->buf_cache, l);
760 sym_drm_slp_bo_unref(b->buf_bo); 754 sym_tbm_bo_unref(b->buf_bo);
761 free(b); 755 free(b);
762 } 756 }
763 } 757 }
764 } 758 }
765 // XXXX: sym_drm_slp_bo_map() is incorrectly defined - it SHOULD return a 759
766 // void * at least 760 tbm_bo_handle bo_handle;
767 swp->buf_data = sym_drm_slp_bo_map(swp->buf_bo, DRM_SLP_DEVICE_CPU, 761
768 DRM_SLP_OPTION_READ | 762 bo_handle = sym_tbm_bo_map (swp->buf_bo, TBM_DEVICE_CPU, TBM_OPTION_READ | TBM_OPTION_WRITE);
769 DRM_SLP_OPTION_WRITE); 763 /* If device is DEFAULT, 2D, 3D, MM,then swp->buf_data = bo_handle.u32 */
764 swp->buf_data = bo_handle.ptr;
765
770 if (!swp->buf_data) 766 if (!swp->buf_data)
771 { 767 {
772 ERR("Buffer map name %i failed", swp->buf->name); 768 ERR("Buffer map name %i failed", swp->buf->name);
@@ -790,7 +786,7 @@ void
790evas_xlib_swapper_buffer_unmap(X_Swapper *swp) 786evas_xlib_swapper_buffer_unmap(X_Swapper *swp)
791{ 787{
792 if (!swp->mapped) return; 788 if (!swp->mapped) return;
793 sym_drm_slp_bo_unmap(swp->buf_bo, DRM_SLP_DEVICE_CPU); 789 sym_tbm_bo_unmap(swp->buf_bo);
794 if (swap_debug) printf("Unmap buffer name %i\n", swp->buf->name); 790 if (swap_debug) printf("Unmap buffer name %i\n", swp->buf->name);
795 free(swp->buf); 791 free(swp->buf);
796 swp->buf = NULL; 792 swp->buf = NULL;