[Intel-gfx] [PATCH] test/testdisplay:add cursor test

Hai Lan hai.lan at intel.com
Sun Oct 23 04:03:05 CEST 2011


Signed-off-by: Hai Lan <hai.lan at intel.com>
---
 tests/testdisplay.c |   32 +++++++++++++++++++++++++-------
 1 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index 01f31dc..174d5c7 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -75,7 +75,7 @@ struct udev_monitor *uevent_monitor;
 drmModeRes *resources;
 int fd, modes;
 int dump_info = 0, test_all_modes =0, test_preferred_mode = 0, force_mode = 0,
-	test_plane, enable_tiling;
+	test_plane, enable_tiling, test_cursor;
 int sleep_between_modes = 5;
 uint32_t depth = 24;
 
@@ -823,7 +823,7 @@ set_mode(struct connector *c)
 		cairo_surface_t *surface;
 		cairo_status_t status;
 		cairo_t *cr;
-		uint32_t handle;
+		uint32_t handle,cursor_handle;
 
 		if (test_all_modes)
 			c->mode = c->connector->modes[j];
@@ -872,7 +872,6 @@ set_mode(struct connector *c)
 				   handle, &fb_id);
 		cairo_surface_destroy(surface);
 		gem_close(fd, handle);
-
 		if (ret) {
 			fprintf(stderr, "failed to add fb (%dx%d): %s\n",
 				width, height, strerror(errno));
@@ -888,6 +887,21 @@ set_mode(struct connector *c)
 			continue;
 		}
 
+		if (test_cursor) {
+			cursor_handle = gem_create(fd,64*64*4);
+			char * cursor_buff = gem_mmap(fd, cursor_handle, 64*64*4, PROT_READ | PROT_WRITE);
+			for(int i=0;i<64*64*4;i++)
+				*(cursor_buff+i)=0xff;
+
+			drmModeSetCursor(fd,c->crtc,cursor_handle,64,64);
+			for(int i=0;i<10;i++) {
+				drmModeMoveCursor(fd,c->crtc,i*100, 0);
+				sleep(1);
+			}
+			drmModeSetCursor(fd,c->crtc,0,64,64);
+			gem_close(fd, cursor_handle);
+		}
+
 		if (test_plane)
 			enable_plane(c);
 
@@ -931,7 +945,7 @@ static int update_display(void)
 		dump_planes();
 	}
 
-	if (test_preferred_mode || test_all_modes || force_mode) {
+	if (test_preferred_mode || test_all_modes || force_mode || test_cursor) {
 		/* Find any connected displays */
 		for (c = 0; c < resources->count_connectors; c++) {
 			connectors[c].id = resources->connectors[c];
@@ -944,11 +958,11 @@ static int update_display(void)
 
 extern char *optarg;
 extern int optind, opterr, optopt;
-static char optstr[] = "hiaf:s:d:pmt";
+static char optstr[] = "hiaf:s:d:pmtc";
 
 static void usage(char *name)
 {
-	fprintf(stderr, "usage: %s [-hiafs]\n", name);
+	fprintf(stderr, "usage: %s [-hiaf:s:d:pmtc]\n", name);
 	fprintf(stderr, "\t-i\tdump info\n");
 	fprintf(stderr, "\t-a\ttest all modes\n");
 	fprintf(stderr, "\t-s\t<duration>\tsleep between each mode test\n");
@@ -959,6 +973,7 @@ static void usage(char *name)
 	fprintf(stderr, "\t-f\t<clock MHz>,<hdisp>,<hsync-start>,<hsync-end>,<htotal>,\n");
 	fprintf(stderr, "\t\t<vdisp>,<vsync-start>,<vsync-end>,<vtotal>\n");
 	fprintf(stderr, "\t\ttest force mode\n");
+	fprintf(stderr, "\t-c\ttest cursor\n");
 	fprintf(stderr, "\tDefault is to test all modes.\n");
 	exit(0);
 }
@@ -1048,6 +1063,9 @@ int main(int argc, char **argv)
 		case 't':
 			enable_tiling = 1;
 			break;
+		case 'c':
+			test_cursor = 1;
+			break;
 		default:
 			fprintf(stderr, "unknown option %c\n", c);
 			/* fall through */
@@ -1057,7 +1075,7 @@ int main(int argc, char **argv)
 		}
 	}
 	if (!test_all_modes && !force_mode && !dump_info &&
-	    !test_preferred_mode)
+	    !test_preferred_mode && !test_cursor)
 		test_all_modes = 1;
 
 	for (i = 0; i < ARRAY_SIZE(modules); i++) {
-- 
1.7.0.1




More information about the Intel-gfx mailing list