| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003-2012, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: bvdc_bufferheap_priv.h $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/22 $ |
|---|
| 12 | * $brcm_Date: 1/12/12 4:34p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/portinginterface/vdc/7038/bvdc_bufferheap_priv.h $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/22 1/12/12 4:34p yuxiaz |
|---|
| 21 | * SW7552-181: Adjust buffer size based on alignment. |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/21 4/19/10 10:11p tdo |
|---|
| 24 | * SW3548-2814: Improvements to VDC ulBlackMagic. Move |
|---|
| 25 | * BDBG_OBJECT_ID_DECLARE private header files instead of .c. |
|---|
| 26 | * |
|---|
| 27 | * Hydra_Software_Devel/20 4/7/10 11:26a tdo |
|---|
| 28 | * SW3548-2814: Improvements to VDC ulBlackMagic. Rename TLA |
|---|
| 29 | * |
|---|
| 30 | * Hydra_Software_Devel/19 4/5/10 3:58p tdo |
|---|
| 31 | * SW3548-2814: Improvements to VDC ulBlackMagic |
|---|
| 32 | * |
|---|
| 33 | * Hydra_Software_Devel/18 6/4/09 2:00p yuxiaz |
|---|
| 34 | * PR55330, PR55323, PR53197, PR55158, PR55604: Need to use separate CAP |
|---|
| 35 | * and VFD buffers in ANR when DCX is enabled. |
|---|
| 36 | * |
|---|
| 37 | * Hydra_Software_Devel/17 10/30/07 7:10p pntruong |
|---|
| 38 | * PR34239: Allow dynamically loading of vec custom timing. |
|---|
| 39 | * |
|---|
| 40 | * Hydra_Software_Devel/16 7/27/07 9:32a yuxiaz |
|---|
| 41 | * PR32421: VDC Should Compute the Heap Size Needed for MAD and ANR for |
|---|
| 42 | * Various Sources. |
|---|
| 43 | * |
|---|
| 44 | * Hydra_Software_Devel/15 1/24/07 9:05p albertl |
|---|
| 45 | * PR22237: Updated BMEM calls to use new BMEM_Heap functions. |
|---|
| 46 | * |
|---|
| 47 | * Hydra_Software_Devel/14 12/18/06 11:36p pntruong |
|---|
| 48 | * PR22577: Merged back to mainline. |
|---|
| 49 | * |
|---|
| 50 | * Hydra_Software_Devel/Refsw_Devel_3563/5 10/26/06 3:17p yuxiaz |
|---|
| 51 | * PR25181: Merge in fix from main branch: VDC Buffer Allocation Fragments |
|---|
| 52 | * HD Buffer Pool and Causes Out of Memory Assertion. |
|---|
| 53 | * |
|---|
| 54 | * Hydra_Software_Devel/Refsw_Devel_3563/4 9/27/06 12:01p yuxiaz |
|---|
| 55 | * PR20875: Use best fit search to get buffer heap id. Integrate with |
|---|
| 56 | * dynamic buffer allocation. |
|---|
| 57 | * |
|---|
| 58 | * Hydra_Software_Devel/Refsw_Devel_3563/3 9/21/06 9:44a yuxiaz |
|---|
| 59 | * PR20875: Integrate buffer heap with pixel format in BVDC_Heap_Settings. |
|---|
| 60 | * |
|---|
| 61 | * Hydra_Software_Devel/Refsw_Devel_3563/2 9/20/06 12:54p pntruong |
|---|
| 62 | * PR23222, PR23225: Defer window and source heap assignments until user |
|---|
| 63 | * create. |
|---|
| 64 | * |
|---|
| 65 | * Hydra_Software_Devel/Refsw_Devel_3563/1 9/19/06 10:34p pntruong |
|---|
| 66 | * PR23222, PR23225: Fixed compile errors for heap based created. |
|---|
| 67 | * |
|---|
| 68 | * Hydra_Software_Devel/12 8/10/06 2:27p yuxiaz |
|---|
| 69 | * PR20875: Consolidate BVN pixel format to support 10 bit 444 bvn path. |
|---|
| 70 | * |
|---|
| 71 | * Hydra_Software_Devel/11 4/26/06 1:51p yuxiaz |
|---|
| 72 | * PR20598: Allocate continous nodes from child node list. |
|---|
| 73 | * |
|---|
| 74 | * Hydra_Software_Devel/10 4/24/06 4:04p yuxiaz |
|---|
| 75 | * PR15161: Fixed VDC _isr naming violations in bvdc_buffer_priv.c and |
|---|
| 76 | * bvdc_bufferheap_priv.c. |
|---|
| 77 | * |
|---|
| 78 | * Hydra_Software_Devel/9 4/14/06 2:31p yuxiaz |
|---|
| 79 | * PR20598: Add support to break larger buffer into smaller buffers in |
|---|
| 80 | * VDC. |
|---|
| 81 | * |
|---|
| 82 | * Hydra_Software_Devel/8 3/28/06 1:23p yuxiaz |
|---|
| 83 | * PR20344: Added double HD buffer support in VDC. |
|---|
| 84 | * |
|---|
| 85 | * Hydra_Software_Devel/7 11/2/05 9:58a jessem |
|---|
| 86 | * PR 17395: Added support for SD Pip buffer use. |
|---|
| 87 | * |
|---|
| 88 | * Hydra_Software_Devel/6 8/18/05 1:12p pntruong |
|---|
| 89 | * PR15757, PR16391, PR16411, PR12519, PR14791, PR15535, PR15206, PR15778: |
|---|
| 90 | * Improved bandwidth for cropping/scaler/capture/playback. Unified |
|---|
| 91 | * window shutdown sequence for destroy, reconfigure mad/scaler, and/or |
|---|
| 92 | * reconfigure result of source changes. And miscellances fixes from |
|---|
| 93 | * above PRs. |
|---|
| 94 | * |
|---|
| 95 | * Hydra_Software_Devel/XVDPhase1/1 6/30/05 2:44p pntruong |
|---|
| 96 | * PR15284: Used the recommended 32-byte align pitch/stride for optimal |
|---|
| 97 | * memory bandwidth utilization. |
|---|
| 98 | * |
|---|
| 99 | * Hydra_Software_Devel/5 4/1/05 5:13p pntruong |
|---|
| 100 | * PR14686: Refresh mad mstart addresses on re-enable and fixed vdec 3d |
|---|
| 101 | * comb mstart alignment. |
|---|
| 102 | * |
|---|
| 103 | * Hydra_Software_Devel/4 1/6/05 2:09p yuxiaz |
|---|
| 104 | * PR13313: Added HD PIP buffer support in VDC. |
|---|
| 105 | * |
|---|
| 106 | * Hydra_Software_Devel/3 12/15/04 3:26p yuxiaz |
|---|
| 107 | * PR13569: Add support for syncronization with XVD for HD_DVI. More work |
|---|
| 108 | * needed. |
|---|
| 109 | * |
|---|
| 110 | * Hydra_Software_Devel/2 12/1/04 4:24p yuxiaz |
|---|
| 111 | * PR10855: Add support to use HD buffers for SD. |
|---|
| 112 | * |
|---|
| 113 | * Hydra_Software_Devel/1 11/19/04 2:40p yuxiaz |
|---|
| 114 | * PR 10855: Initial revision. |
|---|
| 115 | * |
|---|
| 116 | * |
|---|
| 117 | ***************************************************************************/ |
|---|
| 118 | #ifndef BVDC_BUFFERHEAP_PRIV_H__ |
|---|
| 119 | #define BVDC_BUFFERHEAP_PRIV_H__ |
|---|
| 120 | |
|---|
| 121 | #include "bvdc.h" |
|---|
| 122 | #include "blst_queue.h" |
|---|
| 123 | #include "bvdc_common_priv.h" |
|---|
| 124 | |
|---|
| 125 | #ifdef __cplusplus |
|---|
| 126 | extern "C" { |
|---|
| 127 | #endif |
|---|
| 128 | |
|---|
| 129 | BDBG_OBJECT_ID_DECLARE(BVDC_VDC); |
|---|
| 130 | |
|---|
| 131 | /*************************************************************************** |
|---|
| 132 | * Private macros |
|---|
| 133 | ***************************************************************************/ |
|---|
| 134 | #define BVDC_P_BUFFERHEAP_HEAP_IS_2HD(eBufHeapId) \ |
|---|
| 135 | (eBufHeapId == BVDC_P_BufferHeapId_e2HD) |
|---|
| 136 | |
|---|
| 137 | #define BVDC_P_BUFFERHEAP_HEAP_IS_HD(eBufHeapId) \ |
|---|
| 138 | (eBufHeapId == BVDC_P_BufferHeapId_eHD) |
|---|
| 139 | |
|---|
| 140 | #define BVDC_P_BUFFERHEAP_HEAP_IS_SD(eBufHeapId) \ |
|---|
| 141 | (eBufHeapId == BVDC_P_BufferHeapId_eSD) |
|---|
| 142 | |
|---|
| 143 | #define BVDC_P_BUFFERHEAP_HEAP_IS_2HD_PIP(eBufHeapId) \ |
|---|
| 144 | (eBufHeapId == BVDC_P_BufferHeapId_e2HD_Pip) |
|---|
| 145 | |
|---|
| 146 | #define BVDC_P_BUFFERHEAP_HEAP_IS_HD_PIP(eBufHeapId) \ |
|---|
| 147 | (eBufHeapId == BVDC_P_BufferHeapId_eHD_Pip) |
|---|
| 148 | |
|---|
| 149 | #define BVDC_P_BUFFERHEAP_HEAP_IS_SD_PIP(eBufHeapId) \ |
|---|
| 150 | (eBufHeapId == BVDC_P_BufferHeapId_eSD_Pip) |
|---|
| 151 | |
|---|
| 152 | #define BVDC_P_BUFFERHEAP_GET_HEAP_ID_NAME(eBufHeapId) \ |
|---|
| 153 | BVDC_P_BUFFERHEAP_HEAP_IS_2HD(eBufHeapId) ? "2HD" : \ |
|---|
| 154 | BVDC_P_BUFFERHEAP_HEAP_IS_HD(eBufHeapId) ? "HD" : \ |
|---|
| 155 | BVDC_P_BUFFERHEAP_HEAP_IS_SD(eBufHeapId) ? "SD" : \ |
|---|
| 156 | BVDC_P_BUFFERHEAP_HEAP_IS_2HD_PIP(eBufHeapId) ? "2HD_Pip" : \ |
|---|
| 157 | BVDC_P_BUFFERHEAP_HEAP_IS_HD_PIP(eBufHeapId) ? "HD_Pip" : \ |
|---|
| 158 | BVDC_P_BUFFERHEAP_HEAP_IS_SD_PIP(eBufHeapId) ? "SD_Pip" : "Unknown" |
|---|
| 159 | |
|---|
| 160 | |
|---|
| 161 | #define BVDC_P_BUFFERHEAP_GetDeviceOffset(pHeapNode) \ |
|---|
| 162 | pHeapNode->ulDeviceOffset |
|---|
| 163 | |
|---|
| 164 | /*************************************************************************** |
|---|
| 165 | * Internal defines |
|---|
| 166 | ***************************************************************************/ |
|---|
| 167 | #define BVDC_P_HEAP_MEMORY_ALIGNMENT (8) |
|---|
| 168 | #define BVDC_P_HEAP_ALIGN_BYTES (256) |
|---|
| 169 | |
|---|
| 170 | |
|---|
| 171 | /*************************************************************************** |
|---|
| 172 | * Enums |
|---|
| 173 | ***************************************************************************/ |
|---|
| 174 | typedef enum BVDC_P_BufferHeapId |
|---|
| 175 | { |
|---|
| 176 | BVDC_P_BufferHeapId_eSD = 0, |
|---|
| 177 | BVDC_P_BufferHeapId_eHD, |
|---|
| 178 | BVDC_P_BufferHeapId_e2HD, |
|---|
| 179 | BVDC_P_BufferHeapId_eSD_Pip, |
|---|
| 180 | BVDC_P_BufferHeapId_eHD_Pip, |
|---|
| 181 | BVDC_P_BufferHeapId_e2HD_Pip, |
|---|
| 182 | |
|---|
| 183 | BVDC_P_BufferHeapId_eCount, /* Counter. Do not use! */ |
|---|
| 184 | BVDC_P_BufferHeapId_eUnknown |
|---|
| 185 | |
|---|
| 186 | } BVDC_P_BufferHeapId; |
|---|
| 187 | |
|---|
| 188 | /*************************************************************************** |
|---|
| 189 | * BVDC_P_BufferHeap_Head |
|---|
| 190 | ***************************************************************************/ |
|---|
| 191 | typedef struct BVDC_P_BufferHeap_Head BVDC_P_BufferHeap_Head; |
|---|
| 192 | BLST_Q_HEAD(BVDC_P_BufferHeap_Head, BVDC_P_BufferHeapNode); |
|---|
| 193 | |
|---|
| 194 | |
|---|
| 195 | /*************************************************************************** |
|---|
| 196 | * BVDC_P_BufferHeapNode |
|---|
| 197 | ***************************************************************************/ |
|---|
| 198 | typedef struct BVDC_P_BufferHeapNode |
|---|
| 199 | { |
|---|
| 200 | /* Node info: linked-list bookeeping */ |
|---|
| 201 | BLST_Q_ENTRY(BVDC_P_BufferHeapNode) link; |
|---|
| 202 | |
|---|
| 203 | BVDC_P_HeapInfoPtr pHeapInfo; /* heap the node belongs to */ |
|---|
| 204 | |
|---|
| 205 | void *pvBufAddr; /* Virtual address */ |
|---|
| 206 | uint32_t ulDeviceOffset; /* Device offset */ |
|---|
| 207 | uint32_t ulBufIndex; /* index to heap's bufferlist */ |
|---|
| 208 | BVDC_P_BufferHeapId eOrigBufHeapId; /* which buffer the node comes from */ |
|---|
| 209 | bool bUsed; /* node is used or not */ |
|---|
| 210 | bool bContinous; /* continuous with prev node in bufferlist */ |
|---|
| 211 | |
|---|
| 212 | BVDC_P_HeapNodePtr pParentNode; /* parent node */ |
|---|
| 213 | BVDC_P_HeapNodePtr pFirstChildNode; /* first child node */ |
|---|
| 214 | uint32_t ulNumChildNodeUsed; /* num of child nodes used */ |
|---|
| 215 | |
|---|
| 216 | } BVDC_P_BufferHeapNode; |
|---|
| 217 | |
|---|
| 218 | |
|---|
| 219 | /*************************************************************************** |
|---|
| 220 | * BVDC_P_BufferHeap_Info |
|---|
| 221 | ***************************************************************************/ |
|---|
| 222 | typedef struct BVDC_P_BufferHeap_Info |
|---|
| 223 | { |
|---|
| 224 | BVDC_P_BufferHeap_Handle hBufferHeap; |
|---|
| 225 | |
|---|
| 226 | /* Const properties */ |
|---|
| 227 | BVDC_P_BufferHeapId eBufHeapId; |
|---|
| 228 | uint32_t ulWidth; |
|---|
| 229 | uint32_t ulHeight; |
|---|
| 230 | /* real size including alignment */ |
|---|
| 231 | uint32_t ulBufSize; |
|---|
| 232 | /* size by format without alignment, only used to decide how to split buffers */ |
|---|
| 233 | uint32_t ulBufSizeByFmt; |
|---|
| 234 | uint32_t ulPrimaryBufCnt; |
|---|
| 235 | uint32_t ulTotalBufCnt; |
|---|
| 236 | uint32_t ulNodeCntPerParent; /* # nodes = 1 parent node */ |
|---|
| 237 | BVDC_P_HeapInfoPtr pParentHeapInfo; |
|---|
| 238 | BVDC_P_HeapInfoPtr pChildHeapInfo; |
|---|
| 239 | /* Virtual address of start of the primary heap */ |
|---|
| 240 | void *pvHeapStartAddr; |
|---|
| 241 | |
|---|
| 242 | BVDC_P_BufferHeap_Head *pBufList; |
|---|
| 243 | uint32_t ulBufUsed; |
|---|
| 244 | |
|---|
| 245 | } BVDC_P_BufferHeap_Info; |
|---|
| 246 | |
|---|
| 247 | |
|---|
| 248 | /*************************************************************************** |
|---|
| 249 | * BVDC_P_BufferHeapContext |
|---|
| 250 | ***************************************************************************/ |
|---|
| 251 | typedef struct BVDC_P_BufferHeapContext |
|---|
| 252 | { |
|---|
| 253 | BDBG_OBJECT(BVDC_BFH) |
|---|
| 254 | |
|---|
| 255 | /* Handed down by created */ |
|---|
| 256 | BVDC_Handle hVdc; /* Created from this Vdc */ |
|---|
| 257 | BMEM_Heap_Handle hMem; /* corresponding heap. */ |
|---|
| 258 | |
|---|
| 259 | /* Heap Settings */ |
|---|
| 260 | BVDC_Heap_Settings stSettings; |
|---|
| 261 | |
|---|
| 262 | /* Heapsize of the different flavorites of buffers. */ |
|---|
| 263 | uint32_t aulHeapSize[BVDC_P_BufferHeapId_eCount]; |
|---|
| 264 | |
|---|
| 265 | /* Index of astHeapInfo by BVDC_P_BufferHeapId */ |
|---|
| 266 | uint32_t aulIndex[BVDC_P_BufferHeapId_eCount]; |
|---|
| 267 | BVDC_P_BufferHeap_Info astHeapInfo[BVDC_P_BufferHeapId_eCount]; |
|---|
| 268 | |
|---|
| 269 | } BVDC_P_BufferHeapContext; |
|---|
| 270 | |
|---|
| 271 | |
|---|
| 272 | /*************************************************************************** |
|---|
| 273 | * Memory private functions |
|---|
| 274 | ***************************************************************************/ |
|---|
| 275 | BERR_Code BVDC_P_BufferHeap_Create |
|---|
| 276 | ( const BVDC_Handle hVdc, |
|---|
| 277 | BVDC_Heap_Handle *phHeap, |
|---|
| 278 | BMEM_Heap_Handle hMem, |
|---|
| 279 | const BVDC_Heap_Settings *pSettings ); |
|---|
| 280 | |
|---|
| 281 | BERR_Code BVDC_P_BufferHeap_Destroy |
|---|
| 282 | ( BVDC_P_BufferHeap_Handle hBufferHeap ); |
|---|
| 283 | |
|---|
| 284 | void BVDC_P_BufferHeap_Init |
|---|
| 285 | ( BVDC_P_BufferHeap_Handle hBufferHeap ); |
|---|
| 286 | |
|---|
| 287 | BERR_Code BVDC_P_BufferHeap_AllocateBuffers_isr |
|---|
| 288 | ( BVDC_P_BufferHeap_Handle hBufferHeap, |
|---|
| 289 | BVDC_P_HeapNodePtr apHeapNode[], |
|---|
| 290 | uint32_t ulCount, |
|---|
| 291 | bool bContinuous, |
|---|
| 292 | BVDC_P_BufferHeapId eBufferHeapId, |
|---|
| 293 | BVDC_P_BufferHeapId eBufferHeapIdPrefer ); |
|---|
| 294 | |
|---|
| 295 | BERR_Code BVDC_P_BufferHeap_FreeBuffers_isr |
|---|
| 296 | ( BVDC_P_BufferHeap_Handle hBufferHeap, |
|---|
| 297 | BVDC_P_HeapNodePtr apHeapNode[], |
|---|
| 298 | uint32_t ulCount, |
|---|
| 299 | bool bContinuous ); |
|---|
| 300 | |
|---|
| 301 | uint32_t BVDC_P_BufferHeap_GetHeapSize |
|---|
| 302 | ( const BFMT_VideoInfo *pFmtInfo, |
|---|
| 303 | BPXL_Format ePixelFmt, |
|---|
| 304 | uint32_t ulAdditionalLines, |
|---|
| 305 | bool bPip, |
|---|
| 306 | uint32_t *pulUnalignedBufSize, |
|---|
| 307 | uint32_t *pulWidth, |
|---|
| 308 | uint32_t *pulHeight ); |
|---|
| 309 | |
|---|
| 310 | void BVDC_P_BufferHeap_GetHeapIdBySize |
|---|
| 311 | ( const BVDC_P_BufferHeapContext *pHeap, |
|---|
| 312 | uint32_t ulSize, |
|---|
| 313 | BVDC_P_BufferHeapId *peBufHeapId ); |
|---|
| 314 | |
|---|
| 315 | void BVDC_P_BufferHeap_GetHeapSizeById |
|---|
| 316 | ( const BVDC_P_BufferHeapContext *pHeap, |
|---|
| 317 | BVDC_P_BufferHeapId eBufHeapId, |
|---|
| 318 | uint32_t *pulBufHeapSize ); |
|---|
| 319 | |
|---|
| 320 | #ifdef __cplusplus |
|---|
| 321 | } |
|---|
| 322 | #endif |
|---|
| 323 | |
|---|
| 324 | #endif /* #ifndef BVDC_BUFFERHEAP_PRIV_H__*/ |
|---|
| 325 | |
|---|
| 326 | /* End of file. */ |
|---|