From b0033d9310c13eee8fd8268ec0ea16af91c92e6e Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Thu, 7 Jun 2018 16:25:22 +0200 Subject: lib/color_encoding: Prepare support for HDR modes, v2. We're starting to add support for 10, 12 and 16-bits formats that all have different values for the Y offset and range. Some 10 bits formats go from [0...1023], others go to [0...1023] shifted left by 6. To accomodate all formats add a struct definition for all various formats, this can be extended further when we add new formats. Changes since v1: - Rebase on top of added yuv changes. - Add commit description (swatish) - Add missing newline. (swatish) Signed-off-by: Maarten Lankhorst Reviewed-by: Juha-Pekka Heikkila #v1 --- lib/igt_fb.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/igt_fb.c') diff --git a/lib/igt_fb.c b/lib/igt_fb.c index cad8bfea..3a4827c3 100644 --- a/lib/igt_fb.c +++ b/lib/igt_fb.c @@ -1564,7 +1564,7 @@ static void *igt_fb_create_cairo_shadow_buffer(int fd, DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE, IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE); - shadow->strides[0] = ALIGN(width * 4, 16); + shadow->strides[0] = ALIGN(width * shadow->plane_bpp[0], 16); shadow->size = ALIGN(shadow->strides[0] * height, sysconf(_SC_PAGESIZE)); ptr = mmap(NULL, shadow->size, PROT_READ | PROT_WRITE, @@ -1777,7 +1777,9 @@ static void convert_yuv_to_rgb24(struct fb_convert *cvt) uint8_t *y, *u, *v; uint8_t *rgb24 = cvt->dst.ptr; unsigned int rgb24_stride = cvt->dst.fb->strides[0]; - struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(cvt->src.fb->color_encoding, + struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(cvt->src.fb->drm_format, + cvt->dst.fb->drm_format, + cvt->src.fb->color_encoding, cvt->src.fb->color_range); uint8_t *buf; struct yuv_parameters params = { }; @@ -1838,7 +1840,9 @@ static void convert_rgb24_to_yuv(struct fb_convert *cvt) const uint8_t *rgb24 = cvt->src.ptr; uint8_t bpp = 4; unsigned rgb24_stride = cvt->src.fb->strides[0]; - struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(cvt->dst.fb->color_encoding, + struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(cvt->src.fb->drm_format, + cvt->dst.fb->drm_format, + cvt->dst.fb->color_encoding, cvt->dst.fb->color_range); struct yuv_parameters params = { }; -- cgit v1.2.3