drivers/gpu/drm/tilcdc/tilcdc_crtc.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/tilcdc/tilcdc_crtc.c- Extension
.c- Size
- 27891 bytes
- Lines
- 1010
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/dma-mapping.hlinux/of_graph.hlinux/pm_runtime.hdrm/drm_atomic.hdrm/drm_atomic_helper.hdrm/drm_crtc.hdrm/drm_fb_dma_helper.hdrm/drm_fourcc.hdrm/drm_framebuffer.hdrm/drm_gem_dma_helper.hdrm/drm_managed.hdrm/drm_modeset_helper_vtables.hdrm/drm_print.hdrm/drm_vblank.htilcdc_drv.htilcdc_regs.h
Detected Declarations
struct tilcdc_crtcfunction set_scanoutfunction tilcdc_crtc_load_palettefunction tilcdc_crtc_enable_irqsfunction tilcdc_crtc_disable_irqsfunction resetfunction tilcdc_pclk_difffunction tilcdc_crtc_set_clkfunction ratefunction tilcdc_mode_hvtotalfunction tilcdc_crtc_set_modefunction tilcdc_crtc_enablefunction tilcdc_crtc_atomic_enablefunction tilcdc_crtc_offfunction tilcdc_crtc_disablefunction tilcdc_crtc_atomic_disablefunction tilcdc_crtc_atomic_flushfunction tilcdc_crtc_shutdownfunction tilcdc_crtc_is_onfunction tilcdc_crtc_recover_workfunction tilcdc_crtc_destroyfunction tilcdc_crtc_update_fbfunction tilcdc_crtc_mode_fixupfunction tilcdc_crtc_atomic_checkfunction tilcdc_crtc_enable_vblankfunction tilcdc_crtc_disable_vblankfunction tilcdc_crtc_resetfunction tilcdc_crtc_mode_validfunction tilcdc_crtc_update_clkfunction tilcdc_crtc_irqfunction tilcdc_crtc_create
Annotated Snippet
struct tilcdc_crtc {
struct drm_crtc base;
struct tilcdc_plane *primary;
struct drm_pending_vblank_event *event;
struct mutex enable_lock;
bool enabled;
bool shutdown;
wait_queue_head_t frame_done_wq;
bool frame_done;
spinlock_t irq_lock;
unsigned int lcd_fck_rate;
ktime_t last_vblank;
unsigned int hvtotal_us;
struct drm_framebuffer *next_fb;
int sync_lost_count;
bool frame_intact;
struct work_struct recover_work;
dma_addr_t palette_dma_handle;
u16 *palette_base;
struct completion palette_loaded;
};
#define to_tilcdc_crtc(x) container_of(x, struct tilcdc_crtc, base)
static void set_scanout(struct drm_crtc *crtc, struct drm_framebuffer *fb)
{
struct drm_device *dev = crtc->dev;
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
struct drm_gem_dma_object *gem;
dma_addr_t start, end;
u64 dma_base_and_ceiling;
gem = drm_fb_dma_get_gem_obj(fb, 0);
start = gem->dma_addr + fb->offsets[0] +
crtc->y * fb->pitches[0] +
crtc->x * fb->format->cpp[0];
end = start + (crtc->mode.vdisplay * fb->pitches[0]);
/* Write LCDC_DMA_FB_BASE_ADDR_0_REG and LCDC_DMA_FB_CEILING_ADDR_0_REG
* with a single insruction, if available. This should make it more
* unlikely that LCDC would fetch the DMA addresses in the middle of
* an update.
*/
if (priv->rev == 1)
end -= 1;
dma_base_and_ceiling = (u64)end << 32 | start;
tilcdc_write64(dev, LCDC_DMA_FB_BASE_ADDR_0_REG, dma_base_and_ceiling);
}
/*
* The driver currently only supports only true color formats. For
* true color the palette block is bypassed, but a 32 byte palette
* should still be loaded. The first 16-bit entry must be 0x4000 while
* all other entries must be zeroed.
*/
static void tilcdc_crtc_load_palette(struct drm_crtc *crtc)
{
struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
int ret;
reinit_completion(&tilcdc_crtc->palette_loaded);
/* Tell the LCDC where the palette is located. */
tilcdc_write(dev, LCDC_DMA_FB_BASE_ADDR_0_REG,
tilcdc_crtc->palette_dma_handle);
tilcdc_write(dev, LCDC_DMA_FB_CEILING_ADDR_0_REG,
(u32) tilcdc_crtc->palette_dma_handle +
TILCDC_PALETTE_SIZE - 1);
/* Set dma load mode for palette loading only. */
tilcdc_write_mask(dev, LCDC_RASTER_CTRL_REG,
LCDC_PALETTE_LOAD_MODE(PALETTE_ONLY),
LCDC_PALETTE_LOAD_MODE_MASK);
/* Enable DMA Palette Loaded Interrupt */
if (priv->rev == 1)
tilcdc_set(dev, LCDC_RASTER_CTRL_REG, LCDC_V1_PL_INT_ENA);
else
tilcdc_write(dev, LCDC_INT_ENABLE_SET_REG, LCDC_V2_PL_INT_ENA);
Annotation
- Immediate include surface: `linux/delay.h`, `linux/dma-mapping.h`, `linux/of_graph.h`, `linux/pm_runtime.h`, `drm/drm_atomic.h`, `drm/drm_atomic_helper.h`, `drm/drm_crtc.h`, `drm/drm_fb_dma_helper.h`.
- Detected declarations: `struct tilcdc_crtc`, `function set_scanout`, `function tilcdc_crtc_load_palette`, `function tilcdc_crtc_enable_irqs`, `function tilcdc_crtc_disable_irqs`, `function reset`, `function tilcdc_pclk_diff`, `function tilcdc_crtc_set_clk`, `function rate`, `function tilcdc_mode_hvtotal`.
- 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.