Skip to content

Commit 4dc5552

Browse files
author
Laurent Pinchart
committed
drm: plane: Verify that no or all planes have a zpos property
The zpos property is used by userspace to sort the order of planes. While the property is not mandatory for drivers to implement, mixing planes with and without zpos confuses userspace, and shall not be allowed. Clarify this in the documentation and warn at runtime if the drivers mixes planes with and without zpos properties. Signed-off-by: Laurent Pinchart <[email protected]> Acked-by: Sam Ravnborg <[email protected]> Reviewed-by: Daniel Vetter <[email protected]>
1 parent 07de3d3 commit 4dc5552

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

drivers/gpu/drm/drm_blend.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@
135135
* are underneath planes with higher Z position values. Two planes with the
136136
* same Z position value have undefined ordering. Note that the Z position
137137
* value can also be immutable, to inform userspace about the hard-coded
138-
* stacking of planes, see drm_plane_create_zpos_immutable_property().
138+
* stacking of planes, see drm_plane_create_zpos_immutable_property(). If
139+
* any plane has a zpos property (either mutable or immutable), then all
140+
* planes shall have a zpos property.
139141
*
140142
* pixel blend mode:
141143
* Pixel blend mode is set up with drm_plane_create_blend_mode_property().
@@ -344,10 +346,10 @@ EXPORT_SYMBOL(drm_rotation_simplify);
344346
* should be set to 0 and max to maximal number of planes for given crtc - 1.
345347
*
346348
* If zpos of some planes cannot be changed (like fixed background or
347-
* cursor/topmost planes), driver should adjust min/max values and assign those
348-
* planes immutable zpos property with lower or higher values (for more
349+
* cursor/topmost planes), drivers shall adjust the min/max values and assign
350+
* those planes immutable zpos properties with lower or higher values (for more
349351
* information, see drm_plane_create_zpos_immutable_property() function). In such
350-
* case driver should also assign proper initial zpos values for all planes in
352+
* case drivers shall also assign proper initial zpos values for all planes in
351353
* its plane_reset() callback, so the planes will be always sorted properly.
352354
*
353355
* See also drm_atomic_normalize_zpos().

drivers/gpu/drm/drm_plane.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ EXPORT_SYMBOL(drm_universal_plane_init);
289289

290290
int drm_plane_register_all(struct drm_device *dev)
291291
{
292+
unsigned int num_planes = 0;
293+
unsigned int num_zpos = 0;
292294
struct drm_plane *plane;
293295
int ret = 0;
294296

@@ -297,8 +299,15 @@ int drm_plane_register_all(struct drm_device *dev)
297299
ret = plane->funcs->late_register(plane);
298300
if (ret)
299301
return ret;
302+
303+
if (plane->zpos_property)
304+
num_zpos++;
305+
num_planes++;
300306
}
301307

308+
drm_WARN(dev, num_zpos && num_planes != num_zpos,
309+
"Mixing planes with and without zpos property is invalid\n");
310+
302311
return 0;
303312
}
304313

0 commit comments

Comments
 (0)