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 * Multiple Pipe/Plane Combined (MPC) is a component in the hardware pipeline
29 * that performs blending of multiple planes, using global and per-pixel alpha.
30 * It also performs post-blending color correction operations according to the
31 * hardware capabilities, such as color transformation matrix and gamma 1D and
38 #include "dc_hw_types.h"
39 #include "hw_shared.h"
40 #include "transform.h"
47 enum mpc_output_csc_mode {
48 MPC_OUTPUT_CSC_DISABLE = 0,
49 MPC_OUTPUT_CSC_COEF_A,
54 enum mpcc_blend_mode {
55 MPCC_BLEND_MODE_BYPASS,
56 MPCC_BLEND_MODE_TOP_LAYER_PASSTHROUGH,
57 MPCC_BLEND_MODE_TOP_LAYER_ONLY,
58 MPCC_BLEND_MODE_TOP_BOT_BLENDING
62 * enum mpcc_alpha_blend_mode - define the alpha blend mode regarding pixel
63 * alpha and plane alpha values
65 enum mpcc_alpha_blend_mode {
67 * @MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA: per pixel alpha using DPP
70 MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA,
72 * @MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA_COMBINED_GLOBAL_GAIN: per
73 * pixel alpha using DPP alpha value multiplied by a global gain (plane
76 MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA_COMBINED_GLOBAL_GAIN,
78 * @MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA: global alpha value, ignores
79 * pixel alpha and consider only plane alpha
81 MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA
85 * struct mpcc_blnd_cfg - MPCC blending configuration
87 * @black_color: background color
88 * @alpha_mode: alpha blend mode (MPCC_ALPHA_BLND_MODE)
89 * @pre_multiplied_alpha: whether pixel color values were pre-multiplied by the
90 * alpha channel (MPCC_ALPHA_MULTIPLIED_MODE)
91 * @global_gain: used when blend mode considers both pixel alpha and plane
92 * alpha value and assumes the global alpha value.
93 * @global_alpha: plane alpha value
95 struct mpcc_blnd_cfg {
96 struct tg_color black_color; /* background color */
97 enum mpcc_alpha_blend_mode alpha_mode; /* alpha blend mode */
98 bool pre_multiplied_alpha; /* alpha pre-multiplied mode flag */
103 /* MPCC top/bottom gain settings */
104 int bottom_gain_mode;
105 int background_color_bpc;
107 int bottom_inside_gain;
108 int bottom_outside_gain;
111 struct mpc_grph_gamut_adjustment {
112 struct fixed31_32 temperature_matrix[CSC_TEMPERATURE_MATRIX_SIZE];
113 enum graphics_gamut_adjust_type gamut_adjust_type;
118 /* 0-single plane,2-row subsampling,4-column subsampling,6-checkboard subsampling */
120 /* 0- disable frame alternate, 1- enable frame alternate */
122 /* 0- disable field alternate, 1- enable field alternate */
124 /* 0-no force,2-force frame polarity from top,3-force frame polarity from bottom */
125 int force_next_frame_porlarity;
126 /* 0-no force,2-force field polarity from top,3-force field polarity from bottom */
127 int force_next_field_polarity;
130 struct mpc_denorm_clamp {
139 struct mpc_dwb_flow_control {
146 * struct mpcc - MPCC connection and blending configuration for a single MPCC instance.
147 * @mpcc_id: MPCC physical instance
148 * @dpp_id: DPP input to this MPCC
149 * @mpcc_bot: pointer to bottom layer MPCC. NULL when not connected.
150 * @blnd_cfg: the blending configuration for this MPCC
151 * @sm_cfg: stereo mix setting for this MPCC
152 * @shared_bottom: if MPCC output to both OPP and DWB endpoints, true. Otherwise, false.
154 * This struct is used as a node in an MPC tree.
157 int mpcc_id; /* MPCC physical instance */
158 int dpp_id; /* DPP input to this MPCC */
159 struct mpcc *mpcc_bot; /* pointer to bottom layer MPCC. NULL when not connected */
160 struct mpcc_blnd_cfg blnd_cfg; /* The blending configuration for this MPCC */
161 struct mpcc_sm_cfg sm_cfg; /* stereo mix setting for this MPCC */
162 bool shared_bottom; /* TRUE if MPCC output to both OPP and DWB endpoints, else FALSE */
166 * struct mpc_tree - MPC tree represents all MPCC connections for a pipe.
168 * @opp_id: the OPP instance that owns this MPC tree
169 * @opp_list: the top MPCC layer of the MPC tree that outputs to OPP endpoint
173 int opp_id; /* The OPP instance that owns this MPC tree */
174 struct mpcc *opp_list; /* The top MPCC layer of the MPC tree that outputs to OPP endpoint */
178 const struct mpc_funcs *funcs;
179 struct dc_context *ctx;
181 struct mpcc mpcc_array[MAX_MPCC];
182 struct pwl_params blender_params;
189 uint32_t bot_mpcc_id;
192 uint32_t pre_multiplied_alpha;
193 uint32_t overlap_only;
199 * struct mpc_funcs - funcs
202 void (*read_mpcc_state)(
205 struct mpcc_state *s);
210 * Insert DPP into MPC tree based on specified blending position.
211 * Only used for planes that are part of blending chain for OPP output
214 * [in/out] mpc - MPC context.
215 * [in/out] tree - MPC tree structure that plane will be added to.
216 * [in] blnd_cfg - MPCC blending configuration for the new blending layer.
217 * [in] sm_cfg - MPCC stereo mix configuration for the new blending layer.
218 * stereo mix must disable for the very bottom layer of the tree config.
219 * [in] insert_above_mpcc - Insert new plane above this MPCC. If NULL, insert as bottom plane.
220 * [in] dpp_id - DPP instance for the plane to be added.
221 * [in] mpcc_id - The MPCC physical instance to use for blending.
223 * Return: struct mpcc* - MPCC that was added.
225 struct mpcc* (*insert_plane)(
227 struct mpc_tree *tree,
228 struct mpcc_blnd_cfg *blnd_cfg,
229 struct mpcc_sm_cfg *sm_cfg,
230 struct mpcc *insert_above_mpcc,
237 * Remove a specified MPCC from the MPC tree.
240 * [in/out] mpc - MPC context.
241 * [in/out] tree - MPC tree structure that plane will be removed from.
242 * [in/out] mpcc - MPCC to be removed from tree.
248 struct mpc_tree *tree,
254 * Reset the MPCC HW status by disconnecting all muxes.
257 * [in/out] mpc - MPC context.
261 void (*mpc_init)(struct mpc *mpc);
262 void (*mpc_init_single_inst)(
264 unsigned int mpcc_id);
269 * Update the blending configuration for a specified MPCC.
272 * [in/out] mpc - MPC context.
273 * [in] blnd_cfg - MPCC blending configuration.
274 * [in] mpcc_id - The MPCC physical instance.
278 void (*update_blending)(
280 struct mpcc_blnd_cfg *blnd_cfg,
286 * Lock cursor updates for the specified OPP.
287 * OPP defines the set of MPCC that are locked together for cursor.
290 * [in] mpc - MPC context.
291 * [in] opp_id - The OPP to lock cursor updates on
292 * [in] lock - lock/unlock the OPP
302 * @insert_plane_to_secondary:
304 * Add DPP into secondary MPC tree based on specified blending position.
305 * Only used for planes that are part of blending chain for DWB output
308 * [in/out] mpc - MPC context.
309 * [in/out] tree - MPC tree structure that plane will be added to.
310 * [in] blnd_cfg - MPCC blending configuration for the new blending layer.
311 * [in] sm_cfg - MPCC stereo mix configuration for the new blending layer.
312 * stereo mix must disable for the very bottom layer of the tree config.
313 * [in] insert_above_mpcc - Insert new plane above this MPCC. If NULL, insert as bottom plane.
314 * [in] dpp_id - DPP instance for the plane to be added.
315 * [in] mpcc_id - The MPCC physical instance to use for blending.
317 * Return: struct mpcc* - MPCC that was added.
319 struct mpcc* (*insert_plane_to_secondary)(
321 struct mpc_tree *tree,
322 struct mpcc_blnd_cfg *blnd_cfg,
323 struct mpcc_sm_cfg *sm_cfg,
324 struct mpcc *insert_above_mpcc,
329 * @remove_mpcc_from_secondary:
331 * Remove a specified DPP from the 'secondary' MPC tree.
334 * [in/out] mpc - MPC context.
335 * [in/out] tree - MPC tree structure that plane will be removed from.
336 * [in] mpcc - MPCC to be removed from tree.
339 void (*remove_mpcc_from_secondary)(
341 struct mpc_tree *tree,
344 struct mpcc* (*get_mpcc_for_dpp_from_secondary)(
345 struct mpc_tree *tree,
348 struct mpcc* (*get_mpcc_for_dpp)(
349 struct mpc_tree *tree,
352 void (*wait_for_idle)(struct mpc *mpc, int id);
354 void (*assert_mpcc_idle_before_connect)(struct mpc *mpc, int mpcc_id);
356 void (*init_mpcc_list_from_hw)(
358 struct mpc_tree *tree);
360 void (*set_denorm)(struct mpc *mpc,
362 enum dc_color_depth output_depth);
364 void (*set_denorm_clamp)(
367 struct mpc_denorm_clamp denorm_clamp);
369 void (*set_output_csc)(struct mpc *mpc,
371 const uint16_t *regval,
372 enum mpc_output_csc_mode ocsc_mode);
374 void (*set_ocsc_default)(struct mpc *mpc,
376 enum dc_color_space color_space,
377 enum mpc_output_csc_mode ocsc_mode);
379 void (*set_output_gamma)(
382 const struct pwl_params *params);
383 void (*power_on_mpc_mem_pwr)(
392 void (*disable_dwb_mux)(
400 void (*set_out_rate_control)(
405 struct mpc_dwb_flow_control *flow_control);
407 void (*set_gamut_remap)(
410 const struct mpc_grph_gamut_adjustment *adjust);
412 bool (*program_1dlut)(
414 const struct pwl_params *params,
417 bool (*program_shaper)(
419 const struct pwl_params *params,
422 uint32_t (*acquire_rmu)(struct mpc *mpc, int mpcc_id, int rmu_idx);
424 bool (*program_3dlut)(
426 const struct tetrahedral_params *params,
429 int (*release_rmu)(struct mpc *mpc, int mpcc_id);
431 unsigned int (*get_mpc_out_mux)(
435 void (*set_bg_color)(struct mpc *mpc,
436 struct tg_color *bg_color,
438 void (*set_mpc_mem_lp_mode)(struct mpc *mpc);