drivers/gpu/drm/tests/drm_atomic_test.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/tests/drm_atomic_test.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/tests/drm_atomic_test.c- Extension
.c- Size
- 4002 bytes
- Lines
- 154
- 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
drm/drm_atomic.hdrm/drm_atomic_state_helper.hdrm/drm_atomic_uapi.hdrm/drm_encoder.hdrm/drm_kunit_helpers.hdrm/drm_modeset_helper_vtables.hkunit/test.h
Detected Declarations
struct drm_atomic_test_privfunction drm_test_drm_atomic_get_connector_for_encoder
Annotated Snippet
struct drm_atomic_test_priv {
struct drm_device drm;
struct drm_plane *plane;
struct drm_crtc *crtc;
struct drm_encoder encoder;
struct drm_connector connector;
};
static const struct drm_connector_helper_funcs drm_atomic_init_connector_helper_funcs = {
};
static const struct drm_connector_funcs drm_atomic_init_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 struct drm_atomic_test_priv *create_device(struct kunit *test)
{
struct drm_atomic_test_priv *priv;
struct drm_connector *connector;
struct drm_encoder *enc;
struct drm_device *drm;
struct drm_plane *plane;
struct drm_crtc *crtc;
struct device *dev;
int ret;
dev = drm_kunit_helper_alloc_device(test);
if (IS_ERR(dev))
return ERR_CAST(dev);
priv = drm_kunit_helper_alloc_drm_device(test, dev,
struct drm_atomic_test_priv, drm,
DRIVER_MODESET | DRIVER_ATOMIC);
if (IS_ERR(priv))
return ERR_CAST(priv);
drm = &priv->drm;
plane = drm_kunit_helper_create_primary_plane(test, drm,
NULL,
NULL,
NULL, 0,
NULL);
if (IS_ERR(plane))
return ERR_CAST(plane);
priv->plane = plane;
crtc = drm_kunit_helper_create_crtc(test, drm,
plane, NULL,
NULL,
NULL);
if (IS_ERR(crtc))
return ERR_CAST(crtc);
priv->crtc = crtc;
enc = &priv->encoder;
ret = drmm_encoder_init(drm, enc, NULL, DRM_MODE_ENCODER_TMDS, NULL);
if (ret)
return ERR_PTR(ret);
enc->possible_crtcs = drm_crtc_mask(crtc);
connector = &priv->connector;
ret = drmm_connector_init(drm, connector,
&drm_atomic_init_connector_funcs,
DRM_MODE_CONNECTOR_VIRTUAL,
NULL);
if (ret)
return ERR_PTR(ret);
drm_connector_helper_add(connector, &drm_atomic_init_connector_helper_funcs);
drm_connector_attach_encoder(connector, enc);
drm_mode_config_reset(drm);
return priv;
}
static void drm_test_drm_atomic_get_connector_for_encoder(struct kunit *test)
{
struct drm_modeset_acquire_ctx ctx;
struct drm_atomic_test_priv *priv;
struct drm_display_mode *mode;
struct drm_connector *curr_connector;
int ret;
priv = create_device(test);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv);
Annotation
- Immediate include surface: `drm/drm_atomic.h`, `drm/drm_atomic_state_helper.h`, `drm/drm_atomic_uapi.h`, `drm/drm_encoder.h`, `drm/drm_kunit_helpers.h`, `drm/drm_modeset_helper_vtables.h`, `kunit/test.h`.
- Detected declarations: `struct drm_atomic_test_priv`, `function drm_test_drm_atomic_get_connector_for_encoder`.
- 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.