hfi_buffer_iris33.h 70 KB

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