From 70702265d21303193aefdbe5901d17acb281734b Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 19 Mar 2018 20:54:51 +0900 Subject: [PATCH] use the tbm_log.h for logging Change-Id: I695630634cd3884a76ef207884923aeae869d871 --- src/tbm_bufmgr_sprd.c | 221 ++++++++++++++++++-------------------------------- 1 file changed, 81 insertions(+), 140 deletions(-) diff --git a/src/tbm_bufmgr_sprd.c b/src/tbm_bufmgr_sprd.c index 437d6eb..afe29f1 100644 --- a/src/tbm_bufmgr_sprd.c +++ b/src/tbm_bufmgr_sprd.c @@ -52,8 +52,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include #include +#include -#define DEBUG //#define USE_CONTIG_ONLY //#define USE_CACHE #define USE_DMAIMPORT @@ -64,54 +64,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define TBM_COLOR_FORMAT_COUNT 4 -#ifdef DEBUG -#define LOG_TAG "TBM_BACKEND" -#include -static int bDebug = 0; - #define SPRD_DRM_NAME "sprd" -static char * -_target_name(void) -{ - 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_SPRD_ERROR(fmt, args...) LOGE("\033[31m" "[%s] " fmt "\033[0m", _target_name(), ##args) -#define TBM_SPRD_DEBUG(fmt, args...) if (bDebug&01) LOGD("[%s] " fmt, _target_name(), ##args) -#else -#define TBM_SPRD_ERROR(...) -#define TBM_SPRD_DEBUG(...) -#endif - #define STRERR_BUFSIZE 128 #define SIZE_ALIGN(value, base) (((value) + ((base) - 1)) & ~((base) - 1)) @@ -124,13 +78,13 @@ _target_name(void) /* check condition */ #define SPRD_RETURN_IF_FAIL(cond) {\ if (!(cond)) {\ - TBM_SPRD_ERROR("[%s] : '%s' failed.\n", __FUNCTION__, #cond);\ + TBM_ERR("[%s] : '%s' failed.\n", __FUNCTION__, #cond);\ return;\ } \ } #define SPRD_RETURN_VAL_IF_FAIL(cond, val) {\ if (!(cond)) {\ - TBM_SPRD_ERROR("[%s] : '%s' failed.\n", __FUNCTION__, #cond);\ + TBM_ERR("[%s] : '%s' failed.\n", __FUNCTION__, #cond);\ return val;\ } \ } @@ -268,12 +222,12 @@ _tgl_get_version(int fd) err = ioctl(fd, TGL_IOCTL_GET_VERSION, &data); if (err) { - TBM_SPRD_ERROR("error(%s) %s:%d\n", + TBM_ERR("error(%s) %s:%d\n", strerror_r(errno, buf, STRERR_BUFSIZE)); return 0; } - TBM_SPRD_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; } @@ -290,7 +244,7 @@ _tgl_init(int fd, unsigned int key) err = ioctl(fd, TGL_IOCTL_REGISTER, &data); if (err) { - TBM_SPRD_ERROR("error(%s) key:%d\n", + TBM_ERR("error(%s) key:%d\n", strerror_r(errno, buf, STRERR_BUFSIZE), key); return 0; } @@ -308,7 +262,7 @@ _tgl_destroy(int fd, unsigned int key) data.key = key; err = ioctl(fd, TGL_IOCTL_UNREGISTER, &data); if (err) { - TBM_SPRD_ERROR("error(%s) key:%d\n", + TBM_ERR("error(%s) key:%d\n", strerror_r(errno, buf, STRERR_BUFSIZE), key); return 0; } @@ -341,7 +295,7 @@ _tgl_lock(int fd, unsigned int key, int opt) err = ioctl(fd, TGL_IOCTL_LOCK, &data); if (err) { - TBM_SPRD_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; } @@ -361,7 +315,7 @@ _tgl_unlock(int fd, unsigned int key) err = ioctl(fd, TGL_IOCTL_UNLOCK, &data); if (err) { - TBM_SPRD_ERROR("error(%s) key:%d\n", + TBM_ERR("error(%s) key:%d\n", strerror_r(errno, buf, STRERR_BUFSIZE), key); return 0; } @@ -381,7 +335,7 @@ _tgl_set_data(int fd, unsigned int key, unsigned int val) err = ioctl(fd, TGL_IOCTL_SET_DATA, &data); if (err) { - TBM_SPRD_ERROR("error(%s) key:%d\n", + TBM_ERR("error(%s) key:%d\n", strerror_r(errno, buf, STRERR_BUFSIZE), key); return 0; } @@ -400,7 +354,7 @@ _tgl_get_data(int fd, unsigned int key, unsigned int *locked) err = ioctl(fd, TGL_IOCTL_GET_DATA, &data); if (err) { - TBM_SPRD_ERROR("error(%s) key:%d\n", + TBM_ERR("error(%s) key:%d\n", strerror_r(errno, buf, STRERR_BUFSIZE), key); return 0; } @@ -430,11 +384,11 @@ _tbm_sprd_open_drm(void) return fd; #ifdef HAVE_UDEV - TBM_SPRD_DEBUG("warning fail to open drm. search drm-device by udev\n"); + TBM_DBG("warning fail to open drm. search drm-device by udev\n"); udev = udev_new(); if (!udev) { - TBM_SPRD_ERROR("udev_new() failed.\n"); + TBM_ERR("udev_new() failed.\n"); return -1; } @@ -453,7 +407,7 @@ _tbm_sprd_open_drm(void) if (device_parent) { if (strcmp(udev_device_get_sysname(device_parent), "sprd-drm") == 0) { drm_device = device; - TBM_SPRD_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; @@ -467,7 +421,7 @@ _tbm_sprd_open_drm(void) /* Get device file path. */ filepath = udev_device_get_devnode(drm_device); if (!filepath) { - TBM_SPRD_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; @@ -479,12 +433,12 @@ _tbm_sprd_open_drm(void) /* Open DRM device file and check validity. */ fd = open(filepath, O_RDWR | O_CLOEXEC); if (fd < 0) { - TBM_SPRD_ERROR("open(%s, O_RDWR | O_CLOEXEC) failed.\n"); + TBM_ERR("open(%s, O_RDWR | O_CLOEXEC) failed.\n"); return -1; } if (fstat(fd, &s)) { - TBM_SPRD_ERROR("fstat() failed %s.\n"); + TBM_ERR("fstat() failed %s.\n"); close(fd); return -1; } @@ -540,7 +494,7 @@ _sprd_bo_cache_flush(tbm_bufmgr_sprd bufmgr_sprd, tbm_bo_sprd bo_sprd, int flags ret = drmCommandWriteRead(bufmgr_sprd->fd, DRM_SPRD_GEM_CACHE_OP, &cache_op, sizeof(cache_op)); if (ret) { - TBM_SPRD_ERROR("error fail to flush the cache.\n"); + TBM_ERR("error fail to flush the cache.\n"); return 0; } #endif @@ -630,7 +584,7 @@ _bo_set_cache_state(tbm_bufmgr_sprd bufmgr_sprd, tbm_bo_sprd bo_sprd, int device /* call cache flush */ _sprd_bo_cache_flush(bufmgr_sprd, bo_sprd, need_flush); - TBM_SPRD_DEBUG("\tcache(%d,%d)....flush:0x%x, cntFlush(%d)\n", + TBM_DBG("\tcache(%d,%d)....flush:0x%x, cntFlush(%d)\n", bo_sprd->cache_state.data.isCached, bo_sprd->cache_state.data.isDirtied, need_flush, @@ -693,20 +647,20 @@ _bufmgr_init_cache_state(tbm_bufmgr_sprd bufmgr_sprd) if (bufmgr_sprd->tgl_fd < 0) { bufmgr_sprd->tgl_fd = open(tgl_devfile1, O_RDWR); if (bufmgr_sprd->tgl_fd < 0) { - TBM_SPRD_ERROR("fail to open global_lock:%s\n", + TBM_ERR("fail to open global_lock:%s\n", tgl_devfile1); return 0; } } if (!_tgl_get_version(bufmgr_sprd->tgl_fd)) { - TBM_SPRD_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; } if (!_tgl_init(bufmgr_sprd->tgl_fd, GLOBAL_KEY)) { - TBM_SPRD_ERROR("fail to initialize the tgl\n"); + TBM_ERR("fail to initialize the tgl\n"); close(bufmgr_sprd->tgl_fd); return 0; } @@ -783,7 +737,7 @@ _get_name(int fd, unsigned int gem) arg.handle = gem; if (drmIoctl(fd, DRM_IOCTL_GEM_FLINK, &arg)) { - TBM_SPRD_ERROR("fail to DRM_IOCTL_GEM_FLINK gem:%d", gem); + TBM_ERR("fail to DRM_IOCTL_GEM_FLINK gem:%d", gem); return 0; } @@ -809,7 +763,7 @@ _sprd_bo_handle(tbm_bo_sprd bo_sprd, int device) arg.handle = bo_sprd->gem; arg.size = bo_sprd->size; if (drmCommandWriteRead(bo_sprd->fd, DRM_SPRD_GEM_MMAP, &arg, sizeof(arg))) { - TBM_SPRD_ERROR("error Cannot usrptr gem=%d\n", bo_sprd->gem); + TBM_ERR("error Cannot usrptr gem=%d\n", bo_sprd->gem); return (tbm_bo_handle) NULL; } bo_sprd->pBase = (void *)((uint32_t)arg.mapped); @@ -823,7 +777,7 @@ _sprd_bo_handle(tbm_bo_sprd bo_sprd, int device) struct drm_prime_handle arg = {0, }; arg.handle = bo_sprd->gem; if (drmIoctl(bo_sprd->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { - TBM_SPRD_ERROR("error Cannot dmabuf=%d\n", bo_sprd->gem); + TBM_ERR("error Cannot dmabuf=%d\n", bo_sprd->gem); return (tbm_bo_handle) NULL; } bo_sprd->dmabuf = arg.fd; @@ -837,14 +791,14 @@ _sprd_bo_handle(tbm_bo_sprd bo_sprd, int device) case TBM_DEVICE_MM: #ifdef USE_HEAP_ID //TODO : Add ioctl for GSP MAP once available. - TBM_SPRD_DEBUG("%s In case TBM_DEVICE_MM: \n", __FUNCTION_); + TBM_DBG("%s In case TBM_DEVICE_MM: \n", __FUNCTION_); #else if (!bo_sprd->dmabuf) { struct drm_prime_handle arg = {0, }; arg.handle = bo_sprd->gem; if (drmIoctl(bo_sprd->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { - TBM_SPRD_ERROR("error Cannot dmabuf=%d\n", bo_sprd->gem); + TBM_ERR("error Cannot dmabuf=%d\n", bo_sprd->gem); return (tbm_bo_handle) NULL; } bo_sprd->dmabuf = arg.fd; @@ -854,7 +808,7 @@ _sprd_bo_handle(tbm_bo_sprd bo_sprd, int device) #endif break; default: - TBM_SPRD_ERROR("Not supported device:%d\n", device); + TBM_ERR("Not supported device:%d\n", device); bo_handle.ptr = (void *) NULL; break; } @@ -883,7 +837,7 @@ tbm_sprd_bufmgr_bind_native_display(tbm_backend_bufmgr_data *bufmgr_data, tbm_na if (!tbm_drm_helper_wl_auth_server_init(native_display, bufmgr_sprd->fd, bufmgr_sprd->device_name, 0)) { - TBM_SPRD_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; } @@ -910,7 +864,7 @@ tbm_sprd_bufmgr_get_supported_formats(tbm_backend_bufmgr_data *bufmgr_data, *formats = color_formats; *num = TBM_COLOR_FORMAT_COUNT; - TBM_SPRD_DEBUG("supported format count = %d\n", *num); + TBM_DBG("supported format count = %d\n", *num); return TBM_ERROR_NONE; } @@ -1175,7 +1129,7 @@ tbm_sprd_bufmgr_alloc_bo(tbm_backend_bufmgr_data *bufmgr_data, int size, tbm_bo_ unsigned int sprd_flags; if (bufmgr_sprd == NULL) { - TBM_SPRD_ERROR("bufmgr_data is null\n"); + TBM_ERR("bufmgr_data is null\n"); if (error) *error = TBM_ERROR_INVALID_PARAMETER; return NULL; @@ -1183,7 +1137,7 @@ tbm_sprd_bufmgr_alloc_bo(tbm_backend_bufmgr_data *bufmgr_data, int size, tbm_bo_ bo_sprd = calloc(1, sizeof(struct _tbm_bo_sprd)); if (!bo_sprd) { - TBM_SPRD_ERROR("error fail to allocate the bo_sprd\n"); + TBM_ERR("error fail to allocate the bo_sprd\n"); if (error) *error = TBM_ERROR_OUT_OF_MEMORY; return NULL; @@ -1205,7 +1159,7 @@ tbm_sprd_bufmgr_alloc_bo(tbm_backend_bufmgr_data *bufmgr_data, int size, tbm_bo_ arg.flags = sprd_flags; if (drmCommandWriteRead(bufmgr_sprd->fd, DRM_SPRD_GEM_CREATE, &arg, sizeof(arg))) { - TBM_SPRD_ERROR("error Cannot create bo_sprd(flag:%x, size:%d)\n", + TBM_ERR("error Cannot create bo_sprd(flag:%x, size:%d)\n", arg.flags, (unsigned int)arg.size); free(bo_sprd); if (error) @@ -1221,7 +1175,7 @@ tbm_sprd_bufmgr_alloc_bo(tbm_backend_bufmgr_data *bufmgr_data, int size, tbm_bo_ bo_sprd->name = _get_name(bo_sprd->fd, bo_sprd->gem); if (!_bo_init_cache_state(bufmgr_sprd, bo_sprd, 0)) { - TBM_SPRD_ERROR("error fail init cache state(%d)\n", bo_sprd->name); + TBM_ERR("error fail init cache state(%d)\n", bo_sprd->name); free(bo_sprd); if (error) *error = TBM_ERROR_OPERATION_FAILED; @@ -1235,7 +1189,7 @@ tbm_sprd_bufmgr_alloc_bo(tbm_backend_bufmgr_data *bufmgr_data, int size, tbm_bo_ arg.handle = bo_sprd->gem; if (drmIoctl(bo_sprd->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { - TBM_SPRD_ERROR("error Cannot dmabuf=%d\n", bo_sprd->gem); + TBM_ERR("error Cannot dmabuf=%d\n", bo_sprd->gem); free(bo_sprd); if (error) *error = TBM_ERROR_OPERATION_FAILED; @@ -1246,9 +1200,9 @@ tbm_sprd_bufmgr_alloc_bo(tbm_backend_bufmgr_data *bufmgr_data, int size, tbm_bo_ /* add bo_sprd to hash */ if (drmHashInsert(bufmgr_sprd->hashBos, bo_sprd->name, (void *)bo_sprd) < 0) - TBM_SPRD_ERROR("Cannot insert bo_sprd to Hash(%d)\n", bo_sprd->name); + TBM_ERR("Cannot insert bo_sprd to Hash(%d)\n", bo_sprd->name); - TBM_SPRD_DEBUG("%s size:%d, gem:%d(%d), flags:%d(%d)\n", + TBM_DBG("%s size:%d, gem:%d(%d), flags:%d(%d)\n", __FUNCTION__, bo_sprd->size, bo_sprd->gem, bo_sprd->name, flags, sprd_flags); @@ -1270,7 +1224,7 @@ tbm_sprd_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tbm_ char buf[STRERR_BUFSIZE]; if (bufmgr_sprd == NULL) { - TBM_SPRD_ERROR("bufmgr_data is null\n"); + TBM_ERR("bufmgr_data is null\n"); if (error) *error = TBM_ERROR_INVALID_PARAMETER; return NULL; @@ -1281,7 +1235,7 @@ tbm_sprd_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tbm_ arg.fd = key; if (drmIoctl(bufmgr_sprd->fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &arg)) { - TBM_SPRD_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; @@ -1291,7 +1245,7 @@ tbm_sprd_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tbm_ name = _get_name(bufmgr_sprd->fd, gem); if (!name) { - TBM_SPRD_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; @@ -1324,7 +1278,7 @@ tbm_sprd_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tbm_ DRM_SPRD_GEM_GET, &info, sizeof(struct drm_sprd_gem_info))) { - TBM_SPRD_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; @@ -1336,7 +1290,7 @@ tbm_sprd_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tbm_ bo_sprd = calloc(1, sizeof(struct _tbm_bo_sprd)); if (!bo_sprd) { - TBM_SPRD_ERROR("error bo_sprd:%p fail to allocate the bo_sprd\n", bo_sprd); + TBM_ERR("error bo_sprd:%p fail to allocate the bo_sprd\n", bo_sprd); if (error) *error = TBM_ERROR_OUT_OF_MEMORY; return NULL; @@ -1351,7 +1305,7 @@ tbm_sprd_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tbm_ bo_sprd->name = name; if (!_bo_init_cache_state(bufmgr_sprd, bo_sprd, 1)) { - TBM_SPRD_ERROR("error fail init cache state(%d)\n", bo_sprd->name); + TBM_ERR("error fail init cache state(%d)\n", bo_sprd->name); if (error) *error = TBM_ERROR_OPERATION_FAILED; goto fail_init_cache; @@ -1359,10 +1313,10 @@ tbm_sprd_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tbm_ /* add bo_sprd to hash */ if (drmHashInsert(bufmgr_sprd->hashBos, bo_sprd->name, (void *)bo_sprd) < 0) - TBM_SPRD_ERROR("bo_sprd:%p Cannot insert bo_sprd to Hash(%d) from gem:%d, fd:%d\n", + TBM_ERR("bo_sprd:%p Cannot insert bo_sprd to Hash(%d) from gem:%d, fd:%d\n", bo_sprd, bo_sprd->name, gem, key); - TBM_SPRD_DEBUG("bo_sprd:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d(%d), size:%d\n", + TBM_DBG("bo_sprd:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d(%d), size:%d\n", bo_sprd, bo_sprd->gem, bo_sprd->name, bo_sprd->dmabuf, @@ -1388,7 +1342,7 @@ tbm_sprd_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key, tb int ret; if (bufmgr_sprd == NULL) { - TBM_SPRD_ERROR("bufmgr_data is null\n"); + TBM_ERR("bufmgr_data is null\n"); if (error) *error = TBM_ERROR_INVALID_PARAMETER; return NULL; @@ -1406,7 +1360,7 @@ tbm_sprd_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key, tb arg.name = key; if (drmIoctl(bufmgr_sprd->fd, DRM_IOCTL_GEM_OPEN, &arg)) { - TBM_SPRD_ERROR("error Cannot open gem name=%d\n", key); + TBM_ERR("error Cannot open gem name=%d\n", key); if (error) *error = TBM_ERROR_OPERATION_FAILED; return NULL; @@ -1417,7 +1371,7 @@ tbm_sprd_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key, tb DRM_SPRD_GEM_GET, &info, sizeof(struct drm_sprd_gem_info))) { - TBM_SPRD_ERROR("error Cannot get gem info=%d\n", key); + TBM_ERR("error Cannot get gem info=%d\n", key); if (error) *error = TBM_ERROR_OPERATION_FAILED; goto fail_get_gem; @@ -1425,7 +1379,7 @@ tbm_sprd_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key, tb bo_sprd = calloc(1, sizeof(struct _tbm_bo_sprd)); if (!bo_sprd) { - TBM_SPRD_ERROR("error fail to allocate the bo_sprd\n"); + TBM_ERR("error fail to allocate the bo_sprd\n"); if (error) *error = TBM_ERROR_OUT_OF_MEMORY; goto fail_alloc_bo; @@ -1445,7 +1399,7 @@ tbm_sprd_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key, tb #endif if (!_bo_init_cache_state(bufmgr_sprd, bo_sprd, 1)) { - TBM_SPRD_ERROR("error fail init cache state(%d)\n", bo_sprd->name); + TBM_ERR("error fail init cache state(%d)\n", bo_sprd->name); if (error) *error = TBM_ERROR_OPERATION_FAILED; goto fail_init_cache; @@ -1456,7 +1410,7 @@ tbm_sprd_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key, tb arg.handle = bo_sprd->gem; if (drmIoctl(bo_sprd->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { - TBM_SPRD_ERROR("error Cannot dmabuf=%d\n", bo_sprd->gem); + TBM_ERR("error Cannot dmabuf=%d\n", bo_sprd->gem); if (error) *error = TBM_ERROR_OPERATION_FAILED; goto fail_prime_handle_to_fd; @@ -1466,9 +1420,9 @@ tbm_sprd_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key, tb /* add bo_sprd to hash */ if (drmHashInsert(bufmgr_sprd->hashBos, bo_sprd->name, (void *)bo_sprd) < 0) - TBM_SPRD_ERROR("Cannot insert bo_sprd to Hash(%d)\n", bo_sprd->name); + TBM_ERR("Cannot insert bo_sprd to Hash(%d)\n", bo_sprd->name); - TBM_SPRD_DEBUG(" bo_sprd:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d\n", + TBM_DBG(" bo_sprd:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d\n", bo_sprd, bo_sprd->gem, bo_sprd->name, bo_sprd->dmabuf, @@ -1509,7 +1463,7 @@ tbm_sprd_bo_free(tbm_backend_bo_data *bo_data) if (!bufmgr_sprd) return; - TBM_SPRD_DEBUG(" bo_sprd:%p, gem:%d(%d), fd:%d, size:%d\n", + TBM_DBG(" bo_sprd:%p, gem:%d(%d), fd:%d, size:%d\n", bo_sprd, bo_sprd->gem, bo_sprd->name, bo_sprd->dmabuf, @@ -1517,7 +1471,7 @@ tbm_sprd_bo_free(tbm_backend_bo_data *bo_data) if (bo_sprd->pBase) { if (munmap(bo_sprd->pBase, bo_sprd->size) == -1) { - TBM_SPRD_ERROR("bo_sprd:%p fail to munmap(%s)\n", + TBM_ERR("bo_sprd:%p fail to munmap(%s)\n", bo_sprd, strerror_r(errno, buf, STRERR_BUFSIZE)); } } @@ -1534,10 +1488,10 @@ tbm_sprd_bo_free(tbm_backend_bo_data *bo_data) if (ret == 0) drmHashDelete(bufmgr_sprd->hashBos, bo_sprd->name); else - TBM_SPRD_ERROR("Cannot find bo_sprd to Hash(%d), ret=%d\n", bo_sprd->name, ret); + TBM_ERR("Cannot find bo_sprd to Hash(%d), ret=%d\n", bo_sprd->name, ret); if (temp != bo_sprd) - TBM_SPRD_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_sprd, bo_sprd); @@ -1547,7 +1501,7 @@ tbm_sprd_bo_free(tbm_backend_bo_data *bo_data) memset(&arg, 0, sizeof(arg)); arg.handle = bo_sprd->gem; if (drmIoctl(bo_sprd->fd, DRM_IOCTL_GEM_CLOSE, &arg)) - TBM_SPRD_ERROR("bo_sprd:%p fail to gem close.(%s)\n", + TBM_ERR("bo_sprd:%p fail to gem close.(%s)\n", bo_sprd, strerror_r(errno, buf, STRERR_BUFSIZE)); free(bo_sprd); } @@ -1599,13 +1553,13 @@ tbm_sprd_bo_get_handle(tbm_backend_bo_data *bo_data, tbm_bo_device_type device, } if (!bo_sprd->gem) { - TBM_SPRD_ERROR("Cannot map gem=%d\n", bo_sprd->gem); + TBM_ERR("Cannot map gem=%d\n", bo_sprd->gem); if (error) *error = TBM_ERROR_INVALID_PARAMETER; return (tbm_bo_handle) NULL; } - TBM_SPRD_DEBUG("bo_sprd:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d, %s\n", + TBM_DBG("bo_sprd:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d, %s\n", bo_sprd, bo_sprd->gem, bo_sprd->name, bo_sprd->dmabuf, @@ -1616,7 +1570,7 @@ tbm_sprd_bo_get_handle(tbm_backend_bo_data *bo_data, tbm_bo_device_type device, /*Get mapped bo_handle*/ bo_handle = _sprd_bo_handle(bo_sprd, device); if (bo_handle.ptr == NULL) { - TBM_SPRD_ERROR("Cannot get handle: gem:%d, device:%d\n", + TBM_ERR("Cannot get handle: gem:%d, device:%d\n", bo_sprd->gem, device); if (error) *error = TBM_ERROR_OPERATION_FAILED; @@ -1651,13 +1605,13 @@ tbm_sprd_bo_map(tbm_backend_bo_data *bo_data, tbm_bo_device_type device, } if (!bo_sprd->gem) { - TBM_SPRD_ERROR("Cannot map gem=%d\n", bo_sprd->gem); + TBM_ERR("Cannot map gem=%d\n", bo_sprd->gem); if (error) *error = TBM_ERROR_INVALID_PARAMETER; return (tbm_bo_handle) NULL; } - TBM_SPRD_DEBUG(" bo_sprd:%p, gem:%d(%d), fd:%d, %s, %s\n", + TBM_DBG(" bo_sprd:%p, gem:%d(%d), fd:%d, %s, %s\n", bo_sprd, bo_sprd->gem, bo_sprd->name, bo_sprd->dmabuf, @@ -1667,7 +1621,7 @@ tbm_sprd_bo_map(tbm_backend_bo_data *bo_data, tbm_bo_device_type device, /*Get mapped bo_handle*/ bo_handle = _sprd_bo_handle(bo_sprd, device); if (bo_handle.ptr == NULL) { - TBM_SPRD_ERROR("Cannot get handle: gem:%d, device:%d, opt:%d\n", + TBM_ERR("Cannot get handle: gem:%d, device:%d, opt:%d\n", bo_sprd->gem, device, opt); if (error) *error = TBM_ERROR_OPERATION_FAILED; @@ -1706,7 +1660,7 @@ tbm_sprd_bo_unmap(tbm_backend_bo_data *bo_data) if (bo_sprd->map_cnt == 0) _bo_save_cache_state(bufmgr_sprd, bo_sprd); - TBM_SPRD_DEBUG(" bo_sprd:%p, gem:%d(%d), fd:%d\n", + TBM_DBG(" bo_sprd:%p, gem:%d(%d), fd:%d\n", bo_sprd, bo_sprd->gem, bo_sprd->name, bo_sprd->dmabuf); @@ -1731,14 +1685,14 @@ tbm_sprd_bo_export_fd(tbm_backend_bo_data *bo_data, tbm_error_e *error) arg.handle = bo_sprd->gem; ret = drmIoctl(bo_sprd->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg); if (ret) { - TBM_SPRD_ERROR("bo_sprd:%p Cannot dmabuf=%d (%s)\n", + TBM_ERR("bo_sprd:%p Cannot dmabuf=%d (%s)\n", bo_sprd, bo_sprd->gem, strerror_r(errno, buf, STRERR_BUFSIZE)); if (error) *error = TBM_ERROR_OPERATION_FAILED; return (tbm_fd) ret; } - TBM_SPRD_DEBUG("bo_sprd:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d(%d), size:%d\n", + TBM_DBG("bo_sprd:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d(%d), size:%d\n", bo_sprd, bo_sprd->gem, bo_sprd->name, bo_sprd->dmabuf, @@ -1766,14 +1720,14 @@ tbm_sprd_bo_export_key(tbm_backend_bo_data *bo_data, tbm_error_e *error) if (!bo_sprd->name) { bo_sprd->name = _get_name(bo_sprd->fd, bo_sprd->gem); if (!bo_sprd->name) { - TBM_SPRD_ERROR("error Cannot get name\n"); + TBM_ERR("error Cannot get name\n"); if (error) *error = TBM_ERROR_INVALID_PARAMETER; return 0; } } - TBM_SPRD_DEBUG(" bo_sprd:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d\n", + TBM_DBG(" bo_sprd:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d\n", bo_sprd, bo_sprd->gem, bo_sprd->name, bo_sprd->dmabuf, @@ -1840,7 +1794,7 @@ tbm_sprd_init(tbm_bufmgr bufmgr, tbm_error_e *error) tbm_error_e err; if (!bufmgr) { - TBM_SPRD_ERROR("bufmgr is null.\n"); + TBM_ERR("bufmgr is null.\n"); if (error) *error = TBM_ERROR_INVALID_PARAMETER; return NULL; @@ -1848,7 +1802,7 @@ tbm_sprd_init(tbm_bufmgr bufmgr, tbm_error_e *error) bufmgr_sprd = calloc(1, sizeof(struct _tbm_bufmgr_sprd)); if (!bufmgr_sprd) { - TBM_SPRD_ERROR("fail to alloc bufmgr_sprd!\n"); + TBM_ERR("fail to alloc bufmgr_sprd!\n"); if (error) *error = TBM_ERROR_OUT_OF_MEMORY; return NULL; @@ -1859,7 +1813,7 @@ tbm_sprd_init(tbm_bufmgr bufmgr, tbm_error_e *error) if (bufmgr_sprd->fd < 0) { bufmgr_sprd->fd = _tbm_sprd_open_drm(); if (bufmgr_sprd->fd < 0) { - TBM_SPRD_ERROR("fail to open drm!\n"); + TBM_ERR("fail to open drm!\n"); if (error) *error = TBM_ERROR_OPERATION_FAILED; goto fail_open_drm; @@ -1870,7 +1824,7 @@ tbm_sprd_init(tbm_bufmgr bufmgr, tbm_error_e *error) bufmgr_sprd->device_name = drmGetDeviceNameFromFd(bufmgr_sprd->fd); if (!bufmgr_sprd->device_name) { - TBM_SPRD_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; @@ -1878,7 +1832,7 @@ tbm_sprd_init(tbm_bufmgr bufmgr, tbm_error_e *error) } } else { if (!tbm_drm_helper_get_auth_info(&(bufmgr_sprd->fd), &(bufmgr_sprd->device_name), NULL)) { - TBM_SPRD_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; @@ -1900,7 +1854,7 @@ tbm_sprd_init(tbm_bufmgr bufmgr, tbm_error_e *error) } if (!_bufmgr_init_cache_state(bufmgr_sprd)) { - TBM_SPRD_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; @@ -1912,7 +1866,7 @@ tbm_sprd_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_SPRD_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; @@ -1929,7 +1883,7 @@ tbm_sprd_init(tbm_bufmgr bufmgr, tbm_error_e *error) err = tbm_backend_bufmgr_register_bufmgr_func(bufmgr, bufmgr_func); if (err != TBM_ERROR_NONE) { - TBM_SPRD_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; @@ -1939,7 +1893,7 @@ tbm_sprd_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_SPRD_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; @@ -1958,29 +1912,16 @@ tbm_sprd_init(tbm_bufmgr bufmgr, tbm_error_e *error) err = tbm_backend_bufmgr_register_bo_func(bufmgr, bo_func); if (err != TBM_ERROR_NONE) { - TBM_SPRD_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_sprd->bo_func = bo_func; -#ifdef DEBUG - { - char *env; - - env = getenv("TBM_SPRD_DEBUG"); - if (env) { - bDebug = atoi(env); - TBM_SPRD_ERROR("TBM_SPRD_DEBUG=%s\n", env); - } else - bDebug = 0; - } -#endif - - TBM_SPRD_DEBUG("DMABUF FENCE is %s\n", + TBM_DBG("DMABUF FENCE is %s\n", bufmgr_sprd->use_dma_fence ? "supported!" : "NOT supported!"); - TBM_SPRD_DEBUG("fd:%d\n", bufmgr_sprd->fd); + TBM_DBG("fd:%d\n", bufmgr_sprd->fd); if (error) *error = TBM_ERROR_NONE; -- 2.7.4