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 #ifndef __DAL_TRANSFORM_H__ 27 #define __DAL_TRANSFORM_H__ 28 29 #include "hw_shared.h" 30 #include "dc_hw_types.h" 31 #include "fixed31_32.h" 32 #include "spl/dc_spl_types.h" 33 34 #define CSC_TEMPERATURE_MATRIX_SIZE 12 35 36 struct bit_depth_reduction_params; 37 38 struct transform { 39 const struct transform_funcs *funcs; 40 struct dc_context *ctx; 41 int inst; 42 struct dpp_caps *caps; 43 struct pwl_params regamma_params; 44 }; 45 46 /* Colorimetry */ 47 enum colorimetry { 48 COLORIMETRY_NO_DATA = 0, 49 COLORIMETRY_ITU601 = 1, 50 COLORIMETRY_ITU709 = 2, 51 COLORIMETRY_EXTENDED = 3 52 }; 53 54 enum colorimetry_ext { 55 COLORIMETRYEX_XVYCC601 = 0, 56 COLORIMETRYEX_XVYCC709 = 1, 57 COLORIMETRYEX_SYCC601 = 2, 58 COLORIMETRYEX_ADOBEYCC601 = 3, 59 COLORIMETRYEX_ADOBERGB = 4, 60 COLORIMETRYEX_BT2020YCC = 5, 61 COLORIMETRYEX_BT2020RGBYCBCR = 6, 62 COLORIMETRYEX_RESERVED = 7 63 }; 64 65 enum active_format_info { 66 ACTIVE_FORMAT_NO_DATA = 0, 67 ACTIVE_FORMAT_VALID = 1 68 }; 69 70 /* Active format aspect ratio */ 71 enum active_format_aspect_ratio { 72 ACTIVE_FORMAT_ASPECT_RATIO_SAME_AS_PICTURE = 8, 73 ACTIVE_FORMAT_ASPECT_RATIO_4_3 = 9, 74 ACTIVE_FORMAT_ASPECT_RATIO_16_9 = 0XA, 75 ACTIVE_FORMAT_ASPECT_RATIO_14_9 = 0XB 76 }; 77 78 enum bar_info { 79 BAR_INFO_NOT_VALID = 0, 80 BAR_INFO_VERTICAL_VALID = 1, 81 BAR_INFO_HORIZONTAL_VALID = 2, 82 BAR_INFO_BOTH_VALID = 3 83 }; 84 85 enum picture_scaling { 86 PICTURE_SCALING_UNIFORM = 0, 87 PICTURE_SCALING_HORIZONTAL = 1, 88 PICTURE_SCALING_VERTICAL = 2, 89 PICTURE_SCALING_BOTH = 3 90 }; 91 92 /* RGB quantization range */ 93 enum rgb_quantization_range { 94 RGB_QUANTIZATION_DEFAULT_RANGE = 0, 95 RGB_QUANTIZATION_LIMITED_RANGE = 1, 96 RGB_QUANTIZATION_FULL_RANGE = 2, 97 RGB_QUANTIZATION_RESERVED = 3 98 }; 99 100 /* YYC quantization range */ 101 enum yyc_quantization_range { 102 YYC_QUANTIZATION_LIMITED_RANGE = 0, 103 YYC_QUANTIZATION_FULL_RANGE = 1, 104 YYC_QUANTIZATION_RESERVED2 = 2, 105 YYC_QUANTIZATION_RESERVED3 = 3 106 }; 107 108 enum graphics_gamut_adjust_type { 109 GRAPHICS_GAMUT_ADJUST_TYPE_BYPASS = 0, 110 GRAPHICS_GAMUT_ADJUST_TYPE_HW, /* without adjustments */ 111 GRAPHICS_GAMUT_ADJUST_TYPE_SW /* use adjustments */ 112 }; 113 114 struct xfm_grph_csc_adjustment { 115 struct fixed31_32 temperature_matrix[CSC_TEMPERATURE_MATRIX_SIZE]; 116 enum graphics_gamut_adjust_type gamut_adjust_type; 117 }; 118 119 struct overscan_info { 120 int left; 121 int right; 122 int top; 123 int bottom; 124 }; 125 126 struct scaling_ratios { 127 struct fixed31_32 horz; 128 struct fixed31_32 vert; 129 struct fixed31_32 horz_c; 130 struct fixed31_32 vert_c; 131 }; 132 133 struct sharpness_adj { 134 int horz; 135 int vert; 136 }; 137 138 struct line_buffer_params { 139 bool alpha_en; 140 bool pixel_expan_mode; 141 bool interleave_en; 142 int dynamic_pixel_depth; 143 enum lb_pixel_depth depth; 144 }; 145 146 struct scl_inits { 147 struct fixed31_32 h; 148 struct fixed31_32 h_c; 149 struct fixed31_32 v; 150 struct fixed31_32 v_c; 151 }; 152 153 struct scaler_data { 154 int h_active; 155 int v_active; 156 struct scaling_taps taps; 157 struct rect viewport; 158 struct rect viewport_c; 159 struct rect recout; 160 struct scaling_ratios ratios; 161 struct scl_inits inits; 162 struct sharpness_adj sharpness; 163 enum pixel_format format; 164 struct line_buffer_params lb_params; 165 // Below struct holds the scaler values to program hw registers 166 struct dscl_prog_data dscl_prog_data; 167 }; 168 169 struct transform_funcs { 170 void (*transform_reset)(struct transform *xfm); 171 172 void (*transform_set_scaler)(struct transform *xfm, 173 const struct scaler_data *scl_data); 174 175 void (*transform_set_pixel_storage_depth)( 176 struct transform *xfm, 177 enum lb_pixel_depth depth, 178 const struct bit_depth_reduction_params *bit_depth_params); 179 180 bool (*transform_get_optimal_number_of_taps)( 181 struct transform *xfm, 182 struct scaler_data *scl_data, 183 const struct scaling_taps *in_taps); 184 185 void (*transform_set_gamut_remap)( 186 struct transform *xfm, 187 const struct xfm_grph_csc_adjustment *adjust); 188 189 void (*opp_set_csc_default)( 190 struct transform *xfm, 191 const struct default_adjustment *default_adjust); 192 193 void (*opp_set_csc_adjustment)( 194 struct transform *xfm, 195 const struct out_csc_color_matrix *tbl_entry); 196 197 void (*opp_power_on_regamma_lut)( 198 struct transform *xfm, 199 bool power_on); 200 201 void (*opp_program_regamma_lut)( 202 struct transform *xfm, 203 const struct pwl_result_data *rgb, 204 uint32_t num); 205 206 void (*opp_configure_regamma_lut)( 207 struct transform *xfm, 208 bool is_ram_a); 209 210 void (*opp_program_regamma_lutb_settings)( 211 struct transform *xfm, 212 const struct pwl_params *params); 213 214 void (*opp_program_regamma_luta_settings)( 215 struct transform *xfm, 216 const struct pwl_params *params); 217 218 void (*opp_program_regamma_pwl)( 219 struct transform *xfm, const struct pwl_params *params); 220 221 void (*opp_set_regamma_mode)( 222 struct transform *xfm_base, 223 enum opp_regamma mode); 224 225 void (*ipp_set_degamma)( 226 struct transform *xfm_base, 227 enum ipp_degamma_mode mode); 228 229 void (*ipp_program_input_lut)( 230 struct transform *xfm_base, 231 const struct dc_gamma *gamma); 232 233 void (*ipp_program_degamma_pwl)(struct transform *xfm_base, 234 const struct pwl_params *params); 235 236 void (*ipp_setup)( 237 struct transform *xfm_base, 238 enum surface_pixel_format format, 239 enum expansion_mode mode, 240 struct dc_csc_transform input_csc_color_matrix, 241 enum dc_color_space input_color_space); 242 243 void (*ipp_full_bypass)(struct transform *xfm_base); 244 245 void (*set_cursor_attributes)( 246 struct transform *xfm_base, 247 const struct dc_cursor_attributes *attr); 248 }; 249 250 const uint16_t *get_filter_2tap_16p(void); 251 const uint16_t *get_filter_2tap_64p(void); 252 const uint16_t *get_filter_3tap_16p(struct fixed31_32 ratio); 253 const uint16_t *get_filter_3tap_64p(struct fixed31_32 ratio); 254 const uint16_t *get_filter_4tap_16p(struct fixed31_32 ratio); 255 const uint16_t *get_filter_4tap_64p(struct fixed31_32 ratio); 256 const uint16_t *get_filter_5tap_64p(struct fixed31_32 ratio); 257 const uint16_t *get_filter_6tap_64p(struct fixed31_32 ratio); 258 const uint16_t *get_filter_7tap_64p(struct fixed31_32 ratio); 259 const uint16_t *get_filter_8tap_64p(struct fixed31_32 ratio); 260 261 262 /* Defines the pixel processing capability of the DSCL */ 263 enum dscl_data_processing_format { 264 DSCL_DATA_PRCESSING_FIXED_FORMAT, /* The DSCL processes pixel data in fixed format */ 265 DSCL_DATA_PRCESSING_FLOAT_FORMAT, /* The DSCL processes pixel data in float format */ 266 }; 267 268 /* 269 * The DPP capabilities structure contains enumerations to specify the 270 * HW processing features and an associated function pointers to 271 * provide the function interface that can be overloaded for implementations 272 * based on different capabilities 273 */ 274 struct dpp_caps { 275 /* DSCL processing pixel data in fixed or float format */ 276 enum dscl_data_processing_format dscl_data_proc_format; 277 278 /* max LB partitions */ 279 unsigned int max_lb_partitions; 280 281 /* Calculates the number of partitions in the line buffer. 282 * The implementation of this function is overloaded for 283 * different versions of DSCL LB. 284 */ 285 void (*dscl_calc_lb_num_partitions)( 286 const struct scaler_data *scl_data, 287 enum lb_memory_config lb_config, 288 int *num_part_y, 289 int *num_part_c); 290 }; 291 292 293 #endif 294