From patchwork Wed Feb 26 09:31:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13991885 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 16FACC19777 for ; Wed, 26 Feb 2025 09:38:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 52F7910E8B0; Wed, 26 Feb 2025 09:38:21 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by gabe.freedesktop.org (Postfix) with ESMTPS id B670A10E8AD for ; Wed, 26 Feb 2025 09:38:10 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 5167B1F74C; Wed, 26 Feb 2025 09:37:47 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 0A0E713A82; Wed, 26 Feb 2025 09:37:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id YE0pAevgvmezXQAAD6G6ig (envelope-from ); Wed, 26 Feb 2025 09:37:47 +0000 From: Thomas Zimmermann To: lee@kernel.org, pavel@ucw.cz, danielt@kernel.org, jingoohan1@gmail.com, deller@gmx.de, simona@ffwll.ch Cc: linux-leds@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 07/11] backlight: lcd: Move event handling into helpers Date: Wed, 26 Feb 2025 10:31:56 +0100 Message-ID: <20250226093456.147402-8-tzimmermann@suse.de> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250226093456.147402-1-tzimmermann@suse.de> References: <20250226093456.147402-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: 5167B1F74C X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Move the handling of display updates to separate helper functions. There is code for handling fbdev blank events and fbdev mode changes. The code currently runs from fbdev event notifiers, which will be replaced. Signed-off-by: Thomas Zimmermann --- drivers/video/backlight/lcd.c | 38 ++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c index 3267acf8dc5b..f57ff8bcc2fa 100644 --- a/drivers/video/backlight/lcd.c +++ b/drivers/video/backlight/lcd.c @@ -18,6 +18,32 @@ #include #include +static void lcd_notify_blank(struct lcd_device *ld, struct device *display_dev, + int power) +{ + guard(mutex)(&ld->ops_lock); + + if (!ld->ops || !ld->ops->set_power) + return; + if (ld->ops->controls_device && !ld->ops->controls_device(ld, display_dev)) + return; + + ld->ops->set_power(ld, power); +} + +static void lcd_notify_mode_change(struct lcd_device *ld, struct device *display_dev, + unsigned int width, unsigned int height) +{ + guard(mutex)(&ld->ops_lock); + + if (!ld->ops || !ld->ops->set_mode) + return; + if (ld->ops->controls_device && !ld->ops->controls_device(ld, display_dev)) + return; + + ld->ops->set_mode(ld, width, height); +} + #if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \ defined(CONFIG_LCD_CLASS_DEVICE_MODULE)) static int to_lcd_power(int fb_blank) @@ -50,25 +76,17 @@ static int fb_notifier_callback(struct notifier_block *self, struct fb_info *info = evdata->info; struct lcd_device *fb_lcd = fb_lcd_device(info); - guard(mutex)(&ld->ops_lock); - - if (!ld->ops) - return 0; - if (ld->ops->controls_device && !ld->ops->controls_device(ld, info->device)) - return 0; if (fb_lcd && fb_lcd != ld) return 0; if (event == FB_EVENT_BLANK) { int power = to_lcd_power(*(int *)evdata->data); - if (ld->ops->set_power) - ld->ops->set_power(ld, power); + lcd_notify_blank(ld, info->device, power); } else { const struct fb_videomode *videomode = evdata->data; - if (ld->ops->set_mode) - ld->ops->set_mode(ld, videomode->xres, videomode->yres); + lcd_notify_mode_change(ld, info->device, videomode->xres, videomode->yres); } return 0;