Lines Matching +full:default +full:- +full:state

39 #include <linux/dma-fence.h>
42 * DOC: atomic state reset and initialization
45 * and correct atomic software state for all connectors, CRTCs and planes
47 * suspend. One way to solve this is to have a hardware state read-out
48 * infrastructure which reconstructs the full software state (e.g. the i915
51 * The simpler solution is to just reset the software state to everything off,
53 * the atomic helpers provide default reset implementations for all hooks.
55 * On the upside the precise state tracking of atomic simplifies system suspend
63 * __drm_atomic_helper_crtc_state_reset - reset the CRTC state
64 * @crtc_state: atomic CRTC state, must not be NULL
67 * Initializes the newly allocated @crtc_state with default
68 * values. This is useful for drivers that subclass the CRTC state.
74 crtc_state->crtc = crtc; in __drm_atomic_helper_crtc_state_reset()
79 * __drm_atomic_helper_crtc_reset - reset state on CRTC
81 * @crtc_state: CRTC state to assign
84 * the &drm_crtc->state pointer of @crtc, usually required when
88 * This is useful for drivers that subclass the CRTC state.
97 if (drm_dev_has_vblank(crtc->dev)) in __drm_atomic_helper_crtc_reset()
100 crtc->state = crtc_state; in __drm_atomic_helper_crtc_reset()
105 * drm_atomic_helper_crtc_reset - default &drm_crtc_funcs.reset hook for CRTCs
108 * Resets the atomic state for @crtc by freeing the state pointer (which might
109 * be NULL, e.g. at driver load time) and allocating a new empty state object.
114 kzalloc(sizeof(*crtc->state), GFP_KERNEL); in drm_atomic_helper_crtc_reset()
116 if (crtc->state) in drm_atomic_helper_crtc_reset()
117 crtc->funcs->atomic_destroy_state(crtc, crtc->state); in drm_atomic_helper_crtc_reset()
124 * __drm_atomic_helper_crtc_duplicate_state - copy atomic CRTC state
126 * @state: atomic CRTC state
128 * Copies atomic state from a CRTC's current state and resets inferred values.
129 * This is useful for drivers that subclass the CRTC state.
132 struct drm_crtc_state *state) in __drm_atomic_helper_crtc_duplicate_state() argument
134 memcpy(state, crtc->state, sizeof(*state)); in __drm_atomic_helper_crtc_duplicate_state()
136 if (state->mode_blob) in __drm_atomic_helper_crtc_duplicate_state()
137 drm_property_blob_get(state->mode_blob); in __drm_atomic_helper_crtc_duplicate_state()
138 if (state->degamma_lut) in __drm_atomic_helper_crtc_duplicate_state()
139 drm_property_blob_get(state->degamma_lut); in __drm_atomic_helper_crtc_duplicate_state()
140 if (state->ctm) in __drm_atomic_helper_crtc_duplicate_state()
141 drm_property_blob_get(state->ctm); in __drm_atomic_helper_crtc_duplicate_state()
142 if (state->gamma_lut) in __drm_atomic_helper_crtc_duplicate_state()
143 drm_property_blob_get(state->gamma_lut); in __drm_atomic_helper_crtc_duplicate_state()
144 state->mode_changed = false; in __drm_atomic_helper_crtc_duplicate_state()
145 state->active_changed = false; in __drm_atomic_helper_crtc_duplicate_state()
146 state->planes_changed = false; in __drm_atomic_helper_crtc_duplicate_state()
147 state->connectors_changed = false; in __drm_atomic_helper_crtc_duplicate_state()
148 state->color_mgmt_changed = false; in __drm_atomic_helper_crtc_duplicate_state()
149 state->zpos_changed = false; in __drm_atomic_helper_crtc_duplicate_state()
150 state->commit = NULL; in __drm_atomic_helper_crtc_duplicate_state()
151 state->event = NULL; in __drm_atomic_helper_crtc_duplicate_state()
152 state->async_flip = false; in __drm_atomic_helper_crtc_duplicate_state()
155 state->active = drm_atomic_crtc_effectively_active(state); in __drm_atomic_helper_crtc_duplicate_state()
156 state->self_refresh_active = false; in __drm_atomic_helper_crtc_duplicate_state()
161 * drm_atomic_helper_crtc_duplicate_state - default state duplicate hook
164 * Default CRTC state duplicate hook for drivers which don't have their own
165 * subclassed CRTC state structure.
170 struct drm_crtc_state *state; in drm_atomic_helper_crtc_duplicate_state() local
172 if (WARN_ON(!crtc->state)) in drm_atomic_helper_crtc_duplicate_state()
175 state = kmalloc(sizeof(*state), GFP_KERNEL); in drm_atomic_helper_crtc_duplicate_state()
176 if (state) in drm_atomic_helper_crtc_duplicate_state()
177 __drm_atomic_helper_crtc_duplicate_state(crtc, state); in drm_atomic_helper_crtc_duplicate_state()
179 return state; in drm_atomic_helper_crtc_duplicate_state()
184 * __drm_atomic_helper_crtc_destroy_state - release CRTC state
185 * @state: CRTC state object to release
187 * Releases all resources stored in the CRTC state without actually freeing
188 * the memory of the CRTC state. This is useful for drivers that subclass the
189 * CRTC state.
191 void __drm_atomic_helper_crtc_destroy_state(struct drm_crtc_state *state) in __drm_atomic_helper_crtc_destroy_state() argument
193 if (state->commit) { in __drm_atomic_helper_crtc_destroy_state()
195 * In the event that a non-blocking commit returns in __drm_atomic_helper_crtc_destroy_state()
196 * -ERESTARTSYS before the commit_tail work is queued, we will in __drm_atomic_helper_crtc_destroy_state()
200 * state->event may be freed, so we can't directly look at in __drm_atomic_helper_crtc_destroy_state()
201 * state->event->base.completion. in __drm_atomic_helper_crtc_destroy_state()
203 if (state->event && state->commit->abort_completion) in __drm_atomic_helper_crtc_destroy_state()
204 drm_crtc_commit_put(state->commit); in __drm_atomic_helper_crtc_destroy_state()
206 kfree(state->commit->event); in __drm_atomic_helper_crtc_destroy_state()
207 state->commit->event = NULL; in __drm_atomic_helper_crtc_destroy_state()
209 drm_crtc_commit_put(state->commit); in __drm_atomic_helper_crtc_destroy_state()
212 drm_property_blob_put(state->mode_blob); in __drm_atomic_helper_crtc_destroy_state()
213 drm_property_blob_put(state->degamma_lut); in __drm_atomic_helper_crtc_destroy_state()
214 drm_property_blob_put(state->ctm); in __drm_atomic_helper_crtc_destroy_state()
215 drm_property_blob_put(state->gamma_lut); in __drm_atomic_helper_crtc_destroy_state()
220 * drm_atomic_helper_crtc_destroy_state - default state destroy hook
222 * @state: CRTC state object to release
224 * Default CRTC state destroy hook for drivers which don't have their own
225 * subclassed CRTC state structure.
228 struct drm_crtc_state *state) in drm_atomic_helper_crtc_destroy_state() argument
230 __drm_atomic_helper_crtc_destroy_state(state); in drm_atomic_helper_crtc_destroy_state()
231 kfree(state); in drm_atomic_helper_crtc_destroy_state()
236 * __drm_atomic_helper_plane_state_reset - resets plane state to default values
237 * @plane_state: atomic plane state, must not be NULL
240 * Initializes the newly allocated @plane_state with default
241 * values. This is useful for drivers that subclass the CRTC state.
246 plane_state->plane = plane; in __drm_atomic_helper_plane_state_reset()
247 plane_state->rotation = DRM_MODE_ROTATE_0; in __drm_atomic_helper_plane_state_reset()
249 plane_state->alpha = DRM_BLEND_ALPHA_OPAQUE; in __drm_atomic_helper_plane_state_reset()
250 plane_state->pixel_blend_mode = DRM_MODE_BLEND_PREMULTI; in __drm_atomic_helper_plane_state_reset()
255 * __drm_atomic_helper_plane_reset - reset state on plane
257 * @plane_state: plane state to assign
260 * the &drm_crtc->state pointer of @plane, usually required when
264 * This is useful for drivers that subclass the plane state.
272 plane->state = plane_state; in __drm_atomic_helper_plane_reset()
277 * drm_atomic_helper_plane_reset - default &drm_plane_funcs.reset hook for planes
280 * Resets the atomic state for @plane by freeing the state pointer (which might
281 * be NULL, e.g. at driver load time) and allocating a new empty state object.
285 if (plane->state) in drm_atomic_helper_plane_reset()
286 __drm_atomic_helper_plane_destroy_state(plane->state); in drm_atomic_helper_plane_reset()
288 kfree(plane->state); in drm_atomic_helper_plane_reset()
289 plane->state = kzalloc(sizeof(*plane->state), GFP_KERNEL); in drm_atomic_helper_plane_reset()
290 if (plane->state) in drm_atomic_helper_plane_reset()
291 __drm_atomic_helper_plane_reset(plane, plane->state); in drm_atomic_helper_plane_reset()
296 * __drm_atomic_helper_plane_duplicate_state - copy atomic plane state
298 * @state: atomic plane state
300 * Copies atomic state from a plane's current state. This is useful for
301 * drivers that subclass the plane state.
304 struct drm_plane_state *state) in __drm_atomic_helper_plane_duplicate_state() argument
306 memcpy(state, plane->state, sizeof(*state)); in __drm_atomic_helper_plane_duplicate_state()
308 if (state->fb) in __drm_atomic_helper_plane_duplicate_state()
309 drm_framebuffer_get(state->fb); in __drm_atomic_helper_plane_duplicate_state()
311 state->fence = NULL; in __drm_atomic_helper_plane_duplicate_state()
312 state->commit = NULL; in __drm_atomic_helper_plane_duplicate_state()
313 state->fb_damage_clips = NULL; in __drm_atomic_helper_plane_duplicate_state()
318 * drm_atomic_helper_plane_duplicate_state - default state duplicate hook
321 * Default plane state duplicate hook for drivers which don't have their own
322 * subclassed plane state structure.
327 struct drm_plane_state *state; in drm_atomic_helper_plane_duplicate_state() local
329 if (WARN_ON(!plane->state)) in drm_atomic_helper_plane_duplicate_state()
332 state = kmalloc(sizeof(*state), GFP_KERNEL); in drm_atomic_helper_plane_duplicate_state()
333 if (state) in drm_atomic_helper_plane_duplicate_state()
334 __drm_atomic_helper_plane_duplicate_state(plane, state); in drm_atomic_helper_plane_duplicate_state()
336 return state; in drm_atomic_helper_plane_duplicate_state()
341 * __drm_atomic_helper_plane_destroy_state - release plane state
342 * @state: plane state object to release
344 * Releases all resources stored in the plane state without actually freeing
345 * the memory of the plane state. This is useful for drivers that subclass the
346 * plane state.
348 void __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state) in __drm_atomic_helper_plane_destroy_state() argument
350 if (state->fb) in __drm_atomic_helper_plane_destroy_state()
351 drm_framebuffer_put(state->fb); in __drm_atomic_helper_plane_destroy_state()
353 if (state->fence) in __drm_atomic_helper_plane_destroy_state()
354 dma_fence_put(state->fence); in __drm_atomic_helper_plane_destroy_state()
356 if (state->commit) in __drm_atomic_helper_plane_destroy_state()
357 drm_crtc_commit_put(state->commit); in __drm_atomic_helper_plane_destroy_state()
359 drm_property_blob_put(state->fb_damage_clips); in __drm_atomic_helper_plane_destroy_state()
364 * drm_atomic_helper_plane_destroy_state - default state destroy hook
366 * @state: plane state object to release
368 * Default plane state destroy hook for drivers which don't have their own
369 * subclassed plane state structure.
372 struct drm_plane_state *state) in drm_atomic_helper_plane_destroy_state() argument
374 __drm_atomic_helper_plane_destroy_state(state); in drm_atomic_helper_plane_destroy_state()
375 kfree(state); in drm_atomic_helper_plane_destroy_state()
380 * __drm_atomic_helper_connector_state_reset - reset the connector state
381 * @conn_state: atomic connector state, must not be NULL
384 * Initializes the newly allocated @conn_state with default
385 * values. This is useful for drivers that subclass the connector state.
391 conn_state->connector = connector; in __drm_atomic_helper_connector_state_reset()
396 * __drm_atomic_helper_connector_reset - reset state on connector
398 * @conn_state: connector state to assign
401 * the &drm_connector->state pointer of @connector, usually required when
405 * This is useful for drivers that subclass the connector state.
414 connector->state = conn_state; in __drm_atomic_helper_connector_reset()
419 * drm_atomic_helper_connector_reset - default &drm_connector_funcs.reset hook for connectors
422 * Resets the atomic state for @connector by freeing the state pointer (which
423 * might be NULL, e.g. at driver load time) and allocating a new empty state
431 if (connector->state) in drm_atomic_helper_connector_reset()
432 __drm_atomic_helper_connector_destroy_state(connector->state); in drm_atomic_helper_connector_reset()
434 kfree(connector->state); in drm_atomic_helper_connector_reset()
440 * drm_atomic_helper_connector_tv_reset - Resets TV connector properties
443 * Resets the TV-related properties attached to a connector.
447 struct drm_cmdline_mode *cmdline = &connector->cmdline_mode; in drm_atomic_helper_connector_tv_reset()
448 struct drm_connector_state *state = connector->state; in drm_atomic_helper_connector_tv_reset() local
450 state->tv.margins.left = cmdline->tv_margins.left; in drm_atomic_helper_connector_tv_reset()
451 state->tv.margins.right = cmdline->tv_margins.right; in drm_atomic_helper_connector_tv_reset()
452 state->tv.margins.top = cmdline->tv_margins.top; in drm_atomic_helper_connector_tv_reset()
453 state->tv.margins.bottom = cmdline->tv_margins.bottom; in drm_atomic_helper_connector_tv_reset()
458 * __drm_atomic_helper_connector_duplicate_state - copy atomic connector state
460 * @state: atomic connector state
462 * Copies atomic state from a connector's current state. This is useful for
463 * drivers that subclass the connector state.
467 struct drm_connector_state *state) in __drm_atomic_helper_connector_duplicate_state() argument
469 memcpy(state, connector->state, sizeof(*state)); in __drm_atomic_helper_connector_duplicate_state()
470 if (state->crtc) in __drm_atomic_helper_connector_duplicate_state()
472 state->commit = NULL; in __drm_atomic_helper_connector_duplicate_state()
474 if (state->hdr_output_metadata) in __drm_atomic_helper_connector_duplicate_state()
475 drm_property_blob_get(state->hdr_output_metadata); in __drm_atomic_helper_connector_duplicate_state()
478 state->writeback_job = NULL; in __drm_atomic_helper_connector_duplicate_state()
483 * drm_atomic_helper_connector_duplicate_state - default state duplicate hook
486 * Default connector state duplicate hook for drivers which don't have their own
487 * subclassed connector state structure.
492 struct drm_connector_state *state; in drm_atomic_helper_connector_duplicate_state() local
494 if (WARN_ON(!connector->state)) in drm_atomic_helper_connector_duplicate_state()
497 state = kmalloc(sizeof(*state), GFP_KERNEL); in drm_atomic_helper_connector_duplicate_state()
498 if (state) in drm_atomic_helper_connector_duplicate_state()
499 __drm_atomic_helper_connector_duplicate_state(connector, state); in drm_atomic_helper_connector_duplicate_state()
501 return state; in drm_atomic_helper_connector_duplicate_state()
506 * __drm_atomic_helper_connector_destroy_state - release connector state
507 * @state: connector state object to release
509 * Releases all resources stored in the connector state without actually
510 * freeing the memory of the connector state. This is useful for drivers that
511 * subclass the connector state.
514 __drm_atomic_helper_connector_destroy_state(struct drm_connector_state *state) in __drm_atomic_helper_connector_destroy_state() argument
516 if (state->crtc) in __drm_atomic_helper_connector_destroy_state()
517 drm_connector_put(state->connector); in __drm_atomic_helper_connector_destroy_state()
519 if (state->commit) in __drm_atomic_helper_connector_destroy_state()
520 drm_crtc_commit_put(state->commit); in __drm_atomic_helper_connector_destroy_state()
522 if (state->writeback_job) in __drm_atomic_helper_connector_destroy_state()
523 drm_writeback_cleanup_job(state->writeback_job); in __drm_atomic_helper_connector_destroy_state()
525 drm_property_blob_put(state->hdr_output_metadata); in __drm_atomic_helper_connector_destroy_state()
530 * drm_atomic_helper_connector_destroy_state - default state destroy hook
532 * @state: connector state object to release
534 * Default connector state destroy hook for drivers which don't have their own
535 * subclassed connector state structure.
538 struct drm_connector_state *state) in drm_atomic_helper_connector_destroy_state() argument
540 __drm_atomic_helper_connector_destroy_state(state); in drm_atomic_helper_connector_destroy_state()
541 kfree(state); in drm_atomic_helper_connector_destroy_state()
546 * __drm_atomic_helper_private_duplicate_state - copy atomic private state
548 * @state: new private object state
550 * Copies atomic state from a private objects's current state and resets inferred values.
551 * This is useful for drivers that subclass the private state.
554 struct drm_private_state *state) in __drm_atomic_helper_private_obj_duplicate_state() argument
556 memcpy(state, obj->state, sizeof(*state)); in __drm_atomic_helper_private_obj_duplicate_state()
561 * __drm_atomic_helper_bridge_duplicate_state() - Copy atomic bridge state
563 * @state: atomic bridge state
565 * Copies atomic state from a bridge's current state and resets inferred values.
566 * This is useful for drivers that subclass the bridge state.
569 struct drm_bridge_state *state) in __drm_atomic_helper_bridge_duplicate_state() argument
571 __drm_atomic_helper_private_obj_duplicate_state(&bridge->base, in __drm_atomic_helper_bridge_duplicate_state()
572 &state->base); in __drm_atomic_helper_bridge_duplicate_state()
573 state->bridge = bridge; in __drm_atomic_helper_bridge_duplicate_state()
578 * drm_atomic_helper_bridge_duplicate_state() - Duplicate a bridge state object
581 * Allocates a new bridge state and initializes it with the current bridge
582 * state values. This helper is meant to be used as a bridge
584 * subclass the bridge state.
591 if (WARN_ON(!bridge->base.state)) in drm_atomic_helper_bridge_duplicate_state()
603 * drm_atomic_helper_bridge_destroy_state() - Destroy a bridge state object
604 * @bridge: the bridge this state refers to
605 * @state: bridge state to destroy
607 * Destroys a bridge state previously created by
611 * that don't subclass the bridge state.
614 struct drm_bridge_state *state) in drm_atomic_helper_bridge_destroy_state() argument
616 kfree(state); in drm_atomic_helper_bridge_destroy_state()
621 * __drm_atomic_helper_bridge_reset() - Initialize a bridge state to its
622 * default
623 * @bridge: the bridge this state refers to
624 * @state: bridge state to initialize
626 * Initializes the bridge state to default values. This is meant to be called
628 * the bridge state.
631 struct drm_bridge_state *state) in __drm_atomic_helper_bridge_reset() argument
633 memset(state, 0, sizeof(*state)); in __drm_atomic_helper_bridge_reset()
634 state->bridge = bridge; in __drm_atomic_helper_bridge_reset()
639 * drm_atomic_helper_bridge_reset() - Allocate and initialize a bridge state
640 * to its default
641 * @bridge: the bridge this state refers to
643 * Allocates the bridge state and initializes it to default values. This helper
645 * bridges that don't subclass the bridge state.
654 return ERR_PTR(-ENOMEM); in drm_atomic_helper_bridge_reset()