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