Skip to content

Commit 9af8417

Browse files
chadmedjannau
authored andcommitted
drm: apple: make plane zpos immutable
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]>
1 parent 734776f commit 9af8417

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

drivers/gpu/drm/apple/apple_drv.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <drm/drm_aperture.h>
2121
#include <drm/drm_atomic.h>
2222
#include <drm/drm_atomic_helper.h>
23+
#include <drm/drm_blend.h>
2324
#include <drm/drm_crtc.h>
2425
#include <drm/drm_drv.h>
2526
#include <drm/drm_fb_helper.h>
@@ -422,17 +423,27 @@ static int apple_probe_per_dcp(struct device *dev,
422423
struct apple_encoder *enc;
423424
struct drm_plane *planes[DCP_MAX_PLANES];
424425
int ret, i;
426+
int immutable_zpos = 0;
425427

426428
planes[0] = apple_plane_init(drm, 1U << num, DRM_PLANE_TYPE_PRIMARY);
427429
if (IS_ERR(planes[0]))
428430
return PTR_ERR(planes[0]);
431+
ret = drm_plane_create_zpos_immutable_property(planes[0], immutable_zpos);
432+
if (ret) {
433+
return ret;
434+
}
429435

430436

431437
/* Set up our other planes */
432438
for (i = 1; i < DCP_MAX_PLANES; i++) {
433439
planes[i] = apple_plane_init(drm, 1U << num, DRM_PLANE_TYPE_OVERLAY);
434440
if (IS_ERR(planes[i]))
435441
return PTR_ERR(planes[i]);
442+
immutable_zpos++;
443+
ret = drm_plane_create_zpos_immutable_property(planes[i], immutable_zpos);
444+
if (ret) {
445+
return ret;
446+
}
436447
}
437448

438449
/*

drivers/gpu/drm/apple/iomfb_template.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,7 @@ void DCP_FW_NAME(iomfb_flush)(struct apple_dcp *dcp, struct drm_crtc *crtc, stru
13161316
* also unusable on some machines, so ignore it.
13171317
*/
13181318

1319-
l = MAX_BLEND_SURFACES - new_state->zpos;
1319+
l = MAX_BLEND_SURFACES - new_state->normalized_zpos;
13201320

13211321
WARN_ON(l > MAX_BLEND_SURFACES);
13221322

0 commit comments

Comments
 (0)