This source file includes following definitions.
- drm_helper_move_panel_connectors_to_head
- drm_helper_mode_fill_fb_struct
- create_primary_plane
- drm_crtc_init
- drm_mode_config_helper_suspend
- drm_mode_config_helper_resume
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 #include <drm/drm_atomic_helper.h>
24 #include <drm/drm_fb_helper.h>
25 #include <drm/drm_fourcc.h>
26 #include <drm/drm_modeset_helper.h>
27 #include <drm/drm_plane_helper.h>
28 #include <drm/drm_print.h>
29 #include <drm/drm_probe_helper.h>
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 void drm_helper_move_panel_connectors_to_head(struct drm_device *dev)
50 {
51 struct drm_connector *connector, *tmp;
52 struct list_head panel_list;
53
54 INIT_LIST_HEAD(&panel_list);
55
56 spin_lock_irq(&dev->mode_config.connector_list_lock);
57 list_for_each_entry_safe(connector, tmp,
58 &dev->mode_config.connector_list, head) {
59 if (connector->connector_type == DRM_MODE_CONNECTOR_LVDS ||
60 connector->connector_type == DRM_MODE_CONNECTOR_eDP ||
61 connector->connector_type == DRM_MODE_CONNECTOR_DSI)
62 list_move_tail(&connector->head, &panel_list);
63 }
64
65 list_splice(&panel_list, &dev->mode_config.connector_list);
66 spin_unlock_irq(&dev->mode_config.connector_list_lock);
67 }
68 EXPORT_SYMBOL(drm_helper_move_panel_connectors_to_head);
69
70
71
72
73
74
75
76
77
78
79 void drm_helper_mode_fill_fb_struct(struct drm_device *dev,
80 struct drm_framebuffer *fb,
81 const struct drm_mode_fb_cmd2 *mode_cmd)
82 {
83 int i;
84
85 fb->dev = dev;
86 fb->format = drm_get_format_info(dev, mode_cmd);
87 fb->width = mode_cmd->width;
88 fb->height = mode_cmd->height;
89 for (i = 0; i < 4; i++) {
90 fb->pitches[i] = mode_cmd->pitches[i];
91 fb->offsets[i] = mode_cmd->offsets[i];
92 }
93 fb->modifier = mode_cmd->modifier[0];
94 fb->flags = mode_cmd->flags;
95 }
96 EXPORT_SYMBOL(drm_helper_mode_fill_fb_struct);
97
98
99
100
101
102
103
104
105 static const uint32_t safe_modeset_formats[] = {
106 DRM_FORMAT_XRGB8888,
107 DRM_FORMAT_ARGB8888,
108 };
109
110 static struct drm_plane *create_primary_plane(struct drm_device *dev)
111 {
112 struct drm_plane *primary;
113 int ret;
114
115 primary = kzalloc(sizeof(*primary), GFP_KERNEL);
116 if (primary == NULL) {
117 DRM_DEBUG_KMS("Failed to allocate primary plane\n");
118 return NULL;
119 }
120
121
122
123
124
125 primary->format_default = true;
126
127
128 ret = drm_universal_plane_init(dev, primary, 0,
129 &drm_primary_helper_funcs,
130 safe_modeset_formats,
131 ARRAY_SIZE(safe_modeset_formats),
132 NULL,
133 DRM_PLANE_TYPE_PRIMARY, NULL);
134 if (ret) {
135 kfree(primary);
136 primary = NULL;
137 }
138
139 return primary;
140 }
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169 int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
170 const struct drm_crtc_funcs *funcs)
171 {
172 struct drm_plane *primary;
173
174 primary = create_primary_plane(dev);
175 return drm_crtc_init_with_planes(dev, crtc, primary, NULL, funcs,
176 NULL);
177 }
178 EXPORT_SYMBOL(drm_crtc_init);
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195 int drm_mode_config_helper_suspend(struct drm_device *dev)
196 {
197 struct drm_atomic_state *state;
198
199 if (!dev)
200 return 0;
201
202 drm_kms_helper_poll_disable(dev);
203 drm_fb_helper_set_suspend_unlocked(dev->fb_helper, 1);
204 state = drm_atomic_helper_suspend(dev);
205 if (IS_ERR(state)) {
206 drm_fb_helper_set_suspend_unlocked(dev->fb_helper, 0);
207 drm_kms_helper_poll_enable(dev);
208 return PTR_ERR(state);
209 }
210
211 dev->mode_config.suspend_state = state;
212
213 return 0;
214 }
215 EXPORT_SYMBOL(drm_mode_config_helper_suspend);
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231 int drm_mode_config_helper_resume(struct drm_device *dev)
232 {
233 int ret;
234
235 if (!dev)
236 return 0;
237
238 if (WARN_ON(!dev->mode_config.suspend_state))
239 return -EINVAL;
240
241 ret = drm_atomic_helper_resume(dev, dev->mode_config.suspend_state);
242 if (ret)
243 DRM_ERROR("Failed to resume (%d)\n", ret);
244 dev->mode_config.suspend_state = NULL;
245
246 drm_fb_helper_set_suspend_unlocked(dev->fb_helper, 0);
247 drm_kms_helper_poll_enable(dev);
248
249 return ret;
250 }
251 EXPORT_SYMBOL(drm_mode_config_helper_resume);