drivers/gpu/drm/tests/drm_atomic_commit_test.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/tests/drm_atomic_commit_test.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/tests/drm_atomic_commit_test.c- Extension
.c- Size
- 10967 bytes
- Lines
- 410
- 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_kunit_helpers.hdrm/drm_probe_helper.h
Detected Declarations
struct drm_clone_mode_teststruct drm_atomic_test_privfunction drm_test_encoder_mode_setfunction drm_atomic_test_dummy_get_modesfunction drm_atomic_test_init_drm_componentsfunction set_up_atomic_statefunction mode_setfunction drm_crtc_in_clone_modefunction clonesfunction drm_check_in_clone_mode_descfunction drm_check_valid_clones_desc
Annotated Snippet
struct drm_clone_mode_test {
const char *name;
u32 encoder_mask;
int expected_result;
};
static const struct drm_display_mode drm_atomic_test_mode = {
DRM_MODE("1024x768", 0, 65000, 1024, 1048,
1184, 1344, 0, 768, 771, 777, 806, 0,
DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC)
};
struct drm_atomic_test_priv {
struct drm_device drm;
struct drm_plane *plane;
struct drm_crtc *crtc;
struct drm_encoder encoders[3];
struct drm_connector connectors[2];
};
static int modeset_counter;
static void drm_test_encoder_mode_set(struct drm_encoder *encoder,
struct drm_crtc_state *crtc_state,
struct drm_connector_state *conn_state)
{
modeset_counter++;
}
static const struct drm_encoder_helper_funcs drm_atomic_test_encoder_funcs = {
.atomic_mode_set = drm_test_encoder_mode_set,
};
static const struct drm_connector_funcs dummy_connector_funcs = {
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
.reset = drm_atomic_helper_connector_reset,
};
static int drm_atomic_test_dummy_get_modes(struct drm_connector *connector)
{
return drm_connector_helper_get_modes_fixed(connector,
&drm_atomic_test_mode);
}
static const struct drm_connector_helper_funcs dummy_connector_helper_funcs = {
.get_modes = drm_atomic_test_dummy_get_modes,
};
static struct drm_atomic_test_priv *
drm_atomic_test_init_drm_components(struct kunit *test, bool has_connectors)
{
struct drm_atomic_test_priv *priv;
struct drm_encoder *enc;
struct drm_connector *conn;
struct drm_device *drm;
struct device *dev;
int ret;
dev = drm_kunit_helper_alloc_device(test);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev);
priv = drm_kunit_helper_alloc_drm_device(test, dev,
struct drm_atomic_test_priv,
drm,
DRIVER_MODESET | DRIVER_ATOMIC);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv);
test->priv = priv;
drm = &priv->drm;
priv->plane = drm_kunit_helper_create_primary_plane(test, drm,
NULL,
NULL,
NULL, 0,
NULL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->plane);
priv->crtc = drm_kunit_helper_create_crtc(test, drm,
priv->plane, NULL,
NULL,
NULL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->crtc);
for (int i = 0; i < ARRAY_SIZE(priv->encoders); i++) {
enc = &priv->encoders[i];
ret = drmm_encoder_init(drm, enc, NULL,
DRM_MODE_ENCODER_DSI, NULL);
KUNIT_ASSERT_EQ(test, ret, 0);
Annotation
- Immediate include surface: `drm/drm_atomic.h`, `drm/drm_atomic_helper.h`, `drm/drm_atomic_uapi.h`, `drm/drm_kunit_helpers.h`, `drm/drm_probe_helper.h`.
- Detected declarations: `struct drm_clone_mode_test`, `struct drm_atomic_test_priv`, `function drm_test_encoder_mode_set`, `function drm_atomic_test_dummy_get_modes`, `function drm_atomic_test_init_drm_components`, `function set_up_atomic_state`, `function mode_set`, `function drm_crtc_in_clone_mode`, `function clones`, `function drm_check_in_clone_mode_desc`.
- 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.