From f43735d9b821a838aacc013316ae154b0483cadf Mon Sep 17 00:00:00 2001 From: Ayoung Sim Date: Wed, 11 Apr 2018 13:51:11 +0900 Subject: [PATCH] media: mfc: supports B frame encoding of NAL_Q Change-Id: Ib53621c9bae74b3d58281312c5dd69de9c9426a4 Signed-off-by: Ayoung Sim --- .../media/platform/exynos/mfc/s5p_mfc_irq.c | 39 ++++++++++--------- .../media/platform/exynos/mfc/s5p_mfc_nal_q.c | 32 +++++++++------ 2 files changed, 42 insertions(+), 29 deletions(-) diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_irq.c b/drivers/media/platform/exynos/mfc/s5p_mfc_irq.c index 6ca13cafa96c..228679f98349 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_irq.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_irq.c @@ -815,6 +815,10 @@ static void mfc_handle_stream_input(struct s5p_mfc_ctx *ctx, int slice_type) for (i = 0; i < raw->num_planes; i++) mfc_debug(2, "encoded[%d] addr: 0x%08llx\n", i, enc_addr[i]); + if (enc_addr[0] == 0) { + mfc_debug(3, "no encoded addr by B frame\n"); + return; + } if (IS_BUFFER_BATCH_MODE(ctx)) { src_mb = s5p_mfc_find_first_buf(&ctx->buf_queue_lock, @@ -854,22 +858,26 @@ static void mfc_handle_stream_input(struct s5p_mfc_ctx *ctx, int slice_type) &ctx->src_ctrls[index]) < 0) mfc_err_ctx("failed in recover_buf_ctrls_val\n"); + mfc_debug(3, "find src buf in src_queue\n"); vb2_buffer_done(&src_mb->vb.vb2_buf, VB2_BUF_STATE_DONE); /* encoder src buffer CFW UNPROT */ if (ctx->is_drm) s5p_mfc_raw_unprotect(ctx, src_mb, index); - } - - ref_mb = s5p_mfc_find_del_buf(&ctx->buf_queue_lock, - &ctx->ref_buf_queue, enc_addr[0]); - if (ref_mb) { - vb2_buffer_done(&ref_mb->vb.vb2_buf, VB2_BUF_STATE_DONE); - - /* encoder src buffer CFW UNPROT */ - if (ctx->is_drm) { - index = ref_mb->vb.vb2_buf.index; - s5p_mfc_raw_unprotect(ctx, ref_mb, index); + } else { + mfc_debug(3, "no src buf in src_queue\n"); + ref_mb = s5p_mfc_find_del_buf(&ctx->buf_queue_lock, + &ctx->ref_buf_queue, enc_addr[0]); + if (ref_mb) { + vb2_buffer_done(&ref_mb->vb.vb2_buf, VB2_BUF_STATE_DONE); + + /* encoder src buffer CFW UNPROT */ + if (ctx->is_drm) { + index = ref_mb->vb.vb2_buf.index; + s5p_mfc_raw_unprotect(ctx, ref_mb, index); + } + } else { + mfc_err_ctx("couldn't find src buffer\n"); } } } @@ -877,7 +885,7 @@ static void mfc_handle_stream_input(struct s5p_mfc_ctx *ctx, int slice_type) src_mb = s5p_mfc_get_del_buf(&ctx->buf_queue_lock, &ctx->src_buf_queue, MFC_BUF_NO_TOUCH_USED); if (!src_mb) { - mfc_err_dev("no src buffers.\n"); + mfc_err_ctx("no src buffers.\n"); return; } @@ -1010,14 +1018,9 @@ static int mfc_handle_stream(struct s5p_mfc_ctx *ctx) if (ctx->enc_res_change_re_input) ctx->enc_res_change_re_input = 0; - if (s5p_mfc_is_queue_count_greater(&ctx->buf_queue_lock, &ctx->src_buf_queue, 0) && - ((ctx->state == MFCINST_RUNNING) || - (ctx->state == MFCINST_RUNNING_NO_OUTPUT) || - (ctx->state == MFCINST_RUNNING_BUF_FULL))) { - + if (s5p_mfc_is_queue_count_greater(&ctx->buf_queue_lock, &ctx->src_buf_queue, 0)) { s5p_mfc_move_first_buf_used(&ctx->buf_queue_lock, &ctx->ref_buf_queue, &ctx->src_buf_queue, MFC_QUEUE_ADD_BOTTOM); - /* * slice_type = 4 && strm_size = 0, skipped enable * should be considered 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 399690b1dc2d..c6cfc531aa1e 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_nal_q.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_nal_q.c @@ -855,6 +855,11 @@ static void mfc_nal_q_handle_stream_input(struct s5p_mfc_ctx *ctx, int slice_typ mfc_debug(2, "NAL Q: encoded[%d] addr: 0x%08llx\n", i, enc_addr[i]); + if (enc_addr[0] == 0) { + mfc_debug(3, "NAL Q: no encoded addr by B frame\n"); + return; + } + if (IS_BUFFER_BATCH_MODE(ctx)) { src_mb = s5p_mfc_find_first_buf(&ctx->buf_queue_lock, &ctx->src_buf_queue, enc_addr[0]); @@ -885,19 +890,24 @@ static void mfc_nal_q_handle_stream_input(struct s5p_mfc_ctx *ctx, int slice_typ } else { src_mb = s5p_mfc_find_del_buf(&ctx->buf_queue_lock, &ctx->src_buf_nal_queue, enc_addr[0]); - if (!src_mb) { - mfc_err_dev("NAL Q: no src buffers\n"); - return; + if (src_mb) { + mfc_debug(3, "find src buf in src_queue\n"); + vb2_buffer_done(&src_mb->vb.vb2_buf, VB2_BUF_STATE_DONE); + } else { + mfc_debug(3, "no src buf in src_queue\n"); + ref_mb = s5p_mfc_find_del_buf(&ctx->buf_queue_lock, + &ctx->ref_buf_queue, enc_addr[0]); + if (ref_mb) { + mfc_debug(3, "find src buf in ref_queue\n"); + vb2_buffer_done(&ref_mb->vb.vb2_buf, VB2_BUF_STATE_DONE); + } else { + mfc_err_dev("NAL Q: no src buffers\n"); + return; + } } - - vb2_buffer_done(&src_mb->vb.vb2_buf, VB2_BUF_STATE_DONE); - - ref_mb = s5p_mfc_find_del_buf(&ctx->buf_queue_lock, - &ctx->ref_buf_queue, enc_addr[0]); - if (ref_mb) - vb2_buffer_done(&ref_mb->vb.vb2_buf, VB2_BUF_STATE_DONE); } - } else if (s5p_mfc_is_queue_count_greater(&ctx->buf_queue_lock, &ctx->src_buf_nal_queue, 0)) { + } + if (s5p_mfc_is_queue_count_greater(&ctx->buf_queue_lock, &ctx->src_buf_nal_queue, 0)) { if (IS_BUFFER_BATCH_MODE(ctx)) return; -- 2.20.1