dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Rob Clark <robdclark@gmail.com>
To: dri-devel@lists.freedesktop.org
Subject: [RFC] drm: add plane iterator macros
Date: Fri, 21 Nov 2014 07:39:11 -0500	[thread overview]
Message-ID: <1416573551-1890-1-git-send-email-robdclark@gmail.com> (raw)

Inspired in part by some cute iterator macros I noticed in i915.  I
currently have these in drm/msm, but seems like they should be useful
for others.  Quite possibly other iterators would be useful to add for
other drivers.

Signed-off-by: Rob Clark <robdclark@gmail.com>
---
NOTE: to actually merge this, depending on the order this is merged
vs drm/msm/mdp5 atomic support, these would have to be removed from
msm_kms.h.

 include/drm/drm_crtc.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index bc1cc3c..5ea46ec 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -773,6 +773,34 @@ struct drm_plane {
 	struct drm_plane_state *state;
 };
 
+/* iterate over the planes *currently* attached to a crtc, useful
+ * to apply current state to hw:
+ */
+#define for_each_plane_on_crtc(_crtc, _plane) \
+	list_for_each_entry((_plane), &(_crtc)->dev->mode_config.plane_list, head) \
+		if ((_plane)->state->crtc == (_crtc))
+
+static inline bool
+__plane_will_be_attached_to_crtc(struct drm_atomic_state *state,
+		struct drm_plane *plane, struct drm_crtc *crtc)
+{
+	int idx = drm_plane_index(plane);
+
+	/* if plane is modified in incoming state, use the new state: */
+	if (state->plane_states[idx])
+		return state->plane_states[idx]->crtc == crtc;
+
+	/* otherwise, current state: */
+	return plane->state->crtc == crtc;
+}
+
+/* iterate over the planes that *will be* attached to a crtc,
+ * useful for ->atomic_check() operations:
+ */
+#define for_each_pending_plane_on_crtc(_state, _crtc, _plane) \
+	list_for_each_entry((_plane), &(_crtc)->dev->mode_config.plane_list, head) \
+		if (__plane_will_be_attached_to_crtc((_state), (_plane), (_crtc)))
+
 /**
  * struct drm_bridge_funcs - drm_bridge control functions
  * @mode_fixup: Try to fixup (or reject entirely) proposed mode for this bridge
-- 
1.9.3

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

             reply	other threads:[~2014-11-21 12:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-21 12:39 Rob Clark [this message]
2014-11-21 15:24 ` [RFC] drm: add plane iterator macros Daniel Vetter
2014-11-21 16:29 ` Thierry Reding

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=1416573551-1890-1-git-send-email-robdclark@gmail.com \
    --to=robdclark@gmail.com \
    --cc=dri-devel@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