summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert@linux-m68k.org>2022-03-03 18:17:27 +0100
committerGeert Uytterhoeven <geert@linux-m68k.org>2023-10-24 09:44:25 +0200
commit15c6657617a38527b8c4698d3f56cd6cbd55e3fb (patch)
tree1930c3f6bbb9995bcd6ba5b41cb5d32de606840b
parent8134deb31f5220922f8dd5ea9a0e0bfb6f85a487 (diff)
downloadlibdrm-15c6657617a38527b8c4698d3f56cd6cbd55e3fb.tar.gz
libdrm-15c6657617a38527b8c4698d3f56cd6cbd55e3fb.tar.bz2
libdrm-15c6657617a38527b8c4698d3f56cd6cbd55e3fb.zip
util: add SMPTE pattern support for C4 format
Add support for drawing the SMPTE pattern in a buffer using the C4 indexed format. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Acked-by: Sam Ravnborg <sam@ravnborg.org> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> --- v5: - Add Reviewed-by, v4: - No changes, v3: - Add Acked-by, v2: - Use new smpte_top[], - Split off changes to tests/util/pattern.c.
-rw-r--r--tests/util/pattern.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/util/pattern.c b/tests/util/pattern.c
index fc457c4a..17074265 100644
--- a/tests/util/pattern.c
+++ b/tests/util/pattern.c
@@ -672,6 +672,46 @@ static const struct drm_color_lut smpte_color_lut[] = {
#undef EXPAND_COLOR
+static void write_pixel_4(uint8_t *mem, unsigned int x, unsigned int pixel)
+{
+ if (x & 1)
+ mem[x / 2] = (mem[x / 2] & 0xf0) | (pixel & 0x0f);
+ else
+ mem[x / 2] = (mem[x / 2] & 0x0f) | (pixel << 4);
+}
+
+static void fill_smpte_c4(void *mem, unsigned int width, unsigned int height,
+ unsigned int stride)
+{
+ unsigned int x;
+ unsigned int y;
+
+ for (y = 0; y < height * 6 / 9; ++y) {
+ for (x = 0; x < width; ++x)
+ write_pixel_4(mem, x, smpte_top[x * 7 / width]);
+ mem += stride;
+ }
+
+ for (; y < height * 7 / 9; ++y) {
+ for (x = 0; x < width; ++x)
+ write_pixel_4(mem, x, smpte_middle[x * 7 / width]);
+ mem += stride;
+ }
+
+ for (; y < height; ++y) {
+ for (x = 0; x < width * 5 / 7; ++x)
+ write_pixel_4(mem, x,
+ smpte_bottom[x * 4 / (width * 5 / 7)]);
+ for (; x < width * 6 / 7; ++x)
+ write_pixel_4(mem, x,
+ smpte_bottom[(x - width * 5 / 7) * 3 /
+ (width / 7) + 4]);
+ for (; x < width; ++x)
+ write_pixel_4(mem, x, smpte_bottom[7]);
+ mem += stride;
+ }
+}
+
static void fill_smpte_c8(void *mem, unsigned int width, unsigned int height,
unsigned int stride)
{
@@ -723,6 +763,8 @@ static void fill_smpte(const struct util_format_info *info, void *planes[3],
unsigned char *u, *v;
switch (info->format) {
+ case DRM_FORMAT_C4:
+ return fill_smpte_c4(planes[0], width, height, stride);
case DRM_FORMAT_C8:
return fill_smpte_c8(planes[0], width, height, stride);
case DRM_FORMAT_UYVY: