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_DCN10_H__ 26*b843c749SSergey Zigachev #define __DC_MPCC_DCN10_H__ 27*b843c749SSergey Zigachev 28*b843c749SSergey Zigachev #include "mpc.h" 29*b843c749SSergey Zigachev 30*b843c749SSergey Zigachev #define TO_DCN10_MPC(mpc_base) \ 31*b843c749SSergey Zigachev container_of(mpc_base, struct dcn10_mpc, base) 32*b843c749SSergey Zigachev 33*b843c749SSergey Zigachev #define MPC_COMMON_REG_LIST_DCN1_0(inst) \ 34*b843c749SSergey Zigachev SRII(MPCC_TOP_SEL, MPCC, inst),\ 35*b843c749SSergey Zigachev SRII(MPCC_BOT_SEL, MPCC, inst),\ 36*b843c749SSergey Zigachev SRII(MPCC_CONTROL, MPCC, inst),\ 37*b843c749SSergey Zigachev SRII(MPCC_STATUS, MPCC, inst),\ 38*b843c749SSergey Zigachev SRII(MPCC_OPP_ID, MPCC, inst),\ 39*b843c749SSergey Zigachev SRII(MPCC_BG_G_Y, MPCC, inst),\ 40*b843c749SSergey Zigachev SRII(MPCC_BG_R_CR, MPCC, inst),\ 41*b843c749SSergey Zigachev SRII(MPCC_BG_B_CB, MPCC, inst),\ 42*b843c749SSergey Zigachev SRII(MPCC_BG_B_CB, MPCC, inst),\ 43*b843c749SSergey Zigachev SRII(MPCC_SM_CONTROL, MPCC, inst) 44*b843c749SSergey Zigachev 45*b843c749SSergey Zigachev #define MPC_OUT_MUX_COMMON_REG_LIST_DCN1_0(inst) \ 46*b843c749SSergey Zigachev SRII(MUX, MPC_OUT, inst) 47*b843c749SSergey Zigachev 48*b843c749SSergey Zigachev #define MPC_COMMON_REG_VARIABLE_LIST \ 49*b843c749SSergey Zigachev uint32_t MPCC_TOP_SEL[MAX_MPCC]; \ 50*b843c749SSergey Zigachev uint32_t MPCC_BOT_SEL[MAX_MPCC]; \ 51*b843c749SSergey Zigachev uint32_t MPCC_CONTROL[MAX_MPCC]; \ 52*b843c749SSergey Zigachev uint32_t MPCC_STATUS[MAX_MPCC]; \ 53*b843c749SSergey Zigachev uint32_t MPCC_OPP_ID[MAX_MPCC]; \ 54*b843c749SSergey Zigachev uint32_t MPCC_BG_G_Y[MAX_MPCC]; \ 55*b843c749SSergey Zigachev uint32_t MPCC_BG_R_CR[MAX_MPCC]; \ 56*b843c749SSergey Zigachev uint32_t MPCC_BG_B_CB[MAX_MPCC]; \ 57*b843c749SSergey Zigachev uint32_t MPCC_SM_CONTROL[MAX_MPCC]; \ 58*b843c749SSergey Zigachev uint32_t MUX[MAX_OPP]; 59*b843c749SSergey Zigachev 60*b843c749SSergey Zigachev #define MPC_COMMON_MASK_SH_LIST_DCN1_0(mask_sh)\ 61*b843c749SSergey Zigachev SF(MPCC0_MPCC_TOP_SEL, MPCC_TOP_SEL, mask_sh),\ 62*b843c749SSergey Zigachev SF(MPCC0_MPCC_BOT_SEL, MPCC_BOT_SEL, mask_sh),\ 63*b843c749SSergey Zigachev SF(MPCC0_MPCC_CONTROL, MPCC_MODE, mask_sh),\ 64*b843c749SSergey Zigachev SF(MPCC0_MPCC_CONTROL, MPCC_ALPHA_BLND_MODE, mask_sh),\ 65*b843c749SSergey Zigachev SF(MPCC0_MPCC_CONTROL, MPCC_ALPHA_MULTIPLIED_MODE, mask_sh),\ 66*b843c749SSergey Zigachev SF(MPCC0_MPCC_CONTROL, MPCC_BLND_ACTIVE_OVERLAP_ONLY, mask_sh),\ 67*b843c749SSergey Zigachev SF(MPCC0_MPCC_CONTROL, MPCC_GLOBAL_ALPHA, mask_sh),\ 68*b843c749SSergey Zigachev SF(MPCC0_MPCC_CONTROL, MPCC_GLOBAL_GAIN, mask_sh),\ 69*b843c749SSergey Zigachev SF(MPCC0_MPCC_STATUS, MPCC_IDLE, mask_sh),\ 70*b843c749SSergey Zigachev SF(MPCC0_MPCC_STATUS, MPCC_BUSY, mask_sh),\ 71*b843c749SSergey Zigachev SF(MPCC0_MPCC_OPP_ID, MPCC_OPP_ID, mask_sh),\ 72*b843c749SSergey Zigachev SF(MPCC0_MPCC_BG_G_Y, MPCC_BG_G_Y, mask_sh),\ 73*b843c749SSergey Zigachev SF(MPCC0_MPCC_BG_R_CR, MPCC_BG_R_CR, mask_sh),\ 74*b843c749SSergey Zigachev SF(MPCC0_MPCC_BG_B_CB, MPCC_BG_B_CB, mask_sh),\ 75*b843c749SSergey Zigachev SF(MPCC0_MPCC_SM_CONTROL, MPCC_SM_EN, mask_sh),\ 76*b843c749SSergey Zigachev SF(MPCC0_MPCC_SM_CONTROL, MPCC_SM_MODE, mask_sh),\ 77*b843c749SSergey Zigachev SF(MPCC0_MPCC_SM_CONTROL, MPCC_SM_FRAME_ALT, mask_sh),\ 78*b843c749SSergey Zigachev SF(MPCC0_MPCC_SM_CONTROL, MPCC_SM_FIELD_ALT, mask_sh),\ 79*b843c749SSergey Zigachev SF(MPCC0_MPCC_SM_CONTROL, MPCC_SM_FORCE_NEXT_FRAME_POL, mask_sh),\ 80*b843c749SSergey Zigachev SF(MPCC0_MPCC_SM_CONTROL, MPCC_SM_FORCE_NEXT_TOP_POL, mask_sh),\ 81*b843c749SSergey Zigachev SF(MPC_OUT0_MUX, MPC_OUT_MUX, mask_sh) 82*b843c749SSergey Zigachev 83*b843c749SSergey Zigachev #define MPC_REG_FIELD_LIST(type) \ 84*b843c749SSergey Zigachev type MPCC_TOP_SEL;\ 85*b843c749SSergey Zigachev type MPCC_BOT_SEL;\ 86*b843c749SSergey Zigachev type MPCC_MODE;\ 87*b843c749SSergey Zigachev type MPCC_ALPHA_BLND_MODE;\ 88*b843c749SSergey Zigachev type MPCC_ALPHA_MULTIPLIED_MODE;\ 89*b843c749SSergey Zigachev type MPCC_BLND_ACTIVE_OVERLAP_ONLY;\ 90*b843c749SSergey Zigachev type MPCC_GLOBAL_ALPHA;\ 91*b843c749SSergey Zigachev type MPCC_GLOBAL_GAIN;\ 92*b843c749SSergey Zigachev type MPCC_IDLE;\ 93*b843c749SSergey Zigachev type MPCC_BUSY;\ 94*b843c749SSergey Zigachev type MPCC_OPP_ID;\ 95*b843c749SSergey Zigachev type MPCC_BG_G_Y;\ 96*b843c749SSergey Zigachev type MPCC_BG_R_CR;\ 97*b843c749SSergey Zigachev type MPCC_BG_B_CB;\ 98*b843c749SSergey Zigachev type MPCC_SM_EN;\ 99*b843c749SSergey Zigachev type MPCC_SM_MODE;\ 100*b843c749SSergey Zigachev type MPCC_SM_FRAME_ALT;\ 101*b843c749SSergey Zigachev type MPCC_SM_FIELD_ALT;\ 102*b843c749SSergey Zigachev type MPCC_SM_FORCE_NEXT_FRAME_POL;\ 103*b843c749SSergey Zigachev type MPCC_SM_FORCE_NEXT_TOP_POL;\ 104*b843c749SSergey Zigachev type MPC_OUT_MUX; 105*b843c749SSergey Zigachev 106*b843c749SSergey Zigachev struct dcn_mpc_registers { 107*b843c749SSergey Zigachev MPC_COMMON_REG_VARIABLE_LIST 108*b843c749SSergey Zigachev }; 109*b843c749SSergey Zigachev 110*b843c749SSergey Zigachev struct dcn_mpc_shift { 111*b843c749SSergey Zigachev MPC_REG_FIELD_LIST(uint8_t) 112*b843c749SSergey Zigachev }; 113*b843c749SSergey Zigachev 114*b843c749SSergey Zigachev struct dcn_mpc_mask { 115*b843c749SSergey Zigachev MPC_REG_FIELD_LIST(uint32_t) 116*b843c749SSergey Zigachev }; 117*b843c749SSergey Zigachev 118*b843c749SSergey Zigachev struct dcn10_mpc { 119*b843c749SSergey Zigachev struct mpc base; 120*b843c749SSergey Zigachev 121*b843c749SSergey Zigachev int mpcc_in_use_mask; 122*b843c749SSergey Zigachev int num_mpcc; 123*b843c749SSergey Zigachev const struct dcn_mpc_registers *mpc_regs; 124*b843c749SSergey Zigachev const struct dcn_mpc_shift *mpc_shift; 125*b843c749SSergey Zigachev const struct dcn_mpc_mask *mpc_mask; 126*b843c749SSergey Zigachev }; 127*b843c749SSergey Zigachev 128*b843c749SSergey Zigachev void dcn10_mpc_construct(struct dcn10_mpc *mpcc10, 129*b843c749SSergey Zigachev struct dc_context *ctx, 130*b843c749SSergey Zigachev const struct dcn_mpc_registers *mpc_regs, 131*b843c749SSergey Zigachev const struct dcn_mpc_shift *mpc_shift, 132*b843c749SSergey Zigachev const struct dcn_mpc_mask *mpc_mask, 133*b843c749SSergey Zigachev int num_mpcc); 134*b843c749SSergey Zigachev 135*b843c749SSergey Zigachev struct mpcc *mpc1_insert_plane( 136*b843c749SSergey Zigachev struct mpc *mpc, 137*b843c749SSergey Zigachev struct mpc_tree *tree, 138*b843c749SSergey Zigachev struct mpcc_blnd_cfg *blnd_cfg, 139*b843c749SSergey Zigachev struct mpcc_sm_cfg *sm_cfg, 140*b843c749SSergey Zigachev struct mpcc *insert_above_mpcc, 141*b843c749SSergey Zigachev int dpp_id, 142*b843c749SSergey Zigachev int mpcc_id); 143*b843c749SSergey Zigachev 144*b843c749SSergey Zigachev void mpc1_remove_mpcc( 145*b843c749SSergey Zigachev struct mpc *mpc, 146*b843c749SSergey Zigachev struct mpc_tree *tree, 147*b843c749SSergey Zigachev struct mpcc *mpcc); 148*b843c749SSergey Zigachev 149*b843c749SSergey Zigachev void mpc1_mpc_init( 150*b843c749SSergey Zigachev struct mpc *mpc); 151*b843c749SSergey Zigachev 152*b843c749SSergey Zigachev void mpc1_assert_idle_mpcc( 153*b843c749SSergey Zigachev struct mpc *mpc, 154*b843c749SSergey Zigachev int id); 155*b843c749SSergey Zigachev 156*b843c749SSergey Zigachev void mpc1_set_bg_color( 157*b843c749SSergey Zigachev struct mpc *mpc, 158*b843c749SSergey Zigachev struct tg_color *bg_color, 159*b843c749SSergey Zigachev int id); 160*b843c749SSergey Zigachev 161*b843c749SSergey Zigachev void mpc1_update_stereo_mix( 162*b843c749SSergey Zigachev struct mpc *mpc, 163*b843c749SSergey Zigachev struct mpcc_sm_cfg *sm_cfg, 164*b843c749SSergey Zigachev int mpcc_id); 165*b843c749SSergey Zigachev 166*b843c749SSergey Zigachev bool mpc1_is_mpcc_idle( 167*b843c749SSergey Zigachev struct mpc *mpc, 168*b843c749SSergey Zigachev int mpcc_id); 169*b843c749SSergey Zigachev 170*b843c749SSergey Zigachev void mpc1_assert_mpcc_idle_before_connect( 171*b843c749SSergey Zigachev struct mpc *mpc, 172*b843c749SSergey Zigachev int mpcc_id); 173*b843c749SSergey Zigachev 174*b843c749SSergey Zigachev void mpc1_init_mpcc_list_from_hw( 175*b843c749SSergey Zigachev struct mpc *mpc, 176*b843c749SSergey Zigachev struct mpc_tree *tree); 177*b843c749SSergey Zigachev 178*b843c749SSergey Zigachev struct mpcc *mpc1_get_mpcc( 179*b843c749SSergey Zigachev struct mpc *mpc, 180*b843c749SSergey Zigachev int mpcc_id); 181*b843c749SSergey Zigachev 182*b843c749SSergey Zigachev struct mpcc *mpc1_get_mpcc_for_dpp( 183*b843c749SSergey Zigachev struct mpc_tree *tree, 184*b843c749SSergey Zigachev int dpp_id); 185*b843c749SSergey Zigachev 186*b843c749SSergey Zigachev void mpc1_read_mpcc_state( 187*b843c749SSergey Zigachev struct mpc *mpc, 188*b843c749SSergey Zigachev int mpcc_inst, 189*b843c749SSergey Zigachev struct mpcc_state *s); 190*b843c749SSergey Zigachev 191*b843c749SSergey Zigachev #endif 192