The plain pattern can be useful to debug some color issues. Add an option
to configure the color for the plain pattern.

Co-developed-by: Miquel Raynal <miquel.ray...@bootlin.com>
Signed-off-by: Miquel Raynal <miquel.ray...@bootlin.com>
Signed-off-by: Louis Chauvet <louis.chau...@bootlin.com>
---
 tests/modetest/buffers.c |  2 +-
 tests/util/pattern.c     | 19 +++++++++++++------
 tests/util/pattern.h     |  1 +
 3 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/tests/modetest/buffers.c b/tests/modetest/buffers.c
index 165b95295644..03a6d424f102 100644
--- a/tests/modetest/buffers.c
+++ b/tests/modetest/buffers.c
@@ -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;
diff --git a/tests/util/pattern.c b/tests/util/pattern.c
index e5f20c50b5d8..e2847c5457af 100644
--- a/tests/util/pattern.c
+++ b/tests/util/pattern.c
@@ -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);
diff --git a/tests/util/pattern.h b/tests/util/pattern.h
index e500aba3b468..23e11c0f58b8 100644
--- a/tests/util/pattern.h
+++ b/tests/util/pattern.h
@@ -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);
 

-- 
2.48.1

Reply via email to