Home | History | Annotate | Download | only in media
      1 #ifndef __MEDIA_INFO_H__
      2 #define __MEDIA_INFO_H__
      3 
      4 #ifndef MSM_MEDIA_ALIGN
      5 #define MSM_MEDIA_ALIGN(__sz, __align) (((__align) & ((__align) - 1)) ?\
      6 	((((__sz) + (__align) - 1) / (__align)) * (__align)) :\
      7 	(((__sz) + (__align) - 1) & (~((__align) - 1))))
      8 #endif
      9 
     10 #ifndef MSM_MEDIA_ROUNDUP
     11 #define MSM_MEDIA_ROUNDUP(__sz, __r) (((__sz) + ((__r) - 1)) / (__r))
     12 #endif
     13 
     14 #ifndef MSM_MEDIA_MAX
     15 #define MSM_MEDIA_MAX(__a, __b) ((__a) > (__b)?(__a):(__b))
     16 #endif
     17 
     18 enum color_fmts {
     19 	/* Venus NV12:
     20 	 * YUV 4:2:0 image with a plane of 8 bit Y samples followed
     21 	 * by an interleaved U/V plane containing 8 bit 2x2 subsampled
     22 	 * colour difference samples.
     23 	 *
     24 	 * <-------- Y/UV_Stride -------->
     25 	 * <------- Width ------->
     26 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  ^           ^
     27 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  |           |
     28 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  Height      |
     29 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  |          Y_Scanlines
     30 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  |           |
     31 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  |           |
     32 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  |           |
     33 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  V           |
     34 	 * . . . . . . . . . . . . . . . .              |
     35 	 * . . . . . . . . . . . . . . . .              |
     36 	 * . . . . . . . . . . . . . . . .              |
     37 	 * . . . . . . . . . . . . . . . .              V
     38 	 * U V U V U V U V U V U V . . . .  ^
     39 	 * U V U V U V U V U V U V . . . .  |
     40 	 * U V U V U V U V U V U V . . . .  |
     41 	 * U V U V U V U V U V U V . . . .  UV_Scanlines
     42 	 * . . . . . . . . . . . . . . . .  |
     43 	 * . . . . . . . . . . . . . . . .  V
     44 	 * . . . . . . . . . . . . . . . .  --> Buffer size alignment
     45 	 *
     46 	 * Y_Stride : Width aligned to 128
     47 	 * UV_Stride : Width aligned to 128
     48 	 * Y_Scanlines: Height aligned to 32
     49 	 * UV_Scanlines: Height/2 aligned to 16
     50 	 * Extradata: Arbitrary (software-imposed) padding
     51 	 * Total size = align((Y_Stride * Y_Scanlines
     52 	 *          + UV_Stride * UV_Scanlines
     53 	 *          + max(Extradata, Y_Stride * 8), 4096)
     54 	 */
     55 	COLOR_FMT_NV12,
     56 
     57 	/* Venus NV21:
     58 	 * YUV 4:2:0 image with a plane of 8 bit Y samples followed
     59 	 * by an interleaved V/U plane containing 8 bit 2x2 subsampled
     60 	 * colour difference samples.
     61 	 *
     62 	 * <-------- Y/UV_Stride -------->
     63 	 * <------- Width ------->
     64 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  ^           ^
     65 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  |           |
     66 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  Height      |
     67 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  |          Y_Scanlines
     68 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  |           |
     69 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  |           |
     70 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  |           |
     71 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  V           |
     72 	 * . . . . . . . . . . . . . . . .              |
     73 	 * . . . . . . . . . . . . . . . .              |
     74 	 * . . . . . . . . . . . . . . . .              |
     75 	 * . . . . . . . . . . . . . . . .              V
     76 	 * V U V U V U V U V U V U . . . .  ^
     77 	 * V U V U V U V U V U V U . . . .  |
     78 	 * V U V U V U V U V U V U . . . .  |
     79 	 * V U V U V U V U V U V U . . . .  UV_Scanlines
     80 	 * . . . . . . . . . . . . . . . .  |
     81 	 * . . . . . . . . . . . . . . . .  V
     82 	 * . . . . . . . . . . . . . . . .  --> Padding & Buffer size alignment
     83 	 *
     84 	 * Y_Stride : Width aligned to 128
     85 	 * UV_Stride : Width aligned to 128
     86 	 * Y_Scanlines: Height aligned to 32
     87 	 * UV_Scanlines: Height/2 aligned to 16
     88 	 * Extradata: Arbitrary (software-imposed) padding
     89 	 * Total size = align((Y_Stride * Y_Scanlines
     90 	 *          + UV_Stride * UV_Scanlines
     91 	 *          + max(Extradata, Y_Stride * 8), 4096)
     92 	 */
     93 	COLOR_FMT_NV21,
     94 	/* Venus NV12_MVTB:
     95 	 * Two YUV 4:2:0 images/views one after the other
     96 	 * in a top-bottom layout, same as NV12
     97 	 * with a plane of 8 bit Y samples followed
     98 	 * by an interleaved U/V plane containing 8 bit 2x2 subsampled
     99 	 * colour difference samples.
    100 	 *
    101 	 *
    102 	 * <-------- Y/UV_Stride -------->
    103 	 * <------- Width ------->
    104 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  ^           ^               ^
    105 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  |           |               |
    106 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  Height      |               |
    107 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  |          Y_Scanlines      |
    108 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  |           |               |
    109 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  |           |               |
    110 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  |           |               |
    111 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  V           |               |
    112 	 * . . . . . . . . . . . . . . . .              |             View_1
    113 	 * . . . . . . . . . . . . . . . .              |               |
    114 	 * . . . . . . . . . . . . . . . .              |               |
    115 	 * . . . . . . . . . . . . . . . .              V               |
    116 	 * U V U V U V U V U V U V . . . .  ^                           |
    117 	 * U V U V U V U V U V U V . . . .  |                           |
    118 	 * U V U V U V U V U V U V . . . .  |                           |
    119 	 * U V U V U V U V U V U V . . . .  UV_Scanlines                |
    120 	 * . . . . . . . . . . . . . . . .  |                           |
    121 	 * . . . . . . . . . . . . . . . .  V                           V
    122 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  ^           ^               ^
    123 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  |           |               |
    124 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  Height      |               |
    125 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  |          Y_Scanlines      |
    126 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  |           |               |
    127 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  |           |               |
    128 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  |           |               |
    129 	 * Y Y Y Y Y Y Y Y Y Y Y Y . . . .  V           |               |
    130 	 * . . . . . . . . . . . . . . . .              |             View_2
    131 	 * . . . . . . . . . . . . . . . .              |               |
    132 	 * . . . . . . . . . . . . . . . .              |               |
    133 	 * . . . . . . . . . . . . . . . .              V               |
    134 	 * U V U V U V U V U V U V . . . .  ^                           |
    135 	 * U V U V U V U V U V U V . . . .  |                           |
    136 	 * U V U V U V U V U V U V . . . .  |                           |
    137 	 * U V U V U V U V U V U V . . . .  UV_Scanlines                |
    138 	 * . . . . . . . . . . . . . . . .  |                           |
    139 	 * . . . . . . . . . . . . . . . .  V                           V
    140 	 * . . . . . . . . . . . . . . . .  --> Buffer size alignment
    141 	 *
    142 	 * Y_Stride : Width aligned to 128
    143 	 * UV_Stride : Width aligned to 128
    144 	 * Y_Scanlines: Height aligned to 32
    145 	 * UV_Scanlines: Height/2 aligned to 16
    146 	 * View_1 begin at: 0 (zero)
    147 	 * View_2 begin at: Y_Stride * Y_Scanlines + UV_Stride * UV_Scanlines
    148 	 * Extradata: Arbitrary (software-imposed) padding
    149 	 * Total size = align((2*(Y_Stride * Y_Scanlines)
    150 	 *          + 2*(UV_Stride * UV_Scanlines) + Extradata), 4096)
    151 	 */
    152 	COLOR_FMT_NV12_MVTB,
    153 	/* Venus NV12 UBWC:
    154 	 * Compressed Macro-tile format for NV12.
    155 	 * Contains 4 planes in the following order -
    156 	 * (A) Y_Meta_Plane
    157 	 * (B) Y_UBWC_Plane
    158 	 * (C) UV_Meta_Plane
    159 	 * (D) UV_UBWC_Plane
    160 	 *
    161 	 * Y_Meta_Plane consists of meta information to decode compressed
    162 	 * tile data in Y_UBWC_Plane.
    163 	 * Y_UBWC_Plane consists of Y data in compressed macro-tile format.
    164 	 * UBWC decoder block will use the Y_Meta_Plane data together with
    165 	 * Y_UBWC_Plane data to produce loss-less uncompressed 8 bit Y samples.
    166 	 *
    167 	 * UV_Meta_Plane consists of meta information to decode compressed
    168 	 * tile data in UV_UBWC_Plane.
    169 	 * UV_UBWC_Plane consists of UV data in compressed macro-tile format.
    170 	 * UBWC decoder block will use UV_Meta_Plane data together with
    171 	 * UV_UBWC_Plane data to produce loss-less uncompressed 8 bit 2x2
    172 	 * subsampled color difference samples.
    173 	 *
    174 	 * Each tile in Y_UBWC_Plane/UV_UBWC_Plane is independently decodable
    175 	 * and randomly accessible. There is no dependency between tiles.
    176 	 *
    177 	 * <----- Y_Meta_Stride ---->
    178 	 * <-------- Width ------>
    179 	 * M M M M M M M M M M M M . .      ^           ^
    180 	 * M M M M M M M M M M M M . .      |           |
    181 	 * M M M M M M M M M M M M . .      Height      |
    182 	 * M M M M M M M M M M M M . .      |         Meta_Y_Scanlines
    183 	 * M M M M M M M M M M M M . .      |           |
    184 	 * M M M M M M M M M M M M . .      |           |
    185 	 * M M M M M M M M M M M M . .      |           |
    186 	 * M M M M M M M M M M M M . .      V           |
    187 	 * . . . . . . . . . . . . . .                  |
    188 	 * . . . . . . . . . . . . . .                  |
    189 	 * . . . . . . . . . . . . . .      -------> Buffer size aligned to 4k
    190 	 * . . . . . . . . . . . . . .                  V
    191 	 * <--Compressed tile Y Stride--->
    192 	 * <------- Width ------->
    193 	 * Y* Y* Y* Y* Y* Y* Y* Y* . . . .  ^           ^
    194 	 * Y* Y* Y* Y* Y* Y* Y* Y* . . . .  |           |
    195 	 * Y* Y* Y* Y* Y* Y* Y* Y* . . . .  Height      |
    196 	 * Y* Y* Y* Y* Y* Y* Y* Y* . . . .  |        Macro_tile_Y_Scanlines
    197 	 * Y* Y* Y* Y* Y* Y* Y* Y* . . . .  |           |
    198 	 * Y* Y* Y* Y* Y* Y* Y* Y* . . . .  |           |
    199 	 * Y* Y* Y* Y* Y* Y* Y* Y* . . . .  |           |
    200 	 * Y* Y* Y* Y* Y* Y* Y* Y* . . . .  V           |
    201 	 * . . . . . . . . . . . . . . . .              |
    202 	 * . . . . . . . . . . . . . . . .              |
    203 	 * . . . . . . . . . . . . . . . .  -------> Buffer size aligned to 4k
    204 	 * . . . . . . . . . . . . . . . .              V
    205 	 * <----- UV_Meta_Stride ---->
    206 	 * M M M M M M M M M M M M . .      ^
    207 	 * M M M M M M M M M M M M . .      |
    208 	 * M M M M M M M M M M M M . .      |
    209 	 * M M M M M M M M M M M M . .      M_UV_Scanlines
    210 	 * . . . . . . . . . . . . . .      |
    211 	 * . . . . . . . . . . . . . .      V
    212 	 * . . . . . . . . . . . . . .      -------> Buffer size aligned to 4k
    213 	 * <--Compressed tile UV Stride--->
    214 	 * U* V* U* V* U* V* U* V* . . . .  ^
    215 	 * U* V* U* V* U* V* U* V* . . . .  |
    216 	 * U* V* U* V* U* V* U* V* . . . .  |
    217 	 * U* V* U* V* U* V* U* V* . . . .  UV_Scanlines
    218 	 * . . . . . . . . . . . . . . . .  |
    219 	 * . . . . . . . . . . . . . . . .  V
    220 	 * . . . . . . . . . . . . . . . .  -------> Buffer size aligned to 4k
    221 	 *
    222 	 * Y_Stride = align(Width, 128)
    223 	 * UV_Stride = align(Width, 128)
    224 	 * Y_Scanlines = align(Height, 32)
    225 	 * UV_Scanlines = align(Height/2, 16)
    226 	 * Y_UBWC_Plane_size = align(Y_Stride * Y_Scanlines, 4096)
    227 	 * UV_UBWC_Plane_size = align(UV_Stride * UV_Scanlines, 4096)
    228 	 * Y_Meta_Stride = align(roundup(Width, Y_TileWidth), 64)
    229 	 * Y_Meta_Scanlines = align(roundup(Height, Y_TileHeight), 16)
    230 	 * Y_Meta_Plane_size = align(Y_Meta_Stride * Y_Meta_Scanlines, 4096)
    231 	 * UV_Meta_Stride = align(roundup(Width, UV_TileWidth), 64)
    232 	 * UV_Meta_Scanlines = align(roundup(Height, UV_TileHeight), 16)
    233 	 * UV_Meta_Plane_size = align(UV_Meta_Stride * UV_Meta_Scanlines, 4096)
    234 	 * Extradata = 16k
    235 	 *
    236 	 * Total size = align( Y_UBWC_Plane_size + UV_UBWC_Plane_size +
    237 	 *           Y_Meta_Plane_size + UV_Meta_Plane_size
    238 	 *           + max(Extradata, Y_Stride * 64), 4096)
    239 	 */
    240 	COLOR_FMT_NV12_UBWC,
    241 	/* Venus NV12 10-bit UBWC:
    242 	 * Compressed Macro-tile format for NV12.
    243 	 * Contains 4 planes in the following order -
    244 	 * (A) Y_Meta_Plane
    245 	 * (B) Y_UBWC_Plane
    246 	 * (C) UV_Meta_Plane
    247 	 * (D) UV_UBWC_Plane
    248 	 *
    249 	 * Y_Meta_Plane consists of meta information to decode compressed
    250 	 * tile data in Y_UBWC_Plane.
    251 	 * Y_UBWC_Plane consists of Y data in compressed macro-tile format.
    252 	 * UBWC decoder block will use the Y_Meta_Plane data together with
    253 	 * Y_UBWC_Plane data to produce loss-less uncompressed 10 bit Y samples.
    254 	 *
    255 	 * UV_Meta_Plane consists of meta information to decode compressed
    256 	 * tile data in UV_UBWC_Plane.
    257 	 * UV_UBWC_Plane consists of UV data in compressed macro-tile format.
    258 	 * UBWC decoder block will use UV_Meta_Plane data together with
    259 	 * UV_UBWC_Plane data to produce loss-less uncompressed 10 bit 2x2
    260 	 * subsampled color difference samples.
    261 	 *
    262 	 * Each tile in Y_UBWC_Plane/UV_UBWC_Plane is independently decodable
    263 	 * and randomly accessible. There is no dependency between tiles.
    264 	 *
    265 	 * <----- Y_Meta_Stride ----->
    266 	 * <-------- Width ------>
    267 	 * M M M M M M M M M M M M . .      ^           ^
    268 	 * M M M M M M M M M M M M . .      |           |
    269 	 * M M M M M M M M M M M M . .      Height      |
    270 	 * M M M M M M M M M M M M . .      |         Meta_Y_Scanlines
    271 	 * M M M M M M M M M M M M . .      |           |
    272 	 * M M M M M M M M M M M M . .      |           |
    273 	 * M M M M M M M M M M M M . .      |           |
    274 	 * M M M M M M M M M M M M . .      V           |
    275 	 * . . . . . . . . . . . . . .                  |
    276 	 * . . . . . . . . . . . . . .                  |
    277 	 * . . . . . . . . . . . . . .      -------> Buffer size aligned to 4k
    278 	 * . . . . . . . . . . . . . .                  V
    279 	 * <--Compressed tile Y Stride--->
    280 	 * <------- Width ------->
    281 	 * Y* Y* Y* Y* Y* Y* Y* Y* . . . .  ^           ^
    282 	 * Y* Y* Y* Y* Y* Y* Y* Y* . . . .  |           |
    283 	 * Y* Y* Y* Y* Y* Y* Y* Y* . . . .  Height      |
    284 	 * Y* Y* Y* Y* Y* Y* Y* Y* . . . .  |        Macro_tile_Y_Scanlines
    285 	 * Y* Y* Y* Y* Y* Y* Y* Y* . . . .  |           |
    286 	 * Y* Y* Y* Y* Y* Y* Y* Y* . . . .  |           |
    287 	 * Y* Y* Y* Y* Y* Y* Y* Y* . . . .  |           |
    288 	 * Y* Y* Y* Y* Y* Y* Y* Y* . . . .  V           |
    289 	 * . . . . . . . . . . . . . . . .              |
    290 	 * . . . . . . . . . . . . . . . .              |
    291 	 * . . . . . . . . . . . . . . . .  -------> Buffer size aligned to 4k
    292 	 * . . . . . . . . . . . . . . . .              V
    293 	 * <----- UV_Meta_Stride ---->
    294 	 * M M M M M M M M M M M M . .      ^
    295 	 * M M M M M M M M M M M M . .      |
    296 	 * M M M M M M M M M M M M . .      |
    297 	 * M M M M M M M M M M M M . .      M_UV_Scanlines
    298 	 * . . . . . . . . . . . . . .      |
    299 	 * . . . . . . . . . . . . . .      V
    300 	 * . . . . . . . . . . . . . .      -------> Buffer size aligned to 4k
    301 	 * <--Compressed tile UV Stride--->
    302 	 * U* V* U* V* U* V* U* V* . . . .  ^
    303 	 * U* V* U* V* U* V* U* V* . . . .  |
    304 	 * U* V* U* V* U* V* U* V* . . . .  |
    305 	 * U* V* U* V* U* V* U* V* . . . .  UV_Scanlines
    306 	 * . . . . . . . . . . . . . . . .  |
    307 	 * . . . . . . . . . . . . . . . .  V
    308 	 * . . . . . . . . . . . . . . . .  -------> Buffer size aligned to 4k
    309 	 *
    310 	 *
    311 	 * Y_Stride = align(Width * 4/3, 128)
    312 	 * UV_Stride = align(Width * 4/3, 128)
    313 	 * Y_Scanlines = align(Height, 32)
    314 	 * UV_Scanlines = align(Height/2, 16)
    315 	 * Y_UBWC_Plane_Size = align(Y_Stride * Y_Scanlines, 4096)
    316 	 * UV_UBWC_Plane_Size = align(UV_Stride * UV_Scanlines, 4096)
    317 	 * Y_Meta_Stride = align(roundup(Width, Y_TileWidth), 64)
    318 	 * Y_Meta_Scanlines = align(roundup(Height, Y_TileHeight), 16)
    319 	 * Y_Meta_Plane_size = align(Y_Meta_Stride * Y_Meta_Scanlines, 4096)
    320 	 * UV_Meta_Stride = align(roundup(Width, UV_TileWidth), 64)
    321 	 * UV_Meta_Scanlines = align(roundup(Height, UV_TileHeight), 16)
    322 	 * UV_Meta_Plane_size = align(UV_Meta_Stride * UV_Meta_Scanlines, 4096)
    323 	 * Extradata = 16k
    324 	 *
    325 	 * Total size = align(Y_UBWC_Plane_size + UV_UBWC_Plane_size +
    326 	 *           Y_Meta_Plane_size + UV_Meta_Plane_size
    327 	 *           + max(Extradata, Y_Stride * 64), 4096)
    328 	 */
    329 	COLOR_FMT_NV12_BPP10_UBWC,
    330 	/* Venus RGBA8888 format:
    331 	 * Contains 1 plane in the following order -
    332 	 * (A) RGBA plane
    333 	 *
    334 	 * <-------- RGB_Stride -------->
    335 	 * <------- Width ------->
    336 	 * R R R R R R R R R R R R . . . .  ^           ^
    337 	 * R R R R R R R R R R R R . . . .  |           |
    338 	 * R R R R R R R R R R R R . . . .  Height      |
    339 	 * R R R R R R R R R R R R . . . .  |       RGB_Scanlines
    340 	 * R R R R R R R R R R R R . . . .  |           |
    341 	 * R R R R R R R R R R R R . . . .  |           |
    342 	 * R R R R R R R R R R R R . . . .  |           |
    343 	 * R R R R R R R R R R R R . . . .  V           |
    344 	 * . . . . . . . . . . . . . . . .              |
    345 	 * . . . . . . . . . . . . . . . .              |
    346 	 * . . . . . . . . . . . . . . . .              |
    347 	 * . . . . . . . . . . . . . . . .              V
    348 	 *
    349 	 * RGB_Stride = align(Width * 4, 128)
    350 	 * RGB_Scanlines = align(Height, 32)
    351 	 * RGB_Plane_size = align(RGB_Stride * RGB_Scanlines, 4096)
    352 	 * Extradata = 8k
    353 	 *
    354 	 * Total size = align(RGB_Plane_size + Extradata, 4096)
    355 	 */
    356 	COLOR_FMT_RGBA8888,
    357 	/* Venus RGBA8888 UBWC format:
    358 	 * Contains 2 planes in the following order -
    359 	 * (A) Meta plane
    360 	 * (B) RGBA plane
    361 	 *
    362 	 * <--- RGB_Meta_Stride ---->
    363 	 * <-------- Width ------>
    364 	 * M M M M M M M M M M M M . .      ^           ^
    365 	 * M M M M M M M M M M M M . .      |           |
    366 	 * M M M M M M M M M M M M . .      Height      |
    367 	 * M M M M M M M M M M M M . .      |       Meta_RGB_Scanlines
    368 	 * M M M M M M M M M M M M . .      |           |
    369 	 * M M M M M M M M M M M M . .      |           |
    370 	 * M M M M M M M M M M M M . .      |           |
    371 	 * M M M M M M M M M M M M . .      V           |
    372 	 * . . . . . . . . . . . . . .                  |
    373 	 * . . . . . . . . . . . . . .                  |
    374 	 * . . . . . . . . . . . . . .      -------> Buffer size aligned to 4k
    375 	 * . . . . . . . . . . . . . .                  V
    376 	 * <-------- RGB_Stride -------->
    377 	 * <------- Width ------->
    378 	 * R R R R R R R R R R R R . . . .  ^           ^
    379 	 * R R R R R R R R R R R R . . . .  |           |
    380 	 * R R R R R R R R R R R R . . . .  Height      |
    381 	 * R R R R R R R R R R R R . . . .  |       RGB_Scanlines
    382 	 * R R R R R R R R R R R R . . . .  |           |
    383 	 * R R R R R R R R R R R R . . . .  |           |
    384 	 * R R R R R R R R R R R R . . . .  |           |
    385 	 * R R R R R R R R R R R R . . . .  V           |
    386 	 * . . . . . . . . . . . . . . . .              |
    387 	 * . . . . . . . . . . . . . . . .              |
    388 	 * . . . . . . . . . . . . . . . .    -------> Buffer size aligned to 4k
    389 	 * . . . . . . . . . . . . . . . .              V
    390 	 *
    391 	 * RGB_Stride = align(Width * 4, 128)
    392 	 * RGB_Scanlines = align(Height, 32)
    393 	 * RGB_Plane_size = align(RGB_Stride * RGB_Scanlines, 4096)
    394 	 * RGB_Meta_Stride = align(roundup(Width, RGB_TileWidth), 64)
    395 	 * RGB_Meta_Scanline = align(roundup(Height, RGB_TileHeight), 16)
    396 	 * RGB_Meta_Plane_size = align(RGB_Meta_Stride *
    397 	 *		RGB_Meta_Scanlines, 4096)
    398 	 * Extradata = 8k
    399 	 *
    400 	 * Total size = align(RGB_Meta_Plane_size + RGB_Plane_size +
    401 	 *		Extradata, 4096)
    402 	 */
    403 	COLOR_FMT_RGBA8888_UBWC,
    404 	/* Venus RGBA1010102 UBWC format:
    405 	 * Contains 2 planes in the following order -
    406 	 * (A) Meta plane
    407 	 * (B) RGBA plane
    408 	 *
    409 	 * <--- RGB_Meta_Stride ---->
    410 	 * <-------- Width ------>
    411 	 * M M M M M M M M M M M M . .      ^           ^
    412 	 * M M M M M M M M M M M M . .      |           |
    413 	 * M M M M M M M M M M M M . .      Height      |
    414 	 * M M M M M M M M M M M M . .      |       Meta_RGB_Scanlines
    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 . .      |           |
    417 	 * M M M M M M M M M M M M . .      |           |
    418 	 * M M M M M M M M M M M M . .      V           |
    419 	 * . . . . . . . . . . . . . .                  |
    420 	 * . . . . . . . . . . . . . .                  |
    421 	 * . . . . . . . . . . . . . .      -------> Buffer size aligned to 4k
    422 	 * . . . . . . . . . . . . . .                  V
    423 	 * <-------- RGB_Stride -------->
    424 	 * <------- Width ------->
    425 	 * R R R R R R R R R R R R . . . .  ^           ^
    426 	 * R R R R R R R R R R R R . . . .  |           |
    427 	 * R R R R R R R R R R R R . . . .  Height      |
    428 	 * R R R R R R R R R R R R . . . .  |       RGB_Scanlines
    429 	 * R R R R R R R R R R R R . . . .  |           |
    430 	 * R R R R R R R R R R R R . . . .  |           |
    431 	 * R R R R R R R R R R R R . . . .  |           |
    432 	 * R R R R R R R R R R R R . . . .  V           |
    433 	 * . . . . . . . . . . . . . . . .              |
    434 	 * . . . . . . . . . . . . . . . .              |
    435 	 * . . . . . . . . . . . . . . . .    -------> Buffer size aligned to 4k
    436 	 * . . . . . . . . . . . . . . . .              V
    437 	 *
    438 	 * RGB_Stride = align(Width * 4, 256)
    439 	 * RGB_Scanlines = align(Height, 16)
    440 	 * RGB_Plane_size = align(RGB_Stride * RGB_Scanlines, 4096)
    441 	 * RGB_Meta_Stride = align(roundup(Width, RGB_TileWidth), 64)
    442 	 * RGB_Meta_Scanline = align(roundup(Height, RGB_TileHeight), 16)
    443 	 * RGB_Meta_Plane_size = align(RGB_Meta_Stride *
    444 	 *		RGB_Meta_Scanlines, 4096)
    445 	 * Extradata = 8k
    446 	 *
    447 	 * Total size = align(RGB_Meta_Plane_size + RGB_Plane_size +
    448 	 *		Extradata, 4096)
    449 	 */
    450 	COLOR_FMT_RGBA1010102_UBWC,
    451 	/* Venus RGB565 UBWC format:
    452 	 * Contains 2 planes in the following order -
    453 	 * (A) Meta plane
    454 	 * (B) RGB plane
    455 	 *
    456 	 * <--- RGB_Meta_Stride ---->
    457 	 * <-------- Width ------>
    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 . .      |           |
    460 	 * M M M M M M M M M M M M . .      Height      |
    461 	 * M M M M M M M M M M M M . .      |       Meta_RGB_Scanlines
    462 	 * M M M M M M M M M M M M . .      |           |
    463 	 * M M M M M M M M M M M M . .      |           |
    464 	 * M M M M M M M M M M M M . .      |           |
    465 	 * M M M M M M M M M M M M . .      V           |
    466 	 * . . . . . . . . . . . . . .                  |
    467 	 * . . . . . . . . . . . . . .                  |
    468 	 * . . . . . . . . . . . . . .      -------> Buffer size aligned to 4k
    469 	 * . . . . . . . . . . . . . .                  V
    470 	 * <-------- RGB_Stride -------->
    471 	 * <------- Width ------->
    472 	 * R R R R R R R R R R R R . . . .  ^           ^
    473 	 * R R R R R R R R R R R R . . . .  |           |
    474 	 * R R R R R R R R R R R R . . . .  Height      |
    475 	 * R R R R R R R R R R R R . . . .  |       RGB_Scanlines
    476 	 * R R R R R R R R R R R R . . . .  |           |
    477 	 * R R R R R R R R R R R R . . . .  |           |
    478 	 * R R R R R R R R R R R R . . . .  |           |
    479 	 * R R R R R R R R R R R R . . . .  V           |
    480 	 * . . . . . . . . . . . . . . . .              |
    481 	 * . . . . . . . . . . . . . . . .              |
    482 	 * . . . . . . . . . . . . . . . .    -------> Buffer size aligned to 4k
    483 	 * . . . . . . . . . . . . . . . .              V
    484 	 *
    485 	 * RGB_Stride = align(Width * 2, 128)
    486 	 * RGB_Scanlines = align(Height, 16)
    487 	 * RGB_Plane_size = align(RGB_Stride * RGB_Scanlines, 4096)
    488 	 * RGB_Meta_Stride = align(roundup(Width, RGB_TileWidth), 64)
    489 	 * RGB_Meta_Scanline = align(roundup(Height, RGB_TileHeight), 16)
    490 	 * RGB_Meta_Plane_size = align(RGB_Meta_Stride *
    491 	 *		RGB_Meta_Scanlines, 4096)
    492 	 * Extradata = 8k
    493 	 *
    494 	 * Total size = align(RGB_Meta_Plane_size + RGB_Plane_size +
    495 	 *		Extradata, 4096)
    496 	 */
    497 	COLOR_FMT_RGB565_UBWC,
    498 	/* P010 UBWC:
    499 	 * Compressed Macro-tile format for NV12.
    500 	 * Contains 4 planes in the following order -
    501 	 * (A) Y_Meta_Plane
    502 	 * (B) Y_UBWC_Plane
    503 	 * (C) UV_Meta_Plane
    504 	 * (D) UV_UBWC_Plane
    505 	 *
    506 	 * Y_Meta_Plane consists of meta information to decode compressed
    507 	 * tile data in Y_UBWC_Plane.
    508 	 * Y_UBWC_Plane consists of Y data in compressed macro-tile format.
    509 	 * UBWC decoder block will use the Y_Meta_Plane data together with
    510 	 * Y_UBWC_Plane data to produce loss-less uncompressed 10 bit Y samples.
    511 	 *
    512 	 * UV_Meta_Plane consists of meta information to decode compressed
    513 	 * tile data in UV_UBWC_Plane.
    514 	 * UV_UBWC_Plane consists of UV data in compressed macro-tile format.
    515 	 * UBWC decoder block will use UV_Meta_Plane data together with
    516 	 * UV_UBWC_Plane data to produce loss-less uncompressed 10 bit 2x2
    517 	 * subsampled color difference samples.
    518 	 *
    519 	 * Each tile in Y_UBWC_Plane/UV_UBWC_Plane is independently decodable
    520 	 * and randomly accessible. There is no dependency between tiles.
    521 	 *
    522 	 * <----- Y_Meta_Stride ----->
    523 	 * <-------- Width ------>
    524 	 * M M M M M M M M M M M M . .      ^           ^
    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 . .      Height      |
    527 	 * M M M M M M M M M M M M . .      |         Meta_Y_Scanlines
    528 	 * M M M M M M M M M M M M . .      |           |
    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 . .      V           |
    532 	 * . . . . . . . . . . . . . .                  |
    533 	 * . . . . . . . . . . . . . .                  |
    534 	 * . . . . . . . . . . . . . .      -------> Buffer size aligned to 4k
    535 	 * . . . . . . . . . . . . . .                  V
    536 	 * <--Compressed tile Y Stride--->
    537 	 * <------- Width ------->
    538 	 * Y* Y* Y* Y* Y* Y* Y* Y* . . . .  ^           ^
    539 	 * Y* Y* Y* Y* Y* Y* Y* Y* . . . .  |           |
    540 	 * Y* Y* Y* Y* Y* Y* Y* Y* . . . .  Height      |
    541 	 * Y* Y* Y* Y* Y* Y* Y* Y* . . . .  |        Macro_tile_Y_Scanlines
    542 	 * Y* Y* Y* Y* Y* Y* Y* Y* . . . .  |           |
    543 	 * Y* Y* Y* Y* Y* Y* Y* Y* . . . .  |           |
    544 	 * Y* Y* Y* Y* Y* Y* Y* Y* . . . .  |           |
    545 	 * Y* Y* Y* Y* Y* Y* Y* Y* . . . .  V           |
    546 	 * . . . . . . . . . . . . . . . .              |
    547 	 * . . . . . . . . . . . . . . . .              |
    548 	 * . . . . . . . . . . . . . . . .  -------> Buffer size aligned to 4k
    549 	 * . . . . . . . . . . . . . . . .              V
    550 	 * <----- UV_Meta_Stride ---->
    551 	 * M M M M M M M M M M M M . .      ^
    552 	 * M M M M M M M M M M M M . .      |
    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 . .      M_UV_Scanlines
    555 	 * . . . . . . . . . . . . . .      |
    556 	 * . . . . . . . . . . . . . .      V
    557 	 * . . . . . . . . . . . . . .      -------> Buffer size aligned to 4k
    558 	 * <--Compressed tile UV Stride--->
    559 	 * U* V* U* V* U* V* U* V* . . . .  ^
    560 	 * U* V* U* V* U* V* U* V* . . . .  |
    561 	 * U* V* U* V* U* V* U* V* . . . .  |
    562 	 * U* V* U* V* U* V* U* V* . . . .  UV_Scanlines
    563 	 * . . . . . . . . . . . . . . . .  |
    564 	 * . . . . . . . . . . . . . . . .  V
    565 	 * . . . . . . . . . . . . . . . .  -------> Buffer size aligned to 4k
    566 	 *
    567 	 *
    568 	 * Y_Stride = align(Width * 2, 256)
    569 	 * UV_Stride = align(Width * 2, 256)
    570 	 * Y_Scanlines = align(Height, 16)
    571 	 * UV_Scanlines = align(Height/2, 16)
    572 	 * Y_UBWC_Plane_Size = align(Y_Stride * Y_Scanlines, 4096)
    573 	 * UV_UBWC_Plane_Size = align(UV_Stride * UV_Scanlines, 4096)
    574 	 * Y_Meta_Stride = align(roundup(Width, Y_TileWidth), 64)
    575 	 * Y_Meta_Scanlines = align(roundup(Height, Y_TileHeight), 16)
    576 	 * Y_Meta_Plane_size = align(Y_Meta_Stride * Y_Meta_Scanlines, 4096)
    577 	 * UV_Meta_Stride = align(roundup(Width, UV_TileWidth), 64)
    578 	 * UV_Meta_Scanlines = align(roundup(Height, UV_TileHeight), 16)
    579 	 * UV_Meta_Plane_size = align(UV_Meta_Stride * UV_Meta_Scanlines, 4096)
    580 	 * Extradata = 8k
    581 	 *
    582 	 * Total size = align(Y_UBWC_Plane_size + UV_UBWC_Plane_size +
    583 	 *           Y_Meta_Plane_size + UV_Meta_Plane_size
    584 	 *           + max(Extradata, Y_Stride * 48), 4096)
    585 	 */
    586 	COLOR_FMT_P010_UBWC,
    587 };
    588 
    589 #define COLOR_FMT_RGBA1010102_UBWC	COLOR_FMT_RGBA1010102_UBWC
    590 #define COLOR_FMT_RGB565_UBWC		COLOR_FMT_RGB565_UBWC
    591 #define COLOR_FMT_P010_UBWC		COLOR_FMT_P010_UBWC
    592 
    593 static __inline__ unsigned int VENUS_EXTRADATA_SIZE(int width, int height)
    594 {
    595 	(void)height;
    596 	(void)width;
    597 
    598 	/*
    599 	 * In the future, calculate the size based on the w/h but just
    600 	 * hardcode it for now since 16K satisfies all current usecases.
    601 	 */
    602 	return 16 * 1024;
    603 }
    604 
    605 static __inline__ unsigned int VENUS_Y_STRIDE(int color_fmt, int width)
    606 {
    607 	unsigned int alignment, stride = 0;
    608 
    609 	if (!width)
    610 		goto invalid_input;
    611 
    612 	switch (color_fmt) {
    613 	case COLOR_FMT_NV21:
    614 	case COLOR_FMT_NV12:
    615 	case COLOR_FMT_NV12_MVTB:
    616 	case COLOR_FMT_NV12_UBWC:
    617 		alignment = 128;
    618 		stride = MSM_MEDIA_ALIGN(width, alignment);
    619 		break;
    620 	case COLOR_FMT_NV12_BPP10_UBWC:
    621 		alignment = 256;
    622 		stride = MSM_MEDIA_ALIGN(width, 192);
    623 		stride = MSM_MEDIA_ALIGN(stride * 4/3, alignment);
    624 		break;
    625 	case COLOR_FMT_P010_UBWC:
    626 		alignment = 256;
    627 		stride = MSM_MEDIA_ALIGN(width * 2, alignment);
    628 		break;
    629 	default:
    630 		break;
    631 	}
    632 invalid_input:
    633 	return stride;
    634 }
    635 
    636 static __inline__ unsigned int VENUS_UV_STRIDE(int color_fmt, int width)
    637 {
    638 	unsigned int alignment, stride = 0;
    639 
    640 	if (!width)
    641 		goto invalid_input;
    642 
    643 	switch (color_fmt) {
    644 	case COLOR_FMT_NV21:
    645 	case COLOR_FMT_NV12:
    646 	case COLOR_FMT_NV12_MVTB:
    647 	case COLOR_FMT_NV12_UBWC:
    648 		alignment = 128;
    649 		stride = MSM_MEDIA_ALIGN(width, alignment);
    650 		break;
    651 	case COLOR_FMT_NV12_BPP10_UBWC:
    652 		alignment = 256;
    653 		stride = MSM_MEDIA_ALIGN(width, 192);
    654 		stride = MSM_MEDIA_ALIGN(stride * 4/3, alignment);
    655 		break;
    656 	case COLOR_FMT_P010_UBWC:
    657 		alignment = 256;
    658 		stride = MSM_MEDIA_ALIGN(width * 2, alignment);
    659 		break;
    660 	default:
    661 		break;
    662 	}
    663 invalid_input:
    664 	return stride;
    665 }
    666 
    667 static __inline__ unsigned int VENUS_Y_SCANLINES(int color_fmt, int height)
    668 {
    669 	unsigned int alignment, sclines = 0;
    670 
    671 	if (!height)
    672 		goto invalid_input;
    673 
    674 	switch (color_fmt) {
    675 	case COLOR_FMT_NV21:
    676 	case COLOR_FMT_NV12:
    677 	case COLOR_FMT_NV12_MVTB:
    678 	case COLOR_FMT_NV12_UBWC:
    679 		alignment = 32;
    680 		break;
    681 	case COLOR_FMT_NV12_BPP10_UBWC:
    682 	case COLOR_FMT_P010_UBWC:
    683 		alignment = 16;
    684 		break;
    685 	default:
    686 		return 0;
    687 	}
    688 	sclines = MSM_MEDIA_ALIGN(height, alignment);
    689 invalid_input:
    690 	return sclines;
    691 }
    692 
    693 static __inline__ unsigned int VENUS_UV_SCANLINES(int color_fmt, int height)
    694 {
    695 	unsigned int alignment, sclines = 0;
    696 
    697 	if (!height)
    698 		goto invalid_input;
    699 
    700 	switch (color_fmt) {
    701 	case COLOR_FMT_NV21:
    702 	case COLOR_FMT_NV12:
    703 	case COLOR_FMT_NV12_MVTB:
    704 	case COLOR_FMT_NV12_BPP10_UBWC:
    705 	case COLOR_FMT_P010_UBWC:
    706 		alignment = 16;
    707 		break;
    708 	case COLOR_FMT_NV12_UBWC:
    709 		alignment = 32;
    710 		break;
    711 	default:
    712 		goto invalid_input;
    713 	}
    714 
    715 	sclines = MSM_MEDIA_ALIGN(height / 2, alignment);
    716 
    717 invalid_input:
    718 	return sclines;
    719 }
    720 
    721 static __inline__ unsigned int VENUS_Y_META_STRIDE(int color_fmt, int width)
    722 {
    723 	int y_tile_width = 0, y_meta_stride = 0;
    724 
    725 	if (!width)
    726 		goto invalid_input;
    727 
    728 	switch (color_fmt) {
    729 	case COLOR_FMT_NV12_UBWC:
    730 	case COLOR_FMT_P010_UBWC:
    731 		y_tile_width = 32;
    732 		break;
    733 	case COLOR_FMT_NV12_BPP10_UBWC:
    734 		y_tile_width = 48;
    735 		break;
    736 	default:
    737 		goto invalid_input;
    738 	}
    739 
    740 	y_meta_stride = MSM_MEDIA_ROUNDUP(width, y_tile_width);
    741 	y_meta_stride = MSM_MEDIA_ALIGN(y_meta_stride, 64);
    742 
    743 invalid_input:
    744 	return y_meta_stride;
    745 }
    746 
    747 static __inline__ unsigned int VENUS_Y_META_SCANLINES(int color_fmt, int height)
    748 {
    749 	int y_tile_height = 0, y_meta_scanlines = 0;
    750 
    751 	if (!height)
    752 		goto invalid_input;
    753 
    754 	switch (color_fmt) {
    755 	case COLOR_FMT_NV12_UBWC:
    756 		y_tile_height = 8;
    757 		break;
    758 	case COLOR_FMT_NV12_BPP10_UBWC:
    759 	case COLOR_FMT_P010_UBWC:
    760 		y_tile_height = 4;
    761 		break;
    762 	default:
    763 		goto invalid_input;
    764 	}
    765 
    766 	y_meta_scanlines = MSM_MEDIA_ROUNDUP(height, y_tile_height);
    767 	y_meta_scanlines = MSM_MEDIA_ALIGN(y_meta_scanlines, 16);
    768 
    769 invalid_input:
    770 	return y_meta_scanlines;
    771 }
    772 
    773 static __inline__ unsigned int VENUS_UV_META_STRIDE(int color_fmt, int width)
    774 {
    775 	int uv_tile_width = 0, uv_meta_stride = 0;
    776 
    777 	if (!width)
    778 		goto invalid_input;
    779 
    780 	switch (color_fmt) {
    781 	case COLOR_FMT_NV12_UBWC:
    782 	case COLOR_FMT_P010_UBWC:
    783 		uv_tile_width = 16;
    784 		break;
    785 	case COLOR_FMT_NV12_BPP10_UBWC:
    786 		uv_tile_width = 24;
    787 		break;
    788 	default:
    789 		goto invalid_input;
    790 	}
    791 
    792 	uv_meta_stride = MSM_MEDIA_ROUNDUP(width / 2, uv_tile_width);
    793 	uv_meta_stride = MSM_MEDIA_ALIGN(uv_meta_stride, 64);
    794 
    795 invalid_input:
    796 	return uv_meta_stride;
    797 }
    798 
    799 static __inline__ unsigned int VENUS_UV_META_SCANLINES(int color_fmt, int height)
    800 {
    801 	int uv_tile_height = 0, uv_meta_scanlines = 0;
    802 
    803 	if (!height)
    804 		goto invalid_input;
    805 
    806 	switch (color_fmt) {
    807 	case COLOR_FMT_NV12_UBWC:
    808 		uv_tile_height = 8;
    809 		break;
    810 	case COLOR_FMT_NV12_BPP10_UBWC:
    811 	case COLOR_FMT_P010_UBWC:
    812 		uv_tile_height = 4;
    813 		break;
    814 	default:
    815 		goto invalid_input;
    816 	}
    817 
    818 	uv_meta_scanlines = MSM_MEDIA_ROUNDUP(height / 2, uv_tile_height);
    819 	uv_meta_scanlines = MSM_MEDIA_ALIGN(uv_meta_scanlines, 16);
    820 
    821 invalid_input:
    822 	return uv_meta_scanlines;
    823 }
    824 
    825 static __inline__ unsigned int VENUS_RGB_STRIDE(int color_fmt, int width)
    826 {
    827 	unsigned int alignment = 0, stride = 0, bpp = 4;
    828 
    829 	if (!width)
    830 		goto invalid_input;
    831 
    832 	switch (color_fmt) {
    833 	case COLOR_FMT_RGBA8888:
    834 		alignment = 128;
    835 		break;
    836 	case COLOR_FMT_RGB565_UBWC:
    837 		alignment = 128;
    838 		bpp = 2;
    839 		break;
    840 	case COLOR_FMT_RGBA8888_UBWC:
    841 	case COLOR_FMT_RGBA1010102_UBWC:
    842 		alignment = 256;
    843 		break;
    844 	default:
    845 		goto invalid_input;
    846 	}
    847 
    848 	stride = MSM_MEDIA_ALIGN(width * bpp, alignment);
    849 
    850 invalid_input:
    851 	return stride;
    852 }
    853 
    854 static __inline__ unsigned int VENUS_RGB_SCANLINES(int color_fmt, int height)
    855 {
    856 	unsigned int alignment = 0, scanlines = 0;
    857 
    858 	if (!height)
    859 		goto invalid_input;
    860 
    861 	switch (color_fmt) {
    862 	case COLOR_FMT_RGBA8888:
    863 		alignment = 32;
    864 		break;
    865 	case COLOR_FMT_RGBA8888_UBWC:
    866 	case COLOR_FMT_RGBA1010102_UBWC:
    867 	case COLOR_FMT_RGB565_UBWC:
    868 		alignment = 16;
    869 		break;
    870 	default:
    871 		goto invalid_input;
    872 	}
    873 
    874 	scanlines = MSM_MEDIA_ALIGN(height, alignment);
    875 
    876 invalid_input:
    877 	return scanlines;
    878 }
    879 
    880 static __inline__ unsigned int VENUS_RGB_META_STRIDE(int color_fmt, int width)
    881 {
    882 	int rgb_tile_width = 0, rgb_meta_stride = 0;
    883 
    884 	if (!width)
    885 		goto invalid_input;
    886 
    887 	switch (color_fmt) {
    888 	case COLOR_FMT_RGBA8888_UBWC:
    889 	case COLOR_FMT_RGBA1010102_UBWC:
    890 	case COLOR_FMT_RGB565_UBWC:
    891 		rgb_tile_width = 16;
    892 		break;
    893 	default:
    894 		goto invalid_input;
    895 	}
    896 
    897 	rgb_meta_stride = MSM_MEDIA_ROUNDUP(width, rgb_tile_width);
    898 	rgb_meta_stride = MSM_MEDIA_ALIGN(rgb_meta_stride, 64);
    899 
    900 invalid_input:
    901 	return rgb_meta_stride;
    902 }
    903 
    904 static __inline__ unsigned int VENUS_RGB_META_SCANLINES(int color_fmt, int height)
    905 {
    906 	int rgb_tile_height = 0, rgb_meta_scanlines = 0;
    907 
    908 	if (!height)
    909 		goto invalid_input;
    910 
    911 	switch (color_fmt) {
    912 	case COLOR_FMT_RGBA8888_UBWC:
    913 	case COLOR_FMT_RGBA1010102_UBWC:
    914 	case COLOR_FMT_RGB565_UBWC:
    915 		rgb_tile_height = 4;
    916 		break;
    917 	default:
    918 		goto invalid_input;
    919 	}
    920 
    921 	rgb_meta_scanlines = MSM_MEDIA_ROUNDUP(height, rgb_tile_height);
    922 	rgb_meta_scanlines = MSM_MEDIA_ALIGN(rgb_meta_scanlines, 16);
    923 
    924 invalid_input:
    925 	return rgb_meta_scanlines;
    926 }
    927 
    928 static __inline__ unsigned int VENUS_BUFFER_SIZE(
    929 	int color_fmt, int width, int height)
    930 {
    931 	const unsigned int extra_size = VENUS_EXTRADATA_SIZE(width, height);
    932 	unsigned int uv_alignment = 0, size = 0;
    933 	unsigned int y_plane, uv_plane, y_stride,
    934 		uv_stride, y_sclines, uv_sclines;
    935 	unsigned int y_ubwc_plane = 0, uv_ubwc_plane = 0;
    936 	unsigned int y_meta_stride = 0, y_meta_scanlines = 0;
    937 	unsigned int uv_meta_stride = 0, uv_meta_scanlines = 0;
    938 	unsigned int y_meta_plane = 0, uv_meta_plane = 0;
    939 	unsigned int rgb_stride = 0, rgb_scanlines = 0;
    940 	unsigned int rgb_plane = 0, rgb_ubwc_plane = 0, rgb_meta_plane = 0;
    941 	unsigned int rgb_meta_stride = 0, rgb_meta_scanlines = 0;
    942 
    943 	if (!width || !height)
    944 		goto invalid_input;
    945 
    946 	y_stride = VENUS_Y_STRIDE(color_fmt, width);
    947 	uv_stride = VENUS_UV_STRIDE(color_fmt, width);
    948 	y_sclines = VENUS_Y_SCANLINES(color_fmt, height);
    949 	uv_sclines = VENUS_UV_SCANLINES(color_fmt, height);
    950 	rgb_stride = VENUS_RGB_STRIDE(color_fmt, width);
    951 	rgb_scanlines = VENUS_RGB_SCANLINES(color_fmt, height);
    952 
    953 	switch (color_fmt) {
    954 	case COLOR_FMT_NV21:
    955 	case COLOR_FMT_NV12:
    956 		uv_alignment = 4096;
    957 		y_plane = y_stride * y_sclines;
    958 		uv_plane = uv_stride * uv_sclines + uv_alignment;
    959 		size = y_plane + uv_plane +
    960 				MSM_MEDIA_MAX(extra_size, 8 * y_stride);
    961 		size = MSM_MEDIA_ALIGN(size, 4096);
    962 		break;
    963 	case COLOR_FMT_NV12_MVTB:
    964 		uv_alignment = 4096;
    965 		y_plane = y_stride * y_sclines;
    966 		uv_plane = uv_stride * uv_sclines + uv_alignment;
    967 		size = y_plane + uv_plane;
    968 		size = 2 * size + extra_size;
    969 		size = MSM_MEDIA_ALIGN(size, 4096);
    970 		break;
    971 	case COLOR_FMT_NV12_UBWC:
    972 	case COLOR_FMT_NV12_BPP10_UBWC:
    973 		y_ubwc_plane = MSM_MEDIA_ALIGN(y_stride * y_sclines, 4096);
    974 		uv_ubwc_plane = MSM_MEDIA_ALIGN(uv_stride * uv_sclines, 4096);
    975 		y_meta_stride = VENUS_Y_META_STRIDE(color_fmt, width);
    976 		y_meta_scanlines = VENUS_Y_META_SCANLINES(color_fmt, height);
    977 		y_meta_plane = MSM_MEDIA_ALIGN(
    978 				y_meta_stride * y_meta_scanlines, 4096);
    979 		uv_meta_stride = VENUS_UV_META_STRIDE(color_fmt, width);
    980 		uv_meta_scanlines = VENUS_UV_META_SCANLINES(color_fmt, height);
    981 		uv_meta_plane = MSM_MEDIA_ALIGN(uv_meta_stride *
    982 					uv_meta_scanlines, 4096);
    983 
    984 		size = y_ubwc_plane + uv_ubwc_plane + y_meta_plane +
    985 			uv_meta_plane + MSM_MEDIA_MAX(extra_size,
    986 			64 * y_stride);
    987 		size = MSM_MEDIA_ALIGN(size, 4096);
    988 		break;
    989 	case COLOR_FMT_P010_UBWC:
    990 		y_ubwc_plane = MSM_MEDIA_ALIGN(y_stride * y_sclines, 4096);
    991 		uv_ubwc_plane = MSM_MEDIA_ALIGN(uv_stride * uv_sclines, 4096);
    992 		y_meta_stride = VENUS_Y_META_STRIDE(color_fmt, width);
    993 		y_meta_scanlines = VENUS_Y_META_SCANLINES(color_fmt, height);
    994 		y_meta_plane = MSM_MEDIA_ALIGN(
    995 				y_meta_stride * y_meta_scanlines, 4096);
    996 		uv_meta_stride = VENUS_UV_META_STRIDE(color_fmt, width);
    997 		uv_meta_scanlines = VENUS_UV_META_SCANLINES(color_fmt, height);
    998 		uv_meta_plane = MSM_MEDIA_ALIGN(uv_meta_stride *
    999 					uv_meta_scanlines, 4096);
   1000 
   1001 		size = y_ubwc_plane + uv_ubwc_plane + y_meta_plane +
   1002 			uv_meta_plane;
   1003 		size = MSM_MEDIA_ALIGN(size, 4096);
   1004 		break;
   1005 	case COLOR_FMT_RGBA8888:
   1006 		rgb_plane = MSM_MEDIA_ALIGN(rgb_stride  * rgb_scanlines, 4096);
   1007 		size = rgb_plane;
   1008 		size =  MSM_MEDIA_ALIGN(size, 4096);
   1009 		break;
   1010 	case COLOR_FMT_RGBA8888_UBWC:
   1011 		rgb_ubwc_plane = MSM_MEDIA_ALIGN(rgb_stride * rgb_scanlines,
   1012 							4096);
   1013 		rgb_meta_stride = VENUS_RGB_META_STRIDE(color_fmt, width);
   1014 		rgb_meta_scanlines = VENUS_RGB_META_SCANLINES(color_fmt,
   1015 					height);
   1016 		rgb_meta_plane = MSM_MEDIA_ALIGN(rgb_meta_stride *
   1017 					rgb_meta_scanlines, 4096);
   1018 		size = rgb_ubwc_plane + rgb_meta_plane;
   1019 		size = MSM_MEDIA_ALIGN(size, 4096);
   1020 		break;
   1021 	default:
   1022 		break;
   1023 	}
   1024 invalid_input:
   1025 	return size;
   1026 }
   1027 
   1028 static __inline__ unsigned int VENUS_VIEW2_OFFSET(
   1029 	int color_fmt, int width, int height)
   1030 {
   1031 	unsigned int offset = 0;
   1032 	unsigned int y_plane, uv_plane, y_stride,
   1033 		uv_stride, y_sclines, uv_sclines;
   1034 	if (!width || !height)
   1035 		goto invalid_input;
   1036 
   1037 	y_stride = VENUS_Y_STRIDE(color_fmt, width);
   1038 	uv_stride = VENUS_UV_STRIDE(color_fmt, width);
   1039 	y_sclines = VENUS_Y_SCANLINES(color_fmt, height);
   1040 	uv_sclines = VENUS_UV_SCANLINES(color_fmt, height);
   1041 	switch (color_fmt) {
   1042 	case COLOR_FMT_NV12_MVTB:
   1043 		y_plane = y_stride * y_sclines;
   1044 		uv_plane = uv_stride * uv_sclines;
   1045 		offset = y_plane + uv_plane;
   1046 		break;
   1047 	default:
   1048 		break;
   1049 	}
   1050 invalid_input:
   1051 	return offset;
   1052 }
   1053 
   1054 #endif
   1055