drivers/macintosh/via-pmu-backlight.c
Source file repositories/reference/linux-study-clean/drivers/macintosh/via-pmu-backlight.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/macintosh/via-pmu-backlight.c- Extension
.c- Size
- 4515 bytes
- Lines
- 188
- Domain
- Driver Families
- Bucket
- drivers/macintosh
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
asm/ptrace.hlinux/adb.hlinux/backlight.hlinux/fb.hlinux/of.hlinux/pmu.hasm/backlight.h
Detected Declarations
function pmu_backlight_init_curvefunction pmu_backlight_curve_lookupfunction pmu_backlight_get_level_brightnessfunction __pmu_backlight_update_statusfunction pmu_backlight_update_statusfunction pmu_backlight_set_sleepfunction pmu_backlight_init
Annotated Snippet
if (diff < max) {
max = diff;
level = i;
}
}
return level;
}
static int pmu_backlight_get_level_brightness(int level)
{
int pmulevel;
/* Get and convert the value */
pmulevel = bl_curve[level] * FB_BACKLIGHT_MAX / MAX_PMU_LEVEL;
if (pmulevel < 0)
pmulevel = 0;
else if (pmulevel > MAX_PMU_LEVEL)
pmulevel = MAX_PMU_LEVEL;
return pmulevel;
}
static int __pmu_backlight_update_status(struct backlight_device *bd)
{
struct adb_request req;
int level = backlight_get_brightness(bd);
if (level > 0) {
int pmulevel = pmu_backlight_get_level_brightness(level);
pmu_request(&req, NULL, 2, PMU_BACKLIGHT_BRIGHT, pmulevel);
pmu_wait_complete(&req);
pmu_request(&req, NULL, 2, PMU_POWER_CTRL,
PMU_POW_BACKLIGHT | PMU_POW_ON);
pmu_wait_complete(&req);
} else {
pmu_request(&req, NULL, 2, PMU_POWER_CTRL,
PMU_POW_BACKLIGHT | PMU_POW_OFF);
pmu_wait_complete(&req);
}
return 0;
}
static int pmu_backlight_update_status(struct backlight_device *bd)
{
unsigned long flags;
int rc = 0;
spin_lock_irqsave(&pmu_backlight_lock, flags);
/* Don't update brightness when sleeping */
if (!sleeping)
rc = __pmu_backlight_update_status(bd);
spin_unlock_irqrestore(&pmu_backlight_lock, flags);
return rc;
}
static const struct backlight_ops pmu_backlight_data = {
.update_status = pmu_backlight_update_status,
};
#ifdef CONFIG_PM
void pmu_backlight_set_sleep(int sleep)
{
unsigned long flags;
spin_lock_irqsave(&pmu_backlight_lock, flags);
sleeping = sleep;
if (pmac_backlight && uses_pmu_bl) {
if (sleep) {
struct adb_request req;
pmu_request(&req, NULL, 2, PMU_POWER_CTRL,
PMU_POW_BACKLIGHT | PMU_POW_OFF);
pmu_wait_complete(&req);
} else
__pmu_backlight_update_status(pmac_backlight);
}
spin_unlock_irqrestore(&pmu_backlight_lock, flags);
}
#endif /* CONFIG_PM */
void __init pmu_backlight_init(void)
{
struct backlight_properties props;
struct backlight_device *bd;
char name[10];
Annotation
- Immediate include surface: `asm/ptrace.h`, `linux/adb.h`, `linux/backlight.h`, `linux/fb.h`, `linux/of.h`, `linux/pmu.h`, `asm/backlight.h`.
- Detected declarations: `function pmu_backlight_init_curve`, `function pmu_backlight_curve_lookup`, `function pmu_backlight_get_level_brightness`, `function __pmu_backlight_update_status`, `function pmu_backlight_update_status`, `function pmu_backlight_set_sleep`, `function pmu_backlight_init`.
- Atlas domain: Driver Families / drivers/macintosh.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.