From: shihong.zheng Date: Fri, 14 Aug 2020 06:47:00 +0000 (+0800) Subject: decoder: pass dummy vf to notify eos. [1/1] X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b4a59a5a3bd601c51de5971623116b33c26f9b58;p=GitHub%2FLineageOS%2FG12%2Fandroid_hardware_amlogic_kernel-modules_media.git decoder: pass dummy vf to notify eos. [1/1] 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 --- diff --git a/drivers/frame_provider/decoder/h264_multi/vmh264.c b/drivers/frame_provider/decoder/h264_multi/vmh264.c index 2353767..a19a634 100644 --- a/drivers/frame_provider/decoder/h264_multi/vmh264.c +++ b/drivers/frame_provider/decoder/h264_multi/vmh264.c @@ -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; diff --git a/drivers/frame_provider/decoder/h265/vh265.c b/drivers/frame_provider/decoder/h265/vh265.c index 6d47ee0..0872577 100644 --- a/drivers/frame_provider/decoder/h265/vh265.c +++ b/drivers/frame_provider/decoder/h265/vh265.c @@ -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); diff --git a/drivers/frame_provider/decoder/mjpeg/vmjpeg_multi.c b/drivers/frame_provider/decoder/mjpeg/vmjpeg_multi.c index 06b2f50..62592bf 100644 --- a/drivers/frame_provider/decoder/mjpeg/vmjpeg_multi.c +++ b/drivers/frame_provider/decoder/mjpeg/vmjpeg_multi.c @@ -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; diff --git a/drivers/frame_provider/decoder/mpeg12/vmpeg12_multi.c b/drivers/frame_provider/decoder/mpeg12/vmpeg12_multi.c index 832e3c3..c830960 100644 --- a/drivers/frame_provider/decoder/mpeg12/vmpeg12_multi.c +++ b/drivers/frame_provider/decoder/mpeg12/vmpeg12_multi.c @@ -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", diff --git a/drivers/frame_provider/decoder/mpeg4/vmpeg4_multi.c b/drivers/frame_provider/decoder/mpeg4/vmpeg4_multi.c index 0bb416c..6d27c7d 100644 --- a/drivers/frame_provider/decoder/mpeg4/vmpeg4_multi.c +++ b/drivers/frame_provider/decoder/mpeg4/vmpeg4_multi.c @@ -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", diff --git a/drivers/frame_provider/decoder/vav1/vav1.c b/drivers/frame_provider/decoder/vav1/vav1.c index 24bb519..f46c25b 100644 --- a/drivers/frame_provider/decoder/vav1/vav1.c +++ b/drivers/frame_provider/decoder/vav1/vav1.c @@ -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) { diff --git a/drivers/frame_provider/decoder/vp9/vvp9.c b/drivers/frame_provider/decoder/vp9/vvp9.c index 282bba7..2e0b5a7 100644 --- a/drivers/frame_provider/decoder/vp9/vvp9.c +++ b/drivers/frame_provider/decoder/vp9/vvp9.c @@ -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) {