Skip to contentSkip to conversation

modetest: add a -D option to specify a device to be used

PATCH In review Ilia Mirkin 3 participants 5 messages Sep 8, 2013 – Sep 10, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 modetest: add a -D option to specify a device to be used

This is helpful for differentiating between multiple devices that use the same module.

---
 tests/modetest/modetest.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
tests/modetest/modetest.c +10 -4
index f0ed56b..9d6e279 100644
@@ -1303,7 +1303,7 @@ static int parse_property(struct property_arg *p, const char *arg)
 
 static void usage(char *name)
 {
-	fprintf(stderr, "usage: %s [-cdefMmPpsvw]\n", name);
+	fprintf(stderr, "usage: %s [-cDdefMPpsvw]\n", name);
 
 	fprintf(stderr, "\n Query options:\n\n");
 	fprintf(stderr, "\t-c\tlist connectors\n");
@@ -1320,6 +1320,7 @@ static void usage(char *name)
 	fprintf(stderr, "\n Generic options:\n\n");
 	fprintf(stderr, "\t-d\tdrop master after mode set\n");
 	fprintf(stderr, "\t-M module\tuse the given driver\n");
+	fprintf(stderr, "\t-D device\tuse the given device\n");
 
 	fprintf(stderr, "\n\tDefault is to dump all info.\n");
 	exit(0);
@@ -1346,7 +1347,7 @@ static int page_flipping_supported(void)
 #endif
 }
 
-static char optstr[] = "cdefM:P:ps:vw:";
+static char optstr[] = "cdD:efM:P:ps:vw:";
 
 int main(int argc, char **argv)
 {
@@ -1357,6 +1358,7 @@ int main(int argc, char **argv)
 	int drop_master = 0;
 	int test_vsync = 0;
 	const char *modules[] = { "i915", "radeon", "nouveau", "vmwgfx", "omapdrm", "exynos", "tilcdc", "msm" };
+	char *device = NULL;
 	char *module = NULL;
 	unsigned int i;
 	int count = 0, plane_count = 0;
@@ -1377,6 +1379,10 @@ int main(int argc, char **argv)
 		case 'c':
 			connectors = 1;
 			break;
+		case 'D':
+			device = optarg;
+			args--;
+			break;
 		case 'd':
 			drop_master = 1;
 			break;
@@ -1447,7 +1453,7 @@ int main(int argc, char **argv)
 		encoders = connectors = crtcs = planes = framebuffers = 1;
 
 	if (module) {
-		dev.fd = drmOpen(module, NULL);
+		dev.fd = drmOpen(module, device);
 		if (dev.fd < 0) {
 			fprintf(stderr, "failed to open device '%s'.\n", module);
 			return 1;
@@ -1455,7 +1461,7 @@ int main(int argc, char **argv)
 	} else {
 		for (i = 0; i < ARRAY_SIZE(modules); i++) {
 			printf("trying to open device '%s'...", modules[i]);
-			dev.fd = drmOpen(modules[i], NULL);
+			dev.fd = drmOpen(modules[i], device);
 			if (dev.fd < 0) {
 				printf("failed.\n");
 			} else {
Signature · 1 line
1.8.1.5
#1 lore raw

PATCH 2/2 modetest: allow setting a scaling factor when showing plane

---
 tests/modetest/modetest.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
tests/modetest/modetest.c +15 -5
index 9d6e279..51c4e6d 100644
@@ -707,6 +707,7 @@ struct plane_arg {
 	bool has_position;
 	int32_t x, y;
 	uint32_t w, h;
+	double scale;
 	unsigned int fb_id;
 	char format_str[5]; /* need to leave room for terminating \0 */
 	unsigned int fourcc;
@@ -988,16 +989,16 @@ static int set_plane(struct device *dev, struct plane_arg *p)
 		return -1;
 	}
 
+	crtc_w = p->w * p->scale;
+	crtc_h = p->h * p->scale;
 	if (!p->has_position) {
 		/* Default to the middle of the screen */
-		crtc_x = (crtc->mode->hdisplay - p->w) / 2;
-		crtc_y = (crtc->mode->vdisplay - p->h) / 2;
+		crtc_x = (crtc->mode->hdisplay - crtc_w) / 2;
+		crtc_y = (crtc->mode->vdisplay - crtc_h) / 2;
 	} else {
 		crtc_x = p->x;
 		crtc_y = p->y;
 	}
-	crtc_w = p->w;
-	crtc_h = p->h;
 
 	/* note src coords (last 4 args) are in Q16 format */
 	if (drmModeSetPlane(dev->fd, plane_id, crtc->crtc->crtc_id, p->fb_id,
@@ -1271,6 +1272,15 @@ static int parse_plane(struct plane_arg *plane, const char *p)
 		plane->has_position = true;
 	}
 
+	if (*end == '*') {
+		p = end + 1;
+		plane->scale = strtod(p, &end);
+		if (plane->scale <= 0.0)
+			return -EINVAL;
+	} else {
+		plane->scale = 1.0;
+	}
+
 	if (*end == '@') {
 		p = end + 1;
 		if (strlen(p) != 4)
@@ -1312,7 +1322,7 @@ static void usage(char *name)
 	fprintf(stderr, "\t-p\tlist CRTCs and planes (pipes)\n");
 
 	fprintf(stderr, "\n Test options:\n\n");
-	fprintf(stderr, "\t-P <crtc_id>:<w>x<h>[+<x>+<y>][@<format>]\tset a plane\n");
+	fprintf(stderr, "\t-P <crtc_id>:<w>x<h>[+<x>+<y>][*<scale>][@<format>]\tset a plane\n");
 	fprintf(stderr, "\t-s <connector_id>[,<connector_id>][@<crtc_id>]:<mode>[@<format>]\tset a mode\n");
 	fprintf(stderr, "\t-v\ttest vsynced page flipping\n");
 	fprintf(stderr, "\t-w <obj_id>:<prop_name>:<value>\tset property\n");
Signature · 1 line
1.8.1.5
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] modetest: allow setting a scaling factor when showing plane

Quoted 1 line · Ilia Mirkin
Quoted 69 lines
---
 tests/modetest/modetest.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
tests/modetest/modetest.c +15 -6
index 9d6e279..51c4e6d 100644
@@ -707,6 +707,7 @@ struct plane_arg {
        bool has_position;
        int32_t x, y;
        uint32_t w, h;
+       double scale;
        unsigned int fb_id;
        char format_str[5]; /* need to leave room for terminating \0 */
        unsigned int fourcc;
@@ -988,16 +989,16 @@ static int set_plane(struct device *dev, struct plane_arg *p)
                return -1;
        }
 
+       crtc_w = p->w * p->scale;
+       crtc_h = p->h * p->scale;
        if (!p->has_position) {
                /* Default to the middle of the screen */
-               crtc_x = (crtc->mode->hdisplay - p->w) / 2;
-               crtc_y = (crtc->mode->vdisplay - p->h) / 2;
+               crtc_x = (crtc->mode->hdisplay - crtc_w) / 2;
+               crtc_y = (crtc->mode->vdisplay - crtc_h) / 2;
        } else {
                crtc_x = p->x;
                crtc_y = p->y;
        }
-       crtc_w = p->w;
-       crtc_h = p->h;
 
        /* note src coords (last 4 args) are in Q16 format */
        if (drmModeSetPlane(dev->fd, plane_id, crtc->crtc->crtc_id, p->fb_id,
@@ -1271,6 +1272,15 @@ static int parse_plane(struct plane_arg *plane, const char *p)
                plane->has_position = true;
        }
 
+       if (*end == '*') {
+               p = end + 1;
+               plane->scale = strtod(p, &end);
+               if (plane->scale <= 0.0)
+                       return -EINVAL;
+       } else {
+               plane->scale = 1.0;
+       }
+
        if (*end == '@') {
                p = end + 1;
                if (strlen(p) != 4)
@@ -1312,7 +1322,7 @@ static void usage(char *name)
        fprintf(stderr, "\t-p\tlist CRTCs and planes (pipes)\n");
 
        fprintf(stderr, "\n Test options:\n\n");
-       fprintf(stderr, "\t-P <crtc_id>:<w>x<h>[+<x>+<y>][@<format>]\tset a plane\n");
+       fprintf(stderr, "\t-P <crtc_id>:<w>x<h>[+<x>+<y>][*<scale>][@<format>]\tset a plane\n");
        fprintf(stderr, "\t-s <connector_id>[,<connector_id>][@<crtc_id>]:<mode>[@<format>]\tset a mode\n");
        fprintf(stderr, "\t-v\ttest vsynced page flipping\n");
        fprintf(stderr, "\t-w <obj_id>:<prop_name>:<value>\tset property\n");
--

1.8.1.5

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw

Re: [PATCH 2/2] modetest: allow setting a scaling factor when showing plane

Quoted 4 lines · Rob Clark
Quoted 1 line · Ilia Mirkin
Reviewed-and-tested-by Ben Skeggs <[email protected]>
Quoted 74 lines
Quoted 66 lines
---
 tests/modetest/modetest.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
tests/modetest/modetest.c +15 -6
index 9d6e279..51c4e6d 100644
@@ -707,6 +707,7 @@ struct plane_arg {
        bool has_position;
        int32_t x, y;
        uint32_t w, h;
+       double scale;
        unsigned int fb_id;
        char format_str[5]; /* need to leave room for terminating \0 */
        unsigned int fourcc;
@@ -988,16 +989,16 @@ static int set_plane(struct device *dev, struct plane_arg *p)
                return -1;
        }
 
+       crtc_w = p->w * p->scale;
+       crtc_h = p->h * p->scale;
        if (!p->has_position) {
                /* Default to the middle of the screen */
-               crtc_x = (crtc->mode->hdisplay - p->w) / 2;
-               crtc_y = (crtc->mode->vdisplay - p->h) / 2;
+               crtc_x = (crtc->mode->hdisplay - crtc_w) / 2;
+               crtc_y = (crtc->mode->vdisplay - crtc_h) / 2;
        } else {
                crtc_x = p->x;
                crtc_y = p->y;
        }
-       crtc_w = p->w;
-       crtc_h = p->h;
 
        /* note src coords (last 4 args) are in Q16 format */
        if (drmModeSetPlane(dev->fd, plane_id, crtc->crtc->crtc_id, p->fb_id,
@@ -1271,6 +1272,15 @@ static int parse_plane(struct plane_arg *plane, const char *p)
                plane->has_position = true;
        }
 
+       if (*end == '*') {
+               p = end + 1;
+               plane->scale = strtod(p, &end);
+               if (plane->scale <= 0.0)
+                       return -EINVAL;
+       } else {
+               plane->scale = 1.0;
+       }
+
        if (*end == '@') {
                p = end + 1;
                if (strlen(p) != 4)
@@ -1312,7 +1322,7 @@ static void usage(char *name)
        fprintf(stderr, "\t-p\tlist CRTCs and planes (pipes)\n");
 
        fprintf(stderr, "\n Test options:\n\n");
-       fprintf(stderr, "\t-P <crtc_id>:<w>x<h>[+<x>+<y>][@<format>]\tset a plane\n");
+       fprintf(stderr, "\t-P <crtc_id>:<w>x<h>[+<x>+<y>][*<scale>][@<format>]\tset a plane\n");
        fprintf(stderr, "\t-s <connector_id>[,<connector_id>][@<crtc_id>]:<mode>[@<format>]\tset a mode\n");
        fprintf(stderr, "\t-v\ttest vsynced page flipping\n");
        fprintf(stderr, "\t-w <obj_id>:<prop_name>:<value>\tset property\n");
--

1.8.1.5

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Reviewed-by on v1 1/2
#4 lore raw
In reply to Ilia Mirkin
Quoted 4 lines · Ilia Mirkin

This is helpful for differentiating between multiple devices that use the same module.

Quoted 78 lines
---
 tests/modetest/modetest.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
tests/modetest/modetest.c +10 -5
index f0ed56b..9d6e279 100644
@@ -1303,7 +1303,7 @@ static int parse_property(struct property_arg *p, const char *arg)
 
 static void usage(char *name)
 {
-       fprintf(stderr, "usage: %s [-cdefMmPpsvw]\n", name);
+       fprintf(stderr, "usage: %s [-cDdefMPpsvw]\n", name);
 
        fprintf(stderr, "\n Query options:\n\n");
        fprintf(stderr, "\t-c\tlist connectors\n");
@@ -1320,6 +1320,7 @@ static void usage(char *name)
        fprintf(stderr, "\n Generic options:\n\n");
        fprintf(stderr, "\t-d\tdrop master after mode set\n");
        fprintf(stderr, "\t-M module\tuse the given driver\n");
+       fprintf(stderr, "\t-D device\tuse the given device\n");
 
        fprintf(stderr, "\n\tDefault is to dump all info.\n");
        exit(0);
@@ -1346,7 +1347,7 @@ static int page_flipping_supported(void)
 #endif
 }
 
-static char optstr[] = "cdefM:P:ps:vw:";
+static char optstr[] = "cdD:efM:P:ps:vw:";
 
 int main(int argc, char **argv)
 {
@@ -1357,6 +1358,7 @@ int main(int argc, char **argv)
        int drop_master = 0;
        int test_vsync = 0;
        const char *modules[] = { "i915", "radeon", "nouveau", "vmwgfx", "omapdrm", "exynos", "tilcdc", "msm" };
+       char *device = NULL;
        char *module = NULL;
        unsigned int i;
        int count = 0, plane_count = 0;
@@ -1377,6 +1379,10 @@ int main(int argc, char **argv)
                case 'c':
                        connectors = 1;
                        break;
+               case 'D':
+                       device = optarg;
+                       args--;
+                       break;
                case 'd':
                        drop_master = 1;
                        break;
@@ -1447,7 +1453,7 @@ int main(int argc, char **argv)
                encoders = connectors = crtcs = planes = framebuffers = 1;
 
        if (module) {
-               dev.fd = drmOpen(module, NULL);
+               dev.fd = drmOpen(module, device);
                if (dev.fd < 0) {
                        fprintf(stderr, "failed to open device '%s'.\n", module);
                        return 1;
@@ -1455,7 +1461,7 @@ int main(int argc, char **argv)
        } else {
                for (i = 0; i < ARRAY_SIZE(modules); i++) {
                        printf("trying to open device '%s'...", modules[i]);
-                       dev.fd = drmOpen(modules[i], NULL);
+                       dev.fd = drmOpen(modules[i], device);
                        if (dev.fd < 0) {
                                printf("failed.\n");
                        } else {
--

1.8.1.5

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel