lede/target/linux/bcm27xx/patches-6.12/950-0460-backlight-Add-a-display-name-to-the-core-and-a-funct.patch
=?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= d81c03f05e bcm27xx: add 6.12 patches from RPi repo
These patches were generated from:
https://github.com/raspberrypi/linux/commits/rpi-6.12.y
With the following command:
git format-patch -N v6.12.27..HEAD
(HEAD -> 8d3206ee456a5ecdf9ddbfd8e5e231e4f0cd716e)

Exceptions:
- (def)configs patches
- github workflows patches
- applied & reverted patches
- readme patches
- wireless patches

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
2025-06-20 17:01:06 +08:00

101 lines
2.9 KiB
Diff

From 7ac6f0393ced7e5ef80a6a99929c4897696ad3de Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
Date: Fri, 17 May 2024 17:35:25 +0100
Subject: [PATCH] backlight: Add a display name to the core, and a function to
set it
The naming of backlight devices is not terribly useful for
associating a backlight controller with a display (assuming
it is attached to one).
Add a sysfs node that will return a display name that can be set
by other subsystems.
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
drivers/video/backlight/backlight.c | 21 +++++++++++++++++++++
include/linux/backlight.h | 15 +++++++++++++++
2 files changed, 36 insertions(+)
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -287,6 +287,15 @@ static ssize_t max_brightness_show(struc
}
static DEVICE_ATTR_RO(max_brightness);
+static ssize_t display_name_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct backlight_device *bd = to_backlight_device(dev);
+
+ return sprintf(buf, "%s\n", bd->props.display_name);
+}
+static DEVICE_ATTR_RO(display_name);
+
static ssize_t actual_brightness_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -365,6 +374,7 @@ static struct attribute *bl_device_attrs
&dev_attr_max_brightness.attr,
&dev_attr_scale.attr,
&dev_attr_type.attr,
+ &dev_attr_display_name.attr,
NULL,
};
ATTRIBUTE_GROUPS(bl_device);
@@ -668,6 +678,17 @@ static int of_parent_match(struct device
return dev->parent && dev->parent->of_node == data;
}
+int backlight_set_display_name(struct backlight_device *bd, const char *name)
+{
+ if (!bd)
+ return -EINVAL;
+
+ strscpy_pad(bd->props.display_name, name, sizeof(bd->props.display_name));
+
+ return 0;
+}
+EXPORT_SYMBOL(backlight_set_display_name);
+
/**
* of_find_backlight_by_node() - find backlight device by device-tree node
* @node: device-tree node of the backlight device
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -255,6 +255,13 @@ struct backlight_properties {
* @scale: The type of the brightness scale.
*/
enum backlight_scale scale;
+
+#define BL_DISPLAY_NAME_LEN 32
+ /**
+ * @display_name: Optional name that can be registered to associate a
+ * backlight device with a display device.
+ */
+ char display_name[BL_DISPLAY_NAME_LEN];
};
/**
@@ -459,12 +466,20 @@ of_find_backlight_by_node(struct device_
#if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
struct backlight_device *devm_of_find_backlight(struct device *dev);
+int backlight_set_display_name(struct backlight_device *bd, const char *name);
#else
static inline struct backlight_device *
devm_of_find_backlight(struct device *dev)
{
return NULL;
}
+
+static inline int backlight_set_display_name(struct backlight_device *bd,
+ const char *name)
+{
+ return 0;
+}
+
#endif
#endif