xref: /aosp_15_r20/external/mesa3d/src/amd/vpelib/src/core/inc/opp.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 #include "vpe_types.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 struct opp;
33 struct vpe_priv;
34 
35 enum clamping_range {
36     CLAMPING_FULL_RANGE = 0,      /* No Clamping */
37     CLAMPING_LIMITED_RANGE_8BPC,  /* 8  bpc: Clamping 1  to FE */
38     CLAMPING_LIMITED_RANGE_10BPC, /* 10 bpc: Clamping 4  to 3FB */
39     CLAMPING_LIMITED_RANGE_12BPC, /* 12 bpc: Clamping 10 to FEF */
40     /* Use programmable clampping value on FMT_CLAMP_COMPONENT_R/G/B. */
41     CLAMPING_LIMITED_RANGE_PROGRAMMABLE
42 };
43 
44 struct clamping_and_pixel_encoding_params {
45     // enum vpe_pixel_encoding pixel_encoding; /* Pixel Encoding, not used and not initialized yet
46     // */
47     enum clamping_range clamping_level; /* Clamping identifier */
48     enum color_depth    c_depth;        /* Deep color use. */
49     uint32_t            r_clamp_component_upper;
50     uint32_t            b_clamp_component_upper;
51     uint32_t            g_clamp_component_upper;
52     uint32_t            r_clamp_component_lower;
53     uint32_t            b_clamp_component_lower;
54     uint32_t            g_clamp_component_lower;
55 };
56 
57 struct bit_depth_reduction_params {
58     struct {
59         /* truncate/round */
60         /* trunc/round enabled*/
61         uint32_t TRUNCATE_ENABLED : 1;
62         /* 2 bits: 0=6 bpc, 1=8 bpc, 2 = 10bpc*/
63         uint32_t TRUNCATE_DEPTH : 2;
64         /* truncate or round*/
65         uint32_t TRUNCATE_MODE : 1;
66 
67         /* spatial dither */
68         /* Spatial Bit Depth Reduction enabled*/
69         uint32_t SPATIAL_DITHER_ENABLED : 1;
70         /* 2 bits: 0=6 bpc, 1 = 8 bpc, 2 = 10bpc*/
71         uint32_t SPATIAL_DITHER_DEPTH : 2;
72         /* 0-3 to select patterns*/
73         uint32_t SPATIAL_DITHER_MODE : 2;
74         /* Enable RGB random dithering*/
75         uint32_t RGB_RANDOM : 1;
76         /* Enable Frame random dithering*/
77         uint32_t FRAME_RANDOM : 1;
78         /* Enable HighPass random dithering*/
79         uint32_t HIGHPASS_RANDOM : 1;
80 
81         /* temporal dither*/
82         /* frame modulation enabled*/
83         uint32_t FRAME_MODULATION_ENABLED : 1;
84         /* same as for trunc/spatial*/
85         uint32_t FRAME_MODULATION_DEPTH : 2;
86         /* 2/4 gray levels*/
87         uint32_t TEMPORAL_LEVEL : 1;
88         uint32_t FRC25          : 2;
89         uint32_t FRC50          : 2;
90         uint32_t FRC75          : 2;
91     } flags;
92 
93     uint32_t r_seed_value;
94     uint32_t b_seed_value;
95     uint32_t g_seed_value;
96     //   enum vpe_pixel_encoding pixel_encoding;  // not used and not initialized yet
97 };
98 
99 struct opp_funcs {
100 
101     void (*set_clamping)(struct opp *opp, const struct clamping_and_pixel_encoding_params *params);
102 
103     void (*set_dyn_expansion)(struct opp *opp, bool enable, enum color_depth color_dpth);
104 
105     void (*set_truncation)(struct opp *opp, const struct bit_depth_reduction_params *params);
106 
107     void (*set_spatial_dither)(struct opp *opp, const struct bit_depth_reduction_params *params);
108 
109     void (*program_bit_depth_reduction)(
110         struct opp *opp, const struct bit_depth_reduction_params *params);
111 
112     void (*program_fmt)(struct opp *opp, struct bit_depth_reduction_params *fmt_bit_depth,
113         struct clamping_and_pixel_encoding_params *clamping);
114 
115     void (*program_pipe_alpha)(struct opp *opp, uint16_t alpha);
116 
117     void (*program_pipe_bypass)(struct opp *opp, bool enable);
118     void (*program_pipe_crc)(struct opp *opp, bool enable);
119 };
120 
121 struct opp {
122     struct vpe_priv  *vpe_priv;
123     struct opp_funcs *funcs;
124 };
125 
126 #ifdef __cplusplus
127 }
128 #endif
129