hfi_buffer_iris3.h 71 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2021-2023 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) * 48), 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) * 48), H264D_MAX_SLICE) * \
  319. SIZE_H264D_VPP_CMD_PER_BUF; \
  320. if (_size > VPP_CMD_MAX_SIZE) { _size = VPP_CMD_MAX_SIZE; } \
  321. } while (0)
  322. #define HFI_BUFFER_COMV_H264D(coMV_size, frame_width, \
  323. frame_height, _comv_bufcount) \
  324. do \
  325. { \
  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 * (_comv_bufcount); \
  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. _comv_bufcount) \
  514. do \
  515. { \
  516. _size = HFI_ALIGN(((((frame_width + 15) >> 4) * \
  517. ((frame_height + 15) >> 4)) << 8), \
  518. BUFFER_ALIGNMENT_512_BYTES); \
  519. _size *= _comv_bufcount; \
  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. _comv_bufcount) \
  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 *= _comv_bufcount; \
  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, yuv_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. yuv_size = (aligned_width * aligned_height * 3) >> 1; \
  1053. if (aligned_width * aligned_height > (4096 * 2176)) \
  1054. { \
  1055. /* bitstream_size = 0.25 * yuv_size; */ \
  1056. bitstream_size = (bitstream_size >> 3); \
  1057. } \
  1058. else if (aligned_width * aligned_height > (1280 * 720)) \
  1059. { \
  1060. /* bitstream_size = 0.5 * yuv_size; */ \
  1061. bitstream_size = (bitstream_size >> 2); \
  1062. } \
  1063. else \
  1064. { \
  1065. /* bitstream_size = 2 * yuv_size; */ \
  1066. } \
  1067. if (((rc_type == HFI_RC_CQ) || (rc_type == HFI_RC_OFF)) && (bitstream_size < yuv_size)) \
  1068. { \
  1069. bitstream_size = (bitstream_size << 1);\
  1070. } \
  1071. if (is_ten_bit) \
  1072. { \
  1073. bitstream_size = (bitstream_size) + \
  1074. (bitstream_size >> 2); \
  1075. } \
  1076. size = HFI_ALIGN(bitstream_size, HFI_ALIGNMENT_4096); \
  1077. } while (0)
  1078. #define HFI_IRIS3_ENC_TILE_SIZE_INFO(tile_size, tile_count, last_tile_size, \
  1079. frame_width_coded, codec_standard) \
  1080. do \
  1081. { \
  1082. HFI_U32 without_tile_enc_width; \
  1083. HFI_U32 min_tile_size = 352, fixed_tile_width = 960; \
  1084. without_tile_enc_width = min_tile_size + fixed_tile_width; \
  1085. if ((codec_standard == HFI_CODEC_ENCODE_HEVC) && \
  1086. (frame_width_coded > without_tile_enc_width)) \
  1087. { \
  1088. tile_size = fixed_tile_width; \
  1089. tile_count = (frame_width_coded + tile_size - 1) / tile_size; \
  1090. last_tile_size = (frame_width_coded - (tile_size * (tile_count - 1))); \
  1091. if (last_tile_size < min_tile_size) \
  1092. { \
  1093. tile_count -= 1; \
  1094. last_tile_size = (tile_size + min_tile_size); \
  1095. } \
  1096. } \
  1097. else \
  1098. { \
  1099. tile_size = frame_width_coded; \
  1100. tile_count = 1; \
  1101. last_tile_size = 0; \
  1102. } \
  1103. } while (0)
  1104. #define HFI_IRIS3_ENC_MB_BASED_MULTI_SLICE_COUNT(total_slice_count, frame_width, frame_height, \
  1105. codec_standard, multi_slice_max_mb_count) \
  1106. do \
  1107. { \
  1108. HFI_U32 tile_size, tile_count, last_tile_size, \
  1109. slice_count_per_tile, slice_count_in_last_tile; \
  1110. HFI_U32 mbs_in_one_tile, mbs_in_last_tile; \
  1111. HFI_U32 frame_width_coded, frame_height_coded, lcu_size; \
  1112. lcu_size = (codec_standard == HFI_CODEC_ENCODE_HEVC) ? 32 : 16; \
  1113. frame_width_coded = HFI_ALIGN(frame_width, lcu_size); \
  1114. frame_height_coded = HFI_ALIGN(frame_height, lcu_size); \
  1115. HFI_IRIS3_ENC_TILE_SIZE_INFO(tile_size, tile_count, last_tile_size, \
  1116. frame_width_coded, codec_standard); \
  1117. mbs_in_one_tile = (tile_size * frame_height_coded) / (lcu_size * lcu_size); \
  1118. slice_count_per_tile = \
  1119. (mbs_in_one_tile + multi_slice_max_mb_count - 1) / (multi_slice_max_mb_count); \
  1120. if (last_tile_size) \
  1121. { \
  1122. mbs_in_last_tile = \
  1123. (last_tile_size * frame_height_coded) / (lcu_size * lcu_size); \
  1124. slice_count_in_last_tile = \
  1125. (mbs_in_last_tile + multi_slice_max_mb_count - 1) / (multi_slice_max_mb_count); \
  1126. total_slice_count = \
  1127. (slice_count_per_tile * (tile_count - 1)) + slice_count_in_last_tile; \
  1128. } \
  1129. else \
  1130. { \
  1131. total_slice_count = (slice_count_per_tile * tile_count); \
  1132. } \
  1133. } while (0)
  1134. #define SIZE_ROI_METADATA_ENC(size_roi, frame_width, frame_height, lcu_size)\
  1135. do \
  1136. { \
  1137. HFI_U32 width_in_lcus = 0, height_in_lcus = 0, n_shift = 0; \
  1138. while (lcu_size && !(lcu_size & 0x1)) \
  1139. { \
  1140. n_shift++; \
  1141. lcu_size = lcu_size >> 1; \
  1142. } \
  1143. width_in_lcus = (frame_width + (lcu_size - 1)) >> n_shift; \
  1144. height_in_lcus = (frame_height + (lcu_size - 1)) >> n_shift; \
  1145. size_roi = (((width_in_lcus + 7) >> 3) << 3) * \
  1146. height_in_lcus * 2 + 256; \
  1147. } while (0)
  1148. #define HFI_BUFFER_INPUT_METADATA_ENC(size, frame_width, frame_height, \
  1149. is_roi_enabled, lcu_size) \
  1150. do \
  1151. { \
  1152. HFI_U32 roi_size = 0; \
  1153. if (is_roi_enabled) \
  1154. { \
  1155. SIZE_ROI_METADATA_ENC(roi_size, frame_width, \
  1156. frame_height, lcu_size); \
  1157. } \
  1158. size = roi_size + 16384; \
  1159. size = HFI_ALIGN(size, HFI_ALIGNMENT_4096); \
  1160. } while (0)
  1161. #define HFI_BUFFER_INPUT_METADATA_H264E(size_metadata, frame_width, \
  1162. frame_height, is_roi_enabled) \
  1163. do \
  1164. { \
  1165. HFI_BUFFER_INPUT_METADATA_ENC(size_metadata, frame_width, \
  1166. frame_height, is_roi_enabled, 16); \
  1167. }while (0)
  1168. #define HFI_BUFFER_INPUT_METADATA_H265E(size_metadata, frame_width, \
  1169. frame_height, is_roi_enabled) \
  1170. do \
  1171. { \
  1172. HFI_BUFFER_INPUT_METADATA_ENC(size_metadata, frame_width, \
  1173. frame_height, is_roi_enabled, 32); \
  1174. } while (0)
  1175. #define HFI_BUFFER_ARP_ENC(size) \
  1176. do \
  1177. { \
  1178. size = 204800; \
  1179. } while (0)
  1180. #define HFI_MAX_COL_FRAME 6
  1181. #define HFI_VENUS_VENC_TRE_WB_BUFF_SIZE (65 << 4) // bytes
  1182. #define HFI_VENUS_VENC_DB_LINE_BUFF_PER_MB 512
  1183. #define HFI_VENUS_VPPSG_MAX_REGISTERS 2048
  1184. #define HFI_VENUS_WIDTH_ALIGNMENT 128
  1185. #define HFI_VENUS_WIDTH_TEN_BIT_ALIGNMENT 192
  1186. #define HFI_VENUS_HEIGHT_ALIGNMENT 32
  1187. #define VENUS_METADATA_STRIDE_MULTIPLE 64
  1188. #define VENUS_METADATA_HEIGHT_MULTIPLE 16
  1189. #ifndef SYSTEM_LAL_TILE10
  1190. #define SYSTEM_LAL_TILE10 192
  1191. #endif
  1192. #define HFI_IRIS3_ENC_RECON_BUF_COUNT(num_recon, n_bframe, ltr_count, \
  1193. _total_hp_layers, _total_hb_layers, hybrid_hp, codec_standard) \
  1194. do \
  1195. { \
  1196. HFI_U32 num_ref = 1; \
  1197. if (n_bframe) \
  1198. num_ref = 2; \
  1199. if (_total_hp_layers > 1) \
  1200. { \
  1201. if (hybrid_hp) \
  1202. num_ref = (_total_hp_layers + 1) >> 1; \
  1203. else if (codec_standard == HFI_CODEC_ENCODE_HEVC) \
  1204. num_ref = (_total_hp_layers + 1) >> 1; \
  1205. else if (codec_standard == HFI_CODEC_ENCODE_AVC && \
  1206. _total_hp_layers < 4) \
  1207. num_ref = (_total_hp_layers - 1); \
  1208. else \
  1209. num_ref = _total_hp_layers; \
  1210. } \
  1211. if (ltr_count) \
  1212. num_ref = num_ref + ltr_count; \
  1213. if (_total_hb_layers > 1) \
  1214. { \
  1215. if (codec_standard == HFI_CODEC_ENCODE_HEVC) \
  1216. num_ref = (_total_hb_layers); \
  1217. else if (codec_standard == HFI_CODEC_ENCODE_AVC) \
  1218. num_ref = (1 << (_total_hb_layers - 2)) + 1; \
  1219. } \
  1220. num_recon = num_ref + 1; \
  1221. } while (0)
  1222. #define SIZE_BIN_BITSTREAM_ENC(_size, rc_type, frame_width, frame_height, \
  1223. work_mode, lcu_size, profile) \
  1224. do \
  1225. { \
  1226. HFI_U32 size_aligned_width = 0, size_aligned_height = 0; \
  1227. HFI_U32 bitstream_size_eval = 0; \
  1228. size_aligned_width = HFI_ALIGN((frame_width), lcu_size); \
  1229. size_aligned_height = HFI_ALIGN((frame_height), lcu_size); \
  1230. if (work_mode == HFI_WORKMODE_2) \
  1231. { \
  1232. if ((rc_type == HFI_RC_CQ) || (rc_type == HFI_RC_OFF)) \
  1233. { \
  1234. bitstream_size_eval = (((size_aligned_width) * \
  1235. (size_aligned_height) * 3) >> 1); \
  1236. } \
  1237. else \
  1238. { \
  1239. bitstream_size_eval = ((size_aligned_width) * \
  1240. (size_aligned_height) * 3); \
  1241. if (rc_type == HFI_RC_LOSSLESS) \
  1242. { \
  1243. bitstream_size_eval = (bitstream_size_eval * 3 >> 2); \
  1244. } \
  1245. else if ((size_aligned_width * size_aligned_height) > \
  1246. (4096 * 2176)) \
  1247. { \
  1248. bitstream_size_eval >>= 3; \
  1249. } \
  1250. else if ((size_aligned_width * size_aligned_height) > (480 * 320)) \
  1251. { \
  1252. bitstream_size_eval >>= 2; \
  1253. } \
  1254. if (profile == HFI_H265_PROFILE_MAIN_10 || \
  1255. profile == HFI_H265_PROFILE_MAIN_10_STILL_PICTURE) \
  1256. { \
  1257. bitstream_size_eval = (bitstream_size_eval * 5 >> 2); \
  1258. } \
  1259. } \
  1260. } \
  1261. else \
  1262. { \
  1263. bitstream_size_eval = size_aligned_width * \
  1264. size_aligned_height * 3; \
  1265. } \
  1266. _size = HFI_ALIGN(bitstream_size_eval, VENUS_DMA_ALIGNMENT); \
  1267. } while (0)
  1268. #define SIZE_ENC_SINGLE_PIPE(size, rc_type, bitbin_size, num_vpp_pipes, \
  1269. frame_width, frame_height, lcu_size) \
  1270. do \
  1271. { \
  1272. HFI_U32 size_single_pipe_eval = 0, sao_bin_buffer_size = 0, \
  1273. _padded_bin_sz = 0; \
  1274. HFI_U32 size_aligned_width = 0, size_aligned_height = 0; \
  1275. size_aligned_width = HFI_ALIGN((frame_width), lcu_size); \
  1276. size_aligned_height = HFI_ALIGN((frame_height), lcu_size); \
  1277. if ((size_aligned_width * size_aligned_height) > \
  1278. (3840 * 2160)) \
  1279. { \
  1280. size_single_pipe_eval = (bitbin_size / num_vpp_pipes); \
  1281. } \
  1282. else if (num_vpp_pipes > 2) \
  1283. { \
  1284. size_single_pipe_eval = bitbin_size / 2; \
  1285. } \
  1286. else \
  1287. { \
  1288. size_single_pipe_eval = bitbin_size; \
  1289. } \
  1290. if (rc_type == HFI_RC_LOSSLESS) \
  1291. { \
  1292. size_single_pipe_eval = (size_single_pipe_eval << 1); \
  1293. } \
  1294. sao_bin_buffer_size = (64 * ((((frame_width) + \
  1295. BUFFER_ALIGNMENT_32_BYTES) * ((frame_height) +\
  1296. BUFFER_ALIGNMENT_32_BYTES)) >> 10)) + 384; \
  1297. _padded_bin_sz = HFI_ALIGN(size_single_pipe_eval, \
  1298. VENUS_DMA_ALIGNMENT);\
  1299. size_single_pipe_eval = sao_bin_buffer_size + _padded_bin_sz; \
  1300. size_single_pipe_eval = HFI_ALIGN(size_single_pipe_eval, \
  1301. VENUS_DMA_ALIGNMENT); \
  1302. size = size_single_pipe_eval; \
  1303. } while (0)
  1304. #define HFI_BUFFER_BIN_ENC(_size, rc_type, frame_width, frame_height, lcu_size, \
  1305. work_mode, num_vpp_pipes, profile) \
  1306. do \
  1307. { \
  1308. HFI_U32 bitstream_size = 0, total_bitbin_buffers = 0, \
  1309. size_single_pipe = 0, bitbin_size = 0; \
  1310. SIZE_BIN_BITSTREAM_ENC(bitstream_size, rc_type, frame_width, \
  1311. frame_height, work_mode, lcu_size, profile); \
  1312. if (work_mode == HFI_WORKMODE_2) \
  1313. { \
  1314. total_bitbin_buffers = 3; \
  1315. bitbin_size = bitstream_size * 12 / 10; \
  1316. bitbin_size = HFI_ALIGN(bitbin_size, \
  1317. VENUS_DMA_ALIGNMENT); \
  1318. } \
  1319. else if ((lcu_size == 16) || (num_vpp_pipes > 1)) \
  1320. { \
  1321. total_bitbin_buffers = 1; \
  1322. bitbin_size = bitstream_size; \
  1323. } \
  1324. if (total_bitbin_buffers > 0) \
  1325. { \
  1326. SIZE_ENC_SINGLE_PIPE(size_single_pipe, rc_type, bitbin_size, \
  1327. num_vpp_pipes, frame_width, frame_height, lcu_size); \
  1328. bitbin_size = size_single_pipe * num_vpp_pipes; \
  1329. _size = HFI_ALIGN(bitbin_size, VENUS_DMA_ALIGNMENT) * \
  1330. total_bitbin_buffers + 512; \
  1331. } \
  1332. else \
  1333. /* Avoid 512 Bytes allocation in case of 1Pipe HEVC Direct Mode*/\
  1334. { \
  1335. _size = 0; \
  1336. } \
  1337. } while (0)
  1338. #define HFI_BUFFER_BIN_H264E(_size, rc_type, frame_width, frame_height, \
  1339. work_mode, num_vpp_pipes, profile) \
  1340. do \
  1341. { \
  1342. HFI_BUFFER_BIN_ENC(_size, rc_type, frame_width, frame_height, 16, \
  1343. work_mode, num_vpp_pipes, profile); \
  1344. } while (0)
  1345. #define HFI_BUFFER_BIN_H265E(_size, rc_type, frame_width, frame_height, \
  1346. work_mode, num_vpp_pipes, profile) \
  1347. do \
  1348. { \
  1349. HFI_BUFFER_BIN_ENC(_size, rc_type, frame_width, frame_height, 32,\
  1350. work_mode, num_vpp_pipes, profile); \
  1351. } while (0)
  1352. #define SIZE_ENC_SLICE_INFO_BUF(num_lcu_in_frame) HFI_ALIGN((256 + \
  1353. (num_lcu_in_frame << 4)), VENUS_DMA_ALIGNMENT)
  1354. #define SIZE_LINE_BUF_CTRL(frame_width_coded) \
  1355. HFI_ALIGN(frame_width_coded, VENUS_DMA_ALIGNMENT)
  1356. #define SIZE_LINE_BUF_CTRL_ID2(frame_width_coded) \
  1357. HFI_ALIGN(frame_width_coded, VENUS_DMA_ALIGNMENT)
  1358. #define SIZE_LINEBUFF_DATA(_size, is_ten_bit, frame_width_coded) \
  1359. do \
  1360. { \
  1361. _size = is_ten_bit ? (((((10 * (frame_width_coded) +\
  1362. 1024) + (VENUS_DMA_ALIGNMENT - 1)) & \
  1363. (~(VENUS_DMA_ALIGNMENT - 1))) * 1) + \
  1364. (((((10 * (frame_width_coded) + 1024) >> 1) + \
  1365. (VENUS_DMA_ALIGNMENT - 1)) & (~(VENUS_DMA_ALIGNMENT - 1))) * \
  1366. 2)) : (((((8 * (frame_width_coded) + 1024) + \
  1367. (VENUS_DMA_ALIGNMENT - 1)) \
  1368. & (~(VENUS_DMA_ALIGNMENT - 1))) * 1) + \
  1369. (((((8 * (frame_width_coded) +\
  1370. 1024) >> 1) + (VENUS_DMA_ALIGNMENT - 1)) & \
  1371. (~(VENUS_DMA_ALIGNMENT - 1))) * 2)); \
  1372. } while (0)
  1373. #define SIZE_LEFT_LINEBUFF_CTRL(_size, standard, frame_height_coded, \
  1374. num_vpp_pipes_enc) \
  1375. do \
  1376. { \
  1377. _size = (standard == HFI_CODEC_ENCODE_HEVC) ? \
  1378. (((frame_height_coded) + \
  1379. (BUF_SIZE_ALIGN_32)) / BUF_SIZE_ALIGN_32 * 4 * 16) : \
  1380. (((frame_height_coded) + 15) / 16 * 5 * 16); \
  1381. if ((num_vpp_pipes_enc) > 1) \
  1382. { \
  1383. _size += BUFFER_ALIGNMENT_512_BYTES; \
  1384. _size = HFI_ALIGN(_size, BUFFER_ALIGNMENT_512_BYTES) *\
  1385. (num_vpp_pipes_enc); \
  1386. } \
  1387. _size = HFI_ALIGN(_size, VENUS_DMA_ALIGNMENT); \
  1388. } while (0)
  1389. #define SIZE_LEFT_LINEBUFF_RECON_PIX(_size, is_ten_bit, frame_height_coded, \
  1390. num_vpp_pipes_enc) \
  1391. do \
  1392. { \
  1393. _size = (((is_ten_bit + 1) * 2 * (frame_height_coded) + \
  1394. VENUS_DMA_ALIGNMENT) + \
  1395. (VENUS_DMA_ALIGNMENT << (num_vpp_pipes_enc - 1)) - 1) & \
  1396. (~((VENUS_DMA_ALIGNMENT << (num_vpp_pipes_enc - 1)) - 1)) * 1; \
  1397. } while (0)
  1398. #define SIZE_TOP_LINEBUFF_CTRL_FE(_size, frame_width_coded, standard) \
  1399. do \
  1400. { \
  1401. _size = (standard == HFI_CODEC_ENCODE_HEVC) ? (64 * \
  1402. ((frame_width_coded) >> 5)) : (VENUS_DMA_ALIGNMENT + 16 * \
  1403. ((frame_width_coded) >> 4)); \
  1404. _size = HFI_ALIGN(_size, VENUS_DMA_ALIGNMENT); \
  1405. } while (0)
  1406. #define SIZE_LEFT_LINEBUFF_CTRL_FE(frame_height_coded, num_vpp_pipes_enc) \
  1407. ((((VENUS_DMA_ALIGNMENT + 64 * ((frame_height_coded) >> 4)) + \
  1408. (VENUS_DMA_ALIGNMENT << (num_vpp_pipes_enc - 1)) - 1) & \
  1409. (~((VENUS_DMA_ALIGNMENT << (num_vpp_pipes_enc - 1)) - 1)) * 1) * \
  1410. num_vpp_pipes_enc)
  1411. #define SIZE_LEFT_LINEBUFF_METADATA_RECON_Y(_size, frame_height_coded, \
  1412. is_ten_bit, num_vpp_pipes_enc) \
  1413. do \
  1414. { \
  1415. _size = ((VENUS_DMA_ALIGNMENT + 64 * ((frame_height_coded) / \
  1416. (8 * (is_ten_bit ? 4 : 8))))); \
  1417. _size = HFI_ALIGN(_size, VENUS_DMA_ALIGNMENT); \
  1418. _size = (_size * num_vpp_pipes_enc); \
  1419. } while (0)
  1420. #define SIZE_LEFT_LINEBUFF_METADATA_RECON_UV(_size, frame_height_coded, \
  1421. is_ten_bit, num_vpp_pipes_enc) \
  1422. do \
  1423. { \
  1424. _size = ((VENUS_DMA_ALIGNMENT + 64 * ((frame_height_coded) / \
  1425. (4 * (is_ten_bit ? 4 : 8))))); \
  1426. _size = HFI_ALIGN(_size, VENUS_DMA_ALIGNMENT); \
  1427. _size = (_size * num_vpp_pipes_enc); \
  1428. } while (0)
  1429. #define SIZE_LINEBUFF_RECON_PIX(_size, is_ten_bit, frame_width_coded) \
  1430. do \
  1431. { \
  1432. _size = ((is_ten_bit ? 3 : 2) * (frame_width_coded)); \
  1433. _size = HFI_ALIGN(_size, VENUS_DMA_ALIGNMENT); \
  1434. } while (0)
  1435. #define SIZE_SLICE_CMD_BUFFER (HFI_ALIGN(20480, VENUS_DMA_ALIGNMENT))
  1436. #define SIZE_SPS_PPS_SLICE_HDR (2048 + 4096)
  1437. #define SIZE_FRAME_RC_BUF_SIZE(_size, standard, frame_height_coded, \
  1438. num_vpp_pipes_enc) \
  1439. do \
  1440. { \
  1441. _size = (standard == HFI_CODEC_ENCODE_HEVC) ? (256 + 16 * \
  1442. (14 + ((((frame_height_coded) >> 5) + 7) >> 3))) : \
  1443. (256 + 16 * (14 + ((((frame_height_coded) >> 4) + 7) >> 3))); \
  1444. _size *= 11; \
  1445. if (num_vpp_pipes_enc > 1) \
  1446. { \
  1447. _size = HFI_ALIGN(_size, VENUS_DMA_ALIGNMENT) * \
  1448. num_vpp_pipes_enc;\
  1449. } \
  1450. _size = HFI_ALIGN(_size, BUFFER_ALIGNMENT_512_BYTES) * \
  1451. HFI_MAX_COL_FRAME; \
  1452. } while (0)
  1453. #define ENC_BITCNT_BUF_SIZE(num_lcu_in_frame) HFI_ALIGN((256 + \
  1454. (4 * (num_lcu_in_frame))), VENUS_DMA_ALIGNMENT)
  1455. #define ENC_BITMAP_BUF_SIZE(num_lcu_in_frame) HFI_ALIGN((256 + \
  1456. ((num_lcu_in_frame) >> 3)), VENUS_DMA_ALIGNMENT)
  1457. #define SIZE_LINE_BUF_SDE(frame_width_coded) HFI_ALIGN((256 + \
  1458. (16 * ((frame_width_coded) >> 4))), VENUS_DMA_ALIGNMENT)
  1459. #define SIZE_BSE_SLICE_CMD_BUF ((((8192 << 2) + 7) & (~7)) * 3)
  1460. #define SIZE_LAMBDA_LUT (256 * 11)
  1461. #define SIZE_OVERRIDE_BUF(num_lcumb) (HFI_ALIGN(((16 * (((num_lcumb) + 7)\
  1462. >> 3))), VENUS_DMA_ALIGNMENT) * 2)
  1463. #define SIZE_IR_BUF(num_lcu_in_frame) HFI_ALIGN((((((num_lcu_in_frame) << 1) + 7) &\
  1464. (~7)) * 3), VENUS_DMA_ALIGNMENT)
  1465. #define SIZE_VPSS_LINE_BUF(num_vpp_pipes_enc, frame_height_coded, \
  1466. frame_width_coded) \
  1467. (HFI_ALIGN(((((((8192) >> 2) << 5) * (num_vpp_pipes_enc)) + 64) + \
  1468. (((((MAX((frame_width_coded), (frame_height_coded)) + 3) >> 2) << 5) +\
  1469. 256) * 16)), VENUS_DMA_ALIGNMENT))
  1470. #define SIZE_TOP_LINE_BUF_FIRST_STG_SAO(frame_width_coded) \
  1471. HFI_ALIGN((16 * ((frame_width_coded) >> 5)), VENUS_DMA_ALIGNMENT)
  1472. #define HFI_BUFFER_LINE_ENC(_size, frame_width, frame_height, is_ten_bit, \
  1473. num_vpp_pipes_enc, lcu_size, standard) \
  1474. do \
  1475. { \
  1476. HFI_U32 width_in_lcus = 0, height_in_lcus = 0, \
  1477. frame_width_coded = 0, frame_height_coded = 0; \
  1478. HFI_U32 line_buff_data_size = 0, left_line_buff_ctrl_size = 0, \
  1479. left_line_buff_recon_pix_size = 0, \
  1480. top_line_buff_ctrl_fe_size = 0; \
  1481. HFI_U32 left_line_buff_metadata_recon__y__size = 0, \
  1482. left_line_buff_metadata_recon__uv__size = 0, \
  1483. line_buff_recon_pix_size = 0; \
  1484. width_in_lcus = ((frame_width) + (lcu_size)-1) / (lcu_size); \
  1485. height_in_lcus = ((frame_height) + (lcu_size)-1) / (lcu_size); \
  1486. frame_width_coded = width_in_lcus * (lcu_size); \
  1487. frame_height_coded = height_in_lcus * (lcu_size); \
  1488. SIZE_LINEBUFF_DATA(line_buff_data_size, is_ten_bit, \
  1489. frame_width_coded);\
  1490. SIZE_LEFT_LINEBUFF_CTRL(left_line_buff_ctrl_size, standard, \
  1491. frame_height_coded, num_vpp_pipes_enc); \
  1492. SIZE_LEFT_LINEBUFF_RECON_PIX(left_line_buff_recon_pix_size, \
  1493. is_ten_bit, frame_height_coded, num_vpp_pipes_enc); \
  1494. SIZE_TOP_LINEBUFF_CTRL_FE(top_line_buff_ctrl_fe_size, \
  1495. frame_width_coded, standard); \
  1496. SIZE_LEFT_LINEBUFF_METADATA_RECON_Y\
  1497. (left_line_buff_metadata_recon__y__size, \
  1498. frame_height_coded, is_ten_bit, num_vpp_pipes_enc); \
  1499. SIZE_LEFT_LINEBUFF_METADATA_RECON_UV\
  1500. (left_line_buff_metadata_recon__uv__size, \
  1501. frame_height_coded, is_ten_bit, num_vpp_pipes_enc); \
  1502. SIZE_LINEBUFF_RECON_PIX(line_buff_recon_pix_size, is_ten_bit,\
  1503. frame_width_coded); \
  1504. _size = SIZE_LINE_BUF_CTRL(frame_width_coded) + \
  1505. SIZE_LINE_BUF_CTRL_ID2(frame_width_coded) + \
  1506. line_buff_data_size + \
  1507. left_line_buff_ctrl_size + \
  1508. left_line_buff_recon_pix_size + \
  1509. top_line_buff_ctrl_fe_size + \
  1510. left_line_buff_metadata_recon__y__size + \
  1511. left_line_buff_metadata_recon__uv__size + \
  1512. line_buff_recon_pix_size + \
  1513. SIZE_LEFT_LINEBUFF_CTRL_FE(frame_height_coded, \
  1514. num_vpp_pipes_enc) + SIZE_LINE_BUF_SDE(frame_width_coded) + \
  1515. SIZE_VPSS_LINE_BUF(num_vpp_pipes_enc, frame_height_coded, \
  1516. frame_width_coded) + \
  1517. SIZE_TOP_LINE_BUF_FIRST_STG_SAO(frame_width_coded); \
  1518. } while (0)
  1519. #define HFI_BUFFER_LINE_H264E(_size, frame_width, frame_height, is_ten_bit, \
  1520. num_vpp_pipes) \
  1521. do \
  1522. { \
  1523. HFI_BUFFER_LINE_ENC(_size, frame_width, frame_height, 0, \
  1524. num_vpp_pipes, 16, HFI_CODEC_ENCODE_AVC); \
  1525. } while (0)
  1526. #define HFI_BUFFER_LINE_H265E(_size, frame_width, frame_height, is_ten_bit, \
  1527. num_vpp_pipes) \
  1528. do \
  1529. { \
  1530. HFI_BUFFER_LINE_ENC(_size, frame_width, frame_height, \
  1531. is_ten_bit, num_vpp_pipes, 32, HFI_CODEC_ENCODE_HEVC); \
  1532. } while (0)
  1533. #define HFI_BUFFER_COMV_ENC(_size, frame_width, frame_height, lcu_size, \
  1534. num_recon, standard) \
  1535. do \
  1536. { \
  1537. HFI_U32 size_colloc_mv = 0, size_colloc_rc = 0; \
  1538. HFI_U32 mb_width = ((frame_width) + 15) >> 4; \
  1539. HFI_U32 mb_height = ((frame_height) + 15) >> 4; \
  1540. HFI_U32 width_in_lcus = ((frame_width) + (lcu_size)-1) /\
  1541. (lcu_size); \
  1542. HFI_U32 height_in_lcus = ((frame_height) + (lcu_size)-1) / \
  1543. (lcu_size); \
  1544. HFI_U32 num_lcu_in_frame = width_in_lcus * height_in_lcus; \
  1545. size_colloc_mv = (standard == HFI_CODEC_ENCODE_HEVC) ? \
  1546. (16 * ((num_lcu_in_frame << 2) + BUFFER_ALIGNMENT_32_BYTES)) : \
  1547. (3 * 16 * (width_in_lcus * height_in_lcus +\
  1548. BUFFER_ALIGNMENT_32_BYTES)); \
  1549. size_colloc_mv = HFI_ALIGN(size_colloc_mv, \
  1550. VENUS_DMA_ALIGNMENT) * num_recon; \
  1551. size_colloc_rc = (((mb_width + 7) >> 3) * 16 * 2 * mb_height); \
  1552. size_colloc_rc = HFI_ALIGN(size_colloc_rc, \
  1553. VENUS_DMA_ALIGNMENT) * HFI_MAX_COL_FRAME; \
  1554. _size = size_colloc_mv + size_colloc_rc; \
  1555. } while (0)
  1556. #define HFI_BUFFER_COMV_H264E(_size, frame_width, frame_height, num_recon) \
  1557. do \
  1558. { \
  1559. HFI_BUFFER_COMV_ENC(_size, frame_width, frame_height, 16, \
  1560. num_recon, HFI_CODEC_ENCODE_AVC); \
  1561. } while (0)
  1562. #define HFI_BUFFER_COMV_H265E(_size, frame_width, frame_height, num_recon) \
  1563. do \
  1564. { \
  1565. HFI_BUFFER_COMV_ENC(_size, frame_width, frame_height, 32,\
  1566. num_recon, HFI_CODEC_ENCODE_HEVC); \
  1567. } while (0)
  1568. #define HFI_BUFFER_NON_COMV_ENC(_size, frame_width, frame_height, \
  1569. num_vpp_pipes_enc, lcu_size, standard) \
  1570. do \
  1571. { \
  1572. HFI_U32 width_in_lcus = 0, height_in_lcus = 0, \
  1573. frame_width_coded = 0, frame_height_coded = 0, \
  1574. num_lcu_in_frame = 0, num_lcumb = 0; \
  1575. HFI_U32 frame_rc_buf_size = 0; \
  1576. width_in_lcus = ((frame_width) + (lcu_size)-1) / (lcu_size); \
  1577. height_in_lcus = ((frame_height) + (lcu_size)-1) / (lcu_size); \
  1578. num_lcu_in_frame = width_in_lcus * height_in_lcus; \
  1579. frame_width_coded = width_in_lcus * (lcu_size); \
  1580. frame_height_coded = height_in_lcus * (lcu_size); \
  1581. num_lcumb = (frame_height_coded / lcu_size) * \
  1582. ((frame_width_coded + lcu_size * 8) / lcu_size); \
  1583. SIZE_FRAME_RC_BUF_SIZE(frame_rc_buf_size, standard, \
  1584. frame_height_coded, num_vpp_pipes_enc); \
  1585. _size = SIZE_ENC_SLICE_INFO_BUF(num_lcu_in_frame) + \
  1586. SIZE_SLICE_CMD_BUFFER + \
  1587. SIZE_SPS_PPS_SLICE_HDR + \
  1588. frame_rc_buf_size + \
  1589. ENC_BITCNT_BUF_SIZE(num_lcu_in_frame) + \
  1590. ENC_BITMAP_BUF_SIZE(num_lcu_in_frame) + \
  1591. SIZE_BSE_SLICE_CMD_BUF + \
  1592. SIZE_LAMBDA_LUT + \
  1593. SIZE_OVERRIDE_BUF(num_lcumb) + \
  1594. SIZE_IR_BUF(num_lcu_in_frame); \
  1595. } while (0)
  1596. #define HFI_BUFFER_NON_COMV_H264E(_size, frame_width, frame_height, \
  1597. num_vpp_pipes_enc) \
  1598. do \
  1599. { \
  1600. HFI_BUFFER_NON_COMV_ENC(_size, frame_width, frame_height, \
  1601. num_vpp_pipes_enc, 16, HFI_CODEC_ENCODE_AVC); \
  1602. } while (0)
  1603. #define HFI_BUFFER_NON_COMV_H265E(_size, frame_width, frame_height, \
  1604. num_vpp_pipes_enc) \
  1605. do \
  1606. { \
  1607. HFI_BUFFER_NON_COMV_ENC(_size, frame_width, frame_height, \
  1608. num_vpp_pipes_enc, 32, HFI_CODEC_ENCODE_HEVC); \
  1609. } while (0)
  1610. #define SIZE_ENC_REF_BUFFER(size, frame_width, frame_height) \
  1611. do \
  1612. { \
  1613. HFI_U32 u_buffer_width = 0, u_buffer_height = 0, \
  1614. u_chroma_buffer_height = 0; \
  1615. u_buffer_height = HFI_ALIGN(frame_height, \
  1616. HFI_VENUS_HEIGHT_ALIGNMENT); \
  1617. u_chroma_buffer_height = frame_height >> 1; \
  1618. u_chroma_buffer_height = HFI_ALIGN(u_chroma_buffer_height, \
  1619. HFI_VENUS_HEIGHT_ALIGNMENT); \
  1620. u_buffer_width = HFI_ALIGN(frame_width, \
  1621. HFI_VENUS_WIDTH_ALIGNMENT); \
  1622. size = (u_buffer_height + u_chroma_buffer_height) * \
  1623. u_buffer_width; \
  1624. } while (0)
  1625. #define SIZE_ENC_TEN_BIT_REF_BUFFER(size, frame_width, frame_height) \
  1626. do \
  1627. { \
  1628. HFI_U32 ref_buf_height = 0, ref_luma_stride_in_bytes = 0, \
  1629. u_ref_stride = 0, luma_size = 0, ref_chrm_height_in_bytes = 0, \
  1630. chroma_size = 0, ref_buf_size = 0; \
  1631. ref_buf_height = (frame_height + \
  1632. (HFI_VENUS_HEIGHT_ALIGNMENT - 1)) \
  1633. & (~(HFI_VENUS_HEIGHT_ALIGNMENT - 1)); \
  1634. ref_luma_stride_in_bytes = ((frame_width + \
  1635. SYSTEM_LAL_TILE10 - 1) / SYSTEM_LAL_TILE10) * \
  1636. SYSTEM_LAL_TILE10; \
  1637. u_ref_stride = 4 * (ref_luma_stride_in_bytes / 3); \
  1638. u_ref_stride = (u_ref_stride + (BUF_SIZE_ALIGN_128 - 1)) &\
  1639. (~(BUF_SIZE_ALIGN_128 - 1)); \
  1640. luma_size = ref_buf_height * u_ref_stride; \
  1641. ref_chrm_height_in_bytes = (((frame_height + 1) >> 1) + \
  1642. (BUF_SIZE_ALIGN_32 - 1)) & (~(BUF_SIZE_ALIGN_32 - 1)); \
  1643. chroma_size = u_ref_stride * ref_chrm_height_in_bytes; \
  1644. luma_size = (luma_size + (BUF_SIZE_ALIGN_4096 - 1)) & \
  1645. (~(BUF_SIZE_ALIGN_4096 - 1)); \
  1646. chroma_size = (chroma_size + (BUF_SIZE_ALIGN_4096 - 1)) & \
  1647. (~(BUF_SIZE_ALIGN_4096 - 1)); \
  1648. ref_buf_size = luma_size + chroma_size; \
  1649. size = ref_buf_size; \
  1650. } while (0)
  1651. #define HFI_BUFFER_DPB_ENC(_size, frame_width, frame_height, is_ten_bit) \
  1652. do \
  1653. { \
  1654. HFI_U32 metadata_stride, metadata_buf_height, meta_size_y, \
  1655. meta_size_c; \
  1656. HFI_U32 ten_bit_ref_buf_size = 0, ref_buf_size = 0; \
  1657. if (!is_ten_bit) \
  1658. { \
  1659. SIZE_ENC_REF_BUFFER(ref_buf_size, frame_width, \
  1660. frame_height); \
  1661. HFI_UBWC_CALC_METADATA_PLANE_STRIDE(metadata_stride, \
  1662. (frame_width), 64, \
  1663. HFI_COLOR_FORMAT_YUV420_NV12_UBWC_Y_TILE_WIDTH); \
  1664. HFI_UBWC_METADATA_PLANE_BUFHEIGHT(metadata_buf_height, \
  1665. (frame_height), 16, \
  1666. HFI_COLOR_FORMAT_YUV420_NV12_UBWC_Y_TILE_HEIGHT); \
  1667. HFI_UBWC_METADATA_PLANE_BUFFER_SIZE(meta_size_y, \
  1668. metadata_stride, metadata_buf_height); \
  1669. HFI_UBWC_METADATA_PLANE_BUFFER_SIZE(meta_size_c, \
  1670. metadata_stride, metadata_buf_height); \
  1671. _size = ref_buf_size + meta_size_y + meta_size_c; \
  1672. } \
  1673. else \
  1674. { \
  1675. SIZE_ENC_TEN_BIT_REF_BUFFER(ten_bit_ref_buf_size, \
  1676. frame_width, frame_height); \
  1677. HFI_UBWC_CALC_METADATA_PLANE_STRIDE(metadata_stride, \
  1678. frame_width, VENUS_METADATA_STRIDE_MULTIPLE, \
  1679. HFI_COLOR_FORMAT_YUV420_TP10_UBWC_Y_TILE_WIDTH); \
  1680. HFI_UBWC_METADATA_PLANE_BUFHEIGHT(metadata_buf_height, \
  1681. frame_height, VENUS_METADATA_HEIGHT_MULTIPLE, \
  1682. HFI_COLOR_FORMAT_YUV420_TP10_UBWC_Y_TILE_HEIGHT); \
  1683. HFI_UBWC_METADATA_PLANE_BUFFER_SIZE(meta_size_y, \
  1684. metadata_stride, metadata_buf_height); \
  1685. HFI_UBWC_METADATA_PLANE_BUFFER_SIZE(meta_size_c, \
  1686. metadata_stride, metadata_buf_height); \
  1687. _size = ten_bit_ref_buf_size + meta_size_y + \
  1688. meta_size_c; \
  1689. } \
  1690. } while (0)
  1691. #define HFI_BUFFER_DPB_H264E(_size, frame_width, frame_height) \
  1692. do \
  1693. { \
  1694. HFI_BUFFER_DPB_ENC(_size, frame_width, frame_height, 0); \
  1695. } while (0)
  1696. #define HFI_BUFFER_DPB_H265E(_size, frame_width, frame_height, is_ten_bit) \
  1697. do \
  1698. { \
  1699. HFI_BUFFER_DPB_ENC(_size, frame_width, frame_height, is_ten_bit); \
  1700. } while (0)
  1701. #define HFI_BUFFER_VPSS_ENC(vpss_size, dswidth, dsheight, ds_enable, blur, is_ten_bit) \
  1702. do \
  1703. { \
  1704. vpss_size = 0; \
  1705. if (ds_enable || blur) \
  1706. { \
  1707. HFI_BUFFER_DPB_ENC(vpss_size, dswidth, dsheight, is_ten_bit); \
  1708. } \
  1709. } while (0)
  1710. #define HFI_IRIS3_ENC_MIN_INPUT_BUF_COUNT(numInput, TotalHBLayers) \
  1711. do \
  1712. { \
  1713. numInput = 3; \
  1714. if (TotalHBLayers >= 2) \
  1715. { \
  1716. numInput = (1 << (TotalHBLayers - 1)) + 2; \
  1717. } \
  1718. } while (0)
  1719. #endif /* __HFI_BUFFER_IRIS3__ */