drivers/video/backlight/adp5520_bl.c
Source file repositories/reference/linux-study-clean/drivers/video/backlight/adp5520_bl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/backlight/adp5520_bl.c- Extension
.c- Size
- 10184 bytes
- Lines
- 386
- 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.
- 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/kernel.hlinux/init.hlinux/platform_device.hlinux/backlight.hlinux/mfd/adp5520.hlinux/slab.hlinux/module.h
Detected Declarations
struct adp5520_blfunction adp5520_bl_setfunction adp5520_bl_update_statusfunction adp5520_bl_get_brightnessfunction adp5520_bl_setupfunction adp5520_showfunction adp5520_storefunction adp5520_bl_dark_max_showfunction adp5520_bl_dark_max_storefunction adp5520_bl_office_max_showfunction adp5520_bl_office_max_storefunction adp5520_bl_daylight_max_showfunction adp5520_bl_daylight_max_storefunction adp5520_bl_dark_dim_showfunction adp5520_bl_dark_dim_storefunction adp5520_bl_office_dim_showfunction adp5520_bl_office_dim_storefunction adp5520_bl_daylight_dim_showfunction adp5520_bl_daylight_dim_storefunction adp5520_bl_probefunction adp5520_bl_removefunction adp5520_bl_suspendfunction adp5520_bl_resume
Annotated Snippet
struct adp5520_bl {
struct device *master;
struct adp5520_backlight_platform_data *pdata;
struct mutex lock;
unsigned long cached_daylight_max;
int id;
int current_brightness;
};
static int adp5520_bl_set(struct backlight_device *bl, int brightness)
{
struct adp5520_bl *data = bl_get_data(bl);
struct device *master = data->master;
int ret = 0;
if (data->pdata->en_ambl_sens) {
if ((brightness > 0) && (brightness < ADP5020_MAX_BRIGHTNESS)) {
/* Disable Ambient Light auto adjust */
ret |= adp5520_clr_bits(master, ADP5520_BL_CONTROL,
ADP5520_BL_AUTO_ADJ);
ret |= adp5520_write(master, ADP5520_DAYLIGHT_MAX,
brightness);
} else {
/*
* MAX_BRIGHTNESS -> Enable Ambient Light auto adjust
* restore daylight l3 sysfs brightness
*/
ret |= adp5520_write(master, ADP5520_DAYLIGHT_MAX,
data->cached_daylight_max);
ret |= adp5520_set_bits(master, ADP5520_BL_CONTROL,
ADP5520_BL_AUTO_ADJ);
}
} else {
ret |= adp5520_write(master, ADP5520_DAYLIGHT_MAX, brightness);
}
if (data->current_brightness && brightness == 0)
ret |= adp5520_set_bits(master,
ADP5520_MODE_STATUS, ADP5520_DIM_EN);
else if (data->current_brightness == 0 && brightness)
ret |= adp5520_clr_bits(master,
ADP5520_MODE_STATUS, ADP5520_DIM_EN);
if (!ret)
data->current_brightness = brightness;
return ret;
}
static int adp5520_bl_update_status(struct backlight_device *bl)
{
return adp5520_bl_set(bl, backlight_get_brightness(bl));
}
static int adp5520_bl_get_brightness(struct backlight_device *bl)
{
struct adp5520_bl *data = bl_get_data(bl);
int error;
uint8_t reg_val;
error = adp5520_read(data->master, ADP5520_BL_VALUE, ®_val);
return error ? data->current_brightness : reg_val;
}
static const struct backlight_ops adp5520_bl_ops = {
.update_status = adp5520_bl_update_status,
.get_brightness = adp5520_bl_get_brightness,
};
static int adp5520_bl_setup(struct backlight_device *bl)
{
struct adp5520_bl *data = bl_get_data(bl);
struct device *master = data->master;
struct adp5520_backlight_platform_data *pdata = data->pdata;
int ret = 0;
ret |= adp5520_write(master, ADP5520_DAYLIGHT_MAX,
pdata->l1_daylight_max);
ret |= adp5520_write(master, ADP5520_DAYLIGHT_DIM,
pdata->l1_daylight_dim);
if (pdata->en_ambl_sens) {
data->cached_daylight_max = pdata->l1_daylight_max;
ret |= adp5520_write(master, ADP5520_OFFICE_MAX,
pdata->l2_office_max);
ret |= adp5520_write(master, ADP5520_OFFICE_DIM,
pdata->l2_office_dim);
ret |= adp5520_write(master, ADP5520_DARK_MAX,
pdata->l3_dark_max);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/init.h`, `linux/platform_device.h`, `linux/backlight.h`, `linux/mfd/adp5520.h`, `linux/slab.h`, `linux/module.h`.
- Detected declarations: `struct adp5520_bl`, `function adp5520_bl_set`, `function adp5520_bl_update_status`, `function adp5520_bl_get_brightness`, `function adp5520_bl_setup`, `function adp5520_show`, `function adp5520_store`, `function adp5520_bl_dark_max_show`, `function adp5520_bl_dark_max_store`, `function adp5520_bl_office_max_show`.
- Atlas domain: Driver Families / drivers/video.
- Implementation status: source 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.