decoder: pass dummy vf to notify eos. [1/1]
authorshihong.zheng <shihong.zheng@amlogic.com>
Fri, 14 Aug 2020 06:47:00 +0000 (14:47 +0800)
committerHui Zhang <hui.zhang@amlogic.com>
Mon, 24 Aug 2020 07:33:01 +0000 (00:33 -0700)
PD#SWPL-31618

Problem:
decoder pass a dummy vf with eos flag to
backend.

Solution:
pass a dummy vf with eos flag when eos recieved.

Verify:
S905Y2

Change-Id: I775678ee94eeb6db3d304f3e44bf0a3f5def70de
Signed-off-by: shihong.zheng <shihong.zheng@amlogic.com>
drivers/frame_provider/decoder/h264_multi/vmh264.c
drivers/frame_provider/decoder/h265/vh265.c
drivers/frame_provider/decoder/mjpeg/vmjpeg_multi.c
drivers/frame_provider/decoder/mpeg12/vmpeg12_multi.c
drivers/frame_provider/decoder/mpeg4/vmpeg4_multi.c
drivers/frame_provider/decoder/vav1/vav1.c
drivers/frame_provider/decoder/vp9/vvp9.c

index 2353767dd322005350fc1f5ff6fd1ee7b9e8b726..a19a634881f68f78a64bab6923e44541cbc75f83 100644 (file)
@@ -3039,18 +3039,20 @@ int notify_v4l_eos(struct vdec_s *vdec)
        int index = INVALID_IDX;
        ulong expires;
 
-       if (hw->is_used_v4l && hw->eos) {
-               expires = jiffies + msecs_to_jiffies(2000);
-               while (INVALID_IDX == (index = v4l_get_free_buf_idx(vdec))) {
-                       if (time_after(jiffies, expires) ||
-                               v4l2_m2m_num_dst_bufs_ready(ctx->m2m_ctx))
-                               break;
-               }
+       if (hw->eos) {
+               if (hw->is_used_v4l) {
+                       expires = jiffies + msecs_to_jiffies(2000);
+                       while (INVALID_IDX == (index = v4l_get_free_buf_idx(vdec))) {
+                               if (time_after(jiffies, expires) ||
+                                       v4l2_m2m_num_dst_bufs_ready(ctx->m2m_ctx))
+                                       break;
+                       }
 
-               if (index == INVALID_IDX) {
-                       if (vdec_v4l_get_buffer(hw->v4l2_ctx, &fb) < 0) {
-                               pr_err("[%d] EOS get free buff fail.\n", ctx->id);
-                               return -1;
+                       if (index == INVALID_IDX) {
+                               if (vdec_v4l_get_buffer(hw->v4l2_ctx, &fb) < 0) {
+                                       pr_err("[%d] EOS get free buff fail.\n", ctx->id);
+                                       return -1;
+                               }
                        }
                }
 
@@ -3066,7 +3068,7 @@ int notify_v4l_eos(struct vdec_s *vdec)
                vf_notify_receiver(vdec->vf_provider_name,
                        VFRAME_EVENT_PROVIDER_VFRAME_READY, NULL);
 
-               pr_info("[%d] H264 EOS notify.\n", ctx->id);
+               pr_info("[%d] H264 EOS notify.\n", (hw->is_used_v4l)?ctx->id:vdec->id);
        }
 
        return 0;
@@ -8835,8 +8837,7 @@ result_done:
                        amhevc_stop();
                hw->eos = 1;
                flush_dpb(p_H264_Dpb);
-               if (hw->is_used_v4l)
-                       notify_v4l_eos(hw_to_vdec(hw));
+               notify_v4l_eos(hw_to_vdec(hw));
                mutex_lock(&hw->chunks_mutex);
                vdec_vframe_dirty(hw_to_vdec(hw), hw->chunk);
                hw->chunk = NULL;
index 6d47ee0ce70bf634d1f277a67b1df2bb3cf80b4e..087257782402e47dff06757ae047ca07f0b30ca2 100644 (file)
@@ -9357,18 +9357,20 @@ static int notify_v4l_eos(struct vdec_s *vdec)
        int index = INVALID_IDX;
        ulong expires;
 
-       if (hw->is_used_v4l && hw->eos) {
-               expires = jiffies + msecs_to_jiffies(2000);
-               while (INVALID_IDX == (index = get_free_buf_idx(hw))) {
-                       if (time_after(jiffies, expires) ||
-                               v4l2_m2m_num_dst_bufs_ready(ctx->m2m_ctx))
-                               break;
-               }
+       if (hw->eos) {
+               if (hw->is_used_v4l) {
+                       expires = jiffies + msecs_to_jiffies(2000);
+                       while (INVALID_IDX == (index = get_free_buf_idx(hw))) {
+                               if (time_after(jiffies, expires) ||
+                                       v4l2_m2m_num_dst_bufs_ready(ctx->m2m_ctx))
+                                       break;
+                       }
 
-               if (index == INVALID_IDX) {
-                       if (vdec_v4l_get_buffer(hw->v4l2_ctx, &fb) < 0) {
-                               pr_err("[%d] EOS get free buff fail.\n", ctx->id);
-                               return -1;
+                       if (index == INVALID_IDX) {
+                               if (vdec_v4l_get_buffer(hw->v4l2_ctx, &fb) < 0) {
+                                       pr_err("[%d] EOS get free buff fail.\n", ctx->id);
+                                       return -1;
+                               }
                        }
                }
 
@@ -9381,7 +9383,7 @@ static int notify_v4l_eos(struct vdec_s *vdec)
                vf_notify_receiver(vdec->vf_provider_name,
                        VFRAME_EVENT_PROVIDER_VFRAME_READY, NULL);
 
-               pr_info("[%d] H265 EOS notify.\n", ctx->id);
+               pr_info("[%d] H265 EOS notify.\n", (hw->is_used_v4l)?ctx->id:vdec->id);
        }
 
        return 0;
@@ -12538,9 +12540,8 @@ static void vh265_work_implement(struct hevc_state_s *hevc,
                        "%s: end of stream, last dec poc %d => 0x%pf\n",
                        __func__, hevc->curr_POC, pic);
                flush_output(hevc, pic);
-
-               if (hevc->is_used_v4l)
-                       notify_v4l_eos(hw_to_vdec(hevc));
+               /* dummy vf with eos flag to backend */
+               notify_v4l_eos(hw_to_vdec(hevc));
 #ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION
                hevc->shift_byte_count_lo
                        = READ_VREG(HEVC_SHIFT_BYTE_COUNT);
index 06b2f50b63a5f1810ea6fc53cf0af60381306e93..62592bf76ec6bd65c9fe91bb3c8f07c427bdd12c 100644 (file)
@@ -1422,9 +1422,9 @@ static int notify_v4l_eos(struct vdec_s *vdec)
        struct aml_vcodec_ctx *ctx = (struct aml_vcodec_ctx *)(hw->v4l2_ctx);
        struct vframe_s *vf = NULL;
        struct vdec_v4l2_buffer *fb = NULL;
-       int index;
+       int index = -1;
 
-       if (hw->is_used_v4l && hw->eos) {
+       if (hw->eos) {
                if (kfifo_get(&hw->newframe_q, &vf) == 0 || vf == NULL) {
                        mmjpeg_debug_print(DECODE_ID(hw), PRINT_FLAG_ERROR,
                                "%s fatal error, no available buffer slot.\n",
@@ -1432,11 +1432,12 @@ static int notify_v4l_eos(struct vdec_s *vdec)
                        return -1;
                }
 
-               index = find_free_buffer(hw);
-
-               if ((index == -1) && vdec_v4l_get_buffer(hw->v4l2_ctx, &fb)) {
-                       pr_err("[%d] get fb fail.\n", ctx->id);
-                       return -1;
+               if (hw->is_used_v4l) {
+                       index = find_free_buffer(hw);
+                       if ((index == -1) && vdec_v4l_get_buffer(hw->v4l2_ctx, &fb)) {
+                               pr_err("[%d] get fb fail.\n", ctx->id);
+                               return -1;
+                       }
                }
 
                vf->type |= VIDTYPE_V4L_EOS;
@@ -1449,7 +1450,7 @@ static int notify_v4l_eos(struct vdec_s *vdec)
                vf_notify_receiver(vdec->vf_provider_name,
                        VFRAME_EVENT_PROVIDER_VFRAME_READY, NULL);
 
-               pr_info("[%d] mpeg12 EOS notify.\n", ctx->id);
+               pr_info("[%d] mpeg12 EOS notify.\n", (hw->is_used_v4l)?ctx->id:vdec->id);
        }
 
        return 0;
@@ -1495,8 +1496,7 @@ static void vmjpeg_work(struct work_struct *work)
                        hw->stat &= ~STAT_VDEC_RUN;
                }
                hw->eos = 1;
-               if (hw->is_used_v4l)
-                       notify_v4l_eos(vdec);
+               notify_v4l_eos(vdec);
 
                vdec_vframe_dirty(hw_to_vdec(hw), hw->chunk);
                hw->chunk = NULL;
index 832e3c3264ceffdc27f75b7e37870e0828fb31c0..c830960473e1c8c94ed8f5d89f1e540346d118d6 100644 (file)
@@ -2118,20 +2118,22 @@ static int notify_v4l_eos(struct vdec_s *vdec)
        struct aml_vcodec_ctx *ctx = (struct aml_vcodec_ctx *)(hw->v4l2_ctx);
        struct vframe_s *vf = NULL;
        struct vdec_v4l2_buffer *fb = NULL;
-       int index;
+       int index = -1;
 
-       if (hw->is_used_v4l && hw->eos) {
+       if (hw->eos) {
                if (kfifo_get(&hw->newframe_q, &vf) == 0 || vf == NULL) {
                        debug_print(DECODE_ID(hw), PRINT_FLAG_ERROR,
                                "%s fatal error, no available buffer slot.\n",
                                __func__);
                        return -1;
                }
-               index = find_free_buffer(hw);
-               if ((index == -1) &&
-                       vdec_v4l_get_buffer(hw->v4l2_ctx, &fb)) {
-                       pr_err("[%d] get fb fail.\n", ctx->id);
-                       return -1;
+               if (hw->is_used_v4l) {
+                       index = find_free_buffer(hw);
+                       if ((index == -1) &&
+                               vdec_v4l_get_buffer(hw->v4l2_ctx, &fb)) {
+                               pr_err("[%d] get fb fail.\n", ctx->id);
+                               return -1;
+                       }
                }
 
                vf->type |= VIDTYPE_V4L_EOS;
@@ -2144,7 +2146,7 @@ static int notify_v4l_eos(struct vdec_s *vdec)
                vf_notify_receiver(vdec->vf_provider_name,
                        VFRAME_EVENT_PROVIDER_VFRAME_READY, NULL);
 
-               pr_info("[%d] mpeg12 EOS notify.\n", ctx->id);
+               pr_info("[%d] mpeg12 EOS notify.\n", (hw->is_used_v4l)?ctx->id:vdec->id);
        }
 
        return 0;
@@ -2245,8 +2247,7 @@ static void vmpeg12_work_implement(struct vdec_mpeg12_hw_s *hw,
                hw->chunk = NULL;
                vdec_clean_input(vdec);
                flush_output(hw);
-               if (hw->is_used_v4l)
-                       notify_v4l_eos(vdec);
+               notify_v4l_eos(vdec);
 
                debug_print(DECODE_ID(hw), 0,
                        "%s: end of stream, num %d(%d)\n",
index 0bb416c7c63b75ccfe6df8ac2cdcdb67b110aa02..6d27c7d25e4431c6cb253c8639bb729e537a6ba1 100644 (file)
@@ -1398,9 +1398,9 @@ static int notify_v4l_eos(struct vdec_s *vdec)
        struct aml_vcodec_ctx *ctx = (struct aml_vcodec_ctx *)(hw->v4l2_ctx);
        struct vframe_s *vf = NULL;
        struct vdec_v4l2_buffer *fb = NULL;
-       int index;
+       int index = -1;
 
-       if (hw->is_used_v4l && hw->eos) {
+       if (hw->eos) {
                if (kfifo_get(&hw->newframe_q, &vf) == 0 || vf == NULL) {
                        mmpeg4_debug_print(DECODE_ID(hw), PRINT_FLAG_ERROR,
                                "%s fatal error, no available buffer slot.\n",
@@ -1408,12 +1408,13 @@ static int notify_v4l_eos(struct vdec_s *vdec)
                        return -1;
                }
 
-               index = find_free_buffer(hw);
-
-               if ((index == -1) &&
-                               vdec_v4l_get_buffer(hw->v4l2_ctx, &fb)) {
-                       pr_err("[%d] get fb fail.\n", ctx->id);
-                       return -1;
+               if (hw->is_used_v4l) {
+                       index = find_free_buffer(hw);
+                       if ((index == -1) &&
+                                       vdec_v4l_get_buffer(hw->v4l2_ctx, &fb)) {
+                               pr_err("[%d] get fb fail.\n", ctx->id);
+                               return -1;
+                       }
                }
 
                vf->type |= VIDTYPE_V4L_EOS;
@@ -1426,7 +1427,7 @@ static int notify_v4l_eos(struct vdec_s *vdec)
                vf_notify_receiver(vdec->vf_provider_name,
                        VFRAME_EVENT_PROVIDER_VFRAME_READY, NULL);
 
-               pr_info("[%d] mpeg4 EOS notify.\n", ctx->id);
+               pr_info("[%d] mpeg4 EOS notify.\n", (hw->is_used_v4l)?ctx->id:vdec->id);
        }
 
        return 0;
@@ -1486,9 +1487,7 @@ static void vmpeg4_work(struct work_struct *work)
                hw->chunk = NULL;
                vdec_clean_input(vdec);
                flush_output(hw);
-
-               if (hw->is_used_v4l)
-                       notify_v4l_eos(vdec);
+               notify_v4l_eos(vdec);
 
                mmpeg4_debug_print(DECODE_ID(hw), 0,
                        "%s: eos flushed, frame_num %d\n",
index 24bb51975a2b001e706e56bc291c9fa3c813aa13..f46c25b7df5efa33ecbf02647b2803e97621ca0c 100644 (file)
@@ -6309,18 +6309,20 @@ static int notify_v4l_eos(struct vdec_s *vdec)
        int index = INVALID_IDX;
        ulong expires;
 
-       if (hw->is_used_v4l && hw->eos) {
-               expires = jiffies + msecs_to_jiffies(2000);
-               while (INVALID_IDX == (index = v4l_get_free_fb(hw))) {
-                       if (time_after(jiffies, expires) ||
-                               v4l2_m2m_num_dst_bufs_ready(ctx->m2m_ctx))
-                               break;
-               }
+       if (hw->eos) {
+               if (hw->is_used_v4l) {
+                       expires = jiffies + msecs_to_jiffies(2000);
+                       while (INVALID_IDX == (index = v4l_get_free_fb(hw))) {
+                               if (time_after(jiffies, expires) ||
+                                       v4l2_m2m_num_dst_bufs_ready(ctx->m2m_ctx))
+                                       break;
+                       }
 
-               if (index == INVALID_IDX) {
-                       if (vdec_v4l_get_buffer(hw->v4l2_ctx, &fb) < 0) {
-                               pr_err("[%d] EOS get free buff fail.\n", ctx->id);
-                               return -1;
+                       if (index == INVALID_IDX) {
+                               if (vdec_v4l_get_buffer(hw->v4l2_ctx, &fb) < 0) {
+                                       pr_err("[%d] EOS get free buff fail.\n", ctx->id);
+                                       return -1;
+                               }
                        }
                }
 
@@ -6335,7 +6337,7 @@ static int notify_v4l_eos(struct vdec_s *vdec)
                        VFRAME_EVENT_PROVIDER_VFRAME_READY, NULL);
 
                av1_print(hw, PRINT_FLAG_V4L_DETAIL,
-                       "[%d] AV1 EOS notify.\n", ctx->id);
+                       "[%d] AV1 EOS notify.\n", (hw->is_used_v4l)?ctx->id:vdec->id);
        }
 
        return 0;
@@ -9489,8 +9491,7 @@ static void av1_work(struct work_struct *work)
                hw->eos = 1;
                av1_postproc(hw);
 
-               if (hw->is_used_v4l)
-                       notify_v4l_eos(hw_to_vdec(hw));
+               notify_v4l_eos(hw_to_vdec(hw));
 
                vdec_vframe_dirty(hw_to_vdec(hw), hw->chunk);
        } else if (hw->dec_result == DEC_RESULT_FORCE_EXIT) {
index 282bba7bd0f07f305a40c756c26b6f532cd7d1b0..2e0b5a7ff615ba22422e0870b2a126682698738e 100644 (file)
@@ -7478,18 +7478,20 @@ static int notify_v4l_eos(struct vdec_s *vdec)
        int index = INVALID_IDX;
        ulong expires;
 
-       if (hw->is_used_v4l && hw->eos) {
-               expires = jiffies + msecs_to_jiffies(2000);
-               while (INVALID_IDX == (index = v4l_get_free_fb(hw))) {
-                       if (time_after(jiffies, expires) ||
-                               v4l2_m2m_num_dst_bufs_ready(ctx->m2m_ctx))
-                               break;
-               }
+       if (hw->eos) {
+               if (hw->is_used_v4l) {
+                       expires = jiffies + msecs_to_jiffies(2000);
+                       while (INVALID_IDX == (index = v4l_get_free_fb(hw))) {
+                               if (time_after(jiffies, expires) ||
+                                       v4l2_m2m_num_dst_bufs_ready(ctx->m2m_ctx))
+                                       break;
+                       }
 
-               if (index == INVALID_IDX) {
-                       if (vdec_v4l_get_buffer(hw->v4l2_ctx, &fb) < 0) {
-                               pr_err("[%d] EOS get free buff fail.\n", ctx->id);
-                               return -1;
+                       if (index == INVALID_IDX) {
+                               if (vdec_v4l_get_buffer(hw->v4l2_ctx, &fb) < 0) {
+                                       pr_err("[%d] EOS get free buff fail.\n", ctx->id);
+                                       return -1;
+                               }
                        }
                }
 
@@ -7503,7 +7505,7 @@ static int notify_v4l_eos(struct vdec_s *vdec)
                vf_notify_receiver(vdec->vf_provider_name,
                        VFRAME_EVENT_PROVIDER_VFRAME_READY, NULL);
 
-               pr_info("[%d] VP9 EOS notify.\n", ctx->id);
+               pr_info("[%d] VP9 EOS notify.\n", (hw->is_used_v4l)?ctx->id:vdec->id);
        }
 
        return 0;
@@ -9984,8 +9986,7 @@ static void vp9_work(struct work_struct *work)
                pbi->eos = 1;
                vp9_bufmgr_postproc(pbi);
 
-               if (pbi->is_used_v4l)
-                       notify_v4l_eos(hw_to_vdec(pbi));
+               notify_v4l_eos(hw_to_vdec(pbi));
 
                vdec_vframe_dirty(hw_to_vdec(pbi), pbi->chunk);
        } else if (pbi->dec_result == DEC_RESULT_FORCE_EXIT) {