blob: da9d95a1958096be400a3c4b9a4f5f1977d394e9 [file] [log] [blame]
Daniel Vettercc4ceb42014-07-25 21:30:38 +02001/*
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
28#ifndef DRM_ATOMIC_H_
29#define DRM_ATOMIC_H_
30
Thierry Reding37cc0142014-11-25 12:09:48 +010031#include <drm/drm_crtc.h>
32
Daniel Vetter43968d72016-09-21 10:59:24 +020033/**
34 * struct drm_crtc_commit - track modeset commits on a CRTC
35 *
36 * This structure is used to track pending modeset changes and atomic commit on
37 * a per-CRTC basis. Since updating the list should never block this structure
38 * is reference counted to allow waiters to safely wait on an event to complete,
39 * without holding any locks.
40 *
41 * It has 3 different events in total to allow a fine-grained synchronization
42 * between outstanding updates::
43 *
44 * atomic commit thread hardware
45 *
46 * write new state into hardware ----> ...
47 * signal hw_done
48 * switch to new state on next
49 * ... v/hblank
50 *
51 * wait for buffers to show up ...
52 *
53 * ... send completion irq
54 * irq handler signals flip_done
55 * cleanup old buffers
56 *
57 * signal cleanup_done
58 *
59 * wait for flip_done <----
60 * clean up atomic state
61 *
62 * The important bit to know is that cleanup_done is the terminal event, but the
63 * ordering between flip_done and hw_done is entirely up to the specific driver
64 * and modeset state change.
65 *
66 * For an implementation of how to use this look at
67 * drm_atomic_helper_setup_commit() from the atomic helper library.
68 */
69struct drm_crtc_commit {
70 /**
71 * @crtc:
72 *
73 * DRM CRTC for this commit.
74 */
75 struct drm_crtc *crtc;
76
77 /**
78 * @ref:
79 *
80 * Reference count for this structure. Needed to allow blocking on
81 * completions without the risk of the completion disappearing
82 * meanwhile.
83 */
84 struct kref ref;
85
86 /**
87 * @flip_done:
88 *
89 * Will be signaled when the hardware has flipped to the new set of
90 * buffers. Signals at the same time as when the drm event for this
91 * commit is sent to userspace, or when an out-fence is singalled. Note
92 * that for most hardware, in most cases this happens after @hw_done is
93 * signalled.
94 */
95 struct completion flip_done;
96
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 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 struct completion hw_done;
111
112 /**
113 * @cleanup_done:
114 *
115 * Will be signalled after old buffers have been cleaned up by calling
116 * drm_atomic_helper_cleanup_planes(). Since this can only happen after
117 * a vblank wait completed it might be a bit later. This completion is
118 * useful to throttle updates and avoid hardware updates getting ahead
119 * of the buffer cleanup too much.
120 */
121 struct completion cleanup_done;
122
123 /**
124 * @commit_entry:
125 *
Daniel Vetterd5745282017-01-25 07:26:45 +0100126 * Entry on the per-CRTC &drm_crtc.commit_list. Protected by
127 * $drm_crtc.commit_lock.
Daniel Vetter43968d72016-09-21 10:59:24 +0200128 */
129 struct list_head commit_entry;
130
131 /**
132 * @event:
133 *
134 * &drm_pending_vblank_event pointer to clean up private events.
135 */
136 struct drm_pending_vblank_event *event;
Leo (Sunpeng) Li1c6ceee2018-01-17 12:51:08 +0100137
138 /**
139 * @abort_completion:
140 *
141 * A flag that's set after drm_atomic_helper_setup_commit takes a second
142 * reference for the completion of $drm_crtc_state.event. It's used by
143 * the free code to remove the second reference if commit fails.
144 */
145 bool abort_completion;
Daniel Vetter43968d72016-09-21 10:59:24 +0200146};
147
148struct __drm_planes_state {
149 struct drm_plane *ptr;
Maarten Lankhorst581e49f2017-01-16 10:37:38 +0100150 struct drm_plane_state *state, *old_state, *new_state;
Daniel Vetter43968d72016-09-21 10:59:24 +0200151};
152
153struct __drm_crtcs_state {
154 struct drm_crtc *ptr;
Maarten Lankhorst581e49f2017-01-16 10:37:38 +0100155 struct drm_crtc_state *state, *old_state, *new_state;
Gustavo Padovan7e9081c2017-01-13 12:22:09 -0200156 s32 __user *out_fence_ptr;
Dhinakaran Pandiyanf4c04682018-02-02 21:12:59 -0800157 u64 last_vblank_count;
Daniel Vetter43968d72016-09-21 10:59:24 +0200158};
159
160struct __drm_connnectors_state {
161 struct drm_connector *ptr;
Maarten Lankhorst581e49f2017-01-16 10:37:38 +0100162 struct drm_connector_state *state, *old_state, *new_state;
Brian Starkeyb13cc8d2017-03-29 17:42:33 +0100163 /**
164 * @out_fence_ptr:
165 *
166 * User-provided pointer which the kernel uses to return a sync_file
167 * file descriptor. Used by writeback connectors to signal completion of
168 * the writeback.
169 */
170 s32 __user *out_fence_ptr;
Daniel Vetter43968d72016-09-21 10:59:24 +0200171};
172
Ville Syrjäläa4370c72017-07-12 18:51:02 +0300173struct drm_private_obj;
174struct drm_private_state;
175
Daniel Vetter43968d72016-09-21 10:59:24 +0200176/**
Pandiyan, Dhinakaranb430c272017-04-20 22:51:30 -0700177 * struct drm_private_state_funcs - atomic state functions for private objects
178 *
179 * These hooks are used by atomic helpers to create, swap and destroy states of
180 * private objects. The structure itself is used as a vtable to identify the
181 * associated private object type. Each private object type that needs to be
182 * added to the atomic states is expected to have an implementation of these
183 * hooks and pass a pointer to it's drm_private_state_funcs struct to
184 * drm_atomic_get_private_obj_state().
185 */
186struct drm_private_state_funcs {
187 /**
Ville Syrjäläa4370c72017-07-12 18:51:02 +0300188 * @atomic_duplicate_state:
Pandiyan, Dhinakaranb430c272017-04-20 22:51:30 -0700189 *
190 * Duplicate the current state of the private object and return it. It
191 * is an error to call this before obj->state has been initialized.
192 *
193 * RETURNS:
194 *
195 * Duplicated atomic state or NULL when obj->state is not
196 * initialized or allocation failed.
197 */
Ville Syrjäläa4370c72017-07-12 18:51:02 +0300198 struct drm_private_state *(*atomic_duplicate_state)(struct drm_private_obj *obj);
Pandiyan, Dhinakaranb430c272017-04-20 22:51:30 -0700199
200 /**
Ville Syrjäläa4370c72017-07-12 18:51:02 +0300201 * @atomic_destroy_state:
Pandiyan, Dhinakaranb430c272017-04-20 22:51:30 -0700202 *
Ville Syrjäläa4370c72017-07-12 18:51:02 +0300203 * Frees the private object state created with @atomic_duplicate_state.
Pandiyan, Dhinakaranb430c272017-04-20 22:51:30 -0700204 */
Ville Syrjäläa4370c72017-07-12 18:51:02 +0300205 void (*atomic_destroy_state)(struct drm_private_obj *obj,
206 struct drm_private_state *state);
207};
Pandiyan, Dhinakaranb430c272017-04-20 22:51:30 -0700208
Daniel Vetterda6c0592017-12-14 21:30:53 +0100209/**
210 * struct drm_private_obj - base struct for driver private atomic object
211 *
212 * A driver private object is initialized by calling
213 * drm_atomic_private_obj_init() and cleaned up by calling
214 * drm_atomic_private_obj_fini().
215 *
216 * Currently only tracks the state update functions and the opaque driver
217 * private state itself, but in the future might also track which
218 * &drm_modeset_lock is required to duplicate and update this object's state.
219 */
Ville Syrjäläa4370c72017-07-12 18:51:02 +0300220struct drm_private_obj {
Daniel Vetterda6c0592017-12-14 21:30:53 +0100221 /**
222 * @state: Current atomic state for this driver private object.
223 */
Ville Syrjäläa4370c72017-07-12 18:51:02 +0300224 struct drm_private_state *state;
225
Daniel Vetterda6c0592017-12-14 21:30:53 +0100226 /**
227 * @funcs:
228 *
229 * Functions to manipulate the state of this driver private object, see
230 * &drm_private_state_funcs.
231 */
Ville Syrjäläa4370c72017-07-12 18:51:02 +0300232 const struct drm_private_state_funcs *funcs;
233};
234
Daniel Vetterda6c0592017-12-14 21:30:53 +0100235/**
236 * struct drm_private_state - base struct for driver private object state
237 * @state: backpointer to global drm_atomic_state
238 *
239 * Currently only contains a backpointer to the overall atomic update, but in
240 * the future also might hold synchronization information similar to e.g.
241 * &drm_crtc.commit.
242 */
Ville Syrjäläa4370c72017-07-12 18:51:02 +0300243struct drm_private_state {
244 struct drm_atomic_state *state;
Pandiyan, Dhinakaranb430c272017-04-20 22:51:30 -0700245};
246
247struct __drm_private_objs_state {
Ville Syrjäläa4370c72017-07-12 18:51:02 +0300248 struct drm_private_obj *ptr;
249 struct drm_private_state *state, *old_state, *new_state;
Pandiyan, Dhinakaranb430c272017-04-20 22:51:30 -0700250};
251
252/**
Daniel Vetter43968d72016-09-21 10:59:24 +0200253 * struct drm_atomic_state - the global state object for atomic updates
Chris Wilson08536952016-10-14 13:18:18 +0100254 * @ref: count of all references to this state (will not be freed until zero)
Daniel Vetter43968d72016-09-21 10:59:24 +0200255 * @dev: parent DRM device
256 * @allow_modeset: allow full modeset
257 * @legacy_cursor_update: hint to enforce legacy cursor IOCTL semantics
Gustavo Padovanfef9df82017-06-30 15:03:17 -0300258 * @async_update: hint for asynchronous plane update
Daniel Vetter43968d72016-09-21 10:59:24 +0200259 * @planes: pointer to array of structures with per-plane data
260 * @crtcs: pointer to array of CRTC pointers
261 * @num_connector: size of the @connectors and @connector_states arrays
262 * @connectors: pointer to array of structures with per-connector data
Pandiyan, Dhinakaranb430c272017-04-20 22:51:30 -0700263 * @num_private_objs: size of the @private_objs array
264 * @private_objs: pointer to array of private object pointers
Daniel Vetter43968d72016-09-21 10:59:24 +0200265 * @acquire_ctx: acquire context for this atomic modeset state update
Daniel Vetter5fca5ec2017-12-14 21:30:54 +0100266 *
267 * States are added to an atomic update by calling drm_atomic_get_crtc_state(),
268 * drm_atomic_get_plane_state(), drm_atomic_get_connector_state(), or for
269 * private state structures, drm_atomic_get_private_obj_state().
Daniel Vetter43968d72016-09-21 10:59:24 +0200270 */
271struct drm_atomic_state {
Chris Wilson08536952016-10-14 13:18:18 +0100272 struct kref ref;
273
Daniel Vetter43968d72016-09-21 10:59:24 +0200274 struct drm_device *dev;
275 bool allow_modeset : 1;
276 bool legacy_cursor_update : 1;
Gustavo Padovanfef9df82017-06-30 15:03:17 -0300277 bool async_update : 1;
Daniel Vetter43968d72016-09-21 10:59:24 +0200278 struct __drm_planes_state *planes;
279 struct __drm_crtcs_state *crtcs;
280 int num_connector;
281 struct __drm_connnectors_state *connectors;
Pandiyan, Dhinakaranb430c272017-04-20 22:51:30 -0700282 int num_private_objs;
283 struct __drm_private_objs_state *private_objs;
Daniel Vetter43968d72016-09-21 10:59:24 +0200284
285 struct drm_modeset_acquire_ctx *acquire_ctx;
286
287 /**
Maarten Lankhorst21a01ab2017-09-04 12:48:37 +0200288 * @fake_commit:
289 *
290 * Used for signaling unbound planes/connectors.
291 * When a connector or plane is not bound to any CRTC, it's still important
292 * to preserve linearity to prevent the atomic states from being freed to early.
293 *
294 * This commit (if set) is not bound to any crtc, but will be completed when
295 * drm_atomic_helper_commit_hw_done() is called.
296 */
297 struct drm_crtc_commit *fake_commit;
298
299 /**
Daniel Vetter43968d72016-09-21 10:59:24 +0200300 * @commit_work:
301 *
302 * Work item which can be used by the driver or helpers to execute the
303 * commit without blocking.
304 */
305 struct work_struct commit_work;
306};
307
Daniel Vetterb3ba3f6f2016-12-21 14:03:35 +0100308void __drm_crtc_commit_free(struct kref *kref);
309
310/**
311 * drm_crtc_commit_get - acquire a reference to the CRTC commit
312 * @commit: CRTC commit
313 *
314 * Increases the reference of @commit.
Maarten Lankhorstf46640b2017-09-04 12:48:36 +0200315 *
316 * Returns:
317 * The pointer to @commit, with reference increased.
Daniel Vetterb3ba3f6f2016-12-21 14:03:35 +0100318 */
Maarten Lankhorstf46640b2017-09-04 12:48:36 +0200319static inline struct drm_crtc_commit *drm_crtc_commit_get(struct drm_crtc_commit *commit)
Daniel Vetter3b24f7d2016-06-08 14:19:00 +0200320{
321 kref_get(&commit->ref);
Maarten Lankhorstf46640b2017-09-04 12:48:36 +0200322 return commit;
Daniel Vetter3b24f7d2016-06-08 14:19:00 +0200323}
324
Daniel Vetterb3ba3f6f2016-12-21 14:03:35 +0100325/**
326 * drm_crtc_commit_put - release a reference to the CRTC commmit
327 * @commit: CRTC commit
328 *
329 * This releases a reference to @commit which is freed after removing the
330 * final reference. No locking required and callable from any context.
331 */
332static inline void drm_crtc_commit_put(struct drm_crtc_commit *commit)
333{
334 kref_put(&commit->ref, __drm_crtc_commit_free);
335}
336
Daniel Vettercc4ceb42014-07-25 21:30:38 +0200337struct drm_atomic_state * __must_check
338drm_atomic_state_alloc(struct drm_device *dev);
339void drm_atomic_state_clear(struct drm_atomic_state *state);
Chris Wilson08536952016-10-14 13:18:18 +0100340
341/**
342 * drm_atomic_state_get - acquire a reference to the atomic state
343 * @state: The atomic state
344 *
345 * Returns a new reference to the @state
346 */
347static inline struct drm_atomic_state *
348drm_atomic_state_get(struct drm_atomic_state *state)
349{
350 kref_get(&state->ref);
351 return state;
352}
353
354void __drm_atomic_state_free(struct kref *ref);
355
356/**
357 * drm_atomic_state_put - release a reference to the atomic state
358 * @state: The atomic state
359 *
360 * This releases a reference to @state which is freed after removing the
361 * final reference. No locking required and callable from any context.
362 */
363static inline void drm_atomic_state_put(struct drm_atomic_state *state)
364{
365 kref_put(&state->ref, __drm_atomic_state_free);
366}
Daniel Vettercc4ceb42014-07-25 21:30:38 +0200367
Maarten Lankhorst036ef572015-05-18 10:06:40 +0200368int __must_check
369drm_atomic_state_init(struct drm_device *dev, struct drm_atomic_state *state);
370void drm_atomic_state_default_clear(struct drm_atomic_state *state);
371void drm_atomic_state_default_release(struct drm_atomic_state *state);
372
Daniel Vettercc4ceb42014-07-25 21:30:38 +0200373struct drm_crtc_state * __must_check
374drm_atomic_get_crtc_state(struct drm_atomic_state *state,
375 struct drm_crtc *crtc);
Rob Clark40ecc692014-12-18 16:01:46 -0500376int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
377 struct drm_crtc_state *state, struct drm_property *property,
378 uint64_t val);
Daniel Vettercc4ceb42014-07-25 21:30:38 +0200379struct drm_plane_state * __must_check
380drm_atomic_get_plane_state(struct drm_atomic_state *state,
381 struct drm_plane *plane);
382struct drm_connector_state * __must_check
383drm_atomic_get_connector_state(struct drm_atomic_state *state,
384 struct drm_connector *connector);
Rob Clark88a48e22014-12-18 16:01:50 -0500385
Ville Syrjäläa4370c72017-07-12 18:51:02 +0300386void drm_atomic_private_obj_init(struct drm_private_obj *obj,
387 struct drm_private_state *state,
388 const struct drm_private_state_funcs *funcs);
389void drm_atomic_private_obj_fini(struct drm_private_obj *obj);
390
391struct drm_private_state * __must_check
Pandiyan, Dhinakaranb430c272017-04-20 22:51:30 -0700392drm_atomic_get_private_obj_state(struct drm_atomic_state *state,
Ville Syrjäläa4370c72017-07-12 18:51:02 +0300393 struct drm_private_obj *obj);
Pandiyan, Dhinakaranb430c272017-04-20 22:51:30 -0700394
Maarten Lankhorst1b26a5e2015-05-13 10:37:25 +0200395/**
396 * drm_atomic_get_existing_crtc_state - get crtc state, if it exists
397 * @state: global atomic state object
398 * @crtc: crtc to grab
399 *
400 * This function returns the crtc state for the given crtc, or NULL
401 * if the crtc is not part of the global atomic state.
Maarten Lankhorst21077772017-02-16 15:47:08 +0100402 *
403 * This function is deprecated, @drm_atomic_get_old_crtc_state or
404 * @drm_atomic_get_new_crtc_state should be used instead.
Maarten Lankhorst1b26a5e2015-05-13 10:37:25 +0200405 */
406static inline struct drm_crtc_state *
407drm_atomic_get_existing_crtc_state(struct drm_atomic_state *state,
408 struct drm_crtc *crtc)
409{
Daniel Vetter5d943aa62016-06-02 00:06:34 +0200410 return state->crtcs[drm_crtc_index(crtc)].state;
Maarten Lankhorst1b26a5e2015-05-13 10:37:25 +0200411}
412
413/**
Maarten Lankhorst21077772017-02-16 15:47:08 +0100414 * drm_atomic_get_old_crtc_state - get old crtc state, if it exists
415 * @state: global atomic state object
416 * @crtc: crtc to grab
417 *
418 * This function returns the old crtc state for the given crtc, or
419 * NULL if the crtc is not part of the global atomic state.
420 */
421static inline struct drm_crtc_state *
422drm_atomic_get_old_crtc_state(struct drm_atomic_state *state,
423 struct drm_crtc *crtc)
424{
425 return state->crtcs[drm_crtc_index(crtc)].old_state;
426}
427/**
428 * drm_atomic_get_new_crtc_state - get new crtc state, if it exists
429 * @state: global atomic state object
430 * @crtc: crtc to grab
431 *
432 * This function returns the new crtc state for the given crtc, or
433 * NULL if the crtc is not part of the global atomic state.
434 */
435static inline struct drm_crtc_state *
436drm_atomic_get_new_crtc_state(struct drm_atomic_state *state,
437 struct drm_crtc *crtc)
438{
439 return state->crtcs[drm_crtc_index(crtc)].new_state;
440}
441
442/**
Maarten Lankhorst1b26a5e2015-05-13 10:37:25 +0200443 * drm_atomic_get_existing_plane_state - get plane state, if it exists
444 * @state: global atomic state object
445 * @plane: plane to grab
446 *
447 * This function returns the plane state for the given plane, or NULL
448 * if the plane is not part of the global atomic state.
Maarten Lankhorst21077772017-02-16 15:47:08 +0100449 *
450 * This function is deprecated, @drm_atomic_get_old_plane_state or
451 * @drm_atomic_get_new_plane_state should be used instead.
Maarten Lankhorst1b26a5e2015-05-13 10:37:25 +0200452 */
453static inline struct drm_plane_state *
454drm_atomic_get_existing_plane_state(struct drm_atomic_state *state,
455 struct drm_plane *plane)
456{
Daniel Vetterb8b53422016-06-02 00:06:33 +0200457 return state->planes[drm_plane_index(plane)].state;
Maarten Lankhorst1b26a5e2015-05-13 10:37:25 +0200458}
459
460/**
Maarten Lankhorst21077772017-02-16 15:47:08 +0100461 * drm_atomic_get_old_plane_state - get plane state, if it exists
462 * @state: global atomic state object
463 * @plane: plane to grab
464 *
465 * This function returns the old plane state for the given plane, or
466 * NULL if the plane is not part of the global atomic state.
467 */
468static inline struct drm_plane_state *
469drm_atomic_get_old_plane_state(struct drm_atomic_state *state,
470 struct drm_plane *plane)
471{
472 return state->planes[drm_plane_index(plane)].old_state;
473}
474
475/**
476 * drm_atomic_get_new_plane_state - get plane state, if it exists
477 * @state: global atomic state object
478 * @plane: plane to grab
479 *
480 * This function returns the new plane state for the given plane, or
481 * NULL if the plane is not part of the global atomic state.
482 */
483static inline struct drm_plane_state *
484drm_atomic_get_new_plane_state(struct drm_atomic_state *state,
485 struct drm_plane *plane)
486{
487 return state->planes[drm_plane_index(plane)].new_state;
488}
489
490/**
Maarten Lankhorst1b26a5e2015-05-13 10:37:25 +0200491 * drm_atomic_get_existing_connector_state - get connector state, if it exists
492 * @state: global atomic state object
493 * @connector: connector to grab
494 *
495 * This function returns the connector state for the given connector,
496 * or NULL if the connector is not part of the global atomic state.
Maarten Lankhorst21077772017-02-16 15:47:08 +0100497 *
498 * This function is deprecated, @drm_atomic_get_old_connector_state or
499 * @drm_atomic_get_new_connector_state should be used instead.
Maarten Lankhorst1b26a5e2015-05-13 10:37:25 +0200500 */
501static inline struct drm_connector_state *
502drm_atomic_get_existing_connector_state(struct drm_atomic_state *state,
503 struct drm_connector *connector)
504{
505 int index = drm_connector_index(connector);
506
507 if (index >= state->num_connector)
508 return NULL;
509
Daniel Vetter63e83c12016-06-02 00:06:32 +0200510 return state->connectors[index].state;
Maarten Lankhorst1b26a5e2015-05-13 10:37:25 +0200511}
512
Daniel Vetter2f196b72016-06-02 16:21:44 +0200513/**
Maarten Lankhorst21077772017-02-16 15:47:08 +0100514 * drm_atomic_get_old_connector_state - get connector state, if it exists
515 * @state: global atomic state object
516 * @connector: connector to grab
517 *
518 * This function returns the old connector state for the given connector,
519 * or NULL if the connector is not part of the global atomic state.
520 */
521static inline struct drm_connector_state *
522drm_atomic_get_old_connector_state(struct drm_atomic_state *state,
523 struct drm_connector *connector)
524{
525 int index = drm_connector_index(connector);
526
527 if (index >= state->num_connector)
528 return NULL;
529
530 return state->connectors[index].old_state;
531}
532
533/**
534 * drm_atomic_get_new_connector_state - get connector state, if it exists
535 * @state: global atomic state object
536 * @connector: connector to grab
537 *
538 * This function returns the new connector state for the given connector,
539 * or NULL if the connector is not part of the global atomic state.
540 */
541static inline struct drm_connector_state *
542drm_atomic_get_new_connector_state(struct drm_atomic_state *state,
543 struct drm_connector *connector)
544{
545 int index = drm_connector_index(connector);
546
547 if (index >= state->num_connector)
548 return NULL;
549
550 return state->connectors[index].new_state;
551}
552
553/**
Daniel Vetter2f196b72016-06-02 16:21:44 +0200554 * __drm_atomic_get_current_plane_state - get current plane state
555 * @state: global atomic state object
556 * @plane: plane to grab
557 *
558 * This function returns the plane state for the given plane, either from
559 * @state, or if the plane isn't part of the atomic state update, from @plane.
560 * This is useful in atomic check callbacks, when drivers need to peek at, but
561 * not change, state of other planes, since it avoids threading an error code
562 * back up the call chain.
563 *
564 * WARNING:
565 *
566 * Note that this function is in general unsafe since it doesn't check for the
567 * required locking for access state structures. Drivers must ensure that it is
Daniel Vetter60c9e1902016-06-02 17:39:14 +0200568 * safe to access the returned state structure through other means. One common
Daniel Vetter2f196b72016-06-02 16:21:44 +0200569 * example is when planes are fixed to a single CRTC, and the driver knows that
Daniel Vetter60c9e1902016-06-02 17:39:14 +0200570 * the CRTC lock is held already. In that case holding the CRTC lock gives a
Daniel Vetter2f196b72016-06-02 16:21:44 +0200571 * read-lock on all planes connected to that CRTC. But if planes can be
572 * reassigned things get more tricky. In that case it's better to use
573 * drm_atomic_get_plane_state and wire up full error handling.
574 *
575 * Returns:
576 *
577 * Read-only pointer to the current plane state.
578 */
579static inline const struct drm_plane_state *
580__drm_atomic_get_current_plane_state(struct drm_atomic_state *state,
581 struct drm_plane *plane)
582{
Daniel Vetterb8b53422016-06-02 00:06:33 +0200583 if (state->planes[drm_plane_index(plane)].state)
584 return state->planes[drm_plane_index(plane)].state;
Daniel Vetter2f196b72016-06-02 16:21:44 +0200585
586 return plane->state;
587}
588
Daniel Vettercc4ceb42014-07-25 21:30:38 +0200589int __must_check
Daniel Stone819364d2015-05-26 14:36:48 +0100590drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state,
Ville Syrjälä91110a42017-05-18 22:38:36 +0300591 const struct drm_display_mode *mode);
Daniel Stone819364d2015-05-26 14:36:48 +0100592int __must_check
Daniel Stone955f3c32015-05-25 19:11:52 +0100593drm_atomic_set_mode_prop_for_crtc(struct drm_crtc_state *state,
594 struct drm_property_blob *blob);
595int __must_check
Daniel Vetter07cc0ef2014-11-27 15:49:39 +0100596drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state,
597 struct drm_crtc *crtc);
Daniel Vetter321ebf02014-11-04 22:57:27 +0100598void drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state,
599 struct drm_framebuffer *fb);
Gustavo Padovan13b55662016-11-07 19:03:30 +0900600void drm_atomic_set_fence_for_plane(struct drm_plane_state *plane_state,
601 struct dma_fence *fence);
Daniel Vettercc4ceb42014-07-25 21:30:38 +0200602int __must_check
603drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state,
604 struct drm_crtc *crtc);
Brian Starkey935774c2017-03-29 17:42:32 +0100605int drm_atomic_set_writeback_fb_for_connector(
606 struct drm_connector_state *conn_state,
607 struct drm_framebuffer *fb);
Daniel Vettercc4ceb42014-07-25 21:30:38 +0200608int __must_check
609drm_atomic_add_affected_connectors(struct drm_atomic_state *state,
610 struct drm_crtc *crtc);
Maarten Lankhorste01e9f72015-05-19 16:41:02 +0200611int __must_check
612drm_atomic_add_affected_planes(struct drm_atomic_state *state,
613 struct drm_crtc *crtc);
614
Daniel Vettercc4ceb42014-07-25 21:30:38 +0200615int __must_check drm_atomic_check_only(struct drm_atomic_state *state);
616int __must_check drm_atomic_commit(struct drm_atomic_state *state);
Maarten Lankhorstb837ba02016-04-26 16:11:35 +0200617int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state);
Daniel Vettercc4ceb42014-07-25 21:30:38 +0200618
Rob Clark6559c902016-11-05 11:08:10 -0400619void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
620
Daniel Vetterf9a76952017-03-28 17:53:49 +0200621/**
Daniel Vetterf9a76952017-03-28 17:53:49 +0200622 * for_each_oldnew_connector_in_state - iterate over all connectors in an atomic update
623 * @__state: &struct drm_atomic_state pointer
624 * @connector: &struct drm_connector iteration cursor
625 * @old_connector_state: &struct drm_connector_state iteration cursor for the
626 * old state
627 * @new_connector_state: &struct drm_connector_state iteration cursor for the
628 * new state
629 * @__i: int iteration cursor, for macro-internal use
630 *
631 * This iterates over all connectors in an atomic update, tracking both old and
632 * new state. This is useful in places where the state delta needs to be
633 * considered, for example in atomic check functions.
634 */
Maarten Lankhorst581e49f2017-01-16 10:37:38 +0100635#define for_each_oldnew_connector_in_state(__state, connector, old_connector_state, new_connector_state, __i) \
636 for ((__i) = 0; \
Maarten Lankhorst331494e2017-09-27 10:35:32 +0200637 (__i) < (__state)->num_connector; \
638 (__i)++) \
639 for_each_if ((__state)->connectors[__i].ptr && \
640 ((connector) = (__state)->connectors[__i].ptr, \
641 (old_connector_state) = (__state)->connectors[__i].old_state, \
642 (new_connector_state) = (__state)->connectors[__i].new_state, 1))
Maarten Lankhorst581e49f2017-01-16 10:37:38 +0100643
Daniel Vetterf9a76952017-03-28 17:53:49 +0200644/**
645 * for_each_old_connector_in_state - iterate over all connectors in an atomic update
646 * @__state: &struct drm_atomic_state pointer
647 * @connector: &struct drm_connector iteration cursor
648 * @old_connector_state: &struct drm_connector_state iteration cursor for the
649 * old state
650 * @__i: int iteration cursor, for macro-internal use
651 *
652 * This iterates over all connectors in an atomic update, tracking only the old
653 * state. This is useful in disable functions, where we need the old state the
654 * hardware is still in.
655 */
Maarten Lankhorst581e49f2017-01-16 10:37:38 +0100656#define for_each_old_connector_in_state(__state, connector, old_connector_state, __i) \
657 for ((__i) = 0; \
Maarten Lankhorst331494e2017-09-27 10:35:32 +0200658 (__i) < (__state)->num_connector; \
659 (__i)++) \
660 for_each_if ((__state)->connectors[__i].ptr && \
661 ((connector) = (__state)->connectors[__i].ptr, \
662 (old_connector_state) = (__state)->connectors[__i].old_state, 1))
Maarten Lankhorst581e49f2017-01-16 10:37:38 +0100663
Daniel Vetterf9a76952017-03-28 17:53:49 +0200664/**
665 * for_each_new_connector_in_state - iterate over all connectors in an atomic update
666 * @__state: &struct drm_atomic_state pointer
667 * @connector: &struct drm_connector iteration cursor
668 * @new_connector_state: &struct drm_connector_state iteration cursor for the
669 * new state
670 * @__i: int iteration cursor, for macro-internal use
671 *
672 * This iterates over all connectors in an atomic update, tracking only the new
673 * state. This is useful in enable functions, where we need the new state the
674 * hardware should be in when the atomic commit operation has completed.
675 */
Maarten Lankhorst581e49f2017-01-16 10:37:38 +0100676#define for_each_new_connector_in_state(__state, connector, new_connector_state, __i) \
677 for ((__i) = 0; \
Maarten Lankhorst331494e2017-09-27 10:35:32 +0200678 (__i) < (__state)->num_connector; \
679 (__i)++) \
680 for_each_if ((__state)->connectors[__i].ptr && \
681 ((connector) = (__state)->connectors[__i].ptr, \
682 (new_connector_state) = (__state)->connectors[__i].new_state, 1))
Maarten Lankhorst581e49f2017-01-16 10:37:38 +0100683
Daniel Vetterf9a76952017-03-28 17:53:49 +0200684/**
Daniel Vetterf9a76952017-03-28 17:53:49 +0200685 * for_each_oldnew_crtc_in_state - iterate over all CRTCs in an atomic update
686 * @__state: &struct drm_atomic_state pointer
687 * @crtc: &struct drm_crtc iteration cursor
688 * @old_crtc_state: &struct drm_crtc_state iteration cursor for the old state
689 * @new_crtc_state: &struct drm_crtc_state iteration cursor for the new state
690 * @__i: int iteration cursor, for macro-internal use
691 *
692 * This iterates over all CRTCs in an atomic update, tracking both old and
693 * new state. This is useful in places where the state delta needs to be
694 * considered, for example in atomic check functions.
695 */
Maarten Lankhorst581e49f2017-01-16 10:37:38 +0100696#define for_each_oldnew_crtc_in_state(__state, crtc, old_crtc_state, new_crtc_state, __i) \
697 for ((__i) = 0; \
Maarten Lankhorst331494e2017-09-27 10:35:32 +0200698 (__i) < (__state)->dev->mode_config.num_crtc; \
Maarten Lankhorst581e49f2017-01-16 10:37:38 +0100699 (__i)++) \
Maarten Lankhorst331494e2017-09-27 10:35:32 +0200700 for_each_if ((__state)->crtcs[__i].ptr && \
701 ((crtc) = (__state)->crtcs[__i].ptr, \
702 (old_crtc_state) = (__state)->crtcs[__i].old_state, \
703 (new_crtc_state) = (__state)->crtcs[__i].new_state, 1))
Maarten Lankhorst581e49f2017-01-16 10:37:38 +0100704
Daniel Vetterf9a76952017-03-28 17:53:49 +0200705/**
706 * for_each_old_crtc_in_state - iterate over all CRTCs in an atomic update
707 * @__state: &struct drm_atomic_state pointer
708 * @crtc: &struct drm_crtc iteration cursor
709 * @old_crtc_state: &struct drm_crtc_state iteration cursor for the old state
710 * @__i: int iteration cursor, for macro-internal use
711 *
712 * This iterates over all CRTCs in an atomic update, tracking only the old
713 * state. This is useful in disable functions, where we need the old state the
714 * hardware is still in.
715 */
Maarten Lankhorst581e49f2017-01-16 10:37:38 +0100716#define for_each_old_crtc_in_state(__state, crtc, old_crtc_state, __i) \
717 for ((__i) = 0; \
Maarten Lankhorst331494e2017-09-27 10:35:32 +0200718 (__i) < (__state)->dev->mode_config.num_crtc; \
Maarten Lankhorst581e49f2017-01-16 10:37:38 +0100719 (__i)++) \
Maarten Lankhorst331494e2017-09-27 10:35:32 +0200720 for_each_if ((__state)->crtcs[__i].ptr && \
721 ((crtc) = (__state)->crtcs[__i].ptr, \
722 (old_crtc_state) = (__state)->crtcs[__i].old_state, 1))
Maarten Lankhorst581e49f2017-01-16 10:37:38 +0100723
Daniel Vetterf9a76952017-03-28 17:53:49 +0200724/**
725 * for_each_new_crtc_in_state - iterate over all CRTCs in an atomic update
726 * @__state: &struct drm_atomic_state pointer
727 * @crtc: &struct drm_crtc iteration cursor
728 * @new_crtc_state: &struct drm_crtc_state iteration cursor for the new state
729 * @__i: int iteration cursor, for macro-internal use
730 *
731 * This iterates over all CRTCs in an atomic update, tracking only the new
732 * state. This is useful in enable functions, where we need the new state the
733 * hardware should be in when the atomic commit operation has completed.
734 */
Maarten Lankhorst581e49f2017-01-16 10:37:38 +0100735#define for_each_new_crtc_in_state(__state, crtc, new_crtc_state, __i) \
736 for ((__i) = 0; \
Maarten Lankhorst331494e2017-09-27 10:35:32 +0200737 (__i) < (__state)->dev->mode_config.num_crtc; \
Maarten Lankhorst581e49f2017-01-16 10:37:38 +0100738 (__i)++) \
Maarten Lankhorst331494e2017-09-27 10:35:32 +0200739 for_each_if ((__state)->crtcs[__i].ptr && \
740 ((crtc) = (__state)->crtcs[__i].ptr, \
741 (new_crtc_state) = (__state)->crtcs[__i].new_state, 1))
Maarten Lankhorst581e49f2017-01-16 10:37:38 +0100742
Daniel Vetterf9a76952017-03-28 17:53:49 +0200743/**
Daniel Vetterf9a76952017-03-28 17:53:49 +0200744 * for_each_oldnew_plane_in_state - iterate over all planes in an atomic update
745 * @__state: &struct drm_atomic_state pointer
746 * @plane: &struct drm_plane iteration cursor
747 * @old_plane_state: &struct drm_plane_state iteration cursor for the old state
748 * @new_plane_state: &struct drm_plane_state iteration cursor for the new state
749 * @__i: int iteration cursor, for macro-internal use
750 *
751 * This iterates over all planes in an atomic update, tracking both old and
752 * new state. This is useful in places where the state delta needs to be
753 * considered, for example in atomic check functions.
754 */
Maarten Lankhorst581e49f2017-01-16 10:37:38 +0100755#define for_each_oldnew_plane_in_state(__state, plane, old_plane_state, new_plane_state, __i) \
756 for ((__i) = 0; \
Maarten Lankhorst331494e2017-09-27 10:35:32 +0200757 (__i) < (__state)->dev->mode_config.num_total_plane; \
Maarten Lankhorst581e49f2017-01-16 10:37:38 +0100758 (__i)++) \
Maarten Lankhorst331494e2017-09-27 10:35:32 +0200759 for_each_if ((__state)->planes[__i].ptr && \
760 ((plane) = (__state)->planes[__i].ptr, \
761 (old_plane_state) = (__state)->planes[__i].old_state,\
762 (new_plane_state) = (__state)->planes[__i].new_state, 1))
Maarten Lankhorst581e49f2017-01-16 10:37:38 +0100763
Daniel Vetterf9a76952017-03-28 17:53:49 +0200764/**
Shirish S55de2922018-03-07 08:40:03 +0530765 * for_each_oldnew_plane_in_state_reverse - iterate over all planes in an atomic
766 * update in reverse order
767 * @__state: &struct drm_atomic_state pointer
768 * @plane: &struct drm_plane iteration cursor
769 * @old_plane_state: &struct drm_plane_state iteration cursor for the old state
770 * @new_plane_state: &struct drm_plane_state iteration cursor for the new state
771 * @__i: int iteration cursor, for macro-internal use
772 *
773 * This iterates over all planes in an atomic update in reverse order,
774 * tracking both old and new state. This is useful in places where the
775 * state delta needs to be considered, for example in atomic check functions.
776 */
777#define for_each_oldnew_plane_in_state_reverse(__state, plane, old_plane_state, new_plane_state, __i) \
778 for ((__i) = ((__state)->dev->mode_config.num_total_plane - 1); \
779 (__i) >= 0; \
780 (__i)--) \
781 for_each_if ((__state)->planes[__i].ptr && \
782 ((plane) = (__state)->planes[__i].ptr, \
783 (old_plane_state) = (__state)->planes[__i].old_state,\
784 (new_plane_state) = (__state)->planes[__i].new_state, 1))
785
786/**
Daniel Vetterf9a76952017-03-28 17:53:49 +0200787 * for_each_old_plane_in_state - iterate over all planes in an atomic update
788 * @__state: &struct drm_atomic_state pointer
789 * @plane: &struct drm_plane iteration cursor
790 * @old_plane_state: &struct drm_plane_state iteration cursor for the old state
791 * @__i: int iteration cursor, for macro-internal use
792 *
793 * This iterates over all planes in an atomic update, tracking only the old
794 * state. This is useful in disable functions, where we need the old state the
795 * hardware is still in.
796 */
Maarten Lankhorst581e49f2017-01-16 10:37:38 +0100797#define for_each_old_plane_in_state(__state, plane, old_plane_state, __i) \
798 for ((__i) = 0; \
Maarten Lankhorst331494e2017-09-27 10:35:32 +0200799 (__i) < (__state)->dev->mode_config.num_total_plane; \
Maarten Lankhorst581e49f2017-01-16 10:37:38 +0100800 (__i)++) \
Maarten Lankhorst331494e2017-09-27 10:35:32 +0200801 for_each_if ((__state)->planes[__i].ptr && \
802 ((plane) = (__state)->planes[__i].ptr, \
803 (old_plane_state) = (__state)->planes[__i].old_state, 1))
Daniel Vetterf9a76952017-03-28 17:53:49 +0200804/**
805 * for_each_new_plane_in_state - iterate over all planes in an atomic update
806 * @__state: &struct drm_atomic_state pointer
807 * @plane: &struct drm_plane iteration cursor
808 * @new_plane_state: &struct drm_plane_state iteration cursor for the new state
809 * @__i: int iteration cursor, for macro-internal use
810 *
811 * This iterates over all planes in an atomic update, tracking only the new
812 * state. This is useful in enable functions, where we need the new state the
813 * hardware should be in when the atomic commit operation has completed.
814 */
Maarten Lankhorst581e49f2017-01-16 10:37:38 +0100815#define for_each_new_plane_in_state(__state, plane, new_plane_state, __i) \
816 for ((__i) = 0; \
Maarten Lankhorst331494e2017-09-27 10:35:32 +0200817 (__i) < (__state)->dev->mode_config.num_total_plane; \
Maarten Lankhorst581e49f2017-01-16 10:37:38 +0100818 (__i)++) \
Maarten Lankhorst331494e2017-09-27 10:35:32 +0200819 for_each_if ((__state)->planes[__i].ptr && \
820 ((plane) = (__state)->planes[__i].ptr, \
821 (new_plane_state) = (__state)->planes[__i].new_state, 1))
Maarten Lankhorst581e49f2017-01-16 10:37:38 +0100822
Daniel Vetter081e9c02016-06-08 14:18:59 +0200823/**
Ville Syrjäläa4370c72017-07-12 18:51:02 +0300824 * for_each_oldnew_private_obj_in_state - iterate over all private objects in an atomic update
Pandiyan, Dhinakaranb430c272017-04-20 22:51:30 -0700825 * @__state: &struct drm_atomic_state pointer
Ville Syrjäläa4370c72017-07-12 18:51:02 +0300826 * @obj: &struct drm_private_obj iteration cursor
827 * @old_obj_state: &struct drm_private_state iteration cursor for the old state
828 * @new_obj_state: &struct drm_private_state iteration cursor for the new state
Pandiyan, Dhinakaranb430c272017-04-20 22:51:30 -0700829 * @__i: int iteration cursor, for macro-internal use
Pandiyan, Dhinakaranb430c272017-04-20 22:51:30 -0700830 *
Ville Syrjäläa4370c72017-07-12 18:51:02 +0300831 * This iterates over all private objects in an atomic update, tracking both
832 * old and new state. This is useful in places where the state delta needs
833 * to be considered, for example in atomic check functions.
Pandiyan, Dhinakaranb430c272017-04-20 22:51:30 -0700834 */
Ville Syrjäläa4370c72017-07-12 18:51:02 +0300835#define for_each_oldnew_private_obj_in_state(__state, obj, old_obj_state, new_obj_state, __i) \
836 for ((__i) = 0; \
837 (__i) < (__state)->num_private_objs && \
838 ((obj) = (__state)->private_objs[__i].ptr, \
839 (old_obj_state) = (__state)->private_objs[__i].old_state, \
840 (new_obj_state) = (__state)->private_objs[__i].new_state, 1); \
Maarten Lankhorstf0d2e862017-09-27 10:35:31 +0200841 (__i)++)
Pandiyan, Dhinakaranb430c272017-04-20 22:51:30 -0700842
843/**
Ville Syrjäläa4370c72017-07-12 18:51:02 +0300844 * for_each_old_private_obj_in_state - iterate over all private objects in an atomic update
Pandiyan, Dhinakaranb430c272017-04-20 22:51:30 -0700845 * @__state: &struct drm_atomic_state pointer
Ville Syrjäläa4370c72017-07-12 18:51:02 +0300846 * @obj: &struct drm_private_obj iteration cursor
847 * @old_obj_state: &struct drm_private_state iteration cursor for the old state
Pandiyan, Dhinakaranb430c272017-04-20 22:51:30 -0700848 * @__i: int iteration cursor, for macro-internal use
Pandiyan, Dhinakaranb430c272017-04-20 22:51:30 -0700849 *
Ville Syrjäläa4370c72017-07-12 18:51:02 +0300850 * This iterates over all private objects in an atomic update, tracking only
851 * the old state. This is useful in disable functions, where we need the old
852 * state the hardware is still in.
Pandiyan, Dhinakaranb430c272017-04-20 22:51:30 -0700853 */
Ville Syrjäläa4370c72017-07-12 18:51:02 +0300854#define for_each_old_private_obj_in_state(__state, obj, old_obj_state, __i) \
855 for ((__i) = 0; \
856 (__i) < (__state)->num_private_objs && \
857 ((obj) = (__state)->private_objs[__i].ptr, \
858 (old_obj_state) = (__state)->private_objs[__i].old_state, 1); \
Maarten Lankhorstf0d2e862017-09-27 10:35:31 +0200859 (__i)++)
Ville Syrjäläa4370c72017-07-12 18:51:02 +0300860
861/**
862 * for_each_new_private_obj_in_state - iterate over all private objects in an atomic update
863 * @__state: &struct drm_atomic_state pointer
864 * @obj: &struct drm_private_obj iteration cursor
865 * @new_obj_state: &struct drm_private_state iteration cursor for the new state
866 * @__i: int iteration cursor, for macro-internal use
867 *
868 * This iterates over all private objects in an atomic update, tracking only
869 * the new state. This is useful in enable functions, where we need the new state the
870 * hardware should be in when the atomic commit operation has completed.
871 */
872#define for_each_new_private_obj_in_state(__state, obj, new_obj_state, __i) \
873 for ((__i) = 0; \
874 (__i) < (__state)->num_private_objs && \
875 ((obj) = (__state)->private_objs[__i].ptr, \
876 (new_obj_state) = (__state)->private_objs[__i].new_state, 1); \
Maarten Lankhorstf0d2e862017-09-27 10:35:31 +0200877 (__i)++)
Pandiyan, Dhinakaranb430c272017-04-20 22:51:30 -0700878
879/**
Daniel Vetter081e9c02016-06-08 14:18:59 +0200880 * drm_atomic_crtc_needs_modeset - compute combined modeset need
881 * @state: &drm_crtc_state for the CRTC
882 *
Daniel Vetterea0dd852016-12-29 21:48:26 +0100883 * To give drivers flexibility &struct drm_crtc_state has 3 booleans to track
Daniel Vetter081e9c02016-06-08 14:18:59 +0200884 * whether the state CRTC changed enough to need a full modeset cycle:
Thierry Reding96bf51d2017-07-31 11:13:43 +0200885 * mode_changed, active_changed and connectors_changed. This helper simply
Daniel Vetter081e9c02016-06-08 14:18:59 +0200886 * combines these three to compute the overall need for a modeset for @state.
Brian Starkeyd807ed12016-10-13 10:47:08 +0100887 *
888 * The atomic helper code sets these booleans, but drivers can and should
889 * change them appropriately to accurately represent whether a modeset is
890 * really needed. In general, drivers should avoid full modesets whenever
891 * possible.
892 *
893 * For example if the CRTC mode has changed, and the hardware is able to enact
894 * the requested mode change without going through a full modeset, the driver
Daniel Vetterd5745282017-01-25 07:26:45 +0100895 * should clear mode_changed in its &drm_mode_config_funcs.atomic_check
896 * implementation.
Daniel Vetter081e9c02016-06-08 14:18:59 +0200897 */
Daniel Vetter2465ff62015-06-18 09:58:55 +0200898static inline bool
Ville Syrjälä79b95552016-11-24 19:47:02 +0200899drm_atomic_crtc_needs_modeset(const struct drm_crtc_state *state)
Daniel Vetter2465ff62015-06-18 09:58:55 +0200900{
Maarten Lankhorstfc596662015-07-21 13:28:57 +0200901 return state->mode_changed || state->active_changed ||
902 state->connectors_changed;
Daniel Vetter2465ff62015-06-18 09:58:55 +0200903}
904
Daniel Vettercc4ceb42014-07-25 21:30:38 +0200905#endif /* DRM_ATOMIC_H_ */