drivers/gpu/drm/amd/display/modules/power/power.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/display/modules/power/power.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/display/modules/power/power.c- Extension
.c- Size
- 17095 bytes
- Lines
- 504
- Domain
- Driver Families
- Bucket
- drivers/gpu
- 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
dm_services.hdc.hmod_power.hcore_types.hdmcu.habm.hpower_helpers.hdce/dmub_psr.hdal_asic_id.hlink_service.hlinux/math.h
Detected Declarations
function container_offunction mod_power_hw_initfunction mod_power_destroyfunction mod_power_add_streamfunction mod_power_remove_streamfunction statefunction mod_power_notify_mode_change
Annotated Snippet
if (core_power->bl_prop[inst].use_nits_based_brightness) {
core_power->bl_prop[inst].min_brightness_millinits =
init_params[inst].panel_min_millinits;
core_power->bl_prop[inst].max_brightness_millinits =
init_params[inst].panel_max_millinits;
} else {
core_power->bl_prop[inst].min_brightness_millinits =
pwr_default_min_brightness_millinits;
core_power->bl_prop[inst].max_brightness_millinits =
pwr_default_sdr_brightness_millinits;
}
core_power->bl_prop[inst].backlight_range =
core_power->bl_prop[inst].max_backlight_pwm-
core_power->bl_prop[inst].min_backlight_pwm;
core_power->bl_prop[inst].nits_range =
core_power->bl_prop[inst].max_brightness_millinits -
core_power->bl_prop[inst].min_brightness_millinits;
core_power->bl_state[inst].smooth_brightness_enabled = true;
}
/* Check if at least 1 instance in core_power is populated before failing */
for (inst = 0; inst < edp_num; inst++) {
if (core_power->bl_prop[inst].nits_range != 0 && core_power->bl_prop[inst].backlight_range != 0) {
is_brightness_range_valid = true;
break;
}
}
if (!is_brightness_range_valid)
goto fail_bad_brightness_range;
core_power->num_entities = 0;
core_power->dc = dc;
for (inst = 0; inst < edp_num; inst++) {
initialize_backlight_caps(core_power, inst);
core_power->bl_state[inst].backlight_millipercent =
core_power->bl_prop[inst].dc_backlight_percent * 1000;
core_power->bl_state[inst].backlight_pwm = backlight_millipercent_to_pwm(core_power,
core_power->bl_state[inst].backlight_millipercent, inst);
core_power->bl_state[inst].backlight_millinit = backlight_millipercent_to_millinit(core_power,
core_power->bl_state[inst].backlight_millipercent, inst);
}
return &core_power->mod_public;
fail_bad_brightness_range:
fail_alloc_backlight_array:
for (inst = 0; inst < edp_num; inst++)
if (core_power->bl_prop[inst].backlight_lut)
kfree(core_power->bl_prop[inst].backlight_lut);
fail_construct:
for (i = 0; i < MOD_POWER_MAX_CONCURRENT_STREAMS; i++) {
if (core_power->map[i].psr_context)
kfree(core_power->map[i].psr_context);
}
kfree(core_power->map);
fail_alloc_map:
kfree(core_power);
fail_alloc_context:
fail_dc_null:
return NULL;
}
void mod_power_destroy(struct mod_power *mod_power)
{
if (mod_power != NULL) {
unsigned int i;
struct core_power *core_power =
MOD_POWER_TO_CORE(mod_power);
for (i = 0; i < MOD_POWER_MAX_CONCURRENT_STREAMS; i++)
if (core_power->map[i].psr_context)
kfree(core_power->map[i].psr_context);
for (i = 0; i < core_power->num_entities; i++)
if (core_power->map[i].stream)
dc_stream_release(core_power->map[i].stream);
kfree(core_power->map);
for (i = 0; i < MAX_NUM_EDP; i++)
if (core_power->bl_prop[i].backlight_lut)
kfree(core_power->bl_prop[i].backlight_lut);
Annotation
- Immediate include surface: `dm_services.h`, `dc.h`, `mod_power.h`, `core_types.h`, `dmcu.h`, `abm.h`, `power_helpers.h`, `dce/dmub_psr.h`.
- Detected declarations: `function container_of`, `function mod_power_hw_init`, `function mod_power_destroy`, `function mod_power_add_stream`, `function mod_power_remove_stream`, `function state`, `function mod_power_notify_mode_change`.
- Atlas domain: Driver Families / drivers/gpu.
- 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.