All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Paul <sean@poorly.run>
To: dri-devel@lists.freedesktop.org
Cc: "Sean Paul" <seanpaul@chromium.org>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"Ville Syrjälä" <ville.syrjala@linux.intel.com>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <maxime.ripard@bootlin.com>,
	"Sean Paul" <sean@poorly.run>, "David Airlie" <airlied@linux.ie>,
	linux-kernel@vger.kernel.org
Subject: [PATCH v3 02/10] drm: Add drm_atomic_crtc_state_for_encoder helper
Date: Thu,  2 May 2019 15:49:44 -0400	[thread overview]
Message-ID: <20190502194956.218441-3-sean@poorly.run> (raw)
In-Reply-To: <20190502194956.218441-1-sean@poorly.run>

From: Sean Paul <seanpaul@chromium.org>

This patch adds a helper to tease out the currently connected crtc for
an encoder, along with its state. This follows the same pattern as the
drm_atomic_crtc_*_for_* macros in the atomic helpers. Since the
relationship of crtc:encoder is 1:n, we don't need a loop since there is
only one crtc per encoder.

Instead of splitting this into 3 functions which all do the same thing,
this is presented as one function. Perhaps that's too ugly and it should
be split to:
struct drm_crtc *drm_atomic_crtc_for_encoder(state, encoder);
struct drm_crtc_state *drm_atomic_new_crtc_state_for_encoder(state, encoder);
struct drm_crtc_state *drm_atomic_old_crtc_state_for_encoder(state, encoder);

Suggestions welcome.

Changes in v3:
- Added to the set

Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
 drivers/gpu/drm/drm_atomic_helper.c | 48 +++++++++++++++++++++++++++++
 include/drm/drm_atomic_helper.h     |  6 ++++
 2 files changed, 54 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 71cc7d6b0644..1f81ca8daad7 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -3591,3 +3591,51 @@ int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
 	return ret;
 }
 EXPORT_SYMBOL(drm_atomic_helper_legacy_gamma_set);
+
+/**
+ * drm_atomic_crtc_state_for_encoder - Get crtc and new/old state for an encoder
+ * @state: Atomic state
+ * @encoder: The encoder to fetch the crtc information for
+ * @crtc: If not NULL, receives the currently connected crtc
+ * @old_crtc_state: If not NULL, receives the crtc's old state
+ * @new_crtc_state: If not NULL, receives the crtc's new state
+ *
+ * This function finds the crtc which is currently connected to @encoder and
+ * returns it as well as its old and new state. If there is no crtc currently
+ * connected, the function will clear @crtc, @old_crtc_state, @new_crtc_state.
+ *
+ * All of @crtc, @old_crtc_state, and @new_crtc_state are optional.
+ */
+void drm_atomic_crtc_state_for_encoder(struct drm_atomic_state *state,
+				       struct drm_encoder *encoder,
+				       struct drm_crtc **crtc,
+				       struct drm_crtc_state **old_crtc_state,
+				       struct drm_crtc_state **new_crtc_state)
+{
+	struct drm_crtc *tmp_crtc;
+	struct drm_crtc_state *tmp_new_crtc_state, *tmp_old_crtc_state;
+	u32 enc_mask = drm_encoder_mask(encoder);
+	int i;
+
+	for_each_oldnew_crtc_in_state(state, tmp_crtc, tmp_old_crtc_state,
+				      tmp_new_crtc_state, i) {
+		if (!(tmp_new_crtc_state->encoder_mask & enc_mask))
+			continue;
+
+		if (new_crtc_state)
+			*new_crtc_state = tmp_new_crtc_state;
+		if (old_crtc_state)
+			*old_crtc_state = tmp_old_crtc_state;
+		if (crtc)
+			*crtc = tmp_crtc;
+		return;
+	}
+
+	if (new_crtc_state)
+		*new_crtc_state = NULL;
+	if (old_crtc_state)
+		*old_crtc_state = NULL;
+	if (crtc)
+		*crtc = NULL;
+}
+EXPORT_SYMBOL(drm_atomic_crtc_state_for_encoder);
diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h
index 58214be3bf3d..2383550a0cc8 100644
--- a/include/drm/drm_atomic_helper.h
+++ b/include/drm/drm_atomic_helper.h
@@ -153,6 +153,12 @@ int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
 				       uint32_t size,
 				       struct drm_modeset_acquire_ctx *ctx);
 
+void drm_atomic_crtc_state_for_encoder(struct drm_atomic_state *state,
+				       struct drm_encoder *encoder,
+				       struct drm_crtc **crtc,
+				       struct drm_crtc_state **old_crtc_state,
+				       struct drm_crtc_state **new_crtc_state);
+
 /**
  * drm_atomic_crtc_for_each_plane - iterate over planes currently attached to CRTC
  * @plane: the loop cursor
-- 
Sean Paul, Software Engineer, Google / Chromium OS


WARNING: multiple messages have this Message-ID (diff)
From: Sean Paul <sean@poorly.run>
To: dri-devel@lists.freedesktop.org
Cc: Maxime Ripard <maxime.ripard@bootlin.com>,
	linux-kernel@vger.kernel.org, David Airlie <airlied@linux.ie>,
	Sean Paul <seanpaul@chromium.org>, Sean Paul <sean@poorly.run>
Subject: [PATCH v3 02/10] drm: Add drm_atomic_crtc_state_for_encoder helper
Date: Thu,  2 May 2019 15:49:44 -0400	[thread overview]
Message-ID: <20190502194956.218441-3-sean@poorly.run> (raw)
In-Reply-To: <20190502194956.218441-1-sean@poorly.run>

From: Sean Paul <seanpaul@chromium.org>

This patch adds a helper to tease out the currently connected crtc for
an encoder, along with its state. This follows the same pattern as the
drm_atomic_crtc_*_for_* macros in the atomic helpers. Since the
relationship of crtc:encoder is 1:n, we don't need a loop since there is
only one crtc per encoder.

Instead of splitting this into 3 functions which all do the same thing,
this is presented as one function. Perhaps that's too ugly and it should
be split to:
struct drm_crtc *drm_atomic_crtc_for_encoder(state, encoder);
struct drm_crtc_state *drm_atomic_new_crtc_state_for_encoder(state, encoder);
struct drm_crtc_state *drm_atomic_old_crtc_state_for_encoder(state, encoder);

Suggestions welcome.

Changes in v3:
- Added to the set

Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
 drivers/gpu/drm/drm_atomic_helper.c | 48 +++++++++++++++++++++++++++++
 include/drm/drm_atomic_helper.h     |  6 ++++
 2 files changed, 54 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 71cc7d6b0644..1f81ca8daad7 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -3591,3 +3591,51 @@ int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
 	return ret;
 }
 EXPORT_SYMBOL(drm_atomic_helper_legacy_gamma_set);
+
+/**
+ * drm_atomic_crtc_state_for_encoder - Get crtc and new/old state for an encoder
+ * @state: Atomic state
+ * @encoder: The encoder to fetch the crtc information for
+ * @crtc: If not NULL, receives the currently connected crtc
+ * @old_crtc_state: If not NULL, receives the crtc's old state
+ * @new_crtc_state: If not NULL, receives the crtc's new state
+ *
+ * This function finds the crtc which is currently connected to @encoder and
+ * returns it as well as its old and new state. If there is no crtc currently
+ * connected, the function will clear @crtc, @old_crtc_state, @new_crtc_state.
+ *
+ * All of @crtc, @old_crtc_state, and @new_crtc_state are optional.
+ */
+void drm_atomic_crtc_state_for_encoder(struct drm_atomic_state *state,
+				       struct drm_encoder *encoder,
+				       struct drm_crtc **crtc,
+				       struct drm_crtc_state **old_crtc_state,
+				       struct drm_crtc_state **new_crtc_state)
+{
+	struct drm_crtc *tmp_crtc;
+	struct drm_crtc_state *tmp_new_crtc_state, *tmp_old_crtc_state;
+	u32 enc_mask = drm_encoder_mask(encoder);
+	int i;
+
+	for_each_oldnew_crtc_in_state(state, tmp_crtc, tmp_old_crtc_state,
+				      tmp_new_crtc_state, i) {
+		if (!(tmp_new_crtc_state->encoder_mask & enc_mask))
+			continue;
+
+		if (new_crtc_state)
+			*new_crtc_state = tmp_new_crtc_state;
+		if (old_crtc_state)
+			*old_crtc_state = tmp_old_crtc_state;
+		if (crtc)
+			*crtc = tmp_crtc;
+		return;
+	}
+
+	if (new_crtc_state)
+		*new_crtc_state = NULL;
+	if (old_crtc_state)
+		*old_crtc_state = NULL;
+	if (crtc)
+		*crtc = NULL;
+}
+EXPORT_SYMBOL(drm_atomic_crtc_state_for_encoder);
diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h
index 58214be3bf3d..2383550a0cc8 100644
--- a/include/drm/drm_atomic_helper.h
+++ b/include/drm/drm_atomic_helper.h
@@ -153,6 +153,12 @@ int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
 				       uint32_t size,
 				       struct drm_modeset_acquire_ctx *ctx);
 
+void drm_atomic_crtc_state_for_encoder(struct drm_atomic_state *state,
+				       struct drm_encoder *encoder,
+				       struct drm_crtc **crtc,
+				       struct drm_crtc_state **old_crtc_state,
+				       struct drm_crtc_state **new_crtc_state);
+
 /**
  * drm_atomic_crtc_for_each_plane - iterate over planes currently attached to CRTC
  * @plane: the loop cursor
-- 
Sean Paul, Software Engineer, Google / Chromium OS

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

  parent reply	other threads:[~2019-05-02 19:50 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-02 19:49 [PATCH v3 00/10] drm: Add self refresh helpers Sean Paul
2019-05-02 19:49 ` [PATCH v3 01/10] drm: Add atomic variants of enable/disable to encoder helper funcs Sean Paul
2019-05-03  7:51   ` Daniel Vetter
2019-05-03 12:34     ` Sean Paul
2019-05-03 14:08       ` Daniel Vetter
2019-05-03 14:08         ` Daniel Vetter
2019-05-02 19:49 ` Sean Paul [this message]
2019-05-02 19:49   ` [PATCH v3 02/10] drm: Add drm_atomic_crtc_state_for_encoder helper Sean Paul
2019-05-03  8:18   ` Daniel Vetter
2019-05-03 12:47     ` Sean Paul
2019-05-03 14:06       ` Daniel Vetter
2019-05-05 21:15         ` Daniel Vetter
2019-05-05 22:01           ` Laurent Pinchart
2019-05-05 22:01             ` Laurent Pinchart
2019-05-02 19:49 ` [PATCH v3 03/10] drm: Add atomic variants for bridge enable/disable Sean Paul
2019-05-03  7:45   ` Daniel Vetter
2019-05-02 19:49 ` [PATCH v3 04/10] drm: Convert connector_helper_funcs->atomic_check to accept drm_atomic_state Sean Paul
2019-05-02 19:49   ` Sean Paul
2019-05-03  8:19   ` Daniel Vetter
2019-05-11 19:12   ` Laurent Pinchart
2019-05-11 19:12     ` Laurent Pinchart
2019-05-13 14:38     ` Sean Paul
2019-05-13 14:38       ` Sean Paul
2019-05-16 12:00       ` Laurent Pinchart
2019-05-16 12:00         ` Laurent Pinchart
2019-05-16 14:21         ` Sean Paul
2019-05-16 14:21           ` Sean Paul
2019-05-13 14:47     ` Daniel Vetter
2019-05-13 14:47       ` Daniel Vetter
2019-05-16 12:02       ` Laurent Pinchart
2019-05-16 12:02         ` Laurent Pinchart
2019-05-16 12:07         ` Daniel Vetter
2019-05-16 12:07           ` Daniel Vetter
2019-05-16 13:28           ` Ville Syrjälä
2019-05-16 13:28             ` Ville Syrjälä
2019-05-02 19:49 ` [PATCH v3 05/10] drm: Add helpers to kick off self refresh mode in drivers Sean Paul
2019-05-02 19:49   ` Sean Paul
2019-05-03  7:36   ` Daniel Vetter
2019-05-02 19:49 ` [PATCH v3 06/10] drm/rockchip: Use dirtyfb helper Sean Paul
2019-05-02 19:49   ` Sean Paul
2019-05-02 19:49   ` Sean Paul
2019-05-02 19:49 ` [PATCH v3 07/10] drm/rockchip: Check for fast link training before enabling psr Sean Paul
2019-05-02 19:49   ` Sean Paul
2019-05-02 19:49 ` [PATCH v3 08/10] drm/rockchip: Use the helpers for PSR Sean Paul
2019-05-02 19:49   ` Sean Paul
2019-05-02 19:49   ` Sean Paul
2019-05-02 19:49 ` [PATCH v3 09/10] drm/rockchip: Don't fully disable vop on self refresh Sean Paul
2019-05-02 19:49   ` Sean Paul
2019-05-02 19:49   ` Sean Paul
2019-05-02 19:49 ` [PATCH v3 10/10] drm/rockchip: Use drm_atomic_helper_commit_tail_rpm Sean Paul
2019-05-02 19:49   ` Sean Paul
2019-05-02 19:49   ` Sean Paul

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=20190502194956.218441-3-sean@poorly.run \
    --to=sean@poorly.run \
    --cc=airlied@linux.ie \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=maxime.ripard@bootlin.com \
    --cc=seanpaul@chromium.org \
    --cc=ville.syrjala@linux.intel.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.