[igt-dev] [PATCH i-g-t 2/5] tests/kms_tiled_display: Replace the igt_display pointer with a struct

Ville Syrjala ville.syrjala at linux.intel.com
Fri Mar 13 16:11:30 UTC 2020


From: Ville Syrjälä <ville.syrjala at linux.intel.com>

No point in storing a pointer when we can just store the struct itself.
The lifetime is the same.

Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
 tests/kms_tiled_display.c | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/tests/kms_tiled_display.c b/tests/kms_tiled_display.c
index f01152f86395..0671ac6c2249 100644
--- a/tests/kms_tiled_display.c
+++ b/tests/kms_tiled_display.c
@@ -55,7 +55,7 @@ typedef struct {
 	int drm_fd;
 	int num_h_tiles;
 	igt_fb_t fb_test_pattern;
-	igt_display_t *display;
+	igt_display_t display;
 	data_connector_t *conns;
 	enum igt_commit_style commit;
 	struct timeval first_ts;
@@ -131,8 +131,8 @@ static void get_connectors(data_t *data)
 	igt_output_t *output;
 	data_connector_t *conns = data->conns;
 
-	for_each_connected_output(data->display, output) {
-		conns[count].connector = drmModeGetConnector(data->display->drm_fd,
+	for_each_connected_output(&data->display, output) {
+		conns[count].connector = drmModeGetConnector(data->display.drm_fd,
 							     output->id);
 
 		igt_assert(conns[count].connector);
@@ -177,11 +177,11 @@ static void reset_mode(data_t *data)
 	data_connector_t *conns = data->conns;
 
 	for (count = 0; count < data->num_h_tiles; count++) {
-		output = igt_output_from_connector(data->display,
+		output = igt_output_from_connector(&data->display,
 						   conns[count].connector);
 		igt_output_set_pipe(output, PIPE_NONE);
 	}
-	igt_display_commit2(data->display, data->commit);
+	igt_display_commit2(&data->display, data->commit);
 }
 
 static void test_cleanup(data_t *data)
@@ -196,7 +196,7 @@ static void test_cleanup(data_t *data)
 		}
 	}
 	igt_remove_fb(data->drm_fd, &data->fb_test_pattern);
-	igt_display_commit2(data->display, data->commit);
+	igt_display_commit2(&data->display, data->commit);
 	memset(conns, 0, sizeof(data_connector_t) * data->num_h_tiles);
 }
 
@@ -217,10 +217,10 @@ static void setup_mode(data_t *data)
 	reset_mode(data);
 
 	for (count = 0; count < data->num_h_tiles; count++) {
-		output = igt_output_from_connector(data->display,
+		output = igt_output_from_connector(&data->display,
 						   conns[count].connector);
 
-		for_each_pipe(data->display, pipe) {
+		for_each_pipe(&data->display, pipe) {
 			pipe_in_use = false;
 			found = false;
 
@@ -257,7 +257,7 @@ static void setup_mode(data_t *data)
 		igt_require(found);
 		igt_output_override_mode(output, mode);
 	}
-	igt_display_commit_atomic(data->display, DRM_MODE_ATOMIC_ALLOW_MODESET,
+	igt_display_commit_atomic(&data->display, DRM_MODE_ATOMIC_ALLOW_MODESET,
 				  NULL);
 }
 
@@ -316,7 +316,7 @@ static data_connector_t *conn_for_crtc(data_t *data, unsigned int crtc_id)
 	for (int i = 0; i < data->num_h_tiles; i++) {
 		data_connector_t *conn = &data->conns[i];
 
-		if (data->display->pipes[conn->pipe].crtc_id == crtc_id)
+		if (data->display.pipes[conn->pipe].crtc_id == crtc_id)
 			return conn;
 	}
 
@@ -375,7 +375,6 @@ static bool got_all_page_flips(data_t *data)
 
 igt_main
 {
-	igt_display_t display;
 	data_t data = {0};
 	struct pollfd pfd = {0};
 	drmEventContext drm_event = {0};
@@ -385,15 +384,14 @@ igt_main
 		data.drm_fd = drm_open_driver_master(DRIVER_ANY);
 
 		kmstest_set_vt_graphics_mode();
-		igt_display_require(&display, data.drm_fd);
-		igt_display_reset(&display);
+		igt_display_require(&data.display, data.drm_fd);
+		igt_display_reset(&data.display);
 
-		data.display = &display;
 		pfd.fd = data.drm_fd;
 		pfd.events = POLLIN;
 		drm_event.version = 3;
 		drm_event.page_flip_handler2 = page_flip_handler;
-		data.commit = data.display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY;
+		data.commit = data.display.is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY;
 		igt_require(data.commit == COMMIT_ATOMIC);
 
 		get_number_of_h_tiles(&data);
@@ -411,7 +409,7 @@ igt_main
 		setup_mode(&data);
 		setup_framebuffer(&data);
 		timerclear(&data.first_ts);
-		igt_display_commit_atomic(data.display, DRM_MODE_ATOMIC_NONBLOCK |
+		igt_display_commit_atomic(&data.display, DRM_MODE_ATOMIC_NONBLOCK |
 					  DRM_MODE_PAGE_FLIP_EVENT, &data);
 		while (!got_all_page_flips(&data)) {
 			ret = poll(&pfd, 1, 1000);
@@ -426,6 +424,6 @@ igt_main
 		free(data.conns);
 		close(data.drm_fd);
 		kmstest_restore_vt_mode();
-		igt_display_fini(data.display);
+		igt_display_fini(&data.display);
 	}
 }
-- 
2.24.1



More information about the igt-dev mailing list