All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] libdrm: modetest: Allow selecting modes by index
@ 2019-06-24 20:27 John Stultz
  2019-06-24 20:32 ` Ilia Mirkin
  0 siblings, 1 reply; 3+ messages in thread
From: John Stultz @ 2019-06-24 20:27 UTC (permalink / raw)
  To: dri-devel; +Cc: Rob Clark, Bjorn Andersson

Often there are many similar modes, which cannot be selected
via modetest due to its simple string matching.

This change adds a mode index in the display output, which can
then be used to specify a specific modeline to be set.

Cc: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: Rob Clark <robdclark@chromium.org>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
v2: Reworked mode_str check per Ilia's suggestion
---
 tests/modetest/modetest.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index 9c85c07b..5a04190c 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -204,9 +204,10 @@ static void dump_encoders(struct device *dev)
 	printf("\n");
 }
 
-static void dump_mode(drmModeModeInfo *mode)
+static void dump_mode(drmModeModeInfo *mode, int index)
 {
-	printf("  %s %d %d %d %d %d %d %d %d %d %d",
+	printf("  #%i %s %d %d %d %d %d %d %d %d %d %d",
+	       index,
 	       mode->name,
 	       mode->vrefresh,
 	       mode->hdisplay,
@@ -443,10 +444,10 @@ static void dump_connectors(struct device *dev)
 
 		if (connector->count_modes) {
 			printf("  modes:\n");
-			printf("\tname refresh (Hz) hdisp hss hse htot vdisp "
+			printf("\tindex name refresh (Hz) hdisp hss hse htot vdisp "
 			       "vss vse vtot)\n");
 			for (j = 0; j < connector->count_modes; j++)
-				dump_mode(&connector->modes[j]);
+				dump_mode(&connector->modes[j], j);
 		}
 
 		if (_connector->props) {
@@ -478,7 +479,7 @@ static void dump_crtcs(struct device *dev)
 		       crtc->buffer_id,
 		       crtc->x, crtc->y,
 		       crtc->width, crtc->height);
-		dump_mode(&crtc->mode);
+		dump_mode(&crtc->mode, 0);
 
 		if (_crtc->props) {
 			printf("  props:\n");
@@ -829,6 +830,16 @@ connector_find_mode(struct device *dev, uint32_t con_id, const char *mode_str,
 	if (!connector || !connector->count_modes)
 		return NULL;
 
+	/* Pick by Index */
+	if (mode_str[0] == '#') {
+		int index = atoi(mode_str + 1);
+
+		if (index >= connector->count_modes)
+			return NULL;
+		return &connector->modes[index];
+	}
+
+	/* Pick by Name */
 	for (i = 0; i < connector->count_modes; i++) {
 		mode = &connector->modes[i];
 		if (!strcmp(mode->name, mode_str)) {
@@ -1752,7 +1763,7 @@ static void usage(char *name)
 
 	fprintf(stderr, "\n Test options:\n\n");
 	fprintf(stderr, "\t-P <plane_id>@<crtc_id>:<w>x<h>[+<x>+<y>][*<scale>][@<format>]\tset a plane\n");
-	fprintf(stderr, "\t-s <connector_id>[,<connector_id>][@<crtc_id>]:<mode>[-<vrefresh>][@<format>]\tset a mode\n");
+	fprintf(stderr, "\t-s <connector_id>[,<connector_id>][@<crtc_id>]:[#<mode index>]<mode>[-<vrefresh>][@<format>]\tset a mode\n");
 	fprintf(stderr, "\t-C\ttest hw cursor\n");
 	fprintf(stderr, "\t-v\ttest vsynced page flipping\n");
 	fprintf(stderr, "\t-w <obj_id>:<prop_name>:<value>\tset property\n");
-- 
2.17.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH v2] libdrm: modetest: Allow selecting modes by index
  2019-06-24 20:27 [PATCH v2] libdrm: modetest: Allow selecting modes by index John Stultz
@ 2019-06-24 20:32 ` Ilia Mirkin
  2019-06-24 21:28   ` John Stultz
  0 siblings, 1 reply; 3+ messages in thread
From: Ilia Mirkin @ 2019-06-24 20:32 UTC (permalink / raw)
  To: John Stultz; +Cc: Rob Clark, dri-devel, Bjorn Andersson

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>

One minor comment below though:

(Maybe let it sit on the list for a day in case anyone feels like
objecting strenuously.)

On Mon, Jun 24, 2019 at 4:27 PM John Stultz <john.stultz@linaro.org> wrote:
>
> Often there are many similar modes, which cannot be selected
> via modetest due to its simple string matching.
>
> This change adds a mode index in the display output, which can
> then be used to specify a specific modeline to be set.
>
> Cc: Ilia Mirkin <imirkin@alum.mit.edu>
> Cc: Rob Clark <robdclark@chromium.org>
> Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
> Cc: Sumit Semwal <sumit.semwal@linaro.org>
> Signed-off-by: John Stultz <john.stultz@linaro.org>
> ---
> v2: Reworked mode_str check per Ilia's suggestion
> ---
>  tests/modetest/modetest.c | 23 +++++++++++++++++------
>  1 file changed, 17 insertions(+), 6 deletions(-)
>
> diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
> index 9c85c07b..5a04190c 100644
> --- a/tests/modetest/modetest.c
> +++ b/tests/modetest/modetest.c
> @@ -204,9 +204,10 @@ static void dump_encoders(struct device *dev)
>         printf("\n");
>  }
>
> -static void dump_mode(drmModeModeInfo *mode)
> +static void dump_mode(drmModeModeInfo *mode, int index)
>  {
> -       printf("  %s %d %d %d %d %d %d %d %d %d %d",
> +       printf("  #%i %s %d %d %d %d %d %d %d %d %d %d",
> +              index,
>                mode->name,
>                mode->vrefresh,
>                mode->hdisplay,
> @@ -443,10 +444,10 @@ static void dump_connectors(struct device *dev)
>
>                 if (connector->count_modes) {
>                         printf("  modes:\n");
> -                       printf("\tname refresh (Hz) hdisp hss hse htot vdisp "
> +                       printf("\tindex name refresh (Hz) hdisp hss hse htot vdisp "
>                                "vss vse vtot)\n");
>                         for (j = 0; j < connector->count_modes; j++)
> -                               dump_mode(&connector->modes[j]);
> +                               dump_mode(&connector->modes[j], j);
>                 }
>
>                 if (_connector->props) {
> @@ -478,7 +479,7 @@ static void dump_crtcs(struct device *dev)
>                        crtc->buffer_id,
>                        crtc->x, crtc->y,
>                        crtc->width, crtc->height);
> -               dump_mode(&crtc->mode);
> +               dump_mode(&crtc->mode, 0);
>
>                 if (_crtc->props) {
>                         printf("  props:\n");
> @@ -829,6 +830,16 @@ connector_find_mode(struct device *dev, uint32_t con_id, const char *mode_str,
>         if (!connector || !connector->count_modes)
>                 return NULL;
>
> +       /* Pick by Index */
> +       if (mode_str[0] == '#') {
> +               int index = atoi(mode_str + 1);
> +
> +               if (index >= connector->count_modes)

|| index < 0

or maybe just make it unsigned. Either way.

> +                       return NULL;
> +               return &connector->modes[index];
> +       }
> +
> +       /* Pick by Name */
>         for (i = 0; i < connector->count_modes; i++) {
>                 mode = &connector->modes[i];
>                 if (!strcmp(mode->name, mode_str)) {
> @@ -1752,7 +1763,7 @@ static void usage(char *name)
>
>         fprintf(stderr, "\n Test options:\n\n");
>         fprintf(stderr, "\t-P <plane_id>@<crtc_id>:<w>x<h>[+<x>+<y>][*<scale>][@<format>]\tset a plane\n");
> -       fprintf(stderr, "\t-s <connector_id>[,<connector_id>][@<crtc_id>]:<mode>[-<vrefresh>][@<format>]\tset a mode\n");
> +       fprintf(stderr, "\t-s <connector_id>[,<connector_id>][@<crtc_id>]:[#<mode index>]<mode>[-<vrefresh>][@<format>]\tset a mode\n");
>         fprintf(stderr, "\t-C\ttest hw cursor\n");
>         fprintf(stderr, "\t-v\ttest vsynced page flipping\n");
>         fprintf(stderr, "\t-w <obj_id>:<prop_name>:<value>\tset property\n");
> --
> 2.17.1
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH v2] libdrm: modetest: Allow selecting modes by index
  2019-06-24 20:32 ` Ilia Mirkin
@ 2019-06-24 21:28   ` John Stultz
  0 siblings, 0 replies; 3+ messages in thread
From: John Stultz @ 2019-06-24 21:28 UTC (permalink / raw)
  To: Ilia Mirkin; +Cc: Rob Clark, dri-devel, Bjorn Andersson

On Mon, Jun 24, 2019 at 1:32 PM Ilia Mirkin <imirkin@alum.mit.edu> wrote:
>
> Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
>
> One minor comment below though:
>
> (Maybe let it sit on the list for a day in case anyone feels like
> objecting strenuously.)

Thanks so much for the review!

> > @@ -829,6 +830,16 @@ connector_find_mode(struct device *dev, uint32_t con_id, const char *mode_str,
> >         if (!connector || !connector->count_modes)
> >                 return NULL;
> >
> > +       /* Pick by Index */
> > +       if (mode_str[0] == '#') {
> > +               int index = atoi(mode_str + 1);
> > +
> > +               if (index >= connector->count_modes)
>
> || index < 0

Ok, added this bit in my tree. I'll resubmit in a few days to let
others have a chance to review as well.

thanks
-john
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2019-06-24 21:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-24 20:27 [PATCH v2] libdrm: modetest: Allow selecting modes by index John Stultz
2019-06-24 20:32 ` Ilia Mirkin
2019-06-24 21:28   ` John Stultz

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.