From c71f885fe206a10366391a9c37ce069fee632552 Mon Sep 17 00:00:00 2001 From: Jeonghee Kim Date: Thu, 7 Jun 2018 19:07:21 +0900 Subject: [PATCH] [COMMON] media: mfc: use released buffer in dec only Change-Id: I42dff38672689eee66890781e06e5b94aca7565b Signed-off-by: Jeonghee Kim --- drivers/media/platform/exynos/mfc/s5p_mfc.c | 1 + .../media/platform/exynos/mfc/s5p_mfc_data_struct.h | 1 + .../media/platform/exynos/mfc/s5p_mfc_dec_vb2_ops.c | 1 + drivers/media/platform/exynos/mfc/s5p_mfc_irq.c | 5 ++++- drivers/media/platform/exynos/mfc/s5p_mfc_nal_q.c | 5 ++++- drivers/media/platform/exynos/mfc/s5p_mfc_queue.c | 12 ++++++++++++ 6 files changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc.c b/drivers/media/platform/exynos/mfc/s5p_mfc.c index 3a7690822a67..28018fa038c0 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc.c @@ -157,6 +157,7 @@ static int mfc_init_dec_ctx(struct s5p_mfc_ctx *ctx) dec->immediate_display = 0; dec->is_dts_mode = 0; dec->err_reuse_flag = 0; + dec->dec_only_release_flag = 0; dec->is_dynamic_dpb = 1; dec->dynamic_used = 0; diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h b/drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h index 3b52cbb31bc0..47d02b6761eb 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h @@ -1229,6 +1229,7 @@ struct s5p_mfc_dec { int is_dpb_full; unsigned int err_reuse_flag; + unsigned int dec_only_release_flag; /* for debugging about black bar detection */ void *frame_vaddr[3][30]; diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_dec_vb2_ops.c b/drivers/media/platform/exynos/mfc/s5p_mfc_dec_vb2_ops.c index 25a5e83c2d06..57c86ffae5d7 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_dec_vb2_ops.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_dec_vb2_ops.c @@ -449,6 +449,7 @@ static void mfc_dec_dst_stop_streaming(struct s5p_mfc_ctx *ctx) dec->dynamic_used = 0; dec->err_reuse_flag = 0; + dec->dec_only_release_flag = 0; s5p_mfc_cleanup_queue(&ctx->buf_queue_lock, &ctx->dst_buf_queue); diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_irq.c b/drivers/media/platform/exynos/mfc/s5p_mfc_irq.c index 74a17ee382d3..9b1f2f77eea7 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_irq.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_irq.c @@ -519,7 +519,10 @@ static void mfc_handle_reuse_buffer(struct s5p_mfc_ctx *ctx) released_flag &= ~(1 << i); /* Not reused buffer should be released when there is a display frame */ - dec->dynamic_used |= released_flag; + dec->dec_only_release_flag |= released_flag; + for (i = 0; i < MFC_MAX_DPBS; i++) + if (released_flag & (1 << i)) + clear_bit(i, &dec->available_dpb); } static void mfc_handle_frame_input(struct s5p_mfc_ctx *ctx, unsigned int err) diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_nal_q.c b/drivers/media/platform/exynos/mfc/s5p_mfc_nal_q.c index af2a9a9f06be..c05e438fe3f5 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_nal_q.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_nal_q.c @@ -1116,7 +1116,10 @@ static void mfc_nal_q_handle_reuse_buffer(struct s5p_mfc_ctx *ctx, DecoderOutput released_flag &= ~(1 << i); /* Not reused buffer should be released when there is a display frame */ - dec->dynamic_used |= released_flag; + dec->dec_only_release_flag |= released_flag; + for (i = 0; i < MFC_MAX_DPBS; i++) + if (released_flag & (1 << i)) + clear_bit(i, &dec->available_dpb); } static void mfc_nal_q_handle_ref_frame(struct s5p_mfc_ctx *ctx, DecoderOutputStr *pOutStr) diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_queue.c b/drivers/media/platform/exynos/mfc/s5p_mfc_queue.c index 9e701ca60d76..57740d049a8f 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_queue.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_queue.c @@ -674,6 +674,18 @@ void s5p_mfc_handle_released_info(struct s5p_mfc_ctx *ctx, } refBuf = &dec->ref_info[index]; + if (dec->dec_only_release_flag) { + for (t = 0; t < MFC_MAX_DPBS; t++) { + if (dec->dec_only_release_flag & (1 << t)) { + mfc_debug(2, "Release FD[%d] = %03d (already released in dec only)\n", + t, dec->assigned_fd[t]); + refBuf->dpb[ncount].fd[0] = dec->assigned_fd[t]; + ncount++; + dec->dec_only_release_flag &= ~(1 << t); + } + } + } + if (released_flag) { for (t = 0; t < MFC_MAX_DPBS; t++) { if (released_flag & (1 << t)) { -- 2.20.1