msm_media_info.h 49 KB

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