• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_COUNT,
40 };
41 
42 enum mpc_mux_topsel {
43     MPC_MUX_TOPSEL_DPP0    = 0,
44     MPC_MUX_TOPSEL_DISABLE = 0x0f,
45 };
46 
47 enum mpc_mux_botsel {
48     MPC_MUX_BOTSEL_MPCC0   = 0,
49     MPC_MUX_BOTSEL_DISABLE = 0x0f,
50 };
51 
52 enum mpc_mux_outmux {
53     MPC_MUX_OUTMUX_MPCC0   = 0,
54     MPC_MUX_OUTMUX_DISABLE = 0x0f,
55 };
56 
57 enum mpc_mux_oppid {
58     MPC_MUX_OPPID_OPP0    = 0,
59     MPC_MUX_OPPID_DISABLE = 0x0f,
60 };
61 
62 enum mpcc_blend_mode {
63     MPCC_BLEND_MODE_BYPASS,                // Direct digital bypass
64     MPCC_BLEND_MODE_TOP_LAYER_PASSTHROUGH, // Top layer pass-through
65     MPCC_BLEND_MODE_TOP_LAYER_ONLY,        // Top layer bleneded with background color
66     MPCC_BLEND_MODE_TOP_BOT_BLENDING       // Top and bottom blending
67 };
68 
69 enum mpcc_alpha_blend_mode {
70     MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA,
71     MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA_COMBINED_GLOBAL_GAIN,
72     MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA
73 };
74 
75 /*
76  * MPCC blending configuration
77  */
78 struct mpcc_blnd_cfg {
79     struct vpe_color           bg_color;             /* background color */
80     enum mpcc_alpha_blend_mode alpha_mode;           /* alpha blend mode */
81     bool                       pre_multiplied_alpha; /* alpha pre-multiplied mode flag */
82     uint8_t                    global_gain;
83     uint8_t                    global_alpha;
84     bool                       overlap_only;
85 
86     /* MPCC top/bottom gain settings */
87     int bottom_gain_mode;
88     int background_color_bpc;
89     int top_gain;
90     int bottom_inside_gain;
91     int bottom_outside_gain;
92 };
93 
94 enum mpc_output_csc_mode {
95     MPC_OUTPUT_CSC_DISABLE = 0,
96     MPC_OUTPUT_CSC_COEF_A,
97 };
98 
99 struct mpc_denorm_clamp {
100     int clamp_max_r_cr;
101     int clamp_min_r_cr;
102     int clamp_max_g_y;
103     int clamp_min_g_y;
104     int clamp_max_b_cb;
105     int clamp_min_b_cb;
106 };
107 
108 struct mpc_funcs {
109     // TODO finalize it
110     void (*program_mpcc_mux)(struct mpc *mpc, enum mpc_mpccid mpcc_idx, enum mpc_mux_topsel topsel,
111         enum mpc_mux_botsel botsel, enum mpc_mux_outmux outmux, enum mpc_mux_oppid oppid);
112 
113     void (*program_mpcc_blending)(
114         struct mpc *mpc, enum mpc_mpccid mpcc_idx, struct mpcc_blnd_cfg *blnd_cfg);
115 
116     void (*program_mpc_bypass_bg_color)(struct mpc *mpc, struct mpcc_blnd_cfg *blnd_cfg);
117 
118     void (*power_on_ogam_lut)(struct mpc *mpc, bool power_on);
119 
120     void (*set_output_csc)(
121         struct mpc *mpc, const uint16_t *regval, enum mpc_output_csc_mode ocsc_mode);
122 
123     void (*set_ocsc_default)(struct mpc *mpc, enum vpe_surface_pixel_format pixel_format,
124         enum color_space color_space, enum mpc_output_csc_mode ocsc_mode);
125 
126     void (*program_output_csc)(struct mpc *mpc, enum vpe_surface_pixel_format pixel_format,
127         enum color_space colorspace, uint16_t *matrix);
128 
129     void (*set_output_gamma)(struct mpc *mpc, const struct pwl_params *params);
130 
131     void (*set_gamut_remap)(struct mpc *mpc, struct colorspace_transform *gamut_remap);
132 
133     void (*power_on_1dlut_shaper_3dlut)(struct mpc *mpc, bool power_on);
134 
135     bool (*program_shaper)(struct mpc *mpc, const struct pwl_params *params);
136 
137     // using direct config to program the 3dlut specified in params
138     void (*program_3dlut)(struct mpc *mpc, const struct tetrahedral_params *params);
139 
140     // using indirect config to configure the 3DLut
141     bool (*program_3dlut_indirect)(struct mpc *mpc,
142         struct vpe_buf *lut0_3_buf, // 3d lut buf which contains the data for lut0-lut3
143         bool use_tetrahedral_9, bool use_12bits);
144 
145     // Blend-gamma control.
146     void (*program_1dlut)(struct mpc *mpc, const struct pwl_params *params, enum cm_type gamma_type);
147 
148     void (*program_cm_location)(struct mpc *mpc, uint8_t location);
149 
150     void (*set_denorm)(struct mpc *mpc, int opp_id, enum color_depth output_depth,
151         struct mpc_denorm_clamp *denorm_clamp);
152 
153     void (*set_out_float_en)(struct mpc *mpc, bool float_enable);
154 
155     void (*program_mpc_out)(struct mpc *mpc, enum vpe_surface_pixel_format format);
156 
157     void (*set_output_transfer_func)(struct mpc *mpc, struct output_ctx *output_ctx);
158 
159     void (*set_mpc_shaper_3dlut)(struct mpc *mpc, const struct transfer_func *func_shaper,
160         const struct vpe_3dlut *lut3d_func);
161 
162     void (*set_blend_lut)(struct mpc *mpc, const struct transfer_func *blend_tf);
163 
164     bool (*program_movable_cm)(struct mpc *mpc, const struct transfer_func *func_shaper,
165         const struct vpe_3dlut *lut3d_func, const struct transfer_func *blend_tf, bool afterblend);
166     void (*program_crc)(struct mpc *mpc, bool enable);
167 
168 };
169 
170 struct mpc {
171     struct vpe_priv  *vpe_priv;
172     struct mpc_funcs *funcs;
173     struct pwl_params regamma_params;
174     struct pwl_params blender_params;
175     struct pwl_params shaper_params;
176 };
177 
178 const uint16_t *vpe_find_color_matrix(
179     enum color_space color_space, enum vpe_surface_pixel_format pixel_format, uint32_t *array_size);
180 
181 #ifdef __cplusplus
182 }
183 #endif
184