From 89cfea811432c5284ddb23ceb972129c582cf90d Mon Sep 17 00:00:00 2001 From: ming_qian <ming.qian@nxp.com> Date: Wed, 20 Mar 2019 14:44:16 +0800 Subject: [PATCH] MA-10250: VPU Decoder: restart firmware if seq hdr is not found if seq header is not found before user streamoff. and user streamon again. the firmware is keeping parsing seq state. but it don't really parse seq header because it has been canceled by streamoff. The firmware needs driver trigger again to start parse next seq. In this case, driver will send stop cmd to firmware first, and send start cmd to firmware to restart parse seq header. And the user need transfer spspps before I frame again. Signed-off-by: ming_qian <ming.qian@nxp.com> --- drivers/mxc/vpu_malone/vpu_b0.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/mxc/vpu_malone/vpu_b0.c b/drivers/mxc/vpu_malone/vpu_b0.c index 5eacc8b19819e8..592fe5e81364d1 100644 --- a/drivers/mxc/vpu_malone/vpu_b0.c +++ b/drivers/mxc/vpu_malone/vpu_b0.c @@ -1275,9 +1275,6 @@ static int v4l2_ioctl_streamon(struct file *file, if (ctx->hang_status) { vpu_dbg(LVL_ERR, "%s(): not succeed and some instance are blocked\n", __func__); return -EINVAL; - } else if (ctx->firmware_stopped) { - vpu_dbg(LVL_ERR, "%s(): not succeed and firmware is stopped\n", __func__); - return -EINVAL; } else return ret; } @@ -1332,9 +1329,6 @@ static int v4l2_ioctl_streamoff(struct file *file, if (ctx->hang_status) { vpu_dbg(LVL_ERR, "%s(): not succeed and some instance are blocked\n", __func__); return -EINVAL; - } else if (ctx->firmware_stopped) { - vpu_dbg(LVL_ERR, "%s(): not succeed and firmware is stopped\n", __func__); - return -EINVAL; } else return ret; } @@ -2244,7 +2238,7 @@ static void vpu_api_event_handler(struct vpu_ctx *ctx, u_int32 uStrIdx, u_int32 return; } - if (ctx->firmware_stopped) { + if (ctx->firmware_stopped && uEvent != VID_API_EVENT_START_DONE) { vpu_dbg(LVL_ERR, "receive event: 0x%X after stopped, ignore it\n", uEvent); return; } @@ -2253,10 +2247,13 @@ static void vpu_api_event_handler(struct vpu_ctx *ctx, u_int32 uStrIdx, u_int32 switch (uEvent) { case VID_API_EVENT_START_DONE: + ctx->firmware_stopped = false; + ctx->firmware_finished = false; break; case VID_API_EVENT_STOPPED: { vpu_dbg(LVL_INFO, "receive VID_API_EVENT_STOPPED\n"); ctx->firmware_stopped = true; + ctx->start_flag = true; complete(&ctx->completion);//reduce possibility of abort hang if decoder enter stop automatically complete(&ctx->stop_cmp); } @@ -2671,7 +2668,11 @@ static void vpu_api_event_handler(struct vpu_ctx *ctx, u_int32 uStrIdx, u_int32 i, bufstat[p_data_req->status]); } up(&This->drv_q_lock); - complete(&ctx->completion); + if (ctx->b_firstseq) + v4l2_vpu_send_cmd(ctx, ctx->str_index, + VID_API_CMD_STOP, 0, NULL); + else + complete(&ctx->completion); } break; case VID_API_EVENT_RET_PING: -- GitLab