hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h
....@@ -26,7 +26,6 @@
2626 #ifndef __DML_INLINE_DEFS_H__
2727 #define __DML_INLINE_DEFS_H__
2828
29
-#include "dml_common_defs.h"
3029 #include "dcn_calc_math.h"
3130 #include "dml_logger.h"
3231
....@@ -75,9 +74,32 @@
7574 return (double) dcn_bw_floor2(a, granularity);
7675 }
7776
77
+static inline double dml_round(double a)
78
+{
79
+ double round_pt = 0.5;
80
+ double ceil = dml_ceil(a, 1);
81
+ double floor = dml_floor(a, 1);
82
+
83
+ if (a - floor >= round_pt)
84
+ return ceil;
85
+ else
86
+ return floor;
87
+}
88
+
89
+/* float
90
+static inline int dml_log2(float x)
91
+{
92
+ unsigned int ix = *((unsigned int *)&x);
93
+
94
+ return (int)((ix >> 23) & 0xff) - 127;
95
+}*/
96
+
97
+/* double */
7898 static inline int dml_log2(double x)
7999 {
80
- return dml_round((double)dcn_bw_log(x, 2));
100
+ unsigned long long ix = *((unsigned long long *)&x);
101
+
102
+ return (int)((ix >> 52) & 0x7ff) - 1023;
81103 }
82104
83105 static inline double dml_pow(double a, int exp)
....@@ -105,14 +127,9 @@
105127 return (double) dcn_bw_floor2(x, granularity);
106128 }
107129
108
-static inline double dml_log(double x, double base)
109
-{
110
- return (double) dcn_bw_log(x, base);
111
-}
112
-
113130 static inline unsigned int dml_round_to_multiple(unsigned int num,
114131 unsigned int multiple,
115
- bool up)
132
+ unsigned char up)
116133 {
117134 unsigned int remainder;
118135
....@@ -129,4 +146,12 @@
129146 else
130147 return (num - remainder);
131148 }
149
+static inline double dml_abs(double a)
150
+{
151
+ if (a > 0)
152
+ return a;
153
+ else
154
+ return (a*(-1));
155
+}
156
+
132157 #endif