openwrt/target/linux/bcm27xx/patches-6.6/950-1102-backlight-Add-a-display-name-to-the-core-and-a-funct.patch

101 lines
2.9 KiB
Diff
Raw Normal View History

From 1e0dc5254a44722653bef6041e7b4ddbd689aba6 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 1102/1135] 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
@@ -285,6 +285,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);
@@ -662,6 +672,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
@@ -270,6 +270,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];
};
/**
@@ -478,12 +485,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