Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu/display: Add dml support for DCN

Display mode lib handles clock, watermark, and bandwidth
calculations for DCN.

Signed-off-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Harry Wentland and committed by
Alex Deucher
061bfa06 70ccab60

+8717
+22
drivers/gpu/drm/amd/display/dc/dml/Makefile
··· 1 + # 2 + # Makefile for the 'utils' sub-component of DAL. 3 + # It provides the general basic services required by other DAL 4 + # subcomponents. 5 + 6 + CFLAGS_display_mode_lib.o := -mhard-float -msse -mpreferred-stack-boundary=4 7 + CFLAGS_display_pipe_clocks.o := -mhard-float -msse -mpreferred-stack-boundary=4 8 + CFLAGS_display_rq_dlg_calc.o := -mhard-float -msse -mpreferred-stack-boundary=4 9 + CFLAGS_display_rq_dlg_helpers.o := -mhard-float -msse -mpreferred-stack-boundary=4 10 + CFLAGS_display_watermark.o := -mhard-float -msse -mpreferred-stack-boundary=4 11 + CFLAGS_soc_bounding_box.o := -mhard-float -msse -mpreferred-stack-boundary=4 12 + CFLAGS_dml_common_defs.o := -mhard-float -msse -mpreferred-stack-boundary=4 13 + CFLAGS_display_mode_support.o := -mhard-float -msse -mpreferred-stack-boundary=4 14 + 15 + 16 + DML = display_mode_lib.o display_pipe_clocks.o display_rq_dlg_calc.o \ 17 + display_rq_dlg_helpers.o display_watermark.o \ 18 + soc_bounding_box.o dml_common_defs.o display_mode_support.o 19 + 20 + AMD_DAL_DML = $(addprefix $(AMDDALPATH)/dc/dml/,$(DML)) 21 + 22 + AMD_DISPLAY_FILES += $(AMD_DAL_DML)
+557
drivers/gpu/drm/amd/display/dc/dml/dc_features.h
··· 1 + /* 2 + * Copyright 2017 Advanced Micro Devices, Inc. 3 + * 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: 10 + * 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 13 + * 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. 21 + * 22 + * Authors: AMD 23 + * 24 + */ 25 + #ifndef __DC_FEATURES_H__ 26 + #define __DC_FEATURES_H__ 27 + 28 + #define DC__PRESENT 1 29 + #define DC__PRESENT__1 1 30 + #define DC__NUM_DPP 4 31 + #define DC__NUM_DPP__4 1 32 + #define DC__NUM_DPP__0_PRESENT 1 33 + #define DC__NUM_DPP__1_PRESENT 1 34 + #define DC__NUM_DPP__2_PRESENT 1 35 + #define DC__NUM_DPP__3_PRESENT 1 36 + #define DC__NUM_DPP__MAX 8 37 + #define DC__NUM_DPP__MAX__8 1 38 + #define DC__PIPE_10BIT 0 39 + #define DC__PIPE_10BIT__0 1 40 + #define DC__PIPE_10BIT__MAX 1 41 + #define DC__PIPE_10BIT__MAX__1 1 42 + #define DC__NUM_OPP 4 43 + #define DC__NUM_OPP__4 1 44 + #define DC__NUM_OPP__0_PRESENT 1 45 + #define DC__NUM_OPP__1_PRESENT 1 46 + #define DC__NUM_OPP__2_PRESENT 1 47 + #define DC__NUM_OPP__3_PRESENT 1 48 + #define DC__NUM_OPP__MAX 6 49 + #define DC__NUM_OPP__MAX__6 1 50 + #define DC__NUM_DSC 0 51 + #define DC__NUM_DSC__0 1 52 + #define DC__NUM_DSC__MAX 6 53 + #define DC__NUM_DSC__MAX__6 1 54 + #define DC__NUM_ABM 1 55 + #define DC__NUM_ABM__1 1 56 + #define DC__NUM_ABM__0_PRESENT 1 57 + #define DC__NUM_ABM__MAX 2 58 + #define DC__NUM_ABM__MAX__2 1 59 + #define DC__ODM_PRESENT 0 60 + #define DC__ODM_PRESENT__0 1 61 + #define DC__NUM_OTG 4 62 + #define DC__NUM_OTG__4 1 63 + #define DC__NUM_OTG__0_PRESENT 1 64 + #define DC__NUM_OTG__1_PRESENT 1 65 + #define DC__NUM_OTG__2_PRESENT 1 66 + #define DC__NUM_OTG__3_PRESENT 1 67 + #define DC__NUM_OTG__MAX 6 68 + #define DC__NUM_OTG__MAX__6 1 69 + #define DC__NUM_DWB 2 70 + #define DC__NUM_DWB__2 1 71 + #define DC__NUM_DWB__0_PRESENT 1 72 + #define DC__NUM_DWB__1_PRESENT 1 73 + #define DC__NUM_DWB__MAX 2 74 + #define DC__NUM_DWB__MAX__2 1 75 + #define DC__NUM_DIG 4 76 + #define DC__NUM_DIG__4 1 77 + #define DC__NUM_DIG__0_PRESENT 1 78 + #define DC__NUM_DIG__1_PRESENT 1 79 + #define DC__NUM_DIG__2_PRESENT 1 80 + #define DC__NUM_DIG__3_PRESENT 1 81 + #define DC__NUM_DIG__MAX 6 82 + #define DC__NUM_DIG__MAX__6 1 83 + #define DC__NUM_AUX 4 84 + #define DC__NUM_AUX__4 1 85 + #define DC__NUM_AUX__0_PRESENT 1 86 + #define DC__NUM_AUX__1_PRESENT 1 87 + #define DC__NUM_AUX__2_PRESENT 1 88 + #define DC__NUM_AUX__3_PRESENT 1 89 + #define DC__NUM_AUX__MAX 6 90 + #define DC__NUM_AUX__MAX__6 1 91 + #define DC__NUM_AUDIO_STREAMS 4 92 + #define DC__NUM_AUDIO_STREAMS__4 1 93 + #define DC__NUM_AUDIO_STREAMS__0_PRESENT 1 94 + #define DC__NUM_AUDIO_STREAMS__1_PRESENT 1 95 + #define DC__NUM_AUDIO_STREAMS__2_PRESENT 1 96 + #define DC__NUM_AUDIO_STREAMS__3_PRESENT 1 97 + #define DC__NUM_AUDIO_STREAMS__MAX 8 98 + #define DC__NUM_AUDIO_STREAMS__MAX__8 1 99 + #define DC__NUM_AUDIO_ENDPOINTS 6 100 + #define DC__NUM_AUDIO_ENDPOINTS__6 1 101 + #define DC__NUM_AUDIO_ENDPOINTS__0_PRESENT 1 102 + #define DC__NUM_AUDIO_ENDPOINTS__1_PRESENT 1 103 + #define DC__NUM_AUDIO_ENDPOINTS__2_PRESENT 1 104 + #define DC__NUM_AUDIO_ENDPOINTS__3_PRESENT 1 105 + #define DC__NUM_AUDIO_ENDPOINTS__4_PRESENT 1 106 + #define DC__NUM_AUDIO_ENDPOINTS__5_PRESENT 1 107 + #define DC__NUM_AUDIO_ENDPOINTS__MAX 8 108 + #define DC__NUM_AUDIO_ENDPOINTS__MAX__8 1 109 + #define DC__NUM_AUDIO_INPUT_STREAMS 0 110 + #define DC__NUM_AUDIO_INPUT_STREAMS__0 1 111 + #define DC__NUM_AUDIO_INPUT_STREAMS__MAX 8 112 + #define DC__NUM_AUDIO_INPUT_STREAMS__MAX__8 1 113 + #define DC__NUM_AUDIO_INPUT_ENDPOINTS 0 114 + #define DC__NUM_AUDIO_INPUT_ENDPOINTS__0 1 115 + #define DC__NUM_AUDIO_INPUT_ENDPOINTS__MAX 8 116 + #define DC__NUM_AUDIO_INPUT_ENDPOINTS__MAX__8 1 117 + #define DC__NUM_CURSOR 1 118 + #define DC__NUM_CURSOR__1 1 119 + #define DC__NUM_CURSOR__0_PRESENT 1 120 + #define DC__NUM_CURSOR__MAX 2 121 + #define DC__NUM_CURSOR__MAX__2 1 122 + #define DC__DIGITAL_BYPASS_PRESENT 0 123 + #define DC__DIGITAL_BYPASS_PRESENT__0 1 124 + #define DC__HCID_HWMAJVER 1 125 + #define DC__HCID_HWMAJVER__1 1 126 + #define DC__HCID_HWMINVER 0 127 + #define DC__HCID_HWMINVER__0 1 128 + #define DC__HCID_HWREV 0 129 + #define DC__HCID_HWREV__0 1 130 + #define DC__ROMSTRAP_PRESENT 0 131 + #define DC__ROMSTRAP_PRESENT__0 1 132 + #define DC__NUM_RBBMIF_DECODES 30 133 + #define DC__NUM_RBBMIF_DECODES__30 1 134 + #define DC__NUM_DBG_REGS 36 135 + #define DC__NUM_DBG_REGS__36 1 136 + #define DC__NUM_PIPES_UNDERLAY 0 137 + #define DC__NUM_PIPES_UNDERLAY__0 1 138 + #define DC__NUM_PIPES_UNDERLAY__MAX 2 139 + #define DC__NUM_PIPES_UNDERLAY__MAX__2 1 140 + #define DC__NUM_VCE_ENGINE 1 141 + #define DC__NUM_VCE_ENGINE__1 1 142 + #define DC__NUM_VCE_ENGINE__0_PRESENT 1 143 + #define DC__NUM_VCE_ENGINE__MAX 2 144 + #define DC__NUM_VCE_ENGINE__MAX__2 1 145 + #define DC__OTG_EXTERNAL_SYNC_PRESENT 0 146 + #define DC__OTG_EXTERNAL_SYNC_PRESENT__0 1 147 + #define DC__OTG_CRC_PRESENT 1 148 + #define DC__OTG_CRC_PRESENT__1 1 149 + #define DC__VIP_PRESENT 0 150 + #define DC__VIP_PRESENT__0 1 151 + #define DC__DTMTEST_PRESENT 0 152 + #define DC__DTMTEST_PRESENT__0 1 153 + #define DC__POWER_GATE_PRESENT 1 154 + #define DC__POWER_GATE_PRESENT__1 1 155 + #define DC__MEM_PG 1 156 + #define DC__MEM_PG__1 1 157 + #define DC__FMT_SRC_SEL_PRESENT 0 158 + #define DC__FMT_SRC_SEL_PRESENT__0 1 159 + #define DC__DIG_FEATURES__HDMI_PRESENT 1 160 + #define DC__DIG_FEATURES__HDMI_PRESENT__1 1 161 + #define DC__DIG_FEATURES__DP_PRESENT 1 162 + #define DC__DIG_FEATURES__DP_PRESENT__1 1 163 + #define DC__DIG_FEATURES__DP_MST_PRESENT 1 164 + #define DC__DIG_FEATURES__DP_MST_PRESENT__1 1 165 + #define DC__DIG_LP_FEATURES__HDMI_PRESENT 0 166 + #define DC__DIG_LP_FEATURES__HDMI_PRESENT__0 1 167 + #define DC__DIG_LP_FEATURES__DP_PRESENT 1 168 + #define DC__DIG_LP_FEATURES__DP_PRESENT__1 1 169 + #define DC__DIG_LP_FEATURES__DP_MST_PRESENT 0 170 + #define DC__DIG_LP_FEATURES__DP_MST_PRESENT__0 1 171 + #define DC__DIG_RESYNC_FIFO_SIZE 14 172 + #define DC__DIG_RESYNC_FIFO_SIZE__14 1 173 + #define DC__DIG_RESYNC_FIFO_SIZE__0_PRESENT 1 174 + #define DC__DIG_RESYNC_FIFO_SIZE__1_PRESENT 1 175 + #define DC__DIG_RESYNC_FIFO_SIZE__2_PRESENT 1 176 + #define DC__DIG_RESYNC_FIFO_SIZE__3_PRESENT 1 177 + #define DC__DIG_RESYNC_FIFO_SIZE__4_PRESENT 1 178 + #define DC__DIG_RESYNC_FIFO_SIZE__5_PRESENT 1 179 + #define DC__DIG_RESYNC_FIFO_SIZE__6_PRESENT 1 180 + #define DC__DIG_RESYNC_FIFO_SIZE__7_PRESENT 1 181 + #define DC__DIG_RESYNC_FIFO_SIZE__8_PRESENT 1 182 + #define DC__DIG_RESYNC_FIFO_SIZE__9_PRESENT 1 183 + #define DC__DIG_RESYNC_FIFO_SIZE__10_PRESENT 1 184 + #define DC__DIG_RESYNC_FIFO_SIZE__11_PRESENT 1 185 + #define DC__DIG_RESYNC_FIFO_SIZE__12_PRESENT 1 186 + #define DC__DIG_RESYNC_FIFO_SIZE__13_PRESENT 1 187 + #define DC__DIG_RESYNC_FIFO_SIZE__MAX 16 188 + #define DC__DIG_RESYNC_FIFO_SIZE__MAX__16 1 189 + #define DC__DAC_RESYNC_FIFO_SIZE 12 190 + #define DC__DAC_RESYNC_FIFO_SIZE__12 1 191 + #define DC__DAC_RESYNC_FIFO_SIZE__0_PRESENT 1 192 + #define DC__DAC_RESYNC_FIFO_SIZE__1_PRESENT 1 193 + #define DC__DAC_RESYNC_FIFO_SIZE__2_PRESENT 1 194 + #define DC__DAC_RESYNC_FIFO_SIZE__3_PRESENT 1 195 + #define DC__DAC_RESYNC_FIFO_SIZE__4_PRESENT 1 196 + #define DC__DAC_RESYNC_FIFO_SIZE__5_PRESENT 1 197 + #define DC__DAC_RESYNC_FIFO_SIZE__6_PRESENT 1 198 + #define DC__DAC_RESYNC_FIFO_SIZE__7_PRESENT 1 199 + #define DC__DAC_RESYNC_FIFO_SIZE__8_PRESENT 1 200 + #define DC__DAC_RESYNC_FIFO_SIZE__9_PRESENT 1 201 + #define DC__DAC_RESYNC_FIFO_SIZE__10_PRESENT 1 202 + #define DC__DAC_RESYNC_FIFO_SIZE__11_PRESENT 1 203 + #define DC__DAC_RESYNC_FIFO_SIZE__MAX 16 204 + #define DC__DAC_RESYNC_FIFO_SIZE__MAX__16 1 205 + #define DC__DVO_RESYNC_FIFO_SIZE 12 206 + #define DC__DVO_RESYNC_FIFO_SIZE__12 1 207 + #define DC__DVO_RESYNC_FIFO_SIZE__0_PRESENT 1 208 + #define DC__DVO_RESYNC_FIFO_SIZE__1_PRESENT 1 209 + #define DC__DVO_RESYNC_FIFO_SIZE__2_PRESENT 1 210 + #define DC__DVO_RESYNC_FIFO_SIZE__3_PRESENT 1 211 + #define DC__DVO_RESYNC_FIFO_SIZE__4_PRESENT 1 212 + #define DC__DVO_RESYNC_FIFO_SIZE__5_PRESENT 1 213 + #define DC__DVO_RESYNC_FIFO_SIZE__6_PRESENT 1 214 + #define DC__DVO_RESYNC_FIFO_SIZE__7_PRESENT 1 215 + #define DC__DVO_RESYNC_FIFO_SIZE__8_PRESENT 1 216 + #define DC__DVO_RESYNC_FIFO_SIZE__9_PRESENT 1 217 + #define DC__DVO_RESYNC_FIFO_SIZE__10_PRESENT 1 218 + #define DC__DVO_RESYNC_FIFO_SIZE__11_PRESENT 1 219 + #define DC__DVO_RESYNC_FIFO_SIZE__MAX 16 220 + #define DC__DVO_RESYNC_FIFO_SIZE__MAX__16 1 221 + #define DC__MEM_CDC_PRESENT 1 222 + #define DC__MEM_CDC_PRESENT__1 1 223 + #define DC__NUM_HPD 4 224 + #define DC__NUM_HPD__4 1 225 + #define DC__NUM_HPD__0_PRESENT 1 226 + #define DC__NUM_HPD__1_PRESENT 1 227 + #define DC__NUM_HPD__2_PRESENT 1 228 + #define DC__NUM_HPD__3_PRESENT 1 229 + #define DC__NUM_HPD__MAX 6 230 + #define DC__NUM_HPD__MAX__6 1 231 + #define DC__NUM_DDC_PAIRS 4 232 + #define DC__NUM_DDC_PAIRS__4 1 233 + #define DC__NUM_DDC_PAIRS__0_PRESENT 1 234 + #define DC__NUM_DDC_PAIRS__1_PRESENT 1 235 + #define DC__NUM_DDC_PAIRS__2_PRESENT 1 236 + #define DC__NUM_DDC_PAIRS__3_PRESENT 1 237 + #define DC__NUM_DDC_PAIRS__MAX 6 238 + #define DC__NUM_DDC_PAIRS__MAX__6 1 239 + #define DC__NUM_AUDIO_PLL 0 240 + #define DC__NUM_AUDIO_PLL__0 1 241 + #define DC__NUM_AUDIO_PLL__MAX 2 242 + #define DC__NUM_AUDIO_PLL__MAX__2 1 243 + #define DC__NUM_PIXEL_PLL 1 244 + #define DC__NUM_PIXEL_PLL__1 1 245 + #define DC__NUM_PIXEL_PLL__0_PRESENT 1 246 + #define DC__NUM_PIXEL_PLL__MAX 4 247 + #define DC__NUM_PIXEL_PLL__MAX__4 1 248 + #define DC__NUM_CASCADED_PLL 0 249 + #define DC__NUM_CASCADED_PLL__0 1 250 + #define DC__NUM_CASCADED_PLL__MAX 3 251 + #define DC__NUM_CASCADED_PLL__MAX__3 1 252 + #define DC__PIXCLK_FROM_PHYPLL 1 253 + #define DC__PIXCLK_FROM_PHYPLL__1 1 254 + #define DC__NB_STUTTER_MODE_PRESENT 0 255 + #define DC__NB_STUTTER_MODE_PRESENT__0 1 256 + #define DC__I2S0_AND_SPDIF0_PRESENT 0 257 + #define DC__I2S0_AND_SPDIF0_PRESENT__0 1 258 + #define DC__I2S1_PRESENT 0 259 + #define DC__I2S1_PRESENT__0 1 260 + #define DC__SPDIF1_PRESENT 0 261 + #define DC__SPDIF1_PRESENT__0 1 262 + #define DC__DSI_PRESENT 0 263 + #define DC__DSI_PRESENT__0 1 264 + #define DC__DACA_PRESENT 0 265 + #define DC__DACA_PRESENT__0 1 266 + #define DC__DACB_PRESENT 0 267 + #define DC__DACB_PRESENT__0 1 268 + #define DC__NUM_PIPES 4 269 + #define DC__NUM_PIPES__4 1 270 + #define DC__NUM_PIPES__0_PRESENT 1 271 + #define DC__NUM_PIPES__1_PRESENT 1 272 + #define DC__NUM_PIPES__2_PRESENT 1 273 + #define DC__NUM_PIPES__3_PRESENT 1 274 + #define DC__NUM_PIPES__MAX 6 275 + #define DC__NUM_PIPES__MAX__6 1 276 + #define DC__NUM_DIG_LP 0 277 + #define DC__NUM_DIG_LP__0 1 278 + #define DC__NUM_DIG_LP__MAX 2 279 + #define DC__NUM_DIG_LP__MAX__2 1 280 + #define DC__DPDEBUG_PRESENT 0 281 + #define DC__DPDEBUG_PRESENT__0 1 282 + #define DC__DISPLAY_WB_PRESENT 1 283 + #define DC__DISPLAY_WB_PRESENT__1 1 284 + #define DC__NUM_CWB 0 285 + #define DC__NUM_CWB__0 1 286 + #define DC__NUM_CWB__MAX 2 287 + #define DC__NUM_CWB__MAX__2 1 288 + #define DC__MVP_PRESENT 0 289 + #define DC__MVP_PRESENT__0 1 290 + #define DC__DVO_PRESENT 0 291 + #define DC__DVO_PRESENT__0 1 292 + #define DC__ABM_PRESENT 0 293 + #define DC__ABM_PRESENT__0 1 294 + #define DC__BPHYC_PLL_PRESENT 0 295 + #define DC__BPHYC_PLL_PRESENT__0 1 296 + #define DC__BPHYC_UNIPHY_PRESENT 0 297 + #define DC__BPHYC_UNIPHY_PRESENT__0 1 298 + #define DC__PHY_BROADCAST_PRESENT 0 299 + #define DC__PHY_BROADCAST_PRESENT__0 1 300 + #define DC__NUM_OF_DCRX_SD 0 301 + #define DC__NUM_OF_DCRX_SD__0 1 302 + #define DC__DVO_17BIT_MAPPING 0 303 + #define DC__DVO_17BIT_MAPPING__0 1 304 + #define DC__AVSYNC_PRESENT 0 305 + #define DC__AVSYNC_PRESENT__0 1 306 + #define DC__NUM_OF_DCRX_PORTS 0 307 + #define DC__NUM_OF_DCRX_PORTS__0 1 308 + #define DC__NUM_OF_DCRX_PORTS__MAX 1 309 + #define DC__NUM_OF_DCRX_PORTS__MAX__1 1 310 + #define DC__NUM_PHY 4 311 + #define DC__NUM_PHY__4 1 312 + #define DC__NUM_PHY__0_PRESENT 1 313 + #define DC__NUM_PHY__1_PRESENT 1 314 + #define DC__NUM_PHY__2_PRESENT 1 315 + #define DC__NUM_PHY__3_PRESENT 1 316 + #define DC__NUM_PHY__MAX 7 317 + #define DC__NUM_PHY__MAX__7 1 318 + #define DC__NUM_PHY_LP 0 319 + #define DC__NUM_PHY_LP__0 1 320 + #define DC__NUM_PHY_LP__MAX 2 321 + #define DC__NUM_PHY_LP__MAX__2 1 322 + #define DC__SYNC_CELL vid_sync_gf14lpp 323 + #define DC__SYNC_CELL__VID_SYNC_GF14LPP 1 324 + #define DC__USE_NEW_VSS 1 325 + #define DC__USE_NEW_VSS__1 1 326 + #define DC__SYNC_CELL_DISPCLK_NUM_LATCHES 6 327 + #define DC__SYNC_CELL_DISPCLK_NUM_LATCHES__6 1 328 + #define DC__SYNC_CELL_DVOCLK_NUM_LATCHES 6 329 + #define DC__SYNC_CELL_DVOCLK_NUM_LATCHES__6 1 330 + #define DC__SYNC_CELL_PIXCLK_NUM_LATCHES 6 331 + #define DC__SYNC_CELL_PIXCLK_NUM_LATCHES__6 1 332 + #define DC__SYNC_CELL_SYMCLK_NUM_LATCHES 6 333 + #define DC__SYNC_CELL_SYMCLK_NUM_LATCHES__6 1 334 + #define DC__SYNC_CELL_DPPCLK_NUM_LATCHES 6 335 + #define DC__SYNC_CELL_DPPCLK_NUM_LATCHES__6 1 336 + #define DC__SYNC_CELL_DPREFCLK_NUM_LATCHES 6 337 + #define DC__SYNC_CELL_DPREFCLK_NUM_LATCHES__6 1 338 + #define DC__SYNC_CELL_REFCLK_NUM_LATCHES 6 339 + #define DC__SYNC_CELL_REFCLK_NUM_LATCHES__6 1 340 + #define DC__SYNC_CELL_PCIE_REFCLK_NUM_LATCHES 6 341 + #define DC__SYNC_CELL_PCIE_REFCLK_NUM_LATCHES__6 1 342 + #define DC__SYNC_CELL_MVPCLK_NUM_LATCHES 6 343 + #define DC__SYNC_CELL_MVPCLK_NUM_LATCHES__6 1 344 + #define DC__SYNC_CELL_SCLK_NUM_LATCHES 6 345 + #define DC__SYNC_CELL_SCLK_NUM_LATCHES__6 1 346 + #define DC__SYNC_CELL_DCEFCLK_NUM_LATCHES 6 347 + #define DC__SYNC_CELL_DCEFCLK_NUM_LATCHES__6 1 348 + #define DC__SYNC_CELL_AMCLK_NUM_LATCHES 6 349 + #define DC__SYNC_CELL_AMCLK_NUM_LATCHES__6 1 350 + #define DC__SYNC_CELL_DSICLK_NUM_LATCHES 6 351 + #define DC__SYNC_CELL_DSICLK_NUM_LATCHES__6 1 352 + #define DC__SYNC_CELL_BYTECLK_NUM_LATCHES 6 353 + #define DC__SYNC_CELL_BYTECLK_NUM_LATCHES__6 1 354 + #define DC__SYNC_CELL_ESCCLK_NUM_LATCHES 6 355 + #define DC__SYNC_CELL_ESCCLK_NUM_LATCHES__6 1 356 + #define DC__SYNC_CELL_DB_CLK_NUM_LATCHES 6 357 + #define DC__SYNC_CELL_DB_CLK_NUM_LATCHES__6 1 358 + #define UNIPHYA_PRESENT 1 359 + #define UNIPHYA_PRESENT__1 1 360 + #define DC__UNIPHYA_PRESENT 1 361 + #define DC__UNIPHYA_PRESENT__1 1 362 + #define UNIPHYB_PRESENT 1 363 + #define UNIPHYB_PRESENT__1 1 364 + #define DC__UNIPHYB_PRESENT 1 365 + #define DC__UNIPHYB_PRESENT__1 1 366 + #define UNIPHYC_PRESENT 1 367 + #define UNIPHYC_PRESENT__1 1 368 + #define DC__UNIPHYC_PRESENT 1 369 + #define DC__UNIPHYC_PRESENT__1 1 370 + #define UNIPHYD_PRESENT 1 371 + #define UNIPHYD_PRESENT__1 1 372 + #define DC__UNIPHYD_PRESENT 1 373 + #define DC__UNIPHYD_PRESENT__1 1 374 + #define UNIPHYE_PRESENT 0 375 + #define UNIPHYE_PRESENT__0 1 376 + #define DC__UNIPHYE_PRESENT 0 377 + #define DC__UNIPHYE_PRESENT__0 1 378 + #define UNIPHYF_PRESENT 0 379 + #define UNIPHYF_PRESENT__0 1 380 + #define DC__UNIPHYF_PRESENT 0 381 + #define DC__UNIPHYF_PRESENT__0 1 382 + #define UNIPHYG_PRESENT 0 383 + #define UNIPHYG_PRESENT__0 1 384 + #define DC__UNIPHYG_PRESENT 0 385 + #define DC__UNIPHYG_PRESENT__0 1 386 + #define DC__TMDS_LINK tmds_link_dual 387 + #define DC__TMDS_LINK__TMDS_LINK_DUAL 1 388 + #define DC__WBSCL_PIXBW 8 389 + #define DC__WBSCL_PIXBW__8 1 390 + #define DC__DWB_CSC_PRESENT 0 391 + #define DC__DWB_CSC_PRESENT__0 1 392 + #define DC__DWB_LUMA_SCL_PRESENT 0 393 + #define DC__DWB_LUMA_SCL_PRESENT__0 1 394 + #define DC__DENTIST_INTERFACE_PRESENT 1 395 + #define DC__DENTIST_INTERFACE_PRESENT__1 1 396 + #define DC__GENERICA_PRESENT 1 397 + #define DC__GENERICA_PRESENT__1 1 398 + #define DC__GENERICB_PRESENT 1 399 + #define DC__GENERICB_PRESENT__1 1 400 + #define DC__GENERICC_PRESENT 0 401 + #define DC__GENERICC_PRESENT__0 1 402 + #define DC__GENERICD_PRESENT 0 403 + #define DC__GENERICD_PRESENT__0 1 404 + #define DC__GENERICE_PRESENT 0 405 + #define DC__GENERICE_PRESENT__0 1 406 + #define DC__GENERICF_PRESENT 0 407 + #define DC__GENERICF_PRESENT__0 1 408 + #define DC__GENERICG_PRESENT 0 409 + #define DC__GENERICG_PRESENT__0 1 410 + #define DC__UNIPHY_VOLTAGE_MODE 1 411 + #define DC__UNIPHY_VOLTAGE_MODE__1 1 412 + #define DC__BLON_TYPE dedicated 413 + #define DC__BLON_TYPE__DEDICATED 1 414 + #define DC__UNIPHY_STAGGER_CH_PRESENT 1 415 + #define DC__UNIPHY_STAGGER_CH_PRESENT__1 1 416 + #define DC__XDMA_PRESENT 0 417 + #define DC__XDMA_PRESENT__0 1 418 + #define XDMA__PRESENT 0 419 + #define XDMA__PRESENT__0 1 420 + #define DC__DP_MEM_PG 0 421 + #define DC__DP_MEM_PG__0 1 422 + #define DP__MEM_PG 0 423 + #define DP__MEM_PG__0 1 424 + #define DC__AFMT_MEM_PG 0 425 + #define DC__AFMT_MEM_PG__0 1 426 + #define AFMT__MEM_PG 0 427 + #define AFMT__MEM_PG__0 1 428 + #define DC__HDMI_MEM_PG 0 429 + #define DC__HDMI_MEM_PG__0 1 430 + #define HDMI__MEM_PG 0 431 + #define HDMI__MEM_PG__0 1 432 + #define DC__I2C_MEM_PG 0 433 + #define DC__I2C_MEM_PG__0 1 434 + #define I2C__MEM_PG 0 435 + #define I2C__MEM_PG__0 1 436 + #define DC__DSCL_MEM_PG 0 437 + #define DC__DSCL_MEM_PG__0 1 438 + #define DSCL__MEM_PG 0 439 + #define DSCL__MEM_PG__0 1 440 + #define DC__CM_MEM_PG 0 441 + #define DC__CM_MEM_PG__0 1 442 + #define CM__MEM_PG 0 443 + #define CM__MEM_PG__0 1 444 + #define DC__OBUF_MEM_PG 0 445 + #define DC__OBUF_MEM_PG__0 1 446 + #define OBUF__MEM_PG 0 447 + #define OBUF__MEM_PG__0 1 448 + #define DC__WBIF_MEM_PG 1 449 + #define DC__WBIF_MEM_PG__1 1 450 + #define WBIF__MEM_PG 1 451 + #define WBIF__MEM_PG__1 1 452 + #define DC__VGA_MEM_PG 0 453 + #define DC__VGA_MEM_PG__0 1 454 + #define VGA__MEM_PG 0 455 + #define VGA__MEM_PG__0 1 456 + #define DC__FMT_MEM_PG 0 457 + #define DC__FMT_MEM_PG__0 1 458 + #define FMT__MEM_PG 0 459 + #define FMT__MEM_PG__0 1 460 + #define DC__ODM_MEM_PG 0 461 + #define DC__ODM_MEM_PG__0 1 462 + #define ODM__MEM_PG 0 463 + #define ODM__MEM_PG__0 1 464 + #define DC__DSI_MEM_PG 0 465 + #define DC__DSI_MEM_PG__0 1 466 + #define DSI__MEM_PG 0 467 + #define DSI__MEM_PG__0 1 468 + #define DC__AZ_MEM_PG 1 469 + #define DC__AZ_MEM_PG__1 1 470 + #define AZ__MEM_PG 1 471 + #define AZ__MEM_PG__1 1 472 + #define DC__WBSCL_MEM1P1024X64QS_MEM_PG 1 473 + #define DC__WBSCL_MEM1P1024X64QS_MEM_PG__1 1 474 + #define WBSCL_MEM1P1024X64QS__MEM_PG 1 475 + #define WBSCL_MEM1P1024X64QS__MEM_PG__1 1 476 + #define DC__WBSCL_MEM1P528X64QS_MEM_PG 1 477 + #define DC__WBSCL_MEM1P528X64QS_MEM_PG__1 1 478 + #define WBSCL_MEM1P528X64QS__MEM_PG 1 479 + #define WBSCL_MEM1P528X64QS__MEM_PG__1 1 480 + #define DC__DMCU_MEM1P1024X32BQS_MEM_PG 1 481 + #define DC__DMCU_MEM1P1024X32BQS_MEM_PG__1 1 482 + #define DMCU_MEM1P1024X32BQS__MEM_PG 1 483 + #define DMCU_MEM1P1024X32BQS__MEM_PG__1 1 484 + #define DC__HUBBUB_SDP_TAG_INT_MEM_PG 0 485 + #define DC__HUBBUB_SDP_TAG_INT_MEM_PG__0 1 486 + #define HUBBUB_SDP_TAG_INT__MEM_PG 0 487 + #define HUBBUB_SDP_TAG_INT__MEM_PG__0 1 488 + #define DC__HUBBUB_SDP_TAG_EXT_MEM_PG 0 489 + #define DC__HUBBUB_SDP_TAG_EXT_MEM_PG__0 1 490 + #define HUBBUB_SDP_TAG_EXT__MEM_PG 0 491 + #define HUBBUB_SDP_TAG_EXT__MEM_PG__0 1 492 + #define DC__HUBBUB_RET_ZERO_MEM_PG 0 493 + #define DC__HUBBUB_RET_ZERO_MEM_PG__0 1 494 + #define HUBBUB_RET_ZERO__MEM_PG 0 495 + #define HUBBUB_RET_ZERO__MEM_PG__0 1 496 + #define DC__HUBBUB_RET_ROB_MEM_PG 0 497 + #define DC__HUBBUB_RET_ROB_MEM_PG__0 1 498 + #define HUBBUB_RET_ROB__MEM_PG 0 499 + #define HUBBUB_RET_ROB__MEM_PG__0 1 500 + #define DC__HUBPRET_CUR_ROB_MEM_PG 0 501 + #define DC__HUBPRET_CUR_ROB_MEM_PG__0 1 502 + #define HUBPRET_CUR_ROB__MEM_PG 0 503 + #define HUBPRET_CUR_ROB__MEM_PG__0 1 504 + #define DC__HUBPRET_CUR_CDC_MEM_PG 0 505 + #define DC__HUBPRET_CUR_CDC_MEM_PG__0 1 506 + #define HUBPRET_CUR_CDC__MEM_PG 0 507 + #define HUBPRET_CUR_CDC__MEM_PG__0 1 508 + #define DC__HUBPREQ_MPTE_MEM_PG 0 509 + #define DC__HUBPREQ_MPTE_MEM_PG__0 1 510 + #define HUBPREQ_MPTE__MEM_PG 0 511 + #define HUBPREQ_MPTE__MEM_PG__0 1 512 + #define DC__HUBPREQ_META_MEM_PG 0 513 + #define DC__HUBPREQ_META_MEM_PG__0 1 514 + #define HUBPREQ_META__MEM_PG 0 515 + #define HUBPREQ_META__MEM_PG__0 1 516 + #define DC__HUBPREQ_DPTE_MEM_PG 0 517 + #define DC__HUBPREQ_DPTE_MEM_PG__0 1 518 + #define HUBPREQ_DPTE__MEM_PG 0 519 + #define HUBPREQ_DPTE__MEM_PG__0 1 520 + #define DC__HUBPRET_DET_MEM_PG 0 521 + #define DC__HUBPRET_DET_MEM_PG__0 1 522 + #define HUBPRET_DET__MEM_PG 0 523 + #define HUBPRET_DET__MEM_PG__0 1 524 + #define DC__HUBPRET_PIX_CDC_MEM_PG 0 525 + #define DC__HUBPRET_PIX_CDC_MEM_PG__0 1 526 + #define HUBPRET_PIX_CDC__MEM_PG 0 527 + #define HUBPRET_PIX_CDC__MEM_PG__0 1 528 + #define DC__TOP_BLKS__DCCG 1 529 + #define DC__TOP_BLKS__DCHUBBUB 1 530 + #define DC__TOP_BLKS__DCHUBP 1 531 + #define DC__TOP_BLKS__HDA 1 532 + #define DC__TOP_BLKS__DIO 1 533 + #define DC__TOP_BLKS__DCIO 1 534 + #define DC__TOP_BLKS__DMU 1 535 + #define DC__TOP_BLKS__DPP 1 536 + #define DC__TOP_BLKS__MPC 1 537 + #define DC__TOP_BLKS__OPP 1 538 + #define DC__TOP_BLKS__OPTC 1 539 + #define DC__TOP_BLKS__MMHUBBUB 1 540 + #define DC__TOP_BLKS__WB 1 541 + #define DC__TOP_BLKS__MAX 13 542 + #define DC__TOP_BLKS__MAX__13 1 543 + #define DC__DCHUBP_DPP_SF_PIXEL_CREDITS 9 544 + #define DC__DCHUBP_DPP_SF_PIXEL_CREDITS__9 1 545 + #define DC__DPP_MPC_SF_PIXEL_CREDITS 9 546 + #define DC__DPP_MPC_SF_PIXEL_CREDITS__9 1 547 + #define DC__MPC_OPP_SF_PIXEL_CREDITS 8 548 + #define DC__MPC_OPP_SF_PIXEL_CREDITS__8 1 549 + #define DC__OPP_OPTC_SF_PIXEL_CREDITS 8 550 + #define DC__OPP_OPTC_SF_PIXEL_CREDITS__8 1 551 + #define DC__SFR_SFT_ROUND_TRIP_DELAY 5 552 + #define DC__SFR_SFT_ROUND_TRIP_DELAY__5 1 553 + #define DC__REPEATER_PROJECT_MAX 8 554 + #define DC__REPEATER_PROJECT_MAX__8 1 555 + #define DC__SURFACE_422_CAPABLE 0 556 + #define DC__SURFACE_422_CAPABLE__0 1 557 + #endif
+111
drivers/gpu/drm/amd/display/dc/dml/display_mode_enums.h
··· 1 + /* 2 + * Copyright 2017 Advanced Micro Devices, Inc. 3 + * 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: 10 + * 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 13 + * 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. 21 + * 22 + * Authors: AMD 23 + * 24 + */ 25 + #ifndef __DISPLAY_MODE_ENUMS_H__ 26 + #define __DISPLAY_MODE_ENUMS_H__ 27 + enum output_encoder_class { 28 + dm_dp = 0, 29 + dm_hdmi = 1, 30 + dm_wb = 2 31 + }; 32 + enum output_format_class { 33 + dm_444 = 0, 34 + dm_420 = 1 35 + }; 36 + enum source_format_class { 37 + dm_444_16 = 0, 38 + dm_444_32 = 1, 39 + dm_444_64 = 2, 40 + dm_420_8 = 3, 41 + dm_420_10 = 4, 42 + dm_422_8 = 5, 43 + dm_422_10 = 6 44 + }; 45 + enum output_bpc_class { 46 + dm_out_6 = 0, 47 + dm_out_8 = 1, 48 + dm_out_10 = 2, 49 + dm_out_12 = 3, 50 + dm_out_16 = 4 51 + }; 52 + enum scan_direction_class { 53 + dm_horz = 0, 54 + dm_vert = 1 55 + }; 56 + enum dm_swizzle_mode { 57 + dm_sw_linear = 0, 58 + dm_sw_256b_s = 1, 59 + dm_sw_256b_d = 2, 60 + dm_sw_SPARE_0 = 3, 61 + dm_sw_SPARE_1 = 4, 62 + dm_sw_4kb_s = 5, 63 + dm_sw_4kb_d = 6, 64 + dm_sw_SPARE_2 = 7, 65 + dm_sw_SPARE_3 = 8, 66 + dm_sw_64kb_s = 9, 67 + dm_sw_64kb_d = 10, 68 + dm_sw_SPARE_4 = 11, 69 + dm_sw_SPARE_5 = 12, 70 + dm_sw_var_s = 13, 71 + dm_sw_var_d = 14, 72 + dm_sw_SPARE_6 = 15, 73 + dm_sw_SPARE_7 = 16, 74 + dm_sw_64kb_s_t = 17, 75 + dm_sw_64kb_d_t = 18, 76 + dm_sw_SPARE_10 = 19, 77 + dm_sw_SPARE_11 = 20, 78 + dm_sw_4kb_s_x = 21, 79 + dm_sw_4kb_d_x = 22, 80 + dm_sw_SPARE_12 = 23, 81 + dm_sw_SPARE_13 = 24, 82 + dm_sw_64kb_s_x = 25, 83 + dm_sw_64kb_d_x = 26, 84 + dm_sw_SPARE_14 = 27, 85 + dm_sw_SPARE_15 = 28, 86 + dm_sw_var_s_x = 29, 87 + dm_sw_var_d_x = 30 88 + }; 89 + enum lb_depth { 90 + dm_lb_10 = 30, 91 + dm_lb_8 = 24, 92 + dm_lb_6 = 18, 93 + dm_lb_12 = 36 94 + }; 95 + enum voltage_state { 96 + dm_vmin = 0, 97 + dm_vmid = 1, 98 + dm_vnom = 2, 99 + dm_vmax = 3, 100 + dm_vmax_exceeded = 4 101 + }; 102 + enum source_macro_tile_size { 103 + dm_4k_tile = 0, 104 + dm_64k_tile = 1, 105 + dm_256k_tile = 2 106 + }; 107 + enum cursor_bpp { 108 + dm_cur_2bit = 0, 109 + dm_cur_32bit = 1 110 + }; 111 + #endif
+147
drivers/gpu/drm/amd/display/dc/dml/display_mode_lib.c
··· 1 + /* 2 + * Copyright 2017 Advanced Micro Devices, Inc. 3 + * 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: 10 + * 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 13 + * 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. 21 + * 22 + * Authors: AMD 23 + * 24 + */ 25 + 26 + #include "display_mode_lib.h" 27 + 28 + static void set_soc_bounding_box(struct _vcs_dpi_soc_bounding_box_st *soc, enum dml_project project) 29 + { 30 + if (project == DML_PROJECT_RAVEN1) { 31 + soc->sr_exit_time_us = 9.0; 32 + soc->sr_enter_plus_exit_time_us = 11.0; 33 + soc->urgent_latency_us = 4.0; 34 + soc->writeback_latency_us = 12.0; 35 + soc->ideal_dram_bw_after_urgent_percent = 80.0; 36 + soc->max_request_size_bytes = 256; 37 + 38 + soc->vmin.dcfclk_mhz = 300.0; 39 + soc->vmin.dispclk_mhz = 608.0; 40 + soc->vmin.dppclk_mhz = 435.0; 41 + soc->vmin.dram_bw_per_chan_gbps = 12.8; 42 + soc->vmin.phyclk_mhz = 540.0; 43 + soc->vmin.socclk_mhz = 208.0; 44 + 45 + soc->vmid.dcfclk_mhz = 600.0; 46 + soc->vmid.dispclk_mhz = 661.0; 47 + soc->vmid.dppclk_mhz = 661.0; 48 + soc->vmid.dram_bw_per_chan_gbps = 12.8; 49 + soc->vmid.phyclk_mhz = 540.0; 50 + soc->vmid.socclk_mhz = 208.0; 51 + 52 + soc->vnom.dcfclk_mhz = 600.0; 53 + soc->vnom.dispclk_mhz = 661.0; 54 + soc->vnom.dppclk_mhz = 661.0; 55 + soc->vnom.dram_bw_per_chan_gbps = 38.4; 56 + soc->vnom.phyclk_mhz = 810; 57 + soc->vnom.socclk_mhz = 208.0; 58 + 59 + soc->vmax.dcfclk_mhz = 600.0; 60 + soc->vmax.dispclk_mhz = 1086.0; 61 + soc->vmax.dppclk_mhz = 661.0; 62 + soc->vmax.dram_bw_per_chan_gbps = 38.4; 63 + soc->vmax.phyclk_mhz = 810.0; 64 + soc->vmax.socclk_mhz = 208.0; 65 + 66 + soc->downspread_percent = 0.5; 67 + soc->dram_page_open_time_ns = 50.0; 68 + soc->dram_rw_turnaround_time_ns = 17.5; 69 + soc->dram_return_buffer_per_channel_bytes = 8192; 70 + soc->round_trip_ping_latency_dcfclk_cycles = 128; 71 + soc->urgent_out_of_order_return_per_channel_bytes = 256; 72 + soc->channel_interleave_bytes = 256; 73 + soc->num_banks = 8; 74 + soc->num_chans = 2; 75 + soc->vmm_page_size_bytes = 4096; 76 + soc->dram_clock_change_latency_us = 17.0; 77 + soc->writeback_dram_clock_change_latency_us = 23.0; 78 + soc->return_bus_width_bytes = 64; 79 + } else { 80 + BREAK_TO_DEBUGGER(); /* Invalid Project Specified */ 81 + } 82 + } 83 + 84 + static void set_ip_params(struct _vcs_dpi_ip_params_st *ip, enum dml_project project) 85 + { 86 + if (project == DML_PROJECT_RAVEN1) { 87 + ip->rob_buffer_size_kbytes = 64; 88 + ip->det_buffer_size_kbytes = 164; 89 + ip->dpte_buffer_size_in_pte_reqs = 42; 90 + ip->dpp_output_buffer_pixels = 2560; 91 + ip->opp_output_buffer_lines = 1; 92 + ip->pixel_chunk_size_kbytes = 8; 93 + ip->pte_enable = 1; 94 + ip->pte_chunk_size_kbytes = 2; 95 + ip->meta_chunk_size_kbytes = 2; 96 + ip->writeback_chunk_size_kbytes = 2; 97 + ip->line_buffer_size_bits = 589824; 98 + ip->max_line_buffer_lines = 12; 99 + ip->IsLineBufferBppFixed = 0; 100 + ip->LineBufferFixedBpp = -1; 101 + ip->writeback_luma_buffer_size_kbytes = 12; 102 + ip->writeback_chroma_buffer_size_kbytes = 8; 103 + ip->max_num_dpp = 4; 104 + ip->max_num_wb = 2; 105 + ip->max_dchub_pscl_bw_pix_per_clk = 4; 106 + ip->max_pscl_lb_bw_pix_per_clk = 2; 107 + ip->max_lb_vscl_bw_pix_per_clk = 4; 108 + ip->max_vscl_hscl_bw_pix_per_clk = 4; 109 + ip->max_hscl_ratio = 4; 110 + ip->max_vscl_ratio = 4; 111 + ip->hscl_mults = 4; 112 + ip->vscl_mults = 4; 113 + ip->max_hscl_taps = 8; 114 + ip->max_vscl_taps = 8; 115 + ip->dispclk_ramp_margin_percent = 1; 116 + ip->underscan_factor = 1.10; 117 + ip->min_vblank_lines = 14; 118 + ip->dppclk_delay_subtotal = 90; 119 + ip->dispclk_delay_subtotal = 42; 120 + ip->dcfclk_cstate_latency = 10; 121 + ip->max_inter_dcn_tile_repeaters = 8; 122 + ip->can_vstartup_lines_exceed_vsync_plus_back_porch_lines_minus_one = 0; 123 + ip->bug_forcing_LC_req_same_size_fixed = 0; 124 + } else { 125 + BREAK_TO_DEBUGGER(); /* Invalid Project Specified */ 126 + } 127 + } 128 + 129 + static void set_mode_evaluation(struct _vcs_dpi_mode_evaluation_st *me, enum dml_project project) 130 + { 131 + if (project == DML_PROJECT_RAVEN1) { 132 + me->voltage_override = dm_vmin; 133 + } else { 134 + BREAK_TO_DEBUGGER(); /* Invalid Project Specified */ 135 + } 136 + } 137 + 138 + void dml_init_instance(struct display_mode_lib *lib, enum dml_project project) 139 + { 140 + if (lib->project != project) { 141 + set_soc_bounding_box(&lib->soc, project); 142 + set_ip_params(&lib->ip, project); 143 + set_mode_evaluation(&lib->me, project); 144 + lib->project = project; 145 + } 146 + } 147 +
+52
drivers/gpu/drm/amd/display/dc/dml/display_mode_lib.h
··· 1 + /* 2 + * Copyright 2017 Advanced Micro Devices, Inc. 3 + * 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: 10 + * 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 13 + * 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. 21 + * 22 + * Authors: AMD 23 + * 24 + */ 25 + #ifndef __DISPLAY_MODE_LIB_H__ 26 + #define __DISPLAY_MODE_LIB_H__ 27 + 28 + #include "dml_common_defs.h" 29 + #include "soc_bounding_box.h" 30 + #include "display_watermark.h" 31 + #include "display_pipe_clocks.h" 32 + #include "display_rq_dlg_calc.h" 33 + #include "display_mode_support.h" 34 + 35 + enum dml_project { 36 + DML_PROJECT_UNDEFINED, 37 + DML_PROJECT_RAVEN1 38 + }; 39 + 40 + struct display_mode_lib { 41 + struct _vcs_dpi_ip_params_st ip; 42 + struct _vcs_dpi_soc_bounding_box_st soc; 43 + struct _vcs_dpi_mode_evaluation_st me; 44 + enum dml_project project; 45 + struct dml_ms_internal_vars vars; 46 + struct _vcs_dpi_wm_calc_pipe_params_st wm_param[DC__NUM_PIPES__MAX]; 47 + struct dal_logger *logger; 48 + }; 49 + 50 + void dml_init_instance(struct display_mode_lib *lib, enum dml_project project); 51 + 52 + #endif
+429
drivers/gpu/drm/amd/display/dc/dml/display_mode_structs.h
··· 1 + /* 2 + * Copyright 2017 Advanced Micro Devices, Inc. 3 + * 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: 10 + * 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 13 + * 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. 21 + * 22 + * Authors: AMD 23 + * 24 + */ 25 + #ifndef __DISPLAY_MODE_STRUCTS_H__ 26 + #define __DISPLAY_MODE_STRUCTS_H__ 27 + 28 + struct _vcs_dpi_voltage_scaling_st { 29 + double dcfclk_mhz; 30 + double dispclk_mhz; 31 + double dppclk_mhz; 32 + double dram_bw_per_chan_gbps; 33 + double phyclk_mhz; 34 + double socclk_mhz; 35 + }; 36 + 37 + struct _vcs_dpi_soc_bounding_box_st { 38 + double sr_exit_time_us; 39 + double sr_enter_plus_exit_time_us; 40 + double urgent_latency_us; 41 + double writeback_latency_us; 42 + double ideal_dram_bw_after_urgent_percent; 43 + unsigned int max_request_size_bytes; 44 + struct _vcs_dpi_voltage_scaling_st vmin; 45 + struct _vcs_dpi_voltage_scaling_st vmid; 46 + struct _vcs_dpi_voltage_scaling_st vnom; 47 + struct _vcs_dpi_voltage_scaling_st vmax; 48 + double downspread_percent; 49 + double dram_page_open_time_ns; 50 + double dram_rw_turnaround_time_ns; 51 + double dram_return_buffer_per_channel_bytes; 52 + unsigned int round_trip_ping_latency_dcfclk_cycles; 53 + unsigned int urgent_out_of_order_return_per_channel_bytes; 54 + unsigned int channel_interleave_bytes; 55 + unsigned int num_banks; 56 + unsigned int num_chans; 57 + unsigned int vmm_page_size_bytes; 58 + double dram_clock_change_latency_us; 59 + double writeback_dram_clock_change_latency_us; 60 + unsigned int return_bus_width_bytes; 61 + }; 62 + 63 + struct _vcs_dpi_ip_params_st { 64 + unsigned int rob_buffer_size_kbytes; 65 + unsigned int det_buffer_size_kbytes; 66 + unsigned int dpte_buffer_size_in_pte_reqs; 67 + unsigned int dpp_output_buffer_pixels; 68 + unsigned int opp_output_buffer_lines; 69 + unsigned int pixel_chunk_size_kbytes; 70 + unsigned char pte_enable; 71 + unsigned int pte_chunk_size_kbytes; 72 + unsigned int meta_chunk_size_kbytes; 73 + unsigned int writeback_chunk_size_kbytes; 74 + unsigned int line_buffer_size_bits; 75 + unsigned int max_line_buffer_lines; 76 + unsigned int IsLineBufferBppFixed; 77 + unsigned int LineBufferFixedBpp; 78 + unsigned int writeback_luma_buffer_size_kbytes; 79 + unsigned int writeback_chroma_buffer_size_kbytes; 80 + unsigned int max_num_dpp; 81 + unsigned int max_num_wb; 82 + unsigned int max_dchub_pscl_bw_pix_per_clk; 83 + unsigned int max_pscl_lb_bw_pix_per_clk; 84 + unsigned int max_lb_vscl_bw_pix_per_clk; 85 + unsigned int max_vscl_hscl_bw_pix_per_clk; 86 + double max_hscl_ratio; 87 + double max_vscl_ratio; 88 + unsigned int hscl_mults; 89 + unsigned int vscl_mults; 90 + unsigned int max_hscl_taps; 91 + unsigned int max_vscl_taps; 92 + double dispclk_ramp_margin_percent; 93 + double underscan_factor; 94 + unsigned int min_vblank_lines; 95 + unsigned int dppclk_delay_subtotal; 96 + unsigned int dispclk_delay_subtotal; 97 + unsigned int dcfclk_cstate_latency; 98 + unsigned int max_inter_dcn_tile_repeaters; 99 + unsigned int can_vstartup_lines_exceed_vsync_plus_back_porch_lines_minus_one; 100 + unsigned int bug_forcing_LC_req_same_size_fixed; 101 + }; 102 + 103 + struct _vcs_dpi_display_pipe_source_params_st { 104 + int source_format; 105 + unsigned char dcc; 106 + unsigned int dcc_rate; 107 + unsigned char vm; 108 + int source_scan; 109 + int sw_mode; 110 + int macro_tile_size; 111 + unsigned char is_display_sw; 112 + unsigned int viewport_width; 113 + unsigned int viewport_height; 114 + unsigned int viewport_width_c; 115 + unsigned int viewport_height_c; 116 + unsigned int data_pitch; 117 + unsigned int data_pitch_c; 118 + unsigned int meta_pitch; 119 + unsigned int meta_pitch_c; 120 + unsigned int cur0_src_width; 121 + int cur0_bpp; 122 + unsigned char is_hsplit; 123 + unsigned int hsplit_grp; 124 + }; 125 + 126 + struct _vcs_dpi_display_output_params_st { 127 + int output_bpc; 128 + int output_type; 129 + int output_format; 130 + int output_standard; 131 + }; 132 + 133 + struct _vcs_dpi_display_bandwidth_st { 134 + double total_bw_consumed_gbps; 135 + double guaranteed_urgent_return_bw_gbps; 136 + }; 137 + 138 + struct _vcs_dpi_scaler_ratio_depth_st { 139 + double hscl_ratio; 140 + double vscl_ratio; 141 + double hscl_ratio_c; 142 + double vscl_ratio_c; 143 + double vinit; 144 + double vinit_c; 145 + double vinit_bot; 146 + double vinit_bot_c; 147 + int lb_depth; 148 + }; 149 + 150 + struct _vcs_dpi_scaler_taps_st { 151 + unsigned int htaps; 152 + unsigned int vtaps; 153 + unsigned int htaps_c; 154 + unsigned int vtaps_c; 155 + }; 156 + 157 + struct _vcs_dpi_display_pipe_dest_params_st { 158 + unsigned int recout_width; 159 + unsigned int recout_height; 160 + unsigned int full_recout_width; 161 + unsigned int full_recout_height; 162 + unsigned int hblank_start; 163 + unsigned int hblank_end; 164 + unsigned int vblank_start; 165 + unsigned int vblank_end; 166 + unsigned int htotal; 167 + unsigned int vtotal; 168 + unsigned int vactive; 169 + unsigned int vstartup_start; 170 + unsigned int vupdate_offset; 171 + unsigned int vupdate_width; 172 + unsigned int vready_offset; 173 + unsigned int vsync_plus_back_porch; 174 + unsigned char interlaced; 175 + unsigned char underscan; 176 + double pixel_rate_mhz; 177 + unsigned char syncronized_vblank_all_planes; 178 + }; 179 + 180 + struct _vcs_dpi_display_pipe_params_st { 181 + struct _vcs_dpi_display_pipe_source_params_st src; 182 + struct _vcs_dpi_display_pipe_dest_params_st dest; 183 + struct _vcs_dpi_scaler_ratio_depth_st scale_ratio_depth; 184 + struct _vcs_dpi_scaler_taps_st scale_taps; 185 + }; 186 + 187 + struct _vcs_dpi_display_clocks_and_cfg_st { 188 + int voltage; 189 + double dppclk_mhz; 190 + double refclk_mhz; 191 + double dispclk_mhz; 192 + double dcfclk_mhz; 193 + double socclk_mhz; 194 + }; 195 + 196 + struct _vcs_dpi_display_e2e_pipe_params_st { 197 + struct _vcs_dpi_display_pipe_params_st pipe; 198 + struct _vcs_dpi_display_output_params_st dout; 199 + struct _vcs_dpi_display_clocks_and_cfg_st clks_cfg; 200 + }; 201 + 202 + struct _vcs_dpi_dchub_buffer_sizing_st { 203 + unsigned int swath_width_y; 204 + unsigned int swath_height_y; 205 + unsigned int swath_height_c; 206 + unsigned int detail_buffer_size_y; 207 + }; 208 + 209 + struct _vcs_dpi_watermarks_perf_st { 210 + double stutter_eff_in_active_region_percent; 211 + double urgent_latency_supported_us; 212 + double non_urgent_latency_supported_us; 213 + double dram_clock_change_margin_us; 214 + double dram_access_eff_percent; 215 + }; 216 + 217 + struct _vcs_dpi_cstate_pstate_watermarks_st { 218 + double cstate_exit_us; 219 + double cstate_enter_plus_exit_us; 220 + double pstate_change_us; 221 + }; 222 + 223 + struct _vcs_dpi_wm_calc_pipe_params_st { 224 + unsigned int num_dpp; 225 + int voltage; 226 + int output_type; 227 + double dcfclk_mhz; 228 + double socclk_mhz; 229 + double dppclk_mhz; 230 + double pixclk_mhz; 231 + unsigned char interlace_en; 232 + unsigned char pte_enable; 233 + unsigned char dcc_enable; 234 + double dcc_rate; 235 + double bytes_per_pixel_c; 236 + double bytes_per_pixel_y; 237 + unsigned int swath_width_y; 238 + unsigned int swath_height_y; 239 + unsigned int swath_height_c; 240 + unsigned int det_buffer_size_y; 241 + double h_ratio; 242 + double v_ratio; 243 + unsigned int h_taps; 244 + unsigned int h_total; 245 + unsigned int v_total; 246 + unsigned int v_active; 247 + unsigned int e2e_index; 248 + double display_pipe_line_delivery_time; 249 + double read_bw; 250 + unsigned int lines_in_det_y; 251 + unsigned int lines_in_det_y_rounded_down_to_swath; 252 + double full_det_buffering_time; 253 + double dcfclk_deepsleep_mhz_per_plane; 254 + }; 255 + 256 + struct _vcs_dpi_vratio_pre_st { 257 + double vratio_pre_l; 258 + double vratio_pre_c; 259 + }; 260 + 261 + struct _vcs_dpi_display_data_rq_misc_params_st { 262 + unsigned int full_swath_bytes; 263 + unsigned int stored_swath_bytes; 264 + unsigned int blk256_height; 265 + unsigned int blk256_width; 266 + unsigned int req_height; 267 + unsigned int req_width; 268 + }; 269 + 270 + struct _vcs_dpi_display_data_rq_sizing_params_st { 271 + unsigned int chunk_bytes; 272 + unsigned int min_chunk_bytes; 273 + unsigned int meta_chunk_bytes; 274 + unsigned int min_meta_chunk_bytes; 275 + unsigned int mpte_group_bytes; 276 + unsigned int dpte_group_bytes; 277 + }; 278 + 279 + struct _vcs_dpi_display_data_rq_dlg_params_st { 280 + unsigned int swath_width_ub; 281 + unsigned int swath_height; 282 + unsigned int req_per_swath_ub; 283 + unsigned int meta_pte_bytes_per_frame_ub; 284 + unsigned int dpte_req_per_row_ub; 285 + unsigned int dpte_groups_per_row_ub; 286 + unsigned int dpte_row_height; 287 + unsigned int dpte_bytes_per_row_ub; 288 + unsigned int meta_chunks_per_row_ub; 289 + unsigned int meta_req_per_row_ub; 290 + unsigned int meta_row_height; 291 + unsigned int meta_bytes_per_row_ub; 292 + }; 293 + 294 + struct _vcs_dpi_display_cur_rq_dlg_params_st { 295 + unsigned char enable; 296 + unsigned int swath_height; 297 + unsigned int req_per_line; 298 + }; 299 + 300 + struct _vcs_dpi_display_rq_dlg_params_st { 301 + struct _vcs_dpi_display_data_rq_dlg_params_st rq_l; 302 + struct _vcs_dpi_display_data_rq_dlg_params_st rq_c; 303 + struct _vcs_dpi_display_cur_rq_dlg_params_st rq_cur0; 304 + }; 305 + 306 + struct _vcs_dpi_display_rq_sizing_params_st { 307 + struct _vcs_dpi_display_data_rq_sizing_params_st rq_l; 308 + struct _vcs_dpi_display_data_rq_sizing_params_st rq_c; 309 + }; 310 + 311 + struct _vcs_dpi_display_rq_misc_params_st { 312 + struct _vcs_dpi_display_data_rq_misc_params_st rq_l; 313 + struct _vcs_dpi_display_data_rq_misc_params_st rq_c; 314 + }; 315 + 316 + struct _vcs_dpi_display_rq_params_st { 317 + unsigned char yuv420; 318 + unsigned char yuv420_10bpc; 319 + struct _vcs_dpi_display_rq_misc_params_st misc; 320 + struct _vcs_dpi_display_rq_sizing_params_st sizing; 321 + struct _vcs_dpi_display_rq_dlg_params_st dlg; 322 + }; 323 + 324 + struct _vcs_dpi_display_dlg_regs_st { 325 + unsigned int refcyc_h_blank_end; 326 + unsigned int dlg_vblank_end; 327 + unsigned int min_dst_y_next_start; 328 + unsigned int refcyc_per_htotal; 329 + unsigned int refcyc_x_after_scaler; 330 + unsigned int dst_y_after_scaler; 331 + unsigned int dst_y_prefetch; 332 + unsigned int dst_y_per_vm_vblank; 333 + unsigned int dst_y_per_row_vblank; 334 + unsigned int ref_freq_to_pix_freq; 335 + unsigned int vratio_prefetch; 336 + unsigned int vratio_prefetch_c; 337 + unsigned int refcyc_per_pte_group_vblank_l; 338 + unsigned int refcyc_per_pte_group_vblank_c; 339 + unsigned int refcyc_per_meta_chunk_vblank_l; 340 + unsigned int refcyc_per_meta_chunk_vblank_c; 341 + unsigned int dst_y_per_pte_row_nom_l; 342 + unsigned int dst_y_per_pte_row_nom_c; 343 + unsigned int refcyc_per_pte_group_nom_l; 344 + unsigned int refcyc_per_pte_group_nom_c; 345 + unsigned int dst_y_per_meta_row_nom_l; 346 + unsigned int dst_y_per_meta_row_nom_c; 347 + unsigned int refcyc_per_meta_chunk_nom_l; 348 + unsigned int refcyc_per_meta_chunk_nom_c; 349 + unsigned int refcyc_per_line_delivery_pre_l; 350 + unsigned int refcyc_per_line_delivery_pre_c; 351 + unsigned int refcyc_per_line_delivery_l; 352 + unsigned int refcyc_per_line_delivery_c; 353 + unsigned int chunk_hdl_adjust_cur0; 354 + }; 355 + 356 + struct _vcs_dpi_display_ttu_regs_st { 357 + unsigned int qos_level_low_wm; 358 + unsigned int qos_level_high_wm; 359 + unsigned int min_ttu_vblank; 360 + unsigned int qos_level_flip; 361 + unsigned int refcyc_per_req_delivery_l; 362 + unsigned int refcyc_per_req_delivery_c; 363 + unsigned int refcyc_per_req_delivery_cur0; 364 + unsigned int refcyc_per_req_delivery_pre_l; 365 + unsigned int refcyc_per_req_delivery_pre_c; 366 + unsigned int refcyc_per_req_delivery_pre_cur0; 367 + unsigned int qos_level_fixed_l; 368 + unsigned int qos_level_fixed_c; 369 + unsigned int qos_level_fixed_cur0; 370 + unsigned int qos_ramp_disable_l; 371 + unsigned int qos_ramp_disable_c; 372 + unsigned int qos_ramp_disable_cur0; 373 + }; 374 + 375 + struct _vcs_dpi_display_data_rq_regs_st { 376 + unsigned int chunk_size; 377 + unsigned int min_chunk_size; 378 + unsigned int meta_chunk_size; 379 + unsigned int min_meta_chunk_size; 380 + unsigned int dpte_group_size; 381 + unsigned int mpte_group_size; 382 + unsigned int swath_height; 383 + unsigned int pte_row_height_linear; 384 + }; 385 + 386 + struct _vcs_dpi_display_rq_regs_st { 387 + struct _vcs_dpi_display_data_rq_regs_st rq_regs_l; 388 + struct _vcs_dpi_display_data_rq_regs_st rq_regs_c; 389 + unsigned int drq_expansion_mode; 390 + unsigned int prq_expansion_mode; 391 + unsigned int mrq_expansion_mode; 392 + unsigned int crq_expansion_mode; 393 + unsigned int plane1_base_address; 394 + }; 395 + 396 + struct _vcs_dpi_display_dlg_sys_params_st { 397 + double t_mclk_wm_us; 398 + double t_urg_wm_us; 399 + double t_sr_wm_us; 400 + double t_extra_us; 401 + double t_srx_delay_us; 402 + double deepsleep_dcfclk_mhz; 403 + double total_flip_bw; 404 + unsigned int total_flip_bytes; 405 + }; 406 + 407 + struct _vcs_dpi_display_dlg_prefetch_param_st { 408 + double prefetch_bw; 409 + unsigned int flip_bytes; 410 + }; 411 + 412 + struct _vcs_dpi_display_pipe_clock_st { 413 + double dcfclk_mhz; 414 + double dispclk_mhz; 415 + double dppclk_mhz[4]; 416 + unsigned char dppclk_div[4]; 417 + }; 418 + 419 + struct _vcs_dpi_display_arb_params_st { 420 + int max_req_outstanding; 421 + int min_req_outstanding; 422 + int sat_level_us; 423 + }; 424 + 425 + struct _vcs_dpi_mode_evaluation_st { 426 + int voltage_override; 427 + }; 428 + 429 + #endif /*__DISPLAY_MODE_STRUCTS_H__*/
+2326
drivers/gpu/drm/amd/display/dc/dml/display_mode_support.c
··· 1 + /* 2 + * Copyright 2017 Advanced Micro Devices, Inc. 3 + * 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: 10 + * 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 13 + * 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. 21 + * 22 + * Authors: AMD 23 + * 24 + */ 25 + 26 + #include "display_mode_support.h" 27 + #include "display_mode_lib.h" 28 + 29 + int dml_ms_check( 30 + struct display_mode_lib *mode_lib, 31 + struct _vcs_dpi_display_e2e_pipe_params_st *e2e, 32 + int num_pipes) 33 + { 34 + struct _vcs_dpi_ip_params_st *ip; 35 + struct _vcs_dpi_soc_bounding_box_st *soc; 36 + struct _vcs_dpi_mode_evaluation_st *me; 37 + struct dml_ms_internal_vars *v; 38 + int num_planes, i, j, ij, k, ijk; 39 + 40 + ip = &(mode_lib->ip); 41 + soc = &(mode_lib->soc); 42 + me = &(mode_lib->me); 43 + v = &(mode_lib->vars); 44 + num_planes = dml_wm_e2e_to_wm(mode_lib, e2e, num_pipes, v->planes); 45 + 46 + //instantiating variables to zero 47 + v->MacroTileBlockWidthC = 0; 48 + v->SwathWidthGranularityC = 0; 49 + 50 + v->DCFCLKPerState[5] = 0; 51 + v->DCFCLKPerState[4] = 0; 52 + v->DCFCLKPerState[3] = 0; 53 + v->DCFCLKPerState[2] = 0; 54 + v->DCFCLKPerState[1] = 0; 55 + v->DCFCLKPerState[0] = 0; 56 + 57 + if (soc->vmin.dcfclk_mhz > 0) { 58 + v->DCFCLKPerState[5] = soc->vmin.dcfclk_mhz; 59 + v->DCFCLKPerState[4] = soc->vmin.dcfclk_mhz; 60 + v->DCFCLKPerState[3] = soc->vmin.dcfclk_mhz; 61 + v->DCFCLKPerState[2] = soc->vmin.dcfclk_mhz; 62 + v->DCFCLKPerState[1] = soc->vmin.dcfclk_mhz; 63 + v->DCFCLKPerState[0] = soc->vmin.dcfclk_mhz; 64 + } 65 + 66 + if (soc->vmid.dcfclk_mhz > 0) { 67 + v->DCFCLKPerState[5] = soc->vmid.dcfclk_mhz; 68 + v->DCFCLKPerState[4] = soc->vmid.dcfclk_mhz; 69 + v->DCFCLKPerState[3] = soc->vmid.dcfclk_mhz; 70 + v->DCFCLKPerState[2] = soc->vmid.dcfclk_mhz; 71 + v->DCFCLKPerState[1] = soc->vmid.dcfclk_mhz; 72 + } 73 + 74 + if (soc->vnom.dcfclk_mhz > 0) { 75 + v->DCFCLKPerState[5] = soc->vnom.dcfclk_mhz; 76 + v->DCFCLKPerState[4] = soc->vnom.dcfclk_mhz; 77 + v->DCFCLKPerState[3] = soc->vnom.dcfclk_mhz; 78 + v->DCFCLKPerState[2] = soc->vnom.dcfclk_mhz; 79 + } 80 + 81 + if (soc->vmax.dcfclk_mhz > 0) { 82 + v->DCFCLKPerState[5] = soc->vmax.dcfclk_mhz; 83 + v->DCFCLKPerState[4] = soc->vmax.dcfclk_mhz; 84 + v->DCFCLKPerState[3] = soc->vmax.dcfclk_mhz; 85 + } 86 + 87 + v->FabricAndDRAMBandwidthPerState[5] = 0; 88 + v->FabricAndDRAMBandwidthPerState[4] = 0; 89 + v->FabricAndDRAMBandwidthPerState[3] = 0; 90 + v->FabricAndDRAMBandwidthPerState[2] = 0; 91 + v->FabricAndDRAMBandwidthPerState[1] = 0; 92 + v->FabricAndDRAMBandwidthPerState[0] = 0; 93 + 94 + if (soc->vmin.dram_bw_per_chan_gbps > 0) { 95 + v->FabricAndDRAMBandwidthPerState[5] = soc->vmin.dram_bw_per_chan_gbps; 96 + v->FabricAndDRAMBandwidthPerState[4] = soc->vmin.dram_bw_per_chan_gbps; 97 + v->FabricAndDRAMBandwidthPerState[3] = soc->vmin.dram_bw_per_chan_gbps; 98 + v->FabricAndDRAMBandwidthPerState[2] = soc->vmin.dram_bw_per_chan_gbps; 99 + v->FabricAndDRAMBandwidthPerState[1] = soc->vmin.dram_bw_per_chan_gbps; 100 + v->FabricAndDRAMBandwidthPerState[0] = soc->vmin.dram_bw_per_chan_gbps; 101 + } 102 + 103 + if (soc->vmid.dram_bw_per_chan_gbps > 0) { 104 + v->FabricAndDRAMBandwidthPerState[5] = soc->vmid.dram_bw_per_chan_gbps; 105 + v->FabricAndDRAMBandwidthPerState[4] = soc->vmid.dram_bw_per_chan_gbps; 106 + v->FabricAndDRAMBandwidthPerState[3] = soc->vmid.dram_bw_per_chan_gbps; 107 + v->FabricAndDRAMBandwidthPerState[2] = soc->vmid.dram_bw_per_chan_gbps; 108 + v->FabricAndDRAMBandwidthPerState[1] = soc->vmid.dram_bw_per_chan_gbps; 109 + } 110 + 111 + if (soc->vnom.dram_bw_per_chan_gbps > 0) { 112 + v->FabricAndDRAMBandwidthPerState[5] = soc->vnom.dram_bw_per_chan_gbps; 113 + v->FabricAndDRAMBandwidthPerState[4] = soc->vnom.dram_bw_per_chan_gbps; 114 + v->FabricAndDRAMBandwidthPerState[3] = soc->vnom.dram_bw_per_chan_gbps; 115 + v->FabricAndDRAMBandwidthPerState[2] = soc->vnom.dram_bw_per_chan_gbps; 116 + } 117 + 118 + if (soc->vmax.dram_bw_per_chan_gbps > 0) { 119 + v->FabricAndDRAMBandwidthPerState[5] = soc->vmax.dram_bw_per_chan_gbps; 120 + v->FabricAndDRAMBandwidthPerState[4] = soc->vmax.dram_bw_per_chan_gbps; 121 + v->FabricAndDRAMBandwidthPerState[3] = soc->vmax.dram_bw_per_chan_gbps; 122 + } 123 + 124 + v->PHYCLKPerState[5] = 0; 125 + v->PHYCLKPerState[4] = 0; 126 + v->PHYCLKPerState[3] = 0; 127 + v->PHYCLKPerState[2] = 0; 128 + v->PHYCLKPerState[1] = 0; 129 + v->PHYCLKPerState[0] = 0; 130 + 131 + if (soc->vmin.phyclk_mhz > 0) { 132 + v->PHYCLKPerState[5] = soc->vmin.phyclk_mhz; 133 + v->PHYCLKPerState[4] = soc->vmin.phyclk_mhz; 134 + v->PHYCLKPerState[3] = soc->vmin.phyclk_mhz; 135 + v->PHYCLKPerState[2] = soc->vmin.phyclk_mhz; 136 + v->PHYCLKPerState[1] = soc->vmin.phyclk_mhz; 137 + v->PHYCLKPerState[0] = soc->vmin.phyclk_mhz; 138 + } 139 + 140 + if (soc->vmid.phyclk_mhz > 0) { 141 + v->PHYCLKPerState[5] = soc->vmid.phyclk_mhz; 142 + v->PHYCLKPerState[4] = soc->vmid.phyclk_mhz; 143 + v->PHYCLKPerState[3] = soc->vmid.phyclk_mhz; 144 + v->PHYCLKPerState[2] = soc->vmid.phyclk_mhz; 145 + v->PHYCLKPerState[1] = soc->vmid.phyclk_mhz; 146 + } 147 + 148 + if (soc->vnom.phyclk_mhz > 0) { 149 + v->PHYCLKPerState[5] = soc->vnom.phyclk_mhz; 150 + v->PHYCLKPerState[4] = soc->vnom.phyclk_mhz; 151 + v->PHYCLKPerState[3] = soc->vnom.phyclk_mhz; 152 + v->PHYCLKPerState[2] = soc->vnom.phyclk_mhz; 153 + } 154 + 155 + if (soc->vmax.phyclk_mhz > 0) { 156 + v->PHYCLKPerState[5] = soc->vmax.phyclk_mhz; 157 + v->PHYCLKPerState[4] = soc->vmax.phyclk_mhz; 158 + v->PHYCLKPerState[3] = soc->vmax.phyclk_mhz; 159 + } 160 + 161 + v->MaxDispclk[5] = 0; 162 + v->MaxDispclk[4] = 0; 163 + v->MaxDispclk[3] = 0; 164 + v->MaxDispclk[2] = 0; 165 + v->MaxDispclk[1] = 0; 166 + v->MaxDispclk[0] = 0; 167 + 168 + if (soc->vmin.dispclk_mhz > 0) { 169 + v->MaxDispclk[5] = soc->vmin.dispclk_mhz; 170 + v->MaxDispclk[4] = soc->vmin.dispclk_mhz; 171 + v->MaxDispclk[3] = soc->vmin.dispclk_mhz; 172 + v->MaxDispclk[2] = soc->vmin.dispclk_mhz; 173 + v->MaxDispclk[1] = soc->vmin.dispclk_mhz; 174 + v->MaxDispclk[0] = soc->vmin.dispclk_mhz; 175 + } 176 + 177 + if (soc->vmid.dispclk_mhz > 0) { 178 + v->MaxDispclk[5] = soc->vmid.dispclk_mhz; 179 + v->MaxDispclk[4] = soc->vmid.dispclk_mhz; 180 + v->MaxDispclk[3] = soc->vmid.dispclk_mhz; 181 + v->MaxDispclk[2] = soc->vmid.dispclk_mhz; 182 + v->MaxDispclk[1] = soc->vmid.dispclk_mhz; 183 + } 184 + 185 + if (soc->vnom.dispclk_mhz > 0) { 186 + v->MaxDispclk[5] = soc->vnom.dispclk_mhz; 187 + v->MaxDispclk[4] = soc->vnom.dispclk_mhz; 188 + v->MaxDispclk[3] = soc->vnom.dispclk_mhz; 189 + v->MaxDispclk[2] = soc->vnom.dispclk_mhz; 190 + } 191 + 192 + if (soc->vmax.dispclk_mhz > 0) { 193 + v->MaxDispclk[5] = soc->vmax.dispclk_mhz; 194 + v->MaxDispclk[4] = soc->vmax.dispclk_mhz; 195 + v->MaxDispclk[3] = soc->vmax.dispclk_mhz; 196 + } 197 + 198 + v->MaxDppclk[5] = 0; 199 + v->MaxDppclk[4] = 0; 200 + v->MaxDppclk[3] = 0; 201 + v->MaxDppclk[2] = 0; 202 + v->MaxDppclk[1] = 0; 203 + v->MaxDppclk[0] = 0; 204 + 205 + if (soc->vmin.dppclk_mhz > 0) { 206 + v->MaxDppclk[5] = soc->vmin.dppclk_mhz; 207 + v->MaxDppclk[4] = soc->vmin.dppclk_mhz; 208 + v->MaxDppclk[3] = soc->vmin.dppclk_mhz; 209 + v->MaxDppclk[2] = soc->vmin.dppclk_mhz; 210 + v->MaxDppclk[1] = soc->vmin.dppclk_mhz; 211 + v->MaxDppclk[0] = soc->vmin.dppclk_mhz; 212 + } 213 + 214 + if (soc->vmid.dppclk_mhz > 0) { 215 + v->MaxDppclk[5] = soc->vmid.dppclk_mhz; 216 + v->MaxDppclk[4] = soc->vmid.dppclk_mhz; 217 + v->MaxDppclk[3] = soc->vmid.dppclk_mhz; 218 + v->MaxDppclk[2] = soc->vmid.dppclk_mhz; 219 + v->MaxDppclk[1] = soc->vmid.dppclk_mhz; 220 + } 221 + 222 + if (soc->vnom.dppclk_mhz > 0) { 223 + v->MaxDppclk[5] = soc->vnom.dppclk_mhz; 224 + v->MaxDppclk[4] = soc->vnom.dppclk_mhz; 225 + v->MaxDppclk[3] = soc->vnom.dppclk_mhz; 226 + v->MaxDppclk[2] = soc->vnom.dppclk_mhz; 227 + } 228 + 229 + if (soc->vmax.dppclk_mhz > 0) { 230 + v->MaxDppclk[5] = soc->vmax.dppclk_mhz; 231 + v->MaxDppclk[4] = soc->vmax.dppclk_mhz; 232 + v->MaxDppclk[3] = soc->vmax.dppclk_mhz; 233 + } 234 + 235 + if (me->voltage_override == dm_vmax) { 236 + v->VoltageOverrideLevel = NumberOfStates - 1; 237 + } else if (me->voltage_override == dm_vnom) { 238 + v->VoltageOverrideLevel = NumberOfStates - 2; 239 + } else if (me->voltage_override == dm_vmid) { 240 + v->VoltageOverrideLevel = NumberOfStates - 3; 241 + } else { 242 + v->VoltageOverrideLevel = 0; 243 + } 244 + 245 + // Scale Ratio Support Check 246 + 247 + v->ScaleRatioSupport = 1; 248 + 249 + for (k = 0; k < num_planes; k++) { 250 + struct _vcs_dpi_scaler_ratio_depth_st scale_ratio_depth = 251 + e2e[v->planes[k].e2e_index].pipe.scale_ratio_depth; 252 + struct _vcs_dpi_scaler_taps_st scale_taps = 253 + e2e[v->planes[k].e2e_index].pipe.scale_taps; 254 + struct _vcs_dpi_display_pipe_source_params_st src = 255 + e2e[v->planes[k].e2e_index].pipe.src; 256 + 257 + if (scale_ratio_depth.hscl_ratio > ip->max_hscl_ratio 258 + || scale_ratio_depth.vscl_ratio > ip->max_vscl_ratio 259 + || scale_ratio_depth.hscl_ratio > scale_taps.htaps 260 + || scale_ratio_depth.vscl_ratio > scale_taps.vtaps 261 + || (src.source_format != dm_444_64 && src.source_format != dm_444_32 262 + && src.source_format != dm_444_16 263 + && ((scale_ratio_depth.hscl_ratio / 2 264 + > scale_taps.htaps_c) 265 + || (scale_ratio_depth.vscl_ratio / 2 266 + > scale_taps.vtaps_c)))) 267 + 268 + { 269 + v->ScaleRatioSupport = 0; 270 + } 271 + } 272 + 273 + // Source Format, Pixel Format and Scan Support Check 274 + 275 + v->SourceFormatPixelAndScanSupport = 1; 276 + 277 + for (k = 0; k < num_planes; k++) { 278 + struct _vcs_dpi_display_pipe_source_params_st src = 279 + e2e[v->planes[k].e2e_index].pipe.src; 280 + 281 + if ((src.sw_mode == dm_sw_linear && src.source_scan != dm_horz) 282 + || ((src.sw_mode == dm_sw_4kb_d || src.sw_mode == dm_sw_4kb_d_x 283 + || src.sw_mode == dm_sw_64kb_d 284 + || src.sw_mode == dm_sw_64kb_d_t 285 + || src.sw_mode == dm_sw_64kb_d_x 286 + || src.sw_mode == dm_sw_var_d 287 + || src.sw_mode == dm_sw_var_d_x) 288 + && (src.source_format != dm_444_64))) { 289 + v->SourceFormatPixelAndScanSupport = 0; 290 + } 291 + } 292 + 293 + // Bandwidth Support Check 294 + 295 + for (k = 0; k < num_planes; k++) { 296 + struct _vcs_dpi_display_pipe_source_params_st src = 297 + e2e[v->planes[k].e2e_index].pipe.src; 298 + 299 + if (src.source_scan == dm_horz) { 300 + v->SwathWidthYSingleDPP[k] = src.viewport_width; 301 + } else { 302 + v->SwathWidthYSingleDPP[k] = src.viewport_height; 303 + } 304 + 305 + if (src.source_format == dm_444_64) { 306 + v->BytePerPixelInDETY[k] = 8; 307 + v->BytePerPixelInDETC[k] = 0; 308 + } else if (src.source_format == dm_444_32) { 309 + v->BytePerPixelInDETY[k] = 4; 310 + v->BytePerPixelInDETC[k] = 0; 311 + } else if (src.source_format == dm_444_16) { 312 + v->BytePerPixelInDETY[k] = 2; 313 + v->BytePerPixelInDETC[k] = 0; 314 + } else if (src.source_format == dm_420_8) { 315 + v->BytePerPixelInDETY[k] = 1; 316 + v->BytePerPixelInDETC[k] = 2; 317 + } else { 318 + v->BytePerPixelInDETY[k] = 4.00 / 3.00; 319 + v->BytePerPixelInDETC[k] = 8.00 / 3.00; 320 + } 321 + } 322 + 323 + v->TotalReadBandwidthConsumedGBytePerSecond = 0; 324 + 325 + for (k = 0; k < num_planes; k++) { 326 + struct _vcs_dpi_display_pipe_source_params_st src = 327 + e2e[v->planes[k].e2e_index].pipe.src; 328 + struct _vcs_dpi_display_pipe_dest_params_st dest = 329 + e2e[v->planes[k].e2e_index].pipe.dest; 330 + struct _vcs_dpi_scaler_ratio_depth_st scale_ratio_depth = 331 + e2e[v->planes[k].e2e_index].pipe.scale_ratio_depth; 332 + 333 + v->ReadBandwidth[k] = 334 + v->SwathWidthYSingleDPP[k] 335 + * (dml_ceil_ex(v->BytePerPixelInDETY[k], 1) 336 + * scale_ratio_depth.vscl_ratio 337 + + (dml_ceil_ex( 338 + v->BytePerPixelInDETC[k], 339 + 2) / 2) 340 + * (scale_ratio_depth.vscl_ratio 341 + / 2)) 342 + / (dest.htotal / dest.pixel_rate_mhz); 343 + 344 + if (src.dcc == 1) { 345 + v->ReadBandwidth[k] = v->ReadBandwidth[k] * (1 + 1 / 256); 346 + } 347 + 348 + if (ip->pte_enable == 1 && src.source_scan != dm_horz 349 + && (src.sw_mode == dm_sw_4kb_s || src.sw_mode == dm_sw_4kb_s_x 350 + || src.sw_mode == dm_sw_4kb_d 351 + || src.sw_mode == dm_sw_4kb_d_x)) { 352 + v->ReadBandwidth[k] = v->ReadBandwidth[k] * (1 + 1 / 64); 353 + } else if (ip->pte_enable == 1 && src.source_scan == dm_horz 354 + && (src.source_format == dm_444_64 || src.source_format == dm_444_32) 355 + && (src.sw_mode == dm_sw_64kb_s || src.sw_mode == dm_sw_64kb_s_t 356 + || src.sw_mode == dm_sw_64kb_s_x 357 + || src.sw_mode == dm_sw_64kb_d 358 + || src.sw_mode == dm_sw_64kb_d_t 359 + || src.sw_mode == dm_sw_64kb_d_x)) { 360 + v->ReadBandwidth[k] = v->ReadBandwidth[k] * (1 + 1 / 256); 361 + } else if (ip->pte_enable == 1) { 362 + v->ReadBandwidth[k] = v->ReadBandwidth[k] * (1 + 1 / 512); 363 + } 364 + 365 + v->TotalReadBandwidthConsumedGBytePerSecond = 366 + v->TotalReadBandwidthConsumedGBytePerSecond 367 + + v->ReadBandwidth[k] / 1000; 368 + } 369 + 370 + v->TotalWriteBandwidthConsumedGBytePerSecond = 0; 371 + 372 + for (k = 0; k < num_planes; k++) { 373 + struct _vcs_dpi_display_pipe_dest_params_st dest = 374 + e2e[v->planes[k].e2e_index].pipe.dest; 375 + struct _vcs_dpi_display_output_params_st dout = e2e[v->planes[k].e2e_index].dout; 376 + 377 + if (dout.output_type == dm_wb && dout.output_format == dm_444) { 378 + v->WriteBandwidth[k] = dest.recout_width 379 + / (dest.htotal / dest.pixel_rate_mhz) * 4; 380 + } else if (dout.output_type == dm_wb) { 381 + v->WriteBandwidth[k] = dest.recout_width 382 + / (dest.htotal / dest.pixel_rate_mhz) * 1.5; 383 + } else { 384 + v->WriteBandwidth[k] = 0; 385 + } 386 + 387 + v->TotalWriteBandwidthConsumedGBytePerSecond = 388 + v->TotalWriteBandwidthConsumedGBytePerSecond 389 + + v->WriteBandwidth[k] / 1000; 390 + } 391 + 392 + v->TotalBandwidthConsumedGBytePerSecond = v->TotalReadBandwidthConsumedGBytePerSecond 393 + + v->TotalWriteBandwidthConsumedGBytePerSecond; 394 + 395 + v->DCCEnabledInAnyPlane = 0; 396 + 397 + for (k = 0; k < num_planes; k++) { 398 + struct _vcs_dpi_display_pipe_source_params_st src = 399 + e2e[v->planes[k].e2e_index].pipe.src; 400 + 401 + if (src.dcc == 1) { 402 + v->DCCEnabledInAnyPlane = 1; 403 + } 404 + } 405 + 406 + for (i = 0; i < NumberOfStatesPlusTwo; i++) { 407 + v->ReturnBWToDCNPerState = dml_min( 408 + soc->return_bus_width_bytes * v->DCFCLKPerState[i], 409 + v->FabricAndDRAMBandwidthPerState[i] * 1000 410 + * soc->ideal_dram_bw_after_urgent_percent / 100); 411 + 412 + v->ReturnBWPerState[i] = v->ReturnBWToDCNPerState; 413 + 414 + if (v->DCCEnabledInAnyPlane == 1 415 + && v->ReturnBWToDCNPerState 416 + > (v->DCFCLKPerState[i] 417 + * soc->return_bus_width_bytes / 4)) { 418 + v->ReturnBWPerState[i] = 419 + dml_min( 420 + v->ReturnBWPerState[i], 421 + v->ReturnBWToDCNPerState * 4 422 + * (1 423 + - soc->urgent_latency_us 424 + / ((ip->rob_buffer_size_kbytes 425 + - ip->pixel_chunk_size_kbytes) 426 + * 1024 427 + / (v->ReturnBWToDCNPerState 428 + - v->DCFCLKPerState[i] 429 + * soc->return_bus_width_bytes 430 + / 4) 431 + + soc->urgent_latency_us))); 432 + } 433 + 434 + v->CriticalPoint = 2 * soc->return_bus_width_bytes * v->DCFCLKPerState[i] 435 + * soc->urgent_latency_us 436 + / (v->ReturnBWToDCNPerState * soc->urgent_latency_us 437 + + (ip->rob_buffer_size_kbytes 438 + - ip->pixel_chunk_size_kbytes) 439 + * 1024); 440 + 441 + if (v->DCCEnabledInAnyPlane == 1 && v->CriticalPoint > 1 && v->CriticalPoint < 4) { 442 + v->ReturnBWPerState[i] = 443 + dml_min( 444 + v->ReturnBWPerState[i], 445 + 4 * v->ReturnBWToDCNPerState 446 + * (ip->rob_buffer_size_kbytes 447 + - ip->pixel_chunk_size_kbytes) 448 + * 1024 449 + * soc->return_bus_width_bytes 450 + * v->DCFCLKPerState[i] 451 + * soc->urgent_latency_us 452 + / dml_pow( 453 + (v->ReturnBWToDCNPerState 454 + * soc->urgent_latency_us 455 + + (ip->rob_buffer_size_kbytes 456 + - ip->pixel_chunk_size_kbytes) 457 + * 1024), 458 + 2)); 459 + } 460 + 461 + v->ReturnBWToDCNPerState = dml_min( 462 + soc->return_bus_width_bytes * v->DCFCLKPerState[i], 463 + v->FabricAndDRAMBandwidthPerState[i] * 1000); 464 + 465 + if (v->DCCEnabledInAnyPlane == 1 466 + && v->ReturnBWToDCNPerState 467 + > (v->DCFCLKPerState[i] 468 + * soc->return_bus_width_bytes / 4)) { 469 + v->ReturnBWPerState[i] = 470 + dml_min( 471 + v->ReturnBWPerState[i], 472 + v->ReturnBWToDCNPerState * 4 473 + * (1 474 + - soc->urgent_latency_us 475 + / ((ip->rob_buffer_size_kbytes 476 + - ip->pixel_chunk_size_kbytes) 477 + * 1024 478 + / (v->ReturnBWToDCNPerState 479 + - v->DCFCLKPerState[i] 480 + * soc->return_bus_width_bytes 481 + / 4) 482 + + soc->urgent_latency_us))); 483 + } 484 + 485 + v->CriticalPoint = 2 * soc->return_bus_width_bytes * v->DCFCLKPerState[i] 486 + * soc->urgent_latency_us 487 + / (v->ReturnBWToDCNPerState * soc->urgent_latency_us 488 + + (ip->rob_buffer_size_kbytes 489 + - ip->pixel_chunk_size_kbytes) 490 + * 1024); 491 + 492 + if (v->DCCEnabledInAnyPlane == 1 && v->CriticalPoint > 1 && v->CriticalPoint < 4) { 493 + v->ReturnBWPerState[i] = 494 + dml_min( 495 + v->ReturnBWPerState[i], 496 + 4 * v->ReturnBWToDCNPerState 497 + * (ip->rob_buffer_size_kbytes 498 + - ip->pixel_chunk_size_kbytes) 499 + * 1024 500 + * soc->return_bus_width_bytes 501 + * v->DCFCLKPerState[i] 502 + * soc->urgent_latency_us 503 + / dml_pow( 504 + (v->ReturnBWToDCNPerState 505 + * soc->urgent_latency_us 506 + + (ip->rob_buffer_size_kbytes 507 + - ip->pixel_chunk_size_kbytes) 508 + * 1024), 509 + 2)); 510 + } 511 + } 512 + 513 + for (i = 0; i < NumberOfStatesPlusTwo; i++) { 514 + if ((v->TotalReadBandwidthConsumedGBytePerSecond * 1000 <= v->ReturnBWPerState[i]) 515 + && (v->TotalBandwidthConsumedGBytePerSecond * 1000 516 + <= v->FabricAndDRAMBandwidthPerState[i] * 1000 517 + * soc->ideal_dram_bw_after_urgent_percent 518 + / 100)) { 519 + v->BandwidthSupport[i] = 1; 520 + } else { 521 + v->BandwidthSupport[i] = 0; 522 + } 523 + } 524 + 525 + // Writeback Latency support check 526 + 527 + v->WritebackLatencySupport = 1; 528 + 529 + for (k = 0; k < num_planes; k++) { 530 + struct _vcs_dpi_display_pipe_dest_params_st dest = 531 + e2e[v->planes[k].e2e_index].pipe.dest; 532 + struct _vcs_dpi_display_output_params_st dout = e2e[v->planes[k].e2e_index].dout; 533 + 534 + if (dout.output_type == dm_wb && dout.output_format == dm_444 535 + && (dest.recout_width / (dest.htotal / dest.pixel_rate_mhz) * 4) 536 + > ((ip->writeback_luma_buffer_size_kbytes 537 + + ip->writeback_chroma_buffer_size_kbytes) 538 + * 1024 / soc->writeback_latency_us)) { 539 + v->WritebackLatencySupport = 0; 540 + } else if (dout.output_type == dm_wb 541 + && (dest.recout_width / (dest.htotal / dest.pixel_rate_mhz)) 542 + > (dml_min( 543 + ip->writeback_luma_buffer_size_kbytes, 544 + 2 545 + * ip->writeback_chroma_buffer_size_kbytes) 546 + * 1024 / soc->writeback_latency_us)) { 547 + v->WritebackLatencySupport = 0; 548 + } 549 + } 550 + 551 + // Re-ordering Buffer Support Check 552 + 553 + for (i = 0; i < NumberOfStatesPlusTwo; i++) { 554 + v->UrgentRoundTripAndOutOfOrderLatencyPerState[i] = 555 + (soc->round_trip_ping_latency_dcfclk_cycles + 32) 556 + / v->DCFCLKPerState[i] 557 + + soc->urgent_out_of_order_return_per_channel_bytes 558 + * soc->num_chans 559 + / v->ReturnBWPerState[i]; 560 + 561 + if ((ip->rob_buffer_size_kbytes - ip->pixel_chunk_size_kbytes) * 1024 562 + / v->ReturnBWPerState[i] 563 + > v->UrgentRoundTripAndOutOfOrderLatencyPerState[i]) { 564 + v->ROBSupport[i] = 1; 565 + } else { 566 + v->ROBSupport[i] = 0; 567 + } 568 + } 569 + 570 + // Display IO Support Check 571 + 572 + for (k = 0; k < num_planes; k++) { 573 + struct _vcs_dpi_display_pipe_dest_params_st dest = 574 + e2e[v->planes[k].e2e_index].pipe.dest; 575 + struct _vcs_dpi_display_output_params_st dout = e2e[v->planes[k].e2e_index].dout; 576 + 577 + if (dout.output_format == dm_420) { 578 + v->RequiredOutputBW = dest.pixel_rate_mhz * 3 / 2; 579 + } else { 580 + v->RequiredOutputBW = dest.pixel_rate_mhz * 3; 581 + } 582 + 583 + if (dout.output_type == dm_hdmi) { 584 + v->RequiredPHYCLK[k] = v->RequiredOutputBW / 3; 585 + } else if (dout.output_type == dm_dp) { 586 + v->RequiredPHYCLK[k] = v->RequiredOutputBW / 4; 587 + } else { 588 + v->RequiredPHYCLK[k] = 0; 589 + } 590 + } 591 + 592 + for (i = 0; i < NumberOfStatesPlusTwo; i++) { 593 + v->DIOSupport[i] = 1; 594 + 595 + for (k = 0; k < num_planes; k++) { 596 + struct _vcs_dpi_display_output_params_st dout = 597 + e2e[v->planes[k].e2e_index].dout; 598 + 599 + if ((v->RequiredPHYCLK[k] > v->PHYCLKPerState[i]) 600 + || (dout.output_type == dm_hdmi 601 + && v->RequiredPHYCLK[k] > 600)) { 602 + v->DIOSupport[i] = 0; 603 + } 604 + } 605 + } 606 + 607 + // Total Available Writeback Support Check 608 + 609 + v->TotalNumberOfActiveWriteback = 0; 610 + 611 + for (k = 0; k < num_planes; k++) { 612 + struct _vcs_dpi_display_output_params_st dout = e2e[v->planes[k].e2e_index].dout; 613 + 614 + if (dout.output_type == dm_wb) { 615 + v->TotalNumberOfActiveWriteback = v->TotalNumberOfActiveWriteback + 1; 616 + } 617 + } 618 + 619 + if (v->TotalNumberOfActiveWriteback <= ip->max_num_wb) { 620 + v->TotalAvailableWritebackSupport = 1; 621 + } else { 622 + v->TotalAvailableWritebackSupport = 0; 623 + } 624 + 625 + // Maximum DISPCLK/DPPCLK Support check 626 + 627 + for (k = 0; k < num_planes; k++) { 628 + struct _vcs_dpi_display_pipe_dest_params_st dest = 629 + e2e[v->planes[k].e2e_index].pipe.dest; 630 + struct _vcs_dpi_scaler_ratio_depth_st scale_ratio_depth = 631 + e2e[v->planes[k].e2e_index].pipe.scale_ratio_depth; 632 + struct _vcs_dpi_scaler_taps_st scale_taps = 633 + e2e[v->planes[k].e2e_index].pipe.scale_taps; 634 + 635 + if (scale_ratio_depth.hscl_ratio > 1) { 636 + v->PSCL_FACTOR[k] = dml_min( 637 + ip->max_dchub_pscl_bw_pix_per_clk, 638 + ip->max_pscl_lb_bw_pix_per_clk 639 + * scale_ratio_depth.hscl_ratio 640 + / dml_ceil_ex(scale_taps.htaps / 6, 1)); 641 + } else { 642 + v->PSCL_FACTOR[k] = dml_min( 643 + ip->max_dchub_pscl_bw_pix_per_clk, 644 + ip->max_pscl_lb_bw_pix_per_clk); 645 + } 646 + 647 + if (v->BytePerPixelInDETC[k] == 0) { 648 + v->PSCL_FACTOR_CHROMA[k] = 0; 649 + v->MinDPPCLKUsingSingleDPP[k] = 650 + dest.pixel_rate_mhz 651 + * dml_max( 652 + scale_taps.vtaps / 6 653 + * dml_min( 654 + 1, 655 + scale_ratio_depth.hscl_ratio), 656 + dml_max( 657 + scale_ratio_depth.hscl_ratio 658 + * scale_ratio_depth.vscl_ratio 659 + / v->PSCL_FACTOR[k], 660 + 1)); 661 + 662 + } else { 663 + if (scale_ratio_depth.hscl_ratio / 2 > 1) { 664 + v->PSCL_FACTOR_CHROMA[k] = dml_min( 665 + ip->max_dchub_pscl_bw_pix_per_clk, 666 + ip->max_pscl_lb_bw_pix_per_clk 667 + * scale_ratio_depth.hscl_ratio / 2 668 + / dml_ceil_ex( 669 + scale_taps.htaps_c 670 + / 6, 671 + 1)); 672 + } else { 673 + v->PSCL_FACTOR_CHROMA[k] = dml_min( 674 + ip->max_dchub_pscl_bw_pix_per_clk, 675 + ip->max_pscl_lb_bw_pix_per_clk); 676 + } 677 + v->MinDPPCLKUsingSingleDPP[k] = 678 + dest.pixel_rate_mhz 679 + * dml_max( 680 + dml_max( 681 + scale_taps.vtaps 682 + / 6 683 + * dml_min( 684 + 1, 685 + scale_ratio_depth.hscl_ratio), 686 + scale_ratio_depth.hscl_ratio 687 + * scale_ratio_depth.vscl_ratio 688 + / v->PSCL_FACTOR[k]), 689 + dml_max( 690 + dml_max( 691 + scale_taps.vtaps_c 692 + / 6 693 + * dml_min( 694 + 1, 695 + scale_ratio_depth.hscl_ratio 696 + / 2), 697 + scale_ratio_depth.hscl_ratio 698 + * scale_ratio_depth.vscl_ratio 699 + / 4 700 + / v->PSCL_FACTOR_CHROMA[k]), 701 + 1)); 702 + 703 + } 704 + } 705 + 706 + for (k = 0; k < num_planes; k++) { 707 + struct _vcs_dpi_display_pipe_source_params_st src = 708 + e2e[v->planes[k].e2e_index].pipe.src; 709 + struct _vcs_dpi_scaler_ratio_depth_st scale_ratio_depth = 710 + e2e[v->planes[k].e2e_index].pipe.scale_ratio_depth; 711 + struct _vcs_dpi_scaler_taps_st scale_taps = 712 + e2e[v->planes[k].e2e_index].pipe.scale_taps; 713 + 714 + if (src.source_format == dm_444_64 || src.source_format == dm_444_32 715 + || src.source_format == dm_444_16) { 716 + if (src.sw_mode == dm_sw_linear) { 717 + v->Read256BlockHeightY[k] = 1; 718 + } else if (src.source_format == dm_444_64) { 719 + v->Read256BlockHeightY[k] = 4; 720 + } else { 721 + v->Read256BlockHeightY[k] = 8; 722 + } 723 + 724 + v->Read256BlockWidthY[k] = 256 / dml_ceil_ex(v->BytePerPixelInDETY[k], 1) 725 + / v->Read256BlockHeightY[k]; 726 + v->Read256BlockHeightC[k] = 0; 727 + v->Read256BlockWidthC[k] = 0; 728 + } else { 729 + if (src.sw_mode == dm_sw_linear) { 730 + v->Read256BlockHeightY[k] = 1; 731 + v->Read256BlockHeightC[k] = 1; 732 + } else if (src.source_format == dm_420_8) { 733 + v->Read256BlockHeightY[k] = 16; 734 + v->Read256BlockHeightC[k] = 8; 735 + } else { 736 + v->Read256BlockHeightY[k] = 8; 737 + v->Read256BlockHeightC[k] = 8; 738 + } 739 + 740 + v->Read256BlockWidthY[k] = 256 / dml_ceil_ex(v->BytePerPixelInDETY[k], 1) 741 + / v->Read256BlockHeightY[k]; 742 + v->Read256BlockWidthC[k] = 256 / dml_ceil_ex(v->BytePerPixelInDETC[k], 2) 743 + / v->Read256BlockHeightC[k]; 744 + } 745 + 746 + if (src.source_scan == dm_horz) { 747 + v->MaxSwathHeightY[k] = v->Read256BlockHeightY[k]; 748 + v->MaxSwathHeightC[k] = v->Read256BlockHeightC[k]; 749 + } else { 750 + v->MaxSwathHeightY[k] = v->Read256BlockWidthY[k]; 751 + v->MaxSwathHeightC[k] = v->Read256BlockWidthC[k]; 752 + } 753 + 754 + if (src.source_format == dm_444_64 || src.source_format == dm_444_32 755 + || src.source_format == dm_444_16) { 756 + if (src.sw_mode == dm_sw_linear 757 + || (src.source_format == dm_444_64 758 + && (src.sw_mode == dm_sw_4kb_s 759 + || src.sw_mode 760 + == dm_sw_4kb_s_x 761 + || src.sw_mode 762 + == dm_sw_64kb_s 763 + || src.sw_mode 764 + == dm_sw_64kb_s_t 765 + || src.sw_mode 766 + == dm_sw_64kb_s_x 767 + || src.sw_mode 768 + == dm_sw_var_s 769 + || src.sw_mode 770 + == dm_sw_var_s_x) 771 + && src.source_scan == dm_horz)) { 772 + v->MinSwathHeightY[k] = v->MaxSwathHeightY[k]; 773 + } else { 774 + v->MinSwathHeightY[k] = v->MaxSwathHeightY[k] / 2; 775 + } 776 + v->MinSwathHeightC[k] = v->MaxSwathHeightC[k]; 777 + } else { 778 + if (src.sw_mode == dm_sw_linear) { 779 + v->MinSwathHeightY[k] = v->MaxSwathHeightY[k]; 780 + v->MinSwathHeightC[k] = v->MaxSwathHeightC[k]; 781 + } else if (src.source_format == dm_420_8 && src.source_scan == dm_horz) { 782 + v->MinSwathHeightY[k] = v->MaxSwathHeightY[k] / 2; 783 + if (ip->bug_forcing_LC_req_same_size_fixed == 1) { 784 + v->MinSwathHeightC[k] = v->MaxSwathHeightC[k]; 785 + } else { 786 + v->MinSwathHeightC[k] = v->MaxSwathHeightC[k] / 2; 787 + } 788 + } else if (src.source_format == dm_420_10 && src.source_scan == dm_horz) { 789 + v->MinSwathHeightC[k] = v->MaxSwathHeightC[k] / 2; 790 + if (ip->bug_forcing_LC_req_same_size_fixed == 1) { 791 + v->MinSwathHeightY[k] = v->MaxSwathHeightY[k]; 792 + } else { 793 + v->MinSwathHeightY[k] = v->MaxSwathHeightY[k] / 2; 794 + } 795 + } else { 796 + v->MinSwathHeightY[k] = v->MaxSwathHeightY[k]; 797 + v->MinSwathHeightC[k] = v->MaxSwathHeightC[k]; 798 + } 799 + } 800 + 801 + if (src.sw_mode == dm_sw_linear) { 802 + v->MaximumSwathWidth = 8192; 803 + } else { 804 + v->MaximumSwathWidth = 5120; 805 + } 806 + 807 + v->NumberOfDPPRequiredForDETSize = 808 + dml_ceil_ex( 809 + v->SwathWidthYSingleDPP[k] 810 + / dml_min( 811 + v->MaximumSwathWidth, 812 + ip->det_buffer_size_kbytes 813 + * 1024 814 + / 2 815 + / (v->BytePerPixelInDETY[k] 816 + * v->MinSwathHeightY[k] 817 + + v->BytePerPixelInDETC[k] 818 + / 2 819 + * v->MinSwathHeightC[k])), 820 + 1); 821 + 822 + if (v->BytePerPixelInDETC[k] == 0) { 823 + v->NumberOfDPPRequiredForLBSize = 824 + dml_ceil_ex( 825 + (scale_taps.vtaps 826 + + dml_max( 827 + dml_ceil_ex( 828 + scale_ratio_depth.vscl_ratio, 829 + 1) 830 + - 2, 831 + 0)) 832 + * v->SwathWidthYSingleDPP[k] 833 + / dml_max( 834 + scale_ratio_depth.hscl_ratio, 835 + 1) 836 + * scale_ratio_depth.lb_depth 837 + / ip->line_buffer_size_bits, 838 + 1); 839 + } else { 840 + v->NumberOfDPPRequiredForLBSize = 841 + dml_max( 842 + dml_ceil_ex( 843 + (scale_taps.vtaps 844 + + dml_max( 845 + dml_ceil_ex( 846 + scale_ratio_depth.vscl_ratio, 847 + 1) 848 + - 2, 849 + 0)) 850 + * v->SwathWidthYSingleDPP[k] 851 + / dml_max( 852 + scale_ratio_depth.hscl_ratio, 853 + 1) 854 + * scale_ratio_depth.lb_depth 855 + / ip->line_buffer_size_bits, 856 + 1), 857 + dml_ceil_ex( 858 + (scale_taps.vtaps_c 859 + + dml_max( 860 + dml_ceil_ex( 861 + scale_ratio_depth.vscl_ratio 862 + / 2, 863 + 1) 864 + - 2, 865 + 0)) 866 + * v->SwathWidthYSingleDPP[k] 867 + / 2 868 + / dml_max( 869 + scale_ratio_depth.hscl_ratio 870 + / 2, 871 + 1) 872 + * scale_ratio_depth.lb_depth 873 + / ip->line_buffer_size_bits, 874 + 1)); 875 + } 876 + 877 + v->NumberOfDPPRequiredForDETAndLBSize[k] = dml_max( 878 + v->NumberOfDPPRequiredForDETSize, 879 + v->NumberOfDPPRequiredForLBSize); 880 + 881 + } 882 + 883 + for (i = 0; i < NumberOfStatesPlusTwo; i++) { 884 + for (j = 0; j < 2; j++) { 885 + v->TotalNumberOfActiveDPP[j * NumberOfStatesPlusTwo + i] = 0; 886 + v->RequiredDISPCLK[j * NumberOfStatesPlusTwo + i] = 0; 887 + v->DISPCLK_DPPCLK_Support[j * NumberOfStatesPlusTwo + i] = 1; 888 + 889 + for (k = 0; k < num_planes; k++) { 890 + struct _vcs_dpi_display_pipe_dest_params_st dest = 891 + e2e[v->planes[k].e2e_index].pipe.dest; 892 + ijk = k * 2 * NumberOfStatesPlusTwo + j * NumberOfStatesPlusTwo + i; 893 + 894 + v->MinDispclkUsingSingleDPP = dml_max( 895 + dest.pixel_rate_mhz, 896 + v->MinDPPCLKUsingSingleDPP[k] * (j + 1)) 897 + * (1 + soc->downspread_percent / 100); 898 + v->MinDispclkUsingDualDPP = dml_max( 899 + dest.pixel_rate_mhz, 900 + v->MinDPPCLKUsingSingleDPP[k] / 2 * (j + 1)) 901 + * (1 + soc->downspread_percent / 100); 902 + 903 + if (i < NumberOfStates) { 904 + v->MinDispclkUsingSingleDPP = 905 + v->MinDispclkUsingSingleDPP 906 + * (1 907 + + ip->dispclk_ramp_margin_percent 908 + / 100); 909 + v->MinDispclkUsingDualDPP = 910 + v->MinDispclkUsingDualDPP 911 + * (1 912 + + ip->dispclk_ramp_margin_percent 913 + / 100); 914 + } 915 + 916 + if (v->MinDispclkUsingSingleDPP 917 + <= dml_min( 918 + v->MaxDispclk[i], 919 + (j + 1) * v->MaxDppclk[i]) 920 + && v->NumberOfDPPRequiredForDETAndLBSize[k] <= 1) { 921 + v->NoOfDPP[ijk] = 1; 922 + v->RequiredDISPCLK[j * NumberOfStatesPlusTwo + i] = dml_max( 923 + v->RequiredDISPCLK[j * NumberOfStatesPlusTwo 924 + + i], 925 + v->MinDispclkUsingSingleDPP); 926 + } else if (v->MinDispclkUsingDualDPP 927 + <= dml_min( 928 + v->MaxDispclk[i], 929 + (j + 1) * v->MaxDppclk[i])) { 930 + v->NoOfDPP[ijk] = 2; 931 + v->RequiredDISPCLK[j * NumberOfStatesPlusTwo + i] = dml_max( 932 + v->RequiredDISPCLK[j * NumberOfStatesPlusTwo 933 + + i], 934 + v->MinDispclkUsingDualDPP); 935 + } else { 936 + v->NoOfDPP[ijk] = 2; 937 + v->RequiredDISPCLK[j * NumberOfStatesPlusTwo + i] = dml_max( 938 + v->RequiredDISPCLK[j * NumberOfStatesPlusTwo 939 + + i], 940 + v->MinDispclkUsingDualDPP); 941 + v->DISPCLK_DPPCLK_Support[j * NumberOfStatesPlusTwo + i] = 942 + 0; 943 + } 944 + 945 + v->TotalNumberOfActiveDPP[j * NumberOfStatesPlusTwo + i] = 946 + v->TotalNumberOfActiveDPP[j * NumberOfStatesPlusTwo 947 + + i] + v->NoOfDPP[ijk]; 948 + } 949 + 950 + if (v->TotalNumberOfActiveDPP[j * NumberOfStatesPlusTwo + i] 951 + > ip->max_num_dpp) { 952 + v->TotalNumberOfActiveDPP[j * NumberOfStatesPlusTwo + i] = 0; 953 + v->RequiredDISPCLK[j * NumberOfStatesPlusTwo + i] = 0; 954 + v->DISPCLK_DPPCLK_Support[j * NumberOfStatesPlusTwo + i] = 1; 955 + 956 + for (k = 0; k < num_planes; k++) { 957 + struct _vcs_dpi_display_pipe_dest_params_st dest = 958 + e2e[v->planes[k].e2e_index].pipe.dest; 959 + ijk = k * 2 * NumberOfStatesPlusTwo 960 + + j * NumberOfStatesPlusTwo + i; 961 + 962 + v->MinDispclkUsingSingleDPP = dml_max( 963 + dest.pixel_rate_mhz, 964 + v->MinDPPCLKUsingSingleDPP[k] * (j + 1)) 965 + * (1 + soc->downspread_percent / 100); 966 + v->MinDispclkUsingDualDPP = dml_max( 967 + dest.pixel_rate_mhz, 968 + v->MinDPPCLKUsingSingleDPP[k] / 2 * (j + 1)) 969 + * (1 + soc->downspread_percent / 100); 970 + 971 + if (i < NumberOfStates) { 972 + v->MinDispclkUsingSingleDPP = 973 + v->MinDispclkUsingSingleDPP 974 + * (1 975 + + ip->dispclk_ramp_margin_percent 976 + / 100); 977 + v->MinDispclkUsingDualDPP = 978 + v->MinDispclkUsingDualDPP 979 + * (1 980 + + ip->dispclk_ramp_margin_percent 981 + / 100); 982 + } 983 + 984 + if (v->NumberOfDPPRequiredForDETAndLBSize[k] <= 1) { 985 + v->NoOfDPP[ijk] = 1; 986 + v->RequiredDISPCLK[j * NumberOfStatesPlusTwo + i] = 987 + dml_max( 988 + v->RequiredDISPCLK[j 989 + * NumberOfStatesPlusTwo 990 + + i], 991 + v->MinDispclkUsingSingleDPP); 992 + if (v->MinDispclkUsingSingleDPP 993 + > dml_min( 994 + v->MaxDispclk[i], 995 + (j + 1) 996 + * v->MaxDppclk[i])) { 997 + v->DISPCLK_DPPCLK_Support[j 998 + * NumberOfStatesPlusTwo + i] = 999 + 0; 1000 + } 1001 + } else { 1002 + v->NoOfDPP[ijk] = 2; 1003 + v->RequiredDISPCLK[j * NumberOfStatesPlusTwo + i] = 1004 + dml_max( 1005 + v->RequiredDISPCLK[j 1006 + * NumberOfStatesPlusTwo 1007 + + i], 1008 + v->MinDispclkUsingDualDPP); 1009 + if (v->MinDispclkUsingDualDPP 1010 + > dml_min( 1011 + v->MaxDispclk[i], 1012 + (j + 1) 1013 + * v->MaxDppclk[i])) { 1014 + v->DISPCLK_DPPCLK_Support[j 1015 + * NumberOfStatesPlusTwo + i] = 1016 + 0; 1017 + } 1018 + } 1019 + v->TotalNumberOfActiveDPP[j * NumberOfStatesPlusTwo + i] = 1020 + v->TotalNumberOfActiveDPP[j 1021 + * NumberOfStatesPlusTwo + i] 1022 + + v->NoOfDPP[ijk]; 1023 + } 1024 + } 1025 + } 1026 + } 1027 + 1028 + // Viewport Size Check 1029 + 1030 + v->ViewportSizeSupport = 1; 1031 + 1032 + for (k = 0; k < num_planes; k++) { 1033 + if (v->NumberOfDPPRequiredForDETAndLBSize[k] > 2) { 1034 + v->ViewportSizeSupport = 0; 1035 + } 1036 + } 1037 + 1038 + // Total Available Pipes Support Check 1039 + 1040 + for (i = 0; i < NumberOfStatesPlusTwo; i++) { 1041 + for (j = 0; j < 2; j++) { 1042 + if (v->TotalNumberOfActiveDPP[j * NumberOfStatesPlusTwo + i] 1043 + <= ip->max_num_dpp) { 1044 + v->TotalAvailablePipesSupport[j * NumberOfStatesPlusTwo + i] = 1; 1045 + } else { 1046 + v->TotalAvailablePipesSupport[j * NumberOfStatesPlusTwo + i] = 0; 1047 + } 1048 + } 1049 + } 1050 + 1051 + // Urgent Latency Support Check 1052 + 1053 + for (j = 0; j < 2; j++) { 1054 + for (i = 0; i < NumberOfStatesPlusTwo; i++) { 1055 + ij = j * NumberOfStatesPlusTwo + i; 1056 + for (k = 0; k < num_planes; k++) { 1057 + struct _vcs_dpi_display_pipe_source_params_st src = 1058 + e2e[v->planes[k].e2e_index].pipe.src; 1059 + struct _vcs_dpi_display_pipe_dest_params_st dest = 1060 + e2e[v->planes[k].e2e_index].pipe.dest; 1061 + struct _vcs_dpi_scaler_ratio_depth_st scale_ratio_depth = 1062 + e2e[v->planes[k].e2e_index].pipe.scale_ratio_depth; 1063 + struct _vcs_dpi_scaler_taps_st scale_taps = 1064 + e2e[v->planes[k].e2e_index].pipe.scale_taps; 1065 + ijk = k * 2 * NumberOfStatesPlusTwo + j * NumberOfStatesPlusTwo + i; 1066 + 1067 + v->SwathWidthYPerState[ijk] = v->SwathWidthYSingleDPP[k] 1068 + / v->NoOfDPP[ijk]; 1069 + 1070 + v->SwathWidthGranularityY = 256 1071 + / dml_ceil_ex(v->BytePerPixelInDETY[k], 1) 1072 + / v->MaxSwathHeightY[k]; 1073 + v->RoundedUpMaxSwathSizeBytesY = (dml_ceil_ex( 1074 + v->SwathWidthYPerState[ijk] - 1, 1075 + v->SwathWidthGranularityY) 1076 + + v->SwathWidthGranularityY) 1077 + * v->BytePerPixelInDETY[k] * v->MaxSwathHeightY[k]; 1078 + if (src.source_format == dm_420_10) { 1079 + v->RoundedUpMaxSwathSizeBytesY = dml_ceil_ex( 1080 + v->RoundedUpMaxSwathSizeBytesY, 1081 + 256) + 256; 1082 + } 1083 + if (v->MaxSwathHeightC[k] > 0) { 1084 + v->SwathWidthGranularityC = 256 1085 + / dml_ceil_ex(v->BytePerPixelInDETC[k], 2) 1086 + / v->MaxSwathHeightC[k]; 1087 + } 1088 + v->RoundedUpMaxSwathSizeBytesC = (dml_ceil_ex( 1089 + v->SwathWidthYPerState[ijk] / 2 - 1, 1090 + v->SwathWidthGranularityC) 1091 + + v->SwathWidthGranularityC) 1092 + * v->BytePerPixelInDETC[k] * v->MaxSwathHeightC[k]; 1093 + if (src.source_format == dm_420_10) { 1094 + v->RoundedUpMaxSwathSizeBytesC = dml_ceil_ex( 1095 + v->RoundedUpMaxSwathSizeBytesC, 1096 + 256) + 256; 1097 + } 1098 + 1099 + if (v->RoundedUpMaxSwathSizeBytesY + v->RoundedUpMaxSwathSizeBytesC 1100 + <= ip->det_buffer_size_kbytes * 1024 / 2) { 1101 + v->SwathHeightYPerState[ijk] = v->MaxSwathHeightY[k]; 1102 + v->SwathHeightCPerState[ijk] = v->MaxSwathHeightC[k]; 1103 + } else { 1104 + v->SwathHeightYPerState[ijk] = v->MinSwathHeightY[k]; 1105 + v->SwathHeightCPerState[ijk] = v->MinSwathHeightC[k]; 1106 + } 1107 + 1108 + if (v->BytePerPixelInDETC[k] == 0) { 1109 + v->LinesInDETLuma = ip->det_buffer_size_kbytes * 1024 1110 + / v->BytePerPixelInDETY[k] 1111 + / v->SwathWidthYPerState[ijk]; 1112 + 1113 + v->LinesInDETChroma = 0; 1114 + } else if (v->SwathHeightYPerState[ijk] 1115 + <= v->SwathHeightCPerState[ijk]) { 1116 + v->LinesInDETLuma = ip->det_buffer_size_kbytes * 1024 / 2 1117 + / v->BytePerPixelInDETY[k] 1118 + / v->SwathWidthYPerState[ijk]; 1119 + v->LinesInDETChroma = ip->det_buffer_size_kbytes * 1024 / 2 1120 + / v->BytePerPixelInDETC[k] 1121 + / (v->SwathWidthYPerState[ijk] / 2); 1122 + } else { 1123 + v->LinesInDETLuma = ip->det_buffer_size_kbytes * 1024 * 2 1124 + / 3 / v->BytePerPixelInDETY[k] 1125 + / v->SwathWidthYPerState[ijk]; 1126 + v->LinesInDETChroma = ip->det_buffer_size_kbytes * 1024 / 3 1127 + / v->BytePerPixelInDETY[k] 1128 + / (v->SwathWidthYPerState[ijk] / 2); 1129 + } 1130 + 1131 + v->EffectiveLBLatencyHidingSourceLinesLuma = 1132 + dml_min( 1133 + ip->max_line_buffer_lines, 1134 + dml_floor_ex( 1135 + ip->line_buffer_size_bits 1136 + / scale_ratio_depth.lb_depth 1137 + / (v->SwathWidthYPerState[ijk] 1138 + / dml_max( 1139 + scale_ratio_depth.hscl_ratio, 1140 + 1)), 1141 + 1)) 1142 + - (scale_taps.vtaps - 1); 1143 + 1144 + v->EffectiveLBLatencyHidingSourceLinesChroma = 1145 + dml_min( 1146 + ip->max_line_buffer_lines, 1147 + dml_floor_ex( 1148 + ip->line_buffer_size_bits 1149 + / scale_ratio_depth.lb_depth 1150 + / (v->SwathWidthYPerState[ijk] 1151 + / 2 1152 + / dml_max( 1153 + scale_ratio_depth.hscl_ratio 1154 + / 2, 1155 + 1)), 1156 + 1)) 1157 + - (scale_taps.vtaps_c - 1); 1158 + 1159 + v->EffectiveDETLBLinesLuma = 1160 + dml_floor_ex( 1161 + v->LinesInDETLuma 1162 + + dml_min( 1163 + v->LinesInDETLuma 1164 + * v->RequiredDISPCLK[ij] 1165 + * v->BytePerPixelInDETY[k] 1166 + * v->PSCL_FACTOR[k] 1167 + / v->ReturnBWPerState[i], 1168 + v->EffectiveLBLatencyHidingSourceLinesLuma), 1169 + v->SwathHeightYPerState[ijk]); 1170 + 1171 + v->EffectiveDETLBLinesChroma = 1172 + dml_floor_ex( 1173 + v->LinesInDETChroma 1174 + + dml_min( 1175 + v->LinesInDETChroma 1176 + * v->RequiredDISPCLK[ij] 1177 + * v->BytePerPixelInDETC[k] 1178 + * v->PSCL_FACTOR_CHROMA[k] 1179 + / v->ReturnBWPerState[i], 1180 + v->EffectiveLBLatencyHidingSourceLinesChroma), 1181 + v->SwathHeightCPerState[ijk]); 1182 + 1183 + if (v->BytePerPixelInDETC[k] == 0) { 1184 + v->UrgentLatencySupportUsPerState[ijk] = 1185 + v->EffectiveDETLBLinesLuma 1186 + * (dest.htotal 1187 + / dest.pixel_rate_mhz) 1188 + / scale_ratio_depth.vscl_ratio 1189 + - v->EffectiveDETLBLinesLuma 1190 + * v->SwathWidthYPerState[ijk] 1191 + * dml_ceil_ex( 1192 + v->BytePerPixelInDETY[k], 1193 + 1) 1194 + / (v->ReturnBWPerState[i] 1195 + / v->NoOfDPP[ijk]); 1196 + } else { 1197 + v->UrgentLatencySupportUsPerState[ijk] = 1198 + dml_min( 1199 + v->EffectiveDETLBLinesLuma 1200 + * (dest.htotal 1201 + / dest.pixel_rate_mhz) 1202 + / scale_ratio_depth.vscl_ratio 1203 + - v->EffectiveDETLBLinesLuma 1204 + * v->SwathWidthYPerState[ijk] 1205 + * dml_ceil_ex( 1206 + v->BytePerPixelInDETY[k], 1207 + 1) 1208 + / (v->ReturnBWPerState[i] 1209 + / v->NoOfDPP[ijk]), 1210 + v->EffectiveDETLBLinesChroma 1211 + * (dest.htotal 1212 + / dest.pixel_rate_mhz) 1213 + / (scale_ratio_depth.vscl_ratio 1214 + / 2) 1215 + - v->EffectiveDETLBLinesChroma 1216 + * v->SwathWidthYPerState[ijk] 1217 + / 2 1218 + * dml_ceil_ex( 1219 + v->BytePerPixelInDETC[k], 1220 + 2) 1221 + / (v->ReturnBWPerState[i] 1222 + / v->NoOfDPP[ijk])); 1223 + } 1224 + 1225 + } 1226 + } 1227 + } 1228 + 1229 + for (i = 0; i < NumberOfStatesPlusTwo; i++) { 1230 + for (j = 0; j < 2; j++) { 1231 + ij = j * NumberOfStatesPlusTwo + i; 1232 + 1233 + v->UrgentLatencySupport[ij] = 1; 1234 + for (k = 0; k < num_planes; k++) { 1235 + ijk = k * 2 * NumberOfStatesPlusTwo + j * NumberOfStatesPlusTwo + i; 1236 + 1237 + if (v->UrgentLatencySupportUsPerState[ijk] 1238 + < soc->urgent_latency_us / 1) { 1239 + v->UrgentLatencySupport[ij] = 0; 1240 + } 1241 + } 1242 + } 1243 + } 1244 + 1245 + // Prefetch Check 1246 + 1247 + for (i = 0; i < NumberOfStatesPlusTwo; i++) { 1248 + for (j = 0; j < 2; j++) { 1249 + ij = j * NumberOfStatesPlusTwo + i; 1250 + 1251 + v->TotalNumberOfDCCActiveDPP[ij] = 0; 1252 + for (k = 0; k < num_planes; k++) { 1253 + struct _vcs_dpi_display_pipe_source_params_st src = 1254 + e2e[v->planes[k].e2e_index].pipe.src; 1255 + ijk = k * 2 * NumberOfStatesPlusTwo + j * NumberOfStatesPlusTwo + i; 1256 + 1257 + if (src.dcc == 1) { 1258 + v->TotalNumberOfDCCActiveDPP[ij] = 1259 + v->TotalNumberOfDCCActiveDPP[ij] 1260 + + v->NoOfDPP[ijk]; 1261 + } 1262 + } 1263 + } 1264 + } 1265 + 1266 + for (i = 0; i < NumberOfStatesPlusTwo; i++) { 1267 + for (j = 0; j < 2; j++) { 1268 + ij = j * NumberOfStatesPlusTwo + i; 1269 + 1270 + v->ProjectedDCFCLKDeepSleep = 8; 1271 + 1272 + for (k = 0; k < num_planes; k++) { 1273 + struct _vcs_dpi_display_pipe_dest_params_st dest = 1274 + e2e[v->planes[k].e2e_index].pipe.dest; 1275 + struct _vcs_dpi_scaler_ratio_depth_st scale_ratio_depth = 1276 + e2e[v->planes[k].e2e_index].pipe.scale_ratio_depth; 1277 + ijk = k * 2 * NumberOfStatesPlusTwo + j * NumberOfStatesPlusTwo + i; 1278 + 1279 + v->ProjectedDCFCLKDeepSleep = dml_max( 1280 + v->ProjectedDCFCLKDeepSleep, 1281 + dest.pixel_rate_mhz / 16); 1282 + if (v->BytePerPixelInDETC[k] == 0) { 1283 + if (scale_ratio_depth.vscl_ratio <= 1) { 1284 + v->ProjectedDCFCLKDeepSleep = 1285 + dml_max( 1286 + v->ProjectedDCFCLKDeepSleep, 1287 + 1.1 1288 + * dml_ceil_ex( 1289 + v->BytePerPixelInDETY[k], 1290 + 1) 1291 + / 64 1292 + * scale_ratio_depth.hscl_ratio 1293 + * dest.pixel_rate_mhz 1294 + / v->NoOfDPP[ijk]); 1295 + } else { 1296 + v->ProjectedDCFCLKDeepSleep = 1297 + dml_max( 1298 + v->ProjectedDCFCLKDeepSleep, 1299 + 1.1 1300 + * dml_ceil_ex( 1301 + v->BytePerPixelInDETY[k], 1302 + 1) 1303 + / 64 1304 + * v->PSCL_FACTOR[k] 1305 + * v->RequiredDISPCLK[ij] 1306 + / (1 1307 + + j)); 1308 + } 1309 + 1310 + } else { 1311 + if (scale_ratio_depth.vscl_ratio <= 1) { 1312 + v->ProjectedDCFCLKDeepSleep = 1313 + dml_max( 1314 + v->ProjectedDCFCLKDeepSleep, 1315 + 1.1 1316 + * dml_ceil_ex( 1317 + v->BytePerPixelInDETY[k], 1318 + 1) 1319 + / 32 1320 + * scale_ratio_depth.hscl_ratio 1321 + * dest.pixel_rate_mhz 1322 + / v->NoOfDPP[ijk]); 1323 + } else { 1324 + v->ProjectedDCFCLKDeepSleep = 1325 + dml_max( 1326 + v->ProjectedDCFCLKDeepSleep, 1327 + 1.1 1328 + * dml_ceil_ex( 1329 + v->BytePerPixelInDETY[k], 1330 + 1) 1331 + / 32 1332 + * v->PSCL_FACTOR[k] 1333 + * v->RequiredDISPCLK[ij] 1334 + / (1 1335 + + j)); 1336 + } 1337 + if ((scale_ratio_depth.vscl_ratio / 2) <= 1) { 1338 + v->ProjectedDCFCLKDeepSleep = 1339 + dml_max( 1340 + v->ProjectedDCFCLKDeepSleep, 1341 + 1.1 1342 + * dml_ceil_ex( 1343 + v->BytePerPixelInDETC[k], 1344 + 2) 1345 + / 32 1346 + * scale_ratio_depth.hscl_ratio 1347 + / 2 1348 + * dest.pixel_rate_mhz 1349 + / v->NoOfDPP[ijk]); 1350 + } else { 1351 + v->ProjectedDCFCLKDeepSleep = 1352 + dml_max( 1353 + v->ProjectedDCFCLKDeepSleep, 1354 + 1.1 1355 + * dml_ceil_ex( 1356 + v->BytePerPixelInDETC[k], 1357 + 2) 1358 + / 32 1359 + * v->PSCL_FACTOR_CHROMA[k] 1360 + * v->RequiredDISPCLK[ij] 1361 + / (1 1362 + + j)); 1363 + } 1364 + 1365 + } 1366 + } 1367 + 1368 + for (k = 0; k < num_planes; k++) { 1369 + struct _vcs_dpi_display_pipe_source_params_st src = 1370 + e2e[v->planes[k].e2e_index].pipe.src; 1371 + struct _vcs_dpi_display_pipe_dest_params_st dest = 1372 + e2e[v->planes[k].e2e_index].pipe.dest; 1373 + struct _vcs_dpi_scaler_ratio_depth_st scale_ratio_depth = 1374 + e2e[v->planes[k].e2e_index].pipe.scale_ratio_depth; 1375 + struct _vcs_dpi_scaler_taps_st scale_taps = 1376 + e2e[v->planes[k].e2e_index].pipe.scale_taps; 1377 + struct _vcs_dpi_display_output_params_st dout = 1378 + e2e[v->planes[k].e2e_index].dout; 1379 + ijk = k * 2 * NumberOfStatesPlusTwo + j * NumberOfStatesPlusTwo + i; 1380 + 1381 + if (src.dcc == 1) { 1382 + v->MetaReqHeightY = 8 * v->Read256BlockHeightY[k]; 1383 + v->MetaReqWidthY = 64 * 256 1384 + / dml_ceil_ex(v->BytePerPixelInDETY[k], 1) 1385 + / v->MetaReqHeightY; 1386 + v->MetaSurfaceWidthY = dml_ceil_ex( 1387 + src.viewport_width / v->NoOfDPP[ijk] - 1, 1388 + v->MetaReqWidthY) + v->MetaReqWidthY; 1389 + v->MetaSurfaceHeightY = dml_ceil_ex( 1390 + src.viewport_height - 1, 1391 + v->MetaReqHeightY) + v->MetaReqHeightY; 1392 + if (ip->pte_enable == 1) { 1393 + v->MetaPteBytesPerFrameY = 1394 + (dml_ceil_ex( 1395 + (v->MetaSurfaceWidthY 1396 + * v->MetaSurfaceHeightY 1397 + * dml_ceil_ex( 1398 + v->BytePerPixelInDETY[k], 1399 + 1) 1400 + / 256.0 1401 + - 4096) 1402 + / 8 1403 + / 4096, 1404 + 1) + 1) * 64; 1405 + } else { 1406 + v->MetaPteBytesPerFrameY = 0; 1407 + } 1408 + if (src.source_scan == dm_horz) { 1409 + v->MetaRowBytesY = 1410 + v->MetaSurfaceWidthY 1411 + * v->MetaReqHeightY 1412 + * dml_ceil_ex( 1413 + v->BytePerPixelInDETY[k], 1414 + 1) 1415 + / 256; 1416 + } else { 1417 + v->MetaRowBytesY = 1418 + v->MetaSurfaceHeightY 1419 + * v->MetaReqWidthY 1420 + * dml_ceil_ex( 1421 + v->BytePerPixelInDETY[k], 1422 + 1) 1423 + / 256; 1424 + } 1425 + } else { 1426 + v->MetaPteBytesPerFrameY = 0; 1427 + v->MetaRowBytesY = 0; 1428 + } 1429 + 1430 + if (ip->pte_enable == 1) { 1431 + if (src.sw_mode == dm_sw_linear) { 1432 + v->MacroTileBlockSizeBytesY = 256; 1433 + v->MacroTileBlockHeightY = 1; 1434 + } else if (src.sw_mode == dm_sw_4kb_s 1435 + || src.sw_mode == dm_sw_4kb_s_x 1436 + || src.sw_mode == dm_sw_4kb_d 1437 + || src.sw_mode == dm_sw_4kb_d_x) { 1438 + v->MacroTileBlockSizeBytesY = 4096; 1439 + v->MacroTileBlockHeightY = 4 1440 + * v->Read256BlockHeightY[k]; 1441 + } else if (src.sw_mode == dm_sw_64kb_s 1442 + || src.sw_mode == dm_sw_64kb_s_t 1443 + || src.sw_mode == dm_sw_64kb_s_x 1444 + || src.sw_mode == dm_sw_64kb_d 1445 + || src.sw_mode == dm_sw_64kb_d_t 1446 + || src.sw_mode == dm_sw_64kb_d_x) { 1447 + v->MacroTileBlockSizeBytesY = 64 * 1024; 1448 + v->MacroTileBlockHeightY = 16 1449 + * v->Read256BlockHeightY[k]; 1450 + } else { 1451 + v->MacroTileBlockSizeBytesY = 256 * 1024; 1452 + v->MacroTileBlockHeightY = 32 1453 + * v->Read256BlockHeightY[k]; 1454 + } 1455 + if (v->MacroTileBlockSizeBytesY <= 65536) { 1456 + v->DataPTEReqHeightY = v->MacroTileBlockHeightY; 1457 + } else { 1458 + v->DataPTEReqHeightY = 16 1459 + * v->Read256BlockHeightY[k]; 1460 + } 1461 + v->DataPTEReqWidthY = 4096 1462 + / dml_ceil_ex(v->BytePerPixelInDETY[k], 1) 1463 + / v->DataPTEReqHeightY * 8; 1464 + if (src.sw_mode == dm_sw_linear) { 1465 + v->DPTEBytesPerRowY = 1466 + 64 1467 + * (dml_ceil_ex( 1468 + (src.viewport_width 1469 + / v->NoOfDPP[ijk] 1470 + * dml_min( 1471 + 128, 1472 + dml_pow( 1473 + 2, 1474 + dml_floor_ex( 1475 + dml_log( 1476 + ip->dpte_buffer_size_in_pte_reqs 1477 + * v->DataPTEReqWidthY 1478 + / (src.viewport_width 1479 + / v->NoOfDPP[ijk]), 1480 + 2), 1481 + 1))) 1482 + - 1) 1483 + / v->DataPTEReqWidthY, 1484 + 1) 1485 + + 1); 1486 + } else if (src.source_scan == dm_horz) { 1487 + v->DPTEBytesPerRowY = 1488 + 64 1489 + * (dml_ceil_ex( 1490 + (src.viewport_width 1491 + / v->NoOfDPP[ijk] 1492 + - 1) 1493 + / v->DataPTEReqWidthY, 1494 + 1) 1495 + + 1); 1496 + } else { 1497 + v->DPTEBytesPerRowY = 1498 + 64 1499 + * (dml_ceil_ex( 1500 + (src.viewport_height 1501 + - 1) 1502 + / v->DataPTEReqHeightY, 1503 + 1) 1504 + + 1); 1505 + } 1506 + } else { 1507 + v->DPTEBytesPerRowY = 0; 1508 + } 1509 + 1510 + if (src.source_format != dm_444_64 && src.source_format != dm_444_32 1511 + && src.source_format != dm_444_16) { 1512 + if (src.dcc == 1) { 1513 + v->MetaReqHeightC = 8 * v->Read256BlockHeightC[k]; 1514 + v->MetaReqWidthC = 1515 + 64 * 256 1516 + / dml_ceil_ex( 1517 + v->BytePerPixelInDETC[k], 1518 + 2) 1519 + / v->MetaReqHeightC; 1520 + v->MetaSurfaceWidthC = dml_ceil_ex( 1521 + src.viewport_width / v->NoOfDPP[ijk] 1522 + / 2 - 1, 1523 + v->MetaReqWidthC) 1524 + + v->MetaReqWidthC; 1525 + v->MetaSurfaceHeightC = dml_ceil_ex( 1526 + src.viewport_height / 2 - 1, 1527 + v->MetaReqHeightC) 1528 + + v->MetaReqHeightC; 1529 + if (ip->pte_enable == 1) { 1530 + v->MetaPteBytesPerFrameC = 1531 + (dml_ceil_ex( 1532 + (v->MetaSurfaceWidthC 1533 + * v->MetaSurfaceHeightC 1534 + * dml_ceil_ex( 1535 + v->BytePerPixelInDETC[k], 1536 + 2) 1537 + / 256.0 1538 + - 4096) 1539 + / 8 1540 + / 4096, 1541 + 1) + 1) 1542 + * 64; 1543 + } else { 1544 + v->MetaPteBytesPerFrameC = 0; 1545 + } 1546 + if (src.source_scan == dm_horz) { 1547 + v->MetaRowBytesC = 1548 + v->MetaSurfaceWidthC 1549 + * v->MetaReqHeightC 1550 + * dml_ceil_ex( 1551 + v->BytePerPixelInDETC[k], 1552 + 2) 1553 + / 256; 1554 + } else { 1555 + v->MetaRowBytesC = 1556 + v->MetaSurfaceHeightC 1557 + * v->MetaReqWidthC 1558 + * dml_ceil_ex( 1559 + v->BytePerPixelInDETC[k], 1560 + 2) 1561 + / 256; 1562 + } 1563 + } else { 1564 + v->MetaPteBytesPerFrameC = 0; 1565 + v->MetaRowBytesC = 0; 1566 + } 1567 + 1568 + if (ip->pte_enable == 1) { 1569 + if (src.sw_mode == dm_sw_linear) { 1570 + v->MacroTileBlockSizeBytesC = 256; 1571 + v->MacroTileBlockHeightC = 1; 1572 + } else if (src.sw_mode == dm_sw_4kb_s 1573 + || src.sw_mode == dm_sw_4kb_s_x 1574 + || src.sw_mode == dm_sw_4kb_d 1575 + || src.sw_mode == dm_sw_4kb_d_x) { 1576 + v->MacroTileBlockSizeBytesC = 4096; 1577 + v->MacroTileBlockHeightC = 4 1578 + * v->Read256BlockHeightC[k]; 1579 + } else if (src.sw_mode == dm_sw_64kb_s 1580 + || src.sw_mode == dm_sw_64kb_s_t 1581 + || src.sw_mode == dm_sw_64kb_s_x 1582 + || src.sw_mode == dm_sw_64kb_d 1583 + || src.sw_mode == dm_sw_64kb_d_t 1584 + || src.sw_mode == dm_sw_64kb_d_x) { 1585 + v->MacroTileBlockSizeBytesC = 64 * 1024; 1586 + v->MacroTileBlockHeightC = 16 1587 + * v->Read256BlockHeightC[k]; 1588 + } else { 1589 + v->MacroTileBlockSizeBytesC = 256 * 1024; 1590 + v->MacroTileBlockHeightC = 32 1591 + * v->Read256BlockHeightC[k]; 1592 + } 1593 + v->MacroTileBlockWidthC = 1594 + v->MacroTileBlockSizeBytesC 1595 + / dml_ceil_ex( 1596 + v->BytePerPixelInDETC[k], 1597 + 2) 1598 + / v->MacroTileBlockHeightC; 1599 + if (v->MacroTileBlockSizeBytesC <= 65536) { 1600 + v->DataPTEReqHeightC = 1601 + v->MacroTileBlockHeightC; 1602 + } else { 1603 + v->DataPTEReqHeightC = 16 1604 + * v->Read256BlockHeightC[k]; 1605 + } 1606 + v->DataPTEReqWidthC = 1607 + 4096 1608 + / dml_ceil_ex( 1609 + v->BytePerPixelInDETC[k], 1610 + 2) 1611 + / v->DataPTEReqHeightC 1612 + * 8; 1613 + if (src.sw_mode == dm_sw_linear) { 1614 + v->DPTEBytesPerRowC = 1615 + 64 1616 + * (dml_ceil_ex( 1617 + (src.viewport_width 1618 + / v->NoOfDPP[ijk] 1619 + / 2 1620 + * dml_min( 1621 + 128, 1622 + dml_pow( 1623 + 2, 1624 + dml_floor_ex( 1625 + dml_log( 1626 + ip->dpte_buffer_size_in_pte_reqs 1627 + * v->DataPTEReqWidthC 1628 + / (src.viewport_width 1629 + / v->NoOfDPP[ijk] 1630 + / 2), 1631 + 2), 1632 + 1))) 1633 + - 1) 1634 + / v->DataPTEReqWidthC, 1635 + 1) 1636 + + 1); 1637 + } else if (src.source_scan == dm_horz) { 1638 + v->DPTEBytesPerRowC = 1639 + 64 1640 + * (dml_ceil_ex( 1641 + (src.viewport_width 1642 + / v->NoOfDPP[ijk] 1643 + / 2 1644 + - 1) 1645 + / v->DataPTEReqWidthC, 1646 + 1) 1647 + + 1); 1648 + } else { 1649 + v->DPTEBytesPerRowC = 1650 + 64 1651 + * (dml_ceil_ex( 1652 + (src.viewport_height 1653 + / 2 1654 + - 1) 1655 + / v->DataPTEReqHeightC, 1656 + 1) 1657 + + 1); 1658 + } 1659 + } else { 1660 + v->DPTEBytesPerRowC = 0; 1661 + } 1662 + } else { 1663 + v->DPTEBytesPerRowC = 0; 1664 + v->MetaPteBytesPerFrameC = 0; 1665 + v->MetaRowBytesC = 0; 1666 + } 1667 + 1668 + v->DPTEBytesPerRow[k] = v->DPTEBytesPerRowY + v->DPTEBytesPerRowC; 1669 + v->MetaPTEBytesPerFrame[k] = v->MetaPteBytesPerFrameY 1670 + + v->MetaPteBytesPerFrameC; 1671 + v->MetaRowBytes[k] = v->MetaRowBytesY + v->MetaRowBytesC; 1672 + 1673 + v->VInitY = (scale_ratio_depth.vscl_ratio + scale_taps.vtaps + 1 1674 + + dest.interlaced * 0.5 1675 + * scale_ratio_depth.vscl_ratio) 1676 + / 2.0; 1677 + v->PrefillY[k] = dml_floor_ex(v->VInitY, 1); 1678 + v->MaxNumSwY[k] = dml_ceil_ex( 1679 + (v->PrefillY[k] - 1.0) 1680 + / v->SwathHeightYPerState[ijk], 1681 + 1) + 1.0; 1682 + 1683 + if (v->PrefillY[k] > 1) { 1684 + v->MaxPartialSwY = ((int) (v->PrefillY[k] - 2)) 1685 + % ((int) v->SwathHeightYPerState[ijk]); 1686 + } else { 1687 + v->MaxPartialSwY = ((int) (v->PrefillY[k] 1688 + + v->SwathHeightYPerState[ijk] - 2)) 1689 + % ((int) v->SwathHeightYPerState[ijk]); 1690 + } 1691 + v->MaxPartialSwY = dml_max(1, v->MaxPartialSwY); 1692 + 1693 + v->PrefetchLinesY[k] = v->MaxNumSwY[k] 1694 + * v->SwathHeightYPerState[ijk] + v->MaxPartialSwY; 1695 + 1696 + if (src.source_format != dm_444_64 && src.source_format != dm_444_32 1697 + && src.source_format != dm_444_16) { 1698 + v->VInitC = 1699 + (scale_ratio_depth.vscl_ratio / 2 1700 + + scale_taps.vtaps + 1 1701 + + dest.interlaced * 0.5 1702 + * scale_ratio_depth.vscl_ratio 1703 + / 2) / 2.0; 1704 + v->PrefillC[k] = dml_floor_ex(v->VInitC, 1); 1705 + v->MaxNumSwC[k] = 1706 + dml_ceil_ex( 1707 + (v->PrefillC[k] - 1.0) 1708 + / v->SwathHeightCPerState[ijk], 1709 + 1) + 1.0; 1710 + if (v->PrefillC[k] > 1) { 1711 + v->MaxPartialSwC = 1712 + ((int) (v->PrefillC[k] - 2)) 1713 + % ((int) v->SwathHeightCPerState[ijk]); 1714 + } else { 1715 + v->MaxPartialSwC = 1716 + ((int) (v->PrefillC[k] 1717 + + v->SwathHeightCPerState[ijk] 1718 + - 2)) 1719 + % ((int) v->SwathHeightCPerState[ijk]); 1720 + } 1721 + v->MaxPartialSwC = dml_max(1, v->MaxPartialSwC); 1722 + 1723 + v->PrefetchLinesC[k] = v->MaxNumSwC[k] 1724 + * v->SwathHeightCPerState[ijk] 1725 + + v->MaxPartialSwC; 1726 + } else { 1727 + v->PrefetchLinesC[k] = 0; 1728 + } 1729 + 1730 + v->dst_x_after_scaler = 90 * dest.pixel_rate_mhz 1731 + / (v->RequiredDISPCLK[ij] / (j + 1)) 1732 + + 42 * dest.pixel_rate_mhz / v->RequiredDISPCLK[ij]; 1733 + if (v->NoOfDPP[ijk] > 1) { 1734 + v->dst_x_after_scaler = v->dst_x_after_scaler 1735 + + dest.recout_width / 2.0; 1736 + } 1737 + 1738 + if (dout.output_format == dm_420) { 1739 + v->dst_y_after_scaler = 1; 1740 + } else { 1741 + v->dst_y_after_scaler = 0; 1742 + } 1743 + 1744 + v->TimeCalc = 24 / v->ProjectedDCFCLKDeepSleep; 1745 + 1746 + v->VUpdateOffset = dml_ceil_ex(dest.htotal / 4, 1); 1747 + v->TotalRepeaterDelay = ip->max_inter_dcn_tile_repeaters 1748 + * (2 / (v->RequiredDISPCLK[ij] / (j + 1)) 1749 + + 3 / v->RequiredDISPCLK[ij]); 1750 + v->VUpdateWidth = (14 / v->ProjectedDCFCLKDeepSleep 1751 + + 12 / (v->RequiredDISPCLK[ij] / (j + 1)) 1752 + + v->TotalRepeaterDelay) * dest.pixel_rate_mhz; 1753 + v->VReadyOffset = 1754 + dml_max( 1755 + 150 1756 + / (v->RequiredDISPCLK[ij] 1757 + / (j 1758 + + 1)), 1759 + v->TotalRepeaterDelay 1760 + + 20 1761 + / v->ProjectedDCFCLKDeepSleep 1762 + + 10 1763 + / (v->RequiredDISPCLK[ij] 1764 + / (j 1765 + + 1))) 1766 + * dest.pixel_rate_mhz; 1767 + 1768 + v->TimeSetup = 1769 + (v->VUpdateOffset + v->VUpdateWidth 1770 + + v->VReadyOffset) 1771 + / dest.pixel_rate_mhz; 1772 + 1773 + v->ExtraLatency = 1774 + v->UrgentRoundTripAndOutOfOrderLatencyPerState[i] 1775 + + (v->TotalNumberOfActiveDPP[ij] 1776 + * ip->pixel_chunk_size_kbytes 1777 + + v->TotalNumberOfDCCActiveDPP[ij] 1778 + * ip->meta_chunk_size_kbytes) 1779 + * 1024 1780 + / v->ReturnBWPerState[i]; 1781 + 1782 + if (ip->pte_enable == 1) { 1783 + v->ExtraLatency = v->ExtraLatency 1784 + + v->TotalNumberOfActiveDPP[ij] 1785 + * ip->pte_chunk_size_kbytes 1786 + * 1024 1787 + / v->ReturnBWPerState[i]; 1788 + } 1789 + 1790 + if (ip->can_vstartup_lines_exceed_vsync_plus_back_porch_lines_minus_one 1791 + == 1) { 1792 + v->MaximumVStartup = dest.vtotal - dest.vactive - 1; 1793 + } else { 1794 + v->MaximumVStartup = dest.vsync_plus_back_porch - 1; 1795 + } 1796 + 1797 + v->LineTimesForPrefetch[k] = 1798 + v->MaximumVStartup 1799 + - soc->urgent_latency_us 1800 + / (dest.htotal 1801 + / dest.pixel_rate_mhz) 1802 + - (v->TimeCalc + v->TimeSetup) 1803 + / (dest.htotal 1804 + / dest.pixel_rate_mhz) 1805 + - (v->dst_y_after_scaler 1806 + + v->dst_x_after_scaler 1807 + / dest.htotal); 1808 + 1809 + v->LineTimesForPrefetch[k] = dml_floor_ex( 1810 + 4.0 * (v->LineTimesForPrefetch[k] + 0.125), 1811 + 1) / 4; 1812 + 1813 + v->PrefetchBW[k] = 1814 + (v->MetaPTEBytesPerFrame[k] + 2 * v->MetaRowBytes[k] 1815 + + 2 * v->DPTEBytesPerRow[k] 1816 + + v->PrefetchLinesY[k] 1817 + * v->SwathWidthYPerState[ijk] 1818 + * dml_ceil_ex( 1819 + v->BytePerPixelInDETY[k], 1820 + 1) 1821 + + v->PrefetchLinesC[k] 1822 + * v->SwathWidthYPerState[ijk] 1823 + / 2 1824 + * dml_ceil_ex( 1825 + v->BytePerPixelInDETC[k], 1826 + 2)) 1827 + / (v->LineTimesForPrefetch[k] 1828 + * dest.htotal 1829 + / dest.pixel_rate_mhz); 1830 + } 1831 + 1832 + v->BWAvailableForImmediateFlip = v->ReturnBWPerState[i]; 1833 + 1834 + for (k = 0; k < num_planes; k++) { 1835 + v->BWAvailableForImmediateFlip = v->BWAvailableForImmediateFlip 1836 + - dml_max(v->ReadBandwidth[k], v->PrefetchBW[k]); 1837 + } 1838 + 1839 + v->TotalImmediateFlipBytes = 0; 1840 + 1841 + for (k = 0; k < num_planes; k++) { 1842 + struct _vcs_dpi_display_pipe_source_params_st src = 1843 + e2e[v->planes[k].e2e_index].pipe.src; 1844 + 1845 + if (src.source_format != dm_420_8 1846 + && src.source_format != dm_420_10) { 1847 + v->TotalImmediateFlipBytes = v->TotalImmediateFlipBytes 1848 + + v->MetaPTEBytesPerFrame[k] 1849 + + v->MetaRowBytes[k] 1850 + + v->DPTEBytesPerRow[k]; 1851 + } 1852 + } 1853 + 1854 + for (k = 0; k < num_planes; k++) { 1855 + struct _vcs_dpi_display_pipe_source_params_st src = 1856 + e2e[v->planes[k].e2e_index].pipe.src; 1857 + struct _vcs_dpi_display_pipe_dest_params_st dest = 1858 + e2e[v->planes[k].e2e_index].pipe.dest; 1859 + ijk = k * 2 * NumberOfStatesPlusTwo + j * NumberOfStatesPlusTwo + i; 1860 + 1861 + if (ip->pte_enable == 1 && src.dcc == 1) { 1862 + v->TimeForMetaPTEWithImmediateFlip = 1863 + dml_max( 1864 + v->MetaPTEBytesPerFrame[k] 1865 + / v->PrefetchBW[k], 1866 + dml_max( 1867 + v->MetaPTEBytesPerFrame[k] 1868 + * v->TotalImmediateFlipBytes 1869 + / (v->BWAvailableForImmediateFlip 1870 + * (v->MetaPTEBytesPerFrame[k] 1871 + + v->MetaRowBytes[k] 1872 + + v->DPTEBytesPerRow[k])), 1873 + dml_max( 1874 + v->ExtraLatency, 1875 + dml_max( 1876 + soc->urgent_latency_us, 1877 + dest.htotal 1878 + / dest.pixel_rate_mhz 1879 + / 4)))); 1880 + 1881 + v->TimeForMetaPTEWithoutImmediateFlip = 1882 + dml_max( 1883 + v->MetaPTEBytesPerFrame[k] 1884 + / v->PrefetchBW[k], 1885 + dml_max( 1886 + v->ExtraLatency, 1887 + dest.htotal 1888 + / dest.pixel_rate_mhz 1889 + / 4)); 1890 + } else { 1891 + v->TimeForMetaPTEWithImmediateFlip = dest.htotal 1892 + / dest.pixel_rate_mhz / 4; 1893 + v->TimeForMetaPTEWithoutImmediateFlip = dest.htotal 1894 + / dest.pixel_rate_mhz / 4; 1895 + } 1896 + 1897 + if (ip->pte_enable == 1 || src.dcc == 1) { 1898 + v->TimeForMetaAndDPTERowWithImmediateFlip = 1899 + dml_max( 1900 + (v->MetaRowBytes[k] 1901 + + v->DPTEBytesPerRow[k]) 1902 + / v->PrefetchBW[k], 1903 + dml_max( 1904 + (v->MetaRowBytes[k] 1905 + + v->DPTEBytesPerRow[k]) 1906 + * v->TotalImmediateFlipBytes 1907 + / (v->BWAvailableForImmediateFlip 1908 + * (v->MetaPTEBytesPerFrame[k] 1909 + + v->MetaRowBytes[k] 1910 + + v->DPTEBytesPerRow[k])), 1911 + dml_max( 1912 + dest.htotal 1913 + / dest.pixel_rate_mhz 1914 + - v->TimeForMetaPTEWithImmediateFlip, 1915 + dml_max( 1916 + v->ExtraLatency, 1917 + 2 1918 + * soc->urgent_latency_us)))); 1919 + 1920 + v->TimeForMetaAndDPTERowWithoutImmediateFlip = 1921 + dml_max( 1922 + (v->MetaRowBytes[k] 1923 + + v->DPTEBytesPerRow[k]) 1924 + / v->PrefetchBW[k], 1925 + dml_max( 1926 + dest.htotal 1927 + / dest.pixel_rate_mhz 1928 + - v->TimeForMetaPTEWithoutImmediateFlip, 1929 + v->ExtraLatency)); 1930 + } else { 1931 + v->TimeForMetaAndDPTERowWithImmediateFlip = 1932 + dml_max( 1933 + dest.htotal 1934 + / dest.pixel_rate_mhz 1935 + - v->TimeForMetaPTEWithImmediateFlip, 1936 + v->ExtraLatency 1937 + - v->TimeForMetaPTEWithImmediateFlip); 1938 + v->TimeForMetaAndDPTERowWithoutImmediateFlip = 1939 + dml_max( 1940 + dest.htotal 1941 + / dest.pixel_rate_mhz 1942 + - v->TimeForMetaPTEWithoutImmediateFlip, 1943 + v->ExtraLatency 1944 + - v->TimeForMetaPTEWithoutImmediateFlip); 1945 + } 1946 + 1947 + v->LinesForMetaPTEWithImmediateFlip[k] = 1948 + dml_floor_ex( 1949 + 4.0 1950 + * (v->TimeForMetaPTEWithImmediateFlip 1951 + / (dest.htotal 1952 + / dest.pixel_rate_mhz) 1953 + + 0.125), 1954 + 1) / 4.0; 1955 + 1956 + v->LinesForMetaPTEWithoutImmediateFlip[k] = 1957 + dml_floor_ex( 1958 + 4.0 1959 + * (v->TimeForMetaPTEWithoutImmediateFlip 1960 + / (dest.htotal 1961 + / dest.pixel_rate_mhz) 1962 + + 0.125), 1963 + 1) / 4.0; 1964 + 1965 + v->LinesForMetaAndDPTERowWithImmediateFlip[k] = 1966 + dml_floor_ex( 1967 + 4.0 1968 + * (v->TimeForMetaAndDPTERowWithImmediateFlip 1969 + / (dest.htotal 1970 + / dest.pixel_rate_mhz) 1971 + + 0.125), 1972 + 1) / 4.0; 1973 + 1974 + v->LinesForMetaAndDPTERowWithoutImmediateFlip[k] = 1975 + dml_floor_ex( 1976 + 4.0 1977 + * (v->TimeForMetaAndDPTERowWithoutImmediateFlip 1978 + / (dest.htotal 1979 + / dest.pixel_rate_mhz) 1980 + + 0.125), 1981 + 1) / 4.0; 1982 + 1983 + v->LineTimesToRequestPrefetchPixelDataWithImmediateFlip = 1984 + v->LineTimesForPrefetch[k] 1985 + - v->LinesForMetaPTEWithImmediateFlip[k] 1986 + - v->LinesForMetaAndDPTERowWithImmediateFlip[k]; 1987 + 1988 + v->LineTimesToRequestPrefetchPixelDataWithoutImmediateFlip = 1989 + v->LineTimesForPrefetch[k] 1990 + - v->LinesForMetaPTEWithoutImmediateFlip[k] 1991 + - v->LinesForMetaAndDPTERowWithoutImmediateFlip[k]; 1992 + 1993 + if (v->LineTimesToRequestPrefetchPixelDataWithImmediateFlip > 0) { 1994 + v->VRatioPreYWithImmediateFlip[ijk] = 1995 + v->PrefetchLinesY[k] 1996 + / v->LineTimesToRequestPrefetchPixelDataWithImmediateFlip; 1997 + if (v->SwathHeightYPerState[ijk] > 4) { 1998 + if (v->LineTimesToRequestPrefetchPixelDataWithImmediateFlip 1999 + - (v->PrefillY[k] - 3.0) / 2.0 2000 + > 0) { 2001 + v->VRatioPreYWithImmediateFlip[ijk] = 2002 + dml_max( 2003 + v->VRatioPreYWithImmediateFlip[ijk], 2004 + (v->MaxNumSwY[k] 2005 + * v->SwathHeightYPerState[ijk]) 2006 + / (v->LineTimesToRequestPrefetchPixelDataWithImmediateFlip 2007 + - (v->PrefillY[k] 2008 + - 3.0) 2009 + / 2.0)); 2010 + } else { 2011 + v->VRatioPreYWithImmediateFlip[ijk] = 2012 + 999999; 2013 + } 2014 + } 2015 + v->VRatioPreCWithImmediateFlip[ijk] = 2016 + v->PrefetchLinesC[k] 2017 + / v->LineTimesToRequestPrefetchPixelDataWithImmediateFlip; 2018 + if (v->SwathHeightCPerState[ijk] > 4) { 2019 + if (v->LineTimesToRequestPrefetchPixelDataWithImmediateFlip 2020 + - (v->PrefillC[k] - 3.0) / 2.0 2021 + > 0) { 2022 + v->VRatioPreCWithImmediateFlip[ijk] = 2023 + dml_max( 2024 + v->VRatioPreCWithImmediateFlip[ijk], 2025 + (v->MaxNumSwC[k] 2026 + * v->SwathHeightCPerState[ijk]) 2027 + / (v->LineTimesToRequestPrefetchPixelDataWithImmediateFlip 2028 + - (v->PrefillC[k] 2029 + - 3.0) 2030 + / 2.0)); 2031 + } else { 2032 + v->VRatioPreCWithImmediateFlip[ijk] = 2033 + 999999; 2034 + } 2035 + } 2036 + 2037 + v->RequiredPrefetchPixelDataBWWithImmediateFlip[ijk] = 2038 + v->NoOfDPP[ijk] 2039 + * (v->PrefetchLinesY[k] 2040 + / v->LineTimesToRequestPrefetchPixelDataWithImmediateFlip 2041 + * dml_ceil_ex( 2042 + v->BytePerPixelInDETY[k], 2043 + 1) 2044 + + v->PrefetchLinesC[k] 2045 + / v->LineTimesToRequestPrefetchPixelDataWithImmediateFlip 2046 + * dml_ceil_ex( 2047 + v->BytePerPixelInDETC[k], 2048 + 2) 2049 + / 2) 2050 + * v->SwathWidthYPerState[ijk] 2051 + / (dest.htotal 2052 + / dest.pixel_rate_mhz); 2053 + } else { 2054 + v->VRatioPreYWithImmediateFlip[ijk] = 999999; 2055 + v->VRatioPreCWithImmediateFlip[ijk] = 999999; 2056 + v->RequiredPrefetchPixelDataBWWithImmediateFlip[ijk] = 2057 + 999999; 2058 + } 2059 + 2060 + if (v->LineTimesToRequestPrefetchPixelDataWithoutImmediateFlip 2061 + > 0) { 2062 + v->VRatioPreYWithoutImmediateFlip[ijk] = 2063 + v->PrefetchLinesY[k] 2064 + / v->LineTimesToRequestPrefetchPixelDataWithoutImmediateFlip; 2065 + if (v->SwathHeightYPerState[ijk] > 4) { 2066 + if (v->LineTimesToRequestPrefetchPixelDataWithoutImmediateFlip 2067 + - (v->PrefillY[k] - 3.0) / 2.0 2068 + > 0) { 2069 + v->VRatioPreYWithoutImmediateFlip[ijk] = 2070 + dml_max( 2071 + v->VRatioPreYWithoutImmediateFlip[ijk], 2072 + (v->MaxNumSwY[k] 2073 + * v->SwathHeightYPerState[ijk]) 2074 + / (v->LineTimesToRequestPrefetchPixelDataWithoutImmediateFlip 2075 + - (v->PrefillY[k] 2076 + - 3.0) 2077 + / 2.0)); 2078 + } else { 2079 + v->VRatioPreYWithoutImmediateFlip[ijk] = 2080 + 999999; 2081 + } 2082 + } 2083 + v->VRatioPreCWithoutImmediateFlip[ijk] = 2084 + v->PrefetchLinesC[k] 2085 + / v->LineTimesToRequestPrefetchPixelDataWithoutImmediateFlip; 2086 + if (v->SwathHeightCPerState[ijk] > 4) { 2087 + if (v->LineTimesToRequestPrefetchPixelDataWithoutImmediateFlip 2088 + - (v->PrefillC[k] - 3.0) / 2.0 2089 + > 0) { 2090 + v->VRatioPreCWithoutImmediateFlip[ijk] = 2091 + dml_max( 2092 + v->VRatioPreCWithoutImmediateFlip[ijk], 2093 + (v->MaxNumSwC[k] 2094 + * v->SwathHeightCPerState[ijk]) 2095 + / (v->LineTimesToRequestPrefetchPixelDataWithoutImmediateFlip 2096 + - (v->PrefillC[k] 2097 + - 3.0) 2098 + / 2.0)); 2099 + } else { 2100 + v->VRatioPreCWithoutImmediateFlip[ijk] = 2101 + 999999; 2102 + } 2103 + } 2104 + 2105 + v->RequiredPrefetchPixelDataBWWithoutImmediateFlip[ijk] = 2106 + v->NoOfDPP[ijk] 2107 + * (v->PrefetchLinesY[k] 2108 + / v->LineTimesToRequestPrefetchPixelDataWithoutImmediateFlip 2109 + * dml_ceil_ex( 2110 + v->BytePerPixelInDETY[k], 2111 + 1) 2112 + + v->PrefetchLinesC[k] 2113 + / v->LineTimesToRequestPrefetchPixelDataWithoutImmediateFlip 2114 + * dml_ceil_ex( 2115 + v->BytePerPixelInDETC[k], 2116 + 2) 2117 + / 2) 2118 + * v->SwathWidthYPerState[ijk] 2119 + / (dest.htotal 2120 + / dest.pixel_rate_mhz); 2121 + } else { 2122 + v->VRatioPreYWithoutImmediateFlip[ijk] = 999999; 2123 + v->VRatioPreCWithoutImmediateFlip[ijk] = 999999; 2124 + v->RequiredPrefetchPixelDataBWWithoutImmediateFlip[ijk] = 2125 + 999999; 2126 + } 2127 + } 2128 + 2129 + v->MaximumReadBandwidthWithPrefetchWithImmediateFlip = 0; 2130 + 2131 + for (k = 0; k < num_planes; k++) { 2132 + struct _vcs_dpi_display_pipe_source_params_st src = 2133 + e2e[v->planes[k].e2e_index].pipe.src; 2134 + struct _vcs_dpi_display_pipe_dest_params_st dest = 2135 + e2e[v->planes[k].e2e_index].pipe.dest; 2136 + ijk = k * 2 * NumberOfStatesPlusTwo + j * NumberOfStatesPlusTwo + i; 2137 + 2138 + if (src.source_format != dm_420_8 2139 + && src.source_format != dm_420_10) { 2140 + v->MaximumReadBandwidthWithPrefetchWithImmediateFlip = 2141 + v->MaximumReadBandwidthWithPrefetchWithImmediateFlip 2142 + + dml_max( 2143 + v->ReadBandwidth[k], 2144 + v->RequiredPrefetchPixelDataBWWithImmediateFlip[ijk]) 2145 + + dml_max( 2146 + v->MetaPTEBytesPerFrame[k] 2147 + / (v->LinesForMetaPTEWithImmediateFlip[k] 2148 + * dest.htotal 2149 + / dest.pixel_rate_mhz), 2150 + (v->MetaRowBytes[k] 2151 + + v->DPTEBytesPerRow[k]) 2152 + / (v->LinesForMetaAndDPTERowWithImmediateFlip[k] 2153 + * dest.htotal 2154 + / dest.pixel_rate_mhz)); 2155 + } else { 2156 + v->MaximumReadBandwidthWithPrefetchWithImmediateFlip = 2157 + v->MaximumReadBandwidthWithPrefetchWithImmediateFlip 2158 + + dml_max( 2159 + v->ReadBandwidth[k], 2160 + v->RequiredPrefetchPixelDataBWWithoutImmediateFlip[ijk]); 2161 + } 2162 + } 2163 + 2164 + v->MaximumReadBandwidthWithPrefetchWithoutImmediateFlip = 0; 2165 + 2166 + for (k = 0; k < num_planes; k++) { 2167 + ijk = k * 2 * NumberOfStatesPlusTwo + j * NumberOfStatesPlusTwo + i; 2168 + 2169 + v->MaximumReadBandwidthWithPrefetchWithoutImmediateFlip = 2170 + v->MaximumReadBandwidthWithPrefetchWithoutImmediateFlip 2171 + + dml_max( 2172 + v->ReadBandwidth[k], 2173 + v->RequiredPrefetchPixelDataBWWithoutImmediateFlip[ijk]); 2174 + } 2175 + 2176 + v->PrefetchSupportedWithImmediateFlip[ij] = 1; 2177 + if (v->MaximumReadBandwidthWithPrefetchWithImmediateFlip 2178 + > v->ReturnBWPerState[i]) { 2179 + v->PrefetchSupportedWithImmediateFlip[ij] = 0; 2180 + } 2181 + for (k = 0; k < num_planes; k++) { 2182 + if (v->LineTimesForPrefetch[k] < 2 2183 + || v->LinesForMetaPTEWithImmediateFlip[k] >= 8 2184 + || v->LinesForMetaAndDPTERowWithImmediateFlip[k] 2185 + >= 16) { 2186 + v->PrefetchSupportedWithImmediateFlip[ij] = 0; 2187 + } 2188 + } 2189 + 2190 + v->PrefetchSupportedWithoutImmediateFlip[ij] = 1; 2191 + if (v->MaximumReadBandwidthWithPrefetchWithoutImmediateFlip 2192 + > v->ReturnBWPerState[i]) { 2193 + v->PrefetchSupportedWithoutImmediateFlip[ij] = 0; 2194 + } 2195 + for (k = 0; k < num_planes; k++) { 2196 + if (v->LineTimesForPrefetch[k] < 2 2197 + || v->LinesForMetaPTEWithoutImmediateFlip[k] >= 8 2198 + || v->LinesForMetaAndDPTERowWithoutImmediateFlip[k] 2199 + >= 16) { 2200 + v->PrefetchSupportedWithoutImmediateFlip[ij] = 0; 2201 + } 2202 + } 2203 + } 2204 + } 2205 + 2206 + for (i = 0; i < NumberOfStatesPlusTwo; i++) { 2207 + for (j = 0; j < 2; j++) { 2208 + ij = j * NumberOfStatesPlusTwo + i; 2209 + 2210 + v->VRatioInPrefetchSupportedWithImmediateFlip[ij] = 1; 2211 + for (k = 0; k < num_planes; k++) { 2212 + struct _vcs_dpi_display_pipe_source_params_st src = 2213 + e2e[v->planes[k].e2e_index].pipe.src; 2214 + ijk = k * 2 * NumberOfStatesPlusTwo + j * NumberOfStatesPlusTwo + i; 2215 + 2216 + if (((src.source_format != dm_420_8 2217 + && src.source_format != dm_420_10) 2218 + && (v->VRatioPreYWithImmediateFlip[ijk] > 4 2219 + || v->VRatioPreCWithImmediateFlip[ijk] 2220 + > 4)) 2221 + || ((src.source_format == dm_420_8 2222 + || src.source_format == dm_420_10) 2223 + && (v->VRatioPreYWithoutImmediateFlip[ijk] 2224 + > 4 2225 + || v->VRatioPreCWithoutImmediateFlip[ijk] 2226 + > 4))) { 2227 + v->VRatioInPrefetchSupportedWithImmediateFlip[ij] = 0; 2228 + } 2229 + } 2230 + v->VRatioInPrefetchSupportedWithoutImmediateFlip[ij] = 1; 2231 + for (k = 0; k < num_planes; k++) { 2232 + ijk = k * 2 * NumberOfStatesPlusTwo + j * NumberOfStatesPlusTwo + i; 2233 + 2234 + if (v->VRatioPreYWithoutImmediateFlip[ijk] > 4 2235 + || v->VRatioPreCWithoutImmediateFlip[ijk] > 4) { 2236 + v->VRatioInPrefetchSupportedWithoutImmediateFlip[ij] = 0; 2237 + } 2238 + } 2239 + } 2240 + } 2241 + 2242 + // Mode Support, Voltage State and SOC Configuration 2243 + 2244 + for (i = (NumberOfStatesPlusTwo - 1); i >= 0; i--) // use int type here 2245 + { 2246 + for (j = 0; j < 2; j++) { 2247 + ij = j * NumberOfStatesPlusTwo + i; 2248 + 2249 + if (v->ScaleRatioSupport == 1 && v->SourceFormatPixelAndScanSupport == 1 2250 + && v->ViewportSizeSupport == 1 2251 + && v->BandwidthSupport[i] == 1 && v->DIOSupport[i] == 1 2252 + && v->UrgentLatencySupport[ij] == 1 && v->ROBSupport[i] == 1 2253 + && v->DISPCLK_DPPCLK_Support[ij] == 1 2254 + && v->TotalAvailablePipesSupport[ij] == 1 2255 + && v->TotalAvailableWritebackSupport == 1 2256 + && v->WritebackLatencySupport == 1) { 2257 + if (v->PrefetchSupportedWithImmediateFlip[ij] == 1 2258 + && v->VRatioInPrefetchSupportedWithImmediateFlip[ij] 2259 + == 1) { 2260 + v->ModeSupportWithImmediateFlip[ij] = 1; 2261 + } else { 2262 + v->ModeSupportWithImmediateFlip[ij] = 0; 2263 + } 2264 + if (v->PrefetchSupportedWithoutImmediateFlip[ij] == 1 2265 + && v->VRatioInPrefetchSupportedWithoutImmediateFlip[ij] 2266 + == 1) { 2267 + v->ModeSupportWithoutImmediateFlip[ij] = 1; 2268 + } else { 2269 + v->ModeSupportWithoutImmediateFlip[ij] = 0; 2270 + } 2271 + } else { 2272 + v->ModeSupportWithImmediateFlip[ij] = 0; 2273 + v->ModeSupportWithoutImmediateFlip[ij] = 0; 2274 + } 2275 + } 2276 + } 2277 + 2278 + for (i = (NumberOfStatesPlusTwo - 1); i >= 0; i--) // use int type here 2279 + { 2280 + if ((i == (NumberOfStatesPlusTwo - 1) 2281 + || v->ModeSupportWithImmediateFlip[1 * NumberOfStatesPlusTwo + i] 2282 + == 1 2283 + || v->ModeSupportWithImmediateFlip[0 * NumberOfStatesPlusTwo + i] 2284 + == 1) && i >= v->VoltageOverrideLevel) { 2285 + v->VoltageLevelWithImmediateFlip = i; 2286 + } 2287 + } 2288 + 2289 + for (i = (NumberOfStatesPlusTwo - 1); i >= 0; i--) // use int type here 2290 + { 2291 + if ((i == (NumberOfStatesPlusTwo - 1) 2292 + || v->ModeSupportWithoutImmediateFlip[1 * NumberOfStatesPlusTwo + i] 2293 + == 1 2294 + || v->ModeSupportWithoutImmediateFlip[0 * NumberOfStatesPlusTwo + i] 2295 + == 1) && i >= v->VoltageOverrideLevel) { 2296 + v->VoltageLevelWithoutImmediateFlip = i; 2297 + } 2298 + } 2299 + 2300 + if (v->VoltageLevelWithImmediateFlip == (NumberOfStatesPlusTwo - 1)) { 2301 + v->ImmediateFlipSupported = 0; 2302 + v->VoltageLevel = v->VoltageLevelWithoutImmediateFlip; 2303 + } else { 2304 + v->ImmediateFlipSupported = 1; 2305 + v->VoltageLevel = v->VoltageLevelWithImmediateFlip; 2306 + } 2307 + 2308 + v->DCFCLK = v->DCFCLKPerState[(int) v->VoltageLevel]; 2309 + v->FabricAndDRAMBandwidth = v->FabricAndDRAMBandwidthPerState[(int) v->VoltageLevel]; 2310 + 2311 + for (j = 0; j < 2; j++) { 2312 + v->RequiredDISPCLKPerRatio[j] = v->RequiredDISPCLK[j * NumberOfStatesPlusTwo 2313 + + (int) v->VoltageLevel]; 2314 + for (k = 0; k < num_planes; k++) { 2315 + v->DPPPerPlanePerRatio[k * 2 + j] = v->NoOfDPP[k * 2 * NumberOfStatesPlusTwo 2316 + + j * NumberOfStatesPlusTwo + (int) v->VoltageLevel]; 2317 + } 2318 + v->DISPCLK_DPPCLK_SupportPerRatio[j] = v->DISPCLK_DPPCLK_Support[j 2319 + * NumberOfStatesPlusTwo + (int) v->VoltageLevel]; 2320 + } 2321 + 2322 + ASSERT(v->ImmediateFlipSupported || v->MacroTileBlockWidthC || v->DCFCLK || v->FabricAndDRAMBandwidth); 2323 + 2324 + return (v->VoltageLevel); 2325 + } 2326 +
+199
drivers/gpu/drm/amd/display/dc/dml/display_mode_support.h
··· 1 + /* 2 + * Copyright 2017 Advanced Micro Devices, Inc. 3 + * 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: 10 + * 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 13 + * 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. 21 + * 22 + * Authors: AMD 23 + * 24 + */ 25 + #ifndef __DISPLAY_MODE_SUPPORT_H__ 26 + #define __DISPLAY_MODE_SUPPORT_H__ 27 + 28 + #include "dml_common_defs.h" 29 + 30 + struct display_mode_lib; 31 + 32 + #define NumberOfStates 4 33 + #define NumberOfStatesPlusTwo (NumberOfStates+2) 34 + 35 + struct dml_ms_internal_vars { 36 + double ScaleRatioSupport; 37 + double SourceFormatPixelAndScanSupport; 38 + double TotalReadBandwidthConsumedGBytePerSecond; 39 + double TotalWriteBandwidthConsumedGBytePerSecond; 40 + double TotalBandwidthConsumedGBytePerSecond; 41 + double DCCEnabledInAnyPlane; 42 + double ReturnBWToDCNPerState; 43 + double CriticalPoint; 44 + double WritebackLatencySupport; 45 + double RequiredOutputBW; 46 + double TotalNumberOfActiveWriteback; 47 + double TotalAvailableWritebackSupport; 48 + double MaximumSwathWidth; 49 + double NumberOfDPPRequiredForDETSize; 50 + double NumberOfDPPRequiredForLBSize; 51 + double MinDispclkUsingSingleDPP; 52 + double MinDispclkUsingDualDPP; 53 + double ViewportSizeSupport; 54 + double SwathWidthGranularityY; 55 + double RoundedUpMaxSwathSizeBytesY; 56 + double SwathWidthGranularityC; 57 + double RoundedUpMaxSwathSizeBytesC; 58 + double LinesInDETLuma; 59 + double LinesInDETChroma; 60 + double EffectiveLBLatencyHidingSourceLinesLuma; 61 + double EffectiveLBLatencyHidingSourceLinesChroma; 62 + double EffectiveDETLBLinesLuma; 63 + double EffectiveDETLBLinesChroma; 64 + double ProjectedDCFCLKDeepSleep; 65 + double MetaReqHeightY; 66 + double MetaReqWidthY; 67 + double MetaSurfaceWidthY; 68 + double MetaSurfaceHeightY; 69 + double MetaPteBytesPerFrameY; 70 + double MetaRowBytesY; 71 + double MacroTileBlockSizeBytesY; 72 + double MacroTileBlockHeightY; 73 + double DataPTEReqHeightY; 74 + double DataPTEReqWidthY; 75 + double DPTEBytesPerRowY; 76 + double MetaReqHeightC; 77 + double MetaReqWidthC; 78 + double MetaSurfaceWidthC; 79 + double MetaSurfaceHeightC; 80 + double MetaPteBytesPerFrameC; 81 + double MetaRowBytesC; 82 + double MacroTileBlockSizeBytesC; 83 + double MacroTileBlockHeightC; 84 + double MacroTileBlockWidthC; 85 + double DataPTEReqHeightC; 86 + double DataPTEReqWidthC; 87 + double DPTEBytesPerRowC; 88 + double VInitY; 89 + double MaxPartialSwY; 90 + double VInitC; 91 + double MaxPartialSwC; 92 + double dst_x_after_scaler; 93 + double dst_y_after_scaler; 94 + double TimeCalc; 95 + double VUpdateOffset; 96 + double TotalRepeaterDelay; 97 + double VUpdateWidth; 98 + double VReadyOffset; 99 + double TimeSetup; 100 + double ExtraLatency; 101 + double MaximumVStartup; 102 + double BWAvailableForImmediateFlip; 103 + double TotalImmediateFlipBytes; 104 + double TimeForMetaPTEWithImmediateFlip; 105 + double TimeForMetaPTEWithoutImmediateFlip; 106 + double TimeForMetaAndDPTERowWithImmediateFlip; 107 + double TimeForMetaAndDPTERowWithoutImmediateFlip; 108 + double LineTimesToRequestPrefetchPixelDataWithImmediateFlip; 109 + double LineTimesToRequestPrefetchPixelDataWithoutImmediateFlip; 110 + double MaximumReadBandwidthWithPrefetchWithImmediateFlip; 111 + double MaximumReadBandwidthWithPrefetchWithoutImmediateFlip; 112 + double VoltageOverrideLevel; 113 + double VoltageLevelWithImmediateFlip; 114 + double VoltageLevelWithoutImmediateFlip; 115 + double ImmediateFlipSupported; 116 + double VoltageLevel; 117 + double DCFCLK; 118 + double FabricAndDRAMBandwidth; 119 + double SwathWidthYSingleDPP[DC__NUM_PIPES__MAX]; 120 + double BytePerPixelInDETY[DC__NUM_PIPES__MAX]; 121 + double BytePerPixelInDETC[DC__NUM_PIPES__MAX]; 122 + double ReadBandwidth[DC__NUM_PIPES__MAX]; 123 + double WriteBandwidth[DC__NUM_PIPES__MAX]; 124 + double DCFCLKPerState[NumberOfStatesPlusTwo]; 125 + double FabricAndDRAMBandwidthPerState[NumberOfStatesPlusTwo]; 126 + double ReturnBWPerState[NumberOfStatesPlusTwo]; 127 + double BandwidthSupport[NumberOfStatesPlusTwo]; 128 + double UrgentRoundTripAndOutOfOrderLatencyPerState[NumberOfStatesPlusTwo]; 129 + double ROBSupport[NumberOfStatesPlusTwo]; 130 + double RequiredPHYCLK[DC__NUM_PIPES__MAX]; 131 + double DIOSupport[NumberOfStatesPlusTwo]; 132 + double PHYCLKPerState[NumberOfStatesPlusTwo]; 133 + double PSCL_FACTOR[DC__NUM_PIPES__MAX]; 134 + double PSCL_FACTOR_CHROMA[DC__NUM_PIPES__MAX]; 135 + double MinDPPCLKUsingSingleDPP[DC__NUM_PIPES__MAX]; 136 + double Read256BlockHeightY[DC__NUM_PIPES__MAX]; 137 + double Read256BlockWidthY[DC__NUM_PIPES__MAX]; 138 + double Read256BlockHeightC[DC__NUM_PIPES__MAX]; 139 + double Read256BlockWidthC[DC__NUM_PIPES__MAX]; 140 + double MaxSwathHeightY[DC__NUM_PIPES__MAX]; 141 + double MaxSwathHeightC[DC__NUM_PIPES__MAX]; 142 + double MinSwathHeightY[DC__NUM_PIPES__MAX]; 143 + double MinSwathHeightC[DC__NUM_PIPES__MAX]; 144 + double NumberOfDPPRequiredForDETAndLBSize[DC__NUM_PIPES__MAX]; 145 + double TotalNumberOfActiveDPP[NumberOfStatesPlusTwo * 2]; 146 + double RequiredDISPCLK[NumberOfStatesPlusTwo * 2]; 147 + double DISPCLK_DPPCLK_Support[NumberOfStatesPlusTwo * 2]; 148 + double MaxDispclk[NumberOfStatesPlusTwo]; 149 + double MaxDppclk[NumberOfStatesPlusTwo]; 150 + double NoOfDPP[NumberOfStatesPlusTwo * 2 * DC__NUM_PIPES__MAX]; 151 + double TotalAvailablePipesSupport[NumberOfStatesPlusTwo * 2]; 152 + double SwathWidthYPerState[NumberOfStatesPlusTwo * 2 * DC__NUM_PIPES__MAX]; 153 + double SwathHeightYPerState[NumberOfStatesPlusTwo * 2 * DC__NUM_PIPES__MAX]; 154 + double SwathHeightCPerState[NumberOfStatesPlusTwo * 2 * DC__NUM_PIPES__MAX]; 155 + double DETBufferSizeYPerState[NumberOfStatesPlusTwo * 2 * DC__NUM_PIPES__MAX]; 156 + double UrgentLatencySupportUsPerState[NumberOfStatesPlusTwo * 2 * DC__NUM_PIPES__MAX]; 157 + double UrgentLatencySupport[NumberOfStatesPlusTwo * 2]; 158 + double TotalNumberOfDCCActiveDPP[NumberOfStatesPlusTwo * 2]; 159 + double DPTEBytesPerRow[DC__NUM_PIPES__MAX]; 160 + double MetaPTEBytesPerFrame[DC__NUM_PIPES__MAX]; 161 + double MetaRowBytes[DC__NUM_PIPES__MAX]; 162 + double PrefillY[DC__NUM_PIPES__MAX]; 163 + double MaxNumSwY[DC__NUM_PIPES__MAX]; 164 + double PrefetchLinesY[DC__NUM_PIPES__MAX]; 165 + double PrefillC[DC__NUM_PIPES__MAX]; 166 + double MaxNumSwC[DC__NUM_PIPES__MAX]; 167 + double PrefetchLinesC[DC__NUM_PIPES__MAX]; 168 + double LineTimesForPrefetch[DC__NUM_PIPES__MAX]; 169 + double PrefetchBW[DC__NUM_PIPES__MAX]; 170 + double LinesForMetaPTEWithImmediateFlip[DC__NUM_PIPES__MAX]; 171 + double LinesForMetaPTEWithoutImmediateFlip[DC__NUM_PIPES__MAX]; 172 + double LinesForMetaAndDPTERowWithImmediateFlip[DC__NUM_PIPES__MAX]; 173 + double LinesForMetaAndDPTERowWithoutImmediateFlip[DC__NUM_PIPES__MAX]; 174 + double VRatioPreYWithImmediateFlip[NumberOfStatesPlusTwo * 2 * DC__NUM_PIPES__MAX]; 175 + double VRatioPreCWithImmediateFlip[NumberOfStatesPlusTwo * 2 * DC__NUM_PIPES__MAX]; 176 + double RequiredPrefetchPixelDataBWWithImmediateFlip[NumberOfStatesPlusTwo * 2 177 + * DC__NUM_PIPES__MAX]; 178 + double VRatioPreYWithoutImmediateFlip[NumberOfStatesPlusTwo * 2 * DC__NUM_PIPES__MAX]; 179 + double VRatioPreCWithoutImmediateFlip[NumberOfStatesPlusTwo * 2 * DC__NUM_PIPES__MAX]; 180 + double RequiredPrefetchPixelDataBWWithoutImmediateFlip[NumberOfStatesPlusTwo * 2 181 + * DC__NUM_PIPES__MAX]; 182 + double PrefetchSupportedWithImmediateFlip[NumberOfStatesPlusTwo * 2]; 183 + double PrefetchSupportedWithoutImmediateFlip[NumberOfStatesPlusTwo * 2]; 184 + double VRatioInPrefetchSupportedWithImmediateFlip[NumberOfStatesPlusTwo * 2]; 185 + double VRatioInPrefetchSupportedWithoutImmediateFlip[NumberOfStatesPlusTwo * 2]; 186 + double ModeSupportWithImmediateFlip[NumberOfStatesPlusTwo * 2]; 187 + double ModeSupportWithoutImmediateFlip[NumberOfStatesPlusTwo * 2]; 188 + double RequiredDISPCLKPerRatio[2]; 189 + double DPPPerPlanePerRatio[2 * DC__NUM_PIPES__MAX]; 190 + double DISPCLK_DPPCLK_SupportPerRatio[2]; 191 + struct _vcs_dpi_wm_calc_pipe_params_st planes[DC__NUM_PIPES__MAX]; 192 + }; 193 + 194 + int dml_ms_check( 195 + struct display_mode_lib *mode_lib, 196 + struct _vcs_dpi_display_e2e_pipe_params_st *e2e, 197 + int num_pipes); 198 + 199 + #endif
+367
drivers/gpu/drm/amd/display/dc/dml/display_pipe_clocks.c
··· 1 + /* 2 + * Copyright 2017 Advanced Micro Devices, Inc. 3 + * 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: 10 + * 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 13 + * 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. 21 + * 22 + * Authors: AMD 23 + * 24 + */ 25 + 26 + #include "display_pipe_clocks.h" 27 + #include "display_mode_lib.h" 28 + #include "soc_bounding_box.h" 29 + 30 + static enum voltage_state power_state( 31 + struct display_mode_lib *mode_lib, 32 + double dispclk, 33 + double dppclk) 34 + { 35 + enum voltage_state state1; 36 + enum voltage_state state2; 37 + 38 + if (dispclk <= mode_lib->soc.vmin.dispclk_mhz) 39 + state1 = dm_vmin; 40 + else if (dispclk <= mode_lib->soc.vnom.dispclk_mhz) 41 + state1 = dm_vnom; 42 + else if (dispclk <= mode_lib->soc.vmax.dispclk_mhz) 43 + state1 = dm_vmax; 44 + else 45 + state1 = dm_vmax_exceeded; 46 + 47 + if (dppclk <= mode_lib->soc.vmin.dppclk_mhz) 48 + state2 = dm_vmin; 49 + else if (dppclk <= mode_lib->soc.vnom.dppclk_mhz) 50 + state2 = dm_vnom; 51 + else if (dppclk <= mode_lib->soc.vmax.dppclk_mhz) 52 + state2 = dm_vmax; 53 + else 54 + state2 = dm_vmax_exceeded; 55 + 56 + if (state1 > state2) 57 + return state1; 58 + else 59 + return state2; 60 + } 61 + 62 + static unsigned int dpp_in_grp( 63 + struct _vcs_dpi_display_e2e_pipe_params_st *e2e, 64 + unsigned int num_pipes, 65 + unsigned int hsplit_grp) 66 + { 67 + unsigned int num_dpp = 0; 68 + unsigned int i; 69 + 70 + for (i = 0; i < num_pipes; i++) { 71 + if (e2e[i].pipe.src.is_hsplit) { 72 + if (e2e[i].pipe.src.hsplit_grp == hsplit_grp) { 73 + num_dpp++; 74 + } 75 + } 76 + } 77 + 78 + if (0 == num_dpp) 79 + num_dpp = 1; 80 + 81 + return num_dpp; 82 + } 83 + 84 + static void calculate_pipe_clk_requirement( 85 + struct display_mode_lib *mode_lib, 86 + struct _vcs_dpi_display_e2e_pipe_params_st *e2e, 87 + unsigned int num_dpp_in_grp, 88 + double *dppclk, 89 + double *dispclk, 90 + bool *dppdiv) 91 + { 92 + double pscl_throughput = 0.0; 93 + double max_hratio = e2e->pipe.scale_ratio_depth.hscl_ratio; 94 + double max_vratio = e2e->pipe.scale_ratio_depth.vscl_ratio; 95 + double max_htaps = e2e->pipe.scale_taps.htaps; 96 + double max_vtaps = e2e->pipe.scale_taps.vtaps; 97 + double dpp_clock_divider = (double) num_dpp_in_grp; 98 + double dispclk_dppclk_ratio; 99 + double dispclk_ramp_margin_percent; 100 + 101 + if (max_hratio > 1.0) { 102 + double pscl_to_lb = ((double) mode_lib->ip.max_pscl_lb_bw_pix_per_clk * max_hratio) 103 + / dml_ceil(max_htaps / 6.0); 104 + pscl_throughput = dml_min( 105 + pscl_to_lb, 106 + (double) mode_lib->ip.max_dchub_pscl_bw_pix_per_clk); 107 + } else { 108 + pscl_throughput = dml_min( 109 + (double) mode_lib->ip.max_pscl_lb_bw_pix_per_clk, 110 + (double) mode_lib->ip.max_dchub_pscl_bw_pix_per_clk); 111 + } 112 + 113 + DTRACE("pscl_throughput: %f pix per clk", pscl_throughput); 114 + DTRACE("vtaps: %f hratio: %f vratio: %f", max_vtaps, max_hratio, max_vratio); 115 + *dppclk = dml_max( 116 + max_vtaps / 6.0 * dml_min(1.0, max_hratio), 117 + max_hratio * max_vratio / pscl_throughput); 118 + DTRACE("pixel rate multiplier: %f", *dppclk); 119 + *dppclk = dml_max(*dppclk, 1.0); 120 + DTRACE("pixel rate multiplier clamped: %f", *dppclk); 121 + *dppclk = *dppclk * e2e->pipe.dest.pixel_rate_mhz; 122 + 123 + *dppclk = *dppclk / dpp_clock_divider; 124 + DTRACE("dppclk after split: %f", *dppclk); 125 + 126 + if (dpp_clock_divider > 1.0 && (*dppclk < e2e->pipe.dest.pixel_rate_mhz)) { 127 + dispclk_dppclk_ratio = 2.0; 128 + *dppdiv = true; 129 + } else { 130 + dispclk_dppclk_ratio = 1.0; 131 + *dppdiv = false; 132 + } 133 + 134 + dispclk_ramp_margin_percent = mode_lib->ip.dispclk_ramp_margin_percent; 135 + 136 + /* Comment this out because of Gabes possible bug in spreadsheet, 137 + * just to make other cases evident during debug 138 + * 139 + *if(e2e->clks_cfg.voltage == dm_vmax) 140 + * dispclk_ramp_margin_percent = 0.0; 141 + */ 142 + 143 + /* account for ramping margin and downspread */ 144 + *dispclk = dml_max(*dppclk * dispclk_dppclk_ratio, e2e->pipe.dest.pixel_rate_mhz) 145 + * (1.0 + (double) mode_lib->soc.downspread_percent / 100.0) 146 + * (1.0 + (double) dispclk_ramp_margin_percent / 100.0); 147 + 148 + return; 149 + } 150 + 151 + bool dml_clks_pipe_clock_requirement_fit_power_constraint( 152 + struct display_mode_lib *mode_lib, 153 + struct _vcs_dpi_display_e2e_pipe_params_st *e2e, 154 + unsigned int num_dpp_in_grp) 155 + { 156 + double dppclk = 0; 157 + double dispclk = 0; 158 + bool dppdiv = 0; 159 + 160 + calculate_pipe_clk_requirement(mode_lib, e2e, num_dpp_in_grp, &dppclk, &dispclk, &dppdiv); 161 + 162 + if (power_state(mode_lib, dispclk, dppclk) > e2e->clks_cfg.voltage) { 163 + return false; 164 + } 165 + 166 + return true; 167 + } 168 + 169 + static void get_plane_clks( 170 + struct display_mode_lib *mode_lib, 171 + struct _vcs_dpi_display_e2e_pipe_params_st *e2e, 172 + unsigned int num_pipes, 173 + double *dppclks, 174 + double *dispclks, 175 + bool *dppdiv) 176 + { 177 + /* it is assumed that the scale ratios passed into the e2e pipe params have already been calculated 178 + * for any split pipe configurations, where extra pixels inthe overlap region do not contribute to 179 + * the scale ratio. This means that we can simply calculate the dppclk for each dpp independently 180 + * and we would expect the same result on any split pipes, which would be handled 181 + */ 182 + unsigned int i; 183 + 184 + for (i = 0; i < num_pipes; i++) { 185 + double num_dpp_in_grp; 186 + double dispclk_ramp_margin_percent; 187 + double dispclk_margined; 188 + 189 + if (e2e[i].pipe.src.is_hsplit) 190 + num_dpp_in_grp = (double) dpp_in_grp( 191 + e2e, 192 + num_pipes, 193 + e2e[i].pipe.src.hsplit_grp); 194 + else 195 + num_dpp_in_grp = 1; 196 + 197 + calculate_pipe_clk_requirement( 198 + mode_lib, 199 + &e2e[i], 200 + num_dpp_in_grp, 201 + &dppclks[i], 202 + &dispclks[i], 203 + &dppdiv[i]); 204 + 205 + dispclk_ramp_margin_percent = mode_lib->ip.dispclk_ramp_margin_percent; 206 + 207 + dispclk_margined = e2e[i].pipe.dest.pixel_rate_mhz 208 + * (1.0 + (double) mode_lib->soc.downspread_percent / 100.0) 209 + * (1.0 + (double) dispclk_ramp_margin_percent / 100.0); 210 + 211 + DTRACE("p%d: requested power state: %d", i, (int) e2e[0].clks_cfg.voltage); 212 + 213 + if (power_state(mode_lib, dispclks[i], dppclks[i]) 214 + > power_state(mode_lib, dispclk_margined, dispclk_margined) 215 + && dispclk_margined > dppclks[i]) { 216 + if (power_state(mode_lib, dispclks[i], dppclks[i]) 217 + > e2e[0].clks_cfg.voltage) { 218 + dispclks[i] = dispclk_margined; 219 + dppclks[i] = dispclk_margined; 220 + dppdiv[i] = false; 221 + } 222 + } 223 + 224 + DTRACE("p%d: dispclk: %f", i, dispclks[i]); 225 + } 226 + } 227 + 228 + static void get_dcfclk( 229 + struct display_mode_lib *mode_lib, 230 + struct _vcs_dpi_display_e2e_pipe_params_st *e2e, 231 + unsigned int num_pipes, 232 + double *dcfclk_mhz) 233 + { 234 + double bytes_per_pixel_det_y[DC__NUM_PIPES__MAX]; 235 + double bytes_per_pixel_det_c[DC__NUM_PIPES__MAX]; 236 + double swath_width_y[DC__NUM_PIPES__MAX]; 237 + unsigned int i; 238 + double total_read_bandwidth_gbps = 0.0; 239 + 240 + for (i = 0; i < num_pipes; i++) { 241 + if (e2e[i].pipe.src.source_scan == dm_horz) { 242 + swath_width_y[i] = e2e[i].pipe.src.viewport_width * 1.0; 243 + } else { 244 + swath_width_y[i] = e2e[i].pipe.src.viewport_height * 1.0; 245 + } 246 + 247 + switch (e2e[i].pipe.src.source_format) { 248 + case dm_444_64: 249 + bytes_per_pixel_det_y[i] = 8.0; 250 + bytes_per_pixel_det_c[i] = 0.0; 251 + break; 252 + case dm_444_32: 253 + bytes_per_pixel_det_y[i] = 4.0; 254 + bytes_per_pixel_det_c[i] = 0.0; 255 + break; 256 + case dm_444_16: 257 + bytes_per_pixel_det_y[i] = 2.0; 258 + bytes_per_pixel_det_c[i] = 0.0; 259 + break; 260 + case dm_422_8: 261 + bytes_per_pixel_det_y[i] = 2.0; 262 + bytes_per_pixel_det_c[i] = 0.0; 263 + break; 264 + case dm_422_10: 265 + bytes_per_pixel_det_y[i] = 4.0; 266 + bytes_per_pixel_det_c[i] = 0.0; 267 + break; 268 + case dm_420_8: 269 + bytes_per_pixel_det_y[i] = 1.0; 270 + bytes_per_pixel_det_c[i] = 2.0; 271 + break; 272 + case dm_420_10: 273 + bytes_per_pixel_det_y[i] = 4.0 / 3.0; 274 + bytes_per_pixel_det_c[i] = 8.0 / 3.0; 275 + break; 276 + default: 277 + BREAK_TO_DEBUGGER(); /* invalid src_format in get_dcfclk */ 278 + } 279 + } 280 + 281 + for (i = 0; i < num_pipes; i++) { 282 + double read_bandwidth_plane_mbps = 0.0; 283 + read_bandwidth_plane_mbps = (double) swath_width_y[i] 284 + * ((double) bytes_per_pixel_det_y[i] 285 + + (double) bytes_per_pixel_det_c[i] / 2.0) 286 + / ((double) e2e[i].pipe.dest.htotal 287 + / (double) e2e[i].pipe.dest.pixel_rate_mhz) 288 + * e2e[i].pipe.scale_ratio_depth.vscl_ratio; 289 + 290 + if (e2e[i].pipe.src.dcc) { 291 + read_bandwidth_plane_mbps += (read_bandwidth_plane_mbps / 1000.0 / 256.0); 292 + } 293 + 294 + if (e2e[i].pipe.src.vm) { 295 + read_bandwidth_plane_mbps += (read_bandwidth_plane_mbps / 1000.0 / 512.0); 296 + } 297 + 298 + total_read_bandwidth_gbps = total_read_bandwidth_gbps 299 + + read_bandwidth_plane_mbps / 1000.0; 300 + } 301 + 302 + DTRACE("total bandwidth = %f gbps", total_read_bandwidth_gbps); 303 + 304 + (*dcfclk_mhz) = (total_read_bandwidth_gbps * 1000.0) / mode_lib->soc.return_bus_width_bytes; 305 + 306 + DTRACE( 307 + "minimum theoretical dcfclk without stutter and full utilization = %f MHz", 308 + (*dcfclk_mhz)); 309 + 310 + } 311 + 312 + struct _vcs_dpi_display_pipe_clock_st dml_clks_get_pipe_clocks( 313 + struct display_mode_lib *mode_lib, 314 + struct _vcs_dpi_display_e2e_pipe_params_st *e2e, 315 + unsigned int num_pipes) 316 + { 317 + struct _vcs_dpi_display_pipe_clock_st clocks; 318 + double max_dispclk = 0.0; 319 + double dcfclk; 320 + double dispclks[DC__NUM_PIPES__MAX]; 321 + double dppclks[DC__NUM_PIPES__MAX]; 322 + bool dppdiv[DC__NUM_PIPES__MAX]; 323 + unsigned int i; 324 + 325 + DTRACE("Calculating pipe clocks..."); 326 + 327 + /* this is the theoretical minimum, have to adjust based on valid values for soc */ 328 + get_dcfclk(mode_lib, e2e, num_pipes, &dcfclk); 329 + 330 + /* if(dcfclk > soc.vnom.dcfclk_mhz) 331 + * dcfclk = soc.vmax.dcfclk_mhz; 332 + * else if(dcfclk > soc.vmin.dcfclk_mhz) 333 + * dcfclk = soc.vnom.dcfclk_mhz; 334 + * else 335 + * dcfclk = soc.vmin.dcfclk_mhz; 336 + */ 337 + 338 + dcfclk = dml_socbb_voltage_scaling( 339 + &mode_lib->soc, 340 + (enum voltage_state) e2e[0].clks_cfg.voltage).dcfclk_mhz; 341 + clocks.dcfclk_mhz = dcfclk; 342 + 343 + get_plane_clks(mode_lib, e2e, num_pipes, dppclks, dispclks, dppdiv); 344 + 345 + for (i = 0; i < num_pipes; i++) { 346 + max_dispclk = dml_max(max_dispclk, dispclks[i]); 347 + } 348 + 349 + clocks.dispclk_mhz = max_dispclk; 350 + DTRACE("dispclk: %f Mhz", clocks.dispclk_mhz); 351 + DTRACE("dcfclk: %f Mhz", clocks.dcfclk_mhz); 352 + 353 + for (i = 0; i < num_pipes; i++) { 354 + if (dppclks[i] * 2 < max_dispclk) 355 + dppdiv[i] = 1; 356 + 357 + if (dppdiv[i]) 358 + clocks.dppclk_div[i] = 1; 359 + else 360 + clocks.dppclk_div[i] = 0; 361 + 362 + clocks.dppclk_mhz[i] = max_dispclk / ((dppdiv[i]) ? 2.0 : 1.0); 363 + DTRACE("dppclk%d: %f Mhz", i, clocks.dppclk_mhz[i]); 364 + } 365 + 366 + return clocks; 367 + }
+41
drivers/gpu/drm/amd/display/dc/dml/display_pipe_clocks.h
··· 1 + /* 2 + * Copyright 2017 Advanced Micro Devices, Inc. 3 + * 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: 10 + * 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 13 + * 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. 21 + * 22 + * Authors: AMD 23 + * 24 + */ 25 + #ifndef __DISPLAY_PIPE_CLOCKS_H__ 26 + #define __DISPLAY_PIPE_CLOCKS_H__ 27 + 28 + #include "dml_common_defs.h" 29 + 30 + struct display_mode_lib; 31 + 32 + struct _vcs_dpi_display_pipe_clock_st dml_clks_get_pipe_clocks( 33 + struct display_mode_lib *mode_lib, 34 + struct _vcs_dpi_display_e2e_pipe_params_st *e2e, 35 + unsigned int num_pipes); 36 + 37 + bool dml_clks_pipe_clock_requirement_fit_power_constraint( 38 + struct display_mode_lib *mode_lib, 39 + struct _vcs_dpi_display_e2e_pipe_params_st *e2e, 40 + unsigned int num_dpp_in_grp); 41 + #endif
+2254
drivers/gpu/drm/amd/display/dc/dml/display_rq_dlg_calc.c
··· 1 + /* 2 + * Copyright 2017 Advanced Micro Devices, Inc. 3 + * 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: 10 + * 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 13 + * 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. 21 + * 22 + * Authors: AMD 23 + * 24 + */ 25 + #include "display_rq_dlg_calc.h" 26 + #include "display_mode_lib.h" 27 + 28 + static unsigned int get_bytes_per_element(enum source_format_class source_format, bool is_chroma) 29 + { 30 + unsigned int ret_val = 0; 31 + 32 + if (source_format == dm_444_16) { 33 + if (!is_chroma) 34 + ret_val = 2; 35 + } else if (source_format == dm_444_32) { 36 + if (!is_chroma) 37 + ret_val = 4; 38 + } else if (source_format == dm_444_64) { 39 + if (!is_chroma) 40 + ret_val = 8; 41 + } else if (source_format == dm_420_8) { 42 + if (is_chroma) 43 + ret_val = 2; 44 + else 45 + ret_val = 1; 46 + } else if (source_format == dm_420_10) { 47 + if (is_chroma) 48 + ret_val = 4; 49 + else 50 + ret_val = 2; 51 + } 52 + return ret_val; 53 + } 54 + 55 + static bool is_dual_plane(enum source_format_class source_format) 56 + { 57 + bool ret_val = 0; 58 + 59 + if ((source_format == dm_420_8) || (source_format == dm_420_10)) 60 + ret_val = 1; 61 + 62 + return ret_val; 63 + } 64 + 65 + static void get_blk256_size( 66 + unsigned int *blk256_width, 67 + unsigned int *blk256_height, 68 + unsigned int bytes_per_element) 69 + { 70 + if (bytes_per_element == 1) { 71 + *blk256_width = 16; 72 + *blk256_height = 16; 73 + } else if (bytes_per_element == 2) { 74 + *blk256_width = 16; 75 + *blk256_height = 8; 76 + } else if (bytes_per_element == 4) { 77 + *blk256_width = 8; 78 + *blk256_height = 8; 79 + } else if (bytes_per_element == 8) { 80 + *blk256_width = 8; 81 + *blk256_height = 4; 82 + } 83 + } 84 + 85 + static double get_refcyc_per_delivery( 86 + struct display_mode_lib *mode_lib, 87 + double refclk_freq_in_mhz, 88 + double pclk_freq_in_mhz, 89 + int unsigned recout_width, 90 + double vratio, 91 + double hscale_pixel_rate, 92 + int unsigned delivery_width, 93 + int unsigned req_per_swath_ub) 94 + { 95 + double refcyc_per_delivery = 0.0; 96 + if (vratio <= 1.0) { 97 + refcyc_per_delivery = (double) refclk_freq_in_mhz * (double) recout_width 98 + / pclk_freq_in_mhz / (double) req_per_swath_ub; 99 + } else { 100 + refcyc_per_delivery = (double) refclk_freq_in_mhz * (double) delivery_width 101 + / (double) hscale_pixel_rate / (double) req_per_swath_ub; 102 + } 103 + 104 + DTRACE("DLG: %s: refclk_freq_in_mhz = %3.2f", __func__, refclk_freq_in_mhz); 105 + DTRACE("DLG: %s: pclk_freq_in_mhz = %3.2f", __func__, pclk_freq_in_mhz); 106 + DTRACE("DLG: %s: recout_width = %d", __func__, recout_width); 107 + DTRACE("DLG: %s: vratio = %3.2f", __func__, vratio); 108 + DTRACE("DLG: %s: req_per_swath_ub = %d", __func__, req_per_swath_ub); 109 + DTRACE("DLG: %s: refcyc_per_delivery= %3.2f", __func__, refcyc_per_delivery); 110 + 111 + return refcyc_per_delivery; 112 + 113 + } 114 + 115 + static double get_vratio_pre( 116 + struct display_mode_lib *mode_lib, 117 + unsigned int max_num_sw, 118 + unsigned int max_partial_sw, 119 + unsigned int swath_height, 120 + double vinit, 121 + double l_sw) 122 + { 123 + double prefill = dml_floor(vinit); 124 + double vratio_pre = 1.0; 125 + 126 + vratio_pre = (max_num_sw * swath_height + max_partial_sw) / l_sw; 127 + 128 + if (swath_height > 4) { 129 + double tmp0 = (max_num_sw * swath_height) / (l_sw - (prefill - 3.0) / 2.0); 130 + if (tmp0 > vratio_pre) 131 + vratio_pre = tmp0; 132 + } 133 + 134 + DTRACE("DLG: %s: max_num_sw = %0d", __func__, max_num_sw); 135 + DTRACE("DLG: %s: max_partial_sw = %0d", __func__, max_partial_sw); 136 + DTRACE("DLG: %s: swath_height = %0d", __func__, swath_height); 137 + DTRACE("DLG: %s: vinit = %3.2f", __func__, vinit); 138 + DTRACE("DLG: %s: vratio_pre = %3.2f", __func__, vratio_pre); 139 + 140 + if (vratio_pre < 1.0) { 141 + DTRACE("WARNING_DLG: %s: vratio_pre=%3.2f < 1.0, set to 1.0", __func__, vratio_pre); 142 + vratio_pre = 1.0; 143 + } 144 + 145 + if (vratio_pre > 4.0) { 146 + DTRACE( 147 + "WARNING_DLG: %s: vratio_pre=%3.2f > 4.0 (max scaling ratio). set to 4.0", 148 + __func__, 149 + vratio_pre); 150 + vratio_pre = 4.0; 151 + } 152 + 153 + return vratio_pre; 154 + } 155 + 156 + static void get_swath_need( 157 + struct display_mode_lib *mode_lib, 158 + unsigned int *max_num_sw, 159 + unsigned int *max_partial_sw, 160 + unsigned int swath_height, 161 + double vinit) 162 + { 163 + double prefill = dml_floor(vinit); 164 + unsigned int max_partial_sw_int; 165 + 166 + DTRACE("DLG: %s: swath_height = %0d", __func__, swath_height); 167 + DTRACE("DLG: %s: vinit = %3.2f", __func__, vinit); 168 + 169 + ASSERT(prefill > 0.0 && prefill <= 8.0); 170 + 171 + *max_num_sw = (int unsigned) (dml_ceil((prefill - 1.0) / (double) swath_height) + 1.0); /* prefill has to be >= 1 */ 172 + max_partial_sw_int = 173 + (prefill == 1) ? 174 + (swath_height - 1) : 175 + ((int unsigned) (prefill - 2.0) % swath_height); 176 + *max_partial_sw = (max_partial_sw_int < 1) ? 1 : max_partial_sw_int; /* ensure minimum of 1 is used */ 177 + 178 + DTRACE("DLG: %s: max_num_sw = %0d", __func__, *max_num_sw); 179 + DTRACE("DLG: %s: max_partial_sw = %0d", __func__, *max_partial_sw); 180 + } 181 + 182 + static unsigned int get_blk_size_bytes(const enum source_macro_tile_size tile_size) 183 + { 184 + if (tile_size == dm_256k_tile) 185 + return (256 * 1024); 186 + else if (tile_size == dm_64k_tile) 187 + return (64 * 1024); 188 + else 189 + return (4 * 1024); 190 + } 191 + 192 + static void extract_rq_sizing_regs( 193 + struct display_mode_lib *mode_lib, 194 + struct _vcs_dpi_display_data_rq_regs_st *rq_regs, 195 + const struct _vcs_dpi_display_data_rq_sizing_params_st rq_sizing) 196 + { 197 + DTRACE("DLG: %s: rq_sizing param", __func__); 198 + print__data_rq_sizing_params_st(mode_lib, rq_sizing); 199 + 200 + rq_regs->chunk_size = dml_log2(rq_sizing.chunk_bytes) - 10; 201 + 202 + if (rq_sizing.min_chunk_bytes == 0) 203 + rq_regs->min_chunk_size = 0; 204 + else 205 + rq_regs->min_chunk_size = dml_log2(rq_sizing.min_chunk_bytes) - 8 + 1; 206 + 207 + rq_regs->meta_chunk_size = dml_log2(rq_sizing.meta_chunk_bytes) - 10; 208 + if (rq_sizing.min_meta_chunk_bytes == 0) 209 + rq_regs->min_meta_chunk_size = 0; 210 + else 211 + rq_regs->min_meta_chunk_size = dml_log2(rq_sizing.min_meta_chunk_bytes) - 6 + 1; 212 + 213 + rq_regs->dpte_group_size = dml_log2(rq_sizing.dpte_group_bytes) - 6; 214 + rq_regs->mpte_group_size = dml_log2(rq_sizing.mpte_group_bytes) - 6; 215 + } 216 + 217 + void extract_rq_regs( 218 + struct display_mode_lib *mode_lib, 219 + struct _vcs_dpi_display_rq_regs_st *rq_regs, 220 + const struct _vcs_dpi_display_rq_params_st rq_param) 221 + { 222 + unsigned int detile_buf_size_in_bytes = mode_lib->ip.det_buffer_size_kbytes * 1024; 223 + unsigned int detile_buf_plane1_addr = 0; 224 + 225 + extract_rq_sizing_regs(mode_lib, &(rq_regs->rq_regs_l), rq_param.sizing.rq_l); 226 + if (rq_param.yuv420) 227 + extract_rq_sizing_regs(mode_lib, &(rq_regs->rq_regs_c), rq_param.sizing.rq_c); 228 + 229 + rq_regs->rq_regs_l.swath_height = dml_log2(rq_param.dlg.rq_l.swath_height); 230 + rq_regs->rq_regs_c.swath_height = dml_log2(rq_param.dlg.rq_c.swath_height); 231 + 232 + /* FIXME: take the max between luma, chroma chunk size? 233 + * okay for now, as we are setting chunk_bytes to 8kb anyways 234 + */ 235 + if (rq_param.sizing.rq_l.chunk_bytes >= 32 * 1024) { /*32kb */ 236 + rq_regs->drq_expansion_mode = 0; 237 + } else { 238 + rq_regs->drq_expansion_mode = 2; 239 + } 240 + rq_regs->prq_expansion_mode = 1; 241 + rq_regs->mrq_expansion_mode = 1; 242 + rq_regs->crq_expansion_mode = 1; 243 + 244 + if (rq_param.yuv420) { 245 + if ((double) rq_param.misc.rq_l.stored_swath_bytes 246 + / (double) rq_param.misc.rq_c.stored_swath_bytes <= 1.5) { 247 + detile_buf_plane1_addr = (detile_buf_size_in_bytes / 2.0 / 64.0); /* half to chroma */ 248 + } else { 249 + detile_buf_plane1_addr = dml_round_to_multiple( 250 + (unsigned int) ((2.0 * detile_buf_size_in_bytes) / 3.0), 251 + 256, 252 + 0) / 64.0; /* 2/3 to chroma */ 253 + } 254 + } 255 + rq_regs->plane1_base_address = detile_buf_plane1_addr; 256 + } 257 + 258 + static void handle_det_buf_split( 259 + struct display_mode_lib *mode_lib, 260 + struct _vcs_dpi_display_rq_params_st *rq_param, 261 + const struct _vcs_dpi_display_pipe_source_params_st pipe_src_param) 262 + { 263 + unsigned int total_swath_bytes = 0; 264 + unsigned int swath_bytes_l = 0; 265 + unsigned int swath_bytes_c = 0; 266 + unsigned int full_swath_bytes_packed_l = 0; 267 + unsigned int full_swath_bytes_packed_c = 0; 268 + bool req128_l = 0; 269 + bool req128_c = 0; 270 + bool surf_linear = (pipe_src_param.sw_mode == dm_sw_linear); 271 + bool surf_vert = (pipe_src_param.source_scan == dm_vert); 272 + unsigned int log2_swath_height_l = 0; 273 + unsigned int log2_swath_height_c = 0; 274 + unsigned int detile_buf_size_in_bytes = mode_lib->ip.det_buffer_size_kbytes * 1024; 275 + 276 + full_swath_bytes_packed_l = rq_param->misc.rq_l.full_swath_bytes; 277 + full_swath_bytes_packed_c = rq_param->misc.rq_c.full_swath_bytes; 278 + 279 + if (rq_param->yuv420_10bpc) { 280 + full_swath_bytes_packed_l = dml_round_to_multiple( 281 + rq_param->misc.rq_l.full_swath_bytes * 2 / 3, 282 + 256, 283 + 1) + 256; 284 + full_swath_bytes_packed_c = dml_round_to_multiple( 285 + rq_param->misc.rq_c.full_swath_bytes * 2 / 3, 286 + 256, 287 + 1) + 256; 288 + } 289 + 290 + if (rq_param->yuv420) { 291 + total_swath_bytes = 2 * full_swath_bytes_packed_l + 2 * full_swath_bytes_packed_c; 292 + 293 + if (total_swath_bytes <= detile_buf_size_in_bytes) { /*full 256b request */ 294 + req128_l = 0; 295 + req128_c = 0; 296 + swath_bytes_l = full_swath_bytes_packed_l; 297 + swath_bytes_c = full_swath_bytes_packed_c; 298 + } else { /*128b request (for luma only for yuv420 8bpc) */ 299 + req128_l = 1; 300 + req128_c = 0; 301 + swath_bytes_l = full_swath_bytes_packed_l / 2; 302 + swath_bytes_c = full_swath_bytes_packed_c; 303 + } 304 + 305 + /* Bug workaround, luma and chroma req size needs to be the same. (see: DEGVIDCN10-137) 306 + * TODO: Remove after rtl fix 307 + */ 308 + if (req128_l == 1) { 309 + req128_c = 1; 310 + DTRACE("DLG: %s: bug workaround DEGVIDCN10-137", __func__); 311 + } 312 + 313 + /* Note: assumption, the config that pass in will fit into 314 + * the detiled buffer. 315 + */ 316 + } else { 317 + total_swath_bytes = 2 * full_swath_bytes_packed_l; 318 + 319 + if (total_swath_bytes <= detile_buf_size_in_bytes) 320 + req128_l = 0; 321 + else 322 + req128_l = 1; 323 + 324 + swath_bytes_l = total_swath_bytes; 325 + swath_bytes_c = 0; 326 + } 327 + rq_param->misc.rq_l.stored_swath_bytes = swath_bytes_l; 328 + rq_param->misc.rq_c.stored_swath_bytes = swath_bytes_c; 329 + 330 + if (surf_linear) { 331 + log2_swath_height_l = 0; 332 + log2_swath_height_c = 0; 333 + } else if (!surf_vert) { 334 + log2_swath_height_l = dml_log2(rq_param->misc.rq_l.blk256_height) - req128_l; 335 + log2_swath_height_c = dml_log2(rq_param->misc.rq_c.blk256_height) - req128_c; 336 + } else { 337 + log2_swath_height_l = dml_log2(rq_param->misc.rq_l.blk256_width) - req128_l; 338 + log2_swath_height_c = dml_log2(rq_param->misc.rq_c.blk256_width) - req128_c; 339 + } 340 + rq_param->dlg.rq_l.swath_height = 1 << log2_swath_height_l; 341 + rq_param->dlg.rq_c.swath_height = 1 << log2_swath_height_c; 342 + 343 + DTRACE("DLG: %s: req128_l = %0d", __func__, req128_l); 344 + DTRACE("DLG: %s: req128_c = %0d", __func__, req128_c); 345 + DTRACE("DLG: %s: full_swath_bytes_packed_l = %0d", __func__, full_swath_bytes_packed_l); 346 + DTRACE("DLG: %s: full_swath_bytes_packed_c = %0d", __func__, full_swath_bytes_packed_c); 347 + } 348 + 349 + /* Need refactor. */ 350 + void dml_rq_dlg_get_row_heights( 351 + struct display_mode_lib *mode_lib, 352 + unsigned int *o_dpte_row_height, 353 + unsigned int *o_meta_row_height, 354 + unsigned int vp_width, 355 + unsigned int data_pitch, 356 + int source_format, 357 + int tiling, 358 + int macro_tile_size, 359 + int source_scan, 360 + int is_chroma) 361 + { 362 + bool surf_linear = (tiling == dm_sw_linear); 363 + bool surf_vert = (source_scan == dm_vert); 364 + 365 + unsigned int bytes_per_element = get_bytes_per_element( 366 + (enum source_format_class) source_format, 367 + is_chroma); 368 + unsigned int log2_bytes_per_element = dml_log2(bytes_per_element); 369 + unsigned int blk256_width = 0; 370 + unsigned int blk256_height = 0; 371 + 372 + unsigned int log2_blk256_height; 373 + unsigned int blk_bytes; 374 + unsigned int log2_blk_bytes; 375 + unsigned int log2_blk_height; 376 + unsigned int log2_blk_width; 377 + unsigned int log2_meta_req_bytes; 378 + unsigned int log2_meta_req_height; 379 + unsigned int log2_meta_req_width; 380 + unsigned int log2_meta_row_height; 381 + unsigned int log2_vmpg_bytes; 382 + unsigned int dpte_buf_in_pte_reqs; 383 + unsigned int log2_vmpg_height; 384 + unsigned int log2_vmpg_width; 385 + unsigned int log2_dpte_req_height_ptes; 386 + unsigned int log2_dpte_req_width_ptes; 387 + unsigned int log2_dpte_req_height; 388 + unsigned int log2_dpte_req_width; 389 + unsigned int log2_dpte_row_height_linear; 390 + unsigned int log2_dpte_row_height; 391 + unsigned int dpte_req_width; 392 + 393 + if (surf_linear) { 394 + blk256_width = 256; 395 + blk256_height = 1; 396 + } else { 397 + get_blk256_size(&blk256_width, &blk256_height, bytes_per_element); 398 + } 399 + 400 + log2_blk256_height = dml_log2((double) blk256_height); 401 + blk_bytes = surf_linear ? 402 + 256 : get_blk_size_bytes((enum source_macro_tile_size) macro_tile_size); 403 + log2_blk_bytes = dml_log2((double) blk_bytes); 404 + log2_blk_height = 0; 405 + log2_blk_width = 0; 406 + 407 + /* remember log rule 408 + * "+" in log is multiply 409 + * "-" in log is divide 410 + * "/2" is like square root 411 + * blk is vertical biased 412 + */ 413 + if (tiling != dm_sw_linear) 414 + log2_blk_height = log2_blk256_height 415 + + dml_ceil((double) (log2_blk_bytes - 8) / 2.0); 416 + else 417 + log2_blk_height = 0; /* blk height of 1 */ 418 + 419 + log2_blk_width = log2_blk_bytes - log2_bytes_per_element - log2_blk_height; 420 + 421 + /* ------- */ 422 + /* meta */ 423 + /* ------- */ 424 + log2_meta_req_bytes = 6; /* meta request is 64b and is 8x8byte meta element */ 425 + 426 + /* each 64b meta request for dcn is 8x8 meta elements and 427 + * a meta element covers one 256b block of the the data surface. 428 + */ 429 + log2_meta_req_height = log2_blk256_height + 3; /* meta req is 8x8 */ 430 + log2_meta_req_width = log2_meta_req_bytes + 8 - log2_bytes_per_element 431 + - log2_meta_req_height; 432 + log2_meta_row_height = 0; 433 + 434 + /* the dimensions of a meta row are meta_row_width x meta_row_height in elements. 435 + * calculate upper bound of the meta_row_width 436 + */ 437 + if (!surf_vert) 438 + log2_meta_row_height = log2_meta_req_height; 439 + else 440 + log2_meta_row_height = log2_meta_req_width; 441 + 442 + *o_meta_row_height = 1 << log2_meta_row_height; 443 + 444 + /* ------ */ 445 + /* dpte */ 446 + /* ------ */ 447 + log2_vmpg_bytes = dml_log2(mode_lib->soc.vmm_page_size_bytes); 448 + dpte_buf_in_pte_reqs = mode_lib->ip.dpte_buffer_size_in_pte_reqs; 449 + 450 + log2_vmpg_height = 0; 451 + log2_vmpg_width = 0; 452 + log2_dpte_req_height_ptes = 0; 453 + log2_dpte_req_width_ptes = 0; 454 + log2_dpte_req_height = 0; 455 + log2_dpte_req_width = 0; 456 + log2_dpte_row_height_linear = 0; 457 + log2_dpte_row_height = 0; 458 + dpte_req_width = 0; /* 64b dpte req width in data element */ 459 + 460 + if (surf_linear) { 461 + log2_vmpg_height = 0; /* one line high */ 462 + } else { 463 + log2_vmpg_height = (log2_vmpg_bytes - 8) / 2 + log2_blk256_height; 464 + } 465 + log2_vmpg_width = log2_vmpg_bytes - log2_bytes_per_element - log2_vmpg_height; 466 + 467 + /* only 3 possible shapes for dpte request in dimensions of ptes: 8x1, 4x2, 2x4. */ 468 + if (log2_blk_bytes <= log2_vmpg_bytes) 469 + log2_dpte_req_height_ptes = 0; 470 + else if (log2_blk_height - log2_vmpg_height >= 2) 471 + log2_dpte_req_height_ptes = 2; 472 + else 473 + log2_dpte_req_height_ptes = log2_blk_height - log2_vmpg_height; 474 + log2_dpte_req_width_ptes = 3 - log2_dpte_req_height_ptes; 475 + 476 + ASSERT((log2_dpte_req_width_ptes == 3 && log2_dpte_req_height_ptes == 0) || /* 8x1 */ 477 + (log2_dpte_req_width_ptes == 2 && log2_dpte_req_height_ptes == 1) || /* 4x2 */ 478 + (log2_dpte_req_width_ptes == 1 && log2_dpte_req_height_ptes == 2)); /* 2x4 */ 479 + 480 + /* the dpte request dimensions in data elements is dpte_req_width x dpte_req_height 481 + * log2_wmpg_width is how much 1 pte represent, now trying to calculate how much 64b pte req represent 482 + */ 483 + log2_dpte_req_height = log2_vmpg_height + log2_dpte_req_height_ptes; 484 + log2_dpte_req_width = log2_vmpg_width + log2_dpte_req_width_ptes; 485 + dpte_req_width = 1 << log2_dpte_req_width; 486 + 487 + /* calculate pitch dpte row buffer can hold 488 + * round the result down to a power of two. 489 + */ 490 + if (surf_linear) { 491 + log2_dpte_row_height_linear = dml_floor( 492 + dml_log2(dpte_buf_in_pte_reqs * dpte_req_width / data_pitch)); 493 + 494 + ASSERT(log2_dpte_row_height_linear >= 3); 495 + 496 + if (log2_dpte_row_height_linear > 7) 497 + log2_dpte_row_height_linear = 7; 498 + 499 + log2_dpte_row_height = log2_dpte_row_height_linear; 500 + } else { 501 + /* the upper bound of the dpte_row_width without dependency on viewport position follows. */ 502 + if (!surf_vert) { 503 + log2_dpte_row_height = log2_dpte_req_height; 504 + } else { 505 + log2_dpte_row_height = 506 + (log2_blk_width < log2_dpte_req_width) ? 507 + log2_blk_width : log2_dpte_req_width; 508 + } 509 + } 510 + 511 + /* From programming guide: 512 + * There is a special case of saving only half of ptes returned due to buffer space limits. 513 + * this case applies to 4 and 8bpe in horizontal access of a vp_width greater than 2560+16 514 + * when the pte request is 2x4 ptes (which happens when vmpg_bytes =4kb and tile blk_bytes >=64kb). 515 + */ 516 + if (!surf_vert && vp_width > (2560 + 16) && bytes_per_element >= 4 && log2_vmpg_bytes == 12 517 + && log2_blk_bytes >= 16) { 518 + log2_dpte_row_height = log2_dpte_row_height - 1; /*half of the full height */ 519 + } 520 + 521 + *o_dpte_row_height = 1 << log2_dpte_row_height; 522 + } 523 + 524 + static void get_surf_rq_param( 525 + struct display_mode_lib *mode_lib, 526 + struct _vcs_dpi_display_data_rq_sizing_params_st *rq_sizing_param, 527 + struct _vcs_dpi_display_data_rq_dlg_params_st *rq_dlg_param, 528 + struct _vcs_dpi_display_data_rq_misc_params_st *rq_misc_param, 529 + const struct _vcs_dpi_display_pipe_source_params_st pipe_src_param, 530 + bool is_chroma) 531 + { 532 + bool mode_422 = 0; 533 + unsigned int vp_width = 0; 534 + unsigned int vp_height = 0; 535 + unsigned int data_pitch = 0; 536 + unsigned int meta_pitch = 0; 537 + unsigned int ppe = mode_422 ? 2 : 1; 538 + bool surf_linear; 539 + bool surf_vert; 540 + unsigned int bytes_per_element; 541 + unsigned int log2_bytes_per_element; 542 + unsigned int blk256_width; 543 + unsigned int blk256_height; 544 + unsigned int log2_blk256_width; 545 + unsigned int log2_blk256_height; 546 + unsigned int blk_bytes; 547 + unsigned int log2_blk_bytes; 548 + unsigned int log2_blk_height; 549 + unsigned int log2_blk_width; 550 + unsigned int log2_meta_req_bytes; 551 + unsigned int log2_meta_req_height; 552 + unsigned int log2_meta_req_width; 553 + unsigned int meta_req_width; 554 + unsigned int meta_req_height; 555 + unsigned int log2_meta_row_height; 556 + unsigned int meta_row_width_ub; 557 + unsigned int log2_meta_chunk_bytes; 558 + unsigned int log2_meta_chunk_height; 559 + unsigned int log2_meta_chunk_width; 560 + unsigned int log2_min_meta_chunk_bytes; 561 + unsigned int min_meta_chunk_width; 562 + unsigned int meta_chunk_width; 563 + unsigned int meta_chunk_per_row_int; 564 + unsigned int meta_row_remainder; 565 + unsigned int meta_chunk_threshold; 566 + unsigned int meta_blk_bytes; 567 + unsigned int meta_blk_height; 568 + unsigned int meta_blk_width; 569 + unsigned int meta_surface_bytes; 570 + unsigned int vmpg_bytes; 571 + unsigned int meta_pte_req_per_frame_ub; 572 + unsigned int meta_pte_bytes_per_frame_ub; 573 + unsigned int log2_vmpg_bytes; 574 + unsigned int dpte_buf_in_pte_reqs; 575 + unsigned int log2_vmpg_height; 576 + unsigned int log2_vmpg_width; 577 + unsigned int log2_dpte_req_height_ptes; 578 + unsigned int log2_dpte_req_width_ptes; 579 + unsigned int log2_dpte_req_height; 580 + unsigned int log2_dpte_req_width; 581 + unsigned int log2_dpte_row_height_linear; 582 + unsigned int log2_dpte_row_height; 583 + unsigned int log2_dpte_group_width; 584 + unsigned int dpte_row_width_ub; 585 + unsigned int dpte_row_height; 586 + unsigned int dpte_req_height; 587 + unsigned int dpte_req_width; 588 + unsigned int dpte_group_width; 589 + unsigned int log2_dpte_group_bytes; 590 + unsigned int log2_dpte_group_length; 591 + unsigned int func_meta_row_height, func_dpte_row_height; 592 + 593 + /* FIXME check if ppe apply for both luma and chroma in 422 case */ 594 + if (is_chroma) { 595 + vp_width = pipe_src_param.viewport_width_c / ppe; 596 + vp_height = pipe_src_param.viewport_height_c; 597 + data_pitch = pipe_src_param.data_pitch_c; 598 + meta_pitch = pipe_src_param.meta_pitch_c; 599 + } else { 600 + vp_width = pipe_src_param.viewport_width / ppe; 601 + vp_height = pipe_src_param.viewport_height; 602 + data_pitch = pipe_src_param.data_pitch; 603 + meta_pitch = pipe_src_param.meta_pitch; 604 + } 605 + 606 + rq_sizing_param->chunk_bytes = 8192; 607 + 608 + if (rq_sizing_param->chunk_bytes == 64 * 1024) 609 + rq_sizing_param->min_chunk_bytes = 0; 610 + else 611 + rq_sizing_param->min_chunk_bytes = 1024; 612 + 613 + rq_sizing_param->meta_chunk_bytes = 2048; 614 + rq_sizing_param->min_meta_chunk_bytes = 256; 615 + 616 + rq_sizing_param->mpte_group_bytes = 2048; 617 + 618 + surf_linear = (pipe_src_param.sw_mode == dm_sw_linear); 619 + surf_vert = (pipe_src_param.source_scan == dm_vert); 620 + 621 + bytes_per_element = get_bytes_per_element( 622 + (enum source_format_class) pipe_src_param.source_format, 623 + is_chroma); 624 + log2_bytes_per_element = dml_log2(bytes_per_element); 625 + blk256_width = 0; 626 + blk256_height = 0; 627 + 628 + if (surf_linear) { 629 + blk256_width = 256 / bytes_per_element; 630 + blk256_height = 1; 631 + } else { 632 + get_blk256_size(&blk256_width, &blk256_height, bytes_per_element); 633 + } 634 + 635 + DTRACE("DLG: %s: surf_linear = %d", __func__, surf_linear); 636 + DTRACE("DLG: %s: surf_vert = %d", __func__, surf_vert); 637 + DTRACE("DLG: %s: blk256_width = %d", __func__, blk256_width); 638 + DTRACE("DLG: %s: blk256_height = %d", __func__, blk256_height); 639 + 640 + log2_blk256_width = dml_log2((double) blk256_width); 641 + log2_blk256_height = dml_log2((double) blk256_height); 642 + blk_bytes = 643 + surf_linear ? 256 : get_blk_size_bytes( 644 + (enum source_macro_tile_size) pipe_src_param.macro_tile_size); 645 + log2_blk_bytes = dml_log2((double) blk_bytes); 646 + log2_blk_height = 0; 647 + log2_blk_width = 0; 648 + 649 + /* remember log rule 650 + * "+" in log is multiply 651 + * "-" in log is divide 652 + * "/2" is like square root 653 + * blk is vertical biased 654 + */ 655 + if (pipe_src_param.sw_mode != dm_sw_linear) 656 + log2_blk_height = log2_blk256_height 657 + + dml_ceil((double) (log2_blk_bytes - 8) / 2.0); 658 + else 659 + log2_blk_height = 0; /* blk height of 1 */ 660 + 661 + log2_blk_width = log2_blk_bytes - log2_bytes_per_element - log2_blk_height; 662 + 663 + if (!surf_vert) { 664 + rq_dlg_param->swath_width_ub = dml_round_to_multiple(vp_width - 1, blk256_width, 1) 665 + + blk256_width; 666 + rq_dlg_param->req_per_swath_ub = rq_dlg_param->swath_width_ub >> log2_blk256_width; 667 + } else { 668 + rq_dlg_param->swath_width_ub = dml_round_to_multiple( 669 + vp_height - 1, 670 + blk256_height, 671 + 1) + blk256_height; 672 + rq_dlg_param->req_per_swath_ub = rq_dlg_param->swath_width_ub >> log2_blk256_height; 673 + } 674 + 675 + if (!surf_vert) 676 + rq_misc_param->full_swath_bytes = rq_dlg_param->swath_width_ub * blk256_height 677 + * bytes_per_element; 678 + else 679 + rq_misc_param->full_swath_bytes = rq_dlg_param->swath_width_ub * blk256_width 680 + * bytes_per_element; 681 + 682 + rq_misc_param->blk256_height = blk256_height; 683 + rq_misc_param->blk256_width = blk256_width; 684 + 685 + /* ------- */ 686 + /* meta */ 687 + /* ------- */ 688 + log2_meta_req_bytes = 6; /* meta request is 64b and is 8x8byte meta element */ 689 + 690 + /* each 64b meta request for dcn is 8x8 meta elements and 691 + * a meta element covers one 256b block of the the data surface. 692 + */ 693 + log2_meta_req_height = log2_blk256_height + 3; /* meta req is 8x8 byte, each byte represent 1 blk256 */ 694 + log2_meta_req_width = log2_meta_req_bytes + 8 - log2_bytes_per_element 695 + - log2_meta_req_height; 696 + meta_req_width = 1 << log2_meta_req_width; 697 + meta_req_height = 1 << log2_meta_req_height; 698 + log2_meta_row_height = 0; 699 + meta_row_width_ub = 0; 700 + 701 + /* the dimensions of a meta row are meta_row_width x meta_row_height in elements. 702 + * calculate upper bound of the meta_row_width 703 + */ 704 + if (!surf_vert) { 705 + log2_meta_row_height = log2_meta_req_height; 706 + meta_row_width_ub = dml_round_to_multiple(vp_width - 1, meta_req_width, 1) 707 + + meta_req_width; 708 + rq_dlg_param->meta_req_per_row_ub = meta_row_width_ub / meta_req_width; 709 + } else { 710 + log2_meta_row_height = log2_meta_req_width; 711 + meta_row_width_ub = dml_round_to_multiple(vp_height - 1, meta_req_height, 1) 712 + + meta_req_height; 713 + rq_dlg_param->meta_req_per_row_ub = meta_row_width_ub / meta_req_height; 714 + } 715 + rq_dlg_param->meta_bytes_per_row_ub = rq_dlg_param->meta_req_per_row_ub * 64; 716 + 717 + log2_meta_chunk_bytes = dml_log2(rq_sizing_param->meta_chunk_bytes); 718 + log2_meta_chunk_height = log2_meta_row_height; 719 + 720 + /*full sized meta chunk width in unit of data elements */ 721 + log2_meta_chunk_width = log2_meta_chunk_bytes + 8 - log2_bytes_per_element 722 + - log2_meta_chunk_height; 723 + log2_min_meta_chunk_bytes = dml_log2(rq_sizing_param->min_meta_chunk_bytes); 724 + min_meta_chunk_width = 1 725 + << (log2_min_meta_chunk_bytes + 8 - log2_bytes_per_element 726 + - log2_meta_chunk_height); 727 + meta_chunk_width = 1 << log2_meta_chunk_width; 728 + meta_chunk_per_row_int = (unsigned int) (meta_row_width_ub / meta_chunk_width); 729 + meta_row_remainder = meta_row_width_ub % meta_chunk_width; 730 + meta_chunk_threshold = 0; 731 + meta_blk_bytes = 4096; 732 + meta_blk_height = blk256_height * 64; 733 + meta_blk_width = meta_blk_bytes * 256 / bytes_per_element / meta_blk_height; 734 + meta_surface_bytes = meta_pitch 735 + * (dml_round_to_multiple(vp_height - 1, meta_blk_height, 1) 736 + + meta_blk_height) * bytes_per_element / 256; 737 + vmpg_bytes = mode_lib->soc.vmm_page_size_bytes; 738 + meta_pte_req_per_frame_ub = (dml_round_to_multiple( 739 + meta_surface_bytes - vmpg_bytes, 740 + 8 * vmpg_bytes, 741 + 1) + 8 * vmpg_bytes) / (8 * vmpg_bytes); 742 + meta_pte_bytes_per_frame_ub = meta_pte_req_per_frame_ub * 64; /*64B mpte request */ 743 + rq_dlg_param->meta_pte_bytes_per_frame_ub = meta_pte_bytes_per_frame_ub; 744 + 745 + DTRACE("DLG: %s: meta_blk_height = %d", __func__, meta_blk_height); 746 + DTRACE("DLG: %s: meta_blk_width = %d", __func__, meta_blk_width); 747 + DTRACE("DLG: %s: meta_surface_bytes = %d", __func__, meta_surface_bytes); 748 + DTRACE("DLG: %s: meta_pte_req_per_frame_ub = %d", __func__, meta_pte_req_per_frame_ub); 749 + DTRACE("DLG: %s: meta_pte_bytes_per_frame_ub = %d", __func__, meta_pte_bytes_per_frame_ub); 750 + 751 + if (!surf_vert) 752 + meta_chunk_threshold = 2 * min_meta_chunk_width - meta_req_width; 753 + else 754 + meta_chunk_threshold = 2 * min_meta_chunk_width - meta_req_height; 755 + 756 + if (meta_row_remainder <= meta_chunk_threshold) 757 + rq_dlg_param->meta_chunks_per_row_ub = meta_chunk_per_row_int + 1; 758 + else 759 + rq_dlg_param->meta_chunks_per_row_ub = meta_chunk_per_row_int + 2; 760 + 761 + rq_dlg_param->meta_row_height = 1 << log2_meta_row_height; 762 + 763 + /* ------ */ 764 + /* dpte */ 765 + /* ------ */ 766 + log2_vmpg_bytes = dml_log2(mode_lib->soc.vmm_page_size_bytes); 767 + dpte_buf_in_pte_reqs = mode_lib->ip.dpte_buffer_size_in_pte_reqs; 768 + 769 + log2_vmpg_height = 0; 770 + log2_vmpg_width = 0; 771 + log2_dpte_req_height_ptes = 0; 772 + log2_dpte_req_width_ptes = 0; 773 + log2_dpte_req_height = 0; 774 + log2_dpte_req_width = 0; 775 + log2_dpte_row_height_linear = 0; 776 + log2_dpte_row_height = 0; 777 + log2_dpte_group_width = 0; 778 + dpte_row_width_ub = 0; 779 + dpte_row_height = 0; 780 + dpte_req_height = 0; /* 64b dpte req height in data element */ 781 + dpte_req_width = 0; /* 64b dpte req width in data element */ 782 + dpte_group_width = 0; 783 + log2_dpte_group_bytes = 0; 784 + log2_dpte_group_length = 0; 785 + 786 + if (surf_linear) { 787 + log2_vmpg_height = 0; /* one line high */ 788 + } else { 789 + log2_vmpg_height = (log2_vmpg_bytes - 8) / 2 + log2_blk256_height; 790 + } 791 + log2_vmpg_width = log2_vmpg_bytes - log2_bytes_per_element - log2_vmpg_height; 792 + 793 + /* only 3 possible shapes for dpte request in dimensions of ptes: 8x1, 4x2, 2x4. */ 794 + if (log2_blk_bytes <= log2_vmpg_bytes) 795 + log2_dpte_req_height_ptes = 0; 796 + else if (log2_blk_height - log2_vmpg_height >= 2) 797 + log2_dpte_req_height_ptes = 2; 798 + else 799 + log2_dpte_req_height_ptes = log2_blk_height - log2_vmpg_height; 800 + log2_dpte_req_width_ptes = 3 - log2_dpte_req_height_ptes; 801 + 802 + /* Ensure we only have the 3 shapes */ 803 + ASSERT((log2_dpte_req_width_ptes == 3 && log2_dpte_req_height_ptes == 0) || /* 8x1 */ 804 + (log2_dpte_req_width_ptes == 2 && log2_dpte_req_height_ptes == 1) || /* 4x2 */ 805 + (log2_dpte_req_width_ptes == 1 && log2_dpte_req_height_ptes == 2)); /* 2x4 */ 806 + 807 + /* The dpte request dimensions in data elements is dpte_req_width x dpte_req_height 808 + * log2_vmpg_width is how much 1 pte represent, now calculating how much a 64b pte req represent 809 + * That depends on the pte shape (i.e. 8x1, 4x2, 2x4) 810 + */ 811 + log2_dpte_req_height = log2_vmpg_height + log2_dpte_req_height_ptes; 812 + log2_dpte_req_width = log2_vmpg_width + log2_dpte_req_width_ptes; 813 + dpte_req_height = 1 << log2_dpte_req_height; 814 + dpte_req_width = 1 << log2_dpte_req_width; 815 + 816 + /* calculate pitch dpte row buffer can hold 817 + * round the result down to a power of two. 818 + */ 819 + if (surf_linear) { 820 + log2_dpte_row_height_linear = dml_floor( 821 + dml_log2(dpte_buf_in_pte_reqs * dpte_req_width / data_pitch)); 822 + 823 + ASSERT(log2_dpte_row_height_linear >= 3); 824 + 825 + if (log2_dpte_row_height_linear > 7) 826 + log2_dpte_row_height_linear = 7; 827 + 828 + log2_dpte_row_height = log2_dpte_row_height_linear; 829 + rq_dlg_param->dpte_row_height = 1 << log2_dpte_row_height; 830 + 831 + /* For linear, the dpte row is pitch dependent and the pte requests wrap at the pitch boundary. 832 + * the dpte_row_width_ub is the upper bound of data_pitch*dpte_row_height in elements with this unique buffering. 833 + */ 834 + dpte_row_width_ub = dml_round_to_multiple( 835 + data_pitch * dpte_row_height - 1, 836 + dpte_req_width, 837 + 1) + dpte_req_width; 838 + rq_dlg_param->dpte_req_per_row_ub = dpte_row_width_ub / dpte_req_width; 839 + } else { 840 + /* for tiled mode, row height is the same as req height and row store up to vp size upper bound */ 841 + if (!surf_vert) { 842 + log2_dpte_row_height = log2_dpte_req_height; 843 + dpte_row_width_ub = dml_round_to_multiple(vp_width - 1, dpte_req_width, 1) 844 + + dpte_req_width; 845 + rq_dlg_param->dpte_req_per_row_ub = dpte_row_width_ub / dpte_req_width; 846 + } else { 847 + log2_dpte_row_height = 848 + (log2_blk_width < log2_dpte_req_width) ? 849 + log2_blk_width : log2_dpte_req_width; 850 + dpte_row_width_ub = dml_round_to_multiple(vp_height - 1, dpte_req_height, 1) 851 + + dpte_req_height; 852 + rq_dlg_param->dpte_req_per_row_ub = dpte_row_width_ub / dpte_req_height; 853 + } 854 + rq_dlg_param->dpte_row_height = 1 << log2_dpte_row_height; 855 + } 856 + rq_dlg_param->dpte_bytes_per_row_ub = rq_dlg_param->dpte_req_per_row_ub * 64; 857 + 858 + /* From programming guide: 859 + * There is a special case of saving only half of ptes returned due to buffer space limits. 860 + * this case applies to 4 and 8bpe in horizontal access of a vp_width greater than 2560+16 861 + * when the pte request is 2x4 ptes (which happens when vmpg_bytes =4kb and tile blk_bytes >=64kb). 862 + */ 863 + if (!surf_vert && vp_width > (2560 + 16) && bytes_per_element >= 4 && log2_vmpg_bytes == 12 864 + && log2_blk_bytes >= 16) { 865 + log2_dpte_row_height = log2_dpte_row_height - 1; /*half of the full height */ 866 + rq_dlg_param->dpte_row_height = 1 << log2_dpte_row_height; 867 + } 868 + 869 + /* the dpte_group_bytes is reduced for the specific case of vertical 870 + * access of a tile surface that has dpte request of 8x1 ptes. 871 + */ 872 + if (!surf_linear & (log2_dpte_req_height_ptes == 0) & surf_vert) /*reduced, in this case, will have page fault within a group */ 873 + rq_sizing_param->dpte_group_bytes = 512; 874 + else 875 + /*full size */ 876 + rq_sizing_param->dpte_group_bytes = 2048; 877 + 878 + /*since pte request size is 64byte, the number of data pte requests per full sized group is as follows. */ 879 + log2_dpte_group_bytes = dml_log2(rq_sizing_param->dpte_group_bytes); 880 + log2_dpte_group_length = log2_dpte_group_bytes - 6; /*length in 64b requests */ 881 + 882 + /* full sized data pte group width in elements */ 883 + if (!surf_vert) 884 + log2_dpte_group_width = log2_dpte_group_length + log2_dpte_req_width; 885 + else 886 + log2_dpte_group_width = log2_dpte_group_length + log2_dpte_req_height; 887 + 888 + dpte_group_width = 1 << log2_dpte_group_width; 889 + 890 + /* since dpte groups are only aligned to dpte_req_width and not dpte_group_width, 891 + * the upper bound for the dpte groups per row is as follows. 892 + */ 893 + rq_dlg_param->dpte_groups_per_row_ub = dml_ceil( 894 + (double) dpte_row_width_ub / dpte_group_width); 895 + 896 + dml_rq_dlg_get_row_heights( 897 + mode_lib, 898 + &func_dpte_row_height, 899 + &func_meta_row_height, 900 + vp_width, 901 + data_pitch, 902 + pipe_src_param.source_format, 903 + pipe_src_param.sw_mode, 904 + pipe_src_param.macro_tile_size, 905 + pipe_src_param.source_scan, 906 + is_chroma); 907 + 908 + /* Just a check to make sure this function and the new one give the same 909 + * result. The standalone get_row_heights() function is based off of the 910 + * code in this function so the same changes need to be made to both. 911 + */ 912 + if (rq_dlg_param->meta_row_height != func_meta_row_height) { 913 + DTRACE( 914 + "MISMATCH: rq_dlg_param->meta_row_height = %d", 915 + rq_dlg_param->meta_row_height); 916 + DTRACE("MISMATCH: func_meta_row_height = %d", func_meta_row_height); 917 + ASSERT(0); 918 + } 919 + 920 + if (rq_dlg_param->dpte_row_height != func_dpte_row_height) { 921 + DTRACE( 922 + "MISMATCH: rq_dlg_param->dpte_row_height = %d", 923 + rq_dlg_param->dpte_row_height); 924 + DTRACE("MISMATCH: func_dpte_row_height = %d", func_dpte_row_height); 925 + ASSERT(0); 926 + } 927 + } 928 + 929 + void dml_rq_dlg_get_rq_params( 930 + struct display_mode_lib *mode_lib, 931 + struct _vcs_dpi_display_rq_params_st *rq_param, 932 + const struct _vcs_dpi_display_pipe_source_params_st pipe_src_param) 933 + { 934 + /* get param for luma surface */ 935 + rq_param->yuv420 = pipe_src_param.source_format == dm_420_8 936 + || pipe_src_param.source_format == dm_420_10; 937 + rq_param->yuv420_10bpc = pipe_src_param.source_format == dm_420_10; 938 + 939 + get_surf_rq_param( 940 + mode_lib, 941 + &(rq_param->sizing.rq_l), 942 + &(rq_param->dlg.rq_l), 943 + &(rq_param->misc.rq_l), 944 + pipe_src_param, 945 + 0); 946 + 947 + if (is_dual_plane((enum source_format_class) pipe_src_param.source_format)) { 948 + /* get param for chroma surface */ 949 + get_surf_rq_param( 950 + mode_lib, 951 + &(rq_param->sizing.rq_c), 952 + &(rq_param->dlg.rq_c), 953 + &(rq_param->misc.rq_c), 954 + pipe_src_param, 955 + 1); 956 + } 957 + 958 + /* calculate how to split the det buffer space between luma and chroma */ 959 + handle_det_buf_split(mode_lib, rq_param, pipe_src_param); 960 + print__rq_params_st(mode_lib, *rq_param); 961 + } 962 + 963 + void dml_rq_dlg_get_rq_reg( 964 + struct display_mode_lib *mode_lib, 965 + struct _vcs_dpi_display_rq_regs_st *rq_regs, 966 + const struct _vcs_dpi_display_pipe_source_params_st pipe_src_param) 967 + { 968 + struct _vcs_dpi_display_rq_params_st rq_param = {0}; 969 + 970 + memset(rq_regs, 0, sizeof(*rq_regs)); 971 + 972 + dml_rq_dlg_get_rq_params(mode_lib, &rq_param, pipe_src_param); 973 + extract_rq_regs(mode_lib, rq_regs, rq_param); 974 + 975 + print__rq_regs_st(mode_lib, *rq_regs); 976 + } 977 + 978 + /* TODO: Need refactor, so this is used by dml_rq_dlg_get_dlg_params as well 979 + * The problem is that there are some intermediate terms that would need by 980 + * some dlg calculation (i.e. rest of prefetch and active prog guide calculation) 981 + */ 982 + void dml_rq_dlg_get_dlg_params_prefetch( 983 + struct display_mode_lib *mode_lib, 984 + struct _vcs_dpi_display_dlg_prefetch_param_st *prefetch_param, 985 + struct _vcs_dpi_display_rq_dlg_params_st rq_dlg_param, 986 + struct _vcs_dpi_display_dlg_sys_params_st dlg_sys_param, 987 + struct _vcs_dpi_display_e2e_pipe_params_st e2e_pipe_param, 988 + const bool cstate_en, 989 + const bool pstate_en, 990 + const bool vm_en) 991 + { 992 + /* Prefetch */ 993 + unsigned int htotal = e2e_pipe_param.pipe.dest.htotal; 994 + bool interlaced = e2e_pipe_param.pipe.dest.interlaced; 995 + unsigned int min_vblank = mode_lib->ip.min_vblank_lines; 996 + const double prefetch_xy_calc_in_dcfclk = 24.0; /* FIXME: ip_param */ 997 + double min_dcfclk_mhz = dlg_sys_param.deepsleep_dcfclk_mhz; 998 + double t_calc_us = prefetch_xy_calc_in_dcfclk / min_dcfclk_mhz; 999 + 1000 + bool dcc_en = e2e_pipe_param.pipe.src.dcc; 1001 + bool dual_plane = is_dual_plane( 1002 + (enum source_format_class) e2e_pipe_param.pipe.src.source_format); 1003 + unsigned int bytes_per_element_l = get_bytes_per_element( 1004 + (enum source_format_class) e2e_pipe_param.pipe.src.source_format, 1005 + 0); 1006 + unsigned int bytes_per_element_c = get_bytes_per_element( 1007 + (enum source_format_class) e2e_pipe_param.pipe.src.source_format, 1008 + 1); 1009 + 1010 + double pclk_freq_in_mhz = e2e_pipe_param.pipe.dest.pixel_rate_mhz; 1011 + double dppclk_freq_in_mhz = e2e_pipe_param.clks_cfg.dppclk_mhz; 1012 + double dispclk_freq_in_mhz = e2e_pipe_param.clks_cfg.dispclk_mhz; 1013 + 1014 + double line_time_in_us = (htotal / pclk_freq_in_mhz); 1015 + double vinit_l = e2e_pipe_param.pipe.scale_ratio_depth.vinit; 1016 + double vinit_c = e2e_pipe_param.pipe.scale_ratio_depth.vinit_c; 1017 + double vinit_bot_l = e2e_pipe_param.pipe.scale_ratio_depth.vinit_bot; 1018 + double vinit_bot_c = e2e_pipe_param.pipe.scale_ratio_depth.vinit_bot_c; 1019 + 1020 + unsigned int swath_height_l = rq_dlg_param.rq_l.swath_height; 1021 + unsigned int swath_width_ub_l = rq_dlg_param.rq_l.swath_width_ub; 1022 + unsigned int dpte_bytes_per_row_ub_l = rq_dlg_param.rq_l.dpte_bytes_per_row_ub; 1023 + unsigned int meta_pte_bytes_per_frame_ub_l = rq_dlg_param.rq_l.meta_pte_bytes_per_frame_ub; 1024 + unsigned int meta_bytes_per_row_ub_l = rq_dlg_param.rq_l.meta_bytes_per_row_ub; 1025 + 1026 + unsigned int swath_height_c = rq_dlg_param.rq_c.swath_height; 1027 + unsigned int swath_width_ub_c = rq_dlg_param.rq_c.swath_width_ub; 1028 + unsigned int dpte_bytes_per_row_ub_c = rq_dlg_param.rq_c.dpte_bytes_per_row_ub; 1029 + unsigned int vupdate_offset = e2e_pipe_param.pipe.dest.vupdate_offset; 1030 + unsigned int vupdate_width = e2e_pipe_param.pipe.dest.vupdate_width; 1031 + unsigned int vready_offset = e2e_pipe_param.pipe.dest.vready_offset; 1032 + 1033 + const unsigned int dppclk_delay_subtotal = mode_lib->ip.dppclk_delay_subtotal; 1034 + const unsigned int dispclk_delay_subtotal = mode_lib->ip.dispclk_delay_subtotal; 1035 + unsigned int pixel_rate_delay_subtotal = dppclk_delay_subtotal * pclk_freq_in_mhz 1036 + / dppclk_freq_in_mhz 1037 + + dispclk_delay_subtotal * pclk_freq_in_mhz / dispclk_freq_in_mhz; 1038 + unsigned int dst_y_after_scaler = 0; 1039 + unsigned int dst_x_after_scaler = 0; 1040 + 1041 + unsigned int vstartup_start = e2e_pipe_param.pipe.dest.vstartup_start; 1042 + 1043 + double line_wait; 1044 + double line_o; 1045 + double line_setup; 1046 + double line_calc; 1047 + double dst_y_prefetch; 1048 + double t_pre_us; 1049 + int unsigned vm_bytes; 1050 + int unsigned meta_row_bytes; 1051 + int unsigned max_num_sw_l; 1052 + int unsigned max_num_sw_c; 1053 + int unsigned max_partial_sw_l; 1054 + int unsigned max_partial_sw_c; 1055 + 1056 + double max_vinit_l; 1057 + double max_vinit_c; 1058 + int unsigned lsw_l; 1059 + int unsigned lsw_c; 1060 + int unsigned sw_bytes_ub_l; 1061 + int unsigned sw_bytes_ub_c; 1062 + int unsigned sw_bytes; 1063 + int unsigned dpte_row_bytes; 1064 + 1065 + if (interlaced) 1066 + vstartup_start = vstartup_start / 2; 1067 + 1068 + if (vstartup_start >= min_vblank) { 1069 + min_vblank = vstartup_start + 1; 1070 + DTRACE( 1071 + "WARNING_DLG: %s: vstartup_start=%d should be less than min_vblank=%d", 1072 + __func__, 1073 + vstartup_start, 1074 + min_vblank); 1075 + } 1076 + 1077 + if (e2e_pipe_param.pipe.src.is_hsplit) 1078 + dst_x_after_scaler = pixel_rate_delay_subtotal 1079 + + e2e_pipe_param.pipe.dest.recout_width; 1080 + else 1081 + dst_x_after_scaler = pixel_rate_delay_subtotal; 1082 + 1083 + if (e2e_pipe_param.dout.output_format == dm_420) 1084 + dst_y_after_scaler = 1; 1085 + else 1086 + dst_y_after_scaler = 0; 1087 + 1088 + if (dst_x_after_scaler >= htotal) { 1089 + dst_x_after_scaler = dst_x_after_scaler - htotal; 1090 + dst_y_after_scaler = dst_y_after_scaler + 1; 1091 + } 1092 + 1093 + DTRACE("DLG: %s: htotal = %d", __func__, htotal); 1094 + DTRACE( 1095 + "DLG: %s: pixel_rate_delay_subtotal = %d", 1096 + __func__, 1097 + pixel_rate_delay_subtotal); 1098 + DTRACE("DLG: %s: dst_x_after_scaler = %d", __func__, dst_x_after_scaler); 1099 + DTRACE("DLG: %s: dst_y_after_scaler = %d", __func__, dst_y_after_scaler); 1100 + 1101 + line_wait = mode_lib->soc.urgent_latency_us; 1102 + if (cstate_en) 1103 + line_wait = dml_max(mode_lib->soc.sr_enter_plus_exit_time_us, line_wait); 1104 + if (pstate_en) 1105 + line_wait = dml_max( 1106 + mode_lib->soc.dram_clock_change_latency_us 1107 + + mode_lib->soc.urgent_latency_us, 1108 + line_wait); 1109 + line_wait = line_wait / line_time_in_us; 1110 + 1111 + line_o = (double) dst_y_after_scaler + dst_x_after_scaler / (double) htotal; 1112 + line_setup = (double) (vupdate_offset + vupdate_width + vready_offset) / (double) htotal; 1113 + line_calc = t_calc_us / line_time_in_us; 1114 + 1115 + DTRACE( 1116 + "DLG: %s: soc.sr_enter_plus_exit_time_us = %3.2f", 1117 + __func__, 1118 + (double) mode_lib->soc.sr_enter_plus_exit_time_us); 1119 + DTRACE( 1120 + "DLG: %s: soc.dram_clock_change_latency_us = %3.2f", 1121 + __func__, 1122 + (double) mode_lib->soc.dram_clock_change_latency_us); 1123 + 1124 + DTRACE("DLG: %s: urgent_latency_us = %3.2f", __func__, mode_lib->soc.urgent_latency_us); 1125 + DTRACE( 1126 + "DLG: %s: t_srx_delay_us = %3.2f", 1127 + __func__, 1128 + (double) dlg_sys_param.t_srx_delay_us); 1129 + DTRACE("DLG: %s: line_time_in_us = %3.2f", __func__, (double) line_time_in_us); 1130 + DTRACE("DLG: %s: vupdate_offset = %d", __func__, vupdate_offset); 1131 + DTRACE("DLG: %s: vupdate_width = %d", __func__, vupdate_width); 1132 + DTRACE("DLG: %s: vready_offset = %d", __func__, vready_offset); 1133 + DTRACE("DLG: %s: line_wait = %3.2f", __func__, line_wait); 1134 + DTRACE("DLG: %s: line_o = %3.2f", __func__, line_o); 1135 + DTRACE("DLG: %s: line_setup = %3.2f", __func__, line_setup); 1136 + DTRACE("DLG: %s: line_calc = %3.2f", __func__, line_calc); 1137 + 1138 + dst_y_prefetch = ((double) min_vblank - 1.0) 1139 + - (line_setup + line_calc + line_wait + line_o); 1140 + DTRACE("DLG: %s: dst_y_prefetch (before rnd) = %3.2f", __func__, dst_y_prefetch); 1141 + ASSERT(dst_y_prefetch >= 2.0); 1142 + 1143 + dst_y_prefetch = dml_floor(4.0 * (dst_y_prefetch + 0.125)) / 4; 1144 + DTRACE("DLG: %s: dst_y_prefetch (after rnd) = %3.2f", __func__, dst_y_prefetch); 1145 + 1146 + t_pre_us = dst_y_prefetch * line_time_in_us; 1147 + vm_bytes = 0; 1148 + meta_row_bytes = 0; 1149 + 1150 + if (dcc_en && vm_en) 1151 + vm_bytes = meta_pte_bytes_per_frame_ub_l; 1152 + if (dcc_en) 1153 + meta_row_bytes = meta_bytes_per_row_ub_l; 1154 + 1155 + max_num_sw_l = 0; 1156 + max_num_sw_c = 0; 1157 + max_partial_sw_l = 0; 1158 + max_partial_sw_c = 0; 1159 + 1160 + max_vinit_l = interlaced ? dml_max(vinit_l, vinit_bot_l) : vinit_l; 1161 + max_vinit_c = interlaced ? dml_max(vinit_c, vinit_bot_c) : vinit_c; 1162 + 1163 + get_swath_need(mode_lib, &max_num_sw_l, &max_partial_sw_l, swath_height_l, max_vinit_l); 1164 + if (dual_plane) 1165 + get_swath_need( 1166 + mode_lib, 1167 + &max_num_sw_c, 1168 + &max_partial_sw_c, 1169 + swath_height_c, 1170 + max_vinit_c); 1171 + 1172 + lsw_l = max_num_sw_l * swath_height_l + max_partial_sw_l; 1173 + lsw_c = max_num_sw_c * swath_height_c + max_partial_sw_c; 1174 + sw_bytes_ub_l = lsw_l * swath_width_ub_l * bytes_per_element_l; 1175 + sw_bytes_ub_c = lsw_c * swath_width_ub_c * bytes_per_element_c; 1176 + sw_bytes = 0; 1177 + dpte_row_bytes = 0; 1178 + 1179 + if (vm_en) { 1180 + if (dual_plane) 1181 + dpte_row_bytes = dpte_bytes_per_row_ub_l + dpte_bytes_per_row_ub_c; 1182 + else 1183 + dpte_row_bytes = dpte_bytes_per_row_ub_l; 1184 + } else { 1185 + dpte_row_bytes = 0; 1186 + } 1187 + 1188 + if (dual_plane) 1189 + sw_bytes = sw_bytes_ub_l + sw_bytes_ub_c; 1190 + else 1191 + sw_bytes = sw_bytes_ub_l; 1192 + 1193 + DTRACE("DLG: %s: sw_bytes_ub_l = %d", __func__, sw_bytes_ub_l); 1194 + DTRACE("DLG: %s: sw_bytes_ub_c = %d", __func__, sw_bytes_ub_c); 1195 + DTRACE("DLG: %s: sw_bytes = %d", __func__, sw_bytes); 1196 + DTRACE("DLG: %s: vm_bytes = %d", __func__, vm_bytes); 1197 + DTRACE("DLG: %s: meta_row_bytes = %d", __func__, meta_row_bytes); 1198 + DTRACE("DLG: %s: dpte_row_bytes = %d", __func__, dpte_row_bytes); 1199 + 1200 + prefetch_param->prefetch_bw = 1201 + (vm_bytes + 2 * dpte_row_bytes + 2 * meta_row_bytes + sw_bytes) / t_pre_us; 1202 + prefetch_param->flip_bytes = (vm_bytes + dpte_row_bytes + meta_row_bytes); 1203 + } 1204 + 1205 + /* Note: currently taken in as is. 1206 + * Nice to decouple code from hw register implement and extract code that are repeated for luma and chroma. 1207 + */ 1208 + void dml_rq_dlg_get_dlg_params( 1209 + struct display_mode_lib *mode_lib, 1210 + struct _vcs_dpi_display_dlg_regs_st *disp_dlg_regs, 1211 + struct _vcs_dpi_display_ttu_regs_st *disp_ttu_regs, 1212 + const struct _vcs_dpi_display_rq_dlg_params_st rq_dlg_param, 1213 + const struct _vcs_dpi_display_dlg_sys_params_st dlg_sys_param, 1214 + const struct _vcs_dpi_display_e2e_pipe_params_st e2e_pipe_param, 1215 + const bool cstate_en, 1216 + const bool pstate_en, 1217 + const bool vm_en, 1218 + const bool iflip_en) 1219 + { 1220 + /* Timing */ 1221 + unsigned int htotal = e2e_pipe_param.pipe.dest.htotal; 1222 + unsigned int hblank_end = e2e_pipe_param.pipe.dest.hblank_end; 1223 + unsigned int vblank_start = e2e_pipe_param.pipe.dest.vblank_start; 1224 + unsigned int vblank_end = e2e_pipe_param.pipe.dest.vblank_end; 1225 + bool interlaced = e2e_pipe_param.pipe.dest.interlaced; 1226 + unsigned int min_vblank = mode_lib->ip.min_vblank_lines; 1227 + 1228 + double pclk_freq_in_mhz = e2e_pipe_param.pipe.dest.pixel_rate_mhz; 1229 + double refclk_freq_in_mhz = e2e_pipe_param.clks_cfg.refclk_mhz; 1230 + double dppclk_freq_in_mhz = e2e_pipe_param.clks_cfg.dppclk_mhz; 1231 + double dispclk_freq_in_mhz = e2e_pipe_param.clks_cfg.dispclk_mhz; 1232 + 1233 + double ref_freq_to_pix_freq; 1234 + double prefetch_xy_calc_in_dcfclk; 1235 + double min_dcfclk_mhz; 1236 + double t_calc_us; 1237 + double min_ttu_vblank; 1238 + double min_dst_y_ttu_vblank; 1239 + int unsigned dlg_vblank_start; 1240 + bool dcc_en; 1241 + bool dual_plane; 1242 + bool mode_422; 1243 + unsigned int access_dir; 1244 + unsigned int bytes_per_element_l; 1245 + unsigned int bytes_per_element_c; 1246 + unsigned int vp_height_l; 1247 + unsigned int vp_width_l; 1248 + unsigned int vp_height_c; 1249 + unsigned int vp_width_c; 1250 + unsigned int htaps_l; 1251 + unsigned int htaps_c; 1252 + double hratios_l; 1253 + double hratios_c; 1254 + double vratio_l; 1255 + double vratio_c; 1256 + double line_time_in_us; 1257 + double vinit_l; 1258 + double vinit_c; 1259 + double vinit_bot_l; 1260 + double vinit_bot_c; 1261 + unsigned int swath_height_l; 1262 + unsigned int swath_width_ub_l; 1263 + unsigned int dpte_bytes_per_row_ub_l; 1264 + unsigned int dpte_groups_per_row_ub_l; 1265 + unsigned int meta_pte_bytes_per_frame_ub_l; 1266 + unsigned int meta_bytes_per_row_ub_l; 1267 + unsigned int swath_height_c; 1268 + unsigned int swath_width_ub_c; 1269 + unsigned int dpte_bytes_per_row_ub_c; 1270 + unsigned int dpte_groups_per_row_ub_c; 1271 + unsigned int meta_chunks_per_row_ub_l; 1272 + unsigned int vupdate_offset; 1273 + unsigned int vupdate_width; 1274 + unsigned int vready_offset; 1275 + unsigned int dppclk_delay_subtotal; 1276 + unsigned int dispclk_delay_subtotal; 1277 + unsigned int pixel_rate_delay_subtotal; 1278 + unsigned int vstartup_start; 1279 + unsigned int dst_x_after_scaler; 1280 + unsigned int dst_y_after_scaler; 1281 + double line_wait; 1282 + double line_o; 1283 + double line_setup; 1284 + double line_calc; 1285 + double dst_y_prefetch; 1286 + double t_pre_us; 1287 + int unsigned vm_bytes; 1288 + int unsigned meta_row_bytes; 1289 + int unsigned max_num_sw_l; 1290 + int unsigned max_num_sw_c; 1291 + int unsigned max_partial_sw_l; 1292 + int unsigned max_partial_sw_c; 1293 + double max_vinit_l; 1294 + double max_vinit_c; 1295 + int unsigned lsw_l; 1296 + int unsigned lsw_c; 1297 + int unsigned sw_bytes_ub_l; 1298 + int unsigned sw_bytes_ub_c; 1299 + int unsigned sw_bytes; 1300 + int unsigned dpte_row_bytes; 1301 + double prefetch_bw; 1302 + double flip_bw; 1303 + double t_vm_us; 1304 + double t_r0_us; 1305 + double dst_y_per_vm_vblank; 1306 + double dst_y_per_row_vblank; 1307 + double min_dst_y_per_vm_vblank; 1308 + double min_dst_y_per_row_vblank; 1309 + double lsw; 1310 + double vratio_pre_l; 1311 + double vratio_pre_c; 1312 + unsigned int req_per_swath_ub_l; 1313 + unsigned int req_per_swath_ub_c; 1314 + unsigned int meta_row_height_l; 1315 + unsigned int swath_width_pixels_ub_l; 1316 + unsigned int swath_width_pixels_ub_c; 1317 + unsigned int scaler_rec_in_width_l; 1318 + unsigned int scaler_rec_in_width_c; 1319 + unsigned int dpte_row_height_l; 1320 + unsigned int dpte_row_height_c; 1321 + double hscale_pixel_rate_l; 1322 + double hscale_pixel_rate_c; 1323 + double min_hratio_fact_l; 1324 + double min_hratio_fact_c; 1325 + double refcyc_per_line_delivery_pre_l; 1326 + double refcyc_per_line_delivery_pre_c; 1327 + double refcyc_per_line_delivery_l; 1328 + double refcyc_per_line_delivery_c; 1329 + double refcyc_per_req_delivery_pre_l; 1330 + double refcyc_per_req_delivery_pre_c; 1331 + double refcyc_per_req_delivery_l; 1332 + double refcyc_per_req_delivery_c; 1333 + double refcyc_per_req_delivery_pre_cur0; 1334 + double refcyc_per_req_delivery_cur0; 1335 + int unsigned full_recout_width; 1336 + double hratios_cur0; 1337 + unsigned int cur0_src_width; 1338 + enum cursor_bpp cur0_bpp; 1339 + unsigned int cur0_req_size; 1340 + unsigned int cur0_req_width; 1341 + double cur0_width_ub; 1342 + double cur0_req_per_width; 1343 + double hactive_cur0; 1344 + 1345 + memset(disp_dlg_regs, 0, sizeof(*disp_dlg_regs)); 1346 + memset(disp_ttu_regs, 0, sizeof(*disp_ttu_regs)); 1347 + 1348 + DTRACE("DLG: %s: cstate_en = %d", __func__, cstate_en); 1349 + DTRACE("DLG: %s: pstate_en = %d", __func__, pstate_en); 1350 + DTRACE("DLG: %s: vm_en = %d", __func__, vm_en); 1351 + DTRACE("DLG: %s: iflip_en = %d", __func__, iflip_en); 1352 + 1353 + /* ------------------------- */ 1354 + /* Section 1.5.2.1: OTG dependent Params */ 1355 + /* ------------------------- */ 1356 + DTRACE("DLG: %s: dppclk_freq_in_mhz = %3.2f", __func__, dppclk_freq_in_mhz); 1357 + DTRACE("DLG: %s: dispclk_freq_in_mhz = %3.2f", __func__, dispclk_freq_in_mhz); 1358 + DTRACE("DLG: %s: refclk_freq_in_mhz = %3.2f", __func__, refclk_freq_in_mhz); 1359 + DTRACE("DLG: %s: pclk_freq_in_mhz = %3.2f", __func__, pclk_freq_in_mhz); 1360 + DTRACE("DLG: %s: interlaced = %d", __func__, interlaced); 1361 + 1362 + ref_freq_to_pix_freq = refclk_freq_in_mhz / pclk_freq_in_mhz; 1363 + ASSERT(ref_freq_to_pix_freq < 4.0); 1364 + disp_dlg_regs->ref_freq_to_pix_freq = 1365 + (unsigned int) (ref_freq_to_pix_freq * dml_pow(2, 19)); 1366 + disp_dlg_regs->refcyc_per_htotal = (unsigned int) (ref_freq_to_pix_freq * (double) htotal 1367 + * dml_pow(2, 8)); 1368 + disp_dlg_regs->refcyc_h_blank_end = (unsigned int) ((double) hblank_end 1369 + * (double) ref_freq_to_pix_freq); 1370 + ASSERT(disp_dlg_regs->refcyc_h_blank_end < (unsigned int) dml_pow(2, 13)); 1371 + disp_dlg_regs->dlg_vblank_end = interlaced ? (vblank_end / 2) : vblank_end; /* 15 bits */ 1372 + 1373 + prefetch_xy_calc_in_dcfclk = 24.0; /* FIXME: ip_param */ 1374 + min_dcfclk_mhz = dlg_sys_param.deepsleep_dcfclk_mhz; 1375 + t_calc_us = prefetch_xy_calc_in_dcfclk / min_dcfclk_mhz; 1376 + min_ttu_vblank = dlg_sys_param.t_urg_wm_us; 1377 + if (cstate_en) 1378 + min_ttu_vblank = dml_max(dlg_sys_param.t_sr_wm_us, min_ttu_vblank); 1379 + if (pstate_en) 1380 + min_ttu_vblank = dml_max(dlg_sys_param.t_mclk_wm_us, min_ttu_vblank); 1381 + min_ttu_vblank = min_ttu_vblank + t_calc_us; 1382 + 1383 + min_dst_y_ttu_vblank = min_ttu_vblank * pclk_freq_in_mhz / (double) htotal; 1384 + dlg_vblank_start = interlaced ? (vblank_start / 2) : vblank_start; 1385 + 1386 + disp_dlg_regs->min_dst_y_next_start = (unsigned int) (((double) dlg_vblank_start 1387 + + min_dst_y_ttu_vblank) * dml_pow(2, 2)); 1388 + ASSERT(disp_dlg_regs->min_dst_y_next_start < (unsigned int) dml_pow(2, 18)); 1389 + 1390 + DTRACE("DLG: %s: min_dcfclk_mhz = %3.2f", __func__, min_dcfclk_mhz); 1391 + DTRACE("DLG: %s: min_ttu_vblank = %3.2f", __func__, min_ttu_vblank); 1392 + DTRACE( 1393 + "DLG: %s: min_dst_y_ttu_vblank = %3.2f", 1394 + __func__, 1395 + min_dst_y_ttu_vblank); 1396 + DTRACE("DLG: %s: t_calc_us = %3.2f", __func__, t_calc_us); 1397 + DTRACE( 1398 + "DLG: %s: disp_dlg_regs->min_dst_y_next_start = 0x%0x", 1399 + __func__, 1400 + disp_dlg_regs->min_dst_y_next_start); 1401 + DTRACE( 1402 + "DLG: %s: ref_freq_to_pix_freq = %3.2f", 1403 + __func__, 1404 + ref_freq_to_pix_freq); 1405 + 1406 + /* ------------------------- */ 1407 + /* Section 1.5.2.2: Prefetch, Active and TTU */ 1408 + /* ------------------------- */ 1409 + /* Prefetch Calc */ 1410 + /* Source */ 1411 + dcc_en = e2e_pipe_param.pipe.src.dcc; 1412 + dual_plane = is_dual_plane( 1413 + (enum source_format_class) e2e_pipe_param.pipe.src.source_format); 1414 + mode_422 = 0; /* FIXME */ 1415 + access_dir = (e2e_pipe_param.pipe.src.source_scan == dm_vert); /* vp access direction: horizontal or vertical accessed */ 1416 + bytes_per_element_l = get_bytes_per_element( 1417 + (enum source_format_class) e2e_pipe_param.pipe.src.source_format, 1418 + 0); 1419 + bytes_per_element_c = get_bytes_per_element( 1420 + (enum source_format_class) e2e_pipe_param.pipe.src.source_format, 1421 + 1); 1422 + vp_height_l = e2e_pipe_param.pipe.src.viewport_height; 1423 + vp_width_l = e2e_pipe_param.pipe.src.viewport_width; 1424 + vp_height_c = e2e_pipe_param.pipe.src.viewport_height_c; 1425 + vp_width_c = e2e_pipe_param.pipe.src.viewport_width_c; 1426 + 1427 + /* Scaling */ 1428 + htaps_l = e2e_pipe_param.pipe.scale_taps.htaps; 1429 + htaps_c = e2e_pipe_param.pipe.scale_taps.htaps_c; 1430 + hratios_l = e2e_pipe_param.pipe.scale_ratio_depth.hscl_ratio; 1431 + hratios_c = e2e_pipe_param.pipe.scale_ratio_depth.hscl_ratio_c; 1432 + vratio_l = e2e_pipe_param.pipe.scale_ratio_depth.vscl_ratio; 1433 + vratio_c = e2e_pipe_param.pipe.scale_ratio_depth.vscl_ratio_c; 1434 + 1435 + line_time_in_us = (htotal / pclk_freq_in_mhz); 1436 + vinit_l = e2e_pipe_param.pipe.scale_ratio_depth.vinit; 1437 + vinit_c = e2e_pipe_param.pipe.scale_ratio_depth.vinit_c; 1438 + vinit_bot_l = e2e_pipe_param.pipe.scale_ratio_depth.vinit_bot; 1439 + vinit_bot_c = e2e_pipe_param.pipe.scale_ratio_depth.vinit_bot_c; 1440 + 1441 + swath_height_l = rq_dlg_param.rq_l.swath_height; 1442 + swath_width_ub_l = rq_dlg_param.rq_l.swath_width_ub; 1443 + dpte_bytes_per_row_ub_l = rq_dlg_param.rq_l.dpte_bytes_per_row_ub; 1444 + dpte_groups_per_row_ub_l = rq_dlg_param.rq_l.dpte_groups_per_row_ub; 1445 + meta_pte_bytes_per_frame_ub_l = rq_dlg_param.rq_l.meta_pte_bytes_per_frame_ub; 1446 + meta_bytes_per_row_ub_l = rq_dlg_param.rq_l.meta_bytes_per_row_ub; 1447 + 1448 + swath_height_c = rq_dlg_param.rq_c.swath_height; 1449 + swath_width_ub_c = rq_dlg_param.rq_c.swath_width_ub; 1450 + dpte_bytes_per_row_ub_c = rq_dlg_param.rq_c.dpte_bytes_per_row_ub; 1451 + dpte_groups_per_row_ub_c = rq_dlg_param.rq_c.dpte_groups_per_row_ub; 1452 + 1453 + meta_chunks_per_row_ub_l = rq_dlg_param.rq_l.meta_chunks_per_row_ub; 1454 + vupdate_offset = e2e_pipe_param.pipe.dest.vupdate_offset; 1455 + vupdate_width = e2e_pipe_param.pipe.dest.vupdate_width; 1456 + vready_offset = e2e_pipe_param.pipe.dest.vready_offset; 1457 + 1458 + dppclk_delay_subtotal = mode_lib->ip.dppclk_delay_subtotal; 1459 + dispclk_delay_subtotal = mode_lib->ip.dispclk_delay_subtotal; 1460 + pixel_rate_delay_subtotal = dppclk_delay_subtotal * pclk_freq_in_mhz / dppclk_freq_in_mhz 1461 + + dispclk_delay_subtotal * pclk_freq_in_mhz / dispclk_freq_in_mhz; 1462 + 1463 + vstartup_start = e2e_pipe_param.pipe.dest.vstartup_start; 1464 + 1465 + if (interlaced) 1466 + vstartup_start = vstartup_start / 2; 1467 + 1468 + if (vstartup_start >= min_vblank) { 1469 + DTRACE( 1470 + "WARNING_DLG: %s: vblank_start=%d vblank_end=%d", 1471 + __func__, 1472 + vblank_start, 1473 + vblank_end); 1474 + DTRACE( 1475 + "WARNING_DLG: %s: vstartup_start=%d should be less than min_vblank=%d", 1476 + __func__, 1477 + vstartup_start, 1478 + min_vblank); 1479 + min_vblank = vstartup_start + 1; 1480 + DTRACE( 1481 + "WARNING_DLG: %s: vstartup_start=%d should be less than min_vblank=%d", 1482 + __func__, 1483 + vstartup_start, 1484 + min_vblank); 1485 + } 1486 + 1487 + dst_x_after_scaler = 0; 1488 + dst_y_after_scaler = 0; 1489 + 1490 + if (e2e_pipe_param.pipe.src.is_hsplit) 1491 + dst_x_after_scaler = pixel_rate_delay_subtotal 1492 + + e2e_pipe_param.pipe.dest.recout_width; 1493 + else 1494 + dst_x_after_scaler = pixel_rate_delay_subtotal; 1495 + 1496 + if (e2e_pipe_param.dout.output_format == dm_420) 1497 + dst_y_after_scaler = 1; 1498 + else 1499 + dst_y_after_scaler = 0; 1500 + 1501 + if (dst_x_after_scaler >= htotal) { 1502 + dst_x_after_scaler = dst_x_after_scaler - htotal; 1503 + dst_y_after_scaler = dst_y_after_scaler + 1; 1504 + } 1505 + 1506 + DTRACE("DLG: %s: htotal = %d", __func__, htotal); 1507 + DTRACE( 1508 + "DLG: %s: pixel_rate_delay_subtotal = %d", 1509 + __func__, 1510 + pixel_rate_delay_subtotal); 1511 + DTRACE("DLG: %s: dst_x_after_scaler = %d", __func__, dst_x_after_scaler); 1512 + DTRACE("DLG: %s: dst_y_after_scaler = %d", __func__, dst_y_after_scaler); 1513 + 1514 + line_wait = mode_lib->soc.urgent_latency_us; 1515 + if (cstate_en) 1516 + line_wait = dml_max(mode_lib->soc.sr_enter_plus_exit_time_us, line_wait); 1517 + if (pstate_en) 1518 + line_wait = dml_max( 1519 + mode_lib->soc.dram_clock_change_latency_us 1520 + + mode_lib->soc.urgent_latency_us, 1521 + line_wait); 1522 + line_wait = line_wait / line_time_in_us; 1523 + 1524 + line_o = (double) dst_y_after_scaler + dst_x_after_scaler / (double) htotal; 1525 + line_setup = (double) (vupdate_offset + vupdate_width + vready_offset) / (double) htotal; 1526 + line_calc = t_calc_us / line_time_in_us; 1527 + 1528 + DTRACE( 1529 + "DLG: %s: soc.sr_enter_plus_exit_time_us = %3.2f", 1530 + __func__, 1531 + (double) mode_lib->soc.sr_enter_plus_exit_time_us); 1532 + DTRACE( 1533 + "DLG: %s: soc.dram_clock_change_latency_us = %3.2f", 1534 + __func__, 1535 + (double) mode_lib->soc.dram_clock_change_latency_us); 1536 + DTRACE( 1537 + "DLG: %s: soc.urgent_latency_us = %3.2f", 1538 + __func__, 1539 + mode_lib->soc.urgent_latency_us); 1540 + 1541 + DTRACE("DLG: %s: swath_height_l = %d", __func__, swath_height_l); 1542 + if (dual_plane) 1543 + DTRACE("DLG: %s: swath_height_c = %d", __func__, swath_height_c); 1544 + 1545 + DTRACE( 1546 + "DLG: %s: t_srx_delay_us = %3.2f", 1547 + __func__, 1548 + (double) dlg_sys_param.t_srx_delay_us); 1549 + DTRACE("DLG: %s: line_time_in_us = %3.2f", __func__, (double) line_time_in_us); 1550 + DTRACE("DLG: %s: vupdate_offset = %d", __func__, vupdate_offset); 1551 + DTRACE("DLG: %s: vupdate_width = %d", __func__, vupdate_width); 1552 + DTRACE("DLG: %s: vready_offset = %d", __func__, vready_offset); 1553 + DTRACE("DLG: %s: line_time_in_us = %3.2f", __func__, line_time_in_us); 1554 + DTRACE("DLG: %s: line_wait = %3.2f", __func__, line_wait); 1555 + DTRACE("DLG: %s: line_o = %3.2f", __func__, line_o); 1556 + DTRACE("DLG: %s: line_setup = %3.2f", __func__, line_setup); 1557 + DTRACE("DLG: %s: line_calc = %3.2f", __func__, line_calc); 1558 + 1559 + dst_y_prefetch = ((double) min_vblank - 1.0) 1560 + - (line_setup + line_calc + line_wait + line_o); 1561 + DTRACE("DLG: %s: dst_y_prefetch (before rnd) = %3.2f", __func__, dst_y_prefetch); 1562 + ASSERT(dst_y_prefetch >= 2.0); 1563 + 1564 + dst_y_prefetch = dml_floor(4.0 * (dst_y_prefetch + 0.125)) / 4; 1565 + DTRACE("DLG: %s: dst_y_prefetch (after rnd) = %3.2f", __func__, dst_y_prefetch); 1566 + 1567 + t_pre_us = dst_y_prefetch * line_time_in_us; 1568 + vm_bytes = 0; 1569 + meta_row_bytes = 0; 1570 + 1571 + if (dcc_en && vm_en) 1572 + vm_bytes = meta_pte_bytes_per_frame_ub_l; 1573 + if (dcc_en) 1574 + meta_row_bytes = meta_bytes_per_row_ub_l; 1575 + 1576 + max_num_sw_l = 0; 1577 + max_num_sw_c = 0; 1578 + max_partial_sw_l = 0; 1579 + max_partial_sw_c = 0; 1580 + 1581 + max_vinit_l = interlaced ? dml_max(vinit_l, vinit_bot_l) : vinit_l; 1582 + max_vinit_c = interlaced ? dml_max(vinit_c, vinit_bot_c) : vinit_c; 1583 + 1584 + get_swath_need(mode_lib, &max_num_sw_l, &max_partial_sw_l, swath_height_l, max_vinit_l); 1585 + if (dual_plane) 1586 + get_swath_need( 1587 + mode_lib, 1588 + &max_num_sw_c, 1589 + &max_partial_sw_c, 1590 + swath_height_c, 1591 + max_vinit_c); 1592 + 1593 + lsw_l = max_num_sw_l * swath_height_l + max_partial_sw_l; 1594 + lsw_c = max_num_sw_c * swath_height_c + max_partial_sw_c; 1595 + sw_bytes_ub_l = lsw_l * swath_width_ub_l * bytes_per_element_l; 1596 + sw_bytes_ub_c = lsw_c * swath_width_ub_c * bytes_per_element_c; 1597 + sw_bytes = 0; 1598 + dpte_row_bytes = 0; 1599 + 1600 + if (vm_en) { 1601 + if (dual_plane) 1602 + dpte_row_bytes = dpte_bytes_per_row_ub_l + dpte_bytes_per_row_ub_c; 1603 + else 1604 + dpte_row_bytes = dpte_bytes_per_row_ub_l; 1605 + } else { 1606 + dpte_row_bytes = 0; 1607 + } 1608 + 1609 + if (dual_plane) 1610 + sw_bytes = sw_bytes_ub_l + sw_bytes_ub_c; 1611 + else 1612 + sw_bytes = sw_bytes_ub_l; 1613 + 1614 + DTRACE("DLG: %s: sw_bytes_ub_l = %d", __func__, sw_bytes_ub_l); 1615 + DTRACE("DLG: %s: sw_bytes_ub_c = %d", __func__, sw_bytes_ub_c); 1616 + DTRACE("DLG: %s: sw_bytes = %d", __func__, sw_bytes); 1617 + DTRACE("DLG: %s: vm_bytes = %d", __func__, vm_bytes); 1618 + DTRACE("DLG: %s: meta_row_bytes = %d", __func__, meta_row_bytes); 1619 + DTRACE("DLG: %s: dpte_row_bytes = %d", __func__, dpte_row_bytes); 1620 + 1621 + prefetch_bw = (vm_bytes + 2 * dpte_row_bytes + 2 * meta_row_bytes + sw_bytes) / t_pre_us; 1622 + flip_bw = ((vm_bytes + dpte_row_bytes + meta_row_bytes) * dlg_sys_param.total_flip_bw) 1623 + / (double) dlg_sys_param.total_flip_bytes; 1624 + t_vm_us = line_time_in_us / 4.0; 1625 + if (vm_en && dcc_en) { 1626 + t_vm_us = dml_max( 1627 + dlg_sys_param.t_extra_us, 1628 + dml_max((double) vm_bytes / prefetch_bw, t_vm_us)); 1629 + 1630 + if (iflip_en && !dual_plane) { 1631 + t_vm_us = dml_max(mode_lib->soc.urgent_latency_us, t_vm_us); 1632 + if (flip_bw > 0.) 1633 + t_vm_us = dml_max(vm_bytes / flip_bw, t_vm_us); 1634 + } 1635 + } 1636 + 1637 + t_r0_us = dml_max(dlg_sys_param.t_extra_us - t_vm_us, line_time_in_us - t_vm_us); 1638 + 1639 + if (vm_en || dcc_en) { 1640 + t_r0_us = dml_max( 1641 + (double) (dpte_row_bytes + meta_row_bytes) / prefetch_bw, 1642 + dlg_sys_param.t_extra_us); 1643 + t_r0_us = dml_max((double) (line_time_in_us - t_vm_us), t_r0_us); 1644 + 1645 + if (iflip_en && !dual_plane) { 1646 + t_r0_us = dml_max(mode_lib->soc.urgent_latency_us * 2.0, t_r0_us); 1647 + if (flip_bw > 0.) 1648 + t_r0_us = dml_max( 1649 + (dpte_row_bytes + meta_row_bytes) / flip_bw, 1650 + t_r0_us); 1651 + } 1652 + } 1653 + 1654 + disp_dlg_regs->dst_y_after_scaler = dst_y_after_scaler; /* in terms of line */ 1655 + disp_dlg_regs->refcyc_x_after_scaler = dst_x_after_scaler * ref_freq_to_pix_freq; /* in terms of refclk */ 1656 + ASSERT(disp_dlg_regs->refcyc_x_after_scaler < (unsigned int) dml_pow(2, 13)); 1657 + DTRACE( 1658 + "DLG: %s: disp_dlg_regs->dst_y_after_scaler = 0x%0x", 1659 + __func__, 1660 + disp_dlg_regs->dst_y_after_scaler); 1661 + DTRACE( 1662 + "DLG: %s: disp_dlg_regs->refcyc_x_after_scaler = 0x%0x", 1663 + __func__, 1664 + disp_dlg_regs->refcyc_x_after_scaler); 1665 + 1666 + disp_dlg_regs->dst_y_prefetch = (unsigned int) (dst_y_prefetch * dml_pow(2, 2)); 1667 + DTRACE( 1668 + "DLG: %s: disp_dlg_regs->dst_y_prefetch = %d", 1669 + __func__, 1670 + disp_dlg_regs->dst_y_prefetch); 1671 + 1672 + dst_y_per_vm_vblank = 0.0; 1673 + dst_y_per_row_vblank = 0.0; 1674 + 1675 + dst_y_per_vm_vblank = t_vm_us / line_time_in_us; 1676 + dst_y_per_vm_vblank = dml_floor(4.0 * (dst_y_per_vm_vblank + 0.125)) / 4.0; 1677 + disp_dlg_regs->dst_y_per_vm_vblank = (unsigned int) (dst_y_per_vm_vblank * dml_pow(2, 2)); 1678 + 1679 + dst_y_per_row_vblank = t_r0_us / line_time_in_us; 1680 + dst_y_per_row_vblank = dml_floor(4.0 * (dst_y_per_row_vblank + 0.125)) / 4.0; 1681 + disp_dlg_regs->dst_y_per_row_vblank = (unsigned int) (dst_y_per_row_vblank * dml_pow(2, 2)); 1682 + 1683 + DTRACE("DLG: %s: lsw_l = %d", __func__, lsw_l); 1684 + DTRACE("DLG: %s: lsw_c = %d", __func__, lsw_c); 1685 + DTRACE("DLG: %s: dpte_bytes_per_row_ub_l = %d", __func__, dpte_bytes_per_row_ub_l); 1686 + DTRACE("DLG: %s: dpte_bytes_per_row_ub_c = %d", __func__, dpte_bytes_per_row_ub_c); 1687 + 1688 + DTRACE("DLG: %s: prefetch_bw = %3.2f", __func__, prefetch_bw); 1689 + DTRACE("DLG: %s: flip_bw = %3.2f", __func__, flip_bw); 1690 + DTRACE("DLG: %s: t_pre_us = %3.2f", __func__, t_pre_us); 1691 + DTRACE("DLG: %s: t_vm_us = %3.2f", __func__, t_vm_us); 1692 + DTRACE("DLG: %s: t_r0_us = %3.2f", __func__, t_r0_us); 1693 + DTRACE("DLG: %s: dst_y_per_vm_vblank = %3.2f", __func__, dst_y_per_vm_vblank); 1694 + DTRACE("DLG: %s: dst_y_per_row_vblank = %3.2f", __func__, dst_y_per_row_vblank); 1695 + DTRACE("DLG: %s: dst_y_prefetch = %3.2f", __func__, dst_y_prefetch); 1696 + 1697 + min_dst_y_per_vm_vblank = 8.0; 1698 + min_dst_y_per_row_vblank = 16.0; 1699 + if (htotal <= 75) { 1700 + min_vblank = 300; 1701 + min_dst_y_per_vm_vblank = 100.0; 1702 + min_dst_y_per_row_vblank = 100.0; 1703 + } 1704 + 1705 + ASSERT(dst_y_per_vm_vblank < min_dst_y_per_vm_vblank); 1706 + ASSERT(dst_y_per_row_vblank < min_dst_y_per_row_vblank); 1707 + 1708 + ASSERT(dst_y_prefetch > (dst_y_per_vm_vblank + dst_y_per_row_vblank)); 1709 + lsw = dst_y_prefetch - (dst_y_per_vm_vblank + dst_y_per_row_vblank); 1710 + 1711 + DTRACE("DLG: %s: lsw = %3.2f", __func__, lsw); 1712 + 1713 + vratio_pre_l = get_vratio_pre( 1714 + mode_lib, 1715 + max_num_sw_l, 1716 + max_partial_sw_l, 1717 + swath_height_l, 1718 + max_vinit_l, 1719 + lsw); 1720 + vratio_pre_c = 1.0; 1721 + if (dual_plane) 1722 + vratio_pre_c = get_vratio_pre( 1723 + mode_lib, 1724 + max_num_sw_c, 1725 + max_partial_sw_c, 1726 + swath_height_c, 1727 + max_vinit_c, 1728 + lsw); 1729 + 1730 + DTRACE("DLG: %s: vratio_pre_l=%3.2f", __func__, vratio_pre_l); 1731 + DTRACE("DLG: %s: vratio_pre_c=%3.2f", __func__, vratio_pre_c); 1732 + 1733 + ASSERT(vratio_pre_l <= 4.0); 1734 + if (vratio_pre_l >= 4.0) 1735 + disp_dlg_regs->vratio_prefetch = (unsigned int) dml_pow(2, 21) - 1; 1736 + else 1737 + disp_dlg_regs->vratio_prefetch = (unsigned int) (vratio_pre_l * dml_pow(2, 19)); 1738 + 1739 + ASSERT(vratio_pre_c <= 4.0); 1740 + if (vratio_pre_c >= 4.0) 1741 + disp_dlg_regs->vratio_prefetch_c = (unsigned int) dml_pow(2, 21) - 1; 1742 + else 1743 + disp_dlg_regs->vratio_prefetch_c = (unsigned int) (vratio_pre_c * dml_pow(2, 19)); 1744 + 1745 + disp_dlg_regs->refcyc_per_pte_group_vblank_l = 1746 + (unsigned int) (dst_y_per_row_vblank * (double) htotal 1747 + * ref_freq_to_pix_freq / (double) dpte_groups_per_row_ub_l); 1748 + ASSERT(disp_dlg_regs->refcyc_per_pte_group_vblank_l < (unsigned int) dml_pow(2, 13)); 1749 + 1750 + disp_dlg_regs->refcyc_per_pte_group_vblank_c = 1751 + (unsigned int) (dst_y_per_row_vblank * (double) htotal 1752 + * ref_freq_to_pix_freq / (double) dpte_groups_per_row_ub_c); 1753 + ASSERT(disp_dlg_regs->refcyc_per_pte_group_vblank_c < (unsigned int) dml_pow(2, 13)); 1754 + 1755 + disp_dlg_regs->refcyc_per_meta_chunk_vblank_l = 1756 + (unsigned int) (dst_y_per_row_vblank * (double) htotal 1757 + * ref_freq_to_pix_freq / (double) meta_chunks_per_row_ub_l); 1758 + ASSERT(disp_dlg_regs->refcyc_per_meta_chunk_vblank_l < (unsigned int) dml_pow(2, 13)); 1759 + 1760 + disp_dlg_regs->refcyc_per_meta_chunk_vblank_c = 1761 + disp_dlg_regs->refcyc_per_meta_chunk_vblank_l;/* dcc for 4:2:0 is not supported in dcn1.0. assigned to be the same as _l for now */ 1762 + 1763 + /* Active */ 1764 + req_per_swath_ub_l = rq_dlg_param.rq_l.req_per_swath_ub; 1765 + req_per_swath_ub_c = rq_dlg_param.rq_c.req_per_swath_ub; 1766 + meta_row_height_l = rq_dlg_param.rq_l.meta_row_height; 1767 + swath_width_pixels_ub_l = 0; 1768 + swath_width_pixels_ub_c = 0; 1769 + scaler_rec_in_width_l = 0; 1770 + scaler_rec_in_width_c = 0; 1771 + dpte_row_height_l = rq_dlg_param.rq_l.dpte_row_height; 1772 + dpte_row_height_c = rq_dlg_param.rq_c.dpte_row_height; 1773 + 1774 + disp_dlg_regs->dst_y_per_pte_row_nom_l = (unsigned int) ((double) dpte_row_height_l 1775 + / (double) vratio_l * dml_pow(2, 2)); 1776 + ASSERT(disp_dlg_regs->dst_y_per_pte_row_nom_l < (unsigned int) dml_pow(2, 17)); 1777 + 1778 + disp_dlg_regs->dst_y_per_pte_row_nom_c = (unsigned int) ((double) dpte_row_height_c 1779 + / (double) vratio_c * dml_pow(2, 2)); 1780 + ASSERT(disp_dlg_regs->dst_y_per_pte_row_nom_c < (unsigned int) dml_pow(2, 17)); 1781 + 1782 + disp_dlg_regs->dst_y_per_meta_row_nom_l = (unsigned int) ((double) meta_row_height_l 1783 + / (double) vratio_l * dml_pow(2, 2)); 1784 + ASSERT(disp_dlg_regs->dst_y_per_meta_row_nom_l < (unsigned int) dml_pow(2, 17)); 1785 + 1786 + disp_dlg_regs->dst_y_per_meta_row_nom_c = disp_dlg_regs->dst_y_per_meta_row_nom_l; /* dcc for 4:2:0 is not supported in dcn1.0. assigned to be the same as _l for now */ 1787 + 1788 + disp_dlg_regs->refcyc_per_pte_group_nom_l = (unsigned int) ((double) dpte_row_height_l 1789 + / (double) vratio_l * (double) htotal * ref_freq_to_pix_freq 1790 + / (double) dpte_groups_per_row_ub_l); 1791 + if (disp_dlg_regs->refcyc_per_pte_group_nom_l >= (unsigned int) dml_pow(2, 23)) 1792 + disp_dlg_regs->refcyc_per_pte_group_nom_l = dml_pow(2, 23) - 1; 1793 + 1794 + disp_dlg_regs->refcyc_per_pte_group_nom_c = (unsigned int) ((double) dpte_row_height_c 1795 + / (double) vratio_c * (double) htotal * ref_freq_to_pix_freq 1796 + / (double) dpte_groups_per_row_ub_c); 1797 + if (disp_dlg_regs->refcyc_per_pte_group_nom_c >= (unsigned int) dml_pow(2, 23)) 1798 + disp_dlg_regs->refcyc_per_pte_group_nom_c = dml_pow(2, 23) - 1; 1799 + 1800 + disp_dlg_regs->refcyc_per_meta_chunk_nom_l = (unsigned int) ((double) meta_row_height_l 1801 + / (double) vratio_l * (double) htotal * ref_freq_to_pix_freq 1802 + / (double) meta_chunks_per_row_ub_l); 1803 + if (disp_dlg_regs->refcyc_per_meta_chunk_nom_l >= (unsigned int) dml_pow(2, 23)) 1804 + disp_dlg_regs->refcyc_per_meta_chunk_nom_l = dml_pow(2, 23) - 1; 1805 + 1806 + if (mode_422) { 1807 + swath_width_pixels_ub_l = swath_width_ub_l * 2; /* *2 for 2 pixel per element */ 1808 + swath_width_pixels_ub_c = swath_width_ub_c * 2; 1809 + } else { 1810 + swath_width_pixels_ub_l = swath_width_ub_l * 1; 1811 + swath_width_pixels_ub_c = swath_width_ub_c * 1; 1812 + } 1813 + 1814 + hscale_pixel_rate_l = 0.; 1815 + hscale_pixel_rate_c = 0.; 1816 + min_hratio_fact_l = 1.0; 1817 + min_hratio_fact_c = 1.0; 1818 + 1819 + if (htaps_l <= 1) 1820 + min_hratio_fact_l = 2.0; 1821 + else if (htaps_l <= 6) { 1822 + if ((hratios_l * 2.0) > 4.0) 1823 + min_hratio_fact_l = 4.0; 1824 + else 1825 + min_hratio_fact_l = hratios_l * 2.0; 1826 + } else { 1827 + if (hratios_l > 4.0) 1828 + min_hratio_fact_l = 4.0; 1829 + else 1830 + min_hratio_fact_l = hratios_l; 1831 + } 1832 + 1833 + hscale_pixel_rate_l = min_hratio_fact_l * dppclk_freq_in_mhz; 1834 + 1835 + if (htaps_c <= 1) 1836 + min_hratio_fact_c = 2.0; 1837 + else if (htaps_c <= 6) { 1838 + if ((hratios_c * 2.0) > 4.0) 1839 + min_hratio_fact_c = 4.0; 1840 + else 1841 + min_hratio_fact_c = hratios_c * 2.0; 1842 + } else { 1843 + if (hratios_c > 4.0) 1844 + min_hratio_fact_c = 4.0; 1845 + else 1846 + min_hratio_fact_c = hratios_c; 1847 + } 1848 + 1849 + hscale_pixel_rate_c = min_hratio_fact_c * dppclk_freq_in_mhz; 1850 + 1851 + refcyc_per_line_delivery_pre_l = 0.; 1852 + refcyc_per_line_delivery_pre_c = 0.; 1853 + refcyc_per_line_delivery_l = 0.; 1854 + refcyc_per_line_delivery_c = 0.; 1855 + 1856 + refcyc_per_req_delivery_pre_l = 0.; 1857 + refcyc_per_req_delivery_pre_c = 0.; 1858 + refcyc_per_req_delivery_l = 0.; 1859 + refcyc_per_req_delivery_c = 0.; 1860 + refcyc_per_req_delivery_pre_cur0 = 0.; 1861 + refcyc_per_req_delivery_cur0 = 0.; 1862 + 1863 + full_recout_width = 0; 1864 + if (e2e_pipe_param.pipe.src.is_hsplit) { 1865 + if (e2e_pipe_param.pipe.dest.full_recout_width == 0) { 1866 + DTRACE("DLG: %s: Warningfull_recout_width not set in hsplit mode", __func__); 1867 + full_recout_width = e2e_pipe_param.pipe.dest.recout_width * 2; /* assume half split for dcn1 */ 1868 + } else 1869 + full_recout_width = e2e_pipe_param.pipe.dest.full_recout_width; 1870 + } else 1871 + full_recout_width = e2e_pipe_param.pipe.dest.recout_width; 1872 + 1873 + refcyc_per_line_delivery_pre_l = get_refcyc_per_delivery( 1874 + mode_lib, 1875 + refclk_freq_in_mhz, 1876 + pclk_freq_in_mhz, 1877 + full_recout_width, 1878 + vratio_pre_l, 1879 + hscale_pixel_rate_l, 1880 + swath_width_pixels_ub_l, 1881 + 1); /* per line */ 1882 + 1883 + refcyc_per_line_delivery_l = get_refcyc_per_delivery( 1884 + mode_lib, 1885 + refclk_freq_in_mhz, 1886 + pclk_freq_in_mhz, 1887 + full_recout_width, 1888 + vratio_l, 1889 + hscale_pixel_rate_l, 1890 + swath_width_pixels_ub_l, 1891 + 1); /* per line */ 1892 + 1893 + DTRACE("DLG: %s: full_recout_width = %d", __func__, full_recout_width); 1894 + DTRACE("DLG: %s: hscale_pixel_rate_l = %3.2f", __func__, hscale_pixel_rate_l); 1895 + DTRACE( 1896 + "DLG: %s: refcyc_per_line_delivery_pre_l = %3.2f", 1897 + __func__, 1898 + refcyc_per_line_delivery_pre_l); 1899 + DTRACE( 1900 + "DLG: %s: refcyc_per_line_delivery_l = %3.2f", 1901 + __func__, 1902 + refcyc_per_line_delivery_l); 1903 + 1904 + disp_dlg_regs->refcyc_per_line_delivery_pre_l = (unsigned int) dml_floor( 1905 + refcyc_per_line_delivery_pre_l); 1906 + disp_dlg_regs->refcyc_per_line_delivery_l = (unsigned int) dml_floor( 1907 + refcyc_per_line_delivery_l); 1908 + ASSERT(disp_dlg_regs->refcyc_per_line_delivery_pre_l < (unsigned int) dml_pow(2, 13)); 1909 + ASSERT(disp_dlg_regs->refcyc_per_line_delivery_l < (unsigned int) dml_pow(2, 13)); 1910 + 1911 + if (dual_plane) { 1912 + refcyc_per_line_delivery_pre_c = get_refcyc_per_delivery( 1913 + mode_lib, 1914 + refclk_freq_in_mhz, 1915 + pclk_freq_in_mhz, 1916 + full_recout_width, 1917 + vratio_pre_c, 1918 + hscale_pixel_rate_c, 1919 + swath_width_pixels_ub_c, 1920 + 1); /* per line */ 1921 + 1922 + refcyc_per_line_delivery_c = get_refcyc_per_delivery( 1923 + mode_lib, 1924 + refclk_freq_in_mhz, 1925 + pclk_freq_in_mhz, 1926 + full_recout_width, 1927 + vratio_c, 1928 + hscale_pixel_rate_c, 1929 + swath_width_pixels_ub_c, 1930 + 1); /* per line */ 1931 + 1932 + DTRACE( 1933 + "DLG: %s: refcyc_per_line_delivery_pre_c = %3.2f", 1934 + __func__, 1935 + refcyc_per_line_delivery_pre_c); 1936 + DTRACE( 1937 + "DLG: %s: refcyc_per_line_delivery_c = %3.2f", 1938 + __func__, 1939 + refcyc_per_line_delivery_c); 1940 + 1941 + disp_dlg_regs->refcyc_per_line_delivery_pre_c = (unsigned int) dml_floor( 1942 + refcyc_per_line_delivery_pre_c); 1943 + disp_dlg_regs->refcyc_per_line_delivery_c = (unsigned int) dml_floor( 1944 + refcyc_per_line_delivery_c); 1945 + ASSERT(disp_dlg_regs->refcyc_per_line_delivery_pre_c < (unsigned int) dml_pow(2, 13)); ASSERT(disp_dlg_regs->refcyc_per_line_delivery_c < (unsigned int) dml_pow(2, 13)); 1946 + } 1947 + disp_dlg_regs->chunk_hdl_adjust_cur0 = 3; 1948 + 1949 + /* TTU - Luma / Chroma */ 1950 + if (access_dir) { /* vertical access */ 1951 + scaler_rec_in_width_l = vp_height_l; 1952 + scaler_rec_in_width_c = vp_height_c; 1953 + } else { 1954 + scaler_rec_in_width_l = vp_width_l; 1955 + scaler_rec_in_width_c = vp_width_c; 1956 + } 1957 + 1958 + refcyc_per_req_delivery_pre_l = get_refcyc_per_delivery( 1959 + mode_lib, 1960 + refclk_freq_in_mhz, 1961 + pclk_freq_in_mhz, 1962 + full_recout_width, 1963 + vratio_pre_l, 1964 + hscale_pixel_rate_l, 1965 + scaler_rec_in_width_l, 1966 + req_per_swath_ub_l); /* per req */ 1967 + refcyc_per_req_delivery_l = get_refcyc_per_delivery( 1968 + mode_lib, 1969 + refclk_freq_in_mhz, 1970 + pclk_freq_in_mhz, 1971 + full_recout_width, 1972 + vratio_l, 1973 + hscale_pixel_rate_l, 1974 + scaler_rec_in_width_l, 1975 + req_per_swath_ub_l); /* per req */ 1976 + 1977 + DTRACE( 1978 + "DLG: %s: refcyc_per_req_delivery_pre_l = %3.2f", 1979 + __func__, 1980 + refcyc_per_req_delivery_pre_l); 1981 + DTRACE( 1982 + "DLG: %s: refcyc_per_req_delivery_l = %3.2f", 1983 + __func__, 1984 + refcyc_per_req_delivery_l); 1985 + 1986 + disp_ttu_regs->refcyc_per_req_delivery_pre_l = (unsigned int) (refcyc_per_req_delivery_pre_l 1987 + * dml_pow(2, 10)); 1988 + disp_ttu_regs->refcyc_per_req_delivery_l = (unsigned int) (refcyc_per_req_delivery_l 1989 + * dml_pow(2, 10)); 1990 + 1991 + ASSERT(refcyc_per_req_delivery_pre_l < dml_pow(2, 13)); 1992 + ASSERT(refcyc_per_req_delivery_l < dml_pow(2, 13)); 1993 + 1994 + if (dual_plane) { 1995 + refcyc_per_req_delivery_pre_c = get_refcyc_per_delivery( 1996 + mode_lib, 1997 + refclk_freq_in_mhz, 1998 + pclk_freq_in_mhz, 1999 + full_recout_width, 2000 + vratio_pre_c, 2001 + hscale_pixel_rate_c, 2002 + scaler_rec_in_width_c, 2003 + req_per_swath_ub_c); /* per req */ 2004 + refcyc_per_req_delivery_c = get_refcyc_per_delivery( 2005 + mode_lib, 2006 + refclk_freq_in_mhz, 2007 + pclk_freq_in_mhz, 2008 + full_recout_width, 2009 + vratio_c, 2010 + hscale_pixel_rate_c, 2011 + scaler_rec_in_width_c, 2012 + req_per_swath_ub_c); /* per req */ 2013 + 2014 + DTRACE( 2015 + "DLG: %s: refcyc_per_req_delivery_pre_c = %3.2f", 2016 + __func__, 2017 + refcyc_per_req_delivery_pre_c); 2018 + DTRACE( 2019 + "DLG: %s: refcyc_per_req_delivery_c = %3.2f", 2020 + __func__, 2021 + refcyc_per_req_delivery_c); 2022 + 2023 + disp_ttu_regs->refcyc_per_req_delivery_pre_c = 2024 + (unsigned int) (refcyc_per_req_delivery_pre_c * dml_pow(2, 10)); 2025 + disp_ttu_regs->refcyc_per_req_delivery_c = (unsigned int) (refcyc_per_req_delivery_c 2026 + * dml_pow(2, 10)); 2027 + 2028 + ASSERT(refcyc_per_req_delivery_pre_c < dml_pow(2, 13)); 2029 + ASSERT(refcyc_per_req_delivery_c < dml_pow(2, 13)); 2030 + } 2031 + 2032 + /* TTU - Cursor */ 2033 + hratios_cur0 = e2e_pipe_param.pipe.scale_ratio_depth.hscl_ratio; 2034 + cur0_src_width = e2e_pipe_param.pipe.src.cur0_src_width; /* cursor source width */ 2035 + cur0_bpp = (enum cursor_bpp) e2e_pipe_param.pipe.src.cur0_bpp; 2036 + cur0_req_size = 0; 2037 + cur0_req_width = 0; 2038 + cur0_width_ub = 0.0; 2039 + cur0_req_per_width = 0.0; 2040 + hactive_cur0 = 0.0; 2041 + 2042 + ASSERT(cur0_src_width <= 256); 2043 + 2044 + if (cur0_src_width > 0) { 2045 + unsigned int cur0_bit_per_pixel = 0; 2046 + 2047 + if (cur0_bpp == dm_cur_2bit) { 2048 + cur0_req_size = 64; /* byte */ 2049 + cur0_bit_per_pixel = 2; 2050 + } else { /* 32bit */ 2051 + cur0_bit_per_pixel = 32; 2052 + if (cur0_src_width >= 1 && cur0_src_width <= 16) 2053 + cur0_req_size = 64; 2054 + else if (cur0_src_width >= 17 && cur0_src_width <= 31) 2055 + cur0_req_size = 128; 2056 + else 2057 + cur0_req_size = 256; 2058 + } 2059 + 2060 + cur0_req_width = (double) cur0_req_size / ((double) cur0_bit_per_pixel / 8.0); 2061 + cur0_width_ub = dml_ceil((double) cur0_src_width / (double) cur0_req_width) 2062 + * (double) cur0_req_width; 2063 + cur0_req_per_width = cur0_width_ub / (double) cur0_req_width; 2064 + hactive_cur0 = (double) cur0_src_width / hratios_cur0; /* FIXME: oswin to think about what to do for cursor */ 2065 + 2066 + if (vratio_pre_l <= 1.0) { 2067 + refcyc_per_req_delivery_pre_cur0 = hactive_cur0 * ref_freq_to_pix_freq 2068 + / (double) cur0_req_per_width; 2069 + } else { 2070 + refcyc_per_req_delivery_pre_cur0 = (double) refclk_freq_in_mhz 2071 + * (double) cur0_src_width / hscale_pixel_rate_l 2072 + / (double) cur0_req_per_width; 2073 + } 2074 + 2075 + disp_ttu_regs->refcyc_per_req_delivery_pre_cur0 = 2076 + (unsigned int) (refcyc_per_req_delivery_pre_cur0 * dml_pow(2, 10)); 2077 + ASSERT(refcyc_per_req_delivery_pre_cur0 < dml_pow(2, 13)); 2078 + 2079 + if (vratio_l <= 1.0) { 2080 + refcyc_per_req_delivery_cur0 = hactive_cur0 * ref_freq_to_pix_freq 2081 + / (double) cur0_req_per_width; 2082 + } else { 2083 + refcyc_per_req_delivery_cur0 = (double) refclk_freq_in_mhz 2084 + * (double) cur0_src_width / hscale_pixel_rate_l 2085 + / (double) cur0_req_per_width; 2086 + } 2087 + 2088 + DTRACE("DLG: %s: cur0_req_width = %d", __func__, cur0_req_width); 2089 + DTRACE( 2090 + "DLG: %s: cur0_width_ub = %3.2f", 2091 + __func__, 2092 + cur0_width_ub); 2093 + DTRACE( 2094 + "DLG: %s: cur0_req_per_width = %3.2f", 2095 + __func__, 2096 + cur0_req_per_width); 2097 + DTRACE( 2098 + "DLG: %s: hactive_cur0 = %3.2f", 2099 + __func__, 2100 + hactive_cur0); 2101 + DTRACE( 2102 + "DLG: %s: refcyc_per_req_delivery_pre_cur0 = %3.2f", 2103 + __func__, 2104 + refcyc_per_req_delivery_pre_cur0); 2105 + DTRACE( 2106 + "DLG: %s: refcyc_per_req_delivery_cur0 = %3.2f", 2107 + __func__, 2108 + refcyc_per_req_delivery_cur0); 2109 + 2110 + disp_ttu_regs->refcyc_per_req_delivery_cur0 = 2111 + (unsigned int) (refcyc_per_req_delivery_cur0 * dml_pow(2, 10)); 2112 + ASSERT(refcyc_per_req_delivery_cur0 < dml_pow(2, 13)); 2113 + } else { 2114 + disp_ttu_regs->refcyc_per_req_delivery_pre_cur0 = 0; 2115 + disp_ttu_regs->refcyc_per_req_delivery_cur0 = 0; 2116 + } 2117 + 2118 + /* TTU - Misc */ 2119 + disp_ttu_regs->qos_level_low_wm = 0; 2120 + ASSERT(disp_ttu_regs->qos_level_low_wm < dml_pow(2, 14)); 2121 + disp_ttu_regs->qos_level_high_wm = (unsigned int) (4.0 * (double) htotal 2122 + * ref_freq_to_pix_freq); 2123 + ASSERT(disp_ttu_regs->qos_level_high_wm < dml_pow(2, 14)); 2124 + 2125 + disp_ttu_regs->qos_level_flip = 14; 2126 + disp_ttu_regs->qos_level_fixed_l = 8; 2127 + disp_ttu_regs->qos_level_fixed_c = 8; 2128 + disp_ttu_regs->qos_level_fixed_cur0 = 8; 2129 + disp_ttu_regs->qos_ramp_disable_l = 0; 2130 + disp_ttu_regs->qos_ramp_disable_c = 0; 2131 + disp_ttu_regs->qos_ramp_disable_cur0 = 0; 2132 + 2133 + disp_ttu_regs->min_ttu_vblank = min_ttu_vblank * refclk_freq_in_mhz; 2134 + ASSERT(disp_ttu_regs->min_ttu_vblank < dml_pow(2, 24)); 2135 + 2136 + print__ttu_regs_st(mode_lib, *disp_ttu_regs); 2137 + print__dlg_regs_st(mode_lib, *disp_dlg_regs); 2138 + } 2139 + 2140 + void dml_rq_dlg_get_dlg_reg( 2141 + struct display_mode_lib *mode_lib, 2142 + struct _vcs_dpi_display_dlg_regs_st *dlg_regs, 2143 + struct _vcs_dpi_display_ttu_regs_st *ttu_regs, 2144 + struct _vcs_dpi_display_e2e_pipe_params_st *e2e_pipe_param, 2145 + const int unsigned num_pipes, 2146 + const int unsigned pipe_idx, 2147 + const bool cstate_en, 2148 + const bool pstate_en, 2149 + const bool vm_en, 2150 + const bool iflip_en) 2151 + { 2152 + struct _vcs_dpi_display_rq_params_st rq_param = {0}; 2153 + struct _vcs_dpi_display_dlg_sys_params_st dlg_sys_param = {0}; 2154 + struct _vcs_dpi_wm_calc_pipe_params_st *wm_param = mode_lib->wm_param; 2155 + struct _vcs_dpi_cstate_pstate_watermarks_st cstate_pstate_wm; 2156 + struct _vcs_dpi_display_dlg_prefetch_param_st prefetch_param; 2157 + double total_ret_bw; 2158 + double total_active_bw; 2159 + double total_prefetch_bw; 2160 + int unsigned total_flip_bytes; 2161 + int unsigned num_planes; 2162 + int i; 2163 + 2164 + memset(wm_param, 0, sizeof(mode_lib->wm_param)); 2165 + 2166 + /* Get watermark and Tex. */ 2167 + DTRACE("DLG: Start calculating system setting related parameters. num_pipes=%d", num_pipes); 2168 + num_planes = dml_wm_e2e_to_wm(mode_lib, e2e_pipe_param, num_pipes, wm_param); 2169 + 2170 + cstate_pstate_wm = dml_wm_cstate_pstate_e2e(mode_lib, e2e_pipe_param, num_pipes); 2171 + dlg_sys_param.t_mclk_wm_us = cstate_pstate_wm.pstate_change_us; 2172 + dlg_sys_param.t_sr_wm_us = cstate_pstate_wm.cstate_enter_plus_exit_us; 2173 + dlg_sys_param.t_urg_wm_us = dml_wm_urgent_e2e(mode_lib, e2e_pipe_param, num_pipes); 2174 + dlg_sys_param.t_srx_delay_us = mode_lib->ip.dcfclk_cstate_latency 2175 + / dml_wm_dcfclk_deepsleep_mhz_e2e(mode_lib, e2e_pipe_param, num_pipes); 2176 + dlg_sys_param.t_extra_us = dml_wm_urgent_extra(mode_lib, wm_param, num_planes); 2177 + dlg_sys_param.deepsleep_dcfclk_mhz = dml_wm_dcfclk_deepsleep_mhz_e2e( 2178 + mode_lib, 2179 + e2e_pipe_param, 2180 + num_pipes); 2181 + 2182 + print__dlg_sys_params_st(mode_lib, dlg_sys_param); 2183 + 2184 + DTRACE("DLG: Start calculating total prefetch bw. num_planes=%d", num_planes); 2185 + total_ret_bw = dml_wm_calc_return_bw(mode_lib, wm_param, num_planes); 2186 + total_active_bw = dml_wm_calc_total_data_read_bw(mode_lib, wm_param, num_planes); 2187 + total_prefetch_bw = 0.0; 2188 + total_flip_bytes = 0; 2189 + 2190 + for (i = 0; i < num_pipes; i++) { 2191 + dml_rq_dlg_get_rq_params(mode_lib, &rq_param, e2e_pipe_param[i].pipe.src); 2192 + dml_rq_dlg_get_dlg_params_prefetch( 2193 + mode_lib, 2194 + &prefetch_param, 2195 + rq_param.dlg, 2196 + dlg_sys_param, 2197 + e2e_pipe_param[i], 2198 + cstate_en, 2199 + pstate_en, 2200 + vm_en); 2201 + total_prefetch_bw += prefetch_param.prefetch_bw; 2202 + total_flip_bytes += prefetch_param.flip_bytes; 2203 + DTRACE( 2204 + "DLG: pipe=%d, total_prefetch_bw=%3.2f total_flip_bytes=%d", 2205 + i, 2206 + total_prefetch_bw, 2207 + total_flip_bytes); 2208 + } 2209 + 2210 + dlg_sys_param.total_flip_bw = total_ret_bw - dml_max(total_active_bw, total_prefetch_bw); 2211 + 2212 + DTRACE("DLG: Done calculating total prefetch bw"); 2213 + DTRACE("DLG: num_pipes = %d", num_pipes); 2214 + DTRACE("DLG: total_ret_bw = %3.2f", total_ret_bw); 2215 + DTRACE("DLG: total_active_bw = %3.2f", total_active_bw); 2216 + DTRACE("DLG: total_prefetch_bw = %3.2f", total_prefetch_bw); 2217 + DTRACE("DLG: total_flip_bw = %3.2f", dlg_sys_param.total_flip_bw); 2218 + 2219 + if (dlg_sys_param.total_flip_bw < 0.0 && iflip_en) { 2220 + DTRACE("WARNING_DLG Insufficient bw for immediate flip!"); 2221 + dlg_sys_param.total_flip_bw = 0; 2222 + } 2223 + 2224 + dlg_sys_param.total_flip_bytes = total_flip_bytes; 2225 + DTRACE("DLG: total_flip_bytes = %d", dlg_sys_param.total_flip_bytes); 2226 + DTRACE("DLG: Done calculating system setting related parameters."); 2227 + 2228 + /* system parameter calculation done */ 2229 + 2230 + DTRACE("DLG: Calculation for pipe[%d] start", pipe_idx); 2231 + dml_rq_dlg_get_rq_params(mode_lib, &rq_param, e2e_pipe_param[pipe_idx].pipe.src); 2232 + dml_rq_dlg_get_dlg_params( 2233 + mode_lib, 2234 + dlg_regs, 2235 + ttu_regs, 2236 + rq_param.dlg, 2237 + dlg_sys_param, 2238 + e2e_pipe_param[pipe_idx], 2239 + cstate_en, 2240 + pstate_en, 2241 + vm_en, 2242 + iflip_en); 2243 + DTRACE("DLG: Calculation for pipe[%d] end", pipe_idx); 2244 + } 2245 + 2246 + void dml_rq_dlg_get_arb_params( 2247 + struct display_mode_lib *mode_lib, 2248 + struct _vcs_dpi_display_arb_params_st *arb_param) 2249 + { 2250 + memset(arb_param, 0, sizeof(*arb_param)); 2251 + arb_param->max_req_outstanding = 256; 2252 + arb_param->min_req_outstanding = 68; 2253 + arb_param->sat_level_us = 60; 2254 + }
+139
drivers/gpu/drm/amd/display/dc/dml/display_rq_dlg_calc.h
··· 1 + /* 2 + * Copyright 2017 Advanced Micro Devices, Inc. 3 + * 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: 10 + * 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 13 + * 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. 21 + * 22 + * Authors: AMD 23 + * 24 + */ 25 + #ifndef __DISPLAY_RQ_DLG_CALC_H__ 26 + #define __DISPLAY_RQ_DLG_CALC_H__ 27 + 28 + #include "dml_common_defs.h" 29 + #include "display_rq_dlg_helpers.h" 30 + 31 + struct display_mode_lib; 32 + 33 + void extract_rq_regs( 34 + struct display_mode_lib *mode_lib, 35 + struct _vcs_dpi_display_rq_regs_st *rq_regs, 36 + const struct _vcs_dpi_display_rq_params_st rq_param); 37 + /* Function: dml_rq_dlg_get_rq_params 38 + * Calculate requestor related parameters that register definition agnostic 39 + * (i.e. this layer does try to separate real values from register defintion) 40 + * Input: 41 + * pipe_src_param - pipe source configuration (e.g. vp, pitch, etc.) 42 + * Output: 43 + * rq_param - values that can be used to setup RQ (e.g. swath_height, plane1_addr, etc.) 44 + */ 45 + void dml_rq_dlg_get_rq_params( 46 + struct display_mode_lib *mode_lib, 47 + struct _vcs_dpi_display_rq_params_st *rq_param, 48 + const struct _vcs_dpi_display_pipe_source_params_st pipe_src_param); 49 + 50 + /* Function: dml_rq_dlg_get_rq_reg 51 + * Main entry point for test to get the register values out of this DML class. 52 + * This function calls <get_rq_param> and <extract_rq_regs> fucntions to calculate 53 + * and then populate the rq_regs struct 54 + * Input: 55 + * pipe_src_param - pipe source configuration (e.g. vp, pitch, etc.) 56 + * Output: 57 + * rq_regs - struct that holds all the RQ registers field value. 58 + * See also: <display_rq_regs_st> 59 + */ 60 + void dml_rq_dlg_get_rq_reg( 61 + struct display_mode_lib *mode_lib, 62 + struct _vcs_dpi_display_rq_regs_st *rq_regs, 63 + const struct _vcs_dpi_display_pipe_source_params_st pipe_src_param); 64 + 65 + /* Function: dml_rq_dlg_get_dlg_params 66 + * Calculate deadline related parameters 67 + */ 68 + void dml_rq_dlg_get_dlg_params( 69 + struct display_mode_lib *mode_lib, 70 + struct _vcs_dpi_display_dlg_regs_st *dlg_regs, 71 + struct _vcs_dpi_display_ttu_regs_st *ttu_regs, 72 + const struct _vcs_dpi_display_rq_dlg_params_st rq_dlg_param, 73 + const struct _vcs_dpi_display_dlg_sys_params_st dlg_sys_param, 74 + const struct _vcs_dpi_display_e2e_pipe_params_st e2e_pipe_param, 75 + const bool cstate_en, 76 + const bool pstate_en, 77 + const bool vm_en, 78 + const bool iflip_en); 79 + 80 + /* Function: dml_rq_dlg_get_dlg_param_prefetch 81 + * For flip_bw programming guide change, now dml needs to calculate the flip_bytes and prefetch_bw 82 + * for ALL pipes and use this info to calculate the prefetch programming. 83 + * Output: prefetch_param.prefetch_bw and flip_bytes 84 + */ 85 + void dml_rq_dlg_get_dlg_params_prefetch( 86 + struct display_mode_lib *mode_lib, 87 + struct _vcs_dpi_display_dlg_prefetch_param_st *prefetch_param, 88 + struct _vcs_dpi_display_rq_dlg_params_st rq_dlg_param, 89 + struct _vcs_dpi_display_dlg_sys_params_st dlg_sys_param, 90 + struct _vcs_dpi_display_e2e_pipe_params_st e2e_pipe_param, 91 + const bool cstate_en, 92 + const bool pstate_en, 93 + const bool vm_en); 94 + 95 + /* Function: dml_rq_dlg_get_dlg_reg 96 + * Calculate and return DLG and TTU register struct given the system setting 97 + * Output: 98 + * dlg_regs - output DLG register struct 99 + * ttu_regs - output DLG TTU register struct 100 + * Input: 101 + * e2e_pipe_param - "compacted" array of e2e pipe param struct 102 + * num_pipes - num of active "pipe" or "route" 103 + * pipe_idx - index that identifies the e2e_pipe_param that corresponding to this dlg 104 + * cstate - 0: when calculate min_ttu_vblank it is assumed cstate is not required. 1: Normal mode, cstate is considered. 105 + * Added for legacy or unrealistic timing tests. 106 + */ 107 + void dml_rq_dlg_get_dlg_reg( 108 + struct display_mode_lib *mode_lib, 109 + struct _vcs_dpi_display_dlg_regs_st *dlg_regs, 110 + struct _vcs_dpi_display_ttu_regs_st *ttu_regs, 111 + struct _vcs_dpi_display_e2e_pipe_params_st *e2e_pipe_param, 112 + const unsigned int num_pipes, 113 + const unsigned int pipe_idx, 114 + const bool cstate_en, 115 + const bool pstate_en, 116 + const bool vm_en, 117 + const bool iflip_en); 118 + 119 + /* Function: dml_rq_dlg_get_row_heights 120 + * Calculate dpte and meta row heights 121 + */ 122 + void dml_rq_dlg_get_row_heights( 123 + struct display_mode_lib *mode_lib, 124 + unsigned int *o_dpte_row_height, 125 + unsigned int *o_meta_row_height, 126 + unsigned int vp_width, 127 + unsigned int data_pitch, 128 + int source_format, 129 + int tiling, 130 + int macro_tile_size, 131 + int source_scan, 132 + int is_chroma); 133 + 134 + /* Function: dml_rq_dlg_get_arb_params */ 135 + void dml_rq_dlg_get_arb_params( 136 + struct display_mode_lib *mode_lib, 137 + struct _vcs_dpi_display_arb_params_st *arb_param); 138 + 139 + #endif
+320
drivers/gpu/drm/amd/display/dc/dml/display_rq_dlg_helpers.c
··· 1 + /* 2 + * Copyright 2017 Advanced Micro Devices, Inc. 3 + * 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: 10 + * 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 13 + * 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. 21 + * 22 + * Authors: AMD 23 + * 24 + */ 25 + 26 + #include "display_rq_dlg_helpers.h" 27 + 28 + void print__rq_params_st( 29 + struct display_mode_lib *mode_lib, 30 + struct _vcs_dpi_display_rq_params_st rq_param) 31 + { 32 + DTRACE("RQ_DLG_CALC: *************************** "); 33 + DTRACE("RQ_DLG_CALC: DISPLAY_RQ_PARAM_ST"); 34 + DTRACE("RQ_DLG_CALC: <LUMA>"); 35 + print__data_rq_sizing_params_st(mode_lib, rq_param.sizing.rq_l); 36 + DTRACE("RQ_DLG_CALC: <CHROMA> === "); 37 + print__data_rq_sizing_params_st(mode_lib, rq_param.sizing.rq_c); 38 + 39 + DTRACE("RQ_DLG_CALC: <LUMA>"); 40 + print__data_rq_dlg_params_st(mode_lib, rq_param.dlg.rq_l); 41 + DTRACE("RQ_DLG_CALC: <CHROMA>"); 42 + print__data_rq_dlg_params_st(mode_lib, rq_param.dlg.rq_c); 43 + 44 + DTRACE("RQ_DLG_CALC: <LUMA>"); 45 + print__data_rq_misc_params_st(mode_lib, rq_param.misc.rq_l); 46 + DTRACE("RQ_DLG_CALC: <CHROMA>"); 47 + print__data_rq_misc_params_st(mode_lib, rq_param.misc.rq_c); 48 + DTRACE("RQ_DLG_CALC: *************************** "); 49 + } 50 + 51 + void print__data_rq_sizing_params_st( 52 + struct display_mode_lib *mode_lib, 53 + struct _vcs_dpi_display_data_rq_sizing_params_st rq_sizing) 54 + { 55 + DTRACE("RQ_DLG_CALC: ===================================== "); 56 + DTRACE("RQ_DLG_CALC: DISPLAY_DATA_RQ_SIZING_PARAM_ST"); 57 + DTRACE("RQ_DLG_CALC: chunk_bytes = %0d", rq_sizing.chunk_bytes); 58 + DTRACE("RQ_DLG_CALC: min_chunk_bytes = %0d", rq_sizing.min_chunk_bytes); 59 + DTRACE("RQ_DLG_CALC: meta_chunk_bytes = %0d", rq_sizing.meta_chunk_bytes); 60 + DTRACE("RQ_DLG_CALC: min_meta_chunk_bytes = %0d", rq_sizing.min_meta_chunk_bytes); 61 + DTRACE("RQ_DLG_CALC: mpte_group_bytes = %0d", rq_sizing.mpte_group_bytes); 62 + DTRACE("RQ_DLG_CALC: dpte_group_bytes = %0d", rq_sizing.dpte_group_bytes); 63 + DTRACE("RQ_DLG_CALC: ===================================== "); 64 + } 65 + 66 + void print__data_rq_dlg_params_st( 67 + struct display_mode_lib *mode_lib, 68 + struct _vcs_dpi_display_data_rq_dlg_params_st rq_dlg_param) 69 + { 70 + DTRACE("RQ_DLG_CALC: ===================================== "); 71 + DTRACE("RQ_DLG_CALC: DISPLAY_DATA_RQ_DLG_PARAM_ST"); 72 + DTRACE("RQ_DLG_CALC: swath_width_ub = %0d", rq_dlg_param.swath_width_ub); 73 + DTRACE("RQ_DLG_CALC: swath_height = %0d", rq_dlg_param.swath_height); 74 + DTRACE("RQ_DLG_CALC: req_per_swath_ub = %0d", rq_dlg_param.req_per_swath_ub); 75 + DTRACE( 76 + "RQ_DLG_CALC: meta_pte_bytes_per_frame_ub = %0d", 77 + rq_dlg_param.meta_pte_bytes_per_frame_ub); 78 + DTRACE( 79 + "RQ_DLG_CALC: dpte_req_per_row_ub = %0d", 80 + rq_dlg_param.dpte_req_per_row_ub); 81 + DTRACE( 82 + "RQ_DLG_CALC: dpte_groups_per_row_ub = %0d", 83 + rq_dlg_param.dpte_groups_per_row_ub); 84 + DTRACE("RQ_DLG_CALC: dpte_row_height = %0d", rq_dlg_param.dpte_row_height); 85 + DTRACE( 86 + "RQ_DLG_CALC: dpte_bytes_per_row_ub = %0d", 87 + rq_dlg_param.dpte_bytes_per_row_ub); 88 + DTRACE( 89 + "RQ_DLG_CALC: meta_chunks_per_row_ub = %0d", 90 + rq_dlg_param.meta_chunks_per_row_ub); 91 + DTRACE( 92 + "RQ_DLG_CALC: meta_req_per_row_ub = %0d", 93 + rq_dlg_param.meta_req_per_row_ub); 94 + DTRACE("RQ_DLG_CALC: meta_row_height = %0d", rq_dlg_param.meta_row_height); 95 + DTRACE( 96 + "RQ_DLG_CALC: meta_bytes_per_row_ub = %0d", 97 + rq_dlg_param.meta_bytes_per_row_ub); 98 + DTRACE("RQ_DLG_CALC: ===================================== "); 99 + } 100 + 101 + void print__data_rq_misc_params_st( 102 + struct display_mode_lib *mode_lib, 103 + struct _vcs_dpi_display_data_rq_misc_params_st rq_misc_param) 104 + { 105 + DTRACE("RQ_DLG_CALC: ===================================== "); 106 + DTRACE("RQ_DLG_CALC: DISPLAY_DATA_RQ_MISC_PARAM_ST"); 107 + DTRACE("RQ_DLG_CALC: full_swath_bytes = %0d", rq_misc_param.full_swath_bytes); 108 + DTRACE("RQ_DLG_CALC: stored_swath_bytes = %0d", rq_misc_param.stored_swath_bytes); 109 + DTRACE("RQ_DLG_CALC: blk256_width = %0d", rq_misc_param.blk256_width); 110 + DTRACE("RQ_DLG_CALC: blk256_height = %0d", rq_misc_param.blk256_height); 111 + DTRACE("RQ_DLG_CALC: req_width = %0d", rq_misc_param.req_width); 112 + DTRACE("RQ_DLG_CALC: req_height = %0d", rq_misc_param.req_height); 113 + DTRACE("RQ_DLG_CALC: ===================================== "); 114 + } 115 + 116 + void print__rq_dlg_params_st( 117 + struct display_mode_lib *mode_lib, 118 + struct _vcs_dpi_display_rq_dlg_params_st rq_dlg_param) 119 + { 120 + DTRACE("RQ_DLG_CALC: ===================================== "); 121 + DTRACE("RQ_DLG_CALC: DISPLAY_RQ_DLG_PARAM_ST"); 122 + DTRACE("RQ_DLG_CALC: <LUMA> "); 123 + print__data_rq_dlg_params_st(mode_lib, rq_dlg_param.rq_l); 124 + DTRACE("RQ_DLG_CALC: <CHROMA> "); 125 + print__data_rq_dlg_params_st(mode_lib, rq_dlg_param.rq_c); 126 + DTRACE("RQ_DLG_CALC: ===================================== "); 127 + } 128 + 129 + void print__dlg_sys_params_st( 130 + struct display_mode_lib *mode_lib, 131 + struct _vcs_dpi_display_dlg_sys_params_st dlg_sys_param) 132 + { 133 + DTRACE("RQ_DLG_CALC: ===================================== "); 134 + DTRACE("RQ_DLG_CALC: DISPLAY_RQ_DLG_PARAM_ST"); 135 + DTRACE("RQ_DLG_CALC: t_mclk_wm_us = %3.2f", dlg_sys_param.t_mclk_wm_us); 136 + DTRACE("RQ_DLG_CALC: t_urg_wm_us = %3.2f", dlg_sys_param.t_urg_wm_us); 137 + DTRACE("RQ_DLG_CALC: t_sr_wm_us = %3.2f", dlg_sys_param.t_sr_wm_us); 138 + DTRACE("RQ_DLG_CALC: t_extra_us = %3.2f", dlg_sys_param.t_extra_us); 139 + DTRACE("RQ_DLG_CALC: t_srx_delay_us = %3.2f", dlg_sys_param.t_srx_delay_us); 140 + DTRACE("RQ_DLG_CALC: deepsleep_dcfclk_mhz = %3.2f", dlg_sys_param.deepsleep_dcfclk_mhz); 141 + DTRACE("RQ_DLG_CALC: ===================================== "); 142 + } 143 + 144 + void print__data_rq_regs_st( 145 + struct display_mode_lib *mode_lib, 146 + struct _vcs_dpi_display_data_rq_regs_st rq_regs) 147 + { 148 + DTRACE("RQ_DLG_CALC: ===================================== "); 149 + DTRACE("RQ_DLG_CALC: DISPLAY_DATA_RQ_REGS_ST"); 150 + DTRACE("RQ_DLG_CALC: chunk_size = 0x%0x", rq_regs.chunk_size); 151 + DTRACE("RQ_DLG_CALC: min_chunk_size = 0x%0x", rq_regs.min_chunk_size); 152 + DTRACE("RQ_DLG_CALC: meta_chunk_size = 0x%0x", rq_regs.meta_chunk_size); 153 + DTRACE("RQ_DLG_CALC: min_meta_chunk_size = 0x%0x", rq_regs.min_meta_chunk_size); 154 + DTRACE("RQ_DLG_CALC: dpte_group_size = 0x%0x", rq_regs.dpte_group_size); 155 + DTRACE("RQ_DLG_CALC: mpte_group_size = 0x%0x", rq_regs.mpte_group_size); 156 + DTRACE("RQ_DLG_CALC: swath_height = 0x%0x", rq_regs.swath_height); 157 + DTRACE("RQ_DLG_CALC: pte_row_height_linear = 0x%0x", rq_regs.pte_row_height_linear); 158 + DTRACE("RQ_DLG_CALC: ===================================== "); 159 + } 160 + 161 + void print__rq_regs_st( 162 + struct display_mode_lib *mode_lib, 163 + struct _vcs_dpi_display_rq_regs_st rq_regs) 164 + { 165 + DTRACE("RQ_DLG_CALC: ===================================== "); 166 + DTRACE("RQ_DLG_CALC: DISPLAY_RQ_REGS_ST"); 167 + DTRACE("RQ_DLG_CALC: <LUMA> "); 168 + print__data_rq_regs_st(mode_lib, rq_regs.rq_regs_l); 169 + DTRACE("RQ_DLG_CALC: <CHROMA> "); 170 + print__data_rq_regs_st(mode_lib, rq_regs.rq_regs_c); 171 + DTRACE("RQ_DLG_CALC: drq_expansion_mode = 0x%0x", rq_regs.drq_expansion_mode); 172 + DTRACE("RQ_DLG_CALC: prq_expansion_mode = 0x%0x", rq_regs.prq_expansion_mode); 173 + DTRACE("RQ_DLG_CALC: mrq_expansion_mode = 0x%0x", rq_regs.mrq_expansion_mode); 174 + DTRACE("RQ_DLG_CALC: crq_expansion_mode = 0x%0x", rq_regs.crq_expansion_mode); 175 + DTRACE("RQ_DLG_CALC: plane1_base_address = 0x%0x", rq_regs.plane1_base_address); 176 + DTRACE("RQ_DLG_CALC: ===================================== "); 177 + } 178 + 179 + void print__dlg_regs_st( 180 + struct display_mode_lib *mode_lib, 181 + struct _vcs_dpi_display_dlg_regs_st dlg_regs) 182 + { 183 + DTRACE("RQ_DLG_CALC: ===================================== "); 184 + DTRACE("RQ_DLG_CALC: DISPLAY_DLG_REGS_ST "); 185 + DTRACE( 186 + "RQ_DLG_CALC: refcyc_h_blank_end = 0x%0x", 187 + dlg_regs.refcyc_h_blank_end); 188 + DTRACE("RQ_DLG_CALC: dlg_vblank_end = 0x%0x", dlg_regs.dlg_vblank_end); 189 + DTRACE( 190 + "RQ_DLG_CALC: min_dst_y_next_start = 0x%0x", 191 + dlg_regs.min_dst_y_next_start); 192 + DTRACE( 193 + "RQ_DLG_CALC: refcyc_per_htotal = 0x%0x", 194 + dlg_regs.refcyc_per_htotal); 195 + DTRACE( 196 + "RQ_DLG_CALC: refcyc_x_after_scaler = 0x%0x", 197 + dlg_regs.refcyc_x_after_scaler); 198 + DTRACE( 199 + "RQ_DLG_CALC: dst_y_after_scaler = 0x%0x", 200 + dlg_regs.dst_y_after_scaler); 201 + DTRACE("RQ_DLG_CALC: dst_y_prefetch = 0x%0x", dlg_regs.dst_y_prefetch); 202 + DTRACE( 203 + "RQ_DLG_CALC: dst_y_per_vm_vblank = 0x%0x", 204 + dlg_regs.dst_y_per_vm_vblank); 205 + DTRACE( 206 + "RQ_DLG_CALC: dst_y_per_row_vblank = 0x%0x", 207 + dlg_regs.dst_y_per_row_vblank); 208 + DTRACE( 209 + "RQ_DLG_CALC: ref_freq_to_pix_freq = 0x%0x", 210 + dlg_regs.ref_freq_to_pix_freq); 211 + DTRACE("RQ_DLG_CALC: vratio_prefetch = 0x%0x", dlg_regs.vratio_prefetch); 212 + DTRACE( 213 + "RQ_DLG_CALC: vratio_prefetch_c = 0x%0x", 214 + dlg_regs.vratio_prefetch_c); 215 + DTRACE( 216 + "RQ_DLG_CALC: refcyc_per_pte_group_vblank_l = 0x%0x", 217 + dlg_regs.refcyc_per_pte_group_vblank_l); 218 + DTRACE( 219 + "RQ_DLG_CALC: refcyc_per_pte_group_vblank_c = 0x%0x", 220 + dlg_regs.refcyc_per_pte_group_vblank_c); 221 + DTRACE( 222 + "RQ_DLG_CALC: refcyc_per_meta_chunk_vblank_l = 0x%0x", 223 + dlg_regs.refcyc_per_meta_chunk_vblank_l); 224 + DTRACE( 225 + "RQ_DLG_CALC: refcyc_per_meta_chunk_vblank_c = 0x%0x", 226 + dlg_regs.refcyc_per_meta_chunk_vblank_c); 227 + DTRACE( 228 + "RQ_DLG_CALC: dst_y_per_pte_row_nom_l = 0x%0x", 229 + dlg_regs.dst_y_per_pte_row_nom_l); 230 + DTRACE( 231 + "RQ_DLG_CALC: dst_y_per_pte_row_nom_c = 0x%0x", 232 + dlg_regs.dst_y_per_pte_row_nom_c); 233 + DTRACE( 234 + "RQ_DLG_CALC: refcyc_per_pte_group_nom_l = 0x%0x", 235 + dlg_regs.refcyc_per_pte_group_nom_l); 236 + DTRACE( 237 + "RQ_DLG_CALC: refcyc_per_pte_group_nom_c = 0x%0x", 238 + dlg_regs.refcyc_per_pte_group_nom_c); 239 + DTRACE( 240 + "RQ_DLG_CALC: dst_y_per_meta_row_nom_l = 0x%0x", 241 + dlg_regs.dst_y_per_meta_row_nom_l); 242 + DTRACE( 243 + "RQ_DLG_CALC: dst_y_per_meta_row_nom_c = 0x%0x", 244 + dlg_regs.dst_y_per_meta_row_nom_c); 245 + DTRACE( 246 + "RQ_DLG_CALC: refcyc_per_meta_chunk_nom_l = 0x%0x", 247 + dlg_regs.refcyc_per_meta_chunk_nom_l); 248 + DTRACE( 249 + "RQ_DLG_CALC: refcyc_per_meta_chunk_nom_c = 0x%0x", 250 + dlg_regs.refcyc_per_meta_chunk_nom_c); 251 + DTRACE( 252 + "RQ_DLG_CALC: refcyc_per_line_delivery_pre_l = 0x%0x", 253 + dlg_regs.refcyc_per_line_delivery_pre_l); 254 + DTRACE( 255 + "RQ_DLG_CALC: refcyc_per_line_delivery_pre_c = 0x%0x", 256 + dlg_regs.refcyc_per_line_delivery_pre_c); 257 + DTRACE( 258 + "RQ_DLG_CALC: refcyc_per_line_delivery_l = 0x%0x", 259 + dlg_regs.refcyc_per_line_delivery_l); 260 + DTRACE( 261 + "RQ_DLG_CALC: refcyc_per_line_delivery_c = 0x%0x", 262 + dlg_regs.refcyc_per_line_delivery_c); 263 + DTRACE( 264 + "RQ_DLG_CALC: chunk_hdl_adjust_cur0 = 0x%0x", 265 + dlg_regs.chunk_hdl_adjust_cur0); 266 + DTRACE("RQ_DLG_CALC: ===================================== "); 267 + } 268 + 269 + void print__ttu_regs_st( 270 + struct display_mode_lib *mode_lib, 271 + struct _vcs_dpi_display_ttu_regs_st ttu_regs) 272 + { 273 + DTRACE("RQ_DLG_CALC: ===================================== "); 274 + DTRACE("RQ_DLG_CALC: DISPLAY_TTU_REGS_ST "); 275 + DTRACE( 276 + "RQ_DLG_CALC: qos_level_low_wm = 0x%0x", 277 + ttu_regs.qos_level_low_wm); 278 + DTRACE( 279 + "RQ_DLG_CALC: qos_level_high_wm = 0x%0x", 280 + ttu_regs.qos_level_high_wm); 281 + DTRACE("RQ_DLG_CALC: min_ttu_vblank = 0x%0x", ttu_regs.min_ttu_vblank); 282 + DTRACE("RQ_DLG_CALC: qos_level_flip = 0x%0x", ttu_regs.qos_level_flip); 283 + DTRACE( 284 + "RQ_DLG_CALC: refcyc_per_req_delivery_pre_l = 0x%0x", 285 + ttu_regs.refcyc_per_req_delivery_pre_l); 286 + DTRACE( 287 + "RQ_DLG_CALC: refcyc_per_req_delivery_l = 0x%0x", 288 + ttu_regs.refcyc_per_req_delivery_l); 289 + DTRACE( 290 + "RQ_DLG_CALC: refcyc_per_req_delivery_pre_c = 0x%0x", 291 + ttu_regs.refcyc_per_req_delivery_pre_c); 292 + DTRACE( 293 + "RQ_DLG_CALC: refcyc_per_req_delivery_c = 0x%0x", 294 + ttu_regs.refcyc_per_req_delivery_c); 295 + DTRACE( 296 + "RQ_DLG_CALC: refcyc_per_req_delivery_cur0 = 0x%0x", 297 + ttu_regs.refcyc_per_req_delivery_cur0); 298 + DTRACE( 299 + "RQ_DLG_CALC: refcyc_per_req_delivery_pre_cur0 = 0x%0x", 300 + ttu_regs.refcyc_per_req_delivery_pre_cur0); 301 + DTRACE( 302 + "RQ_DLG_CALC: qos_level_fixed_l = 0x%0x", 303 + ttu_regs.qos_level_fixed_l); 304 + DTRACE( 305 + "RQ_DLG_CALC: qos_ramp_disable_l = 0x%0x", 306 + ttu_regs.qos_ramp_disable_l); 307 + DTRACE( 308 + "RQ_DLG_CALC: qos_level_fixed_c = 0x%0x", 309 + ttu_regs.qos_level_fixed_c); 310 + DTRACE( 311 + "RQ_DLG_CALC: qos_ramp_disable_c = 0x%0x", 312 + ttu_regs.qos_ramp_disable_c); 313 + DTRACE( 314 + "RQ_DLG_CALC: qos_level_fixed_cur0 = 0x%0x", 315 + ttu_regs.qos_level_fixed_cur0); 316 + DTRACE( 317 + "RQ_DLG_CALC: qos_ramp_disable_cur0 = 0x%0x", 318 + ttu_regs.qos_ramp_disable_cur0); 319 + DTRACE("RQ_DLG_CALC: ===================================== "); 320 + }
+66
drivers/gpu/drm/amd/display/dc/dml/display_rq_dlg_helpers.h
··· 1 + /* 2 + * Copyright 2017 Advanced Micro Devices, Inc. 3 + * 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: 10 + * 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 13 + * 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. 21 + * 22 + * Authors: AMD 23 + * 24 + */ 25 + #ifndef __DISPLAY_RQ_DLG_HELPERS_H__ 26 + #define __DISPLAY_RQ_DLG_HELPERS_H__ 27 + 28 + #include "dml_common_defs.h" 29 + #include "display_mode_lib.h" 30 + 31 + /* Function: Printer functions 32 + * Print various struct 33 + */ 34 + void print__rq_params_st( 35 + struct display_mode_lib *mode_lib, 36 + struct _vcs_dpi_display_rq_params_st rq_param); 37 + void print__data_rq_sizing_params_st( 38 + struct display_mode_lib *mode_lib, 39 + struct _vcs_dpi_display_data_rq_sizing_params_st rq_sizing); 40 + void print__data_rq_dlg_params_st( 41 + struct display_mode_lib *mode_lib, 42 + struct _vcs_dpi_display_data_rq_dlg_params_st rq_dlg_param); 43 + void print__data_rq_misc_params_st( 44 + struct display_mode_lib *mode_lib, 45 + struct _vcs_dpi_display_data_rq_misc_params_st rq_misc_param); 46 + void print__rq_dlg_params_st( 47 + struct display_mode_lib *mode_lib, 48 + struct _vcs_dpi_display_rq_dlg_params_st rq_dlg_param); 49 + void print__dlg_sys_params_st( 50 + struct display_mode_lib *mode_lib, 51 + struct _vcs_dpi_display_dlg_sys_params_st dlg_sys_param); 52 + 53 + void print__data_rq_regs_st( 54 + struct display_mode_lib *mode_lib, 55 + struct _vcs_dpi_display_data_rq_regs_st data_rq_regs); 56 + void print__rq_regs_st( 57 + struct display_mode_lib *mode_lib, 58 + struct _vcs_dpi_display_rq_regs_st rq_regs); 59 + void print__dlg_regs_st( 60 + struct display_mode_lib *mode_lib, 61 + struct _vcs_dpi_display_dlg_regs_st dlg_regs); 62 + void print__ttu_regs_st( 63 + struct display_mode_lib *mode_lib, 64 + struct _vcs_dpi_display_ttu_regs_st ttu_regs); 65 + 66 + #endif
+1281
drivers/gpu/drm/amd/display/dc/dml/display_watermark.c
··· 1 + /* 2 + * Copyright 2017 Advanced Micro Devices, Inc. 3 + * 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: 10 + * 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 13 + * 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. 21 + * 22 + * Authors: AMD 23 + * 24 + */ 25 + #include "display_watermark.h" 26 + #include "display_mode_lib.h" 27 + 28 + static void get_bytes_per_pixel( 29 + enum source_format_class format, 30 + struct _vcs_dpi_wm_calc_pipe_params_st *plane) 31 + { 32 + switch (format) { 33 + case dm_444_64: 34 + plane->bytes_per_pixel_y = 8.0; 35 + plane->bytes_per_pixel_c = 0.0; 36 + break; 37 + case dm_444_32: 38 + plane->bytes_per_pixel_y = 4.0; 39 + plane->bytes_per_pixel_c = 0.0; 40 + break; 41 + case dm_444_16: 42 + plane->bytes_per_pixel_y = 2.0; 43 + plane->bytes_per_pixel_c = 0.0; 44 + break; 45 + case dm_422_10: 46 + plane->bytes_per_pixel_y = 4.0; 47 + plane->bytes_per_pixel_c = 0.0; 48 + break; 49 + case dm_422_8: 50 + plane->bytes_per_pixel_y = 2.0; 51 + plane->bytes_per_pixel_c = 0.0; 52 + break; 53 + case dm_420_8: 54 + plane->bytes_per_pixel_y = 1.0; 55 + plane->bytes_per_pixel_c = 2.0; 56 + break; 57 + case dm_420_10: 58 + plane->bytes_per_pixel_y = 4.0 / 3; 59 + plane->bytes_per_pixel_c = 8.0 / 3; 60 + break; 61 + default: 62 + BREAK_TO_DEBUGGER(); /* invalid format in get_bytes_per_pixel */ 63 + } 64 + } 65 + 66 + static unsigned int get_swath_width_y( 67 + struct _vcs_dpi_display_pipe_source_params_st *src_param, 68 + unsigned int num_dpp) 69 + { 70 + unsigned int val; 71 + 72 + /* note that we don't divide by num_dpp here because we have an interface which has already split 73 + * any viewports 74 + */ 75 + if (src_param->source_scan == dm_horz) { 76 + val = src_param->viewport_width; 77 + } else { 78 + val = src_param->viewport_height; 79 + } 80 + 81 + return val; 82 + } 83 + 84 + static void get_swath_height( 85 + struct display_mode_lib *mode_lib, 86 + struct _vcs_dpi_display_pipe_source_params_st *src_param, 87 + struct _vcs_dpi_wm_calc_pipe_params_st *plane, 88 + unsigned int swath_width_y) 89 + { 90 + double buffer_width; 91 + 92 + if (src_param->source_format == dm_444_64 || src_param->source_format == dm_444_32 93 + || src_param->source_format == dm_444_16) { 94 + if (src_param->sw_mode == dm_sw_linear) { 95 + plane->swath_height_y = 1; 96 + } else if (src_param->source_format == dm_444_64) { 97 + plane->swath_height_y = 4; 98 + } else { 99 + plane->swath_height_y = 8; 100 + } 101 + 102 + if (src_param->source_scan != dm_horz) { 103 + plane->swath_height_y = 256 / (unsigned int) plane->bytes_per_pixel_y 104 + / plane->swath_height_y; 105 + } 106 + 107 + plane->swath_height_c = 0; 108 + 109 + } else { 110 + if (src_param->sw_mode == dm_sw_linear) { 111 + plane->swath_height_y = 1; 112 + plane->swath_height_c = 1; 113 + } else if (src_param->source_format == dm_420_8) { 114 + plane->swath_height_y = 16; 115 + plane->swath_height_c = 8; 116 + } else { 117 + plane->swath_height_y = 8; 118 + plane->swath_height_c = 8; 119 + } 120 + 121 + if (src_param->source_scan != dm_horz) { 122 + double bytes_per_pixel_c_ceil; 123 + 124 + plane->swath_height_y = 256 / dml_ceil(plane->bytes_per_pixel_y) 125 + / plane->swath_height_y; 126 + 127 + bytes_per_pixel_c_ceil = dml_ceil_2(plane->bytes_per_pixel_c); 128 + 129 + plane->swath_height_c = 256 / bytes_per_pixel_c_ceil 130 + / plane->swath_height_c; 131 + } 132 + } 133 + 134 + /* use swath height min if buffer isn't big enough */ 135 + 136 + buffer_width = ((double) mode_lib->ip.det_buffer_size_kbytes * 1024.0 / 2.0) 137 + / (plane->bytes_per_pixel_y * (double) plane->swath_height_y 138 + + (plane->bytes_per_pixel_c / 2.0 139 + * (double) plane->swath_height_c)); 140 + 141 + if ((double) swath_width_y <= buffer_width) { 142 + /* do nothing, just keep code structure from Gabes vba */ 143 + } else { 144 + /* substitute swath height with swath height min */ 145 + if (src_param->source_format == dm_444_64 || src_param->source_format == dm_444_32 146 + || src_param->source_format == dm_444_16) { 147 + if ((src_param->sw_mode == dm_sw_linear) 148 + || (src_param->source_format == dm_444_64 149 + && (src_param->sw_mode == dm_sw_4kb_s 150 + || src_param->sw_mode 151 + == dm_sw_4kb_s_x 152 + || src_param->sw_mode 153 + == dm_sw_64kb_s 154 + || src_param->sw_mode 155 + == dm_sw_64kb_s_t 156 + || src_param->sw_mode 157 + == dm_sw_64kb_s_x 158 + || src_param->sw_mode 159 + == dm_sw_var_s 160 + || src_param->sw_mode 161 + == dm_sw_var_s_x) 162 + && src_param->source_scan == dm_horz)) { 163 + /* do nothing, just keep code structure from Gabes vba */ 164 + } else { 165 + plane->swath_height_y = plane->swath_height_y / 2; 166 + } 167 + } else { 168 + if (src_param->sw_mode == dm_sw_linear) { 169 + /* do nothing, just keep code structure from Gabes vba */ 170 + } else if (src_param->source_format == dm_420_8 171 + && src_param->source_scan == dm_horz) { 172 + plane->swath_height_y = plane->swath_height_y / 2; 173 + } else if (src_param->source_format == dm_420_10 174 + && src_param->source_scan == dm_horz) { 175 + plane->swath_height_c = plane->swath_height_c / 2; 176 + } 177 + } 178 + } 179 + 180 + if (plane->swath_height_c == 0) { 181 + plane->det_buffer_size_y = mode_lib->ip.det_buffer_size_kbytes * 1024.0; 182 + } else if (plane->swath_height_c <= plane->swath_height_y) { 183 + plane->det_buffer_size_y = mode_lib->ip.det_buffer_size_kbytes * 1024.0 / 2.0; 184 + } else { 185 + plane->det_buffer_size_y = mode_lib->ip.det_buffer_size_kbytes * 1024.0 * 2.0 / 3.0; 186 + } 187 + } 188 + 189 + static void calc_display_pipe_line_delivery_time( 190 + struct display_mode_lib *mode_lib, 191 + struct _vcs_dpi_wm_calc_pipe_params_st *planes, 192 + unsigned int num_planes) 193 + { 194 + unsigned int i; 195 + 196 + for (i = 0; i < num_planes; i++) { 197 + if (planes[i].v_ratio <= 1.0) { 198 + planes[i].display_pipe_line_delivery_time = planes[i].swath_width_y 199 + * planes[i].num_dpp / planes[i].h_ratio 200 + / planes[i].pixclk_mhz; 201 + } else { 202 + double dchub_pscl_bw_per_clk; 203 + 204 + if (planes[i].h_ratio > 1) { 205 + double num_hscl_kernels; 206 + 207 + num_hscl_kernels = dml_ceil((double) planes[i].h_taps / 6); 208 + dchub_pscl_bw_per_clk = 209 + dml_min( 210 + (double) mode_lib->ip.max_dchub_pscl_bw_pix_per_clk, 211 + mode_lib->ip.max_pscl_lb_bw_pix_per_clk 212 + * planes[i].h_ratio 213 + / num_hscl_kernels); 214 + } else { 215 + dchub_pscl_bw_per_clk = 216 + dml_min( 217 + (double) mode_lib->ip.max_dchub_pscl_bw_pix_per_clk, 218 + (double) mode_lib->ip.max_pscl_lb_bw_pix_per_clk); 219 + } 220 + 221 + planes[i].display_pipe_line_delivery_time = planes[i].swath_width_y 222 + / dchub_pscl_bw_per_clk / planes[i].dppclk_mhz; 223 + } 224 + } 225 + } 226 + 227 + static double calc_total_data_read_bw( 228 + struct display_mode_lib *mode_lib, 229 + struct _vcs_dpi_wm_calc_pipe_params_st *planes, 230 + unsigned int num_planes) 231 + { 232 + double val = 0.0; 233 + unsigned int i; 234 + 235 + for (i = 0; i < num_planes; i++) { 236 + double swath_width_y_plane = planes[i].swath_width_y * planes[i].num_dpp; 237 + 238 + planes[i].read_bw = swath_width_y_plane 239 + * (dml_ceil(planes[i].bytes_per_pixel_y) 240 + + dml_ceil_2(planes[i].bytes_per_pixel_c) / 2) 241 + / (planes[i].h_total / planes[i].pixclk_mhz) * planes[i].v_ratio; 242 + 243 + val += planes[i].read_bw; 244 + 245 + DTRACE("plane[%d] start", i); 246 + DTRACE("read_bw = %f", planes[i].read_bw); 247 + DTRACE("plane[%d] end", i); 248 + } 249 + 250 + return val; 251 + } 252 + 253 + double dml_wm_calc_total_data_read_bw( 254 + struct display_mode_lib *mode_lib, 255 + struct _vcs_dpi_wm_calc_pipe_params_st *planes, 256 + unsigned int num_planes) 257 + { 258 + return calc_total_data_read_bw(mode_lib, planes, num_planes); 259 + } 260 + 261 + static double calc_dcfclk_mhz( 262 + struct _vcs_dpi_wm_calc_pipe_params_st *planes, 263 + unsigned int num_planes) 264 + { 265 + double dcfclk_mhz = -1.0; 266 + unsigned int i; 267 + 268 + for (i = 0; i < num_planes; i++) { 269 + /* voltage and dcfclk must be the same for all pipes */ 270 + ASSERT(dcfclk_mhz == -1.0 || dcfclk_mhz == planes[i].dcfclk_mhz); 271 + dcfclk_mhz = planes[i].dcfclk_mhz; 272 + } 273 + 274 + return dcfclk_mhz; 275 + } 276 + 277 + static enum voltage_state find_voltage( 278 + struct _vcs_dpi_wm_calc_pipe_params_st *planes, 279 + unsigned int num_planes) 280 + { 281 + int voltage = -1; 282 + unsigned int i; 283 + 284 + for (i = 0; i < num_planes; i++) { 285 + ASSERT(voltage == -1 || voltage == planes[i].voltage); 286 + voltage = planes[i].voltage; 287 + } 288 + 289 + return (enum voltage_state) voltage; 290 + } 291 + 292 + static bool find_dcc_enable(struct _vcs_dpi_wm_calc_pipe_params_st *planes, unsigned int num_planes) 293 + { 294 + unsigned int i; 295 + 296 + for (i = 0; i < num_planes; i++) { 297 + if (planes[i].dcc_enable) { 298 + return true; 299 + } 300 + } 301 + 302 + return false; 303 + } 304 + 305 + static double calc_return_bw( 306 + struct display_mode_lib *mode_lib, 307 + struct _vcs_dpi_wm_calc_pipe_params_st *planes, 308 + unsigned int num_planes) 309 + { 310 + struct _vcs_dpi_soc_bounding_box_st *soc; 311 + double return_bw_mbps; 312 + double dcfclk_mhz; 313 + double return_bus_bw; 314 + enum voltage_state voltage; 315 + double return_bw_to_dcn; 316 + bool dcc_enable; 317 + double rob_chunk_diff; 318 + double urgent_latency_traffic; 319 + double critical_compression; 320 + struct _vcs_dpi_voltage_scaling_st state; 321 + 322 + soc = &mode_lib->soc; 323 + 324 + dcfclk_mhz = calc_dcfclk_mhz(planes, num_planes); 325 + return_bus_bw = dcfclk_mhz * soc->return_bus_width_bytes; 326 + 327 + DTRACE("INTERMEDIATE dcfclk_mhz = %f", dcfclk_mhz); 328 + DTRACE("INTERMEDIATE return_bus_bw = %f", return_bus_bw); 329 + 330 + voltage = find_voltage(planes, num_planes); 331 + return_bw_to_dcn = dml_socbb_return_bw_mhz(soc, voltage); 332 + 333 + dcc_enable = find_dcc_enable(planes, num_planes); 334 + 335 + return_bw_mbps = return_bw_to_dcn; 336 + DTRACE("INTERMEDIATE return_bw_mbps = %f", return_bw_mbps); 337 + 338 + rob_chunk_diff = 339 + (mode_lib->ip.rob_buffer_size_kbytes - mode_lib->ip.pixel_chunk_size_kbytes) 340 + * 1024.0; 341 + DTRACE("INTERMEDIATE rob_chunk_diff = %f", rob_chunk_diff); 342 + 343 + if (dcc_enable && return_bw_to_dcn > return_bus_bw / 4) { 344 + double dcc_return_bw = 345 + return_bw_to_dcn * 4.0 346 + * (1.0 347 + - soc->urgent_latency_us 348 + / (rob_chunk_diff 349 + / (return_bw_to_dcn 350 + - return_bus_bw 351 + / 4.0) 352 + + soc->urgent_latency_us)); 353 + return_bw_mbps = dml_min(return_bw_mbps, dcc_return_bw); 354 + DTRACE("INTERMEDIATE dcc_return_bw = %f", dcc_return_bw); 355 + } 356 + 357 + urgent_latency_traffic = return_bus_bw * soc->urgent_latency_us; 358 + DTRACE("INTERMEDIATE urgent_latency_traffic = %f", urgent_latency_traffic); 359 + critical_compression = 2.0 * urgent_latency_traffic 360 + / (return_bw_to_dcn * soc->urgent_latency_us + rob_chunk_diff); 361 + DTRACE("INTERMEDIATE critical_compression = %f", critical_compression); 362 + 363 + if (dcc_enable && critical_compression > 1.0 && critical_compression < 4.0) { 364 + double crit_return_bw = (4 * return_bw_to_dcn * rob_chunk_diff 365 + * urgent_latency_traffic); 366 + crit_return_bw = crit_return_bw 367 + / dml_pow( 368 + return_bw_to_dcn * soc->urgent_latency_us 369 + + rob_chunk_diff, 370 + 2); 371 + DTRACE("INTERMEDIATE critical_return_bw = %f", crit_return_bw); 372 + return_bw_mbps = dml_min(return_bw_mbps, crit_return_bw); 373 + } 374 + 375 + /* Gabe does this again for some reason using the value of return_bw_mpbs from the previous calculation 376 + * and a lightly different return_bw_to_dcn 377 + */ 378 + 379 + state = dml_socbb_voltage_scaling(soc, voltage); 380 + return_bw_to_dcn = dml_min( 381 + soc->return_bus_width_bytes * dcfclk_mhz, 382 + state.dram_bw_per_chan_gbps * 1000.0 * (double) soc->num_chans); 383 + 384 + DTRACE("INTERMEDIATE rob_chunk_diff = %f", rob_chunk_diff); 385 + 386 + if (dcc_enable && return_bw_to_dcn > return_bus_bw / 4) { 387 + double dcc_return_bw = 388 + return_bw_to_dcn * 4.0 389 + * (1.0 390 + - soc->urgent_latency_us 391 + / (rob_chunk_diff 392 + / (return_bw_to_dcn 393 + - return_bus_bw 394 + / 4.0) 395 + + soc->urgent_latency_us)); 396 + return_bw_mbps = dml_min(return_bw_mbps, dcc_return_bw); 397 + DTRACE("INTERMEDIATE dcc_return_bw = %f", dcc_return_bw); 398 + } 399 + 400 + urgent_latency_traffic = return_bus_bw * soc->urgent_latency_us; 401 + DTRACE("INTERMEDIATE urgent_latency_traffic = %f", urgent_latency_traffic); 402 + critical_compression = 2.0 * urgent_latency_traffic 403 + / (return_bw_to_dcn * soc->urgent_latency_us + rob_chunk_diff); 404 + DTRACE("INTERMEDIATE critical_compression = %f", critical_compression); 405 + 406 + /* problem here? */ 407 + if (dcc_enable && critical_compression > 1.0 && critical_compression < 4.0) { 408 + double crit_return_bw = (4 * return_bw_to_dcn * rob_chunk_diff 409 + * urgent_latency_traffic); 410 + crit_return_bw = crit_return_bw 411 + / dml_pow( 412 + return_bw_to_dcn * soc->urgent_latency_us 413 + + rob_chunk_diff, 414 + 2); 415 + DTRACE("INTERMEDIATE critical_return_bw = %f", crit_return_bw); 416 + DTRACE("INTERMEDIATE return_bw_to_dcn = %f", return_bw_to_dcn); 417 + DTRACE("INTERMEDIATE rob_chunk_diff = %f", rob_chunk_diff); 418 + DTRACE("INTERMEDIATE urgent_latency_traffic = %f", urgent_latency_traffic); 419 + 420 + return_bw_mbps = dml_min(return_bw_mbps, crit_return_bw); 421 + } 422 + 423 + DTRACE("INTERMEDIATE final return_bw_mbps = %f", return_bw_mbps); 424 + return return_bw_mbps; 425 + } 426 + 427 + double dml_wm_calc_return_bw( 428 + struct display_mode_lib *mode_lib, 429 + struct _vcs_dpi_wm_calc_pipe_params_st *planes, 430 + unsigned int num_planes) 431 + { 432 + return calc_return_bw(mode_lib, planes, num_planes); 433 + } 434 + 435 + static double calc_last_pixel_of_line_extra_wm_us( 436 + struct display_mode_lib *mode_lib, 437 + struct _vcs_dpi_wm_calc_pipe_params_st *planes, 438 + unsigned int num_planes) 439 + { 440 + double val = 0.0; 441 + double total_data_read_bw = calc_total_data_read_bw(mode_lib, planes, num_planes); 442 + int voltage = -1; 443 + unsigned int i; 444 + double return_bw_mbps; 445 + 446 + for (i = 0; i < num_planes; i++) { 447 + /* voltage mode must be the same for all pipes */ 448 + ASSERT(voltage == -1 || voltage == planes[i].voltage); 449 + voltage = planes[i].voltage; 450 + } 451 + return_bw_mbps = calc_return_bw(mode_lib, planes, num_planes); 452 + 453 + for (i = 0; i < num_planes; i++) { 454 + double bytes_pp_y = dml_ceil(planes[i].bytes_per_pixel_y); 455 + double bytes_pp_c = dml_ceil_2(planes[i].bytes_per_pixel_c); 456 + double swath_bytes_y = (double) planes[i].swath_width_y 457 + * (double) planes[i].swath_height_y * (double) bytes_pp_y; 458 + double swath_bytes_c = ((double) planes[i].swath_width_y / 2.0) 459 + * (double) planes[i].swath_height_c * (double) bytes_pp_c; 460 + double data_fabric_line_delivery_time = (swath_bytes_y + swath_bytes_c) 461 + / (return_bw_mbps * planes[i].read_bw / (double) planes[i].num_dpp 462 + / total_data_read_bw); 463 + 464 + DTRACE( 465 + "bytes_pp_y = %f, swath_width_y = %f, swath_height_y = %f, swath_bytes_y = %f", 466 + bytes_pp_y, 467 + (double) planes[i].swath_width_y, 468 + (double) planes[i].swath_height_y, 469 + swath_bytes_y); 470 + DTRACE( 471 + "bytes_pp_c = %f, swath_width_c = %f, swath_height_c = %f, swath_bytes_c = %f", 472 + bytes_pp_c, 473 + ((double) planes[i].swath_width_y / 2.0), 474 + (double) planes[i].swath_height_c, 475 + swath_bytes_c); 476 + DTRACE( 477 + "return_bw_mbps = %f, read_bw = %f, num_dpp = %d, total_data_read_bw = %f", 478 + return_bw_mbps, 479 + planes[i].read_bw, 480 + planes[i].num_dpp, 481 + total_data_read_bw); 482 + DTRACE("data_fabric_line_delivery_time = %f", data_fabric_line_delivery_time); 483 + DTRACE( 484 + "display_pipe_line_delivery_time = %f", 485 + planes[i].display_pipe_line_delivery_time); 486 + 487 + val = dml_max( 488 + val, 489 + data_fabric_line_delivery_time 490 + - planes[i].display_pipe_line_delivery_time); 491 + } 492 + 493 + DTRACE("last_pixel_of_line_extra_wm is %f us", val); 494 + return val; 495 + } 496 + 497 + static bool calc_pte_enable(struct _vcs_dpi_wm_calc_pipe_params_st *planes, unsigned int num_planes) 498 + { 499 + unsigned int i; 500 + 501 + for (i = 0; i < num_planes; i++) { 502 + if (planes[i].pte_enable) { 503 + return true; 504 + } 505 + } 506 + 507 + return false; 508 + } 509 + 510 + static void calc_lines_in_det_y(struct _vcs_dpi_wm_calc_pipe_params_st *plane) 511 + { 512 + plane->lines_in_det_y = plane->det_buffer_size_y / plane->bytes_per_pixel_y 513 + / plane->swath_width_y; 514 + plane->lines_in_det_y_rounded_down_to_swath = dml_floor( 515 + (double) plane->lines_in_det_y / plane->swath_height_y) 516 + * plane->swath_height_y; 517 + plane->full_det_buffering_time = plane->lines_in_det_y_rounded_down_to_swath 518 + * (plane->h_total / plane->pixclk_mhz); 519 + } 520 + 521 + /* CHECKME: not obviously 1:1 with calculation described in architectural 522 + * document or spreadsheet */ 523 + static void calc_dcfclk_deepsleep_mhz_per_plane( 524 + struct display_mode_lib *mode_lib, 525 + struct _vcs_dpi_wm_calc_pipe_params_st *plane) 526 + { 527 + double bus_width_per_pixel; 528 + 529 + if (plane->swath_height_c == 0) { 530 + bus_width_per_pixel = dml_ceil(plane->bytes_per_pixel_y) / 64; 531 + } else { 532 + double bus_width_per_pixel_c; 533 + 534 + bus_width_per_pixel = dml_ceil(plane->bytes_per_pixel_y) / 32; 535 + bus_width_per_pixel_c = dml_ceil(plane->bytes_per_pixel_c) / 32; 536 + if (bus_width_per_pixel < bus_width_per_pixel_c) 537 + bus_width_per_pixel = bus_width_per_pixel_c; 538 + } 539 + 540 + if (plane->v_ratio <= 1) { 541 + plane->dcfclk_deepsleep_mhz_per_plane = 1.1 * plane->pixclk_mhz / plane->num_dpp 542 + * plane->h_ratio * bus_width_per_pixel; 543 + } else if (plane->h_ratio > 1) { 544 + double num_hscl_kernels = dml_ceil((double) plane->h_taps / 6); 545 + double dchub_pscl_bw_per_clk = dml_min( 546 + (double) mode_lib->ip.max_dchub_pscl_bw_pix_per_clk, 547 + mode_lib->ip.max_pscl_lb_bw_pix_per_clk * plane->h_ratio 548 + / num_hscl_kernels); 549 + 550 + plane->dcfclk_deepsleep_mhz_per_plane = 1.1 * plane->dppclk_mhz 551 + * dchub_pscl_bw_per_clk * bus_width_per_pixel; 552 + } else { 553 + double dchub_pscl_bw_per_clk = dml_min( 554 + (double) mode_lib->ip.max_dchub_pscl_bw_pix_per_clk, 555 + (double) mode_lib->ip.max_pscl_lb_bw_pix_per_clk); 556 + 557 + plane->dcfclk_deepsleep_mhz_per_plane = 1.1 * plane->dppclk_mhz 558 + * dchub_pscl_bw_per_clk * bus_width_per_pixel; 559 + } 560 + 561 + plane->dcfclk_deepsleep_mhz_per_plane = dml_max( 562 + plane->dcfclk_deepsleep_mhz_per_plane, 563 + plane->pixclk_mhz / 16); 564 + } 565 + 566 + /* Implementation of expected stutter efficiency from DCN1_Display_Mode.docx */ 567 + double dml_wm_expected_stutter_eff_e2e( 568 + struct display_mode_lib *mode_lib, 569 + struct _vcs_dpi_display_e2e_pipe_params_st *e2e, 570 + unsigned int num_pipes) 571 + { 572 + double min_full_det_buffering_time_us; 573 + double frame_time_for_min_full_det_buffering_time_us = 0.0; 574 + struct _vcs_dpi_wm_calc_pipe_params_st *planes = mode_lib->wm_param; 575 + unsigned int num_planes; 576 + unsigned int i; 577 + double total_data_read_bw_mbps; 578 + double average_read_bw_gbps; 579 + double min_full_det_buffer_size_bytes; 580 + double rob_fill_size_bytes; 581 + double part_of_burst_that_fits_in_rob; 582 + int voltage; 583 + double dcfclk_mhz; 584 + unsigned int total_writeback; 585 + double return_bw_mbps; 586 + double stutter_burst_time_us; 587 + double stutter_eff_not_including_vblank; 588 + double smallest_vblank_us; 589 + double stutter_eff; 590 + 591 + memset(mode_lib->wm_param, 0, sizeof(mode_lib->wm_param)); 592 + DTRACE("calculating expected stutter efficiency"); 593 + 594 + num_planes = dml_wm_e2e_to_wm(mode_lib, e2e, num_pipes, planes); 595 + 596 + for (i = 0; i < num_planes; i++) { 597 + calc_lines_in_det_y(&planes[i]); 598 + 599 + DTRACE("swath width y plane %d = %d", i, planes[i].swath_width_y); 600 + DTRACE("swath height y plane %d = %d", i, planes[i].swath_height_y); 601 + DTRACE( 602 + "bytes per pixel det y plane %d = %f", 603 + i, 604 + planes[i].bytes_per_pixel_y); 605 + DTRACE( 606 + "bytes per pixel det c plane %d = %f", 607 + i, 608 + planes[i].bytes_per_pixel_c); 609 + DTRACE( 610 + "det buffer size plane %d = %d", 611 + i, 612 + planes[i].det_buffer_size_y); 613 + DTRACE("lines in det plane %d = %d", i, planes[i].lines_in_det_y); 614 + DTRACE( 615 + "lines in det rounded to swaths plane %d = %d", 616 + i, 617 + planes[i].lines_in_det_y_rounded_down_to_swath); 618 + } 619 + 620 + min_full_det_buffering_time_us = 9999.0; 621 + for (i = 0; i < num_planes; i++) { 622 + if (planes[i].full_det_buffering_time < min_full_det_buffering_time_us) { 623 + min_full_det_buffering_time_us = planes[i].full_det_buffering_time; 624 + frame_time_for_min_full_det_buffering_time_us = (double) planes[i].v_total 625 + * planes[i].h_total / planes[i].pixclk_mhz; 626 + } 627 + } 628 + 629 + DTRACE("INTERMEDIATE: min_full_det_buffering_time_us = %f", min_full_det_buffering_time_us); 630 + 631 + total_data_read_bw_mbps = calc_total_data_read_bw(mode_lib, planes, num_planes); 632 + 633 + average_read_bw_gbps = 0.0; 634 + 635 + for (i = 0; i < num_planes; i++) { 636 + if (planes[i].dcc_enable) { 637 + average_read_bw_gbps += planes[i].read_bw / planes[i].dcc_rate / 1000; 638 + } else { 639 + average_read_bw_gbps += planes[i].read_bw / 1000; 640 + } 641 + 642 + if (planes[i].dcc_enable) { 643 + average_read_bw_gbps += planes[i].read_bw / 1000 / 256; 644 + } 645 + 646 + if (planes[i].pte_enable) { 647 + average_read_bw_gbps += planes[i].read_bw / 1000 / 512; 648 + } 649 + } 650 + 651 + min_full_det_buffer_size_bytes = min_full_det_buffering_time_us * total_data_read_bw_mbps; 652 + rob_fill_size_bytes = mode_lib->ip.rob_buffer_size_kbytes * 1024 * total_data_read_bw_mbps 653 + / (average_read_bw_gbps * 1000); 654 + part_of_burst_that_fits_in_rob = dml_min( 655 + min_full_det_buffer_size_bytes, 656 + rob_fill_size_bytes); 657 + 658 + voltage = -1; 659 + dcfclk_mhz = -1.0; 660 + total_writeback = 0; 661 + 662 + for (i = 0; i < num_pipes; i++) { 663 + /* voltage and dcfclk must be the same for all pipes */ 664 + ASSERT(voltage == -1 || voltage == e2e[i].clks_cfg.voltage); 665 + voltage = e2e[i].clks_cfg.voltage; 666 + ASSERT(dcfclk_mhz == -1.0 || dcfclk_mhz == e2e[i].clks_cfg.dcfclk_mhz); 667 + dcfclk_mhz = e2e[i].clks_cfg.dcfclk_mhz; 668 + 669 + if (e2e[i].dout.output_type == dm_wb) 670 + total_writeback++; 671 + } 672 + 673 + return_bw_mbps = calc_return_bw(mode_lib, planes, num_planes); 674 + 675 + DTRACE("INTERMEDIATE: part_of_burst_that_fits_in_rob = %f", part_of_burst_that_fits_in_rob); 676 + DTRACE("INTERMEDIATE: average_read_bw_gbps = %f", average_read_bw_gbps); 677 + DTRACE("INTERMEDIATE: total_data_read_bw_mbps = %f", total_data_read_bw_mbps); 678 + DTRACE("INTERMEDIATE: return_bw_mbps = %f", return_bw_mbps); 679 + 680 + stutter_burst_time_us = part_of_burst_that_fits_in_rob * (average_read_bw_gbps * 1000) 681 + / total_data_read_bw_mbps / return_bw_mbps 682 + + (min_full_det_buffering_time_us * total_data_read_bw_mbps 683 + - part_of_burst_that_fits_in_rob) / (dcfclk_mhz * 64); 684 + DTRACE("INTERMEDIATE: stutter_burst_time_us = %f", stutter_burst_time_us); 685 + 686 + if (total_writeback == 0) { 687 + stutter_eff_not_including_vblank = (1.0 688 + - ((mode_lib->soc.sr_exit_time_us + stutter_burst_time_us) 689 + / min_full_det_buffering_time_us)) * 100.0; 690 + } else { 691 + stutter_eff_not_including_vblank = 0.0; 692 + } 693 + 694 + DTRACE("stutter_efficiency_not_including_vblank = %f", stutter_eff_not_including_vblank); 695 + 696 + smallest_vblank_us = 9999.0; 697 + 698 + for (i = 0; i < num_pipes; i++) { 699 + double vblank_us; 700 + if (e2e[i].pipe.dest.syncronized_vblank_all_planes != 0 || num_pipes == 1) { 701 + vblank_us = (double) (e2e[i].pipe.dest.vtotal + 1 702 + - e2e[i].pipe.dest.vblank_start 703 + + e2e[i].pipe.dest.vblank_end * e2e[i].pipe.dest.htotal) 704 + / e2e[i].pipe.dest.pixel_rate_mhz; 705 + } else { 706 + vblank_us = 0.0; 707 + } 708 + 709 + smallest_vblank_us = dml_min(smallest_vblank_us, vblank_us); 710 + } 711 + 712 + DTRACE("smallest vblank = %f us", smallest_vblank_us); 713 + 714 + stutter_eff = 100.0 715 + * (((stutter_eff_not_including_vblank / 100.0) 716 + * (frame_time_for_min_full_det_buffering_time_us 717 + - smallest_vblank_us) + smallest_vblank_us) 718 + / frame_time_for_min_full_det_buffering_time_us); 719 + 720 + DTRACE("stutter_efficiency = %f", stutter_eff); 721 + 722 + return stutter_eff_not_including_vblank; 723 + } 724 + 725 + double dml_wm_expected_stutter_eff_e2e_with_vblank( 726 + struct display_mode_lib *mode_lib, 727 + struct _vcs_dpi_display_e2e_pipe_params_st *e2e, 728 + unsigned int num_pipes) 729 + { 730 + double min_full_det_buffering_time_us; 731 + double frame_time_for_min_full_det_buffering_time_us = 0.0; 732 + struct _vcs_dpi_wm_calc_pipe_params_st *planes = mode_lib->wm_param; 733 + unsigned int num_planes; 734 + unsigned int i; 735 + double total_data_read_bw_mbps; 736 + double average_read_bw_gbps; 737 + double min_full_det_buffer_size_bytes; 738 + double rob_fill_size_bytes; 739 + double part_of_burst_that_fits_in_rob; 740 + int voltage; 741 + double dcfclk_mhz; 742 + unsigned int total_writeback; 743 + double return_bw_mbps; 744 + double stutter_burst_time_us; 745 + double stutter_eff_not_including_vblank; 746 + double smallest_vblank_us; 747 + double stutter_eff; 748 + 749 + memset(mode_lib->wm_param, 0, sizeof(mode_lib->wm_param)); 750 + num_planes = dml_wm_e2e_to_wm(mode_lib, e2e, num_pipes, planes); 751 + 752 + for (i = 0; i < num_planes; i++) { 753 + calc_lines_in_det_y(&planes[i]); 754 + } 755 + 756 + min_full_det_buffering_time_us = 9999.0; 757 + for (i = 0; i < num_planes; i++) { 758 + if (planes[i].full_det_buffering_time < min_full_det_buffering_time_us) { 759 + min_full_det_buffering_time_us = planes[i].full_det_buffering_time; 760 + frame_time_for_min_full_det_buffering_time_us = (double) planes[i].v_total 761 + * planes[i].h_total / planes[i].pixclk_mhz; 762 + } 763 + } 764 + 765 + total_data_read_bw_mbps = calc_total_data_read_bw(mode_lib, planes, num_planes); 766 + average_read_bw_gbps = 0.0; 767 + 768 + for (i = 0; i < num_planes; i++) { 769 + if (planes[i].dcc_enable) { 770 + average_read_bw_gbps += planes[i].read_bw / planes[i].dcc_rate / 1000; 771 + } else { 772 + average_read_bw_gbps += planes[i].read_bw / 1000; 773 + } 774 + 775 + if (planes[i].dcc_enable) { 776 + average_read_bw_gbps += planes[i].read_bw / 1000 / 256; 777 + } 778 + 779 + if (planes[i].pte_enable) { 780 + average_read_bw_gbps += planes[i].read_bw / 1000 / 512; 781 + } 782 + } 783 + 784 + min_full_det_buffer_size_bytes = min_full_det_buffering_time_us * total_data_read_bw_mbps; 785 + rob_fill_size_bytes = mode_lib->ip.rob_buffer_size_kbytes * 1024 * total_data_read_bw_mbps 786 + / (average_read_bw_gbps * 1000); 787 + part_of_burst_that_fits_in_rob = dml_min( 788 + min_full_det_buffer_size_bytes, 789 + rob_fill_size_bytes); 790 + 791 + voltage = -1; 792 + dcfclk_mhz = -1.0; 793 + total_writeback = 0; 794 + 795 + for (i = 0; i < num_pipes; i++) { 796 + /* voltage and dcfclk must be the same for all pipes */ 797 + ASSERT(voltage == -1 || voltage == e2e[i].clks_cfg.voltage); 798 + voltage = e2e[i].clks_cfg.voltage; 799 + ASSERT(dcfclk_mhz == -1.0 || dcfclk_mhz == e2e[i].clks_cfg.dcfclk_mhz); 800 + dcfclk_mhz = e2e[i].clks_cfg.dcfclk_mhz; 801 + 802 + if (e2e[i].dout.output_type == dm_wb) 803 + total_writeback++; 804 + } 805 + 806 + return_bw_mbps = calc_return_bw(mode_lib, planes, num_planes); 807 + 808 + stutter_burst_time_us = part_of_burst_that_fits_in_rob * (average_read_bw_gbps * 1000) 809 + / total_data_read_bw_mbps / return_bw_mbps 810 + + (min_full_det_buffering_time_us * total_data_read_bw_mbps 811 + - part_of_burst_that_fits_in_rob) / (dcfclk_mhz * 64); 812 + 813 + if (total_writeback == 0) { 814 + stutter_eff_not_including_vblank = (1.0 815 + - ((mode_lib->soc.sr_exit_time_us + stutter_burst_time_us) 816 + / min_full_det_buffering_time_us)) * 100.0; 817 + } else { 818 + stutter_eff_not_including_vblank = 0.0; 819 + } 820 + 821 + smallest_vblank_us = 9999.0; 822 + 823 + for (i = 0; i < num_pipes; i++) { 824 + double vblank_us; 825 + if (e2e[i].pipe.dest.syncronized_vblank_all_planes != 0 || num_pipes == 1) { 826 + vblank_us = (double) (e2e[i].pipe.dest.vtotal + 1 827 + - e2e[i].pipe.dest.vblank_start 828 + + e2e[i].pipe.dest.vblank_end * e2e[i].pipe.dest.htotal) 829 + / e2e[i].pipe.dest.pixel_rate_mhz; 830 + } else { 831 + vblank_us = 0.0; 832 + } 833 + 834 + smallest_vblank_us = dml_min(smallest_vblank_us, vblank_us); 835 + } 836 + 837 + stutter_eff = 100.0 838 + * (((stutter_eff_not_including_vblank / 100.0) 839 + * (frame_time_for_min_full_det_buffering_time_us 840 + - smallest_vblank_us) + smallest_vblank_us) 841 + / frame_time_for_min_full_det_buffering_time_us); 842 + 843 + 844 + return stutter_eff; 845 + } 846 + 847 + double urgent_extra_calc( 848 + struct display_mode_lib *mode_lib, 849 + double dcfclk_mhz, 850 + double return_bw_mbps, 851 + unsigned int total_active_dpp, 852 + unsigned int total_dcc_active_dpp) 853 + { 854 + double urgent_extra_latency_us = 0.0; 855 + double urgent_round_trip_ooo_latency_us; 856 + 857 + urgent_round_trip_ooo_latency_us = 858 + (((double) mode_lib->soc.round_trip_ping_latency_dcfclk_cycles + 32) 859 + / dcfclk_mhz) 860 + + (((double) (mode_lib->soc.urgent_out_of_order_return_per_channel_bytes 861 + * mode_lib->soc.num_chans)) / return_bw_mbps); 862 + 863 + DTRACE( 864 + "INTERMEDIATE round_trip_ping_latency_dcfclk_cycles = %d", 865 + mode_lib->soc.round_trip_ping_latency_dcfclk_cycles); 866 + DTRACE("INTERMEDIATE dcfclk_mhz = %f", dcfclk_mhz); 867 + DTRACE( 868 + "INTERMEDIATE urgent_out_of_order_return_per_channel_bytes = %d", 869 + mode_lib->soc.urgent_out_of_order_return_per_channel_bytes); 870 + 871 + urgent_extra_latency_us = urgent_round_trip_ooo_latency_us 872 + + ((double) total_active_dpp * mode_lib->ip.pixel_chunk_size_kbytes 873 + + (double) total_dcc_active_dpp 874 + * mode_lib->ip.meta_chunk_size_kbytes) 875 + * 1024.0 / return_bw_mbps; /* to us */ 876 + 877 + DTRACE( 878 + "INTERMEDIATE urgent_round_trip_ooo_latency_us = %f", 879 + urgent_round_trip_ooo_latency_us); 880 + DTRACE("INTERMEDIATE total_active_dpp = %d", total_active_dpp); 881 + DTRACE( 882 + "INTERMEDIATE pixel_chunk_size_kbytes = %d", 883 + mode_lib->ip.pixel_chunk_size_kbytes); 884 + DTRACE("INTERMEDIATE total_dcc_active_dpp = %d", total_dcc_active_dpp); 885 + DTRACE( 886 + "INTERMEDIATE meta_chunk_size_kbyte = %d", 887 + mode_lib->ip.meta_chunk_size_kbytes); 888 + DTRACE("INTERMEDIATE return_bw_mbps = %f", return_bw_mbps); 889 + 890 + return urgent_extra_latency_us; 891 + } 892 + 893 + double dml_wm_urgent_extra_max(struct display_mode_lib *mode_lib) 894 + { 895 + unsigned int total_active_dpp = DC__NUM_DPP; 896 + unsigned int total_dcc_active_dpp = total_active_dpp; 897 + double urgent_extra_latency_us = 0.0; 898 + double dcfclk_mhz = 0.0; 899 + double return_bw_mbps = 0.0; 900 + int voltage = dm_vmin; 901 + 902 + /* use minimum voltage */ 903 + return_bw_mbps = dml_socbb_return_bw_mhz(&mode_lib->soc, (enum voltage_state) voltage); 904 + /* use minimum dcfclk */ 905 + dcfclk_mhz = mode_lib->soc.vmin.dcfclk_mhz; 906 + /* use max dpps and dpps with dcc */ 907 + 908 + urgent_extra_latency_us = urgent_extra_calc( 909 + mode_lib, 910 + dcfclk_mhz, 911 + return_bw_mbps, 912 + total_active_dpp, 913 + total_dcc_active_dpp); 914 + 915 + DTRACE("urgent extra max = %f", urgent_extra_latency_us); 916 + return urgent_extra_latency_us; 917 + } 918 + 919 + double dml_wm_urgent_extra( 920 + struct display_mode_lib *mode_lib, 921 + struct _vcs_dpi_wm_calc_pipe_params_st *pipes, 922 + unsigned int num_pipes) 923 + { 924 + unsigned int total_active_dpp = 0; 925 + unsigned int total_dcc_active_dpp = 0; 926 + double urgent_extra_latency_us = 0.0; 927 + double dcfclk_mhz = 0.0; 928 + double return_bw_mbps = 0.0; 929 + int voltage = -1; 930 + bool pte_enable = false; 931 + unsigned int i; 932 + 933 + for (i = 0; i < num_pipes; i++) { 934 + /* num_dpp must be greater than 0 */ 935 + ASSERT(pipes[i].num_dpp > 0); 936 + 937 + /* voltage mode must be the same for all pipes */ 938 + ASSERT(voltage == -1 || voltage == pipes[i].voltage); 939 + voltage = pipes[i].voltage; 940 + 941 + /* dcfclk for all pipes must be the same */ 942 + ASSERT(dcfclk_mhz == 0.0 || dcfclk_mhz == pipes[i].dcfclk_mhz); 943 + dcfclk_mhz = pipes[i].dcfclk_mhz; 944 + 945 + total_active_dpp += pipes[i].num_dpp; 946 + 947 + if (pipes[i].dcc_enable) { 948 + total_dcc_active_dpp += pipes[i].num_dpp; 949 + } 950 + } 951 + 952 + DTRACE("total active dpps %d", total_active_dpp); 953 + DTRACE("total active dpps with dcc %d", total_dcc_active_dpp); 954 + DTRACE("voltage state is %d", voltage); 955 + 956 + return_bw_mbps = calc_return_bw(mode_lib, pipes, num_pipes); 957 + 958 + DTRACE("return_bandwidth is %f MBps", return_bw_mbps); 959 + 960 + pte_enable = calc_pte_enable(pipes, num_pipes); 961 + 962 + /* calculate the maximum extra latency just for comparison purposes */ 963 + /* dml_wm_urgent_extra_max(); */ 964 + urgent_extra_latency_us = urgent_extra_calc( 965 + mode_lib, 966 + dcfclk_mhz, 967 + return_bw_mbps, 968 + total_active_dpp, 969 + total_dcc_active_dpp); 970 + 971 + DTRACE("INTERMEDIATE urgent_extra_latency_us_before_pte = %f", urgent_extra_latency_us); 972 + 973 + if (pte_enable) { 974 + urgent_extra_latency_us += total_active_dpp * mode_lib->ip.pte_chunk_size_kbytes 975 + * 1024.0 / return_bw_mbps; 976 + 977 + DTRACE("INTERMEDIATE pte_enable = true"); 978 + DTRACE("INTERMEDIATE total_active_dpp = %d", total_active_dpp); 979 + DTRACE( 980 + "INTERMEDIATE pte_chunk_size_kbytes = %d", 981 + mode_lib->ip.pte_chunk_size_kbytes); 982 + DTRACE("INTERMEDIATE return_bw_mbps = %f", return_bw_mbps); 983 + } 984 + 985 + return urgent_extra_latency_us; 986 + } 987 + 988 + double dml_wm_urgent_e2e( 989 + struct display_mode_lib *mode_lib, 990 + struct _vcs_dpi_display_e2e_pipe_params_st *pipes, 991 + unsigned int num_pipes) 992 + { 993 + struct _vcs_dpi_wm_calc_pipe_params_st *wm = mode_lib->wm_param; 994 + unsigned int combined_pipes; 995 + double urgent_wm; 996 + 997 + memset(mode_lib->wm_param, 0, sizeof(mode_lib->wm_param)); 998 + combined_pipes = dml_wm_e2e_to_wm(mode_lib, pipes, num_pipes, wm); 999 + 1000 + urgent_wm = dml_wm_urgent(mode_lib, wm, combined_pipes); 1001 + 1002 + return urgent_wm; 1003 + } 1004 + 1005 + double dml_wm_urgent( 1006 + struct display_mode_lib *mode_lib, 1007 + struct _vcs_dpi_wm_calc_pipe_params_st *planes, 1008 + unsigned int num_planes) 1009 + { 1010 + double urgent_watermark; 1011 + double urgent_extra_latency_us; 1012 + double last_pixel_of_line_extra_wm_us = 0.0; 1013 + 1014 + DTRACE("calculating urgent watermark"); 1015 + calc_display_pipe_line_delivery_time(mode_lib, planes, num_planes); 1016 + urgent_extra_latency_us = dml_wm_urgent_extra(mode_lib, planes, num_planes); 1017 + 1018 + last_pixel_of_line_extra_wm_us = calc_last_pixel_of_line_extra_wm_us( 1019 + mode_lib, 1020 + planes, 1021 + num_planes); 1022 + 1023 + urgent_watermark = mode_lib->soc.urgent_latency_us + last_pixel_of_line_extra_wm_us 1024 + + urgent_extra_latency_us; 1025 + 1026 + DTRACE("INTERMEDIATE urgent_latency_us = %f", mode_lib->soc.urgent_latency_us); 1027 + DTRACE("INTERMEDIATE last_pixel_of_line_extra_wm_us = %f", last_pixel_of_line_extra_wm_us); 1028 + DTRACE("INTERMEDIATE urgent_extra_latency_us = %f", urgent_extra_latency_us); 1029 + 1030 + DTRACE("urgent_watermark_us = %f", urgent_watermark); 1031 + return urgent_watermark; 1032 + } 1033 + 1034 + double dml_wm_pte_meta_urgent(struct display_mode_lib *mode_lib, double urgent_wm_us) 1035 + { 1036 + double val; 1037 + 1038 + val = urgent_wm_us + 2.0 * mode_lib->soc.urgent_latency_us; 1039 + DTRACE("pte_meta_urgent_watermark_us = %f", val); 1040 + 1041 + return val; 1042 + } 1043 + 1044 + double dml_wm_dcfclk_deepsleep_mhz_e2e( 1045 + struct display_mode_lib *mode_lib, 1046 + struct _vcs_dpi_display_e2e_pipe_params_st *pipes, 1047 + unsigned int num_pipes) 1048 + { 1049 + struct _vcs_dpi_wm_calc_pipe_params_st *planes = mode_lib->wm_param; 1050 + unsigned int num_planes; 1051 + double val; 1052 + 1053 + memset(mode_lib->wm_param, 0, sizeof(mode_lib->wm_param)); 1054 + num_planes = dml_wm_e2e_to_wm(mode_lib, pipes, num_pipes, planes); 1055 + 1056 + val = dml_wm_dcfclk_deepsleep_mhz(mode_lib, planes, num_planes); 1057 + 1058 + return val; 1059 + } 1060 + 1061 + double dml_wm_dcfclk_deepsleep_mhz( 1062 + struct display_mode_lib *mode_lib, 1063 + struct _vcs_dpi_wm_calc_pipe_params_st *planes, 1064 + unsigned int num_planes) 1065 + { 1066 + double val = 8.0; 1067 + unsigned int i; 1068 + 1069 + for (i = 0; i < num_planes; i++) { 1070 + calc_dcfclk_deepsleep_mhz_per_plane(mode_lib, &planes[i]); 1071 + 1072 + if (val < planes[i].dcfclk_deepsleep_mhz_per_plane) { 1073 + val = planes[i].dcfclk_deepsleep_mhz_per_plane; 1074 + } 1075 + 1076 + DTRACE("plane[%d] start", i); 1077 + DTRACE("dcfclk_deepsleep_per_plane = %f", planes[i].dcfclk_deepsleep_mhz_per_plane); 1078 + DTRACE("plane[%d] end", i); 1079 + } 1080 + 1081 + DTRACE("dcfclk_deepsleep_mhz = %f", val); 1082 + 1083 + return val; 1084 + } 1085 + 1086 + struct _vcs_dpi_cstate_pstate_watermarks_st dml_wm_cstate_pstate_e2e( 1087 + struct display_mode_lib *mode_lib, 1088 + struct _vcs_dpi_display_e2e_pipe_params_st *pipes, 1089 + unsigned int num_pipes) 1090 + { 1091 + struct _vcs_dpi_wm_calc_pipe_params_st *wm = mode_lib->wm_param; 1092 + unsigned int combined_pipes; 1093 + struct _vcs_dpi_cstate_pstate_watermarks_st cstate_pstate_wm; 1094 + 1095 + memset(mode_lib->wm_param, 0, sizeof(mode_lib->wm_param)); 1096 + combined_pipes = dml_wm_e2e_to_wm(mode_lib, pipes, num_pipes, wm); 1097 + cstate_pstate_wm = dml_wm_cstate_pstate(mode_lib, wm, combined_pipes); 1098 + 1099 + 1100 + return cstate_pstate_wm; 1101 + } 1102 + 1103 + struct _vcs_dpi_cstate_pstate_watermarks_st dml_wm_cstate_pstate( 1104 + struct display_mode_lib *mode_lib, 1105 + struct _vcs_dpi_wm_calc_pipe_params_st *pipes, 1106 + unsigned int num_pipes) 1107 + { 1108 + struct _vcs_dpi_cstate_pstate_watermarks_st wm; 1109 + double urgent_extra_latency_us; 1110 + double urgent_watermark_us; 1111 + double last_pixel_of_line_extra_wm_us; 1112 + double dcfclk_deepsleep_freq; 1113 + 1114 + DTRACE("calculating cstate and pstate watermarks"); 1115 + urgent_extra_latency_us = dml_wm_urgent_extra(mode_lib, pipes, num_pipes); 1116 + urgent_watermark_us = dml_wm_urgent(mode_lib, pipes, num_pipes); 1117 + 1118 + last_pixel_of_line_extra_wm_us = calc_last_pixel_of_line_extra_wm_us( 1119 + mode_lib, 1120 + pipes, 1121 + num_pipes); 1122 + dcfclk_deepsleep_freq = dml_wm_dcfclk_deepsleep_mhz(mode_lib, pipes, num_pipes); 1123 + 1124 + wm.cstate_exit_us = mode_lib->soc.sr_exit_time_us + last_pixel_of_line_extra_wm_us 1125 + + urgent_extra_latency_us 1126 + + mode_lib->ip.dcfclk_cstate_latency / dcfclk_deepsleep_freq; 1127 + wm.cstate_enter_plus_exit_us = mode_lib->soc.sr_enter_plus_exit_time_us 1128 + + last_pixel_of_line_extra_wm_us + urgent_extra_latency_us; 1129 + wm.pstate_change_us = mode_lib->soc.dram_clock_change_latency_us + urgent_watermark_us; 1130 + 1131 + DTRACE("stutter_exit_watermark_us = %f", wm.cstate_exit_us); 1132 + DTRACE("stutter_enter_plus_exit_watermark_us = %f", wm.cstate_enter_plus_exit_us); 1133 + DTRACE("dram_clock_change_watermark_us = %f", wm.pstate_change_us); 1134 + 1135 + return wm; 1136 + } 1137 + 1138 + double dml_wm_writeback_pstate_e2e( 1139 + struct display_mode_lib *mode_lib, 1140 + struct _vcs_dpi_display_e2e_pipe_params_st *pipes, 1141 + unsigned int num_pipes) 1142 + { 1143 + struct _vcs_dpi_wm_calc_pipe_params_st *wm = mode_lib->wm_param; 1144 + unsigned int combined_pipes; 1145 + 1146 + memset(mode_lib->wm_param, 0, sizeof(mode_lib->wm_param)); 1147 + combined_pipes = dml_wm_e2e_to_wm(mode_lib, pipes, num_pipes, wm); 1148 + 1149 + 1150 + return dml_wm_writeback_pstate(mode_lib, wm, combined_pipes); 1151 + } 1152 + 1153 + double dml_wm_writeback_pstate( 1154 + struct display_mode_lib *mode_lib, 1155 + struct _vcs_dpi_wm_calc_pipe_params_st *pipes, 1156 + unsigned int num_pipes) 1157 + { 1158 + unsigned int total_active_wb = 0; 1159 + double wm = 0.0; 1160 + double socclk_mhz = 0.0; 1161 + unsigned int i; 1162 + 1163 + DTRACE("calculating wb pstate watermark"); 1164 + for (i = 0; i < num_pipes; i++) { 1165 + if (pipes[i].output_type == dm_wb) 1166 + total_active_wb++; 1167 + ASSERT(socclk_mhz == 0.0 || socclk_mhz == pipes[i].socclk_mhz); 1168 + socclk_mhz = pipes[i].socclk_mhz; 1169 + } 1170 + 1171 + DTRACE("total wb outputs %d", total_active_wb); 1172 + DTRACE("socclk frequency %f Mhz", socclk_mhz); 1173 + 1174 + if (total_active_wb <= 1) { 1175 + wm = mode_lib->soc.writeback_dram_clock_change_latency_us; 1176 + } else { 1177 + wm = mode_lib->soc.writeback_dram_clock_change_latency_us 1178 + + (mode_lib->ip.writeback_chunk_size_kbytes * 1024.0) / 32.0 1179 + / socclk_mhz; 1180 + } 1181 + 1182 + DTRACE("wb pstate watermark %f us", wm); 1183 + return wm; 1184 + } 1185 + 1186 + unsigned int dml_wm_e2e_to_wm( 1187 + struct display_mode_lib *mode_lib, 1188 + struct _vcs_dpi_display_e2e_pipe_params_st *e2e, 1189 + unsigned int num_pipes, 1190 + struct _vcs_dpi_wm_calc_pipe_params_st *wm) 1191 + { 1192 + unsigned int num_planes = 0; 1193 + bool visited[DC__NUM_PIPES]; 1194 + unsigned int i, j; 1195 + 1196 + for (i = 0; i < num_pipes; i++) { 1197 + visited[i] = false; 1198 + } 1199 + 1200 + for (i = 0; i < num_pipes; i++) { 1201 + unsigned int num_dpp = 1; 1202 + 1203 + if (visited[i]) { 1204 + continue; 1205 + } 1206 + 1207 + visited[i] = true; 1208 + 1209 + if (e2e[i].pipe.src.is_hsplit) { 1210 + for (j = i + 1; j < num_pipes; j++) { 1211 + if (e2e[j].pipe.src.is_hsplit && !visited[j] 1212 + && (e2e[i].pipe.src.hsplit_grp 1213 + == e2e[j].pipe.src.hsplit_grp)) { 1214 + num_dpp++; 1215 + visited[j] = true; 1216 + } 1217 + } 1218 + } 1219 + 1220 + wm[num_planes].num_dpp = num_dpp; 1221 + wm[num_planes].voltage = e2e[i].clks_cfg.voltage; 1222 + wm[num_planes].output_type = e2e[i].dout.output_type; 1223 + wm[num_planes].dcfclk_mhz = e2e[i].clks_cfg.dcfclk_mhz; 1224 + wm[num_planes].socclk_mhz = e2e[i].clks_cfg.socclk_mhz; 1225 + wm[num_planes].dppclk_mhz = e2e[i].clks_cfg.dppclk_mhz; 1226 + wm[num_planes].pixclk_mhz = e2e[i].pipe.dest.pixel_rate_mhz; 1227 + 1228 + wm[num_planes].pte_enable = e2e[i].pipe.src.vm; 1229 + wm[num_planes].dcc_enable = e2e[i].pipe.src.dcc; 1230 + wm[num_planes].dcc_rate = e2e[i].pipe.src.dcc_rate; 1231 + 1232 + get_bytes_per_pixel( 1233 + (enum source_format_class) e2e[i].pipe.src.source_format, 1234 + &wm[num_planes]); 1235 + wm[num_planes].swath_width_y = get_swath_width_y(&e2e[i].pipe.src, num_dpp); 1236 + get_swath_height( 1237 + mode_lib, 1238 + &e2e[i].pipe.src, 1239 + &wm[num_planes], 1240 + wm[num_planes].swath_width_y); 1241 + 1242 + wm[num_planes].interlace_en = e2e[i].pipe.dest.interlaced; 1243 + wm[num_planes].h_ratio = e2e[i].pipe.scale_ratio_depth.hscl_ratio; 1244 + wm[num_planes].v_ratio = e2e[i].pipe.scale_ratio_depth.vscl_ratio; 1245 + if (wm[num_planes].interlace_en) { 1246 + wm[num_planes].v_ratio = 2 * wm[num_planes].v_ratio; 1247 + } 1248 + wm[num_planes].h_taps = e2e[i].pipe.scale_taps.htaps; 1249 + wm[num_planes].h_total = e2e[i].pipe.dest.htotal; 1250 + wm[num_planes].v_total = e2e[i].pipe.dest.vtotal; 1251 + wm[num_planes].v_active = e2e[i].pipe.dest.vactive; 1252 + wm[num_planes].e2e_index = i; 1253 + num_planes++; 1254 + } 1255 + 1256 + for (i = 0; i < num_planes; i++) { 1257 + DTRACE("plane[%d] start", i); 1258 + DTRACE("voltage = %d", wm[i].voltage); 1259 + DTRACE("v_active = %d", wm[i].v_active); 1260 + DTRACE("h_total = %d", wm[i].h_total); 1261 + DTRACE("v_total = %d", wm[i].v_total); 1262 + DTRACE("pixclk_mhz = %f", wm[i].pixclk_mhz); 1263 + DTRACE("dcfclk_mhz = %f", wm[i].dcfclk_mhz); 1264 + DTRACE("dppclk_mhz = %f", wm[i].dppclk_mhz); 1265 + DTRACE("h_ratio = %f", wm[i].h_ratio); 1266 + DTRACE("v_ratio = %f", wm[i].v_ratio); 1267 + DTRACE("interlaced = %d", wm[i].interlace_en); 1268 + DTRACE("h_taps = %d", wm[i].h_taps); 1269 + DTRACE("num_dpp = %d", wm[i].num_dpp); 1270 + DTRACE("swath_width_y = %d", wm[i].swath_width_y); 1271 + DTRACE("swath_height_y = %d", wm[i].swath_height_y); 1272 + DTRACE("swath_height_c = %d", wm[i].swath_height_c); 1273 + DTRACE("det_buffer_size_y = %d", wm[i].det_buffer_size_y); 1274 + DTRACE("dcc_rate = %f", wm[i].dcc_rate); 1275 + DTRACE("dcc_enable = %s", wm[i].dcc_enable ? "true" : "false"); 1276 + DTRACE("pte_enable = %s", wm[i].pte_enable ? "true" : "false"); 1277 + DTRACE("plane[%d] end", i); 1278 + } 1279 + 1280 + return num_planes; 1281 + }
+98
drivers/gpu/drm/amd/display/dc/dml/display_watermark.h
··· 1 + /* 2 + * Copyright 2017 Advanced Micro Devices, Inc. 3 + * 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: 10 + * 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 13 + * 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. 21 + * 22 + * Authors: AMD 23 + * 24 + */ 25 + #ifndef __DISPLAY_WATERMARK_H__ 26 + #define __DISPLAY_WATERMARK_H__ 27 + 28 + #include "dml_common_defs.h" 29 + 30 + struct display_mode_lib; 31 + 32 + double dml_wm_urgent_extra( 33 + struct display_mode_lib *mode_lib, 34 + struct _vcs_dpi_wm_calc_pipe_params_st *pipes, 35 + unsigned int num_pipes); 36 + double dml_wm_urgent_extra_max(struct display_mode_lib *mode_lib); 37 + 38 + double dml_wm_urgent_e2e( 39 + struct display_mode_lib *mode_lib, 40 + struct _vcs_dpi_display_e2e_pipe_params_st *pipes, 41 + unsigned int num_pipes); 42 + double dml_wm_urgent( 43 + struct display_mode_lib *mode_lib, 44 + struct _vcs_dpi_wm_calc_pipe_params_st *planes, 45 + unsigned int num_planes); 46 + double dml_wm_pte_meta_urgent(struct display_mode_lib *mode_lib, double urgent_wm_us); 47 + double dml_wm_dcfclk_deepsleep_mhz_e2e( 48 + struct display_mode_lib *mode_lib, 49 + struct _vcs_dpi_display_e2e_pipe_params_st *pipes, 50 + unsigned int num_pipes); 51 + double dml_wm_dcfclk_deepsleep_mhz( 52 + struct display_mode_lib *mode_lib, 53 + struct _vcs_dpi_wm_calc_pipe_params_st *planes, 54 + unsigned int num_planes); 55 + 56 + struct _vcs_dpi_cstate_pstate_watermarks_st dml_wm_cstate_pstate_e2e( 57 + struct display_mode_lib *mode_lib, 58 + struct _vcs_dpi_display_e2e_pipe_params_st *pipes, 59 + unsigned int num_pipes); 60 + struct _vcs_dpi_cstate_pstate_watermarks_st dml_wm_cstate_pstate( 61 + struct display_mode_lib *mode_lib, 62 + struct _vcs_dpi_wm_calc_pipe_params_st *pipes, 63 + unsigned int num_pipes); 64 + 65 + double dml_wm_writeback_pstate_e2e( 66 + struct display_mode_lib *mode_lib, 67 + struct _vcs_dpi_display_e2e_pipe_params_st *pipes, 68 + unsigned int num_pipes); 69 + double dml_wm_writeback_pstate( 70 + struct display_mode_lib *mode_lib, 71 + struct _vcs_dpi_wm_calc_pipe_params_st *pipes, 72 + unsigned int num_pipes); 73 + 74 + double dml_wm_expected_stutter_eff_e2e( 75 + struct display_mode_lib *mode_lib, 76 + struct _vcs_dpi_display_e2e_pipe_params_st *e2e, 77 + unsigned int num_pipes); 78 + double dml_wm_expected_stutter_eff_e2e_with_vblank( 79 + struct display_mode_lib *mode_lib, 80 + struct _vcs_dpi_display_e2e_pipe_params_st *e2e, 81 + unsigned int num_pipes); 82 + 83 + unsigned int dml_wm_e2e_to_wm( 84 + struct display_mode_lib *mode_lib, 85 + struct _vcs_dpi_display_e2e_pipe_params_st *e2e, 86 + unsigned int num_pipes, 87 + struct _vcs_dpi_wm_calc_pipe_params_st *wm); 88 + 89 + double dml_wm_calc_total_data_read_bw( 90 + struct display_mode_lib *mode_lib, 91 + struct _vcs_dpi_wm_calc_pipe_params_st *planes, 92 + unsigned int num_planes); 93 + double dml_wm_calc_return_bw( 94 + struct display_mode_lib *mode_lib, 95 + struct _vcs_dpi_wm_calc_pipe_params_st *planes, 96 + unsigned int num_planes); 97 + 98 + #endif
+148
drivers/gpu/drm/amd/display/dc/dml/dml_common_defs.c
··· 1 + /* 2 + * Copyright 2017 Advanced Micro Devices, Inc. 3 + * 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: 10 + * 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 13 + * 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. 21 + * 22 + * Authors: AMD 23 + * 24 + */ 25 + 26 + #include "dml_common_defs.h" 27 + #include "../calcs/dcn_calc_math.h" 28 + 29 + double dml_min(double a, double b) 30 + { 31 + return (double) dcn_bw_min2(a, b); 32 + } 33 + 34 + double dml_max(double a, double b) 35 + { 36 + return (double) dcn_bw_max2(a, b); 37 + } 38 + 39 + double dml_ceil(double a) 40 + { 41 + return (double) dcn_bw_ceil2(a, 1); 42 + } 43 + 44 + double dml_floor(double a) 45 + { 46 + return (double) dcn_bw_floor2(a, 1); 47 + } 48 + 49 + double dml_round(double a) 50 + { 51 + double round_pt = 0.5; 52 + double ceil = dml_ceil(a); 53 + double floor = dml_floor(a); 54 + 55 + if (a - floor >= round_pt) 56 + return ceil; 57 + else 58 + return floor; 59 + } 60 + 61 + int dml_log2(double x) 62 + { 63 + return dml_round((double)dcn_bw_log(x, 2)); 64 + } 65 + 66 + double dml_pow(double a, int exp) 67 + { 68 + return (double) dcn_bw_pow(a, exp); 69 + } 70 + 71 + unsigned int dml_round_to_multiple( 72 + unsigned int num, 73 + unsigned int multiple, 74 + bool up) 75 + { 76 + unsigned int remainder; 77 + 78 + if (multiple == 0) 79 + return num; 80 + 81 + remainder = num % multiple; 82 + 83 + if (remainder == 0) 84 + return num; 85 + 86 + if (up) 87 + return (num + multiple - remainder); 88 + else 89 + return (num - remainder); 90 + } 91 + 92 + double dml_fmod(double f, int val) 93 + { 94 + return (double) dcn_bw_mod(f, val); 95 + } 96 + 97 + double dml_ceil_2(double f) 98 + { 99 + return (double) dcn_bw_ceil2(f, 2); 100 + } 101 + 102 + bool dml_util_is_420(enum source_format_class sorce_format) 103 + { 104 + bool val = false; 105 + 106 + switch (sorce_format) { 107 + case dm_444_16: 108 + val = false; 109 + break; 110 + case dm_444_32: 111 + val = false; 112 + break; 113 + case dm_444_64: 114 + val = false; 115 + break; 116 + case dm_420_8: 117 + val = true; 118 + break; 119 + case dm_420_10: 120 + val = true; 121 + break; 122 + case dm_422_8: 123 + val = false; 124 + break; 125 + case dm_422_10: 126 + val = false; 127 + break; 128 + default: 129 + BREAK_TO_DEBUGGER(); 130 + } 131 + 132 + return val; 133 + } 134 + 135 + double dml_ceil_ex(double x, double granularity) 136 + { 137 + return (double) dcn_bw_ceil2(x, granularity); 138 + } 139 + 140 + double dml_floor_ex(double x, double granularity) 141 + { 142 + return (double) dcn_bw_floor2(x, granularity); 143 + } 144 + 145 + double dml_log(double x, double base) 146 + { 147 + return (double) dcn_bw_log(x, base); 148 + }
+51
drivers/gpu/drm/amd/display/dc/dml/dml_common_defs.h
··· 1 + /* 2 + * Copyright 2017 Advanced Micro Devices, Inc. 3 + * 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: 10 + * 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 13 + * 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. 21 + * 22 + * Authors: AMD 23 + * 24 + */ 25 + #ifndef __DC_COMMON_DEFS_H__ 26 + #define __DC_COMMON_DEFS_H__ 27 + 28 + #include "dm_services.h" 29 + #include "dc_features.h" 30 + #include "display_mode_structs.h" 31 + #include "display_mode_enums.h" 32 + 33 + #define DTRACE(str, ...) dm_logger_write(mode_lib->logger, LOG_DML, str, ##__VA_ARGS__); 34 + 35 + double dml_min(double a, double b); 36 + double dml_max(double a, double b); 37 + bool dml_util_is_420(enum source_format_class sorce_format); 38 + double dml_ceil_ex(double x, double granularity); 39 + double dml_floor_ex(double x, double granularity); 40 + double dml_log(double x, double base); 41 + double dml_ceil(double a); 42 + double dml_floor(double a); 43 + double dml_round(double a); 44 + int dml_log2(double x); 45 + double dml_pow(double a, int exp); 46 + unsigned int dml_round_to_multiple( 47 + unsigned int num, unsigned int multiple, bool up); 48 + double dml_fmod(double f, int val); 49 + double dml_ceil_2(double f); 50 + 51 + #endif /* __DC_COMMON_DEFS_H__ */
+73
drivers/gpu/drm/amd/display/dc/dml/soc_bounding_box.c
··· 1 + /* 2 + * Copyright 2017 Advanced Micro Devices, Inc. 3 + * 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: 10 + * 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 13 + * 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. 21 + * 22 + * Authors: AMD 23 + * 24 + */ 25 + #include "soc_bounding_box.h" 26 + #include "display_mode_lib.h" 27 + 28 + void dml_socbb_set_latencies( 29 + struct display_mode_lib *mode_lib, 30 + struct _vcs_dpi_soc_bounding_box_st *from_box) 31 + { 32 + struct _vcs_dpi_soc_bounding_box_st *to_box = &mode_lib->soc; 33 + 34 + to_box->dram_clock_change_latency_us = from_box->dram_clock_change_latency_us; 35 + to_box->sr_exit_time_us = from_box->sr_exit_time_us; 36 + to_box->sr_enter_plus_exit_time_us = from_box->sr_enter_plus_exit_time_us; 37 + to_box->urgent_latency_us = from_box->urgent_latency_us; 38 + to_box->writeback_latency_us = from_box->writeback_latency_us; 39 + DTRACE("box.dram_clock_change_latency_us: %f", from_box->dram_clock_change_latency_us); 40 + DTRACE("box.sr_exit_time_us: %f", from_box->sr_exit_time_us); 41 + DTRACE("box.sr_enter_plus_exit_time_us: %f", from_box->sr_enter_plus_exit_time_us); 42 + DTRACE("box.urgent_latency_us: %f", from_box->urgent_latency_us); 43 + DTRACE("box.writeback_latency_us: %f", from_box->writeback_latency_us); 44 + 45 + } 46 + 47 + struct _vcs_dpi_voltage_scaling_st dml_socbb_voltage_scaling( 48 + struct _vcs_dpi_soc_bounding_box_st *box, 49 + enum voltage_state voltage) 50 + { 51 + switch (voltage) { 52 + case dm_vmin: 53 + return box->vmin; 54 + case dm_vnom: 55 + return box->vnom; 56 + case dm_vmax: 57 + default: 58 + return box->vmax; 59 + } 60 + } 61 + 62 + double dml_socbb_return_bw_mhz(struct _vcs_dpi_soc_bounding_box_st *box, enum voltage_state voltage) 63 + { 64 + double return_bw; 65 + 66 + struct _vcs_dpi_voltage_scaling_st state = dml_socbb_voltage_scaling(box, voltage); 67 + 68 + return_bw = dml_min( 69 + ((double) box->return_bus_width_bytes) * state.dcfclk_mhz, 70 + state.dram_bw_per_chan_gbps * 1000.0 * (double) box->num_chans 71 + * box->ideal_dram_bw_after_urgent_percent / 100.0); 72 + return return_bw; 73 + }
+36
drivers/gpu/drm/amd/display/dc/dml/soc_bounding_box.h
··· 1 + /* 2 + * Copyright 2017 Advanced Micro Devices, Inc. 3 + * 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: 10 + * 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 13 + * 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. 21 + * 22 + * Authors: AMD 23 + * 24 + */ 25 + #ifndef __SOC_BOUNDING_BOX_H__ 26 + #define __SOC_BOUNDING_BOX_H__ 27 + 28 + #include "dml_common_defs.h" 29 + 30 + struct display_mode_lib; 31 + 32 + void dml_socbb_set_latencies(struct display_mode_lib *mode_lib, struct _vcs_dpi_soc_bounding_box_st *from_box); 33 + struct _vcs_dpi_voltage_scaling_st dml_socbb_voltage_scaling(struct _vcs_dpi_soc_bounding_box_st *box, enum voltage_state voltage); 34 + double dml_socbb_return_bw_mhz(struct _vcs_dpi_soc_bounding_box_st *box, enum voltage_state voltage); 35 + 36 + #endif