All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 6/8] lib/fb: Add color_encoding/color_range to igt_fb
Date: Wed, 23 May 2018 21:31:08 +0300	[thread overview]
Message-ID: <20180523183110.1975-6-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20180523183110.1975-1-ville.syrjala@linux.intel.com>

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

Make igt_fb be aware of the color encoding/range. For now
we still hardcore everything to BT.709 limited range though.

v2: Default to BT.709

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 lib/igt_fb.c | 46 +++++++++++++++++++++++++++++-----------------
 lib/igt_fb.h |  4 ++++
 2 files changed, 33 insertions(+), 17 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 70bb435c5eb0..2f1f959cc9c3 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -374,6 +374,8 @@ static void *memset32(void *s, uint32_t c, size_t n)
 
 /* helpers to create nice-looking framebuffers */
 static int create_bo_for_fb(int fd, int width, int height,
+			    enum igt_color_encoding color_encoding,
+			    enum igt_color_range color_range,
 			    struct format_desc_struct *format,
 			    uint64_t tiling, unsigned size, unsigned stride,
 			    unsigned *size_ret, unsigned *stride_ret,
@@ -406,7 +408,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 */
+			bool full_range = color_range == IGT_COLOR_YCBCR_FULL_RANGE;
 
 			bo = gem_create(fd, size);
 			gem_set_tiling(fd, bo, igt_fb_mod_to_tiling(tiling), stride);
@@ -481,7 +483,10 @@ int igt_create_bo_with_dimensions(int fd, int width, int height,
 				  unsigned stride, unsigned *size_ret,
 				  unsigned *stride_ret, bool *is_dumb)
 {
-	return create_bo_for_fb(fd, width, height, lookup_drm_format(format),
+	return create_bo_for_fb(fd, width, height,
+				IGT_COLOR_YCBCR_BT709,
+				IGT_COLOR_YCBCR_LIMITED_RANGE,
+				lookup_drm_format(format),
 				modifier, 0, stride, size_ret, stride_ret, NULL, is_dumb);
 }
 
@@ -823,6 +828,9 @@ igt_create_fb_with_bo_size(int fd, int width, int height,
 			   struct igt_fb *fb, unsigned 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;
 	struct format_desc_struct *f = lookup_drm_format(format);
 	uint32_t fb_id;
 	int i;
@@ -833,8 +841,9 @@ igt_create_fb_with_bo_size(int fd, int width, int height,
 
 	igt_debug("%s(width=%d, height=%d, format=0x%x, tiling=0x%"PRIx64", size=%d)\n",
 		  __func__, width, height, format, tiling, bo_size);
-	fb->gem_handle = create_bo_for_fb(fd, width, height, f,
-					  tiling, bo_size, bo_stride,
+	fb->gem_handle = create_bo_for_fb(fd, width, height,
+					  color_encoding, color_range,
+					  f, tiling, bo_size, bo_stride,
 					  &fb->size, &fb->stride,
 					  fb->offsets, &fb->is_dumb);
 	igt_assert(fb->gem_handle > 0);
@@ -873,6 +882,8 @@ igt_create_fb_with_bo_size(int fd, int width, int height,
 	fb->fb_id = fb_id;
 	fb->fd = fd;
 	fb->num_planes = f->num_planes;
+	fb->color_encoding = color_encoding;
+	fb->color_range = color_range;
 
 	for (i = 0; i < f->num_planes; i++) {
 		fb->plane_bpp[i] = f->plane_bpp[i];
@@ -1249,11 +1260,12 @@ static void setup_linear_mapping(int fd, struct igt_fb *fb, struct fb_blit_linea
 	 * destination, tiling it at the same time.
 	 */
 	linear->handle = create_bo_for_fb(fd, fb->width, fb->height,
-					       lookup_drm_format(fb->drm_format),
-					       LOCAL_DRM_FORMAT_MOD_NONE, 0,
-					       0, &linear->size,
-					       &linear->stride,
-					       linear->offsets, &linear->is_dumb);
+					  fb->color_encoding, fb->color_range,
+					  lookup_drm_format(fb->drm_format),
+					  LOCAL_DRM_FORMAT_MOD_NONE, 0,
+					  0, &linear->size,
+					  &linear->stride,
+					  linear->offsets, &linear->is_dumb);
 
 	igt_assert(linear->handle > 0);
 
@@ -1396,8 +1408,8 @@ static void convert_nv12_to_rgb24(struct igt_fb *fb, struct fb_convert_blit_uplo
 	uint8_t *rgb24 = blit->rgb24.map;
 	unsigned rgb24_stride = blit->rgb24.stride, planar_stride = blit->linear.stride;
 	uint8_t *buf = malloc(blit->linear.size);
-	struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(IGT_COLOR_YCBCR_BT601,
-						    IGT_COLOR_YCBCR_LIMITED_RANGE);
+	struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(fb->color_encoding,
+						    fb->color_range);
 
 	/*
 	 * Reading from the BO is awfully slow because of lack of read caching,
@@ -1505,8 +1517,8 @@ static void convert_rgb24_to_nv12(struct igt_fb *fb, struct fb_convert_blit_uplo
 	const uint8_t *rgb24 = blit->rgb24.map;
 	unsigned rgb24_stride = blit->rgb24.stride;
 	unsigned planar_stride = blit->linear.stride;
-	struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(IGT_COLOR_YCBCR_BT601,
-						    IGT_COLOR_YCBCR_LIMITED_RANGE);
+	struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(fb->color_encoding,
+						    fb->color_range);
 
 	igt_assert_f(fb->drm_format == DRM_FORMAT_NV12,
 		     "Conversion not implemented for !NV12 planar formats\n");
@@ -1633,8 +1645,8 @@ static void convert_yuyv_to_rgb24(struct igt_fb *fb, struct fb_convert_blit_uplo
 	uint8_t *rgb24 = blit->rgb24.map;
 	unsigned rgb24_stride = blit->rgb24.stride, yuyv_stride = blit->linear.stride;
 	uint8_t *buf = malloc(blit->linear.size);
-	struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(IGT_COLOR_YCBCR_BT601,
-						    IGT_COLOR_YCBCR_LIMITED_RANGE);
+	struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(fb->color_encoding,
+						    fb->color_range);
 
 	/*
 	 * Reading from the BO is awfully slow because of lack of read caching,
@@ -1692,8 +1704,8 @@ static void convert_rgb24_to_yuyv(struct igt_fb *fb, struct fb_convert_blit_uplo
 	const uint8_t *rgb24 = blit->rgb24.map;
 	unsigned rgb24_stride = blit->rgb24.stride;
 	unsigned yuyv_stride = blit->linear.stride;
-	struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(IGT_COLOR_YCBCR_BT601,
-						    IGT_COLOR_YCBCR_LIMITED_RANGE);
+	struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(fb->color_encoding,
+						    fb->color_range);
 
 	igt_assert_f(fb->drm_format == DRM_FORMAT_YUYV ||
 		     fb->drm_format == DRM_FORMAT_YVYU ||
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index 081ed42a99c9..d28bc0c4110a 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -36,6 +36,8 @@
 
 #include <i915_drm.h>
 
+#include "igt_color_encoding.h"
+
 /**
  * igt_fb_t:
  * @fb_id: KMS ID of the framebuffer
@@ -66,6 +68,8 @@ typedef struct igt_fb {
 	uint32_t drm_format;
 	int width;
 	int height;
+	enum igt_color_encoding color_encoding;
+	enum igt_color_range color_range;
 	unsigned int stride;
 	uint64_t tiling;
 	unsigned int size;
-- 
2.16.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2018-05-23 18:31 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-23 18:31 [igt-dev] [PATCH i-g-t 1/8] lib: Clear packed YUV formats to black Ville Syrjala
2018-05-23 18:31 ` [igt-dev] [PATCH i-g-t 2/8] lib: Don't use dumb buffers for YCbCr Ville Syrjala
2018-06-05  9:51   ` Maarten Lankhorst
2018-05-23 18:31 ` [igt-dev] [PATCH i-g-t 3/8] lib: Clean up format_desc Ville Syrjala
2018-05-23 18:31 ` [igt-dev] [PATCH i-g-t 4/8] lib: Use igt_matrix for ycbcr<->rgb conversion Ville Syrjala
2018-06-06 10:11   ` Maarten Lankhorst
2018-05-23 18:31 ` [igt-dev] [PATCH i-g-t 5/8] lib: Add support for rendering into packed YCbCr framebuffers Ville Syrjala
2018-05-23 18:31 ` Ville Syrjala [this message]
2018-05-23 18:31 ` [igt-dev] [PATCH i-g-t 7/8] lib/kms: Respect fb color_encoding/color_range Ville Syrjala
2018-05-23 18:31 ` [igt-dev] [PATCH i-g-t 8/8] tests/kms_plane: crc check plane pixel formats Ville Syrjala
2018-05-24 10:48   ` [igt-dev] [PATCH i-g-t v2 " Ville Syrjala
2018-06-07 15:18     ` Maarten Lankhorst
2018-05-23 19:09 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/8] lib: Clear packed YUV formats to black Patchwork
2018-05-23 23:27 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2018-05-24 17:15 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/8] lib: Clear packed YUV formats to black (rev2) Patchwork
2018-05-24 23:05 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2018-06-05  9:42 ` [igt-dev] [PATCH i-g-t 1/8] lib: Clear packed YUV formats to black Maarten Lankhorst
2018-06-05 10:13   ` Ville Syrjälä
2018-06-05 10:33     ` Maarten Lankhorst

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180523183110.1975-6-ville.syrjala@linux.intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.