Skip to content

Commit f18142b

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 <jcalligeros99@gmail.com>
1 parent 1d2cea9 commit f18142b

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

2121
#include <drm/drm_atomic.h>
2222
#include <drm/drm_atomic_helper.h>
23+
#include <drm/drm_blend.h>
2324
#include <drm/clients/drm_client_setup.h>
2425
#include <drm/drm_crtc.h>
2526
#include <drm/drm_drv.h>
@@ -431,17 +432,27 @@ static int apple_probe_per_dcp(struct device *dev,
431432
struct apple_encoder *enc;
432433
struct drm_plane *planes[DCP_MAX_PLANES];
433434
int ret, i;
435+
int immutable_zpos = 0;
434436

435437
planes[0] = apple_plane_init(drm, 1U << num, DRM_PLANE_TYPE_PRIMARY);
436438
if (IS_ERR(planes[0]))
437439
return PTR_ERR(planes[0]);
440+
ret = drm_plane_create_zpos_immutable_property(planes[0], immutable_zpos);
441+
if (ret) {
442+
return ret;
443+
}
438444

439445

440446
/* Set up our other planes */
441447
for (i = 1; i < DCP_MAX_PLANES; i++) {
442448
planes[i] = apple_plane_init(drm, 1U << num, DRM_PLANE_TYPE_OVERLAY);
443449
if (IS_ERR(planes[i]))
444450
return PTR_ERR(planes[i]);
451+
immutable_zpos++;
452+
ret = drm_plane_create_zpos_immutable_property(planes[i], immutable_zpos);
453+
if (ret) {
454+
return ret;
455+
}
445456
}
446457

447458
/*

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)