imx drm atomic mode setting conversion
Subsystems (6)
cover imx drm atomic mode setting conversion
Hi,
This patch set converts imx drm into atomic mode setting.
It takes 3 phases to achieve the goal as recommended.
This patch set may apply to Philipp Zabel's open git branch imx-drm/fixes.
Liu Ying (14):
drm/imx: ipuv3-plane: Constify ipu_plane_funcs
drm/imx: plane: Don't set plane->crtc in ipu_plane_update()
drm: imx: ipuv3 plane: Check different types of plane separately
gpu: ipu-v3: ipu-dmfc: Use static DMFC FIFO allocation mechanism drm/crtc_helper: Disable and reenable primary plane in
drm_helper_crtc_mode_set
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: atomic phase 3 step 1: Atomic updates for planes drm/atomic-helper: Disable planes when suspending drm/imx: atomic phase 3 step 2: Use atomic configuration drm/imx: atomic phase 3 step 3: Legacy callback fixups drm/imx: atomic phase 3 step 4: Use generic atomic page flip drm/imx: atomic phase 3 step 5: Advertise DRIVER_ATOMIC
drivers/gpu/drm/bridge/dw-hdmi.c | 19 +- drivers/gpu/drm/drm_atomic_helper.c | 18 +- drivers/gpu/drm/drm_crtc_helper.c | 9 + drivers/gpu/drm/imx/dw_hdmi-imx.c | 22 +- drivers/gpu/drm/imx/imx-drm-core.c | 192 +++++++++--- drivers/gpu/drm/imx/imx-drm.h | 11 +- drivers/gpu/drm/imx/imx-ldb.c | 129 ++++---- drivers/gpu/drm/imx/imx-tve.c | 75 ++--- drivers/gpu/drm/imx/ipuv3-crtc.c | 331 +++++--------------- drivers/gpu/drm/imx/ipuv3-plane.c | 538 +++++++++++++++++++-------------- drivers/gpu/drm/imx/ipuv3-plane.h | 14 +- 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 - 16 files changed, 720 insertions(+), 936 deletions(-)
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/14 drm/imx: ipuv3-plane: Constify ipu_plane_funcs
--- drivers/gpu/drm/imx/ipuv3-plane.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/imx/ipuv3-plane.c +1 -1
@@ -461,7 +461,7 @@ static void ipu_plane_destroy(struct drm_plane *plane)kfree (ipu_plane); } -static struct drm_plane_funcs ipu_plane_funcs = { +static const struct drm_plane_funcs ipu_plane_funcs = { .update_plane = ipu_update_plane, .disable_plane = ipu_disable_plane, .destroy = ipu_plane_destroy,
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/14 drm/imx: plane: Don't set plane->crtc in ipu_plane_update()
In reply to Liu YingSince the drm core sets plane->crtc correctly, we don't need to do that.
--- drivers/gpu/drm/imx/ipuv3-plane.c | 1 - 1 file changed, 1 deletion(-)
drivers/gpu/drm/imx/ipuv3-plane.c +0 -1
@@ -428,7 +428,6 @@ static int ipu_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,if (crtc != plane->crtc)dev_dbg (plane->dev->dev,"crtc change: %p -> %p\n" , plane->crtc, crtc); - plane->crtc = crtc;if (!ipu_plane->enabled)ipu_plane_enable (ipu_plane);
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/14 drm: imx: ipuv3 plane: Check different types of plane separately
In reply to Liu YingThe 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.
--- drivers/gpu/drm/imx/ipuv3-plane.c | 72 ++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 31 deletions(-)
drivers/gpu/drm/imx/ipuv3-plane.c +41 -31
@@ -190,44 +190,54 @@ int ipu_plane_mode_set(struct ipu_plane *ipu_plane, struct drm_crtc *crtc, uint32_t src_x, uint32_t src_y, uint32_t src_w, uint32_t src_h, bool interlaced) { - struct device *dev = ipu_plane->base.dev->dev; + struct drm_plane plane = ipu_plane->base; +struct device *dev = plane.dev->dev;int ret;/* no scaling */ 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 (plane.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 (plane.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 ;
@@ -238,7 +248,7 @@ int ipu_plane_mode_set(struct ipu_plane *ipu_plane, struct drm_crtc *crtc,*/ if (ipu_plane->enabled) {if (src_w != ipu_plane->w || src_h != ipu_plane->h || - fb->pixel_format != ipu_plane->base.fb->pixel_format) + fb->pixel_format != plane.fb->pixel_format)return -EINVAL ;return ipu_plane_set_base (ipu_plane, fb, src_x, src_y);
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Philipp Zabel
maintainerRe: [PATCH 03/14] drm: imx: ipuv3 plane: Check different types of plane separately
Am Dienstag, den 24.05.2016, 18:10 +0800 schrieb Liu Ying:
Quoted 14 lines
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.
Signed-off-by Liu Ying <[email protected]>--- drivers/gpu/drm/imx/ipuv3-plane.c | 72 ++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 31 deletions(-)drivers/gpu/drm/imx/ipuv3-plane.c +0
-0
drivers/gpu/drm/imx/ipuv3-plane.c int ipu_plane_mode_set(struct ipu_plane *ipu_plane, struct drm_crtc *crtc, · line 193
Quoted 5 lines
drivers/gpu/drm/imx/ipuv3-plane.c +1
-1@@ -190,44 +190,54 @@ int ipu_plane_mode_set(struct ipu_plane *ipu_plane, struct drm_crtc *crtc, uint32_t src_x, uint32_t src_y, uint32_t src_w, uint32_t src_h, bool interlaced) { - struct device *dev = ipu_plane->base.dev->dev; + struct drm_plane plane = ipu_plane->base;
Why make a copy of the drm_plane here?
Quoted 4 lines
drivers/gpu/drm/imx/ipuv3-plane.c +1
-0+struct device *dev = plane.dev->dev;int ret;/* no scaling */
drivers/gpu/drm/imx/ipuv3-plane.c int ipu_plane_mode_set(struct ipu_plane *ipu_plane, struct drm_crtc *crtc, · line 204
Quoted 10 lines
drivers/gpu/drm/imx/ipuv3-plane.c +4
-3if (src_w != crtc_w || src_h != crtc_h)return -EINVAL ; -/* clip to crtc bounds */ -if (crtc_x <0 ) { -if (-crtc_x > crtc_w) +if (plane.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)
As long as the requested plane is large enough to cover the whole base plane, we can fix the crtc_x/y/w/h up by clipping to the base plane boundaries. There is no need to return -EINVAL here as long as the IDMAC is capable to start reading at src_x/y = -crtc_x/y.
regards
Philipp
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 03/14] drm: imx: ipuv3 plane: Check different types of plane separately
Quoted 38 lines · Philipp Zabel
Am Dienstag, den 24.05.2016, 18:10 +0800 schrieb Liu Ying:
Quoted 14 lines
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.
Signed-off-by Liu Ying <[email protected]>--- drivers/gpu/drm/imx/ipuv3-plane.c | 72 ++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 31 deletions(-)drivers/gpu/drm/imx/ipuv3-plane.c +0
-0drivers/gpu/drm/imx/ipuv3-plane.c int ipu_plane_mode_set(struct ipu_plane *ipu_plane, struct drm_crtc *crtc, · line 193
Quoted 5 lines
drivers/gpu/drm/imx/ipuv3-plane.c +1
-1@@ -190,44 +190,54 @@ int ipu_plane_mode_set(struct ipu_plane *ipu_plane, struct drm_crtc *crtc, uint32_t src_x, uint32_t src_y, uint32_t src_w, uint32_t src_h, bool interlaced) { - struct device *dev = ipu_plane->base.dev->dev; + struct drm_plane plane = ipu_plane->base;Why make a copy of the
drm_planehere?Quoted 4 lines
drivers/gpu/drm/imx/ipuv3-plane.c +1
-0+struct device *dev = plane.dev->dev;int ret;/* no scaling */ drivers/gpu/drm/imx/ipuv3-plane.c int ipu_plane_mode_set(struct ipu_plane *ipu_plane, struct drm_crtc *crtc, · line 204
Quoted 10 lines
drivers/gpu/drm/imx/ipuv3-plane.c +4
-3if (src_w != crtc_w || src_h != crtc_h)return -EINVAL ; -/* clip to crtc bounds */ -if (crtc_x <0 ) { -if (-crtc_x > crtc_w) +if (plane.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)
Quoted 4 lines
As long as the requested plane is large enough to cover the whole base plane, we can fix the crtc_x/y/w/h up by clipping to the base plane boundaries. There is no need to return
-EINVALhere as long as the IDMAC is capable to start reading at src_x/y = -crtc_x/y.
For the primary plane, we really need to look at mode->v/hdisplay to make sure no partial off screen happens(plane partial off CRTC). The clip is tricky, so for primary plane, I just take the simple way to avoid the clip.
Eventually, we'll use atomic check to simply accept or reject the user's request instead of changing the state to do clip. This makes the driver simpler.
Regards,
Liu Ying
Quoted 4 lines
regards
Philipp
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 03/14] drm: imx: ipuv3 plane: Check different types of plane separately
In reply to Philipp ZabelQuoted 10 lines · Philipp Zabel
Am Dienstag, den 24.05.2016, 18:10 +0800 schrieb Liu Ying:
Quoted 9 lines
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.
Signed-off-by Liu Ying <[email protected]>--- drivers/gpu/drm/imx/ipuv3-plane.c | 72 ++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 31 deletions(-)
Quoted 12 lines
drivers/gpu/drm/imx/ipuv3-plane.c int ipu_plane_mode_set(struct ipu_plane *ipu_plane, struct drm_crtc *crtc, · line 193
Quoted 10 lines
drivers/gpu/drm/imx/ipuv3-plane.c +1
-1@@ -190,44 +190,54 @@ int ipu_plane_mode_set(struct ipu_plane *ipu_plane, struct drm_crtc *crtc, uint32_t src_x, uint32_t src_y, uint32_t src_w, uint32_t src_h, bool interlaced) { - struct device *dev = ipu_plane->base.dev->dev; + struct drm_plane plane = ipu_plane->base;Why make a copy of the
drm_planehere?
Will remove that copy.
Regards,
Liu Ying
Quoted 16 lines
Quoted 5 lines
drivers/gpu/drm/imx/ipuv3-plane.c +1
-0+struct device *dev = plane.dev->dev;int ret;/* no scaling */ drivers/gpu/drm/imx/ipuv3-plane.c int ipu_plane_mode_set(struct ipu_plane *ipu_plane, struct drm_crtc *crtc, · line 204
Quoted 10 lines
drivers/gpu/drm/imx/ipuv3-plane.c +4
-3if (src_w != crtc_w || src_h != crtc_h)return -EINVAL ; -/* clip to crtc bounds */ -if (crtc_x <0 ) { -if (-crtc_x > crtc_w) +if (plane.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)
Quoted 8 lines
As long as the requested plane is large enough to cover the whole base plane, we can fix the crtc_x/y/w/h up by clipping to the base plane boundaries. There is no need to return
-EINVALhere as long as the IDMAC is capable to start reading at src_x/y = -crtc_x/y.regards
Philipp
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/14 gpu: ipu-v3: ipu-dmfc: Use static DMFC FIFO allocation mechanism
In reply to Liu YingFor normal video modes such as 1280x720p@60Hz and 1920x1080p@60Hz, 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.
--- 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
@@ -51,24 +51,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) {
@@ -290,14 +272,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
Philipp Zabel
maintainerRe: [PATCH 04/14] gpu: ipu-v3: ipu-dmfc: Use static DMFC FIFO allocation mechanism
Am Dienstag, den 24.05.2016, 18:10 +0800 schrieb Liu Ying:
Quoted 1 line
For normal video modes such as 1280x720p@60Hz and 1920x1080p@60Hz,
I'm very happy to drop all this code if possible, but the stated reason is not good enough. Rather we should look at the worst case and make sure that 2 FIFO slots are enough for 180 MPixel/s on i.MX5 and enough for 240 MPixel/s on i.MX6.
According to the current heuristic (total bandwidth = clkrate * 4 pixels with 8 slots) that should be true.
regards
Philipp
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 04/14] gpu: ipu-v3: ipu-dmfc: Use static DMFC FIFO allocation mechanism
Quoted 7 lines · Philipp Zabel
Am Dienstag, den 24.05.2016, 18:10 +0800 schrieb Liu Ying:
Quoted 1 line
For normal video modes such as 1280x720p@60Hz and 1920x1080p@60Hz,
I'm very happy to drop all this code if possible, but the stated reason is not good enough. Rather we should look at the worst case and make sure that 2 FIFO slots are enough for 180 MPixel/s on i.MX5 and enough for 240 MPixel/s on i.MX6.
My stated reason is not accurate, perhaps. Sorry. IIRC, when I wrote this patch, I found we use 2 slots for all video modes with the dynamic allocation mechanism. That's why the static one comes up to mind.
Quoted 2 lines
According to the current heuristic (total bandwidth = clkrate * 4 pixels with 8 slots) that should be true.
I'm not sure what's the best allocation algorithm is. Hope that the static one can be accepted temporarily and some one may offer a better solution in future.
Regards,
Liu Ying
Quoted 4 lines
regards
Philipp
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 5/14 drm/crtc_helper: Disable and reenable primary plane in drm_helper_crtc_mode_set
In reply to Liu YingSince CRTC has already been disabled in crtc_funcs->prepare(), it doesn't hurt to disable the primary plane in drm_helper_crtc_mode_set() before enabling it in drm_helper_crtc_mode_set_base(). This makes those who reject active plane update in plane_funcs->atomic_check() happy.
--- drivers/gpu/drm/drm_crtc_helper.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/gpu/drm/drm_crtc_helper.c +9 -0
@@ -1013,6 +1013,15 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod goto out; } +/* +* It doesn't hurt to disable primary plane here since crtc is off +* and we'll enable it again in drm_helper_crtc_mode_set_base() +* below soon. +*/ + ret =drm_plane_helper_disable (crtc->primary); +if (ret) + goto out; +swap (crtc->state, crtc_state); crtc_funcs->mode_set_nofb (crtc);
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 05/14] drm/crtc_helper: Disable and reenable primary plane in drm_helper_crtc_mode_set
Quoted 4 lines · Liu Ying
Since CRTC has already been disabled in
crtc_funcs->prepare(), it doesn't hurt to disable the primary plane indrm_helper_crtc_mode_set()before enabling it indrm_helper_crtc_mode_set_base(). This makes those who reject active plane update inplane_funcs->atomic_check()happy.
How/where exactly do you blow up?
Quoted 11 lines
Signed-off-by Liu Ying <[email protected]>--- drivers/gpu/drm/drm_crtc_helper.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/gpu/drm/drm_crtc_helper.c +0
-0
drivers/gpu/drm/drm_crtc_helper.c int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod · line 1021
Quoted 9 lines
drivers/gpu/drm/drm_crtc_helper.c +6
-0@@ -1013,6 +1013,15 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod goto out; } +/* +* It doesn't hurt to disable primary plane here since crtc is off +* and we'll enable it again in drm_helper_crtc_mode_set_base() +* below soon. +*/ + ret =drm_plane_helper_disable (crtc->primary);
You can't call this helper from crtc helpers. drm_plane_helper_disable assumes that a) you've already extracted universal plane support for the primary plane by registering a proper drm_plane for it b) that you're driver is at least partially using atomic hooks already.
Both assumptions are wrong for all current users of this function. drm_helper_crtc_mode_set() is purely a legacy helper for legecy drivers. -Daniel
Quoted 13 lines
drivers/gpu/drm/drm_crtc_helper.c +3
-0+if (ret) + goto out; +swap (crtc->state, crtc_state); crtc_funcs->mode_set_nofb (crtc);Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 05/14] drm/crtc_helper: Disable and reenable primary plane in drm_helper_crtc_mode_set
Quoted 33 lines · Daniel Vetter
Quoted 4 lines · Liu Ying
Since CRTC has already been disabled in
crtc_funcs->prepare(), it doesn't hurt to disable the primary plane indrm_helper_crtc_mode_set()before enabling it indrm_helper_crtc_mode_set_base(). This makes those who reject active plane update inplane_funcs->atomic_check()happy.How/where exactly do you blow up?
Quoted 11 lines
Signed-off-by Liu Ying <[email protected]>--- drivers/gpu/drm/drm_crtc_helper.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/gpu/drm/drm_crtc_helper.c +0
-0drivers/gpu/drm/drm_crtc_helper.c int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod · line 1021
Quoted 9 lines
drivers/gpu/drm/drm_crtc_helper.c +6
-0@@ -1013,6 +1013,15 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod goto out; } +/* +* It doesn't hurt to disable primary plane here since crtc is off +* and we'll enable it again in drm_helper_crtc_mode_set_base() +* below soon. +*/ + ret =drm_plane_helper_disable (crtc->primary);You can't call this helper from crtc helpers.
drm_plane_helper_disableassumes that a) you've already extracted universal plane support for the primary plane by registering a properdrm_planefor it b) that you're driver is at least partially using atomic hooks already.
Quoted 2 lines
Both assumptions are wrong for all current users of this function.
drm_helper_crtc_mode_set()is purely a legacy helper for legecy drivers.
Isn't the function a transitional helper, just as the kdoc claims? It looks all current users are sort of atomic users already.
Regards,
Liu Ying
Quoted 16 lines
-Daniel
Quoted 9 lines
drivers/gpu/drm/drm_crtc_helper.c +3
-1+if (ret) + goto out; +swap (crtc->state, crtc_state); crtc_funcs->mode_set_nofb (crtc); --2.7.4
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 4 lines
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 05/14] drm/crtc_helper: Disable and reenable primary plane in drm_helper_crtc_mode_set
Quoted 34 lines · Ying Liu
Quoted 33 lines · Daniel Vetter
Quoted 4 lines · Liu Ying
Since CRTC has already been disabled in
crtc_funcs->prepare(), it doesn't hurt to disable the primary plane indrm_helper_crtc_mode_set()before enabling it indrm_helper_crtc_mode_set_base(). This makes those who reject active plane update inplane_funcs->atomic_check()happy.How/where exactly do you blow up?
Quoted 11 lines
Signed-off-by Liu Ying <[email protected]>--- drivers/gpu/drm/drm_crtc_helper.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/gpu/drm/drm_crtc_helper.c +0
-0drivers/gpu/drm/drm_crtc_helper.c int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod · line 1021
Quoted 9 lines
drivers/gpu/drm/drm_crtc_helper.c +6
-0@@ -1013,6 +1013,15 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod goto out; } +/* +* It doesn't hurt to disable primary plane here since crtc is off +* and we'll enable it again in drm_helper_crtc_mode_set_base() +* below soon. +*/ + ret =drm_plane_helper_disable (crtc->primary);You can't call this helper from crtc helpers.
drm_plane_helper_disableassumes that a) you've already extracted universal plane support for the primary plane by registering a properdrm_planefor it b) that you're driver is at least partially using atomic hooks already.
Quoted 5 lines
Quoted 2 lines
Both assumptions are wrong for all current users of this function.
drm_helper_crtc_mode_set()is purely a legacy helper for legecy drivers.Isn't the function a transitional helper, just as the kdoc claims? It looks all current users are sort of atomic users already.
drm_helper_crtc_mode_set is exclusively used by legacy drivers. drm_plane_helper_disable can be used for transitioning to atomic.
Calling the latter from the former means you break every non-transition legacy driver.
-Daniel
Quoted 24 lines
Regards,
Liu YingQuoted 20 lines
-Daniel
Quoted 9 lines
drivers/gpu/drm/drm_crtc_helper.c +3
-1+if (ret) + goto out; +swap (crtc->state, crtc_state); crtc_funcs->mode_set_nofb (crtc); --2.7.4
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 05/14] drm/crtc_helper: Disable and reenable primary plane in drm_helper_crtc_mode_set
Quoted 35 lines · Daniel Vetter
Quoted 34 lines · Ying Liu
Quoted 33 lines · Daniel Vetter
Quoted 4 lines · Liu Ying
Since CRTC has already been disabled in
crtc_funcs->prepare(), it doesn't hurt to disable the primary plane indrm_helper_crtc_mode_set()before enabling it indrm_helper_crtc_mode_set_base(). This makes those who reject active plane update inplane_funcs->atomic_check()happy.How/where exactly do you blow up?
Quoted 11 lines
Signed-off-by Liu Ying <[email protected]>--- drivers/gpu/drm/drm_crtc_helper.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/gpu/drm/drm_crtc_helper.c +0
-0drivers/gpu/drm/drm_crtc_helper.c int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod · line 1021
Quoted 9 lines
drivers/gpu/drm/drm_crtc_helper.c +6
-0@@ -1013,6 +1013,15 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod goto out; } +/* +* It doesn't hurt to disable primary plane here since crtc is off +* and we'll enable it again in drm_helper_crtc_mode_set_base() +* below soon. +*/ + ret =drm_plane_helper_disable (crtc->primary);You can't call this helper from crtc helpers.
drm_plane_helper_disableassumes that a) you've already extracted universal plane support for the primary plane by registering a properdrm_planefor it b) that you're driver is at least partially using atomic hooks already.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Both assumptions are wrong for all current users of this function.
drm_helper_crtc_mode_set()is purely a legacy helper for legecy drivers.Isn't the function a transitional helper, just as the kdoc claims? It looks all current users are sort of atomic users already.
drm_helper_crtc_mode_setis exclusively used by legacy drivers.drm_plane_helper_disablecan be used for transitioning to atomic.
Again, please take a look at the kdoc of drm_helper_crtc_mode_set. It reads 'Besides the atomic plane helper functions for the primary plane the driver must also provide the ->mode_set_nofb callback to set up the CRTC. This is a transitional helper useful for converting drivers to the atomic interfaces.'
Quoted 3 lines
Calling the latter from the former means you break every non-transition legacy driver.
drm_helper_crtc_mode_set calls drm_helper_crtc_mode_set_base. Both drm_helper_crtc_mode_set_base and drm_plane_helper_disable call drm_plane_helper_commit, so they are somewhat counterparts, that is to say, drm_helper_crtc_mode_set may call drm_plane_helper_disable technically.
Regards,
Liu Ying
Quoted 27 lines
-Daniel
Quoted 24 lines
Regards,
Liu YingQuoted 20 lines
-Daniel
Quoted 9 lines
drivers/gpu/drm/drm_crtc_helper.c +3
-1+if (ret) + goto out; +swap (crtc->state, crtc_state); crtc_funcs->mode_set_nofb (crtc); --2.7.4
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Quoted 4 lines
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 05/14] drm/crtc_helper: Disable and reenable primary plane in drm_helper_crtc_mode_set
Quoted 42 lines · Ying Liu
Quoted 41 lines · Daniel Vetter
Quoted 39 lines · Ying Liu
Quoted 33 lines · Daniel Vetter
Quoted 4 lines · Liu Ying
Since CRTC has already been disabled in
crtc_funcs->prepare(), it doesn't hurt to disable the primary plane indrm_helper_crtc_mode_set()before enabling it indrm_helper_crtc_mode_set_base(). This makes those who reject active plane update inplane_funcs->atomic_check()happy.How/where exactly do you blow up?
Quoted 11 lines
Signed-off-by Liu Ying <[email protected]>--- drivers/gpu/drm/drm_crtc_helper.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/gpu/drm/drm_crtc_helper.c +0
-0drivers/gpu/drm/drm_crtc_helper.c int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod · line 1021
Quoted 9 lines
drivers/gpu/drm/drm_crtc_helper.c +6
-0@@ -1013,6 +1013,15 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod goto out; } +/* +* It doesn't hurt to disable primary plane here since crtc is off +* and we'll enable it again in drm_helper_crtc_mode_set_base() +* below soon. +*/ + ret =drm_plane_helper_disable (crtc->primary);You can't call this helper from crtc helpers.
drm_plane_helper_disableassumes that a) you've already extracted universal plane support for the primary plane by registering a properdrm_planefor it b) that you're driver is at least partially using atomic hooks already.Quoted 2 lines
Both assumptions are wrong for all current users of this function.
drm_helper_crtc_mode_set()is purely a legacy helper for legecy drivers.Isn't the function a transitional helper, just as the kdoc claims? It looks all current users are sort of atomic users already.
Quoted 8 lines
Quoted 2 lines
drm_helper_crtc_mode_setis exclusively used by legacy drivers.drm_plane_helper_disablecan be used for transitioning to atomic.Again, please take a look at the kdoc of
drm_helper_crtc_mode_set. It reads 'Besides the atomic plane helper functions for the primary plane the driver must also provide the ->mode_set_nofb callback to set up the CRTC. This is a transitional helper useful for converting drivers to the atomic interfaces.'
Oops, my apologies, I mixed it all up in my head. Sorry for all the mess, I'll start a new thread since this discussion here is a bit confusion now. -Daniel
Quoted 43 lines
Quoted 2 lines
Calling the latter from the former means you break every non-transition legacy driver.
drm_helper_crtc_mode_setcallsdrm_helper_crtc_mode_set_base. Bothdrm_helper_crtc_mode_set_baseanddrm_plane_helper_disablecalldrm_plane_helper_commit, so they are somewhat counterparts, that is to say,drm_helper_crtc_mode_setmay calldrm_plane_helper_disabletechnically.Regards,
Liu YingQuoted 31 lines
-Daniel
Quoted 24 lines
Regards,
Liu YingQuoted 20 lines
-Daniel
Quoted 9 lines
drivers/gpu/drm/drm_crtc_helper.c +3
-1+if (ret) + goto out; +swap (crtc->state, crtc_state); crtc_funcs->mode_set_nofb (crtc); --2.7.4
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 05/14] drm/crtc_helper: Disable and reenable primary plane in drm_helper_crtc_mode_set
In reply to Liu YingQuoted 17 lines · Liu Ying
Since CRTC has already been disabled in
crtc_funcs->prepare(), it doesn't hurt to disable the primary plane indrm_helper_crtc_mode_set()before enabling it indrm_helper_crtc_mode_set_base(). This makes those who reject active plane update inplane_funcs->atomic_check()happy.Signed-off-by Liu Ying <[email protected]>--- drivers/gpu/drm/drm_crtc_helper.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/gpu/drm/drm_crtc_helper.c +0
-0@@ -1013,6 +1013,15 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod goto out; }
drivers/gpu/drm/drm_crtc_helper.c int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod · line 1024
Quoted 10 lines
drivers/gpu/drm/drm_crtc_helper.c +9
-0+/* +* It doesn't hurt to disable primary plane here since crtc is off +* and we'll enable it again in drm_helper_crtc_mode_set_base() +* below soon. +*/ + ret =drm_plane_helper_disable (crtc->primary); +if (ret) + goto out; +
Ok, so there's no problem with mixing up legacy and transitional helpers here. It's still not how it's supposed to work though. All the helpers (legacy, transitional & atomic) assume that when the helpers call into crtc->disable hooks, the driver will also disable all the scanout engines. The helpers will _not_ do that for you, it's the driver duties.
For atomic we have a helper function which you can call at the right place, drm_atomic_helper_disable_planes_on_crtc(). Unfortunately it looks like no one ever used it, so probably a bunch of bugs in drivers because of this. Explicitly disabling the plane when the crtc is shut down might confused/break drivers which get this right, hence why we can't have this in the helper libraries.
In short: You need to fix this in your driver, by manually disabling the plane at a suitable place first. Most likely that's in the crtc->prepare hook (since you're still transitioning).
-Daniel
Quoted 10 lines
drivers/gpu/drm/drm_crtc_helper.c +0
-0swap (crtc->state, crtc_state); crtc_funcs->mode_set_nofb (crtc);Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 6/14 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() transistional 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.
--- drivers/gpu/drm/imx/ipuv3-crtc.c | 173 +++++++------ drivers/gpu/drm/imx/ipuv3-plane.c | 516 +++++++++++++++++++++++--------------- drivers/gpu/drm/imx/ipuv3-plane.h | 14 +- drivers/gpu/ipu-v3/ipu-dc.c | 5 +- drivers/gpu/ipu-v3/ipu-di.c | 3 - 5 files changed, 400 insertions(+), 311 deletions(-)
drivers/gpu/drm/imx/ipuv3-crtc.c +86 -87
@@ -72,7 +72,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);
@@ -80,16 +80,19 @@ 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);
@@ -99,11 +102,10 @@ static void ipu_fb_disable(struct ipu_crtc *ipu_crtc)/* 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)
@@ -114,12 +116,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 ; } }
@@ -233,77 +235,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 =1 ; - sig_cfg.clk_pol =0 ; - 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;
@@ -327,8 +258,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);
@@ -352,6 +282,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;
@@ -361,28 +294,93 @@ 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 =1 ; + sig_cfg.clk_pol =0 ; + 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 ;
@@ -506,6 +504,8 @@ static int ipu_crtc_init(struct ipu_crtc *ipu_crtc,/* Only enable IRQ when we actually need it to trigger work. */ disable_irq (ipu_crtc->irq); +ipu_plane_put_resources (ipu_crtc->plane[0 ]); + ipu_crtc->flip_queue =create_singlethread_workqueue ("ipu-crtc-flip" );return 0 ;
@@ -550,7 +550,6 @@ 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); }
drivers/gpu/drm/imx/ipuv3-plane.c +312 -204
627 lines not on this page · raw message
drivers/gpu/drm/imx/ipuv3-plane.h +1 -13
@@ -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,
@@ -50,8 +39,7 @@ int ipu_plane_mode_set(struct ipu_plane *plane, struct drm_crtc *crtc,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
Philipp Zabel
maintainerRe: [PATCH 06/14] drm/imx: atomic phase 1: Use transitional atomic CRTC and plane helpers
Am Dienstag, den 24.05.2016, 18:10 +0800 schrieb Liu Ying:
Quoted 16 lines
Use the drm_plane_helper_update/disable() and
drm_helper_crtc_mode_set()transistional atomic helpers. Thecrtc->mode_set_nofbcallback is added so that the primary plane is no longer tied to the CRTC. Check/update logics are separated to make surecrtc->mode_set_nofbandplane->atomic_updateare always successful. Also, some necessary logics are tweaked for a smooth transition.Signed-off-by Liu Ying <[email protected]>--- drivers/gpu/drm/imx/ipuv3-crtc.c | 173 +++++++------ drivers/gpu/drm/imx/ipuv3-plane.c | 516 +++++++++++++++++++++++--------------- drivers/gpu/drm/imx/ipuv3-plane.h | 14 +- drivers/gpu/ipu-v3/ipu-dc.c | 5 +- drivers/gpu/ipu-v3/ipu-di.c | 3 - 5 files changed, 400 insertions(+), 311 deletions(-)
[...]
Quoted 16 lines
drivers/gpu/drm/imx/ipuv3-plane.c +1
-0@@ -16,6 +16,7 @@#include <drm/drmP.h> #include <drm/drm_fb_cma_helper.h> #include <drm/drm_gem_cma_helper.h> +#include <drm/drm_plane_helper.h> #include "video/imx-ipu-v3.h" #include "ipuv3-plane.h" @@ -51,12 +52,15 @@ int ipu_plane_irq(struct ipu_plane *ipu_plane) IPU_IRQ_EOF); }
drivers/gpu/drm/imx/ipuv3-plane.c int ipu_plane_irq(struct ipu_plane *ipu_plane) · line 60
Quoted 10 lines
drivers/gpu/drm/imx/ipuv3-plane.c +5
-4-int ipu_plane_set_base (struct ipu_plane *ipu_plane,struct drm_framebuffer *fb, -int x,int y) +int ipu_plane_set_base (struct ipu_plane *ipu_plane,struct drm_framebuffer *fb) { -struct drm_gem_cma_object *cma_obj[3 ]; -unsigned long eba, ubo, vbo; +struct drm_gem_cma_object *cma_obj[3 ], *old_cma_obj[3 ]; +struct drm_plane_state *state = ipu_plane->base.state; +struct drm_framebuffer *old_fb = state->fb; +unsigned long eba, ubo, vbo, old_eba, old_ubo, old_vbo;
It looks to me like eba, ubo, vbo are good candidates to be put into a custom ipu_plane_state structure during check.
regards
Philipp
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 06/14] drm/imx: atomic phase 1: Use transitional atomic CRTC and plane helpers
Quoted 34 lines · Philipp Zabel
Am Dienstag, den 24.05.2016, 18:10 +0800 schrieb Liu Ying:
Quoted 16 lines
Use the drm_plane_helper_update/disable() and
drm_helper_crtc_mode_set()transistional atomic helpers. Thecrtc->mode_set_nofbcallback is added so that the primary plane is no longer tied to the CRTC. Check/update logics are separated to make surecrtc->mode_set_nofbandplane->atomic_updateare always successful. Also, some necessary logics are tweaked for a smooth transition.Signed-off-by Liu Ying <[email protected]>--- drivers/gpu/drm/imx/ipuv3-crtc.c | 173 +++++++------ drivers/gpu/drm/imx/ipuv3-plane.c | 516 +++++++++++++++++++++++--------------- drivers/gpu/drm/imx/ipuv3-plane.h | 14 +- drivers/gpu/ipu-v3/ipu-dc.c | 5 +- drivers/gpu/ipu-v3/ipu-di.c | 3 - 5 files changed, 400 insertions(+), 311 deletions(-)[...]
Quoted 16 lines
drivers/gpu/drm/imx/ipuv3-plane.c +1
-0@@ -16,6 +16,7 @@#include <drm/drmP.h> #include <drm/drm_fb_cma_helper.h> #include <drm/drm_gem_cma_helper.h> +#include <drm/drm_plane_helper.h> #include "video/imx-ipu-v3.h" #include "ipuv3-plane.h" @@ -51,12 +52,15 @@ int ipu_plane_irq(struct ipu_plane *ipu_plane) IPU_IRQ_EOF); }
Quoted 13 lines
drivers/gpu/drm/imx/ipuv3-plane.c int ipu_plane_irq(struct ipu_plane *ipu_plane) · line 60
Quoted 10 lines
drivers/gpu/drm/imx/ipuv3-plane.c +5
-4-int ipu_plane_set_base (struct ipu_plane *ipu_plane,struct drm_framebuffer *fb, -int x,int y) +int ipu_plane_set_base (struct ipu_plane *ipu_plane,struct drm_framebuffer *fb) { -struct drm_gem_cma_object *cma_obj[3 ]; -unsigned long eba, ubo, vbo; +struct drm_gem_cma_object *cma_obj[3 ], *old_cma_obj[3 ]; +struct drm_plane_state *state = ipu_plane->base.state; +struct drm_framebuffer *old_fb = state->fb; +unsigned long eba, ubo, vbo, old_eba, old_ubo, old_vbo;It looks to me like eba, ubo, vbo are good candidates to be put into a custom
ipu_plane_statestructure during check.
Yes for the first impression. I'll think about that more. If the required change is too invasive and you accept, I'd like to customize ipu_plane_state with another patch(set) after this one is landed.
Regards,
Liu Ying
Quoted 4 lines
regards
Philipp
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 7/14 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.
--- drivers/gpu/drm/bridge/dw-hdmi.c | 19 +++---------------- 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(+), 16 deletions(-)
drivers/gpu/drm/bridge/dw-hdmi.c +3 -16
@@ -1508,14 +1508,6 @@ static void dw_hdmi_connector_force(struct drm_connector *connector)mutex_unlock (&hdmi->mutex); } -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, -}; -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,
@@ -1650,14 +1642,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_atomic_connector_funcs, +DRM_MODE_CONNECTOR_HDMIA );drm_mode_connector_attach_encoder (&hdmi->connector, encoder);
drivers/gpu/drm/imx/imx-drm-core.c +2 -0
@@ -283,6 +283,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>
@@ -357,6 +358,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>
@@ -358,6 +359,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>
@@ -233,6 +234,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>
@@ -146,6 +147,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
Philipp Zabel
maintainerRe: [PATCH 07/14] drm/imx: atomic phase 2 step 1: Wire up state ->reset, ->duplicate and ->destroy
Am Dienstag, den 24.05.2016, 18:10 +0800 schrieb Liu Ying:
Quoted 22 lines
Wire 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.
Signed-off-by Liu Ying <[email protected]>--- drivers/gpu/drm/bridge/dw-hdmi.c | 19 +++---------------- 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(+), 16 deletions(-)drivers/gpu/drm/bridge/dw-hdmi.c +0
-0@@ -1508,14 +1508,6 @@ static void dw_hdmi_connector_force(struct drm_connector *connector)mutex_unlock (&hdmi->mutex); }
drivers/gpu/drm/bridge/dw-hdmi.c static void dw_hdmi_connector_force(struct drm_connector *connector) · line 1511
Quoted 10 lines
drivers/gpu/drm/bridge/dw-hdmi.c +0
-8-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, -}; -static const struct drm_connector_funcs dw_hdmi_atomic_connector_funcs = {
Might as well remove the _atomic_ form the structure's name.
regards
Philipp
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 07/14] drm/imx: atomic phase 2 step 1: Wire up state ->reset, ->duplicate and ->destroy
Quoted 24 lines · Philipp Zabel
Am Dienstag, den 24.05.2016, 18:10 +0800 schrieb Liu Ying:
Quoted 23 lines
Wire 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.
Signed-off-by Liu Ying <[email protected]>--- drivers/gpu/drm/bridge/dw-hdmi.c | 19 +++---------------- 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(+), 16 deletions(-)drivers/gpu/drm/bridge/dw-hdmi.c +0
-0@@ -1508,14 +1508,6 @@ static void dw_hdmi_connector_force(struct drm_connector *connector)mutex_unlock (&hdmi->mutex); }
Quoted 11 lines
drivers/gpu/drm/bridge/dw-hdmi.c static void dw_hdmi_connector_force(struct drm_connector *connector) · line 1511
Quoted 9 lines
drivers/gpu/drm/bridge/dw-hdmi.c +0
-8-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, -}; -static const struct drm_connector_funcs dw_hdmi_atomic_connector_funcs = {Might as well remove the _atomic_ form the structure's name.
Good point. Will do.
Regards,
Liu Ying
Quoted 4 lines
regards
Philipp
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 8/14 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.
--- 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>
@@ -218,6 +219,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 9/14 drm/imx: atomic phase 3 step 1: Atomic updates for planes
In reply to Liu YingThis patch switches the update/disable_plane callbacks to their atomic version. Also, use the default atomic helpers to implement the atomic_check/commit callbacks for mode configuration.
--- drivers/gpu/drm/imx/imx-drm-core.c | 3 +++ drivers/gpu/drm/imx/ipuv3-plane.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/imx/imx-drm-core.c +3 -0
@@ -19,6 +19,7 @@#include <linux/module.h> #include <linux/platform_device.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_gem_cma_helper.h>
@@ -205,6 +206,8 @@ 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, };/*
drivers/gpu/drm/imx/ipuv3-plane.c +2 -2
@@ -360,8 +360,8 @@ static void ipu_plane_destroy(struct drm_plane *plane) }static const struct drm_plane_funcs ipu_plane_funcs = { - .update_plane = drm_plane_helper_update, - .disable_plane = drm_plane_helper_disable, + .update_plane = drm_atomic_helper_update_plane, + .disable_plane = drm_atomic_helper_disable_plane, .destroy = ipu_plane_destroy, .reset = drm_atomic_helper_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 10/14 drm/atomic-helper: Disable planes when suspending
In reply to Liu YingWe should disable planes explicitly when suspending. Especially, this is meaningful for those display controllers which don't support active planes without relevant CRTCs being enabled.
--- drivers/gpu/drm/drm_atomic_helper.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_atomic_helper.c +17 -1
@@ -1967,7 +1967,7 @@ commit:* * Loops through all connectors, finding those that aren't turned off and then * turns them off by setting their DPMS mode to OFF and deactivating the CRTC -* that they are connected to. +* that they are connected to. The relevant planes are deactivated as well. * * This is used for example in suspend/resume to disable all currently active * functions when suspending.
@@ -1997,6 +1997,7 @@ int drm_atomic_helper_disable_all(struct drm_device *dev,drm_for_each_connector (conn, dev) {struct drm_crtc *crtc = conn->state->crtc;struct drm_crtc_state *crtc_state; +struct drm_plane *plane;if (!crtc || conn->dpms !=DRM_MODE_DPMS_ON )continue ;
@@ -2008,6 +2009,21 @@ int drm_atomic_helper_disable_all(struct drm_device *dev, } crtc_state->active = false; + +drm_for_each_plane_mask (plane, dev, crtc_state->plane_mask) { +struct drm_plane_state *plane_state; + + plane_state =drm_atomic_get_plane_state (state, plane); +if (IS_ERR (plane_state)) { + err =PTR_ERR (plane_state); + goto free; + } + + err =drm_atomic_set_crtc_for_plane (plane_state,NULL ); +if (err !=0 ) + goto free; +drm_atomic_set_fb_for_plane (plane_state,NULL ); + } } err =drm_atomic_commit (state);
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 10/14] drm/atomic-helper: Disable planes when suspending
Quoted 5 lines · Liu Ying
We should disable planes explicitly when suspending. Especially, this is meaningful for those display controllers which don't support active planes without relevant CRTCs being enabled.
Signed-off-by Liu Ying <[email protected]>
Recommended way is to call drm_atomic_helper_disable_planes_on_crtc in your crtc's ->disable() callback if your hw needs this. This is a general problem (test e.g. dpms), not just an issue in suspend code.
Also unsetting the planes from state has a semantic meaning: It unpins the backing storage, which is definitely not what we want for suspend/resume. -Daniel
Quoted 54 lines
--- drivers/gpu/drm/drm_atomic_helper.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_atomic_helper.c +17
-1@@ -1967,7 +1967,7 @@ commit:* * Loops through all connectors, finding those that aren't turned off and then * turns them off by setting their DPMS mode to OFF and deactivating the CRTC -* that they are connected to. +* that they are connected to. The relevant planes are deactivated as well. * * This is used for example in suspend/resume to disable all currently active * functions when suspending. @@ -1997,6 +1997,7 @@ int drm_atomic_helper_disable_all(struct drm_device *dev,drm_for_each_connector (conn, dev) {struct drm_crtc *crtc = conn->state->crtc;struct drm_crtc_state *crtc_state; +struct drm_plane *plane;if (!crtc || conn->dpms !=DRM_MODE_DPMS_ON )continue ;@@ -2008,6 +2009,21 @@ int drm_atomic_helper_disable_all(struct drm_device *dev, } crtc_state->active = false; + +drm_for_each_plane_mask (plane, dev, crtc_state->plane_mask) { +struct drm_plane_state *plane_state; + + plane_state =drm_atomic_get_plane_state (state, plane); +if (IS_ERR (plane_state)) { + err =PTR_ERR (plane_state); + goto free; + } + + err =drm_atomic_set_crtc_for_plane (plane_state,NULL ); +if (err !=0 ) + goto free; +drm_atomic_set_fb_for_plane (plane_state,NULL ); + } } err =drm_atomic_commit (state);Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 10/14] drm/atomic-helper: Disable planes when suspending
Quoted 10 lines · Daniel Vetter
Quoted 5 lines · Liu Ying
We should disable planes explicitly when suspending. Especially, this is meaningful for those display controllers which don't support active planes without relevant CRTCs being enabled.
Signed-off-by Liu Ying <[email protected]>Recommended way is to call
drm_atomic_helper_disable_planes_on_crtcin your crtc's ->disable() callback if your hw needs this. This is a general problem (test e.g. dpms), not just an issue in suspend code.
It looks legacy fbdev unblank operation fails after call that function in ->disable(). I made the change on top of this patch set. If you have any idea, please help out here.
Regards,
Liu Ying
Quoted 55 lines
Also unsetting the planes from state has a semantic meaning: It unpins the backing storage, which is definitely not what we want for suspend/resume. -Daniel
Quoted 50 lines
--- drivers/gpu/drm/drm_atomic_helper.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_atomic_helper.c +17
-2@@ -1967,7 +1967,7 @@ commit:* * Loops through all connectors, finding those that aren't turned off and then * turns them off by setting their DPMS mode to OFF and deactivating the CRTC -* that they are connected to. +* that they are connected to. The relevant planes are deactivated as well. * * This is used for example in suspend/resume to disable all currently active * functions when suspending. @@ -1997,6 +1997,7 @@ int drm_atomic_helper_disable_all(struct drm_device *dev,drm_for_each_connector (conn, dev) {struct drm_crtc *crtc = conn->state->crtc;struct drm_crtc_state *crtc_state; +struct drm_plane *plane;if (!crtc || conn->dpms !=DRM_MODE_DPMS_ON )continue ;@@ -2008,6 +2009,21 @@ int drm_atomic_helper_disable_all(struct drm_device *dev, } crtc_state->active = false; + +drm_for_each_plane_mask (plane, dev, crtc_state->plane_mask) { +struct drm_plane_state *plane_state; + + plane_state =drm_atomic_get_plane_state (state, plane); +if (IS_ERR (plane_state)) { + err =PTR_ERR (plane_state); + goto free; + } + + err =drm_atomic_set_crtc_for_plane (plane_state,NULL ); +if (err !=0 ) + goto free; +drm_atomic_set_fb_for_plane (plane_state,NULL ); + } } err =drm_atomic_commit (state); --2.7.4
Quoted 9 lines
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 10/14] drm/atomic-helper: Disable planes when suspending
Quoted 8 lines · Ying Liu
Quoted 7 lines · Daniel Vetter
Quoted 5 lines · Liu Ying
We should disable planes explicitly when suspending. Especially, this is meaningful for those display controllers which don't support active planes without relevant CRTCs being enabled.
Signed-off-by Liu Ying <[email protected]>
Quoted 7 lines
Quoted 3 lines
Recommended way is to call
drm_atomic_helper_disable_planes_on_crtcin your crtc's ->disable() callback if your hw needs this. This is a general problem (test e.g. dpms), not just an issue in suspend code.It looks legacy fbdev unblank operation fails after call that function in ->disable(). I made the change on top of this patch set. If you have any idea, please help out here.
Please explain in detail what fails and how, but your patch here is definitely not the solution. This is something your driver must be able to handle, and which cannot be handled in all callers of ->atomic_commit. -Daniel
Quoted 68 lines
Regards,
Liu YingQuoted 64 lines
Also unsetting the planes from state has a semantic meaning: It unpins the backing storage, which is definitely not what we want for suspend/resume. -Daniel
Quoted 50 lines
--- drivers/gpu/drm/drm_atomic_helper.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_atomic_helper.c +17
-2@@ -1967,7 +1967,7 @@ commit:* * Loops through all connectors, finding those that aren't turned off and then * turns them off by setting their DPMS mode to OFF and deactivating the CRTC -* that they are connected to. +* that they are connected to. The relevant planes are deactivated as well. * * This is used for example in suspend/resume to disable all currently active * functions when suspending. @@ -1997,6 +1997,7 @@ int drm_atomic_helper_disable_all(struct drm_device *dev,drm_for_each_connector (conn, dev) {struct drm_crtc *crtc = conn->state->crtc;struct drm_crtc_state *crtc_state; +struct drm_plane *plane;if (!crtc || conn->dpms !=DRM_MODE_DPMS_ON )continue ;@@ -2008,6 +2009,21 @@ int drm_atomic_helper_disable_all(struct drm_device *dev, } crtc_state->active = false; + +drm_for_each_plane_mask (plane, dev, crtc_state->plane_mask) { +struct drm_plane_state *plane_state; + + plane_state =drm_atomic_get_plane_state (state, plane); +if (IS_ERR (plane_state)) { + err =PTR_ERR (plane_state); + goto free; + } + + err =drm_atomic_set_crtc_for_plane (plane_state,NULL ); +if (err !=0 ) + goto free; +drm_atomic_set_fb_for_plane (plane_state,NULL ); + } } err =drm_atomic_commit (state); --2.7.4
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 11/14 drm/imx: atomic phase 3 step 2: 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 makes us be able to use atomic configurations. All of these allows us to remove the crtc_funcs->mode_set callback as it is no longer used. Also, we may remove all the encoders' ->prepare callbacks as they can be replaced by ->disable. In consequence, the bus_format, di_vsync_pin and di_hsync_pin settings are moved from ->prepare to structure imx_encoder. 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.
--- drivers/gpu/drm/imx/dw_hdmi-imx.c | 18 +++--- drivers/gpu/drm/imx/imx-drm-core.c | 49 ++++----------- drivers/gpu/drm/imx/imx-drm.h | 11 +++- drivers/gpu/drm/imx/imx-ldb.c | 109 +++++++++++++++------------------ drivers/gpu/drm/imx/imx-tve.c | 56 +++++++---------- drivers/gpu/drm/imx/ipuv3-crtc.c | 63 +++++-------------- drivers/gpu/drm/imx/ipuv3-plane.c | 23 +++---- drivers/gpu/drm/imx/parallel-display.c | 56 ++++++++--------- 8 files changed, 159 insertions(+), 226 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 +12 -37
83 lines not on this page · raw message
drivers/gpu/drm/imx/imx-drm.h +9 -2
@@ -15,11 +15,18 @@ struct platform_device;unsigned int imx_drm_crtc_id (struct imx_drm_crtc *crtc); +struct imx_drm_encoder { +struct drm_encoder encoder; +int bus_format; +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);const struct drm_crtc_helper_funcs *crtc_helper_funcs;const struct drm_crtc_funcs *crtc_funcs; };
drivers/gpu/drm/imx/imx-ldb.c +51 -58
211 lines not on this page · raw message
drivers/gpu/drm/imx/imx-tve.c +22 -34
151 lines not on this page · raw message
drivers/gpu/drm/imx/ipuv3-crtc.c +16 -47
151 lines not on this page · raw message
drivers/gpu/drm/imx/ipuv3-plane.c +12 -11
@@ -14,6 +14,7 @@*/ #include <drm/drmP.h> +#include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> #include <drm/drm_fb_cma_helper.h> #include <drm/drm_gem_cma_helper.h>
@@ -374,31 +375,31 @@ static int ipu_plane_atomic_check(struct drm_plane *plane,struct drm_plane_state *old_state = plane->state;struct drm_crtc_state *crtc_state;struct device *dev = plane->dev->dev; -struct drm_crtc *crtc;struct drm_framebuffer *fb = state->fb;struct drm_framebuffer *old_fb = old_state->fb;unsigned long eba, ubo, vbo, old_ubo, old_vbo;/* Ok to disable */ if (!fb) -return old_fb ?0 : -EINVAL ; +return 0 ; + +if (!state->crtc) +return -EINVAL ; + + crtc_state = +drm_atomic_get_existing_crtc_state (state->state, state->crtc); +if (WARN_ON (!crtc_state)) +return -EINVAL ;/* CRTC should be enabled */ -drm_for_each_crtc (crtc, plane->dev) { -if (drm_crtc_mask (crtc) == plane->possible_crtcs) { -if (!crtc->enabled) -return -EINVAL ; -break ; - } - } +if (!crtc_state->enable) +return -EINVAL ;/* no scaling */ if (state->src_w >>16 != state->crtc_w || state->src_h >>16 != state->crtc_h)return -EINVAL ; - crtc_state = state->crtc->state; -switch (plane->type) {case DRM_PLANE_TYPE_PRIMARY :/* full plane doesn't support partial off screen */
drivers/gpu/drm/imx/parallel-display.c +28 -28
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 12/14 drm/imx: atomic phase 3 step 3: 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.
--- drivers/gpu/drm/imx/dw_hdmi-imx.c | 4 ++-- drivers/gpu/drm/imx/imx-ldb.c | 16 ++++++------- drivers/gpu/drm/imx/imx-tve.c | 19 +++------------ drivers/gpu/drm/imx/ipuv3-crtc.c | 43 +++++----------------------------- drivers/gpu/drm/imx/parallel-display.c | 18 +++----------- 5 files changed, 22 insertions(+), 78 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
@@ -137,10 +137,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) {
@@ -169,7 +165,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);
@@ -180,8 +176,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) {
@@ -321,7 +322,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,
@@ -340,9 +341,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 +3 -16
@@ -274,18 +274,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)
@@ -323,7 +311,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 +328,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 +348,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 -37
78 lines not on this page · raw message
drivers/gpu/drm/imx/parallel-display.c +3 -15
@@ -103,18 +103,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);
@@ -139,7 +128,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,
@@ -158,9 +147,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 13/14 drm/imx: atomic phase 3 step 4: Use generic atomic page flip
In reply to Liu YingTo support generic atomic page flip, this patch customizes ->atomic_commit for async commits.
--- drivers/gpu/drm/imx/imx-drm-core.c | 137 +++++++++++++++++++++++++++++++- drivers/gpu/drm/imx/ipuv3-crtc.c | 156 ++----------------------------------- 2 files changed, 144 insertions(+), 149 deletions(-)
drivers/gpu/drm/imx/imx-drm-core.c +136 -1
@@ -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 <linux/wait.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>
@@ -48,6 +52,14 @@ struct imx_drm_device {struct imx_drm_crtc {struct drm_crtc *crtc;struct imx_drm_crtc_helper_funcs imx_drm_helper_funcs; +wait_queue_head_t commit_wait; +bool commit_pending; +}; + +struct imx_drm_commit { +struct work_struct work; +struct drm_device *dev; +struct drm_atomic_state *state; };#if IS_ENABLED (CONFIG_DRM_FBDEV_EMULATION )
@@ -168,11 +180,132 @@ static void imx_drm_output_poll_changed(struct drm_device *drm)drm_fbdev_cma_hotplug_event (imxdrm->fbhelper); } +static void imx_drm_atomic_complete (struct imx_drm_commit *commit,bool async) +{ +struct drm_device *dev = commit->dev; +struct imx_drm_device *imxdrm = dev->dev_private; +struct imx_drm_crtc *imx_crtc; +struct drm_atomic_state *old_state = commit->state; +struct drm_crtc *crtc; +struct drm_crtc_state *old_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 (old_state, crtc, old_crtc_state, i) { +if (crtc->state->event) { + plane_state = crtc->primary->state; + 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]); + } + } + } + } + +/* Apply the atomic update. */ +drm_atomic_helper_commit_modeset_disables (dev, old_state); +drm_atomic_helper_commit_modeset_enables (dev, old_state); +drm_atomic_helper_commit_planes (dev, old_state, false); +drm_atomic_helper_wait_for_vblanks (dev, old_state); +drm_atomic_helper_cleanup_planes (dev, old_state); + +if (async) +for_each_crtc_in_state (old_state, crtc, old_crtc_state, i) { + imx_crtc = imxdrm->crtc[i]; + +/* Complete the commit, wake up any waiter. */ +spin_lock (&imx_crtc->commit_wait.lock); + imx_crtc->commit_pending = false; +wake_up_all_locked (&imx_crtc->commit_wait); +spin_unlock (&imx_crtc->commit_wait.lock); + } + +drm_atomic_state_free (old_state); + +kfree (commit); +} + +static void imx_drm_atomic_work (struct work_struct *work) +{ +struct imx_drm_commit *commit = + container_of(work, struct imx_drm_commit, work); + +imx_drm_atomic_complete (commit, true); +} + +static int imx_drm_atomic_commit (struct drm_device *dev, +struct drm_atomic_state *state,bool async) +{ +struct imx_drm_device *imxdrm = dev->dev_private; +struct imx_drm_crtc *imx_crtc; +struct imx_drm_commit *commit; +struct drm_crtc *crtc; +struct drm_crtc_state *crtc_state; +unsigned int i; +int ret; + + commit =kzalloc (sizeof (*commit),GFP_KERNEL ); +if (commit ==NULL ) +return -ENOMEM ; + + commit->dev = dev; + commit->state = state; + +if (async) { +for_each_crtc_in_state (state, crtc, crtc_state, i) { + imx_crtc = imxdrm->crtc[i]; + +spin_lock (&imx_crtc->commit_wait.lock); + ret =wait_event_interruptible_locked ( + imx_crtc->commit_wait, + !imx_crtc->commit_pending); +if (ret ==0 ) + imx_crtc->commit_pending = true; +spin_unlock (&imx_crtc->commit_wait.lock); + +if (ret) { +kfree (commit); +return ret; + } + } + +INIT_WORK (&commit->work, imx_drm_atomic_work); + } + +drm_atomic_helper_swap_state (dev, state); + +if (async) +schedule_work (&commit->work); +else +imx_drm_atomic_complete (commit, async); + +return 0 ; +} +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, + .atomic_commit = imx_drm_atomic_commit, };/*
@@ -315,6 +448,8 @@ int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc, imx_drm_crtc->imx_drm_helper_funcs = *imx_drm_helper_funcs; imx_drm_crtc->crtc = crtc; +init_waitqueue_head (&imx_drm_crtc->commit_wait); + crtc->port = port; imxdrm->crtc[imxdrm->pipes++] = imx_drm_crtc;
drivers/gpu/drm/imx/ipuv3-crtc.c +8 -148
213 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
Re: [PATCH 13/14] drm/imx: atomic phase 3 step 4: Use generic atomic page flip
Quoted 2 lines · Liu Ying
To support generic atomic page flip, this patch customizes ->atomic_commit for async commits.
It's now called nonblocking instead of async. Please run s/async/nonblock/ over this patch.
-Daniel
Quoted 414 lines
Signed-off-by Liu Ying <[email protected]>--- drivers/gpu/drm/imx/imx-drm-core.c | 137 +++++++++++++++++++++++++++++++- drivers/gpu/drm/imx/ipuv3-crtc.c | 156 ++----------------------------------- 2 files changed, 144 insertions(+), 149 deletions(-)drivers/gpu/drm/imx/imx-drm-core.c +136
-1@@ -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 <linux/wait.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> @@ -48,6 +52,14 @@ struct imx_drm_device {struct imx_drm_crtc {struct drm_crtc *crtc;struct imx_drm_crtc_helper_funcs imx_drm_helper_funcs; +wait_queue_head_t commit_wait; +bool commit_pending; +}; + +struct imx_drm_commit { +struct work_struct work; +struct drm_device *dev; +struct drm_atomic_state *state; };#if IS_ENABLED (CONFIG_DRM_FBDEV_EMULATION )@@ -168,11 +180,132 @@ static void imx_drm_output_poll_changed(struct drm_device *drm)drm_fbdev_cma_hotplug_event (imxdrm->fbhelper); } +static void imx_drm_atomic_complete (struct imx_drm_commit *commit,bool async) +{ +struct drm_device *dev = commit->dev; +struct imx_drm_device *imxdrm = dev->dev_private; +struct imx_drm_crtc *imx_crtc; +struct drm_atomic_state *old_state = commit->state; +struct drm_crtc *crtc; +struct drm_crtc_state *old_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 (old_state, crtc, old_crtc_state, i) { +if (crtc->state->event) { + plane_state = crtc->primary->state; + 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]); + } + } + } + } + +/* Apply the atomic update. */ +drm_atomic_helper_commit_modeset_disables (dev, old_state); +drm_atomic_helper_commit_modeset_enables (dev, old_state); +drm_atomic_helper_commit_planes (dev, old_state, false); +drm_atomic_helper_wait_for_vblanks (dev, old_state); +drm_atomic_helper_cleanup_planes (dev, old_state); + +if (async) +for_each_crtc_in_state (old_state, crtc, old_crtc_state, i) { + imx_crtc = imxdrm->crtc[i]; + +/* Complete the commit, wake up any waiter. */ +spin_lock (&imx_crtc->commit_wait.lock); + imx_crtc->commit_pending = false; +wake_up_all_locked (&imx_crtc->commit_wait); +spin_unlock (&imx_crtc->commit_wait.lock); + } + +drm_atomic_state_free (old_state); + +kfree (commit); +} + +static void imx_drm_atomic_work (struct work_struct *work) +{ +struct imx_drm_commit *commit = + container_of(work, struct imx_drm_commit, work); + +imx_drm_atomic_complete (commit, true); +} + +static int imx_drm_atomic_commit (struct drm_device *dev, +struct drm_atomic_state *state,bool async) +{ +struct imx_drm_device *imxdrm = dev->dev_private; +struct imx_drm_crtc *imx_crtc; +struct imx_drm_commit *commit; +struct drm_crtc *crtc; +struct drm_crtc_state *crtc_state; +unsigned int i; +int ret; + + commit =kzalloc (sizeof (*commit),GFP_KERNEL ); +if (commit ==NULL ) +return -ENOMEM ; + + commit->dev = dev; + commit->state = state; + +if (async) { +for_each_crtc_in_state (state, crtc, crtc_state, i) { + imx_crtc = imxdrm->crtc[i]; + +spin_lock (&imx_crtc->commit_wait.lock); + ret =wait_event_interruptible_locked ( + imx_crtc->commit_wait, + !imx_crtc->commit_pending); +if (ret ==0 ) + imx_crtc->commit_pending = true; +spin_unlock (&imx_crtc->commit_wait.lock); + +if (ret) { +kfree (commit); +return ret; + } + } + +INIT_WORK (&commit->work, imx_drm_atomic_work); + } + +drm_atomic_helper_swap_state (dev, state); + +if (async) +schedule_work (&commit->work); +else +imx_drm_atomic_complete (commit, async); + +return 0 ; +} +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, + .atomic_commit = imx_drm_atomic_commit, };/* @@ -315,6 +448,8 @@ int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc, imx_drm_crtc->imx_drm_helper_funcs = *imx_drm_helper_funcs; imx_drm_crtc->crtc = crtc; +init_waitqueue_head (&imx_drm_crtc->commit_wait); + crtc->port = port; imxdrm->crtc[imxdrm->pipes++] = imx_drm_crtc;drivers/gpu/drm/imx/ipuv3-crtc.c +8
-148@@ -24,8 +24,6 @@#include <linux/fb.h> #include <linux/clk.h> #include <linux/errno.h> -#include <linux/reservation.h> -#include <linux/dma-buf.h> #include <drm/drm_gem_cma_helper.h> #include <drm/drm_fb_cma_helper.h> @@ -35,23 +33,6 @@#define DRIVER_DESC "i.MX IPUv3 Graphics" -enum ipu_flip_status { -IPU_FLIP_NONE , -IPU_FLIP_PENDING , -IPU_FLIP_SUBMITTED , -}; - -struct ipu_flip_work { -struct work_struct unref_work; -struct drm_gem_object *bo; -struct drm_pending_vblank_event *page_flip_event; -struct work_struct fence_work; -struct ipu_crtc *crtc; -struct fence *excl; -unsigned shared_count; -struct fence **shared; -}; -struct ipu_crtc {struct device *dev;struct drm_crtc base;@@ -62,9 +43,6 @@ struct ipu_crtc {struct ipu_dc *dc;struct ipu_di *di; -enum ipu_flip_status flip_state; -struct workqueue_struct *flip_queue; -struct ipu_flip_work *flip_work;int irq; };@@ -94,150 +72,35 @@ static void ipu_crtc_disable(struct drm_crtc *crtc)drm_crtc_vblank_off (&ipu_crtc->base); } -static void ipu_flip_unref_work_func (struct work_struct *__work) -{ -struct ipu_flip_work *work = - container_of(__work, struct ipu_flip_work, unref_work); - -drm_gem_object_unreference_unlocked (work->bo); -kfree (work); -} - -static void ipu_flip_fence_work_func (struct work_struct *__work) -{ -struct ipu_flip_work *work = - container_of(__work, struct ipu_flip_work, fence_work); -int i; - -/* wait for all fences attached to the FB obj to signal */ -if (work->excl) { -fence_wait (work->excl, false); -fence_put (work->excl); - } -for (i =0 ; i < work->shared_count; i++) { -fence_wait (work->shared[i], false); -fence_put (work->shared[i]); - } - - work->crtc->flip_state =IPU_FLIP_SUBMITTED ; -} - -static int ipu_page_flip (struct drm_crtc *crtc, -struct drm_framebuffer *fb, -struct drm_pending_vblank_event *event, -uint32_t page_flip_flags) -{ -struct drm_gem_cma_object *cma_obj =drm_fb_cma_get_gem_obj (fb,0 ); -struct ipu_crtc *ipu_crtc =to_ipu_crtc (crtc); -struct ipu_flip_work *flip_work; -int ret; - -if (ipu_crtc->flip_state !=IPU_FLIP_NONE ) -return -EBUSY ; - - ret =imx_drm_crtc_vblank_get (ipu_crtc->imx_crtc); -if (ret) { -dev_dbg (ipu_crtc->dev,"failed to acquire vblank counter\n" ); -list_del (&event->base.link); - -return ret; - } - - flip_work =kzalloc (sizeof *flip_work,GFP_KERNEL ); -if (!flip_work) { - ret = -ENOMEM ; - goto put_vblank; - } -INIT_WORK (&flip_work->unref_work, ipu_flip_unref_work_func); - flip_work->page_flip_event = event; - -/* get BO backing the old framebuffer and take a reference */ - flip_work->bo = &drm_fb_cma_get_gem_obj (crtc->primary->fb,0 )->base; -drm_gem_object_reference (flip_work->bo); - - ipu_crtc->flip_work = flip_work; -/* -* If the object has a DMABUF attached, we need to wait on its fences -* if there are any. -*/ -if (cma_obj->base.dma_buf) { -INIT_WORK (&flip_work->fence_work, ipu_flip_fence_work_func); - flip_work->crtc = ipu_crtc; - - ret =reservation_object_get_fences_rcu ( - cma_obj->base.dma_buf->resv, &flip_work->excl, - &flip_work->shared_count, &flip_work->shared); - -if (unlikely (ret)) { -DRM_ERROR ("failed to get fences for buffer\n" ); - goto free_flip_work; - } - -/* No need to queue the worker if the are no fences */ -if (!flip_work->excl && !flip_work->shared_count) { - ipu_crtc->flip_state =IPU_FLIP_SUBMITTED ; - }else { - ipu_crtc->flip_state =IPU_FLIP_PENDING ; -queue_work (ipu_crtc->flip_queue, - &flip_work->fence_work); - } - }else { - 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: -drm_gem_object_unreference_unlocked (flip_work->bo); -kfree (flip_work); - ipu_crtc->flip_work =NULL ; -put_vblank: -imx_drm_crtc_vblank_put (ipu_crtc->imx_crtc); - -return ret; -} -static const struct drm_crtc_funcs ipu_crtc_funcs = { .set_config = drm_atomic_helper_set_config, .destroy = drm_crtc_cleanup, - .page_flip = ipu_page_flip, + .page_flip = drm_atomic_helper_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) +static void ipu_crtc_handle_pageflip (struct drm_crtc *crtc) { +struct drm_device *drm = crtc->dev;unsigned long flags; -struct drm_device *drm = ipu_crtc->base.dev; -struct ipu_flip_work *work = ipu_crtc->flip_work;spin_lock_irqsave (&drm->event_lock, flags); -if (work->page_flip_event) -drm_crtc_send_vblank_event (&ipu_crtc->base, - work->page_flip_event); -imx_drm_crtc_vblank_put (ipu_crtc->imx_crtc); +drm_crtc_send_vblank_event (crtc, crtc->state->event); + crtc->state->event =NULL ;spin_unlock_irqrestore (&drm->event_lock, flags); }static irqreturn_t ipu_irq_handler (int irq,void *dev_id) {struct ipu_crtc *ipu_crtc = dev_id; +struct drm_crtc *crtc = &ipu_crtc->base;imx_drm_handle_vblank (ipu_crtc->imx_crtc); -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); -ipu_crtc_handle_pageflip (ipu_crtc); -queue_work (ipu_crtc->flip_queue, - &ipu_crtc->flip_work->unref_work); - ipu_crtc->flip_state =IPU_FLIP_NONE ; - } +if (crtc->state->event) +ipu_crtc_handle_pageflip (crtc);return IRQ_HANDLED ; }@@ -452,8 +315,6 @@ static int ipu_crtc_init(struct ipu_crtc *ipu_crtc,ipu_plane_put_resources (ipu_crtc->plane[0 ]); - ipu_crtc->flip_queue =create_singlethread_workqueue ("ipu-crtc-flip" ); -return 0 ; err_put_plane_res:@@ -495,7 +356,6 @@ 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_put_resources (ipu_crtc); }Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 13/14] drm/imx: atomic phase 3 step 4: Use generic atomic page flip
Quoted 6 lines · Daniel Vetter
Quoted 2 lines · Liu Ying
To support generic atomic page flip, this patch customizes ->atomic_commit for async commits.
It's now called nonblocking instead of async. Please run s/async/nonblock/ over this patch.
Ok. Will do.
Regards,
Liu Ying
Quoted 412 lines
-Daniel
Quoted 410 lines
Signed-off-by Liu Ying <[email protected]>--- drivers/gpu/drm/imx/imx-drm-core.c | 137 +++++++++++++++++++++++++++++++- drivers/gpu/drm/imx/ipuv3-crtc.c | 156 ++----------------------------------- 2 files changed, 144 insertions(+), 149 deletions(-)drivers/gpu/drm/imx/imx-drm-core.c +136
-1@@ -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 <linux/wait.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> @@ -48,6 +52,14 @@ struct imx_drm_device {struct imx_drm_crtc {struct drm_crtc *crtc;struct imx_drm_crtc_helper_funcs imx_drm_helper_funcs; +wait_queue_head_t commit_wait; +bool commit_pending; +}; + +struct imx_drm_commit { +struct work_struct work; +struct drm_device *dev; +struct drm_atomic_state *state; };#if IS_ENABLED (CONFIG_DRM_FBDEV_EMULATION )@@ -168,11 +180,132 @@ static void imx_drm_output_poll_changed(struct drm_device *drm)drm_fbdev_cma_hotplug_event (imxdrm->fbhelper); } +static void imx_drm_atomic_complete (struct imx_drm_commit *commit,bool async) +{ +struct drm_device *dev = commit->dev; +struct imx_drm_device *imxdrm = dev->dev_private; +struct imx_drm_crtc *imx_crtc; +struct drm_atomic_state *old_state = commit->state; +struct drm_crtc *crtc; +struct drm_crtc_state *old_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 (old_state, crtc, old_crtc_state, i) { +if (crtc->state->event) { + plane_state = crtc->primary->state; + 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]); + } + } + } + } + +/* Apply the atomic update. */ +drm_atomic_helper_commit_modeset_disables (dev, old_state); +drm_atomic_helper_commit_modeset_enables (dev, old_state); +drm_atomic_helper_commit_planes (dev, old_state, false); +drm_atomic_helper_wait_for_vblanks (dev, old_state); +drm_atomic_helper_cleanup_planes (dev, old_state); + +if (async) +for_each_crtc_in_state (old_state, crtc, old_crtc_state, i) { + imx_crtc = imxdrm->crtc[i]; + +/* Complete the commit, wake up any waiter. */ +spin_lock (&imx_crtc->commit_wait.lock); + imx_crtc->commit_pending = false; +wake_up_all_locked (&imx_crtc->commit_wait); +spin_unlock (&imx_crtc->commit_wait.lock); + } + +drm_atomic_state_free (old_state); + +kfree (commit); +} + +static void imx_drm_atomic_work (struct work_struct *work) +{ +struct imx_drm_commit *commit = + container_of(work, struct imx_drm_commit, work); + +imx_drm_atomic_complete (commit, true); +} + +static int imx_drm_atomic_commit (struct drm_device *dev, +struct drm_atomic_state *state,bool async) +{ +struct imx_drm_device *imxdrm = dev->dev_private; +struct imx_drm_crtc *imx_crtc; +struct imx_drm_commit *commit; +struct drm_crtc *crtc; +struct drm_crtc_state *crtc_state; +unsigned int i; +int ret; + + commit =kzalloc (sizeof (*commit),GFP_KERNEL ); +if (commit ==NULL ) +return -ENOMEM ; + + commit->dev = dev; + commit->state = state; + +if (async) { +for_each_crtc_in_state (state, crtc, crtc_state, i) { + imx_crtc = imxdrm->crtc[i]; + +spin_lock (&imx_crtc->commit_wait.lock); + ret =wait_event_interruptible_locked ( + imx_crtc->commit_wait, + !imx_crtc->commit_pending); +if (ret ==0 ) + imx_crtc->commit_pending = true; +spin_unlock (&imx_crtc->commit_wait.lock); + +if (ret) { +kfree (commit); +return ret; + } + } + +INIT_WORK (&commit->work, imx_drm_atomic_work); + } + +drm_atomic_helper_swap_state (dev, state); + +if (async) +schedule_work (&commit->work); +else +imx_drm_atomic_complete (commit, async); + +return 0 ; +} +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, + .atomic_commit = imx_drm_atomic_commit, };/* @@ -315,6 +448,8 @@ int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc, imx_drm_crtc->imx_drm_helper_funcs = *imx_drm_helper_funcs; imx_drm_crtc->crtc = crtc; +init_waitqueue_head (&imx_drm_crtc->commit_wait); + crtc->port = port; imxdrm->crtc[imxdrm->pipes++] = imx_drm_crtc;drivers/gpu/drm/imx/ipuv3-crtc.c +8
-149@@ -24,8 +24,6 @@#include <linux/fb.h> #include <linux/clk.h> #include <linux/errno.h> -#include <linux/reservation.h> -#include <linux/dma-buf.h> #include <drm/drm_gem_cma_helper.h> #include <drm/drm_fb_cma_helper.h> @@ -35,23 +33,6 @@#define DRIVER_DESC "i.MX IPUv3 Graphics" -enum ipu_flip_status { -IPU_FLIP_NONE , -IPU_FLIP_PENDING , -IPU_FLIP_SUBMITTED , -}; - -struct ipu_flip_work { -struct work_struct unref_work; -struct drm_gem_object *bo; -struct drm_pending_vblank_event *page_flip_event; -struct work_struct fence_work; -struct ipu_crtc *crtc; -struct fence *excl; -unsigned shared_count; -struct fence **shared; -}; -struct ipu_crtc {struct device *dev;struct drm_crtc base;@@ -62,9 +43,6 @@ struct ipu_crtc {struct ipu_dc *dc;struct ipu_di *di; -enum ipu_flip_status flip_state; -struct workqueue_struct *flip_queue; -struct ipu_flip_work *flip_work;int irq; };@@ -94,150 +72,35 @@ static void ipu_crtc_disable(struct drm_crtc *crtc)drm_crtc_vblank_off (&ipu_crtc->base); } -static void ipu_flip_unref_work_func (struct work_struct *__work) -{ -struct ipu_flip_work *work = - container_of(__work, struct ipu_flip_work, unref_work); - -drm_gem_object_unreference_unlocked (work->bo); -kfree (work); -} - -static void ipu_flip_fence_work_func (struct work_struct *__work) -{ -struct ipu_flip_work *work = - container_of(__work, struct ipu_flip_work, fence_work); -int i; - -/* wait for all fences attached to the FB obj to signal */ -if (work->excl) { -fence_wait (work->excl, false); -fence_put (work->excl); - } -for (i =0 ; i < work->shared_count; i++) { -fence_wait (work->shared[i], false); -fence_put (work->shared[i]); - } - - work->crtc->flip_state =IPU_FLIP_SUBMITTED ; -} - -static int ipu_page_flip (struct drm_crtc *crtc, -struct drm_framebuffer *fb, -struct drm_pending_vblank_event *event, -uint32_t page_flip_flags) -{ -struct drm_gem_cma_object *cma_obj =drm_fb_cma_get_gem_obj (fb,0 ); -struct ipu_crtc *ipu_crtc =to_ipu_crtc (crtc); -struct ipu_flip_work *flip_work; -int ret; - -if (ipu_crtc->flip_state !=IPU_FLIP_NONE ) -return -EBUSY ; - - ret =imx_drm_crtc_vblank_get (ipu_crtc->imx_crtc); -if (ret) { -dev_dbg (ipu_crtc->dev,"failed to acquire vblank counter\n" ); -list_del (&event->base.link); - -return ret; - } - - flip_work =kzalloc (sizeof *flip_work,GFP_KERNEL ); -if (!flip_work) { - ret = -ENOMEM ; - goto put_vblank; - } -INIT_WORK (&flip_work->unref_work, ipu_flip_unref_work_func); - flip_work->page_flip_event = event; - -/* get BO backing the old framebuffer and take a reference */ - flip_work->bo = &drm_fb_cma_get_gem_obj (crtc->primary->fb,0 )->base; -drm_gem_object_reference (flip_work->bo); - - ipu_crtc->flip_work = flip_work; -/* -* If the object has a DMABUF attached, we need to wait on its fences -* if there are any. -*/ -if (cma_obj->base.dma_buf) { -INIT_WORK (&flip_work->fence_work, ipu_flip_fence_work_func); - flip_work->crtc = ipu_crtc; - - ret =reservation_object_get_fences_rcu ( - cma_obj->base.dma_buf->resv, &flip_work->excl, - &flip_work->shared_count, &flip_work->shared); - -if (unlikely (ret)) { -DRM_ERROR ("failed to get fences for buffer\n" ); - goto free_flip_work; - } - -/* No need to queue the worker if the are no fences */ -if (!flip_work->excl && !flip_work->shared_count) { - ipu_crtc->flip_state =IPU_FLIP_SUBMITTED ; - }else { - ipu_crtc->flip_state =IPU_FLIP_PENDING ; -queue_work (ipu_crtc->flip_queue, - &flip_work->fence_work); - } - }else { - 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: -drm_gem_object_unreference_unlocked (flip_work->bo); -kfree (flip_work); - ipu_crtc->flip_work =NULL ; -put_vblank: -imx_drm_crtc_vblank_put (ipu_crtc->imx_crtc); - -return ret; -} -static const struct drm_crtc_funcs ipu_crtc_funcs = { .set_config = drm_atomic_helper_set_config, .destroy = drm_crtc_cleanup, - .page_flip = ipu_page_flip, + .page_flip = drm_atomic_helper_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) +static void ipu_crtc_handle_pageflip (struct drm_crtc *crtc) { +struct drm_device *drm = crtc->dev;unsigned long flags; -struct drm_device *drm = ipu_crtc->base.dev; -struct ipu_flip_work *work = ipu_crtc->flip_work;spin_lock_irqsave (&drm->event_lock, flags); -if (work->page_flip_event) -drm_crtc_send_vblank_event (&ipu_crtc->base, - work->page_flip_event); -imx_drm_crtc_vblank_put (ipu_crtc->imx_crtc); +drm_crtc_send_vblank_event (crtc, crtc->state->event); + crtc->state->event =NULL ;spin_unlock_irqrestore (&drm->event_lock, flags); }static irqreturn_t ipu_irq_handler (int irq,void *dev_id) {struct ipu_crtc *ipu_crtc = dev_id; +struct drm_crtc *crtc = &ipu_crtc->base;imx_drm_handle_vblank (ipu_crtc->imx_crtc); -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); -ipu_crtc_handle_pageflip (ipu_crtc); -queue_work (ipu_crtc->flip_queue, - &ipu_crtc->flip_work->unref_work); - ipu_crtc->flip_state =IPU_FLIP_NONE ; - } +if (crtc->state->event) +ipu_crtc_handle_pageflip (crtc);return IRQ_HANDLED ; }@@ -452,8 +315,6 @@ static int ipu_crtc_init(struct ipu_crtc *ipu_crtc,ipu_plane_put_resources (ipu_crtc->plane[0 ]); - ipu_crtc->flip_queue =create_singlethread_workqueue ("ipu-crtc-flip" ); -return 0 ; err_put_plane_res:@@ -495,7 +356,6 @@ 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_put_resources (ipu_crtc); } --2.7.4
Quoted 9 lines
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 14/14 drm/imx: atomic phase 3 step 5: Advertise DRIVER_ATOMIC
In reply to Liu YingWith all the beforehand phases and steps done, we can adverstise DRIVER_ATOMIC.
--- 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
@@ -512,7 +512,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
Philipp Zabel
maintainerHi Liu,
Am Dienstag, den 24.05.2016, 18:10 +0800 schrieb Liu Ying:
Quoted 5 lines
Hi,
This patch set converts imx drm into atomic mode setting.
It takes 3 phases to achieve the goal as recommended.
This patch set may apply to Philipp Zabel's open git branch imx-drm/fixes.
Thank you for the rework! Could I ask you to rebase this onto imx-drm/next?
I have applied the first two patches, and I have some superficial comments for some of the later patches at this time. Still have to look at the rest in detail.
best regards
Philipp
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 11 lines · Philipp Zabel
Hi Liu,
Am Dienstag, den 24.05.2016, 18:10 +0800 schrieb Liu Ying:
Quoted 5 lines
Hi,
This patch set converts imx drm into atomic mode setting.
It takes 3 phases to achieve the goal as recommended.
This patch set may apply to Philipp Zabel's open git branch imx-drm/fixes.Thank you for the rework! Could I ask you to rebase this onto imx-drm/next?
With some comments addressed, I have a local version which is based on imx-drm/next. Will send it out after it is mature.
Quoted 3 lines
I have applied the first two patches, and I have some superficial comments for some of the later patches at this time. Still have to look at the rest in detail.
Thanks for the review.
Regards,
Liu Ying
Quoted 4 lines
best regards
Philipp
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel