drivers/video/backlight/tps65217_bl.c
Source file repositories/reference/linux-study-clean/drivers/video/backlight/tps65217_bl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/backlight/tps65217_bl.c- Extension
.c- Size
- 6996 bytes
- Lines
- 318
- 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/kernel.hlinux/backlight.hlinux/err.hlinux/mfd/tps65217.hlinux/module.hlinux/platform_device.hlinux/slab.h
Detected Declarations
struct tps65217_blfunction tps65217_bl_enablefunction tps65217_bl_disablefunction tps65217_bl_update_statusfunction tps65217_bl_hw_initfunction tps65217_bl_parse_dtfunction tps65217_bl_parse_dtfunction tps65217_bl_probe
Annotated Snippet
struct tps65217_bl {
struct tps65217 *tps;
struct device *dev;
struct backlight_device *bl;
bool is_enabled;
};
static int tps65217_bl_enable(struct tps65217_bl *tps65217_bl)
{
int rc;
rc = tps65217_set_bits(tps65217_bl->tps, TPS65217_REG_WLEDCTRL1,
TPS65217_WLEDCTRL1_ISINK_ENABLE,
TPS65217_WLEDCTRL1_ISINK_ENABLE, TPS65217_PROTECT_NONE);
if (rc) {
dev_err(tps65217_bl->dev,
"failed to enable backlight: %d\n", rc);
return rc;
}
tps65217_bl->is_enabled = true;
dev_dbg(tps65217_bl->dev, "backlight enabled\n");
return 0;
}
static int tps65217_bl_disable(struct tps65217_bl *tps65217_bl)
{
int rc;
rc = tps65217_clear_bits(tps65217_bl->tps,
TPS65217_REG_WLEDCTRL1,
TPS65217_WLEDCTRL1_ISINK_ENABLE,
TPS65217_PROTECT_NONE);
if (rc) {
dev_err(tps65217_bl->dev,
"failed to disable backlight: %d\n", rc);
return rc;
}
tps65217_bl->is_enabled = false;
dev_dbg(tps65217_bl->dev, "backlight disabled\n");
return 0;
}
static int tps65217_bl_update_status(struct backlight_device *bl)
{
struct tps65217_bl *tps65217_bl = bl_get_data(bl);
int rc;
int brightness = backlight_get_brightness(bl);
if (brightness > 0) {
rc = tps65217_reg_write(tps65217_bl->tps,
TPS65217_REG_WLEDCTRL2,
brightness - 1,
TPS65217_PROTECT_NONE);
if (rc) {
dev_err(tps65217_bl->dev,
"failed to set brightness level: %d\n", rc);
return rc;
}
dev_dbg(tps65217_bl->dev, "brightness set to %d\n", brightness);
if (!tps65217_bl->is_enabled)
rc = tps65217_bl_enable(tps65217_bl);
} else {
rc = tps65217_bl_disable(tps65217_bl);
}
return rc;
}
static const struct backlight_ops tps65217_bl_ops = {
.options = BL_CORE_SUSPENDRESUME,
.update_status = tps65217_bl_update_status,
};
static int tps65217_bl_hw_init(struct tps65217_bl *tps65217_bl,
struct tps65217_bl_pdata *pdata)
{
int rc;
rc = tps65217_bl_disable(tps65217_bl);
if (rc)
return rc;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/backlight.h`, `linux/err.h`, `linux/mfd/tps65217.h`, `linux/module.h`, `linux/platform_device.h`, `linux/slab.h`.
- Detected declarations: `struct tps65217_bl`, `function tps65217_bl_enable`, `function tps65217_bl_disable`, `function tps65217_bl_update_status`, `function tps65217_bl_hw_init`, `function tps65217_bl_parse_dt`, `function tps65217_bl_parse_dt`, `function tps65217_bl_probe`.
- 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.