summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/util/pattern.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/tests/util/pattern.c b/tests/util/pattern.c
index 85cb3db7..f1c844ea 100644
--- a/tests/util/pattern.c
+++ b/tests/util/pattern.c
@@ -23,6 +23,7 @@
* IN THE SOFTWARE.
*/
+#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -75,13 +76,17 @@ static inline uint32_t swap32(uint32_t x)
}
#ifdef HAVE_BIG_ENDIAN
+#define cpu_to_be16(x) (x)
#define cpu_to_le16(x) swap16(x)
#define cpu_to_le32(x) swap32(x)
#else
+#define cpu_to_be16(x) swap16(x)
#define cpu_to_le16(x) (x)
#define cpu_to_le32(x) (x)
#endif
+#define cpu_to_fb16(x) (fb_be ? cpu_to_be16(x) : cpu_to_le16(x))
+
/* This function takes 8-bit color values */
static inline uint32_t shiftcolor8(const struct util_color_component *comp,
uint32_t value)
@@ -524,7 +529,7 @@ static void fill_smpte_yuv_packed(const struct util_yuv_info *yuv, void *mem,
static void fill_smpte_rgb16(const struct util_rgb_info *rgb, void *mem,
unsigned int width, unsigned int height,
- unsigned int stride)
+ unsigned int stride, bool fb_be)
{
const uint16_t colors_top[] = {
MAKE_RGBA(rgb, 192, 192, 192, 255), /* grey */
@@ -559,26 +564,26 @@ static void fill_smpte_rgb16(const struct util_rgb_info *rgb, void *mem,
for (y = 0; y < height * 6 / 9; ++y) {
for (x = 0; x < width; ++x)
- ((uint16_t *)mem)[x] = cpu_to_le16(colors_top[x * 7 / width]);
+ ((uint16_t *)mem)[x] = cpu_to_fb16(colors_top[x * 7 / width]);
mem += stride;
}
for (; y < height * 7 / 9; ++y) {
for (x = 0; x < width; ++x)
- ((uint16_t *)mem)[x] = cpu_to_le16(colors_middle[x * 7 / width]);
+ ((uint16_t *)mem)[x] = cpu_to_fb16(colors_middle[x * 7 / width]);
mem += stride;
}
for (; y < height; ++y) {
for (x = 0; x < width * 5 / 7; ++x)
((uint16_t *)mem)[x] =
- cpu_to_le16(colors_bottom[x * 4 / (width * 5 / 7)]);
+ cpu_to_fb16(colors_bottom[x * 4 / (width * 5 / 7)]);
for (; x < width * 6 / 7; ++x)
((uint16_t *)mem)[x] =
- cpu_to_le16(colors_bottom[(x - width * 5 / 7) * 3
+ cpu_to_fb16(colors_bottom[(x - width * 5 / 7) * 3
/ (width / 7) + 4]);
for (; x < width; ++x)
- ((uint16_t *)mem)[x] = cpu_to_le16(colors_bottom[7]);
+ ((uint16_t *)mem)[x] = cpu_to_fb16(colors_bottom[7]);
mem += stride;
}
}
@@ -1238,9 +1243,11 @@ static void fill_smpte(const struct util_format_info *info, void *planes[3],
case DRM_FORMAT_BGRA4444:
case DRM_FORMAT_BGRX4444:
case DRM_FORMAT_RGB565:
+ case DRM_FORMAT_RGB565 | DRM_FORMAT_BIG_ENDIAN:
case DRM_FORMAT_BGR565:
case DRM_FORMAT_ARGB1555:
case DRM_FORMAT_XRGB1555:
+ case DRM_FORMAT_XRGB1555 | DRM_FORMAT_BIG_ENDIAN:
case DRM_FORMAT_ABGR1555:
case DRM_FORMAT_XBGR1555:
case DRM_FORMAT_RGBA5551:
@@ -1248,7 +1255,8 @@ static void fill_smpte(const struct util_format_info *info, void *planes[3],
case DRM_FORMAT_BGRA5551:
case DRM_FORMAT_BGRX5551:
return fill_smpte_rgb16(&info->rgb, planes[0],
- width, height, stride);
+ width, height, stride,
+ info->format & DRM_FORMAT_BIG_ENDIAN);
case DRM_FORMAT_BGR888:
case DRM_FORMAT_RGB888:
@@ -1463,7 +1471,7 @@ static void fill_tiles_yuv_packed(const struct util_format_info *info,
static void fill_tiles_rgb16(const struct util_format_info *info, void *mem,
unsigned int width, unsigned int height,
- unsigned int stride)
+ unsigned int stride, bool fb_be)
{
const struct util_rgb_info *rgb = &info->rgb;
void *mem_base = mem;
@@ -1479,7 +1487,7 @@ static void fill_tiles_rgb16(const struct util_format_info *info, void *mem,
(rgb32 >> 8) & 0xff, rgb32 & 0xff,
255);
- ((uint16_t *)mem)[x] = cpu_to_le16(color);
+ ((uint16_t *)mem)[x] = cpu_to_fb16(color);
}
mem += stride;
}
@@ -1609,9 +1617,11 @@ static void fill_tiles(const struct util_format_info *info, void *planes[3],
case DRM_FORMAT_BGRA4444:
case DRM_FORMAT_BGRX4444:
case DRM_FORMAT_RGB565:
+ case DRM_FORMAT_RGB565 | DRM_FORMAT_BIG_ENDIAN:
case DRM_FORMAT_BGR565:
case DRM_FORMAT_ARGB1555:
case DRM_FORMAT_XRGB1555:
+ case DRM_FORMAT_XRGB1555 | DRM_FORMAT_BIG_ENDIAN:
case DRM_FORMAT_ABGR1555:
case DRM_FORMAT_XBGR1555:
case DRM_FORMAT_RGBA5551:
@@ -1619,7 +1629,8 @@ static void fill_tiles(const struct util_format_info *info, void *planes[3],
case DRM_FORMAT_BGRA5551:
case DRM_FORMAT_BGRX5551:
return fill_tiles_rgb16(info, planes[0],
- width, height, stride);
+ width, height, stride,
+ info->format & DRM_FORMAT_BIG_ENDIAN);
case DRM_FORMAT_BGR888:
case DRM_FORMAT_RGB888: