1 #ifndef __MEDIA_INFO_H__ 2 #define __MEDIA_INFO_H__ 3 4 #ifndef MSM_MEDIA_ALIGN 5 #define MSM_MEDIA_ALIGN(__sz, __align) (((__sz) + (__align-1)) & (~(__align-1))) 6 #endif 7 8 #ifndef MSM_MEDIA_ROUNDUP 9 #define MSM_MEDIA_ROUNDUP(__sz, __r) (((__sz) + ((__r) - 1)) / (__r)) 10 #endif 11 12 enum color_fmts { 13 /* Venus NV12: 14 * YUV 4:2:0 image with a plane of 8 bit Y samples followed 15 * by an interleaved U/V plane containing 8 bit 2x2 subsampled 16 * colour difference samples. 17 * 18 * <-------- Y/UV_Stride --------> 19 * <------- Width -------> 20 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . ^ ^ 21 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | | 22 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . Height | 23 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | Y_Scanlines 24 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | | 25 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | | 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 . . . . V | 28 * . . . . . . . . . . . . . . . . | 29 * . . . . . . . . . . . . . . . . | 30 * . . . . . . . . . . . . . . . . | 31 * . . . . . . . . . . . . . . . . V 32 * U V U V U V U V U V U V . . . . ^ 33 * U V U V U V U V U V U V . . . . | 34 * U V U V U V U V U V U V . . . . | 35 * U V U V U V U V U V U V . . . . UV_Scanlines 36 * . . . . . . . . . . . . . . . . | 37 * . . . . . . . . . . . . . . . . V 38 * . . . . . . . . . . . . . . . . --> Buffer size alignment 39 * 40 * Y_Stride : Width aligned to 128 41 * UV_Stride : Width aligned to 128 42 * Y_Scanlines: Height aligned to 32 43 * UV_Scanlines: Height/2 aligned to 16 44 * Extradata: Arbitrary (software-imposed) padding 45 * Total size = align((Y_Stride * Y_Scanlines 46 * + UV_Stride * UV_Scanlines + Extradata), 4096) 47 */ 48 COLOR_FMT_NV12, 49 50 /* Venus NV21: 51 * YUV 4:2:0 image with a plane of 8 bit Y samples followed 52 * by an interleaved V/U plane containing 8 bit 2x2 subsampled 53 * colour difference samples. 54 * 55 * <-------- Y/UV_Stride --------> 56 * <------- Width -------> 57 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . ^ ^ 58 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | | 59 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . Height | 60 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | Y_Scanlines 61 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | | 62 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | | 63 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | | 64 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . V | 65 * . . . . . . . . . . . . . . . . | 66 * . . . . . . . . . . . . . . . . | 67 * . . . . . . . . . . . . . . . . | 68 * . . . . . . . . . . . . . . . . V 69 * V U V U V U V U V U V U . . . . ^ 70 * V U V U V U V U V U V U . . . . | 71 * V U V U V U V U V U V U . . . . | 72 * V U V U V U V U V U V U . . . . UV_Scanlines 73 * . . . . . . . . . . . . . . . . | 74 * . . . . . . . . . . . . . . . . V 75 * . . . . . . . . . . . . . . . . --> Padding & Buffer size alignment 76 * 77 * Y_Stride : Width aligned to 128 78 * UV_Stride : Width aligned to 128 79 * Y_Scanlines: Height aligned to 32 80 * UV_Scanlines: Height/2 aligned to 16 81 * Extradata: Arbitrary (software-imposed) padding 82 * Total size = align((Y_Stride * Y_Scanlines 83 * + UV_Stride * UV_Scanlines + Extradata), 4096) 84 */ 85 COLOR_FMT_NV21, 86 /* Venus NV12_MVTB: 87 * Two YUV 4:2:0 images/views one after the other 88 * in a top-bottom layout, same as NV12 89 * with a plane of 8 bit Y samples followed 90 * by an interleaved U/V plane containing 8 bit 2x2 subsampled 91 * colour difference samples. 92 * 93 * 94 * <-------- Y/UV_Stride --------> 95 * <------- Width -------> 96 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . ^ ^ ^ 97 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | | | 98 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . Height | | 99 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | Y_Scanlines | 100 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | | | 101 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | | | 102 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | | | 103 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . V | | 104 * . . . . . . . . . . . . . . . . | View_1 105 * . . . . . . . . . . . . . . . . | | 106 * . . . . . . . . . . . . . . . . | | 107 * . . . . . . . . . . . . . . . . V | 108 * U V U V U V U V U V U V . . . . ^ | 109 * U V U V U V U V U V U V . . . . | | 110 * U V U V U V U V U V U V . . . . | | 111 * U V U V U V U V U V U V . . . . UV_Scanlines | 112 * . . . . . . . . . . . . . . . . | | 113 * . . . . . . . . . . . . . . . . V V 114 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . ^ ^ ^ 115 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | | | 116 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . Height | | 117 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | Y_Scanlines | 118 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | | | 119 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | | | 120 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | | | 121 * Y Y Y Y Y Y Y Y Y Y Y Y . . . . V | | 122 * . . . . . . . . . . . . . . . . | View_2 123 * . . . . . . . . . . . . . . . . | | 124 * . . . . . . . . . . . . . . . . | | 125 * . . . . . . . . . . . . . . . . V | 126 * U V U V U V U V U V U V . . . . ^ | 127 * U V U V U V U V U V U V . . . . | | 128 * U V U V U V U V U V U V . . . . | | 129 * U V U V U V U V U V U V . . . . UV_Scanlines | 130 * . . . . . . . . . . . . . . . . | | 131 * . . . . . . . . . . . . . . . . V V 132 * . . . . . . . . . . . . . . . . --> Buffer size alignment 133 * 134 * Y_Stride : Width aligned to 128 135 * UV_Stride : Width aligned to 128 136 * Y_Scanlines: Height aligned to 32 137 * UV_Scanlines: Height/2 aligned to 16 138 * View_1 begin at: 0 (zero) 139 * View_2 begin at: Y_Stride * Y_Scanlines + UV_Stride * UV_Scanlines 140 * Extradata: Arbitrary (software-imposed) padding 141 * Total size = align((2*(Y_Stride * Y_Scanlines) 142 * + 2*(UV_Stride * UV_Scanlines) + Extradata), 4096) 143 */ 144 COLOR_FMT_NV12_MVTB, 145 /* Venus NV12 UBWC: 146 * Compressed Macro-tile format for NV12. 147 * Contains 4 planes in the following order - 148 * (A) Y_Meta_Plane 149 * (B) Y_UBWC_Plane 150 * (C) UV_Meta_Plane 151 * (D) UV_UBWC_Plane 152 * 153 * Y_Meta_Plane consists of meta information to decode compressed 154 * tile data in Y_UBWC_Plane. 155 * Y_UBWC_Plane consists of Y data in compressed macro-tile format. 156 * UBWC decoder block will use the Y_Meta_Plane data together with 157 * Y_UBWC_Plane data to produce loss-less uncompressed 8 bit Y samples. 158 * 159 * UV_Meta_Plane consists of meta information to decode compressed 160 * tile data in UV_UBWC_Plane. 161 * UV_UBWC_Plane consists of UV data in compressed macro-tile format. 162 * UBWC decoder block will use UV_Meta_Plane data together with 163 * UV_UBWC_Plane data to produce loss-less uncompressed 8 bit 2x2 164 * subsampled color difference samples. 165 * 166 * Each tile in Y_UBWC_Plane/UV_UBWC_Plane is independently decodable 167 * and randomly accessible. There is no dependency between tiles. 168 * 169 * <----- Y_Meta_Stride ----> 170 * <-------- Width ------> 171 * M M M M M M M M M M M M . . ^ ^ 172 * M M M M M M M M M M M M . . | | 173 * M M M M M M M M M M M M . . Height | 174 * M M M M M M M M M M M M . . | Meta_Y_Scanlines 175 * M M M M M M M M M M M M . . | | 176 * M M M M M M M M M M M M . . | | 177 * M M M M M M M M M M M M . . | | 178 * M M M M M M M M M M M M . . V | 179 * . . . . . . . . . . . . . . | 180 * . . . . . . . . . . . . . . | 181 * . . . . . . . . . . . . . . -------> Buffer size aligned to 4k 182 * . . . . . . . . . . . . . . V 183 * <--Compressed tile Y Stride---> 184 * <------- Width -------> 185 * Y* Y* Y* Y* Y* Y* Y* Y* . . . . ^ ^ 186 * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | | 187 * Y* Y* Y* Y* Y* Y* Y* Y* . . . . Height | 188 * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | Macro_tile_Y_Scanlines 189 * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | | 190 * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | | 191 * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | | 192 * Y* Y* Y* Y* Y* Y* Y* Y* . . . . V | 193 * . . . . . . . . . . . . . . . . | 194 * . . . . . . . . . . . . . . . . | 195 * . . . . . . . . . . . . . . . . -------> Buffer size aligned to 4k 196 * . . . . . . . . . . . . . . . . V 197 * <----- UV_Meta_Stride ----> 198 * M M M M M M M M M M M M . . ^ 199 * M M M M M M M M M M M M . . | 200 * M M M M M M M M M M M M . . | 201 * M M M M M M M M M M M M . . M_UV_Scanlines 202 * . . . . . . . . . . . . . . | 203 * . . . . . . . . . . . . . . V 204 * . . . . . . . . . . . . . . -------> Buffer size aligned to 4k 205 * <--Compressed tile UV Stride---> 206 * U* V* U* V* U* V* U* V* . . . . ^ 207 * U* V* U* V* U* V* U* V* . . . . | 208 * U* V* U* V* U* V* U* V* . . . . | 209 * U* V* U* V* U* V* U* V* . . . . UV_Scanlines 210 * . . . . . . . . . . . . . . . . | 211 * . . . . . . . . . . . . . . . . V 212 * . . . . . . . . . . . . . . . . -------> Buffer size aligned to 4k 213 * 214 * Y_Stride = align(Width, 128) 215 * UV_Stride = align(Width, 128) 216 * Y_Scanlines = align(Height, 32) 217 * UV_Scanlines = align(Height/2, 16) 218 * Y_UBWC_Plane_size = align(Y_Stride * Y_Scanlines, 4096) 219 * UV_UBWC_Plane_size = align(UV_Stride * UV_Scanlines, 4096) 220 * Y_Meta_Stride = align(roundup(Width, Y_TileWidth), 64) 221 * Y_Meta_Scanlines = align(roundup(Height, Y_TileHeight), 16) 222 * Y_Meta_Plane_size = align(Y_Meta_Stride * Y_Meta_Scanlines, 4096) 223 * UV_Meta_Stride = align(roundup(Width, UV_TileWidth), 64) 224 * UV_Meta_Scanlines = align(roundup(Height, UV_TileHeight), 16) 225 * UV_Meta_Plane_size = align(UV_Meta_Stride * UV_Meta_Scanlines, 4096) 226 * Extradata = 8k 227 * 228 * Total size = align( Y_UBWC_Plane_size + UV_UBWC_Plane_size + 229 * Y_Meta_Plane_size + UV_Meta_Plane_size + Extradata, 4096) 230 */ 231 COLOR_FMT_NV12_UBWC, 232 /* Venus NV12 10-bit UBWC: 233 * Compressed Macro-tile format for NV12. 234 * Contains 4 planes in the following order - 235 * (A) Y_Meta_Plane 236 * (B) Y_UBWC_Plane 237 * (C) UV_Meta_Plane 238 * (D) UV_UBWC_Plane 239 * 240 * Y_Meta_Plane consists of meta information to decode compressed 241 * tile data in Y_UBWC_Plane. 242 * Y_UBWC_Plane consists of Y data in compressed macro-tile format. 243 * UBWC decoder block will use the Y_Meta_Plane data together with 244 * Y_UBWC_Plane data to produce loss-less uncompressed 10 bit Y samples. 245 * 246 * UV_Meta_Plane consists of meta information to decode compressed 247 * tile data in UV_UBWC_Plane. 248 * UV_UBWC_Plane consists of UV data in compressed macro-tile format. 249 * UBWC decoder block will use UV_Meta_Plane data together with 250 * UV_UBWC_Plane data to produce loss-less uncompressed 10 bit 2x2 251 * subsampled color difference samples. 252 * 253 * Each tile in Y_UBWC_Plane/UV_UBWC_Plane is independently decodable 254 * and randomly accessible. There is no dependency between tiles. 255 * 256 * <----- Y_Meta_Stride -----> 257 * <-------- Width ------> 258 * M M M M M M M M M M M M . . ^ ^ 259 * M M M M M M M M M M M M . . | | 260 * M M M M M M M M M M M M . . Height | 261 * M M M M M M M M M M M M . . | Meta_Y_Scanlines 262 * M M M M M M M M M M M M . . | | 263 * M M M M M M M M M M M M . . | | 264 * M M M M M M M M M M M M . . | | 265 * M M M M M M M M M M M M . . V | 266 * . . . . . . . . . . . . . . | 267 * . . . . . . . . . . . . . . | 268 * . . . . . . . . . . . . . . -------> Buffer size aligned to 4k 269 * . . . . . . . . . . . . . . V 270 * <--Compressed tile Y Stride---> 271 * <------- Width -------> 272 * Y* Y* Y* Y* Y* Y* Y* Y* . . . . ^ ^ 273 * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | | 274 * Y* Y* Y* Y* Y* Y* Y* Y* . . . . Height | 275 * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | Macro_tile_Y_Scanlines 276 * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | | 277 * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | | 278 * Y* Y* Y* Y* Y* Y* Y* Y* . . . . | | 279 * Y* Y* Y* Y* Y* Y* Y* Y* . . . . V | 280 * . . . . . . . . . . . . . . . . | 281 * . . . . . . . . . . . . . . . . | 282 * . . . . . . . . . . . . . . . . -------> Buffer size aligned to 4k 283 * . . . . . . . . . . . . . . . . V 284 * <----- UV_Meta_Stride ----> 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 . . M_UV_Scanlines 289 * . . . . . . . . . . . . . . | 290 * . . . . . . . . . . . . . . V 291 * . . . . . . . . . . . . . . -------> Buffer size aligned to 4k 292 * <--Compressed tile UV Stride---> 293 * U* V* U* V* U* V* U* V* . . . . ^ 294 * U* V* U* V* U* V* U* V* . . . . | 295 * U* V* U* V* U* V* U* V* . . . . | 296 * U* V* U* V* U* V* U* V* . . . . UV_Scanlines 297 * . . . . . . . . . . . . . . . . | 298 * . . . . . . . . . . . . . . . . V 299 * . . . . . . . . . . . . . . . . -------> Buffer size aligned to 4k 300 * 301 * 302 * Y_Stride = align(Width * 4/3, 128) 303 * UV_Stride = align(Width * 4/3, 128) 304 * Y_Scanlines = align(Height, 32) 305 * UV_Scanlines = align(Height/2, 16) 306 * Y_UBWC_Plane_Size = align(Y_Stride * Y_Scanlines, 4096) 307 * UV_UBWC_Plane_Size = align(UV_Stride * UV_Scanlines, 4096) 308 * Y_Meta_Stride = align(roundup(Width, Y_TileWidth), 64) 309 * Y_Meta_Scanlines = align(roundup(Height, Y_TileHeight), 16) 310 * Y_Meta_Plane_size = align(Y_Meta_Stride * Y_Meta_Scanlines, 4096) 311 * UV_Meta_Stride = align(roundup(Width, UV_TileWidth), 64) 312 * UV_Meta_Scanlines = align(roundup(Height, UV_TileHeight), 16) 313 * UV_Meta_Plane_size = align(UV_Meta_Stride * UV_Meta_Scanlines, 4096) 314 * Extradata = 8k 315 */ 316 COLOR_FMT_NV12_BPP10_UBWC, 317 }; 318 319 static inline unsigned int VENUS_EXTRADATA_SIZE(int width, int height) 320 { 321 (void)height; 322 (void)width; 323 324 /* 325 * In the future, calculate the size based on the w/h but just 326 * hardcode it for now since 8K satisfies all current usecases. 327 */ 328 return 8 * 1024; 329 } 330 331 static inline unsigned int VENUS_Y_STRIDE(int color_fmt, int width) 332 { 333 unsigned int alignment, stride = 0; 334 if (!width) 335 goto invalid_input; 336 337 switch (color_fmt) { 338 case COLOR_FMT_NV21: 339 case COLOR_FMT_NV12: 340 case COLOR_FMT_NV12_MVTB: 341 case COLOR_FMT_NV12_UBWC: 342 alignment = 128; 343 stride = MSM_MEDIA_ALIGN(width, alignment); 344 break; 345 case COLOR_FMT_NV12_BPP10_UBWC: 346 alignment = 128; 347 stride = MSM_MEDIA_ALIGN(width * 4/3, alignment); 348 break; 349 default: 350 break; 351 } 352 invalid_input: 353 return stride; 354 } 355 356 static inline unsigned int VENUS_UV_STRIDE(int color_fmt, int width) 357 { 358 unsigned int alignment, stride = 0; 359 if (!width) 360 goto invalid_input; 361 362 switch (color_fmt) { 363 case COLOR_FMT_NV21: 364 case COLOR_FMT_NV12: 365 case COLOR_FMT_NV12_MVTB: 366 case COLOR_FMT_NV12_UBWC: 367 alignment = 128; 368 stride = MSM_MEDIA_ALIGN(width, alignment); 369 break; 370 case COLOR_FMT_NV12_BPP10_UBWC: 371 alignment = 128; 372 stride = MSM_MEDIA_ALIGN(width * 4/3, alignment); 373 break; 374 default: 375 break; 376 } 377 invalid_input: 378 return stride; 379 } 380 381 static inline unsigned int VENUS_Y_SCANLINES(int color_fmt, int height) 382 { 383 unsigned int alignment, sclines = 0; 384 if (!height) 385 goto invalid_input; 386 387 switch (color_fmt) { 388 case COLOR_FMT_NV21: 389 case COLOR_FMT_NV12: 390 case COLOR_FMT_NV12_MVTB: 391 case COLOR_FMT_NV12_UBWC: 392 case COLOR_FMT_NV12_BPP10_UBWC: 393 alignment = 32; 394 sclines = MSM_MEDIA_ALIGN(height, alignment); 395 break; 396 default: 397 break; 398 } 399 invalid_input: 400 return sclines; 401 } 402 403 static inline unsigned int VENUS_UV_SCANLINES(int color_fmt, int height) 404 { 405 unsigned int alignment, sclines = 0; 406 if (!height) 407 goto invalid_input; 408 409 switch (color_fmt) { 410 case COLOR_FMT_NV21: 411 case COLOR_FMT_NV12: 412 case COLOR_FMT_NV12_MVTB: 413 case COLOR_FMT_NV12_UBWC: 414 case COLOR_FMT_NV12_BPP10_UBWC: 415 alignment = 16; 416 sclines = MSM_MEDIA_ALIGN(((height + 1) >> 1), alignment); 417 break; 418 default: 419 break; 420 } 421 invalid_input: 422 return sclines; 423 } 424 425 static inline unsigned int VENUS_Y_META_STRIDE(int color_fmt, int width) 426 { 427 int y_tile_width = 0, y_meta_stride = 0; 428 429 if (!width) 430 goto invalid_input; 431 432 switch (color_fmt) { 433 case COLOR_FMT_NV12_UBWC: 434 y_tile_width = 32; 435 break; 436 case COLOR_FMT_NV12_BPP10_UBWC: 437 y_tile_width = 48; 438 break; 439 default: 440 goto invalid_input; 441 } 442 443 y_meta_stride = MSM_MEDIA_ROUNDUP(width, y_tile_width); 444 y_meta_stride = MSM_MEDIA_ALIGN(y_meta_stride, 64); 445 446 invalid_input: 447 return y_meta_stride; 448 } 449 450 static inline unsigned int VENUS_Y_META_SCANLINES(int color_fmt, int height) 451 { 452 int y_tile_height = 0, y_meta_scanlines = 0; 453 454 if (!height) 455 goto invalid_input; 456 457 switch (color_fmt) { 458 case COLOR_FMT_NV12_UBWC: 459 y_tile_height = 8; 460 break; 461 case COLOR_FMT_NV12_BPP10_UBWC: 462 y_tile_height = 4; 463 break; 464 default: 465 goto invalid_input; 466 } 467 468 y_meta_scanlines = MSM_MEDIA_ROUNDUP(height, y_tile_height); 469 y_meta_scanlines = MSM_MEDIA_ALIGN(y_meta_scanlines, 16); 470 471 invalid_input: 472 return y_meta_scanlines; 473 } 474 475 static inline unsigned int VENUS_UV_META_STRIDE(int color_fmt, int width) 476 { 477 int uv_tile_width = 0, uv_meta_stride = 0; 478 479 if (!width) 480 goto invalid_input; 481 482 switch (color_fmt) { 483 case COLOR_FMT_NV12_UBWC: 484 uv_tile_width = 16; 485 break; 486 case COLOR_FMT_NV12_BPP10_UBWC: 487 uv_tile_width = 24; 488 break; 489 default: 490 goto invalid_input; 491 } 492 493 uv_meta_stride = MSM_MEDIA_ROUNDUP(width, uv_tile_width); 494 uv_meta_stride = MSM_MEDIA_ALIGN(uv_meta_stride, 64); 495 496 invalid_input: 497 return uv_meta_stride; 498 } 499 500 static inline unsigned int VENUS_UV_META_SCANLINES(int color_fmt, int height) 501 { 502 int uv_tile_height = 0, uv_meta_scanlines = 0; 503 504 if (!height) 505 goto invalid_input; 506 507 switch (color_fmt) { 508 case COLOR_FMT_NV12_UBWC: 509 uv_tile_height = 8; 510 break; 511 case COLOR_FMT_NV12_BPP10_UBWC: 512 uv_tile_height = 4; 513 break; 514 default: 515 goto invalid_input; 516 } 517 518 uv_meta_scanlines = MSM_MEDIA_ROUNDUP(height, uv_tile_height); 519 uv_meta_scanlines = MSM_MEDIA_ALIGN(uv_meta_scanlines, 16); 520 521 invalid_input: 522 return uv_meta_scanlines; 523 } 524 525 static inline unsigned int VENUS_BUFFER_SIZE( 526 int color_fmt, int width, int height) 527 { 528 const unsigned int extra_size = VENUS_EXTRADATA_SIZE(width, height); 529 unsigned int uv_alignment = 0, size = 0; 530 unsigned int y_plane, uv_plane, y_stride, 531 uv_stride, y_sclines, uv_sclines; 532 unsigned int y_ubwc_plane = 0, uv_ubwc_plane = 0; 533 unsigned int y_meta_stride = 0, y_meta_scanlines = 0; 534 unsigned int uv_meta_stride = 0, uv_meta_scanlines = 0; 535 unsigned int y_meta_plane = 0, uv_meta_plane = 0; 536 537 if (!width || !height) 538 goto invalid_input; 539 540 y_stride = VENUS_Y_STRIDE(color_fmt, width); 541 uv_stride = VENUS_UV_STRIDE(color_fmt, width); 542 y_sclines = VENUS_Y_SCANLINES(color_fmt, height); 543 uv_sclines = VENUS_UV_SCANLINES(color_fmt, height); 544 switch (color_fmt) { 545 case COLOR_FMT_NV21: 546 case COLOR_FMT_NV12: 547 uv_alignment = 4096; 548 y_plane = y_stride * y_sclines; 549 uv_plane = uv_stride * uv_sclines + uv_alignment; 550 size = y_plane + uv_plane + extra_size; 551 size = MSM_MEDIA_ALIGN(size, 4096); 552 break; 553 case COLOR_FMT_NV12_MVTB: 554 uv_alignment = 4096; 555 y_plane = y_stride * y_sclines; 556 uv_plane = uv_stride * uv_sclines + uv_alignment; 557 size = y_plane + uv_plane; 558 size = 2 * size + extra_size; 559 size = MSM_MEDIA_ALIGN(size, 4096); 560 break; 561 case COLOR_FMT_NV12_UBWC: 562 case COLOR_FMT_NV12_BPP10_UBWC: 563 y_ubwc_plane = MSM_MEDIA_ALIGN(y_stride * y_sclines, 4096); 564 uv_ubwc_plane = MSM_MEDIA_ALIGN(uv_stride * uv_sclines, 4096); 565 y_meta_stride = VENUS_Y_META_STRIDE(color_fmt, width); 566 y_meta_scanlines = VENUS_Y_META_SCANLINES(color_fmt, height); 567 y_meta_plane = MSM_MEDIA_ALIGN( 568 y_meta_stride * y_meta_scanlines, 4096); 569 uv_meta_stride = VENUS_UV_META_STRIDE(color_fmt, width); 570 uv_meta_scanlines = VENUS_UV_META_SCANLINES(color_fmt, height); 571 uv_meta_plane = MSM_MEDIA_ALIGN(uv_meta_stride * 572 uv_meta_scanlines, 4096); 573 574 size = y_ubwc_plane + uv_ubwc_plane + y_meta_plane + 575 uv_meta_plane + extra_size; 576 size = MSM_MEDIA_ALIGN(size, 4096); 577 break; 578 default: 579 break; 580 } 581 invalid_input: 582 return size; 583 } 584 585 static inline unsigned int VENUS_VIEW2_OFFSET( 586 int color_fmt, int width, int height) 587 { 588 unsigned int offset = 0; 589 unsigned int y_plane, uv_plane, y_stride, 590 uv_stride, y_sclines, uv_sclines; 591 if (!width || !height) 592 goto invalid_input; 593 594 y_stride = VENUS_Y_STRIDE(color_fmt, width); 595 uv_stride = VENUS_UV_STRIDE(color_fmt, width); 596 y_sclines = VENUS_Y_SCANLINES(color_fmt, height); 597 uv_sclines = VENUS_UV_SCANLINES(color_fmt, height); 598 switch (color_fmt) { 599 case COLOR_FMT_NV12_MVTB: 600 y_plane = y_stride * y_sclines; 601 uv_plane = uv_stride * uv_sclines; 602 offset = y_plane + uv_plane; 603 break; 604 default: 605 break; 606 } 607 invalid_input: 608 return offset; 609 } 610 611 #endif 612