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 Combiner (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
34 * MPC receives output from all DPP pipes and combines them to multiple outputs
35 * supporting "M MPC inputs -> N MPC outputs" flexible composition
36 * architecture. It features:
38 * - Programmable blending structure to allow software controlled blending and
40 * - Programmable window location of each DPP in active region of display;
41 * - Combining multiple DPP pipes in one active region when a single DPP pipe
42 * cannot process very large surface;
43 * - Combining multiple DPP from different SLS with blending;
44 * - Stereo formats from single DPP in top-bottom or side-by-side modes;
45 * - Stereo formats from 2 DPPs;
46 * - Alpha blending of multiple layers from different DPP pipes;
47 * - Programmable background color;
53 #include "dc_hw_types.h"
54 #include "hw_shared.h"
55 #include "transform.h"
62 enum mpc_output_csc_mode {
63 MPC_OUTPUT_CSC_DISABLE = 0,
64 MPC_OUTPUT_CSC_COEF_A,
69 enum mpcc_blend_mode {
70 MPCC_BLEND_MODE_BYPASS,
71 MPCC_BLEND_MODE_TOP_LAYER_PASSTHROUGH,
72 MPCC_BLEND_MODE_TOP_LAYER_ONLY,
73 MPCC_BLEND_MODE_TOP_BOT_BLENDING
77 * enum mpcc_alpha_blend_mode - define the alpha blend mode regarding pixel
78 * alpha and plane alpha values
80 enum mpcc_alpha_blend_mode {
82 * @MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA: per pixel alpha using DPP
85 MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA,
87 * @MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA_COMBINED_GLOBAL_GAIN: per
88 * pixel alpha using DPP alpha value multiplied by a global gain (plane
91 MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA_COMBINED_GLOBAL_GAIN,
93 * @MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA: global alpha value, ignores
94 * pixel alpha and consider only plane alpha
96 MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA
100 * struct mpcc_blnd_cfg - MPCC blending configuration
102 struct mpcc_blnd_cfg {
104 * @black_color: background color.
106 struct tg_color black_color;
109 * @alpha_mode: alpha blend mode (MPCC_ALPHA_BLND_MODE).
111 enum mpcc_alpha_blend_mode alpha_mode;
114 * @pre_multiplied_alpha:
115 * Whether pixel color values were pre-multiplied by the alpha channel
116 * (MPCC_ALPHA_MULTIPLIED_MODE).
118 bool pre_multiplied_alpha;
121 * @global_gain: Used when blend mode considers both pixel alpha and plane.
126 * @global_alpha: Plane alpha value.
131 * @overlap_only: Whether overlapping of different planes is allowed.
135 /* MPCC top/bottom gain settings */
138 * @bottom_gain_mode: Blend mode for bottom gain setting.
140 int bottom_gain_mode;
143 * @background_color_bpc: Background color for bpc.
145 int background_color_bpc;
148 * @top_gain: Top gain setting.
153 * @bottom_inside_gain: Blend mode for bottom inside.
155 int bottom_inside_gain;
158 * @bottom_outside_gain: Blend mode for bottom outside.
160 int bottom_outside_gain;
163 struct mpc_grph_gamut_adjustment {
164 struct fixed31_32 temperature_matrix[CSC_TEMPERATURE_MATRIX_SIZE];
165 enum graphics_gamut_adjust_type gamut_adjust_type;
170 /* 0-single plane,2-row subsampling,4-column subsampling,6-checkboard subsampling */
172 /* 0- disable frame alternate, 1- enable frame alternate */
174 /* 0- disable field alternate, 1- enable field alternate */
176 /* 0-no force,2-force frame polarity from top,3-force frame polarity from bottom */
177 int force_next_frame_porlarity;
178 /* 0-no force,2-force field polarity from top,3-force field polarity from bottom */
179 int force_next_field_polarity;
182 struct mpc_denorm_clamp {
191 struct mpc_dwb_flow_control {
198 * struct mpcc - MPCC connection and blending configuration for a single MPCC instance.
200 * This struct is used as a node in an MPC tree.
204 * @mpcc_id: MPCC physical instance.
209 * @dpp_id: DPP input to this MPCC
214 * @mpcc_bot: Pointer to bottom layer MPCC. NULL when not connected.
216 struct mpcc *mpcc_bot;
219 * @blnd_cfg: The blending configuration for this MPCC.
221 struct mpcc_blnd_cfg blnd_cfg;
224 * @sm_cfg: stereo mix setting for this MPCC
226 struct mpcc_sm_cfg sm_cfg;
231 * If MPCC output to both OPP and DWB endpoints, true. Otherwise, false.
237 * struct mpc_tree - MPC tree represents all MPCC connections for a pipe.
243 * @opp_id: The OPP instance that owns this MPC tree.
248 * @opp_list: the top MPCC layer of the MPC tree that outputs to OPP endpoint
250 struct mpcc *opp_list;
254 const struct mpc_funcs *funcs;
255 struct dc_context *ctx;
257 struct mpcc mpcc_array[MAX_MPCC];
258 struct pwl_params blender_params;
265 uint32_t bot_mpcc_id;
268 uint32_t pre_multiplied_alpha;
269 uint32_t overlap_only;
272 uint32_t shaper_lut_mode;
274 uint32_t lut3d_bit_depth;
278 struct mpc_grph_gamut_adjustment gamut_remap;
282 * struct mpc_funcs - funcs
285 void (*read_mpcc_state)(
288 struct mpcc_state *s);
293 * Insert DPP into MPC tree based on specified blending position.
294 * Only used for planes that are part of blending chain for OPP output
298 * - [in/out] mpc - MPC context.
299 * - [in/out] tree - MPC tree structure that plane will be added to.
300 * - [in] blnd_cfg - MPCC blending configuration for the new blending layer.
301 * - [in] sm_cfg - MPCC stereo mix configuration for the new blending layer.
302 * stereo mix must disable for the very bottom layer of the tree config.
303 * - [in] insert_above_mpcc - Insert new plane above this MPCC.
304 * If NULL, insert as bottom plane.
305 * - [in] dpp_id - DPP instance for the plane to be added.
306 * - [in] mpcc_id - The MPCC physical instance to use for blending.
310 * struct mpcc* - MPCC that was added.
312 struct mpcc* (*insert_plane)(
314 struct mpc_tree *tree,
315 struct mpcc_blnd_cfg *blnd_cfg,
316 struct mpcc_sm_cfg *sm_cfg,
317 struct mpcc *insert_above_mpcc,
324 * Remove a specified MPCC from the MPC tree.
328 * - [in/out] mpc - MPC context.
329 * - [in/out] tree - MPC tree structure that plane will be removed from.
330 * - [in/out] mpcc - MPCC to be removed from tree.
338 struct mpc_tree *tree,
344 * Reset the MPCC HW status by disconnecting all muxes.
348 * - [in/out] mpc - MPC context.
354 void (*mpc_init)(struct mpc *mpc);
355 void (*mpc_init_single_inst)(
357 unsigned int mpcc_id);
362 * Update the blending configuration for a specified MPCC.
366 * - [in/out] mpc - MPC context.
367 * - [in] blnd_cfg - MPCC blending configuration.
368 * - [in] mpcc_id - The MPCC physical instance.
374 void (*update_blending)(
376 struct mpcc_blnd_cfg *blnd_cfg,
382 * Lock cursor updates for the specified OPP. OPP defines the set of
383 * MPCC that are locked together for cursor.
387 * - [in] mpc - MPC context.
388 * - [in] opp_id - The OPP to lock cursor updates on
389 * - [in] lock - lock/unlock the OPP
401 * @insert_plane_to_secondary:
403 * Add DPP into secondary MPC tree based on specified blending
404 * position. Only used for planes that are part of blending chain for
409 * - [in/out] mpc - MPC context.
410 * - [in/out] tree - MPC tree structure that plane will be added to.
411 * - [in] blnd_cfg - MPCC blending configuration for the new blending layer.
412 * - [in] sm_cfg - MPCC stereo mix configuration for the new blending layer.
413 * stereo mix must disable for the very bottom layer of the tree config.
414 * - [in] insert_above_mpcc - Insert new plane above this MPCC. If
415 * NULL, insert as bottom plane.
416 * - [in] dpp_id - DPP instance for the plane to be added.
417 * - [in] mpcc_id - The MPCC physical instance to use for blending.
421 * struct mpcc* - MPCC that was added.
423 struct mpcc* (*insert_plane_to_secondary)(
425 struct mpc_tree *tree,
426 struct mpcc_blnd_cfg *blnd_cfg,
427 struct mpcc_sm_cfg *sm_cfg,
428 struct mpcc *insert_above_mpcc,
433 * @remove_mpcc_from_secondary:
435 * Remove a specified DPP from the 'secondary' MPC tree.
439 * - [in/out] mpc - MPC context.
440 * - [in/out] tree - MPC tree structure that plane will be removed from.
441 * - [in] mpcc - MPCC to be removed from tree.
447 void (*remove_mpcc_from_secondary)(
449 struct mpc_tree *tree,
452 struct mpcc* (*get_mpcc_for_dpp_from_secondary)(
453 struct mpc_tree *tree,
456 struct mpcc* (*get_mpcc_for_dpp)(
457 struct mpc_tree *tree,
460 void (*wait_for_idle)(struct mpc *mpc, int id);
462 void (*assert_mpcc_idle_before_connect)(struct mpc *mpc, int mpcc_id);
464 void (*init_mpcc_list_from_hw)(
466 struct mpc_tree *tree);
468 void (*set_denorm)(struct mpc *mpc,
470 enum dc_color_depth output_depth);
472 void (*set_denorm_clamp)(
475 struct mpc_denorm_clamp denorm_clamp);
477 void (*set_output_csc)(struct mpc *mpc,
479 const uint16_t *regval,
480 enum mpc_output_csc_mode ocsc_mode);
482 void (*set_ocsc_default)(struct mpc *mpc,
484 enum dc_color_space color_space,
485 enum mpc_output_csc_mode ocsc_mode);
487 void (*set_output_gamma)(
490 const struct pwl_params *params);
491 void (*power_on_mpc_mem_pwr)(
500 void (*disable_dwb_mux)(
508 void (*set_out_rate_control)(
513 struct mpc_dwb_flow_control *flow_control);
515 void (*set_gamut_remap)(
518 const struct mpc_grph_gamut_adjustment *adjust);
520 bool (*program_1dlut)(
522 const struct pwl_params *params,
525 bool (*program_shaper)(
527 const struct pwl_params *params,
530 uint32_t (*acquire_rmu)(struct mpc *mpc, int mpcc_id, int rmu_idx);
532 bool (*program_3dlut)(
534 const struct tetrahedral_params *params,
537 int (*release_rmu)(struct mpc *mpc, int mpcc_id);
539 unsigned int (*get_mpc_out_mux)(
543 void (*set_bg_color)(struct mpc *mpc,
544 struct tg_color *bg_color,
546 void (*set_mpc_mem_lp_mode)(struct mpc *mpc);