summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/tbm_backend_dumb.c226
1 files changed, 2 insertions, 224 deletions
diff --git a/src/tbm_backend_dumb.c b/src/tbm_backend_dumb.c
index 64abcf0..f646dc6 100644
--- a/src/tbm_backend_dumb.c
+++ b/src/tbm_backend_dumb.c
@@ -61,31 +61,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define TBM_SURFACE_ALIGNMENT_PITCH_RGB (128)
#define TBM_SURFACE_ALIGNMENT_PITCH_YUV (16)
-struct dma_buf_info {
- unsigned long size;
- unsigned int fence_supported;
- unsigned int padding;
-};
-
-#define DMA_BUF_ACCESS_READ 0x1
-#define DMA_BUF_ACCESS_WRITE 0x2
-#define DMA_BUF_ACCESS_DMA 0x4
-#define DMA_BUF_ACCESS_MAX 0x8
-
-#define DMA_FENCE_LIST_MAX 5
-
-struct dma_buf_fence {
- unsigned long ctx;
- unsigned int type;
-};
-
-#define DMABUF_IOCTL_BASE 'F'
-#define DMABUF_IOWR(nr, type) _IOWR(DMABUF_IOCTL_BASE, nr, type)
-
-#define DMABUF_IOCTL_GET_INFO DMABUF_IOWR(0x00, struct dma_buf_info)
-#define DMABUF_IOCTL_GET_FENCE DMABUF_IOWR(0x01, struct dma_buf_fence)
-#define DMABUF_IOCTL_PUT_FENCE DMABUF_IOWR(0x02, struct dma_buf_fence)
-
typedef struct _tbm_dumb_bufmgr tbm_dumb_bufmgr;
typedef struct _tbm_dumb_bo tbm_dumb_bo;
@@ -107,7 +82,6 @@ struct _tbm_dumb_bo {
unsigned int flags_tbm;
pthread_mutex_t mutex;
- struct dma_buf_fence dma_fence[DMA_FENCE_LIST_MAX];
int device;
int opt;
@@ -118,8 +92,6 @@ struct _tbm_dumb_bo {
struct _tbm_dumb_bufmgr {
int fd;
void *hashBos;
-
- int use_dma_fence;
};
static char *STR_DEVICE[] = {
@@ -725,20 +697,6 @@ tbm_dumb_bufmgr_alloc_bo(hal_tbm_bufmgr *bufmgr, unsigned int size,
pthread_mutex_init(&bo_data->mutex, NULL);
- if (bufmgr_data->use_dma_fence && !bo_data->dmabuf) {
- struct drm_prime_handle arg = {0, };
-
- arg.handle = bo_data->gem;
- if (drmIoctl(bo_data->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) {
- TBM_BACKEND_ERR("Cannot dmabuf=%d\n", bo_data->gem);
- free(bo_data);
- if (error)
- *error = HAL_TBM_ERROR_INVALID_OPERATION;
- return NULL;
- }
- bo_data->dmabuf = arg.fd;
- }
-
/* add bo to hash */
if (drmHashInsert(bufmgr_data->hashBos, bo_data->name, (void *)bo_data) < 0)
TBM_BACKEND_ERR("error Cannot insert bo to Hash(%d)\n", bo_data->name);
@@ -1158,173 +1116,6 @@ tbm_dumb_bo_unmap(hal_tbm_bo *bo)
return HAL_TBM_ERROR_NONE;
}
-static hal_tbm_error
-tbm_dumb_bo_lock(hal_tbm_bo *bo, hal_tbm_bo_device_type device,
- hal_tbm_bo_access_option opt)
-{
-#if USE_BACKEND_LOCK
- tbm_dumb_bo *bo_data = (tbm_dumb_bo *)bo;
- tbm_dumb_bufmgr *bufmgr_data;
- struct dma_buf_fence fence;
- struct flock filelock;
- int ret = 0;
-
- if (!bo_data)
- return HAL_TBM_ERROR_INVALID_PARAMETER;
-
- bufmgr_data = bo_data->bufmgr_data;
- if (!bufmgr_data)
- return HAL_TBM_ERROR_INVALID_PARAMETER;
-
- if (device != TBM_DEVICE_3D && device != TBM_DEVICE_CPU) {
- TBM_BACKEND_DBG("Not support device type,\n");
- return HAL_TBM_ERROR_INVALID_OPERATION;
- }
-
- if (!bufmgr_data->use_dma_fence)
- return HAL_TBM_ERROR_INVALID_OPERATION;
-
- memset(&fence, 0, sizeof(struct dma_buf_fence));
-
- /* Check if the given type is valid or not. */
- if (opt & HAL_TBM_OPTION_WRITE) {
- if (device == HAL_TBM_DEVICE_3D)
- fence.type = DMA_BUF_ACCESS_WRITE | DMA_BUF_ACCESS_DMA;
- } else if (opt & HAL_TBM_OPTION_READ) {
- if (device == HAL_TBM_DEVICE_3D)
- fence.type = DMA_BUF_ACCESS_READ | DMA_BUF_ACCESS_DMA;
- } else {
- TBM_BACKEND_ERR("error Invalid argument\n");
- return HAL_TBM_ERROR_INVALID_PARAMETER;
- }
-
- /* Check if the tbm manager supports dma fence or not. */
- if (!bufmgr_data->use_dma_fence) {
- TBM_BACKEND_ERR("Not support DMA FENCE (%m)\n");
- return HAL_TBM_ERROR_INVALID_OPERATION;
- }
-
- if (device == HAL_TBM_DEVICE_3D) {
- ret = ioctl(bo_data->dmabuf, DMABUF_IOCTL_GET_FENCE, &fence);
- if (ret < 0) {
- TBM_BACKEND_ERR("Cannot set GET FENCE (%m)\n");
- return HAL_TBM_ERROR_INVALID_OPERATION;
- }
- } else {
- if (opt & HAL_TBM_OPTION_WRITE)
- filelock.l_type = F_WRLCK;
- else
- filelock.l_type = F_RDLCK;
-
- filelock.l_whence = SEEK_CUR;
- filelock.l_start = 0;
- filelock.l_len = 0;
-
- if (-1 == fcntl(bo_data->dmabuf, F_SETLKW, &filelock))
- return HAL_TBM_ERROR_INVALID_OPERATION;
- }
-
- pthread_mutex_lock(&bo_data->mutex);
-
- if (device == HAL_TBM_DEVICE_3D) {
- int i;
- for (i = 0; i < DMA_FENCE_LIST_MAX; i++) {
- if (bo_data->dma_fence[i].ctx == 0) {
- bo_data->dma_fence[i].type = fence.type;
- bo_data->dma_fence[i].ctx = fence.ctx;
- break;
- }
- }
-
- if (i == DMA_FENCE_LIST_MAX) {
- //TODO: if dma_fence list is full, it needs realloc. I will fix this. by minseok3.kim
- TBM_BACKEND_ERR("fence list is full\n");
- }
- }
-
- pthread_mutex_unlock(&bo_data->mutex);
-
- TBM_BACKEND_DBG("DMABUF_IOCTL_GET_FENCE! bo_data:%p, gem:%d(%d), fd:%ds\n",
- bo_data,
- bo_data->gem, bo_data->name,
- bo_data->dmabuf);
-#endif
-
- return HAL_TBM_ERROR_NONE;
-}
-
-static hal_tbm_error
-tbm_dumb_bo_unlock(hal_tbm_bo *bo)
-{
-#if USE_BACKEND_LOCK
- tbm_dumb_bo *bo_data = (tbm_dumb_bo *)bo;
- tbm_dumb_bufmgr *bufmgr_data;
- struct dma_buf_fence fence;
- struct flock filelock;
- unsigned int dma_type = 0;
- int ret = 0;
-
- bufmgr_data = bo_data->bufmgr_data;
- if (!bufmgr_data)
- return HAL_TBM_ERROR_INVALID_PARAMETER;
-
- if (!bufmgr_data->use_dma_fence)
- return HAL_TBM_ERROR_INVALID_OPERATION;
-
- if (bo_data->dma_fence[0].type & DMA_BUF_ACCESS_DMA)
- dma_type = 1;
-
- if (!bo_data->dma_fence[0].ctx && dma_type) {
- TBM_BACKEND_DBG("FENCE not support or ignored,\n");
- return HAL_TBM_ERROR_INVALID_OPERATION;
- }
-
- if (!bo_data->dma_fence[0].ctx && dma_type) {
- TBM_BACKEND_DBG("device type is not 3D/CPU,\n");
- return HAL_TBM_ERROR_INVALID_OPERATION;
- }
-
- pthread_mutex_lock(&bo_data->mutex);
-
- if (dma_type) {
- fence.type = bo_data->dma_fence[0].type;
- fence.ctx = bo_data->dma_fence[0].ctx;
- int i;
- for (i = 1; i < DMA_FENCE_LIST_MAX; i++) {
- bo_data->dma_fence[i-1].type = bo_data->dma_fence[i].type;
- bo_data->dma_fence[i-1].ctx = bo_data->dma_fence[i].ctx;
- }
- bo_data->dma_fence[DMA_FENCE_LIST_MAX-1].type = 0;
- bo_data->dma_fence[DMA_FENCE_LIST_MAX-1].ctx = 0;
- }
-
- pthread_mutex_unlock(&bo_data->mutex);
-
- if (dma_type) {
- ret = ioctl(bo_data->dmabuf, DMABUF_IOCTL_PUT_FENCE, &fence);
- if (ret < 0) {
- TBM_BACKEND_ERR("Can not set PUT FENCE (%m)\n");
- return HAL_TBM_ERROR_INVALID_OPERATION;
- }
- } else {
- filelock.l_type = F_UNLCK;
- filelock.l_whence = SEEK_CUR;
- filelock.l_start = 0;
- filelock.l_len = 0;
-
- if (-1 == fcntl(bo_data->dmabuf, F_SETLKW, &filelock))
- return HAL_TBM_ERROR_INVALID_OPERATION;
- }
-
- TBM_BACKEND_DBG("DMABUF_IOCTL_PUT_FENCE! bo_data:%p, gem:%d(%d), fd:%ds\n",
- bo_data,
- bo_data->gem, bo_data->name,
- bo_data->dmabuf);
-#endif
-
- return HAL_TBM_ERROR_NONE;
-}
-
hal_tbm_fd
tbm_dumb_bo_export_fd(hal_tbm_bo *bo, hal_tbm_error *error)
{
@@ -1454,7 +1245,6 @@ hal_backend_tbm_dumb_init(void **data)
hal_tbm_bo_funcs *bo_funcs = NULL;
tbm_dumb_bufmgr *bufmgr_data = NULL;
int drm_fd = -1;
- int fp;
uint64_t cap = 0;
uint32_t ret;
@@ -1511,18 +1301,6 @@ hal_backend_tbm_dumb_init(void **data)
TBM_BACKEND_INFO("A backend requests an authenticated drm_fd.\n");
}
- //Check if the tbm manager supports dma fence or not.
- fp = open("/sys/module/dmabuf_sync/parameters/enabled", O_RDONLY);
- if (fp != -1) {
- char buf[1];
- int length = read(fp, buf, 1);
-
- if (length == 1 && buf[0] == '1')
- bufmgr_data->use_dma_fence = 1;
-
- close(fp);
- }
-
/*Create Hash Table*/
bufmgr_data->hashBos = drmHashCreate();
@@ -1556,8 +1334,8 @@ hal_backend_tbm_dumb_init(void **data)
bo_funcs->bo_get_handle = tbm_dumb_bo_get_handle;
bo_funcs->bo_map = tbm_dumb_bo_map;
bo_funcs->bo_unmap = tbm_dumb_bo_unmap;
- bo_funcs->bo_lock = tbm_dumb_bo_lock;
- bo_funcs->bo_unlock = tbm_dumb_bo_unlock;
+ bo_funcs->bo_lock = NULL;
+ bo_funcs->bo_unlock = NULL;
bo_funcs->bo_export_fd = tbm_dumb_bo_export_fd;
bo_funcs->bo_export_key = tbm_dumb_bo_export_key;