drivers/video/backlight/lm3509_bl.c
Source file repositories/reference/linux-study-clean/drivers/video/backlight/lm3509_bl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/backlight/lm3509_bl.c- Extension
.c- Size
- 8084 bytes
- Lines
- 344
- Domain
- Driver Families
- Bucket
- drivers/video
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/backlight.hlinux/delay.hlinux/gpio/consumer.hlinux/i2c.hlinux/module.hlinux/regmap.h
Detected Declarations
struct lm3509_blstruct lm3509_bl_led_datafunction lm3509_resetfunction lm3509_update_statusfunction lm3509_main_update_statusfunction lm3509_sub_update_statusfunction lm3509_backlight_registerfunction lm3509_parse_led_sourcesfunction lm3509_parse_dt_nodefunction for_each_child_of_node_scopedfunction lm3509_probefunction lm3509_remove
Annotated Snippet
struct lm3509_bl {
struct regmap *regmap;
struct backlight_device *bl_main;
struct backlight_device *bl_sub;
struct gpio_desc *reset_gpio;
};
struct lm3509_bl_led_data {
const char *label;
int led_sources;
u32 brightness;
u32 max_brightness;
};
static void lm3509_reset(struct lm3509_bl *data)
{
if (data->reset_gpio) {
gpiod_set_value(data->reset_gpio, 1);
udelay(1);
gpiod_set_value(data->reset_gpio, 0);
udelay(10);
}
}
static int lm3509_update_status(struct backlight_device *bl,
unsigned int en_mask, unsigned int br_reg)
{
struct lm3509_bl *data = bl_get_data(bl);
int ret;
bool en;
ret = regmap_write(data->regmap, br_reg, backlight_get_brightness(bl));
if (ret < 0)
return ret;
en = !backlight_is_blank(bl);
return regmap_update_bits(data->regmap, REG_GP, en_mask,
en ? en_mask : 0);
}
static int lm3509_main_update_status(struct backlight_device *bl)
{
return lm3509_update_status(bl, BIT(REG_GP_ENM_BIT), REG_BMAIN);
}
static const struct backlight_ops lm3509_main_ops = {
.options = BL_CORE_SUSPENDRESUME,
.update_status = lm3509_main_update_status,
};
static int lm3509_sub_update_status(struct backlight_device *bl)
{
return lm3509_update_status(bl, BIT(REG_GP_ENS_BIT), REG_BSUB);
}
static const struct backlight_ops lm3509_sub_ops = {
.options = BL_CORE_SUSPENDRESUME,
.update_status = lm3509_sub_update_status,
};
static struct backlight_device *
lm3509_backlight_register(struct device *dev, const char *name_suffix,
struct lm3509_bl *data,
const struct backlight_ops *ops,
const struct lm3509_bl_led_data *led_data)
{
struct backlight_device *bd;
struct backlight_properties props;
const char *label = led_data->label;
char name[64];
memset(&props, 0, sizeof(props));
props.type = BACKLIGHT_RAW;
props.brightness = led_data->brightness;
props.max_brightness = led_data->max_brightness;
props.scale = BACKLIGHT_SCALE_NON_LINEAR;
if (!label) {
snprintf(name, sizeof(name), "lm3509-%s-%s", dev_name(dev),
name_suffix);
label = name;
}
bd = devm_backlight_device_register(dev, label, dev, data, ops, &props);
if (IS_ERR(bd))
return bd;
backlight_update_status(bd);
return bd;
Annotation
- Immediate include surface: `linux/backlight.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/module.h`, `linux/regmap.h`.
- Detected declarations: `struct lm3509_bl`, `struct lm3509_bl_led_data`, `function lm3509_reset`, `function lm3509_update_status`, `function lm3509_main_update_status`, `function lm3509_sub_update_status`, `function lm3509_backlight_register`, `function lm3509_parse_led_sources`, `function lm3509_parse_dt_node`, `function for_each_child_of_node_scoped`.
- Atlas domain: Driver Families / drivers/video.
- Implementation status: source implementation candidate.
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.