diff options
author | Changyeon Lee <cyeon.lee@samsung.com> | 2023-07-12 16:47:45 +0900 |
---|---|---|
committer | Changyeon Lee <cyeon.lee@samsung.com> | 2023-07-12 17:18:17 +0900 |
commit | 23157d258b2718b4a1cd4f5f452d383d3ac59aec (patch) | |
tree | 566fc18c57556007a7702ec0a4f783b58d7de2ce | |
parent | 1c4cdf6f76c00dd0c95c2ca7a5f944ec7340bd1e (diff) | |
download | libtbm-dumb-23157d258b2718b4a1cd4f5f452d383d3ac59aec.tar.gz libtbm-dumb-23157d258b2718b4a1cd4f5f452d383d3ac59aec.tar.bz2 libtbm-dumb-23157d258b2718b4a1cd4f5f452d383d3ac59aec.zip |
Initialize dmabuf to negative value
Change-Id: I5e2a5de694a07e8c6bc6f3bf98e90af2a8b208c1
-rw-r--r-- | src/tbm_backend_dumb.c | 36 |
1 files changed, 10 insertions, 26 deletions
diff --git a/src/tbm_backend_dumb.c b/src/tbm_backend_dumb.c index 0b71775..8939de5 100644 --- a/src/tbm_backend_dumb.c +++ b/src/tbm_backend_dumb.c @@ -72,7 +72,7 @@ struct _tbm_dumb_bo { unsigned int gem; /* GEM Handle */ - unsigned int dmabuf; /* fd for dmabuf */ + int dmabuf; /* fd for dmabuf */ void *pBase; /* virtual address */ @@ -303,7 +303,6 @@ _dumb_bo_handle(tbm_dumb_bo *bo_data, int device) break; case HAL_TBM_DEVICE_CPU: if (!bo_data->pBase) { - map_dumb_arg.handle = bo_data->gem; if (drmIoctl(bo_data->fd, DRM_IOCTL_MODE_MAP_DUMB, &map_dumb_arg)) { TBM_BACKEND_ERR("fail to DRM_IOCTL_MODE_MAP_DUMB bo_data:%p gem:%d", @@ -322,8 +321,7 @@ _dumb_bo_handle(tbm_dumb_bo *bo_data, int device) bo_handle.ptr = (void *)bo_data->pBase; break; case HAL_TBM_DEVICE_3D: - if (!bo_data->dmabuf) { - + if (bo_data->dmabuf < 0) { prime_handle_arg.handle = bo_data->gem; if (drmIoctl(bo_data->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &prime_handle_arg)) { TBM_BACKEND_ERR("fail to DRM_IOCTL_PRIME_HANDLE_TO_FD bo_data:%p gem:%d", @@ -336,7 +334,7 @@ _dumb_bo_handle(tbm_dumb_bo *bo_data, int device) bo_handle.u32 = (uint32_t)bo_data->dmabuf; break; case HAL_TBM_DEVICE_MM: - if (!bo_data->dmabuf) { + if (bo_data->dmabuf < 0) { prime_handle_arg.handle = bo_data->gem; if (drmIoctl(bo_data->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &prime_handle_arg)) { TBM_BACKEND_ERR("fail to DRM_IOCTL_PRIME_HANDLE_TO_FD bo_data:%p gem:%d", @@ -683,6 +681,7 @@ tbm_dumb_bufmgr_alloc_bo(hal_tbm_bufmgr *bufmgr, unsigned int size, bo_data->fd = bufmgr_data->fd; bo_data->gem = create_dumb_arg.handle; bo_data->size = create_dumb_arg.size; + bo_data->dmabuf = -1; bo_data->flags_tbm = flags; bo_data->flags_dumb = dumb_flags; bo_data->name = _get_name(bo_data->fd, bo_data->gem); @@ -795,8 +794,8 @@ tbm_dumb_bufmgr_import_fd(hal_tbm_bufmgr *bufmgr, hal_tbm_fd key, hal_tbm_error bo_data->fd = bufmgr_data->fd; bo_data->gem = gem; - bo_data->dmabuf = 0; bo_data->size = real_size; + bo_data->dmabuf = -1; bo_data->flags_dumb = 0; bo_data->flags_tbm = _get_tbm_flag_from_dumb(bo_data->flags_dumb); bo_data->name = name; @@ -806,11 +805,10 @@ tbm_dumb_bufmgr_import_fd(hal_tbm_bufmgr *bufmgr, hal_tbm_fd key, hal_tbm_error TBM_BACKEND_ERR("fail to insert bo_data to Hash:%d bo_data:%p gem:%d fd:%d", bo_data->name, bo_data, gem, key); - TBM_BACKEND_DBG("bo_data:%p gem:%d name:%d fd:%d key_fd:%d flags:%d size:%d", + TBM_BACKEND_DBG("bo_data:%p gem:%d name:%d key_fd:%d flags:%d size:%d", bo_data, bo_data->gem, bo_data->name, - bo_data->dmabuf, key, bo_data->flags_tbm, bo_data->size); @@ -827,7 +825,6 @@ tbm_dumb_bufmgr_import_key(hal_tbm_bufmgr *bufmgr, hal_tbm_key key, hal_tbm_erro tbm_dumb_bufmgr *bufmgr_data = (tbm_dumb_bufmgr *)bufmgr; tbm_dumb_bo *bo_data; struct drm_gem_open open_arg = {0, }; - struct drm_prime_handle prim_handle_arg = {0, }; int ret; if (bufmgr_data == NULL) { @@ -864,32 +861,19 @@ tbm_dumb_bufmgr_import_key(hal_tbm_bufmgr *bufmgr, hal_tbm_key key, hal_tbm_erro bo_data->fd = bufmgr_data->fd; bo_data->gem = open_arg.handle; bo_data->size = open_arg.size; + bo_data->dmabuf = -1; bo_data->flags_dumb = 0; bo_data->name = key; bo_data->flags_tbm = _get_tbm_flag_from_dumb(bo_data->flags_dumb); - if (!bo_data->dmabuf) { - prim_handle_arg.handle = bo_data->gem; - if (drmIoctl(bo_data->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &prim_handle_arg)) { - TBM_BACKEND_ERR("fail to DRM_IOCTL_PRIME_HANDLE_TO_FD bo_data:%p gem:d%d", - bo_data, bo_data->gem); - if (error) - *error = HAL_TBM_ERROR_INVALID_OPERATION; - free(bo_data); - return NULL; - } - bo_data->dmabuf = prim_handle_arg.fd; - } - /* add bo to hash */ if (drmHashInsert(bufmgr_data->hashBos, bo_data->name, (void *)bo_data) < 0) TBM_BACKEND_ERR("fail to insert bo_data:%p to Hash:%d", bo_data, bo_data->name); - TBM_BACKEND_DBG("bo_data:%p gem:%d name:%d fd:%d flags:%d size:%d", + TBM_BACKEND_DBG("bo_data:%p gem:%d name:%d flags:%d size:%d", bo_data, bo_data->gem, bo_data->name, - bo_data->dmabuf, bo_data->flags_tbm, bo_data->size); @@ -930,9 +914,9 @@ tbm_dumb_bo_free(hal_tbm_bo *bo) } /* close dmabuf */ - if (bo_data->dmabuf) { + if (bo_data->dmabuf >= 0) { close(bo_data->dmabuf); - bo_data->dmabuf = 0; + bo_data->dmabuf = -1; } /* delete bo from hash */ |