From patchwork Mon Jul 27 11:04:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 6872021 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CF6819F46B for ; Mon, 27 Jul 2015 11:04:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6D81720374 for ; Mon, 27 Jul 2015 11:04:34 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 6D0B22035B for ; Mon, 27 Jul 2015 11:04:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 61B0E6E8D9; Mon, 27 Jul 2015 04:04:32 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 6A6486E8D9; Mon, 27 Jul 2015 04:04:31 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP; 27 Jul 2015 04:04:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,553,1432623600"; d="scan'208";a="613475021" Received: from akmurthy-mobl.gar.corp.intel.com (HELO patser.lan) ([10.252.18.212]) by orsmga003.jf.intel.com with ESMTP; 27 Jul 2015 04:04:28 -0700 To: Daniel Vetter References: <1437037166-9339-1-git-send-email-maarten.lankhorst@linux.intel.com> <1437037166-9339-3-git-send-email-maarten.lankhorst@linux.intel.com> <20150716091956.GE6223@phenom.ffwll.local> <55A77832.3050908@linux.intel.com> <20150716093123.GH6223@phenom.ffwll.local> From: Maarten Lankhorst Message-ID: <55B61034.8000909@linux.intel.com> Date: Mon, 27 Jul 2015 13:04:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <20150716093123.GH6223@phenom.ffwll.local> Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [Intel-gfx] [PATCH v1.1 02/13] drm/atomic: Update legacy DPMS state during modesets, v2. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 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;