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.

Dependency Surface

Detected Declarations

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

Implementation Notes