Commit 13f9173a authored by Rodrigo Siqueira's avatar Rodrigo Siqueira Committed by Alex Deucher

drm/amd/display: Move custom_float from DML folder

The custom_float file does not have any FPU operation, so it should be
inside DML. This commit moves the file to the basic folder.
Reviewed-by: default avatarQingqing Zhuo <Qingqing.Zhuo@amd.com>
Signed-off-by: default avatarRodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent d310d18b
...@@ -29,7 +29,8 @@ BASICS := \ ...@@ -29,7 +29,8 @@ BASICS := \
fixpt31_32.o \ fixpt31_32.o \
vector.o \ vector.o \
dc_common.o \ dc_common.o \
dce_calcs.o dce_calcs.o \
custom_float.o
AMD_DAL_BASICS = $(addprefix $(AMDDALPATH)/dc/basics/,$(BASICS)) AMD_DAL_BASICS = $(addprefix $(AMDDALPATH)/dc/basics/,$(BASICS))
......
// SPDX-License-Identifier: MIT
/* /*
* Copyright 2017 Advanced Micro Devices, Inc. * Copyright 2023 Advanced Micro Devices, Inc.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
...@@ -25,52 +26,41 @@ ...@@ -25,52 +26,41 @@
#include "dm_services.h" #include "dm_services.h"
#include "custom_float.h" #include "custom_float.h"
static bool build_custom_float(struct fixed31_32 value,
static bool build_custom_float( const struct custom_float_format *format,
struct fixed31_32 value, bool *negative,
const struct custom_float_format *format, uint32_t *mantissa,
bool *negative, uint32_t *exponenta)
uint32_t *mantissa,
uint32_t *exponenta)
{ {
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 =
dc_fixpt_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 (dc_fixpt_eq( if (dc_fixpt_eq(value, dc_fixpt_zero)) {
value,
dc_fixpt_zero)) {
*negative = false; *negative = false;
*mantissa = 0; *mantissa = 0;
*exponenta = 0; *exponenta = 0;
return true; return true;
} }
if (dc_fixpt_lt( if (dc_fixpt_lt(value, dc_fixpt_zero)) {
value,
dc_fixpt_zero)) {
*negative = format->sign; *negative = format->sign;
value = dc_fixpt_neg(value); value = dc_fixpt_neg(value);
} else { } else {
*negative = false; *negative = false;
} }
if (dc_fixpt_lt( if (dc_fixpt_lt(value, dc_fixpt_one)) {
value,
dc_fixpt_one)) {
uint32_t i = 1; uint32_t i = 1;
do { do {
value = dc_fixpt_shl(value, 1); value = dc_fixpt_shl(value, 1);
++i; ++i;
} while (dc_fixpt_lt( } while (dc_fixpt_lt(value, dc_fixpt_one));
value,
dc_fixpt_one));
--i; --i;
...@@ -81,54 +71,40 @@ static bool build_custom_float( ...@@ -81,54 +71,40 @@ static bool build_custom_float(
} }
*exponenta = exp_offset - i; *exponenta = exp_offset - i;
} else if (dc_fixpt_le( } else if (dc_fixpt_le(mantissa_constant_plus_max_fraction, value)) {
mantissa_constant_plus_max_fraction,
value)) {
uint32_t i = 1; uint32_t i = 1;
do { do {
value = dc_fixpt_shr(value, 1); value = dc_fixpt_shr(value, 1);
++i; ++i;
} while (dc_fixpt_lt( } while (dc_fixpt_lt(mantissa_constant_plus_max_fraction, value));
mantissa_constant_plus_max_fraction,
value));
*exponenta = exp_offset + i - 1; *exponenta = exp_offset + i - 1;
} else { } else {
*exponenta = exp_offset; *exponenta = exp_offset;
} }
mantiss = dc_fixpt_sub( mantiss = dc_fixpt_sub(value, dc_fixpt_one);
value,
dc_fixpt_one);
if (dc_fixpt_lt( if (dc_fixpt_lt(mantiss, dc_fixpt_zero) ||
mantiss, dc_fixpt_lt(dc_fixpt_one, mantiss))
dc_fixpt_zero) ||
dc_fixpt_lt(
dc_fixpt_one,
mantiss))
mantiss = dc_fixpt_zero; mantiss = dc_fixpt_zero;
else else
mantiss = dc_fixpt_shl( mantiss = dc_fixpt_shl(mantiss, format->mantissa_bits);
mantiss,
format->mantissa_bits);
*mantissa = dc_fixpt_floor(mantiss); *mantissa = dc_fixpt_floor(mantiss);
return true; return true;
} }
static bool setup_custom_float( static bool setup_custom_float(const struct custom_float_format *format,
const struct custom_float_format *format, bool negative,
bool negative, uint32_t mantissa,
uint32_t mantissa, uint32_t exponenta,
uint32_t exponenta, uint32_t *result)
uint32_t *result)
{ {
uint32_t i = 0; uint32_t i = 0;
uint32_t j = 0; uint32_t j = 0;
uint32_t value = 0; uint32_t value = 0;
/* verification code: /* verification code:
...@@ -179,19 +155,19 @@ static bool setup_custom_float( ...@@ -179,19 +155,19 @@ static bool setup_custom_float(
return true; return true;
} }
bool convert_to_custom_float_format( bool convert_to_custom_float_format(struct fixed31_32 value,
struct fixed31_32 value, const struct custom_float_format *format,
const struct custom_float_format *format, uint32_t *result)
uint32_t *result)
{ {
uint32_t mantissa; uint32_t mantissa;
uint32_t exponenta; uint32_t exponenta;
bool negative; bool negative;
return build_custom_float( return build_custom_float(value, format, &negative, &mantissa, &exponenta) &&
value, format, &negative, &mantissa, &exponenta) && setup_custom_float(format,
setup_custom_float( negative,
format, negative, mantissa, exponenta, result); mantissa,
exponenta,
result);
} }
...@@ -134,7 +134,7 @@ CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/calcs/dcn_calcs.o := $(dml_rcflags) ...@@ -134,7 +134,7 @@ CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/calcs/dcn_calcs.o := $(dml_rcflags)
CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/calcs/dcn_calc_auto.o := $(dml_rcflags) CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/calcs/dcn_calc_auto.o := $(dml_rcflags)
CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/calcs/dcn_calc_math.o := $(dml_rcflags) CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/calcs/dcn_calc_math.o := $(dml_rcflags)
DML = calcs/custom_float.o calcs/bw_fixed.o DML = calcs/bw_fixed.o
ifdef CONFIG_DRM_AMD_DC_FP ifdef CONFIG_DRM_AMD_DC_FP
DML += display_mode_lib.o display_rq_dlg_helpers.o dml1_display_rq_dlg_calc.o DML += display_mode_lib.o display_rq_dlg_helpers.o dml1_display_rq_dlg_calc.o
......
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