drivers/gpu/drm/tests/drm_client_modeset_test.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/tests/drm_client_modeset_test.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/tests/drm_client_modeset_test.c- Extension
.c- Size
- 5852 bytes
- Lines
- 204
- 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
kunit/test.hdrm/drm_atomic_state_helper.hdrm/drm_connector.hdrm/drm_edid.hdrm/drm_drv.hdrm/drm_kunit_helpers.hdrm/drm_modes.hdrm/drm_modeset_helper_vtables.hdrm/drm_probe_helper.h
Detected Declarations
struct drm_client_modeset_test_privstruct drm_connector_pick_cmdline_mode_testfunction drm_client_modeset_connector_get_modesfunction drm_client_modeset_test_initfunction drm_test_pick_cmdline_res_1920_1080_60function drm_test_pick_cmdline_namedfunction drm_connector_pick_cmdline_mode_desc
Annotated Snippet
struct drm_client_modeset_test_priv {
struct drm_device *drm;
struct device *dev;
struct drm_connector connector;
};
static int drm_client_modeset_connector_get_modes(struct drm_connector *connector)
{
struct drm_display_mode *mode;
int count;
count = drm_add_modes_noedid(connector, 1920, 1200);
mode = drm_mode_analog_ntsc_480i(connector->dev);
if (!mode)
return count;
drm_mode_probed_add(connector, mode);
count += 1;
mode = drm_mode_analog_pal_576i(connector->dev);
if (!mode)
return count;
drm_mode_probed_add(connector, mode);
count += 1;
return count;
}
static const struct drm_connector_helper_funcs drm_client_modeset_connector_helper_funcs = {
.get_modes = drm_client_modeset_connector_get_modes,
};
static const struct drm_connector_funcs drm_client_modeset_connector_funcs = {
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state
};
static int drm_client_modeset_test_init(struct kunit *test)
{
struct drm_client_modeset_test_priv *priv;
int ret;
priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, priv);
test->priv = priv;
priv->dev = drm_kunit_helper_alloc_device(test);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->dev);
priv->drm = __drm_kunit_helper_alloc_drm_device(test, priv->dev,
sizeof(*priv->drm), 0,
DRIVER_MODESET);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->drm);
ret = drmm_connector_init(priv->drm, &priv->connector,
&drm_client_modeset_connector_funcs,
DRM_MODE_CONNECTOR_Unknown,
NULL);
KUNIT_ASSERT_EQ(test, ret, 0);
drm_connector_helper_add(&priv->connector, &drm_client_modeset_connector_helper_funcs);
priv->connector.interlace_allowed = true;
priv->connector.doublescan_allowed = true;
return 0;
}
static void drm_test_pick_cmdline_res_1920_1080_60(struct kunit *test)
{
struct drm_client_modeset_test_priv *priv = test->priv;
struct drm_device *drm = priv->drm;
struct drm_connector *connector = &priv->connector;
struct drm_cmdline_mode *cmdline_mode = &connector->cmdline_mode;
struct drm_display_mode *expected_mode;
const struct drm_display_mode *mode;
const char *cmdline = "1920x1080@60";
int ret;
expected_mode = drm_mode_find_dmt(priv->drm, 1920, 1080, 60, false);
KUNIT_ASSERT_NOT_NULL(test, expected_mode);
ret = drm_kunit_add_mode_destroy_action(test, expected_mode);
KUNIT_ASSERT_EQ(test, ret, 0);
KUNIT_ASSERT_TRUE(test,
drm_mode_parse_command_line_for_connector(cmdline,
Annotation
- Immediate include surface: `kunit/test.h`, `drm/drm_atomic_state_helper.h`, `drm/drm_connector.h`, `drm/drm_edid.h`, `drm/drm_drv.h`, `drm/drm_kunit_helpers.h`, `drm/drm_modes.h`, `drm/drm_modeset_helper_vtables.h`.
- Detected declarations: `struct drm_client_modeset_test_priv`, `struct drm_connector_pick_cmdline_mode_test`, `function drm_client_modeset_connector_get_modes`, `function drm_client_modeset_test_init`, `function drm_test_pick_cmdline_res_1920_1080_60`, `function drm_test_pick_cmdline_named`, `function drm_connector_pick_cmdline_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.