All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
To: dri-devel@lists.freedesktop.org
Cc: linux-sh@vger.kernel.org
Subject: [PATCH 08/10] drm: rcar-du: Consider plane to CRTC associations in the plane allocator
Date: Wed, 29 Apr 2015 00:38:02 +0000	[thread overview]
Message-ID: <1430267884-20560-9-git-send-email-laurent.pinchart+renesas@ideasonboard.com> (raw)
In-Reply-To: <1430267884-20560-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com>

Hardware planes are driven by the timing generator of the CRTC they are
associated to. Changing the association requires restarting the CRTC
group that the plane belongs to, resulting in flicker on the other CRTC.

To avoid flicker as much as possible, try to allocate planes first from
the free planes already associated with the target CRTC. If allocation
fails then fall back to allocation from all free planes.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/gpu/drm/rcar-du/rcar_du_kms.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index ade135008e98..2c6cf691d163 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -383,6 +383,8 @@ static int rcar_du_atomic_check(struct drm_device *dev,
 	for (i = 0; i < dev->mode_config.num_total_plane; ++i) {
 		struct rcar_du_plane_state *plane_state;
 		struct rcar_du_plane *plane;
+		unsigned int crtc_planes;
+		unsigned int free;
 		int idx;
 
 		if (!state->planes[i])
@@ -401,8 +403,21 @@ static int rcar_du_atomic_check(struct drm_device *dev,
 		    !rcar_du_plane_needs_realloc(plane, plane_state))
 			continue;
 
+		/* Try to allocate the plane from the free planes currently
+		 * associated with the target CRTC to avoid restarting the CRTC
+		 * group and thus minimize flicker. If it fails fall back to
+		 * allocating from all free planes.
+		 */
+		crtc_planes = to_rcar_crtc(plane_state->state.crtc)->index % 2
+			    ? plane->group->dptsr_planes
+			    : ~plane->group->dptsr_planes;
+		free = group_free_planes[plane->group->index];
+
 		idx = rcar_du_plane_hwalloc(plane_state->format->planes,
-					group_free_planes[plane->group->index]);
+					    free & crtc_planes);
+		if (idx < 0)
+			idx = rcar_du_plane_hwalloc(plane_state->format->planes,
+						    free);
 		if (idx < 0) {
 			dev_dbg(rcdu->dev, "%s: no available hardware plane\n",
 				__func__);
@@ -749,6 +764,11 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu)
 		rgrp->mmio_offset = mmio_offsets[i];
 		rgrp->index = i;
 
+		/* Pre-associate all hardware planes with the first CRTC in the
+		 * group.
+		 */
+		rgrp->dptsr_planes = 0;
+
 		ret = rcar_du_planes_init(rgrp);
 		if (ret < 0)
 			return ret;
-- 
2.0.5


WARNING: multiple messages have this Message-ID (diff)
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
To: dri-devel@lists.freedesktop.org
Cc: linux-sh@vger.kernel.org
Subject: [PATCH 08/10] drm: rcar-du: Consider plane to CRTC associations in the plane allocator
Date: Wed, 29 Apr 2015 03:38:02 +0300	[thread overview]
Message-ID: <1430267884-20560-9-git-send-email-laurent.pinchart+renesas@ideasonboard.com> (raw)
In-Reply-To: <1430267884-20560-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com>

Hardware planes are driven by the timing generator of the CRTC they are
associated to. Changing the association requires restarting the CRTC
group that the plane belongs to, resulting in flicker on the other CRTC.

To avoid flicker as much as possible, try to allocate planes first from
the free planes already associated with the target CRTC. If allocation
fails then fall back to allocation from all free planes.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/gpu/drm/rcar-du/rcar_du_kms.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index ade135008e98..2c6cf691d163 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -383,6 +383,8 @@ static int rcar_du_atomic_check(struct drm_device *dev,
 	for (i = 0; i < dev->mode_config.num_total_plane; ++i) {
 		struct rcar_du_plane_state *plane_state;
 		struct rcar_du_plane *plane;
+		unsigned int crtc_planes;
+		unsigned int free;
 		int idx;
 
 		if (!state->planes[i])
@@ -401,8 +403,21 @@ static int rcar_du_atomic_check(struct drm_device *dev,
 		    !rcar_du_plane_needs_realloc(plane, plane_state))
 			continue;
 
+		/* Try to allocate the plane from the free planes currently
+		 * associated with the target CRTC to avoid restarting the CRTC
+		 * group and thus minimize flicker. If it fails fall back to
+		 * allocating from all free planes.
+		 */
+		crtc_planes = to_rcar_crtc(plane_state->state.crtc)->index % 2
+			    ? plane->group->dptsr_planes
+			    : ~plane->group->dptsr_planes;
+		free = group_free_planes[plane->group->index];
+
 		idx = rcar_du_plane_hwalloc(plane_state->format->planes,
-					group_free_planes[plane->group->index]);
+					    free & crtc_planes);
+		if (idx < 0)
+			idx = rcar_du_plane_hwalloc(plane_state->format->planes,
+						    free);
 		if (idx < 0) {
 			dev_dbg(rcdu->dev, "%s: no available hardware plane\n",
 				__func__);
@@ -749,6 +764,11 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu)
 		rgrp->mmio_offset = mmio_offsets[i];
 		rgrp->index = i;
 
+		/* Pre-associate all hardware planes with the first CRTC in the
+		 * group.
+		 */
+		rgrp->dptsr_planes = 0;
+
 		ret = rcar_du_planes_init(rgrp);
 		if (ret < 0)
 			return ret;
-- 
2.0.5

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2015-04-29  0:38 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-29  0:37 [PATCH 00/10] R-Car DU: Fix flicker due to hardware plane reassociations Laurent Pinchart
2015-04-29  0:37 ` Laurent Pinchart
2015-04-29  0:37 ` [PATCH 01/10] drm: rcar-du: Document the rcar_du_crtc structure Laurent Pinchart
2015-04-29  0:37   ` Laurent Pinchart
2015-04-29 11:33   ` Sergei Shtylyov
2015-04-29 11:33     ` Sergei Shtylyov
2015-04-29 11:37     ` Laurent Pinchart
2015-04-29 11:37       ` Laurent Pinchart
2015-04-29  0:37 ` [PATCH 02/10] drm: rcar-du: Document the rcar_du_plane_state structure Laurent Pinchart
2015-04-29  0:37   ` Laurent Pinchart
2015-04-29 11:34   ` Sergei Shtylyov
2015-04-29 11:34     ` Sergei Shtylyov
2015-04-29  0:37 ` [PATCH 03/10] drm: rcar-du: Move properties from rcar_du_planes to rcar_du_device Laurent Pinchart
2015-04-29  0:37   ` Laurent Pinchart
2015-04-29  0:37 ` [PATCH 04/10] drm: rcar-du: Embed rcar_du_planes structure into rcar_du_group Laurent Pinchart
2015-04-29  0:37   ` Laurent Pinchart
2015-04-29  0:37 ` [PATCH 05/10] drm: rcar-du: Rename to_rcar_du_plane_state to to_rcar_plane_state Laurent Pinchart
2015-04-29  0:37   ` Laurent Pinchart
2015-04-29  0:38 ` [PATCH 06/10] drm: rcar-du: Add plane allocation debugging Laurent Pinchart
2015-04-29  0:38   ` Laurent Pinchart
2015-04-29  0:38 ` [PATCH 07/10] drm: rcar-du: Keep plane to CRTC associations when disabling a plane Laurent Pinchart
2015-04-29  0:38   ` Laurent Pinchart
2015-04-29  0:38 ` Laurent Pinchart [this message]
2015-04-29  0:38   ` [PATCH 08/10] drm: rcar-du: Consider plane to CRTC associations in the plane allocator Laurent Pinchart
2015-04-29  0:38 ` [PATCH 09/10] drm: rcar-du: Store the number of CRTCs per group in the group structure Laurent Pinchart
2015-04-29  0:38   ` Laurent Pinchart
2015-04-29  0:38 ` [PATCH 10/10] drm: rcar-du: Split planes pre-association 4/4 between CRTCs Laurent Pinchart
2015-04-29  0:38   ` Laurent Pinchart

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=1430267884-20560-9-git-send-email-laurent.pinchart+renesas@ideasonboard.com \
    --to=laurent.pinchart+renesas@ideasonboard.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-sh@vger.kernel.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 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.