drivers/gpu/drm/mediatek/mtk_plane.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/mediatek/mtk_plane.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/mediatek/mtk_plane.c- Extension
.c- Size
- 11217 bytes
- Lines
- 368
- 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_atomic.hdrm/drm_atomic_helper.hdrm/drm_atomic_uapi.hdrm/drm_blend.hdrm/drm_fourcc.hdrm/drm_framebuffer.hdrm/drm_gem_atomic_helper.hdrm/drm_gem_dma_helper.hdrm/drm_print.hlinux/align.hmtk_crtc.hmtk_ddp_comp.hmtk_drm_drv.hmtk_plane.h
Detected Declarations
function mtk_plane_resetfunction mtk_plane_format_mod_supportedfunction mtk_plane_destroy_statefunction mtk_plane_atomic_async_checkfunction mtk_plane_update_new_statefunction mtk_plane_atomic_async_updatefunction mtk_plane_atomic_checkfunction mtk_plane_atomic_disablefunction mtk_plane_atomic_updatefunction mtk_plane_init
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2015 MediaTek Inc.
* Author: CK Hu <ck.hu@mediatek.com>
*/
#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_atomic_uapi.h>
#include <drm/drm_blend.h>
#include <drm/drm_fourcc.h>
#include <drm/drm_framebuffer.h>
#include <drm/drm_gem_atomic_helper.h>
#include <drm/drm_gem_dma_helper.h>
#include <drm/drm_print.h>
#include <linux/align.h>
#include "mtk_crtc.h"
#include "mtk_ddp_comp.h"
#include "mtk_drm_drv.h"
#include "mtk_plane.h"
static const u64 modifiers[] = {
DRM_FORMAT_MOD_LINEAR,
DRM_FORMAT_MOD_INVALID,
};
static void mtk_plane_reset(struct drm_plane *plane)
{
struct mtk_plane_state *state;
if (plane->state) {
__drm_atomic_helper_plane_destroy_state(plane->state);
state = to_mtk_plane_state(plane->state);
memset(state, 0, sizeof(*state));
} else {
state = kzalloc_obj(*state);
if (!state)
return;
}
__drm_atomic_helper_plane_reset(plane, &state->base);
state->base.plane = plane;
state->pending.format = DRM_FORMAT_RGB565;
state->pending.modifier = DRM_FORMAT_MOD_LINEAR;
}
static struct drm_plane_state *mtk_plane_duplicate_state(struct drm_plane *plane)
{
struct mtk_plane_state *old_state = to_mtk_plane_state(plane->state);
struct mtk_plane_state *state;
state = kmalloc_obj(*state);
if (!state)
return NULL;
__drm_atomic_helper_plane_duplicate_state(plane, &state->base);
WARN_ON(state->base.plane != plane);
state->pending = old_state->pending;
return &state->base;
}
static bool mtk_plane_format_mod_supported(struct drm_plane *plane,
uint32_t format,
uint64_t modifier)
{
return modifier == DRM_FORMAT_MOD_LINEAR;
}
static void mtk_plane_destroy_state(struct drm_plane *plane,
struct drm_plane_state *state)
{
__drm_atomic_helper_plane_destroy_state(state);
kfree(to_mtk_plane_state(state));
}
static int mtk_plane_atomic_async_check(struct drm_plane *plane,
struct drm_atomic_commit *state, bool flip)
{
struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
plane);
struct drm_crtc_state *crtc_state;
int ret;
if (plane != new_plane_state->crtc->cursor)
Annotation
- Immediate include surface: `drm/drm_atomic.h`, `drm/drm_atomic_helper.h`, `drm/drm_atomic_uapi.h`, `drm/drm_blend.h`, `drm/drm_fourcc.h`, `drm/drm_framebuffer.h`, `drm/drm_gem_atomic_helper.h`, `drm/drm_gem_dma_helper.h`.
- Detected declarations: `function mtk_plane_reset`, `function mtk_plane_format_mod_supported`, `function mtk_plane_destroy_state`, `function mtk_plane_atomic_async_check`, `function mtk_plane_update_new_state`, `function mtk_plane_atomic_async_update`, `function mtk_plane_atomic_check`, `function mtk_plane_atomic_disable`, `function mtk_plane_atomic_update`, `function mtk_plane_init`.
- 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.