drivers/gpu/drm/tests/drm_fixp_test.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/tests/drm_fixp_test.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/tests/drm_fixp_test.c- Extension
.c- Size
- 1840 bytes
- Lines
- 72
- 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_fixed.h
Detected Declarations
function drm_test_sm2fixpfunction drm_test_int2fixp
Annotated Snippet
// SPDX-License-Identifier: MIT
/*
* Copyright 2022 Advanced Micro Devices, Inc.
*/
#include <kunit/test.h>
#include <drm/drm_fixed.h>
static void drm_test_sm2fixp(struct kunit *test)
{
KUNIT_EXPECT_EQ(test, 0x7fffffffffffffffll, ((1ull << 63) - 1));
/* 1 */
KUNIT_EXPECT_EQ(test, drm_int2fixp(1), drm_sm2fixp(1ull << DRM_FIXED_POINT));
/* -1 */
KUNIT_EXPECT_EQ(test, drm_int2fixp(-1),
drm_sm2fixp((1ull << 63) | (1ull << DRM_FIXED_POINT)));
/* 0.5 */
KUNIT_EXPECT_EQ(test, drm_fixp_from_fraction(1, 2),
drm_sm2fixp(1ull << (DRM_FIXED_POINT - 1)));
/* -0.5 */
KUNIT_EXPECT_EQ(test, drm_fixp_from_fraction(-1, 2),
drm_sm2fixp((1ull << 63) | (1ull << (DRM_FIXED_POINT - 1))));
}
static void drm_test_int2fixp(struct kunit *test)
{
/* 1 */
KUNIT_EXPECT_EQ(test, 1ll << 32, drm_int2fixp(1));
/* -1 */
KUNIT_EXPECT_EQ(test, -(1ll << 32), drm_int2fixp(-1));
/* 1 + (-1) = 0 */
KUNIT_EXPECT_EQ(test, 0, drm_int2fixp(1) + drm_int2fixp(-1));
/* 1 / 2 */
KUNIT_EXPECT_EQ(test, 1ll << 31, drm_fixp_from_fraction(1, 2));
/* -0.5 */
KUNIT_EXPECT_EQ(test, -(1ll << 31), drm_fixp_from_fraction(-1, 2));
/* (1 / 2) + (-1) = 0.5 */
KUNIT_EXPECT_EQ(test, 1ll << 31, drm_fixp_from_fraction(-1, 2) + drm_int2fixp(1));
/* (1 / 2) - 1) = 0.5 */
KUNIT_EXPECT_EQ(test, -(1ll << 31), drm_fixp_from_fraction(1, 2) + drm_int2fixp(-1));
/* (1 / 2) - 1) = 0.5 */
KUNIT_EXPECT_EQ(test, -(1ll << 31), drm_fixp_from_fraction(1, 2) - drm_int2fixp(1));
}
static struct kunit_case drm_fixp_tests[] = {
KUNIT_CASE(drm_test_int2fixp),
KUNIT_CASE(drm_test_sm2fixp),
{ }
};
static struct kunit_suite drm_fixp_test_suite = {
.name = "drm_fixp",
.test_cases = drm_fixp_tests,
};
kunit_test_suite(drm_fixp_test_suite);
MODULE_AUTHOR("AMD");
MODULE_LICENSE("Dual MIT/GPL");
MODULE_DESCRIPTION("Unit tests for drm_fixed.h");
Annotation
- Immediate include surface: `kunit/test.h`, `drm/drm_fixed.h`.
- Detected declarations: `function drm_test_sm2fixp`, `function drm_test_int2fixp`.
- 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.