1*b843c749SSergey Zigachev /* 2*b843c749SSergey Zigachev * Copyright 2016 Advanced Micro Devices, Inc. 3*b843c749SSergey Zigachev * 4*b843c749SSergey Zigachev * Permission is hereby granted, free of charge, to any person obtaining a 5*b843c749SSergey Zigachev * copy of this software and associated documentation files (the "Software"), 6*b843c749SSergey Zigachev * to deal in the Software without restriction, including without limitation 7*b843c749SSergey Zigachev * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8*b843c749SSergey Zigachev * and/or sell copies of the Software, and to permit persons to whom the 9*b843c749SSergey Zigachev * Software is furnished to do so, subject to the following conditions: 10*b843c749SSergey Zigachev * 11*b843c749SSergey Zigachev * The above copyright notice and this permission notice shall be included in 12*b843c749SSergey Zigachev * all copies or substantial portions of the Software. 13*b843c749SSergey Zigachev * 14*b843c749SSergey Zigachev * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15*b843c749SSergey Zigachev * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16*b843c749SSergey Zigachev * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17*b843c749SSergey Zigachev * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18*b843c749SSergey Zigachev * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19*b843c749SSergey Zigachev * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20*b843c749SSergey Zigachev * OTHER DEALINGS IN THE SOFTWARE. 21*b843c749SSergey Zigachev * 22*b843c749SSergey Zigachev * Authors: AMD 23*b843c749SSergey Zigachev * 24*b843c749SSergey Zigachev */ 25*b843c749SSergey Zigachev 26*b843c749SSergey Zigachev #ifndef __DAL_DCN10_CM_COMMON_H__ 27*b843c749SSergey Zigachev #define __DAL_DCN10_CM_COMMON_H__ 28*b843c749SSergey Zigachev 29*b843c749SSergey Zigachev #define TF_HELPER_REG_FIELD_LIST(type) \ 30*b843c749SSergey Zigachev type exp_region0_lut_offset; \ 31*b843c749SSergey Zigachev type exp_region0_num_segments; \ 32*b843c749SSergey Zigachev type exp_region1_lut_offset; \ 33*b843c749SSergey Zigachev type exp_region1_num_segments;\ 34*b843c749SSergey Zigachev type field_region_end;\ 35*b843c749SSergey Zigachev type field_region_end_slope;\ 36*b843c749SSergey Zigachev type field_region_end_base;\ 37*b843c749SSergey Zigachev type exp_region_start;\ 38*b843c749SSergey Zigachev type exp_resion_start_segment;\ 39*b843c749SSergey Zigachev type field_region_linear_slope 40*b843c749SSergey Zigachev 41*b843c749SSergey Zigachev #define TF_CM_REG_FIELD_LIST(type) \ 42*b843c749SSergey Zigachev type csc_c11; \ 43*b843c749SSergey Zigachev type csc_c12 44*b843c749SSergey Zigachev 45*b843c749SSergey Zigachev struct xfer_func_shift { 46*b843c749SSergey Zigachev TF_HELPER_REG_FIELD_LIST(uint8_t); 47*b843c749SSergey Zigachev }; 48*b843c749SSergey Zigachev 49*b843c749SSergey Zigachev struct xfer_func_mask { 50*b843c749SSergey Zigachev TF_HELPER_REG_FIELD_LIST(uint32_t); 51*b843c749SSergey Zigachev }; 52*b843c749SSergey Zigachev 53*b843c749SSergey Zigachev struct xfer_func_reg { 54*b843c749SSergey Zigachev struct xfer_func_shift shifts; 55*b843c749SSergey Zigachev struct xfer_func_mask masks; 56*b843c749SSergey Zigachev 57*b843c749SSergey Zigachev uint32_t start_cntl_b; 58*b843c749SSergey Zigachev uint32_t start_cntl_g; 59*b843c749SSergey Zigachev uint32_t start_cntl_r; 60*b843c749SSergey Zigachev uint32_t start_slope_cntl_b; 61*b843c749SSergey Zigachev uint32_t start_slope_cntl_g; 62*b843c749SSergey Zigachev uint32_t start_slope_cntl_r; 63*b843c749SSergey Zigachev uint32_t start_end_cntl1_b; 64*b843c749SSergey Zigachev uint32_t start_end_cntl2_b; 65*b843c749SSergey Zigachev uint32_t start_end_cntl1_g; 66*b843c749SSergey Zigachev uint32_t start_end_cntl2_g; 67*b843c749SSergey Zigachev uint32_t start_end_cntl1_r; 68*b843c749SSergey Zigachev uint32_t start_end_cntl2_r; 69*b843c749SSergey Zigachev uint32_t region_start; 70*b843c749SSergey Zigachev uint32_t region_end; 71*b843c749SSergey Zigachev }; 72*b843c749SSergey Zigachev 73*b843c749SSergey Zigachev struct cm_color_matrix_shift { 74*b843c749SSergey Zigachev TF_CM_REG_FIELD_LIST(uint8_t); 75*b843c749SSergey Zigachev }; 76*b843c749SSergey Zigachev 77*b843c749SSergey Zigachev struct cm_color_matrix_mask { 78*b843c749SSergey Zigachev TF_CM_REG_FIELD_LIST(uint32_t); 79*b843c749SSergey Zigachev }; 80*b843c749SSergey Zigachev 81*b843c749SSergey Zigachev struct color_matrices_reg{ 82*b843c749SSergey Zigachev struct cm_color_matrix_shift shifts; 83*b843c749SSergey Zigachev struct cm_color_matrix_mask masks; 84*b843c749SSergey Zigachev 85*b843c749SSergey Zigachev uint32_t csc_c11_c12; 86*b843c749SSergey Zigachev uint32_t csc_c33_c34; 87*b843c749SSergey Zigachev }; 88*b843c749SSergey Zigachev 89*b843c749SSergey Zigachev void cm_helper_program_color_matrices( 90*b843c749SSergey Zigachev struct dc_context *ctx, 91*b843c749SSergey Zigachev const uint16_t *regval, 92*b843c749SSergey Zigachev const struct color_matrices_reg *reg); 93*b843c749SSergey Zigachev 94*b843c749SSergey Zigachev void cm_helper_program_xfer_func( 95*b843c749SSergey Zigachev struct dc_context *ctx, 96*b843c749SSergey Zigachev const struct pwl_params *params, 97*b843c749SSergey Zigachev const struct xfer_func_reg *reg); 98*b843c749SSergey Zigachev 99*b843c749SSergey Zigachev bool cm_helper_convert_to_custom_float( 100*b843c749SSergey Zigachev struct pwl_result_data *rgb_resulted, 101*b843c749SSergey Zigachev struct curve_points *arr_points, 102*b843c749SSergey Zigachev uint32_t hw_points_num, 103*b843c749SSergey Zigachev bool fixpoint); 104*b843c749SSergey Zigachev 105*b843c749SSergey Zigachev bool cm_helper_translate_curve_to_hw_format( 106*b843c749SSergey Zigachev const struct dc_transfer_func *output_tf, 107*b843c749SSergey Zigachev struct pwl_params *lut_params, bool fixpoint); 108*b843c749SSergey Zigachev 109*b843c749SSergey Zigachev bool cm_helper_translate_curve_to_degamma_hw_format( 110*b843c749SSergey Zigachev const struct dc_transfer_func *output_tf, 111*b843c749SSergey Zigachev struct pwl_params *lut_params); 112*b843c749SSergey Zigachev 113*b843c749SSergey Zigachev 114*b843c749SSergey Zigachev #endif 115