drivers/gpu/drm/nouveau/dispnv04/crtc.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/nouveau/dispnv04/crtc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/nouveau/dispnv04/crtc.c- Extension
.c- Size
- 42285 bytes
- Lines
- 1335
- 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.
- 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
drm/drm_crtc_helper.hdrm/drm_fourcc.hdrm/drm_modeset_helper_vtables.hdrm/drm_plane_helper.hdrm/drm_vblank.hnouveau_drv.hnouveau_reg.hnouveau_ttm.hnouveau_bo.hnouveau_gem.hnouveau_encoder.hnouveau_connector.hnouveau_crtc.hhw.hnvreg.hdisp.hnouveau_dma.hsubdev/bios/pll.hsubdev/clk.hnvif/push006c.hnvif/event.hnvif/cl0046.h
Detected Declarations
struct rgbstruct nv04_page_flip_statefunction crtc_wr_cio_statefunction nv_crtc_set_digital_vibrancefunction nv_crtc_set_image_sharpeningfunction nv_crtc_calc_state_extfunction nv_crtc_dpmsfunction nv_crtc_mode_set_vgafunction list_for_each_entryfunction nv_crtc_mode_set_regsfunction list_for_each_entryfunction nv_crtc_swap_fbsfunction nv_crtc_mode_setfunction nv_crtc_savefunction nv_crtc_restorefunction nv_crtc_preparefunction nv_crtc_commitfunction nv_crtc_destroyfunction nv_crtc_gamma_loadfunction nv_crtc_disablefunction nv_crtc_gamma_setfunction mode_set_basefunction nv04_crtc_do_mode_set_basefunction nv04_crtc_mode_set_basefunction nv04_cursor_uploadfunction nv11_cursor_uploadfunction nv04_crtc_cursor_setfunction nv04_crtc_cursor_movefunction nv04_finish_page_flipfunction nv04_flip_completefunction nv04_page_flip_emitfunction nv04_crtc_page_flipfunction nv04_crtc_vblank_handlerfunction nv04_crtc_create
Annotated Snippet
struct rgb { uint8_t r, g, b; } __attribute__((packed)) *rgbs;
u16 *r, *g, *b;
int i;
rgbs = (struct rgb *)nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index].DAC;
r = crtc->gamma_store;
g = r + crtc->gamma_size;
b = g + crtc->gamma_size;
for (i = 0; i < 256; i++) {
rgbs[i].r = *r++ >> 8;
rgbs[i].g = *g++ >> 8;
rgbs[i].b = *b++ >> 8;
}
nouveau_hw_load_state_palette(dev, nv_crtc->index, &nv04_display(dev)->mode_reg);
}
static void
nv_crtc_disable(struct drm_crtc *crtc)
{
struct nv04_display *disp = nv04_display(crtc->dev);
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
if (disp->image[nv_crtc->index]) {
struct nouveau_bo *bo = disp->image[nv_crtc->index];
nouveau_bo_unpin(bo);
drm_gem_object_put(&bo->bo.base);
disp->image[nv_crtc->index] = NULL;
}
}
static int
nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
uint32_t size,
struct drm_modeset_acquire_ctx *ctx)
{
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
/* We need to know the depth before we upload, but it's possible to
* get called before a framebuffer is bound. If this is the case,
* mark the lut values as dirty by setting depth==0, and it'll be
* uploaded on the first mode_set_base()
*/
if (!nv_crtc->base.primary->fb) {
nv_crtc->lut.depth = 0;
return 0;
}
nv_crtc_gamma_load(crtc);
return 0;
}
static int
nv04_crtc_do_mode_set_base(struct drm_crtc *crtc,
struct drm_framebuffer *passed_fb,
int x, int y)
{
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct nouveau_drm *drm = nouveau_drm(dev);
struct nv04_crtc_reg *regp = &nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index];
struct nouveau_bo *nvbo;
struct drm_framebuffer *drm_fb;
int arb_burst, arb_lwm;
NV_DEBUG(drm, "index %d\n", nv_crtc->index);
/* no fb bound */
if (!crtc->primary->fb) {
NV_DEBUG(drm, "No FB bound\n");
return 0;
}
drm_fb = crtc->primary->fb;
nvbo = nouveau_gem_object(drm_fb->obj[0]);
nv_crtc->fb.offset = nvbo->offset;
if (nv_crtc->lut.depth != drm_fb->format->depth) {
nv_crtc->lut.depth = drm_fb->format->depth;
nv_crtc_gamma_load(crtc);
}
/* Update the framebuffer format. */
regp->CRTC[NV_CIO_CRE_PIXEL_INDEX] &= ~3;
regp->CRTC[NV_CIO_CRE_PIXEL_INDEX] |= (drm_fb->format->depth + 1) / 8;
regp->ramdac_gen_ctrl &= ~NV_PRAMDAC_GENERAL_CONTROL_ALT_MODE_SEL;
Annotation
- Immediate include surface: `drm/drm_crtc_helper.h`, `drm/drm_fourcc.h`, `drm/drm_modeset_helper_vtables.h`, `drm/drm_plane_helper.h`, `drm/drm_vblank.h`, `nouveau_drv.h`, `nouveau_reg.h`, `nouveau_ttm.h`.
- Detected declarations: `struct rgb`, `struct nv04_page_flip_state`, `function crtc_wr_cio_state`, `function nv_crtc_set_digital_vibrance`, `function nv_crtc_set_image_sharpening`, `function nv_crtc_calc_state_ext`, `function nv_crtc_dpms`, `function nv_crtc_mode_set_vga`, `function list_for_each_entry`, `function nv_crtc_mode_set_regs`.
- 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.
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.