Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp252602iol; Thu, 9 Jun 2022 03:15:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUjQcGIAIC2AqUqogCWmdNPy5nQZ644ahnXpyufYn0pLzK1e7hSitiT5k9Lz6JXgDuXBGx X-Received: by 2002:a05:6a00:b42:b0:51c:79bd:4226 with SMTP id p2-20020a056a000b4200b0051c79bd4226mr4548554pfo.70.1654769722506; Thu, 09 Jun 2022 03:15:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654769722; cv=none; d=google.com; s=arc-20160816; b=BmcEGEw/k78VaA1MAfvOQipaIWJIXwW1M94PxhXWOptmk4zqgqNt3yjgr+qVwiFQ07 Us/ZjwsW+CVm1xD8G017qnISAdbG0qdWQri+bFIB2a44NM4TxOL0kxQrAFf0FlDbR8/E oA684x6lbJyl3b5CE3SbYwTCBRYT4VjAE3ktNJcREyHBdXBUKALaGE2XS8FkWmHq4Ico Yb4IjhtPQhpsw1lR7Vzlyr++n4ju8hwFqojgdVzWSGROSaXiYOJv+zQoTQsDdGpFxG80 CqxoGqgzZl+StgL3LI8SYBUmFK5QBKH6aQTh8UCfF6wQVSki43LEwMDApx8iL0EXQZz5 clRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=dgxIUh9kZnAhshZpAfcCNmc5NM9XP1H+pazqAWk3o4M=; b=Zw93JMN+g5LEbpCt0fF1bewyBtOJduSONfUpWJhQDFXYpnpUlYMW07WqY8Grp4sx+e kggvMBrOTJlswIiuvEf8t0dWBTjWxpbJcW2V9LWE+nC6Rt+k4VAOZC63pZAVv5ttSTcL 4Q062nhaSWNEl8eEf5HU+EGlbsVYeJ3TNZGHR2g7ve9ttwMhvm1FTfB4yGuZDANRW4MO 1jk/0TvEocnM893u1FDVIKVgFjFFyoJjHpus8C60VgjU3XsWVm5Y90ZBSAPEPsll79P8 kwnDH/17thXlpg4wPLPoHRRW3k1mOpSrTvZDxySXzzO/SgGCxXzmsRkxwJ9LbhhYLKBa t/2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="sYbi7/4Q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d14-20020a65620e000000b003fdef35644esi11350256pgv.649.2022.06.09.03.15.08; Thu, 09 Jun 2022 03:15:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="sYbi7/4Q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S234712AbiFIJyT (ORCPT + 99 others); Thu, 9 Jun 2022 05:54:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234288AbiFIJyS (ORCPT ); Thu, 9 Jun 2022 05:54:18 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04E88194254 for ; Thu, 9 Jun 2022 02:54:17 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id k19so31630828wrd.8 for ; Thu, 09 Jun 2022 02:54:16 -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; bh=dgxIUh9kZnAhshZpAfcCNmc5NM9XP1H+pazqAWk3o4M=; b=sYbi7/4QmhUcDAphES1n3sjziqocBdZaVokz7jqGR4vrF3G3Qx7JFQpiauElXr2toJ gZCDaP679DwAhMrD7ycpRlIYOzaEABiJxvohe6lQDbOyZ046TDwXOkS0cfiY0nbpoyJn YCLA016qOzd+q/EJpiVMQjT/jLcQTvR3KG6oXmdYhV8Q2nNGNmausPfLhEbsQeMd/AeP cCNlWGGAQTCzmt6MBNFK4z7FzPN3oY6B1jDnNTP8HO6T7vXWhZeqo2tkfKjPrjmkzih1 okOr9aVs9Hff9CcOIbUAMS5m1PFeAewjo+nOUf8xnjRWRtJM3OEVD6S68MmTywxggO4G esMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=dgxIUh9kZnAhshZpAfcCNmc5NM9XP1H+pazqAWk3o4M=; b=SZHjqzuA5NEmRAFkWGvgt0e2MEMZHxIgJAoxkjCycUV63UVmGTbvjVb7UqarcKpAMF f2ND3gu4QTMrLiq0DBjtzNpheswdGUm7mK2U3Srg2K9nEfj6HLhKoM0N/DRoeyuZRO0a ruf+FzqV6QoqmHS7OzCzO+UgwfS3uOUSTtmYORV7YrrvfnxE4Pe6TjTwTC9vAM/9wcuY P84AzQg1wqIG0E+EuQPlVHMsWudckzNqVsfjRms4Sc6Ww2ihu3zUSJO2KMO430zD+1CI nqbHOzCXSGqark77Hub2CE30F8n3UTwqlB8Ukd89xRR0m53o0TlBVR0tZ3s5f8/XohNh Uyog== X-Gm-Message-State: AOAM530oB9ces4PA/YT+9HZgrkTlyqtZdu2/JxE2g1JfiRCnSHENlgtL m/XxMYo1PDENS/zzqRuwQFa90A== X-Received: by 2002:a5d:64e7:0:b0:218:5626:7e7f with SMTP id g7-20020a5d64e7000000b0021856267e7fmr11844016wri.245.1654768455480; Thu, 09 Jun 2022 02:54:15 -0700 (PDT) Received: from maple.lan (cpc141216-aztw34-2-0-cust174.18-1.cable.virginm.net. [80.7.220.175]) by smtp.gmail.com with ESMTPSA id h13-20020a5d504d000000b002100e86319asm15031976wrt.78.2022.06.09.02.54.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:54:14 -0700 (PDT) Date: Thu, 9 Jun 2022 10:54:12 +0100 From: Daniel Thompson To: Stephen Kitt Cc: Nicolas Ferre , Helge Deller , Alexandre Belloni , Claudiu Beznea , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] fbdev: atmel_lcdfb: Rework backlight status updates Message-ID: <20220609095412.fccofr2e2kpzhw4t@maple.lan> References: <20220608205623.2106113-1-steve@sk2.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220608205623.2106113-1-steve@sk2.org> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 08, 2022 at 10:56:23PM +0200, Stephen Kitt wrote: > Instead of checking the state of various backlight_properties fields > against the memorised state in atmel_lcdfb_info.bl_power, > atmel_bl_update_status() should retrieve the desired state using > backlight_get_brightness (which takes into account the power state, > blanking etc.). This means the explicit checks using props.fb_blank > and props.power can be dropped. > > Then brightness can only be negative if the backlight is on but > props.brightness is negative, so the test before reading the > brightness value from the hardware can be simplified to > (brightness < 0). props.brightness should always be in the interval 0..max_brightness. This is enforced by the main backlight code (and APIs to set the brightness use unsigned values). Thus props.brightness could only be negative is the driver explicitly sets a negative value as some kind of placeholder (which this driver does not do). I don't think there is any need to keep this logic. Daniel. > diff --git a/drivers/video/fbdev/atmel_lcdfb.c b/drivers/video/fbdev/atmel_lcdfb.c > index 1fc8de4ecbeb..06159a4da293 100644 > --- a/drivers/video/fbdev/atmel_lcdfb.c > +++ b/drivers/video/fbdev/atmel_lcdfb.c > @@ -109,22 +108,10 @@ static u32 contrast_ctr = ATMEL_LCDC_PS_DIV8 > static int atmel_bl_update_status(struct backlight_device *bl) > { > struct atmel_lcdfb_info *sinfo = bl_get_data(bl); > - int power = sinfo->bl_power; > - int brightness = bl->props.brightness; > + int brightness = backlight_get_brightness(bl); > > - /* REVISIT there may be a meaningful difference between > - * fb_blank and power ... there seem to be some cases > - * this doesn't handle correctly. > - */ > - if (bl->props.fb_blank != sinfo->bl_power) > - power = bl->props.fb_blank; > - else if (bl->props.power != sinfo->bl_power) > - power = bl->props.power; > - > - if (brightness < 0 && power == FB_BLANK_UNBLANK) > + if (brightness < 0) > brightness = lcdc_readl(sinfo, ATMEL_LCDC_CONTRAST_VAL); > - else if (power != FB_BLANK_UNBLANK) > - brightness = 0; > > lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_VAL, brightness); > if (contrast_ctr & ATMEL_LCDC_POL_POSITIVE)