drivers/video/backlight/lcd.c
Source file repositories/reference/linux-study-clean/drivers/video/backlight/lcd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/backlight/lcd.c- Extension
.c- Size
- 8363 bytes
- Lines
- 348
- 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/lcd.hlinux/notifier.hlinux/ctype.hlinux/err.hlinux/slab.h
Detected Declarations
function lcd_notify_blankfunction lcd_notify_blank_allfunction lcd_notify_mode_changefunction lcd_notify_mode_change_allfunction lcd_power_showfunction lcd_power_storefunction contrast_showfunction contrast_storefunction max_contrast_showfunction lcd_device_releasefunction lcd_get_datafunction lcd_device_unregisterfunction devm_lcd_device_releasefunction devm_lcd_device_matchfunction lcd_device_registerfunction devm_lcd_device_registerfunction lcd_class_exitfunction lcd_class_initexport lcd_notify_blank_allexport lcd_notify_mode_change_allexport lcd_device_registerexport lcd_device_unregisterexport devm_lcd_device_registerexport devm_lcd_device_unregister
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* LCD Lowlevel Control Abstraction
*
* Copyright (C) 2003,2004 Hewlett-Packard Company
*
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h>
#include <linux/init.h>
#include <linux/device.h>
#include <linux/lcd.h>
#include <linux/notifier.h>
#include <linux/ctype.h>
#include <linux/err.h>
#include <linux/slab.h>
static DEFINE_MUTEX(lcd_dev_list_mutex);
static LIST_HEAD(lcd_dev_list);
static void lcd_notify_blank(struct lcd_device *ld, struct device *display_dev,
int power)
{
guard(mutex)(&ld->ops_lock);
if (!ld->ops || !ld->ops->set_power)
return;
if (ld->ops->controls_device && !ld->ops->controls_device(ld, display_dev))
return;
ld->ops->set_power(ld, power);
}
void lcd_notify_blank_all(struct device *display_dev, int power)
{
struct lcd_device *ld;
guard(mutex)(&lcd_dev_list_mutex);
list_for_each_entry(ld, &lcd_dev_list, entry)
lcd_notify_blank(ld, display_dev, power);
}
EXPORT_SYMBOL(lcd_notify_blank_all);
static void lcd_notify_mode_change(struct lcd_device *ld, struct device *display_dev,
unsigned int width, unsigned int height)
{
guard(mutex)(&ld->ops_lock);
if (!ld->ops || !ld->ops->set_mode)
return;
if (ld->ops->controls_device && !ld->ops->controls_device(ld, display_dev))
return;
ld->ops->set_mode(ld, width, height);
}
void lcd_notify_mode_change_all(struct device *display_dev,
unsigned int width, unsigned int height)
{
struct lcd_device *ld;
guard(mutex)(&lcd_dev_list_mutex);
list_for_each_entry(ld, &lcd_dev_list, entry)
lcd_notify_mode_change(ld, display_dev, width, height);
}
EXPORT_SYMBOL(lcd_notify_mode_change_all);
static ssize_t lcd_power_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
int rc;
struct lcd_device *ld = to_lcd_device(dev);
mutex_lock(&ld->ops_lock);
if (ld->ops && ld->ops->get_power)
rc = sprintf(buf, "%d\n", ld->ops->get_power(ld));
else
rc = -ENXIO;
mutex_unlock(&ld->ops_lock);
return rc;
}
static ssize_t lcd_power_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/device.h`, `linux/lcd.h`, `linux/notifier.h`, `linux/ctype.h`, `linux/err.h`, `linux/slab.h`.
- Detected declarations: `function lcd_notify_blank`, `function lcd_notify_blank_all`, `function lcd_notify_mode_change`, `function lcd_notify_mode_change_all`, `function lcd_power_show`, `function lcd_power_store`, `function contrast_show`, `function contrast_store`, `function max_contrast_show`, `function lcd_device_release`.
- 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.