Re: [PATCH weston] clients/weston-info: print unknown formats better
On Tue, 21 Feb 2017 10:01:45 + Eric Engestromwrote: > On Monday, 2017-02-20 15:47:57 +0200, Pekka Paalanen wrote: > > From: Pekka Paalanen > > > > Don't just dump the raw 32-bit values, try to interpret it as a DRM > > fourcc too. > > > > This prints properly the formats YUYV, NV12 and YU12 supported by > > Weston. > > > > Signed-off-by: Pekka Paalanen > > --- > > clients/weston-info.c | 29 - > > 1 file changed, 28 insertions(+), 1 deletion(-) > > > > diff --git a/clients/weston-info.c b/clients/weston-info.c > > index 712346a..ab12947 100644 > > --- a/clients/weston-info.c > > +++ b/clients/weston-info.c > > @@ -30,6 +30,8 @@ > > #include > > #include > > #include > > +#include > > +#include > > > > #include > > > > @@ -240,9 +242,33 @@ print_output_info(void *data) > > } > > } > > > > +static char > > +bits2graph(uint32_t value, unsigned bitoffset) > > +{ > > + int c = (value >> bitoffset) & 0xff; > > + > > + if (isgraph(c) || isspace(c)) > > + return c; > > + > > + return '?'; > > +} > > + > > +static void > > +fmt2str(uint32_t format, char *str, int len) > > `fourcc2str()` ? > This function is specific to 4 char codes, I think its name should > reflect this. I suppose. > > +{ > > + int i; > > + > > + assert(len >= 5); > > + > > + for (i = 0; i < 4; i++) > > + str[i] = bits2graph(format, i * 8); > > + str[i] = '\0'; > > +} > > + > > static void > > print_shm_info(void *data) > > { > > + char str[6]; > > 6? not 5? Yeah, I made the changes you suggested. > These are nit-picks, this patch already does what it says on the tin: > Reviewed-by: Eric Engestrom Pushed: 4d6eb17..78dc6a9 master -> master Thanks, pq > > struct shm_info *shm = data; > > struct shm_format *format; > > > > @@ -262,7 +288,8 @@ print_shm_info(void *data) > > printf(" RGB565"); > > break; > > default: > > - printf(" unknown(%08x)", format->format); > > + fmt2str(format->format, str, sizeof(str)); > > + printf(" '%s'(0x%08x)", str, format->format); > > break; > > } > > > > -- > > 2.10.2 > > pgpYb_WfJNoAa.pgp Description: OpenPGP digital signature ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH weston] clients/weston-info: print unknown formats better
On Monday, 2017-02-20 15:47:57 +0200, Pekka Paalanen wrote: > From: Pekka Paalanen> > Don't just dump the raw 32-bit values, try to interpret it as a DRM > fourcc too. > > This prints properly the formats YUYV, NV12 and YU12 supported by > Weston. > > Signed-off-by: Pekka Paalanen > --- > clients/weston-info.c | 29 - > 1 file changed, 28 insertions(+), 1 deletion(-) > > diff --git a/clients/weston-info.c b/clients/weston-info.c > index 712346a..ab12947 100644 > --- a/clients/weston-info.c > +++ b/clients/weston-info.c > @@ -30,6 +30,8 @@ > #include > #include > #include > +#include > +#include > > #include > > @@ -240,9 +242,33 @@ print_output_info(void *data) > } > } > > +static char > +bits2graph(uint32_t value, unsigned bitoffset) > +{ > + int c = (value >> bitoffset) & 0xff; > + > + if (isgraph(c) || isspace(c)) > + return c; > + > + return '?'; > +} > + > +static void > +fmt2str(uint32_t format, char *str, int len) `fourcc2str()` ? This function is specific to 4 char codes, I think its name should reflect this. > +{ > + int i; > + > + assert(len >= 5); > + > + for (i = 0; i < 4; i++) > + str[i] = bits2graph(format, i * 8); > + str[i] = '\0'; > +} > + > static void > print_shm_info(void *data) > { > + char str[6]; 6? not 5? These are nit-picks, this patch already does what it says on the tin: Reviewed-by: Eric Engestrom > struct shm_info *shm = data; > struct shm_format *format; > > @@ -262,7 +288,8 @@ print_shm_info(void *data) > printf(" RGB565"); > break; > default: > - printf(" unknown(%08x)", format->format); > + fmt2str(format->format, str, sizeof(str)); > + printf(" '%s'(0x%08x)", str, format->format); > break; > } > > -- > 2.10.2 > ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston] clients/weston-info: print unknown formats better
From: Pekka PaalanenDon't just dump the raw 32-bit values, try to interpret it as a DRM fourcc too. This prints properly the formats YUYV, NV12 and YU12 supported by Weston. Signed-off-by: Pekka Paalanen --- clients/weston-info.c | 29 - 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/clients/weston-info.c b/clients/weston-info.c index 712346a..ab12947 100644 --- a/clients/weston-info.c +++ b/clients/weston-info.c @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include @@ -240,9 +242,33 @@ print_output_info(void *data) } } +static char +bits2graph(uint32_t value, unsigned bitoffset) +{ + int c = (value >> bitoffset) & 0xff; + + if (isgraph(c) || isspace(c)) + return c; + + return '?'; +} + +static void +fmt2str(uint32_t format, char *str, int len) +{ + int i; + + assert(len >= 5); + + for (i = 0; i < 4; i++) + str[i] = bits2graph(format, i * 8); + str[i] = '\0'; +} + static void print_shm_info(void *data) { + char str[6]; struct shm_info *shm = data; struct shm_format *format; @@ -262,7 +288,8 @@ print_shm_info(void *data) printf(" RGB565"); break; default: - printf(" unknown(%08x)", format->format); + fmt2str(format->format, str, sizeof(str)); + printf(" '%s'(0x%08x)", str, format->format); break; } -- 2.10.2 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel