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 "fixed31_32.h" 28 29 #define MAX_3DLUT 1 30 31 #define MAX_INPUT_PIPE 1 32 #define MAX_OUTPUT_PIPE 1 33 34 #ifdef __cplusplus 35 extern "C" { 36 #endif 37 38 struct bias_and_scale { 39 uint32_t scale_red; 40 uint32_t bias_red; 41 uint32_t scale_green; 42 uint32_t bias_green; 43 uint32_t scale_blue; 44 uint32_t bias_blue; 45 }; 46 47 struct gamma_curve { 48 uint32_t offset; 49 uint32_t segments_num; 50 }; 51 52 struct curve_points { 53 struct fixed31_32 x; 54 struct fixed31_32 y; 55 struct fixed31_32 offset; 56 struct fixed31_32 slope; 57 58 uint32_t custom_float_x; 59 uint32_t custom_float_y; 60 uint32_t custom_float_offset; 61 uint32_t custom_float_slope; 62 }; 63 64 struct curve_points3 { 65 struct curve_points red; 66 struct curve_points green; 67 struct curve_points blue; 68 }; 69 70 struct pwl_result_data { 71 struct fixed31_32 red; 72 struct fixed31_32 green; 73 struct fixed31_32 blue; 74 75 struct fixed31_32 delta_red; 76 struct fixed31_32 delta_green; 77 struct fixed31_32 delta_blue; 78 79 uint32_t red_reg; 80 uint32_t green_reg; 81 uint32_t blue_reg; 82 83 uint32_t delta_red_reg; 84 uint32_t delta_green_reg; 85 uint32_t delta_blue_reg; 86 }; 87 88 /* arr_curve_points - regamma regions/segments specification 89 * arr_points - beginning and end point specified separately (only one on DCE) 90 * corner_points - beginning and end point for all 3 colors (DCN) 91 * rgb_resulted - final curve 92 */ 93 struct pwl_params { 94 struct gamma_curve arr_curve_points[34]; 95 union { 96 struct curve_points arr_points[2]; 97 struct curve_points3 corner_points[2]; 98 }; 99 struct pwl_result_data rgb_resulted[256 + 3]; 100 uint32_t hw_points_num; 101 }; 102 103 struct hw_x_point { 104 uint32_t custom_float_x; 105 struct fixed31_32 x; 106 struct fixed31_32 regamma_y_red; 107 struct fixed31_32 regamma_y_green; 108 struct fixed31_32 regamma_y_blue; 109 }; 110 111 struct gamma_coefficients { 112 struct fixed31_32 a0[3]; 113 struct fixed31_32 a1[3]; 114 struct fixed31_32 a2[3]; 115 struct fixed31_32 a3[3]; 116 struct fixed31_32 user_gamma[3]; 117 struct fixed31_32 user_contrast; 118 struct fixed31_32 user_brightness; 119 }; 120 121 struct pwl_float_data_ex { 122 struct fixed31_32 r; 123 struct fixed31_32 g; 124 struct fixed31_32 b; 125 struct fixed31_32 delta_r; 126 struct fixed31_32 delta_g; 127 struct fixed31_32 delta_b; 128 }; 129 130 enum hw_point_position { 131 /* hw point sits between left and right sw points */ 132 HW_POINT_POSITION_MIDDLE, 133 /* hw point lays left from left (smaller) sw point */ 134 HW_POINT_POSITION_LEFT, 135 /* hw point lays stays from right (bigger) sw point */ 136 HW_POINT_POSITION_RIGHT 137 }; 138 139 struct gamma_point { 140 int32_t left_index; 141 int32_t right_index; 142 enum hw_point_position pos; 143 struct fixed31_32 coeff; 144 }; 145 146 struct pixel_gamma_point { 147 struct gamma_point r; 148 struct gamma_point g; 149 struct gamma_point b; 150 }; 151 152 enum gamut_remap_select { 153 GAMUT_REMAP_BYPASS = 0, 154 GAMUT_REMAP_COMA_COEFF, 155 }; 156 157 enum lut_dimension { 158 LUT_DIM_INVALID = 0, 159 LUT_DIM_9 = 9, 160 LUT_DIM_17 = 17, 161 }; 162 163 struct vpe_rgb { 164 uint32_t red; 165 uint32_t green; 166 uint32_t blue; 167 }; 168 169 struct tetrahedral_17x17x17 { 170 struct vpe_rgb lut0[1229]; 171 struct vpe_rgb lut1[1228]; 172 struct vpe_rgb lut2[1228]; 173 struct vpe_rgb lut3[1228]; 174 }; 175 struct tetrahedral_9x9x9 { 176 struct vpe_rgb lut0[183]; 177 struct vpe_rgb lut1[182]; 178 struct vpe_rgb lut2[182]; 179 struct vpe_rgb lut3[182]; 180 }; 181 182 struct tetrahedral_params { 183 union { 184 struct tetrahedral_17x17x17 tetrahedral_17; 185 struct tetrahedral_9x9x9 tetrahedral_9; 186 }; 187 enum lut_dimension lut_dim; 188 bool use_12bits; 189 }; 190 191 enum vpe_lut_mode { 192 LUT_BYPASS, 193 LUT_RAM_A, 194 LUT_RAM_B 195 }; 196 197 #ifdef __cplusplus 198 } 199 #endif 200