drivers/gpu/drm/renesas/rcar-du/rcar_du_crtc.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/renesas/rcar-du/rcar_du_crtc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/renesas/rcar-du/rcar_du_crtc.c- Extension
.c- Size
- 36168 bytes
- Lines
- 1340
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/clk.hlinux/mutex.hlinux/platform_device.hdrm/drm_atomic.hdrm/drm_atomic_helper.hdrm/drm_bridge.hdrm/drm_crtc.hdrm/drm_device.hdrm/drm_gem_dma_helper.hdrm/drm_print.hdrm/drm_vblank.hrcar_cmm.hrcar_du_crtc.hrcar_du_drv.hrcar_du_encoder.hrcar_du_kms.hrcar_du_plane.hrcar_du_regs.hrcar_du_vsp.hrcar_lvds.hrcar_mipi_dsi.h
Detected Declarations
struct dpll_infostruct du_clk_paramsfunction Copyrightfunction rcar_du_crtc_writefunction rcar_du_crtc_clrfunction rcar_du_crtc_setfunction rcar_du_crtc_dsysr_clr_setfunction rcar_du_dpll_dividerfunction rcar_du_escr_dividerfunction rcar_du_crtc_set_display_timingfunction BITfunction plane_zposfunction plane_formatfunction rcar_du_crtc_update_planesfunction rcar_du_crtc_finish_page_flipfunction rcar_du_crtc_page_flip_pendingfunction rcar_du_crtc_wait_page_flipfunction Modulefunction rcar_du_cmm_setupfunction rcar_du_crtc_setupfunction rcar_du_crtc_getfunction rcar_du_crtc_putfunction rcar_du_crtc_startfunction rcar_du_crtc_disable_planesfunction rcar_du_crtc_stopfunction rcar_du_crtc_atomic_checkfunction drm_for_each_encoder_maskfunction rcar_du_crtc_atomic_enablefunction rcar_du_crtc_atomic_disablefunction rcar_du_crtc_atomic_beginfunction rcar_du_crtc_atomic_flushfunction rcar_du_crtc_mode_validfunction rcar_du_crtc_crc_initfunction rcar_du_crtc_crc_cleanupfunction rcar_du_crtc_atomic_duplicate_statefunction rcar_du_crtc_atomic_destroy_statefunction rcar_du_crtc_cleanupfunction rcar_du_crtc_resetfunction rcar_du_crtc_enable_vblankfunction rcar_du_crtc_disable_vblankfunction rcar_du_crtc_parse_crc_sourcefunction planefunction rcar_du_crtc_verify_crc_sourcefunction rcar_du_crtc_get_crc_sourcesfunction rcar_du_crtc_set_crc_sourcefunction rcar_du_crtc_irqfunction rcar_du_crtc_create
Annotated Snippet
struct dpll_info {
unsigned int output;
unsigned int fdpll;
unsigned int n;
unsigned int m;
};
static void rcar_du_dpll_divider(struct rcar_du_crtc *rcrtc,
struct dpll_info *dpll,
unsigned long input,
unsigned long target)
{
unsigned long best_diff = (unsigned long)-1;
unsigned long diff;
unsigned int fdpll;
unsigned int m;
unsigned int n;
/*
* fin fvco fout fclkout
* in --> [1/M] --> |PD| -> [LPF] -> [VCO] -> [1/P] -+-> [1/FDPLL] -> out
* +-> | | |
* | |
* +---------------- [1/N] <------------+
*
* fclkout = fvco / P / FDPLL -- (1)
*
* fin/M = fvco/P/N
*
* fvco = fin * P * N / M -- (2)
*
* (1) + (2) indicates
*
* fclkout = fin * N / M / FDPLL
*
* NOTES
* N : (n + 1)
* M : (m + 1)
* FDPLL : (fdpll + 1)
* P : 2
* 2kHz < fvco < 4096MHz
*
* To minimize the jitter,
* N : as large as possible
* M : as small as possible
*/
for (m = 0; m < 4; m++) {
for (n = 119; n > 38; n--) {
/*
* This code only runs on 64-bit architectures, the
* unsigned long type can thus be used for 64-bit
* computation. It will still compile without any
* warning on 32-bit architectures.
*
* To optimize calculations, use fout instead of fvco
* to verify the VCO frequency constraint.
*/
unsigned long fout = input * (n + 1) / (m + 1);
if (fout < 1000 || fout > 2048 * 1000 * 1000U)
continue;
for (fdpll = 1; fdpll < 32; fdpll++) {
unsigned long output;
output = fout / (fdpll + 1);
if (output >= 400 * 1000 * 1000)
continue;
diff = abs((long)output - (long)target);
if (best_diff > diff) {
best_diff = diff;
dpll->n = n;
dpll->m = m;
dpll->fdpll = fdpll;
dpll->output = output;
}
if (diff == 0)
goto done;
}
}
}
done:
dev_dbg(rcrtc->dev->dev,
"output:%u, fdpll:%u, n:%u, m:%u, diff:%lu\n",
dpll->output, dpll->fdpll, dpll->n, dpll->m, best_diff);
}
Annotation
- Immediate include surface: `linux/clk.h`, `linux/mutex.h`, `linux/platform_device.h`, `drm/drm_atomic.h`, `drm/drm_atomic_helper.h`, `drm/drm_bridge.h`, `drm/drm_crtc.h`, `drm/drm_device.h`.
- Detected declarations: `struct dpll_info`, `struct du_clk_params`, `function Copyright`, `function rcar_du_crtc_write`, `function rcar_du_crtc_clr`, `function rcar_du_crtc_set`, `function rcar_du_crtc_dsysr_clr_set`, `function rcar_du_dpll_divider`, `function rcar_du_escr_divider`, `function rcar_du_crtc_set_display_timing`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.