From patchwork Sat Jan 29 09:30:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 516371 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0T9VNLP001352 for ; Sat, 29 Jan 2011 09:31:44 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 322919ED74 for ; Sat, 29 Jan 2011 01:31:23 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (server109-228-6-236.live-servers.net [109.228.6.236]) by gabe.freedesktop.org (Postfix) with ESMTP id 305B99E761 for ; Sat, 29 Jan 2011 01:30:52 -0800 (PST) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.66.37; Received: from arrandale.alporthouse.com (unverified [78.156.66.37]) by fireflyinternet.com (Firefly Internet SMTP) with ESMTP id 24232117-1500050 for multiple; Sat, 29 Jan 2011 09:31:42 +0000 From: Chris Wilson To: Peter Clifton Date: Sat, 29 Jan 2011 09:30:40 +0000 Message-Id: <1296293440-4660-1-git-send-email-chris@chris-wilson.co.uk> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: References: X-Originating-IP: 78.156.66.37 Cc: intel-gfx@lists.freedesktop.org, stable@kernel.org Subject: [Intel-gfx] [PATCH] drm/i915/panel: Fix application of legacy backlight value X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.11 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 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sat, 29 Jan 2011 09:31:44 +0000 (UTC) diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c index c65992d..71ba046 100644 --- a/drivers/gpu/drm/i915/intel_panel.c +++ b/drivers/gpu/drm/i915/intel_panel.c @@ -205,10 +205,11 @@ u32 intel_panel_get_backlight(struct drm_device *dev) if (is_backlight_combination_mode(dev)){ u8 lbpc; - val &= ~1; pci_read_config_byte(dev->pdev, PCI_LBPC, &lbpc); + /* Report the value in [0:max] i.e. always multiplied + * by lbpc even if the hardware does not (0xff). + */ val *= lbpc; - val >>= 1; } } @@ -237,9 +238,12 @@ void intel_panel_set_backlight(struct drm_device *dev, u32 level) u32 max = intel_panel_get_max_backlight(dev); u8 lpbc; - lpbc = level * 0xfe / max + 1; - level /= lpbc; + lpbc = (level * 0xfe + max-1) / max + 1; pci_write_config_byte(dev->pdev, PCI_LBPC, lpbc); + + /* The hardware is tricksy and treats lpbc == 0xff specially */ + max = lpbc == 0xff ? 0xff : 0xff * lpbc; + level = (level + max-1) / max; } tmp = I915_READ(BLC_PWM_CTL);