drivers/video/backlight/pandora_bl.c
Source file repositories/reference/linux-study-clean/drivers/video/backlight/pandora_bl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/backlight/pandora_bl.c- Extension
.c- Size
- 4202 bytes
- Lines
- 160
- 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/module.hlinux/kernel.hlinux/platform_device.hlinux/delay.hlinux/backlight.hlinux/mfd/twl.hlinux/err.h
Detected Declarations
struct pandora_privatefunction pandora_backlight_update_statusfunction pandora_backlight_probe
Annotated Snippet
struct pandora_private {
unsigned old_state;
#define PANDORABL_WAS_OFF 1
};
static int pandora_backlight_update_status(struct backlight_device *bl)
{
int brightness = bl->props.brightness;
struct pandora_private *priv = bl_get_data(bl);
u8 r;
if (bl->props.power != BACKLIGHT_POWER_ON)
brightness = 0;
if (bl->props.state & BL_CORE_FBBLANK)
brightness = 0;
if (bl->props.state & BL_CORE_SUSPENDED)
brightness = 0;
if ((unsigned int)brightness > MAX_USER_VALUE)
brightness = MAX_USER_VALUE;
if (brightness == 0) {
if (priv->old_state == PANDORABL_WAS_OFF)
goto done;
/* first disable PWM0 output, then clock */
twl_i2c_read_u8(TWL4030_MODULE_INTBR, &r, TWL_INTBR_GPBR1);
r &= ~PWM0_ENABLE;
twl_i2c_write_u8(TWL4030_MODULE_INTBR, r, TWL_INTBR_GPBR1);
r &= ~PWM0_CLK_ENABLE;
twl_i2c_write_u8(TWL4030_MODULE_INTBR, r, TWL_INTBR_GPBR1);
goto done;
}
if (priv->old_state == PANDORABL_WAS_OFF) {
/*
* set PWM duty cycle to max. TPS61161 seems to use this
* to calibrate it's PWM sensitivity when it starts.
*/
twl_i2c_write_u8(TWL_MODULE_PWM, MAX_VALUE, TWL_PWM0_OFF);
/* first enable clock, then PWM0 out */
twl_i2c_read_u8(TWL4030_MODULE_INTBR, &r, TWL_INTBR_GPBR1);
r &= ~PWM0_ENABLE;
r |= PWM0_CLK_ENABLE;
twl_i2c_write_u8(TWL4030_MODULE_INTBR, r, TWL_INTBR_GPBR1);
r |= PWM0_ENABLE;
twl_i2c_write_u8(TWL4030_MODULE_INTBR, r, TWL_INTBR_GPBR1);
/*
* TI made it very easy to enable digital control, so easy that
* it often triggers unintentionally and disabes PWM control,
* so wait until 1 wire mode detection window ends.
*/
usleep_range(2000, 10000);
}
twl_i2c_write_u8(TWL_MODULE_PWM, MIN_VALUE + brightness, TWL_PWM0_OFF);
done:
if (brightness != 0)
priv->old_state = 0;
else
priv->old_state = PANDORABL_WAS_OFF;
return 0;
}
static const struct backlight_ops pandora_backlight_ops = {
.options = BL_CORE_SUSPENDRESUME,
.update_status = pandora_backlight_update_status,
};
static int pandora_backlight_probe(struct platform_device *pdev)
{
struct backlight_properties props;
struct backlight_device *bl;
struct pandora_private *priv;
u8 r;
priv = devm_kmalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
memset(&props, 0, sizeof(props));
props.max_brightness = MAX_USER_VALUE;
props.type = BACKLIGHT_RAW;
bl = devm_backlight_device_register(&pdev->dev, pdev->name, &pdev->dev,
priv, &pandora_backlight_ops, &props);
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/platform_device.h`, `linux/delay.h`, `linux/backlight.h`, `linux/mfd/twl.h`, `linux/err.h`.
- Detected declarations: `struct pandora_private`, `function pandora_backlight_update_status`, `function pandora_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.