[igt-dev] [for trybot 7/7] lib/igt_kms: Add support for igt_display_readout_hw_state
Maarten Lankhorst
maarten.lankhorst at linux.intel.com
Thu Jan 18 11:14:06 UTC 2018
Signed-off-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
---
lib/igt_kms.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
lib/igt_kms.h | 1 +
2 files changed, 76 insertions(+)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index eb57f4a99454..11f23fcaaa81 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1776,6 +1776,81 @@ void igt_display_reset(igt_display_t *display)
}
}
+/**
+ * igt_display_readout_hw_state:
+ * @display: a pointer to an #igt_display_t structure
+ *
+ * Reads in the current state for pipes, connectors and planes on @display.
+ * It will also set output->pending_pipe based on the current crtc the pipe
+ * is set on.
+ *
+ * This function requires an atomic driver, and will skip if not found.
+ * If the mode must be preserved across the entire test, then commits
+ * should be done atomically with the %DRM_MODE_ATOMIC_ALLOW_MODESET flag
+ * cleared.
+ */
+void igt_display_readout_hw_state(igt_display_t *display)
+{
+ enum pipe pipe;
+ int i;
+
+ igt_display_reset(display);
+
+ /*
+ * igt_display matches closely the atomic interfaces, implementing
+ * legacy readout would be a nice source of bugs.
+ */
+ igt_require_f(display->is_atomic, "readout only implemented for atomic drivers\n");
+
+ for_each_pipe(display, pipe) {
+ igt_pipe_t *pipe_obj = &display->pipes[pipe];
+ igt_plane_t *plane;
+
+ for (i = 0; i < IGT_NUM_CRTC_PROPS; i++) {
+ if (igt_pipe_obj_has_prop(pipe_obj, i))
+ pipe_obj->values[i] = igt_pipe_obj_get_prop(pipe_obj, i);
+ }
+
+ for_each_plane_on_pipe(display, pipe, plane) {
+ for (i = 0; i < IGT_NUM_PLANE_PROPS; i++) {
+ if (igt_plane_has_prop(plane, i))
+ plane->values[i] = igt_plane_get_prop(plane, i);
+ }
+
+ plane->changed = 0;
+ }
+ pipe_obj->changed = 0;
+ }
+
+ for (i = 0; i < display->n_outputs; i++) {
+ igt_output_t *output = &display->outputs[i];
+ uint64_t crtc_id;
+ int j;
+
+ for (j = 0; j < IGT_NUM_CONNECTOR_PROPS; j++)
+ if (igt_output_has_prop(output, i))
+ output->values[i] = igt_output_get_prop(output, i);
+
+ crtc_id = output->values[IGT_CONNECTOR_CRTC_ID];
+
+ output->pending_pipe = output->config.pipe = PIPE_NONE;
+ output->changed = 0;
+
+ if (crtc_id) {
+ for_each_pipe(display, pipe) {
+ igt_pipe_t *pipe_obj = &display->pipes[pipe];
+
+ if (pipe_obj->crtc_id != crtc_id)
+ continue;
+
+ output->pending_pipe = output->config.pipe = pipe;
+ break;
+ }
+ igt_assert(output->pending_pipe != PIPE_NONE);
+ }
+ }
+}
+
/**
* igt_display_init:
* @display: a pointer to an #igt_display_t structure
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index b75210393d3b..85e9564adf34 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -360,6 +360,7 @@ struct igt_display {
void igt_display_init(igt_display_t *display, int drm_fd);
void igt_display_fini(igt_display_t *display);
void igt_display_reset(igt_display_t *display);
+void igt_display_readout_hw_state(igt_display_t *display);
int igt_display_commit2(igt_display_t *display, enum igt_commit_style s);
int igt_display_commit(igt_display_t *display);
int igt_display_try_commit_atomic(igt_display_t *display, uint32_t flags, void *user_data);
--
2.15.1
More information about the igt-dev
mailing list