Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/atomic-helper: Add NO_DISABLE_AFTER_MODESET flag support for plane commit

Drivers may set the NO_DISABLE_AFTER_MODESET flag in the 'flags' parameter
of the helper drm_atomic_helper_commit_planes() if the relevant display
controllers(e.g., IPUv3 for imx-drm) require to disable a CRTC's planes
when the CRTC is disabled. The helper would skip the ->atomic_disable
call for a plane if the CRTC of the old plane state needs a modesetting
operation. Of course, the drivers need to disable the planes in their CRTC
disable callbacks since no one else would do that.

Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: David Airlie <airlied@linux.ie>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Peter Senna Tschudin <peter.senna@gmail.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Liu Ying <gnuiyl@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1472461923-14364-1-git-send-email-gnuiyl@gmail.com

authored by

Liu Ying and committed by
Daniel Vetter
2b58e98d 28500291

+59 -28
+2 -1
drivers/gpu/drm/arm/malidp_drv.c
··· 91 91 92 92 drm_atomic_helper_commit_modeset_disables(drm, state); 93 93 drm_atomic_helper_commit_modeset_enables(drm, state); 94 - drm_atomic_helper_commit_planes(drm, state, true); 94 + drm_atomic_helper_commit_planes(drm, state, 95 + DRM_PLANE_COMMIT_ACTIVE_ONLY); 95 96 96 97 malidp_atomic_commit_hw_done(state); 97 98
+1 -1
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
··· 457 457 458 458 /* Apply the atomic update. */ 459 459 drm_atomic_helper_commit_modeset_disables(dev, old_state); 460 - drm_atomic_helper_commit_planes(dev, old_state, false); 460 + drm_atomic_helper_commit_planes(dev, old_state, 0); 461 461 drm_atomic_helper_commit_modeset_enables(dev, old_state); 462 462 463 463 drm_atomic_helper_wait_for_vblanks(dev, old_state);
+31 -12
drivers/gpu/drm/drm_atomic_helper.c
··· 1148 1148 * 1149 1149 * drm_atomic_helper_commit_modeset_enables(dev, state); 1150 1150 * 1151 - * drm_atomic_helper_commit_planes(dev, state, true); 1151 + * drm_atomic_helper_commit_planes(dev, state, 1152 + * DRM_PLANE_COMMIT_ACTIVE_ONLY); 1152 1153 * 1153 1154 * for committing the atomic update to hardware. See the kerneldoc entries for 1154 1155 * these three functions for more details. ··· 1160 1159 1161 1160 drm_atomic_helper_commit_modeset_disables(dev, state); 1162 1161 1163 - drm_atomic_helper_commit_planes(dev, state, false); 1162 + drm_atomic_helper_commit_planes(dev, state, 0); 1164 1163 1165 1164 drm_atomic_helper_commit_modeset_enables(dev, state); 1166 1165 ··· 1679 1678 * drm_atomic_helper_commit_planes - commit plane state 1680 1679 * @dev: DRM device 1681 1680 * @old_state: atomic state object with old state structures 1682 - * @active_only: Only commit on active CRTC if set 1681 + * @flags: flags for committing plane state 1683 1682 * 1684 1683 * This function commits the new plane state using the plane and atomic helper 1685 1684 * functions for planes and crtcs. It assumes that the atomic state has already ··· 1699 1698 * most drivers don't need to be immediately notified of plane updates for a 1700 1699 * disabled CRTC. 1701 1700 * 1702 - * Unless otherwise needed, drivers are advised to set the @active_only 1703 - * parameters to true in order not to receive plane update notifications related 1704 - * to a disabled CRTC. This avoids the need to manually ignore plane updates in 1701 + * Unless otherwise needed, drivers are advised to set the ACTIVE_ONLY flag in 1702 + * @flags in order not to receive plane update notifications related to a 1703 + * disabled CRTC. This avoids the need to manually ignore plane updates in 1705 1704 * driver code when the driver and/or hardware can't or just don't need to deal 1706 1705 * with updates on disabled CRTCs, for example when supporting runtime PM. 1707 1706 * 1708 - * The drm_atomic_helper_commit() default implementation only sets @active_only 1709 - * to false to most closely match the behaviour of the legacy helpers. This should 1710 - * not be copied blindly by drivers. 1707 + * Drivers may set the NO_DISABLE_AFTER_MODESET flag in @flags if the relevant 1708 + * display controllers require to disable a CRTC's planes when the CRTC is 1709 + * disabled. This function would skip the ->atomic_disable call for a plane if 1710 + * the CRTC of the old plane state needs a modesetting operation. Of course, 1711 + * the drivers need to disable the planes in their CRTC disable callbacks 1712 + * since no one else would do that. 1713 + * 1714 + * The drm_atomic_helper_commit() default implementation doesn't set the 1715 + * ACTIVE_ONLY flag to most closely match the behaviour of the legacy helpers. 1716 + * This should not be copied blindly by drivers. 1711 1717 */ 1712 1718 void drm_atomic_helper_commit_planes(struct drm_device *dev, 1713 1719 struct drm_atomic_state *old_state, 1714 - bool active_only) 1720 + uint32_t flags) 1715 1721 { 1716 1722 struct drm_crtc *crtc; 1717 1723 struct drm_crtc_state *old_crtc_state; 1718 1724 struct drm_plane *plane; 1719 1725 struct drm_plane_state *old_plane_state; 1720 1726 int i; 1727 + bool active_only = flags & DRM_PLANE_COMMIT_ACTIVE_ONLY; 1728 + bool no_disable = flags & DRM_PLANE_COMMIT_NO_DISABLE_AFTER_MODESET; 1721 1729 1722 1730 for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) { 1723 1731 const struct drm_crtc_helper_funcs *funcs; ··· 1770 1760 /* 1771 1761 * Special-case disabling the plane if drivers support it. 1772 1762 */ 1773 - if (disabling && funcs->atomic_disable) 1763 + if (disabling && funcs->atomic_disable) { 1764 + struct drm_crtc_state *crtc_state; 1765 + 1766 + crtc_state = old_plane_state->crtc->state; 1767 + 1768 + if (drm_atomic_crtc_needs_modeset(crtc_state) && 1769 + no_disable) 1770 + continue; 1771 + 1774 1772 funcs->atomic_disable(plane, old_plane_state); 1775 - else if (plane->state->crtc || disabling) 1773 + } else if (plane->state->crtc || disabling) { 1776 1774 funcs->atomic_update(plane, old_plane_state); 1775 + } 1777 1776 } 1778 1777 1779 1778 for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
+1 -1
drivers/gpu/drm/exynos/exynos_drm_drv.c
··· 105 105 atomic_inc(&exynos_crtc->pending_update); 106 106 } 107 107 108 - drm_atomic_helper_commit_planes(dev, state, false); 108 + drm_atomic_helper_commit_planes(dev, state, 0); 109 109 110 110 exynos_atomic_wait_for_commit(state); 111 111
+2 -1
drivers/gpu/drm/imx/imx-drm-core.c
··· 193 193 194 194 drm_atomic_helper_commit_modeset_disables(dev, state); 195 195 196 - drm_atomic_helper_commit_planes(dev, state, true); 196 + drm_atomic_helper_commit_planes(dev, state, 197 + DRM_PLANE_COMMIT_ACTIVE_ONLY); 197 198 198 199 drm_atomic_helper_commit_modeset_enables(dev, state); 199 200
+4 -2
drivers/gpu/drm/mediatek/mtk_drm_drv.c
··· 70 70 * 71 71 * drm_atomic_helper_commit_modeset_disables(dev, state); 72 72 * drm_atomic_helper_commit_modeset_enables(dev, state); 73 - * drm_atomic_helper_commit_planes(dev, state, true); 73 + * drm_atomic_helper_commit_planes(dev, state, 74 + * DRM_PLANE_COMMIT_ACTIVE_ONLY); 74 75 * 75 76 * See the kerneldoc entries for these three functions for more details. 76 77 */ 77 78 drm_atomic_helper_commit_modeset_disables(drm, state); 78 79 drm_atomic_helper_commit_modeset_enables(drm, state); 79 - drm_atomic_helper_commit_planes(drm, state, true); 80 + drm_atomic_helper_commit_planes(drm, state, 81 + DRM_PLANE_COMMIT_ACTIVE_ONLY); 80 82 81 83 drm_atomic_helper_wait_for_vblanks(drm, state); 82 84
+1 -1
drivers/gpu/drm/msm/msm_atomic.c
··· 118 118 119 119 drm_atomic_helper_commit_modeset_disables(dev, state); 120 120 121 - drm_atomic_helper_commit_planes(dev, state, false); 121 + drm_atomic_helper_commit_planes(dev, state, 0); 122 122 123 123 drm_atomic_helper_commit_modeset_enables(dev, state); 124 124
+1 -1
drivers/gpu/drm/omapdrm/omap_drv.c
··· 96 96 dispc_runtime_get(); 97 97 98 98 drm_atomic_helper_commit_modeset_disables(dev, old_state); 99 - drm_atomic_helper_commit_planes(dev, old_state, false); 99 + drm_atomic_helper_commit_planes(dev, old_state, 0); 100 100 drm_atomic_helper_commit_modeset_enables(dev, old_state); 101 101 102 102 omap_atomic_wait_for_completion(dev, old_state);
+2 -1
drivers/gpu/drm/rcar-du/rcar_du_kms.c
··· 257 257 /* Apply the atomic update. */ 258 258 drm_atomic_helper_commit_modeset_disables(dev, old_state); 259 259 drm_atomic_helper_commit_modeset_enables(dev, old_state); 260 - drm_atomic_helper_commit_planes(dev, old_state, true); 260 + drm_atomic_helper_commit_planes(dev, old_state, 261 + DRM_PLANE_COMMIT_ACTIVE_ONLY); 261 262 262 263 drm_atomic_helper_wait_for_vblanks(dev, old_state); 263 264
+2 -1
drivers/gpu/drm/rockchip/rockchip_drm_fb.c
··· 233 233 234 234 drm_atomic_helper_commit_modeset_enables(dev, state); 235 235 236 - drm_atomic_helper_commit_planes(dev, state, true); 236 + drm_atomic_helper_commit_planes(dev, state, 237 + DRM_PLANE_COMMIT_ACTIVE_ONLY); 237 238 238 239 drm_atomic_helper_commit_hw_done(state); 239 240
+1 -1
drivers/gpu/drm/sti/sti_drv.c
··· 178 178 */ 179 179 180 180 drm_atomic_helper_commit_modeset_disables(drm, state); 181 - drm_atomic_helper_commit_planes(drm, state, false); 181 + drm_atomic_helper_commit_planes(drm, state, 0); 182 182 drm_atomic_helper_commit_modeset_enables(drm, state); 183 183 184 184 drm_atomic_helper_wait_for_vblanks(drm, state);
+2 -1
drivers/gpu/drm/tegra/drm.c
··· 57 57 58 58 drm_atomic_helper_commit_modeset_disables(drm, state); 59 59 drm_atomic_helper_commit_modeset_enables(drm, state); 60 - drm_atomic_helper_commit_planes(drm, state, true); 60 + drm_atomic_helper_commit_planes(drm, state, 61 + DRM_PLANE_COMMIT_ACTIVE_ONLY); 61 62 62 63 drm_atomic_helper_wait_for_vblanks(drm, state); 63 64
+1 -1
drivers/gpu/drm/tilcdc/tilcdc_drv.c
··· 118 118 119 119 drm_atomic_helper_commit_modeset_disables(dev, state); 120 120 121 - drm_atomic_helper_commit_planes(dev, state, false); 121 + drm_atomic_helper_commit_planes(dev, state, 0); 122 122 123 123 drm_atomic_helper_commit_modeset_enables(dev, state); 124 124
+1 -1
drivers/gpu/drm/vc4/vc4_kms.c
··· 44 44 45 45 drm_atomic_helper_commit_modeset_disables(dev, state); 46 46 47 - drm_atomic_helper_commit_planes(dev, state, false); 47 + drm_atomic_helper_commit_planes(dev, state, 0); 48 48 49 49 drm_atomic_helper_commit_modeset_enables(dev, state); 50 50
+2 -1
drivers/gpu/drm/virtio/virtgpu_display.c
··· 338 338 339 339 drm_atomic_helper_commit_modeset_disables(dev, state); 340 340 drm_atomic_helper_commit_modeset_enables(dev, state); 341 - drm_atomic_helper_commit_planes(dev, state, true); 341 + drm_atomic_helper_commit_planes(dev, state, 342 + DRM_PLANE_COMMIT_ACTIVE_ONLY); 342 343 343 344 drm_atomic_helper_commit_hw_done(state); 344 345
+5 -1
include/drm/drm_atomic_helper.h
··· 65 65 66 66 int drm_atomic_helper_prepare_planes(struct drm_device *dev, 67 67 struct drm_atomic_state *state); 68 + 69 + #define DRM_PLANE_COMMIT_ACTIVE_ONLY BIT(0) 70 + #define DRM_PLANE_COMMIT_NO_DISABLE_AFTER_MODESET BIT(1) 71 + 68 72 void drm_atomic_helper_commit_planes(struct drm_device *dev, 69 73 struct drm_atomic_state *state, 70 - bool active_only); 74 + uint32_t flags); 71 75 void drm_atomic_helper_cleanup_planes(struct drm_device *dev, 72 76 struct drm_atomic_state *old_state); 73 77 void drm_atomic_helper_commit_planes_on_crtc(struct drm_crtc_state *old_crtc_state);