Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eb0e5154 authored by Dmytro Laktyushkin's avatar Dmytro Laktyushkin Committed by Alex Deucher
Browse files

drm/amd/display: get rid of 32.32 unsigned fixed point



32.32 is redundant, 31.32 does everything we use 32.32 for

Signed-off-by: default avatarDmytro Laktyushkin <Dmytro.Laktyushkin@amd.com>
Reviewed-by: default avatarTony Cheng <Tony.Cheng@amd.com>
Acked-by: default avatarHarry Wentland <harry.wentland@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent b79655c3
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -88,9 +88,9 @@ static void __drm_lut_to_dc_gamma(struct drm_color_lut *lut,
			g = drm_color_lut_extract(lut[i].green, 16);
			b = drm_color_lut_extract(lut[i].blue, 16);

			gamma->entries.red[i] = dal_fixed31_32_from_int(r);
			gamma->entries.green[i] = dal_fixed31_32_from_int(g);
			gamma->entries.blue[i] = dal_fixed31_32_from_int(b);
			gamma->entries.red[i] = dc_fixpt_from_int(r);
			gamma->entries.green[i] = dc_fixpt_from_int(g);
			gamma->entries.blue[i] = dc_fixpt_from_int(b);
		}
		return;
	}
@@ -101,9 +101,9 @@ static void __drm_lut_to_dc_gamma(struct drm_color_lut *lut,
		g = drm_color_lut_extract(lut[i].green, 16);
		b = drm_color_lut_extract(lut[i].blue, 16);

		gamma->entries.red[i] = dal_fixed31_32_from_fraction(r, MAX_DRM_LUT_VALUE);
		gamma->entries.green[i] = dal_fixed31_32_from_fraction(g, MAX_DRM_LUT_VALUE);
		gamma->entries.blue[i] = dal_fixed31_32_from_fraction(b, MAX_DRM_LUT_VALUE);
		gamma->entries.red[i] = dc_fixpt_from_fraction(r, MAX_DRM_LUT_VALUE);
		gamma->entries.green[i] = dc_fixpt_from_fraction(g, MAX_DRM_LUT_VALUE);
		gamma->entries.blue[i] = dc_fixpt_from_fraction(b, MAX_DRM_LUT_VALUE);
	}
}

@@ -208,7 +208,7 @@ void amdgpu_dm_set_ctm(struct dm_crtc_state *crtc)
	for (i = 0; i < 12; i++) {
		/* Skip 4th element */
		if (i % 4 == 3) {
			stream->gamut_remap_matrix.matrix[i] = dal_fixed31_32_zero;
			stream->gamut_remap_matrix.matrix[i] = dc_fixpt_zero;
			continue;
		}

+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@
# It provides the general basic services required by other DAL
# subcomponents.

BASICS = conversion.o fixpt31_32.o fixpt32_32.o \
BASICS = conversion.o fixpt31_32.o \
	logger.o log_helpers.o vector.o

AMD_DAL_BASICS = $(addprefix $(AMDDALPATH)/dc/basics/,$(BASICS))
+14 −14
Original line number Diff line number Diff line
@@ -41,22 +41,22 @@ uint16_t fixed_point_to_int_frac(

	uint16_t result;

	uint16_t d = (uint16_t)dal_fixed31_32_floor(
		dal_fixed31_32_abs(
	uint16_t d = (uint16_t)dc_fixpt_floor(
		dc_fixpt_abs(
			arg));

	if (d <= (uint16_t)(1 << integer_bits) - (1 / (uint16_t)divisor))
		numerator = (uint16_t)dal_fixed31_32_round(
			dal_fixed31_32_mul_int(
		numerator = (uint16_t)dc_fixpt_round(
			dc_fixpt_mul_int(
				arg,
				divisor));
	else {
		numerator = dal_fixed31_32_floor(
			dal_fixed31_32_sub(
				dal_fixed31_32_from_int(
		numerator = dc_fixpt_floor(
			dc_fixpt_sub(
				dc_fixpt_from_int(
					1LL << integer_bits),
				dal_fixed31_32_recip(
					dal_fixed31_32_from_int(
				dc_fixpt_recip(
					dc_fixpt_from_int(
						divisor))));
	}

@@ -66,8 +66,8 @@ uint16_t fixed_point_to_int_frac(
		result = (uint16_t)(
		(1 << (integer_bits + fractional_bits + 1)) + numerator);

	if ((result != 0) && dal_fixed31_32_lt(
		arg, dal_fixed31_32_zero))
	if ((result != 0) && dc_fixpt_lt(
		arg, dc_fixpt_zero))
		result |= 1 << (integer_bits + fractional_bits);

	return result;
@@ -84,15 +84,15 @@ void convert_float_matrix(
	uint32_t buffer_size)
{
	const struct fixed31_32 min_2_13 =
		dal_fixed31_32_from_fraction(S2D13_MIN, DIVIDER);
		dc_fixpt_from_fraction(S2D13_MIN, DIVIDER);
	const struct fixed31_32 max_2_13 =
		dal_fixed31_32_from_fraction(S2D13_MAX, DIVIDER);
		dc_fixpt_from_fraction(S2D13_MAX, DIVIDER);
	uint32_t i;

	for (i = 0; i < buffer_size; ++i) {
		uint32_t reg_value =
				fixed_point_to_int_frac(
					dal_fixed31_32_clamp(
					dc_fixpt_clamp(
						flt[i],
						min_2_13,
						max_2_13),
+88 −88
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ static inline unsigned long long complete_integer_division_u64(
#define GET_FRACTIONAL_PART(x) \
	(FRACTIONAL_PART_MASK & (x))

struct fixed31_32 dal_fixed31_32_from_fraction(
struct fixed31_32 dc_fixpt_from_fraction(
	long long numerator,
	long long denominator)
{
@@ -118,7 +118,7 @@ struct fixed31_32 dal_fixed31_32_from_fraction(
	return res;
}

struct fixed31_32 dal_fixed31_32_from_int_nonconst(
struct fixed31_32 dc_fixpt_from_int_nonconst(
	long long arg)
{
	struct fixed31_32 res;
@@ -130,7 +130,7 @@ struct fixed31_32 dal_fixed31_32_from_int_nonconst(
	return res;
}

struct fixed31_32 dal_fixed31_32_shl(
struct fixed31_32 dc_fixpt_shl(
	struct fixed31_32 arg,
	unsigned char shift)
{
@@ -144,7 +144,7 @@ struct fixed31_32 dal_fixed31_32_shl(
	return res;
}

struct fixed31_32 dal_fixed31_32_add(
struct fixed31_32 dc_fixpt_add(
	struct fixed31_32 arg1,
	struct fixed31_32 arg2)
{
@@ -158,7 +158,7 @@ struct fixed31_32 dal_fixed31_32_add(
	return res;
}

struct fixed31_32 dal_fixed31_32_sub(
struct fixed31_32 dc_fixpt_sub(
	struct fixed31_32 arg1,
	struct fixed31_32 arg2)
{
@@ -172,7 +172,7 @@ struct fixed31_32 dal_fixed31_32_sub(
	return res;
}

struct fixed31_32 dal_fixed31_32_mul(
struct fixed31_32 dc_fixpt_mul(
	struct fixed31_32 arg1,
	struct fixed31_32 arg2)
{
@@ -213,7 +213,7 @@ struct fixed31_32 dal_fixed31_32_mul(
	tmp = arg1_fra * arg2_fra;

	tmp = (tmp >> FIXED31_32_BITS_PER_FRACTIONAL_PART) +
		(tmp >= (unsigned long long)dal_fixed31_32_half.value);
		(tmp >= (unsigned long long)dc_fixpt_half.value);

	ASSERT(tmp <= (unsigned long long)(LLONG_MAX - res.value));

@@ -225,7 +225,7 @@ struct fixed31_32 dal_fixed31_32_mul(
	return res;
}

struct fixed31_32 dal_fixed31_32_sqr(
struct fixed31_32 dc_fixpt_sqr(
	struct fixed31_32 arg)
{
	struct fixed31_32 res;
@@ -257,7 +257,7 @@ struct fixed31_32 dal_fixed31_32_sqr(
	tmp = arg_fra * arg_fra;

	tmp = (tmp >> FIXED31_32_BITS_PER_FRACTIONAL_PART) +
		(tmp >= (unsigned long long)dal_fixed31_32_half.value);
		(tmp >= (unsigned long long)dc_fixpt_half.value);

	ASSERT(tmp <= (unsigned long long)(LLONG_MAX - res.value));

@@ -266,7 +266,7 @@ struct fixed31_32 dal_fixed31_32_sqr(
	return res;
}

struct fixed31_32 dal_fixed31_32_recip(
struct fixed31_32 dc_fixpt_recip(
	struct fixed31_32 arg)
{
	/*
@@ -276,41 +276,41 @@ struct fixed31_32 dal_fixed31_32_recip(

	ASSERT(arg.value);

	return dal_fixed31_32_from_fraction(
		dal_fixed31_32_one.value,
	return dc_fixpt_from_fraction(
		dc_fixpt_one.value,
		arg.value);
}

struct fixed31_32 dal_fixed31_32_sinc(
struct fixed31_32 dc_fixpt_sinc(
	struct fixed31_32 arg)
{
	struct fixed31_32 square;

	struct fixed31_32 res = dal_fixed31_32_one;
	struct fixed31_32 res = dc_fixpt_one;

	int n = 27;

	struct fixed31_32 arg_norm = arg;

	if (dal_fixed31_32_le(
		dal_fixed31_32_two_pi,
		dal_fixed31_32_abs(arg))) {
		arg_norm = dal_fixed31_32_sub(
	if (dc_fixpt_le(
		dc_fixpt_two_pi,
		dc_fixpt_abs(arg))) {
		arg_norm = dc_fixpt_sub(
			arg_norm,
			dal_fixed31_32_mul_int(
				dal_fixed31_32_two_pi,
			dc_fixpt_mul_int(
				dc_fixpt_two_pi,
				(int)div64_s64(
					arg_norm.value,
					dal_fixed31_32_two_pi.value)));
					dc_fixpt_two_pi.value)));
	}

	square = dal_fixed31_32_sqr(arg_norm);
	square = dc_fixpt_sqr(arg_norm);

	do {
		res = dal_fixed31_32_sub(
			dal_fixed31_32_one,
			dal_fixed31_32_div_int(
				dal_fixed31_32_mul(
		res = dc_fixpt_sub(
			dc_fixpt_one,
			dc_fixpt_div_int(
				dc_fixpt_mul(
					square,
					res),
				n * (n - 1)));
@@ -319,37 +319,37 @@ struct fixed31_32 dal_fixed31_32_sinc(
	} while (n > 2);

	if (arg.value != arg_norm.value)
		res = dal_fixed31_32_div(
			dal_fixed31_32_mul(res, arg_norm),
		res = dc_fixpt_div(
			dc_fixpt_mul(res, arg_norm),
			arg);

	return res;
}

struct fixed31_32 dal_fixed31_32_sin(
struct fixed31_32 dc_fixpt_sin(
	struct fixed31_32 arg)
{
	return dal_fixed31_32_mul(
	return dc_fixpt_mul(
		arg,
		dal_fixed31_32_sinc(arg));
		dc_fixpt_sinc(arg));
}

struct fixed31_32 dal_fixed31_32_cos(
struct fixed31_32 dc_fixpt_cos(
	struct fixed31_32 arg)
{
	/* TODO implement argument normalization */

	const struct fixed31_32 square = dal_fixed31_32_sqr(arg);
	const struct fixed31_32 square = dc_fixpt_sqr(arg);

	struct fixed31_32 res = dal_fixed31_32_one;
	struct fixed31_32 res = dc_fixpt_one;

	int n = 26;

	do {
		res = dal_fixed31_32_sub(
			dal_fixed31_32_one,
			dal_fixed31_32_div_int(
				dal_fixed31_32_mul(
		res = dc_fixpt_sub(
			dc_fixpt_one,
			dc_fixpt_div_int(
				dc_fixpt_mul(
					square,
					res),
				n * (n - 1)));
@@ -372,31 +372,31 @@ static struct fixed31_32 fixed31_32_exp_from_taylor_series(
{
	unsigned int n = 9;

	struct fixed31_32 res = dal_fixed31_32_from_fraction(
	struct fixed31_32 res = dc_fixpt_from_fraction(
		n + 2,
		n + 1);
	/* TODO find correct res */

	ASSERT(dal_fixed31_32_lt(arg, dal_fixed31_32_one));
	ASSERT(dc_fixpt_lt(arg, dc_fixpt_one));

	do
		res = dal_fixed31_32_add(
			dal_fixed31_32_one,
			dal_fixed31_32_div_int(
				dal_fixed31_32_mul(
		res = dc_fixpt_add(
			dc_fixpt_one,
			dc_fixpt_div_int(
				dc_fixpt_mul(
					arg,
					res),
				n));
	while (--n != 1);

	return dal_fixed31_32_add(
		dal_fixed31_32_one,
		dal_fixed31_32_mul(
	return dc_fixpt_add(
		dc_fixpt_one,
		dc_fixpt_mul(
			arg,
			res));
}

struct fixed31_32 dal_fixed31_32_exp(
struct fixed31_32 dc_fixpt_exp(
	struct fixed31_32 arg)
{
	/*
@@ -406,44 +406,44 @@ struct fixed31_32 dal_fixed31_32_exp(
	 * where m = round(x / ln(2)), r = x - m * ln(2)
	 */

	if (dal_fixed31_32_le(
		dal_fixed31_32_ln2_div_2,
		dal_fixed31_32_abs(arg))) {
		int m = dal_fixed31_32_round(
			dal_fixed31_32_div(
	if (dc_fixpt_le(
		dc_fixpt_ln2_div_2,
		dc_fixpt_abs(arg))) {
		int m = dc_fixpt_round(
			dc_fixpt_div(
				arg,
				dal_fixed31_32_ln2));
				dc_fixpt_ln2));

		struct fixed31_32 r = dal_fixed31_32_sub(
		struct fixed31_32 r = dc_fixpt_sub(
			arg,
			dal_fixed31_32_mul_int(
				dal_fixed31_32_ln2,
			dc_fixpt_mul_int(
				dc_fixpt_ln2,
				m));

		ASSERT(m != 0);

		ASSERT(dal_fixed31_32_lt(
			dal_fixed31_32_abs(r),
			dal_fixed31_32_one));
		ASSERT(dc_fixpt_lt(
			dc_fixpt_abs(r),
			dc_fixpt_one));

		if (m > 0)
			return dal_fixed31_32_shl(
			return dc_fixpt_shl(
				fixed31_32_exp_from_taylor_series(r),
				(unsigned char)m);
		else
			return dal_fixed31_32_div_int(
			return dc_fixpt_div_int(
				fixed31_32_exp_from_taylor_series(r),
				1LL << -m);
	} else if (arg.value != 0)
		return fixed31_32_exp_from_taylor_series(arg);
	else
		return dal_fixed31_32_one;
		return dc_fixpt_one;
}

struct fixed31_32 dal_fixed31_32_log(
struct fixed31_32 dc_fixpt_log(
	struct fixed31_32 arg)
{
	struct fixed31_32 res = dal_fixed31_32_neg(dal_fixed31_32_one);
	struct fixed31_32 res = dc_fixpt_neg(dc_fixpt_one);
	/* TODO improve 1st estimation */

	struct fixed31_32 error;
@@ -453,15 +453,15 @@ struct fixed31_32 dal_fixed31_32_log(
	/* TODO if arg is zero, return -INF */

	do {
		struct fixed31_32 res1 = dal_fixed31_32_add(
			dal_fixed31_32_sub(
		struct fixed31_32 res1 = dc_fixpt_add(
			dc_fixpt_sub(
				res,
				dal_fixed31_32_one),
			dal_fixed31_32_div(
				dc_fixpt_one),
			dc_fixpt_div(
				arg,
				dal_fixed31_32_exp(res)));
				dc_fixpt_exp(res)));

		error = dal_fixed31_32_sub(
		error = dc_fixpt_sub(
			res,
			res1);

@@ -472,17 +472,17 @@ struct fixed31_32 dal_fixed31_32_log(
	return res;
}

struct fixed31_32 dal_fixed31_32_pow(
struct fixed31_32 dc_fixpt_pow(
	struct fixed31_32 arg1,
	struct fixed31_32 arg2)
{
	return dal_fixed31_32_exp(
		dal_fixed31_32_mul(
			dal_fixed31_32_log(arg1),
	return dc_fixpt_exp(
		dc_fixpt_mul(
			dc_fixpt_log(arg1),
			arg2));
}

int dal_fixed31_32_floor(
int dc_fixpt_floor(
	struct fixed31_32 arg)
{
	unsigned long long arg_value = abs_i64(arg.value);
@@ -493,12 +493,12 @@ int dal_fixed31_32_floor(
		return -(int)GET_INTEGER_PART(arg_value);
}

int dal_fixed31_32_round(
int dc_fixpt_round(
	struct fixed31_32 arg)
{
	unsigned long long arg_value = abs_i64(arg.value);

	const long long summand = dal_fixed31_32_half.value;
	const long long summand = dc_fixpt_half.value;

	ASSERT(LLONG_MAX - (long long)arg_value >= summand);

@@ -510,13 +510,13 @@ int dal_fixed31_32_round(
		return -(int)GET_INTEGER_PART(arg_value);
}

int dal_fixed31_32_ceil(
int dc_fixpt_ceil(
	struct fixed31_32 arg)
{
	unsigned long long arg_value = abs_i64(arg.value);

	const long long summand = dal_fixed31_32_one.value -
		dal_fixed31_32_epsilon.value;
	const long long summand = dc_fixpt_one.value -
		dc_fixpt_epsilon.value;

	ASSERT(LLONG_MAX - (long long)arg_value >= summand);

@@ -531,7 +531,7 @@ int dal_fixed31_32_ceil(
/* this function is a generic helper to translate fixed point value to
 * specified integer format that will consist of integer_bits integer part and
 * fractional_bits fractional part. For example it is used in
 * dal_fixed31_32_u2d19 to receive 2 bits integer part and 19 bits fractional
 * dc_fixpt_u2d19 to receive 2 bits integer part and 19 bits fractional
 * part in 32 bits. It is used in hw programming (scaler)
 */

@@ -570,35 +570,35 @@ static inline unsigned int clamp_ux_dy(
		return min_clamp;
}

unsigned int dal_fixed31_32_u2d19(
unsigned int dc_fixpt_u2d19(
	struct fixed31_32 arg)
{
	return ux_dy(arg.value, 2, 19);
}

unsigned int dal_fixed31_32_u0d19(
unsigned int dc_fixpt_u0d19(
	struct fixed31_32 arg)
{
	return ux_dy(arg.value, 0, 19);
}

unsigned int dal_fixed31_32_clamp_u0d14(
unsigned int dc_fixpt_clamp_u0d14(
	struct fixed31_32 arg)
{
	return clamp_ux_dy(arg.value, 0, 14, 1);
}

unsigned int dal_fixed31_32_clamp_u0d10(
unsigned int dc_fixpt_clamp_u0d10(
	struct fixed31_32 arg)
{
	return clamp_ux_dy(arg.value, 0, 10, 1);
}

int dal_fixed31_32_s4d19(
int dc_fixpt_s4d19(
	struct fixed31_32 arg)
{
	if (arg.value < 0)
		return -(int)ux_dy(dal_fixed31_32_abs(arg).value, 4, 19);
		return -(int)ux_dy(dc_fixpt_abs(arg).value, 4, 19);
	else
		return ux_dy(arg.value, 4, 19);
}
+0 −161
Original line number Diff line number Diff line
/*
 * Copyright 2012-15 Advanced Micro Devices, Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
 * Authors: AMD
 *
 */

#include "dm_services.h"
#include "include/fixed32_32.h"

static uint64_t u64_div(uint64_t n, uint64_t d)
{
	uint32_t i = 0;
	uint64_t r;
	uint64_t q = div64_u64_rem(n, d, &r);

	for (i = 0; i < 32; ++i) {
		uint64_t sbit = q & (1ULL<<63);

		r <<= 1;
		r |= sbit ? 1 : 0;
		q <<= 1;
		if (r >= d) {
			r -= d;
			q |= 1;
		}
	}

	if (2*r >= d)
		q += 1;
	return q;
}

struct fixed32_32 dal_fixed32_32_from_fraction(uint32_t n, uint32_t d)
{
	struct fixed32_32 fx;

	fx.value = u64_div((uint64_t)n << 32, (uint64_t)d << 32);
	return fx;
}

struct fixed32_32 dal_fixed32_32_add(
	struct fixed32_32 lhs,
	struct fixed32_32 rhs)
{
	struct fixed32_32 fx = {lhs.value + rhs.value};

	ASSERT(fx.value >= rhs.value);
	return fx;
}

struct fixed32_32 dal_fixed32_32_add_int(struct fixed32_32 lhs, uint32_t rhs)
{
	struct fixed32_32 fx = {lhs.value + ((uint64_t)rhs << 32)};

	ASSERT(fx.value >= (uint64_t)rhs << 32);
	return fx;

}
struct fixed32_32 dal_fixed32_32_sub(
	struct fixed32_32 lhs,
	struct fixed32_32 rhs)
{
	struct fixed32_32 fx;

	ASSERT(lhs.value >= rhs.value);
	fx.value = lhs.value - rhs.value;
	return fx;
}

struct fixed32_32 dal_fixed32_32_sub_int(struct fixed32_32 lhs, uint32_t rhs)
{
	struct fixed32_32 fx;

	ASSERT(lhs.value >= ((uint64_t)rhs<<32));
	fx.value = lhs.value - ((uint64_t)rhs<<32);
	return fx;
}

struct fixed32_32 dal_fixed32_32_mul(
	struct fixed32_32 lhs,
	struct fixed32_32 rhs)
{
	struct fixed32_32 fx;
	uint64_t lhs_int = lhs.value>>32;
	uint64_t lhs_frac = (uint32_t)lhs.value;
	uint64_t rhs_int = rhs.value>>32;
	uint64_t rhs_frac = (uint32_t)rhs.value;
	uint64_t ahbh = lhs_int * rhs_int;
	uint64_t ahbl = lhs_int * rhs_frac;
	uint64_t albh = lhs_frac * rhs_int;
	uint64_t albl = lhs_frac * rhs_frac;

	ASSERT((ahbh>>32) == 0);

	fx.value = (ahbh<<32) + ahbl + albh + (albl>>32);
	return fx;

}

struct fixed32_32 dal_fixed32_32_mul_int(struct fixed32_32 lhs, uint32_t rhs)
{
	struct fixed32_32 fx;
	uint64_t lhsi = (lhs.value>>32) * (uint64_t)rhs;
	uint64_t lhsf;

	ASSERT((lhsi>>32) == 0);
	lhsf = ((uint32_t)lhs.value) * (uint64_t)rhs;
	ASSERT((lhsi<<32) + lhsf >= lhsf);
	fx.value = (lhsi<<32) + lhsf;
	return fx;
}

struct fixed32_32 dal_fixed32_32_div(
	struct fixed32_32 lhs,
	struct fixed32_32 rhs)
{
	struct fixed32_32 fx;

	fx.value = u64_div(lhs.value, rhs.value);
	return fx;
}

struct fixed32_32 dal_fixed32_32_div_int(struct fixed32_32 lhs, uint32_t rhs)
{
	struct fixed32_32 fx;

	fx.value = u64_div(lhs.value, (uint64_t)rhs << 32);
	return fx;
}

uint32_t dal_fixed32_32_ceil(struct fixed32_32 v)
{
	ASSERT((uint32_t)v.value ? (v.value >> 32) + 1 >= 1 : true);
	return (v.value>>32) + ((uint32_t)v.value ? 1 : 0);
}

uint32_t dal_fixed32_32_round(struct fixed32_32 v)
{
	ASSERT(v.value + (1ULL<<31) >= (1ULL<<31));
	return (v.value + (1ULL<<31))>>32;
}
Loading