drivers/video/backlight/lm3639_bl.c
Source file repositories/reference/linux-study-clean/drivers/video/backlight/lm3639_bl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/backlight/lm3639_bl.c- Extension
.c- Size
- 10459 bytes
- Lines
- 426
- 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/module.hlinux/slab.hlinux/i2c.hlinux/leds.hlinux/backlight.hlinux/err.hlinux/delay.hlinux/uaccess.hlinux/interrupt.hlinux/regmap.hlinux/platform_data/lm3639_bl.h
Detected Declarations
struct lm3639_chip_datafunction lm3639_chip_initfunction lm3639_bled_update_statusfunction lm3639_bled_get_brightnessfunction lm3639_bled_mode_storefunction lm3639_torch_brightness_setfunction lm3639_flash_brightness_setfunction lm3639_probefunction lm3639_remove
Annotated Snippet
struct lm3639_chip_data {
struct device *dev;
struct lm3639_platform_data *pdata;
struct backlight_device *bled;
struct led_classdev cdev_flash;
struct led_classdev cdev_torch;
struct regmap *regmap;
unsigned int bled_mode;
unsigned int bled_map;
unsigned int last_flag;
};
/* initialize chip */
static int lm3639_chip_init(struct lm3639_chip_data *pchip)
{
int ret;
unsigned int reg_val;
struct lm3639_platform_data *pdata = pchip->pdata;
/* input pins config. */
ret =
regmap_update_bits(pchip->regmap, REG_BL_CONF_1, 0x08,
pdata->pin_pwm);
if (ret < 0)
goto out;
reg_val = (pdata->pin_pwm & 0x40) | pdata->pin_strobe | pdata->pin_tx;
ret = regmap_update_bits(pchip->regmap, REG_IO_CTRL, 0x7C, reg_val);
if (ret < 0)
goto out;
/* init brightness */
ret = regmap_write(pchip->regmap, REG_BL_CONF_4, pdata->init_brt_led);
if (ret < 0)
goto out;
ret = regmap_write(pchip->regmap, REG_BL_CONF_3, pdata->init_brt_led);
if (ret < 0)
goto out;
/* output pins config. */
if (!pdata->init_brt_led) {
reg_val = pdata->fled_pins;
reg_val |= pdata->bled_pins;
} else {
reg_val = pdata->fled_pins;
reg_val |= pdata->bled_pins | 0x01;
}
ret = regmap_update_bits(pchip->regmap, REG_ENABLE, 0x79, reg_val);
if (ret < 0)
goto out;
return ret;
out:
dev_err(pchip->dev, "i2c failed to access register\n");
return ret;
}
/* update and get brightness */
static int lm3639_bled_update_status(struct backlight_device *bl)
{
int ret;
unsigned int reg_val;
struct lm3639_chip_data *pchip = bl_get_data(bl);
struct lm3639_platform_data *pdata = pchip->pdata;
ret = regmap_read(pchip->regmap, REG_FLAG, ®_val);
if (ret < 0)
goto out;
if (reg_val != 0)
dev_info(pchip->dev, "last flag is 0x%x\n", reg_val);
/* pwm control */
if (pdata->pin_pwm) {
if (pdata->pwm_set_intensity)
pdata->pwm_set_intensity(bl->props.brightness,
pdata->max_brt_led);
else
dev_err(pchip->dev,
"No pwm control func. in plat-data\n");
return bl->props.brightness;
}
/* i2c control and set brigtness */
ret = regmap_write(pchip->regmap, REG_BL_CONF_4, bl->props.brightness);
if (ret < 0)
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/i2c.h`, `linux/leds.h`, `linux/backlight.h`, `linux/err.h`, `linux/delay.h`, `linux/uaccess.h`.
- Detected declarations: `struct lm3639_chip_data`, `function lm3639_chip_init`, `function lm3639_bled_update_status`, `function lm3639_bled_get_brightness`, `function lm3639_bled_mode_store`, `function lm3639_torch_brightness_set`, `function lm3639_flash_brightness_set`, `function lm3639_probe`, `function lm3639_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.