present: Code cleanup of window to crtc timings update

Make the code more readable by going through some logical abort
conditions. Also make the function only about updating the crtc
msc value and not about also returning the next target msc.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
This commit is contained in:
Roman Gilg 2019-05-27 22:49:23 +02:00
parent 4d89ba0058
commit 8c2dcc5f80
2 changed files with 35 additions and 34 deletions

View File

@ -222,30 +222,28 @@ present_queue_vblank(ScreenPtr screen,
return ret;
}
static uint64_t
present_window_to_crtc_msc(WindowPtr window, RRCrtcPtr crtc, uint64_t window_msc, uint64_t new_msc)
static void
present_scmd_update_window_crtc(WindowPtr window, RRCrtcPtr crtc, uint64_t new_msc)
{
present_window_priv_ptr window_priv = present_get_window_priv(window, TRUE);
present_window_priv_ptr window_priv = present_get_window_priv(window, TRUE);
uint64_t old_ust, old_msc;
if (crtc != window_priv->crtc) {
uint64_t old_ust, old_msc;
/* Crtc unchanged, no offset. */
if (crtc == window_priv->crtc)
return;
if (window_priv->crtc == PresentCrtcNeverSet) {
window_priv->msc_offset = 0;
} else {
/* The old CRTC may have been turned off, in which case
* we'll just use whatever previous MSC we'd seen from this CRTC
*/
if (present_get_ust_msc(window->drawable.pScreen, window_priv->crtc, &old_ust, &old_msc) != Success)
old_msc = window_priv->msc;
window_priv->msc_offset += new_msc - old_msc;
}
/* No crtc earlier to offset against, just set the crtc first time. */
if (window_priv->crtc == PresentCrtcNeverSet) {
window_priv->crtc = crtc;
return;
}
return window_msc + window_priv->msc_offset;
/* Crtc may have been turned off, just use whatever previous MSC we'd seen from this CRTC. */
if (present_get_ust_msc(window->drawable.pScreen, window_priv->crtc, &old_ust, &old_msc) != Success)
old_msc = window_priv->msc;
window_priv->msc_offset += new_msc - old_msc;
window_priv->crtc = crtc;
}
/*
@ -682,7 +680,7 @@ present_scmd_pixmap(WindowPtr window,
ret = present_get_ust_msc(screen, target_crtc, &ust, &crtc_msc);
target_msc = present_window_to_crtc_msc(window, target_crtc, window_msc, crtc_msc);
present_scmd_update_window_crtc(window, target_crtc, crtc_msc);
if (ret == Success) {
/* Stash the current MSC away in case we need it later
@ -690,7 +688,7 @@ present_scmd_pixmap(WindowPtr window,
window_priv->msc = crtc_msc;
}
target_msc = present_get_target_msc(target_msc,
target_msc = present_get_target_msc(window_msc + window_priv->msc_offset,
crtc_msc,
divisor,
remainder,

View File

@ -519,25 +519,28 @@ present_wnmd_queue_vblank(ScreenPtr screen,
return (*screen_priv->wnmd_info->queue_vblank) (window, crtc, event_id, msc);
}
static uint64_t
present_wnmd_window_to_crtc_msc(WindowPtr window, RRCrtcPtr crtc, uint64_t window_msc, uint64_t new_msc)
static void
present_wnmd_update_window_crtc(WindowPtr window, RRCrtcPtr crtc, uint64_t new_msc)
{
present_window_priv_ptr window_priv = present_get_window_priv(window, TRUE);
if (crtc != window_priv->crtc) {
if (window_priv->crtc == PresentCrtcNeverSet) {
window_priv->msc_offset = 0;
} else {
/* The old CRTC may have been turned off, in which case
* we'll just use whatever previous MSC we'd seen from this CRTC
*/
/* Crtc unchanged, no offset. */
if (crtc == window_priv->crtc)
return;
window_priv->msc_offset += new_msc - window_priv->msc;
}
/* No crtc earlier to offset against, just set the crtc. */
if (window_priv->crtc == PresentCrtcNeverSet) {
window_priv->msc_offset = 0;
window_priv->crtc = crtc;
return;
}
return window_msc + window_priv->msc_offset;
/* In window-mode the last correct msc-offset is always kept
* in window-priv struct because msc is saved per window and
* not per crtc as in screen-mode.
*/
window_priv->msc_offset += new_msc - window_priv->msc;
window_priv->crtc = crtc;
}
static int
@ -574,7 +577,7 @@ present_wnmd_pixmap(WindowPtr window,
ret = present_wnmd_get_ust_msc(screen, window, &ust, &crtc_msc);
target_msc = present_wnmd_window_to_crtc_msc(window, target_crtc, window_msc, crtc_msc);
present_wnmd_update_window_crtc(window, target_crtc, crtc_msc);
if (ret == Success) {
/* Stash the current MSC away in case we need it later
@ -582,7 +585,7 @@ present_wnmd_pixmap(WindowPtr window,
window_priv->msc = crtc_msc;
}
target_msc = present_get_target_msc(target_msc,
target_msc = present_get_target_msc(window_msc + window_priv->msc_offset,
crtc_msc,
divisor,
remainder,