2 * Copyright © 2014 Advanced Micro Devices, Inc.
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sub license, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16 * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
17 * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 * USE OR OTHER DEALINGS IN THE SOFTWARE.
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
28 ***************************************************************************************************
30 * @brief Contains the R800AddrLib class definition.
31 ***************************************************************************************************
34 #ifndef __SI_ADDR_LIB_H__
35 #define __SI_ADDR_LIB_H__
38 #include "egbaddrlib.h"
41 ***************************************************************************************************
42 * @brief Describes the information in tile mode table
43 ***************************************************************************************************
53 ***************************************************************************************************
54 * @brief SI specific settings structure.
55 ***************************************************************************************************
61 UINT_32 isSouthernIsland
: 1;
63 UINT_32 isPitCairn
: 1;
64 UINT_32 isCapeVerde
: 1;
65 /// Oland/Hainan are of GFXIP 6.0, similar with SI
72 ***************************************************************************************************
73 * @brief This class is the SI specific address library
75 ***************************************************************************************************
77 class SiAddrLib
: public EgBasedAddrLib
80 /// Creates SIAddrLib object
81 static AddrLib
* CreateObj(const AddrClient
* pClient
)
83 return new(pClient
) SiAddrLib(pClient
);
87 SiAddrLib(const AddrClient
* pClient
);
90 // Hwl interface - defined in AddrLib1
91 virtual ADDR_E_RETURNCODE
HwlComputeSurfaceInfo(
92 const ADDR_COMPUTE_SURFACE_INFO_INPUT
* pIn
,
93 ADDR_COMPUTE_SURFACE_INFO_OUTPUT
* pOut
) const;
95 virtual ADDR_E_RETURNCODE
HwlConvertTileInfoToHW(
96 const ADDR_CONVERT_TILEINFOTOHW_INPUT
* pIn
,
97 ADDR_CONVERT_TILEINFOTOHW_OUTPUT
* pOut
) const;
99 virtual UINT_64
HwlComputeXmaskAddrFromCoord(
100 UINT_32 pitch
, UINT_32 height
, UINT_32 x
, UINT_32 y
, UINT_32 slice
, UINT_32 numSlices
,
101 UINT_32 factor
, BOOL_32 isLinear
, BOOL_32 isWidth8
, BOOL_32 isHeight8
,
102 ADDR_TILEINFO
* pTileInfo
, UINT_32
* pBitPosition
) const;
104 virtual VOID
HwlComputeXmaskCoordFromAddr(
105 UINT_64 addr
, UINT_32 bitPosition
, UINT_32 pitch
, UINT_32 height
, UINT_32 numSlices
,
106 UINT_32 factor
, BOOL_32 isLinear
, BOOL_32 isWidth8
, BOOL_32 isHeight8
,
107 ADDR_TILEINFO
* pTileInfo
, UINT_32
* pX
, UINT_32
* pY
, UINT_32
* pSlice
) const;
109 virtual ADDR_E_RETURNCODE
HwlGetTileIndex(
110 const ADDR_GET_TILEINDEX_INPUT
* pIn
,
111 ADDR_GET_TILEINDEX_OUTPUT
* pOut
) const;
113 virtual BOOL_32
HwlComputeMipLevel(
114 ADDR_COMPUTE_SURFACE_INFO_INPUT
* pIn
) const;
116 virtual AddrChipFamily
HwlConvertChipFamily(
117 UINT_32 uChipFamily
, UINT_32 uChipRevision
);
119 virtual BOOL_32
HwlInitGlobalParams(
120 const ADDR_CREATE_INPUT
* pCreateIn
);
122 virtual ADDR_E_RETURNCODE
HwlSetupTileCfg(
123 UINT_32 bpp
, INT_32 index
, INT_32 macroModeIndex
,
124 ADDR_TILEINFO
* pInfo
, AddrTileMode
* pMode
= 0, AddrTileType
* pType
= 0) const;
126 virtual VOID
HwlComputeTileDataWidthAndHeightLinear(
127 UINT_32
* pMacroWidth
, UINT_32
* pMacroHeight
,
128 UINT_32 bpp
, ADDR_TILEINFO
* pTileInfo
) const;
130 virtual UINT_64
HwlComputeHtileBytes(
131 UINT_32 pitch
, UINT_32 height
, UINT_32 bpp
,
132 BOOL_32 isLinear
, UINT_32 numSlices
, UINT_64
* pSliceBytes
, UINT_32 baseAlign
) const;
134 virtual ADDR_E_RETURNCODE
ComputeBankEquation(
135 UINT_32 log2BytesPP
, UINT_32 threshX
, UINT_32 threshY
,
136 ADDR_TILEINFO
* pTileInfo
, ADDR_EQUATION
* pEquation
) const;
138 virtual ADDR_E_RETURNCODE
ComputePipeEquation(
139 UINT_32 log2BytesPP
, UINT_32 threshX
, UINT_32 threshY
,
140 ADDR_TILEINFO
* pTileInfo
, ADDR_EQUATION
* pEquation
) const;
142 virtual UINT_32
ComputePipeFromCoord(
143 UINT_32 x
, UINT_32 y
, UINT_32 slice
,
144 AddrTileMode tileMode
, UINT_32 pipeSwizzle
, BOOL_32 ignoreSE
,
145 ADDR_TILEINFO
* pTileInfo
) const;
147 virtual UINT_32
HwlGetPipes(const ADDR_TILEINFO
* pTileInfo
) const;
149 /// Pre-handler of 3x pitch (96 bit) adjustment
150 virtual UINT_32
HwlPreHandleBaseLvl3xPitch(
151 const ADDR_COMPUTE_SURFACE_INFO_INPUT
* pIn
, UINT_32 expPitch
) const;
152 /// Post-handler of 3x pitch adjustment
153 virtual UINT_32
HwlPostHandleBaseLvl3xPitch(
154 const ADDR_COMPUTE_SURFACE_INFO_INPUT
* pIn
, UINT_32 expPitch
) const;
156 /// Dummy function to finalize the inheritance
157 virtual UINT_32
HwlComputeXmaskCoordYFrom8Pipe(
158 UINT_32 pipe
, UINT_32 x
) const;
160 // Sub-hwl interface - defined in EgBasedAddrLib
161 virtual VOID
HwlSetupTileInfo(
162 AddrTileMode tileMode
, ADDR_SURFACE_FLAGS flags
,
163 UINT_32 bpp
, UINT_32 pitch
, UINT_32 height
, UINT_32 numSamples
,
164 ADDR_TILEINFO
* inputTileInfo
, ADDR_TILEINFO
* outputTileInfo
,
165 AddrTileType inTileType
, ADDR_COMPUTE_SURFACE_INFO_OUTPUT
* pOut
) const;
167 virtual UINT_32
HwlGetPitchAlignmentMicroTiled(
168 AddrTileMode tileMode
, UINT_32 bpp
, ADDR_SURFACE_FLAGS flags
, UINT_32 numSamples
) const;
170 virtual UINT_64
HwlGetSizeAdjustmentMicroTiled(
171 UINT_32 thickness
, UINT_32 bpp
, ADDR_SURFACE_FLAGS flags
, UINT_32 numSamples
,
172 UINT_32 baseAlign
, UINT_32 pitchAlign
,
173 UINT_32
*pPitch
, UINT_32
*pHeight
) const;
175 virtual VOID
HwlCheckLastMacroTiledLvl(
176 const ADDR_COMPUTE_SURFACE_INFO_INPUT
* pIn
, ADDR_COMPUTE_SURFACE_INFO_OUTPUT
* pOut
) const;
178 virtual BOOL_32
HwlTileInfoEqual(
179 const ADDR_TILEINFO
* pLeft
, const ADDR_TILEINFO
* pRight
) const;
181 virtual AddrTileMode
HwlDegradeThickTileMode(
182 AddrTileMode baseTileMode
, UINT_32 numSlices
, UINT_32
* pBytesPerTile
) const;
184 virtual VOID
HwlOverrideTileMode(ADDR_COMPUTE_SURFACE_INFO_INPUT
* pInOut
) const;
186 virtual BOOL_32
HwlSanityCheckMacroTiled(
187 ADDR_TILEINFO
* pTileInfo
) const
192 virtual UINT_32
HwlGetPitchAlignmentLinear(UINT_32 bpp
, ADDR_SURFACE_FLAGS flags
) const;
194 virtual UINT_64
HwlGetSizeAdjustmentLinear(
195 AddrTileMode tileMode
,
196 UINT_32 bpp
, UINT_32 numSamples
, UINT_32 baseAlign
, UINT_32 pitchAlign
,
197 UINT_32
*pPitch
, UINT_32
*pHeight
, UINT_32
*pHeightAlign
) const;
199 virtual VOID
HwlComputeSurfaceCoord2DFromBankPipe(
200 AddrTileMode tileMode
, UINT_32
* pX
, UINT_32
* pY
, UINT_32 slice
,
201 UINT_32 bank
, UINT_32 pipe
,
202 UINT_32 bankSwizzle
, UINT_32 pipeSwizzle
, UINT_32 tileSlices
,
204 ADDR_TILEINFO
* pTileInfo
) const;
206 virtual UINT_32
HwlPreAdjustBank(
207 UINT_32 tileX
, UINT_32 bank
, ADDR_TILEINFO
* pTileInfo
) const;
209 virtual INT_32
HwlPostCheckTileIndex(
210 const ADDR_TILEINFO
* pInfo
, AddrTileMode mode
, AddrTileType type
,
211 INT curIndex
= TileIndexInvalid
) const;
213 virtual VOID
HwlFmaskPreThunkSurfInfo(
214 const ADDR_COMPUTE_FMASK_INFO_INPUT
* pFmaskIn
,
215 const ADDR_COMPUTE_FMASK_INFO_OUTPUT
* pFmaskOut
,
216 ADDR_COMPUTE_SURFACE_INFO_INPUT
* pSurfIn
,
217 ADDR_COMPUTE_SURFACE_INFO_OUTPUT
* pSurfOut
) const;
219 virtual VOID
HwlFmaskPostThunkSurfInfo(
220 const ADDR_COMPUTE_SURFACE_INFO_OUTPUT
* pSurfOut
,
221 ADDR_COMPUTE_FMASK_INFO_OUTPUT
* pFmaskOut
) const;
223 virtual UINT_32
HwlComputeFmaskBits(
224 const ADDR_COMPUTE_FMASK_INFO_INPUT
* pIn
,
225 UINT_32
* pNumSamples
) const;
227 virtual BOOL_32
HwlReduceBankWidthHeight(
228 UINT_32 tileSize
, UINT_32 bpp
, ADDR_SURFACE_FLAGS flags
, UINT_32 numSamples
,
229 UINT_32 bankHeightAlign
, UINT_32 pipes
,
230 ADDR_TILEINFO
* pTileInfo
) const
235 virtual ADDR_E_RETURNCODE
HwlGetMaxAlignments(ADDR_GET_MAX_ALINGMENTS_OUTPUT
* pOut
) const;
237 // Get equation table pointer and number of equations
238 virtual UINT_32
HwlGetEquationTableInfo(const ADDR_EQUATION
** ppEquationTable
) const
240 *ppEquationTable
= m_equationTable
;
242 return m_numEquations
;
245 // Check if it is supported for given bpp and tile config to generate an equation
246 BOOL_32
IsEquationSupported(
247 UINT_32 bpp
, AddrTileConfig tileConfig
, INT_32 tileIndex
) const;
249 // Protected non-virtual functions
250 VOID
ComputeTileCoordFromPipeAndElemIdx(
251 UINT_32 elemIdx
, UINT_32 pipe
, AddrPipeCfg pipeCfg
, UINT_32 pitchInMacroTile
,
252 UINT_32 x
, UINT_32 y
, UINT_32
* pX
, UINT_32
* pY
) const;
254 UINT_32
TileCoordToMaskElementIndex(
255 UINT_32 tx
, UINT_32 ty
, AddrPipeCfg pipeConfig
,
256 UINT_32
*macroShift
, UINT_32
*elemIdxBits
) const;
258 BOOL_32
DecodeGbRegs(
259 const ADDR_REGISTER_VALUE
* pRegValue
);
261 const AddrTileConfig
* GetTileSetting(
262 UINT_32 index
) const;
264 // Initialize equation table
265 VOID
InitEquationTable();
267 static const UINT_32 TileTableSize
= 32;
268 AddrTileConfig m_tileTable
[TileTableSize
];
269 UINT_32 m_noOfEntries
;
271 // Max number of bpp (8bpp/16bpp/32bpp/64bpp/128bpp)
272 static const UINT_32 MaxNumElementBytes
= 5;
273 // More than half slots in tile mode table can't support equation
274 static const UINT_32 EquationTableSize
= (MaxNumElementBytes
* TileTableSize
) / 2;
276 ADDR_EQUATION m_equationTable
[EquationTableSize
];
277 UINT_32 m_blockWidth
[EquationTableSize
];
278 UINT_32 m_blockHeight
[EquationTableSize
];
279 UINT_32 m_blockSlices
[EquationTableSize
];
280 // Number of equation entries in the table
281 UINT_32 m_numEquations
;
282 // Equation lookup table according to bpp and tile index
283 UINT_32 m_equationLookupTable
[MaxNumElementBytes
][TileTableSize
];
287 UINT_32
GetPipePerSurf(AddrPipeCfg pipeConfig
) const;
290 UINT_32 regValue
, AddrTileConfig
* pCfg
) const;
291 BOOL_32
InitTileSettingTable(
292 const UINT_32
*pSetting
, UINT_32 noOfEntries
);
294 SIChipSettings m_settings
;