mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
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>
This commit is contained in:
committed by
Phil Elwell
parent
a59df153f4
commit
1e0dc5254a
@@ -285,6 +285,15 @@ static ssize_t max_brightness_show(struct device *dev,
|
|||||||
}
|
}
|
||||||
static DEVICE_ATTR_RO(max_brightness);
|
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,
|
static ssize_t actual_brightness_show(struct device *dev,
|
||||||
struct device_attribute *attr, char *buf)
|
struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
@@ -365,6 +374,7 @@ static struct attribute *bl_device_attrs[] = {
|
|||||||
&dev_attr_max_brightness.attr,
|
&dev_attr_max_brightness.attr,
|
||||||
&dev_attr_scale.attr,
|
&dev_attr_scale.attr,
|
||||||
&dev_attr_type.attr,
|
&dev_attr_type.attr,
|
||||||
|
&dev_attr_display_name.attr,
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
ATTRIBUTE_GROUPS(bl_device);
|
ATTRIBUTE_GROUPS(bl_device);
|
||||||
@@ -662,6 +672,17 @@ static int of_parent_match(struct device *dev, const void *data)
|
|||||||
return dev->parent && dev->parent->of_node == data;
|
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
|
* of_find_backlight_by_node() - find backlight device by device-tree node
|
||||||
* @node: device-tree node of the backlight device
|
* @node: device-tree node of the backlight device
|
||||||
|
|||||||
@@ -270,6 +270,13 @@ struct backlight_properties {
|
|||||||
* @scale: The type of the brightness scale.
|
* @scale: The type of the brightness scale.
|
||||||
*/
|
*/
|
||||||
enum backlight_scale 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_node *node)
|
|||||||
|
|
||||||
#if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
|
#if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
|
||||||
struct backlight_device *devm_of_find_backlight(struct device *dev);
|
struct backlight_device *devm_of_find_backlight(struct device *dev);
|
||||||
|
int backlight_set_display_name(struct backlight_device *bd, const char *name);
|
||||||
#else
|
#else
|
||||||
static inline struct backlight_device *
|
static inline struct backlight_device *
|
||||||
devm_of_find_backlight(struct device *dev)
|
devm_of_find_backlight(struct device *dev)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int backlight_set_display_name(struct backlight_device *bd,
|
||||||
|
const char *name)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user