summaryrefslogtreecommitdiff
path: root/lib/igt_kms.c
diff options
context:
space:
mode:
authorBrian Starkey <rodrigosiqueiramelo@gmail.com>2020-08-30 13:44:07 -0400
committerPetri Latvala <petri.latvala@intel.com>2020-09-04 14:51:17 +0300
commit3642acbb74f562435b8d7455a5467d869d331350 (patch)
tree1fe487b204b11a42f8e02bfec857d35135bf8b73 /lib/igt_kms.c
parent9a9db93fd2f2f59eb37b79d4b9a623067a945bac (diff)
lib/igt_kms: Add writeback support
Add support in igt_kms for writeback connectors, with the ability to attach framebuffers. v8: Remove unnecessary fence cleanup on prepare commit. v5: Rebase and add DRM_CLIENT_CAP_WRITEBACK_CONNECTORS before drmModeGetResources() Signed-off-by: Brian Starkey <brian.starkey@arm.com> [rebased and updated to the latest igt style] Signed-off-by: Liviu Dudau <liviu.dudau@arm.com> [rebased and updated to the latest igt style] Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com> Reviewed-by: Liviu Dudau <liviu.dudau@arm.com> Reviewed-by: Simon Ser <simon.ser@intel.com>
Diffstat (limited to 'lib/igt_kms.c')
-rw-r--r--lib/igt_kms.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index f57972f1..7cf2008e 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -421,6 +421,9 @@ const char * const igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
[IGT_CONNECTOR_LINK_STATUS] = "link-status",
[IGT_CONNECTOR_MAX_BPC] = "max bpc",
[IGT_CONNECTOR_HDR_OUTPUT_METADATA] = "HDR_OUTPUT_METADATA",
+ [IGT_CONNECTOR_WRITEBACK_PIXEL_FORMATS] = "WRITEBACK_PIXEL_FORMATS",
+ [IGT_CONNECTOR_WRITEBACK_FB_ID] = "WRITEBACK_FB_ID",
+ [IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR] = "WRITEBACK_OUT_FENCE_PTR",
};
/*
@@ -653,6 +656,7 @@ static const struct type_name connector_type_names[] = {
{ DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" },
{ DRM_MODE_CONNECTOR_DSI, "DSI" },
{ DRM_MODE_CONNECTOR_DPI, "DPI" },
+ { DRM_MODE_CONNECTOR_WRITEBACK, "Writeback" },
{}
};
@@ -1813,6 +1817,14 @@ static void igt_output_reset(igt_output_t *output)
if (igt_output_has_prop(output, IGT_CONNECTOR_HDR_OUTPUT_METADATA))
igt_output_set_prop_value(output,
IGT_CONNECTOR_HDR_OUTPUT_METADATA, 0);
+
+ if (igt_output_has_prop(output, IGT_CONNECTOR_WRITEBACK_FB_ID))
+ igt_output_set_prop_value(output, IGT_CONNECTOR_WRITEBACK_FB_ID, 0);
+ if (igt_output_has_prop(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR)) {
+ igt_output_clear_prop_changed(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR);
+ output->writeback_out_fence_fd = -1;
+ }
+
}
/**
@@ -1930,6 +1942,8 @@ void igt_display_require(igt_display_t *display, int drm_fd)
display->drm_fd = drm_fd;
is_i915_dev = is_i915_device(drm_fd);
+ drmSetClientCap(drm_fd, DRM_CLIENT_CAP_WRITEBACK_CONNECTORS, 1);
+
resources = drmModeGetResources(display->drm_fd);
if (!resources)
goto out;
@@ -2268,6 +2282,11 @@ static void igt_output_fini(igt_output_t *output)
kmstest_free_connector_config(&output->config);
free(output->name);
output->name = NULL;
+
+ if (output->writeback_out_fence_fd != -1) {
+ close(output->writeback_out_fence_fd);
+ output->writeback_out_fence_fd = -1;
+ }
}
/**
@@ -3458,6 +3477,16 @@ display_commit_changed(igt_display_t *display, enum igt_commit_style s)
else
/* no modeset in universal commit, no change to crtc. */
output->changed &= 1 << IGT_CONNECTOR_CRTC_ID;
+
+ if (s == COMMIT_ATOMIC) {
+ if (igt_output_is_prop_changed(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR))
+ igt_assert(output->writeback_out_fence_fd >= 0);
+
+ output->values[IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR] = 0;
+ output->values[IGT_CONNECTOR_WRITEBACK_FB_ID] = 0;
+ igt_output_clear_prop_changed(output, IGT_CONNECTOR_WRITEBACK_FB_ID);
+ igt_output_clear_prop_changed(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR);
+ }
}
if (display->first_commit) {
@@ -4131,6 +4160,29 @@ void igt_pipe_request_out_fence(igt_pipe_t *pipe)
}
/**
+ * igt_output_set_writeback_fb:
+ * @output: Target output
+ * @fb: Target framebuffer
+ *
+ * This function sets the given @fb to be used as the target framebuffer for the
+ * writeback engine at the next atomic commit. It will also request a writeback
+ * out fence that will contain the fd number of the out fence created by KMS if
+ * the given @fb is valid.
+ */
+void igt_output_set_writeback_fb(igt_output_t *output, struct igt_fb *fb)
+{
+ igt_display_t *display = output->display;
+
+ LOG(display, "%s: output_set_writeback_fb(%d)\n", output->name, fb ? fb->fb_id : 0);
+
+ igt_output_set_prop_value(output, IGT_CONNECTOR_WRITEBACK_FB_ID, fb ? fb->fb_id : 0);
+ /* only request a writeback out fence if the framebuffer is valid */
+ if (fb)
+ igt_output_set_prop_value(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR,
+ (ptrdiff_t)&output->writeback_out_fence_fd);
+}
+
+/**
* igt_wait_for_vblank_count:
* @drm_fd: A drm file descriptor
* @crtc_offset: offset of the crtc in drmModeRes.crtcs