diff mbox series

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

Message ID 20201012232840.15680-3-laurent.pinchart@ideasonboard.com (mailing list archive)
State New, archived
Headers show
Series drm: mxsfb: Primary plane format fix and enhancement | expand

Commit Message

Laurent Pinchart Oct. 12, 2020, 11:28 p.m. UTC
The primary plane can support the packed 24-bit RGB888 format. Enable
it.

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

Patch

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,
 };