1 /* Copyright 2024 Advanced Micro Devices, Inc. 2 * 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: 9 * 10 * The above copyright notice and this permission notice shall be included in 11 * all copies or substantial portions of the Software. 12 * 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. 20 * 21 * Authors: AMD 22 * 23 */ 24 #pragma once 25 26 #include "cdc.h" 27 #include "reg_helper.h" 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 #define VPE10_CDC_VUPDATE_OFFSET_DEFAULT (21) 34 #define VPE10_CDC_VUPDATE_WIDTH_DEFAULT (60) 35 #define VPE10_CDC_VREADY_OFFSET_DEFAULT (150) 36 37 /* macros for filing variable or field list 38 SRI, SFRB should be defined in the resource file */ 39 #define CDC_FE_REG_LIST_VPE10(id) \ 40 SRIDFVL(VPEP_MGCG_CNTL, CDC, id), SRIDFVL(VPCDC_SOFT_RESET, CDC, id), \ 41 SRIDFVL(VPCDC_FE0_SURFACE_CONFIG, CDC, id), SRIDFVL(VPCDC_FE0_CROSSBAR_CONFIG, CDC, id), \ 42 SRIDFVL(VPCDC_FE0_VIEWPORT_START_CONFIG, CDC, id), \ 43 SRIDFVL(VPCDC_FE0_VIEWPORT_DIMENSION_CONFIG, CDC, id), \ 44 SRIDFVL(VPCDC_FE0_VIEWPORT_START_C_CONFIG, CDC, id), \ 45 SRIDFVL(VPCDC_FE0_VIEWPORT_DIMENSION_C_CONFIG, CDC, id), \ 46 SRIDFVL(VPCDC_GLOBAL_SYNC_TRIGGER, CDC, id), \ 47 SRIDFVL(VPEP_MEM_GLOBAL_PWR_REQ_CNTL, CDC, id), SRIDFVL(VPFE_MEM_PWR_CNTL, CDC, id), \ 48 SRIDFVL(VPBE_MEM_PWR_CNTL, CDC, id) 49 50 #define CDC_FE_FIELD_LIST_VPE10(post_fix) \ 51 SFRB(VPDPP0_CLK_GATE_DIS, VPEP_MGCG_CNTL, post_fix), \ 52 SFRB(VPMPC_CLK_GATE_DIS, VPEP_MGCG_CNTL, post_fix), \ 53 SFRB(VPOPP_CLK_GATE_DIS, VPEP_MGCG_CNTL, post_fix), \ 54 SFRB(VPCDC_SOCCLK_G_GATE_DIS, VPEP_MGCG_CNTL, post_fix), \ 55 SFRB(VPCDC_SOCCLK_R_GATE_DIS, VPEP_MGCG_CNTL, post_fix), \ 56 SFRB(VPCDC_VPECLK_G_GATE_DIS, VPEP_MGCG_CNTL, post_fix), \ 57 SFRB(VPCDC_VPECLK_R_GATE_DIS, VPEP_MGCG_CNTL, post_fix), \ 58 SFRB(VPCDC_SOCCLK_SOFT_RESET, VPCDC_SOFT_RESET, post_fix), \ 59 SFRB(VPCDC_VPECLK_SOFT_RESET, VPCDC_SOFT_RESET, post_fix), \ 60 SFRB(SURFACE_PIXEL_FORMAT_FE0, VPCDC_FE0_SURFACE_CONFIG, post_fix), \ 61 SFRB(ROTATION_ANGLE_FE0, VPCDC_FE0_SURFACE_CONFIG, post_fix), \ 62 SFRB(H_MIRROR_EN_FE0, VPCDC_FE0_SURFACE_CONFIG, post_fix), \ 63 SFRB(PIX_SURFACE_LINEAR_FE0, VPCDC_FE0_SURFACE_CONFIG, post_fix), \ 64 SFRB(CROSSBAR_SRC_ALPHA_FE0, VPCDC_FE0_CROSSBAR_CONFIG, post_fix), \ 65 SFRB(CROSSBAR_SRC_Y_G_FE0, VPCDC_FE0_CROSSBAR_CONFIG, post_fix), \ 66 SFRB(CROSSBAR_SRC_CB_B_FE0, VPCDC_FE0_CROSSBAR_CONFIG, post_fix), \ 67 SFRB(CROSSBAR_SRC_CR_R_FE0, VPCDC_FE0_CROSSBAR_CONFIG, post_fix), \ 68 SFRB(VIEWPORT_X_START_FE0, VPCDC_FE0_VIEWPORT_START_CONFIG, post_fix), \ 69 SFRB(VIEWPORT_Y_START_FE0, VPCDC_FE0_VIEWPORT_START_CONFIG, post_fix), \ 70 SFRB(VIEWPORT_WIDTH_FE0, VPCDC_FE0_VIEWPORT_DIMENSION_CONFIG, post_fix), \ 71 SFRB(VIEWPORT_HEIGHT_FE0, VPCDC_FE0_VIEWPORT_DIMENSION_CONFIG, post_fix), \ 72 SFRB(VIEWPORT_X_START_C_FE0, VPCDC_FE0_VIEWPORT_START_C_CONFIG, post_fix), \ 73 SFRB(VIEWPORT_Y_START_C_FE0, VPCDC_FE0_VIEWPORT_START_C_CONFIG, post_fix), \ 74 SFRB(VIEWPORT_WIDTH_C_FE0, VPCDC_FE0_VIEWPORT_DIMENSION_C_CONFIG, post_fix), \ 75 SFRB(VIEWPORT_HEIGHT_C_FE0, VPCDC_FE0_VIEWPORT_DIMENSION_C_CONFIG, post_fix), \ 76 SFRB(VPBE_GS_TRIG, VPCDC_GLOBAL_SYNC_TRIGGER, post_fix), \ 77 SFRB(VPFE_VR_STATUS, VPCDC_VREADY_STATUS, post_fix), \ 78 SFRB(MEM_GLOBAL_PWR_REQ_DIS, VPEP_MEM_GLOBAL_PWR_REQ_CNTL, post_fix), \ 79 SFRB(VPFE0_MEM_PWR_FORCE, VPFE_MEM_PWR_CNTL, post_fix), \ 80 SFRB(VPFE0_MEM_PWR_MODE, VPFE_MEM_PWR_CNTL, post_fix), \ 81 SFRB(VPFE0_MEM_PWR_STATE, VPFE_MEM_PWR_CNTL, post_fix), \ 82 SFRB(VPFE0_MEM_PWR_DIS, VPFE_MEM_PWR_CNTL, post_fix), \ 83 SFRB(VPBE0_MEM_PWR_FORCE, VPBE_MEM_PWR_CNTL, post_fix), \ 84 SFRB(VPBE0_MEM_PWR_MODE, VPBE_MEM_PWR_CNTL, post_fix), \ 85 SFRB(VPBE0_MEM_PWR_STATE, VPBE_MEM_PWR_CNTL, post_fix), \ 86 SFRB(VPBE0_MEM_PWR_DIS, VPBE_MEM_PWR_CNTL, post_fix) 87 88 /* define all structure register variables below */ 89 #define CDC_FE_REG_VARIABLE_LIST_VPE10 \ 90 reg_id_val VPEP_MGCG_CNTL; \ 91 reg_id_val VPCDC_SOFT_RESET; \ 92 reg_id_val VPCDC_FE0_SURFACE_CONFIG; \ 93 reg_id_val VPCDC_FE0_CROSSBAR_CONFIG; \ 94 reg_id_val VPCDC_FE0_VIEWPORT_START_CONFIG; \ 95 reg_id_val VPCDC_FE0_VIEWPORT_DIMENSION_CONFIG; \ 96 reg_id_val VPCDC_FE0_VIEWPORT_START_C_CONFIG; \ 97 reg_id_val VPCDC_FE0_VIEWPORT_DIMENSION_C_CONFIG; \ 98 reg_id_val VPCDC_GLOBAL_SYNC_TRIGGER; \ 99 reg_id_val VPEP_MEM_GLOBAL_PWR_REQ_CNTL; \ 100 reg_id_val VPFE_MEM_PWR_CNTL; \ 101 reg_id_val VPBE_MEM_PWR_CNTL; 102 103 #define CDC_FE_FIELD_VARIABLE_LIST_VPE10(type) \ 104 type VPDPP0_CLK_GATE_DIS; \ 105 type VPMPC_CLK_GATE_DIS; \ 106 type VPOPP_CLK_GATE_DIS; \ 107 type VPCDC_SOCCLK_G_GATE_DIS; \ 108 type VPCDC_SOCCLK_R_GATE_DIS; \ 109 type VPCDC_VPECLK_G_GATE_DIS; \ 110 type VPCDC_VPECLK_R_GATE_DIS; \ 111 type VPCDC_SOCCLK_SOFT_RESET; \ 112 type VPCDC_VPECLK_SOFT_RESET; \ 113 type SURFACE_PIXEL_FORMAT_FE0; \ 114 type ROTATION_ANGLE_FE0; \ 115 type H_MIRROR_EN_FE0; \ 116 type PIX_SURFACE_LINEAR_FE0; \ 117 type CROSSBAR_SRC_ALPHA_FE0; \ 118 type CROSSBAR_SRC_Y_G_FE0; \ 119 type CROSSBAR_SRC_CB_B_FE0; \ 120 type CROSSBAR_SRC_CR_R_FE0; \ 121 type VIEWPORT_X_START_FE0; \ 122 type VIEWPORT_Y_START_FE0; \ 123 type VIEWPORT_WIDTH_FE0; \ 124 type VIEWPORT_HEIGHT_FE0; \ 125 type VIEWPORT_X_START_C_FE0; \ 126 type VIEWPORT_Y_START_C_FE0; \ 127 type VIEWPORT_WIDTH_C_FE0; \ 128 type VIEWPORT_HEIGHT_C_FE0; \ 129 type VPBE_GS_TRIG; \ 130 type VPFE_VR_STATUS; \ 131 type MEM_GLOBAL_PWR_REQ_DIS; \ 132 type VPFE0_MEM_PWR_FORCE; \ 133 type VPFE0_MEM_PWR_MODE; \ 134 type VPFE0_MEM_PWR_STATE; \ 135 type VPFE0_MEM_PWR_DIS; \ 136 type VPBE0_MEM_PWR_FORCE; \ 137 type VPBE0_MEM_PWR_MODE; \ 138 type VPBE0_MEM_PWR_STATE; \ 139 type VPBE0_MEM_PWR_DIS; 140 141 struct vpe10_cdc_fe_registers { 142 CDC_FE_REG_VARIABLE_LIST_VPE10 143 }; 144 145 struct vpe10_cdc_fe_shift { 146 CDC_FE_FIELD_VARIABLE_LIST_VPE10(uint8_t) 147 }; 148 149 struct vpe10_cdc_fe_mask { 150 CDC_FE_FIELD_VARIABLE_LIST_VPE10(uint32_t) 151 }; 152 153 struct vpe10_cdc_fe { 154 struct cdc_fe base; // base class, must be the first field 155 struct vpe10_cdc_fe_registers *regs; 156 const struct vpe10_cdc_fe_shift *shift; 157 const struct vpe10_cdc_fe_mask *mask; 158 }; 159 160 void vpe10_construct_cdc_fe(struct vpe_priv *vpe_priv, struct cdc_fe *cdc_fe); 161 162 bool vpe10_cdc_check_input_format(struct cdc_fe *cdc_fe, enum vpe_surface_pixel_format format); 163 164 void vpe10_cdc_program_surface_config(struct cdc_fe *cdc_fe, enum vpe_surface_pixel_format format, 165 enum vpe_rotation_angle rotation, bool horizontal_mirror, enum vpe_swizzle_mode_values swizzle); 166 167 void vpe10_cdc_program_crossbar_config(struct cdc_fe *cdc_fe, enum vpe_surface_pixel_format format); 168 169 /***** segment register programming *****/ 170 void vpe10_cdc_program_viewport( 171 struct cdc_fe *cdc_fe, const struct vpe_rect *viewport, const struct vpe_rect *viewport_c); 172 173 #ifdef __cplusplus 174 } 175 #endif 176