Lines Matching +full:- +full:state

4  * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
59 * drm_crtc_commit_wait - Waits for a commit to complete
76 ret = wait_for_completion_timeout(&commit->hw_done, timeout); in drm_crtc_commit_wait()
78 drm_err(commit->crtc->dev, "hw_done timed out\n"); in drm_crtc_commit_wait()
79 return -ETIMEDOUT; in drm_crtc_commit_wait()
86 ret = wait_for_completion_timeout(&commit->flip_done, timeout); in drm_crtc_commit_wait()
88 drm_err(commit->crtc->dev, "flip_done timed out\n"); in drm_crtc_commit_wait()
89 return -ETIMEDOUT; in drm_crtc_commit_wait()
97 * drm_atomic_state_default_release -
99 * @state: atomic state
105 void drm_atomic_state_default_release(struct drm_atomic_state *state) in drm_atomic_state_default_release() argument
107 kfree(state->connectors); in drm_atomic_state_default_release()
108 kfree(state->crtcs); in drm_atomic_state_default_release()
109 kfree(state->planes); in drm_atomic_state_default_release()
110 kfree(state->private_objs); in drm_atomic_state_default_release()
115 * drm_atomic_state_init - init new atomic state
117 * @state: atomic state
119 * Default implementation for filling in a new atomic state.
124 drm_atomic_state_init(struct drm_device *dev, struct drm_atomic_state *state) in drm_atomic_state_init() argument
126 kref_init(&state->ref); in drm_atomic_state_init()
131 state->allow_modeset = true; in drm_atomic_state_init()
133 state->crtcs = kcalloc(dev->mode_config.num_crtc, in drm_atomic_state_init()
134 sizeof(*state->crtcs), GFP_KERNEL); in drm_atomic_state_init()
135 if (!state->crtcs) in drm_atomic_state_init()
137 state->planes = kcalloc(dev->mode_config.num_total_plane, in drm_atomic_state_init()
138 sizeof(*state->planes), GFP_KERNEL); in drm_atomic_state_init()
139 if (!state->planes) in drm_atomic_state_init()
148 state->dev = dev; in drm_atomic_state_init()
150 drm_dbg_atomic(dev, "Allocated atomic state %p\n", state); in drm_atomic_state_init()
154 drm_atomic_state_default_release(state); in drm_atomic_state_init()
155 return -ENOMEM; in drm_atomic_state_init()
160 * drm_atomic_state_alloc - allocate atomic state
163 * This allocates an empty atomic state to track updates.
168 struct drm_mode_config *config = &dev->mode_config; in drm_atomic_state_alloc()
170 if (!config->funcs->atomic_state_alloc) { in drm_atomic_state_alloc()
171 struct drm_atomic_state *state; in drm_atomic_state_alloc() local
173 state = kzalloc(sizeof(*state), GFP_KERNEL); in drm_atomic_state_alloc()
174 if (!state) in drm_atomic_state_alloc()
176 if (drm_atomic_state_init(dev, state) < 0) { in drm_atomic_state_alloc()
177 kfree(state); in drm_atomic_state_alloc()
180 return state; in drm_atomic_state_alloc()
183 return config->funcs->atomic_state_alloc(dev); in drm_atomic_state_alloc()
188 * drm_atomic_state_default_clear - clear base atomic state
189 * @state: atomic state
191 * Default implementation for clearing atomic state.
195 void drm_atomic_state_default_clear(struct drm_atomic_state *state) in drm_atomic_state_default_clear() argument
197 struct drm_device *dev = state->dev; in drm_atomic_state_default_clear()
198 struct drm_mode_config *config = &dev->mode_config; in drm_atomic_state_default_clear()
201 drm_dbg_atomic(dev, "Clearing atomic state %p\n", state); in drm_atomic_state_default_clear()
203 for (i = 0; i < state->num_connector; i++) { in drm_atomic_state_default_clear()
204 struct drm_connector *connector = state->connectors[i].ptr; in drm_atomic_state_default_clear()
209 connector->funcs->atomic_destroy_state(connector, in drm_atomic_state_default_clear()
210 state->connectors[i].state); in drm_atomic_state_default_clear()
211 state->connectors[i].ptr = NULL; in drm_atomic_state_default_clear()
212 state->connectors[i].state = NULL; in drm_atomic_state_default_clear()
213 state->connectors[i].old_state = NULL; in drm_atomic_state_default_clear()
214 state->connectors[i].new_state = NULL; in drm_atomic_state_default_clear()
218 for (i = 0; i < config->num_crtc; i++) { in drm_atomic_state_default_clear()
219 struct drm_crtc *crtc = state->crtcs[i].ptr; in drm_atomic_state_default_clear()
224 crtc->funcs->atomic_destroy_state(crtc, in drm_atomic_state_default_clear()
225 state->crtcs[i].state); in drm_atomic_state_default_clear()
227 state->crtcs[i].ptr = NULL; in drm_atomic_state_default_clear()
228 state->crtcs[i].state = NULL; in drm_atomic_state_default_clear()
229 state->crtcs[i].old_state = NULL; in drm_atomic_state_default_clear()
230 state->crtcs[i].new_state = NULL; in drm_atomic_state_default_clear()
232 if (state->crtcs[i].commit) { in drm_atomic_state_default_clear()
233 drm_crtc_commit_put(state->crtcs[i].commit); in drm_atomic_state_default_clear()
234 state->crtcs[i].commit = NULL; in drm_atomic_state_default_clear()
238 for (i = 0; i < config->num_total_plane; i++) { in drm_atomic_state_default_clear()
239 struct drm_plane *plane = state->planes[i].ptr; in drm_atomic_state_default_clear()
244 plane->funcs->atomic_destroy_state(plane, in drm_atomic_state_default_clear()
245 state->planes[i].state); in drm_atomic_state_default_clear()
246 state->planes[i].ptr = NULL; in drm_atomic_state_default_clear()
247 state->planes[i].state = NULL; in drm_atomic_state_default_clear()
248 state->planes[i].old_state = NULL; in drm_atomic_state_default_clear()
249 state->planes[i].new_state = NULL; in drm_atomic_state_default_clear()
252 for (i = 0; i < state->num_private_objs; i++) { in drm_atomic_state_default_clear()
253 struct drm_private_obj *obj = state->private_objs[i].ptr; in drm_atomic_state_default_clear()
255 obj->funcs->atomic_destroy_state(obj, in drm_atomic_state_default_clear()
256 state->private_objs[i].state); in drm_atomic_state_default_clear()
257 state->private_objs[i].ptr = NULL; in drm_atomic_state_default_clear()
258 state->private_objs[i].state = NULL; in drm_atomic_state_default_clear()
259 state->private_objs[i].old_state = NULL; in drm_atomic_state_default_clear()
260 state->private_objs[i].new_state = NULL; in drm_atomic_state_default_clear()
262 state->num_private_objs = 0; in drm_atomic_state_default_clear()
264 if (state->fake_commit) { in drm_atomic_state_default_clear()
265 drm_crtc_commit_put(state->fake_commit); in drm_atomic_state_default_clear()
266 state->fake_commit = NULL; in drm_atomic_state_default_clear()
272 * drm_atomic_state_clear - clear state object
273 * @state: atomic state
277 * configuration. Which means that all the state assembled in @state is no
278 * longer an atomic update to the current state, but to some arbitrary earlier
279 * state. Which could break assumptions the driver's
282 * Hence we must clear all cached state and completely start over, using this
285 void drm_atomic_state_clear(struct drm_atomic_state *state) in drm_atomic_state_clear() argument
287 struct drm_device *dev = state->dev; in drm_atomic_state_clear()
288 struct drm_mode_config *config = &dev->mode_config; in drm_atomic_state_clear()
290 if (config->funcs->atomic_state_clear) in drm_atomic_state_clear()
291 config->funcs->atomic_state_clear(state); in drm_atomic_state_clear()
293 drm_atomic_state_default_clear(state); in drm_atomic_state_clear()
298 * __drm_atomic_state_free - free all memory for an atomic state
299 * @ref: This atomic state to deallocate
301 * This frees all memory associated with an atomic state, including all the
302 * per-object state for planes, CRTCs and connectors.
306 struct drm_atomic_state *state = container_of(ref, typeof(*state), ref); in __drm_atomic_state_free() local
307 struct drm_device *dev = state->dev; in __drm_atomic_state_free()
308 struct drm_mode_config *config = &dev->mode_config; in __drm_atomic_state_free()
310 drm_atomic_state_clear(state); in __drm_atomic_state_free()
312 drm_dbg_atomic(state->dev, "Freeing atomic state %p\n", state); in __drm_atomic_state_free()
314 if (config->funcs->atomic_state_free) { in __drm_atomic_state_free()
315 config->funcs->atomic_state_free(state); in __drm_atomic_state_free()
317 drm_atomic_state_default_release(state); in __drm_atomic_state_free()
318 kfree(state); in __drm_atomic_state_free()
326 * drm_atomic_get_crtc_state - get CRTC state
327 * @state: global atomic state object
328 * @crtc: CRTC to get state object for
330 * This function returns the CRTC state for the given CRTC, allocating it if
331 * needed. It will also grab the relevant CRTC lock to make sure that the state
334 * WARNING: Drivers may only add new CRTC states to a @state if
335 * drm_atomic_state.allow_modeset is set, or if it's a driver-internal commit
339 * Either the allocated state or the error code encoded into the pointer. When
344 drm_atomic_get_crtc_state(struct drm_atomic_state *state, in drm_atomic_get_crtc_state() argument
350 WARN_ON(!state->acquire_ctx); in drm_atomic_get_crtc_state()
352 crtc_state = drm_atomic_get_existing_crtc_state(state, crtc); in drm_atomic_get_crtc_state()
356 ret = drm_modeset_lock(&crtc->mutex, state->acquire_ctx); in drm_atomic_get_crtc_state()
360 crtc_state = crtc->funcs->atomic_duplicate_state(crtc); in drm_atomic_get_crtc_state()
362 return ERR_PTR(-ENOMEM); in drm_atomic_get_crtc_state()
364 state->crtcs[index].state = crtc_state; in drm_atomic_get_crtc_state()
365 state->crtcs[index].old_state = crtc->state; in drm_atomic_get_crtc_state()
366 state->crtcs[index].new_state = crtc_state; in drm_atomic_get_crtc_state()
367 state->crtcs[index].ptr = crtc; in drm_atomic_get_crtc_state()
368 crtc_state->state = state; in drm_atomic_get_crtc_state()
370 drm_dbg_atomic(state->dev, "Added [CRTC:%d:%s] %p state to %p\n", in drm_atomic_get_crtc_state()
371 crtc->base.id, crtc->name, crtc_state, state); in drm_atomic_get_crtc_state()
380 struct drm_crtc *crtc = new_crtc_state->crtc; in drm_atomic_crtc_check()
385 * should be checked in driver's crtc->atomic_check() vfunc. in drm_atomic_crtc_check()
387 * TODO: Add generic modeset state checks once we support those. in drm_atomic_crtc_check()
390 if (new_crtc_state->active && !new_crtc_state->enable) { in drm_atomic_crtc_check()
391 drm_dbg_atomic(crtc->dev, in drm_atomic_crtc_check()
393 crtc->base.id, crtc->name); in drm_atomic_crtc_check()
394 return -EINVAL; in drm_atomic_crtc_check()
397 /* The state->enable vs. state->mode_blob checks can be WARN_ON, in drm_atomic_crtc_check()
398 * as this is a kernel-internal detail that userspace should never in drm_atomic_crtc_check()
401 if (drm_core_check_feature(crtc->dev, DRIVER_ATOMIC) && in drm_atomic_crtc_check()
402 WARN_ON(new_crtc_state->enable && !new_crtc_state->mode_blob)) { in drm_atomic_crtc_check()
403 drm_dbg_atomic(crtc->dev, in drm_atomic_crtc_check()
405 crtc->base.id, crtc->name); in drm_atomic_crtc_check()
406 return -EINVAL; in drm_atomic_crtc_check()
409 if (drm_core_check_feature(crtc->dev, DRIVER_ATOMIC) && in drm_atomic_crtc_check()
410 WARN_ON(!new_crtc_state->enable && new_crtc_state->mode_blob)) { in drm_atomic_crtc_check()
411 drm_dbg_atomic(crtc->dev, in drm_atomic_crtc_check()
413 crtc->base.id, crtc->name); in drm_atomic_crtc_check()
414 return -EINVAL; in drm_atomic_crtc_check()
427 if (new_crtc_state->event && in drm_atomic_crtc_check()
428 !new_crtc_state->active && !old_crtc_state->active) { in drm_atomic_crtc_check()
429 drm_dbg_atomic(crtc->dev, in drm_atomic_crtc_check()
431 crtc->base.id, crtc->name); in drm_atomic_crtc_check()
432 return -EINVAL; in drm_atomic_crtc_check()
439 const struct drm_crtc_state *state) in drm_atomic_crtc_print_state() argument
441 struct drm_crtc *crtc = state->crtc; in drm_atomic_crtc_print_state()
443 drm_printf(p, "crtc[%u]: %s\n", crtc->base.id, crtc->name); in drm_atomic_crtc_print_state()
444 drm_printf(p, "\tenable=%d\n", state->enable); in drm_atomic_crtc_print_state()
445 drm_printf(p, "\tactive=%d\n", state->active); in drm_atomic_crtc_print_state()
446 drm_printf(p, "\tself_refresh_active=%d\n", state->self_refresh_active); in drm_atomic_crtc_print_state()
447 drm_printf(p, "\tplanes_changed=%d\n", state->planes_changed); in drm_atomic_crtc_print_state()
448 drm_printf(p, "\tmode_changed=%d\n", state->mode_changed); in drm_atomic_crtc_print_state()
449 drm_printf(p, "\tactive_changed=%d\n", state->active_changed); in drm_atomic_crtc_print_state()
450 drm_printf(p, "\tconnectors_changed=%d\n", state->connectors_changed); in drm_atomic_crtc_print_state()
451 drm_printf(p, "\tcolor_mgmt_changed=%d\n", state->color_mgmt_changed); in drm_atomic_crtc_print_state()
452 drm_printf(p, "\tplane_mask=%x\n", state->plane_mask); in drm_atomic_crtc_print_state()
453 drm_printf(p, "\tconnector_mask=%x\n", state->connector_mask); in drm_atomic_crtc_print_state()
454 drm_printf(p, "\tencoder_mask=%x\n", state->encoder_mask); in drm_atomic_crtc_print_state()
455 drm_printf(p, "\tmode: " DRM_MODE_FMT "\n", DRM_MODE_ARG(&state->mode)); in drm_atomic_crtc_print_state()
457 if (crtc->funcs->atomic_print_state) in drm_atomic_crtc_print_state()
458 crtc->funcs->atomic_print_state(p, state); in drm_atomic_crtc_print_state()
462 struct drm_connector_state *state) in drm_atomic_connector_check() argument
465 struct drm_writeback_job *writeback_job = state->writeback_job; in drm_atomic_connector_check()
466 const struct drm_display_info *info = &connector->display_info; in drm_atomic_connector_check()
468 state->max_bpc = info->bpc ? info->bpc : 8; in drm_atomic_connector_check()
469 if (connector->max_bpc_property) in drm_atomic_connector_check()
470 state->max_bpc = min(state->max_bpc, state->max_requested_bpc); in drm_atomic_connector_check()
472 if ((connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK) || !writeback_job) in drm_atomic_connector_check()
475 if (writeback_job->fb && !state->crtc) { in drm_atomic_connector_check()
476 drm_dbg_atomic(connector->dev, in drm_atomic_connector_check()
478 connector->base.id, connector->name); in drm_atomic_connector_check()
479 return -EINVAL; in drm_atomic_connector_check()
482 if (state->crtc) in drm_atomic_connector_check()
483 crtc_state = drm_atomic_get_existing_crtc_state(state->state, in drm_atomic_connector_check()
484 state->crtc); in drm_atomic_connector_check()
486 if (writeback_job->fb && !crtc_state->active) { in drm_atomic_connector_check()
487 drm_dbg_atomic(connector->dev, in drm_atomic_connector_check()
489 connector->base.id, connector->name, in drm_atomic_connector_check()
490 state->crtc->base.id); in drm_atomic_connector_check()
491 return -EINVAL; in drm_atomic_connector_check()
494 if (!writeback_job->fb) { in drm_atomic_connector_check()
495 if (writeback_job->out_fence) { in drm_atomic_connector_check()
496 drm_dbg_atomic(connector->dev, in drm_atomic_connector_check()
497 "[CONNECTOR:%d:%s] requesting out-fence without framebuffer\n", in drm_atomic_connector_check()
498 connector->base.id, connector->name); in drm_atomic_connector_check()
499 return -EINVAL; in drm_atomic_connector_check()
503 state->writeback_job = NULL; in drm_atomic_connector_check()
510 * drm_atomic_get_plane_state - get plane state
511 * @state: global atomic state object
512 * @plane: plane to get state object for
514 * This function returns the plane state for the given plane, allocating it if
515 * needed. It will also grab the relevant plane lock to make sure that the state
519 * Either the allocated state or the error code encoded into the pointer. When
524 drm_atomic_get_plane_state(struct drm_atomic_state *state, in drm_atomic_get_plane_state() argument
530 WARN_ON(!state->acquire_ctx); in drm_atomic_get_plane_state()
533 WARN_ON(plane->fb); in drm_atomic_get_plane_state()
534 WARN_ON(plane->old_fb); in drm_atomic_get_plane_state()
535 WARN_ON(plane->crtc); in drm_atomic_get_plane_state()
537 plane_state = drm_atomic_get_existing_plane_state(state, plane); in drm_atomic_get_plane_state()
541 ret = drm_modeset_lock(&plane->mutex, state->acquire_ctx); in drm_atomic_get_plane_state()
545 plane_state = plane->funcs->atomic_duplicate_state(plane); in drm_atomic_get_plane_state()
547 return ERR_PTR(-ENOMEM); in drm_atomic_get_plane_state()
549 state->planes[index].state = plane_state; in drm_atomic_get_plane_state()
550 state->planes[index].ptr = plane; in drm_atomic_get_plane_state()
551 state->planes[index].old_state = plane->state; in drm_atomic_get_plane_state()
552 state->planes[index].new_state = plane_state; in drm_atomic_get_plane_state()
553 plane_state->state = state; in drm_atomic_get_plane_state()
555 drm_dbg_atomic(plane->dev, "Added [PLANE:%d:%s] %p state to %p\n", in drm_atomic_get_plane_state()
556 plane->base.id, plane->name, plane_state, state); in drm_atomic_get_plane_state()
558 if (plane_state->crtc) { in drm_atomic_get_plane_state()
561 crtc_state = drm_atomic_get_crtc_state(state, in drm_atomic_get_plane_state()
562 plane_state->crtc); in drm_atomic_get_plane_state()
575 if (!old_plane_state->crtc || !new_plane_state->crtc) in plane_switching_crtc()
578 if (old_plane_state->crtc == new_plane_state->crtc) in plane_switching_crtc()
584 * full OFF state. in plane_switching_crtc()
590 * drm_atomic_plane_check - check plane state
591 * @old_plane_state: old plane state to check
592 * @new_plane_state: new plane state to check
594 * Provides core sanity checks for plane state.
602 struct drm_plane *plane = new_plane_state->plane; in drm_atomic_plane_check()
603 struct drm_crtc *crtc = new_plane_state->crtc; in drm_atomic_plane_check()
604 const struct drm_framebuffer *fb = new_plane_state->fb; in drm_atomic_plane_check()
611 drm_dbg_atomic(plane->dev, "[PLANE:%d:%s] CRTC set but no FB\n", in drm_atomic_plane_check()
612 plane->base.id, plane->name); in drm_atomic_plane_check()
613 return -EINVAL; in drm_atomic_plane_check()
615 drm_dbg_atomic(plane->dev, "[PLANE:%d:%s] FB set but no CRTC\n", in drm_atomic_plane_check()
616 plane->base.id, plane->name); in drm_atomic_plane_check()
617 return -EINVAL; in drm_atomic_plane_check()
620 /* if disabled, we don't care about the rest of the state: */ in drm_atomic_plane_check()
625 if (!(plane->possible_crtcs & drm_crtc_mask(crtc))) { in drm_atomic_plane_check()
626 drm_dbg_atomic(plane->dev, in drm_atomic_plane_check()
628 crtc->base.id, crtc->name, in drm_atomic_plane_check()
629 plane->base.id, plane->name); in drm_atomic_plane_check()
630 return -EINVAL; in drm_atomic_plane_check()
634 if (!drm_plane_has_format(plane, fb->format->format, fb->modifier)) { in drm_atomic_plane_check()
635 drm_dbg_atomic(plane->dev, in drm_atomic_plane_check()
637 plane->base.id, plane->name, in drm_atomic_plane_check()
638 &fb->format->format, fb->modifier); in drm_atomic_plane_check()
639 return -EINVAL; in drm_atomic_plane_check()
643 if (new_plane_state->crtc_w > INT_MAX || in drm_atomic_plane_check()
644 new_plane_state->crtc_x > INT_MAX - (int32_t) new_plane_state->crtc_w || in drm_atomic_plane_check()
645 new_plane_state->crtc_h > INT_MAX || in drm_atomic_plane_check()
646 new_plane_state->crtc_y > INT_MAX - (int32_t) new_plane_state->crtc_h) { in drm_atomic_plane_check()
647 drm_dbg_atomic(plane->dev, in drm_atomic_plane_check()
649 plane->base.id, plane->name, in drm_atomic_plane_check()
650 new_plane_state->crtc_w, new_plane_state->crtc_h, in drm_atomic_plane_check()
651 new_plane_state->crtc_x, new_plane_state->crtc_y); in drm_atomic_plane_check()
652 return -ERANGE; in drm_atomic_plane_check()
655 fb_width = fb->width << 16; in drm_atomic_plane_check()
656 fb_height = fb->height << 16; in drm_atomic_plane_check()
659 if (new_plane_state->src_w > fb_width || in drm_atomic_plane_check()
660 new_plane_state->src_x > fb_width - new_plane_state->src_w || in drm_atomic_plane_check()
661 new_plane_state->src_h > fb_height || in drm_atomic_plane_check()
662 new_plane_state->src_y > fb_height - new_plane_state->src_h) { in drm_atomic_plane_check()
663 drm_dbg_atomic(plane->dev, in drm_atomic_plane_check()
666 plane->base.id, plane->name, in drm_atomic_plane_check()
667 new_plane_state->src_w >> 16, in drm_atomic_plane_check()
668 ((new_plane_state->src_w & 0xffff) * 15625) >> 10, in drm_atomic_plane_check()
669 new_plane_state->src_h >> 16, in drm_atomic_plane_check()
670 ((new_plane_state->src_h & 0xffff) * 15625) >> 10, in drm_atomic_plane_check()
671 new_plane_state->src_x >> 16, in drm_atomic_plane_check()
672 ((new_plane_state->src_x & 0xffff) * 15625) >> 10, in drm_atomic_plane_check()
673 new_plane_state->src_y >> 16, in drm_atomic_plane_check()
674 ((new_plane_state->src_y & 0xffff) * 15625) >> 10, in drm_atomic_plane_check()
675 fb->width, fb->height); in drm_atomic_plane_check()
676 return -ENOSPC; in drm_atomic_plane_check()
684 if (clips->x1 >= clips->x2 || in drm_atomic_plane_check()
685 clips->y1 >= clips->y2 || in drm_atomic_plane_check()
686 clips->x1 < 0 || in drm_atomic_plane_check()
687 clips->y1 < 0 || in drm_atomic_plane_check()
688 clips->x2 > fb_width || in drm_atomic_plane_check()
689 clips->y2 > fb_height) { in drm_atomic_plane_check()
690 drm_dbg_atomic(plane->dev, in drm_atomic_plane_check()
692 plane->base.id, plane->name, clips->x1, in drm_atomic_plane_check()
693 clips->y1, clips->x2, clips->y2); in drm_atomic_plane_check()
694 return -EINVAL; in drm_atomic_plane_check()
697 num_clips--; in drm_atomic_plane_check()
701 drm_dbg_atomic(plane->dev, in drm_atomic_plane_check()
703 plane->base.id, plane->name); in drm_atomic_plane_check()
704 return -EINVAL; in drm_atomic_plane_check()
711 const struct drm_plane_state *state) in drm_atomic_plane_print_state() argument
713 struct drm_plane *plane = state->plane; in drm_atomic_plane_print_state()
714 struct drm_rect src = drm_plane_state_src(state); in drm_atomic_plane_print_state()
715 struct drm_rect dest = drm_plane_state_dest(state); in drm_atomic_plane_print_state()
717 drm_printf(p, "plane[%u]: %s\n", plane->base.id, plane->name); in drm_atomic_plane_print_state()
718 drm_printf(p, "\tcrtc=%s\n", state->crtc ? state->crtc->name : "(null)"); in drm_atomic_plane_print_state()
719 drm_printf(p, "\tfb=%u\n", state->fb ? state->fb->base.id : 0); in drm_atomic_plane_print_state()
720 if (state->fb) in drm_atomic_plane_print_state()
721 drm_framebuffer_print_info(p, 2, state->fb); in drm_atomic_plane_print_state()
722 drm_printf(p, "\tcrtc-pos=" DRM_RECT_FMT "\n", DRM_RECT_ARG(&dest)); in drm_atomic_plane_print_state()
723 drm_printf(p, "\tsrc-pos=" DRM_RECT_FP_FMT "\n", DRM_RECT_FP_ARG(&src)); in drm_atomic_plane_print_state()
724 drm_printf(p, "\trotation=%x\n", state->rotation); in drm_atomic_plane_print_state()
725 drm_printf(p, "\tnormalized-zpos=%x\n", state->normalized_zpos); in drm_atomic_plane_print_state()
726 drm_printf(p, "\tcolor-encoding=%s\n", in drm_atomic_plane_print_state()
727 drm_get_color_encoding_name(state->color_encoding)); in drm_atomic_plane_print_state()
728 drm_printf(p, "\tcolor-range=%s\n", in drm_atomic_plane_print_state()
729 drm_get_color_range_name(state->color_range)); in drm_atomic_plane_print_state()
730 drm_printf(p, "\tcolor_mgmt_changed=%d\n", state->color_mgmt_changed); in drm_atomic_plane_print_state()
732 if (plane->funcs->atomic_print_state) in drm_atomic_plane_print_state()
733 plane->funcs->atomic_print_state(p, state); in drm_atomic_plane_print_state()
737 * DOC: handling driver private state
744 * objects. Drivers then need to do similar state tracking and commit ordering for
749 * driver private state objects using struct &drm_private_obj, with the
750 * associated state struct &drm_private_state.
752 * Similar to userspace-exposed objects, private state structures can be
755 * directly. Sequence of the actual hardware state commit is not handled,
760 * All private state structures contained in a &drm_atomic_state update can be
763 * Drivers are recommended to wrap these for each type of driver private state
767 * An earlier way to handle driver private state was by subclassing struct
768 * &drm_atomic_state. But since that encourages non-standard ways to implement
770 * commit instead" of "duplicate state, check, then either commit or release
771 * duplicated state) it is deprecated in favour of using &drm_private_state.
775 * drm_atomic_private_obj_init - initialize private object
778 * @state: initial private object state
783 * driver private object that needs its own atomic state.
788 struct drm_private_state *state, in drm_atomic_private_obj_init() argument
793 drm_modeset_lock_init(&obj->lock); in drm_atomic_private_obj_init()
795 obj->state = state; in drm_atomic_private_obj_init()
796 obj->funcs = funcs; in drm_atomic_private_obj_init()
797 list_add_tail(&obj->head, &dev->mode_config.privobj_list); in drm_atomic_private_obj_init()
799 state->obj = obj; in drm_atomic_private_obj_init()
804 * drm_atomic_private_obj_fini - finalize private object
812 list_del(&obj->head); in drm_atomic_private_obj_fini()
813 obj->funcs->atomic_destroy_state(obj, obj->state); in drm_atomic_private_obj_fini()
814 drm_modeset_lock_fini(&obj->lock); in drm_atomic_private_obj_fini()
819 * drm_atomic_get_private_obj_state - get private object state
820 * @state: global atomic state
821 * @obj: private object to get the state for
823 * This function returns the private object state for the given private object,
824 * allocating the state if needed. It will also grab the relevant private
825 * object lock to make sure that the state is consistent.
828 * Either the allocated state or the error code encoded into a pointer.
831 drm_atomic_get_private_obj_state(struct drm_atomic_state *state, in drm_atomic_get_private_obj_state() argument
839 for (i = 0; i < state->num_private_objs; i++) in drm_atomic_get_private_obj_state()
840 if (obj == state->private_objs[i].ptr) in drm_atomic_get_private_obj_state()
841 return state->private_objs[i].state; in drm_atomic_get_private_obj_state()
843 ret = drm_modeset_lock(&obj->lock, state->acquire_ctx); in drm_atomic_get_private_obj_state()
847 num_objs = state->num_private_objs + 1; in drm_atomic_get_private_obj_state()
848 size = sizeof(*state->private_objs) * num_objs; in drm_atomic_get_private_obj_state()
849 arr = krealloc(state->private_objs, size, GFP_KERNEL); in drm_atomic_get_private_obj_state()
851 return ERR_PTR(-ENOMEM); in drm_atomic_get_private_obj_state()
853 state->private_objs = arr; in drm_atomic_get_private_obj_state()
854 index = state->num_private_objs; in drm_atomic_get_private_obj_state()
855 memset(&state->private_objs[index], 0, sizeof(*state->private_objs)); in drm_atomic_get_private_obj_state()
857 obj_state = obj->funcs->atomic_duplicate_state(obj); in drm_atomic_get_private_obj_state()
859 return ERR_PTR(-ENOMEM); in drm_atomic_get_private_obj_state()
861 state->private_objs[index].state = obj_state; in drm_atomic_get_private_obj_state()
862 state->private_objs[index].old_state = obj->state; in drm_atomic_get_private_obj_state()
863 state->private_objs[index].new_state = obj_state; in drm_atomic_get_private_obj_state()
864 state->private_objs[index].ptr = obj; in drm_atomic_get_private_obj_state()
865 obj_state->state = state; in drm_atomic_get_private_obj_state()
867 state->num_private_objs = num_objs; in drm_atomic_get_private_obj_state()
869 drm_dbg_atomic(state->dev, in drm_atomic_get_private_obj_state()
870 "Added new private object %p state %p to %p\n", in drm_atomic_get_private_obj_state()
871 obj, obj_state, state); in drm_atomic_get_private_obj_state()
879 * @state: global atomic state object
882 * This function returns the old private object state for the given private_obj,
883 * or NULL if the private_obj is not part of the global atomic state.
886 drm_atomic_get_old_private_obj_state(const struct drm_atomic_state *state, in drm_atomic_get_old_private_obj_state() argument
891 for (i = 0; i < state->num_private_objs; i++) in drm_atomic_get_old_private_obj_state()
892 if (obj == state->private_objs[i].ptr) in drm_atomic_get_old_private_obj_state()
893 return state->private_objs[i].old_state; in drm_atomic_get_old_private_obj_state()
901 * @state: global atomic state object
904 * This function returns the new private object state for the given private_obj,
905 * or NULL if the private_obj is not part of the global atomic state.
908 drm_atomic_get_new_private_obj_state(const struct drm_atomic_state *state, in drm_atomic_get_new_private_obj_state() argument
913 for (i = 0; i < state->num_private_objs; i++) in drm_atomic_get_new_private_obj_state()
914 if (obj == state->private_objs[i].ptr) in drm_atomic_get_new_private_obj_state()
915 return state->private_objs[i].new_state; in drm_atomic_get_new_private_obj_state()
922 * drm_atomic_get_old_connector_for_encoder - Get old connector for an encoder
923 * @state: Atomic state
924 * @encoder: The encoder to fetch the connector state for
927 * as specified by the @state.
929 * If there is no connector in @state which previously had @encoder connected to
933 * state). This is especially true in enable hooks because the pipeline has
940 drm_atomic_get_old_connector_for_encoder(const struct drm_atomic_state *state, in drm_atomic_get_old_connector_for_encoder() argument
947 for_each_old_connector_in_state(state, connector, conn_state, i) { in drm_atomic_get_old_connector_for_encoder()
948 if (conn_state->best_encoder == encoder) in drm_atomic_get_old_connector_for_encoder()
957 * drm_atomic_get_new_connector_for_encoder - Get new connector for an encoder
958 * @state: Atomic state
959 * @encoder: The encoder to fetch the connector state for
962 * @encoder as specified by the @state.
964 * If there is no connector in @state which will have @encoder connected to it,
967 * attached to @encoder vs ones that do (and to inspect their state). This is
974 drm_atomic_get_new_connector_for_encoder(const struct drm_atomic_state *state, in drm_atomic_get_new_connector_for_encoder() argument
981 for_each_new_connector_in_state(state, connector, conn_state, i) { in drm_atomic_get_new_connector_for_encoder()
982 if (conn_state->best_encoder == encoder) in drm_atomic_get_new_connector_for_encoder()
991 * drm_atomic_get_old_crtc_for_encoder - Get old crtc for an encoder
992 * @state: Atomic state
993 * @encoder: The encoder to fetch the crtc state for
996 * as specified by the @state.
1002 drm_atomic_get_old_crtc_for_encoder(struct drm_atomic_state *state, in drm_atomic_get_old_crtc_for_encoder() argument
1008 connector = drm_atomic_get_old_connector_for_encoder(state, encoder); in drm_atomic_get_old_crtc_for_encoder()
1012 conn_state = drm_atomic_get_old_connector_state(state, connector); in drm_atomic_get_old_crtc_for_encoder()
1016 return conn_state->crtc; in drm_atomic_get_old_crtc_for_encoder()
1021 * drm_atomic_get_new_crtc_for_encoder - Get new crtc for an encoder
1022 * @state: Atomic state
1023 * @encoder: The encoder to fetch the crtc state for
1026 * as specified by the @state.
1032 drm_atomic_get_new_crtc_for_encoder(struct drm_atomic_state *state, in drm_atomic_get_new_crtc_for_encoder() argument
1038 connector = drm_atomic_get_new_connector_for_encoder(state, encoder); in drm_atomic_get_new_crtc_for_encoder()
1042 conn_state = drm_atomic_get_new_connector_state(state, connector); in drm_atomic_get_new_crtc_for_encoder()
1046 return conn_state->crtc; in drm_atomic_get_new_crtc_for_encoder()
1051 * drm_atomic_get_connector_state - get connector state
1052 * @state: global atomic state object
1053 * @connector: connector to get state object for
1055 * This function returns the connector state for the given connector,
1057 * make sure that the state is consistent.
1060 * Either the allocated state or the error code encoded into the pointer. When
1065 drm_atomic_get_connector_state(struct drm_atomic_state *state, in drm_atomic_get_connector_state() argument
1069 struct drm_mode_config *config = &connector->dev->mode_config; in drm_atomic_get_connector_state()
1072 WARN_ON(!state->acquire_ctx); in drm_atomic_get_connector_state()
1074 ret = drm_modeset_lock(&config->connection_mutex, state->acquire_ctx); in drm_atomic_get_connector_state()
1080 if (index >= state->num_connector) { in drm_atomic_get_connector_state()
1082 int alloc = max(index + 1, config->num_connector); in drm_atomic_get_connector_state()
1084 c = krealloc_array(state->connectors, alloc, in drm_atomic_get_connector_state()
1085 sizeof(*state->connectors), GFP_KERNEL); in drm_atomic_get_connector_state()
1087 return ERR_PTR(-ENOMEM); in drm_atomic_get_connector_state()
1089 state->connectors = c; in drm_atomic_get_connector_state()
1090 memset(&state->connectors[state->num_connector], 0, in drm_atomic_get_connector_state()
1091 sizeof(*state->connectors) * (alloc - state->num_connector)); in drm_atomic_get_connector_state()
1093 state->num_connector = alloc; in drm_atomic_get_connector_state()
1096 if (state->connectors[index].state) in drm_atomic_get_connector_state()
1097 return state->connectors[index].state; in drm_atomic_get_connector_state()
1099 connector_state = connector->funcs->atomic_duplicate_state(connector); in drm_atomic_get_connector_state()
1101 return ERR_PTR(-ENOMEM); in drm_atomic_get_connector_state()
1104 state->connectors[index].state = connector_state; in drm_atomic_get_connector_state()
1105 state->connectors[index].old_state = connector->state; in drm_atomic_get_connector_state()
1106 state->connectors[index].new_state = connector_state; in drm_atomic_get_connector_state()
1107 state->connectors[index].ptr = connector; in drm_atomic_get_connector_state()
1108 connector_state->state = state; in drm_atomic_get_connector_state()
1110 drm_dbg_atomic(connector->dev, "Added [CONNECTOR:%d:%s] %p state to %p\n", in drm_atomic_get_connector_state()
1111 connector->base.id, connector->name, in drm_atomic_get_connector_state()
1112 connector_state, state); in drm_atomic_get_connector_state()
1114 if (connector_state->crtc) { in drm_atomic_get_connector_state()
1117 crtc_state = drm_atomic_get_crtc_state(state, in drm_atomic_get_connector_state()
1118 connector_state->crtc); in drm_atomic_get_connector_state()
1128 const struct drm_connector_state *state) in drm_atomic_connector_print_state() argument
1130 struct drm_connector *connector = state->connector; in drm_atomic_connector_print_state()
1132 drm_printf(p, "connector[%u]: %s\n", connector->base.id, connector->name); in drm_atomic_connector_print_state()
1133 drm_printf(p, "\tcrtc=%s\n", state->crtc ? state->crtc->name : "(null)"); in drm_atomic_connector_print_state()
1134 drm_printf(p, "\tself_refresh_aware=%d\n", state->self_refresh_aware); in drm_atomic_connector_print_state()
1135 drm_printf(p, "\tmax_requested_bpc=%d\n", state->max_requested_bpc); in drm_atomic_connector_print_state()
1136 drm_printf(p, "\tcolorspace=%s\n", drm_get_colorspace_name(state->colorspace)); in drm_atomic_connector_print_state()
1138 if (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA || in drm_atomic_connector_print_state()
1139 connector->connector_type == DRM_MODE_CONNECTOR_HDMIB) { in drm_atomic_connector_print_state()
1141 drm_hdmi_connector_get_broadcast_rgb_name(state->hdmi.broadcast_rgb)); in drm_atomic_connector_print_state()
1142 drm_printf(p, "\tis_limited_range=%c\n", state->hdmi.is_limited_range ? 'y' : 'n'); in drm_atomic_connector_print_state()
1143 drm_printf(p, "\toutput_bpc=%u\n", state->hdmi.output_bpc); in drm_atomic_connector_print_state()
1145 drm_hdmi_connector_get_output_format_name(state->hdmi.output_format)); in drm_atomic_connector_print_state()
1146 drm_printf(p, "\ttmds_char_rate=%llu\n", state->hdmi.tmds_char_rate); in drm_atomic_connector_print_state()
1149 if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK) in drm_atomic_connector_print_state()
1150 if (state->writeback_job && state->writeback_job->fb) in drm_atomic_connector_print_state()
1151 drm_printf(p, "\tfb=%d\n", state->writeback_job->fb->base.id); in drm_atomic_connector_print_state()
1153 if (connector->funcs->atomic_print_state) in drm_atomic_connector_print_state()
1154 connector->funcs->atomic_print_state(p, state); in drm_atomic_connector_print_state()
1158 * drm_atomic_get_bridge_state - get bridge state
1159 * @state: global atomic state object
1160 * @bridge: bridge to get state object for
1162 * This function returns the bridge state for the given bridge, allocating it
1164 * state is consistent.
1167 * Either the allocated state or the error code encoded into the pointer. When
1172 drm_atomic_get_bridge_state(struct drm_atomic_state *state, in drm_atomic_get_bridge_state() argument
1177 obj_state = drm_atomic_get_private_obj_state(state, &bridge->base); in drm_atomic_get_bridge_state()
1186 * drm_atomic_get_old_bridge_state - get old bridge state, if it exists
1187 * @state: global atomic state object
1190 * This function returns the old bridge state for the given bridge, or NULL if
1191 * the bridge is not part of the global atomic state.
1194 drm_atomic_get_old_bridge_state(const struct drm_atomic_state *state, in drm_atomic_get_old_bridge_state() argument
1199 obj_state = drm_atomic_get_old_private_obj_state(state, &bridge->base); in drm_atomic_get_old_bridge_state()
1208 * drm_atomic_get_new_bridge_state - get new bridge state, if it exists
1209 * @state: global atomic state object
1212 * This function returns the new bridge state for the given bridge, or NULL if
1213 * the bridge is not part of the global atomic state.
1216 drm_atomic_get_new_bridge_state(const struct drm_atomic_state *state, in drm_atomic_get_new_bridge_state() argument
1221 obj_state = drm_atomic_get_new_private_obj_state(state, &bridge->base); in drm_atomic_get_new_bridge_state()
1230 * drm_atomic_add_encoder_bridges - add bridges attached to an encoder
1231 * @state: atomic state
1235 * bridge states to @state and make them available when
1241 * 0 on success or can fail with -EDEADLK or -ENOMEM. When the error is EDEADLK
1246 drm_atomic_add_encoder_bridges(struct drm_atomic_state *state, in drm_atomic_add_encoder_bridges() argument
1255 drm_dbg_atomic(encoder->dev, in drm_atomic_add_encoder_bridges()
1257 encoder->base.id, encoder->name, state); in drm_atomic_add_encoder_bridges()
1260 /* Skip bridges that don't implement the atomic state hooks. */ in drm_atomic_add_encoder_bridges()
1261 if (!bridge->funcs->atomic_duplicate_state) in drm_atomic_add_encoder_bridges()
1264 bridge_state = drm_atomic_get_bridge_state(state, bridge); in drm_atomic_add_encoder_bridges()
1274 * drm_atomic_add_affected_connectors - add connectors for CRTC
1275 * @state: atomic state
1279 * currently using @crtc to the atomic configuration @state. Note that this
1286 * 0 on success or can fail with -EDEADLK or -ENOMEM. When the error is EDEADLK
1291 drm_atomic_add_affected_connectors(struct drm_atomic_state *state, in drm_atomic_add_affected_connectors() argument
1294 struct drm_mode_config *config = &state->dev->mode_config; in drm_atomic_add_affected_connectors()
1301 crtc_state = drm_atomic_get_crtc_state(state, crtc); in drm_atomic_add_affected_connectors()
1305 ret = drm_modeset_lock(&config->connection_mutex, state->acquire_ctx); in drm_atomic_add_affected_connectors()
1309 drm_dbg_atomic(crtc->dev, in drm_atomic_add_affected_connectors()
1311 crtc->base.id, crtc->name, state); in drm_atomic_add_affected_connectors()
1314 * Changed connectors are already in @state, so only need to look in drm_atomic_add_affected_connectors()
1317 drm_connector_list_iter_begin(state->dev, &conn_iter); in drm_atomic_add_affected_connectors()
1319 if (!(crtc_state->connector_mask & drm_connector_mask(connector))) in drm_atomic_add_affected_connectors()
1322 conn_state = drm_atomic_get_connector_state(state, connector); in drm_atomic_add_affected_connectors()
1335 * drm_atomic_add_affected_planes - add planes for CRTC
1336 * @state: atomic state
1340 * currently used by @crtc to the atomic configuration @state. This is useful
1342 * @crtc, e.g. when changing the mode. It's also useful when re-enabling a CRTC
1343 * to avoid special code to force-enable all planes.
1345 * Since acquiring a plane state will always also acquire the w/w mutex of the
1350 * 0 on success or can fail with -EDEADLK or -ENOMEM. When the error is EDEADLK
1355 drm_atomic_add_affected_planes(struct drm_atomic_state *state, in drm_atomic_add_affected_planes() argument
1359 drm_atomic_get_old_crtc_state(state, crtc); in drm_atomic_add_affected_planes()
1362 WARN_ON(!drm_atomic_get_new_crtc_state(state, crtc)); in drm_atomic_add_affected_planes()
1364 drm_dbg_atomic(crtc->dev, in drm_atomic_add_affected_planes()
1366 crtc->base.id, crtc->name, state); in drm_atomic_add_affected_planes()
1368 drm_for_each_plane_mask(plane, state->dev, old_crtc_state->plane_mask) { in drm_atomic_add_affected_planes()
1370 drm_atomic_get_plane_state(state, plane); in drm_atomic_add_affected_planes()
1380 * drm_atomic_check_only - check whether a given config would work
1381 * @state: atomic configuration to check
1383 * Note that this function can return -EDEADLK if the driver needed to acquire
1390 int drm_atomic_check_only(struct drm_atomic_state *state) in drm_atomic_check_only() argument
1392 struct drm_device *dev = state->dev; in drm_atomic_check_only()
1393 struct drm_mode_config *config = &dev->mode_config; in drm_atomic_check_only()
1406 drm_dbg_atomic(dev, "checking %p\n", state); in drm_atomic_check_only()
1408 for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) { in drm_atomic_check_only()
1409 if (new_crtc_state->enable) in drm_atomic_check_only()
1413 for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) { in drm_atomic_check_only()
1417 plane->base.id, plane->name); in drm_atomic_check_only()
1422 for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) { in drm_atomic_check_only()
1426 crtc->base.id, crtc->name); in drm_atomic_check_only()
1431 for_each_new_connector_in_state(state, conn, conn_state, i) { in drm_atomic_check_only()
1435 conn->base.id, conn->name); in drm_atomic_check_only()
1440 if (config->funcs->atomic_check) { in drm_atomic_check_only()
1441 ret = config->funcs->atomic_check(state->dev, state); in drm_atomic_check_only()
1445 state, ret); in drm_atomic_check_only()
1450 if (!state->allow_modeset) { in drm_atomic_check_only()
1451 for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) { in drm_atomic_check_only()
1454 crtc->base.id, crtc->name); in drm_atomic_check_only()
1455 return -EINVAL; in drm_atomic_check_only()
1460 for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) { in drm_atomic_check_only()
1461 if (new_crtc_state->enable) in drm_atomic_check_only()
1479 …WARN(!state->allow_modeset, "adding CRTC not allowed without modesets: requested 0x%x, affected 0x… in drm_atomic_check_only()
1488 * drm_atomic_commit - commit configuration atomically
1489 * @state: atomic configuration to check
1491 * Note that this function can return -EDEADLK if the driver needed to acquire
1495 * This function will take its own reference on @state.
1501 int drm_atomic_commit(struct drm_atomic_state *state) in drm_atomic_commit() argument
1503 struct drm_mode_config *config = &state->dev->mode_config; in drm_atomic_commit()
1504 struct drm_printer p = drm_info_printer(state->dev->dev); in drm_atomic_commit()
1508 drm_atomic_print_new_state(state, &p); in drm_atomic_commit()
1510 ret = drm_atomic_check_only(state); in drm_atomic_commit()
1514 drm_dbg_atomic(state->dev, "committing %p\n", state); in drm_atomic_commit()
1516 return config->funcs->atomic_commit(state->dev, state, false); in drm_atomic_commit()
1521 * drm_atomic_nonblocking_commit - atomic nonblocking commit
1522 * @state: atomic configuration to check
1524 * Note that this function can return -EDEADLK if the driver needed to acquire
1528 * This function will take its own reference on @state.
1534 int drm_atomic_nonblocking_commit(struct drm_atomic_state *state) in drm_atomic_nonblocking_commit() argument
1536 struct drm_mode_config *config = &state->dev->mode_config; in drm_atomic_nonblocking_commit()
1539 ret = drm_atomic_check_only(state); in drm_atomic_nonblocking_commit()
1543 drm_dbg_atomic(state->dev, "committing %p nonblocking\n", state); in drm_atomic_nonblocking_commit()
1545 return config->funcs->atomic_commit(state->dev, state, true); in drm_atomic_nonblocking_commit()
1549 /* just used from drm-client and atomic-helper: */
1560 plane_state->crtc_x = 0; in __drm_atomic_helper_disable_plane()
1561 plane_state->crtc_y = 0; in __drm_atomic_helper_disable_plane()
1562 plane_state->crtc_w = 0; in __drm_atomic_helper_disable_plane()
1563 plane_state->crtc_h = 0; in __drm_atomic_helper_disable_plane()
1564 plane_state->src_x = 0; in __drm_atomic_helper_disable_plane()
1565 plane_state->src_y = 0; in __drm_atomic_helper_disable_plane()
1566 plane_state->src_w = 0; in __drm_atomic_helper_disable_plane()
1567 plane_state->src_h = 0; in __drm_atomic_helper_disable_plane()
1573 static int update_output_state(struct drm_atomic_state *state, in update_output_state() argument
1576 struct drm_device *dev = set->crtc->dev; in update_output_state()
1583 ret = drm_modeset_lock(&dev->mode_config.connection_mutex, in update_output_state()
1584 state->acquire_ctx); in update_output_state()
1589 ret = drm_atomic_add_affected_connectors(state, set->crtc); in update_output_state()
1593 for_each_new_connector_in_state(state, connector, new_conn_state, i) { in update_output_state()
1594 if (new_conn_state->crtc == set->crtc) { in update_output_state()
1600 /* Make sure legacy setCrtc always re-trains */ in update_output_state()
1601 new_conn_state->link_status = DRM_LINK_STATUS_GOOD; in update_output_state()
1605 /* Then set all connectors from set->connectors on the target crtc */ in update_output_state()
1606 for (i = 0; i < set->num_connectors; i++) { in update_output_state()
1607 new_conn_state = drm_atomic_get_connector_state(state, in update_output_state()
1608 set->connectors[i]); in update_output_state()
1613 set->crtc); in update_output_state()
1618 for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) { in update_output_state()
1620 * Don't update ->enable for the CRTC in the set_config request, in update_output_state()
1625 if (crtc == set->crtc) in update_output_state()
1628 if (!new_crtc_state->connector_mask) { in update_output_state()
1634 new_crtc_state->active = false; in update_output_state()
1641 /* just used from drm-client and atomic-helper: */
1643 struct drm_atomic_state *state) in __drm_atomic_helper_set_config() argument
1647 struct drm_crtc *crtc = set->crtc; in __drm_atomic_helper_set_config()
1651 crtc_state = drm_atomic_get_crtc_state(state, crtc); in __drm_atomic_helper_set_config()
1655 primary_state = drm_atomic_get_plane_state(state, crtc->primary); in __drm_atomic_helper_set_config()
1659 if (!set->mode) { in __drm_atomic_helper_set_config()
1660 WARN_ON(set->fb); in __drm_atomic_helper_set_config()
1661 WARN_ON(set->num_connectors); in __drm_atomic_helper_set_config()
1667 crtc_state->active = false; in __drm_atomic_helper_set_config()
1678 WARN_ON(!set->fb); in __drm_atomic_helper_set_config()
1679 WARN_ON(!set->num_connectors); in __drm_atomic_helper_set_config()
1681 ret = drm_atomic_set_mode_for_crtc(crtc_state, set->mode); in __drm_atomic_helper_set_config()
1685 crtc_state->active = true; in __drm_atomic_helper_set_config()
1691 drm_mode_get_hv_timing(set->mode, &hdisplay, &vdisplay); in __drm_atomic_helper_set_config()
1693 drm_atomic_set_fb_for_plane(primary_state, set->fb); in __drm_atomic_helper_set_config()
1694 primary_state->crtc_x = 0; in __drm_atomic_helper_set_config()
1695 primary_state->crtc_y = 0; in __drm_atomic_helper_set_config()
1696 primary_state->crtc_w = hdisplay; in __drm_atomic_helper_set_config()
1697 primary_state->crtc_h = vdisplay; in __drm_atomic_helper_set_config()
1698 primary_state->src_x = set->x << 16; in __drm_atomic_helper_set_config()
1699 primary_state->src_y = set->y << 16; in __drm_atomic_helper_set_config()
1700 if (drm_rotation_90_or_270(primary_state->rotation)) { in __drm_atomic_helper_set_config()
1701 primary_state->src_w = vdisplay << 16; in __drm_atomic_helper_set_config()
1702 primary_state->src_h = hdisplay << 16; in __drm_atomic_helper_set_config()
1704 primary_state->src_w = hdisplay << 16; in __drm_atomic_helper_set_config()
1705 primary_state->src_h = vdisplay << 16; in __drm_atomic_helper_set_config()
1709 ret = update_output_state(state, set); in __drm_atomic_helper_set_config()
1718 const struct drm_private_state *state) in drm_atomic_private_obj_print_state() argument
1720 struct drm_private_obj *obj = state->obj; in drm_atomic_private_obj_print_state()
1722 if (obj->funcs->atomic_print_state) in drm_atomic_private_obj_print_state()
1723 obj->funcs->atomic_print_state(p, state); in drm_atomic_private_obj_print_state()
1727 * drm_atomic_print_new_state - prints drm atomic state
1728 * @state: atomic configuration to check
1731 * This functions prints the drm atomic state snapshot using the drm printer
1734 * Note that this function looks into the new state objects and hence its not
1737 void drm_atomic_print_new_state(const struct drm_atomic_state *state, in drm_atomic_print_new_state() argument
1751 drm_err(state->dev, "invalid drm printer\n"); in drm_atomic_print_new_state()
1755 drm_dbg_atomic(state->dev, "checking %p\n", state); in drm_atomic_print_new_state()
1757 for_each_new_plane_in_state(state, plane, plane_state, i) in drm_atomic_print_new_state()
1760 for_each_new_crtc_in_state(state, crtc, crtc_state, i) in drm_atomic_print_new_state()
1763 for_each_new_connector_in_state(state, connector, connector_state, i) in drm_atomic_print_new_state()
1766 for_each_new_private_obj_in_state(state, obj, obj_state, i) in drm_atomic_print_new_state()
1774 struct drm_mode_config *config = &dev->mode_config; in __drm_state_dump()
1784 list_for_each_entry(plane, &config->plane_list, head) { in __drm_state_dump()
1786 drm_modeset_lock(&plane->mutex, NULL); in __drm_state_dump()
1787 drm_atomic_plane_print_state(p, plane->state); in __drm_state_dump()
1789 drm_modeset_unlock(&plane->mutex); in __drm_state_dump()
1792 list_for_each_entry(crtc, &config->crtc_list, head) { in __drm_state_dump()
1794 drm_modeset_lock(&crtc->mutex, NULL); in __drm_state_dump()
1795 drm_atomic_crtc_print_state(p, crtc->state); in __drm_state_dump()
1797 drm_modeset_unlock(&crtc->mutex); in __drm_state_dump()
1802 drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); in __drm_state_dump()
1804 drm_atomic_connector_print_state(p, connector->state); in __drm_state_dump()
1806 drm_modeset_unlock(&dev->mode_config.connection_mutex); in __drm_state_dump()
1809 list_for_each_entry(obj, &config->privobj_list, head) { in __drm_state_dump()
1811 drm_modeset_lock(&obj->lock, NULL); in __drm_state_dump()
1812 drm_atomic_private_obj_print_state(p, obj->state); in __drm_state_dump()
1814 drm_modeset_unlock(&obj->lock); in __drm_state_dump()
1819 * drm_state_dump - dump entire device atomic state
1821 * @p: where to print the state to
1823 * Just for debugging. Drivers might want an option to dump state
1829 * not be enabled by default - if you are debugging errors you might
1842 struct drm_debugfs_entry *entry = m->private; in drm_state_info()
1843 struct drm_device *dev = entry->dev; in drm_state_info()
1853 {"state", drm_state_info, 0},