From 3d087da22e2d5058ce402a25a47ef6dac1bce3c4 Mon Sep 17 00:00:00 2001 From: Cho KyongHo Date: Fri, 13 Apr 2018 14:02:46 +0900 Subject: [PATCH] [COMMON] media: mfc: move to the new dma-buf-container The new, working dma-buf-container is introduced by the commit ee1d9055d ('dma-buf: introduce dma-buf container'). It still supports the same API functions but the contexts are slightly changed because the design of dma-buf-container is changed. Specifically, dmabuf_container_get_count() now returns -EINVAL instead of 0 for the dma-bufs that is not a dma-buf-container. This change of return value comes from the fact that dma-buf-container allows having no dma-buf by its design although it is impossible to create an empty dma-buf-container in practice. Change-Id: I38b7534b2e0bb30e8ec331d019a089736d847dbe Signed-off-by: Cho KyongHo --- drivers/media/platform/exynos/mfc/s5p_mfc_common.h | 2 +- drivers/media/platform/exynos/mfc/s5p_mfc_enc_vb2_ops.c | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_common.h b/drivers/media/platform/exynos/mfc/s5p_mfc_common.h index ae107bf7bf7a..927992ac5b89 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_common.h +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_common.h @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_enc_vb2_ops.c b/drivers/media/platform/exynos/mfc/s5p_mfc_enc_vb2_ops.c index df3bfe47aba4..2917b444a2d0 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_enc_vb2_ops.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_enc_vb2_ops.c @@ -204,6 +204,15 @@ static int s5p_mfc_enc_buf_prepare(struct vb2_buffer *vb) buf->num_bufs_in_vb = s5p_mfc_bufcon_get_buf_count(dmabuf); mfc_debug(3, "bufcon count:%d\n", buf->num_bufs_in_vb); + if (buf->num_bufs_in_vb == 0) { + mfc_err_ctx("bufcon count couldn't be zero\n"); + s5p_mfc_mem_put_dmabuf(dmabuf); + return -ENOMEM; + } + + if (buf->num_bufs_in_vb < 0) + buf->num_bufs_in_vb = 0; + if (!ctx->batch_mode && buf->num_bufs_in_vb > 0) { ctx->batch_mode = 1; mfc_debug(3, "buffer batch mode enabled\n"); -- 2.20.1