diff options
author | Shiyong Li <shiyongli@google.com> | 2023-03-29 18:04:06 +0000 |
---|---|---|
committer | Shiyong Li <shiyongli@google.com> | 2023-04-12 22:05:37 +0000 |
commit | d662610d6bf12d3fd1e2c3e3a34c03f4f447bdc5 (patch) | |
tree | 86d75d05e3ba1b3e53ad45dc929154eaa0fa0231 | |
parent | ca17e7c957c57610dce7574ba36aacc444eca3a5 (diff) | |
download | display-d662610d6bf12d3fd1e2c3e3a34c03f4f447bdc5.tar.gz |
samsung/panel: add the functions of waiting for vsync
Bug: 274187749
Change-Id: Iedd736ff7753da1ada8669e8f30c7603f87838ba
Signed-off-by: Shiyong Li <shiyongli@google.com>
-rw-r--r-- | samsung/panel/panel-samsung-drv.c | 33 | ||||
-rw-r--r-- | samsung/panel/panel-samsung-drv.h | 4 |
2 files changed, 37 insertions, 0 deletions
diff --git a/samsung/panel/panel-samsung-drv.c b/samsung/panel/panel-samsung-drv.c index eba999e..234577a 100644 --- a/samsung/panel/panel-samsung-drv.c +++ b/samsung/panel/panel-samsung-drv.c @@ -3400,6 +3400,39 @@ static u64 exynos_panel_vsync_start_time_us(u32 te_us, u32 te_period_us) return te_period_us * 55 / 100; } +int exynos_panel_wait_for_vblank(struct exynos_panel *ctx) +{ + struct drm_crtc *crtc = NULL; + + if (ctx->exynos_connector.base.state) + crtc = ctx->exynos_connector.base.state->crtc; + + if (crtc && !drm_crtc_vblank_get(crtc)) { + drm_crtc_wait_one_vblank(crtc); + drm_crtc_vblank_put(crtc); + return 0; + } + + WARN_ON(1); + return -ENODEV; +} +EXPORT_SYMBOL(exynos_panel_wait_for_vblank); + +void exynos_panel_wait_for_vsync_done(struct exynos_panel *ctx, u32 te_us, u32 period_us) +{ + u32 delay_us; + + if (unlikely(exynos_panel_wait_for_vblank(ctx))) { + delay_us = period_us + 1000; + usleep_range(delay_us, delay_us + 10); + return; + } + + delay_us = exynos_panel_vsync_start_time_us(te_us, period_us); + usleep_range(delay_us, delay_us + 10); +} +EXPORT_SYMBOL(exynos_panel_wait_for_vsync_done); + /* avoid accumulate te varaince cause predicted value is not accurate enough */ #define ACCEPTABLE_TE_PERIOD_DETLA_NS (3 * NSEC_PER_SEC) static ktime_t exynos_panel_te_ts_prediction(struct exynos_panel *ctx, ktime_t last_te, diff --git a/samsung/panel/panel-samsung-drv.h b/samsung/panel/panel-samsung-drv.h index f91f801..fe46b3b 100644 --- a/samsung/panel/panel-samsung-drv.h +++ b/samsung/panel/panel-samsung-drv.h @@ -913,6 +913,10 @@ static inline bool is_local_hbm_disabled(struct exynos_panel *ctx) i > 0; \ i--, data++) \ +#define EXYNOS_VREFRESH_TO_PERIOD_USEC(rate) DIV_ROUND_UP(USEC_PER_SEC, (rate) ? (rate) : 60) + +int exynos_panel_wait_for_vblank(struct exynos_panel *ctx); +void exynos_panel_wait_for_vsync_done(struct exynos_panel *ctx, u32 te_us, u32 period_us); unsigned int panel_get_idle_time_delta(struct exynos_panel *ctx); int exynos_panel_configure_te2_edges(struct exynos_panel *ctx, u32 *timings, bool lp_mode); |