backend-drm: Select plane based on current attached CRTC

When doing plane selection for an output CRTC check if the plane
already has a CRTC attached and if so prefer that plane only for
the corresponding CRTC.

This prevents changing a CRTC's primary plane when it is active
which is not allowed by the DRM framework.

Based-on-patch-by: Eric Ruei <e-ruei1@ti.com>
Signed-off-by: Andrew F. Davis <afd@ti.com>
This commit is contained in:
Andrew F. Davis 2020-03-06 13:06:55 -05:00 committed by Daniel Stone
parent 9248340db0
commit 94afcbcdc3
2 changed files with 10 additions and 0 deletions

View file

@ -536,6 +536,7 @@ struct drm_plane {
uint32_t possible_crtcs;
uint32_t plane_id;
uint32_t plane_idx;
uint32_t crtc_id;
struct drm_property_info props[WDRM_PLANE__COUNT];

View file

@ -1001,6 +1001,7 @@ drm_plane_create(struct drm_device *device, const drmModePlane *kplane)
plane->state_cur->complete = true;
plane->possible_crtcs = kplane->possible_crtcs;
plane->plane_id = kplane->plane_id;
plane->crtc_id = kplane->crtc_id;
weston_drm_format_array_init(&plane->formats);
@ -1117,6 +1118,14 @@ drm_output_find_special_plane(struct drm_device *device,
if (found_elsewhere)
continue;
/* If a plane already has a CRTC selected and it is not our
* output's CRTC, then do not select this plane. We cannot
* switch away a plane from a CTRC when active. */
if ((type == WDRM_PLANE_TYPE_PRIMARY) &&
(plane->crtc_id != 0) &&
(plane->crtc_id != output->crtc->crtc_id))
continue;
plane->possible_crtcs = (1 << output->crtc->pipe);
return plane;
}