hfi_buffer_iris2.h 57 KB

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