Skip to contentSkip to conversation

Add support for atomic modeset to IGT.

PATCH Superseded Maarten Lankhorst 1 participant 11 messages Jun 30, 2016 Library code

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Add support for atomic modeset to IGT.

Big patch series to perform a single thing.

With legacy modesets if the primary plane had a null fb it was disabled, and code would often do the following:

for_each_pipe(...)

	for_each_output(...) {
		igt_output_set_pipe(output, pipe);

		igt_display_commit();

		if (!output->valid)
			bail;

		cleanup;
		igt_output_set_pipe(output, PIPE_ANY);
		igt_display_commit();
	}

A straightforward replacement of igt_display_commit with igt_display_commit2(COMMIT_ATOMIC) will not work with this series, since in this case it can perform a modeset without primary framebuffer, and invalid configurations get rejected.

Best solution is to do the following to get atomic behavior, with fallback to legacy:

bool valid = false;

for_each_pipe_with_valid_output(display, pipe, output) {
	valid = true;

	igt_output_set_pipe(output, pipe);
	/* perform more setup here for planes, etc */
	igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);

	/* tests + cleanup */
	igt_output_set_pipe(output, PIPE_NONE);
}

igt_require_f(valid, "no valid crtc/connector combinations found\n");

If the test requires a fixed pipe, use for_each_valid_output_on_pipe instead.

Maarten Lankhorst (10):
igt_kms: Remove kmstest_connector_config.crtc_idx
igt_kms: Find optimal encoder only after selecting pipe
kms_psr_sink_crc: Use for_each_pipe_with_valid_output to find a valid
config.
igt_kms: Make PIPE_ANY a alias for PIPE_NONE
igt_kms: Change PIPE_ANY behavior to mean unassigned
igt_kms: Handle atomic pipe properties better.
igt_kms: Remove pan members from igt_plane
igt_kms: Clear all _changed members centrally
igt_kms: Add modeset support to atomic commits.
tests: Add kms_rmfb test.

 lib/igt_kms.c             | 626 ++++++++++++++++++++++++++--------------------
 lib/igt_kms.h             |  48 ++--
 tests/Makefile.sources    |   1 +
 tests/kms_panel_fitting.c |   2 +-
 tests/kms_plane.c         |   8 +-
 tests/kms_plane_scaling.c |   2 +-
 tests/kms_psr_sink_crc.c  |   5 +-
 tests/kms_rmfb.c          | 171 +++++++++++++
 tests/testdisplay.c       |   4 +-
 9 files changed, 567 insertions(+), 300 deletions(-)
 create mode 100644 tests/kms_rmfb.c
Signature · 6 lines
2.5.5

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 1/10 igt_kms: Remove kmstest_connector_config.crtc_idx

This is the same as using config.pipe because the order of crtcs will never change.

---
 lib/igt_kms.c       | 4 +---
 lib/igt_kms.h       | 1 -
 tests/testdisplay.c | 4 +---
 3 files changed, 2 insertions(+), 7 deletions(-)
lib/igt_kms.c +1 -3
index f9e32a5a2e3d..f1ada2850707 100644
@@ -848,9 +848,7 @@ static bool _kmstest_connector_config(int drm_fd, uint32_t connector_id,
 	config->connector = connector;
 	config->encoder = found;
 	config->crtc = drmModeGetCrtc(drm_fd, resources->crtcs[pipe]);
-	config->crtc_idx = pipe;
-	config->pipe = kmstest_get_pipe_from_crtc_id(drm_fd,
-						     config->crtc->crtc_id);
+	config->pipe = pipe;
 
 	drmModeFreeResources(resources);
 
lib/igt_kms.h +0 -1
index b66743a29027..4b15528c2858 100644
@@ -112,7 +112,6 @@ struct kmstest_connector_config {
 	bool connector_dpms_changed;
 	uint32_t atomic_props_crtc[IGT_NUM_CRTC_PROPS];
 	uint32_t atomic_props_connector[IGT_NUM_CONNECTOR_PROPS];
-	int crtc_idx;
 	int pipe;
 	unsigned valid_crtc_idx_mask;
 };
tests/testdisplay.c +1 -3
index 45280e4cad82..a974f42be9f1 100644
@@ -112,7 +112,6 @@ struct connector {
 	drmModeEncoder *encoder;
 	drmModeConnector *connector;
 	int crtc;
-	int crtc_idx;
 	int pipe;
 };
 
@@ -211,7 +210,6 @@ static void connector_find_preferred_mode(uint32_t connector_id,
 	c->connector = config.connector;
 	c->encoder = config.encoder;
 	c->crtc = config.crtc->crtc_id;
-	c->crtc_idx = config.crtc_idx;
 	c->pipe = config.pipe;
 
 	if (mode_num != -1) {
@@ -497,7 +495,7 @@ int update_display(bool probe)
 
 			if (test_preferred_mode || force_mode ||
 			    specified_mode_num != -1)
-				crtc_idx_mask &= ~(1 << connector->crtc_idx);
+				crtc_idx_mask &= ~(1 << connector->pipe);
 
 		}
 	}
Signature · 6 lines
2.5.5

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

PATCH 2/10 igt_kms: Find optimal encoder only after selecting pipe

In reply to Maarten Lankhorst

This will allow us to find a matching encoder based on a pipe only.

---
 lib/igt_kms.c | 98 +++++++++++++++++++++++++++++++++++++----------------------
 1 file changed, 62 insertions(+), 36 deletions(-)
lib/igt_kms.c +62 -36
index f1ada2850707..8b9c7c9234c6 100644
@@ -755,6 +755,59 @@ bool kmstest_get_connector_default_mode(int drm_fd, drmModeConnector *connector,
 	return true;
 }
 
+static void
+_kmstest_connector_config_crtc_mask(int drm_fd,
+				    drmModeConnector *connector,
+				    struct kmstest_connector_config *config)
+{
+	int i;
+
+	config->valid_crtc_idx_mask = 0;
+
+	/* Now get a compatible encoder */
+	for (i = 0; i < connector->count_encoders; i++) {
+		drmModeEncoder *encoder = drmModeGetEncoder(drm_fd,
+							    connector->encoders[i]);
+
+		if (!encoder) {
+			igt_warn("could not get encoder %d: %s\n",
+				 connector->encoders[i],
+				 strerror(errno));
+
+			continue;
+		}
+
+		config->valid_crtc_idx_mask |= encoder->possible_crtcs;
+		drmModeFreeEncoder(encoder);
+	}
+}
+
+static drmModeEncoder *
+_kmstest_connector_config_find_encoder(int drm_fd, drmModeConnector *connector, enum pipe pipe)
+{
+	int i;
+
+	for (i = 0; i < connector->count_encoders; i++) {
+		drmModeEncoder *encoder = drmModeGetEncoder(drm_fd, connector->encoders[i]);
+
+		if (!encoder) {
+			igt_warn("could not get encoder %d: %s\n",
+				 connector->encoders[i],
+				 strerror(errno));
+
+			continue;
+		}
+
+		if (encoder->possible_crtcs & (1 << pipe))
+			return encoder;
+
+		drmModeFreeEncoder(encoder);
+	}
+
+	igt_assert(false);
+	return NULL;
+}
+
 /**
  * _kmstest_connector_config:
  * @drm_fd: DRM fd
@@ -773,8 +826,7 @@ static bool _kmstest_connector_config(int drm_fd, uint32_t connector_id,
 {
 	drmModeRes *resources;
 	drmModeConnector *connector;
-	drmModeEncoder *encoder, *found = NULL;
-	int i, j, pipe;
+	drmModeEncoder *encoder;
 
 	resources = drmModeGetResources(drm_fd);
 	if (!resources) {
@@ -810,51 +862,25 @@ static bool _kmstest_connector_config(int drm_fd, uint32_t connector_id,
 	 * In both cases find the first compatible encoder and skip the CRTC
 	 * if there is non such.
 	 */
-	config->valid_crtc_idx_mask = 0;
-	for (i = 0; i < resources->count_crtcs; i++) {
-		if (!resources->crtcs[i])
-			continue;
+	_kmstest_connector_config_crtc_mask(drm_fd, connector, config);
 
-		/* Now get a compatible encoder */
-		for (j = 0; j < connector->count_encoders; j++) {
-			encoder = drmModeGetEncoder(drm_fd,
-						    connector->encoders[j]);
-
-			if (!encoder) {
-				igt_warn("could not get encoder %d: %s\n",
-					 resources->encoders[j],
-					 strerror(errno));
-
-				continue;
-			}
-
-			config->valid_crtc_idx_mask |= encoder->possible_crtcs;
-
-			if (!found && (crtc_idx_mask & encoder->possible_crtcs & (1 << i))) {
-				found = encoder;
-				pipe = i;
-			} else
-				drmModeFreeEncoder(encoder);
-		}
-	}
-
-	if (!found)
+	crtc_idx_mask &= config->valid_crtc_idx_mask;
+	if (!crtc_idx_mask)
 		goto err3;
 
+	config->pipe = ffs(crtc_idx_mask) - 1;
+
 	if (!kmstest_get_connector_default_mode(drm_fd, connector,
 						&config->default_mode))
-		goto err4;
+		goto err3;
 
+	config->encoder = _kmstest_connector_config_find_encoder(drm_fd, connector, config->pipe);
 	config->connector = connector;
-	config->encoder = found;
-	config->crtc = drmModeGetCrtc(drm_fd, resources->crtcs[pipe]);
-	config->pipe = pipe;
+	config->crtc = drmModeGetCrtc(drm_fd, resources->crtcs[config->pipe]);
 
 	drmModeFreeResources(resources);
 
 	return true;
-err4:
-	drmModeFreeEncoder(found);
 err3:
 	drmModeFreeConnector(connector);
 err2:
Signature · 6 lines
2.5.5

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

PATCH 3/10 kms_psr_sink_crc: Use for_each_pipe_with_valid_output to find a valid config.

In reply to Maarten Lankhorst

This is the only time PIPE_ANY was used to mean something other than unassign this output from a pipe. Without this PIPE_ANY can be aliased to PIPE_NONE.

---
 tests/kms_psr_sink_crc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tests/kms_psr_sink_crc.c +3 -2
index b18e426303e3..d7bce3bb7855 100644
@@ -103,15 +103,16 @@ static void setup_output(data_t *data)
 {
 	igt_display_t *display = &data->display;
 	igt_output_t *output;
+	enum pipe pipe;
 
-	for_each_connected_output(display, output) {
+	for_each_pipe_with_valid_output(display, pipe, output) {
 		drmModeConnectorPtr c = output->config.connector;
 
 		if (c->connector_type != DRM_MODE_CONNECTOR_eDP ||
 		    c->connection != DRM_MODE_CONNECTED)
 			continue;
 
-		igt_output_set_pipe(output, PIPE_ANY);
+		igt_output_set_pipe(output, pipe);
 		data->crtc_id = output->config.crtc->crtc_id;
 		data->output = output;
 		data->mode = igt_output_get_mode(output);
Signature · 6 lines
2.5.5

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw

PATCH 4/10 igt_kms: Make PIPE_ANY a alias for PIPE_NONE

In reply to Maarten Lankhorst
---
 lib/igt_kms.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/igt_kms.h +2 -1
index 4b15528c2858..47b78e1a6b1f 100644
@@ -40,7 +40,8 @@
 /* Low-level helpers with kmstest_ prefix */
 
 enum pipe {
-        PIPE_ANY = -1,
+        PIPE_NONE = -1,
+        PIPE_ANY = PIPE_NONE,
         PIPE_A = 0,
         PIPE_B,
         PIPE_C,
Signature · 6 lines
2.5.5

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

PATCH 5/10 igt_kms: Change PIPE_ANY behavior to mean unassigned

In reply to Maarten Lankhorst

None of the tests requires that a output bound to PIPE_ANY is assigned, so don't do it. Fix the display commit to iterate over crtc's instead of outputs to properly disable pipes without outputs.

This also means that output->valid is only set after connecting a output to a pipe, so no longer depend on it in for_each_connected_output and similar macros.

---
 lib/igt_kms.c | 246 ++++++++++++++++++++++++++++------------------------------
 lib/igt_kms.h |  18 ++++-
 2 files changed, 135 insertions(+), 129 deletions(-)
lib/igt_kms.c +119 -127
index 8b9c7c9234c6..c1a033992845 100644
@@ -864,18 +864,20 @@ static bool _kmstest_connector_config(int drm_fd, uint32_t connector_id,
 	 */
 	_kmstest_connector_config_crtc_mask(drm_fd, connector, config);
 
+	if (!kmstest_get_connector_default_mode(drm_fd, connector,
+						&config->default_mode))
+		goto err3;
+
+	config->connector = connector;
+
 	crtc_idx_mask &= config->valid_crtc_idx_mask;
 	if (!crtc_idx_mask)
-		goto err3;
+		/* Keep config->connector */
+		goto err2;
 
 	config->pipe = ffs(crtc_idx_mask) - 1;
 
-	if (!kmstest_get_connector_default_mode(drm_fd, connector,
-						&config->default_mode))
-		goto err3;
-
 	config->encoder = _kmstest_connector_config_find_encoder(drm_fd, connector, config->pipe);
-	config->connector = connector;
 	config->crtc = drmModeGetCrtc(drm_fd, resources->crtcs[config->pipe]);
 
 	drmModeFreeResources(resources);
@@ -935,8 +937,13 @@ bool kmstest_probe_connector_config(int drm_fd, uint32_t connector_id,
 void kmstest_free_connector_config(struct kmstest_connector_config *config)
 {
 	drmModeFreeCrtc(config->crtc);
+	config->crtc = NULL;
+
 	drmModeFreeEncoder(config->encoder);
+	config->encoder = NULL;
+
 	drmModeFreeConnector(config->connector);
+	config->connector = NULL;
 }
 
 /**
@@ -1192,8 +1199,7 @@ static void igt_output_refresh(igt_output_t *output)
 	/* we mask out the pipes already in use */
 	crtc_idx_mask = output->pending_crtc_idx_mask & ~display->pipes_in_use;
 
-	if (output->valid)
-		kmstest_free_connector_config(&output->config);
+	kmstest_free_connector_config(&output->config);
 
 	ret = kmstest_get_connector_config(display->drm_fd,
 					   output->id,
@@ -1204,19 +1210,19 @@ static void igt_output_refresh(igt_output_t *output)
 	else
 		output->valid = false;
 
-	if (!output->valid)
-		return;
-
-	if (output->use_override_mode)
-		output->config.default_mode = output->override_mode;
-
-	if (!output->name) {
+	if (!output->name && output->config.connector) {
 		drmModeConnector *c = output->config.connector;
 
 		igt_assert_neq(asprintf(&output->name, "%s-%d", kmstest_connector_type_str(c->connector_type), c->connector_type_id),
 			       -1);
 	}
 
+	if (!output->valid)
+		return;
+
+	if (output->use_override_mode)
+		output->config.default_mode = output->override_mode;
+
 	LOG(display, "%s: Selecting pipe %s\n", output->name,
 	    kmstest_pipe_name(output->config.pipe));
 
@@ -1254,10 +1260,10 @@ get_crtc_property(int drm_fd, uint32_t crtc_id, const char *name,
 }
 
 static void
-igt_crtc_set_property(igt_output_t *output, uint32_t prop_id, uint64_t value)
+igt_crtc_set_property(igt_pipe_t *pipe, uint32_t prop_id, uint64_t value)
 {
-	drmModeObjectSetProperty(output->display->drm_fd,
-		output->config.crtc->crtc_id, DRM_MODE_OBJECT_CRTC, prop_id, value);
+	drmModeObjectSetProperty(pipe->display->drm_fd,
+		pipe->crtc_id, DRM_MODE_OBJECT_CRTC, prop_id, value);
 }
 
 /*
@@ -1319,15 +1325,37 @@ void igt_display_init(igt_display_t *display, int drm_fd)
 		igt_plane_t *plane;
 		int p = IGT_PLANE_2;
 		int j, type;
+		uint64_t prop_value;
 
 		pipe->crtc_id = resources->crtcs[i];
 		pipe->display = display;
 		pipe->pipe = i;
 
+		get_crtc_property(display->drm_fd, pipe->crtc_id,
+				    "background_color",
+				    &pipe->background_property,
+				    &prop_value,
+				    NULL);
+		pipe->background = (uint32_t)prop_value;
+		get_crtc_property(display->drm_fd, pipe->crtc_id,
+				  "DEGAMMA_LUT",
+				  &pipe->degamma_property,
+				  NULL,
+				  NULL);
+		get_crtc_property(display->drm_fd, pipe->crtc_id,
+				  "CTM",
+				  &pipe->ctm_property,
+				  NULL,
+				  NULL);
+		get_crtc_property(display->drm_fd, pipe->crtc_id,
+				  "GAMMA_LUT",
+				  &pipe->gamma_property,
+				  NULL,
+				  NULL);
+
 		/* add the planes that can be used with that pipe */
 		for (j = 0; j < plane_resources->count_planes; j++) {
 			drmModePlane *drm_plane;
-			uint64_t prop_value;
 
 			drm_plane = drmModeGetPlane(display->drm_fd,
 						    plane_resources->planes[j]);
@@ -1433,47 +1461,17 @@ void igt_display_init(igt_display_t *display, int drm_fd)
 	igt_assert(display->outputs);
 
 	for (i = 0; i < display->n_outputs; i++) {
-		int j;
 		igt_output_t *output = &display->outputs[i];
 
 		/*
-		 * We're free to select any pipe to drive that output until
-		 * a constraint is set with igt_output_set_pipe().
+		 * We don't assign each output a pipe unless
+		 * a pipe is set with igt_output_set_pipe().
 		 */
-		output->pending_crtc_idx_mask = -1UL;
+		output->pending_crtc_idx_mask = 0;
 		output->id = resources->connectors[i];
 		output->display = display;
 
 		igt_output_refresh(output);
-
-		for (j = 0; j < display->n_pipes; j++) {
-			uint64_t prop_value;
-			igt_pipe_t *pipe = &display->pipes[j];
-
-			if (output->config.crtc) {
-				get_crtc_property(display->drm_fd, output->config.crtc->crtc_id,
-						   "background_color",
-						   &pipe->background_property,
-						   &prop_value,
-						   NULL);
-				pipe->background = (uint32_t)prop_value;
-				get_crtc_property(display->drm_fd, output->config.crtc->crtc_id,
-						  "DEGAMMA_LUT",
-						  &pipe->degamma_property,
-						  NULL,
-						  NULL);
-				get_crtc_property(display->drm_fd, output->config.crtc->crtc_id,
-						  "CTM",
-						  &pipe->ctm_property,
-						  NULL,
-						  NULL);
-				get_crtc_property(display->drm_fd, output->config.crtc->crtc_id,
-						  "GAMMA_LUT",
-						  &pipe->gamma_property,
-						  NULL,
-						  NULL);
-			}
-		}
 	}
 
 	drmModeFreePlaneResources(plane_resources);
@@ -1538,7 +1536,7 @@ static void igt_display_refresh(igt_display_t *display)
         for (i = 0; i < display->n_outputs; i++) {
                 igt_output_t *a = &display->outputs[i];
 
-                if (a->pending_crtc_idx_mask == -1UL)
+                if (!a->pending_crtc_idx_mask)
                         continue;
 
                 for (j = 0; j < display->n_outputs; j++) {
@@ -1547,9 +1545,6 @@ static void igt_display_refresh(igt_display_t *display)
                         if (i == j)
                                 continue;
 
-                        if (b->pending_crtc_idx_mask == -1UL)
-                                continue;
-
                         igt_assert_f(a->pending_crtc_idx_mask !=
                                      b->pending_crtc_idx_mask,
                                      "%s and %s are both trying to use pipe %s\n",
@@ -1558,25 +1553,9 @@ static void igt_display_refresh(igt_display_t *display)
                 }
         }
 
-	/*
-	 * The pipe allocation has to be done in two phases:
-	 *   - first, try to satisfy the outputs where a pipe has been specified
-	 *   - then, allocate the outputs with PIPE_ANY
-	 */
 	for (i = 0; i < display->n_outputs; i++) {
 		igt_output_t *output = &display->outputs[i];
 
-		if (output->pending_crtc_idx_mask == -1UL)
-			continue;
-
-		igt_output_refresh(output);
-	}
-	for (i = 0; i < display->n_outputs; i++) {
-		igt_output_t *output = &display->outputs[i];
-
-		if (output->pending_crtc_idx_mask != -1UL)
-			continue;
-
 		igt_output_refresh(output);
 	}
 }
@@ -1586,12 +1565,11 @@ static igt_pipe_t *igt_output_get_driving_pipe(igt_output_t *output)
 	igt_display_t *display = output->display;
 	enum pipe pipe;
 
-	if (output->pending_crtc_idx_mask == -1UL) {
+	if (!output->pending_crtc_idx_mask) {
 		/*
-		 * The user hasn't specified a pipe to use, take the one
-		 * configured by the last refresh()
+		 * The user hasn't specified a pipe to use, return none.
 		 */
-		pipe = output->config.pipe;
+		return NULL;
 	} else {
 		/*
 		 * Otherwise, return the pending pipe (ie the pipe that should
@@ -1621,6 +1599,21 @@ static igt_plane_t *igt_pipe_get_plane(igt_pipe_t *pipe, enum igt_plane plane)
 	return &pipe->planes[idx];
 }
 
+static igt_output_t *igt_pipe_get_output(igt_pipe_t *pipe)
+{
+	igt_display_t *display = pipe->display;
+	int i;
+
+	for (i = 0; i < display->n_outputs; i++) {
+		igt_output_t *output = &display->outputs[i];
+
+		if (output->pending_crtc_idx_mask == (1 << pipe->pipe))
+			return output;
+	}
+
+	return NULL;
+}
+
 bool igt_pipe_get_property(igt_pipe_t *pipe, const char *name,
 			   uint32_t *prop_id, uint64_t *value,
 			   drmModePropertyPtr *prop)
@@ -1734,10 +1727,10 @@ igt_atomic_prepare_plane_commit(igt_plane_t *plane, igt_output_t *output,
  * tests that expect a specific error code).
  */
 static int igt_drm_plane_commit(igt_plane_t *plane,
-				igt_output_t *output,
+				igt_pipe_t *pipe,
 				bool fail_on_error)
 {
-	igt_display_t *display = output->display;
+	igt_display_t *display = pipe->display;
 	uint32_t fb_id, crtc_id;
 	int ret;
 	uint32_t src_x;
@@ -1756,13 +1749,12 @@ static int igt_drm_plane_commit(igt_plane_t *plane,
 		   !plane->rotation_changed);
 
 	fb_id = igt_plane_get_fb_id(plane);
-	crtc_id = output->config.crtc->crtc_id;
+	crtc_id = pipe->crtc_id;
 
 	if ((plane->fb_changed || plane->size_changed) && fb_id == 0) {
 		LOG(display,
-		    "%s: SetPlane pipe %s, plane %d, disabling\n",
-		    igt_output_name(output),
-		    kmstest_pipe_name(output->config.pipe),
+		    "SetPlane pipe %s, plane %d, disabling\n",
+		    kmstest_pipe_name(pipe->pipe),
 		    plane->index);
 
 		ret = drmModeSetPlane(display->drm_fd,
@@ -1790,10 +1782,9 @@ static int igt_drm_plane_commit(igt_plane_t *plane,
 		crtc_h = plane->crtc_h;
 
 		LOG(display,
-		    "%s: SetPlane %s.%d, fb %u, src = (%d, %d) "
+		    "SetPlane %s.%d, fb %u, src = (%d, %d) "
 			"%ux%u dst = (%u, %u) %ux%u\n",
-		    igt_output_name(output),
-		    kmstest_pipe_name(output->config.pipe),
+		    kmstest_pipe_name(pipe->pipe),
 		    plane->index,
 		    fb_id,
 		    src_x >> 16, src_y >> 16, src_w >> 16, src_h >> 16,
@@ -1834,11 +1825,11 @@ static int igt_drm_plane_commit(igt_plane_t *plane,
  * code).
  */
 static int igt_cursor_commit_legacy(igt_plane_t *cursor,
-				    igt_output_t *output,
+				    igt_pipe_t *pipe,
 				    bool fail_on_error)
 {
-	igt_display_t *display = output->display;
-	uint32_t crtc_id = output->config.crtc->crtc_id;
+	igt_display_t *display = pipe->display;
+	uint32_t crtc_id = pipe->crtc_id;
 	int ret;
 
 	if (cursor->fb_changed) {
@@ -1846,9 +1837,8 @@ static int igt_cursor_commit_legacy(igt_plane_t *cursor,
 
 		if (gem_handle) {
 			LOG(display,
-			    "%s: SetCursor pipe %s, fb %u %dx%d\n",
-			    igt_output_name(output),
-			    kmstest_pipe_name(output->config.pipe),
+			    "SetCursor pipe %s, fb %u %dx%d\n",
+			    kmstest_pipe_name(pipe->pipe),
 			    gem_handle,
 			    cursor->crtc_w, cursor->crtc_h);
 
@@ -1858,9 +1848,8 @@ static int igt_cursor_commit_legacy(igt_plane_t *cursor,
 					       cursor->crtc_h);
 		} else {
 			LOG(display,
-			    "%s: SetCursor pipe %s, disabling\n",
-			    igt_output_name(output),
-			    kmstest_pipe_name(output->config.pipe));
+			    "SetCursor pipe %s, disabling\n",
+			    kmstest_pipe_name(pipe->pipe));
 
 			ret = drmModeSetCursor(display->drm_fd, crtc_id,
 					       0, 0, 0);
@@ -1876,9 +1865,8 @@ static int igt_cursor_commit_legacy(igt_plane_t *cursor,
 		int y = cursor->crtc_y;
 
 		LOG(display,
-		    "%s: MoveCursor pipe %s, (%d, %d)\n",
-		    igt_output_name(output),
-		    kmstest_pipe_name(output->config.pipe),
+		    "MoveCursor pipe %s, (%d, %d)\n",
+		    kmstest_pipe_name(pipe->pipe),
 		    x, y);
 
 		ret = drmModeMoveCursor(display->drm_fd, crtc_id, x, y);
@@ -1895,10 +1883,11 @@ static int igt_cursor_commit_legacy(igt_plane_t *cursor,
  * (setmode).
  */
 static int igt_primary_plane_commit_legacy(igt_plane_t *primary,
-					   igt_output_t *output,
+					   igt_pipe_t *pipe,
 					   bool fail_on_error)
 {
 	struct igt_display *display = primary->pipe->display;
+	igt_output_t *output = igt_pipe_get_output(pipe);
 	drmModeModeInfo *mode;
 	uint32_t fb_id, crtc_id;
 	int ret;
@@ -1913,7 +1902,7 @@ static int igt_primary_plane_commit_legacy(igt_plane_t *primary,
 		!primary->size_changed && !primary->panning_changed)
 		return 0;
 
-	crtc_id = output->config.crtc->crtc_id;
+	crtc_id = pipe->crtc_id;
 	fb_id = igt_plane_get_fb_id(primary);
 	if (fb_id)
 		mode = igt_output_get_mode(output);
@@ -1925,7 +1914,7 @@ static int igt_primary_plane_commit_legacy(igt_plane_t *primary,
 		    "%s: SetCrtc pipe %s, fb %u, panning (%d, %d), "
 		    "mode %dx%d\n",
 		    igt_output_name(output),
-		    kmstest_pipe_name(output->config.pipe),
+		    kmstest_pipe_name(pipe->pipe),
 		    fb_id,
 		    primary->pan_x, primary->pan_y,
 		    mode->hdisplay, mode->vdisplay);
@@ -1939,9 +1928,8 @@ static int igt_primary_plane_commit_legacy(igt_plane_t *primary,
 				     mode);
 	} else {
 		LOG(display,
-		    "%s: SetCrtc pipe %s, disabling\n",
-		    igt_output_name(output),
-		    kmstest_pipe_name(output->config.pipe));
+		    "SetCrtc pipe %s, disabling\n",
+		    kmstest_pipe_name(pipe->pipe));
 
 		ret = drmModeSetCrtc(display->drm_fd,
 				     crtc_id,
@@ -1969,17 +1957,17 @@ static int igt_primary_plane_commit_legacy(igt_plane_t *primary,
  * which API is used to do the programming.
  */
 static int igt_plane_commit(igt_plane_t *plane,
-			    igt_output_t *output,
+			    igt_pipe_t *pipe,
 			    enum igt_commit_style s,
 			    bool fail_on_error)
 {
 	if (plane->is_cursor && s == COMMIT_LEGACY) {
-		return igt_cursor_commit_legacy(plane, output, fail_on_error);
+		return igt_cursor_commit_legacy(plane, pipe, fail_on_error);
 	} else if (plane->is_primary && s == COMMIT_LEGACY) {
-		return igt_primary_plane_commit_legacy(plane, output,
+		return igt_primary_plane_commit_legacy(plane, pipe,
 						       fail_on_error);
 	} else {
-			return igt_drm_plane_commit(plane, output, fail_on_error);
+			return igt_drm_plane_commit(plane, pipe, fail_on_error);
 	}
 }
 
@@ -1993,31 +1981,28 @@ static int igt_plane_commit(igt_plane_t *plane,
  * further programming will take place, which may result in some changes
  * taking effect and others not taking effect.
  */
-static int igt_output_commit(igt_output_t *output,
-			     enum igt_commit_style s,
-			     bool fail_on_error)
+static int igt_pipe_commit(igt_pipe_t *pipe,
+			   enum igt_commit_style s,
+			   bool fail_on_error)
 {
-	igt_display_t *display = output->display;
-	igt_pipe_t *pipe;
+	igt_display_t *display = pipe->display;
 	int i;
 	int ret;
 	bool need_wait_for_vblank = false;
 
-	pipe = igt_output_get_driving_pipe(output);
-
 	if (pipe->background_changed) {
-		igt_crtc_set_property(output, pipe->background_property,
+		igt_crtc_set_property(pipe, pipe->background_property,
 			pipe->background);
 
 		pipe->background_changed = false;
 	}
 
 	if (pipe->color_mgmt_changed) {
-		igt_crtc_set_property(output, pipe->degamma_property,
+		igt_crtc_set_property(pipe, pipe->degamma_property,
 				      pipe->degamma_blob);
-		igt_crtc_set_property(output, pipe->ctm_property,
+		igt_crtc_set_property(pipe, pipe->ctm_property,
 				      pipe->ctm_blob);
-		igt_crtc_set_property(output, pipe->gamma_property,
+		igt_crtc_set_property(pipe, pipe->gamma_property,
 				      pipe->gamma_blob);
 
 		pipe->color_mgmt_changed = false;
@@ -2029,7 +2014,7 @@ static int igt_output_commit(igt_output_t *output,
 		if (plane->fb_changed || plane->position_changed || plane->size_changed)
 			need_wait_for_vblank = true;
 
-		ret = igt_plane_commit(plane, output, s, fail_on_error);
+		ret = igt_plane_commit(plane, pipe, s, fail_on_error);
 		CHECK_RETURN(ret, fail_on_error);
 	}
 
@@ -2053,6 +2038,9 @@ static void igt_atomic_prepare_crtc_commit(igt_output_t *output, drmModeAtomicRe
 
 	igt_pipe_t *pipe_obj = igt_output_get_driving_pipe(output);
 
+	if (!pipe_obj)
+		return;
+
 	if (pipe_obj->background_changed)
 		igt_atomic_populate_crtc_req(req, output, IGT_CRTC_BACKGROUND, pipe_obj->background);
 
@@ -2118,6 +2106,8 @@ static int igt_atomic_commit(igt_display_t *display)
 
 
 		pipe_obj = igt_output_get_driving_pipe(output);
+		if (!pipe_obj)
+			continue;
 
 		pipe = pipe_obj->pipe;
 
@@ -2160,14 +2150,14 @@ static int do_display_commit(igt_display_t *display,
 
 	}
 
-	for (i = 0; i < display->n_outputs; i++) {
-		igt_output_t *output = &display->outputs[i];
+	for_each_pipe(display, i) {
+		igt_pipe_t *pipe_obj = &display->pipes[i];
+		igt_output_t *output = igt_pipe_get_output(pipe_obj);
 
-		if (!output->valid)
-			continue;
+		if (output && output->valid)
+			valid_outs++;
 
-		valid_outs++;
-		ret = igt_output_commit(output, s, fail_on_error);
+		ret = igt_pipe_commit(pipe_obj, s, fail_on_error);
 		CHECK_RETURN(ret, fail_on_error);
 	}
 
@@ -2275,9 +2265,9 @@ void igt_output_set_pipe(igt_output_t *output, enum pipe pipe)
 {
 	igt_display_t *display = output->display;
 
-	if (pipe == PIPE_ANY) {
+	if (pipe == PIPE_NONE) {
 		LOG(display, "%s: set_pipe(any)\n", igt_output_name(output));
-		output->pending_crtc_idx_mask = -1UL;
+		output->pending_crtc_idx_mask = 0;
 	} else {
 		LOG(display, "%s: set_pipe(%s)\n", igt_output_name(output),
 		    kmstest_pipe_name(pipe));
@@ -2290,6 +2280,8 @@ igt_plane_t *igt_output_get_plane(igt_output_t *output, enum igt_plane plane)
 	igt_pipe_t *pipe;
 
 	pipe = igt_output_get_driving_pipe(output);
+	igt_assert(pipe);
+
 	return igt_pipe_get_plane(pipe, plane);
 }
 
lib/igt_kms.h +16 -2
index 47b78e1a6b1f..a3505a1a6b25 100644
@@ -328,17 +328,31 @@ void igt_fb_set_size(struct igt_fb *fb, igt_plane_t *plane,
 
 void igt_wait_for_vblank(int drm_fd, enum pipe pipe);
 
+static inline bool igt_output_is_connected(igt_output_t *output)
+{
+	/* Something went wrong during probe? */
+	if (!output->config.connector)
+		return false;
+
+	if (output->config.connector->connection == DRM_MODE_CONNECTED)
+		return true;
+
+	return false;
+}
+
 static inline bool igt_pipe_connector_valid(enum pipe pipe,
 					    igt_output_t *output)
 {
-	return output->valid && (output->config.valid_crtc_idx_mask & (1 << pipe));
+	return igt_output_is_connected(output) &&
+	       (output->config.valid_crtc_idx_mask & (1 << pipe));
 }
 
 #define for_each_if(condition) if (!(condition)) {} else
 
 #define for_each_connected_output(display, output)		\
 	for (int i__ = 0;  i__ < (display)->n_outputs; i__++)	\
-		for_each_if (((output = &(display)->outputs[i__]), output->valid))
+		for_each_if (((output = &(display)->outputs[i__]), \
+			      igt_output_is_connected(output)))
 
 #define for_each_pipe(display, pipe)					\
 	for (pipe = 0; pipe < igt_display_get_n_pipes(display); pipe++)	\
Signature · 6 lines
2.5.5

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw

PATCH 6/10 igt_kms: Handle atomic pipe properties better.

In reply to Maarten Lankhorst

Move properties to the pipe, they don't belong in the output and make atomic commit use the pipes for crtc properties.

---
 lib/igt_kms.c | 98 +++++++++++++++++++++++++++++------------------------------
 lib/igt_kms.h | 12 +++++---
 2 files changed, 55 insertions(+), 55 deletions(-)
lib/igt_kms.c +48 -50
index c1a033992845..eefdc74af1a6 100644
@@ -213,8 +213,7 @@ igt_atomic_fill_plane_props(igt_display_t *display, igt_plane_t *plane,
  * config->atomic_props_crtc and config->atomic_props_connector.
  */
 static void
-igt_atomic_fill_props(igt_display_t *display, igt_output_t *output,
-			int num_crtc_props, const char **crtc_prop_names,
+igt_atomic_fill_connector_props(igt_display_t *display, igt_output_t *output,
 			int num_connector_props, const char **conn_prop_names)
 {
 	drmModeObjectPropertiesPtr props;
@@ -222,18 +221,18 @@ igt_atomic_fill_props(igt_display_t *display, igt_output_t *output,
 
 	fd = display->drm_fd;
 
-	props = drmModeObjectGetProperties(fd, output->config.crtc->crtc_id, DRM_MODE_OBJECT_CRTC);
+	props = drmModeObjectGetProperties(fd, output->config.connector->connector_id, DRM_MODE_OBJECT_CONNECTOR);
 	igt_assert(props);
 
 	for (i = 0; i < props->count_props; i++) {
 		drmModePropertyPtr prop =
 			drmModeGetProperty(fd, props->props[i]);
 
-		for (j = 0; j < num_crtc_props; j++) {
-			if (strcmp(prop->name, crtc_prop_names[j]) != 0)
+		for (j = 0; j < num_connector_props; j++) {
+			if (strcmp(prop->name, conn_prop_names[j]) != 0)
 				continue;
 
-			output->config.atomic_props_crtc[j] = props->props[i];
+			output->config.atomic_props_connector[j] = props->props[i];
 			break;
 		}
 
@@ -241,19 +240,29 @@ igt_atomic_fill_props(igt_display_t *display, igt_output_t *output,
 	}
 
 	drmModeFreeObjectProperties(props);
-	props = NULL;
-	props = drmModeObjectGetProperties(fd, output->config.connector->connector_id, DRM_MODE_OBJECT_CONNECTOR);
+}
+
+static void
+igt_atomic_fill_pipe_props(igt_display_t *display, igt_pipe_t *pipe,
+			int num_crtc_props, const char **crtc_prop_names)
+{
+	drmModeObjectPropertiesPtr props;
+	int i, j, fd;
+
+	fd = display->drm_fd;
+
+	props = drmModeObjectGetProperties(fd, pipe->crtc_id, DRM_MODE_OBJECT_CRTC);
 	igt_assert(props);
 
 	for (i = 0; i < props->count_props; i++) {
 		drmModePropertyPtr prop =
 			drmModeGetProperty(fd, props->props[i]);
 
-		for (j = 0; j < num_connector_props; j++) {
-			if (strcmp(prop->name, conn_prop_names[j]) != 0)
+		for (j = 0; j < num_crtc_props; j++) {
+			if (strcmp(prop->name, crtc_prop_names[j]) != 0)
 				continue;
 
-			output->config.atomic_props_connector[j] = props->props[i];
+			pipe->atomic_props_crtc[j] = props->props[i];
 			break;
 		}
 
@@ -261,7 +270,6 @@ igt_atomic_fill_props(igt_display_t *display, igt_output_t *output,
 	}
 
 	drmModeFreeObjectProperties(props);
-
 }
 
 const unsigned char* igt_kms_get_alt_edid(void)
@@ -1217,6 +1225,9 @@ static void igt_output_refresh(igt_output_t *output)
 			       -1);
 	}
 
+	igt_atomic_fill_connector_props(display, output,
+		IGT_NUM_CONNECTOR_PROPS, igt_connector_prop_names);
+
 	if (!output->valid)
 		return;
 
@@ -1227,8 +1238,6 @@ static void igt_output_refresh(igt_output_t *output)
 	    kmstest_pipe_name(output->config.pipe));
 
 	display->pipes_in_use |= 1 << output->config.pipe;
-	igt_atomic_fill_props(display, output, IGT_NUM_CRTC_PROPS, igt_crtc_prop_names,
-		IGT_NUM_CONNECTOR_PROPS, igt_connector_prop_names);
 }
 
 static bool
@@ -1353,6 +1362,8 @@ void igt_display_init(igt_display_t *display, int drm_fd)
 				  NULL,
 				  NULL);
 
+		igt_atomic_fill_pipe_props(display, pipe, IGT_NUM_CRTC_PROPS, igt_crtc_prop_names);
+
 		/* add the planes that can be used with that pipe */
 		for (j = 0; j < plane_resources->count_planes; j++) {
 			drmModePlane *drm_plane;
@@ -1653,11 +1664,10 @@ static uint32_t igt_plane_get_fb_gem_handle(igt_plane_t *plane)
  * Add position and fb changes of a plane to the atomic property set
  */
 static void
-igt_atomic_prepare_plane_commit(igt_plane_t *plane, igt_output_t *output,
+igt_atomic_prepare_plane_commit(igt_plane_t *plane, igt_pipe_t *pipe,
 	drmModeAtomicReq *req)
 {
-
-	igt_display_t *display = output->display;
+	igt_display_t *display = pipe->display;
 	uint32_t fb_id, crtc_id;
 
 	igt_assert(plane->drm_plane);
@@ -1667,12 +1677,11 @@ igt_atomic_prepare_plane_commit(igt_plane_t *plane, igt_output_t *output,
 			!plane->rotation_changed);
 
 	fb_id = igt_plane_get_fb_id(plane);
-	crtc_id = output->config.crtc->crtc_id;
+	crtc_id = pipe->crtc_id;
 
 	LOG(display,
-	    "%s: populating plane data: %s.%d, fb %u\n",
-	    igt_output_name(output),
-	    kmstest_pipe_name(output->config.pipe),
+	    "populating plane data: %s.%d, fb %u\n",
+	    kmstest_pipe_name(pipe->pipe),
 	    plane->index,
 	    fb_id);
 
@@ -2033,21 +2042,15 @@ static int igt_pipe_commit(igt_pipe_t *pipe,
 /*
  * Add crtc property changes to the atomic property set
  */
-static void igt_atomic_prepare_crtc_commit(igt_output_t *output, drmModeAtomicReq *req)
+static void igt_atomic_prepare_crtc_commit(igt_pipe_t *pipe_obj, drmModeAtomicReq *req)
 {
-
-	igt_pipe_t *pipe_obj = igt_output_get_driving_pipe(output);
-
-	if (!pipe_obj)
-		return;
-
 	if (pipe_obj->background_changed)
-		igt_atomic_populate_crtc_req(req, output, IGT_CRTC_BACKGROUND, pipe_obj->background);
+		igt_atomic_populate_crtc_req(req, pipe_obj, IGT_CRTC_BACKGROUND, pipe_obj->background);
 
 	if (pipe_obj->color_mgmt_changed) {
-		igt_atomic_populate_crtc_req(req, output, IGT_CRTC_DEGAMMA_LUT, pipe_obj->degamma_blob);
-		igt_atomic_populate_crtc_req(req, output, IGT_CRTC_CTM, pipe_obj->ctm_blob);
-		igt_atomic_populate_crtc_req(req, output, IGT_CRTC_GAMMA_LUT, pipe_obj->gamma_blob);
+		igt_atomic_populate_crtc_req(req, pipe_obj, IGT_CRTC_DEGAMMA_LUT, pipe_obj->degamma_blob);
+		igt_atomic_populate_crtc_req(req, pipe_obj, IGT_CRTC_CTM, pipe_obj->ctm_blob);
+		igt_atomic_populate_crtc_req(req, pipe_obj, IGT_CRTC_GAMMA_LUT, pipe_obj->gamma_blob);
 	}
 
 	/*
@@ -2081,42 +2084,37 @@ static void igt_atomic_prepare_connector_commit(igt_output_t *output, drmModeAto
 static int igt_atomic_commit(igt_display_t *display)
 {
 
-	int ret = 0;
+	int ret = 0, i;
+	enum pipe pipe;
 	drmModeAtomicReq *req;
 	igt_output_t *output;
+
 	if (display->is_atomic != 1)
 		return -1;
 	req = drmModeAtomicAlloc();
 	drmModeAtomicSetCursor(req, 0);
 
-	for_each_connected_output(display, output) {
-		igt_pipe_t *pipe_obj;
+	for_each_pipe(display, pipe) {
+		igt_pipe_t *pipe_obj = &display->pipes[pipe];
 		igt_plane_t *plane;
-		enum pipe pipe;
 
 		/*
 		 * Add CRTC Properties to the property set
 		 */
-		igt_atomic_prepare_crtc_commit(output, req);
-
-		/*
-		 * Add Connector Properties to the property set
-		 */
-		igt_atomic_prepare_connector_commit(output, req);
-
-
-		pipe_obj = igt_output_get_driving_pipe(output);
-		if (!pipe_obj)
-			continue;
-
-		pipe = pipe_obj->pipe;
+		igt_atomic_prepare_crtc_commit(pipe_obj, req);
 
 		for_each_plane_on_pipe(display, pipe, plane) {
-			igt_atomic_prepare_plane_commit(plane, output, req);
+			igt_atomic_prepare_plane_commit(plane, pipe_obj, req);
 		}
 
 	}
 
+	for (i = 0; i < display->n_outputs; i++) {
+		output = &display->outputs[i];
+
+		igt_atomic_prepare_connector_commit(output, req);
+	}
+
 	ret = drmModeAtomicCommit(display->drm_fd, req, 0, NULL);
 	drmModeAtomicFree(req);
 	return ret;
lib/igt_kms.h +7 -5
index a3505a1a6b25..718af11fa333 100644
@@ -111,7 +111,6 @@ struct kmstest_connector_config {
 	bool connector_scaling_mode_changed;
 	uint64_t connector_dpms;
 	bool connector_dpms_changed;
-	uint32_t atomic_props_crtc[IGT_NUM_CRTC_PROPS];
 	uint32_t atomic_props_connector[IGT_NUM_CONNECTOR_PROPS];
 	int pipe;
 	unsigned valid_crtc_idx_mask;
@@ -251,6 +250,9 @@ struct igt_pipe {
 	bool enabled;
 	int n_planes;
 	igt_plane_t planes[IGT_MAX_PLANES];
+
+	uint32_t atomic_props_crtc[IGT_NUM_CRTC_PROPS];
+
 	uint64_t background; /* Background color MSB BGR 16bpc LSB */
 	uint32_t background_changed : 1;
 	uint32_t background_property;
@@ -389,13 +391,13 @@ static inline bool igt_pipe_connector_valid(enum pipe pipe,
 /**
  * igt_atomic_populate_crtc_req:
  * @req: A pointer to drmModeAtomicReq
- * @output: A pointer igt_output_t
+ * @pipe: A pointer igt_pipe_t
  * @prop: one of igt_atomic_crtc_properties
  * @value: the value to add
  */
-#define igt_atomic_populate_crtc_req(req, output, prop, value) \
-	igt_assert_lt(0, drmModeAtomicAddProperty(req, output->config.crtc->crtc_id,\
-						  output->config.atomic_props_crtc[prop], value))
+#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
Signature · 6 lines
2.5.5

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw

PATCH 7/10 igt_kms: Remove pan members from igt_plane

In reply to Maarten Lankhorst

They're duplicates with src_x/y, so just use those.

---
 lib/igt_kms.c             | 24 ++++--------------------
 lib/igt_kms.h             |  4 ----
 tests/kms_panel_fitting.c |  2 +-
 tests/kms_plane.c         |  8 +++-----
 tests/kms_plane_scaling.c |  2 +-
 5 files changed, 9 insertions(+), 31 deletions(-)
lib/igt_kms.c +4 -20
index eefdc74af1a6..64abd341e8e5 100644
@@ -1908,7 +1908,7 @@ static int igt_primary_plane_commit_legacy(igt_plane_t *primary,
 	igt_assert(!primary->rotation_changed);
 
 	if (!primary->fb_changed && !primary->position_changed &&
-		!primary->size_changed && !primary->panning_changed)
+		!primary->size_changed)
 		return 0;
 
 	crtc_id = pipe->crtc_id;
@@ -1920,18 +1920,18 @@ static int igt_primary_plane_commit_legacy(igt_plane_t *primary,
 
 	if (fb_id) {
 		LOG(display,
-		    "%s: SetCrtc pipe %s, fb %u, panning (%d, %d), "
+		    "%s: SetCrtc pipe %s, fb %u, src (%d, %d), "
 		    "mode %dx%d\n",
 		    igt_output_name(output),
 		    kmstest_pipe_name(pipe->pipe),
 		    fb_id,
-		    primary->pan_x, primary->pan_y,
+		    primary->src_x, primary->src_x,
 		    mode->hdisplay, mode->vdisplay);
 
 		ret = drmModeSetCrtc(display->drm_fd,
 				     crtc_id,
 				     fb_id,
-				     primary->pan_x, primary->pan_y,
+				     primary->src_x, primary->src_x,
 				     &output->id,
 				     1,
 				     mode);
@@ -1955,7 +1955,6 @@ static int igt_primary_plane_commit_legacy(igt_plane_t *primary,
 	primary->fb_changed = false;
 	primary->position_changed = false;
 	primary->size_changed = false;
-	primary->panning_changed = false;
 
 	return 0;
 }
@@ -2401,21 +2400,6 @@ void igt_fb_set_size(struct igt_fb *fb, igt_plane_t *plane,
 	plane->fb_changed = true;
 }
 
-void igt_plane_set_panning(igt_plane_t *plane, int x, int y)
-{
-	igt_pipe_t *pipe = plane->pipe;
-	igt_display_t *display = pipe->display;
-
-	LOG(display, "%s.%d: plane_set_panning(%d,%d)\n",
-	    kmstest_pipe_name(pipe->pipe),
-	    plane->index, x, y);
-
-	plane->pan_x = x;
-	plane->pan_y = y;
-
-	plane->panning_changed = true;
-}
-
 static const char *rotation_name(igt_rotation_t rotation)
 {
 	switch (rotation) {
lib/igt_kms.h +0 -4
index 718af11fa333..2c88c1be61e4 100644
@@ -214,7 +214,6 @@ typedef struct {
 	/* state tracking */
 	unsigned int fb_changed       : 1;
 	unsigned int position_changed : 1;
-	unsigned int panning_changed  : 1;
 	unsigned int rotation_changed : 1;
 	unsigned int size_changed     : 1;
 	/*
@@ -238,8 +237,6 @@ typedef struct {
 	uint32_t src_w;
 	uint32_t src_h;
 
-	/* panning offset within the fb */
-	unsigned int pan_x, pan_y;
 	igt_rotation_t rotation;
 	uint32_t atomic_props_plane[IGT_NUM_PLANE_PROPS];
 } igt_plane_t;
@@ -320,7 +317,6 @@ 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_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_panning(igt_plane_t *plane, int x, int y);
 void igt_plane_set_rotation(igt_plane_t *plane, igt_rotation_t rotation);
 void igt_crtc_set_background(igt_pipe_t *pipe, uint64_t background);
 void igt_fb_set_position(struct igt_fb *fb, igt_plane_t *plane,
tests/kms_panel_fitting.c +1 -1
index b796c6812679..f858cef6a947 100644
@@ -89,7 +89,7 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
 		ret = drmModeSetCrtc(data->drm_fd,
 				output->config.crtc->crtc_id,
 				data->fb_id1,
-				plane->pan_x, plane->pan_y,
+				plane->src_x, plane->src_y,
 				&output->id,
 				1,
 				mode);
tests/kms_plane.c +3 -5
index 60b8d71d52d4..56c9d8d8c0ea 100644
@@ -321,11 +321,9 @@ test_plane_panning_with_output(data_t *data,
 	igt_plane_set_fb(primary, &primary_fb);
 
 	if (flags & TEST_PANNING_TOP_LEFT)
-		igt_plane_set_panning(primary, 0, 0);
+		igt_fb_set_position(primary, &primary_fb, 0, 0);
 	else
-		igt_plane_set_panning(primary, mode->hdisplay, mode->vdisplay);
-
-	igt_plane_set_position(primary, 0, 0);
+		igt_fb_set_position(primary, &primary_fb, mode->hdisplay, mode->vdisplay);
 
 	igt_display_commit(&data->display);
 
@@ -343,7 +341,7 @@ test_plane_panning_with_output(data_t *data,
 
 	/* reset states to neutral values, assumed by other tests */
 	igt_output_set_pipe(output, PIPE_ANY);
-	igt_plane_set_panning(primary, 0, 0);
+	igt_fb_set_position(&primary_fb, primary, 0, 0);
 
 	test_fini(data);
 }
tests/kms_plane_scaling.c +1 -1
index ad5404d90bfa..855670857c18 100644
@@ -98,7 +98,7 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
 		ret = drmModeSetCrtc(data->drm_fd,
 				output->config.crtc->crtc_id,
 				data->fb_id1,
-				plane->pan_x, plane->pan_y,
+				plane->src_x, plane->src_y,
 				&output->id,
 				1,
 				mode);
Signature · 6 lines
2.5.5

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#8 lore raw

PATCH 8/10 igt_kms: Clear all _changed members centrally

In reply to Maarten Lankhorst

This will make it easier to support TEST_ONLY commits.

---
 lib/igt_kms.c | 84 ++++++++++++++++++++++++++++++++++-------------------------
 1 file changed, 48 insertions(+), 36 deletions(-)
lib/igt_kms.c +48 -36
index 64abd341e8e5..cae99618b93b 100644
@@ -1720,11 +1720,6 @@ igt_atomic_prepare_plane_commit(igt_plane_t *plane, igt_pipe_t *pipe,
 	if (plane->rotation_changed)
 		igt_atomic_populate_plane_req(req, plane,
 			IGT_PLANE_ROTATION, plane->rotation);
-
-	plane->fb_changed = false;
-	plane->position_changed = false;
-	plane->size_changed = false;
-	plane->rotation_changed = false;
 }
 
 
@@ -1812,15 +1807,10 @@ static int igt_drm_plane_commit(igt_plane_t *plane,
 		CHECK_RETURN(ret, fail_on_error);
 	}
 
-	plane->fb_changed = false;
-	plane->position_changed = false;
-	plane->size_changed = false;
-
 	if (plane->rotation_changed) {
 		ret = igt_plane_set_property(plane, plane->rotation_property,
 				       plane->rotation);
 
-		plane->rotation_changed = false;
 		CHECK_RETURN(ret, fail_on_error);
 	}
 
@@ -1865,8 +1855,6 @@ static int igt_cursor_commit_legacy(igt_plane_t *cursor,
 		}
 
 		CHECK_RETURN(ret, fail_on_error);
-
-		cursor->fb_changed = false;
 	}
 
 	if (cursor->position_changed) {
@@ -1880,8 +1868,6 @@ static int igt_cursor_commit_legacy(igt_plane_t *cursor,
 
 		ret = drmModeMoveCursor(display->drm_fd, crtc_id, x, y);
 		CHECK_RETURN(ret, fail_on_error);
-
-		cursor->position_changed = false;
 	}
 
 	return 0;
@@ -1908,7 +1894,7 @@ static int igt_primary_plane_commit_legacy(igt_plane_t *primary,
 	igt_assert(!primary->rotation_changed);
 
 	if (!primary->fb_changed && !primary->position_changed &&
-		!primary->size_changed)
+	    !primary->size_changed)
 		return 0;
 
 	crtc_id = pipe->crtc_id;
@@ -1952,9 +1938,6 @@ static int igt_primary_plane_commit_legacy(igt_plane_t *primary,
 	CHECK_RETURN(ret, fail_on_error);
 
 	primary->pipe->enabled = (fb_id != 0);
-	primary->fb_changed = false;
-	primary->position_changed = false;
-	primary->size_changed = false;
 
 	return 0;
 }
@@ -1975,7 +1958,7 @@ static int igt_plane_commit(igt_plane_t *plane,
 		return igt_primary_plane_commit_legacy(plane, pipe,
 						       fail_on_error);
 	} else {
-			return igt_drm_plane_commit(plane, pipe, fail_on_error);
+		return igt_drm_plane_commit(plane, pipe, fail_on_error);
 	}
 }
 
@@ -2001,8 +1984,6 @@ static int igt_pipe_commit(igt_pipe_t *pipe,
 	if (pipe->background_changed) {
 		igt_crtc_set_property(pipe, pipe->background_property,
 			pipe->background);
-
-		pipe->background_changed = false;
 	}
 
 	if (pipe->color_mgmt_changed) {
@@ -2012,8 +1993,6 @@ static int igt_pipe_commit(igt_pipe_t *pipe,
 				      pipe->ctm_blob);
 		igt_crtc_set_property(pipe, pipe->gamma_property,
 				      pipe->gamma_blob);
-
-		pipe->color_mgmt_changed = false;
 	}
 
 	for (i = 0; i < pipe->n_planes; i++) {
@@ -2133,35 +2112,68 @@ static int do_display_commit(igt_display_t *display,
 			     bool fail_on_error)
 {
 	int i, ret;
-	int valid_outs = 0;
-
+	enum pipe pipe;
 	LOG_INDENT(display, "commit");
 
 	igt_display_refresh(display);
 
 	if (s == COMMIT_ATOMIC) {
-
 		ret = igt_atomic_commit(display);
+
 		CHECK_RETURN(ret, fail_on_error);
-		return 0;
+	} else {
+		int valid_outs = 0;
 
-	}
+		for_each_pipe(display, pipe) {
+			igt_pipe_t *pipe_obj = &display->pipes[pipe];
+			igt_output_t *output = igt_pipe_get_output(pipe_obj);
 
-	for_each_pipe(display, i) {
-		igt_pipe_t *pipe_obj = &display->pipes[i];
-		igt_output_t *output = igt_pipe_get_output(pipe_obj);
+			if (output && output->valid)
+				valid_outs++;
 
-		if (output && output->valid)
-			valid_outs++;
+			ret = igt_pipe_commit(pipe_obj, s, fail_on_error);
+			CHECK_RETURN(ret, fail_on_error);
+		}
 
-		ret = igt_pipe_commit(pipe_obj, s, fail_on_error);
 		CHECK_RETURN(ret, fail_on_error);
+
+		if (valid_outs == 0) {
+			LOG_UNINDENT(display);
+
+			return -1;
+		}
 	}
 
 	LOG_UNINDENT(display);
 
-	if (valid_outs == 0)
-		return -1;
+	if (ret)
+		return ret;
+
+	for_each_pipe(display, pipe) {
+		igt_pipe_t *pipe_obj = &display->pipes[pipe];
+		igt_plane_t *plane;
+
+		if (s == COMMIT_ATOMIC) {
+			pipe_obj->color_mgmt_changed = false;
+			pipe_obj->background_changed = false;
+		}
+
+		for_each_plane_on_pipe(display, pipe, plane) {
+			plane->fb_changed = false;
+			plane->position_changed = false;
+			plane->size_changed = false;
+
+			if (s != COMMIT_LEGACY || !(plane->is_primary || plane->is_cursor))
+				plane->rotation_changed = false;
+		}
+	}
+
+	for (i = 0; i < display->n_outputs && s == COMMIT_ATOMIC; i++) {
+		igt_output_t *output = &display->outputs[i];
+
+		output->config.connector_dpms_changed = false;
+		output->config.connector_scaling_mode_changed = false;
+	}
 
 	igt_debug_wait_for_keypress("modeset");
 
Signature · 6 lines
2.5.5

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#9 lore raw

PATCH 9/10 igt_kms: Add modeset support to atomic commits.

In reply to Maarten Lankhorst

Add the correct properties, add pipe_changed and mode_changed and go!

---
 lib/igt_kms.c | 124 ++++++++++++++++++++++++++++++++++++++++++++++------------
 lib/igt_kms.h |  10 +++--
 2 files changed, 105 insertions(+), 29 deletions(-)
lib/igt_kms.c +98 -26
index cae99618b93b..fc0164f4f1a2 100644
@@ -167,11 +167,13 @@ static const char *igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
 	"DEGAMMA_LUT",
 	"CTM",
 	"GAMMA_LUT",
+	"MODE_ID",
+	"ACTIVE"
 };
 
 static const char *igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
 	"scaling mode",
-	"DPMS"
+	"CRTC_ID"
 };
 
 /*
@@ -312,6 +314,9 @@ const char *kmstest_pipe_name(enum pipe pipe)
 {
 	const char *str[] = { "A", "B", "C" };
 
+	if (pipe == PIPE_NONE)
+		return "None";
+
 	if (pipe > 2)
 		return "invalid";
 
@@ -836,6 +841,8 @@ static bool _kmstest_connector_config(int drm_fd, uint32_t connector_id,
 	drmModeConnector *connector;
 	drmModeEncoder *encoder;
 
+	config->pipe = PIPE_NONE;
+
 	resources = drmModeGetResources(drm_fd);
 	if (!resources) {
 		igt_warn("drmModeGetResources failed");
@@ -1225,8 +1232,9 @@ static void igt_output_refresh(igt_output_t *output)
 			       -1);
 	}
 
-	igt_atomic_fill_connector_props(display, output,
-		IGT_NUM_CONNECTOR_PROPS, igt_connector_prop_names);
+	if (output->config.connector)
+		igt_atomic_fill_connector_props(display, output,
+			IGT_NUM_CONNECTOR_PROPS, igt_connector_prop_names);
 
 	if (!output->valid)
 		return;
@@ -1458,8 +1466,13 @@ void igt_display_init(igt_display_t *display, int drm_fd)
 		/* planes = 1 primary, (p-1) sprites, 1 cursor */
 		pipe->n_planes = p + 1;
 
+		for_each_plane_on_pipe(display, i, plane)
+			plane->fb_changed = true;
+
 		/* make sure we don't overflow the plane array */
 		igt_assert(pipe->n_planes <= IGT_MAX_PLANES);
+
+		pipe->mode_changed = true;
 	}
 
 	/*
@@ -1483,6 +1496,8 @@ void igt_display_init(igt_display_t *display, int drm_fd)
 		output->display = display;
 
 		igt_output_refresh(output);
+
+		output->config.pipe_changed = true;
 	}
 
 	drmModeFreePlaneResources(plane_resources);
@@ -2016,6 +2031,22 @@ static int igt_pipe_commit(igt_pipe_t *pipe,
 	return 0;
 }
 
+static void
+igt_pipe_replace_blob(igt_pipe_t *pipe, uint64_t *blob, void *ptr, size_t length)
+{
+	igt_display_t *display = pipe->display;
+	uint32_t blob_id = 0;
+
+	if (*blob != 0)
+		igt_assert(drmModeDestroyPropertyBlob(display->drm_fd,
+						      *blob) == 0);
+
+	if (length > 0)
+		igt_assert(drmModeCreatePropertyBlob(display->drm_fd,
+						     ptr, length, &blob_id) == 0);
+
+	*blob = blob_id;
+}
 
 /*
  * Add crtc property changes to the atomic property set
@@ -2031,6 +2062,28 @@ static void igt_atomic_prepare_crtc_commit(igt_pipe_t *pipe_obj, drmModeAtomicRe
 		igt_atomic_populate_crtc_req(req, pipe_obj, IGT_CRTC_GAMMA_LUT, pipe_obj->gamma_blob);
 	}
 
+	if (pipe_obj->mode_changed) {
+		igt_output_t *output = igt_pipe_get_output(pipe_obj);
+
+		if (!output) {
+			igt_pipe_replace_blob(pipe_obj, &pipe_obj->mode_blob, NULL, 0);
+
+			LOG(pipe_obj->display, "%s: Setting NULL mode\n",
+			    kmstest_pipe_name(pipe_obj->pipe));
+		} else {
+			drmModeModeInfo *mode = igt_output_get_mode(output);
+
+			igt_pipe_replace_blob(pipe_obj, &pipe_obj->mode_blob, mode, sizeof(*mode));
+
+			LOG(pipe_obj->display, "%s: Setting mode %s from %s\n",
+			    kmstest_pipe_name(pipe_obj->pipe),
+			    mode->name, igt_output_name(output));
+		}
+
+		igt_atomic_populate_crtc_req(req, pipe_obj, IGT_CRTC_MODE_ID, pipe_obj->mode_blob);
+		igt_atomic_populate_crtc_req(req, pipe_obj, IGT_CRTC_ACTIVE, !!output);
+	}
+
 	/*
 	 *	TODO: Add all crtc level properties here
 	 */
@@ -2047,8 +2100,14 @@ static void igt_atomic_prepare_connector_commit(igt_output_t *output, drmModeAto
 	if (config->connector_scaling_mode_changed)
 		igt_atomic_populate_connector_req(req, output, IGT_CONNECTOR_SCALING_MODE, config->connector_scaling_mode);
 
-	if (config->connector_dpms_changed)
-		igt_atomic_populate_connector_req(req, output, IGT_CONNECTOR_DPMS, config->connector_dpms);
+	if (config->pipe_changed) {
+		uint32_t crtc_id = 0;
+
+		if (output->config.pipe != PIPE_NONE)
+			crtc_id = output->config.crtc->crtc_id;
+
+		igt_atomic_populate_connector_req(req, output, IGT_CONNECTOR_CRTC_ID, crtc_id);
+	}
 	/*
 	 *	TODO: Add all other connector level properties here
 	 */
@@ -2090,10 +2149,17 @@ static int igt_atomic_commit(igt_display_t *display)
 	for (i = 0; i < display->n_outputs; i++) {
 		output = &display->outputs[i];
 
+		if (!output->config.connector)
+			continue;
+
+		LOG(display, "%s: preparing atomic, pipe: %s\n",
+		    igt_output_name(output),
+		    kmstest_pipe_name(output->config.pipe));
+
 		igt_atomic_prepare_connector_commit(output, req);
 	}
 
-	ret = drmModeAtomicCommit(display->drm_fd, req, 0, NULL);
+	ret = drmModeAtomicCommit(display->drm_fd, req, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
 	drmModeAtomicFree(req);
 	return ret;
 
@@ -2158,6 +2224,9 @@ static int do_display_commit(igt_display_t *display,
 			pipe_obj->background_changed = false;
 		}
 
+		if (s != COMMIT_UNIVERSAL)
+			pipe_obj->mode_changed = false;
+
 		for_each_plane_on_pipe(display, pipe, plane) {
 			plane->fb_changed = false;
 			plane->position_changed = false;
@@ -2168,11 +2237,14 @@ static int do_display_commit(igt_display_t *display,
 		}
 	}
 
-	for (i = 0; i < display->n_outputs && s == COMMIT_ATOMIC; i++) {
+	for (i = 0; i < display->n_outputs; i++) {
 		igt_output_t *output = &display->outputs[i];
 
-		output->config.connector_dpms_changed = false;
-		output->config.connector_scaling_mode_changed = false;
+		if (s != COMMIT_UNIVERSAL)
+			output->config.pipe_changed = false;
+
+		if (s == COMMIT_ATOMIC)
+			output->config.connector_scaling_mode_changed = false;
 	}
 
 	igt_debug_wait_for_keypress("modeset");
@@ -2266,13 +2338,25 @@ drmModeModeInfo *igt_output_get_mode(igt_output_t *output)
  */
 void igt_output_override_mode(igt_output_t *output, drmModeModeInfo *mode)
 {
+	igt_pipe_t *pipe = igt_output_get_driving_pipe(output);
+
 	output->override_mode = *mode;
 	output->use_override_mode = true;
+
+	if (pipe)
+		pipe->mode_changed = true;
 }
 
 void igt_output_set_pipe(igt_output_t *output, enum pipe pipe)
 {
 	igt_display_t *display = output->display;
+	igt_pipe_t *old_pipe;
+
+	if (output->pending_crtc_idx_mask) {
+		old_pipe = igt_output_get_driving_pipe(output);
+
+		old_pipe->mode_changed = true;
+	}
 
 	if (pipe == PIPE_NONE) {
 		LOG(display, "%s: set_pipe(any)\n", igt_output_name(output));
@@ -2281,7 +2365,12 @@ void igt_output_set_pipe(igt_output_t *output, enum pipe pipe)
 		LOG(display, "%s: set_pipe(%s)\n", igt_output_name(output),
 		    kmstest_pipe_name(pipe));
 		output->pending_crtc_idx_mask = 1 << pipe;
+
+		display->pipes[pipe].mode_changed = true;
 	}
+
+	if (pipe != output->config.pipe)
+		output->config.pipe_changed = true;
 }
 
 igt_plane_t *igt_output_get_plane(igt_output_t *output, enum igt_plane plane)
@@ -2442,23 +2531,6 @@ void igt_plane_set_rotation(igt_plane_t *plane, igt_rotation_t rotation)
 	plane->rotation_changed = true;
 }
 
-static void
-igt_pipe_replace_blob(igt_pipe_t *pipe, uint64_t *blob, void *ptr, size_t length)
-{
-	igt_display_t *display = pipe->display;
-	uint32_t blob_id = 0;
-
-	if (*blob != 0)
-		igt_assert(drmModeDestroyPropertyBlob(display->drm_fd,
-						      *blob) == 0);
-
-	if (length > 0)
-		igt_assert(drmModeCreatePropertyBlob(display->drm_fd,
-						     ptr, length, &blob_id) == 0);
-
-	*blob = blob_id;
-}
-
 void
 igt_pipe_set_degamma_lut(igt_pipe_t *pipe, void *ptr, size_t length)
 {
lib/igt_kms.h +7 -3
index 2c88c1be61e4..2e5547d664ca 100644
@@ -93,12 +93,14 @@ enum igt_atomic_crtc_properties {
        IGT_CRTC_CTM,
        IGT_CRTC_DEGAMMA_LUT,
        IGT_CRTC_GAMMA_LUT,
+       IGT_CRTC_MODE_ID,
+       IGT_CRTC_ACTIVE,
        IGT_NUM_CRTC_PROPS
 };
 
 enum igt_atomic_connector_properties {
        IGT_CONNECTOR_SCALING_MODE = 0,
-       IGT_CONNECTOR_DPMS,
+       IGT_CONNECTOR_CRTC_ID,
        IGT_NUM_CONNECTOR_PROPS
 };
 
@@ -109,8 +111,7 @@ struct kmstest_connector_config {
 	drmModeModeInfo default_mode;
 	uint64_t connector_scaling_mode;
 	bool connector_scaling_mode_changed;
-	uint64_t connector_dpms;
-	bool connector_dpms_changed;
+	bool pipe_changed;
 	uint32_t atomic_props_connector[IGT_NUM_CONNECTOR_PROPS];
 	int pipe;
 	unsigned valid_crtc_idx_mask;
@@ -263,6 +264,9 @@ struct igt_pipe {
 	uint32_t color_mgmt_changed : 1;
 
 	uint32_t crtc_id;
+
+	uint64_t mode_blob;
+	bool mode_changed;
 };
 
 typedef struct {
Signature · 6 lines
2.5.5

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#10 lore raw

PATCH 10/10 tests: Add kms_rmfb test.

In reply to Maarten Lankhorst

This tests rmfb and last close behavior. In those cases the framebuffers should be removed from the crtc.

If atomic modeset is supported, we do it all in one nice atomic commit too.

---
 tests/Makefile.sources |   1 +
 tests/kms_rmfb.c       | 171 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 172 insertions(+)
 create mode 100644 tests/kms_rmfb.c
tests/Makefile.sources +1 -0
index 80e9a35330dd..2ab25eac7764 100644
@@ -103,6 +103,7 @@ TESTS_progs_M = \
 	kms_plane \
 	kms_psr_sink_crc \
 	kms_render \
+	kms_rmfb \
 	kms_rotation_crc \
 	kms_setmode \
 	kms_universal_plane \
tests/kms_rmfb.c new file +171 -0

171 lines not on this page · raw message

Signature · 6 lines
2.5.5

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx