From b29e43288d0bfafb02565e15777fe939141852e5 Mon Sep 17 00:00:00 2001 From: Sangjin Lee Date: Fri, 20 Nov 2015 20:06:25 +0900 Subject: [PATCH 01/16] Add COPYING for MIT Change-Id: I5fe98845c0f3155498943a1066d5847700109513 Signed-off-by: Sangjin Lee --- COPYING | 19 +++++++++++++++++++ packaging/libgbm.spec | 1 + 2 files changed, 20 insertions(+) create mode 100644 COPYING diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..9036173 --- /dev/null +++ b/COPYING @@ -0,0 +1,19 @@ +Copyright (C) 2000 - 2015 Samsung Electronics co., Ltd. All Rights Reserved. + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that copyright +notice and this permission notice appear in supporting documentation, and +that the name of the copyright holders not be used in advertising or +publicity pertaining to distribution of the software without specific, +written prior permission. The copyright holders make no representations +about the suitability of this software for any purpose. It is provided "as +is" without express or implied warranty. + +THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +OF THIS SOFTWARE. diff --git a/packaging/libgbm.spec b/packaging/libgbm.spec index 44ca2dd..3a9e05f 100644 --- a/packaging/libgbm.spec +++ b/packaging/libgbm.spec @@ -46,6 +46,7 @@ ln -sf libgbm.so.%{MAJOR_VER} %{buildroot}%{_libdir}/libgbm.so %files %manifest packaging/libgbm.manifest +%license COPYING %defattr(-,root,root,-) %{_libdir}/libgbm.so %{_libdir}/libgbm.so.%{MAJOR_VER} -- 2.7.4 From a2dd6b9fee96e6c4ade04d65268cc31912c60a53 Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Fri, 20 Nov 2015 22:26:03 +0900 Subject: [PATCH 02/16] Add gbm_tbm API for getting stride info from gbm_tbm_bo. Change-Id: I32bc73f4bf64f705563d5a6220d221a542911e0b --- backends/tbm/gbm_tbm.c | 6 ++++++ backends/tbm/gbm_tbm.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/backends/tbm/gbm_tbm.c b/backends/tbm/gbm_tbm.c index e5393a2..f6560aa 100644 --- a/backends/tbm/gbm_tbm.c +++ b/backends/tbm/gbm_tbm.c @@ -46,6 +46,12 @@ gbm_tbm_bo_get_tbm_bo(struct gbm_tbm_bo *bo) } GBM_EXPORT uint32_t +gbm_tbm_bo_get_stride(struct gbm_tbm_bo *bo) +{ + return bo->base.stride; +} + +GBM_EXPORT uint32_t gbm_tbm_surface_get_width(struct gbm_tbm_surface *surf) { return surf->base.width; diff --git a/backends/tbm/gbm_tbm.h b/backends/tbm/gbm_tbm.h index 651a4a2..4094375 100644 --- a/backends/tbm/gbm_tbm.h +++ b/backends/tbm/gbm_tbm.h @@ -39,4 +39,7 @@ gbm_tbm_surface_get_user_data(struct gbm_tbm_surface *surf); tbm_bo gbm_tbm_bo_get_tbm_bo(struct gbm_tbm_bo *bo); +uint32_t +gbm_tbm_bo_get_stride(struct gbm_tbm_bo *bo); + #endif -- 2.7.4 From 36dde46fe1c1514334fd1896d4c78873f13fd332 Mon Sep 17 00:00:00 2001 From: Sangjin Lee Date: Sat, 21 Nov 2015 21:34:37 +0900 Subject: [PATCH 03/16] Use tbm surface queue Change-Id: I8023244921a39963c101d2835817ad4a275d3734 --- backends/tbm/gbm_tbm.c | 199 ++++++++++++++++++++++++++++++++++++++-------- backends/tbm/gbm_tbm.h | 13 +++ backends/tbm/gbm_tbmint.h | 8 ++ configure.ac | 7 ++ packaging/libgbm.spec | 2 +- src/gbm.h | 8 -- 6 files changed, 195 insertions(+), 42 deletions(-) diff --git a/backends/tbm/gbm_tbm.c b/backends/tbm/gbm_tbm.c index f6560aa..e8adca4 100644 --- a/backends/tbm/gbm_tbm.c +++ b/backends/tbm/gbm_tbm.c @@ -33,10 +33,32 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include +#include "config.h" #include "gbm_tbmint.h" #include #include +static int tbm_private_data; +#define TBM_DATA_KEY ((unsigned long)&tbm_private_data) + +#ifdef USE_TBM_QUEUE +struct gbm_bo* __gbm_tbm_get_gbm_bo(tbm_surface_h surf); + +GBM_EXPORT tbm_surface_queue_h +gbm_tbm_get_surface_queue(struct gbm_surface* surface) +{ + struct gbm_tbm_surface *surf = gbm_tbm_surface(surface); + return surf->queue; +} + +GBM_EXPORT tbm_surface_h +gbm_tbm_get_surface(struct gbm_bo* bo) +{ + struct gbm_tbm_bo *_bo = gbm_tbm_bo(bo); + return _bo->tbm_surf; +} + +#else GBM_EXPORT tbm_bo gbm_tbm_bo_get_tbm_bo(struct gbm_tbm_bo *bo) { @@ -104,6 +126,7 @@ gbm_tbm_device_set_callback_surface_release_buffer(struct gbm_tbm_device *gbm_tb { gbm_tbm->base.surface_release_buffer = callback; } +#endif static int __gbm_tbm_is_format_supported(struct gbm_device *gbm, @@ -112,10 +135,8 @@ __gbm_tbm_is_format_supported(struct gbm_device *gbm, { switch (format) { - case GBM_BO_FORMAT_XRGB8888: case GBM_FORMAT_XRGB8888: break; - case GBM_BO_FORMAT_ARGB8888: case GBM_FORMAT_ARGB8888: if (usage & GBM_BO_USE_SCANOUT) return 0; @@ -157,7 +178,6 @@ __gbm_tbm_bo_get_fd(struct gbm_bo *_bo) tbo = tbm_surface_internal_get_bo(bo->tbm_surf, 0); if (!tbo) { - fprintf(stderr, "%s::tbm_surface_internal_get_bo() failed.\n", __FUNCTION__); return 0; } handle = tbm_bo_get_handle(tbo, TBM_DEVICE_MM); @@ -225,14 +245,13 @@ __gbm_tbm_bo_import(struct gbm_device *gbm, uint32_t type, } static struct gbm_bo * -__gbm_tbm_bo_create(struct gbm_device *gbm, +__gbm_tbm_bo_create_by_tbm_surface(struct gbm_device *gbm, + tbm_surface_h tbm_surf, uint32_t width, uint32_t height, uint32_t format, uint32_t usage) { struct gbm_tbm_bo *bo; uint32_t size, offset, pitch; - int flags = TBM_BO_DEFAULT; - int surface_format; tbm_bo_handle handle; tbm_bo tbo; @@ -245,53 +264,161 @@ __gbm_tbm_bo_create(struct gbm_device *gbm, bo->base.height = height; bo->base.format = format; bo->usage = usage; + bo->tbm_surf = tbm_surf; - switch (format) + if (!tbm_surface_internal_get_plane_data(bo->tbm_surf, 0, &size, &offset, &pitch)) { - case GBM_FORMAT_RGB565: - surface_format = TBM_FORMAT_BGR565; - break; - case GBM_FORMAT_XRGB8888: - case GBM_BO_FORMAT_XRGB8888: - surface_format = TBM_FORMAT_XRGB8888; - break; - case GBM_FORMAT_ARGB8888: - case GBM_BO_FORMAT_ARGB8888: - case GBM_FORMAT_ABGR8888: - surface_format = TBM_FORMAT_ABGR8888; - break; - default: - free(bo); - return NULL; + tbm_surface_destroy(bo->tbm_surf); + free(bo); + return NULL; } + bo->base.stride = pitch; + tbo = tbm_surface_internal_get_bo(bo->tbm_surf, 0); + handle = tbm_bo_get_handle(tbo, TBM_DEVICE_DEFAULT); + bo->base.handle.u64 = handle.u64; + + tbm_bo_add_user_data(tbo, TBM_DATA_KEY, NULL); + tbm_bo_set_user_data(tbo, TBM_DATA_KEY, &bo->base); + + return &bo->base; +} + +static struct gbm_bo * +__gbm_tbm_bo_create(struct gbm_device *gbm, + uint32_t width, uint32_t height, + uint32_t format, uint32_t usage) +{ + tbm_surface_h tbm_surf; + int flags = TBM_BO_DEFAULT; + if ((usage & GBM_BO_USE_SCANOUT) || (usage & GBM_BO_USE_CURSOR_64X64)) { flags |= TBM_BO_SCANOUT; } - bo->tbm_surf = tbm_surface_internal_create_with_flags(width, height, surface_format, flags); - if (!bo->tbm_surf) + tbm_surf = tbm_surface_internal_create_with_flags(width, height, format, flags); + if (tbm_surf) { - free(bo); return NULL; } - if (!tbm_surface_internal_get_plane_data(bo->tbm_surf, 0, &size, &offset, &pitch)) + return __gbm_tbm_bo_create_by_tbm_surface(gbm, tbm_surf, width, height, format, flags); +} + + +#ifdef USE_TBM_QUEUE +struct gbm_bo* +__gbm_tbm_get_gbm_bo(tbm_surface_h surf) +{ + tbm_bo bo; + struct gbm_bo* gbo = NULL; + + bo = tbm_surface_internal_get_bo(surf, 0); + if (!bo) return NULL; + + if (tbm_bo_get_user_data(bo, TBM_DATA_KEY, (void**)&gbo)) { - tbm_surface_destroy(bo->tbm_surf); - free(bo); + return gbo; + } + + return NULL; +} + +static struct gbm_surface * +__gbm_tbm_surface_create(struct gbm_device *gbm, + uint32_t width, uint32_t height, + uint32_t format, uint32_t flags) +{ + struct gbm_tbm_surface *surf; + int tbm_flags = 0; + + surf = calloc(1, sizeof *surf); + if (surf == NULL) + return NULL; + + surf->base.gbm = gbm; + surf->base.width = width; + surf->base.height = height; + surf->base.format = format; + surf->base.flags = flags; + + if ((flags & GBM_BO_USE_SCANOUT) || (flags & GBM_BO_USE_CURSOR_64X64)) + { + tbm_flags |= TBM_BO_SCANOUT; + } + + surf->queue = tbm_surface_queue_create(3, width, height, format, tbm_flags); + if (!surf->queue) + { + free(surf); return NULL; } - bo->base.stride = pitch; - tbo = tbm_surface_internal_get_bo(bo->tbm_surf, 0); - handle = tbm_bo_get_handle(tbo, TBM_DEVICE_DEFAULT); - bo->base.handle.u64 = handle.u64; + return &surf->base; +} - return &bo->base; +static void +__gbm_tbm_surface_destroy(struct gbm_surface *surface) +{ + struct gbm_tbm_surface *surf = gbm_tbm_surface(surface); + + tbm_surface_queue_destroy(surf->queue); + free(surf); } +static struct gbm_bo * +__gbm_tbm_surface_lock_front_buffer(struct gbm_surface *surface) +{ + struct gbm_tbm_surface *surf = gbm_tbm_surface(surface); + int num_duty; + tbm_surface_h tbm_surf; + struct gbm_bo *gbo; + + if ((num_duty = tbm_surface_queue_can_acquire(surf->queue, 1))) + { + if ((TBM_SURFACE_QUEUE_ERROR_NONE == tbm_surface_queue_acquire(surf->queue, &tbm_surf))) + { + gbo = __gbm_tbm_get_gbm_bo(tbm_surf); + if (gbo) + return gbo; + + gbo = __gbm_tbm_bo_create_by_tbm_surface(surf->base.gbm, + tbm_surf, + surf->base.width, + surf->base.height, + surf->base.format, + surf->base.flags); + if (gbo) + { + return gbo; + } + } + } + + return NULL; +} + +static void +__gbm_tbm_surface_release_buffer(struct gbm_surface *surface, + struct gbm_bo *gbo) +{ + struct gbm_tbm_surface *surf = gbm_tbm_surface(surface); + struct gbm_tbm_bo *bo = gbm_tbm_bo(gbo); + tbm_surface_h tbm_surf; + + tbm_surf = bo->tbm_surf; + tbm_surface_queue_release(surf->queue, tbm_surf); +} + +static int +__gbm_tbm_surface_has_free_buffers(struct gbm_surface *surface) +{ + struct gbm_tbm_surface *surf = gbm_tbm_surface(surface); + + return tbm_surface_queue_can_acquire(surf->queue, 0); +} +#else static struct gbm_surface * __gbm_tbm_surface_create(struct gbm_device *gbm, uint32_t width, uint32_t height, @@ -319,6 +446,7 @@ __gbm_tbm_surface_destroy(struct gbm_surface *_surf) free(surf); } +#endif static void __tbm_destroy(struct gbm_device *gbm) @@ -355,6 +483,11 @@ __tbm_device_create(int fd) dri->base.destroy = __tbm_destroy; dri->base.surface_create = __gbm_tbm_surface_create; dri->base.surface_destroy = __gbm_tbm_surface_destroy; +#ifdef USE_TBM_QUEUE + dri->base.surface_lock_front_buffer = __gbm_tbm_surface_lock_front_buffer; + dri->base.surface_release_buffer = __gbm_tbm_surface_release_buffer; + dri->base.surface_has_free_buffers = __gbm_tbm_surface_has_free_buffers; +#endif dri->base.name = "gbm_tbm"; return &dri->base; diff --git a/backends/tbm/gbm_tbm.h b/backends/tbm/gbm_tbm.h index 4094375..cb62de4 100644 --- a/backends/tbm/gbm_tbm.h +++ b/backends/tbm/gbm_tbm.h @@ -2,6 +2,18 @@ #define _GBM_TBM_H_ #include + +#ifdef USE_TBM_QUEUE +#include +#include + +tbm_surface_queue_h +gbm_tbm_get_surface_queue(struct gbm_surface* surf); + +tbm_surface_h +gbm_tbm_get_surface(struct gbm_bo* bo); + +#else #include struct gbm_tbm_device; @@ -43,3 +55,4 @@ uint32_t gbm_tbm_bo_get_stride(struct gbm_tbm_bo *bo); #endif +#endif diff --git a/backends/tbm/gbm_tbmint.h b/backends/tbm/gbm_tbmint.h index 9dd9b71..9804d81 100644 --- a/backends/tbm/gbm_tbmint.h +++ b/backends/tbm/gbm_tbmint.h @@ -31,6 +31,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include +#ifdef USE_TBM_QUEUE +#include +#endif + #include "gbm_tbm.h" #include "gbmint.h" @@ -49,6 +53,10 @@ struct gbm_tbm_bo { struct gbm_tbm_surface { struct gbm_surface base; void *tbm_private; + +#ifdef USE_TBM_QUEUE + tbm_surface_queue_h queue; +#endif }; static inline struct gbm_tbm_device * diff --git a/configure.ac b/configure.ac index 8042948..7f2eb5b 100644 --- a/configure.ac +++ b/configure.ac @@ -13,6 +13,13 @@ AC_PROG_LIBTOOL PKG_CHECK_MODULES([TBM], [libtbm wayland-tbm-server], [have_tbm=yes], [have_tbm=no]) if test x$have_tbm = xyes; then AC_DEFINE([HAVE_TBM], [1], [Build the tbm backend]) + + AC_ARG_ENABLE(tbm-queue, [--enable-tbm-queue],, + enable_tbm_queue=no) + AM_CONDITIONAL(USE_TBM_QUEUE, test x$enable_tbm_queue = xyes) + if test x$enable_tbm_queue = xyes; then + AC_DEFINE([USE_TBM_QUEUE], [1], [Build gbm_tbm with TBM surface queue]) + fi fi AM_CONDITIONAL(HAVE_TBM, test "x$have_tbm" = "xyes") diff --git a/packaging/libgbm.spec b/packaging/libgbm.spec index 3a9e05f..adc4da5 100644 --- a/packaging/libgbm.spec +++ b/packaging/libgbm.spec @@ -30,7 +30,7 @@ Development header files for use with Wayland GBM %setup -q -n %{name} %build -%reconfigure --disable-static +%reconfigure --disable-static --enable-tbm-queue make libdir=%{_libdir} major_ver=%{MAJOR_VER} minor_ver=%{MINOR_VER} %install diff --git a/src/gbm.h b/src/gbm.h index 92d472a..8312d3d 100644 --- a/src/gbm.h +++ b/src/gbm.h @@ -68,14 +68,6 @@ union gbm_bo_handle { uint64_t u64; }; -/** Format of the allocated buffer */ -enum gbm_bo_format { - /** RGB with 8 bits per channel in a 32 bit value */ - GBM_BO_FORMAT_XRGB8888, - /** ARGB with 8 bits per channel in a 32 bit value */ - GBM_BO_FORMAT_ARGB8888 -}; - #define __gbm_fourcc_code(a,b,c,d) ((uint32_t)(a) | ((uint32_t)(b) << 8) | \ ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24)) -- 2.7.4 From ea84d600bd312bf8198036f520fd8f6c37440c12 Mon Sep 17 00:00:00 2001 From: Sangjin Lee Date: Mon, 30 Nov 2015 20:50:05 +0900 Subject: [PATCH 04/16] gbm-tbm : disable surface-queue Change-Id: I7661f06809d79b947a9fe10bb27f6ffff3a01b37 Signed-off-by: Sangjin Lee --- packaging/libgbm.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libgbm.spec b/packaging/libgbm.spec index adc4da5..3a9e05f 100644 --- a/packaging/libgbm.spec +++ b/packaging/libgbm.spec @@ -30,7 +30,7 @@ Development header files for use with Wayland GBM %setup -q -n %{name} %build -%reconfigure --disable-static --enable-tbm-queue +%reconfigure --disable-static make libdir=%{_libdir} major_ver=%{MAJOR_VER} minor_ver=%{MINOR_VER} %install -- 2.7.4 From 74dc7e25c56c752f12ea145a5e5f9e27137acb29 Mon Sep 17 00:00:00 2001 From: Sangjin Lee Date: Tue, 1 Dec 2015 09:10:21 +0900 Subject: [PATCH 05/16] gbm-tbm: Fix bug for gbm_bo create Change-Id: I4e5a463219c749b321592629cb9623c8bdf3881a Signed-off-by: Sangjin Lee --- backends/tbm/gbm_tbm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backends/tbm/gbm_tbm.c b/backends/tbm/gbm_tbm.c index e8adca4..5d619f1 100644 --- a/backends/tbm/gbm_tbm.c +++ b/backends/tbm/gbm_tbm.c @@ -298,7 +298,7 @@ __gbm_tbm_bo_create(struct gbm_device *gbm, } tbm_surf = tbm_surface_internal_create_with_flags(width, height, format, flags); - if (tbm_surf) + if (!tbm_surf) { return NULL; } -- 2.7.4 From e127a4a8176faffd2e00bc5a7d7fa59681972a7b Mon Sep 17 00:00:00 2001 From: Sangjin Lee Date: Fri, 4 Dec 2015 21:20:45 +0900 Subject: [PATCH 06/16] enable buffer-queue Change-Id: Icd530a0f1361a075b1c2b8da46bb1f391fa7eb22 --- packaging/libgbm.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libgbm.spec b/packaging/libgbm.spec index 3a9e05f..adc4da5 100644 --- a/packaging/libgbm.spec +++ b/packaging/libgbm.spec @@ -30,7 +30,7 @@ Development header files for use with Wayland GBM %setup -q -n %{name} %build -%reconfigure --disable-static +%reconfigure --disable-static --enable-tbm-queue make libdir=%{_libdir} major_ver=%{MAJOR_VER} minor_ver=%{MINOR_VER} %install -- 2.7.4 From 6bf675bd2b94298996ec362f59d070a672a8837f Mon Sep 17 00:00:00 2001 From: Sangjin Lee Date: Mon, 14 Dec 2015 11:47:25 +0900 Subject: [PATCH 07/16] gbm-tbm: remove useless code for tbm_surface_queue remove USE_TBM_QUEUE Change-Id: I7dffb34b36d3e912f0f80dc444d3a9127e023494 Signed-off-by: Sangjin Lee --- backends/tbm/gbm_tbm.c | 104 ---------------------------------------------- backends/tbm/gbm_tbm.h | 44 -------------------- backends/tbm/gbm_tbmint.h | 4 -- 3 files changed, 152 deletions(-) diff --git a/backends/tbm/gbm_tbm.c b/backends/tbm/gbm_tbm.c index 5d619f1..92527c3 100644 --- a/backends/tbm/gbm_tbm.c +++ b/backends/tbm/gbm_tbm.c @@ -41,7 +41,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. static int tbm_private_data; #define TBM_DATA_KEY ((unsigned long)&tbm_private_data) -#ifdef USE_TBM_QUEUE struct gbm_bo* __gbm_tbm_get_gbm_bo(tbm_surface_h surf); GBM_EXPORT tbm_surface_queue_h @@ -58,76 +57,6 @@ gbm_tbm_get_surface(struct gbm_bo* bo) return _bo->tbm_surf; } -#else -GBM_EXPORT tbm_bo -gbm_tbm_bo_get_tbm_bo(struct gbm_tbm_bo *bo) -{ - tbm_bo tbo; - tbo = tbm_surface_internal_get_bo(bo->tbm_surf, 0); - return tbo; -} - -GBM_EXPORT uint32_t -gbm_tbm_bo_get_stride(struct gbm_tbm_bo *bo) -{ - return bo->base.stride; -} - -GBM_EXPORT uint32_t -gbm_tbm_surface_get_width(struct gbm_tbm_surface *surf) -{ - return surf->base.width; -} - -GBM_EXPORT uint32_t -gbm_tbm_surface_get_height(struct gbm_tbm_surface *surf) -{ - return surf->base.height; -} - -GBM_EXPORT uint32_t -gbm_tbm_surface_get_format(struct gbm_tbm_surface *surf) -{ - return surf->base.format; -} - -GBM_EXPORT uint32_t -gbm_tbm_surface_get_flags(struct gbm_tbm_surface *surf) -{ - return surf->base.flags; -} - -GBM_EXPORT void -gbm_tbm_surface_set_user_data(struct gbm_tbm_surface *surf, void *data) -{ - surf->tbm_private = data; -} - -GBM_EXPORT void * -gbm_tbm_surface_get_user_data(struct gbm_tbm_surface *surf) -{ - return surf->tbm_private; -} - -GBM_EXPORT void -gbm_tbm_device_set_callback_surface_has_free_buffers(struct gbm_tbm_device *gbm_tbm, int (*callback)(struct gbm_surface *)) -{ - gbm_tbm->base.surface_has_free_buffers = callback; -} - -GBM_EXPORT void -gbm_tbm_device_set_callback_surface_lock_front_buffer(struct gbm_tbm_device *gbm_tbm, struct gbm_bo *(*callback)(struct gbm_surface *)) -{ - gbm_tbm->base.surface_lock_front_buffer = callback; -} - -GBM_EXPORT void -gbm_tbm_device_set_callback_surface_release_buffer(struct gbm_tbm_device *gbm_tbm, void (*callback)(struct gbm_surface *, struct gbm_bo *)) -{ - gbm_tbm->base.surface_release_buffer = callback; -} -#endif - static int __gbm_tbm_is_format_supported(struct gbm_device *gbm, uint32_t format, @@ -306,8 +235,6 @@ __gbm_tbm_bo_create(struct gbm_device *gbm, return __gbm_tbm_bo_create_by_tbm_surface(gbm, tbm_surf, width, height, format, flags); } - -#ifdef USE_TBM_QUEUE struct gbm_bo* __gbm_tbm_get_gbm_bo(tbm_surface_h surf) { @@ -418,35 +345,6 @@ __gbm_tbm_surface_has_free_buffers(struct gbm_surface *surface) return tbm_surface_queue_can_acquire(surf->queue, 0); } -#else -static struct gbm_surface * -__gbm_tbm_surface_create(struct gbm_device *gbm, - uint32_t width, uint32_t height, - uint32_t format, uint32_t flags) -{ - struct gbm_tbm_surface *surf; - - surf = calloc(1, sizeof *surf); - if (surf == NULL) - return NULL; - - surf->base.gbm = gbm; - surf->base.width = width; - surf->base.height = height; - surf->base.format = format; - surf->base.flags = flags; - - return &surf->base; -} - -static void -__gbm_tbm_surface_destroy(struct gbm_surface *_surf) -{ - struct gbm_tbm_surface *surf = gbm_tbm_surface(_surf); - - free(surf); -} -#endif static void __tbm_destroy(struct gbm_device *gbm) @@ -483,11 +381,9 @@ __tbm_device_create(int fd) dri->base.destroy = __tbm_destroy; dri->base.surface_create = __gbm_tbm_surface_create; dri->base.surface_destroy = __gbm_tbm_surface_destroy; -#ifdef USE_TBM_QUEUE dri->base.surface_lock_front_buffer = __gbm_tbm_surface_lock_front_buffer; dri->base.surface_release_buffer = __gbm_tbm_surface_release_buffer; dri->base.surface_has_free_buffers = __gbm_tbm_surface_has_free_buffers; -#endif dri->base.name = "gbm_tbm"; return &dri->base; diff --git a/backends/tbm/gbm_tbm.h b/backends/tbm/gbm_tbm.h index cb62de4..26779cb 100644 --- a/backends/tbm/gbm_tbm.h +++ b/backends/tbm/gbm_tbm.h @@ -2,8 +2,6 @@ #define _GBM_TBM_H_ #include - -#ifdef USE_TBM_QUEUE #include #include @@ -13,46 +11,4 @@ gbm_tbm_get_surface_queue(struct gbm_surface* surf); tbm_surface_h gbm_tbm_get_surface(struct gbm_bo* bo); -#else -#include - -struct gbm_tbm_device; -struct gbm_tbm_bo; -struct gbm_tbm_surface; - - -void -gbm_tbm_device_set_callback_surface_has_free_buffers(struct gbm_tbm_device *gbm_tbm, int (*callback)(struct gbm_surface *)); - -void -gbm_tbm_device_set_callback_surface_lock_front_buffer(struct gbm_tbm_device *gbm_tbm, struct gbm_bo *(*callback)(struct gbm_surface *)); - -void -gbm_tbm_device_set_callback_surface_release_buffer(struct gbm_tbm_device *gbm_tbm, void (*callback)(struct gbm_surface *, struct gbm_bo *)); - -uint32_t -gbm_tbm_surface_get_width(struct gbm_tbm_surface *surf); - -uint32_t -gbm_tbm_surface_get_height(struct gbm_tbm_surface *surf); - -uint32_t -gbm_tbm_surface_get_format(struct gbm_tbm_surface *surf); - -uint32_t -gbm_tbm_surface_get_flags(struct gbm_tbm_surface *surf); - -void -gbm_tbm_surface_set_user_data(struct gbm_tbm_surface *surf, void *data); - -void * -gbm_tbm_surface_get_user_data(struct gbm_tbm_surface *surf); - -tbm_bo -gbm_tbm_bo_get_tbm_bo(struct gbm_tbm_bo *bo); - -uint32_t -gbm_tbm_bo_get_stride(struct gbm_tbm_bo *bo); - -#endif #endif diff --git a/backends/tbm/gbm_tbmint.h b/backends/tbm/gbm_tbmint.h index 9804d81..52de64d 100644 --- a/backends/tbm/gbm_tbmint.h +++ b/backends/tbm/gbm_tbmint.h @@ -31,9 +31,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include -#ifdef USE_TBM_QUEUE #include -#endif #include "gbm_tbm.h" #include "gbmint.h" @@ -54,9 +52,7 @@ struct gbm_tbm_surface { struct gbm_surface base; void *tbm_private; -#ifdef USE_TBM_QUEUE tbm_surface_queue_h queue; -#endif }; static inline struct gbm_tbm_device * -- 2.7.4 From 44e7a91e88c5f6dd2dd1685e46f4611732e26a0a Mon Sep 17 00:00:00 2001 From: "Mun, Gwan-gyeong" Date: Wed, 16 Dec 2015 14:14:39 +0900 Subject: [PATCH 08/16] gbm.h : Add gbm_bo_format enums Change-Id: I50a6f738670aa0eb5d23500381e181e6b3d65bca --- src/gbm.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gbm.h b/src/gbm.h index 8312d3d..558b512 100644 --- a/src/gbm.h +++ b/src/gbm.h @@ -68,6 +68,14 @@ union gbm_bo_handle { uint64_t u64; }; +/** Format of the allocated buffer */ +enum gbm_bo_format { + /** RGB with 8 bits per channel in a 32 bit value */ + GBM_BO_FORMAT_XRGB8888, + /** ARGB with 8 bits per channel in a 32 bit value */ + GBM_BO_FORMAT_ARGB8888 +}; + #define __gbm_fourcc_code(a,b,c,d) ((uint32_t)(a) | ((uint32_t)(b) << 8) | \ ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24)) -- 2.7.4 From 0b4ffbc25d71c88023ec2c7005c17d7252fcf97c Mon Sep 17 00:00:00 2001 From: Sangjin Lee Date: Wed, 16 Dec 2015 16:38:03 +0900 Subject: [PATCH 09/16] support old GBM_BO_FORMAT_XXX Change-Id: Ib291aa3fcfda62959dc70c79501727c6c9949bd0 Signed-off-by: Sangjin Lee --- src/gbm.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/gbm.c b/src/gbm.c index e1cd2d5..b6d207c 100644 --- a/src/gbm.c +++ b/src/gbm.c @@ -83,6 +83,16 @@ GBM_EXPORT int gbm_device_is_format_supported(struct gbm_device *gbm, uint32_t format, uint32_t usage) { + switch (format) + { + case GBM_BO_FORMAT_XRGB8888: + format = GBM_FORMAT_XRGB8888; + break; + case GBM_BO_FORMAT_ARGB8888: + format = GBM_FORMAT_ABGR8888; + break; + } + return gbm->is_format_supported(gbm, format, usage); } @@ -321,6 +331,16 @@ gbm_bo_create(struct gbm_device *gbm, (width != 64 || height != 64)) return NULL; + switch (format) + { + case GBM_BO_FORMAT_XRGB8888: + format = GBM_FORMAT_XRGB8888; + break; + case GBM_BO_FORMAT_ARGB8888: + format = GBM_FORMAT_ABGR8888; + break; + } + return gbm->bo_create(gbm, width, height, format, usage); } @@ -375,6 +395,16 @@ gbm_surface_create(struct gbm_device *gbm, uint32_t width, uint32_t height, uint32_t format, uint32_t flags) { + switch (format) + { + case GBM_BO_FORMAT_XRGB8888: + format = GBM_FORMAT_XRGB8888; + break; + case GBM_BO_FORMAT_ARGB8888: + format = GBM_FORMAT_ABGR8888; + break; + } + return gbm->surface_create(gbm, width, height, format, flags); } -- 2.7.4 From 985b3959ac1d773d72f9086cdd4cf4ada3e92706 Mon Sep 17 00:00:00 2001 From: Sangjin Lee Date: Mon, 21 Dec 2015 20:26:43 +0900 Subject: [PATCH 10/16] update gbm_bo flags Change-Id: I4bc382b37d3a3df9d7537a4366007df57f0dbe61 --- src/gbm.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/gbm.h b/src/gbm.h index 558b512..ca2dd4c 100644 --- a/src/gbm.h +++ b/src/gbm.h @@ -192,10 +192,13 @@ enum gbm_bo_flags { */ GBM_BO_USE_SCANOUT = (1 << 0), /** - * Buffer is going to be used as cursor - the dimensions for the buffer - * must be 64x64 if this flag is passed. + * Buffer is going to be used as cursor */ - GBM_BO_USE_CURSOR_64X64 = (1 << 1), + GBM_BO_USE_CURSOR = (1 << 1), + /** + * Deprecated + */ + GBM_BO_USE_CURSOR_64X64 = GBM_BO_USE_CURSOR, /** * Buffer is to be used for rendering - for example it is going to be used * as the storage for a color buffer @@ -203,10 +206,13 @@ enum gbm_bo_flags { GBM_BO_USE_RENDERING = (1 << 2), /** * Buffer can be used for gbm_bo_write. This is guaranteed to work - * with GBM_BO_USE_CURSOR_64X64. but may not work for other - * combinations. + * with GBM_BO_USE_CURSOR. but may not work for other combinations. */ GBM_BO_USE_WRITE = (1 << 3), + /** + * Buffer is linear, i.e. not tiled. + */ + GBM_BO_USE_LINEAR = (1 << 4), }; int -- 2.7.4 From 6d11fba6ec86e648b038d52e8643e41949543915 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Tue, 15 Mar 2016 16:44:19 +0900 Subject: [PATCH 11/16] do not build gbm_tbm at emulator Change-Id: Id875ebab821418dce9fca4dc8f26d42efab094c5 --- Makefile.am | 3 ++- configure.ac | 9 +++++++-- packaging/libgbm.spec | 6 +++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Makefile.am b/Makefile.am index 8289c37..5740071 100644 --- a/Makefile.am +++ b/Makefile.am @@ -38,11 +38,12 @@ AM_CFLAGS += \ libgbm_la_LIBADD += \ $(TBM_LIBS) +endif + libgbmtbmincludedir=$(includedir)/gbm libgbmtbminclude_HEADERS = \ backends/tbm/gbm_tbm.h \ backends/tbm/gbm_tbmint.h -endif CLEANFILES = diff --git a/configure.ac b/configure.ac index 7f2eb5b..274c567 100644 --- a/configure.ac +++ b/configure.ac @@ -10,19 +10,24 @@ AM_SILENT_RULES([yes]) AC_PROG_CC AC_PROG_LIBTOOL -PKG_CHECK_MODULES([TBM], [libtbm wayland-tbm-server], [have_tbm=yes], [have_tbm=no]) +AC_ARG_ENABLE(tbm, AS_HELP_STRING([--disable-tbm], + [use tbm or not (default: enabled)]), + [have_tbm=$enableval], [have_tbm=yes]) + if test x$have_tbm = xyes; then + PKG_CHECK_MODULES([TBM], [libtbm wayland-tbm-server]) AC_DEFINE([HAVE_TBM], [1], [Build the tbm backend]) AC_ARG_ENABLE(tbm-queue, [--enable-tbm-queue],, enable_tbm_queue=no) - AM_CONDITIONAL(USE_TBM_QUEUE, test x$enable_tbm_queue = xyes) if test x$enable_tbm_queue = xyes; then AC_DEFINE([USE_TBM_QUEUE], [1], [Build gbm_tbm with TBM surface queue]) fi fi AM_CONDITIONAL(HAVE_TBM, test "x$have_tbm" = "xyes") +AM_CONDITIONAL(USE_TBM_QUEUE, test x$enable_tbm_queue = xyes) + AC_CONFIG_FILES([ Makefile gbm.pc diff --git a/packaging/libgbm.spec b/packaging/libgbm.spec index adc4da5..c32acea 100644 --- a/packaging/libgbm.spec +++ b/packaging/libgbm.spec @@ -30,7 +30,11 @@ Development header files for use with Wayland GBM %setup -q -n %{name} %build -%reconfigure --disable-static --enable-tbm-queue +%if "%_repository" == "emulator32-wayland" || "%_repository" == "emulator64-wayland" +%reconfigure --disable-static --disable-tbm +%else +%reconfigure --disable-static --enable-tbm --enable-tbm-queue +%endif make libdir=%{_libdir} major_ver=%{MAJOR_VER} minor_ver=%{MINOR_VER} %install -- 2.7.4 From fbeecc5f03c8bf7cc09d2e093d4ab1d0afb580ca Mon Sep 17 00:00:00 2001 From: "Mun, Gwan-gyeong" Date: Sat, 30 Apr 2016 01:00:42 +0900 Subject: [PATCH 12/16] enable tbm backend and tbm-queue on emulator environment. Change-Id: I0d9117cced57e69212aa463bc8c361915ba315d3 --- packaging/libgbm.spec | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packaging/libgbm.spec b/packaging/libgbm.spec index c32acea..02568af 100644 --- a/packaging/libgbm.spec +++ b/packaging/libgbm.spec @@ -30,11 +30,7 @@ Development header files for use with Wayland GBM %setup -q -n %{name} %build -%if "%_repository" == "emulator32-wayland" || "%_repository" == "emulator64-wayland" -%reconfigure --disable-static --disable-tbm -%else %reconfigure --disable-static --enable-tbm --enable-tbm-queue -%endif make libdir=%{_libdir} major_ver=%{MAJOR_VER} minor_ver=%{MINOR_VER} %install -- 2.7.4 From fd3bc8d03f065c807c8dd12d22e67851cecf0e52 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Tue, 3 May 2016 20:40:46 +0900 Subject: [PATCH 13/16] Fix handle leak Change-Id: Ic4128016668f77e35657b1fe32817408727596d9 --- src/backend.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/backend.c b/src/backend.c index a0aa744..332d960 100644 --- a/src/backend.c +++ b/src/backend.c @@ -82,8 +82,10 @@ load_backend(const struct backend_desc *backend) } init = dlsym(module, entrypoint); - if (!init) + if (!init) { + dlclose(module); return NULL; + } } return init; -- 2.7.4 From f37dc48624157b3cb0bdbd902151b6efe1d4adaa Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Tue, 10 May 2016 09:51:38 +0900 Subject: [PATCH 14/16] fix open module lost Change-Id: I2ebae8d762513fc68fccb90649b27a37ac596407 Signed-off-by: Junkyeong Kim --- src/backend.c | 16 ++++++++++++++++ src/backend.h | 2 ++ src/gbm.c | 4 +++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/backend.c b/src/backend.c index 332d960..13f705f 100644 --- a/src/backend.c +++ b/src/backend.c @@ -37,6 +37,8 @@ #define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0])) +static void *g_gbm_module; + #if HAVE_TBM extern const struct gbm_backend gbm_tbm_backend; #endif @@ -64,6 +66,9 @@ load_backend(const struct backend_desc *backend) if (backend == NULL) return NULL; + if (g_gbm_module) + return NULL; + name = backend->name; if (backend->builtin) { @@ -87,6 +92,7 @@ load_backend(const struct backend_desc *backend) return NULL; } } + g_gbm_module = module; return init; } @@ -132,3 +138,13 @@ _gbm_create_device(int fd) return dev; } + +void +_gbm_close_device(void) +{ + if (g_gbm_module) { + dlclose(g_gbm_module); + g_gbm_module = NULL; + } +} + diff --git a/src/backend.h b/src/backend.h index 4a64375..8609196 100644 --- a/src/backend.h +++ b/src/backend.h @@ -32,5 +32,7 @@ struct gbm_device * _gbm_create_device(int fd); +void +_gbm_close_device(void); #endif diff --git a/src/gbm.c b/src/gbm.c index b6d207c..e62b694 100644 --- a/src/gbm.c +++ b/src/gbm.c @@ -104,8 +104,10 @@ GBM_EXPORT void gbm_device_destroy(struct gbm_device *gbm) { gbm->refcount--; - if (gbm->refcount == 0) + if (gbm->refcount == 0) { gbm->destroy(gbm); + _gbm_close_device(); + } } /** Create a gbm device for allocating buffers -- 2.7.4 From 1df80a91f82dbad6a6727868eab659fb864c5d34 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 19 May 2016 17:42:58 +0900 Subject: [PATCH 15/16] null initialization fix the build warning Change-Id: I6377b63cff5da7953a91eb91c6bf23204d5b3416 --- src/backend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend.c b/src/backend.c index 13f705f..8749f57 100644 --- a/src/backend.c +++ b/src/backend.c @@ -59,7 +59,7 @@ load_backend(const struct backend_desc *backend) { char path[PATH_MAX]; const void *init = NULL; - void *module; + void *module = NULL; const char *name; const char *entrypoint = "gbm_backend"; -- 2.7.4 From ae5d34445eee38daa4349a9ea0340b3faa324ded Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 19 May 2016 17:43:36 +0900 Subject: [PATCH 16/16] add -Werror to catch the build warnings Change-Id: I98966a119c753c9f1848b217dea046a7484f2501 --- packaging/libgbm.spec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packaging/libgbm.spec b/packaging/libgbm.spec index 02568af..757853c 100644 --- a/packaging/libgbm.spec +++ b/packaging/libgbm.spec @@ -30,7 +30,8 @@ Development header files for use with Wayland GBM %setup -q -n %{name} %build -%reconfigure --disable-static --enable-tbm --enable-tbm-queue +%reconfigure --disable-static --enable-tbm --enable-tbm-queue \ + CFLAGS="${CFLAGS} -Wall -Werror" make libdir=%{_libdir} major_ver=%{MAJOR_VER} minor_ver=%{MINOR_VER} %install -- 2.7.4