summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2018-02-27 22:39:26 +0200
committerVille Syrjälä <ville.syrjala@linux.intel.com>2018-06-08 12:56:01 +0300
commite867d65b7161b75dcbabb56677577c04aa52feb7 (patch)
treea02a58028475fc85f926faf31eae770b187400ff /lib
parent44b837c9b498a2749d2564cbd8acb5a57da02217 (diff)
lib: Clear packed YUV formats to black
As we do for NV12, let's also clear packed YUV formats to black instead of zero. Avoids unexpected green screens. v2: Nuke the debug messages v3: Use wmemset(Maarten) Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/igt_fb.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 6ff90d53..01936dd7 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <math.h>
+#include <wchar.h>
#include <inttypes.h>
#include "drmtest.h"
@@ -368,7 +369,8 @@ static int create_bo_for_fb(int fd, int width, int height,
*is_dumb = false;
if (is_i915_device(fd)) {
- uint8_t *ptr;
+ void *ptr;
+ bool full_range = false; /* FIXME */
bo = gem_create(fd, size);
gem_set_tiling(fd, bo, igt_fb_mod_to_tiling(tiling), stride);
@@ -377,10 +379,23 @@ 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:
+ wmemset(ptr, full_range ? 0x80008000 : 0x80108010,
+ calculated_stride * height / sizeof(wchar_t));
+ break;
+ case DRM_FORMAT_UYVY:
+ case DRM_FORMAT_VYUY:
+ wmemset(ptr, full_range ? 0x00800080 : 0x10801080,
+ calculated_stride * height / sizeof(wchar_t));
+ break;
}
gem_munmap(ptr, size);