Lines Matching +full:- +full:state

41 #include <linux/dma-fence.h>
44 * DOC: atomic state reset and initialization
47 * and correct atomic software state for all connectors, CRTCs and planes
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,
57 * On the upside the precise state tracking of atomic simplifies system suspend
65 * __drm_atomic_helper_crtc_state_reset - reset the CRTC state
66 * @crtc_state: atomic CRTC state, must not be NULL
70 * values. This is useful for drivers that subclass the CRTC state.
76 crtc_state->crtc = crtc; in __drm_atomic_helper_crtc_state_reset()
81 * __drm_atomic_helper_crtc_reset - reset state on CRTC
83 * @crtc_state: CRTC state to assign
86 * the &drm_crtc->state pointer of @crtc, usually required when
90 * This is useful for drivers that subclass the CRTC state.
99 if (drm_dev_has_vblank(crtc->dev)) in __drm_atomic_helper_crtc_reset()
102 crtc->state = crtc_state; in __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.
116 kzalloc(sizeof(*crtc->state), GFP_KERNEL); in drm_atomic_helper_crtc_reset()
118 if (crtc->state) in drm_atomic_helper_crtc_reset()
119 crtc->funcs->atomic_destroy_state(crtc, crtc->state); in 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.
134 struct drm_crtc_state *state) in __drm_atomic_helper_crtc_duplicate_state() argument
136 memcpy(state, crtc->state, sizeof(*state)); in __drm_atomic_helper_crtc_duplicate_state()
138 if (state->mode_blob) in __drm_atomic_helper_crtc_duplicate_state()
139 drm_property_blob_get(state->mode_blob); in __drm_atomic_helper_crtc_duplicate_state()
140 if (state->degamma_lut) in __drm_atomic_helper_crtc_duplicate_state()
141 drm_property_blob_get(state->degamma_lut); in __drm_atomic_helper_crtc_duplicate_state()
142 if (state->ctm) in __drm_atomic_helper_crtc_duplicate_state()
143 drm_property_blob_get(state->ctm); in __drm_atomic_helper_crtc_duplicate_state()
144 if (state->gamma_lut) in __drm_atomic_helper_crtc_duplicate_state()
145 drm_property_blob_get(state->gamma_lut); in __drm_atomic_helper_crtc_duplicate_state()
146 state->mode_changed = false; in __drm_atomic_helper_crtc_duplicate_state()
147 state->active_changed = false; in __drm_atomic_helper_crtc_duplicate_state()
148 state->planes_changed = false; in __drm_atomic_helper_crtc_duplicate_state()
149 state->connectors_changed = false; in __drm_atomic_helper_crtc_duplicate_state()
150 state->color_mgmt_changed = false; in __drm_atomic_helper_crtc_duplicate_state()
151 state->zpos_changed = false; in __drm_atomic_helper_crtc_duplicate_state()
152 state->commit = NULL; in __drm_atomic_helper_crtc_duplicate_state()
153 state->event = NULL; in __drm_atomic_helper_crtc_duplicate_state()
154 state->async_flip = false; in __drm_atomic_helper_crtc_duplicate_state()
157 state->active = drm_atomic_crtc_effectively_active(state); in __drm_atomic_helper_crtc_duplicate_state()
158 state->self_refresh_active = false; in __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.
172 struct drm_crtc_state *state; in drm_atomic_helper_crtc_duplicate_state() local
174 if (WARN_ON(!crtc->state)) in drm_atomic_helper_crtc_duplicate_state()
177 state = kmalloc(sizeof(*state), GFP_KERNEL); in drm_atomic_helper_crtc_duplicate_state()
178 if (state) in drm_atomic_helper_crtc_duplicate_state()
179 __drm_atomic_helper_crtc_duplicate_state(crtc, state); in drm_atomic_helper_crtc_duplicate_state()
181 return state; in 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
191 * CRTC state.
193 void __drm_atomic_helper_crtc_destroy_state(struct drm_crtc_state *state) in __drm_atomic_helper_crtc_destroy_state() argument
195 if (state->commit) { in __drm_atomic_helper_crtc_destroy_state()
197 * In the event that a non-blocking commit returns in __drm_atomic_helper_crtc_destroy_state()
198 * -ERESTARTSYS before the commit_tail work is queued, we will in __drm_atomic_helper_crtc_destroy_state()
202 * state->event may be freed, so we can't directly look at in __drm_atomic_helper_crtc_destroy_state()
203 * state->event->base.completion. in __drm_atomic_helper_crtc_destroy_state()
205 if (state->event && state->commit->abort_completion) in __drm_atomic_helper_crtc_destroy_state()
206 drm_crtc_commit_put(state->commit); in __drm_atomic_helper_crtc_destroy_state()
208 kfree(state->commit->event); in __drm_atomic_helper_crtc_destroy_state()
209 state->commit->event = NULL; in __drm_atomic_helper_crtc_destroy_state()
211 drm_crtc_commit_put(state->commit); in __drm_atomic_helper_crtc_destroy_state()
214 drm_property_blob_put(state->mode_blob); in __drm_atomic_helper_crtc_destroy_state()
215 drm_property_blob_put(state->degamma_lut); in __drm_atomic_helper_crtc_destroy_state()
216 drm_property_blob_put(state->ctm); in __drm_atomic_helper_crtc_destroy_state()
217 drm_property_blob_put(state->gamma_lut); in __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.
230 struct drm_crtc_state *state) in drm_atomic_helper_crtc_destroy_state() argument
232 __drm_atomic_helper_crtc_destroy_state(state); in drm_atomic_helper_crtc_destroy_state()
233 kfree(state); in 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
243 * values. This is useful for drivers that subclass the CRTC state.
250 plane_state->plane = plane; in __drm_atomic_helper_plane_state_reset()
251 plane_state->rotation = DRM_MODE_ROTATE_0; in __drm_atomic_helper_plane_state_reset()
253 plane_state->alpha = DRM_BLEND_ALPHA_OPAQUE; in __drm_atomic_helper_plane_state_reset()
254 plane_state->pixel_blend_mode = DRM_MODE_BLEND_PREMULTI; in __drm_atomic_helper_plane_state_reset()
256 if (plane->color_encoding_property) { in __drm_atomic_helper_plane_state_reset()
257 if (!drm_object_property_get_default_value(&plane->base, in __drm_atomic_helper_plane_state_reset()
258 plane->color_encoding_property, in __drm_atomic_helper_plane_state_reset()
260 plane_state->color_encoding = val; in __drm_atomic_helper_plane_state_reset()
263 if (plane->color_range_property) { in __drm_atomic_helper_plane_state_reset()
264 if (!drm_object_property_get_default_value(&plane->base, in __drm_atomic_helper_plane_state_reset()
265 plane->color_range_property, in __drm_atomic_helper_plane_state_reset()
267 plane_state->color_range = val; in __drm_atomic_helper_plane_state_reset()
270 if (plane->zpos_property) { in __drm_atomic_helper_plane_state_reset()
271 if (!drm_object_property_get_default_value(&plane->base, in __drm_atomic_helper_plane_state_reset()
272 plane->zpos_property, in __drm_atomic_helper_plane_state_reset()
274 plane_state->zpos = val; in __drm_atomic_helper_plane_state_reset()
275 plane_state->normalized_zpos = val; in __drm_atomic_helper_plane_state_reset()
282 * __drm_atomic_helper_plane_reset - reset state on plane
284 * @plane_state: plane state to assign
287 * the &drm_crtc->state pointer of @plane, usually required when
291 * This is useful for drivers that subclass the plane state.
299 plane->state = plane_state; in __drm_atomic_helper_plane_reset()
304 * drm_atomic_helper_plane_reset - default &drm_plane_funcs.reset hook for planes
307 * Resets the atomic state for @plane by freeing the state pointer (which might
308 * be NULL, e.g. at driver load time) and allocating a new empty state object.
312 if (plane->state) in drm_atomic_helper_plane_reset()
313 __drm_atomic_helper_plane_destroy_state(plane->state); in drm_atomic_helper_plane_reset()
315 kfree(plane->state); in drm_atomic_helper_plane_reset()
316 plane->state = kzalloc(sizeof(*plane->state), GFP_KERNEL); in drm_atomic_helper_plane_reset()
317 if (plane->state) in drm_atomic_helper_plane_reset()
318 __drm_atomic_helper_plane_reset(plane, plane->state); in drm_atomic_helper_plane_reset()
323 * __drm_atomic_helper_plane_duplicate_state - copy atomic plane state
325 * @state: atomic plane state
327 * Copies atomic state from a plane's current state. This is useful for
328 * drivers that subclass the plane state.
331 struct drm_plane_state *state) in __drm_atomic_helper_plane_duplicate_state() argument
333 memcpy(state, plane->state, sizeof(*state)); in __drm_atomic_helper_plane_duplicate_state()
335 if (state->fb) in __drm_atomic_helper_plane_duplicate_state()
336 drm_framebuffer_get(state->fb); in __drm_atomic_helper_plane_duplicate_state()
338 state->fence = NULL; in __drm_atomic_helper_plane_duplicate_state()
339 state->commit = NULL; in __drm_atomic_helper_plane_duplicate_state()
340 state->fb_damage_clips = NULL; in __drm_atomic_helper_plane_duplicate_state()
345 * drm_atomic_helper_plane_duplicate_state - default state duplicate hook
348 * Default plane state duplicate hook for drivers which don't have their own
349 * subclassed plane state structure.
354 struct drm_plane_state *state; in drm_atomic_helper_plane_duplicate_state() local
356 if (WARN_ON(!plane->state)) in drm_atomic_helper_plane_duplicate_state()
359 state = kmalloc(sizeof(*state), GFP_KERNEL); in drm_atomic_helper_plane_duplicate_state()
360 if (state) in drm_atomic_helper_plane_duplicate_state()
361 __drm_atomic_helper_plane_duplicate_state(plane, state); in drm_atomic_helper_plane_duplicate_state()
363 return state; in drm_atomic_helper_plane_duplicate_state()
368 * __drm_atomic_helper_plane_destroy_state - release plane state
369 * @state: plane state object to release
371 * Releases all resources stored in the plane state without actually freeing
372 * the memory of the plane state. This is useful for drivers that subclass the
373 * plane state.
375 void __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state) in __drm_atomic_helper_plane_destroy_state() argument
377 if (state->fb) in __drm_atomic_helper_plane_destroy_state()
378 drm_framebuffer_put(state->fb); in __drm_atomic_helper_plane_destroy_state()
380 if (state->fence) in __drm_atomic_helper_plane_destroy_state()
381 dma_fence_put(state->fence); in __drm_atomic_helper_plane_destroy_state()
383 if (state->commit) in __drm_atomic_helper_plane_destroy_state()
384 drm_crtc_commit_put(state->commit); in __drm_atomic_helper_plane_destroy_state()
386 drm_property_blob_put(state->fb_damage_clips); in __drm_atomic_helper_plane_destroy_state()
391 * drm_atomic_helper_plane_destroy_state - default state destroy hook
393 * @state: plane state object to release
395 * Default plane state destroy hook for drivers which don't have their own
396 * subclassed plane state structure.
399 struct drm_plane_state *state) in drm_atomic_helper_plane_destroy_state() argument
401 __drm_atomic_helper_plane_destroy_state(state); in drm_atomic_helper_plane_destroy_state()
402 kfree(state); in drm_atomic_helper_plane_destroy_state()
407 * __drm_atomic_helper_connector_state_reset - reset the connector state
408 * @conn_state: atomic connector state, must not be NULL
412 * values. This is useful for drivers that subclass the connector state.
418 conn_state->connector = connector; in __drm_atomic_helper_connector_state_reset()
423 * __drm_atomic_helper_connector_reset - reset state on connector
425 * @conn_state: connector state to assign
428 * the &drm_connector->state pointer of @connector, usually required when
432 * This is useful for drivers that subclass the connector state.
441 connector->state = conn_state; in __drm_atomic_helper_connector_reset()
446 * drm_atomic_helper_connector_reset - default &drm_connector_funcs.reset hook for connectors
449 * Resets the atomic state for @connector by freeing the state pointer (which
450 * might be NULL, e.g. at driver load time) and allocating a new empty state
458 if (connector->state) in drm_atomic_helper_connector_reset()
459 __drm_atomic_helper_connector_destroy_state(connector->state); in drm_atomic_helper_connector_reset()
461 kfree(connector->state); in drm_atomic_helper_connector_reset()
467 * drm_atomic_helper_connector_tv_reset - Resets TV connector properties
470 * Resets the TV-related properties attached to a connector.
474 struct drm_cmdline_mode *cmdline = &connector->cmdline_mode; in drm_atomic_helper_connector_tv_reset()
475 struct drm_connector_state *state = connector->state; in drm_atomic_helper_connector_tv_reset() local
477 state->tv.margins.left = cmdline->tv_margins.left; in drm_atomic_helper_connector_tv_reset()
478 state->tv.margins.right = cmdline->tv_margins.right; in drm_atomic_helper_connector_tv_reset()
479 state->tv.margins.top = cmdline->tv_margins.top; in drm_atomic_helper_connector_tv_reset()
480 state->tv.margins.bottom = cmdline->tv_margins.bottom; in drm_atomic_helper_connector_tv_reset()
485 * __drm_atomic_helper_connector_duplicate_state - copy atomic connector state
487 * @state: atomic connector state
489 * Copies atomic state from a connector's current state. This is useful for
490 * drivers that subclass the connector state.
494 struct drm_connector_state *state) in __drm_atomic_helper_connector_duplicate_state() argument
496 memcpy(state, connector->state, sizeof(*state)); in __drm_atomic_helper_connector_duplicate_state()
497 if (state->crtc) in __drm_atomic_helper_connector_duplicate_state()
499 state->commit = NULL; in __drm_atomic_helper_connector_duplicate_state()
501 if (state->hdr_output_metadata) in __drm_atomic_helper_connector_duplicate_state()
502 drm_property_blob_get(state->hdr_output_metadata); in __drm_atomic_helper_connector_duplicate_state()
505 state->writeback_job = NULL; in __drm_atomic_helper_connector_duplicate_state()
510 * drm_atomic_helper_connector_duplicate_state - default state duplicate hook
513 * Default connector state duplicate hook for drivers which don't have their own
514 * subclassed connector state structure.
519 struct drm_connector_state *state; in drm_atomic_helper_connector_duplicate_state() local
521 if (WARN_ON(!connector->state)) in drm_atomic_helper_connector_duplicate_state()
524 state = kmalloc(sizeof(*state), GFP_KERNEL); in drm_atomic_helper_connector_duplicate_state()
525 if (state) in drm_atomic_helper_connector_duplicate_state()
526 __drm_atomic_helper_connector_duplicate_state(connector, state); in drm_atomic_helper_connector_duplicate_state()
528 return state; in drm_atomic_helper_connector_duplicate_state()
533 * __drm_atomic_helper_connector_destroy_state - release connector state
534 * @state: connector state object to release
536 * Releases all resources stored in the connector state without actually
537 * freeing the memory of the connector state. This is useful for drivers that
538 * subclass the connector state.
541 __drm_atomic_helper_connector_destroy_state(struct drm_connector_state *state) in __drm_atomic_helper_connector_destroy_state() argument
543 if (state->crtc) in __drm_atomic_helper_connector_destroy_state()
544 drm_connector_put(state->connector); in __drm_atomic_helper_connector_destroy_state()
546 if (state->commit) in __drm_atomic_helper_connector_destroy_state()
547 drm_crtc_commit_put(state->commit); in __drm_atomic_helper_connector_destroy_state()
549 if (state->writeback_job) in __drm_atomic_helper_connector_destroy_state()
550 drm_writeback_cleanup_job(state->writeback_job); in __drm_atomic_helper_connector_destroy_state()
552 drm_property_blob_put(state->hdr_output_metadata); in __drm_atomic_helper_connector_destroy_state()
557 * drm_atomic_helper_connector_destroy_state - default state destroy hook
559 * @state: connector state object to release
561 * Default connector state destroy hook for drivers which don't have their own
562 * subclassed connector state structure.
565 struct drm_connector_state *state) in drm_atomic_helper_connector_destroy_state() argument
567 __drm_atomic_helper_connector_destroy_state(state); in drm_atomic_helper_connector_destroy_state()
568 kfree(state); in drm_atomic_helper_connector_destroy_state()
573 * __drm_atomic_helper_private_obj_duplicate_state - copy atomic private state
575 * @state: new private object state
577 * Copies atomic state from a private objects's current state and resets inferred values.
578 * This is useful for drivers that subclass the private state.
581 struct drm_private_state *state) in __drm_atomic_helper_private_obj_duplicate_state() argument
583 memcpy(state, obj->state, sizeof(*state)); in __drm_atomic_helper_private_obj_duplicate_state()
588 * __drm_atomic_helper_bridge_duplicate_state() - Copy atomic bridge state
590 * @state: atomic bridge state
592 * Copies atomic state from a bridge's current state and resets inferred values.
593 * This is useful for drivers that subclass the bridge state.
596 struct drm_bridge_state *state) in __drm_atomic_helper_bridge_duplicate_state() argument
598 __drm_atomic_helper_private_obj_duplicate_state(&bridge->base, in __drm_atomic_helper_bridge_duplicate_state()
599 &state->base); in __drm_atomic_helper_bridge_duplicate_state()
600 state->bridge = bridge; in __drm_atomic_helper_bridge_duplicate_state()
605 * drm_atomic_helper_bridge_duplicate_state() - Duplicate a bridge state object
608 * Allocates a new bridge state and initializes it with the current bridge
609 * state values. This helper is meant to be used as a bridge
611 * subclass the bridge state.
618 if (WARN_ON(!bridge->base.state)) in drm_atomic_helper_bridge_duplicate_state()
630 * drm_atomic_helper_bridge_destroy_state() - Destroy a bridge state object
631 * @bridge: the bridge this state refers to
632 * @state: bridge state to destroy
634 * Destroys a bridge state previously created by
638 * that don't subclass the bridge state.
641 struct drm_bridge_state *state) in drm_atomic_helper_bridge_destroy_state() argument
643 kfree(state); in drm_atomic_helper_bridge_destroy_state()
648 * __drm_atomic_helper_bridge_reset() - Initialize a bridge state to its
650 * @bridge: the bridge this state refers to
651 * @state: bridge state to initialize
653 * Initializes the bridge state to default values. This is meant to be called
655 * the bridge state.
658 struct drm_bridge_state *state) in __drm_atomic_helper_bridge_reset() argument
660 memset(state, 0, sizeof(*state)); in __drm_atomic_helper_bridge_reset()
661 state->bridge = bridge; in __drm_atomic_helper_bridge_reset()
666 * drm_atomic_helper_bridge_reset() - Allocate and initialize a bridge state
668 * @bridge: the bridge this state refers to
670 * Allocates the bridge state and initializes it to default values. This helper
672 * bridges that don't subclass the bridge state.
681 return ERR_PTR(-ENOMEM); in drm_atomic_helper_bridge_reset()