]>
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
;
160 * A reference to the CRTC commit object that is kept for use by
161 * drm_atomic_helper_wait_for_flip_done() after
162 * drm_atomic_helper_commit_hw_done() is called. This ensures that a
163 * concurrent commit won't free a commit object that is still in use.
165 struct drm_crtc_commit
*commit
;
167 s32 __user
*out_fence_ptr
;
168 unsigned last_vblank_count
;
171 struct __drm_connnectors_state
{
172 struct drm_connector
*ptr
;
173 struct drm_connector_state
*state
, *old_state
, *new_state
;
176 struct drm_private_obj
;
177 struct drm_private_state
;
180 * struct drm_private_state_funcs - atomic state functions for private objects
182 * These hooks are used by atomic helpers to create, swap and destroy states of
183 * private objects. The structure itself is used as a vtable to identify the
184 * associated private object type. Each private object type that needs to be
185 * added to the atomic states is expected to have an implementation of these
186 * hooks and pass a pointer to it's drm_private_state_funcs struct to
187 * drm_atomic_get_private_obj_state().
189 struct drm_private_state_funcs
{
191 * @atomic_duplicate_state:
193 * Duplicate the current state of the private object and return it. It
194 * is an error to call this before obj->state has been initialized.
198 * Duplicated atomic state or NULL when obj->state is not
199 * initialized or allocation failed.
201 struct drm_private_state
*(*atomic_duplicate_state
)(struct drm_private_obj
*obj
);
204 * @atomic_destroy_state:
206 * Frees the private object state created with @atomic_duplicate_state.
208 void (*atomic_destroy_state
)(struct drm_private_obj
*obj
,
209 struct drm_private_state
*state
);
212 struct drm_private_obj
{
213 struct drm_private_state
*state
;
215 const struct drm_private_state_funcs
*funcs
;
218 struct drm_private_state
{
219 struct drm_atomic_state
*state
;
222 struct __drm_private_objs_state
{
223 struct drm_private_obj
*ptr
;
224 struct drm_private_state
*state
, *old_state
, *new_state
;
228 * struct drm_atomic_state - the global state object for atomic updates
229 * @ref: count of all references to this state (will not be freed until zero)
230 * @dev: parent DRM device
231 * @allow_modeset: allow full modeset
232 * @legacy_cursor_update: hint to enforce legacy cursor IOCTL semantics
233 * @async_update: hint for asynchronous plane update
234 * @planes: pointer to array of structures with per-plane data
235 * @crtcs: pointer to array of CRTC pointers
236 * @num_connector: size of the @connectors and @connector_states arrays
237 * @connectors: pointer to array of structures with per-connector data
238 * @num_private_objs: size of the @private_objs array
239 * @private_objs: pointer to array of private object pointers
240 * @acquire_ctx: acquire context for this atomic modeset state update
242 struct drm_atomic_state
{
245 struct drm_device
*dev
;
246 bool allow_modeset
: 1;
247 bool legacy_cursor_update
: 1;
248 bool async_update
: 1;
249 struct __drm_planes_state
*planes
;
250 struct __drm_crtcs_state
*crtcs
;
252 struct __drm_connnectors_state
*connectors
;
253 int num_private_objs
;
254 struct __drm_private_objs_state
*private_objs
;
256 struct drm_modeset_acquire_ctx
*acquire_ctx
;
261 * Used for signaling unbound planes/connectors.
262 * When a connector or plane is not bound to any CRTC, it's still important
263 * to preserve linearity to prevent the atomic states from being freed to early.
265 * This commit (if set) is not bound to any crtc, but will be completed when
266 * drm_atomic_helper_commit_hw_done() is called.
268 struct drm_crtc_commit
*fake_commit
;
273 * Work item which can be used by the driver or helpers to execute the
274 * commit without blocking.
276 struct work_struct commit_work
;
279 void __drm_crtc_commit_free(struct kref
*kref
);
282 * drm_crtc_commit_get - acquire a reference to the CRTC commit
283 * @commit: CRTC commit
285 * Increases the reference of @commit.
288 * The pointer to @commit, with reference increased.
290 static inline struct drm_crtc_commit
*drm_crtc_commit_get(struct drm_crtc_commit
*commit
)
292 kref_get(&commit
->ref
);
297 * drm_crtc_commit_put - release a reference to the CRTC commmit
298 * @commit: CRTC commit
300 * This releases a reference to @commit which is freed after removing the
301 * final reference. No locking required and callable from any context.
303 static inline void drm_crtc_commit_put(struct drm_crtc_commit
*commit
)
305 kref_put(&commit
->ref
, __drm_crtc_commit_free
);
308 struct drm_atomic_state
* __must_check
309 drm_atomic_state_alloc(struct drm_device
*dev
);
310 void drm_atomic_state_clear(struct drm_atomic_state
*state
);
313 * drm_atomic_state_get - acquire a reference to the atomic state
314 * @state: The atomic state
316 * Returns a new reference to the @state
318 static inline struct drm_atomic_state
*
319 drm_atomic_state_get(struct drm_atomic_state
*state
)
321 kref_get(&state
->ref
);
325 void __drm_atomic_state_free(struct kref
*ref
);
328 * drm_atomic_state_put - release a reference to the atomic state
329 * @state: The atomic state
331 * This releases a reference to @state which is freed after removing the
332 * final reference. No locking required and callable from any context.
334 static inline void drm_atomic_state_put(struct drm_atomic_state
*state
)
336 kref_put(&state
->ref
, __drm_atomic_state_free
);
340 drm_atomic_state_init(struct drm_device
*dev
, struct drm_atomic_state
*state
);
341 void drm_atomic_state_default_clear(struct drm_atomic_state
*state
);
342 void drm_atomic_state_default_release(struct drm_atomic_state
*state
);
344 struct drm_crtc_state
* __must_check
345 drm_atomic_get_crtc_state(struct drm_atomic_state
*state
,
346 struct drm_crtc
*crtc
);
347 int drm_atomic_crtc_set_property(struct drm_crtc
*crtc
,
348 struct drm_crtc_state
*state
, struct drm_property
*property
,
350 struct drm_plane_state
* __must_check
351 drm_atomic_get_plane_state(struct drm_atomic_state
*state
,
352 struct drm_plane
*plane
);
353 struct drm_connector_state
* __must_check
354 drm_atomic_get_connector_state(struct drm_atomic_state
*state
,
355 struct drm_connector
*connector
);
357 void drm_atomic_private_obj_init(struct drm_private_obj
*obj
,
358 struct drm_private_state
*state
,
359 const struct drm_private_state_funcs
*funcs
);
360 void drm_atomic_private_obj_fini(struct drm_private_obj
*obj
);
362 struct drm_private_state
* __must_check
363 drm_atomic_get_private_obj_state(struct drm_atomic_state
*state
,
364 struct drm_private_obj
*obj
);
367 * drm_atomic_get_existing_crtc_state - get crtc state, if it exists
368 * @state: global atomic state object
369 * @crtc: crtc to grab
371 * This function returns the crtc state for the given crtc, or NULL
372 * if the crtc is not part of the global atomic state.
374 * This function is deprecated, @drm_atomic_get_old_crtc_state or
375 * @drm_atomic_get_new_crtc_state should be used instead.
377 static inline struct drm_crtc_state
*
378 drm_atomic_get_existing_crtc_state(struct drm_atomic_state
*state
,
379 struct drm_crtc
*crtc
)
381 return state
->crtcs
[drm_crtc_index(crtc
)].state
;
385 * drm_atomic_get_old_crtc_state - get old crtc state, if it exists
386 * @state: global atomic state object
387 * @crtc: crtc to grab
389 * This function returns the old crtc state for the given crtc, or
390 * NULL if the crtc is not part of the global atomic state.
392 static inline struct drm_crtc_state
*
393 drm_atomic_get_old_crtc_state(struct drm_atomic_state
*state
,
394 struct drm_crtc
*crtc
)
396 return state
->crtcs
[drm_crtc_index(crtc
)].old_state
;
399 * drm_atomic_get_new_crtc_state - get new crtc state, if it exists
400 * @state: global atomic state object
401 * @crtc: crtc to grab
403 * This function returns the new crtc state for the given crtc, or
404 * NULL if the crtc is not part of the global atomic state.
406 static inline struct drm_crtc_state
*
407 drm_atomic_get_new_crtc_state(struct drm_atomic_state
*state
,
408 struct drm_crtc
*crtc
)
410 return state
->crtcs
[drm_crtc_index(crtc
)].new_state
;
414 * drm_atomic_get_existing_plane_state - get plane state, if it exists
415 * @state: global atomic state object
416 * @plane: plane to grab
418 * This function returns the plane state for the given plane, or NULL
419 * if the plane is not part of the global atomic state.
421 * This function is deprecated, @drm_atomic_get_old_plane_state or
422 * @drm_atomic_get_new_plane_state should be used instead.
424 static inline struct drm_plane_state
*
425 drm_atomic_get_existing_plane_state(struct drm_atomic_state
*state
,
426 struct drm_plane
*plane
)
428 return state
->planes
[drm_plane_index(plane
)].state
;
432 * drm_atomic_get_old_plane_state - get plane state, if it exists
433 * @state: global atomic state object
434 * @plane: plane to grab
436 * This function returns the old plane state for the given plane, or
437 * NULL if the plane is not part of the global atomic state.
439 static inline struct drm_plane_state
*
440 drm_atomic_get_old_plane_state(struct drm_atomic_state
*state
,
441 struct drm_plane
*plane
)
443 return state
->planes
[drm_plane_index(plane
)].old_state
;
447 * drm_atomic_get_new_plane_state - get plane state, if it exists
448 * @state: global atomic state object
449 * @plane: plane to grab
451 * This function returns the new plane state for the given plane, or
452 * NULL if the plane is not part of the global atomic state.
454 static inline struct drm_plane_state
*
455 drm_atomic_get_new_plane_state(struct drm_atomic_state
*state
,
456 struct drm_plane
*plane
)
458 return state
->planes
[drm_plane_index(plane
)].new_state
;
462 * drm_atomic_get_existing_connector_state - get connector state, if it exists
463 * @state: global atomic state object
464 * @connector: connector to grab
466 * This function returns the connector state for the given connector,
467 * or NULL if the connector is not part of the global atomic state.
469 * This function is deprecated, @drm_atomic_get_old_connector_state or
470 * @drm_atomic_get_new_connector_state should be used instead.
472 static inline struct drm_connector_state
*
473 drm_atomic_get_existing_connector_state(struct drm_atomic_state
*state
,
474 struct drm_connector
*connector
)
476 int index
= drm_connector_index(connector
);
478 if (index
>= state
->num_connector
)
481 return state
->connectors
[index
].state
;
485 * drm_atomic_get_old_connector_state - get connector state, if it exists
486 * @state: global atomic state object
487 * @connector: connector to grab
489 * This function returns the old connector state for the given connector,
490 * or NULL if the connector is not part of the global atomic state.
492 static inline struct drm_connector_state
*
493 drm_atomic_get_old_connector_state(struct drm_atomic_state
*state
,
494 struct drm_connector
*connector
)
496 int index
= drm_connector_index(connector
);
498 if (index
>= state
->num_connector
)
501 return state
->connectors
[index
].old_state
;
505 * drm_atomic_get_new_connector_state - get connector state, if it exists
506 * @state: global atomic state object
507 * @connector: connector to grab
509 * This function returns the new connector state for the given connector,
510 * or NULL if the connector is not part of the global atomic state.
512 static inline struct drm_connector_state
*
513 drm_atomic_get_new_connector_state(struct drm_atomic_state
*state
,
514 struct drm_connector
*connector
)
516 int index
= drm_connector_index(connector
);
518 if (index
>= state
->num_connector
)
521 return state
->connectors
[index
].new_state
;
525 * __drm_atomic_get_current_plane_state - get current plane state
526 * @state: global atomic state object
527 * @plane: plane to grab
529 * This function returns the plane state for the given plane, either from
530 * @state, or if the plane isn't part of the atomic state update, from @plane.
531 * This is useful in atomic check callbacks, when drivers need to peek at, but
532 * not change, state of other planes, since it avoids threading an error code
533 * back up the call chain.
537 * Note that this function is in general unsafe since it doesn't check for the
538 * required locking for access state structures. Drivers must ensure that it is
539 * safe to access the returned state structure through other means. One common
540 * example is when planes are fixed to a single CRTC, and the driver knows that
541 * the CRTC lock is held already. In that case holding the CRTC lock gives a
542 * read-lock on all planes connected to that CRTC. But if planes can be
543 * reassigned things get more tricky. In that case it's better to use
544 * drm_atomic_get_plane_state and wire up full error handling.
548 * Read-only pointer to the current plane state.
550 static inline const struct drm_plane_state
*
551 __drm_atomic_get_current_plane_state(struct drm_atomic_state
*state
,
552 struct drm_plane
*plane
)
554 if (state
->planes
[drm_plane_index(plane
)].state
)
555 return state
->planes
[drm_plane_index(plane
)].state
;
561 drm_atomic_set_mode_for_crtc(struct drm_crtc_state
*state
,
562 const struct drm_display_mode
*mode
);
564 drm_atomic_set_mode_prop_for_crtc(struct drm_crtc_state
*state
,
565 struct drm_property_blob
*blob
);
567 drm_atomic_set_crtc_for_plane(struct drm_plane_state
*plane_state
,
568 struct drm_crtc
*crtc
);
569 void drm_atomic_set_fb_for_plane(struct drm_plane_state
*plane_state
,
570 struct drm_framebuffer
*fb
);
571 void drm_atomic_set_fence_for_plane(struct drm_plane_state
*plane_state
,
572 struct dma_fence
*fence
);
574 drm_atomic_set_crtc_for_connector(struct drm_connector_state
*conn_state
,
575 struct drm_crtc
*crtc
);
577 drm_atomic_add_affected_connectors(struct drm_atomic_state
*state
,
578 struct drm_crtc
*crtc
);
580 drm_atomic_add_affected_planes(struct drm_atomic_state
*state
,
581 struct drm_crtc
*crtc
);
584 drm_atomic_clean_old_fb(struct drm_device
*dev
, unsigned plane_mask
, int ret
);
586 int __must_check
drm_atomic_check_only(struct drm_atomic_state
*state
);
587 int __must_check
drm_atomic_commit(struct drm_atomic_state
*state
);
588 int __must_check
drm_atomic_nonblocking_commit(struct drm_atomic_state
*state
);
590 void drm_state_dump(struct drm_device
*dev
, struct drm_printer
*p
);
593 * for_each_oldnew_connector_in_state - iterate over all connectors in an atomic update
594 * @__state: &struct drm_atomic_state pointer
595 * @connector: &struct drm_connector iteration cursor
596 * @old_connector_state: &struct drm_connector_state iteration cursor for the
598 * @new_connector_state: &struct drm_connector_state iteration cursor for the
600 * @__i: int iteration cursor, for macro-internal use
602 * This iterates over all connectors in an atomic update, tracking both old and
603 * new state. This is useful in places where the state delta needs to be
604 * considered, for example in atomic check functions.
606 #define for_each_oldnew_connector_in_state(__state, connector, old_connector_state, new_connector_state, __i) \
608 (__i) < (__state)->num_connector; \
610 for_each_if ((__state)->connectors[__i].ptr && \
611 ((connector) = (__state)->connectors[__i].ptr, \
612 (old_connector_state) = (__state)->connectors[__i].old_state, \
613 (new_connector_state) = (__state)->connectors[__i].new_state, 1))
616 * for_each_old_connector_in_state - iterate over all connectors in an atomic update
617 * @__state: &struct drm_atomic_state pointer
618 * @connector: &struct drm_connector iteration cursor
619 * @old_connector_state: &struct drm_connector_state iteration cursor for the
621 * @__i: int iteration cursor, for macro-internal use
623 * This iterates over all connectors in an atomic update, tracking only the old
624 * state. This is useful in disable functions, where we need the old state the
625 * hardware is still in.
627 #define for_each_old_connector_in_state(__state, connector, old_connector_state, __i) \
629 (__i) < (__state)->num_connector; \
631 for_each_if ((__state)->connectors[__i].ptr && \
632 ((connector) = (__state)->connectors[__i].ptr, \
633 (old_connector_state) = (__state)->connectors[__i].old_state, 1))
636 * for_each_new_connector_in_state - iterate over all connectors in an atomic update
637 * @__state: &struct drm_atomic_state pointer
638 * @connector: &struct drm_connector iteration cursor
639 * @new_connector_state: &struct drm_connector_state iteration cursor for the
641 * @__i: int iteration cursor, for macro-internal use
643 * This iterates over all connectors in an atomic update, tracking only the new
644 * state. This is useful in enable functions, where we need the new state the
645 * hardware should be in when the atomic commit operation has completed.
647 #define for_each_new_connector_in_state(__state, connector, new_connector_state, __i) \
649 (__i) < (__state)->num_connector; \
651 for_each_if ((__state)->connectors[__i].ptr && \
652 ((connector) = (__state)->connectors[__i].ptr, \
653 (new_connector_state) = (__state)->connectors[__i].new_state, 1))
656 * for_each_oldnew_crtc_in_state - iterate over all CRTCs in an atomic update
657 * @__state: &struct drm_atomic_state pointer
658 * @crtc: &struct drm_crtc iteration cursor
659 * @old_crtc_state: &struct drm_crtc_state iteration cursor for the old state
660 * @new_crtc_state: &struct drm_crtc_state iteration cursor for the new state
661 * @__i: int iteration cursor, for macro-internal use
663 * This iterates over all CRTCs in an atomic update, tracking both old and
664 * new state. This is useful in places where the state delta needs to be
665 * considered, for example in atomic check functions.
667 #define for_each_oldnew_crtc_in_state(__state, crtc, old_crtc_state, new_crtc_state, __i) \
669 (__i) < (__state)->dev->mode_config.num_crtc; \
671 for_each_if ((__state)->crtcs[__i].ptr && \
672 ((crtc) = (__state)->crtcs[__i].ptr, \
673 (old_crtc_state) = (__state)->crtcs[__i].old_state, \
674 (new_crtc_state) = (__state)->crtcs[__i].new_state, 1))
677 * for_each_old_crtc_in_state - iterate over all CRTCs in an atomic update
678 * @__state: &struct drm_atomic_state pointer
679 * @crtc: &struct drm_crtc iteration cursor
680 * @old_crtc_state: &struct drm_crtc_state iteration cursor for the old state
681 * @__i: int iteration cursor, for macro-internal use
683 * This iterates over all CRTCs in an atomic update, tracking only the old
684 * state. This is useful in disable functions, where we need the old state the
685 * hardware is still in.
687 #define for_each_old_crtc_in_state(__state, crtc, old_crtc_state, __i) \
689 (__i) < (__state)->dev->mode_config.num_crtc; \
691 for_each_if ((__state)->crtcs[__i].ptr && \
692 ((crtc) = (__state)->crtcs[__i].ptr, \
693 (old_crtc_state) = (__state)->crtcs[__i].old_state, 1))
696 * for_each_new_crtc_in_state - iterate over all CRTCs in an atomic update
697 * @__state: &struct drm_atomic_state pointer
698 * @crtc: &struct drm_crtc iteration cursor
699 * @new_crtc_state: &struct drm_crtc_state iteration cursor for the new state
700 * @__i: int iteration cursor, for macro-internal use
702 * This iterates over all CRTCs in an atomic update, tracking only the new
703 * state. This is useful in enable functions, where we need the new state the
704 * hardware should be in when the atomic commit operation has completed.
706 #define for_each_new_crtc_in_state(__state, crtc, new_crtc_state, __i) \
708 (__i) < (__state)->dev->mode_config.num_crtc; \
710 for_each_if ((__state)->crtcs[__i].ptr && \
711 ((crtc) = (__state)->crtcs[__i].ptr, \
712 (new_crtc_state) = (__state)->crtcs[__i].new_state, 1))
715 * for_each_oldnew_plane_in_state - iterate over all planes in an atomic update
716 * @__state: &struct drm_atomic_state pointer
717 * @plane: &struct drm_plane iteration cursor
718 * @old_plane_state: &struct drm_plane_state iteration cursor for the old state
719 * @new_plane_state: &struct drm_plane_state iteration cursor for the new state
720 * @__i: int iteration cursor, for macro-internal use
722 * This iterates over all planes in an atomic update, tracking both old and
723 * new state. This is useful in places where the state delta needs to be
724 * considered, for example in atomic check functions.
726 #define for_each_oldnew_plane_in_state(__state, plane, old_plane_state, new_plane_state, __i) \
728 (__i) < (__state)->dev->mode_config.num_total_plane; \
730 for_each_if ((__state)->planes[__i].ptr && \
731 ((plane) = (__state)->planes[__i].ptr, \
732 (old_plane_state) = (__state)->planes[__i].old_state,\
733 (new_plane_state) = (__state)->planes[__i].new_state, 1))
736 * for_each_old_plane_in_state - iterate over all planes in an atomic update
737 * @__state: &struct drm_atomic_state pointer
738 * @plane: &struct drm_plane iteration cursor
739 * @old_plane_state: &struct drm_plane_state iteration cursor for the old state
740 * @__i: int iteration cursor, for macro-internal use
742 * This iterates over all planes in an atomic update, tracking only the old
743 * state. This is useful in disable functions, where we need the old state the
744 * hardware is still in.
746 #define for_each_old_plane_in_state(__state, plane, old_plane_state, __i) \
748 (__i) < (__state)->dev->mode_config.num_total_plane; \
750 for_each_if ((__state)->planes[__i].ptr && \
751 ((plane) = (__state)->planes[__i].ptr, \
752 (old_plane_state) = (__state)->planes[__i].old_state, 1))
754 * for_each_new_plane_in_state - iterate over all planes in an atomic update
755 * @__state: &struct drm_atomic_state pointer
756 * @plane: &struct drm_plane iteration cursor
757 * @new_plane_state: &struct drm_plane_state iteration cursor for the new state
758 * @__i: int iteration cursor, for macro-internal use
760 * This iterates over all planes in an atomic update, tracking only the new
761 * state. This is useful in enable functions, where we need the new state the
762 * hardware should be in when the atomic commit operation has completed.
764 #define for_each_new_plane_in_state(__state, plane, new_plane_state, __i) \
766 (__i) < (__state)->dev->mode_config.num_total_plane; \
768 for_each_if ((__state)->planes[__i].ptr && \
769 ((plane) = (__state)->planes[__i].ptr, \
770 (new_plane_state) = (__state)->planes[__i].new_state, 1))
773 * for_each_oldnew_private_obj_in_state - iterate over all private objects in an atomic update
774 * @__state: &struct drm_atomic_state pointer
775 * @obj: &struct drm_private_obj iteration cursor
776 * @old_obj_state: &struct drm_private_state iteration cursor for the old state
777 * @new_obj_state: &struct drm_private_state iteration cursor for the new state
778 * @__i: int iteration cursor, for macro-internal use
780 * This iterates over all private objects in an atomic update, tracking both
781 * old and new state. This is useful in places where the state delta needs
782 * to be considered, for example in atomic check functions.
784 #define for_each_oldnew_private_obj_in_state(__state, obj, old_obj_state, new_obj_state, __i) \
786 (__i) < (__state)->num_private_objs && \
787 ((obj) = (__state)->private_objs[__i].ptr, \
788 (old_obj_state) = (__state)->private_objs[__i].old_state, \
789 (new_obj_state) = (__state)->private_objs[__i].new_state, 1); \
793 * for_each_old_private_obj_in_state - iterate over all private objects in an atomic update
794 * @__state: &struct drm_atomic_state pointer
795 * @obj: &struct drm_private_obj iteration cursor
796 * @old_obj_state: &struct drm_private_state iteration cursor for the old state
797 * @__i: int iteration cursor, for macro-internal use
799 * This iterates over all private objects in an atomic update, tracking only
800 * the old state. This is useful in disable functions, where we need the old
801 * state the hardware is still in.
803 #define for_each_old_private_obj_in_state(__state, obj, old_obj_state, __i) \
805 (__i) < (__state)->num_private_objs && \
806 ((obj) = (__state)->private_objs[__i].ptr, \
807 (old_obj_state) = (__state)->private_objs[__i].old_state, 1); \
811 * for_each_new_private_obj_in_state - iterate over all private objects in an atomic update
812 * @__state: &struct drm_atomic_state pointer
813 * @obj: &struct drm_private_obj iteration cursor
814 * @new_obj_state: &struct drm_private_state iteration cursor for the new state
815 * @__i: int iteration cursor, for macro-internal use
817 * This iterates over all private objects in an atomic update, tracking only
818 * the new state. This is useful in enable functions, where we need the new state the
819 * hardware should be in when the atomic commit operation has completed.
821 #define for_each_new_private_obj_in_state(__state, obj, new_obj_state, __i) \
823 (__i) < (__state)->num_private_objs && \
824 ((obj) = (__state)->private_objs[__i].ptr, \
825 (new_obj_state) = (__state)->private_objs[__i].new_state, 1); \
829 * drm_atomic_crtc_needs_modeset - compute combined modeset need
830 * @state: &drm_crtc_state for the CRTC
832 * To give drivers flexibility &struct drm_crtc_state has 3 booleans to track
833 * whether the state CRTC changed enough to need a full modeset cycle:
834 * mode_changed, active_changed and connectors_changed. This helper simply
835 * combines these three to compute the overall need for a modeset for @state.
837 * The atomic helper code sets these booleans, but drivers can and should
838 * change them appropriately to accurately represent whether a modeset is
839 * really needed. In general, drivers should avoid full modesets whenever
842 * For example if the CRTC mode has changed, and the hardware is able to enact
843 * the requested mode change without going through a full modeset, the driver
844 * should clear mode_changed in its &drm_mode_config_funcs.atomic_check
848 drm_atomic_crtc_needs_modeset(const struct drm_crtc_state
*state
)
850 return state
->mode_changed
|| state
->active_changed
||
851 state
->connectors_changed
;
854 #endif /* DRM_ATOMIC_H_ */