hfi_buffer_iris3.h 70 KB

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