drivers/gpu/drm/tests/drm_modes_test.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/tests/drm_modes_test.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/tests/drm_modes_test.c- Extension
.c- Size
- 5640 bytes
- Lines
- 209
- 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.
- 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_drv.hdrm/drm_kunit_helpers.hdrm/drm_modes.hkunit/test.hlinux/units.h
Detected Declarations
struct drm_test_modes_privfunction drm_test_modes_initfunction drm_test_modes_analog_tv_ntsc_480ifunction drm_test_modes_analog_tv_ntsc_480i_inlinedfunction drm_test_modes_analog_tv_pal_576ifunction drm_test_modes_analog_tv_pal_576i_inlinedfunction drm_test_modes_analog_tv_mono_576i
Annotated Snippet
struct drm_test_modes_priv {
struct drm_device *drm;
struct device *dev;
};
static int drm_test_modes_init(struct kunit *test)
{
struct drm_test_modes_priv *priv;
priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, 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);
test->priv = priv;
return 0;
}
static void drm_test_modes_analog_tv_ntsc_480i(struct kunit *test)
{
struct drm_test_modes_priv *priv = test->priv;
struct drm_display_mode *mode;
int ret;
mode = drm_analog_tv_mode(priv->drm,
DRM_MODE_TV_MODE_NTSC,
13500 * HZ_PER_KHZ, 720, 480,
true);
KUNIT_ASSERT_NOT_NULL(test, mode);
ret = drm_kunit_add_mode_destroy_action(test, mode);
KUNIT_ASSERT_EQ(test, ret, 0);
KUNIT_EXPECT_EQ(test, drm_mode_vrefresh(mode), 60);
KUNIT_EXPECT_EQ(test, mode->hdisplay, 720);
/* BT.601 defines hsync_start at 736 for 480i */
KUNIT_EXPECT_EQ(test, mode->hsync_start, 736);
/*
* The NTSC standard expects a line to take 63.556us. With a
* pixel clock of 13.5 MHz, a pixel takes around 74ns, so we
* need to have 63556ns / 74ns = 858.
*
* This is also mandated by BT.601.
*/
KUNIT_EXPECT_EQ(test, mode->htotal, 858);
KUNIT_EXPECT_EQ(test, mode->vdisplay, 480);
KUNIT_EXPECT_EQ(test, mode->vtotal, 525);
}
static void drm_test_modes_analog_tv_ntsc_480i_inlined(struct kunit *test)
{
struct drm_test_modes_priv *priv = test->priv;
struct drm_display_mode *expected, *mode;
int ret;
expected = drm_analog_tv_mode(priv->drm,
DRM_MODE_TV_MODE_NTSC,
13500 * HZ_PER_KHZ, 720, 480,
true);
KUNIT_ASSERT_NOT_NULL(test, expected);
ret = drm_kunit_add_mode_destroy_action(test, expected);
KUNIT_ASSERT_EQ(test, ret, 0);
mode = drm_mode_analog_ntsc_480i(priv->drm);
KUNIT_ASSERT_NOT_NULL(test, mode);
ret = drm_kunit_add_mode_destroy_action(test, mode);
KUNIT_ASSERT_EQ(test, ret, 0);
KUNIT_EXPECT_TRUE(test, drm_mode_equal(expected, mode));
}
static void drm_test_modes_analog_tv_pal_576i(struct kunit *test)
{
struct drm_test_modes_priv *priv = test->priv;
struct drm_display_mode *mode;
int ret;
mode = drm_analog_tv_mode(priv->drm,
Annotation
- Immediate include surface: `drm/drm_drv.h`, `drm/drm_kunit_helpers.h`, `drm/drm_modes.h`, `kunit/test.h`, `linux/units.h`.
- Detected declarations: `struct drm_test_modes_priv`, `function drm_test_modes_init`, `function drm_test_modes_analog_tv_ntsc_480i`, `function drm_test_modes_analog_tv_ntsc_480i_inlined`, `function drm_test_modes_analog_tv_pal_576i`, `function drm_test_modes_analog_tv_pal_576i_inlined`, `function drm_test_modes_analog_tv_mono_576i`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
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.