diff options
author | Oleksandr Suvorov <oleksandr.suvorov@toradex.com> | 2019-07-05 17:02:23 +0300 |
---|---|---|
committer | Oleksandr Suvorov <oleksandr.suvorov@toradex.com> | 2019-07-09 09:57:14 +0300 |
commit | 5854ed397b654f1f430398d346b5c8da864240bd (patch) | |
tree | 22d0390f27eabaf479521f32578344f54d754938 /drivers | |
parent | ffa30ad23d0decb38f974f5be990cc54389c22ec (diff) |
drm/mxsfb: support bus-width property of dt
There could be different implementations of output bus widths
(8, 16, 18, 24 bits). Selecting the correct bus format allows
eLCDIF to translate framebuffer properly.
Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/mxsfb/mxsfb_crtc.c | 8 | ||||
-rw-r--r-- | drivers/gpu/drm/mxsfb/mxsfb_drv.c | 8 | ||||
-rw-r--r-- | drivers/gpu/drm/mxsfb/mxsfb_drv.h | 2 |
3 files changed, 14 insertions, 4 deletions
diff --git a/drivers/gpu/drm/mxsfb/mxsfb_crtc.c b/drivers/gpu/drm/mxsfb/mxsfb_crtc.c index 94a6d16d469c..6c9a5efb3ab8 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_crtc.c +++ b/drivers/gpu/drm/mxsfb/mxsfb_crtc.c @@ -158,9 +158,9 @@ err: return -EINVAL; } -static u32 get_bus_format_from_bpp(u32 bpp) +static u32 get_bus_format_from_width(u32 width) { - switch (bpp) { + switch (width) { case 16: return MEDIA_BUS_FMT_RGB565_1X16; case 18: @@ -177,7 +177,7 @@ static void mxsfb_set_bus_fmt(struct mxsfb_drm_private *mxsfb) struct drm_crtc *crtc = &mxsfb->pipe.crtc; unsigned int bits_per_pixel = crtc->primary->state->fb->format->depth; struct drm_device *drm = crtc->dev; - u32 bus_format = MEDIA_BUS_FMT_RGB888_1X24; + u32 bus_format = get_bus_format_from_width(mxsfb->bus_width); int num_bus_formats = mxsfb->connector->display_info.num_bus_formats; const u32 *bus_formats = mxsfb->connector->display_info.bus_formats; u32 reg = 0; @@ -185,7 +185,7 @@ static void mxsfb_set_bus_fmt(struct mxsfb_drm_private *mxsfb) /* match the user requested bus_format to one supported by the panel */ if (num_bus_formats) { - u32 user_bus_format = get_bus_format_from_bpp(bits_per_pixel); + u32 user_bus_format = get_bus_format_from_width(bits_per_pixel); bus_format = bus_formats[0]; for (i = 0; i < num_bus_formats; i++) { diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c b/drivers/gpu/drm/mxsfb/mxsfb_drv.c index d9801bdcaf40..1a12f5e1bd13 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c @@ -56,6 +56,9 @@ enum mxsfb_devtype { MXSFB_V4, }; +/* default output bus width */ +#define MXSFB_DEFAULT_BUS_WIDTH 24 + /* * When adding new formats, make sure to update the num_formats from * mxsfb_devdata below. @@ -415,6 +418,7 @@ static int mxsfb_load(struct drm_device *drm, unsigned long flags) struct mxsfb_drm_private *mxsfb; struct resource *res; u32 max_res[2] = {0, 0}; + u32 bus_width = MXSFB_DEFAULT_BUS_WIDTH; int ret; mxsfb = devm_kzalloc(&pdev->dev, sizeof(*mxsfb), GFP_KERNEL); @@ -510,6 +514,10 @@ static int mxsfb_load(struct drm_device *drm, unsigned long flags) } } + /* bus width is needed to set up correct bus format */ + of_property_read_u32(drm->dev->of_node, "bus-width", &bus_width); + mxsfb->bus_width = bus_width; + of_property_read_u32_array(drm->dev->of_node, "max-res", &max_res[0], 2); if (!max_res[0]) diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.h b/drivers/gpu/drm/mxsfb/mxsfb_drv.h index 24d573fe5aee..ead101bc4e17 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.h +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.h @@ -56,6 +56,8 @@ struct mxsfb_drm_private { struct drm_bridge *bridge; struct drm_fbdev_cma *fbdev; + u32 bus_width; + struct list_head valid_modes; }; |