All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maxime Ripard <maxime.ripard@bootlin.com>
To: igt-dev@lists.freedesktop.org
Cc: eben@raspberrypi.org,
	Paul Kocialkowski <paul.kocialkowski@bootlin.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: [igt-dev] [PATCH v7 02/14] fb: Use an igt_fb for the cairo shadow buffer
Date: Tue, 11 Sep 2018 10:47:29 +0200	[thread overview]
Message-ID: <3048e3bbb684b05aa15be23e224f3090d7818a7c.1536655647.git-series.maxime.ripard@bootlin.com> (raw)
In-Reply-To: <cover.cafc7aee9c887562e8432741cd1f0543ff92121a.1536655647.git-series.maxime.ripard@bootlin.com>
In-Reply-To: <cover.cafc7aee9c887562e8432741cd1f0543ff92121a.1536655647.git-series.maxime.ripard@bootlin.com>

In the case where an igt_fb user wants to get a cairo surface out of that
framebuffer, if the format of that framebuffer cannot be imported as-is in
Cairo, the current code will do an anonymous mapping to create a shadow
buffer where an RGB24 copy of that buffer will be created.

However, making that shadow buffer into an igt_fb itself will help us do
further improvements on the conversion code.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
---
 lib/igt_fb.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 542c62610412..dd180c6c8016 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -1381,12 +1381,12 @@ static void create_cairo_surface__gtt(int fd, struct igt_fb *fb)
 
 struct fb_convert_blit_upload {
 	int fd;
+
 	struct igt_fb *fb;
+	uint8_t *ptr;
 
-	struct {
-		uint8_t *map;
-		unsigned stride, size;
-	} rgb24;
+	struct igt_fb shadow_fb;
+	uint8_t *shadow_ptr;
 
 	struct fb_blit_linear linear;
 };
@@ -1780,7 +1780,8 @@ static void destroy_cairo_surface__convert(void *arg)
 			     fb->drm_format);
 	}
 
-	munmap(blit->rgb24.map, blit->rgb24.size);
+	igt_fb_unmap_buffer(&blit->shadow_fb, blit->shadow_ptr);
+	igt_remove_fb(blit->fd, &blit->shadow_fb);
 
 	if (blit->linear.handle)
 		free_linear_mapping(blit->fd, blit->fb, &blit->linear);
@@ -1795,14 +1796,19 @@ static void destroy_cairo_surface__convert(void *arg)
 static void create_cairo_surface__convert(int fd, struct igt_fb *fb)
 {
 	struct fb_convert_blit_upload *blit = malloc(sizeof(*blit));
+	int shadow_id;
+
 	igt_assert(blit);
 
 	blit->fd = fd;
 	blit->fb = fb;
-	blit->rgb24.stride = ALIGN(fb->width * 4, 16);
-	blit->rgb24.size = ALIGN(blit->rgb24.stride * fb->height, sysconf(_SC_PAGESIZE));
-	blit->rgb24.map = mmap(NULL, blit->rgb24.size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
-	igt_assert(blit->rgb24.map != MAP_FAILED);
+
+	shadow_id = igt_create_fb(fd, fb->width, fb->height, DRM_FORMAT_RGB888,
+				  LOCAL_DRM_FORMAT_MOD_NONE, &blit->shadow_fb);
+	igt_assert(shadow_id > 0);
+
+	blit->shadow_ptr = igt_fb_map_buffer(fd, &blit->shadow_fb);
+	igt_assert(blit->shadow_ptr);
 
 	if (fb->tiling == LOCAL_I915_FORMAT_MOD_Y_TILED ||
 	    fb->tiling == LOCAL_I915_FORMAT_MOD_Yf_TILED) {
@@ -1834,10 +1840,10 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)
 	}
 
 	fb->cairo_surface =
-		cairo_image_surface_create_for_data(blit->rgb24.map,
+		cairo_image_surface_create_for_data(blit->shadow_ptr,
 						    CAIRO_FORMAT_RGB24,
 						    fb->width, fb->height,
-						    blit->rgb24.stride);
+						    blit->shadow_fb.stride);
 
 	cairo_surface_set_user_data(fb->cairo_surface,
 				    (cairo_user_data_key_t *)create_cairo_surface__convert,
-- 
git-series 0.9.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2018-09-11  8:47 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-11  8:47 [igt-dev] [PATCH v7 00/14] chamelium: Test the plane formats Maxime Ripard
2018-09-11  8:47 ` [igt-dev] [PATCH v7 01/14] fb: Add buffer map/unmap functions Maxime Ripard
2018-09-11  8:47 ` Maxime Ripard [this message]
2018-09-19 13:21   ` [igt-dev] [PATCH v7 02/14] fb: Use an igt_fb for the cairo shadow buffer Ville Syrjälä
2018-09-25  8:51     ` Maxime Ripard
2018-10-01 10:47       ` Arkadiusz Hiler
2018-10-01 13:55         ` Ville Syrjälä
2018-10-01 14:10           ` Arkadiusz Hiler
2018-10-02 14:56             ` Maxime Ripard
2018-09-11  8:47 ` [igt-dev] [PATCH v7 03/14] fb: convert: Remove swizzle from the arguments Maxime Ripard
2018-09-11  8:47 ` [igt-dev] [PATCH v7 04/14] fb: Create common function to convert frame formats Maxime Ripard
2018-09-19 13:03   ` Ville Syrjälä
2018-09-25  7:51     ` Maxime Ripard
2018-09-25 12:20       ` Ville Syrjälä
2018-09-11  8:47 ` [igt-dev] [PATCH v7 05/14] fb: Add format conversion routine Maxime Ripard
2018-09-11  8:47 ` [igt-dev] [PATCH v7 06/14] fb: Fix ARGB8888 color depth Maxime Ripard
2018-09-11  8:47 ` [igt-dev] [PATCH v7 07/14] fb: Add support for conversions through pixman Maxime Ripard
2018-10-01  9:26   ` Petri Latvala
2018-10-02 14:57     ` Maxime Ripard
2018-09-11  8:47 ` [igt-dev] [PATCH v7 08/14] fb: Add depth lookup function Maxime Ripard
2018-09-11  8:47 ` [igt-dev] [PATCH v7 09/14] fb: Add more formats Maxime Ripard
2018-09-19 13:14   ` Ville Syrjälä
2018-09-25  7:49     ` Maxime Ripard
2018-09-25 12:18       ` Ville Syrjälä
2018-09-11  8:47 ` [igt-dev] [PATCH v7 10/14] chamelium: Split CRC test function in two Maxime Ripard
2018-09-11  8:47 ` [igt-dev] [PATCH v7 11/14] chamelium: Change our pattern for a custom one if needed Maxime Ripard
2018-09-11  8:47 ` [igt-dev] [PATCH v7 12/14] chamelium: Add format support Maxime Ripard
2018-09-11  8:47 ` [igt-dev] [PATCH v7 13/14] chamelium: Add format subtests Maxime Ripard
2018-09-11  8:47 ` [igt-dev] [PATCH v7 14/14] tests: Add chamelium formats subtests to vc4 test lists Maxime Ripard
2018-09-12  8:12 ` [igt-dev] ✗ Fi.CI.BAT: failure for chamelium: Test the plane formats (rev6) Patchwork
2018-09-19 12:45 ` [igt-dev] [PATCH v7 00/14] chamelium: Test the plane formats Maxime Ripard

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=3048e3bbb684b05aa15be23e224f3090d7818a7c.1536655647.git-series.maxime.ripard@bootlin.com \
    --to=maxime.ripard@bootlin.com \
    --cc=eben@raspberrypi.org \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=paul.kocialkowski@bootlin.com \
    --cc=thomas.petazzoni@bootlin.com \
    /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.