From patchwork Tue Jul 29 12:44:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: rafael.barbalho@intel.com X-Patchwork-Id: 4640351 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 81C82C0338 for ; Tue, 29 Jul 2014 12:44:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BE5D220115 for ; Tue, 29 Jul 2014 12:44:47 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id E5D2720114 for ; Tue, 29 Jul 2014 12:44:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 779046E104; Tue, 29 Jul 2014 05:44:46 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id 6435D6E104 for ; Tue, 29 Jul 2014 05:44:45 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 29 Jul 2014 05:44:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,757,1400050800"; d="scan'208";a="577082319" Received: from rbarbalh-linux.iwi.intel.com ([172.28.253.45]) by fmsmga002.fm.intel.com with ESMTP; 29 Jul 2014 05:44:43 -0700 From: rafael.barbalho@intel.com To: intel-gfx@lists.freedesktop.org Date: Tue, 29 Jul 2014 13:44:40 +0100 Message-Id: <1406637880-6918-1-git-send-email-rafael.barbalho@intel.com> X-Mailer: git-send-email 2.0.3 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH] drm/i915: Correctly read backlight PWM for pipe B on vlv/chv 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: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.9 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 From: Rafael Barbalho Make the vlv/chv backlight setup more generic by actually looking at which pipe the panel is attached to and read the backlight PWM registers that were setup by the bios from that pipe. Cc: Ville Syrjälä Signed-off-by: Rafael Barbalho --- drivers/gpu/drm/i915/intel_panel.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c index 59b028f..be75d76 100644 --- a/drivers/gpu/drm/i915/intel_panel.c +++ b/drivers/gpu/drm/i915/intel_panel.c @@ -1200,32 +1200,28 @@ static int vlv_setup_backlight(struct intel_connector *connector) struct drm_device *dev = connector->base.dev; struct drm_i915_private *dev_priv = dev->dev_private; struct intel_panel *panel = &connector->panel; - enum pipe pipe; + enum pipe pipe = intel_get_pipe_from_connector(connector); u32 ctl, ctl2, val; - for_each_pipe(pipe) { - u32 cur_val = I915_READ(VLV_BLC_PWM_CTL(pipe)); + ctl2 = I915_READ(VLV_BLC_PWM_CTL2(pipe)); + panel->backlight.active_low_pwm = ctl2 & BLM_POLARITY_I965; - /* Skip if the modulation freq is already set */ - if (cur_val & ~BACKLIGHT_DUTY_CYCLE_MASK) - continue; + ctl = I915_READ(VLV_BLC_PWM_CTL(pipe)); - cur_val &= BACKLIGHT_DUTY_CYCLE_MASK; - I915_WRITE(VLV_BLC_PWM_CTL(pipe), (0xf42 << 16) | - cur_val); + /* Skip if the modulation freq is already set */ + if ((ctl & ~BACKLIGHT_DUTY_CYCLE_MASK) == 0) { + ctl &= BACKLIGHT_DUTY_CYCLE_MASK; + ctl |= (0xf42 << 16); + I915_WRITE(VLV_BLC_PWM_CTL(pipe), ctl); } - ctl2 = I915_READ(VLV_BLC_PWM_CTL2(PIPE_A)); - panel->backlight.active_low_pwm = ctl2 & BLM_POLARITY_I965; - - ctl = I915_READ(VLV_BLC_PWM_CTL(PIPE_A)); panel->backlight.max = ctl >> 16; if (!panel->backlight.max) return -ENODEV; panel->backlight.min = get_backlight_min_vbt(connector); - val = _vlv_get_backlight(dev, PIPE_A); + val = _vlv_get_backlight(dev, pipe); panel->backlight.level = intel_panel_compute_brightness(connector, val); panel->backlight.enabled = (ctl2 & BLM_PWM_ENABLE) &&