drivers/video/backlight/da9052_bl.c
Source file repositories/reference/linux-study-clean/drivers/video/backlight/da9052_bl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/backlight/da9052_bl.c- Extension
.c- Size
- 4058 bytes
- Lines
- 180
- 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/mod_devicetable.hlinux/module.hlinux/platform_device.hlinux/mfd/da9052/da9052.hlinux/mfd/da9052/reg.h
Detected Declarations
struct da9052_blfunction da9052_adjust_wled_brightnessfunction da9052_backlight_update_statusfunction da9052_backlight_get_brightnessfunction da9052_backlight_probefunction da9052_backlight_remove
Annotated Snippet
struct da9052_bl {
struct da9052 *da9052;
uint brightness;
uint state;
uint led_reg;
};
static int da9052_adjust_wled_brightness(struct da9052_bl *wleds)
{
unsigned char boost_en;
unsigned char i_sink;
int ret;
boost_en = 0x3F;
i_sink = 0xFF;
if (wleds->state == DA9052_WLEDS_OFF) {
boost_en = 0x00;
i_sink = 0x00;
}
ret = da9052_reg_write(wleds->da9052, DA9052_BOOST_REG, boost_en);
if (ret < 0)
return ret;
ret = da9052_reg_write(wleds->da9052, DA9052_LED_CONT_REG, i_sink);
if (ret < 0)
return ret;
ret = da9052_reg_write(wleds->da9052, wled_bank[wleds->led_reg], 0x0);
if (ret < 0)
return ret;
usleep_range(10000, 11000);
if (wleds->brightness) {
ret = da9052_reg_write(wleds->da9052, wled_bank[wleds->led_reg],
wleds->brightness);
if (ret < 0)
return ret;
}
return 0;
}
static int da9052_backlight_update_status(struct backlight_device *bl)
{
int brightness = bl->props.brightness;
struct da9052_bl *wleds = bl_get_data(bl);
wleds->brightness = brightness;
wleds->state = DA9052_WLEDS_ON;
return da9052_adjust_wled_brightness(wleds);
}
static int da9052_backlight_get_brightness(struct backlight_device *bl)
{
struct da9052_bl *wleds = bl_get_data(bl);
return wleds->brightness;
}
static const struct backlight_ops da9052_backlight_ops = {
.update_status = da9052_backlight_update_status,
.get_brightness = da9052_backlight_get_brightness,
};
static int da9052_backlight_probe(struct platform_device *pdev)
{
struct backlight_device *bl;
struct backlight_properties props;
struct da9052_bl *wleds;
wleds = devm_kzalloc(&pdev->dev, sizeof(struct da9052_bl), GFP_KERNEL);
if (!wleds)
return -ENOMEM;
wleds->da9052 = dev_get_drvdata(pdev->dev.parent);
wleds->brightness = 0;
wleds->led_reg = platform_get_device_id(pdev)->driver_data;
wleds->state = DA9052_WLEDS_OFF;
memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = DA9052_MAX_BRIGHTNESS;
bl = devm_backlight_device_register(&pdev->dev, pdev->name,
wleds->da9052->dev, wleds,
&da9052_backlight_ops, &props);
if (IS_ERR(bl)) {
Annotation
- Immediate include surface: `linux/backlight.h`, `linux/delay.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/platform_device.h`, `linux/mfd/da9052/da9052.h`, `linux/mfd/da9052/reg.h`.
- Detected declarations: `struct da9052_bl`, `function da9052_adjust_wled_brightness`, `function da9052_backlight_update_status`, `function da9052_backlight_get_brightness`, `function da9052_backlight_probe`, `function da9052_backlight_remove`.
- 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.