1*b843c749SSergey Zigachev /* 2*b843c749SSergey Zigachev * Copyright 2012-15 Advanced Micro Devices, Inc. 3*b843c749SSergey Zigachev * 4*b843c749SSergey Zigachev * Permission is hereby granted, free of charge, to any person obtaining a 5*b843c749SSergey Zigachev * copy of this software and associated documentation files (the "Software"), 6*b843c749SSergey Zigachev * to deal in the Software without restriction, including without limitation 7*b843c749SSergey Zigachev * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8*b843c749SSergey Zigachev * and/or sell copies of the Software, and to permit persons to whom the 9*b843c749SSergey Zigachev * Software is furnished to do so, subject to the following conditions: 10*b843c749SSergey Zigachev * 11*b843c749SSergey Zigachev * The above copyright notice and this permission notice shall be included in 12*b843c749SSergey Zigachev * all copies or substantial portions of the Software. 13*b843c749SSergey Zigachev * 14*b843c749SSergey Zigachev * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15*b843c749SSergey Zigachev * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16*b843c749SSergey Zigachev * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17*b843c749SSergey Zigachev * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18*b843c749SSergey Zigachev * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19*b843c749SSergey Zigachev * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20*b843c749SSergey Zigachev * OTHER DEALINGS IN THE SOFTWARE. 21*b843c749SSergey Zigachev * 22*b843c749SSergey Zigachev * Authors: AMD 23*b843c749SSergey Zigachev * 24*b843c749SSergey Zigachev */ 25*b843c749SSergey Zigachev 26*b843c749SSergey Zigachev #ifndef __DAL_TRANSFORM_H__ 27*b843c749SSergey Zigachev #define __DAL_TRANSFORM_H__ 28*b843c749SSergey Zigachev 29*b843c749SSergey Zigachev #include "hw_shared.h" 30*b843c749SSergey Zigachev #include "dc_hw_types.h" 31*b843c749SSergey Zigachev #include "fixed31_32.h" 32*b843c749SSergey Zigachev 33*b843c749SSergey Zigachev #define CSC_TEMPERATURE_MATRIX_SIZE 12 34*b843c749SSergey Zigachev 35*b843c749SSergey Zigachev struct bit_depth_reduction_params; 36*b843c749SSergey Zigachev 37*b843c749SSergey Zigachev struct transform { 38*b843c749SSergey Zigachev const struct transform_funcs *funcs; 39*b843c749SSergey Zigachev struct dc_context *ctx; 40*b843c749SSergey Zigachev int inst; 41*b843c749SSergey Zigachev struct dpp_caps *caps; 42*b843c749SSergey Zigachev struct pwl_params regamma_params; 43*b843c749SSergey Zigachev }; 44*b843c749SSergey Zigachev 45*b843c749SSergey Zigachev /* Colorimetry */ 46*b843c749SSergey Zigachev enum colorimetry { 47*b843c749SSergey Zigachev COLORIMETRY_NO_DATA = 0, 48*b843c749SSergey Zigachev COLORIMETRY_ITU601 = 1, 49*b843c749SSergey Zigachev COLORIMETRY_ITU709 = 2, 50*b843c749SSergey Zigachev COLORIMETRY_EXTENDED = 3 51*b843c749SSergey Zigachev }; 52*b843c749SSergey Zigachev 53*b843c749SSergey Zigachev enum colorimetry_ext { 54*b843c749SSergey Zigachev COLORIMETRYEX_XVYCC601 = 0, 55*b843c749SSergey Zigachev COLORIMETRYEX_XVYCC709 = 1, 56*b843c749SSergey Zigachev COLORIMETRYEX_SYCC601 = 2, 57*b843c749SSergey Zigachev COLORIMETRYEX_ADOBEYCC601 = 3, 58*b843c749SSergey Zigachev COLORIMETRYEX_ADOBERGB = 4, 59*b843c749SSergey Zigachev COLORIMETRYEX_BT2020YCC = 5, 60*b843c749SSergey Zigachev COLORIMETRYEX_BT2020RGBYCBCR = 6, 61*b843c749SSergey Zigachev COLORIMETRYEX_RESERVED = 7 62*b843c749SSergey Zigachev }; 63*b843c749SSergey Zigachev 64*b843c749SSergey Zigachev enum active_format_info { 65*b843c749SSergey Zigachev ACTIVE_FORMAT_NO_DATA = 0, 66*b843c749SSergey Zigachev ACTIVE_FORMAT_VALID = 1 67*b843c749SSergey Zigachev }; 68*b843c749SSergey Zigachev 69*b843c749SSergey Zigachev /* Active format aspect ratio */ 70*b843c749SSergey Zigachev enum active_format_aspect_ratio { 71*b843c749SSergey Zigachev ACTIVE_FORMAT_ASPECT_RATIO_SAME_AS_PICTURE = 8, 72*b843c749SSergey Zigachev ACTIVE_FORMAT_ASPECT_RATIO_4_3 = 9, 73*b843c749SSergey Zigachev ACTIVE_FORMAT_ASPECT_RATIO_16_9 = 0XA, 74*b843c749SSergey Zigachev ACTIVE_FORMAT_ASPECT_RATIO_14_9 = 0XB 75*b843c749SSergey Zigachev }; 76*b843c749SSergey Zigachev 77*b843c749SSergey Zigachev enum bar_info { 78*b843c749SSergey Zigachev BAR_INFO_NOT_VALID = 0, 79*b843c749SSergey Zigachev BAR_INFO_VERTICAL_VALID = 1, 80*b843c749SSergey Zigachev BAR_INFO_HORIZONTAL_VALID = 2, 81*b843c749SSergey Zigachev BAR_INFO_BOTH_VALID = 3 82*b843c749SSergey Zigachev }; 83*b843c749SSergey Zigachev 84*b843c749SSergey Zigachev enum picture_scaling { 85*b843c749SSergey Zigachev PICTURE_SCALING_UNIFORM = 0, 86*b843c749SSergey Zigachev PICTURE_SCALING_HORIZONTAL = 1, 87*b843c749SSergey Zigachev PICTURE_SCALING_VERTICAL = 2, 88*b843c749SSergey Zigachev PICTURE_SCALING_BOTH = 3 89*b843c749SSergey Zigachev }; 90*b843c749SSergey Zigachev 91*b843c749SSergey Zigachev /* RGB quantization range */ 92*b843c749SSergey Zigachev enum rgb_quantization_range { 93*b843c749SSergey Zigachev RGB_QUANTIZATION_DEFAULT_RANGE = 0, 94*b843c749SSergey Zigachev RGB_QUANTIZATION_LIMITED_RANGE = 1, 95*b843c749SSergey Zigachev RGB_QUANTIZATION_FULL_RANGE = 2, 96*b843c749SSergey Zigachev RGB_QUANTIZATION_RESERVED = 3 97*b843c749SSergey Zigachev }; 98*b843c749SSergey Zigachev 99*b843c749SSergey Zigachev /* YYC quantization range */ 100*b843c749SSergey Zigachev enum yyc_quantization_range { 101*b843c749SSergey Zigachev YYC_QUANTIZATION_LIMITED_RANGE = 0, 102*b843c749SSergey Zigachev YYC_QUANTIZATION_FULL_RANGE = 1, 103*b843c749SSergey Zigachev YYC_QUANTIZATION_RESERVED2 = 2, 104*b843c749SSergey Zigachev YYC_QUANTIZATION_RESERVED3 = 3 105*b843c749SSergey Zigachev }; 106*b843c749SSergey Zigachev 107*b843c749SSergey Zigachev enum graphics_gamut_adjust_type { 108*b843c749SSergey Zigachev GRAPHICS_GAMUT_ADJUST_TYPE_BYPASS = 0, 109*b843c749SSergey Zigachev GRAPHICS_GAMUT_ADJUST_TYPE_HW, /* without adjustments */ 110*b843c749SSergey Zigachev GRAPHICS_GAMUT_ADJUST_TYPE_SW /* use adjustments */ 111*b843c749SSergey Zigachev }; 112*b843c749SSergey Zigachev 113*b843c749SSergey Zigachev enum lb_memory_config { 114*b843c749SSergey Zigachev /* Enable all 3 pieces of memory */ 115*b843c749SSergey Zigachev LB_MEMORY_CONFIG_0 = 0, 116*b843c749SSergey Zigachev 117*b843c749SSergey Zigachev /* Enable only the first piece of memory */ 118*b843c749SSergey Zigachev LB_MEMORY_CONFIG_1 = 1, 119*b843c749SSergey Zigachev 120*b843c749SSergey Zigachev /* Enable only the second piece of memory */ 121*b843c749SSergey Zigachev LB_MEMORY_CONFIG_2 = 2, 122*b843c749SSergey Zigachev 123*b843c749SSergey Zigachev /* Only applicable in 4:2:0 mode, enable all 3 pieces of memory and the 124*b843c749SSergey Zigachev * last piece of chroma memory used for the luma storage 125*b843c749SSergey Zigachev */ 126*b843c749SSergey Zigachev LB_MEMORY_CONFIG_3 = 3 127*b843c749SSergey Zigachev }; 128*b843c749SSergey Zigachev 129*b843c749SSergey Zigachev struct xfm_grph_csc_adjustment { 130*b843c749SSergey Zigachev struct fixed31_32 temperature_matrix[CSC_TEMPERATURE_MATRIX_SIZE]; 131*b843c749SSergey Zigachev enum graphics_gamut_adjust_type gamut_adjust_type; 132*b843c749SSergey Zigachev }; 133*b843c749SSergey Zigachev 134*b843c749SSergey Zigachev struct overscan_info { 135*b843c749SSergey Zigachev int left; 136*b843c749SSergey Zigachev int right; 137*b843c749SSergey Zigachev int top; 138*b843c749SSergey Zigachev int bottom; 139*b843c749SSergey Zigachev }; 140*b843c749SSergey Zigachev 141*b843c749SSergey Zigachev struct scaling_ratios { 142*b843c749SSergey Zigachev struct fixed31_32 horz; 143*b843c749SSergey Zigachev struct fixed31_32 vert; 144*b843c749SSergey Zigachev struct fixed31_32 horz_c; 145*b843c749SSergey Zigachev struct fixed31_32 vert_c; 146*b843c749SSergey Zigachev }; 147*b843c749SSergey Zigachev 148*b843c749SSergey Zigachev struct sharpness_adj { 149*b843c749SSergey Zigachev int horz; 150*b843c749SSergey Zigachev int vert; 151*b843c749SSergey Zigachev }; 152*b843c749SSergey Zigachev 153*b843c749SSergey Zigachev struct line_buffer_params { 154*b843c749SSergey Zigachev bool alpha_en; 155*b843c749SSergey Zigachev bool pixel_expan_mode; 156*b843c749SSergey Zigachev bool interleave_en; 157*b843c749SSergey Zigachev int dynamic_pixel_depth; 158*b843c749SSergey Zigachev enum lb_pixel_depth depth; 159*b843c749SSergey Zigachev }; 160*b843c749SSergey Zigachev 161*b843c749SSergey Zigachev struct scl_inits { 162*b843c749SSergey Zigachev struct fixed31_32 h; 163*b843c749SSergey Zigachev struct fixed31_32 h_c; 164*b843c749SSergey Zigachev struct fixed31_32 v; 165*b843c749SSergey Zigachev struct fixed31_32 v_bot; 166*b843c749SSergey Zigachev struct fixed31_32 v_c; 167*b843c749SSergey Zigachev struct fixed31_32 v_c_bot; 168*b843c749SSergey Zigachev }; 169*b843c749SSergey Zigachev 170*b843c749SSergey Zigachev struct scaler_data { 171*b843c749SSergey Zigachev int h_active; 172*b843c749SSergey Zigachev int v_active; 173*b843c749SSergey Zigachev struct scaling_taps taps; 174*b843c749SSergey Zigachev struct rect viewport; 175*b843c749SSergey Zigachev struct rect viewport_c; 176*b843c749SSergey Zigachev struct rect recout; 177*b843c749SSergey Zigachev struct scaling_ratios ratios; 178*b843c749SSergey Zigachev struct scl_inits inits; 179*b843c749SSergey Zigachev struct sharpness_adj sharpness; 180*b843c749SSergey Zigachev enum pixel_format format; 181*b843c749SSergey Zigachev struct line_buffer_params lb_params; 182*b843c749SSergey Zigachev }; 183*b843c749SSergey Zigachev 184*b843c749SSergey Zigachev struct transform_funcs { 185*b843c749SSergey Zigachev void (*transform_reset)(struct transform *xfm); 186*b843c749SSergey Zigachev 187*b843c749SSergey Zigachev void (*transform_set_scaler)(struct transform *xfm, 188*b843c749SSergey Zigachev const struct scaler_data *scl_data); 189*b843c749SSergey Zigachev 190*b843c749SSergey Zigachev void (*transform_set_pixel_storage_depth)( 191*b843c749SSergey Zigachev struct transform *xfm, 192*b843c749SSergey Zigachev enum lb_pixel_depth depth, 193*b843c749SSergey Zigachev const struct bit_depth_reduction_params *bit_depth_params); 194*b843c749SSergey Zigachev 195*b843c749SSergey Zigachev bool (*transform_get_optimal_number_of_taps)( 196*b843c749SSergey Zigachev struct transform *xfm, 197*b843c749SSergey Zigachev struct scaler_data *scl_data, 198*b843c749SSergey Zigachev const struct scaling_taps *in_taps); 199*b843c749SSergey Zigachev 200*b843c749SSergey Zigachev void (*transform_set_gamut_remap)( 201*b843c749SSergey Zigachev struct transform *xfm, 202*b843c749SSergey Zigachev const struct xfm_grph_csc_adjustment *adjust); 203*b843c749SSergey Zigachev 204*b843c749SSergey Zigachev void (*opp_set_csc_default)( 205*b843c749SSergey Zigachev struct transform *xfm, 206*b843c749SSergey Zigachev const struct default_adjustment *default_adjust); 207*b843c749SSergey Zigachev 208*b843c749SSergey Zigachev void (*opp_set_csc_adjustment)( 209*b843c749SSergey Zigachev struct transform *xfm, 210*b843c749SSergey Zigachev const struct out_csc_color_matrix *tbl_entry); 211*b843c749SSergey Zigachev 212*b843c749SSergey Zigachev void (*opp_power_on_regamma_lut)( 213*b843c749SSergey Zigachev struct transform *xfm, 214*b843c749SSergey Zigachev bool power_on); 215*b843c749SSergey Zigachev 216*b843c749SSergey Zigachev void (*opp_program_regamma_lut)( 217*b843c749SSergey Zigachev struct transform *xfm, 218*b843c749SSergey Zigachev const struct pwl_result_data *rgb, 219*b843c749SSergey Zigachev uint32_t num); 220*b843c749SSergey Zigachev 221*b843c749SSergey Zigachev void (*opp_configure_regamma_lut)( 222*b843c749SSergey Zigachev struct transform *xfm, 223*b843c749SSergey Zigachev bool is_ram_a); 224*b843c749SSergey Zigachev 225*b843c749SSergey Zigachev void (*opp_program_regamma_lutb_settings)( 226*b843c749SSergey Zigachev struct transform *xfm, 227*b843c749SSergey Zigachev const struct pwl_params *params); 228*b843c749SSergey Zigachev 229*b843c749SSergey Zigachev void (*opp_program_regamma_luta_settings)( 230*b843c749SSergey Zigachev struct transform *xfm, 231*b843c749SSergey Zigachev const struct pwl_params *params); 232*b843c749SSergey Zigachev 233*b843c749SSergey Zigachev void (*opp_program_regamma_pwl)( 234*b843c749SSergey Zigachev struct transform *xfm, const struct pwl_params *params); 235*b843c749SSergey Zigachev 236*b843c749SSergey Zigachev void (*opp_set_regamma_mode)( 237*b843c749SSergey Zigachev struct transform *xfm_base, 238*b843c749SSergey Zigachev enum opp_regamma mode); 239*b843c749SSergey Zigachev 240*b843c749SSergey Zigachev void (*ipp_set_degamma)( 241*b843c749SSergey Zigachev struct transform *xfm_base, 242*b843c749SSergey Zigachev enum ipp_degamma_mode mode); 243*b843c749SSergey Zigachev 244*b843c749SSergey Zigachev void (*ipp_program_input_lut)( 245*b843c749SSergey Zigachev struct transform *xfm_base, 246*b843c749SSergey Zigachev const struct dc_gamma *gamma); 247*b843c749SSergey Zigachev 248*b843c749SSergey Zigachev void (*ipp_program_degamma_pwl)(struct transform *xfm_base, 249*b843c749SSergey Zigachev const struct pwl_params *params); 250*b843c749SSergey Zigachev 251*b843c749SSergey Zigachev void (*ipp_setup)( 252*b843c749SSergey Zigachev struct transform *xfm_base, 253*b843c749SSergey Zigachev enum surface_pixel_format format, 254*b843c749SSergey Zigachev enum expansion_mode mode, 255*b843c749SSergey Zigachev struct dc_csc_transform input_csc_color_matrix, 256*b843c749SSergey Zigachev enum dc_color_space input_color_space); 257*b843c749SSergey Zigachev 258*b843c749SSergey Zigachev void (*ipp_full_bypass)(struct transform *xfm_base); 259*b843c749SSergey Zigachev 260*b843c749SSergey Zigachev void (*set_cursor_attributes)( 261*b843c749SSergey Zigachev struct transform *xfm_base, 262*b843c749SSergey Zigachev const struct dc_cursor_attributes *attr); 263*b843c749SSergey Zigachev 264*b843c749SSergey Zigachev }; 265*b843c749SSergey Zigachev 266*b843c749SSergey Zigachev const uint16_t *get_filter_2tap_16p(void); 267*b843c749SSergey Zigachev const uint16_t *get_filter_2tap_64p(void); 268*b843c749SSergey Zigachev const uint16_t *get_filter_3tap_16p(struct fixed31_32 ratio); 269*b843c749SSergey Zigachev const uint16_t *get_filter_3tap_64p(struct fixed31_32 ratio); 270*b843c749SSergey Zigachev const uint16_t *get_filter_4tap_16p(struct fixed31_32 ratio); 271*b843c749SSergey Zigachev const uint16_t *get_filter_4tap_64p(struct fixed31_32 ratio); 272*b843c749SSergey Zigachev const uint16_t *get_filter_5tap_64p(struct fixed31_32 ratio); 273*b843c749SSergey Zigachev const uint16_t *get_filter_6tap_64p(struct fixed31_32 ratio); 274*b843c749SSergey Zigachev const uint16_t *get_filter_7tap_64p(struct fixed31_32 ratio); 275*b843c749SSergey Zigachev const uint16_t *get_filter_8tap_64p(struct fixed31_32 ratio); 276*b843c749SSergey Zigachev 277*b843c749SSergey Zigachev 278*b843c749SSergey Zigachev /* Defines the pixel processing capability of the DSCL */ 279*b843c749SSergey Zigachev enum dscl_data_processing_format { 280*b843c749SSergey Zigachev DSCL_DATA_PRCESSING_FIXED_FORMAT, /* The DSCL processes pixel data in fixed format */ 281*b843c749SSergey Zigachev DSCL_DATA_PRCESSING_FLOAT_FORMAT, /* The DSCL processes pixel data in float format */ 282*b843c749SSergey Zigachev }; 283*b843c749SSergey Zigachev 284*b843c749SSergey Zigachev /* 285*b843c749SSergey Zigachev * The DPP capabilities structure contains enumerations to specify the 286*b843c749SSergey Zigachev * HW processing features and an associated function pointers to 287*b843c749SSergey Zigachev * provide the function interface that can be overloaded for implementations 288*b843c749SSergey Zigachev * based on different capabilities 289*b843c749SSergey Zigachev */ 290*b843c749SSergey Zigachev struct dpp_caps { 291*b843c749SSergey Zigachev /* DSCL processing pixel data in fixed or float format */ 292*b843c749SSergey Zigachev enum dscl_data_processing_format dscl_data_proc_format; 293*b843c749SSergey Zigachev 294*b843c749SSergey Zigachev /* Calculates the number of partitions in the line buffer. 295*b843c749SSergey Zigachev * The implementation of this function is overloaded for 296*b843c749SSergey Zigachev * different versions of DSCL LB. 297*b843c749SSergey Zigachev */ 298*b843c749SSergey Zigachev void (*dscl_calc_lb_num_partitions)( 299*b843c749SSergey Zigachev const struct scaler_data *scl_data, 300*b843c749SSergey Zigachev enum lb_memory_config lb_config, 301*b843c749SSergey Zigachev int *num_part_y, 302*b843c749SSergey Zigachev int *num_part_c); 303*b843c749SSergey Zigachev }; 304*b843c749SSergey Zigachev 305*b843c749SSergey Zigachev 306*b843c749SSergey Zigachev #endif 307