Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1962894ybi; Thu, 20 Jun 2019 06:57:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjpaXCEUvXSU4y5fxtKr2a9goFgpSP/9niY1npPppQOPr2IzgR11iTjDGIJ7MYl2U1afPK X-Received: by 2002:a17:902:f089:: with SMTP id go9mr55827763plb.81.1561039027773; Thu, 20 Jun 2019 06:57:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561039027; cv=none; d=google.com; s=arc-20160816; b=jJTbCVaQck8hCXsd6ilJep4sxhOmk9tJa/Tlc9sKO2T1NVU3VBd8zkIt/RYLdW1UNM MaqyLMZ9UdJaU2hjYQyBSWh3DRStC6XZNpRAPMgOntzNqRh8KW+Oy6Qr178U51/xVYjz ukPEXAYvL3eAA9no/W7xd5VCBpkTxswX+GT96RH1wPVcWcODtBiRV08fhf+iM7mwd9jq EVKu0WjljJ2nYdS8y7zsB5nOUYXRVyia7hvbBJKKiyo7sQcHPFSois2z9UkiGh7AyldC mkVvILSSzEAEPJpc1hmbUjWcUwP1ppY5+gLRr8BNrMQptWRWv18t5lCaRkknhu9XzoEb R0tg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=lFm7NdIa2HHNh0HHo0ufCJYY4GiimW3KQmJfZuX/+1A=; b=ytWJiRZvz9rfjmVW6JTPqVgIaCY6YIsLPf8ksRSXDktElFqZdbkthZL9KUyW619Llj S900TzdKZqdZQJSCp2bqQm9sYejYEURSShqGCeLqXhrwxsgJxxl2c7pJygyTfOJG+kYY pbzFMgr/YeZ7Q+bN7PoeHKbLfF+CdFIaN2J36BzPG//p99DKaWlaQ3wrDC1ZowSSbCDr TDDUsizF8G43oHTOK8glkT2lGxeUPXFjxv5pVBY4H22Ebw2QZ8KBzhH7NGBsKRpmzsy0 wPvJQijIA7wv7+PpiTUkCXrUns/oJW6KWlBQob4iT08a4WY/3htn6QqNZITo1KFTzw5h K72g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ke6yJck4; 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 q7si6180248pgc.374.2019.06.20.06.56.52; Thu, 20 Jun 2019 06:57:07 -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=Ke6yJck4; 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 S1731567AbfFTN4a (ORCPT + 99 others); Thu, 20 Jun 2019 09:56:30 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:33678 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726786AbfFTN4a (ORCPT ); Thu, 20 Jun 2019 09:56:30 -0400 Received: by mail-wm1-f66.google.com with SMTP id h19so6986094wme.0 for ; Thu, 20 Jun 2019 06:56:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=lFm7NdIa2HHNh0HHo0ufCJYY4GiimW3KQmJfZuX/+1A=; b=Ke6yJck4jVgEhh/tKvRzf4ORtRvDLepDlBQG7G/hYzHQMzbUIg7HdjRx50Eut9YlBw XY4sV2dTy/Xj36F66LMAAEym59Oa53iPPeBZJXoKXqxrnOUH+dOUJd32WQGYDfM7opNG J3AjnSL2NiTS/ThA75UTKJa/nPmqpEnSbFnhay98AkR/l4+yfCNwdC5HNQ+/4YTQl8Wr Y68y8KszF3i3UrkHx0aWzS8lD9GISUTkuGIzCvCgEnXLAHz93/VkIhqB+tBasCXhJ5WC 4GIPtssQwjmmvH3+bRDbRGyrgyJTcexbC8Xb10toGo0T4GB4mgKNHy4+gIGl6fV5wWBZ auMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=lFm7NdIa2HHNh0HHo0ufCJYY4GiimW3KQmJfZuX/+1A=; b=Jruv30Vt8/Z0BTAlvvkLXZmMTKp8pK0lgmfQ7CLwof7nzlLJHuqNsYTLzpUG4tbSI8 Wizc1SbdTExpUfY1dYdBgr8fpry944cnjHrqxm274V3zWpLFsTuV0sY5FIQpU054q/I+ UBHtLlyk7e1VUo4nfbM2Po515TEonDcVrBz8Jk/oEKKwEJSM59X2IQzRhmiEoOQPRSgR pKDuq5V/3mmT54pr4iLRBLG8RcWN6tQ2SFHLI6oyveASBo32LZItdU8LBXgPNOPuxFDl q4+0noOwTgJ3CTELmsyZSa1qVQ0CqBLaL1lKzutOEydhXIcu1q1h7V/YaYwOrjVF18nw EqoA== X-Gm-Message-State: APjAAAUp8UVIp0DCcMc0Mgo83hyP8+zFYQNoe3CW2oaOJKMhiTggdOEl 6NdSu1uPFfSvaotxHmb83//1bQ== X-Received: by 2002:a1c:6156:: with SMTP id v83mr3145978wmb.81.1561038987399; Thu, 20 Jun 2019 06:56:27 -0700 (PDT) Received: from holly.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.googlemail.com with ESMTPSA id d18sm36948937wrb.90.2019.06.20.06.56.26 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jun 2019 06:56:26 -0700 (PDT) Subject: Re: Re: [PATCH] backlight: gpio-backlight: Set power state instead of brightness at probe To: Paul Kocialkowski , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Lee Jones , Jingoo Han , Bartlomiej Zolnierkiewicz , Thomas Petazzoni , Laurent Pinchart , Peter Ujfalusi References: <20190517150546.4508-1-paul.kocialkowski@bootlin.com> From: Daniel Thompson Message-ID: <29712212-0567-702b-fbc9-c0f37806d84c@linaro.org> Date: Thu, 20 Jun 2019 14:56:25 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 18/06/2019 13:58, Paul Kocialkowski wrote: > 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). My apologies. This patch brought on such severe deja-vu I got rather confused. Then when I went digging I've also dropped the ball on the same feature previously. Peter Ujfalusi provided a similar patch to yours but with a slightly different implementation: https://lore.kernel.org/patchwork/patch/1002359/ On the whole I think it is important to read the GPIO pin since otherwise we swap problems when there bootloader does setup the backlight for problems where it does not. The thing I don't get is why both patches try to avoid setting the backlight brightness from def_value. Simple displays, especially monochrome ones are perfectly readable with the backlight off... zero brightness is not a "bad" value. Not sure if Peter is still willing to rev his version of this code (given how badly we neglected him previously) or whether you want to try and combine both ideas. Daniel. > > 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);