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