Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp752200iol; Thu, 9 Jun 2022 13:13:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzW2KjOXKJIQ6QBTnFmVKegrvXL1yElaRYjSaqc1qRfaKsJvBofKz0Bos+0FPNC+lvuSukm X-Received: by 2002:a17:906:2b92:b0:709:236c:de1b with SMTP id m18-20020a1709062b9200b00709236cde1bmr39224312ejg.754.1654805638287; Thu, 09 Jun 2022 13:13:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654805638; cv=none; d=google.com; s=arc-20160816; b=gY+ivK3uCcgcK/CmNOQ3371+G4Fbr70VjaImSpBM8ouHM18bmpTFf3cz3WGQ6LUK4h DRnsHcYdLM2nvM+q7al/ONnlhSiAKH3cJv8m9+Gf/OSCIloAyNfkrXvjIOgP/iUdrC2I UzMU220QpaZvGmSn97emu2LtpY5xSDjIJbLiDtbw3NZlHnB481V9nKVAKkKTashYKqsm BCHC8yduvD44ZNQBvgBxaCbr9XlBzs1uJhn8dADOQKBDa1X7mdhodIc+qOqKAvFl/t3J 5ynt5YhOCEiNag8Kel5m5bOyCkIdhg5LI0WSaip4kWG+bwiZGCfgPtCc3doCalbebT0d ytqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=7iblyi4oCNYtMfTkWIJJkyy0IxkvkM1P9UeEoViOh7Y=; b=br8K1hd1T8Pin6u4UTk//0ZO7qXaeysL1s+7g/hSNuc/rYq7kZlwhz5SHgvxu9ikZ9 ak+OWhBVpcTTuQgJsw0BcISeSmdssHMrXEwREky9/JBui6hVsHKFNcR/Sait3NuRn4ZZ oqxA0+TAVu4HRpCxAaeBl9E5iEPEG1NBLgfxG9NH/h5xJNjWS2OiCDB39Hdx23MaGRD2 JliTURn/CF5sSNC8Gxlczhqx5R26ZhxZm+0viO/TR4IOsxDX5OxwmdSJcFoVjTNOQXG0 4F3fFboMq6kLSTBn3E5Ws0vYJ4euo6Z2Y62MUldLpCsN0USP97ZTUEmju/o/QqoyD6NC tgNg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o10-20020a056402438a00b0042e0b28922asi197073edc.7.2022.06.09.13.13.32; Thu, 09 Jun 2022 13:13:58 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344827AbiFITYR (ORCPT + 99 others); Thu, 9 Jun 2022 15:24:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344909AbiFITYO (ORCPT ); Thu, 9 Jun 2022 15:24:14 -0400 X-Greylist: delayed 2402 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 09 Jun 2022 12:24:11 PDT Received: from 4.mo550.mail-out.ovh.net (4.mo550.mail-out.ovh.net [46.105.76.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2EB01145B for ; Thu, 9 Jun 2022 12:24:11 -0700 (PDT) Received: from player788.ha.ovh.net (unknown [10.108.1.240]) by mo550.mail-out.ovh.net (Postfix) with ESMTP id B094224FEE for ; Thu, 9 Jun 2022 18:06:25 +0000 (UTC) Received: from sk2.org (82-65-25-201.subs.proxad.net [82.65.25.201]) (Authenticated sender: steve@sk2.org) by player788.ha.ovh.net (Postfix) with ESMTPSA id C45D92B66FB16; Thu, 9 Jun 2022 18:06:13 +0000 (UTC) Authentication-Results: garm.ovh; auth=pass (GARM-104R005d40fa0bf-8e0f-46d4-85d9-c1d69ed95b28, FB82ABC7E83112E23A0D9558C7043BAE976A9334) smtp.auth=steve@sk2.org X-OVh-ClientIp: 82.65.25.201 From: Stephen Kitt To: Nicolas Ferre , Alexandre Belloni , Claudiu Beznea Cc: Daniel Thompson , Sam Ravnborg , Stephen Kitt , Helge Deller , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] fbdev: atmel_lcdfb: Rework backlight status updates Date: Thu, 9 Jun 2022 20:04:40 +0200 Message-Id: <20220609180440.3138625-1-steve@sk2.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 3936427552257050331 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvfedruddtledgudduiecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffoggfgsedtkeertdertddtnecuhfhrohhmpefuthgvphhhvghnucfmihhtthcuoehsthgvvhgvsehskhdvrdhorhhgqeenucggtffrrghtthgvrhhnpeelgeetueejffejfeejvefhtddufeejgfetleegtddukeelieelvddvteduveejtdenucfkpheptddrtddrtddrtddpkedvrdeihedrvdehrddvtddunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmohguvgepshhmthhpohhuthdphhgvlhhopehplhgrhigvrhejkeekrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomhepshhtvghvvgesshhkvddrohhrghdpnhgspghrtghpthhtohepuddprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdpoffvtefjohhsthepmhhoheehtd X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 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. The backlight framework ensures that backlight is never negative, so the test before reading the brightness from the hardware always ends up false and the whole block can be removed. The framework retrieves the brightness from the hardware through atmel_bl_get_brightness() when necessary. As a result, bl_power in struct atmel_lcdfb_info is no longer necessary, so remove that while we're at it. Since we only ever care about reading the current state in backlight_properties, drop the updates at the end of the function. Signed-off-by: Stephen Kitt Cc: Nicolas Ferre Cc: Helge Deller Cc: Alexandre Belloni Cc: Claudiu Beznea Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linux-arm-kernel@lists.infradead.org --- drivers/video/fbdev/atmel_lcdfb.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/drivers/video/fbdev/atmel_lcdfb.c b/drivers/video/fbdev/atmel_lcdfb.c index 1fc8de4ecbeb..8187a7c4f910 100644 --- a/drivers/video/fbdev/atmel_lcdfb.c +++ b/drivers/video/fbdev/atmel_lcdfb.c @@ -49,7 +49,6 @@ struct atmel_lcdfb_info { struct clk *lcdc_clk; struct backlight_device *backlight; - u8 bl_power; u8 saved_lcdcon; u32 pseudo_palette[16]; @@ -109,22 +108,7 @@ 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; - - /* 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) - brightness = lcdc_readl(sinfo, ATMEL_LCDC_CONTRAST_VAL); - else if (power != FB_BLANK_UNBLANK) - brightness = 0; + int brightness = backlight_get_brightness(bl); lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_VAL, brightness); if (contrast_ctr & ATMEL_LCDC_POL_POSITIVE) @@ -133,8 +117,6 @@ static int atmel_bl_update_status(struct backlight_device *bl) else lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, contrast_ctr); - bl->props.fb_blank = bl->props.power = sinfo->bl_power = power; - return 0; } @@ -155,8 +137,6 @@ static void init_backlight(struct atmel_lcdfb_info *sinfo) struct backlight_properties props; struct backlight_device *bl; - sinfo->bl_power = FB_BLANK_UNBLANK; - if (sinfo->backlight) return; base-commit: f2906aa863381afb0015a9eb7fefad885d4e5a56 -- 2.30.2