1 /* Copyright 2022 Advanced Micro Devices, Inc. 2 * 3 * Permission is hereby granted, free of charge, to any person obtaining a 4 * copy of this software and associated documentation files (the "Software"), 5 * to deal in the Software without restriction, including without limitation 6 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 * and/or sell copies of the Software, and to permit persons to whom the 8 * Software is furnished to do so, subject to the following conditions: 9 * 10 * The above copyright notice and this permission notice shall be included in 11 * all copies or substantial portions of the Software. 12 * 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 17 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 18 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 19 * OTHER DEALINGS IN THE SOFTWARE. 20 * 21 * Authors: AMD 22 * 23 */ 24 25 #pragma once 26 27 #include "vpe_types.h" 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 struct mpc; 34 struct vpe_priv; 35 struct output_ctx; 36 37 enum mpc_mpccid { 38 MPC_MPCCID_0 = 0, 39 MPC_MPCCID_1 = 1, 40 MPC_MPCCID_COUNT, 41 }; 42 43 enum mpc_mux_topsel { 44 MPC_MUX_TOPSEL_DPP0 = 0, 45 MPC_MUX_TOPSEL_DISABLE = 0x0f, 46 }; 47 48 enum mpc_mux_botsel { 49 MPC_MUX_BOTSEL_MPCC0 = 0, 50 MPC_MUX_BOTSEL_DISABLE = 0x0f, 51 }; 52 53 enum mpc_mux_outmux { 54 MPC_MUX_OUTMUX_MPCC0 = 0, 55 MPC_MUX_OUTMUX_DISABLE = 0x0f, 56 }; 57 58 enum mpc_mux_oppid { 59 MPC_MUX_OPPID_OPP0 = 0, 60 MPC_MUX_OPPID_DISABLE = 0x0f, 61 }; 62 63 enum mpcc_blend_mode { 64 MPCC_BLEND_MODE_BYPASS, // Direct digital bypass 65 MPCC_BLEND_MODE_TOP_LAYER_PASSTHROUGH, // Top layer pass-through 66 MPCC_BLEND_MODE_TOP_LAYER_ONLY, // Top layer bleneded with background color 67 MPCC_BLEND_MODE_TOP_BOT_BLENDING // Top and bottom blending 68 }; 69 70 enum mpcc_alpha_blend_mode { 71 MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA, 72 MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA_COMBINED_GLOBAL_GAIN, 73 MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA 74 }; 75 76 /* 77 * MPCC blending configuration 78 */ 79 struct mpcc_blnd_cfg { 80 struct vpe_color bg_color; /* background color */ 81 enum mpcc_alpha_blend_mode alpha_mode; /* alpha blend mode */ 82 bool pre_multiplied_alpha; /* alpha pre-multiplied mode flag */ 83 uint8_t global_gain; 84 uint8_t global_alpha; 85 bool overlap_only; 86 87 /* MPCC top/bottom gain settings */ 88 int bottom_gain_mode; 89 int background_color_bpc; 90 int top_gain; 91 int bottom_inside_gain; 92 int bottom_outside_gain; 93 }; 94 95 enum mpc_output_csc_mode { 96 MPC_OUTPUT_CSC_DISABLE = 0, 97 MPC_OUTPUT_CSC_COEF_A, 98 }; 99 100 struct mpc_denorm_clamp { 101 int clamp_max_r_cr; 102 int clamp_min_r_cr; 103 int clamp_max_g_y; 104 int clamp_min_g_y; 105 int clamp_max_b_cb; 106 int clamp_min_b_cb; 107 }; 108 109 struct mpc_funcs { 110 // TODO finalize it 111 void (*program_mpcc_mux)(struct mpc *mpc, enum mpc_mpccid mpcc_idx, enum mpc_mux_topsel topsel, 112 enum mpc_mux_botsel botsel, enum mpc_mux_outmux outmux, enum mpc_mux_oppid oppid); 113 114 void (*program_mpcc_blending)( 115 struct mpc *mpc, enum mpc_mpccid mpcc_idx, struct mpcc_blnd_cfg *blnd_cfg); 116 117 void (*program_mpc_bypass_bg_color)(struct mpc *mpc, struct mpcc_blnd_cfg *blnd_cfg); 118 119 void (*power_on_ogam_lut)(struct mpc *mpc, bool power_on); 120 121 void (*set_output_csc)( 122 struct mpc *mpc, const uint16_t *regval, enum mpc_output_csc_mode ocsc_mode); 123 124 void (*set_ocsc_default)(struct mpc *mpc, enum vpe_surface_pixel_format pixel_format, 125 enum color_space color_space, enum mpc_output_csc_mode ocsc_mode); 126 127 void (*program_output_csc)(struct mpc *mpc, enum vpe_surface_pixel_format pixel_format, 128 enum color_space colorspace, uint16_t *matrix); 129 130 void (*set_output_gamma)(struct mpc *mpc, const struct pwl_params *params); 131 132 void (*set_gamut_remap)(struct mpc *mpc, struct colorspace_transform *gamut_remap); 133 134 void (*power_on_1dlut_shaper_3dlut)(struct mpc *mpc, bool power_on); 135 136 bool (*program_shaper)(struct mpc *mpc, const struct pwl_params *params); 137 138 // using direct config to program the 3dlut specified in params 139 void (*program_3dlut)(struct mpc *mpc, const struct tetrahedral_params *params); 140 141 // using indirect config to configure the 3DLut 142 bool (*program_3dlut_indirect)(struct mpc *mpc, 143 struct vpe_buf *lut0_3_buf, // 3d lut buf which contains the data for lut0-lut3 144 bool use_tetrahedral_9, bool use_12bits); 145 146 // Blend-gamma control. 147 void (*program_1dlut)(struct mpc *mpc, const struct pwl_params *params, enum cm_type gamma_type); 148 149 void (*program_cm_location)(struct mpc *mpc, uint8_t location); 150 151 void (*set_denorm)(struct mpc *mpc, int opp_id, enum color_depth output_depth, 152 struct mpc_denorm_clamp *denorm_clamp); 153 154 void (*set_out_float_en)(struct mpc *mpc, bool float_enable); 155 156 void (*program_mpc_out)(struct mpc *mpc, enum vpe_surface_pixel_format format); 157 158 void (*set_output_transfer_func)(struct mpc *mpc, struct output_ctx *output_ctx); 159 160 void (*set_mpc_shaper_3dlut)(struct mpc *mpc, const struct transfer_func *func_shaper, 161 const struct vpe_3dlut *lut3d_func); 162 163 void (*set_blend_lut)(struct mpc *mpc, const struct transfer_func *blend_tf); 164 165 bool (*program_movable_cm)(struct mpc *mpc, const struct transfer_func *func_shaper, 166 const struct vpe_3dlut *lut3d_func, const struct transfer_func *blend_tf, bool afterblend); 167 void (*program_crc)(struct mpc *mpc, bool enable); 168 169 }; 170 171 struct mpc { 172 struct vpe_priv *vpe_priv; 173 struct mpc_funcs *funcs; 174 struct pwl_params regamma_params; 175 struct pwl_params blender_params; 176 struct pwl_params shaper_params; 177 }; 178 179 const uint16_t *vpe_find_color_matrix( 180 enum color_space color_space, enum vpe_surface_pixel_format pixel_format, uint32_t *array_size); 181 182 #ifdef __cplusplus 183 } 184 #endif 185