From 43a6a02eb3558d1f3a0618f9bf02328662fb06e3 Mon Sep 17 00:00:00 2001 From: Nicholas Kazlauskas Date: Tue, 15 Jan 2019 10:33:58 -0500 Subject: drm/amd/display: Re-enable CRC capture following modeset [Why] During any modeset the CRTC stream is removed and a new stream is added. This new stream doesn't carry over CRC capture state if it was previously set. [How] Re-program the stream for CRC capture. The existing DRM callback can be re-used here for the most part - the only modification needed is additional locking now that it's called from within commit tail. Signed-off-by: Nicholas Kazlauskas Reviewed-by: Harry Wentland Reviewed-by: Sun peng Li Acked-by: Leo Li Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c') diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c index 26b651148c67..a10e3a50d9ef 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c @@ -64,6 +64,7 @@ amdgpu_dm_crtc_verify_crc_source(struct drm_crtc *crtc, const char *src_name, int amdgpu_dm_crtc_set_crc_source(struct drm_crtc *crtc, const char *src_name) { + struct amdgpu_device *adev = crtc->dev->dev_private; struct dm_crtc_state *crtc_state = to_dm_crtc_state(crtc->state); struct dc_stream_state *stream_state = crtc_state->stream; bool enable; @@ -83,15 +84,20 @@ int amdgpu_dm_crtc_set_crc_source(struct drm_crtc *crtc, const char *src_name) enable = (source == AMDGPU_DM_PIPE_CRC_SOURCE_AUTO); + mutex_lock(&adev->dm.dc_lock); if (!dc_stream_configure_crc(stream_state->ctx->dc, stream_state, - enable, enable)) + enable, enable)) { + mutex_unlock(&adev->dm.dc_lock); return -EINVAL; + } /* When enabling CRC, we should also disable dithering. */ dc_stream_set_dither_option(stream_state, enable ? DITHER_OPTION_TRUN8 : DITHER_OPTION_DEFAULT); + mutex_unlock(&adev->dm.dc_lock); + /* * Reading the CRC requires the vblank interrupt handler to be * enabled. Keep a reference until CRC capture stops. -- cgit v1.2.3