2 * Copyright 2012-15 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
29 * Multiple Pipe/Plane Combiner (MPC) is a component in the hardware pipeline
30 * that performs blending of multiple planes, using global and per-pixel alpha.
31 * It also performs post-blending color correction operations according to the
32 * hardware capabilities, such as color transformation matrix and gamma 1D and
35 * MPC receives output from all DPP pipes and combines them to multiple outputs
36 * supporting "M MPC inputs -> N MPC outputs" flexible composition
37 * architecture. It features:
39 * - Programmable blending structure to allow software controlled blending and
41 * - Programmable window location of each DPP in active region of display;
42 * - Combining multiple DPP pipes in one active region when a single DPP pipe
43 * cannot process very large surface;
44 * - Combining multiple DPP from different SLS with blending;
45 * - Stereo formats from single DPP in top-bottom or side-by-side modes;
46 * - Stereo formats from 2 DPPs;
47 * - Alpha blending of multiple layers from different DPP pipes;
48 * - Programmable background color;
54 #include "dc_hw_types.h"
55 #include "hw_shared.h"
56 #include "transform.h"
63 enum mpc_output_csc_mode {
64 MPC_OUTPUT_CSC_DISABLE = 0,
65 MPC_OUTPUT_CSC_COEF_A,
70 enum mpcc_blend_mode {
71 MPCC_BLEND_MODE_BYPASS,
72 MPCC_BLEND_MODE_TOP_LAYER_PASSTHROUGH,
73 MPCC_BLEND_MODE_TOP_LAYER_ONLY,
74 MPCC_BLEND_MODE_TOP_BOT_BLENDING
78 * enum mpcc_alpha_blend_mode - define the alpha blend mode regarding pixel
79 * alpha and plane alpha values
81 enum mpcc_alpha_blend_mode {
83 * @MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA: per pixel alpha using DPP
86 MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA,
88 * @MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA_COMBINED_GLOBAL_GAIN: per
89 * pixel alpha using DPP alpha value multiplied by a global gain (plane
92 MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA_COMBINED_GLOBAL_GAIN,
94 * @MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA: global alpha value, ignores
95 * pixel alpha and consider only plane alpha
97 MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA
100 enum mpcc_movable_cm_location {
101 MPCC_MOVABLE_CM_LOCATION_BEFORE,
102 MPCC_MOVABLE_CM_LOCATION_AFTER,
107 MCM_LUT_DISABLED = MCM_LUT_DISABLE,
109 MCM_LUT_ENABLED = MCM_LUT_ENABLE,
118 union mcm_lut_params {
119 const struct pwl_params *pwl;
120 const struct tetrahedral_params *lut3d;
124 * struct mpcc_blnd_cfg - MPCC blending configuration
126 struct mpcc_blnd_cfg {
128 * @black_color: background color.
130 struct tg_color black_color;
133 * @alpha_mode: alpha blend mode (MPCC_ALPHA_BLND_MODE).
135 enum mpcc_alpha_blend_mode alpha_mode;
138 * @pre_multiplied_alpha:
139 * Whether pixel color values were pre-multiplied by the alpha channel
140 * (MPCC_ALPHA_MULTIPLIED_MODE).
142 bool pre_multiplied_alpha;
145 * @global_gain: Used when blend mode considers both pixel alpha and plane.
150 * @global_alpha: Plane alpha value.
155 * @overlap_only: Whether overlapping of different planes is allowed.
159 /* MPCC top/bottom gain settings */
162 * @bottom_gain_mode: Blend mode for bottom gain setting.
164 int bottom_gain_mode;
167 * @background_color_bpc: Background color for bpc.
169 int background_color_bpc;
172 * @top_gain: Top gain setting.
177 * @bottom_inside_gain: Blend mode for bottom inside.
179 int bottom_inside_gain;
182 * @bottom_outside_gain: Blend mode for bottom outside.
184 int bottom_outside_gain;
187 struct mpc_grph_gamut_adjustment {
188 struct fixed31_32 temperature_matrix[CSC_TEMPERATURE_MATRIX_SIZE];
189 enum graphics_gamut_adjust_type gamut_adjust_type;
190 enum mpcc_gamut_remap_id mpcc_gamut_remap_block_id;
195 /* 0-single plane,2-row subsampling,4-column subsampling,6-checkboard subsampling */
197 /* 0- disable frame alternate, 1- enable frame alternate */
199 /* 0- disable field alternate, 1- enable field alternate */
201 /* 0-no force,2-force frame polarity from top,3-force frame polarity from bottom */
202 int force_next_frame_porlarity;
203 /* 0-no force,2-force field polarity from top,3-force field polarity from bottom */
204 int force_next_field_polarity;
207 struct mpc_denorm_clamp {
216 struct mpc_dwb_flow_control {
223 * struct mpcc - MPCC connection and blending configuration for a single MPCC instance.
225 * This struct is used as a node in an MPC tree.
229 * @mpcc_id: MPCC physical instance.
234 * @dpp_id: DPP input to this MPCC
239 * @mpcc_bot: Pointer to bottom layer MPCC. NULL when not connected.
241 struct mpcc *mpcc_bot;
244 * @blnd_cfg: The blending configuration for this MPCC.
246 struct mpcc_blnd_cfg blnd_cfg;
249 * @sm_cfg: stereo mix setting for this MPCC
251 struct mpcc_sm_cfg sm_cfg;
256 * If MPCC output to both OPP and DWB endpoints, true. Otherwise, false.
262 * struct mpc_tree - MPC tree represents all MPCC connections for a pipe.
268 * @opp_id: The OPP instance that owns this MPC tree.
273 * @opp_list: the top MPCC layer of the MPC tree that outputs to OPP endpoint
275 struct mpcc *opp_list;
279 const struct mpc_funcs *funcs;
280 struct dc_context *ctx;
282 struct mpcc mpcc_array[MAX_MPCC];
283 struct pwl_params blender_params;
290 uint32_t bot_mpcc_id;
293 uint32_t pre_multiplied_alpha;
294 uint32_t overlap_only;
297 uint32_t shaper_lut_mode;
299 uint32_t lut3d_bit_depth;
303 struct mpc_grph_gamut_adjustment gamut_remap;
307 * struct mpc_funcs - funcs
313 * Read register content from given MPCC physical instance.
317 * - [in/out] mpc - MPC context
318 * - [in] mpcc_instance - MPC context instance
319 * - [in] mpcc_state - MPC context state
325 void (*read_mpcc_state)(
328 struct mpcc_state *s);
333 * Insert DPP into MPC tree based on specified blending position.
334 * Only used for planes that are part of blending chain for OPP output
338 * - [in/out] mpc - MPC context.
339 * - [in/out] tree - MPC tree structure that plane will be added to.
340 * - [in] blnd_cfg - MPCC blending configuration for the new blending layer.
341 * - [in] sm_cfg - MPCC stereo mix configuration for the new blending layer.
342 * stereo mix must disable for the very bottom layer of the tree config.
343 * - [in] insert_above_mpcc - Insert new plane above this MPCC.
344 * If NULL, insert as bottom plane.
345 * - [in] dpp_id - DPP instance for the plane to be added.
346 * - [in] mpcc_id - The MPCC physical instance to use for blending.
350 * struct mpcc* - MPCC that was added.
352 struct mpcc* (*insert_plane)(
354 struct mpc_tree *tree,
355 struct mpcc_blnd_cfg *blnd_cfg,
356 struct mpcc_sm_cfg *sm_cfg,
357 struct mpcc *insert_above_mpcc,
364 * Remove a specified MPCC from the MPC tree.
368 * - [in/out] mpc - MPC context.
369 * - [in/out] tree - MPC tree structure that plane will be removed from.
370 * - [in/out] mpcc - MPCC to be removed from tree.
378 struct mpc_tree *tree,
384 * Reset the MPCC HW status by disconnecting all muxes.
388 * - [in/out] mpc - MPC context.
394 void (*mpc_init)(struct mpc *mpc);
397 * @mpc_init_single_inst:
399 * Initialize given MPCC physical instance.
402 * - [in/out] mpc - MPC context.
403 * - [in] mpcc_id - The MPCC physical instance to be initialized.
405 void (*mpc_init_single_inst)(
407 unsigned int mpcc_id);
412 * Update the blending configuration for a specified MPCC.
416 * - [in/out] mpc - MPC context.
417 * - [in] blnd_cfg - MPCC blending configuration.
418 * - [in] mpcc_id - The MPCC physical instance.
424 void (*update_blending)(
426 struct mpcc_blnd_cfg *blnd_cfg,
432 * Lock cursor updates for the specified OPP. OPP defines the set of
433 * MPCC that are locked together for cursor.
437 * - [in] mpc - MPC context.
438 * - [in] opp_id - The OPP to lock cursor updates on
439 * - [in] lock - lock/unlock the OPP
451 * @insert_plane_to_secondary:
453 * Add DPP into secondary MPC tree based on specified blending
454 * position. Only used for planes that are part of blending chain for
459 * - [in/out] mpc - MPC context.
460 * - [in/out] tree - MPC tree structure that plane will be added to.
461 * - [in] blnd_cfg - MPCC blending configuration for the new blending layer.
462 * - [in] sm_cfg - MPCC stereo mix configuration for the new blending layer.
463 * stereo mix must disable for the very bottom layer of the tree config.
464 * - [in] insert_above_mpcc - Insert new plane above this MPCC. If
465 * NULL, insert as bottom plane.
466 * - [in] dpp_id - DPP instance for the plane to be added.
467 * - [in] mpcc_id - The MPCC physical instance to use for blending.
471 * struct mpcc* - MPCC that was added.
473 struct mpcc* (*insert_plane_to_secondary)(
475 struct mpc_tree *tree,
476 struct mpcc_blnd_cfg *blnd_cfg,
477 struct mpcc_sm_cfg *sm_cfg,
478 struct mpcc *insert_above_mpcc,
483 * @remove_mpcc_from_secondary:
485 * Remove a specified DPP from the 'secondary' MPC tree.
489 * - [in/out] mpc - MPC context.
490 * - [in/out] tree - MPC tree structure that plane will be removed from.
491 * - [in] mpcc - MPCC to be removed from tree.
497 void (*remove_mpcc_from_secondary)(
499 struct mpc_tree *tree,
503 * @get_mpcc_for_dpp_from_secondary:
505 * Find, if it exists, a MPCC from a given 'secondary' MPC tree that
506 * is associated with specified plane.
509 * - [in/out] tree - MPC tree structure to search for plane.
510 * - [in] dpp_id - DPP to be searched.
514 * struct mpcc* - pointer to plane or NULL if no plane found.
516 struct mpcc* (*get_mpcc_for_dpp_from_secondary)(
517 struct mpc_tree *tree,
523 * Find, if it exists, a MPCC from a given MPC tree that
524 * is associated with specified plane.
527 * - [in/out] tree - MPC tree structure to search for plane.
528 * - [in] dpp_id - DPP to be searched.
532 * struct mpcc* - pointer to plane or NULL if no plane found.
534 struct mpcc* (*get_mpcc_for_dpp)(
535 struct mpc_tree *tree,
541 * Wait for a MPCC in MPC context to enter idle state.
544 * - [in/out] mpc - MPC Context.
545 * - [in] id - MPCC to wait for idle state.
551 void (*wait_for_idle)(struct mpc *mpc, int id);
554 * @assert_mpcc_idle_before_connect:
556 * Assert if MPCC in MPC context is in idle state.
559 * - [in/out] mpc - MPC context.
560 * - [in] id - MPCC to assert idle state.
566 void (*assert_mpcc_idle_before_connect)(struct mpc *mpc, int mpcc_id);
569 * @init_mpcc_list_from_hw:
571 * Iterate through the MPCC array from a given MPC context struct
572 * and configure each MPCC according to its registers' values.
575 * - [in/out] mpc - MPC context to initialize MPCC array.
576 * - [in/out] tree - MPC tree structure containing MPCC contexts to initialize.
582 void (*init_mpcc_list_from_hw)(
584 struct mpc_tree *tree);
589 * Set corresponding OPP DENORM_CONTROL register value to specific denorm_mode
590 * based on given color depth.
593 * - [in/out] mpc - MPC context.
594 * - [in] opp_id - Corresponding OPP to update register.
595 * - [in] output_depth - Arbitrary color depth to set denorm_mode.
601 void (*set_denorm)(struct mpc *mpc,
603 enum dc_color_depth output_depth);
608 * Set denorm clamp values on corresponding OPP DENORM CONTROL register.
611 * - [in/out] mpc - MPC context.
612 * - [in] opp_id - Corresponding OPP to update register.
613 * - [in] denorm_clamp - Arbitrary denorm clamp to be set.
619 void (*set_denorm_clamp)(
622 struct mpc_denorm_clamp denorm_clamp);
627 * Set the Output Color Space Conversion matrix
628 * with given values and mode.
631 * - [in/out] mpc - MPC context.
632 * - [in] opp_id - Corresponding OPP to update register.
633 * - [in] regval - Values to set in CSC matrix.
634 * - [in] ocsc_mode - Mode to set CSC.
640 void (*set_output_csc)(struct mpc *mpc,
642 const uint16_t *regval,
643 enum mpc_output_csc_mode ocsc_mode);
648 * Set the Output Color Space Conversion matrix
649 * to default values according to color space.
652 * - [in/out] mpc - MPC context.
653 * - [in] opp_id - Corresponding OPP to update register.
654 * - [in] color_space - OCSC color space.
655 * - [in] ocsc_mode - Mode to set CSC.
662 void (*set_ocsc_default)(struct mpc *mpc,
664 enum dc_color_space color_space,
665 enum mpc_output_csc_mode ocsc_mode);
670 * Set Output Gamma with given curve parameters.
673 * - [in/out] mpc - MPC context.
674 * - [in] mpcc_id - Corresponding MPC to update registers.
675 * - [in] params - Parameters.
682 void (*set_output_gamma)(
685 const struct pwl_params *params);
687 * @power_on_mpc_mem_pwr:
689 * Power on/off memory LUT for given MPCC.
690 * Powering on enables LUT to be updated.
691 * Powering off allows entering low power mode.
694 * - [in/out] mpc - MPC context.
695 * - [in] mpcc_id - MPCC to power on.
702 void (*power_on_mpc_mem_pwr)(
709 * Set corresponding Display Writeback mux
710 * MPC register field to given MPCC id.
713 * - [in/out] mpc - MPC context.
714 * - [in] dwb_id - DWB to be set.
715 * - [in] mpcc_id - MPCC id to be stored in DWB mux register.
729 * Reset corresponding Display Writeback mux
730 * MPC register field.
733 * - [in/out] mpc - MPC context.
734 * - [in] dwb_id - DWB to be set.
740 void (*disable_dwb_mux)(
747 * Check DWB status on MPC_DWB0_MUX_STATUS register field.
748 * Return if it is null.
751 * - [in/out] mpc - MPC context.
752 * - [in] dwb_id - DWB to be checked.
756 * bool - wheter DWB is idle or not
763 * @set_out_rate_control:
765 * Set display output rate control.
768 * - [in/out] mpc - MPC context.
769 * - [in] opp_id - OPP to be set.
771 * - [in] rate_2x_mode
772 * - [in] flow_control
778 void (*set_out_rate_control)(
783 struct mpc_dwb_flow_control *flow_control);
788 * Set post-blending CTM for given MPCC.
791 * - [in] mpc - MPC context.
792 * - [in] mpcc_id - MPCC to set gamut map.
799 void (*set_gamut_remap)(
802 const struct mpc_grph_gamut_adjustment *adjust);
807 * Set 1 dimensional Lookup Table.
810 * - [in/out] mpc - MPC context
811 * - [in] params - curve parameters for the LUT configuration
814 * bool - wheter LUT was set (set with given parameters) or not (params is NULL and LUT is disabled).
816 bool (*program_1dlut)(
818 const struct pwl_params *params,
827 * - [in/out] mpc - MPC context
828 * - [in] params - curve parameters to be set
833 * bool - wheter shaper was set (set with given parameters) or not (params is NULL and LUT is disabled).
835 bool (*program_shaper)(
837 const struct pwl_params *params,
843 * Set given MPCC to be multiplexed to given RMU unit.
846 * - [in/out] mpc - MPC context
847 * - [in] mpcc_id - MPCC
848 * - [in] rmu_idx - Given RMU unit to set MPCC to be multiplexed to.
852 * unit32_t - rmu_idx if operation was successful, -1 else.
854 uint32_t (*acquire_rmu)(struct mpc *mpc, int mpcc_id, int rmu_idx);
859 * Set 3 dimensional Lookup Table.
862 * - [in/out] mpc - MPC context
863 * - [in] params - tetrahedral parameters for the LUT configuration
866 * bool - wheter LUT was set (set with given parameters) or not (params is NULL and LUT is disabled).
868 bool (*program_3dlut)(
870 const struct tetrahedral_params *params,
876 * For a given MPCC, release the RMU unit it muliplexes to.
879 * - [in/out] mpc - MPC context
880 * - [in] mpcc_id - MPCC
884 * int - a valid rmu_idx representing released RMU unit or -1 if there was no RMU unit to release.
886 int (*release_rmu)(struct mpc *mpc, int mpcc_id);
891 * Return MPC out mux.
894 * - [in] mpc - MPC context.
895 * - [in] opp_id - OPP
899 * unsigned int - Out Mux
901 unsigned int (*get_mpc_out_mux)(
908 * Find corresponding bottommost MPCC and
912 * - [in/out] mpc - MPC context.
913 * - [in] bg_color - background color to be set.
920 void (*set_bg_color)(struct mpc *mpc,
921 struct tg_color *bg_color,
925 * @set_mpc_mem_lp_mode:
927 * Set mpc_mem_lp_mode.
930 * - [in/out] mpc - MPC context.
937 void (*set_mpc_mem_lp_mode)(struct mpc *mpc);
939 * @set_movable_cm_location:
941 * Set Movable CM Location.
944 * - [in/out] mpc - MPC context.
953 void (*set_movable_cm_location)(struct mpc *mpc, enum mpcc_movable_cm_location location, int mpcc_id);
955 * @update_3dlut_fast_load_select:
957 * Update 3D LUT fast load select.
960 * - [in/out] mpc - MPC context.
969 void (*update_3dlut_fast_load_select)(struct mpc *mpc, int mpcc_id, int hubp_idx);
971 * @get_3dlut_fast_load_status:
973 * Get 3D LUT fast load status and reference them with done, soft_underflow and hard_underflow pointers.
976 * - [in/out] mpc - MPC context.
979 * - [in/out] soft_underflow
980 * - [in/out] hard_underflow
986 void (*get_3dlut_fast_load_status)(struct mpc *mpc, int mpcc_id, uint32_t *done, uint32_t *soft_underflow, uint32_t *hard_underflow);
991 * Populate LUT with given tetrahedral parameters.
994 * - [in/out] mpc - MPC context.
1004 void (*populate_lut)(struct mpc *mpc, const enum MCM_LUT_ID id, const union mcm_lut_params params,
1005 bool lut_bank_a, int mpcc_id);
1008 * @program_lut_read_write_control:
1010 * Program LUT RW control.
1013 * - [in/out] mpc - MPC context.
1022 void (*program_lut_read_write_control)(struct mpc *mpc, const enum MCM_LUT_ID id, bool lut_bank_a, int mpcc_id);
1025 * @program_lut_mode:
1030 * - [in/out] mpc - MPC context.
1040 void (*program_lut_mode)(struct mpc *mpc, const enum MCM_LUT_ID id, const enum MCM_LUT_XABLE xable,
1041 bool lut_bank_a, int mpcc_id);
1043 * @program_3dlut_size:
1045 * Program 3D LUT size.
1048 * - [in/out] mpc - MPC context.
1049 * - [in] is_17x17x17 - is 3dlut 17x17x17
1056 void (*program_3dlut_size)(struct mpc *mpc, bool is_17x17x17, int mpcc_id);