From patchwork Thu Jan 22 17:53:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 5687291 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B056BC058D for ; Thu, 22 Jan 2015 17:53:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B4E16200FE for ; Thu, 22 Jan 2015 17:53:18 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 8A647201BC for ; Thu, 22 Jan 2015 17:53:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 855196E357; Thu, 22 Jan 2015 09:53:15 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wg0-f47.google.com (mail-wg0-f47.google.com [74.125.82.47]) by gabe.freedesktop.org (Postfix) with ESMTP id 242796E378 for ; Thu, 22 Jan 2015 09:53:14 -0800 (PST) Received: by mail-wg0-f47.google.com with SMTP id n12so3184798wgh.6 for ; Thu, 22 Jan 2015 09:53:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6Dj+/2UtJCKY8Qs2spp8eDiFJ+qeiZo2QRfgExYF/xs=; b=jrQupkC0rR2GDFFRaUe/bf8Yud5Jh5l3IppB+45TbBsBD1La/mdiXo5TUg1qkdW4IE BegT96ZkdDyQGaFVUY+zt5Qw/3/fW/qcszmuKiIgCJ3voHhbO6Xp+qbr69Wh3uBDYwT4 76cDAUCuQe2GHfH5uXir2i7czwubqf+6pqpDE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6Dj+/2UtJCKY8Qs2spp8eDiFJ+qeiZo2QRfgExYF/xs=; b=jyp6dUN2PxVB34XmrOJaDN3WBtJqnHcpaJcMP+ORufh5dDn8r7kXKvl/W0mN7W7qKO DIdkjypEnoAAhijlypG0UEO1R0Gp0o9LvSyM+ngp+91KAvTzdKDKTNwF7D+oltVDvyHs 1OJOBbOshkzlw5UwT60D8QmASl6kLGSU+mw0zP/CNc8J1wfj4UmGdrkvy669a2bDk9Su pJe0WZNYkqcbhrSfGLF+6n5uWqOfnEMhyO/W/vwtCP3ZSz9wVMyzYFcTXDIGeyJdfNqN g3pFzvcSMqHPAokYosz1rzr4clD0HGA7YlhN4hGfBk/gxvHs/nNs3SsigQYbaexeeXRM +tBA== X-Gm-Message-State: ALoCoQnMsamG5mfisSkV3q8EB00YWcw5DytKhOFQkUXP0EKibKyLAzg1uvnXfgEzlI0AI5I2LmnI X-Received: by 10.194.48.11 with SMTP id h11mr5366405wjn.23.1421949192843; Thu, 22 Jan 2015 09:53:12 -0800 (PST) Received: from phenom.ffwll.local (80-219-119-195.dclient.hispeed.ch. [80.219.119.195]) by mx.google.com with ESMTPSA id u18sm4853473wjq.42.2015.01.22.09.53.11 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Jan 2015 09:53:11 -0800 (PST) From: Daniel Vetter To: DRI Development Subject: [PATCH] drm/atomic-helper: add connector->dpms() implementation Date: Thu, 22 Jan 2015 18:53:05 +0100 Message-Id: <1421949185-940-1-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1421940985-5961-2-git-send-email-daniel.vetter@ffwll.ch> References: <1421940985-5961-2-git-send-email-daniel.vetter@ffwll.ch> Cc: Daniel Vetter , Intel Graphics Development , Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_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 builds on top of the crtc->active infrastructure to implement legacy DPMS. My choice of semantics is somewhat arbitrary, but the entire pipe is enabled as along as one output is still enabled. Of course it also clamps everything that's not ON to OFF. v2: Fix spelling in one comment. v3: Don't do an async commit (Thierry) Cc: Thierry Reding Signed-off-by: Daniel Vetter --- drivers/gpu/drm/drm_atomic_helper.c | 75 +++++++++++++++++++++++++++++++++++++ include/drm/drm_atomic_helper.h | 2 + 2 files changed, 77 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 3f17933b1d2c..f693344d9573 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -1887,6 +1887,81 @@ backoff: EXPORT_SYMBOL(drm_atomic_helper_page_flip); /** + * drm_atomic_helper_connector_dpms() - connector dpms helper implementation + * @connector: affected connector + * @mode: DPMS mode + * + * This is the main helper function provided by the atomic helper framework for + * implementing the legacy DPMS connector interface. It computes the new desired + * ->active state for the corresponding CRTC (if the connector is enabled) and + * updates it. + */ +void drm_atomic_helper_connector_dpms(struct drm_connector *connector, + int mode) +{ + struct drm_mode_config *config = &connector->dev->mode_config; + struct drm_atomic_state *state; + struct drm_crtc_state *crtc_state; + struct drm_crtc *crtc; + struct drm_connector *tmp_connector; + int ret; + bool active = false; + + if (mode != DRM_MODE_DPMS_ON) + mode = DRM_MODE_DPMS_OFF; + + connector->dpms = mode; + crtc = connector->state->crtc; + + if (!crtc) + return; + + /* FIXME: ->dpms has no return value so can't forward the -ENOMEM. */ + state = drm_atomic_state_alloc(connector->dev); + if (!state) + return; + + state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc); +retry: + crtc_state = drm_atomic_get_crtc_state(state, crtc); + + WARN_ON(!drm_modeset_is_locked(&config->connection_mutex)); + + list_for_each_entry(tmp_connector, &config->connector_list, head) { + if (connector->state->crtc != crtc) + continue; + + if (connector->dpms == DRM_MODE_DPMS_ON) { + active = true; + break; + } + } + crtc_state->active = active; + + ret = drm_atomic_commit(state); + if (ret != 0) + goto fail; + + /* Driver takes ownership of state on successful async commit. */ + return; +fail: + if (ret == -EDEADLK) + goto backoff; + + drm_atomic_state_free(state); + + WARN(1, "Driver bug: Changing ->active failed with ret=%i\n", ret); + + return; +backoff: + drm_atomic_state_clear(state); + drm_atomic_legacy_backoff(state); + + goto retry; +} +EXPORT_SYMBOL(drm_atomic_helper_connector_dpms); + +/** * DOC: atomic state reset and initialization * * Both the drm core and the atomic helpers assume that there is always the full diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h index 2095917ff8c7..cf501df9e513 100644 --- a/include/drm/drm_atomic_helper.h +++ b/include/drm/drm_atomic_helper.h @@ -82,6 +82,8 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb, struct drm_pending_vblank_event *event, uint32_t flags); +void drm_atomic_helper_connector_dpms(struct drm_connector *connector, + int mode); /* default implementations for state handling */ void drm_atomic_helper_crtc_reset(struct drm_crtc *crtc);