Skip to content

Commit 2f9c638

Browse files
melissawenalexdeucher
authored andcommitted
drm/amd/display: update color on atomic commit time
Use `atomic_commit_setup` to change the DC stream state. It's a preparation to remove from `atomic_check` changes in CRTC color components of DC stream state and prevent DC to commit TEST_ONLY changes. Link: https://gitlab.freedesktop.org/drm/amd/-/issues/4444 Reviewed-by: Harry Wentland <harry.wentland@amd.com> Signed-off-by: Melissa Wen <mwen@igalia.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent cceb542 commit 2f9c638

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ static int amdgpu_dm_encoder_init(struct drm_device *dev,
233233

234234
static int amdgpu_dm_connector_get_modes(struct drm_connector *connector);
235235

236+
static int amdgpu_dm_atomic_setup_commit(struct drm_atomic_state *state);
236237
static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state);
237238

238239
static int amdgpu_dm_atomic_check(struct drm_device *dev,
@@ -3636,7 +3637,7 @@ static const struct drm_mode_config_funcs amdgpu_dm_mode_funcs = {
36363637

36373638
static struct drm_mode_config_helper_funcs amdgpu_dm_mode_config_helperfuncs = {
36383639
.atomic_commit_tail = amdgpu_dm_atomic_commit_tail,
3639-
.atomic_commit_setup = drm_dp_mst_atomic_setup_commit,
3640+
.atomic_commit_setup = amdgpu_dm_atomic_setup_commit,
36403641
};
36413642

36423643
static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector)
@@ -10362,6 +10363,39 @@ static void amdgpu_dm_update_hdcp(struct drm_atomic_state *state)
1036210363
}
1036310364
}
1036410365

10366+
static int amdgpu_dm_atomic_setup_commit(struct drm_atomic_state *state)
10367+
{
10368+
struct drm_crtc *crtc;
10369+
struct drm_crtc_state *old_crtc_state, *new_crtc_state;
10370+
struct dm_crtc_state *dm_old_crtc_state, *dm_new_crtc_state;
10371+
int i, ret;
10372+
10373+
ret = drm_dp_mst_atomic_setup_commit(state);
10374+
if (ret)
10375+
return ret;
10376+
10377+
for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
10378+
dm_old_crtc_state = to_dm_crtc_state(old_crtc_state);
10379+
dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
10380+
/*
10381+
* Color management settings. We also update color properties
10382+
* when a modeset is needed, to ensure it gets reprogrammed.
10383+
*/
10384+
if (dm_new_crtc_state->base.active && dm_new_crtc_state->stream &&
10385+
(dm_new_crtc_state->base.color_mgmt_changed ||
10386+
dm_old_crtc_state->regamma_tf != dm_new_crtc_state->regamma_tf ||
10387+
drm_atomic_crtc_needs_modeset(new_crtc_state))) {
10388+
ret = amdgpu_dm_update_crtc_color_mgmt(dm_new_crtc_state);
10389+
if (ret) {
10390+
drm_dbg_atomic(state->dev, "Failed to update color state\n");
10391+
return ret;
10392+
}
10393+
}
10394+
}
10395+
10396+
return 0;
10397+
}
10398+
1036510399
/**
1036610400
* amdgpu_dm_atomic_commit_tail() - AMDgpu DM's commit tail implementation.
1036710401
* @state: The atomic state to commit

0 commit comments

Comments
 (0)