From a7e2978cf6107b783a8b665db0c8acf701a1e4e7 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 18 Aug 2014 10:47:11 +0900 Subject: [PATCH 01/16] version up Change-Id: I0ade6bddf13d74766692b84b66903543be94d63f --- configure.ac | 2 +- packaging/libtbm-exynos4412.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index a0d26ed..112e12a 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,7 @@ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. AC_PREREQ(2.60) -AC_INIT(libtbm-exynos4412, 1.0.0) +AC_INIT(libtbm-exynos4412, 1.0.5) AC_USE_SYSTEM_EXTENSIONS AC_CONFIG_SRCDIR([Makefile.am]) AM_INIT_AUTOMAKE([dist-bzip2]) diff --git a/packaging/libtbm-exynos4412.spec b/packaging/libtbm-exynos4412.spec index 1ef54df..539741c 100644 --- a/packaging/libtbm-exynos4412.spec +++ b/packaging/libtbm-exynos4412.spec @@ -2,7 +2,7 @@ Name: libtbm-exynos4412 Version: 1.0.5 Release: 1 License: MIT -Summary: The exynos4412 tbm backend +Summary: Tizen Buffer Manager - exynos4412 backend Group: System/Libraries ExcludeArch: i586 Source0: %{name}-%{version}.tar.gz -- 2.7.4 From c97911394517d41659619e0bb0a355acf1c1cabc Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 25 Aug 2014 15:19:21 +0900 Subject: [PATCH 02/16] add the code for supporting the tbm_surface Change-Id: I6b3280a882cf07ec4b2c2c3ba1bb275ff7027474 --- configure.ac | 5 +- packaging/libtbm-exynos4412.spec | 1 + src/tbm_bufmgr_exynos4412.c | 515 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 515 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 112e12a..37bf4f4 100644 --- a/configure.ac +++ b/configure.ac @@ -39,6 +39,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) PKG_CHECK_MODULES(LIBDRM, libdrm) PKG_CHECK_MODULES(LIBDRM_EXYNOS, libdrm_exynos) PKG_CHECK_MODULES(LIBTBM, libtbm) +PKG_CHECK_MODULES(DLOG, dlog) AC_ARG_ENABLE(cachectrl, AS_HELP_STRING([--enable-cache-crtl], @@ -49,8 +50,8 @@ if test "x$CACHE_CTRL" = xyes; then AC_DEFINE(ENABLE_CACHECRTL, 1, [Enable cache control]) fi -LIBTBM_EXYNOS4412_CFLAGS="$LIBDRM_CFLAGS $LIBDRM_EXYNOS_CFLAGS $LIBTBM_CFLAGS " -LIBTBM_EXYNOS4412_LIBS="$LIBDRM_LIBS $LIBDRM_EXYNOS_LIBS $LIBTBM_LIBS " +LIBTBM_EXYNOS4412_CFLAGS="$LIBDRM_CFLAGS $LIBDRM_EXYNOS_CFLAGS $LIBTBM_CFLAGS $DLOG_CFLAGS " +LIBTBM_EXYNOS4412_LIBS="$LIBDRM_LIBS $LIBDRM_EXYNOS_LIBS $LIBTBM_LIBS $DLOG_LIBS " AC_SUBST(LIBTBM_EXYNOS4412_CFLAGS) AC_SUBST(LIBTBM_EXYNOS4412_LIBS) diff --git a/packaging/libtbm-exynos4412.spec b/packaging/libtbm-exynos4412.spec index 539741c..5e7b391 100644 --- a/packaging/libtbm-exynos4412.spec +++ b/packaging/libtbm-exynos4412.spec @@ -11,6 +11,7 @@ BuildRequires: pkgconfig(pthread-stubs) BuildRequires: pkgconfig(libdrm) BuildRequires: pkgconfig(libdrm_exynos) BuildRequires: pkgconfig(libtbm) +BuildRequires: pkgconfig(dlog) %description descriptionion: Tizen Buffer manager backend module for exynos4412 diff --git a/src/tbm_bufmgr_exynos4412.c b/src/tbm_bufmgr_exynos4412.c index 259edee..9f47379 100755 --- a/src/tbm_bufmgr_exynos4412.c +++ b/src/tbm_bufmgr_exynos4412.c @@ -46,20 +46,71 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include #include -#include "exynos_drm.h" +#include #include +#include +#include #define DEBUG #define USE_DMAIMPORT -#define TBM_EXYNOS4412_LOG(...) fprintf (stderr, __VA_ARGS__) +#define TBM_COLOR_FORMAT_COUNT 8 #ifdef DEBUG -static int bDebug = 0; -#define DBG(...) if(bDebug&0x1) TBM_EXYNOS4412_LOG (__VA_ARGS__) +#define LOG_TAG "TBM_BACKEND" +#include +static int bDebug=0; + +char* target_name() +{ + FILE *f; + char *slash; + static int initialized = 0; + static char app_name[128]; + + if ( initialized ) + return app_name; + + /* get the application name */ + f = fopen("/proc/self/cmdline", "r"); + + if ( !f ) + { + return 0; + } + + memset(app_name, 0x00, sizeof(app_name)); + + if ( fgets(app_name, 100, f) == NULL ) + { + fclose(f); + return 0; + } + + fclose(f); + + if ( (slash=strrchr(app_name, '/')) != NULL ) + { + memmove(app_name, slash+1, strlen(slash)); + } + + initialized = 1; + + return app_name; +} +#define TBM_EXYNOS4412_LOG(fmt, args...) LOGE("\033[31m" "[%s]" fmt "\033[0m", target_name(), ##args) +#define DBG(fmt, args...) if(bDebug&01) LOGE("[%s]" fmt, target_name(), ##args) #else +#define TBM_EXYNOS4412_LOG(...) #define DBG(...) #endif +#define SIZE_ALIGN( value, base ) (((value) + ((base) - 1)) & ~((base) - 1)) + +#define TBM_SURFACE_ALIGNMENT_PLANE (64) +#define TBM_SURFACE_ALIGNMENT_PITCH_RGB (64) +#define TBM_SURFACE_ALIGNMENT_PITCH_YUV (16) + + /* check condition */ #define EXYNOS4412_RETURN_IF_FAIL(cond) {\ if (!(cond)) {\ @@ -160,6 +211,17 @@ char *STR_OPT[]= "RDWR" }; + +uint32_t tbm_exynos4412_color_format_list[TBM_COLOR_FORMAT_COUNT] = { TBM_FORMAT_RGBA8888, + TBM_FORMAT_BGRA8888, + TBM_FORMAT_RGBX8888, + TBM_FORMAT_RGB888, + TBM_FORMAT_NV12, + TBM_FORMAT_NV21, + TBM_FORMAT_YUV420, + TBM_FORMAT_YVU420 }; + + static unsigned int _get_exynos_flag_from_tbm (unsigned int ftbm) { @@ -1006,6 +1068,448 @@ tbm_exynos4412_bufmgr_deinit (void *priv) free (bufmgr_exynos4412); } +int +tbm_exynos4412_surface_supported_format(uint32_t **formats, uint32_t *num) +{ + uint32_t* color_formats=NULL; + + color_formats = (uint32_t*)calloc (1,sizeof(uint32_t)*TBM_COLOR_FORMAT_COUNT); + + if( color_formats == NULL ) + { + return 0; + } + memcpy( color_formats, tbm_exynos4412_color_format_list , sizeof(uint32_t)*TBM_COLOR_FORMAT_COUNT ); + + + *formats = color_formats; + *num = TBM_COLOR_FORMAT_COUNT; + + fprintf (stderr, "tbm_exynos4412_surface_supported_format count = %d \n",*num); + + return 1; +} + + +/** + * @brief get the plane data of the surface. + * @param[in] surface : the surface + * @param[in] width : the width of the surface + * @param[in] height : the height of the surface + * @param[in] format : the format of the surface + * @param[in] plane_idx : the format of the surface + * @param[out] size : the size of the plane + * @param[out] offset : the offset of the plane + * @param[out] pitch : the pitch of the plane + * @param[out] padding : the padding of the plane + * @return 1 if this function succeeds, otherwise 0. + */ +int +tbm_exynos4412_surface_get_plane_data(tbm_surface_h surface, int width, int height, tbm_format format, int plane_idx, uint32_t *size, uint32_t *offset, uint32_t *pitch) +{ + int ret = 1; + int bpp; + int _offset =0; + int _pitch =0; + int _size =0; + + + switch(format) + { + /* 16 bpp RGB */ + case TBM_FORMAT_XRGB4444: + case TBM_FORMAT_XBGR4444: + case TBM_FORMAT_RGBX4444: + case TBM_FORMAT_BGRX4444: + case TBM_FORMAT_ARGB4444: + case TBM_FORMAT_ABGR4444: + case TBM_FORMAT_RGBA4444: + case TBM_FORMAT_BGRA4444: + case TBM_FORMAT_XRGB1555: + case TBM_FORMAT_XBGR1555: + case TBM_FORMAT_RGBX5551: + case TBM_FORMAT_BGRX5551: + case TBM_FORMAT_ARGB1555: + case TBM_FORMAT_ABGR1555: + case TBM_FORMAT_RGBA5551: + case TBM_FORMAT_BGRA5551: + case TBM_FORMAT_RGB565: + bpp = 16; + _offset = 0; + _pitch = SIZE_ALIGN((width*bpp)>>3,TBM_SURFACE_ALIGNMENT_PITCH_RGB); + _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + break; + /* 24 bpp RGB */ + case TBM_FORMAT_RGB888: + case TBM_FORMAT_BGR888: + bpp = 24; + _offset = 0; + _pitch = SIZE_ALIGN((width*bpp)>>3,TBM_SURFACE_ALIGNMENT_PITCH_RGB); + _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + break; + /* 32 bpp RGB */ + case TBM_FORMAT_XRGB8888: + case TBM_FORMAT_XBGR8888: + case TBM_FORMAT_RGBX8888: + case TBM_FORMAT_BGRX8888: + case TBM_FORMAT_ARGB8888: + case TBM_FORMAT_ABGR8888: + case TBM_FORMAT_RGBA8888: + case TBM_FORMAT_BGRA8888: + bpp = 32; + _offset = 0; + _pitch = SIZE_ALIGN((width*bpp)>>3,TBM_SURFACE_ALIGNMENT_PITCH_RGB); + _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + break; + + /* packed YCbCr */ + case TBM_FORMAT_YUYV: + case TBM_FORMAT_YVYU: + case TBM_FORMAT_UYVY: + case TBM_FORMAT_VYUY: + case TBM_FORMAT_AYUV: + bpp = 32; + _offset = 0; + _pitch = SIZE_ALIGN((width*bpp)>>3,TBM_SURFACE_ALIGNMENT_PITCH_YUV); + _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + break; + + /* + * 2 plane YCbCr + * index 0 = Y plane, [7:0] Y + * index 1 = Cr:Cb plane, [15:0] Cr:Cb little endian + * or + * index 1 = Cb:Cr plane, [15:0] Cb:Cr little endian + */ + case TBM_FORMAT_NV12: + case TBM_FORMAT_NV21: + bpp = 12; + if(plane_idx == 0) + { + _offset = 0; + _pitch = SIZE_ALIGN( width ,TBM_SURFACE_ALIGNMENT_PITCH_YUV); + _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + } + else if( plane_idx ==1 ) + { + _offset = width*height; + _pitch = SIZE_ALIGN( width ,TBM_SURFACE_ALIGNMENT_PITCH_YUV/2); + _size = SIZE_ALIGN(_pitch*(height/2),TBM_SURFACE_ALIGNMENT_PLANE); + } + break; + + case TBM_FORMAT_NV16: + case TBM_FORMAT_NV61: + bpp = 16; + //if(plane_idx == 0) + { + _offset = 0; + _pitch = SIZE_ALIGN(width,TBM_SURFACE_ALIGNMENT_PITCH_YUV); + _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + if(plane_idx == 0) + break; + } + //else if( plane_idx ==1 ) + { + _offset += _size; + _pitch = SIZE_ALIGN(width,TBM_SURFACE_ALIGNMENT_PITCH_YUV/2); + _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + } + break; + + /* + * 3 plane YCbCr + * index 0: Y plane, [7:0] Y + * index 1: Cb plane, [7:0] Cb + * index 2: Cr plane, [7:0] Cr + * or + * index 1: Cr plane, [7:0] Cr + * index 2: Cb plane, [7:0] Cb + */ + /* + NATIVE_BUFFER_FORMAT_YV12 + NATIVE_BUFFER_FORMAT_I420 + */ + case TBM_FORMAT_YUV410: + case TBM_FORMAT_YVU410: + bpp = 9; + break; + case TBM_FORMAT_YUV411: + case TBM_FORMAT_YVU411: + case TBM_FORMAT_YUV420: + case TBM_FORMAT_YVU420: + bpp = 12; + //if(plane_idx == 0) + { + _offset = 0; + _pitch = SIZE_ALIGN(width,TBM_SURFACE_ALIGNMENT_PITCH_YUV); + _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + if(plane_idx == 0) + break; + } + //else if( plane_idx == 1 ) + { + _offset += _size; + _pitch = SIZE_ALIGN(width/2,TBM_SURFACE_ALIGNMENT_PITCH_YUV/2); + _size = SIZE_ALIGN(_pitch*(height/2),TBM_SURFACE_ALIGNMENT_PLANE); + if(plane_idx == 1) + break; + } + //else if (plane_idx == 2 ) + { + _offset += _size; + _pitch = SIZE_ALIGN(width/2,TBM_SURFACE_ALIGNMENT_PITCH_YUV/2); + _size = SIZE_ALIGN(_pitch*(height/2),TBM_SURFACE_ALIGNMENT_PLANE); + } + break; + case TBM_FORMAT_YUV422: + case TBM_FORMAT_YVU422: + bpp = 16; + //if(plane_idx == 0) + { + _offset = 0; + _pitch = SIZE_ALIGN(width,TBM_SURFACE_ALIGNMENT_PITCH_YUV); + _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + if(plane_idx == 0) + break; + } + //else if( plane_idx == 1 ) + { + _offset += _size; + _pitch = SIZE_ALIGN(width/2,TBM_SURFACE_ALIGNMENT_PITCH_YUV/2); + _size = SIZE_ALIGN(_pitch*(height),TBM_SURFACE_ALIGNMENT_PLANE); + if(plane_idx == 1) + break; + } + //else if (plane_idx == 2 ) + { + _offset += _size; + _pitch = SIZE_ALIGN(width/2,TBM_SURFACE_ALIGNMENT_PITCH_YUV/2); + _size = SIZE_ALIGN(_pitch*(height),TBM_SURFACE_ALIGNMENT_PLANE); + } + break; + case TBM_FORMAT_YUV444: + case TBM_FORMAT_YVU444: + bpp = 24; + //if(plane_idx == 0) + { + _offset = 0; + _pitch = SIZE_ALIGN(width,TBM_SURFACE_ALIGNMENT_PITCH_YUV); + _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + if(plane_idx == 0) + break; + } + //else if( plane_idx == 1 ) + { + _offset += _size; + _pitch = SIZE_ALIGN(width,TBM_SURFACE_ALIGNMENT_PITCH_YUV); + _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + if(plane_idx == 1) + break; + } + //else if (plane_idx == 2 ) + { + _offset += _size; + _pitch = SIZE_ALIGN(width,TBM_SURFACE_ALIGNMENT_PITCH_YUV); + _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + } + break; + default: + bpp = 0; + break; + } + + *size = _size; + *offset = _offset; + *pitch = _pitch; + + return ret; +} +/** +* @brief get the size of the surface with a format. +* @param[in] surface : the surface +* @param[in] width : the width of the surface +* @param[in] height : the height of the surface +* @param[in] format : the format of the surface +* @return size of the surface if this function succeeds, otherwise 0. +*/ + +int +tbm_exynos4412_surface_get_size(tbm_surface_h surface, int width, int height, tbm_format format) +{ + int ret = 0; + int bpp = 0; + int _pitch =0; + int _size =0; + int align =TBM_SURFACE_ALIGNMENT_PLANE; + + switch(format) + { + /* 16 bpp RGB */ + case TBM_FORMAT_XRGB4444: + case TBM_FORMAT_XBGR4444: + case TBM_FORMAT_RGBX4444: + case TBM_FORMAT_BGRX4444: + case TBM_FORMAT_ARGB4444: + case TBM_FORMAT_ABGR4444: + case TBM_FORMAT_RGBA4444: + case TBM_FORMAT_BGRA4444: + case TBM_FORMAT_XRGB1555: + case TBM_FORMAT_XBGR1555: + case TBM_FORMAT_RGBX5551: + case TBM_FORMAT_BGRX5551: + case TBM_FORMAT_ARGB1555: + case TBM_FORMAT_ABGR1555: + case TBM_FORMAT_RGBA5551: + case TBM_FORMAT_BGRA5551: + case TBM_FORMAT_RGB565: + bpp = 16; + _pitch = SIZE_ALIGN((width*bpp)>>3,TBM_SURFACE_ALIGNMENT_PITCH_RGB); + _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + break; + /* 24 bpp RGB */ + case TBM_FORMAT_RGB888: + case TBM_FORMAT_BGR888: + bpp = 24; + _pitch = SIZE_ALIGN((width*bpp)>>3,TBM_SURFACE_ALIGNMENT_PITCH_RGB); + _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + break; + /* 32 bpp RGB */ + case TBM_FORMAT_XRGB8888: + case TBM_FORMAT_XBGR8888: + case TBM_FORMAT_RGBX8888: + case TBM_FORMAT_BGRX8888: + case TBM_FORMAT_ARGB8888: + case TBM_FORMAT_ABGR8888: + case TBM_FORMAT_RGBA8888: + case TBM_FORMAT_BGRA8888: + bpp = 32; + _pitch = SIZE_ALIGN((width*bpp)>>3,TBM_SURFACE_ALIGNMENT_PITCH_RGB); + _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + break; + /* packed YCbCr */ + case TBM_FORMAT_YUYV: + case TBM_FORMAT_YVYU: + case TBM_FORMAT_UYVY: + case TBM_FORMAT_VYUY: + case TBM_FORMAT_AYUV: + bpp = 32; + _pitch = SIZE_ALIGN((width*bpp)>>3,TBM_SURFACE_ALIGNMENT_PITCH_YUV); + _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + break; + /* + * 2 plane YCbCr + * index 0 = Y plane, [7:0] Y + * index 1 = Cr:Cb plane, [15:0] Cr:Cb little endian + * or + * index 1 = Cb:Cr plane, [15:0] Cb:Cr little endian + */ + case TBM_FORMAT_NV12: + case TBM_FORMAT_NV21: + bpp = 12; + //plane_idx == 0 + { + _pitch = SIZE_ALIGN( width ,TBM_SURFACE_ALIGNMENT_PITCH_YUV); + _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + } + //plane_idx ==1 + { + _pitch = SIZE_ALIGN( width ,TBM_SURFACE_ALIGNMENT_PITCH_YUV/2); + _size += SIZE_ALIGN(_pitch*(height/2),TBM_SURFACE_ALIGNMENT_PLANE); + } + break; + + break; + case TBM_FORMAT_NV16: + case TBM_FORMAT_NV61: + bpp = 16; + //plane_idx == 0 + { + _pitch = SIZE_ALIGN(width,TBM_SURFACE_ALIGNMENT_PITCH_YUV); + _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + } + //plane_idx ==1 + { + _pitch = SIZE_ALIGN(width,TBM_SURFACE_ALIGNMENT_PITCH_YUV/2); + _size += SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + } + + break; + /* + * 3 plane YCbCr + * index 0: Y plane, [7:0] Y + * index 1: Cb plane, [7:0] Cb + * index 2: Cr plane, [7:0] Cr + * or + * index 1: Cr plane, [7:0] Cr + * index 2: Cb plane, [7:0] Cb + */ + case TBM_FORMAT_YUV410: + case TBM_FORMAT_YVU410: + bpp = 9; + align = TBM_SURFACE_ALIGNMENT_PITCH_YUV; + break; + case TBM_FORMAT_YUV411: + case TBM_FORMAT_YVU411: + case TBM_FORMAT_YUV420: + case TBM_FORMAT_YVU420: + bpp = 12; + //plane_idx == 0 + { + _pitch = SIZE_ALIGN(width,TBM_SURFACE_ALIGNMENT_PITCH_YUV); + _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + } + //plane_idx == 1 + { + _pitch = SIZE_ALIGN(width/2,TBM_SURFACE_ALIGNMENT_PITCH_YUV/2); + _size += SIZE_ALIGN(_pitch*(height/2),TBM_SURFACE_ALIGNMENT_PLANE); + } + //plane_idx == 2 + { + _pitch = SIZE_ALIGN(width/2,TBM_SURFACE_ALIGNMENT_PITCH_YUV/2); + _size += SIZE_ALIGN(_pitch*(height/2),TBM_SURFACE_ALIGNMENT_PLANE); + } + + break; + case TBM_FORMAT_YUV422: + case TBM_FORMAT_YVU422: + bpp = 16; + //plane_idx == 0 + { + _pitch = SIZE_ALIGN(width,TBM_SURFACE_ALIGNMENT_PITCH_YUV); + _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + } + //plane_idx == 1 + { + _pitch = SIZE_ALIGN(width/2,TBM_SURFACE_ALIGNMENT_PITCH_YUV/2); + _size += SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + } + //plane_idx == 2 + { + _pitch = SIZE_ALIGN(width/2,TBM_SURFACE_ALIGNMENT_PITCH_YUV/2); + _size += SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + } + break; + case TBM_FORMAT_YUV444: + case TBM_FORMAT_YVU444: + bpp = 24; + align = TBM_SURFACE_ALIGNMENT_PITCH_YUV; + break; + + default: + bpp = 0; + break; + } + + if(_size > 0) + ret = _size; + else + ret = SIZE_ALIGN( (width * height * bpp) >> 3, align); + + return ret; + +} + MODULEINITPPROTO (init_tbm_bufmgr_priv); static TBMModuleVersionInfo Exynos4412VersRec = @@ -1078,6 +1582,9 @@ init_tbm_bufmgr_priv (tbm_bufmgr bufmgr, int fd) bufmgr_backend->bo_unmap = tbm_exynos4412_bo_unmap, bufmgr_backend->bo_cache_flush = tbm_exynos4412_bo_cache_flush, bufmgr_backend->bo_get_global_key = tbm_exynos4412_bo_get_global_key; + bufmgr_backend->surface_get_plane_data = tbm_exynos4412_surface_get_plane_data; + bufmgr_backend->surface_get_size = tbm_exynos4412_surface_get_size; + bufmgr_backend->surface_supported_format = tbm_exynos4412_surface_supported_format; if (bufmgr_exynos4412->use_dma_fence) { -- 2.7.4 From 4b9a8fb58812df1b185874f98f606867445a412b Mon Sep 17 00:00:00 2001 From: Roman Marchenko Date: Fri, 26 Sep 2014 16:38:58 +0300 Subject: [PATCH 03/16] add the code for supporting the tbm_fd Change-Id: I4b1db124e57228f6ea1f8696b17ca7e03fb37209 Signed-off-by: Roman Marchenko --- src/tbm_bufmgr_exynos4412.c | 151 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 149 insertions(+), 2 deletions(-) mode change 100755 => 100644 src/tbm_bufmgr_exynos4412.c diff --git a/src/tbm_bufmgr_exynos4412.c b/src/tbm_bufmgr_exynos4412.c old mode 100755 new mode 100644 index 9f47379..24214c2 --- a/src/tbm_bufmgr_exynos4412.c +++ b/src/tbm_bufmgr_exynos4412.c @@ -684,9 +684,121 @@ tbm_exynos4412_bo_import (tbm_bo bo, unsigned int key) getpid(), __FUNCTION__, __LINE__, bo_exynos4412->name); } - DBG ("[libtbm-exynos4412:%d] %s size:%d, gem:%d(%d), flags:%d(%d)\n", getpid(), + DBG ("[libtbm-exynos4412:%d] %s size:%d, gem:%d(%d, %d), flags:%d(%d)\n", getpid(), __FUNCTION__, bo_exynos4412->size, - bo_exynos4412->gem, bo_exynos4412->name, + bo_exynos4412->gem, bo_exynos4412->name, bo_exynos4412->dmabuf, + bo_exynos4412->flags_tbm, bo_exynos4412->flags_exynos); + + return (void *)bo_exynos4412; +} + +static void * +tbm_exynos4412_bo_import_fd (tbm_bo bo, tbm_fd key) +{ + EXYNOS4412_RETURN_VAL_IF_FAIL (bo!=NULL, 0); + + tbm_bufmgr_exynos4412 bufmgr_exynos4412; + tbm_bo_exynos4412 bo_exynos4412; + + bufmgr_exynos4412 = (tbm_bufmgr_exynos4412)tbm_backend_get_bufmgr_priv(bo); + EXYNOS4412_RETURN_VAL_IF_FAIL (bufmgr_exynos4412!=NULL, 0); + + unsigned int gem = 0; + unsigned int real_size = -1; + struct drm_exynos_gem_info info = {0, }; + + //getting handle from fd + struct drm_prime_handle arg = {0, }; + + arg.fd = key; + arg.flags = 0; + if (drmIoctl (bufmgr_exynos4412->fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &arg)) + { + TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " + "error %s:%d Cannot getting gem from prime fd=%d\n", + getpid(), __FUNCTION__, __LINE__, arg.fd); + return NULL; + } + gem = arg.handle; + + /* Determine size of bo. The fd-to-handle ioctl really should + * return the size, but it doesn't. If we have kernel 3.12 or + * later, we can lseek on the prime fd to get the size. Older + * kernels will just fail, in which case we fall back to the + * provided (estimated or guess size). */ + real_size = lseek(key, 0, SEEK_END); + + info.handle = gem; + if (drmCommandWriteRead(bufmgr_exynos4412->fd, + DRM_EXYNOS_GEM_GET, + &info, + sizeof(struct drm_exynos_gem_info))) + { + TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " + "error %s:%d Cannot get gem info=%d\n", + getpid(), __FUNCTION__, __LINE__, key); + return 0; + } + + if (real_size == -1) + real_size = info.size; + + bo_exynos4412 = calloc (1, sizeof(struct _tbm_bo_exynos4412)); + if (!bo_exynos4412) + { + TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " + "error %s:%d fail to allocate the bo private\n", + getpid(), __FUNCTION__, __LINE__); + return 0; + } + + bo_exynos4412->fd = bufmgr_exynos4412->fd; + bo_exynos4412->gem = gem; + bo_exynos4412->size = real_size; + bo_exynos4412->flags_exynos = info.flags; + bo_exynos4412->flags_tbm = _get_tbm_flag_from_exynos (bo_exynos4412->flags_exynos); + + bo_exynos4412->name = _get_name(bo_exynos4412->fd, bo_exynos4412->gem); + if (!bo_exynos4412->name) + { + TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " + "error %s:%d Cannot get name\n", + getpid(), __FUNCTION__, __LINE__); + return 0; + } + + bo_exynos4412->dmabuf = (unsigned int)key; + + /* add bo to hash */ + PrivGem *privGem = NULL; + int ret; + + ret = drmHashLookup (bufmgr_exynos4412->hashBos, bo_exynos4412->name, (void**)&privGem); + if (ret == 0) + { + privGem->ref_count++; + } + else if (ret == 1) + { + privGem = calloc (1, sizeof(PrivGem)); + privGem->ref_count = 1; + if (drmHashInsert (bufmgr_exynos4412->hashBos, bo_exynos4412->name, (void *)privGem) < 0) + { + TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " + "error %s:%d Cannot insert bo to Hash(%d)\n", + getpid(), __FUNCTION__, __LINE__, bo_exynos4412->name); + } + } + else + { + TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " + "error %s:%d Cannot insert bo to Hash(%d)\n", + getpid(), __FUNCTION__, __LINE__, bo_exynos4412->name); + } + + DBG ("[libtbm-exynos4412:%d] %s size:%d, gem:%d(%d,%d), flags:%d(%d)\n", getpid(), + __FUNCTION__, bo_exynos4412->size, + bo_exynos4412->gem, bo_exynos4412->name, bo_exynos4412->dmabuf, bo_exynos4412->flags_tbm, bo_exynos4412->flags_exynos); return (void *)bo_exynos4412; @@ -722,6 +834,39 @@ tbm_exynos4412_bo_export (tbm_bo bo) return (unsigned int)bo_exynos4412->name; } +tbm_fd +tbm_exynos4412_bo_export_fd (tbm_bo bo) +{ + EXYNOS4412_RETURN_VAL_IF_FAIL (bo!=NULL, 0); + + tbm_bo_exynos4412 bo_exynos4412; + + bo_exynos4412 = (tbm_bo_exynos4412)tbm_backend_get_bo_priv(bo); + EXYNOS4412_RETURN_VAL_IF_FAIL (bo_exynos4412!=NULL, 0); + + if (!bo_exynos4412->dmabuf) + { + struct drm_prime_handle arg = {0, }; + + arg.handle = bo_exynos4412->gem; + if (drmIoctl (bo_exynos4412->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) + { + TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " + "error %s:%d Cannot dmabuf=%d\n", + getpid(), __FUNCTION__, __LINE__, bo_exynos4412->gem); + return (tbm_fd) NULL; + } + bo_exynos4412->dmabuf = arg.fd; + } + + DBG ("[libtbm-exynos4412:%d] %s size:%d, gem:%d(%d, %d), flags:%d(%d)\n", getpid(), + __FUNCTION__, bo_exynos4412->size, + bo_exynos4412->gem, bo_exynos4412->name, bo_exynos4412->dmabuf, + bo_exynos4412->flags_tbm, bo_exynos4412->flags_exynos); + + return (tbm_fd)bo_exynos4412->dmabuf; +} + static tbm_bo_handle tbm_exynos4412_bo_get_handle (tbm_bo bo, int device) { @@ -1576,7 +1721,9 @@ init_tbm_bufmgr_priv (tbm_bufmgr bufmgr, int fd) bufmgr_backend->bo_alloc = tbm_exynos4412_bo_alloc, bufmgr_backend->bo_free = tbm_exynos4412_bo_free, bufmgr_backend->bo_import = tbm_exynos4412_bo_import, + bufmgr_backend->bo_import_fd = tbm_exynos4412_bo_import_fd, bufmgr_backend->bo_export = tbm_exynos4412_bo_export, + bufmgr_backend->bo_export_fd = tbm_exynos4412_bo_export_fd, bufmgr_backend->bo_get_handle = tbm_exynos4412_bo_get_handle, bufmgr_backend->bo_map = tbm_exynos4412_bo_map, bufmgr_backend->bo_unmap = tbm_exynos4412_bo_unmap, -- 2.7.4 From 705d30370726a7f25dec9d726a0b0591a04332b6 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Wed, 17 Dec 2014 14:47:49 +0900 Subject: [PATCH 04/16] fix -Werror=int-to-pointer-cast, -Werror=pointer-to-int-cast error at 64bits system Change-Id: Ib4ae382e5e34c700d13568c2080c331304881fc1 --- packaging/libtbm-exynos4412.spec | 2 +- src/tbm_bufmgr_exynos4412.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packaging/libtbm-exynos4412.spec b/packaging/libtbm-exynos4412.spec index 5e7b391..4142fee 100644 --- a/packaging/libtbm-exynos4412.spec +++ b/packaging/libtbm-exynos4412.spec @@ -1,6 +1,6 @@ Name: libtbm-exynos4412 Version: 1.0.5 -Release: 1 +Release: 2 License: MIT Summary: Tizen Buffer Manager - exynos4412 backend Group: System/Libraries diff --git a/src/tbm_bufmgr_exynos4412.c b/src/tbm_bufmgr_exynos4412.c index 24214c2..cd6b28d 100644 --- a/src/tbm_bufmgr_exynos4412.c +++ b/src/tbm_bufmgr_exynos4412.c @@ -305,7 +305,7 @@ _exynos4412_bo_handle (tbm_bo_exynos4412 bo_exynos4412, int device) getpid(), __FUNCTION__, __LINE__, bo_exynos4412->gem); return (tbm_bo_handle) NULL; } - bo_exynos4412->pBase = (void*)((uint32_t)arg.mapped); + bo_exynos4412->pBase = (void*)((uint64_t)arg.mapped); } bo_handle.ptr = (void *)bo_exynos4412->pBase; @@ -854,7 +854,7 @@ tbm_exynos4412_bo_export_fd (tbm_bo bo) TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " "error %s:%d Cannot dmabuf=%d\n", getpid(), __FUNCTION__, __LINE__, bo_exynos4412->gem); - return (tbm_fd) NULL; + return (tbm_fd) 0; } bo_exynos4412->dmabuf = arg.fd; } -- 2.7.4 From d2e9b801c2546ef35dafd21363f0485815c3c5cb Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Wed, 17 Dec 2014 19:19:20 +0900 Subject: [PATCH 05/16] Fix type cast Change-Id: I76585a1f8f6f2fb49dbe5c14facda147798788fb --- src/tbm_bufmgr_exynos4412.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tbm_bufmgr_exynos4412.c b/src/tbm_bufmgr_exynos4412.c index cd6b28d..2ceabc2 100644 --- a/src/tbm_bufmgr_exynos4412.c +++ b/src/tbm_bufmgr_exynos4412.c @@ -305,7 +305,7 @@ _exynos4412_bo_handle (tbm_bo_exynos4412 bo_exynos4412, int device) getpid(), __FUNCTION__, __LINE__, bo_exynos4412->gem); return (tbm_bo_handle) NULL; } - bo_exynos4412->pBase = (void*)((uint64_t)arg.mapped); + bo_exynos4412->pBase = (void*)((unsigned int)arg.mapped); } bo_handle.ptr = (void *)bo_exynos4412->pBase; -- 2.7.4 From ebfe781ab02c30d1811d8f97b5a704ffe8a33dcb Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Wed, 17 Dec 2014 20:21:04 +0900 Subject: [PATCH 06/16] Fix type casting error at 64bit system Change-Id: Ic942460148bbb758d07734df6a0f40a77d64f032 --- src/tbm_bufmgr_exynos4412.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tbm_bufmgr_exynos4412.c b/src/tbm_bufmgr_exynos4412.c index 2ceabc2..7cf4a6e 100644 --- a/src/tbm_bufmgr_exynos4412.c +++ b/src/tbm_bufmgr_exynos4412.c @@ -305,7 +305,7 @@ _exynos4412_bo_handle (tbm_bo_exynos4412 bo_exynos4412, int device) getpid(), __FUNCTION__, __LINE__, bo_exynos4412->gem); return (tbm_bo_handle) NULL; } - bo_exynos4412->pBase = (void*)((unsigned int)arg.mapped); + bo_exynos4412->pBase = (void*)((unsigned long)arg.mapped); } bo_handle.ptr = (void *)bo_exynos4412->pBase; -- 2.7.4 From a7e69c25a2c97df27732c008de813ae7f7aca9c1 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Fri, 19 Dec 2014 16:00:05 +0900 Subject: [PATCH 07/16] Fix cache control configuration Change-Id: Id46aef7e7503a2748fd2de37f88c813f0eb81cd4 Signed-off-by: Changyeon Lee --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 37bf4f4..d2c8030 100644 --- a/configure.ac +++ b/configure.ac @@ -42,7 +42,7 @@ PKG_CHECK_MODULES(LIBTBM, libtbm) PKG_CHECK_MODULES(DLOG, dlog) AC_ARG_ENABLE(cachectrl, - AS_HELP_STRING([--enable-cache-crtl], + AS_HELP_STRING([--enable-cachecrtl], [Enable cache control (default: enable)]), [CACHE_CTRL=$enableval], [CACHE_CTRL=yes]) -- 2.7.4 From 89adceef2c29073fcadc033fe1d16be89bad1f25 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Wed, 7 Jan 2015 18:57:41 +0900 Subject: [PATCH 08/16] Fix cache control configure name Change-Id: Id58c9954eff46121cdb60f3f5bb6be5a3735bc66 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index d2c8030..37b3f99 100644 --- a/configure.ac +++ b/configure.ac @@ -42,7 +42,7 @@ PKG_CHECK_MODULES(LIBTBM, libtbm) PKG_CHECK_MODULES(DLOG, dlog) AC_ARG_ENABLE(cachectrl, - AS_HELP_STRING([--enable-cachecrtl], + AS_HELP_STRING([--enable-cachectrl], [Enable cache control (default: enable)]), [CACHE_CTRL=$enableval], [CACHE_CTRL=yes]) -- 2.7.4 From d4734dbead1ab3dfab42cfc8e21a45e42856f1a7 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Wed, 7 Jan 2015 19:12:06 +0900 Subject: [PATCH 09/16] Pacakge version up Change-Id: I1d22ab4b99a4ac2f7a3caa586f275cb7e9fc7239 --- packaging/libtbm-exynos4412.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/libtbm-exynos4412.spec b/packaging/libtbm-exynos4412.spec index 4142fee..924aec4 100644 --- a/packaging/libtbm-exynos4412.spec +++ b/packaging/libtbm-exynos4412.spec @@ -1,6 +1,6 @@ Name: libtbm-exynos4412 -Version: 1.0.5 -Release: 2 +Version: 1.0.6 +Release: 1 License: MIT Summary: Tizen Buffer Manager - exynos4412 backend Group: System/Libraries -- 2.7.4 From 638386a69677cff60d73ee55963ff1c2e448927c Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Tue, 27 Jan 2015 20:52:49 +0900 Subject: [PATCH 10/16] Change DRM_EXYNOS_GEM_MAP to DRM_IOCTL_MODE_MAP_DUMB and mmap Change-Id: I16e7f95bf713fd9c0d8100fd2d91a19eca25ce16 Signed-off-by: Changyeon Lee --- src/tbm_bufmgr_exynos4412.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) mode change 100644 => 100755 src/tbm_bufmgr_exynos4412.c diff --git a/src/tbm_bufmgr_exynos4412.c b/src/tbm_bufmgr_exynos4412.c old mode 100644 new mode 100755 index 7cf4a6e..0f90ffd --- a/src/tbm_bufmgr_exynos4412.c +++ b/src/tbm_bufmgr_exynos4412.c @@ -294,18 +294,28 @@ _exynos4412_bo_handle (tbm_bo_exynos4412 bo_exynos4412, int device) case TBM_DEVICE_CPU: if (!bo_exynos4412->pBase) { - struct drm_exynos_gem_mmap arg = {0,}; + struct drm_mode_map_dumb arg = {0,}; + void *map = NULL; arg.handle = bo_exynos4412->gem; - arg.size = bo_exynos4412->size; - if (drmCommandWriteRead (bo_exynos4412->fd, DRM_EXYNOS_GEM_MMAP, &arg, sizeof(arg))) + if (drmIoctl (bo_exynos4412->fd, DRM_IOCTL_MODE_MAP_DUMB, &arg)) + { + TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " + "error %s:%d Cannot map_dumb gem=%d\n", + getpid(), __FUNCTION__, __LINE__, bo_exynos4412->gem); + return (tbm_bo_handle) NULL; + } + + map = mmap (NULL, bo_exynos4412->size, PROT_READ|PROT_WRITE, MAP_SHARED, + bo_exynos4412->fd, arg.offset); + if (map == MAP_FAILED) { TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " "error %s:%d Cannot usrptr gem=%d\n", getpid(), __FUNCTION__, __LINE__, bo_exynos4412->gem); return (tbm_bo_handle) NULL; } - bo_exynos4412->pBase = (void*)((unsigned long)arg.mapped); + bo_exynos4412->pBase = map; } bo_handle.ptr = (void *)bo_exynos4412->pBase; -- 2.7.4 From e8cc5c977c34a10758e7f3011f469ccf37c648e8 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Tue, 2 Jun 2015 16:03:43 +0900 Subject: [PATCH 11/16] Bump up version 1.0.8 sync code spin tizen_2.4 Change-Id: I16362f9848d8edfaef72b99e1cb6ce1e5d3dc452 --- packaging/libtbm-exynos4412.spec | 2 +- src/tbm_bufmgr_exynos4412.c | 341 ++++++++++++++++++++------------------- 2 files changed, 176 insertions(+), 167 deletions(-) diff --git a/packaging/libtbm-exynos4412.spec b/packaging/libtbm-exynos4412.spec index 924aec4..c148012 100644 --- a/packaging/libtbm-exynos4412.spec +++ b/packaging/libtbm-exynos4412.spec @@ -1,5 +1,5 @@ Name: libtbm-exynos4412 -Version: 1.0.6 +Version: 1.0.8 Release: 1 License: MIT Summary: Tizen Buffer Manager - exynos4412 backend diff --git a/src/tbm_bufmgr_exynos4412.c b/src/tbm_bufmgr_exynos4412.c index 0f90ffd..354e1a9 100755 --- a/src/tbm_bufmgr_exynos4412.c +++ b/src/tbm_bufmgr_exynos4412.c @@ -97,8 +97,8 @@ char* target_name() return app_name; } -#define TBM_EXYNOS4412_LOG(fmt, args...) LOGE("\033[31m" "[%s]" fmt "\033[0m", target_name(), ##args) -#define DBG(fmt, args...) if(bDebug&01) LOGE("[%s]" fmt, target_name(), ##args) +#define TBM_EXYNOS4412_LOG(fmt, args...) LOGE("\033[31m" "[%s]" fmt "\033[0m", target_name(), ##args) +#define DBG(fmt, args...) if(bDebug&01) LOGE(fmt, ##args) #else #define TBM_EXYNOS4412_LOG(...) #define DBG(...) @@ -270,9 +270,8 @@ _get_name (int fd, unsigned int gem) arg.handle = gem; if (drmIoctl (fd, DRM_IOCTL_GEM_FLINK, &arg)) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d fail to get flink gem=%d\n", - getpid(), __FUNCTION__, __LINE__, gem); + TBM_EXYNOS4412_LOG ("error fail to get flink from gem:%d (DRM_IOCTL_GEM_FLINK)\n", + gem); return 0; } @@ -300,24 +299,19 @@ _exynos4412_bo_handle (tbm_bo_exynos4412 bo_exynos4412, int device) arg.handle = bo_exynos4412->gem; if (drmIoctl (bo_exynos4412->fd, DRM_IOCTL_MODE_MAP_DUMB, &arg)) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d Cannot map_dumb gem=%d\n", - getpid(), __FUNCTION__, __LINE__, bo_exynos4412->gem); - return (tbm_bo_handle) NULL; + TBM_EXYNOS4412_LOG ("error Cannot map_dumb gem=%d\n", bo_exynos4412->gem); + return (tbm_bo_handle) NULL; } map = mmap (NULL, bo_exynos4412->size, PROT_READ|PROT_WRITE, MAP_SHARED, bo_exynos4412->fd, arg.offset); if (map == MAP_FAILED) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d Cannot usrptr gem=%d\n", - getpid(), __FUNCTION__, __LINE__, bo_exynos4412->gem); + TBM_EXYNOS4412_LOG ("error Cannot usrptr gem=%d\n", bo_exynos4412->gem); return (tbm_bo_handle) NULL; } bo_exynos4412->pBase = map; } - bo_handle.ptr = (void *)bo_exynos4412->pBase; break; case TBM_DEVICE_3D: @@ -335,9 +329,7 @@ _exynos4412_bo_handle (tbm_bo_exynos4412 bo_exynos4412, int device) arg.handle = bo_exynos4412->gem; if (drmIoctl (bo_exynos4412->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d Cannot dmabuf=%d\n", - getpid(), __FUNCTION__, __LINE__, bo_exynos4412->gem); + TBM_EXYNOS4412_LOG ("error Cannot dmabuf=%d\n", bo_exynos4412->gem); return (tbm_bo_handle) NULL; } bo_exynos4412->dmabuf = arg.fd; @@ -354,9 +346,7 @@ _exynos4412_bo_handle (tbm_bo_exynos4412 bo_exynos4412, int device) arg.handle = bo_exynos4412->gem; if (drmIoctl (bo_exynos4412->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d Cannot dmabuf=%d\n", - getpid(), __FUNCTION__, __LINE__, bo_exynos4412->gem); + TBM_EXYNOS4412_LOG ("error Cannot dmabuf=%d\n", bo_exynos4412->gem); return (tbm_bo_handle) NULL; } bo_exynos4412->dmabuf = arg.fd; @@ -365,9 +355,7 @@ _exynos4412_bo_handle (tbm_bo_exynos4412 bo_exynos4412, int device) bo_handle.u32 = (uint32_t)bo_exynos4412->dmabuf; break; default: - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d Not supported device:%d\n", - getpid(), __FUNCTION__, __LINE__, device); + TBM_EXYNOS4412_LOG ("error Not supported device:%d\n", device); bo_handle.ptr = (void *) NULL; break; } @@ -419,15 +407,11 @@ _exynos4412_cache_flush (int fd, tbm_bo_exynos4412 bo_exynos4412, int flags) ret = drmCommandWriteRead (fd, DRM_EXYNOS_GEM_CACHE_OP, &cache_op, sizeof(cache_op)); if (ret) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d fail to flush the cache.\n", - getpid(), __FUNCTION__, __LINE__); + TBM_EXYNOS4412_LOG ("error fail to flush the cache.\n"); return 0; } #else - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "warning %s:%d fail to enable the cache flush.\n", - getpid(), __FUNCTION__, __LINE__); + TBM_EXYNOS4412_LOG ("warning fail to enable the cache flush.\n"); #endif return 1; } @@ -459,9 +443,7 @@ tbm_exynos4412_bo_alloc (tbm_bo bo, int size, int flags) bo_exynos4412 = calloc (1, sizeof(struct _tbm_bo_exynos4412)); if (!bo_exynos4412) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d fail to allocate the bo private\n", - getpid(), __FUNCTION__, __LINE__); + TBM_EXYNOS4412_LOG ("error fail to allocate the bo private\n"); return 0; } @@ -477,9 +459,7 @@ tbm_exynos4412_bo_alloc (tbm_bo bo, int size, int flags) arg.flags = exynos_flags; if (drmCommandWriteRead(bufmgr_exynos4412->fd, DRM_EXYNOS_GEM_CREATE, &arg, sizeof(arg))) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d Cannot create bo(flag:%x, size:%d)\n", - getpid(), __FUNCTION__, __LINE__, arg.flags, (unsigned int)arg.size); + TBM_EXYNOS4412_LOG ("error Cannot create bo(flag:%x, size:%d)\n", arg.flags, (unsigned int)arg.size); free (bo_exynos4412); return 0; } @@ -501,9 +481,7 @@ tbm_exynos4412_bo_alloc (tbm_bo bo, int size, int flags) arg.handle = bo_exynos4412->gem; if (drmIoctl (bo_exynos4412->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d Cannot dmabuf=%d\n", - getpid(), __FUNCTION__, __LINE__, bo_exynos4412->gem); + TBM_EXYNOS4412_LOG ("error Cannot dmabuf=%d\n", bo_exynos4412->gem); free (bo_exynos4412); return 0; } @@ -515,15 +493,14 @@ tbm_exynos4412_bo_alloc (tbm_bo bo, int size, int flags) privGem->ref_count = 1; if (drmHashInsert(bufmgr_exynos4412->hashBos, bo_exynos4412->name, (void *)privGem) < 0) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d Cannot insert bo to Hash(%d)\n", - getpid(), __FUNCTION__, __LINE__, bo_exynos4412->name); + TBM_EXYNOS4412_LOG ("error Cannot insert bo to Hash(%d)\n", bo_exynos4412->name); } - DBG ("[libtbm-exynos4412:%d] %s size:%d, gem:%d(%d), flags:%d(%d)\n", getpid(), - __FUNCTION__, bo_exynos4412->size, + DBG (" [%s] bo:%p, gem:%d(%d), flags:%d(%d), size:%d\n", target_name(), + bo, bo_exynos4412->gem, bo_exynos4412->name, - flags, exynos_flags); + flags, exynos_flags, + bo_exynos4412->size); return (void *)bo_exynos4412; } @@ -543,16 +520,18 @@ tbm_exynos4412_bo_free(tbm_bo bo) bo_exynos4412 = (tbm_bo_exynos4412)tbm_backend_get_bo_priv(bo); EXYNOS4412_RETURN_IF_FAIL (bo_exynos4412!=NULL); - DBG ("[libtbm-exynos4412:%d] %s size:%d, gem:%d(%d)\n", - getpid(), __FUNCTION__, bo_exynos4412->size, bo_exynos4412->gem, bo_exynos4412->name); + DBG (" [%s] bo:%p, gem:%d(%d), fd:%d, size:%d\n",target_name(), + bo, + bo_exynos4412->gem, bo_exynos4412->name, + bo_exynos4412->dmabuf, + bo_exynos4412->size); if (bo_exynos4412->pBase) { if (munmap(bo_exynos4412->pBase, bo_exynos4412->size) == -1) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d\n", - getpid(), __FUNCTION__, __LINE__); + TBM_EXYNOS4412_LOG ("error bo:%p fail to munmap(%s)\n", + bo, strerror(errno)); } } @@ -580,9 +559,7 @@ tbm_exynos4412_bo_free(tbm_bo bo) } else { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "warning %s:%d Cannot find bo to Hash(%d), ret=%d\n", - getpid(), __FUNCTION__, __LINE__, bo_exynos4412->name, ret); + TBM_EXYNOS4412_LOG ("warning Cannot find bo to Hash(%d), ret=%d\n", bo_exynos4412->name, ret); } /* Free gem handle */ @@ -591,9 +568,8 @@ tbm_exynos4412_bo_free(tbm_bo bo) arg.handle = bo_exynos4412->gem; if (drmIoctl (bo_exynos4412->fd, DRM_IOCTL_GEM_CLOSE, &arg)) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d\n", - getpid(), __FUNCTION__, __LINE__); + TBM_EXYNOS4412_LOG ("error bo:%p fail to gem close.(%s)\n", + bo, strerror(errno)); } free (bo_exynos4412); @@ -617,9 +593,7 @@ tbm_exynos4412_bo_import (tbm_bo bo, unsigned int key) arg.name = key; if (drmIoctl(bufmgr_exynos4412->fd, DRM_IOCTL_GEM_OPEN, &arg)) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d Cannot open gem name=%d\n", - getpid(), __FUNCTION__, __LINE__, key); + TBM_EXYNOS4412_LOG ("error Cannot open gem name=%d\n", key); return 0; } @@ -629,18 +603,14 @@ tbm_exynos4412_bo_import (tbm_bo bo, unsigned int key) &info, sizeof(struct drm_exynos_gem_info))) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d Cannot get gem info=%d\n", - getpid(), __FUNCTION__, __LINE__, key); + TBM_EXYNOS4412_LOG ("error Cannot get gem info=%d\n", key); return 0; } bo_exynos4412 = calloc (1, sizeof(struct _tbm_bo_exynos4412)); if (!bo_exynos4412) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d fail to allocate the bo private\n", - getpid(), __FUNCTION__, __LINE__); + TBM_EXYNOS4412_LOG ("error fail to allocate the bo private\n"); return 0; } @@ -658,9 +628,7 @@ tbm_exynos4412_bo_import (tbm_bo bo, unsigned int key) arg.handle = bo_exynos4412->gem; if (drmIoctl (bo_exynos4412->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d Cannot dmabuf=%d\n", - getpid(), __FUNCTION__, __LINE__, bo_exynos4412->gem); + TBM_EXYNOS4412_LOG ("error Cannot dmabuf=%d\n", bo_exynos4412->gem); free (bo_exynos4412); return 0; } @@ -682,22 +650,20 @@ tbm_exynos4412_bo_import (tbm_bo bo, unsigned int key) privGem->ref_count = 1; if (drmHashInsert (bufmgr_exynos4412->hashBos, bo_exynos4412->name, (void *)privGem) < 0) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d Cannot insert bo to Hash(%d)\n", - getpid(), __FUNCTION__, __LINE__, bo_exynos4412->name); + TBM_EXYNOS4412_LOG ("error Cannot insert bo to Hash(%d)\n", bo_exynos4412->name); } } else { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d Cannot insert bo to Hash(%d)\n", - getpid(), __FUNCTION__, __LINE__, bo_exynos4412->name); + TBM_EXYNOS4412_LOG ("error Cannot insert bo to Hash(%d)\n", bo_exynos4412->name); } - DBG ("[libtbm-exynos4412:%d] %s size:%d, gem:%d(%d, %d), flags:%d(%d)\n", getpid(), - __FUNCTION__, bo_exynos4412->size, - bo_exynos4412->gem, bo_exynos4412->name, bo_exynos4412->dmabuf, - bo_exynos4412->flags_tbm, bo_exynos4412->flags_exynos); + DBG (" [%s] bo:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d\n", target_name(), + bo, + bo_exynos4412->gem, bo_exynos4412->name, + bo_exynos4412->dmabuf, + bo_exynos4412->flags_tbm, bo_exynos4412->flags_exynos, + bo_exynos4412->size); return (void *)bo_exynos4412; } @@ -724,9 +690,8 @@ tbm_exynos4412_bo_import_fd (tbm_bo bo, tbm_fd key) arg.flags = 0; if (drmIoctl (bufmgr_exynos4412->fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &arg)) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d Cannot getting gem from prime fd=%d\n", - getpid(), __FUNCTION__, __LINE__, arg.fd); + TBM_EXYNOS4412_LOG ("error bo:%p Cannot get gem handle from fd:%d (%s)\n", + bo, arg.fd, strerror(errno)); return NULL; } gem = arg.handle; @@ -744,9 +709,8 @@ tbm_exynos4412_bo_import_fd (tbm_bo bo, tbm_fd key) &info, sizeof(struct drm_exynos_gem_info))) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d Cannot get gem info=%d\n", - getpid(), __FUNCTION__, __LINE__, key); + TBM_EXYNOS4412_LOG ("error bo:%p Cannot get gem info from gem:%d, fd:%d (%s)\n", + bo, gem, key, strerror(errno)); return 0; } @@ -756,9 +720,7 @@ tbm_exynos4412_bo_import_fd (tbm_bo bo, tbm_fd key) bo_exynos4412 = calloc (1, sizeof(struct _tbm_bo_exynos4412)); if (!bo_exynos4412) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d fail to allocate the bo private\n", - getpid(), __FUNCTION__, __LINE__); + TBM_EXYNOS4412_LOG ("error bo:%p fail to allocate the bo private\n", bo); return 0; } @@ -771,14 +733,11 @@ tbm_exynos4412_bo_import_fd (tbm_bo bo, tbm_fd key) bo_exynos4412->name = _get_name(bo_exynos4412->fd, bo_exynos4412->gem); if (!bo_exynos4412->name) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d Cannot get name\n", - getpid(), __FUNCTION__, __LINE__); + TBM_EXYNOS4412_LOG ("error bo:%p Cannot get name from gem:%d, fd:%d (%s)\n", + bo, gem, key, strerror(errno)); return 0; } - bo_exynos4412->dmabuf = (unsigned int)key; - /* add bo to hash */ PrivGem *privGem = NULL; int ret; @@ -794,22 +753,23 @@ tbm_exynos4412_bo_import_fd (tbm_bo bo, tbm_fd key) privGem->ref_count = 1; if (drmHashInsert (bufmgr_exynos4412->hashBos, bo_exynos4412->name, (void *)privGem) < 0) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d Cannot insert bo to Hash(%d)\n", - getpid(), __FUNCTION__, __LINE__, bo_exynos4412->name); + TBM_EXYNOS4412_LOG ("error bo:%p Cannot insert bo to Hash(%d) from gem:%d, fd:%d\n", + bo, bo_exynos4412->name, gem, key); } } else { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d Cannot insert bo to Hash(%d)\n", - getpid(), __FUNCTION__, __LINE__, bo_exynos4412->name); + TBM_EXYNOS4412_LOG ("error bo:%p Cannot insert bo to Hash(%d) from gem:%d, fd:%d\n", + bo, bo_exynos4412->name, gem, key); } - DBG ("[libtbm-exynos4412:%d] %s size:%d, gem:%d(%d,%d), flags:%d(%d)\n", getpid(), - __FUNCTION__, bo_exynos4412->size, - bo_exynos4412->gem, bo_exynos4412->name, bo_exynos4412->dmabuf, - bo_exynos4412->flags_tbm, bo_exynos4412->flags_exynos); + DBG (" [%s] bo:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d(%d), size:%d\n", target_name(), + bo, + bo_exynos4412->gem, bo_exynos4412->name, + bo_exynos4412->dmabuf, + key, + bo_exynos4412->flags_tbm, bo_exynos4412->flags_exynos, + bo_exynos4412->size); return (void *)bo_exynos4412; } @@ -829,17 +789,17 @@ tbm_exynos4412_bo_export (tbm_bo bo) bo_exynos4412->name = _get_name(bo_exynos4412->fd, bo_exynos4412->gem); if (!bo_exynos4412->name) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d Cannot get name\n", - getpid(), __FUNCTION__, __LINE__); + TBM_EXYNOS4412_LOG ("error Cannot get name\n"); return 0; } } - DBG ("[libtbm-exynos4412:%d] %s size:%d, gem:%d(%d), flags:%d(%d)\n", getpid(), - __FUNCTION__, bo_exynos4412->size, + DBG (" [%s] bo:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d\n", target_name(), + bo, bo_exynos4412->gem, bo_exynos4412->name, - bo_exynos4412->flags_tbm, bo_exynos4412->flags_exynos); + bo_exynos4412->dmabuf, + bo_exynos4412->flags_tbm, bo_exynos4412->flags_exynos, + bo_exynos4412->size); return (unsigned int)bo_exynos4412->name; } @@ -854,27 +814,25 @@ tbm_exynos4412_bo_export_fd (tbm_bo bo) bo_exynos4412 = (tbm_bo_exynos4412)tbm_backend_get_bo_priv(bo); EXYNOS4412_RETURN_VAL_IF_FAIL (bo_exynos4412!=NULL, 0); - if (!bo_exynos4412->dmabuf) - { - struct drm_prime_handle arg = {0, }; + struct drm_prime_handle arg = {0, }; - arg.handle = bo_exynos4412->gem; - if (drmIoctl (bo_exynos4412->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) - { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d Cannot dmabuf=%d\n", - getpid(), __FUNCTION__, __LINE__, bo_exynos4412->gem); - return (tbm_fd) 0; - } - bo_exynos4412->dmabuf = arg.fd; + arg.handle = bo_exynos4412->gem; + if (drmIoctl (bo_exynos4412->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) + { + TBM_EXYNOS4412_LOG ("error bo:%p Cannot dmabuf=%d (%s)\n", + bo, bo_exynos4412->gem, strerror(errno)); + return (tbm_fd) NULL; } - DBG ("[libtbm-exynos4412:%d] %s size:%d, gem:%d(%d, %d), flags:%d(%d)\n", getpid(), - __FUNCTION__, bo_exynos4412->size, - bo_exynos4412->gem, bo_exynos4412->name, bo_exynos4412->dmabuf, - bo_exynos4412->flags_tbm, bo_exynos4412->flags_exynos); + DBG (" [%s] bo:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d(%d), size:%d\n", target_name(), + bo, + bo_exynos4412->gem, bo_exynos4412->name, + bo_exynos4412->dmabuf, + arg.fd, + bo_exynos4412->flags_tbm, bo_exynos4412->flags_exynos, + bo_exynos4412->size); - return (tbm_fd)bo_exynos4412->dmabuf; + return (tbm_fd)arg.fd; } static tbm_bo_handle @@ -890,22 +848,23 @@ tbm_exynos4412_bo_get_handle (tbm_bo bo, int device) if (!bo_exynos4412->gem) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d Cannot map gem=%d\n", - getpid(), __FUNCTION__, __LINE__, bo_exynos4412->gem); + TBM_EXYNOS4412_LOG ("error Cannot map gem=%d\n", bo_exynos4412->gem); return (tbm_bo_handle) NULL; } - DBG ("[libtbm-exynos4412:%d] %s gem:%d(%d), %s\n", getpid(), - __FUNCTION__, bo_exynos4412->gem, bo_exynos4412->name, STR_DEVICE[device]); + DBG ("[%s] bo:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d, %s\n", target_name(), + bo, + bo_exynos4412->gem, bo_exynos4412->name, + bo_exynos4412->dmabuf, + bo_exynos4412->flags_tbm, bo_exynos4412->flags_exynos, + bo_exynos4412->size, + STR_DEVICE[device]); /*Get mapped bo_handle*/ bo_handle = _exynos4412_bo_handle (bo_exynos4412, device); if (bo_handle.ptr == NULL) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d Cannot get handle: gem:%d, device:%d\n", - getpid(), __FUNCTION__, __LINE__, bo_exynos4412->gem, device); + TBM_EXYNOS4412_LOG ("error Cannot get handle: gem:%d, device:%d\n", bo_exynos4412->gem, device); return (tbm_bo_handle) NULL; } @@ -925,22 +884,22 @@ tbm_exynos4412_bo_map (tbm_bo bo, int device, int opt) if (!bo_exynos4412->gem) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d Cannot map gem=%d\n", - getpid(), __FUNCTION__, __LINE__, bo_exynos4412->gem); + TBM_EXYNOS4412_LOG ("error Cannot map gem=%d\n", bo_exynos4412->gem); return (tbm_bo_handle) NULL; } - DBG ("[libtbm-exynos4412:%d] %s gem:%d(%d), %s, %s\n", getpid(), - __FUNCTION__, bo_exynos4412->gem, bo_exynos4412->name, STR_DEVICE[device], STR_OPT[opt]); + DBG (" [%s] bo:%p, gem:%d(%d), fd:%d, %s, %s\n", target_name(), + bo, + bo_exynos4412->gem, bo_exynos4412->name, + bo_exynos4412->dmabuf, + STR_DEVICE[device], + STR_OPT[opt]); /*Get mapped bo_handle*/ bo_handle = _exynos4412_bo_handle (bo_exynos4412, device); if (bo_handle.ptr == NULL) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d Cannot get handle: gem:%d, device:%d, opt:%d\n", - getpid(), __FUNCTION__, __LINE__, bo_exynos4412->gem, device, opt); + TBM_EXYNOS4412_LOG ("error Cannot get handle: gem:%d, device:%d, opt:%d\n", bo_exynos4412->gem, device, opt); return (tbm_bo_handle) NULL; } @@ -960,8 +919,10 @@ tbm_exynos4412_bo_unmap (tbm_bo bo) if (!bo_exynos4412->gem) return 0; - DBG ("[libtbm-exynos4412:%d] %s gem:%d(%d) \n", getpid(), - __FUNCTION__, bo_exynos4412->gem, bo_exynos4412->name); + DBG (" [%s] bo:%p, gem:%d(%d), fd:%d\n", target_name(), + bo, + bo_exynos4412->gem, bo_exynos4412->name, + bo_exynos4412->dmabuf); return 1; } @@ -1048,16 +1009,14 @@ tbm_exynos4412_bo_lock(tbm_bo bo, int device, int opt) } else { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] error %s:%d Invalid argument\n", getpid(), __FUNCTION__, __LINE__); + TBM_EXYNOS4412_LOG ("error Invalid argument\n"); return 0; } /* Check if the tbm manager supports dma fence or not. */ if (!bufmgr_exynos4412->use_dma_fence) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d Not support DMA FENCE(%s)\n", - getpid(), __FUNCTION__, __LINE__, strerror(errno) ); + TBM_EXYNOS4412_LOG ("error Not support DMA FENCE(%s)\n", strerror(errno) ); return 0; } @@ -1067,9 +1026,7 @@ tbm_exynos4412_bo_lock(tbm_bo bo, int device, int opt) ret = ioctl(bo_exynos4412->dmabuf, DMABUF_IOCTL_GET_FENCE, &fence); if (ret < 0) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d Can not set GET FENCE(%s)\n", - getpid(), __FUNCTION__, __LINE__, strerror(errno) ); + TBM_EXYNOS4412_LOG ("error Cannot set GET FENCE(%s)\n", strerror(errno) ); return 0; } } else @@ -1107,16 +1064,16 @@ tbm_exynos4412_bo_lock(tbm_bo bo, int device, int opt) if (i == DMA_FENCE_LIST_MAX) { //TODO: if dma_fence list is full, it needs realloc. I will fix this. by minseok3.kim - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d fence list is full\n", - getpid(), __FUNCTION__, __LINE__); + TBM_EXYNOS4412_LOG ("error fence list is full\n"); } } pthread_mutex_unlock(&bo_exynos4412->mutex); - DBG ("[libtbm-exynos4412:%d] %s DMABUF_IOCTL_GET_FENCE! flink_id=%d dmabuf=%d\n", getpid(), - __FUNCTION__, bo_exynos4412->name, bo_exynos4412->dmabuf); + DBG ("[%s] DMABUF_IOCTL_GET_FENCE! bo:%p, gem:%d(%d), fd:%ds\n", target_name(), + bo, + bo_exynos4412->gem, bo_exynos4412->name, + bo_exynos4412->dmabuf); return 1; } @@ -1172,9 +1129,7 @@ tbm_exynos4412_bo_unlock(tbm_bo bo) ret = ioctl(bo_exynos4412->dmabuf, DMABUF_IOCTL_PUT_FENCE, &fence); if (ret < 0) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " - "error %s:%d Can not set PUT FENCE(%s)\n", - getpid(), __FUNCTION__, __LINE__, strerror(errno) ); + TBM_EXYNOS4412_LOG ("error Can not set PUT FENCE(%s)\n", strerror(errno)); return 0; } } else @@ -1190,8 +1145,10 @@ tbm_exynos4412_bo_unlock(tbm_bo bo) } } - DBG ("[libtbm-exynos4412:%d] %s DMABUF_IOCTL_PUT_FENCE! flink_id=%d dmabuf=%d\n", getpid(), - __FUNCTION__, bo_exynos4412->name, bo_exynos4412->dmabuf); + DBG ("[%s] DMABUF_IOCTL_PUT_FENCE! bo:%p, gem:%d(%d), fd:%ds\n", target_name(), + bo, + bo_exynos4412->gem, bo_exynos4412->name, + bo_exynos4412->dmabuf); return 1; } @@ -1665,6 +1622,55 @@ tbm_exynos4412_surface_get_size(tbm_surface_h surface, int width, int height, tb } +tbm_bo_handle +tbm_exynos4412_fd_to_handle(tbm_bufmgr bufmgr, tbm_fd fd, int device) +{ + EXYNOS4412_RETURN_VAL_IF_FAIL (bufmgr!=NULL, (tbm_bo_handle) NULL); + EXYNOS4412_RETURN_VAL_IF_FAIL (fd > 0, (tbm_bo_handle) NULL); + + tbm_bo_handle bo_handle; + memset (&bo_handle, 0x0, sizeof (uint64_t)); + + tbm_bufmgr_exynos4412 bufmgr_exynos4412 = (tbm_bufmgr_exynos4412)tbm_backend_get_priv_from_bufmgr(bufmgr); + + switch(device) + { + case TBM_DEVICE_DEFAULT: + case TBM_DEVICE_2D: + { + //getting handle from fd + struct drm_prime_handle arg = {0, }; + + arg.fd = fd; + arg.flags = 0; + if (drmIoctl (bufmgr_exynos4412->fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &arg)) + { + TBM_EXYNOS4412_LOG ("error Cannot get gem handle from fd:%d (%s)\n", + arg.fd, strerror(errno)); + return (tbm_bo_handle) NULL; + } + + bo_handle.u32 = (uint32_t)arg.handle;; + break; + } + case TBM_DEVICE_CPU: + TBM_EXYNOS4412_LOG ("Not supported device:%d\n", device); + bo_handle.ptr = (void *) NULL; + break; + case TBM_DEVICE_3D: + case TBM_DEVICE_MM: + bo_handle.u32 = (uint32_t)fd; + break; + default: + TBM_EXYNOS4412_LOG ("error Not supported device:%d\n", device); + bo_handle.ptr = (void *) NULL; + break; + } + + return bo_handle; +} + + MODULEINITPPROTO (init_tbm_bufmgr_priv); static TBMModuleVersionInfo Exynos4412VersRec = @@ -1688,14 +1694,14 @@ init_tbm_bufmgr_priv (tbm_bufmgr bufmgr, int fd) bufmgr_exynos4412 = calloc (1, sizeof(struct _tbm_bufmgr_exynos4412)); if (!bufmgr_exynos4412) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] error: Fail to alloc bufmgr_exynos4412!\n", getpid()); + TBM_EXYNOS4412_LOG ("error: Fail to alloc bufmgr_exynos4412!\n"); return 0; } bufmgr_exynos4412->fd = fd; if (bufmgr_exynos4412->fd < 0) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] error: Fail to create drm!\n", getpid()); + TBM_EXYNOS4412_LOG ("error: Fail to create drm!\n"); free (bufmgr_exynos4412); return 0; } @@ -1720,7 +1726,9 @@ init_tbm_bufmgr_priv (tbm_bufmgr bufmgr, int fd) bufmgr_backend = tbm_backend_alloc(); if (!bufmgr_backend) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] error: Fail to create drm!\n", getpid()); + TBM_EXYNOS4412_LOG ("error: Fail to create drm!\n"); + if (bufmgr_exynos4412->hashBos) + drmHashDestroy (bufmgr_exynos4412->hashBos); free (bufmgr_exynos4412); return 0; } @@ -1742,6 +1750,7 @@ init_tbm_bufmgr_priv (tbm_bufmgr bufmgr, int fd) bufmgr_backend->surface_get_plane_data = tbm_exynos4412_surface_get_plane_data; bufmgr_backend->surface_get_size = tbm_exynos4412_surface_get_size; bufmgr_backend->surface_supported_format = tbm_exynos4412_surface_supported_format; + bufmgr_backend->fd_to_handle = tbm_exynos4412_fd_to_handle; if (bufmgr_exynos4412->use_dma_fence) { @@ -1759,7 +1768,7 @@ init_tbm_bufmgr_priv (tbm_bufmgr bufmgr, int fd) if (!tbm_backend_init (bufmgr, bufmgr_backend)) { - TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] error: Fail to init backend!\n", getpid()); + TBM_EXYNOS4412_LOG ("error: Fail to init backend!\n"); tbm_backend_free (bufmgr_backend); free (bufmgr_exynos4412); return 0; @@ -1781,11 +1790,11 @@ init_tbm_bufmgr_priv (tbm_bufmgr bufmgr, int fd) } #endif - DBG ("[libtbm-exynos4412:%d] %s DMABUF FENCE is %s\n", getpid(), - __FUNCTION__, bufmgr_exynos4412->use_dma_fence ? "supported!" : "NOT supported!"); + DBG ("[%s] DMABUF FENCE is %s\n", target_name(), + bufmgr_exynos4412->use_dma_fence ? "supported!" : "NOT supported!"); - DBG ("[libtbm-exynos4412:%d] %s fd:%d\n", getpid(), - __FUNCTION__, bufmgr_exynos4412->fd); + DBG ("[%s] drm_fd:%d\n", target_name(), + bufmgr_exynos4412->fd); return 1; } -- 2.7.4 From efcf9d766ef1f216769a7d73487ca34b9be7e981 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Wed, 3 Jun 2015 20:10:53 +0900 Subject: [PATCH 12/16] Fix build break in 64bit Change-Id: Ic2f2d21280afad0adf844e8b29cdc09b9cd1fb0f --- src/tbm_bufmgr_exynos4412.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tbm_bufmgr_exynos4412.c b/src/tbm_bufmgr_exynos4412.c index 354e1a9..91487d4 100755 --- a/src/tbm_bufmgr_exynos4412.c +++ b/src/tbm_bufmgr_exynos4412.c @@ -821,7 +821,7 @@ tbm_exynos4412_bo_export_fd (tbm_bo bo) { TBM_EXYNOS4412_LOG ("error bo:%p Cannot dmabuf=%d (%s)\n", bo, bo_exynos4412->gem, strerror(errno)); - return (tbm_fd) NULL; + return (tbm_fd) 0; } DBG (" [%s] bo:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d(%d), size:%d\n", target_name(), -- 2.7.4 From fd9f048606b769c91e6c58848646045c618cb6f9 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 13 Jul 2015 16:46:09 +0900 Subject: [PATCH 13/16] remove manifest for security domain policy Change-Id: If64f93301fa37e795bc6ae4100c96d1332f19eae --- libtbm-exynos4412.manifest | 5 ----- packaging/libtbm-exynos4412.spec | 1 - 2 files changed, 6 deletions(-) delete mode 100644 libtbm-exynos4412.manifest diff --git a/libtbm-exynos4412.manifest b/libtbm-exynos4412.manifest deleted file mode 100644 index 97e8c31..0000000 --- a/libtbm-exynos4412.manifest +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/packaging/libtbm-exynos4412.spec b/packaging/libtbm-exynos4412.spec index c148012..4851fa2 100644 --- a/packaging/libtbm-exynos4412.spec +++ b/packaging/libtbm-exynos4412.spec @@ -42,7 +42,6 @@ ln -s libtbm_exynos4412.so %{_libdir}/bufmgr/libtbm_default.so %postun -p /sbin/ldconfig %files -%manifest libtbm-exynos4412.manifest %{_libdir}/bufmgr/libtbm_*.so* /usr/share/license/%{name} -- 2.7.4 From 8653e638a961dbeb81471ae71eca99e5ea9fe15b Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Tue, 2 Jun 2015 20:34:49 +0900 Subject: [PATCH 14/16] Fix prevent issues Change-Id: I0995981a685ef5a140380afbb70bd56f0c26c26f --- src/tbm_bufmgr_exynos4412.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/tbm_bufmgr_exynos4412.c b/src/tbm_bufmgr_exynos4412.c index 91487d4..f77c42a 100755 --- a/src/tbm_bufmgr_exynos4412.c +++ b/src/tbm_bufmgr_exynos4412.c @@ -490,6 +490,15 @@ tbm_exynos4412_bo_alloc (tbm_bo bo, int size, int flags) /* add bo to hash */ PrivGem* privGem = calloc (1, sizeof(PrivGem)); + if (!privGem) + { + TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " + "error %s:%d Fail to calloc privGem\n", + getpid(), __FUNCTION__, __LINE__); + free (bo_exynos4412); + return 0; + } + privGem->ref_count = 1; if (drmHashInsert(bufmgr_exynos4412->hashBos, bo_exynos4412->name, (void *)privGem) < 0) { @@ -647,6 +656,15 @@ tbm_exynos4412_bo_import (tbm_bo bo, unsigned int key) else if (ret == 1) { privGem = calloc (1, sizeof(PrivGem)); + if (!privGem) + { + TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " + "error %s:%d Fail to calloc privGem\n", + getpid(), __FUNCTION__, __LINE__); + free (bo_exynos4412); + return 0; + } + privGem->ref_count = 1; if (drmHashInsert (bufmgr_exynos4412->hashBos, bo_exynos4412->name, (void *)privGem) < 0) { @@ -735,6 +753,7 @@ tbm_exynos4412_bo_import_fd (tbm_bo bo, tbm_fd key) { TBM_EXYNOS4412_LOG ("error bo:%p Cannot get name from gem:%d, fd:%d (%s)\n", bo, gem, key, strerror(errno)); + free (bo_exynos4412); return 0; } @@ -750,6 +769,15 @@ tbm_exynos4412_bo_import_fd (tbm_bo bo, tbm_fd key) else if (ret == 1) { privGem = calloc (1, sizeof(PrivGem)); + if (!privGem) + { + TBM_EXYNOS4412_LOG ("[libtbm-exynos4412:%d] " + "error %s:%d Fail to calloc privGem\n", + getpid(), __FUNCTION__, __LINE__); + free (bo_exynos4412); + return 0; + } + privGem->ref_count = 1; if (drmHashInsert (bufmgr_exynos4412->hashBos, bo_exynos4412->name, (void *)privGem) < 0) { -- 2.7.4 From d27dc4560c6d0a979db669c06c3557d96b0bd44e Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Sat, 27 Jun 2015 17:03:04 +0900 Subject: [PATCH 15/16] Surpport multiple bo surface Change-Id: Id9a75d85a714cad25e9db87fb3e9df32a8ad0b37 --- packaging/libtbm-exynos4412.spec | 2 +- src/tbm_bufmgr_exynos4412.c | 128 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 127 insertions(+), 3 deletions(-) mode change 100755 => 100644 src/tbm_bufmgr_exynos4412.c diff --git a/packaging/libtbm-exynos4412.spec b/packaging/libtbm-exynos4412.spec index 4851fa2..01767a1 100644 --- a/packaging/libtbm-exynos4412.spec +++ b/packaging/libtbm-exynos4412.spec @@ -1,5 +1,5 @@ Name: libtbm-exynos4412 -Version: 1.0.8 +Version: 1.0.9 Release: 1 License: MIT Summary: Tizen Buffer Manager - exynos4412 backend diff --git a/src/tbm_bufmgr_exynos4412.c b/src/tbm_bufmgr_exynos4412.c old mode 100755 new mode 100644 index f77c42a..bd86c1e --- a/src/tbm_bufmgr_exynos4412.c +++ b/src/tbm_bufmgr_exynos4412.c @@ -1245,14 +1245,14 @@ tbm_exynos4412_surface_supported_format(uint32_t **formats, uint32_t *num) * @return 1 if this function succeeds, otherwise 0. */ int -tbm_exynos4412_surface_get_plane_data(tbm_surface_h surface, int width, int height, tbm_format format, int plane_idx, uint32_t *size, uint32_t *offset, uint32_t *pitch) +tbm_exynos4412_surface_get_plane_data(tbm_surface_h surface, int width, int height, tbm_format format, int plane_idx, uint32_t *size, uint32_t *offset, uint32_t *pitch, int *bo_idx) { int ret = 1; int bpp; int _offset =0; int _pitch =0; int _size =0; - + int _bo_idx = 0; switch(format) { @@ -1278,6 +1278,7 @@ tbm_exynos4412_surface_get_plane_data(tbm_surface_h surface, int width, int heig _offset = 0; _pitch = SIZE_ALIGN((width*bpp)>>3,TBM_SURFACE_ALIGNMENT_PITCH_RGB); _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + _bo_idx = 0; break; /* 24 bpp RGB */ case TBM_FORMAT_RGB888: @@ -1286,6 +1287,7 @@ tbm_exynos4412_surface_get_plane_data(tbm_surface_h surface, int width, int heig _offset = 0; _pitch = SIZE_ALIGN((width*bpp)>>3,TBM_SURFACE_ALIGNMENT_PITCH_RGB); _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + _bo_idx = 0; break; /* 32 bpp RGB */ case TBM_FORMAT_XRGB8888: @@ -1300,6 +1302,7 @@ tbm_exynos4412_surface_get_plane_data(tbm_surface_h surface, int width, int heig _offset = 0; _pitch = SIZE_ALIGN((width*bpp)>>3,TBM_SURFACE_ALIGNMENT_PITCH_RGB); _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + _bo_idx = 0; break; /* packed YCbCr */ @@ -1312,6 +1315,7 @@ tbm_exynos4412_surface_get_plane_data(tbm_surface_h surface, int width, int heig _offset = 0; _pitch = SIZE_ALIGN((width*bpp)>>3,TBM_SURFACE_ALIGNMENT_PITCH_YUV); _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + _bo_idx = 0; break; /* @@ -1322,6 +1326,22 @@ tbm_exynos4412_surface_get_plane_data(tbm_surface_h surface, int width, int heig * index 1 = Cb:Cr plane, [15:0] Cb:Cr little endian */ case TBM_FORMAT_NV12: + bpp = 12; + if(plane_idx == 0) + { + _offset = 0; + _pitch = SIZE_ALIGN( width ,TBM_SURFACE_ALIGNMENT_PITCH_YUV); + _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + _bo_idx = 0; + } + else if( plane_idx ==1 ) + { + _offset = 0; + _pitch = SIZE_ALIGN( width ,TBM_SURFACE_ALIGNMENT_PITCH_YUV/2); + _size = SIZE_ALIGN(_pitch*(height/2),TBM_SURFACE_ALIGNMENT_PLANE); + _bo_idx = 1; + } + break; case TBM_FORMAT_NV21: bpp = 12; if(plane_idx == 0) @@ -1329,12 +1349,14 @@ tbm_exynos4412_surface_get_plane_data(tbm_surface_h surface, int width, int heig _offset = 0; _pitch = SIZE_ALIGN( width ,TBM_SURFACE_ALIGNMENT_PITCH_YUV); _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + _bo_idx = 0; } else if( plane_idx ==1 ) { _offset = width*height; _pitch = SIZE_ALIGN( width ,TBM_SURFACE_ALIGNMENT_PITCH_YUV/2); _size = SIZE_ALIGN(_pitch*(height/2),TBM_SURFACE_ALIGNMENT_PLANE); + _bo_idx = 0; } break; @@ -1346,6 +1368,7 @@ tbm_exynos4412_surface_get_plane_data(tbm_surface_h surface, int width, int heig _offset = 0; _pitch = SIZE_ALIGN(width,TBM_SURFACE_ALIGNMENT_PITCH_YUV); _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + _bo_idx = 0; if(plane_idx == 0) break; } @@ -1354,6 +1377,7 @@ tbm_exynos4412_surface_get_plane_data(tbm_surface_h surface, int width, int heig _offset += _size; _pitch = SIZE_ALIGN(width,TBM_SURFACE_ALIGNMENT_PITCH_YUV/2); _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + _bo_idx = 0; } break; @@ -1373,6 +1397,7 @@ tbm_exynos4412_surface_get_plane_data(tbm_surface_h surface, int width, int heig case TBM_FORMAT_YUV410: case TBM_FORMAT_YVU410: bpp = 9; + _bo_idx = 0; break; case TBM_FORMAT_YUV411: case TBM_FORMAT_YVU411: @@ -1384,6 +1409,7 @@ tbm_exynos4412_surface_get_plane_data(tbm_surface_h surface, int width, int heig _offset = 0; _pitch = SIZE_ALIGN(width,TBM_SURFACE_ALIGNMENT_PITCH_YUV); _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + _bo_idx = 0; if(plane_idx == 0) break; } @@ -1392,6 +1418,7 @@ tbm_exynos4412_surface_get_plane_data(tbm_surface_h surface, int width, int heig _offset += _size; _pitch = SIZE_ALIGN(width/2,TBM_SURFACE_ALIGNMENT_PITCH_YUV/2); _size = SIZE_ALIGN(_pitch*(height/2),TBM_SURFACE_ALIGNMENT_PLANE); + _bo_idx = 0; if(plane_idx == 1) break; } @@ -1400,6 +1427,7 @@ tbm_exynos4412_surface_get_plane_data(tbm_surface_h surface, int width, int heig _offset += _size; _pitch = SIZE_ALIGN(width/2,TBM_SURFACE_ALIGNMENT_PITCH_YUV/2); _size = SIZE_ALIGN(_pitch*(height/2),TBM_SURFACE_ALIGNMENT_PLANE); + _bo_idx = 0; } break; case TBM_FORMAT_YUV422: @@ -1410,6 +1438,7 @@ tbm_exynos4412_surface_get_plane_data(tbm_surface_h surface, int width, int heig _offset = 0; _pitch = SIZE_ALIGN(width,TBM_SURFACE_ALIGNMENT_PITCH_YUV); _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + _bo_idx = 0; if(plane_idx == 0) break; } @@ -1418,6 +1447,7 @@ tbm_exynos4412_surface_get_plane_data(tbm_surface_h surface, int width, int heig _offset += _size; _pitch = SIZE_ALIGN(width/2,TBM_SURFACE_ALIGNMENT_PITCH_YUV/2); _size = SIZE_ALIGN(_pitch*(height),TBM_SURFACE_ALIGNMENT_PLANE); + _bo_idx = 0; if(plane_idx == 1) break; } @@ -1426,6 +1456,7 @@ tbm_exynos4412_surface_get_plane_data(tbm_surface_h surface, int width, int heig _offset += _size; _pitch = SIZE_ALIGN(width/2,TBM_SURFACE_ALIGNMENT_PITCH_YUV/2); _size = SIZE_ALIGN(_pitch*(height),TBM_SURFACE_ALIGNMENT_PLANE); + _bo_idx = 0; } break; case TBM_FORMAT_YUV444: @@ -1436,6 +1467,7 @@ tbm_exynos4412_surface_get_plane_data(tbm_surface_h surface, int width, int heig _offset = 0; _pitch = SIZE_ALIGN(width,TBM_SURFACE_ALIGNMENT_PITCH_YUV); _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + _bo_idx = 0; if(plane_idx == 0) break; } @@ -1444,6 +1476,7 @@ tbm_exynos4412_surface_get_plane_data(tbm_surface_h surface, int width, int heig _offset += _size; _pitch = SIZE_ALIGN(width,TBM_SURFACE_ALIGNMENT_PITCH_YUV); _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + _bo_idx = 0; if(plane_idx == 1) break; } @@ -1452,6 +1485,7 @@ tbm_exynos4412_surface_get_plane_data(tbm_surface_h surface, int width, int heig _offset += _size; _pitch = SIZE_ALIGN(width,TBM_SURFACE_ALIGNMENT_PITCH_YUV); _size = SIZE_ALIGN(_pitch*height,TBM_SURFACE_ALIGNMENT_PLANE); + _bo_idx = 0; } break; default: @@ -1462,9 +1496,98 @@ tbm_exynos4412_surface_get_plane_data(tbm_surface_h surface, int width, int heig *size = _size; *offset = _offset; *pitch = _pitch; + *bo_idx = _bo_idx; return ret; } + +int +tbm_exynos4412_surface_get_num_bos(tbm_format format) +{ + int num = 0; + + switch(format) + { + /* 16 bpp RGB */ + case TBM_FORMAT_XRGB4444: + case TBM_FORMAT_XBGR4444: + case TBM_FORMAT_RGBX4444: + case TBM_FORMAT_BGRX4444: + case TBM_FORMAT_ARGB4444: + case TBM_FORMAT_ABGR4444: + case TBM_FORMAT_RGBA4444: + case TBM_FORMAT_BGRA4444: + case TBM_FORMAT_XRGB1555: + case TBM_FORMAT_XBGR1555: + case TBM_FORMAT_RGBX5551: + case TBM_FORMAT_BGRX5551: + case TBM_FORMAT_ARGB1555: + case TBM_FORMAT_ABGR1555: + case TBM_FORMAT_RGBA5551: + case TBM_FORMAT_BGRA5551: + case TBM_FORMAT_RGB565: + /* 24 bpp RGB */ + case TBM_FORMAT_RGB888: + case TBM_FORMAT_BGR888: + /* 32 bpp RGB */ + case TBM_FORMAT_XRGB8888: + case TBM_FORMAT_XBGR8888: + case TBM_FORMAT_RGBX8888: + case TBM_FORMAT_BGRX8888: + case TBM_FORMAT_ARGB8888: + case TBM_FORMAT_ABGR8888: + case TBM_FORMAT_RGBA8888: + case TBM_FORMAT_BGRA8888: + /* packed YCbCr */ + case TBM_FORMAT_YUYV: + case TBM_FORMAT_YVYU: + case TBM_FORMAT_UYVY: + case TBM_FORMAT_VYUY: + case TBM_FORMAT_AYUV: + /* + * 2 plane YCbCr + * index 0 = Y plane, [7:0] Y + * index 1 = Cr:Cb plane, [15:0] Cr:Cb little endian + * or + * index 1 = Cb:Cr plane, [15:0] Cb:Cr little endian + */ + case TBM_FORMAT_NV21: + case TBM_FORMAT_NV16: + case TBM_FORMAT_NV61: + /* + * 3 plane YCbCr + * index 0: Y plane, [7:0] Y + * index 1: Cb plane, [7:0] Cb + * index 2: Cr plane, [7:0] Cr + * or + * index 1: Cr plane, [7:0] Cr + * index 2: Cb plane, [7:0] Cb + */ + case TBM_FORMAT_YUV410: + case TBM_FORMAT_YVU410: + case TBM_FORMAT_YUV411: + case TBM_FORMAT_YVU411: + case TBM_FORMAT_YUV420: + case TBM_FORMAT_YVU420: + case TBM_FORMAT_YUV422: + case TBM_FORMAT_YVU422: + case TBM_FORMAT_YUV444: + case TBM_FORMAT_YVU444: + num = 1; + break; + + case TBM_FORMAT_NV12: + num = 2; + break; + + default: + num = 0; + break; + } + + return num; +} + /** * @brief get the size of the surface with a format. * @param[in] surface : the surface @@ -1779,6 +1902,7 @@ init_tbm_bufmgr_priv (tbm_bufmgr bufmgr, int fd) bufmgr_backend->surface_get_size = tbm_exynos4412_surface_get_size; bufmgr_backend->surface_supported_format = tbm_exynos4412_surface_supported_format; bufmgr_backend->fd_to_handle = tbm_exynos4412_fd_to_handle; + bufmgr_backend->surface_get_num_bos = tbm_exynos4412_surface_get_num_bos; if (bufmgr_exynos4412->use_dma_fence) { -- 2.7.4 From 94f4e1da0e00bad17ae66b896c5f21727215ecc0 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Wed, 19 Aug 2015 21:14:43 +0900 Subject: [PATCH 16/16] Add tbm_bo_get_flags backend function Change-Id: I198de4bd097a8cbaa95ab043ba46327b112c1364 --- packaging/libtbm-exynos4412.spec | 2 +- src/tbm_bufmgr_exynos4412.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packaging/libtbm-exynos4412.spec b/packaging/libtbm-exynos4412.spec index 01767a1..d44be04 100644 --- a/packaging/libtbm-exynos4412.spec +++ b/packaging/libtbm-exynos4412.spec @@ -1,5 +1,5 @@ Name: libtbm-exynos4412 -Version: 1.0.9 +Version: 1.1.0 Release: 1 License: MIT Summary: Tizen Buffer Manager - exynos4412 backend diff --git a/src/tbm_bufmgr_exynos4412.c b/src/tbm_bufmgr_exynos4412.c index bd86c1e..4c6d40f 100644 --- a/src/tbm_bufmgr_exynos4412.c +++ b/src/tbm_bufmgr_exynos4412.c @@ -1821,6 +1821,18 @@ tbm_exynos4412_fd_to_handle(tbm_bufmgr bufmgr, tbm_fd fd, int device) return bo_handle; } +int +tbm_exynos4412_bo_get_flags (tbm_bo bo) +{ + EXYNOS4412_RETURN_VAL_IF_FAIL (bo != NULL, 0); + + tbm_bo_exynos4412 bo_exynos4412; + + bo_exynos4412 = (tbm_bo_exynos4412)tbm_backend_get_bo_priv(bo); + EXYNOS4412_RETURN_VAL_IF_FAIL (bo_exynos4412 != NULL, 0); + + return bo_exynos4412->flags_tbm; +} MODULEINITPPROTO (init_tbm_bufmgr_priv); @@ -1903,6 +1915,7 @@ init_tbm_bufmgr_priv (tbm_bufmgr bufmgr, int fd) bufmgr_backend->surface_supported_format = tbm_exynos4412_surface_supported_format; bufmgr_backend->fd_to_handle = tbm_exynos4412_fd_to_handle; bufmgr_backend->surface_get_num_bos = tbm_exynos4412_surface_get_num_bos; + bufmgr_backend->bo_get_flags = tbm_exynos4412_bo_get_flags; if (bufmgr_exynos4412->use_dma_fence) { -- 2.7.4