[igt-dev] [PATCH i-g-t v4 11/21] lib/igt_fb: Pass the modifier to igt_fb_convert helpers

Paul Kocialkowski paul.kocialkowski at bootlin.com
Fri Jan 25 14:06:13 UTC 2019


The modifier is part of how a frame is represented, so add it as an
extra argument so that it can be specified when converting framebuffers.

For now, only a linear modifier is supported.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski at bootlin.com>
---
 lib/igt_fb.c          | 14 ++++++++++----
 lib/igt_fb.h          |  3 ++-
 tests/kms_chamelium.c |  3 ++-
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 4c97e99bf06b..b24356fa07e4 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -2254,6 +2254,7 @@ void igt_remove_fb(int fd, struct igt_fb *fb)
  * @dst: pointer to the #igt_fb structure that will store the conversion result
  * @src: pointer to the #igt_fb structure that stores the frame we convert
  * @dst_fourcc: DRM format specifier to convert to
+ * @dst_modifier: DRM format modifier to convert to
  * @dst_stride: Stride for the resulting framebuffer (0 for automatic stride)
  *
  * This will convert a given @src content to the @dst_fourcc format,
@@ -2268,6 +2269,7 @@ void igt_remove_fb(int fd, struct igt_fb *fb)
  */
 unsigned int igt_fb_convert_with_stride(struct igt_fb *dst, struct igt_fb *src,
 					uint32_t dst_fourcc,
+					uint64_t dst_modifier,
 					unsigned int dst_stride)
 {
 	struct fb_convert cvt = { };
@@ -2276,8 +2278,8 @@ 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,
-					   LOCAL_DRM_FORMAT_MOD_NONE,
-					   dst, 0, dst_stride);
+					   LOCAL_DRM_FORMAT_MOD_NONE, dst, 0,
+					   dst_stride);
 	igt_assert(fb_id > 0);
 
 	src_ptr = igt_fb_map_buffer(src->fd, src);
@@ -2295,6 +2297,8 @@ unsigned int igt_fb_convert_with_stride(struct igt_fb *dst, struct igt_fb *src,
 	igt_fb_unmap_buffer(dst, dst_ptr);
 	igt_fb_unmap_buffer(src, src_ptr);
 
+	igt_assert(dst_modifier == LOCAL_DRM_FORMAT_MOD_NONE);
+
 	return fb_id;
 }
 
@@ -2303,6 +2307,7 @@ unsigned int igt_fb_convert_with_stride(struct igt_fb *dst, struct igt_fb *src,
  * @dst: pointer to the #igt_fb structure that will store the conversion result
  * @src: pointer to the #igt_fb structure that stores the frame we convert
  * @dst_fourcc: DRM format specifier to convert to
+ * @dst_modifier: DRM format modifier to convert to
  *
  * This will convert a given @src content to the @dst_fourcc format,
  * storing the result in the @dst fb, allocating the @dst fb
@@ -2315,9 +2320,10 @@ unsigned int igt_fb_convert_with_stride(struct igt_fb *dst, struct igt_fb *src,
  * The kms id of the created framebuffer.
  */
 unsigned int igt_fb_convert(struct igt_fb *dst, struct igt_fb *src,
-			    uint32_t dst_fourcc)
+			    uint32_t dst_fourcc, uint64_t dst_modifier)
 {
-	return igt_fb_convert_with_stride(dst, src, dst_fourcc, 0);
+	return igt_fb_convert_with_stride(dst, src, dst_fourcc, dst_modifier,
+					  0);
 }
 
 /**
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index c6edddec1d76..9a6c5e3cd518 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -132,9 +132,10 @@ unsigned int igt_create_stereo_fb(int drm_fd, drmModeModeInfo *mode,
 				  uint32_t format, uint64_t tiling);
 unsigned int igt_fb_convert_with_stride(struct igt_fb *dst, struct igt_fb *src,
 					uint32_t dst_fourcc,
+					uint64_t dst_modifier,
 					unsigned int stride);
 unsigned int igt_fb_convert(struct igt_fb *dst, struct igt_fb *src,
-			    uint32_t dst_fourcc);
+			    uint32_t dst_fourcc, uint64_t dst_modifier);
 void igt_remove_fb(int fd, struct igt_fb *fb);
 int igt_dirty_fb(int fd, struct igt_fb *fb);
 void *igt_fb_map_buffer(int fd, struct igt_fb *fb);
diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
index 64f87d3ae474..fe58aea98e86 100644
--- a/tests/kms_chamelium.c
+++ b/tests/kms_chamelium.c
@@ -546,7 +546,8 @@ static void do_test_display(data_t *data, struct chamelium_port *port,
 					 DRM_FORMAT_XRGB8888, 64, &fb);
 	igt_assert(fb_id > 0);
 
-	frame_id = igt_fb_convert(&frame_fb, &fb, fourcc);
+	frame_id = igt_fb_convert(&frame_fb, &fb, fourcc,
+				  LOCAL_DRM_FORMAT_MOD_NONE);
 	igt_assert(frame_id > 0);
 
 	if (check == CHAMELIUM_CHECK_CRC)
-- 
2.20.1



More information about the igt-dev mailing list