[Intel-gfx] [PATCH i-g-t 2/6] lib/igt_kms: Rework connector properties to be more atomic
Maarten Lankhorst
maarten.lankhorst at linux.intel.com
Tue Sep 26 13:06:44 UTC 2017
In the future I want to allow tests to commit more properties,
but for this to work I have to fix all properties to work better
with atomic commit. Instead of special casing each
property make a bitmask for all property changed flags, and try to
commit all properties.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
---
lib/igt_kms.c | 41 ++++++++++++++++------------------------
lib/igt_kms.h | 35 ++++++++++++++++++++--------------
tests/kms_atomic_interruptible.c | 4 ++--
tests/kms_panel_fitting.c | 2 +-
4 files changed, 40 insertions(+), 42 deletions(-)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 7bcafc072f70..33a5668edb09 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -248,7 +248,7 @@ igt_atomic_fill_connector_props(igt_display_t *display, igt_output_t *output,
if (strcmp(prop->name, conn_prop_names[j]) != 0)
continue;
- output->config.atomic_props_connector[j] = props->props[i];
+ output->props[j] = props->props[i];
break;
}
@@ -1836,7 +1836,7 @@ void igt_display_init(igt_display_t *display, int drm_fd)
igt_output_refresh(output);
- output->config.pipe_changed = true;
+ igt_output_set_prop_changed(output, IGT_CONNECTOR_CRTC_ID);
}
drmModeFreePlaneResources(plane_resources);
@@ -2514,23 +2514,17 @@ static void igt_atomic_prepare_crtc_commit(igt_pipe_t *pipe_obj, drmModeAtomicRe
static void igt_atomic_prepare_connector_commit(igt_output_t *output, drmModeAtomicReq *req)
{
- struct kmstest_connector_config *config = &output->config;
-
- if (config->connector_scaling_mode_changed)
- igt_atomic_populate_connector_req(req, output, IGT_CONNECTOR_SCALING_MODE, config->connector_scaling_mode);
-
- if (config->pipe_changed) {
- uint32_t crtc_id = 0;
+ int i;
- if (output->config.pipe != PIPE_NONE)
- crtc_id = output->config.crtc->crtc_id;
+ for (i = 0; i < IGT_NUM_CONNECTOR_PROPS; i++) {
+ if (!igt_output_is_prop_changed(output, i))
+ continue;
- igt_atomic_populate_connector_req(req, output, IGT_CONNECTOR_CRTC_ID, crtc_id);
+ igt_assert_lt(0, drmModeAtomicAddProperty(req,
+ output->config.connector->connector_id,
+ output->props[i],
+ output->values[i]));
}
- /*
- * TODO: Add all other connector level properties here
- */
-
}
/*
@@ -2625,11 +2619,10 @@ display_commit_changed(igt_display_t *display, enum igt_commit_style s)
for (i = 0; i < display->n_outputs; i++) {
igt_output_t *output = &display->outputs[i];
- if (s != COMMIT_UNIVERSAL)
- output->config.pipe_changed = false;
-
if (s == COMMIT_ATOMIC)
- output->config.connector_scaling_mode_changed = false;
+ output->changed = 0;
+ else if (s != COMMIT_UNIVERSAL)
+ igt_output_clear_prop_changed(output, IGT_CONNECTOR_CRTC_ID);
}
}
@@ -2877,18 +2870,16 @@ void igt_output_set_pipe(igt_output_t *output, enum pipe pipe)
display->pipes[pipe].mode_changed = true;
}
- output->config.pipe_changed = true;
+ igt_output_set_prop_value(output, IGT_CONNECTOR_CRTC_ID, pipe == PIPE_NONE ? 0 : display->pipes[pipe].crtc_id);
igt_output_refresh(output);
}
void igt_output_set_scaling_mode(igt_output_t *output, uint64_t scaling_mode)
{
- output->config.connector_scaling_mode_changed = true;
-
- output->config.connector_scaling_mode = scaling_mode;
+ igt_output_set_prop_value(output, IGT_CONNECTOR_SCALING_MODE, scaling_mode);
- igt_require(output->config.atomic_props_connector[IGT_CONNECTOR_SCALING_MODE]);
+ igt_require(output->props[IGT_CONNECTOR_SCALING_MODE]);
}
igt_plane_t *igt_output_get_plane(igt_output_t *output, int plane_idx)
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 62197dcfea7b..1e5e3ed01f38 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -131,10 +131,7 @@ struct kmstest_connector_config {
drmModeConnector *connector;
drmModeEncoder *encoder;
drmModeModeInfo default_mode;
- uint64_t connector_scaling_mode;
- bool connector_scaling_mode_changed;
- bool pipe_changed;
- uint32_t atomic_props_connector[IGT_NUM_CONNECTOR_PROPS];
+
int pipe;
unsigned valid_crtc_idx_mask;
};
@@ -364,6 +361,12 @@ typedef struct {
unsigned long pending_crtc_idx_mask;
bool use_override_mode;
drmModeModeInfo override_mode;
+
+ /* bitmask of changed properties */
+ uint64_t changed;
+
+ uint32_t props[IGT_NUM_CONNECTOR_PROPS];
+ uint64_t values[IGT_NUM_CONNECTOR_PROPS];
} igt_output_t;
struct igt_display {
@@ -545,16 +548,20 @@ static inline bool igt_output_is_connected(igt_output_t *output)
#define igt_atomic_populate_crtc_req(req, pipe, prop, value) \
igt_assert_lt(0, drmModeAtomicAddProperty(req, pipe->crtc_id,\
pipe->atomic_props_crtc[prop], value))
-/**
- * igt_atomic_populate_connector_req:
- * @req: A pointer to drmModeAtomicReq
- * @output: A pointer igt_output_t
- * @prop: one of igt_atomic_connector_properties
- * @value: the value to add
- */
-#define igt_atomic_populate_connector_req(req, output, prop, value) \
- igt_assert_lt(0, drmModeAtomicAddProperty(req, output->config.connector->connector_id,\
- output->config.atomic_props_connector[prop], value))
+
+#define igt_output_is_prop_changed(output, prop) \
+ (!!((output)->changed & (1 << (prop))))
+#define igt_output_set_prop_changed(output, prop) \
+ (output)->changed |= 1 << (prop)
+
+#define igt_output_clear_prop_changed(output, prop) \
+ (output)->changed &= ~(1 << (prop))
+
+#define igt_output_set_prop_value(output, prop, value) \
+ do { \
+ (output)->values[prop] = (value); \
+ igt_output_set_prop_changed(output, prop); \
+ } while (0)
/*
* igt_pipe_refresh:
diff --git a/tests/kms_atomic_interruptible.c b/tests/kms_atomic_interruptible.c
index 4e06ee4e2d6b..2d19fe967809 100644
--- a/tests/kms_atomic_interruptible.c
+++ b/tests/kms_atomic_interruptible.c
@@ -159,7 +159,7 @@ static void run_plane_test(igt_display_t *display, enum pipe pipe, igt_output_t
plane->pipe->atomic_props_crtc[IGT_CRTC_MODE_ID],
plane->pipe->atomic_props_crtc[IGT_CRTC_ACTIVE],
/* connector: 1 prop */
- output->config.atomic_props_connector[IGT_CONNECTOR_CRTC_ID],
+ output->props[IGT_CONNECTOR_CRTC_ID],
/* plane: remainder props */
plane->atomic_props_plane[IGT_PLANE_CRTC_ID],
plane->atomic_props_plane[IGT_PLANE_FB_ID],
@@ -204,7 +204,7 @@ static void run_plane_test(igt_display_t *display, enum pipe pipe, igt_output_t
case test_legacy_dpms: {
struct drm_mode_connector_set_property prop = {
.value = DRM_MODE_DPMS_OFF,
- .prop_id = output->config.atomic_props_connector[IGT_CONNECTOR_DPMS],
+ .prop_id = output->props[IGT_CONNECTOR_DPMS],
.connector_id = output->id,
};
diff --git a/tests/kms_panel_fitting.c b/tests/kms_panel_fitting.c
index 85a231e60ea2..e4ea355611c3 100644
--- a/tests/kms_panel_fitting.c
+++ b/tests/kms_panel_fitting.c
@@ -275,7 +275,7 @@ static void test_atomic_fastset(igt_display_t *display)
igt_require(intel_gen(intel_get_drm_devid(display->drm_fd)) >= 5);
for_each_pipe_with_valid_output(display, pipe, output) {
- if (!output->config.atomic_props_connector[IGT_CONNECTOR_SCALING_MODE])
+ if (!output->props[IGT_CONNECTOR_SCALING_MODE])
continue;
test_panel_fitting_fastset(display, pipe, output);
--
2.14.1
More information about the Intel-gfx
mailing list