2 * Copyright (C) 2018 Intel Corp.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
23 * Rob Clark <robdclark@gmail.com>
24 * Daniel Vetter <daniel.vetter@ffwll.ch>
27 #include <drm/drm_atomic.h>
28 #include <drm/drm_atomic_state_helper.h>
29 #include <drm/drm_blend.h>
30 #include <drm/drm_bridge.h>
31 #include <drm/drm_connector.h>
32 #include <drm/drm_crtc.h>
33 #include <drm/drm_device.h>
34 #include <drm/drm_framebuffer.h>
35 #include <drm/drm_plane.h>
36 #include <drm/drm_print.h>
37 #include <drm/drm_vblank.h>
38 #include <drm/drm_writeback.h>
40 #include <linux/slab.h>
41 #include <linux/dma-fence.h>
44 * DOC: atomic state reset and initialization
46 * Both the drm core and the atomic helpers assume that there is always the full
47 * and correct atomic software state for all connectors, CRTCs and planes
48 * available. Which is a bit a problem on driver load and also after system
49 * suspend. One way to solve this is to have a hardware state read-out
50 * infrastructure which reconstructs the full software state (e.g. the i915
53 * The simpler solution is to just reset the software state to everything off,
54 * which is easiest to do by calling drm_mode_config_reset(). To facilitate this
55 * the atomic helpers provide default reset implementations for all hooks.
57 * On the upside the precise state tracking of atomic simplifies system suspend
58 * and resume a lot. For drivers using drm_mode_config_reset() a complete recipe
59 * is implemented in drm_atomic_helper_suspend() and drm_atomic_helper_resume().
60 * For other drivers the building blocks are split out, see the documentation
61 * for these functions.
65 * __drm_atomic_helper_crtc_state_reset - reset the CRTC state
66 * @crtc_state: atomic CRTC state, must not be NULL
67 * @crtc: CRTC object, must not be NULL
69 * Initializes the newly allocated @crtc_state with default
70 * values. This is useful for drivers that subclass the CRTC state.
73 __drm_atomic_helper_crtc_state_reset(struct drm_crtc_state
*crtc_state
,
74 struct drm_crtc
*crtc
)
76 crtc_state
->crtc
= crtc
;
78 EXPORT_SYMBOL(__drm_atomic_helper_crtc_state_reset
);
81 * __drm_atomic_helper_crtc_reset - reset state on CRTC
83 * @crtc_state: CRTC state to assign
85 * Initializes the newly allocated @crtc_state and assigns it to
86 * the &drm_crtc->state pointer of @crtc, usually required when
87 * initializing the drivers or when called from the &drm_crtc_funcs.reset
90 * This is useful for drivers that subclass the CRTC state.
93 __drm_atomic_helper_crtc_reset(struct drm_crtc
*crtc
,
94 struct drm_crtc_state
*crtc_state
)
97 __drm_atomic_helper_crtc_state_reset(crtc_state
, crtc
);
99 if (drm_dev_has_vblank(crtc
->dev
))
100 drm_crtc_vblank_reset(crtc
);
102 crtc
->state
= crtc_state
;
104 EXPORT_SYMBOL(__drm_atomic_helper_crtc_reset
);
107 * drm_atomic_helper_crtc_reset - default &drm_crtc_funcs.reset hook for CRTCs
110 * Resets the atomic state for @crtc by freeing the state pointer (which might
111 * be NULL, e.g. at driver load time) and allocating a new empty state object.
113 void drm_atomic_helper_crtc_reset(struct drm_crtc
*crtc
)
115 struct drm_crtc_state
*crtc_state
=
116 kzalloc(sizeof(*crtc
->state
), GFP_KERNEL
);
119 crtc
->funcs
->atomic_destroy_state(crtc
, crtc
->state
);
121 __drm_atomic_helper_crtc_reset(crtc
, crtc_state
);
123 EXPORT_SYMBOL(drm_atomic_helper_crtc_reset
);
126 * __drm_atomic_helper_crtc_duplicate_state - copy atomic CRTC state
128 * @state: atomic CRTC state
130 * Copies atomic state from a CRTC's current state and resets inferred values.
131 * This is useful for drivers that subclass the CRTC state.
133 void __drm_atomic_helper_crtc_duplicate_state(struct drm_crtc
*crtc
,
134 struct drm_crtc_state
*state
)
136 memcpy(state
, crtc
->state
, sizeof(*state
));
138 if (state
->mode_blob
)
139 drm_property_blob_get(state
->mode_blob
);
140 if (state
->degamma_lut
)
141 drm_property_blob_get(state
->degamma_lut
);
143 drm_property_blob_get(state
->ctm
);
144 if (state
->gamma_lut
)
145 drm_property_blob_get(state
->gamma_lut
);
146 state
->mode_changed
= false;
147 state
->active_changed
= false;
148 state
->planes_changed
= false;
149 state
->connectors_changed
= false;
150 state
->color_mgmt_changed
= false;
151 state
->zpos_changed
= false;
152 state
->commit
= NULL
;
154 state
->async_flip
= false;
156 /* Self refresh should be canceled when a new update is available */
157 state
->active
= drm_atomic_crtc_effectively_active(state
);
158 state
->self_refresh_active
= false;
160 EXPORT_SYMBOL(__drm_atomic_helper_crtc_duplicate_state
);
163 * drm_atomic_helper_crtc_duplicate_state - default state duplicate hook
166 * Default CRTC state duplicate hook for drivers which don't have their own
167 * subclassed CRTC state structure.
169 struct drm_crtc_state
*
170 drm_atomic_helper_crtc_duplicate_state(struct drm_crtc
*crtc
)
172 struct drm_crtc_state
*state
;
174 if (WARN_ON(!crtc
->state
))
177 state
= kmalloc(sizeof(*state
), GFP_KERNEL
);
179 __drm_atomic_helper_crtc_duplicate_state(crtc
, state
);
183 EXPORT_SYMBOL(drm_atomic_helper_crtc_duplicate_state
);
186 * __drm_atomic_helper_crtc_destroy_state - release CRTC state
187 * @state: CRTC state object to release
189 * Releases all resources stored in the CRTC state without actually freeing
190 * the memory of the CRTC state. This is useful for drivers that subclass the
193 void __drm_atomic_helper_crtc_destroy_state(struct drm_crtc_state
*state
)
197 * In the event that a non-blocking commit returns
198 * -ERESTARTSYS before the commit_tail work is queued, we will
199 * have an extra reference to the commit object. Release it, if
200 * the event has not been consumed by the worker.
202 * state->event may be freed, so we can't directly look at
203 * state->event->base.completion.
205 if (state
->event
&& state
->commit
->abort_completion
)
206 drm_crtc_commit_put(state
->commit
);
208 kfree(state
->commit
->event
);
209 state
->commit
->event
= NULL
;
211 drm_crtc_commit_put(state
->commit
);
214 drm_property_blob_put(state
->mode_blob
);
215 drm_property_blob_put(state
->degamma_lut
);
216 drm_property_blob_put(state
->ctm
);
217 drm_property_blob_put(state
->gamma_lut
);
219 EXPORT_SYMBOL(__drm_atomic_helper_crtc_destroy_state
);
222 * drm_atomic_helper_crtc_destroy_state - default state destroy hook
224 * @state: CRTC state object to release
226 * Default CRTC state destroy hook for drivers which don't have their own
227 * subclassed CRTC state structure.
229 void drm_atomic_helper_crtc_destroy_state(struct drm_crtc
*crtc
,
230 struct drm_crtc_state
*state
)
232 __drm_atomic_helper_crtc_destroy_state(state
);
235 EXPORT_SYMBOL(drm_atomic_helper_crtc_destroy_state
);
238 * __drm_atomic_helper_plane_state_reset - resets plane state to default values
239 * @plane_state: atomic plane state, must not be NULL
240 * @plane: plane object, must not be NULL
242 * Initializes the newly allocated @plane_state with default
243 * values. This is useful for drivers that subclass the CRTC state.
245 void __drm_atomic_helper_plane_state_reset(struct drm_plane_state
*plane_state
,
246 struct drm_plane
*plane
)
250 plane_state
->plane
= plane
;
251 plane_state
->rotation
= DRM_MODE_ROTATE_0
;
253 plane_state
->alpha
= DRM_BLEND_ALPHA_OPAQUE
;
254 plane_state
->pixel_blend_mode
= DRM_MODE_BLEND_PREMULTI
;
256 if (plane
->color_encoding_property
) {
257 if (!drm_object_property_get_default_value(&plane
->base
,
258 plane
->color_encoding_property
,
260 plane_state
->color_encoding
= val
;
263 if (plane
->color_range_property
) {
264 if (!drm_object_property_get_default_value(&plane
->base
,
265 plane
->color_range_property
,
267 plane_state
->color_range
= val
;
270 if (plane
->zpos_property
) {
271 if (!drm_object_property_get_default_value(&plane
->base
,
272 plane
->zpos_property
,
274 plane_state
->zpos
= val
;
275 plane_state
->normalized_zpos
= val
;
279 if (plane
->hotspot_x_property
) {
280 if (!drm_object_property_get_default_value(&plane
->base
,
281 plane
->hotspot_x_property
,
283 plane_state
->hotspot_x
= val
;
286 if (plane
->hotspot_y_property
) {
287 if (!drm_object_property_get_default_value(&plane
->base
,
288 plane
->hotspot_y_property
,
290 plane_state
->hotspot_y
= val
;
293 EXPORT_SYMBOL(__drm_atomic_helper_plane_state_reset
);
296 * __drm_atomic_helper_plane_reset - reset state on plane
298 * @plane_state: plane state to assign
300 * Initializes the newly allocated @plane_state and assigns it to
301 * the &drm_crtc->state pointer of @plane, usually required when
302 * initializing the drivers or when called from the &drm_plane_funcs.reset
305 * This is useful for drivers that subclass the plane state.
307 void __drm_atomic_helper_plane_reset(struct drm_plane
*plane
,
308 struct drm_plane_state
*plane_state
)
311 __drm_atomic_helper_plane_state_reset(plane_state
, plane
);
313 plane
->state
= plane_state
;
315 EXPORT_SYMBOL(__drm_atomic_helper_plane_reset
);
318 * drm_atomic_helper_plane_reset - default &drm_plane_funcs.reset hook for planes
321 * Resets the atomic state for @plane by freeing the state pointer (which might
322 * be NULL, e.g. at driver load time) and allocating a new empty state object.
324 void drm_atomic_helper_plane_reset(struct drm_plane
*plane
)
327 __drm_atomic_helper_plane_destroy_state(plane
->state
);
330 plane
->state
= kzalloc(sizeof(*plane
->state
), GFP_KERNEL
);
332 __drm_atomic_helper_plane_reset(plane
, plane
->state
);
334 EXPORT_SYMBOL(drm_atomic_helper_plane_reset
);
337 * __drm_atomic_helper_plane_duplicate_state - copy atomic plane state
338 * @plane: plane object
339 * @state: atomic plane state
341 * Copies atomic state from a plane's current state. This is useful for
342 * drivers that subclass the plane state.
344 void __drm_atomic_helper_plane_duplicate_state(struct drm_plane
*plane
,
345 struct drm_plane_state
*state
)
347 memcpy(state
, plane
->state
, sizeof(*state
));
350 drm_framebuffer_get(state
->fb
);
353 state
->commit
= NULL
;
354 state
->fb_damage_clips
= NULL
;
355 state
->color_mgmt_changed
= false;
357 EXPORT_SYMBOL(__drm_atomic_helper_plane_duplicate_state
);
360 * drm_atomic_helper_plane_duplicate_state - default state duplicate hook
363 * Default plane state duplicate hook for drivers which don't have their own
364 * subclassed plane state structure.
366 struct drm_plane_state
*
367 drm_atomic_helper_plane_duplicate_state(struct drm_plane
*plane
)
369 struct drm_plane_state
*state
;
371 if (WARN_ON(!plane
->state
))
374 state
= kmalloc(sizeof(*state
), GFP_KERNEL
);
376 __drm_atomic_helper_plane_duplicate_state(plane
, state
);
380 EXPORT_SYMBOL(drm_atomic_helper_plane_duplicate_state
);
383 * __drm_atomic_helper_plane_destroy_state - release plane state
384 * @state: plane state object to release
386 * Releases all resources stored in the plane state without actually freeing
387 * the memory of the plane state. This is useful for drivers that subclass the
390 void __drm_atomic_helper_plane_destroy_state(struct drm_plane_state
*state
)
393 drm_framebuffer_put(state
->fb
);
396 dma_fence_put(state
->fence
);
399 drm_crtc_commit_put(state
->commit
);
401 drm_property_blob_put(state
->fb_damage_clips
);
403 EXPORT_SYMBOL(__drm_atomic_helper_plane_destroy_state
);
406 * drm_atomic_helper_plane_destroy_state - default state destroy hook
408 * @state: plane state object to release
410 * Default plane state destroy hook for drivers which don't have their own
411 * subclassed plane state structure.
413 void drm_atomic_helper_plane_destroy_state(struct drm_plane
*plane
,
414 struct drm_plane_state
*state
)
416 __drm_atomic_helper_plane_destroy_state(state
);
419 EXPORT_SYMBOL(drm_atomic_helper_plane_destroy_state
);
422 * __drm_atomic_helper_connector_state_reset - reset the connector state
423 * @conn_state: atomic connector state, must not be NULL
424 * @connector: connectotr object, must not be NULL
426 * Initializes the newly allocated @conn_state with default
427 * values. This is useful for drivers that subclass the connector state.
430 __drm_atomic_helper_connector_state_reset(struct drm_connector_state
*conn_state
,
431 struct drm_connector
*connector
)
433 conn_state
->connector
= connector
;
435 EXPORT_SYMBOL(__drm_atomic_helper_connector_state_reset
);
438 * __drm_atomic_helper_connector_reset - reset state on connector
439 * @connector: drm connector
440 * @conn_state: connector state to assign
442 * Initializes the newly allocated @conn_state and assigns it to
443 * the &drm_connector->state pointer of @connector, usually required when
444 * initializing the drivers or when called from the &drm_connector_funcs.reset
447 * This is useful for drivers that subclass the connector state.
450 __drm_atomic_helper_connector_reset(struct drm_connector
*connector
,
451 struct drm_connector_state
*conn_state
)
454 __drm_atomic_helper_connector_state_reset(conn_state
, connector
);
456 connector
->state
= conn_state
;
458 EXPORT_SYMBOL(__drm_atomic_helper_connector_reset
);
461 * drm_atomic_helper_connector_reset - default &drm_connector_funcs.reset hook for connectors
462 * @connector: drm connector
464 * Resets the atomic state for @connector by freeing the state pointer (which
465 * might be NULL, e.g. at driver load time) and allocating a new empty state
468 void drm_atomic_helper_connector_reset(struct drm_connector
*connector
)
470 struct drm_connector_state
*conn_state
=
471 kzalloc(sizeof(*conn_state
), GFP_KERNEL
);
473 if (connector
->state
)
474 __drm_atomic_helper_connector_destroy_state(connector
->state
);
476 kfree(connector
->state
);
477 __drm_atomic_helper_connector_reset(connector
, conn_state
);
479 EXPORT_SYMBOL(drm_atomic_helper_connector_reset
);
482 * drm_atomic_helper_connector_tv_margins_reset - Resets TV connector properties
483 * @connector: DRM connector
485 * Resets the TV-related properties attached to a connector.
487 void drm_atomic_helper_connector_tv_margins_reset(struct drm_connector
*connector
)
489 struct drm_cmdline_mode
*cmdline
= &connector
->cmdline_mode
;
490 struct drm_connector_state
*state
= connector
->state
;
492 state
->tv
.margins
.left
= cmdline
->tv_margins
.left
;
493 state
->tv
.margins
.right
= cmdline
->tv_margins
.right
;
494 state
->tv
.margins
.top
= cmdline
->tv_margins
.top
;
495 state
->tv
.margins
.bottom
= cmdline
->tv_margins
.bottom
;
497 EXPORT_SYMBOL(drm_atomic_helper_connector_tv_margins_reset
);
500 * drm_atomic_helper_connector_tv_reset - Resets Analog TV connector properties
501 * @connector: DRM connector
503 * Resets the analog TV properties attached to a connector
505 void drm_atomic_helper_connector_tv_reset(struct drm_connector
*connector
)
507 struct drm_device
*dev
= connector
->dev
;
508 struct drm_cmdline_mode
*cmdline
= &connector
->cmdline_mode
;
509 struct drm_connector_state
*state
= connector
->state
;
510 struct drm_property
*prop
;
513 prop
= dev
->mode_config
.tv_mode_property
;
515 if (!drm_object_property_get_default_value(&connector
->base
,
517 state
->tv
.mode
= val
;
519 if (cmdline
->tv_mode_specified
)
520 state
->tv
.mode
= cmdline
->tv_mode
;
522 prop
= dev
->mode_config
.tv_select_subconnector_property
;
524 if (!drm_object_property_get_default_value(&connector
->base
,
526 state
->tv
.select_subconnector
= val
;
528 prop
= dev
->mode_config
.tv_subconnector_property
;
530 if (!drm_object_property_get_default_value(&connector
->base
,
532 state
->tv
.subconnector
= val
;
534 prop
= dev
->mode_config
.tv_brightness_property
;
536 if (!drm_object_property_get_default_value(&connector
->base
,
538 state
->tv
.brightness
= val
;
540 prop
= dev
->mode_config
.tv_contrast_property
;
542 if (!drm_object_property_get_default_value(&connector
->base
,
544 state
->tv
.contrast
= val
;
546 prop
= dev
->mode_config
.tv_flicker_reduction_property
;
548 if (!drm_object_property_get_default_value(&connector
->base
,
550 state
->tv
.flicker_reduction
= val
;
552 prop
= dev
->mode_config
.tv_overscan_property
;
554 if (!drm_object_property_get_default_value(&connector
->base
,
556 state
->tv
.overscan
= val
;
558 prop
= dev
->mode_config
.tv_saturation_property
;
560 if (!drm_object_property_get_default_value(&connector
->base
,
562 state
->tv
.saturation
= val
;
564 prop
= dev
->mode_config
.tv_hue_property
;
566 if (!drm_object_property_get_default_value(&connector
->base
,
570 drm_atomic_helper_connector_tv_margins_reset(connector
);
572 EXPORT_SYMBOL(drm_atomic_helper_connector_tv_reset
);
575 * drm_atomic_helper_connector_tv_check - Validate an analog TV connector state
576 * @connector: DRM Connector
577 * @state: the DRM State object
579 * Checks the state object to see if the requested state is valid for an
580 * analog TV connector.
583 * %0 for success, a negative error code on error.
585 int drm_atomic_helper_connector_tv_check(struct drm_connector
*connector
,
586 struct drm_atomic_state
*state
)
588 struct drm_connector_state
*old_conn_state
=
589 drm_atomic_get_old_connector_state(state
, connector
);
590 struct drm_connector_state
*new_conn_state
=
591 drm_atomic_get_new_connector_state(state
, connector
);
592 struct drm_crtc_state
*crtc_state
;
593 struct drm_crtc
*crtc
;
595 crtc
= new_conn_state
->crtc
;
599 crtc_state
= drm_atomic_get_new_crtc_state(state
, crtc
);
603 if (old_conn_state
->tv
.mode
!= new_conn_state
->tv
.mode
)
604 crtc_state
->mode_changed
= true;
606 if (old_conn_state
->tv
.margins
.left
!= new_conn_state
->tv
.margins
.left
||
607 old_conn_state
->tv
.margins
.right
!= new_conn_state
->tv
.margins
.right
||
608 old_conn_state
->tv
.margins
.top
!= new_conn_state
->tv
.margins
.top
||
609 old_conn_state
->tv
.margins
.bottom
!= new_conn_state
->tv
.margins
.bottom
||
610 old_conn_state
->tv
.mode
!= new_conn_state
->tv
.mode
||
611 old_conn_state
->tv
.brightness
!= new_conn_state
->tv
.brightness
||
612 old_conn_state
->tv
.contrast
!= new_conn_state
->tv
.contrast
||
613 old_conn_state
->tv
.flicker_reduction
!= new_conn_state
->tv
.flicker_reduction
||
614 old_conn_state
->tv
.overscan
!= new_conn_state
->tv
.overscan
||
615 old_conn_state
->tv
.saturation
!= new_conn_state
->tv
.saturation
||
616 old_conn_state
->tv
.hue
!= new_conn_state
->tv
.hue
)
617 crtc_state
->connectors_changed
= true;
621 EXPORT_SYMBOL(drm_atomic_helper_connector_tv_check
);
624 * __drm_atomic_helper_connector_duplicate_state - copy atomic connector state
625 * @connector: connector object
626 * @state: atomic connector state
628 * Copies atomic state from a connector's current state. This is useful for
629 * drivers that subclass the connector state.
632 __drm_atomic_helper_connector_duplicate_state(struct drm_connector
*connector
,
633 struct drm_connector_state
*state
)
635 memcpy(state
, connector
->state
, sizeof(*state
));
637 drm_connector_get(connector
);
638 state
->commit
= NULL
;
640 if (state
->hdr_output_metadata
)
641 drm_property_blob_get(state
->hdr_output_metadata
);
643 /* Don't copy over a writeback job, they are used only once */
644 state
->writeback_job
= NULL
;
646 EXPORT_SYMBOL(__drm_atomic_helper_connector_duplicate_state
);
649 * drm_atomic_helper_connector_duplicate_state - default state duplicate hook
650 * @connector: drm connector
652 * Default connector state duplicate hook for drivers which don't have their own
653 * subclassed connector state structure.
655 struct drm_connector_state
*
656 drm_atomic_helper_connector_duplicate_state(struct drm_connector
*connector
)
658 struct drm_connector_state
*state
;
660 if (WARN_ON(!connector
->state
))
663 state
= kmalloc(sizeof(*state
), GFP_KERNEL
);
665 __drm_atomic_helper_connector_duplicate_state(connector
, state
);
669 EXPORT_SYMBOL(drm_atomic_helper_connector_duplicate_state
);
672 * __drm_atomic_helper_connector_destroy_state - release connector state
673 * @state: connector state object to release
675 * Releases all resources stored in the connector state without actually
676 * freeing the memory of the connector state. This is useful for drivers that
677 * subclass the connector state.
680 __drm_atomic_helper_connector_destroy_state(struct drm_connector_state
*state
)
683 drm_connector_put(state
->connector
);
686 drm_crtc_commit_put(state
->commit
);
688 if (state
->writeback_job
)
689 drm_writeback_cleanup_job(state
->writeback_job
);
691 drm_property_blob_put(state
->hdr_output_metadata
);
693 EXPORT_SYMBOL(__drm_atomic_helper_connector_destroy_state
);
696 * drm_atomic_helper_connector_destroy_state - default state destroy hook
697 * @connector: drm connector
698 * @state: connector state object to release
700 * Default connector state destroy hook for drivers which don't have their own
701 * subclassed connector state structure.
703 void drm_atomic_helper_connector_destroy_state(struct drm_connector
*connector
,
704 struct drm_connector_state
*state
)
706 __drm_atomic_helper_connector_destroy_state(state
);
709 EXPORT_SYMBOL(drm_atomic_helper_connector_destroy_state
);
712 * __drm_atomic_helper_private_obj_duplicate_state - copy atomic private state
714 * @state: new private object state
716 * Copies atomic state from a private objects's current state and resets inferred values.
717 * This is useful for drivers that subclass the private state.
719 void __drm_atomic_helper_private_obj_duplicate_state(struct drm_private_obj
*obj
,
720 struct drm_private_state
*state
)
722 memcpy(state
, obj
->state
, sizeof(*state
));
724 EXPORT_SYMBOL(__drm_atomic_helper_private_obj_duplicate_state
);
727 * __drm_atomic_helper_bridge_duplicate_state() - Copy atomic bridge state
728 * @bridge: bridge object
729 * @state: atomic bridge state
731 * Copies atomic state from a bridge's current state and resets inferred values.
732 * This is useful for drivers that subclass the bridge state.
734 void __drm_atomic_helper_bridge_duplicate_state(struct drm_bridge
*bridge
,
735 struct drm_bridge_state
*state
)
737 __drm_atomic_helper_private_obj_duplicate_state(&bridge
->base
,
739 state
->bridge
= bridge
;
741 EXPORT_SYMBOL(__drm_atomic_helper_bridge_duplicate_state
);
744 * drm_atomic_helper_bridge_duplicate_state() - Duplicate a bridge state object
745 * @bridge: bridge object
747 * Allocates a new bridge state and initializes it with the current bridge
748 * state values. This helper is meant to be used as a bridge
749 * &drm_bridge_funcs.atomic_duplicate_state hook for bridges that don't
750 * subclass the bridge state.
752 struct drm_bridge_state
*
753 drm_atomic_helper_bridge_duplicate_state(struct drm_bridge
*bridge
)
755 struct drm_bridge_state
*new;
757 if (WARN_ON(!bridge
->base
.state
))
760 new = kzalloc(sizeof(*new), GFP_KERNEL
);
762 __drm_atomic_helper_bridge_duplicate_state(bridge
, new);
766 EXPORT_SYMBOL(drm_atomic_helper_bridge_duplicate_state
);
769 * drm_atomic_helper_bridge_destroy_state() - Destroy a bridge state object
770 * @bridge: the bridge this state refers to
771 * @state: bridge state to destroy
773 * Destroys a bridge state previously created by
774 * &drm_atomic_helper_bridge_reset() or
775 * &drm_atomic_helper_bridge_duplicate_state(). This helper is meant to be
776 * used as a bridge &drm_bridge_funcs.atomic_destroy_state hook for bridges
777 * that don't subclass the bridge state.
779 void drm_atomic_helper_bridge_destroy_state(struct drm_bridge
*bridge
,
780 struct drm_bridge_state
*state
)
784 EXPORT_SYMBOL(drm_atomic_helper_bridge_destroy_state
);
787 * __drm_atomic_helper_bridge_reset() - Initialize a bridge state to its
789 * @bridge: the bridge this state refers to
790 * @state: bridge state to initialize
792 * Initializes the bridge state to default values. This is meant to be called
793 * by the bridge &drm_bridge_funcs.atomic_reset hook for bridges that subclass
796 void __drm_atomic_helper_bridge_reset(struct drm_bridge
*bridge
,
797 struct drm_bridge_state
*state
)
799 memset(state
, 0, sizeof(*state
));
800 state
->bridge
= bridge
;
802 EXPORT_SYMBOL(__drm_atomic_helper_bridge_reset
);
805 * drm_atomic_helper_bridge_reset() - Allocate and initialize a bridge state
807 * @bridge: the bridge this state refers to
809 * Allocates the bridge state and initializes it to default values. This helper
810 * is meant to be used as a bridge &drm_bridge_funcs.atomic_reset hook for
811 * bridges that don't subclass the bridge state.
813 struct drm_bridge_state
*
814 drm_atomic_helper_bridge_reset(struct drm_bridge
*bridge
)
816 struct drm_bridge_state
*bridge_state
;
818 bridge_state
= kzalloc(sizeof(*bridge_state
), GFP_KERNEL
);
820 return ERR_PTR(-ENOMEM
);
822 __drm_atomic_helper_bridge_reset(bridge
, bridge_state
);
825 EXPORT_SYMBOL(drm_atomic_helper_bridge_reset
);