diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c index 868a7057a9b0..d713e0d97eb8 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c @@ -5998,6 +5998,8 @@ static int vop2_gamma_init(struct vop2 *vop2) for (i = 0; i < vop2_data->nr_vps; i++) { vp = &vop2->vps[i]; crtc = &vp->crtc; + if (!crtc->dev) + continue; vp_data = &vop2_data->vp[vp->id]; lut_len = vp_data->gamma_lut_len; vp->gamma_lut_len = vp_data->gamma_lut_len; @@ -6029,7 +6031,6 @@ static int vop2_gamma_init(struct vop2 *vop2) return 0; } - static int vop2_crtc_create_plane_mask_property(struct vop2 *vop2, struct drm_crtc *crtc) { @@ -6084,10 +6085,26 @@ static int vop2_create_crtc(struct vop2 *vop2) int ret = 0; bool be_used_for_primary_plane = false; bool find_primary_plane = false; + bool bootloader_initialized = false; /* all planes can attach to any crtc */ possible_crtcs = (1 << vop2_data->nr_vps) - 1; + /* + * We set plane_mask from dts or bootloader + * if all the plane_mask are zero, that means + * the bootloader don't initialized the vop, or + * something is wrong, the kernel will try to + * initial all the vp. + */ + for (i = 0; i < vop2_data->nr_vps; i++) { + vp = &vop2->vps[i]; + if (vp->plane_mask) { + bootloader_initialized = true; + break; + } + } + /* * Create primary plane for eache crtc first, since we need * to pass them to drm_crtc_init_with_planes, which sets the @@ -6100,6 +6117,14 @@ static int vop2_create_crtc(struct vop2 *vop2) vp->id = vp_data->id; vp->regs = vp_data->regs; vp->cursor_win_id = -1; + + /* + * we assume a vp with a zere plane_mask(set from dts or bootloader) + * as unused. + */ + if (!vp->plane_mask && bootloader_initialized) + continue; + if (vop2_soc_is_rk3566()) soc_id = vp_data->soc_id[1]; else