drivers/video/backlight/88pm860x_bl.c
Source file repositories/reference/linux-study-clean/drivers/video/backlight/88pm860x_bl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/backlight/88pm860x_bl.c- Extension
.c- Size
- 6747 bytes
- Lines
- 260
- 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/init.hlinux/kernel.hlinux/of.hlinux/platform_device.hlinux/slab.hlinux/i2c.hlinux/backlight.hlinux/mfd/88pm860x.hlinux/module.h
Detected Declarations
struct pm860x_backlight_datafunction backlight_power_setfunction pm860x_backlight_setfunction pm860x_backlight_update_statusfunction pm860x_backlight_get_brightnessfunction pm860x_backlight_dt_initfunction pm860x_backlight_probe
Annotated Snippet
struct pm860x_backlight_data {
struct pm860x_chip *chip;
struct i2c_client *i2c;
int current_brightness;
int port;
int pwm;
int iset;
int reg_duty_cycle;
int reg_always_on;
int reg_current;
};
static int backlight_power_set(struct pm860x_chip *chip, int port,
int on)
{
int ret = -EINVAL;
switch (port) {
case 0:
ret = on ? pm8606_osc_enable(chip, WLED1_DUTY) :
pm8606_osc_disable(chip, WLED1_DUTY);
break;
case 1:
ret = on ? pm8606_osc_enable(chip, WLED2_DUTY) :
pm8606_osc_disable(chip, WLED2_DUTY);
break;
case 2:
ret = on ? pm8606_osc_enable(chip, WLED3_DUTY) :
pm8606_osc_disable(chip, WLED3_DUTY);
break;
}
return ret;
}
static int pm860x_backlight_set(struct backlight_device *bl, int brightness)
{
struct pm860x_backlight_data *data = bl_get_data(bl);
struct pm860x_chip *chip = data->chip;
unsigned char value;
int ret;
if (brightness > MAX_BRIGHTNESS)
value = MAX_BRIGHTNESS;
else
value = brightness;
if (brightness)
backlight_power_set(chip, data->port, 1);
ret = pm860x_reg_write(data->i2c, data->reg_duty_cycle, value);
if (ret < 0)
goto out;
if ((data->current_brightness == 0) && brightness) {
if (data->iset) {
ret = pm860x_set_bits(data->i2c, data->reg_current,
CURRENT_BITMASK, data->iset);
if (ret < 0)
goto out;
}
if (data->pwm) {
ret = pm860x_set_bits(data->i2c, PM8606_PWM,
PM8606_PWM_FREQ_MASK, data->pwm);
if (ret < 0)
goto out;
}
if (brightness == MAX_BRIGHTNESS) {
/* set WLED_ON bit as 100% */
ret = pm860x_set_bits(data->i2c, data->reg_always_on,
PM8606_WLED_ON, PM8606_WLED_ON);
}
} else {
if (brightness == MAX_BRIGHTNESS) {
/* set WLED_ON bit as 100% */
ret = pm860x_set_bits(data->i2c, data->reg_always_on,
PM8606_WLED_ON, PM8606_WLED_ON);
} else {
/* clear WLED_ON bit since it's not 100% */
ret = pm860x_set_bits(data->i2c, data->reg_always_on,
PM8606_WLED_ON, 0);
}
}
if (ret < 0)
goto out;
if (brightness == 0)
backlight_power_set(chip, data->port, 0);
dev_dbg(chip->dev, "set brightness %d\n", value);
data->current_brightness = value;
Annotation
- Immediate include surface: `linux/init.h`, `linux/kernel.h`, `linux/of.h`, `linux/platform_device.h`, `linux/slab.h`, `linux/i2c.h`, `linux/backlight.h`, `linux/mfd/88pm860x.h`.
- Detected declarations: `struct pm860x_backlight_data`, `function backlight_power_set`, `function pm860x_backlight_set`, `function pm860x_backlight_update_status`, `function pm860x_backlight_get_brightness`, `function pm860x_backlight_dt_init`, `function pm860x_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.