drivers/gpu/drm/imx/dc/dc-plane.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/imx/dc/dc-plane.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/imx/dc/dc-plane.c- Extension
.c- Size
- 6093 bytes
- Lines
- 225
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/container_of.hdrm/drm_atomic.hdrm/drm_atomic_helper.hdrm/drm_atomic_state_helper.hdrm/drm_crtc.hdrm/drm_drv.hdrm/drm_fb_dma_helper.hdrm/drm_fourcc.hdrm/drm_framebuffer.hdrm/drm_gem_atomic_helper.hdrm/drm_plane_helper.hdrm/drm_print.hdc-drv.hdc-fu.hdc-kms.h
Detected Declarations
function dc_plane_check_max_source_resolutionfunction dc_plane_check_fbfunction dc_plane_atomic_checkfunction dc_plane_atomic_updatefunction dc_plane_atomic_disablefunction dc_plane_init
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2024 NXP
*/
#include <linux/container_of.h>
#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_atomic_state_helper.h>
#include <drm/drm_crtc.h>
#include <drm/drm_drv.h>
#include <drm/drm_fb_dma_helper.h>
#include <drm/drm_fourcc.h>
#include <drm/drm_framebuffer.h>
#include <drm/drm_gem_atomic_helper.h>
#include <drm/drm_plane_helper.h>
#include <drm/drm_print.h>
#include "dc-drv.h"
#include "dc-fu.h"
#include "dc-kms.h"
#define DC_PLANE_MAX_PITCH 0x10000
#define DC_PLANE_MAX_PIX_CNT 8192
#define dc_plane_dbg(plane, fmt, ...) \
do { \
struct drm_plane *_plane = (plane); \
drm_dbg_kms(_plane->dev, "[PLANE:%d:%s] " fmt, \
_plane->base.id, _plane->name, ##__VA_ARGS__); \
} while (0)
static const uint32_t dc_plane_formats[] = {
DRM_FORMAT_XRGB8888,
};
static const struct drm_plane_funcs dc_plane_funcs = {
.update_plane = drm_atomic_helper_update_plane,
.disable_plane = drm_atomic_helper_disable_plane,
.destroy = drm_plane_cleanup,
.reset = drm_atomic_helper_plane_reset,
.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
};
static inline struct dc_plane *to_dc_plane(struct drm_plane *plane)
{
return container_of(plane, struct dc_plane, base);
}
static int dc_plane_check_max_source_resolution(struct drm_plane_state *state)
{
int src_h = drm_rect_height(&state->src) >> 16;
int src_w = drm_rect_width(&state->src) >> 16;
if (src_w > DC_PLANE_MAX_PIX_CNT || src_h > DC_PLANE_MAX_PIX_CNT) {
dc_plane_dbg(state->plane, "invalid source resolution\n");
return -EINVAL;
}
return 0;
}
static int dc_plane_check_fb(struct drm_plane_state *state)
{
struct drm_framebuffer *fb = state->fb;
dma_addr_t baseaddr = drm_fb_dma_get_gem_addr(fb, state, 0);
/* base address alignment */
if (baseaddr & 0x3) {
dc_plane_dbg(state->plane, "fb bad baddr alignment\n");
return -EINVAL;
}
/* pitches[0] range */
if (fb->pitches[0] > DC_PLANE_MAX_PITCH) {
dc_plane_dbg(state->plane, "fb pitches[0] is out of range\n");
return -EINVAL;
}
/* pitches[0] alignment */
if (fb->pitches[0] & 0x3) {
dc_plane_dbg(state->plane, "fb bad pitches[0] alignment\n");
return -EINVAL;
}
return 0;
}
Annotation
- Immediate include surface: `linux/container_of.h`, `drm/drm_atomic.h`, `drm/drm_atomic_helper.h`, `drm/drm_atomic_state_helper.h`, `drm/drm_crtc.h`, `drm/drm_drv.h`, `drm/drm_fb_dma_helper.h`, `drm/drm_fourcc.h`.
- Detected declarations: `function dc_plane_check_max_source_resolution`, `function dc_plane_check_fb`, `function dc_plane_atomic_check`, `function dc_plane_atomic_update`, `function dc_plane_atomic_disable`, `function dc_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.