From patchwork Wed Jul 16 21:49:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clint Taylor X-Patchwork-Id: 4571661 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 7B871C0514 for ; Wed, 16 Jul 2014 21:51:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ADFBB201DE for ; Wed, 16 Jul 2014 21:51:03 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id CD3FF201F4 for ; Wed, 16 Jul 2014 21:51:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6086989E52; Wed, 16 Jul 2014 14:51:02 -0700 (PDT) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id 74AEB89E52 for ; Wed, 16 Jul 2014 14:51:00 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 16 Jul 2014 14:51:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,673,1400050800"; d="scan'208";a="574315341" Received: from cataylo2-ubuntu64-12.jf.intel.com ([10.7.200.177]) by orsmga002.jf.intel.com with ESMTP; 16 Jul 2014 14:50:59 -0700 From: clinton.a.taylor@intel.com To: Intel-gfx@lists.freedesktop.org Date: Wed, 16 Jul 2014 14:49:43 -0700 Message-Id: <1405547387-14051-8-git-send-email-clinton.a.taylor@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1405547387-14051-1-git-send-email-clinton.a.taylor@intel.com> References: <1405547387-14051-1-git-send-email-clinton.a.taylor@intel.com> Cc: Ben Widawsky , Ben Widawsky Subject: [Intel-gfx] [PATCH 07/11] CHROMIUM: drm/i915/vlv: Scale backlight to min duty ratio 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.2 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: Ben Widawsky On VLV specifically, going too low runs the risk of getting the BLC_EN signal out of sync, preventing resume from working correctly. Scale /sys/class/backlight at this level to prevent userspace from doing this on suspend. This gets rid of the explicitly hardcoded value for a previous/similar patch. Instead relies on the VBT to provide the value, and if VBT does not provide one, then it uses a hardcoded 5% min duty cycle. This was defined a couple patches ago for the same fallback on VLV. Signed-off-by: Ben Widawsky Signed-off-by: Wayne Boyer Change-Id: Ibbbc33338ef1659d0f797d6a33d3727a45ad95d5 Reviewed-on: https://chromium-review.googlesource.com/196609 Reviewed-by: Aaron Durbin Tested-by: Wayne Boyer Commit-Queue: Wayne Boyer Conflicts: drivers/gpu/drm/i915/intel_panel.c --- drivers/gpu/drm/i915/intel_panel.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c index b3327d0..02248a5 100644 --- a/drivers/gpu/drm/i915/intel_panel.c +++ b/drivers/gpu/drm/i915/intel_panel.c @@ -576,11 +576,22 @@ void intel_panel_set_backlight(struct intel_connector *connector, u32 level, WARN_ON(panel->backlight.max == 0); - /* scale to hardware max, but be careful to not overflow */ - freq = panel->backlight.max; - n = (u64)level * freq; - do_div(n, max); - level = n; + /* XXX: we probably want to do this for all platforms. */ + if (IS_VALLEYVIEW(dev)) { + /* It's always safe to use vbt values for VLV since we fake them + * if they don't actually exist. */ + const int min_duty = (dev_priv->vbt.backlight.min_duty_cycle_percentage * + __vlv_calculate_mod_freq(dev_priv->vbt.backlight.pwm_freq_hz, true)) / 100; + BUG_ON(min_duty == 0); + /* linear conversion to new range */ +#define FIXED_POINT_SCALE 1000 + level = ((level * FIXED_POINT_SCALE / max) * (max - min_duty) / FIXED_POINT_SCALE) + min_duty; +#undef FIXED_POINT_SCALE + } else if (freq < max) + /* scale to hardware, but be careful to not overflow */ + level = level * freq / max; + else + level = freq / max * level; panel->backlight.level = level; if (panel->backlight.device)