]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - include/drm/drm_modeset_helper_vtables.h
drm/atomic: Drop helper include from drm_atomic.c
[mirror_ubuntu-jammy-kernel.git] / include / drm / drm_modeset_helper_vtables.h
CommitLineData
092d01da
DV
1/*
2 * Copyright © 2006 Keith Packard
3 * Copyright © 2007-2008 Dave Airlie
4 * Copyright © 2007-2008 Intel Corporation
5 * Jesse Barnes <jesse.barnes@intel.com>
6 * Copyright © 2011-2013 Intel Corporation
7 * Copyright © 2015 Intel Corporation
8 * Daniel Vetter <daniel.vetter@ffwll.ch>
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
24 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 * OTHER DEALINGS IN THE SOFTWARE.
27 */
28
29#ifndef __DRM_MODESET_HELPER_VTABLES_H__
30#define __DRM_MODESET_HELPER_VTABLES_H__
31
32#include <drm/drm_crtc.h>
9338203c 33#include <drm/drm_encoder.h>
092d01da
DV
34
35/**
36 * DOC: overview
37 *
38 * The DRM mode setting helper functions are common code for drivers to use if
39 * they wish. Drivers are not forced to use this code in their
40 * implementations but it would be useful if the code they do use at least
41 * provides a consistent interface and operation to userspace. Therefore it is
42 * highly recommended to use the provided helpers as much as possible.
43 *
44 * Because there is only one pointer per modeset object to hold a vfunc table
45 * for helper libraries they are by necessity shared among the different
46 * helpers.
47 *
48 * To make this clear all the helper vtables are pulled together in this location here.
49 */
50
51enum mode_set_atomic;
52
53/**
54 * struct drm_crtc_helper_funcs - helper operations for CRTCs
092d01da 55 *
36b66080
DV
56 * These hooks are used by the legacy CRTC helpers, the transitional plane
57 * helpers and the new atomic modesetting helpers.
092d01da
DV
58 */
59struct drm_crtc_helper_funcs {
36b66080
DV
60 /**
61 * @dpms:
62 *
63 * Callback to control power levels on the CRTC. If the mode passed in
64 * is unsupported, the provider must use the next lowest power level.
65 * This is used by the legacy CRTC helpers to implement DPMS
66 * functionality in drm_helper_connector_dpms().
67 *
68 * This callback is also used to disable a CRTC by calling it with
69 * DRM_MODE_DPMS_OFF if the @disable hook isn't used.
70 *
71 * This callback is used by the legacy CRTC helpers. Atomic helpers
72 * also support using this hook for enabling and disabling a CRTC to
73 * facilitate transitions to atomic, but it is deprecated. Instead
0b20a0f8 74 * @atomic_enable and @atomic_disable should be used.
092d01da
DV
75 */
76 void (*dpms)(struct drm_crtc *crtc, int mode);
36b66080
DV
77
78 /**
79 * @prepare:
80 *
81 * This callback should prepare the CRTC for a subsequent modeset, which
82 * in practice means the driver should disable the CRTC if it is
83 * running. Most drivers ended up implementing this by calling their
84 * @dpms hook with DRM_MODE_DPMS_OFF.
85 *
86 * This callback is used by the legacy CRTC helpers. Atomic helpers
87 * also support using this hook for disabling a CRTC to facilitate
0b20a0f8
LP
88 * transitions to atomic, but it is deprecated. Instead @atomic_disable
89 * should be used.
36b66080 90 */
092d01da 91 void (*prepare)(struct drm_crtc *crtc);
36b66080
DV
92
93 /**
94 * @commit:
95 *
96 * This callback should commit the new mode on the CRTC after a modeset,
97 * which in practice means the driver should enable the CRTC. Most
98 * drivers ended up implementing this by calling their @dpms hook with
99 * DRM_MODE_DPMS_ON.
100 *
101 * This callback is used by the legacy CRTC helpers. Atomic helpers
102 * also support using this hook for enabling a CRTC to facilitate
0b20a0f8
LP
103 * transitions to atomic, but it is deprecated. Instead @atomic_enable
104 * should be used.
36b66080 105 */
092d01da
DV
106 void (*commit)(struct drm_crtc *crtc);
107
3eb220a5
JA
108 /**
109 * @mode_valid:
110 *
111 * This callback is used to check if a specific mode is valid in this
112 * crtc. This should be implemented if the crtc has some sort of
113 * restriction in the modes it can display. For example, a given crtc
114 * may be responsible to set a clock value. If the clock can not
115 * produce all the values for the available modes then this callback
116 * can be used to restrict the number of modes to only the ones that
117 * can be displayed.
118 *
119 * This hook is used by the probe helpers to filter the mode list in
120 * drm_helper_probe_single_connector_modes(), and it is used by the
121 * atomic helpers to validate modes supplied by userspace in
122 * drm_atomic_helper_check_modeset().
123 *
124 * This function is optional.
125 *
126 * NOTE:
127 *
128 * Since this function is both called from the check phase of an atomic
129 * commit, and the mode validation in the probe paths it is not allowed
130 * to look at anything else but the passed-in mode, and validate it
131 * against configuration-invariant hardward constraints. Any further
132 * limits which depend upon the configuration can only be checked in
133 * @mode_fixup or @atomic_check.
134 *
135 * RETURNS:
136 *
137 * drm_mode_status Enum
138 */
139 enum drm_mode_status (*mode_valid)(struct drm_crtc *crtc,
140 const struct drm_display_mode *mode);
141
36b66080
DV
142 /**
143 * @mode_fixup:
144 *
145 * This callback is used to validate a mode. The parameter mode is the
146 * display mode that userspace requested, adjusted_mode is the mode the
147 * encoders need to be fed with. Note that this is the inverse semantics
6806cdf9
DV
148 * of the meaning for the &drm_encoder and &drm_bridge_funcs.mode_fixup
149 * vfunc. If the CRTC cannot support the requested conversion from mode
9de5d4a6
DV
150 * to adjusted_mode it should reject the modeset. See also
151 * &drm_crtc_state.adjusted_mode for more details.
36b66080
DV
152 *
153 * This function is used by both legacy CRTC helpers and atomic helpers.
154 * With atomic helpers it is optional.
155 *
156 * NOTE:
157 *
158 * This function is called in the check phase of atomic modesets, which
159 * can be aborted for any reason (including on userspace's request to
160 * just check whether a configuration would be possible). Atomic drivers
161 * MUST NOT touch any persistent state (hardware or software) or data
162 * structures except the passed in adjusted_mode parameter.
163 *
164 * This is in contrast to the legacy CRTC helpers where this was
165 * allowed.
166 *
167 * Atomic drivers which need to inspect and adjust more state should
9f800214
DV
168 * instead use the @atomic_check callback, but note that they're not
169 * perfectly equivalent: @mode_valid is called from
170 * drm_atomic_helper_check_modeset(), but @atomic_check is called from
171 * drm_atomic_helper_check_planes(), because originally it was meant for
172 * plane update checks only.
36b66080 173 *
3eb220a5
JA
174 * Also beware that userspace can request its own custom modes, neither
175 * core nor helpers filter modes to the list of probe modes reported by
176 * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
177 * that modes are filtered consistently put any CRTC constraints and
178 * limits checks into @mode_valid.
df7d678b 179 *
36b66080
DV
180 * RETURNS:
181 *
182 * True if an acceptable configuration is possible, false if the modeset
183 * operation should be rejected.
184 */
092d01da
DV
185 bool (*mode_fixup)(struct drm_crtc *crtc,
186 const struct drm_display_mode *mode,
187 struct drm_display_mode *adjusted_mode);
36b66080
DV
188
189 /**
190 * @mode_set:
191 *
192 * This callback is used by the legacy CRTC helpers to set a new mode,
193 * position and framebuffer. Since it ties the primary plane to every
194 * mode change it is incompatible with universal plane support. And
195 * since it can't update other planes it's incompatible with atomic
196 * modeset support.
197 *
198 * This callback is only used by CRTC helpers and deprecated.
199 *
200 * RETURNS:
201 *
202 * 0 on success or a negative error code on failure.
203 */
092d01da
DV
204 int (*mode_set)(struct drm_crtc *crtc, struct drm_display_mode *mode,
205 struct drm_display_mode *adjusted_mode, int x, int y,
206 struct drm_framebuffer *old_fb);
36b66080
DV
207
208 /**
209 * @mode_set_nofb:
210 *
211 * This callback is used to update the display mode of a CRTC without
212 * changing anything of the primary plane configuration. This fits the
213 * requirement of atomic and hence is used by the atomic helpers. It is
214 * also used by the transitional plane helpers to implement a
215 * @mode_set hook in drm_helper_crtc_mode_set().
216 *
217 * Note that the display pipe is completely off when this function is
218 * called. Atomic drivers which need hardware to be running before they
219 * program the new display mode (e.g. because they implement runtime PM)
220 * should not use this hook. This is because the helper library calls
221 * this hook only once per mode change and not every time the display
222 * pipeline is suspended using either DPMS or the new "ACTIVE" property.
223 * Which means register values set in this callback might get reset when
224 * the CRTC is suspended, but not restored. Such drivers should instead
0b20a0f8 225 * move all their CRTC setup into the @atomic_enable callback.
36b66080
DV
226 *
227 * This callback is optional.
228 */
092d01da
DV
229 void (*mode_set_nofb)(struct drm_crtc *crtc);
230
36b66080
DV
231 /**
232 * @mode_set_base:
233 *
234 * This callback is used by the legacy CRTC helpers to set a new
235 * framebuffer and scanout position. It is optional and used as an
236 * optimized fast-path instead of a full mode set operation with all the
df7d678b
DV
237 * resulting flickering. If it is not present
238 * drm_crtc_helper_set_config() will fall back to a full modeset, using
6806cdf9 239 * the @mode_set callback. Since it can't update other planes it's
36b66080
DV
240 * incompatible with atomic modeset support.
241 *
242 * This callback is only used by the CRTC helpers and deprecated.
243 *
244 * RETURNS:
245 *
246 * 0 on success or a negative error code on failure.
247 */
092d01da
DV
248 int (*mode_set_base)(struct drm_crtc *crtc, int x, int y,
249 struct drm_framebuffer *old_fb);
36b66080
DV
250
251 /**
252 * @mode_set_base_atomic:
253 *
254 * This callback is used by the fbdev helpers to set a new framebuffer
255 * and scanout without sleeping, i.e. from an atomic calling context. It
256 * is only used to implement kgdb support.
257 *
258 * This callback is optional and only needed for kgdb support in the fbdev
259 * helpers.
260 *
261 * RETURNS:
262 *
263 * 0 on success or a negative error code on failure.
264 */
092d01da
DV
265 int (*mode_set_base_atomic)(struct drm_crtc *crtc,
266 struct drm_framebuffer *fb, int x, int y,
267 enum mode_set_atomic);
268
36b66080
DV
269 /**
270 * @load_lut:
271 *
6806cdf9 272 * Load a LUT prepared with the &drm_fb_helper_funcs.gamma_set vfunc.
36b66080
DV
273 *
274 * This callback is optional and is only used by the fbdev emulation
275 * helpers.
276 *
277 * FIXME:
278 *
279 * This callback is functionally redundant with the core gamma table
280 * support and simply exists because the fbdev hasn't yet been
281 * refactored to use the core gamma table interfaces.
282 */
092d01da
DV
283 void (*load_lut)(struct drm_crtc *crtc);
284
36b66080
DV
285 /**
286 * @disable:
287 *
288 * This callback should be used to disable the CRTC. With the atomic
289 * drivers it is called after all encoders connected to this CRTC have
6806cdf9
DV
290 * been shut off already using their own
291 * &drm_encoder_helper_funcs.disable hook. If that sequence is too
292 * simple drivers can just add their own hooks and call it from this
293 * CRTC callback here by looping over all encoders connected to it using
294 * for_each_encoder_on_crtc().
36b66080
DV
295 *
296 * This hook is used both by legacy CRTC helpers and atomic helpers.
297 * Atomic drivers don't need to implement it if there's no need to
298 * disable anything at the CRTC level. To ensure that runtime PM
299 * handling (using either DPMS or the new "ACTIVE" property) works
0b20a0f8 300 * @disable must be the inverse of @atomic_enable for atomic drivers.
c9ac8b4c
LY
301 * Atomic drivers should consider to use @atomic_disable instead of
302 * this one.
36b66080
DV
303 *
304 * NOTE:
305 *
306 * With legacy CRTC helpers there's a big semantic difference between
307 * @disable and other hooks (like @prepare or @dpms) used to shut down a
308 * CRTC: @disable is only called when also logically disabling the
309 * display pipeline and needs to release any resources acquired in
310 * @mode_set (like shared PLLs, or again release pinned framebuffers).
311 *
312 * Therefore @disable must be the inverse of @mode_set plus @commit for
313 * drivers still using legacy CRTC helpers, which is different from the
314 * rules under atomic.
315 */
092d01da 316 void (*disable)(struct drm_crtc *crtc);
36b66080 317
11a0ba97
DV
318 /**
319 * @atomic_check:
320 *
321 * Drivers should check plane-update related CRTC constraints in this
322 * hook. They can also check mode related limitations but need to be
323 * aware of the calling order, since this hook is used by
324 * drm_atomic_helper_check_planes() whereas the preparations needed to
325 * check output routing and the display mode is done in
326 * drm_atomic_helper_check_modeset(). Therefore drivers that want to
327 * check output routing and display mode constraints in this callback
328 * must ensure that drm_atomic_helper_check_modeset() has been called
329 * beforehand. This is calling order used by the default helper
330 * implementation in drm_atomic_helper_check().
331 *
6806cdf9
DV
332 * When using drm_atomic_helper_check_planes() this hook is called
333 * after the &drm_plane_helper_funcs.atomc_check hook for planes, which
334 * allows drivers to assign shared resources requested by planes in this
335 * callback here. For more complicated dependencies the driver can call
336 * the provided check helpers multiple times until the computed state
337 * has a final configuration and everything has been checked.
11a0ba97
DV
338 *
339 * This function is also allowed to inspect any other object's state and
340 * can add more state objects to the atomic commit if needed. Care must
6806cdf9 341 * be taken though to ensure that state check and compute functions for
11a0ba97
DV
342 * these added states are all called, and derived state in other objects
343 * all updated. Again the recommendation is to just call check helpers
344 * until a maximal configuration is reached.
345 *
346 * This callback is used by the atomic modeset helpers and by the
347 * transitional plane helpers, but it is optional.
348 *
349 * NOTE:
350 *
351 * This function is called in the check phase of an atomic update. The
352 * driver is not allowed to change anything outside of the free-standing
353 * state objects passed-in or assembled in the overall &drm_atomic_state
354 * update tracking structure.
355 *
3eb220a5
JA
356 * Also beware that userspace can request its own custom modes, neither
357 * core nor helpers filter modes to the list of probe modes reported by
358 * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
359 * that modes are filtered consistently put any CRTC constraints and
360 * limits checks into @mode_valid.
361 *
11a0ba97
DV
362 * RETURNS:
363 *
364 * 0 on success, -EINVAL if the state or the transition can't be
365 * supported, -ENOMEM on memory allocation failure and -EDEADLK if an
366 * attempt to obtain another state object ran into a &drm_modeset_lock
367 * deadlock.
368 */
092d01da
DV
369 int (*atomic_check)(struct drm_crtc *crtc,
370 struct drm_crtc_state *state);
11a0ba97
DV
371
372 /**
373 * @atomic_begin:
374 *
375 * Drivers should prepare for an atomic update of multiple planes on
376 * a CRTC in this hook. Depending upon hardware this might be vblank
377 * evasion, blocking updates by setting bits or doing preparatory work
378 * for e.g. manual update display.
379 *
380 * This hook is called before any plane commit functions are called.
381 *
382 * Note that the power state of the display pipe when this function is
383 * called depends upon the exact helpers and calling sequence the driver
0dc9967d
SA
384 * has picked. See drm_atomic_helper_commit_planes() for a discussion of
385 * the tradeoffs and variants of plane commit helpers.
11a0ba97
DV
386 *
387 * This callback is used by the atomic modeset helpers and by the
388 * transitional plane helpers, but it is optional.
389 */
092d01da
DV
390 void (*atomic_begin)(struct drm_crtc *crtc,
391 struct drm_crtc_state *old_crtc_state);
11a0ba97
DV
392 /**
393 * @atomic_flush:
394 *
395 * Drivers should finalize an atomic update of multiple planes on
396 * a CRTC in this hook. Depending upon hardware this might include
397 * checking that vblank evasion was successful, unblocking updates by
398 * setting bits or setting the GO bit to flush out all updates.
399 *
400 * Simple hardware or hardware with special requirements can commit and
401 * flush out all updates for all planes from this hook and forgo all the
402 * other commit hooks for plane updates.
403 *
404 * This hook is called after any plane commit functions are called.
405 *
406 * Note that the power state of the display pipe when this function is
407 * called depends upon the exact helpers and calling sequence the driver
0dc9967d
SA
408 * has picked. See drm_atomic_helper_commit_planes() for a discussion of
409 * the tradeoffs and variants of plane commit helpers.
11a0ba97
DV
410 *
411 * This callback is used by the atomic modeset helpers and by the
412 * transitional plane helpers, but it is optional.
413 */
092d01da
DV
414 void (*atomic_flush)(struct drm_crtc *crtc,
415 struct drm_crtc_state *old_crtc_state);
c9ac8b4c 416
0b20a0f8
LP
417 /**
418 * @atomic_enable:
419 *
420 * This callback should be used to enable the CRTC. With the atomic
421 * drivers it is called before all encoders connected to this CRTC are
422 * enabled through the encoder's own &drm_encoder_helper_funcs.enable
423 * hook. If that sequence is too simple drivers can just add their own
424 * hooks and call it from this CRTC callback here by looping over all
425 * encoders connected to it using for_each_encoder_on_crtc().
426 *
427 * This hook is used only by atomic helpers, for symmetry with
428 * @atomic_disable. Atomic drivers don't need to implement it if there's
429 * no need to enable anything at the CRTC level. To ensure that runtime
430 * PM handling (using either DPMS or the new "ACTIVE" property) works
431 * @atomic_enable must be the inverse of @atomic_disable for atomic
432 * drivers.
433 *
434 * Drivers can use the @old_crtc_state input parameter if the operations
435 * needed to enable the CRTC don't depend solely on the new state but
436 * also on the transition between the old state and the new state.
437 */
438 void (*atomic_enable)(struct drm_crtc *crtc,
439 struct drm_crtc_state *old_crtc_state);
440
c9ac8b4c
LY
441 /**
442 * @atomic_disable:
443 *
444 * This callback should be used to disable the CRTC. With the atomic
445 * drivers it is called after all encoders connected to this CRTC have
6806cdf9
DV
446 * been shut off already using their own
447 * &drm_encoder_helper_funcs.disable hook. If that sequence is too
448 * simple drivers can just add their own hooks and call it from this
449 * CRTC callback here by looping over all encoders connected to it using
450 * for_each_encoder_on_crtc().
c9ac8b4c
LY
451 *
452 * This hook is used only by atomic helpers. Atomic drivers don't
453 * need to implement it if there's no need to disable anything at the
454 * CRTC level.
455 *
456 * Comparing to @disable, this one provides the additional input
457 * parameter @old_crtc_state which could be used to access the old
458 * state. Atomic drivers should consider to use this one instead
459 * of @disable.
460 */
461 void (*atomic_disable)(struct drm_crtc *crtc,
462 struct drm_crtc_state *old_crtc_state);
092d01da
DV
463};
464
465/**
466 * drm_crtc_helper_add - sets the helper vtable for a crtc
467 * @crtc: DRM CRTC
468 * @funcs: helper vtable to set for @crtc
469 */
470static inline void drm_crtc_helper_add(struct drm_crtc *crtc,
471 const struct drm_crtc_helper_funcs *funcs)
472{
473 crtc->helper_private = funcs;
474}
475
476/**
477 * struct drm_encoder_helper_funcs - helper operations for encoders
092d01da 478 *
36b66080
DV
479 * These hooks are used by the legacy CRTC helpers, the transitional plane
480 * helpers and the new atomic modesetting helpers.
092d01da
DV
481 */
482struct drm_encoder_helper_funcs {
36b66080
DV
483 /**
484 * @dpms:
485 *
486 * Callback to control power levels on the encoder. If the mode passed in
487 * is unsupported, the provider must use the next lowest power level.
488 * This is used by the legacy encoder helpers to implement DPMS
489 * functionality in drm_helper_connector_dpms().
490 *
491 * This callback is also used to disable an encoder by calling it with
492 * DRM_MODE_DPMS_OFF if the @disable hook isn't used.
493 *
494 * This callback is used by the legacy CRTC helpers. Atomic helpers
495 * also support using this hook for enabling and disabling an encoder to
496 * facilitate transitions to atomic, but it is deprecated. Instead
497 * @enable and @disable should be used.
498 */
092d01da 499 void (*dpms)(struct drm_encoder *encoder, int mode);
092d01da 500
3eb220a5
JA
501 /**
502 * @mode_valid:
503 *
504 * This callback is used to check if a specific mode is valid in this
505 * encoder. This should be implemented if the encoder has some sort
506 * of restriction in the modes it can display. For example, a given
507 * encoder may be responsible to set a clock value. If the clock can
508 * not produce all the values for the available modes then this callback
509 * can be used to restrict the number of modes to only the ones that
510 * can be displayed.
511 *
512 * This hook is used by the probe helpers to filter the mode list in
513 * drm_helper_probe_single_connector_modes(), and it is used by the
514 * atomic helpers to validate modes supplied by userspace in
515 * drm_atomic_helper_check_modeset().
516 *
517 * This function is optional.
518 *
519 * NOTE:
520 *
521 * Since this function is both called from the check phase of an atomic
522 * commit, and the mode validation in the probe paths it is not allowed
523 * to look at anything else but the passed-in mode, and validate it
524 * against configuration-invariant hardward constraints. Any further
525 * limits which depend upon the configuration can only be checked in
526 * @mode_fixup or @atomic_check.
527 *
528 * RETURNS:
529 *
530 * drm_mode_status Enum
531 */
532 enum drm_mode_status (*mode_valid)(struct drm_encoder *crtc,
533 const struct drm_display_mode *mode);
534
36b66080
DV
535 /**
536 * @mode_fixup:
537 *
538 * This callback is used to validate and adjust a mode. The parameter
539 * mode is the display mode that should be fed to the next element in
540 * the display chain, either the final &drm_connector or a &drm_bridge.
541 * The parameter adjusted_mode is the input mode the encoder requires. It
9de5d4a6
DV
542 * can be modified by this callback and does not need to match mode. See
543 * also &drm_crtc_state.adjusted_mode for more details.
36b66080
DV
544 *
545 * This function is used by both legacy CRTC helpers and atomic helpers.
3c5b2673 546 * This hook is optional.
36b66080
DV
547 *
548 * NOTE:
549 *
550 * This function is called in the check phase of atomic modesets, which
551 * can be aborted for any reason (including on userspace's request to
552 * just check whether a configuration would be possible). Atomic drivers
553 * MUST NOT touch any persistent state (hardware or software) or data
554 * structures except the passed in adjusted_mode parameter.
555 *
556 * This is in contrast to the legacy CRTC helpers where this was
557 * allowed.
558 *
559 * Atomic drivers which need to inspect and adjust more state should
9f800214
DV
560 * instead use the @atomic_check callback. If @atomic_check is used,
561 * this hook isn't called since @atomic_check allows a strict superset
562 * of the functionality of @mode_fixup.
36b66080 563 *
3eb220a5
JA
564 * Also beware that userspace can request its own custom modes, neither
565 * core nor helpers filter modes to the list of probe modes reported by
566 * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
567 * that modes are filtered consistently put any encoder constraints and
568 * limits checks into @mode_valid.
df7d678b 569 *
36b66080
DV
570 * RETURNS:
571 *
572 * True if an acceptable configuration is possible, false if the modeset
573 * operation should be rejected.
574 */
092d01da
DV
575 bool (*mode_fixup)(struct drm_encoder *encoder,
576 const struct drm_display_mode *mode,
577 struct drm_display_mode *adjusted_mode);
36b66080
DV
578
579 /**
580 * @prepare:
581 *
582 * This callback should prepare the encoder for a subsequent modeset,
583 * which in practice means the driver should disable the encoder if it
584 * is running. Most drivers ended up implementing this by calling their
585 * @dpms hook with DRM_MODE_DPMS_OFF.
586 *
587 * This callback is used by the legacy CRTC helpers. Atomic helpers
588 * also support using this hook for disabling an encoder to facilitate
589 * transitions to atomic, but it is deprecated. Instead @disable should
590 * be used.
591 */
092d01da 592 void (*prepare)(struct drm_encoder *encoder);
36b66080
DV
593
594 /**
595 * @commit:
596 *
597 * This callback should commit the new mode on the encoder after a modeset,
598 * which in practice means the driver should enable the encoder. Most
599 * drivers ended up implementing this by calling their @dpms hook with
600 * DRM_MODE_DPMS_ON.
601 *
602 * This callback is used by the legacy CRTC helpers. Atomic helpers
603 * also support using this hook for enabling an encoder to facilitate
604 * transitions to atomic, but it is deprecated. Instead @enable should
605 * be used.
606 */
092d01da 607 void (*commit)(struct drm_encoder *encoder);
36b66080
DV
608
609 /**
610 * @mode_set:
611 *
612 * This callback is used to update the display mode of an encoder.
613 *
614 * Note that the display pipe is completely off when this function is
615 * called. Drivers which need hardware to be running before they program
616 * the new display mode (because they implement runtime PM) should not
617 * use this hook, because the helper library calls it only once and not
618 * every time the display pipeline is suspend using either DPMS or the
619 * new "ACTIVE" property. Such drivers should instead move all their
6806cdf9 620 * encoder setup into the @enable callback.
36b66080
DV
621 *
622 * This callback is used both by the legacy CRTC helpers and the atomic
623 * modeset helpers. It is optional in the atomic helpers.
fe4a11c9
PZ
624 *
625 * NOTE:
626 *
627 * If the driver uses the atomic modeset helpers and needs to inspect
628 * the connector state or connector display info during mode setting,
629 * @atomic_mode_set can be used instead.
36b66080 630 */
092d01da
DV
631 void (*mode_set)(struct drm_encoder *encoder,
632 struct drm_display_mode *mode,
633 struct drm_display_mode *adjusted_mode);
36b66080 634
fe4a11c9
PZ
635 /**
636 * @atomic_mode_set:
637 *
638 * This callback is used to update the display mode of an encoder.
639 *
640 * Note that the display pipe is completely off when this function is
641 * called. Drivers which need hardware to be running before they program
642 * the new display mode (because they implement runtime PM) should not
643 * use this hook, because the helper library calls it only once and not
644 * every time the display pipeline is suspended using either DPMS or the
645 * new "ACTIVE" property. Such drivers should instead move all their
6806cdf9 646 * encoder setup into the @enable callback.
fe4a11c9
PZ
647 *
648 * This callback is used by the atomic modeset helpers in place of the
649 * @mode_set callback, if set by the driver. It is optional and should
650 * be used instead of @mode_set if the driver needs to inspect the
651 * connector state or display info, since there is no direct way to
652 * go from the encoder to the current connector.
653 */
654 void (*atomic_mode_set)(struct drm_encoder *encoder,
655 struct drm_crtc_state *crtc_state,
656 struct drm_connector_state *conn_state);
657
36b66080
DV
658 /**
659 * @get_crtc:
660 *
661 * This callback is used by the legacy CRTC helpers to work around
662 * deficiencies in its own book-keeping.
663 *
664 * Do not use, use atomic helpers instead, which get the book keeping
665 * right.
666 *
667 * FIXME:
668 *
669 * Currently only nouveau is using this, and as soon as nouveau is
670 * atomic we can ditch this hook.
671 */
092d01da 672 struct drm_crtc *(*get_crtc)(struct drm_encoder *encoder);
36b66080
DV
673
674 /**
675 * @detect:
676 *
677 * This callback can be used by drivers who want to do detection on the
678 * encoder object instead of in connector functions.
679 *
680 * It is not used by any helper and therefore has purely driver-specific
681 * semantics. New drivers shouldn't use this and instead just implement
682 * their own private callbacks.
683 *
684 * FIXME:
685 *
686 * This should just be converted into a pile of driver vfuncs.
687 * Currently radeon, amdgpu and nouveau are using it.
688 */
092d01da
DV
689 enum drm_connector_status (*detect)(struct drm_encoder *encoder,
690 struct drm_connector *connector);
36b66080
DV
691
692 /**
693 * @disable:
694 *
695 * This callback should be used to disable the encoder. With the atomic
696 * drivers it is called before this encoder's CRTC has been shut off
6806cdf9
DV
697 * using their own &drm_crtc_helper_funcs.disable hook. If that
698 * sequence is too simple drivers can just add their own driver private
699 * encoder hooks and call them from CRTC's callback by looping over all
700 * encoders connected to it using for_each_encoder_on_crtc().
36b66080
DV
701 *
702 * This hook is used both by legacy CRTC helpers and atomic helpers.
703 * Atomic drivers don't need to implement it if there's no need to
704 * disable anything at the encoder level. To ensure that runtime PM
705 * handling (using either DPMS or the new "ACTIVE" property) works
706 * @disable must be the inverse of @enable for atomic drivers.
707 *
708 * NOTE:
709 *
710 * With legacy CRTC helpers there's a big semantic difference between
711 * @disable and other hooks (like @prepare or @dpms) used to shut down a
712 * encoder: @disable is only called when also logically disabling the
713 * display pipeline and needs to release any resources acquired in
714 * @mode_set (like shared PLLs, or again release pinned framebuffers).
715 *
716 * Therefore @disable must be the inverse of @mode_set plus @commit for
717 * drivers still using legacy CRTC helpers, which is different from the
718 * rules under atomic.
719 */
092d01da
DV
720 void (*disable)(struct drm_encoder *encoder);
721
36b66080
DV
722 /**
723 * @enable:
724 *
725 * This callback should be used to enable the encoder. With the atomic
726 * drivers it is called after this encoder's CRTC has been enabled using
6806cdf9
DV
727 * their own &drm_crtc_helper_funcs.enable hook. If that sequence is
728 * too simple drivers can just add their own driver private encoder
729 * hooks and call them from CRTC's callback by looping over all encoders
730 * connected to it using for_each_encoder_on_crtc().
36b66080
DV
731 *
732 * This hook is used only by atomic helpers, for symmetry with @disable.
733 * Atomic drivers don't need to implement it if there's no need to
734 * enable anything at the encoder level. To ensure that runtime PM handling
735 * (using either DPMS or the new "ACTIVE" property) works
736 * @enable must be the inverse of @disable for atomic drivers.
737 */
092d01da
DV
738 void (*enable)(struct drm_encoder *encoder);
739
36b66080
DV
740 /**
741 * @atomic_check:
742 *
743 * This callback is used to validate encoder state for atomic drivers.
744 * Since the encoder is the object connecting the CRTC and connector it
745 * gets passed both states, to be able to validate interactions and
746 * update the CRTC to match what the encoder needs for the requested
747 * connector.
748 *
9f800214
DV
749 * Since this provides a strict superset of the functionality of
750 * @mode_fixup (the requested and adjusted modes are both available
751 * through the passed in &struct drm_crtc_state) @mode_fixup is not
752 * called when @atomic_check is implemented.
753 *
36b66080
DV
754 * This function is used by the atomic helpers, but it is optional.
755 *
756 * NOTE:
757 *
758 * This function is called in the check phase of an atomic update. The
759 * driver is not allowed to change anything outside of the free-standing
760 * state objects passed-in or assembled in the overall &drm_atomic_state
761 * update tracking structure.
762 *
3eb220a5
JA
763 * Also beware that userspace can request its own custom modes, neither
764 * core nor helpers filter modes to the list of probe modes reported by
765 * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
766 * that modes are filtered consistently put any encoder constraints and
767 * limits checks into @mode_valid.
768 *
36b66080
DV
769 * RETURNS:
770 *
771 * 0 on success, -EINVAL if the state or the transition can't be
772 * supported, -ENOMEM on memory allocation failure and -EDEADLK if an
773 * attempt to obtain another state object ran into a &drm_modeset_lock
774 * deadlock.
775 */
092d01da
DV
776 int (*atomic_check)(struct drm_encoder *encoder,
777 struct drm_crtc_state *crtc_state,
778 struct drm_connector_state *conn_state);
779};
780
781/**
36b66080 782 * drm_encoder_helper_add - sets the helper vtable for an encoder
092d01da
DV
783 * @encoder: DRM encoder
784 * @funcs: helper vtable to set for @encoder
785 */
786static inline void drm_encoder_helper_add(struct drm_encoder *encoder,
787 const struct drm_encoder_helper_funcs *funcs)
788{
789 encoder->helper_private = funcs;
790}
791
792/**
793 * struct drm_connector_helper_funcs - helper operations for connectors
092d01da 794 *
4ee6034c
DV
795 * These functions are used by the atomic and legacy modeset helpers and by the
796 * probe helpers.
092d01da
DV
797 */
798struct drm_connector_helper_funcs {
4ee6034c
DV
799 /**
800 * @get_modes:
801 *
802 * This function should fill in all modes currently valid for the sink
6806cdf9 803 * into the &drm_connector.probed_modes list. It should also update the
4ee6034c
DV
804 * EDID property by calling drm_mode_connector_update_edid_property().
805 *
806 * The usual way to implement this is to cache the EDID retrieved in the
807 * probe callback somewhere in the driver-private connector structure.
808 * In this function drivers then parse the modes in the EDID and add
809 * them by calling drm_add_edid_modes(). But connectors that driver a
810 * fixed panel can also manually add specific modes using
df7d678b 811 * drm_mode_probed_add(). Drivers which manually add modes should also
6806cdf9
DV
812 * make sure that the &drm_connector.display_info,
813 * &drm_connector.width_mm and &drm_connector.height_mm fields are
814 * filled in.
df7d678b
DV
815 *
816 * Virtual drivers that just want some standard VESA mode with a given
817 * resolution can call drm_add_modes_noedid(), and mark the preferred
818 * one using drm_set_preferred_mode().
819 *
820 * Finally drivers that support audio probably want to update the ELD
821 * data, too, using drm_edid_to_eld().
4ee6034c 822 *
6806cdf9 823 * This function is only called after the @detect hook has indicated
4ee6034c
DV
824 * that a sink is connected and when the EDID isn't overridden through
825 * sysfs or the kernel commandline.
826 *
827 * This callback is used by the probe helpers in e.g.
828 * drm_helper_probe_single_connector_modes().
829 *
6c5ed5ae
ML
830 * To avoid races with concurrent connector state updates, the helper
831 * libraries always call this with the &drm_mode_config.connection_mutex
832 * held. Because of this it's safe to inspect &drm_connector->state.
833 *
4ee6034c
DV
834 * RETURNS:
835 *
836 * The number of modes added by calling drm_mode_probed_add().
837 */
092d01da 838 int (*get_modes)(struct drm_connector *connector);
4ee6034c 839
6c5ed5ae
ML
840 /**
841 * @detect_ctx:
842 *
843 * Check to see if anything is attached to the connector. The parameter
844 * force is set to false whilst polling, true when checking the
845 * connector due to a user request. force can be used by the driver to
846 * avoid expensive, destructive operations during automated probing.
847 *
848 * This callback is optional, if not implemented the connector will be
849 * considered as always being attached.
850 *
851 * This is the atomic version of &drm_connector_funcs.detect.
852 *
853 * To avoid races against concurrent connector state updates, the
854 * helper libraries always call this with ctx set to a valid context,
855 * and &drm_mode_config.connection_mutex will always be locked with
856 * the ctx parameter set to this ctx. This allows taking additional
857 * locks as required.
858 *
859 * RETURNS:
860 *
861 * &drm_connector_status indicating the connector's status,
862 * or the error code returned by drm_modeset_lock(), -EDEADLK.
863 */
864 int (*detect_ctx)(struct drm_connector *connector,
865 struct drm_modeset_acquire_ctx *ctx,
866 bool force);
867
4ee6034c
DV
868 /**
869 * @mode_valid:
870 *
871 * Callback to validate a mode for a connector, irrespective of the
872 * specific display configuration.
873 *
874 * This callback is used by the probe helpers to filter the mode list
875 * (which is usually derived from the EDID data block from the sink).
876 * See e.g. drm_helper_probe_single_connector_modes().
877 *
3eb220a5
JA
878 * This function is optional.
879 *
4ee6034c
DV
880 * NOTE:
881 *
882 * This only filters the mode list supplied to userspace in the
3eb220a5
JA
883 * GETCONNECTOR IOCTL. Compared to &drm_encoder_helper_funcs.mode_valid,
884 * &drm_crtc_helper_funcs.mode_valid and &drm_bridge_funcs.mode_valid,
885 * which are also called by the atomic helpers from
886 * drm_atomic_helper_check_modeset(). This allows userspace to force and
887 * ignore sink constraint (like the pixel clock limits in the screen's
888 * EDID), which is useful for e.g. testing, or working around a broken
889 * EDID. Any source hardware constraint (which always need to be
890 * enforced) therefore should be checked in one of the above callbacks,
891 * and not this one here.
4ee6034c 892 *
6c5ed5ae
ML
893 * To avoid races with concurrent connector state updates, the helper
894 * libraries always call this with the &drm_mode_config.connection_mutex
895 * held. Because of this it's safe to inspect &drm_connector->state.
896 *
4ee6034c
DV
897 * RETURNS:
898 *
6806cdf9
DV
899 * Either &drm_mode_status.MODE_OK or one of the failure reasons in &enum
900 * drm_mode_status.
4ee6034c 901 */
092d01da
DV
902 enum drm_mode_status (*mode_valid)(struct drm_connector *connector,
903 struct drm_display_mode *mode);
4ee6034c
DV
904 /**
905 * @best_encoder:
906 *
907 * This function should select the best encoder for the given connector.
908 *
909 * This function is used by both the atomic helpers (in the
910 * drm_atomic_helper_check_modeset() function) and in the legacy CRTC
911 * helpers.
912 *
913 * NOTE:
914 *
915 * In atomic drivers this function is called in the check phase of an
916 * atomic update. The driver is not allowed to change or inspect
917 * anything outside of arguments passed-in. Atomic drivers which need to
918 * inspect dynamic configuration state should instead use
919 * @atomic_best_encoder.
920 *
c61b93fe
BB
921 * You can leave this function to NULL if the connector is only
922 * attached to a single encoder and you are using the atomic helpers.
923 * In this case, the core will call drm_atomic_helper_best_encoder()
924 * for you.
925 *
4ee6034c
DV
926 * RETURNS:
927 *
928 * Encoder that should be used for the given connector and connector
929 * state, or NULL if no suitable encoder exists. Note that the helpers
930 * will ensure that encoders aren't used twice, drivers should not check
931 * for this.
932 */
092d01da 933 struct drm_encoder *(*best_encoder)(struct drm_connector *connector);
4ee6034c
DV
934
935 /**
936 * @atomic_best_encoder:
937 *
938 * This is the atomic version of @best_encoder for atomic drivers which
939 * need to select the best encoder depending upon the desired
940 * configuration and can't select it statically.
941 *
c61b93fe
BB
942 * This function is used by drm_atomic_helper_check_modeset().
943 * If it is not implemented, the core will fallback to @best_encoder
944 * (or drm_atomic_helper_best_encoder() if @best_encoder is NULL).
4ee6034c
DV
945 *
946 * NOTE:
947 *
948 * This function is called in the check phase of an atomic update. The
949 * driver is not allowed to change anything outside of the free-standing
950 * state objects passed-in or assembled in the overall &drm_atomic_state
951 * update tracking structure.
952 *
953 * RETURNS:
954 *
955 * Encoder that should be used for the given connector and connector
956 * state, or NULL if no suitable encoder exists. Note that the helpers
957 * will ensure that encoders aren't used twice, drivers should not check
958 * for this.
959 */
092d01da
DV
960 struct drm_encoder *(*atomic_best_encoder)(struct drm_connector *connector,
961 struct drm_connector_state *connector_state);
ce09d766
ML
962
963 /**
964 * @atomic_check:
965 *
966 * This hook is used to validate connector state. This function is
967 * called from &drm_atomic_helper_check_modeset, and is called when
968 * a connector property is set, or a modeset on the crtc is forced.
969 *
970 * Because &drm_atomic_helper_check_modeset may be called multiple times,
971 * this function should handle being called multiple times as well.
972 *
973 * This function is also allowed to inspect any other object's state and
974 * can add more state objects to the atomic commit if needed. Care must
975 * be taken though to ensure that state check and compute functions for
976 * these added states are all called, and derived state in other objects
977 * all updated. Again the recommendation is to just call check helpers
978 * until a maximal configuration is reached.
979 *
980 * NOTE:
981 *
982 * This function is called in the check phase of an atomic update. The
983 * driver is not allowed to change anything outside of the free-standing
984 * state objects passed-in or assembled in the overall &drm_atomic_state
985 * update tracking structure.
986 *
987 * RETURNS:
988 *
989 * 0 on success, -EINVAL if the state or the transition can't be
990 * supported, -ENOMEM on memory allocation failure and -EDEADLK if an
991 * attempt to obtain another state object ran into a &drm_modeset_lock
992 * deadlock.
993 */
994 int (*atomic_check)(struct drm_connector *connector,
995 struct drm_connector_state *state);
092d01da
DV
996};
997
998/**
999 * drm_connector_helper_add - sets the helper vtable for a connector
1000 * @connector: DRM connector
1001 * @funcs: helper vtable to set for @connector
1002 */
1003static inline void drm_connector_helper_add(struct drm_connector *connector,
1004 const struct drm_connector_helper_funcs *funcs)
1005{
1006 connector->helper_private = funcs;
1007}
1008
1009/**
11a0ba97 1010 * struct drm_plane_helper_funcs - helper operations for planes
092d01da 1011 *
11a0ba97
DV
1012 * These functions are used by the atomic helpers and by the transitional plane
1013 * helpers.
092d01da
DV
1014 */
1015struct drm_plane_helper_funcs {
11a0ba97
DV
1016 /**
1017 * @prepare_fb:
1018 *
1019 * This hook is to prepare a framebuffer for scanout by e.g. pinning
1020 * it's backing storage or relocating it into a contiguous block of
1021 * VRAM. Other possible preparatory work includes flushing caches.
1022 *
1023 * This function must not block for outstanding rendering, since it is
1024 * called in the context of the atomic IOCTL even for async commits to
1025 * be able to return any errors to userspace. Instead the recommended
1026 * way is to fill out the fence member of the passed-in
1027 * &drm_plane_state. If the driver doesn't support native fences then
1028 * equivalent functionality should be implemented through private
1029 * members in the plane structure.
1030 *
1031 * The helpers will call @cleanup_fb with matching arguments for every
1032 * successful call to this hook.
1033 *
1034 * This callback is used by the atomic modeset helpers and by the
1035 * transitional plane helpers, but it is optional.
1036 *
1037 * RETURNS:
1038 *
1039 * 0 on success or one of the following negative error codes allowed by
6806cdf9 1040 * the &drm_mode_config_funcs.atomic_commit vfunc. When using helpers
11a0ba97
DV
1041 * this callback is the only one which can fail an atomic commit,
1042 * everything else must complete successfully.
1043 */
092d01da 1044 int (*prepare_fb)(struct drm_plane *plane,
1832040d 1045 struct drm_plane_state *new_state);
11a0ba97
DV
1046 /**
1047 * @cleanup_fb:
1048 *
1049 * This hook is called to clean up any resources allocated for the given
1050 * framebuffer and plane configuration in @prepare_fb.
1051 *
1052 * This callback is used by the atomic modeset helpers and by the
1053 * transitional plane helpers, but it is optional.
1054 */
092d01da 1055 void (*cleanup_fb)(struct drm_plane *plane,
1832040d 1056 struct drm_plane_state *old_state);
092d01da 1057
11a0ba97
DV
1058 /**
1059 * @atomic_check:
1060 *
1061 * Drivers should check plane specific constraints in this hook.
1062 *
6806cdf9 1063 * When using drm_atomic_helper_check_planes() plane's @atomic_check
11a0ba97
DV
1064 * hooks are called before the ones for CRTCs, which allows drivers to
1065 * request shared resources that the CRTC controls here. For more
1066 * complicated dependencies the driver can call the provided check helpers
1067 * multiple times until the computed state has a final configuration and
1068 * everything has been checked.
1069 *
1070 * This function is also allowed to inspect any other object's state and
1071 * can add more state objects to the atomic commit if needed. Care must
6806cdf9 1072 * be taken though to ensure that state check and compute functions for
11a0ba97
DV
1073 * these added states are all called, and derived state in other objects
1074 * all updated. Again the recommendation is to just call check helpers
1075 * until a maximal configuration is reached.
1076 *
1077 * This callback is used by the atomic modeset helpers and by the
1078 * transitional plane helpers, but it is optional.
1079 *
1080 * NOTE:
1081 *
1082 * This function is called in the check phase of an atomic update. The
1083 * driver is not allowed to change anything outside of the free-standing
1084 * state objects passed-in or assembled in the overall &drm_atomic_state
1085 * update tracking structure.
1086 *
1087 * RETURNS:
1088 *
1089 * 0 on success, -EINVAL if the state or the transition can't be
1090 * supported, -ENOMEM on memory allocation failure and -EDEADLK if an
1091 * attempt to obtain another state object ran into a &drm_modeset_lock
1092 * deadlock.
1093 */
092d01da
DV
1094 int (*atomic_check)(struct drm_plane *plane,
1095 struct drm_plane_state *state);
11a0ba97
DV
1096
1097 /**
1098 * @atomic_update:
1099 *
1100 * Drivers should use this function to update the plane state. This
6806cdf9
DV
1101 * hook is called in-between the &drm_crtc_helper_funcs.atomic_begin and
1102 * drm_crtc_helper_funcs.atomic_flush callbacks.
11a0ba97
DV
1103 *
1104 * Note that the power state of the display pipe when this function is
1105 * called depends upon the exact helpers and calling sequence the driver
0dc9967d
SA
1106 * has picked. See drm_atomic_helper_commit_planes() for a discussion of
1107 * the tradeoffs and variants of plane commit helpers.
11a0ba97
DV
1108 *
1109 * This callback is used by the atomic modeset helpers and by the
1110 * transitional plane helpers, but it is optional.
1111 */
092d01da
DV
1112 void (*atomic_update)(struct drm_plane *plane,
1113 struct drm_plane_state *old_state);
11a0ba97
DV
1114 /**
1115 * @atomic_disable:
1116 *
1117 * Drivers should use this function to unconditionally disable a plane.
6806cdf9
DV
1118 * This hook is called in-between the
1119 * &drm_crtc_helper_funcs.atomic_begin and
1120 * drm_crtc_helper_funcs.atomic_flush callbacks. It is an alternative to
11a0ba97
DV
1121 * @atomic_update, which will be called for disabling planes, too, if
1122 * the @atomic_disable hook isn't implemented.
1123 *
1124 * This hook is also useful to disable planes in preparation of a modeset,
1125 * by calling drm_atomic_helper_disable_planes_on_crtc() from the
6806cdf9 1126 * &drm_crtc_helper_funcs.disable hook.
11a0ba97
DV
1127 *
1128 * Note that the power state of the display pipe when this function is
1129 * called depends upon the exact helpers and calling sequence the driver
0dc9967d
SA
1130 * has picked. See drm_atomic_helper_commit_planes() for a discussion of
1131 * the tradeoffs and variants of plane commit helpers.
11a0ba97
DV
1132 *
1133 * This callback is used by the atomic modeset helpers and by the
1134 * transitional plane helpers, but it is optional.
1135 */
092d01da
DV
1136 void (*atomic_disable)(struct drm_plane *plane,
1137 struct drm_plane_state *old_state);
1138};
1139
1140/**
1141 * drm_plane_helper_add - sets the helper vtable for a plane
1142 * @plane: DRM plane
1143 * @funcs: helper vtable to set for @plane
1144 */
1145static inline void drm_plane_helper_add(struct drm_plane *plane,
1146 const struct drm_plane_helper_funcs *funcs)
1147{
1148 plane->helper_private = funcs;
1149}
1150
9f2a7950
DV
1151/**
1152 * struct drm_mode_config_helper_funcs - global modeset helper operations
1153 *
1154 * These helper functions are used by the atomic helpers.
1155 */
1156struct drm_mode_config_helper_funcs {
1157 /**
1158 * @atomic_commit_tail:
1159 *
1160 * This hook is used by the default atomic_commit() hook implemented in
1161 * drm_atomic_helper_commit() together with the nonblocking commit
1162 * helpers (see drm_atomic_helper_setup_commit() for a starting point)
1163 * to implement blocking and nonblocking commits easily. It is not used
1164 * by the atomic helpers
1165 *
1ea0c02e
DV
1166 * This function is called when the new atomic state has already been
1167 * swapped into the various state pointers. The passed in state
1168 * therefore contains copies of the old/previous state. This hook should
1169 * commit the new state into hardware. Note that the helpers have
1170 * already waited for preceeding atomic commits and fences, but drivers
1171 * can add more waiting calls at the start of their implementation, e.g.
1172 * to wait for driver-internal request for implicit syncing, before
1173 * starting to commit the update to the hardware.
9f2a7950
DV
1174 *
1175 * After the atomic update is committed to the hardware this hook needs
1176 * to call drm_atomic_helper_commit_hw_done(). Then wait for the upate
1177 * to be executed by the hardware, for example using
01086487
BB
1178 * drm_atomic_helper_wait_for_vblanks() or
1179 * drm_atomic_helper_wait_for_flip_done(), and then clean up the old
9f2a7950
DV
1180 * framebuffers using drm_atomic_helper_cleanup_planes().
1181 *
1182 * When disabling a CRTC this hook _must_ stall for the commit to
1183 * complete. Vblank waits don't work on disabled CRTC, hence the core
1184 * can't take care of this. And it also can't rely on the vblank event,
1185 * since that can be signalled already when the screen shows black,
1186 * which can happen much earlier than the last hardware access needed to
1187 * shut off the display pipeline completely.
1188 *
1189 * This hook is optional, the default implementation is
1190 * drm_atomic_helper_commit_tail().
1191 */
1192 void (*atomic_commit_tail)(struct drm_atomic_state *state);
1193};
1194
092d01da 1195#endif