video: rockchip: mpp: rk3576: Add compatible check when hack run

dec->fix is used in rk3568 and rk3576, while CONFIG_CPU_RK3568 and
CONFIG_CPU_RK3576 are all defined, it will hack error.
Thus, the compatible need matching, then hack.

Change-Id: Icd1368c9f414422c0403d425ba732f20579b550d
Signed-off-by: Ding Wei <leo.ding@rock-chips.com>
This commit is contained in:
Ding Wei
2024-03-13 14:43:10 +08:00
committed by Tao Huang
parent deee50bc92
commit ec8394fb33
3 changed files with 31 additions and 4 deletions

View File

@@ -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);

View File

@@ -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);
};
/*

View File

@@ -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;