From 97e31ffa5dcbcb11c8d21b57e0709fcdc48aa450 Mon Sep 17 00:00:00 2001 From: Andy Yan Date: Wed, 23 Jun 2021 15:06:11 +0800 Subject: [PATCH] drm/rockchip: vop2: Disable all other multi area when disable area0 When area0 is disabled, all other sub multi area must be disabled, or the win may run into unexpected situlation: such as post_buf_empty or iommu fault. Change-Id: I8a92e45849cfc31af029ba0e86562751be92ddbd Signed-off-by: Andy Yan --- drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 1 + drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 19 +++++++++++++++++++ drivers/gpu/drm/rockchip/rockchip_vop2_reg.c | 6 ++++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h index e5ee271c0ca8..456027acb831 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h @@ -48,6 +48,7 @@ * This is a feather on rk3566 */ #define WIN_FEATURE_MIRROR BIT(6) +#define WIN_FEATURE_MULTI_AREA BIT(7) #define VOP2_SOC_VARIANT 4 diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c index 9c6649813784..95e4628174e2 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c @@ -1101,6 +1101,19 @@ static inline void vop2_wb_cfg_done(struct vop2_video_port *vp) } +static void vop2_win_multi_area_disable(struct vop2_win *parent) +{ + struct vop2 *vop2 = parent->vop2; + struct vop2_win *area; + int i; + + for (i = 0; i < vop2->registered_num_wins; i++) { + area = &vop2->win[i]; + if (area->parent == parent) + VOP_WIN_SET(vop2, area, enable, 0); + } +} + static void vop2_win_disable(struct vop2_win *win) { struct vop2 *vop2 = win->vop2; @@ -1120,6 +1133,12 @@ static void vop2_win_disable(struct vop2_win *win) VOP_CLUSTER_SET(vop2, win, enable, 0); } + + /* + * disable all other multi area win if we want disable area0 here + */ + if (!win->parent && (win->feature & WIN_FEATURE_MULTI_AREA)) + vop2_win_multi_area_disable(win); } static inline void vop2_write_lut(struct vop2 *vop2, uint32_t offset, uint32_t v) diff --git a/drivers/gpu/drm/rockchip/rockchip_vop2_reg.c b/drivers/gpu/drm/rockchip/rockchip_vop2_reg.c index 2fea21461d68..c0ef4b43b5d3 100644 --- a/drivers/gpu/drm/rockchip/rockchip_vop2_reg.c +++ b/drivers/gpu/drm/rockchip/rockchip_vop2_reg.c @@ -1021,6 +1021,7 @@ static const struct vop2_win_data rk3568_vop_win_data[] = { .max_upscale_factor = 8, .max_downscale_factor = 8, .dly = { 20, 47, 41 }, + .feature = WIN_FEATURE_MULTI_AREA, }, { @@ -1043,7 +1044,7 @@ static const struct vop2_win_data rk3568_vop_win_data[] = { .max_upscale_factor = 8, .max_downscale_factor = 8, .dly = { 20, 47, 41 }, - .feature = WIN_FEATURE_MIRROR, + .feature = WIN_FEATURE_MIRROR | WIN_FEATURE_MULTI_AREA, }, { @@ -1066,7 +1067,7 @@ static const struct vop2_win_data rk3568_vop_win_data[] = { .max_upscale_factor = 8, .max_downscale_factor = 8, .dly = { 20, 47, 41 }, - .feature = WIN_FEATURE_MIRROR, + .feature = WIN_FEATURE_MIRROR | WIN_FEATURE_MULTI_AREA, }, { @@ -1089,6 +1090,7 @@ static const struct vop2_win_data rk3568_vop_win_data[] = { .max_upscale_factor = 8, .max_downscale_factor = 8, .dly = { 20, 47, 41 }, + .feature = WIN_FEATURE_MULTI_AREA, }, {