[igt-dev] [PATCH i-g-t v2 1/3] lib/igt_fb: Allow creating yuv fbs with different encodings/ranges

Ville Syrjala
2019-07-02T17:56:42Z

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Pass the color encoding/range to igt_create_fb_with_bo_size()
so that tests are able to generate fbs with various encodings/ranges.

v2: Drop the _full() variants of th fb create funcs (Nicholas)

Cc: Uma Shankar <uma.shankar@intel.com>
Reviewed-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com> #v1
Reviewed-by: Uma Shankar <uma.shankar@intel.com> #v1
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
lib/igt_fb.c | 18 ++++++++++++------
lib/igt_fb.h | 2 ++
tests/kms_flip.c | 6 ++++--
tests/kms_frontbuffer_tracking.c | 6 ++++--
4 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 415a3d65d24b..5dc74a00089a 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -1415,6 +1415,8 @@ void igt_paint_image(cairo_t *cr, const char *filename,
* @height: height of the framebuffer in pixel
* @format: drm fourcc pixel format code
* @modifier: tiling layout of the framebuffer (as framebuffer modifier)
+ * @color_encoding: color encoding for YCbCr formats (ignored otherwise)
+ * @color_range: color range for YCbCr formats (ignored otherwise)
* @fb: pointer to an #igt_fb structure
* @bo_size: size of the backing bo (0 for automatic size)
* @bo_stride: stride of the backing bo (0 for automatic stride)
@@ -1432,12 +1434,11 @@ void igt_paint_image(cairo_t *cr, const char *filename,
unsigned int
igt_create_fb_with_bo_size(int fd, int width, int height,
uint32_t format, uint64_t modifier,
+ enum igt_color_encoding color_encoding,
+ enum igt_color_range color_range,
struct igt_fb *fb, uint64_t bo_size,
unsigned bo_stride)
{
- /* FIXME allow the caller to pass these in */
- enum igt_color_encoding color_encoding = IGT_COLOR_YCBCR_BT709;
- enum igt_color_range color_range = IGT_COLOR_YCBCR_LIMITED_RANGE;
uint32_t flags = 0;

fb_init(fb, fd, width, height, format, modifier,
@@ -1493,8 +1494,10 @@ igt_create_fb_with_bo_size(int fd, int width, int height,
unsigned int igt_create_fb(int fd, int width, int height, uint32_t format,
uint64_t modifier, struct igt_fb *fb)
{
- return igt_create_fb_with_bo_size(fd, width, height, format, modifier, fb,
- 0, 0);
+ return igt_create_fb_with_bo_size(fd, width, height, format, modifier,
+ IGT_COLOR_YCBCR_BT709,
+ IGT_COLOR_YCBCR_LIMITED_RANGE,
+ fb, 0, 0);
}

/**
@@ -3329,7 +3332,10 @@ unsigned int igt_fb_convert_with_stride(struct igt_fb *dst, struct igt_fb *src,

fb_id = igt_create_fb_with_bo_size(src->fd, src->width,
src->height, dst_fourcc,
- dst_modifier, dst, 0,
+ dst_modifier,
+ IGT_COLOR_YCBCR_BT709,
+ IGT_COLOR_YCBCR_LIMITED_RANGE,
+ dst, 0,
dst_stride);
igt_assert(fb_id > 0);

diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index be786911d577..e19cc5d415ef 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -120,6 +120,8 @@ void igt_calc_fb_size(int fd, int width, int height, uint32_t format, uint64_t m
unsigned int
igt_create_fb_with_bo_size(int fd, int width, int height,
uint32_t format, uint64_t modifier,
+ enum igt_color_encoding color_encoding,
+ enum igt_color_range color_range,
struct igt_fb *fb, uint64_t bo_size,
unsigned bo_stride);
unsigned int igt_create_fb(int fd, int width, int height, uint32_t format,
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 0a8d1c55a7aa..ef2521f21a42 100755
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -1247,8 +1247,10 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs,
igt_bpp_depth_to_drm_format(o->bpp, o->depth),
tiling, &o->fb_info[0]);
o->fb_ids[1] = igt_create_fb_with_bo_size(drm_fd, o->fb_width, o->fb_height,
- igt_bpp_depth_to_drm_format(o->bpp, o->depth),
- tiling, &o->fb_info[1], bo_size, 0);
+ igt_bpp_depth_to_drm_format(o->bpp, o->depth),
+ tiling, IGT_COLOR_YCBCR_BT709,
+ IGT_COLOR_YCBCR_LIMITED_RANGE,
+ &o->fb_info[1], bo_size, 0);

igt_assert(o->fb_ids[0]);
igt_assert(o->fb_ids[1]);
diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c
index 1037faf8e6f7..c788b59eefba 100644
--- a/tests/kms_frontbuffer_tracking.c
+++ b/tests/kms_frontbuffer_tracking.c
@@ -491,8 +491,10 @@ static void create_fb(enum pixel_format pformat, int width, int height,
igt_calc_fb_size(drm.fd, width, height, format, tiling_for_size, &size,
&stride);

- igt_create_fb_with_bo_size(drm.fd, width, height, format, tiling, fb,
- size, stride);
+ igt_create_fb_with_bo_size(drm.fd, width, height, format, tiling,
+ IGT_COLOR_YCBCR_BT709,
+ IGT_COLOR_YCBCR_LIMITED_RANGE,
+ fb, size, stride);
}

static uint32_t pick_color(struct igt_fb *fb, enum color ecolor)
--
2.21.0