All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [i-g-t] Stereo 3D
@ 2013-09-06 19:08 Damien Lespiau
  2013-09-06 19:08 ` [PATCH i-g-t 01/12] lib: Dump information about the supported 3D stereo formats Damien Lespiau
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: Damien Lespiau @ 2013-09-06 19:08 UTC (permalink / raw
  To: intel-gfx

This series makes testdisplay able to display top and bottom, side by side half
and frame packing stereo framebuffers. The final fb is composited from separate
left and right images using cairo.

I skipped the first couple of patches because of 2 massive 1080p pngs, but
pushed a branch:
  http://cgit.freedesktop.org/~damien/intel-gpu-tools/log/?h=20130906-stereo-3d

-- 
Damien

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

* [PATCH i-g-t 01/12] lib: Dump information about the supported 3D stereo formats
  2013-09-06 19:08 [i-g-t] Stereo 3D Damien Lespiau
@ 2013-09-06 19:08 ` Damien Lespiau
  2013-09-06 19:08 ` [PATCH i-g-t 02/12] lib: Add a helper to paint a PNG using cairo Damien Lespiau
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Damien Lespiau @ 2013-09-06 19:08 UTC (permalink / raw
  To: intel-gfx

When dumping the details of a mode, let's add the 3D formats the mode
supports.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 lib/drmtest.c | 37 +++++++++++++++++++++++++++++++++++--
 lib/drmtest.h |  9 +++++++++
 2 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index 37a0e22..eca792c 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -1587,10 +1587,42 @@ struct type_name connector_type_names[] = {
 
 type_name_fn(connector_type)
 
+#define DRM_MODE_FOR_EACH_3D_FLAG(func, sep) \
+		func(DRM_MODE_FLAG_3D_FRAME_PACKING) sep \
+	        func(DRM_MODE_FLAG_3D_FIELD_ALTERNATIVE) sep \
+	        func(DRM_MODE_FLAG_3D_LINE_ALTERNATIVE) sep \
+	        func(DRM_MODE_FLAG_3D_SIDE_BY_SIDE_FULL) sep \
+	        func(DRM_MODE_FLAG_3D_L_DEPTH) sep \
+	        func(DRM_MODE_FLAG_3D_L_DEPTH_GFX_GFX_DEPTH) sep \
+	        func(DRM_MODE_FLAG_3D_TOP_AND_BOTTOM) sep \
+	        func(DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF)
 
 void kmstest_dump_mode(drmModeModeInfo *mode)
 {
-	printf("  %s %d %d %d %d %d %d %d %d %d 0x%x 0x%x %d\n",
+	bool stereo_3d = mode->flags & DRMTEST_MODE_FLAG_3D_MASK;
+	char flags_str[32];
+
+#define PRINT_S(name) "%s"
+#define SEP_EMPTY
+#define PRINT_FLAG(flag, str)	\
+	mode->flags & DRM_MODE_FLAG_3D_ ## flag ? " "str : ""
+
+	snprintf(flags_str, sizeof(flags_str), " (3D:"
+		 DRM_MODE_FOR_EACH_3D_FLAG(PRINT_S, SEP_EMPTY) ")",
+		 PRINT_FLAG(FRAME_PACKING, "FP"),
+		 PRINT_FLAG(FIELD_ALTERNATIVE, "FA"),
+		 PRINT_FLAG(LINE_ALTERNATIVE, "LA"),
+		 PRINT_FLAG(SIDE_BY_SIDE_FULL, "SBSF"),
+		 PRINT_FLAG(L_DEPTH, "LD"),
+		 PRINT_FLAG(L_DEPTH_GFX_GFX_DEPTH, "LDGFX"),
+		 PRINT_FLAG(TOP_AND_BOTTOM, "TB"),
+		 PRINT_FLAG(SIDE_BY_SIDE_HALF, "SBSH"));
+
+#undef PRINT_S
+#undef SEP_EMPTY
+#undef PRINT_FLAG
+
+	printf("  %s %d %d %d %d %d %d %d %d %d 0x%x 0x%x %d%s\n",
 	       mode->name,
 	       mode->vrefresh,
 	       mode->hdisplay,
@@ -1603,7 +1635,8 @@ void kmstest_dump_mode(drmModeModeInfo *mode)
 	       mode->vtotal,
 	       mode->flags,
 	       mode->type,
-	       mode->clock);
+	       mode->clock,
+	       stereo_3d ? flags_str : "");
 	fflush(stdout);
 }
 
diff --git a/lib/drmtest.h b/lib/drmtest.h
index f55825e..2a562f7 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -259,6 +259,15 @@ bool igt_run_in_simulation(void);
  */
 void igt_skip_on_simulation(void);
 
+#define DRMTEST_MODE_FLAG_3D_MASK   (DRM_MODE_FLAG_3D_FRAME_PACKING         | \
+				     DRM_MODE_FLAG_3D_FIELD_ALTERNATIVE     | \
+				     DRM_MODE_FLAG_3D_LINE_ALTERNATIVE      | \
+				     DRM_MODE_FLAG_3D_SIDE_BY_SIDE_FULL     | \
+				     DRM_MODE_FLAG_3D_L_DEPTH               | \
+				     DRM_MODE_FLAG_3D_L_DEPTH_GFX_GFX_DEPTH | \
+				     DRM_MODE_FLAG_3D_TOP_AND_BOTTOM        | \
+				     DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF)
+
 /* helpers based upon the libdrm buffer manager */
 void igt_init_aperture_trashers(drm_intel_bufmgr *bufmgr);
 void igt_trash_aperture(void);
-- 
1.8.3.1

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

* [PATCH i-g-t 02/12] lib: Add a helper to paint a PNG using cairo
  2013-09-06 19:08 [i-g-t] Stereo 3D Damien Lespiau
  2013-09-06 19:08 ` [PATCH i-g-t 01/12] lib: Dump information about the supported 3D stereo formats Damien Lespiau
@ 2013-09-06 19:08 ` Damien Lespiau
  2013-09-06 19:08 ` [PATCH i-g-t 03/12] lib: Split create_image_surface() out of create_cairo_ctx() Damien Lespiau
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Damien Lespiau @ 2013-09-06 19:08 UTC (permalink / raw
  To: intel-gfx

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 lib/drmtest.c | 28 ++++++++++++++++++++++++++++
 lib/drmtest.h |  2 ++
 2 files changed, 30 insertions(+)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index eca792c..f760028 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -1338,6 +1338,34 @@ void kmstest_paint_test_pattern(cairo_t *cr, int width, int height)
 	assert(!cairo_status(cr));
 }
 
+void kmstest_paint_image(cairo_t *cr, const char *filename,
+			 int dst_x, int dst_y, int dst_width, int dst_height)
+{
+	cairo_surface_t *image;
+	int img_width, img_height;
+	double scale_x, scale_y;
+
+	image = cairo_image_surface_create_from_png(filename);
+	assert(cairo_surface_status(image) == CAIRO_STATUS_SUCCESS);
+
+	img_width = cairo_image_surface_get_width(image);
+	img_height = cairo_image_surface_get_height(image);
+
+	scale_x = (double)dst_width / img_width;
+	scale_y = (double)dst_height / img_height;
+
+	cairo_save(cr);
+
+	cairo_translate(cr, dst_x, dst_y);
+	cairo_scale(cr, scale_x, scale_y);
+	cairo_set_source_surface(cr, image, 0, 0);
+	cairo_paint(cr);
+
+	cairo_surface_destroy(image);
+
+	cairo_restore(cr);
+}
+
 #define DF(did, cid, _bpp, _depth)	\
 	{ DRM_FORMAT_##did, CAIRO_FORMAT_##cid, # did, _bpp, _depth }
 static struct format_desc_struct {
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 2a562f7..6591068 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -326,6 +326,8 @@ cairo_t *kmstest_get_cairo_ctx(int fd, struct kmstest_fb *fb);
 void kmstest_paint_color_gradient(cairo_t *cr, int x, int y, int w, int h,
 				  int r, int g, int b);
 void kmstest_paint_test_pattern(cairo_t *cr, int width, int height);
+void kmstest_paint_image(cairo_t *cr, const char *filename,
+			 int dst_x, int dst_y, int dst_width, int dst_height);
 void kmstest_dump_mode(drmModeModeInfo *mode);
 int kmstest_get_pipe_from_crtc_id(int fd, int crtc_id);
 const char *kmstest_format_str(uint32_t drm_format);
-- 
1.8.3.1

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

* [PATCH i-g-t 03/12] lib: Split create_image_surface() out of create_cairo_ctx()
  2013-09-06 19:08 [i-g-t] Stereo 3D Damien Lespiau
  2013-09-06 19:08 ` [PATCH i-g-t 01/12] lib: Dump information about the supported 3D stereo formats Damien Lespiau
  2013-09-06 19:08 ` [PATCH i-g-t 02/12] lib: Add a helper to paint a PNG using cairo Damien Lespiau
@ 2013-09-06 19:08 ` Damien Lespiau
  2013-09-06 19:08 ` [PATCH i-g-t 04/12] lib: Add a helper to write a png from a struct kmstest_fb Damien Lespiau
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Damien Lespiau @ 2013-09-06 19:08 UTC (permalink / raw
  To: intel-gfx

So we can use it in the next commit.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 lib/drmtest.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index f760028..12bd0ff 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -1483,9 +1483,8 @@ static cairo_format_t drm_format_to_cairo(uint32_t drm_format)
 	abort();
 }
 
-static cairo_t *create_cairo_ctx(int fd, struct kmstest_fb *fb)
+static cairo_surface_t *create_image_surface(int fd, struct kmstest_fb *fb)
 {
-	cairo_t *cr;
 	cairo_surface_t *surface;
 	cairo_format_t cformat;
 	void *fb_ptr;
@@ -1496,6 +1495,16 @@ static cairo_t *create_cairo_ctx(int fd, struct kmstest_fb *fb)
 						   cformat, fb->width,
 						   fb->height, fb->stride);
 	assert(surface);
+
+	return surface;
+}
+
+static cairo_t *create_cairo_ctx(int fd, struct kmstest_fb *fb)
+{
+	cairo_t *cr;
+	cairo_surface_t *surface;
+
+	surface = create_image_surface(fd, fb);
 	cr = cairo_create(surface);
 	cairo_surface_destroy(surface);
 
-- 
1.8.3.1

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

* [PATCH i-g-t 04/12] lib: Add a helper to write a png from a struct kmstest_fb
  2013-09-06 19:08 [i-g-t] Stereo 3D Damien Lespiau
                   ` (2 preceding siblings ...)
  2013-09-06 19:08 ` [PATCH i-g-t 03/12] lib: Split create_image_surface() out of create_cairo_ctx() Damien Lespiau
@ 2013-09-06 19:08 ` Damien Lespiau
  2013-09-06 19:08 ` [PATCH i-g-t 05/12] testdisplay: Move the code sanitizing depth into main() Damien Lespiau
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Damien Lespiau @ 2013-09-06 19:08 UTC (permalink / raw
  To: intel-gfx

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 lib/drmtest.c | 11 +++++++++++
 lib/drmtest.h |  1 +
 2 files changed, 12 insertions(+)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index 12bd0ff..f7de232 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -1531,6 +1531,17 @@ void kmstest_remove_fb(int fd, struct kmstest_fb *fb)
 	gem_close(fd, fb->gem_handle);
 }
 
+void kmstest_write_fb(int fd, struct kmstest_fb *fb, const char *filename)
+{
+	cairo_surface_t *surface;
+	cairo_status_t status;
+
+	surface = create_image_surface(fd, fb);
+	status = cairo_surface_write_to_png(surface, filename);
+	assert(status == CAIRO_STATUS_SUCCESS);
+	cairo_surface_destroy(surface);
+}
+
 const char *kmstest_format_str(uint32_t drm_format)
 {
 	struct format_desc_struct *f;
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 6591068..542b87e 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -328,6 +328,7 @@ void kmstest_paint_color_gradient(cairo_t *cr, int x, int y, int w, int h,
 void kmstest_paint_test_pattern(cairo_t *cr, int width, int height);
 void kmstest_paint_image(cairo_t *cr, const char *filename,
 			 int dst_x, int dst_y, int dst_width, int dst_height);
+void kmstest_write_fb(int fd, struct kmstest_fb *fb, const char *filename);
 void kmstest_dump_mode(drmModeModeInfo *mode);
 int kmstest_get_pipe_from_crtc_id(int fd, int crtc_id);
 const char *kmstest_format_str(uint32_t drm_format);
-- 
1.8.3.1

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

* [PATCH i-g-t 05/12] testdisplay: Move the code sanitizing depth into main()
  2013-09-06 19:08 [i-g-t] Stereo 3D Damien Lespiau
                   ` (3 preceding siblings ...)
  2013-09-06 19:08 ` [PATCH i-g-t 04/12] lib: Add a helper to write a png from a struct kmstest_fb Damien Lespiau
@ 2013-09-06 19:08 ` Damien Lespiau
  2013-09-06 19:08 ` [PATCH i-g-t 06/12] testdisplay: Map the fb inside paint_color_key() Damien Lespiau
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Damien Lespiau @ 2013-09-06 19:08 UTC (permalink / raw
  To: intel-gfx

It'll be shared by the set_mode() and set_3d_mode() functions.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 tests/testdisplay.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index 6c39b68..c3a0d04 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -334,13 +334,6 @@ set_mode(struct connector *c)
 	unsigned int fb_id = 0;
 	int j, test_mode_num;
 
-	if (depth <= 8)
-		bpp = 8;
-	else if (depth > 8 && depth <= 16)
-		bpp = 16;
-	else if (depth > 16 && depth <= 32)
-		bpp = 32;
-
 	test_mode_num = 1;
 	if (force_mode){
 		memcpy( &c->mode, &force_timing, sizeof(force_timing));
@@ -585,6 +578,14 @@ int main(int argc, char **argv)
 			break;
 		}
 	}
+
+	if (depth <= 8)
+		bpp = 8;
+	else if (depth <= 16)
+		bpp = 16;
+	else if (depth <= 32)
+		bpp = 32;
+
 	if (!test_all_modes && !force_mode && !dump_info &&
 	    !test_preferred_mode && specified_mode_num == -1)
 		test_all_modes = 1;
-- 
1.8.3.1

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

* [PATCH i-g-t 06/12] testdisplay: Map the fb inside paint_color_key()
  2013-09-06 19:08 [i-g-t] Stereo 3D Damien Lespiau
                   ` (4 preceding siblings ...)
  2013-09-06 19:08 ` [PATCH i-g-t 05/12] testdisplay: Move the code sanitizing depth into main() Damien Lespiau
@ 2013-09-06 19:08 ` Damien Lespiau
  2013-09-06 19:08 ` [PATCH i-g-t 07/12] testdisplay: Properly handle the life cycle of framebuffers Damien Lespiau
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Damien Lespiau @ 2013-09-06 19:08 UTC (permalink / raw
  To: intel-gfx

So the code for this is self-contained. This goes along the way of
reducing the number of global variables in testdisplay.

Take the opportunity to unmap the fb after use as well.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 tests/testdisplay.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index c3a0d04..3d696a0 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -82,7 +82,6 @@ unsigned int plane_crtc_id;
 unsigned int plane_id;
 int plane_width, plane_height;
 static const uint32_t SPRITE_COLOR_KEY = 0x00aaaaaa;
-uint32_t *fb_ptr;
 
 /*
  * Mode setting with the kernel interfaces is a bit of a chore.
@@ -213,6 +212,11 @@ static void
 paint_color_key(struct kmstest_fb *fb_info)
 {
 	int i, j;
+	uint32_t *fb_ptr;
+
+	fb_ptr = gem_mmap(drm_fd, fb_info->gem_handle,
+			  fb_info->size, PROT_READ | PROT_WRITE);
+	igt_assert(fb_ptr);
 
 	for (i = crtc_y; i < crtc_y + crtc_h; i++)
 		for (j = crtc_x; j < crtc_x + crtc_w; j++) {
@@ -221,6 +225,8 @@ paint_color_key(struct kmstest_fb *fb_info)
 			offset = (i * fb_info->stride / 4) + j;
 			fb_ptr[offset] = SPRITE_COLOR_KEY;
 		}
+
+	munmap(fb_ptr, fb_info->size);
 }
 
 static void paint_image(cairo_t *cr, const char *file)
@@ -358,10 +364,6 @@ set_mode(struct connector *c)
 		fb_id = kmstest_create_fb(drm_fd, width, height, bpp, depth,
 					  enable_tiling, &fb_info);
 		paint_output_info(c, &fb_info);
-
-		fb_ptr = gem_mmap(drm_fd, fb_info.gem_handle,
-				  fb_info.size, PROT_READ | PROT_WRITE);
-		igt_assert(fb_ptr);
 		paint_color_key(&fb_info);
 
 		gem_close(drm_fd, fb_info.gem_handle);
-- 
1.8.3.1

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

* [PATCH i-g-t 07/12] testdisplay: Properly handle the life cycle of framebuffers
  2013-09-06 19:08 [i-g-t] Stereo 3D Damien Lespiau
                   ` (5 preceding siblings ...)
  2013-09-06 19:08 ` [PATCH i-g-t 06/12] testdisplay: Map the fb inside paint_color_key() Damien Lespiau
@ 2013-09-06 19:08 ` Damien Lespiau
  2013-09-06 19:08 ` [PATCH i-g-t 08/12] testdisplay: Fix CRTS typo Damien Lespiau
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Damien Lespiau @ 2013-09-06 19:08 UTC (permalink / raw
  To: intel-gfx

When cycling through the modes, let's make sure to free the previous
framebuffers. This is the perfect occasion to use kmstest_remove_fb().

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 tests/testdisplay.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index 3d696a0..6e47ae2 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -338,7 +338,8 @@ static void
 set_mode(struct connector *c)
 {
 	unsigned int fb_id = 0;
-	int j, test_mode_num;
+	struct kmstest_fb fb_info[2] = { };
+	int j, test_mode_num, current_fb = 0, old_fb = -1;
 
 	test_mode_num = 1;
 	if (force_mode){
@@ -350,7 +351,6 @@ set_mode(struct connector *c)
 		test_mode_num = c->connector->count_modes;
 
 	for (j = 0; j < test_mode_num; j++) {
-		struct kmstest_fb fb_info;
 
 		if (test_all_modes)
 			c->mode = c->connector->modes[j];
@@ -362,11 +362,9 @@ set_mode(struct connector *c)
 		height = c->mode.vdisplay;
 
 		fb_id = kmstest_create_fb(drm_fd, width, height, bpp, depth,
-					  enable_tiling, &fb_info);
-		paint_output_info(c, &fb_info);
-		paint_color_key(&fb_info);
-
-		gem_close(drm_fd, fb_info.gem_handle);
+					  enable_tiling, &fb_info[current_fb]);
+		paint_output_info(c, &fb_info[current_fb]);
+		paint_color_key(&fb_info[current_fb]);
 
 		fprintf(stdout, "CRTS(%u):[%d]",c->crtc, j);
 		kmstest_dump_mode(&c->mode);
@@ -378,6 +376,11 @@ set_mode(struct connector *c)
 			continue;
 		}
 
+		if (old_fb != -1)
+			kmstest_remove_fb(drm_fd, &fb_info[old_fb]);
+		old_fb = current_fb;
+		current_fb = 1 - current_fb;
+
 		if (sleep_between_modes && test_all_modes && !qr_code)
 			sleep(sleep_between_modes);
 
@@ -385,13 +388,10 @@ set_mode(struct connector *c)
 			set_single();
 			pause();
 		}
-
 	}
 
-	if(test_all_modes){
-		drmModeRmFB(drm_fd,fb_id);
-		drmModeSetCrtc(drm_fd, c->crtc, fb_id, 0, 0,  &c->id, 1, 0);
-	}
+	if (test_all_modes)
+		kmstest_remove_fb(drm_fd, &fb_info[old_fb]);
 
 	drmModeFreeEncoder(c->encoder);
 	drmModeFreeConnector(c->connector);
-- 
1.8.3.1

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

* [PATCH i-g-t 08/12] testdisplay: Fix CRTS typo
  2013-09-06 19:08 [i-g-t] Stereo 3D Damien Lespiau
                   ` (6 preceding siblings ...)
  2013-09-06 19:08 ` [PATCH i-g-t 07/12] testdisplay: Properly handle the life cycle of framebuffers Damien Lespiau
@ 2013-09-06 19:08 ` Damien Lespiau
  2013-09-06 19:08 ` [PATCH i-g-t 09/12] testdisplay: Untangle dump_info() from the main testing loop Damien Lespiau
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Damien Lespiau @ 2013-09-06 19:08 UTC (permalink / raw
  To: intel-gfx

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 tests/testdisplay.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index 6e47ae2..f94e5c4 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -366,7 +366,7 @@ set_mode(struct connector *c)
 		paint_output_info(c, &fb_info[current_fb]);
 		paint_color_key(&fb_info[current_fb]);
 
-		fprintf(stdout, "CRTS(%u):[%d]",c->crtc, j);
+		fprintf(stdout, "CRTC(%u):[%d]",c->crtc, j);
 		kmstest_dump_mode(&c->mode);
 		if (drmModeSetCrtc(drm_fd, c->crtc, fb_id, 0, 0,
 				   &c->id, 1, &c->mode)) {
-- 
1.8.3.1

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

* [PATCH i-g-t 09/12] testdisplay: Untangle dump_info() from the main testing loop
  2013-09-06 19:08 [i-g-t] Stereo 3D Damien Lespiau
                   ` (7 preceding siblings ...)
  2013-09-06 19:08 ` [PATCH i-g-t 08/12] testdisplay: Fix CRTS typo Damien Lespiau
@ 2013-09-06 19:08 ` Damien Lespiau
  2013-09-06 19:08 ` [PATCH i-g-t 10/12] testdisplay: Free the array of connectors Damien Lespiau
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Damien Lespiau @ 2013-09-06 19:08 UTC (permalink / raw
  To: intel-gfx

-i is just supposed to show some information about the DRM resources.
Right now it works in a quite convoluted way. Untangle this to call
dump_info() when -i is given, exit the program and be done with it.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 tests/testdisplay.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index f94e5c4..3a9eab7 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -53,6 +53,7 @@
 #include <errno.h>
 #include <math.h>
 #include <stdint.h>
+#include <stdbool.h>
 #include <unistd.h>
 #include <sys/poll.h>
 #include <sys/time.h>
@@ -67,8 +68,8 @@
 
 drmModeRes *resources;
 int drm_fd, modes;
-int dump_info = 0, test_all_modes =0, test_preferred_mode = 0, force_mode = 0,
-	test_plane, enable_tiling;
+int test_all_modes = 0, test_preferred_mode = 0, force_mode = 0, test_plane,
+    enable_tiling;
 int sleep_between_modes = 5;
 uint32_t depth = 24, stride, bpp;
 int qr_code = 0;
@@ -181,6 +182,12 @@ static void dump_crtcs_fd(int drmfd)
 	drmModeFreeResources(mode_resources);
 }
 
+static void dump_info(void)
+{
+	dump_connectors_fd(drm_fd);
+	dump_crtcs_fd(drm_fd);
+}
+
 static void connector_find_preferred_mode(uint32_t connector_id,
 					  unsigned long crtc_idx_mask,
 					  int mode_num, struct connector *c)
@@ -423,11 +430,6 @@ int update_display(void)
 	if (!connectors)
 		return 0;
 
-	if (dump_info) {
-		dump_connectors_fd(drm_fd);
-		dump_crtcs_fd(drm_fd);
-	}
-
 	if (test_preferred_mode || test_all_modes || force_mode || specified_disp_id != -1) {
 		unsigned long crtc_idx_mask = -1UL;
 
@@ -523,6 +525,7 @@ int main(int argc, char **argv)
 	GIOChannel *stdinchannel;
 	GMainLoop *mainloop;
 	float force_clock;
+	bool opt_dump_info = false;
 
 	igt_skip_on_simulation();
 
@@ -532,7 +535,7 @@ int main(int argc, char **argv)
 	while ((c = getopt(argc, argv, optstr)) != -1) {
 		switch (c) {
 		case 'i':
-			dump_info = 1;
+			opt_dump_info = true;
 			break;
 		case 'a':
 			test_all_modes = 1;
@@ -588,12 +591,17 @@ int main(int argc, char **argv)
 	else if (depth <= 32)
 		bpp = 32;
 
-	if (!test_all_modes && !force_mode && !dump_info &&
-	    !test_preferred_mode && specified_mode_num == -1)
+	if (!test_all_modes && !force_mode && !test_preferred_mode &&
+	    specified_mode_num == -1)
 		test_all_modes = 1;
 
 	drm_fd = drm_open_any();
 
+	if (opt_dump_info) {
+		dump_info();
+		goto out_close;
+	}
+
 	do_or_die(igt_set_vt_graphics_mode());
 
 	mainloop = g_main_loop_new(NULL, FALSE);
@@ -628,7 +636,7 @@ int main(int argc, char **argv)
 		goto out_stdio;
 	}
 
-	if (dump_info || test_all_modes)
+	if (test_all_modes)
 		goto out_stdio;
 
 	g_main_loop_run(mainloop);
-- 
1.8.3.1

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

* [PATCH i-g-t 10/12] testdisplay: Free the array of connectors
  2013-09-06 19:08 [i-g-t] Stereo 3D Damien Lespiau
                   ` (8 preceding siblings ...)
  2013-09-06 19:08 ` [PATCH i-g-t 09/12] testdisplay: Untangle dump_info() from the main testing loop Damien Lespiau
@ 2013-09-06 19:08 ` Damien Lespiau
  2013-09-06 19:08 ` [PATCH i-g-t 11/12] testdisplay: Provide a full path when opening pngs Damien Lespiau
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Damien Lespiau @ 2013-09-06 19:08 UTC (permalink / raw
  To: intel-gfx

That's an array we allocated earlier in this function. Let's be symetric
and free it once done.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 tests/testdisplay.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index 3a9eab7..00d777a 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -457,6 +457,8 @@ int update_display(void)
 
 		}
 	}
+
+	free(connectors);
 	drmModeFreeResources(resources);
 	return 1;
 }
-- 
1.8.3.1

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

* [PATCH i-g-t 11/12] testdisplay: Provide a full path when opening pngs
  2013-09-06 19:08 [i-g-t] Stereo 3D Damien Lespiau
                   ` (9 preceding siblings ...)
  2013-09-06 19:08 ` [PATCH i-g-t 10/12] testdisplay: Free the array of connectors Damien Lespiau
@ 2013-09-06 19:08 ` Damien Lespiau
  2013-09-06 19:08 ` [PATCH i-g-t 12/12] testdisplay: Test the stereo 3D modes Damien Lespiau
  2013-09-30 17:09 ` [i-g-t] Stereo 3D Damien Lespiau
  12 siblings, 0 replies; 14+ messages in thread
From: Damien Lespiau @ 2013-09-06 19:08 UTC (permalink / raw
  To: intel-gfx

This way one doesn't have to be in tests/ for testsdisplay to be able to
open pass.png.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 tests/Makefile.am   | 5 ++++-
 tests/testdisplay.c | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index dd63bda..2d10f72 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -187,7 +187,10 @@ CLEANFILES = $(EXTRA_PROGRAMS)
 
 AM_CFLAGS = $(DRM_CFLAGS) $(CWARNFLAGS) \
 	-I$(srcdir)/.. \
-	-I$(srcdir)/../lib
+	-I$(srcdir)/../lib \
+	-DIGT_DATADIR=\""$(abs_srcdir)"\" \
+	$(NULL)
+
 LDADD = ../lib/libintel_tools.la $(PCIACCESS_LIBS) $(DRM_LIBS) 
 
 testdisplay_SOURCES = \
diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index 00d777a..df3b4d4 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -319,7 +319,7 @@ static void paint_output_info(struct connector *c, struct kmstest_fb *fb)
 	}
 
 	if (qr_code)
-		paint_image(cr, "./pass.png");
+		paint_image(cr, IGT_DATADIR"/pass.png");
 
 	igt_assert(!cairo_status(cr));
 }
-- 
1.8.3.1

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

* [PATCH i-g-t 12/12] testdisplay: Test the stereo 3D modes
  2013-09-06 19:08 [i-g-t] Stereo 3D Damien Lespiau
                   ` (10 preceding siblings ...)
  2013-09-06 19:08 ` [PATCH i-g-t 11/12] testdisplay: Provide a full path when opening pngs Damien Lespiau
@ 2013-09-06 19:08 ` Damien Lespiau
  2013-09-30 17:09 ` [i-g-t] Stereo 3D Damien Lespiau
  12 siblings, 0 replies; 14+ messages in thread
From: Damien Lespiau @ 2013-09-06 19:08 UTC (permalink / raw
  To: intel-gfx

Now that modes have flags to describe which 3d formats the sink
supports, it's time to test them.

The new test cycles through the supported 3D formats and paint 3D
stereoscopic images taken from publicly available samples:
  http://www.quantumdata.com/apps/3D/sample_BMP.asp

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 tests/testdisplay.c | 255 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 252 insertions(+), 3 deletions(-)

diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index df3b4d4..a8b39fe 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -54,10 +54,13 @@
 #include <math.h>
 #include <stdint.h>
 #include <stdbool.h>
+#include <strings.h>
 #include <unistd.h>
 #include <sys/poll.h>
 #include <sys/time.h>
 #include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 
 #include "i915_drm.h"
 #include "drmtest.h"
@@ -69,7 +72,7 @@
 drmModeRes *resources;
 int drm_fd, modes;
 int test_all_modes = 0, test_preferred_mode = 0, force_mode = 0, test_plane,
-    enable_tiling;
+    test_3d_modes, enable_tiling;
 int sleep_between_modes = 5;
 uint32_t depth = 24, stride, bpp;
 int qr_code = 0;
@@ -362,6 +365,9 @@ set_mode(struct connector *c)
 		if (test_all_modes)
 			c->mode = c->connector->modes[j];
 
+		/* set_mode() only tests 2D modes */
+		c->mode.flags &= ~DRMTEST_MODE_FLAG_3D_MASK;
+
 		if (!c->mode_valid)
 			continue;
 
@@ -404,6 +410,223 @@ set_mode(struct connector *c)
 	drmModeFreeConnector(c->connector);
 }
 
+static void adjust_3d_timings(drmModeModeInfo *mode, unsigned int format)
+{
+	uint16_t vdisplay, vactive_space;
+
+	/* just set the 3D format we are setting (this is not used by the
+	 * kernel, it's just for kmstest_dump_mode()) */
+	mode->flags &= ~DRMTEST_MODE_FLAG_3D_MASK;
+	mode->flags |= format;
+
+	switch (format) {
+	case DRM_MODE_FLAG_3D_TOP_AND_BOTTOM:
+	case DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF:
+		return;
+	case DRM_MODE_FLAG_3D_FRAME_PACKING:
+		vactive_space = mode->vtotal - mode->vdisplay;
+		vdisplay = mode->vdisplay;
+
+		mode->vdisplay += vdisplay + vactive_space;
+		mode->vsync_start += vdisplay + vactive_space;
+		mode->vsync_end += vdisplay + vactive_space;
+		mode->vtotal += vdisplay + vactive_space;
+		mode->clock = (mode->vtotal * mode->htotal * mode->vrefresh) /
+			      1000;
+		return;
+	default:
+		assert(0);
+	}
+}
+
+struct box {
+	int x, y, width, height;
+};
+
+struct s3d_fb_layout {
+	int fb_width, fb_height;
+	struct box left, right;
+};
+
+static void box_init(struct box *box, int x, int y, int bwidth, int bheight)
+{
+	box->x = x;
+	box->y = y;
+	box->width = bwidth;
+	box->height = bheight;
+}
+
+static void box_print(const char * prefix, struct box *box)
+{
+	printf("%s: %d, %d, %d, %d\n", prefix,
+			box->x, box->y, box->width, box->height);
+}
+
+static void s3d_fb_layout_from_mode(struct s3d_fb_layout *layout,
+				    drmModeModeInfo *mode)
+{
+	unsigned int format = mode->flags & DRMTEST_MODE_FLAG_3D_MASK;
+	const int hdisplay = mode->hdisplay, vdisplay = mode->vdisplay;
+	int middle;
+
+	switch (format) {
+	case DRM_MODE_FLAG_3D_TOP_AND_BOTTOM:
+		layout->fb_width = hdisplay;
+		layout->fb_height = vdisplay;
+
+		middle = vdisplay / 2;
+		box_init(&layout->left, 0, 0, hdisplay, middle);
+		box_init(&layout->right,
+			 0, middle, hdisplay, vdisplay - middle);
+		break;
+	case DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF:
+		layout->fb_width = hdisplay;
+		layout->fb_height = vdisplay;
+
+		middle = hdisplay / 2;
+		box_init(&layout->left, 0, 0, middle, vdisplay);
+		box_init(&layout->right,
+			 middle, 0, hdisplay - middle, vdisplay);
+		break;
+	case DRM_MODE_FLAG_3D_FRAME_PACKING:
+	{
+		int vactive_space = mode->vtotal - vdisplay;
+
+		layout->fb_width = hdisplay;
+		layout->fb_height = 2 * vdisplay + vactive_space;
+
+		box_init(&layout->left,
+			 0, 0, hdisplay, vdisplay);
+		box_init(&layout->right,
+			 0, vdisplay + vactive_space, hdisplay, vdisplay);
+		break;
+	}
+	default:
+		assert(0);
+	}
+}
+
+static const char *s3d_mode_str(unsigned format)
+{
+	switch (format) {
+	case DRM_MODE_FLAG_3D_TOP_AND_BOTTOM:
+		return "TB";
+	case DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF:
+		return "SbSH";
+	case DRM_MODE_FLAG_3D_FRAME_PACKING:
+		return "FP";
+	default:
+		assert(0);
+	}
+}
+
+static uint32_t create_s3d_fb(drmModeModeInfo *mode, struct kmstest_fb *fb)
+{
+	struct s3d_fb_layout layout;
+	cairo_t *cr;
+	uint32_t fb_id;
+
+	s3d_fb_layout_from_mode(&layout, mode);
+	box_print("left: ", &layout.left);
+	box_print("right: ", &layout.right);
+	fb_id = kmstest_create_fb(drm_fd, layout.fb_width, layout.fb_height,
+				  bpp, depth, enable_tiling, fb);
+	cr = kmstest_get_cairo_ctx(drm_fd, fb);
+
+	kmstest_paint_image(cr, IGT_DATADIR"/1080p-left.png",
+			    layout.left.x, layout.left.y,
+			    layout.left.width, layout.left.height);
+	kmstest_paint_image(cr, IGT_DATADIR"/1080p-right.png",
+			    layout.right.x, layout.right.y,
+			    layout.right.width, layout.right.height);
+
+#if 0 /* Comment this out if you want to see what the composited fb looks
+	 like */
+	{
+		char buffer[64];
+
+		snprintf(buffer, sizeof(buffer), "%dx%d@%dHz-%s.png",
+			 mode->hdisplay,
+			 mode->vdisplay,
+			 mode->vrefresh,
+			 s3d_mode_str(mode->flags & DRMTEST_MODE_FLAG_3D_MASK));
+
+		kmstest_write_fb(drm_fd, fb, buffer);
+	}
+#endif
+
+	return fb_id;
+}
+
+static void do_set_3d_format(struct connector *c, unsigned int format)
+{
+	uint32_t fb_id;
+	struct kmstest_fb fb_info;
+
+	fb_id = create_s3d_fb(&c->mode, &fb_info);
+	adjust_3d_timings(&c->mode, format);
+
+	if (drmModeSetCrtc(drm_fd, c->crtc, fb_id, 0, 0,
+			   &c->id, 1, &c->mode)) {
+		fprintf(stderr, "failed to set mode (%dx%d@%dHz): %s\n",
+			width, height, c->mode.vrefresh,
+			strerror(errno));
+	}
+}
+
+static void
+set_3d_mode(struct connector *c)
+{
+	int i;
+
+	for (i = 0; i < c->connector->count_modes; i++) {
+		unsigned int s3d_formats, format;
+
+		c->mode = c->connector->modes[i];
+
+		if (!c->mode_valid)
+			continue;
+
+		s3d_formats = c->mode.flags & DRMTEST_MODE_FLAG_3D_MASK;
+		if (!s3d_formats)
+			continue;
+
+		do {
+			format = 1 << (ffs(s3d_formats) - 1);
+
+			/*
+			 * Modify the mode flags to specify which 3D format is
+			 * being set.
+			 *
+			 * XXX: One would need to also clear the upper bits of
+			 * flags in case extra modes/flags are added
+			 */
+			c->mode.flags &= ~DRMTEST_MODE_FLAG_3D_MASK;
+			c->mode.flags |= format;
+
+			do_set_3d_format(c, format);
+
+			/*
+			 * The mode may have been adjusted for this format,
+			 * reset it to its origin timings
+			 */
+			c->mode = c->connector->modes[i];
+
+			if (qr_code){
+				set_single();
+				pause();
+			} else if (sleep_between_modes)
+				sleep(sleep_between_modes);
+
+			s3d_formats &= ~format;
+		} while (s3d_formats);
+
+	}
+
+	drmModeFreeEncoder(c->encoder);
+	drmModeFreeConnector(c->connector);
+}
+
 /*
  * Re-probe outputs and light up as many as possible.
  *
@@ -458,12 +681,29 @@ int update_display(void)
 		}
 	}
 
+	if (test_3d_modes) {
+		for (c = 0; c < resources->count_connectors; c++) {
+			struct connector *connector = &connectors[c];
+
+			connector->id = resources->connectors[c];
+
+			connector_find_preferred_mode(connector->id,
+						      -1UL,
+						      specified_mode_num,
+						      connector);
+			if (!connector->mode_valid)
+				continue;
+
+			set_3d_mode(connector);
+		}
+	}
+
 	free(connectors);
 	drmModeFreeResources(resources);
 	return 1;
 }
 
-static char optstr[] = "hiaf:s:d:p:mrto:";
+static char optstr[] = "3hiaf:s:d:p:mrto:";
 
 static void __attribute__((noreturn)) usage(char *name)
 {
@@ -474,6 +714,7 @@ static void __attribute__((noreturn)) usage(char *name)
 	fprintf(stderr, "\t-d\t<depth>\tbit depth of scanout buffer\n");
 	fprintf(stderr, "\t-p\t<planew,h>,<crtcx,y>,<crtcw,h> test overlay plane\n");
 	fprintf(stderr, "\t-m\ttest the preferred mode\n");
+	fprintf(stderr, "\t-3\ttest all 3D modes\n");
 	fprintf(stderr, "\t-t\tuse a tiled framebuffer\n");
 	fprintf(stderr, "\t-r\tprint a QR code on the screen whose content is \"pass\" for the automatic test\n");
 	fprintf(stderr, "\t-o\t<id of the display>,<number of the mode>\tonly test specified mode on the specified display\n");
@@ -536,6 +777,9 @@ int main(int argc, char **argv)
 	opterr = 0;
 	while ((c = getopt(argc, argv, optstr)) != -1) {
 		switch (c) {
+		case '3':
+			test_3d_modes = 1;
+			break;
 		case 'i':
 			opt_dump_info = true;
 			break;
@@ -594,11 +838,16 @@ int main(int argc, char **argv)
 		bpp = 32;
 
 	if (!test_all_modes && !force_mode && !test_preferred_mode &&
-	    specified_mode_num == -1)
+	    specified_mode_num == -1 && !test_3d_modes)
 		test_all_modes = 1;
 
 	drm_fd = drm_open_any();
 
+	if (test_3d_modes && drmSetCap(drm_fd, DRM_CAP_STEREO_3D, 1) < 0) {
+		fprintf(stderr, "DRM_CAP_STEREO_3D isn't supported\n");
+		goto out_close;
+	}
+
 	if (opt_dump_info) {
 		dump_info();
 		goto out_close;
-- 
1.8.3.1

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

* Re: [i-g-t] Stereo 3D
  2013-09-06 19:08 [i-g-t] Stereo 3D Damien Lespiau
                   ` (11 preceding siblings ...)
  2013-09-06 19:08 ` [PATCH i-g-t 12/12] testdisplay: Test the stereo 3D modes Damien Lespiau
@ 2013-09-30 17:09 ` Damien Lespiau
  12 siblings, 0 replies; 14+ messages in thread
From: Damien Lespiau @ 2013-09-30 17:09 UTC (permalink / raw
  To: intel-gfx

On Fri, Sep 06, 2013 at 08:08:38PM +0100, Damien Lespiau wrote:
> This series makes testdisplay able to display top and bottom, side by side half
> and frame packing stereo framebuffers. The final fb is composited from separate
> left and right images using cairo.

Pushed an up-to-date and cleaned-up series to i-g-t now that the kernel
patches are in drm-intel.

-- 
Damien

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

end of thread, other threads:[~2013-09-30 17:09 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-06 19:08 [i-g-t] Stereo 3D Damien Lespiau
2013-09-06 19:08 ` [PATCH i-g-t 01/12] lib: Dump information about the supported 3D stereo formats Damien Lespiau
2013-09-06 19:08 ` [PATCH i-g-t 02/12] lib: Add a helper to paint a PNG using cairo Damien Lespiau
2013-09-06 19:08 ` [PATCH i-g-t 03/12] lib: Split create_image_surface() out of create_cairo_ctx() Damien Lespiau
2013-09-06 19:08 ` [PATCH i-g-t 04/12] lib: Add a helper to write a png from a struct kmstest_fb Damien Lespiau
2013-09-06 19:08 ` [PATCH i-g-t 05/12] testdisplay: Move the code sanitizing depth into main() Damien Lespiau
2013-09-06 19:08 ` [PATCH i-g-t 06/12] testdisplay: Map the fb inside paint_color_key() Damien Lespiau
2013-09-06 19:08 ` [PATCH i-g-t 07/12] testdisplay: Properly handle the life cycle of framebuffers Damien Lespiau
2013-09-06 19:08 ` [PATCH i-g-t 08/12] testdisplay: Fix CRTS typo Damien Lespiau
2013-09-06 19:08 ` [PATCH i-g-t 09/12] testdisplay: Untangle dump_info() from the main testing loop Damien Lespiau
2013-09-06 19:08 ` [PATCH i-g-t 10/12] testdisplay: Free the array of connectors Damien Lespiau
2013-09-06 19:08 ` [PATCH i-g-t 11/12] testdisplay: Provide a full path when opening pngs Damien Lespiau
2013-09-06 19:08 ` [PATCH i-g-t 12/12] testdisplay: Test the stereo 3D modes Damien Lespiau
2013-09-30 17:09 ` [i-g-t] Stereo 3D Damien Lespiau

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.