···11+/*22+ * Copyright 2017 Advanced Micro Devices, Inc.33+ *44+ * Permission is hereby granted, free of charge, to any person obtaining a55+ * copy of this software and associated documentation files (the "Software"),66+ * to deal in the Software without restriction, including without limitation77+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,88+ * and/or sell copies of the Software, and to permit persons to whom the99+ * Software is furnished to do so, subject to the following conditions:1010+ *1111+ * The above copyright notice and this permission notice shall be included in1212+ * all copies or substantial portions of the Software.1313+ *1414+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR1515+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,1616+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL1717+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR1818+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,1919+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR2020+ * OTHER DEALINGS IN THE SOFTWARE.2121+ *2222+ * Authors: AMD2323+ *2424+ */2525+2626+#ifndef _DCN_CALC_AUTO_H_2727+#define _DCN_CALC_AUTO_H_2828+2929+#include "dcn_calcs.h"3030+3131+void scaler_settings_calculation(struct dcn_bw_internal_vars *v);3232+void mode_support_and_system_configuration(struct dcn_bw_internal_vars *v);3333+void display_pipe_configuration(struct dcn_bw_internal_vars *v);3434+void dispclkdppclkdcfclk_deep_sleep_prefetch_parameters_watermarks_and_performance_calculation(3535+ struct dcn_bw_internal_vars *v);3636+3737+#endif /* _DCN_CALC_AUTO_H_ */
···11+/*22+ * Copyright 2017 Advanced Micro Devices, Inc.33+ *44+ * Permission is hereby granted, free of charge, to any person obtaining a55+ * copy of this software and associated documentation files (the "Software"),66+ * to deal in the Software without restriction, including without limitation77+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,88+ * and/or sell copies of the Software, and to permit persons to whom the99+ * Software is furnished to do so, subject to the following conditions:1010+ *1111+ * The above copyright notice and this permission notice shall be included in1212+ * all copies or substantial portions of the Software.1313+ *1414+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR1515+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,1616+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL1717+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR1818+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,1919+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR2020+ * OTHER DEALINGS IN THE SOFTWARE.2121+ *2222+ * Authors: AMD2323+ *2424+ */2525+2626+#include "dcn_calc_math.h"2727+2828+float dcn_bw_mod(const float arg1, const float arg2)2929+{3030+ return arg1 - arg1 * ((int) (arg1 / arg2));3131+}3232+3333+float dcn_bw_min2(const float arg1, const float arg2)3434+{3535+ return arg1 < arg2 ? arg1 : arg2;3636+}3737+3838+unsigned int dcn_bw_max(const unsigned int arg1, const unsigned int arg2)3939+{4040+ return arg1 > arg2 ? arg1 : arg2;4141+}4242+float dcn_bw_max2(const float arg1, const float arg2)4343+{4444+ return arg1 > arg2 ? arg1 : arg2;4545+}4646+4747+float dcn_bw_floor2(const float arg, const float significance)4848+{4949+ if (significance == 0)5050+ return 0;5151+ return ((int) (arg / significance)) * significance;5252+}5353+5454+float dcn_bw_ceil2(const float arg, const float significance)5555+{5656+ float flr = dcn_bw_floor2(arg, significance);5757+ if (significance == 0)5858+ return 0;5959+ return flr + 0.00001 >= arg ? arg : flr + significance;6060+}6161+6262+float dcn_bw_max3(float v1, float v2, float v3)6363+{6464+ return v3 > dcn_bw_max2(v1, v2) ? v3 : dcn_bw_max2(v1, v2);6565+}6666+6767+float dcn_bw_max5(float v1, float v2, float v3, float v4, float v5)6868+{6969+ return dcn_bw_max3(v1, v2, v3) > dcn_bw_max2(v4, v5) ? dcn_bw_max3(v1, v2, v3) : dcn_bw_max2(v4, v5);7070+}7171+7272+float dcn_bw_pow(float a, float exp)7373+{7474+ float temp;7575+ /*ASSERT(exp == (int)exp);*/7676+ if ((int)exp == 0)7777+ return 1;7878+ temp = dcn_bw_pow(a, (int)(exp / 2));7979+ if (((int)exp % 2) == 0) {8080+ return temp * temp;8181+ } else {8282+ if ((int)exp > 0)8383+ return a * temp * temp;8484+ else8585+ return (temp * temp) / a;8686+ }8787+}8888+8989+float dcn_bw_log(float a, float b)9090+{9191+ int * const exp_ptr = (int *)(&a);9292+ int x = *exp_ptr;9393+ const int log_2 = ((x >> 23) & 255) - 128;9494+ x &= ~(255 << 23);9595+ x += 127 << 23;9696+ *exp_ptr = x;9797+9898+ a = ((-1.0f / 3) * a + 2) * a - 2.0f / 3;9999+100100+ if (b > 2.00001 || b < 1.99999)101101+ return (a + log_2) / dcn_bw_log(b, 2);102102+ else103103+ return (a + log_2);104104+}
···11+/*22+ * Copyright 2017 Advanced Micro Devices, Inc.33+ *44+ * Permission is hereby granted, free of charge, to any person obtaining a55+ * copy of this software and associated documentation files (the "Software"),66+ * to deal in the Software without restriction, including without limitation77+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,88+ * and/or sell copies of the Software, and to permit persons to whom the99+ * Software is furnished to do so, subject to the following conditions:1010+ *1111+ * The above copyright notice and this permission notice shall be included in1212+ * all copies or substantial portions of the Software.1313+ *1414+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR1515+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,1616+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL1717+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR1818+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,1919+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR2020+ * OTHER DEALINGS IN THE SOFTWARE.2121+ *2222+ * Authors: AMD2323+ *2424+ */2525+2626+#ifndef _DCN_CALC_MATH_H_2727+#define _DCN_CALC_MATH_H_2828+2929+float dcn_bw_mod(const float arg1, const float arg2);3030+float dcn_bw_min2(const float arg1, const float arg2);3131+unsigned int dcn_bw_max(const unsigned int arg1, const unsigned int arg2);3232+float dcn_bw_max2(const float arg1, const float arg2);3333+float dcn_bw_floor2(const float arg, const float significance);3434+float dcn_bw_ceil2(const float arg, const float significance);3535+float dcn_bw_max3(float v1, float v2, float v3);3636+float dcn_bw_max5(float v1, float v2, float v3, float v4, float v5);3737+float dcn_bw_pow(float a, float exp);3838+float dcn_bw_log(float a, float b);3939+4040+#endif /* _DCN_CALC_MATH_H_ */