Skip to content

Commit 3dad690

Browse files
melissawenalexdeucher
authored andcommitted
drm/amd/display: add plane CTM support
Map the plane CTM driver-specific property to DC plane, instead of DC stream. The remaining steps to program DPP block are already implemented on DC shared-code. v3: - fix comment about plane and CRTC CTMs priorities (Harry) 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 34dc227 commit 3dad690

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9983,6 +9983,7 @@ static bool should_reset_plane(struct drm_atomic_state *state,
99839983
if (dm_old_other_state->degamma_tf != dm_new_other_state->degamma_tf ||
99849984
dm_old_other_state->degamma_lut != dm_new_other_state->degamma_lut ||
99859985
dm_old_other_state->hdr_mult != dm_new_other_state->hdr_mult ||
9986+
dm_old_other_state->ctm != dm_new_other_state->ctm ||
99869987
dm_old_other_state->shaper_lut != dm_new_other_state->shaper_lut ||
99879988
dm_old_other_state->shaper_tf != dm_new_other_state->shaper_tf ||
99889989
dm_old_other_state->lut3d != dm_new_other_state->lut3d ||

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,6 +1172,8 @@ int amdgpu_dm_update_plane_color_mgmt(struct dm_crtc_state *crtc,
11721172
struct dc_plane_state *dc_plane_state)
11731173
{
11741174
struct amdgpu_device *adev = drm_to_adev(crtc->base.state->dev);
1175+
struct dm_plane_state *dm_plane_state = to_dm_plane_state(plane_state);
1176+
struct drm_color_ctm *ctm = NULL;
11751177
struct dc_color_caps *color_caps = NULL;
11761178
bool has_crtc_cm_degamma;
11771179
int ret;
@@ -1224,5 +1226,29 @@ int amdgpu_dm_update_plane_color_mgmt(struct dm_crtc_state *crtc,
12241226
return ret;
12251227
}
12261228

1229+
/* Setup CRTC CTM. */
1230+
if (dm_plane_state->ctm) {
1231+
ctm = (struct drm_color_ctm *)dm_plane_state->ctm->data;
1232+
/*
1233+
* DCN2 and older don't support both pre-blending and
1234+
* post-blending gamut remap. For this HW family, if we have
1235+
* the plane and CRTC CTMs simultaneously, CRTC CTM takes
1236+
* priority, and we discard plane CTM, as implemented in
1237+
* dcn10_program_gamut_remap(). However, DCN3+ has DPP
1238+
* (pre-blending) and MPC (post-blending) `gamut remap` blocks;
1239+
* therefore, we can program plane and CRTC CTMs together by
1240+
* mapping CRTC CTM to MPC and keeping plane CTM setup at DPP,
1241+
* as it's done by dcn30_program_gamut_remap().
1242+
*/
1243+
__drm_ctm_to_dc_matrix(ctm, dc_plane_state->gamut_remap_matrix.matrix);
1244+
1245+
dc_plane_state->gamut_remap_matrix.enable_remap = true;
1246+
dc_plane_state->input_csc_color_matrix.enable_adjustment = false;
1247+
} else {
1248+
/* Bypass CTM. */
1249+
dc_plane_state->gamut_remap_matrix.enable_remap = false;
1250+
dc_plane_state->input_csc_color_matrix.enable_adjustment = false;
1251+
}
1252+
12271253
return amdgpu_dm_plane_set_color_properties(plane_state, dc_plane_state);
12281254
}

0 commit comments

Comments
 (0)