drivers/video/backlight/wm831x_bl.c
Source file repositories/reference/linux-study-clean/drivers/video/backlight/wm831x_bl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/backlight/wm831x_bl.c- Extension
.c- Size
- 5313 bytes
- Lines
- 216
- 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/init.hlinux/platform_device.hlinux/module.hlinux/backlight.hlinux/slab.hlinux/mfd/wm831x/core.hlinux/mfd/wm831x/pdata.hlinux/mfd/wm831x/regulator.h
Detected Declarations
struct wm831x_backlight_datafunction wm831x_backlight_setfunction wm831x_backlight_update_statusfunction wm831x_backlight_get_brightnessfunction wm831x_backlight_probe
Annotated Snippet
struct wm831x_backlight_data {
struct wm831x *wm831x;
int isink_reg;
int current_brightness;
};
static int wm831x_backlight_set(struct backlight_device *bl, int brightness)
{
struct wm831x_backlight_data *data = bl_get_data(bl);
struct wm831x *wm831x = data->wm831x;
int power_up = !data->current_brightness && brightness;
int power_down = data->current_brightness && !brightness;
int ret;
if (power_up) {
/* Enable the ISINK */
ret = wm831x_set_bits(wm831x, data->isink_reg,
WM831X_CS1_ENA, WM831X_CS1_ENA);
if (ret < 0)
goto err;
/* Enable the DC-DC */
ret = wm831x_set_bits(wm831x, WM831X_DCDC_ENABLE,
WM831X_DC4_ENA, WM831X_DC4_ENA);
if (ret < 0)
goto err;
}
if (power_down) {
/* DCDC first */
ret = wm831x_set_bits(wm831x, WM831X_DCDC_ENABLE,
WM831X_DC4_ENA, 0);
if (ret < 0)
goto err;
/* ISINK */
ret = wm831x_set_bits(wm831x, data->isink_reg,
WM831X_CS1_DRIVE | WM831X_CS1_ENA, 0);
if (ret < 0)
goto err;
}
/* Set the new brightness */
ret = wm831x_set_bits(wm831x, data->isink_reg,
WM831X_CS1_ISEL_MASK, brightness);
if (ret < 0)
goto err;
if (power_up) {
/* Drive current through the ISINK */
ret = wm831x_set_bits(wm831x, data->isink_reg,
WM831X_CS1_DRIVE, WM831X_CS1_DRIVE);
if (ret < 0)
return ret;
}
data->current_brightness = brightness;
return 0;
err:
/* If we were in the middle of a power transition always shut down
* for safety.
*/
if (power_up || power_down) {
wm831x_set_bits(wm831x, WM831X_DCDC_ENABLE, WM831X_DC4_ENA, 0);
wm831x_set_bits(wm831x, data->isink_reg, WM831X_CS1_ENA, 0);
}
return ret;
}
static int wm831x_backlight_update_status(struct backlight_device *bl)
{
return wm831x_backlight_set(bl, backlight_get_brightness(bl));
}
static int wm831x_backlight_get_brightness(struct backlight_device *bl)
{
struct wm831x_backlight_data *data = bl_get_data(bl);
return data->current_brightness;
}
static const struct backlight_ops wm831x_backlight_ops = {
.options = BL_CORE_SUSPENDRESUME,
.update_status = wm831x_backlight_update_status,
.get_brightness = wm831x_backlight_get_brightness,
};
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/init.h`, `linux/platform_device.h`, `linux/module.h`, `linux/backlight.h`, `linux/slab.h`, `linux/mfd/wm831x/core.h`, `linux/mfd/wm831x/pdata.h`.
- Detected declarations: `struct wm831x_backlight_data`, `function wm831x_backlight_set`, `function wm831x_backlight_update_status`, `function wm831x_backlight_get_brightness`, `function wm831x_backlight_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.