hfi_buffer_iris33.h 70 KB

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