drivers/gpu/drm/mediatek/mtk_crtc.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/mediatek/mtk_crtc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/mediatek/mtk_crtc.c- Extension
.c- Size
- 32789 bytes
- Lines
- 1189
- 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
linux/clk.hlinux/dma-mapping.hlinux/mailbox_controller.hlinux/of.hlinux/pm_runtime.hlinux/soc/mediatek/mtk-cmdq.hlinux/soc/mediatek/mtk-mmsys.hlinux/soc/mediatek/mtk-mutex.hasm/barrier.hdrm/drm_atomic.hdrm/drm_atomic_helper.hdrm/drm_print.hdrm/drm_probe_helper.hdrm/drm_vblank.hmtk_crtc.hmtk_ddp_comp.hmtk_drm_drv.hmtk_plane.h
Detected Declarations
struct mtk_crtcstruct mtk_crtc_statefunction mtk_crtc_finish_page_flipfunction mtk_drm_finish_page_flipfunction mtk_crtc_destroyfunction mtk_crtc_resetfunction mtk_crtc_destroy_statefunction mtk_crtc_mode_validfunction mtk_crtc_mode_fixupfunction mtk_crtc_mode_set_nofbfunction mtk_crtc_ddp_clk_enablefunction mtk_crtc_ddp_clk_disablefunction ddp_cmdq_cbfunction mtk_crtc_ddp_hw_initfunction drm_for_each_encoderfunction drm_for_each_connector_iterfunction mtk_crtc_ddp_hw_finifunction mtk_crtc_ddp_configfunction mtk_crtc_update_configfunction mtk_crtc_ddp_irqfunction mtk_crtc_enable_vblankfunction mtk_crtc_disable_vblankfunction mtk_crtc_update_outputfunction mtk_crtc_plane_checkfunction mtk_crtc_plane_disablefunction mtk_crtc_async_updatefunction mtk_crtc_atomic_enablefunction mtk_crtc_atomic_disablefunction mtk_crtc_atomic_beginfunction mtk_crtc_atomic_flushfunction mtk_crtc_initfunction mtk_crtc_num_comp_planesfunction mtk_crtc_plane_typefunction mtk_crtc_init_comp_planesfunction mtk_crtc_create
Annotated Snippet
struct mtk_crtc {
struct drm_crtc base;
bool enabled;
bool pending_needs_vblank;
struct drm_pending_vblank_event *event;
struct drm_plane *planes;
unsigned int layer_nr;
bool pending_planes;
bool pending_async_planes;
#if IS_REACHABLE(CONFIG_MTK_CMDQ)
struct cmdq_client cmdq_client;
struct cmdq_pkt cmdq_handle;
u32 cmdq_event;
u32 cmdq_vblank_cnt;
wait_queue_head_t cb_blocking_queue;
#endif
struct device *mmsys_dev;
struct device *dma_dev;
struct mtk_mutex *mutex;
unsigned int ddp_comp_nr;
unsigned int num_conn_routes;
const struct mtk_drm_route *conn_routes;
/* lock for display hardware access */
struct mutex hw_lock;
bool config_updating;
/* lock for config_updating to cmd buffer */
spinlock_t config_lock;
struct mtk_ddp_comp *ddp_comp[];
};
struct mtk_crtc_state {
struct drm_crtc_state base;
bool pending_config;
unsigned int pending_width;
unsigned int pending_height;
unsigned int pending_vrefresh;
};
static inline struct mtk_crtc *to_mtk_crtc(struct drm_crtc *c)
{
return container_of(c, struct mtk_crtc, base);
}
static inline struct mtk_crtc_state *to_mtk_crtc_state(struct drm_crtc_state *s)
{
return container_of(s, struct mtk_crtc_state, base);
}
static void mtk_crtc_finish_page_flip(struct mtk_crtc *mtk_crtc)
{
struct drm_crtc *crtc = &mtk_crtc->base;
unsigned long flags;
if (mtk_crtc->event) {
spin_lock_irqsave(&crtc->dev->event_lock, flags);
drm_crtc_send_vblank_event(crtc, mtk_crtc->event);
drm_crtc_vblank_put(crtc);
mtk_crtc->event = NULL;
spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
}
}
static void mtk_drm_finish_page_flip(struct mtk_crtc *mtk_crtc)
{
unsigned long flags;
drm_crtc_handle_vblank(&mtk_crtc->base);
#if IS_REACHABLE(CONFIG_MTK_CMDQ)
if (mtk_crtc->cmdq_client.chan)
return;
#endif
spin_lock_irqsave(&mtk_crtc->config_lock, flags);
if (!mtk_crtc->config_updating && mtk_crtc->pending_needs_vblank) {
mtk_crtc_finish_page_flip(mtk_crtc);
mtk_crtc->pending_needs_vblank = false;
}
spin_unlock_irqrestore(&mtk_crtc->config_lock, flags);
}
static void mtk_crtc_destroy(struct drm_crtc *crtc)
{
Annotation
- Immediate include surface: `linux/clk.h`, `linux/dma-mapping.h`, `linux/mailbox_controller.h`, `linux/of.h`, `linux/pm_runtime.h`, `linux/soc/mediatek/mtk-cmdq.h`, `linux/soc/mediatek/mtk-mmsys.h`, `linux/soc/mediatek/mtk-mutex.h`.
- Detected declarations: `struct mtk_crtc`, `struct mtk_crtc_state`, `function mtk_crtc_finish_page_flip`, `function mtk_drm_finish_page_flip`, `function mtk_crtc_destroy`, `function mtk_crtc_reset`, `function mtk_crtc_destroy_state`, `function mtk_crtc_mode_valid`, `function mtk_crtc_mode_fixup`, `function mtk_crtc_mode_set_nofb`.
- 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.