Add support for DRM bridge and additional pixel formats
Subsystems (5)
cover Add support for DRM bridge and additional pixel formats
This patchset improves the use of eLCDIF block on iMX 8 SoCs (like 8MQ, 8MM and 8QXP):
1. Add support for drm_bridge
On 8MQ and 8MM, the LCDIF block is not directly connected to a parallel display connector, where an LCD panel can be attached, but instead it is connected to DSI controller. Since this DSI stands between the display controller (eLCDIF) and the physical connector, the DSI can be implemented as a DRM bridge. So, in order to be able to connect the mxsfb driver to the DSI driver, the support for a drm_bridge was needed in mxsfb DRM driver (the actual driver for the eLCDIF block).
2. Add support for additional pixel formats
Some of the pixel formats needed by Android were not implemented in this driver, but they were actually supported. So, add support for them.
3. Few minor features and bug-fixing
The addition of max-res DT property was actually needed in order to limit the bandwidth usage of the eLCDIF block. This is need on systems where multiple display controllers are presend and the memory bandwidth is not enough to handle all of them at maximum capacity (like it is the case on 8MQ, where there are two display controllers: DCSS and eLCDIF). The rest of the patches are bug-fixes.
Changes since v1:
* Replaced for_each_crtc_in_state (removed since deprecated) with for_each_new_crtc_in_state
* Removed unused MXSFB_FLAG_* flags
* Split the patch for LCD reset and moved the pm_runtime_enable fix into a separate patch
Mirela Rabulea (2):
drm/mxsfb: Add support for new pixel formats in eLCDIF drm/mxsfb: Signal mode changed when bpp changed
Robert Chiras (9):
drm/mxsfb: Update mxsfb to support a bridge
dt-bindings: display: Add max-res property for mxsfb drm/mxsfb: Add max-res property for MXSFB drm/mxsfb: Update mxsfb with additional pixel formats drm/mxsfb: Fix the vblank events
drm/mxsfb: Update mxsfb to support LCD reset drm/mxsfb: Move pm_runtime_enable at the end of probe drm/mxsfb: Improve the axi clock usage drm/mxsfb: Clear OUTSTANDING_REQS bits
.../devicetree/bindings/display/mxsfb.txt | 6 + drivers/gpu/drm/mxsfb/mxsfb_crtc.c | 215 ++++++++++++++++++--- drivers/gpu/drm/mxsfb/mxsfb_drv.c | 183 ++++++++++++++---- drivers/gpu/drm/mxsfb/mxsfb_drv.h | 10 +- drivers/gpu/drm/mxsfb/mxsfb_out.c | 26 +-- drivers/gpu/drm/mxsfb/mxsfb_regs.h | 112 +++++++---- 6 files changed, 429 insertions(+), 123 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/11 drm/mxsfb: Update mxsfb to support a bridge
Currently, the MXSFB DRM driver only supports a panel. But, its output display signal can also be redirected to another encoder, like a DSI controller. In this case, that DSI controller may act like a drm_bridge. In order support this use-case too, this patch adds support for drm_bridge in mxsfb.
--- drivers/gpu/drm/mxsfb/mxsfb_crtc.c | 46 +++++++++++++++++++++++++++++++++++--- drivers/gpu/drm/mxsfb/mxsfb_drv.c | 46 +++++++++++++++++++++++++++++++++----- drivers/gpu/drm/mxsfb/mxsfb_drv.h | 4 +++- drivers/gpu/drm/mxsfb/mxsfb_out.c | 26 +++++++++++---------- drivers/gpu/drm/mxsfb/mxsfb_regs.h | 15 +++++++++++++ 5 files changed, 116 insertions(+), 21 deletions(-)
drivers/gpu/drm/mxsfb/mxsfb_crtc.c +43 -3
@@ -101,8 +101,11 @@ static void mxsfb_set_bus_fmt(struct mxsfb_drm_private *mxsfb) reg =readl (mxsfb->base +LCDC_CTRL ); -if (mxsfb->connector.display_info.num_bus_formats) - bus_format = mxsfb->connector.display_info.bus_formats[0 ]; +if (mxsfb->connector->display_info.num_bus_formats) + bus_format = mxsfb->connector->display_info.bus_formats[0 ]; + +DRM_DEV_DEBUG_DRIVER (drm->dev, +"Using bus_format: 0x%08X\n" , bus_format); reg &= ~CTRL_BUS_WIDTH_MASK ;switch (bus_format) {
@@ -130,6 +133,9 @@ static void mxsfb_enable_controller(struct mxsfb_drm_private *mxsfb)clk_prepare_enable (mxsfb->clk_disp_axi);clk_prepare_enable (mxsfb->clk); +writel (CTRL2_OUTSTANDING_REQS__REQ_16 , + mxsfb->base +LCDC_V4_CTRL2 +REG_SET ); +/* If it was disabled, re-enable the mode again */ writel (CTRL_DOTCLK_MODE , mxsfb->base +LCDC_CTRL +REG_SET );
@@ -139,12 +145,15 @@ static void mxsfb_enable_controller(struct mxsfb_drm_private *mxsfb)writel (reg, mxsfb->base +LCDC_VDCTRL4 );writel (CTRL_RUN , mxsfb->base +LCDC_CTRL +REG_SET ); +writel (CTRL1_RECOVERY_ON_UNDERFLOW , mxsfb->base +LCDC_CTRL1 +REG_SET ); }static void mxsfb_disable_controller (struct mxsfb_drm_private *mxsfb) {u32 reg; +writel (CTRL_RUN , mxsfb->base +LCDC_CTRL +REG_CLR ); +/* * Even if we disable the controller here, it will still continue * until its FIFOs are running out of data
@@ -210,8 +219,9 @@ static dma_addr_t mxsfb_get_fb_paddr(struct mxsfb_drm_private *mxsfb)static void mxsfb_crtc_mode_set_nofb (struct mxsfb_drm_private *mxsfb) { +struct drm_device *drm = mxsfb->pipe.crtc.dev;struct drm_display_mode *m = &mxsfb->pipe.crtc.state->adjusted_mode; -const u32 bus_flags = mxsfb->connector.display_info.bus_flags; +const u32 bus_flags = mxsfb->connector->display_info.bus_flags;u32 vdctrl0, vsync_pulse_len, hsync_pulse_len;int err;
@@ -235,6 +245,13 @@ static void mxsfb_crtc_mode_set_nofb(struct mxsfb_drm_private *mxsfb)clk_set_rate (mxsfb->clk, m->crtc_clock *1000 ); +DRM_DEV_DEBUG_DRIVER (drm->dev,"Pixel clock: %dkHz (actual: %dkHz)\n" , + m->crtc_clock, (int )(clk_get_rate (mxsfb->clk) /1000 )); +DRM_DEV_DEBUG_DRIVER (drm->dev, +"Connector bus_flags: 0x%08X\n" , bus_flags); +DRM_DEV_DEBUG_DRIVER (drm->dev, +"Mode flags: 0x%08X\n" , m->flags); +writel (TRANSFER_COUNT_SET_VCOUNT (m->crtc_vdisplay) |TRANSFER_COUNT_SET_HCOUNT (m->crtc_hdisplay), mxsfb->base + mxsfb->devdata->transfer_count);
@@ -287,6 +304,7 @@ void mxsfb_crtc_enable(struct mxsfb_drm_private *mxsfb)dma_addr_t paddr;mxsfb_enable_axi_clk (mxsfb); +writel (0 , mxsfb->base +LCDC_CTRL );mxsfb_crtc_mode_set_nofb (mxsfb);/* Write cur_buf as well to avoid an initial corrupt frame */
@@ -310,6 +328,8 @@ void mxsfb_plane_atomic_update(struct mxsfb_drm_private *mxsfb, {struct drm_simple_display_pipe *pipe = &mxsfb->pipe;struct drm_crtc *crtc = &pipe->crtc; +struct drm_framebuffer *fb = pipe->plane.state->fb; +struct drm_framebuffer *old_fb = old_state->fb;struct drm_pending_vblank_event *event;dma_addr_t paddr;
@@ -332,4 +352,24 @@ void mxsfb_plane_atomic_update(struct mxsfb_drm_private *mxsfb,writel (paddr, mxsfb->base + mxsfb->devdata->next_buf);mxsfb_disable_axi_clk (mxsfb); } + +if (!fb || !old_fb) +return ; + +/* +* TODO: Currently, we only support pixel format change, but we need +* also to care about size changes too +*/ +if (old_fb->format->format != fb->format->format) { +struct drm_format_name_buf old_fmt_buf; +struct drm_format_name_buf new_fmt_buf; + +DRM_DEV_DEBUG_DRIVER (crtc->dev->dev, +"Switching pixel format: %s -> %s\n" , +drm_get_format_name (old_fb->format->format, + &old_fmt_buf), +drm_get_format_name (fb->format->format, + &new_fmt_buf)); +mxsfb_set_pixel_fmt (mxsfb, true); + } }
drivers/gpu/drm/mxsfb/mxsfb_drv.c +41 -5
72 lines not on this page · raw message
drivers/gpu/drm/mxsfb/mxsfb_drv.h +3 -1
@@ -35,8 +35,10 @@ struct mxsfb_drm_private {struct clk *clk_disp_axi;struct drm_simple_display_pipe pipe; -struct drm_connector connector; +struct drm_connector panel_connector; +struct drm_connector *connector;struct drm_panel *panel; +struct drm_bridge *bridge;struct drm_fbdev_cma *fbdev; };
drivers/gpu/drm/mxsfb/mxsfb_out.c +14 -12
@@ -30,7 +30,8 @@static struct mxsfb_drm_private *drm_connector_to_mxsfb_drm_private (struct drm_connector *connector) { - return container_of(connector, struct mxsfb_drm_private, connector); + return container_of(connector, struct mxsfb_drm_private, + panel_connector); }static int mxsfb_panel_get_modes (struct drm_connector *connector)
@@ -85,22 +86,23 @@ static const struct drm_connector_funcs mxsfb_panel_connector_funcs = {int mxsfb_create_output (struct drm_device *drm) {struct mxsfb_drm_private *mxsfb = drm->dev_private; -struct drm_panel *panel;int ret; - ret =drm_of_find_panel_or_bridge (drm->dev->of_node,0 ,0 , &panel,NULL ); + ret =drm_of_find_panel_or_bridge (drm->dev->of_node,0 ,0 , + &mxsfb->panel, &mxsfb->bridge);if (ret)return ret; - mxsfb->connector.dpms =DRM_MODE_DPMS_OFF ; - mxsfb->connector.polled =0 ; -drm_connector_helper_add (&mxsfb->connector, - &mxsfb_panel_connector_helper_funcs); - ret =drm_connector_init (drm, &mxsfb->connector, - &mxsfb_panel_connector_funcs, - DRM_MODE_CONNECTOR_Unknown); -if (!ret) - mxsfb->panel = panel; +if (mxsfb->panel) { + mxsfb->connector = &mxsfb->panel_connector; + mxsfb->connector->dpms =DRM_MODE_DPMS_OFF ; + mxsfb->connector->polled =0 ; +drm_connector_helper_add (mxsfb->connector, + &mxsfb_panel_connector_helper_funcs); + ret =drm_connector_init (drm, mxsfb->connector, + &mxsfb_panel_connector_funcs, + DRM_MODE_CONNECTOR_Unknown); + }return ret; }
drivers/gpu/drm/mxsfb/mxsfb_regs.h +15 -0
@@ -22,19 +22,31 @@#define LCDC_CTRL 0x00#define LCDC_CTRL1 0x10 +#define LCDC_V4_CTRL2 0x20#define LCDC_V3_TRANSFER_COUNT 0x20#define LCDC_V4_TRANSFER_COUNT 0x30#define LCDC_V4_CUR_BUF 0x40#define LCDC_V4_NEXT_BUF 0x50#define LCDC_V3_CUR_BUF 0x30#define LCDC_V3_NEXT_BUF 0x40 +#define LCDC_TIMING 0x60#define LCDC_VDCTRL0 0x70#define LCDC_VDCTRL1 0x80#define LCDC_VDCTRL2 0x90#define LCDC_VDCTRL3 0xa0#define LCDC_VDCTRL4 0xb0 +#define LCDC_DVICTRL0 0xc0 +#define LCDC_DVICTRL1 0xd0 +#define LCDC_DVICTRL2 0xe0 +#define LCDC_DVICTRL3 0xf0 +#define LCDC_DVICTRL4 0x100 +#define LCDC_V4_DATA 0x180 +#define LCDC_V3_DATA 0x1b0#define LCDC_V4_DEBUG0 0x1d0#define LCDC_V3_DEBUG0 0x1f0 +#define LCDC_AS_CTRL 0x210 +#define LCDC_AS_BUF 0x220 +#define LCDC_AS_NEXT_BUF 0x230#define CTRL_SFTRST (1 << 31)#define CTRL_CLKGATE (1 << 30)
@@ -53,12 +65,15 @@#define CTRL_DF24 (1 << 1)#define CTRL_RUN (1 << 0) +#define CTRL1_RECOVERY_ON_UNDERFLOW (1 << 24)#define CTRL1_FIFO_CLEAR (1 << 21)#define CTRL1_SET_BYTE_PACKAGING (x) (((x) & 0xf) << 16)#define CTRL1_GET_BYTE_PACKAGING (x) (((x) >> 16) & 0xf)#define CTRL1_CUR_FRAME_DONE_IRQ_EN (1 << 13)#define CTRL1_CUR_FRAME_DONE_IRQ (1 << 9) +#define CTRL2_OUTSTANDING_REQS__REQ_16 (4 << 21) +#define TRANSFER_COUNT_SET_VCOUNT (x) (((x) & 0xffff) << 16)#define TRANSFER_COUNT_GET_VCOUNT (x) (((x) >> 16) & 0xffff)#define TRANSFER_COUNT_SET_HCOUNT (x) ((x) & 0xffff)
Signature · 1 line
2.7.4
PATCH 2/11 dt-bindings: display: Add max-res property for mxsfb
In reply to Robert ChirasAdd new optional property 'max-res', to limit the maximum supported resolution by the MXSFB_DRM driver.
--- Documentation/devicetree/bindings/display/mxsfb.txt | 6 ++++++ 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/display/mxsfb.txt +6 -0
@@ -17,6 +17,12 @@ Required properties: Required sub-nodes: - port: The connection to an encoder chip. +Optional properties: +- max-res: an array with a maximum of two integers, representing the + maximum supported resolution, in the form of + <maxX>, <maxY>; if one of the item is <0>, the default + driver-defined maximum resolution for that axis is used + Example: lcdif1: display-controller@2220000 {
Signature · 1 line
2.7.4
PATCH 3/11 drm/mxsfb: Add max-res property for MXSFB
In reply to Robert ChirasBecause of stability issues, we may want to limit the maximum resolution supported by the MXSFB (eLCDIF) driver.
This patch add support for a new property which we can use to impose such limitation.
--- drivers/gpu/drm/mxsfb/mxsfb_drv.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/mxsfb/mxsfb_drv.c +10 -2
@@ -201,6 +201,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; +u32 max_res[2 ] = {0 ,0 };int ret; mxsfb =devm_kzalloc (&pdev->dev,sizeof (*mxsfb),GFP_KERNEL );
@@ -279,10 +280,17 @@ static int mxsfb_load(struct drm_device *drm, unsigned long flags) } } +of_property_read_u32_array (drm->dev->of_node,"max-res" , + &max_res[0 ],2 ); +if (!max_res[0 ]) + max_res[0 ] =MXSFB_MAX_XRES ; +if (!max_res[1 ]) + max_res[1 ] =MXSFB_MAX_YRES ; + drm->mode_config.min_width =MXSFB_MIN_XRES ; drm->mode_config.min_height =MXSFB_MIN_YRES ; - drm->mode_config.max_width =MXSFB_MAX_XRES ; - drm->mode_config.max_height =MXSFB_MAX_YRES ; + drm->mode_config.max_width = max_res[0 ]; + drm->mode_config.max_height = max_res[1 ]; drm->mode_config.funcs = &mxsfb_mode_config_funcs; drm->mode_config.helper_private = &mxsfb_mode_config_helpers;
Signature · 1 line
2.7.4
PATCH 4/11 drm/mxsfb: Update mxsfb with additional pixel formats
In reply to Robert ChirasSince version 4 of eLCDIF, there are some registers that can do transformations on the input data, like re-arranging the pixel components. By doing that, we can support more pixel formats. This patch adds support for X/ABGR and RGBX/A. Although, the local alpha is not supported by eLCDIF, the alpha pixel formats were added to the supported pixel formats but it will be ignored. This was necessary since there are systems (like Android) that requires such pixel formats.
--- drivers/gpu/drm/mxsfb/mxsfb_crtc.c | 108 ++++++++++++++++++++++++++++--------- drivers/gpu/drm/mxsfb/mxsfb_drv.c | 25 ++++++--- drivers/gpu/drm/mxsfb/mxsfb_drv.h | 3 +- drivers/gpu/drm/mxsfb/mxsfb_regs.h | 100 ++++++++++++++++++++-------------- 4 files changed, 166 insertions(+), 70 deletions(-)
drivers/gpu/drm/mxsfb/mxsfb_crtc.c +84 -24
@@ -48,15 +48,35 @@ static u32 set_hsync_pulse_width(struct mxsfb_drm_private *mxsfb, u32 val) mxsfb->devdata->hs_wdth_shift; } +/* Print Four-character-code (FOURCC) */ +static char *fourcc_to_str (u32 fmt) +{ +/* Use 10 chars so we can simultaneously print two codes */ +static char code[10 ], *c = &code[0 ]; + +if (c == &code[10 ]) + c = &code[0 ]; + + *(c++) = (unsigned char )(fmt &0xff ); + *(c++) = (unsigned char )((fmt >>8 ) &0xff ); + *(c++) = (unsigned char )((fmt >>16 ) &0xff ); + *(c++) = (unsigned char )((fmt >>24 ) &0xff ); + *(c++) ='\0' ; + +return (c -5 ); +} +/* Setup the MXSFB registers for decoding the pixels out of the framebuffer */ -static int mxsfb_set_pixel_fmt (struct mxsfb_drm_private *mxsfb) +static int mxsfb_set_pixel_fmt (struct mxsfb_drm_private *mxsfb,bool update) {struct drm_crtc *crtc = &mxsfb->pipe.crtc;struct drm_device *drm = crtc->dev;const u32 format = crtc->primary->state->fb->format->format; -u32 ctrl, ctrl1; +u32 ctrl =0 , ctrl1 =0 ; +bool bgr_format = true; - ctrl =CTRL_BYPASS_COUNT |CTRL_MASTER ; +if (!update) + ctrl =CTRL_BYPASS_COUNT |CTRL_MASTER ;/* * WARNING: The bus width, CTRL_SET_BUS_WIDTH(), is configured to
@@ -65,31 +85,69 @@ static int mxsfb_set_pixel_fmt(struct mxsfb_drm_private *mxsfb)* to arbitrary value. This limitation should not pose an issue. */ -/* CTRL1 contains IRQ config and status bits, preserve those. */ - ctrl1 =readl (mxsfb->base +LCDC_CTRL1 ); - ctrl1 &=CTRL1_CUR_FRAME_DONE_IRQ_EN |CTRL1_CUR_FRAME_DONE_IRQ ; +if (!update) { +/* CTRL1 contains IRQ config and status bits, preserve those. */ + ctrl1 =readl (mxsfb->base +LCDC_CTRL1 ); + ctrl1 &=CTRL1_CUR_FRAME_DONE_IRQ_EN |CTRL1_CUR_FRAME_DONE_IRQ ; + } + +DRM_DEV_DEBUG_DRIVER (drm->dev,"Setting up %s mode\n" , +fourcc_to_str (format)); + +/* Do some clean-up that we might have from a previous mode */ + ctrl &= ~CTRL_SHIFT_DIR (1 ); + ctrl &= ~CTRL_SHIFT_NUM (0x3f ); +if (mxsfb->devdata->ipversion >=4 ) +writel (CTRL2_ODD_LINE_PATTERN (0x7 ) | +CTRL2_EVEN_LINE_PATTERN (0x7 ), + mxsfb->base +LCDC_V4_CTRL2 +REG_CLR );switch (format) {case DRM_FORMAT_RGB565 : -dev_dbg (drm->dev,"Setting up RGB565 mode\n" ); ctrl |=CTRL_SET_WORD_LENGTH (0 ); ctrl1 |=CTRL1_SET_BYTE_PACKAGING (0xf );break ; +case DRM_FORMAT_RGBX8888 : +case DRM_FORMAT_RGBA8888 : +/* RGBX - > 0RGB */ + ctrl |=CTRL_SHIFT_DIR (1 ); + ctrl |=CTRL_SHIFT_NUM (8 ); + bgr_format = false; +/* Fall through */ +case DRM_FORMAT_XBGR8888 : +case DRM_FORMAT_ABGR8888 : +if (bgr_format) { +if (mxsfb->devdata->ipversion <4 ) + goto err; +writel (CTRL2_ODD_LINE_PATTERN (0x5 ) | +CTRL2_EVEN_LINE_PATTERN (0x5 ), + mxsfb->base +LCDC_V4_CTRL2 +REG_SET ); + } +/* Fall through */ case DRM_FORMAT_XRGB8888 : -dev_dbg (drm->dev,"Setting up XRGB8888 mode\n" ); +case DRM_FORMAT_ARGB8888 : ctrl |=CTRL_SET_WORD_LENGTH (3 );/* Do not use packed pixels = one pixel per word instead. */ ctrl1 |=CTRL1_SET_BYTE_PACKAGING (0x7 );break ;default : -dev_err (drm->dev,"Unhandled pixel format %08x\n" , format); -return -EINVAL ; + goto err; } -writel (ctrl1, mxsfb->base +LCDC_CTRL1 ); -writel (ctrl, mxsfb->base +LCDC_CTRL ); +if (update) { +writel (ctrl, mxsfb->base +LCDC_CTRL +REG_SET ); +writel (ctrl1, mxsfb->base +LCDC_CTRL1 +REG_SET ); + }else { +writel (ctrl, mxsfb->base +LCDC_CTRL ); +writel (ctrl1, mxsfb->base +LCDC_CTRL1 ); + }return 0 ; + +err: +DRM_DEV_ERROR (drm->dev,"Unhandled pixel format: %s\n" , +fourcc_to_str (format)); +return -EINVAL ; }static void mxsfb_set_bus_fmt (struct mxsfb_drm_private *mxsfb)
@@ -97,9 +155,7 @@ static void mxsfb_set_bus_fmt(struct mxsfb_drm_private *mxsfb)struct drm_crtc *crtc = &mxsfb->pipe.crtc;struct drm_device *drm = crtc->dev;u32 bus_format =MEDIA_BUS_FMT_RGB888_1X24 ; -u32 reg; - - reg =readl (mxsfb->base +LCDC_CTRL ); +u32 reg =0 ;if (mxsfb->connector->display_info.num_bus_formats) bus_format = mxsfb->connector->display_info.bus_formats[0 ];
@@ -107,22 +163,21 @@ static void mxsfb_set_bus_fmt(struct mxsfb_drm_private *mxsfb)DRM_DEV_DEBUG_DRIVER (drm->dev,"Using bus_format: 0x%08X\n" , bus_format); - reg &= ~CTRL_BUS_WIDTH_MASK ;switch (bus_format) {case MEDIA_BUS_FMT_RGB565_1X16 : - reg |=CTRL_SET_BUS_WIDTH (STMLCDIF_16BIT ); + reg =CTRL_SET_BUS_WIDTH (STMLCDIF_16BIT );break ;case MEDIA_BUS_FMT_RGB666_1X18 : - reg |=CTRL_SET_BUS_WIDTH (STMLCDIF_18BIT ); + reg =CTRL_SET_BUS_WIDTH (STMLCDIF_18BIT );break ;case MEDIA_BUS_FMT_RGB888_1X24 : - reg |=CTRL_SET_BUS_WIDTH (STMLCDIF_24BIT ); + reg =CTRL_SET_BUS_WIDTH (STMLCDIF_24BIT );break ;default :dev_err (drm->dev,"Unknown media bus format %d\n" , bus_format);break ; } -writel (reg, mxsfb->base +LCDC_CTRL ); +writel (reg, mxsfb->base +LCDC_CTRL +REG_SET ); }static void mxsfb_enable_controller (struct mxsfb_drm_private *mxsfb)
@@ -133,8 +188,9 @@ static void mxsfb_enable_controller(struct mxsfb_drm_private *mxsfb)clk_prepare_enable (mxsfb->clk_disp_axi);clk_prepare_enable (mxsfb->clk); -writel (CTRL2_OUTSTANDING_REQS__REQ_16 , - mxsfb->base +LCDC_V4_CTRL2 +REG_SET ); +if (mxsfb->devdata->ipversion >=4 ) +writel (CTRL2_OUTSTANDING_REQS (REQ_16 ), + mxsfb->base +LCDC_V4_CTRL2 +REG_SET );/* If it was disabled, re-enable the mode again */ writel (CTRL_DOTCLK_MODE , mxsfb->base +LCDC_CTRL +REG_SET );
@@ -152,6 +208,10 @@ static void mxsfb_disable_controller(struct mxsfb_drm_private *mxsfb) {u32 reg; +if (mxsfb->devdata->ipversion >=4 ) +writel (CTRL2_OUTSTANDING_REQS (0x7 ), + mxsfb->base +LCDC_V4_CTRL2 +REG_CLR ); +writel (CTRL_RUN , mxsfb->base +LCDC_CTRL +REG_CLR );/*
@@ -239,7 +299,7 @@ static void mxsfb_crtc_mode_set_nofb(struct mxsfb_drm_private *mxsfb)/* Clear the FIFOs */ writel (CTRL1_FIFO_CLEAR , mxsfb->base +LCDC_CTRL1 +REG_SET ); - err =mxsfb_set_pixel_fmt (mxsfb); + err =mxsfb_set_pixel_fmt (mxsfb, false);if (err)return ;
@@ -324,7 +384,7 @@ void mxsfb_crtc_disable(struct mxsfb_drm_private *mxsfb) }void mxsfb_plane_atomic_update (struct mxsfb_drm_private *mxsfb, -struct drm_plane_state *state) +struct drm_plane_state *old_state) {struct drm_simple_display_pipe *pipe = &mxsfb->pipe;struct drm_crtc *crtc = &pipe->crtc;
drivers/gpu/drm/mxsfb/mxsfb_drv.c +19 -6
@@ -48,6 +48,22 @@ enum mxsfb_devtype { MXSFB_V4, }; +/* +* When adding new formats, make sure to update the num_formats from +* mxsfb_devdata below. +*/ +static const uint32_t mxsfb_formats[] = { +/* MXSFB_V3 */ +DRM_FORMAT_XRGB8888 , +DRM_FORMAT_ARGB8888 , +DRM_FORMAT_RGB565 , +/* MXSFB_V4 */ +DRM_FORMAT_XBGR8888 , +DRM_FORMAT_ABGR8888 , +DRM_FORMAT_RGBX8888 , +DRM_FORMAT_RGBA8888 , +}; +static const struct mxsfb_devdata mxsfb_devdata[] = { [MXSFB_V3 ] = { .transfer_count =LCDC_V3_TRANSFER_COUNT ,
@@ -57,6 +73,7 @@ static const struct mxsfb_devdata mxsfb_devdata[] = { .hs_wdth_mask = 0xff, .hs_wdth_shift = 24, .ipversion = 3, + .num_formats = 3, }, [MXSFB_V4] = { .transfer_count = LCDC_V4_TRANSFER_COUNT,
@@ -66,14 +83,10 @@ static const struct mxsfb_devdata mxsfb_devdata[] = { .hs_wdth_mask = 0x3fff, .hs_wdth_shift = 18, .ipversion = 4, + .num_formats = ARRAY_SIZE(mxsfb_formats), }, }; -static const uint32_t mxsfb_formats[] = { -DRM_FORMAT_XRGB8888 , -DRM_FORMAT_RGB565 -}; -static struct mxsfb_drm_private *drm_pipe_to_mxsfb_drm_private (struct drm_simple_display_pipe *pipe) {
@@ -250,7 +263,7 @@ static int mxsfb_load(struct drm_device *drm, unsigned long flags) } ret =drm_simple_display_pipe_init (drm, &mxsfb->pipe, &mxsfb_funcs, - mxsfb_formats,ARRAY_SIZE (mxsfb_formats),NULL , + mxsfb_formats, mxsfb->devdata->num_formats,NULL , mxsfb->connector);if (ret <0 ) {dev_err (drm->dev,"Cannot setup simple display pipe\n" );
drivers/gpu/drm/mxsfb/mxsfb_drv.h +2 -1
@@ -24,6 +24,7 @@ struct mxsfb_devdata {unsigned int hs_wdth_mask;unsigned int hs_wdth_shift;unsigned int ipversion; +unsigned int num_formats; };struct mxsfb_drm_private {
@@ -51,6 +52,6 @@ void mxsfb_disable_axi_clk(struct mxsfb_drm_private *mxsfb);void mxsfb_crtc_enable (struct mxsfb_drm_private *mxsfb);void mxsfb_crtc_disable (struct mxsfb_drm_private *mxsfb);void mxsfb_plane_atomic_update (struct mxsfb_drm_private *mxsfb, -struct drm_plane_state *state); +struct drm_plane_state *old_state);#endif /* __MXSFB_DRV_H__ */
drivers/gpu/drm/mxsfb/mxsfb_regs.h +61 -39
129 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH 5/11 drm/mxsfb: Fix the vblank events
In reply to Robert ChirasCurrently, the vblank support is not correctly implemented in MXSFB_DRM driver. The call to drm_vblank_init is made with mode_config.num_crtc which at that time is 0. Because of this, vblank is not activated, so there won't be any vblank event submitted.
--- drivers/gpu/drm/mxsfb/mxsfb_drv.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/mxsfb/mxsfb_drv.c +8 -1
@@ -43,6 +43,9 @@#include "mxsfb_drv.h" #include "mxsfb_regs.h" +/* The eLCDIF max possible CRTCs */ +#define MAX_CRTCS 1 +enum mxsfb_devtype {MXSFB_V3 ,MXSFB_V4 ,
@@ -138,6 +141,8 @@ static void mxsfb_pipe_enable(struct drm_simple_display_pipe *pipe, mxsfb->connector = &mxsfb->panel_connector; } +drm_crtc_vblank_on (&mxsfb->pipe.crtc); +pm_runtime_get_sync (drm->dev);drm_panel_prepare (mxsfb->panel);mxsfb_crtc_enable (mxsfb);
@@ -247,7 +252,7 @@ static int mxsfb_load(struct drm_device *drm, unsigned long flags)pm_runtime_enable (drm->dev); - ret =drm_vblank_init (drm, drm->mode_config.num_crtc); + ret =drm_vblank_init (drm,MAX_CRTCS );if (ret <0 ) {dev_err (drm->dev,"Failed to initialise vblank\n" ); goto err_vblank;
@@ -270,6 +275,8 @@ static int mxsfb_load(struct drm_device *drm, unsigned long flags) goto err_vblank; } +drm_crtc_vblank_off (&mxsfb->pipe.crtc); +/* * Attach panel only if there is one. * If there is no panel attach, it must be a bridge. In this case, we
Signature · 1 line
2.7.4
PATCH 6/11 drm/mxsfb: Add support for new pixel formats in eLCDIF
In reply to Robert ChirasFrom: Mirela Rabulea <[email protected]>
Add support for the following pixel formats:
16 bpp: RG16 ,BG16, XR15, XB15, AR15, AB15
Set the bus format based on input from the user and panel capabilities. Save the bus format in crtc->mode.private_flags, the DSI will use it. Use drm_get_format_name instead of locally defined fourcc_to_str.
--- drivers/gpu/drm/mxsfb/mxsfb_crtc.c | 100 ++++++++++++++++++++++++++----------- drivers/gpu/drm/mxsfb/mxsfb_drv.c | 5 ++ 2 files changed, 76 insertions(+), 29 deletions(-)
drivers/gpu/drm/mxsfb/mxsfb_crtc.c +71 -29
@@ -48,24 +48,6 @@ static u32 set_hsync_pulse_width(struct mxsfb_drm_private *mxsfb, u32 val) mxsfb->devdata->hs_wdth_shift; } -/* Print Four-character-code (FOURCC) */ -static char *fourcc_to_str (u32 fmt) -{ -/* Use 10 chars so we can simultaneously print two codes */ -static char code[10 ], *c = &code[0 ]; - -if (c == &code[10 ]) - c = &code[0 ]; - - *(c++) = (unsigned char )(fmt &0xff ); - *(c++) = (unsigned char )((fmt >>8 ) &0xff ); - *(c++) = (unsigned char )((fmt >>16 ) &0xff ); - *(c++) = (unsigned char )((fmt >>24 ) &0xff ); - *(c++) ='\0' ; - -return (c -5 ); -} -/* Setup the MXSFB registers for decoding the pixels out of the framebuffer */ static int mxsfb_set_pixel_fmt (struct mxsfb_drm_private *mxsfb,bool update) {
@@ -74,6 +56,7 @@ static int mxsfb_set_pixel_fmt(struct mxsfb_drm_private *mxsfb, bool update)const u32 format = crtc->primary->state->fb->format->format;u32 ctrl =0 , ctrl1 =0 ;bool bgr_format = true; +struct drm_format_name_buf format_name_buf;if (!update) ctrl =CTRL_BYPASS_COUNT |CTRL_MASTER ;
@@ -92,7 +75,7 @@ static int mxsfb_set_pixel_fmt(struct mxsfb_drm_private *mxsfb, bool update) }DRM_DEV_DEBUG_DRIVER (drm->dev,"Setting up %s mode\n" , -fourcc_to_str (format)); +drm_get_format_name (format, &format_name_buf));/* Do some clean-up that we might have from a previous mode */ ctrl &= ~CTRL_SHIFT_DIR (1 );
@@ -103,19 +86,41 @@ static int mxsfb_set_pixel_fmt(struct mxsfb_drm_private *mxsfb, bool update) mxsfb->base + LCDC_V4_CTRL2 + REG_CLR);switch (format) { -case DRM_FORMAT_RGB565 : +case DRM_FORMAT_BGR565 :/* BG16 */ +if (mxsfb->devdata->ipversion <4 ) + goto err; +writel (CTRL2_ODD_LINE_PATTERN (0x5 ) | +CTRL2_EVEN_LINE_PATTERN (0x5 ), + mxsfb->base +LCDC_V4_CTRL2 +REG_SET ); +/* Fall through */ +case DRM_FORMAT_RGB565 :/* RG16 */ ctrl |=CTRL_SET_WORD_LENGTH (0 ); + ctrl &= ~CTRL_DF16 ; ctrl1 |=CTRL1_SET_BYTE_PACKAGING (0xf );break ; -case DRM_FORMAT_RGBX8888 : -case DRM_FORMAT_RGBA8888 : +case DRM_FORMAT_XBGR1555 :/* XB15 */ +case DRM_FORMAT_ABGR1555 :/* AB15 */ +if (mxsfb->devdata->ipversion <4 ) + goto err; +writel (CTRL2_ODD_LINE_PATTERN (0x5 ) | +CTRL2_EVEN_LINE_PATTERN (0x5 ), + mxsfb->base +LCDC_V4_CTRL2 +REG_SET ); +/* Fall through */ +case DRM_FORMAT_XRGB1555 :/* XR15 */ +case DRM_FORMAT_ARGB1555 :/* AR15 */ + ctrl |=CTRL_SET_WORD_LENGTH (0 ); + ctrl |=CTRL_DF16 ; + ctrl1 |=CTRL1_SET_BYTE_PACKAGING (0xf ); +break ; +case DRM_FORMAT_RGBX8888 :/* RX24 */ +case DRM_FORMAT_RGBA8888 :/* RA24 */ /* RGBX - > 0RGB */ ctrl |=CTRL_SHIFT_DIR (1 ); ctrl |=CTRL_SHIFT_NUM (8 ); bgr_format = false;/* Fall through */ -case DRM_FORMAT_XBGR8888 : -case DRM_FORMAT_ABGR8888 : +case DRM_FORMAT_XBGR8888 :/* XB24 */ +case DRM_FORMAT_ABGR8888 :/* AB24 */ if (bgr_format) {if (mxsfb->devdata->ipversion <4 ) goto err;
@@ -124,8 +129,8 @@ static int mxsfb_set_pixel_fmt(struct mxsfb_drm_private *mxsfb, bool update) mxsfb->base + LCDC_V4_CTRL2 + REG_SET); }/* Fall through */ -case DRM_FORMAT_XRGB8888 : -case DRM_FORMAT_ARGB8888 : +case DRM_FORMAT_XRGB8888 :/* XR24 */ +case DRM_FORMAT_ARGB8888 :/* AR24 */ ctrl |=CTRL_SET_WORD_LENGTH (3 );/* Do not use packed pixels = one pixel per word instead. */ ctrl1 |=CTRL1_SET_BYTE_PACKAGING (0x7 );
@@ -146,19 +151,56 @@ static int mxsfb_set_pixel_fmt(struct mxsfb_drm_private *mxsfb, bool update) err:DRM_DEV_ERROR (drm->dev,"Unhandled pixel format: %s\n" , -fourcc_to_str (format)); +drm_get_format_name (format, &format_name_buf)); +return -EINVAL ; } +static u32 get_bus_format_from_bpp (u32 bpp) +{ +switch (bpp) { +case 16 : +return MEDIA_BUS_FMT_RGB565_1X16 ; +case 18 : +return MEDIA_BUS_FMT_RGB666_1X18 ; +case 24 : +return MEDIA_BUS_FMT_RGB888_1X24 ; +default : +return MEDIA_BUS_FMT_RGB888_1X24 ; + } +} +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 ; +int num_bus_formats = mxsfb->connector->display_info.num_bus_formats; +const u32 *bus_formats = mxsfb->connector->display_info.bus_formats;u32 reg =0 ; +int i =0 ; + +/* 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); + + bus_format = bus_formats[0 ]; +for (i =0 ; i < num_bus_formats; i++) { +if (user_bus_format == bus_formats[i]) { + bus_format = user_bus_format; +break ; + } + } + } -if (mxsfb->connector->display_info.num_bus_formats) - bus_format = mxsfb->connector->display_info.bus_formats[0 ]; +/* +* CRTC will dictate the bus format via private_flags[16:1] +* and private_flags[0] will signal a bus format change +*/ + crtc->mode.private_flags &= ~0x1FFFF ;/* clear bus format */ + crtc->mode.private_flags |= (bus_format <<1 );/* set bus format */ + crtc->mode.private_flags |=0x1 ;/* bus format change indication*/ DRM_DEV_DEBUG_DRIVER (drm->dev,"Using bus_format: 0x%08X\n" , bus_format);
drivers/gpu/drm/mxsfb/mxsfb_drv.c +5 -0
@@ -65,6 +65,11 @@ static const uint32_t mxsfb_formats[] = {DRM_FORMAT_ABGR8888 ,DRM_FORMAT_RGBX8888 ,DRM_FORMAT_RGBA8888 , +DRM_FORMAT_ARGB1555 , +DRM_FORMAT_XRGB1555 , +DRM_FORMAT_ABGR1555 , +DRM_FORMAT_XBGR1555 , +DRM_FORMAT_BGR565 }; static const struct mxsfb_devdata mxsfb_devdata[] = {
Signature · 1 line
2.7.4
PATCH 7/11 drm/mxsfb: Signal mode changed when bpp changed
In reply to Robert ChirasFrom: Mirela Rabulea <[email protected]>
Add mxsfb_atomic_helper_check to signal mode changed when bpp changed. This will trigger the execution of disable/enable on
a modeset with different bpp than the current one.
--- drivers/gpu/drm/mxsfb/mxsfb_drv.c | 48 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-)
drivers/gpu/drm/mxsfb/mxsfb_drv.c +47 -1
@@ -113,9 +113,55 @@ void mxsfb_disable_axi_clk(struct mxsfb_drm_private *mxsfb)clk_disable_unprepare (mxsfb->clk_axi); } +/** +* mxsfb_atomic_helper_check - validate state object +* @dev: DRM device +* @state: the driver state object +* +* On top of the drm imlementation drm_atomic_helper_check, +* check if the bpp is changed, if so, signal mode_changed, +* this will trigger disable/enable +* +* RETURNS: +* Zero for success or -errno +*/ +static int mxsfb_atomic_helper_check (struct drm_device *dev, +struct drm_atomic_state *state) +{ +struct drm_crtc *crtc; +struct drm_crtc_state *new_state; +int i, ret; + + ret =drm_atomic_helper_check (dev, state); +if (ret) +return ret; + +for_each_new_crtc_in_state (state, crtc, new_state, i) { +struct drm_plane_state *primary_state; +int old_bpp =0 ; +int new_bpp =0 ; + +if (!crtc->primary || !crtc->primary->old_fb) +continue ; + primary_state = +drm_atomic_get_plane_state (state, crtc->primary); +if (!primary_state || !primary_state->fb) +continue ; + old_bpp = crtc->primary->old_fb->format->depth; + new_bpp = primary_state->fb->format->depth; +if (old_bpp != new_bpp) { + new_state->mode_changed = true; +DRM_DEBUG_ATOMIC ( +"[CRTC:%d:%s] mode changed, bpp %d->%d\n" , + crtc->base.id, crtc->name, old_bpp, new_bpp); + } + } +return ret; +} +static const struct drm_mode_config_funcs mxsfb_mode_config_funcs = { .fb_create = drm_gem_fb_create, - .atomic_check = drm_atomic_helper_check, + .atomic_check = mxsfb_atomic_helper_check, .atomic_commit = drm_atomic_helper_commit, };
Signature · 1 line
2.7.4
PATCH 8/11 drm/mxsfb: Update mxsfb to support LCD reset
In reply to Robert ChirasThe eLCDIF controller has control pin for the external LCD reset pin. Add support for it and assert this pin in enable and de-assert it in disable.
--- drivers/gpu/drm/mxsfb/mxsfb_crtc.c | 10 ++++++++-- drivers/gpu/drm/mxsfb/mxsfb_regs.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/mxsfb/mxsfb_crtc.c +8 -2
@@ -230,9 +230,12 @@ static void mxsfb_enable_controller(struct mxsfb_drm_private *mxsfb)clk_prepare_enable (mxsfb->clk_disp_axi);clk_prepare_enable (mxsfb->clk); -if (mxsfb->devdata->ipversion >=4 ) +if (mxsfb->devdata->ipversion >=4 ) {writel (CTRL2_OUTSTANDING_REQS (REQ_16 ), mxsfb->base +LCDC_V4_CTRL2 +REG_SET ); +/* Assert LCD Reset bit */ +writel (CTRL2_LCD_RESET , mxsfb->base +LCDC_V4_CTRL2 +REG_SET ); + }/* If it was disabled, re-enable the mode again */ writel (CTRL_DOTCLK_MODE , mxsfb->base +LCDC_CTRL +REG_SET );
@@ -250,9 +253,12 @@ static void mxsfb_disable_controller(struct mxsfb_drm_private *mxsfb) {u32 reg; -if (mxsfb->devdata->ipversion >=4 ) +if (mxsfb->devdata->ipversion >=4 ) {writel (CTRL2_OUTSTANDING_REQS (0x7 ), mxsfb->base +LCDC_V4_CTRL2 +REG_CLR ); +/* De-assert LCD Reset bit */ +writel (CTRL2_LCD_RESET , mxsfb->base +LCDC_V4_CTRL2 +REG_CLR ); + }writel (CTRL_RUN , mxsfb->base +LCDC_CTRL +REG_CLR );
drivers/gpu/drm/mxsfb/mxsfb_regs.h +1 -0
@@ -95,6 +95,7 @@#define CTRL2_OUTSTANDING_REQS (x) REG_PUT((x), 23, 21)#define CTRL2_ODD_LINE_PATTERN (x) REG_PUT((x), 18, 16)#define CTRL2_EVEN_LINE_PATTERN (x) REG_PUT((x), 14, 12) +#define CTRL2_LCD_RESET BIT(0)#define TRANSFER_COUNT_SET_VCOUNT (x) (((x) & 0xffff) << 16)#define TRANSFER_COUNT_GET_VCOUNT (x) (((x) >> 16) & 0xffff)
Signature · 1 line
2.7.4
PATCH 9/11 drm/mxsfb: Move pm_runtime_enable at the end of probe
In reply to Robert ChirasMove the pm_runtime_enable call at the end of probbe, since it was made too early, causing issues to DRM enable routines.
--- drivers/gpu/drm/mxsfb/mxsfb_drv.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
drivers/gpu/drm/mxsfb/mxsfb_drv.c +7 -11
@@ -301,12 +301,10 @@ static int mxsfb_load(struct drm_device *drm, unsigned long flags)if (ret)return ret; -pm_runtime_enable (drm->dev); - ret =drm_vblank_init (drm,MAX_CRTCS );if (ret <0 ) {dev_err (drm->dev,"Failed to initialise vblank\n" ); - goto err_vblank; +return ret; }/* Modeset init */
@@ -315,7 +313,7 @@ static int mxsfb_load(struct drm_device *drm, unsigned long flags) ret =mxsfb_create_output (drm);if (ret <0 ) {dev_err (drm->dev,"Failed to create outputs\n" ); - goto err_vblank; +return ret; } ret = drm_simple_display_pipe_init(drm, &mxsfb->pipe, &mxsfb_funcs,
@@ -323,7 +321,7 @@ static int mxsfb_load(struct drm_device *drm, unsigned long flags) mxsfb->connector);if (ret <0 ) {dev_err (drm->dev,"Cannot setup simple display pipe\n" ); - goto err_vblank; +return ret; }drm_crtc_vblank_off (&mxsfb->pipe.crtc);
@@ -340,14 +338,14 @@ static int mxsfb_load(struct drm_device *drm, unsigned long flags) ret =drm_panel_attach (mxsfb->panel, mxsfb->connector);if (ret) {dev_err (drm->dev,"Cannot connect panel\n" ); - goto err_vblank; +return ret; } }else if (mxsfb->bridge) { ret =drm_simple_display_pipe_attach_bridge (&mxsfb->pipe, mxsfb->bridge);if (ret) {dev_err (drm->dev,"Cannot connect bridge\n" ); - goto err_vblank; +return ret; } }
@@ -367,9 +365,7 @@ static int mxsfb_load(struct drm_device *drm, unsigned long flags)drm_mode_config_reset (drm); -pm_runtime_get_sync (drm->dev); ret =drm_irq_install (drm,platform_get_irq (pdev,0 )); -pm_runtime_put_sync (drm->dev);if (ret <0 ) {dev_err (drm->dev,"Failed to install IRQ handler\n" );
@@ -391,14 +387,14 @@ static int mxsfb_load(struct drm_device *drm, unsigned long flags)drm_helper_hpd_irq_event (drm); +pm_runtime_enable (drm->dev); +return 0 ; err_cma:drm_irq_uninstall (drm); err_irq:drm_panel_detach (mxsfb->panel); -err_vblank: -pm_runtime_disable (drm->dev);return ret; }
Signature · 1 line
2.7.4
PATCH 10/11 drm/mxsfb: Improve the axi clock usage
In reply to Robert ChirasCurrently, the enable of the axi clock return status is ignored, causing issues when the enable fails then we try to disable it. Therefore, it is better to check the return status and disable it only when enable succeeded.
Also, remove the helper functions around clk_axi, since we can directly use the clk API function for enable/disable the clock. Those functions are already checking for NULL clk and returning 0 if that's the case.
--- drivers/gpu/drm/mxsfb/mxsfb_crtc.c | 8 ++++---- drivers/gpu/drm/mxsfb/mxsfb_drv.c | 32 +++++++++++++------------------- drivers/gpu/drm/mxsfb/mxsfb_drv.h | 3 --- 3 files changed, 17 insertions(+), 26 deletions(-)
drivers/gpu/drm/mxsfb/mxsfb_crtc.c +4 -4
@@ -411,7 +411,7 @@ void mxsfb_crtc_enable(struct mxsfb_drm_private *mxsfb) {dma_addr_t paddr; -mxsfb_enable_axi_clk (mxsfb); +clk_prepare_enable (mxsfb->clk_axi);writel (0 , mxsfb->base +LCDC_CTRL );mxsfb_crtc_mode_set_nofb (mxsfb);
@@ -428,7 +428,7 @@ void mxsfb_crtc_enable(struct mxsfb_drm_private *mxsfb)void mxsfb_crtc_disable (struct mxsfb_drm_private *mxsfb) {mxsfb_disable_controller (mxsfb); -mxsfb_disable_axi_clk (mxsfb); +clk_disable_unprepare (mxsfb->clk_axi); } void mxsfb_plane_atomic_update(struct mxsfb_drm_private *mxsfb,
@@ -456,9 +456,9 @@ void mxsfb_plane_atomic_update(struct mxsfb_drm_private *mxsfb, paddr =mxsfb_get_fb_paddr (mxsfb);if (paddr) { -mxsfb_enable_axi_clk (mxsfb); +clk_prepare_enable (mxsfb->clk_axi);writel (paddr, mxsfb->base + mxsfb->devdata->next_buf); -mxsfb_disable_axi_clk (mxsfb); +clk_disable_unprepare (mxsfb->clk_axi); }if (!fb || !old_fb)
drivers/gpu/drm/mxsfb/mxsfb_drv.c +13 -19
@@ -101,18 +101,6 @@ drm_pipe_to_mxsfb_drm_private(struct drm_simple_display_pipe *pipe) return container_of(pipe, struct mxsfb_drm_private, pipe); } -void mxsfb_enable_axi_clk (struct mxsfb_drm_private *mxsfb) -{ -if (mxsfb->clk_axi) -clk_prepare_enable (mxsfb->clk_axi); -} - -void mxsfb_disable_axi_clk (struct mxsfb_drm_private *mxsfb) -{ -if (mxsfb->clk_axi) -clk_disable_unprepare (mxsfb->clk_axi); -} -/** * mxsfb_atomic_helper_check - validate state object * @dev: DRM device
@@ -235,25 +223,31 @@ static void mxsfb_pipe_update(struct drm_simple_display_pipe *pipe,static int mxsfb_pipe_enable_vblank (struct drm_simple_display_pipe *pipe) {struct mxsfb_drm_private *mxsfb =drm_pipe_to_mxsfb_drm_private (pipe); +int ret =0 ; + + ret =clk_prepare_enable (mxsfb->clk_axi); +if (ret) +return ret;/* Clear and enable VBLANK IRQ */ -mxsfb_enable_axi_clk (mxsfb);writel (CTRL1_CUR_FRAME_DONE_IRQ , mxsfb->base +LCDC_CTRL1 +REG_CLR );writel (CTRL1_CUR_FRAME_DONE_IRQ_EN , mxsfb->base +LCDC_CTRL1 +REG_SET ); -mxsfb_disable_axi_clk (mxsfb); +clk_disable_unprepare (mxsfb->clk_axi); -return 0 ; +return ret; }static void mxsfb_pipe_disable_vblank (struct drm_simple_display_pipe *pipe) {struct mxsfb_drm_private *mxsfb =drm_pipe_to_mxsfb_drm_private (pipe); +if (clk_prepare_enable (mxsfb->clk_axi)) +return ; +/* Disable and clear VBLANK IRQ */ -mxsfb_enable_axi_clk (mxsfb);writel (CTRL1_CUR_FRAME_DONE_IRQ_EN , mxsfb->base +LCDC_CTRL1 +REG_CLR );writel (CTRL1_CUR_FRAME_DONE_IRQ , mxsfb->base +LCDC_CTRL1 +REG_CLR ); -mxsfb_disable_axi_clk (mxsfb); +clk_disable_unprepare (mxsfb->clk_axi); }static struct drm_simple_display_pipe_funcs mxsfb_funcs = {
@@ -438,7 +432,7 @@ static irqreturn_t mxsfb_irq_handler(int irq, void *data)struct mxsfb_drm_private *mxsfb = drm->dev_private;u32 reg; -mxsfb_enable_axi_clk (mxsfb); +clk_prepare_enable (mxsfb->clk_axi); reg =readl (mxsfb->base +LCDC_CTRL1 );
@@ -447,7 +441,7 @@ static irqreturn_t mxsfb_irq_handler(int irq, void *data)writel (CTRL1_CUR_FRAME_DONE_IRQ , mxsfb->base +LCDC_CTRL1 +REG_CLR ); -mxsfb_disable_axi_clk (mxsfb); +clk_disable_unprepare (mxsfb->clk_axi);return IRQ_HANDLED ; }
drivers/gpu/drm/mxsfb/mxsfb_drv.h +0 -3
@@ -46,9 +46,6 @@ struct mxsfb_drm_private {int mxsfb_setup_crtc (struct drm_device *dev);int mxsfb_create_output (struct drm_device *dev); -void mxsfb_enable_axi_clk (struct mxsfb_drm_private *mxsfb); -void mxsfb_disable_axi_clk (struct mxsfb_drm_private *mxsfb); -void mxsfb_crtc_enable (struct mxsfb_drm_private *mxsfb);void mxsfb_crtc_disable (struct mxsfb_drm_private *mxsfb); void mxsfb_plane_atomic_update(struct mxsfb_drm_private *mxsfb,
Signature · 1 line
2.7.4
PATCH 11/11 drm/mxsfb: Clear OUTSTANDING_REQS bits
In reply to Robert ChirasBit 21 can alter the CTRL2_OUTSTANDING_REQS value right after the eLCDIF is enabled, since it comes up with default value of 1 (this behaviour has been seen on some imx8 platforms).
In order to fix this, clear CTRL2_OUTSTANDING_REQS bits before setting its value.
--- drivers/gpu/drm/mxsfb/mxsfb_crtc.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/mxsfb/mxsfb_crtc.c +7 -0
@@ -231,6 +231,13 @@ static void mxsfb_enable_controller(struct mxsfb_drm_private *mxsfb)clk_prepare_enable (mxsfb->clk);if (mxsfb->devdata->ipversion >=4 ) { +/* +* On some platforms, bit 21 is defaulted to 1, which may alter +* the below setting. So, to make sure we have the right setting +* clear all the bits for CTRL2_OUTSTANDING_REQS. +*/ +writel (CTRL2_OUTSTANDING_REQS (0x7 ), + mxsfb->base +LCDC_V4_CTRL2 +REG_CLR );writel (CTRL2_OUTSTANDING_REQS (REQ_16 ), mxsfb->base +LCDC_V4_CTRL2 +REG_SET );/* Assert LCD Reset bit */
Signature · 1 line
2.7.4