dc_stream_remove_writeback(dm->dc, crtc_state->stream, 0);
}
-static void amdgpu_dm_mod_power_update_streams(struct drm_atomic_state *state,
+ /**
+ * amdgpu_dm_mod_power_update_streams - update mod_power stream state on modeset
+ * @state: the drm atomic state
+ * @dm: the display manager to update mod_power on
+ *
+ * Notify mod_power of stream changes on modeset events, and disable PSR/Replay
+ * in preparation for hardware programming. See also
+ * amdgpu_dm_mod_power_setup_streams() for post-modeset mod_power setup.
+ */
-static void amdgpu_dm_mod_power_setup_streams(struct drm_atomic_state *state,
++static void amdgpu_dm_mod_power_update_streams(struct drm_atomic_commit *state,
+ struct amdgpu_display_manager *dm)
+ {
+ struct dm_crtc_state *dm_old_crtc_state, *dm_new_crtc_state;
+ struct drm_crtc_state *old_crtc_state, *new_crtc_state;
+ struct amdgpu_dm_connector *aconnector;
+ struct drm_crtc *crtc;
+ int i = 0;
+
+ for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
+ dm_old_crtc_state = to_dm_crtc_state(old_crtc_state);
+ dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
+
+ if (!drm_atomic_crtc_needs_modeset(new_crtc_state))
+ continue;
+
+ /*
+ * Update mod_power on modeset event in preparation for hw
+ * programming. Always use the old stream, since it would have
+ * been previously added to mod_power. If old stream is null (on
+ * crtc enable, for example), mod_power will no-op, which is the
+ * desried behavior.
+ */
+ if (old_crtc_state->active) {
+ scoped_guard(mutex, &dm->dc_lock) {
+ amdgpu_dm_psr_set_event(dm, dm_old_crtc_state->stream, true,
+ psr_event_hw_programming, true);
+ amdgpu_dm_replay_set_event(dm, dm_old_crtc_state->stream, true,
+ replay_event_hw_programming, true);
+ }
+ }
+
+ if (new_crtc_state->active) {
+ aconnector = (struct amdgpu_dm_connector *)
+ dm_new_crtc_state->stream->dm_stream_context;
+ if (old_crtc_state->active) {
+ mod_power_replace_stream(dm->power_module,
+ dm_old_crtc_state->stream,
+ dm_new_crtc_state->stream,
+ &aconnector->psr_caps);
+ } else {
+ mod_power_add_stream(dm->power_module,
+ dm_new_crtc_state->stream,
+ &aconnector->psr_caps);
+ }
+ } else if (old_crtc_state->active) {
+ mod_power_remove_stream(dm->power_module,
+ dm_old_crtc_state->stream);
+ }
+ }
+ }
+
+ /**
+ * amdgpu_dm_mod_power_setup_streams - setup mod_power stream state post modeset
+ * @state: the drm atomic state
+ * @dm: the display manager to update mod_power on
+ *
+ * Notify mod_power of mode_change. This needs to be done after dc_stream
+ * updates have been committed, and VRR parameters have been updated.
+ */
-static void amdgpu_dm_commit_streams(struct drm_atomic_state *state,
++static void amdgpu_dm_mod_power_setup_streams(struct drm_atomic_commit *state,
+ struct amdgpu_display_manager *dm)
+ {
+ struct dm_crtc_state *dm_new_crtc_state;
+ struct drm_crtc_state *new_crtc_state;
+ struct amdgpu_crtc *acrtc;
+ struct drm_crtc *crtc;
+ int i = 0;
+
+ for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
+ dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
+ acrtc = to_amdgpu_crtc(crtc);
+
+ if (!drm_atomic_crtc_needs_modeset(new_crtc_state))
+ continue;
+
+ if (new_crtc_state->active) {
+ amdgpu_dm_link_setup_replay(dm_new_crtc_state->stream,
+ &acrtc->dm_irq_params.vrr_params);
+ mod_power_notify_mode_change(dm->power_module,
+ dm_new_crtc_state->stream,
+ false);
+ }
+ }
+
+ }
+
+static void amdgpu_dm_commit_streams(struct drm_atomic_commit *state,
struct dc_state *dc_state)
{
struct drm_device *dev = state->dev;