Add an option to configure the plain pattern in modetest
cover Add an option to configure the plain pattern in modetest
modetest is a very useful tool to test displays, but to debug issues on electrical level, it is often usefull to choose a certain bit pattern for color.
Add an option in modetest, so you don't have to recompile for each new color you want to use.
---
Louis Chauvet (2):
util: Add option to change the color for plain pattern
modetest: Add color configuration for plain pattern
tests/modetest/buffers.c | 5 +++-- tests/modetest/buffers.h | 3 ++- tests/modetest/modetest.c | 22 +++++++++++++++++----- tests/util/pattern.c | 19 +++++++++++++------ tests/util/pattern.h | 1 + 5 files changed, 36 insertions(+), 14 deletions(-)
---
base-commit: a7eb2cfd53a70fcd9ba9dcfad80a3994642f362f
change-id: 20250304-color-option-950cccb9ead7
Best regards,
Signature · 1 line
Louis Chauvet <[email protected]>
PATCH 1/2 util: Add option to change the color for plain pattern
The plain pattern can be useful to debug some color issues. Add an option to configure the color for the plain pattern.
--- tests/modetest/buffers.c | 2 +- tests/util/pattern.c | 19 +++++++++++++------ tests/util/pattern.h | 1 + 3 files changed, 15 insertions(+), 7 deletions(-)
tests/modetest/buffers.c +1 -1
@@ -386,7 +386,7 @@ bo_create(int fd, unsigned int format,break ; } -util_fill_pattern (format, pattern, planes, width, height, pitches[0 ]); +util_fill_pattern (format, pattern,0x38383838 , planes, width, height, pitches[0 ]);bo_unmap (bo);return bo;
tests/util/pattern.c +13 -6
@@ -1719,18 +1719,24 @@ static void fill_tiles(const struct util_format_info *info, void *planes[3],static void fill_plain (const struct util_format_info *info,void *planes[3 ],unsigned int height, -unsigned int stride) +unsigned int stride,unsigned int color) { +int i; +char *p; +switch (info->format) {case DRM_FORMAT_XRGB16161616F :case DRM_FORMAT_XBGR16161616F :case DRM_FORMAT_ARGB16161616F :case DRM_FORMAT_ABGR16161616F : -/* 0x3838 = 0.5273 */ -memset (planes[0 ],0x38 , stride * height); -break ;default : -memset (planes[0 ],0x77 , stride * height); +for (i =0 ; i < height * stride; i +=4 ) { +int j; + + p = planes[0 ] + i; +for (j =0 ; j <4 ; j++) + p[j] = (color >> (j *8 )) &0xFF ; + }break ; } }
@@ -1862,6 +1868,7 @@ static void fill_gradient(const struct util_format_info *info, void *planes[3],* Supported formats vary depending on the selected pattern. */ void util_fill_pattern (uint32_t format,enum util_fill_pattern pattern, +unsigned int color,void *planes[3 ],unsigned int width,unsigned int height,unsigned int stride) {
@@ -1879,7 +1886,7 @@ void util_fill_pattern(uint32_t format, enum util_fill_pattern pattern,return fill_smpte (info, planes, width, height, stride);case UTIL_PATTERN_PLAIN : -return fill_plain (info, planes, height, stride); +return fill_plain (info, planes, height, stride, color);case UTIL_PATTERN_GRADIENT :return fill_gradient (info, planes, width, height, stride);
tests/util/pattern.h +1 -0
@@ -36,6 +36,7 @@ enum util_fill_pattern { };void util_fill_pattern (uint32_t format,enum util_fill_pattern pattern, +unsigned int color,void *planes[3 ],unsigned int width,unsigned int height,unsigned int stride);
Signature · 1 line
2.48.1
PATCH 2/2 modetest: Add color configuration for plain pattern
In reply to Louis ChauvetThe plain pattern is useful to debug display issues. Unfortunatly this pattern is not configurable. Add a new option '-V' for this.
--- tests/modetest/buffers.c | 5 +++-- tests/modetest/buffers.h | 3 ++- tests/modetest/modetest.c | 22 +++++++++++++++++----- 3 files changed, 22 insertions(+), 8 deletions(-)
tests/modetest/buffers.c +3 -2
@@ -114,7 +114,8 @@ struct bo * bo_create(int fd, unsigned int format, unsigned int width, unsigned int height, unsigned int handles[4], unsigned int pitches[4], - unsigned int offsets[4], enum util_fill_pattern pattern) + unsigned int offsets[4], enum util_fill_pattern pattern, + unsigned int color) { unsigned int virtual_height, xsub, ysub;struct bo *bo;
@@ -386,7 +387,7 @@ bo_create(int fd, unsigned int format,break ; } -util_fill_pattern (format, pattern,0x38383838 , planes, width, height, pitches[0 ]); +util_fill_pattern (format, pattern, color, planes, width, height, pitches[0 ]);bo_unmap (bo);return bo;
tests/modetest/buffers.h +2 -1
@@ -34,7 +34,8 @@ struct bo;struct bo *bo_create (int fd,unsigned int format,unsigned int width,unsigned int height,unsigned int handles[4 ],unsigned int pitches[4 ], -unsigned int offsets[4 ],enum util_fill_pattern pattern); +unsigned int offsets[4 ],enum util_fill_pattern pattern, +unsigned int color);void bo_destroy (struct bo *bo);void bo_dump (struct bo *bo,const char *filename);
tests/modetest/modetest.c +17 -5
@@ -70,6 +70,7 @@static enum util_fill_pattern primary_fill =UTIL_PATTERN_SMPTE ;static enum util_fill_pattern secondary_fill =UTIL_PATTERN_TILES ; +static unsigned long color =0x308830 ;static drmModeModeInfo user_mode;struct crtc {
@@ -1199,7 +1200,7 @@ bo_fb_create(int fd, unsigned int fourcc, const uint32_t w, const uint32_t h,struct bo *bo;unsigned int fb_id; - bo =bo_create (fd, fourcc, w, h, handles, pitches, offsets, pat); + bo =bo_create (fd, fourcc, w, h, handles, pitches, offsets, pat, color);if (bo ==NULL )return -1 ;
@@ -1240,7 +1241,7 @@ static int atomic_set_plane(struct device *dev, struct plane_arg *p,if (!plane_bo) {if (bo_fb_create (dev->fd, p->fourcc, p->w, p->h, - pattern, &plane_bo, &p->fb_id)) + pattern, &plane_bo, &p->fb_id))return -1 ; }
@@ -1665,7 +1666,7 @@ static unsigned int set_mode(struct device *dev, struct pipe_arg **pipe_args, un }if (bo_fb_create (dev->fd, pipes[0 ].fourcc, dev->mode.width, dev->mode.height, - primary_fill, &dev->mode.bo, &dev->mode.fb_id)) + primary_fill, &dev->mode.bo, &dev->mode.fb_id))return 0 ; }
@@ -1857,7 +1858,7 @@ static void set_cursors(struct device *dev, struct pipe_arg *pipes, unsigned int* translucent alpha */ bo =bo_create (dev->fd,DRM_FORMAT_ARGB8888 , cw, ch, handles, pitches, - offsets,UTIL_PATTERN_PLAIN ); + offsets,UTIL_PATTERN_PLAIN , color);if (bo ==NULL )return ;
@@ -2126,6 +2127,13 @@ static void parse_fill_patterns(char *arg) secondary_fill =util_pattern_enum (fill); } +static void parse_fill_value (char *arg) +{ +char *end; + + color =strtoul (arg, &end,16 ); +} +static void usage (char *name) {fprintf (stderr,"usage: %s [-acDdefMoPpsCvrw]\n" , name);
@@ -2149,6 +2157,7 @@ static void usage(char *name)fprintf (stderr,"\t-w <obj_id>:<prop_name>:<value>\tset property, see 'property'\n" );fprintf (stderr,"\t-a \tuse atomic API\n" );fprintf (stderr,"\t-F pattern1,pattern2\tspecify fill patterns\n" ); +fprintf (stderr,"\t-V <RRGGBB hex value>\tspecify RGB hex color for plain pattern\n" );fprintf (stderr,"\t-o <desired file path> \t Dump writeback output buffer to file\n" );fprintf (stderr,"\n Generic options:\n\n" );
@@ -2179,7 +2188,7 @@ static void usage(char *name)exit (0 ); } -static char optstr[] ="acdD:efF:M:P:ps:Cvrw:o:" ; +static const char optstr[] ="acdD:efF:V:M:P:ps:Cvrw:o:" ;int main (int argc,char **argv) {
@@ -2236,6 +2245,9 @@ int main(int argc, char **argv)case 'F' :parse_fill_patterns (optarg);break ; +case 'V' : +parse_fill_value (optarg); +break ;case 'M' : module = optarg;/* Preserve the default behaviour of dumping all information. */
Signature · 1 line
2.48.1