msm_media_info.h 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. /*
  3. * Copyright (c) 2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __MSM_MEDIA_INFO_H__
  6. #define __MSM_MEDIA_INFO_H__
  7. /* Width and Height should be multiple of 16 */
  8. #define INTERLACE_WIDTH_MAX 1920
  9. #define INTERLACE_HEIGHT_MAX 1920
  10. #define INTERLACE_MB_PER_FRAME_MAX ((1920*1088)/256)
  11. #ifndef MSM_MEDIA_ALIGN
  12. #define MSM_MEDIA_ALIGN(__sz, __align) (((__align) & ((__align) - 1)) ?\
  13. ((((__sz) + (__align) - 1) / (__align)) * (__align)) :\
  14. (((__sz) + (__align) - 1) & (~((__align) - 1))))
  15. #endif
  16. #ifndef MSM_MEDIA_ROUNDUP
  17. #define MSM_MEDIA_ROUNDUP(__sz, __r) (((__sz) + ((__r) - 1)) / (__r))
  18. #endif
  19. enum color_fmts {
  20. /* Venus NV12:
  21. * YUV 4:2:0 image with a plane of 8 bit Y samples followed
  22. * by an interleaved U/V plane containing 8 bit 2x2 subsampled
  23. * colour difference samples.
  24. *
  25. * <-------- Y/UV_Stride -------->
  26. * <------- Width ------->
  27. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . ^ ^
  28. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | |
  29. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . Height |
  30. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | Y_Scanlines
  31. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | |
  32. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | |
  33. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | |
  34. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . V |
  35. * . . . . . . . . . . . . . . . . |
  36. * . . . . . . . . . . . . . . . . |
  37. * . . . . . . . . . . . . . . . . |
  38. * . . . . . . . . . . . . . . . . V
  39. * U V U V U V U V U V U V . . . . ^
  40. * U V U V U V U V U V U V . . . . |
  41. * U V U V U V U V U V U V . . . . |
  42. * U V U V U V U V U V U V . . . . UV_Scanlines
  43. * . . . . . . . . . . . . . . . . |
  44. * . . . . . . . . . . . . . . . . V
  45. * . . . . . . . . . . . . . . . . --> Buffer size alignment
  46. *
  47. * Y_Stride : Width aligned to 128
  48. * UV_Stride : Width aligned to 128
  49. * Y_Scanlines: Height aligned to 32
  50. * UV_Scanlines: Height/2 aligned to 16
  51. * Total size = align(Y_Stride * Y_Scanlines
  52. * + UV_Stride * UV_Scanlines, 4096)
  53. */
  54. COLOR_FMT_NV12,
  55. /* Venus NV21:
  56. * YUV 4:2:0 image with a plane of 8 bit Y samples followed
  57. * by an interleaved V/U plane containing 8 bit 2x2 subsampled
  58. * colour difference samples.
  59. *
  60. * <-------- Y/UV_Stride -------->
  61. * <------- Width ------->
  62. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . ^ ^
  63. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | |
  64. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . Height |
  65. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | Y_Scanlines
  66. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | |
  67. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | |
  68. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | |
  69. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . V |
  70. * . . . . . . . . . . . . . . . . |
  71. * . . . . . . . . . . . . . . . . |
  72. * . . . . . . . . . . . . . . . . |
  73. * . . . . . . . . . . . . . . . . V
  74. * V U V U V U V U V U V U . . . . ^
  75. * V U V U V U V U V U V U . . . . |
  76. * V U V U V U V U V U V U . . . . |
  77. * V U V U V U V U V U V U . . . . UV_Scanlines
  78. * . . . . . . . . . . . . . . . . |
  79. * . . . . . . . . . . . . . . . . V
  80. * . . . . . . . . . . . . . . . . --> Padding & Buffer size alignment
  81. *
  82. * Y_Stride : Width aligned to 128
  83. * UV_Stride : Width aligned to 128
  84. * Y_Scanlines: Height aligned to 32
  85. * UV_Scanlines: Height/2 aligned to 16
  86. * Total size = align(Y_Stride * Y_Scanlines
  87. * + UV_Stride * UV_Scanlines, 4096)
  88. */
  89. COLOR_FMT_NV21,
  90. /*
  91. * The buffer can be of 2 types:
  92. * (1) Venus NV12 UBWC Progressive
  93. * (2) Venus NV12 UBWC Interlaced
  94. *
  95. * (1) Venus NV12 UBWC Progressive Buffer Format:
  96. * Compressed Macro-tile format for NV12.
  97. * Contains 4 planes in the following order -
  98. * (A) Y_Meta_Plane
  99. * (B) Y_UBWC_Plane
  100. * (C) UV_Meta_Plane
  101. * (D) UV_UBWC_Plane
  102. *
  103. * Y_Meta_Plane consists of meta information to decode compressed
  104. * tile data in Y_UBWC_Plane.
  105. * Y_UBWC_Plane consists of Y data in compressed macro-tile format.
  106. * UBWC decoder block will use the Y_Meta_Plane data together with
  107. * Y_UBWC_Plane data to produce loss-less uncompressed 8 bit Y samples.
  108. *
  109. * UV_Meta_Plane consists of meta information to decode compressed
  110. * tile data in UV_UBWC_Plane.
  111. * UV_UBWC_Plane consists of UV data in compressed macro-tile format.
  112. * UBWC decoder block will use UV_Meta_Plane data together with
  113. * UV_UBWC_Plane data to produce loss-less uncompressed 8 bit 2x2
  114. * subsampled color difference samples.
  115. *
  116. * Each tile in Y_UBWC_Plane/UV_UBWC_Plane is independently decodable
  117. * and randomly accessible. There is no dependency between tiles.
  118. *
  119. * <----- Y_Meta_Stride ---->
  120. * <-------- Width ------>
  121. * M M M M M M M M M M M M . . ^ ^
  122. * M M M M M M M M M M M M . . | |
  123. * M M M M M M M M M M M M . . Height |
  124. * M M M M M M M M M M M M . . | Meta_Y_Scanlines
  125. * M M M M M M M M M M M M . . | |
  126. * M M M M M M M M M M M M . . | |
  127. * M M M M M M M M M M M M . . | |
  128. * M M M M M M M M M M M M . . V |
  129. * . . . . . . . . . . . . . . |
  130. * . . . . . . . . . . . . . . |
  131. * . . . . . . . . . . . . . . -------> Buffer size aligned to 4k
  132. * . . . . . . . . . . . . . . V
  133. * <--Compressed tile Y Stride--->
  134. * <------- Width ------->
  135. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . ^ ^
  136. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | |
  137. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . Height |
  138. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | Macro_tile_Y_Scanlines
  139. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | |
  140. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | |
  141. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | |
  142. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . V |
  143. * . . . . . . . . . . . . . . . . |
  144. * . . . . . . . . . . . . . . . . |
  145. * . . . . . . . . . . . . . . . . -------> Buffer size aligned to 4k
  146. * . . . . . . . . . . . . . . . . V
  147. * <----- UV_Meta_Stride ---->
  148. * M M M M M M M M M M M M . . ^
  149. * M M M M M M M M M M M M . . |
  150. * M M M M M M M M M M M M . . |
  151. * M M M M M M M M M M M M . . M_UV_Scanlines
  152. * . . . . . . . . . . . . . . |
  153. * . . . . . . . . . . . . . . V
  154. * . . . . . . . . . . . . . . -------> Buffer size aligned to 4k
  155. * <--Compressed tile UV Stride--->
  156. * U* V* U* V* U* V* U* V* . . . . ^
  157. * U* V* U* V* U* V* U* V* . . . . |
  158. * U* V* U* V* U* V* U* V* . . . . |
  159. * U* V* U* V* U* V* U* V* . . . . UV_Scanlines
  160. * . . . . . . . . . . . . . . . . |
  161. * . . . . . . . . . . . . . . . . V
  162. * . . . . . . . . . . . . . . . . -------> Buffer size aligned to 4k
  163. *
  164. * Y_Stride = align(Width, 128)
  165. * UV_Stride = align(Width, 128)
  166. * Y_Scanlines = align(Height, 32)
  167. * UV_Scanlines = align(Height/2, 32)
  168. * Y_UBWC_Plane_size = align(Y_Stride * Y_Scanlines, 4096)
  169. * UV_UBWC_Plane_size = align(UV_Stride * UV_Scanlines, 4096)
  170. * Y_Meta_Stride = align(roundup(Width, Y_TileWidth), 64)
  171. * Y_Meta_Scanlines = align(roundup(Height, Y_TileHeight), 16)
  172. * Y_Meta_Plane_size = align(Y_Meta_Stride * Y_Meta_Scanlines, 4096)
  173. * UV_Meta_Stride = align(roundup(Width, UV_TileWidth), 64)
  174. * UV_Meta_Scanlines = align(roundup(Height, UV_TileHeight), 16)
  175. * UV_Meta_Plane_size = align(UV_Meta_Stride * UV_Meta_Scanlines, 4096)
  176. *
  177. * Total size = align( Y_UBWC_Plane_size + UV_UBWC_Plane_size +
  178. * Y_Meta_Plane_size + UV_Meta_Plane_size, 4096)
  179. *
  180. *
  181. * (2) Venus NV12 UBWC Interlaced Buffer Format:
  182. * Compressed Macro-tile format for NV12 interlaced.
  183. * Contains 8 planes in the following order -
  184. * (A) Y_Meta_Top_Field_Plane
  185. * (B) Y_UBWC_Top_Field_Plane
  186. * (C) UV_Meta_Top_Field_Plane
  187. * (D) UV_UBWC_Top_Field_Plane
  188. * (E) Y_Meta_Bottom_Field_Plane
  189. * (F) Y_UBWC_Bottom_Field_Plane
  190. * (G) UV_Meta_Bottom_Field_Plane
  191. * (H) UV_UBWC_Bottom_Field_Plane
  192. * Y_Meta_Top_Field_Plane consists of meta information to decode
  193. * compressed tile data for Y_UBWC_Top_Field_Plane.
  194. * Y_UBWC_Top_Field_Plane consists of Y data in compressed macro-tile
  195. * format for top field of an interlaced frame.
  196. * UBWC decoder block will use the Y_Meta_Top_Field_Plane data together
  197. * with Y_UBWC_Top_Field_Plane data to produce loss-less uncompressed
  198. * 8 bit Y samples for top field of an interlaced frame.
  199. *
  200. * UV_Meta_Top_Field_Plane consists of meta information to decode
  201. * compressed tile data in UV_UBWC_Top_Field_Plane.
  202. * UV_UBWC_Top_Field_Plane consists of UV data in compressed macro-tile
  203. * format for top field of an interlaced frame.
  204. * UBWC decoder block will use UV_Meta_Top_Field_Plane data together
  205. * with UV_UBWC_Top_Field_Plane data to produce loss-less uncompressed
  206. * 8 bit subsampled color difference samples for top field of an
  207. * interlaced frame.
  208. *
  209. * Each tile in Y_UBWC_Top_Field_Plane/UV_UBWC_Top_Field_Plane is
  210. * independently decodable and randomly accessible. There is no
  211. * dependency between tiles.
  212. *
  213. * Y_Meta_Bottom_Field_Plane consists of meta information to decode
  214. * compressed tile data for Y_UBWC_Bottom_Field_Plane.
  215. * Y_UBWC_Bottom_Field_Plane consists of Y data in compressed macro-tile
  216. * format for bottom field of an interlaced frame.
  217. * UBWC decoder block will use the Y_Meta_Bottom_Field_Plane data
  218. * together with Y_UBWC_Bottom_Field_Plane data to produce loss-less
  219. * uncompressed 8 bit Y samples for bottom field of an interlaced frame.
  220. *
  221. * UV_Meta_Bottom_Field_Plane consists of meta information to decode
  222. * compressed tile data in UV_UBWC_Bottom_Field_Plane.
  223. * UV_UBWC_Bottom_Field_Plane consists of UV data in compressed
  224. * macro-tile format for bottom field of an interlaced frame.
  225. * UBWC decoder block will use UV_Meta_Bottom_Field_Plane data together
  226. * with UV_UBWC_Bottom_Field_Plane data to produce loss-less
  227. * uncompressed 8 bit subsampled color difference samples for bottom
  228. * field of an interlaced frame.
  229. *
  230. * Each tile in Y_UBWC_Bottom_Field_Plane/UV_UBWC_Bottom_Field_Plane is
  231. * independently decodable and randomly accessible. There is no
  232. * dependency between tiles.
  233. *
  234. * <-----Y_TF_Meta_Stride---->
  235. * <-------- Width ------>
  236. * M M M M M M M M M M M M . . ^ ^
  237. * M M M M M M M M M M M M . . | |
  238. * M M M M M M M M M M M M . . Half_height |
  239. * M M M M M M M M M M M M . . | Meta_Y_TF_Scanlines
  240. * M M M M M M M M M M M M . . | |
  241. * M M M M M M M M M M M M . . | |
  242. * M M M M M M M M M M M M . . | |
  243. * M M M M M M M M M M M M . . V |
  244. * . . . . . . . . . . . . . . |
  245. * . . . . . . . . . . . . . . |
  246. * . . . . . . . . . . . . . . -------> Buffer size aligned to 4k
  247. * . . . . . . . . . . . . . . V
  248. * <-Compressed tile Y_TF Stride->
  249. * <------- Width ------->
  250. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . ^ ^
  251. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | |
  252. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . Half_height |
  253. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | Macro_tile_Y_TF_Scanlines
  254. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | |
  255. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | |
  256. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | |
  257. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . V |
  258. * . . . . . . . . . . . . . . . . |
  259. * . . . . . . . . . . . . . . . . |
  260. * . . . . . . . . . . . . . . . . -------> Buffer size aligned to 4k
  261. * . . . . . . . . . . . . . . . . V
  262. * <----UV_TF_Meta_Stride---->
  263. * M M M M M M M M M M M M . . ^
  264. * M M M M M M M M M M M M . . |
  265. * M M M M M M M M M M M M . . |
  266. * M M M M M M M M M M M M . . M_UV_TF_Scanlines
  267. * . . . . . . . . . . . . . . |
  268. * . . . . . . . . . . . . . . V
  269. * . . . . . . . . . . . . . . -------> Buffer size aligned to 4k
  270. * <-Compressed tile UV_TF Stride->
  271. * U* V* U* V* U* V* U* V* . . . . ^
  272. * U* V* U* V* U* V* U* V* . . . . |
  273. * U* V* U* V* U* V* U* V* . . . . |
  274. * U* V* U* V* U* V* U* V* . . . . UV_TF_Scanlines
  275. * . . . . . . . . . . . . . . . . |
  276. * . . . . . . . . . . . . . . . . V
  277. * . . . . . . . . . . . . . . . . -------> Buffer size aligned to 4k
  278. * <-----Y_BF_Meta_Stride---->
  279. * <-------- Width ------>
  280. * M M M M M M M M M M M M . . ^ ^
  281. * M M M M M M M M M M M M . . | |
  282. * M M M M M M M M M M M M . . Half_height |
  283. * M M M M M M M M M M M M . . | Meta_Y_BF_Scanlines
  284. * M M M M M M M M M M M M . . | |
  285. * M M M M M M M M M M M M . . | |
  286. * M M M M M M M M M M M M . . | |
  287. * M M M M M M M M M M M M . . V |
  288. * . . . . . . . . . . . . . . |
  289. * . . . . . . . . . . . . . . |
  290. * . . . . . . . . . . . . . . -------> Buffer size aligned to 4k
  291. * . . . . . . . . . . . . . . V
  292. * <-Compressed tile Y_BF Stride->
  293. * <------- Width ------->
  294. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . ^ ^
  295. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | |
  296. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . Half_height |
  297. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | Macro_tile_Y_BF_Scanlines
  298. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | |
  299. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | |
  300. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | |
  301. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . V |
  302. * . . . . . . . . . . . . . . . . |
  303. * . . . . . . . . . . . . . . . . |
  304. * . . . . . . . . . . . . . . . . -------> Buffer size aligned to 4k
  305. * . . . . . . . . . . . . . . . . V
  306. * <----UV_BF_Meta_Stride---->
  307. * M M M M M M M M M M M M . . ^
  308. * M M M M M M M M M M M M . . |
  309. * M M M M M M M M M M M M . . |
  310. * M M M M M M M M M M M M . . M_UV_BF_Scanlines
  311. * . . . . . . . . . . . . . . |
  312. * . . . . . . . . . . . . . . V
  313. * . . . . . . . . . . . . . . -------> Buffer size aligned to 4k
  314. * <-Compressed tile UV_BF Stride->
  315. * U* V* U* V* U* V* U* V* . . . . ^
  316. * U* V* U* V* U* V* U* V* . . . . |
  317. * U* V* U* V* U* V* U* V* . . . . |
  318. * U* V* U* V* U* V* U* V* . . . . UV_BF_Scanlines
  319. * . . . . . . . . . . . . . . . . |
  320. * . . . . . . . . . . . . . . . . V
  321. * . . . . . . . . . . . . . . . . -------> Buffer size aligned to 4k
  322. *
  323. * Half_height = (Height+1)>>1
  324. * Y_TF_Stride = align(Width, 128)
  325. * UV_TF_Stride = align(Width, 128)
  326. * Y_TF_Scanlines = align(Half_height, 32)
  327. * UV_TF_Scanlines = align((Half_height+1)/2, 32)
  328. * Y_UBWC_TF_Plane_size = align(Y_TF_Stride * Y_TF_Scanlines, 4096)
  329. * UV_UBWC_TF_Plane_size = align(UV_TF_Stride * UV_TF_Scanlines, 4096)
  330. * Y_TF_Meta_Stride = align(roundup(Width, Y_TileWidth), 64)
  331. * Y_TF_Meta_Scanlines = align(roundup(Half_height, Y_TileHeight), 16)
  332. * Y_TF_Meta_Plane_size =
  333. * align(Y_TF_Meta_Stride * Y_TF_Meta_Scanlines, 4096)
  334. * UV_TF_Meta_Stride = align(roundup(Width, UV_TileWidth), 64)
  335. * UV_TF_Meta_Scanlines = align(roundup(Half_height, UV_TileHeight), 16)
  336. * UV_TF_Meta_Plane_size =
  337. * align(UV_TF_Meta_Stride * UV_TF_Meta_Scanlines, 4096)
  338. * Y_BF_Stride = align(Width, 128)
  339. * UV_BF_Stride = align(Width, 128)
  340. * Y_BF_Scanlines = align(Half_height, 32)
  341. * UV_BF_Scanlines = align((Half_height+1)/2, 32)
  342. * Y_UBWC_BF_Plane_size = align(Y_BF_Stride * Y_BF_Scanlines, 4096)
  343. * UV_UBWC_BF_Plane_size = align(UV_BF_Stride * UV_BF_Scanlines, 4096)
  344. * Y_BF_Meta_Stride = align(roundup(Width, Y_TileWidth), 64)
  345. * Y_BF_Meta_Scanlines = align(roundup(Half_height, Y_TileHeight), 16)
  346. * Y_BF_Meta_Plane_size =
  347. * align(Y_BF_Meta_Stride * Y_BF_Meta_Scanlines, 4096)
  348. * UV_BF_Meta_Stride = align(roundup(Width, UV_TileWidth), 64)
  349. * UV_BF_Meta_Scanlines = align(roundup(Half_height, UV_TileHeight), 16)
  350. * UV_BF_Meta_Plane_size =
  351. * align(UV_BF_Meta_Stride * UV_BF_Meta_Scanlines, 4096)
  352. *
  353. * Total size = align( Y_UBWC_TF_Plane_size + UV_UBWC_TF_Plane_size +
  354. * Y_TF_Meta_Plane_size + UV_TF_Meta_Plane_size +
  355. * Y_UBWC_BF_Plane_size + UV_UBWC_BF_Plane_size +
  356. * Y_BF_Meta_Plane_size + UV_BF_Meta_Plane_size +, 4096)
  357. */
  358. COLOR_FMT_NV12_UBWC,
  359. /* Venus NV12 10-bit UBWC:
  360. * Compressed Macro-tile format for NV12.
  361. * Contains 4 planes in the following order -
  362. * (A) Y_Meta_Plane
  363. * (B) Y_UBWC_Plane
  364. * (C) UV_Meta_Plane
  365. * (D) UV_UBWC_Plane
  366. *
  367. * Y_Meta_Plane consists of meta information to decode compressed
  368. * tile data in Y_UBWC_Plane.
  369. * Y_UBWC_Plane consists of Y data in compressed macro-tile format.
  370. * UBWC decoder block will use the Y_Meta_Plane data together with
  371. * Y_UBWC_Plane data to produce loss-less uncompressed 10 bit Y samples.
  372. *
  373. * UV_Meta_Plane consists of meta information to decode compressed
  374. * tile data in UV_UBWC_Plane.
  375. * UV_UBWC_Plane consists of UV data in compressed macro-tile format.
  376. * UBWC decoder block will use UV_Meta_Plane data together with
  377. * UV_UBWC_Plane data to produce loss-less uncompressed 10 bit 2x2
  378. * subsampled color difference samples.
  379. *
  380. * Each tile in Y_UBWC_Plane/UV_UBWC_Plane is independently decodable
  381. * and randomly accessible. There is no dependency between tiles.
  382. *
  383. * <----- Y_Meta_Stride ----->
  384. * <-------- Width ------>
  385. * M M M M M M M M M M M M . . ^ ^
  386. * M M M M M M M M M M M M . . | |
  387. * M M M M M M M M M M M M . . Height |
  388. * M M M M M M M M M M M M . . | Meta_Y_Scanlines
  389. * M M M M M M M M M M M M . . | |
  390. * M M M M M M M M M M M M . . | |
  391. * M M M M M M M M M M M M . . | |
  392. * M M M M M M M M M M M M . . V |
  393. * . . . . . . . . . . . . . . |
  394. * . . . . . . . . . . . . . . |
  395. * . . . . . . . . . . . . . . -------> Buffer size aligned to 4k
  396. * . . . . . . . . . . . . . . V
  397. * <--Compressed tile Y Stride--->
  398. * <------- Width ------->
  399. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . ^ ^
  400. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | |
  401. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . Height |
  402. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | Macro_tile_Y_Scanlines
  403. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | |
  404. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | |
  405. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | |
  406. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . V |
  407. * . . . . . . . . . . . . . . . . |
  408. * . . . . . . . . . . . . . . . . |
  409. * . . . . . . . . . . . . . . . . -------> Buffer size aligned to 4k
  410. * . . . . . . . . . . . . . . . . V
  411. * <----- UV_Meta_Stride ---->
  412. * M M M M M M M M M M M M . . ^
  413. * M M M M M M M M M M M M . . |
  414. * M M M M M M M M M M M M . . |
  415. * M M M M M M M M M M M M . . M_UV_Scanlines
  416. * . . . . . . . . . . . . . . |
  417. * . . . . . . . . . . . . . . V
  418. * . . . . . . . . . . . . . . -------> Buffer size aligned to 4k
  419. * <--Compressed tile UV Stride--->
  420. * U* V* U* V* U* V* U* V* . . . . ^
  421. * U* V* U* V* U* V* U* V* . . . . |
  422. * U* V* U* V* U* V* U* V* . . . . |
  423. * U* V* U* V* U* V* U* V* . . . . UV_Scanlines
  424. * . . . . . . . . . . . . . . . . |
  425. * . . . . . . . . . . . . . . . . V
  426. * . . . . . . . . . . . . . . . . -------> Buffer size aligned to 4k
  427. *
  428. *
  429. * Y_Stride = align(Width * 4/3, 256)
  430. * UV_Stride = align(Width * 4/3, 256)
  431. * Y_Scanlines = align(Height, 32)
  432. * UV_Scanlines = align(Height/2, 16)
  433. * Y_UBWC_Plane_Size = align(Y_Stride * Y_Scanlines, 4096)
  434. * UV_UBWC_Plane_Size = align(UV_Stride * UV_Scanlines, 4096)
  435. * Y_Meta_Stride = align(roundup(Width, Y_TileWidth), 64)
  436. * Y_Meta_Scanlines = align(roundup(Height, Y_TileHeight), 16)
  437. * Y_Meta_Plane_size = align(Y_Meta_Stride * Y_Meta_Scanlines, 4096)
  438. * UV_Meta_Stride = align(roundup(Width, UV_TileWidth), 64)
  439. * UV_Meta_Scanlines = align(roundup(Height, UV_TileHeight), 16)
  440. * UV_Meta_Plane_size = align(UV_Meta_Stride * UV_Meta_Scanlines, 4096)
  441. *
  442. * Total size = align(Y_UBWC_Plane_size + UV_UBWC_Plane_size +
  443. * Y_Meta_Plane_size + UV_Meta_Plane_size, 4096)
  444. */
  445. COLOR_FMT_NV12_BPP10_UBWC,
  446. /* Venus RGBA8888 format:
  447. * Contains 1 plane in the following order -
  448. * (A) RGBA plane
  449. *
  450. * <-------- RGB_Stride -------->
  451. * <------- Width ------->
  452. * R R R R R R R R R R R R . . . . ^ ^
  453. * R R R R R R R R R R R R . . . . | |
  454. * R R R R R R R R R R R R . . . . Height |
  455. * R R R R R R R R R R R R . . . . | RGB_Scanlines
  456. * R R R R R R R R R R R R . . . . | |
  457. * R R R R R R R R R R R R . . . . | |
  458. * R R R R R R R R R R R R . . . . | |
  459. * R R R R R R R R R R R R . . . . V |
  460. * . . . . . . . . . . . . . . . . |
  461. * . . . . . . . . . . . . . . . . |
  462. * . . . . . . . . . . . . . . . . |
  463. * . . . . . . . . . . . . . . . . V
  464. *
  465. * RGB_Stride = align(Width * 4, 128)
  466. * RGB_Scanlines = align(Height, 32)
  467. * RGB_Plane_size = align(RGB_Stride * RGB_Scanlines, 4096)
  468. *
  469. * Total size = align(RGB_Plane_size , 4096)
  470. */
  471. COLOR_FMT_RGBA8888,
  472. /* Venus RGBA8888 UBWC format:
  473. * Contains 2 planes in the following order -
  474. * (A) Meta plane
  475. * (B) RGBA plane
  476. *
  477. * <--- RGB_Meta_Stride ---->
  478. * <-------- Width ------>
  479. * M M M M M M M M M M M M . . ^ ^
  480. * M M M M M M M M M M M M . . | |
  481. * M M M M M M M M M M M M . . Height |
  482. * M M M M M M M M M M M M . . | Meta_RGB_Scanlines
  483. * M M M M M M M M M M M M . . | |
  484. * M M M M M M M M M M M M . . | |
  485. * M M M M M M M M M M M M . . | |
  486. * M M M M M M M M M M M M . . V |
  487. * . . . . . . . . . . . . . . |
  488. * . . . . . . . . . . . . . . |
  489. * . . . . . . . . . . . . . . -------> Buffer size aligned to 4k
  490. * . . . . . . . . . . . . . . V
  491. * <-------- RGB_Stride -------->
  492. * <------- Width ------->
  493. * R R R R R R R R R R R R . . . . ^ ^
  494. * R R R R R R R R R R R R . . . . | |
  495. * R R R R R R R R R R R R . . . . Height |
  496. * R R R R R R R R R R R R . . . . | RGB_Scanlines
  497. * R R R R R R R R R R R R . . . . | |
  498. * R R R R R R R R R R R R . . . . | |
  499. * R R R R R R R R R R R R . . . . | |
  500. * R R R R R R R R R R R R . . . . V |
  501. * . . . . . . . . . . . . . . . . |
  502. * . . . . . . . . . . . . . . . . |
  503. * . . . . . . . . . . . . . . . . -------> Buffer size aligned to 4k
  504. * . . . . . . . . . . . . . . . . V
  505. *
  506. * RGB_Stride = align(Width * 4, 256)
  507. * RGB_Scanlines = align(Height, 16)
  508. * RGB_Plane_size = align(RGB_Stride * RGB_Scanlines, 4096)
  509. * RGB_Meta_Stride = align(roundup(Width, RGB_TileWidth), 64)
  510. * RGB_Meta_Scanline = align(roundup(Height, RGB_TileHeight), 16)
  511. * RGB_Meta_Plane_size = align(RGB_Meta_Stride *
  512. * RGB_Meta_Scanlines, 4096)
  513. *
  514. * Total size = align(RGB_Meta_Plane_size + RGB_Plane_size, 4096)
  515. */
  516. COLOR_FMT_RGBA8888_UBWC,
  517. /* Venus RGBA1010102 UBWC format:
  518. * Contains 2 planes in the following order -
  519. * (A) Meta plane
  520. * (B) RGBA plane
  521. *
  522. * <--- RGB_Meta_Stride ---->
  523. * <-------- Width ------>
  524. * M M M M M M M M M M M M . . ^ ^
  525. * M M M M M M M M M M M M . . | |
  526. * M M M M M M M M M M M M . . Height |
  527. * M M M M M M M M M M M M . . | Meta_RGB_Scanlines
  528. * M M M M M M M M M M M M . . | |
  529. * M M M M M M M M M M M M . . | |
  530. * M M M M M M M M M M M M . . | |
  531. * M M M M M M M M M M M M . . V |
  532. * . . . . . . . . . . . . . . |
  533. * . . . . . . . . . . . . . . |
  534. * . . . . . . . . . . . . . . -------> Buffer size aligned to 4k
  535. * . . . . . . . . . . . . . . V
  536. * <-------- RGB_Stride -------->
  537. * <------- Width ------->
  538. * R R R R R R R R R R R R . . . . ^ ^
  539. * R R R R R R R R R R R R . . . . | |
  540. * R R R R R R R R R R R R . . . . Height |
  541. * R R R R R R R R R R R R . . . . | RGB_Scanlines
  542. * R R R R R R R R R R R R . . . . | |
  543. * R R R R R R R R R R R R . . . . | |
  544. * R R R R R R R R R R R R . . . . | |
  545. * R R R R R R R R R R R R . . . . V |
  546. * . . . . . . . . . . . . . . . . |
  547. * . . . . . . . . . . . . . . . . |
  548. * . . . . . . . . . . . . . . . . -------> Buffer size aligned to 4k
  549. * . . . . . . . . . . . . . . . . V
  550. *
  551. * RGB_Stride = align(Width * 4, 256)
  552. * RGB_Scanlines = align(Height, 16)
  553. * RGB_Plane_size = align(RGB_Stride * RGB_Scanlines, 4096)
  554. * RGB_Meta_Stride = align(roundup(Width, RGB_TileWidth), 64)
  555. * RGB_Meta_Scanline = align(roundup(Height, RGB_TileHeight), 16)
  556. * RGB_Meta_Plane_size = align(RGB_Meta_Stride *
  557. * RGB_Meta_Scanlines, 4096)
  558. *
  559. * Total size = align(RGB_Meta_Plane_size + RGB_Plane_size, 4096)
  560. */
  561. COLOR_FMT_RGBA1010102_UBWC,
  562. /* Venus RGB565 UBWC format:
  563. * Contains 2 planes in the following order -
  564. * (A) Meta plane
  565. * (B) RGB plane
  566. *
  567. * <--- RGB_Meta_Stride ---->
  568. * <-------- Width ------>
  569. * M M M M M M M M M M M M . . ^ ^
  570. * M M M M M M M M M M M M . . | |
  571. * M M M M M M M M M M M M . . Height |
  572. * M M M M M M M M M M M M . . | Meta_RGB_Scanlines
  573. * M M M M M M M M M M M M . . | |
  574. * M M M M M M M M M M M M . . | |
  575. * M M M M M M M M M M M M . . | |
  576. * M M M M M M M M M M M M . . V |
  577. * . . . . . . . . . . . . . . |
  578. * . . . . . . . . . . . . . . |
  579. * . . . . . . . . . . . . . . -------> Buffer size aligned to 4k
  580. * . . . . . . . . . . . . . . V
  581. * <-------- RGB_Stride -------->
  582. * <------- Width ------->
  583. * R R R R R R R R R R R R . . . . ^ ^
  584. * R R R R R R R R R R R R . . . . | |
  585. * R R R R R R R R R R R R . . . . Height |
  586. * R R R R R R R R R R R R . . . . | RGB_Scanlines
  587. * R R R R R R R R R R R R . . . . | |
  588. * R R R R R R R R R R R R . . . . | |
  589. * R R R R R R R R R R R R . . . . | |
  590. * R R R R R R R R R R R R . . . . V |
  591. * . . . . . . . . . . . . . . . . |
  592. * . . . . . . . . . . . . . . . . |
  593. * . . . . . . . . . . . . . . . . -------> Buffer size aligned to 4k
  594. * . . . . . . . . . . . . . . . . V
  595. *
  596. * RGB_Stride = align(Width * 2, 256)
  597. * RGB_Scanlines = align(Height, 16)
  598. * RGB_Plane_size = align(RGB_Stride * RGB_Scanlines, 4096)
  599. * RGB_Meta_Stride = align(roundup(Width, RGB_TileWidth), 64)
  600. * RGB_Meta_Scanline = align(roundup(Height, RGB_TileHeight), 16)
  601. * RGB_Meta_Plane_size = align(RGB_Meta_Stride *
  602. * RGB_Meta_Scanlines, 4096)
  603. *
  604. * Total size = align(RGB_Meta_Plane_size + RGB_Plane_size, 4096)
  605. */
  606. COLOR_FMT_RGB565_UBWC,
  607. /* P010 UBWC:
  608. * Compressed Macro-tile format for NV12.
  609. * Contains 4 planes in the following order -
  610. * (A) Y_Meta_Plane
  611. * (B) Y_UBWC_Plane
  612. * (C) UV_Meta_Plane
  613. * (D) UV_UBWC_Plane
  614. *
  615. * Y_Meta_Plane consists of meta information to decode compressed
  616. * tile data in Y_UBWC_Plane.
  617. * Y_UBWC_Plane consists of Y data in compressed macro-tile format.
  618. * UBWC decoder block will use the Y_Meta_Plane data together with
  619. * Y_UBWC_Plane data to produce loss-less uncompressed 10 bit Y samples.
  620. *
  621. * UV_Meta_Plane consists of meta information to decode compressed
  622. * tile data in UV_UBWC_Plane.
  623. * UV_UBWC_Plane consists of UV data in compressed macro-tile format.
  624. * UBWC decoder block will use UV_Meta_Plane data together with
  625. * UV_UBWC_Plane data to produce loss-less uncompressed 10 bit 2x2
  626. * subsampled color difference samples.
  627. *
  628. * Each tile in Y_UBWC_Plane/UV_UBWC_Plane is independently decodable
  629. * and randomly accessible. There is no dependency between tiles.
  630. *
  631. * <----- Y_Meta_Stride ----->
  632. * <-------- Width ------>
  633. * M M M M M M M M M M M M . . ^ ^
  634. * M M M M M M M M M M M M . . | |
  635. * M M M M M M M M M M M M . . Height |
  636. * M M M M M M M M M M M M . . | Meta_Y_Scanlines
  637. * M M M M M M M M M M M M . . | |
  638. * M M M M M M M M M M M M . . | |
  639. * M M M M M M M M M M M M . . | |
  640. * M M M M M M M M M M M M . . V |
  641. * . . . . . . . . . . . . . . |
  642. * . . . . . . . . . . . . . . |
  643. * . . . . . . . . . . . . . . -------> Buffer size aligned to 4k
  644. * . . . . . . . . . . . . . . V
  645. * <--Compressed tile Y Stride--->
  646. * <------- Width ------->
  647. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . ^ ^
  648. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | |
  649. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . Height |
  650. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | Macro_tile_Y_Scanlines
  651. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | |
  652. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | |
  653. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | |
  654. * Y* Y* Y* Y* Y* Y* Y* Y* . . . . V |
  655. * . . . . . . . . . . . . . . . . |
  656. * . . . . . . . . . . . . . . . . |
  657. * . . . . . . . . . . . . . . . . -------> Buffer size aligned to 4k
  658. * . . . . . . . . . . . . . . . . V
  659. * <----- UV_Meta_Stride ---->
  660. * M M M M M M M M M M M M . . ^
  661. * M M M M M M M M M M M M . . |
  662. * M M M M M M M M M M M M . . |
  663. * M M M M M M M M M M M M . . M_UV_Scanlines
  664. * . . . . . . . . . . . . . . |
  665. * . . . . . . . . . . . . . . V
  666. * . . . . . . . . . . . . . . -------> Buffer size aligned to 4k
  667. * <--Compressed tile UV Stride--->
  668. * U* V* U* V* U* V* U* V* . . . . ^
  669. * U* V* U* V* U* V* U* V* . . . . |
  670. * U* V* U* V* U* V* U* V* . . . . |
  671. * U* V* U* V* U* V* U* V* . . . . UV_Scanlines
  672. * . . . . . . . . . . . . . . . . |
  673. * . . . . . . . . . . . . . . . . V
  674. * . . . . . . . . . . . . . . . . -------> Buffer size aligned to 4k
  675. *
  676. *
  677. * Y_Stride = align(Width * 2, 256)
  678. * UV_Stride = align(Width * 2, 256)
  679. * Y_Scanlines = align(Height, 16)
  680. * UV_Scanlines = align(Height/2, 16)
  681. * Y_UBWC_Plane_Size = align(Y_Stride * Y_Scanlines, 4096)
  682. * UV_UBWC_Plane_Size = align(UV_Stride * UV_Scanlines, 4096)
  683. * Y_Meta_Stride = align(roundup(Width, Y_TileWidth), 64)
  684. * Y_Meta_Scanlines = align(roundup(Height, Y_TileHeight), 16)
  685. * Y_Meta_Plane_size = align(Y_Meta_Stride * Y_Meta_Scanlines, 4096)
  686. * UV_Meta_Stride = align(roundup(Width, UV_TileWidth), 64)
  687. * UV_Meta_Scanlines = align(roundup(Height, UV_TileHeight), 16)
  688. * UV_Meta_Plane_size = align(UV_Meta_Stride * UV_Meta_Scanlines, 4096)
  689. *
  690. * Total size = align(Y_UBWC_Plane_size + UV_UBWC_Plane_size +
  691. * Y_Meta_Plane_size + UV_Meta_Plane_size, 4096)
  692. */
  693. COLOR_FMT_P010_UBWC,
  694. /* Venus P010:
  695. * YUV 4:2:0 image with a plane of 10 bit Y samples followed
  696. * by an interleaved U/V plane containing 10 bit 2x2 subsampled
  697. * colour difference samples.
  698. *
  699. * <-------- Y/UV_Stride -------->
  700. * <------- Width ------->
  701. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . ^ ^
  702. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | |
  703. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . Height |
  704. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | Y_Scanlines
  705. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | |
  706. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | |
  707. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | |
  708. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . V |
  709. * . . . . . . . . . . . . . . . . |
  710. * . . . . . . . . . . . . . . . . |
  711. * . . . . . . . . . . . . . . . . |
  712. * . . . . . . . . . . . . . . . . V
  713. * U V U V U V U V U V U V . . . . ^
  714. * U V U V U V U V U V U V . . . . |
  715. * U V U V U V U V U V U V . . . . |
  716. * U V U V U V U V U V U V . . . . UV_Scanlines
  717. * . . . . . . . . . . . . . . . . |
  718. * . . . . . . . . . . . . . . . . V
  719. * . . . . . . . . . . . . . . . . --> Buffer size alignment
  720. *
  721. * Y_Stride : Width * 2 aligned to 256
  722. * UV_Stride : Width * 2 aligned to 256
  723. * Y_Scanlines: Height aligned to 32
  724. * UV_Scanlines: Height/2 aligned to 16
  725. * Total size = align(Y_Stride * Y_Scanlines
  726. * + UV_Stride * UV_Scanlines, 4096)
  727. */
  728. COLOR_FMT_P010,
  729. };
  730. /*
  731. * Function arguments:
  732. * @color_fmt
  733. * @width
  734. * Progressive: width
  735. * Interlaced: width
  736. */
  737. static inline unsigned int VENUS_Y_STRIDE(unsigned int color_fmt,
  738. unsigned int width)
  739. {
  740. unsigned int alignment, stride = 0;
  741. if (!width)
  742. goto invalid_input;
  743. switch (color_fmt) {
  744. case COLOR_FMT_NV12:
  745. case COLOR_FMT_NV21:
  746. case COLOR_FMT_NV12_UBWC:
  747. alignment = 128;
  748. stride = MSM_MEDIA_ALIGN(width, alignment);
  749. break;
  750. case COLOR_FMT_NV12_BPP10_UBWC:
  751. alignment = 256;
  752. stride = MSM_MEDIA_ALIGN(width, 192);
  753. stride = MSM_MEDIA_ALIGN(stride * 4/3, alignment);
  754. break;
  755. case COLOR_FMT_P010_UBWC:
  756. case COLOR_FMT_P010:
  757. alignment = 256;
  758. stride = MSM_MEDIA_ALIGN(width * 2, alignment);
  759. break;
  760. default:
  761. break;
  762. }
  763. invalid_input:
  764. return stride;
  765. }
  766. /*
  767. * Function arguments:
  768. * @color_fmt
  769. * @width
  770. * Progressive: width
  771. * Interlaced: width
  772. */
  773. static inline unsigned int VENUS_UV_STRIDE(unsigned int color_fmt,
  774. unsigned int width)
  775. {
  776. unsigned int alignment, stride = 0;
  777. if (!width)
  778. goto invalid_input;
  779. switch (color_fmt) {
  780. case COLOR_FMT_NV21:
  781. case COLOR_FMT_NV12:
  782. case COLOR_FMT_NV12_UBWC:
  783. alignment = 128;
  784. stride = MSM_MEDIA_ALIGN(width, alignment);
  785. break;
  786. case COLOR_FMT_NV12_BPP10_UBWC:
  787. alignment = 256;
  788. stride = MSM_MEDIA_ALIGN(width, 192);
  789. stride = MSM_MEDIA_ALIGN(stride * 4/3, alignment);
  790. break;
  791. case COLOR_FMT_P010_UBWC:
  792. case COLOR_FMT_P010:
  793. alignment = 256;
  794. stride = MSM_MEDIA_ALIGN(width * 2, alignment);
  795. break;
  796. default:
  797. break;
  798. }
  799. invalid_input:
  800. return stride;
  801. }
  802. /*
  803. * Function arguments:
  804. * @color_fmt
  805. * @height
  806. * Progressive: height
  807. * Interlaced: (height+1)>>1
  808. */
  809. static inline unsigned int VENUS_Y_SCANLINES(unsigned int color_fmt,
  810. unsigned int height)
  811. {
  812. unsigned int alignment, sclines = 0;
  813. if (!height)
  814. goto invalid_input;
  815. switch (color_fmt) {
  816. case COLOR_FMT_NV12:
  817. case COLOR_FMT_NV21:
  818. case COLOR_FMT_NV12_UBWC:
  819. case COLOR_FMT_P010:
  820. alignment = 32;
  821. break;
  822. case COLOR_FMT_NV12_BPP10_UBWC:
  823. case COLOR_FMT_P010_UBWC:
  824. alignment = 16;
  825. break;
  826. default:
  827. return 0;
  828. }
  829. sclines = MSM_MEDIA_ALIGN(height, alignment);
  830. invalid_input:
  831. return sclines;
  832. }
  833. /*
  834. * Function arguments:
  835. * @color_fmt
  836. * @height
  837. * Progressive: height
  838. * Interlaced: (height+1)>>1
  839. */
  840. static inline unsigned int VENUS_UV_SCANLINES(unsigned int color_fmt,
  841. unsigned int height)
  842. {
  843. unsigned int alignment, sclines = 0;
  844. if (!height)
  845. goto invalid_input;
  846. switch (color_fmt) {
  847. case COLOR_FMT_NV21:
  848. case COLOR_FMT_NV12:
  849. case COLOR_FMT_NV12_BPP10_UBWC:
  850. case COLOR_FMT_P010_UBWC:
  851. case COLOR_FMT_P010:
  852. alignment = 16;
  853. break;
  854. case COLOR_FMT_NV12_UBWC:
  855. alignment = 32;
  856. break;
  857. default:
  858. goto invalid_input;
  859. }
  860. sclines = MSM_MEDIA_ALIGN((height+1)>>1, alignment);
  861. invalid_input:
  862. return sclines;
  863. }
  864. /*
  865. * Function arguments:
  866. * @color_fmt
  867. * @width
  868. * Progressive: width
  869. * Interlaced: width
  870. */
  871. static inline unsigned int VENUS_Y_META_STRIDE(unsigned int color_fmt,
  872. unsigned int width)
  873. {
  874. int y_tile_width = 0, y_meta_stride = 0;
  875. if (!width)
  876. goto invalid_input;
  877. switch (color_fmt) {
  878. case COLOR_FMT_NV12_UBWC:
  879. case COLOR_FMT_P010_UBWC:
  880. y_tile_width = 32;
  881. break;
  882. case COLOR_FMT_NV12_BPP10_UBWC:
  883. y_tile_width = 48;
  884. break;
  885. default:
  886. goto invalid_input;
  887. }
  888. y_meta_stride = MSM_MEDIA_ROUNDUP(width, y_tile_width);
  889. y_meta_stride = MSM_MEDIA_ALIGN(y_meta_stride, 64);
  890. invalid_input:
  891. return y_meta_stride;
  892. }
  893. /*
  894. * Function arguments:
  895. * @color_fmt
  896. * @height
  897. * Progressive: height
  898. * Interlaced: (height+1)>>1
  899. */
  900. static inline unsigned int VENUS_Y_META_SCANLINES(unsigned int color_fmt,
  901. unsigned int height)
  902. {
  903. int y_tile_height = 0, y_meta_scanlines = 0;
  904. if (!height)
  905. goto invalid_input;
  906. switch (color_fmt) {
  907. case COLOR_FMT_NV12_UBWC:
  908. y_tile_height = 8;
  909. break;
  910. case COLOR_FMT_NV12_BPP10_UBWC:
  911. case COLOR_FMT_P010_UBWC:
  912. y_tile_height = 4;
  913. break;
  914. default:
  915. goto invalid_input;
  916. }
  917. y_meta_scanlines = MSM_MEDIA_ROUNDUP(height, y_tile_height);
  918. y_meta_scanlines = MSM_MEDIA_ALIGN(y_meta_scanlines, 16);
  919. invalid_input:
  920. return y_meta_scanlines;
  921. }
  922. /*
  923. * Function arguments:
  924. * @color_fmt
  925. * @width
  926. * Progressive: width
  927. * Interlaced: width
  928. */
  929. static inline unsigned int VENUS_UV_META_STRIDE(unsigned int color_fmt,
  930. unsigned int width)
  931. {
  932. int uv_tile_width = 0, uv_meta_stride = 0;
  933. if (!width)
  934. goto invalid_input;
  935. switch (color_fmt) {
  936. case COLOR_FMT_NV12_UBWC:
  937. case COLOR_FMT_P010_UBWC:
  938. uv_tile_width = 16;
  939. break;
  940. case COLOR_FMT_NV12_BPP10_UBWC:
  941. uv_tile_width = 24;
  942. break;
  943. default:
  944. goto invalid_input;
  945. }
  946. uv_meta_stride = MSM_MEDIA_ROUNDUP((width+1)>>1, uv_tile_width);
  947. uv_meta_stride = MSM_MEDIA_ALIGN(uv_meta_stride, 64);
  948. invalid_input:
  949. return uv_meta_stride;
  950. }
  951. /*
  952. * Function arguments:
  953. * @color_fmt
  954. * @height
  955. * Progressive: height
  956. * Interlaced: (height+1)>>1
  957. */
  958. static inline unsigned int VENUS_UV_META_SCANLINES(unsigned int color_fmt,
  959. unsigned int height)
  960. {
  961. int uv_tile_height = 0, uv_meta_scanlines = 0;
  962. if (!height)
  963. goto invalid_input;
  964. switch (color_fmt) {
  965. case COLOR_FMT_NV12_UBWC:
  966. uv_tile_height = 8;
  967. break;
  968. case COLOR_FMT_NV12_BPP10_UBWC:
  969. case COLOR_FMT_P010_UBWC:
  970. uv_tile_height = 4;
  971. break;
  972. default:
  973. goto invalid_input;
  974. }
  975. uv_meta_scanlines = MSM_MEDIA_ROUNDUP((height+1)>>1, uv_tile_height);
  976. uv_meta_scanlines = MSM_MEDIA_ALIGN(uv_meta_scanlines, 16);
  977. invalid_input:
  978. return uv_meta_scanlines;
  979. }
  980. static inline unsigned int VENUS_RGB_STRIDE(unsigned int color_fmt,
  981. unsigned int width)
  982. {
  983. unsigned int alignment = 0, stride = 0, bpp = 4;
  984. if (!width)
  985. goto invalid_input;
  986. switch (color_fmt) {
  987. case COLOR_FMT_RGBA8888:
  988. alignment = 128;
  989. break;
  990. case COLOR_FMT_RGB565_UBWC:
  991. alignment = 256;
  992. bpp = 2;
  993. break;
  994. case COLOR_FMT_RGBA8888_UBWC:
  995. case COLOR_FMT_RGBA1010102_UBWC:
  996. alignment = 256;
  997. break;
  998. default:
  999. goto invalid_input;
  1000. }
  1001. stride = MSM_MEDIA_ALIGN(width * bpp, alignment);
  1002. invalid_input:
  1003. return stride;
  1004. }
  1005. static inline unsigned int VENUS_RGB_SCANLINES(unsigned int color_fmt,
  1006. unsigned int height)
  1007. {
  1008. unsigned int alignment = 0, scanlines = 0;
  1009. if (!height)
  1010. goto invalid_input;
  1011. switch (color_fmt) {
  1012. case COLOR_FMT_RGBA8888:
  1013. alignment = 32;
  1014. break;
  1015. case COLOR_FMT_RGBA8888_UBWC:
  1016. case COLOR_FMT_RGBA1010102_UBWC:
  1017. case COLOR_FMT_RGB565_UBWC:
  1018. alignment = 16;
  1019. break;
  1020. default:
  1021. goto invalid_input;
  1022. }
  1023. scanlines = MSM_MEDIA_ALIGN(height, alignment);
  1024. invalid_input:
  1025. return scanlines;
  1026. }
  1027. static inline unsigned int VENUS_RGB_META_STRIDE(unsigned int color_fmt,
  1028. unsigned int width)
  1029. {
  1030. int rgb_tile_width = 0, rgb_meta_stride = 0;
  1031. if (!width)
  1032. goto invalid_input;
  1033. switch (color_fmt) {
  1034. case COLOR_FMT_RGBA8888_UBWC:
  1035. case COLOR_FMT_RGBA1010102_UBWC:
  1036. case COLOR_FMT_RGB565_UBWC:
  1037. rgb_tile_width = 16;
  1038. break;
  1039. default:
  1040. goto invalid_input;
  1041. }
  1042. rgb_meta_stride = MSM_MEDIA_ROUNDUP(width, rgb_tile_width);
  1043. rgb_meta_stride = MSM_MEDIA_ALIGN(rgb_meta_stride, 64);
  1044. invalid_input:
  1045. return rgb_meta_stride;
  1046. }
  1047. static inline unsigned int VENUS_RGB_META_SCANLINES(unsigned int color_fmt,
  1048. unsigned int height)
  1049. {
  1050. int rgb_tile_height = 0, rgb_meta_scanlines = 0;
  1051. if (!height)
  1052. goto invalid_input;
  1053. switch (color_fmt) {
  1054. case COLOR_FMT_RGBA8888_UBWC:
  1055. case COLOR_FMT_RGBA1010102_UBWC:
  1056. case COLOR_FMT_RGB565_UBWC:
  1057. rgb_tile_height = 4;
  1058. break;
  1059. default:
  1060. goto invalid_input;
  1061. }
  1062. rgb_meta_scanlines = MSM_MEDIA_ROUNDUP(height, rgb_tile_height);
  1063. rgb_meta_scanlines = MSM_MEDIA_ALIGN(rgb_meta_scanlines, 16);
  1064. invalid_input:
  1065. return rgb_meta_scanlines;
  1066. }
  1067. /*
  1068. * Function arguments:
  1069. * @color_fmt
  1070. * @width
  1071. * Progressive: width
  1072. * Interlaced: width
  1073. * @height
  1074. * Progressive: height
  1075. * Interlaced: height
  1076. */
  1077. static inline unsigned int VENUS_BUFFER_SIZE(unsigned int color_fmt,
  1078. unsigned int width, unsigned int height)
  1079. {
  1080. unsigned int size = 0;
  1081. unsigned int y_plane, uv_plane, y_stride,
  1082. uv_stride, y_sclines, uv_sclines;
  1083. unsigned int y_ubwc_plane = 0, uv_ubwc_plane = 0;
  1084. unsigned int y_meta_stride = 0, y_meta_scanlines = 0;
  1085. unsigned int uv_meta_stride = 0, uv_meta_scanlines = 0;
  1086. unsigned int y_meta_plane = 0, uv_meta_plane = 0;
  1087. unsigned int rgb_stride = 0, rgb_scanlines = 0;
  1088. unsigned int rgb_plane = 0, rgb_ubwc_plane = 0, rgb_meta_plane = 0;
  1089. unsigned int rgb_meta_stride = 0, rgb_meta_scanlines = 0;
  1090. if (!width || !height)
  1091. goto invalid_input;
  1092. y_stride = VENUS_Y_STRIDE(color_fmt, width);
  1093. uv_stride = VENUS_UV_STRIDE(color_fmt, width);
  1094. y_sclines = VENUS_Y_SCANLINES(color_fmt, height);
  1095. uv_sclines = VENUS_UV_SCANLINES(color_fmt, height);
  1096. rgb_stride = VENUS_RGB_STRIDE(color_fmt, width);
  1097. rgb_scanlines = VENUS_RGB_SCANLINES(color_fmt, height);
  1098. switch (color_fmt) {
  1099. case COLOR_FMT_NV21:
  1100. case COLOR_FMT_NV12:
  1101. case COLOR_FMT_P010:
  1102. y_plane = y_stride * y_sclines;
  1103. uv_plane = uv_stride * uv_sclines;
  1104. size = y_plane + uv_plane;
  1105. break;
  1106. case COLOR_FMT_NV12_UBWC:
  1107. y_meta_stride = VENUS_Y_META_STRIDE(color_fmt, width);
  1108. uv_meta_stride = VENUS_UV_META_STRIDE(color_fmt, width);
  1109. if (width <= INTERLACE_WIDTH_MAX &&
  1110. height <= INTERLACE_HEIGHT_MAX &&
  1111. (height * width) / 256 <= INTERLACE_MB_PER_FRAME_MAX) {
  1112. y_sclines =
  1113. VENUS_Y_SCANLINES(color_fmt, (height+1)>>1);
  1114. y_ubwc_plane =
  1115. MSM_MEDIA_ALIGN(y_stride * y_sclines, 4096);
  1116. uv_sclines =
  1117. VENUS_UV_SCANLINES(color_fmt, (height+1)>>1);
  1118. uv_ubwc_plane =
  1119. MSM_MEDIA_ALIGN(uv_stride * uv_sclines, 4096);
  1120. y_meta_scanlines =
  1121. VENUS_Y_META_SCANLINES(color_fmt, (height+1)>>1);
  1122. y_meta_plane = MSM_MEDIA_ALIGN(
  1123. y_meta_stride * y_meta_scanlines, 4096);
  1124. uv_meta_scanlines =
  1125. VENUS_UV_META_SCANLINES(color_fmt, (height+1)>>1);
  1126. uv_meta_plane = MSM_MEDIA_ALIGN(uv_meta_stride *
  1127. uv_meta_scanlines, 4096);
  1128. size = (y_ubwc_plane + uv_ubwc_plane + y_meta_plane +
  1129. uv_meta_plane)*2;
  1130. } else {
  1131. y_sclines = VENUS_Y_SCANLINES(color_fmt, height);
  1132. y_ubwc_plane =
  1133. MSM_MEDIA_ALIGN(y_stride * y_sclines, 4096);
  1134. uv_sclines = VENUS_UV_SCANLINES(color_fmt, height);
  1135. uv_ubwc_plane =
  1136. MSM_MEDIA_ALIGN(uv_stride * uv_sclines, 4096);
  1137. y_meta_scanlines =
  1138. VENUS_Y_META_SCANLINES(color_fmt, height);
  1139. y_meta_plane = MSM_MEDIA_ALIGN(
  1140. y_meta_stride * y_meta_scanlines, 4096);
  1141. uv_meta_scanlines =
  1142. VENUS_UV_META_SCANLINES(color_fmt, height);
  1143. uv_meta_plane = MSM_MEDIA_ALIGN(uv_meta_stride *
  1144. uv_meta_scanlines, 4096);
  1145. size = (y_ubwc_plane + uv_ubwc_plane + y_meta_plane +
  1146. uv_meta_plane);
  1147. }
  1148. break;
  1149. case COLOR_FMT_NV12_BPP10_UBWC:
  1150. y_ubwc_plane = MSM_MEDIA_ALIGN(y_stride * y_sclines, 4096);
  1151. uv_ubwc_plane = MSM_MEDIA_ALIGN(uv_stride * uv_sclines, 4096);
  1152. y_meta_stride = VENUS_Y_META_STRIDE(color_fmt, width);
  1153. y_meta_scanlines = VENUS_Y_META_SCANLINES(color_fmt, height);
  1154. y_meta_plane = MSM_MEDIA_ALIGN(
  1155. y_meta_stride * y_meta_scanlines, 4096);
  1156. uv_meta_stride = VENUS_UV_META_STRIDE(color_fmt, width);
  1157. uv_meta_scanlines = VENUS_UV_META_SCANLINES(color_fmt, height);
  1158. uv_meta_plane = MSM_MEDIA_ALIGN(uv_meta_stride *
  1159. uv_meta_scanlines, 4096);
  1160. size = y_ubwc_plane + uv_ubwc_plane + y_meta_plane +
  1161. uv_meta_plane;
  1162. break;
  1163. case COLOR_FMT_P010_UBWC:
  1164. y_ubwc_plane = MSM_MEDIA_ALIGN(y_stride * y_sclines, 4096);
  1165. uv_ubwc_plane = MSM_MEDIA_ALIGN(uv_stride * uv_sclines, 4096);
  1166. y_meta_stride = VENUS_Y_META_STRIDE(color_fmt, width);
  1167. y_meta_scanlines = VENUS_Y_META_SCANLINES(color_fmt, height);
  1168. y_meta_plane = MSM_MEDIA_ALIGN(
  1169. y_meta_stride * y_meta_scanlines, 4096);
  1170. uv_meta_stride = VENUS_UV_META_STRIDE(color_fmt, width);
  1171. uv_meta_scanlines = VENUS_UV_META_SCANLINES(color_fmt, height);
  1172. uv_meta_plane = MSM_MEDIA_ALIGN(uv_meta_stride *
  1173. uv_meta_scanlines, 4096);
  1174. size = y_ubwc_plane + uv_ubwc_plane + y_meta_plane +
  1175. uv_meta_plane;
  1176. break;
  1177. case COLOR_FMT_RGBA8888:
  1178. rgb_plane = MSM_MEDIA_ALIGN(rgb_stride * rgb_scanlines, 4096);
  1179. size = rgb_plane;
  1180. break;
  1181. case COLOR_FMT_RGBA8888_UBWC:
  1182. case COLOR_FMT_RGBA1010102_UBWC:
  1183. case COLOR_FMT_RGB565_UBWC:
  1184. rgb_ubwc_plane = MSM_MEDIA_ALIGN(rgb_stride * rgb_scanlines,
  1185. 4096);
  1186. rgb_meta_stride = VENUS_RGB_META_STRIDE(color_fmt, width);
  1187. rgb_meta_scanlines = VENUS_RGB_META_SCANLINES(color_fmt,
  1188. height);
  1189. rgb_meta_plane = MSM_MEDIA_ALIGN(rgb_meta_stride *
  1190. rgb_meta_scanlines, 4096);
  1191. size = rgb_ubwc_plane + rgb_meta_plane;
  1192. break;
  1193. default:
  1194. break;
  1195. }
  1196. invalid_input:
  1197. return MSM_MEDIA_ALIGN(size, 4096);
  1198. }
  1199. static inline unsigned int VENUS_BUFFER_SIZE_USED(unsigned int color_fmt,
  1200. unsigned int width, unsigned int height, unsigned int interlace)
  1201. {
  1202. unsigned int size = 0;
  1203. unsigned int y_stride, uv_stride, y_sclines, uv_sclines;
  1204. unsigned int y_ubwc_plane = 0, uv_ubwc_plane = 0;
  1205. unsigned int y_meta_stride = 0, y_meta_scanlines = 0;
  1206. unsigned int uv_meta_stride = 0, uv_meta_scanlines = 0;
  1207. unsigned int y_meta_plane = 0, uv_meta_plane = 0;
  1208. if (!width || !height)
  1209. goto invalid_input;
  1210. if (!interlace && color_fmt == COLOR_FMT_NV12_UBWC) {
  1211. y_stride = VENUS_Y_STRIDE(color_fmt, width);
  1212. uv_stride = VENUS_UV_STRIDE(color_fmt, width);
  1213. y_sclines = VENUS_Y_SCANLINES(color_fmt, height);
  1214. y_ubwc_plane = MSM_MEDIA_ALIGN(y_stride * y_sclines, 4096);
  1215. uv_sclines = VENUS_UV_SCANLINES(color_fmt, height);
  1216. uv_ubwc_plane = MSM_MEDIA_ALIGN(uv_stride * uv_sclines, 4096);
  1217. y_meta_stride = VENUS_Y_META_STRIDE(color_fmt, width);
  1218. y_meta_scanlines =
  1219. VENUS_Y_META_SCANLINES(color_fmt, height);
  1220. y_meta_plane = MSM_MEDIA_ALIGN(
  1221. y_meta_stride * y_meta_scanlines, 4096);
  1222. uv_meta_stride = VENUS_UV_META_STRIDE(color_fmt, width);
  1223. uv_meta_scanlines =
  1224. VENUS_UV_META_SCANLINES(color_fmt, height);
  1225. uv_meta_plane = MSM_MEDIA_ALIGN(uv_meta_stride *
  1226. uv_meta_scanlines, 4096);
  1227. size = (y_ubwc_plane + uv_ubwc_plane + y_meta_plane +
  1228. uv_meta_plane);
  1229. size = MSM_MEDIA_ALIGN(size, 4096);
  1230. } else {
  1231. size = VENUS_BUFFER_SIZE(color_fmt, width, height);
  1232. }
  1233. invalid_input:
  1234. return size;
  1235. }
  1236. #endif