blob: be87b1e652d4308f60a34e27e5b58e0db1ccffdb [file] [log] [blame]
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -08001#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,
Umesh Pandey929a7912017-03-03 17:45:33 -0800153 /*
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:
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -0800159 * 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)
Umesh Pandey929a7912017-03-03 17:45:33 -0800244 *
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)
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -0800424 */
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};
773
774#define COLOR_FMT_RGBA1010102_UBWC COLOR_FMT_RGBA1010102_UBWC
775#define COLOR_FMT_RGB565_UBWC COLOR_FMT_RGB565_UBWC
776#define COLOR_FMT_P010_UBWC COLOR_FMT_P010_UBWC
777
778static inline unsigned int VENUS_EXTRADATA_SIZE(int width, int height)
779{
780 (void)height;
781 (void)width;
782
783 /*
784 * In the future, calculate the size based on the w/h but just
785 * hardcode it for now since 16K satisfies all current usecases.
786 */
787 return 16 * 1024;
788}
789
Umesh Pandey929a7912017-03-03 17:45:33 -0800790/*
791 * Function arguments:
792 * @color_fmt
793 * @width
794 * Progressive: width
795 * Interlaced: width
796 */
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -0800797static inline unsigned int VENUS_Y_STRIDE(int color_fmt, int width)
798{
799 unsigned int alignment, stride = 0;
800
801 if (!width)
802 goto invalid_input;
803
804 switch (color_fmt) {
805 case COLOR_FMT_NV21:
806 case COLOR_FMT_NV12:
807 case COLOR_FMT_NV12_MVTB:
808 case COLOR_FMT_NV12_UBWC:
809 alignment = 128;
810 stride = MSM_MEDIA_ALIGN(width, alignment);
811 break;
812 case COLOR_FMT_NV12_BPP10_UBWC:
813 alignment = 256;
814 stride = MSM_MEDIA_ALIGN(width, 192);
815 stride = MSM_MEDIA_ALIGN(stride * 4/3, alignment);
816 break;
817 case COLOR_FMT_P010_UBWC:
818 alignment = 256;
819 stride = MSM_MEDIA_ALIGN(width * 2, alignment);
820 break;
821 default:
822 break;
823 }
824invalid_input:
825 return stride;
826}
827
Umesh Pandey929a7912017-03-03 17:45:33 -0800828/*
829 * Function arguments:
830 * @color_fmt
831 * @width
832 * Progressive: width
833 * Interlaced: width
834 */
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -0800835static inline unsigned int VENUS_UV_STRIDE(int color_fmt, int width)
836{
837 unsigned int alignment, stride = 0;
838
839 if (!width)
840 goto invalid_input;
841
842 switch (color_fmt) {
843 case COLOR_FMT_NV21:
844 case COLOR_FMT_NV12:
845 case COLOR_FMT_NV12_MVTB:
846 case COLOR_FMT_NV12_UBWC:
847 alignment = 128;
848 stride = MSM_MEDIA_ALIGN(width, alignment);
849 break;
850 case COLOR_FMT_NV12_BPP10_UBWC:
851 alignment = 256;
852 stride = MSM_MEDIA_ALIGN(width, 192);
853 stride = MSM_MEDIA_ALIGN(stride * 4/3, alignment);
854 break;
855 case COLOR_FMT_P010_UBWC:
856 alignment = 256;
857 stride = MSM_MEDIA_ALIGN(width * 2, alignment);
858 break;
859 default:
860 break;
861 }
862invalid_input:
863 return stride;
864}
865
Umesh Pandey929a7912017-03-03 17:45:33 -0800866/*
867 * Function arguments:
868 * @color_fmt
869 * @height
870 * Progressive: height
871 * Interlaced: (height+1)>>1
872 */
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -0800873static inline unsigned int VENUS_Y_SCANLINES(int color_fmt, int height)
874{
875 unsigned int alignment, sclines = 0;
876
877 if (!height)
878 goto invalid_input;
879
880 switch (color_fmt) {
881 case COLOR_FMT_NV21:
882 case COLOR_FMT_NV12:
883 case COLOR_FMT_NV12_MVTB:
884 case COLOR_FMT_NV12_UBWC:
885 alignment = 32;
886 break;
887 case COLOR_FMT_NV12_BPP10_UBWC:
888 case COLOR_FMT_P010_UBWC:
889 alignment = 16;
890 break;
891 default:
892 return 0;
893 }
894 sclines = MSM_MEDIA_ALIGN(height, alignment);
895invalid_input:
896 return sclines;
897}
898
Umesh Pandey929a7912017-03-03 17:45:33 -0800899/*
900 * Function arguments:
901 * @color_fmt
902 * @height
903 * Progressive: height
904 * Interlaced: (height+1)>>1
905 */
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -0800906static inline unsigned int VENUS_UV_SCANLINES(int color_fmt, int height)
907{
908 unsigned int alignment, sclines = 0;
909
910 if (!height)
911 goto invalid_input;
912
913 switch (color_fmt) {
914 case COLOR_FMT_NV21:
915 case COLOR_FMT_NV12:
916 case COLOR_FMT_NV12_MVTB:
917 case COLOR_FMT_NV12_BPP10_UBWC:
918 case COLOR_FMT_P010_UBWC:
919 alignment = 16;
920 break;
921 case COLOR_FMT_NV12_UBWC:
922 alignment = 32;
923 break;
924 default:
925 goto invalid_input;
926 }
927
Umesh Pandey929a7912017-03-03 17:45:33 -0800928 sclines = MSM_MEDIA_ALIGN((height+1)>>1, alignment);
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -0800929
930invalid_input:
931 return sclines;
932}
933
Umesh Pandey929a7912017-03-03 17:45:33 -0800934/*
935 * Function arguments:
936 * @color_fmt
937 * @width
938 * Progressive: width
939 * Interlaced: width
940 */
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -0800941static inline unsigned int VENUS_Y_META_STRIDE(int color_fmt, int width)
942{
943 int y_tile_width = 0, y_meta_stride = 0;
944
945 if (!width)
946 goto invalid_input;
947
948 switch (color_fmt) {
949 case COLOR_FMT_NV12_UBWC:
950 case COLOR_FMT_P010_UBWC:
951 y_tile_width = 32;
952 break;
953 case COLOR_FMT_NV12_BPP10_UBWC:
954 y_tile_width = 48;
955 break;
956 default:
957 goto invalid_input;
958 }
959
960 y_meta_stride = MSM_MEDIA_ROUNDUP(width, y_tile_width);
961 y_meta_stride = MSM_MEDIA_ALIGN(y_meta_stride, 64);
962
963invalid_input:
964 return y_meta_stride;
965}
966
Umesh Pandey929a7912017-03-03 17:45:33 -0800967/*
968 * Function arguments:
969 * @color_fmt
970 * @height
971 * Progressive: height
972 * Interlaced: (height+1)>>1
973 */
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -0800974static inline unsigned int VENUS_Y_META_SCANLINES(int color_fmt, int height)
975{
976 int y_tile_height = 0, y_meta_scanlines = 0;
977
978 if (!height)
979 goto invalid_input;
980
981 switch (color_fmt) {
982 case COLOR_FMT_NV12_UBWC:
983 y_tile_height = 8;
984 break;
985 case COLOR_FMT_NV12_BPP10_UBWC:
986 case COLOR_FMT_P010_UBWC:
987 y_tile_height = 4;
988 break;
989 default:
990 goto invalid_input;
991 }
992
993 y_meta_scanlines = MSM_MEDIA_ROUNDUP(height, y_tile_height);
994 y_meta_scanlines = MSM_MEDIA_ALIGN(y_meta_scanlines, 16);
995
996invalid_input:
997 return y_meta_scanlines;
998}
999
Umesh Pandey929a7912017-03-03 17:45:33 -08001000/*
1001 * Function arguments:
1002 * @color_fmt
1003 * @width
1004 * Progressive: width
1005 * Interlaced: width
1006 */
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -08001007static inline unsigned int VENUS_UV_META_STRIDE(int color_fmt, int width)
1008{
1009 int uv_tile_width = 0, uv_meta_stride = 0;
1010
1011 if (!width)
1012 goto invalid_input;
1013
1014 switch (color_fmt) {
1015 case COLOR_FMT_NV12_UBWC:
1016 case COLOR_FMT_P010_UBWC:
1017 uv_tile_width = 16;
1018 break;
1019 case COLOR_FMT_NV12_BPP10_UBWC:
1020 uv_tile_width = 24;
1021 break;
1022 default:
1023 goto invalid_input;
1024 }
1025
Umesh Pandey929a7912017-03-03 17:45:33 -08001026 uv_meta_stride = MSM_MEDIA_ROUNDUP((width+1)>>1, uv_tile_width);
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -08001027 uv_meta_stride = MSM_MEDIA_ALIGN(uv_meta_stride, 64);
1028
1029invalid_input:
1030 return uv_meta_stride;
1031}
1032
Umesh Pandey929a7912017-03-03 17:45:33 -08001033/*
1034 * Function arguments:
1035 * @color_fmt
1036 * @height
1037 * Progressive: height
1038 * Interlaced: (height+1)>>1
1039 */
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -08001040static inline unsigned int VENUS_UV_META_SCANLINES(int color_fmt, int height)
1041{
1042 int uv_tile_height = 0, uv_meta_scanlines = 0;
1043
1044 if (!height)
1045 goto invalid_input;
1046
1047 switch (color_fmt) {
1048 case COLOR_FMT_NV12_UBWC:
1049 uv_tile_height = 8;
1050 break;
1051 case COLOR_FMT_NV12_BPP10_UBWC:
1052 case COLOR_FMT_P010_UBWC:
1053 uv_tile_height = 4;
1054 break;
1055 default:
1056 goto invalid_input;
1057 }
1058
Umesh Pandey929a7912017-03-03 17:45:33 -08001059 uv_meta_scanlines = MSM_MEDIA_ROUNDUP((height+1)>>1, uv_tile_height);
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -08001060 uv_meta_scanlines = MSM_MEDIA_ALIGN(uv_meta_scanlines, 16);
1061
1062invalid_input:
1063 return uv_meta_scanlines;
1064}
1065
1066static inline unsigned int VENUS_RGB_STRIDE(int color_fmt, int width)
1067{
1068 unsigned int alignment = 0, stride = 0, bpp = 4;
1069
1070 if (!width)
1071 goto invalid_input;
1072
1073 switch (color_fmt) {
1074 case COLOR_FMT_RGBA8888:
1075 alignment = 128;
1076 break;
1077 case COLOR_FMT_RGB565_UBWC:
Alexander Beykun3a271652017-04-06 14:25:07 -07001078 alignment = 256;
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -08001079 bpp = 2;
1080 break;
1081 case COLOR_FMT_RGBA8888_UBWC:
1082 case COLOR_FMT_RGBA1010102_UBWC:
1083 alignment = 256;
1084 break;
1085 default:
1086 goto invalid_input;
1087 }
1088
1089 stride = MSM_MEDIA_ALIGN(width * bpp, alignment);
1090
1091invalid_input:
1092 return stride;
1093}
1094
1095static inline unsigned int VENUS_RGB_SCANLINES(int color_fmt, int height)
1096{
1097 unsigned int alignment = 0, scanlines = 0;
1098
1099 if (!height)
1100 goto invalid_input;
1101
1102 switch (color_fmt) {
1103 case COLOR_FMT_RGBA8888:
1104 alignment = 32;
1105 break;
1106 case COLOR_FMT_RGBA8888_UBWC:
1107 case COLOR_FMT_RGBA1010102_UBWC:
1108 case COLOR_FMT_RGB565_UBWC:
1109 alignment = 16;
1110 break;
1111 default:
1112 goto invalid_input;
1113 }
1114
1115 scanlines = MSM_MEDIA_ALIGN(height, alignment);
1116
1117invalid_input:
1118 return scanlines;
1119}
1120
1121static inline unsigned int VENUS_RGB_META_STRIDE(int color_fmt, int width)
1122{
1123 int rgb_tile_width = 0, rgb_meta_stride = 0;
1124
1125 if (!width)
1126 goto invalid_input;
1127
1128 switch (color_fmt) {
1129 case COLOR_FMT_RGBA8888_UBWC:
1130 case COLOR_FMT_RGBA1010102_UBWC:
1131 case COLOR_FMT_RGB565_UBWC:
1132 rgb_tile_width = 16;
1133 break;
1134 default:
1135 goto invalid_input;
1136 }
1137
1138 rgb_meta_stride = MSM_MEDIA_ROUNDUP(width, rgb_tile_width);
1139 rgb_meta_stride = MSM_MEDIA_ALIGN(rgb_meta_stride, 64);
1140
1141invalid_input:
1142 return rgb_meta_stride;
1143}
1144
1145static inline unsigned int VENUS_RGB_META_SCANLINES(int color_fmt, int height)
1146{
1147 int rgb_tile_height = 0, rgb_meta_scanlines = 0;
1148
1149 if (!height)
1150 goto invalid_input;
1151
1152 switch (color_fmt) {
1153 case COLOR_FMT_RGBA8888_UBWC:
1154 case COLOR_FMT_RGBA1010102_UBWC:
1155 case COLOR_FMT_RGB565_UBWC:
1156 rgb_tile_height = 4;
1157 break;
1158 default:
1159 goto invalid_input;
1160 }
1161
1162 rgb_meta_scanlines = MSM_MEDIA_ROUNDUP(height, rgb_tile_height);
1163 rgb_meta_scanlines = MSM_MEDIA_ALIGN(rgb_meta_scanlines, 16);
1164
1165invalid_input:
1166 return rgb_meta_scanlines;
1167}
1168
Umesh Pandey929a7912017-03-03 17:45:33 -08001169/*
1170 * Function arguments:
1171 * @color_fmt
1172 * @width
1173 * Progressive: width
1174 * Interlaced: width
1175 * @height
1176 * Progressive: height
1177 * Interlaced: height
1178 */
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -08001179static inline unsigned int VENUS_BUFFER_SIZE(
1180 int color_fmt, int width, int height)
1181{
1182 const unsigned int extra_size = VENUS_EXTRADATA_SIZE(width, height);
1183 unsigned int uv_alignment = 0, size = 0;
1184 unsigned int y_plane, uv_plane, y_stride,
1185 uv_stride, y_sclines, uv_sclines;
1186 unsigned int y_ubwc_plane = 0, uv_ubwc_plane = 0;
1187 unsigned int y_meta_stride = 0, y_meta_scanlines = 0;
1188 unsigned int uv_meta_stride = 0, uv_meta_scanlines = 0;
1189 unsigned int y_meta_plane = 0, uv_meta_plane = 0;
1190 unsigned int rgb_stride = 0, rgb_scanlines = 0;
1191 unsigned int rgb_plane = 0, rgb_ubwc_plane = 0, rgb_meta_plane = 0;
1192 unsigned int rgb_meta_stride = 0, rgb_meta_scanlines = 0;
1193
1194 if (!width || !height)
1195 goto invalid_input;
1196
1197 y_stride = VENUS_Y_STRIDE(color_fmt, width);
1198 uv_stride = VENUS_UV_STRIDE(color_fmt, width);
1199 y_sclines = VENUS_Y_SCANLINES(color_fmt, height);
1200 uv_sclines = VENUS_UV_SCANLINES(color_fmt, height);
1201 rgb_stride = VENUS_RGB_STRIDE(color_fmt, width);
1202 rgb_scanlines = VENUS_RGB_SCANLINES(color_fmt, height);
1203
1204 switch (color_fmt) {
1205 case COLOR_FMT_NV21:
1206 case COLOR_FMT_NV12:
1207 uv_alignment = 4096;
1208 y_plane = y_stride * y_sclines;
1209 uv_plane = uv_stride * uv_sclines + uv_alignment;
1210 size = y_plane + uv_plane +
1211 MSM_MEDIA_MAX(extra_size, 8 * y_stride);
1212 size = MSM_MEDIA_ALIGN(size, 4096);
1213 break;
1214 case COLOR_FMT_NV12_MVTB:
1215 uv_alignment = 4096;
1216 y_plane = y_stride * y_sclines;
1217 uv_plane = uv_stride * uv_sclines + uv_alignment;
1218 size = y_plane + uv_plane;
1219 size = 2 * size + extra_size;
1220 size = MSM_MEDIA_ALIGN(size, 4096);
1221 break;
1222 case COLOR_FMT_NV12_UBWC:
Umesh Pandey929a7912017-03-03 17:45:33 -08001223 y_sclines = VENUS_Y_SCANLINES(color_fmt, (height+1)>>1);
1224 y_ubwc_plane = MSM_MEDIA_ALIGN(y_stride * y_sclines, 4096);
1225 uv_sclines = VENUS_UV_SCANLINES(color_fmt, (height+1)>>1);
1226 uv_ubwc_plane = MSM_MEDIA_ALIGN(uv_stride * uv_sclines, 4096);
1227 y_meta_stride = VENUS_Y_META_STRIDE(color_fmt, width);
1228 y_meta_scanlines =
1229 VENUS_Y_META_SCANLINES(color_fmt, (height+1)>>1);
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 =
1234 VENUS_UV_META_SCANLINES(color_fmt, (height+1)>>1);
1235 uv_meta_plane = MSM_MEDIA_ALIGN(uv_meta_stride *
1236 uv_meta_scanlines, 4096);
1237
1238 size = (y_ubwc_plane + uv_ubwc_plane + y_meta_plane +
1239 uv_meta_plane)*2 +
1240 MSM_MEDIA_MAX(extra_size + 8192, 48 * y_stride);
1241 size = MSM_MEDIA_ALIGN(size, 4096);
1242 break;
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -08001243 case COLOR_FMT_NV12_BPP10_UBWC:
1244 y_ubwc_plane = MSM_MEDIA_ALIGN(y_stride * y_sclines, 4096);
1245 uv_ubwc_plane = MSM_MEDIA_ALIGN(uv_stride * uv_sclines, 4096);
1246 y_meta_stride = VENUS_Y_META_STRIDE(color_fmt, width);
1247 y_meta_scanlines = VENUS_Y_META_SCANLINES(color_fmt, height);
1248 y_meta_plane = MSM_MEDIA_ALIGN(
1249 y_meta_stride * y_meta_scanlines, 4096);
1250 uv_meta_stride = VENUS_UV_META_STRIDE(color_fmt, width);
1251 uv_meta_scanlines = VENUS_UV_META_SCANLINES(color_fmt, height);
1252 uv_meta_plane = MSM_MEDIA_ALIGN(uv_meta_stride *
1253 uv_meta_scanlines, 4096);
1254
1255 size = y_ubwc_plane + uv_ubwc_plane + y_meta_plane +
1256 uv_meta_plane +
1257 MSM_MEDIA_MAX(extra_size + 8192, 48 * y_stride);
1258 size = MSM_MEDIA_ALIGN(size, 4096);
1259 break;
1260 case COLOR_FMT_P010_UBWC:
1261 y_ubwc_plane = MSM_MEDIA_ALIGN(y_stride * y_sclines, 4096);
1262 uv_ubwc_plane = MSM_MEDIA_ALIGN(uv_stride * uv_sclines, 4096);
1263 y_meta_stride = VENUS_Y_META_STRIDE(color_fmt, width);
1264 y_meta_scanlines = VENUS_Y_META_SCANLINES(color_fmt, height);
1265 y_meta_plane = MSM_MEDIA_ALIGN(
1266 y_meta_stride * y_meta_scanlines, 4096);
1267 uv_meta_stride = VENUS_UV_META_STRIDE(color_fmt, width);
1268 uv_meta_scanlines = VENUS_UV_META_SCANLINES(color_fmt, height);
1269 uv_meta_plane = MSM_MEDIA_ALIGN(uv_meta_stride *
1270 uv_meta_scanlines, 4096);
1271
1272 size = y_ubwc_plane + uv_ubwc_plane + y_meta_plane +
1273 uv_meta_plane;
1274 size = MSM_MEDIA_ALIGN(size, 4096);
1275 break;
1276 case COLOR_FMT_RGBA8888:
1277 rgb_plane = MSM_MEDIA_ALIGN(rgb_stride * rgb_scanlines, 4096);
1278 size = rgb_plane;
1279 size = MSM_MEDIA_ALIGN(size, 4096);
1280 break;
1281 case COLOR_FMT_RGBA8888_UBWC:
Alexander Beykun3a271652017-04-06 14:25:07 -07001282 case COLOR_FMT_RGBA1010102_UBWC:
1283 case COLOR_FMT_RGB565_UBWC:
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -08001284 rgb_ubwc_plane = MSM_MEDIA_ALIGN(rgb_stride * rgb_scanlines,
1285 4096);
1286 rgb_meta_stride = VENUS_RGB_META_STRIDE(color_fmt, width);
1287 rgb_meta_scanlines = VENUS_RGB_META_SCANLINES(color_fmt,
1288 height);
1289 rgb_meta_plane = MSM_MEDIA_ALIGN(rgb_meta_stride *
1290 rgb_meta_scanlines, 4096);
1291 size = rgb_ubwc_plane + rgb_meta_plane;
1292 size = MSM_MEDIA_ALIGN(size, 4096);
1293 break;
1294 default:
1295 break;
1296 }
1297invalid_input:
1298 return size;
1299}
1300
1301static inline unsigned int VENUS_VIEW2_OFFSET(
1302 int color_fmt, int width, int height)
1303{
1304 unsigned int offset = 0;
1305 unsigned int y_plane, uv_plane, y_stride,
1306 uv_stride, y_sclines, uv_sclines;
1307 if (!width || !height)
1308 goto invalid_input;
1309
1310 y_stride = VENUS_Y_STRIDE(color_fmt, width);
1311 uv_stride = VENUS_UV_STRIDE(color_fmt, width);
1312 y_sclines = VENUS_Y_SCANLINES(color_fmt, height);
1313 uv_sclines = VENUS_UV_SCANLINES(color_fmt, height);
1314 switch (color_fmt) {
1315 case COLOR_FMT_NV12_MVTB:
1316 y_plane = y_stride * y_sclines;
1317 uv_plane = uv_stride * uv_sclines;
1318 offset = y_plane + uv_plane;
1319 break;
1320 default:
1321 break;
1322 }
1323invalid_input:
1324 return offset;
1325}
1326
1327#endif