@@ -114,10 +114,36 @@ static int mxsfb_attach_bridge(struct mxsfb_drm_private *mxsfb)
{
struct drm_device *drm = mxsfb->drm;
struct drm_connector_list_iter iter;
+ struct device_node *ep;
struct drm_panel *panel;
struct drm_bridge *bridge;
+ u32 bus_width = 0;
int ret;
+ ep = of_graph_get_endpoint_by_regs(drm->dev->of_node, 0, 0);
+ if (!ep)
+ return -ENODEV;
+
+ of_property_read_u32(ep, "bus-width", &bus_width);
+ of_node_put(ep);
+
+ switch (bus_width) {
+ case 16:
+ mxsfb->bus_format = MEDIA_BUS_FMT_RGB565_1X16;
+ break;
+ case 18:
+ mxsfb->bus_format = MEDIA_BUS_FMT_RGB666_1X18;
+ break;
+ case 24:
+ mxsfb->bus_format = MEDIA_BUS_FMT_RGB888_1X24;
+ break;
+ case 0:
+ break;
+ default:
+ DRM_DEV_ERROR(drm->dev, "Invalid bus-width %u", bus_width);
+ return -ENODEV;
+ }
+
ret = drm_of_find_panel_or_bridge(drm->dev->of_node, 0, 0, &panel,
&bridge);
if (ret)
@@ -32,6 +32,8 @@ struct mxsfb_drm_private {
struct clk *clk_axi;
struct clk *clk_disp_axi;
+ u32 bus_format;
+
struct drm_device *drm;
struct {
struct drm_plane primary;
@@ -50,11 +50,15 @@ static void mxsfb_set_formats(struct mxsfb_drm_private *mxsfb)
{
struct drm_device *drm = mxsfb->drm;
const u32 format = mxsfb->crtc.primary->state->fb->format->format;
- u32 bus_format = MEDIA_BUS_FMT_RGB888_1X24;
+ u32 bus_format;
u32 ctrl, ctrl1;
- if (mxsfb->connector->display_info.num_bus_formats)
+ if (mxsfb->bus_format)
+ bus_format = mxsfb->bus_format;
+ else if (mxsfb->connector->display_info.num_bus_formats)
bus_format = mxsfb->connector->display_info.bus_formats[0];
+ else
+ bus_format = MEDIA_BUS_FMT_RGB888_1X24;
DRM_DEV_DEBUG_DRIVER(drm->dev, "Using bus_format: 0x%08X\n",
bus_format);
A new bus-width DT property has been introduced in the bindings to allow overriding the bus width. Support it. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- drivers/gpu/drm/mxsfb/mxsfb_drv.c | 26 ++++++++++++++++++++++++++ drivers/gpu/drm/mxsfb/mxsfb_drv.h | 2 ++ drivers/gpu/drm/mxsfb/mxsfb_kms.c | 8 ++++++-- 3 files changed, 34 insertions(+), 2 deletions(-)