drivers/gpu/drm/amd/display/dc/inc/bw_fixed.h

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/display/dc/inc/bw_fixed.h

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/amd/display/dc/inc/bw_fixed.h
Extension
.h
Size
4771 bytes
Lines
167
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

struct bw_fixed {
	int64_t value;
};

#define BW_FIXED_MIN_I32 \
	(int64_t)(-(1LL << (63 - BW_FIXED_BITS_PER_FRACTIONAL_PART)))

#define BW_FIXED_MAX_I32 \
	(int64_t)((1ULL << (63 - BW_FIXED_BITS_PER_FRACTIONAL_PART)) - 1)

static inline struct bw_fixed bw_min2(const struct bw_fixed arg1,
				      const struct bw_fixed arg2)
{
	return (arg1.value <= arg2.value) ? arg1 : arg2;
}

static inline struct bw_fixed bw_max2(const struct bw_fixed arg1,
				      const struct bw_fixed arg2)
{
	return (arg2.value <= arg1.value) ? arg1 : arg2;
}

static inline struct bw_fixed bw_min3(struct bw_fixed v1,
				      struct bw_fixed v2,
				      struct bw_fixed v3)
{
	return bw_min2(bw_min2(v1, v2), v3);
}

static inline struct bw_fixed bw_max3(struct bw_fixed v1,
				      struct bw_fixed v2,
				      struct bw_fixed v3)
{
	return bw_max2(bw_max2(v1, v2), v3);
}

struct bw_fixed bw_int_to_fixed_nonconst(int64_t value);
static inline struct bw_fixed bw_int_to_fixed(int64_t value)
{
	if (__builtin_constant_p(value)) {
		struct bw_fixed res;
		BUILD_BUG_ON(value > BW_FIXED_MAX_I32 || value < BW_FIXED_MIN_I32);
		res.value = value << BW_FIXED_BITS_PER_FRACTIONAL_PART;
		return res;
	} else
		return bw_int_to_fixed_nonconst(value);
}

static inline int32_t bw_fixed_to_int(struct bw_fixed value)
{
	return (int32_t)BW_FIXED_GET_INTEGER_PART(value.value);
}

struct bw_fixed bw_frc_to_fixed(int64_t num, int64_t denum);

static inline struct bw_fixed fixed31_32_to_bw_fixed(int64_t raw)
{
	struct bw_fixed result = { 0 };

	if (raw < 0) {
		raw = -raw;
		result.value = -(raw >> (32 - BW_FIXED_BITS_PER_FRACTIONAL_PART));
	} else {
		result.value = raw >> (32 - BW_FIXED_BITS_PER_FRACTIONAL_PART);
	}

	return result;
}

static inline struct bw_fixed bw_add(const struct bw_fixed arg1,
				     const struct bw_fixed arg2)
{
	struct bw_fixed res;

	res.value = arg1.value + arg2.value;

	return res;
}

static inline struct bw_fixed bw_sub(const struct bw_fixed arg1, const struct bw_fixed arg2)
{
	struct bw_fixed res;

	res.value = arg1.value - arg2.value;

	return res;
}

struct bw_fixed bw_mul(const struct bw_fixed arg1, const struct bw_fixed arg2);
static inline struct bw_fixed bw_div(const struct bw_fixed arg1, const struct bw_fixed arg2)

Annotation

Implementation Notes