All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: daniel@ffwll.ch, airlied@gmail.com, mripard@kernel.org,
	maarten.lankhorst@linux.intel.com, thierry.reding@gmail.com,
	sam@ravnborg.org, emma@anholt.net, david@lechnology.com,
	kamlesh.gurudasani@gmail.com, noralf@tronnes.org,
	javierm@redhat.com
Cc: Thomas Zimmermann <tzimmermann@suse.de>, dri-devel@lists.freedesktop.org
Subject: [PATCH 7/8] drm/mipi-dbi: Use shadow-plane mappings
Date: Mon, 21 Nov 2022 11:45:31 +0100	[thread overview]
Message-ID: <20221121104532.8301-8-tzimmermann@suse.de> (raw)
In-Reply-To: <20221121104532.8301-1-tzimmermann@suse.de>

Use the buffer mappings provided by shadow-plane helpers. As the
mappings are established while the commit can still fail, errors
are now reported correctly to callers.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/drm_mipi_dbi.c | 31 +++++++++++--------------------
 drivers/gpu/drm/tiny/ili9225.c | 28 ++++++++++------------------
 drivers/gpu/drm/tiny/st7586.c  | 22 ++++++++++------------
 3 files changed, 31 insertions(+), 50 deletions(-)

diff --git a/drivers/gpu/drm/drm_mipi_dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c
index 3030344d25b48..d45824a65c9fd 100644
--- a/drivers/gpu/drm/drm_mipi_dbi.c
+++ b/drivers/gpu/drm/drm_mipi_dbi.c
@@ -323,12 +323,13 @@ EXPORT_SYMBOL(mipi_dbi_pipe_mode_valid);
 void mipi_dbi_pipe_update(struct drm_simple_display_pipe *pipe,
 			  struct drm_plane_state *old_state)
 {
-	struct iosys_map map[DRM_FORMAT_MAX_PLANES];
-	struct iosys_map data[DRM_FORMAT_MAX_PLANES];
 	struct drm_plane_state *state = pipe->plane.state;
+	struct mipi_dbi_plane_state *mipi_dbi_plane_state =
+		to_mipi_dbi_plane_state(state);
+	struct drm_shadow_plane_state *shadow_plane_state =
+		&mipi_dbi_plane_state->shadow_plane_state;
 	struct drm_framebuffer *fb = state->fb;
 	struct drm_rect rect;
-	int ret;
 
 	if (!pipe->crtc.state->active)
 		return;
@@ -336,14 +337,8 @@ void mipi_dbi_pipe_update(struct drm_simple_display_pipe *pipe,
 	if (WARN_ON(!fb))
 		return;
 
-	ret = drm_gem_fb_vmap(fb, map, data);
-	if (ret)
-		return;
-
 	if (drm_atomic_helper_damage_merged(old_state, state, &rect))
-		mipi_dbi_fb_dirty(&data[0], fb, &rect);
-
-	drm_gem_fb_vunmap(fb, map);
+		mipi_dbi_fb_dirty(&shadow_plane_state->data[0], fb, &rect);
 }
 EXPORT_SYMBOL(mipi_dbi_pipe_update);
 
@@ -364,6 +359,10 @@ void mipi_dbi_enable_flush(struct mipi_dbi_dev *dbidev,
 			   struct drm_crtc_state *crtc_state,
 			   struct drm_plane_state *plane_state)
 {
+	struct mipi_dbi_plane_state *mipi_dbi_plane_state =
+		to_mipi_dbi_plane_state(plane_state);
+	struct drm_shadow_plane_state *shadow_plane_state =
+		&mipi_dbi_plane_state->shadow_plane_state;
 	struct drm_framebuffer *fb = plane_state->fb;
 	struct drm_rect rect = {
 		.x1 = 0,
@@ -371,22 +370,14 @@ void mipi_dbi_enable_flush(struct mipi_dbi_dev *dbidev,
 		.y1 = 0,
 		.y2 = fb->height,
 	};
-	struct iosys_map map[DRM_FORMAT_MAX_PLANES];
-	struct iosys_map data[DRM_FORMAT_MAX_PLANES];
-	int idx, ret;
+	int idx;
 
 	if (!drm_dev_enter(&dbidev->drm, &idx))
 		return;
 
-	ret = drm_gem_fb_vmap(fb, map, data);
-	if (ret)
-		goto err_drm_dev_exit;
-
-	mipi_dbi_fb_dirty(&data[0], fb, &rect);
+	mipi_dbi_fb_dirty(&shadow_plane_state->data[0], fb, &rect);
 	backlight_enable(dbidev->backlight);
 
-	drm_gem_fb_vunmap(fb, map);
-err_drm_dev_exit:
 	drm_dev_exit(idx);
 }
 EXPORT_SYMBOL(mipi_dbi_enable_flush);
diff --git a/drivers/gpu/drm/tiny/ili9225.c b/drivers/gpu/drm/tiny/ili9225.c
index 9e55ce28b4552..ba5681b63ffbf 100644
--- a/drivers/gpu/drm/tiny/ili9225.c
+++ b/drivers/gpu/drm/tiny/ili9225.c
@@ -163,24 +163,19 @@ static void ili9225_fb_dirty(struct iosys_map *src, struct drm_framebuffer *fb,
 static void ili9225_pipe_update(struct drm_simple_display_pipe *pipe,
 				struct drm_plane_state *old_state)
 {
-	struct iosys_map map[DRM_FORMAT_MAX_PLANES];
-	struct iosys_map data[DRM_FORMAT_MAX_PLANES];
 	struct drm_plane_state *state = pipe->plane.state;
+	struct mipi_dbi_plane_state *mipi_dbi_plane_state =
+		to_mipi_dbi_plane_state(state);
+	struct drm_shadow_plane_state *shadow_plane_state =
+		&mipi_dbi_plane_state->shadow_plane_state;
 	struct drm_framebuffer *fb = state->fb;
 	struct drm_rect rect;
-	int ret;
 
 	if (!pipe->crtc.state->active)
 		return;
 
-	ret = drm_gem_fb_vmap(fb, map, data);
-	if (ret)
-		return;
-
 	if (drm_atomic_helper_damage_merged(old_state, state, &rect))
-		ili9225_fb_dirty(&data[0], fb, &rect);
-
-	drm_gem_fb_vunmap(fb, map);
+		ili9225_fb_dirty(&shadow_plane_state->data[0], fb, &rect);
 }
 
 static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe,
@@ -188,6 +183,10 @@ static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe,
 				struct drm_plane_state *plane_state)
 {
 	struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev);
+	struct mipi_dbi_plane_state *mipi_dbi_plane_state =
+		to_mipi_dbi_plane_state(plane_state);
+	struct drm_shadow_plane_state *shadow_plane_state =
+		&mipi_dbi_plane_state->shadow_plane_state;
 	struct drm_framebuffer *fb = plane_state->fb;
 	struct device *dev = pipe->crtc.dev->dev;
 	struct mipi_dbi *dbi = &dbidev->dbi;
@@ -197,8 +196,6 @@ static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe,
 		.y1 = 0,
 		.y2 = fb->height,
 	};
-	struct iosys_map map[DRM_FORMAT_MAX_PLANES];
-	struct iosys_map data[DRM_FORMAT_MAX_PLANES];
 	int ret, idx;
 	u8 am_id;
 
@@ -289,13 +286,8 @@ static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe,
 
 	ili9225_command(dbi, ILI9225_DISPLAY_CONTROL_1, 0x1017);
 
-	ret = drm_gem_fb_vmap(fb, map, data);
-	if (ret)
-		goto out_exit;
-
-	ili9225_fb_dirty(&data[0], fb, &rect);
+	ili9225_fb_dirty(&shadow_plane_state->data[0], fb, &rect);
 
-	drm_gem_fb_vunmap(fb, map);
 out_exit:
 	drm_dev_exit(idx);
 }
diff --git a/drivers/gpu/drm/tiny/st7586.c b/drivers/gpu/drm/tiny/st7586.c
index 76b13cefc904f..ddaa82c2e58ae 100644
--- a/drivers/gpu/drm/tiny/st7586.c
+++ b/drivers/gpu/drm/tiny/st7586.c
@@ -153,19 +153,18 @@ static void st7586_pipe_update(struct drm_simple_display_pipe *pipe,
 			       struct drm_plane_state *old_state)
 {
 	struct drm_plane_state *state = pipe->plane.state;
+	struct mipi_dbi_plane_state *mipi_dbi_plane_state =
+		to_mipi_dbi_plane_state(state);
+	struct drm_shadow_plane_state *shadow_plane_state =
+		&mipi_dbi_plane_state->shadow_plane_state;
 	struct drm_framebuffer *fb = state->fb;
-	struct drm_gem_dma_object *dma_obj;
-	struct iosys_map src;
 	struct drm_rect rect;
 
 	if (!pipe->crtc.state->active)
 		return;
 
-	dma_obj = drm_fb_dma_get_gem_obj(fb, 0);
-	iosys_map_set_vaddr(&src, dma_obj->vaddr);
-
 	if (drm_atomic_helper_damage_merged(old_state, state, &rect))
-		st7586_fb_dirty(&src, fb, &rect);
+		st7586_fb_dirty(&shadow_plane_state->data[0], fb, &rect);
 }
 
 static void st7586_pipe_enable(struct drm_simple_display_pipe *pipe,
@@ -173,6 +172,10 @@ static void st7586_pipe_enable(struct drm_simple_display_pipe *pipe,
 			       struct drm_plane_state *plane_state)
 {
 	struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev);
+	struct mipi_dbi_plane_state *mipi_dbi_plane_state =
+		to_mipi_dbi_plane_state(plane_state);
+	struct drm_shadow_plane_state *shadow_plane_state =
+		&mipi_dbi_plane_state->shadow_plane_state;
 	struct drm_framebuffer *fb = plane_state->fb;
 	struct mipi_dbi *dbi = &dbidev->dbi;
 	struct drm_rect rect = {
@@ -181,8 +184,6 @@ static void st7586_pipe_enable(struct drm_simple_display_pipe *pipe,
 		.y1 = 0,
 		.y2 = fb->height,
 	};
-	struct drm_gem_dma_object *dma_obj;
-	struct iosys_map src;
 	int idx, ret;
 	u8 addr_mode;
 
@@ -242,10 +243,7 @@ static void st7586_pipe_enable(struct drm_simple_display_pipe *pipe,
 
 	msleep(100);
 
-	dma_obj = drm_fb_dma_get_gem_obj(fb, 0);
-	iosys_map_set_vaddr(&src, dma_obj->vaddr);
-
-	st7586_fb_dirty(&src, fb, &rect);
+	st7586_fb_dirty(&shadow_plane_state->data[0], fb, &rect);
 
 	mipi_dbi_command(dbi, MIPI_DCS_SET_DISPLAY_ON);
 out_exit:
-- 
2.38.1


  parent reply	other threads:[~2022-11-21 10:46 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-21 10:45 [PATCH 0/8] drm/mipi-dbi: Convert to shadow-plane helpers Thomas Zimmermann
2022-11-21 10:45 ` [PATCH 1/8] drm/simple-kms: Remove drm_gem_simple_display_pipe_prepare_fb() Thomas Zimmermann
2022-11-25 16:45   ` Noralf Trønnes
2022-11-21 10:45 ` [PATCH 2/8] drm/ili9225: Call MIPI DBI mode_valid helper Thomas Zimmermann
2022-11-25 16:52   ` Noralf Trønnes
2022-11-21 10:45 ` [PATCH 3/8] drm/st7586: " Thomas Zimmermann
2022-11-25 16:52   ` Noralf Trønnes
2022-11-21 10:45 ` [PATCH 4/8] drm/mipi-dbi: Initialize default driver functions with macro Thomas Zimmermann
2022-11-25 17:05   ` Noralf Trønnes
2022-11-21 10:45 ` [PATCH 5/8] drm/mipi-dbi: Prepare framebuffer copy operation in pipe-update helpers Thomas Zimmermann
2022-11-25 17:39   ` Noralf Trønnes
2022-12-02 11:27     ` Thomas Zimmermann
2022-12-02 11:50       ` Thomas Zimmermann
2022-12-02 12:22         ` Noralf Trønnes
2022-12-02 12:04       ` Noralf Trønnes
2022-11-21 10:45 ` [PATCH 6/8] drm/mipi-dbi: Support shadow-plane state Thomas Zimmermann
2022-11-25 17:48   ` Noralf Trønnes
2022-11-28 12:10     ` Thomas Zimmermann
2022-11-28 13:06       ` Noralf Trønnes
2022-11-21 10:45 ` Thomas Zimmermann [this message]
2022-11-28 13:07   ` [PATCH 7/8] drm/mipi-dbi: Use shadow-plane mappings Noralf Trønnes
2022-11-21 10:45 ` [PATCH 8/8] drm/mipi-dbi: Move drm_dev_{enter, exit}() out from fb_dirty functions Thomas Zimmermann
2022-11-25 17:56   ` [PATCH 8/8] drm/mipi-dbi: Move drm_dev_{enter,exit}() " Noralf Trønnes
2022-11-21 12:27 ` [PATCH 0/8] drm/mipi-dbi: Convert to shadow-plane helpers Noralf Trønnes
2022-11-21 12:41   ` Thomas Zimmermann
2022-11-21 15:14     ` Noralf Trønnes
2022-11-21 15:22   ` Javier Martinez Canillas
2022-11-25 18:00 ` Noralf Trønnes
2022-11-30  7:19 ` Javier Martinez Canillas

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=20221121104532.8301-8-tzimmermann@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@gmail.com \
    --cc=daniel@ffwll.ch \
    --cc=david@lechnology.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emma@anholt.net \
    --cc=javierm@redhat.com \
    --cc=kamlesh.gurudasani@gmail.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=noralf@tronnes.org \
    --cc=sam@ravnborg.org \
    --cc=thierry.reding@gmail.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.