drivers/video/backlight/backlight.c
Source file repositories/reference/linux-study-clean/drivers/video/backlight/backlight.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/backlight/backlight.c- Extension
.c- Size
- 18471 bytes
- Lines
- 691
- Domain
- Driver Families
- Bucket
- drivers/video
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/init.hlinux/device.hlinux/backlight.hlinux/notifier.hlinux/ctype.hlinux/err.hlinux/slab.hlinux/of.hasm/backlight.h
Detected Declarations
function backlight_notify_blankfunction backlight_notify_blank_allfunction backlight_generate_eventfunction bl_power_showfunction bl_power_storefunction brightness_showfunction backlight_device_set_brightnessfunction brightness_storefunction type_showfunction max_brightness_showfunction actual_brightness_showfunction scale_showfunction backlight_suspendfunction backlight_resumefunction bl_device_releasefunction backlight_force_updatefunction put_devicefunction backlight_device_unregisterfunction devm_backlight_device_releasefunction devm_backlight_device_matchfunction devm_backlight_device_registerfunction of_parent_matchfunction of_find_backlight_by_nodefunction devm_backlight_releasefunction backlight_class_exitfunction backlight_class_initexport backlight_notify_blankexport backlight_notify_blank_allexport backlight_device_set_brightnessexport backlight_force_updateexport backlight_device_registerexport backlight_device_get_by_typeexport backlight_device_get_by_nameexport backlight_device_unregisterexport devm_backlight_device_registerexport devm_backlight_device_unregisterexport of_find_backlight_by_nodeexport devm_of_find_backlight
Annotated Snippet
if (!bd->use_count++) {
bd->props.state &= ~BL_CORE_FBBLANK;
backlight_update_status(bd);
}
} else if (!fb_on && prev_fb_on && bd->use_count) {
if (!(--bd->use_count)) {
bd->props.state |= BL_CORE_FBBLANK;
backlight_update_status(bd);
}
}
}
EXPORT_SYMBOL(backlight_notify_blank);
void backlight_notify_blank_all(struct device *display_dev, bool fb_on, bool prev_fb_on)
{
struct backlight_device *bd;
guard(mutex)(&backlight_dev_list_mutex);
list_for_each_entry(bd, &backlight_dev_list, entry)
backlight_notify_blank(bd, display_dev, fb_on, prev_fb_on);
}
EXPORT_SYMBOL(backlight_notify_blank_all);
static void backlight_generate_event(struct backlight_device *bd,
enum backlight_update_reason reason)
{
char *envp[2];
switch (reason) {
case BACKLIGHT_UPDATE_SYSFS:
envp[0] = "SOURCE=sysfs";
break;
case BACKLIGHT_UPDATE_HOTKEY:
envp[0] = "SOURCE=hotkey";
break;
default:
envp[0] = "SOURCE=unknown";
break;
}
envp[1] = NULL;
kobject_uevent_env(&bd->dev.kobj, KOBJ_CHANGE, envp);
sysfs_notify(&bd->dev.kobj, NULL, "actual_brightness");
}
static ssize_t bl_power_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct backlight_device *bd = to_backlight_device(dev);
return sprintf(buf, "%d\n", bd->props.power);
}
static ssize_t bl_power_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
int rc;
struct backlight_device *bd = to_backlight_device(dev);
unsigned long power, old_power;
rc = kstrtoul(buf, 0, &power);
if (rc)
return rc;
rc = -ENXIO;
mutex_lock(&bd->ops_lock);
if (bd->ops) {
pr_debug("set power to %lu\n", power);
if (bd->props.power != power) {
old_power = bd->props.power;
bd->props.power = power;
rc = backlight_update_status(bd);
if (rc)
bd->props.power = old_power;
else
rc = count;
} else {
rc = count;
}
}
mutex_unlock(&bd->ops_lock);
return rc;
}
static DEVICE_ATTR_RW(bl_power);
static ssize_t brightness_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct backlight_device *bd = to_backlight_device(dev);
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/device.h`, `linux/backlight.h`, `linux/notifier.h`, `linux/ctype.h`, `linux/err.h`, `linux/slab.h`.
- Detected declarations: `function backlight_notify_blank`, `function backlight_notify_blank_all`, `function backlight_generate_event`, `function bl_power_show`, `function bl_power_store`, `function brightness_show`, `function backlight_device_set_brightness`, `function brightness_store`, `function type_show`, `function max_brightness_show`.
- Atlas domain: Driver Families / drivers/video.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.