linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: lee@kernel.org, daniel.thompson@linaro.org, jingoohan1@gmail.com,
	deller@gmx.de, bonbons@linux-vserver.org, jikos@kernel.org,
	bentiss@kernel.org, s.hauer@pengutronix.de,
	kernel@pengutronix.de, shawnguo@kernel.org, festevam@gmail.com
Cc: dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org,
	linux-omap@vger.kernel.org,
	Thomas Zimmermann <tzimmermann@suse.de>
Subject: [PATCH v2 03/28] backlight: lcd: Add LCD_POWER_ constants for power states
Date: Fri,  6 Sep 2024 09:52:17 +0200	[thread overview]
Message-ID: <20240906075439.98476-4-tzimmermann@suse.de> (raw)
In-Reply-To: <20240906075439.98476-1-tzimmermann@suse.de>

Duplicate FB_BLANK_ constants as LCD_POWER_ constants in the lcd
header file. Allows lcd drivers to avoid including the fbdev header
file and removes a compile-time dependency between the two subsystems.

The new LCD_POWER_ constants have the same values as their
FB_BLANK_ counterparts. Hence semantics does not change and the lcd
drivers can be converted one by one. Each instance of FB_BLANK_UNBLANK
becomes LCD_POWER_ON, each of FB_BLANK_POWERDOWN becomes LCD_POWER_OFF,
FB_BLANK_NORMAL becomes LCD_POWER_REDUCED and FB_BLANK_VSYNC_SUSPEND
becomes LCD_POWER_REDUCED_VSYNC_SUSPEND.

Lcd code or drivers do not use FB_BLANK_HSYNC_SUSPEND, so no
new constants for this is being added. The tokens LCD_POWER_REDUCED
and LCD_POWER_REDUCED_VSYNC_SUSPEND are deprecated and drivers should
replace them with LCD_POWER_ON and LCD_POWER_OFF.

See also commit a1cacb8a8e70 ("backlight: Add BACKLIGHT_POWER_ constants
for power states"), which added similar constants for backlight drivers.

v2:
- fix typo in commit description

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
---
 drivers/video/backlight/lcd.c | 22 +++++++++++++++++++++-
 include/linux/lcd.h           |  5 +++++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c
index c69407aed296..713f7fb8b10a 100644
--- a/drivers/video/backlight/lcd.c
+++ b/drivers/video/backlight/lcd.c
@@ -20,6 +20,24 @@
 
 #if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \
 			   defined(CONFIG_LCD_CLASS_DEVICE_MODULE))
+static int to_lcd_power(int fb_blank)
+{
+	switch (fb_blank) {
+	case FB_BLANK_UNBLANK:
+		return LCD_POWER_ON;
+	/* deprecated; TODO: should become 'off' */
+	case FB_BLANK_NORMAL:
+		return LCD_POWER_REDUCED;
+	case FB_BLANK_VSYNC_SUSPEND:
+		return LCD_POWER_REDUCED_VSYNC_SUSPEND;
+	/* 'off' */
+	case FB_BLANK_HSYNC_SUSPEND:
+	case FB_BLANK_POWERDOWN:
+	default:
+		return LCD_POWER_OFF;
+	}
+}
+
 /* This callback gets called when something important happens inside a
  * framebuffer driver. We're looking if that important event is blanking,
  * and if it is, we're switching lcd power as well ...
@@ -42,8 +60,10 @@ static int fb_notifier_callback(struct notifier_block *self,
 		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, *(int *)evdata->data);
+			ld->ops->set_power(ld, power);
 	} else {
 		if (ld->ops->set_mode)
 			ld->ops->set_mode(ld, evdata->data);
diff --git a/include/linux/lcd.h b/include/linux/lcd.h
index 68703a51dc53..dfcc54d327f5 100644
--- a/include/linux/lcd.h
+++ b/include/linux/lcd.h
@@ -14,6 +14,11 @@
 #include <linux/notifier.h>
 #include <linux/fb.h>
 
+#define LCD_POWER_ON			(0)
+#define LCD_POWER_REDUCED		(1) // deprecated; don't use in new code
+#define LCD_POWER_REDUCED_VSYNC_SUSPEND	(2) // deprecated; don't use in new code
+#define LCD_POWER_OFF			(4)
+
 /* Notes on locking:
  *
  * lcd_device->ops_lock is an internal backlight lock protecting the ops
-- 
2.46.0


  parent reply	other threads:[~2024-09-06  7:54 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-06  7:52 [PATCH v2 00/28] backlight: lcd: Remove fbdev dependencies Thomas Zimmermann
2024-09-06  7:52 ` [PATCH v2 01/28] backlight: lcd: Rearrange code in fb_notifier_callback() Thomas Zimmermann
2024-09-06  7:52 ` [PATCH v2 02/28] backlight: lcd: Test against struct fb_info.lcd_dev Thomas Zimmermann
2024-09-06  7:52 ` Thomas Zimmermann [this message]
2024-09-06  7:52 ` [PATCH v2 04/28] backlight: corgi_lcd: Use lcd power constants Thomas Zimmermann
2024-09-06  7:52 ` [PATCH v2 05/28] backlight: hx8357: " Thomas Zimmermann
2024-09-06  7:52 ` [PATCH v2 06/28] backlight: ili922x: " Thomas Zimmermann
2024-09-06  7:52 ` [PATCH v2 07/28] backlight: ili9320: " Thomas Zimmermann
2024-09-06  7:52 ` [PATCH v2 08/28] backlight: jornada720_lcd: Include <linux/io.h> for IOMEM() macro Thomas Zimmermann
2024-09-06  7:52 ` [PATCH v2 09/28] backlight: jornada720_lcd: Use lcd power constants Thomas Zimmermann
2024-09-06  7:52 ` [PATCH v2 10/28] backlight: l4f00242t03: " Thomas Zimmermann
2024-09-06  7:52 ` [PATCH v2 11/28] backlight: lms283gf05: " Thomas Zimmermann
2024-09-06  7:52 ` [PATCH v2 12/28] backlight: lms501kf03: Remove unnecessary include of <linux/backlight.h> Thomas Zimmermann
2024-09-06  7:52 ` [PATCH v2 13/28] backlight: lms501kf03: Use lcd power constants Thomas Zimmermann
2024-09-06  7:52 ` [PATCH v2 14/28] backlight: ltv350qv: " Thomas Zimmermann
2024-09-06  7:52 ` [PATCH v2 15/28] backlight: otm3225a: " Thomas Zimmermann
2024-09-06  7:52 ` [PATCH v2 16/28] backlight: platform_lcd: Remove include statement for <linux/backlight.h> Thomas Zimmermann
2024-09-06  7:52 ` [PATCH v2 17/28] backlight: platform_lcd: Remove match_fb from struct plat_lcd_data Thomas Zimmermann
2024-09-06  7:52 ` [PATCH v2 18/28] backlight: platform_lcd: Use lcd power constants Thomas Zimmermann
2024-09-06  7:52 ` [PATCH v2 19/28] backlight: tdo24m: " Thomas Zimmermann
2024-09-06  7:52 ` [PATCH v2 20/28] fbdev: clps711x-fb: Replace check_fb in favor of struct fb_info.lcd_dev Thomas Zimmermann
2024-10-03 18:33   ` Kees Bakker
2024-10-04 14:01     ` Thomas Zimmermann
2024-11-23 20:11   ` Andy Shevchenko
2024-09-06  7:52 ` [PATCH v2 21/28] fbdev: clps711x-fb: Use lcd power constants Thomas Zimmermann
2024-09-06  7:52 ` [PATCH v2 22/28] fbdev: imxfb: Replace check_fb in favor of struct fb_info.lcd_dev Thomas Zimmermann
2024-09-06  7:52 ` [PATCH v2 23/28] fbdev: imxfb: Use lcd power constants Thomas Zimmermann
2024-09-06  7:52 ` [PATCH v2 24/28] fbdev: omap: " Thomas Zimmermann
2024-09-06  7:52 ` [PATCH v2 25/28] HID: picoLCD: Replace check_fb in favor of struct fb_info.lcd_dev Thomas Zimmermann
2024-09-06  7:52 ` [PATCH v2 26/28] backlight: lcd: Replace check_fb with controls_device Thomas Zimmermann
2024-09-06  7:52 ` [PATCH v2 27/28] backlight: lcd: Remove struct fb_videomode from set_mode callback Thomas Zimmermann
2024-09-06  7:52 ` [PATCH v2 28/28] backlight: lcd: Do not include <linux/fb.h> in lcd header Thomas Zimmermann
2024-09-30 15:50 ` [PATCH v2 00/28] backlight: lcd: Remove fbdev dependencies Lee Jones
2024-10-01  8:55 ` [GIT PULL] Immutable branch between Backlight, HID and fbdev due for the v6.13 merge window Lee Jones
2024-10-21 15:51   ` Jiri Kosina
2024-10-25  8:59     ` Lee Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240906075439.98476-4-tzimmermann@suse.de \
    --to=tzimmermann@suse.de \
    --cc=bentiss@kernel.org \
    --cc=bonbons@linux-vserver.org \
    --cc=daniel.thompson@linaro.org \
    --cc=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=festevam@gmail.com \
    --cc=jikos@kernel.org \
    --cc=jingoohan1@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=lee@kernel.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).