[PATCH 2/2] drm: mxsfb: Add RGB888 support on the primary plane

Laurent Pinchart laurent.pinchart at ideasonboard.com
Mon Oct 12 23:28:40 UTC 2020


The primary plane can support the packed 24-bit RGB888 format. Enable
it.

Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
 drivers/gpu/drm/mxsfb/mxsfb_drv.c | 5 +++++
 drivers/gpu/drm/mxsfb/mxsfb_kms.c | 7 +++++++
 2 files changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
index d52cf8a506a5..5ec10f0f6508 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
@@ -97,6 +97,11 @@ mxsfb_fb_create(struct drm_device *dev, struct drm_file *file_priv,
 		return ERR_PTR(-EINVAL);
 	}
 
+	if (info->cpp[0] == 3 && mode_cmd->width % 4) {
+		dev_dbg(dev->dev, "24-bit RGB format requires a width aligned to 4\n");
+		return ERR_PTR(-EINVAL);
+	}
+
 	return drm_gem_fb_create(dev, file_priv, mode_cmd);
 }
 
diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
index 7a69d9f3a875..7a0d6bc58be0 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
@@ -75,6 +75,12 @@ static void mxsfb_set_formats(struct mxsfb_drm_private *mxsfb)
 		ctrl |= CTRL_WORD_LENGTH_16;
 		ctrl1 |= CTRL1_SET_BYTE_PACKAGING(0xf);
 		break;
+	case DRM_FORMAT_RGB888:
+		dev_dbg(drm->dev, "Setting up RGB888 mode\n");
+		ctrl |= CTRL_WORD_LENGTH_24;
+		/* Enable pixel packing, 4 pixels in 3 bytes. */
+		ctrl1 |= CTRL1_SET_BYTE_PACKAGING(0xf);
+		break;
 	case DRM_FORMAT_XRGB8888:
 		dev_dbg(drm->dev, "Setting up XRGB8888 mode\n");
 		ctrl |= CTRL_WORD_LENGTH_24;
@@ -523,6 +529,7 @@ static const struct drm_plane_funcs mxsfb_plane_funcs = {
 
 static const uint32_t mxsfb_primary_plane_formats[] = {
 	DRM_FORMAT_RGB565,
+	DRM_FORMAT_RGB888,
 	DRM_FORMAT_XRGB8888,
 };
 
-- 
Regards,

Laurent Pinchart



More information about the dri-devel mailing list