Skip to content

Commit

Permalink
drm: apple: make plane zpos immutable
Browse files Browse the repository at this point in the history
Userspace cannot be trusted to give us a sane zpos value, but given DCP's
requirement that the primary plane always be the bottommost surface, we
can't rely on drm_atomic_normalize_zpos() to do the job for us either.

Make the zpos property immutable, and keep the primary plane at zpos 0.

Signed-off-by: James Calligeros <[email protected]>
  • Loading branch information
chadmed committed Oct 13, 2024
1 parent 1a8d722 commit 5669272
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions drivers/gpu/drm/apple/apple_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <drm/drm_aperture.h>
#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_blend.h>
#include <drm/drm_crtc.h>
#include <drm/drm_drv.h>
#include <drm/drm_fb_helper.h>
Expand Down Expand Up @@ -364,17 +365,27 @@ static int apple_probe_per_dcp(struct device *dev,
struct apple_encoder *enc;
struct drm_plane *planes[DCP_MAX_PLANES];
int ret, i;
int immutable_zpos = 0;

planes[0] = apple_plane_init(drm, 1U << num, DRM_PLANE_TYPE_PRIMARY);
if (IS_ERR(planes[0]))
return PTR_ERR(planes[0]);
ret = drm_plane_create_zpos_immutable_property(planes[0], immutable_zpos);
if (ret) {
return ret;
}


/* Set up our other planes */
for (i = 1; i < DCP_MAX_PLANES; i++) {
planes[i] = apple_plane_init(drm, 1U << num, DRM_PLANE_TYPE_OVERLAY);
if (IS_ERR(planes[i]))
return PTR_ERR(planes[i]);
immutable_zpos++;
ret = drm_plane_create_zpos_immutable_property(planes[i], immutable_zpos);
if (ret) {
return ret;
}
}

/*
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/apple/iomfb_template.c
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@ void DCP_FW_NAME(iomfb_flush)(struct apple_dcp *dcp, struct drm_crtc *crtc, stru
* also unusable on some machines, so ignore it.
*/

l = MAX_BLEND_SURFACES - new_state->zpos;
l = MAX_BLEND_SURFACES - new_state->normalized_zpos;

WARN_ON(l > MAX_BLEND_SURFACES);

Expand Down

0 comments on commit 5669272

Please sign in to comment.