drivers/video/backlight/lp8788_bl.c
Source file repositories/reference/linux-study-clean/drivers/video/backlight/lp8788_bl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/backlight/lp8788_bl.c- Extension
.c- Size
- 4465 bytes
- Lines
- 191
- 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/err.hlinux/mfd/lp8788.hlinux/module.hlinux/platform_device.hlinux/slab.h
Detected Declarations
struct lp8788_blfunction lp8788_backlight_configurefunction lp8788_bl_update_statusfunction lp8788_backlight_registerfunction lp8788_backlight_unregisterfunction lp8788_get_bl_ctl_modefunction lp8788_backlight_probefunction lp8788_backlight_remove
Annotated Snippet
struct lp8788_bl {
struct lp8788 *lp;
struct backlight_device *bl_dev;
};
static int lp8788_backlight_configure(struct lp8788_bl *bl)
{
int ret;
u8 val;
/* Brightness ramp up/down */
val = (LP8788_RAMP_8192us << LP8788_BL_RAMP_RISE_SHIFT) | LP8788_RAMP_8192us;
ret = lp8788_write_byte(bl->lp, LP8788_BL_RAMP, val);
if (ret)
return ret;
/* Fullscale current setting */
val = (LP8788_FULLSCALE_1900uA << LP8788_BL_FULLSCALE_SHIFT) |
(LP8788_DIM_EXPONENTIAL << LP8788_BL_DIM_MODE_SHIFT);
/* Brightness control mode */
val |= LP8788_BL_EN;
return lp8788_write_byte(bl->lp, LP8788_BL_CONFIG, val);
}
static int lp8788_bl_update_status(struct backlight_device *bl_dev)
{
struct lp8788_bl *bl = bl_get_data(bl_dev);
if (bl_dev->props.state & BL_CORE_SUSPENDED)
bl_dev->props.brightness = 0;
lp8788_write_byte(bl->lp, LP8788_BL_BRIGHTNESS, bl_dev->props.brightness);
return 0;
}
static const struct backlight_ops lp8788_bl_ops = {
.options = BL_CORE_SUSPENDRESUME,
.update_status = lp8788_bl_update_status,
};
static int lp8788_backlight_register(struct lp8788_bl *bl)
{
struct backlight_device *bl_dev;
struct backlight_properties props;
memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_PLATFORM;
props.max_brightness = MAX_BRIGHTNESS;
/* Initial brightness */
props.brightness = 0;
/* Backlight device name */
bl_dev = backlight_device_register(DEFAULT_BL_NAME, bl->lp->dev, bl,
&lp8788_bl_ops, &props);
if (IS_ERR(bl_dev))
return PTR_ERR(bl_dev);
bl->bl_dev = bl_dev;
return 0;
}
static void lp8788_backlight_unregister(struct lp8788_bl *bl)
{
struct backlight_device *bl_dev = bl->bl_dev;
backlight_device_unregister(bl_dev);
}
static ssize_t lp8788_get_bl_ctl_mode(struct device *dev,
struct device_attribute *attr, char *buf)
{
const char *strmode = "Register based";
return scnprintf(buf, PAGE_SIZE, "%s\n", strmode);
}
static DEVICE_ATTR(bl_ctl_mode, S_IRUGO, lp8788_get_bl_ctl_mode, NULL);
static struct attribute *lp8788_attributes[] = {
&dev_attr_bl_ctl_mode.attr,
NULL,
};
static const struct attribute_group lp8788_attr_group = {
.attrs = lp8788_attributes,
Annotation
- Immediate include surface: `linux/backlight.h`, `linux/err.h`, `linux/mfd/lp8788.h`, `linux/module.h`, `linux/platform_device.h`, `linux/slab.h`.
- Detected declarations: `struct lp8788_bl`, `function lp8788_backlight_configure`, `function lp8788_bl_update_status`, `function lp8788_backlight_register`, `function lp8788_backlight_unregister`, `function lp8788_get_bl_ctl_mode`, `function lp8788_backlight_probe`, `function lp8788_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.