[Intel-gfx] [PATCH 06/12] lib/igt_kms: Add support for the IN_FENCE_FD property

Brian Starkey brian.starkey at arm.com
Tue Nov 22 11:41:08 UTC 2016


Hi,

On Mon, Nov 14, 2016 at 06:59:20PM +0900, Gustavo Padovan wrote:
>From: Robert Foss <robert.foss at collabora.com>
>
>Add support dor the IN_FENCE_FD property to enable setting in fences for atomic
>commits.
>
>Signed-off-by: Robert Foss <robert.foss at collabora.com>
>---
> lib/igt_kms.c | 20 ++++++++++++++++++++
> lib/igt_kms.h |  5 +++++
> 2 files changed, 25 insertions(+)
>
>diff --git a/lib/igt_kms.c b/lib/igt_kms.c
>index 8aaff5b..4748c0a 100644
>--- a/lib/igt_kms.c
>+++ b/lib/igt_kms.c
>@@ -164,6 +164,7 @@ const char *igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
> 	"CRTC_H",
> 	"FB_ID",
> 	"CRTC_ID",
>+	"IN_FENCE_FD",
> 	"type",
> 	"rotation"
> };
>@@ -1426,6 +1427,7 @@ void igt_display_init(igt_display_t *display, int drm_fd)
> 			n_planes++;
> 			plane->pipe = pipe;
> 			plane->drm_plane = drm_plane;
>+			plane->fence_fd = -1;
>
> 			if (is_atomic == 0) {
> 				display->is_atomic = 1;
>@@ -1712,6 +1714,11 @@ igt_atomic_prepare_plane_commit(igt_plane_t *plane, igt_pipe_t *pipe,
> 	    plane->index,
> 	    fb_id);
>
>+	if (plane->fence_fd >= 0) {
>+		uint32_t fence_fd = plane->fence_fd;

Assigning to uint32_t here will make the top bytes zero when it gets
cast to uint64_t. I guess that works out fine because the cast back to
int in the kernel will be 32-bits, but IMO better to cast to int64_t
here to get proper sign-extension to 64-bits.

>+		igt_atomic_populate_plane_req(req, plane, IGT_PLANE_IN_FENCE_FD, fence_fd);
>+	}
>+
> 	if (plane->fb_changed) {
> 		igt_atomic_populate_plane_req(req, plane, IGT_PLANE_CRTC_ID, fb_id ? crtc_id : 0);
> 		igt_atomic_populate_plane_req(req, plane, IGT_PLANE_FB_ID, fb_id);
>@@ -2522,6 +2529,19 @@ void igt_plane_set_fb(igt_plane_t *plane, struct igt_fb *fb)
> 	plane->size_changed = true;
> }
>
>+/**
>+ * igt_plane_set_fence_fd:
>+ * @plane: plane
>+ * @fence_fd: fence fd, disable fence_fd by setting it to 0

Should be -1 to disable.

Cheers,
Brian

>+ *
>+ * This function sets a fence fd to enable a commit to wait for some event to
>+ * occur before completing.
>+ */
>+void igt_plane_set_fence_fd(igt_plane_t *plane, uint32_t fence_fd)
>+{
>+	plane->fence_fd = fence_fd;
>+}
>+
> void igt_plane_set_position(igt_plane_t *plane, int x, int y)
> {
> 	igt_pipe_t *pipe = plane->pipe;
>diff --git a/lib/igt_kms.h b/lib/igt_kms.h
>index ae2b505..344f931 100644
>--- a/lib/igt_kms.h
>+++ b/lib/igt_kms.h
>@@ -213,6 +213,7 @@ enum igt_atomic_plane_properties {
>
>        IGT_PLANE_FB_ID,
>        IGT_PLANE_CRTC_ID,
>+       IGT_PLANE_IN_FENCE_FD,
>        IGT_PLANE_TYPE,
>        IGT_PLANE_ROTATION,
>        IGT_NUM_PLANE_PROPS
>@@ -266,6 +267,9 @@ typedef struct {
> 	uint32_t src_h;
>
> 	igt_rotation_t rotation;
>+
>+	/* in fence fd */
>+	int32_t fence_fd;
> 	uint32_t atomic_props_plane[IGT_NUM_PLANE_PROPS];
> } igt_plane_t;
>
>@@ -349,6 +353,7 @@ void igt_pipe_set_ctm_matrix(igt_pipe_t *pipe, void *ptr, size_t length);
> void igt_pipe_set_gamma_lut(igt_pipe_t *pipe, void *ptr, size_t length);
>
> void igt_plane_set_fb(igt_plane_t *plane, struct igt_fb *fb);
>+void igt_plane_set_fence_fd(igt_plane_t *plane, uint32_t fence_fd);
> void igt_plane_set_position(igt_plane_t *plane, int x, int y);
> void igt_plane_set_size(igt_plane_t *plane, int w, int h);
> void igt_plane_set_rotation(igt_plane_t *plane, igt_rotation_t rotation);
>-- 
>2.5.5
>
>_______________________________________________
>dri-devel mailing list
>dri-devel at lists.freedesktop.org
>https://lists.freedesktop.org/mailman/listinfo/dri-devel


More information about the Intel-gfx mailing list