1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * Copyright (c) 2014 The Linux Foundation. All rights reserved. 4 * Copyright (C) 2013 Red Hat 5 * Author: Rob Clark <robdclark@gmail.com> 6 */ 7 8 #include <drm/drm_fourcc.h> 9 #include <drm/drm_framebuffer.h> 10 11 #include "msm_drv.h" 12 #include "mdp_kms.h" 13 14 static struct csc_cfg csc_convert[CSC_MAX] = { 15 [CSC_RGB2RGB] = { 16 .type = CSC_RGB2RGB, 17 .matrix = { 18 0x0200, 0x0000, 0x0000, 19 0x0000, 0x0200, 0x0000, 20 0x0000, 0x0000, 0x0200 21 }, 22 .pre_bias = { 0x0, 0x0, 0x0 }, 23 .post_bias = { 0x0, 0x0, 0x0 }, 24 .pre_clamp = { 0x0, 0xff, 0x0, 0xff, 0x0, 0xff }, 25 .post_clamp = { 0x0, 0xff, 0x0, 0xff, 0x0, 0xff }, 26 }, 27 [CSC_YUV2RGB] = { 28 .type = CSC_YUV2RGB, 29 .matrix = { 30 0x0254, 0x0000, 0x0331, 31 0x0254, 0xff37, 0xfe60, 32 0x0254, 0x0409, 0x0000 33 }, 34 .pre_bias = { 0xfff0, 0xff80, 0xff80 }, 35 .post_bias = { 0x00, 0x00, 0x00 }, 36 .pre_clamp = { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff }, 37 .post_clamp = { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff }, 38 }, 39 [CSC_RGB2YUV] = { 40 .type = CSC_RGB2YUV, 41 .matrix = { 42 0x0083, 0x0102, 0x0032, 43 0x1fb5, 0x1f6c, 0x00e1, 44 0x00e1, 0x1f45, 0x1fdc 45 }, 46 .pre_bias = { 0x00, 0x00, 0x00 }, 47 .post_bias = { 0x10, 0x80, 0x80 }, 48 .pre_clamp = { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff }, 49 .post_clamp = { 0x10, 0xeb, 0x10, 0xf0, 0x10, 0xf0 }, 50 }, 51 [CSC_YUV2YUV] = { 52 .type = CSC_YUV2YUV, 53 .matrix = { 54 0x0200, 0x0000, 0x0000, 55 0x0000, 0x0200, 0x0000, 56 0x0000, 0x0000, 0x0200 57 }, 58 .pre_bias = { 0x00, 0x00, 0x00 }, 59 .post_bias = { 0x00, 0x00, 0x00 }, 60 .pre_clamp = { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff }, 61 .post_clamp = { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff }, 62 }, 63 }; 64 65 #define MDP_TILE_HEIGHT_DEFAULT 1 66 #define MDP_TILE_HEIGHT_UBWC 4 67 #define MDP_TILE_HEIGHT_NV12 8 68 69 #define INTERLEAVED_RGB_FMT(fmt, a, r, g, b, e0, e1, e2, e3, uc, alpha, \ 70 bp, flg, fm, np) \ 71 { \ 72 .pixel_format = DRM_FORMAT_ ## fmt, \ 73 .fetch_type = MDP_PLANE_INTERLEAVED, \ 74 .alpha_enable = alpha, \ 75 .element = { (e0), (e1), (e2), (e3) }, \ 76 .bpc_g_y = g, \ 77 .bpc_b_cb = b, \ 78 .bpc_r_cr = r, \ 79 .bpc_a = a, \ 80 .chroma_sample = CHROMA_FULL, \ 81 .unpack_count = uc, \ 82 .bpp = bp, \ 83 .fetch_mode = fm, \ 84 .flags = MSM_FORMAT_FLAG_UNPACK_TIGHT | flg, \ 85 .num_planes = np, \ 86 .tile_height = MDP_TILE_HEIGHT_DEFAULT \ 87 } 88 89 #define INTERLEAVED_RGB_FMT_TILED(fmt, a, r, g, b, e0, e1, e2, e3, uc, \ 90 alpha, bp, flg, fm, np, th) \ 91 { \ 92 .pixel_format = DRM_FORMAT_ ## fmt, \ 93 .fetch_type = MDP_PLANE_INTERLEAVED, \ 94 .alpha_enable = alpha, \ 95 .element = { (e0), (e1), (e2), (e3) }, \ 96 .bpc_g_y = g, \ 97 .bpc_b_cb = b, \ 98 .bpc_r_cr = r, \ 99 .bpc_a = a, \ 100 .chroma_sample = CHROMA_FULL, \ 101 .unpack_count = uc, \ 102 .bpp = bp, \ 103 .fetch_mode = fm, \ 104 .flags = MSM_FORMAT_FLAG_UNPACK_TIGHT | flg, \ 105 .num_planes = np, \ 106 .tile_height = th \ 107 } 108 109 #define INTERLEAVED_YUV_FMT(fmt, a, r, g, b, e0, e1, e2, e3, \ 110 alpha, chroma, count, bp, flg, fm, np) \ 111 { \ 112 .pixel_format = DRM_FORMAT_ ## fmt, \ 113 .fetch_type = MDP_PLANE_INTERLEAVED, \ 114 .alpha_enable = alpha, \ 115 .element = { (e0), (e1), (e2), (e3)}, \ 116 .bpc_g_y = g, \ 117 .bpc_b_cb = b, \ 118 .bpc_r_cr = r, \ 119 .bpc_a = a, \ 120 .chroma_sample = chroma, \ 121 .unpack_count = count, \ 122 .bpp = bp, \ 123 .fetch_mode = fm, \ 124 .flags = MSM_FORMAT_FLAG_UNPACK_TIGHT | flg, \ 125 .num_planes = np, \ 126 .tile_height = MDP_TILE_HEIGHT_DEFAULT \ 127 } 128 129 #define PSEUDO_YUV_FMT(fmt, a, r, g, b, e0, e1, chroma, flg, fm, np) \ 130 { \ 131 .pixel_format = DRM_FORMAT_ ## fmt, \ 132 .fetch_type = MDP_PLANE_PSEUDO_PLANAR, \ 133 .alpha_enable = 0, \ 134 .element = { (e0), (e1), 0, 0 }, \ 135 .bpc_g_y = g, \ 136 .bpc_b_cb = b, \ 137 .bpc_r_cr = r, \ 138 .bpc_a = a, \ 139 .chroma_sample = chroma, \ 140 .unpack_count = 2, \ 141 .bpp = 2, \ 142 .fetch_mode = fm, \ 143 .flags = MSM_FORMAT_FLAG_UNPACK_TIGHT | flg, \ 144 .num_planes = np, \ 145 .tile_height = MDP_TILE_HEIGHT_DEFAULT \ 146 } 147 148 #define PSEUDO_YUV_FMT_TILED(fmt, a, r, g, b, e0, e1, chroma, \ 149 flg, fm, np, th) \ 150 { \ 151 .pixel_format = DRM_FORMAT_ ## fmt, \ 152 .fetch_type = MDP_PLANE_PSEUDO_PLANAR, \ 153 .alpha_enable = 0, \ 154 .element = { (e0), (e1), 0, 0 }, \ 155 .bpc_g_y = g, \ 156 .bpc_b_cb = b, \ 157 .bpc_r_cr = r, \ 158 .bpc_a = a, \ 159 .chroma_sample = chroma, \ 160 .unpack_count = 2, \ 161 .bpp = 2, \ 162 .fetch_mode = fm, \ 163 .flags = MSM_FORMAT_FLAG_UNPACK_TIGHT | flg, \ 164 .num_planes = np, \ 165 .tile_height = th \ 166 } 167 168 #define PSEUDO_YUV_FMT_LOOSE(fmt, a, r, g, b, e0, e1, chroma, flg, fm, np)\ 169 { \ 170 .pixel_format = DRM_FORMAT_ ## fmt, \ 171 .fetch_type = MDP_PLANE_PSEUDO_PLANAR, \ 172 .alpha_enable = 0, \ 173 .element = { (e0), (e1), 0, 0 }, \ 174 .bpc_g_y = g, \ 175 .bpc_b_cb = b, \ 176 .bpc_r_cr = r, \ 177 .bpc_a = a, \ 178 .chroma_sample = chroma, \ 179 .unpack_count = 2, \ 180 .bpp = 2, \ 181 .fetch_mode = fm, \ 182 .flags = MSM_FORMAT_FLAG_UNPACK_ALIGN_MSB | flg, \ 183 .num_planes = np, \ 184 .tile_height = MDP_TILE_HEIGHT_DEFAULT \ 185 } 186 187 #define PSEUDO_YUV_FMT_LOOSE_TILED(fmt, a, r, g, b, e0, e1, chroma, \ 188 flg, fm, np, th) \ 189 { \ 190 .pixel_format = DRM_FORMAT_ ## fmt, \ 191 .fetch_type = MDP_PLANE_PSEUDO_PLANAR, \ 192 .alpha_enable = 0, \ 193 .element = { (e0), (e1), 0, 0 }, \ 194 .bpc_g_y = g, \ 195 .bpc_b_cb = b, \ 196 .bpc_r_cr = r, \ 197 .bpc_a = a, \ 198 .chroma_sample = chroma, \ 199 .unpack_count = 2, \ 200 .bpp = 2, \ 201 .fetch_mode = fm, \ 202 .flags = MSM_FORMAT_FLAG_UNPACK_ALIGN_MSB | flg, \ 203 .num_planes = np, \ 204 .tile_height = th \ 205 } 206 207 #define PLANAR_YUV_FMT(fmt, a, r, g, b, e0, e1, e2, alpha, chroma, bp, \ 208 flg, fm, np) \ 209 { \ 210 .pixel_format = DRM_FORMAT_ ## fmt, \ 211 .fetch_type = MDP_PLANE_PLANAR, \ 212 .alpha_enable = alpha, \ 213 .element = { (e0), (e1), (e2), 0 }, \ 214 .bpc_g_y = g, \ 215 .bpc_b_cb = b, \ 216 .bpc_r_cr = r, \ 217 .bpc_a = a, \ 218 .chroma_sample = chroma, \ 219 .unpack_count = 1, \ 220 .bpp = bp, \ 221 .fetch_mode = fm, \ 222 .flags = MSM_FORMAT_FLAG_UNPACK_TIGHT | flg, \ 223 .num_planes = np, \ 224 .tile_height = MDP_TILE_HEIGHT_DEFAULT \ 225 } 226 227 static const struct msm_format mdp_formats[] = { 228 INTERLEAVED_RGB_FMT(ARGB8888, 229 BPC8A, BPC8, BPC8, BPC8, 230 C1_B_Cb, C0_G_Y, C2_R_Cr, C3_ALPHA, 4, 231 true, 4, 0, 232 MDP_FETCH_LINEAR, 1), 233 234 INTERLEAVED_RGB_FMT(ABGR8888, 235 BPC8A, BPC8, BPC8, BPC8, 236 C2_R_Cr, C0_G_Y, C1_B_Cb, C3_ALPHA, 4, 237 true, 4, 0, 238 MDP_FETCH_LINEAR, 1), 239 240 INTERLEAVED_RGB_FMT(XBGR8888, 241 BPC8A, BPC8, BPC8, BPC8, 242 C2_R_Cr, C0_G_Y, C1_B_Cb, C3_ALPHA, 4, 243 false, 4, 0, 244 MDP_FETCH_LINEAR, 1), 245 246 INTERLEAVED_RGB_FMT(RGBA8888, 247 BPC8A, BPC8, BPC8, BPC8, 248 C3_ALPHA, C1_B_Cb, C0_G_Y, C2_R_Cr, 4, 249 true, 4, 0, 250 MDP_FETCH_LINEAR, 1), 251 252 INTERLEAVED_RGB_FMT(BGRA8888, 253 BPC8A, BPC8, BPC8, BPC8, 254 C3_ALPHA, C2_R_Cr, C0_G_Y, C1_B_Cb, 4, 255 true, 4, 0, 256 MDP_FETCH_LINEAR, 1), 257 258 INTERLEAVED_RGB_FMT(BGRX8888, 259 BPC8A, BPC8, BPC8, BPC8, 260 C3_ALPHA, C2_R_Cr, C0_G_Y, C1_B_Cb, 4, 261 false, 4, 0, 262 MDP_FETCH_LINEAR, 1), 263 264 INTERLEAVED_RGB_FMT(XRGB8888, 265 BPC8A, BPC8, BPC8, BPC8, 266 C1_B_Cb, C0_G_Y, C2_R_Cr, C3_ALPHA, 4, 267 false, 4, 0, 268 MDP_FETCH_LINEAR, 1), 269 270 INTERLEAVED_RGB_FMT(RGBX8888, 271 BPC8A, BPC8, BPC8, BPC8, 272 C3_ALPHA, C1_B_Cb, C0_G_Y, C2_R_Cr, 4, 273 false, 4, 0, 274 MDP_FETCH_LINEAR, 1), 275 276 INTERLEAVED_RGB_FMT(RGB888, 277 0, BPC8, BPC8, BPC8, 278 C1_B_Cb, C0_G_Y, C2_R_Cr, 0, 3, 279 false, 3, 0, 280 MDP_FETCH_LINEAR, 1), 281 282 INTERLEAVED_RGB_FMT(BGR888, 283 0, BPC8, BPC8, BPC8, 284 C2_R_Cr, C0_G_Y, C1_B_Cb, 0, 3, 285 false, 3, 0, 286 MDP_FETCH_LINEAR, 1), 287 288 INTERLEAVED_RGB_FMT(RGB565, 289 0, BPC5, BPC6, BPC5, 290 C1_B_Cb, C0_G_Y, C2_R_Cr, 0, 3, 291 false, 2, 0, 292 MDP_FETCH_LINEAR, 1), 293 294 INTERLEAVED_RGB_FMT(BGR565, 295 0, BPC5, BPC6, BPC5, 296 C2_R_Cr, C0_G_Y, C1_B_Cb, 0, 3, 297 false, 2, 0, 298 MDP_FETCH_LINEAR, 1), 299 300 INTERLEAVED_RGB_FMT(ARGB1555, 301 BPC1A, BPC5, BPC5, BPC5, 302 C1_B_Cb, C0_G_Y, C2_R_Cr, C3_ALPHA, 4, 303 true, 2, 0, 304 MDP_FETCH_LINEAR, 1), 305 306 INTERLEAVED_RGB_FMT(ABGR1555, 307 BPC1A, BPC5, BPC5, BPC5, 308 C2_R_Cr, C0_G_Y, C1_B_Cb, C3_ALPHA, 4, 309 true, 2, 0, 310 MDP_FETCH_LINEAR, 1), 311 312 INTERLEAVED_RGB_FMT(RGBA5551, 313 BPC1A, BPC5, BPC5, BPC5, 314 C3_ALPHA, C1_B_Cb, C0_G_Y, C2_R_Cr, 4, 315 true, 2, 0, 316 MDP_FETCH_LINEAR, 1), 317 318 INTERLEAVED_RGB_FMT(BGRA5551, 319 BPC1A, BPC5, BPC5, BPC5, 320 C3_ALPHA, C2_R_Cr, C0_G_Y, C1_B_Cb, 4, 321 true, 2, 0, 322 MDP_FETCH_LINEAR, 1), 323 324 INTERLEAVED_RGB_FMT(XRGB1555, 325 BPC1A, BPC5, BPC5, BPC5, 326 C1_B_Cb, C0_G_Y, C2_R_Cr, C3_ALPHA, 4, 327 false, 2, 0, 328 MDP_FETCH_LINEAR, 1), 329 330 INTERLEAVED_RGB_FMT(XBGR1555, 331 BPC1A, BPC5, BPC5, BPC5, 332 C2_R_Cr, C0_G_Y, C1_B_Cb, C3_ALPHA, 4, 333 false, 2, 0, 334 MDP_FETCH_LINEAR, 1), 335 336 INTERLEAVED_RGB_FMT(RGBX5551, 337 BPC1A, BPC5, BPC5, BPC5, 338 C3_ALPHA, C1_B_Cb, C0_G_Y, C2_R_Cr, 4, 339 false, 2, 0, 340 MDP_FETCH_LINEAR, 1), 341 342 INTERLEAVED_RGB_FMT(BGRX5551, 343 BPC1A, BPC5, BPC5, BPC5, 344 C3_ALPHA, C2_R_Cr, C0_G_Y, C1_B_Cb, 4, 345 false, 2, 0, 346 MDP_FETCH_LINEAR, 1), 347 348 INTERLEAVED_RGB_FMT(ARGB4444, 349 BPC4A, BPC4, BPC4, BPC4, 350 C1_B_Cb, C0_G_Y, C2_R_Cr, C3_ALPHA, 4, 351 true, 2, 0, 352 MDP_FETCH_LINEAR, 1), 353 354 INTERLEAVED_RGB_FMT(ABGR4444, 355 BPC4A, BPC4, BPC4, BPC4, 356 C2_R_Cr, C0_G_Y, C1_B_Cb, C3_ALPHA, 4, 357 true, 2, 0, 358 MDP_FETCH_LINEAR, 1), 359 360 INTERLEAVED_RGB_FMT(RGBA4444, 361 BPC4A, BPC4, BPC4, BPC4, 362 C3_ALPHA, C1_B_Cb, C0_G_Y, C2_R_Cr, 4, 363 true, 2, 0, 364 MDP_FETCH_LINEAR, 1), 365 366 INTERLEAVED_RGB_FMT(BGRA4444, 367 BPC4A, BPC4, BPC4, BPC4, 368 C3_ALPHA, C2_R_Cr, C0_G_Y, C1_B_Cb, 4, 369 true, 2, 0, 370 MDP_FETCH_LINEAR, 1), 371 372 INTERLEAVED_RGB_FMT(XRGB4444, 373 BPC4A, BPC4, BPC4, BPC4, 374 C1_B_Cb, C0_G_Y, C2_R_Cr, C3_ALPHA, 4, 375 false, 2, 0, 376 MDP_FETCH_LINEAR, 1), 377 378 INTERLEAVED_RGB_FMT(XBGR4444, 379 BPC4A, BPC4, BPC4, BPC4, 380 C2_R_Cr, C0_G_Y, C1_B_Cb, C3_ALPHA, 4, 381 false, 2, 0, 382 MDP_FETCH_LINEAR, 1), 383 384 INTERLEAVED_RGB_FMT(RGBX4444, 385 BPC4A, BPC4, BPC4, BPC4, 386 C3_ALPHA, C1_B_Cb, C0_G_Y, C2_R_Cr, 4, 387 false, 2, 0, 388 MDP_FETCH_LINEAR, 1), 389 390 INTERLEAVED_RGB_FMT(BGRX4444, 391 BPC4A, BPC4, BPC4, BPC4, 392 C3_ALPHA, C2_R_Cr, C0_G_Y, C1_B_Cb, 4, 393 false, 2, 0, 394 MDP_FETCH_LINEAR, 1), 395 396 INTERLEAVED_RGB_FMT(BGRA1010102, 397 BPC8A, BPC8, BPC8, BPC8, 398 C3_ALPHA, C2_R_Cr, C0_G_Y, C1_B_Cb, 4, 399 true, 4, MSM_FORMAT_FLAG_DX, 400 MDP_FETCH_LINEAR, 1), 401 402 INTERLEAVED_RGB_FMT(RGBA1010102, 403 BPC8A, BPC8, BPC8, BPC8, 404 C3_ALPHA, C1_B_Cb, C0_G_Y, C2_R_Cr, 4, 405 true, 4, MSM_FORMAT_FLAG_DX, 406 MDP_FETCH_LINEAR, 1), 407 408 INTERLEAVED_RGB_FMT(ABGR2101010, 409 BPC8A, BPC8, BPC8, BPC8, 410 C2_R_Cr, C0_G_Y, C1_B_Cb, C3_ALPHA, 4, 411 true, 4, MSM_FORMAT_FLAG_DX, 412 MDP_FETCH_LINEAR, 1), 413 414 INTERLEAVED_RGB_FMT(ARGB2101010, 415 BPC8A, BPC8, BPC8, BPC8, 416 C1_B_Cb, C0_G_Y, C2_R_Cr, C3_ALPHA, 4, 417 true, 4, MSM_FORMAT_FLAG_DX, 418 MDP_FETCH_LINEAR, 1), 419 420 INTERLEAVED_RGB_FMT(XRGB2101010, 421 BPC8A, BPC8, BPC8, BPC8, 422 C1_B_Cb, C0_G_Y, C2_R_Cr, C3_ALPHA, 4, 423 false, 4, MSM_FORMAT_FLAG_DX, 424 MDP_FETCH_LINEAR, 1), 425 426 INTERLEAVED_RGB_FMT(BGRX1010102, 427 BPC8A, BPC8, BPC8, BPC8, 428 C3_ALPHA, C2_R_Cr, C0_G_Y, C1_B_Cb, 4, 429 false, 4, MSM_FORMAT_FLAG_DX, 430 MDP_FETCH_LINEAR, 1), 431 432 INTERLEAVED_RGB_FMT(XBGR2101010, 433 BPC8A, BPC8, BPC8, BPC8, 434 C2_R_Cr, C0_G_Y, C1_B_Cb, C3_ALPHA, 4, 435 false, 4, MSM_FORMAT_FLAG_DX, 436 MDP_FETCH_LINEAR, 1), 437 438 INTERLEAVED_RGB_FMT(RGBX1010102, 439 BPC8A, BPC8, BPC8, BPC8, 440 C3_ALPHA, C1_B_Cb, C0_G_Y, C2_R_Cr, 4, 441 false, 4, MSM_FORMAT_FLAG_DX, 442 MDP_FETCH_LINEAR, 1), 443 444 /* --- RGB formats above / YUV formats below this line --- */ 445 446 /* 2 plane YUV */ 447 PSEUDO_YUV_FMT(NV12, 448 0, BPC8, BPC8, BPC8, 449 C1_B_Cb, C2_R_Cr, 450 CHROMA_420, MSM_FORMAT_FLAG_YUV, 451 MDP_FETCH_LINEAR, 2), 452 453 PSEUDO_YUV_FMT(NV21, 454 0, BPC8, BPC8, BPC8, 455 C2_R_Cr, C1_B_Cb, 456 CHROMA_420, MSM_FORMAT_FLAG_YUV, 457 MDP_FETCH_LINEAR, 2), 458 459 PSEUDO_YUV_FMT(NV16, 460 0, BPC8, BPC8, BPC8, 461 C1_B_Cb, C2_R_Cr, 462 CHROMA_H2V1, MSM_FORMAT_FLAG_YUV, 463 MDP_FETCH_LINEAR, 2), 464 465 PSEUDO_YUV_FMT(NV61, 466 0, BPC8, BPC8, BPC8, 467 C2_R_Cr, C1_B_Cb, 468 CHROMA_H2V1, MSM_FORMAT_FLAG_YUV, 469 MDP_FETCH_LINEAR, 2), 470 471 PSEUDO_YUV_FMT_LOOSE(P010, 472 0, BPC8, BPC8, BPC8, 473 C1_B_Cb, C2_R_Cr, 474 CHROMA_420, MSM_FORMAT_FLAG_DX | MSM_FORMAT_FLAG_YUV, 475 MDP_FETCH_LINEAR, 2), 476 477 /* 1 plane YUV */ 478 INTERLEAVED_YUV_FMT(VYUY, 479 0, BPC8, BPC8, BPC8, 480 C2_R_Cr, C0_G_Y, C1_B_Cb, C0_G_Y, 481 false, CHROMA_H2V1, 4, 2, MSM_FORMAT_FLAG_YUV, 482 MDP_FETCH_LINEAR, 2), 483 484 INTERLEAVED_YUV_FMT(UYVY, 485 0, BPC8, BPC8, BPC8, 486 C1_B_Cb, C0_G_Y, C2_R_Cr, C0_G_Y, 487 false, CHROMA_H2V1, 4, 2, MSM_FORMAT_FLAG_YUV, 488 MDP_FETCH_LINEAR, 2), 489 490 INTERLEAVED_YUV_FMT(YUYV, 491 0, BPC8, BPC8, BPC8, 492 C0_G_Y, C1_B_Cb, C0_G_Y, C2_R_Cr, 493 false, CHROMA_H2V1, 4, 2, MSM_FORMAT_FLAG_YUV, 494 MDP_FETCH_LINEAR, 2), 495 496 INTERLEAVED_YUV_FMT(YVYU, 497 0, BPC8, BPC8, BPC8, 498 C0_G_Y, C2_R_Cr, C0_G_Y, C1_B_Cb, 499 false, CHROMA_H2V1, 4, 2, MSM_FORMAT_FLAG_YUV, 500 MDP_FETCH_LINEAR, 2), 501 502 /* 3 plane YUV */ 503 PLANAR_YUV_FMT(YUV420, 504 0, BPC8, BPC8, BPC8, 505 C2_R_Cr, C1_B_Cb, C0_G_Y, 506 false, CHROMA_420, 1, MSM_FORMAT_FLAG_YUV, 507 MDP_FETCH_LINEAR, 3), 508 509 PLANAR_YUV_FMT(YVU420, 510 0, BPC8, BPC8, BPC8, 511 C1_B_Cb, C2_R_Cr, C0_G_Y, 512 false, CHROMA_420, 1, MSM_FORMAT_FLAG_YUV, 513 MDP_FETCH_LINEAR, 3), 514 }; 515 516 /* 517 * UBWC formats table: 518 * This table holds the UBWC formats supported. 519 * If a compression ratio needs to be used for this or any other format, 520 * the data will be passed by user-space. 521 */ 522 static const struct msm_format mdp_formats_ubwc[] = { 523 INTERLEAVED_RGB_FMT_TILED(BGR565, 524 0, BPC5, BPC6, BPC5, 525 C2_R_Cr, C0_G_Y, C1_B_Cb, 0, 3, 526 false, 2, MSM_FORMAT_FLAG_COMPRESSED, 527 MDP_FETCH_UBWC, 2, MDP_TILE_HEIGHT_UBWC), 528 529 INTERLEAVED_RGB_FMT_TILED(ABGR8888, 530 BPC8A, BPC8, BPC8, BPC8, 531 C2_R_Cr, C0_G_Y, C1_B_Cb, C3_ALPHA, 4, 532 true, 4, MSM_FORMAT_FLAG_COMPRESSED, 533 MDP_FETCH_UBWC, 2, MDP_TILE_HEIGHT_UBWC), 534 535 /* ARGB8888 and ABGR8888 purposely have the same color 536 * ordering. The hardware only supports ABGR8888 UBWC 537 * natively. 538 */ 539 INTERLEAVED_RGB_FMT_TILED(ARGB8888, 540 BPC8A, BPC8, BPC8, BPC8, 541 C2_R_Cr, C0_G_Y, C1_B_Cb, C3_ALPHA, 4, 542 true, 4, MSM_FORMAT_FLAG_COMPRESSED, 543 MDP_FETCH_UBWC, 2, MDP_TILE_HEIGHT_UBWC), 544 545 INTERLEAVED_RGB_FMT_TILED(XBGR8888, 546 BPC8A, BPC8, BPC8, BPC8, 547 C2_R_Cr, C0_G_Y, C1_B_Cb, C3_ALPHA, 4, 548 false, 4, MSM_FORMAT_FLAG_COMPRESSED, 549 MDP_FETCH_UBWC, 2, MDP_TILE_HEIGHT_UBWC), 550 551 INTERLEAVED_RGB_FMT_TILED(XRGB8888, 552 BPC8A, BPC8, BPC8, BPC8, 553 C2_R_Cr, C0_G_Y, C1_B_Cb, C3_ALPHA, 4, 554 false, 4, MSM_FORMAT_FLAG_COMPRESSED, 555 MDP_FETCH_UBWC, 2, MDP_TILE_HEIGHT_UBWC), 556 557 INTERLEAVED_RGB_FMT_TILED(ABGR2101010, 558 BPC8A, BPC8, BPC8, BPC8, 559 C2_R_Cr, C0_G_Y, C1_B_Cb, C3_ALPHA, 4, 560 true, 4, MSM_FORMAT_FLAG_DX | MSM_FORMAT_FLAG_COMPRESSED, 561 MDP_FETCH_UBWC, 2, MDP_TILE_HEIGHT_UBWC), 562 563 INTERLEAVED_RGB_FMT_TILED(XBGR2101010, 564 BPC8A, BPC8, BPC8, BPC8, 565 C2_R_Cr, C0_G_Y, C1_B_Cb, C3_ALPHA, 4, 566 true, 4, MSM_FORMAT_FLAG_DX | MSM_FORMAT_FLAG_COMPRESSED, 567 MDP_FETCH_UBWC, 2, MDP_TILE_HEIGHT_UBWC), 568 569 INTERLEAVED_RGB_FMT_TILED(XRGB2101010, 570 BPC8A, BPC8, BPC8, BPC8, 571 C2_R_Cr, C0_G_Y, C1_B_Cb, C3_ALPHA, 4, 572 true, 4, MSM_FORMAT_FLAG_DX | MSM_FORMAT_FLAG_COMPRESSED, 573 MDP_FETCH_UBWC, 2, MDP_TILE_HEIGHT_UBWC), 574 575 /* XRGB2101010 and ARGB2101010 purposely have the same color 576 * ordering. The hardware only supports ARGB2101010 UBWC 577 * natively. 578 */ 579 INTERLEAVED_RGB_FMT_TILED(ARGB2101010, 580 BPC8A, BPC8, BPC8, BPC8, 581 C2_R_Cr, C0_G_Y, C1_B_Cb, C3_ALPHA, 4, 582 true, 4, MSM_FORMAT_FLAG_DX | MSM_FORMAT_FLAG_COMPRESSED, 583 MDP_FETCH_UBWC, 2, MDP_TILE_HEIGHT_UBWC), 584 585 PSEUDO_YUV_FMT_TILED(NV12, 586 0, BPC8, BPC8, BPC8, 587 C1_B_Cb, C2_R_Cr, 588 CHROMA_420, MSM_FORMAT_FLAG_YUV | 589 MSM_FORMAT_FLAG_COMPRESSED, 590 MDP_FETCH_UBWC, 4, MDP_TILE_HEIGHT_NV12), 591 592 PSEUDO_YUV_FMT_TILED(P010, 593 0, BPC8, BPC8, BPC8, 594 C1_B_Cb, C2_R_Cr, 595 CHROMA_420, MSM_FORMAT_FLAG_DX | 596 MSM_FORMAT_FLAG_YUV | 597 MSM_FORMAT_FLAG_COMPRESSED, 598 MDP_FETCH_UBWC, 4, MDP_TILE_HEIGHT_UBWC), 599 }; 600 601 const struct msm_format *mdp_get_format(struct msm_kms *kms, uint32_t format, 602 uint64_t modifier) 603 { 604 const struct msm_format *map = NULL; 605 ssize_t map_size; 606 int i; 607 608 switch (modifier) { 609 case 0: 610 map = mdp_formats; 611 map_size = ARRAY_SIZE(mdp_formats); 612 break; 613 case DRM_FORMAT_MOD_QCOM_COMPRESSED: 614 map = mdp_formats_ubwc; 615 map_size = ARRAY_SIZE(mdp_formats_ubwc); 616 break; 617 default: 618 drm_err(kms->dev, "unsupported format modifier %llX\n", modifier); 619 return NULL; 620 } 621 622 for (i = 0; i < map_size; i++) { 623 const struct msm_format *f = &map[i]; 624 625 if (f->pixel_format == format) 626 return f; 627 } 628 629 drm_err(kms->dev, "unsupported fmt: %p4cc modifier 0x%llX\n", 630 &format, modifier); 631 632 return NULL; 633 } 634 635 struct csc_cfg *mdp_get_default_csc_cfg(enum csc_type type) 636 { 637 if (WARN_ON(type >= CSC_MAX)) 638 return NULL; 639 640 return &csc_convert[type]; 641 } 642