From a930aaedf1ebb22e5e5c8391eb7850f1089f6c63 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Thu, 24 Mar 2016 20:44:40 +0900 Subject: [PATCH] Remove code for 1.0 version backend Change-Id: I6da29f73a21aea13cff91791107fdc001e21f428 Signed-off-by: Changyeon Lee --- src/tbm_bufmgr.c | 627 +++------------------------------------------ src/tbm_bufmgr.h | 13 - src/tbm_bufmgr_backend.c | 15 -- src/tbm_bufmgr_backend.h | 97 +------ src/tbm_bufmgr_int.h | 41 --- src/tbm_bufmgr_tgl.h | 70 ----- src/tbm_surface_internal.c | 11 +- 7 files changed, 42 insertions(+), 832 deletions(-) delete mode 100644 src/tbm_bufmgr_tgl.h diff --git a/src/tbm_bufmgr.c b/src/tbm_bufmgr.c index 8a7b32d..981d50e 100644 --- a/src/tbm_bufmgr.c +++ b/src/tbm_bufmgr.c @@ -34,7 +34,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "tbm_bufmgr.h" #include "tbm_bufmgr_int.h" #include "tbm_bufmgr_backend.h" -#include "tbm_bufmgr_tgl.h" #include "list.h" #define DEBUG @@ -51,19 +50,6 @@ int bDebug; #define SUFFIX_LIB ".so" #define DEFAULT_LIB PREFIX_LIB"default"SUFFIX_LIB -/* unneeded version 2.0 */ -#define BO_IS_CACHEABLE(bo) ((bo->flags & TBM_BO_NONCACHABLE) ? 0 : 1) -#define DEVICE_IS_CACHE_AWARE(device) ((device == TBM_DEVICE_CPU) ? (1) : (0)) - -/* tgl key values */ -#define GLOBAL_KEY ((unsigned int)(-1)) -#define INITIAL_KEY ((unsigned int)(-2)) - -#define CACHE_OP_CREATE (-1) -#define CACHE_OP_ATTACH (-2) -#define CACHE_OP_IMPORT (-3) -/* unneeded version 2.0 */ - /* values to indicate unspecified fields in XF86ModReqInfo. */ #define MAJOR_UNSPEC 0xFF #define MINOR_UNSPEC 0xFF @@ -82,14 +68,6 @@ enum { LOCK_TRY_NEVER }; -/* unneeded version 2.0 */ -enum { - DEVICE_NONE = 0, - DEVICE_CA, /* cache aware device */ - DEVICE_CO /* cache oblivious device */ -}; -/* unneeded version 2.0 */ - pthread_mutex_t gLock = PTHREAD_MUTEX_INITIALIZER; tbm_bufmgr gBufMgr; @@ -153,116 +131,6 @@ _tbm_util_get_appname_from_pid(long pid, char *str) snprintf(str, sizeof(cmdline), "%s", cmdline); } - -/* unneeded version 2.0 */ -static inline int -_tgl_init(int fd, unsigned int key) -{ - struct tgl_attribute attr; - int err; - - attr.key = key; - attr.timeout_ms = 1000; - - err = ioctl(fd, TGL_IOC_INIT_LOCK, &attr); - if (err) { - TBM_LOG("[libtbm:%d] error(%s) %s:%d key:%d\n", - getpid(), strerror(errno), __func__, __LINE__, key); - return 0; - } - - return 1; -} - -static inline int -_tgl_destroy(int fd, unsigned int key) -{ - int err; - - err = ioctl(fd, TGL_IOC_DESTROY_LOCK, key); - if (err) { - TBM_LOG("[libtbm:%d] " - "error(%s) %s:%d key:%d\n", - getpid(), strerror(errno), __func__, __LINE__, key); - return 0; - } - - return 1; -} - -static inline int -_tgl_lock(int fd, unsigned int key) -{ - int err; - - err = ioctl(fd, TGL_IOC_LOCK_LOCK, key); - if (err) { - TBM_LOG("[libtbm:%d] " - "error(%s) %s:%d key:%d\n", - getpid(), strerror(errno), __func__, __LINE__, key); - return 0; - } - - return 1; -} - -static inline int -_tgl_unlock(int fd, unsigned int key) -{ - int err; - - err = ioctl(fd, TGL_IOC_UNLOCK_LOCK, key); - if (err) { - TBM_LOG("[libtbm:%d] " - "error(%s) %s:%d key:%d\n", - getpid(), strerror(errno), __func__, __LINE__, key); - return 0; - } - - return 1; -} - -static inline int -_tgl_set_data(int fd, unsigned int key, unsigned int val) -{ - int err; - struct tgl_user_data arg; - - arg.key = key; - arg.data1 = val; - err = ioctl(fd, TGL_IOC_SET_DATA, &arg); - if (err) { - TBM_LOG("[libtbm:%d] " - "error(%s) %s:%d key:%d\n", - getpid(), strerror(errno), __func__, __LINE__, key); - return 0; - } - - return 1; -} - -static inline unsigned int -_tgl_get_data(int fd, unsigned int key, unsigned int *locked) -{ - int err; - struct tgl_user_data arg = { 0, }; - - arg.key = key; - err = ioctl(fd, TGL_IOC_GET_DATA, &arg); - if (err) { - TBM_LOG("[libtbm:%d] " - "error(%s) %s:%d key:%d\n", - getpid(), strerror(errno), __func__, __LINE__, key); - return 0; - } - - if (locked) - *locked = arg.locked; - - return arg.data1; -} -/* unneeded version 2.0 */ - tbm_user_data *user_data_lookup(struct list_head *user_data_list, unsigned long key) { @@ -314,35 +182,10 @@ _bo_lock(tbm_bo bo, int device, int opt) tbm_bufmgr bufmgr = bo->bufmgr; int ret = 0; - if (bufmgr->use_2_0) { - if (bufmgr->backend->bo_lock2) { - /* use bo_lock2 backend lock */ - ret = bufmgr->backend->bo_lock2(bo, device, opt); - } else if (bufmgr->backend->bo_lock) { - /* use bo_lock backend lock */ - ret = bufmgr->backend->bo_lock(bo); - } else { - TBM_LOG("[libtbm:%d] " - "error %s:%d no backend lock functions\n", - getpid(), __func__, __LINE__); - } + if (bufmgr->backend->bo_lock) { + ret = bufmgr->backend->bo_lock(bo, device, opt); } else { - if (TBM_LOCK_CTRL_BACKEND_VALID(bufmgr->backend->flags)) { - if (bufmgr->backend->bo_lock2) { - /* use bo_lock2 backend lock */ - ret = bufmgr->backend->bo_lock2(bo, device, opt); - } else if (bufmgr->backend->bo_lock) { - /* use bo_lock backend lock */ - ret = bufmgr->backend->bo_lock(bo); - } else { - TBM_LOG("[libtbm:%d] " - "error %s:%d no backend lock functions\n", - getpid(), __func__, __LINE__); - } - } else { - /* use tizen global lock */ - ret = _tgl_lock(bufmgr->lock_fd, bo->tgl_key); - } + ret = 1; } return ret; @@ -353,159 +196,9 @@ _bo_unlock(tbm_bo bo) { tbm_bufmgr bufmgr = bo->bufmgr; - if (bufmgr->use_2_0) { - if (bufmgr->backend->bo_unlock) { - /* use backend unlock */ - bufmgr->backend->bo_unlock(bo); - } else { - TBM_LOG("[libtbm:%d] " - "error %s:%d no backend unlock functions\n", - getpid(), __func__, __LINE__); - } - } else { - if (TBM_LOCK_CTRL_BACKEND_VALID(bufmgr->backend->flags)) { - if (bufmgr->backend->bo_unlock) { - /* use backend unlock */ - bufmgr->backend->bo_unlock(bo); - } else { - TBM_LOG("[libtbm:%d] " - "error %s:%d no backend unlock functions\n", - getpid(), __func__, __LINE__); - } - } else { - /* use tizen global unlock */ - _tgl_unlock(bufmgr->lock_fd, bo->tgl_key); - } - } -} - -static int -_tbm_bo_init_state(tbm_bo bo, int opt) -{ - tbm_bufmgr bufmgr = bo->bufmgr; - tbm_bo_cache_state cache_state; - - if (bo->tgl_key == INITIAL_KEY) - bo->tgl_key = bufmgr->backend->bo_get_global_key(bo); - - if (!bo->default_handle.u32) - bo->default_handle = bufmgr->backend->bo_get_handle(bo, TBM_DEVICE_DEFAULT); - - RETURN_VAL_CHECK_FLAG(TBM_ALL_CTRL_BACKEND_VALID(bufmgr->backend->flags), 1); - - cache_state.val = 0; - switch (opt) { - case CACHE_OP_CREATE: /*Create */ - - _tgl_init(bufmgr->lock_fd, bo->tgl_key); - - cache_state.data.isCacheable = BO_IS_CACHEABLE(bo); - cache_state.data.isDirtied = DEVICE_NONE; - cache_state.data.isCached = 0; - cache_state.data.cntFlush = 0; - - _tgl_set_data(bufmgr->lock_fd, bo->tgl_key, cache_state.val); - break; - case CACHE_OP_IMPORT: /*Import */ - - _tgl_init(bufmgr->lock_fd, bo->tgl_key); - break; - default: - break; - } - - return 1; -} - -static void -_tbm_bo_destroy_state(tbm_bo bo) -{ - tbm_bufmgr bufmgr = bo->bufmgr; - - RETURN_CHECK_FLAG(TBM_ALL_CTRL_BACKEND_VALID(bufmgr->backend->flags)); - - _tgl_destroy(bufmgr->lock_fd, bo->tgl_key); -} - -static int -_tbm_bo_set_state(tbm_bo bo, int device, int opt) -{ - tbm_bufmgr bufmgr = bo->bufmgr; - char need_flush = 0; - unsigned short cntFlush = 0; - unsigned int is_locked; - - RETURN_VAL_CHECK_FLAG(TBM_CACHE_CTRL_BACKEND_VALID(bufmgr->backend->flags), 1); - - /* get cache state of a bo */ - bo->cache_state.val = _tgl_get_data(bufmgr->lock_fd, bo->tgl_key, &is_locked); - - if (!bo->cache_state.data.isCacheable) - return 1; - - /* get global cache flush count */ - cntFlush = (unsigned short)_tgl_get_data(bufmgr->lock_fd, GLOBAL_KEY, NULL); - - if (DEVICE_IS_CACHE_AWARE(device)) { - if (bo->cache_state.data.isDirtied == DEVICE_CO && - bo->cache_state.data.isCached) - need_flush = TBM_CACHE_INV; - - bo->cache_state.data.isCached = 1; - if (opt & TBM_OPTION_WRITE) - bo->cache_state.data.isDirtied = DEVICE_CA; - else { - if (bo->cache_state.data.isDirtied != DEVICE_CA) - bo->cache_state.data.isDirtied = DEVICE_NONE; - } - } else { - if (bo->cache_state.data.isDirtied == DEVICE_CA && - bo->cache_state.data.isCached && - bo->cache_state.data.cntFlush == cntFlush) - need_flush = TBM_CACHE_CLN | TBM_CACHE_ALL; - - if (opt & TBM_OPTION_WRITE) - bo->cache_state.data.isDirtied = DEVICE_CO; - else { - if (bo->cache_state.data.isDirtied != DEVICE_CO) - bo->cache_state.data.isDirtied = DEVICE_NONE; - } + if (bufmgr->backend->bo_unlock) { + bufmgr->backend->bo_unlock(bo); } - - if (need_flush) { - /* set global cache flush count */ - if (need_flush & TBM_CACHE_ALL) - _tgl_set_data(bufmgr->lock_fd, GLOBAL_KEY, (unsigned int)(++cntFlush)); - - /* call backend cache flush */ - bufmgr->backend->bo_cache_flush(bo, need_flush); - - DBG("[libtbm:%d] \tcache(%d,%d,%d)....flush:0x%x, cntFlush(%d)\n", - getpid(), - bo->cache_state.data.isCacheable, - bo->cache_state.data.isCached, - bo->cache_state.data.isDirtied, - need_flush, - cntFlush); - } - - return 1; -} - -static void -_tbm_bo_save_state(tbm_bo bo) -{ - tbm_bufmgr bufmgr = bo->bufmgr; - unsigned short cntFlush = 0; - - RETURN_CHECK_FLAG(TBM_CACHE_CTRL_BACKEND_VALID(bufmgr->backend->flags)); - - /* get global cache flush count */ - cntFlush = (unsigned short)_tgl_get_data(bufmgr->lock_fd, GLOBAL_KEY, NULL); - - /* save global cache flush count */ - bo->cache_state.data.cntFlush = cntFlush; - _tgl_set_data(bufmgr->lock_fd, bo->tgl_key, bo->cache_state.val); } static int @@ -526,8 +219,8 @@ _tbm_bo_lock(tbm_bo bo, int device, int opt) if (bo->lock_cnt < 0) { TBM_LOG("[libtbm:%d] " - "error %s:%d bo:%p(%d) LOCK_CNT=%d\n", - getpid(), __func__, __LINE__, bo, bo->tgl_key, bo->lock_cnt); + "error %s:%d bo:%p LOCK_CNT=%d\n", + getpid(), __func__, __LINE__, bo, bo->lock_cnt); } old = bo->lock_cnt; @@ -552,8 +245,8 @@ _tbm_bo_lock(tbm_bo bo, int device, int opt) getpid(), __func__, __LINE__, bo); } - DBG_LOCK("[libtbm:%d] >> LOCK bo:%p(%d, %d->%d)\n", getpid(), - bo, bo->tgl_key, old, bo->lock_cnt); + DBG_LOCK("[libtbm:%d] >> LOCK bo:%p(%d->%d)\n", getpid(), + bo, old, bo->lock_cnt); return ret; } @@ -595,8 +288,8 @@ _tbm_bo_unlock(tbm_bo bo) if (bo->lock_cnt < 0) bo->lock_cnt = 0; - DBG_LOCK("[libtbm:%d] << unlock bo:%p(%d, %d->%d)\n", getpid(), - bo, bo->tgl_key, old, bo->lock_cnt); + DBG_LOCK("[libtbm:%d] << unlock bo:%p(%d->%d)\n", getpid(), + bo, old, bo->lock_cnt); } static int @@ -650,11 +343,6 @@ _tbm_bo_unref(tbm_bo bo) _bo_unlock(bo); } - if (!bufmgr->use_2_0) { - /* Destroy Global Lock */ - _tbm_bo_destroy_state(bo); - } - /* call the bo_free */ bufmgr->backend->bo_free(bo); bo->priv = NULL; @@ -667,42 +355,6 @@ _tbm_bo_unref(tbm_bo bo) } static int -_tbm_bufmgr_init_state(tbm_bufmgr bufmgr) -{ - RETURN_VAL_CHECK_FLAG(TBM_ALL_CTRL_BACKEND_VALID(bufmgr->backend->flags), 1); - - bufmgr->lock_fd = open(tgl_devfile, O_RDWR); - - if (bufmgr->lock_fd < 0) { - bufmgr->lock_fd = open(tgl_devfile1, O_RDWR); - if (bufmgr->lock_fd < 0) { - - TBM_LOG("[libtbm:%d] " - "error: Fail to open global_lock:%s\n", - getpid(), tgl_devfile); - return 0; - } - } - - if (!_tgl_init(bufmgr->lock_fd, GLOBAL_KEY)) { - TBM_LOG("[libtbm:%d] " - "error: Fail to initialize the tgl\n", - getpid()); - return 0; - } - - return 1; -} - -static void -_tbm_bufmgr_destroy_state(tbm_bufmgr bufmgr) -{ - RETURN_CHECK_FLAG(TBM_ALL_CTRL_BACKEND_VALID(bufmgr->backend->flags)); - - close(bufmgr->lock_fd); -} - -static int _check_version(TBMModuleVersionInfo *data) { int abimaj, abimin; @@ -854,8 +506,6 @@ tbm_bufmgr tbm_bufmgr_init(int fd) { char *env; - int fd_flag = 0; - int backend_flag = 0; pthread_mutex_lock(&gLock); @@ -871,20 +521,6 @@ tbm_bufmgr_init(int fd) /* initialize buffer manager */ if (gBufMgr) { - DBG("[libtbm:%d] use previous gBufMgr\n", getpid()); - if (!gBufMgr->fd_flag) { - if (fd >= 0) { - if (dup2(gBufMgr->fd, fd) < 0) { - _tbm_set_last_result(TBM_BO_ERROR_DUP_FD_FAILED); - TBM_LOG("[libtbm:%d] Fail to duplicate(dup2) the drm fd\n", - getpid()); - pthread_mutex_unlock(&gLock); - return NULL; - } - DBG("[libtbm:%d] duplicate the drm_fd(%d), new drm_fd(%d).\n", - getpid(), gBufMgr->fd, fd); - } - } gBufMgr->ref_count++; DBG("[libtbm:%d] bufmgr ref: fd=%d, ref_count:%d\n", @@ -893,10 +529,7 @@ tbm_bufmgr_init(int fd) return gBufMgr; } - if (fd < 0) - fd_flag = 1; - - DBG("[libtbm:%d] bufmgr init: fd=%d\n", getpid(), fd); + DBG("[libtbm:%d] bufmgr init\n", getpid()); /* allocate bufmgr */ gBufMgr = calloc(1, sizeof(struct _tbm_bufmgr)); @@ -906,61 +539,22 @@ tbm_bufmgr_init(int fd) return NULL; } - gBufMgr->fd_flag = fd_flag; - - if (fd_flag) { - gBufMgr->fd = -1; - } else { - gBufMgr->fd = dup(fd); - if (gBufMgr->fd < 0) { - _tbm_set_last_result(TBM_BO_ERROR_DUP_FD_FAILED); - TBM_LOG("[libtbm:%d] Fail to duplicate(dup) the drm fd\n", - getpid()); - free(gBufMgr); - gBufMgr = NULL; - pthread_mutex_unlock(&gLock); - return NULL; - } - DBG("[libtbm:%d] duplicate the drm_fd(%d), bufmgr use fd(%d).\n", - getpid(), fd, gBufMgr->fd); - } + gBufMgr->fd = fd; /* load bufmgr priv from env */ if (!_tbm_load_module(gBufMgr, gBufMgr->fd)) { _tbm_set_last_result(TBM_BO_ERROR_LOAD_MODULE_FAILED); TBM_LOG("[libtbm:%d] error : Fail to load bufmgr backend\n", getpid()); - if (gBufMgr->fd > 0) - close(gBufMgr->fd); - free(gBufMgr); gBufMgr = NULL; pthread_mutex_unlock(&gLock); return NULL; } - backend_flag = gBufMgr->backend->flags; /* log for tbm backend_flag */ DBG("[libtbm:%d] ", getpid()); - DBG("cache_crtl:"); - if (backend_flag & TBM_CACHE_CTRL_BACKEND) { - DBG("BACKEND "); - } else { - DBG("TBM "); - } - - DBG("lock_crtl:"); - if (backend_flag & TBM_LOCK_CTRL_BACKEND) { - DBG("BACKEND "); - } else { - DBG("TBM "); - } - - if (backend_flag & TBM_USE_2_0_BACKEND) { - gBufMgr->use_2_0 = 1; - DBG("USE 2.0 backend"); - } - + DBG("backend flag:%x:", gBufMgr->backend->flags); DBG("\n"); gBufMgr->ref_count = 1; @@ -973,45 +567,12 @@ tbm_bufmgr_init(int fd) gBufMgr->backend->bufmgr_deinit(gBufMgr->backend->priv); tbm_backend_free(gBufMgr->backend); dlclose(gBufMgr->module_data); - - if (gBufMgr->fd > 0) - close(gBufMgr->fd); - free(gBufMgr); gBufMgr = NULL; pthread_mutex_unlock(&gLock); return NULL; } - if (!gBufMgr->use_2_0) { - /* intialize the tizen global status */ - if (!_tbm_bufmgr_init_state(gBufMgr)) { - _tbm_set_last_result(TBM_BO_ERROR_INIT_STATE_FAILED); - TBM_LOG("[libtbm:%d] error: Fail to init state\n", getpid()); - gBufMgr->backend->bufmgr_deinit(gBufMgr->backend->priv); - tbm_backend_free(gBufMgr->backend); - pthread_mutex_destroy(&gBufMgr->lock); - dlclose(gBufMgr->module_data); - - if (gBufMgr->fd > 0) - close(gBufMgr->fd); - - free(gBufMgr); - gBufMgr = NULL; - pthread_mutex_unlock(&gLock); - return NULL; - } - - /* setup the map_cache */ - env = getenv("BUFMGR_MAP_CACHE"); - if (env && !strcmp(env, "false")) - gBufMgr->use_map_cache = 0; - else - gBufMgr->use_map_cache = 1; - DBG("[libtbm:%d] BUFMGR_MAP_CACHE=%s\n", - getpid(), env ? env : "default:true"); - } - /* setup the lock_type */ env = getenv("BUFMGR_LOCK_TYPE"); if (env && !strcmp(env, "always")) @@ -1079,11 +640,6 @@ tbm_bufmgr_deinit(tbm_bufmgr bufmgr) } } - if (!bufmgr->use_2_0) { - /* destroy the tizen global status */ - _tbm_bufmgr_destroy_state(bufmgr); - } - /* destroy bufmgr priv */ bufmgr->backend->bufmgr_deinit(bufmgr->backend->priv); bufmgr->backend->priv = NULL; @@ -1185,19 +741,6 @@ tbm_bo_alloc(tbm_bufmgr bufmgr, int size, int flags) bo->flags = flags; bo->priv = bo_priv; - if (!bufmgr->use_2_0) { - bo->tgl_key = INITIAL_KEY; - bo->default_handle.u32 = 0; - - /* init bo state */ - if (!_tbm_bo_init_state(bo, CACHE_OP_CREATE)) { - _tbm_set_last_result(TBM_BO_ERROR_INIT_STATE_FAILED); - _tbm_bo_unref(bo); - pthread_mutex_unlock(&bufmgr->lock); - return NULL; - } - } - LIST_INITHEAD(&bo->user_data_list); LIST_ADD(&bo->item_link, &bufmgr->bo_list); @@ -1219,23 +762,6 @@ tbm_bo_import(tbm_bufmgr bufmgr, unsigned int key) pthread_mutex_lock(&bufmgr->lock); - if (!bufmgr->use_2_0) { - /* find bo in list */ - if (!LIST_IS_EMPTY(&bufmgr->bo_list)) { - LIST_FOR_EACH_ENTRY_SAFE(bo2, tmp, &bufmgr->bo_list, item_link) { - if (bo2->tgl_key == key) { - DBG("[libtbm:%d] " - "find bo(%p, ref:%d key:%d) in list\n", - getpid(), bo2, bo2->ref_cnt, bo2->tgl_key); - - bo2->ref_cnt++; - pthread_mutex_unlock(&bufmgr->lock); - return bo2; - } - } - } - } - bo = calloc(1, sizeof(struct _tbm_bo)); if (!bo) { pthread_mutex_unlock(&bufmgr->lock); @@ -1252,19 +778,17 @@ tbm_bo_import(tbm_bufmgr bufmgr, unsigned int key) return NULL; } - if (bufmgr->use_2_0) { - if (!LIST_IS_EMPTY(&bufmgr->bo_list)) { - LIST_FOR_EACH_ENTRY_SAFE(bo2, tmp, &bufmgr->bo_list, item_link) { - if (bo2->priv == bo_priv) { - DBG("[libtbm:%d] " - "find bo(%p, ref:%d key:%d) in list\n", - getpid(), bo2, bo2->ref_cnt, bo2->tgl_key); - - bo2->ref_cnt++; - free(bo); - pthread_mutex_unlock(&bufmgr->lock); - return bo2; - } + if (!LIST_IS_EMPTY(&bufmgr->bo_list)) { + LIST_FOR_EACH_ENTRY_SAFE(bo2, tmp, &bufmgr->bo_list, item_link) { + if (bo2->priv == bo_priv) { + DBG("[libtbm:%d] " + "find bo(%p, ref:%d key:%d) in list\n", + getpid(), bo2, bo2->ref_cnt, key); + + bo2->ref_cnt++; + free(bo); + pthread_mutex_unlock(&bufmgr->lock); + return bo2; } } } @@ -1272,19 +796,6 @@ tbm_bo_import(tbm_bufmgr bufmgr, unsigned int key) bo->ref_cnt = 1; bo->priv = bo_priv; - if (!bufmgr->use_2_0) { - bo->tgl_key = INITIAL_KEY; - bo->default_handle.u32 = 0; - - /* init bo state */ - if (!_tbm_bo_init_state(bo, CACHE_OP_IMPORT)) { - _tbm_set_last_result(TBM_BO_ERROR_INIT_STATE_FAILED); - _tbm_bo_unref(bo); - pthread_mutex_unlock(&bufmgr->lock); - return NULL; - } - } - if (bufmgr->backend->bo_get_flags) bo->flags = bufmgr->backend->bo_get_flags(bo); else @@ -1308,29 +819,9 @@ tbm_bo_import_fd(tbm_bufmgr bufmgr, tbm_fd fd) tbm_bo bo2 = NULL; tbm_bo tmp = NULL; void *bo_priv = NULL; - tbm_bo_handle default_handle; pthread_mutex_lock(&bufmgr->lock); - if (!bufmgr->use_2_0) { - default_handle = bufmgr->backend->fd_to_handle(bufmgr, fd, TBM_DEVICE_DEFAULT); - - /* find bo in list */ - if (!LIST_IS_EMPTY(&bufmgr->bo_list)) { - LIST_FOR_EACH_ENTRY_SAFE(bo2, tmp, &bufmgr->bo_list, item_link) { - if (bo2->default_handle.u32 == default_handle.u32) { - DBG("[libtbm:%d] " - "find bo(%p, ref:%d handle:%d) in list\n", - getpid(), bo2, bo2->ref_cnt, bo2->default_handle.u32); - - bo2->ref_cnt++; - pthread_mutex_unlock(&bufmgr->lock); - return bo2; - } - } - } - } - bo = calloc(1, sizeof(struct _tbm_bo)); if (!bo) { pthread_mutex_unlock(&bufmgr->lock); @@ -1347,19 +838,17 @@ tbm_bo_import_fd(tbm_bufmgr bufmgr, tbm_fd fd) return NULL; } - if (bufmgr->use_2_0) { - if (!LIST_IS_EMPTY(&bufmgr->bo_list)) { - LIST_FOR_EACH_ENTRY_SAFE(bo2, tmp, &bufmgr->bo_list, item_link) { - if (bo2->priv == bo_priv) { - DBG("[libtbm:%d] " - "find bo(%p, ref:%d key:%d) in list\n", - getpid(), bo2, bo2->ref_cnt, bo2->tgl_key); - - bo2->ref_cnt++; - free(bo); - pthread_mutex_unlock(&bufmgr->lock); - return bo2; - } + if (!LIST_IS_EMPTY(&bufmgr->bo_list)) { + LIST_FOR_EACH_ENTRY_SAFE(bo2, tmp, &bufmgr->bo_list, item_link) { + if (bo2->priv == bo_priv) { + DBG("[libtbm:%d] " + "find bo(%p, ref:%d, fd:%d) in list\n", + getpid(), bo2, bo2->ref_cnt, fd); + + bo2->ref_cnt++; + free(bo); + pthread_mutex_unlock(&bufmgr->lock); + return bo2; } } } @@ -1367,19 +856,6 @@ tbm_bo_import_fd(tbm_bufmgr bufmgr, tbm_fd fd) bo->ref_cnt = 1; bo->priv = bo_priv; - if (!bufmgr->use_2_0) { - bo->tgl_key = INITIAL_KEY; - bo->default_handle.u32 = 0; - - /* init bo state */ - if (!_tbm_bo_init_state(bo, CACHE_OP_IMPORT)) { - _tbm_set_last_result(TBM_BO_ERROR_INIT_STATE_FAILED); - _tbm_bo_unref(bo); - pthread_mutex_unlock(&bufmgr->lock); - return NULL; - } - } - if (bufmgr->backend->bo_get_flags) bo->flags = bufmgr->backend->bo_get_flags(bo); else @@ -1493,11 +969,6 @@ tbm_bo_map(tbm_bo bo, int device, int opt) return (tbm_bo_handle) NULL; } - if (!bufmgr->use_2_0) { - if (bufmgr->use_map_cache == 1 && bo->map_cnt == 0) - _tbm_bo_set_state(bo, device, opt); - } - /* increase the map_count */ bo->map_cnt++; @@ -1529,11 +1000,6 @@ tbm_bo_unmap(tbm_bo bo) /* decrease the map_count */ bo->map_cnt--; - if (!bufmgr->use_2_0) { - if (bo->map_cnt == 0) - _tbm_bo_save_state(bo); - } - _tbm_bo_unlock(bo); pthread_mutex_unlock(&bufmgr->lock); @@ -1548,8 +1014,6 @@ tbm_bo_swap(tbm_bo bo1, tbm_bo bo2) TBM_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo2), 0); void *temp; - unsigned int tmp_key; - tbm_bo_handle tmp_defualt_handle; pthread_mutex_lock(&bo1->bufmgr->lock); @@ -1559,16 +1023,6 @@ tbm_bo_swap(tbm_bo bo1, tbm_bo bo2) return 0; } - if (!bo1->bufmgr->use_2_0) { - tmp_key = bo1->tgl_key; - bo1->tgl_key = bo2->tgl_key; - bo2->tgl_key = tmp_key; - - tmp_defualt_handle = bo1->default_handle; - bo1->default_handle = bo2->default_handle; - bo2->default_handle = tmp_defualt_handle; - } - temp = bo1->priv; bo1->priv = bo2->priv; bo2->priv = temp; @@ -1771,9 +1225,8 @@ tbm_bufmgr_debug_show(tbm_bufmgr bufmgr) app_name); for (i = 0; i < surf->num_bos; i++) { - TBM_DEBUG(" bo:%-12p(key:%2d) %-26d%-10d\n", + TBM_DEBUG(" bo:%-12p %-26d%-10d\n", surf->bos[i], - surf->bos[i]->tgl_key, surf->bos[i]->ref_cnt, tbm_bo_size(surf->bos[i]) / 1024); } @@ -1786,20 +1239,18 @@ tbm_bufmgr_debug_show(tbm_bufmgr bufmgr) TBM_DEBUG("\n"); TBM_DEBUG("[tbm_bo information]\n"); - TBM_DEBUG("no bo refcnt size lock_cnt map_cnt cache_state flags surface\n"); + TBM_DEBUG("no bo refcnt size lock_cnt map_cnt flags surface\n"); /* show the tbm_bo information in bo_list */ if (!LIST_IS_EMPTY(&bufmgr->bo_list)) { LIST_FOR_EACH_ENTRY_SAFE(bo, tmp_bo, &bufmgr->bo_list, item_link) { - TBM_DEBUG("%-4d%-11p(key:%2d) %-6d%-12d%-9d%-9d%-10d%-4d%-11p\n", + TBM_DEBUG("%-4d%-11p %-6d%-12d%-9d%-9d%-4d%-11p\n", ++bo_cnt, bo, - bo->tgl_key, bo->ref_cnt, tbm_bo_size(bo) / 1024, bo->lock_cnt, bo->map_cnt, - bo->cache_state.val, bo->flags, bo->surface); } diff --git a/src/tbm_bufmgr.h b/src/tbm_bufmgr.h index 1c3ff90..50fcf08 100644 --- a/src/tbm_bufmgr.h +++ b/src/tbm_bufmgr.h @@ -113,19 +113,6 @@ typedef int32_t tbm_fd; */ #define TBM_OPTION_VENDOR (0xffff0000) -/* unneeded version 2.0 */ -/** - * @brief Definition for the cache invalidate - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif - */ -#define TBM_CACHE_INV 0x01 -/** - * @brief Definition for the cache clean - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif - */ -#define TBM_CACHE_CLN 0x02 -/* unneeded version 2.0 */ - /** * @brief tbm_bo_handle abstraction of the memory handle by TBM_DEVICE_TYPE * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif diff --git a/src/tbm_bufmgr_backend.c b/src/tbm_bufmgr_backend.c index bcd6a06..65ef8c6 100644 --- a/src/tbm_bufmgr_backend.c +++ b/src/tbm_bufmgr_backend.c @@ -59,8 +59,6 @@ void tbm_backend_free(tbm_bufmgr_backend backend) int tbm_backend_init(tbm_bufmgr bufmgr, tbm_bufmgr_backend backend) { - int flags = 0; - if (!bufmgr) { TBM_LOG("[libtbm:%d] " "error (%s): fail to init tbm backend... bufmgr is null\n", getpid(), @@ -75,19 +73,6 @@ int tbm_backend_init(tbm_bufmgr bufmgr, tbm_bufmgr_backend backend) return 0; } - flags = backend->flags; - /* check the backend flags */ - if (!(flags & TBM_USE_2_0_BACKEND)) { - if (flags & TBM_CACHE_CTRL_BACKEND) { - if (!backend->bo_cache_flush) { - TBM_LOG("[libtbm:%d] " - "error (%s): TBM_FLAG_CACHE_CTRL_TBM needs backend->bo_cache_flush\n", getpid(), - __func__); - return 0; - } - } - } - bufmgr->backend = backend; return 1; diff --git a/src/tbm_bufmgr_backend.h b/src/tbm_bufmgr_backend.h index 722c4e3..1c967ac 100644 --- a/src/tbm_bufmgr_backend.h +++ b/src/tbm_bufmgr_backend.h @@ -63,28 +63,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define TBM_ABI_VERSION SET_ABI_VERSION(1, 1) /**< current abi vertion */ -/* unneeded version 2.0 */ -/* TBM_CACHE */ -#define TBM_CACHE_INV 0x01 /**< cache invalidate */ -#define TBM_CACHE_CLN 0x02 /**< cache clean */ -#define TBM_CACHE_ALL 0x10 /**< cache all */ -#define TBM_CACHE_FLUSH (TBM_CACHE_INV|TBM_CACHE_CLN) /**< cache flush */ -#define TBM_CACHE_FLUSH_ALL (TBM_CACHE_FLUSH|TBM_CACHE_ALL) /**< cache flush all */ - -/* TBM flag for cache control and lock control */ -/** - * TBM_CACHE_CTRL_BACKEND indicates that the backend control the cache coherency. - */ -#define TBM_CACHE_CTRL_BACKEND (1 << 0) - -/** - * TBM_LOCK_CTRL_BACKEND indicates that the backend control the lock of bos. - */ -#define TBM_LOCK_CTRL_BACKEND (1 << 1) -/* unneeded version 2.0 */ - -#define TBM_USE_2_0_BACKEND (1 << 2) - typedef struct _tbm_bufmgr_backend *tbm_bufmgr_backend; /** @@ -168,31 +146,6 @@ struct _tbm_bufmgr_backend { */ int (*bo_unmap)(tbm_bo bo); - /* version 2.0 dosen't need to backend function bo_cache_flush */ - /** - * @brief flush the cache of the buffer object. - * @param[in] bo : the buffer object - * @param[in] flags : the flags of cache flush type - * @return 1 if this function succeeds, otherwise 0. - */ - int (*bo_cache_flush)(tbm_bo bo, int flags); - - /* version 2.0 dosen't need to backend function bo_get_global_key */ - /** - * @brief get the global key associated with the buffer object. - * @param[in] bo : the buffer object - * @return global key associated with the buffer object. - */ - int (*bo_get_global_key)(tbm_bo bo); - - /** - * @brief lock the buffer object. - * @param[in] bo : the buffer object - * @return 1 if this function succeeds, otherwise 0. - * @remark This function pointer could be null. (default: use the tizen global lock) - */ - int (*bo_lock)(tbm_bo bo); - /** * @brief unlock the buffer object. * @param[in] bo : the buffer object @@ -209,7 +162,7 @@ struct _tbm_bufmgr_backend { * @return 1 if this function succeeds, otherwise 0. * @remark This function pointer could be null. (default: use the tizen global lock) */ - int (*bo_lock2)(tbm_bo bo, int device, int opt); + int (*bo_lock)(tbm_bo bo, int device, int opt); /** * @brief query the formats list and the num to be supported by backend. @@ -219,18 +172,6 @@ struct _tbm_bufmgr_backend { */ int (*surface_supported_format)(uint32_t **formats, uint32_t *num); - /* version 2.0 dosen't need to backend function surface get size*/ - /** - * @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 (*surface_get_size)(tbm_surface_h surface, int width, int height, - tbm_format format); - /** * @brief get the plane data of the surface. * @param[in] surface : the surface @@ -244,7 +185,7 @@ struct _tbm_bufmgr_backend { * @param[out] bo_idx : the bo index of the plane * @return 1 if this function succeeds, otherwise 0. */ - int (*surface_get_plane_data)(tbm_surface_h surface, int width, int height, + int (*surface_get_plane_data)(int width, int height, tbm_format format, int plane_idx, uint32_t *size, uint32_t *offset, uint32_t *pitch, int *bo_idx); @@ -269,24 +210,6 @@ struct _tbm_bufmgr_backend { */ tbm_fd (*bo_export_fd)(tbm_bo bo); - /* version 2.0 dosen't need to backend function fd_to_handle */ - /** - * @brief get the tbm_bo_handle according to the device type and the prime fd. - * @param[in] bufmgr : the tizen buffer manager - * @param[in] fd : the prime fd associated with the buffer object - * @param[in] device : the option to access the buffer object - * @return the handle of the buffer object - */ - tbm_bo_handle(*fd_to_handle)(tbm_bufmgr bufmgr, tbm_fd fd, int device); - - /* version 2.0 dosen't need to backend function surface_get_num_bos */ - /** - * @brief get the num of bos with a format. - * @param[in] format : the format of the surface - * @return num of the bos if this function succeeds, otherwise 0. - */ - int (*surface_get_num_bos)(tbm_format format); - /** * @brief get the tbm flags of memory type * @param[in] bo : the buffer object @@ -303,22 +226,6 @@ struct _tbm_bufmgr_backend { */ int (*bufmgr_bind_native_display)(tbm_bufmgr bufmgr, void *NativeDisplay); - /** - * @brief get the plane data of 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] bo_idx : the bo index of the plane - * @return 1 if this function succeeds, otherwise 0. - */ - int (*surface_get_plane_data2)(int width, int height, - tbm_format format, int plane_idx, uint32_t *size, uint32_t *offset, - uint32_t *pitch, int *bo_idx); - /* Padding for future extension */ void (*reserved1)(void); void (*reserved2)(void); diff --git a/src/tbm_bufmgr_int.h b/src/tbm_bufmgr_int.h index c3c3061..aa7ed81 100644 --- a/src/tbm_bufmgr_int.h +++ b/src/tbm_bufmgr_int.h @@ -96,28 +96,6 @@ struct list_head { struct list_head *next; }; -/* unneeded version 2.0 */ -#define TBM_ALL_CTRL_BACKEND_VALID(flags) \ - ((flags&TBM_CACHE_CTRL_BACKEND) &&\ - (flags&TBM_LOCK_CTRL_BACKEND)) -#define TBM_CACHE_CTRL_BACKEND_VALID(flags) \ - (flags&TBM_CACHE_CTRL_BACKEND) -#define TBM_LOCK_CTRL_BACKEND_VALID(flags) \ - (flags&TBM_LOCK_CTRL_BACKEND) - -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 isCacheable: 1; - unsigned int isCached: 1; - unsigned int isDirtied: 2; - } data; -}; -/* unneeded version 2.0 */ - /** * @brief tbm_bo : buffer object of Tizen Buffer Manager */ @@ -139,15 +117,6 @@ struct _tbm_bo { int lock_cnt; /* lock count of bo */ unsigned int map_cnt; /* device map count */ - - /* unneeded version 2.0 */ - tbm_bo_handle default_handle; /*default handle */ - - unsigned int tgl_key; /*global key for tizen global lock */ - - /* for cache control */ - tbm_bo_cache_state cache_state; /*cache state */ - /* unneeded version 2.0 */ }; /** @@ -170,16 +139,6 @@ struct _tbm_bufmgr { void *module_data; tbm_bufmgr_backend backend; /* bufmgr backend */ - - int use_2_0; - - /* unneeded version 2.0 */ - int lock_fd; /* fd of tizen global lock */ - - int fd_flag; /* flag set 1 when bufmgr fd open in tbm_bufmgr_init */ - - int use_map_cache; /* flag to use the map_cahce */ - /* unneeded version 2.0 */ }; /** diff --git a/src/tbm_bufmgr_tgl.h b/src/tbm_bufmgr_tgl.h deleted file mode 100644 index 2279cac..0000000 --- a/src/tbm_bufmgr_tgl.h +++ /dev/null @@ -1,70 +0,0 @@ -/************************************************************************** - * - * libtbm - * - * Copyright 2012 Samsung Electronics co., Ltd. All Rights Reserved. - * - * Contact: SooChan Lim , Sangjin Lee - * Boram Park , Changyeon Lee - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * **************************************************************************/ - -#ifndef __TBM_BUFMGR_TGL_H__ -#define __TBM_BUFMGR_TGL_H__ - -#include - -static char tgl_devfile[] = "/dev/slp_global_lock"; -static char tgl_devfile1[] = "/dev/tgl"; - -#define TGL_IOC_BASE 0x32 - -struct tgl_attribute { - unsigned int key; - unsigned int timeout_ms; -}; - -struct tgl_user_data { - unsigned int key; - unsigned int data1; - unsigned int data2; - unsigned int locked; -}; - -typedef enum { - _TGL_INIT_LOCK = 1, - _TGL_DESTROY_LOCK, - _TGL_LOCK_LOCK, - _TGL_UNLOCK_LOCK, - _TGL_SET_DATA, - _TGL_GET_DATA, -} _tgl_ioctls; - -#define TGL_IOC_INIT_LOCK _IOW(TGL_IOC_BASE, _TGL_INIT_LOCK, struct tgl_attribute *) -#define TGL_IOC_DESTROY_LOCK _IOW(TGL_IOC_BASE, _TGL_DESTROY_LOCK, unsigned int) -#define TGL_IOC_LOCK_LOCK _IOW(TGL_IOC_BASE, _TGL_LOCK_LOCK, unsigned int) -#define TGL_IOC_UNLOCK_LOCK _IOW(TGL_IOC_BASE, _TGL_UNLOCK_LOCK, unsigned int) -#define TGL_IOC_SET_DATA _IOW(TGL_IOC_BASE, _TGL_SET_DATA, struct tgl_user_data *) -#define TGL_IOC_GET_DATA _IOW(TGL_IOC_BASE, _TGL_GET_DATA, struct tgl_user_data *) - -#endif /* __TBM_BUFMGR_TGL_H__ */ diff --git a/src/tbm_surface_internal.c b/src/tbm_surface_internal.c index cedd9ca..49d4db6 100644 --- a/src/tbm_surface_internal.c +++ b/src/tbm_surface_internal.c @@ -230,19 +230,10 @@ _tbm_surface_internal_query_plane_data(tbm_surface_h surface, TBM_RETURN_VAL_IF_FAIL(surf->info.height > 0, 0); TBM_RETURN_VAL_IF_FAIL(surf->info.format > 0, 0); - if (mgr->backend->surface_get_plane_data2) { - ret = mgr->backend->surface_get_plane_data2(surf->info.width, - surf->info.height, surf->info.format, plane_idx, size, offset, pitch, bo_idx); - if (!ret) - return 0; - - return 1; - } - if (!mgr->backend->surface_get_plane_data) return 0; - ret = mgr->backend->surface_get_plane_data(surf, surf->info.width, + ret = mgr->backend->surface_get_plane_data(surf->info.width, surf->info.height, surf->info.format, plane_idx, size, offset, pitch, bo_idx); if (!ret) return 0; -- 2.7.4