121 lines · c
1/*2 * Copyright 2016 Advanced Micro Devices, Inc.3 *4 * Permission is hereby granted, free of charge, to any person obtaining a5 * copy of this software and associated documentation files (the "Software"),6 * to deal in the Software without restriction, including without limitation7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,8 * and/or sell copies of the Software, and to permit persons to whom the9 * Software is furnished to do so, subject to the following conditions:10 *11 * The above copyright notice and this permission notice shall be included in12 * all copies or substantial portions of the Software.13 *14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR18 * 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 OR20 * OTHER DEALINGS IN THE SOFTWARE.21 *22 * Authors: AMD23 *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_slope40 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_end56 57#define TF_CM_REG_FIELD_LIST(type) \58 type csc_c11; \59 type csc_c1260 61struct xfer_func_shift {62 TF_HELPER_REG_FIELD_LIST(uint8_t);63};64 65struct xfer_func_mask {66 TF_HELPER_REG_FIELD_LIST(uint32_t);67};68 69struct xfer_func_reg {70 struct xfer_func_shift shifts;71 struct xfer_func_mask masks;72 73 TF_HELPER_REG_LIST;74};75 76struct cm_color_matrix_shift {77 TF_CM_REG_FIELD_LIST(uint8_t);78};79 80struct cm_color_matrix_mask {81 TF_CM_REG_FIELD_LIST(uint32_t);82};83 84struct 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 92void cm_helper_program_color_matrices(93 struct dc_context *ctx,94 const uint16_t *regval,95 const struct color_matrices_reg *reg);96 97void cm_helper_program_xfer_func(98 struct dc_context *ctx,99 const struct pwl_params *params,100 const struct xfer_func_reg *reg);101 102bool 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 108bool cm_helper_translate_curve_to_hw_format(109 struct dc_context *ctx,110 const struct dc_transfer_func *output_tf,111 struct pwl_params *lut_params, bool fixpoint);112 113bool cm_helper_translate_curve_to_degamma_hw_format(114 const struct dc_transfer_func *output_tf,115 struct pwl_params *lut_params);116 117void cm_helper_read_color_matrices(struct dc_context *ctx,118 uint16_t *regval,119 const struct color_matrices_reg *reg);120#endif121