1 /* 2 * Copyright 2016 Advanced Micro Devices, Inc. 3 * 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: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 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. 21 * 22 * Authors: AMD 23 * 24 */ 25 26 #ifndef __DAL_DCN10_CM_COMMON_H__ 27 #define __DAL_DCN10_CM_COMMON_H__ 28 29 #define TF_HELPER_REG_FIELD_LIST(type) \ 30 type exp_region0_lut_offset; \ 31 type exp_region0_num_segments; \ 32 type exp_region1_lut_offset; \ 33 type exp_region1_num_segments;\ 34 type field_region_end;\ 35 type field_region_end_slope;\ 36 type field_region_end_base;\ 37 type exp_region_start;\ 38 type exp_resion_start_segment;\ 39 type field_region_linear_slope 40 41 #define TF_HELPER_REG_LIST \ 42 uint32_t start_cntl_b; \ 43 uint32_t start_cntl_g; \ 44 uint32_t start_cntl_r; \ 45 uint32_t start_slope_cntl_b; \ 46 uint32_t start_slope_cntl_g; \ 47 uint32_t start_slope_cntl_r; \ 48 uint32_t start_end_cntl1_b; \ 49 uint32_t start_end_cntl2_b; \ 50 uint32_t start_end_cntl1_g; \ 51 uint32_t start_end_cntl2_g; \ 52 uint32_t start_end_cntl1_r; \ 53 uint32_t start_end_cntl2_r; \ 54 uint32_t region_start; \ 55 uint32_t region_end 56 57 #define TF_CM_REG_FIELD_LIST(type) \ 58 type csc_c11; \ 59 type csc_c12 60 61 struct xfer_func_shift { 62 TF_HELPER_REG_FIELD_LIST(uint8_t); 63 }; 64 65 struct xfer_func_mask { 66 TF_HELPER_REG_FIELD_LIST(uint32_t); 67 }; 68 69 struct xfer_func_reg { 70 struct xfer_func_shift shifts; 71 struct xfer_func_mask masks; 72 73 TF_HELPER_REG_LIST; 74 }; 75 76 struct cm_color_matrix_shift { 77 TF_CM_REG_FIELD_LIST(uint8_t); 78 }; 79 80 struct cm_color_matrix_mask { 81 TF_CM_REG_FIELD_LIST(uint32_t); 82 }; 83 84 struct color_matrices_reg{ 85 struct cm_color_matrix_shift shifts; 86 struct cm_color_matrix_mask masks; 87 88 uint32_t csc_c11_c12; 89 uint32_t csc_c33_c34; 90 }; 91 92 void cm_helper_program_color_matrices( 93 struct dc_context *ctx, 94 const uint16_t *regval, 95 const struct color_matrices_reg *reg); 96 97 void cm_helper_program_xfer_func( 98 struct dc_context *ctx, 99 const struct pwl_params *params, 100 const struct xfer_func_reg *reg); 101 102 bool cm_helper_convert_to_custom_float( 103 struct pwl_result_data *rgb_resulted, 104 struct curve_points3 *corner_points, 105 uint32_t hw_points_num, 106 bool fixpoint); 107 108 bool cm_helper_translate_curve_to_hw_format( 109 const struct dc_transfer_func *output_tf, 110 struct pwl_params *lut_params, bool fixpoint); 111 112 bool cm_helper_translate_curve_to_degamma_hw_format( 113 const struct dc_transfer_func *output_tf, 114 struct pwl_params *lut_params); 115 116 117 #endif 118