From 4935d15e9b39cb8bbf052cd7da3e238ca5703338 Mon Sep 17 00:00:00 2001 From: Yandong Lin Date: Thu, 11 Aug 2022 11:36:57 +0800 Subject: [PATCH] video: rockchip: mpp: fix dec err issue for rk356x 1. Add need_hack check for rk356x 2. Use cancel_delayed_work replace cancel_delayed_work_sync 3. Remove the operation of resetting rkvdec2 before suspend Signed-off-by: Yandong Lin Change-Id: If826ce65fa1db164a99067bdc9ab5092474a88a3 --- drivers/video/rockchip/mpp/mpp_rkvdec2.c | 9 --------- drivers/video/rockchip/mpp/mpp_rkvdec2_link.c | 19 +++++++++++++++++-- drivers/video/rockchip/mpp/mpp_rkvdec2_link.h | 1 + 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/video/rockchip/mpp/mpp_rkvdec2.c b/drivers/video/rockchip/mpp/mpp_rkvdec2.c index 5c5ca8f38c90..ada9df5961ad 100644 --- a/drivers/video/rockchip/mpp/mpp_rkvdec2.c +++ b/drivers/video/rockchip/mpp/mpp_rkvdec2.c @@ -1595,17 +1595,8 @@ static int __maybe_unused rkvdec2_runtime_suspend(struct device *dev) mpp_clk_safe_disable(ccu->aclk_info.clk); } else { - u32 val; struct mpp_dev *mpp = dev_get_drvdata(dev); - /* soft reset */ - mpp_write(mpp, RKVDEC_REG_IMPORTANT_BASE, RKVDEC_SOFTREST_EN); - udelay(5); - val = mpp_read(mpp, RKVDEC_REG_INT_EN); - if (!(val & RKVDEC_SOFT_RESET_READY)) - mpp_err("soft reset fail, int %08x\n", val); - mpp_write(mpp, RKVDEC_REG_INT_EN, 0); - if (mpp->is_irq_startup) { /* disable core irq */ disable_irq(mpp->irq); diff --git a/drivers/video/rockchip/mpp/mpp_rkvdec2_link.c b/drivers/video/rockchip/mpp/mpp_rkvdec2_link.c index 0dd7c21d85af..f7418621c683 100644 --- a/drivers/video/rockchip/mpp/mpp_rkvdec2_link.c +++ b/drivers/video/rockchip/mpp/mpp_rkvdec2_link.c @@ -71,6 +71,7 @@ struct rkvdec_link_info rkvdec_link_v2_hw_info = { .reg_num = 28, }, .tb_reg_int = 180, + .hack_setup = 0, }; /* vdpu34x link hw info for rk356x */ @@ -123,6 +124,7 @@ struct rkvdec_link_info rkvdec_link_rk356x_hw_info = { .reg_num = 28, }, .tb_reg_int = 164, + .hack_setup = 1, }; static void rkvdec_link_status_update(struct rkvdec_link_dev *dev) @@ -601,7 +603,7 @@ static int rkvdec_link_isr_recv_task(struct mpp_dev *mpp, task->irq_status = irq_status ? irq_status : mpp->irq_status; - cancel_delayed_work_sync(&mpp_task->timeout_work); + cancel_delayed_work(&mpp_task->timeout_work); set_bit(TASK_STATE_HANDLE, &mpp_task->state); if (link_dec->statistic_count && @@ -768,7 +770,7 @@ static int rkvdec2_link_isr(struct mpp_dev *mpp) rkvdec_link_reg_dump("timeout", link_dec); val = mpp_read(mpp, 224 * 4); - if (!(val & BIT(2))) { + if (link_dec->info->hack_setup && !(val & BIT(2))) { dev_info(mpp->dev, "frame not complete\n"); link_dec->decoded++; } @@ -955,6 +957,9 @@ int rkvdec2_link_init(struct platform_device *pdev, struct rkvdec2_dev *dec) if (ret) goto done; + if (dec->fix) + rkvdec2_link_hack_data_setup(dec->fix); + link_dec->mpp = mpp; link_dec->dev = dev; atomic_set(&link_dec->task_timeout, 0); @@ -1282,6 +1287,7 @@ int rkvdec2_link_process_task(struct mpp_session *session, { struct mpp_task *task = NULL; struct mpp_dev *mpp = session->mpp; + struct rkvdec_link_info *link_info = mpp->var->hw_info->link_info; task = rkvdec2_alloc_task(session, msgs); if (!task) { @@ -1289,6 +1295,15 @@ int rkvdec2_link_process_task(struct mpp_session *session, return -ENOMEM; } + if (link_info->hack_setup) { + u32 fmt; + struct rkvdec2_task *dec_task = NULL; + + dec_task = to_rkvdec2_task(task); + fmt = RKVDEC_GET_FORMAT(dec_task->reg[RKVDEC_REG_FORMAT_INDEX]); + dec_task->need_hack = (fmt == RKVDEC_FMT_H264D); + } + kref_init(&task->ref); atomic_set(&task->abort_request, 0); task->task_index = atomic_fetch_inc(&mpp->task_index); diff --git a/drivers/video/rockchip/mpp/mpp_rkvdec2_link.h b/drivers/video/rockchip/mpp/mpp_rkvdec2_link.h index 208789c7c36b..635516ae3262 100644 --- a/drivers/video/rockchip/mpp/mpp_rkvdec2_link.h +++ b/drivers/video/rockchip/mpp/mpp_rkvdec2_link.h @@ -112,6 +112,7 @@ struct rkvdec_link_info { /* interrupt read back in table buffer */ u32 tb_reg_int; + bool hack_setup; }; struct rkvdec_link_dev {