From patchwork Tue Apr 22 22:55:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 4036911 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1F4D89F319 for ; Tue, 22 Apr 2014 22:56:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F0E5A2022D for ; Tue, 22 Apr 2014 22:56:10 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id E371A2021F for ; Tue, 22 Apr 2014 22:56:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8E4FB6E973; Tue, 22 Apr 2014 15:56:09 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-yk0-f182.google.com (mail-yk0-f182.google.com [209.85.160.182]) by gabe.freedesktop.org (Postfix) with ESMTP id 863846E972 for ; Tue, 22 Apr 2014 15:56:07 -0700 (PDT) Received: by mail-yk0-f182.google.com with SMTP id 142so143526ykq.13 for ; Tue, 22 Apr 2014 15:56:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5L7X5qyMDz3D96JNp2DHaG9BL4iMhU34lmxEMyi7Lws=; b=y4Qw10UBMd3Y8LRIL5k+AvFQknnK63pAlbA790JP/uwNQWgmEJYhQLsuEOm0+/FiQx ChORL0NsQ4ffwgJCDVHVH/p7+tz2vFijU5boyMIlIvPrKZlVFxj2q2iU/NhAUCkgJzGd QGowiA4LhAj2L//dQ1yThRTbjozelAJYRVe2ryptDawoEPzgoMHWjmKkyuu3naDQkSgg OzuU/SzN8uxBLMb1USfshrCfyUxrap4PW/gOrngBedPatKKedCg2N77cZqnaM2rJ8aY/ RC7ND5w1Dc67r7BhKmHzKblszQSo66a/ONrEw/NEKAf4G3gOnFKS0voHlpEUEcehZl+V 5J0A== X-Received: by 10.236.115.198 with SMTP id e46mr64331496yhh.24.1398207366164; Tue, 22 Apr 2014 15:56:06 -0700 (PDT) Received: from localhost.localdomain ([177.156.79.173]) by mx.google.com with ESMTPSA id 63sm81337973yhi.13.2014.04.22.15.56.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Apr 2014 15:56:05 -0700 (PDT) From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Tue, 22 Apr 2014 19:55:43 -0300 Message-Id: <1398207345-1865-2-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1398207345-1865-1-git-send-email-przanoni@gmail.com> References: <20140411132123.GH9262@phenom.ffwll.local> <1398207345-1865-1-git-send-email-przanoni@gmail.com> Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH 2/4] drm/i915: add intel_dp_power_get/put X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 From: Paulo Zanoni This was suggested by Chris on his review to the first version of "drm/i915: get power domain in case the BIOS enabled eDP VDD". Well, at least that's what I understood from his comment :) The downside of this patch is that in a few places we will call intel_display_port_power_domain() twice instead of once. Signed-off-by: Paulo Zanoni --- drivers/gpu/drm/i915/intel_dp.c | 61 ++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index 44df493..b385b03 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -1063,13 +1063,30 @@ static u32 ironlake_get_pp_control(struct intel_dp *intel_dp) return control; } +static void intel_dp_power_get(struct intel_encoder *encoder) +{ + struct drm_i915_private *dev_priv = encoder->base.dev->dev_private; + enum intel_display_power_domain power_domain; + + power_domain = intel_display_port_power_domain(encoder); + intel_display_power_get(dev_priv, power_domain); +} + +static void intel_dp_power_put(struct intel_encoder *encoder) +{ + struct drm_i915_private *dev_priv = encoder->base.dev->dev_private; + enum intel_display_power_domain power_domain; + + power_domain = intel_display_port_power_domain(encoder); + intel_display_power_put(dev_priv, power_domain); +} + static bool _edp_panel_vdd_on(struct intel_dp *intel_dp) { struct drm_device *dev = intel_dp_to_dev(intel_dp); struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); struct intel_encoder *intel_encoder = &intel_dig_port->base; struct drm_i915_private *dev_priv = dev->dev_private; - enum intel_display_power_domain power_domain; u32 pp; u32 pp_stat_reg, pp_ctrl_reg; bool need_to_disable = !intel_dp->want_panel_vdd; @@ -1082,8 +1099,7 @@ static bool _edp_panel_vdd_on(struct intel_dp *intel_dp) if (edp_have_panel_vdd(intel_dp)) return need_to_disable; - power_domain = intel_display_port_power_domain(intel_encoder); - intel_display_power_get(dev_priv, power_domain); + intel_dp_power_get(intel_encoder); DRM_DEBUG_KMS("Turning eDP VDD on\n"); @@ -1133,7 +1149,6 @@ static void edp_panel_vdd_off_sync(struct intel_dp *intel_dp) struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); struct intel_encoder *intel_encoder = &intel_dig_port->base; - enum intel_display_power_domain power_domain; DRM_DEBUG_KMS("Turning eDP VDD off\n"); @@ -1153,8 +1168,7 @@ static void edp_panel_vdd_off_sync(struct intel_dp *intel_dp) if ((pp & POWER_TARGET_ON) == 0) intel_dp->last_power_cycle = jiffies; - power_domain = intel_display_port_power_domain(intel_encoder); - intel_display_power_put(dev_priv, power_domain); + intel_dp_power_put(intel_encoder); } } @@ -1242,7 +1256,6 @@ void intel_edp_panel_off(struct intel_dp *intel_dp) struct intel_encoder *intel_encoder = &intel_dig_port->base; struct drm_device *dev = intel_dp_to_dev(intel_dp); struct drm_i915_private *dev_priv = dev->dev_private; - enum intel_display_power_domain power_domain; u32 pp; u32 pp_ctrl_reg; @@ -1272,8 +1285,7 @@ void intel_edp_panel_off(struct intel_dp *intel_dp) wait_panel_off(intel_dp); /* We got a reference when we enabled the VDD. */ - power_domain = intel_display_port_power_domain(intel_encoder); - intel_display_power_put(dev_priv, power_domain); + intel_dp_power_put(intel_encoder); } void intel_edp_backlight_on(struct intel_dp *intel_dp) @@ -3161,13 +3173,10 @@ intel_dp_detect(struct drm_connector *connector, bool force) struct drm_device *dev = connector->dev; struct drm_i915_private *dev_priv = dev->dev_private; enum drm_connector_status status; - enum intel_display_power_domain power_domain; struct edid *edid = NULL; intel_runtime_pm_get(dev_priv); - - power_domain = intel_display_port_power_domain(intel_encoder); - intel_display_power_get(dev_priv, power_domain); + intel_dp_power_get(intel_encoder); DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", connector->base.id, drm_get_connector_name(connector)); @@ -3199,8 +3208,7 @@ intel_dp_detect(struct drm_connector *connector, bool force) status = connector_status_connected; out: - intel_display_power_put(dev_priv, power_domain); - + intel_dp_power_put(intel_encoder); intel_runtime_pm_put(dev_priv); return status; @@ -3213,18 +3221,14 @@ static int intel_dp_get_modes(struct drm_connector *connector) struct intel_encoder *intel_encoder = &intel_dig_port->base; struct intel_connector *intel_connector = to_intel_connector(connector); struct drm_device *dev = connector->dev; - struct drm_i915_private *dev_priv = dev->dev_private; - enum intel_display_power_domain power_domain; int ret; /* We should parse the EDID data and find out if it has an audio sink */ - power_domain = intel_display_port_power_domain(intel_encoder); - intel_display_power_get(dev_priv, power_domain); - + intel_dp_power_get(intel_encoder); ret = intel_dp_get_edid_modes(connector, &intel_dp->aux.ddc); - intel_display_power_put(dev_priv, power_domain); + intel_dp_power_put(intel_encoder); if (ret) return ret; @@ -3247,14 +3251,10 @@ intel_dp_detect_audio(struct drm_connector *connector) struct intel_dp *intel_dp = intel_attached_dp(connector); struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); struct intel_encoder *intel_encoder = &intel_dig_port->base; - struct drm_device *dev = connector->dev; - struct drm_i915_private *dev_priv = dev->dev_private; - enum intel_display_power_domain power_domain; struct edid *edid; bool has_audio = false; - power_domain = intel_display_port_power_domain(intel_encoder); - intel_display_power_get(dev_priv, power_domain); + intel_dp_power_get(intel_encoder); edid = intel_dp_get_edid(connector, &intel_dp->aux.ddc); if (edid) { @@ -3262,7 +3262,7 @@ intel_dp_detect_audio(struct drm_connector *connector) kfree(edid); } - intel_display_power_put(dev_priv, power_domain); + intel_dp_power_put(intel_encoder); return has_audio; } @@ -3801,11 +3801,8 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp, /* The VDD bit needs a power domain reference, so if the bit is already * enabled when we boot, grab this reference. */ - if (edp_have_panel_vdd(intel_dp)) { - enum intel_display_power_domain power_domain; - power_domain = intel_display_port_power_domain(intel_encoder); - intel_display_power_get(dev_priv, power_domain); - } + if (edp_have_panel_vdd(intel_dp)) + intel_dp_power_get(intel_encoder); /* Cache DPCD and EDID for edp. */ intel_edp_panel_vdd_on(intel_dp);