1c349dbc7Sjsg /* Copyright 2012-17 Advanced Micro Devices, Inc. 2c349dbc7Sjsg * 3c349dbc7Sjsg * Permission is hereby granted, free of charge, to any person obtaining a 4c349dbc7Sjsg * copy of this software and associated documentation files (the "Software"), 5c349dbc7Sjsg * to deal in the Software without restriction, including without limitation 6c349dbc7Sjsg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 7c349dbc7Sjsg * and/or sell copies of the Software, and to permit persons to whom the 8c349dbc7Sjsg * Software is furnished to do so, subject to the following conditions: 9c349dbc7Sjsg * 10c349dbc7Sjsg * The above copyright notice and this permission notice shall be included in 11c349dbc7Sjsg * all copies or substantial portions of the Software. 12c349dbc7Sjsg * 13c349dbc7Sjsg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14c349dbc7Sjsg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15c349dbc7Sjsg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16c349dbc7Sjsg * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 17c349dbc7Sjsg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 18c349dbc7Sjsg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 19c349dbc7Sjsg * OTHER DEALINGS IN THE SOFTWARE. 20c349dbc7Sjsg * 21c349dbc7Sjsg * Authors: AMD 22c349dbc7Sjsg * 23c349dbc7Sjsg */ 24c349dbc7Sjsg 25c349dbc7Sjsg #ifndef __DC_DWBC_H__ 26c349dbc7Sjsg #define __DC_DWBC_H__ 27c349dbc7Sjsg 28c349dbc7Sjsg #include "dal_types.h" 29c349dbc7Sjsg #include "dc_hw_types.h" 30c349dbc7Sjsg 31c349dbc7Sjsg #define DWB_SW_V2 1 32c349dbc7Sjsg #define DWB_MCIF_BUF_COUNT 4 33c349dbc7Sjsg 34c349dbc7Sjsg /* forward declaration of mcif_wb struct */ 35c349dbc7Sjsg struct mcif_wb; 36c349dbc7Sjsg 37c349dbc7Sjsg 38c349dbc7Sjsg enum dwb_sw_version { 39c349dbc7Sjsg dwb_ver_1_0 = 1, 40c349dbc7Sjsg dwb_ver_2_0 = 2, 41c349dbc7Sjsg }; 42c349dbc7Sjsg 43c349dbc7Sjsg enum dwb_source { 44c349dbc7Sjsg dwb_src_scl = 0, /* for DCE7x/9x, DCN won't support. */ 45c349dbc7Sjsg dwb_src_blnd, /* for DCE7x/9x */ 46c349dbc7Sjsg dwb_src_fmt, /* for DCE7x/9x */ 47c349dbc7Sjsg dwb_src_otg0 = 0x100, /* for DCN1.x/DCN2.x, register: mmDWB_SOURCE_SELECT */ 48c349dbc7Sjsg dwb_src_otg1, /* for DCN1.x/DCN2.x */ 49c349dbc7Sjsg dwb_src_otg2, /* for DCN1.x/DCN2.x */ 50c349dbc7Sjsg dwb_src_otg3, /* for DCN1.x/DCN2.x */ 51c349dbc7Sjsg }; 52c349dbc7Sjsg 53c349dbc7Sjsg /* DCN1.x, DCN2.x support 2 pipes */ 54c349dbc7Sjsg enum dwb_pipe { 55c349dbc7Sjsg dwb_pipe0 = 0, 56c349dbc7Sjsg dwb_pipe1, 57c349dbc7Sjsg dwb_pipe_max_num, 58c349dbc7Sjsg }; 59c349dbc7Sjsg 60c349dbc7Sjsg enum dwb_frame_capture_enable { 61c349dbc7Sjsg DWB_FRAME_CAPTURE_DISABLE = 0, 62c349dbc7Sjsg DWB_FRAME_CAPTURE_ENABLE = 1, 63c349dbc7Sjsg }; 64c349dbc7Sjsg 65c349dbc7Sjsg enum wbscl_coef_filter_type_sel { 66c349dbc7Sjsg WBSCL_COEF_LUMA_VERT_FILTER = 0, 67c349dbc7Sjsg WBSCL_COEF_CHROMA_VERT_FILTER = 1, 68c349dbc7Sjsg WBSCL_COEF_LUMA_HORZ_FILTER = 2, 69c349dbc7Sjsg WBSCL_COEF_CHROMA_HORZ_FILTER = 3 70c349dbc7Sjsg }; 71c349dbc7Sjsg 72c349dbc7Sjsg 73ad8b1aafSjsg enum dwb_boundary_mode { 74ad8b1aafSjsg DWBSCL_BOUNDARY_MODE_EDGE = 0, 75ad8b1aafSjsg DWBSCL_BOUNDARY_MODE_BLACK = 1 76ad8b1aafSjsg }; 77ad8b1aafSjsg 78ad8b1aafSjsg enum dwb_output_csc_mode { 79ad8b1aafSjsg DWB_OUTPUT_CSC_DISABLE = 0, 80ad8b1aafSjsg DWB_OUTPUT_CSC_COEF_A = 1, 81ad8b1aafSjsg DWB_OUTPUT_CSC_COEF_B = 2 82ad8b1aafSjsg }; 83ad8b1aafSjsg 84ad8b1aafSjsg enum dwb_ogam_lut_mode { 85ad8b1aafSjsg DWB_OGAM_MODE_BYPASS, 86ad8b1aafSjsg DWB_OGAM_RAMA_LUT, 87ad8b1aafSjsg DWB_OGAM_RAMB_LUT 88ad8b1aafSjsg }; 89ad8b1aafSjsg 90ad8b1aafSjsg enum dwb_color_volume { 91ad8b1aafSjsg DWB_SRGB_BT709 = 0, //SDR 92ad8b1aafSjsg DWB_PQ = 1, //HDR 93ad8b1aafSjsg DWB_HLG = 2, //HDR 94ad8b1aafSjsg }; 95ad8b1aafSjsg 96ad8b1aafSjsg enum dwb_color_space { 97ad8b1aafSjsg DWB_SRGB = 0, //SDR 98ad8b1aafSjsg DWB_BT709 = 1, //SDR 99ad8b1aafSjsg DWB_BT2020 = 2, //HDR 100ad8b1aafSjsg }; 101ad8b1aafSjsg 102ad8b1aafSjsg struct dwb_efc_hdr_metadata { 103ad8b1aafSjsg /*display chromaticities and white point in units of 0.00001 */ 104ad8b1aafSjsg unsigned int chromaticity_green_x; 105ad8b1aafSjsg unsigned int chromaticity_green_y; 106ad8b1aafSjsg unsigned int chromaticity_blue_x; 107ad8b1aafSjsg unsigned int chromaticity_blue_y; 108ad8b1aafSjsg unsigned int chromaticity_red_x; 109ad8b1aafSjsg unsigned int chromaticity_red_y; 110ad8b1aafSjsg unsigned int chromaticity_white_point_x; 111ad8b1aafSjsg unsigned int chromaticity_white_point_y; 112ad8b1aafSjsg 113ad8b1aafSjsg /*in units of candelas per square meter */ 114ad8b1aafSjsg unsigned int min_luminance; 115ad8b1aafSjsg unsigned int max_luminance; 116ad8b1aafSjsg 117ad8b1aafSjsg /*in units of nits */ 118ad8b1aafSjsg unsigned int maximum_content_light_level; 119ad8b1aafSjsg unsigned int maximum_frame_average_light_level; 120ad8b1aafSjsg }; 121ad8b1aafSjsg 122ad8b1aafSjsg struct dwb_efc_display_settings { 123ad8b1aafSjsg unsigned int inputColorVolume; 124ad8b1aafSjsg unsigned int inputColorSpace; 125ad8b1aafSjsg unsigned int inputBitDepthMinus8; 126ad8b1aafSjsg struct dwb_efc_hdr_metadata hdr_metadata; 127ad8b1aafSjsg unsigned int dwbOutputBlack; // 0 - Normal, 1 - Output Black 128ad8b1aafSjsg }; 129ad8b1aafSjsg 130c349dbc7Sjsg struct dwb_warmup_params { 131c349dbc7Sjsg bool warmup_en; /* false: normal mode, true: enable pattern generator */ 132c349dbc7Sjsg bool warmup_mode; /* false: 420, true: 444 */ 133c349dbc7Sjsg bool warmup_depth; /* false: 8bit, true: 10bit */ 134c349dbc7Sjsg int warmup_data; /* Data to be sent by pattern generator (same for each pixel component) */ 135c349dbc7Sjsg int warmup_width; /* Pattern width (pixels) */ 136c349dbc7Sjsg int warmup_height; /* Pattern height (lines) */ 137c349dbc7Sjsg }; 138c349dbc7Sjsg 139c349dbc7Sjsg struct dwb_caps { 140c349dbc7Sjsg enum dce_version hw_version; /* DCN engine version. */ 141c349dbc7Sjsg enum dwb_sw_version sw_version; /* DWB sw implementation version. */ 142c349dbc7Sjsg unsigned int reserved[6]; /* Reserved for future use, MUST BE 0. */ 143c349dbc7Sjsg unsigned int adapter_id; 144c349dbc7Sjsg unsigned int num_pipes; /* number of DWB pipes */ 145c349dbc7Sjsg struct { 146c349dbc7Sjsg unsigned int support_dwb :1; 147c349dbc7Sjsg unsigned int support_ogam :1; 148c349dbc7Sjsg unsigned int support_wbscl :1; 149c349dbc7Sjsg unsigned int support_ocsc :1; 150c349dbc7Sjsg unsigned int support_stereo :1; 151c349dbc7Sjsg } caps; 152c349dbc7Sjsg unsigned int reserved2[9]; /* Reserved for future use, MUST BE 0. */ 153c349dbc7Sjsg }; 154c349dbc7Sjsg 155c349dbc7Sjsg struct dwbc { 156c349dbc7Sjsg const struct dwbc_funcs *funcs; 157c349dbc7Sjsg struct dc_context *ctx; 158c349dbc7Sjsg int inst; 159c349dbc7Sjsg struct mcif_wb *mcif; 160c349dbc7Sjsg bool status; 161c349dbc7Sjsg int inputSrcSelect; 162c349dbc7Sjsg bool dwb_output_black; 163c349dbc7Sjsg enum dc_transfer_func_predefined tf; 164c349dbc7Sjsg enum dc_color_space output_color_space; 165c349dbc7Sjsg bool dwb_is_efc_transition; 166c349dbc7Sjsg bool dwb_is_drc; 167c349dbc7Sjsg int wb_src_plane_inst;/*hubp, mpcc, inst*/ 168c349dbc7Sjsg uint32_t mask_id; 169c349dbc7Sjsg int otg_inst; 170c349dbc7Sjsg bool mvc_cfg; 171c349dbc7Sjsg }; 172c349dbc7Sjsg 173c349dbc7Sjsg struct dwbc_funcs { 174c349dbc7Sjsg bool (*get_caps)( 175c349dbc7Sjsg struct dwbc *dwbc, 176c349dbc7Sjsg struct dwb_caps *caps); 177c349dbc7Sjsg 178c349dbc7Sjsg bool (*enable)( 179c349dbc7Sjsg struct dwbc *dwbc, 180c349dbc7Sjsg struct dc_dwb_params *params); 181c349dbc7Sjsg 182c349dbc7Sjsg bool (*disable)(struct dwbc *dwbc); 183c349dbc7Sjsg 184c349dbc7Sjsg bool (*update)( 185c349dbc7Sjsg struct dwbc *dwbc, 186c349dbc7Sjsg struct dc_dwb_params *params); 187c349dbc7Sjsg 188c349dbc7Sjsg bool (*is_enabled)( 189c349dbc7Sjsg struct dwbc *dwbc); 190c349dbc7Sjsg 191c349dbc7Sjsg void (*set_stereo)( 192c349dbc7Sjsg struct dwbc *dwbc, 193c349dbc7Sjsg struct dwb_stereo_params *stereo_params); 194c349dbc7Sjsg 195c349dbc7Sjsg void (*set_new_content)( 196c349dbc7Sjsg struct dwbc *dwbc, 197c349dbc7Sjsg bool is_new_content); 198c349dbc7Sjsg 199c349dbc7Sjsg 200c349dbc7Sjsg void (*set_warmup)( 201c349dbc7Sjsg struct dwbc *dwbc, 202c349dbc7Sjsg struct dwb_warmup_params *warmup_params); 203c349dbc7Sjsg 204c349dbc7Sjsg 205*f005ef32Sjsg #if defined(CONFIG_DRM_AMD_DC_FP) 206ad8b1aafSjsg 207ad8b1aafSjsg void (*dwb_program_output_csc)( 208ad8b1aafSjsg struct dwbc *dwbc, 209ad8b1aafSjsg enum dc_color_space color_space, 210ad8b1aafSjsg enum dwb_output_csc_mode mode); 211ad8b1aafSjsg 212ad8b1aafSjsg bool (*dwb_ogam_set_output_transfer_func)( 213ad8b1aafSjsg struct dwbc *dwbc, 214ad8b1aafSjsg const struct dc_transfer_func *in_transfer_func_dwb_ogam); 215ad8b1aafSjsg 216ad8b1aafSjsg //TODO: merge with output_transfer_func? 217ad8b1aafSjsg bool (*dwb_ogam_set_input_transfer_func)( 218ad8b1aafSjsg struct dwbc *dwbc, 219ad8b1aafSjsg const struct dc_transfer_func *in_transfer_func_dwb_ogam); 220ad8b1aafSjsg #endif 221c349dbc7Sjsg bool (*get_dwb_status)( 222c349dbc7Sjsg struct dwbc *dwbc); 223c349dbc7Sjsg void (*dwb_set_scaler)( 224c349dbc7Sjsg struct dwbc *dwbc, 225c349dbc7Sjsg struct dc_dwb_params *params); 226c349dbc7Sjsg }; 227c349dbc7Sjsg 228c349dbc7Sjsg #endif 229