drivers/gpu/drm/tests/drm_format_test.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/tests/drm_format_test.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/tests/drm_format_test.c- Extension
.c- Size
- 15730 bytes
- Lines
- 361
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
kunit/test.hdrm/drm_fourcc.h
Detected Declarations
function Copyrightfunction drm_test_format_block_width_one_planefunction drm_test_format_block_width_two_planefunction drm_test_format_block_width_three_planefunction drm_test_format_block_width_tiledfunction drm_test_format_block_height_invalidfunction drm_test_format_block_height_one_planefunction drm_test_format_block_height_two_planefunction drm_test_format_block_height_three_planefunction drm_test_format_block_height_tiledfunction drm_test_format_min_pitch_invalidfunction drm_test_format_min_pitch_one_plane_8bppfunction drm_test_format_min_pitch_one_plane_16bppfunction drm_test_format_min_pitch_one_plane_24bppfunction drm_test_format_min_pitch_one_plane_32bppfunction drm_test_format_min_pitch_two_planefunction drm_test_format_min_pitch_three_plane_8bppfunction drm_test_format_min_pitch_tiled
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Test cases for the drm_format functions
*
* Copyright (c) 2022 MaĆra Canal <mairacanal@riseup.net>
*/
#include <kunit/test.h>
#include <drm/drm_fourcc.h>
static void drm_test_format_block_width_invalid(struct kunit *test)
{
const struct drm_format_info *info = NULL;
KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 0), 0);
KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, -1), 0);
KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 1), 0);
}
static void drm_test_format_block_width_one_plane(struct kunit *test)
{
const struct drm_format_info *info = drm_format_info(DRM_FORMAT_XRGB4444);
KUNIT_ASSERT_NOT_NULL(test, info);
KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 0), 1);
KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 1), 0);
KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, -1), 0);
}
static void drm_test_format_block_width_two_plane(struct kunit *test)
{
const struct drm_format_info *info = drm_format_info(DRM_FORMAT_NV12);
KUNIT_ASSERT_NOT_NULL(test, info);
KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 0), 1);
KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 1), 1);
KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 2), 0);
KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, -1), 0);
}
static void drm_test_format_block_width_three_plane(struct kunit *test)
{
const struct drm_format_info *info = drm_format_info(DRM_FORMAT_YUV422);
KUNIT_ASSERT_NOT_NULL(test, info);
KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 0), 1);
KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 1), 1);
KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 2), 1);
KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 3), 0);
KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, -1), 0);
}
static void drm_test_format_block_width_tiled(struct kunit *test)
{
const struct drm_format_info *info = drm_format_info(DRM_FORMAT_X0L0);
KUNIT_ASSERT_NOT_NULL(test, info);
KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 0), 2);
KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 1), 0);
KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, -1), 0);
}
static void drm_test_format_block_height_invalid(struct kunit *test)
{
const struct drm_format_info *info = NULL;
KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 0), 0);
KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, -1), 0);
KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 1), 0);
}
static void drm_test_format_block_height_one_plane(struct kunit *test)
{
const struct drm_format_info *info = drm_format_info(DRM_FORMAT_XRGB4444);
KUNIT_ASSERT_NOT_NULL(test, info);
KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 0), 1);
KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, -1), 0);
KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 1), 0);
}
static void drm_test_format_block_height_two_plane(struct kunit *test)
{
const struct drm_format_info *info = drm_format_info(DRM_FORMAT_NV12);
Annotation
- Immediate include surface: `kunit/test.h`, `drm/drm_fourcc.h`.
- Detected declarations: `function Copyright`, `function drm_test_format_block_width_one_plane`, `function drm_test_format_block_width_two_plane`, `function drm_test_format_block_width_three_plane`, `function drm_test_format_block_width_tiled`, `function drm_test_format_block_height_invalid`, `function drm_test_format_block_height_one_plane`, `function drm_test_format_block_height_two_plane`, `function drm_test_format_block_height_three_plane`, `function drm_test_format_block_height_tiled`.
- 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.