Skip to contentSkip to conversation

Proposal of the z-order patch

PATCH New Yu Dai 2 participants 4 messages Mar 20, 2014 – Mar 21, 2014

Subsystems (3)
lore
Share & tools
lore

Yu Dai

author
#0 lore raw

All,

Thanks for the review of z-order patch. Based on that, we had some internal discussion within our Display driver team. Here is the summary.

1. Re: define plane z-order combinations as an enum property

User mode needs extra work to understand the definition. The number of combinations expands dramatically with the increasing of planes. Says for 4 planes, the total combo is 24.

2. Re: per-plane z-order property

We prefer the atomic setup of z-order for all planes. So driver can validate the property value in the SetProperty call. Otherwise, if for each plane the separated SetProperty call is made to update the z-order, it could be difficult to handle and validate. For example, when set a plane to zorder 2, there might be another plane with zorder 2 already. In the end, we still need another check point to validate this.

3. We also discussed the possibility of using blob property

Some generic blob property calls are needed to handle a property with a list of plane id and zorder etc. But currently it is lack of support in libdrm to pass down user data via blob property. The current drm_mode_obj_set_property really doesn't handle blob. It might be useful to implement a property that can handle complicated data structure from user. But this is long term goal.

The new proposal we have is still based on previous solution (64bits property) but it tries to make the code platform agnostic and eliminate the magic number like PASASBCA.

Define the supported plane name tag in i915_drm.h. For i915, it might be

#define DRM_I915_PLANE_PRIMARY    0
#define DRM_I915_PLANE_SPRITE_A   1
#define DRM_I915_PLANE_SPRITE_B   2
#define DRM_I915_PLANE_CURSOR     3

Limits the above setting within 0~15. So we need 4 bits to save it into z-order property. The 64bits of z-order will indicate the order of planes from bottom (lower bits) to top (higher bits) by every 4 bits. Bit 3:0 is the plane at bottom; Bit 7:4 is the one right on top of it and so on. In this way, we can support up to 16 planes total. And it is very straightforward for user mode to use. The SetProperty call will reject any invalid setting. The HW specific code will be wrapped up in kernel SetProperty callback. Be note on Intel platform, the PLANE_SPRITE_A/B will be mapped to HW Sprite C/D for pipe 2. And this is crtc property - we don't have to pass around pipe id.

Please let us know your opinion on this.

Thanks,

Alex
GCM Core uArch, Intel VGP

#1 lore raw
Quoted 53 lines · Yu Dai

All,

Thanks for the review of z-order patch. Based on that, we had some internal discussion within our Display driver team. Here is the summary.

1. Re: define plane z-order combinations as an enum property

User mode needs extra work to understand the definition. The number of combinations expands dramatically with the increasing of planes. Says for 4 planes, the total combo is 24.

2. Re: per-plane z-order property

We prefer the atomic setup of z-order for all planes. So driver can validate the property value in the SetProperty call. Otherwise, if for each plane the separated SetProperty call is made to update the z-order, it could be difficult to handle and validate. For example, when set a plane to zorder 2, there might be another plane with zorder 2 already. In the end, we still need another check point to validate this.

3. We also discussed the possibility of using blob property

Some generic blob property calls are needed to handle a property with a list of plane id and zorder etc. But currently it is lack of support in libdrm to pass down user data via blob property. The current drm_mode_obj_set_property really doesn't handle blob. It might be useful to implement a property that can handle complicated data structure from user. But this is long term goal.

The new proposal we have is still based on previous solution (64bits property) but it tries to make the code platform agnostic and eliminate the magic number like PASASBCA.

Define the supported plane name tag in i915_drm.h. For i915, it might be

#define DRM_I915_PLANE_PRIMARY    0
#define DRM_I915_PLANE_SPRITE_A   1
#define DRM_I915_PLANE_SPRITE_B   2
#define DRM_I915_PLANE_CURSOR     3

Limits the above setting within 0~15. So we need 4 bits to save it into z-order property. The 64bits of z-order will indicate the order of planes from bottom (lower bits) to top (higher bits) by every 4 bits. Bit 3:0 is the plane at bottom; Bit 7:4 is the one right on top of it and so on. In this way, we can support up to 16 planes total. And it is very straightforward for user mode to use. The SetProperty call will reject any invalid setting. The HW specific code will be wrapped up in kernel SetProperty callback. Be note on Intel platform, the PLANE_SPRITE_A/B will be mapped to HW Sprite C/D for pipe 2. And this is crtc property - we don't have to pass around pipe id.

Quoted 6 lines

Please let us know your opinion on this.

Thanks,

Alex
GCM Core uArch, Intel VGP

Hi Alex.

I think the first question here is whether you're proposing a solution for a pre-atomic or post-atomic driver stack? Based on your description of option #2, it sounds like you're focusing on a pre-atomic environment since you're using SetProperty and drm_mode_obj_set_property. With the atomic framework, you can use drmModePropertySetAdd() to add a bunch of desired property values to a single userspace property set object, then dispatch that whole set to the kernel with drmModePropertySetCommit() which calls the DRM_IOCTL_MODE_ATOMIC ioctl. The kernel can sanity check the whole batch of property values and then either accept or reject the whole set together in a transactional manner (so you don't have to worry about winding up in some strange limbo where some of your changes were good and took effect but others weren't).

Not to say your proposed solution directly conflicts with the atomic programming approach in any way (programming a single CRTC property works the same way as programming a bunch of separate plane properties in that case); I just want to make sure you understand the direction that we're expecting the API's to go in the near (hopefully!) future so that we can make sure we're settling on the best possible approach for z-order handling for the long term.

For the specific approach you propose above, can you clarify what the logic looks like from the point of view of a generic (non hw-specific) userspace compositor (e.g., Weston)? The compositor, which starts out knowing nothing at all about the underlying hardware, would call drmModeGetPlaneResources() and get a list of all the planes that are present. How does it know which of the HW-specific plane ID's you #define above correspond to which planes in the plane list it received? Are these ID's going to show up as immutable plane properties or something that userspace can read? Is it going to assume that those values correspond to the order that planes show up in the plane list? One of the advantages of using a single value to program z-order as you're doing here is that presumably there can be a mechanism to advertise what the valid plane orderings are so that the compositor doesn't have to spend some time at startup testing the various combinations itself...do you have plans on how you'd enumerate the valid configs for userspace?

Matt

Signature · 5 lines
Matt Roper
Graphics Software Engineer
ISG Platform Enabling & Development
Intel Corporation
(916) 356-2795
#3 lore raw

PATCH 1/1 drm/i915: add support for Z-order of planes

In reply to Yu Dai

From: "Yu(Alex) Dai" <[email protected]>

Add "zorder" property to crtc to control Z-order of sprite and primary planes. The plane tag is packed into the 64 bits value in the order of from bottom (lower bits) to top (higher bits). Four bits are used for each plane tag. It can support up to 16 planes.

The alpha channel of the plane is set during Z-order change. If a plane is put to the bottom, its alpha channel is off. Otherwise, its alpha channel is on.

---
 drivers/gpu/drm/i915/i915_drv.h      |   1 +
 drivers/gpu/drm/i915/i915_reg.h      |   3 +
 drivers/gpu/drm/i915/intel_display.c |  58 +++++++++++++++--
 drivers/gpu/drm/i915/intel_drv.h     |   6 ++
 drivers/gpu/drm/i915/intel_sprite.c  | 119 ++++++++++++++++++++++++++++++++++-
 include/uapi/drm/i915_drm.h          |   6 ++
 6 files changed, 186 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 9b8c1e0..8de2f45 100644
@@ -2656,6 +2656,7 @@ int i915_reg_read_ioctl(struct drm_device *dev, void *data,
 			struct drm_file *file);
 int i915_get_reset_stats_ioctl(struct drm_device *dev, void *data,
 			       struct drm_file *file);
+extern int i915_set_plane_zorder(struct drm_crtc *crtc, uint64_t zorder);
 
 /* overlay */
 extern struct intel_overlay_error_state *intel_overlay_capture_error_state(struct drm_device *dev);
drivers/gpu/drm/i915/i915_reg.h +3 -0
index 74f7d85..a0173b1 100644
@@ -3778,6 +3778,9 @@ enum punit_power_well {
 #define   SPRITE_INT_GAMMA_ENABLE	(1<<13)
 #define   SPRITE_TILED			(1<<10)
 #define   SPRITE_DEST_KEY		(1<<2)
+#define   SPRITE_FORCE_BOTTOM		(1<<2)
+#define   SPRITE_ZORDER_ENABLE		(1<<0)
+
 #define _SPRA_LINOFF		0x70284
 #define _SPRA_STRIDE		0x70288
 #define _SPRA_POS		0x7028c
drivers/gpu/drm/i915/intel_display.c +54 -4

109 lines not on this page · raw message

drivers/gpu/drm/i915/intel_drv.h +6 -0
index fa99104..6d90629 100644
@@ -382,6 +382,9 @@ struct intel_crtc {
 	bool new_enabled;
 
 	uint32_t ddi_pll_sel;
+	bool primary_alpha;
+	bool sprite0_alpha;
+	bool sprite1_alpha;
 
 	/* reset counter value when the last flip was submitted */
 	unsigned int reset_counter;
@@ -395,6 +398,9 @@ struct intel_crtc {
 		/* watermarks currently being used  */
 		struct intel_pipe_wm active;
 	} wm;
+
+	struct drm_property *zorder_property;
+	uint64_t zorder;
 };
 
 struct intel_plane_wm_parameters {
drivers/gpu/drm/i915/intel_sprite.c +116 -3

151 lines not on this page · raw message

include/uapi/drm/i915_drm.h +6 -0
index 126bfaa..df12b5d 100644
@@ -1049,4 +1049,10 @@ struct drm_i915_reset_stats {
 	__u32 pad;
 };
 
+#define I915_PLANE_PRIMARY		0
+#define I915_PLANE_SPRITE_A		1
+#define I915_PLANE_SPRITE_B		2
+#define I915_PLANE_CURSOR		3
+#define I915_PLANE_MAX_NUM		(I915_PLANE_CURSOR + 1)
+
 #endif /* _UAPI_I915_DRM_H_ */
Signature · 1 line
1.8.3.2
author
#2 lore raw
In reply to Matt Roper
Quoted 75 lines · Matt Roper
Quoted 53 lines · Yu Dai

All,

Thanks for the review of z-order patch. Based on that, we had some internal discussion within our Display driver team. Here is the summary.

1. Re: define plane z-order combinations as an enum property

User mode needs extra work to understand the definition. The number of combinations expands dramatically with the increasing of planes. Says for 4 planes, the total combo is 24.

2. Re: per-plane z-order property

We prefer the atomic setup of z-order for all planes. So driver can validate the property value in the SetProperty call. Otherwise, if for each plane the separated SetProperty call is made to update the z-order, it could be difficult to handle and validate. For example, when set a plane to zorder 2, there might be another plane with zorder 2 already. In the end, we still need another check point to validate this.

3. We also discussed the possibility of using blob property

Some generic blob property calls are needed to handle a property with a list of plane id and zorder etc. But currently it is lack of support in libdrm to pass down user data via blob property. The current drm_mode_obj_set_property really doesn't handle blob. It might be useful to implement a property that can handle complicated data structure from user. But this is long term goal.

The new proposal we have is still based on previous solution (64bits property) but it tries to make the code platform agnostic and eliminate the magic number like PASASBCA.

Define the supported plane name tag in i915_drm.h. For i915, it might be

#define DRM_I915_PLANE_PRIMARY    0
#define DRM_I915_PLANE_SPRITE_A   1
#define DRM_I915_PLANE_SPRITE_B   2
#define DRM_I915_PLANE_CURSOR     3

Limits the above setting within 0~15. So we need 4 bits to save it into z-order property. The 64bits of z-order will indicate the order of planes from bottom (lower bits) to top (higher bits) by every 4 bits. Bit 3:0 is the plane at bottom; Bit 7:4 is the one right on top of it and so on. In this way, we can support up to 16 planes total. And it is very straightforward for user mode to use. The SetProperty call will reject any invalid setting. The HW specific code will be wrapped up in kernel SetProperty callback. Be note on Intel platform, the PLANE_SPRITE_A/B will be mapped to HW Sprite C/D for pipe 2. And this is crtc property - we don't have to pass around pipe id.

Quoted 6 lines

Please let us know your opinion on this.

Thanks,

Alex
GCM Core uArch, Intel VGP

Hi Alex.

I think the first question here is whether you're proposing a solution for a pre-atomic or post-atomic driver stack? Based on your description of option #2, it sounds like you're focusing on a pre-atomic environment since you're using SetProperty and drm_mode_obj_set_property. With the atomic framework, you can use drmModePropertySetAdd() to add a bunch of desired property values to a single userspace property set object, then dispatch that whole set to the kernel with drmModePropertySetCommit() which calls the DRM_IOCTL_MODE_ATOMIC ioctl. The kernel can sanity check the whole batch of property values and then either accept or reject the whole set together in a transactional manner (so you don't have to worry about winding up in some strange limbo where some of your changes were good and took effect but others weren't).

Quoted 7 lines

Not to say your proposed solution directly conflicts with the atomic programming approach in any way (programming a single CRTC property works the same way as programming a bunch of separate plane properties in that case); I just want to make sure you understand the direction that we're expecting the API's to go in the near (hopefully!) future so that we can make sure we're settling on the best possible approach for z-order handling for the long term.

Agree.

Quoted 8 lines

For the specific approach you propose above, can you clarify what the logic looks like from the point of view of a generic (non hw-specific) userspace compositor (e.g., Weston)? The compositor, which starts out knowing nothing at all about the underlying hardware, would call drmModeGetPlaneResources() and get a list of all the planes that are present. How does it know which of the HW-specific plane ID's you #define above correspond to which planes in the plane list it received? Are these ID's going to show up as immutable plane properties or

Quoted 9 lines

something that userspace can read? Is it going to assume that those values correspond to the order that planes show up in the plane list? One of the advantages of using a single value to program z-order as you're doing here is that presumably there can be a mechanism to advertise what the valid plane orderings are so that the compositor doesn't have to spend some time at startup testing the various combinations itself...do you have plans on how you'd enumerate the valid configs for userspace?

I submitted the new patch for review. It is still based on the assumption that user knows how those surfaces are mapped to HW planes. Such as, which one is primary and which one is sprite A etc. If not such case, it won't work.

Alex