drivers/gpu/drm/amd/display/modules/freesync/freesync.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/display/modules/freesync/freesync.c- Extension
.c- Size
- 42444 bytes
- Lines
- 1311
- 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_freesync.hcore_types.h
Detected Declarations
struct core_freesyncfunction container_offunction mod_freesync_destroyfunction calc_refresh_in_uhz_from_durationfunction calc_duration_in_us_from_refresh_in_uhzfunction calc_duration_in_us_from_v_totalfunction calc_max_hardware_v_totalfunction mod_freesync_calc_v_total_from_refreshfunction calc_v_total_from_durationfunction update_v_total_for_static_rampfunction apply_below_the_rangefunction apply_fixed_refreshfunction determine_flip_interval_workaround_reqfunction vrr_settings_require_updatefunction build_vrr_infopacket_data_v1function build_vrr_infopacket_data_v3function build_vrr_infopacket_fs2_datafunction build_vrr_infopacket_header_v1function build_vrr_infopacket_header_v2function build_vrr_infopacket_header_v3function build_vrr_infopacket_checksumfunction build_vrr_infopacket_v1function build_vrr_infopacket_v2function build_vrr_infopacket_v3function build_vrr_infopacket_sdp_v1_3function mod_freesync_build_vrr_infopacketfunction mod_freesync_build_vrr_paramsfunction mod_freesync_handle_preflipfunction mod_freesync_handle_v_updatefunction mod_freesync_calc_nominal_field_ratefunction mod_freesync_get_freesync_enabled
Annotated Snippet
struct core_freesync {
struct mod_freesync public;
struct dc *dc;
};
#define MOD_FREESYNC_TO_CORE(mod_freesync)\
container_of(mod_freesync, struct core_freesync, public)
struct mod_freesync *mod_freesync_create(struct dc *dc)
{
struct core_freesync *core_freesync =
kzalloc_obj(struct core_freesync);
if (core_freesync == NULL)
goto fail_alloc_context;
if (dc == NULL)
goto fail_construct;
core_freesync->dc = dc;
return &core_freesync->public;
fail_construct:
kfree(core_freesync);
fail_alloc_context:
return NULL;
}
void mod_freesync_destroy(struct mod_freesync *mod_freesync)
{
struct core_freesync *core_freesync = NULL;
if (mod_freesync == NULL)
return;
core_freesync = MOD_FREESYNC_TO_CORE(mod_freesync);
kfree(core_freesync);
}
#if 0 /* Unused currently */
static unsigned int calc_refresh_in_uhz_from_duration(
unsigned int duration_in_ns)
{
unsigned int refresh_in_uhz =
((unsigned int)(div64_u64((1000000000ULL * 1000000),
duration_in_ns)));
return refresh_in_uhz;
}
#endif
static unsigned int calc_duration_in_us_from_refresh_in_uhz(
unsigned int refresh_in_uhz)
{
unsigned int duration_in_us =
((unsigned int)(div64_u64((1000000000ULL * 1000),
refresh_in_uhz)));
return duration_in_us;
}
static unsigned int calc_duration_in_us_from_v_total(
const struct dc_stream_state *stream,
const struct mod_vrr_params *in_vrr,
unsigned int v_total)
{
(void)in_vrr;
unsigned int duration_in_us =
(unsigned int)(div64_u64(((unsigned long long)(v_total)
* 10000) * stream->timing.h_total,
stream->timing.pix_clk_100hz));
return duration_in_us;
}
static unsigned int calc_max_hardware_v_total(const struct dc_stream_state *stream)
{
unsigned int max_hw_v_total = stream->ctx->dc->caps.max_v_total;
if (stream->ctx->dc->caps.vtotal_limited_by_fp2) {
max_hw_v_total -= stream->timing.v_front_porch + 1;
}
return max_hw_v_total;
}
unsigned int mod_freesync_calc_v_total_from_refresh(
const struct dc_stream_state *stream,
unsigned int refresh_in_uhz)
{
unsigned int v_total;
unsigned int frame_duration_in_ns;
Annotation
- Immediate include surface: `dm_services.h`, `dc.h`, `mod_freesync.h`, `core_types.h`.
- Detected declarations: `struct core_freesync`, `function container_of`, `function mod_freesync_destroy`, `function calc_refresh_in_uhz_from_duration`, `function calc_duration_in_us_from_refresh_in_uhz`, `function calc_duration_in_us_from_v_total`, `function calc_max_hardware_v_total`, `function mod_freesync_calc_v_total_from_refresh`, `function calc_v_total_from_duration`, `function update_v_total_for_static_ramp`.
- 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.