From 641da0dc82a05616ac5aa9edc5024d3eb877cbbe Mon Sep 17 00:00:00 2001 From: Sandy Huang Date: Thu, 22 Jul 2021 16:41:29 +0800 Subject: [PATCH] drm/rockchip: vop2: get correct plane state for dmc Signed-off-by: Sandy Huang Change-Id: I2cdc7394ccddcd0a0a10b2b7fc3d8f5b033fa643 --- drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c index 0b00f69cdfd4..185b500a75f0 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c @@ -3959,7 +3959,7 @@ static size_t vop2_crtc_bandwidth(struct drm_crtc *crtc, struct drm_crtc_state *crtc_state, unsigned int *plane_num_total) { - struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode; + struct drm_display_mode *adjusted_mode = &crtc->state->adjusted_mode; uint16_t htotal = adjusted_mode->crtc_htotal; uint16_t vdisplay = adjusted_mode->crtc_vdisplay; int clock = adjusted_mode->crtc_clock; @@ -3970,6 +3970,7 @@ static size_t vop2_crtc_bandwidth(struct drm_crtc *crtc, struct drm_plane *plane; uint64_t bandwidth; int8_t cnt = 0, plane_num = 0; + int i = 0; #if defined(CONFIG_ROCKCHIP_DRM_DEBUG) struct vop_dump_list *pos, *n; #endif @@ -3991,8 +3992,10 @@ static size_t vop2_crtc_bandwidth(struct drm_crtc *crtc, } #endif - drm_atomic_crtc_state_for_each_plane(plane, crtc_state) - plane_num++; + for_each_new_plane_in_state(state, plane, pstate, i) { + if (pstate->crtc == crtc) + plane_num++; + } if (plane_num_total) *plane_num_total += plane_num; @@ -4000,8 +4003,8 @@ static size_t vop2_crtc_bandwidth(struct drm_crtc *crtc, GFP_KERNEL); if (!pbandwidth) return -ENOMEM; - drm_atomic_crtc_state_for_each_plane(plane, crtc_state) { - pstate = drm_atomic_get_new_plane_state(state, plane); + + for_each_new_plane_in_state(state, plane, pstate, i) { if (!pstate || pstate->crtc != crtc || !pstate->fb) continue;