[PATCH 4/4] backlight: support setting brightness as percentage
Ahmad Fatoum
a.fatoum at barebox.org
Sun Oct 26 23:30:39 PDT 2025
From: Ahmad Fatoum <ahmad at a3f.at>
Unlike the PWN duty cycle, we already have a parameter for the
brightness, so we can't retroactively redefine it to be in terms of
percentages.
By setting the scale, we allow users to enter percentages between 0% and
100% over the same parameter as well.
Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
---
drivers/video/backlight.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/video/backlight.c b/drivers/video/backlight.c
index 51d245a80fdb..6d8146ee5aa0 100644
--- a/drivers/video/backlight.c
+++ b/drivers/video/backlight.c
@@ -69,6 +69,7 @@ static int backlight_brightness_set(struct param_d *p, void *priv)
int backlight_register(struct backlight_device *bl)
{
+ struct param_d *param;
int ret;
dev_set_name(&bl->dev, "backlight");
@@ -78,8 +79,10 @@ int backlight_register(struct backlight_device *bl)
if (ret)
return ret;
- dev_add_param_uint32(&bl->dev, "brightness", backlight_brightness_set,
- NULL, &bl->brightness, "%u", bl);
+ param = dev_add_param_uint32(&bl->dev, "brightness", backlight_brightness_set,
+ NULL, &bl->brightness, "%u", bl);
+ param_int_set_scale(param, bl->brightness_max);
+
dev_add_param_uint32(&bl->dev, "slew_time_ms", NULL, NULL,
&bl->slew_time_ms, "%u", NULL);
--
2.47.3
More information about the barebox
mailing list