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