drivers/gpu/drm/drm_simple_kms_helper.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_simple_kms_helper.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_simple_kms_helper.c- Extension
.c- Size
- 11135 bytes
- Lines
- 376
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/export.hlinux/module.hlinux/slab.hdrm/drm_atomic.hdrm/drm_atomic_helper.hdrm/drm_bridge.hdrm/drm_drv.hdrm/drm_gem_atomic_helper.hdrm/drm_managed.hdrm/drm_probe_helper.hdrm/drm_simple_kms_helper.h
Detected Declarations
function drm_simple_encoder_initfunction drm_simple_kms_crtc_mode_validfunction drm_simple_kms_crtc_checkfunction drm_simple_kms_crtc_enablefunction drm_simple_kms_crtc_disablefunction drm_simple_kms_crtc_resetfunction drm_simple_kms_crtc_destroy_statefunction drm_simple_kms_crtc_enable_vblankfunction drm_simple_kms_crtc_disable_vblankfunction drm_simple_kms_plane_atomic_checkfunction drm_simple_kms_plane_atomic_updatefunction drm_simple_kms_plane_prepare_fbfunction drm_simple_kms_plane_cleanup_fbfunction drm_simple_kms_plane_begin_fb_accessfunction drm_simple_kms_plane_end_fb_accessfunction drm_simple_kms_format_mod_supportedfunction drm_simple_kms_plane_resetfunction drm_simple_kms_plane_destroy_statefunction drm_simple_display_pipe_attach_bridgefunction drm_simple_display_pipe_initexport drm_simple_encoder_initexport __drmm_simple_encoder_allocexport drm_simple_display_pipe_attach_bridgeexport drm_simple_display_pipe_init
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2016 Noralf Trønnes
*/
#include <linux/export.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_bridge.h>
#include <drm/drm_drv.h>
#include <drm/drm_gem_atomic_helper.h>
#include <drm/drm_managed.h>
#include <drm/drm_probe_helper.h>
#include <drm/drm_simple_kms_helper.h>
static const struct drm_encoder_funcs drm_simple_encoder_funcs_cleanup = {
.destroy = drm_encoder_cleanup,
};
int drm_simple_encoder_init(struct drm_device *dev,
struct drm_encoder *encoder,
int encoder_type)
{
return drm_encoder_init(dev, encoder,
&drm_simple_encoder_funcs_cleanup,
encoder_type, NULL);
}
EXPORT_SYMBOL(drm_simple_encoder_init);
void *__drmm_simple_encoder_alloc(struct drm_device *dev, size_t size,
size_t offset, int encoder_type)
{
return __drmm_encoder_alloc(dev, size, offset, NULL, encoder_type,
NULL);
}
EXPORT_SYMBOL(__drmm_simple_encoder_alloc);
static enum drm_mode_status
drm_simple_kms_crtc_mode_valid(struct drm_crtc *crtc,
const struct drm_display_mode *mode)
{
struct drm_simple_display_pipe *pipe;
pipe = container_of(crtc, struct drm_simple_display_pipe, crtc);
if (!pipe->funcs || !pipe->funcs->mode_valid)
/* Anything goes */
return MODE_OK;
return pipe->funcs->mode_valid(pipe, mode);
}
static int drm_simple_kms_crtc_check(struct drm_crtc *crtc,
struct drm_atomic_commit *state)
{
struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
int ret;
if (!crtc_state->enable)
goto out;
ret = drm_atomic_helper_check_crtc_primary_plane(crtc_state);
if (ret)
return ret;
out:
return drm_atomic_add_affected_planes(state, crtc);
}
static void drm_simple_kms_crtc_enable(struct drm_crtc *crtc,
struct drm_atomic_commit *state)
{
struct drm_plane *plane;
struct drm_simple_display_pipe *pipe;
pipe = container_of(crtc, struct drm_simple_display_pipe, crtc);
if (!pipe->funcs || !pipe->funcs->enable)
return;
plane = &pipe->plane;
pipe->funcs->enable(pipe, crtc->state, plane->state);
}
static void drm_simple_kms_crtc_disable(struct drm_crtc *crtc,
struct drm_atomic_commit *state)
{
struct drm_simple_display_pipe *pipe;
Annotation
- Immediate include surface: `linux/export.h`, `linux/module.h`, `linux/slab.h`, `drm/drm_atomic.h`, `drm/drm_atomic_helper.h`, `drm/drm_bridge.h`, `drm/drm_drv.h`, `drm/drm_gem_atomic_helper.h`.
- Detected declarations: `function drm_simple_encoder_init`, `function drm_simple_kms_crtc_mode_valid`, `function drm_simple_kms_crtc_check`, `function drm_simple_kms_crtc_enable`, `function drm_simple_kms_crtc_disable`, `function drm_simple_kms_crtc_reset`, `function drm_simple_kms_crtc_destroy_state`, `function drm_simple_kms_crtc_enable_vblank`, `function drm_simple_kms_crtc_disable_vblank`, `function drm_simple_kms_plane_atomic_check`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: integration 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.