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>
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:
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
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.
29 #ifndef __DRM_MODESET_HELPER_VTABLES_H__
30 #define __DRM_MODESET_HELPER_VTABLES_H__
32 #include <drm/drm_crtc.h>
37 * The DRM mode setting helper functions are common code for drivers to use if
38 * they wish. Drivers are not forced to use this code in their
39 * implementations but it would be useful if the code they do use at least
40 * provides a consistent interface and operation to userspace. Therefore it is
41 * highly recommended to use the provided helpers as much as possible.
43 * Because there is only one pointer per modeset object to hold a vfunc table
44 * for helper libraries they are by necessity shared among the different
47 * To make this clear all the helper vtables are pulled together in this location here.
53 * struct drm_crtc_helper_funcs - helper operations for CRTCs
55 * These hooks are used by the legacy CRTC helpers, the transitional plane
56 * helpers and the new atomic modesetting helpers.
58 struct drm_crtc_helper_funcs
{
62 * Callback to control power levels on the CRTC. If the mode passed in
63 * is unsupported, the provider must use the next lowest power level.
64 * This is used by the legacy CRTC helpers to implement DPMS
65 * functionality in drm_helper_connector_dpms().
67 * This callback is also used to disable a CRTC by calling it with
68 * DRM_MODE_DPMS_OFF if the @disable hook isn't used.
70 * This callback is used by the legacy CRTC helpers. Atomic helpers
71 * also support using this hook for enabling and disabling a CRTC to
72 * facilitate transitions to atomic, but it is deprecated. Instead
73 * @enable and @disable should be used.
75 void (*dpms
)(struct drm_crtc
*crtc
, int mode
);
80 * This callback should prepare the CRTC for a subsequent modeset, which
81 * in practice means the driver should disable the CRTC if it is
82 * running. Most drivers ended up implementing this by calling their
83 * @dpms hook with DRM_MODE_DPMS_OFF.
85 * This callback is used by the legacy CRTC helpers. Atomic helpers
86 * also support using this hook for disabling a CRTC to facilitate
87 * transitions to atomic, but it is deprecated. Instead @disable should
90 void (*prepare
)(struct drm_crtc
*crtc
);
95 * This callback should commit the new mode on the CRTC after a modeset,
96 * which in practice means the driver should enable the CRTC. Most
97 * drivers ended up implementing this by calling their @dpms hook with
100 * This callback is used by the legacy CRTC helpers. Atomic helpers
101 * also support using this hook for enabling a CRTC to facilitate
102 * transitions to atomic, but it is deprecated. Instead @enable should
105 void (*commit
)(struct drm_crtc
*crtc
);
110 * This callback is used to validate a mode. The parameter mode is the
111 * display mode that userspace requested, adjusted_mode is the mode the
112 * encoders need to be fed with. Note that this is the inverse semantics
113 * of the meaning for the &drm_encoder and &drm_bridge
114 * ->mode_fixup() functions. If the CRTC cannot support the requested
115 * conversion from mode to adjusted_mode it should reject the modeset.
117 * This function is used by both legacy CRTC helpers and atomic helpers.
118 * With atomic helpers it is optional.
122 * This function is called in the check phase of atomic modesets, which
123 * can be aborted for any reason (including on userspace's request to
124 * just check whether a configuration would be possible). Atomic drivers
125 * MUST NOT touch any persistent state (hardware or software) or data
126 * structures except the passed in adjusted_mode parameter.
128 * This is in contrast to the legacy CRTC helpers where this was
131 * Atomic drivers which need to inspect and adjust more state should
132 * instead use the @atomic_check callback.
136 * True if an acceptable configuration is possible, false if the modeset
137 * operation should be rejected.
139 bool (*mode_fixup
)(struct drm_crtc
*crtc
,
140 const struct drm_display_mode
*mode
,
141 struct drm_display_mode
*adjusted_mode
);
146 * This callback is used by the legacy CRTC helpers to set a new mode,
147 * position and framebuffer. Since it ties the primary plane to every
148 * mode change it is incompatible with universal plane support. And
149 * since it can't update other planes it's incompatible with atomic
152 * This callback is only used by CRTC helpers and deprecated.
156 * 0 on success or a negative error code on failure.
158 int (*mode_set
)(struct drm_crtc
*crtc
, struct drm_display_mode
*mode
,
159 struct drm_display_mode
*adjusted_mode
, int x
, int y
,
160 struct drm_framebuffer
*old_fb
);
165 * This callback is used to update the display mode of a CRTC without
166 * changing anything of the primary plane configuration. This fits the
167 * requirement of atomic and hence is used by the atomic helpers. It is
168 * also used by the transitional plane helpers to implement a
169 * @mode_set hook in drm_helper_crtc_mode_set().
171 * Note that the display pipe is completely off when this function is
172 * called. Atomic drivers which need hardware to be running before they
173 * program the new display mode (e.g. because they implement runtime PM)
174 * should not use this hook. This is because the helper library calls
175 * this hook only once per mode change and not every time the display
176 * pipeline is suspended using either DPMS or the new "ACTIVE" property.
177 * Which means register values set in this callback might get reset when
178 * the CRTC is suspended, but not restored. Such drivers should instead
179 * move all their CRTC setup into the @enable callback.
181 * This callback is optional.
183 void (*mode_set_nofb
)(struct drm_crtc
*crtc
);
188 * This callback is used by the legacy CRTC helpers to set a new
189 * framebuffer and scanout position. It is optional and used as an
190 * optimized fast-path instead of a full mode set operation with all the
191 * resulting flickering. Since it can't update other planes it's
192 * incompatible with atomic modeset support.
194 * This callback is only used by the CRTC helpers and deprecated.
198 * 0 on success or a negative error code on failure.
200 int (*mode_set_base
)(struct drm_crtc
*crtc
, int x
, int y
,
201 struct drm_framebuffer
*old_fb
);
204 * @mode_set_base_atomic:
206 * This callback is used by the fbdev helpers to set a new framebuffer
207 * and scanout without sleeping, i.e. from an atomic calling context. It
208 * is only used to implement kgdb support.
210 * This callback is optional and only needed for kgdb support in the fbdev
215 * 0 on success or a negative error code on failure.
217 int (*mode_set_base_atomic
)(struct drm_crtc
*crtc
,
218 struct drm_framebuffer
*fb
, int x
, int y
,
219 enum mode_set_atomic
);
224 * Load a LUT prepared with the @gamma_set functions from
225 * &drm_fb_helper_funcs.
227 * This callback is optional and is only used by the fbdev emulation
232 * This callback is functionally redundant with the core gamma table
233 * support and simply exists because the fbdev hasn't yet been
234 * refactored to use the core gamma table interfaces.
236 void (*load_lut
)(struct drm_crtc
*crtc
);
241 * This callback should be used to disable the CRTC. With the atomic
242 * drivers it is called after all encoders connected to this CRTC have
243 * been shut off already using their own ->disable hook. If that
244 * sequence is too simple drivers can just add their own hooks and call
245 * it from this CRTC callback here by looping over all encoders
246 * connected to it using for_each_encoder_on_crtc().
248 * This hook is used both by legacy CRTC helpers and atomic helpers.
249 * Atomic drivers don't need to implement it if there's no need to
250 * disable anything at the CRTC level. To ensure that runtime PM
251 * handling (using either DPMS or the new "ACTIVE" property) works
252 * @disable must be the inverse of @enable for atomic drivers.
256 * With legacy CRTC helpers there's a big semantic difference between
257 * @disable and other hooks (like @prepare or @dpms) used to shut down a
258 * CRTC: @disable is only called when also logically disabling the
259 * display pipeline and needs to release any resources acquired in
260 * @mode_set (like shared PLLs, or again release pinned framebuffers).
262 * Therefore @disable must be the inverse of @mode_set plus @commit for
263 * drivers still using legacy CRTC helpers, which is different from the
264 * rules under atomic.
266 void (*disable
)(struct drm_crtc
*crtc
);
271 * This callback should be used to enable the CRTC. With the atomic
272 * drivers it is called before all encoders connected to this CRTC are
273 * enabled through the encoder's own ->enable hook. If that sequence is
274 * too simple drivers can just add their own hooks and call it from this
275 * CRTC callback here by looping over all encoders connected to it using
276 * for_each_encoder_on_crtc().
278 * This hook is used only by atomic helpers, for symmetry with @disable.
279 * Atomic drivers don't need to implement it if there's no need to
280 * enable anything at the CRTC level. To ensure that runtime PM handling
281 * (using either DPMS or the new "ACTIVE" property) works
282 * @enable must be the inverse of @disable for atomic drivers.
284 void (*enable
)(struct drm_crtc
*crtc
);
289 * Drivers should check plane-update related CRTC constraints in this
290 * hook. They can also check mode related limitations but need to be
291 * aware of the calling order, since this hook is used by
292 * drm_atomic_helper_check_planes() whereas the preparations needed to
293 * check output routing and the display mode is done in
294 * drm_atomic_helper_check_modeset(). Therefore drivers that want to
295 * check output routing and display mode constraints in this callback
296 * must ensure that drm_atomic_helper_check_modeset() has been called
297 * beforehand. This is calling order used by the default helper
298 * implementation in drm_atomic_helper_check().
300 * When using drm_atomic_helper_check_planes() CRTCs' ->atomic_check()
301 * hooks are called after the ones for planes, which allows drivers to
302 * assign shared resources requested by planes in the CRTC callback
303 * here. For more complicated dependencies the driver can call the provided
304 * check helpers multiple times until the computed state has a final
305 * configuration and everything has been checked.
307 * This function is also allowed to inspect any other object's state and
308 * can add more state objects to the atomic commit if needed. Care must
309 * be taken though to ensure that state check&compute functions for
310 * these added states are all called, and derived state in other objects
311 * all updated. Again the recommendation is to just call check helpers
312 * until a maximal configuration is reached.
314 * This callback is used by the atomic modeset helpers and by the
315 * transitional plane helpers, but it is optional.
319 * This function is called in the check phase of an atomic update. The
320 * driver is not allowed to change anything outside of the free-standing
321 * state objects passed-in or assembled in the overall &drm_atomic_state
322 * update tracking structure.
326 * 0 on success, -EINVAL if the state or the transition can't be
327 * supported, -ENOMEM on memory allocation failure and -EDEADLK if an
328 * attempt to obtain another state object ran into a &drm_modeset_lock
331 int (*atomic_check
)(struct drm_crtc
*crtc
,
332 struct drm_crtc_state
*state
);
337 * Drivers should prepare for an atomic update of multiple planes on
338 * a CRTC in this hook. Depending upon hardware this might be vblank
339 * evasion, blocking updates by setting bits or doing preparatory work
340 * for e.g. manual update display.
342 * This hook is called before any plane commit functions are called.
344 * Note that the power state of the display pipe when this function is
345 * called depends upon the exact helpers and calling sequence the driver
346 * has picked. See drm_atomic_commit_planes() for a discussion of the
347 * tradeoffs and variants of plane commit helpers.
349 * This callback is used by the atomic modeset helpers and by the
350 * transitional plane helpers, but it is optional.
352 void (*atomic_begin
)(struct drm_crtc
*crtc
,
353 struct drm_crtc_state
*old_crtc_state
);
357 * Drivers should finalize an atomic update of multiple planes on
358 * a CRTC in this hook. Depending upon hardware this might include
359 * checking that vblank evasion was successful, unblocking updates by
360 * setting bits or setting the GO bit to flush out all updates.
362 * Simple hardware or hardware with special requirements can commit and
363 * flush out all updates for all planes from this hook and forgo all the
364 * other commit hooks for plane updates.
366 * This hook is called after any plane commit functions are called.
368 * Note that the power state of the display pipe when this function is
369 * called depends upon the exact helpers and calling sequence the driver
370 * has picked. See drm_atomic_commit_planes() for a discussion of the
371 * tradeoffs and variants of plane commit helpers.
373 * This callback is used by the atomic modeset helpers and by the
374 * transitional plane helpers, but it is optional.
376 void (*atomic_flush
)(struct drm_crtc
*crtc
,
377 struct drm_crtc_state
*old_crtc_state
);
381 * drm_crtc_helper_add - sets the helper vtable for a crtc
383 * @funcs: helper vtable to set for @crtc
385 static inline void drm_crtc_helper_add(struct drm_crtc
*crtc
,
386 const struct drm_crtc_helper_funcs
*funcs
)
388 crtc
->helper_private
= funcs
;
392 * struct drm_encoder_helper_funcs - helper operations for encoders
394 * These hooks are used by the legacy CRTC helpers, the transitional plane
395 * helpers and the new atomic modesetting helpers.
397 struct drm_encoder_helper_funcs
{
401 * Callback to control power levels on the encoder. If the mode passed in
402 * is unsupported, the provider must use the next lowest power level.
403 * This is used by the legacy encoder helpers to implement DPMS
404 * functionality in drm_helper_connector_dpms().
406 * This callback is also used to disable an encoder by calling it with
407 * DRM_MODE_DPMS_OFF if the @disable hook isn't used.
409 * This callback is used by the legacy CRTC helpers. Atomic helpers
410 * also support using this hook for enabling and disabling an encoder to
411 * facilitate transitions to atomic, but it is deprecated. Instead
412 * @enable and @disable should be used.
414 void (*dpms
)(struct drm_encoder
*encoder
, int mode
);
419 * This callback is used to validate and adjust a mode. The parameter
420 * mode is the display mode that should be fed to the next element in
421 * the display chain, either the final &drm_connector or a &drm_bridge.
422 * The parameter adjusted_mode is the input mode the encoder requires. It
423 * can be modified by this callback and does not need to match mode.
425 * This function is used by both legacy CRTC helpers and atomic helpers.
426 * With atomic helpers it is optional.
430 * This function is called in the check phase of atomic modesets, which
431 * can be aborted for any reason (including on userspace's request to
432 * just check whether a configuration would be possible). Atomic drivers
433 * MUST NOT touch any persistent state (hardware or software) or data
434 * structures except the passed in adjusted_mode parameter.
436 * This is in contrast to the legacy CRTC helpers where this was
439 * Atomic drivers which need to inspect and adjust more state should
440 * instead use the @atomic_check callback.
444 * True if an acceptable configuration is possible, false if the modeset
445 * operation should be rejected.
447 bool (*mode_fixup
)(struct drm_encoder
*encoder
,
448 const struct drm_display_mode
*mode
,
449 struct drm_display_mode
*adjusted_mode
);
454 * This callback should prepare the encoder for a subsequent modeset,
455 * which in practice means the driver should disable the encoder if it
456 * is running. Most drivers ended up implementing this by calling their
457 * @dpms hook with DRM_MODE_DPMS_OFF.
459 * This callback is used by the legacy CRTC helpers. Atomic helpers
460 * also support using this hook for disabling an encoder to facilitate
461 * transitions to atomic, but it is deprecated. Instead @disable should
464 void (*prepare
)(struct drm_encoder
*encoder
);
469 * This callback should commit the new mode on the encoder after a modeset,
470 * which in practice means the driver should enable the encoder. Most
471 * drivers ended up implementing this by calling their @dpms hook with
474 * This callback is used by the legacy CRTC helpers. Atomic helpers
475 * also support using this hook for enabling an encoder to facilitate
476 * transitions to atomic, but it is deprecated. Instead @enable should
479 void (*commit
)(struct drm_encoder
*encoder
);
484 * This callback is used to update the display mode of an encoder.
486 * Note that the display pipe is completely off when this function is
487 * called. Drivers which need hardware to be running before they program
488 * the new display mode (because they implement runtime PM) should not
489 * use this hook, because the helper library calls it only once and not
490 * every time the display pipeline is suspend using either DPMS or the
491 * new "ACTIVE" property. Such drivers should instead move all their
492 * encoder setup into the ->enable() callback.
494 * This callback is used both by the legacy CRTC helpers and the atomic
495 * modeset helpers. It is optional in the atomic helpers.
497 void (*mode_set
)(struct drm_encoder
*encoder
,
498 struct drm_display_mode
*mode
,
499 struct drm_display_mode
*adjusted_mode
);
504 * This callback is used by the legacy CRTC helpers to work around
505 * deficiencies in its own book-keeping.
507 * Do not use, use atomic helpers instead, which get the book keeping
512 * Currently only nouveau is using this, and as soon as nouveau is
513 * atomic we can ditch this hook.
515 struct drm_crtc
*(*get_crtc
)(struct drm_encoder
*encoder
);
520 * This callback can be used by drivers who want to do detection on the
521 * encoder object instead of in connector functions.
523 * It is not used by any helper and therefore has purely driver-specific
524 * semantics. New drivers shouldn't use this and instead just implement
525 * their own private callbacks.
529 * This should just be converted into a pile of driver vfuncs.
530 * Currently radeon, amdgpu and nouveau are using it.
532 enum drm_connector_status (*detect
)(struct drm_encoder
*encoder
,
533 struct drm_connector
*connector
);
538 * This callback should be used to disable the encoder. With the atomic
539 * drivers it is called before this encoder's CRTC has been shut off
540 * using the CRTC's own ->disable hook. If that sequence is too simple
541 * drivers can just add their own driver private encoder hooks and call
542 * them from CRTC's callback by looping over all encoders connected to
543 * it using for_each_encoder_on_crtc().
545 * This hook is used both by legacy CRTC helpers and atomic helpers.
546 * Atomic drivers don't need to implement it if there's no need to
547 * disable anything at the encoder level. To ensure that runtime PM
548 * handling (using either DPMS or the new "ACTIVE" property) works
549 * @disable must be the inverse of @enable for atomic drivers.
553 * With legacy CRTC helpers there's a big semantic difference between
554 * @disable and other hooks (like @prepare or @dpms) used to shut down a
555 * encoder: @disable is only called when also logically disabling the
556 * display pipeline and needs to release any resources acquired in
557 * @mode_set (like shared PLLs, or again release pinned framebuffers).
559 * Therefore @disable must be the inverse of @mode_set plus @commit for
560 * drivers still using legacy CRTC helpers, which is different from the
561 * rules under atomic.
563 void (*disable
)(struct drm_encoder
*encoder
);
568 * This callback should be used to enable the encoder. With the atomic
569 * drivers it is called after this encoder's CRTC has been enabled using
570 * the CRTC's own ->enable hook. If that sequence is too simple drivers
571 * can just add their own driver private encoder hooks and call them
572 * from CRTC's callback by looping over all encoders connected to it
573 * using for_each_encoder_on_crtc().
575 * This hook is used only by atomic helpers, for symmetry with @disable.
576 * Atomic drivers don't need to implement it if there's no need to
577 * enable anything at the encoder level. To ensure that runtime PM handling
578 * (using either DPMS or the new "ACTIVE" property) works
579 * @enable must be the inverse of @disable for atomic drivers.
581 void (*enable
)(struct drm_encoder
*encoder
);
586 * This callback is used to validate encoder state for atomic drivers.
587 * Since the encoder is the object connecting the CRTC and connector it
588 * gets passed both states, to be able to validate interactions and
589 * update the CRTC to match what the encoder needs for the requested
592 * This function is used by the atomic helpers, but it is optional.
596 * This function is called in the check phase of an atomic update. The
597 * driver is not allowed to change anything outside of the free-standing
598 * state objects passed-in or assembled in the overall &drm_atomic_state
599 * update tracking structure.
603 * 0 on success, -EINVAL if the state or the transition can't be
604 * supported, -ENOMEM on memory allocation failure and -EDEADLK if an
605 * attempt to obtain another state object ran into a &drm_modeset_lock
608 int (*atomic_check
)(struct drm_encoder
*encoder
,
609 struct drm_crtc_state
*crtc_state
,
610 struct drm_connector_state
*conn_state
);
614 * drm_encoder_helper_add - sets the helper vtable for an encoder
615 * @encoder: DRM encoder
616 * @funcs: helper vtable to set for @encoder
618 static inline void drm_encoder_helper_add(struct drm_encoder
*encoder
,
619 const struct drm_encoder_helper_funcs
*funcs
)
621 encoder
->helper_private
= funcs
;
625 * struct drm_connector_helper_funcs - helper operations for connectors
627 * These functions are used by the atomic and legacy modeset helpers and by the
630 struct drm_connector_helper_funcs
{
634 * This function should fill in all modes currently valid for the sink
635 * into the connector->probed_modes list. It should also update the
636 * EDID property by calling drm_mode_connector_update_edid_property().
638 * The usual way to implement this is to cache the EDID retrieved in the
639 * probe callback somewhere in the driver-private connector structure.
640 * In this function drivers then parse the modes in the EDID and add
641 * them by calling drm_add_edid_modes(). But connectors that driver a
642 * fixed panel can also manually add specific modes using
643 * drm_mode_probed_add(). Finally drivers that support audio probably
644 * want to update the ELD data, too, using drm_edid_to_eld().
646 * This function is only called after the ->detect() hook has indicated
647 * that a sink is connected and when the EDID isn't overridden through
648 * sysfs or the kernel commandline.
650 * This callback is used by the probe helpers in e.g.
651 * drm_helper_probe_single_connector_modes().
655 * The number of modes added by calling drm_mode_probed_add().
657 int (*get_modes
)(struct drm_connector
*connector
);
662 * Callback to validate a mode for a connector, irrespective of the
663 * specific display configuration.
665 * This callback is used by the probe helpers to filter the mode list
666 * (which is usually derived from the EDID data block from the sink).
667 * See e.g. drm_helper_probe_single_connector_modes().
671 * This only filters the mode list supplied to userspace in the
672 * GETCONNECOTR IOCTL. Userspace is free to create modes of its own and
673 * ask the kernel to use them. It this case the atomic helpers or legacy
674 * CRTC helpers will not call this function. Drivers therefore must
675 * still fully validate any mode passed in in a modeset request.
679 * Either MODE_OK or one of the failure reasons in enum
682 enum drm_mode_status (*mode_valid
)(struct drm_connector
*connector
,
683 struct drm_display_mode
*mode
);
687 * This function should select the best encoder for the given connector.
689 * This function is used by both the atomic helpers (in the
690 * drm_atomic_helper_check_modeset() function) and in the legacy CRTC
695 * In atomic drivers this function is called in the check phase of an
696 * atomic update. The driver is not allowed to change or inspect
697 * anything outside of arguments passed-in. Atomic drivers which need to
698 * inspect dynamic configuration state should instead use
699 * @atomic_best_encoder.
703 * Encoder that should be used for the given connector and connector
704 * state, or NULL if no suitable encoder exists. Note that the helpers
705 * will ensure that encoders aren't used twice, drivers should not check
708 struct drm_encoder
*(*best_encoder
)(struct drm_connector
*connector
);
711 * @atomic_best_encoder:
713 * This is the atomic version of @best_encoder for atomic drivers which
714 * need to select the best encoder depending upon the desired
715 * configuration and can't select it statically.
717 * This function is used by drm_atomic_helper_check_modeset() and either
718 * this or @best_encoder is required.
722 * This function is called in the check phase of an atomic update. The
723 * driver is not allowed to change anything outside of the free-standing
724 * state objects passed-in or assembled in the overall &drm_atomic_state
725 * update tracking structure.
729 * Encoder that should be used for the given connector and connector
730 * state, or NULL if no suitable encoder exists. Note that the helpers
731 * will ensure that encoders aren't used twice, drivers should not check
734 struct drm_encoder
*(*atomic_best_encoder
)(struct drm_connector
*connector
,
735 struct drm_connector_state
*connector_state
);
739 * drm_connector_helper_add - sets the helper vtable for a connector
740 * @connector: DRM connector
741 * @funcs: helper vtable to set for @connector
743 static inline void drm_connector_helper_add(struct drm_connector
*connector
,
744 const struct drm_connector_helper_funcs
*funcs
)
746 connector
->helper_private
= funcs
;
750 * struct drm_plane_helper_funcs - helper operations for planes
752 * These functions are used by the atomic helpers and by the transitional plane
755 struct drm_plane_helper_funcs
{
759 * This hook is to prepare a framebuffer for scanout by e.g. pinning
760 * it's backing storage or relocating it into a contiguous block of
761 * VRAM. Other possible preparatory work includes flushing caches.
763 * This function must not block for outstanding rendering, since it is
764 * called in the context of the atomic IOCTL even for async commits to
765 * be able to return any errors to userspace. Instead the recommended
766 * way is to fill out the fence member of the passed-in
767 * &drm_plane_state. If the driver doesn't support native fences then
768 * equivalent functionality should be implemented through private
769 * members in the plane structure.
771 * The helpers will call @cleanup_fb with matching arguments for every
772 * successful call to this hook.
774 * This callback is used by the atomic modeset helpers and by the
775 * transitional plane helpers, but it is optional.
779 * 0 on success or one of the following negative error codes allowed by
780 * the atomic_commit hook in &drm_mode_config_funcs. When using helpers
781 * this callback is the only one which can fail an atomic commit,
782 * everything else must complete successfully.
784 int (*prepare_fb
)(struct drm_plane
*plane
,
785 const struct drm_plane_state
*new_state
);
789 * This hook is called to clean up any resources allocated for the given
790 * framebuffer and plane configuration in @prepare_fb.
792 * This callback is used by the atomic modeset helpers and by the
793 * transitional plane helpers, but it is optional.
795 void (*cleanup_fb
)(struct drm_plane
*plane
,
796 const struct drm_plane_state
*old_state
);
801 * Drivers should check plane specific constraints in this hook.
803 * When using drm_atomic_helper_check_planes() plane's ->atomic_check()
804 * hooks are called before the ones for CRTCs, which allows drivers to
805 * request shared resources that the CRTC controls here. For more
806 * complicated dependencies the driver can call the provided check helpers
807 * multiple times until the computed state has a final configuration and
808 * everything has been checked.
810 * This function is also allowed to inspect any other object's state and
811 * can add more state objects to the atomic commit if needed. Care must
812 * be taken though to ensure that state check&compute functions for
813 * these added states are all called, and derived state in other objects
814 * all updated. Again the recommendation is to just call check helpers
815 * until a maximal configuration is reached.
817 * This callback is used by the atomic modeset helpers and by the
818 * transitional plane helpers, but it is optional.
822 * This function is called in the check phase of an atomic update. The
823 * driver is not allowed to change anything outside of the free-standing
824 * state objects passed-in or assembled in the overall &drm_atomic_state
825 * update tracking structure.
829 * 0 on success, -EINVAL if the state or the transition can't be
830 * supported, -ENOMEM on memory allocation failure and -EDEADLK if an
831 * attempt to obtain another state object ran into a &drm_modeset_lock
834 int (*atomic_check
)(struct drm_plane
*plane
,
835 struct drm_plane_state
*state
);
840 * Drivers should use this function to update the plane state. This
841 * hook is called in-between the ->atomic_begin() and
842 * ->atomic_flush() of &drm_crtc_helper_funcs.
844 * Note that the power state of the display pipe when this function is
845 * called depends upon the exact helpers and calling sequence the driver
846 * has picked. See drm_atomic_commit_planes() for a discussion of the
847 * tradeoffs and variants of plane commit helpers.
849 * This callback is used by the atomic modeset helpers and by the
850 * transitional plane helpers, but it is optional.
852 void (*atomic_update
)(struct drm_plane
*plane
,
853 struct drm_plane_state
*old_state
);
857 * Drivers should use this function to unconditionally disable a plane.
858 * This hook is called in-between the ->atomic_begin() and
859 * ->atomic_flush() of &drm_crtc_helper_funcs. It is an alternative to
860 * @atomic_update, which will be called for disabling planes, too, if
861 * the @atomic_disable hook isn't implemented.
863 * This hook is also useful to disable planes in preparation of a modeset,
864 * by calling drm_atomic_helper_disable_planes_on_crtc() from the
865 * ->disable() hook in &drm_crtc_helper_funcs.
867 * Note that the power state of the display pipe when this function is
868 * called depends upon the exact helpers and calling sequence the driver
869 * has picked. See drm_atomic_commit_planes() for a discussion of the
870 * tradeoffs and variants of plane commit helpers.
872 * This callback is used by the atomic modeset helpers and by the
873 * transitional plane helpers, but it is optional.
875 void (*atomic_disable
)(struct drm_plane
*plane
,
876 struct drm_plane_state
*old_state
);
880 * drm_plane_helper_add - sets the helper vtable for a plane
882 * @funcs: helper vtable to set for @plane
884 static inline void drm_plane_helper_add(struct drm_plane
*plane
,
885 const struct drm_plane_helper_funcs
*funcs
)
887 plane
->helper_private
= funcs
;