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