Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp892037ybl; Wed, 21 Aug 2019 07:07:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqwfxUm3t5ci/Y11z9UATYAzPxFjMQuhQ24h7wFcBHXmvSGm8Ec6lzXkPnskG9Grdsftul79 X-Received: by 2002:a17:902:ba81:: with SMTP id k1mr35384581pls.213.1566396447164; Wed, 21 Aug 2019 07:07:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566396447; cv=none; d=google.com; s=arc-20160816; b=wW0ukds/E/5kt3zlaQxaeWKR92jzvy3C19VEks872cLdCSvJLANsCzUM9f58gZ+H5D CvwfpZ+gxXGsPdHbNIFmxjgzoGFKFlx3lXKKIZTrZCkVUUstfsi8tmiFPa5feAl3opIZ Yn8TgrDH8jLVDrYERgHnJLwo2dSdYRwWyQ9pO7nbpSqI/uPy6w6QMrKdGPczo6GeFPVd zahrbYz8bcZR5spcBYfYEJIVGOLBouZhaOgeOXfrI1kKunaP68RvPMusw/vRIoq8N+s3 5smfNttRQjLX0UzrEBKsf9CYP45lSuhaTFDExFQ8TiD2uXm/NLjZkNQ6zHe76vjQ4jgq jB3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Ep3pc90vpoVG0Lq8JYK4R2Sa69WJp1f9mSFS+lsduu0=; b=oODSjlW6k3lKYDlhdssy0JDeMhKyJokz1kkSnUbDlUpCJTgMKye7naO94+55bhBOTb MsvDkTvPQYHKLVPU5bfrfRY7IK+QQxYq3OpwXYrTL6b6lhdNammnzQME29e6JgeM657D APA7j9CWR67Jv82eIzdoCv0OfsM5NW4HNyZN4sOmJYwuQSM3N9HYEZqxwRBxv/XkIewM QBNLfju60+wUMGK2okcDcpbHBCy2NlI+AFc+ndquU4esuxn7h2u3teMXaYmVtfRQ3I/c WrxZcOaVYfdE6V1ys+QCyUBO7g468FeVOD+W4RtqRnP/AH5PJiDtjok62hTJGhGdOPH/ DFXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CMLmpdVr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r11si14312159plo.150.2019.08.21.07.07.11; Wed, 21 Aug 2019 07:07:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CMLmpdVr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729058AbfHUOE7 (ORCPT + 99 others); Wed, 21 Aug 2019 10:04:59 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:46986 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727949AbfHUOE7 (ORCPT ); Wed, 21 Aug 2019 10:04:59 -0400 Received: by mail-wr1-f66.google.com with SMTP id z1so2147322wru.13 for ; Wed, 21 Aug 2019 07:04:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Ep3pc90vpoVG0Lq8JYK4R2Sa69WJp1f9mSFS+lsduu0=; b=CMLmpdVrYckFsCp7XcD4I5fsNQE83lkhqKBvYVnwzZc1V2q5+GmgP396fcmaJ7NSKu /IKfoU5FDuJidTSGvV5vAROimcrCuS/GNN0EM9JI0yymk9228JEMAkFV6poxxjj+/OuP PpxUF1n6buUWwfMT808oS62Hnx8TfhNIV79aaiXiGIyenVzccqpdngz57BNzI9NRwoDB R5R+vU9xdiYso82A7HHmwJ2WCDiAM6o5f4fDWsBdHMKzIMyBJQsiYozECbPPO+xlCmBP KtInRJXJqhrlAYeAYLnwkj09ig3XVXSWb+zTHeD23nULW3fUApzAwTQt7VSrYPy3IF75 eDdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Ep3pc90vpoVG0Lq8JYK4R2Sa69WJp1f9mSFS+lsduu0=; b=b8ZQtpiIhIAwyCvCXXCMGTrBVEfWW1IAzlAyPs8L8mlob4xAWiceinFSRLccyKDbzi oOdMCeuIMWIJTR03XGtL6BMspUznwRstcmQUWhfnwpkJ3MZJt2TGDa94wnfJQJc5LkfF h+ZQaB5kJ+rMDOSiArzb6Ww7cSJeJWzGrScP/IkW+vRXq16L6/3qrt1jPLnwWVjcLSQv NusO3EJ7lldehb6a4vQ3ukZBGrBcVRI0f9D0mQTc0Lx6nC1zbZ3O/teUxSVByVLv1B2p iWpjRlgD6L2S/+EqgW12+7eQU1AScUKs6WlFauF9XPj1dDbFjuUfs8Y6RMT1iEYJkz/K YRhA== X-Gm-Message-State: APjAAAWzJv6qiMJe88vx9o+goisRiCWO+4ioEGLG1fLySqnPDW+VojdL /Z9FHkIf7P6EZY6Jg+rAhul+qA== X-Received: by 2002:adf:f48d:: with SMTP id l13mr43516861wro.190.1566396296807; Wed, 21 Aug 2019 07:04:56 -0700 (PDT) Received: from holly.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id m6sm16729440wrq.95.2019.08.21.07.04.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2019 07:04:55 -0700 (PDT) Date: Wed, 21 Aug 2019 15:04:54 +0100 From: Daniel Thompson To: Peter Ujfalusi Cc: lee.jones@linaro.org, jingoohan1@gmail.com, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, paul.kocialkowski@bootlin.com Subject: Re: [PATCH v3] backlight: gpio-backlight: Correct initial power state handling Message-ID: <20190821140454.6uuquwx7bkyx656e@holly.lan> References: <20190731084018.5318-1-peter.ujfalusi@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190731084018.5318-1-peter.ujfalusi@ti.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 31, 2019 at 11:40:18AM +0300, Peter Ujfalusi wrote: > The default-on property - or the def_value via legacy pdata) should be > handled as: > if it is 1, the backlight must be enabled (kept enabled) > if it is 0, the backlight must be disabled (kept disabled) > > This only works for the case when default-on is set. If it is not set then > the brightness of the backlight is set to 0. Now if the backlight is > enabled by external driver (graphics) the backlight will stay disabled since > the brightness is configured as 0. The backlight will not turn on. > > In order to minimize screen flickering during device boot: > > The initial brightness should be set to 1. > > If booted in non DT mode or no phandle link to the backlight node: > follow the def_value/default-on to select UNBLANK or POWERDOWN > > If in DT boot we have phandle link then leave the GPIO in a state which the > bootloader left it and let the user of the backlight to configure it > further. > > Signed-off-by: Peter Ujfalusi Reviewed-by: Daniel Thompson > --- > Hi, > > sorry for the delay, but got distracted a bit with the resend of this... > Let's try again ;) > > Changes since v2 (https://lore.kernel.org/patchwork/patch/1002359/): > - Rebased on drm-next > > Changes since v1: > - Implement similiar initial power state handling as pwm backlight have > > Regards, > Peter > > drivers/video/backlight/gpio_backlight.c | 24 ++++++++++++++++++++---- > 1 file changed, 20 insertions(+), 4 deletions(-) > > diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c > index e84f3087e29f..18e053e4716c 100644 > --- a/drivers/video/backlight/gpio_backlight.c > +++ b/drivers/video/backlight/gpio_backlight.c > @@ -59,13 +59,11 @@ static int gpio_backlight_probe_dt(struct platform_device *pdev, > struct gpio_backlight *gbl) > { > struct device *dev = &pdev->dev; > - enum gpiod_flags flags; > int ret; > > gbl->def_value = device_property_read_bool(dev, "default-on"); > - flags = gbl->def_value ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW; > > - gbl->gpiod = devm_gpiod_get(dev, NULL, flags); > + gbl->gpiod = devm_gpiod_get(dev, NULL, GPIOD_ASIS); > if (IS_ERR(gbl->gpiod)) { > ret = PTR_ERR(gbl->gpiod); > > @@ -79,6 +77,22 @@ static int gpio_backlight_probe_dt(struct platform_device *pdev, > return 0; > } > > +static int gpio_backlight_initial_power_state(struct gpio_backlight *gbl) > +{ > + struct device_node *node = gbl->dev->of_node; > + > + /* Not booted with device tree or no phandle link to the node */ > + if (!node || !node->phandle) > + return gbl->def_value ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; > + > + /* if the enable GPIO is disabled, do not enable the backlight */ > + if (gpiod_get_value_cansleep(gbl->gpiod) == 0) > + return FB_BLANK_POWERDOWN; > + > + return FB_BLANK_UNBLANK; > +} > + > + > static int gpio_backlight_probe(struct platform_device *pdev) > { > struct gpio_backlight_platform_data *pdata = > @@ -136,7 +150,9 @@ static int gpio_backlight_probe(struct platform_device *pdev) > return PTR_ERR(bl); > } > > - bl->props.brightness = gbl->def_value; > + bl->props.power = gpio_backlight_initial_power_state(gbl); > + bl->props.brightness = 1; > + > backlight_update_status(bl); > > platform_set_drvdata(pdev, bl); > -- > Peter > > Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. > Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki