drivers/gpu/drm/vc4/tests/vc4_mock_output.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/vc4/tests/vc4_mock_output.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/vc4/tests/vc4_mock_output.c- Extension
.c- Size
- 4739 bytes
- Lines
- 177
- 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_state_helper.hdrm/drm_atomic_uapi.hdrm/drm_connector.hdrm/drm_crtc.hdrm/drm_encoder.hdrm/drm_modeset_helper_vtables.hkunit/test.hvc4_mock.h
Detected Declarations
function vc4_mock_atomic_add_outputfunction vc4_mock_atomic_del_output
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#include <drm/drm_atomic_state_helper.h>
#include <drm/drm_atomic_uapi.h>
#include <drm/drm_connector.h>
#include <drm/drm_crtc.h>
#include <drm/drm_encoder.h>
#include <drm/drm_modeset_helper_vtables.h>
#include <kunit/test.h>
#include "vc4_mock.h"
static const struct drm_connector_helper_funcs vc4_dummy_connector_helper_funcs = {
};
static const struct drm_connector_funcs vc4_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,
};
struct vc4_dummy_output *vc4_dummy_output(struct kunit *test,
struct drm_device *drm,
struct drm_crtc *crtc,
enum vc4_encoder_type vc4_encoder_type,
unsigned int kms_encoder_type,
unsigned int connector_type)
{
struct vc4_dummy_output *dummy_output;
struct drm_connector *conn;
struct drm_encoder *enc;
int ret;
dummy_output = drmm_kzalloc(drm, sizeof(*dummy_output), GFP_KERNEL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dummy_output);
dummy_output->encoder.type = vc4_encoder_type;
enc = &dummy_output->encoder.base;
ret = drmm_encoder_init(drm, enc,
NULL,
kms_encoder_type,
NULL);
KUNIT_ASSERT_EQ(test, ret, 0);
enc->possible_crtcs = drm_crtc_mask(crtc);
conn = &dummy_output->connector;
ret = drmm_connector_init(drm, conn,
&vc4_dummy_connector_funcs,
connector_type,
NULL);
KUNIT_ASSERT_EQ(test, ret, 0);
drm_connector_helper_add(conn, &vc4_dummy_connector_helper_funcs);
drm_connector_attach_encoder(conn, enc);
return dummy_output;
}
static const struct drm_display_mode default_mode = {
DRM_SIMPLE_MODE(640, 480, 64, 48)
};
/**
* vc4_mock_atomic_add_output() - Enables an output in a state
* @test: The test context object
* @state: Atomic state to enable the output in.
* @type: Type of the output encoder
*
* Adds an output CRTC and connector to a state, and enables them.
*
* Returns:
* 0 on success, a negative error code on failure. If the error is
* EDEADLK, the entire atomic sequence must be restarted. All other
* errors are fatal.
*/
int vc4_mock_atomic_add_output(struct kunit *test,
struct drm_atomic_commit *state,
enum vc4_encoder_type type)
{
struct drm_device *drm = state->dev;
struct drm_connector_state *conn_state;
struct drm_crtc_state *crtc_state;
struct vc4_dummy_output *output;
struct drm_connector *conn;
struct drm_encoder *encoder;
struct drm_crtc *crtc;
int ret;
encoder = vc4_find_encoder_by_type(drm, type);
Annotation
- Immediate include surface: `drm/drm_atomic_state_helper.h`, `drm/drm_atomic_uapi.h`, `drm/drm_connector.h`, `drm/drm_crtc.h`, `drm/drm_encoder.h`, `drm/drm_modeset_helper_vtables.h`, `kunit/test.h`, `vc4_mock.h`.
- Detected declarations: `function vc4_mock_atomic_add_output`, `function vc4_mock_atomic_del_output`.
- 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.