From: KwangCheol Lee Date: Fri, 29 Sep 2017 08:45:51 +0000 (+0900) Subject: add tbm bo allocation for tizen waylandsink X-Git-Tag: accepted/tizen/4.0/unified/20171123.065508~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F49%2F153749%2F6;p=platform%2Fadaptation%2Fnexell%2Fnx-video-api.git add tbm bo allocation for tizen waylandsink Change-Id: Ib2713a7ac8747df6e5c1ea99085010e4f8bd0616 Signed-off-by: KwangCheol Lee --- diff --git a/packaging/nx-video-api.spec b/packaging/nx-video-api.spec index f219054..f4adaec 100644 --- a/packaging/nx-video-api.spec +++ b/packaging/nx-video-api.spec @@ -8,6 +8,7 @@ Source: %{name}-%{version}.tar.gz BuildRequires: pkgconfig automake autoconf libtool BuildRequires: pkgconfig(libdrm) +BuildRequires: pkgconfig(libtbm) Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig diff --git a/src/Makefile.am b/src/Makefile.am index a93bb81..1d443ac 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,11 +1,12 @@ AM_CFLAGS = \ $(WARN_CFLAGS) \ + -DTIZEN_FEATURE_ARTIK530 \ -I./include \ -I${includedir} libnx_video_api_la_LTLIBRARIES = libnx_video_api.la libnx_video_api_ladir = ${libdir} -libnx_video_api_la_LDFLAGS = -L${libdir} -ldrm +libnx_video_api_la_LDFLAGS = -L${libdir} -ldrm -ltbm libnx_video_api_la_SOURCES = \ nx_video_alloc.c \ diff --git a/src/nx_video_alloc.c b/src/nx_video_alloc.c index 8ee1972..effd3f8 100644 --- a/src/nx_video_alloc.c +++ b/src/nx_video_alloc.c @@ -25,6 +25,9 @@ #include #include #include +#ifdef TIZEN_FEATURE_ARTIK530 +#include +#endif #define DRM_DEVICE_NAME "/dev/dri/card0" @@ -355,6 +358,15 @@ NX_AllocateVideoMemory (int width, int height, int32_t planes, uint32_t format, } pVidMem = (NX_VID_MEMORY_INFO *) calloc (1, sizeof (NX_VID_MEMORY_INFO)); + if (!pVidMem) + goto ErrorExit; + +#ifdef TIZEN_FEATURE_ARTIK530 + pVidMem->bufmgr = tbm_bufmgr_init (drmFd); + if (!pVidMem->bufmgr) + goto ErrorExit; +#endif + pVidMem->width = width; pVidMem->height = height; pVidMem->align = align; @@ -367,9 +379,22 @@ NX_AllocateVideoMemory (int width, int height, int32_t planes, uint32_t format, pVidMem->size[i] = size[i]; pVidMem->stride[i] = stride[i]; pVidMem->flink[i] = flink[i]; +#ifdef TIZEN_FEATURE_ARTIK530 + pVidMem->bo[i] = tbm_bo_import (pVidMem->bufmgr, flink[i]); + if (!pVidMem->bo[i]) + goto alloc_bo_fail; +#endif } return pVidMem; +#ifdef TIZEN_FEATURE_ARTIK530 +alloc_bo_fail: + for (i = 0; i < planes; i++) { + if (pVidMem->bo[i]) + tbm_bo_unref (pVidMem->bo[i]); + } +#endif + ErrorExit: for (i = 0; i < planes; i++) { if (gemFd[i] > 0) { @@ -379,6 +404,13 @@ ErrorExit: close (dmaFd[i]); } } + if (pVidMem) { +#ifdef TIZEN_FEATURE_ARTIK530 + if (pVidMem->bufmgr) + tbm_bufmgr_deinit (pVidMem->bufmgr); +#endif + free(pVidMem); + } if (drmFd > 0) close (drmFd); @@ -391,12 +423,20 @@ NX_FreeVideoMemory (NX_VID_MEMORY_INFO * pMem) int32_t i; if (pMem) { for (i = 0; i < pMem->planes; i++) { +#ifdef TIZEN_FEATURE_ARTIK530 + if (pMem->bo[i]) + tbm_bo_unref (pMem->bo[i]); +#endif if (pMem->pBuffer[i]) { munmap (pMem->pBuffer[i], pMem->size[i]); } free_gem (pMem->drmFd, pMem->gemFd[i]); close (pMem->dmaFd[i]); } +#ifdef TIZEN_FEATURE_ARTIK530 + if (pMem->bufmgr) + tbm_bufmgr_deinit (pMem->bufmgr); +#endif close (pMem->drmFd); free (pMem); } diff --git a/src/nx_video_alloc.h b/src/nx_video_alloc.h index a612a4b..1049437 100644 --- a/src/nx_video_alloc.h +++ b/src/nx_video_alloc.h @@ -51,6 +51,10 @@ extern "C" int32_t stride[NX_MAX_PLANES]; // Each plane's stride. void *pBuffer[NX_MAX_PLANES]; // virtual address. uint32_t reserved[NX_MAX_PLANES]; // for debugging or future user. +#ifdef TIZEN_FEATURE_ARTIK530 + void *bufmgr; + void *bo[NX_MAX_PLANES]; // tbm bo +#endif } NX_VID_MEMORY_INFO, *NX_VID_MEMORY_HANDLE; // Nexell Private Memory Allocator