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