All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t v13] lib/igt_fb: Added XYUV format support for testing
@ 2018-12-17 14:30 Stanislav Lisovskiy
  2018-12-17 15:00 ` [igt-dev] ✓ Fi.CI.BAT: success for lib/igt_fb: Added XYUV format support for testing (rev15) Patchwork
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Stanislav Lisovskiy @ 2018-12-17 14:30 UTC (permalink / raw)
  To: igt-dev; +Cc: stanislav.lisovskiy, ville.syrjala, martin.peres

XYUV format support has been added to DRM, modified
IGT to reflect those changes.

v2: Fixed merge conflict, started to use new yuv<=>rgb
    conversion functions.

v3: Fixed kms_available_modes_crc test to support new XYUV
    format. Fixed a problem, where test complains that two
    outputs might use same pipe at the same time.

v4: Fixed convertion procedure in igt_fb to support XYUV
    properly.

v5: Fixed a coding typo.

v6: Set depth equal to -1 for XYUV format in order to prevent
    it to be used by igt_bpp_depth_to_drm_format, as we do not
    want YUV formats to be used in that case.

v7: Fix "black" color initialization for create_bo_for_fb with
    proper value. Changed naming "planar_stride" to "xyuv_stride".

v8: Change naming from DRM_FORMAT_XYUV to DRM_FORMAT_XYUV8888

v9: Fixed compilation errors by rebasing to recent master.

v10: Adding reference to correspondent kernel commit with the new format
     in include/drm-uapi

v11: Removed unnecessary sizeof's in rgb <=> yuv444 convert functions.

v12: Rebased against master branch, fixed rebase conflict caused by
     new fb_convert functions. Removed drm kernel commit reference
     as it is still not merged, so doesn't make sense to use it.

v13: Resolved one more rebase conflict.

Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
---
 include/drm-uapi/drm_fourcc.h |  2 +-
 lib/igt_fb.c                  | 89 +++++++++++++++++++++++++++++++++++
 2 files changed, 90 insertions(+), 1 deletion(-)

diff --git a/include/drm-uapi/drm_fourcc.h b/include/drm-uapi/drm_fourcc.h
index 0b44260a..4ddf754b 100644
--- a/include/drm-uapi/drm_fourcc.h
+++ b/include/drm-uapi/drm_fourcc.h
@@ -151,7 +151,7 @@ extern "C" {
 #define DRM_FORMAT_VYUY		fourcc_code('V', 'Y', 'U', 'Y') /* [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian */
 
 #define DRM_FORMAT_AYUV		fourcc_code('A', 'Y', 'U', 'V') /* [31:0] A:Y:Cb:Cr 8:8:8:8 little endian */
-#define DRM_FORMAT_XYUV8888		fourcc_code('X', 'Y', 'U', 'V') /* [31:0] X:Y:Cb:Cr 8:8:8:8 little endian */
+#define DRM_FORMAT_XYUV8888	fourcc_code('X', 'Y', 'U', 'V') /* [31:0] X:Y:Cb:Cr 8:8:8:8 little endian */
 
 /*
  * packed YCbCr420 2x2 tiled formats
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 2462d6ba..57264844 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -102,6 +102,10 @@ static const struct format_desc_struct {
 	  .pixman_id = PIXMAN_r8g8b8,
 	  .num_planes = 1, .plane_bpp = { 24, },
 	},
+	{ .name = "XYUV8888", .depth = -1, .drm_id = DRM_FORMAT_XYUV8888,
+	  .cairo_id = CAIRO_FORMAT_RGB24,
+	  .num_planes = 1, .plane_bpp = { 32, },
+	},
 	{ .name = "XRGB8888", .depth = 24, .drm_id = DRM_FORMAT_XRGB8888,
 	  .cairo_id = CAIRO_FORMAT_RGB24,
 	  .pixman_id = PIXMAN_x8r8g8b8,
@@ -496,6 +500,10 @@ static int create_bo_for_fb(struct igt_fb *fb)
 				       0x80,
 				       fb->strides[1] * fb->plane_height[1]);
 				break;
+			case DRM_FORMAT_XYUV8888:
+				wmemset(ptr + fb->offsets[0], full_range ? 0x00008080 : 0x00108080,
+					fb->strides[0] * fb->plane_height[0] / sizeof(wchar_t));
+				break;
 			case DRM_FORMAT_YUYV:
 			case DRM_FORMAT_YVYU:
 				wmemset(ptr + fb->offsets[0],
@@ -1649,6 +1657,79 @@ static void convert_nv12_to_rgb24(struct fb_convert *cvt)
 	convert_src_put(cvt, buf);
 }
 
+static void convert_yuv444_to_rgb24(struct fb_convert *cvt)
+{
+	int i, j;
+	uint8_t *yuv24;
+	uint8_t *rgb24 = cvt->dst.ptr;
+	unsigned rgb24_stride = cvt->dst.fb->strides[0], xyuv_stride = cvt->src.fb->strides[0];
+	uint8_t *buf = malloc(cvt->src.fb->size);
+	struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(cvt->src.fb->color_encoding,
+						    cvt->src.fb->color_range);
+
+	/*
+	 * Reading from the BO is awfully slow because of lack of read caching,
+	 * it's faster to copy the whole BO to a temporary buffer and convert
+	 * from there.
+	 */
+	igt_memcpy_from_wc(buf, cvt->src.ptr + cvt->src.fb->offsets[0], cvt->src.fb->size);
+	yuv24 = buf;
+
+	for (i = 0; i < cvt->dst.fb->height; i++) {
+		for (j = 0; j < cvt->dst.fb->width; j++) {
+			float y, u, v;
+			struct igt_vec4 yuv;
+			struct igt_vec4 rgb;
+
+			v = yuv24[i * xyuv_stride + j * 4];
+			u = yuv24[i * xyuv_stride + j * 4 + 1];
+			y = yuv24[i * xyuv_stride + j * 4 + 2];
+			yuv.d[0] = y;
+			yuv.d[1] = u;
+			yuv.d[2] = v;
+			yuv.d[3] = 1.0f;
+
+			rgb = igt_matrix_transform(&m, &yuv);
+
+			write_rgb(&rgb24[i * rgb24_stride + j * 4], &rgb);
+		}
+	}
+
+	free(buf);
+}
+
+
+static void convert_rgb24_to_yuv444(struct fb_convert *cvt)
+{
+	int i, j;
+	uint8_t *rgb24;
+	uint8_t *yuv444 = cvt->dst.ptr + cvt->dst.fb->offsets[0];
+	unsigned int rgb24_stride = cvt->src.fb->strides[0], xyuv_stride = cvt->dst.fb->strides[0];
+	struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(cvt->dst.fb->color_encoding,
+						    cvt->dst.fb->color_range);
+
+	rgb24 = cvt->src.ptr;
+
+	igt_assert_f(cvt->dst.fb->drm_format == DRM_FORMAT_XYUV8888,
+		     "Conversion not implemented for !XYUV packed formats\n");
+
+	for (i = 0; i < cvt->dst.fb->height; i++) {
+		for (j = 0; j < cvt->dst.fb->width; j++) {
+			struct igt_vec4 rgb;
+			struct igt_vec4 yuv;
+			float y, u, v;
+
+			read_rgb(&rgb, &rgb24[i * rgb24_stride + j * 4]);
+
+			yuv = igt_matrix_transform(&m, &rgb);
+
+			yuv444[i * xyuv_stride + j * 4] = yuv.d[2];
+			yuv444[i * xyuv_stride + j * 4 + 1] = yuv.d[1];
+			yuv444[i * xyuv_stride + j * 4 + 2] = yuv.d[0];
+		}
+	}
+}
+
 static void convert_rgb24_to_nv12(struct fb_convert *cvt)
 {
 	int i, j;
@@ -1934,6 +2015,9 @@ static void fb_convert(struct fb_convert *cvt)
 		return;
 	} else if (cvt->dst.fb->drm_format == DRM_FORMAT_XRGB8888) {
 		switch (cvt->src.fb->drm_format) {
+		case DRM_FORMAT_XYUV8888:
+			convert_yuv444_to_rgb24(cvt);
+			return;
 		case DRM_FORMAT_NV12:
 			convert_nv12_to_rgb24(cvt);
 			return;
@@ -1946,6 +2030,9 @@ static void fb_convert(struct fb_convert *cvt)
 		}
 	} else if (cvt->src.fb->drm_format == DRM_FORMAT_XRGB8888) {
 		switch (cvt->dst.fb->drm_format) {
+		case DRM_FORMAT_XYUV8888:
+			convert_rgb24_to_yuv444(cvt);
+			return;
 		case DRM_FORMAT_NV12:
 			convert_rgb24_to_nv12(cvt);
 			return;
@@ -2037,6 +2124,7 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)
 				    blit, destroy_cairo_surface__convert);
 }
 
+
 /**
  * igt_fb_map_buffer:
  * @fd: open drm file descriptor
@@ -2302,6 +2390,7 @@ bool igt_format_is_yuv(uint32_t drm_format)
 	case DRM_FORMAT_YVYU:
 	case DRM_FORMAT_UYVY:
 	case DRM_FORMAT_VYUY:
+	case DRM_FORMAT_XYUV8888:
 		return true;
 	default:
 		return false;
-- 
2.17.1

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [igt-dev] ✓ Fi.CI.BAT: success for lib/igt_fb: Added XYUV format support for testing (rev15)
  2018-12-17 14:30 [igt-dev] [PATCH i-g-t v13] lib/igt_fb: Added XYUV format support for testing Stanislav Lisovskiy
@ 2018-12-17 15:00 ` Patchwork
  2018-12-17 16:27 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
  2018-12-18 12:56 ` [igt-dev] [PATCH i-g-t v13] lib/igt_fb: Added XYUV format support for testing Maarten Lankhorst
  2 siblings, 0 replies; 4+ messages in thread
From: Patchwork @ 2018-12-17 15:00 UTC (permalink / raw)
  To: Stanislav Lisovskiy; +Cc: igt-dev

== Series Details ==

Series: lib/igt_fb: Added XYUV format support for testing (rev15)
URL   : https://patchwork.freedesktop.org/series/48789/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_5324 -> IGTPW_2164
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/48789/revisions/15/mbox/

Known issues
------------

  Here are the changes found in IGTPW_2164 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@i915_selftest@live_contexts:
    - fi-bsw-n3050:       PASS -> DMESG-FAIL [fdo#108656]

  * igt@i915_selftest@live_gem:
    - fi-bsw-kefka:       PASS -> DMESG-WARN [fdo#108797]

  * igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
    - fi-blb-e6850:       PASS -> INCOMPLETE [fdo#107718]

  * {igt@runner@aborted}:
    - fi-bsw-kefka:       NOTRUN -> FAIL [fdo#108797]

  
#### Possible fixes ####

  * igt@kms_flip@basic-flip-vs-dpms:
    - fi-skl-6700hq:      DMESG-WARN [fdo#105998] -> PASS

  * igt@kms_pipe_crc_basic@nonblocking-crc-pipe-b:
    - fi-byt-clapper:     FAIL [fdo#107362] -> PASS

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#105998]: https://bugs.freedesktop.org/show_bug.cgi?id=105998
  [fdo#107362]: https://bugs.freedesktop.org/show_bug.cgi?id=107362
  [fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
  [fdo#108656]: https://bugs.freedesktop.org/show_bug.cgi?id=108656
  [fdo#108797]: https://bugs.freedesktop.org/show_bug.cgi?id=108797


Participating hosts (49 -> 44)
------------------------------

  Additional (1): fi-cfl-8109u 
  Missing    (6): fi-ilk-m540 fi-bxt-dsi fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-icl-y 


Build changes
-------------

    * IGT: IGT_4748 -> IGTPW_2164

  CI_DRM_5324: 93009153b9bde1d65ca49bb1729cd1111591144b @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_2164: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2164/
  IGT_4748: 90c76cb9bb47a5a3ebb34ad6b1a557bc02d39713 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2164/
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [igt-dev] ✓ Fi.CI.IGT: success for lib/igt_fb: Added XYUV format support for testing (rev15)
  2018-12-17 14:30 [igt-dev] [PATCH i-g-t v13] lib/igt_fb: Added XYUV format support for testing Stanislav Lisovskiy
  2018-12-17 15:00 ` [igt-dev] ✓ Fi.CI.BAT: success for lib/igt_fb: Added XYUV format support for testing (rev15) Patchwork
@ 2018-12-17 16:27 ` Patchwork
  2018-12-18 12:56 ` [igt-dev] [PATCH i-g-t v13] lib/igt_fb: Added XYUV format support for testing Maarten Lankhorst
  2 siblings, 0 replies; 4+ messages in thread
From: Patchwork @ 2018-12-17 16:27 UTC (permalink / raw)
  To: Stanislav Lisovskiy; +Cc: igt-dev

== Series Details ==

Series: lib/igt_fb: Added XYUV format support for testing (rev15)
URL   : https://patchwork.freedesktop.org/series/48789/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_5324_full -> IGTPW_2164_full
====================================================

Summary
-------

  **WARNING**

  Minor unknown changes coming with IGTPW_2164_full need to be verified
  manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in IGTPW_2164_full, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/48789/revisions/15/mbox/

Possible new issues
-------------------

  Here are the unknown changes that may have been introduced in IGTPW_2164_full:

### IGT changes ###

#### Warnings ####

  * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-render:
    - shard-snb:          SKIP -> PASS

  * igt@pm_rc6_residency@rc6-accuracy:
    - shard-kbl:          SKIP -> PASS
    - shard-snb:          PASS -> SKIP

  
Known issues
------------

  Here are the changes found in IGTPW_2164_full that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@kms_available_modes_crc@available_mode_test_crc:
    - shard-apl:          PASS -> FAIL [fdo#106641]

  * igt@kms_busy@extended-pageflip-modeset-hang-oldfb-render-b:
    - shard-glk:          PASS -> DMESG-WARN [fdo#107956]

  * igt@kms_color@pipe-c-ctm-max:
    - shard-apl:          PASS -> FAIL [fdo#108147]

  * igt@kms_cursor_crc@cursor-256x85-random:
    - shard-apl:          PASS -> FAIL [fdo#103232] +6

  * igt@kms_cursor_crc@cursor-64x21-onscreen:
    - shard-kbl:          PASS -> FAIL [fdo#103232] +2
    - shard-glk:          PASS -> FAIL [fdo#103232] +3

  * igt@kms_flip@2x-modeset-vs-vblank-race:
    - shard-glk:          PASS -> FAIL [fdo#103060]

  * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-draw-mmap-cpu:
    - shard-kbl:          PASS -> FAIL [fdo#103167]

  * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-mmap-gtt:
    - shard-apl:          PASS -> FAIL [fdo#103167] +4

  * igt@kms_frontbuffer_tracking@fbc-2p-primscrn-cur-indfb-move:
    - shard-glk:          PASS -> FAIL [fdo#103167] +4

  * igt@kms_plane@plane-panning-bottom-right-suspend-pipe-b-planes:
    - shard-apl:          PASS -> DMESG-WARN [fdo#108566]

  * igt@kms_plane@plane-position-covered-pipe-b-planes:
    - shard-glk:          PASS -> FAIL [fdo#103166] +2

  * igt@kms_plane_multiple@atomic-pipe-b-tiling-y:
    - shard-apl:          NOTRUN -> FAIL [fdo#103166]
    - shard-kbl:          PASS -> FAIL [fdo#103166] +1

  * igt@kms_plane_multiple@atomic-pipe-c-tiling-yf:
    - shard-apl:          PASS -> FAIL [fdo#103166] +2

  * igt@kms_setmode@basic:
    - shard-apl:          PASS -> FAIL [fdo#99912]
    - shard-hsw:          PASS -> FAIL [fdo#99912]

  
#### Possible fixes ####

  * igt@kms_ccs@pipe-a-crc-sprite-planes-basic:
    - shard-apl:          FAIL [fdo#106510] / [fdo#108145] -> PASS
    - shard-glk:          FAIL [fdo#108145] -> PASS
    - shard-kbl:          FAIL [fdo#107725] / [fdo#108145] -> PASS

  * igt@kms_color@pipe-c-legacy-gamma:
    - shard-kbl:          FAIL [fdo#104782] -> PASS
    - shard-apl:          FAIL [fdo#104782] -> PASS

  * igt@kms_cursor_crc@cursor-128x128-dpms:
    - shard-glk:          FAIL [fdo#103232] -> PASS

  * igt@kms_cursor_crc@cursor-128x128-onscreen:
    - shard-apl:          FAIL [fdo#103232] -> PASS +3

  * igt@kms_cursor_crc@cursor-128x128-suspend:
    - shard-apl:          FAIL [fdo#103191] / [fdo#103232] -> PASS +1

  * igt@kms_cursor_crc@cursor-256x256-dpms:
    - shard-kbl:          FAIL [fdo#103232] -> PASS

  * igt@kms_cursor_crc@cursor-64x64-suspend:
    - shard-kbl:          FAIL [fdo#103191] / [fdo#103232] -> PASS

  * igt@kms_flip@plain-flip-fb-recreate:
    - shard-apl:          INCOMPLETE [fdo#103927] -> PASS

  * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-onoff:
    - shard-apl:          FAIL [fdo#103167] -> PASS +2
    - shard-kbl:          FAIL [fdo#103167] -> PASS +2

  * igt@kms_frontbuffer_tracking@fbc-2p-primscrn-cur-indfb-draw-blt:
    - shard-glk:          FAIL [fdo#103167] -> PASS +6

  * igt@kms_pipe_crc_basic@hang-read-crc-pipe-c:
    - shard-apl:          DMESG-WARN [fdo#103558] / [fdo#105602] -> PASS +20

  * igt@kms_plane_multiple@atomic-pipe-a-tiling-x:
    - shard-apl:          FAIL [fdo#103166] -> PASS +3

  * igt@kms_plane_multiple@atomic-pipe-a-tiling-y:
    - shard-glk:          FAIL [fdo#103166] -> PASS +3
    - shard-kbl:          FAIL [fdo#103166] -> PASS

  * igt@kms_plane_multiple@atomic-pipe-b-tiling-yf:
    - shard-apl:          DMESG-FAIL [fdo#103166] / [fdo#103558] / [fdo#105602] -> PASS

  * igt@kms_rotation_crc@multiplane-rotation-cropping-top:
    - shard-glk:          DMESG-FAIL [fdo#105763] / [fdo#106538] -> PASS

  
#### Warnings ####

  * igt@i915_suspend@shrink:
    - shard-snb:          DMESG-WARN [fdo#108784] -> INCOMPLETE [fdo#105411] / [fdo#106886]

  
  [fdo#103060]: https://bugs.freedesktop.org/show_bug.cgi?id=103060
  [fdo#103166]: https://bugs.freedesktop.org/show_bug.cgi?id=103166
  [fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
  [fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
  [fdo#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232
  [fdo#103558]: https://bugs.freedesktop.org/show_bug.cgi?id=103558
  [fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
  [fdo#104782]: https://bugs.freedesktop.org/show_bug.cgi?id=104782
  [fdo#105411]: https://bugs.freedesktop.org/show_bug.cgi?id=105411
  [fdo#105602]: https://bugs.freedesktop.org/show_bug.cgi?id=105602
  [fdo#105763]: https://bugs.freedesktop.org/show_bug.cgi?id=105763
  [fdo#106510]: https://bugs.freedesktop.org/show_bug.cgi?id=106510
  [fdo#106538]: https://bugs.freedesktop.org/show_bug.cgi?id=106538
  [fdo#106641]: https://bugs.freedesktop.org/show_bug.cgi?id=106641
  [fdo#106886]: https://bugs.freedesktop.org/show_bug.cgi?id=106886
  [fdo#107725]: https://bugs.freedesktop.org/show_bug.cgi?id=107725
  [fdo#107956]: https://bugs.freedesktop.org/show_bug.cgi?id=107956
  [fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
  [fdo#108147]: https://bugs.freedesktop.org/show_bug.cgi?id=108147
  [fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
  [fdo#108784]: https://bugs.freedesktop.org/show_bug.cgi?id=108784
  [fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912


Participating hosts (7 -> 5)
------------------------------

  Missing    (2): shard-skl shard-iclb 


Build changes
-------------

    * IGT: IGT_4748 -> IGTPW_2164
    * Piglit: piglit_4509 -> None

  CI_DRM_5324: 93009153b9bde1d65ca49bb1729cd1111591144b @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_2164: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2164/
  IGT_4748: 90c76cb9bb47a5a3ebb34ad6b1a557bc02d39713 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2164/
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [igt-dev] [PATCH i-g-t v13] lib/igt_fb: Added XYUV format support for testing
  2018-12-17 14:30 [igt-dev] [PATCH i-g-t v13] lib/igt_fb: Added XYUV format support for testing Stanislav Lisovskiy
  2018-12-17 15:00 ` [igt-dev] ✓ Fi.CI.BAT: success for lib/igt_fb: Added XYUV format support for testing (rev15) Patchwork
  2018-12-17 16:27 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
@ 2018-12-18 12:56 ` Maarten Lankhorst
  2 siblings, 0 replies; 4+ messages in thread
From: Maarten Lankhorst @ 2018-12-18 12:56 UTC (permalink / raw)
  To: Stanislav Lisovskiy, igt-dev; +Cc: ville.syrjala, martin.peres

Op 17-12-2018 om 15:30 schreef Stanislav Lisovskiy:
> XYUV format support has been added to DRM, modified
> IGT to reflect those changes.
>
> v2: Fixed merge conflict, started to use new yuv<=>rgb
>     conversion functions.
>
> v3: Fixed kms_available_modes_crc test to support new XYUV
>     format. Fixed a problem, where test complains that two
>     outputs might use same pipe at the same time.
>
> v4: Fixed convertion procedure in igt_fb to support XYUV
>     properly.
>
> v5: Fixed a coding typo.
>
> v6: Set depth equal to -1 for XYUV format in order to prevent
>     it to be used by igt_bpp_depth_to_drm_format, as we do not
>     want YUV formats to be used in that case.
>
> v7: Fix "black" color initialization for create_bo_for_fb with
>     proper value. Changed naming "planar_stride" to "xyuv_stride".
>
> v8: Change naming from DRM_FORMAT_XYUV to DRM_FORMAT_XYUV8888
>
> v9: Fixed compilation errors by rebasing to recent master.
>
> v10: Adding reference to correspondent kernel commit with the new format
>      in include/drm-uapi
>
> v11: Removed unnecessary sizeof's in rgb <=> yuv444 convert functions.
>
> v12: Rebased against master branch, fixed rebase conflict caused by
>      new fb_convert functions. Removed drm kernel commit reference
>      as it is still not merged, so doesn't make sense to use it.
>
> v13: Resolved one more rebase conflict.
>
> Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
> ---
>  include/drm-uapi/drm_fourcc.h |  2 +-
>  lib/igt_fb.c                  | 89 +++++++++++++++++++++++++++++++++++
>  2 files changed, 90 insertions(+), 1 deletion(-)
>
> diff --git a/include/drm-uapi/drm_fourcc.h b/include/drm-uapi/drm_fourcc.h
> index 0b44260a..4ddf754b 100644
> --- a/include/drm-uapi/drm_fourcc.h
> +++ b/include/drm-uapi/drm_fourcc.h
> @@ -151,7 +151,7 @@ extern "C" {
>  #define DRM_FORMAT_VYUY		fourcc_code('V', 'Y', 'U', 'Y') /* [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian */
>  
>  #define DRM_FORMAT_AYUV		fourcc_code('A', 'Y', 'U', 'V') /* [31:0] A:Y:Cb:Cr 8:8:8:8 little endian */
> -#define DRM_FORMAT_XYUV8888		fourcc_code('X', 'Y', 'U', 'V') /* [31:0] X:Y:Cb:Cr 8:8:8:8 little endian */
> +#define DRM_FORMAT_XYUV8888	fourcc_code('X', 'Y', 'U', 'V') /* [31:0] X:Y:Cb:Cr 8:8:8:8 little endian */
>  
>  /*
>   * packed YCbCr420 2x2 tiled formats
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index 2462d6ba..57264844 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -102,6 +102,10 @@ static const struct format_desc_struct {
>  	  .pixman_id = PIXMAN_r8g8b8,
>  	  .num_planes = 1, .plane_bpp = { 24, },
>  	},
> +	{ .name = "XYUV8888", .depth = -1, .drm_id = DRM_FORMAT_XYUV8888,
> +	  .cairo_id = CAIRO_FORMAT_RGB24,
> +	  .num_planes = 1, .plane_bpp = { 32, },
> +	},
>  	{ .name = "XRGB8888", .depth = 24, .drm_id = DRM_FORMAT_XRGB8888,
>  	  .cairo_id = CAIRO_FORMAT_RGB24,
>  	  .pixman_id = PIXMAN_x8r8g8b8,
> @@ -496,6 +500,10 @@ static int create_bo_for_fb(struct igt_fb *fb)
>  				       0x80,
>  				       fb->strides[1] * fb->plane_height[1]);
>  				break;
> +			case DRM_FORMAT_XYUV8888:
> +				wmemset(ptr + fb->offsets[0], full_range ? 0x00008080 : 0x00108080,
> +					fb->strides[0] * fb->plane_height[0] / sizeof(wchar_t));
> +				break;
>  			case DRM_FORMAT_YUYV:
>  			case DRM_FORMAT_YVYU:
>  				wmemset(ptr + fb->offsets[0],
> @@ -1649,6 +1657,79 @@ static void convert_nv12_to_rgb24(struct fb_convert *cvt)
>  	convert_src_put(cvt, buf);
>  }
>  
> +static void convert_yuv444_to_rgb24(struct fb_convert *cvt)
> +{
> +	int i, j;
> +	uint8_t *yuv24;
> +	uint8_t *rgb24 = cvt->dst.ptr;
> +	unsigned rgb24_stride = cvt->dst.fb->strides[0], xyuv_stride = cvt->src.fb->strides[0];
> +	uint8_t *buf = malloc(cvt->src.fb->size);
> +	struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(cvt->src.fb->color_encoding,
> +						    cvt->src.fb->color_range);
> +
> +	/*
> +	 * Reading from the BO is awfully slow because of lack of read caching,
> +	 * it's faster to copy the whole BO to a temporary buffer and convert
> +	 * from there.
> +	 */
> +	igt_memcpy_from_wc(buf, cvt->src.ptr + cvt->src.fb->offsets[0], cvt->src.fb->size);
> +	yuv24 = buf;
> +
> +	for (i = 0; i < cvt->dst.fb->height; i++) {
> +		for (j = 0; j < cvt->dst.fb->width; j++) {
> +			float y, u, v;
> +			struct igt_vec4 yuv;
> +			struct igt_vec4 rgb;
> +
> +			v = yuv24[i * xyuv_stride + j * 4];
> +			u = yuv24[i * xyuv_stride + j * 4 + 1];
> +			y = yuv24[i * xyuv_stride + j * 4 + 2];
> +			yuv.d[0] = y;
> +			yuv.d[1] = u;
> +			yuv.d[2] = v;
> +			yuv.d[3] = 1.0f;
> +
> +			rgb = igt_matrix_transform(&m, &yuv);
> +
> +			write_rgb(&rgb24[i * rgb24_stride + j * 4], &rgb);
> +		}
> +	}
> +
> +	free(buf);
> +}
> +
> +
> +static void convert_rgb24_to_yuv444(struct fb_convert *cvt)
> +{
> +	int i, j;
> +	uint8_t *rgb24;
> +	uint8_t *yuv444 = cvt->dst.ptr + cvt->dst.fb->offsets[0];
> +	unsigned int rgb24_stride = cvt->src.fb->strides[0], xyuv_stride = cvt->dst.fb->strides[0];
> +	struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(cvt->dst.fb->color_encoding,
> +						    cvt->dst.fb->color_range);
> +
> +	rgb24 = cvt->src.ptr;
> +
> +	igt_assert_f(cvt->dst.fb->drm_format == DRM_FORMAT_XYUV8888,
> +		     "Conversion not implemented for !XYUV packed formats\n");
> +
> +	for (i = 0; i < cvt->dst.fb->height; i++) {
> +		for (j = 0; j < cvt->dst.fb->width; j++) {
> +			struct igt_vec4 rgb;
> +			struct igt_vec4 yuv;
> +			float y, u, v;
> +
> +			read_rgb(&rgb, &rgb24[i * rgb24_stride + j * 4]);
> +
> +			yuv = igt_matrix_transform(&m, &rgb);
> +
> +			yuv444[i * xyuv_stride + j * 4] = yuv.d[2];
> +			yuv444[i * xyuv_stride + j * 4 + 1] = yuv.d[1];
> +			yuv444[i * xyuv_stride + j * 4 + 2] = yuv.d[0];
> +		}
> +	}
> +}
> +
>  static void convert_rgb24_to_nv12(struct fb_convert *cvt)
>  {
>  	int i, j;
> @@ -1934,6 +2015,9 @@ static void fb_convert(struct fb_convert *cvt)
>  		return;
>  	} else if (cvt->dst.fb->drm_format == DRM_FORMAT_XRGB8888) {
>  		switch (cvt->src.fb->drm_format) {
> +		case DRM_FORMAT_XYUV8888:
> +			convert_yuv444_to_rgb24(cvt);
> +			return;
>  		case DRM_FORMAT_NV12:
>  			convert_nv12_to_rgb24(cvt);
>  			return;
> @@ -1946,6 +2030,9 @@ static void fb_convert(struct fb_convert *cvt)
>  		}
>  	} else if (cvt->src.fb->drm_format == DRM_FORMAT_XRGB8888) {
>  		switch (cvt->dst.fb->drm_format) {
> +		case DRM_FORMAT_XYUV8888:
> +			convert_rgb24_to_yuv444(cvt);
> +			return;
>  		case DRM_FORMAT_NV12:
>  			convert_rgb24_to_nv12(cvt);
>  			return;
> @@ -2037,6 +2124,7 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)
>  				    blit, destroy_cairo_surface__convert);
>  }
>  
> +
>  /**
>   * igt_fb_map_buffer:
>   * @fd: open drm file descriptor
> @@ -2302,6 +2390,7 @@ bool igt_format_is_yuv(uint32_t drm_format)
>  	case DRM_FORMAT_YVYU:
>  	case DRM_FORMAT_UYVY:
>  	case DRM_FORMAT_VYUY:
> +	case DRM_FORMAT_XYUV8888:
>  		return true;
>  	default:
>  		return false;

Would be nice if this was extended to AYUV as well, but oh well.

Pushed. :)

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-12-18 12:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-17 14:30 [igt-dev] [PATCH i-g-t v13] lib/igt_fb: Added XYUV format support for testing Stanislav Lisovskiy
2018-12-17 15:00 ` [igt-dev] ✓ Fi.CI.BAT: success for lib/igt_fb: Added XYUV format support for testing (rev15) Patchwork
2018-12-17 16:27 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2018-12-18 12:56 ` [igt-dev] [PATCH i-g-t v13] lib/igt_fb: Added XYUV format support for testing Maarten Lankhorst

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.