From 223244caa7e0d9726fa60ab6bdf4c7b23a7c1caf Mon Sep 17 00:00:00 2001 From: Ayoung Sim Date: Fri, 26 Oct 2018 09:12:40 +0900 Subject: [PATCH] [RAMEN9610-10029][COMMON] media: mfc: add the MFCINST_FINISHED status MFCINST_FINISHED status has following meaning. Instance has already been opened but can't do anything. When new format settings come, encoding can be re-started begin with SEQ_START. Change-Id: I679f77541942db75db9ba76e936b88668ba25e45 Signed-off-by: Ayoung Sim --- drivers/media/platform/exynos/mfc/mfc_data_struct.h | 2 +- drivers/media/platform/exynos/mfc/mfc_enc_v4l2.c | 6 +++--- drivers/media/platform/exynos/mfc/mfc_enc_vb2.c | 10 ++++------ drivers/media/platform/exynos/mfc/mfc_isr.c | 4 ++-- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/exynos/mfc/mfc_data_struct.h b/drivers/media/platform/exynos/mfc/mfc_data_struct.h index 5c8224849fb9..bda4b0556eaa 100644 --- a/drivers/media/platform/exynos/mfc/mfc_data_struct.h +++ b/drivers/media/platform/exynos/mfc/mfc_data_struct.h @@ -112,7 +112,7 @@ enum mfc_inst_state { MFCINST_RES_CHANGE_INIT, MFCINST_RES_CHANGE_FLUSH, MFCINST_RES_CHANGE_END, - MFCINST_RUNNING_NO_OUTPUT, // Unused + MFCINST_FINISHED, MFCINST_ABORT_INST, MFCINST_DPB_FLUSHING, MFCINST_SPECIAL_PARSING, diff --git a/drivers/media/platform/exynos/mfc/mfc_enc_v4l2.c b/drivers/media/platform/exynos/mfc/mfc_enc_v4l2.c index e64ce08206c5..221cec3942e1 100644 --- a/drivers/media/platform/exynos/mfc/mfc_enc_v4l2.c +++ b/drivers/media/platform/exynos/mfc/mfc_enc_v4l2.c @@ -526,7 +526,7 @@ static int mfc_enc_s_fmt_vid_out_mplane(struct file *file, void *priv, __mfc_enc_check_format(ctx); - if (ctx->state == MFCINST_RUNNING) { + if (ctx->state == MFCINST_FINISHED) { mfc_change_state(ctx, MFCINST_GOT_INST); mfc_info_ctx("[DRC] Enc resolution is changed\n"); } @@ -586,8 +586,8 @@ static int mfc_enc_s_crop(struct file *file, void *priv, const struct v4l2_crop if ((cr->c.height > ctx->img_height) || (cr->c.top > ctx->img_height) || (cr->c.width > ctx->img_width) || (cr->c.left > ctx->img_width) || - (cr->c.left <= (ctx->img_width - cr->c.width)) || - (cr->c.top <= (ctx->img_height - cr->c.height))) { + (cr->c.left >= (ctx->img_width - cr->c.width)) || + (cr->c.top >= (ctx->img_height - cr->c.height))) { mfc_err_ctx("[FRAME] Out of crop range: (%d,%d,%d,%d) from %dx%d\n", cr->c.left, cr->c.top, cr->c.width, cr->c.height, ctx->img_width, ctx->img_height); diff --git a/drivers/media/platform/exynos/mfc/mfc_enc_vb2.c b/drivers/media/platform/exynos/mfc/mfc_enc_vb2.c index 346113a32f9c..4849e9b55a7b 100644 --- a/drivers/media/platform/exynos/mfc/mfc_enc_vb2.c +++ b/drivers/media/platform/exynos/mfc/mfc_enc_vb2.c @@ -335,7 +335,6 @@ static void mfc_enc_stop_streaming(struct vb2_queue *q) struct mfc_ctx *ctx = q->drv_priv; struct mfc_dev *dev = ctx->dev; int index = 0; - int aborted = 0; int ret = 0; mfc_info_ctx("enc stop_streaming is called, hwlock : %d, type : %d\n", @@ -348,7 +347,6 @@ static void mfc_enc_stop_streaming(struct vb2_queue *q) mfc_err_ctx("time out during nal abort\n"); mfc_cleanup_work_bit_and_try_run(ctx); } - aborted = 1; } ret = mfc_get_hwlock_ctx(ctx); @@ -368,7 +366,7 @@ static void mfc_enc_stop_streaming(struct vb2_queue *q) index++; } } else if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { - if (ctx->state == MFCINST_RUNNING) { + if (ctx->state == MFCINST_RUNNING || ctx->state == MFCINST_FINISHING) { mfc_change_state(ctx, MFCINST_FINISHING); mfc_set_bit(ctx->num, &dev->work_bits); @@ -382,7 +380,7 @@ static void mfc_enc_stop_streaming(struct vb2_queue *q) mfc_err_ctx("Waiting for LAST_SEQ timed out\n"); break; } - if (ctx->state == MFCINST_RUNNING) { + if (ctx->state == MFCINST_FINISHED) { mfc_debug(2, "all encoded buffers out\n"); break; } @@ -402,8 +400,8 @@ static void mfc_enc_stop_streaming(struct vb2_queue *q) } } - if (aborted || ctx->state == MFCINST_FINISHING) - mfc_change_state(ctx, MFCINST_RUNNING); + if (ctx->state == MFCINST_FINISHING) + mfc_change_state(ctx, MFCINST_FINISHED); mfc_debug(2, "buffer cleanup is done in stop_streaming, type : %d\n", q->type); diff --git a/drivers/media/platform/exynos/mfc/mfc_isr.c b/drivers/media/platform/exynos/mfc/mfc_isr.c index 30d82a27066d..ba32eb746b45 100644 --- a/drivers/media/platform/exynos/mfc/mfc_isr.c +++ b/drivers/media/platform/exynos/mfc/mfc_isr.c @@ -1197,7 +1197,7 @@ static int __mfc_handle_seq_enc(struct mfc_ctx *ctx) /* If the ROI is enabled at SEQ_START, clear ROI_ENABLE bit */ mfc_clear_roi_enable(dev); - if (!ctx->codec_buffer_allocated) { + if (ctx->codec_buffer_allocated) { mfc_debug(2, "[DRC] previous codec buffer is exist\n"); if (dev->has_mmcache && dev->mmcache.is_on_status) @@ -1429,7 +1429,7 @@ static int __mfc_irq_ctx(struct mfc_ctx *ctx, unsigned int reason, unsigned int case MFC_REG_R2H_CMD_COMPLETE_SEQ_RET: if (ctx->type == MFCINST_ENCODER) { __mfc_handle_stream(ctx); - mfc_change_state(ctx, MFCINST_RUNNING); + mfc_change_state(ctx, MFCINST_FINISHED); } else if (ctx->type == MFCINST_DECODER) { return __mfc_handle_done_frame(ctx, reason, err); } -- 2.20.1