[igt-dev] [PATCH i-g-t 2/8] lib: Clear packed YUV formats to black
Ville Syrjala
ville.syrjala at linux.intel.com
Tue Feb 27 21:21:14 UTC 2018
From: Ville Syrjälä <ville.syrjala at linux.intel.com>
As we do for NV12, let's also clear packed YUV formats to black instead
of zero. Avoids unexpected green screens.
Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
lib/igt_fb.c | 34 ++++++++++++++++++++++++++++++----
1 file changed, 30 insertions(+), 4 deletions(-)
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 9af600896e50..d9c5406cb34e 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -333,6 +333,16 @@ uint64_t igt_fb_tiling_to_mod(uint64_t tiling)
}
}
+static void *memset32(void *s, uint32_t c, size_t n)
+{
+ uint32_t *ptr = s;
+
+ for (int i = 0; i < n; i++)
+ *ptr++ = c;
+
+ return s;
+}
+
/* helpers to create nice-looking framebuffers */
static int create_bo_for_fb(int fd, int width, int height,
struct format_desc_struct *format,
@@ -367,6 +377,7 @@ static int create_bo_for_fb(int fd, int width, int height,
if (is_i915_device(fd)) {
uint8_t *ptr;
+ bool full_range = false; /* FIXME */
bo = gem_create(fd, size);
gem_set_tiling(fd, bo, igt_fb_mod_to_tiling(tiling), stride);
@@ -375,10 +386,25 @@ static int create_bo_for_fb(int fd, int width, int height,
ptr = gem_mmap__gtt(fd, bo, size, PROT_READ | PROT_WRITE);
igt_assert(*(uint32_t *)ptr == 0);
- if (format->drm_id == DRM_FORMAT_NV12) {
- /* component formats have a different zero point */
- memset(ptr, 16, offsets[1]);
- memset(ptr + offsets[1], 0x80, (height + 1)/2 * stride);
+ switch (format->drm_id) {
+ case DRM_FORMAT_NV12:
+ memset(ptr + offsets[0], full_range ? 0x00 : 0x10,
+ calculated_stride * height);
+ memset(ptr + offsets[1], 0x80,
+ calculated_stride * height/2);
+ break;
+ case DRM_FORMAT_YUYV:
+ case DRM_FORMAT_YVYU:
+ igt_info("clearing yuyv\n");
+ memset32(ptr, full_range ? 0x80008000 : 0x80108010,
+ calculated_stride * height / 4);
+ break;
+ case DRM_FORMAT_UYVY:
+ case DRM_FORMAT_VYUY:
+ igt_info("clearing uyvy\n");
+ memset32(ptr, full_range ? 0x00800080 : 0x10801080,
+ calculated_stride * height / 4);
+ break;
}
gem_munmap(ptr, size);
--
2.13.6
More information about the igt-dev
mailing list