1fb4d8502Sjsg /* 2fb4d8502Sjsg * Copyright 2012-15 Advanced Micro Devices, Inc. 3fb4d8502Sjsg * 4fb4d8502Sjsg * Permission is hereby granted, free of charge, to any person obtaining a 5fb4d8502Sjsg * copy of this software and associated documentation files (the "Software"), 6fb4d8502Sjsg * to deal in the Software without restriction, including without limitation 7fb4d8502Sjsg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8fb4d8502Sjsg * and/or sell copies of the Software, and to permit persons to whom the 9fb4d8502Sjsg * Software is furnished to do so, subject to the following conditions: 10fb4d8502Sjsg * 11fb4d8502Sjsg * The above copyright notice and this permission notice shall be included in 12fb4d8502Sjsg * all copies or substantial portions of the Software. 13fb4d8502Sjsg * 14fb4d8502Sjsg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15fb4d8502Sjsg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16fb4d8502Sjsg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17fb4d8502Sjsg * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18fb4d8502Sjsg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19fb4d8502Sjsg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20fb4d8502Sjsg * OTHER DEALINGS IN THE SOFTWARE. 21fb4d8502Sjsg * 22fb4d8502Sjsg * Authors: AMD 23fb4d8502Sjsg * 24fb4d8502Sjsg */ 25fb4d8502Sjsg 26fb4d8502Sjsg #ifndef __DAL_OPP_H__ 27fb4d8502Sjsg #define __DAL_OPP_H__ 28fb4d8502Sjsg 29fb4d8502Sjsg #include "hw_shared.h" 30fb4d8502Sjsg #include "dc_hw_types.h" 31fb4d8502Sjsg #include "transform.h" 32fb4d8502Sjsg #include "mpc.h" 33fb4d8502Sjsg 34fb4d8502Sjsg struct fixed31_32; 35fb4d8502Sjsg 36fb4d8502Sjsg /* TODO: Need cleanup */ 37fb4d8502Sjsg enum clamping_range { 38fb4d8502Sjsg CLAMPING_FULL_RANGE = 0, /* No Clamping */ 39fb4d8502Sjsg CLAMPING_LIMITED_RANGE_8BPC, /* 8 bpc: Clamping 1 to FE */ 40fb4d8502Sjsg CLAMPING_LIMITED_RANGE_10BPC, /* 10 bpc: Clamping 4 to 3FB */ 41fb4d8502Sjsg CLAMPING_LIMITED_RANGE_12BPC, /* 12 bpc: Clamping 10 to FEF */ 42fb4d8502Sjsg /* Use programmable clampping value on FMT_CLAMP_COMPONENT_R/G/B. */ 43fb4d8502Sjsg CLAMPING_LIMITED_RANGE_PROGRAMMABLE 44fb4d8502Sjsg }; 45fb4d8502Sjsg 46fb4d8502Sjsg struct clamping_and_pixel_encoding_params { 47fb4d8502Sjsg enum dc_pixel_encoding pixel_encoding; /* Pixel Encoding */ 48fb4d8502Sjsg enum clamping_range clamping_level; /* Clamping identifier */ 49fb4d8502Sjsg enum dc_color_depth c_depth; /* Deep color use. */ 50fb4d8502Sjsg }; 51fb4d8502Sjsg 52fb4d8502Sjsg struct bit_depth_reduction_params { 53fb4d8502Sjsg struct { 54fb4d8502Sjsg /* truncate/round */ 55fb4d8502Sjsg /* trunc/round enabled*/ 56fb4d8502Sjsg uint32_t TRUNCATE_ENABLED:1; 57fb4d8502Sjsg /* 2 bits: 0=6 bpc, 1=8 bpc, 2 = 10bpc*/ 58fb4d8502Sjsg uint32_t TRUNCATE_DEPTH:2; 59fb4d8502Sjsg /* truncate or round*/ 60fb4d8502Sjsg uint32_t TRUNCATE_MODE:1; 61fb4d8502Sjsg 62fb4d8502Sjsg /* spatial dither */ 63fb4d8502Sjsg /* Spatial Bit Depth Reduction enabled*/ 64fb4d8502Sjsg uint32_t SPATIAL_DITHER_ENABLED:1; 65fb4d8502Sjsg /* 2 bits: 0=6 bpc, 1 = 8 bpc, 2 = 10bpc*/ 66fb4d8502Sjsg uint32_t SPATIAL_DITHER_DEPTH:2; 67fb4d8502Sjsg /* 0-3 to select patterns*/ 68fb4d8502Sjsg uint32_t SPATIAL_DITHER_MODE:2; 69fb4d8502Sjsg /* Enable RGB random dithering*/ 70fb4d8502Sjsg uint32_t RGB_RANDOM:1; 71fb4d8502Sjsg /* Enable Frame random dithering*/ 72fb4d8502Sjsg uint32_t FRAME_RANDOM:1; 73fb4d8502Sjsg /* Enable HighPass random dithering*/ 74fb4d8502Sjsg uint32_t HIGHPASS_RANDOM:1; 75fb4d8502Sjsg 76fb4d8502Sjsg /* temporal dither*/ 77fb4d8502Sjsg /* frame modulation enabled*/ 78fb4d8502Sjsg uint32_t FRAME_MODULATION_ENABLED:1; 79fb4d8502Sjsg /* same as for trunc/spatial*/ 80fb4d8502Sjsg uint32_t FRAME_MODULATION_DEPTH:2; 81fb4d8502Sjsg /* 2/4 gray levels*/ 82fb4d8502Sjsg uint32_t TEMPORAL_LEVEL:1; 83fb4d8502Sjsg uint32_t FRC25:2; 84fb4d8502Sjsg uint32_t FRC50:2; 85fb4d8502Sjsg uint32_t FRC75:2; 86fb4d8502Sjsg } flags; 87fb4d8502Sjsg 88fb4d8502Sjsg uint32_t r_seed_value; 89fb4d8502Sjsg uint32_t b_seed_value; 90fb4d8502Sjsg uint32_t g_seed_value; 91fb4d8502Sjsg enum dc_pixel_encoding pixel_encoding; 92fb4d8502Sjsg }; 93fb4d8502Sjsg 94fb4d8502Sjsg enum wide_gamut_regamma_mode { 95fb4d8502Sjsg /* 0x0 - BITS2:0 Bypass */ 96fb4d8502Sjsg WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_BYPASS, 97fb4d8502Sjsg /* 0x1 - Fixed curve sRGB 2.4 */ 98fb4d8502Sjsg WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_SRGB24, 99fb4d8502Sjsg /* 0x2 - Fixed curve xvYCC 2.22 */ 100fb4d8502Sjsg WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_XYYCC22, 101fb4d8502Sjsg /* 0x3 - Programmable control A */ 102fb4d8502Sjsg WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_MATRIX_A, 103fb4d8502Sjsg /* 0x4 - Programmable control B */ 104fb4d8502Sjsg WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_MATRIX_B, 105fb4d8502Sjsg /* 0x0 - BITS6:4 Bypass */ 106fb4d8502Sjsg WIDE_GAMUT_REGAMMA_MODE_OVL_BYPASS, 107fb4d8502Sjsg /* 0x1 - Fixed curve sRGB 2.4 */ 108fb4d8502Sjsg WIDE_GAMUT_REGAMMA_MODE_OVL_SRGB24, 109fb4d8502Sjsg /* 0x2 - Fixed curve xvYCC 2.22 */ 110fb4d8502Sjsg WIDE_GAMUT_REGAMMA_MODE_OVL_XYYCC22, 111fb4d8502Sjsg /* 0x3 - Programmable control A */ 112fb4d8502Sjsg WIDE_GAMUT_REGAMMA_MODE_OVL_MATRIX_A, 113fb4d8502Sjsg /* 0x4 - Programmable control B */ 114fb4d8502Sjsg WIDE_GAMUT_REGAMMA_MODE_OVL_MATRIX_B 115fb4d8502Sjsg }; 116fb4d8502Sjsg 117fb4d8502Sjsg struct gamma_pixel { 118fb4d8502Sjsg struct fixed31_32 r; 119fb4d8502Sjsg struct fixed31_32 g; 120fb4d8502Sjsg struct fixed31_32 b; 121fb4d8502Sjsg }; 122fb4d8502Sjsg 123fb4d8502Sjsg enum channel_name { 124fb4d8502Sjsg CHANNEL_NAME_RED, 125fb4d8502Sjsg CHANNEL_NAME_GREEN, 126fb4d8502Sjsg CHANNEL_NAME_BLUE 127fb4d8502Sjsg }; 128fb4d8502Sjsg 129fb4d8502Sjsg struct custom_float_format { 130fb4d8502Sjsg uint32_t mantissa_bits; 131fb4d8502Sjsg uint32_t exponenta_bits; 132fb4d8502Sjsg bool sign; 133fb4d8502Sjsg }; 134fb4d8502Sjsg 135fb4d8502Sjsg struct custom_float_value { 136fb4d8502Sjsg uint32_t mantissa; 137fb4d8502Sjsg uint32_t exponenta; 138fb4d8502Sjsg uint32_t value; 139fb4d8502Sjsg bool negative; 140fb4d8502Sjsg }; 141fb4d8502Sjsg 142fb4d8502Sjsg struct hw_x_point { 143fb4d8502Sjsg uint32_t custom_float_x; 144fb4d8502Sjsg struct fixed31_32 x; 145fb4d8502Sjsg struct fixed31_32 regamma_y_red; 146fb4d8502Sjsg struct fixed31_32 regamma_y_green; 147fb4d8502Sjsg struct fixed31_32 regamma_y_blue; 148fb4d8502Sjsg 149fb4d8502Sjsg }; 150fb4d8502Sjsg 151fb4d8502Sjsg struct pwl_float_data_ex { 152fb4d8502Sjsg struct fixed31_32 r; 153fb4d8502Sjsg struct fixed31_32 g; 154fb4d8502Sjsg struct fixed31_32 b; 155fb4d8502Sjsg struct fixed31_32 delta_r; 156fb4d8502Sjsg struct fixed31_32 delta_g; 157fb4d8502Sjsg struct fixed31_32 delta_b; 158fb4d8502Sjsg }; 159fb4d8502Sjsg 160fb4d8502Sjsg enum hw_point_position { 161fb4d8502Sjsg /* hw point sits between left and right sw points */ 162fb4d8502Sjsg HW_POINT_POSITION_MIDDLE, 163fb4d8502Sjsg /* hw point lays left from left (smaller) sw point */ 164fb4d8502Sjsg HW_POINT_POSITION_LEFT, 165fb4d8502Sjsg /* hw point lays stays from right (bigger) sw point */ 166fb4d8502Sjsg HW_POINT_POSITION_RIGHT 167fb4d8502Sjsg }; 168fb4d8502Sjsg 169fb4d8502Sjsg struct gamma_point { 170fb4d8502Sjsg int32_t left_index; 171fb4d8502Sjsg int32_t right_index; 172fb4d8502Sjsg enum hw_point_position pos; 173fb4d8502Sjsg struct fixed31_32 coeff; 174fb4d8502Sjsg }; 175fb4d8502Sjsg 176fb4d8502Sjsg struct pixel_gamma_point { 177fb4d8502Sjsg struct gamma_point r; 178fb4d8502Sjsg struct gamma_point g; 179fb4d8502Sjsg struct gamma_point b; 180fb4d8502Sjsg }; 181fb4d8502Sjsg 182fb4d8502Sjsg struct gamma_coefficients { 183fb4d8502Sjsg struct fixed31_32 a0[3]; 184fb4d8502Sjsg struct fixed31_32 a1[3]; 185fb4d8502Sjsg struct fixed31_32 a2[3]; 186fb4d8502Sjsg struct fixed31_32 a3[3]; 187fb4d8502Sjsg struct fixed31_32 user_gamma[3]; 188fb4d8502Sjsg struct fixed31_32 user_contrast; 189fb4d8502Sjsg struct fixed31_32 user_brightness; 190fb4d8502Sjsg }; 191fb4d8502Sjsg 192fb4d8502Sjsg struct pwl_float_data { 193fb4d8502Sjsg struct fixed31_32 r; 194fb4d8502Sjsg struct fixed31_32 g; 195fb4d8502Sjsg struct fixed31_32 b; 196fb4d8502Sjsg }; 197fb4d8502Sjsg 198fb4d8502Sjsg struct mpc_tree_cfg { 199fb4d8502Sjsg int num_pipes; 200fb4d8502Sjsg int dpp[MAX_PIPES]; 201fb4d8502Sjsg int mpcc[MAX_PIPES]; 202fb4d8502Sjsg }; 203fb4d8502Sjsg 204fb4d8502Sjsg struct output_pixel_processor { 205fb4d8502Sjsg struct dc_context *ctx; 206fb4d8502Sjsg uint32_t inst; 207fb4d8502Sjsg struct pwl_params regamma_params; 208fb4d8502Sjsg struct mpc_tree mpc_tree_params; 209fb4d8502Sjsg bool mpcc_disconnect_pending[MAX_PIPES]; 210fb4d8502Sjsg const struct opp_funcs *funcs; 211c349dbc7Sjsg uint32_t dyn_expansion; 212fb4d8502Sjsg }; 213fb4d8502Sjsg 214fb4d8502Sjsg enum fmt_stereo_action { 215fb4d8502Sjsg FMT_STEREO_ACTION_ENABLE = 0, 216fb4d8502Sjsg FMT_STEREO_ACTION_DISABLE, 217fb4d8502Sjsg FMT_STEREO_ACTION_UPDATE_POLARITY 218fb4d8502Sjsg }; 219fb4d8502Sjsg 220fb4d8502Sjsg struct opp_grph_csc_adjustment { 221fb4d8502Sjsg //enum grph_color_adjust_option color_adjust_option; 222fb4d8502Sjsg enum dc_color_space c_space; 223fb4d8502Sjsg enum dc_color_depth color_depth; /* clean up to uint32_t */ 224fb4d8502Sjsg enum graphics_csc_adjust_type csc_adjust_type; 225fb4d8502Sjsg int32_t adjust_divider; 226fb4d8502Sjsg int32_t grph_cont; 227fb4d8502Sjsg int32_t grph_sat; 228fb4d8502Sjsg int32_t grph_bright; 229fb4d8502Sjsg int32_t grph_hue; 230fb4d8502Sjsg }; 231fb4d8502Sjsg 232fb4d8502Sjsg /* Underlay related types */ 233fb4d8502Sjsg 234fb4d8502Sjsg struct hw_adjustment_range { 235fb4d8502Sjsg int32_t hw_default; 236fb4d8502Sjsg int32_t min; 237fb4d8502Sjsg int32_t max; 238fb4d8502Sjsg int32_t step; 239fb4d8502Sjsg uint32_t divider; /* (actually HW range is min/divider; divider !=0) */ 240fb4d8502Sjsg }; 241fb4d8502Sjsg 242fb4d8502Sjsg enum ovl_csc_adjust_item { 243fb4d8502Sjsg OVERLAY_BRIGHTNESS = 0, 244fb4d8502Sjsg OVERLAY_GAMMA, 245fb4d8502Sjsg OVERLAY_CONTRAST, 246fb4d8502Sjsg OVERLAY_SATURATION, 247fb4d8502Sjsg OVERLAY_HUE, 248fb4d8502Sjsg OVERLAY_ALPHA, 249fb4d8502Sjsg OVERLAY_ALPHA_PER_PIX, 250fb4d8502Sjsg OVERLAY_COLOR_TEMPERATURE 251fb4d8502Sjsg }; 252fb4d8502Sjsg 253fb4d8502Sjsg enum oppbuf_display_segmentation { 254fb4d8502Sjsg OPPBUF_DISPLAY_SEGMENTATION_1_SEGMENT = 0, 255fb4d8502Sjsg OPPBUF_DISPLAY_SEGMENTATION_2_SEGMENT = 1, 256fb4d8502Sjsg OPPBUF_DISPLAY_SEGMENTATION_4_SEGMENT = 2, 257fb4d8502Sjsg OPPBUF_DISPLAY_SEGMENTATION_4_SEGMENT_SPLIT_LEFT = 3, 258fb4d8502Sjsg OPPBUF_DISPLAY_SEGMENTATION_4_SEGMENT_SPLIT_RIGHT = 4 259fb4d8502Sjsg }; 260fb4d8502Sjsg 261fb4d8502Sjsg struct oppbuf_params { 262fb4d8502Sjsg uint32_t active_width; 263fb4d8502Sjsg enum oppbuf_display_segmentation mso_segmentation; 264fb4d8502Sjsg uint32_t mso_overlap_pixel_num; 265fb4d8502Sjsg uint32_t pixel_repetition; 266c349dbc7Sjsg uint32_t num_segment_padded_pixels; 267fb4d8502Sjsg }; 268fb4d8502Sjsg 269fb4d8502Sjsg struct opp_funcs { 270fb4d8502Sjsg 271fb4d8502Sjsg 272fb4d8502Sjsg /* FORMATTER RELATED */ 273fb4d8502Sjsg 274fb4d8502Sjsg void (*opp_program_fmt)( 275fb4d8502Sjsg struct output_pixel_processor *opp, 276fb4d8502Sjsg struct bit_depth_reduction_params *fmt_bit_depth, 277fb4d8502Sjsg struct clamping_and_pixel_encoding_params *clamping); 278fb4d8502Sjsg 279fb4d8502Sjsg void (*opp_set_dyn_expansion)( 280fb4d8502Sjsg struct output_pixel_processor *opp, 281fb4d8502Sjsg enum dc_color_space color_sp, 282fb4d8502Sjsg enum dc_color_depth color_dpth, 283fb4d8502Sjsg enum amd_signal_type signal); 284fb4d8502Sjsg 285fb4d8502Sjsg void (*opp_program_bit_depth_reduction)( 286fb4d8502Sjsg struct output_pixel_processor *opp, 287fb4d8502Sjsg const struct bit_depth_reduction_params *params); 288fb4d8502Sjsg 289fb4d8502Sjsg /* underlay related */ 290fb4d8502Sjsg void (*opp_get_underlay_adjustment_range)( 291fb4d8502Sjsg struct output_pixel_processor *opp, 292fb4d8502Sjsg enum ovl_csc_adjust_item overlay_adjust_item, 293fb4d8502Sjsg struct hw_adjustment_range *range); 294fb4d8502Sjsg 295fb4d8502Sjsg void (*opp_destroy)(struct output_pixel_processor **opp); 296fb4d8502Sjsg 297fb4d8502Sjsg void (*opp_program_stereo)( 298fb4d8502Sjsg struct output_pixel_processor *opp, 299fb4d8502Sjsg bool enable, 300fb4d8502Sjsg const struct dc_crtc_timing *timing); 301fb4d8502Sjsg 302fb4d8502Sjsg void (*opp_pipe_clock_control)( 303fb4d8502Sjsg struct output_pixel_processor *opp, 304fb4d8502Sjsg bool enable); 305fb4d8502Sjsg 306c349dbc7Sjsg void (*opp_set_disp_pattern_generator)( 307c349dbc7Sjsg struct output_pixel_processor *opp, 308c349dbc7Sjsg enum controller_dp_test_pattern test_pattern, 309c349dbc7Sjsg enum controller_dp_color_space color_space, 310c349dbc7Sjsg enum dc_color_depth color_depth, 311c349dbc7Sjsg const struct tg_color *solid_color, 312c349dbc7Sjsg int width, 313c349dbc7Sjsg int height, 314c349dbc7Sjsg int offset); 315c349dbc7Sjsg 316*5ca02815Sjsg void (*opp_program_dpg_dimensions)( 317*5ca02815Sjsg struct output_pixel_processor *opp, 318*5ca02815Sjsg int width, 319*5ca02815Sjsg int height); 320*5ca02815Sjsg 321c349dbc7Sjsg bool (*dpg_is_blanked)( 322c349dbc7Sjsg struct output_pixel_processor *opp); 323c349dbc7Sjsg 324c349dbc7Sjsg void (*opp_dpg_set_blank_color)( 325c349dbc7Sjsg struct output_pixel_processor *opp, 326c349dbc7Sjsg const struct tg_color *color); 327c349dbc7Sjsg 328c349dbc7Sjsg void (*opp_program_left_edge_extra_pixel)( 329c349dbc7Sjsg struct output_pixel_processor *opp, 330c349dbc7Sjsg bool count); 331c349dbc7Sjsg 332fb4d8502Sjsg }; 333fb4d8502Sjsg 334fb4d8502Sjsg #endif 335