From patchwork Wed Jul 11 14:28:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 1183811 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 2334DDF25A for ; Wed, 11 Jul 2012 16:03:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E47FAA0E4F for ; Wed, 11 Jul 2012 09:03:37 -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 4C2749E8AF for ; Wed, 11 Jul 2012 08:35:54 -0700 (PDT) Received: by mail-wg0-f43.google.com with SMTP id dr1so946426wgb.12 for ; Wed, 11 Jul 2012 08:35:54 -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=7XT3OaYGFYz97RKzWF5ji9kxk+MHGjRFipFUGKhXH7g=; b=QfU9fC8+NxWKEqnbWpCnPF1UXjXhBopli15/sgB2hWYrc9ELup1/3MwnoZ/J9PnSKA UCPmJ6aB1jKnzy6Jr4g/VtA7sx9zlqmO4SMr9Jk7dPQOQ+AmhZAZ32jzPrSVyuulM4wF hlxeTpRlat7XztxgRsKK/T+zxSuOLu5yYuxJg= 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=7XT3OaYGFYz97RKzWF5ji9kxk+MHGjRFipFUGKhXH7g=; b=BPYOfG4pbtSRJeVqJL5JiQsjRU/3RSPQutv1M1Tf5diJrgKAnPrMVDJnYycXm6k6pY QYUAAxjVWsw5K1zE1cpfq/MennvYh8GwqtD8IdmYBrkJuhehLoXrsvVerQMIJA0oKxGS NsitiuCjpou8NkJ2KfJHk4iVUyE2myFkD7AhdxyEdt+p5Srztn315NVrItYHREl8vq5M pKFV8EdrTs+05jqAHGL1hj02wAyq2zBHHMgwkCSuzHTGafkdhODYNgm9SMikfz+RTnHg Am8DiWiPqQrvK9fBJ8Hsa/sSKXz0gJk6UmAhuLhuFwHL8ByRAaGQX3+5Ej3Fa89mGJNh CtmQ== Received: by 10.180.86.226 with SMTP id s2mr48164003wiz.9.1342020953970; Wed, 11 Jul 2012 08:35:53 -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 bc2sm5777080wib.0.2012.07.11.08.35.52 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 11 Jul 2012 08:35:53 -0700 (PDT) From: Daniel Vetter To: Intel Graphics Development Date: Wed, 11 Jul 2012 16:28:17 +0200 Message-Id: <1342016944-23395-35-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1342016944-23395-1-git-send-email-daniel.vetter@ffwll.ch> References: <1342016944-23395-1-git-send-email-daniel.vetter@ffwll.ch> X-Gm-Message-State: ALoCoQmeI0ZsiAq4ccNFyvDRSVo4LXEe7DAA7JbM7AIRfQRLM/BmpZEhmDhVj4GjDCjIb+Rk4cqj Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH 34/81] 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/disable 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 - we don't know what outputs/ports are enabled and hence have to disable everything in a rather ad-hoc way. 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 where we have a 1:1 encoder to connector mapping. 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 744241e..42b306a 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -3572,6 +3572,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 c5b71bf..c06cfda 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 { @@ -396,6 +403,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) {