1 /* 2 * Copyright 2012-15 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 27 #ifndef __DAL_DPP_H__ 28 #define __DAL_DPP_H__ 29 30 #include "transform.h" 31 32 struct dpp { 33 const struct dpp_funcs *funcs; 34 struct dc_context *ctx; 35 /** 36 * @inst: 37 * 38 * inst stands for "instance," and it is an id number that references a 39 * specific DPP. 40 */ 41 int inst; 42 struct dpp_caps *caps; 43 struct pwl_params regamma_params; 44 struct pwl_params degamma_params; 45 struct dpp_cursor_attributes cur_attr; 46 47 struct pwl_params shaper_params; 48 bool cm_bypass_mode; 49 }; 50 51 struct dpp_input_csc_matrix { 52 enum dc_color_space color_space; 53 uint16_t regval[12]; 54 }; 55 56 static const struct dpp_input_csc_matrix __maybe_unused dpp_input_csc_matrix[] = { 57 {COLOR_SPACE_SRGB, 58 {0x2000, 0, 0, 0, 0, 0x2000, 0, 0, 0, 0, 0x2000, 0} }, 59 {COLOR_SPACE_SRGB_LIMITED, 60 {0x2000, 0, 0, 0, 0, 0x2000, 0, 0, 0, 0, 0x2000, 0} }, 61 {COLOR_SPACE_YCBCR601, 62 {0x2cdd, 0x2000, 0, 0xe991, 0xe926, 0x2000, 0xf4fd, 0x10ef, 63 0, 0x2000, 0x38b4, 0xe3a6} }, 64 {COLOR_SPACE_YCBCR601_LIMITED, 65 {0x3353, 0x2568, 0, 0xe400, 0xe5dc, 0x2568, 0xf367, 0x1108, 66 0, 0x2568, 0x40de, 0xdd3a} }, 67 {COLOR_SPACE_YCBCR709, 68 {0x3265, 0x2000, 0, 0xe6ce, 0xf105, 0x2000, 0xfa01, 0xa7d, 0, 69 0x2000, 0x3b61, 0xe24f} }, 70 71 {COLOR_SPACE_YCBCR709_LIMITED, 72 {0x39a6, 0x2568, 0, 0xe0d6, 0xeedd, 0x2568, 0xf925, 0x9a8, 0, 73 0x2568, 0x43ee, 0xdbb2} } 74 }; 75 76 struct dpp_grph_csc_adjustment { 77 struct fixed31_32 temperature_matrix[CSC_TEMPERATURE_MATRIX_SIZE]; 78 enum graphics_gamut_adjust_type gamut_adjust_type; 79 }; 80 81 struct cnv_color_keyer_params { 82 int color_keyer_en; 83 int color_keyer_mode; 84 int color_keyer_alpha_low; 85 int color_keyer_alpha_high; 86 int color_keyer_red_low; 87 int color_keyer_red_high; 88 int color_keyer_green_low; 89 int color_keyer_green_high; 90 int color_keyer_blue_low; 91 int color_keyer_blue_high; 92 }; 93 94 /* new for dcn2: set the 8bit alpha values based on the 2 bit alpha 95 *ALPHA_2BIT_LUT. ALPHA_2BIT_LUT0 default: 0b00000000 96 *ALPHA_2BIT_LUT. ALPHA_2BIT_LUT1 default: 0b01010101 97 *ALPHA_2BIT_LUT. ALPHA_2BIT_LUT2 default: 0b10101010 98 *ALPHA_2BIT_LUT. ALPHA_2BIT_LUT3 default: 0b11111111 99 */ 100 struct cnv_alpha_2bit_lut { 101 int lut0; 102 int lut1; 103 int lut2; 104 int lut3; 105 }; 106 107 struct dcn_dpp_state { 108 uint32_t is_enabled; 109 uint32_t igam_lut_mode; 110 uint32_t igam_input_format; 111 uint32_t dgam_lut_mode; 112 uint32_t rgam_lut_mode; 113 uint32_t gamut_remap_mode; 114 uint32_t gamut_remap_c11_c12; 115 uint32_t gamut_remap_c13_c14; 116 uint32_t gamut_remap_c21_c22; 117 uint32_t gamut_remap_c23_c24; 118 uint32_t gamut_remap_c31_c32; 119 uint32_t gamut_remap_c33_c34; 120 }; 121 122 struct CM_bias_params { 123 uint32_t cm_bias_cr_r; 124 uint32_t cm_bias_y_g; 125 uint32_t cm_bias_cb_b; 126 uint32_t cm_bias_format; 127 }; 128 129 struct dpp_funcs { 130 bool (*dpp_program_gamcor_lut)( 131 struct dpp *dpp_base, const struct pwl_params *params); 132 133 void (*dpp_set_pre_degam)(struct dpp *dpp_base, 134 enum dc_transfer_func_predefined tr); 135 136 void (*dpp_program_cm_dealpha)(struct dpp *dpp_base, 137 uint32_t enable, uint32_t additive_blending); 138 139 void (*dpp_program_cm_bias)( 140 struct dpp *dpp_base, 141 struct CM_bias_params *bias_params); 142 143 void (*dpp_read_state)(struct dpp *dpp, struct dcn_dpp_state *s); 144 145 void (*dpp_reset)(struct dpp *dpp); 146 147 void (*dpp_set_scaler)(struct dpp *dpp, 148 const struct scaler_data *scl_data); 149 150 void (*dpp_set_pixel_storage_depth)( 151 struct dpp *dpp, 152 enum lb_pixel_depth depth, 153 const struct bit_depth_reduction_params *bit_depth_params); 154 155 bool (*dpp_get_optimal_number_of_taps)( 156 struct dpp *dpp, 157 struct scaler_data *scl_data, 158 const struct scaling_taps *in_taps); 159 160 void (*dpp_set_gamut_remap)( 161 struct dpp *dpp, 162 const struct dpp_grph_csc_adjustment *adjust); 163 164 void (*dpp_set_csc_default)( 165 struct dpp *dpp, 166 enum dc_color_space colorspace); 167 168 void (*dpp_set_csc_adjustment)( 169 struct dpp *dpp, 170 const uint16_t *regval); 171 172 void (*dpp_power_on_regamma_lut)( 173 struct dpp *dpp, 174 bool power_on); 175 176 void (*dpp_program_regamma_lut)( 177 struct dpp *dpp, 178 const struct pwl_result_data *rgb, 179 uint32_t num); 180 181 void (*dpp_configure_regamma_lut)( 182 struct dpp *dpp, 183 bool is_ram_a); 184 185 void (*dpp_program_regamma_lutb_settings)( 186 struct dpp *dpp, 187 const struct pwl_params *params); 188 189 void (*dpp_program_regamma_luta_settings)( 190 struct dpp *dpp, 191 const struct pwl_params *params); 192 193 void (*dpp_program_regamma_pwl)( 194 struct dpp *dpp, 195 const struct pwl_params *params, 196 enum opp_regamma mode); 197 198 void (*dpp_program_bias_and_scale)( 199 struct dpp *dpp, 200 struct dc_bias_and_scale *params); 201 202 void (*dpp_set_degamma)( 203 struct dpp *dpp_base, 204 enum ipp_degamma_mode mode); 205 206 void (*dpp_program_input_lut)( 207 struct dpp *dpp_base, 208 const struct dc_gamma *gamma); 209 210 void (*dpp_program_degamma_pwl)(struct dpp *dpp_base, 211 const struct pwl_params *params); 212 213 void (*dpp_setup)( 214 struct dpp *dpp_base, 215 enum surface_pixel_format format, 216 enum expansion_mode mode, 217 struct dc_csc_transform input_csc_color_matrix, 218 enum dc_color_space input_color_space, 219 struct cnv_alpha_2bit_lut *alpha_2bit_lut); 220 221 void (*dpp_full_bypass)(struct dpp *dpp_base); 222 223 void (*set_cursor_attributes)( 224 struct dpp *dpp_base, 225 struct dc_cursor_attributes *cursor_attributes); 226 227 void (*set_cursor_position)( 228 struct dpp *dpp_base, 229 const struct dc_cursor_position *pos, 230 const struct dc_cursor_mi_param *param, 231 uint32_t width, 232 uint32_t height 233 ); 234 235 void (*dpp_set_hdr_multiplier)( 236 struct dpp *dpp_base, 237 uint32_t multiplier); 238 239 void (*set_optional_cursor_attributes)( 240 struct dpp *dpp_base, 241 struct dpp_cursor_attributes *attr); 242 243 void (*dpp_dppclk_control)( 244 struct dpp *dpp_base, 245 bool dppclk_div, 246 bool enable); 247 248 bool (*dpp_program_blnd_lut)( 249 struct dpp *dpp, 250 const struct pwl_params *params); 251 bool (*dpp_program_shaper_lut)( 252 struct dpp *dpp, 253 const struct pwl_params *params); 254 bool (*dpp_program_3dlut)( 255 struct dpp *dpp, 256 struct tetrahedral_params *params); 257 void (*dpp_cnv_set_alpha_keyer)( 258 struct dpp *dpp_base, 259 struct cnv_color_keyer_params *color_keyer); 260 }; 261 262 263 264 #endif 265