From 77d385f62dbcd359a4a11be2a037e2065fe97f5d Mon Sep 17 00:00:00 2001 From: Steve Cohen Date: Wed, 24 Mar 2021 16:14:46 -0400 Subject: [PATCH] disp: msm: sde: remove idle time from Qsync threshold calculation Remove idle time from the Qsync calculation, round down to the nearest multiple of 4 and remove a couple of extra lines to compensate for possible latencies. This helps to reduce the possibility of causing tearing due to the driver calculation mismatching with the DDIC's expected timeout value. Change-Id: I8a53a989e26cbd7f0e2b94caa8df8f5bee3ad26c Signed-off-by: Steve Cohen --- msm/sde/sde_encoder.c | 18 ------------------ msm/sde/sde_encoder_phys.h | 8 -------- msm/sde/sde_encoder_phys_cmd.c | 30 +++++++++++++----------------- 3 files changed, 13 insertions(+), 43 deletions(-) diff --git a/msm/sde/sde_encoder.c b/msm/sde/sde_encoder.c index 14da4f5d952e..14643150ee75 100644 --- a/msm/sde/sde_encoder.c +++ b/msm/sde/sde_encoder.c @@ -4286,24 +4286,6 @@ void sde_encoder_helper_get_pp_line_count(struct drm_encoder *drm_enc, } } -void sde_encoder_helper_get_transfer_time(struct drm_encoder *drm_enc, - u32 *transfer_time_us) -{ - struct sde_encoder_virt *sde_enc; - struct msm_mode_info *info; - - if (!drm_enc || !transfer_time_us) { - SDE_ERROR("bad arg: encoder:%d transfer_time:%d\n", !drm_enc, - !transfer_time_us); - return; - } - - sde_enc = to_sde_encoder_virt(drm_enc); - info = &sde_enc->mode_info; - - *transfer_time_us = info->mdp_transfer_time_us; -} - int sde_encoder_helper_reset_mixers(struct sde_encoder_phys *phys_enc, struct drm_framebuffer *fb) { diff --git a/msm/sde/sde_encoder_phys.h b/msm/sde/sde_encoder_phys.h index 710c1aff62b0..802140bd28c0 100644 --- a/msm/sde/sde_encoder_phys.h +++ b/msm/sde/sde_encoder_phys.h @@ -541,14 +541,6 @@ void sde_encoder_phys_setup_cdm(struct sde_encoder_phys *phys_enc, void sde_encoder_helper_get_pp_line_count(struct drm_encoder *drm_enc, struct sde_hw_pp_vsync_info *info); -/** - * sde_encoder_helper_get_transfer_time - get the mdp transfer time in usecs - * @drm_enc: Pointer to drm encoder structure - * @transfer_time_us: Pointer to store the output value - */ -void sde_encoder_helper_get_transfer_time(struct drm_encoder *drm_enc, - u32 *transfer_time_us); - /** * sde_encoder_helper_trigger_flush - control flush helper function * This helper function may be optionally specified by physical diff --git a/msm/sde/sde_encoder_phys_cmd.c b/msm/sde/sde_encoder_phys_cmd.c index e9c456aaa6d8..8dd05021abac 100644 --- a/msm/sde/sde_encoder_phys_cmd.c +++ b/msm/sde/sde_encoder_phys_cmd.c @@ -963,8 +963,6 @@ static int _get_tearcheck_threshold(struct sde_encoder_phys *phys_enc) u32 default_time_ns; u32 extra_time_ns; u32 default_line_time_ns; - u32 idle_time_ns = 0; - u32 transfer_time_us = 0; if (phys_enc->parent_ops.get_qsync_fps) phys_enc->parent_ops.get_qsync_fps( @@ -985,28 +983,26 @@ static int _get_tearcheck_threshold(struct sde_encoder_phys *phys_enc) } /* Calculate the number of extra lines*/ - slow_time_ns = (1 * 1000000000) / qsync_min_fps; - default_time_ns = (1 * 1000000000) / default_fps; - sde_encoder_helper_get_transfer_time(phys_enc->parent, - &transfer_time_us); - if (transfer_time_us) - idle_time_ns = default_time_ns - - (1000 * transfer_time_us); - - extra_time_ns = slow_time_ns - default_time_ns + idle_time_ns; - default_line_time_ns = (1 * 1000000000) / (default_fps * yres); + slow_time_ns = 1000000000 / qsync_min_fps; + default_time_ns = 1000000000 / default_fps; + extra_time_ns = slow_time_ns - default_time_ns; + default_line_time_ns = default_time_ns / yres; threshold_lines = extra_time_ns / default_line_time_ns; + /* round down to nearest multiple of 4 to compensate for rounding in DDIC */ + threshold_lines &= ~(4 - 1); + /* additional compensation for latency */ + if (threshold_lines - 2 > DEFAULT_TEARCHECK_SYNC_THRESH_START) + threshold_lines -= 2; + SDE_DEBUG_CMDENC(cmd_enc, "slow:%d default:%d extra:%d(ns)\n", slow_time_ns, default_time_ns, extra_time_ns); - SDE_DEBUG_CMDENC(cmd_enc, "xfer:%d(us) idle:%d(ns) lines:%d\n", - transfer_time_us, idle_time_ns, threshold_lines); - SDE_DEBUG_CMDENC(cmd_enc, "min_fps:%d fps:%d yres:%d\n", - qsync_min_fps, default_fps, yres); + SDE_DEBUG_CMDENC(cmd_enc, "min_fps:%d fps:%d yres:%d lines:%d\n", + qsync_min_fps, default_fps, yres, threshold_lines); SDE_EVT32(qsync_mode, qsync_min_fps, extra_time_ns, default_fps, - yres, transfer_time_us, threshold_lines); + yres, threshold_lines); } exit: