Lines Matching +full:free +full:- +full:standing
5 * Permission is hereby granted, free of charge, to any person obtaining a
28 #include <linux/dma-fence.h>
84 if (old_plane_state->crtc) { in drm_atomic_helper_plane_changed()
86 old_plane_state->crtc); in drm_atomic_helper_plane_changed()
91 crtc_state->planes_changed = true; in drm_atomic_helper_plane_changed()
94 if (plane_state->crtc) { in drm_atomic_helper_plane_changed()
95 crtc_state = drm_atomic_get_new_crtc_state(state, plane_state->crtc); in drm_atomic_helper_plane_changed()
100 crtc_state->planes_changed = true; in drm_atomic_helper_plane_changed()
120 const struct drm_connector_helper_funcs *funcs = connector->helper_private; in handle_conflicting_encoders()
123 if (!new_conn_state->crtc) in handle_conflicting_encoders()
126 if (funcs->atomic_best_encoder) in handle_conflicting_encoders()
127 new_encoder = funcs->atomic_best_encoder(connector, in handle_conflicting_encoders()
129 else if (funcs->best_encoder) in handle_conflicting_encoders()
130 new_encoder = funcs->best_encoder(connector); in handle_conflicting_encoders()
136 drm_dbg_atomic(connector->dev, in handle_conflicting_encoders()
138 new_encoder->base.id, new_encoder->name, in handle_conflicting_encoders()
139 connector->base.id, connector->name); in handle_conflicting_encoders()
141 return -EINVAL; in handle_conflicting_encoders()
162 drm_connector_list_iter_begin(state->dev, &conn_iter); in handle_conflicting_encoders()
169 encoder = connector->state->best_encoder; in handle_conflicting_encoders()
174 drm_dbg_atomic(connector->dev, in handle_conflicting_encoders()
176 encoder->base.id, encoder->name, in handle_conflicting_encoders()
177 connector->state->crtc->base.id, in handle_conflicting_encoders()
178 connector->state->crtc->name, in handle_conflicting_encoders()
179 connector->base.id, connector->name); in handle_conflicting_encoders()
180 ret = -EINVAL; in handle_conflicting_encoders()
190 drm_dbg_atomic(connector->dev, in handle_conflicting_encoders()
192 encoder->base.id, encoder->name, in handle_conflicting_encoders()
193 new_conn_state->crtc->base.id, new_conn_state->crtc->name, in handle_conflicting_encoders()
194 connector->base.id, connector->name); in handle_conflicting_encoders()
196 crtc_state = drm_atomic_get_new_crtc_state(state, new_conn_state->crtc); in handle_conflicting_encoders()
202 if (!crtc_state->connector_mask) { in handle_conflicting_encoders()
208 crtc_state->active = false; in handle_conflicting_encoders()
225 if (conn_state->best_encoder) { in set_best_encoder()
227 crtc = conn_state->connector->state->crtc; in set_best_encoder()
235 WARN_ON(!crtc && encoder != conn_state->best_encoder); in set_best_encoder()
239 crtc_state->encoder_mask &= in set_best_encoder()
240 ~drm_encoder_mask(conn_state->best_encoder); in set_best_encoder()
245 crtc = conn_state->crtc; in set_best_encoder()
250 crtc_state->encoder_mask |= in set_best_encoder()
255 conn_state->best_encoder = encoder; in set_best_encoder()
270 if (new_connector_state->best_encoder != encoder) in steal_encoder()
273 encoder_crtc = old_connector_state->crtc; in steal_encoder()
275 drm_dbg_atomic(encoder->dev, in steal_encoder()
277 encoder->base.id, encoder->name, in steal_encoder()
278 encoder_crtc->base.id, encoder_crtc->name); in steal_encoder()
283 crtc_state->connectors_changed = true; in steal_encoder()
300 drm_dbg_atomic(connector->dev, "Updating routing for [CONNECTOR:%d:%s]\n", in update_connector_routing()
301 connector->base.id, connector->name); in update_connector_routing()
303 if (old_connector_state->crtc != new_connector_state->crtc) { in update_connector_routing()
304 if (old_connector_state->crtc) { in update_connector_routing()
305 crtc_state = drm_atomic_get_new_crtc_state(state, old_connector_state->crtc); in update_connector_routing()
306 crtc_state->connectors_changed = true; in update_connector_routing()
309 if (new_connector_state->crtc) { in update_connector_routing()
310 crtc_state = drm_atomic_get_new_crtc_state(state, new_connector_state->crtc); in update_connector_routing()
311 crtc_state->connectors_changed = true; in update_connector_routing()
315 if (!new_connector_state->crtc) { in update_connector_routing()
316 drm_dbg_atomic(connector->dev, "Disabling [CONNECTOR:%d:%s]\n", in update_connector_routing()
317 connector->base.id, connector->name); in update_connector_routing()
325 new_connector_state->crtc); in update_connector_routing()
328 * we allow DPMS On->Off modesets on unregistered connectors. Modesets in update_connector_routing()
345 * was not pulled in the atomic state by user-space (ie, was pulled in update_connector_routing()
346 * in by the driver, e.g. when updating a DP-MST stream). in update_connector_routing()
348 if (!state->duplicated && drm_connector_is_unregistered(connector) && in update_connector_routing()
349 added_by_user && crtc_state->active) { in update_connector_routing()
350 drm_dbg_atomic(connector->dev, in update_connector_routing()
352 connector->base.id, connector->name); in update_connector_routing()
353 return -EINVAL; in update_connector_routing()
356 funcs = connector->helper_private; in update_connector_routing()
358 if (funcs->atomic_best_encoder) in update_connector_routing()
359 new_encoder = funcs->atomic_best_encoder(connector, state); in update_connector_routing()
360 else if (funcs->best_encoder) in update_connector_routing()
361 new_encoder = funcs->best_encoder(connector); in update_connector_routing()
366 drm_dbg_atomic(connector->dev, in update_connector_routing()
368 connector->base.id, connector->name); in update_connector_routing()
369 return -EINVAL; in update_connector_routing()
372 if (!drm_encoder_crtc_ok(new_encoder, new_connector_state->crtc)) { in update_connector_routing()
373 drm_dbg_atomic(connector->dev, in update_connector_routing()
375 new_encoder->base.id, in update_connector_routing()
376 new_encoder->name, in update_connector_routing()
377 new_connector_state->crtc->base.id, in update_connector_routing()
378 new_connector_state->crtc->name); in update_connector_routing()
379 return -EINVAL; in update_connector_routing()
382 if (new_encoder == new_connector_state->best_encoder) { in update_connector_routing()
385 drm_dbg_atomic(connector->dev, in update_connector_routing()
387 connector->base.id, in update_connector_routing()
388 connector->name, in update_connector_routing()
389 new_encoder->base.id, in update_connector_routing()
390 new_encoder->name, in update_connector_routing()
391 new_connector_state->crtc->base.id, in update_connector_routing()
392 new_connector_state->crtc->name); in update_connector_routing()
401 crtc_state->connectors_changed = true; in update_connector_routing()
403 drm_dbg_atomic(connector->dev, in update_connector_routing()
405 connector->base.id, in update_connector_routing()
406 connector->name, in update_connector_routing()
407 new_encoder->base.id, in update_connector_routing()
408 new_encoder->name, in update_connector_routing()
409 new_connector_state->crtc->base.id, in update_connector_routing()
410 new_connector_state->crtc->name); in update_connector_routing()
426 if (!new_crtc_state->mode_changed && in mode_fixup()
427 !new_crtc_state->connectors_changed) in mode_fixup()
430 drm_mode_copy(&new_crtc_state->adjusted_mode, &new_crtc_state->mode); in mode_fixup()
438 WARN_ON(!!new_conn_state->best_encoder != !!new_conn_state->crtc); in mode_fixup()
440 if (!new_conn_state->crtc || !new_conn_state->best_encoder) in mode_fixup()
444 drm_atomic_get_new_crtc_state(state, new_conn_state->crtc); in mode_fixup()
448 * it away), so we won't call ->mode_fixup twice. in mode_fixup()
450 encoder = new_conn_state->best_encoder; in mode_fixup()
451 funcs = encoder->helper_private; in mode_fixup()
458 drm_dbg_atomic(encoder->dev, "Bridge atomic check failed\n"); in mode_fixup()
462 if (funcs && funcs->atomic_check) { in mode_fixup()
463 ret = funcs->atomic_check(encoder, new_crtc_state, in mode_fixup()
466 drm_dbg_atomic(encoder->dev, in mode_fixup()
468 encoder->base.id, encoder->name); in mode_fixup()
471 } else if (funcs && funcs->mode_fixup) { in mode_fixup()
472 ret = funcs->mode_fixup(encoder, &new_crtc_state->mode, in mode_fixup()
473 &new_crtc_state->adjusted_mode); in mode_fixup()
475 drm_dbg_atomic(encoder->dev, in mode_fixup()
477 encoder->base.id, encoder->name); in mode_fixup()
478 return -EINVAL; in mode_fixup()
486 if (!new_crtc_state->enable) in mode_fixup()
489 if (!new_crtc_state->mode_changed && in mode_fixup()
490 !new_crtc_state->connectors_changed) in mode_fixup()
493 funcs = crtc->helper_private; in mode_fixup()
494 if (!funcs || !funcs->mode_fixup) in mode_fixup()
497 ret = funcs->mode_fixup(crtc, &new_crtc_state->mode, in mode_fixup()
498 &new_crtc_state->adjusted_mode); in mode_fixup()
500 drm_dbg_atomic(crtc->dev, "[CRTC:%d:%s] fixup failed\n", in mode_fixup()
501 crtc->base.id, crtc->name); in mode_fixup()
502 return -EINVAL; in mode_fixup()
519 drm_dbg_atomic(encoder->dev, in mode_valid_path()
521 encoder->base.id, encoder->name); in mode_valid_path()
526 ret = drm_bridge_chain_mode_valid(bridge, &connector->display_info, in mode_valid_path()
529 drm_dbg_atomic(encoder->dev, "[BRIDGE] mode_valid() failed\n"); in mode_valid_path()
535 drm_dbg_atomic(encoder->dev, "[CRTC:%d:%s] mode_valid() failed\n", in mode_valid_path()
536 crtc->base.id, crtc->name); in mode_valid_path()
551 struct drm_encoder *encoder = conn_state->best_encoder; in mode_valid()
552 struct drm_crtc *crtc = conn_state->crtc; in mode_valid()
563 if (!crtc_state->mode_changed && !crtc_state->connectors_changed) in mode_valid()
566 mode = &crtc_state->mode; in mode_valid()
570 return -EINVAL; in mode_valid()
577 * drm_atomic_helper_check_modeset - validate state object for modeset changes
584 * the various per-object callbacks in the follow order:
617 * Zero for success or -errno
635 !!new_crtc_state->connector_mask; in drm_atomic_helper_check_modeset()
637 WARN_ON(!drm_modeset_is_locked(&crtc->mutex)); in drm_atomic_helper_check_modeset()
639 if (!drm_mode_equal(&old_crtc_state->mode, &new_crtc_state->mode)) { in drm_atomic_helper_check_modeset()
641 crtc->base.id, crtc->name); in drm_atomic_helper_check_modeset()
642 new_crtc_state->mode_changed = true; in drm_atomic_helper_check_modeset()
645 if (old_crtc_state->enable != new_crtc_state->enable) { in drm_atomic_helper_check_modeset()
647 crtc->base.id, crtc->name); in drm_atomic_helper_check_modeset()
657 new_crtc_state->mode_changed = true; in drm_atomic_helper_check_modeset()
658 new_crtc_state->connectors_changed = true; in drm_atomic_helper_check_modeset()
661 if (old_crtc_state->active != new_crtc_state->active) { in drm_atomic_helper_check_modeset()
663 crtc->base.id, crtc->name); in drm_atomic_helper_check_modeset()
664 new_crtc_state->active_changed = true; in drm_atomic_helper_check_modeset()
667 if (new_crtc_state->enable != has_connectors) { in drm_atomic_helper_check_modeset()
669 crtc->base.id, crtc->name); in drm_atomic_helper_check_modeset()
671 return -EINVAL; in drm_atomic_helper_check_modeset()
675 new_crtc_state->no_vblank = false; in drm_atomic_helper_check_modeset()
677 new_crtc_state->no_vblank = true; in drm_atomic_helper_check_modeset()
685 const struct drm_connector_helper_funcs *funcs = connector->helper_private; in drm_atomic_helper_check_modeset()
687 WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex)); in drm_atomic_helper_check_modeset()
690 * This only sets crtc->connectors_changed for routing changes, in drm_atomic_helper_check_modeset()
691 * drivers must set crtc->connectors_changed themselves when in drm_atomic_helper_check_modeset()
700 if (old_connector_state->crtc) { in drm_atomic_helper_check_modeset()
702 old_connector_state->crtc); in drm_atomic_helper_check_modeset()
703 if (old_connector_state->link_status != in drm_atomic_helper_check_modeset()
704 new_connector_state->link_status) in drm_atomic_helper_check_modeset()
705 new_crtc_state->connectors_changed = true; in drm_atomic_helper_check_modeset()
707 if (old_connector_state->max_requested_bpc != in drm_atomic_helper_check_modeset()
708 new_connector_state->max_requested_bpc) in drm_atomic_helper_check_modeset()
709 new_crtc_state->connectors_changed = true; in drm_atomic_helper_check_modeset()
712 if (funcs->atomic_check) in drm_atomic_helper_check_modeset()
713 ret = funcs->atomic_check(connector, state); in drm_atomic_helper_check_modeset()
717 connector->base.id, connector->name); in drm_atomic_helper_check_modeset()
736 crtc->base.id, crtc->name, in drm_atomic_helper_check_modeset()
737 new_crtc_state->enable ? 'y' : 'n', in drm_atomic_helper_check_modeset()
738 new_crtc_state->active ? 'y' : 'n'); in drm_atomic_helper_check_modeset()
754 const struct drm_connector_helper_funcs *funcs = connector->helper_private; in drm_atomic_helper_check_modeset()
759 if (funcs->atomic_check) in drm_atomic_helper_check_modeset()
760 ret = funcs->atomic_check(connector, state); in drm_atomic_helper_check_modeset()
764 connector->base.id, connector->name); in drm_atomic_helper_check_modeset()
778 encoder = old_connector_state->best_encoder; in drm_atomic_helper_check_modeset()
783 encoder = new_connector_state->best_encoder; in drm_atomic_helper_check_modeset()
798 * drm_atomic_helper_check_wb_encoder_state() - Check writeback encoder state
806 * Zero for success or -errno
812 struct drm_writeback_job *wb_job = conn_state->writeback_job; in drm_atomic_helper_check_wb_encoder_state()
818 if (!wb_job || !wb_job->fb) in drm_atomic_helper_check_wb_encoder_state()
821 pixel_format_blob = wb_job->connector->pixel_formats_blob_ptr; in drm_atomic_helper_check_wb_encoder_state()
822 nformats = pixel_format_blob->length / sizeof(u32); in drm_atomic_helper_check_wb_encoder_state()
823 formats = pixel_format_blob->data; in drm_atomic_helper_check_wb_encoder_state()
824 fb = wb_job->fb; in drm_atomic_helper_check_wb_encoder_state()
827 if (fb->format->format == formats[i]) in drm_atomic_helper_check_wb_encoder_state()
830 drm_dbg_kms(encoder->dev, "Invalid pixel format %p4cc\n", &fb->format->format); in drm_atomic_helper_check_wb_encoder_state()
832 return -EINVAL; in drm_atomic_helper_check_wb_encoder_state()
837 * drm_atomic_helper_check_plane_state() - Check plane state for validity
850 * their own plane handling rather than helper-provided implementations may
864 struct drm_framebuffer *fb = plane_state->fb; in drm_atomic_helper_check_plane_state()
865 struct drm_rect *src = &plane_state->src; in drm_atomic_helper_check_plane_state()
866 struct drm_rect *dst = &plane_state->dst; in drm_atomic_helper_check_plane_state()
867 unsigned int rotation = plane_state->rotation; in drm_atomic_helper_check_plane_state()
871 WARN_ON(plane_state->crtc && plane_state->crtc != crtc_state->crtc); in drm_atomic_helper_check_plane_state()
877 plane_state->visible = false; in drm_atomic_helper_check_plane_state()
882 if (WARN_ON(!plane_state->crtc)) { in drm_atomic_helper_check_plane_state()
883 plane_state->visible = false; in drm_atomic_helper_check_plane_state()
887 if (!crtc_state->enable && !can_update_disabled) { in drm_atomic_helper_check_plane_state()
888 drm_dbg_kms(plane_state->plane->dev, in drm_atomic_helper_check_plane_state()
890 return -EINVAL; in drm_atomic_helper_check_plane_state()
893 drm_rect_rotate(src, fb->width << 16, fb->height << 16, rotation); in drm_atomic_helper_check_plane_state()
899 drm_dbg_kms(plane_state->plane->dev, in drm_atomic_helper_check_plane_state()
901 drm_rect_debug_print("src: ", &plane_state->src, true); in drm_atomic_helper_check_plane_state()
902 drm_rect_debug_print("dst: ", &plane_state->dst, false); in drm_atomic_helper_check_plane_state()
903 return -ERANGE; in drm_atomic_helper_check_plane_state()
906 if (crtc_state->enable) in drm_atomic_helper_check_plane_state()
907 drm_mode_get_hv_timing(&crtc_state->mode, &clip.x2, &clip.y2); in drm_atomic_helper_check_plane_state()
909 plane_state->visible = drm_rect_clip_scaled(src, dst, &clip); in drm_atomic_helper_check_plane_state()
911 drm_rect_rotate_inv(src, fb->width << 16, fb->height << 16, rotation); in drm_atomic_helper_check_plane_state()
913 if (!plane_state->visible) in drm_atomic_helper_check_plane_state()
924 drm_dbg_kms(plane_state->plane->dev, in drm_atomic_helper_check_plane_state()
928 return -EINVAL; in drm_atomic_helper_check_plane_state()
936 * drm_atomic_helper_check_crtc_primary_plane() - Check CRTC state for primary plane
950 struct drm_crtc *crtc = crtc_state->crtc; in drm_atomic_helper_check_crtc_primary_plane()
951 struct drm_device *dev = crtc->dev; in drm_atomic_helper_check_crtc_primary_plane()
955 drm_for_each_plane_mask(plane, dev, crtc_state->plane_mask) { in drm_atomic_helper_check_crtc_primary_plane()
956 if (plane->type == DRM_PLANE_TYPE_PRIMARY) in drm_atomic_helper_check_crtc_primary_plane()
960 drm_dbg_atomic(dev, "[CRTC:%d:%s] primary plane missing\n", crtc->base.id, crtc->name); in drm_atomic_helper_check_crtc_primary_plane()
962 return -EINVAL; in drm_atomic_helper_check_crtc_primary_plane()
967 * drm_atomic_helper_check_planes - validate state object for planes changes
980 * Zero for success or -errno
995 WARN_ON(!drm_modeset_is_locked(&plane->mutex)); in drm_atomic_helper_check_planes()
997 funcs = plane->helper_private; in drm_atomic_helper_check_planes()
1003 if (!funcs || !funcs->atomic_check) in drm_atomic_helper_check_planes()
1006 ret = funcs->atomic_check(plane, state); in drm_atomic_helper_check_planes()
1008 drm_dbg_atomic(plane->dev, in drm_atomic_helper_check_planes()
1010 plane->base.id, plane->name); in drm_atomic_helper_check_planes()
1018 funcs = crtc->helper_private; in drm_atomic_helper_check_planes()
1020 if (!funcs || !funcs->atomic_check) in drm_atomic_helper_check_planes()
1023 ret = funcs->atomic_check(crtc, state); in drm_atomic_helper_check_planes()
1025 drm_dbg_atomic(crtc->dev, in drm_atomic_helper_check_planes()
1027 crtc->base.id, crtc->name); in drm_atomic_helper_check_planes()
1037 * drm_atomic_helper_check - validate state object
1060 * Zero for success or -errno
1071 if (dev->mode_config.normalize_zpos) { in drm_atomic_helper_check()
1081 if (state->legacy_cursor_update) in drm_atomic_helper_check()
1082 state->async_update = !drm_atomic_helper_async_check(dev, state); in drm_atomic_helper_check()
1103 * self-refresh and changing CRTCs at the same time, because the in crtc_needs_disable()
1104 * bridge tracks self-refresh status via CRTC state. in crtc_needs_disable()
1106 if (old_state->self_refresh_active && in crtc_needs_disable()
1107 old_state->crtc != new_state->crtc) in crtc_needs_disable()
1111 * We also need to run through the crtc_funcs->disable() function if in crtc_needs_disable()
1116 return old_state->active || in crtc_needs_disable()
1117 (old_state->self_refresh_active && !new_state->active) || in crtc_needs_disable()
1118 new_state->self_refresh_active; in crtc_needs_disable()
1139 if (!old_conn_state->crtc) in disable_outputs()
1142 old_crtc_state = drm_atomic_get_old_crtc_state(old_state, old_conn_state->crtc); in disable_outputs()
1144 if (new_conn_state->crtc) in disable_outputs()
1147 new_conn_state->crtc); in disable_outputs()
1152 !drm_atomic_crtc_needs_modeset(old_conn_state->crtc->state)) in disable_outputs()
1155 encoder = old_conn_state->best_encoder; in disable_outputs()
1163 funcs = encoder->helper_private; in disable_outputs()
1166 encoder->base.id, encoder->name); in disable_outputs()
1177 if (funcs->atomic_disable) in disable_outputs()
1178 funcs->atomic_disable(encoder, old_state); in disable_outputs()
1179 else if (new_conn_state->crtc && funcs->prepare) in disable_outputs()
1180 funcs->prepare(encoder); in disable_outputs()
1181 else if (funcs->disable) in disable_outputs()
1182 funcs->disable(encoder); in disable_outputs()
1183 else if (funcs->dpms) in disable_outputs()
1184 funcs->dpms(encoder, DRM_MODE_DPMS_OFF); in disable_outputs()
1201 funcs = crtc->helper_private; in disable_outputs()
1204 crtc->base.id, crtc->name); in disable_outputs()
1208 if (new_crtc_state->enable && funcs->prepare) in disable_outputs()
1209 funcs->prepare(crtc); in disable_outputs()
1210 else if (funcs->atomic_disable) in disable_outputs()
1211 funcs->atomic_disable(crtc, old_state); in disable_outputs()
1212 else if (funcs->disable) in disable_outputs()
1213 funcs->disable(crtc); in disable_outputs()
1214 else if (funcs->dpms) in disable_outputs()
1215 funcs->dpms(crtc, DRM_MODE_DPMS_OFF); in disable_outputs()
1222 * Self-refresh is not a true "disable"; ensure vblank remains in disable_outputs()
1225 if (new_crtc_state->self_refresh_active) in disable_outputs()
1227 "driver disabled vblank in self-refresh\n"); in disable_outputs()
1229 WARN_ONCE(ret != -EINVAL, in disable_outputs()
1237 * drm_atomic_helper_update_legacy_modeset_state - update legacy modeset state
1245 * a pure helper-based modeset implementation.
1265 if (connector->encoder) { in drm_atomic_helper_update_legacy_modeset_state()
1266 WARN_ON(!connector->encoder->crtc); in drm_atomic_helper_update_legacy_modeset_state()
1268 connector->encoder->crtc = NULL; in drm_atomic_helper_update_legacy_modeset_state()
1269 connector->encoder = NULL; in drm_atomic_helper_update_legacy_modeset_state()
1272 crtc = new_conn_state->crtc; in drm_atomic_helper_update_legacy_modeset_state()
1273 if ((!crtc && old_conn_state->crtc) || in drm_atomic_helper_update_legacy_modeset_state()
1274 (crtc && drm_atomic_crtc_needs_modeset(crtc->state))) { in drm_atomic_helper_update_legacy_modeset_state()
1277 if (crtc && crtc->state->active) in drm_atomic_helper_update_legacy_modeset_state()
1280 connector->dpms = mode; in drm_atomic_helper_update_legacy_modeset_state()
1286 if (!new_conn_state->crtc) in drm_atomic_helper_update_legacy_modeset_state()
1289 if (WARN_ON(!new_conn_state->best_encoder)) in drm_atomic_helper_update_legacy_modeset_state()
1292 connector->encoder = new_conn_state->best_encoder; in drm_atomic_helper_update_legacy_modeset_state()
1293 connector->encoder->crtc = new_conn_state->crtc; in drm_atomic_helper_update_legacy_modeset_state()
1298 struct drm_plane *primary = crtc->primary; in drm_atomic_helper_update_legacy_modeset_state()
1301 crtc->mode = new_crtc_state->mode; in drm_atomic_helper_update_legacy_modeset_state()
1302 crtc->enabled = new_crtc_state->enable; in drm_atomic_helper_update_legacy_modeset_state()
1307 if (new_plane_state && new_plane_state->crtc == crtc) { in drm_atomic_helper_update_legacy_modeset_state()
1308 crtc->x = new_plane_state->src_x >> 16; in drm_atomic_helper_update_legacy_modeset_state()
1309 crtc->y = new_plane_state->src_y >> 16; in drm_atomic_helper_update_legacy_modeset_state()
1316 * drm_atomic_helper_calc_timestamping_constants - update vblank timestamping constants
1329 if (new_crtc_state->enable) in drm_atomic_helper_calc_timestamping_constants()
1331 &new_crtc_state->adjusted_mode); in drm_atomic_helper_calc_timestamping_constants()
1348 if (!new_crtc_state->mode_changed) in crtc_set_mode()
1351 funcs = crtc->helper_private; in crtc_set_mode()
1353 if (new_crtc_state->enable && funcs->mode_set_nofb) { in crtc_set_mode()
1355 crtc->base.id, crtc->name); in crtc_set_mode()
1357 funcs->mode_set_nofb(crtc); in crtc_set_mode()
1367 if (!new_conn_state->best_encoder) in crtc_set_mode()
1370 encoder = new_conn_state->best_encoder; in crtc_set_mode()
1371 funcs = encoder->helper_private; in crtc_set_mode()
1372 new_crtc_state = new_conn_state->crtc->state; in crtc_set_mode()
1373 mode = &new_crtc_state->mode; in crtc_set_mode()
1374 adjusted_mode = &new_crtc_state->adjusted_mode; in crtc_set_mode()
1376 if (!new_crtc_state->mode_changed) in crtc_set_mode()
1380 encoder->base.id, encoder->name); in crtc_set_mode()
1386 if (funcs && funcs->atomic_mode_set) { in crtc_set_mode()
1387 funcs->atomic_mode_set(encoder, new_crtc_state, in crtc_set_mode()
1389 } else if (funcs && funcs->mode_set) { in crtc_set_mode()
1390 funcs->mode_set(encoder, mode, adjusted_mode); in crtc_set_mode()
1399 * drm_atomic_helper_commit_modeset_disables - modeset commit to disable outputs
1434 funcs = connector->helper_private; in drm_atomic_helper_commit_writebacks()
1435 if (!funcs->atomic_commit) in drm_atomic_helper_commit_writebacks()
1438 if (new_conn_state->writeback_job && new_conn_state->writeback_job->fb) { in drm_atomic_helper_commit_writebacks()
1439 WARN_ON(connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK); in drm_atomic_helper_commit_writebacks()
1440 funcs->atomic_commit(connector, old_state); in drm_atomic_helper_commit_writebacks()
1446 * drm_atomic_helper_commit_modeset_enables - modeset commit to enable outputs
1476 if (!new_crtc_state->active) in drm_atomic_helper_commit_modeset_enables()
1479 funcs = crtc->helper_private; in drm_atomic_helper_commit_modeset_enables()
1481 if (new_crtc_state->enable) { in drm_atomic_helper_commit_modeset_enables()
1483 crtc->base.id, crtc->name); in drm_atomic_helper_commit_modeset_enables()
1484 if (funcs->atomic_enable) in drm_atomic_helper_commit_modeset_enables()
1485 funcs->atomic_enable(crtc, old_state); in drm_atomic_helper_commit_modeset_enables()
1486 else if (funcs->commit) in drm_atomic_helper_commit_modeset_enables()
1487 funcs->commit(crtc); in drm_atomic_helper_commit_modeset_enables()
1496 if (!new_conn_state->best_encoder) in drm_atomic_helper_commit_modeset_enables()
1499 if (!new_conn_state->crtc->state->active || in drm_atomic_helper_commit_modeset_enables()
1500 !drm_atomic_crtc_needs_modeset(new_conn_state->crtc->state)) in drm_atomic_helper_commit_modeset_enables()
1503 encoder = new_conn_state->best_encoder; in drm_atomic_helper_commit_modeset_enables()
1504 funcs = encoder->helper_private; in drm_atomic_helper_commit_modeset_enables()
1507 encoder->base.id, encoder->name); in drm_atomic_helper_commit_modeset_enables()
1517 if (funcs->atomic_enable) in drm_atomic_helper_commit_modeset_enables()
1518 funcs->atomic_enable(encoder, old_state); in drm_atomic_helper_commit_modeset_enables()
1519 else if (funcs->enable) in drm_atomic_helper_commit_modeset_enables()
1520 funcs->enable(encoder); in drm_atomic_helper_commit_modeset_enables()
1521 else if (funcs->commit) in drm_atomic_helper_commit_modeset_enables()
1522 funcs->commit(encoder); in drm_atomic_helper_commit_modeset_enables()
1552 if (!new_crtc_state->active) in set_fence_deadline()
1567 if (!new_plane_state->fence) in set_fence_deadline()
1569 dma_fence_set_deadline(new_plane_state->fence, vbltime); in set_fence_deadline()
1574 * drm_atomic_helper_wait_for_fences - wait for fences stashed in plane state
1587 * non-blocking. For non-blocking commit all waiting needs to happen after
1605 if (!new_plane_state->fence) in drm_atomic_helper_wait_for_fences()
1608 WARN_ON(!new_plane_state->fb); in drm_atomic_helper_wait_for_fences()
1611 * If waiting for fences pre-swap (ie: nonblock), userspace can in drm_atomic_helper_wait_for_fences()
1615 ret = dma_fence_wait(new_plane_state->fence, pre_swap); in drm_atomic_helper_wait_for_fences()
1619 dma_fence_put(new_plane_state->fence); in drm_atomic_helper_wait_for_fences()
1620 new_plane_state->fence = NULL; in drm_atomic_helper_wait_for_fences()
1628 * drm_atomic_helper_wait_for_vblanks - wait for vblank on CRTCs
1636 * plane update use-case.
1655 if (old_state->legacy_cursor_update) in drm_atomic_helper_wait_for_vblanks()
1659 if (!new_crtc_state->active) in drm_atomic_helper_wait_for_vblanks()
1667 old_state->crtcs[i].last_vblank_count = drm_crtc_vblank_count(crtc); in drm_atomic_helper_wait_for_vblanks()
1674 ret = wait_event_timeout(dev->vblank[i].queue, in drm_atomic_helper_wait_for_vblanks()
1675 old_state->crtcs[i].last_vblank_count != in drm_atomic_helper_wait_for_vblanks()
1680 crtc->base.id, crtc->name); in drm_atomic_helper_wait_for_vblanks()
1688 * drm_atomic_helper_wait_for_flip_done - wait for all page flips to be done
1696 * CRTCs, assuming that cursors-only updates are signalling their completion
1708 for (i = 0; i < dev->mode_config.num_crtc; i++) { in drm_atomic_helper_wait_for_flip_done()
1709 struct drm_crtc_commit *commit = old_state->crtcs[i].commit; in drm_atomic_helper_wait_for_flip_done()
1712 crtc = old_state->crtcs[i].ptr; in drm_atomic_helper_wait_for_flip_done()
1717 ret = wait_for_completion_timeout(&commit->flip_done, 10 * HZ); in drm_atomic_helper_wait_for_flip_done()
1720 crtc->base.id, crtc->name); in drm_atomic_helper_wait_for_flip_done()
1723 if (old_state->fake_commit) in drm_atomic_helper_wait_for_flip_done()
1724 complete_all(&old_state->fake_commit->flip_done); in drm_atomic_helper_wait_for_flip_done()
1729 * drm_atomic_helper_commit_tail - commit atomic update to hardware
1743 struct drm_device *dev = old_state->dev; in drm_atomic_helper_commit_tail()
1762 * drm_atomic_helper_commit_tail_rpm - commit atomic update to hardware
1773 struct drm_device *dev = old_state->dev; in drm_atomic_helper_commit_tail_rpm()
1794 struct drm_device *dev = old_state->dev; in commit_tail()
1802 funcs = dev->mode_config.helper_private; in commit_tail()
1823 * self-refresh active beforehand: in commit_tail()
1826 if (new_crtc_state->self_refresh_active) in commit_tail()
1829 if (funcs && funcs->atomic_commit_tail) in commit_tail()
1830 funcs->atomic_commit_tail(old_state); in commit_tail()
1854 * drm_atomic_helper_async_check - check if state can be committed asynchronously
1860 * but just do in-place changes on the current state.
1879 return -EINVAL; in drm_atomic_helper_async_check()
1889 return -EINVAL; in drm_atomic_helper_async_check()
1892 if (!new_plane_state->crtc || in drm_atomic_helper_async_check()
1893 old_plane_state->crtc != new_plane_state->crtc) { in drm_atomic_helper_async_check()
1896 plane->base.id, plane->name); in drm_atomic_helper_async_check()
1897 return -EINVAL; in drm_atomic_helper_async_check()
1900 funcs = plane->helper_private; in drm_atomic_helper_async_check()
1901 if (!funcs->atomic_async_update) { in drm_atomic_helper_async_check()
1904 plane->base.id, plane->name); in drm_atomic_helper_async_check()
1905 return -EINVAL; in drm_atomic_helper_async_check()
1908 if (new_plane_state->fence) { in drm_atomic_helper_async_check()
1911 plane->base.id, plane->name); in drm_atomic_helper_async_check()
1912 return -EINVAL; in drm_atomic_helper_async_check()
1920 if (old_plane_state->commit && in drm_atomic_helper_async_check()
1921 !try_wait_for_completion(&old_plane_state->commit->hw_done)) { in drm_atomic_helper_async_check()
1924 plane->base.id, plane->name); in drm_atomic_helper_async_check()
1925 return -EBUSY; in drm_atomic_helper_async_check()
1928 ret = funcs->atomic_async_check(plane, state); in drm_atomic_helper_async_check()
1932 plane->base.id, plane->name); in drm_atomic_helper_async_check()
1938 * drm_atomic_helper_async_commit - commit state asynchronously
1945 * the states like normal sync commits, but just do in-place changes on the
1948 * TODO: Implement full swap instead of doing in-place changes.
1959 struct drm_framebuffer *new_fb = plane_state->fb; in drm_atomic_helper_async_commit()
1960 struct drm_framebuffer *old_fb = plane->state->fb; in drm_atomic_helper_async_commit()
1962 funcs = plane->helper_private; in drm_atomic_helper_async_commit()
1963 funcs->atomic_async_update(plane, state); in drm_atomic_helper_async_commit()
1966 * ->atomic_async_update() is supposed to update the in drm_atomic_helper_async_commit()
1967 * plane->state in-place, make sure at least common in drm_atomic_helper_async_commit()
1970 WARN_ON_ONCE(plane->state->fb != new_fb); in drm_atomic_helper_async_commit()
1971 WARN_ON_ONCE(plane->state->crtc_x != plane_state->crtc_x); in drm_atomic_helper_async_commit()
1972 WARN_ON_ONCE(plane->state->crtc_y != plane_state->crtc_y); in drm_atomic_helper_async_commit()
1973 WARN_ON_ONCE(plane->state->src_x != plane_state->src_x); in drm_atomic_helper_async_commit()
1974 WARN_ON_ONCE(plane->state->src_y != plane_state->src_y); in drm_atomic_helper_async_commit()
1980 WARN_ON_ONCE(plane_state->fb != old_fb); in drm_atomic_helper_async_commit()
1986 * drm_atomic_helper_commit - commit validated state object
1991 * This function commits a with drm_atomic_helper_check() pre-validated state
2001 * Zero for success or -errno.
2009 if (state->async_update) { in drm_atomic_helper_commit()
2024 INIT_WORK(&state->commit_work, commit_work); in drm_atomic_helper_commit()
2037 * This is the point of no return - everything below never fails except in drm_atomic_helper_commit()
2068 queue_work(system_unbound_wq, &state->commit_work); in drm_atomic_helper_commit()
2103 * individual commit in parallel - userspace is supposed to do that if it cares.
2122 * free-standing state objects (currently not the case for any driver) then even
2123 * multiple pending commits could be in-flight at the same time.
2125 * 4. Schedule a work item to do all subsequent steps, using the split-out
2126 * commit helpers: a) pre-plane commit b) plane commit c) post-plane commit and
2140 spin_lock(&crtc->commit_lock); in stall_checks()
2142 list_for_each_entry(commit, &crtc->commit_list, commit_entry) { in stall_checks()
2144 completed = try_wait_for_completion(&commit->flip_done); in stall_checks()
2150 spin_unlock(&crtc->commit_lock); in stall_checks()
2151 drm_dbg_atomic(crtc->dev, in stall_checks()
2153 crtc->base.id, crtc->name); in stall_checks()
2155 return -EBUSY; in stall_checks()
2164 spin_unlock(&crtc->commit_lock); in stall_checks()
2170 * stalling on 2nd previous commit means triple-buffer won't ever stall. in stall_checks()
2172 ret = wait_for_completion_interruptible_timeout(&stall_commit->cleanup_done, in stall_checks()
2175 drm_err(crtc->dev, "[CRTC:%d:%s] cleanup_done timed out\n", in stall_checks()
2176 crtc->base.id, crtc->name); in stall_checks()
2194 init_completion(&commit->flip_done); in init_commit()
2195 init_completion(&commit->hw_done); in init_commit()
2196 init_completion(&commit->cleanup_done); in init_commit()
2197 INIT_LIST_HEAD(&commit->commit_entry); in init_commit()
2198 kref_init(&commit->ref); in init_commit()
2199 commit->crtc = crtc; in init_commit()
2210 return new_crtc_state->commit; in crtc_or_fake_commit()
2213 if (!state->fake_commit) { in crtc_or_fake_commit()
2214 state->fake_commit = kzalloc(sizeof(*state->fake_commit), GFP_KERNEL); in crtc_or_fake_commit()
2215 if (!state->fake_commit) in crtc_or_fake_commit()
2218 init_commit(state->fake_commit, NULL); in crtc_or_fake_commit()
2221 return state->fake_commit; in crtc_or_fake_commit()
2225 * drm_atomic_helper_setup_commit - setup possibly nonblocking commit
2248 * Only the free standing @state with pointers to the old state structures can
2256 * complete and easy-to-use default implementation of the atomic_commit() hook.
2267 * 0 on success. -EBUSY when userspace schedules nonblocking commits too fast,
2268 * -ENOMEM on allocation failures and -EINTR when a signal is pending.
2283 funcs = state->dev->mode_config.helper_private; in drm_atomic_helper_setup_commit()
2288 return -ENOMEM; in drm_atomic_helper_setup_commit()
2292 new_crtc_state->commit = commit; in drm_atomic_helper_setup_commit()
2303 if (!old_crtc_state->active && !new_crtc_state->active) { in drm_atomic_helper_setup_commit()
2304 complete_all(&commit->flip_done); in drm_atomic_helper_setup_commit()
2309 if (state->legacy_cursor_update) { in drm_atomic_helper_setup_commit()
2310 complete_all(&commit->flip_done); in drm_atomic_helper_setup_commit()
2314 if (!new_crtc_state->event) { in drm_atomic_helper_setup_commit()
2315 commit->event = kzalloc(sizeof(*commit->event), in drm_atomic_helper_setup_commit()
2317 if (!commit->event) in drm_atomic_helper_setup_commit()
2318 return -ENOMEM; in drm_atomic_helper_setup_commit()
2320 new_crtc_state->event = commit->event; in drm_atomic_helper_setup_commit()
2323 new_crtc_state->event->base.completion = &commit->flip_done; in drm_atomic_helper_setup_commit()
2324 new_crtc_state->event->base.completion_release = release_crtc_commit; in drm_atomic_helper_setup_commit()
2327 commit->abort_completion = true; in drm_atomic_helper_setup_commit()
2329 state->crtcs[i].commit = commit; in drm_atomic_helper_setup_commit()
2338 if (nonblock && old_conn_state->commit && in drm_atomic_helper_setup_commit()
2339 !try_wait_for_completion(&old_conn_state->commit->flip_done)) { in drm_atomic_helper_setup_commit()
2340 drm_dbg_atomic(conn->dev, in drm_atomic_helper_setup_commit()
2342 conn->base.id, conn->name); in drm_atomic_helper_setup_commit()
2344 return -EBUSY; in drm_atomic_helper_setup_commit()
2348 commit = crtc_or_fake_commit(state, new_conn_state->crtc ?: old_conn_state->crtc); in drm_atomic_helper_setup_commit()
2350 return -ENOMEM; in drm_atomic_helper_setup_commit()
2352 new_conn_state->commit = drm_crtc_commit_get(commit); in drm_atomic_helper_setup_commit()
2360 if (nonblock && old_plane_state->commit && in drm_atomic_helper_setup_commit()
2361 !try_wait_for_completion(&old_plane_state->commit->flip_done)) { in drm_atomic_helper_setup_commit()
2362 drm_dbg_atomic(plane->dev, in drm_atomic_helper_setup_commit()
2364 plane->base.id, plane->name); in drm_atomic_helper_setup_commit()
2366 return -EBUSY; in drm_atomic_helper_setup_commit()
2370 commit = crtc_or_fake_commit(state, new_plane_state->crtc ?: old_plane_state->crtc); in drm_atomic_helper_setup_commit()
2372 return -ENOMEM; in drm_atomic_helper_setup_commit()
2374 new_plane_state->commit = drm_crtc_commit_get(commit); in drm_atomic_helper_setup_commit()
2377 if (funcs && funcs->atomic_commit_setup) in drm_atomic_helper_setup_commit()
2378 return funcs->atomic_commit_setup(state); in drm_atomic_helper_setup_commit()
2385 * drm_atomic_helper_wait_for_dependencies - wait for required preceeding commits
2408 ret = drm_crtc_commit_wait(old_crtc_state->commit); in drm_atomic_helper_wait_for_dependencies()
2410 drm_err(crtc->dev, in drm_atomic_helper_wait_for_dependencies()
2412 crtc->base.id, crtc->name); in drm_atomic_helper_wait_for_dependencies()
2416 ret = drm_crtc_commit_wait(old_conn_state->commit); in drm_atomic_helper_wait_for_dependencies()
2418 drm_err(conn->dev, in drm_atomic_helper_wait_for_dependencies()
2420 conn->base.id, conn->name); in drm_atomic_helper_wait_for_dependencies()
2424 ret = drm_crtc_commit_wait(old_plane_state->commit); in drm_atomic_helper_wait_for_dependencies()
2426 drm_err(plane->dev, in drm_atomic_helper_wait_for_dependencies()
2428 plane->base.id, plane->name); in drm_atomic_helper_wait_for_dependencies()
2434 * drm_atomic_helper_fake_vblank - fake VBLANK events if needed
2460 if (!new_crtc_state->no_vblank) in drm_atomic_helper_fake_vblank()
2463 spin_lock_irqsave(&old_state->dev->event_lock, flags); in drm_atomic_helper_fake_vblank()
2464 if (new_crtc_state->event) { in drm_atomic_helper_fake_vblank()
2466 new_crtc_state->event); in drm_atomic_helper_fake_vblank()
2467 new_crtc_state->event = NULL; in drm_atomic_helper_fake_vblank()
2469 spin_unlock_irqrestore(&old_state->dev->event_lock, flags); in drm_atomic_helper_fake_vblank()
2475 * drm_atomic_helper_commit_hw_done - setup possible nonblocking commit
2497 commit = new_crtc_state->commit; in drm_atomic_helper_commit_hw_done()
2502 * copy new_crtc_state->commit to old_crtc_state->commit, in drm_atomic_helper_commit_hw_done()
2506 if (old_crtc_state->commit) in drm_atomic_helper_commit_hw_done()
2507 drm_crtc_commit_put(old_crtc_state->commit); in drm_atomic_helper_commit_hw_done()
2509 old_crtc_state->commit = drm_crtc_commit_get(commit); in drm_atomic_helper_commit_hw_done()
2512 WARN_ON(new_crtc_state->event); in drm_atomic_helper_commit_hw_done()
2513 complete_all(&commit->hw_done); in drm_atomic_helper_commit_hw_done()
2516 if (old_state->fake_commit) { in drm_atomic_helper_commit_hw_done()
2517 complete_all(&old_state->fake_commit->hw_done); in drm_atomic_helper_commit_hw_done()
2518 complete_all(&old_state->fake_commit->flip_done); in drm_atomic_helper_commit_hw_done()
2524 * drm_atomic_helper_commit_cleanup_done - signal completion of commit
2542 commit = old_crtc_state->commit; in drm_atomic_helper_commit_cleanup_done()
2546 complete_all(&commit->cleanup_done); in drm_atomic_helper_commit_cleanup_done()
2547 WARN_ON(!try_wait_for_completion(&commit->hw_done)); in drm_atomic_helper_commit_cleanup_done()
2549 spin_lock(&crtc->commit_lock); in drm_atomic_helper_commit_cleanup_done()
2550 list_del(&commit->commit_entry); in drm_atomic_helper_commit_cleanup_done()
2551 spin_unlock(&crtc->commit_lock); in drm_atomic_helper_commit_cleanup_done()
2554 if (old_state->fake_commit) { in drm_atomic_helper_commit_cleanup_done()
2555 complete_all(&old_state->fake_commit->cleanup_done); in drm_atomic_helper_commit_cleanup_done()
2556 WARN_ON(!try_wait_for_completion(&old_state->fake_commit->hw_done)); in drm_atomic_helper_commit_cleanup_done()
2562 * drm_atomic_helper_prepare_planes - prepare plane resources before commit
2584 if (!new_conn_state->writeback_job) in drm_atomic_helper_prepare_planes()
2587 ret = drm_writeback_prepare_job(new_conn_state->writeback_job); in drm_atomic_helper_prepare_planes()
2595 funcs = plane->helper_private; in drm_atomic_helper_prepare_planes()
2597 if (funcs->prepare_fb) { in drm_atomic_helper_prepare_planes()
2598 ret = funcs->prepare_fb(plane, new_plane_state); in drm_atomic_helper_prepare_planes()
2602 WARN_ON_ONCE(funcs->cleanup_fb); in drm_atomic_helper_prepare_planes()
2614 const struct drm_plane_helper_funcs *funcs = plane->helper_private; in drm_atomic_helper_prepare_planes()
2616 if (funcs->begin_fb_access) { in drm_atomic_helper_prepare_planes()
2617 ret = funcs->begin_fb_access(plane, new_plane_state); in drm_atomic_helper_prepare_planes()
2627 const struct drm_plane_helper_funcs *funcs = plane->helper_private; in drm_atomic_helper_prepare_planes()
2632 if (funcs->end_fb_access) in drm_atomic_helper_prepare_planes()
2633 funcs->end_fb_access(plane, new_plane_state); in drm_atomic_helper_prepare_planes()
2643 funcs = plane->helper_private; in drm_atomic_helper_prepare_planes()
2645 if (funcs->cleanup_fb) in drm_atomic_helper_prepare_planes()
2646 funcs->cleanup_fb(plane, new_plane_state); in drm_atomic_helper_prepare_planes()
2654 * drm_atomic_helper_unprepare_planes - release plane resources on aborts
2671 const struct drm_plane_helper_funcs *funcs = plane->helper_private; in drm_atomic_helper_unprepare_planes()
2673 if (funcs->end_fb_access) in drm_atomic_helper_unprepare_planes()
2674 funcs->end_fb_access(plane, new_plane_state); in drm_atomic_helper_unprepare_planes()
2678 const struct drm_plane_helper_funcs *funcs = plane->helper_private; in drm_atomic_helper_unprepare_planes()
2680 if (funcs->cleanup_fb) in drm_atomic_helper_unprepare_planes()
2681 funcs->cleanup_fb(plane, new_plane_state); in drm_atomic_helper_unprepare_planes()
2688 return state->crtc && state->crtc->state->active; in plane_crtc_active()
2692 * drm_atomic_helper_commit_planes - commit plane state
2747 funcs = crtc->helper_private; in drm_atomic_helper_commit_planes()
2749 if (!funcs || !funcs->atomic_begin) in drm_atomic_helper_commit_planes()
2752 if (active_only && !new_crtc_state->active) in drm_atomic_helper_commit_planes()
2755 funcs->atomic_begin(crtc, old_state); in drm_atomic_helper_commit_planes()
2762 funcs = plane->helper_private; in drm_atomic_helper_commit_planes()
2785 * Special-case disabling the plane if drivers support it. in drm_atomic_helper_commit_planes()
2787 if (disabling && funcs->atomic_disable) { in drm_atomic_helper_commit_planes()
2790 crtc_state = old_plane_state->crtc->state; in drm_atomic_helper_commit_planes()
2796 funcs->atomic_disable(plane, old_state); in drm_atomic_helper_commit_planes()
2797 } else if (new_plane_state->crtc || disabling) { in drm_atomic_helper_commit_planes()
2798 funcs->atomic_update(plane, old_state); in drm_atomic_helper_commit_planes()
2800 if (!disabling && funcs->atomic_enable) { in drm_atomic_helper_commit_planes()
2802 funcs->atomic_enable(plane, old_state); in drm_atomic_helper_commit_planes()
2810 funcs = crtc->helper_private; in drm_atomic_helper_commit_planes()
2812 if (!funcs || !funcs->atomic_flush) in drm_atomic_helper_commit_planes()
2815 if (active_only && !new_crtc_state->active) in drm_atomic_helper_commit_planes()
2818 funcs->atomic_flush(crtc, old_state); in drm_atomic_helper_commit_planes()
2826 const struct drm_plane_helper_funcs *funcs = plane->helper_private; in drm_atomic_helper_commit_planes()
2828 if (funcs->end_fb_access) in drm_atomic_helper_commit_planes()
2829 funcs->end_fb_access(plane, old_plane_state); in drm_atomic_helper_commit_planes()
2835 * drm_atomic_helper_commit_planes_on_crtc - commit plane state for a CRTC
2843 * This function is useful when plane updates should be done CRTC-by-CRTC
2847 * between different CRTCs because this function doesn't handle inter-CRTC
2855 struct drm_crtc *crtc = old_crtc_state->crtc; in drm_atomic_helper_commit_planes_on_crtc()
2856 struct drm_atomic_state *old_state = old_crtc_state->state; in drm_atomic_helper_commit_planes_on_crtc()
2862 plane_mask = old_crtc_state->plane_mask; in drm_atomic_helper_commit_planes_on_crtc()
2863 plane_mask |= new_crtc_state->plane_mask; in drm_atomic_helper_commit_planes_on_crtc()
2865 crtc_funcs = crtc->helper_private; in drm_atomic_helper_commit_planes_on_crtc()
2866 if (crtc_funcs && crtc_funcs->atomic_begin) in drm_atomic_helper_commit_planes_on_crtc()
2867 crtc_funcs->atomic_begin(crtc, old_state); in drm_atomic_helper_commit_planes_on_crtc()
2869 drm_for_each_plane_mask(plane, crtc->dev, plane_mask) { in drm_atomic_helper_commit_planes_on_crtc()
2877 plane_funcs = plane->helper_private; in drm_atomic_helper_commit_planes_on_crtc()
2882 WARN_ON(new_plane_state->crtc && in drm_atomic_helper_commit_planes_on_crtc()
2883 new_plane_state->crtc != crtc); in drm_atomic_helper_commit_planes_on_crtc()
2887 if (disabling && plane_funcs->atomic_disable) { in drm_atomic_helper_commit_planes_on_crtc()
2888 plane_funcs->atomic_disable(plane, old_state); in drm_atomic_helper_commit_planes_on_crtc()
2889 } else if (new_plane_state->crtc || disabling) { in drm_atomic_helper_commit_planes_on_crtc()
2890 plane_funcs->atomic_update(plane, old_state); in drm_atomic_helper_commit_planes_on_crtc()
2892 if (!disabling && plane_funcs->atomic_enable) { in drm_atomic_helper_commit_planes_on_crtc()
2894 plane_funcs->atomic_enable(plane, old_state); in drm_atomic_helper_commit_planes_on_crtc()
2899 if (crtc_funcs && crtc_funcs->atomic_flush) in drm_atomic_helper_commit_planes_on_crtc()
2900 crtc_funcs->atomic_flush(crtc, old_state); in drm_atomic_helper_commit_planes_on_crtc()
2905 * drm_atomic_helper_disable_planes_on_crtc - helper to disable CRTC's planes
2913 * If the atomic-parameter is set the function calls the CRTC's
2924 struct drm_crtc *crtc = old_crtc_state->crtc; in drm_atomic_helper_disable_planes_on_crtc()
2926 crtc->helper_private; in drm_atomic_helper_disable_planes_on_crtc()
2929 if (atomic && crtc_funcs && crtc_funcs->atomic_begin) in drm_atomic_helper_disable_planes_on_crtc()
2930 crtc_funcs->atomic_begin(crtc, NULL); in drm_atomic_helper_disable_planes_on_crtc()
2934 plane->helper_private; in drm_atomic_helper_disable_planes_on_crtc()
2939 WARN_ON(!plane_funcs->atomic_disable); in drm_atomic_helper_disable_planes_on_crtc()
2940 if (plane_funcs->atomic_disable) in drm_atomic_helper_disable_planes_on_crtc()
2941 plane_funcs->atomic_disable(plane, NULL); in drm_atomic_helper_disable_planes_on_crtc()
2944 if (atomic && crtc_funcs && crtc_funcs->atomic_flush) in drm_atomic_helper_disable_planes_on_crtc()
2945 crtc_funcs->atomic_flush(crtc, NULL); in drm_atomic_helper_disable_planes_on_crtc()
2950 * drm_atomic_helper_cleanup_planes - cleanup plane resources after commit
2970 const struct drm_plane_helper_funcs *funcs = plane->helper_private; in drm_atomic_helper_cleanup_planes()
2972 if (funcs->cleanup_fb) in drm_atomic_helper_cleanup_planes()
2973 funcs->cleanup_fb(plane, old_plane_state); in drm_atomic_helper_cleanup_planes()
2979 * drm_atomic_helper_swap_state - store atomic state into current sw state
3010 * Returns 0 on success. Can return -ERESTARTSYS when @stall is true and the
3032 * obj->state is directly dereferenced anywhere in the drivers in drm_atomic_helper_swap_state()
3038 commit = old_crtc_state->commit; in drm_atomic_helper_swap_state()
3043 ret = wait_for_completion_interruptible(&commit->hw_done); in drm_atomic_helper_swap_state()
3049 commit = old_conn_state->commit; in drm_atomic_helper_swap_state()
3054 ret = wait_for_completion_interruptible(&commit->hw_done); in drm_atomic_helper_swap_state()
3060 commit = old_plane_state->commit; in drm_atomic_helper_swap_state()
3065 ret = wait_for_completion_interruptible(&commit->hw_done); in drm_atomic_helper_swap_state()
3072 WARN_ON(connector->state != old_conn_state); in drm_atomic_helper_swap_state()
3074 old_conn_state->state = state; in drm_atomic_helper_swap_state()
3075 new_conn_state->state = NULL; in drm_atomic_helper_swap_state()
3077 state->connectors[i].state = old_conn_state; in drm_atomic_helper_swap_state()
3078 connector->state = new_conn_state; in drm_atomic_helper_swap_state()
3082 WARN_ON(crtc->state != old_crtc_state); in drm_atomic_helper_swap_state()
3084 old_crtc_state->state = state; in drm_atomic_helper_swap_state()
3085 new_crtc_state->state = NULL; in drm_atomic_helper_swap_state()
3087 state->crtcs[i].state = old_crtc_state; in drm_atomic_helper_swap_state()
3088 crtc->state = new_crtc_state; in drm_atomic_helper_swap_state()
3090 if (new_crtc_state->commit) { in drm_atomic_helper_swap_state()
3091 spin_lock(&crtc->commit_lock); in drm_atomic_helper_swap_state()
3092 list_add(&new_crtc_state->commit->commit_entry, in drm_atomic_helper_swap_state()
3093 &crtc->commit_list); in drm_atomic_helper_swap_state()
3094 spin_unlock(&crtc->commit_lock); in drm_atomic_helper_swap_state()
3096 new_crtc_state->commit->event = NULL; in drm_atomic_helper_swap_state()
3101 WARN_ON(plane->state != old_plane_state); in drm_atomic_helper_swap_state()
3103 old_plane_state->state = state; in drm_atomic_helper_swap_state()
3104 new_plane_state->state = NULL; in drm_atomic_helper_swap_state()
3106 state->planes[i].state = old_plane_state; in drm_atomic_helper_swap_state()
3107 plane->state = new_plane_state; in drm_atomic_helper_swap_state()
3111 WARN_ON(obj->state != old_obj_state); in drm_atomic_helper_swap_state()
3113 old_obj_state->state = state; in drm_atomic_helper_swap_state()
3114 new_obj_state->state = NULL; in drm_atomic_helper_swap_state()
3116 state->private_objs[i].state = old_obj_state; in drm_atomic_helper_swap_state()
3117 obj->state = new_obj_state; in drm_atomic_helper_swap_state()
3125 * drm_atomic_helper_update_plane - Helper for primary plane update using atomic
3157 state = drm_atomic_state_alloc(plane->dev); in drm_atomic_helper_update_plane()
3159 return -ENOMEM; in drm_atomic_helper_update_plane()
3161 state->acquire_ctx = ctx; in drm_atomic_helper_update_plane()
3172 plane_state->crtc_x = crtc_x; in drm_atomic_helper_update_plane()
3173 plane_state->crtc_y = crtc_y; in drm_atomic_helper_update_plane()
3174 plane_state->crtc_w = crtc_w; in drm_atomic_helper_update_plane()
3175 plane_state->crtc_h = crtc_h; in drm_atomic_helper_update_plane()
3176 plane_state->src_x = src_x; in drm_atomic_helper_update_plane()
3177 plane_state->src_y = src_y; in drm_atomic_helper_update_plane()
3178 plane_state->src_w = src_w; in drm_atomic_helper_update_plane()
3179 plane_state->src_h = src_h; in drm_atomic_helper_update_plane()
3181 if (plane == crtc->cursor) in drm_atomic_helper_update_plane()
3182 state->legacy_cursor_update = true; in drm_atomic_helper_update_plane()
3192 * drm_atomic_helper_disable_plane - Helper for primary plane disable using atomic
3208 state = drm_atomic_state_alloc(plane->dev); in drm_atomic_helper_disable_plane()
3210 return -ENOMEM; in drm_atomic_helper_disable_plane()
3212 state->acquire_ctx = ctx; in drm_atomic_helper_disable_plane()
3219 if (plane_state->crtc && plane_state->crtc->cursor == plane) in drm_atomic_helper_disable_plane()
3220 plane_state->state->legacy_cursor_update = true; in drm_atomic_helper_disable_plane()
3234 * drm_atomic_helper_set_config - set a new config from userspace
3241 * resets the "link-status" property to GOOD, to force any link
3242 * re-training. The SETCRTC ioctl does not define whether an update does
3253 struct drm_crtc *crtc = set->crtc; in drm_atomic_helper_set_config()
3256 state = drm_atomic_state_alloc(crtc->dev); in drm_atomic_helper_set_config()
3258 return -ENOMEM; in drm_atomic_helper_set_config()
3260 state->acquire_ctx = ctx; in drm_atomic_helper_set_config()
3278 * drm_atomic_helper_disable_all - disable all currently active outputs
3291 * return -EDEADLK, which must be handled by calling drm_modeset_backoff().
3314 return -ENOMEM; in drm_atomic_helper_disable_all()
3316 state->acquire_ctx = ctx; in drm_atomic_helper_disable_all()
3322 goto free; in drm_atomic_helper_disable_all()
3325 crtc_state->active = false; in drm_atomic_helper_disable_all()
3329 goto free; in drm_atomic_helper_disable_all()
3333 goto free; in drm_atomic_helper_disable_all()
3337 goto free; in drm_atomic_helper_disable_all()
3343 goto free; in drm_atomic_helper_disable_all()
3349 goto free; in drm_atomic_helper_disable_all()
3355 free: in drm_atomic_helper_disable_all()
3362 * drm_atomic_helper_shutdown - shutdown all CRTC
3390 * drm_atomic_helper_duplicate_state - duplicate an atomic state object
3404 * return -EDEADLK, which must be handled by calling drm_modeset_backoff().
3408 * ERR_PTR()-encoded error code on failure.
3426 return ERR_PTR(-ENOMEM); in drm_atomic_helper_duplicate_state()
3428 state->acquire_ctx = ctx; in drm_atomic_helper_duplicate_state()
3429 state->duplicated = true; in drm_atomic_helper_duplicate_state()
3437 goto free; in drm_atomic_helper_duplicate_state()
3447 goto free; in drm_atomic_helper_duplicate_state()
3459 goto free; in drm_atomic_helper_duplicate_state()
3465 state->acquire_ctx = NULL; in drm_atomic_helper_duplicate_state()
3467 free: in drm_atomic_helper_duplicate_state()
3478 * drm_atomic_helper_suspend - subsystem-level suspend helper
3493 * A pointer to a copy of the state before suspend on success or an ERR_PTR()-
3509 state = ERR_PTR(-EINVAL); in drm_atomic_helper_suspend()
3534 * drm_atomic_helper_commit_duplicated_state - commit duplicated state
3559 state->acquire_ctx = ctx; in drm_atomic_helper_commit_duplicated_state()
3562 state->planes[i].old_state = plane->state; in drm_atomic_helper_commit_duplicated_state()
3565 state->crtcs[i].old_state = crtc->state; in drm_atomic_helper_commit_duplicated_state()
3568 state->connectors[i].old_state = connector->state; in drm_atomic_helper_commit_duplicated_state()
3572 state->acquire_ctx = NULL; in drm_atomic_helper_commit_duplicated_state()
3579 * drm_atomic_helper_resume - subsystem-level resume helper
3586 * implement suspend/resume for drivers that support atomic mode-setting.
3619 struct drm_plane *plane = crtc->primary; in page_flip_common()
3628 crtc_state->event = event; in page_flip_common()
3629 crtc_state->async_flip = flags & DRM_MODE_PAGE_FLIP_ASYNC; in page_flip_common()
3641 state->allow_modeset = false; in page_flip_common()
3642 if (!crtc_state->active) { in page_flip_common()
3643 drm_dbg_atomic(crtc->dev, in page_flip_common()
3645 crtc->base.id, crtc->name); in page_flip_common()
3646 return -EINVAL; in page_flip_common()
3653 * drm_atomic_helper_page_flip - execute a legacy page flip
3657 * @flags: flip flags for non-vblank sync'ed updates
3675 struct drm_plane *plane = crtc->primary; in drm_atomic_helper_page_flip()
3679 state = drm_atomic_state_alloc(plane->dev); in drm_atomic_helper_page_flip()
3681 return -ENOMEM; in drm_atomic_helper_page_flip()
3683 state->acquire_ctx = ctx; in drm_atomic_helper_page_flip()
3697 * drm_atomic_helper_page_flip_target - do page flip on target vblank period.
3701 * @flags: flip flags for non-vblank sync'ed updates
3719 struct drm_plane *plane = crtc->primary; in drm_atomic_helper_page_flip_target()
3724 state = drm_atomic_state_alloc(plane->dev); in drm_atomic_helper_page_flip_target()
3726 return -ENOMEM; in drm_atomic_helper_page_flip_target()
3728 state->acquire_ctx = ctx; in drm_atomic_helper_page_flip_target()
3736 ret = -EINVAL; in drm_atomic_helper_page_flip_target()
3739 crtc_state->target_vblank = target; in drm_atomic_helper_page_flip_target()
3749 * drm_atomic_helper_bridge_propagate_bus_fmt() - Propagate output format to