[PATCH v3 02/16] drm/amd/display: Move custom_float outside DML

Rodrigo Siqueira Rodrigo.Siqueira at amd.com
Wed Oct 4 21:20:56 UTC 2023


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.

Signed-off-by: Rodrigo Siqueira <Rodrigo.Siqueira at amd.com>
---
 .../gpu/drm/amd/display/dc/basics/Makefile    |  3 +-
 .../dc/{dml/calcs => basics}/custom_float.c   | 90 +++++++------------
 drivers/gpu/drm/amd/display/dc/dml/Makefile   |  2 +-
 3 files changed, 36 insertions(+), 59 deletions(-)
 rename drivers/gpu/drm/amd/display/dc/{dml/calcs => basics}/custom_float.c (66%)

diff --git a/drivers/gpu/drm/amd/display/dc/basics/Makefile b/drivers/gpu/drm/amd/display/dc/basics/Makefile
index ee611b03dc48..65d713aff407 100644
--- a/drivers/gpu/drm/amd/display/dc/basics/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/basics/Makefile
@@ -29,7 +29,8 @@ BASICS := \
 	fixpt31_32.o \
 	vector.o \
 	dc_common.o \
-	dce_calcs.o
+	dce_calcs.o \
+	custom_float.o
 
 AMD_DAL_BASICS = $(addprefix $(AMDDALPATH)/dc/basics/,$(BASICS))
 
diff --git a/drivers/gpu/drm/amd/display/dc/dml/calcs/custom_float.c b/drivers/gpu/drm/amd/display/dc/basics/custom_float.c
similarity index 66%
rename from drivers/gpu/drm/amd/display/dc/dml/calcs/custom_float.c
rename to drivers/gpu/drm/amd/display/dc/basics/custom_float.c
index 31d167bc548f..ae05ded9a7f3 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/calcs/custom_float.c
+++ b/drivers/gpu/drm/amd/display/dc/basics/custom_float.c
@@ -1,5 +1,6 @@
+// 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
  * copy of this software and associated documentation files (the "Software"),
@@ -25,52 +26,41 @@
 #include "dm_services.h"
 #include "custom_float.h"
 
-
-static bool build_custom_float(
-	struct fixed31_32 value,
-	const struct custom_float_format *format,
-	bool *negative,
-	uint32_t *mantissa,
-	uint32_t *exponenta)
+static bool build_custom_float(struct fixed31_32 value,
+			       const struct custom_float_format *format,
+			       bool *negative,
+			       uint32_t *mantissa,
+			       uint32_t *exponenta)
 {
 	uint32_t exp_offset = (1 << (format->exponenta_bits - 1)) - 1;
 
 	const struct fixed31_32 mantissa_constant_plus_max_fraction =
-		dc_fixpt_from_fraction(
-			(1LL << (format->mantissa_bits + 1)) - 1,
-			1LL << format->mantissa_bits);
+		dc_fixpt_from_fraction((1LL << (format->mantissa_bits + 1)) - 1,
+				       1LL << format->mantissa_bits);
 
 	struct fixed31_32 mantiss;
 
-	if (dc_fixpt_eq(
-		value,
-		dc_fixpt_zero)) {
+	if (dc_fixpt_eq(value, dc_fixpt_zero)) {
 		*negative = false;
 		*mantissa = 0;
 		*exponenta = 0;
 		return true;
 	}
 
-	if (dc_fixpt_lt(
-		value,
-		dc_fixpt_zero)) {
+	if (dc_fixpt_lt(value, dc_fixpt_zero)) {
 		*negative = format->sign;
 		value = dc_fixpt_neg(value);
 	} else {
 		*negative = false;
 	}
 
-	if (dc_fixpt_lt(
-		value,
-		dc_fixpt_one)) {
+	if (dc_fixpt_lt(value, dc_fixpt_one)) {
 		uint32_t i = 1;
 
 		do {
 			value = dc_fixpt_shl(value, 1);
 			++i;
-		} while (dc_fixpt_lt(
-			value,
-			dc_fixpt_one));
+		} while (dc_fixpt_lt(value, dc_fixpt_one));
 
 		--i;
 
@@ -81,54 +71,40 @@ static bool build_custom_float(
 		}
 
 		*exponenta = exp_offset - i;
-	} else if (dc_fixpt_le(
-		mantissa_constant_plus_max_fraction,
-		value)) {
+	} else if (dc_fixpt_le(mantissa_constant_plus_max_fraction, value)) {
 		uint32_t i = 1;
 
 		do {
 			value = dc_fixpt_shr(value, 1);
 			++i;
-		} while (dc_fixpt_lt(
-			mantissa_constant_plus_max_fraction,
-			value));
+		} while (dc_fixpt_lt(mantissa_constant_plus_max_fraction, value));
 
 		*exponenta = exp_offset + i - 1;
 	} else {
 		*exponenta = exp_offset;
 	}
 
-	mantiss = dc_fixpt_sub(
-		value,
-		dc_fixpt_one);
+	mantiss = dc_fixpt_sub(value, dc_fixpt_one);
 
-	if (dc_fixpt_lt(
-			mantiss,
-			dc_fixpt_zero) ||
-		dc_fixpt_lt(
-			dc_fixpt_one,
-			mantiss))
+	if (dc_fixpt_lt(mantiss, dc_fixpt_zero) ||
+	    dc_fixpt_lt(dc_fixpt_one, mantiss))
 		mantiss = dc_fixpt_zero;
 	else
-		mantiss = dc_fixpt_shl(
-			mantiss,
-			format->mantissa_bits);
+		mantiss = dc_fixpt_shl(mantiss, format->mantissa_bits);
 
 	*mantissa = dc_fixpt_floor(mantiss);
 
 	return true;
 }
 
-static bool setup_custom_float(
-	const struct custom_float_format *format,
-	bool negative,
-	uint32_t mantissa,
-	uint32_t exponenta,
-	uint32_t *result)
+static bool setup_custom_float(const struct custom_float_format *format,
+			       bool negative,
+			       uint32_t mantissa,
+			       uint32_t exponenta,
+			       uint32_t *result)
 {
 	uint32_t i = 0;
 	uint32_t j = 0;
-
 	uint32_t value = 0;
 
 	/* verification code:
@@ -179,19 +155,19 @@ static bool setup_custom_float(
 	return true;
 }
 
-bool convert_to_custom_float_format(
-	struct fixed31_32 value,
-	const struct custom_float_format *format,
-	uint32_t *result)
+bool convert_to_custom_float_format(struct fixed31_32 value,
+				    const struct custom_float_format *format,
+				    uint32_t *result)
 {
 	uint32_t mantissa;
 	uint32_t exponenta;
 	bool negative;
 
-	return build_custom_float(
-		value, format, &negative, &mantissa, &exponenta) &&
-	setup_custom_float(
-		format, negative, mantissa, exponenta, result);
+	return build_custom_float(value, format, &negative, &mantissa, &exponenta) &&
+				  setup_custom_float(format,
+						     negative,
+						     mantissa,
+						     exponenta,
+						     result);
 }
 
-
diff --git a/drivers/gpu/drm/amd/display/dc/dml/Makefile b/drivers/gpu/drm/amd/display/dc/dml/Makefile
index 8621dfe9a68c..2fe8588a070a 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/dml/Makefile
@@ -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_math.o := $(dml_rcflags)
 
-DML = calcs/custom_float.o calcs/bw_fixed.o
+DML = calcs/bw_fixed.o
 
 ifdef CONFIG_DRM_AMD_DC_FP
 DML += display_mode_lib.o display_rq_dlg_helpers.o dml1_display_rq_dlg_calc.o
-- 
2.40.1



More information about the amd-gfx mailing list