public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [CI 07/16] fb: Add format conversion routine
Date: Mon,  8 Oct 2018 17:04:24 +0300	[thread overview]
Message-ID: <20181008140433.32399-7-arkadiusz.hiler@intel.com> (raw)
In-Reply-To: <20181008140433.32399-1-arkadiusz.hiler@intel.com>

From: Maxime Ripard <maxime.ripard@bootlin.com>

The chamelium format subtests will need to convert the reference pattern to
the format to be tested on the DRM device.

However, Cairo is very limited when it comes to format, and while pixman
has much more support for formats, it's still falling short compared to
what DRM exposes, especially on the YUV side. Plus, since we want to run
CRC checks on the frame, we can't afford having conversions back and forth
between RGB24, as the current API is doing.

In order to abstract this away, let's create a function that will convert a
igt_fb structure to another DRM format and return the converted igt_fb.

For now, we will use only cairo to do the conversion, but we will use other
libraries or roll our own routines to convert to more exotic formats and
abstract it away from the users.

Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
---
 lib/igt_fb.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_fb.h |  2 ++
 2 files changed, 47 insertions(+)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index dc227493..bd9ebf50 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -2036,6 +2036,51 @@ void igt_remove_fb(int fd, struct igt_fb *fb)
 	fb->fb_id = 0;
 }
 
+/**
+ * igt_fb_convert:
+ * @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
+ *
+ * This will convert a given @src content to the @dst_fourcc format,
+ * storing the result in the @dst fb, allocating the @dst fb
+ * underlying buffer.
+ *
+ * Once done with @dst, the caller will have to call igt_remove_fb()
+ * on it to free the associated resources.
+ *
+ * Returns:
+ * The kms id of the created framebuffer.
+ */
+unsigned int igt_fb_convert(struct igt_fb *dst, struct igt_fb *src,
+			    uint32_t dst_fourcc)
+{
+	struct fb_convert cvt = { 0 };
+	void *dst_ptr, *src_ptr;
+	int fb_id;
+
+	fb_id = igt_create_fb(src->fd, src->width, src->height,
+			      dst_fourcc, LOCAL_DRM_FORMAT_MOD_NONE, dst);
+	igt_assert(fb_id > 0);
+
+	src_ptr = igt_fb_map_buffer(src->fd, src);
+	igt_assert(src_ptr);
+
+	dst_ptr = igt_fb_map_buffer(dst->fd, dst);
+	igt_assert(dst_ptr);
+
+	cvt.dst.ptr = dst_ptr;
+	cvt.dst.fb = dst;
+	cvt.src.ptr = src_ptr;
+	cvt.src.fb = src;
+	fb_convert(&cvt);
+
+	igt_fb_unmap_buffer(dst, dst_ptr);
+	igt_fb_unmap_buffer(src, src_ptr);
+
+	return fb_id;
+}
+
 /**
  * igt_bpp_depth_to_drm_format:
  * @bpp: desired bits per pixel
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index 758d4d0d..9f027deb 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -130,6 +130,8 @@ unsigned int igt_create_image_fb(int drm_fd,  int width, int height,
 				 struct igt_fb *fb /* out */);
 unsigned int igt_create_stereo_fb(int drm_fd, drmModeModeInfo *mode,
 				  uint32_t format, uint64_t tiling);
+unsigned int igt_fb_convert(struct igt_fb *dst, struct igt_fb *src,
+			    uint32_t dst_fourcc);
 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);
-- 
2.17.1

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

  parent reply	other threads:[~2018-10-08 14:05 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-08 14:04 [igt-dev] [CI 01/16] fb: Add buffer map/unmap functions Arkadiusz Hiler
2018-10-08 14:04 ` [igt-dev] [CI 02/16] fb: Only set the GEM domain on intel platforms Arkadiusz Hiler
2018-10-08 14:04 ` [igt-dev] [CI 03/16] fb: Add RGB888 format Arkadiusz Hiler
2018-10-08 14:04 ` [igt-dev] [CI 04/16] fb: Use an igt_fb for the cairo shadow buffer Arkadiusz Hiler
2018-10-08 14:04 ` [igt-dev] [CI 05/16] fb: convert: Remove swizzle from the arguments Arkadiusz Hiler
2018-10-08 14:04 ` [igt-dev] [CI 06/16] fb: Create common function to convert frame formats Arkadiusz Hiler
2018-10-08 14:04 ` Arkadiusz Hiler [this message]
2018-10-08 14:04 ` [igt-dev] [CI 08/16] igt: Make pixman mandatory Arkadiusz Hiler
2018-10-08 14:04 ` [igt-dev] [CI 09/16] tests: kms_plane: Disable XBGR8888 Arkadiusz Hiler
2018-10-08 14:04 ` [igt-dev] [CI 10/16] fb: Add support for conversions through pixman Arkadiusz Hiler
2018-10-08 14:04 ` [igt-dev] [CI 11/16] fb: Add more formats Arkadiusz Hiler
2018-10-08 14:04 ` [igt-dev] [CI 12/16] chamelium: Split CRC test function in two Arkadiusz Hiler
2018-10-08 14:04 ` [igt-dev] [CI 13/16] chamelium: Change our pattern for a custom one if needed Arkadiusz Hiler
2018-10-08 14:04 ` [igt-dev] [CI 14/16] chamelium: Add format support Arkadiusz Hiler
2018-10-08 14:04 ` [igt-dev] [CI 15/16] chamelium: Add format subtests Arkadiusz Hiler
2018-10-08 14:04 ` [igt-dev] [CI 16/16] tests: Add chamelium formats subtests to vc4 test lists Arkadiusz Hiler
2018-10-08 14:56 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [CI,01/16] fb: Add buffer map/unmap functions Patchwork
2018-10-08 16:26 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

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=20181008140433.32399-7-arkadiusz.hiler@intel.com \
    --to=arkadiusz.hiler@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox