.. | .. |
---|
26 | 26 | #ifndef __DML_INLINE_DEFS_H__ |
---|
27 | 27 | #define __DML_INLINE_DEFS_H__ |
---|
28 | 28 | |
---|
29 | | -#include "dml_common_defs.h" |
---|
30 | 29 | #include "dcn_calc_math.h" |
---|
31 | 30 | #include "dml_logger.h" |
---|
32 | 31 | |
---|
.. | .. |
---|
75 | 74 | return (double) dcn_bw_floor2(a, granularity); |
---|
76 | 75 | } |
---|
77 | 76 | |
---|
| 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 */ |
---|
78 | 98 | static inline int dml_log2(double x) |
---|
79 | 99 | { |
---|
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; |
---|
81 | 103 | } |
---|
82 | 104 | |
---|
83 | 105 | static inline double dml_pow(double a, int exp) |
---|
.. | .. |
---|
105 | 127 | return (double) dcn_bw_floor2(x, granularity); |
---|
106 | 128 | } |
---|
107 | 129 | |
---|
108 | | -static inline double dml_log(double x, double base) |
---|
109 | | -{ |
---|
110 | | - return (double) dcn_bw_log(x, base); |
---|
111 | | -} |
---|
112 | | - |
---|
113 | 130 | static inline unsigned int dml_round_to_multiple(unsigned int num, |
---|
114 | 131 | unsigned int multiple, |
---|
115 | | - bool up) |
---|
| 132 | + unsigned char up) |
---|
116 | 133 | { |
---|
117 | 134 | unsigned int remainder; |
---|
118 | 135 | |
---|
.. | .. |
---|
129 | 146 | else |
---|
130 | 147 | return (num - remainder); |
---|
131 | 148 | } |
---|
| 149 | +static inline double dml_abs(double a) |
---|
| 150 | +{ |
---|
| 151 | + if (a > 0) |
---|
| 152 | + return a; |
---|
| 153 | + else |
---|
| 154 | + return (a*(-1)); |
---|
| 155 | +} |
---|
| 156 | + |
---|
132 | 157 | #endif |
---|