All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 2/6] drm/i915: Don't store temporary load-detect variables in the generic encoder
Date: Wed, 20 Apr 2011 10:22:18 +0100	[thread overview]
Message-ID: <1303291342-27668-3-git-send-email-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <1303291342-27668-1-git-send-email-chris@chris-wilson.co.uk>

Keep all the state required for undoing and restoring the previous pipe
configuration together in a single struct passed from
intel_get_load_detect_pipe() to intel_release_load_detect_pipe() rather
than stuffing them inside the common encoder structure.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/intel_crt.c     |   11 ++++++-----
 drivers/gpu/drm/i915/intel_display.c |   26 +++++++++++++++-----------
 drivers/gpu/drm/i915/intel_drv.h     |   10 +++++++---
 drivers/gpu/drm/i915/intel_tv.c      |    9 +++++----
 4 files changed, 33 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c
index 2eb60cd..e93f93c 100644
--- a/drivers/gpu/drm/i915/intel_crt.c
+++ b/drivers/gpu/drm/i915/intel_crt.c
@@ -430,7 +430,6 @@ intel_crt_detect(struct drm_connector *connector, bool force)
 	struct drm_device *dev = connector->dev;
 	struct intel_crt *crt = intel_attached_crt(connector);
 	struct drm_crtc *crtc;
-	int dpms_mode;
 	enum drm_connector_status status;
 
 	if (I915_HAS_HOTPLUG(dev)) {
@@ -454,14 +453,16 @@ intel_crt_detect(struct drm_connector *connector, bool force)
 	if (crtc && crtc->enabled) {
 		status = intel_crt_load_detect(crt);
 	} else {
-		if (intel_get_load_detect_pipe(&crt->base, connector,
-					       NULL, &dpms_mode)) {
+		struct intel_load_detect_pipe tmp;
+
+		if (intel_get_load_detect_pipe(&crt->base, connector, NULL,
+					       &tmp)) {
 			if (intel_crt_detect_ddc(connector))
 				status = connector_status_connected;
 			else
 				status = intel_crt_load_detect(crt);
-			intel_release_load_detect_pipe(&crt->base,
-						       connector, dpms_mode);
+			intel_release_load_detect_pipe(&crt->base, connector,
+						       &tmp);
 		} else
 			status = connector_status_unknown;
 	}
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 92e2f14..1d7b9d4 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -5542,7 +5542,7 @@ static struct drm_display_mode load_detect_mode = {
 bool intel_get_load_detect_pipe(struct intel_encoder *intel_encoder,
 				struct drm_connector *connector,
 				struct drm_display_mode *mode,
-				int *dpms_mode)
+				struct intel_load_detect_pipe *old)
 {
 	struct intel_crtc *intel_crtc;
 	struct drm_crtc *possible_crtc;
@@ -5567,14 +5567,18 @@ bool intel_get_load_detect_pipe(struct intel_encoder *intel_encoder,
 	/* See if we already have a CRTC for this connector */
 	if (encoder->crtc) {
 		crtc = encoder->crtc;
-		/* Make sure the crtc and connector are running */
+
 		intel_crtc = to_intel_crtc(crtc);
-		*dpms_mode = intel_crtc->dpms_mode;
+		old->dpms_mode = intel_crtc->dpms_mode;
+		old->load_detect_temp = false;
+
+		/* Make sure the crtc and connector are running */
 		if (intel_crtc->dpms_mode != DRM_MODE_DPMS_ON) {
 			crtc_funcs = crtc->helper_private;
 			crtc_funcs->dpms(crtc, DRM_MODE_DPMS_ON);
 			encoder_funcs->dpms(encoder, DRM_MODE_DPMS_ON);
 		}
+
 		return true;
 	}
 
@@ -5601,10 +5605,10 @@ bool intel_get_load_detect_pipe(struct intel_encoder *intel_encoder,
 
 	encoder->crtc = crtc;
 	connector->encoder = encoder;
-	intel_encoder->load_detect_temp = true;
 
 	intel_crtc = to_intel_crtc(crtc);
-	*dpms_mode = intel_crtc->dpms_mode;
+	old->dpms_mode = intel_crtc->dpms_mode;
+	old->load_detect_temp = true;
 
 	if (!crtc->enabled) {
 		if (!mode)
@@ -5632,7 +5636,8 @@ bool intel_get_load_detect_pipe(struct intel_encoder *intel_encoder,
 }
 
 void intel_release_load_detect_pipe(struct intel_encoder *intel_encoder,
-				    struct drm_connector *connector, int dpms_mode)
+				    struct drm_connector *connector,
+				    struct intel_load_detect_pipe *old)
 {
 	struct drm_encoder *encoder = &intel_encoder->base;
 	struct drm_device *dev = encoder->dev;
@@ -5640,19 +5645,18 @@ void intel_release_load_detect_pipe(struct intel_encoder *intel_encoder,
 	struct drm_encoder_helper_funcs *encoder_funcs = encoder->helper_private;
 	struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
 
-	if (intel_encoder->load_detect_temp) {
+	if (old->load_detect_temp) {
 		encoder->crtc = NULL;
 		connector->encoder = NULL;
-		intel_encoder->load_detect_temp = false;
 		crtc->enabled = drm_helper_crtc_in_use(crtc);
 		drm_helper_disable_unused_functions(dev);
 	}
 
 	/* Switch crtc and encoder back off if necessary */
-	if (crtc->enabled && dpms_mode != DRM_MODE_DPMS_ON) {
+	if (crtc->enabled && old->dpms_mode != DRM_MODE_DPMS_ON) {
 		if (encoder->crtc == crtc)
-			encoder_funcs->dpms(encoder, dpms_mode);
-		crtc_funcs->dpms(crtc, dpms_mode);
+			encoder_funcs->dpms(encoder, old->dpms_mode);
+		crtc_funcs->dpms(crtc, old->dpms_mode);
 	}
 }
 
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 7ea4bab..9409a46 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -140,7 +140,6 @@ struct intel_fbdev {
 struct intel_encoder {
 	struct drm_encoder base;
 	int type;
-	bool load_detect_temp;
 	bool needs_tv_clock;
 	void (*hot_plug)(struct intel_encoder *);
 	int crtc_mask;
@@ -298,13 +297,18 @@ static inline void intel_wait_for_crtc_vblank_safe(struct drm_crtc *crtc)
 		msleep(50);
 }
 extern void intel_wait_for_pipe_off(struct drm_device *dev, int pipe);
+
+struct intel_load_detect_pipe {
+	bool load_detect_temp;
+	int dpms_mode;
+};
 extern bool intel_get_load_detect_pipe(struct intel_encoder *intel_encoder,
 				       struct drm_connector *connector,
 				       struct drm_display_mode *mode,
-				       int *dpms_mode);
+				       struct intel_load_detect_pipe *old);
 extern void intel_release_load_detect_pipe(struct intel_encoder *intel_encoder,
 					   struct drm_connector *connector,
-					   int dpms_mode);
+					   struct intel_load_detect_pipe *old);
 
 extern struct drm_connector* intel_sdvo_find(struct drm_device *dev, int sdvoB);
 extern int intel_sdvo_supports_hotplug(struct drm_connector *connector);
diff --git a/drivers/gpu/drm/i915/intel_tv.c b/drivers/gpu/drm/i915/intel_tv.c
index 1174f77..529f232 100644
--- a/drivers/gpu/drm/i915/intel_tv.c
+++ b/drivers/gpu/drm/i915/intel_tv.c
@@ -1370,13 +1370,14 @@ intel_tv_detect(struct drm_connector *connector, bool force)
 	if (intel_tv->base.base.crtc && intel_tv->base.base.crtc->enabled) {
 		type = intel_tv_detect_type(intel_tv, connector);
 	} else if (force) {
-		int dpms_mode;
+		struct intel_load_detect_pipe tmp;
 
 		if (intel_get_load_detect_pipe(&intel_tv->base, connector,
-					       &mode, &dpms_mode)) {
+					       &mode, &tmp)) {
 			type = intel_tv_detect_type(intel_tv, connector);
-			intel_release_load_detect_pipe(&intel_tv->base, connector,
-						       dpms_mode);
+			intel_release_load_detect_pipe(&intel_tv->base,
+						       connector,
+						       &tmp);
 		} else
 			return connector_status_unknown;
 	} else
-- 
1.7.4.1

  parent reply	other threads:[~2011-04-20  9:22 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-20  9:22 Remove dead code from intel_get_load_detect_pipe Chris Wilson
2011-04-20  9:22 ` [PATCH 1/6] drm/i915: Simplify return value " Chris Wilson
2011-04-20 18:10   ` Keith Packard
2011-04-20 18:26     ` [PATCH 1/2] " Chris Wilson
2011-04-20 18:26       ` [PATCH 2/2] drm/i915: Propagate failure to set mode for load-detect pipe Chris Wilson
2011-04-20  9:22 ` Chris Wilson [this message]
2011-04-20 18:12   ` [PATCH 2/6] drm/i915: Don't store temporary load-detect variables in the generic encoder Keith Packard
2011-04-20  9:22 ` [PATCH 3/6] drm/i915: Remove unused supported_crtc from intel_load_detect_pipe Chris Wilson
2011-04-20 18:12   ` Keith Packard
2011-04-20  9:22 ` [PATCH 4/6] drm/i915: Pass the saved adjusted_mode when adding to the load-detect crtc Chris Wilson
2011-04-20 18:23   ` Keith Packard
2011-04-20 19:38     ` Chris Wilson
2011-04-20 21:00       ` Keith Packard
2011-04-20  9:22 ` [PATCH 5/6] drm/i915: Remove dead code from intel_get_load_detect_pipe() Chris Wilson
2011-04-20 18:26   ` Keith Packard
2011-04-20  9:22 ` [PATCH 6/6] drm/i915: Attach a fb to the load-detect pipe Chris Wilson
2011-04-20 18:43   ` Keith Packard
2011-04-20 18:55     ` Chris Wilson
2011-04-20 21:03       ` Keith Packard
2011-04-20 21:43         ` [PATCH] " Chris Wilson
2011-04-21  8:45           ` When in doubt, use a temporary fb Chris Wilson
2011-04-21  8:45             ` [PATCH 1/3] drm/i915: Remove dead code from intel_release_load_detect_pipe() Chris Wilson
2011-04-21  8:45             ` [PATCH 2/3] drm/i915: Attach a fb to the load-detect pipe Chris Wilson
2011-04-21  8:45             ` [PATCH 3/3] drm/i915: Move the tracking of dpms_mode down into crtc enable/disable Chris Wilson
2011-04-20 20:16     ` [PATCH] drm/i915: Attach a fb to the load-detect pipe Chris Wilson

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=1303291342-27668-3-git-send-email-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=intel-gfx@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 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.