From: SooChan Lim Date: Tue, 20 Mar 2018 02:26:56 +0000 (+0900) Subject: use the tbm_log.h for logging. X-Git-Tag: submit/tizen/20180320.042059~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0c5a811b02cf0790926e68efd97dad15b54a4135;p=platform%2Fadaptation%2Fsamsung_exynos%2Flibtbm-exynos.git use the tbm_log.h for logging. Change-Id: I855448552f638023bc017d9f346decdd1d69cda6 --- diff --git a/src/tbm_bufmgr_exynos.c b/src/tbm_bufmgr_exynos.c index e9bdb79..43e7793 100644 --- a/src/tbm_bufmgr_exynos.c +++ b/src/tbm_bufmgr_exynos.c @@ -50,60 +50,15 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include #include +#include #include #include "tbm_bufmgr_tgl.h" -#define DEBUG #define USE_DMAIMPORT #define TBM_COLOR_FORMAT_COUNT 4 -#ifdef DEBUG -#define LOG_TAG "TBM_BACKEND" -#include -static int bDebug; - #define EXYNOS_DRM_NAME "exynos" -char *target_name() -{ - static char app_name[128] = {0, }; - static int initialized = 0; - char *slash; - FILE *f; - - if (initialized) - return app_name; - - /* get the application name */ - f = fopen("/proc/self/cmdline", "r"); - if (!f) - return NULL; - - memset(app_name, 0x00, sizeof(app_name)); - - if (fgets(app_name, 100, f) == NULL) { - fclose(f); - return NULL; - } - - fclose(f); - - slash = strrchr(app_name, '/'); - if (slash != NULL) - memmove(app_name, slash + 1, strlen(slash)); - - initialized = 1; - - return app_name; -} - -#define TBM_EXYNOS_ERROR(fmt, args...) LOGE("\033[31m" "[%s] " fmt "\033[0m", target_name(), ##args) -#define TBM_EXYNOS_DEBUG(fmt, args...) {if (bDebug&01) LOGD("[%s] " fmt, target_name(), ##args); } -#else -#define TBM_EXYNOS_ERROR(...) -#define TBM_EXYNOS_DEBUG(...) -#endif - #define STRERR_BUFSIZE 128 #define SIZE_ALIGN(value, base) (((value) + ((base) - 1)) & ~((base) - 1)) @@ -128,14 +83,14 @@ static unsigned int g_tbm_surface_alignment_pitch_rgb; /* check condition */ #define EXYNOS_RETURN_IF_FAIL(cond) {\ if (!(cond)) {\ - TBM_EXYNOS_ERROR("[%s] : '%s' failed.\n", __func__, #cond);\ + TBM_ERR("[%s] : '%s' failed.\n", __func__, #cond);\ return;\ } \ } #define EXYNOS_RETURN_VAL_IF_FAIL(cond, val) {\ if (!(cond)) {\ - TBM_EXYNOS_ERROR("[%s] : '%s' failed.\n", __func__, #cond);\ + TBM_ERR("[%s] : '%s' failed.\n", __func__, #cond);\ return val;\ } \ } @@ -278,12 +233,12 @@ _tgl_get_version(int fd) err = ioctl(fd, TGL_IOCTL_GET_VERSION, &data); if (err) { - TBM_EXYNOS_ERROR("error(%s) %s:%d\n", + TBM_ERR("error(%s) %s:%d\n", strerror_r(errno, buf, STRERR_BUFSIZE)); return 0; } - TBM_EXYNOS_DEBUG("tgl version is (%u, %u).\n", data.major, data.minor); + TBM_DBG("tgl version is (%u, %u).\n", data.major, data.minor); return 1; } @@ -301,7 +256,7 @@ _tgl_init(int fd, unsigned int key) err = ioctl(fd, TGL_IOCTL_REGISTER, &data); if (err) { - TBM_EXYNOS_ERROR("error(%s) key:%d\n", + TBM_ERR("error(%s) key:%d\n", strerror_r(errno, buf, STRERR_BUFSIZE), key); return 0; } @@ -319,7 +274,7 @@ _tgl_destroy(int fd, unsigned int key) data.key = key; err = ioctl(fd, TGL_IOCTL_UNREGISTER, &data); if (err) { - TBM_EXYNOS_ERROR("error(%s) key:%d\n", + TBM_ERR("error(%s) key:%d\n", strerror_r(errno, buf, STRERR_BUFSIZE), key); return 0; } @@ -352,7 +307,7 @@ _tgl_lock(int fd, unsigned int key, int opt) err = ioctl(fd, TGL_IOCTL_LOCK, &data); if (err) { - TBM_EXYNOS_ERROR("error(%s) key:%d opt:%d\n", + TBM_ERR("error(%s) key:%d opt:%d\n", strerror_r(errno, buf, STRERR_BUFSIZE), key, opt); return 0; } @@ -372,7 +327,7 @@ _tgl_unlock(int fd, unsigned int key) err = ioctl(fd, TGL_IOCTL_UNLOCK, &data); if (err) { - TBM_EXYNOS_ERROR("error(%s) key:%d\n", + TBM_ERR("error(%s) key:%d\n", strerror_r(errno, buf, STRERR_BUFSIZE), key); return 0; } @@ -392,7 +347,7 @@ _tgl_set_data(int fd, unsigned int key, unsigned int val) err = ioctl(fd, TGL_IOCTL_SET_DATA, &data); if (err) { - TBM_EXYNOS_ERROR("error(%s) key:%d\n", + TBM_ERR("error(%s) key:%d\n", strerror_r(errno, buf, STRERR_BUFSIZE), key); return 0; } @@ -411,7 +366,7 @@ _tgl_get_data(int fd, unsigned int key) err = ioctl(fd, TGL_IOCTL_GET_DATA, &data); if (err) { - TBM_EXYNOS_ERROR("error(%s) key:%d\n", + TBM_ERR("error(%s) key:%d\n", strerror_r(errno, buf, STRERR_BUFSIZE), key); return 0; } @@ -463,7 +418,7 @@ _exynos_cache_flush(tbm_bufmgr_exynos bufmgr_exynos, tbm_bo_exynos bo_exynos, in ret = drmCommandWriteRead(bufmgr_exynos->fd, DRM_EXYNOS_GEM_CACHE_OP, &cache_op, sizeof(cache_op)); if (ret) { - TBM_EXYNOS_ERROR("fail to flush the cache.\n"); + TBM_ERR("fail to flush the cache.\n"); return 0; } @@ -557,7 +512,7 @@ _bo_set_cache_state(tbm_bufmgr_exynos bufmgr_exynos, tbm_bo_exynos bo_exynos, in /* call cache flush */ _exynos_cache_flush(bufmgr_exynos, bo_exynos, need_flush); - TBM_EXYNOS_DEBUG(" \tcache(%d,%d)....flush:0x%x, cntFlush(%d)\n", + TBM_DBG(" \tcache(%d,%d)....flush:0x%x, cntFlush(%d)\n", bo_exynos->cache_state.data.isCached, bo_exynos->cache_state.data.isDirtied, need_flush, @@ -627,7 +582,7 @@ _bufmgr_init_cache_state(tbm_bufmgr_exynos bufmgr_exynos) if (bufmgr_exynos->tgl_fd < 0) { bufmgr_exynos->tgl_fd = open(tgl_devfile1, O_RDWR); if (bufmgr_exynos->tgl_fd < 0) { - TBM_EXYNOS_ERROR("fail to open global_lock:%s\n", + TBM_ERR("fail to open global_lock:%s\n", tgl_devfile1); return 0; } @@ -635,14 +590,14 @@ _bufmgr_init_cache_state(tbm_bufmgr_exynos bufmgr_exynos) #ifdef TGL_GET_VERSION if (!_tgl_get_version(bufmgr_exynos->tgl_fd)) { - TBM_EXYNOS_ERROR("fail to get tgl_version. tgl init failed.\n"); + TBM_ERR("fail to get tgl_version. tgl init failed.\n"); close(bufmgr_exynos->tgl_fd); return 0; } #endif if (!_tgl_init(bufmgr_exynos->tgl_fd, GLOBAL_KEY)) { - TBM_EXYNOS_ERROR("fail to initialize the tgl\n"); + TBM_ERR("fail to initialize the tgl\n"); close(bufmgr_exynos->tgl_fd); return 0; } @@ -673,7 +628,7 @@ _tbm_exynos_open_drm() fd = drmOpen(EXYNOS_DRM_NAME, NULL); if (fd < 0) { - TBM_EXYNOS_ERROR("fail to open drm.(%s)\n", EXYNOS_DRM_NAME); + TBM_ERR("fail to open drm.(%s)\n", EXYNOS_DRM_NAME); } if (fd < 0) { @@ -685,11 +640,11 @@ _tbm_exynos_open_drm() struct stat s; int ret; - TBM_EXYNOS_DEBUG("search drm-device by udev\n"); + TBM_DBG("search drm-device by udev\n"); udev = udev_new(); if (!udev) { - TBM_EXYNOS_ERROR("udev_new() failed.\n"); + TBM_ERR("udev_new() failed.\n"); return -1; } @@ -706,8 +661,7 @@ _tbm_exynos_open_drm() if (device_parent) { if (strcmp(udev_device_get_sysname(device_parent), "exynos-drm") == 0) { drm_device = device; - TBM_EXYNOS_DEBUG("[%s] Found render device: '%s' (%s)\n", - target_name(), + TBM_DBG("Found render device: '%s' (%s)\n", udev_device_get_syspath(drm_device), udev_device_get_sysname(device_parent)); break; @@ -721,7 +675,7 @@ _tbm_exynos_open_drm() /* Get device file path. */ filepath = udev_device_get_devnode(drm_device); if (!filepath) { - TBM_EXYNOS_ERROR("udev_device_get_devnode() failed.\n"); + TBM_ERR("udev_device_get_devnode() failed.\n"); udev_device_unref(drm_device); udev_unref(udev); return -1; @@ -730,7 +684,7 @@ _tbm_exynos_open_drm() /* Open DRM device file and check validity. */ fd = open(filepath, O_RDWR | O_CLOEXEC); if (fd < 0) { - TBM_EXYNOS_ERROR("open(%s, O_RDWR | O_CLOEXEC) failed.\n"); + TBM_ERR("open(%s, O_RDWR | O_CLOEXEC) failed.\n"); udev_device_unref(drm_device); udev_unref(udev); return -1; @@ -738,7 +692,7 @@ _tbm_exynos_open_drm() ret = fstat(fd, &s); if (ret) { - TBM_EXYNOS_ERROR("fstat() failed %s.\n"); + TBM_ERR("fstat() failed %s.\n"); close(fd); udev_device_unref(drm_device); udev_unref(udev); @@ -765,7 +719,7 @@ _check_render_node(void) udev = udev_new(); if (!udev) { - TBM_EXYNOS_ERROR("udev_new() failed.\n"); + TBM_ERR("udev_new() failed.\n"); return -1; } @@ -782,7 +736,7 @@ _check_render_node(void) if (device_parent) { if (strcmp(udev_device_get_sysname(device_parent), "exynos-drm") == 0) { drm_device = device; - TBM_EXYNOS_DEBUG("Found render device: '%s' (%s)\n", + TBM_DBG("Found render device: '%s' (%s)\n", udev_device_get_syspath(drm_device), udev_device_get_sysname(device_parent)); break; @@ -818,7 +772,7 @@ _get_render_node(void) udev = udev_new(); if (!udev) { - TBM_EXYNOS_ERROR("udev_new() failed.\n"); + TBM_ERR("udev_new() failed.\n"); return -1; } @@ -835,7 +789,7 @@ _get_render_node(void) if (device_parent) { if (strcmp(udev_device_get_sysname(device_parent), "exynos-drm") == 0) { drm_device = device; - TBM_EXYNOS_DEBUG("Found render device: '%s' (%s)\n", + TBM_DBG("Found render device: '%s' (%s)\n", udev_device_get_syspath(drm_device), udev_device_get_sysname(device_parent)); break; @@ -849,7 +803,7 @@ _get_render_node(void) /* Get device file path. */ filepath = udev_device_get_devnode(drm_device); if (!filepath) { - TBM_EXYNOS_ERROR("udev_device_get_devnode() failed.\n"); + TBM_ERR("udev_device_get_devnode() failed.\n"); udev_device_unref(drm_device); udev_unref(udev); return -1; @@ -858,7 +812,7 @@ _get_render_node(void) /* Open DRM device file and check validity. */ fd = open(filepath, O_RDWR | O_CLOEXEC); if (fd < 0) { - TBM_EXYNOS_ERROR("open(%s, O_RDWR | O_CLOEXEC) failed.\n"); + TBM_ERR("open(%s, O_RDWR | O_CLOEXEC) failed.\n"); udev_device_unref(drm_device); udev_unref(udev); return -1; @@ -866,7 +820,7 @@ _get_render_node(void) ret = fstat(fd, &s); if (ret) { - TBM_EXYNOS_ERROR("fstat() failed %s.\n"); + TBM_ERR("fstat() failed %s.\n"); udev_device_unref(drm_device); udev_unref(udev); close(fd); @@ -926,7 +880,7 @@ _get_name(int fd, unsigned int gem) arg.handle = gem; if (drmIoctl(fd, DRM_IOCTL_GEM_FLINK, &arg)) { - TBM_EXYNOS_ERROR("fail to DRM_IOCTL_GEM_FLINK gem:%d", gem); + TBM_ERR("fail to DRM_IOCTL_GEM_FLINK gem:%d", gem); return 0; } @@ -953,14 +907,14 @@ _exynos_bo_handle(tbm_bo_exynos bo_exynos, int device) arg.handle = bo_exynos->gem; if (drmCommandWriteRead(bo_exynos->fd, DRM_EXYNOS_GEM_MAP, &arg, sizeof(arg))) { - TBM_EXYNOS_ERROR("Cannot map_dumb gem=%d\n", bo_exynos->gem); + TBM_ERR("Cannot map_dumb gem=%d\n", bo_exynos->gem); return (tbm_bo_handle) NULL; } map = mmap(NULL, bo_exynos->size, PROT_READ | PROT_WRITE, MAP_SHARED, bo_exynos->fd, arg.offset); if (map == MAP_FAILED) { - TBM_EXYNOS_ERROR("Cannot usrptr gem=%d\n", bo_exynos->gem); + TBM_ERR("Cannot usrptr gem=%d\n", bo_exynos->gem); return (tbm_bo_handle) NULL; } bo_exynos->pBase = map; @@ -979,7 +933,7 @@ _exynos_bo_handle(tbm_bo_exynos bo_exynos, int device) arg.handle = bo_exynos->gem; if (drmIoctl(bo_exynos->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { - TBM_EXYNOS_ERROR("Cannot dmabuf=%d\n", bo_exynos->gem); + TBM_ERR("Cannot dmabuf=%d\n", bo_exynos->gem); return (tbm_bo_handle) NULL; } bo_exynos->dmabuf = arg.fd; @@ -994,7 +948,7 @@ _exynos_bo_handle(tbm_bo_exynos bo_exynos, int device) arg.handle = bo_exynos->gem; if (drmIoctl(bo_exynos->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { - TBM_EXYNOS_ERROR("Cannot dmabuf=%d\n", bo_exynos->gem); + TBM_ERR("Cannot dmabuf=%d\n", bo_exynos->gem); return (tbm_bo_handle) NULL; } bo_exynos->dmabuf = arg.fd; @@ -1003,7 +957,7 @@ _exynos_bo_handle(tbm_bo_exynos bo_exynos, int device) bo_handle.u32 = (uint32_t)bo_exynos->dmabuf; break; default: - TBM_EXYNOS_ERROR("Not supported device:%d\n", device); + TBM_ERR("Not supported device:%d\n", device); bo_handle.ptr = (void *) NULL; break; } @@ -1085,7 +1039,7 @@ tbm_exynos_bufmgr_bind_native_display(tbm_backend_bufmgr_data *bufmgr_data, tbm_ if (!tbm_drm_helper_wl_auth_server_init(native_display, bufmgr_exynos->fd, bufmgr_exynos->device_name, 0)) { - TBM_EXYNOS_ERROR("fail to tbm_drm_helper_wl_server_init\n"); + TBM_ERR("fail to tbm_drm_helper_wl_server_init\n"); return TBM_ERROR_OPERATION_FAILED; } @@ -1112,7 +1066,7 @@ tbm_exynos_bufmgr_get_supported_formats(tbm_backend_bufmgr_data *bufmgr_data, *formats = color_formats; *num = TBM_COLOR_FORMAT_COUNT; - TBM_EXYNOS_DEBUG("supported format count = %d\n", *num); + TBM_DBG("supported format count = %d\n", *num); return TBM_ERROR_NONE; } @@ -1407,7 +1361,7 @@ tbm_exynos_bufmgr_alloc_bo(tbm_backend_bufmgr_data *bufmgr_data, int size, tbm_b unsigned int exynos_flags; if (bufmgr_exynos == NULL) { - TBM_EXYNOS_ERROR("bufmgr_data is null\n"); + TBM_ERR("bufmgr_data is null\n"); if (error) *error = TBM_ERROR_INVALID_PARAMETER; return NULL; @@ -1415,7 +1369,7 @@ tbm_exynos_bufmgr_alloc_bo(tbm_backend_bufmgr_data *bufmgr_data, int size, tbm_b bo_exynos = calloc(1, sizeof(struct _tbm_bo_exynos)); if (!bo_exynos) { - TBM_EXYNOS_ERROR("fail to allocate the bo_exynos private\n"); + TBM_ERR("fail to allocate the bo_exynos private\n"); if (error) *error = TBM_ERROR_OUT_OF_MEMORY; return NULL; @@ -1434,7 +1388,7 @@ tbm_exynos_bufmgr_alloc_bo(tbm_backend_bufmgr_data *bufmgr_data, int size, tbm_b arg.flags = exynos_flags; if (drmCommandWriteRead(bufmgr_exynos->fd, DRM_EXYNOS_GEM_CREATE, &arg, sizeof(arg))) { - TBM_EXYNOS_ERROR("Cannot create bo_exynos(flag:%x, size:%d)\n", arg.flags, + TBM_ERR("Cannot create bo_exynos(flag:%x, size:%d)\n", arg.flags, (unsigned int)arg.size); free(bo_exynos); if (error) @@ -1450,7 +1404,7 @@ tbm_exynos_bufmgr_alloc_bo(tbm_backend_bufmgr_data *bufmgr_data, int size, tbm_b bo_exynos->name = _get_name(bo_exynos->fd, bo_exynos->gem); if (!_bo_init_cache_state(bufmgr_exynos, bo_exynos, 0)) { - TBM_EXYNOS_ERROR("fail init cache state(%d)\n", bo_exynos->name); + TBM_ERR("fail init cache state(%d)\n", bo_exynos->name); free(bo_exynos); if (error) *error = TBM_ERROR_OPERATION_FAILED; @@ -1464,7 +1418,7 @@ tbm_exynos_bufmgr_alloc_bo(tbm_backend_bufmgr_data *bufmgr_data, int size, tbm_b arg.handle = bo_exynos->gem; if (drmIoctl(bo_exynos->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { - TBM_EXYNOS_ERROR("Cannot dmabuf=%d\n", bo_exynos->gem); + TBM_ERR("Cannot dmabuf=%d\n", bo_exynos->gem); free(bo_exynos); if (error) *error = TBM_ERROR_OPERATION_FAILED; @@ -1475,9 +1429,9 @@ tbm_exynos_bufmgr_alloc_bo(tbm_backend_bufmgr_data *bufmgr_data, int size, tbm_b /* add bo_exynos to hash */ if (drmHashInsert(bufmgr_exynos->hashBos, bo_exynos->name, (void *)bo_exynos) < 0) - TBM_EXYNOS_ERROR("Cannot insert bo_exynos to Hash(%d)\n", bo_exynos->name); + TBM_ERR("Cannot insert bo_exynos to Hash(%d)\n", bo_exynos->name); - TBM_EXYNOS_DEBUG(" bo_exynos:%p, gem:%d(%d), flags:%d(%d), size:%d\n", + TBM_DBG(" bo_exynos:%p, gem:%d(%d), flags:%d(%d), size:%d\n", bo_exynos, bo_exynos->gem, bo_exynos->name, flags, exynos_flags, @@ -1500,7 +1454,7 @@ tbm_exynos_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tb char buf[STRERR_BUFSIZE]; if (bufmgr_exynos == NULL) { - TBM_EXYNOS_ERROR("bufmgr_data is null\n"); + TBM_ERR("bufmgr_data is null\n"); if (error) *error = TBM_ERROR_INVALID_PARAMETER; return NULL; @@ -1512,7 +1466,7 @@ tbm_exynos_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tb arg.fd = key; arg.flags = 0; if (drmIoctl(bufmgr_exynos->fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &arg)) { - TBM_EXYNOS_ERROR("Cannot get gem handle from fd:%d (%s)\n", + TBM_ERR("Cannot get gem handle from fd:%d (%s)\n", arg.fd, strerror_r(errno, buf, STRERR_BUFSIZE)); if (error) *error = TBM_ERROR_OPERATION_FAILED; @@ -1522,7 +1476,7 @@ tbm_exynos_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tb name = _get_name(bufmgr_exynos->fd, gem); if (!name) { - TBM_EXYNOS_ERROR("Cannot get name from gem:%d, fd:%d (%s)\n", + TBM_ERR("Cannot get name from gem:%d, fd:%d (%s)\n", gem, key, strerror_r(errno, buf, STRERR_BUFSIZE)); if (error) *error = TBM_ERROR_OPERATION_FAILED; @@ -1554,7 +1508,7 @@ tbm_exynos_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tb DRM_EXYNOS_GEM_GET, &info, sizeof(struct drm_exynos_gem_info))) { - TBM_EXYNOS_ERROR("Cannot get gem info from gem:%d, fd:%d (%s)\n", + TBM_ERR("Cannot get gem info from gem:%d, fd:%d (%s)\n", gem, key, strerror_r(errno, buf, STRERR_BUFSIZE)); if (error) *error = TBM_ERROR_OPERATION_FAILED; @@ -1566,7 +1520,7 @@ tbm_exynos_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tb bo_exynos = calloc(1, sizeof(struct _tbm_bo_exynos)); if (!bo_exynos) { - TBM_EXYNOS_ERROR("bo_exynos:%p fail to allocate the bo_exynos\n", bo_exynos); + TBM_ERR("bo_exynos:%p fail to allocate the bo_exynos\n", bo_exynos); if (error) *error = TBM_ERROR_OUT_OF_MEMORY; return NULL; @@ -1581,7 +1535,7 @@ tbm_exynos_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tb bo_exynos->name = name; if (!_bo_init_cache_state(bufmgr_exynos, bo_exynos, 1)) { - TBM_EXYNOS_ERROR("fail init cache state(%d)\n", bo_exynos->name); + TBM_ERR("fail init cache state(%d)\n", bo_exynos->name); free(bo_exynos); if (error) *error = TBM_ERROR_OPERATION_FAILED; @@ -1590,10 +1544,10 @@ tbm_exynos_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tb /* add bo_exynos to hash */ if (drmHashInsert(bufmgr_exynos->hashBos, bo_exynos->name, (void *)bo_exynos) < 0) - TBM_EXYNOS_ERROR("bo_exynos:%p Cannot insert bo_exynos to Hash(%d) from gem:%d, fd:%d\n", + TBM_ERR("bo_exynos:%p Cannot insert bo_exynos to Hash(%d) from gem:%d, fd:%d\n", bo_exynos, bo_exynos->name, gem, key); - TBM_EXYNOS_DEBUG(" bo_exynos:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d(%d), size:%d\n", + TBM_DBG(" bo_exynos:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d(%d), size:%d\n", bo_exynos, bo_exynos->gem, bo_exynos->name, bo_exynos->dmabuf, @@ -1615,7 +1569,7 @@ tbm_exynos_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key, int ret; if (bufmgr_exynos == NULL) { - TBM_EXYNOS_ERROR("bufmgr_data is null\n"); + TBM_ERR("bufmgr_data is null\n"); if (error) *error = TBM_ERROR_INVALID_PARAMETER; return NULL; @@ -1633,7 +1587,7 @@ tbm_exynos_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key, arg.name = key; if (drmIoctl(bufmgr_exynos->fd, DRM_IOCTL_GEM_OPEN, &arg)) { - TBM_EXYNOS_ERROR("Cannot open gem name=%d\n", key); + TBM_ERR("Cannot open gem name=%d\n", key); if (error) *error = TBM_ERROR_OPERATION_FAILED; return NULL; @@ -1644,7 +1598,7 @@ tbm_exynos_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key, DRM_EXYNOS_GEM_GET, &info, sizeof(struct drm_exynos_gem_info))) { - TBM_EXYNOS_ERROR("Cannot get gem info=%d\n", key); + TBM_ERR("Cannot get gem info=%d\n", key); if (error) *error = TBM_ERROR_OPERATION_FAILED; return NULL; @@ -1652,7 +1606,7 @@ tbm_exynos_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key, bo_exynos = calloc(1, sizeof(struct _tbm_bo_exynos)); if (!bo_exynos) { - TBM_EXYNOS_ERROR("fail to allocate the bo_exynos private\n"); + TBM_ERR("fail to allocate the bo_exynos private\n"); if (error) *error = TBM_ERROR_OUT_OF_MEMORY; return NULL; @@ -1667,7 +1621,7 @@ tbm_exynos_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key, bo_exynos->flags_tbm = _get_tbm_flag_from_exynos(bo_exynos->flags_exynos); if (!_bo_init_cache_state(bufmgr_exynos, bo_exynos, 1)) { - TBM_EXYNOS_ERROR("fail init cache state(%d)\n", bo_exynos->name); + TBM_ERR("fail init cache state(%d)\n", bo_exynos->name); free(bo_exynos); if (error) *error = TBM_ERROR_OPERATION_FAILED; @@ -1679,7 +1633,7 @@ tbm_exynos_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key, arg.handle = bo_exynos->gem; if (drmIoctl(bo_exynos->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { - TBM_EXYNOS_ERROR("fail to DRM_IOCTL_PRIME_HANDLE_TO_FD gem=%d\n", bo_exynos->gem); + TBM_ERR("fail to DRM_IOCTL_PRIME_HANDLE_TO_FD gem=%d\n", bo_exynos->gem); if (error) *error = TBM_ERROR_OPERATION_FAILED; free(bo_exynos); @@ -1690,9 +1644,9 @@ tbm_exynos_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key, /* add bo_exynos to hash */ if (drmHashInsert(bufmgr_exynos->hashBos, bo_exynos->name, (void *)bo_exynos) < 0) - TBM_EXYNOS_ERROR("Cannot insert bo_exynos to Hash(%d)\n", bo_exynos->name); + TBM_ERR("Cannot insert bo_exynos to Hash(%d)\n", bo_exynos->name); - TBM_EXYNOS_DEBUG(" bo_exynos:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d\n", + TBM_DBG(" bo_exynos:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d\n", bo_exynos, bo_exynos->gem, bo_exynos->name, bo_exynos->dmabuf, @@ -1721,7 +1675,7 @@ tbm_exynos_bo_free(tbm_backend_bo_data *bo_data) if (!bufmgr_exynos) return; - TBM_EXYNOS_DEBUG(" bo_exynos:%p, gem:%d(%d), fd:%d, size:%d\n", + TBM_DBG(" bo_exynos:%p, gem:%d(%d), fd:%d, size:%d\n", bo_exynos, bo_exynos->gem, bo_exynos->name, bo_exynos->dmabuf, @@ -1729,7 +1683,7 @@ tbm_exynos_bo_free(tbm_backend_bo_data *bo_data) if (bo_exynos->pBase) { if (munmap(bo_exynos->pBase, bo_exynos->size) == -1) { - TBM_EXYNOS_ERROR("bo_exynos:%p fail to munmap(%s)\n", + TBM_ERR("bo_exynos:%p fail to munmap(%s)\n", bo_exynos, strerror_r(errno, buf, STRERR_BUFSIZE)); } } @@ -1745,10 +1699,10 @@ tbm_exynos_bo_free(tbm_backend_bo_data *bo_data) if (ret == 0) drmHashDelete(bufmgr_exynos->hashBos, bo_exynos->name); else - TBM_EXYNOS_ERROR("Cannot find bo_exynos to Hash(%d), ret=%d\n", bo_exynos->name, ret); + TBM_ERR("Cannot find bo_exynos to Hash(%d), ret=%d\n", bo_exynos->name, ret); if (temp != bo_exynos) - TBM_EXYNOS_ERROR("hashBos probably has several BOs with same name!!!\n"); + TBM_ERR("hashBos probably has several BOs with same name!!!\n"); _bo_destroy_cache_state(bufmgr_exynos, bo_exynos); @@ -1758,7 +1712,7 @@ tbm_exynos_bo_free(tbm_backend_bo_data *bo_data) memset(&arg, 0, sizeof(arg)); arg.handle = bo_exynos->gem; if (drmIoctl(bo_exynos->fd, DRM_IOCTL_GEM_CLOSE, &arg)) - TBM_EXYNOS_ERROR("bo_exynos:%p fail to gem close.(%s)\n", + TBM_ERR("bo_exynos:%p fail to gem close.(%s)\n", bo_exynos, strerror_r(errno, buf, STRERR_BUFSIZE)); free(bo_exynos); @@ -1811,13 +1765,13 @@ tbm_exynos_bo_get_handle(tbm_backend_bo_data *bo_data, tbm_bo_device_type device } if (!bo_exynos->gem) { - TBM_EXYNOS_ERROR("Cannot map gem=%d\n", bo_exynos->gem); + TBM_ERR("Cannot map gem=%d\n", bo_exynos->gem); if (error) *error = TBM_ERROR_INVALID_PARAMETER; return (tbm_bo_handle) NULL; } - TBM_EXYNOS_DEBUG("bo_exynos:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d, %s\n", + TBM_DBG("bo_exynos:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d, %s\n", bo_exynos, bo_exynos->gem, bo_exynos->name, bo_exynos->dmabuf, @@ -1828,7 +1782,7 @@ tbm_exynos_bo_get_handle(tbm_backend_bo_data *bo_data, tbm_bo_device_type device /*Get mapped bo_handle*/ bo_handle = _exynos_bo_handle(bo_exynos, device); if (bo_handle.ptr == NULL) { - TBM_EXYNOS_ERROR("Cannot get handle: gem:%d, device:%d\n", + TBM_ERR("Cannot get handle: gem:%d, device:%d\n", bo_exynos->gem, device); if (error) *error = TBM_ERROR_OPERATION_FAILED; @@ -1863,13 +1817,13 @@ tbm_exynos_bo_map(tbm_backend_bo_data *bo_data, tbm_bo_device_type device, } if (!bo_exynos->gem) { - TBM_EXYNOS_ERROR("Cannot map gem=%d\n", bo_exynos->gem); + TBM_ERR("Cannot map gem=%d\n", bo_exynos->gem); if (error) *error = TBM_ERROR_INVALID_PARAMETER; return (tbm_bo_handle) NULL; } - TBM_EXYNOS_DEBUG(" bo_exynos:%p, gem:%d(%d), fd:%d, %s, %s\n", + TBM_DBG(" bo_exynos:%p, gem:%d(%d), fd:%d, %s, %s\n", bo_exynos, bo_exynos->gem, bo_exynos->name, bo_exynos->dmabuf, @@ -1879,7 +1833,7 @@ tbm_exynos_bo_map(tbm_backend_bo_data *bo_data, tbm_bo_device_type device, /*Get mapped bo_handle*/ bo_handle = _exynos_bo_handle(bo_exynos, device); if (bo_handle.ptr == NULL) { - TBM_EXYNOS_ERROR("Cannot get handle: gem:%d, device:%d, opt:%d\n", + TBM_ERR("Cannot get handle: gem:%d, device:%d, opt:%d\n", bo_exynos->gem, device, opt); if (error) *error = TBM_ERROR_OPERATION_FAILED; @@ -1926,7 +1880,7 @@ tbm_exynos_bo_unmap(tbm_backend_bo_data *bo_data) bo_exynos->last_map_device = -1; - TBM_EXYNOS_DEBUG(" bo_exynos:%p, gem:%d(%d), fd:%d\n", + TBM_DBG(" bo_exynos:%p, gem:%d(%d), fd:%d\n", bo_exynos, bo_exynos->gem, bo_exynos->name, bo_exynos->dmabuf); @@ -1954,7 +1908,7 @@ tbm_exynos_bo_lock(tbm_backend_bo_data *bo_data, tbm_bo_device_type device, return TBM_ERROR_INVALID_PARAMETER; if (device != TBM_DEVICE_3D && device != TBM_DEVICE_CPU) { - TBM_EXYNOS_DEBUG("Not support device type,\n"); + TBM_DBG("Not support device type,\n"); return TBM_ERROR_OPERATION_FAILED; } @@ -1968,13 +1922,13 @@ tbm_exynos_bo_lock(tbm_backend_bo_data *bo_data, tbm_bo_device_type device, if (device == TBM_DEVICE_3D) fence.type = DMA_BUF_ACCESS_READ | DMA_BUF_ACCESS_DMA; } else { - TBM_EXYNOS_ERROR("Invalid argument\n"); + TBM_ERR("Invalid argument\n"); return TBM_ERROR_INVALID_PARAMETER; } /* Check if the tbm manager supports dma fence or not. */ if (!bufmgr_exynos->use_dma_fence) { - TBM_EXYNOS_ERROR("Not support DMA FENCE(%s)\n", strerror_r(errno, buf, STRERR_BUFSIZE)); + TBM_ERR("Not support DMA FENCE(%s)\n", strerror_r(errno, buf, STRERR_BUFSIZE)); return TBM_ERROR_OPERATION_FAILED; } @@ -1982,7 +1936,7 @@ tbm_exynos_bo_lock(tbm_backend_bo_data *bo_data, tbm_bo_device_type device, if (device == TBM_DEVICE_3D) { ret = ioctl(bo_exynos->dmabuf, DMABUF_IOCTL_GET_FENCE, &fence); if (ret < 0) { - TBM_EXYNOS_ERROR("Cannot set GET FENCE(%s)\n", strerror_r(errno, buf, STRERR_BUFSIZE)); + TBM_ERR("Cannot set GET FENCE(%s)\n", strerror_r(errno, buf, STRERR_BUFSIZE)); return TBM_ERROR_OPERATION_FAILED; } } else { @@ -2014,13 +1968,13 @@ tbm_exynos_bo_lock(tbm_backend_bo_data *bo_data, tbm_bo_device_type device, if (i == DMA_FENCE_LIST_MAX) { /*TODO: if dma_fence list is full, it needs realloc. I will fix this. by minseok3.kim*/ - TBM_EXYNOS_ERROR("fence list is full\n"); + TBM_ERR("fence list is full\n"); } } pthread_mutex_unlock(&bo_exynos->mutex); - TBM_EXYNOS_DEBUG("DMABUF_IOCTL_GET_FENCE! bo_exynos:%p, gem:%d(%d), fd:%ds\n", + TBM_DBG("DMABUF_IOCTL_GET_FENCE! bo_exynos:%p, gem:%d(%d), fd:%ds\n", bo_exynos, bo_exynos->gem, bo_exynos->name, bo_exynos->dmabuf); @@ -2048,12 +2002,12 @@ tbm_exynos_bo_unlock(tbm_backend_bo_data *bo_data) dma_type = 1; if (!bo_exynos->dma_fence[0].ctx && dma_type) { - TBM_EXYNOS_DEBUG("FENCE not support or ignored,\n"); + TBM_DBG("FENCE not support or ignored,\n"); return TBM_ERROR_OPERATION_FAILED; } if (!bo_exynos->dma_fence[0].ctx && dma_type) { - TBM_EXYNOS_DEBUG("device type is not 3D/CPU,\n"); + TBM_DBG("device type is not 3D/CPU,\n"); return TBM_ERROR_OPERATION_FAILED; } @@ -2076,7 +2030,7 @@ tbm_exynos_bo_unlock(tbm_backend_bo_data *bo_data) if (dma_type) { ret = ioctl(bo_exynos->dmabuf, DMABUF_IOCTL_PUT_FENCE, &fence); if (ret < 0) { - TBM_EXYNOS_ERROR("Can not set PUT FENCE(%s)\n", strerror_r(errno, buf, STRERR_BUFSIZE)); + TBM_ERR("Can not set PUT FENCE(%s)\n", strerror_r(errno, buf, STRERR_BUFSIZE)); return TBM_ERROR_OPERATION_FAILED; } } else { @@ -2089,7 +2043,7 @@ tbm_exynos_bo_unlock(tbm_backend_bo_data *bo_data) return TBM_ERROR_OPERATION_FAILED; } - TBM_EXYNOS_DEBUG("DMABUF_IOCTL_PUT_FENCE! bo_exynos:%p, gem:%d(%d), fd:%ds\n", + TBM_DBG("DMABUF_IOCTL_PUT_FENCE! bo_exynos:%p, gem:%d(%d), fd:%ds\n", bo_exynos, bo_exynos->gem, bo_exynos->name, bo_exynos->dmabuf); @@ -2115,14 +2069,14 @@ tbm_exynos_bo_export_fd(tbm_backend_bo_data *bo_data, tbm_error_e *error) arg.handle = bo_exynos->gem; ret = drmIoctl(bo_exynos->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg); if (ret) { - TBM_EXYNOS_ERROR("bo_exynos:%p Cannot dmabuf=%d (%s)\n", + TBM_ERR("bo_exynos:%p Cannot dmabuf=%d (%s)\n", bo_exynos, bo_exynos->gem, strerror_r(errno, buf, STRERR_BUFSIZE)); if (error) *error = TBM_ERROR_OPERATION_FAILED; return (tbm_fd) ret; } - TBM_EXYNOS_DEBUG(" bo_exynos:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d(%d), size:%d\n", + TBM_DBG(" bo_exynos:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d(%d), size:%d\n", bo_exynos, bo_exynos->gem, bo_exynos->name, bo_exynos->dmabuf, @@ -2150,14 +2104,14 @@ tbm_exynos_bo_export_key(tbm_backend_bo_data *bo_data, tbm_error_e *error) if (!bo_exynos->name) { bo_exynos->name = _get_name(bo_exynos->fd, bo_exynos->gem); if (!bo_exynos->name) { - TBM_EXYNOS_ERROR("error Cannot get name\n"); + TBM_ERR("error Cannot get name\n"); if (error) *error = TBM_ERROR_INVALID_PARAMETER; return 0; } } - TBM_EXYNOS_DEBUG(" bo_exynos:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d\n", + TBM_DBG(" bo_exynos:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d\n", bo_exynos, bo_exynos->gem, bo_exynos->name, bo_exynos->dmabuf, @@ -2225,7 +2179,7 @@ tbm_exynos_init(tbm_bufmgr bufmgr, tbm_error_e *error) char *value = NULL; if (!bufmgr) { - TBM_EXYNOS_ERROR("bufmgr is null.\n"); + TBM_ERR("bufmgr is null.\n"); if (error) *error = TBM_ERROR_INVALID_PARAMETER; return NULL; @@ -2233,7 +2187,7 @@ tbm_exynos_init(tbm_bufmgr bufmgr, tbm_error_e *error) bufmgr_exynos = calloc(1, sizeof(struct _tbm_bufmgr_exynos)); if (!bufmgr_exynos) { - TBM_EXYNOS_ERROR("fail to alloc bufmgr_exynos!\n"); + TBM_ERR("fail to alloc bufmgr_exynos!\n"); if (error) *error = TBM_ERROR_OUT_OF_MEMORY; return NULL; @@ -2244,7 +2198,7 @@ tbm_exynos_init(tbm_bufmgr bufmgr, tbm_error_e *error) if (bufmgr_exynos->fd < 0) { bufmgr_exynos->fd = _tbm_exynos_open_drm(); if (bufmgr_exynos->fd < 0) { - TBM_EXYNOS_ERROR("fail to open drm!\n"); + TBM_ERR("fail to open drm!\n"); if (error) *error = TBM_ERROR_OPERATION_FAILED; goto fail_open_drm; @@ -2255,7 +2209,7 @@ tbm_exynos_init(tbm_bufmgr bufmgr, tbm_error_e *error) bufmgr_exynos->device_name = drmGetDeviceNameFromFd(bufmgr_exynos->fd); if (!bufmgr_exynos->device_name) { - TBM_EXYNOS_ERROR("fail to get device name!\n"); + TBM_ERR("fail to get device name!\n"); tbm_drm_helper_unset_tbm_master_fd(); if (error) *error = TBM_ERROR_OPERATION_FAILED; @@ -2265,15 +2219,15 @@ tbm_exynos_init(tbm_bufmgr bufmgr, tbm_error_e *error) if (_check_render_node()) { bufmgr_exynos->fd = _get_render_node(); if (bufmgr_exynos->fd < 0) { - TBM_EXYNOS_ERROR("fail to get render node\n"); + TBM_ERR("fail to get render node\n"); if (error) *error = TBM_ERROR_OPERATION_FAILED; goto fail_get_render_node; } - TBM_EXYNOS_DEBUG("Use render node:%d\n", bufmgr_exynos->fd); + TBM_DBG("Use render node:%d\n", bufmgr_exynos->fd); } else { if (!tbm_drm_helper_get_auth_info(&(bufmgr_exynos->fd), &(bufmgr_exynos->device_name), NULL)) { - TBM_EXYNOS_ERROR("fail to get auth drm info!\n"); + TBM_ERR("fail to get auth drm info!\n"); if (error) *error = TBM_ERROR_OPERATION_FAILED; goto fail_get_auth_info; @@ -2300,8 +2254,8 @@ tbm_exynos_init(tbm_bufmgr bufmgr, tbm_error_e *error) * is not set to the backend. */ if (system_info_get_platform_string("http://tizen.org/system/model_name", &value) != SYSTEM_INFO_ERROR_NONE) { - TBM_EXYNOS_ERROR("Cannot get the \"http://tizen.org/system/model_name\" key value from system-info.\n"); - TBM_EXYNOS_ERROR("May not set the right value on libtbm-exynos backend.\n"); + TBM_ERR("Cannot get the \"http://tizen.org/system/model_name\" key value from system-info.\n"); + TBM_ERR("May not set the right value on libtbm-exynos backend.\n"); } else { if (!strncmp(value, "TW1", 4)) { g_tbm_surface_alignment_plane = 8; @@ -2316,7 +2270,7 @@ tbm_exynos_init(tbm_bufmgr bufmgr, tbm_error_e *error) free(value); if (!_bufmgr_init_cache_state(bufmgr_exynos)) { - TBM_EXYNOS_ERROR("fail to init bufmgr cache state\n"); + TBM_ERR("fail to init bufmgr cache state\n"); if (error) *error = TBM_ERROR_OPERATION_FAILED; goto fail_init_cache_state; @@ -2328,7 +2282,7 @@ tbm_exynos_init(tbm_bufmgr bufmgr, tbm_error_e *error) /* alloc and register bufmgr_funcs */ bufmgr_func = tbm_backend_bufmgr_alloc_bufmgr_func(bufmgr, &err); if (!bufmgr_func) { - TBM_EXYNOS_ERROR("fail to alloc bufmgr_func! err(%d)\n", err); + TBM_ERR("fail to alloc bufmgr_func! err(%d)\n", err); if (error) *error = TBM_ERROR_OUT_OF_MEMORY; goto fail_alloc_bufmgr_func; @@ -2346,7 +2300,7 @@ tbm_exynos_init(tbm_bufmgr bufmgr, tbm_error_e *error) err = tbm_backend_bufmgr_register_bufmgr_func(bufmgr, bufmgr_func); if (err != TBM_ERROR_NONE) { - TBM_EXYNOS_ERROR("fail to register bufmgr_func! err(%d)\n", err); + TBM_ERR("fail to register bufmgr_func! err(%d)\n", err); if (error) *error = TBM_ERROR_OPERATION_FAILED; goto fail_register_bufmgr_func; @@ -2356,7 +2310,7 @@ tbm_exynos_init(tbm_bufmgr bufmgr, tbm_error_e *error) /* alloc and register bo_funcs */ bo_func = tbm_backend_bufmgr_alloc_bo_func(bufmgr, &err); if (!bo_func) { - TBM_EXYNOS_ERROR("fail to alloc bo_func! err(%d)\n", err); + TBM_ERR("fail to alloc bo_func! err(%d)\n", err); if (error) *error = TBM_ERROR_OUT_OF_MEMORY; goto fail_alloc_bo_func; @@ -2375,27 +2329,14 @@ tbm_exynos_init(tbm_bufmgr bufmgr, tbm_error_e *error) err = tbm_backend_bufmgr_register_bo_func(bufmgr, bo_func); if (err != TBM_ERROR_NONE) { - TBM_EXYNOS_ERROR("fail to register bo_func! err(%d)\n", err); + TBM_ERR("fail to register bo_func! err(%d)\n", err); if (error) *error = TBM_ERROR_OPERATION_FAILED; goto fail_register_bo_func; } bufmgr_exynos->bo_func = bo_func; -#ifdef DEBUG - { - char *env; - - env = getenv("TBM_EXYNOS_DEBUG"); - if (env) { - bDebug = atoi(env); - TBM_EXYNOS_ERROR("TBM_EXYNOS_DEBUG=%s\n", env); - } else - bDebug = 0; - } -#endif - - TBM_EXYNOS_DEBUG("drm_fd:%d\n", bufmgr_exynos->fd); + TBM_DBG("drm_fd:%d\n", bufmgr_exynos->fd); if (error) *error = TBM_ERROR_NONE;