From patchwork Mon Jul 9 06:04:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Courbot X-Patchwork-Id: 1170911 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id CC54C3FD4F for ; Mon, 9 Jul 2012 06:08:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751484Ab2GIGC6 (ORCPT ); Mon, 9 Jul 2012 02:02:58 -0400 Received: from hqemgate04.nvidia.com ([216.228.121.35]:10925 "EHLO hqemgate04.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751043Ab2GIGCg (ORCPT ); Mon, 9 Jul 2012 02:02:36 -0400 Received: from hqnvupgp07.nvidia.com (Not Verified[216.228.121.13]) by hqemgate04.nvidia.com id ; Sun, 08 Jul 2012 23:01:51 -0700 Received: from hqemhub03.nvidia.com ([172.17.108.22]) by hqnvupgp07.nvidia.com (PGP Universal service); Sun, 08 Jul 2012 22:58:55 -0700 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Sun, 08 Jul 2012 22:58:55 -0700 Received: from percival.nvidia.com (172.20.144.16) by hqemhub03.nvidia.com (172.20.150.15) with Microsoft SMTP Server (TLS) id 8.3.264.0; Sun, 8 Jul 2012 23:02:34 -0700 From: Alexandre Courbot To: Thierry Reding CC: , , Alexandre Courbot Subject: [PATCHv3] pwm_backlight: pass correct brightness to callback Date: Mon, 9 Jul 2012 15:04:23 +0900 Message-ID: <1341813863-18822-1-git-send-email-acourbot@nvidia.com> X-Mailer: git-send-email 1.7.11.1 In-Reply-To: <4FFA6BCA.2040101@nvidia.com> References: <4FFA6BCA.2040101@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org pwm_backlight_update_status calls the notify() and notify_after() callbacks before and after applying the new PWM settings. However, if brightness levels are used, the brightness value will be changed from the index into the levels array to the PWM duty cycle length before being passed to notify_after(), which results in inconsistent behavior. Signed-off-by: Alexandre Courbot --- drivers/video/backlight/pwm_bl.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index 057389d..be48517 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -54,14 +54,17 @@ static int pwm_backlight_update_status(struct backlight_device *bl) pwm_config(pb->pwm, 0, pb->period); pwm_disable(pb->pwm); } else { + int duty_cycle; if (pb->levels) { - brightness = pb->levels[brightness]; + duty_cycle = pb->levels[brightness]; max = pb->levels[max]; + } else { + duty_cycle = brightness; } - brightness = pb->lth_brightness + - (brightness * (pb->period - pb->lth_brightness) / max); - pwm_config(pb->pwm, brightness, pb->period); + duty_cycle = pb->lth_brightness + + (duty_cycle * (pb->period - pb->lth_brightness) / max); + pwm_config(pb->pwm, duty_cycle, pb->period); pwm_enable(pb->pwm); }