diff mbox

[PATCH/RFC,368/390] drm/rcar-du: Don't re-reserve hardware plane at each update

Message ID 1364525119-31791-369-git-send-email-horms+renesas@verge.net.au (mailing list archive)
State New, archived
Headers show

Commit Message

Simon Horman March 29, 2013, 2:44 a.m. UTC
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

Hardware planes only need to be reserved if not already reserved, or if
the number of required planes has changed. Release the previously
reserved planes (if any) and reserve new ones in that case.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
(cherry picked from commit c38cbeedb6536f8bf9bad0d17fcdceb9bf727583)

Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 drivers/gpu/drm/rcar-du/rcar_du_plane.c |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
index 110fd13..220ca00 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
@@ -206,6 +206,7 @@  rcar_du_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
 	struct rcar_du_plane *rplane = to_rcar_plane(plane);
 	struct rcar_du_device *rcdu = plane->dev->dev_private;
 	const struct rcar_du_format_info *format;
+	unsigned int nplanes;
 	int ret;
 
 	format = rcar_du_format_info(fb->pixel_format);
@@ -220,6 +221,8 @@  rcar_du_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
 		return -EINVAL;
 	}
 
+	nplanes = rplane->format ? rplane->format->planes : 0;
+
 	rplane->crtc = crtc;
 	rplane->format = format;
 	rplane->pitch = fb->pitches[0];
@@ -231,9 +234,15 @@  rcar_du_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
 	rplane->width = crtc_w;
 	rplane->height = crtc_h;
 
-	ret = rcar_du_plane_reserve(rplane);
-	if (ret < 0)
-		return ret;
+	/* Reallocate hardware planes if the number of required planes has
+	 * changed.
+	 */
+	if (format->planes != nplanes) {
+		rcar_du_plane_release(rplane);
+		ret = rcar_du_plane_reserve(rplane);
+		if (ret < 0)
+			return ret;
+	}
 
 	rcar_du_plane_compute_base(rplane, fb);
 	rcar_du_plane_setup(rplane);