From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH 4/4] backlight: support setting brightness as percentage
Date: Mon, 27 Oct 2025 07:30:39 +0100 [thread overview]
Message-ID: <20251027063045.2396578-4-a.fatoum@barebox.org> (raw)
In-Reply-To: <20251027063045.2396578-1-a.fatoum@barebox.org>
From: Ahmad Fatoum <ahmad@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@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
next prev parent reply other threads:[~2025-10-27 6:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-27 6:30 [PATCH 1/4] sound: pwm-beeper: make duty cycle configurable Ahmad Fatoum
2025-10-27 6:30 ` [PATCH 2/4] param: add support for setting parameters with percentages Ahmad Fatoum
2025-10-27 6:30 ` [PATCH 3/4] video: backlight-pwm: switch to gpiod functions Ahmad Fatoum
2025-10-27 6:30 ` Ahmad Fatoum [this message]
2025-10-28 8:19 ` [PATCH 1/4] sound: pwm-beeper: make duty cycle configurable Sascha Hauer
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=20251027063045.2396578-4-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--cc=barebox@lists.infradead.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