1 /* Copyright 2012-15 Advanced Micro Devices, Inc.
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:
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
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.
28 #include "dc_hw_types.h"
29 #include "hw_shared.h"
30 #include "transform.h"
37 enum mpc_output_csc_mode {
38 MPC_OUTPUT_CSC_DISABLE = 0,
39 MPC_OUTPUT_CSC_COEF_A,
44 enum mpcc_blend_mode {
45 MPCC_BLEND_MODE_BYPASS,
46 MPCC_BLEND_MODE_TOP_LAYER_PASSTHROUGH,
47 MPCC_BLEND_MODE_TOP_LAYER_ONLY,
48 MPCC_BLEND_MODE_TOP_BOT_BLENDING
51 enum mpcc_alpha_blend_mode {
52 MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA,
53 MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA_COMBINED_GLOBAL_GAIN,
54 MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA
58 * MPCC blending configuration
60 struct mpcc_blnd_cfg {
61 struct tg_color black_color; /* background color */
62 enum mpcc_alpha_blend_mode alpha_mode; /* alpha blend mode */
63 bool pre_multiplied_alpha; /* alpha pre-multiplied mode flag */
68 /* MPCC top/bottom gain settings */
70 int background_color_bpc;
72 int bottom_inside_gain;
73 int bottom_outside_gain;
76 struct mpc_grph_gamut_adjustment {
77 struct fixed31_32 temperature_matrix[CSC_TEMPERATURE_MATRIX_SIZE];
78 enum graphics_gamut_adjust_type gamut_adjust_type;
83 /* 0-single plane,2-row subsampling,4-column subsampling,6-checkboard subsampling */
85 /* 0- disable frame alternate, 1- enable frame alternate */
87 /* 0- disable field alternate, 1- enable field alternate */
89 /* 0-no force,2-force frame polarity from top,3-force frame polarity from bottom */
90 int force_next_frame_porlarity;
91 /* 0-no force,2-force field polarity from top,3-force field polarity from bottom */
92 int force_next_field_polarity;
95 struct mpc_denorm_clamp {
104 struct mpc_dwb_flow_control {
111 * MPCC connection and blending configuration for a single MPCC instance.
112 * This struct is used as a node in an MPC tree.
115 int mpcc_id; /* MPCC physical instance */
116 int dpp_id; /* DPP input to this MPCC */
117 struct mpcc *mpcc_bot; /* pointer to bottom layer MPCC. NULL when not connected */
118 struct mpcc_blnd_cfg blnd_cfg; /* The blending configuration for this MPCC */
119 struct mpcc_sm_cfg sm_cfg; /* stereo mix setting for this MPCC */
120 bool shared_bottom; /* TRUE if MPCC output to both OPP and DWB endpoints, else FALSE */
124 * MPC tree represents all MPCC connections for a pipe.
127 int opp_id; /* The OPP instance that owns this MPC tree */
128 struct mpcc *opp_list; /* The top MPCC layer of the MPC tree that outputs to OPP endpoint */
132 const struct mpc_funcs *funcs;
133 struct dc_context *ctx;
135 struct mpcc mpcc_array[MAX_MPCC];
136 struct pwl_params blender_params;
143 uint32_t bot_mpcc_id;
146 uint32_t pre_multiplied_alpha;
147 uint32_t overlap_only;
153 void (*read_mpcc_state)(
156 struct mpcc_state *s);
159 * Insert DPP into MPC tree based on specified blending position.
160 * Only used for planes that are part of blending chain for OPP output
163 * [in/out] mpc - MPC context.
164 * [in/out] tree - MPC tree structure that plane will be added to.
165 * [in] blnd_cfg - MPCC blending configuration for the new blending layer.
166 * [in] sm_cfg - MPCC stereo mix configuration for the new blending layer.
167 * stereo mix must disable for the very bottom layer of the tree config.
168 * [in] insert_above_mpcc - Insert new plane above this MPCC. If NULL, insert as bottom plane.
169 * [in] dpp_id - DPP instance for the plane to be added.
170 * [in] mpcc_id - The MPCC physical instance to use for blending.
172 * Return: struct mpcc* - MPCC that was added.
174 struct mpcc* (*insert_plane)(
176 struct mpc_tree *tree,
177 struct mpcc_blnd_cfg *blnd_cfg,
178 struct mpcc_sm_cfg *sm_cfg,
179 struct mpcc *insert_above_mpcc,
184 * Remove a specified MPCC from the MPC tree.
187 * [in/out] mpc - MPC context.
188 * [in/out] tree - MPC tree structure that plane will be removed from.
189 * [in/out] mpcc - MPCC to be removed from tree.
195 struct mpc_tree *tree,
199 * Reset the MPCC HW status by disconnecting all muxes.
202 * [in/out] mpc - MPC context.
206 void (*mpc_init)(struct mpc *mpc);
207 void (*mpc_init_single_inst)(
209 unsigned int mpcc_id);
212 * Update the blending configuration for a specified MPCC.
215 * [in/out] mpc - MPC context.
216 * [in] blnd_cfg - MPCC blending configuration.
217 * [in] mpcc_id - The MPCC physical instance.
221 void (*update_blending)(
223 struct mpcc_blnd_cfg *blnd_cfg,
227 * Lock cursor updates for the specified OPP.
228 * OPP defines the set of MPCC that are locked together for cursor.
231 * [in] mpc - MPC context.
232 * [in] opp_id - The OPP to lock cursor updates on
233 * [in] lock - lock/unlock the OPP
243 * Add DPP into 'secondary' MPC tree based on specified blending position.
244 * Only used for planes that are part of blending chain for DWB output
247 * [in/out] mpc - MPC context.
248 * [in/out] tree - MPC tree structure that plane will be added to.
249 * [in] blnd_cfg - MPCC blending configuration for the new blending layer.
250 * [in] sm_cfg - MPCC stereo mix configuration for the new blending layer.
251 * stereo mix must disable for the very bottom layer of the tree config.
252 * [in] insert_above_mpcc - Insert new plane above this MPCC. If NULL, insert as bottom plane.
253 * [in] dpp_id - DPP instance for the plane to be added.
254 * [in] mpcc_id - The MPCC physical instance to use for blending.
256 * Return: struct mpcc* - MPCC that was added.
258 struct mpcc* (*insert_plane_to_secondary)(
260 struct mpc_tree *tree,
261 struct mpcc_blnd_cfg *blnd_cfg,
262 struct mpcc_sm_cfg *sm_cfg,
263 struct mpcc *insert_above_mpcc,
268 * Remove a specified DPP from the 'secondary' MPC tree.
271 * [in/out] mpc - MPC context.
272 * [in/out] tree - MPC tree structure that plane will be removed from.
273 * [in] mpcc - MPCC to be removed from tree.
276 void (*remove_mpcc_from_secondary)(
278 struct mpc_tree *tree,
281 struct mpcc* (*get_mpcc_for_dpp_from_secondary)(
282 struct mpc_tree *tree,
284 struct mpcc* (*get_mpcc_for_dpp)(
285 struct mpc_tree *tree,
288 void (*wait_for_idle)(struct mpc *mpc, int id);
290 void (*assert_mpcc_idle_before_connect)(struct mpc *mpc, int mpcc_id);
292 void (*init_mpcc_list_from_hw)(
294 struct mpc_tree *tree);
296 void (*set_denorm)(struct mpc *mpc,
298 enum dc_color_depth output_depth);
300 void (*set_denorm_clamp)(
303 struct mpc_denorm_clamp denorm_clamp);
305 void (*set_output_csc)(struct mpc *mpc,
307 const uint16_t *regval,
308 enum mpc_output_csc_mode ocsc_mode);
310 void (*set_ocsc_default)(struct mpc *mpc,
312 enum dc_color_space color_space,
313 enum mpc_output_csc_mode ocsc_mode);
315 void (*set_output_gamma)(
318 const struct pwl_params *params);
319 void (*power_on_mpc_mem_pwr)(
328 void (*disable_dwb_mux)(
336 void (*set_out_rate_control)(
341 struct mpc_dwb_flow_control *flow_control);
343 void (*set_gamut_remap)(
346 const struct mpc_grph_gamut_adjustment *adjust);
348 bool (*program_shaper)(
350 const struct pwl_params *params,
353 uint32_t (*acquire_rmu)(struct mpc *mpc, int mpcc_id, int rmu_idx);
355 bool (*program_3dlut)(
357 const struct tetrahedral_params *params,
360 int (*release_rmu)(struct mpc *mpc, int mpcc_id);