treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / gpu / drm / amd / display / dc / dml / dml_inline_defs.h
blobded71ea82413df3ef8b537099eb0860e270a8485
1 /*
2 * Copyright 2017 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
22 * Authors: AMD
26 #ifndef __DML_INLINE_DEFS_H__
27 #define __DML_INLINE_DEFS_H__
29 #include "dml_common_defs.h"
30 #include "dcn_calc_math.h"
31 #include "dml_logger.h"
33 static inline double dml_min(double a, double b)
35 return (double) dcn_bw_min2(a, b);
38 static inline double dml_min3(double a, double b, double c)
40 return dml_min(dml_min(a, b), c);
43 static inline double dml_min4(double a, double b, double c, double d)
45 return dml_min(dml_min(a, b), dml_min(c, d));
48 static inline double dml_max(double a, double b)
50 return (double) dcn_bw_max2(a, b);
53 static inline double dml_max3(double a, double b, double c)
55 return dml_max(dml_max(a, b), c);
58 static inline double dml_max4(double a, double b, double c, double d)
60 return dml_max(dml_max(a, b), dml_max(c, d));
63 static inline double dml_max5(double a, double b, double c, double d, double e)
65 return dml_max(dml_max4(a, b, c, d), e);
68 static inline double dml_ceil(double a, double granularity)
70 return (double) dcn_bw_ceil2(a, granularity);
73 static inline double dml_floor(double a, double granularity)
75 return (double) dcn_bw_floor2(a, granularity);
78 static inline int dml_log2(double x)
80 return dml_round((double)dcn_bw_log(x, 2));
83 static inline double dml_pow(double a, int exp)
85 return (double) dcn_bw_pow(a, exp);
88 static inline double dml_fmod(double f, int val)
90 return (double) dcn_bw_mod(f, val);
93 static inline double dml_ceil_2(double f)
95 return (double) dcn_bw_ceil2(f, 2);
98 static inline double dml_ceil_ex(double x, double granularity)
100 return (double) dcn_bw_ceil2(x, granularity);
103 static inline double dml_floor_ex(double x, double granularity)
105 return (double) dcn_bw_floor2(x, granularity);
108 static inline double dml_log(double x, double base)
110 return (double) dcn_bw_log(x, base);
113 static inline unsigned int dml_round_to_multiple(unsigned int num,
114 unsigned int multiple,
115 bool up)
117 unsigned int remainder;
119 if (multiple == 0)
120 return num;
122 remainder = num % multiple;
124 if (remainder == 0)
125 return num;
127 if (up)
128 return (num + multiple - remainder);
129 else
130 return (num - remainder);
132 static inline double dml_abs(double a)
134 if (a > 0)
135 return a;
136 else
137 return (a*(-1));
140 #endif