Skip to content

Commit 966c5de

Browse files
committed
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 <[email protected]> Signed-off-by: Dmitry Baryshkov <[email protected]> Patchwork: https://patchwork.freedesktop.org/patch/590421/ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Baryshkov <[email protected]>
1 parent 7898814 commit 966c5de

File tree

4 files changed

+80
-42
lines changed

4 files changed

+80
-42
lines changed

drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,47 @@ static const uint64_t supported_format_modifiers[] = {
371371
DRM_FORMAT_MOD_INVALID
372372
};
373373

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+
374415
/* initialize plane */
375416
struct drm_plane *mdp4_plane_init(struct drm_device *dev,
376417
enum mdp4_pipe pipe_id, bool private_plane)
@@ -379,6 +420,8 @@ struct drm_plane *mdp4_plane_init(struct drm_device *dev,
379420
struct mdp4_plane *mdp4_plane;
380421
int ret;
381422
enum drm_plane_type type;
423+
const uint32_t *formats;
424+
unsigned int nformats;
382425

383426
mdp4_plane = kzalloc(sizeof(*mdp4_plane), GFP_KERNEL);
384427
if (!mdp4_plane) {
@@ -392,13 +435,17 @@ struct drm_plane *mdp4_plane_init(struct drm_device *dev,
392435
mdp4_plane->name = pipe_names[pipe_id];
393436
mdp4_plane->caps = mdp4_pipe_caps(pipe_id);
394437

395-
mdp4_plane->nformats = mdp_get_formats(mdp4_plane->formats,
396-
ARRAY_SIZE(mdp4_plane->formats),
397-
!pipe_supports_yuv(mdp4_plane->caps));
398-
399438
type = private_plane ? DRM_PLANE_TYPE_PRIMARY : DRM_PLANE_TYPE_OVERLAY;
439+
440+
if (pipe_supports_yuv(mdp4_plane->caps)) {
441+
formats = mdp4_rgb_yuv_formats;
442+
nformats = ARRAY_SIZE(mdp4_rgb_yuv_formats);
443+
} else {
444+
formats = mdp4_rgb_formats;
445+
nformats = ARRAY_SIZE(mdp4_rgb_formats);
446+
}
400447
ret = drm_universal_plane_init(dev, plane, 0xff, &mdp4_plane_funcs,
401-
mdp4_plane->formats, mdp4_plane->nformats,
448+
formats, nformats,
402449
supported_format_modifiers, type, NULL);
403450
if (ret)
404451
goto fail;

drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717

1818
struct mdp5_plane {
1919
struct drm_plane base;
20-
21-
uint32_t nformats;
22-
uint32_t formats[32];
2320
};
2421
#define to_mdp5_plane(x) container_of(x, struct mdp5_plane, base)
2522

@@ -1007,6 +1004,32 @@ uint32_t mdp5_plane_get_flush(struct drm_plane *plane)
10071004
return mask;
10081005
}
10091006

1007+
static const uint32_t mdp5_plane_formats[] = {
1008+
DRM_FORMAT_ARGB8888,
1009+
DRM_FORMAT_ABGR8888,
1010+
DRM_FORMAT_RGBA8888,
1011+
DRM_FORMAT_BGRA8888,
1012+
DRM_FORMAT_XRGB8888,
1013+
DRM_FORMAT_XBGR8888,
1014+
DRM_FORMAT_RGBX8888,
1015+
DRM_FORMAT_BGRX8888,
1016+
DRM_FORMAT_RGB888,
1017+
DRM_FORMAT_BGR888,
1018+
DRM_FORMAT_RGB565,
1019+
DRM_FORMAT_BGR565,
1020+
1021+
DRM_FORMAT_NV12,
1022+
DRM_FORMAT_NV21,
1023+
DRM_FORMAT_NV16,
1024+
DRM_FORMAT_NV61,
1025+
DRM_FORMAT_VYUY,
1026+
DRM_FORMAT_UYVY,
1027+
DRM_FORMAT_YUYV,
1028+
DRM_FORMAT_YVYU,
1029+
DRM_FORMAT_YUV420,
1030+
DRM_FORMAT_YVU420,
1031+
};
1032+
10101033
/* initialize plane */
10111034
struct drm_plane *mdp5_plane_init(struct drm_device *dev,
10121035
enum drm_plane_type type)
@@ -1023,12 +1046,9 @@ struct drm_plane *mdp5_plane_init(struct drm_device *dev,
10231046

10241047
plane = &mdp5_plane->base;
10251048

1026-
mdp5_plane->nformats = mdp_get_formats(mdp5_plane->formats,
1027-
ARRAY_SIZE(mdp5_plane->formats), false);
1028-
10291049
ret = drm_universal_plane_init(dev, plane, 0xff, &mdp5_plane_funcs,
1030-
mdp5_plane->formats, mdp5_plane->nformats,
1031-
NULL, type, NULL);
1050+
mdp5_plane_formats, ARRAY_SIZE(mdp5_plane_formats),
1051+
NULL, type, NULL);
10321052
if (ret)
10331053
goto fail;
10341054

drivers/gpu/drm/msm/disp/mdp_format.c

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,6 @@ static struct csc_cfg csc_convert[CSC_MAX] = {
8080

8181
#define BPC0A 0
8282

83-
/*
84-
* Note: Keep RGB formats 1st, followed by YUV formats to avoid breaking
85-
* mdp_get_rgb_formats()'s implementation.
86-
*/
8783
static const struct mdp_format formats[] = {
8884
/* name a r g b e0 e1 e2 e3 alpha tight cpp cnt ... */
8985
FMT(ARGB8888, 8, 8, 8, 8, 1, 0, 2, 3, true, true, 4, 4,
@@ -138,30 +134,6 @@ static const struct mdp_format formats[] = {
138134
MDP_PLANE_PLANAR, CHROMA_420, true),
139135
};
140136

141-
/*
142-
* Note:
143-
* @rgb_only must be set to true, when requesting
144-
* supported formats for RGB pipes.
145-
*/
146-
uint32_t mdp_get_formats(uint32_t *pixel_formats, uint32_t max_formats,
147-
bool rgb_only)
148-
{
149-
uint32_t i;
150-
for (i = 0; i < ARRAY_SIZE(formats); i++) {
151-
const struct mdp_format *f = &formats[i];
152-
153-
if (i == max_formats)
154-
break;
155-
156-
if (rgb_only && MDP_FORMAT_IS_YUV(f))
157-
break;
158-
159-
pixel_formats[i] = f->base.pixel_format;
160-
}
161-
162-
return i;
163-
}
164-
165137
const struct msm_format *mdp_get_format(struct msm_kms *kms, uint32_t format,
166138
uint64_t modifier)
167139
{

drivers/gpu/drm/msm/disp/mdp_kms.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ struct mdp_format {
9191
#define to_mdp_format(x) container_of(x, struct mdp_format, base)
9292
#define MDP_FORMAT_IS_YUV(mdp_format) ((mdp_format)->is_yuv)
9393

94-
uint32_t mdp_get_formats(uint32_t *formats, uint32_t max_formats, bool rgb_only);
9594
const struct msm_format *mdp_get_format(struct msm_kms *kms, uint32_t format, uint64_t modifier);
9695

9796
/* MDP capabilities */

0 commit comments

Comments
 (0)