23411bc117c52cfb6fa90e0635c0d5b1a6e207df
[openwrt/staging/linusw.git] /
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
5 ipuv3-kms.c (part 1)"
6
7 This reverts commit aad8cd9d3f10c57bbf405e25ed1be491d99b6294.
8 ---
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(-)
12
13 --- a/drivers/gpu/drm/imx/imx-drm-core.c
14 +++ b/drivers/gpu/drm/imx/imx-drm-core.c
15 @@ -28,6 +28,9 @@
16 #include <video/dpu.h>
17
18 #include "imx-drm.h"
19 +#include "ipuv3-plane.h"
20 +
21 +#define MAX_CRTC 4
22
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_
26 }
27 EXPORT_SYMBOL_GPL(imx_drm_encoder_destroy);
28
29 +static int imx_drm_atomic_check(struct drm_device *dev,
30 + struct drm_atomic_state *state)
31 +{
32 + int ret;
33 +
34 + ret = drm_atomic_helper_check(dev, state);
35 + if (ret)
36 + return ret;
37 +
38 + /*
39 + * Check modeset again in case crtc_state->mode_changed is
40 + * updated in plane's ->atomic_check callback.
41 + */
42 + ret = drm_atomic_helper_check_modeset(dev, state);
43 + if (ret)
44 + return ret;
45 +
46 + /* Assign PRG/PRE channels and check if all constrains are satisfied. */
47 + ret = ipu_planes_assign_pre(dev, state);
48 + if (ret)
49 + return ret;
50 +
51 + return ret;
52 +}
53 +
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,
58 +};
59 +
60 +static void imx_drm_atomic_commit_tail(struct drm_atomic_state *state)
61 +{
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;
66 + int i;
67 +
68 + drm_atomic_helper_commit_modeset_disables(dev, state);
69 +
70 + drm_atomic_helper_commit_planes(dev, state,
71 + DRM_PLANE_COMMIT_ACTIVE_ONLY |
72 + DRM_PLANE_COMMIT_NO_DISABLE_AFTER_MODESET);
73 +
74 + drm_atomic_helper_commit_modeset_enables(dev, state);
75 +
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;
79 + }
80 +
81 + /*
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.
87 + */
88 + drm_atomic_helper_wait_for_flip_done(dev, state);
89 +
90 + if (plane_disabling) {
91 + for_each_old_plane_in_state(state, plane, old_plane_state, i)
92 + ipu_plane_disable_deferred(plane);
93 +
94 + }
95 +
96 + drm_atomic_helper_commit_hw_done(state);
97 +}
98 +
99 +static const struct drm_mode_config_helper_funcs imx_drm_mode_config_helpers = {
100 + .atomic_commit_tail = imx_drm_atomic_commit_tail,
101 +};
102 +
103 +
104 int imx_drm_encoder_parse_of(struct drm_device *drm,
105 struct drm_encoder *encoder, struct device_node *np)
106 {
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;
115
116 drm_mode_config_init(drm);
117 --- a/drivers/gpu/drm/imx/imx-drm.h
118 +++ b/drivers/gpu/drm/imx/imx-drm.h
119 @@ -2,8 +2,6 @@
120 #ifndef _IMX_DRM_H_
121 #define _IMX_DRM_H_
122
123 -#define MAX_CRTC 4
124 -
125 struct device_node;
126 struct drm_crtc;
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);
131
132 +int ipu_planes_assign_pre(struct drm_device *dev,
133 + struct drm_atomic_state *state);
134 +
135 #endif /* _IMX_DRM_H_ */