drivers/video/backlight/lp855x_bl.c
Source file repositories/reference/linux-study-clean/drivers/video/backlight/lp855x_bl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/backlight/lp855x_bl.c- Extension
.c- Size
- 14172 bytes
- Lines
- 609
- 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/acpi.hlinux/module.hlinux/slab.hlinux/i2c.hlinux/backlight.hlinux/delay.hlinux/err.hlinux/of.hlinux/platform_data/lp855x.hlinux/pwm.hlinux/regulator/consumer.h
Detected Declarations
struct lp855xstruct lp855x_device_configstruct lp855xenum lp855x_brightness_ctrl_modefunction lp855x_write_bytefunction lp855x_update_bitfunction lp855x_is_valid_rom_areafunction lp8557_bl_offfunction lp8557_bl_onfunction lp855x_configurefunction lp855x_pwm_ctrlfunction lp855x_bl_update_statusfunction lp855x_backlight_registerfunction lp855x_get_chip_idfunction lp855x_get_bl_ctl_modefunction lp855x_parse_dtfunction for_each_child_of_nodefunction lp855x_parse_dtfunction lp855x_parse_acpifunction lp855x_probefunction lp855x_remove
Annotated Snippet
struct lp855x_device_config {
int (*pre_init_device)(struct lp855x *);
u8 reg_brightness;
u8 reg_devicectrl;
int (*post_init_device)(struct lp855x *);
};
struct lp855x {
const char *chipname;
enum lp855x_chip_id chip_id;
enum lp855x_brightness_ctrl_mode mode;
struct lp855x_device_config *cfg;
struct i2c_client *client;
struct backlight_device *bl;
struct device *dev;
struct lp855x_platform_data *pdata;
struct pwm_device *pwm;
bool needs_pwm_init;
struct regulator *supply; /* regulator for VDD input */
struct regulator *enable; /* regulator for EN/VDDIO input */
};
static int lp855x_write_byte(struct lp855x *lp, u8 reg, u8 data)
{
return i2c_smbus_write_byte_data(lp->client, reg, data);
}
static int lp855x_update_bit(struct lp855x *lp, u8 reg, u8 mask, u8 data)
{
int ret;
u8 tmp;
ret = i2c_smbus_read_byte_data(lp->client, reg);
if (ret < 0) {
dev_err(lp->dev, "failed to read 0x%.2x\n", reg);
return ret;
}
tmp = (u8)ret;
tmp &= ~mask;
tmp |= data & mask;
return lp855x_write_byte(lp, reg, tmp);
}
static bool lp855x_is_valid_rom_area(struct lp855x *lp, u8 addr)
{
u8 start, end;
switch (lp->chip_id) {
case LP8550:
case LP8551:
case LP8552:
case LP8553:
start = LP855X_EEPROM_START;
end = LP855X_EEPROM_END;
break;
case LP8556:
start = LP8556_EPROM_START;
end = LP8556_EPROM_END;
break;
case LP8555:
start = LP8555_EPROM_START;
end = LP8555_EPROM_END;
break;
case LP8557:
start = LP8557_EPROM_START;
end = LP8557_EPROM_END;
break;
default:
return false;
}
return addr >= start && addr <= end;
}
static int lp8557_bl_off(struct lp855x *lp)
{
/* BL_ON = 0 before updating EPROM settings */
return lp855x_update_bit(lp, LP8557_BL_CMD, LP8557_BL_MASK,
LP8557_BL_OFF);
}
static int lp8557_bl_on(struct lp855x *lp)
{
/* BL_ON = 1 after updating EPROM settings */
return lp855x_update_bit(lp, LP8557_BL_CMD, LP8557_BL_MASK,
LP8557_BL_ON);
}
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/module.h`, `linux/slab.h`, `linux/i2c.h`, `linux/backlight.h`, `linux/delay.h`, `linux/err.h`, `linux/of.h`.
- Detected declarations: `struct lp855x`, `struct lp855x_device_config`, `struct lp855x`, `enum lp855x_brightness_ctrl_mode`, `function lp855x_write_byte`, `function lp855x_update_bit`, `function lp855x_is_valid_rom_area`, `function lp8557_bl_off`, `function lp8557_bl_on`, `function lp855x_configure`.
- 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.