All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: [PATCH v1.1 02/13] drm/atomic: Update legacy DPMS state during modesets, v2.
Date: Mon, 27 Jul 2015 13:04:20 +0200	[thread overview]
Message-ID: <55B61034.8000909@linux.intel.com> (raw)
In-Reply-To: <20150716093123.GH6223@phenom.ffwll.local>

This is required for DPMS to work correctly, during a modeset
the DPMS property should be turned off, unless the state is
crtc is made active in which case it should be set to DPMS on.

The legacy dpms handling performs its own dpms updates, so add a
property to prevent updating the legacy dpms state and use it
in the atomic dpms helpers and i915 suspend/resume.

Changes since v1:
- Set DPMS to off when a connector is removed from a crtc too.
- Update the legacy dpms property too.
- Add an exception for the legacy dpms paths, it updates its own state.
- Add an exception for i915 suspend/resume, it should preserve dpms state.

Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 5ec13c7cc832..f463f8ce8f4d 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -660,15 +660,33 @@ drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev,
 	struct drm_crtc_state *old_crtc_state;
 	int i;
 
-	/* clear out existing links */
+	/* clear out existing links and update dpms */
 	for_each_connector_in_state(old_state, connector, old_conn_state, i) {
-		if (!connector->encoder)
+		if (connector->encoder) {
+			WARN_ON(!connector->encoder->crtc);
+
+			connector->encoder->crtc = NULL;
+			connector->encoder = NULL;
+		}
+
+		if (old_state->preserve_dpms)
 			continue;
 
-		WARN_ON(!connector->encoder->crtc);
+		crtc = connector->state->crtc;
 
-		connector->encoder->crtc = NULL;
-		connector->encoder = NULL;
+		if ((!crtc && old_conn_state->crtc) ||
+		    (crtc && drm_atomic_crtc_needs_modeset(crtc->state))) {
+			struct drm_property *dpms_prop =
+				dev->mode_config.dpms_property;
+			int mode = DRM_MODE_DPMS_OFF;
+
+			if (crtc && crtc->state->active)
+				mode = DRM_MODE_DPMS_ON;
+
+			connector->dpms = mode;
+			drm_object_property_set_value(&connector->base,
+						      dpms_prop, mode);
+		}
 	}
 
 	/* set new links */
@@ -2001,6 +2019,7 @@ void drm_atomic_helper_connector_dpms(struct drm_connector *connector,
 		return;
 
 	state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc);
+	state->preserve_dpms = true;
 retry:
 	crtc_state = drm_atomic_get_crtc_state(state, crtc);
 	if (IS_ERR(crtc_state))
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 28ff75bc9e04..4e49b6667ffa 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -6246,7 +6246,7 @@ int intel_display_suspend(struct drm_device *dev)
 		return -ENOMEM;
 
 	state->acquire_ctx = ctx;
-	state->allow_modeset = true;
+	state->preserve_dpms = true;
 
 	for_each_crtc(dev, crtc) {
 		struct drm_crtc_state *crtc_state =
@@ -6309,7 +6309,7 @@ int intel_crtc_control(struct drm_crtc *crtc, bool enable)
 		return -ENOMEM;
 
 	state->acquire_ctx = ctx;
-	state->allow_modeset = true;
+	state->preserve_dpms = true;
 
 	pipe_config = intel_atomic_get_crtc_state(state, intel_crtc);
 	if (IS_ERR(pipe_config)) {
@@ -12358,16 +12358,9 @@ intel_modeset_update_state(struct drm_atomic_state *state)
 			continue;
 
 		if (crtc->state->active) {
-			struct drm_property *dpms_property =
-				dev->mode_config.dpms_property;
-
-			connector->dpms = DRM_MODE_DPMS_ON;
-			drm_object_property_set_value(&connector->base, dpms_property, DRM_MODE_DPMS_ON);
-
 			intel_encoder = to_intel_encoder(connector->encoder);
 			intel_encoder->connectors_active = true;
-		} else
-			connector->dpms = DRM_MODE_DPMS_OFF;
+		}
 	}
 }
 
@@ -15417,6 +15410,7 @@ void intel_display_resume(struct drm_device *dev)
 		return;
 
 	state->acquire_ctx = dev->mode_config.acquire_ctx;
+	state->preserve_dpms = true;
 
 	/* preserve complete old state, including dpll */
 	intel_atomic_get_shared_dpll_state(state);
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 90a0ff70384a..64d49307c76d 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -937,6 +937,7 @@ struct drm_bridge {
  * @dev: parent DRM device
  * @allow_modeset: allow full modeset
  * @legacy_cursor_update: hint to enforce legacy cursor ioctl semantics
+ * @preserve_dpms: the caller wants to preserve connector->dpms state.
  * @planes: pointer to array of plane pointers
  * @plane_states: pointer to array of plane states pointers
  * @crtcs: pointer to array of CRTC pointers
@@ -950,6 +951,7 @@ struct drm_atomic_state {
 	struct drm_device *dev;
 	bool allow_modeset : 1;
 	bool legacy_cursor_update : 1;
+	bool preserve_dpms : 1;
 	struct drm_plane **planes;
 	struct drm_plane_state **plane_states;
 	struct drm_crtc **crtcs;

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2015-07-27 11:04 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-16  8:59 [PATCH 00/13] Make i915 dpms atomic Maarten Lankhorst
2015-07-16  8:59 ` [PATCH 01/13] drm/atomic: Only update crtc->x/y if it's part of the state Maarten Lankhorst
2015-07-16  9:19   ` Daniel Vetter
2015-07-16  9:17     ` Maarten Lankhorst
2015-07-16  9:29       ` Daniel Vetter
2015-07-16  9:38         ` Maarten Lankhorst
2015-07-16 12:34           ` Daniel Vetter
2015-07-16 13:44             ` Maarten Lankhorst
2015-07-16 13:51   ` [PATCH v1.1 01/13] drm/atomic: Only update crtc->x/y if it's part of the state, v2 Maarten Lankhorst
2015-07-16 14:58     ` Daniel Vetter
2015-07-16  8:59 ` [PATCH 02/13] drm/atomic: Update legacy DPMS state during modesets Maarten Lankhorst
2015-07-16  9:19   ` Daniel Vetter
2015-07-16  9:24     ` Maarten Lankhorst
2015-07-16  9:31       ` Daniel Vetter
2015-07-27 11:04         ` Maarten Lankhorst [this message]
2015-07-27 11:16           ` [PATCH v1.1 02/13] drm/atomic: Update legacy DPMS state during modesets, v2 Daniel Vetter
2015-07-27 11:15             ` Maarten Lankhorst
2015-07-27 11:24             ` [PATCH v1.2 02/13] drm/atomic: Update legacy DPMS state during modesets, v3 Maarten Lankhorst
2015-07-27 13:56               ` Daniel Vetter
2015-07-16  8:59 ` [PATCH 03/13] drm/i915: Make the force_thru workaround atomic Maarten Lankhorst
2015-07-16  8:59 ` [PATCH 04/13] drm/i915: Remove special dpms handling from intel_crt.c Maarten Lankhorst
2015-07-16  8:59 ` [PATCH 05/13] drm/i915: Remove special dpms handling from intel_crtc.c Maarten Lankhorst
2015-07-16  8:59 ` [PATCH 06/13] drm/i915: Remove special dpms handling from intel_sdvo.c Maarten Lankhorst
2015-07-16  8:59 ` [PATCH 07/13] drm/i915: Get rid of dpms handling Maarten Lankhorst
2015-07-16  8:59 ` [PATCH 08/13] drm/i915: Use proper locking for intel_dp_check_link_status Maarten Lankhorst
2015-07-16  8:59 ` [PATCH 09/13] drm/i915: Remove some unneeded checks from check_crtc_state Maarten Lankhorst
2015-07-16  9:24   ` Daniel Vetter
2015-07-16  9:38     ` Maarten Lankhorst
2015-07-16 15:01       ` Daniel Vetter
2015-07-16 14:59         ` Maarten Lankhorst
2015-07-16  8:59 ` [PATCH 10/13] drm/i915: Remove connectors_active from state checking Maarten Lankhorst
2015-07-16  8:59 ` [PATCH 11/13] drm/i915: Remove connectors_active from sanitization Maarten Lankhorst
2015-07-16  8:59 ` [PATCH 12/13] drm/i915: Remove connectors_active from intel_dp.c Maarten Lankhorst
2015-07-16  8:59 ` [PATCH 13/13] drm/i915: Remove connectors_active Maarten Lankhorst
2015-07-16  9:52 ` [PATCH 14/13] drm/i915: Only update mode related state if a modeset happened Maarten Lankhorst

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=55B61034.8000909@linux.intel.com \
    --to=maarten.lankhorst@linux.intel.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --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.