msm_media_info.h 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355
  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 512
  48. * UV_Stride : Width aligned to 512
  49. * Y_Scanlines: Height aligned to 512
  50. * UV_Scanlines: Height/2 aligned to 256
  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 512
  83. * UV_Stride : Width aligned to 512
  84. * Y_Scanlines: Height aligned to 512
  85. * UV_Scanlines: Height/2 aligned to 256
  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. /* Venus NV12_512:
  730. * YUV 4:2:0 image with a plane of 8 bit Y samples followed
  731. * by an interleaved U/V plane containing 8 bit 2x2 subsampled
  732. * colour difference samples.
  733. *
  734. * <-------- Y/UV_Stride -------->
  735. * <------- Width ------->
  736. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . ^ ^
  737. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | |
  738. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . Height |
  739. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | Y_Scanlines
  740. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | |
  741. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | |
  742. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | |
  743. * Y Y Y Y Y Y Y Y Y Y Y Y . . . . V |
  744. * . . . . . . . . . . . . . . . . |
  745. * . . . . . . . . . . . . . . . . |
  746. * . . . . . . . . . . . . . . . . |
  747. * . . . . . . . . . . . . . . . . V
  748. * U V U V U V U V U V U V . . . . ^
  749. * U V U V U V U V U V U V . . . . |
  750. * U V U V U V U V U V U V . . . . |
  751. * U V U V U V U V U V U V . . . . UV_Scanlines
  752. * . . . . . . . . . . . . . . . . |
  753. * . . . . . . . . . . . . . . . . V
  754. * . . . . . . . . . . . . . . . . --> Buffer size alignment
  755. *
  756. * Y_Stride : Width aligned to 512
  757. * UV_Stride : Width aligned to 512
  758. * Y_Scanlines: Height aligned to 512
  759. * UV_Scanlines: Height/2 aligned to 256
  760. * Total size = align((Y_Stride * Y_Scanlines
  761. * + UV_Stride * UV_Scanlines), 4096)
  762. */
  763. COLOR_FMT_NV12_512,
  764. };
  765. /*
  766. * Function arguments:
  767. * @color_fmt
  768. * @width
  769. * Progressive: width
  770. * Interlaced: width
  771. */
  772. static inline unsigned int VENUS_Y_STRIDE(unsigned int color_fmt,
  773. unsigned int width)
  774. {
  775. unsigned int alignment, stride = 0;
  776. if (!width)
  777. goto invalid_input;
  778. switch (color_fmt) {
  779. case COLOR_FMT_NV12:
  780. case COLOR_FMT_NV21:
  781. case COLOR_FMT_NV12_512:
  782. alignment = 512;
  783. stride = MSM_MEDIA_ALIGN(width, alignment);
  784. break;
  785. case COLOR_FMT_NV12_UBWC:
  786. alignment = 128;
  787. stride = MSM_MEDIA_ALIGN(width, alignment);
  788. break;
  789. case COLOR_FMT_NV12_BPP10_UBWC:
  790. alignment = 256;
  791. stride = MSM_MEDIA_ALIGN(width, 192);
  792. stride = MSM_MEDIA_ALIGN(stride * 4/3, alignment);
  793. break;
  794. case COLOR_FMT_P010_UBWC:
  795. case COLOR_FMT_P010:
  796. alignment = 256;
  797. stride = MSM_MEDIA_ALIGN(width * 2, alignment);
  798. break;
  799. default:
  800. break;
  801. }
  802. invalid_input:
  803. return stride;
  804. }
  805. /*
  806. * Function arguments:
  807. * @color_fmt
  808. * @width
  809. * Progressive: width
  810. * Interlaced: width
  811. */
  812. static inline unsigned int VENUS_UV_STRIDE(unsigned int color_fmt,
  813. unsigned int width)
  814. {
  815. unsigned int alignment, stride = 0;
  816. if (!width)
  817. goto invalid_input;
  818. switch (color_fmt) {
  819. case COLOR_FMT_NV21:
  820. case COLOR_FMT_NV12:
  821. case COLOR_FMT_NV12_512:
  822. alignment = 512;
  823. stride = MSM_MEDIA_ALIGN(width, alignment);
  824. break;
  825. case COLOR_FMT_NV12_UBWC:
  826. alignment = 128;
  827. stride = MSM_MEDIA_ALIGN(width, alignment);
  828. break;
  829. case COLOR_FMT_NV12_BPP10_UBWC:
  830. alignment = 256;
  831. stride = MSM_MEDIA_ALIGN(width, 192);
  832. stride = MSM_MEDIA_ALIGN(stride * 4/3, alignment);
  833. break;
  834. case COLOR_FMT_P010_UBWC:
  835. case COLOR_FMT_P010:
  836. alignment = 256;
  837. stride = MSM_MEDIA_ALIGN(width * 2, alignment);
  838. break;
  839. default:
  840. break;
  841. }
  842. invalid_input:
  843. return stride;
  844. }
  845. /*
  846. * Function arguments:
  847. * @color_fmt
  848. * @height
  849. * Progressive: height
  850. * Interlaced: (height+1)>>1
  851. */
  852. static inline unsigned int VENUS_Y_SCANLINES(unsigned int color_fmt,
  853. unsigned int height)
  854. {
  855. unsigned int alignment, sclines = 0;
  856. if (!height)
  857. goto invalid_input;
  858. switch (color_fmt) {
  859. case COLOR_FMT_NV12:
  860. case COLOR_FMT_NV21:
  861. case COLOR_FMT_NV12_512:
  862. alignment = 512;
  863. break;
  864. case COLOR_FMT_NV12_UBWC:
  865. case COLOR_FMT_P010:
  866. alignment = 32;
  867. break;
  868. case COLOR_FMT_NV12_BPP10_UBWC:
  869. case COLOR_FMT_P010_UBWC:
  870. alignment = 16;
  871. break;
  872. default:
  873. return 0;
  874. }
  875. sclines = MSM_MEDIA_ALIGN(height, alignment);
  876. invalid_input:
  877. return sclines;
  878. }
  879. /*
  880. * Function arguments:
  881. * @color_fmt
  882. * @height
  883. * Progressive: height
  884. * Interlaced: (height+1)>>1
  885. */
  886. static inline unsigned int VENUS_UV_SCANLINES(unsigned int color_fmt,
  887. unsigned int height)
  888. {
  889. unsigned int alignment, sclines = 0;
  890. if (!height)
  891. goto invalid_input;
  892. switch (color_fmt) {
  893. case COLOR_FMT_NV21:
  894. case COLOR_FMT_NV12:
  895. case COLOR_FMT_NV12_512:
  896. alignment = 256;
  897. break;
  898. case COLOR_FMT_NV12_BPP10_UBWC:
  899. case COLOR_FMT_P010_UBWC:
  900. case COLOR_FMT_P010:
  901. alignment = 16;
  902. break;
  903. case COLOR_FMT_NV12_UBWC:
  904. alignment = 32;
  905. break;
  906. default:
  907. goto invalid_input;
  908. }
  909. sclines = MSM_MEDIA_ALIGN((height+1)>>1, alignment);
  910. invalid_input:
  911. return sclines;
  912. }
  913. /*
  914. * Function arguments:
  915. * @color_fmt
  916. * @width
  917. * Progressive: width
  918. * Interlaced: width
  919. */
  920. static inline unsigned int VENUS_Y_META_STRIDE(unsigned int color_fmt,
  921. unsigned int width)
  922. {
  923. int y_tile_width = 0, y_meta_stride = 0;
  924. if (!width)
  925. goto invalid_input;
  926. switch (color_fmt) {
  927. case COLOR_FMT_NV12_UBWC:
  928. case COLOR_FMT_P010_UBWC:
  929. y_tile_width = 32;
  930. break;
  931. case COLOR_FMT_NV12_BPP10_UBWC:
  932. y_tile_width = 48;
  933. break;
  934. default:
  935. goto invalid_input;
  936. }
  937. y_meta_stride = MSM_MEDIA_ROUNDUP(width, y_tile_width);
  938. y_meta_stride = MSM_MEDIA_ALIGN(y_meta_stride, 64);
  939. invalid_input:
  940. return y_meta_stride;
  941. }
  942. /*
  943. * Function arguments:
  944. * @color_fmt
  945. * @height
  946. * Progressive: height
  947. * Interlaced: (height+1)>>1
  948. */
  949. static inline unsigned int VENUS_Y_META_SCANLINES(unsigned int color_fmt,
  950. unsigned int height)
  951. {
  952. int y_tile_height = 0, y_meta_scanlines = 0;
  953. if (!height)
  954. goto invalid_input;
  955. switch (color_fmt) {
  956. case COLOR_FMT_NV12_UBWC:
  957. y_tile_height = 8;
  958. break;
  959. case COLOR_FMT_NV12_BPP10_UBWC:
  960. case COLOR_FMT_P010_UBWC:
  961. y_tile_height = 4;
  962. break;
  963. default:
  964. goto invalid_input;
  965. }
  966. y_meta_scanlines = MSM_MEDIA_ROUNDUP(height, y_tile_height);
  967. y_meta_scanlines = MSM_MEDIA_ALIGN(y_meta_scanlines, 16);
  968. invalid_input:
  969. return y_meta_scanlines;
  970. }
  971. /*
  972. * Function arguments:
  973. * @color_fmt
  974. * @width
  975. * Progressive: width
  976. * Interlaced: width
  977. */
  978. static inline unsigned int VENUS_UV_META_STRIDE(unsigned int color_fmt,
  979. unsigned int width)
  980. {
  981. int uv_tile_width = 0, uv_meta_stride = 0;
  982. if (!width)
  983. goto invalid_input;
  984. switch (color_fmt) {
  985. case COLOR_FMT_NV12_UBWC:
  986. case COLOR_FMT_P010_UBWC:
  987. uv_tile_width = 16;
  988. break;
  989. case COLOR_FMT_NV12_BPP10_UBWC:
  990. uv_tile_width = 24;
  991. break;
  992. default:
  993. goto invalid_input;
  994. }
  995. uv_meta_stride = MSM_MEDIA_ROUNDUP((width+1)>>1, uv_tile_width);
  996. uv_meta_stride = MSM_MEDIA_ALIGN(uv_meta_stride, 64);
  997. invalid_input:
  998. return uv_meta_stride;
  999. }
  1000. /*
  1001. * Function arguments:
  1002. * @color_fmt
  1003. * @height
  1004. * Progressive: height
  1005. * Interlaced: (height+1)>>1
  1006. */
  1007. static inline unsigned int VENUS_UV_META_SCANLINES(unsigned int color_fmt,
  1008. unsigned int height)
  1009. {
  1010. int uv_tile_height = 0, uv_meta_scanlines = 0;
  1011. if (!height)
  1012. goto invalid_input;
  1013. switch (color_fmt) {
  1014. case COLOR_FMT_NV12_UBWC:
  1015. uv_tile_height = 8;
  1016. break;
  1017. case COLOR_FMT_NV12_BPP10_UBWC:
  1018. case COLOR_FMT_P010_UBWC:
  1019. uv_tile_height = 4;
  1020. break;
  1021. default:
  1022. goto invalid_input;
  1023. }
  1024. uv_meta_scanlines = MSM_MEDIA_ROUNDUP((height+1)>>1, uv_tile_height);
  1025. uv_meta_scanlines = MSM_MEDIA_ALIGN(uv_meta_scanlines, 16);
  1026. invalid_input:
  1027. return uv_meta_scanlines;
  1028. }
  1029. static inline unsigned int VENUS_RGB_STRIDE(unsigned int color_fmt,
  1030. unsigned int width)
  1031. {
  1032. unsigned int alignment = 0, stride = 0, bpp = 4;
  1033. if (!width)
  1034. goto invalid_input;
  1035. switch (color_fmt) {
  1036. case COLOR_FMT_RGBA8888:
  1037. alignment = 128;
  1038. break;
  1039. case COLOR_FMT_RGB565_UBWC:
  1040. alignment = 256;
  1041. bpp = 2;
  1042. break;
  1043. case COLOR_FMT_RGBA8888_UBWC:
  1044. case COLOR_FMT_RGBA1010102_UBWC:
  1045. alignment = 256;
  1046. break;
  1047. default:
  1048. goto invalid_input;
  1049. }
  1050. stride = MSM_MEDIA_ALIGN(width * bpp, alignment);
  1051. invalid_input:
  1052. return stride;
  1053. }
  1054. static inline unsigned int VENUS_RGB_SCANLINES(unsigned int color_fmt,
  1055. unsigned int height)
  1056. {
  1057. unsigned int alignment = 0, scanlines = 0;
  1058. if (!height)
  1059. goto invalid_input;
  1060. switch (color_fmt) {
  1061. case COLOR_FMT_RGBA8888:
  1062. alignment = 32;
  1063. break;
  1064. case COLOR_FMT_RGBA8888_UBWC:
  1065. case COLOR_FMT_RGBA1010102_UBWC:
  1066. case COLOR_FMT_RGB565_UBWC:
  1067. alignment = 16;
  1068. break;
  1069. default:
  1070. goto invalid_input;
  1071. }
  1072. scanlines = MSM_MEDIA_ALIGN(height, alignment);
  1073. invalid_input:
  1074. return scanlines;
  1075. }
  1076. static inline unsigned int VENUS_RGB_META_STRIDE(unsigned int color_fmt,
  1077. unsigned int width)
  1078. {
  1079. int rgb_tile_width = 0, rgb_meta_stride = 0;
  1080. if (!width)
  1081. goto invalid_input;
  1082. switch (color_fmt) {
  1083. case COLOR_FMT_RGBA8888_UBWC:
  1084. case COLOR_FMT_RGBA1010102_UBWC:
  1085. case COLOR_FMT_RGB565_UBWC:
  1086. rgb_tile_width = 16;
  1087. break;
  1088. default:
  1089. goto invalid_input;
  1090. }
  1091. rgb_meta_stride = MSM_MEDIA_ROUNDUP(width, rgb_tile_width);
  1092. rgb_meta_stride = MSM_MEDIA_ALIGN(rgb_meta_stride, 64);
  1093. invalid_input:
  1094. return rgb_meta_stride;
  1095. }
  1096. static inline unsigned int VENUS_RGB_META_SCANLINES(unsigned int color_fmt,
  1097. unsigned int height)
  1098. {
  1099. int rgb_tile_height = 0, rgb_meta_scanlines = 0;
  1100. if (!height)
  1101. goto invalid_input;
  1102. switch (color_fmt) {
  1103. case COLOR_FMT_RGBA8888_UBWC:
  1104. case COLOR_FMT_RGBA1010102_UBWC:
  1105. case COLOR_FMT_RGB565_UBWC:
  1106. rgb_tile_height = 4;
  1107. break;
  1108. default:
  1109. goto invalid_input;
  1110. }
  1111. rgb_meta_scanlines = MSM_MEDIA_ROUNDUP(height, rgb_tile_height);
  1112. rgb_meta_scanlines = MSM_MEDIA_ALIGN(rgb_meta_scanlines, 16);
  1113. invalid_input:
  1114. return rgb_meta_scanlines;
  1115. }
  1116. /*
  1117. * Function arguments:
  1118. * @color_fmt
  1119. * @width
  1120. * Progressive: width
  1121. * Interlaced: width
  1122. * @height
  1123. * Progressive: height
  1124. * Interlaced: height
  1125. */
  1126. static inline unsigned int VENUS_BUFFER_SIZE(unsigned int color_fmt,
  1127. unsigned int width, unsigned int height)
  1128. {
  1129. unsigned int size = 0;
  1130. unsigned int y_plane, uv_plane, y_stride,
  1131. uv_stride, y_sclines, uv_sclines;
  1132. unsigned int y_ubwc_plane = 0, uv_ubwc_plane = 0;
  1133. unsigned int y_meta_stride = 0, y_meta_scanlines = 0;
  1134. unsigned int uv_meta_stride = 0, uv_meta_scanlines = 0;
  1135. unsigned int y_meta_plane = 0, uv_meta_plane = 0;
  1136. unsigned int rgb_stride = 0, rgb_scanlines = 0;
  1137. unsigned int rgb_plane = 0, rgb_ubwc_plane = 0, rgb_meta_plane = 0;
  1138. unsigned int rgb_meta_stride = 0, rgb_meta_scanlines = 0;
  1139. if (!width || !height)
  1140. goto invalid_input;
  1141. y_stride = VENUS_Y_STRIDE(color_fmt, width);
  1142. uv_stride = VENUS_UV_STRIDE(color_fmt, width);
  1143. y_sclines = VENUS_Y_SCANLINES(color_fmt, height);
  1144. uv_sclines = VENUS_UV_SCANLINES(color_fmt, height);
  1145. rgb_stride = VENUS_RGB_STRIDE(color_fmt, width);
  1146. rgb_scanlines = VENUS_RGB_SCANLINES(color_fmt, height);
  1147. switch (color_fmt) {
  1148. case COLOR_FMT_NV21:
  1149. case COLOR_FMT_NV12:
  1150. case COLOR_FMT_P010:
  1151. case COLOR_FMT_NV12_512:
  1152. y_plane = y_stride * y_sclines;
  1153. uv_plane = uv_stride * uv_sclines;
  1154. size = y_plane + uv_plane;
  1155. break;
  1156. case COLOR_FMT_NV12_UBWC:
  1157. y_meta_stride = VENUS_Y_META_STRIDE(color_fmt, width);
  1158. uv_meta_stride = VENUS_UV_META_STRIDE(color_fmt, width);
  1159. if (width <= INTERLACE_WIDTH_MAX &&
  1160. height <= INTERLACE_HEIGHT_MAX &&
  1161. (height * width) / 256 <= INTERLACE_MB_PER_FRAME_MAX) {
  1162. y_sclines =
  1163. VENUS_Y_SCANLINES(color_fmt, (height+1)>>1);
  1164. y_ubwc_plane =
  1165. MSM_MEDIA_ALIGN(y_stride * y_sclines, 4096);
  1166. uv_sclines =
  1167. VENUS_UV_SCANLINES(color_fmt, (height+1)>>1);
  1168. uv_ubwc_plane =
  1169. MSM_MEDIA_ALIGN(uv_stride * uv_sclines, 4096);
  1170. y_meta_scanlines =
  1171. VENUS_Y_META_SCANLINES(color_fmt, (height+1)>>1);
  1172. y_meta_plane = MSM_MEDIA_ALIGN(
  1173. y_meta_stride * y_meta_scanlines, 4096);
  1174. uv_meta_scanlines =
  1175. VENUS_UV_META_SCANLINES(color_fmt, (height+1)>>1);
  1176. uv_meta_plane = MSM_MEDIA_ALIGN(uv_meta_stride *
  1177. uv_meta_scanlines, 4096);
  1178. size = (y_ubwc_plane + uv_ubwc_plane + y_meta_plane +
  1179. uv_meta_plane)*2;
  1180. } else {
  1181. y_sclines = VENUS_Y_SCANLINES(color_fmt, height);
  1182. y_ubwc_plane =
  1183. MSM_MEDIA_ALIGN(y_stride * y_sclines, 4096);
  1184. uv_sclines = VENUS_UV_SCANLINES(color_fmt, height);
  1185. uv_ubwc_plane =
  1186. MSM_MEDIA_ALIGN(uv_stride * uv_sclines, 4096);
  1187. y_meta_scanlines =
  1188. VENUS_Y_META_SCANLINES(color_fmt, height);
  1189. y_meta_plane = MSM_MEDIA_ALIGN(
  1190. y_meta_stride * y_meta_scanlines, 4096);
  1191. uv_meta_scanlines =
  1192. VENUS_UV_META_SCANLINES(color_fmt, height);
  1193. uv_meta_plane = MSM_MEDIA_ALIGN(uv_meta_stride *
  1194. uv_meta_scanlines, 4096);
  1195. size = (y_ubwc_plane + uv_ubwc_plane + y_meta_plane +
  1196. uv_meta_plane);
  1197. }
  1198. break;
  1199. case COLOR_FMT_NV12_BPP10_UBWC:
  1200. y_ubwc_plane = MSM_MEDIA_ALIGN(y_stride * y_sclines, 4096);
  1201. uv_ubwc_plane = MSM_MEDIA_ALIGN(uv_stride * uv_sclines, 4096);
  1202. y_meta_stride = VENUS_Y_META_STRIDE(color_fmt, width);
  1203. y_meta_scanlines = VENUS_Y_META_SCANLINES(color_fmt, height);
  1204. y_meta_plane = MSM_MEDIA_ALIGN(
  1205. y_meta_stride * y_meta_scanlines, 4096);
  1206. uv_meta_stride = VENUS_UV_META_STRIDE(color_fmt, width);
  1207. uv_meta_scanlines = VENUS_UV_META_SCANLINES(color_fmt, height);
  1208. uv_meta_plane = MSM_MEDIA_ALIGN(uv_meta_stride *
  1209. uv_meta_scanlines, 4096);
  1210. size = y_ubwc_plane + uv_ubwc_plane + y_meta_plane +
  1211. uv_meta_plane;
  1212. break;
  1213. case COLOR_FMT_P010_UBWC:
  1214. y_ubwc_plane = MSM_MEDIA_ALIGN(y_stride * y_sclines, 4096);
  1215. uv_ubwc_plane = MSM_MEDIA_ALIGN(uv_stride * uv_sclines, 4096);
  1216. y_meta_stride = VENUS_Y_META_STRIDE(color_fmt, width);
  1217. y_meta_scanlines = VENUS_Y_META_SCANLINES(color_fmt, height);
  1218. y_meta_plane = MSM_MEDIA_ALIGN(
  1219. y_meta_stride * y_meta_scanlines, 4096);
  1220. uv_meta_stride = VENUS_UV_META_STRIDE(color_fmt, width);
  1221. uv_meta_scanlines = VENUS_UV_META_SCANLINES(color_fmt, height);
  1222. uv_meta_plane = MSM_MEDIA_ALIGN(uv_meta_stride *
  1223. uv_meta_scanlines, 4096);
  1224. size = y_ubwc_plane + uv_ubwc_plane + y_meta_plane +
  1225. uv_meta_plane;
  1226. break;
  1227. case COLOR_FMT_RGBA8888:
  1228. rgb_plane = MSM_MEDIA_ALIGN(rgb_stride * rgb_scanlines, 4096);
  1229. size = rgb_plane;
  1230. break;
  1231. case COLOR_FMT_RGBA8888_UBWC:
  1232. case COLOR_FMT_RGBA1010102_UBWC:
  1233. case COLOR_FMT_RGB565_UBWC:
  1234. rgb_ubwc_plane = MSM_MEDIA_ALIGN(rgb_stride * rgb_scanlines,
  1235. 4096);
  1236. rgb_meta_stride = VENUS_RGB_META_STRIDE(color_fmt, width);
  1237. rgb_meta_scanlines = VENUS_RGB_META_SCANLINES(color_fmt,
  1238. height);
  1239. rgb_meta_plane = MSM_MEDIA_ALIGN(rgb_meta_stride *
  1240. rgb_meta_scanlines, 4096);
  1241. size = rgb_ubwc_plane + rgb_meta_plane;
  1242. break;
  1243. default:
  1244. break;
  1245. }
  1246. invalid_input:
  1247. return MSM_MEDIA_ALIGN(size, 4096);
  1248. }
  1249. static inline unsigned int VENUS_BUFFER_SIZE_USED(unsigned int color_fmt,
  1250. unsigned int width, unsigned int height, unsigned int interlace)
  1251. {
  1252. unsigned int size = 0;
  1253. unsigned int y_stride, uv_stride, y_sclines, uv_sclines;
  1254. unsigned int y_ubwc_plane = 0, uv_ubwc_plane = 0;
  1255. unsigned int y_meta_stride = 0, y_meta_scanlines = 0;
  1256. unsigned int uv_meta_stride = 0, uv_meta_scanlines = 0;
  1257. unsigned int y_meta_plane = 0, uv_meta_plane = 0;
  1258. if (!width || !height)
  1259. goto invalid_input;
  1260. if (!interlace && color_fmt == COLOR_FMT_NV12_UBWC) {
  1261. y_stride = VENUS_Y_STRIDE(color_fmt, width);
  1262. uv_stride = VENUS_UV_STRIDE(color_fmt, width);
  1263. y_sclines = VENUS_Y_SCANLINES(color_fmt, height);
  1264. y_ubwc_plane = MSM_MEDIA_ALIGN(y_stride * y_sclines, 4096);
  1265. uv_sclines = VENUS_UV_SCANLINES(color_fmt, height);
  1266. uv_ubwc_plane = MSM_MEDIA_ALIGN(uv_stride * uv_sclines, 4096);
  1267. y_meta_stride = VENUS_Y_META_STRIDE(color_fmt, width);
  1268. y_meta_scanlines =
  1269. VENUS_Y_META_SCANLINES(color_fmt, height);
  1270. y_meta_plane = MSM_MEDIA_ALIGN(
  1271. y_meta_stride * y_meta_scanlines, 4096);
  1272. uv_meta_stride = VENUS_UV_META_STRIDE(color_fmt, width);
  1273. uv_meta_scanlines =
  1274. VENUS_UV_META_SCANLINES(color_fmt, height);
  1275. uv_meta_plane = MSM_MEDIA_ALIGN(uv_meta_stride *
  1276. uv_meta_scanlines, 4096);
  1277. size = (y_ubwc_plane + uv_ubwc_plane + y_meta_plane +
  1278. uv_meta_plane);
  1279. size = MSM_MEDIA_ALIGN(size, 4096);
  1280. } else {
  1281. size = VENUS_BUFFER_SIZE(color_fmt, width, height);
  1282. }
  1283. invalid_input:
  1284. return size;
  1285. }
  1286. #endif