hfi_buffer_iris33.h 70 KB

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