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

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
...@@ -88,9 +88,9 @@ static void __drm_lut_to_dc_gamma(struct drm_color_lut *lut, ...@@ -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); g = drm_color_lut_extract(lut[i].green, 16);
b = drm_color_lut_extract(lut[i].blue, 16); b = drm_color_lut_extract(lut[i].blue, 16);
gamma->entries.red[i] = dal_fixed31_32_from_int(r); gamma->entries.red[i] = dc_fixpt_from_int(r);
gamma->entries.green[i] = dal_fixed31_32_from_int(g); gamma->entries.green[i] = dc_fixpt_from_int(g);
gamma->entries.blue[i] = dal_fixed31_32_from_int(b); gamma->entries.blue[i] = dc_fixpt_from_int(b);
} }
return; return;
} }
...@@ -101,9 +101,9 @@ static void __drm_lut_to_dc_gamma(struct drm_color_lut *lut, ...@@ -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); g = drm_color_lut_extract(lut[i].green, 16);
b = drm_color_lut_extract(lut[i].blue, 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.red[i] = dc_fixpt_from_fraction(r, MAX_DRM_LUT_VALUE);
gamma->entries.green[i] = dal_fixed31_32_from_fraction(g, MAX_DRM_LUT_VALUE); gamma->entries.green[i] = dc_fixpt_from_fraction(g, MAX_DRM_LUT_VALUE);
gamma->entries.blue[i] = dal_fixed31_32_from_fraction(b, 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) ...@@ -208,7 +208,7 @@ void amdgpu_dm_set_ctm(struct dm_crtc_state *crtc)
for (i = 0; i < 12; i++) { for (i = 0; i < 12; i++) {
/* Skip 4th element */ /* Skip 4th element */
if (i % 4 == 3) { if (i % 4 == 3) {
stream->gamut_remap_matrix.matrix[i] = dal_fixed31_32_zero; stream->gamut_remap_matrix.matrix[i] = dc_fixpt_zero;
continue; continue;
} }
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
# It provides the general basic services required by other DAL # It provides the general basic services required by other DAL
# subcomponents. # subcomponents.
BASICS = conversion.o fixpt31_32.o fixpt32_32.o \ BASICS = conversion.o fixpt31_32.o \
logger.o log_helpers.o vector.o logger.o log_helpers.o vector.o
AMD_DAL_BASICS = $(addprefix $(AMDDALPATH)/dc/basics/,$(BASICS)) AMD_DAL_BASICS = $(addprefix $(AMDDALPATH)/dc/basics/,$(BASICS))
......
...@@ -41,22 +41,22 @@ uint16_t fixed_point_to_int_frac( ...@@ -41,22 +41,22 @@ uint16_t fixed_point_to_int_frac(
uint16_t result; uint16_t result;
uint16_t d = (uint16_t)dal_fixed31_32_floor( uint16_t d = (uint16_t)dc_fixpt_floor(
dal_fixed31_32_abs( dc_fixpt_abs(
arg)); arg));
if (d <= (uint16_t)(1 << integer_bits) - (1 / (uint16_t)divisor)) if (d <= (uint16_t)(1 << integer_bits) - (1 / (uint16_t)divisor))
numerator = (uint16_t)dal_fixed31_32_round( numerator = (uint16_t)dc_fixpt_round(
dal_fixed31_32_mul_int( dc_fixpt_mul_int(
arg, arg,
divisor)); divisor));
else { else {
numerator = dal_fixed31_32_floor( numerator = dc_fixpt_floor(
dal_fixed31_32_sub( dc_fixpt_sub(
dal_fixed31_32_from_int( dc_fixpt_from_int(
1LL << integer_bits), 1LL << integer_bits),
dal_fixed31_32_recip( dc_fixpt_recip(
dal_fixed31_32_from_int( dc_fixpt_from_int(
divisor)))); divisor))));
} }
...@@ -66,8 +66,8 @@ uint16_t fixed_point_to_int_frac( ...@@ -66,8 +66,8 @@ uint16_t fixed_point_to_int_frac(
result = (uint16_t)( result = (uint16_t)(
(1 << (integer_bits + fractional_bits + 1)) + numerator); (1 << (integer_bits + fractional_bits + 1)) + numerator);
if ((result != 0) && dal_fixed31_32_lt( if ((result != 0) && dc_fixpt_lt(
arg, dal_fixed31_32_zero)) arg, dc_fixpt_zero))
result |= 1 << (integer_bits + fractional_bits); result |= 1 << (integer_bits + fractional_bits);
return result; return result;
...@@ -84,15 +84,15 @@ void convert_float_matrix( ...@@ -84,15 +84,15 @@ void convert_float_matrix(
uint32_t buffer_size) uint32_t buffer_size)
{ {
const struct fixed31_32 min_2_13 = 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 = 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; uint32_t i;
for (i = 0; i < buffer_size; ++i) { for (i = 0; i < buffer_size; ++i) {
uint32_t reg_value = uint32_t reg_value =
fixed_point_to_int_frac( fixed_point_to_int_frac(
dal_fixed31_32_clamp( dc_fixpt_clamp(
flt[i], flt[i],
min_2_13, min_2_13,
max_2_13), max_2_13),
......
...@@ -64,7 +64,7 @@ static inline unsigned long long complete_integer_division_u64( ...@@ -64,7 +64,7 @@ static inline unsigned long long complete_integer_division_u64(
#define GET_FRACTIONAL_PART(x) \ #define GET_FRACTIONAL_PART(x) \
(FRACTIONAL_PART_MASK & (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 numerator,
long long denominator) long long denominator)
{ {
...@@ -118,7 +118,7 @@ struct fixed31_32 dal_fixed31_32_from_fraction( ...@@ -118,7 +118,7 @@ struct fixed31_32 dal_fixed31_32_from_fraction(
return res; return res;
} }
struct fixed31_32 dal_fixed31_32_from_int_nonconst( struct fixed31_32 dc_fixpt_from_int_nonconst(
long long arg) long long arg)
{ {
struct fixed31_32 res; struct fixed31_32 res;
...@@ -130,7 +130,7 @@ struct fixed31_32 dal_fixed31_32_from_int_nonconst( ...@@ -130,7 +130,7 @@ struct fixed31_32 dal_fixed31_32_from_int_nonconst(
return res; return res;
} }
struct fixed31_32 dal_fixed31_32_shl( struct fixed31_32 dc_fixpt_shl(
struct fixed31_32 arg, struct fixed31_32 arg,
unsigned char shift) unsigned char shift)
{ {
...@@ -144,7 +144,7 @@ struct fixed31_32 dal_fixed31_32_shl( ...@@ -144,7 +144,7 @@ struct fixed31_32 dal_fixed31_32_shl(
return res; return res;
} }
struct fixed31_32 dal_fixed31_32_add( struct fixed31_32 dc_fixpt_add(
struct fixed31_32 arg1, struct fixed31_32 arg1,
struct fixed31_32 arg2) struct fixed31_32 arg2)
{ {
...@@ -158,7 +158,7 @@ struct fixed31_32 dal_fixed31_32_add( ...@@ -158,7 +158,7 @@ struct fixed31_32 dal_fixed31_32_add(
return res; return res;
} }
struct fixed31_32 dal_fixed31_32_sub( struct fixed31_32 dc_fixpt_sub(
struct fixed31_32 arg1, struct fixed31_32 arg1,
struct fixed31_32 arg2) struct fixed31_32 arg2)
{ {
...@@ -172,7 +172,7 @@ struct fixed31_32 dal_fixed31_32_sub( ...@@ -172,7 +172,7 @@ struct fixed31_32 dal_fixed31_32_sub(
return res; return res;
} }
struct fixed31_32 dal_fixed31_32_mul( struct fixed31_32 dc_fixpt_mul(
struct fixed31_32 arg1, struct fixed31_32 arg1,
struct fixed31_32 arg2) struct fixed31_32 arg2)
{ {
...@@ -213,7 +213,7 @@ struct fixed31_32 dal_fixed31_32_mul( ...@@ -213,7 +213,7 @@ struct fixed31_32 dal_fixed31_32_mul(
tmp = arg1_fra * arg2_fra; tmp = arg1_fra * arg2_fra;
tmp = (tmp >> FIXED31_32_BITS_PER_FRACTIONAL_PART) + 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)); ASSERT(tmp <= (unsigned long long)(LLONG_MAX - res.value));
...@@ -225,7 +225,7 @@ struct fixed31_32 dal_fixed31_32_mul( ...@@ -225,7 +225,7 @@ struct fixed31_32 dal_fixed31_32_mul(
return res; return res;
} }
struct fixed31_32 dal_fixed31_32_sqr( struct fixed31_32 dc_fixpt_sqr(
struct fixed31_32 arg) struct fixed31_32 arg)
{ {
struct fixed31_32 res; struct fixed31_32 res;
...@@ -257,7 +257,7 @@ struct fixed31_32 dal_fixed31_32_sqr( ...@@ -257,7 +257,7 @@ struct fixed31_32 dal_fixed31_32_sqr(
tmp = arg_fra * arg_fra; tmp = arg_fra * arg_fra;
tmp = (tmp >> FIXED31_32_BITS_PER_FRACTIONAL_PART) + 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)); ASSERT(tmp <= (unsigned long long)(LLONG_MAX - res.value));
...@@ -266,7 +266,7 @@ struct fixed31_32 dal_fixed31_32_sqr( ...@@ -266,7 +266,7 @@ struct fixed31_32 dal_fixed31_32_sqr(
return res; return res;
} }
struct fixed31_32 dal_fixed31_32_recip( struct fixed31_32 dc_fixpt_recip(
struct fixed31_32 arg) struct fixed31_32 arg)
{ {
/* /*
...@@ -276,41 +276,41 @@ struct fixed31_32 dal_fixed31_32_recip( ...@@ -276,41 +276,41 @@ struct fixed31_32 dal_fixed31_32_recip(
ASSERT(arg.value); ASSERT(arg.value);
return dal_fixed31_32_from_fraction( return dc_fixpt_from_fraction(
dal_fixed31_32_one.value, dc_fixpt_one.value,
arg.value); arg.value);
} }
struct fixed31_32 dal_fixed31_32_sinc( struct fixed31_32 dc_fixpt_sinc(
struct fixed31_32 arg) struct fixed31_32 arg)
{ {
struct fixed31_32 square; struct fixed31_32 square;
struct fixed31_32 res = dal_fixed31_32_one; struct fixed31_32 res = dc_fixpt_one;
int n = 27; int n = 27;
struct fixed31_32 arg_norm = arg; struct fixed31_32 arg_norm = arg;
if (dal_fixed31_32_le( if (dc_fixpt_le(
dal_fixed31_32_two_pi, dc_fixpt_two_pi,
dal_fixed31_32_abs(arg))) { dc_fixpt_abs(arg))) {
arg_norm = dal_fixed31_32_sub( arg_norm = dc_fixpt_sub(
arg_norm, arg_norm,
dal_fixed31_32_mul_int( dc_fixpt_mul_int(
dal_fixed31_32_two_pi, dc_fixpt_two_pi,
(int)div64_s64( (int)div64_s64(
arg_norm.value, 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 { do {
res = dal_fixed31_32_sub( res = dc_fixpt_sub(
dal_fixed31_32_one, dc_fixpt_one,
dal_fixed31_32_div_int( dc_fixpt_div_int(
dal_fixed31_32_mul( dc_fixpt_mul(
square, square,
res), res),
n * (n - 1))); n * (n - 1)));
...@@ -319,37 +319,37 @@ struct fixed31_32 dal_fixed31_32_sinc( ...@@ -319,37 +319,37 @@ struct fixed31_32 dal_fixed31_32_sinc(
} while (n > 2); } while (n > 2);
if (arg.value != arg_norm.value) if (arg.value != arg_norm.value)
res = dal_fixed31_32_div( res = dc_fixpt_div(
dal_fixed31_32_mul(res, arg_norm), dc_fixpt_mul(res, arg_norm),
arg); arg);
return res; return res;
} }
struct fixed31_32 dal_fixed31_32_sin( struct fixed31_32 dc_fixpt_sin(
struct fixed31_32 arg) struct fixed31_32 arg)
{ {
return dal_fixed31_32_mul( return dc_fixpt_mul(
arg, 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) struct fixed31_32 arg)
{ {
/* TODO implement argument normalization */ /* 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; int n = 26;
do { do {
res = dal_fixed31_32_sub( res = dc_fixpt_sub(
dal_fixed31_32_one, dc_fixpt_one,
dal_fixed31_32_div_int( dc_fixpt_div_int(
dal_fixed31_32_mul( dc_fixpt_mul(
square, square,
res), res),
n * (n - 1))); n * (n - 1)));
...@@ -372,31 +372,31 @@ static struct fixed31_32 fixed31_32_exp_from_taylor_series( ...@@ -372,31 +372,31 @@ static struct fixed31_32 fixed31_32_exp_from_taylor_series(
{ {
unsigned int n = 9; unsigned int n = 9;
struct fixed31_32 res = dal_fixed31_32_from_fraction( struct fixed31_32 res = dc_fixpt_from_fraction(
n + 2, n + 2,
n + 1); n + 1);
/* TODO find correct res */ /* TODO find correct res */
ASSERT(dal_fixed31_32_lt(arg, dal_fixed31_32_one)); ASSERT(dc_fixpt_lt(arg, dc_fixpt_one));
do do
res = dal_fixed31_32_add( res = dc_fixpt_add(
dal_fixed31_32_one, dc_fixpt_one,
dal_fixed31_32_div_int( dc_fixpt_div_int(
dal_fixed31_32_mul( dc_fixpt_mul(
arg, arg,
res), res),
n)); n));
while (--n != 1); while (--n != 1);
return dal_fixed31_32_add( return dc_fixpt_add(
dal_fixed31_32_one, dc_fixpt_one,
dal_fixed31_32_mul( dc_fixpt_mul(
arg, arg,
res)); res));
} }
struct fixed31_32 dal_fixed31_32_exp( struct fixed31_32 dc_fixpt_exp(
struct fixed31_32 arg) struct fixed31_32 arg)
{ {
/* /*
...@@ -406,44 +406,44 @@ struct fixed31_32 dal_fixed31_32_exp( ...@@ -406,44 +406,44 @@ struct fixed31_32 dal_fixed31_32_exp(
* where m = round(x / ln(2)), r = x - m * ln(2) * where m = round(x / ln(2)), r = x - m * ln(2)
*/ */
if (dal_fixed31_32_le( if (dc_fixpt_le(
dal_fixed31_32_ln2_div_2, dc_fixpt_ln2_div_2,
dal_fixed31_32_abs(arg))) { dc_fixpt_abs(arg))) {
int m = dal_fixed31_32_round( int m = dc_fixpt_round(
dal_fixed31_32_div( dc_fixpt_div(
arg, arg,
dal_fixed31_32_ln2)); dc_fixpt_ln2));
struct fixed31_32 r = dal_fixed31_32_sub( struct fixed31_32 r = dc_fixpt_sub(
arg, arg,
dal_fixed31_32_mul_int( dc_fixpt_mul_int(
dal_fixed31_32_ln2, dc_fixpt_ln2,
m)); m));
ASSERT(m != 0); ASSERT(m != 0);
ASSERT(dal_fixed31_32_lt( ASSERT(dc_fixpt_lt(
dal_fixed31_32_abs(r), dc_fixpt_abs(r),
dal_fixed31_32_one)); dc_fixpt_one));
if (m > 0) if (m > 0)
return dal_fixed31_32_shl( return dc_fixpt_shl(
fixed31_32_exp_from_taylor_series(r), fixed31_32_exp_from_taylor_series(r),
(unsigned char)m); (unsigned char)m);
else else
return dal_fixed31_32_div_int( return dc_fixpt_div_int(
fixed31_32_exp_from_taylor_series(r), fixed31_32_exp_from_taylor_series(r),
1LL << -m); 1LL << -m);
} else if (arg.value != 0) } else if (arg.value != 0)
return fixed31_32_exp_from_taylor_series(arg); return fixed31_32_exp_from_taylor_series(arg);
else 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 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 */ /* TODO improve 1st estimation */
struct fixed31_32 error; struct fixed31_32 error;
...@@ -453,15 +453,15 @@ struct fixed31_32 dal_fixed31_32_log( ...@@ -453,15 +453,15 @@ struct fixed31_32 dal_fixed31_32_log(
/* TODO if arg is zero, return -INF */ /* TODO if arg is zero, return -INF */
do { do {
struct fixed31_32 res1 = dal_fixed31_32_add( struct fixed31_32 res1 = dc_fixpt_add(
dal_fixed31_32_sub( dc_fixpt_sub(
res, res,
dal_fixed31_32_one), dc_fixpt_one),
dal_fixed31_32_div( dc_fixpt_div(
arg, arg,
dal_fixed31_32_exp(res))); dc_fixpt_exp(res)));
error = dal_fixed31_32_sub( error = dc_fixpt_sub(
res, res,
res1); res1);
...@@ -472,17 +472,17 @@ struct fixed31_32 dal_fixed31_32_log( ...@@ -472,17 +472,17 @@ struct fixed31_32 dal_fixed31_32_log(
return res; return res;
} }
struct fixed31_32 dal_fixed31_32_pow( struct fixed31_32 dc_fixpt_pow(
struct fixed31_32 arg1, struct fixed31_32 arg1,
struct fixed31_32 arg2) struct fixed31_32 arg2)
{ {
return dal_fixed31_32_exp( return dc_fixpt_exp(
dal_fixed31_32_mul( dc_fixpt_mul(
dal_fixed31_32_log(arg1), dc_fixpt_log(arg1),
arg2)); arg2));
} }
int dal_fixed31_32_floor( int dc_fixpt_floor(
struct fixed31_32 arg) struct fixed31_32 arg)
{ {
unsigned long long arg_value = abs_i64(arg.value); unsigned long long arg_value = abs_i64(arg.value);
...@@ -493,12 +493,12 @@ int dal_fixed31_32_floor( ...@@ -493,12 +493,12 @@ int dal_fixed31_32_floor(
return -(int)GET_INTEGER_PART(arg_value); return -(int)GET_INTEGER_PART(arg_value);
} }
int dal_fixed31_32_round( int dc_fixpt_round(
struct fixed31_32 arg) struct fixed31_32 arg)
{ {
unsigned long long arg_value = abs_i64(arg.value); 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); ASSERT(LLONG_MAX - (long long)arg_value >= summand);
...@@ -510,13 +510,13 @@ int dal_fixed31_32_round( ...@@ -510,13 +510,13 @@ int dal_fixed31_32_round(
return -(int)GET_INTEGER_PART(arg_value); return -(int)GET_INTEGER_PART(arg_value);
} }
int dal_fixed31_32_ceil( int dc_fixpt_ceil(
struct fixed31_32 arg) struct fixed31_32 arg)
{ {
unsigned long long arg_value = abs_i64(arg.value); unsigned long long arg_value = abs_i64(arg.value);
const long long summand = dal_fixed31_32_one.value - const long long summand = dc_fixpt_one.value -
dal_fixed31_32_epsilon.value; dc_fixpt_epsilon.value;
ASSERT(LLONG_MAX - (long long)arg_value >= summand); ASSERT(LLONG_MAX - (long long)arg_value >= summand);
...@@ -531,7 +531,7 @@ int dal_fixed31_32_ceil( ...@@ -531,7 +531,7 @@ int dal_fixed31_32_ceil(
/* this function is a generic helper to translate fixed point value to /* this function is a generic helper to translate fixed point value to
* specified integer format that will consist of integer_bits integer part and * specified integer format that will consist of integer_bits integer part and
* fractional_bits fractional part. For example it is used in * 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) * part in 32 bits. It is used in hw programming (scaler)
*/ */
...@@ -570,35 +570,35 @@ static inline unsigned int clamp_ux_dy( ...@@ -570,35 +570,35 @@ static inline unsigned int clamp_ux_dy(
return min_clamp; return min_clamp;
} }
unsigned int dal_fixed31_32_u2d19( unsigned int dc_fixpt_u2d19(
struct fixed31_32 arg) struct fixed31_32 arg)
{ {
return ux_dy(arg.value, 2, 19); return ux_dy(arg.value, 2, 19);
} }
unsigned int dal_fixed31_32_u0d19( unsigned int dc_fixpt_u0d19(
struct fixed31_32 arg) struct fixed31_32 arg)
{ {
return ux_dy(arg.value, 0, 19); return ux_dy(arg.value, 0, 19);
} }
unsigned int dal_fixed31_32_clamp_u0d14( unsigned int dc_fixpt_clamp_u0d14(
struct fixed31_32 arg) struct fixed31_32 arg)
{ {
return clamp_ux_dy(arg.value, 0, 14, 1); 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) struct fixed31_32 arg)
{ {
return clamp_ux_dy(arg.value, 0, 10, 1); return clamp_ux_dy(arg.value, 0, 10, 1);
} }
int dal_fixed31_32_s4d19( int dc_fixpt_s4d19(
struct fixed31_32 arg) struct fixed31_32 arg)
{ {
if (arg.value < 0) 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 else
return ux_dy(arg.value, 4, 19); return ux_dy(arg.value, 4, 19);
} }
/*
* 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;
}
...@@ -36,41 +36,41 @@ static bool build_custom_float( ...@@ -36,41 +36,41 @@ static bool build_custom_float(
uint32_t exp_offset = (1 << (format->exponenta_bits - 1)) - 1; uint32_t exp_offset = (1 << (format->exponenta_bits - 1)) - 1;
const struct fixed31_32 mantissa_constant_plus_max_fraction = const struct fixed31_32 mantissa_constant_plus_max_fraction =
dal_fixed31_32_from_fraction( dc_fixpt_from_fraction(
(1LL << (format->mantissa_bits + 1)) - 1, (1LL << (format->mantissa_bits + 1)) - 1,
1LL << format->mantissa_bits); 1LL << format->mantissa_bits);
struct fixed31_32 mantiss; struct fixed31_32 mantiss;
if (dal_fixed31_32_eq( if (dc_fixpt_eq(
value, value,
dal_fixed31_32_zero)) { dc_fixpt_zero)) {
*negative = false; *negative = false;
*mantissa = 0; *mantissa = 0;
*exponenta = 0; *exponenta = 0;
return true; return true;
} }
if (dal_fixed31_32_lt( if (dc_fixpt_lt(
value, value,
dal_fixed31_32_zero)) { dc_fixpt_zero)) {
*negative = format->sign; *negative = format->sign;
value = dal_fixed31_32_neg(value); value = dc_fixpt_neg(value);
} else { } else {
*negative = false; *negative = false;
} }
if (dal_fixed31_32_lt( if (dc_fixpt_lt(
value, value,
dal_fixed31_32_one)) { dc_fixpt_one)) {
uint32_t i = 1; uint32_t i = 1;
do { do {
value = dal_fixed31_32_shl(value, 1); value = dc_fixpt_shl(value, 1);
++i; ++i;
} while (dal_fixed31_32_lt( } while (dc_fixpt_lt(
value, value,
dal_fixed31_32_one)); dc_fixpt_one));
--i; --i;
...@@ -81,15 +81,15 @@ static bool build_custom_float( ...@@ -81,15 +81,15 @@ static bool build_custom_float(
} }
*exponenta = exp_offset - i; *exponenta = exp_offset - i;
} else if (dal_fixed31_32_le( } else if (dc_fixpt_le(
mantissa_constant_plus_max_fraction, mantissa_constant_plus_max_fraction,
value)) { value)) {
uint32_t i = 1; uint32_t i = 1;
do { do {
value = dal_fixed31_32_shr(value, 1); value = dc_fixpt_shr(value, 1);
++i; ++i;
} while (dal_fixed31_32_lt( } while (dc_fixpt_lt(
mantissa_constant_plus_max_fraction, mantissa_constant_plus_max_fraction,
value)); value));
...@@ -98,23 +98,23 @@ static bool build_custom_float( ...@@ -98,23 +98,23 @@ static bool build_custom_float(
*exponenta = exp_offset; *exponenta = exp_offset;
} }
mantiss = dal_fixed31_32_sub( mantiss = dc_fixpt_sub(
value, value,
dal_fixed31_32_one); dc_fixpt_one);
if (dal_fixed31_32_lt( if (dc_fixpt_lt(
mantiss, mantiss,
dal_fixed31_32_zero) || dc_fixpt_zero) ||
dal_fixed31_32_lt( dc_fixpt_lt(
dal_fixed31_32_one, dc_fixpt_one,
mantiss)) mantiss))
mantiss = dal_fixed31_32_zero; mantiss = dc_fixpt_zero;
else else
mantiss = dal_fixed31_32_shl( mantiss = dc_fixpt_shl(
mantiss, mantiss,
format->mantissa_bits); format->mantissa_bits);
*mantissa = dal_fixed31_32_floor(mantiss); *mantissa = dc_fixpt_floor(mantiss);
return true; return true;
} }
......
...@@ -873,14 +873,14 @@ bool dcn_validate_bandwidth( ...@@ -873,14 +873,14 @@ bool dcn_validate_bandwidth(
} }
if (pipe->plane_state->rotation % 2 == 0) { if (pipe->plane_state->rotation % 2 == 0) {
ASSERT(pipe->plane_res.scl_data.ratios.horz.value != dal_fixed31_32_one.value ASSERT(pipe->plane_res.scl_data.ratios.horz.value != dc_fixpt_one.value
|| v->scaler_rec_out_width[input_idx] == v->viewport_width[input_idx]); || v->scaler_rec_out_width[input_idx] == v->viewport_width[input_idx]);
ASSERT(pipe->plane_res.scl_data.ratios.vert.value != dal_fixed31_32_one.value ASSERT(pipe->plane_res.scl_data.ratios.vert.value != dc_fixpt_one.value
|| v->scaler_recout_height[input_idx] == v->viewport_height[input_idx]); || v->scaler_recout_height[input_idx] == v->viewport_height[input_idx]);
} else { } else {
ASSERT(pipe->plane_res.scl_data.ratios.horz.value != dal_fixed31_32_one.value ASSERT(pipe->plane_res.scl_data.ratios.horz.value != dc_fixpt_one.value
|| v->scaler_recout_height[input_idx] == v->viewport_width[input_idx]); || v->scaler_recout_height[input_idx] == v->viewport_width[input_idx]);
ASSERT(pipe->plane_res.scl_data.ratios.vert.value != dal_fixed31_32_one.value ASSERT(pipe->plane_res.scl_data.ratios.vert.value != dc_fixpt_one.value
|| v->scaler_rec_out_width[input_idx] == v->viewport_height[input_idx]); || v->scaler_rec_out_width[input_idx] == v->viewport_height[input_idx]);
} }
v->dcc_enable[input_idx] = pipe->plane_state->dcc.enable ? dcn_bw_yes : dcn_bw_no; v->dcc_enable[input_idx] = pipe->plane_state->dcc.enable ? dcn_bw_yes : dcn_bw_no;
......
...@@ -631,7 +631,7 @@ bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason) ...@@ -631,7 +631,7 @@ bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason)
/* Need to setup mst link_cap struct here /* Need to setup mst link_cap struct here
* otherwise dc_link_detect() will leave mst link_cap * otherwise dc_link_detect() will leave mst link_cap
* empty which leads to allocate_mst_payload() has "0" * empty which leads to allocate_mst_payload() has "0"
* pbn_per_slot value leading to exception on dal_fixed31_32_div() * pbn_per_slot value leading to exception on dc_fixpt_div()
*/ */
link->verified_link_cap = link->reported_link_cap; link->verified_link_cap = link->reported_link_cap;
return false; return false;
...@@ -2059,10 +2059,10 @@ static struct fixed31_32 get_pbn_per_slot(struct dc_stream_state *stream) ...@@ -2059,10 +2059,10 @@ static struct fixed31_32 get_pbn_per_slot(struct dc_stream_state *stream)
&stream->sink->link->cur_link_settings; &stream->sink->link->cur_link_settings;
uint32_t link_rate_in_mbps = uint32_t link_rate_in_mbps =
link_settings->link_rate * LINK_RATE_REF_FREQ_IN_MHZ; link_settings->link_rate * LINK_RATE_REF_FREQ_IN_MHZ;
struct fixed31_32 mbps = dal_fixed31_32_from_int( struct fixed31_32 mbps = dc_fixpt_from_int(
link_rate_in_mbps * link_settings->lane_count); link_rate_in_mbps * link_settings->lane_count);
return dal_fixed31_32_div_int(mbps, 54); return dc_fixpt_div_int(mbps, 54);
} }
static int get_color_depth(enum dc_color_depth color_depth) static int get_color_depth(enum dc_color_depth color_depth)
...@@ -2103,7 +2103,7 @@ static struct fixed31_32 get_pbn_from_timing(struct pipe_ctx *pipe_ctx) ...@@ -2103,7 +2103,7 @@ static struct fixed31_32 get_pbn_from_timing(struct pipe_ctx *pipe_ctx)
numerator = 64 * PEAK_FACTOR_X1000; numerator = 64 * PEAK_FACTOR_X1000;
denominator = 54 * 8 * 1000 * 1000; denominator = 54 * 8 * 1000 * 1000;
kbps *= numerator; kbps *= numerator;
peak_kbps = dal_fixed31_32_from_fraction(kbps, denominator); peak_kbps = dc_fixpt_from_fraction(kbps, denominator);
return peak_kbps; return peak_kbps;
} }
...@@ -2230,7 +2230,7 @@ static enum dc_status allocate_mst_payload(struct pipe_ctx *pipe_ctx) ...@@ -2230,7 +2230,7 @@ static enum dc_status allocate_mst_payload(struct pipe_ctx *pipe_ctx)
/* slot X.Y for only current stream */ /* slot X.Y for only current stream */
pbn_per_slot = get_pbn_per_slot(stream); pbn_per_slot = get_pbn_per_slot(stream);
pbn = get_pbn_from_timing(pipe_ctx); pbn = get_pbn_from_timing(pipe_ctx);
avg_time_slots_per_mtp = dal_fixed31_32_div(pbn, pbn_per_slot); avg_time_slots_per_mtp = dc_fixpt_div(pbn, pbn_per_slot);
stream_encoder->funcs->set_mst_bandwidth( stream_encoder->funcs->set_mst_bandwidth(
stream_encoder, stream_encoder,
...@@ -2247,7 +2247,7 @@ static enum dc_status deallocate_mst_payload(struct pipe_ctx *pipe_ctx) ...@@ -2247,7 +2247,7 @@ static enum dc_status deallocate_mst_payload(struct pipe_ctx *pipe_ctx)
struct link_encoder *link_encoder = link->link_enc; struct link_encoder *link_encoder = link->link_enc;
struct stream_encoder *stream_encoder = pipe_ctx->stream_res.stream_enc; struct stream_encoder *stream_encoder = pipe_ctx->stream_res.stream_enc;
struct dp_mst_stream_allocation_table proposed_table = {0}; struct dp_mst_stream_allocation_table proposed_table = {0};
struct fixed31_32 avg_time_slots_per_mtp = dal_fixed31_32_from_int(0); struct fixed31_32 avg_time_slots_per_mtp = dc_fixpt_from_int(0);
uint8_t i; uint8_t i;
bool mst_mode = (link->type == dc_connection_mst_branch); bool mst_mode = (link->type == dc_connection_mst_branch);
DC_LOGGER_INIT(link->ctx->logger); DC_LOGGER_INIT(link->ctx->logger);
......
...@@ -496,9 +496,9 @@ static void calculate_viewport(struct pipe_ctx *pipe_ctx) ...@@ -496,9 +496,9 @@ static void calculate_viewport(struct pipe_ctx *pipe_ctx)
data->viewport_c.x = data->viewport.x / vpc_div; data->viewport_c.x = data->viewport.x / vpc_div;
data->viewport_c.y = data->viewport.y / vpc_div; data->viewport_c.y = data->viewport.y / vpc_div;
data->inits.h_c = (data->viewport.x % vpc_div) != 0 ? data->inits.h_c = (data->viewport.x % vpc_div) != 0 ?
dal_fixed31_32_half : dal_fixed31_32_zero; dc_fixpt_half : dc_fixpt_zero;
data->inits.v_c = (data->viewport.y % vpc_div) != 0 ? data->inits.v_c = (data->viewport.y % vpc_div) != 0 ?
dal_fixed31_32_half : dal_fixed31_32_zero; dc_fixpt_half : dc_fixpt_zero;
/* Round up, assume original video size always even dimensions */ /* Round up, assume original video size always even dimensions */
data->viewport_c.width = (data->viewport.width + vpc_div - 1) / vpc_div; data->viewport_c.width = (data->viewport.width + vpc_div - 1) / vpc_div;
data->viewport_c.height = (data->viewport.height + vpc_div - 1) / vpc_div; data->viewport_c.height = (data->viewport.height + vpc_div - 1) / vpc_div;
...@@ -627,10 +627,10 @@ static void calculate_scaling_ratios(struct pipe_ctx *pipe_ctx) ...@@ -627,10 +627,10 @@ static void calculate_scaling_ratios(struct pipe_ctx *pipe_ctx)
pipe_ctx->plane_state->rotation == ROTATION_ANGLE_270) pipe_ctx->plane_state->rotation == ROTATION_ANGLE_270)
rect_swap_helper(&surf_src); rect_swap_helper(&surf_src);
pipe_ctx->plane_res.scl_data.ratios.horz = dal_fixed31_32_from_fraction( pipe_ctx->plane_res.scl_data.ratios.horz = dc_fixpt_from_fraction(
surf_src.width, surf_src.width,
plane_state->dst_rect.width); plane_state->dst_rect.width);
pipe_ctx->plane_res.scl_data.ratios.vert = dal_fixed31_32_from_fraction( pipe_ctx->plane_res.scl_data.ratios.vert = dc_fixpt_from_fraction(
surf_src.height, surf_src.height,
plane_state->dst_rect.height); plane_state->dst_rect.height);
...@@ -688,32 +688,32 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r ...@@ -688,32 +688,32 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r
* init_bot = init + scaling_ratio * init_bot = init + scaling_ratio
* init_c = init + truncated_vp_c_offset(from calculate viewport) * init_c = init + truncated_vp_c_offset(from calculate viewport)
*/ */
data->inits.h = dal_fixed31_32_div_int( data->inits.h = dc_fixpt_div_int(
dal_fixed31_32_add_int(data->ratios.horz, data->taps.h_taps + 1), 2); dc_fixpt_add_int(data->ratios.horz, data->taps.h_taps + 1), 2);
data->inits.h_c = dal_fixed31_32_add(data->inits.h_c, dal_fixed31_32_div_int( data->inits.h_c = dc_fixpt_add(data->inits.h_c, dc_fixpt_div_int(
dal_fixed31_32_add_int(data->ratios.horz_c, data->taps.h_taps_c + 1), 2)); dc_fixpt_add_int(data->ratios.horz_c, data->taps.h_taps_c + 1), 2));
data->inits.v = dal_fixed31_32_div_int( data->inits.v = dc_fixpt_div_int(
dal_fixed31_32_add_int(data->ratios.vert, data->taps.v_taps + 1), 2); dc_fixpt_add_int(data->ratios.vert, data->taps.v_taps + 1), 2);
data->inits.v_c = dal_fixed31_32_add(data->inits.v_c, dal_fixed31_32_div_int( data->inits.v_c = dc_fixpt_add(data->inits.v_c, dc_fixpt_div_int(
dal_fixed31_32_add_int(data->ratios.vert_c, data->taps.v_taps_c + 1), 2)); dc_fixpt_add_int(data->ratios.vert_c, data->taps.v_taps_c + 1), 2));
/* Adjust for viewport end clip-off */ /* Adjust for viewport end clip-off */
if ((data->viewport.x + data->viewport.width) < (src.x + src.width) && !flip_horz_scan_dir) { if ((data->viewport.x + data->viewport.width) < (src.x + src.width) && !flip_horz_scan_dir) {
int vp_clip = src.x + src.width - data->viewport.width - data->viewport.x; int vp_clip = src.x + src.width - data->viewport.width - data->viewport.x;
int int_part = dal_fixed31_32_floor( int int_part = dc_fixpt_floor(
dal_fixed31_32_sub(data->inits.h, data->ratios.horz)); dc_fixpt_sub(data->inits.h, data->ratios.horz));
int_part = int_part > 0 ? int_part : 0; int_part = int_part > 0 ? int_part : 0;
data->viewport.width += int_part < vp_clip ? int_part : vp_clip; data->viewport.width += int_part < vp_clip ? int_part : vp_clip;
} }
if ((data->viewport.y + data->viewport.height) < (src.y + src.height) && !flip_vert_scan_dir) { if ((data->viewport.y + data->viewport.height) < (src.y + src.height) && !flip_vert_scan_dir) {
int vp_clip = src.y + src.height - data->viewport.height - data->viewport.y; int vp_clip = src.y + src.height - data->viewport.height - data->viewport.y;
int int_part = dal_fixed31_32_floor( int int_part = dc_fixpt_floor(
dal_fixed31_32_sub(data->inits.v, data->ratios.vert)); dc_fixpt_sub(data->inits.v, data->ratios.vert));
int_part = int_part > 0 ? int_part : 0; int_part = int_part > 0 ? int_part : 0;
data->viewport.height += int_part < vp_clip ? int_part : vp_clip; data->viewport.height += int_part < vp_clip ? int_part : vp_clip;
...@@ -721,8 +721,8 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r ...@@ -721,8 +721,8 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r
if ((data->viewport_c.x + data->viewport_c.width) < (src.x + src.width) / vpc_div && !flip_horz_scan_dir) { if ((data->viewport_c.x + data->viewport_c.width) < (src.x + src.width) / vpc_div && !flip_horz_scan_dir) {
int vp_clip = (src.x + src.width) / vpc_div - int vp_clip = (src.x + src.width) / vpc_div -
data->viewport_c.width - data->viewport_c.x; data->viewport_c.width - data->viewport_c.x;
int int_part = dal_fixed31_32_floor( int int_part = dc_fixpt_floor(
dal_fixed31_32_sub(data->inits.h_c, data->ratios.horz_c)); dc_fixpt_sub(data->inits.h_c, data->ratios.horz_c));
int_part = int_part > 0 ? int_part : 0; int_part = int_part > 0 ? int_part : 0;
data->viewport_c.width += int_part < vp_clip ? int_part : vp_clip; data->viewport_c.width += int_part < vp_clip ? int_part : vp_clip;
...@@ -730,8 +730,8 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r ...@@ -730,8 +730,8 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r
if ((data->viewport_c.y + data->viewport_c.height) < (src.y + src.height) / vpc_div && !flip_vert_scan_dir) { if ((data->viewport_c.y + data->viewport_c.height) < (src.y + src.height) / vpc_div && !flip_vert_scan_dir) {
int vp_clip = (src.y + src.height) / vpc_div - int vp_clip = (src.y + src.height) / vpc_div -
data->viewport_c.height - data->viewport_c.y; data->viewport_c.height - data->viewport_c.y;
int int_part = dal_fixed31_32_floor( int int_part = dc_fixpt_floor(
dal_fixed31_32_sub(data->inits.v_c, data->ratios.vert_c)); dc_fixpt_sub(data->inits.v_c, data->ratios.vert_c));
int_part = int_part > 0 ? int_part : 0; int_part = int_part > 0 ? int_part : 0;
data->viewport_c.height += int_part < vp_clip ? int_part : vp_clip; data->viewport_c.height += int_part < vp_clip ? int_part : vp_clip;
...@@ -741,9 +741,9 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r ...@@ -741,9 +741,9 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r
if (data->viewport.x && !flip_horz_scan_dir) { if (data->viewport.x && !flip_horz_scan_dir) {
int int_part; int int_part;
data->inits.h = dal_fixed31_32_add(data->inits.h, dal_fixed31_32_mul_int( data->inits.h = dc_fixpt_add(data->inits.h, dc_fixpt_mul_int(
data->ratios.horz, recout_skip->width)); data->ratios.horz, recout_skip->width));
int_part = dal_fixed31_32_floor(data->inits.h) - data->viewport.x; int_part = dc_fixpt_floor(data->inits.h) - data->viewport.x;
if (int_part < data->taps.h_taps) { if (int_part < data->taps.h_taps) {
int int_adj = data->viewport.x >= (data->taps.h_taps - int_part) ? int int_adj = data->viewport.x >= (data->taps.h_taps - int_part) ?
(data->taps.h_taps - int_part) : data->viewport.x; (data->taps.h_taps - int_part) : data->viewport.x;
...@@ -756,15 +756,15 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r ...@@ -756,15 +756,15 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r
int_part = data->taps.h_taps; int_part = data->taps.h_taps;
} }
data->inits.h.value &= 0xffffffff; data->inits.h.value &= 0xffffffff;
data->inits.h = dal_fixed31_32_add_int(data->inits.h, int_part); data->inits.h = dc_fixpt_add_int(data->inits.h, int_part);
} }
if (data->viewport_c.x && !flip_horz_scan_dir) { if (data->viewport_c.x && !flip_horz_scan_dir) {
int int_part; int int_part;
data->inits.h_c = dal_fixed31_32_add(data->inits.h_c, dal_fixed31_32_mul_int( data->inits.h_c = dc_fixpt_add(data->inits.h_c, dc_fixpt_mul_int(
data->ratios.horz_c, recout_skip->width)); data->ratios.horz_c, recout_skip->width));
int_part = dal_fixed31_32_floor(data->inits.h_c) - data->viewport_c.x; int_part = dc_fixpt_floor(data->inits.h_c) - data->viewport_c.x;
if (int_part < data->taps.h_taps_c) { if (int_part < data->taps.h_taps_c) {
int int_adj = data->viewport_c.x >= (data->taps.h_taps_c - int_part) ? int int_adj = data->viewport_c.x >= (data->taps.h_taps_c - int_part) ?
(data->taps.h_taps_c - int_part) : data->viewport_c.x; (data->taps.h_taps_c - int_part) : data->viewport_c.x;
...@@ -777,15 +777,15 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r ...@@ -777,15 +777,15 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r
int_part = data->taps.h_taps_c; int_part = data->taps.h_taps_c;
} }
data->inits.h_c.value &= 0xffffffff; data->inits.h_c.value &= 0xffffffff;
data->inits.h_c = dal_fixed31_32_add_int(data->inits.h_c, int_part); data->inits.h_c = dc_fixpt_add_int(data->inits.h_c, int_part);
} }
if (data->viewport.y && !flip_vert_scan_dir) { if (data->viewport.y && !flip_vert_scan_dir) {
int int_part; int int_part;
data->inits.v = dal_fixed31_32_add(data->inits.v, dal_fixed31_32_mul_int( data->inits.v = dc_fixpt_add(data->inits.v, dc_fixpt_mul_int(
data->ratios.vert, recout_skip->height)); data->ratios.vert, recout_skip->height));
int_part = dal_fixed31_32_floor(data->inits.v) - data->viewport.y; int_part = dc_fixpt_floor(data->inits.v) - data->viewport.y;
if (int_part < data->taps.v_taps) { if (int_part < data->taps.v_taps) {
int int_adj = data->viewport.y >= (data->taps.v_taps - int_part) ? int int_adj = data->viewport.y >= (data->taps.v_taps - int_part) ?
(data->taps.v_taps - int_part) : data->viewport.y; (data->taps.v_taps - int_part) : data->viewport.y;
...@@ -798,15 +798,15 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r ...@@ -798,15 +798,15 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r
int_part = data->taps.v_taps; int_part = data->taps.v_taps;
} }
data->inits.v.value &= 0xffffffff; data->inits.v.value &= 0xffffffff;
data->inits.v = dal_fixed31_32_add_int(data->inits.v, int_part); data->inits.v = dc_fixpt_add_int(data->inits.v, int_part);
} }
if (data->viewport_c.y && !flip_vert_scan_dir) { if (data->viewport_c.y && !flip_vert_scan_dir) {
int int_part; int int_part;
data->inits.v_c = dal_fixed31_32_add(data->inits.v_c, dal_fixed31_32_mul_int( data->inits.v_c = dc_fixpt_add(data->inits.v_c, dc_fixpt_mul_int(
data->ratios.vert_c, recout_skip->height)); data->ratios.vert_c, recout_skip->height));
int_part = dal_fixed31_32_floor(data->inits.v_c) - data->viewport_c.y; int_part = dc_fixpt_floor(data->inits.v_c) - data->viewport_c.y;
if (int_part < data->taps.v_taps_c) { if (int_part < data->taps.v_taps_c) {
int int_adj = data->viewport_c.y >= (data->taps.v_taps_c - int_part) ? int int_adj = data->viewport_c.y >= (data->taps.v_taps_c - int_part) ?
(data->taps.v_taps_c - int_part) : data->viewport_c.y; (data->taps.v_taps_c - int_part) : data->viewport_c.y;
...@@ -819,12 +819,12 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r ...@@ -819,12 +819,12 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r
int_part = data->taps.v_taps_c; int_part = data->taps.v_taps_c;
} }
data->inits.v_c.value &= 0xffffffff; data->inits.v_c.value &= 0xffffffff;
data->inits.v_c = dal_fixed31_32_add_int(data->inits.v_c, int_part); data->inits.v_c = dc_fixpt_add_int(data->inits.v_c, int_part);
} }
/* Interlaced inits based on final vert inits */ /* Interlaced inits based on final vert inits */
data->inits.v_bot = dal_fixed31_32_add(data->inits.v, data->ratios.vert); data->inits.v_bot = dc_fixpt_add(data->inits.v, data->ratios.vert);
data->inits.v_c_bot = dal_fixed31_32_add(data->inits.v_c, data->ratios.vert_c); data->inits.v_c_bot = dc_fixpt_add(data->inits.v_c, data->ratios.vert_c);
if (pipe_ctx->plane_state->rotation == ROTATION_ANGLE_90 || if (pipe_ctx->plane_state->rotation == ROTATION_ANGLE_90 ||
pipe_ctx->plane_state->rotation == ROTATION_ANGLE_270) { pipe_ctx->plane_state->rotation == ROTATION_ANGLE_270) {
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#ifndef DC_DP_TYPES_H #ifndef DC_DP_TYPES_H
#define DC_DP_TYPES_H #define DC_DP_TYPES_H
#include "os_types.h"
enum dc_lane_count { enum dc_lane_count {
LANE_COUNT_UNKNOWN = 0, LANE_COUNT_UNKNOWN = 0,
LANE_COUNT_ONE = 1, LANE_COUNT_ONE = 1,
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#ifndef DC_TYPES_H_ #ifndef DC_TYPES_H_
#define DC_TYPES_H_ #define DC_TYPES_H_
#include "fixed32_32.h" #include "os_types.h"
#include "fixed31_32.h" #include "fixed31_32.h"
#include "irq_types.h" #include "irq_types.h"
#include "dc_dp_types.h" #include "dc_dp_types.h"
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "dce_abm.h" #include "dce_abm.h"
#include "dm_services.h" #include "dm_services.h"
#include "reg_helper.h" #include "reg_helper.h"
#include "fixed32_32.h" #include "fixed31_32.h"
#include "dc.h" #include "dc.h"
#include "atom.h" #include "atom.h"
......
...@@ -657,12 +657,12 @@ static uint32_t dce110_get_d_to_pixel_rate_in_hz( ...@@ -657,12 +657,12 @@ static uint32_t dce110_get_d_to_pixel_rate_in_hz(
return 0; return 0;
} }
pix_rate = dal_fixed31_32_from_int(clk_src->ref_freq_khz); pix_rate = dc_fixpt_from_int(clk_src->ref_freq_khz);
pix_rate = dal_fixed31_32_mul_int(pix_rate, 1000); pix_rate = dc_fixpt_mul_int(pix_rate, 1000);
pix_rate = dal_fixed31_32_mul_int(pix_rate, phase); pix_rate = dc_fixpt_mul_int(pix_rate, phase);
pix_rate = dal_fixed31_32_div_int(pix_rate, modulo); pix_rate = dc_fixpt_div_int(pix_rate, modulo);
return dal_fixed31_32_round(pix_rate); return dc_fixpt_round(pix_rate);
} else { } else {
return dce110_get_dp_pixel_rate_from_combo_phy_pll(cs, pix_clk_params, pll_settings); return dce110_get_dp_pixel_rate_from_combo_phy_pll(cs, pix_clk_params, pll_settings);
} }
...@@ -711,12 +711,12 @@ static bool calculate_ss( ...@@ -711,12 +711,12 @@ static bool calculate_ss(
const struct spread_spectrum_data *ss_data, const struct spread_spectrum_data *ss_data,
struct delta_sigma_data *ds_data) struct delta_sigma_data *ds_data)
{ {
struct fixed32_32 fb_div; struct fixed31_32 fb_div;
struct fixed32_32 ss_amount; struct fixed31_32 ss_amount;
struct fixed32_32 ss_nslip_amount; struct fixed31_32 ss_nslip_amount;
struct fixed32_32 ss_ds_frac_amount; struct fixed31_32 ss_ds_frac_amount;
struct fixed32_32 ss_step_size; struct fixed31_32 ss_step_size;
struct fixed32_32 modulation_time; struct fixed31_32 modulation_time;
if (ds_data == NULL) if (ds_data == NULL)
return false; return false;
...@@ -731,42 +731,42 @@ static bool calculate_ss( ...@@ -731,42 +731,42 @@ static bool calculate_ss(
/* compute SS_AMOUNT_FBDIV & SS_AMOUNT_NFRAC_SLIP & SS_AMOUNT_DSFRAC*/ /* compute SS_AMOUNT_FBDIV & SS_AMOUNT_NFRAC_SLIP & SS_AMOUNT_DSFRAC*/
/* 6 decimal point support in fractional feedback divider */ /* 6 decimal point support in fractional feedback divider */
fb_div = dal_fixed32_32_from_fraction( fb_div = dc_fixpt_from_fraction(
pll_settings->fract_feedback_divider, 1000000); pll_settings->fract_feedback_divider, 1000000);
fb_div = dal_fixed32_32_add_int(fb_div, pll_settings->feedback_divider); fb_div = dc_fixpt_add_int(fb_div, pll_settings->feedback_divider);
ds_data->ds_frac_amount = 0; ds_data->ds_frac_amount = 0;
/*spreadSpectrumPercentage is in the unit of .01%, /*spreadSpectrumPercentage is in the unit of .01%,
* so have to divided by 100 * 100*/ * so have to divided by 100 * 100*/
ss_amount = dal_fixed32_32_mul( ss_amount = dc_fixpt_mul(
fb_div, dal_fixed32_32_from_fraction(ss_data->percentage, fb_div, dc_fixpt_from_fraction(ss_data->percentage,
100 * ss_data->percentage_divider)); 100 * ss_data->percentage_divider));
ds_data->feedback_amount = dal_fixed32_32_floor(ss_amount); ds_data->feedback_amount = dc_fixpt_floor(ss_amount);
ss_nslip_amount = dal_fixed32_32_sub(ss_amount, ss_nslip_amount = dc_fixpt_sub(ss_amount,
dal_fixed32_32_from_int(ds_data->feedback_amount)); dc_fixpt_from_int(ds_data->feedback_amount));
ss_nslip_amount = dal_fixed32_32_mul_int(ss_nslip_amount, 10); ss_nslip_amount = dc_fixpt_mul_int(ss_nslip_amount, 10);
ds_data->nfrac_amount = dal_fixed32_32_floor(ss_nslip_amount); ds_data->nfrac_amount = dc_fixpt_floor(ss_nslip_amount);
ss_ds_frac_amount = dal_fixed32_32_sub(ss_nslip_amount, ss_ds_frac_amount = dc_fixpt_sub(ss_nslip_amount,
dal_fixed32_32_from_int(ds_data->nfrac_amount)); dc_fixpt_from_int(ds_data->nfrac_amount));
ss_ds_frac_amount = dal_fixed32_32_mul_int(ss_ds_frac_amount, 65536); ss_ds_frac_amount = dc_fixpt_mul_int(ss_ds_frac_amount, 65536);
ds_data->ds_frac_amount = dal_fixed32_32_floor(ss_ds_frac_amount); ds_data->ds_frac_amount = dc_fixpt_floor(ss_ds_frac_amount);
/* compute SS_STEP_SIZE_DSFRAC */ /* compute SS_STEP_SIZE_DSFRAC */
modulation_time = dal_fixed32_32_from_fraction( modulation_time = dc_fixpt_from_fraction(
pll_settings->reference_freq * 1000, pll_settings->reference_freq * 1000,
pll_settings->reference_divider * ss_data->modulation_freq_hz); pll_settings->reference_divider * ss_data->modulation_freq_hz);
if (ss_data->flags.CENTER_SPREAD) if (ss_data->flags.CENTER_SPREAD)
modulation_time = dal_fixed32_32_div_int(modulation_time, 4); modulation_time = dc_fixpt_div_int(modulation_time, 4);
else else
modulation_time = dal_fixed32_32_div_int(modulation_time, 2); modulation_time = dc_fixpt_div_int(modulation_time, 2);
ss_step_size = dal_fixed32_32_div(ss_amount, modulation_time); ss_step_size = dc_fixpt_div(ss_amount, modulation_time);
/* SS_STEP_SIZE_DSFRAC_DEC = Int(SS_STEP_SIZE * 2 ^ 16 * 10)*/ /* SS_STEP_SIZE_DSFRAC_DEC = Int(SS_STEP_SIZE * 2 ^ 16 * 10)*/
ss_step_size = dal_fixed32_32_mul_int(ss_step_size, 65536 * 10); ss_step_size = dc_fixpt_mul_int(ss_step_size, 65536 * 10);
ds_data->ds_frac_size = dal_fixed32_32_floor(ss_step_size); ds_data->ds_frac_size = dc_fixpt_floor(ss_step_size);
return true; return true;
} }
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "dce_clocks.h" #include "dce_clocks.h"
#include "dm_services.h" #include "dm_services.h"
#include "reg_helper.h" #include "reg_helper.h"
#include "fixed32_32.h" #include "fixed31_32.h"
#include "bios_parser_interface.h" #include "bios_parser_interface.h"
#include "dc.h" #include "dc.h"
#include "dmcu.h" #include "dmcu.h"
...@@ -228,19 +228,19 @@ static int dce_clocks_get_dp_ref_freq(struct display_clock *clk) ...@@ -228,19 +228,19 @@ static int dce_clocks_get_dp_ref_freq(struct display_clock *clk)
generated according to average value (case as with previous ASICs) generated according to average value (case as with previous ASICs)
*/ */
if (clk_dce->ss_on_dprefclk && clk_dce->dprefclk_ss_divider != 0) { if (clk_dce->ss_on_dprefclk && clk_dce->dprefclk_ss_divider != 0) {
struct fixed32_32 ss_percentage = dal_fixed32_32_div_int( struct fixed31_32 ss_percentage = dc_fixpt_div_int(
dal_fixed32_32_from_fraction( dc_fixpt_from_fraction(
clk_dce->dprefclk_ss_percentage, clk_dce->dprefclk_ss_percentage,
clk_dce->dprefclk_ss_divider), 200); clk_dce->dprefclk_ss_divider), 200);
struct fixed32_32 adj_dp_ref_clk_khz; struct fixed31_32 adj_dp_ref_clk_khz;
ss_percentage = dal_fixed32_32_sub(dal_fixed32_32_one, ss_percentage = dc_fixpt_sub(dc_fixpt_one,
ss_percentage); ss_percentage);
adj_dp_ref_clk_khz = adj_dp_ref_clk_khz =
dal_fixed32_32_mul_int( dc_fixpt_mul_int(
ss_percentage, ss_percentage,
dp_ref_clk_khz); dp_ref_clk_khz);
dp_ref_clk_khz = dal_fixed32_32_floor(adj_dp_ref_clk_khz); dp_ref_clk_khz = dc_fixpt_floor(adj_dp_ref_clk_khz);
} }
return dp_ref_clk_khz; return dp_ref_clk_khz;
...@@ -256,19 +256,19 @@ static int dce_clocks_get_dp_ref_freq_wrkaround(struct display_clock *clk) ...@@ -256,19 +256,19 @@ static int dce_clocks_get_dp_ref_freq_wrkaround(struct display_clock *clk)
int dp_ref_clk_khz = 600000; int dp_ref_clk_khz = 600000;
if (clk_dce->ss_on_dprefclk && clk_dce->dprefclk_ss_divider != 0) { if (clk_dce->ss_on_dprefclk && clk_dce->dprefclk_ss_divider != 0) {
struct fixed32_32 ss_percentage = dal_fixed32_32_div_int( struct fixed31_32 ss_percentage = dc_fixpt_div_int(
dal_fixed32_32_from_fraction( dc_fixpt_from_fraction(
clk_dce->dprefclk_ss_percentage, clk_dce->dprefclk_ss_percentage,
clk_dce->dprefclk_ss_divider), 200); clk_dce->dprefclk_ss_divider), 200);
struct fixed32_32 adj_dp_ref_clk_khz; struct fixed31_32 adj_dp_ref_clk_khz;
ss_percentage = dal_fixed32_32_sub(dal_fixed32_32_one, ss_percentage = dc_fixpt_sub(dc_fixpt_one,
ss_percentage); ss_percentage);
adj_dp_ref_clk_khz = adj_dp_ref_clk_khz =
dal_fixed32_32_mul_int( dc_fixpt_mul_int(
ss_percentage, ss_percentage,
dp_ref_clk_khz); dp_ref_clk_khz);
dp_ref_clk_khz = dal_fixed32_32_floor(adj_dp_ref_clk_khz); dp_ref_clk_khz = dc_fixpt_floor(adj_dp_ref_clk_khz);
} }
return dp_ref_clk_khz; return dp_ref_clk_khz;
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "dce_dmcu.h" #include "dce_dmcu.h"
#include "dm_services.h" #include "dm_services.h"
#include "reg_helper.h" #include "reg_helper.h"
#include "fixed32_32.h" #include "fixed31_32.h"
#include "dc.h" #include "dc.h"
#define TO_DCE_DMCU(dmcu)\ #define TO_DCE_DMCU(dmcu)\
......
...@@ -195,13 +195,13 @@ static void dce_ipp_program_input_lut( ...@@ -195,13 +195,13 @@ static void dce_ipp_program_input_lut(
for (i = 0; i < gamma->num_entries; i++) { for (i = 0; i < gamma->num_entries; i++) {
REG_SET(DC_LUT_SEQ_COLOR, 0, DC_LUT_SEQ_COLOR, REG_SET(DC_LUT_SEQ_COLOR, 0, DC_LUT_SEQ_COLOR,
dal_fixed31_32_round( dc_fixpt_round(
gamma->entries.red[i])); gamma->entries.red[i]));
REG_SET(DC_LUT_SEQ_COLOR, 0, DC_LUT_SEQ_COLOR, REG_SET(DC_LUT_SEQ_COLOR, 0, DC_LUT_SEQ_COLOR,
dal_fixed31_32_round( dc_fixpt_round(
gamma->entries.green[i])); gamma->entries.green[i]));
REG_SET(DC_LUT_SEQ_COLOR, 0, DC_LUT_SEQ_COLOR, REG_SET(DC_LUT_SEQ_COLOR, 0, DC_LUT_SEQ_COLOR,
dal_fixed31_32_round( dc_fixpt_round(
gamma->entries.blue[i])); gamma->entries.blue[i]));
} }
......
...@@ -1014,11 +1014,11 @@ static const uint16_t filter_8tap_64p_183[264] = { ...@@ -1014,11 +1014,11 @@ static const uint16_t filter_8tap_64p_183[264] = {
const uint16_t *get_filter_3tap_16p(struct fixed31_32 ratio) const uint16_t *get_filter_3tap_16p(struct fixed31_32 ratio)
{ {
if (ratio.value < dal_fixed31_32_one.value) if (ratio.value < dc_fixpt_one.value)
return filter_3tap_16p_upscale; return filter_3tap_16p_upscale;
else if (ratio.value < dal_fixed31_32_from_fraction(4, 3).value) else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
return filter_3tap_16p_117; return filter_3tap_16p_117;
else if (ratio.value < dal_fixed31_32_from_fraction(5, 3).value) else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
return filter_3tap_16p_150; return filter_3tap_16p_150;
else else
return filter_3tap_16p_183; return filter_3tap_16p_183;
...@@ -1026,11 +1026,11 @@ const uint16_t *get_filter_3tap_16p(struct fixed31_32 ratio) ...@@ -1026,11 +1026,11 @@ const uint16_t *get_filter_3tap_16p(struct fixed31_32 ratio)
const uint16_t *get_filter_3tap_64p(struct fixed31_32 ratio) const uint16_t *get_filter_3tap_64p(struct fixed31_32 ratio)
{ {
if (ratio.value < dal_fixed31_32_one.value) if (ratio.value < dc_fixpt_one.value)
return filter_3tap_64p_upscale; return filter_3tap_64p_upscale;
else if (ratio.value < dal_fixed31_32_from_fraction(4, 3).value) else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
return filter_3tap_64p_117; return filter_3tap_64p_117;
else if (ratio.value < dal_fixed31_32_from_fraction(5, 3).value) else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
return filter_3tap_64p_150; return filter_3tap_64p_150;
else else
return filter_3tap_64p_183; return filter_3tap_64p_183;
...@@ -1038,11 +1038,11 @@ const uint16_t *get_filter_3tap_64p(struct fixed31_32 ratio) ...@@ -1038,11 +1038,11 @@ const uint16_t *get_filter_3tap_64p(struct fixed31_32 ratio)
const uint16_t *get_filter_4tap_16p(struct fixed31_32 ratio) const uint16_t *get_filter_4tap_16p(struct fixed31_32 ratio)
{ {
if (ratio.value < dal_fixed31_32_one.value) if (ratio.value < dc_fixpt_one.value)
return filter_4tap_16p_upscale; return filter_4tap_16p_upscale;
else if (ratio.value < dal_fixed31_32_from_fraction(4, 3).value) else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
return filter_4tap_16p_117; return filter_4tap_16p_117;
else if (ratio.value < dal_fixed31_32_from_fraction(5, 3).value) else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
return filter_4tap_16p_150; return filter_4tap_16p_150;
else else
return filter_4tap_16p_183; return filter_4tap_16p_183;
...@@ -1050,11 +1050,11 @@ const uint16_t *get_filter_4tap_16p(struct fixed31_32 ratio) ...@@ -1050,11 +1050,11 @@ const uint16_t *get_filter_4tap_16p(struct fixed31_32 ratio)
const uint16_t *get_filter_4tap_64p(struct fixed31_32 ratio) const uint16_t *get_filter_4tap_64p(struct fixed31_32 ratio)
{ {
if (ratio.value < dal_fixed31_32_one.value) if (ratio.value < dc_fixpt_one.value)
return filter_4tap_64p_upscale; return filter_4tap_64p_upscale;
else if (ratio.value < dal_fixed31_32_from_fraction(4, 3).value) else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
return filter_4tap_64p_117; return filter_4tap_64p_117;
else if (ratio.value < dal_fixed31_32_from_fraction(5, 3).value) else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
return filter_4tap_64p_150; return filter_4tap_64p_150;
else else
return filter_4tap_64p_183; return filter_4tap_64p_183;
...@@ -1062,11 +1062,11 @@ const uint16_t *get_filter_4tap_64p(struct fixed31_32 ratio) ...@@ -1062,11 +1062,11 @@ const uint16_t *get_filter_4tap_64p(struct fixed31_32 ratio)
const uint16_t *get_filter_5tap_64p(struct fixed31_32 ratio) const uint16_t *get_filter_5tap_64p(struct fixed31_32 ratio)
{ {
if (ratio.value < dal_fixed31_32_one.value) if (ratio.value < dc_fixpt_one.value)
return filter_5tap_64p_upscale; return filter_5tap_64p_upscale;
else if (ratio.value < dal_fixed31_32_from_fraction(4, 3).value) else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
return filter_5tap_64p_117; return filter_5tap_64p_117;
else if (ratio.value < dal_fixed31_32_from_fraction(5, 3).value) else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
return filter_5tap_64p_150; return filter_5tap_64p_150;
else else
return filter_5tap_64p_183; return filter_5tap_64p_183;
...@@ -1074,11 +1074,11 @@ const uint16_t *get_filter_5tap_64p(struct fixed31_32 ratio) ...@@ -1074,11 +1074,11 @@ const uint16_t *get_filter_5tap_64p(struct fixed31_32 ratio)
const uint16_t *get_filter_6tap_64p(struct fixed31_32 ratio) const uint16_t *get_filter_6tap_64p(struct fixed31_32 ratio)
{ {
if (ratio.value < dal_fixed31_32_one.value) if (ratio.value < dc_fixpt_one.value)
return filter_6tap_64p_upscale; return filter_6tap_64p_upscale;
else if (ratio.value < dal_fixed31_32_from_fraction(4, 3).value) else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
return filter_6tap_64p_117; return filter_6tap_64p_117;
else if (ratio.value < dal_fixed31_32_from_fraction(5, 3).value) else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
return filter_6tap_64p_150; return filter_6tap_64p_150;
else else
return filter_6tap_64p_183; return filter_6tap_64p_183;
...@@ -1086,11 +1086,11 @@ const uint16_t *get_filter_6tap_64p(struct fixed31_32 ratio) ...@@ -1086,11 +1086,11 @@ const uint16_t *get_filter_6tap_64p(struct fixed31_32 ratio)
const uint16_t *get_filter_7tap_64p(struct fixed31_32 ratio) const uint16_t *get_filter_7tap_64p(struct fixed31_32 ratio)
{ {
if (ratio.value < dal_fixed31_32_one.value) if (ratio.value < dc_fixpt_one.value)
return filter_7tap_64p_upscale; return filter_7tap_64p_upscale;
else if (ratio.value < dal_fixed31_32_from_fraction(4, 3).value) else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
return filter_7tap_64p_117; return filter_7tap_64p_117;
else if (ratio.value < dal_fixed31_32_from_fraction(5, 3).value) else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
return filter_7tap_64p_150; return filter_7tap_64p_150;
else else
return filter_7tap_64p_183; return filter_7tap_64p_183;
...@@ -1098,11 +1098,11 @@ const uint16_t *get_filter_7tap_64p(struct fixed31_32 ratio) ...@@ -1098,11 +1098,11 @@ const uint16_t *get_filter_7tap_64p(struct fixed31_32 ratio)
const uint16_t *get_filter_8tap_64p(struct fixed31_32 ratio) const uint16_t *get_filter_8tap_64p(struct fixed31_32 ratio)
{ {
if (ratio.value < dal_fixed31_32_one.value) if (ratio.value < dc_fixpt_one.value)
return filter_8tap_64p_upscale; return filter_8tap_64p_upscale;
else if (ratio.value < dal_fixed31_32_from_fraction(4, 3).value) else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
return filter_8tap_64p_117; return filter_8tap_64p_117;
else if (ratio.value < dal_fixed31_32_from_fraction(5, 3).value) else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
return filter_8tap_64p_150; return filter_8tap_64p_150;
else else
return filter_8tap_64p_183; return filter_8tap_64p_183;
......
...@@ -683,11 +683,11 @@ static void dce110_stream_encoder_set_mst_bandwidth( ...@@ -683,11 +683,11 @@ static void dce110_stream_encoder_set_mst_bandwidth(
struct fixed31_32 avg_time_slots_per_mtp) struct fixed31_32 avg_time_slots_per_mtp)
{ {
struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc); struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc);
uint32_t x = dal_fixed31_32_floor( uint32_t x = dc_fixpt_floor(
avg_time_slots_per_mtp); avg_time_slots_per_mtp);
uint32_t y = dal_fixed31_32_ceil( uint32_t y = dc_fixpt_ceil(
dal_fixed31_32_shl( dc_fixpt_shl(
dal_fixed31_32_sub_int( dc_fixpt_sub_int(
avg_time_slots_per_mtp, avg_time_slots_per_mtp,
x), x),
26)); 26));
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
#define DC_LOGGER \ #define DC_LOGGER \
xfm_dce->base.ctx->logger xfm_dce->base.ctx->logger
#define IDENTITY_RATIO(ratio) (dal_fixed31_32_u2d19(ratio) == (1 << 19)) #define IDENTITY_RATIO(ratio) (dc_fixpt_u2d19(ratio) == (1 << 19))
#define GAMUT_MATRIX_SIZE 12 #define GAMUT_MATRIX_SIZE 12
#define SCL_PHASES 16 #define SCL_PHASES 16
...@@ -256,27 +256,27 @@ static void calculate_inits( ...@@ -256,27 +256,27 @@ static void calculate_inits(
struct fixed31_32 v_init; struct fixed31_32 v_init;
inits->h_int_scale_ratio = inits->h_int_scale_ratio =
dal_fixed31_32_u2d19(data->ratios.horz) << 5; dc_fixpt_u2d19(data->ratios.horz) << 5;
inits->v_int_scale_ratio = inits->v_int_scale_ratio =
dal_fixed31_32_u2d19(data->ratios.vert) << 5; dc_fixpt_u2d19(data->ratios.vert) << 5;
h_init = h_init =
dal_fixed31_32_div_int( dc_fixpt_div_int(
dal_fixed31_32_add( dc_fixpt_add(
data->ratios.horz, data->ratios.horz,
dal_fixed31_32_from_int(data->taps.h_taps + 1)), dc_fixpt_from_int(data->taps.h_taps + 1)),
2); 2);
inits->h_init.integer = dal_fixed31_32_floor(h_init); inits->h_init.integer = dc_fixpt_floor(h_init);
inits->h_init.fraction = dal_fixed31_32_u0d19(h_init) << 5; inits->h_init.fraction = dc_fixpt_u0d19(h_init) << 5;
v_init = v_init =
dal_fixed31_32_div_int( dc_fixpt_div_int(
dal_fixed31_32_add( dc_fixpt_add(
data->ratios.vert, data->ratios.vert,
dal_fixed31_32_from_int(data->taps.v_taps + 1)), dc_fixpt_from_int(data->taps.v_taps + 1)),
2); 2);
inits->v_init.integer = dal_fixed31_32_floor(v_init); inits->v_init.integer = dc_fixpt_floor(v_init);
inits->v_init.fraction = dal_fixed31_32_u0d19(v_init) << 5; inits->v_init.fraction = dc_fixpt_u0d19(v_init) << 5;
} }
static void program_scl_ratios_inits( static void program_scl_ratios_inits(
......
...@@ -509,19 +509,19 @@ dce110_translate_regamma_to_hw_format(const struct dc_transfer_func *output_tf, ...@@ -509,19 +509,19 @@ dce110_translate_regamma_to_hw_format(const struct dc_transfer_func *output_tf,
rgb_resulted[hw_points - 1].green = output_tf->tf_pts.green[start_index]; rgb_resulted[hw_points - 1].green = output_tf->tf_pts.green[start_index];
rgb_resulted[hw_points - 1].blue = output_tf->tf_pts.blue[start_index]; rgb_resulted[hw_points - 1].blue = output_tf->tf_pts.blue[start_index];
arr_points[0].x = dal_fixed31_32_pow(dal_fixed31_32_from_int(2), arr_points[0].x = dc_fixpt_pow(dc_fixpt_from_int(2),
dal_fixed31_32_from_int(region_start)); dc_fixpt_from_int(region_start));
arr_points[1].x = dal_fixed31_32_pow(dal_fixed31_32_from_int(2), arr_points[1].x = dc_fixpt_pow(dc_fixpt_from_int(2),
dal_fixed31_32_from_int(region_end)); dc_fixpt_from_int(region_end));
y_r = rgb_resulted[0].red; y_r = rgb_resulted[0].red;
y_g = rgb_resulted[0].green; y_g = rgb_resulted[0].green;
y_b = rgb_resulted[0].blue; y_b = rgb_resulted[0].blue;
y1_min = dal_fixed31_32_min(y_r, dal_fixed31_32_min(y_g, y_b)); y1_min = dc_fixpt_min(y_r, dc_fixpt_min(y_g, y_b));
arr_points[0].y = y1_min; arr_points[0].y = y1_min;
arr_points[0].slope = dal_fixed31_32_div(arr_points[0].y, arr_points[0].slope = dc_fixpt_div(arr_points[0].y,
arr_points[0].x); arr_points[0].x);
y_r = rgb_resulted[hw_points - 1].red; y_r = rgb_resulted[hw_points - 1].red;
...@@ -531,21 +531,21 @@ dce110_translate_regamma_to_hw_format(const struct dc_transfer_func *output_tf, ...@@ -531,21 +531,21 @@ dce110_translate_regamma_to_hw_format(const struct dc_transfer_func *output_tf,
/* see comment above, m_arrPoints[1].y should be the Y value for the /* see comment above, m_arrPoints[1].y should be the Y value for the
* region end (m_numOfHwPoints), not last HW point(m_numOfHwPoints - 1) * region end (m_numOfHwPoints), not last HW point(m_numOfHwPoints - 1)
*/ */
y3_max = dal_fixed31_32_max(y_r, dal_fixed31_32_max(y_g, y_b)); y3_max = dc_fixpt_max(y_r, dc_fixpt_max(y_g, y_b));
arr_points[1].y = y3_max; arr_points[1].y = y3_max;
arr_points[1].slope = dal_fixed31_32_zero; arr_points[1].slope = dc_fixpt_zero;
if (output_tf->tf == TRANSFER_FUNCTION_PQ) { if (output_tf->tf == TRANSFER_FUNCTION_PQ) {
/* for PQ, we want to have a straight line from last HW X point, /* for PQ, we want to have a straight line from last HW X point,
* and the slope to be such that we hit 1.0 at 10000 nits. * and the slope to be such that we hit 1.0 at 10000 nits.
*/ */
const struct fixed31_32 end_value = dal_fixed31_32_from_int(125); const struct fixed31_32 end_value = dc_fixpt_from_int(125);
arr_points[1].slope = dal_fixed31_32_div( arr_points[1].slope = dc_fixpt_div(
dal_fixed31_32_sub(dal_fixed31_32_one, arr_points[1].y), dc_fixpt_sub(dc_fixpt_one, arr_points[1].y),
dal_fixed31_32_sub(end_value, arr_points[1].x)); dc_fixpt_sub(end_value, arr_points[1].x));
} }
regamma_params->hw_points_num = hw_points; regamma_params->hw_points_num = hw_points;
...@@ -569,16 +569,16 @@ dce110_translate_regamma_to_hw_format(const struct dc_transfer_func *output_tf, ...@@ -569,16 +569,16 @@ dce110_translate_regamma_to_hw_format(const struct dc_transfer_func *output_tf,
i = 1; i = 1;
while (i != hw_points + 1) { while (i != hw_points + 1) {
if (dal_fixed31_32_lt(rgb_plus_1->red, rgb->red)) if (dc_fixpt_lt(rgb_plus_1->red, rgb->red))
rgb_plus_1->red = rgb->red; rgb_plus_1->red = rgb->red;
if (dal_fixed31_32_lt(rgb_plus_1->green, rgb->green)) if (dc_fixpt_lt(rgb_plus_1->green, rgb->green))
rgb_plus_1->green = rgb->green; rgb_plus_1->green = rgb->green;
if (dal_fixed31_32_lt(rgb_plus_1->blue, rgb->blue)) if (dc_fixpt_lt(rgb_plus_1->blue, rgb->blue))
rgb_plus_1->blue = rgb->blue; rgb_plus_1->blue = rgb->blue;
rgb->delta_red = dal_fixed31_32_sub(rgb_plus_1->red, rgb->red); rgb->delta_red = dc_fixpt_sub(rgb_plus_1->red, rgb->red);
rgb->delta_green = dal_fixed31_32_sub(rgb_plus_1->green, rgb->green); rgb->delta_green = dc_fixpt_sub(rgb_plus_1->green, rgb->green);
rgb->delta_blue = dal_fixed31_32_sub(rgb_plus_1->blue, rgb->blue); rgb->delta_blue = dc_fixpt_sub(rgb_plus_1->blue, rgb->blue);
++rgb_plus_1; ++rgb_plus_1;
++rgb; ++rgb;
......
...@@ -373,13 +373,13 @@ static void calculate_inits( ...@@ -373,13 +373,13 @@ static void calculate_inits(
struct rect *chroma_viewport) struct rect *chroma_viewport)
{ {
inits->h_int_scale_ratio_luma = inits->h_int_scale_ratio_luma =
dal_fixed31_32_u2d19(data->ratios.horz) << 5; dc_fixpt_u2d19(data->ratios.horz) << 5;
inits->v_int_scale_ratio_luma = inits->v_int_scale_ratio_luma =
dal_fixed31_32_u2d19(data->ratios.vert) << 5; dc_fixpt_u2d19(data->ratios.vert) << 5;
inits->h_int_scale_ratio_chroma = inits->h_int_scale_ratio_chroma =
dal_fixed31_32_u2d19(data->ratios.horz_c) << 5; dc_fixpt_u2d19(data->ratios.horz_c) << 5;
inits->v_int_scale_ratio_chroma = inits->v_int_scale_ratio_chroma =
dal_fixed31_32_u2d19(data->ratios.vert_c) << 5; dc_fixpt_u2d19(data->ratios.vert_c) << 5;
inits->h_init_luma.integer = 1; inits->h_init_luma.integer = 1;
inits->v_init_luma.integer = 1; inits->v_init_luma.integer = 1;
......
...@@ -169,7 +169,7 @@ bool cm_helper_convert_to_custom_float( ...@@ -169,7 +169,7 @@ bool cm_helper_convert_to_custom_float(
} }
if (fixpoint == true) if (fixpoint == true)
arr_points[1].custom_float_y = dal_fixed31_32_clamp_u0d14(arr_points[1].y); arr_points[1].custom_float_y = dc_fixpt_clamp_u0d14(arr_points[1].y);
else if (!convert_to_custom_float_format(arr_points[1].y, &fmt, else if (!convert_to_custom_float_format(arr_points[1].y, &fmt,
&arr_points[1].custom_float_y)) { &arr_points[1].custom_float_y)) {
BREAK_TO_DEBUGGER(); BREAK_TO_DEBUGGER();
...@@ -327,19 +327,19 @@ bool cm_helper_translate_curve_to_hw_format( ...@@ -327,19 +327,19 @@ bool cm_helper_translate_curve_to_hw_format(
rgb_resulted[hw_points - 1].green = output_tf->tf_pts.green[start_index]; rgb_resulted[hw_points - 1].green = output_tf->tf_pts.green[start_index];
rgb_resulted[hw_points - 1].blue = output_tf->tf_pts.blue[start_index]; rgb_resulted[hw_points - 1].blue = output_tf->tf_pts.blue[start_index];
arr_points[0].x = dal_fixed31_32_pow(dal_fixed31_32_from_int(2), arr_points[0].x = dc_fixpt_pow(dc_fixpt_from_int(2),
dal_fixed31_32_from_int(region_start)); dc_fixpt_from_int(region_start));
arr_points[1].x = dal_fixed31_32_pow(dal_fixed31_32_from_int(2), arr_points[1].x = dc_fixpt_pow(dc_fixpt_from_int(2),
dal_fixed31_32_from_int(region_end)); dc_fixpt_from_int(region_end));
y_r = rgb_resulted[0].red; y_r = rgb_resulted[0].red;
y_g = rgb_resulted[0].green; y_g = rgb_resulted[0].green;
y_b = rgb_resulted[0].blue; y_b = rgb_resulted[0].blue;
y1_min = dal_fixed31_32_min(y_r, dal_fixed31_32_min(y_g, y_b)); y1_min = dc_fixpt_min(y_r, dc_fixpt_min(y_g, y_b));
arr_points[0].y = y1_min; arr_points[0].y = y1_min;
arr_points[0].slope = dal_fixed31_32_div(arr_points[0].y, arr_points[0].x); arr_points[0].slope = dc_fixpt_div(arr_points[0].y, arr_points[0].x);
y_r = rgb_resulted[hw_points - 1].red; y_r = rgb_resulted[hw_points - 1].red;
y_g = rgb_resulted[hw_points - 1].green; y_g = rgb_resulted[hw_points - 1].green;
y_b = rgb_resulted[hw_points - 1].blue; y_b = rgb_resulted[hw_points - 1].blue;
...@@ -347,22 +347,22 @@ bool cm_helper_translate_curve_to_hw_format( ...@@ -347,22 +347,22 @@ bool cm_helper_translate_curve_to_hw_format(
/* see comment above, m_arrPoints[1].y should be the Y value for the /* see comment above, m_arrPoints[1].y should be the Y value for the
* region end (m_numOfHwPoints), not last HW point(m_numOfHwPoints - 1) * region end (m_numOfHwPoints), not last HW point(m_numOfHwPoints - 1)
*/ */
y3_max = dal_fixed31_32_max(y_r, dal_fixed31_32_max(y_g, y_b)); y3_max = dc_fixpt_max(y_r, dc_fixpt_max(y_g, y_b));
arr_points[1].y = y3_max; arr_points[1].y = y3_max;
arr_points[1].slope = dal_fixed31_32_zero; arr_points[1].slope = dc_fixpt_zero;
if (output_tf->tf == TRANSFER_FUNCTION_PQ) { if (output_tf->tf == TRANSFER_FUNCTION_PQ) {
/* for PQ, we want to have a straight line from last HW X point, /* for PQ, we want to have a straight line from last HW X point,
* and the slope to be such that we hit 1.0 at 10000 nits. * and the slope to be such that we hit 1.0 at 10000 nits.
*/ */
const struct fixed31_32 end_value = const struct fixed31_32 end_value =
dal_fixed31_32_from_int(125); dc_fixpt_from_int(125);
arr_points[1].slope = dal_fixed31_32_div( arr_points[1].slope = dc_fixpt_div(
dal_fixed31_32_sub(dal_fixed31_32_one, arr_points[1].y), dc_fixpt_sub(dc_fixpt_one, arr_points[1].y),
dal_fixed31_32_sub(end_value, arr_points[1].x)); dc_fixpt_sub(end_value, arr_points[1].x));
} }
lut_params->hw_points_num = hw_points; lut_params->hw_points_num = hw_points;
...@@ -386,24 +386,24 @@ bool cm_helper_translate_curve_to_hw_format( ...@@ -386,24 +386,24 @@ bool cm_helper_translate_curve_to_hw_format(
i = 1; i = 1;
while (i != hw_points + 1) { while (i != hw_points + 1) {
if (dal_fixed31_32_lt(rgb_plus_1->red, rgb->red)) if (dc_fixpt_lt(rgb_plus_1->red, rgb->red))
rgb_plus_1->red = rgb->red; rgb_plus_1->red = rgb->red;
if (dal_fixed31_32_lt(rgb_plus_1->green, rgb->green)) if (dc_fixpt_lt(rgb_plus_1->green, rgb->green))
rgb_plus_1->green = rgb->green; rgb_plus_1->green = rgb->green;
if (dal_fixed31_32_lt(rgb_plus_1->blue, rgb->blue)) if (dc_fixpt_lt(rgb_plus_1->blue, rgb->blue))
rgb_plus_1->blue = rgb->blue; rgb_plus_1->blue = rgb->blue;
rgb->delta_red = dal_fixed31_32_sub(rgb_plus_1->red, rgb->red); rgb->delta_red = dc_fixpt_sub(rgb_plus_1->red, rgb->red);
rgb->delta_green = dal_fixed31_32_sub(rgb_plus_1->green, rgb->green); rgb->delta_green = dc_fixpt_sub(rgb_plus_1->green, rgb->green);
rgb->delta_blue = dal_fixed31_32_sub(rgb_plus_1->blue, rgb->blue); rgb->delta_blue = dc_fixpt_sub(rgb_plus_1->blue, rgb->blue);
if (fixpoint == true) { if (fixpoint == true) {
rgb->delta_red_reg = dal_fixed31_32_clamp_u0d10(rgb->delta_red); rgb->delta_red_reg = dc_fixpt_clamp_u0d10(rgb->delta_red);
rgb->delta_green_reg = dal_fixed31_32_clamp_u0d10(rgb->delta_green); rgb->delta_green_reg = dc_fixpt_clamp_u0d10(rgb->delta_green);
rgb->delta_blue_reg = dal_fixed31_32_clamp_u0d10(rgb->delta_blue); rgb->delta_blue_reg = dc_fixpt_clamp_u0d10(rgb->delta_blue);
rgb->red_reg = dal_fixed31_32_clamp_u0d14(rgb->red); rgb->red_reg = dc_fixpt_clamp_u0d14(rgb->red);
rgb->green_reg = dal_fixed31_32_clamp_u0d14(rgb->green); rgb->green_reg = dc_fixpt_clamp_u0d14(rgb->green);
rgb->blue_reg = dal_fixed31_32_clamp_u0d14(rgb->blue); rgb->blue_reg = dc_fixpt_clamp_u0d14(rgb->blue);
} }
++rgb_plus_1; ++rgb_plus_1;
...@@ -489,19 +489,19 @@ bool cm_helper_translate_curve_to_degamma_hw_format( ...@@ -489,19 +489,19 @@ bool cm_helper_translate_curve_to_degamma_hw_format(
rgb_resulted[hw_points - 1].green = output_tf->tf_pts.green[start_index]; rgb_resulted[hw_points - 1].green = output_tf->tf_pts.green[start_index];
rgb_resulted[hw_points - 1].blue = output_tf->tf_pts.blue[start_index]; rgb_resulted[hw_points - 1].blue = output_tf->tf_pts.blue[start_index];
arr_points[0].x = dal_fixed31_32_pow(dal_fixed31_32_from_int(2), arr_points[0].x = dc_fixpt_pow(dc_fixpt_from_int(2),
dal_fixed31_32_from_int(region_start)); dc_fixpt_from_int(region_start));
arr_points[1].x = dal_fixed31_32_pow(dal_fixed31_32_from_int(2), arr_points[1].x = dc_fixpt_pow(dc_fixpt_from_int(2),
dal_fixed31_32_from_int(region_end)); dc_fixpt_from_int(region_end));
y_r = rgb_resulted[0].red; y_r = rgb_resulted[0].red;
y_g = rgb_resulted[0].green; y_g = rgb_resulted[0].green;
y_b = rgb_resulted[0].blue; y_b = rgb_resulted[0].blue;
y1_min = dal_fixed31_32_min(y_r, dal_fixed31_32_min(y_g, y_b)); y1_min = dc_fixpt_min(y_r, dc_fixpt_min(y_g, y_b));
arr_points[0].y = y1_min; arr_points[0].y = y1_min;
arr_points[0].slope = dal_fixed31_32_div(arr_points[0].y, arr_points[0].x); arr_points[0].slope = dc_fixpt_div(arr_points[0].y, arr_points[0].x);
y_r = rgb_resulted[hw_points - 1].red; y_r = rgb_resulted[hw_points - 1].red;
y_g = rgb_resulted[hw_points - 1].green; y_g = rgb_resulted[hw_points - 1].green;
y_b = rgb_resulted[hw_points - 1].blue; y_b = rgb_resulted[hw_points - 1].blue;
...@@ -509,22 +509,22 @@ bool cm_helper_translate_curve_to_degamma_hw_format( ...@@ -509,22 +509,22 @@ bool cm_helper_translate_curve_to_degamma_hw_format(
/* see comment above, m_arrPoints[1].y should be the Y value for the /* see comment above, m_arrPoints[1].y should be the Y value for the
* region end (m_numOfHwPoints), not last HW point(m_numOfHwPoints - 1) * region end (m_numOfHwPoints), not last HW point(m_numOfHwPoints - 1)
*/ */
y3_max = dal_fixed31_32_max(y_r, dal_fixed31_32_max(y_g, y_b)); y3_max = dc_fixpt_max(y_r, dc_fixpt_max(y_g, y_b));
arr_points[1].y = y3_max; arr_points[1].y = y3_max;
arr_points[1].slope = dal_fixed31_32_zero; arr_points[1].slope = dc_fixpt_zero;
if (output_tf->tf == TRANSFER_FUNCTION_PQ) { if (output_tf->tf == TRANSFER_FUNCTION_PQ) {
/* for PQ, we want to have a straight line from last HW X point, /* for PQ, we want to have a straight line from last HW X point,
* and the slope to be such that we hit 1.0 at 10000 nits. * and the slope to be such that we hit 1.0 at 10000 nits.
*/ */
const struct fixed31_32 end_value = const struct fixed31_32 end_value =
dal_fixed31_32_from_int(125); dc_fixpt_from_int(125);
arr_points[1].slope = dal_fixed31_32_div( arr_points[1].slope = dc_fixpt_div(
dal_fixed31_32_sub(dal_fixed31_32_one, arr_points[1].y), dc_fixpt_sub(dc_fixpt_one, arr_points[1].y),
dal_fixed31_32_sub(end_value, arr_points[1].x)); dc_fixpt_sub(end_value, arr_points[1].x));
} }
lut_params->hw_points_num = hw_points; lut_params->hw_points_num = hw_points;
...@@ -548,16 +548,16 @@ bool cm_helper_translate_curve_to_degamma_hw_format( ...@@ -548,16 +548,16 @@ bool cm_helper_translate_curve_to_degamma_hw_format(
i = 1; i = 1;
while (i != hw_points + 1) { while (i != hw_points + 1) {
if (dal_fixed31_32_lt(rgb_plus_1->red, rgb->red)) if (dc_fixpt_lt(rgb_plus_1->red, rgb->red))
rgb_plus_1->red = rgb->red; rgb_plus_1->red = rgb->red;
if (dal_fixed31_32_lt(rgb_plus_1->green, rgb->green)) if (dc_fixpt_lt(rgb_plus_1->green, rgb->green))
rgb_plus_1->green = rgb->green; rgb_plus_1->green = rgb->green;
if (dal_fixed31_32_lt(rgb_plus_1->blue, rgb->blue)) if (dc_fixpt_lt(rgb_plus_1->blue, rgb->blue))
rgb_plus_1->blue = rgb->blue; rgb_plus_1->blue = rgb->blue;
rgb->delta_red = dal_fixed31_32_sub(rgb_plus_1->red, rgb->red); rgb->delta_red = dc_fixpt_sub(rgb_plus_1->red, rgb->red);
rgb->delta_green = dal_fixed31_32_sub(rgb_plus_1->green, rgb->green); rgb->delta_green = dc_fixpt_sub(rgb_plus_1->green, rgb->green);
rgb->delta_blue = dal_fixed31_32_sub(rgb_plus_1->blue, rgb->blue); rgb->delta_blue = dc_fixpt_sub(rgb_plus_1->blue, rgb->blue);
++rgb_plus_1; ++rgb_plus_1;
++rgb; ++rgb;
......
...@@ -130,7 +130,7 @@ void dpp_set_gamut_remap_bypass(struct dcn10_dpp *dpp) ...@@ -130,7 +130,7 @@ void dpp_set_gamut_remap_bypass(struct dcn10_dpp *dpp)
/* Gamut remap in bypass */ /* Gamut remap in bypass */
} }
#define IDENTITY_RATIO(ratio) (dal_fixed31_32_u2d19(ratio) == (1 << 19)) #define IDENTITY_RATIO(ratio) (dc_fixpt_u2d19(ratio) == (1 << 19))
bool dpp_get_optimal_number_of_taps( bool dpp_get_optimal_number_of_taps(
......
...@@ -811,13 +811,13 @@ void dpp1_program_input_lut( ...@@ -811,13 +811,13 @@ void dpp1_program_input_lut(
REG_UPDATE(CM_IGAM_LUT_RW_INDEX, CM_IGAM_LUT_RW_INDEX, 0); REG_UPDATE(CM_IGAM_LUT_RW_INDEX, CM_IGAM_LUT_RW_INDEX, 0);
for (i = 0; i < gamma->num_entries; i++) { for (i = 0; i < gamma->num_entries; i++) {
REG_SET(CM_IGAM_LUT_SEQ_COLOR, 0, CM_IGAM_LUT_SEQ_COLOR, REG_SET(CM_IGAM_LUT_SEQ_COLOR, 0, CM_IGAM_LUT_SEQ_COLOR,
dal_fixed31_32_round( dc_fixpt_round(
gamma->entries.red[i])); gamma->entries.red[i]));
REG_SET(CM_IGAM_LUT_SEQ_COLOR, 0, CM_IGAM_LUT_SEQ_COLOR, REG_SET(CM_IGAM_LUT_SEQ_COLOR, 0, CM_IGAM_LUT_SEQ_COLOR,
dal_fixed31_32_round( dc_fixpt_round(
gamma->entries.green[i])); gamma->entries.green[i]));
REG_SET(CM_IGAM_LUT_SEQ_COLOR, 0, CM_IGAM_LUT_SEQ_COLOR, REG_SET(CM_IGAM_LUT_SEQ_COLOR, 0, CM_IGAM_LUT_SEQ_COLOR,
dal_fixed31_32_round( dc_fixpt_round(
gamma->entries.blue[i])); gamma->entries.blue[i]));
} }
// Power off LUT memory // Power off LUT memory
......
...@@ -169,7 +169,7 @@ static enum dscl_mode_sel dpp1_dscl_get_dscl_mode( ...@@ -169,7 +169,7 @@ static enum dscl_mode_sel dpp1_dscl_get_dscl_mode(
const struct scaler_data *data, const struct scaler_data *data,
bool dbg_always_scale) bool dbg_always_scale)
{ {
const long long one = dal_fixed31_32_one.value; const long long one = dc_fixpt_one.value;
if (dpp_base->caps->dscl_data_proc_format == DSCL_DATA_PRCESSING_FIXED_FORMAT) { if (dpp_base->caps->dscl_data_proc_format == DSCL_DATA_PRCESSING_FIXED_FORMAT) {
/* DSCL is processing data in fixed format */ /* DSCL is processing data in fixed format */
...@@ -464,8 +464,8 @@ static enum lb_memory_config dpp1_dscl_find_lb_memory_config(struct dcn10_dpp *d ...@@ -464,8 +464,8 @@ static enum lb_memory_config dpp1_dscl_find_lb_memory_config(struct dcn10_dpp *d
int num_part_y, num_part_c; int num_part_y, num_part_c;
int vtaps = scl_data->taps.v_taps; int vtaps = scl_data->taps.v_taps;
int vtaps_c = scl_data->taps.v_taps_c; int vtaps_c = scl_data->taps.v_taps_c;
int ceil_vratio = dal_fixed31_32_ceil(scl_data->ratios.vert); int ceil_vratio = dc_fixpt_ceil(scl_data->ratios.vert);
int ceil_vratio_c = dal_fixed31_32_ceil(scl_data->ratios.vert_c); int ceil_vratio_c = dc_fixpt_ceil(scl_data->ratios.vert_c);
enum lb_memory_config mem_cfg = LB_MEMORY_CONFIG_0; enum lb_memory_config mem_cfg = LB_MEMORY_CONFIG_0;
if (dpp->base.ctx->dc->debug.use_max_lb) if (dpp->base.ctx->dc->debug.use_max_lb)
...@@ -565,52 +565,52 @@ static void dpp1_dscl_set_manual_ratio_init( ...@@ -565,52 +565,52 @@ static void dpp1_dscl_set_manual_ratio_init(
uint32_t init_int = 0; uint32_t init_int = 0;
REG_SET(SCL_HORZ_FILTER_SCALE_RATIO, 0, REG_SET(SCL_HORZ_FILTER_SCALE_RATIO, 0,
SCL_H_SCALE_RATIO, dal_fixed31_32_u2d19(data->ratios.horz) << 5); SCL_H_SCALE_RATIO, dc_fixpt_u2d19(data->ratios.horz) << 5);
REG_SET(SCL_VERT_FILTER_SCALE_RATIO, 0, REG_SET(SCL_VERT_FILTER_SCALE_RATIO, 0,
SCL_V_SCALE_RATIO, dal_fixed31_32_u2d19(data->ratios.vert) << 5); SCL_V_SCALE_RATIO, dc_fixpt_u2d19(data->ratios.vert) << 5);
REG_SET(SCL_HORZ_FILTER_SCALE_RATIO_C, 0, REG_SET(SCL_HORZ_FILTER_SCALE_RATIO_C, 0,
SCL_H_SCALE_RATIO_C, dal_fixed31_32_u2d19(data->ratios.horz_c) << 5); SCL_H_SCALE_RATIO_C, dc_fixpt_u2d19(data->ratios.horz_c) << 5);
REG_SET(SCL_VERT_FILTER_SCALE_RATIO_C, 0, REG_SET(SCL_VERT_FILTER_SCALE_RATIO_C, 0,
SCL_V_SCALE_RATIO_C, dal_fixed31_32_u2d19(data->ratios.vert_c) << 5); SCL_V_SCALE_RATIO_C, dc_fixpt_u2d19(data->ratios.vert_c) << 5);
/* /*
* 0.24 format for fraction, first five bits zeroed * 0.24 format for fraction, first five bits zeroed
*/ */
init_frac = dal_fixed31_32_u0d19(data->inits.h) << 5; init_frac = dc_fixpt_u0d19(data->inits.h) << 5;
init_int = dal_fixed31_32_floor(data->inits.h); init_int = dc_fixpt_floor(data->inits.h);
REG_SET_2(SCL_HORZ_FILTER_INIT, 0, REG_SET_2(SCL_HORZ_FILTER_INIT, 0,
SCL_H_INIT_FRAC, init_frac, SCL_H_INIT_FRAC, init_frac,
SCL_H_INIT_INT, init_int); SCL_H_INIT_INT, init_int);
init_frac = dal_fixed31_32_u0d19(data->inits.h_c) << 5; init_frac = dc_fixpt_u0d19(data->inits.h_c) << 5;
init_int = dal_fixed31_32_floor(data->inits.h_c); init_int = dc_fixpt_floor(data->inits.h_c);
REG_SET_2(SCL_HORZ_FILTER_INIT_C, 0, REG_SET_2(SCL_HORZ_FILTER_INIT_C, 0,
SCL_H_INIT_FRAC_C, init_frac, SCL_H_INIT_FRAC_C, init_frac,
SCL_H_INIT_INT_C, init_int); SCL_H_INIT_INT_C, init_int);
init_frac = dal_fixed31_32_u0d19(data->inits.v) << 5; init_frac = dc_fixpt_u0d19(data->inits.v) << 5;
init_int = dal_fixed31_32_floor(data->inits.v); init_int = dc_fixpt_floor(data->inits.v);
REG_SET_2(SCL_VERT_FILTER_INIT, 0, REG_SET_2(SCL_VERT_FILTER_INIT, 0,
SCL_V_INIT_FRAC, init_frac, SCL_V_INIT_FRAC, init_frac,
SCL_V_INIT_INT, init_int); SCL_V_INIT_INT, init_int);
init_frac = dal_fixed31_32_u0d19(data->inits.v_bot) << 5; init_frac = dc_fixpt_u0d19(data->inits.v_bot) << 5;
init_int = dal_fixed31_32_floor(data->inits.v_bot); init_int = dc_fixpt_floor(data->inits.v_bot);
REG_SET_2(SCL_VERT_FILTER_INIT_BOT, 0, REG_SET_2(SCL_VERT_FILTER_INIT_BOT, 0,
SCL_V_INIT_FRAC_BOT, init_frac, SCL_V_INIT_FRAC_BOT, init_frac,
SCL_V_INIT_INT_BOT, init_int); SCL_V_INIT_INT_BOT, init_int);
init_frac = dal_fixed31_32_u0d19(data->inits.v_c) << 5; init_frac = dc_fixpt_u0d19(data->inits.v_c) << 5;
init_int = dal_fixed31_32_floor(data->inits.v_c); init_int = dc_fixpt_floor(data->inits.v_c);
REG_SET_2(SCL_VERT_FILTER_INIT_C, 0, REG_SET_2(SCL_VERT_FILTER_INIT_C, 0,
SCL_V_INIT_FRAC_C, init_frac, SCL_V_INIT_FRAC_C, init_frac,
SCL_V_INIT_INT_C, init_int); SCL_V_INIT_INT_C, init_int);
init_frac = dal_fixed31_32_u0d19(data->inits.v_c_bot) << 5; init_frac = dc_fixpt_u0d19(data->inits.v_c_bot) << 5;
init_int = dal_fixed31_32_floor(data->inits.v_c_bot); init_int = dc_fixpt_floor(data->inits.v_c_bot);
REG_SET_2(SCL_VERT_FILTER_INIT_BOT_C, 0, REG_SET_2(SCL_VERT_FILTER_INIT_BOT_C, 0,
SCL_V_INIT_FRAC_BOT_C, init_frac, SCL_V_INIT_FRAC_BOT_C, init_frac,
SCL_V_INIT_INT_BOT_C, init_int); SCL_V_INIT_INT_BOT_C, init_int);
......
...@@ -1054,8 +1054,8 @@ void hubp1_cursor_set_position( ...@@ -1054,8 +1054,8 @@ void hubp1_cursor_set_position(
ASSERT(param->h_scale_ratio.value); ASSERT(param->h_scale_ratio.value);
if (param->h_scale_ratio.value) if (param->h_scale_ratio.value)
dst_x_offset = dal_fixed31_32_floor(dal_fixed31_32_div( dst_x_offset = dc_fixpt_floor(dc_fixpt_div(
dal_fixed31_32_from_int(dst_x_offset), dc_fixpt_from_int(dst_x_offset),
param->h_scale_ratio)); param->h_scale_ratio));
if (src_x_offset >= (int)param->viewport_width) if (src_x_offset >= (int)param->viewport_width)
......
...@@ -1685,22 +1685,22 @@ static uint16_t fixed_point_to_int_frac( ...@@ -1685,22 +1685,22 @@ static uint16_t fixed_point_to_int_frac(
uint16_t result; uint16_t result;
uint16_t d = (uint16_t)dal_fixed31_32_floor( uint16_t d = (uint16_t)dc_fixpt_floor(
dal_fixed31_32_abs( dc_fixpt_abs(
arg)); arg));
if (d <= (uint16_t)(1 << integer_bits) - (1 / (uint16_t)divisor)) if (d <= (uint16_t)(1 << integer_bits) - (1 / (uint16_t)divisor))
numerator = (uint16_t)dal_fixed31_32_floor( numerator = (uint16_t)dc_fixpt_floor(
dal_fixed31_32_mul_int( dc_fixpt_mul_int(
arg, arg,
divisor)); divisor));
else { else {
numerator = dal_fixed31_32_floor( numerator = dc_fixpt_floor(
dal_fixed31_32_sub( dc_fixpt_sub(
dal_fixed31_32_from_int( dc_fixpt_from_int(
1LL << integer_bits), 1LL << integer_bits),
dal_fixed31_32_recip( dc_fixpt_recip(
dal_fixed31_32_from_int( dc_fixpt_from_int(
divisor)))); divisor))));
} }
...@@ -1710,8 +1710,8 @@ static uint16_t fixed_point_to_int_frac( ...@@ -1710,8 +1710,8 @@ static uint16_t fixed_point_to_int_frac(
result = (uint16_t)( result = (uint16_t)(
(1 << (integer_bits + fractional_bits + 1)) + numerator); (1 << (integer_bits + fractional_bits + 1)) + numerator);
if ((result != 0) && dal_fixed31_32_lt( if ((result != 0) && dc_fixpt_lt(
arg, dal_fixed31_32_zero)) arg, dc_fixpt_zero))
result |= 1 << (integer_bits + fractional_bits); result |= 1 << (integer_bits + fractional_bits);
return result; return result;
...@@ -1725,8 +1725,8 @@ void build_prescale_params(struct dc_bias_and_scale *bias_and_scale, ...@@ -1725,8 +1725,8 @@ void build_prescale_params(struct dc_bias_and_scale *bias_and_scale,
&& plane_state->input_csc_color_matrix.enable_adjustment && plane_state->input_csc_color_matrix.enable_adjustment
&& plane_state->coeff_reduction_factor.value != 0) { && plane_state->coeff_reduction_factor.value != 0) {
bias_and_scale->scale_blue = fixed_point_to_int_frac( bias_and_scale->scale_blue = fixed_point_to_int_frac(
dal_fixed31_32_mul(plane_state->coeff_reduction_factor, dc_fixpt_mul(plane_state->coeff_reduction_factor,
dal_fixed31_32_from_fraction(256, 255)), dc_fixpt_from_fraction(256, 255)),
2, 2,
13); 13);
bias_and_scale->scale_red = bias_and_scale->scale_blue; bias_and_scale->scale_red = bias_and_scale->scale_blue;
...@@ -1995,7 +1995,7 @@ static void dcn10_blank_pixel_data( ...@@ -1995,7 +1995,7 @@ static void dcn10_blank_pixel_data(
static void set_hdr_multiplier(struct pipe_ctx *pipe_ctx) static void set_hdr_multiplier(struct pipe_ctx *pipe_ctx)
{ {
struct fixed31_32 multiplier = dal_fixed31_32_from_fraction( struct fixed31_32 multiplier = dc_fixpt_from_fraction(
pipe_ctx->plane_state->sdr_white_level, 80); pipe_ctx->plane_state->sdr_white_level, 80);
uint32_t hw_mult = 0x1f000; // 1.0 default multiplier uint32_t hw_mult = 0x1f000; // 1.0 default multiplier
struct custom_float_format fmt; struct custom_float_format fmt;
......
...@@ -603,11 +603,11 @@ void enc1_stream_encoder_set_mst_bandwidth( ...@@ -603,11 +603,11 @@ void enc1_stream_encoder_set_mst_bandwidth(
struct fixed31_32 avg_time_slots_per_mtp) struct fixed31_32 avg_time_slots_per_mtp)
{ {
struct dcn10_stream_encoder *enc1 = DCN10STRENC_FROM_STRENC(enc); struct dcn10_stream_encoder *enc1 = DCN10STRENC_FROM_STRENC(enc);
uint32_t x = dal_fixed31_32_floor( uint32_t x = dc_fixpt_floor(
avg_time_slots_per_mtp); avg_time_slots_per_mtp);
uint32_t y = dal_fixed31_32_ceil( uint32_t y = dc_fixpt_ceil(
dal_fixed31_32_shl( dc_fixpt_shl(
dal_fixed31_32_sub_int( dc_fixpt_sub_int(
avg_time_slots_per_mtp, avg_time_slots_per_mtp,
x), x),
26)); 26));
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#ifndef __DAL_IRQ_TYPES_H__ #ifndef __DAL_IRQ_TYPES_H__
#define __DAL_IRQ_TYPES_H__ #define __DAL_IRQ_TYPES_H__
#include "os_types.h"
struct dc_context; struct dc_context;
typedef void (*interrupt_handler)(void *); typedef void (*interrupt_handler)(void *);
......
...@@ -50,16 +50,16 @@ struct fixed31_32 { ...@@ -50,16 +50,16 @@ struct fixed31_32 {
* Useful constants * Useful constants
*/ */
static const struct fixed31_32 dal_fixed31_32_zero = { 0 }; static const struct fixed31_32 dc_fixpt_zero = { 0 };
static const struct fixed31_32 dal_fixed31_32_epsilon = { 1LL }; static const struct fixed31_32 dc_fixpt_epsilon = { 1LL };
static const struct fixed31_32 dal_fixed31_32_half = { 0x80000000LL }; static const struct fixed31_32 dc_fixpt_half = { 0x80000000LL };
static const struct fixed31_32 dal_fixed31_32_one = { 0x100000000LL }; static const struct fixed31_32 dc_fixpt_one = { 0x100000000LL };
static const struct fixed31_32 dal_fixed31_32_pi = { 13493037705LL }; static const struct fixed31_32 dc_fixpt_pi = { 13493037705LL };
static const struct fixed31_32 dal_fixed31_32_two_pi = { 26986075409LL }; static const struct fixed31_32 dc_fixpt_two_pi = { 26986075409LL };
static const struct fixed31_32 dal_fixed31_32_e = { 11674931555LL }; static const struct fixed31_32 dc_fixpt_e = { 11674931555LL };
static const struct fixed31_32 dal_fixed31_32_ln2 = { 2977044471LL }; static const struct fixed31_32 dc_fixpt_ln2 = { 2977044471LL };
static const struct fixed31_32 dal_fixed31_32_ln2_div_2 = { 1488522236LL }; static const struct fixed31_32 dc_fixpt_ln2_div_2 = { 1488522236LL };
/* /*
* @brief * @brief
...@@ -70,7 +70,7 @@ static const struct fixed31_32 dal_fixed31_32_ln2_div_2 = { 1488522236LL }; ...@@ -70,7 +70,7 @@ static const struct fixed31_32 dal_fixed31_32_ln2_div_2 = { 1488522236LL };
* @brief * @brief
* result = numerator / denominator * result = numerator / denominator
*/ */
struct fixed31_32 dal_fixed31_32_from_fraction( struct fixed31_32 dc_fixpt_from_fraction(
long long numerator, long long numerator,
long long denominator); long long denominator);
...@@ -78,8 +78,8 @@ struct fixed31_32 dal_fixed31_32_from_fraction( ...@@ -78,8 +78,8 @@ struct fixed31_32 dal_fixed31_32_from_fraction(
* @brief * @brief
* result = arg * result = arg
*/ */
struct fixed31_32 dal_fixed31_32_from_int_nonconst(long long arg); struct fixed31_32 dc_fixpt_from_int_nonconst(long long arg);
static inline struct fixed31_32 dal_fixed31_32_from_int(long long arg) static inline struct fixed31_32 dc_fixpt_from_int(long long arg)
{ {
if (__builtin_constant_p(arg)) { if (__builtin_constant_p(arg)) {
struct fixed31_32 res; struct fixed31_32 res;
...@@ -87,7 +87,7 @@ static inline struct fixed31_32 dal_fixed31_32_from_int(long long arg) ...@@ -87,7 +87,7 @@ static inline struct fixed31_32 dal_fixed31_32_from_int(long long arg)
res.value = arg << FIXED31_32_BITS_PER_FRACTIONAL_PART; res.value = arg << FIXED31_32_BITS_PER_FRACTIONAL_PART;
return res; return res;
} else } else
return dal_fixed31_32_from_int_nonconst(arg); return dc_fixpt_from_int_nonconst(arg);
} }
/* /*
...@@ -99,7 +99,7 @@ static inline struct fixed31_32 dal_fixed31_32_from_int(long long arg) ...@@ -99,7 +99,7 @@ static inline struct fixed31_32 dal_fixed31_32_from_int(long long arg)
* @brief * @brief
* result = -arg * result = -arg
*/ */
static inline struct fixed31_32 dal_fixed31_32_neg(struct fixed31_32 arg) static inline struct fixed31_32 dc_fixpt_neg(struct fixed31_32 arg)
{ {
struct fixed31_32 res; struct fixed31_32 res;
...@@ -112,10 +112,10 @@ static inline struct fixed31_32 dal_fixed31_32_neg(struct fixed31_32 arg) ...@@ -112,10 +112,10 @@ static inline struct fixed31_32 dal_fixed31_32_neg(struct fixed31_32 arg)
* @brief * @brief
* result = abs(arg) := (arg >= 0) ? arg : -arg * result = abs(arg) := (arg >= 0) ? arg : -arg
*/ */
static inline struct fixed31_32 dal_fixed31_32_abs(struct fixed31_32 arg) static inline struct fixed31_32 dc_fixpt_abs(struct fixed31_32 arg)
{ {
if (arg.value < 0) if (arg.value < 0)
return dal_fixed31_32_neg(arg); return dc_fixpt_neg(arg);
else else
return arg; return arg;
} }
...@@ -129,7 +129,7 @@ static inline struct fixed31_32 dal_fixed31_32_abs(struct fixed31_32 arg) ...@@ -129,7 +129,7 @@ static inline struct fixed31_32 dal_fixed31_32_abs(struct fixed31_32 arg)
* @brief * @brief
* result = arg1 < arg2 * result = arg1 < arg2
*/ */
static inline bool dal_fixed31_32_lt(struct fixed31_32 arg1, static inline bool dc_fixpt_lt(struct fixed31_32 arg1,
struct fixed31_32 arg2) struct fixed31_32 arg2)
{ {
return arg1.value < arg2.value; return arg1.value < arg2.value;
...@@ -139,7 +139,7 @@ static inline bool dal_fixed31_32_lt(struct fixed31_32 arg1, ...@@ -139,7 +139,7 @@ static inline bool dal_fixed31_32_lt(struct fixed31_32 arg1,
* @brief * @brief
* result = arg1 <= arg2 * result = arg1 <= arg2
*/ */
static inline bool dal_fixed31_32_le(struct fixed31_32 arg1, static inline bool dc_fixpt_le(struct fixed31_32 arg1,
struct fixed31_32 arg2) struct fixed31_32 arg2)
{ {
return arg1.value <= arg2.value; return arg1.value <= arg2.value;
...@@ -149,7 +149,7 @@ static inline bool dal_fixed31_32_le(struct fixed31_32 arg1, ...@@ -149,7 +149,7 @@ static inline bool dal_fixed31_32_le(struct fixed31_32 arg1,
* @brief * @brief
* result = arg1 == arg2 * result = arg1 == arg2
*/ */
static inline bool dal_fixed31_32_eq(struct fixed31_32 arg1, static inline bool dc_fixpt_eq(struct fixed31_32 arg1,
struct fixed31_32 arg2) struct fixed31_32 arg2)
{ {
return arg1.value == arg2.value; return arg1.value == arg2.value;
...@@ -159,7 +159,7 @@ static inline bool dal_fixed31_32_eq(struct fixed31_32 arg1, ...@@ -159,7 +159,7 @@ static inline bool dal_fixed31_32_eq(struct fixed31_32 arg1,
* @brief * @brief
* result = min(arg1, arg2) := (arg1 <= arg2) ? arg1 : arg2 * result = min(arg1, arg2) := (arg1 <= arg2) ? arg1 : arg2
*/ */
static inline struct fixed31_32 dal_fixed31_32_min(struct fixed31_32 arg1, static inline struct fixed31_32 dc_fixpt_min(struct fixed31_32 arg1,
struct fixed31_32 arg2) struct fixed31_32 arg2)
{ {
if (arg1.value <= arg2.value) if (arg1.value <= arg2.value)
...@@ -172,7 +172,7 @@ static inline struct fixed31_32 dal_fixed31_32_min(struct fixed31_32 arg1, ...@@ -172,7 +172,7 @@ static inline struct fixed31_32 dal_fixed31_32_min(struct fixed31_32 arg1,
* @brief * @brief
* result = max(arg1, arg2) := (arg1 <= arg2) ? arg2 : arg1 * result = max(arg1, arg2) := (arg1 <= arg2) ? arg2 : arg1
*/ */
static inline struct fixed31_32 dal_fixed31_32_max(struct fixed31_32 arg1, static inline struct fixed31_32 dc_fixpt_max(struct fixed31_32 arg1,
struct fixed31_32 arg2) struct fixed31_32 arg2)
{ {
if (arg1.value <= arg2.value) if (arg1.value <= arg2.value)
...@@ -187,14 +187,14 @@ static inline struct fixed31_32 dal_fixed31_32_max(struct fixed31_32 arg1, ...@@ -187,14 +187,14 @@ static inline struct fixed31_32 dal_fixed31_32_max(struct fixed31_32 arg1,
* result = | arg, when min_value < arg < max_value * result = | arg, when min_value < arg < max_value
* | max_value, when arg >= max_value * | max_value, when arg >= max_value
*/ */
static inline struct fixed31_32 dal_fixed31_32_clamp( static inline struct fixed31_32 dc_fixpt_clamp(
struct fixed31_32 arg, struct fixed31_32 arg,
struct fixed31_32 min_value, struct fixed31_32 min_value,
struct fixed31_32 max_value) struct fixed31_32 max_value)
{ {
if (dal_fixed31_32_le(arg, min_value)) if (dc_fixpt_le(arg, min_value))
return min_value; return min_value;
else if (dal_fixed31_32_le(max_value, arg)) else if (dc_fixpt_le(max_value, arg))
return max_value; return max_value;
else else
return arg; return arg;
...@@ -209,7 +209,7 @@ static inline struct fixed31_32 dal_fixed31_32_clamp( ...@@ -209,7 +209,7 @@ static inline struct fixed31_32 dal_fixed31_32_clamp(
* @brief * @brief
* result = arg << shift * result = arg << shift
*/ */
struct fixed31_32 dal_fixed31_32_shl( struct fixed31_32 dc_fixpt_shl(
struct fixed31_32 arg, struct fixed31_32 arg,
unsigned char shift); unsigned char shift);
...@@ -217,7 +217,7 @@ struct fixed31_32 dal_fixed31_32_shl( ...@@ -217,7 +217,7 @@ struct fixed31_32 dal_fixed31_32_shl(
* @brief * @brief
* result = arg >> shift * result = arg >> shift
*/ */
static inline struct fixed31_32 dal_fixed31_32_shr( static inline struct fixed31_32 dc_fixpt_shr(
struct fixed31_32 arg, struct fixed31_32 arg,
unsigned char shift) unsigned char shift)
{ {
...@@ -235,7 +235,7 @@ static inline struct fixed31_32 dal_fixed31_32_shr( ...@@ -235,7 +235,7 @@ static inline struct fixed31_32 dal_fixed31_32_shr(
* @brief * @brief
* result = arg1 + arg2 * result = arg1 + arg2
*/ */
struct fixed31_32 dal_fixed31_32_add( struct fixed31_32 dc_fixpt_add(
struct fixed31_32 arg1, struct fixed31_32 arg1,
struct fixed31_32 arg2); struct fixed31_32 arg2);
...@@ -243,18 +243,18 @@ struct fixed31_32 dal_fixed31_32_add( ...@@ -243,18 +243,18 @@ struct fixed31_32 dal_fixed31_32_add(
* @brief * @brief
* result = arg1 + arg2 * result = arg1 + arg2
*/ */
static inline struct fixed31_32 dal_fixed31_32_add_int(struct fixed31_32 arg1, static inline struct fixed31_32 dc_fixpt_add_int(struct fixed31_32 arg1,
int arg2) int arg2)
{ {
return dal_fixed31_32_add(arg1, return dc_fixpt_add(arg1,
dal_fixed31_32_from_int(arg2)); dc_fixpt_from_int(arg2));
} }
/* /*
* @brief * @brief
* result = arg1 - arg2 * result = arg1 - arg2
*/ */
struct fixed31_32 dal_fixed31_32_sub( struct fixed31_32 dc_fixpt_sub(
struct fixed31_32 arg1, struct fixed31_32 arg1,
struct fixed31_32 arg2); struct fixed31_32 arg2);
...@@ -262,11 +262,11 @@ struct fixed31_32 dal_fixed31_32_sub( ...@@ -262,11 +262,11 @@ struct fixed31_32 dal_fixed31_32_sub(
* @brief * @brief
* result = arg1 - arg2 * result = arg1 - arg2
*/ */
static inline struct fixed31_32 dal_fixed31_32_sub_int(struct fixed31_32 arg1, static inline struct fixed31_32 dc_fixpt_sub_int(struct fixed31_32 arg1,
int arg2) int arg2)
{ {
return dal_fixed31_32_sub(arg1, return dc_fixpt_sub(arg1,
dal_fixed31_32_from_int(arg2)); dc_fixpt_from_int(arg2));
} }
...@@ -279,7 +279,7 @@ static inline struct fixed31_32 dal_fixed31_32_sub_int(struct fixed31_32 arg1, ...@@ -279,7 +279,7 @@ static inline struct fixed31_32 dal_fixed31_32_sub_int(struct fixed31_32 arg1,
* @brief * @brief
* result = arg1 * arg2 * result = arg1 * arg2
*/ */
struct fixed31_32 dal_fixed31_32_mul( struct fixed31_32 dc_fixpt_mul(
struct fixed31_32 arg1, struct fixed31_32 arg1,
struct fixed31_32 arg2); struct fixed31_32 arg2);
...@@ -288,39 +288,39 @@ struct fixed31_32 dal_fixed31_32_mul( ...@@ -288,39 +288,39 @@ struct fixed31_32 dal_fixed31_32_mul(
* @brief * @brief
* result = arg1 * arg2 * result = arg1 * arg2
*/ */
static inline struct fixed31_32 dal_fixed31_32_mul_int(struct fixed31_32 arg1, static inline struct fixed31_32 dc_fixpt_mul_int(struct fixed31_32 arg1,
int arg2) int arg2)
{ {
return dal_fixed31_32_mul(arg1, return dc_fixpt_mul(arg1,
dal_fixed31_32_from_int(arg2)); dc_fixpt_from_int(arg2));
} }
/* /*
* @brief * @brief
* result = square(arg) := arg * arg * result = square(arg) := arg * arg
*/ */
struct fixed31_32 dal_fixed31_32_sqr( struct fixed31_32 dc_fixpt_sqr(
struct fixed31_32 arg); struct fixed31_32 arg);
/* /*
* @brief * @brief
* result = arg1 / arg2 * result = arg1 / arg2
*/ */
static inline struct fixed31_32 dal_fixed31_32_div_int(struct fixed31_32 arg1, static inline struct fixed31_32 dc_fixpt_div_int(struct fixed31_32 arg1,
long long arg2) long long arg2)
{ {
return dal_fixed31_32_from_fraction(arg1.value, return dc_fixpt_from_fraction(arg1.value,
dal_fixed31_32_from_int(arg2).value); dc_fixpt_from_int(arg2).value);
} }
/* /*
* @brief * @brief
* result = arg1 / arg2 * result = arg1 / arg2
*/ */
static inline struct fixed31_32 dal_fixed31_32_div(struct fixed31_32 arg1, static inline struct fixed31_32 dc_fixpt_div(struct fixed31_32 arg1,
struct fixed31_32 arg2) struct fixed31_32 arg2)
{ {
return dal_fixed31_32_from_fraction(arg1.value, return dc_fixpt_from_fraction(arg1.value,
arg2.value); arg2.value);
} }
...@@ -336,7 +336,7 @@ static inline struct fixed31_32 dal_fixed31_32_div(struct fixed31_32 arg1, ...@@ -336,7 +336,7 @@ static inline struct fixed31_32 dal_fixed31_32_div(struct fixed31_32 arg1,
* @note * @note
* No special actions taken in case argument is zero. * No special actions taken in case argument is zero.
*/ */
struct fixed31_32 dal_fixed31_32_recip( struct fixed31_32 dc_fixpt_recip(
struct fixed31_32 arg); struct fixed31_32 arg);
/* /*
...@@ -352,7 +352,7 @@ struct fixed31_32 dal_fixed31_32_recip( ...@@ -352,7 +352,7 @@ struct fixed31_32 dal_fixed31_32_recip(
* Argument specified in radians, * Argument specified in radians,
* internally it's normalized to [-2pi...2pi] range. * internally it's normalized to [-2pi...2pi] range.
*/ */
struct fixed31_32 dal_fixed31_32_sinc( struct fixed31_32 dc_fixpt_sinc(
struct fixed31_32 arg); struct fixed31_32 arg);
/* /*
...@@ -363,7 +363,7 @@ struct fixed31_32 dal_fixed31_32_sinc( ...@@ -363,7 +363,7 @@ struct fixed31_32 dal_fixed31_32_sinc(
* Argument specified in radians, * Argument specified in radians,
* internally it's normalized to [-2pi...2pi] range. * internally it's normalized to [-2pi...2pi] range.
*/ */
struct fixed31_32 dal_fixed31_32_sin( struct fixed31_32 dc_fixpt_sin(
struct fixed31_32 arg); struct fixed31_32 arg);
/* /*
...@@ -376,7 +376,7 @@ struct fixed31_32 dal_fixed31_32_sin( ...@@ -376,7 +376,7 @@ struct fixed31_32 dal_fixed31_32_sin(
* passing arguments outside that range * passing arguments outside that range
* will cause incorrect result! * will cause incorrect result!
*/ */
struct fixed31_32 dal_fixed31_32_cos( struct fixed31_32 dc_fixpt_cos(
struct fixed31_32 arg); struct fixed31_32 arg);
/* /*
...@@ -391,7 +391,7 @@ struct fixed31_32 dal_fixed31_32_cos( ...@@ -391,7 +391,7 @@ struct fixed31_32 dal_fixed31_32_cos(
* @note * @note
* Currently, function is verified for abs(arg) <= 1. * Currently, function is verified for abs(arg) <= 1.
*/ */
struct fixed31_32 dal_fixed31_32_exp( struct fixed31_32 dc_fixpt_exp(
struct fixed31_32 arg); struct fixed31_32 arg);
/* /*
...@@ -404,7 +404,7 @@ struct fixed31_32 dal_fixed31_32_exp( ...@@ -404,7 +404,7 @@ struct fixed31_32 dal_fixed31_32_exp(
* Currently, no special actions taken * Currently, no special actions taken
* in case of invalid argument(s). Take care! * in case of invalid argument(s). Take care!
*/ */
struct fixed31_32 dal_fixed31_32_log( struct fixed31_32 dc_fixpt_log(
struct fixed31_32 arg); struct fixed31_32 arg);
/* /*
...@@ -419,7 +419,7 @@ struct fixed31_32 dal_fixed31_32_log( ...@@ -419,7 +419,7 @@ struct fixed31_32 dal_fixed31_32_log(
* @note * @note
* Currently, abs(arg1) should be less than 1. Take care! * Currently, abs(arg1) should be less than 1. Take care!
*/ */
struct fixed31_32 dal_fixed31_32_pow( struct fixed31_32 dc_fixpt_pow(
struct fixed31_32 arg1, struct fixed31_32 arg1,
struct fixed31_32 arg2); struct fixed31_32 arg2);
...@@ -432,21 +432,21 @@ struct fixed31_32 dal_fixed31_32_pow( ...@@ -432,21 +432,21 @@ struct fixed31_32 dal_fixed31_32_pow(
* @brief * @brief
* result = floor(arg) := greatest integer lower than or equal to arg * result = floor(arg) := greatest integer lower than or equal to arg
*/ */
int dal_fixed31_32_floor( int dc_fixpt_floor(
struct fixed31_32 arg); struct fixed31_32 arg);
/* /*
* @brief * @brief
* result = round(arg) := integer nearest to arg * result = round(arg) := integer nearest to arg
*/ */
int dal_fixed31_32_round( int dc_fixpt_round(
struct fixed31_32 arg); struct fixed31_32 arg);
/* /*
* @brief * @brief
* result = ceil(arg) := lowest integer greater than or equal to arg * result = ceil(arg) := lowest integer greater than or equal to arg
*/ */
int dal_fixed31_32_ceil( int dc_fixpt_ceil(
struct fixed31_32 arg); struct fixed31_32 arg);
/* the following two function are used in scaler hw programming to convert fixed /* the following two function are used in scaler hw programming to convert fixed
...@@ -455,20 +455,20 @@ int dal_fixed31_32_ceil( ...@@ -455,20 +455,20 @@ int dal_fixed31_32_ceil(
* fractional * fractional
*/ */
unsigned int dal_fixed31_32_u2d19( unsigned int dc_fixpt_u2d19(
struct fixed31_32 arg); struct fixed31_32 arg);
unsigned int dal_fixed31_32_u0d19( unsigned int dc_fixpt_u0d19(
struct fixed31_32 arg); struct fixed31_32 arg);
unsigned int dal_fixed31_32_clamp_u0d14( unsigned int dc_fixpt_clamp_u0d14(
struct fixed31_32 arg); struct fixed31_32 arg);
unsigned int dal_fixed31_32_clamp_u0d10( unsigned int dc_fixpt_clamp_u0d10(
struct fixed31_32 arg); struct fixed31_32 arg);
int dal_fixed31_32_s4d19( int dc_fixpt_s4d19(
struct fixed31_32 arg); struct fixed31_32 arg);
#endif #endif
/*
* 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
*
*/
#ifndef __DAL_FIXED32_32_H__
#define __DAL_FIXED32_32_H__
#include "os_types.h"
struct fixed32_32 {
uint64_t value;
};
static const struct fixed32_32 dal_fixed32_32_zero = { 0 };
static const struct fixed32_32 dal_fixed32_32_one = { 0x100000000LL };
static const struct fixed32_32 dal_fixed32_32_half = { 0x80000000LL };
struct fixed32_32 dal_fixed32_32_from_fraction(uint32_t n, uint32_t d);
static inline struct fixed32_32 dal_fixed32_32_from_int(uint32_t value)
{
struct fixed32_32 fx;
fx.value = (uint64_t)value<<32;
return fx;
}
struct fixed32_32 dal_fixed32_32_add(
struct fixed32_32 lhs,
struct fixed32_32 rhs);
struct fixed32_32 dal_fixed32_32_add_int(
struct fixed32_32 lhs,
uint32_t rhs);
struct fixed32_32 dal_fixed32_32_sub(
struct fixed32_32 lhs,
struct fixed32_32 rhs);
struct fixed32_32 dal_fixed32_32_sub_int(
struct fixed32_32 lhs,
uint32_t rhs);
struct fixed32_32 dal_fixed32_32_mul(
struct fixed32_32 lhs,
struct fixed32_32 rhs);
struct fixed32_32 dal_fixed32_32_mul_int(
struct fixed32_32 lhs,
uint32_t rhs);
struct fixed32_32 dal_fixed32_32_div(
struct fixed32_32 lhs,
struct fixed32_32 rhs);
struct fixed32_32 dal_fixed32_32_div_int(
struct fixed32_32 lhs,
uint32_t rhs);
static inline struct fixed32_32 dal_fixed32_32_min(struct fixed32_32 lhs,
struct fixed32_32 rhs)
{
return (lhs.value < rhs.value) ? lhs : rhs;
}
static inline struct fixed32_32 dal_fixed32_32_max(struct fixed32_32 lhs,
struct fixed32_32 rhs)
{
return (lhs.value > rhs.value) ? lhs : rhs;
}
static inline bool dal_fixed32_32_gt(struct fixed32_32 lhs, struct fixed32_32 rhs)
{
return lhs.value > rhs.value;
}
static inline bool dal_fixed32_32_gt_int(struct fixed32_32 lhs, uint32_t rhs)
{
return lhs.value > ((uint64_t)rhs<<32);
}
static inline bool dal_fixed32_32_lt(struct fixed32_32 lhs, struct fixed32_32 rhs)
{
return lhs.value < rhs.value;
}
static inline bool dal_fixed32_32_lt_int(struct fixed32_32 lhs, uint32_t rhs)
{
return lhs.value < ((uint64_t)rhs<<32);
}
static inline bool dal_fixed32_32_le(struct fixed32_32 lhs, struct fixed32_32 rhs)
{
return lhs.value <= rhs.value;
}
static inline bool dal_fixed32_32_le_int(struct fixed32_32 lhs, uint32_t rhs)
{
return lhs.value <= ((uint64_t)rhs<<32);
}
static inline bool dal_fixed32_32_eq(struct fixed32_32 lhs, struct fixed32_32 rhs)
{
return lhs.value == rhs.value;
}
uint32_t dal_fixed32_32_ceil(struct fixed32_32 value);
static inline uint32_t dal_fixed32_32_floor(struct fixed32_32 value)
{
return value.value>>32;
}
uint32_t dal_fixed32_32_round(struct fixed32_32 value);
#endif
...@@ -43,7 +43,7 @@ static bool de_pq_initialized; /* = false; */ ...@@ -43,7 +43,7 @@ static bool de_pq_initialized; /* = false; */
/* one-time setup of X points */ /* one-time setup of X points */
void setup_x_points_distribution(void) void setup_x_points_distribution(void)
{ {
struct fixed31_32 region_size = dal_fixed31_32_from_int(128); struct fixed31_32 region_size = dc_fixpt_from_int(128);
int32_t segment; int32_t segment;
uint32_t seg_offset; uint32_t seg_offset;
uint32_t index; uint32_t index;
...@@ -53,8 +53,8 @@ void setup_x_points_distribution(void) ...@@ -53,8 +53,8 @@ void setup_x_points_distribution(void)
coordinates_x[MAX_HW_POINTS + 1].x = region_size; coordinates_x[MAX_HW_POINTS + 1].x = region_size;
for (segment = 6; segment > (6 - NUM_REGIONS); segment--) { for (segment = 6; segment > (6 - NUM_REGIONS); segment--) {
region_size = dal_fixed31_32_div_int(region_size, 2); region_size = dc_fixpt_div_int(region_size, 2);
increment = dal_fixed31_32_div_int(region_size, increment = dc_fixpt_div_int(region_size,
NUM_PTS_IN_REGION); NUM_PTS_IN_REGION);
seg_offset = (segment + (NUM_REGIONS - 7)) * NUM_PTS_IN_REGION; seg_offset = (segment + (NUM_REGIONS - 7)) * NUM_PTS_IN_REGION;
coordinates_x[seg_offset].x = region_size; coordinates_x[seg_offset].x = region_size;
...@@ -62,7 +62,7 @@ void setup_x_points_distribution(void) ...@@ -62,7 +62,7 @@ void setup_x_points_distribution(void)
for (index = seg_offset + 1; for (index = seg_offset + 1;
index < seg_offset + NUM_PTS_IN_REGION; index < seg_offset + NUM_PTS_IN_REGION;
index++) { index++) {
coordinates_x[index].x = dal_fixed31_32_add coordinates_x[index].x = dc_fixpt_add
(coordinates_x[index-1].x, increment); (coordinates_x[index-1].x, increment);
} }
} }
...@@ -72,63 +72,63 @@ static void compute_pq(struct fixed31_32 in_x, struct fixed31_32 *out_y) ...@@ -72,63 +72,63 @@ static void compute_pq(struct fixed31_32 in_x, struct fixed31_32 *out_y)
{ {
/* consts for PQ gamma formula. */ /* consts for PQ gamma formula. */
const struct fixed31_32 m1 = const struct fixed31_32 m1 =
dal_fixed31_32_from_fraction(159301758, 1000000000); dc_fixpt_from_fraction(159301758, 1000000000);
const struct fixed31_32 m2 = const struct fixed31_32 m2 =
dal_fixed31_32_from_fraction(7884375, 100000); dc_fixpt_from_fraction(7884375, 100000);
const struct fixed31_32 c1 = const struct fixed31_32 c1 =
dal_fixed31_32_from_fraction(8359375, 10000000); dc_fixpt_from_fraction(8359375, 10000000);
const struct fixed31_32 c2 = const struct fixed31_32 c2 =
dal_fixed31_32_from_fraction(188515625, 10000000); dc_fixpt_from_fraction(188515625, 10000000);
const struct fixed31_32 c3 = const struct fixed31_32 c3 =
dal_fixed31_32_from_fraction(186875, 10000); dc_fixpt_from_fraction(186875, 10000);
struct fixed31_32 l_pow_m1; struct fixed31_32 l_pow_m1;
struct fixed31_32 base; struct fixed31_32 base;
if (dal_fixed31_32_lt(in_x, dal_fixed31_32_zero)) if (dc_fixpt_lt(in_x, dc_fixpt_zero))
in_x = dal_fixed31_32_zero; in_x = dc_fixpt_zero;
l_pow_m1 = dal_fixed31_32_pow(in_x, m1); l_pow_m1 = dc_fixpt_pow(in_x, m1);
base = dal_fixed31_32_div( base = dc_fixpt_div(
dal_fixed31_32_add(c1, dc_fixpt_add(c1,
(dal_fixed31_32_mul(c2, l_pow_m1))), (dc_fixpt_mul(c2, l_pow_m1))),
dal_fixed31_32_add(dal_fixed31_32_one, dc_fixpt_add(dc_fixpt_one,
(dal_fixed31_32_mul(c3, l_pow_m1)))); (dc_fixpt_mul(c3, l_pow_m1))));
*out_y = dal_fixed31_32_pow(base, m2); *out_y = dc_fixpt_pow(base, m2);
} }
static void compute_de_pq(struct fixed31_32 in_x, struct fixed31_32 *out_y) static void compute_de_pq(struct fixed31_32 in_x, struct fixed31_32 *out_y)
{ {
/* consts for dePQ gamma formula. */ /* consts for dePQ gamma formula. */
const struct fixed31_32 m1 = const struct fixed31_32 m1 =
dal_fixed31_32_from_fraction(159301758, 1000000000); dc_fixpt_from_fraction(159301758, 1000000000);
const struct fixed31_32 m2 = const struct fixed31_32 m2 =
dal_fixed31_32_from_fraction(7884375, 100000); dc_fixpt_from_fraction(7884375, 100000);
const struct fixed31_32 c1 = const struct fixed31_32 c1 =
dal_fixed31_32_from_fraction(8359375, 10000000); dc_fixpt_from_fraction(8359375, 10000000);
const struct fixed31_32 c2 = const struct fixed31_32 c2 =
dal_fixed31_32_from_fraction(188515625, 10000000); dc_fixpt_from_fraction(188515625, 10000000);
const struct fixed31_32 c3 = const struct fixed31_32 c3 =
dal_fixed31_32_from_fraction(186875, 10000); dc_fixpt_from_fraction(186875, 10000);
struct fixed31_32 l_pow_m1; struct fixed31_32 l_pow_m1;
struct fixed31_32 base, div; struct fixed31_32 base, div;
if (dal_fixed31_32_lt(in_x, dal_fixed31_32_zero)) if (dc_fixpt_lt(in_x, dc_fixpt_zero))
in_x = dal_fixed31_32_zero; in_x = dc_fixpt_zero;
l_pow_m1 = dal_fixed31_32_pow(in_x, l_pow_m1 = dc_fixpt_pow(in_x,
dal_fixed31_32_div(dal_fixed31_32_one, m2)); dc_fixpt_div(dc_fixpt_one, m2));
base = dal_fixed31_32_sub(l_pow_m1, c1); base = dc_fixpt_sub(l_pow_m1, c1);
if (dal_fixed31_32_lt(base, dal_fixed31_32_zero)) if (dc_fixpt_lt(base, dc_fixpt_zero))
base = dal_fixed31_32_zero; base = dc_fixpt_zero;
div = dal_fixed31_32_sub(c2, dal_fixed31_32_mul(c3, l_pow_m1)); div = dc_fixpt_sub(c2, dc_fixpt_mul(c3, l_pow_m1));
*out_y = dal_fixed31_32_pow(dal_fixed31_32_div(base, div), *out_y = dc_fixpt_pow(dc_fixpt_div(base, div),
dal_fixed31_32_div(dal_fixed31_32_one, m1)); dc_fixpt_div(dc_fixpt_one, m1));
} }
/* one-time pre-compute PQ values - only for sdr_white_level 80 */ /* one-time pre-compute PQ values - only for sdr_white_level 80 */
...@@ -138,14 +138,14 @@ void precompute_pq(void) ...@@ -138,14 +138,14 @@ void precompute_pq(void)
struct fixed31_32 x; struct fixed31_32 x;
const struct hw_x_point *coord_x = coordinates_x + 32; const struct hw_x_point *coord_x = coordinates_x + 32;
struct fixed31_32 scaling_factor = struct fixed31_32 scaling_factor =
dal_fixed31_32_from_fraction(80, 10000); dc_fixpt_from_fraction(80, 10000);
/* pow function has problems with arguments too small */ /* pow function has problems with arguments too small */
for (i = 0; i < 32; i++) for (i = 0; i < 32; i++)
pq_table[i] = dal_fixed31_32_zero; pq_table[i] = dc_fixpt_zero;
for (i = 32; i <= MAX_HW_POINTS; i++) { for (i = 32; i <= MAX_HW_POINTS; i++) {
x = dal_fixed31_32_mul(coord_x->x, scaling_factor); x = dc_fixpt_mul(coord_x->x, scaling_factor);
compute_pq(x, &pq_table[i]); compute_pq(x, &pq_table[i]);
++coord_x; ++coord_x;
} }
...@@ -158,7 +158,7 @@ void precompute_de_pq(void) ...@@ -158,7 +158,7 @@ void precompute_de_pq(void)
struct fixed31_32 y; struct fixed31_32 y;
uint32_t begin_index, end_index; uint32_t begin_index, end_index;
struct fixed31_32 scaling_factor = dal_fixed31_32_from_int(125); struct fixed31_32 scaling_factor = dc_fixpt_from_int(125);
/* X points is 2^-25 to 2^7 /* X points is 2^-25 to 2^7
* De-gamma X is 2^-12 to 2^0 – we are skipping first -12-(-25) = 13 regions * De-gamma X is 2^-12 to 2^0 – we are skipping first -12-(-25) = 13 regions
...@@ -167,11 +167,11 @@ void precompute_de_pq(void) ...@@ -167,11 +167,11 @@ void precompute_de_pq(void)
end_index = begin_index + 12 * NUM_PTS_IN_REGION; end_index = begin_index + 12 * NUM_PTS_IN_REGION;
for (i = 0; i <= begin_index; i++) for (i = 0; i <= begin_index; i++)
de_pq_table[i] = dal_fixed31_32_zero; de_pq_table[i] = dc_fixpt_zero;
for (; i <= end_index; i++) { for (; i <= end_index; i++) {
compute_de_pq(coordinates_x[i].x, &y); compute_de_pq(coordinates_x[i].x, &y);
de_pq_table[i] = dal_fixed31_32_mul(y, scaling_factor); de_pq_table[i] = dc_fixpt_mul(y, scaling_factor);
} }
for (; i <= MAX_HW_POINTS; i++) for (; i <= MAX_HW_POINTS; i++)
...@@ -195,15 +195,15 @@ static void build_coefficients(struct gamma_coefficients *coefficients, bool is_ ...@@ -195,15 +195,15 @@ static void build_coefficients(struct gamma_coefficients *coefficients, bool is_
uint32_t index = is_2_4 == true ? 0:1; uint32_t index = is_2_4 == true ? 0:1;
do { do {
coefficients->a0[i] = dal_fixed31_32_from_fraction( coefficients->a0[i] = dc_fixpt_from_fraction(
numerator01[index], 10000000); numerator01[index], 10000000);
coefficients->a1[i] = dal_fixed31_32_from_fraction( coefficients->a1[i] = dc_fixpt_from_fraction(
numerator02[index], 1000); numerator02[index], 1000);
coefficients->a2[i] = dal_fixed31_32_from_fraction( coefficients->a2[i] = dc_fixpt_from_fraction(
numerator03[index], 1000); numerator03[index], 1000);
coefficients->a3[i] = dal_fixed31_32_from_fraction( coefficients->a3[i] = dc_fixpt_from_fraction(
numerator04[index], 1000); numerator04[index], 1000);
coefficients->user_gamma[i] = dal_fixed31_32_from_fraction( coefficients->user_gamma[i] = dc_fixpt_from_fraction(
numerator05[index], 1000); numerator05[index], 1000);
++i; ++i;
...@@ -218,33 +218,33 @@ static struct fixed31_32 translate_from_linear_space( ...@@ -218,33 +218,33 @@ static struct fixed31_32 translate_from_linear_space(
struct fixed31_32 a3, struct fixed31_32 a3,
struct fixed31_32 gamma) struct fixed31_32 gamma)
{ {
const struct fixed31_32 one = dal_fixed31_32_from_int(1); const struct fixed31_32 one = dc_fixpt_from_int(1);
if (dal_fixed31_32_lt(one, arg)) if (dc_fixpt_lt(one, arg))
return one; return one;
if (dal_fixed31_32_le(arg, dal_fixed31_32_neg(a0))) if (dc_fixpt_le(arg, dc_fixpt_neg(a0)))
return dal_fixed31_32_sub( return dc_fixpt_sub(
a2, a2,
dal_fixed31_32_mul( dc_fixpt_mul(
dal_fixed31_32_add( dc_fixpt_add(
one, one,
a3), a3),
dal_fixed31_32_pow( dc_fixpt_pow(
dal_fixed31_32_neg(arg), dc_fixpt_neg(arg),
dal_fixed31_32_recip(gamma)))); dc_fixpt_recip(gamma))));
else if (dal_fixed31_32_le(a0, arg)) else if (dc_fixpt_le(a0, arg))
return dal_fixed31_32_sub( return dc_fixpt_sub(
dal_fixed31_32_mul( dc_fixpt_mul(
dal_fixed31_32_add( dc_fixpt_add(
one, one,
a3), a3),
dal_fixed31_32_pow( dc_fixpt_pow(
arg, arg,
dal_fixed31_32_recip(gamma))), dc_fixpt_recip(gamma))),
a2); a2);
else else
return dal_fixed31_32_mul( return dc_fixpt_mul(
arg, arg,
a1); a1);
} }
...@@ -259,25 +259,25 @@ static struct fixed31_32 translate_to_linear_space( ...@@ -259,25 +259,25 @@ static struct fixed31_32 translate_to_linear_space(
{ {
struct fixed31_32 linear; struct fixed31_32 linear;
a0 = dal_fixed31_32_mul(a0, a1); a0 = dc_fixpt_mul(a0, a1);
if (dal_fixed31_32_le(arg, dal_fixed31_32_neg(a0))) if (dc_fixpt_le(arg, dc_fixpt_neg(a0)))
linear = dal_fixed31_32_neg( linear = dc_fixpt_neg(
dal_fixed31_32_pow( dc_fixpt_pow(
dal_fixed31_32_div( dc_fixpt_div(
dal_fixed31_32_sub(a2, arg), dc_fixpt_sub(a2, arg),
dal_fixed31_32_add( dc_fixpt_add(
dal_fixed31_32_one, a3)), gamma)); dc_fixpt_one, a3)), gamma));
else if (dal_fixed31_32_le(dal_fixed31_32_neg(a0), arg) && else if (dc_fixpt_le(dc_fixpt_neg(a0), arg) &&
dal_fixed31_32_le(arg, a0)) dc_fixpt_le(arg, a0))
linear = dal_fixed31_32_div(arg, a1); linear = dc_fixpt_div(arg, a1);
else else
linear = dal_fixed31_32_pow( linear = dc_fixpt_pow(
dal_fixed31_32_div( dc_fixpt_div(
dal_fixed31_32_add(a2, arg), dc_fixpt_add(a2, arg),
dal_fixed31_32_add( dc_fixpt_add(
dal_fixed31_32_one, a3)), gamma); dc_fixpt_one, a3)), gamma);
return linear; return linear;
} }
...@@ -352,8 +352,8 @@ static bool find_software_points( ...@@ -352,8 +352,8 @@ static bool find_software_points(
right = axis_x[max_number - 1].b; right = axis_x[max_number - 1].b;
} }
if (dal_fixed31_32_le(left, hw_point) && if (dc_fixpt_le(left, hw_point) &&
dal_fixed31_32_le(hw_point, right)) { dc_fixpt_le(hw_point, right)) {
*index_to_start = i; *index_to_start = i;
*index_left = i; *index_left = i;
...@@ -366,7 +366,7 @@ static bool find_software_points( ...@@ -366,7 +366,7 @@ static bool find_software_points(
return true; return true;
} else if ((i == *index_to_start) && } else if ((i == *index_to_start) &&
dal_fixed31_32_le(hw_point, left)) { dc_fixpt_le(hw_point, left)) {
*index_to_start = i; *index_to_start = i;
*index_left = i; *index_left = i;
*index_right = i; *index_right = i;
...@@ -375,7 +375,7 @@ static bool find_software_points( ...@@ -375,7 +375,7 @@ static bool find_software_points(
return true; return true;
} else if ((i == max_number - 1) && } else if ((i == max_number - 1) &&
dal_fixed31_32_le(right, hw_point)) { dc_fixpt_le(right, hw_point)) {
*index_to_start = i; *index_to_start = i;
*index_left = i; *index_left = i;
*index_right = i; *index_right = i;
...@@ -457,17 +457,17 @@ static bool build_custom_gamma_mapping_coefficients_worker( ...@@ -457,17 +457,17 @@ static bool build_custom_gamma_mapping_coefficients_worker(
} }
if (hw_pos == HW_POINT_POSITION_MIDDLE) if (hw_pos == HW_POINT_POSITION_MIDDLE)
point->coeff = dal_fixed31_32_div( point->coeff = dc_fixpt_div(
dal_fixed31_32_sub( dc_fixpt_sub(
coord_x, coord_x,
left_pos), left_pos),
dal_fixed31_32_sub( dc_fixpt_sub(
right_pos, right_pos,
left_pos)); left_pos));
else if (hw_pos == HW_POINT_POSITION_LEFT) else if (hw_pos == HW_POINT_POSITION_LEFT)
point->coeff = dal_fixed31_32_zero; point->coeff = dc_fixpt_zero;
else if (hw_pos == HW_POINT_POSITION_RIGHT) else if (hw_pos == HW_POINT_POSITION_RIGHT)
point->coeff = dal_fixed31_32_from_int(2); point->coeff = dc_fixpt_from_int(2);
else { else {
BREAK_TO_DEBUGGER(); BREAK_TO_DEBUGGER();
return false; return false;
...@@ -502,45 +502,45 @@ static struct fixed31_32 calculate_mapped_value( ...@@ -502,45 +502,45 @@ static struct fixed31_32 calculate_mapped_value(
if ((point->left_index < 0) || (point->left_index > max_index)) { if ((point->left_index < 0) || (point->left_index > max_index)) {
BREAK_TO_DEBUGGER(); BREAK_TO_DEBUGGER();
return dal_fixed31_32_zero; return dc_fixpt_zero;
} }
if ((point->right_index < 0) || (point->right_index > max_index)) { if ((point->right_index < 0) || (point->right_index > max_index)) {
BREAK_TO_DEBUGGER(); BREAK_TO_DEBUGGER();
return dal_fixed31_32_zero; return dc_fixpt_zero;
} }
if (point->pos == HW_POINT_POSITION_MIDDLE) if (point->pos == HW_POINT_POSITION_MIDDLE)
if (channel == CHANNEL_NAME_RED) if (channel == CHANNEL_NAME_RED)
result = dal_fixed31_32_add( result = dc_fixpt_add(
dal_fixed31_32_mul( dc_fixpt_mul(
point->coeff, point->coeff,
dal_fixed31_32_sub( dc_fixpt_sub(
rgb[point->right_index].r, rgb[point->right_index].r,
rgb[point->left_index].r)), rgb[point->left_index].r)),
rgb[point->left_index].r); rgb[point->left_index].r);
else if (channel == CHANNEL_NAME_GREEN) else if (channel == CHANNEL_NAME_GREEN)
result = dal_fixed31_32_add( result = dc_fixpt_add(
dal_fixed31_32_mul( dc_fixpt_mul(
point->coeff, point->coeff,
dal_fixed31_32_sub( dc_fixpt_sub(
rgb[point->right_index].g, rgb[point->right_index].g,
rgb[point->left_index].g)), rgb[point->left_index].g)),
rgb[point->left_index].g); rgb[point->left_index].g);
else else
result = dal_fixed31_32_add( result = dc_fixpt_add(
dal_fixed31_32_mul( dc_fixpt_mul(
point->coeff, point->coeff,
dal_fixed31_32_sub( dc_fixpt_sub(
rgb[point->right_index].b, rgb[point->right_index].b,
rgb[point->left_index].b)), rgb[point->left_index].b)),
rgb[point->left_index].b); rgb[point->left_index].b);
else if (point->pos == HW_POINT_POSITION_LEFT) { else if (point->pos == HW_POINT_POSITION_LEFT) {
BREAK_TO_DEBUGGER(); BREAK_TO_DEBUGGER();
result = dal_fixed31_32_zero; result = dc_fixpt_zero;
} else { } else {
BREAK_TO_DEBUGGER(); BREAK_TO_DEBUGGER();
result = dal_fixed31_32_one; result = dc_fixpt_one;
} }
return result; return result;
...@@ -558,7 +558,7 @@ static void build_pq(struct pwl_float_data_ex *rgb_regamma, ...@@ -558,7 +558,7 @@ static void build_pq(struct pwl_float_data_ex *rgb_regamma,
struct fixed31_32 x; struct fixed31_32 x;
struct fixed31_32 output; struct fixed31_32 output;
struct fixed31_32 scaling_factor = struct fixed31_32 scaling_factor =
dal_fixed31_32_from_fraction(sdr_white_level, 10000); dc_fixpt_from_fraction(sdr_white_level, 10000);
if (!pq_initialized && sdr_white_level == 80) { if (!pq_initialized && sdr_white_level == 80) {
precompute_pq(); precompute_pq();
...@@ -579,15 +579,15 @@ static void build_pq(struct pwl_float_data_ex *rgb_regamma, ...@@ -579,15 +579,15 @@ static void build_pq(struct pwl_float_data_ex *rgb_regamma,
if (sdr_white_level == 80) { if (sdr_white_level == 80) {
output = pq_table[i]; output = pq_table[i];
} else { } else {
x = dal_fixed31_32_mul(coord_x->x, scaling_factor); x = dc_fixpt_mul(coord_x->x, scaling_factor);
compute_pq(x, &output); compute_pq(x, &output);
} }
/* should really not happen? */ /* should really not happen? */
if (dal_fixed31_32_lt(output, dal_fixed31_32_zero)) if (dc_fixpt_lt(output, dc_fixpt_zero))
output = dal_fixed31_32_zero; output = dc_fixpt_zero;
else if (dal_fixed31_32_lt(dal_fixed31_32_one, output)) else if (dc_fixpt_lt(dc_fixpt_one, output))
output = dal_fixed31_32_one; output = dc_fixpt_one;
rgb->r = output; rgb->r = output;
rgb->g = output; rgb->g = output;
...@@ -605,7 +605,7 @@ static void build_de_pq(struct pwl_float_data_ex *de_pq, ...@@ -605,7 +605,7 @@ static void build_de_pq(struct pwl_float_data_ex *de_pq,
uint32_t i; uint32_t i;
struct fixed31_32 output; struct fixed31_32 output;
struct fixed31_32 scaling_factor = dal_fixed31_32_from_int(125); struct fixed31_32 scaling_factor = dc_fixpt_from_int(125);
if (!de_pq_initialized) { if (!de_pq_initialized) {
precompute_de_pq(); precompute_de_pq();
...@@ -616,9 +616,9 @@ static void build_de_pq(struct pwl_float_data_ex *de_pq, ...@@ -616,9 +616,9 @@ static void build_de_pq(struct pwl_float_data_ex *de_pq,
for (i = 0; i <= hw_points_num; i++) { for (i = 0; i <= hw_points_num; i++) {
output = de_pq_table[i]; output = de_pq_table[i];
/* should really not happen? */ /* should really not happen? */
if (dal_fixed31_32_lt(output, dal_fixed31_32_zero)) if (dc_fixpt_lt(output, dc_fixpt_zero))
output = dal_fixed31_32_zero; output = dc_fixpt_zero;
else if (dal_fixed31_32_lt(scaling_factor, output)) else if (dc_fixpt_lt(scaling_factor, output))
output = scaling_factor; output = scaling_factor;
de_pq[i].r = output; de_pq[i].r = output;
de_pq[i].g = output; de_pq[i].g = output;
...@@ -670,9 +670,9 @@ static void build_degamma(struct pwl_float_data_ex *curve, ...@@ -670,9 +670,9 @@ static void build_degamma(struct pwl_float_data_ex *curve,
end_index = begin_index + 12 * NUM_PTS_IN_REGION; end_index = begin_index + 12 * NUM_PTS_IN_REGION;
while (i != begin_index) { while (i != begin_index) {
curve[i].r = dal_fixed31_32_zero; curve[i].r = dc_fixpt_zero;
curve[i].g = dal_fixed31_32_zero; curve[i].g = dc_fixpt_zero;
curve[i].b = dal_fixed31_32_zero; curve[i].b = dc_fixpt_zero;
i++; i++;
} }
...@@ -684,9 +684,9 @@ static void build_degamma(struct pwl_float_data_ex *curve, ...@@ -684,9 +684,9 @@ static void build_degamma(struct pwl_float_data_ex *curve,
i++; i++;
} }
while (i != hw_points_num + 1) { while (i != hw_points_num + 1) {
curve[i].r = dal_fixed31_32_one; curve[i].r = dc_fixpt_one;
curve[i].g = dal_fixed31_32_one; curve[i].g = dc_fixpt_one;
curve[i].b = dal_fixed31_32_one; curve[i].b = dc_fixpt_one;
i++; i++;
} }
} }
...@@ -695,8 +695,8 @@ static void scale_gamma(struct pwl_float_data *pwl_rgb, ...@@ -695,8 +695,8 @@ static void scale_gamma(struct pwl_float_data *pwl_rgb,
const struct dc_gamma *ramp, const struct dc_gamma *ramp,
struct dividers dividers) struct dividers dividers)
{ {
const struct fixed31_32 max_driver = dal_fixed31_32_from_int(0xFFFF); const struct fixed31_32 max_driver = dc_fixpt_from_int(0xFFFF);
const struct fixed31_32 max_os = dal_fixed31_32_from_int(0xFF00); const struct fixed31_32 max_os = dc_fixpt_from_int(0xFF00);
struct fixed31_32 scaler = max_os; struct fixed31_32 scaler = max_os;
uint32_t i; uint32_t i;
struct pwl_float_data *rgb = pwl_rgb; struct pwl_float_data *rgb = pwl_rgb;
...@@ -705,9 +705,9 @@ static void scale_gamma(struct pwl_float_data *pwl_rgb, ...@@ -705,9 +705,9 @@ static void scale_gamma(struct pwl_float_data *pwl_rgb,
i = 0; i = 0;
do { do {
if (dal_fixed31_32_lt(max_os, ramp->entries.red[i]) || if (dc_fixpt_lt(max_os, ramp->entries.red[i]) ||
dal_fixed31_32_lt(max_os, ramp->entries.green[i]) || dc_fixpt_lt(max_os, ramp->entries.green[i]) ||
dal_fixed31_32_lt(max_os, ramp->entries.blue[i])) { dc_fixpt_lt(max_os, ramp->entries.blue[i])) {
scaler = max_driver; scaler = max_driver;
break; break;
} }
...@@ -717,40 +717,40 @@ static void scale_gamma(struct pwl_float_data *pwl_rgb, ...@@ -717,40 +717,40 @@ static void scale_gamma(struct pwl_float_data *pwl_rgb,
i = 0; i = 0;
do { do {
rgb->r = dal_fixed31_32_div( rgb->r = dc_fixpt_div(
ramp->entries.red[i], scaler); ramp->entries.red[i], scaler);
rgb->g = dal_fixed31_32_div( rgb->g = dc_fixpt_div(
ramp->entries.green[i], scaler); ramp->entries.green[i], scaler);
rgb->b = dal_fixed31_32_div( rgb->b = dc_fixpt_div(
ramp->entries.blue[i], scaler); ramp->entries.blue[i], scaler);
++rgb; ++rgb;
++i; ++i;
} while (i != ramp->num_entries); } while (i != ramp->num_entries);
rgb->r = dal_fixed31_32_mul(rgb_last->r, rgb->r = dc_fixpt_mul(rgb_last->r,
dividers.divider1); dividers.divider1);
rgb->g = dal_fixed31_32_mul(rgb_last->g, rgb->g = dc_fixpt_mul(rgb_last->g,
dividers.divider1); dividers.divider1);
rgb->b = dal_fixed31_32_mul(rgb_last->b, rgb->b = dc_fixpt_mul(rgb_last->b,
dividers.divider1); dividers.divider1);
++rgb; ++rgb;
rgb->r = dal_fixed31_32_mul(rgb_last->r, rgb->r = dc_fixpt_mul(rgb_last->r,
dividers.divider2); dividers.divider2);
rgb->g = dal_fixed31_32_mul(rgb_last->g, rgb->g = dc_fixpt_mul(rgb_last->g,
dividers.divider2); dividers.divider2);
rgb->b = dal_fixed31_32_mul(rgb_last->b, rgb->b = dc_fixpt_mul(rgb_last->b,
dividers.divider2); dividers.divider2);
++rgb; ++rgb;
rgb->r = dal_fixed31_32_mul(rgb_last->r, rgb->r = dc_fixpt_mul(rgb_last->r,
dividers.divider3); dividers.divider3);
rgb->g = dal_fixed31_32_mul(rgb_last->g, rgb->g = dc_fixpt_mul(rgb_last->g,
dividers.divider3); dividers.divider3);
rgb->b = dal_fixed31_32_mul(rgb_last->b, rgb->b = dc_fixpt_mul(rgb_last->b,
dividers.divider3); dividers.divider3);
} }
...@@ -759,62 +759,62 @@ static void scale_gamma_dx(struct pwl_float_data *pwl_rgb, ...@@ -759,62 +759,62 @@ static void scale_gamma_dx(struct pwl_float_data *pwl_rgb,
struct dividers dividers) struct dividers dividers)
{ {
uint32_t i; uint32_t i;
struct fixed31_32 min = dal_fixed31_32_zero; struct fixed31_32 min = dc_fixpt_zero;
struct fixed31_32 max = dal_fixed31_32_one; struct fixed31_32 max = dc_fixpt_one;
struct fixed31_32 delta = dal_fixed31_32_zero; struct fixed31_32 delta = dc_fixpt_zero;
struct fixed31_32 offset = dal_fixed31_32_zero; struct fixed31_32 offset = dc_fixpt_zero;
for (i = 0 ; i < ramp->num_entries; i++) { for (i = 0 ; i < ramp->num_entries; i++) {
if (dal_fixed31_32_lt(ramp->entries.red[i], min)) if (dc_fixpt_lt(ramp->entries.red[i], min))
min = ramp->entries.red[i]; min = ramp->entries.red[i];
if (dal_fixed31_32_lt(ramp->entries.green[i], min)) if (dc_fixpt_lt(ramp->entries.green[i], min))
min = ramp->entries.green[i]; min = ramp->entries.green[i];
if (dal_fixed31_32_lt(ramp->entries.blue[i], min)) if (dc_fixpt_lt(ramp->entries.blue[i], min))
min = ramp->entries.blue[i]; min = ramp->entries.blue[i];
if (dal_fixed31_32_lt(max, ramp->entries.red[i])) if (dc_fixpt_lt(max, ramp->entries.red[i]))
max = ramp->entries.red[i]; max = ramp->entries.red[i];
if (dal_fixed31_32_lt(max, ramp->entries.green[i])) if (dc_fixpt_lt(max, ramp->entries.green[i]))
max = ramp->entries.green[i]; max = ramp->entries.green[i];
if (dal_fixed31_32_lt(max, ramp->entries.blue[i])) if (dc_fixpt_lt(max, ramp->entries.blue[i]))
max = ramp->entries.blue[i]; max = ramp->entries.blue[i];
} }
if (dal_fixed31_32_lt(min, dal_fixed31_32_zero)) if (dc_fixpt_lt(min, dc_fixpt_zero))
delta = dal_fixed31_32_neg(min); delta = dc_fixpt_neg(min);
offset = dal_fixed31_32_add(min, max); offset = dc_fixpt_add(min, max);
for (i = 0 ; i < ramp->num_entries; i++) { for (i = 0 ; i < ramp->num_entries; i++) {
pwl_rgb[i].r = dal_fixed31_32_div( pwl_rgb[i].r = dc_fixpt_div(
dal_fixed31_32_add( dc_fixpt_add(
ramp->entries.red[i], delta), offset); ramp->entries.red[i], delta), offset);
pwl_rgb[i].g = dal_fixed31_32_div( pwl_rgb[i].g = dc_fixpt_div(
dal_fixed31_32_add( dc_fixpt_add(
ramp->entries.green[i], delta), offset); ramp->entries.green[i], delta), offset);
pwl_rgb[i].b = dal_fixed31_32_div( pwl_rgb[i].b = dc_fixpt_div(
dal_fixed31_32_add( dc_fixpt_add(
ramp->entries.blue[i], delta), offset); ramp->entries.blue[i], delta), offset);
} }
pwl_rgb[i].r = dal_fixed31_32_sub(dal_fixed31_32_mul_int( pwl_rgb[i].r = dc_fixpt_sub(dc_fixpt_mul_int(
pwl_rgb[i-1].r, 2), pwl_rgb[i-2].r); pwl_rgb[i-1].r, 2), pwl_rgb[i-2].r);
pwl_rgb[i].g = dal_fixed31_32_sub(dal_fixed31_32_mul_int( pwl_rgb[i].g = dc_fixpt_sub(dc_fixpt_mul_int(
pwl_rgb[i-1].g, 2), pwl_rgb[i-2].g); pwl_rgb[i-1].g, 2), pwl_rgb[i-2].g);
pwl_rgb[i].b = dal_fixed31_32_sub(dal_fixed31_32_mul_int( pwl_rgb[i].b = dc_fixpt_sub(dc_fixpt_mul_int(
pwl_rgb[i-1].b, 2), pwl_rgb[i-2].b); pwl_rgb[i-1].b, 2), pwl_rgb[i-2].b);
++i; ++i;
pwl_rgb[i].r = dal_fixed31_32_sub(dal_fixed31_32_mul_int( pwl_rgb[i].r = dc_fixpt_sub(dc_fixpt_mul_int(
pwl_rgb[i-1].r, 2), pwl_rgb[i-2].r); pwl_rgb[i-1].r, 2), pwl_rgb[i-2].r);
pwl_rgb[i].g = dal_fixed31_32_sub(dal_fixed31_32_mul_int( pwl_rgb[i].g = dc_fixpt_sub(dc_fixpt_mul_int(
pwl_rgb[i-1].g, 2), pwl_rgb[i-2].g); pwl_rgb[i-1].g, 2), pwl_rgb[i-2].g);
pwl_rgb[i].b = dal_fixed31_32_sub(dal_fixed31_32_mul_int( pwl_rgb[i].b = dc_fixpt_sub(dc_fixpt_mul_int(
pwl_rgb[i-1].b, 2), pwl_rgb[i-2].b); pwl_rgb[i-1].b, 2), pwl_rgb[i-2].b);
} }
...@@ -846,40 +846,40 @@ static void scale_user_regamma_ramp(struct pwl_float_data *pwl_rgb, ...@@ -846,40 +846,40 @@ static void scale_user_regamma_ramp(struct pwl_float_data *pwl_rgb,
i = 0; i = 0;
do { do {
rgb->r = dal_fixed31_32_from_fraction( rgb->r = dc_fixpt_from_fraction(
ramp->gamma[i], scaler); ramp->gamma[i], scaler);
rgb->g = dal_fixed31_32_from_fraction( rgb->g = dc_fixpt_from_fraction(
ramp->gamma[i + 256], scaler); ramp->gamma[i + 256], scaler);
rgb->b = dal_fixed31_32_from_fraction( rgb->b = dc_fixpt_from_fraction(
ramp->gamma[i + 512], scaler); ramp->gamma[i + 512], scaler);
++rgb; ++rgb;
++i; ++i;
} while (i != GAMMA_RGB_256_ENTRIES); } while (i != GAMMA_RGB_256_ENTRIES);
rgb->r = dal_fixed31_32_mul(rgb_last->r, rgb->r = dc_fixpt_mul(rgb_last->r,
dividers.divider1); dividers.divider1);
rgb->g = dal_fixed31_32_mul(rgb_last->g, rgb->g = dc_fixpt_mul(rgb_last->g,
dividers.divider1); dividers.divider1);
rgb->b = dal_fixed31_32_mul(rgb_last->b, rgb->b = dc_fixpt_mul(rgb_last->b,
dividers.divider1); dividers.divider1);
++rgb; ++rgb;
rgb->r = dal_fixed31_32_mul(rgb_last->r, rgb->r = dc_fixpt_mul(rgb_last->r,
dividers.divider2); dividers.divider2);
rgb->g = dal_fixed31_32_mul(rgb_last->g, rgb->g = dc_fixpt_mul(rgb_last->g,
dividers.divider2); dividers.divider2);
rgb->b = dal_fixed31_32_mul(rgb_last->b, rgb->b = dc_fixpt_mul(rgb_last->b,
dividers.divider2); dividers.divider2);
++rgb; ++rgb;
rgb->r = dal_fixed31_32_mul(rgb_last->r, rgb->r = dc_fixpt_mul(rgb_last->r,
dividers.divider3); dividers.divider3);
rgb->g = dal_fixed31_32_mul(rgb_last->g, rgb->g = dc_fixpt_mul(rgb_last->g,
dividers.divider3); dividers.divider3);
rgb->b = dal_fixed31_32_mul(rgb_last->b, rgb->b = dc_fixpt_mul(rgb_last->b,
dividers.divider3); dividers.divider3);
} }
...@@ -913,7 +913,7 @@ static void apply_lut_1d( ...@@ -913,7 +913,7 @@ static void apply_lut_1d(
struct fixed31_32 lut2; struct fixed31_32 lut2;
const int max_lut_index = 4095; const int max_lut_index = 4095;
const struct fixed31_32 max_lut_index_f = const struct fixed31_32 max_lut_index_f =
dal_fixed31_32_from_int_nonconst(max_lut_index); dc_fixpt_from_int_nonconst(max_lut_index);
int32_t index = 0, index_next = 0; int32_t index = 0, index_next = 0;
struct fixed31_32 index_f; struct fixed31_32 index_f;
struct fixed31_32 delta_lut; struct fixed31_32 delta_lut;
...@@ -931,10 +931,10 @@ static void apply_lut_1d( ...@@ -931,10 +931,10 @@ static void apply_lut_1d(
else else
regamma_y = &tf_pts->blue[i]; regamma_y = &tf_pts->blue[i];
norm_y = dal_fixed31_32_mul(max_lut_index_f, norm_y = dc_fixpt_mul(max_lut_index_f,
*regamma_y); *regamma_y);
index = dal_fixed31_32_floor(norm_y); index = dc_fixpt_floor(norm_y);
index_f = dal_fixed31_32_from_int_nonconst(index); index_f = dc_fixpt_from_int_nonconst(index);
if (index < 0 || index > max_lut_index) if (index < 0 || index > max_lut_index)
continue; continue;
...@@ -953,11 +953,11 @@ static void apply_lut_1d( ...@@ -953,11 +953,11 @@ static void apply_lut_1d(
} }
// we have everything now, so interpolate // we have everything now, so interpolate
delta_lut = dal_fixed31_32_sub(lut2, lut1); delta_lut = dc_fixpt_sub(lut2, lut1);
delta_index = dal_fixed31_32_sub(norm_y, index_f); delta_index = dc_fixpt_sub(norm_y, index_f);
*regamma_y = dal_fixed31_32_add(lut1, *regamma_y = dc_fixpt_add(lut1,
dal_fixed31_32_mul(delta_index, delta_lut)); dc_fixpt_mul(delta_index, delta_lut));
} }
} }
} }
...@@ -973,7 +973,7 @@ static void build_evenly_distributed_points( ...@@ -973,7 +973,7 @@ static void build_evenly_distributed_points(
uint32_t i = 0; uint32_t i = 0;
do { do {
struct fixed31_32 value = dal_fixed31_32_from_fraction(i, struct fixed31_32 value = dc_fixpt_from_fraction(i,
numberof_points - 1); numberof_points - 1);
p->r = value; p->r = value;
...@@ -984,21 +984,21 @@ static void build_evenly_distributed_points( ...@@ -984,21 +984,21 @@ static void build_evenly_distributed_points(
++i; ++i;
} while (i != numberof_points); } while (i != numberof_points);
p->r = dal_fixed31_32_div(p_last->r, dividers.divider1); p->r = dc_fixpt_div(p_last->r, dividers.divider1);
p->g = dal_fixed31_32_div(p_last->g, dividers.divider1); p->g = dc_fixpt_div(p_last->g, dividers.divider1);
p->b = dal_fixed31_32_div(p_last->b, dividers.divider1); p->b = dc_fixpt_div(p_last->b, dividers.divider1);
++p; ++p;
p->r = dal_fixed31_32_div(p_last->r, dividers.divider2); p->r = dc_fixpt_div(p_last->r, dividers.divider2);
p->g = dal_fixed31_32_div(p_last->g, dividers.divider2); p->g = dc_fixpt_div(p_last->g, dividers.divider2);
p->b = dal_fixed31_32_div(p_last->b, dividers.divider2); p->b = dc_fixpt_div(p_last->b, dividers.divider2);
++p; ++p;
p->r = dal_fixed31_32_div(p_last->r, dividers.divider3); p->r = dc_fixpt_div(p_last->r, dividers.divider3);
p->g = dal_fixed31_32_div(p_last->g, dividers.divider3); p->g = dc_fixpt_div(p_last->g, dividers.divider3);
p->b = dal_fixed31_32_div(p_last->b, dividers.divider3); p->b = dc_fixpt_div(p_last->b, dividers.divider3);
} }
static inline void copy_rgb_regamma_to_coordinates_x( static inline void copy_rgb_regamma_to_coordinates_x(
...@@ -1094,7 +1094,7 @@ static void interpolate_user_regamma(uint32_t hw_points_num, ...@@ -1094,7 +1094,7 @@ static void interpolate_user_regamma(uint32_t hw_points_num,
struct fixed31_32 *tf_point; struct fixed31_32 *tf_point;
struct fixed31_32 hw_x; struct fixed31_32 hw_x;
struct fixed31_32 norm_factor = struct fixed31_32 norm_factor =
dal_fixed31_32_from_int_nonconst(255); dc_fixpt_from_int_nonconst(255);
struct fixed31_32 norm_x; struct fixed31_32 norm_x;
struct fixed31_32 index_f; struct fixed31_32 index_f;
struct fixed31_32 lut1; struct fixed31_32 lut1;
...@@ -1105,9 +1105,9 @@ static void interpolate_user_regamma(uint32_t hw_points_num, ...@@ -1105,9 +1105,9 @@ static void interpolate_user_regamma(uint32_t hw_points_num,
i = 0; i = 0;
/* fixed_pt library has problems handling too small values */ /* fixed_pt library has problems handling too small values */
while (i != 32) { while (i != 32) {
tf_pts->red[i] = dal_fixed31_32_zero; tf_pts->red[i] = dc_fixpt_zero;
tf_pts->green[i] = dal_fixed31_32_zero; tf_pts->green[i] = dc_fixpt_zero;
tf_pts->blue[i] = dal_fixed31_32_zero; tf_pts->blue[i] = dc_fixpt_zero;
++i; ++i;
} }
while (i <= hw_points_num + 1) { while (i <= hw_points_num + 1) {
...@@ -1129,12 +1129,12 @@ static void interpolate_user_regamma(uint32_t hw_points_num, ...@@ -1129,12 +1129,12 @@ static void interpolate_user_regamma(uint32_t hw_points_num,
} else } else
hw_x = coordinates_x[i].x; hw_x = coordinates_x[i].x;
norm_x = dal_fixed31_32_mul(norm_factor, hw_x); norm_x = dc_fixpt_mul(norm_factor, hw_x);
index = dal_fixed31_32_floor(norm_x); index = dc_fixpt_floor(norm_x);
if (index < 0 || index > 255) if (index < 0 || index > 255)
continue; continue;
index_f = dal_fixed31_32_from_int_nonconst(index); index_f = dc_fixpt_from_int_nonconst(index);
index_next = (index == 255) ? index : index + 1; index_next = (index == 255) ? index : index + 1;
if (color == 0) { if (color == 0) {
...@@ -1149,11 +1149,11 @@ static void interpolate_user_regamma(uint32_t hw_points_num, ...@@ -1149,11 +1149,11 @@ static void interpolate_user_regamma(uint32_t hw_points_num,
} }
// we have everything now, so interpolate // we have everything now, so interpolate
delta_lut = dal_fixed31_32_sub(lut2, lut1); delta_lut = dc_fixpt_sub(lut2, lut1);
delta_index = dal_fixed31_32_sub(norm_x, index_f); delta_index = dc_fixpt_sub(norm_x, index_f);
*tf_point = dal_fixed31_32_add(lut1, *tf_point = dc_fixpt_add(lut1,
dal_fixed31_32_mul(delta_index, delta_lut)); dc_fixpt_mul(delta_index, delta_lut));
} }
++i; ++i;
} }
...@@ -1168,15 +1168,15 @@ static void build_new_custom_resulted_curve( ...@@ -1168,15 +1168,15 @@ static void build_new_custom_resulted_curve(
i = 0; i = 0;
while (i != hw_points_num + 1) { while (i != hw_points_num + 1) {
tf_pts->red[i] = dal_fixed31_32_clamp( tf_pts->red[i] = dc_fixpt_clamp(
tf_pts->red[i], dal_fixed31_32_zero, tf_pts->red[i], dc_fixpt_zero,
dal_fixed31_32_one); dc_fixpt_one);
tf_pts->green[i] = dal_fixed31_32_clamp( tf_pts->green[i] = dc_fixpt_clamp(
tf_pts->green[i], dal_fixed31_32_zero, tf_pts->green[i], dc_fixpt_zero,
dal_fixed31_32_one); dc_fixpt_one);
tf_pts->blue[i] = dal_fixed31_32_clamp( tf_pts->blue[i] = dc_fixpt_clamp(
tf_pts->blue[i], dal_fixed31_32_zero, tf_pts->blue[i], dc_fixpt_zero,
dal_fixed31_32_one); dc_fixpt_one);
++i; ++i;
} }
...@@ -1290,9 +1290,9 @@ bool mod_color_calculate_regamma_params(struct dc_transfer_func *output_tf, ...@@ -1290,9 +1290,9 @@ bool mod_color_calculate_regamma_params(struct dc_transfer_func *output_tf,
if (!coeff) if (!coeff)
goto coeff_alloc_fail; goto coeff_alloc_fail;
dividers.divider1 = dal_fixed31_32_from_fraction(3, 2); dividers.divider1 = dc_fixpt_from_fraction(3, 2);
dividers.divider2 = dal_fixed31_32_from_int(2); dividers.divider2 = dc_fixpt_from_int(2);
dividers.divider3 = dal_fixed31_32_from_fraction(5, 2); dividers.divider3 = dc_fixpt_from_fraction(5, 2);
tf = output_tf->tf; tf = output_tf->tf;
...@@ -1357,15 +1357,15 @@ bool calculate_user_regamma_coeff(struct dc_transfer_func *output_tf, ...@@ -1357,15 +1357,15 @@ bool calculate_user_regamma_coeff(struct dc_transfer_func *output_tf,
uint32_t i = 0; uint32_t i = 0;
do { do {
coeff.a0[i] = dal_fixed31_32_from_fraction( coeff.a0[i] = dc_fixpt_from_fraction(
regamma->coeff.A0[i], 10000000); regamma->coeff.A0[i], 10000000);
coeff.a1[i] = dal_fixed31_32_from_fraction( coeff.a1[i] = dc_fixpt_from_fraction(
regamma->coeff.A1[i], 1000); regamma->coeff.A1[i], 1000);
coeff.a2[i] = dal_fixed31_32_from_fraction( coeff.a2[i] = dc_fixpt_from_fraction(
regamma->coeff.A2[i], 1000); regamma->coeff.A2[i], 1000);
coeff.a3[i] = dal_fixed31_32_from_fraction( coeff.a3[i] = dc_fixpt_from_fraction(
regamma->coeff.A3[i], 1000); regamma->coeff.A3[i], 1000);
coeff.user_gamma[i] = dal_fixed31_32_from_fraction( coeff.user_gamma[i] = dc_fixpt_from_fraction(
regamma->coeff.gamma[i], 1000); regamma->coeff.gamma[i], 1000);
++i; ++i;
...@@ -1374,9 +1374,9 @@ bool calculate_user_regamma_coeff(struct dc_transfer_func *output_tf, ...@@ -1374,9 +1374,9 @@ bool calculate_user_regamma_coeff(struct dc_transfer_func *output_tf,
i = 0; i = 0;
/* fixed_pt library has problems handling too small values */ /* fixed_pt library has problems handling too small values */
while (i != 32) { while (i != 32) {
output_tf->tf_pts.red[i] = dal_fixed31_32_zero; output_tf->tf_pts.red[i] = dc_fixpt_zero;
output_tf->tf_pts.green[i] = dal_fixed31_32_zero; output_tf->tf_pts.green[i] = dc_fixpt_zero;
output_tf->tf_pts.blue[i] = dal_fixed31_32_zero; output_tf->tf_pts.blue[i] = dc_fixpt_zero;
++coord_x; ++coord_x;
++i; ++i;
} }
...@@ -1423,9 +1423,9 @@ bool calculate_user_regamma_ramp(struct dc_transfer_func *output_tf, ...@@ -1423,9 +1423,9 @@ bool calculate_user_regamma_ramp(struct dc_transfer_func *output_tf,
if (!rgb_regamma) if (!rgb_regamma)
goto rgb_regamma_alloc_fail; goto rgb_regamma_alloc_fail;
dividers.divider1 = dal_fixed31_32_from_fraction(3, 2); dividers.divider1 = dc_fixpt_from_fraction(3, 2);
dividers.divider2 = dal_fixed31_32_from_int(2); dividers.divider2 = dc_fixpt_from_int(2);
dividers.divider3 = dal_fixed31_32_from_fraction(5, 2); dividers.divider3 = dc_fixpt_from_fraction(5, 2);
scale_user_regamma_ramp(rgb_user, &regamma->ramp, dividers); scale_user_regamma_ramp(rgb_user, &regamma->ramp, dividers);
...@@ -1496,9 +1496,9 @@ bool mod_color_calculate_degamma_params(struct dc_transfer_func *input_tf, ...@@ -1496,9 +1496,9 @@ bool mod_color_calculate_degamma_params(struct dc_transfer_func *input_tf,
if (!coeff) if (!coeff)
goto coeff_alloc_fail; goto coeff_alloc_fail;
dividers.divider1 = dal_fixed31_32_from_fraction(3, 2); dividers.divider1 = dc_fixpt_from_fraction(3, 2);
dividers.divider2 = dal_fixed31_32_from_int(2); dividers.divider2 = dc_fixpt_from_int(2);
dividers.divider3 = dal_fixed31_32_from_fraction(5, 2); dividers.divider3 = dc_fixpt_from_fraction(5, 2);
tf = input_tf->tf; tf = input_tf->tf;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment