Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3745822ybi; Tue, 18 Jun 2019 05:59:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjslU1L1EA4y6IVct0wkSxG7CiZQLHXS607DHA0IzmHUeO8/Ekgx1LJcjjehtH+WxIwvMK X-Received: by 2002:a17:902:ac85:: with SMTP id h5mr107286246plr.198.1560862759303; Tue, 18 Jun 2019 05:59:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560862759; cv=none; d=google.com; s=arc-20160816; b=QHYg+1CxyzQwIKRGWKLUdDuNXdddnQL8hPGVEdYnqUFGoUJsdeTeWu+RusnbucbJlC 7K1AnS5+whqtHSlGKKdAVs5Idw1qlXUqw4zH7r/4TcFzBw0tKodXhODGam2ngvRH/1P6 CgUDlyNR7ZpEBNsKt6rJe+3ndRI18A9XVkKGUuDHCXV3TmIuW+kpxMq+vmcGhGR20cN1 nDt49XdfCmKvn3ZqJ9MQemfqXVtRujIa71wvgxN0yT+yGQgRCZ3nNAR00cN+78CVHFdh +SzNg/051/oBWi3xY5weHS/agwfJm+ZKz9PPcZRAycITfvY62QNakhIA4NL5K1lEvfsH AncQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:organization:references:in-reply-to:date:cc:to:from :subject:message-id; bh=lh5RNz/SjKsusEai7fecA9ZeTInTKwi1SWEawe9PH/U=; b=BKMMnV7VIN/8fWTdaKhYkmnU6SLC6mq1CT/LPj3el9crp6jBiXxGEyvRRwSfRUHq9K V39VdwLWn4+29ffBX555nr14JfwvBDDz1mpeu4cylyTyiI+eR9gG3VPfCrxPR+WDVyx8 isyvHOlzbm/+P/mS9Q3sdcwS9ptYnHvMrdHR/9/nlG//2II1/kl9Xv0x/xq3l5CAbebP iig0fHPITWbehKTmjl5gYzez94mleN3OpjZL1+LRYUIcD95Y5JIpt1Sm0dVOpCHwLgp+ bBNxFv01KeWTfnaYzC4mFBTGWJ/hNNlmiaVmw2QT5su39wb/C9TYTpm5txnTnBadApqr 45Ew== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o3si12599305pll.53.2019.06.18.05.59.03; Tue, 18 Jun 2019 05:59:19 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727097AbfFRM6w (ORCPT + 99 others); Tue, 18 Jun 2019 08:58:52 -0400 Received: from relay12.mail.gandi.net ([217.70.178.232]:43581 "EHLO relay12.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725988AbfFRM6w (ORCPT ); Tue, 18 Jun 2019 08:58:52 -0400 Received: from aptenodytes (aaubervilliers-681-1-81-150.w90-88.abo.wanadoo.fr [90.88.23.150]) (Authenticated sender: paul.kocialkowski@bootlin.com) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 551DF200008; Tue, 18 Jun 2019 12:58:48 +0000 (UTC) Message-ID: Subject: Re: [PATCH] backlight: gpio-backlight: Set power state instead of brightness at probe From: Paul Kocialkowski To: dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Lee Jones , Daniel Thompson , Jingoo Han , Bartlomiej Zolnierkiewicz , Thomas Petazzoni , Laurent Pinchart Date: Tue, 18 Jun 2019 14:58:47 +0200 In-Reply-To: <20190517150546.4508-1-paul.kocialkowski@bootlin.com> References: <20190517150546.4508-1-paul.kocialkowski@bootlin.com> Organization: Bootlin Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Fri, 2019-05-17 at 17:05 +0200, Paul Kocialkowski wrote: > On a trivial gpio-backlight setup with a panel using the backlight but > no boot software to enable it beforehand, we fall in a case where the > backlight is disabled (not just blanked) and thus remains disabled when > the panel gets enabled. > > Setting gbl->def_value via the device-tree prop allows enabling the > backlight in this situation, but it will be unblanked straight away, > in compliance with the binding. This does not work well when there was no > boot software to display something before, since we really need to unblank > by the time the panel is enabled, not before. > > Resolve the situation by setting the brightness to 1 at probe and > managing the power state accordingly, a bit like it's done in > pwm-backlight. Any feedback on this? I was under the impression that it could be quite controversial, as it implies that the backlight can no longer be enabled without a bound panel (which IMO makes good sense but could be a matter to debate). Cheers, Paul > Fixes: 8b770e3c9824 ("backlight: Add GPIO-based backlight driver") > Signed-off-by: Paul Kocialkowski > --- > drivers/video/backlight/gpio_backlight.c | 19 ++++++++++++++++++- > 1 file changed, 18 insertions(+), 1 deletion(-) > > diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c > index e470da95d806..c9cb97fa13d0 100644 > --- a/drivers/video/backlight/gpio_backlight.c > +++ b/drivers/video/backlight/gpio_backlight.c > @@ -57,6 +57,21 @@ static const struct backlight_ops gpio_backlight_ops = { > .check_fb = gpio_backlight_check_fb, > }; > > +static int gpio_backlight_initial_power_state(struct gpio_backlight *gbl) > +{ > + struct device_node *node = gbl->dev->of_node; > + > + /* If we absolutely want the backlight enabled at boot. */ > + if (gbl->def_value) > + return FB_BLANK_UNBLANK; > + > + /* If there's no panel to unblank the backlight later. */ > + if (!node || !node->phandle) > + return FB_BLANK_UNBLANK; > + > + return FB_BLANK_POWERDOWN; > +} > + > static int gpio_backlight_probe_dt(struct platform_device *pdev, > struct gpio_backlight *gbl) > { > @@ -142,7 +157,9 @@ static int gpio_backlight_probe(struct platform_device *pdev) > return PTR_ERR(bl); > } > > - bl->props.brightness = gbl->def_value; > + bl->props.brightness = 1; > + bl->props.power = gpio_backlight_initial_power_state(gbl); > + > backlight_update_status(bl); > > platform_set_drvdata(pdev, bl); -- Paul Kocialkowski, Bootlin Embedded Linux and kernel engineering https://bootlin.com