1*b843c749SSergey Zigachev /* Copyright 2012-15 Advanced Micro Devices, Inc. 2*b843c749SSergey Zigachev * 3*b843c749SSergey Zigachev * Permission is hereby granted, free of charge, to any person obtaining a 4*b843c749SSergey Zigachev * copy of this software and associated documentation files (the "Software"), 5*b843c749SSergey Zigachev * to deal in the Software without restriction, including without limitation 6*b843c749SSergey Zigachev * the rights to use, copy, modify, merge, publish, distribute, sublicense, 7*b843c749SSergey Zigachev * and/or sell copies of the Software, and to permit persons to whom the 8*b843c749SSergey Zigachev * Software is furnished to do so, subject to the following conditions: 9*b843c749SSergey Zigachev * 10*b843c749SSergey Zigachev * The above copyright notice and this permission notice shall be included in 11*b843c749SSergey Zigachev * all copies or substantial portions of the Software. 12*b843c749SSergey Zigachev * 13*b843c749SSergey Zigachev * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14*b843c749SSergey Zigachev * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15*b843c749SSergey Zigachev * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16*b843c749SSergey Zigachev * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 17*b843c749SSergey Zigachev * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 18*b843c749SSergey Zigachev * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 19*b843c749SSergey Zigachev * OTHER DEALINGS IN THE SOFTWARE. 20*b843c749SSergey Zigachev * 21*b843c749SSergey Zigachev * Authors: AMD 22*b843c749SSergey Zigachev * 23*b843c749SSergey Zigachev */ 24*b843c749SSergey Zigachev 25*b843c749SSergey Zigachev #ifndef __DC_MPCC_H__ 26*b843c749SSergey Zigachev #define __DC_MPCC_H__ 27*b843c749SSergey Zigachev 28*b843c749SSergey Zigachev #include "dc_hw_types.h" 29*b843c749SSergey Zigachev #include "hw_shared.h" 30*b843c749SSergey Zigachev 31*b843c749SSergey Zigachev #define MAX_MPCC 6 32*b843c749SSergey Zigachev #define MAX_OPP 6 33*b843c749SSergey Zigachev 34*b843c749SSergey Zigachev enum mpc_output_csc_mode { 35*b843c749SSergey Zigachev MPC_OUTPUT_CSC_DISABLE = 0, 36*b843c749SSergey Zigachev MPC_OUTPUT_CSC_COEF_A, 37*b843c749SSergey Zigachev MPC_OUTPUT_CSC_COEF_B 38*b843c749SSergey Zigachev }; 39*b843c749SSergey Zigachev 40*b843c749SSergey Zigachev 41*b843c749SSergey Zigachev enum mpcc_blend_mode { 42*b843c749SSergey Zigachev MPCC_BLEND_MODE_BYPASS, 43*b843c749SSergey Zigachev MPCC_BLEND_MODE_TOP_LAYER_PASSTHROUGH, 44*b843c749SSergey Zigachev MPCC_BLEND_MODE_TOP_LAYER_ONLY, 45*b843c749SSergey Zigachev MPCC_BLEND_MODE_TOP_BOT_BLENDING 46*b843c749SSergey Zigachev }; 47*b843c749SSergey Zigachev 48*b843c749SSergey Zigachev enum mpcc_alpha_blend_mode { 49*b843c749SSergey Zigachev MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA, 50*b843c749SSergey Zigachev MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA_COMBINED_GLOBAL_GAIN, 51*b843c749SSergey Zigachev MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA 52*b843c749SSergey Zigachev }; 53*b843c749SSergey Zigachev 54*b843c749SSergey Zigachev /* 55*b843c749SSergey Zigachev * MPCC blending configuration 56*b843c749SSergey Zigachev */ 57*b843c749SSergey Zigachev struct mpcc_blnd_cfg { 58*b843c749SSergey Zigachev struct tg_color black_color; /* background color */ 59*b843c749SSergey Zigachev enum mpcc_alpha_blend_mode alpha_mode; /* alpha blend mode */ 60*b843c749SSergey Zigachev bool pre_multiplied_alpha; /* alpha pre-multiplied mode flag */ 61*b843c749SSergey Zigachev int global_gain; 62*b843c749SSergey Zigachev int global_alpha; 63*b843c749SSergey Zigachev bool overlap_only; 64*b843c749SSergey Zigachev 65*b843c749SSergey Zigachev }; 66*b843c749SSergey Zigachev 67*b843c749SSergey Zigachev struct mpcc_sm_cfg { 68*b843c749SSergey Zigachev bool enable; 69*b843c749SSergey Zigachev /* 0-single plane,2-row subsampling,4-column subsampling,6-checkboard subsampling */ 70*b843c749SSergey Zigachev int sm_mode; 71*b843c749SSergey Zigachev /* 0- disable frame alternate, 1- enable frame alternate */ 72*b843c749SSergey Zigachev bool frame_alt; 73*b843c749SSergey Zigachev /* 0- disable field alternate, 1- enable field alternate */ 74*b843c749SSergey Zigachev bool field_alt; 75*b843c749SSergey Zigachev /* 0-no force,2-force frame polarity from top,3-force frame polarity from bottom */ 76*b843c749SSergey Zigachev int force_next_frame_porlarity; 77*b843c749SSergey Zigachev /* 0-no force,2-force field polarity from top,3-force field polarity from bottom */ 78*b843c749SSergey Zigachev int force_next_field_polarity; 79*b843c749SSergey Zigachev }; 80*b843c749SSergey Zigachev 81*b843c749SSergey Zigachev /* 82*b843c749SSergey Zigachev * MPCC connection and blending configuration for a single MPCC instance. 83*b843c749SSergey Zigachev * This struct is used as a node in an MPC tree. 84*b843c749SSergey Zigachev */ 85*b843c749SSergey Zigachev struct mpcc { 86*b843c749SSergey Zigachev int mpcc_id; /* MPCC physical instance */ 87*b843c749SSergey Zigachev int dpp_id; /* DPP input to this MPCC */ 88*b843c749SSergey Zigachev struct mpcc *mpcc_bot; /* pointer to bottom layer MPCC. NULL when not connected */ 89*b843c749SSergey Zigachev struct mpcc_blnd_cfg blnd_cfg; /* The blending configuration for this MPCC */ 90*b843c749SSergey Zigachev struct mpcc_sm_cfg sm_cfg; /* stereo mix setting for this MPCC */ 91*b843c749SSergey Zigachev }; 92*b843c749SSergey Zigachev 93*b843c749SSergey Zigachev /* 94*b843c749SSergey Zigachev * MPC tree represents all MPCC connections for a pipe. 95*b843c749SSergey Zigachev */ 96*b843c749SSergey Zigachev struct mpc_tree { 97*b843c749SSergey Zigachev int opp_id; /* The OPP instance that owns this MPC tree */ 98*b843c749SSergey Zigachev struct mpcc *opp_list; /* The top MPCC layer of the MPC tree that outputs to OPP endpoint */ 99*b843c749SSergey Zigachev }; 100*b843c749SSergey Zigachev 101*b843c749SSergey Zigachev struct mpc { 102*b843c749SSergey Zigachev const struct mpc_funcs *funcs; 103*b843c749SSergey Zigachev struct dc_context *ctx; 104*b843c749SSergey Zigachev 105*b843c749SSergey Zigachev struct mpcc mpcc_array[MAX_MPCC]; 106*b843c749SSergey Zigachev }; 107*b843c749SSergey Zigachev 108*b843c749SSergey Zigachev struct mpcc_state { 109*b843c749SSergey Zigachev uint32_t opp_id; 110*b843c749SSergey Zigachev uint32_t dpp_id; 111*b843c749SSergey Zigachev uint32_t bot_mpcc_id; 112*b843c749SSergey Zigachev uint32_t mode; 113*b843c749SSergey Zigachev uint32_t alpha_mode; 114*b843c749SSergey Zigachev uint32_t pre_multiplied_alpha; 115*b843c749SSergey Zigachev uint32_t overlap_only; 116*b843c749SSergey Zigachev uint32_t idle; 117*b843c749SSergey Zigachev uint32_t busy; 118*b843c749SSergey Zigachev }; 119*b843c749SSergey Zigachev 120*b843c749SSergey Zigachev struct mpc_funcs { 121*b843c749SSergey Zigachev void (*read_mpcc_state)( 122*b843c749SSergey Zigachev struct mpc *mpc, 123*b843c749SSergey Zigachev int mpcc_inst, 124*b843c749SSergey Zigachev struct mpcc_state *s); 125*b843c749SSergey Zigachev 126*b843c749SSergey Zigachev /* 127*b843c749SSergey Zigachev * Insert DPP into MPC tree based on specified blending position. 128*b843c749SSergey Zigachev * Only used for planes that are part of blending chain for OPP output 129*b843c749SSergey Zigachev * 130*b843c749SSergey Zigachev * Parameters: 131*b843c749SSergey Zigachev * [in/out] mpc - MPC context. 132*b843c749SSergey Zigachev * [in/out] tree - MPC tree structure that plane will be added to. 133*b843c749SSergey Zigachev * [in] blnd_cfg - MPCC blending configuration for the new blending layer. 134*b843c749SSergey Zigachev * [in] sm_cfg - MPCC stereo mix configuration for the new blending layer. 135*b843c749SSergey Zigachev * stereo mix must disable for the very bottom layer of the tree config. 136*b843c749SSergey Zigachev * [in] insert_above_mpcc - Insert new plane above this MPCC. If NULL, insert as bottom plane. 137*b843c749SSergey Zigachev * [in] dpp_id - DPP instance for the plane to be added. 138*b843c749SSergey Zigachev * [in] mpcc_id - The MPCC physical instance to use for blending. 139*b843c749SSergey Zigachev * 140*b843c749SSergey Zigachev * Return: struct mpcc* - MPCC that was added. 141*b843c749SSergey Zigachev */ 142*b843c749SSergey Zigachev struct mpcc* (*insert_plane)( 143*b843c749SSergey Zigachev struct mpc *mpc, 144*b843c749SSergey Zigachev struct mpc_tree *tree, 145*b843c749SSergey Zigachev struct mpcc_blnd_cfg *blnd_cfg, 146*b843c749SSergey Zigachev struct mpcc_sm_cfg *sm_cfg, 147*b843c749SSergey Zigachev struct mpcc *insert_above_mpcc, 148*b843c749SSergey Zigachev int dpp_id, 149*b843c749SSergey Zigachev int mpcc_id); 150*b843c749SSergey Zigachev 151*b843c749SSergey Zigachev /* 152*b843c749SSergey Zigachev * Remove a specified MPCC from the MPC tree. 153*b843c749SSergey Zigachev * 154*b843c749SSergey Zigachev * Parameters: 155*b843c749SSergey Zigachev * [in/out] mpc - MPC context. 156*b843c749SSergey Zigachev * [in/out] tree - MPC tree structure that plane will be removed from. 157*b843c749SSergey Zigachev * [in/out] mpcc - MPCC to be removed from tree. 158*b843c749SSergey Zigachev * 159*b843c749SSergey Zigachev * Return: void 160*b843c749SSergey Zigachev */ 161*b843c749SSergey Zigachev void (*remove_mpcc)( 162*b843c749SSergey Zigachev struct mpc *mpc, 163*b843c749SSergey Zigachev struct mpc_tree *tree, 164*b843c749SSergey Zigachev struct mpcc *mpcc); 165*b843c749SSergey Zigachev 166*b843c749SSergey Zigachev /* 167*b843c749SSergey Zigachev * Reset the MPCC HW status by disconnecting all muxes. 168*b843c749SSergey Zigachev * 169*b843c749SSergey Zigachev * Parameters: 170*b843c749SSergey Zigachev * [in/out] mpc - MPC context. 171*b843c749SSergey Zigachev * 172*b843c749SSergey Zigachev * Return: void 173*b843c749SSergey Zigachev */ 174*b843c749SSergey Zigachev void (*mpc_init)(struct mpc *mpc); 175*b843c749SSergey Zigachev 176*b843c749SSergey Zigachev /* 177*b843c749SSergey Zigachev * Update the blending configuration for a specified MPCC. 178*b843c749SSergey Zigachev * 179*b843c749SSergey Zigachev * Parameters: 180*b843c749SSergey Zigachev * [in/out] mpc - MPC context. 181*b843c749SSergey Zigachev * [in] blnd_cfg - MPCC blending configuration. 182*b843c749SSergey Zigachev * [in] mpcc_id - The MPCC physical instance. 183*b843c749SSergey Zigachev * 184*b843c749SSergey Zigachev * Return: void 185*b843c749SSergey Zigachev */ 186*b843c749SSergey Zigachev void (*update_blending)( 187*b843c749SSergey Zigachev struct mpc *mpc, 188*b843c749SSergey Zigachev struct mpcc_blnd_cfg *blnd_cfg, 189*b843c749SSergey Zigachev int mpcc_id); 190*b843c749SSergey Zigachev 191*b843c749SSergey Zigachev struct mpcc* (*get_mpcc_for_dpp)( 192*b843c749SSergey Zigachev struct mpc_tree *tree, 193*b843c749SSergey Zigachev int dpp_id); 194*b843c749SSergey Zigachev 195*b843c749SSergey Zigachev void (*wait_for_idle)(struct mpc *mpc, int id); 196*b843c749SSergey Zigachev 197*b843c749SSergey Zigachev void (*assert_mpcc_idle_before_connect)(struct mpc *mpc, int mpcc_id); 198*b843c749SSergey Zigachev 199*b843c749SSergey Zigachev void (*init_mpcc_list_from_hw)( 200*b843c749SSergey Zigachev struct mpc *mpc, 201*b843c749SSergey Zigachev struct mpc_tree *tree); 202*b843c749SSergey Zigachev 203*b843c749SSergey Zigachev }; 204*b843c749SSergey Zigachev 205*b843c749SSergey Zigachev #endif 206