[PATCH 2/3] drm/mxsfb: implement interface-pix-fmt of_property to override bus format

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This way hardware that has the LCD signal lines swapped can express
so in the device tree and existing panel support can be reused
unmodified.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 drivers/gpu/drm/mxsfb/mxsfb_crtc.c |  4 +++-
 drivers/gpu/drm/mxsfb/mxsfb_drv.c  | 13 +++++++++++++
 drivers/gpu/drm/mxsfb/mxsfb_drv.h  |  1 +
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_crtc.c b/drivers/gpu/drm/mxsfb/mxsfb_crtc.c
index 1b5b1fddd691..0de48384054d 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_crtc.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_crtc.c
@@ -101,7 +101,9 @@ static void mxsfb_set_bus_fmt(struct mxsfb_drm_private *mxsfb)
 
 	ctrl = readl(mxsfb->base + LCDC_CTRL);
 
-	if (mxsfb->connector.display_info.num_bus_formats)
+	if (mxsfb->bus_format_override)
+		bus_format = mxsfb->bus_format_override;
+	else if (mxsfb->connector.display_info.num_bus_formats)
 		bus_format = mxsfb->connector.display_info.bus_formats[0];
 
 	ctrl &= ~CTRL_BUS_WIDTH_MASK;
diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
index 2393e6d16ffd..169b458691e4 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
@@ -182,6 +182,7 @@ static int mxsfb_load(struct drm_device *drm, unsigned long flags)
 	struct platform_device *pdev = to_platform_device(drm->dev);
 	struct mxsfb_drm_private *mxsfb;
 	struct resource *res;
+	const char *fmt;
 	int ret;
 
 	mxsfb = devm_kzalloc(&pdev->dev, sizeof(*mxsfb), GFP_KERNEL);
@@ -208,6 +209,18 @@ static int mxsfb_load(struct drm_device *drm, unsigned long flags)
 	if (IS_ERR(mxsfb->clk_disp_axi))
 		mxsfb->clk_disp_axi = NULL;
 
+	ret = of_property_read_string(drm->dev->of_node, "interface-pix-fmt", &fmt);
+	if (!ret) {
+		if (!strcmp(fmt, "rgb24"))
+			mxsfb->bus_format_override = MEDIA_BUS_FMT_RGB888_1X24;
+		else if (!strcmp(fmt, "bgr24"))
+			mxsfb->bus_format_override = MEDIA_BUS_FMT_BGR888_1X24;
+		else if (!strcmp(fmt, "rbg24"))
+			mxsfb->bus_format_override = MEDIA_BUS_FMT_RBG888_1X24;
+		else if (!strcmp(fmt, "gbr24"))
+			mxsfb->bus_format_override = MEDIA_BUS_FMT_GBR888_1X24;
+	}
+
 	ret = dma_set_mask_and_coherent(drm->dev, DMA_BIT_MASK(32));
 	if (ret)
 		return ret;
diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.h b/drivers/gpu/drm/mxsfb/mxsfb_drv.h
index 89fa2076acaf..63d30dd4dc36 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_drv.h
+++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.h
@@ -40,6 +40,7 @@ struct mxsfb_drm_private {
 	struct drm_connector		connector;
 	struct drm_panel		*panel;
 	struct drm_fbdev_cma		*fbdev;
+	unsigned int			bus_format_override;
 };
 
 int mxsfb_setup_crtc(struct drm_device *dev);
-- 
2.19.1

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux