1 /* 2 * Copyright (C) 2014 Red Hat 3 * Copyright (C) 2014 Intel Corp. 4 * 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: 11 * 12 * The above copyright notice and this permission notice shall be included in 13 * all copies or substantial portions of the Software. 14 * 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. 22 * 23 * Authors: 24 * Rob Clark <robdclark@gmail.com> 25 * Daniel Vetter <daniel.vetter@ffwll.ch> 26 */ 27 28 #ifndef DRM_ATOMIC_H_ 29 #define DRM_ATOMIC_H_ 30 31 #include <drm/drm_crtc.h> 32 #include <drm/drm_util.h> 33 34 /** 35 * struct drm_crtc_commit - track modeset commits on a CRTC 36 * 37 * This structure is used to track pending modeset changes and atomic commit on 38 * a per-CRTC basis. Since updating the list should never block, this structure 39 * is reference counted to allow waiters to safely wait on an event to complete, 40 * without holding any locks. 41 * 42 * It has 3 different events in total to allow a fine-grained synchronization 43 * between outstanding updates:: 44 * 45 * atomic commit thread hardware 46 * 47 * write new state into hardware ----> ... 48 * signal hw_done 49 * switch to new state on next 50 * ... v/hblank 51 * 52 * wait for buffers to show up ... 53 * 54 * ... send completion irq 55 * irq handler signals flip_done 56 * cleanup old buffers 57 * 58 * signal cleanup_done 59 * 60 * wait for flip_done <---- 61 * clean up atomic state 62 * 63 * The important bit to know is that &cleanup_done is the terminal event, but the 64 * ordering between &flip_done and &hw_done is entirely up to the specific driver 65 * and modeset state change. 66 * 67 * For an implementation of how to use this look at 68 * drm_atomic_helper_setup_commit() from the atomic helper library. 69 * 70 * See also drm_crtc_commit_wait(). 71 */ 72 struct drm_crtc_commit { 73 /** 74 * @crtc: 75 * 76 * DRM CRTC for this commit. 77 */ 78 struct drm_crtc *crtc; 79 80 /** 81 * @ref: 82 * 83 * Reference count for this structure. Needed to allow blocking on 84 * completions without the risk of the completion disappearing 85 * meanwhile. 86 */ 87 struct kref ref; 88 89 /** 90 * @flip_done: 91 * 92 * Will be signaled when the hardware has flipped to the new set of 93 * buffers. Signals at the same time as when the drm event for this 94 * commit is sent to userspace, or when an out-fence is singalled. Note 95 * that for most hardware, in most cases this happens after @hw_done is 96 * signalled. 97 * 98 * Completion of this stage is signalled implicitly by calling 99 * drm_crtc_send_vblank_event() on &drm_crtc_state.event. 100 */ 101 struct completion flip_done; 102 103 /** 104 * @hw_done: 105 * 106 * Will be signalled when all hw register changes for this commit have 107 * been written out. Especially when disabling a pipe this can be much 108 * later than @flip_done, since that can signal already when the 109 * screen goes black, whereas to fully shut down a pipe more register 110 * I/O is required. 111 * 112 * Note that this does not need to include separately reference-counted 113 * resources like backing storage buffer pinning, or runtime pm 114 * management. 115 * 116 * Drivers should call drm_atomic_helper_commit_hw_done() to signal 117 * completion of this stage. 118 */ 119 struct completion hw_done; 120 121 /** 122 * @cleanup_done: 123 * 124 * Will be signalled after old buffers have been cleaned up by calling 125 * drm_atomic_helper_cleanup_planes(). Since this can only happen after 126 * a vblank wait completed it might be a bit later. This completion is 127 * useful to throttle updates and avoid hardware updates getting ahead 128 * of the buffer cleanup too much. 129 * 130 * Drivers should call drm_atomic_helper_commit_cleanup_done() to signal 131 * completion of this stage. 132 */ 133 struct completion cleanup_done; 134 135 /** 136 * @commit_entry: 137 * 138 * Entry on the per-CRTC &drm_crtc.commit_list. Protected by 139 * $drm_crtc.commit_lock. 140 */ 141 struct list_head commit_entry; 142 143 /** 144 * @event: 145 * 146 * &drm_pending_vblank_event pointer to clean up private events. 147 */ 148 struct drm_pending_vblank_event *event; 149 150 /** 151 * @abort_completion: 152 * 153 * A flag that's set after drm_atomic_helper_setup_commit() takes a 154 * second reference for the completion of $drm_crtc_state.event. It's 155 * used by the free code to remove the second reference if commit fails. 156 */ 157 bool abort_completion; 158 }; 159 160 struct __drm_planes_state { 161 struct drm_plane *ptr; 162 163 /** 164 * @state_to_destroy: 165 * 166 * Used to track the @drm_plane_state we will need to free when 167 * tearing down the associated &drm_atomic_state in 168 * $drm_mode_config_funcs.atomic_state_clear or 169 * drm_atomic_state_default_clear(). 170 * 171 * Before a commit, and the call to 172 * drm_atomic_helper_swap_state() in particular, it points to 173 * the same state than @new_state. After a commit, it points to 174 * the same state than @old_state. 175 */ 176 struct drm_plane_state *state_to_destroy; 177 178 struct drm_plane_state *old_state, *new_state; 179 }; 180 181 struct __drm_crtcs_state { 182 struct drm_crtc *ptr; 183 184 /** 185 * @state_to_destroy: 186 * 187 * Used to track the @drm_crtc_state we will need to free when 188 * tearing down the associated &drm_atomic_state in 189 * $drm_mode_config_funcs.atomic_state_clear or 190 * drm_atomic_state_default_clear(). 191 * 192 * Before a commit, and the call to 193 * drm_atomic_helper_swap_state() in particular, it points to 194 * the same state than @new_state. After a commit, it points to 195 * the same state than @old_state. 196 */ 197 struct drm_crtc_state *state_to_destroy; 198 199 struct drm_crtc_state *old_state, *new_state; 200 201 /** 202 * @commit: 203 * 204 * A reference to the CRTC commit object that is kept for use by 205 * drm_atomic_helper_wait_for_flip_done() after 206 * drm_atomic_helper_commit_hw_done() is called. This ensures that a 207 * concurrent commit won't free a commit object that is still in use. 208 */ 209 struct drm_crtc_commit *commit; 210 211 s32 __user *out_fence_ptr; 212 u64 last_vblank_count; 213 }; 214 215 struct __drm_connnectors_state { 216 struct drm_connector *ptr; 217 218 /** 219 * @state_to_destroy: 220 * 221 * Used to track the @drm_connector_state we will need to free 222 * when tearing down the associated &drm_atomic_state in 223 * $drm_mode_config_funcs.atomic_state_clear or 224 * drm_atomic_state_default_clear(). 225 * 226 * Before a commit, and the call to 227 * drm_atomic_helper_swap_state() in particular, it points to 228 * the same state than @new_state. After a commit, it points to 229 * the same state than @old_state. 230 */ 231 struct drm_connector_state *state_to_destroy; 232 233 struct drm_connector_state *old_state, *new_state; 234 235 /** 236 * @out_fence_ptr: 237 * 238 * User-provided pointer which the kernel uses to return a sync_file 239 * file descriptor. Used by writeback connectors to signal completion of 240 * the writeback. 241 */ 242 s32 __user *out_fence_ptr; 243 }; 244 245 struct drm_private_obj; 246 struct drm_private_state; 247 248 /** 249 * struct drm_private_state_funcs - atomic state functions for private objects 250 * 251 * These hooks are used by atomic helpers to create, swap and destroy states of 252 * private objects. The structure itself is used as a vtable to identify the 253 * associated private object type. Each private object type that needs to be 254 * added to the atomic states is expected to have an implementation of these 255 * hooks and pass a pointer to its drm_private_state_funcs struct to 256 * drm_atomic_get_private_obj_state(). 257 */ 258 struct drm_private_state_funcs { 259 /** 260 * @atomic_duplicate_state: 261 * 262 * Duplicate the current state of the private object and return it. It 263 * is an error to call this before obj->state has been initialized. 264 * 265 * RETURNS: 266 * 267 * Duplicated atomic state or NULL when obj->state is not 268 * initialized or allocation failed. 269 */ 270 struct drm_private_state *(*atomic_duplicate_state)(struct drm_private_obj *obj); 271 272 /** 273 * @atomic_destroy_state: 274 * 275 * Frees the private object state created with @atomic_duplicate_state. 276 */ 277 void (*atomic_destroy_state)(struct drm_private_obj *obj, 278 struct drm_private_state *state); 279 280 /** 281 * @atomic_print_state: 282 * 283 * If driver subclasses &struct drm_private_state, it should implement 284 * this optional hook for printing additional driver specific state. 285 * 286 * Do not call this directly, use drm_atomic_private_obj_print_state() 287 * instead. 288 */ 289 void (*atomic_print_state)(struct drm_printer *p, 290 const struct drm_private_state *state); 291 }; 292 293 /** 294 * struct drm_private_obj - base struct for driver private atomic object 295 * 296 * A driver private object is initialized by calling 297 * drm_atomic_private_obj_init() and cleaned up by calling 298 * drm_atomic_private_obj_fini(). 299 * 300 * Currently only tracks the state update functions and the opaque driver 301 * private state itself, but in the future might also track which 302 * &drm_modeset_lock is required to duplicate and update this object's state. 303 * 304 * All private objects must be initialized before the DRM device they are 305 * attached to is registered to the DRM subsystem (call to drm_dev_register()) 306 * and should stay around until this DRM device is unregistered (call to 307 * drm_dev_unregister()). In other words, private objects lifetime is tied 308 * to the DRM device lifetime. This implies that: 309 * 310 * 1/ all calls to drm_atomic_private_obj_init() must be done before calling 311 * drm_dev_register() 312 * 2/ all calls to drm_atomic_private_obj_fini() must be done after calling 313 * drm_dev_unregister() 314 * 315 * If that private object is used to store a state shared by multiple 316 * CRTCs, proper care must be taken to ensure that non-blocking commits are 317 * properly ordered to avoid a use-after-free issue. 318 * 319 * Indeed, assuming a sequence of two non-blocking &drm_atomic_commit on two 320 * different &drm_crtc using different &drm_plane and &drm_connector, so with no 321 * resources shared, there's no guarantee on which commit is going to happen 322 * first. However, the second &drm_atomic_commit will consider the first 323 * &drm_private_obj its old state, and will be in charge of freeing it whenever 324 * the second &drm_atomic_commit is done. 325 * 326 * If the first &drm_atomic_commit happens after it, it will consider its 327 * &drm_private_obj the new state and will be likely to access it, resulting in 328 * an access to a freed memory region. Drivers should store (and get a reference 329 * to) the &drm_crtc_commit structure in our private state in 330 * &drm_mode_config_helper_funcs.atomic_commit_setup, and then wait for that 331 * commit to complete as the first step of 332 * &drm_mode_config_helper_funcs.atomic_commit_tail, similar to 333 * drm_atomic_helper_wait_for_dependencies(). 334 */ 335 struct drm_private_obj { 336 /** 337 * @head: List entry used to attach a private object to a &drm_device 338 * (queued to &drm_mode_config.privobj_list). 339 */ 340 struct list_head head; 341 342 /** 343 * @lock: Modeset lock to protect the state object. 344 */ 345 struct drm_modeset_lock lock; 346 347 /** 348 * @state: Current atomic state for this driver private object. 349 */ 350 struct drm_private_state *state; 351 352 /** 353 * @funcs: 354 * 355 * Functions to manipulate the state of this driver private object, see 356 * &drm_private_state_funcs. 357 */ 358 const struct drm_private_state_funcs *funcs; 359 }; 360 361 /** 362 * drm_for_each_privobj() - private object iterator 363 * 364 * @privobj: pointer to the current private object. Updated after each 365 * iteration 366 * @dev: the DRM device we want get private objects from 367 * 368 * Allows one to iterate over all private objects attached to @dev 369 */ 370 #define drm_for_each_privobj(privobj, dev) \ 371 list_for_each_entry(privobj, &(dev)->mode_config.privobj_list, head) 372 373 /** 374 * struct drm_private_state - base struct for driver private object state 375 * 376 * Currently only contains a backpointer to the overall atomic update, 377 * and the relevant private object but in the future also might hold 378 * synchronization information similar to e.g. &drm_crtc.commit. 379 */ 380 struct drm_private_state { 381 /** 382 * @state: backpointer to global drm_atomic_state 383 */ 384 struct drm_atomic_state *state; 385 386 /** 387 * @obj: backpointer to the private object 388 */ 389 struct drm_private_obj *obj; 390 }; 391 392 struct __drm_private_objs_state { 393 struct drm_private_obj *ptr; 394 395 /** 396 * @state_to_destroy: 397 * 398 * Used to track the @drm_private_state we will need to free 399 * when tearing down the associated &drm_atomic_state in 400 * $drm_mode_config_funcs.atomic_state_clear or 401 * drm_atomic_state_default_clear(). 402 * 403 * Before a commit, and the call to 404 * drm_atomic_helper_swap_state() in particular, it points to 405 * the same state than @new_state. After a commit, it points to 406 * the same state than @old_state. 407 */ 408 struct drm_private_state *state_to_destroy; 409 410 struct drm_private_state *old_state, *new_state; 411 }; 412 413 /** 414 * struct drm_atomic_state - Atomic commit structure 415 * 416 * This structure is the kernel counterpart of @drm_mode_atomic and represents 417 * an atomic commit that transitions from an old to a new display state. It 418 * contains all the objects affected by the atomic commit and both the new 419 * state structures and pointers to the old state structures for 420 * these. 421 * 422 * States are added to an atomic update by calling drm_atomic_get_crtc_state(), 423 * drm_atomic_get_plane_state(), drm_atomic_get_connector_state(), or for 424 * private state structures, drm_atomic_get_private_obj_state(). 425 * 426 * NOTE: struct drm_atomic_state first started as a single collection of 427 * entities state pointers (drm_plane_state, drm_crtc_state, etc.). 428 * 429 * At atomic_check time, you could get the state about to be committed 430 * from drm_atomic_state, and the one currently running from the 431 * entities state pointer (drm_crtc.state, for example). After the call 432 * to drm_atomic_helper_swap_state(), the entities state pointer would 433 * contain the state previously checked, and the drm_atomic_state 434 * structure the old state. 435 * 436 * Over time, and in order to avoid confusion, drm_atomic_state has 437 * grown to have both the old state (ie, the state we replace) and the 438 * new state (ie, the state we want to apply). Those names are stable 439 * during the commit process, which makes it easier to reason about. 440 * 441 * You can still find some traces of that evolution through some hooks 442 * or callbacks taking a drm_atomic_state parameter called names like 443 * "old_state". This doesn't necessarily mean that the previous 444 * drm_atomic_state is passed, but rather that this used to be the state 445 * collection we were replacing after drm_atomic_helper_swap_state(), 446 * but the variable name was never updated. 447 * 448 * Some atomic operations implementations followed a similar process. We 449 * first started to pass the entity state only. However, it was pretty 450 * cumbersome for drivers, and especially CRTCs, to retrieve the states 451 * of other components. Thus, we switched to passing the whole 452 * drm_atomic_state as a parameter to those operations. Similarly, the 453 * transition isn't complete yet, and one might still find atomic 454 * operations taking a drm_atomic_state pointer, or a component state 455 * pointer. The former is the preferred form. 456 */ 457 struct drm_atomic_state { 458 /** 459 * @ref: 460 * 461 * Count of all references to this update (will not be freed until zero). 462 */ 463 struct kref ref; 464 465 /** 466 * @dev: Parent DRM Device. 467 */ 468 struct drm_device *dev; 469 470 /** 471 * @allow_modeset: 472 * 473 * Allow full modeset. This is used by the ATOMIC IOCTL handler to 474 * implement the DRM_MODE_ATOMIC_ALLOW_MODESET flag. Drivers should 475 * generally not consult this flag, but instead look at the output of 476 * drm_atomic_crtc_needs_modeset(). The detailed rules are: 477 * 478 * - Drivers must not consult @allow_modeset in the atomic commit path. 479 * Use drm_atomic_crtc_needs_modeset() instead. 480 * 481 * - Drivers must consult @allow_modeset before adding unrelated struct 482 * drm_crtc_state to this commit by calling 483 * drm_atomic_get_crtc_state(). See also the warning in the 484 * documentation for that function. 485 * 486 * - Drivers must never change this flag, it is under the exclusive 487 * control of userspace. 488 * 489 * - Drivers may consult @allow_modeset in the atomic check path, if 490 * they have the choice between an optimal hardware configuration 491 * which requires a modeset, and a less optimal configuration which 492 * can be committed without a modeset. An example would be suboptimal 493 * scanout FIFO allocation resulting in increased idle power 494 * consumption. This allows userspace to avoid flickering and delays 495 * for the normal composition loop at reasonable cost. 496 */ 497 bool allow_modeset : 1; 498 /** 499 * @legacy_cursor_update: 500 * 501 * Hint to enforce legacy cursor IOCTL semantics. 502 * 503 * WARNING: This is thoroughly broken and pretty much impossible to 504 * implement correctly. Drivers must ignore this and should instead 505 * implement &drm_plane_helper_funcs.atomic_async_check and 506 * &drm_plane_helper_funcs.atomic_async_commit hooks. New users of this 507 * flag are not allowed. 508 */ 509 bool legacy_cursor_update : 1; 510 511 /** 512 * @async_update: hint for asynchronous plane update 513 */ 514 bool async_update : 1; 515 516 /** 517 * @duplicated: 518 * 519 * Indicates whether or not this atomic state was duplicated using 520 * drm_atomic_helper_duplicate_state(). Drivers and atomic helpers 521 * should use this to fixup normal inconsistencies in duplicated 522 * states. 523 */ 524 bool duplicated : 1; 525 526 /** 527 * @planes: 528 * 529 * Pointer to array of @drm_plane and @drm_plane_state part of this 530 * update. 531 */ 532 struct __drm_planes_state *planes; 533 534 /** 535 * @crtcs: 536 * 537 * Pointer to array of @drm_crtc and @drm_crtc_state part of this 538 * update. 539 */ 540 struct __drm_crtcs_state *crtcs; 541 542 /** 543 * @num_connector: size of the @connectors array 544 */ 545 int num_connector; 546 547 /** 548 * @connectors: 549 * 550 * Pointer to array of @drm_connector and @drm_connector_state part of 551 * this update. 552 */ 553 struct __drm_connnectors_state *connectors; 554 555 /** 556 * @num_private_objs: size of the @private_objs array 557 */ 558 int num_private_objs; 559 560 /** 561 * @private_objs: 562 * 563 * Pointer to array of @drm_private_obj and @drm_private_obj_state part 564 * of this update. 565 */ 566 struct __drm_private_objs_state *private_objs; 567 568 /** 569 * @acquire_ctx: acquire context for this atomic modeset state update 570 */ 571 struct drm_modeset_acquire_ctx *acquire_ctx; 572 573 /** 574 * @fake_commit: 575 * 576 * Used for signaling unbound planes/connectors. 577 * When a connector or plane is not bound to any CRTC, it's still important 578 * to preserve linearity to prevent the atomic states from being freed too early. 579 * 580 * This commit (if set) is not bound to any CRTC, but will be completed when 581 * drm_atomic_helper_commit_hw_done() is called. 582 */ 583 struct drm_crtc_commit *fake_commit; 584 585 /** 586 * @commit_work: 587 * 588 * Work item which can be used by the driver or helpers to execute the 589 * commit without blocking. 590 */ 591 struct work_struct commit_work; 592 }; 593 594 void __drm_crtc_commit_free(struct kref *kref); 595 596 /** 597 * drm_crtc_commit_get - acquire a reference to the CRTC commit 598 * @commit: CRTC commit 599 * 600 * Increases the reference of @commit. 601 * 602 * Returns: 603 * The pointer to @commit, with reference increased. 604 */ 605 static inline struct drm_crtc_commit *drm_crtc_commit_get(struct drm_crtc_commit *commit) 606 { 607 kref_get(&commit->ref); 608 return commit; 609 } 610 611 /** 612 * drm_crtc_commit_put - release a reference to the CRTC commmit 613 * @commit: CRTC commit 614 * 615 * This releases a reference to @commit which is freed after removing the 616 * final reference. No locking required and callable from any context. 617 */ 618 static inline void drm_crtc_commit_put(struct drm_crtc_commit *commit) 619 { 620 kref_put(&commit->ref, __drm_crtc_commit_free); 621 } 622 623 int drm_crtc_commit_wait(struct drm_crtc_commit *commit); 624 625 struct drm_atomic_state * __must_check 626 drm_atomic_state_alloc(struct drm_device *dev); 627 void drm_atomic_state_clear(struct drm_atomic_state *state); 628 629 /** 630 * drm_atomic_state_get - acquire a reference to the atomic state 631 * @state: The atomic state 632 * 633 * Returns a new reference to the @state 634 */ 635 static inline struct drm_atomic_state * 636 drm_atomic_state_get(struct drm_atomic_state *state) 637 { 638 kref_get(&state->ref); 639 return state; 640 } 641 642 void __drm_atomic_state_free(struct kref *ref); 643 644 /** 645 * drm_atomic_state_put - release a reference to the atomic state 646 * @state: The atomic state 647 * 648 * This releases a reference to @state which is freed after removing the 649 * final reference. No locking required and callable from any context. 650 */ 651 static inline void drm_atomic_state_put(struct drm_atomic_state *state) 652 { 653 kref_put(&state->ref, __drm_atomic_state_free); 654 } 655 656 int __must_check 657 drm_atomic_state_init(struct drm_device *dev, struct drm_atomic_state *state); 658 void drm_atomic_state_default_clear(struct drm_atomic_state *state); 659 void drm_atomic_state_default_release(struct drm_atomic_state *state); 660 661 struct drm_crtc_state * __must_check 662 drm_atomic_get_crtc_state(struct drm_atomic_state *state, 663 struct drm_crtc *crtc); 664 struct drm_plane_state * __must_check 665 drm_atomic_get_plane_state(struct drm_atomic_state *state, 666 struct drm_plane *plane); 667 struct drm_connector_state * __must_check 668 drm_atomic_get_connector_state(struct drm_atomic_state *state, 669 struct drm_connector *connector); 670 671 void drm_atomic_private_obj_init(struct drm_device *dev, 672 struct drm_private_obj *obj, 673 struct drm_private_state *state, 674 const struct drm_private_state_funcs *funcs); 675 void drm_atomic_private_obj_fini(struct drm_private_obj *obj); 676 677 struct drm_private_state * __must_check 678 drm_atomic_get_private_obj_state(struct drm_atomic_state *state, 679 struct drm_private_obj *obj); 680 struct drm_private_state * 681 drm_atomic_get_old_private_obj_state(const struct drm_atomic_state *state, 682 struct drm_private_obj *obj); 683 struct drm_private_state * 684 drm_atomic_get_new_private_obj_state(const struct drm_atomic_state *state, 685 struct drm_private_obj *obj); 686 687 struct drm_connector * 688 drm_atomic_get_old_connector_for_encoder(const struct drm_atomic_state *state, 689 struct drm_encoder *encoder); 690 struct drm_connector * 691 drm_atomic_get_new_connector_for_encoder(const struct drm_atomic_state *state, 692 struct drm_encoder *encoder); 693 struct drm_connector * 694 drm_atomic_get_connector_for_encoder(const struct drm_encoder *encoder, 695 struct drm_modeset_acquire_ctx *ctx); 696 697 struct drm_crtc * 698 drm_atomic_get_old_crtc_for_encoder(struct drm_atomic_state *state, 699 struct drm_encoder *encoder); 700 struct drm_crtc * 701 drm_atomic_get_new_crtc_for_encoder(struct drm_atomic_state *state, 702 struct drm_encoder *encoder); 703 704 /** 705 * drm_atomic_get_old_crtc_state - get old CRTC state, if it exists 706 * @state: global atomic state object 707 * @crtc: CRTC to grab 708 * 709 * This function returns the old CRTC state for the given CRTC, or 710 * NULL if the CRTC is not part of the global atomic state. 711 */ 712 static inline struct drm_crtc_state * 713 drm_atomic_get_old_crtc_state(const struct drm_atomic_state *state, 714 struct drm_crtc *crtc) 715 { 716 return state->crtcs[drm_crtc_index(crtc)].old_state; 717 } 718 /** 719 * drm_atomic_get_new_crtc_state - get new CRTC state, if it exists 720 * @state: global atomic state object 721 * @crtc: CRTC to grab 722 * 723 * This function returns the new CRTC state for the given CRTC, or 724 * NULL if the CRTC is not part of the global atomic state. 725 */ 726 static inline struct drm_crtc_state * 727 drm_atomic_get_new_crtc_state(const struct drm_atomic_state *state, 728 struct drm_crtc *crtc) 729 { 730 return state->crtcs[drm_crtc_index(crtc)].new_state; 731 } 732 733 /** 734 * drm_atomic_get_old_plane_state - get plane state, if it exists 735 * @state: global atomic state object 736 * @plane: plane to grab 737 * 738 * This function returns the old plane state for the given plane, or 739 * NULL if the plane is not part of the global atomic state. 740 */ 741 static inline struct drm_plane_state * 742 drm_atomic_get_old_plane_state(const struct drm_atomic_state *state, 743 struct drm_plane *plane) 744 { 745 return state->planes[drm_plane_index(plane)].old_state; 746 } 747 748 /** 749 * drm_atomic_get_new_plane_state - get plane state, if it exists 750 * @state: global atomic state object 751 * @plane: plane to grab 752 * 753 * This function returns the new plane state for the given plane, or 754 * NULL if the plane is not part of the global atomic state. 755 */ 756 static inline struct drm_plane_state * 757 drm_atomic_get_new_plane_state(const struct drm_atomic_state *state, 758 struct drm_plane *plane) 759 { 760 return state->planes[drm_plane_index(plane)].new_state; 761 } 762 763 /** 764 * drm_atomic_get_old_connector_state - get connector state, if it exists 765 * @state: global atomic state object 766 * @connector: connector to grab 767 * 768 * This function returns the old connector state for the given connector, 769 * or NULL if the connector is not part of the global atomic state. 770 */ 771 static inline struct drm_connector_state * 772 drm_atomic_get_old_connector_state(const struct drm_atomic_state *state, 773 struct drm_connector *connector) 774 { 775 int index = drm_connector_index(connector); 776 777 if (index >= state->num_connector) 778 return NULL; 779 780 return state->connectors[index].old_state; 781 } 782 783 /** 784 * drm_atomic_get_new_connector_state - get connector state, if it exists 785 * @state: global atomic state object 786 * @connector: connector to grab 787 * 788 * This function returns the new connector state for the given connector, 789 * or NULL if the connector is not part of the global atomic state. 790 */ 791 static inline struct drm_connector_state * 792 drm_atomic_get_new_connector_state(const struct drm_atomic_state *state, 793 struct drm_connector *connector) 794 { 795 int index = drm_connector_index(connector); 796 797 if (index >= state->num_connector) 798 return NULL; 799 800 return state->connectors[index].new_state; 801 } 802 803 /** 804 * __drm_atomic_get_current_plane_state - get current plane state 805 * @state: global atomic state object 806 * @plane: plane to grab 807 * 808 * This function returns the plane state for the given plane, either the 809 * new plane state from @state, or if the plane isn't part of the atomic 810 * state update, from @plane. This is useful in atomic check callbacks, 811 * when drivers need to peek at, but not change, state of other planes, 812 * since it avoids threading an error code back up the call chain. 813 * 814 * WARNING: 815 * 816 * Note that this function is in general unsafe since it doesn't check for the 817 * required locking for access state structures. Drivers must ensure that it is 818 * safe to access the returned state structure through other means. One common 819 * example is when planes are fixed to a single CRTC, and the driver knows that 820 * the CRTC lock is held already. In that case holding the CRTC lock gives a 821 * read-lock on all planes connected to that CRTC. But if planes can be 822 * reassigned things get more tricky. In that case it's better to use 823 * drm_atomic_get_plane_state and wire up full error handling. 824 * 825 * Returns: 826 * 827 * Read-only pointer to the current plane state. 828 */ 829 static inline const struct drm_plane_state * 830 __drm_atomic_get_current_plane_state(const struct drm_atomic_state *state, 831 struct drm_plane *plane) 832 { 833 struct drm_plane_state *plane_state; 834 835 plane_state = drm_atomic_get_new_plane_state(state, plane); 836 if (plane_state) 837 return plane_state; 838 839 /* 840 * If the plane isn't part of the state, fallback to the currently active one. 841 */ 842 return plane->state; 843 } 844 845 int __must_check 846 drm_atomic_add_encoder_bridges(struct drm_atomic_state *state, 847 struct drm_encoder *encoder); 848 int __must_check 849 drm_atomic_add_affected_connectors(struct drm_atomic_state *state, 850 struct drm_crtc *crtc); 851 int __must_check 852 drm_atomic_add_affected_planes(struct drm_atomic_state *state, 853 struct drm_crtc *crtc); 854 855 int __must_check drm_atomic_check_only(struct drm_atomic_state *state); 856 int __must_check drm_atomic_commit(struct drm_atomic_state *state); 857 int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state); 858 859 void drm_state_dump(struct drm_device *dev, struct drm_printer *p); 860 861 /** 862 * for_each_oldnew_connector_in_state - iterate over all connectors in an atomic update 863 * @__state: &struct drm_atomic_state pointer 864 * @connector: &struct drm_connector iteration cursor 865 * @old_connector_state: &struct drm_connector_state iteration cursor for the 866 * old state 867 * @new_connector_state: &struct drm_connector_state iteration cursor for the 868 * new state 869 * @__i: int iteration cursor, for macro-internal use 870 * 871 * This iterates over all connectors in an atomic update, tracking both old and 872 * new state. This is useful in places where the state delta needs to be 873 * considered, for example in atomic check functions. 874 */ 875 #define for_each_oldnew_connector_in_state(__state, connector, old_connector_state, new_connector_state, __i) \ 876 for ((__i) = 0; \ 877 (__i) < (__state)->num_connector; \ 878 (__i)++) \ 879 for_each_if ((__state)->connectors[__i].ptr && \ 880 ((connector) = (__state)->connectors[__i].ptr, \ 881 (void)(connector) /* Only to avoid unused-but-set-variable warning */, \ 882 (old_connector_state) = (__state)->connectors[__i].old_state, \ 883 (new_connector_state) = (__state)->connectors[__i].new_state, 1)) 884 885 /** 886 * for_each_old_connector_in_state - iterate over all connectors in an atomic update 887 * @__state: &struct drm_atomic_state pointer 888 * @connector: &struct drm_connector iteration cursor 889 * @old_connector_state: &struct drm_connector_state iteration cursor for the 890 * old state 891 * @__i: int iteration cursor, for macro-internal use 892 * 893 * This iterates over all connectors in an atomic update, tracking only the old 894 * state. This is useful in disable functions, where we need the old state the 895 * hardware is still in. 896 */ 897 #define for_each_old_connector_in_state(__state, connector, old_connector_state, __i) \ 898 for ((__i) = 0; \ 899 (__i) < (__state)->num_connector; \ 900 (__i)++) \ 901 for_each_if ((__state)->connectors[__i].ptr && \ 902 ((connector) = (__state)->connectors[__i].ptr, \ 903 (void)(connector) /* Only to avoid unused-but-set-variable warning */, \ 904 (old_connector_state) = (__state)->connectors[__i].old_state, 1)) 905 906 /** 907 * for_each_new_connector_in_state - iterate over all connectors in an atomic update 908 * @__state: &struct drm_atomic_state pointer 909 * @connector: &struct drm_connector iteration cursor 910 * @new_connector_state: &struct drm_connector_state iteration cursor for the 911 * new state 912 * @__i: int iteration cursor, for macro-internal use 913 * 914 * This iterates over all connectors in an atomic update, tracking only the new 915 * state. This is useful in enable functions, where we need the new state the 916 * hardware should be in when the atomic commit operation has completed. 917 */ 918 #define for_each_new_connector_in_state(__state, connector, new_connector_state, __i) \ 919 for ((__i) = 0; \ 920 (__i) < (__state)->num_connector; \ 921 (__i)++) \ 922 for_each_if ((__state)->connectors[__i].ptr && \ 923 ((connector) = (__state)->connectors[__i].ptr, \ 924 (void)(connector) /* Only to avoid unused-but-set-variable warning */, \ 925 (new_connector_state) = (__state)->connectors[__i].new_state, \ 926 (void)(new_connector_state) /* Only to avoid unused-but-set-variable warning */, 1)) 927 928 /** 929 * for_each_oldnew_crtc_in_state - iterate over all CRTCs in an atomic update 930 * @__state: &struct drm_atomic_state pointer 931 * @crtc: &struct drm_crtc iteration cursor 932 * @old_crtc_state: &struct drm_crtc_state iteration cursor for the old state 933 * @new_crtc_state: &struct drm_crtc_state iteration cursor for the new state 934 * @__i: int iteration cursor, for macro-internal use 935 * 936 * This iterates over all CRTCs in an atomic update, tracking both old and 937 * new state. This is useful in places where the state delta needs to be 938 * considered, for example in atomic check functions. 939 */ 940 #define for_each_oldnew_crtc_in_state(__state, crtc, old_crtc_state, new_crtc_state, __i) \ 941 for ((__i) = 0; \ 942 (__i) < (__state)->dev->mode_config.num_crtc; \ 943 (__i)++) \ 944 for_each_if ((__state)->crtcs[__i].ptr && \ 945 ((crtc) = (__state)->crtcs[__i].ptr, \ 946 (void)(crtc) /* Only to avoid unused-but-set-variable warning */, \ 947 (old_crtc_state) = (__state)->crtcs[__i].old_state, \ 948 (void)(old_crtc_state) /* Only to avoid unused-but-set-variable warning */, \ 949 (new_crtc_state) = (__state)->crtcs[__i].new_state, \ 950 (void)(new_crtc_state) /* Only to avoid unused-but-set-variable warning */, 1)) 951 952 /** 953 * for_each_old_crtc_in_state - iterate over all CRTCs in an atomic update 954 * @__state: &struct drm_atomic_state pointer 955 * @crtc: &struct drm_crtc iteration cursor 956 * @old_crtc_state: &struct drm_crtc_state iteration cursor for the old state 957 * @__i: int iteration cursor, for macro-internal use 958 * 959 * This iterates over all CRTCs in an atomic update, tracking only the old 960 * state. This is useful in disable functions, where we need the old state the 961 * hardware is still in. 962 */ 963 #define for_each_old_crtc_in_state(__state, crtc, old_crtc_state, __i) \ 964 for ((__i) = 0; \ 965 (__i) < (__state)->dev->mode_config.num_crtc; \ 966 (__i)++) \ 967 for_each_if ((__state)->crtcs[__i].ptr && \ 968 ((crtc) = (__state)->crtcs[__i].ptr, \ 969 (void)(crtc) /* Only to avoid unused-but-set-variable warning */, \ 970 (old_crtc_state) = (__state)->crtcs[__i].old_state, 1)) 971 972 /** 973 * for_each_new_crtc_in_state - iterate over all CRTCs in an atomic update 974 * @__state: &struct drm_atomic_state pointer 975 * @crtc: &struct drm_crtc iteration cursor 976 * @new_crtc_state: &struct drm_crtc_state iteration cursor for the new state 977 * @__i: int iteration cursor, for macro-internal use 978 * 979 * This iterates over all CRTCs in an atomic update, tracking only the new 980 * state. This is useful in enable functions, where we need the new state the 981 * hardware should be in when the atomic commit operation has completed. 982 */ 983 #define for_each_new_crtc_in_state(__state, crtc, new_crtc_state, __i) \ 984 for ((__i) = 0; \ 985 (__i) < (__state)->dev->mode_config.num_crtc; \ 986 (__i)++) \ 987 for_each_if ((__state)->crtcs[__i].ptr && \ 988 ((crtc) = (__state)->crtcs[__i].ptr, \ 989 (void)(crtc) /* Only to avoid unused-but-set-variable warning */, \ 990 (new_crtc_state) = (__state)->crtcs[__i].new_state, \ 991 (void)(new_crtc_state) /* Only to avoid unused-but-set-variable warning */, 1)) 992 993 /** 994 * for_each_oldnew_plane_in_state - iterate over all planes in an atomic update 995 * @__state: &struct drm_atomic_state pointer 996 * @plane: &struct drm_plane iteration cursor 997 * @old_plane_state: &struct drm_plane_state iteration cursor for the old state 998 * @new_plane_state: &struct drm_plane_state iteration cursor for the new state 999 * @__i: int iteration cursor, for macro-internal use 1000 * 1001 * This iterates over all planes in an atomic update, tracking both old and 1002 * new state. This is useful in places where the state delta needs to be 1003 * considered, for example in atomic check functions. 1004 */ 1005 #define for_each_oldnew_plane_in_state(__state, plane, old_plane_state, new_plane_state, __i) \ 1006 for ((__i) = 0; \ 1007 (__i) < (__state)->dev->mode_config.num_total_plane; \ 1008 (__i)++) \ 1009 for_each_if ((__state)->planes[__i].ptr && \ 1010 ((plane) = (__state)->planes[__i].ptr, \ 1011 (void)(plane) /* Only to avoid unused-but-set-variable warning */, \ 1012 (old_plane_state) = (__state)->planes[__i].old_state,\ 1013 (new_plane_state) = (__state)->planes[__i].new_state, 1)) 1014 1015 /** 1016 * for_each_oldnew_plane_in_state_reverse - iterate over all planes in an atomic 1017 * update in reverse order 1018 * @__state: &struct drm_atomic_state pointer 1019 * @plane: &struct drm_plane iteration cursor 1020 * @old_plane_state: &struct drm_plane_state iteration cursor for the old state 1021 * @new_plane_state: &struct drm_plane_state iteration cursor for the new state 1022 * @__i: int iteration cursor, for macro-internal use 1023 * 1024 * This iterates over all planes in an atomic update in reverse order, 1025 * tracking both old and new state. This is useful in places where the 1026 * state delta needs to be considered, for example in atomic check functions. 1027 */ 1028 #define for_each_oldnew_plane_in_state_reverse(__state, plane, old_plane_state, new_plane_state, __i) \ 1029 for ((__i) = ((__state)->dev->mode_config.num_total_plane - 1); \ 1030 (__i) >= 0; \ 1031 (__i)--) \ 1032 for_each_if ((__state)->planes[__i].ptr && \ 1033 ((plane) = (__state)->planes[__i].ptr, \ 1034 (old_plane_state) = (__state)->planes[__i].old_state,\ 1035 (new_plane_state) = (__state)->planes[__i].new_state, 1)) 1036 1037 /** 1038 * for_each_new_plane_in_state_reverse - other than only tracking new state, 1039 * it's the same as for_each_oldnew_plane_in_state_reverse 1040 * @__state: &struct drm_atomic_state pointer 1041 * @plane: &struct drm_plane iteration cursor 1042 * @new_plane_state: &struct drm_plane_state iteration cursor for the new state 1043 * @__i: int iteration cursor, for macro-internal use 1044 */ 1045 #define for_each_new_plane_in_state_reverse(__state, plane, new_plane_state, __i) \ 1046 for ((__i) = ((__state)->dev->mode_config.num_total_plane - 1); \ 1047 (__i) >= 0; \ 1048 (__i)--) \ 1049 for_each_if ((__state)->planes[__i].ptr && \ 1050 ((plane) = (__state)->planes[__i].ptr, \ 1051 (new_plane_state) = (__state)->planes[__i].new_state, 1)) 1052 1053 /** 1054 * for_each_old_plane_in_state - iterate over all planes in an atomic update 1055 * @__state: &struct drm_atomic_state pointer 1056 * @plane: &struct drm_plane iteration cursor 1057 * @old_plane_state: &struct drm_plane_state iteration cursor for the old state 1058 * @__i: int iteration cursor, for macro-internal use 1059 * 1060 * This iterates over all planes in an atomic update, tracking only the old 1061 * state. This is useful in disable functions, where we need the old state the 1062 * hardware is still in. 1063 */ 1064 #define for_each_old_plane_in_state(__state, plane, old_plane_state, __i) \ 1065 for ((__i) = 0; \ 1066 (__i) < (__state)->dev->mode_config.num_total_plane; \ 1067 (__i)++) \ 1068 for_each_if ((__state)->planes[__i].ptr && \ 1069 ((plane) = (__state)->planes[__i].ptr, \ 1070 (old_plane_state) = (__state)->planes[__i].old_state, 1)) 1071 /** 1072 * for_each_new_plane_in_state - iterate over all planes in an atomic update 1073 * @__state: &struct drm_atomic_state pointer 1074 * @plane: &struct drm_plane iteration cursor 1075 * @new_plane_state: &struct drm_plane_state iteration cursor for the new state 1076 * @__i: int iteration cursor, for macro-internal use 1077 * 1078 * This iterates over all planes in an atomic update, tracking only the new 1079 * state. This is useful in enable functions, where we need the new state the 1080 * hardware should be in when the atomic commit operation has completed. 1081 */ 1082 #define for_each_new_plane_in_state(__state, plane, new_plane_state, __i) \ 1083 for ((__i) = 0; \ 1084 (__i) < (__state)->dev->mode_config.num_total_plane; \ 1085 (__i)++) \ 1086 for_each_if ((__state)->planes[__i].ptr && \ 1087 ((plane) = (__state)->planes[__i].ptr, \ 1088 (void)(plane) /* Only to avoid unused-but-set-variable warning */, \ 1089 (new_plane_state) = (__state)->planes[__i].new_state, \ 1090 (void)(new_plane_state) /* Only to avoid unused-but-set-variable warning */, 1)) 1091 1092 /** 1093 * for_each_oldnew_private_obj_in_state - iterate over all private objects in an atomic update 1094 * @__state: &struct drm_atomic_state pointer 1095 * @obj: &struct drm_private_obj iteration cursor 1096 * @old_obj_state: &struct drm_private_state iteration cursor for the old state 1097 * @new_obj_state: &struct drm_private_state iteration cursor for the new state 1098 * @__i: int iteration cursor, for macro-internal use 1099 * 1100 * This iterates over all private objects in an atomic update, tracking both 1101 * old and new state. This is useful in places where the state delta needs 1102 * to be considered, for example in atomic check functions. 1103 */ 1104 #define for_each_oldnew_private_obj_in_state(__state, obj, old_obj_state, new_obj_state, __i) \ 1105 for ((__i) = 0; \ 1106 (__i) < (__state)->num_private_objs && \ 1107 ((obj) = (__state)->private_objs[__i].ptr, \ 1108 (old_obj_state) = (__state)->private_objs[__i].old_state, \ 1109 (new_obj_state) = (__state)->private_objs[__i].new_state, 1); \ 1110 (__i)++) 1111 1112 /** 1113 * for_each_old_private_obj_in_state - iterate over all private objects in an atomic update 1114 * @__state: &struct drm_atomic_state pointer 1115 * @obj: &struct drm_private_obj iteration cursor 1116 * @old_obj_state: &struct drm_private_state iteration cursor for the old state 1117 * @__i: int iteration cursor, for macro-internal use 1118 * 1119 * This iterates over all private objects in an atomic update, tracking only 1120 * the old state. This is useful in disable functions, where we need the old 1121 * state the hardware is still in. 1122 */ 1123 #define for_each_old_private_obj_in_state(__state, obj, old_obj_state, __i) \ 1124 for ((__i) = 0; \ 1125 (__i) < (__state)->num_private_objs && \ 1126 ((obj) = (__state)->private_objs[__i].ptr, \ 1127 (old_obj_state) = (__state)->private_objs[__i].old_state, 1); \ 1128 (__i)++) 1129 1130 /** 1131 * for_each_new_private_obj_in_state - iterate over all private objects in an atomic update 1132 * @__state: &struct drm_atomic_state pointer 1133 * @obj: &struct drm_private_obj iteration cursor 1134 * @new_obj_state: &struct drm_private_state iteration cursor for the new state 1135 * @__i: int iteration cursor, for macro-internal use 1136 * 1137 * This iterates over all private objects in an atomic update, tracking only 1138 * the new state. This is useful in enable functions, where we need the new state the 1139 * hardware should be in when the atomic commit operation has completed. 1140 */ 1141 #define for_each_new_private_obj_in_state(__state, obj, new_obj_state, __i) \ 1142 for ((__i) = 0; \ 1143 (__i) < (__state)->num_private_objs && \ 1144 ((obj) = (__state)->private_objs[__i].ptr, \ 1145 (void)(obj) /* Only to avoid unused-but-set-variable warning */, \ 1146 (new_obj_state) = (__state)->private_objs[__i].new_state, 1); \ 1147 (__i)++) 1148 1149 /** 1150 * drm_atomic_crtc_needs_modeset - compute combined modeset need 1151 * @state: &drm_crtc_state for the CRTC 1152 * 1153 * To give drivers flexibility &struct drm_crtc_state has 3 booleans to track 1154 * whether the state CRTC changed enough to need a full modeset cycle: 1155 * mode_changed, active_changed and connectors_changed. This helper simply 1156 * combines these three to compute the overall need for a modeset for @state. 1157 * 1158 * The atomic helper code sets these booleans, but drivers can and should 1159 * change them appropriately to accurately represent whether a modeset is 1160 * really needed. In general, drivers should avoid full modesets whenever 1161 * possible. 1162 * 1163 * For example if the CRTC mode has changed, and the hardware is able to enact 1164 * the requested mode change without going through a full modeset, the driver 1165 * should clear mode_changed in its &drm_mode_config_funcs.atomic_check 1166 * implementation. 1167 */ 1168 static inline bool 1169 drm_atomic_crtc_needs_modeset(const struct drm_crtc_state *state) 1170 { 1171 return state->mode_changed || state->active_changed || 1172 state->connectors_changed; 1173 } 1174 1175 /** 1176 * drm_atomic_crtc_effectively_active - compute whether CRTC is actually active 1177 * @state: &drm_crtc_state for the CRTC 1178 * 1179 * When in self refresh mode, the crtc_state->active value will be false, since 1180 * the CRTC is off. However in some cases we're interested in whether the CRTC 1181 * is active, or effectively active (ie: it's connected to an active display). 1182 * In these cases, use this function instead of just checking active. 1183 */ 1184 static inline bool 1185 drm_atomic_crtc_effectively_active(const struct drm_crtc_state *state) 1186 { 1187 return state->active || state->self_refresh_active; 1188 } 1189 1190 /** 1191 * struct drm_bus_cfg - bus configuration 1192 * 1193 * This structure stores the configuration of a physical bus between two 1194 * components in an output pipeline, usually between two bridges, an encoder 1195 * and a bridge, or a bridge and a connector. 1196 * 1197 * The bus configuration is stored in &drm_bridge_state separately for the 1198 * input and output buses, as seen from the point of view of each bridge. The 1199 * bus configuration of a bridge output is usually identical to the 1200 * configuration of the next bridge's input, but may differ if the signals are 1201 * modified between the two bridges, for instance by an inverter on the board. 1202 * The input and output configurations of a bridge may differ if the bridge 1203 * modifies the signals internally, for instance by performing format 1204 * conversion, or modifying signals polarities. 1205 */ 1206 struct drm_bus_cfg { 1207 /** 1208 * @format: format used on this bus (one of the MEDIA_BUS_FMT_* format) 1209 * 1210 * This field should not be directly modified by drivers 1211 * (drm_atomic_bridge_chain_select_bus_fmts() takes care of the bus 1212 * format negotiation). 1213 */ 1214 u32 format; 1215 1216 /** 1217 * @flags: DRM_BUS_* flags used on this bus 1218 */ 1219 u32 flags; 1220 }; 1221 1222 /** 1223 * struct drm_bridge_state - Atomic bridge state object 1224 */ 1225 struct drm_bridge_state { 1226 /** 1227 * @base: inherit from &drm_private_state 1228 */ 1229 struct drm_private_state base; 1230 1231 /** 1232 * @bridge: the bridge this state refers to 1233 */ 1234 struct drm_bridge *bridge; 1235 1236 /** 1237 * @input_bus_cfg: input bus configuration 1238 */ 1239 struct drm_bus_cfg input_bus_cfg; 1240 1241 /** 1242 * @output_bus_cfg: output bus configuration 1243 */ 1244 struct drm_bus_cfg output_bus_cfg; 1245 }; 1246 1247 static inline struct drm_bridge_state * 1248 drm_priv_to_bridge_state(struct drm_private_state *priv) 1249 { 1250 return container_of(priv, struct drm_bridge_state, base); 1251 } 1252 1253 struct drm_bridge_state * 1254 drm_atomic_get_bridge_state(struct drm_atomic_state *state, 1255 struct drm_bridge *bridge); 1256 struct drm_bridge_state * 1257 drm_atomic_get_old_bridge_state(const struct drm_atomic_state *state, 1258 struct drm_bridge *bridge); 1259 struct drm_bridge_state * 1260 drm_atomic_get_new_bridge_state(const struct drm_atomic_state *state, 1261 struct drm_bridge *bridge); 1262 1263 #endif /* DRM_ATOMIC_H_ */ 1264