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