drivers/gpu/drm/amd/display/dc/basics/bw_fixed.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/display/dc/basics/bw_fixed.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/display/dc/basics/bw_fixed.c- Extension
.c- Size
- 4742 bytes
- Lines
- 189
- 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
dm_services.hbw_fixed.h
Detected Declarations
function filesfunction bw_int_to_fixed_nonconstfunction bw_frc_to_fixedfunction bw_floor2function bw_ceil2function bw_mul
Annotated Snippet
if (remainder >= arg2_value) {
res_value |= 1;
remainder -= arg2_value;
}
} while (--i != 0);
}
/* round up LSB */
{
uint64_t summand = (remainder << 1) >= arg2_value;
ASSERT(res_value <= MAX_I64 - summand);
res_value += summand;
}
res.value = (int64_t)(res_value);
if (arg1_negative ^ arg2_negative)
res.value = -res.value;
return res;
}
struct bw_fixed bw_floor2(const struct bw_fixed arg,
const struct bw_fixed significance)
{
struct bw_fixed result;
int64_t multiplicand;
multiplicand = div64_s64(arg.value, abs_i64(significance.value));
result.value = abs_i64(significance.value) * multiplicand;
ASSERT(abs_i64(result.value) <= abs_i64(arg.value));
return result;
}
struct bw_fixed bw_ceil2(const struct bw_fixed arg,
const struct bw_fixed significance)
{
struct bw_fixed result;
int64_t multiplicand;
multiplicand = div64_s64(arg.value, abs_i64(significance.value));
result.value = abs_i64(significance.value) * multiplicand;
if (abs_i64(result.value) < abs_i64(arg.value)) {
if (arg.value < 0)
result.value -= abs_i64(significance.value);
else
result.value += abs_i64(significance.value);
}
return result;
}
struct bw_fixed bw_mul(const struct bw_fixed arg1, const struct bw_fixed arg2)
{
struct bw_fixed res;
bool arg1_negative = arg1.value < 0;
bool arg2_negative = arg2.value < 0;
uint64_t arg1_value = abs_i64(arg1.value);
uint64_t arg2_value = abs_i64(arg2.value);
uint64_t arg1_int = BW_FIXED_GET_INTEGER_PART(arg1_value);
uint64_t arg2_int = BW_FIXED_GET_INTEGER_PART(arg2_value);
uint64_t arg1_fra = GET_FRACTIONAL_PART(arg1_value);
uint64_t arg2_fra = GET_FRACTIONAL_PART(arg2_value);
uint64_t tmp;
res.value = arg1_int * arg2_int;
ASSERT(res.value <= BW_FIXED_MAX_I32);
res.value <<= BW_FIXED_BITS_PER_FRACTIONAL_PART;
tmp = arg1_int * arg2_fra;
ASSERT(tmp <= (uint64_t)(MAX_I64 - res.value));
res.value += tmp;
tmp = arg2_int * arg1_fra;
ASSERT(tmp <= (uint64_t)(MAX_I64 - res.value));
res.value += tmp;
tmp = arg1_fra * arg2_fra;
Annotation
- Immediate include surface: `dm_services.h`, `bw_fixed.h`.
- Detected declarations: `function files`, `function bw_int_to_fixed_nonconst`, `function bw_frc_to_fixed`, `function bw_floor2`, `function bw_ceil2`, `function bw_mul`.
- 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.