From patchwork Wed Feb 26 11:39:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Ying X-Patchwork-Id: 3723611 Return-Path: X-Original-To: patchwork-linux-fbdev@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 B97159F2F7 for ; Wed, 26 Feb 2014 11:37:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D4B0720173 for ; Wed, 26 Feb 2014 11:37:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ACA3820166 for ; Wed, 26 Feb 2014 11:37:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751224AbaBZLhh (ORCPT ); Wed, 26 Feb 2014 06:37:37 -0500 Received: from am1ehsobe001.messaging.microsoft.com ([213.199.154.204]:18682 "EHLO am1outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751200AbaBZLhh (ORCPT ); Wed, 26 Feb 2014 06:37:37 -0500 Received: from mail26-am1-R.bigfish.com (10.3.201.234) by AM1EHSOBE020.bigfish.com (10.3.207.142) with Microsoft SMTP Server id 14.1.225.22; Wed, 26 Feb 2014 11:37:35 +0000 Received: from mail26-am1 (localhost [127.0.0.1]) by mail26-am1-R.bigfish.com (Postfix) with ESMTP id 5CA8120339; Wed, 26 Feb 2014 11:37:35 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzzz1f42h2148h208ch1ee6h1de0h1fdah2073h2146h1202h1e76h2189h1d1ah1d2ah21bch1fc6hzz1de098h8275bh1de097hz2dh2a8h839he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1b2fh2222h224fh1fb3h1d0ch1d2eh1d3fh1dc1h1dfeh1dffh1e23h1fe8h1ff5h2218h2216h226dh22d0h24afh2327h2336h2438h2461h2487h24d7h2516h2545h255eh25cch1155h) Received: from mail26-am1 (localhost.localdomain [127.0.0.1]) by mail26-am1 (MessageSwitch) id 139341465421106_8416; Wed, 26 Feb 2014 11:37:34 +0000 (UTC) Received: from AM1EHSMHS006.bigfish.com (unknown [10.3.201.234]) by mail26-am1.bigfish.com (Postfix) with ESMTP id F40BC3C0074; Wed, 26 Feb 2014 11:37:33 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by AM1EHSMHS006.bigfish.com (10.3.207.106) with Microsoft SMTP Server (TLS) id 14.16.227.3; Wed, 26 Feb 2014 11:37:31 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-004.039d.mgd.msft.net (10.84.1.14) with Microsoft SMTP Server (TLS) id 14.3.158.2; Wed, 26 Feb 2014 11:37:29 +0000 Received: from victor.ap.freescale.net (victor.ap.freescale.net [10.192.241.62]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id s1QBbOj5017039; Wed, 26 Feb 2014 04:37:25 -0700 From: Liu Ying To: , CC: , , , , Subject: [PATCH] video: pwm backlight: power off when necessary Date: Wed, 26 Feb 2014 19:39:12 +0800 Message-ID: <1393414752-8861-1-git-send-email-Ying.Liu@freescale.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 The pwm backlight should be powered off only in two cases: 1) pwm polarity is normal and brightness is zero. 2) pwm polarity is inversed and brightness is maximal, that is, 100% duty. This patch implements this logic in the pwm backlight driver and actually fixes the issue that backlight is on when we intend to set the brightness to be zero for an inversed pwm signal. The root cause of the issue is that power is off in that case. Cc: Thierry Reding Cc: Jingoo Han Cc: Jean-Christophe Plagniol-Villard Cc: Tomi Valkeinen Signed-off-by: Liu Ying --- drivers/video/backlight/pwm_bl.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index b75201f..e61e66a 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -100,6 +100,8 @@ static int compute_duty_cycle(struct pwm_bl_data *pb, int brightness) static int pwm_backlight_update_status(struct backlight_device *bl) { struct pwm_bl_data *pb = bl_get_data(bl); + enum pwm_polarity polarity = pb->pwm->polarity; + int max = bl->props.max_brightness; int brightness = bl->props.brightness; int duty_cycle; @@ -111,12 +113,14 @@ static int pwm_backlight_update_status(struct backlight_device *bl) if (pb->notify) brightness = pb->notify(pb->dev, brightness); - if (brightness > 0) { + if ((polarity == PWM_POLARITY_NORMAL && brightness == 0) || + (polarity == PWM_POLARITY_INVERSED && brightness == max)) { + pwm_backlight_power_off(pb); + } else { duty_cycle = compute_duty_cycle(pb, brightness); pwm_config(pb->pwm, duty_cycle, pb->period); pwm_backlight_power_on(pb, brightness); - } else - pwm_backlight_power_off(pb); + } if (pb->notify_after) pb->notify_after(pb->dev, brightness);