]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - include/drm/drm_atomic.h
2 * Copyright (C) 2014 Red Hat
3 * Copyright (C) 2014 Intel Corp.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
24 * Rob Clark <robdclark@gmail.com>
25 * Daniel Vetter <daniel.vetter@ffwll.ch>
31 #include <drm/drm_crtc.h>
34 * struct drm_crtc_commit - track modeset commits on a CRTC
36 * This structure is used to track pending modeset changes and atomic commit on
37 * a per-CRTC basis. Since updating the list should never block this structure
38 * is reference counted to allow waiters to safely wait on an event to complete,
39 * without holding any locks.
41 * It has 3 different events in total to allow a fine-grained synchronization
42 * between outstanding updates::
44 * atomic commit thread hardware
46 * write new state into hardware ----> ...
48 * switch to new state on next
51 * wait for buffers to show up ...
53 * ... send completion irq
54 * irq handler signals flip_done
59 * wait for flip_done <----
60 * clean up atomic state
62 * The important bit to know is that cleanup_done is the terminal event, but the
63 * ordering between flip_done and hw_done is entirely up to the specific driver
64 * and modeset state change.
66 * For an implementation of how to use this look at
67 * drm_atomic_helper_setup_commit() from the atomic helper library.
69 struct drm_crtc_commit
{
73 * DRM CRTC for this commit.
75 struct drm_crtc
*crtc
;
80 * Reference count for this structure. Needed to allow blocking on
81 * completions without the risk of the completion disappearing
89 * Will be signaled when the hardware has flipped to the new set of
90 * buffers. Signals at the same time as when the drm event for this
91 * commit is sent to userspace, or when an out-fence is singalled. Note
92 * that for most hardware, in most cases this happens after @hw_done is
95 struct completion flip_done
;
100 * Will be signalled when all hw register changes for this commit have
101 * been written out. Especially when disabling a pipe this can be much
102 * later than than @flip_done, since that can signal already when the
103 * screen goes black, whereas to fully shut down a pipe more register
106 * Note that this does not need to include separately reference-counted
107 * resources like backing storage buffer pinning, or runtime pm
110 struct completion hw_done
;
115 * Will be signalled after old buffers have been cleaned up by calling
116 * drm_atomic_helper_cleanup_planes(). Since this can only happen after
117 * a vblank wait completed it might be a bit later. This completion is
118 * useful to throttle updates and avoid hardware updates getting ahead
119 * of the buffer cleanup too much.
121 struct completion cleanup_done
;
126 * Entry on the per-CRTC &drm_crtc.commit_list. Protected by
127 * $drm_crtc.commit_lock.
129 struct list_head commit_entry
;
134 * &drm_pending_vblank_event pointer to clean up private events.
136 struct drm_pending_vblank_event
*event
;
141 * A flag that's set after drm_atomic_helper_setup_commit takes a second
142 * reference for the completion of $drm_crtc_state.event. It's used by
143 * the free code to remove the second reference if commit fails.
145 bool abort_completion
;
148 struct __drm_planes_state
{
149 struct drm_plane
*ptr
;
150 struct drm_plane_state
*state
, *old_state
, *new_state
;
153 struct __drm_crtcs_state
{
154 struct drm_crtc
*ptr
;
155 struct drm_crtc_state
*state
, *old_state
, *new_state
;
156 s32 __user
*out_fence_ptr
;
157 unsigned last_vblank_count
;
160 struct __drm_connnectors_state
{
161 struct drm_connector
*ptr
;
162 struct drm_connector_state
*state
, *old_state
, *new_state
;
165 struct drm_private_obj
;
166 struct drm_private_state
;
169 * struct drm_private_state_funcs - atomic state functions for private objects
171 * These hooks are used by atomic helpers to create, swap and destroy states of
172 * private objects. The structure itself is used as a vtable to identify the
173 * associated private object type. Each private object type that needs to be
174 * added to the atomic states is expected to have an implementation of these
175 * hooks and pass a pointer to it's drm_private_state_funcs struct to
176 * drm_atomic_get_private_obj_state().
178 struct drm_private_state_funcs
{
180 * @atomic_duplicate_state:
182 * Duplicate the current state of the private object and return it. It
183 * is an error to call this before obj->state has been initialized.
187 * Duplicated atomic state or NULL when obj->state is not
188 * initialized or allocation failed.
190 struct drm_private_state
*(*atomic_duplicate_state
)(struct drm_private_obj
*obj
);
193 * @atomic_destroy_state:
195 * Frees the private object state created with @atomic_duplicate_state.
197 void (*atomic_destroy_state
)(struct drm_private_obj
*obj
,
198 struct drm_private_state
*state
);
201 struct drm_private_obj
{
202 struct drm_private_state
*state
;
204 const struct drm_private_state_funcs
*funcs
;
207 struct drm_private_state
{
208 struct drm_atomic_state
*state
;
211 struct __drm_private_objs_state
{
212 struct drm_private_obj
*ptr
;
213 struct drm_private_state
*state
, *old_state
, *new_state
;
217 * struct drm_atomic_state - the global state object for atomic updates
218 * @ref: count of all references to this state (will not be freed until zero)
219 * @dev: parent DRM device
220 * @allow_modeset: allow full modeset
221 * @legacy_cursor_update: hint to enforce legacy cursor IOCTL semantics
222 * @async_update: hint for asynchronous plane update
223 * @planes: pointer to array of structures with per-plane data
224 * @crtcs: pointer to array of CRTC pointers
225 * @num_connector: size of the @connectors and @connector_states arrays
226 * @connectors: pointer to array of structures with per-connector data
227 * @num_private_objs: size of the @private_objs array
228 * @private_objs: pointer to array of private object pointers
229 * @acquire_ctx: acquire context for this atomic modeset state update
231 struct drm_atomic_state
{
234 struct drm_device
*dev
;
235 bool allow_modeset
: 1;
236 bool legacy_cursor_update
: 1;
237 bool async_update
: 1;
238 struct __drm_planes_state
*planes
;
239 struct __drm_crtcs_state
*crtcs
;
241 struct __drm_connnectors_state
*connectors
;
242 int num_private_objs
;
243 struct __drm_private_objs_state
*private_objs
;
245 struct drm_modeset_acquire_ctx
*acquire_ctx
;
250 * Used for signaling unbound planes/connectors.
251 * When a connector or plane is not bound to any CRTC, it's still important
252 * to preserve linearity to prevent the atomic states from being freed to early.
254 * This commit (if set) is not bound to any crtc, but will be completed when
255 * drm_atomic_helper_commit_hw_done() is called.
257 struct drm_crtc_commit
*fake_commit
;
262 * Work item which can be used by the driver or helpers to execute the
263 * commit without blocking.
265 struct work_struct commit_work
;
268 void __drm_crtc_commit_free(struct kref
*kref
);
271 * drm_crtc_commit_get - acquire a reference to the CRTC commit
272 * @commit: CRTC commit
274 * Increases the reference of @commit.
277 * The pointer to @commit, with reference increased.
279 static inline struct drm_crtc_commit
*drm_crtc_commit_get(struct drm_crtc_commit
*commit
)
281 kref_get(&commit
->ref
);
286 * drm_crtc_commit_put - release a reference to the CRTC commmit
287 * @commit: CRTC commit
289 * This releases a reference to @commit which is freed after removing the
290 * final reference. No locking required and callable from any context.
292 static inline void drm_crtc_commit_put(struct drm_crtc_commit
*commit
)
294 kref_put(&commit
->ref
, __drm_crtc_commit_free
);
297 struct drm_atomic_state
* __must_check
298 drm_atomic_state_alloc(struct drm_device
*dev
);
299 void drm_atomic_state_clear(struct drm_atomic_state
*state
);
302 * drm_atomic_state_get - acquire a reference to the atomic state
303 * @state: The atomic state
305 * Returns a new reference to the @state
307 static inline struct drm_atomic_state
*
308 drm_atomic_state_get(struct drm_atomic_state
*state
)
310 kref_get(&state
->ref
);
314 void __drm_atomic_state_free(struct kref
*ref
);
317 * drm_atomic_state_put - release a reference to the atomic state
318 * @state: The atomic state
320 * This releases a reference to @state which is freed after removing the
321 * final reference. No locking required and callable from any context.
323 static inline void drm_atomic_state_put(struct drm_atomic_state
*state
)
325 kref_put(&state
->ref
, __drm_atomic_state_free
);
329 drm_atomic_state_init(struct drm_device
*dev
, struct drm_atomic_state
*state
);
330 void drm_atomic_state_default_clear(struct drm_atomic_state
*state
);
331 void drm_atomic_state_default_release(struct drm_atomic_state
*state
);
333 struct drm_crtc_state
* __must_check
334 drm_atomic_get_crtc_state(struct drm_atomic_state
*state
,
335 struct drm_crtc
*crtc
);
336 int drm_atomic_crtc_set_property(struct drm_crtc
*crtc
,
337 struct drm_crtc_state
*state
, struct drm_property
*property
,
339 struct drm_plane_state
* __must_check
340 drm_atomic_get_plane_state(struct drm_atomic_state
*state
,
341 struct drm_plane
*plane
);
342 struct drm_connector_state
* __must_check
343 drm_atomic_get_connector_state(struct drm_atomic_state
*state
,
344 struct drm_connector
*connector
);
346 void drm_atomic_private_obj_init(struct drm_private_obj
*obj
,
347 struct drm_private_state
*state
,
348 const struct drm_private_state_funcs
*funcs
);
349 void drm_atomic_private_obj_fini(struct drm_private_obj
*obj
);
351 struct drm_private_state
* __must_check
352 drm_atomic_get_private_obj_state(struct drm_atomic_state
*state
,
353 struct drm_private_obj
*obj
);
356 * drm_atomic_get_existing_crtc_state - get crtc state, if it exists
357 * @state: global atomic state object
358 * @crtc: crtc to grab
360 * This function returns the crtc state for the given crtc, or NULL
361 * if the crtc is not part of the global atomic state.
363 * This function is deprecated, @drm_atomic_get_old_crtc_state or
364 * @drm_atomic_get_new_crtc_state should be used instead.
366 static inline struct drm_crtc_state
*
367 drm_atomic_get_existing_crtc_state(struct drm_atomic_state
*state
,
368 struct drm_crtc
*crtc
)
370 return state
->crtcs
[drm_crtc_index(crtc
)].state
;
374 * drm_atomic_get_old_crtc_state - get old crtc state, if it exists
375 * @state: global atomic state object
376 * @crtc: crtc to grab
378 * This function returns the old crtc state for the given crtc, or
379 * NULL if the crtc is not part of the global atomic state.
381 static inline struct drm_crtc_state
*
382 drm_atomic_get_old_crtc_state(struct drm_atomic_state
*state
,
383 struct drm_crtc
*crtc
)
385 return state
->crtcs
[drm_crtc_index(crtc
)].old_state
;
388 * drm_atomic_get_new_crtc_state - get new crtc state, if it exists
389 * @state: global atomic state object
390 * @crtc: crtc to grab
392 * This function returns the new crtc state for the given crtc, or
393 * NULL if the crtc is not part of the global atomic state.
395 static inline struct drm_crtc_state
*
396 drm_atomic_get_new_crtc_state(struct drm_atomic_state
*state
,
397 struct drm_crtc
*crtc
)
399 return state
->crtcs
[drm_crtc_index(crtc
)].new_state
;
403 * drm_atomic_get_existing_plane_state - get plane state, if it exists
404 * @state: global atomic state object
405 * @plane: plane to grab
407 * This function returns the plane state for the given plane, or NULL
408 * if the plane is not part of the global atomic state.
410 * This function is deprecated, @drm_atomic_get_old_plane_state or
411 * @drm_atomic_get_new_plane_state should be used instead.
413 static inline struct drm_plane_state
*
414 drm_atomic_get_existing_plane_state(struct drm_atomic_state
*state
,
415 struct drm_plane
*plane
)
417 return state
->planes
[drm_plane_index(plane
)].state
;
421 * drm_atomic_get_old_plane_state - get plane state, if it exists
422 * @state: global atomic state object
423 * @plane: plane to grab
425 * This function returns the old plane state for the given plane, or
426 * NULL if the plane is not part of the global atomic state.
428 static inline struct drm_plane_state
*
429 drm_atomic_get_old_plane_state(struct drm_atomic_state
*state
,
430 struct drm_plane
*plane
)
432 return state
->planes
[drm_plane_index(plane
)].old_state
;
436 * drm_atomic_get_new_plane_state - get plane state, if it exists
437 * @state: global atomic state object
438 * @plane: plane to grab
440 * This function returns the new plane state for the given plane, or
441 * NULL if the plane is not part of the global atomic state.
443 static inline struct drm_plane_state
*
444 drm_atomic_get_new_plane_state(struct drm_atomic_state
*state
,
445 struct drm_plane
*plane
)
447 return state
->planes
[drm_plane_index(plane
)].new_state
;
451 * drm_atomic_get_existing_connector_state - get connector state, if it exists
452 * @state: global atomic state object
453 * @connector: connector to grab
455 * This function returns the connector state for the given connector,
456 * or NULL if the connector is not part of the global atomic state.
458 * This function is deprecated, @drm_atomic_get_old_connector_state or
459 * @drm_atomic_get_new_connector_state should be used instead.
461 static inline struct drm_connector_state
*
462 drm_atomic_get_existing_connector_state(struct drm_atomic_state
*state
,
463 struct drm_connector
*connector
)
465 int index
= drm_connector_index(connector
);
467 if (index
>= state
->num_connector
)
470 return state
->connectors
[index
].state
;
474 * drm_atomic_get_old_connector_state - get connector state, if it exists
475 * @state: global atomic state object
476 * @connector: connector to grab
478 * This function returns the old connector state for the given connector,
479 * or NULL if the connector is not part of the global atomic state.
481 static inline struct drm_connector_state
*
482 drm_atomic_get_old_connector_state(struct drm_atomic_state
*state
,
483 struct drm_connector
*connector
)
485 int index
= drm_connector_index(connector
);
487 if (index
>= state
->num_connector
)
490 return state
->connectors
[index
].old_state
;
494 * drm_atomic_get_new_connector_state - get connector state, if it exists
495 * @state: global atomic state object
496 * @connector: connector to grab
498 * This function returns the new connector state for the given connector,
499 * or NULL if the connector is not part of the global atomic state.
501 static inline struct drm_connector_state
*
502 drm_atomic_get_new_connector_state(struct drm_atomic_state
*state
,
503 struct drm_connector
*connector
)
505 int index
= drm_connector_index(connector
);
507 if (index
>= state
->num_connector
)
510 return state
->connectors
[index
].new_state
;
514 * __drm_atomic_get_current_plane_state - get current plane state
515 * @state: global atomic state object
516 * @plane: plane to grab
518 * This function returns the plane state for the given plane, either from
519 * @state, or if the plane isn't part of the atomic state update, from @plane.
520 * This is useful in atomic check callbacks, when drivers need to peek at, but
521 * not change, state of other planes, since it avoids threading an error code
522 * back up the call chain.
526 * Note that this function is in general unsafe since it doesn't check for the
527 * required locking for access state structures. Drivers must ensure that it is
528 * safe to access the returned state structure through other means. One common
529 * example is when planes are fixed to a single CRTC, and the driver knows that
530 * the CRTC lock is held already. In that case holding the CRTC lock gives a
531 * read-lock on all planes connected to that CRTC. But if planes can be
532 * reassigned things get more tricky. In that case it's better to use
533 * drm_atomic_get_plane_state and wire up full error handling.
537 * Read-only pointer to the current plane state.
539 static inline const struct drm_plane_state
*
540 __drm_atomic_get_current_plane_state(struct drm_atomic_state
*state
,
541 struct drm_plane
*plane
)
543 if (state
->planes
[drm_plane_index(plane
)].state
)
544 return state
->planes
[drm_plane_index(plane
)].state
;
550 drm_atomic_set_mode_for_crtc(struct drm_crtc_state
*state
,
551 const struct drm_display_mode
*mode
);
553 drm_atomic_set_mode_prop_for_crtc(struct drm_crtc_state
*state
,
554 struct drm_property_blob
*blob
);
556 drm_atomic_set_crtc_for_plane(struct drm_plane_state
*plane_state
,
557 struct drm_crtc
*crtc
);
558 void drm_atomic_set_fb_for_plane(struct drm_plane_state
*plane_state
,
559 struct drm_framebuffer
*fb
);
560 void drm_atomic_set_fence_for_plane(struct drm_plane_state
*plane_state
,
561 struct dma_fence
*fence
);
563 drm_atomic_set_crtc_for_connector(struct drm_connector_state
*conn_state
,
564 struct drm_crtc
*crtc
);
566 drm_atomic_add_affected_connectors(struct drm_atomic_state
*state
,
567 struct drm_crtc
*crtc
);
569 drm_atomic_add_affected_planes(struct drm_atomic_state
*state
,
570 struct drm_crtc
*crtc
);
573 drm_atomic_clean_old_fb(struct drm_device
*dev
, unsigned plane_mask
, int ret
);
575 int __must_check
drm_atomic_check_only(struct drm_atomic_state
*state
);
576 int __must_check
drm_atomic_commit(struct drm_atomic_state
*state
);
577 int __must_check
drm_atomic_nonblocking_commit(struct drm_atomic_state
*state
);
579 void drm_state_dump(struct drm_device
*dev
, struct drm_printer
*p
);
582 * for_each_oldnew_connector_in_state - iterate over all connectors in an atomic update
583 * @__state: &struct drm_atomic_state pointer
584 * @connector: &struct drm_connector iteration cursor
585 * @old_connector_state: &struct drm_connector_state iteration cursor for the
587 * @new_connector_state: &struct drm_connector_state iteration cursor for the
589 * @__i: int iteration cursor, for macro-internal use
591 * This iterates over all connectors in an atomic update, tracking both old and
592 * new state. This is useful in places where the state delta needs to be
593 * considered, for example in atomic check functions.
595 #define for_each_oldnew_connector_in_state(__state, connector, old_connector_state, new_connector_state, __i) \
597 (__i) < (__state)->num_connector; \
599 for_each_if ((__state)->connectors[__i].ptr && \
600 ((connector) = (__state)->connectors[__i].ptr, \
601 (old_connector_state) = (__state)->connectors[__i].old_state, \
602 (new_connector_state) = (__state)->connectors[__i].new_state, 1))
605 * for_each_old_connector_in_state - iterate over all connectors in an atomic update
606 * @__state: &struct drm_atomic_state pointer
607 * @connector: &struct drm_connector iteration cursor
608 * @old_connector_state: &struct drm_connector_state iteration cursor for the
610 * @__i: int iteration cursor, for macro-internal use
612 * This iterates over all connectors in an atomic update, tracking only the old
613 * state. This is useful in disable functions, where we need the old state the
614 * hardware is still in.
616 #define for_each_old_connector_in_state(__state, connector, old_connector_state, __i) \
618 (__i) < (__state)->num_connector; \
620 for_each_if ((__state)->connectors[__i].ptr && \
621 ((connector) = (__state)->connectors[__i].ptr, \
622 (old_connector_state) = (__state)->connectors[__i].old_state, 1))
625 * for_each_new_connector_in_state - iterate over all connectors in an atomic update
626 * @__state: &struct drm_atomic_state pointer
627 * @connector: &struct drm_connector iteration cursor
628 * @new_connector_state: &struct drm_connector_state iteration cursor for the
630 * @__i: int iteration cursor, for macro-internal use
632 * This iterates over all connectors in an atomic update, tracking only the new
633 * state. This is useful in enable functions, where we need the new state the
634 * hardware should be in when the atomic commit operation has completed.
636 #define for_each_new_connector_in_state(__state, connector, new_connector_state, __i) \
638 (__i) < (__state)->num_connector; \
640 for_each_if ((__state)->connectors[__i].ptr && \
641 ((connector) = (__state)->connectors[__i].ptr, \
642 (new_connector_state) = (__state)->connectors[__i].new_state, 1))
645 * for_each_oldnew_crtc_in_state - iterate over all CRTCs in an atomic update
646 * @__state: &struct drm_atomic_state pointer
647 * @crtc: &struct drm_crtc iteration cursor
648 * @old_crtc_state: &struct drm_crtc_state iteration cursor for the old state
649 * @new_crtc_state: &struct drm_crtc_state iteration cursor for the new state
650 * @__i: int iteration cursor, for macro-internal use
652 * This iterates over all CRTCs in an atomic update, tracking both old and
653 * new state. This is useful in places where the state delta needs to be
654 * considered, for example in atomic check functions.
656 #define for_each_oldnew_crtc_in_state(__state, crtc, old_crtc_state, new_crtc_state, __i) \
658 (__i) < (__state)->dev->mode_config.num_crtc; \
660 for_each_if ((__state)->crtcs[__i].ptr && \
661 ((crtc) = (__state)->crtcs[__i].ptr, \
662 (old_crtc_state) = (__state)->crtcs[__i].old_state, \
663 (new_crtc_state) = (__state)->crtcs[__i].new_state, 1))
666 * for_each_old_crtc_in_state - iterate over all CRTCs in an atomic update
667 * @__state: &struct drm_atomic_state pointer
668 * @crtc: &struct drm_crtc iteration cursor
669 * @old_crtc_state: &struct drm_crtc_state iteration cursor for the old state
670 * @__i: int iteration cursor, for macro-internal use
672 * This iterates over all CRTCs in an atomic update, tracking only the old
673 * state. This is useful in disable functions, where we need the old state the
674 * hardware is still in.
676 #define for_each_old_crtc_in_state(__state, crtc, old_crtc_state, __i) \
678 (__i) < (__state)->dev->mode_config.num_crtc; \
680 for_each_if ((__state)->crtcs[__i].ptr && \
681 ((crtc) = (__state)->crtcs[__i].ptr, \
682 (old_crtc_state) = (__state)->crtcs[__i].old_state, 1))
685 * for_each_new_crtc_in_state - iterate over all CRTCs in an atomic update
686 * @__state: &struct drm_atomic_state pointer
687 * @crtc: &struct drm_crtc iteration cursor
688 * @new_crtc_state: &struct drm_crtc_state iteration cursor for the new state
689 * @__i: int iteration cursor, for macro-internal use
691 * This iterates over all CRTCs in an atomic update, tracking only the new
692 * state. This is useful in enable functions, where we need the new state the
693 * hardware should be in when the atomic commit operation has completed.
695 #define for_each_new_crtc_in_state(__state, crtc, new_crtc_state, __i) \
697 (__i) < (__state)->dev->mode_config.num_crtc; \
699 for_each_if ((__state)->crtcs[__i].ptr && \
700 ((crtc) = (__state)->crtcs[__i].ptr, \
701 (new_crtc_state) = (__state)->crtcs[__i].new_state, 1))
704 * for_each_oldnew_plane_in_state - iterate over all planes in an atomic update
705 * @__state: &struct drm_atomic_state pointer
706 * @plane: &struct drm_plane iteration cursor
707 * @old_plane_state: &struct drm_plane_state iteration cursor for the old state
708 * @new_plane_state: &struct drm_plane_state iteration cursor for the new state
709 * @__i: int iteration cursor, for macro-internal use
711 * This iterates over all planes in an atomic update, tracking both old and
712 * new state. This is useful in places where the state delta needs to be
713 * considered, for example in atomic check functions.
715 #define for_each_oldnew_plane_in_state(__state, plane, old_plane_state, new_plane_state, __i) \
717 (__i) < (__state)->dev->mode_config.num_total_plane; \
719 for_each_if ((__state)->planes[__i].ptr && \
720 ((plane) = (__state)->planes[__i].ptr, \
721 (old_plane_state) = (__state)->planes[__i].old_state,\
722 (new_plane_state) = (__state)->planes[__i].new_state, 1))
725 * for_each_old_plane_in_state - iterate over all planes in an atomic update
726 * @__state: &struct drm_atomic_state pointer
727 * @plane: &struct drm_plane iteration cursor
728 * @old_plane_state: &struct drm_plane_state iteration cursor for the old state
729 * @__i: int iteration cursor, for macro-internal use
731 * This iterates over all planes in an atomic update, tracking only the old
732 * state. This is useful in disable functions, where we need the old state the
733 * hardware is still in.
735 #define for_each_old_plane_in_state(__state, plane, old_plane_state, __i) \
737 (__i) < (__state)->dev->mode_config.num_total_plane; \
739 for_each_if ((__state)->planes[__i].ptr && \
740 ((plane) = (__state)->planes[__i].ptr, \
741 (old_plane_state) = (__state)->planes[__i].old_state, 1))
743 * for_each_new_plane_in_state - iterate over all planes in an atomic update
744 * @__state: &struct drm_atomic_state pointer
745 * @plane: &struct drm_plane iteration cursor
746 * @new_plane_state: &struct drm_plane_state iteration cursor for the new state
747 * @__i: int iteration cursor, for macro-internal use
749 * This iterates over all planes in an atomic update, tracking only the new
750 * state. This is useful in enable functions, where we need the new state the
751 * hardware should be in when the atomic commit operation has completed.
753 #define for_each_new_plane_in_state(__state, plane, new_plane_state, __i) \
755 (__i) < (__state)->dev->mode_config.num_total_plane; \
757 for_each_if ((__state)->planes[__i].ptr && \
758 ((plane) = (__state)->planes[__i].ptr, \
759 (new_plane_state) = (__state)->planes[__i].new_state, 1))
762 * for_each_oldnew_private_obj_in_state - iterate over all private objects in an atomic update
763 * @__state: &struct drm_atomic_state pointer
764 * @obj: &struct drm_private_obj iteration cursor
765 * @old_obj_state: &struct drm_private_state iteration cursor for the old state
766 * @new_obj_state: &struct drm_private_state iteration cursor for the new state
767 * @__i: int iteration cursor, for macro-internal use
769 * This iterates over all private objects in an atomic update, tracking both
770 * old and new state. This is useful in places where the state delta needs
771 * to be considered, for example in atomic check functions.
773 #define for_each_oldnew_private_obj_in_state(__state, obj, old_obj_state, new_obj_state, __i) \
775 (__i) < (__state)->num_private_objs && \
776 ((obj) = (__state)->private_objs[__i].ptr, \
777 (old_obj_state) = (__state)->private_objs[__i].old_state, \
778 (new_obj_state) = (__state)->private_objs[__i].new_state, 1); \
782 * for_each_old_private_obj_in_state - iterate over all private objects in an atomic update
783 * @__state: &struct drm_atomic_state pointer
784 * @obj: &struct drm_private_obj iteration cursor
785 * @old_obj_state: &struct drm_private_state iteration cursor for the old state
786 * @__i: int iteration cursor, for macro-internal use
788 * This iterates over all private objects in an atomic update, tracking only
789 * the old state. This is useful in disable functions, where we need the old
790 * state the hardware is still in.
792 #define for_each_old_private_obj_in_state(__state, obj, old_obj_state, __i) \
794 (__i) < (__state)->num_private_objs && \
795 ((obj) = (__state)->private_objs[__i].ptr, \
796 (old_obj_state) = (__state)->private_objs[__i].old_state, 1); \
800 * for_each_new_private_obj_in_state - iterate over all private objects in an atomic update
801 * @__state: &struct drm_atomic_state pointer
802 * @obj: &struct drm_private_obj iteration cursor
803 * @new_obj_state: &struct drm_private_state iteration cursor for the new state
804 * @__i: int iteration cursor, for macro-internal use
806 * This iterates over all private objects in an atomic update, tracking only
807 * the new state. This is useful in enable functions, where we need the new state the
808 * hardware should be in when the atomic commit operation has completed.
810 #define for_each_new_private_obj_in_state(__state, obj, new_obj_state, __i) \
812 (__i) < (__state)->num_private_objs && \
813 ((obj) = (__state)->private_objs[__i].ptr, \
814 (new_obj_state) = (__state)->private_objs[__i].new_state, 1); \
818 * drm_atomic_crtc_needs_modeset - compute combined modeset need
819 * @state: &drm_crtc_state for the CRTC
821 * To give drivers flexibility &struct drm_crtc_state has 3 booleans to track
822 * whether the state CRTC changed enough to need a full modeset cycle:
823 * mode_changed, active_changed and connectors_changed. This helper simply
824 * combines these three to compute the overall need for a modeset for @state.
826 * The atomic helper code sets these booleans, but drivers can and should
827 * change them appropriately to accurately represent whether a modeset is
828 * really needed. In general, drivers should avoid full modesets whenever
831 * For example if the CRTC mode has changed, and the hardware is able to enact
832 * the requested mode change without going through a full modeset, the driver
833 * should clear mode_changed in its &drm_mode_config_funcs.atomic_check
837 drm_atomic_crtc_needs_modeset(const struct drm_crtc_state
*state
)
839 return state
->mode_changed
|| state
->active_changed
||
840 state
->connectors_changed
;
843 #endif /* DRM_ATOMIC_H_ */