drm_atomic.h 41 KB

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