drivers/video/fbdev/riva/riva_hw.c
Source file repositories/reference/linux-study-clean/drivers/video/fbdev/riva/riva_hw.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/fbdev/riva/riva_hw.c- Extension
.c- Size
- 78205 bytes
- Lines
- 2238
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/pci.hlinux/pci_ids.hriva_hw.hriva_tbl.hnv_type.h
Detected Declarations
function identicallyfunction nv4Busyfunction nv10Busyfunction vgaLockUnlockfunction nv3LockUnlockfunction nv4LockUnlockfunction ShowHideCursorfunction nv3_iteratefunction nv3_arbfunction nv3_get_paramfunction nv3CalcArbitrationfunction nv3UpdateArbitrationSettingsfunction nv4CalcArbitrationfunction nv4UpdateArbitrationSettingsfunction nv10CalcArbitrationfunction nv10UpdateArbitrationSettingsfunction nForceUpdateArbitrationSettingsfunction CalcVClockfunction parametersfunction NV_WR32function LoadStateExtfunction UnloadStateExtfunction SetStartAddressfunction SetStartAddress3function nv3SetSurfaces2Dfunction nv4SetSurfaces2Dfunction nv10SetSurfaces2Dfunction nv3SetSurfaces3Dfunction nv4SetSurfaces3Dfunction nv10SetSurfaces3Dfunction nv3GetConfigfunction nv4GetConfigfunction nv10GetConfigfunction RivaGetConfig
Annotated Snippet
while(found != 1) {
fifo->valid = 1;
found = 1;
mclk_loop = mclks+mclk_extra;
us_m = mclk_loop *1000*1000 / mclk_freq; /* Mclk latency in us */
us_m_min = mclks * 1000*1000 / mclk_freq; /* Minimum Mclk latency in us */
us_min_mclk_extra = min_mclk_extra *1000*1000 / mclk_freq;
us_n = nvclks*1000*1000 / nvclk_freq;/* nvclk latency in us */
us_p = pclks*1000*1000 / pclk_freq;/* nvclk latency in us */
us_pipe_min = us_m_min + us_n + us_p;
vus_m = mclk_loop *1000*1000 / mclk_freq; /* Mclk latency in us */
if(video_enable) {
crtc_drain_rate = pclk_freq * bpp/8; /* MB/s */
vpagemiss = 1; /* self generating page miss */
vpagemiss += 1; /* One higher priority before */
crtpagemiss = 2; /* self generating page miss */
if(mp_enable)
crtpagemiss += 1; /* if MA0 conflict */
vpm_us = (vpagemiss * pagemiss)*1000*1000/mclk_freq;
us_video = vpm_us + vus_m; /* Video has separate read return path */
cpm_us = crtpagemiss * pagemiss *1000*1000/ mclk_freq;
us_crt =
us_video /* Wait for video */
+cpm_us /* CRT Page miss */
+us_m + us_n +us_p /* other latency */
;
clwm = us_crt * crtc_drain_rate/(1000*1000);
clwm++; /* fixed point <= float_point - 1. Fixes that */
} else {
crtc_drain_rate = pclk_freq * bpp/8; /* bpp * pclk/8 */
crtpagemiss = 1; /* self generating page miss */
crtpagemiss += 1; /* MA0 page miss */
if(mp_enable)
crtpagemiss += 1; /* if MA0 conflict */
cpm_us = crtpagemiss * pagemiss *1000*1000/ mclk_freq;
us_crt = cpm_us + us_m + us_n + us_p ;
clwm = us_crt * crtc_drain_rate/(1000*1000);
clwm++; /* fixed point <= float_point - 1. Fixes that */
/*
//
// Another concern, only for high pclks so don't do this
// with video:
// What happens if the latency to fetch the cbs is so large that
// fifo empties. In that case we need to have an alternate clwm value
// based off the total burst fetch
//
us_crt = (cbs * 1000 * 1000)/ (8*width)/mclk_freq ;
us_crt = us_crt + us_m + us_n + us_p + (4 * 1000 * 1000)/mclk_freq;
clwm_mt = us_crt * crtc_drain_rate/(1000*1000);
clwm_mt ++;
if(clwm_mt > clwm)
clwm = clwm_mt;
*/
/* Finally, a heuristic check when width == 64 bits */
if(width == 1){
nvclk_fill = nvclk_freq * 8;
if(crtc_drain_rate * 100 >= nvclk_fill * 102)
clwm = 0xfff; /*Large number to fail */
else if(crtc_drain_rate * 100 >= nvclk_fill * 98) {
clwm = 1024;
cbs = 512;
}
}
}
/*
Overfill check:
*/
clwm_rnd_down = ((int)clwm/8)*8;
if (clwm_rnd_down < clwm)
clwm += 8;
m1 = clwm + cbs - 1024; /* Amount of overfill */
m2us = us_pipe_min + us_min_mclk_extra;
/* pclk cycles to drain */
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/pci.h`, `linux/pci_ids.h`, `riva_hw.h`, `riva_tbl.h`, `nv_type.h`.
- Detected declarations: `function identically`, `function nv4Busy`, `function nv10Busy`, `function vgaLockUnlock`, `function nv3LockUnlock`, `function nv4LockUnlock`, `function ShowHideCursor`, `function nv3_iterate`, `function nv3_arb`, `function nv3_get_param`.
- 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.