summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/display/dc/dml
diff options
context:
space:
mode:
authorDmytro Laktyushkin <Dmytro.Laktyushkin@amd.com>2020-05-11 10:33:58 -0400
committerAlex Deucher <alexander.deucher@amd.com>2020-05-28 14:00:50 -0400
commitb236e048ec633a35b2a83d663f74c22ef04b9bab (patch)
treee62c7f849343c5b57687a525b22e1fb6409574c3 /drivers/gpu/drm/amd/display/dc/dml
parent0023b7eec02c1ddd76c184cfa584dfdc37903c94 (diff)
drm/amd/display: simplify dml log2 function
Current implementation is slightly inaccurate and will often result in truncation/floor operation decrementing an exact integer output by 1. Only rounded down output is ever expected, just extract the fp exponent for this to increase performance and avoid any truncation issues. Signed-off-by: Dmytro Laktyushkin <Dmytro.Laktyushkin@amd.com> Reviewed-by: Eric Bernstein <Eric.Bernstein@amd.com> Acked-by: Qingqing Zhuo <qingqing.zhuo@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/display/dc/dml')
-rw-r--r--drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h20
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h b/drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h
index ab0870e2a103..479d7d83220c 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h
+++ b/drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h
@@ -86,9 +86,20 @@ static inline double dml_round(double a)
return floor;
}
-static inline double dml_log2(double x)
+/* float
+static inline int dml_log2(float x)
{
- return (double) dcn_bw_log(x, 2);
+ unsigned int ix = *((unsigned int *)&x);
+
+ return (int)((ix >> 23) & 0xff) - 127;
+}*/
+
+/* double */
+static inline int dml_log2(double x)
+{
+ unsigned long long ix = *((unsigned long long *)&x);
+
+ return (int)((ix >> 52) & 0x7ff) - 1023;
}
static inline double dml_pow(double a, int exp)
@@ -116,11 +127,6 @@ static inline double dml_floor_ex(double x, double granularity)
return (double) dcn_bw_floor2(x, granularity);
}
-static inline double dml_log(double x, double base)
-{
- return (double) dcn_bw_log(x, base);
-}
-
static inline unsigned int dml_round_to_multiple(unsigned int num,
unsigned int multiple,
unsigned char up)