1 From d2943462cef18cb78680215dec058d5254e63dc3 Mon Sep 17 00:00:00 2001
2 From: Yangbo Lu <yangbo.lu@nxp.com>
3 Date: Mon, 2 Mar 2020 13:45:41 +0800
4 Subject: [PATCH] Revert "drm/imx: Extract IPUv3 specific KMS functions to
7 This reverts commit aad8cd9d3f10c57bbf405e25ed1be491d99b6294.
9 drivers/gpu/drm/imx/imx-drm-core.c | 81 ++++++++++++++++++++++++++++++++++++++
10 drivers/gpu/drm/imx/imx-drm.h | 5 ++-
11 2 files changed, 84 insertions(+), 2 deletions(-)
13 --- a/drivers/gpu/drm/imx/imx-drm-core.c
14 +++ b/drivers/gpu/drm/imx/imx-drm-core.c
16 #include <video/dpu.h>
19 +#include "ipuv3-plane.h"
23 static int legacyfb_depth = 16;
24 module_param(legacyfb_depth, int, 0444);
25 @@ -47,6 +50,81 @@ void imx_drm_encoder_destroy(struct drm_
27 EXPORT_SYMBOL_GPL(imx_drm_encoder_destroy);
29 +static int imx_drm_atomic_check(struct drm_device *dev,
30 + struct drm_atomic_state *state)
34 + ret = drm_atomic_helper_check(dev, state);
39 + * Check modeset again in case crtc_state->mode_changed is
40 + * updated in plane's ->atomic_check callback.
42 + ret = drm_atomic_helper_check_modeset(dev, state);
46 + /* Assign PRG/PRE channels and check if all constrains are satisfied. */
47 + ret = ipu_planes_assign_pre(dev, state);
54 +static const struct drm_mode_config_funcs imx_drm_mode_config_funcs = {
55 + .fb_create = drm_gem_fb_create,
56 + .atomic_check = imx_drm_atomic_check,
57 + .atomic_commit = drm_atomic_helper_commit,
60 +static void imx_drm_atomic_commit_tail(struct drm_atomic_state *state)
62 + struct drm_device *dev = state->dev;
63 + struct drm_plane *plane;
64 + struct drm_plane_state *old_plane_state, *new_plane_state;
65 + bool plane_disabling = false;
68 + drm_atomic_helper_commit_modeset_disables(dev, state);
70 + drm_atomic_helper_commit_planes(dev, state,
71 + DRM_PLANE_COMMIT_ACTIVE_ONLY |
72 + DRM_PLANE_COMMIT_NO_DISABLE_AFTER_MODESET);
74 + drm_atomic_helper_commit_modeset_enables(dev, state);
76 + for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
77 + if (drm_atomic_plane_disabling(old_plane_state, new_plane_state))
78 + plane_disabling = true;
82 + * The flip done wait is only strictly required by imx-drm if a deferred
83 + * plane disable is in-flight. As the core requires blocking commits
84 + * to wait for the flip it is done here unconditionally. This keeps the
85 + * workitem around a bit longer than required for the majority of
86 + * non-blocking commits, but we accept that for the sake of simplicity.
88 + drm_atomic_helper_wait_for_flip_done(dev, state);
90 + if (plane_disabling) {
91 + for_each_old_plane_in_state(state, plane, old_plane_state, i)
92 + ipu_plane_disable_deferred(plane);
96 + drm_atomic_helper_commit_hw_done(state);
99 +static const struct drm_mode_config_helper_funcs imx_drm_mode_config_helpers = {
100 + .atomic_commit_tail = imx_drm_atomic_commit_tail,
104 int imx_drm_encoder_parse_of(struct drm_device *drm,
105 struct drm_encoder *encoder, struct device_node *np)
107 @@ -163,6 +241,9 @@ static int imx_drm_bind(struct device *d
108 drm->mode_config.min_height = 1;
109 drm->mode_config.max_width = 4096;
110 drm->mode_config.max_height = 4096;
111 + drm->mode_config.funcs = &imx_drm_mode_config_funcs;
112 + drm->mode_config.helper_private = &imx_drm_mode_config_helpers;
113 + drm->mode_config.allow_fb_modifiers = true;
114 drm->mode_config.normalize_zpos = true;
116 drm_mode_config_init(drm);
117 --- a/drivers/gpu/drm/imx/imx-drm.h
118 +++ b/drivers/gpu/drm/imx/imx-drm.h
127 struct drm_connector;
128 @@ -40,4 +38,7 @@ int imx_drm_encoder_parse_of(struct drm_
129 void imx_drm_connector_destroy(struct drm_connector *connector);
130 void imx_drm_encoder_destroy(struct drm_encoder *encoder);
132 +int ipu_planes_assign_pre(struct drm_device *dev,
133 + struct drm_atomic_state *state);
135 #endif /* _IMX_DRM_H_ */