drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_standalone_libraries/lib_float_math.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_standalone_libraries/lib_float_math.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_standalone_libraries/lib_float_math.c- Extension
.c- Size
- 2993 bytes
- Lines
- 148
- 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.
Dependency Surface
lib_float_math.h
Detected Declarations
function math_modfunction math_min2function math_max2function math_floor2function math_floorfunction math_ceilfunction math_ceil2function math_max3function math_max4function math_max5function math_powfunction math_fabsfunction math_logfunction math_log2function math_log2_approxfunction math_round
Annotated Snippet
// SPDX-License-Identifier: MIT
//
// Copyright 2024 Advanced Micro Devices, Inc.
#include "lib_float_math.h"
#define ASSERT(condition)
#define isNaN(number) ((number) != (number))
/*
* NOTE:
* This file is gcc-parseable HW gospel, coming straight from HW engineers.
*
* It doesn't adhere to Linux kernel style and sometimes will do things in odd
* ways. Unless there is something clearly wrong with it the code should
* remain as-is as it provides us with a guarantee from HW that it is correct.
*/
double math_mod(const double arg1, const double arg2)
{
if (isNaN(arg1))
return arg2;
if (isNaN(arg2))
return arg1;
return arg1 - arg2 * ((int)(arg1 / arg2));
}
double math_min2(const double arg1, const double arg2)
{
if (isNaN(arg1))
return arg2;
if (isNaN(arg2))
return arg1;
return arg1 < arg2 ? arg1 : arg2;
}
double math_max2(const double arg1, const double arg2)
{
if (isNaN(arg1))
return arg2;
if (isNaN(arg2))
return arg1;
return arg1 > arg2 ? arg1 : arg2;
}
double math_floor2(const double arg, const double significance)
{
ASSERT(significance != 0);
return ((int)(arg / significance)) * significance;
}
double math_floor(const double arg)
{
return ((int)(arg));
}
double math_ceil(const double arg)
{
return (int)(arg + 0.99999);
}
double math_ceil2(const double arg, const double significance)
{
return ((int)(arg / significance + 0.99999)) * significance;
}
double math_max3(double v1, double v2, double v3)
{
return v3 > math_max2(v1, v2) ? v3 : math_max2(v1, v2);
}
double math_max4(double v1, double v2, double v3, double v4)
{
return v4 > math_max3(v1, v2, v3) ? v4 : math_max3(v1, v2, v3);
}
double math_max5(double v1, double v2, double v3, double v4, double v5)
{
return math_max3(v1, v2, v3) > math_max2(v4, v5) ? math_max3(v1, v2, v3) : math_max2(v4, v5);
}
float math_pow(float a, float exp)
{
double temp;
if ((int)exp == 0)
return 1;
temp = math_pow(a, (float)((int)(exp / 2)));
if (((int)exp % 2) == 0) {
Annotation
- Immediate include surface: `lib_float_math.h`.
- Detected declarations: `function math_mod`, `function math_min2`, `function math_max2`, `function math_floor2`, `function math_floor`, `function math_ceil`, `function math_ceil2`, `function math_max3`, `function math_max4`, `function math_max5`.
- 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.