imx drm atomic mode setting conversion
Subsystems (6)
v4 cover imx drm atomic mode setting conversion
Hi,
This is the v4 patch set to convert imx drm into atomic mode setting. It takes 3 phases to achieve the goal.
v3->v4:
* Rebase onto Daniel Vetter's open git branch for-linux-next.
* Fix wrong LVDS bus format translation issue in imx_ldb_connector_get_modes() so that bus format could be determined by panel instead of device tree.
This issue was found by Philipp Zabel.
* Staticize ipu_plane_atomic_set_base()..
v2->v3:
* Rebase onto Daniel Vetter's open git branch topic/drm-misc so that we may better support nonblock atomic commit with the aid from drm atomic helper.
* Remove dw-hdmi bridge driver's legacy drm_connector_funcs struture step-by-step instead of doing that in patch 04/10 directly. So, patch 08/10 in this set is newly introduced.
v1->v2:
* Rebase onto Philipp Zabel's open git branch imx-drm/next as Philipp required.
* Drop patch 05/14 and 10/14 in v1 which touch drm core to disable plane in transitional helper drm_helper_crtc_mode_set and in drm_atomic_helper_disable_all, because we won't get ipu plane resource in v2 when updating plane and failure won't happen.
* Wait for pending commit on each CRTC for both block and nonblock atomic mode settings. This way, a block commit will not overwrite the hardware setting when a nonblock page flip is about to finish, so that the page flip may wait for vblank successfully.
* See changelogs in each patch for other trivial updates.
Liu Ying (10):
drm/imx: ipuv3 plane: Check different types of plane separately
gpu: ipu-v3: ipu-dmfc: Use static DMFC FIFO allocation mechanism drm/imx: atomic phase 1: Use transitional atomic CRTC and plane
helpers
drm/imx: atomic phase 2 step 1: Wire up state ->reset, ->duplicate and
->destroy
drm/imx: atomic phase 2 step 2: Track plane_state->fb correctly in
->page_flip drm/imx: Remove encoders' ->prepare callbacks
drm/imx: atomic phase 3 step 1: Use atomic configuration drm/bridge: dw-hdmi: Remove the legacy drm_connector_funcs structure drm/imx: atomic phase 3 step 2: Legacy callback fixups drm/imx: atomic phase 3 step 3: Advertise DRIVER_ATOMIC
drivers/gpu/drm/bridge/dw-hdmi.c | 19 +- drivers/gpu/drm/imx/dw_hdmi-imx.c | 22 +- drivers/gpu/drm/imx/imx-drm-core.c | 120 +++++--- drivers/gpu/drm/imx/imx-drm.h | 18 +- drivers/gpu/drm/imx/imx-ldb.c | 138 +++++---- drivers/gpu/drm/imx/imx-tve.c | 85 ++---- drivers/gpu/drm/imx/ipuv3-crtc.c | 370 ++++++---------------- drivers/gpu/drm/imx/ipuv3-plane.c | 543 ++++++++++++++++----------------- drivers/gpu/drm/imx/ipuv3-plane.h | 16 - drivers/gpu/drm/imx/parallel-display.c | 74 +++-- drivers/gpu/ipu-v3/ipu-dc.c | 5 +- drivers/gpu/ipu-v3/ipu-di.c | 3 - drivers/gpu/ipu-v3/ipu-dmfc.c | 213 +------------ include/video/imx-ipu-v3.h | 3 - 14 files changed, 601 insertions(+), 1028 deletions(-)
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 1/10 drm/imx: ipuv3 plane: Check different types of plane separately
The IPUv3 primary plane doesn't support partial off screen. So, this patch separates plane check logics for primary plane and overlay plane and adds more limitations on the primary plane.
---v3->v4:
* None.
v2->v3:
* None.
v1->v2:
* Remove an unnecessary copy to address Philipp's comment.
drivers/gpu/drm/imx/ipuv3-plane.c | 67 ++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 29 deletions(-)
drivers/gpu/drm/imx/ipuv3-plane.c +38 -29
@@ -199,37 +199,46 @@ int ipu_plane_mode_set(struct ipu_plane *ipu_plane, struct drm_crtc *crtc,if (src_w != crtc_w || src_h != crtc_h)return -EINVAL ; -/* clip to crtc bounds */ -if (crtc_x <0 ) { -if (-crtc_x > crtc_w) +if (ipu_plane->base.type ==DRM_PLANE_TYPE_PRIMARY ) { +/* full plane doesn't support partial off screen */ +if (crtc_x || crtc_y || crtc_w != mode->hdisplay || + crtc_h != mode->vdisplay)return -EINVAL ; - src_x += -crtc_x; - src_w -= -crtc_x; - crtc_w -= -crtc_x; - crtc_x =0 ; - } -if (crtc_y <0 ) { -if (-crtc_y > crtc_h) -return -EINVAL ; - src_y += -crtc_y; - src_h -= -crtc_y; - crtc_h -= -crtc_y; - crtc_y =0 ; - } -if (crtc_x + crtc_w > mode->hdisplay) { -if (crtc_x > mode->hdisplay) -return -EINVAL ; - crtc_w = mode->hdisplay - crtc_x; - src_w = crtc_w; - } -if (crtc_y + crtc_h > mode->vdisplay) { -if (crtc_y > mode->vdisplay) + +/* full plane minimum width is 13 pixels */ +if (crtc_w <13 )return -EINVAL ; - crtc_h = mode->vdisplay - crtc_y; - src_h = crtc_h; - } -/* full plane minimum width is 13 pixels */ -if (crtc_w <13 && (ipu_plane->dp_flow !=IPU_DP_FLOW_SYNC_FG )) + }else if (ipu_plane->base.type ==DRM_PLANE_TYPE_OVERLAY ) { +/* clip to crtc bounds */ +if (crtc_x <0 ) { +if (-crtc_x > crtc_w) +return -EINVAL ; + src_x += -crtc_x; + src_w -= -crtc_x; + crtc_w -= -crtc_x; + crtc_x =0 ; + } +if (crtc_y <0 ) { +if (-crtc_y > crtc_h) +return -EINVAL ; + src_y += -crtc_y; + src_h -= -crtc_y; + crtc_h -= -crtc_y; + crtc_y =0 ; + } +if (crtc_x + crtc_w > mode->hdisplay) { +if (crtc_x > mode->hdisplay) +return -EINVAL ; + crtc_w = mode->hdisplay - crtc_x; + src_w = crtc_w; + } +if (crtc_y + crtc_h > mode->vdisplay) { +if (crtc_y > mode->vdisplay) +return -EINVAL ; + crtc_h = mode->vdisplay - crtc_y; + src_h = crtc_h; + } + }else return -EINVAL ;if (crtc_h <2 )return -EINVAL ;
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 2/10 gpu: ipu-v3: ipu-dmfc: Use static DMFC FIFO allocation mechanism
In reply to Liu YingFor all video modes we support currently, we always get 2 slots for a plane by using the current existing dynamic DMFC FIFO allocation mechanism. So, let's change to use the static one to simplify the code. This also makes it easier to implement the atomic mode setting as we don't need to handle allocation failure cases then.
---v3->v4:
* None.
v2->v3:
* None.
v1->v2:
* Improve the commit message to better explain why the static allocation mechanism can replace the dynamic one.
drivers/gpu/drm/imx/ipuv3-plane.c | 26 ----- drivers/gpu/ipu-v3/ipu-dmfc.c | 213 ++------------------------------------ include/video/imx-ipu-v3.h | 3 - 3 files changed, 7 insertions(+), 235 deletions(-)
drivers/gpu/drm/imx/ipuv3-plane.c +0 -26
@@ -53,24 +53,6 @@ int ipu_plane_irq(struct ipu_plane *ipu_plane) IPU_IRQ_EOF); } -static int calc_vref (struct drm_display_mode *mode) -{ -unsigned long htotal, vtotal; - - htotal = mode->htotal; - vtotal = mode->vtotal; - -if (!htotal || !vtotal) -return 60 ; - -return DIV_ROUND_UP (mode->clock *1000 , vtotal * htotal); -} - -static inline int calc_bandwidth (int width,int height,unsigned int vref) -{ -return width * height * vref; -} -int ipu_plane_set_base (struct ipu_plane *ipu_plane,struct drm_framebuffer *fb,int x,int y) {
@@ -291,14 +273,6 @@ int ipu_plane_mode_set(struct ipu_plane *ipu_plane, struct drm_crtc *crtc, } } - ret =ipu_dmfc_alloc_bandwidth (ipu_plane->dmfc, -calc_bandwidth (crtc_w, crtc_h, -calc_vref (mode)),64 ); -if (ret) { -dev_err (dev,"allocating dmfc bandwidth failed with %d\n" , ret); -return ret; - } -ipu_dmfc_config_wait4eot (ipu_plane->dmfc, crtc_w);ipu_cpmem_zero (ipu_plane->ipu_ch);
drivers/gpu/ipu-v3/ipu-dmfc.c +7 -206
251 lines not on this page · raw message
include/video/imx-ipu-v3.h +0 -3
@@ -235,9 +235,6 @@ int ipu_di_init_sync_panel(struct ipu_di *, struct ipu_di_signal_cfg *sig);struct dmfc_channel ;int ipu_dmfc_enable_channel (struct dmfc_channel *dmfc);void ipu_dmfc_disable_channel (struct dmfc_channel *dmfc); -int ipu_dmfc_alloc_bandwidth (struct dmfc_channel *dmfc, -unsigned long bandwidth_mbs,int burstsize); -void ipu_dmfc_free_bandwidth (struct dmfc_channel *dmfc);void ipu_dmfc_config_wait4eot (struct dmfc_channel *dmfc,int width);struct dmfc_channel *ipu_dmfc_get (struct ipu_soc *ipu,int ipuv3_channel);void ipu_dmfc_put (struct dmfc_channel *dmfc);
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 3/10 drm/imx: atomic phase 1: Use transitional atomic CRTC and plane helpers
In reply to Liu YingUse the drm_plane_helper_update/disable() and drm_helper_crtc_mode_set() transitional atomic helpers. The crtc->mode_set_nofb callback is added so that the primary plane is no longer tied to the CRTC. Check/update logics are separated to make sure crtc->mode_set_nofb and plane->atomic_update are always successful. Also, some necessary logics are tweaked for a smooth transition.
---v3->v4:
* Staticize ipu_plane_atomic_set_base().
v2->v3:
* A minor change to simplify the way we find crtc->enabled in drm_plane_helper_funcs->atomic_check.
v1->v2:
* Get the overlay ipu plane resource when initializing the relevant CRTC and do not get ipu plane resource any more when updating plane to avoid resource allocation failure.
* Remove obsolete comments from ipu_crtc_enable/disable().
drivers/gpu/drm/imx/ipuv3-crtc.c | 197 ++++++++------- drivers/gpu/drm/imx/ipuv3-plane.c | 511 +++++++++++++++++++++++--------------- drivers/gpu/drm/imx/ipuv3-plane.h | 16 +- drivers/gpu/ipu-v3/ipu-dc.c | 5 +- drivers/gpu/ipu-v3/ipu-di.c | 3 - 5 files changed, 410 insertions(+), 322 deletions(-)
drivers/gpu/drm/imx/ipuv3-crtc.c +103 -94
@@ -73,7 +73,7 @@ struct ipu_crtc {#define to_ipu_crtc (x) container_of(x, struct ipu_crtc, base) -static void ipu_fb_enable (struct ipu_crtc *ipu_crtc) +static void ipu_crtc_enable (struct ipu_crtc *ipu_crtc) {struct ipu_soc *ipu =dev_get_drvdata (ipu_crtc->dev->parent);
@@ -81,30 +81,30 @@ static void ipu_fb_enable(struct ipu_crtc *ipu_crtc)return ;ipu_dc_enable (ipu); -ipu_plane_enable (ipu_crtc->plane[0 ]); -/* Start DC channel and DI after IDMAC */ ipu_dc_enable_channel (ipu_crtc->dc);ipu_di_enable (ipu_crtc->di); -drm_crtc_vblank_on (&ipu_crtc->base); - ipu_crtc->enabled =1 ; + +/* +* In order not to be warned on enabling vblank failure, +* we should call drm_crtc_vblank_on() after ->enabled is set to 1. +*/ +drm_crtc_vblank_on (&ipu_crtc->base); } -static void ipu_fb_disable (struct ipu_crtc *ipu_crtc) +static void ipu_crtc_disable (struct ipu_crtc *ipu_crtc) {struct ipu_soc *ipu =dev_get_drvdata (ipu_crtc->dev->parent);if (!ipu_crtc->enabled)return ; -/* Stop DC channel and DI before IDMAC */ ipu_dc_disable_channel (ipu_crtc->dc);ipu_di_disable (ipu_crtc->di); -ipu_plane_disable (ipu_crtc->plane[0 ]);ipu_dc_disable (ipu); -drm_crtc_vblank_off (&ipu_crtc->base); - ipu_crtc->enabled =0 ; + +drm_crtc_vblank_off (&ipu_crtc->base); }static void ipu_crtc_dpms (struct drm_crtc *crtc,int mode)
@@ -115,12 +115,12 @@ static void ipu_crtc_dpms(struct drm_crtc *crtc, int mode)switch (mode) {case DRM_MODE_DPMS_ON : -ipu_fb_enable (ipu_crtc); +ipu_crtc_enable (ipu_crtc);break ;case DRM_MODE_DPMS_STANDBY :case DRM_MODE_DPMS_SUSPEND :case DRM_MODE_DPMS_OFF : -ipu_fb_disable (ipu_crtc); +ipu_crtc_disable (ipu_crtc);break ; } }
@@ -234,79 +234,6 @@ static const struct drm_crtc_funcs ipu_crtc_funcs = { .page_flip = ipu_page_flip, }; -static int ipu_crtc_mode_set (struct drm_crtc *crtc, -struct drm_display_mode *orig_mode, -struct drm_display_mode *mode, -int x,int y, -struct drm_framebuffer *old_fb) -{ -struct drm_device *dev = crtc->dev; -struct drm_encoder *encoder; -struct ipu_crtc *ipu_crtc =to_ipu_crtc (crtc); -struct ipu_di_signal_cfg sig_cfg = {}; -unsigned long encoder_types =0 ; -int ret; - -dev_dbg (ipu_crtc->dev,"%s: mode->hdisplay: %d\n" , __func__, - mode->hdisplay); -dev_dbg (ipu_crtc->dev,"%s: mode->vdisplay: %d\n" , __func__, - mode->vdisplay); - -list_for_each_entry (encoder, &dev->mode_config.encoder_list, head) -if (encoder->crtc == crtc) - encoder_types |=BIT (encoder->encoder_type); - -dev_dbg (ipu_crtc->dev,"%s: attached to encoder types 0x%lx\n" , - __func__, encoder_types); - -/* -* If we have DAC or LDB, then we need the IPU DI clock to be -* the same as the LDB DI clock. For TVDAC, derive the IPU DI -* clock from 27 MHz TVE_DI clock, but allow to divide it. -*/ -if (encoder_types & (BIT (DRM_MODE_ENCODER_DAC ) | -BIT (DRM_MODE_ENCODER_LVDS ))) - sig_cfg.clkflags =IPU_DI_CLKMODE_SYNC |IPU_DI_CLKMODE_EXT ; -else if (encoder_types &BIT (DRM_MODE_ENCODER_TVDAC )) - sig_cfg.clkflags =IPU_DI_CLKMODE_EXT ; -else - sig_cfg.clkflags =0 ; - - sig_cfg.enable_pol = !(ipu_crtc->bus_flags &DRM_BUS_FLAG_DE_LOW ); -/* Default to driving pixel data on negative clock edges */ - sig_cfg.clk_pol = !!(ipu_crtc->bus_flags & -DRM_BUS_FLAG_PIXDATA_POSEDGE ); - sig_cfg.bus_format = ipu_crtc->bus_format; - sig_cfg.v_to_h_sync =0 ; - sig_cfg.hsync_pin = ipu_crtc->di_hsync_pin; - sig_cfg.vsync_pin = ipu_crtc->di_vsync_pin; - -drm_display_mode_to_videomode (mode, &sig_cfg.mode); - - ret =ipu_dc_init_sync (ipu_crtc->dc, ipu_crtc->di, - mode->flags &DRM_MODE_FLAG_INTERLACE , - ipu_crtc->bus_format, mode->hdisplay); -if (ret) { -dev_err (ipu_crtc->dev, -"initializing display controller failed with %d\n" , - ret); -return ret; - } - - ret =ipu_di_init_sync_panel (ipu_crtc->di, &sig_cfg); -if (ret) { -dev_err (ipu_crtc->dev, -"initializing panel failed with %d\n" , ret); -return ret; - } - -return ipu_plane_mode_set (ipu_crtc->plane[0 ], crtc, mode, - crtc->primary->fb, -0 ,0 , mode->hdisplay, mode->vdisplay, - x, y, mode->hdisplay, mode->vdisplay, - mode->flags &DRM_MODE_FLAG_INTERLACE ); -} -static void ipu_crtc_handle_pageflip (struct ipu_crtc *ipu_crtc) {unsigned long flags;
@@ -330,8 +257,7 @@ static irqreturn_t ipu_irq_handler(int irq, void *dev_id)if (ipu_crtc->flip_state ==IPU_FLIP_SUBMITTED ) {struct ipu_plane *plane = ipu_crtc->plane[0 ]; -ipu_plane_set_base (plane, ipu_crtc->base.primary->fb, - plane->x, plane->y); +ipu_plane_set_base (plane, ipu_crtc->base.primary->fb);ipu_crtc_handle_pageflip (ipu_crtc);queue_work (ipu_crtc->flip_queue, &ipu_crtc->flip_work->unref_work);
@@ -355,6 +281,9 @@ static bool ipu_crtc_mode_fixup(struct drm_crtc *crtc,if (ret)return false; +if ((vm.vsync_len ==0 ) || (vm.hsync_len ==0 )) +return false; +drm_display_mode_from_videomode (&vm, adjusted_mode);return true;
@@ -364,28 +293,95 @@ static void ipu_crtc_prepare(struct drm_crtc *crtc) {struct ipu_crtc *ipu_crtc =to_ipu_crtc (crtc); -ipu_fb_disable (ipu_crtc); +ipu_crtc_disable (ipu_crtc); }static void ipu_crtc_commit (struct drm_crtc *crtc) {struct ipu_crtc *ipu_crtc =to_ipu_crtc (crtc); -ipu_fb_enable (ipu_crtc); +ipu_crtc_enable (ipu_crtc); +} + +static int ipu_crtc_atomic_check (struct drm_crtc *crtc, +struct drm_crtc_state *state) +{ +return 0 ; +} + +static void ipu_crtc_mode_set_nofb (struct drm_crtc *crtc) +{ +struct drm_device *dev = crtc->dev; +struct drm_encoder *encoder; +struct ipu_crtc *ipu_crtc =to_ipu_crtc (crtc); +struct drm_display_mode *mode = &crtc->state->adjusted_mode; +struct ipu_di_signal_cfg sig_cfg = {}; +unsigned long encoder_types =0 ; + +dev_dbg (ipu_crtc->dev,"%s: mode->hdisplay: %d\n" , __func__, + mode->hdisplay); +dev_dbg (ipu_crtc->dev,"%s: mode->vdisplay: %d\n" , __func__, + mode->vdisplay); + +list_for_each_entry (encoder, &dev->mode_config.encoder_list, head) +if (encoder->crtc == crtc) + encoder_types |=BIT (encoder->encoder_type); + +dev_dbg (ipu_crtc->dev,"%s: attached to encoder types 0x%lx\n" , + __func__, encoder_types); + +/* +* If we have DAC or LDB, then we need the IPU DI clock to be +* the same as the LDB DI clock. For TVDAC, derive the IPU DI +* clock from 27 MHz TVE_DI clock, but allow to divide it. +*/ +if (encoder_types & (BIT (DRM_MODE_ENCODER_DAC ) | +BIT (DRM_MODE_ENCODER_LVDS ))) + sig_cfg.clkflags =IPU_DI_CLKMODE_SYNC |IPU_DI_CLKMODE_EXT ; +else if (encoder_types &BIT (DRM_MODE_ENCODER_TVDAC )) + sig_cfg.clkflags =IPU_DI_CLKMODE_EXT ; +else + sig_cfg.clkflags =0 ; + + sig_cfg.enable_pol = !(ipu_crtc->bus_flags &DRM_BUS_FLAG_DE_LOW ); +/* Default to driving pixel data on negative clock edges */ + sig_cfg.clk_pol = !!(ipu_crtc->bus_flags & +DRM_BUS_FLAG_PIXDATA_POSEDGE ); + sig_cfg.bus_format = ipu_crtc->bus_format; + sig_cfg.v_to_h_sync =0 ; + sig_cfg.hsync_pin = ipu_crtc->di_hsync_pin; + sig_cfg.vsync_pin = ipu_crtc->di_vsync_pin; + +drm_display_mode_to_videomode (mode, &sig_cfg.mode); + +ipu_dc_init_sync (ipu_crtc->dc, ipu_crtc->di, + mode->flags &DRM_MODE_FLAG_INTERLACE , + ipu_crtc->bus_format, mode->hdisplay); +ipu_di_init_sync_panel (ipu_crtc->di, &sig_cfg); }static const struct drm_crtc_helper_funcs ipu_helper_funcs = { .dpms = ipu_crtc_dpms, .mode_fixup = ipu_crtc_mode_fixup, - .mode_set = ipu_crtc_mode_set, + .mode_set = drm_helper_crtc_mode_set, + .mode_set_nofb = ipu_crtc_mode_set_nofb, .prepare = ipu_crtc_prepare, .commit = ipu_crtc_commit, + .atomic_check = ipu_crtc_atomic_check, };static int ipu_enable_vblank (struct drm_crtc *crtc) {struct ipu_crtc *ipu_crtc =to_ipu_crtc (crtc); +/* +* ->commit is done after ->mode_set in drm_crtc_helper_set_mode(), +* so waiting for vblank in drm_plane_helper_commit() will timeout. +* Check the state here to avoid the waiting. +*/ +if (!ipu_crtc->enabled) +return -EINVAL ; +enable_irq (ipu_crtc->irq);return 0 ;
@@ -496,8 +492,16 @@ static int ipu_crtc_init(struct ipu_crtc *ipu_crtc,IPU_DP_FLOW_SYNC_FG ,drm_crtc_mask (&ipu_crtc->base), DRM_PLANE_TYPE_OVERLAY); -if (IS_ERR (ipu_crtc->plane[1 ])) +if (IS_ERR (ipu_crtc->plane[1 ])) { ipu_crtc->plane[1 ] =NULL ; + }else { + ret =ipu_plane_get_resources (ipu_crtc->plane[1 ]); +if (ret) { +dev_err (ipu_crtc->dev,"getting plane 1 " +"resources failed with %d.\n" , ret); + goto err_put_plane0_res; + } + } } ipu_crtc->irq =ipu_plane_irq (ipu_crtc->plane[0 ]);
@@ -505,7 +509,7 @@ static int ipu_crtc_init(struct ipu_crtc *ipu_crtc, "imx_drm", ipu_crtc);if (ret <0 ) {dev_err (ipu_crtc->dev,"irq request failed with %d.\n" , ret); - goto err_put_plane_res; + goto err_put_plane1_res; }/* Only enable IRQ when we actually need it to trigger work. */ disable_irq (ipu_crtc->irq);
@@ -514,7 +518,10 @@ static int ipu_crtc_init(struct ipu_crtc *ipu_crtc,return 0 ; -err_put_plane_res: +err_put_plane1_res: +if (ipu_crtc->plane[1 ]) +ipu_plane_put_resources (ipu_crtc->plane[1 ]); +err_put_plane0_res:ipu_plane_put_resources (ipu_crtc->plane[0 ]); err_remove_crtc:imx_drm_remove_crtc (ipu_crtc->imx_crtc);
@@ -554,8 +561,10 @@ static void ipu_drm_unbind(struct device *dev, struct device *master,imx_drm_remove_crtc (ipu_crtc->imx_crtc);destroy_workqueue (ipu_crtc->flip_queue); -ipu_plane_put_resources (ipu_crtc->plane[0 ]);ipu_put_resources (ipu_crtc); +if (ipu_crtc->plane[1 ]) +ipu_plane_put_resources (ipu_crtc->plane[1 ]); +ipu_plane_put_resources (ipu_crtc->plane[0 ]); }static const struct component_ops ipu_crtc_ops = {
drivers/gpu/drm/imx/ipuv3-plane.c +305 -206
636 lines not on this page · raw message
drivers/gpu/drm/imx/ipuv3-plane.h +1 -15
@@ -23,17 +23,6 @@ struct ipu_plane {int dma;int dp_flow; - -int x; -int y; -int w; -int h; - -unsigned int u_offset; -unsigned int v_offset; -unsigned int stride[2 ]; - -bool enabled; }; struct ipu_plane *ipu_plane_init(struct drm_device *dev, struct ipu_soc *ipu,
@@ -48,10 +37,7 @@ int ipu_plane_mode_set(struct ipu_plane *plane, struct drm_crtc *crtc, uint32_t src_x, uint32_t src_y, uint32_t src_w, uint32_t src_h, bool interlaced); -void ipu_plane_enable (struct ipu_plane *plane); -void ipu_plane_disable (struct ipu_plane *plane); -int ipu_plane_set_base (struct ipu_plane *plane,struct drm_framebuffer *fb, -int x,int y); +int ipu_plane_set_base (struct ipu_plane *plane,struct drm_framebuffer *fb);int ipu_plane_get_resources (struct ipu_plane *plane);void ipu_plane_put_resources (struct ipu_plane *plane);
drivers/gpu/ipu-v3/ipu-dc.c +1 -4
@@ -178,10 +178,7 @@ int ipu_dc_init_sync(struct ipu_dc *dc, struct ipu_di *di, bool interlaced, dc->di =ipu_di_get_num (di); map =ipu_bus_format_to_map (bus_format); -if (map <0 ) { -dev_dbg (priv->dev,"IPU_DISP: No MAP\n" ); -return map; - } +BUG_ON (map <0 );/* * In interlaced mode we need more counters to create the asymmetric
drivers/gpu/ipu-v3/ipu-di.c +0 -3
@@ -572,9 +572,6 @@ int ipu_di_init_sync_panel(struct ipu_di *di, struct ipu_di_signal_cfg *sig)dev_dbg (di->ipu->dev,"disp %d: panel size = %d x %d\n" , di->id, sig->mode.hactive, sig->mode.vactive); -if ((sig->mode.vsync_len ==0 ) || (sig->mode.hsync_len ==0 )) -return -EINVAL ; - dev_dbg(di->ipu->dev, "Clocks: IPU %luHz DI %luHz Needed %luHz\n", clk_get_rate(di->clk_ipu), clk_get_rate(di->clk_di),
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 4/10 drm/imx: atomic phase 2 step 1: Wire up state ->reset, ->duplicate and ->destroy
In reply to Liu YingWire up CRTCs', planes' and connectors' ->reset, ->duplicate and ->destroy state hooks to use the default implementations from the atomic helper library. The helpers track each DRM object state.
---v3->v4:
* None.
v2->v3:
* For dw-hdmi bridge driver, simply add the hooks to the legacy connector function structure instead of using the atomic version directly, because we are not yet ready to use the atomic version's ->dpms hook.
v1->v2:
* Remove the 'atomic' from the name of the structure dw_hdmi_atomic_connector_funcs to address Philipp's comment.
drivers/gpu/drm/bridge/dw-hdmi.c | 3 +++ drivers/gpu/drm/imx/imx-drm-core.c | 2 ++ drivers/gpu/drm/imx/imx-ldb.c | 4 ++++ drivers/gpu/drm/imx/imx-tve.c | 4 ++++ drivers/gpu/drm/imx/ipuv3-crtc.c | 4 ++++ drivers/gpu/drm/imx/ipuv3-plane.c | 4 ++++ drivers/gpu/drm/imx/parallel-display.c | 4 ++++ 7 files changed, 25 insertions(+)
drivers/gpu/drm/bridge/dw-hdmi.c +3 -0
@@ -1500,6 +1500,9 @@ static const struct drm_connector_funcs dw_hdmi_connector_funcs = { .detect = dw_hdmi_connector_detect, .destroy = dw_hdmi_connector_destroy, .force = dw_hdmi_connector_force, + .reset = drm_atomic_helper_connector_reset, + .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, };static const struct drm_connector_funcs dw_hdmi_atomic_connector_funcs = {
drivers/gpu/drm/imx/imx-drm-core.c +2 -0
@@ -279,6 +279,8 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags) } } +drm_mode_config_reset (drm); +/* * All components are now initialised, so setup the fb helper. * The fb helper takes copies of key hardware information, so the
drivers/gpu/drm/imx/imx-ldb.c +4 -0
@@ -17,6 +17,7 @@#include <linux/clk.h> #include <linux/component.h> #include <drm/drmP.h> +#include <drm/drm_atomic_helper.h> #include <drm/drm_fb_helper.h> #include <drm/drm_crtc_helper.h> #include <drm/drm_of.h>
@@ -362,6 +363,9 @@ static const struct drm_connector_funcs imx_ldb_connector_funcs = { .fill_modes = drm_helper_probe_single_connector_modes, .detect = imx_ldb_connector_detect, .destroy = imx_drm_connector_destroy, + .reset = drm_atomic_helper_connector_reset, + .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, };static const struct drm_connector_helper_funcs imx_ldb_connector_helper_funcs = {
drivers/gpu/drm/imx/imx-tve.c +4 -0
@@ -23,6 +23,7 @@#include <linux/spinlock.h> #include <linux/videodev2.h> #include <drm/drmP.h> +#include <drm/drm_atomic_helper.h> #include <drm/drm_fb_helper.h> #include <drm/drm_crtc_helper.h> #include <video/imx-ipu-v3.h>
@@ -360,6 +361,9 @@ static const struct drm_connector_funcs imx_tve_connector_funcs = { .fill_modes = drm_helper_probe_single_connector_modes, .detect = imx_tve_connector_detect, .destroy = imx_drm_connector_destroy, + .reset = drm_atomic_helper_connector_reset, + .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, };static const struct drm_connector_helper_funcs imx_tve_connector_helper_funcs = {
drivers/gpu/drm/imx/ipuv3-crtc.c +4 -0
@@ -18,6 +18,7 @@#include <linux/device.h> #include <linux/platform_device.h> #include <drm/drmP.h> +#include <drm/drm_atomic_helper.h> #include <drm/drm_crtc_helper.h> #include <linux/fb.h> #include <linux/clk.h>
@@ -232,6 +233,9 @@ static const struct drm_crtc_funcs ipu_crtc_funcs = { .set_config = drm_crtc_helper_set_config, .destroy = drm_crtc_cleanup, .page_flip = ipu_page_flip, + .reset = drm_atomic_helper_crtc_reset, + .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, };static void ipu_crtc_handle_pageflip (struct ipu_crtc *ipu_crtc)
drivers/gpu/drm/imx/ipuv3-plane.c +4 -0
@@ -14,6 +14,7 @@*/ #include <drm/drmP.h> +#include <drm/drm_atomic_helper.h> #include <drm/drm_fb_cma_helper.h> #include <drm/drm_gem_cma_helper.h> #include <drm/drm_plane_helper.h>
@@ -362,6 +363,9 @@ static const struct drm_plane_funcs ipu_plane_funcs = { .update_plane = drm_plane_helper_update, .disable_plane = drm_plane_helper_disable, .destroy = ipu_plane_destroy, + .reset = drm_atomic_helper_plane_reset, + .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, }; static int ipu_plane_atomic_check(struct drm_plane *plane,
drivers/gpu/drm/imx/parallel-display.c +4 -0
@@ -16,6 +16,7 @@#include <linux/component.h> #include <linux/module.h> #include <drm/drmP.h> +#include <drm/drm_atomic_helper.h> #include <drm/drm_fb_helper.h> #include <drm/drm_crtc_helper.h> #include <drm/drm_panel.h>
@@ -134,6 +135,9 @@ static const struct drm_connector_funcs imx_pd_connector_funcs = { .fill_modes = drm_helper_probe_single_connector_modes, .detect = imx_pd_connector_detect, .destroy = imx_drm_connector_destroy, + .reset = drm_atomic_helper_connector_reset, + .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, };static const struct drm_connector_helper_funcs imx_pd_connector_helper_funcs = {
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 5/10 drm/imx: atomic phase 2 step 2: Track plane_state->fb correctly in ->page_flip
In reply to Liu YingUse drm_atomic_set_fb_for_plane() in the legacy ->page_flip path to track the pointer plane_state->fb correctly.
---v3->v4:
* None.
v2->v3:
* None.
v1->v2:
* None.
drivers/gpu/drm/imx/ipuv3-crtc.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/imx/ipuv3-crtc.c +4 -0
@@ -18,6 +18,7 @@#include <linux/device.h> #include <linux/platform_device.h> #include <drm/drmP.h> +#include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> #include <drm/drm_crtc_helper.h> #include <linux/fb.h>
@@ -217,6 +218,9 @@ static int ipu_page_flip(struct drm_crtc *crtc, ipu_crtc->flip_state =IPU_FLIP_SUBMITTED ; } +if (crtc->primary->state) +drm_atomic_set_fb_for_plane (crtc->primary->state, fb); +return 0 ; free_flip_work:
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 6/10 drm/imx: Remove encoders' ->prepare callbacks
In reply to Liu YingThe main task of imx encoders' ->prepare callbacks is to set bus_format, bus_flags, di_vsync_pin and di_hsync_pin. We may create a structure named imx_encoder to cache them. The atomic encoder callback ->disable may replace ->prepare later, so let's remove ->prepare.
---v3->v4:
* Fix wrong LVDS bus format translation issue in imx_ldb_connector_get_modes() so that bus format could be determined by panel instead of device tree.
This issue was found by Philipp Zabel.
v2->v3:
* Newly introduced.
The logic is picked from patch 07/10 in v2 to generate a self-contained patch.
drivers/gpu/drm/imx/dw_hdmi-imx.c | 18 ++--- drivers/gpu/drm/imx/imx-drm-core.c | 39 ----------- drivers/gpu/drm/imx/imx-drm.h | 18 ++--- drivers/gpu/drm/imx/imx-ldb.c | 118 +++++++++++++++++---------------- drivers/gpu/drm/imx/imx-tve.c | 58 ++++++---------- drivers/gpu/drm/imx/ipuv3-crtc.c | 38 ++++------- drivers/gpu/drm/imx/parallel-display.c | 56 ++++++++-------- 7 files changed, 142 insertions(+), 203 deletions(-)
drivers/gpu/drm/imx/dw_hdmi-imx.c +9 -9
@@ -22,9 +22,11 @@#include "imx-drm.h" +#define imx_enc_to_imx_hdmi (x) container_of(x, struct imx_hdmi, imx_encoder) +struct imx_hdmi {struct device *dev; -struct drm_encoder encoder; +struct imx_drm_encoder imx_encoder;struct regmap *regmap; };
@@ -117,7 +119,8 @@ static void dw_hdmi_imx_encoder_mode_set(struct drm_encoder *encoder,static void dw_hdmi_imx_encoder_commit (struct drm_encoder *encoder) { - struct imx_hdmi *hdmi = container_of(encoder, struct imx_hdmi, encoder); +struct imx_drm_encoder *imx_encoder =enc_to_imx_enc (encoder); +struct imx_hdmi *hdmi =imx_enc_to_imx_hdmi (imx_encoder);int mux =drm_of_encoder_active_port_id (hdmi->dev->of_node, encoder); regmap_update_bits(hdmi->regmap, IOMUXC_GPR3,
@@ -125,14 +128,8 @@ static void dw_hdmi_imx_encoder_commit(struct drm_encoder *encoder) mux << IMX6Q_GPR3_HDMI_MUX_CTL_SHIFT); } -static void dw_hdmi_imx_encoder_prepare (struct drm_encoder *encoder) -{ -imx_drm_set_bus_format (encoder,MEDIA_BUS_FMT_RGB888_1X24 ); -} -static const struct drm_encoder_helper_funcs dw_hdmi_imx_encoder_helper_funcs = { .mode_set = dw_hdmi_imx_encoder_mode_set, - .prepare = dw_hdmi_imx_encoder_prepare, .commit = dw_hdmi_imx_encoder_commit, .disable = dw_hdmi_imx_encoder_disable, };
@@ -215,7 +212,10 @@ static int dw_hdmi_imx_bind(struct device *dev, struct device *master, match =of_match_node (dw_hdmi_imx_dt_ids, pdev->dev.of_node); plat_data = match->data; hdmi->dev = &pdev->dev; - encoder = &hdmi->encoder; + encoder = &hdmi->imx_encoder.encoder; + hdmi->imx_encoder.bus_format =MEDIA_BUS_FMT_RGB888_1X24 ; + hdmi->imx_encoder.di_hsync_pin =2 ; + hdmi->imx_encoder.di_vsync_pin =3 ; irq =platform_get_irq (pdev,0 );if (irq <0 )
drivers/gpu/drm/imx/imx-drm-core.c +0 -39
@@ -85,45 +85,6 @@ static int imx_drm_driver_unload(struct drm_device *drm)return 0 ; } -static struct imx_drm_crtc *imx_drm_find_crtc (struct drm_crtc *crtc) -{ -struct imx_drm_device *imxdrm = crtc->dev->dev_private; -unsigned i; - -for (i =0 ; i <MAX_CRTC ; i++) -if (imxdrm->crtc[i] && imxdrm->crtc[i]->crtc == crtc) -return imxdrm->crtc[i]; - -return NULL ; -} - -int imx_drm_set_bus_config (struct drm_encoder *encoder,u32 bus_format, -int hsync_pin,int vsync_pin,u32 bus_flags) -{ -struct imx_drm_crtc_helper_funcs *helper; -struct imx_drm_crtc *imx_crtc; - - imx_crtc =imx_drm_find_crtc (encoder->crtc); -if (!imx_crtc) -return -EINVAL ; - - helper = &imx_crtc->imx_drm_helper_funcs; -if (helper->set_interface_pix_fmt) -return helper->set_interface_pix_fmt (encoder->crtc, - bus_format, hsync_pin, vsync_pin, - bus_flags); -return 0 ; -} -EXPORT_SYMBOL_GPL (imx_drm_set_bus_config); - -int imx_drm_set_bus_format (struct drm_encoder *encoder,u32 bus_format) -{ -return imx_drm_set_bus_config (encoder, bus_format,2 ,3 , -DRM_BUS_FLAG_DE_HIGH | -DRM_BUS_FLAG_PIXDATA_NEGEDGE ); -} -EXPORT_SYMBOL_GPL (imx_drm_set_bus_format); -int imx_drm_crtc_vblank_get (struct imx_drm_crtc *imx_drm_crtc) {return drm_crtc_vblank_get (imx_drm_crtc->crtc);
drivers/gpu/drm/imx/imx-drm.h +10 -8
@@ -15,12 +15,19 @@ struct platform_device;unsigned int imx_drm_crtc_id (struct imx_drm_crtc *crtc); +struct imx_drm_encoder { +struct drm_encoder encoder; +u32 bus_format; +u32 bus_flags; +int di_hsync_pin; +int di_vsync_pin; +}; + +#define enc_to_imx_enc (x) container_of(x, struct imx_drm_encoder, encoder) +struct imx_drm_crtc_helper_funcs {int (*enable_vblank)(struct drm_crtc *crtc);void (*disable_vblank)(struct drm_crtc *crtc); -int (*set_interface_pix_fmt)(struct drm_crtc *crtc, -u32 bus_format,int hsync_pin,int vsync_pin, -u32 bus_flags);const struct drm_crtc_helper_funcs *crtc_helper_funcs;const struct drm_crtc_funcs *crtc_funcs; };
@@ -42,11 +49,6 @@ void imx_drm_mode_config_init(struct drm_device *drm);struct drm_gem_cma_object *imx_drm_fb_get_obj (struct drm_framebuffer *fb); -int imx_drm_set_bus_config (struct drm_encoder *encoder,u32 bus_format, -int hsync_pin,int vsync_pin,u32 bus_flags); -int imx_drm_set_bus_format (struct drm_encoder *encoder, -u32 bus_format); -int imx_drm_encoder_parse_of (struct drm_device *drm,struct drm_encoder *encoder,struct device_node *np);
drivers/gpu/drm/imx/imx-ldb.c +60 -58
226 lines not on this page · raw message
drivers/gpu/drm/imx/imx-tve.c +22 -36
153 lines not on this page · raw message
drivers/gpu/drm/imx/ipuv3-crtc.c +12 -26
@@ -67,10 +67,6 @@ struct ipu_crtc {struct workqueue_struct *flip_queue;struct ipu_flip_work *flip_work;int irq; -u32 bus_format; -u32 bus_flags; -int di_hsync_pin; -int di_vsync_pin; };#define to_ipu_crtc (x) container_of(x, struct ipu_crtc, base)
@@ -321,6 +317,7 @@ static void ipu_crtc_mode_set_nofb(struct drm_crtc *crtc) {struct drm_device *dev = crtc->dev;struct drm_encoder *encoder; +struct imx_drm_encoder *imx_encoder =NULL ;struct ipu_crtc *ipu_crtc =to_ipu_crtc (crtc);struct drm_display_mode *mode = &crtc->state->adjusted_mode;struct ipu_di_signal_cfg sig_cfg = {};
@@ -331,9 +328,12 @@ static void ipu_crtc_mode_set_nofb(struct drm_crtc *crtc)dev_dbg (ipu_crtc->dev,"%s: mode->vdisplay: %d\n" , __func__, mode->vdisplay); -list_for_each_entry (encoder, &dev->mode_config.encoder_list, head) -if (encoder->crtc == crtc) +list_for_each_entry (encoder, &dev->mode_config.encoder_list, head) { +if (encoder->crtc == crtc) { encoder_types |=BIT (encoder->encoder_type); + imx_encoder =enc_to_imx_enc (encoder); + } + }dev_dbg (ipu_crtc->dev,"%s: attached to encoder types 0x%lx\n" , __func__, encoder_types);
@@ -351,20 +351,20 @@ static void ipu_crtc_mode_set_nofb(struct drm_crtc *crtc)else sig_cfg.clkflags =0 ; - sig_cfg.enable_pol = !(ipu_crtc->bus_flags &DRM_BUS_FLAG_DE_LOW ); + sig_cfg.enable_pol = !(imx_encoder->bus_flags &DRM_BUS_FLAG_DE_LOW );/* Default to driving pixel data on negative clock edges */ - sig_cfg.clk_pol = !!(ipu_crtc->bus_flags & + sig_cfg.clk_pol = !!(imx_encoder->bus_flags &DRM_BUS_FLAG_PIXDATA_POSEDGE ); - sig_cfg.bus_format = ipu_crtc->bus_format; + sig_cfg.bus_format = imx_encoder->bus_format; sig_cfg.v_to_h_sync =0 ; - sig_cfg.hsync_pin = ipu_crtc->di_hsync_pin; - sig_cfg.vsync_pin = ipu_crtc->di_vsync_pin; + sig_cfg.hsync_pin = imx_encoder->di_hsync_pin; + sig_cfg.vsync_pin = imx_encoder->di_vsync_pin;drm_display_mode_to_videomode (mode, &sig_cfg.mode);ipu_dc_init_sync (ipu_crtc->dc, ipu_crtc->di, mode->flags &DRM_MODE_FLAG_INTERLACE , - ipu_crtc->bus_format, mode->hdisplay); + imx_encoder->bus_format, mode->hdisplay);ipu_di_init_sync_panel (ipu_crtc->di, &sig_cfg); }
@@ -402,23 +402,9 @@ static void ipu_disable_vblank(struct drm_crtc *crtc)disable_irq_nosync (ipu_crtc->irq); } -static int ipu_set_interface_pix_fmt (struct drm_crtc *crtc, -u32 bus_format,int hsync_pin,int vsync_pin,u32 bus_flags) -{ -struct ipu_crtc *ipu_crtc =to_ipu_crtc (crtc); - - ipu_crtc->bus_format = bus_format; - ipu_crtc->bus_flags = bus_flags; - ipu_crtc->di_hsync_pin = hsync_pin; - ipu_crtc->di_vsync_pin = vsync_pin; - -return 0 ; -} -static const struct imx_drm_crtc_helper_funcs ipu_crtc_helper_funcs = { .enable_vblank = ipu_enable_vblank, .disable_vblank = ipu_disable_vblank, - .set_interface_pix_fmt = ipu_set_interface_pix_fmt, .crtc_funcs = &ipu_crtc_funcs, .crtc_helper_funcs = &ipu_helper_funcs, };
drivers/gpu/drm/imx/parallel-display.c +29 -27
144 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 7/10 drm/imx: atomic phase 3 step 1: Use atomic configuration
In reply to Liu YingReplacing drm_crtc_helper_set_config() by drm_atomic_helper_set_config() and converting the suspend/resume operations to atomic make us be able to use atomic configurations. All of these allow us to remove the crtc_funcs->mode_set callback as it is no longer used. Also, change the plane_funcs->update/disable_plane callbacks from the transitional version to the atomic version. Furthermore, switching to the pure atomic version of set_config callback means that we may implement CRTC/plane atomic checks by using the new CRTC/plane states instead of the legacy ones and we may remove the private ipu_crtc->enabled state which was left there for the transitional atomic helpers in phase 1. Page flip is also switched to the atomic version. Last, the legacy function drm_helper_disable_unused_functions() is removed from ->load in order not to confuse the atomic driver.
---v3->v4:
* None.
v2->v3:
* Newly introduced, but this contains some important logic in patch 06/10 , 07/10 and 09/10 of v2 to support nonblock atomic commit(including page flip) - the ->set_config and ->update_plane/disable_plane hooks are updated to be pure atomic version, and ->atomic_check/atomic_commit hooks of drm_mode_config_funcs are wired up.
drivers/gpu/drm/imx/imx-drm-core.c | 76 +++++++++++++- drivers/gpu/drm/imx/ipuv3-crtc.c | 209 +++++-------------------------------- drivers/gpu/drm/imx/ipuv3-plane.c | 135 +++--------------------- drivers/gpu/drm/imx/ipuv3-plane.h | 2 - 4 files changed, 114 insertions(+), 308 deletions(-)
drivers/gpu/drm/imx/imx-drm-core.c +74 -2
@@ -15,10 +15,14 @@*/ #include <linux/component.h> #include <linux/device.h> +#include <linux/dma-buf.h> #include <linux/fb.h> #include <linux/module.h> #include <linux/platform_device.h> +#include <linux/reservation.h> #include <drm/drmP.h> +#include <drm/drm_atomic.h> +#include <drm/drm_atomic_helper.h> #include <drm/drm_fb_helper.h> #include <drm/drm_crtc_helper.h> #include <drm/drm_gem_cma_helper.h>
@@ -41,6 +45,7 @@ struct imx_drm_device {struct imx_drm_crtc *crtc[MAX_CRTC ];unsigned int pipes;struct drm_fbdev_cma *fbhelper; +struct drm_atomic_state *state; };struct imx_drm_crtc {
@@ -169,6 +174,63 @@ static void imx_drm_output_poll_changed(struct drm_device *drm)static const struct drm_mode_config_funcs imx_drm_mode_config_funcs = { .fb_create = drm_fb_cma_create, .output_poll_changed = imx_drm_output_poll_changed, + .atomic_check = drm_atomic_helper_check, + .atomic_commit = drm_atomic_helper_commit, +}; + +static void imx_drm_atomic_commit_tail (struct drm_atomic_state *state) +{ +struct drm_device *dev = state->dev; +struct drm_crtc *crtc; +struct drm_crtc_state *crtc_state; +struct drm_plane_state *plane_state; +struct drm_gem_cma_object *cma_obj; +struct fence *excl; +unsigned shared_count; +struct fence **shared; +unsigned int i, j; +int ret; + +/* Wait for fences. */ +for_each_crtc_in_state (state, crtc, crtc_state, i) { + plane_state = crtc->primary->state; +if (plane_state->fb) { + cma_obj =drm_fb_cma_get_gem_obj (plane_state->fb,0 ); +if (cma_obj->base.dma_buf) { + ret =reservation_object_get_fences_rcu ( + cma_obj->base.dma_buf->resv, &excl, + &shared_count, &shared); +if (unlikely (ret)) +DRM_ERROR ("failed to get fences " +"for buffer\n" ); + +if (excl) { +fence_wait (excl, false); +fence_put (excl); + } +for (j =0 ; j < shared_count; i++) { +fence_wait (shared[j], false); +fence_put (shared[j]); + } + } + } + } + +drm_atomic_helper_commit_modeset_disables (dev, state); + +drm_atomic_helper_commit_planes (dev, state, true); + +drm_atomic_helper_commit_modeset_enables (dev, state); + +drm_atomic_helper_commit_hw_done (state); + +drm_atomic_helper_wait_for_vblanks (dev, state); + +drm_atomic_helper_cleanup_planes (dev, state); +} + +static struct drm_mode_config_helper_funcs imx_drm_mode_config_helpers = { + .atomic_commit_tail = imx_drm_atomic_commit_tail, };/*
@@ -210,6 +272,7 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags) drm->mode_config.max_width =4096 ; drm->mode_config.max_height =4096 ; drm->mode_config.funcs = &imx_drm_mode_config_funcs; + drm->mode_config.helper_private = &imx_drm_mode_config_helpers;drm_mode_config_init (drm);
@@ -252,7 +315,6 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags)dev_warn (drm->dev,"Invalid legacyfb_depth. Defaulting to 16bpp\n" ); legacyfb_depth =16 ; } -drm_helper_disable_unused_functions (drm); imxdrm->fbhelper =drm_fbdev_cma_init (drm, legacyfb_depth, drm->mode_config.num_crtc,MAX_CRTC );if (IS_ERR (imxdrm->fbhelper)) {
@@ -454,6 +516,7 @@ static int imx_drm_platform_remove(struct platform_device *pdev)static int imx_drm_suspend (struct device *dev) {struct drm_device *drm_dev =dev_get_drvdata (dev); +struct imx_drm_device *imxdrm;/* The drm_dev is NULL before .load hook is called */ if (drm_dev ==NULL )
@@ -461,17 +524,26 @@ static int imx_drm_suspend(struct device *dev)drm_kms_helper_poll_disable (drm_dev); + imxdrm = drm_dev->dev_private; + imxdrm->state =drm_atomic_helper_suspend (drm_dev); +if (IS_ERR (imxdrm->state)) { +drm_kms_helper_poll_enable (drm_dev); +return PTR_ERR (imxdrm->state); + } +return 0 ; }static int imx_drm_resume (struct device *dev) {struct drm_device *drm_dev =dev_get_drvdata (dev); +struct imx_drm_device *imx_drm;if (drm_dev ==NULL )return 0 ; -drm_helper_resume_force_mode (drm_dev); + imx_drm = drm_dev->dev_private; +drm_atomic_helper_resume (drm_dev, imx_drm->state);drm_kms_helper_poll_enable (drm_dev);return 0 ;
drivers/gpu/drm/imx/ipuv3-crtc.c +27 -182
302 lines not on this page · raw message
drivers/gpu/drm/imx/ipuv3-plane.c +13 -122
167 lines not on this page · raw message
drivers/gpu/drm/imx/ipuv3-plane.h +0 -2
@@ -37,8 +37,6 @@ int ipu_plane_mode_set(struct ipu_plane *plane, struct drm_crtc *crtc, uint32_t src_x, uint32_t src_y, uint32_t src_w, uint32_t src_h, bool interlaced); -int ipu_plane_set_base (struct ipu_plane *plane,struct drm_framebuffer *fb); -int ipu_plane_get_resources (struct ipu_plane *plane);void ipu_plane_put_resources (struct ipu_plane *plane);
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 8/10 drm/bridge: dw-hdmi: Remove the legacy drm_connector_funcs structure
In reply to Liu YingThere is no one using the legacy drm_connector_funcs structure since the imx-drm has been converted to atomic, so we may remove it.
---v3->v4:
* None.
v2->v3:
* Newly introduced to remove the legacy drm_connector_funcs structure step-by-step.
drivers/gpu/drm/bridge/dw-hdmi.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-)
drivers/gpu/drm/bridge/dw-hdmi.c +3 -19
@@ -1495,17 +1495,6 @@ static void dw_hdmi_connector_force(struct drm_connector *connector) }static const struct drm_connector_funcs dw_hdmi_connector_funcs = { - .dpms = drm_helper_connector_dpms, - .fill_modes = drm_helper_probe_single_connector_modes, - .detect = dw_hdmi_connector_detect, - .destroy = dw_hdmi_connector_destroy, - .force = dw_hdmi_connector_force, - .reset = drm_atomic_helper_connector_reset, - .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, - .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, -}; - -static const struct drm_connector_funcs dw_hdmi_atomic_connector_funcs = { .dpms = drm_atomic_helper_connector_dpms, .fill_modes = drm_helper_probe_single_connector_modes, .detect = dw_hdmi_connector_detect,
@@ -1637,14 +1626,9 @@ static int dw_hdmi_register(struct drm_device *drm, struct dw_hdmi *hdmi)drm_connector_helper_add (&hdmi->connector, &dw_hdmi_connector_helper_funcs); -if (drm_core_check_feature (drm,DRIVER_ATOMIC )) -drm_connector_init (drm, &hdmi->connector, - &dw_hdmi_atomic_connector_funcs, -DRM_MODE_CONNECTOR_HDMIA ); -else -drm_connector_init (drm, &hdmi->connector, - &dw_hdmi_connector_funcs, -DRM_MODE_CONNECTOR_HDMIA ); +drm_connector_init (drm, &hdmi->connector, + &dw_hdmi_connector_funcs, +DRM_MODE_CONNECTOR_HDMIA );drm_mode_connector_attach_encoder (&hdmi->connector, encoder);
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 9/10 drm/imx: atomic phase 3 step 2: Legacy callback fixups
In reply to Liu YingNow that we can use atomic configurations, all the legacy callbacks of CRTCs, encoders and connectors can be switched to the atomic version. For the imx-ldb driver, there is a clock parent setting mismatch bewteen ->enable and ->disable after the switch, so a fixup is added. For the imx-tve driver, since the encoder's callback ->dpms is replaced by ->disable, we need to move the setting for the IPU_CLK_EN bit(in register TVE_COM_CONF_REG) from ->enable/->disable to ->mode_set, otherwise, the relevant CRTC cannot be disabled correctly with a warning on DC stop timeout.
---v3->v4:
* None.
v2->v3:
* Trivial change due to rebasing.
v1->v2:
* A fixup on the TVE register bit IPU_CLK_EN to avoid a warning on DC stop timeout when doing mode setting.
drivers/gpu/drm/imx/dw_hdmi-imx.c | 4 ++-- drivers/gpu/drm/imx/imx-ldb.c | 16 ++++++------- drivers/gpu/drm/imx/imx-tve.c | 27 +++++++-------------- drivers/gpu/drm/imx/ipuv3-crtc.c | 44 +++++----------------------------- drivers/gpu/drm/imx/parallel-display.c | 18 +++----------- 5 files changed, 27 insertions(+), 82 deletions(-)
drivers/gpu/drm/imx/dw_hdmi-imx.c +2 -2
@@ -117,7 +117,7 @@ static void dw_hdmi_imx_encoder_mode_set(struct drm_encoder *encoder, { } -static void dw_hdmi_imx_encoder_commit (struct drm_encoder *encoder) +static void dw_hdmi_imx_encoder_enable (struct drm_encoder *encoder) {struct imx_drm_encoder *imx_encoder =enc_to_imx_enc (encoder);struct imx_hdmi *hdmi =imx_enc_to_imx_hdmi (imx_encoder);
@@ -130,7 +130,7 @@ static void dw_hdmi_imx_encoder_commit(struct drm_encoder *encoder)static const struct drm_encoder_helper_funcs dw_hdmi_imx_encoder_helper_funcs = { .mode_set = dw_hdmi_imx_encoder_mode_set, - .commit = dw_hdmi_imx_encoder_commit, + .enable = dw_hdmi_imx_encoder_enable, .disable = dw_hdmi_imx_encoder_disable, };
drivers/gpu/drm/imx/imx-ldb.c +8 -8
@@ -172,10 +172,6 @@ static struct drm_encoder *imx_ldb_connector_best_encoder(return &imx_ldb_ch->imx_encoder.encoder; } -static void imx_ldb_encoder_dpms (struct drm_encoder *encoder,int mode) -{ -} -static void imx_ldb_set_clock (struct imx_ldb *ldb,int mux,int chno,unsigned long serial_clk,unsigned long di_clk) {
@@ -204,7 +200,7 @@ static void imx_ldb_set_clock(struct imx_ldb *ldb, int mux, int chno, chno); } -static void imx_ldb_encoder_commit (struct drm_encoder *encoder) +static void imx_ldb_encoder_enable (struct drm_encoder *encoder) {struct imx_drm_encoder *imx_encoder =enc_to_imx_enc (encoder);struct imx_ldb_channel *imx_ldb_ch =imx_enc_to_imx_ldb_ch (imx_encoder);
@@ -215,8 +211,13 @@ static void imx_ldb_encoder_commit(struct drm_encoder *encoder)drm_panel_prepare (imx_ldb_ch->panel);if (dual) { +clk_set_parent (ldb->clk_sel[mux], ldb->clk[0 ]); +clk_set_parent (ldb->clk_sel[mux], ldb->clk[1 ]); +clk_prepare_enable (ldb->clk[0 ]);clk_prepare_enable (ldb->clk[1 ]); + }else { +clk_set_parent (ldb->clk_sel[mux], ldb->clk[imx_ldb_ch->chno]); }if (imx_ldb_ch == &ldb->channel[0 ] || dual) {
@@ -356,7 +357,7 @@ static void imx_ldb_encoder_disable(struct drm_encoder *encoder) }static const struct drm_connector_funcs imx_ldb_connector_funcs = { - .dpms = drm_helper_connector_dpms, + .dpms = drm_atomic_helper_connector_dpms, .fill_modes = drm_helper_probe_single_connector_modes, .detect = imx_ldb_connector_detect, .destroy = imx_drm_connector_destroy,
@@ -375,9 +376,8 @@ static const struct drm_encoder_funcs imx_ldb_encoder_funcs = { };static const struct drm_encoder_helper_funcs imx_ldb_encoder_helper_funcs = { - .dpms = imx_ldb_encoder_dpms, - .commit = imx_ldb_encoder_commit, .mode_set = imx_ldb_encoder_mode_set, + .enable = imx_ldb_encoder_enable, .disable = imx_ldb_encoder_disable, };
drivers/gpu/drm/imx/imx-tve.c +8 -19
@@ -147,8 +147,7 @@ static void tve_enable(struct imx_tve *tve) tve->enabled = true;clk_prepare_enable (tve->clk); ret =regmap_update_bits (tve->regmap,TVE_COM_CONF_REG , -TVE_IPU_CLK_EN |TVE_EN , -TVE_IPU_CLK_EN |TVE_EN ); +TVE_EN ,TVE_EN ); }/* clear interrupt status register */
@@ -171,7 +170,7 @@ static void tve_disable(struct imx_tve *tve)if (tve->enabled) { tve->enabled = false; ret =regmap_update_bits (tve->regmap,TVE_COM_CONF_REG , -TVE_IPU_CLK_EN |TVE_EN ,0 ); +TVE_EN ,0 );clk_disable_unprepare (tve->clk); } }
@@ -274,18 +273,6 @@ static struct drm_encoder *imx_tve_connector_best_encoder(return &tve->imx_encoder.encoder; } -static void imx_tve_encoder_dpms (struct drm_encoder *encoder,int mode) -{ -struct imx_drm_encoder *imx_encoder =enc_to_imx_enc (encoder); -struct imx_tve *tve =imx_enc_to_tve (imx_encoder); -int ret; - - ret =regmap_update_bits (tve->regmap,TVE_COM_CONF_REG , -TVE_TV_OUT_MODE_MASK ,TVE_TV_OUT_DISABLE ); -if (ret <0 ) -dev_err (tve->dev,"failed to disable TVOUT: %d\n" , ret); -} -static void imx_tve_encoder_mode_set (struct drm_encoder *encoder,struct drm_display_mode *orig_mode,struct drm_display_mode *mode)
@@ -315,6 +302,9 @@ static void imx_tve_encoder_mode_set(struct drm_encoder *encoder, ret); } +regmap_update_bits (tve->regmap,TVE_COM_CONF_REG , +TVE_IPU_CLK_EN ,TVE_IPU_CLK_EN ); +if (tve->mode ==TVE_MODE_VGA ) ret =tve_setup_vga (tve);else
@@ -323,7 +313,7 @@ static void imx_tve_encoder_mode_set(struct drm_encoder *encoder,dev_err (tve->dev,"failed to set configuration: %d\n" , ret); } -static void imx_tve_encoder_commit (struct drm_encoder *encoder) +static void imx_tve_encoder_enable (struct drm_encoder *encoder) {struct imx_drm_encoder *imx_encoder =enc_to_imx_enc (encoder);struct imx_tve *tve =imx_enc_to_tve (imx_encoder);
@@ -340,7 +330,7 @@ static void imx_tve_encoder_disable(struct drm_encoder *encoder) }static const struct drm_connector_funcs imx_tve_connector_funcs = { - .dpms = drm_helper_connector_dpms, + .dpms = drm_atomic_helper_connector_dpms, .fill_modes = drm_helper_probe_single_connector_modes, .detect = imx_tve_connector_detect, .destroy = imx_drm_connector_destroy,
@@ -360,9 +350,8 @@ static const struct drm_encoder_funcs imx_tve_encoder_funcs = { };static const struct drm_encoder_helper_funcs imx_tve_encoder_helper_funcs = { - .dpms = imx_tve_encoder_dpms, .mode_set = imx_tve_encoder_mode_set, - .commit = imx_tve_encoder_commit, + .enable = imx_tve_encoder_enable, .disable = imx_tve_encoder_disable, };
drivers/gpu/drm/imx/ipuv3-crtc.c +6 -38
81 lines not on this page · raw message
drivers/gpu/drm/imx/parallel-display.c +3 -15
@@ -92,18 +92,7 @@ static struct drm_encoder *imx_pd_connector_best_encoder(return &imxpd->imx_encoder.encoder; } -static void imx_pd_encoder_dpms (struct drm_encoder *encoder,int mode) -{ -struct imx_drm_encoder *imx_encoder =enc_to_imx_enc (encoder); -struct imx_parallel_display *imxpd =imx_enc_to_imxpd (imx_encoder); - -if (mode !=DRM_MODE_DPMS_ON ) -drm_panel_disable (imxpd->panel); -else -drm_panel_enable (imxpd->panel); -} - -static void imx_pd_encoder_commit (struct drm_encoder *encoder) +static void imx_pd_encoder_enable (struct drm_encoder *encoder) {struct imx_drm_encoder *imx_encoder =enc_to_imx_enc (encoder);struct imx_parallel_display *imxpd =imx_enc_to_imxpd (imx_encoder);
@@ -128,7 +117,7 @@ static void imx_pd_encoder_disable(struct drm_encoder *encoder) }static const struct drm_connector_funcs imx_pd_connector_funcs = { - .dpms = drm_helper_connector_dpms, + .dpms = drm_atomic_helper_connector_dpms, .fill_modes = drm_helper_probe_single_connector_modes, .detect = imx_pd_connector_detect, .destroy = imx_drm_connector_destroy,
@@ -147,9 +136,8 @@ static const struct drm_encoder_funcs imx_pd_encoder_funcs = { };static const struct drm_encoder_helper_funcs imx_pd_encoder_helper_funcs = { - .dpms = imx_pd_encoder_dpms, - .commit = imx_pd_encoder_commit, .mode_set = imx_pd_encoder_mode_set, + .enable = imx_pd_encoder_enable, .disable = imx_pd_encoder_disable, };
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 10/10 drm/imx: atomic phase 3 step 3: Advertise DRIVER_ATOMIC
In reply to Liu YingWith all the beforehand phases and steps done, we can adverstise DRIVER_ATOMIC.
---v3->v4:
* None.
v2->v3:
* None.
v1->v2:
* None.
drivers/gpu/drm/imx/imx-drm-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/imx/imx-drm-core.c +2 -1
@@ -428,7 +428,8 @@ static const struct drm_ioctl_desc imx_drm_ioctls[] = { };static struct drm_driver imx_drm_driver = { - .driver_features =DRIVER_MODESET |DRIVER_GEM |DRIVER_PRIME , + .driver_features =DRIVER_MODESET |DRIVER_GEM |DRIVER_PRIME | +DRIVER_ATOMIC , .load = imx_drm_driver_load, .unload = imx_drm_driver_unload, .lastclose = imx_drm_driver_lastclose,
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel