diff --git a/drivers/video/rockchip/mpp/hack/mpp_hack_rk3576.c b/drivers/video/rockchip/mpp/hack/mpp_hack_rk3576.c index 6fd8dd287d65..a5919f0ea48a 100644 --- a/drivers/video/rockchip/mpp/hack/mpp_hack_rk3576.c +++ b/drivers/video/rockchip/mpp/hack/mpp_hack_rk3576.c @@ -50,11 +50,27 @@ static const char rk3576_hack_h264_pps_data[] = { 0x00, 0x00, 0x00, 0x00, }; +static bool rk3576_hack_flag; + +static bool is_rk3576(struct device *dev) +{ + int ret; + + ret = device_property_match_string(dev, "compatible", "rockchip,rkv-decoder-rk3576"); + + return (ret < 0) ? false : true; +} + int rk3576_workaround_init(struct mpp_dev *mpp) { struct rkvdec2_dev *dec = to_rkvdec2_dev(mpp); u32 *reg; + /* check current soc is rk3576 */ + rk3576_hack_flag = is_rk3576(mpp->dev); + if (!rk3576_hack_flag) + return 0; + /* alloc buffer for node */ dec->fix = mpp_dma_alloc(mpp->dev, 2 * PAGE_SIZE); if (!dec->fix) { @@ -113,8 +129,14 @@ int rk3576_workaround_exit(struct mpp_dev *mpp) { struct rkvdec2_dev *dec = to_rkvdec2_dev(mpp); - if (dec->fix) + /* check current soc is rk3576 */ + if (!rk3576_hack_flag) + return 0; + + if (dec->fix) { mpp_dma_free(dec->fix); + dec->fix = NULL; + } return 0; } @@ -126,8 +148,10 @@ int rk3576_workaround_run(struct mpp_dev *mpp) int ret; u32 irq_val, status; - if (!dec->fix || !link) + /* check current soc is rk3576 */ + if (!rk3576_hack_flag || !dec->fix || !link) return 0; + /* disable hardware irq */ writel_relaxed(0x00008000, link->reg_base + 0x58); diff --git a/drivers/video/rockchip/mpp/mpp_common.h b/drivers/video/rockchip/mpp/mpp_common.h index 4e013f336355..43b62e8e7df6 100644 --- a/drivers/video/rockchip/mpp/mpp_common.h +++ b/drivers/video/rockchip/mpp/mpp_common.h @@ -547,6 +547,7 @@ struct mpp_service { * @set_freq Set freq to hardware. * @reduce_freq Reduce freq when hardware is not running. * @reset When error, reset hardware. + * @hack_run Hack run for some soc */ struct mpp_hw_ops { int (*init)(struct mpp_dev *mpp); @@ -560,6 +561,7 @@ struct mpp_hw_ops { int (*reduce_freq)(struct mpp_dev *mpp); int (*reset)(struct mpp_dev *mpp); int (*set_grf)(struct mpp_dev *mpp); + int (*hack_run)(struct mpp_dev *mpp); }; /* diff --git a/drivers/video/rockchip/mpp/mpp_rkvdec2.c b/drivers/video/rockchip/mpp/mpp_rkvdec2.c index 845224b3ba8a..1c92426cdffe 100644 --- a/drivers/video/rockchip/mpp/mpp_rkvdec2.c +++ b/drivers/video/rockchip/mpp/mpp_rkvdec2.c @@ -1464,6 +1464,7 @@ static struct mpp_hw_ops rkvdec_rk3576_hw_ops = { .get_freq = rkvdec2_get_freq, .set_freq = rkvdec2_set_freq, .reset = rkvdec_vdpu383_reset, + .hack_run = rk3576_workaround_run, }; static struct mpp_dev_ops rkvdec_v2_dev_ops = { @@ -2031,8 +2032,8 @@ static int __maybe_unused rkvdec2_runtime_resume(struct device *dev) enable_irq(mpp->iommu_info->irq); } /* work workaround */ - if (dec->fix) - rk3576_workaround_run(mpp); + if (dec->fix && mpp->hw_ops->hack_run) + mpp->hw_ops->hack_run(mpp); } return 0;