drm/amd/display: Skip 2 frames when first reading CRC
authorLeo (Sunpeng) Li <sunpeng.li@amd.com>
Tue, 6 Feb 2018 15:20:46 +0000 (10:20 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 19 Feb 2018 19:20:11 +0000 (14:20 -0500)
Skipping the first frame will prevent uncoooked values most of the time.
However, in some unlikely cases, the second frame will be uncooked as
well.

Signed-off-by: Leo (Sunpeng) Li <sunpeng.li@amd.com>
Reviewed-by: Harry Wentland <Harry.Wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c

index ed93960..aa7df57 100644 (file)
@@ -198,7 +198,7 @@ struct dm_crtc_state {
        struct drm_crtc_state base;
        struct dc_stream_state *stream;
 
-       bool crc_first_skipped;
+       int crc_skip_count;
        bool crc_enabled;
 };
 
index 55aa379..52f2c01 100644 (file)
@@ -84,8 +84,8 @@ int amdgpu_dm_crtc_set_crc_source(struct drm_crtc *crtc, const char *src_name,
        }
 
        *values_cnt = 3;
-       /* Reset crc_skipped flag on dm state */
-       crtc_state->crc_first_skipped = false;
+       /* Reset crc_skipped on dm state */
+       crtc_state->crc_skip_count = 0;
        return 0;
 }
 
@@ -109,11 +109,11 @@ void amdgpu_dm_crtc_handle_crc_irq(struct drm_crtc *crtc)
        /*
         * Since flipping and crc enablement happen asynchronously, we - more
         * often than not - will be returning an 'uncooked' crc on first frame.
-        * Probably because hw isn't ready yet. Simply skip the first crc
-        * value.
+        * Probably because hw isn't ready yet. For added security, skip the
+        * first two CRC values.
         */
-       if (!crtc_state->crc_first_skipped) {
-               crtc_state->crc_first_skipped = true;
+       if (crtc_state->crc_skip_count < 2) {
+               crtc_state->crc_skip_count += 1;
                return;
        }