From 2da2fd53ac9a3673f77bcb9d950de9fba7f5dfde Mon Sep 17 00:00:00 2001 From: Jeonghee Kim Date: Mon, 14 May 2018 14:01:50 +0900 Subject: [PATCH] [COMMON] media: mfc: OTF: change otf initialization sequence. An unnecessary error message was outputted at the time of booting while trying to get HWFC information from a repeater driver that is not initialized. So, the location requesting HWFC information has been changed. (open->s_fmt) Change-Id: Iaefa9670dc367d7987721ec74847ac7e3cd50757 Signed-off-by: Jeonghee Kim --- drivers/media/platform/exynos/mfc/s5p_mfc.c | 13 +++-- .../media/platform/exynos/mfc/s5p_mfc_enc.c | 15 ++++-- .../media/platform/exynos/mfc/s5p_mfc_otf.c | 53 +++++++++++++++---- .../media/platform/exynos/mfc/s5p_mfc_otf.h | 2 + 4 files changed, 64 insertions(+), 19 deletions(-) diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc.c b/drivers/media/platform/exynos/mfc/s5p_mfc.c index 679f1f10c9ef..06eea90ad83e 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc.c @@ -568,10 +568,11 @@ static int s5p_mfc_open(struct file *file) } #ifdef CONFIG_VIDEO_EXYNOS_REPEATER - if (s5p_mfc_is_encoder_otf_node(node)) - ret = s5p_mfc_otf_init(ctx); - if (ret) - mfc_err_ctx("OTF: failed otf init\n"); + if (s5p_mfc_is_encoder_otf_node(node)) { + ret = s5p_mfc_otf_create(ctx); + if (ret) + mfc_err_ctx("OTF: otf_create failed\n"); + } #endif s5p_mfc_perf_init(dev); @@ -771,8 +772,10 @@ static int s5p_mfc_release(struct file *file) mfc_deinit_enc_ctx(ctx); #ifdef CONFIG_VIDEO_EXYNOS_REPEATER - if (ctx->otf_handle) + if (ctx->otf_handle) { s5p_mfc_otf_deinit(ctx); + s5p_mfc_otf_destroy(ctx); + } #endif s5p_mfc_destroy_listable_wq_ctx(ctx); diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c b/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c index ee4567ef8d78..c59e85e33490 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c @@ -339,10 +339,17 @@ static int vidioc_s_fmt_vid_cap_mplane(struct file *file, void *priv, mfc_info_ctx("Enc output codec(%d) : %s\n", ctx->dst_fmt->codec_mode, ctx->dst_fmt->name); - if (ctx->otf_handle && ctx->dst_fmt->fourcc != V4L2_PIX_FMT_H264 && - ctx->dst_fmt->fourcc != V4L2_PIX_FMT_HEVC) { - mfc_err_ctx("OTF: only H.264 and HEVC is supported\n"); - return -EINVAL; + if (ctx->otf_handle) { + if (ctx->dst_fmt->fourcc != V4L2_PIX_FMT_H264 && + ctx->dst_fmt->fourcc != V4L2_PIX_FMT_HEVC) { + mfc_err_ctx("OTF: only H.264 and HEVC is supported\n"); + return -EINVAL; + } + if (s5p_mfc_otf_init(ctx)) { + mfc_err_ctx("OTF: otf_init failed\n"); + s5p_mfc_otf_destroy(ctx); + return -EINVAL; + } } enc->dst_buf_size = pix_fmt_mp->plane_fmt[0].sizeimage; diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_otf.c b/drivers/media/platform/exynos/mfc/s5p_mfc_otf.c index 131829576200..34d19711469f 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_otf.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_otf.c @@ -261,7 +261,7 @@ static void mfc_otf_destroy_handle(struct s5p_mfc_ctx *ctx) mfc_debug_leave(); } -int s5p_mfc_otf_init(struct s5p_mfc_ctx *ctx) +int s5p_mfc_otf_create(struct s5p_mfc_ctx *ctx) { struct s5p_mfc_dev *dev; int i; @@ -291,12 +291,6 @@ int s5p_mfc_otf_init(struct s5p_mfc_ctx *ctx) return -EINVAL; } - if (mfc_otf_init_hwfc_buf(ctx)) { - mfc_err_dev("OTF: HWFC init failed\n"); - mfc_otf_destroy_handle(ctx); - return -EINVAL; - } - if (otf_dump) { /* It is for debugging. Do not return error */ if (s5p_mfc_otf_alloc_stream_buf(ctx)) { @@ -305,6 +299,48 @@ int s5p_mfc_otf_init(struct s5p_mfc_ctx *ctx) } } + mfc_debug(2, "OTF: otf_create is completed\n"); + + mfc_debug_leave(); + + return 0; +} + +void s5p_mfc_otf_destroy(struct s5p_mfc_ctx *ctx) +{ + mfc_debug_enter(); + + if (!ctx) { + mfc_err_dev("OTF: no mfc context to run\n"); + return; + } + + s5p_mfc_otf_release_stream_buf(ctx); + mfc_otf_destroy_handle(ctx); + mfc_debug(2, "OTF: otf_destroy is completed\n"); + + mfc_debug_leave(); +} + +int s5p_mfc_otf_init(struct s5p_mfc_ctx *ctx) +{ + mfc_debug_enter(); + + if (!ctx) { + mfc_err_dev("OTF: no mfc context to run\n"); + return -EINVAL; + } + + if (!ctx->otf_handle) { + mfc_err_dev("OTF: otf_handle was not created\n"); + return -EINVAL; + } + + if (mfc_otf_init_hwfc_buf(ctx)) { + mfc_err_dev("OTF: HWFC init failed\n"); + return -EINVAL; + } + mfc_debug(2, "OTF: otf_init is completed\n"); mfc_debug_leave(); @@ -321,10 +357,7 @@ void s5p_mfc_otf_deinit(struct s5p_mfc_ctx *ctx) return; } - s5p_mfc_otf_release_stream_buf(ctx); mfc_otf_deinit_hwfc_buf(ctx); - mfc_otf_destroy_handle(ctx); - s5p_mfc_qos_off(ctx); mfc_debug(2, "OTF: deinit_otf is completed\n"); mfc_debug_leave(); diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_otf.h b/drivers/media/platform/exynos/mfc/s5p_mfc_otf.h index 1167b2320639..e7b5e5788f45 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_otf.h +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_otf.h @@ -17,6 +17,8 @@ extern struct s5p_mfc_dev *g_mfc_dev; +int s5p_mfc_otf_create(struct s5p_mfc_ctx *ctx); +void s5p_mfc_otf_destroy(struct s5p_mfc_ctx *ctx); int s5p_mfc_otf_init(struct s5p_mfc_ctx *ctx); void s5p_mfc_otf_deinit(struct s5p_mfc_ctx *ctx); int s5p_mfc_otf_ctx_ready(struct s5p_mfc_ctx *ctx); -- 2.20.1