Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/msm: add arrays listing formats supported by MDP4/MDP5 hardware

MDP4 and MDP5 drivers enumerate supported formats each time the plane is
created. In preparation to merger of MDP DPU format databases, define
precise formats list, so that changes to the database do not cause the
driver to add unsupported format to the list.

Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Patchwork: https://patchwork.freedesktop.org/patch/590421/
Link: https://lore.kernel.org/r/20240420-dpu-format-v2-2-9e93226cbffd@linaro.org
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

+80 -42
+52 -5
drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c
··· 371 371 DRM_FORMAT_MOD_INVALID 372 372 }; 373 373 374 + static const uint32_t mdp4_rgb_formats[] = { 375 + DRM_FORMAT_ARGB8888, 376 + DRM_FORMAT_ABGR8888, 377 + DRM_FORMAT_RGBA8888, 378 + DRM_FORMAT_BGRA8888, 379 + DRM_FORMAT_XRGB8888, 380 + DRM_FORMAT_XBGR8888, 381 + DRM_FORMAT_RGBX8888, 382 + DRM_FORMAT_BGRX8888, 383 + DRM_FORMAT_RGB888, 384 + DRM_FORMAT_BGR888, 385 + DRM_FORMAT_RGB565, 386 + DRM_FORMAT_BGR565, 387 + }; 388 + 389 + static const uint32_t mdp4_rgb_yuv_formats[] = { 390 + DRM_FORMAT_ARGB8888, 391 + DRM_FORMAT_ABGR8888, 392 + DRM_FORMAT_RGBA8888, 393 + DRM_FORMAT_BGRA8888, 394 + DRM_FORMAT_XRGB8888, 395 + DRM_FORMAT_XBGR8888, 396 + DRM_FORMAT_RGBX8888, 397 + DRM_FORMAT_BGRX8888, 398 + DRM_FORMAT_RGB888, 399 + DRM_FORMAT_BGR888, 400 + DRM_FORMAT_RGB565, 401 + DRM_FORMAT_BGR565, 402 + 403 + DRM_FORMAT_NV12, 404 + DRM_FORMAT_NV21, 405 + DRM_FORMAT_NV16, 406 + DRM_FORMAT_NV61, 407 + DRM_FORMAT_VYUY, 408 + DRM_FORMAT_UYVY, 409 + DRM_FORMAT_YUYV, 410 + DRM_FORMAT_YVYU, 411 + DRM_FORMAT_YUV420, 412 + DRM_FORMAT_YVU420, 413 + }; 414 + 374 415 /* initialize plane */ 375 416 struct drm_plane *mdp4_plane_init(struct drm_device *dev, 376 417 enum mdp4_pipe pipe_id, bool private_plane) ··· 420 379 struct mdp4_plane *mdp4_plane; 421 380 int ret; 422 381 enum drm_plane_type type; 382 + const uint32_t *formats; 383 + unsigned int nformats; 423 384 424 385 mdp4_plane = kzalloc(sizeof(*mdp4_plane), GFP_KERNEL); 425 386 if (!mdp4_plane) { ··· 435 392 mdp4_plane->name = pipe_names[pipe_id]; 436 393 mdp4_plane->caps = mdp4_pipe_caps(pipe_id); 437 394 438 - mdp4_plane->nformats = mdp_get_formats(mdp4_plane->formats, 439 - ARRAY_SIZE(mdp4_plane->formats), 440 - !pipe_supports_yuv(mdp4_plane->caps)); 441 - 442 395 type = private_plane ? DRM_PLANE_TYPE_PRIMARY : DRM_PLANE_TYPE_OVERLAY; 396 + 397 + if (pipe_supports_yuv(mdp4_plane->caps)) { 398 + formats = mdp4_rgb_yuv_formats; 399 + nformats = ARRAY_SIZE(mdp4_rgb_yuv_formats); 400 + } else { 401 + formats = mdp4_rgb_formats; 402 + nformats = ARRAY_SIZE(mdp4_rgb_formats); 403 + } 443 404 ret = drm_universal_plane_init(dev, plane, 0xff, &mdp4_plane_funcs, 444 - mdp4_plane->formats, mdp4_plane->nformats, 405 + formats, nformats, 445 406 supported_format_modifiers, type, NULL); 446 407 if (ret) 447 408 goto fail;
+28 -8
drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
··· 17 17 18 18 struct mdp5_plane { 19 19 struct drm_plane base; 20 - 21 - uint32_t nformats; 22 - uint32_t formats[32]; 23 20 }; 24 21 #define to_mdp5_plane(x) container_of(x, struct mdp5_plane, base) 25 22 ··· 1004 1007 return mask; 1005 1008 } 1006 1009 1010 + static const uint32_t mdp5_plane_formats[] = { 1011 + DRM_FORMAT_ARGB8888, 1012 + DRM_FORMAT_ABGR8888, 1013 + DRM_FORMAT_RGBA8888, 1014 + DRM_FORMAT_BGRA8888, 1015 + DRM_FORMAT_XRGB8888, 1016 + DRM_FORMAT_XBGR8888, 1017 + DRM_FORMAT_RGBX8888, 1018 + DRM_FORMAT_BGRX8888, 1019 + DRM_FORMAT_RGB888, 1020 + DRM_FORMAT_BGR888, 1021 + DRM_FORMAT_RGB565, 1022 + DRM_FORMAT_BGR565, 1023 + 1024 + DRM_FORMAT_NV12, 1025 + DRM_FORMAT_NV21, 1026 + DRM_FORMAT_NV16, 1027 + DRM_FORMAT_NV61, 1028 + DRM_FORMAT_VYUY, 1029 + DRM_FORMAT_UYVY, 1030 + DRM_FORMAT_YUYV, 1031 + DRM_FORMAT_YVYU, 1032 + DRM_FORMAT_YUV420, 1033 + DRM_FORMAT_YVU420, 1034 + }; 1035 + 1007 1036 /* initialize plane */ 1008 1037 struct drm_plane *mdp5_plane_init(struct drm_device *dev, 1009 1038 enum drm_plane_type type) ··· 1046 1023 1047 1024 plane = &mdp5_plane->base; 1048 1025 1049 - mdp5_plane->nformats = mdp_get_formats(mdp5_plane->formats, 1050 - ARRAY_SIZE(mdp5_plane->formats), false); 1051 - 1052 1026 ret = drm_universal_plane_init(dev, plane, 0xff, &mdp5_plane_funcs, 1053 - mdp5_plane->formats, mdp5_plane->nformats, 1054 - NULL, type, NULL); 1027 + mdp5_plane_formats, ARRAY_SIZE(mdp5_plane_formats), 1028 + NULL, type, NULL); 1055 1029 if (ret) 1056 1030 goto fail; 1057 1031
-28
drivers/gpu/drm/msm/disp/mdp_format.c
··· 80 80 81 81 #define BPC0A 0 82 82 83 - /* 84 - * Note: Keep RGB formats 1st, followed by YUV formats to avoid breaking 85 - * mdp_get_rgb_formats()'s implementation. 86 - */ 87 83 static const struct mdp_format formats[] = { 88 84 /* name a r g b e0 e1 e2 e3 alpha tight cpp cnt ... */ 89 85 FMT(ARGB8888, 8, 8, 8, 8, 1, 0, 2, 3, true, true, 4, 4, ··· 133 137 FMT(YVU420, 0, 8, 8, 8, 1, 2, 0, 0, false, true, 1, 1, 134 138 MDP_PLANE_PLANAR, CHROMA_420, true), 135 139 }; 136 - 137 - /* 138 - * Note: 139 - * @rgb_only must be set to true, when requesting 140 - * supported formats for RGB pipes. 141 - */ 142 - uint32_t mdp_get_formats(uint32_t *pixel_formats, uint32_t max_formats, 143 - bool rgb_only) 144 - { 145 - uint32_t i; 146 - for (i = 0; i < ARRAY_SIZE(formats); i++) { 147 - const struct mdp_format *f = &formats[i]; 148 - 149 - if (i == max_formats) 150 - break; 151 - 152 - if (rgb_only && MDP_FORMAT_IS_YUV(f)) 153 - break; 154 - 155 - pixel_formats[i] = f->base.pixel_format; 156 - } 157 - 158 - return i; 159 - } 160 140 161 141 const struct msm_format *mdp_get_format(struct msm_kms *kms, uint32_t format, 162 142 uint64_t modifier)
-1
drivers/gpu/drm/msm/disp/mdp_kms.h
··· 91 91 #define to_mdp_format(x) container_of(x, struct mdp_format, base) 92 92 #define MDP_FORMAT_IS_YUV(mdp_format) ((mdp_format)->is_yuv) 93 93 94 - uint32_t mdp_get_formats(uint32_t *formats, uint32_t max_formats, bool rgb_only); 95 94 const struct msm_format *mdp_get_format(struct msm_kms *kms, uint32_t format, uint64_t modifier); 96 95 97 96 /* MDP capabilities */