hfi_buffer_iris33.h 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2020-2022, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __HFI_BUFFER_IRIS3_3__
  7. #define __HFI_BUFFER_IRIS3_3__
  8. #include <linux/types.h>
  9. #include "hfi_property.h"
  10. typedef u8 HFI_U8;
  11. typedef s8 HFI_S8;
  12. typedef u16 HFI_U16;
  13. typedef s16 HFI_S16;
  14. typedef u32 HFI_U32;
  15. typedef s32 HFI_S32;
  16. typedef u64 HFI_U64;
  17. typedef HFI_U32 HFI_BOOL;
  18. #ifndef MIN
  19. #define MIN(x, y) (((x) < (y)) ? (x) : (y))
  20. #endif
  21. #ifndef MAX
  22. #define MAX(x, y) (((x) > (y)) ? (x) : (y))
  23. #endif
  24. #define HFI_ALIGNMENT_4096 (4096)
  25. #define BUF_SIZE_ALIGN_16 (16)
  26. #define BUF_SIZE_ALIGN_32 (32)
  27. #define BUF_SIZE_ALIGN_64 (64)
  28. #define BUF_SIZE_ALIGN_128 (128)
  29. #define BUF_SIZE_ALIGN_256 (256)
  30. #define BUF_SIZE_ALIGN_512 (512)
  31. #define BUF_SIZE_ALIGN_4096 (4096)
  32. #define HFI_ALIGN(a, b) (((b) & ((b) - 1)) ? (((a) + (b) - 1) / \
  33. (b) * (b)) : (((a) + (b) - 1) & (~((b) - 1))))
  34. #define HFI_WORKMODE_1 1
  35. #define HFI_WORKMODE_2 2
  36. #define HFI_DEFAULT_METADATA_STRIDE_MULTIPLE (64)
  37. #define HFI_DEFAULT_METADATA_BUFFERHEIGHT_MULTIPLE (16)
  38. #define HFI_COLOR_FORMAT_YUV420_NV12_UBWC_Y_TILE_HEIGHT (8)
  39. #define HFI_COLOR_FORMAT_YUV420_NV12_UBWC_Y_TILE_WIDTH (32)
  40. #define HFI_COLOR_FORMAT_YUV420_NV12_UBWC_UV_TILE_HEIGHT (8)
  41. #define HFI_COLOR_FORMAT_YUV420_NV12_UBWC_UV_TILE_WIDTH (16)
  42. #define HFI_COLOR_FORMAT_YUV420_TP10_UBWC_Y_TILE_HEIGHT (4)
  43. #define HFI_COLOR_FORMAT_YUV420_TP10_UBWC_Y_TILE_WIDTH (48)
  44. #define HFI_COLOR_FORMAT_YUV420_TP10_UBWC_UV_TILE_HEIGHT (4)
  45. #define HFI_COLOR_FORMAT_YUV420_TP10_UBWC_UV_TILE_WIDTH (24)
  46. #define HFI_COLOR_FORMAT_RGBA8888_UBWC_TILE_HEIGHT (4)
  47. #define HFI_COLOR_FORMAT_RGBA8888_UBWC_TILE_WIDTH (16)
  48. #define HFI_NV12_IL_CALC_Y_STRIDE(stride, frame_width, stride_multiple) \
  49. (stride = HFI_ALIGN(frame_width, stride_multiple))
  50. #define HFI_NV12_IL_CALC_Y_BUFHEIGHT(buf_height, frame_height, \
  51. min_buf_height_multiple) (buf_height = HFI_ALIGN(frame_height, \
  52. min_buf_height_multiple))
  53. #define HFI_NV12_IL_CALC_UV_STRIDE(stride, frame_width, stride_multiple) \
  54. stride = HFI_ALIGN(frame_width, stride_multiple)
  55. #define HFI_NV12_IL_CALC_UV_BUFHEIGHT(buf_height, frame_height, \
  56. min_buf_height_multiple) (buf_height = HFI_ALIGN(((frame_height + 1) \
  57. >> 1), min_buf_height_multiple))
  58. #define HFI_NV12_IL_CALC_BUF_SIZE(buf_size, y_bufSize, y_stride, y_buf_height, \
  59. uv_buf_size, uv_stride, uv_buf_height) \
  60. do { \
  61. y_bufSize = (y_stride * y_buf_height); \
  62. uv_buf_size = (uv_stride * uv_buf_height); \
  63. buf_size = HFI_ALIGN(y_bufSize + uv_buf_size, HFI_ALIGNMENT_4096) \
  64. } while (0)
  65. #define HFI_NV12_UBWC_IL_CALC_Y_BUF_SIZE(y_bufSize, y_stride, y_buf_height) \
  66. (y_bufSize = HFI_ALIGN(y_stride * y_buf_height, HFI_ALIGNMENT_4096))
  67. #define HFI_NV12_UBWC_IL_CALC_UV_BUF_SIZE(uv_buf_size, \
  68. uv_stride, uv_buf_height) \
  69. (uv_buf_size = HFI_ALIGN(uv_stride * uv_buf_height, HFI_ALIGNMENT_4096))
  70. #define HFI_NV12_UBWC_IL_CALC_BUF_SIZE_V2(buf_size,\
  71. frame_width, frame_height, y_stride_multiple,\
  72. y_buffer_height_multiple, uv_stride_multiple, \
  73. uv_buffer_height_multiple, y_metadata_stride_multiple, \
  74. y_metadata_buffer_height_multiple, \
  75. uv_metadata_stride_multiple, uv_metadata_buffer_height_multiple, binterlace) \
  76. do { \
  77. HFI_U32 y_buf_size, uv_buf_size, y_meta_size, uv_meta_size; \
  78. HFI_U32 stride, _height; \
  79. HFI_U32 half_height = (frame_height + 1) >> 1; \
  80. HFI_NV12_IL_CALC_Y_STRIDE(stride, frame_width,\
  81. y_stride_multiple); \
  82. HFI_NV12_IL_CALC_Y_BUFHEIGHT(_height, half_height,\
  83. y_buffer_height_multiple); \
  84. HFI_NV12_UBWC_IL_CALC_Y_BUF_SIZE(y_buf_size, stride, _height);\
  85. HFI_NV12_IL_CALC_UV_STRIDE(stride, frame_width, \
  86. uv_stride_multiple); \
  87. HFI_NV12_IL_CALC_UV_BUFHEIGHT(_height, half_height, \
  88. uv_buffer_height_multiple); \
  89. HFI_NV12_UBWC_IL_CALC_UV_BUF_SIZE(uv_buf_size, stride, _height);\
  90. HFI_UBWC_CALC_METADATA_PLANE_STRIDE(stride, frame_width,\
  91. y_metadata_stride_multiple, \
  92. HFI_COLOR_FORMAT_YUV420_NV12_UBWC_Y_TILE_WIDTH);\
  93. HFI_UBWC_METADATA_PLANE_BUFHEIGHT(_height, half_height, \
  94. y_metadata_buffer_height_multiple,\
  95. HFI_COLOR_FORMAT_YUV420_NV12_UBWC_Y_TILE_HEIGHT);\
  96. HFI_UBWC_METADATA_PLANE_BUFFER_SIZE(y_meta_size, stride, \
  97. _height); \
  98. HFI_UBWC_UV_METADATA_PLANE_STRIDE(stride, frame_width,\
  99. uv_metadata_stride_multiple, \
  100. HFI_COLOR_FORMAT_YUV420_NV12_UBWC_UV_TILE_WIDTH); \
  101. HFI_UBWC_UV_METADATA_PLANE_BUFHEIGHT(_height, half_height,\
  102. uv_metadata_buffer_height_multiple,\
  103. HFI_COLOR_FORMAT_YUV420_NV12_UBWC_UV_TILE_HEIGHT);\
  104. HFI_UBWC_METADATA_PLANE_BUFFER_SIZE(uv_meta_size, stride, \
  105. _height); \
  106. buf_size = (y_buf_size + uv_buf_size + y_meta_size + \
  107. uv_meta_size) << binterlace;\
  108. } while (0)
  109. #define HFI_YUV420_TP10_CALC_Y_STRIDE(stride, frame_width, stride_multiple) \
  110. stride = HFI_ALIGN(frame_width, 192); \
  111. stride = HFI_ALIGN(stride * 4 / 3, stride_multiple)
  112. #define HFI_YUV420_TP10_CALC_Y_BUFHEIGHT(buf_height, frame_height, \
  113. min_buf_height_multiple) \
  114. (buf_height = HFI_ALIGN(frame_height, min_buf_height_multiple))
  115. #define HFI_YUV420_TP10_CALC_UV_STRIDE(stride, frame_width, stride_multiple) \
  116. do { \
  117. stride = HFI_ALIGN(frame_width, 192); \
  118. stride = HFI_ALIGN(stride * 4 / 3, stride_multiple); \
  119. } while (0)
  120. #define HFI_YUV420_TP10_CALC_UV_BUFHEIGHT(buf_height, frame_height, \
  121. min_buf_height_multiple) \
  122. (buf_height = HFI_ALIGN(((frame_height + 1) >> 1), \
  123. min_buf_height_multiple))
  124. #define HFI_YUV420_TP10_CALC_BUF_SIZE(buf_size, y_buf_size, y_stride,\
  125. y_buf_height, uv_buf_size, uv_stride, uv_buf_height) \
  126. y_buf_size = (y_stride * y_buf_height); \
  127. uv_buf_size = (uv_stride * uv_buf_height); \
  128. buf_size = y_buf_size + uv_buf_size
  129. #define HFI_YUV420_TP10_UBWC_CALC_Y_BUF_SIZE(y_buf_size, y_stride, \
  130. y_buf_height) \
  131. (y_buf_size = HFI_ALIGN(y_stride * y_buf_height, HFI_ALIGNMENT_4096))
  132. #define HFI_YUV420_TP10_UBWC_CALC_UV_BUF_SIZE(uv_buf_size, uv_stride, \
  133. uv_buf_height) \
  134. (uv_buf_size = HFI_ALIGN(uv_stride * uv_buf_height, HFI_ALIGNMENT_4096))
  135. #define HFI_YUV420_TP10_UBWC_CALC_BUF_SIZE(buf_size, y_stride, y_buf_height, \
  136. uv_stride, uv_buf_height, y_md_stride, y_md_height, uv_md_stride, \
  137. uv_md_height)\
  138. do { \
  139. HFI_U32 y_data_size, uv_data_size, y_md_size, uv_md_size; \
  140. HFI_YUV420_TP10_UBWC_CALC_Y_BUF_SIZE(y_data_size, y_stride,\
  141. y_buf_height); \
  142. HFI_YUV420_TP10_UBWC_CALC_UV_BUF_SIZE(uv_data_size, uv_stride, \
  143. uv_buf_height); \
  144. HFI_UBWC_METADATA_PLANE_BUFFER_SIZE(y_md_size, y_md_stride, \
  145. y_md_height); \
  146. HFI_UBWC_METADATA_PLANE_BUFFER_SIZE(uv_md_size, uv_md_stride, \
  147. uv_md_height); \
  148. buf_size = y_data_size + uv_data_size + y_md_size + \
  149. uv_md_size; \
  150. } while (0)
  151. #define HFI_YUV420_P010_CALC_Y_STRIDE(stride, frame_width, stride_multiple) \
  152. (stride = HFI_ALIGN(frame_width * 2, stride_multiple))
  153. #define HFI_YUV420_P010_CALC_Y_BUFHEIGHT(buf_height, frame_height, \
  154. min_buf_height_multiple) \
  155. (buf_height = HFI_ALIGN(frame_height, min_buf_height_multiple))
  156. #define HFI_YUV420_P010_CALC_UV_STRIDE(stride, frame_width, stride_multiple) \
  157. (stride = HFI_ALIGN(frame_width * 2, stride_multiple))
  158. #define HFI_YUV420_P010_CALC_UV_BUFHEIGHT(buf_height, frame_height, \
  159. min_buf_height_multiple) \
  160. (buf_height = HFI_ALIGN(((frame_height + 1) >> 1), \
  161. min_buf_height_multiple))
  162. #define HFI_YUV420_P010_CALC_BUF_SIZE(buf_size, y_data_size, y_stride, \
  163. y_buf_height, uv_data_size, uv_stride, uv_buf_height) \
  164. do { \
  165. y_data_size = HFI_ALIGN(y_stride * y_buf_height, \
  166. HFI_ALIGNMENT_4096);\
  167. uv_data_size = HFI_ALIGN(uv_stride * uv_buf_height, \
  168. HFI_ALIGNMENT_4096); \
  169. buf_size = y_data_size + uv_data_size; \
  170. } while (0)
  171. #define HFI_RGB888_CALC_STRIDE(stride, frame_width, stride_multiple) \
  172. (stride = ((frame_width * 3) + stride_multiple - 1) & \
  173. (0xffffffff - (stride_multiple - 1)))
  174. #define HFI_RGB888_CALC_BUFHEIGHT(buf_height, frame_height, \
  175. min_buf_height_multiple) \
  176. (buf_height = ((frame_height + min_buf_height_multiple - 1) & \
  177. (0xffffffff - (min_buf_height_multiple - 1))))
  178. #define HFI_RGB888_CALC_BUF_SIZE(buf_size, stride, buf_height) \
  179. (buf_size = ((stride) * (buf_height)))
  180. #define HFI_RGBA8888_CALC_STRIDE(stride, frame_width, stride_multiple) \
  181. (stride = HFI_ALIGN((frame_width << 2), stride_multiple))
  182. #define HFI_RGBA8888_CALC_BUFHEIGHT(buf_height, frame_height, \
  183. min_buf_height_multiple) \
  184. (buf_height = HFI_ALIGN(frame_height, min_buf_height_multiple))
  185. #define HFI_RGBA8888_CALC_BUF_SIZE(buf_size, stride, buf_height) \
  186. (buf_size = (stride) * (buf_height))
  187. #define HFI_RGBA8888_UBWC_CALC_DATA_PLANE_BUF_SIZE(buf_size, stride, \
  188. buf_height) \
  189. (buf_size = HFI_ALIGN((stride) * (buf_height), HFI_ALIGNMENT_4096))
  190. #define HFI_RGBA8888_UBWC_BUF_SIZE(buf_size, data_buf_size, \
  191. metadata_buffer_size, stride, buf_height, _metadata_tride, \
  192. _metadata_buf_height) \
  193. do { \
  194. HFI_RGBA8888_UBWC_CALC_DATA_PLANE_BUF_SIZE(data_buf_size, \
  195. stride, buf_height); \
  196. HFI_UBWC_METADATA_PLANE_BUFFER_SIZE(metadata_buffer_size, \
  197. _metadata_tride, _metadata_buf_height); \
  198. buf_size = data_buf_size + metadata_buffer_size \
  199. } while (0)
  200. #define HFI_UBWC_CALC_METADATA_PLANE_STRIDE(metadata_stride, frame_width,\
  201. metadata_stride_multiple, tile_width_in_pels) \
  202. ((metadata_stride = HFI_ALIGN(((frame_width + (tile_width_in_pels - 1)) /\
  203. tile_width_in_pels), metadata_stride_multiple)))
  204. #define HFI_UBWC_METADATA_PLANE_BUFHEIGHT(metadata_buf_height, frame_height, \
  205. metadata_height_multiple, tile_height_in_pels) \
  206. ((metadata_buf_height = HFI_ALIGN(((frame_height + \
  207. (tile_height_in_pels - 1)) / tile_height_in_pels), \
  208. metadata_height_multiple)))
  209. #define HFI_UBWC_UV_METADATA_PLANE_STRIDE(metadata_stride, frame_width, \
  210. metadata_stride_multiple, tile_width_in_pels) \
  211. ((metadata_stride = HFI_ALIGN(((((frame_width + 1) >> 1) +\
  212. (tile_width_in_pels - 1)) / tile_width_in_pels), \
  213. metadata_stride_multiple)))
  214. #define HFI_UBWC_UV_METADATA_PLANE_BUFHEIGHT(metadata_buf_height, frame_height,\
  215. metadata_height_multiple, tile_height_in_pels) \
  216. (metadata_buf_height = HFI_ALIGN(((((frame_height + 1) >> 1) + \
  217. (tile_height_in_pels - 1)) / tile_height_in_pels), \
  218. metadata_height_multiple))
  219. #define HFI_UBWC_METADATA_PLANE_BUFFER_SIZE(buffer_size, _metadata_tride, \
  220. _metadata_buf_height) \
  221. ((buffer_size = HFI_ALIGN(_metadata_tride * _metadata_buf_height, \
  222. HFI_ALIGNMENT_4096)))
  223. #define BUFFER_ALIGNMENT_512_BYTES 512
  224. #define BUFFER_ALIGNMENT_256_BYTES 256
  225. #define BUFFER_ALIGNMENT_128_BYTES 128
  226. #define BUFFER_ALIGNMENT_64_BYTES 64
  227. #define BUFFER_ALIGNMENT_32_BYTES 32
  228. #define BUFFER_ALIGNMENT_16_BYTES 16
  229. #define BUFFER_ALIGNMENT_8_BYTES 8
  230. #define BUFFER_ALIGNMENT_4_BYTES 4
  231. #define VENUS_DMA_ALIGNMENT BUFFER_ALIGNMENT_256_BYTES
  232. #define MAX_FE_NBR_CTRL_LCU64_LINE_BUFFER_SIZE 64
  233. #define MAX_FE_NBR_CTRL_LCU32_LINE_BUFFER_SIZE 64
  234. #define MAX_FE_NBR_CTRL_LCU16_LINE_BUFFER_SIZE 64
  235. #define MAX_FE_NBR_DATA_LUMA_LINE_BUFFER_SIZE 640
  236. #define MAX_FE_NBR_DATA_CB_LINE_BUFFER_SIZE 320
  237. #define MAX_FE_NBR_DATA_CR_LINE_BUFFER_SIZE 320
  238. #define MAX_SE_NBR_CTRL_LCU64_LINE_BUFFER_SIZE (128 / 8)
  239. #define MAX_SE_NBR_CTRL_LCU32_LINE_BUFFER_SIZE (128 / 8)
  240. #define MAX_SE_NBR_CTRL_LCU16_LINE_BUFFER_SIZE (128 / 8)
  241. #define MAX_PE_NBR_DATA_LCU64_LINE_BUFFER_SIZE (64 * 2 * 3)
  242. #define MAX_PE_NBR_DATA_LCU32_LINE_BUFFER_SIZE (32 * 2 * 3)
  243. #define MAX_PE_NBR_DATA_LCU16_LINE_BUFFER_SIZE (16 * 2 * 3)
  244. #define MAX_TILE_COLUMNS 32
  245. #define SIZE_VPSS_LB(Size, frame_width, frame_height, num_vpp_pipes) \
  246. do { \
  247. HFI_U32 vpss_4tap_top_buffer_size, vpss_div2_top_buffer_size, \
  248. vpss_4tap_left_buffer_size, vpss_div2_left_buffer_size; \
  249. HFI_U32 opb_wr_top_line_luma_buffer_size, \
  250. opb_wr_top_line_chroma_buffer_size, \
  251. opb_lb_wr_llb_y_buffer_size,\
  252. opb_lb_wr_llb_uv_buffer_size; \
  253. HFI_U32 macrotiling_size; \
  254. vpss_4tap_top_buffer_size = vpss_div2_top_buffer_size = \
  255. vpss_4tap_left_buffer_size = vpss_div2_left_buffer_size = 0; \
  256. macrotiling_size = 32; \
  257. opb_wr_top_line_luma_buffer_size = HFI_ALIGN(frame_width, \
  258. macrotiling_size) / macrotiling_size * 256; \
  259. opb_wr_top_line_luma_buffer_size = \
  260. HFI_ALIGN(opb_wr_top_line_luma_buffer_size, \
  261. VENUS_DMA_ALIGNMENT) + (MAX_TILE_COLUMNS - 1) * 256; \
  262. opb_wr_top_line_luma_buffer_size = \
  263. MAX(opb_wr_top_line_luma_buffer_size, (32 * \
  264. HFI_ALIGN(frame_height, 8))); \
  265. opb_wr_top_line_chroma_buffer_size = \
  266. opb_wr_top_line_luma_buffer_size;\
  267. opb_lb_wr_llb_uv_buffer_size = opb_lb_wr_llb_y_buffer_size = \
  268. HFI_ALIGN((HFI_ALIGN(frame_height, 8) / (4 / 2)) * 64,\
  269. BUFFER_ALIGNMENT_32_BYTES); \
  270. Size = num_vpp_pipes * 2 * (vpss_4tap_top_buffer_size + \
  271. vpss_div2_top_buffer_size) + \
  272. 2 * (vpss_4tap_left_buffer_size + \
  273. vpss_div2_left_buffer_size) + \
  274. opb_wr_top_line_luma_buffer_size + \
  275. opb_wr_top_line_chroma_buffer_size + \
  276. opb_lb_wr_llb_uv_buffer_size + \
  277. opb_lb_wr_llb_y_buffer_size; \
  278. } while (0)
  279. #define VPP_CMD_MAX_SIZE (1 << 20)
  280. #define NUM_HW_PIC_BUF 32
  281. #define BIN_BUFFER_THRESHOLD (1280 * 736)
  282. #define H264D_MAX_SLICE 1800
  283. #define SIZE_H264D_BUFTAB_T (256)
  284. #define SIZE_H264D_HW_PIC_T (1 << 11)
  285. #define SIZE_H264D_BSE_CMD_PER_BUF (32 * 4)
  286. #define SIZE_H264D_VPP_CMD_PER_BUF (512)
  287. #define SIZE_H264D_LB_FE_TOP_DATA(frame_width, frame_height) \
  288. (MAX_FE_NBR_DATA_LUMA_LINE_BUFFER_SIZE * HFI_ALIGN(frame_width, 16) * 3)
  289. #define SIZE_H264D_LB_FE_TOP_CTRL(frame_width, frame_height) \
  290. (MAX_FE_NBR_CTRL_LCU64_LINE_BUFFER_SIZE * ((frame_width + 15) >> 4))
  291. #define SIZE_H264D_LB_FE_LEFT_CTRL(frame_width, frame_height) \
  292. (MAX_FE_NBR_CTRL_LCU64_LINE_BUFFER_SIZE * ((frame_height + 15) >> 4))
  293. #define SIZE_H264D_LB_SE_TOP_CTRL(frame_width, frame_height) \
  294. (MAX_SE_NBR_CTRL_LCU64_LINE_BUFFER_SIZE * ((frame_width + 15) >> 4))
  295. #define SIZE_H264D_LB_SE_LEFT_CTRL(frame_width, frame_height) \
  296. (MAX_SE_NBR_CTRL_LCU64_LINE_BUFFER_SIZE * ((frame_height + 15) >> 4))
  297. #define SIZE_H264D_LB_PE_TOP_DATA(frame_width, frame_height) \
  298. (MAX_PE_NBR_DATA_LCU64_LINE_BUFFER_SIZE * ((frame_width + 15) >> 4))
  299. #define SIZE_H264D_LB_VSP_TOP(frame_width, frame_height) \
  300. ((((frame_width + 15) >> 4) << 7))
  301. #define SIZE_H264D_LB_RECON_DMA_METADATA_WR(frame_width, frame_height) \
  302. (HFI_ALIGN(frame_height, 16) * 32)
  303. #define SIZE_H264D_QP(frame_width, frame_height) \
  304. (((frame_width + 63) >> 6) * ((frame_height + 63) >> 6) * 128)
  305. #define SIZE_HW_PIC(size_per_buf) \
  306. (NUM_HW_PIC_BUF * size_per_buf)
  307. #define SIZE_H264D_BSE_CMD_BUF(_size, frame_width, frame_height) \
  308. do { \
  309. HFI_U32 _height = HFI_ALIGN(frame_height, \
  310. BUFFER_ALIGNMENT_32_BYTES); \
  311. _size = MIN((((_height + 15) >> 4) * 48), H264D_MAX_SLICE) *\
  312. SIZE_H264D_BSE_CMD_PER_BUF; \
  313. } while (0)
  314. #define SIZE_H264D_VPP_CMD_BUF(_size, frame_width, frame_height) \
  315. do { \
  316. HFI_U32 _height = HFI_ALIGN(frame_height, \
  317. BUFFER_ALIGNMENT_32_BYTES); \
  318. _size = MIN((((_height + 15) >> 4) * 48), H264D_MAX_SLICE) * \
  319. SIZE_H264D_VPP_CMD_PER_BUF; \
  320. if (_size > VPP_CMD_MAX_SIZE) { _size = VPP_CMD_MAX_SIZE; } \
  321. } while (0)
  322. #define HFI_BUFFER_COMV_H264D(coMV_size, frame_width, \
  323. frame_height, _comv_bufcount) \
  324. do { \
  325. HFI_U32 frame_width_in_mbs = ((frame_width + 15) >> 4); \
  326. HFI_U32 frame_height_in_mbs = ((frame_height + 15) >> 4); \
  327. HFI_U32 col_mv_aligned_width = (frame_width_in_mbs << 7); \
  328. HFI_U32 col_zero_aligned_width = (frame_width_in_mbs << 2); \
  329. HFI_U32 col_zero_size = 0, size_colloc = 0; \
  330. col_mv_aligned_width = HFI_ALIGN(col_mv_aligned_width, \
  331. BUFFER_ALIGNMENT_16_BYTES); \
  332. col_zero_aligned_width = HFI_ALIGN(col_zero_aligned_width, \
  333. BUFFER_ALIGNMENT_16_BYTES); \
  334. col_zero_size = col_zero_aligned_width * \
  335. ((frame_height_in_mbs + 1) >> 1); \
  336. col_zero_size = HFI_ALIGN(col_zero_size, \
  337. BUFFER_ALIGNMENT_64_BYTES); \
  338. col_zero_size <<= 1; \
  339. col_zero_size = HFI_ALIGN(col_zero_size, \
  340. BUFFER_ALIGNMENT_512_BYTES); \
  341. size_colloc = col_mv_aligned_width * ((frame_height_in_mbs + \
  342. 1) >> 1); \
  343. size_colloc = HFI_ALIGN(size_colloc, \
  344. BUFFER_ALIGNMENT_64_BYTES); \
  345. size_colloc <<= 1; \
  346. size_colloc = HFI_ALIGN(size_colloc, \
  347. BUFFER_ALIGNMENT_512_BYTES); \
  348. size_colloc += (col_zero_size + SIZE_H264D_BUFTAB_T * 2); \
  349. coMV_size = size_colloc * (_comv_bufcount); \
  350. coMV_size += BUFFER_ALIGNMENT_512_BYTES; \
  351. } while (0)
  352. #define HFI_BUFFER_NON_COMV_H264D(_size, frame_width, frame_height, \
  353. num_vpp_pipes) \
  354. do { \
  355. HFI_U32 _size_bse, _size_vpp; \
  356. SIZE_H264D_BSE_CMD_BUF(_size_bse, frame_width, frame_height); \
  357. SIZE_H264D_VPP_CMD_BUF(_size_vpp, frame_width, frame_height); \
  358. _size = HFI_ALIGN(_size_bse, VENUS_DMA_ALIGNMENT) + \
  359. HFI_ALIGN(_size_vpp, VENUS_DMA_ALIGNMENT) + \
  360. HFI_ALIGN(SIZE_HW_PIC(SIZE_H264D_HW_PIC_T), \
  361. VENUS_DMA_ALIGNMENT); \
  362. _size = HFI_ALIGN(_size, VENUS_DMA_ALIGNMENT); \
  363. } while (0)
  364. #define HFI_BUFFER_LINE_H264D(_size, frame_width, frame_height, \
  365. is_opb, num_vpp_pipes) \
  366. do { \
  367. HFI_U32 vpss_lb_size = 0; \
  368. _size = HFI_ALIGN(SIZE_H264D_LB_FE_TOP_DATA(frame_width, \
  369. frame_height), VENUS_DMA_ALIGNMENT) + \
  370. HFI_ALIGN(SIZE_H264D_LB_FE_TOP_CTRL(frame_width, \
  371. frame_height), VENUS_DMA_ALIGNMENT) + \
  372. HFI_ALIGN(SIZE_H264D_LB_FE_LEFT_CTRL(frame_width, \
  373. frame_height), VENUS_DMA_ALIGNMENT) * num_vpp_pipes + \
  374. HFI_ALIGN(SIZE_H264D_LB_SE_TOP_CTRL(frame_width, \
  375. frame_height), VENUS_DMA_ALIGNMENT) + \
  376. HFI_ALIGN(SIZE_H264D_LB_SE_LEFT_CTRL(frame_width, \
  377. frame_height), VENUS_DMA_ALIGNMENT) * \
  378. num_vpp_pipes + \
  379. HFI_ALIGN(SIZE_H264D_LB_PE_TOP_DATA(frame_width, \
  380. frame_height), VENUS_DMA_ALIGNMENT) + \
  381. HFI_ALIGN(SIZE_H264D_LB_VSP_TOP(frame_width, \
  382. frame_height), VENUS_DMA_ALIGNMENT) + \
  383. HFI_ALIGN(SIZE_H264D_LB_RECON_DMA_METADATA_WR\
  384. (frame_width, frame_height), \
  385. VENUS_DMA_ALIGNMENT) * 2 + HFI_ALIGN(SIZE_H264D_QP\
  386. (frame_width, frame_height), VENUS_DMA_ALIGNMENT); \
  387. _size = HFI_ALIGN(_size, VENUS_DMA_ALIGNMENT); \
  388. if (is_opb) { \
  389. SIZE_VPSS_LB(vpss_lb_size, frame_width, frame_height, \
  390. num_vpp_pipes); \
  391. } \
  392. _size = HFI_ALIGN((_size + vpss_lb_size), \
  393. VENUS_DMA_ALIGNMENT); \
  394. } while (0)
  395. #define H264_CABAC_HDR_RATIO_HD_TOT 1
  396. #define H264_CABAC_RES_RATIO_HD_TOT 3
  397. #define SIZE_H264D_HW_BIN_BUFFER(_size, frame_width, frame_height, \
  398. delay, num_vpp_pipes) \
  399. do { \
  400. HFI_U32 size_yuv, size_bin_hdr, size_bin_res; \
  401. size_yuv = ((frame_width * frame_height) <= \
  402. BIN_BUFFER_THRESHOLD) ?\
  403. ((BIN_BUFFER_THRESHOLD * 3) >> 1) : \
  404. ((frame_width * frame_height * 3) >> 1); \
  405. size_bin_hdr = size_yuv * H264_CABAC_HDR_RATIO_HD_TOT; \
  406. size_bin_res = size_yuv * H264_CABAC_RES_RATIO_HD_TOT; \
  407. size_bin_hdr = size_bin_hdr * (((((HFI_U32)(delay)) & 31) /\
  408. 10) + 2) / 2; \
  409. size_bin_res = size_bin_res * (((((HFI_U32)(delay)) & 31) /\
  410. 10) + 2) / 2; \
  411. size_bin_hdr = HFI_ALIGN(size_bin_hdr / num_vpp_pipes,\
  412. VENUS_DMA_ALIGNMENT) * num_vpp_pipes; \
  413. size_bin_res = HFI_ALIGN(size_bin_res / num_vpp_pipes, \
  414. VENUS_DMA_ALIGNMENT) * num_vpp_pipes; \
  415. _size = size_bin_hdr + size_bin_res; \
  416. } while (0)
  417. #define HFI_BUFFER_BIN_H264D(_size, frame_width, frame_height, is_interlaced, \
  418. delay, num_vpp_pipes) \
  419. do { \
  420. HFI_U32 n_aligned_w = HFI_ALIGN(frame_width, \
  421. BUFFER_ALIGNMENT_16_BYTES);\
  422. HFI_U32 n_aligned_h = HFI_ALIGN(frame_height, \
  423. BUFFER_ALIGNMENT_16_BYTES); \
  424. if (!is_interlaced) { \
  425. SIZE_H264D_HW_BIN_BUFFER(_size, n_aligned_w, \
  426. n_aligned_h, delay, num_vpp_pipes); \
  427. } else { \
  428. _size = 0; \
  429. } \
  430. } while (0)
  431. #define NUM_SLIST_BUF_H264 (256 + 32)
  432. #define SIZE_SLIST_BUF_H264 (512)
  433. #define SIZE_SEI_USERDATA (4096)
  434. #define H264_NUM_FRM_INFO (66)
  435. #define H264_DISPLAY_BUF_SIZE (3328)
  436. #define SIZE_DOLBY_RPU_METADATA (41 * 1024)
  437. #define HFI_BUFFER_PERSIST_H264D(_size, rpu_enabled) \
  438. _size = HFI_ALIGN((SIZE_SLIST_BUF_H264 * NUM_SLIST_BUF_H264 + \
  439. H264_DISPLAY_BUF_SIZE * H264_NUM_FRM_INFO + \
  440. NUM_HW_PIC_BUF * SIZE_SEI_USERDATA + \
  441. rpu_enabled * NUM_HW_PIC_BUF * SIZE_DOLBY_RPU_METADATA), \
  442. VENUS_DMA_ALIGNMENT)
  443. #define LCU_MAX_SIZE_PELS 64
  444. #define LCU_MIN_SIZE_PELS 16
  445. #define H265D_MAX_SLICE 1200
  446. #define SIZE_H265D_HW_PIC_T SIZE_H264D_HW_PIC_T
  447. #define SIZE_H265D_BSE_CMD_PER_BUF (16 * sizeof(HFI_U32))
  448. #define SIZE_H265D_VPP_CMD_PER_BUF (256)
  449. #define SIZE_H265D_LB_FE_TOP_DATA(frame_width, frame_height) \
  450. (MAX_FE_NBR_DATA_LUMA_LINE_BUFFER_SIZE * \
  451. (HFI_ALIGN(frame_width, 64) + 8) * 2)
  452. #define SIZE_H265D_LB_FE_TOP_CTRL(frame_width, frame_height) \
  453. (MAX_FE_NBR_CTRL_LCU64_LINE_BUFFER_SIZE * \
  454. (HFI_ALIGN(frame_width, LCU_MAX_SIZE_PELS) / LCU_MIN_SIZE_PELS))
  455. #define SIZE_H265D_LB_FE_LEFT_CTRL(frame_width, frame_height) \
  456. (MAX_FE_NBR_CTRL_LCU64_LINE_BUFFER_SIZE * \
  457. (HFI_ALIGN(frame_height, LCU_MAX_SIZE_PELS) / LCU_MIN_SIZE_PELS))
  458. #define SIZE_H265D_LB_SE_TOP_CTRL(frame_width, frame_height) \
  459. ((LCU_MAX_SIZE_PELS / 8 * (128 / 8)) * ((frame_width + 15) >> 4))
  460. #define SIZE_H265D_LB_SE_LEFT_CTRL(frame_width, frame_height) \
  461. (MAX(((frame_height + 16 - 1) / 8) * \
  462. MAX_SE_NBR_CTRL_LCU16_LINE_BUFFER_SIZE, \
  463. MAX(((frame_height + 32 - 1) / 8) * \
  464. MAX_SE_NBR_CTRL_LCU32_LINE_BUFFER_SIZE, \
  465. ((frame_height + 64 - 1) / 8) * \
  466. MAX_SE_NBR_CTRL_LCU64_LINE_BUFFER_SIZE)))
  467. #define SIZE_H265D_LB_PE_TOP_DATA(frame_width, frame_height) \
  468. (MAX_PE_NBR_DATA_LCU64_LINE_BUFFER_SIZE * (HFI_ALIGN(frame_width, \
  469. LCU_MIN_SIZE_PELS) / LCU_MIN_SIZE_PELS))
  470. #define SIZE_H265D_LB_VSP_TOP(frame_width, frame_height) \
  471. (((frame_width + 63) >> 6) * 128)
  472. #define SIZE_H265D_LB_VSP_LEFT(frame_width, frame_height) \
  473. (((frame_height + 63) >> 6) * 128)
  474. #define SIZE_H265D_LB_RECON_DMA_METADATA_WR(frame_width, frame_height) \
  475. SIZE_H264D_LB_RECON_DMA_METADATA_WR(frame_width, frame_height)
  476. #define SIZE_H265D_QP(frame_width, frame_height) \
  477. SIZE_H264D_QP(frame_width, frame_height)
  478. #define SIZE_H265D_BSE_CMD_BUF(_size, frame_width, frame_height)\
  479. do { \
  480. _size = HFI_ALIGN(((HFI_ALIGN(frame_width, \
  481. LCU_MAX_SIZE_PELS) / LCU_MIN_SIZE_PELS) * \
  482. (HFI_ALIGN(frame_height, LCU_MAX_SIZE_PELS) /\
  483. LCU_MIN_SIZE_PELS)) * NUM_HW_PIC_BUF, VENUS_DMA_ALIGNMENT); \
  484. _size = MIN(_size, H265D_MAX_SLICE + 1); \
  485. _size = 2 * _size * SIZE_H265D_BSE_CMD_PER_BUF; \
  486. } while (0)
  487. #define SIZE_H265D_VPP_CMD_BUF(_size, frame_width, frame_height) \
  488. do { \
  489. _size = HFI_ALIGN(((HFI_ALIGN(frame_width, LCU_MAX_SIZE_PELS) /\
  490. LCU_MIN_SIZE_PELS) * (HFI_ALIGN(frame_height, \
  491. LCU_MAX_SIZE_PELS) / LCU_MIN_SIZE_PELS)) * \
  492. NUM_HW_PIC_BUF, VENUS_DMA_ALIGNMENT); \
  493. _size = MIN(_size, H265D_MAX_SLICE + 1); \
  494. _size = HFI_ALIGN(_size, 4); \
  495. _size = 2 * _size * SIZE_H265D_VPP_CMD_PER_BUF; \
  496. if (_size > VPP_CMD_MAX_SIZE) { \
  497. _size = VPP_CMD_MAX_SIZE; \
  498. } \
  499. } while (0)
  500. #define HFI_BUFFER_COMV_H265D(_size, frame_width, frame_height, \
  501. _comv_bufcount) \
  502. do { \
  503. _size = HFI_ALIGN(((((frame_width + 15) >> 4) * \
  504. ((frame_height + 15) >> 4)) << 8), \
  505. BUFFER_ALIGNMENT_512_BYTES); \
  506. _size *= _comv_bufcount; \
  507. _size += BUFFER_ALIGNMENT_512_BYTES; \
  508. } while (0)
  509. #define HDR10_HIST_EXTRADATA_SIZE (4 * 1024)
  510. #define HFI_BUFFER_NON_COMV_H265D(_size, frame_width, frame_height, \
  511. num_vpp_pipes) \
  512. do { \
  513. HFI_U32 _size_bse, _size_vpp; \
  514. SIZE_H265D_BSE_CMD_BUF(_size_bse, frame_width, \
  515. frame_height); \
  516. SIZE_H265D_VPP_CMD_BUF(_size_vpp, frame_width, \
  517. frame_height); \
  518. _size = HFI_ALIGN(_size_bse, VENUS_DMA_ALIGNMENT) + \
  519. HFI_ALIGN(_size_vpp, VENUS_DMA_ALIGNMENT) + \
  520. HFI_ALIGN(NUM_HW_PIC_BUF * 20 * 22 * 4, \
  521. VENUS_DMA_ALIGNMENT) + \
  522. HFI_ALIGN(2 * sizeof(HFI_U16) * \
  523. (HFI_ALIGN(frame_width, LCU_MAX_SIZE_PELS) / \
  524. LCU_MIN_SIZE_PELS) * (HFI_ALIGN(frame_height, \
  525. LCU_MAX_SIZE_PELS) / LCU_MIN_SIZE_PELS), \
  526. VENUS_DMA_ALIGNMENT) + \
  527. HFI_ALIGN(SIZE_HW_PIC(SIZE_H265D_HW_PIC_T), \
  528. VENUS_DMA_ALIGNMENT) + \
  529. HDR10_HIST_EXTRADATA_SIZE; \
  530. _size = HFI_ALIGN(_size, VENUS_DMA_ALIGNMENT); \
  531. } while (0)
  532. #define HFI_BUFFER_LINE_H265D(_size, frame_width, frame_height, \
  533. is_opb, num_vpp_pipes) \
  534. do { \
  535. HFI_U32 vpss_lb_size = 0; \
  536. _size = HFI_ALIGN(SIZE_H265D_LB_FE_TOP_DATA(frame_width, \
  537. frame_height), VENUS_DMA_ALIGNMENT) + \
  538. HFI_ALIGN(SIZE_H265D_LB_FE_TOP_CTRL(frame_width, \
  539. frame_height), VENUS_DMA_ALIGNMENT) + \
  540. HFI_ALIGN(SIZE_H265D_LB_FE_LEFT_CTRL(frame_width, \
  541. frame_height), VENUS_DMA_ALIGNMENT) * num_vpp_pipes + \
  542. HFI_ALIGN(SIZE_H265D_LB_SE_LEFT_CTRL(frame_width, \
  543. frame_height), VENUS_DMA_ALIGNMENT) * num_vpp_pipes + \
  544. HFI_ALIGN(SIZE_H265D_LB_SE_TOP_CTRL(frame_width, \
  545. frame_height), VENUS_DMA_ALIGNMENT) + \
  546. HFI_ALIGN(SIZE_H265D_LB_PE_TOP_DATA(frame_width, \
  547. frame_height), VENUS_DMA_ALIGNMENT) + \
  548. HFI_ALIGN(SIZE_H265D_LB_VSP_TOP(frame_width, \
  549. frame_height), VENUS_DMA_ALIGNMENT) + \
  550. HFI_ALIGN(SIZE_H265D_LB_VSP_LEFT(frame_width, \
  551. frame_height), VENUS_DMA_ALIGNMENT) * num_vpp_pipes + \
  552. HFI_ALIGN(SIZE_H265D_LB_RECON_DMA_METADATA_WR\
  553. (frame_width, frame_height), \
  554. VENUS_DMA_ALIGNMENT) * 4 + \
  555. HFI_ALIGN(SIZE_H265D_QP(frame_width, frame_height),\
  556. VENUS_DMA_ALIGNMENT); \
  557. if (is_opb) { \
  558. SIZE_VPSS_LB(vpss_lb_size, frame_width, frame_height,\
  559. num_vpp_pipes); \
  560. } \
  561. _size = HFI_ALIGN((_size + vpss_lb_size), \
  562. VENUS_DMA_ALIGNMENT); \
  563. } while (0)
  564. #define H265_CABAC_HDR_RATIO_HD_TOT 2
  565. #define H265_CABAC_RES_RATIO_HD_TOT 2
  566. #define SIZE_H265D_HW_BIN_BUFFER(_size, frame_width, frame_height, \
  567. delay, num_vpp_pipes) \
  568. do { \
  569. HFI_U32 size_yuv, size_bin_hdr, size_bin_res; \
  570. size_yuv = ((frame_width * frame_height) <= \
  571. BIN_BUFFER_THRESHOLD) ? \
  572. ((BIN_BUFFER_THRESHOLD * 3) >> 1) : \
  573. ((frame_width * frame_height * 3) >> 1); \
  574. size_bin_hdr = size_yuv * H265_CABAC_HDR_RATIO_HD_TOT; \
  575. size_bin_res = size_yuv * H265_CABAC_RES_RATIO_HD_TOT; \
  576. size_bin_hdr = size_bin_hdr * \
  577. (((((HFI_U32)(delay)) & 31) / 10) + 2) / 2; \
  578. size_bin_res = size_bin_res * \
  579. (((((HFI_U32)(delay)) & 31) / 10) + 2) / 2; \
  580. size_bin_hdr = HFI_ALIGN(size_bin_hdr / \
  581. num_vpp_pipes, VENUS_DMA_ALIGNMENT) * \
  582. num_vpp_pipes; \
  583. size_bin_res = HFI_ALIGN(size_bin_res / num_vpp_pipes,\
  584. VENUS_DMA_ALIGNMENT) * num_vpp_pipes; \
  585. _size = size_bin_hdr + size_bin_res; \
  586. } while (0)
  587. #define HFI_BUFFER_BIN_H265D(_size, frame_width, frame_height, \
  588. is_interlaced, delay, num_vpp_pipes) \
  589. do { \
  590. HFI_U32 n_aligned_w = HFI_ALIGN(frame_width, \
  591. BUFFER_ALIGNMENT_16_BYTES); \
  592. HFI_U32 n_aligned_h = HFI_ALIGN(frame_height, \
  593. BUFFER_ALIGNMENT_16_BYTES); \
  594. if (!is_interlaced) { \
  595. SIZE_H265D_HW_BIN_BUFFER(_size, n_aligned_w, \
  596. n_aligned_h, delay, num_vpp_pipes); \
  597. } else { \
  598. _size = 0; \
  599. } \
  600. } while (0)
  601. #define SIZE_SLIST_BUF_H265 (1 << 10)
  602. #define NUM_SLIST_BUF_H265 (80 + 20)
  603. #define H265_NUM_TILE_COL 32
  604. #define H265_NUM_TILE_ROW 128
  605. #define H265_NUM_TILE (H265_NUM_TILE_ROW * H265_NUM_TILE_COL + 1)
  606. #define H265_NUM_FRM_INFO (48)
  607. #define H265_DISPLAY_BUF_SIZE (3072)
  608. #define HFI_BUFFER_PERSIST_H265D(_size, rpu_enabled) \
  609. _size = HFI_ALIGN((SIZE_SLIST_BUF_H265 * NUM_SLIST_BUF_H265 + \
  610. H265_NUM_FRM_INFO * H265_DISPLAY_BUF_SIZE + \
  611. H265_NUM_TILE * sizeof(HFI_U32) + NUM_HW_PIC_BUF * SIZE_SEI_USERDATA + \
  612. rpu_enabled * NUM_HW_PIC_BUF * SIZE_DOLBY_RPU_METADATA),\
  613. VENUS_DMA_ALIGNMENT)
  614. #define SIZE_VPXD_LB_FE_LEFT_CTRL(frame_width, frame_height) \
  615. MAX(((frame_height + 15) >> 4) * \
  616. MAX_FE_NBR_CTRL_LCU16_LINE_BUFFER_SIZE, \
  617. MAX(((frame_height + 31) >> 5) * \
  618. MAX_FE_NBR_CTRL_LCU32_LINE_BUFFER_SIZE, \
  619. ((frame_height + 63) >> 6) * MAX_FE_NBR_CTRL_LCU64_LINE_BUFFER_SIZE))
  620. #define SIZE_VPXD_LB_FE_TOP_CTRL(frame_width, frame_height) \
  621. (((HFI_ALIGN(frame_width, 64) + 8) * 10 * 2))
  622. #define SIZE_VPXD_LB_SE_TOP_CTRL(frame_width, frame_height) \
  623. (((frame_width + 15) >> 4) * MAX_FE_NBR_CTRL_LCU16_LINE_BUFFER_SIZE)
  624. #define SIZE_VPXD_LB_SE_LEFT_CTRL(frame_width, frame_height) \
  625. MAX(((frame_height + 15) >> 4) * \
  626. MAX_SE_NBR_CTRL_LCU16_LINE_BUFFER_SIZE,\
  627. MAX(((frame_height + 31) >> 5) * \
  628. MAX_SE_NBR_CTRL_LCU32_LINE_BUFFER_SIZE, \
  629. ((frame_height + 63) >> 6) * MAX_SE_NBR_CTRL_LCU64_LINE_BUFFER_SIZE))
  630. #define SIZE_VPXD_LB_RECON_DMA_METADATA_WR(frame_width, frame_height) \
  631. HFI_ALIGN((HFI_ALIGN(frame_height, 8) / (4 / 2)) * 64,\
  632. BUFFER_ALIGNMENT_32_BYTES)
  633. #define SIZE_MP2D_LB_FE_TOP_DATA(frame_width, frame_height) \
  634. ((HFI_ALIGN(frame_width, 16) + 8) * 10 * 2)
  635. #define SIZE_VP9D_LB_FE_TOP_DATA(frame_width, frame_height) \
  636. ((HFI_ALIGN(HFI_ALIGN(frame_width, 8), 64) + 8) * 10 * 2)
  637. #define SIZE_MP2D_LB_PE_TOP_DATA(frame_width, frame_height) \
  638. ((HFI_ALIGN(frame_width, 16) >> 4) * 64)
  639. #define SIZE_VP9D_LB_PE_TOP_DATA(frame_width, frame_height) \
  640. ((HFI_ALIGN(HFI_ALIGN(frame_width, 8), 64) >> 6) * 176)
  641. #define SIZE_MP2D_LB_VSP_TOP(frame_width, frame_height) \
  642. (((HFI_ALIGN(frame_width, 16) >> 4) * 64 / 2) + 256)
  643. #define SIZE_VP9D_LB_VSP_TOP(frame_width, frame_height) \
  644. ((((HFI_ALIGN(HFI_ALIGN(frame_width, 8), 64) >> 6) * 64 * 8) + 256))
  645. #define HFI_IRIS3_VP9D_COMV_SIZE \
  646. ((((8192 + 63) >> 6) * ((4320 + 63) >> 6) * 8 * 8 * 2 * 8))
  647. #define SIZE_VP9D_QP(frame_width, frame_height) \
  648. SIZE_H264D_QP(frame_width, frame_height)
  649. #define HFI_IRIS3_VP9D_LB_SIZE(_size, frame_width, frame_height, num_vpp_pipes)\
  650. do { \
  651. _size = HFI_ALIGN(SIZE_VPXD_LB_FE_LEFT_CTRL(frame_width, \
  652. frame_height), VENUS_DMA_ALIGNMENT) * num_vpp_pipes + \
  653. HFI_ALIGN(SIZE_VPXD_LB_SE_LEFT_CTRL(frame_width, frame_height),\
  654. VENUS_DMA_ALIGNMENT) * num_vpp_pipes + \
  655. HFI_ALIGN(SIZE_VP9D_LB_VSP_TOP(frame_width, frame_height), \
  656. VENUS_DMA_ALIGNMENT) + \
  657. HFI_ALIGN(SIZE_VPXD_LB_FE_TOP_CTRL(frame_width, frame_height), \
  658. VENUS_DMA_ALIGNMENT) + 2 * \
  659. HFI_ALIGN(SIZE_VPXD_LB_RECON_DMA_METADATA_WR \
  660. (frame_width, frame_height), VENUS_DMA_ALIGNMENT) + \
  661. HFI_ALIGN(SIZE_VPXD_LB_SE_TOP_CTRL(frame_width, frame_height), \
  662. VENUS_DMA_ALIGNMENT) + \
  663. HFI_ALIGN(SIZE_VP9D_LB_PE_TOP_DATA(frame_width, frame_height), \
  664. VENUS_DMA_ALIGNMENT) + \
  665. HFI_ALIGN(SIZE_VP9D_LB_FE_TOP_DATA(frame_width, frame_height), \
  666. VENUS_DMA_ALIGNMENT) + \
  667. HFI_ALIGN(SIZE_VP9D_QP(frame_width, frame_height), \
  668. VENUS_DMA_ALIGNMENT); \
  669. } while (0)
  670. #define HFI_BUFFER_LINE_VP9D(_size, frame_width, frame_height, \
  671. _yuv_bufcount_min, is_opb, num_vpp_pipes) \
  672. do { \
  673. HFI_U32 _lb_size = 0; \
  674. HFI_U32 vpss_lb_size = 0; \
  675. HFI_IRIS3_VP9D_LB_SIZE(_lb_size, frame_width, frame_height,\
  676. num_vpp_pipes); \
  677. if (is_opb) { \
  678. SIZE_VPSS_LB(vpss_lb_size, frame_width, frame_height, \
  679. num_vpp_pipes); \
  680. } \
  681. _size = _lb_size + vpss_lb_size; \
  682. } while (0)
  683. #define VPX_DECODER_FRAME_CONCURENCY_LVL (2)
  684. #define VPX_DECODER_FRAME_BIN_HDR_BUDGET_RATIO 1 / 2
  685. #define VPX_DECODER_FRAME_BIN_RES_BUDGET_RATIO 3 / 2
  686. #define HFI_BUFFER_BIN_VP9D(_size, frame_width, frame_height, \
  687. is_interlaced, num_vpp_pipes) \
  688. do { \
  689. HFI_U32 _size_yuv = HFI_ALIGN(frame_width, \
  690. BUFFER_ALIGNMENT_16_BYTES) *\
  691. HFI_ALIGN(frame_height, BUFFER_ALIGNMENT_16_BYTES) * 3 / 2; \
  692. if (!is_interlaced) { \
  693. _size = HFI_ALIGN(((MAX(_size_yuv, \
  694. ((BIN_BUFFER_THRESHOLD * 3) >> 1)) * \
  695. VPX_DECODER_FRAME_BIN_HDR_BUDGET_RATIO * \
  696. VPX_DECODER_FRAME_CONCURENCY_LVL) / num_vpp_pipes), \
  697. VENUS_DMA_ALIGNMENT) + HFI_ALIGN(((MAX(_size_yuv, \
  698. ((BIN_BUFFER_THRESHOLD * 3) >> 1)) * \
  699. VPX_DECODER_FRAME_BIN_RES_BUDGET_RATIO * \
  700. VPX_DECODER_FRAME_CONCURENCY_LVL) / num_vpp_pipes), \
  701. VENUS_DMA_ALIGNMENT); \
  702. _size = _size * num_vpp_pipes; \
  703. } \
  704. else \
  705. _size = 0; \
  706. } while (0)
  707. #define VP9_NUM_FRAME_INFO_BUF 32
  708. #define VP9_NUM_PROBABILITY_TABLE_BUF (VP9_NUM_FRAME_INFO_BUF + 4)
  709. #define VP9_PROB_TABLE_SIZE (3840)
  710. #define VP9_FRAME_INFO_BUF_SIZE (6144)
  711. #define VP9_UDC_HEADER_BUF_SIZE (3 * 128)
  712. #define MAX_SUPERFRAME_HEADER_LEN (34)
  713. #define CCE_TILE_OFFSET_SIZE HFI_ALIGN(32 * 4 * 4, BUFFER_ALIGNMENT_32_BYTES)
  714. #define HFI_BUFFER_PERSIST_VP9D(_size) \
  715. _size = HFI_ALIGN(VP9_NUM_PROBABILITY_TABLE_BUF * VP9_PROB_TABLE_SIZE, \
  716. VENUS_DMA_ALIGNMENT) + HFI_ALIGN(HFI_IRIS3_VP9D_COMV_SIZE, \
  717. VENUS_DMA_ALIGNMENT) + HFI_ALIGN(MAX_SUPERFRAME_HEADER_LEN, \
  718. VENUS_DMA_ALIGNMENT) + HFI_ALIGN(VP9_UDC_HEADER_BUF_SIZE, \
  719. VENUS_DMA_ALIGNMENT) + HFI_ALIGN(VP9_NUM_FRAME_INFO_BUF * \
  720. CCE_TILE_OFFSET_SIZE, VENUS_DMA_ALIGNMENT) + \
  721. HFI_ALIGN(VP9_NUM_FRAME_INFO_BUF * VP9_FRAME_INFO_BUF_SIZE, \
  722. VENUS_DMA_ALIGNMENT) + HDR10_HIST_EXTRADATA_SIZE
  723. #define HFI_BUFFER_LINE_MP2D(_size, frame_width, frame_height, \
  724. _yuv_bufcount_min, is_opb, num_vpp_pipes) \
  725. do { \
  726. HFI_U32 vpss_lb_size = 0; \
  727. _size = HFI_ALIGN(SIZE_VPXD_LB_FE_LEFT_CTRL(frame_width, \
  728. frame_height), VENUS_DMA_ALIGNMENT) * num_vpp_pipes + \
  729. HFI_ALIGN(SIZE_VPXD_LB_SE_LEFT_CTRL(frame_width, frame_height),\
  730. VENUS_DMA_ALIGNMENT) * num_vpp_pipes + \
  731. HFI_ALIGN(SIZE_MP2D_LB_VSP_TOP(frame_width, frame_height),\
  732. VENUS_DMA_ALIGNMENT) + HFI_ALIGN(SIZE_VPXD_LB_FE_TOP_CTRL\
  733. (frame_width, frame_height), VENUS_DMA_ALIGNMENT) + \
  734. 2 * HFI_ALIGN(SIZE_VPXD_LB_RECON_DMA_METADATA_WR(frame_width,\
  735. frame_height), VENUS_DMA_ALIGNMENT) + \
  736. HFI_ALIGN(SIZE_VPXD_LB_SE_TOP_CTRL(frame_width, frame_height),\
  737. VENUS_DMA_ALIGNMENT) + \
  738. HFI_ALIGN(SIZE_MP2D_LB_PE_TOP_DATA(frame_width, frame_height), \
  739. VENUS_DMA_ALIGNMENT) + \
  740. HFI_ALIGN(SIZE_MP2D_LB_FE_TOP_DATA(frame_width, frame_height), \
  741. VENUS_DMA_ALIGNMENT); \
  742. if (is_opb) { \
  743. SIZE_VPSS_LB(vpss_lb_size, frame_width, frame_height, \
  744. num_vpp_pipes); \
  745. } \
  746. _size += vpss_lb_size; \
  747. } while (0)
  748. #define HFI_BUFFER_BIN_MP2D(_size, frame_width, frame_height, is_interlaced) 0
  749. #define QMATRIX_SIZE (sizeof(HFI_U32) * 128 + 256)
  750. #define MP2D_QPDUMP_SIZE 115200
  751. #define HFI_BUFFER_PERSIST_MP2D(_size) \
  752. _size = QMATRIX_SIZE + MP2D_QPDUMP_SIZE;
  753. #define AV1D_LCU_MAX_SIZE_PELS 128
  754. #define AV1D_LCU_MIN_SIZE_PELS 64
  755. #define AV1D_MAX_TILE_COLS 64
  756. #define HFI_BUFFER_COMV_AV1D(_size, frame_width, frame_height, \
  757. _comv_bufcount) \
  758. do { \
  759. _size = 2 * HFI_ALIGN(MAX(((frame_width + 63) / 64) * \
  760. ((frame_height + 63) / 64) * 512, \
  761. ((frame_width + 127) / 128) * \
  762. ((frame_height + 127) / 128) * 2816), \
  763. VENUS_DMA_ALIGNMENT); \
  764. _size *= _comv_bufcount; \
  765. } while (0)
  766. #define SIZE_AV1D_LB_FE_TOP_DATA(frame_width, frame_height) \
  767. (HFI_ALIGN(frame_width, AV1D_LCU_MAX_SIZE_PELS) * ((16 * 10) >> 3) + \
  768. HFI_ALIGN(frame_width, AV1D_LCU_MAX_SIZE_PELS) / 2 * ((16 * 6) >> 3) * 2)
  769. #define SIZE_AV1D_LB_FE_LEFT_DATA(frame_width, frame_height) \
  770. (32 * (HFI_ALIGN(frame_height, AV1D_LCU_MAX_SIZE_PELS) + \
  771. HFI_ALIGN(frame_height, AV1D_LCU_MAX_SIZE_PELS) / \
  772. AV1D_LCU_MIN_SIZE_PELS * 16) + \
  773. 16 * (HFI_ALIGN(frame_height, AV1D_LCU_MAX_SIZE_PELS) / 2 + \
  774. HFI_ALIGN(frame_height, AV1D_LCU_MAX_SIZE_PELS) / \
  775. AV1D_LCU_MIN_SIZE_PELS * 8) * 2 + \
  776. 24 * (HFI_ALIGN(frame_height, AV1D_LCU_MAX_SIZE_PELS) + \
  777. HFI_ALIGN(frame_height, AV1D_LCU_MAX_SIZE_PELS) / \
  778. AV1D_LCU_MIN_SIZE_PELS * 16) + \
  779. 24 * (HFI_ALIGN(frame_height, AV1D_LCU_MAX_SIZE_PELS) / 2 + \
  780. HFI_ALIGN(frame_height, AV1D_LCU_MAX_SIZE_PELS) / \
  781. AV1D_LCU_MIN_SIZE_PELS * 12) * 2 + \
  782. 24 * (HFI_ALIGN(frame_height, AV1D_LCU_MAX_SIZE_PELS) + \
  783. HFI_ALIGN(frame_height, AV1D_LCU_MAX_SIZE_PELS) / \
  784. AV1D_LCU_MIN_SIZE_PELS * 16) + \
  785. 16 * (HFI_ALIGN(frame_height, AV1D_LCU_MAX_SIZE_PELS) + \
  786. HFI_ALIGN(frame_height, AV1D_LCU_MAX_SIZE_PELS) / \
  787. AV1D_LCU_MIN_SIZE_PELS * 16) + \
  788. 16 * (HFI_ALIGN(frame_height, AV1D_LCU_MAX_SIZE_PELS) / 2 + \
  789. HFI_ALIGN(frame_height, AV1D_LCU_MAX_SIZE_PELS) / \
  790. AV1D_LCU_MIN_SIZE_PELS * 12) * 2)
  791. #define SIZE_AV1D_LB_FE_TOP_CTRL(frame_width, frame_height) \
  792. (10 * ((frame_width + AV1D_LCU_MIN_SIZE_PELS - 1) / \
  793. AV1D_LCU_MIN_SIZE_PELS) * 128 / 8)
  794. #define SIZE_AV1D_LB_FE_LEFT_CTRL(frame_width, frame_height) \
  795. (16 * ((HFI_ALIGN(frame_height, AV1D_LCU_MAX_SIZE_PELS) / 16) + \
  796. (HFI_ALIGN(frame_height, AV1D_LCU_MAX_SIZE_PELS) / \
  797. AV1D_LCU_MIN_SIZE_PELS)) + \
  798. 3 * 16 * (HFI_ALIGN(frame_height, AV1D_LCU_MAX_SIZE_PELS) / \
  799. AV1D_LCU_MIN_SIZE_PELS))
  800. #define SIZE_AV1D_LB_SE_TOP_CTRL(frame_width, frame_height) \
  801. (((frame_width + 7) / 8) * 16)
  802. #define SIZE_AV1D_LB_SE_LEFT_CTRL(frame_width, frame_height) \
  803. (MAX(((frame_height + 15) / 16) * MAX_SE_NBR_CTRL_LCU16_LINE_BUFFER_SIZE, \
  804. MAX(((frame_height + 31) / 32) * MAX_SE_NBR_CTRL_LCU32_LINE_BUFFER_SIZE, \
  805. ((frame_height + 63) / 64) * MAX_SE_NBR_CTRL_LCU64_LINE_BUFFER_SIZE)))
  806. #define SIZE_AV1D_LB_PE_TOP_DATA(frame_width, frame_height) \
  807. (MAX(((frame_width + 15) / 16) * MAX_PE_NBR_DATA_LCU16_LINE_BUFFER_SIZE, \
  808. MAX(((frame_width + 31) / 32) * MAX_PE_NBR_DATA_LCU32_LINE_BUFFER_SIZE, \
  809. ((frame_width + 63) / 64) * MAX_PE_NBR_DATA_LCU64_LINE_BUFFER_SIZE)))
  810. #define SIZE_AV1D_LB_VSP_TOP(frame_width, frame_height) \
  811. (MAX(((frame_width + 63) / 64) * 1280, ((frame_width + 127) / 128) * 2304))
  812. #define SIZE_AV1D_LB_RECON_DMA_METADATA_WR(frame_width, frame_height) \
  813. ((HFI_ALIGN(frame_height, 8) / (4 / 2)) * 64)
  814. #define SIZE_AV1D_QP(frame_width, frame_height) \
  815. SIZE_H264D_QP(frame_width, frame_height)
  816. #define SIZE_AV1D_LB_OPB_WR1_NV12_UBWC(_size, frame_width, frame_height) \
  817. do { \
  818. HFI_U32 y_width, y_width_a = 128; \
  819. HFI_NV12_IL_CALC_Y_STRIDE(y_width, frame_width, y_width_a); \
  820. _size = (256 * ((y_width + 31) / 32 + (AV1D_MAX_TILE_COLS - 1))); \
  821. } while (0)
  822. #define SIZE_AV1D_LB_OPB_WR1_TP10_UBWC(_size, frame_width, frame_height) \
  823. do { \
  824. HFI_U32 y_width, y_width_a = 256; \
  825. HFI_YUV420_TP10_CALC_Y_STRIDE(y_width, frame_width, y_width_a); \
  826. _size = (256 * ((y_width + 47) / 48 + (AV1D_MAX_TILE_COLS - 1))); \
  827. } while (0)
  828. #define SIZE_AV1D_IBC_NV12_UBWC(_size, frame_width, frame_height) \
  829. do { \
  830. HFI_U32 y_width_a = 128, y_height_a = 32; \
  831. HFI_U32 uv_width_a = 128, uv_height_a = 32; \
  832. HFI_U32 yBufSize, uvBufSize, y_width, y_height, uv_width, uv_height; \
  833. HFI_U32 y_meta_width_a = 64, y_meta_height_a = 16; \
  834. HFI_U32 uv_meta_width_a = 64, uv_meta_height_a = 16; \
  835. HFI_U32 meta_height, meta_stride, meta_size; \
  836. HFI_U32 tile_width_y = HFI_COLOR_FORMAT_YUV420_NV12_UBWC_Y_TILE_WIDTH; \
  837. HFI_U32 tile_height_y = HFI_COLOR_FORMAT_YUV420_NV12_UBWC_Y_TILE_HEIGHT; \
  838. HFI_U32 tile_width_uv = HFI_COLOR_FORMAT_YUV420_NV12_UBWC_UV_TILE_WIDTH; \
  839. HFI_U32 tile_height_uv = \
  840. HFI_COLOR_FORMAT_YUV420_NV12_UBWC_UV_TILE_HEIGHT; \
  841. HFI_NV12_IL_CALC_Y_STRIDE(y_width, frame_width, y_width_a); \
  842. HFI_NV12_IL_CALC_Y_BUFHEIGHT(y_height, frame_height, y_height_a); \
  843. HFI_NV12_IL_CALC_UV_STRIDE(uv_width, frame_width, uv_width_a); \
  844. HFI_NV12_IL_CALC_UV_BUFHEIGHT(uv_height, frame_height, uv_height_a); \
  845. HFI_NV12_UBWC_IL_CALC_Y_BUF_SIZE(yBufSize, y_width, y_height); \
  846. HFI_NV12_UBWC_IL_CALC_UV_BUF_SIZE(uvBufSize, uv_width, uv_height); \
  847. _size = yBufSize + uvBufSize; \
  848. HFI_UBWC_CALC_METADATA_PLANE_STRIDE(meta_stride, frame_width, \
  849. y_meta_width_a, tile_width_y); \
  850. HFI_UBWC_METADATA_PLANE_BUFHEIGHT(meta_height, frame_height, \
  851. y_meta_height_a, tile_height_y); \
  852. HFI_UBWC_METADATA_PLANE_BUFFER_SIZE(meta_size, \
  853. meta_stride, meta_height); \
  854. _size += meta_size; \
  855. HFI_UBWC_UV_METADATA_PLANE_STRIDE(meta_stride, frame_width, \
  856. uv_meta_width_a, tile_width_uv); \
  857. HFI_UBWC_UV_METADATA_PLANE_BUFHEIGHT(meta_height, frame_height, \
  858. uv_meta_height_a, tile_height_uv); \
  859. HFI_UBWC_METADATA_PLANE_BUFFER_SIZE(meta_size, \
  860. meta_stride, meta_height); \
  861. _size += meta_size; \
  862. } while (0)
  863. #define SIZE_AV1D_IBC_TP10_UBWC(_size, frame_width, frame_height) \
  864. do { \
  865. HFI_U32 y_width_a = 256, y_height_a = 16, \
  866. uv_width_a = 256, uv_height_a = 16; \
  867. HFI_U32 yBufSize, uvBufSize, y_width, y_height, uv_width, uv_height; \
  868. HFI_U32 y_meta_width_a = 64, y_meta_height_a = 16, \
  869. uv_meta_width_a = 64, uv_meta_height_a = 16; \
  870. HFI_U32 meta_height, meta_stride, meta_size; \
  871. HFI_U32 tile_width_y = HFI_COLOR_FORMAT_YUV420_TP10_UBWC_Y_TILE_WIDTH; \
  872. HFI_U32 tile_height_y = HFI_COLOR_FORMAT_YUV420_TP10_UBWC_Y_TILE_HEIGHT; \
  873. HFI_U32 tile_width_uv = HFI_COLOR_FORMAT_YUV420_TP10_UBWC_UV_TILE_WIDTH; \
  874. HFI_U32 tile_height_uv = \
  875. HFI_COLOR_FORMAT_YUV420_TP10_UBWC_UV_TILE_HEIGHT; \
  876. HFI_YUV420_TP10_CALC_Y_STRIDE(y_width, frame_width, y_width_a); \
  877. HFI_YUV420_TP10_CALC_Y_BUFHEIGHT(y_height, frame_height, y_height_a); \
  878. HFI_YUV420_TP10_CALC_UV_STRIDE(uv_width, frame_width, uv_width_a); \
  879. HFI_YUV420_TP10_CALC_UV_BUFHEIGHT(uv_height, frame_height, \
  880. uv_height_a); \
  881. HFI_YUV420_TP10_UBWC_CALC_Y_BUF_SIZE(yBufSize, y_width, y_height); \
  882. HFI_YUV420_TP10_UBWC_CALC_UV_BUF_SIZE(uvBufSize, uv_width, uv_height); \
  883. _size = yBufSize + uvBufSize; \
  884. HFI_UBWC_CALC_METADATA_PLANE_STRIDE(meta_stride, frame_width, \
  885. y_meta_width_a, tile_width_y); \
  886. HFI_UBWC_METADATA_PLANE_BUFHEIGHT(meta_height, frame_height, \
  887. y_meta_height_a, tile_height_y); \
  888. HFI_UBWC_METADATA_PLANE_BUFFER_SIZE(meta_size, \
  889. meta_stride, meta_height); \
  890. _size += meta_size; \
  891. HFI_UBWC_UV_METADATA_PLANE_STRIDE(meta_stride, frame_width, \
  892. uv_meta_width_a, tile_width_uv); \
  893. HFI_UBWC_UV_METADATA_PLANE_BUFHEIGHT(meta_height, frame_height, \
  894. uv_meta_height_a, tile_height_uv); \
  895. HFI_UBWC_METADATA_PLANE_BUFFER_SIZE(meta_size, \
  896. meta_stride, meta_height); \
  897. _size += meta_size; \
  898. } while (0)
  899. #define HFI_BUFFER_LINE_AV1D(_size, frame_width, frame_height, isOPB, \
  900. num_vpp_pipes) \
  901. do { \
  902. HFI_U32 vpssLBSize, opbwr1BufSize, opbwr8, opbwr10; \
  903. _size = HFI_ALIGN(SIZE_AV1D_LB_FE_TOP_DATA(frame_width, frame_height), \
  904. VENUS_DMA_ALIGNMENT) + \
  905. HFI_ALIGN(SIZE_AV1D_LB_FE_TOP_CTRL(frame_width, frame_height), \
  906. VENUS_DMA_ALIGNMENT) + \
  907. HFI_ALIGN(SIZE_AV1D_LB_FE_LEFT_DATA(frame_width, frame_height), \
  908. VENUS_DMA_ALIGNMENT) * num_vpp_pipes + \
  909. HFI_ALIGN(SIZE_AV1D_LB_FE_LEFT_CTRL(frame_width, frame_height), \
  910. VENUS_DMA_ALIGNMENT) * num_vpp_pipes + \
  911. HFI_ALIGN(SIZE_AV1D_LB_SE_LEFT_CTRL(frame_width, frame_height), \
  912. VENUS_DMA_ALIGNMENT) * num_vpp_pipes + \
  913. HFI_ALIGN(SIZE_AV1D_LB_SE_TOP_CTRL(frame_width, frame_height), \
  914. VENUS_DMA_ALIGNMENT) + \
  915. HFI_ALIGN(SIZE_AV1D_LB_PE_TOP_DATA(frame_width, frame_height), \
  916. VENUS_DMA_ALIGNMENT) + \
  917. HFI_ALIGN(SIZE_AV1D_LB_VSP_TOP(frame_width, frame_height), \
  918. VENUS_DMA_ALIGNMENT) + \
  919. HFI_ALIGN(SIZE_AV1D_LB_RECON_DMA_METADATA_WR(frame_width, \
  920. frame_height), \
  921. VENUS_DMA_ALIGNMENT) * 2 + \
  922. HFI_ALIGN(SIZE_AV1D_QP(frame_width, frame_height), \
  923. VENUS_DMA_ALIGNMENT); \
  924. SIZE_AV1D_LB_OPB_WR1_NV12_UBWC(opbwr8, frame_width, frame_height); \
  925. SIZE_AV1D_LB_OPB_WR1_TP10_UBWC(opbwr10, frame_width, frame_height); \
  926. opbwr1BufSize = MAX(opbwr8, opbwr10); \
  927. _size = HFI_ALIGN((_size + opbwr1BufSize), VENUS_DMA_ALIGNMENT); \
  928. if (isOPB) { \
  929. SIZE_VPSS_LB(vpssLBSize, frame_width, frame_height, num_vpp_pipes); \
  930. _size = HFI_ALIGN((_size + vpssLBSize), VENUS_DMA_ALIGNMENT); \
  931. } \
  932. } while (0)
  933. #define HFI_BUFFER_IBC_AV1D(_size, frame_width, frame_height) \
  934. do { \
  935. HFI_U32 ibc8, ibc10; \
  936. SIZE_AV1D_IBC_NV12_UBWC(ibc8, frame_width, frame_height); \
  937. SIZE_AV1D_IBC_TP10_UBWC(ibc10, frame_width, frame_height); \
  938. _size = HFI_ALIGN(MAX(ibc8, ibc10), VENUS_DMA_ALIGNMENT); \
  939. } while (0)
  940. #define AV1_CABAC_HDR_RATIO_HD_TOT 2
  941. #define AV1_CABAC_RES_RATIO_HD_TOT 2
  942. /* some content need more bin buffer,
  943. * but limit buffer size for high resolution */
  944. #define SIZE_AV1D_HW_BIN_BUFFER(_size, frame_width, frame_height, delay, \
  945. num_vpp_pipes) \
  946. do { \
  947. HFI_U32 size_yuv, size_bin_hdr, size_bin_res; \
  948. size_yuv = ((frame_width * frame_height) <= BIN_BUFFER_THRESHOLD) ? \
  949. ((BIN_BUFFER_THRESHOLD * 3) >> 1) : \
  950. ((frame_width * frame_height * 3) >> 1); \
  951. size_bin_hdr = size_yuv * AV1_CABAC_HDR_RATIO_HD_TOT; \
  952. size_bin_res = size_yuv * AV1_CABAC_RES_RATIO_HD_TOT; \
  953. size_bin_hdr = size_bin_hdr * \
  954. (((((HFI_U32)(delay)) & 31) / 10) + 2) / 2; \
  955. size_bin_res = size_bin_res * \
  956. (((((HFI_U32)(delay)) & 31) / 10) + 2) / 2; \
  957. size_bin_hdr = HFI_ALIGN(size_bin_hdr / num_vpp_pipes, \
  958. VENUS_DMA_ALIGNMENT) * num_vpp_pipes; \
  959. size_bin_res = HFI_ALIGN(size_bin_res / num_vpp_pipes, \
  960. VENUS_DMA_ALIGNMENT) * num_vpp_pipes; \
  961. _size = size_bin_hdr + size_bin_res; \
  962. } while (0)
  963. #define HFI_BUFFER_BIN_AV1D(_size, frame_width, frame_height, isInterlaced, \
  964. delay, num_vpp_pipes) \
  965. do { \
  966. HFI_U32 nAlignedW = HFI_ALIGN(frame_width, BUFFER_ALIGNMENT_16_BYTES); \
  967. HFI_U32 nAlignedH = HFI_ALIGN(frame_height, BUFFER_ALIGNMENT_16_BYTES); \
  968. if (!isInterlaced) { \
  969. SIZE_AV1D_HW_BIN_BUFFER(_size, nAlignedW, nAlignedH, \
  970. delay, num_vpp_pipes); \
  971. } else { \
  972. _size = 0; \
  973. } \
  974. } while (0)
  975. #define AV1D_NUM_HW_PIC_BUF 16
  976. #define AV1D_NUM_FRAME_HEADERS 16
  977. #define SIZE_AV1D_SEQUENCE_HEADER 768
  978. #define SIZE_AV1D_METADATA 512
  979. #define SIZE_AV1D_FRAME_HEADER 1280
  980. #define SIZE_AV1D_TILE_OFFSET 65536
  981. #define SIZE_AV1D_QM 3328
  982. #define SIZE_AV1D_PROB_TABLE 22784
  983. #define AV1D_SIZE_BSE_COL_MV_64x64 512
  984. #define AV1D_SIZE_BSE_COL_MV_128x128 2816
  985. #define SIZE_AV1D_COL_MV MAX((((8192 + 63) / 64) * ((4352 + 63) / 64) * \
  986. AV1D_SIZE_BSE_COL_MV_64x64), \
  987. (((8192 + 127) / 128) * ((4352 + 127) / 128) * \
  988. AV1D_SIZE_BSE_COL_MV_128x128))
  989. #define HFI_BUFFER_PERSIST_AV1D(_size, max_width, max_height, total_ref_count) \
  990. do { \
  991. HFI_U32 comv_size; \
  992. HFI_BUFFER_COMV_AV1D(comv_size, max_width, max_height, total_ref_count); \
  993. _size = \
  994. HFI_ALIGN((SIZE_AV1D_SEQUENCE_HEADER * 2 + \
  995. SIZE_AV1D_METADATA + \
  996. AV1D_NUM_HW_PIC_BUF * (SIZE_AV1D_TILE_OFFSET + SIZE_AV1D_QM) + \
  997. AV1D_NUM_FRAME_HEADERS * (SIZE_AV1D_FRAME_HEADER + \
  998. 2 * SIZE_AV1D_PROB_TABLE) + \
  999. comv_size + HDR10_HIST_EXTRADATA_SIZE + \
  1000. SIZE_AV1D_METADATA * AV1D_NUM_HW_PIC_BUF), VENUS_DMA_ALIGNMENT); \
  1001. } while (0)
  1002. #define HFI_BUFFER_BITSTREAM_ENC(size, frame_width, frame_height, \
  1003. rc_type, is_ten_bit) \
  1004. do { \
  1005. HFI_U32 aligned_width, aligned_height, bitstream_size, yuv_size; \
  1006. aligned_width = HFI_ALIGN(frame_width, 32); \
  1007. aligned_height = HFI_ALIGN(frame_height, 32); \
  1008. bitstream_size = aligned_width * aligned_height * 3; \
  1009. yuv_size = (aligned_width * aligned_height * 3) >> 1; \
  1010. if (aligned_width * aligned_height > (4096 * 2176)) { \
  1011. /* bitstream_size = 0.25 * yuv_size; */ \
  1012. bitstream_size = (bitstream_size >> 3); \
  1013. } \
  1014. else if (aligned_width * aligned_height > (1280 * 720)) { \
  1015. /* bitstream_size = 0.5 * yuv_size; */ \
  1016. bitstream_size = (bitstream_size >> 2); \
  1017. } else { \
  1018. /* bitstream_size = 2 * yuv_size; */ \
  1019. } \
  1020. if (((rc_type == HFI_RC_CQ) || (rc_type == HFI_RC_OFF)) \
  1021. && (bitstream_size < yuv_size)) { \
  1022. bitstream_size = (bitstream_size << 1);\
  1023. } \
  1024. if (is_ten_bit) { \
  1025. bitstream_size = (bitstream_size) + \
  1026. (bitstream_size >> 2); \
  1027. } \
  1028. size = HFI_ALIGN(bitstream_size, HFI_ALIGNMENT_4096); \
  1029. } while (0)
  1030. #define HFI_IRIS3_ENC_TILE_SIZE_INFO(tile_size, tile_count, last_tile_size, \
  1031. frame_width_coded, codec_standard) \
  1032. do { \
  1033. HFI_U32 without_tile_enc_width; \
  1034. HFI_U32 min_tile_size = 352, fixed_tile_width = 960; \
  1035. without_tile_enc_width = min_tile_size + fixed_tile_width; \
  1036. if ((codec_standard == HFI_CODEC_ENCODE_HEVC) && \
  1037. (frame_width_coded > without_tile_enc_width)) { \
  1038. tile_size = fixed_tile_width; \
  1039. tile_count = (frame_width_coded + tile_size - 1) / tile_size; \
  1040. last_tile_size = (frame_width_coded - (tile_size * (tile_count - 1))); \
  1041. if (last_tile_size < min_tile_size) { \
  1042. tile_count -= 1; \
  1043. last_tile_size = (tile_size + min_tile_size); \
  1044. } \
  1045. } else { \
  1046. tile_size = frame_width_coded; \
  1047. tile_count = 1; \
  1048. last_tile_size = 0; \
  1049. } \
  1050. } while (0)
  1051. #define HFI_IRIS3_ENC_MB_BASED_MULTI_SLICE_COUNT(total_slice_count, frame_width, frame_height, \
  1052. codec_standard, multi_slice_max_mb_count) \
  1053. do { \
  1054. HFI_U32 tile_size, tile_count, last_tile_size, \
  1055. slice_count_per_tile, slice_count_in_last_tile; \
  1056. HFI_U32 mbs_in_one_tile, mbs_in_last_tile; \
  1057. HFI_U32 frame_width_coded, frame_height_coded, lcu_size; \
  1058. lcu_size = (codec_standard == HFI_CODEC_ENCODE_HEVC) ? 32 : 16; \
  1059. frame_width_coded = HFI_ALIGN(frame_width, lcu_size); \
  1060. frame_height_coded = HFI_ALIGN(frame_height, lcu_size); \
  1061. HFI_IRIS3_ENC_TILE_SIZE_INFO(tile_size, tile_count, last_tile_size, \
  1062. frame_width_coded, codec_standard); \
  1063. mbs_in_one_tile = (tile_size * frame_height_coded) / (lcu_size * lcu_size); \
  1064. slice_count_per_tile = \
  1065. (mbs_in_one_tile + multi_slice_max_mb_count - 1) / (multi_slice_max_mb_count); \
  1066. if (last_tile_size) { \
  1067. mbs_in_last_tile = \
  1068. (last_tile_size * frame_height_coded) / (lcu_size * lcu_size); \
  1069. slice_count_in_last_tile = \
  1070. (mbs_in_last_tile + multi_slice_max_mb_count - 1) / (multi_slice_max_mb_count); \
  1071. total_slice_count = \
  1072. (slice_count_per_tile * (tile_count - 1)) + slice_count_in_last_tile; \
  1073. } else { \
  1074. total_slice_count = (slice_count_per_tile * tile_count); \
  1075. } \
  1076. } while (0)
  1077. #define SIZE_ROI_METADATA_ENC(size_roi, frame_width, frame_height, lcu_size)\
  1078. do { \
  1079. HFI_U32 width_in_lcus = 0, height_in_lcus = 0, n_shift = 0; \
  1080. while (lcu_size && !(lcu_size & 0x1)) { \
  1081. n_shift++; \
  1082. lcu_size = lcu_size >> 1; \
  1083. } \
  1084. width_in_lcus = (frame_width + (lcu_size - 1)) >> n_shift; \
  1085. height_in_lcus = (frame_height + (lcu_size - 1)) >> n_shift; \
  1086. size_roi = (((width_in_lcus + 7) >> 3) << 3) * \
  1087. height_in_lcus * 2 + 256; \
  1088. } while (0)
  1089. #define HFI_BUFFER_INPUT_METADATA_ENC(size, frame_width, frame_height, \
  1090. is_roi_enabled, lcu_size) \
  1091. do { \
  1092. HFI_U32 roi_size = 0; \
  1093. if (is_roi_enabled) { \
  1094. SIZE_ROI_METADATA_ENC(roi_size, frame_width, \
  1095. frame_height, lcu_size); \
  1096. } \
  1097. size = roi_size + 16384; \
  1098. size = HFI_ALIGN(size, HFI_ALIGNMENT_4096); \
  1099. } while (0)
  1100. #define HFI_BUFFER_INPUT_METADATA_H264E(size_metadata, frame_width, \
  1101. frame_height, is_roi_enabled) \
  1102. do { \
  1103. HFI_BUFFER_INPUT_METADATA_ENC(size_metadata, frame_width, \
  1104. frame_height, is_roi_enabled, 16); \
  1105. } while (0)
  1106. #define HFI_BUFFER_INPUT_METADATA_H265E(size_metadata, frame_width, \
  1107. frame_height, is_roi_enabled) \
  1108. do { \
  1109. HFI_BUFFER_INPUT_METADATA_ENC(size_metadata, frame_width, \
  1110. frame_height, is_roi_enabled, 32); \
  1111. } while (0)
  1112. #define HFI_BUFFER_ARP_ENC(size) \
  1113. do { \
  1114. size = 204800; \
  1115. } while (0)
  1116. #define HFI_MAX_COL_FRAME 6
  1117. #define HFI_VENUS_VENC_TRE_WB_BUFF_SIZE (65 << 4) // bytes
  1118. #define HFI_VENUS_VENC_DB_LINE_BUFF_PER_MB 512
  1119. #define HFI_VENUS_VPPSG_MAX_REGISTERS 2048
  1120. #define HFI_VENUS_WIDTH_ALIGNMENT 128
  1121. #define HFI_VENUS_WIDTH_TEN_BIT_ALIGNMENT 192
  1122. #define HFI_VENUS_HEIGHT_ALIGNMENT 32
  1123. #define VENUS_METADATA_STRIDE_MULTIPLE 64
  1124. #define VENUS_METADATA_HEIGHT_MULTIPLE 16
  1125. #ifndef SYSTEM_LAL_TILE10
  1126. #define SYSTEM_LAL_TILE10 192
  1127. #endif
  1128. #define HFI_IRIS3_ENC_RECON_BUF_COUNT(num_recon, n_bframe, ltr_count, \
  1129. _total_hp_layers, _total_hb_layers, hybrid_hp, codec_standard) \
  1130. do { \
  1131. HFI_U32 num_ref = 1; \
  1132. if (n_bframe) \
  1133. num_ref = 2; \
  1134. if (_total_hp_layers > 1) { \
  1135. if (hybrid_hp) \
  1136. num_ref = (_total_hp_layers + 1) >> 1; \
  1137. else if (codec_standard == HFI_CODEC_ENCODE_HEVC) \
  1138. num_ref = (_total_hp_layers + 1) >> 1; \
  1139. else if (codec_standard == HFI_CODEC_ENCODE_AVC && \
  1140. _total_hp_layers < 4) \
  1141. num_ref = (_total_hp_layers - 1); \
  1142. else \
  1143. num_ref = _total_hp_layers; \
  1144. } \
  1145. if (ltr_count) \
  1146. num_ref = num_ref + ltr_count; \
  1147. if (_total_hb_layers > 1) { \
  1148. if (codec_standard == HFI_CODEC_ENCODE_HEVC) \
  1149. num_ref = (_total_hb_layers); \
  1150. else if (codec_standard == HFI_CODEC_ENCODE_AVC) \
  1151. num_ref = (1 << (_total_hb_layers - 2)) + 1; \
  1152. } \
  1153. num_recon = num_ref + 1; \
  1154. } while (0)
  1155. #define SIZE_BIN_BITSTREAM_ENC(_size, rc_type, frame_width, frame_height, \
  1156. work_mode, lcu_size, profile) \
  1157. do { \
  1158. HFI_U32 size_aligned_width = 0, size_aligned_height = 0; \
  1159. HFI_U32 bitstream_size_eval = 0; \
  1160. size_aligned_width = HFI_ALIGN((frame_width), lcu_size); \
  1161. size_aligned_height = HFI_ALIGN((frame_height), lcu_size); \
  1162. if (work_mode == HFI_WORKMODE_2) { \
  1163. if ((rc_type == HFI_RC_CQ) || (rc_type == HFI_RC_OFF)) { \
  1164. bitstream_size_eval = (((size_aligned_width) * \
  1165. (size_aligned_height) * 3) >> 1); \
  1166. } \
  1167. else { \
  1168. bitstream_size_eval = ((size_aligned_width) * \
  1169. (size_aligned_height) * 3); \
  1170. if (rc_type == HFI_RC_LOSSLESS) { \
  1171. bitstream_size_eval = (bitstream_size_eval * 3 >> 2); \
  1172. } \
  1173. else if ((size_aligned_width * size_aligned_height) > \
  1174. (4096 * 2176)) { \
  1175. bitstream_size_eval >>= 3; \
  1176. } \
  1177. else if ((size_aligned_width * size_aligned_height) > \
  1178. (480 * 320)) { \
  1179. bitstream_size_eval >>= 2; \
  1180. } \
  1181. if (profile == HFI_H265_PROFILE_MAIN_10 || \
  1182. profile == HFI_H265_PROFILE_MAIN_10_STILL_PICTURE) { \
  1183. bitstream_size_eval = (bitstream_size_eval * 5 >> 2); \
  1184. } \
  1185. } \
  1186. } else { \
  1187. bitstream_size_eval = size_aligned_width * \
  1188. size_aligned_height * 3; \
  1189. } \
  1190. _size = HFI_ALIGN(bitstream_size_eval, VENUS_DMA_ALIGNMENT); \
  1191. } while (0)
  1192. #define SIZE_ENC_SINGLE_PIPE(size, rc_type, bitbin_size, num_vpp_pipes, \
  1193. frame_width, frame_height, lcu_size) \
  1194. do { \
  1195. HFI_U32 size_single_pipe_eval = 0, sao_bin_buffer_size = 0, \
  1196. _padded_bin_sz = 0; \
  1197. HFI_U32 size_aligned_width = 0, size_aligned_height = 0; \
  1198. size_aligned_width = HFI_ALIGN((frame_width), lcu_size); \
  1199. size_aligned_height = HFI_ALIGN((frame_height), lcu_size); \
  1200. if ((size_aligned_width * size_aligned_height) > \
  1201. (3840 * 2160)) { \
  1202. size_single_pipe_eval = (bitbin_size / num_vpp_pipes); \
  1203. } \
  1204. else if (num_vpp_pipes > 2) { \
  1205. size_single_pipe_eval = bitbin_size / 2; \
  1206. } else { \
  1207. size_single_pipe_eval = bitbin_size; \
  1208. } \
  1209. if (rc_type == HFI_RC_LOSSLESS) { \
  1210. size_single_pipe_eval = (size_single_pipe_eval << 1); \
  1211. } \
  1212. sao_bin_buffer_size = (64 * ((((frame_width) + \
  1213. BUFFER_ALIGNMENT_32_BYTES) * ((frame_height) +\
  1214. BUFFER_ALIGNMENT_32_BYTES)) >> 10)) + 384; \
  1215. _padded_bin_sz = HFI_ALIGN(size_single_pipe_eval, \
  1216. VENUS_DMA_ALIGNMENT);\
  1217. size_single_pipe_eval = sao_bin_buffer_size + _padded_bin_sz; \
  1218. size_single_pipe_eval = HFI_ALIGN(size_single_pipe_eval, \
  1219. VENUS_DMA_ALIGNMENT); \
  1220. size = size_single_pipe_eval; \
  1221. } while (0)
  1222. #define HFI_BUFFER_BIN_ENC(_size, rc_type, frame_width, frame_height, lcu_size, \
  1223. work_mode, num_vpp_pipes, profile, ring_buf_count) \
  1224. do { \
  1225. HFI_U32 bitstream_size = 0, total_bitbin_buffers = 0, \
  1226. size_single_pipe = 0, bitbin_size = 0; \
  1227. SIZE_BIN_BITSTREAM_ENC(bitstream_size, rc_type, frame_width, \
  1228. frame_height, work_mode, lcu_size, profile); \
  1229. if (work_mode == HFI_WORKMODE_2) { \
  1230. total_bitbin_buffers = (ring_buf_count > 3) ? ring_buf_count : 3; \
  1231. bitbin_size = bitstream_size * 17 / 10; \
  1232. bitbin_size = HFI_ALIGN(bitbin_size, \
  1233. VENUS_DMA_ALIGNMENT); \
  1234. } \
  1235. else if ((lcu_size == 16) || (num_vpp_pipes > 1)) { \
  1236. total_bitbin_buffers = 1; \
  1237. bitbin_size = bitstream_size; \
  1238. } \
  1239. if (total_bitbin_buffers > 0) { \
  1240. SIZE_ENC_SINGLE_PIPE(size_single_pipe, rc_type, bitbin_size, \
  1241. num_vpp_pipes, frame_width, frame_height, lcu_size); \
  1242. bitbin_size = size_single_pipe * num_vpp_pipes; \
  1243. _size = HFI_ALIGN(bitbin_size, VENUS_DMA_ALIGNMENT) * \
  1244. total_bitbin_buffers + 512; \
  1245. } \
  1246. else \
  1247. /* Avoid 512 Bytes allocation in case of 1Pipe HEVC Direct Mode*/ \
  1248. _size = 0; \
  1249. } while (0)
  1250. #define HFI_BUFFER_BIN_H264E(_size, rc_type, frame_width, frame_height, \
  1251. work_mode, num_vpp_pipes, profile, ring_buf_count) \
  1252. do { \
  1253. HFI_BUFFER_BIN_ENC(_size, rc_type, frame_width, frame_height, 16, \
  1254. work_mode, num_vpp_pipes, profile, ring_buf_count); \
  1255. } while (0)
  1256. #define HFI_BUFFER_BIN_H265E(_size, rc_type, frame_width, frame_height, \
  1257. work_mode, num_vpp_pipes, profile, ring_buf_count) \
  1258. do { \
  1259. HFI_BUFFER_BIN_ENC(_size, rc_type, frame_width, frame_height, 32,\
  1260. work_mode, num_vpp_pipes, profile, ring_buf_count); \
  1261. } while (0)
  1262. #define SIZE_ENC_SLICE_INFO_BUF(num_lcu_in_frame) HFI_ALIGN((256 + \
  1263. (num_lcu_in_frame << 4)), VENUS_DMA_ALIGNMENT)
  1264. #define SIZE_LINE_BUF_CTRL(frame_width_coded) \
  1265. HFI_ALIGN(frame_width_coded, VENUS_DMA_ALIGNMENT)
  1266. #define SIZE_LINE_BUF_CTRL_ID2(frame_width_coded) \
  1267. HFI_ALIGN(frame_width_coded, VENUS_DMA_ALIGNMENT)
  1268. #define SIZE_LINEBUFF_DATA(_size, is_ten_bit, frame_width_coded) \
  1269. do { \
  1270. _size = is_ten_bit ? (((((10 * (frame_width_coded) +\
  1271. 1024) + (VENUS_DMA_ALIGNMENT - 1)) & \
  1272. (~(VENUS_DMA_ALIGNMENT - 1))) * 1) + \
  1273. (((((10 * (frame_width_coded) + 1024) >> 1) + \
  1274. (VENUS_DMA_ALIGNMENT - 1)) & (~(VENUS_DMA_ALIGNMENT - 1))) * \
  1275. 2)) : (((((8 * (frame_width_coded) + 1024) + \
  1276. (VENUS_DMA_ALIGNMENT - 1)) \
  1277. & (~(VENUS_DMA_ALIGNMENT - 1))) * 1) + \
  1278. (((((8 * (frame_width_coded) +\
  1279. 1024) >> 1) + (VENUS_DMA_ALIGNMENT - 1)) & \
  1280. (~(VENUS_DMA_ALIGNMENT - 1))) * 2)); \
  1281. } while (0)
  1282. #define SIZE_LEFT_LINEBUFF_CTRL(_size, standard, frame_height_coded, \
  1283. num_vpp_pipes_enc) \
  1284. do { \
  1285. _size = (standard == HFI_CODEC_ENCODE_HEVC) ? \
  1286. (((frame_height_coded) + \
  1287. (BUF_SIZE_ALIGN_32)) / BUF_SIZE_ALIGN_32 * 4 * 16) : \
  1288. (((frame_height_coded) + 15) / 16 * 5 * 16); \
  1289. if ((num_vpp_pipes_enc) > 1) { \
  1290. _size += BUFFER_ALIGNMENT_512_BYTES; \
  1291. _size = HFI_ALIGN(_size, BUFFER_ALIGNMENT_512_BYTES) *\
  1292. (num_vpp_pipes_enc); \
  1293. } \
  1294. _size = HFI_ALIGN(_size, VENUS_DMA_ALIGNMENT); \
  1295. } while (0)
  1296. #define SIZE_LEFT_LINEBUFF_RECON_PIX(_size, is_ten_bit, frame_height_coded, \
  1297. num_vpp_pipes_enc) \
  1298. do { \
  1299. _size = (((is_ten_bit + 1) * 2 * (frame_height_coded) + \
  1300. VENUS_DMA_ALIGNMENT) + \
  1301. (VENUS_DMA_ALIGNMENT << (num_vpp_pipes_enc - 1)) - 1) & \
  1302. (~((VENUS_DMA_ALIGNMENT << (num_vpp_pipes_enc - 1)) - 1)) * 1; \
  1303. } while (0)
  1304. #define SIZE_TOP_LINEBUFF_CTRL_FE(_size, frame_width_coded, standard) \
  1305. do { \
  1306. _size = (standard == HFI_CODEC_ENCODE_HEVC) ? (64 * \
  1307. ((frame_width_coded) >> 5)) : (VENUS_DMA_ALIGNMENT + 16 * \
  1308. ((frame_width_coded) >> 4)); \
  1309. _size = HFI_ALIGN(_size, VENUS_DMA_ALIGNMENT); \
  1310. } while (0)
  1311. #define SIZE_LEFT_LINEBUFF_CTRL_FE(frame_height_coded, num_vpp_pipes_enc) \
  1312. ((((VENUS_DMA_ALIGNMENT + 64 * ((frame_height_coded) >> 4)) + \
  1313. (VENUS_DMA_ALIGNMENT << (num_vpp_pipes_enc - 1)) - 1) & \
  1314. (~((VENUS_DMA_ALIGNMENT << (num_vpp_pipes_enc - 1)) - 1)) * 1) * \
  1315. num_vpp_pipes_enc)
  1316. #define SIZE_LEFT_LINEBUFF_METADATA_RECON_Y(_size, frame_height_coded, \
  1317. is_ten_bit, num_vpp_pipes_enc) \
  1318. do { \
  1319. _size = ((VENUS_DMA_ALIGNMENT + 64 * ((frame_height_coded) / \
  1320. (8 * (is_ten_bit ? 4 : 8))))); \
  1321. _size = HFI_ALIGN(_size, VENUS_DMA_ALIGNMENT); \
  1322. _size = (_size * num_vpp_pipes_enc); \
  1323. } while (0)
  1324. #define SIZE_LEFT_LINEBUFF_METADATA_RECON_UV(_size, frame_height_coded, \
  1325. is_ten_bit, num_vpp_pipes_enc) \
  1326. do { \
  1327. _size = ((VENUS_DMA_ALIGNMENT + 64 * ((frame_height_coded) / \
  1328. (4 * (is_ten_bit ? 4 : 8))))); \
  1329. _size = HFI_ALIGN(_size, VENUS_DMA_ALIGNMENT); \
  1330. _size = (_size * num_vpp_pipes_enc); \
  1331. } while (0)
  1332. #define SIZE_LINEBUFF_RECON_PIX(_size, is_ten_bit, frame_width_coded) \
  1333. do { \
  1334. _size = ((is_ten_bit ? 3 : 2) * (frame_width_coded)); \
  1335. _size = HFI_ALIGN(_size, VENUS_DMA_ALIGNMENT); \
  1336. } while (0)
  1337. #define SIZE_SLICE_CMD_BUFFER (HFI_ALIGN(20480, VENUS_DMA_ALIGNMENT))
  1338. #define SIZE_SPS_PPS_SLICE_HDR (2048 + 4096)
  1339. #define SIZE_FRAME_RC_BUF_SIZE(_size, standard, frame_height_coded, \
  1340. num_vpp_pipes_enc) \
  1341. do { \
  1342. _size = (standard == HFI_CODEC_ENCODE_HEVC) ? (256 + 16 * \
  1343. (14 + ((((frame_height_coded) >> 5) + 7) >> 3))) : \
  1344. (256 + 16 * (14 + ((((frame_height_coded) >> 4) + 7) >> 3))); \
  1345. _size *= 11; \
  1346. if (num_vpp_pipes_enc > 1) { \
  1347. _size = HFI_ALIGN(_size, VENUS_DMA_ALIGNMENT) * \
  1348. num_vpp_pipes_enc;\
  1349. } \
  1350. _size = HFI_ALIGN(_size, BUFFER_ALIGNMENT_512_BYTES) * \
  1351. HFI_MAX_COL_FRAME; \
  1352. } while (0)
  1353. #define ENC_BITCNT_BUF_SIZE(num_lcu_in_frame) HFI_ALIGN((256 + \
  1354. (4 * (num_lcu_in_frame))), VENUS_DMA_ALIGNMENT)
  1355. #define ENC_BITMAP_BUF_SIZE(num_lcu_in_frame) HFI_ALIGN((256 + \
  1356. ((num_lcu_in_frame) >> 3)), VENUS_DMA_ALIGNMENT)
  1357. #define SIZE_LINE_BUF_SDE(frame_width_coded) HFI_ALIGN((256 + \
  1358. (16 * ((frame_width_coded) >> 4))), VENUS_DMA_ALIGNMENT)
  1359. #define SIZE_BSE_SLICE_CMD_BUF ((((8192 << 2) + 7) & (~7)) * 3)
  1360. #define SIZE_LAMBDA_LUT (256 * 11)
  1361. #define SIZE_OVERRIDE_BUF(num_lcumb) (HFI_ALIGN(((16 * (((num_lcumb) + 7)\
  1362. >> 3))), VENUS_DMA_ALIGNMENT) * 2)
  1363. #define SIZE_IR_BUF(num_lcu_in_frame) HFI_ALIGN((((((num_lcu_in_frame) << 1) + 7) &\
  1364. (~7)) * 3), VENUS_DMA_ALIGNMENT)
  1365. #define SIZE_VPSS_LINE_BUF(num_vpp_pipes_enc, frame_height_coded, \
  1366. frame_width_coded) \
  1367. (HFI_ALIGN(((((((8192) >> 2) << 5) * (num_vpp_pipes_enc)) + 64) + \
  1368. (((((MAX((frame_width_coded), (frame_height_coded)) + 3) >> 2) << 5) +\
  1369. 256) * 16)), VENUS_DMA_ALIGNMENT))
  1370. #define SIZE_TOP_LINE_BUF_FIRST_STG_SAO(frame_width_coded) \
  1371. HFI_ALIGN((16 * ((frame_width_coded) >> 5)), VENUS_DMA_ALIGNMENT)
  1372. #define HFI_BUFFER_LINE_ENC(_size, frame_width, frame_height, is_ten_bit, \
  1373. num_vpp_pipes_enc, lcu_size, standard) \
  1374. do { \
  1375. HFI_U32 width_in_lcus = 0, height_in_lcus = 0, \
  1376. frame_width_coded = 0, frame_height_coded = 0; \
  1377. HFI_U32 line_buff_data_size = 0, left_line_buff_ctrl_size = 0, \
  1378. left_line_buff_recon_pix_size = 0, \
  1379. top_line_buff_ctrl_fe_size = 0; \
  1380. HFI_U32 left_line_buff_metadata_recon__y__size = 0, \
  1381. left_line_buff_metadata_recon__uv__size = 0, \
  1382. line_buff_recon_pix_size = 0; \
  1383. width_in_lcus = ((frame_width) + (lcu_size)-1) / (lcu_size); \
  1384. height_in_lcus = ((frame_height) + (lcu_size)-1) / (lcu_size); \
  1385. frame_width_coded = width_in_lcus * (lcu_size); \
  1386. frame_height_coded = height_in_lcus * (lcu_size); \
  1387. SIZE_LINEBUFF_DATA(line_buff_data_size, is_ten_bit, \
  1388. frame_width_coded);\
  1389. SIZE_LEFT_LINEBUFF_CTRL(left_line_buff_ctrl_size, standard, \
  1390. frame_height_coded, num_vpp_pipes_enc); \
  1391. SIZE_LEFT_LINEBUFF_RECON_PIX(left_line_buff_recon_pix_size, \
  1392. is_ten_bit, frame_height_coded, num_vpp_pipes_enc); \
  1393. SIZE_TOP_LINEBUFF_CTRL_FE(top_line_buff_ctrl_fe_size, \
  1394. frame_width_coded, standard); \
  1395. SIZE_LEFT_LINEBUFF_METADATA_RECON_Y\
  1396. (left_line_buff_metadata_recon__y__size, \
  1397. frame_height_coded, is_ten_bit, num_vpp_pipes_enc); \
  1398. SIZE_LEFT_LINEBUFF_METADATA_RECON_UV\
  1399. (left_line_buff_metadata_recon__uv__size, \
  1400. frame_height_coded, is_ten_bit, num_vpp_pipes_enc); \
  1401. SIZE_LINEBUFF_RECON_PIX(line_buff_recon_pix_size, is_ten_bit,\
  1402. frame_width_coded); \
  1403. _size = SIZE_LINE_BUF_CTRL(frame_width_coded) + \
  1404. SIZE_LINE_BUF_CTRL_ID2(frame_width_coded) + \
  1405. line_buff_data_size + \
  1406. left_line_buff_ctrl_size + \
  1407. left_line_buff_recon_pix_size + \
  1408. top_line_buff_ctrl_fe_size + \
  1409. left_line_buff_metadata_recon__y__size + \
  1410. left_line_buff_metadata_recon__uv__size + \
  1411. line_buff_recon_pix_size + \
  1412. SIZE_LEFT_LINEBUFF_CTRL_FE(frame_height_coded, \
  1413. num_vpp_pipes_enc) + SIZE_LINE_BUF_SDE(frame_width_coded) + \
  1414. SIZE_VPSS_LINE_BUF(num_vpp_pipes_enc, frame_height_coded, \
  1415. frame_width_coded) + \
  1416. SIZE_TOP_LINE_BUF_FIRST_STG_SAO(frame_width_coded); \
  1417. } while (0)
  1418. #define HFI_BUFFER_LINE_H264E(_size, frame_width, frame_height, is_ten_bit, \
  1419. num_vpp_pipes) \
  1420. do { \
  1421. HFI_BUFFER_LINE_ENC(_size, frame_width, frame_height, 0, \
  1422. num_vpp_pipes, 16, HFI_CODEC_ENCODE_AVC); \
  1423. } while (0)
  1424. #define HFI_BUFFER_LINE_H265E(_size, frame_width, frame_height, is_ten_bit, \
  1425. num_vpp_pipes) \
  1426. do { \
  1427. HFI_BUFFER_LINE_ENC(_size, frame_width, frame_height, \
  1428. is_ten_bit, num_vpp_pipes, 32, HFI_CODEC_ENCODE_HEVC); \
  1429. } while (0)
  1430. #define HFI_BUFFER_COMV_ENC(_size, frame_width, frame_height, lcu_size, \
  1431. num_recon, standard) \
  1432. do { \
  1433. HFI_U32 size_colloc_mv = 0, size_colloc_rc = 0; \
  1434. HFI_U32 mb_width = ((frame_width) + 15) >> 4; \
  1435. HFI_U32 mb_height = ((frame_height) + 15) >> 4; \
  1436. HFI_U32 width_in_lcus = ((frame_width) + (lcu_size)-1) /\
  1437. (lcu_size); \
  1438. HFI_U32 height_in_lcus = ((frame_height) + (lcu_size)-1) / \
  1439. (lcu_size); \
  1440. HFI_U32 num_lcu_in_frame = width_in_lcus * height_in_lcus; \
  1441. size_colloc_mv = (standard == HFI_CODEC_ENCODE_HEVC) ? \
  1442. (16 * ((num_lcu_in_frame << 2) + BUFFER_ALIGNMENT_32_BYTES)) : \
  1443. (3 * 16 * (width_in_lcus * height_in_lcus +\
  1444. BUFFER_ALIGNMENT_32_BYTES)); \
  1445. size_colloc_mv = HFI_ALIGN(size_colloc_mv, \
  1446. VENUS_DMA_ALIGNMENT) * num_recon; \
  1447. size_colloc_rc = (((mb_width + 7) >> 3) * 16 * 2 * mb_height); \
  1448. size_colloc_rc = HFI_ALIGN(size_colloc_rc, \
  1449. VENUS_DMA_ALIGNMENT) * HFI_MAX_COL_FRAME; \
  1450. _size = size_colloc_mv + size_colloc_rc; \
  1451. } while (0)
  1452. #define HFI_BUFFER_COMV_H264E(_size, frame_width, frame_height, num_recon) \
  1453. do { \
  1454. HFI_BUFFER_COMV_ENC(_size, frame_width, frame_height, 16, \
  1455. num_recon, HFI_CODEC_ENCODE_AVC); \
  1456. } while (0)
  1457. #define HFI_BUFFER_COMV_H265E(_size, frame_width, frame_height, num_recon) \
  1458. do { \
  1459. HFI_BUFFER_COMV_ENC(_size, frame_width, frame_height, 32,\
  1460. num_recon, HFI_CODEC_ENCODE_HEVC); \
  1461. } while (0)
  1462. #define HFI_BUFFER_NON_COMV_ENC(_size, frame_width, frame_height, \
  1463. num_vpp_pipes_enc, lcu_size, standard) \
  1464. do { \
  1465. HFI_U32 width_in_lcus = 0, height_in_lcus = 0, \
  1466. frame_width_coded = 0, frame_height_coded = 0, \
  1467. num_lcu_in_frame = 0, num_lcumb = 0; \
  1468. HFI_U32 frame_rc_buf_size = 0; \
  1469. width_in_lcus = ((frame_width) + (lcu_size)-1) / (lcu_size); \
  1470. height_in_lcus = ((frame_height) + (lcu_size)-1) / (lcu_size); \
  1471. num_lcu_in_frame = width_in_lcus * height_in_lcus; \
  1472. frame_width_coded = width_in_lcus * (lcu_size); \
  1473. frame_height_coded = height_in_lcus * (lcu_size); \
  1474. num_lcumb = (frame_height_coded / lcu_size) * \
  1475. ((frame_width_coded + lcu_size * 8) / lcu_size); \
  1476. SIZE_FRAME_RC_BUF_SIZE(frame_rc_buf_size, standard, \
  1477. frame_height_coded, num_vpp_pipes_enc); \
  1478. _size = SIZE_ENC_SLICE_INFO_BUF(num_lcu_in_frame) + \
  1479. SIZE_SLICE_CMD_BUFFER + \
  1480. SIZE_SPS_PPS_SLICE_HDR + \
  1481. frame_rc_buf_size + \
  1482. ENC_BITCNT_BUF_SIZE(num_lcu_in_frame) + \
  1483. ENC_BITMAP_BUF_SIZE(num_lcu_in_frame) + \
  1484. SIZE_BSE_SLICE_CMD_BUF + \
  1485. SIZE_LAMBDA_LUT + \
  1486. SIZE_OVERRIDE_BUF(num_lcumb) + \
  1487. SIZE_IR_BUF(num_lcu_in_frame); \
  1488. } while (0)
  1489. #define HFI_BUFFER_NON_COMV_H264E(_size, frame_width, frame_height, \
  1490. num_vpp_pipes_enc) \
  1491. do { \
  1492. HFI_BUFFER_NON_COMV_ENC(_size, frame_width, frame_height, \
  1493. num_vpp_pipes_enc, 16, HFI_CODEC_ENCODE_AVC); \
  1494. } while (0)
  1495. #define SIZE_ONE_SLICE_BUF 256
  1496. #define HFI_BUFFER_NON_COMV_H265E(_size, frame_width, frame_height, \
  1497. num_vpp_pipes_enc) \
  1498. do { \
  1499. HFI_BUFFER_NON_COMV_ENC(_size, frame_width, frame_height, \
  1500. num_vpp_pipes_enc, 32, HFI_CODEC_ENCODE_HEVC); \
  1501. _size += SIZE_ONE_SLICE_BUF; \
  1502. } while (0)
  1503. #define SIZE_ENC_REF_BUFFER(size, frame_width, frame_height) \
  1504. do { \
  1505. HFI_U32 u_buffer_width = 0, u_buffer_height = 0, \
  1506. u_chroma_buffer_height = 0; \
  1507. u_buffer_height = HFI_ALIGN(frame_height, \
  1508. HFI_VENUS_HEIGHT_ALIGNMENT); \
  1509. u_chroma_buffer_height = frame_height >> 1; \
  1510. u_chroma_buffer_height = HFI_ALIGN(u_chroma_buffer_height, \
  1511. HFI_VENUS_HEIGHT_ALIGNMENT); \
  1512. u_buffer_width = HFI_ALIGN(frame_width, \
  1513. HFI_VENUS_WIDTH_ALIGNMENT); \
  1514. size = (u_buffer_height + u_chroma_buffer_height) * \
  1515. u_buffer_width; \
  1516. } while (0)
  1517. #define SIZE_ENC_TEN_BIT_REF_BUFFER(size, frame_width, frame_height) \
  1518. do { \
  1519. HFI_U32 ref_buf_height = 0, ref_luma_stride_in_bytes = 0, \
  1520. u_ref_stride = 0, luma_size = 0, ref_chrm_height_in_bytes = 0, \
  1521. chroma_size = 0, ref_buf_size = 0; \
  1522. ref_buf_height = (frame_height + \
  1523. (HFI_VENUS_HEIGHT_ALIGNMENT - 1)) \
  1524. & (~(HFI_VENUS_HEIGHT_ALIGNMENT - 1)); \
  1525. ref_luma_stride_in_bytes = ((frame_width + \
  1526. SYSTEM_LAL_TILE10 - 1) / SYSTEM_LAL_TILE10) * \
  1527. SYSTEM_LAL_TILE10; \
  1528. u_ref_stride = 4 * (ref_luma_stride_in_bytes / 3); \
  1529. u_ref_stride = (u_ref_stride + (BUF_SIZE_ALIGN_128 - 1)) &\
  1530. (~(BUF_SIZE_ALIGN_128 - 1)); \
  1531. luma_size = ref_buf_height * u_ref_stride; \
  1532. ref_chrm_height_in_bytes = (((frame_height + 1) >> 1) + \
  1533. (BUF_SIZE_ALIGN_32 - 1)) & (~(BUF_SIZE_ALIGN_32 - 1)); \
  1534. chroma_size = u_ref_stride * ref_chrm_height_in_bytes; \
  1535. luma_size = (luma_size + (BUF_SIZE_ALIGN_4096 - 1)) & \
  1536. (~(BUF_SIZE_ALIGN_4096 - 1)); \
  1537. chroma_size = (chroma_size + (BUF_SIZE_ALIGN_4096 - 1)) & \
  1538. (~(BUF_SIZE_ALIGN_4096 - 1)); \
  1539. ref_buf_size = luma_size + chroma_size; \
  1540. size = ref_buf_size; \
  1541. } while (0)
  1542. #define HFI_BUFFER_DPB_ENC(_size, frame_width, frame_height, is_ten_bit) \
  1543. do { \
  1544. HFI_U32 metadata_stride, metadata_buf_height, meta_size_y, \
  1545. meta_size_c; \
  1546. HFI_U32 ten_bit_ref_buf_size = 0, ref_buf_size = 0; \
  1547. if (!is_ten_bit) { \
  1548. SIZE_ENC_REF_BUFFER(ref_buf_size, frame_width, \
  1549. frame_height); \
  1550. HFI_UBWC_CALC_METADATA_PLANE_STRIDE(metadata_stride, \
  1551. (frame_width), 64, \
  1552. HFI_COLOR_FORMAT_YUV420_NV12_UBWC_Y_TILE_WIDTH); \
  1553. HFI_UBWC_METADATA_PLANE_BUFHEIGHT(metadata_buf_height, \
  1554. (frame_height), 16, \
  1555. HFI_COLOR_FORMAT_YUV420_NV12_UBWC_Y_TILE_HEIGHT); \
  1556. HFI_UBWC_METADATA_PLANE_BUFFER_SIZE(meta_size_y, \
  1557. metadata_stride, metadata_buf_height); \
  1558. HFI_UBWC_METADATA_PLANE_BUFFER_SIZE(meta_size_c, \
  1559. metadata_stride, metadata_buf_height); \
  1560. _size = ref_buf_size + meta_size_y + meta_size_c; \
  1561. } else { \
  1562. SIZE_ENC_TEN_BIT_REF_BUFFER(ten_bit_ref_buf_size, \
  1563. frame_width, frame_height); \
  1564. HFI_UBWC_CALC_METADATA_PLANE_STRIDE(metadata_stride, \
  1565. frame_width, VENUS_METADATA_STRIDE_MULTIPLE, \
  1566. HFI_COLOR_FORMAT_YUV420_TP10_UBWC_Y_TILE_WIDTH); \
  1567. HFI_UBWC_METADATA_PLANE_BUFHEIGHT(metadata_buf_height, \
  1568. frame_height, VENUS_METADATA_HEIGHT_MULTIPLE, \
  1569. HFI_COLOR_FORMAT_YUV420_TP10_UBWC_Y_TILE_HEIGHT); \
  1570. HFI_UBWC_METADATA_PLANE_BUFFER_SIZE(meta_size_y, \
  1571. metadata_stride, metadata_buf_height); \
  1572. HFI_UBWC_METADATA_PLANE_BUFFER_SIZE(meta_size_c, \
  1573. metadata_stride, metadata_buf_height); \
  1574. _size = ten_bit_ref_buf_size + meta_size_y + \
  1575. meta_size_c; \
  1576. } \
  1577. } while (0)
  1578. #define HFI_BUFFER_DPB_H264E(_size, frame_width, frame_height) \
  1579. do { \
  1580. HFI_BUFFER_DPB_ENC(_size, frame_width, frame_height, 0); \
  1581. } while (0)
  1582. #define HFI_BUFFER_DPB_H265E(_size, frame_width, frame_height, is_ten_bit) \
  1583. do { \
  1584. HFI_BUFFER_DPB_ENC(_size, frame_width, frame_height, is_ten_bit); \
  1585. } while (0)
  1586. #define HFI_BUFFER_VPSS_ENC(vpss_size, dswidth, dsheight, ds_enable, blur, is_ten_bit) \
  1587. do { \
  1588. vpss_size = 0; \
  1589. if (ds_enable || blur) { \
  1590. HFI_BUFFER_DPB_ENC(vpss_size, dswidth, dsheight, is_ten_bit); \
  1591. } \
  1592. } while (0)
  1593. #define HFI_IRIS3_ENC_MIN_INPUT_BUF_COUNT(numInput, TotalHBLayers) \
  1594. do { \
  1595. numInput = 3; \
  1596. if (TotalHBLayers >= 2) { \
  1597. numInput = (1 << (TotalHBLayers - 1)) + 2; \
  1598. } \
  1599. } while (0)
  1600. #endif /* __HFI_BUFFER_IRIS3_3__ */