diff options
author | SooChan Lim <sc1.lim@samsung.com> | 2018-03-20 11:32:38 +0900 |
---|---|---|
committer | SooChan Lim <sc1.lim@samsung.com> | 2018-03-20 03:44:16 +0000 |
commit | 4867252c516f8e3f025b758b8dae27623e17dba5 (patch) | |
tree | 0b0e2051eac6a116bd83f545ae552a711cff7c98 | |
parent | 915af9cd1eeab3e54b85ecd1ec1db37ddcede95e (diff) | |
download | libtbm-vc4-4867252c516f8e3f025b758b8dae27623e17dba5.tar.gz libtbm-vc4-4867252c516f8e3f025b758b8dae27623e17dba5.tar.bz2 libtbm-vc4-4867252c516f8e3f025b758b8dae27623e17dba5.zip |
use the tbm_log.h for logging.
Change-Id: Id60ed5e8996ccc64af79f957e1f0df1a50c6c563
-rw-r--r-- | src/tbm_bufmgr_vc4.c | 259 |
1 files changed, 100 insertions, 159 deletions
diff --git a/src/tbm_bufmgr_vc4.c b/src/tbm_bufmgr_vc4.c index bdf4ddb..7bffcfe 100644 --- a/src/tbm_bufmgr_vc4.c +++ b/src/tbm_bufmgr_vc4.c @@ -50,59 +50,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <pthread.h> #include <tbm_backend.h> #include <tbm_drm_helper.h> +#include <tbm_log.h> #include "tbm_bufmgr_tgl.h" -#define DEBUG #define USE_DMAIMPORT #define TBM_COLOR_FORMAT_COUNT 4 -#ifdef DEBUG -#define LOG_TAG "TBM_BACKEND" -#include <dlog.h> -static int bDebug; - #define VC4_DRM_NAME "vc4" -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_VC4_ERROR(fmt, args...) LOGE("\033[31m" "[%s] " fmt "\033[0m", target_name(), ##args) -#define TBM_VC4_DEBUG(fmt, args...) {if (bDebug&01) LOGD("[%s] " fmt, target_name(), ##args); } -#else -#define TBM_VC4_ERROR(...) -#define TBM_VC4_DEBUG(...) -#endif - #define STRERR_BUFSIZE 128 #define SIZE_ALIGN(value, base) (((value) + ((base) - 1)) & ~((base) - 1)) @@ -132,14 +87,14 @@ char *target_name() /* check condition */ #define VC4_RETURN_IF_FAIL(cond) {\ if (!(cond)) {\ - TBM_VC4_ERROR("[%s] : '%s' failed.\n", __func__, #cond);\ + TBM_ERR("[%s] : '%s' failed.\n", __func__, #cond);\ return;\ } \ } #define VC4_RETURN_VAL_IF_FAIL(cond, val) {\ if (!(cond)) {\ - TBM_VC4_ERROR("[%s] : '%s' failed.\n", __func__, #cond);\ + TBM_ERR("[%s] : '%s' failed.\n", __func__, #cond);\ return val;\ } \ } @@ -279,12 +234,12 @@ _tgl_get_version(int fd) err = ioctl(fd, TGL_IOCTL_GET_VERSION, &data); if (err) { - TBM_VC4_ERROR("error(%s) %s:%d\n", + TBM_ERR("error(%s) %s:%d\n", strerror_r(errno, buf, STRERR_BUFSIZE)); return 0; } - TBM_VC4_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; } @@ -302,7 +257,7 @@ _tgl_init(int fd, unsigned int key) err = ioctl(fd, TGL_IOCTL_REGISTER, &data); if (err) { - TBM_VC4_ERROR("error(%s) key:%d\n", + TBM_ERR("error(%s) key:%d\n", strerror_r(errno, buf, STRERR_BUFSIZE), key); return 0; } @@ -320,7 +275,7 @@ _tgl_destroy(int fd, unsigned int key) data.key = key; err = ioctl(fd, TGL_IOCTL_UNREGISTER, &data); if (err) { - TBM_VC4_ERROR("error(%s) key:%d\n", + TBM_ERR("error(%s) key:%d\n", strerror_r(errno, buf, STRERR_BUFSIZE), key); return 0; } @@ -353,7 +308,7 @@ _tgl_lock(int fd, unsigned int key, int opt) err = ioctl(fd, TGL_IOCTL_LOCK, &data); if (err) { - TBM_VC4_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; } @@ -373,7 +328,7 @@ _tgl_unlock(int fd, unsigned int key) err = ioctl(fd, TGL_IOCTL_UNLOCK, &data); if (err) { - TBM_VC4_ERROR("error(%s) key:%d\n", + TBM_ERR("error(%s) key:%d\n", strerror_r(errno, buf, STRERR_BUFSIZE), key); return 0; } @@ -393,7 +348,7 @@ _tgl_set_data(int fd, unsigned int key, unsigned int val) err = ioctl(fd, TGL_IOCTL_SET_DATA, &data); if (err) { - TBM_VC4_ERROR("error(%s) key:%d\n", + TBM_ERR("error(%s) key:%d\n", strerror_r(errno, buf, STRERR_BUFSIZE), key); return 0; } @@ -412,7 +367,7 @@ _tgl_get_data(int fd, unsigned int key) err = ioctl(fd, TGL_IOCTL_GET_DATA, &data); if (err) { - TBM_VC4_ERROR("error(%s) key:%d\n", + TBM_ERR("error(%s) key:%d\n", strerror_r(errno, buf, STRERR_BUFSIZE), key); return 0; } @@ -464,7 +419,7 @@ _vc4_cache_flush(tbm_bufmgr_vc4 bufmgr_vc4, tbm_bo_vc4 bo_vc4, int flags) ret = drmCommandWriteRead(bufmgr_vc4->fd, DRM_VC4_GEM_CACHE_OP, &cache_op, sizeof(cache_op)); if (ret) { - TBM_VC4_ERROR("fail to flush the cache.\n"); + TBM_ERR("fail to flush the cache.\n"); return 0; } @@ -551,7 +506,7 @@ _bo_set_cache_state(tbm_bufmgr_vc4 bufmgr_vc4, tbm_bo_vc4 bo_vc4, int device, in /* call cache flush */ _vc4_cache_flush(bufmgr_vc4, bo_vc4, need_flush); - TBM_VC4_DEBUG(" \tcache(%d,%d)....flush:0x%x, cntFlush(%d)\n", + TBM_DBG(" \tcache(%d,%d)....flush:0x%x, cntFlush(%d)\n", bo_vc4->cache_state.data.isCached, bo_vc4->cache_state.data.isDirtied, need_flush, @@ -615,7 +570,7 @@ _bufmgr_init_cache_state(tbm_bufmgr_vc4 bufmgr_vc4) if (bufmgr_vc4->tgl_fd < 0) { bufmgr_vc4->tgl_fd = open(tgl_devfile1, O_RDWR); if (bufmgr_vc4->tgl_fd < 0) { - TBM_VC4_ERROR("fail to open global_lock:%s\n", + TBM_ERR("fail to open global_lock:%s\n", tgl_devfile1); return 0; } @@ -623,14 +578,14 @@ _bufmgr_init_cache_state(tbm_bufmgr_vc4 bufmgr_vc4) #ifdef TGL_GET_VERSION if (!_tgl_get_version(bufmgr_vc4->tgl_fd)) { - TBM_VC4_ERROR("fail to get tgl_version. tgl init failed.\n"); + TBM_ERR("fail to get tgl_version. tgl init failed.\n"); close(bufmgr_sprd->tgl_fd); return 0; } #endif if (!_tgl_init(bufmgr_vc4->tgl_fd, GLOBAL_KEY)) { - TBM_VC4_ERROR("fail to initialize the tgl\n"); + TBM_ERR("fail to initialize the tgl\n"); close(bufmgr_vc4->tgl_fd); return 0; } @@ -660,7 +615,7 @@ _tbm_vc4_open_drm() fd = drmOpen(VC4_DRM_NAME, NULL); if (fd < 0) { - TBM_VC4_ERROR("fail to open drm.(%s)\n", VC4_DRM_NAME); + TBM_ERR("fail to open drm.(%s)\n", VC4_DRM_NAME); } if (fd < 0) { @@ -672,11 +627,11 @@ _tbm_vc4_open_drm() struct stat s; int ret; - TBM_VC4_DEBUG("search drm-device by udev\n"); + TBM_DBG("search drm-device by udev\n"); udev = udev_new(); if (!udev) { - TBM_VC4_ERROR("udev_new() failed.\n"); + TBM_ERR("udev_new() failed.\n"); return -1; } @@ -693,8 +648,7 @@ _tbm_vc4_open_drm() if (device_parent) { if (strcmp(udev_device_get_sysname(device_parent), "vc4-drm") == 0) { drm_device = device; - TBM_VC4_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; @@ -708,7 +662,7 @@ _tbm_vc4_open_drm() /* Get device file path. */ filepath = udev_device_get_devnode(drm_device); if (!filepath) { - TBM_VC4_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; @@ -717,7 +671,7 @@ _tbm_vc4_open_drm() /* Open DRM device file and check validity. */ fd = open(filepath, O_RDWR | O_CLOEXEC); if (fd < 0) { - TBM_VC4_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; @@ -725,7 +679,7 @@ _tbm_vc4_open_drm() ret = fstat(fd, &s); if (ret) { - TBM_VC4_ERROR("fstat() failed %s.\n"); + TBM_ERR("fstat() failed %s.\n"); close(fd); udev_device_unref(drm_device); udev_unref(udev); @@ -752,7 +706,7 @@ _check_render_node(void) udev = udev_new(); if (!udev) { - TBM_VC4_ERROR("udev_new() failed.\n"); + TBM_ERR("udev_new() failed.\n"); return -1; } @@ -769,7 +723,7 @@ _check_render_node(void) if (device_parent) { if (strcmp(udev_device_get_sysname(device_parent), "vc4-drm") == 0) { drm_device = device; - TBM_VC4_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; @@ -805,7 +759,7 @@ _get_render_node(void) udev = udev_new(); if (!udev) { - TBM_VC4_ERROR("udev_new() failed.\n"); + TBM_ERR("udev_new() failed.\n"); return -1; } @@ -822,7 +776,7 @@ _get_render_node(void) if (device_parent) { if (strcmp(udev_device_get_sysname(device_parent), "vc4-drm") == 0) { drm_device = device; - TBM_VC4_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; @@ -836,7 +790,7 @@ _get_render_node(void) /* Get device file path. */ filepath = udev_device_get_devnode(drm_device); if (!filepath) { - TBM_VC4_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; @@ -845,7 +799,7 @@ _get_render_node(void) /* Open DRM device file and check validity. */ fd = open(filepath, O_RDWR | O_CLOEXEC); if (fd < 0) { - TBM_VC4_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; @@ -853,7 +807,7 @@ _get_render_node(void) ret = fstat(fd, &s); if (ret) { - TBM_VC4_ERROR("fstat() failed %s.\n"); + TBM_ERR("fstat() failed %s.\n"); udev_device_unref(drm_device); udev_unref(udev); close(fd); @@ -873,7 +827,7 @@ _get_name(int fd, unsigned int gem) arg.handle = gem; if (drmIoctl(fd, DRM_IOCTL_GEM_FLINK, &arg)) { - TBM_VC4_ERROR("fail to DRM_IOCTL_GEM_FLINK gem:%d", gem); + TBM_ERR("fail to DRM_IOCTL_GEM_FLINK gem:%d", gem); return 0; } @@ -899,14 +853,14 @@ _vc4_bo_handle(tbm_bo_vc4 bo_vc4, int device) arg.handle = bo_vc4->gem; if (drmIoctl(bo_vc4->fd, DRM_IOCTL_VC4_MMAP_BO, &arg)) { - TBM_VC4_ERROR("Cannot map_vc4 gem=%d\n", bo_vc4->gem); + TBM_ERR("Cannot map_vc4 gem=%d\n", bo_vc4->gem); return (tbm_bo_handle) NULL; } map = mmap(NULL, bo_vc4->size, PROT_READ | PROT_WRITE, MAP_SHARED, bo_vc4->fd, arg.offset); if (map == MAP_FAILED) { - TBM_VC4_ERROR("Cannot usrptr gem=%d\n", bo_vc4->gem); + TBM_ERR("Cannot usrptr gem=%d\n", bo_vc4->gem); return (tbm_bo_handle) NULL; } bo_vc4->pBase = map; @@ -925,7 +879,7 @@ _vc4_bo_handle(tbm_bo_vc4 bo_vc4, int device) arg.handle = bo_vc4->gem; if (drmIoctl(bo_vc4->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { - TBM_VC4_ERROR("Cannot dmabuf=%d\n", bo_vc4->gem); + TBM_ERR("Cannot dmabuf=%d\n", bo_vc4->gem); return (tbm_bo_handle) NULL; } bo_vc4->dmabuf = arg.fd; @@ -940,7 +894,7 @@ _vc4_bo_handle(tbm_bo_vc4 bo_vc4, int device) arg.handle = bo_vc4->gem; if (drmIoctl(bo_vc4->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { - TBM_VC4_ERROR("Cannot dmabuf=%d\n", bo_vc4->gem); + TBM_ERR("Cannot dmabuf=%d\n", bo_vc4->gem); return (tbm_bo_handle) NULL; } bo_vc4->dmabuf = arg.fd; @@ -949,7 +903,7 @@ _vc4_bo_handle(tbm_bo_vc4 bo_vc4, int device) bo_handle.u32 = (uint32_t)bo_vc4->dmabuf; break; default: - TBM_VC4_ERROR("Not supported device:%d\n", device); + TBM_ERR("Not supported device:%d\n", device); bo_handle.ptr = (void *) NULL; break; } @@ -1031,7 +985,7 @@ tbm_vc4_bufmgr_bind_native_display(tbm_backend_bufmgr_data *bufmgr_data, tbm_nat if (!tbm_drm_helper_wl_auth_server_init(native_display, bufmgr_vc4->fd, bufmgr_vc4->device_name, 0)) { - TBM_VC4_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; } @@ -1057,7 +1011,7 @@ tbm_vc4_bufmgr_get_supported_formats(tbm_backend_bufmgr_data *bufmgr_data, *formats = color_formats; *num = TBM_COLOR_FORMAT_COUNT; - TBM_VC4_DEBUG("supported format count = %d\n", *num); + TBM_DBG("supported format count = %d\n", *num); return TBM_ERROR_NONE; } @@ -1352,7 +1306,7 @@ tbm_vc4_bufmgr_alloc_bo(tbm_backend_bufmgr_data *bufmgr_data, int size, tbm_bo_m tbm_bo_vc4 bo_vc4; if (bufmgr_vc4 == NULL) { - TBM_VC4_ERROR("bufmgr_data is null\n"); + TBM_ERR("bufmgr_data is null\n"); if (error) *error = TBM_ERROR_INVALID_PARAMETER; return NULL; @@ -1360,7 +1314,7 @@ tbm_vc4_bufmgr_alloc_bo(tbm_backend_bufmgr_data *bufmgr_data, int size, tbm_bo_m bo_vc4 = calloc(1, sizeof(struct _tbm_bo_vc4)); if (!bo_vc4) { - TBM_VC4_ERROR("fail to allocate the bo_vc4 private\n"); + TBM_ERR("fail to allocate the bo_vc4 private\n"); if (error) *error = TBM_ERROR_OUT_OF_MEMORY; return NULL; @@ -1372,7 +1326,7 @@ tbm_vc4_bufmgr_alloc_bo(tbm_backend_bufmgr_data *bufmgr_data, int size, tbm_bo_m arg.size = (__u32)size; arg.flags = flags;/*currently no values for the flags,but it may be used in future extension*/ if (drmIoctl(bufmgr_vc4->fd, DRM_IOCTL_VC4_CREATE_BO, &arg)) { - TBM_VC4_ERROR("Cannot create bo_vc4(flag:%x, size:%d)\n", arg.flags, + TBM_ERR("Cannot create bo_vc4(flag:%x, size:%d)\n", arg.flags, (unsigned int)arg.size); free(bo_vc4); if (error) @@ -1387,7 +1341,7 @@ tbm_vc4_bufmgr_alloc_bo(tbm_backend_bufmgr_data *bufmgr_data, int size, tbm_bo_m bo_vc4->name = _get_name(bo_vc4->fd, bo_vc4->gem); if (!_bo_init_cache_state(bufmgr_vc4, bo_vc4, 0)) { - TBM_VC4_ERROR("fail init cache state(%d)\n", bo_vc4->name); + TBM_ERR("fail init cache state(%d)\n", bo_vc4->name); free(bo_vc4); if (error) *error = TBM_ERROR_OPERATION_FAILED; @@ -1401,7 +1355,7 @@ tbm_vc4_bufmgr_alloc_bo(tbm_backend_bufmgr_data *bufmgr_data, int size, tbm_bo_m arg.handle = bo_vc4->gem; if (drmIoctl(bo_vc4->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { - TBM_VC4_ERROR("Cannot dmabuf=%d\n", bo_vc4->gem); + TBM_ERR("Cannot dmabuf=%d\n", bo_vc4->gem); free(bo_vc4); if (error) *error = TBM_ERROR_OPERATION_FAILED; @@ -1412,9 +1366,9 @@ tbm_vc4_bufmgr_alloc_bo(tbm_backend_bufmgr_data *bufmgr_data, int size, tbm_bo_m /* add bo_vc4 to hash */ if (drmHashInsert(bufmgr_vc4->hashBos, bo_vc4->name, (void *)bo_vc4) < 0) - TBM_VC4_ERROR("Cannot insert bo_vc4 to Hash(%d)\n", bo_vc4->name); + TBM_ERR("Cannot insert bo_vc4 to Hash(%d)\n", bo_vc4->name); - TBM_VC4_DEBUG(" bo_vc4:%p, gem:%d(%d), flags:%d(%d), size:%d\n", + TBM_DBG(" bo_vc4:%p, gem:%d(%d), flags:%d(%d), size:%d\n", bo_vc4, bo_vc4->gem, bo_vc4->name, bo_vc4->flags_tbm, @@ -1437,7 +1391,7 @@ tbm_vc4_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tbm_e char buf[STRERR_BUFSIZE]; if (bufmgr_vc4 == NULL) { - TBM_VC4_ERROR("bufmgr_data is null\n"); + TBM_ERR("bufmgr_data is null\n"); if (error) *error = TBM_ERROR_INVALID_PARAMETER; return NULL; @@ -1449,7 +1403,7 @@ tbm_vc4_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tbm_e arg.fd = key; arg.flags = 0; if (drmIoctl(bufmgr_vc4->fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &arg)) { - TBM_VC4_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; @@ -1459,7 +1413,7 @@ tbm_vc4_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tbm_e name = _get_name(bufmgr_vc4->fd, gem); if (!name) { - TBM_VC4_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; @@ -1488,7 +1442,7 @@ tbm_vc4_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tbm_e open_arg.name = name; if (drmIoctl(bufmgr_vc4->fd, DRM_IOCTL_GEM_OPEN, &open_arg)) { - TBM_VC4_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; @@ -1500,7 +1454,7 @@ tbm_vc4_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tbm_e memset(&close_arg, 0, sizeof(close_arg)); close_arg.handle = open_arg.handle; if (drmIoctl(bufmgr_vc4->fd, DRM_IOCTL_GEM_CLOSE, &close_arg)) { - TBM_VC4_ERROR("Cannot close gem_handle.\n", + TBM_ERR("Cannot close gem_handle.\n", strerror_r(errno, buf, STRERR_BUFSIZE)); if (error) *error = TBM_ERROR_OPERATION_FAILED; @@ -1512,7 +1466,7 @@ tbm_vc4_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tbm_e bo_vc4 = calloc(1, sizeof(struct _tbm_bo_vc4)); if (!bo_vc4) { - TBM_VC4_ERROR("bo_vc4:%p fail to allocate the bo_vc4\n", bo_vc4); + TBM_ERR("bo_vc4:%p fail to allocate the bo_vc4\n", bo_vc4); if (error) *error = TBM_ERROR_OUT_OF_MEMORY; return NULL; @@ -1526,7 +1480,7 @@ tbm_vc4_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tbm_e bo_vc4->name = name; if (!_bo_init_cache_state(bufmgr_vc4, bo_vc4, 1)) { - TBM_VC4_ERROR("fail init cache state(%d)\n", bo_vc4->name); + TBM_ERR("fail init cache state(%d)\n", bo_vc4->name); free(bo_vc4); if (error) *error = TBM_ERROR_OPERATION_FAILED; @@ -1535,10 +1489,10 @@ tbm_vc4_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tbm_e /* add bo_vc4 to hash */ if (drmHashInsert(bufmgr_vc4->hashBos, bo_vc4->name, (void *)bo_vc4) < 0) - TBM_VC4_ERROR("bo_vc4:%p Cannot insert bo_vc4 to Hash(%d) from gem:%d, fd:%d\n", + TBM_ERR("bo_vc4:%p Cannot insert bo_vc4 to Hash(%d) from gem:%d, fd:%d\n", bo_vc4, bo_vc4->name, gem, key); - TBM_VC4_DEBUG(" bo_vc4:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d, size:%d\n", + TBM_DBG(" bo_vc4:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d, size:%d\n", bo_vc4, bo_vc4->gem, bo_vc4->name, bo_vc4->dmabuf, @@ -1560,7 +1514,7 @@ tbm_vc4_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key, tbm int ret; if (bufmgr_vc4 == NULL) { - TBM_VC4_ERROR("bufmgr_data is null\n"); + TBM_ERR("bufmgr_data is null\n"); if (error) *error = TBM_ERROR_INVALID_PARAMETER; return NULL; @@ -1577,7 +1531,7 @@ tbm_vc4_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key, tbm arg.name = key; if (drmIoctl(bufmgr_vc4->fd, DRM_IOCTL_GEM_OPEN, &arg)) { - TBM_VC4_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; @@ -1585,7 +1539,7 @@ tbm_vc4_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key, tbm bo_vc4 = calloc(1, sizeof(struct _tbm_bo_vc4)); if (!bo_vc4) { - TBM_VC4_ERROR("fail to allocate the bo_vc4 private\n"); + TBM_ERR("fail to allocate the bo_vc4 private\n"); if (error) *error = TBM_ERROR_OUT_OF_MEMORY; return NULL; @@ -1598,7 +1552,7 @@ tbm_vc4_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key, tbm bo_vc4->flags_tbm = 0; if (!_bo_init_cache_state(bufmgr_vc4, bo_vc4, 1)) { - TBM_VC4_ERROR("fail init cache state(%d)\n", bo_vc4->name); + TBM_ERR("fail init cache state(%d)\n", bo_vc4->name); free(bo_vc4); if (error) *error = TBM_ERROR_OPERATION_FAILED; @@ -1610,7 +1564,7 @@ tbm_vc4_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key, tbm arg.handle = bo_vc4->gem; if (drmIoctl(bo_vc4->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { - TBM_VC4_ERROR("fail to DRM_IOCTL_PRIME_HANDLE_TO_FD gem=%d\n", bo_vc4->gem); + TBM_ERR("fail to DRM_IOCTL_PRIME_HANDLE_TO_FD gem=%d\n", bo_vc4->gem); if (error) *error = TBM_ERROR_OPERATION_FAILED; free(bo_vc4); @@ -1621,9 +1575,9 @@ tbm_vc4_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key, tbm /* add bo_vc4 to hash */ if (drmHashInsert(bufmgr_vc4->hashBos, bo_vc4->name, (void *)bo_vc4) < 0) - TBM_VC4_ERROR("Cannot insert bo_vc4 to Hash(%d)\n", bo_vc4->name); + TBM_ERR("Cannot insert bo_vc4 to Hash(%d)\n", bo_vc4->name); - TBM_VC4_DEBUG(" bo_vc4:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d\n", + TBM_DBG(" bo_vc4:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d\n", bo_vc4, bo_vc4->gem, bo_vc4->name, bo_vc4->dmabuf, @@ -1652,7 +1606,7 @@ tbm_vc4_bo_free(tbm_backend_bo_data *bo_data) if (!bufmgr_vc4) return; - TBM_VC4_DEBUG(" bo_vc4:%p, gem:%d(%d), fd:%d, size:%d\n", + TBM_DBG(" bo_vc4:%p, gem:%d(%d), fd:%d, size:%d\n", bo_vc4, bo_vc4->gem, bo_vc4->name, bo_vc4->dmabuf, @@ -1660,7 +1614,7 @@ tbm_vc4_bo_free(tbm_backend_bo_data *bo_data) if (bo_vc4->pBase) { if (munmap(bo_vc4->pBase, bo_vc4->size) == -1) { - TBM_VC4_ERROR("bo_vc4:%p fail to munmap(%s)\n", + TBM_ERR("bo_vc4:%p fail to munmap(%s)\n", bo_vc4, strerror_r(errno, buf, STRERR_BUFSIZE)); } } @@ -1676,10 +1630,10 @@ tbm_vc4_bo_free(tbm_backend_bo_data *bo_data) if (ret == 0) drmHashDelete(bufmgr_vc4->hashBos, bo_vc4->name); else - TBM_VC4_ERROR("Cannot find bo_vc4 to Hash(%d), ret=%d\n", bo_vc4->name, ret); + TBM_ERR("Cannot find bo_vc4 to Hash(%d), ret=%d\n", bo_vc4->name, ret); if (temp != bo_vc4) - TBM_VC4_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_vc4, bo_vc4); @@ -1689,7 +1643,7 @@ tbm_vc4_bo_free(tbm_backend_bo_data *bo_data) memset(&arg, 0, sizeof(arg)); arg.handle = bo_vc4->gem; if (drmIoctl(bo_vc4->fd, DRM_IOCTL_GEM_CLOSE, &arg)) - TBM_VC4_ERROR("bo_vc4:%p fail to gem close.(%s)\n", + TBM_ERR("bo_vc4:%p fail to gem close.(%s)\n", bo_vc4, strerror_r(errno, buf, STRERR_BUFSIZE)); free(bo_vc4); @@ -1742,13 +1696,13 @@ tbm_vc4_bo_get_handle(tbm_backend_bo_data *bo_data, tbm_bo_device_type device, t } if (!bo_vc4->gem) { - TBM_VC4_ERROR("Cannot map gem=%d\n", bo_vc4->gem); + TBM_ERR("Cannot map gem=%d\n", bo_vc4->gem); if (error) *error = TBM_ERROR_INVALID_PARAMETER; return (tbm_bo_handle) NULL; } - TBM_VC4_DEBUG("bo_vc4:%p, gem:%d(%d), fd:%d, flags:%d, size:%d, %s\n", + TBM_DBG("bo_vc4:%p, gem:%d(%d), fd:%d, flags:%d, size:%d, %s\n", bo_vc4, bo_vc4->gem, bo_vc4->name, bo_vc4->dmabuf, @@ -1759,7 +1713,7 @@ tbm_vc4_bo_get_handle(tbm_backend_bo_data *bo_data, tbm_bo_device_type device, t /*Get mapped bo_handle*/ bo_handle = _vc4_bo_handle(bo_vc4, device); if (bo_handle.ptr == NULL) { - TBM_VC4_ERROR("Cannot get handle: gem:%d, device:%d\n", + TBM_ERR("Cannot get handle: gem:%d, device:%d\n", bo_vc4->gem, device); if (error) *error = TBM_ERROR_OPERATION_FAILED; @@ -1794,13 +1748,13 @@ tbm_vc4_bo_map(tbm_backend_bo_data *bo_data, tbm_bo_device_type device, } if (!bo_vc4->gem) { - TBM_VC4_ERROR("Cannot map gem=%d\n", bo_vc4->gem); + TBM_ERR("Cannot map gem=%d\n", bo_vc4->gem); if (error) *error = TBM_ERROR_INVALID_PARAMETER; return (tbm_bo_handle) NULL; } - TBM_VC4_DEBUG(" bo_vc4:%p, gem:%d(%d), fd:%d, %s, %s\n", + TBM_DBG(" bo_vc4:%p, gem:%d(%d), fd:%d, %s, %s\n", bo_vc4, bo_vc4->gem, bo_vc4->name, bo_vc4->dmabuf, @@ -1810,7 +1764,7 @@ tbm_vc4_bo_map(tbm_backend_bo_data *bo_data, tbm_bo_device_type device, /*Get mapped bo_handle*/ bo_handle = _vc4_bo_handle(bo_vc4, device); if (bo_handle.ptr == NULL) { - TBM_VC4_ERROR("Cannot get handle: gem:%d, device:%d, opt:%d\n", + TBM_ERR("Cannot get handle: gem:%d, device:%d, opt:%d\n", bo_vc4->gem, device, opt); if (error) *error = TBM_ERROR_OPERATION_FAILED; @@ -1858,7 +1812,7 @@ tbm_vc4_bo_unmap(tbm_backend_bo_data *bo_data) bo_vc4->last_map_device = -1; - TBM_VC4_DEBUG(" bo_vc4:%p, gem:%d(%d), fd:%d\n", + TBM_DBG(" bo_vc4:%p, gem:%d(%d), fd:%d\n", bo_vc4, bo_vc4->gem, bo_vc4->name, bo_vc4->dmabuf); @@ -1886,7 +1840,7 @@ tbm_vc4_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_VC4_DEBUG("Not support device type,\n"); + TBM_DBG("Not support device type,\n"); return TBM_ERROR_OPERATION_FAILED; } @@ -1900,13 +1854,13 @@ tbm_vc4_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_VC4_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_vc4->use_dma_fence) { - TBM_VC4_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; } @@ -1914,7 +1868,7 @@ tbm_vc4_bo_lock(tbm_backend_bo_data *bo_data, tbm_bo_device_type device, if (device == TBM_DEVICE_3D) { ret = ioctl(bo_vc4->dmabuf, DMABUF_IOCTL_GET_FENCE, &fence); if (ret < 0) { - TBM_VC4_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 { @@ -1946,13 +1900,13 @@ tbm_vc4_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_VC4_ERROR("fence list is full\n"); + TBM_ERR("fence list is full\n"); } } pthread_mutex_unlock(&bo_vc4->mutex); - TBM_VC4_DEBUG("DMABUF_IOCTL_GET_FENCE! bo_vc4:%p, gem:%d(%d), fd:%ds\n", + TBM_DBG("DMABUF_IOCTL_GET_FENCE! bo_vc4:%p, gem:%d(%d), fd:%ds\n", bo_vc4, bo_vc4->gem, bo_vc4->name, bo_vc4->dmabuf); @@ -1980,12 +1934,12 @@ tbm_vc4_bo_unlock(tbm_backend_bo_data *bo_data) dma_type = 1; if (!bo_vc4->dma_fence[0].ctx && dma_type) { - TBM_VC4_DEBUG("FENCE not support or ignored,\n"); + TBM_DBG("FENCE not support or ignored,\n"); return TBM_ERROR_OPERATION_FAILED; } if (!bo_vc4->dma_fence[0].ctx && dma_type) { - TBM_VC4_DEBUG("device type is not 3D/CPU,\n"); + TBM_DBG("device type is not 3D/CPU,\n"); return TBM_ERROR_OPERATION_FAILED; } @@ -2009,7 +1963,7 @@ tbm_vc4_bo_unlock(tbm_backend_bo_data *bo_data) if (dma_type) { ret = ioctl(bo_vc4->dmabuf, DMABUF_IOCTL_PUT_FENCE, &fence); if (ret < 0) { - TBM_VC4_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 { @@ -2022,7 +1976,7 @@ tbm_vc4_bo_unlock(tbm_backend_bo_data *bo_data) return TBM_ERROR_OPERATION_FAILED; } - TBM_VC4_DEBUG("DMABUF_IOCTL_PUT_FENCE! bo_vc4:%p, gem:%d(%d), fd:%ds\n", + TBM_DBG("DMABUF_IOCTL_PUT_FENCE! bo_vc4:%p, gem:%d(%d), fd:%ds\n", bo_vc4, bo_vc4->gem, bo_vc4->name, bo_vc4->dmabuf); @@ -2049,14 +2003,14 @@ tbm_vc4_bo_export_fd(tbm_backend_bo_data *bo_data, tbm_error_e *error) arg.handle = bo_vc4->gem; ret = drmIoctl(bo_vc4->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg); if (ret) { - TBM_VC4_ERROR("bo_vc4:%p Cannot dmabuf=%d (%s)\n", + TBM_ERR("bo_vc4:%p Cannot dmabuf=%d (%s)\n", bo_vc4, bo_vc4->gem, strerror_r(errno, buf, STRERR_BUFSIZE)); if (error) *error = TBM_ERROR_OPERATION_FAILED; return (tbm_fd) ret; } - TBM_VC4_DEBUG(" bo_vc4:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d, size:%d\n", + TBM_DBG(" bo_vc4:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d, size:%d\n", bo_vc4, bo_vc4->gem, bo_vc4->name, bo_vc4->dmabuf, @@ -2081,14 +2035,14 @@ tbm_vc4_bo_export_key(tbm_backend_bo_data *bo_data, tbm_error_e *error) if (!bo_vc4->name) { bo_vc4->name = _get_name(bo_vc4->fd, bo_vc4->gem); if (!bo_vc4->name) { - TBM_VC4_ERROR("error Cannot get name\n"); + TBM_ERR("error Cannot get name\n"); if (error) *error = TBM_ERROR_INVALID_PARAMETER; return 0; } } - TBM_VC4_DEBUG(" bo_vc4:%p, gem:%d(%d), fd:%d, flags:%d, size:%d\n", + TBM_DBG(" bo_vc4:%p, gem:%d(%d), fd:%d, flags:%d, size:%d\n", bo_vc4, bo_vc4->gem, bo_vc4->name, bo_vc4->dmabuf, @@ -2155,7 +2109,7 @@ tbm_vc4_init(tbm_bufmgr bufmgr, tbm_error_e *error) tbm_error_e err; if (!bufmgr) { - TBM_VC4_ERROR("bufmgr is null.\n"); + TBM_ERR("bufmgr is null.\n"); if (error) *error = TBM_ERROR_INVALID_PARAMETER; return NULL; @@ -2163,7 +2117,7 @@ tbm_vc4_init(tbm_bufmgr bufmgr, tbm_error_e *error) bufmgr_vc4 = calloc(1, sizeof(struct _tbm_bufmgr_vc4)); if (!bufmgr_vc4) { - TBM_VC4_ERROR("fail to alloc bufmgr_vc4!\n"); + TBM_ERR("fail to alloc bufmgr_vc4!\n"); if (error) *error = TBM_ERROR_OUT_OF_MEMORY; return NULL; @@ -2174,7 +2128,7 @@ tbm_vc4_init(tbm_bufmgr bufmgr, tbm_error_e *error) if (bufmgr_vc4->fd < 0) { bufmgr_vc4->fd = _tbm_vc4_open_drm(); if (bufmgr_vc4->fd < 0) { - TBM_VC4_ERROR("fail to open drm!\n"); + TBM_ERR("fail to open drm!\n"); if (error) *error = TBM_ERROR_OPERATION_FAILED; goto fail_open_drm; @@ -2185,7 +2139,7 @@ tbm_vc4_init(tbm_bufmgr bufmgr, tbm_error_e *error) bufmgr_vc4->device_name = drmGetDeviceNameFromFd(bufmgr_vc4->fd); if (!bufmgr_vc4->device_name) { - TBM_VC4_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; @@ -2196,15 +2150,15 @@ tbm_vc4_init(tbm_bufmgr bufmgr, tbm_error_e *error) if (_check_render_node()) { bufmgr_vc4->fd = _get_render_node();//TODO if (bufmgr_vc4->fd < 0) { - TBM_VC4_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_VC4_DEBUG("Use render node:%d\n", bufmgr_vc4->fd); + TBM_DBG("Use render node:%d\n", bufmgr_vc4->fd); } else { if (!tbm_drm_helper_get_auth_info(&(bufmgr_vc4->fd), &(bufmgr_vc4->device_name), NULL)) { - TBM_VC4_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; @@ -2226,7 +2180,7 @@ tbm_vc4_init(tbm_bufmgr bufmgr, tbm_error_e *error) } if (!_bufmgr_init_cache_state(bufmgr_vc4)) { - TBM_VC4_ERROR("fail to init bufmgr cache state\n"); + TBM_ERR("fail to init bufmgr cache state\n"); goto fail_init_cache_state; } @@ -2236,7 +2190,7 @@ tbm_vc4_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_VC4_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; @@ -2254,7 +2208,7 @@ tbm_vc4_init(tbm_bufmgr bufmgr, tbm_error_e *error) err = tbm_backend_bufmgr_register_bufmgr_func(bufmgr, bufmgr_func); if (err != TBM_ERROR_NONE) { - TBM_VC4_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; @@ -2264,7 +2218,7 @@ tbm_vc4_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_VC4_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; @@ -2283,27 +2237,14 @@ tbm_vc4_init(tbm_bufmgr bufmgr, tbm_error_e *error) err = tbm_backend_bufmgr_register_bo_func(bufmgr, bo_func); if (err != TBM_ERROR_NONE) { - TBM_VC4_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_vc4->bo_func = bo_func; -#ifdef DEBUG - { - char *env; - - env = getenv("TBM_VC4_DEBUG"); - if (env) { - bDebug = atoi(env); - TBM_VC4_ERROR("TBM_VC4_DEBUG=%s\n", env); - } else - bDebug = 0; - } -#endif - - TBM_VC4_DEBUG("drm_fd:%d\n", bufmgr_vc4->fd); + TBM_DBG("drm_fd:%d\n", bufmgr_vc4->fd); if (error) *error = TBM_ERROR_NONE; |