All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt PATCH 1/5] lib: move connector_type_str and co to drmtest
@ 2013-05-31  9:23 Imre Deak
  2013-05-31  9:23 ` [igt PATCH 2/5] lib: add kmstest_cairo_printf_line Imre Deak
                   ` (4 more replies)
  0 siblings, 5 replies; 22+ messages in thread
From: Imre Deak @ 2013-05-31  9:23 UTC (permalink / raw)
  To: intel-gfx

These are used by multiple test cases, so make them shared.

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 demos/intel_sprite_on.c | 58 ++++------------------------------------------
 lib/drmtest.c           | 54 +++++++++++++++++++++++++++++++++++++++++++
 lib/drmtest.h           |  3 +++
 tests/testdisplay.c     | 61 ++++---------------------------------------------
 4 files changed, 65 insertions(+), 111 deletions(-)

diff --git a/demos/intel_sprite_on.c b/demos/intel_sprite_on.c
index 62bd98e..783f9af 100644
--- a/demos/intel_sprite_on.c
+++ b/demos/intel_sprite_on.c
@@ -53,56 +53,6 @@
 
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 
-struct type_name {
-	int                 type;
-	const char          *name;
-};
-
-#define type_name_fn(res) \
-	static const char * res##_str(int type) {		\
-		unsigned int i;					\
-		for (i = 0; i < ARRAY_SIZE(res##_names); i++) { \
-			if (res##_names[i].type == type)	\
-			return res##_names[i].name;		\
-		}						\
-		return "(invalid)";				\
-	}
-
-struct type_name encoder_type_names[] = {
-	{ DRM_MODE_ENCODER_NONE, "none" },
-	{ DRM_MODE_ENCODER_DAC, "DAC" },
-	{ DRM_MODE_ENCODER_TMDS, "TMDS" },
-	{ DRM_MODE_ENCODER_LVDS, "LVDS" },
-	{ DRM_MODE_ENCODER_TVDAC, "TVDAC" },
-};
-type_name_fn(encoder_type)
-
-struct type_name connector_status_names[] = {
-	{ DRM_MODE_CONNECTED, "connected" },
-	{ DRM_MODE_DISCONNECTED, "disconnected" },
-	{ DRM_MODE_UNKNOWNCONNECTION, "unknown" },
-};
-type_name_fn(connector_status)
-
-struct type_name connector_type_names[] = {
-	{ DRM_MODE_CONNECTOR_Unknown, "unknown" },
-	{ DRM_MODE_CONNECTOR_VGA, "VGA" },
-	{ DRM_MODE_CONNECTOR_DVII, "DVI-I" },
-	{ DRM_MODE_CONNECTOR_DVID, "DVI-D" },
-	{ DRM_MODE_CONNECTOR_DVIA, "DVI-A" },
-	{ DRM_MODE_CONNECTOR_Composite, "composite" },
-	{ DRM_MODE_CONNECTOR_SVIDEO, "s-video" },
-	{ DRM_MODE_CONNECTOR_LVDS, "LVDS" },
-	{ DRM_MODE_CONNECTOR_Component, "component" },
-	{ DRM_MODE_CONNECTOR_9PinDIN, "9-pin DIN" },
-	{ DRM_MODE_CONNECTOR_DisplayPort, "DisplayPort" },
-	{ DRM_MODE_CONNECTOR_HDMIA, "HDMI-A" },
-	{ DRM_MODE_CONNECTOR_HDMIB, "HDMI-B" },
-	{ DRM_MODE_CONNECTOR_TV, "TV" },
-	{ DRM_MODE_CONNECTOR_eDP, "Embedded DisplayPort" },
-};
-type_name_fn(connector_type)
-
 /*
  * Mode setting with the kernel interfaces is a bit of a chore.
  * First you have to find the connector in question and make sure the
@@ -157,8 +107,8 @@ static void dump_connectors(int gfx_fd, drmModeRes *resources)
 		printf("%d\t%d\t%s\t%s\t%dx%d\t\t%d\n",
 			connector->connector_id,
 			connector->encoder_id,
-			connector_status_str(connector->connection),
-			connector_type_str(connector->connector_type),
+			kmstest_connector_status_str(connector->connection),
+			kmstest_connector_type_str(connector->connector_type),
 			connector->mmWidth, connector->mmHeight,
 			connector->count_modes);
 
@@ -744,14 +694,14 @@ static void ricochet(int tiled, int sprite_w, int sprite_h,
 				curr_connector.mode.flags,
 				curr_connector.encoder->encoder_id,
 				curr_connector.encoder->encoder_type,
-				encoder_type_str(curr_connector.encoder->encoder_type),
+				kmstest_encoder_type_str(curr_connector.encoder->encoder_type),
 				curr_connector.encoder->crtc_id,
 				curr_connector.encoder->possible_crtcs,
 				curr_connector.encoder->possible_clones,
 				curr_connector.connector->connector_id,
 				curr_connector.connector->encoder_id,
 				curr_connector.connector->connector_type,
-				connector_type_str(curr_connector.connector->connector_type),
+				kmstest_connector_type_str(curr_connector.connector->connector_type),
 				curr_connector.connector->connector_type_id);
 
 			printf("Sprite surface dimensions = %dx%d\n"
diff --git a/lib/drmtest.c b/lib/drmtest.c
index d17dbb0..3c4812f 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -1023,6 +1023,60 @@ void kmstest_remove_fb(int fd, int fb_id)
 	do_or_die(drmModeRmFB(fd, fb_id));
 }
 
+struct type_name {
+	int type;
+	const char *name;
+};
+
+#define type_name_fn(res) \
+const char * kmstest_##res##_str(int type) {		\
+	unsigned int i;					\
+	for (i = 0; i < ARRAY_SIZE(res##_names); i++) { \
+		if (res##_names[i].type == type)	\
+			return res##_names[i].name;	\
+	}						\
+	return "(invalid)";				\
+}
+
+struct type_name encoder_type_names[] = {
+	{ DRM_MODE_ENCODER_NONE, "none" },
+	{ DRM_MODE_ENCODER_DAC, "DAC" },
+	{ DRM_MODE_ENCODER_TMDS, "TMDS" },
+	{ DRM_MODE_ENCODER_LVDS, "LVDS" },
+	{ DRM_MODE_ENCODER_TVDAC, "TVDAC" },
+};
+
+type_name_fn(encoder_type)
+
+struct type_name connector_status_names[] = {
+	{ DRM_MODE_CONNECTED, "connected" },
+	{ DRM_MODE_DISCONNECTED, "disconnected" },
+	{ DRM_MODE_UNKNOWNCONNECTION, "unknown" },
+};
+
+type_name_fn(connector_status)
+
+struct type_name connector_type_names[] = {
+	{ DRM_MODE_CONNECTOR_Unknown, "unknown" },
+	{ DRM_MODE_CONNECTOR_VGA, "VGA" },
+	{ DRM_MODE_CONNECTOR_DVII, "DVI-I" },
+	{ DRM_MODE_CONNECTOR_DVID, "DVI-D" },
+	{ DRM_MODE_CONNECTOR_DVIA, "DVI-A" },
+	{ DRM_MODE_CONNECTOR_Composite, "composite" },
+	{ DRM_MODE_CONNECTOR_SVIDEO, "s-video" },
+	{ DRM_MODE_CONNECTOR_LVDS, "LVDS" },
+	{ DRM_MODE_CONNECTOR_Component, "component" },
+	{ DRM_MODE_CONNECTOR_9PinDIN, "9-pin DIN" },
+	{ DRM_MODE_CONNECTOR_DisplayPort, "DisplayPort" },
+	{ DRM_MODE_CONNECTOR_HDMIA, "HDMI-A" },
+	{ DRM_MODE_CONNECTOR_HDMIB, "HDMI-B" },
+	{ DRM_MODE_CONNECTOR_TV, "TV" },
+	{ DRM_MODE_CONNECTOR_eDP, "Embedded DisplayPort" },
+};
+
+type_name_fn(connector_type)
+
+
 void kmstest_dump_mode(drmModeModeInfo *mode)
 {
 	printf("  %s %d %d %d %d %d %d %d %d %d 0x%x 0x%x %d\n",
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 7202ad5..38aeb9d 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -119,6 +119,9 @@ unsigned int kmstest_create_fb(int fd, int width, int height, int bpp,
 void kmstest_remove_fb(int fd, int fb_id);
 void kmstest_dump_mode(drmModeModeInfo *mode);
 int kmstest_get_pipe_from_crtc_id(int fd, int crtc_id);
+const char *kmstest_encoder_type_str(int type);
+const char *kmstest_connector_status_str(int type);
+const char *kmstest_connector_type_str(int type);
 
 inline static void _do_or_die(const char *function, int line, int ret)
 {
diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index 80cd112..e7a2555 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -88,59 +88,6 @@ uint32_t *fb_ptr;
 
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 
-struct type_name {
-	int type;
-	const char *name;
-};
-
-#define type_name_fn(res) \
-static const char * res##_str(int type) {			\
-	unsigned int i;					\
-	for (i = 0; i < ARRAY_SIZE(res##_names); i++) { \
-		if (res##_names[i].type == type)	\
-			return res##_names[i].name;	\
-	}						\
-	return "(invalid)";				\
-}
-
-struct type_name encoder_type_names[] = {
-	{ DRM_MODE_ENCODER_NONE, "none" },
-	{ DRM_MODE_ENCODER_DAC, "DAC" },
-	{ DRM_MODE_ENCODER_TMDS, "TMDS" },
-	{ DRM_MODE_ENCODER_LVDS, "LVDS" },
-	{ DRM_MODE_ENCODER_TVDAC, "TVDAC" },
-};
-
-type_name_fn(encoder_type)
-
-struct type_name connector_status_names[] = {
-	{ DRM_MODE_CONNECTED, "connected" },
-	{ DRM_MODE_DISCONNECTED, "disconnected" },
-	{ DRM_MODE_UNKNOWNCONNECTION, "unknown" },
-};
-
-type_name_fn(connector_status)
-
-struct type_name connector_type_names[] = {
-	{ DRM_MODE_CONNECTOR_Unknown, "unknown" },
-	{ DRM_MODE_CONNECTOR_VGA, "VGA" },
-	{ DRM_MODE_CONNECTOR_DVII, "DVI-I" },
-	{ DRM_MODE_CONNECTOR_DVID, "DVI-D" },
-	{ DRM_MODE_CONNECTOR_DVIA, "DVI-A" },
-	{ DRM_MODE_CONNECTOR_Composite, "composite" },
-	{ DRM_MODE_CONNECTOR_SVIDEO, "s-video" },
-	{ DRM_MODE_CONNECTOR_LVDS, "LVDS" },
-	{ DRM_MODE_CONNECTOR_Component, "component" },
-	{ DRM_MODE_CONNECTOR_9PinDIN, "9-pin DIN" },
-	{ DRM_MODE_CONNECTOR_DisplayPort, "DisplayPort" },
-	{ DRM_MODE_CONNECTOR_HDMIA, "HDMI-A" },
-	{ DRM_MODE_CONNECTOR_HDMIB, "HDMI-B" },
-	{ DRM_MODE_CONNECTOR_TV, "TV" },
-	{ DRM_MODE_CONNECTOR_eDP, "Embedded DisplayPort" },
-};
-
-type_name_fn(connector_type)
-
 /*
  * Mode setting with the kernel interfaces is a bit of a chore.
  * First you have to find the connector in question and make sure the
@@ -185,8 +132,8 @@ static void dump_connectors_fd(int drmfd)
 		printf("%d\t%d\t%s\t%s\t%dx%d\t\t%d\n",
 		       connector->connector_id,
 		       connector->encoder_id,
-		       connector_status_str(connector->connection),
-		       connector_type_str(connector->connector_type),
+		       kmstest_connector_status_str(connector->connection),
+		       kmstest_connector_type_str(connector->connector_type),
 		       connector->mmWidth, connector->mmHeight,
 		       connector->count_modes);
 
@@ -390,7 +337,7 @@ paint_output_info(cairo_t *cr, int l_width, int l_height, void *priv)
 
 	/* Get text extents for each string */
 	snprintf(name_buf, sizeof name_buf, "%s",
-		 connector_type_str(c->connector->connector_type));
+		 kmstest_connector_type_str(c->connector->connector_type));
 	cairo_set_font_size(cr, 48);
 	cairo_select_font_face(cr, "Helvetica",
 			       CAIRO_FONT_SLANT_NORMAL,
@@ -399,7 +346,7 @@ paint_output_info(cairo_t *cr, int l_width, int l_height, void *priv)
 
 	snprintf(mode_buf, sizeof mode_buf, "%s @ %dHz on %s encoder",
 		 c->mode.name, c->mode.vrefresh,
-		 encoder_type_str(c->encoder->encoder_type));
+		 kmstest_encoder_type_str(c->encoder->encoder_type));
 	cairo_set_font_size(cr, 36);
 	cairo_text_extents(cr, mode_buf, &mode_extents);
 
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2013-06-06 10:19 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-31  9:23 [igt PATCH 1/5] lib: move connector_type_str and co to drmtest Imre Deak
2013-05-31  9:23 ` [igt PATCH 2/5] lib: add kmstest_cairo_printf_line Imre Deak
2013-06-05 17:44   ` Rodrigo Vivi
2013-06-05 19:01     ` Imre Deak
2013-05-31  9:23 ` [igt PATCH 3/5] lib: add kmstest_get_connector_config Imre Deak
2013-06-05 18:00   ` Rodrigo Vivi
2013-05-31  9:23 ` [igt PATCH 4/5] lib: refactor kmstest_create_fb Imre Deak
2013-06-05 18:21   ` Rodrigo Vivi
2013-05-31  9:23 ` [igt PATCH 5/5] tests: add kms_render Imre Deak
2013-06-05 18:28   ` Rodrigo Vivi
2013-06-06 10:19     ` Imre Deak
2013-06-05 19:25   ` [PATCH v2 0/6] tests: add tests for front buffer rendering Imre Deak
2013-06-05 19:25     ` [PATCH v2 1/6] lib: move connector_type_str and co to drmtest Imre Deak
2013-06-05 19:25     ` [PATCH v2 2/6] lib: add kmstest_cairo_printf_line Imre Deak
2013-06-05 19:27       ` Rodrigo Vivi
2013-06-05 20:04       ` [PATCH v3 " Imre Deak
2013-06-05 19:25     ` [PATCH v2 3/6] lib: use kmstest_cairo_printf_line in paint_marker Imre Deak
2013-06-05 19:29       ` Rodrigo Vivi
2013-06-05 19:25     ` [PATCH v2 4/6] lib: add kmstest_get_connector_config Imre Deak
2013-06-05 19:25     ` [PATCH v2 5/6] lib: refactor kmstest_create_fb Imre Deak
2013-06-05 19:25     ` [PATCH v2 6/6] tests: add kms_render Imre Deak
2013-06-05 17:40 ` [igt PATCH 1/5] lib: move connector_type_str and co to drmtest Rodrigo Vivi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.