hfi_buffer_iris3.h 70 KB

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