[PATCH libdrm] modetest: Fix mode_vrefresh() for interlace/dblscan/vscan
Geert Uytterhoeven
geert at linux-m68k.org
Mon Jul 11 15:55:16 UTC 2022
mode_vrefresh() does not take into account interlaced, doublescan, and
multiscan modes, leading to incorrect refresh rates.
Fix this, based on drm_mode_vrefresh() in Linux.
Signed-off-by: Geert Uytterhoeven <geert at linux-m68k.org>
---
tests/modetest/modetest.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index 8ff6c80da8ba6db6..9ceb5688f7683ffc 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -137,8 +137,19 @@ static inline int64_t U642I64(uint64_t val)
static float mode_vrefresh(drmModeModeInfo *mode)
{
- return mode->clock * 1000.00
- / (mode->htotal * mode->vtotal);
+ unsigned int num, den;
+
+ num = mode->clock;
+ den = mode->htotal * mode->vtotal;
+
+ if (mode->flags & DRM_MODE_FLAG_INTERLACE)
+ num *= 2;
+ if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
+ den *= 2;
+ if (mode->vscan > 1)
+ den *= mode->vscan;
+
+ return num * 1000.00 / den;
}
#define bit_name_fn(res) \
--
2.25.1
More information about the dri-devel
mailing list