From 0a146313b0e78ed744f09ba461d67a2bc6e4d6b9 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Mon, 22 Aug 2016 15:21:54 +0900 Subject: [PATCH] Apply tizen coding rule Change-Id: I59637ebe0abb94986c1096680b5af24191fdc842 --- src/tbm_bufmgr_sprd.c | 450 +++++++++++++++++++++++++------------------------- 1 file changed, 222 insertions(+), 228 deletions(-) diff --git a/src/tbm_bufmgr_sprd.c b/src/tbm_bufmgr_sprd.c index da5c9e5..767f6e7 100644 --- a/src/tbm_bufmgr_sprd.c +++ b/src/tbm_bufmgr_sprd.c @@ -78,41 +78,39 @@ target_name() static int initialized = 0; static char app_name[128]; - if ( initialized ) + if (initialized) return app_name; /* get the application name */ f = fopen("/proc/self/cmdline", "r"); - if ( !f ) { + if (!f) return 0; - } memset(app_name, 0x00, sizeof(app_name)); - if ( fgets(app_name, 100, f) == NULL ) { + if (fgets(app_name, 100, f) == NULL) { fclose(f); return 0; } fclose(f); - if ( (slash = strrchr(app_name, '/')) != NULL ) { + if ((slash = strrchr(app_name, '/')) != NULL) memmove(app_name, slash + 1, strlen(slash)); - } initialized = 1; return app_name; } #define TBM_SPRD_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 DBG(fmt, args...) if (bDebug&01) LOGE("[%s]" fmt, target_name(), ##args) #else #define TBM_SPRD_LOG(...) #define DBG(...) #endif -#define SIZE_ALIGN( value, base ) (((value) + ((base) - 1)) & ~((base) - 1)) +#define SIZE_ALIGN(value, base) (((value) + ((base) - 1)) & ~((base) - 1)) #define TBM_SURFACE_ALIGNMENT_PLANE (64) #define TBM_SURFACE_ALIGNMENT_PITCH_RGB (128) @@ -121,16 +119,16 @@ target_name() /* check condition */ #define SPRD_RETURN_IF_FAIL(cond) {\ - if (!(cond)) {\ - TBM_SPRD_LOG ("[%s] : '%s' failed.\n", __FUNCTION__, #cond);\ - return;\ - }\ + if (!(cond)) {\ + TBM_SPRD_LOG("[%s] : '%s' failed.\n", __FUNCTION__, #cond);\ + return;\ + } \ } #define SPRD_RETURN_VAL_IF_FAIL(cond, val) {\ - if (!(cond)) {\ - TBM_SPRD_LOG ("[%s] : '%s' failed.\n", __FUNCTION__, #cond);\ - return val;\ - }\ + if (!(cond)) {\ + TBM_SPRD_LOG("[%s] : '%s' failed.\n", __FUNCTION__, #cond);\ + return val;\ + } \ } struct dma_buf_info { @@ -178,9 +176,9 @@ typedef union _tbm_bo_cache_state tbm_bo_cache_state; union _tbm_bo_cache_state { unsigned int val; struct { - unsigned int cntFlush: 16; /*Flush all index for sync */ - unsigned int isCached: 1; - unsigned int isDirtied: 2; + unsigned int cntFlush:16; /*Flush all index for sync */ + unsigned int isCached:1; + unsigned int isDirtied:2; } data; }; @@ -375,7 +373,7 @@ _tbm_sprd_open_drm() fd = drmOpen(SPRD_DRM_NAME, NULL); if (fd < 0) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] " + TBM_SPRD_LOG("[libtbm-sprd:%d] " "warning %s:%d fail to open drm\n", getpid(), __FUNCTION__, __LINE__); } @@ -390,7 +388,7 @@ _tbm_sprd_open_drm() struct stat s; int ret; - TBM_SPRD_LOG ("[libtbm-sprd:%d] " + TBM_SPRD_LOG("[libtbm-sprd:%d] " "%s:%d search drm-device by udev\n", getpid(), __FUNCTION__, __LINE__); @@ -462,10 +460,10 @@ _tbm_sprd_open_drm() #ifdef USE_CACHE static int -_sprd_bo_cache_flush (tbm_bufmgr_sprd bufmgr_sprd, tbm_bo_sprd bo_sprd, int flags) +_sprd_bo_cache_flush(tbm_bufmgr_sprd bufmgr_sprd, tbm_bo_sprd bo_sprd, int flags) { - SPRD_RETURN_VAL_IF_FAIL (bufmgr_sprd != NULL, 0); - SPRD_RETURN_VAL_IF_FAIL (bo_sprd != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bufmgr_sprd != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bo_sprd != NULL, 0); /* cache flush is managed by kernel side when using dma-fence. */ if (bufmgr_sprd->use_dma_fence) @@ -503,10 +501,10 @@ _sprd_bo_cache_flush (tbm_bufmgr_sprd bufmgr_sprd, tbm_bo_sprd bo_sprd, int flag if (flags & TBM_SPRD_CACHE_ALL) cache_op.flags |= SPRD_DRM_ALL_CACHES_CORES; - ret = drmCommandWriteRead (bufmgr_sprd->fd, DRM_SPRD_GEM_CACHE_OP, &cache_op, + ret = drmCommandWriteRead(bufmgr_sprd->fd, DRM_SPRD_GEM_CACHE_OP, &cache_op, sizeof(cache_op)); if (ret) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] " + TBM_SPRD_LOG("[libtbm-sprd:%d] " "error %s:%d fail to flush the cache.\n", getpid(), __FUNCTION__, __LINE__); return 0; @@ -519,8 +517,8 @@ _sprd_bo_cache_flush (tbm_bufmgr_sprd bufmgr_sprd, tbm_bo_sprd bo_sprd, int flag static int _bo_init_cache_state(tbm_bufmgr_sprd bufmgr_sprd, tbm_bo_sprd bo_sprd, int import) { - SPRD_RETURN_VAL_IF_FAIL (bo_sprd != NULL, 0); - SPRD_RETURN_VAL_IF_FAIL (bufmgr_sprd != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bo_sprd != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bufmgr_sprd != NULL, 0); if (bufmgr_sprd->use_dma_fence) return 1; @@ -546,8 +544,8 @@ static int _bo_set_cache_state(tbm_bufmgr_sprd bufmgr_sprd, tbm_bo_sprd bo_sprd, int device, int opt) { #ifdef USE_CACHE - SPRD_RETURN_VAL_IF_FAIL (bo_sprd != NULL, 0); - SPRD_RETURN_VAL_IF_FAIL (bufmgr_sprd != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bo_sprd != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bufmgr_sprd != NULL, 0); char need_flush = 0; unsigned short cntFlush = 0; @@ -595,7 +593,7 @@ _bo_set_cache_state(tbm_bufmgr_sprd bufmgr_sprd, tbm_bo_sprd bo_sprd, int device _tgl_set_data(bufmgr_sprd->tgl_fd, GLOBAL_KEY, (unsigned int)(++cntFlush)); /* call cache flush */ - _sprd_bo_cache_flush (bufmgr_sprd, bo_sprd, need_flush); + _sprd_bo_cache_flush(bufmgr_sprd, bo_sprd, need_flush); DBG("[libtbm:%d] \tcache(%d,%d)....flush:0x%x, cntFlush(%d)\n", getpid(), @@ -613,8 +611,8 @@ static int _bo_save_cache_state(tbm_bufmgr_sprd bufmgr_sprd, tbm_bo_sprd bo_sprd) { #ifdef USE_CACHE - SPRD_RETURN_VAL_IF_FAIL (bo_sprd != NULL, 0); - SPRD_RETURN_VAL_IF_FAIL (bufmgr_sprd != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bo_sprd != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bufmgr_sprd != NULL, 0); if (bufmgr_sprd->use_dma_fence) return 1; @@ -635,8 +633,8 @@ _bo_save_cache_state(tbm_bufmgr_sprd bufmgr_sprd, tbm_bo_sprd bo_sprd) static void _bo_destroy_cache_state(tbm_bufmgr_sprd bufmgr_sprd, tbm_bo_sprd bo_sprd) { - SPRD_RETURN_IF_FAIL (bo_sprd != NULL); - SPRD_RETURN_IF_FAIL (bufmgr_sprd != NULL); + SPRD_RETURN_IF_FAIL(bo_sprd != NULL); + SPRD_RETURN_IF_FAIL(bufmgr_sprd != NULL); if (bufmgr_sprd->use_dma_fence) return; @@ -693,7 +691,7 @@ _bufmgr_deinit_cache_state(tbm_bufmgr_sprd bufmgr_sprd) #ifndef USE_CONTIG_ONLY static unsigned int -_get_sprd_flag_from_tbm (unsigned int ftbm) +_get_sprd_flag_from_tbm(unsigned int ftbm) { unsigned int flags = 0; @@ -704,11 +702,10 @@ _get_sprd_flag_from_tbm (unsigned int ftbm) * To be updated appropriately once DRM-GEM supports different heap id masks. * */ - if (ftbm & TBM_BO_SCANOUT) { + if (ftbm & TBM_BO_SCANOUT) flags = SPRD_BO_CONTIG; - } else { + else flags = SPRD_BO_NONCONTIG | SPRD_BO_DEV_SYSTEM; - } if (ftbm & TBM_BO_WC) flags |= SPRD_BO_WC; @@ -719,7 +716,7 @@ _get_sprd_flag_from_tbm (unsigned int ftbm) } static unsigned int -_get_tbm_flag_from_sprd (unsigned int fsprd) +_get_tbm_flag_from_sprd(unsigned int fsprd) { unsigned int flags = 0; @@ -740,13 +737,13 @@ _get_tbm_flag_from_sprd (unsigned int fsprd) #endif static unsigned int -_get_name (int fd, unsigned int gem) +_get_name(int fd, unsigned int gem) { struct drm_gem_flink arg = {0,}; arg.handle = gem; - if (drmIoctl (fd, DRM_IOCTL_GEM_FLINK, &arg)) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] " + if (drmIoctl(fd, DRM_IOCTL_GEM_FLINK, &arg)) { + TBM_SPRD_LOG("[libtbm-sprd:%d] " "error %s:%d fail to get flink gem=%d\n", getpid(), __FUNCTION__, __LINE__, gem); return 0; @@ -756,10 +753,10 @@ _get_name (int fd, unsigned int gem) } static tbm_bo_handle -_sprd_bo_handle (tbm_bo_sprd bo_sprd, int device) +_sprd_bo_handle(tbm_bo_sprd bo_sprd, int device) { tbm_bo_handle bo_handle; - memset (&bo_handle, 0x0, sizeof (uint64_t)); + memset(&bo_handle, 0x0, sizeof(uint64_t)); switch (device) { case TBM_DEVICE_DEFAULT: @@ -772,8 +769,8 @@ _sprd_bo_handle (tbm_bo_sprd bo_sprd, int device) arg.handle = bo_sprd->gem; arg.size = bo_sprd->size; - if (drmCommandWriteRead (bo_sprd->fd, DRM_SPRD_GEM_MMAP, &arg, sizeof(arg))) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] " + if (drmCommandWriteRead(bo_sprd->fd, DRM_SPRD_GEM_MMAP, &arg, sizeof(arg))) { + TBM_SPRD_LOG("[libtbm-sprd:%d] " "error %s:%d Cannot usrptr gem=%d\n", getpid(), __FUNCTION__, __LINE__, bo_sprd->gem); return (tbm_bo_handle) NULL; @@ -788,8 +785,8 @@ _sprd_bo_handle (tbm_bo_sprd bo_sprd, int device) if (!bo_sprd->dmabuf) { struct drm_prime_handle arg = {0, }; arg.handle = bo_sprd->gem; - if (drmIoctl (bo_sprd->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] " + if (drmIoctl(bo_sprd->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { + TBM_SPRD_LOG("[libtbm-sprd:%d] " "error %s:%d Cannot dmabuf=%d\n", getpid(), __FUNCTION__, __LINE__, bo_sprd->gem); return (tbm_bo_handle) NULL; @@ -805,7 +802,7 @@ _sprd_bo_handle (tbm_bo_sprd bo_sprd, int device) case TBM_DEVICE_MM: #ifdef USE_HEAP_ID //TODO : Add ioctl for GSP MAP once available. - DBG ("[libtbm-sprd:%d] %s In case TBM_DEVICE_MM: \n", getpid(), + DBG("[libtbm-sprd:%d] %s In case TBM_DEVICE_MM: \n", getpid(), __FUNCTION_); _ @@ -814,8 +811,8 @@ _sprd_bo_handle (tbm_bo_sprd bo_sprd, int device) struct drm_prime_handle arg = {0, }; arg.handle = bo_sprd->gem; - if (drmIoctl (bo_sprd->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] " + if (drmIoctl(bo_sprd->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { + TBM_SPRD_LOG("[libtbm-sprd:%d] " "error %s:%d Cannot dmabuf=%d\n", getpid(), __FUNCTION__, __LINE__, bo_sprd->gem); return (tbm_bo_handle) NULL; @@ -835,9 +832,9 @@ _sprd_bo_handle (tbm_bo_sprd bo_sprd, int device) } static int -tbm_sprd_bo_size (tbm_bo bo) +tbm_sprd_bo_size(tbm_bo bo) { - SPRD_RETURN_VAL_IF_FAIL (bo != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bo != NULL, 0); tbm_bo_sprd bo_sprd; @@ -847,20 +844,20 @@ tbm_sprd_bo_size (tbm_bo bo) } static void * -tbm_sprd_bo_alloc (tbm_bo bo, int size, int flags) +tbm_sprd_bo_alloc(tbm_bo bo, int size, int flags) { - SPRD_RETURN_VAL_IF_FAIL (bo != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bo != NULL, 0); tbm_bo_sprd bo_sprd; tbm_bufmgr_sprd bufmgr_sprd; unsigned int sprd_flags; bufmgr_sprd = (tbm_bufmgr_sprd)tbm_backend_get_bufmgr_priv(bo); - SPRD_RETURN_VAL_IF_FAIL (bufmgr_sprd != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bufmgr_sprd != NULL, 0); - bo_sprd = calloc (1, sizeof(struct _tbm_bo_sprd)); + bo_sprd = calloc(1, sizeof(struct _tbm_bo_sprd)); if (!bo_sprd) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] " + TBM_SPRD_LOG("[libtbm-sprd:%d] " "error %s:%d fail to allocate the bo private\n", getpid(), __FUNCTION__, __LINE__); return 0; @@ -870,7 +867,7 @@ tbm_sprd_bo_alloc (tbm_bo bo, int size, int flags) flags = TBM_BO_SCANOUT; sprd_flags = SPRD_BO_CONTIG; #else - sprd_flags = _get_sprd_flag_from_tbm (flags); + sprd_flags = _get_sprd_flag_from_tbm(flags); if ((flags & TBM_BO_SCANOUT) && size <= 4 * 1024) { sprd_flags |= SPRD_BO_NONCONTIG; @@ -881,10 +878,10 @@ tbm_sprd_bo_alloc (tbm_bo bo, int size, int flags) arg.flags = sprd_flags; if (drmCommandWriteRead(bufmgr_sprd->fd, DRM_SPRD_GEM_CREATE, &arg, sizeof(arg))) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] " + TBM_SPRD_LOG("[libtbm-sprd:%d] " "error %s:%d Cannot create bo(flag:%x, size:%d)\n", getpid(), __FUNCTION__, __LINE__, arg.flags, (unsigned int)arg.size); - free (bo_sprd); + free(bo_sprd); return 0; } @@ -893,11 +890,11 @@ tbm_sprd_bo_alloc (tbm_bo bo, int size, int flags) bo_sprd->size = size; bo_sprd->flags_tbm = flags; bo_sprd->flags_sprd = sprd_flags; - bo_sprd->name = _get_name (bo_sprd->fd, bo_sprd->gem); + bo_sprd->name = _get_name(bo_sprd->fd, bo_sprd->gem); if (!_bo_init_cache_state(bufmgr_sprd, bo_sprd, 0)) { - TBM_SPRD_LOG ("error fail init cache state(%d)\n", bo_sprd->name); - free (bo_sprd); + TBM_SPRD_LOG("error fail init cache state(%d)\n", bo_sprd->name); + free(bo_sprd); return 0; } @@ -908,27 +905,27 @@ tbm_sprd_bo_alloc (tbm_bo bo, int size, int flags) struct drm_prime_handle arg = {0, }; arg.handle = bo_sprd->gem; - if (drmIoctl (bo_sprd->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] " + if (drmIoctl(bo_sprd->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { + TBM_SPRD_LOG("[libtbm-sprd:%d] " "error %s:%d Cannot dmabuf=%d\n", getpid(), __FUNCTION__, __LINE__, bo_sprd->gem); - free (bo_sprd); + free(bo_sprd); return 0; } bo_sprd->dmabuf = arg.fd; } /* add bo to hash */ - PrivGem *privGem = calloc (1, sizeof(PrivGem)); + PrivGem *privGem = calloc(1, sizeof(PrivGem)); privGem->ref_count = 1; privGem->bo_priv = bo_sprd; if (drmHashInsert(bufmgr_sprd->hashBos, bo_sprd->name, (void *)privGem) < 0) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] " + TBM_SPRD_LOG("[libtbm-sprd:%d] " "error %s:%d Cannot insert bo to Hash(%d)\n", getpid(), __FUNCTION__, __LINE__, bo_sprd->name); } - DBG ("[libtbm-sprd:%d] %s size:%d, gem:%d(%d), flags:%d(%d)\n", getpid(), + DBG("[libtbm-sprd:%d] %s size:%d, gem:%d(%d), flags:%d(%d)\n", getpid(), __FUNCTION__, bo_sprd->size, bo_sprd->gem, bo_sprd->name, flags, sprd_flags); @@ -946,25 +943,25 @@ tbm_sprd_bo_free(tbm_bo bo) return; bufmgr_sprd = (tbm_bufmgr_sprd)tbm_backend_get_bufmgr_priv(bo); - SPRD_RETURN_IF_FAIL (bufmgr_sprd != NULL); + SPRD_RETURN_IF_FAIL(bufmgr_sprd != NULL); bo_sprd = (tbm_bo_sprd)tbm_backend_get_bo_priv(bo); - SPRD_RETURN_IF_FAIL (bo_sprd != NULL); + SPRD_RETURN_IF_FAIL(bo_sprd != NULL); - DBG ("[libtbm-sprd:%d] %s size:%d, gem:%d(%d)\n", + DBG("[libtbm-sprd:%d] %s size:%d, gem:%d(%d)\n", getpid(), __FUNCTION__, bo_sprd->size, bo_sprd->gem, bo_sprd->name); if (bo_sprd->pBase) { if (munmap(bo_sprd->pBase, bo_sprd->size) == -1) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] " + TBM_SPRD_LOG("[libtbm-sprd:%d] " "error %s:%d\n", getpid(), __FUNCTION__, __LINE__); } } - /* close dmabuf */ + /* closedmabuf */ if (bo_sprd->dmabuf) { - close (bo_sprd->dmabuf); + close(bo_sprd->dmabuf); bo_sprd->dmabuf = 0; } @@ -972,16 +969,16 @@ tbm_sprd_bo_free(tbm_bo bo) PrivGem *privGem = NULL; int ret; - ret = drmHashLookup (bufmgr_sprd->hashBos, bo_sprd->name, (void **)&privGem); + ret = drmHashLookup(bufmgr_sprd->hashBos, bo_sprd->name, (void **)&privGem); if (ret == 0) { privGem->ref_count--; if (privGem->ref_count == 0) { - drmHashDelete (bufmgr_sprd->hashBos, bo_sprd->name); - free (privGem); + drmHashDelete(bufmgr_sprd->hashBos, bo_sprd->name); + free(privGem); privGem = NULL; } } else { - TBM_SPRD_LOG ("[libtbm-sprd:%d] " + TBM_SPRD_LOG("[libtbm-sprd:%d] " "warning %s:%d Cannot find bo to Hash(%d), ret=%d\n", getpid(), __FUNCTION__, __LINE__, bo_sprd->name, ret); } @@ -990,22 +987,22 @@ tbm_sprd_bo_free(tbm_bo bo) /* Free gem handle */ struct drm_gem_close arg = {0, }; - memset (&arg, 0, sizeof(arg)); + memset(&arg, 0, sizeof(arg)); arg.handle = bo_sprd->gem; - if (drmIoctl (bo_sprd->fd, DRM_IOCTL_GEM_CLOSE, &arg)) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] " + if (drmIoctl(bo_sprd->fd, DRM_IOCTL_GEM_CLOSE, &arg)) { + TBM_SPRD_LOG("[libtbm-sprd:%d] " "error %s:%d\n", getpid(), __FUNCTION__, __LINE__); } - free (bo_sprd); + free(bo_sprd); } static void * -tbm_sprd_bo_import (tbm_bo bo, unsigned int key) +tbm_sprd_bo_import(tbm_bo bo, unsigned int key) { - SPRD_RETURN_VAL_IF_FAIL (bo != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bo != NULL, 0); tbm_bufmgr_sprd bufmgr_sprd; tbm_bo_sprd bo_sprd; @@ -1013,19 +1010,18 @@ tbm_sprd_bo_import (tbm_bo bo, unsigned int key) int ret; bufmgr_sprd = (tbm_bufmgr_sprd)tbm_backend_get_bufmgr_priv(bo); - SPRD_RETURN_VAL_IF_FAIL (bufmgr_sprd != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bufmgr_sprd != NULL, 0); - ret = drmHashLookup (bufmgr_sprd->hashBos, key, (void **)&privGem); - if (ret == 0) { + ret = drmHashLookup(bufmgr_sprd->hashBos, key, (void **)&privGem); + if (ret == 0) return privGem->bo_priv; - } struct drm_gem_open arg = {0, }; struct drm_sprd_gem_info info = {0, }; arg.name = key; if (drmIoctl(bufmgr_sprd->fd, DRM_IOCTL_GEM_OPEN, &arg)) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] " + TBM_SPRD_LOG("[libtbm-sprd:%d] " "error %s:%d Cannot open gem name=%d\n", getpid(), __FUNCTION__, __LINE__, key); return 0; @@ -1036,15 +1032,15 @@ tbm_sprd_bo_import (tbm_bo bo, unsigned int key) DRM_SPRD_GEM_GET, &info, sizeof(struct drm_sprd_gem_info))) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] " + TBM_SPRD_LOG("[libtbm-sprd:%d] " "error %s:%d Cannot get gem info=%d\n", getpid(), __FUNCTION__, __LINE__, key); return 0; } - bo_sprd = calloc (1, sizeof(struct _tbm_bo_sprd)); + bo_sprd = calloc(1, sizeof(struct _tbm_bo_sprd)); if (!bo_sprd) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] " + TBM_SPRD_LOG("[libtbm-sprd:%d] " "error %s:%d fail to allocate the bo private\n", getpid(), __FUNCTION__, __LINE__); return 0; @@ -1059,12 +1055,12 @@ tbm_sprd_bo_import (tbm_bo bo, unsigned int key) bo_sprd->flags_sprd = SPRD_BO_CONTIG; bo_sprd->flags_tbm |= TBM_BO_SCANOUT; #else - bo_sprd->flags_tbm = _get_tbm_flag_from_sprd (bo_sprd->flags_sprd); + bo_sprd->flags_tbm = _get_tbm_flag_from_sprd(bo_sprd->flags_sprd); #endif if (!_bo_init_cache_state(bufmgr_sprd, bo_sprd, 1)) { - TBM_SPRD_LOG ("error fail init cache state(%d)\n", bo_sprd->name); - free (bo_sprd); + TBM_SPRD_LOG("error fail init cache state(%d)\n", bo_sprd->name); + free(bo_sprd); return 0; } @@ -1072,27 +1068,27 @@ tbm_sprd_bo_import (tbm_bo bo, unsigned int key) struct drm_prime_handle arg = {0, }; arg.handle = bo_sprd->gem; - if (drmIoctl (bo_sprd->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] " + if (drmIoctl(bo_sprd->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { + TBM_SPRD_LOG("[libtbm-sprd:%d] " "error %s:%d Cannot dmabuf=%d\n", getpid(), __FUNCTION__, __LINE__, bo_sprd->gem); - free (bo_sprd); + free(bo_sprd); return 0; } bo_sprd->dmabuf = arg.fd; } /* add bo to hash */ - privGem = calloc (1, sizeof(PrivGem)); + privGem = calloc(1, sizeof(PrivGem)); privGem->ref_count = 1; privGem->bo_priv = bo_sprd; - if (drmHashInsert (bufmgr_sprd->hashBos, bo_sprd->name, (void *)privGem) < 0) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] " + if (drmHashInsert(bufmgr_sprd->hashBos, bo_sprd->name, (void *)privGem) < 0) { + TBM_SPRD_LOG("[libtbm-sprd:%d] " "error %s:%d Cannot insert bo to Hash(%d)\n", getpid(), __FUNCTION__, __LINE__, bo_sprd->name); } - DBG ("[libtbm-sprd:%d] %s size:%d, gem:%d(%d), flags:%d(%d)\n", getpid(), + DBG("[libtbm-sprd:%d] %s size:%d, gem:%d(%d), flags:%d(%d)\n", getpid(), __FUNCTION__, bo_sprd->size, bo_sprd->gem, bo_sprd->name, bo_sprd->flags_tbm, bo_sprd->flags_sprd); @@ -1101,9 +1097,9 @@ tbm_sprd_bo_import (tbm_bo bo, unsigned int key) } static void * -tbm_sprd_bo_import_fd (tbm_bo bo, tbm_fd key) +tbm_sprd_bo_import_fd(tbm_bo bo, tbm_fd key) { - SPRD_RETURN_VAL_IF_FAIL (bo != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bo != NULL, 0); tbm_bufmgr_sprd bufmgr_sprd; tbm_bo_sprd bo_sprd; @@ -1112,7 +1108,7 @@ tbm_sprd_bo_import_fd (tbm_bo bo, tbm_fd key) unsigned int name; bufmgr_sprd = (tbm_bufmgr_sprd)tbm_backend_get_bufmgr_priv(bo); - SPRD_RETURN_VAL_IF_FAIL (bufmgr_sprd != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bufmgr_sprd != NULL, 0); //getting handle from fd unsigned int gem = 0; @@ -1120,20 +1116,19 @@ tbm_sprd_bo_import_fd (tbm_bo bo, tbm_fd key) arg.fd = key; arg.flags = 0; - if (drmIoctl (bufmgr_sprd->fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &arg)) { - TBM_SPRD_LOG ("error bo:%p Cannot get gem handle from fd:%d (%s)\n", + if (drmIoctl(bufmgr_sprd->fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &arg)) { + TBM_SPRD_LOG("error bo:%p Cannot get gem handle from fd:%d (%s)\n", bo, arg.fd, strerror(errno)); return NULL; } gem = arg.handle; - name = _get_name (bufmgr_sprd->fd, gem); + name = _get_name(bufmgr_sprd->fd, gem); - ret = drmHashLookup (bufmgr_sprd->hashBos, name, (void **)&privGem); + ret = drmHashLookup(bufmgr_sprd->hashBos, name, (void **)&privGem); if (ret == 0) { - if (gem == privGem->bo_priv->gem) { + if (gem == privGem->bo_priv->gem) return privGem->bo_priv; - } } unsigned int real_size = -1; @@ -1151,7 +1146,7 @@ tbm_sprd_bo_import_fd (tbm_bo bo, tbm_fd key) DRM_SPRD_GEM_GET, &info, sizeof(struct drm_sprd_gem_info))) { - TBM_SPRD_LOG ("error bo:%p Cannot get gem info from gem:%d, fd:%d (%s)\n", + TBM_SPRD_LOG("error bo:%p Cannot get gem info from gem:%d, fd:%d (%s)\n", bo, gem, key, strerror(errno)); return 0; } @@ -1159,9 +1154,9 @@ tbm_sprd_bo_import_fd (tbm_bo bo, tbm_fd key) if (real_size == -1) real_size = info.size; - bo_sprd = calloc (1, sizeof(struct _tbm_bo_sprd)); + bo_sprd = calloc(1, sizeof(struct _tbm_bo_sprd)); if (!bo_sprd) { - TBM_SPRD_LOG ("error bo:%p fail to allocate the bo private\n", bo); + TBM_SPRD_LOG("error bo:%p fail to allocate the bo private\n", bo); return 0; } @@ -1169,42 +1164,42 @@ tbm_sprd_bo_import_fd (tbm_bo bo, tbm_fd key) bo_sprd->gem = gem; bo_sprd->size = real_size; bo_sprd->flags_sprd = info.flags; - bo_sprd->flags_tbm = _get_tbm_flag_from_sprd (bo_sprd->flags_sprd); + bo_sprd->flags_tbm = _get_tbm_flag_from_sprd(bo_sprd->flags_sprd); bo_sprd->name = name; if (!bo_sprd->name) { - TBM_SPRD_LOG ("error bo:%p Cannot get name from gem:%d, fd:%d (%s)\n", + TBM_SPRD_LOG("error bo:%p Cannot get name from gem:%d, fd:%d (%s)\n", bo, gem, key, strerror(errno)); - free (bo_sprd); + free(bo_sprd); return 0; } if (!_bo_init_cache_state(bufmgr_sprd, bo_sprd, 1)) { - TBM_SPRD_LOG ("error fail init cache state(%d)\n", bo_sprd->name); - free (bo_sprd); + TBM_SPRD_LOG("error fail init cache state(%d)\n", bo_sprd->name); + free(bo_sprd); return 0; } /* add bo to hash */ privGem = NULL; - privGem = calloc (1, sizeof(PrivGem)); + privGem = calloc(1, sizeof(PrivGem)); if (!privGem) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] " - "error %s:%d Fail to calloc privGem\n", + TBM_SPRD_LOG("[libtbm-sprd:%d] " + "error %s:%d Fail to callocprivGem\n", getpid(), __FUNCTION__, __LINE__); - free (bo_sprd); + free(bo_sprd); return 0; } privGem->ref_count = 1; privGem->bo_priv = bo_sprd; - if (drmHashInsert (bufmgr_sprd->hashBos, bo_sprd->name, (void *)privGem) < 0) { - TBM_SPRD_LOG ("error bo:%p Cannot insert bo to Hash(%d) from gem:%d, fd:%d\n", + if (drmHashInsert(bufmgr_sprd->hashBos, bo_sprd->name, (void *)privGem) < 0) { + TBM_SPRD_LOG("error bo:%p Cannot insert bo to Hash(%d) from gem:%d, fd:%d\n", bo, bo_sprd->name, gem, key); } - DBG (" [%s] bo:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d(%d), size:%d\n", + DBG(" [%s] bo:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d(%d), size:%d\n", target_name(), bo, bo_sprd->gem, bo_sprd->name, @@ -1217,26 +1212,26 @@ tbm_sprd_bo_import_fd (tbm_bo bo, tbm_fd key) } static unsigned int -tbm_sprd_bo_export (tbm_bo bo) +tbm_sprd_bo_export(tbm_bo bo) { - SPRD_RETURN_VAL_IF_FAIL (bo != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bo != NULL, 0); tbm_bo_sprd bo_sprd; bo_sprd = (tbm_bo_sprd)tbm_backend_get_bo_priv(bo); - SPRD_RETURN_VAL_IF_FAIL (bo_sprd != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bo_sprd != NULL, 0); if (!bo_sprd->name) { bo_sprd->name = _get_name(bo_sprd->fd, bo_sprd->gem); if (!bo_sprd->name) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] " + TBM_SPRD_LOG("[libtbm-sprd:%d] " "error %s:%d Cannot get name\n", getpid(), __FUNCTION__, __LINE__); return 0; } } - DBG ("[libtbm-sprd:%d] %s size:%d, gem:%d(%d), flags:%d(%d)\n", getpid(), + DBG("[libtbm-sprd:%d] %s size:%d, gem:%d(%d), flags:%d(%d)\n", getpid(), __FUNCTION__, bo_sprd->size, bo_sprd->gem, bo_sprd->name, bo_sprd->flags_tbm, bo_sprd->flags_sprd); @@ -1245,27 +1240,27 @@ tbm_sprd_bo_export (tbm_bo bo) } tbm_fd -tbm_sprd_bo_export_fd (tbm_bo bo) +tbm_sprd_bo_export_fd(tbm_bo bo) { - SPRD_RETURN_VAL_IF_FAIL (bo != NULL, -1); + SPRD_RETURN_VAL_IF_FAIL(bo != NULL, -1); tbm_bo_sprd bo_sprd; int ret; bo_sprd = (tbm_bo_sprd)tbm_backend_get_bo_priv(bo); - SPRD_RETURN_VAL_IF_FAIL (bo_sprd != NULL, -1); + SPRD_RETURN_VAL_IF_FAIL(bo_sprd != NULL, -1); struct drm_prime_handle arg = {0, }; arg.handle = bo_sprd->gem; - ret = drmIoctl (bo_sprd->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg); + ret = drmIoctl(bo_sprd->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg); if (ret) { - TBM_SPRD_LOG ("error bo:%p Cannot dmabuf=%d (%s)\n", + TBM_SPRD_LOG("error bo:%p Cannot dmabuf=%d (%s)\n", bo, bo_sprd->gem, strerror(errno)); return (tbm_fd) ret; } - DBG (" [%s] bo:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d(%d), size:%d\n", + DBG(" [%s] bo:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d(%d), size:%d\n", target_name(), bo, bo_sprd->gem, bo_sprd->name, @@ -1279,30 +1274,30 @@ tbm_sprd_bo_export_fd (tbm_bo bo) static tbm_bo_handle -tbm_sprd_bo_get_handle (tbm_bo bo, int device) +tbm_sprd_bo_get_handle(tbm_bo bo, int device) { - SPRD_RETURN_VAL_IF_FAIL (bo != NULL, (tbm_bo_handle) NULL); + SPRD_RETURN_VAL_IF_FAIL(bo != NULL, (tbm_bo_handle) NULL); tbm_bo_handle bo_handle; tbm_bo_sprd bo_sprd; bo_sprd = (tbm_bo_sprd)tbm_backend_get_bo_priv(bo); - SPRD_RETURN_VAL_IF_FAIL (bo_sprd != NULL, (tbm_bo_handle) NULL); + SPRD_RETURN_VAL_IF_FAIL(bo_sprd != NULL, (tbm_bo_handle) NULL); if (!bo_sprd->gem) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] " + TBM_SPRD_LOG("[libtbm-sprd:%d] " "error %s:%d Cannot map gem=%d\n", getpid(), __FUNCTION__, __LINE__, bo_sprd->gem); return (tbm_bo_handle) NULL; } - DBG ("[libtbm-sprd:%d] %s gem:%d(%d), %s\n", getpid(), + DBG("[libtbm-sprd:%d] %s gem:%d(%d), %s\n", getpid(), __FUNCTION__, bo_sprd->gem, bo_sprd->name, STR_DEVICE[device]); /*Get mapped bo_handle*/ - bo_handle = _sprd_bo_handle (bo_sprd, device); + bo_handle = _sprd_bo_handle(bo_sprd, device); if (bo_handle.ptr == NULL) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] " + TBM_SPRD_LOG("[libtbm-sprd:%d] " "error %s:%d Cannot get handle: gem:%d, device:%d\n", getpid(), __FUNCTION__, __LINE__, bo_sprd->gem, device); return (tbm_bo_handle) NULL; @@ -1312,41 +1307,41 @@ tbm_sprd_bo_get_handle (tbm_bo bo, int device) } static tbm_bo_handle -tbm_sprd_bo_map (tbm_bo bo, int device, int opt) +tbm_sprd_bo_map(tbm_bo bo, int device, int opt) { - SPRD_RETURN_VAL_IF_FAIL (bo != NULL, (tbm_bo_handle) NULL); + SPRD_RETURN_VAL_IF_FAIL(bo != NULL, (tbm_bo_handle) NULL); tbm_bo_handle bo_handle; tbm_bo_sprd bo_sprd; tbm_bufmgr_sprd bufmgr_sprd; bufmgr_sprd = (tbm_bufmgr_sprd)tbm_backend_get_bufmgr_priv(bo); - SPRD_RETURN_VAL_IF_FAIL (bufmgr_sprd != NULL, (tbm_bo_handle) NULL); + SPRD_RETURN_VAL_IF_FAIL(bufmgr_sprd != NULL, (tbm_bo_handle) NULL); bo_sprd = (tbm_bo_sprd)tbm_backend_get_bo_priv(bo); - SPRD_RETURN_VAL_IF_FAIL (bo_sprd != NULL, (tbm_bo_handle) NULL); + SPRD_RETURN_VAL_IF_FAIL(bo_sprd != NULL, (tbm_bo_handle) NULL); if (!bo_sprd->gem) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] " + TBM_SPRD_LOG("[libtbm-sprd:%d] " "error %s:%d Cannot map gem=%d\n", getpid(), __FUNCTION__, __LINE__, bo_sprd->gem); return (tbm_bo_handle) NULL; } - DBG ("[libtbm-sprd:%d] %s gem:%d(%d), %s, %s\n", getpid(), + DBG("[libtbm-sprd:%d] %s gem:%d(%d), %s, %s\n", getpid(), __FUNCTION__, bo_sprd->gem, bo_sprd->name, STR_DEVICE[device], STR_OPT[opt]); /*Get mapped bo_handle*/ - bo_handle = _sprd_bo_handle (bo_sprd, device); + bo_handle = _sprd_bo_handle(bo_sprd, device); if (bo_handle.ptr == NULL) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] " + TBM_SPRD_LOG("[libtbm-sprd:%d] " "error %s:%d Cannot get handle: gem:%d, device:%d, opt:%d\n", getpid(), __FUNCTION__, __LINE__, bo_sprd->gem, device, opt); return (tbm_bo_handle) NULL; } if (bo_sprd->map_cnt == 0) - _bo_set_cache_state (bufmgr_sprd, bo_sprd, device, opt); + _bo_set_cache_state(bufmgr_sprd, bo_sprd, device, opt); bo_sprd->map_cnt++; @@ -1354,18 +1349,18 @@ tbm_sprd_bo_map (tbm_bo bo, int device, int opt) } static int -tbm_sprd_bo_unmap (tbm_bo bo) +tbm_sprd_bo_unmap(tbm_bo bo) { - SPRD_RETURN_VAL_IF_FAIL (bo != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bo != NULL, 0); tbm_bo_sprd bo_sprd; tbm_bufmgr_sprd bufmgr_sprd; bufmgr_sprd = (tbm_bufmgr_sprd)tbm_backend_get_bufmgr_priv(bo); - SPRD_RETURN_VAL_IF_FAIL (bufmgr_sprd != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bufmgr_sprd != NULL, 0); bo_sprd = (tbm_bo_sprd)tbm_backend_get_bo_priv(bo); - SPRD_RETURN_VAL_IF_FAIL (bo_sprd != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bo_sprd != NULL, 0); if (!bo_sprd->gem) return 0; @@ -1373,9 +1368,9 @@ tbm_sprd_bo_unmap (tbm_bo bo) bo_sprd->map_cnt--; if (bo_sprd->map_cnt == 0) - _bo_save_cache_state (bufmgr_sprd, bo_sprd); + _bo_save_cache_state(bufmgr_sprd, bo_sprd); - DBG ("[libtbm-sprd:%d] %s gem:%d(%d) \n", getpid(), + DBG("[libtbm-sprd:%d] %s gem:%d(%d) \n", getpid(), __FUNCTION__, bo_sprd->gem, bo_sprd->name); return 1; @@ -1384,16 +1379,16 @@ tbm_sprd_bo_unmap (tbm_bo bo) static int tbm_sprd_bo_lock(tbm_bo bo, int device, int opt) { - SPRD_RETURN_VAL_IF_FAIL (bo != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bo != NULL, 0); tbm_bufmgr_sprd bufmgr_sprd; tbm_bo_sprd bo_sprd; bo_sprd = (tbm_bo_sprd)tbm_backend_get_bo_priv(bo); - SPRD_RETURN_VAL_IF_FAIL (bo_sprd != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bo_sprd != NULL, 0); bufmgr_sprd = (tbm_bufmgr_sprd)tbm_backend_get_bufmgr_priv(bo); - SPRD_RETURN_VAL_IF_FAIL (bufmgr_sprd != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bufmgr_sprd != NULL, 0); #if USE_BACKEND_LOCK int ret = 0; @@ -1411,7 +1406,7 @@ tbm_sprd_bo_lock(tbm_bo bo, int device, int opt) else if (device == TBM_DEVICE_3D) fence.type = DMA_BUF_ACCESS_WRITE | DMA_BUF_ACCESS_DMA; else { - DBG ("[libtbm-sprd:%d] %s GET_FENCE is ignored(device type is not 3D/CPU),\n", + DBG("[libtbm-sprd:%d] %s GET_FENCE is ignored(device type is not 3D/CPU),\n", getpid(), __FUNCTION__); return 0; } @@ -1421,30 +1416,30 @@ tbm_sprd_bo_lock(tbm_bo bo, int device, int opt) else if (device == TBM_DEVICE_3D) fence.type = DMA_BUF_ACCESS_READ | DMA_BUF_ACCESS_DMA; else { - DBG ("[libtbm-sprd:%d] %s GET_FENCE is ignored(device type is not 3D/CPU),\n", + DBG("[libtbm-sprd:%d] %s GET_FENCE is ignored(device type is not 3D/CPU),\n", getpid(), __FUNCTION__); return 0; } } else { - TBM_SPRD_LOG ("[libtbm-sprd:%d] error %s:%d Invalid argument\n", getpid(), + TBM_SPRD_LOG("[libtbm-sprd:%d] error %s:%d Invalid argument\n", getpid(), __FUNCTION__, __LINE__); return 0; } /* Check if the tbm manager supports dma fence or not. */ if (!bufmgr_sprd->use_dma_fence) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] " + TBM_SPRD_LOG("[libtbm-sprd:%d] " "error %s:%d Not support DMA FENCE(%s)\n", - getpid(), __FUNCTION__, __LINE__, strerror(errno) ); + getpid(), __FUNCTION__, __LINE__, strerror(errno)); return 0; } ret = ioctl(bo_sprd->dmabuf, DMABUF_IOCTL_GET_FENCE, &fence); if (ret < 0) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] " + TBM_SPRD_LOG("[libtbm-sprd:%d] " "error %s:%d Can not set GET FENCE(%s)\n", - getpid(), __FUNCTION__, __LINE__, strerror(errno) ); + getpid(), __FUNCTION__, __LINE__, strerror(errno)); return 0; } @@ -1459,20 +1454,20 @@ tbm_sprd_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_SPRD_LOG ("[libtbm-sprd:%d] " + TBM_SPRD_LOG("[libtbm-sprd:%d] " "error %s:%d fence list is full\n", getpid(), __FUNCTION__, __LINE__); } pthread_mutex_unlock(&bo_sprd->mutex); - DBG ("[libtbm-sprd:%d] %s DMABUF_IOCTL_GET_FENCE! flink_id=%d dmabuf=%d\n", + DBG("[libtbm-sprd:%d] %s DMABUF_IOCTL_GET_FENCE! flink_id=%d dmabuf=%d\n", getpid(), __FUNCTION__, bo_sprd->name, bo_sprd->dmabuf); } else { ret = _tgl_lock(bufmgr_sprd->tgl_fd, bo_sprd->name); - DBG ("[libtbm-sprd:%d] lock tgl flink_id:%d\n", + DBG("[libtbm-sprd:%d] lock tgl flink_id:%d\n", getpid(), __FUNCTION__, bo_sprd->name); return ret; @@ -1485,16 +1480,16 @@ tbm_sprd_bo_lock(tbm_bo bo, int device, int opt) static int tbm_sprd_bo_unlock(tbm_bo bo) { - SPRD_RETURN_VAL_IF_FAIL (bo != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bo != NULL, 0); tbm_bufmgr_sprd bufmgr_sprd; tbm_bo_sprd bo_sprd; bo_sprd = (tbm_bo_sprd)tbm_backend_get_bo_priv(bo); - SPRD_RETURN_VAL_IF_FAIL (bo_sprd != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bo_sprd != NULL, 0); bufmgr_sprd = (tbm_bufmgr_sprd)tbm_backend_get_bufmgr_priv(bo); - SPRD_RETURN_VAL_IF_FAIL (bufmgr_sprd != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bufmgr_sprd != NULL, 0); #if USE_BACKEND_LOCK int ret = 0; @@ -1503,13 +1498,13 @@ tbm_sprd_bo_unlock(tbm_bo bo) struct dma_buf_fence fence; if (!bo_sprd->dma_fence[0].ctx) { - DBG ("[libtbm-sprd:%d] %s FENCE not support or ignored,\n", getpid(), + DBG("[libtbm-sprd:%d] %s FENCE not support or ignored,\n", getpid(), __FUNCTION__); return 0; } if (!bo_sprd->dma_fence[0].type) { - DBG ("[libtbm-sprd:%d] %s device type is not 3D/CPU,\n", getpid(), + DBG("[libtbm-sprd:%d] %s device type is not 3D/CPU,\n", getpid(), __FUNCTION__); return 0; } @@ -1528,19 +1523,19 @@ tbm_sprd_bo_unlock(tbm_bo bo) ret = ioctl(bo_sprd->dmabuf, DMABUF_IOCTL_PUT_FENCE, &fence); if (ret < 0) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] " + TBM_SPRD_LOG("[libtbm-sprd:%d] " "error %s:%d Can not set PUT FENCE(%s)\n", - getpid(), __FUNCTION__, __LINE__, strerror(errno) ); + getpid(), __FUNCTION__, __LINE__, strerror(errno)); return 0; } - DBG ("[libtbm-sprd:%d] %s DMABUF_IOCTL_PUT_FENCE! flink_id=%d dmabuf=%d\n", + DBG("[libtbm-sprd:%d] %s DMABUF_IOCTL_PUT_FENCE! flink_id=%d dmabuf=%d\n", getpid(), __FUNCTION__, bo_sprd->name, bo_sprd->dmabuf); } else { ret = _tgl_unlock(bufmgr_sprd->tgl_fd, bo_sprd->name); - DBG ("[libtbm-sprd:%d] unlock tgl flink_id:%d\n", + DBG("[libtbm-sprd:%d] unlock tgl flink_id:%d\n", getpid(), __FUNCTION__, bo_sprd->name); return ret; @@ -1551,9 +1546,9 @@ tbm_sprd_bo_unlock(tbm_bo bo) } static void -tbm_sprd_bufmgr_deinit (void *priv) +tbm_sprd_bufmgr_deinit(void *priv) { - SPRD_RETURN_IF_FAIL (priv != NULL); + SPRD_RETURN_IF_FAIL(priv != NULL); tbm_bufmgr_sprd bufmgr_sprd; @@ -1564,11 +1559,11 @@ tbm_sprd_bufmgr_deinit (void *priv) void *value; while (drmHashFirst(bufmgr_sprd->hashBos, &key, &value) > 0) { - free (value); - drmHashDelete (bufmgr_sprd->hashBos, key); + free(value); + drmHashDelete(bufmgr_sprd->hashBos, key); } - drmHashDestroy (bufmgr_sprd->hashBos); + drmHashDestroy(bufmgr_sprd->hashBos); bufmgr_sprd->hashBos = NULL; } @@ -1583,9 +1578,9 @@ tbm_sprd_bufmgr_deinit (void *priv) _bufmgr_deinit_cache_state(bufmgr_sprd); - close (bufmgr_sprd->fd); + close(bufmgr_sprd->fd); - free (bufmgr_sprd); + free(bufmgr_sprd); } int @@ -1593,14 +1588,14 @@ tbm_sprd_surface_supported_format(uint32_t **formats, uint32_t *num) { uint32_t *color_formats = NULL; - color_formats = (uint32_t *)calloc (1, + color_formats = (uint32_t *)calloc(1, sizeof(uint32_t) * TBM_COLOR_FORMAT_COUNT); - if ( color_formats == NULL ) { + if (color_formats == NULL) return 0; - } - memcpy( color_formats, tbm_sprd_color_format_list , - sizeof(uint32_t)*TBM_COLOR_FORMAT_COUNT ); + + memcpy(color_formats, tbm_sprd_color_format_list, + sizeof(uint32_t)*TBM_COLOR_FORMAT_COUNT); *formats = color_formats; @@ -1711,13 +1706,13 @@ tbm_sprd_surface_get_plane_data(int width, int height, bpp = 12; if (plane_idx == 0) { _offset = 0; - _pitch = SIZE_ALIGN( width , TBM_SURFACE_ALIGNMENT_PITCH_YUV); + _pitch = SIZE_ALIGN(width , TBM_SURFACE_ALIGNMENT_PITCH_YUV); _align_height = SIZE_ALIGN(height, TBM_SURFACE_ALIGNMENT_PITCH_YUV); _size = SIZE_ALIGN(_pitch * _align_height, TBM_SURFACE_ALIGNMENT_PLANE); _bo_idx = 0; - } else if ( plane_idx == 1 ) { + } else if (plane_idx == 1) { _offset = width * height; - _pitch = SIZE_ALIGN( width , TBM_SURFACE_ALIGNMENT_PITCH_YUV / 2); + _pitch = SIZE_ALIGN(width , TBM_SURFACE_ALIGNMENT_PITCH_YUV / 2); _align_height = SIZE_ALIGN(height / 2, TBM_SURFACE_ALIGNMENT_PITCH_YUV); _size = SIZE_ALIGN(_pitch * _align_height, TBM_SURFACE_ALIGNMENT_PLANE); _bo_idx = 0; @@ -1865,20 +1860,20 @@ tbm_sprd_surface_get_plane_data(int width, int height, } int -tbm_sprd_bo_get_flags (tbm_bo bo) +tbm_sprd_bo_get_flags(tbm_bo bo) { - SPRD_RETURN_VAL_IF_FAIL (bo != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bo != NULL, 0); tbm_bo_sprd bo_sprd; bo_sprd = (tbm_bo_sprd)tbm_backend_get_bo_priv(bo); - SPRD_RETURN_VAL_IF_FAIL (bo_sprd != NULL, 0); + SPRD_RETURN_VAL_IF_FAIL(bo_sprd != NULL, 0); return bo_sprd->flags_tbm; } int -tbm_sprd_bufmgr_bind_native_display (tbm_bufmgr bufmgr, void *NativeDisplay) +tbm_sprd_bufmgr_bind_native_display(tbm_bufmgr bufmgr, void *NativeDisplay) { tbm_bufmgr_sprd bufmgr_sprd; @@ -1896,7 +1891,7 @@ tbm_sprd_bufmgr_bind_native_display (tbm_bufmgr bufmgr, void *NativeDisplay) return 1; } -MODULEINITPPROTO (init_tbm_bufmgr_priv); +MODULEINITPPROTO(init_tbm_bufmgr_priv); static TBMModuleVersionInfo SprdVersRec = { "sprd", @@ -1907,7 +1902,7 @@ static TBMModuleVersionInfo SprdVersRec = { TBMModuleData tbmModuleData = { &SprdVersRec, init_tbm_bufmgr_priv}; int -init_tbm_bufmgr_priv (tbm_bufmgr bufmgr, int fd) +init_tbm_bufmgr_priv(tbm_bufmgr bufmgr, int fd) { tbm_bufmgr_sprd bufmgr_sprd; tbm_bufmgr_backend bufmgr_backend; @@ -1915,9 +1910,9 @@ init_tbm_bufmgr_priv (tbm_bufmgr bufmgr, int fd) if (!bufmgr) return 0; - bufmgr_sprd = calloc (1, sizeof(struct _tbm_bufmgr_sprd)); + bufmgr_sprd = calloc(1, sizeof(struct _tbm_bufmgr_sprd)); if (!bufmgr_sprd) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] error: Fail to alloc bufmgr_sprd!\n", getpid()); + TBM_SPRD_LOG("[libtbm-sprd:%d] error: Fail to alloc bufmgr_sprd!\n", getpid()); return 0; } @@ -1929,8 +1924,8 @@ init_tbm_bufmgr_priv (tbm_bufmgr bufmgr, int fd) bufmgr_sprd->fd = _tbm_sprd_open_drm(); if (bufmgr_sprd->fd < 0) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] error: Fail to create drm!\n", getpid()); - free (bufmgr_sprd); + TBM_SPRD_LOG("[libtbm-sprd:%d] error: Fail to create drm!\n", getpid()); + free(bufmgr_sprd); return 0; } @@ -1938,25 +1933,24 @@ init_tbm_bufmgr_priv (tbm_bufmgr bufmgr, int fd) bufmgr_sprd->device_name = drmGetDeviceNameFromFd(bufmgr_sprd->fd); - if (!bufmgr_sprd->device_name) - { - TBM_SPRD_LOG ("[libtbm-sprd:%d] error: Fail to get device name!\n", getpid()); + if (!bufmgr_sprd->device_name) { + TBM_SPRD_LOG("[libtbm-sprd:%d] error: Fail to get device name!\n", getpid()); tbm_drm_helper_unset_tbm_master_fd(); close(bufmgr_sprd->fd); - free (bufmgr_sprd); + free(bufmgr_sprd); return 0; } } else { if (!tbm_drm_helper_get_auth_info(&(bufmgr_sprd->fd), &(bufmgr_sprd->device_name), NULL)) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] error: Fail to get auth drm info!\n", getpid()); - free (bufmgr_sprd); + TBM_SPRD_LOG("[libtbm-sprd:%d] error: Fail to get auth drm info!\n", getpid()); + free(bufmgr_sprd); return 0; } } //Create Hash Table - bufmgr_sprd->hashBos = drmHashCreate (); + bufmgr_sprd->hashBos = drmHashCreate(); //Check if the tbm manager supports dma fence or not. int fp = open("/sys/module/dmabuf_sync/parameters/enabled", O_RDONLY); @@ -1972,7 +1966,7 @@ init_tbm_bufmgr_priv (tbm_bufmgr bufmgr, int fd) } if (!_bufmgr_init_cache_state(bufmgr_sprd)) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] error: init bufmgr cache state failed!\n", getpid()); + TBM_SPRD_LOG("[libtbm-sprd:%d] error: init bufmgr cache state failed!\n", getpid()); if (tbm_backend_is_display_server()) tbm_drm_helper_unset_tbm_master_fd(); @@ -1985,7 +1979,7 @@ init_tbm_bufmgr_priv (tbm_bufmgr bufmgr, int fd) bufmgr_backend = tbm_backend_alloc(); if (!bufmgr_backend) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] error: Fail to create drm!\n", getpid()); + TBM_SPRD_LOG("[libtbm-sprd:%d] error: Fail to create drm!\n", getpid()); _bufmgr_deinit_cache_state(bufmgr_sprd); @@ -1994,7 +1988,7 @@ init_tbm_bufmgr_priv (tbm_bufmgr bufmgr, int fd) close(bufmgr_sprd->fd); - free (bufmgr_sprd); + free(bufmgr_sprd); return 0; } @@ -2017,9 +2011,9 @@ init_tbm_bufmgr_priv (tbm_bufmgr bufmgr, int fd) bufmgr_backend->bo_unlock = tbm_sprd_bo_unlock; bufmgr_backend->bufmgr_bind_native_display = tbm_sprd_bufmgr_bind_native_display; - if (!tbm_backend_init (bufmgr, bufmgr_backend)) { - TBM_SPRD_LOG ("[libtbm-sprd:%d] error: Fail to init backend!\n", getpid()); - tbm_backend_free (bufmgr_backend); + if (!tbm_backend_init(bufmgr, bufmgr_backend)) { + TBM_SPRD_LOG("[libtbm-sprd:%d] error: Fail to init backend!\n", getpid()); + tbm_backend_free(bufmgr_backend); _bufmgr_deinit_cache_state(bufmgr_sprd); @@ -2028,27 +2022,27 @@ init_tbm_bufmgr_priv (tbm_bufmgr bufmgr, int fd) close(bufmgr_sprd->fd); - free (bufmgr_sprd); + free(bufmgr_sprd); return 0; } #ifdef DEBUG { char *env; - env = getenv ("TBM_SPRD_DEBUG"); + env = getenv("TBM_SPRD_DEBUG"); if (env) { - bDebug = atoi (env); - TBM_SPRD_LOG ("TBM_SPRD_DEBUG=%s\n", env); + bDebug = atoi(env); + TBM_SPRD_LOG("TBM_SPRD_DEBUG=%s\n", env); } else { bDebug = 0; } } #endif - DBG ("[libtbm-sprd:%d] %s DMABUF FENCE is %s\n", getpid(), + DBG("[libtbm-sprd:%d] %s DMABUF FENCE is %s\n", getpid(), __FUNCTION__, bufmgr_sprd->use_dma_fence ? "supported!" : "NOT supported!"); - DBG ("[libtbm-sprd:%d] %s fd:%d\n", getpid(), + DBG("[libtbm-sprd:%d] %s fd:%d\n", getpid(), __FUNCTION__, bufmgr_sprd->fd); return 1; -- 2.7.4