drivers/video/backlight/as3711_bl.c
Source file repositories/reference/linux-study-clean/drivers/video/backlight/as3711_bl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/backlight/as3711_bl.c- Extension
.c- Size
- 11566 bytes
- Lines
- 481
- 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/device.hlinux/err.hlinux/kernel.hlinux/mfd/as3711.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/regmap.hlinux/slab.h
Detected Declarations
struct as3711_bl_datastruct as3711_bl_supplyenum as3711_bl_typefunction as3711_set_brightness_auto_ifunction as3711_set_brightness_vfunction as3711_bl_su2_resetfunction as3711_bl_update_statusfunction as3711_bl_get_brightnessfunction as3711_bl_init_su2function as3711_bl_registerfunction as3711_backlight_parse_dtfunction as3711_backlight_probe
Annotated Snippet
struct as3711_bl_data {
bool powered;
enum as3711_bl_type type;
int brightness;
struct backlight_device *bl;
};
struct as3711_bl_supply {
struct as3711_bl_data su1;
struct as3711_bl_data su2;
const struct as3711_bl_pdata *pdata;
struct as3711 *as3711;
};
static struct as3711_bl_supply *to_supply(struct as3711_bl_data *su)
{
switch (su->type) {
case AS3711_BL_SU1:
return container_of(su, struct as3711_bl_supply, su1);
case AS3711_BL_SU2:
return container_of(su, struct as3711_bl_supply, su2);
}
return NULL;
}
static int as3711_set_brightness_auto_i(struct as3711_bl_data *data,
unsigned int brightness)
{
struct as3711_bl_supply *supply = to_supply(data);
struct as3711 *as3711 = supply->as3711;
const struct as3711_bl_pdata *pdata = supply->pdata;
int ret = 0;
/* Only all equal current values are supported */
if (pdata->su2_auto_curr1)
ret = regmap_write(as3711->regmap, AS3711_CURR1_VALUE,
brightness);
if (!ret && pdata->su2_auto_curr2)
ret = regmap_write(as3711->regmap, AS3711_CURR2_VALUE,
brightness);
if (!ret && pdata->su2_auto_curr3)
ret = regmap_write(as3711->regmap, AS3711_CURR3_VALUE,
brightness);
return ret;
}
static int as3711_set_brightness_v(struct as3711 *as3711,
unsigned int brightness,
unsigned int reg)
{
if (brightness > 31)
return -EINVAL;
return regmap_update_bits(as3711->regmap, reg, 0xf0,
brightness << 4);
}
static int as3711_bl_su2_reset(struct as3711_bl_supply *supply)
{
struct as3711 *as3711 = supply->as3711;
int ret = regmap_update_bits(as3711->regmap, AS3711_STEPUP_CONTROL_5,
3, supply->pdata->su2_fbprot);
if (!ret)
ret = regmap_update_bits(as3711->regmap,
AS3711_STEPUP_CONTROL_2, 1, 0);
if (!ret)
ret = regmap_update_bits(as3711->regmap,
AS3711_STEPUP_CONTROL_2, 1, 1);
return ret;
}
/*
* Someone with less fragile or less expensive hardware could try to simplify
* the brightness adjustment procedure.
*/
static int as3711_bl_update_status(struct backlight_device *bl)
{
struct as3711_bl_data *data = bl_get_data(bl);
struct as3711_bl_supply *supply = to_supply(data);
struct as3711 *as3711 = supply->as3711;
int brightness;
int ret = 0;
brightness = backlight_get_brightness(bl);
if (data->type == AS3711_BL_SU1) {
ret = as3711_set_brightness_v(as3711, brightness,
AS3711_STEPUP_CONTROL_1);
} else {
Annotation
- Immediate include surface: `linux/backlight.h`, `linux/delay.h`, `linux/device.h`, `linux/err.h`, `linux/kernel.h`, `linux/mfd/as3711.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct as3711_bl_data`, `struct as3711_bl_supply`, `enum as3711_bl_type`, `function as3711_set_brightness_auto_i`, `function as3711_set_brightness_v`, `function as3711_bl_su2_reset`, `function as3711_bl_update_status`, `function as3711_bl_get_brightness`, `function as3711_bl_init_su2`, `function as3711_bl_register`.
- 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.