37#define dfixed_const(A) (u32)(((A) << 12))
38#define dfixed_const_half(A) (u32)(((A) << 12) + 2048)
39#define dfixed_const_666(A) (u32)(((A) << 12) + 2731)
40#define dfixed_const_8(A) (u32)(((A) << 12) + 3277)
41#define dfixed_mul(A, B) ((u64)((u64)(A).full * (B).full + 2048) >> 12)
42#define dfixed_init(A) { .full = dfixed_const((A)) }
43#define dfixed_init_half(A) { .full = dfixed_const_half((A)) }
44#define dfixed_trunc(A) ((A).full >> 12)
45#define dfixed_frac(A) ((A).full & ((1 << 12) - 1))
74#define DRM_FIXED_POINT 32
75#define DRM_FIXED_ONE (1ULL << DRM_FIXED_POINT)
76#define DRM_FIXED_DECIMAL_MASK (DRM_FIXED_ONE - 1)
77#define DRM_FIXED_DIGITS_MASK (~DRM_FIXED_DECIMAL_MASK)
78#define DRM_FIXED_EPSILON 1LL
79#define DRM_FIXED_ALMOST_ONE (DRM_FIXED_ONE - DRM_FIXED_EPSILON)
92 if ((
a & (1LL << 63))) {
93 return -(
a & 0x7fffffffffffffffll);
99static inline s64 drm_int2fixp(
int a)
104static inline int drm_fixp2int(
s64 a)
109static inline int drm_fixp2int_round(
s64 a)
114static inline int drm_fixp2int_ceil(
s64 a)
122static inline unsigned drm_fixp_msbset(
s64 a)
124 unsigned shift,
sign = (
a >> 63) & 1;
126 for (shift = 62; shift > 0; --shift)
127 if (((
a >> shift) & 1) !=
sign)
135 unsigned shift = drm_fixp_msbset(
a) + drm_fixp_msbset(
b);
140 a >>= (shift >> 1) + (shift & 1);
158 unsigned shift = 62 - drm_fixp_msbset(
a);
166 result = div64_s64(
a,
b);
174static inline s64 drm_fixp_from_fraction(
s64 a,
s64 b)
179 u64 a_abs = a_neg ? -
a :
a;
180 u64 b_abs = b_neg ? -
b :
b;
184 u64 res_abs = div64_u64_rem(a_abs, b_abs, &rem);
202 u64 summand = (rem << 1) >= b_abs;
213static inline s64 drm_fixp_exp(
s64 x)
224 while (
term >= tolerance) {
227 term = drm_fixp_mul(
term, div64_s64(y, count));
236static inline int fxp_q4_from_int(
int val_int)
241static inline int fxp_q4_to_int(
int val_q4)
246static inline int fxp_q4_to_int_roundup(
int val_q4)
248 return (val_q4 + 0xf) >> 4;
251static inline int fxp_q4_to_frac(
int val_q4)
256#define FXP_Q4_FMT "%d.%04d"
257#define FXP_Q4_ARGS(val_q4) fxp_q4_to_int(val_q4), (fxp_q4_to_frac(val_q4) * 625)
#define do_div(n, base)
Definition stdint.h:256
size_t a
Definition main.cpp:156
size_t b
Definition main.cpp:156
#define sign(x)
Definition draw.cpp:36
uint64_t __u64
Definition drm.h:44
#define DRM_FIXED_ALMOST_ONE
Definition drm_fixed.h:79
#define dfixed_trunc(A)
Definition drm_fixed.h:44
#define dfixed_const(A)
Definition drm_fixed.h:37
#define DRM_FIXED_POINT
Definition drm_fixed.h:74
#define DRM_FIXED_ONE
Definition drm_fixed.h:75
@ B
Definition element-type.h:28
@ A
Definition element-type.h:28
int y
Definition layout.c:118
int x
Definition layout.c:118
int64_t s64
Definition kernel.h:21
#define lower_32_bits(n)
Definition kernel.h:581
uint64_t u64
Definition kernel.h:17
uint32_t u32
Definition kernel.h:16
Terminal term
Definition term.cpp:54
Definition drm_fixed.h:32
u32 full
Definition drm_fixed.h:33