[COMMON] media: mfc: use released buffer in dec only
authorJeonghee Kim <jhhhh.kim@samsung.com>
Thu, 7 Jun 2018 10:07:21 +0000 (19:07 +0900)
committerSunyoung Kang <sy0816.kang@samsung.com>
Mon, 23 Jul 2018 06:12:18 +0000 (15:12 +0900)
Change-Id: I42dff38672689eee66890781e06e5b94aca7565b
Signed-off-by: Jeonghee Kim <jhhhh.kim@samsung.com>
drivers/media/platform/exynos/mfc/s5p_mfc.c
drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h
drivers/media/platform/exynos/mfc/s5p_mfc_dec_vb2_ops.c
drivers/media/platform/exynos/mfc/s5p_mfc_irq.c
drivers/media/platform/exynos/mfc/s5p_mfc_nal_q.c
drivers/media/platform/exynos/mfc/s5p_mfc_queue.c

index 3a7690822a676bee885f7666541ba12238d7390d..28018fa038c05c92a79de76e0871eb6d5df445e4 100644 (file)
@@ -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;
index 3b52cbb31bc0556003408de0347ca6a1d1e4f95f..47d02b6761eb9fe9d8f6c5259bd9f904452e7fe3 100644 (file)
@@ -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];
index 25a5e83c2d068a87832150b50a274d5164b11671..57c86ffae5d7607f8de5354cd787a4d9590687d7 100644 (file)
@@ -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);
 
index 74a17ee382d34099e7d5f10a873a66c7373a01da..9b1f2f77eea7d075fb4f91bfcd5ccafae1e97b7a 100644 (file)
@@ -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)
index af2a9a9f06be923576e73d1c74c7338c521fef3f..c05e438fe3f5f2c7ef9a2dbf80d092c9509ca906 100644 (file)
@@ -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)
index 9e701ca60d76c5abb6a03b360cf2a10c9a74a30b..57740d049a8fc7b67090ff7ce1e8535954cd7164 100644 (file)
@@ -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)) {