From patchwork Tue Jul 3 09:28:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 1150441 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id DD940DFF72 for ; Tue, 3 Jul 2012 11:01:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CC6769F74F for ; Tue, 3 Jul 2012 04:01:26 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wg0-f43.google.com (mail-wg0-f43.google.com [74.125.82.43]) by gabe.freedesktop.org (Postfix) with ESMTP id 126279F613 for ; Tue, 3 Jul 2012 03:35:10 -0700 (PDT) Received: by mail-wg0-f43.google.com with SMTP id dr1so4714410wgb.12 for ; Tue, 03 Jul 2012 03:35:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=YkVOObk/75vXY3kYKF6PdQP5XQ7iswkMw/Gfcbunu3g=; b=gfci67NSu6sMSnX8roIQqBXTdcDQHv34QFcKXIfBCD8JozHgRzOPAeAFhkbvI3B3QN w8AXxNfXrC4VWeQLpi7VWk2bAD5XqfSbXHALFj0HE2aSwKP7AhiEnjQW9LF3u4yeeEad imymVVky4eqWz0H9dCPZfKfDM2+7vNVN3/tVA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=YkVOObk/75vXY3kYKF6PdQP5XQ7iswkMw/Gfcbunu3g=; b=ib3P0tX0bYodcfKKrglf0dOURfnEmcJhoAm7kGMDempgPghNYLBNlVaowdlZzbK4hM RvUCt0sx39shCVDXeZtWoij9ydqIMKdl72iB3h7I4yrgOB53/MorsECG24Z78AY9dgZu HqICemB/98SwvUIG/ntZAosm01+eiwg6EAeAJ0hv5U16oBksJ0aSIcFO+RULH3MKZfgF ae9XgOXNzFDN/A1BAwPk/IGU+NxlDE4iKAF7tbnfMu3Oh8iBIyKP2Vr3Tx3HDb+C1eCA vfV0jbp6xLPr0ETAyuOkNGQEj+A1NpWo3atJZiEiRF0Sk9oYHrXHZLzuWhUNpYgZ03iP SOMQ== Received: by 10.216.210.229 with SMTP id u79mr4061279weo.31.1341311710610; Tue, 03 Jul 2012 03:35:10 -0700 (PDT) Received: from wespe.ffwll.local (178-83-130-250.dynamic.hispeed.ch. [178.83.130.250]) by mx.google.com with ESMTPS id e9sm14845138wiw.10.2012.07.03.03.35.09 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 03 Jul 2012 03:35:09 -0700 (PDT) From: Daniel Vetter To: Intel Graphics Development Date: Tue, 3 Jul 2012 11:28:26 +0200 Message-Id: <1341307715-3886-35-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1341307715-3886-1-git-send-email-daniel.vetter@ffwll.ch> References: <1341307715-3886-1-git-send-email-daniel.vetter@ffwll.ch> X-Gm-Message-State: ALoCoQkmS2l+DWU1chJw1eOMKTaUmUEI3qnkuurwLauAEHUJGt30ec/6Cl+V1FM2yVUu103OviR4 Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH 34/43] drm/i915: Add interfaces to read out encoder/connector hw state X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org It is all glorious if we try really hard to only enable an entire display pipe to ensure that everyting happens in the right order. But if we don't know the output configuration when the driver takes over, this will all be for vain because we'll make the hw angry right on the first modeset. Hence we need to be able to read out the current hw state, so that we can properly tear down the current hw state on the first modeset. Obviously this is also a nice preparation for the fastboot work, where we try to avoid the modeset on driver load if it matches what the hw is currently using. Furthermore we'll be using these functions to cross-check the actual hw state with what we think it should be, to ensure that the modeset state machine actually works as advertised. This patch only contains the interface definitions and a little helper for the simple case. Signed-Off-by: Daniel Vetter --- drivers/gpu/drm/i915/intel_display.c | 11 +++++++++++ drivers/gpu/drm/i915/intel_drv.h | 8 ++++++++ 2 files changed, 19 insertions(+), 0 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index e01cd09..d423b9a 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -3541,6 +3541,17 @@ void intel_connector_dpms(struct drm_connector *connector, int mode) encoder->connectors_active = false; } +/* Simple connector->get_hw_state implementation for encoders that support only + * one connector and no cloning and hence the encoder state determines the state + * of the connector. */ +bool intel_connector_get_hw_state(struct intel_connector *connector) +{ + enum pipe pipe; + struct intel_encoder *encoder = connector->encoder; + + return encoder->get_hw_state(encoder, &pipe); +} + static bool intel_crtc_mode_fixup(struct drm_crtc *crtc, struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 8714f00..45dd067 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -142,12 +142,19 @@ struct intel_encoder { void (*hot_plug)(struct intel_encoder *); void (*enable)(struct intel_encoder *); void (*disable)(struct intel_encoder *); + /* Read out the current hw state of this connector, returning true if + * the encoder is active. If the encoder is enabled it also set the pipe + * it is connected to in the pipe parameter. */ + bool (*get_hw_state)(struct intel_encoder *, enum pipe *pipe); int crtc_mask; }; struct intel_connector { struct drm_connector base; struct intel_encoder *encoder; + /* Reads out the current hw, returning true if the connector is enabled + * and active (i.e. dpms ON state). */ + bool (*get_hw_state)(struct intel_connector *); }; struct intel_crtc { @@ -391,6 +398,7 @@ extern void intel_encoder_disable(struct drm_encoder *encoder); extern void intel_encoder_destroy(struct drm_encoder *encoder); extern void intel_encoder_dpms(struct intel_encoder *encoder, int mode); extern void intel_connector_dpms(struct drm_connector *, int mode); +extern bool intel_connector_get_hw_state(struct intel_connector *connector); static inline struct intel_encoder *intel_attached_encoder(struct drm_connector *connector) {