Commit 13ead623 authored by Maarten Lankhorst's avatar Maarten Lankhorst

lib/igt_kms: Rework connector properties to be more atomic, v2.

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.

Changs since v1:
- Mention which properties we set to what.
- Assert the property to be set is valid.
Signed-off-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: default avatarMika Kahola <mika.kahola@intel.com>
parent abc08cba
...@@ -248,7 +248,7 @@ igt_atomic_fill_connector_props(igt_display_t *display, igt_output_t *output, ...@@ -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) if (strcmp(prop->name, conn_prop_names[j]) != 0)
continue; continue;
output->config.atomic_props_connector[j] = props->props[i]; output->props[j] = props->props[i];
break; break;
} }
...@@ -1834,7 +1834,7 @@ void igt_display_init(igt_display_t *display, int drm_fd) ...@@ -1834,7 +1834,7 @@ void igt_display_init(igt_display_t *display, int drm_fd)
igt_output_refresh(output); igt_output_refresh(output);
output->config.pipe_changed = true; igt_output_set_prop_changed(output, IGT_CONNECTOR_CRTC_ID);
} }
drmModeFreePlaneResources(plane_resources); drmModeFreePlaneResources(plane_resources);
...@@ -2514,23 +2514,24 @@ static void igt_atomic_prepare_crtc_commit(igt_pipe_t *pipe_obj, drmModeAtomicRe ...@@ -2514,23 +2514,24 @@ 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) static void igt_atomic_prepare_connector_commit(igt_output_t *output, drmModeAtomicReq *req)
{ {
struct kmstest_connector_config *config = &output->config; int i;
if (config->connector_scaling_mode_changed) for (i = 0; i < IGT_NUM_CONNECTOR_PROPS; i++) {
igt_atomic_populate_connector_req(req, output, IGT_CONNECTOR_SCALING_MODE, config->connector_scaling_mode); if (!igt_output_is_prop_changed(output, i))
continue;
if (config->pipe_changed) { /* it's an error to try an unsupported feature */
uint32_t crtc_id = 0; igt_assert(output->props[i]);
if (output->config.pipe != PIPE_NONE) igt_debug("%s: Setting property \"%s\" to 0x%"PRIx64"/%"PRIi64"\n",
crtc_id = output->config.crtc->crtc_id; igt_output_name(output), igt_connector_prop_names[i],
output->values[i], output->values[i]);
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 +2626,10 @@ display_commit_changed(igt_display_t *display, enum igt_commit_style s) ...@@ -2625,11 +2626,10 @@ display_commit_changed(igt_display_t *display, enum igt_commit_style s)
for (i = 0; i < display->n_outputs; i++) { for (i = 0; i < display->n_outputs; i++) {
igt_output_t *output = &display->outputs[i]; igt_output_t *output = &display->outputs[i];
if (s != COMMIT_UNIVERSAL)
output->config.pipe_changed = false;
if (s == COMMIT_ATOMIC) 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);
} }
} }
...@@ -2873,18 +2873,16 @@ void igt_output_set_pipe(igt_output_t *output, enum pipe pipe) ...@@ -2873,18 +2873,16 @@ void igt_output_set_pipe(igt_output_t *output, enum pipe pipe)
if (pipe != PIPE_NONE) if (pipe != PIPE_NONE)
display->pipes[pipe].mode_changed = true; 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); igt_output_refresh(output);
} }
void igt_output_set_scaling_mode(igt_output_t *output, uint64_t scaling_mode) void igt_output_set_scaling_mode(igt_output_t *output, uint64_t scaling_mode)
{ {
output->config.connector_scaling_mode_changed = true; igt_output_set_prop_value(output, IGT_CONNECTOR_SCALING_MODE, scaling_mode);
output->config.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) igt_plane_t *igt_output_get_plane(igt_output_t *output, int plane_idx)
......
...@@ -131,10 +131,7 @@ struct kmstest_connector_config { ...@@ -131,10 +131,7 @@ struct kmstest_connector_config {
drmModeConnector *connector; drmModeConnector *connector;
drmModeEncoder *encoder; drmModeEncoder *encoder;
drmModeModeInfo default_mode; 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; int pipe;
unsigned valid_crtc_idx_mask; unsigned valid_crtc_idx_mask;
}; };
...@@ -364,6 +361,12 @@ typedef struct { ...@@ -364,6 +361,12 @@ typedef struct {
enum pipe pending_pipe; enum pipe pending_pipe;
bool use_override_mode; bool use_override_mode;
drmModeModeInfo 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; } igt_output_t;
struct igt_display { struct igt_display {
...@@ -545,16 +548,20 @@ static inline bool igt_output_is_connected(igt_output_t *output) ...@@ -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) \ #define igt_atomic_populate_crtc_req(req, pipe, prop, value) \
igt_assert_lt(0, drmModeAtomicAddProperty(req, pipe->crtc_id,\ igt_assert_lt(0, drmModeAtomicAddProperty(req, pipe->crtc_id,\
pipe->atomic_props_crtc[prop], value)) pipe->atomic_props_crtc[prop], value))
/**
* igt_atomic_populate_connector_req: #define igt_output_is_prop_changed(output, prop) \
* @req: A pointer to drmModeAtomicReq (!!((output)->changed & (1 << (prop))))
* @output: A pointer igt_output_t #define igt_output_set_prop_changed(output, prop) \
* @prop: one of igt_atomic_connector_properties (output)->changed |= 1 << (prop)
* @value: the value to add
*/ #define igt_output_clear_prop_changed(output, prop) \
#define igt_atomic_populate_connector_req(req, output, prop, value) \ (output)->changed &= ~(1 << (prop))
igt_assert_lt(0, drmModeAtomicAddProperty(req, output->config.connector->connector_id,\
output->config.atomic_props_connector[prop], value)) #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: * igt_pipe_refresh:
......
...@@ -161,7 +161,7 @@ static void run_plane_test(igt_display_t *display, enum pipe pipe, igt_output_t ...@@ -161,7 +161,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_MODE_ID],
plane->pipe->atomic_props_crtc[IGT_CRTC_ACTIVE], plane->pipe->atomic_props_crtc[IGT_CRTC_ACTIVE],
/* connector: 1 prop */ /* connector: 1 prop */
output->config.atomic_props_connector[IGT_CONNECTOR_CRTC_ID], output->props[IGT_CONNECTOR_CRTC_ID],
/* plane: remainder props */ /* plane: remainder props */
plane->atomic_props_plane[IGT_PLANE_CRTC_ID], plane->atomic_props_plane[IGT_PLANE_CRTC_ID],
plane->atomic_props_plane[IGT_PLANE_FB_ID], plane->atomic_props_plane[IGT_PLANE_FB_ID],
...@@ -206,7 +206,7 @@ static void run_plane_test(igt_display_t *display, enum pipe pipe, igt_output_t ...@@ -206,7 +206,7 @@ static void run_plane_test(igt_display_t *display, enum pipe pipe, igt_output_t
case test_legacy_dpms: { case test_legacy_dpms: {
struct drm_mode_connector_set_property prop = { struct drm_mode_connector_set_property prop = {
.value = DRM_MODE_DPMS_OFF, .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, .connector_id = output->id,
}; };
......
...@@ -275,7 +275,7 @@ static void test_atomic_fastset(igt_display_t *display) ...@@ -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); igt_require(intel_gen(intel_get_drm_devid(display->drm_fd)) >= 5);
for_each_pipe_with_valid_output(display, pipe, output) { 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; continue;
test_panel_fitting_fastset(display, pipe, output); test_panel_fitting_fastset(display, pipe, output);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment