[PATCH i-g-t] lib/kms: Add secondary sort key (vrefresh) to DRM mode sorting func()
Swati Sharma
swati2.sharma at intel.com
Wed May 21 06:50:27 UTC 2025
Extend sort_drm_modes_by_res_dsc() and sort_drm_modes_by_res_asc()
to use vrefresh as a secondary key when hdisplay values are equal.
Signed-off-by: Swati Sharma <swati2.sharma at intel.com>
---
lib/igt_kms.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 9ee03e870..e5c0a51ae 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1887,7 +1887,11 @@ int sort_drm_modes_by_res_dsc(const void *a, const void *b)
{
const drmModeModeInfo *mode1 = a, *mode2 = b;
- return (mode1->hdisplay < mode2->hdisplay) - (mode2->hdisplay < mode1->hdisplay);
+ int cmp = (mode1->hdisplay < mode2->hdisplay) - (mode2->hdisplay < mode1->hdisplay);
+ if (cmp == 0)
+ cmp = (mode1->vrefresh < mode2->vrefresh) - (mode2->vrefresh < mode1->vrefresh);
+
+ return cmp;
}
/**
@@ -1904,7 +1908,11 @@ int sort_drm_modes_by_res_asc(const void *a, const void *b)
{
const drmModeModeInfo *mode1 = a, *mode2 = b;
- return (mode1->hdisplay > mode2->hdisplay) - (mode2->hdisplay > mode1->hdisplay);
+ int cmp = (mode1->hdisplay > mode2->hdisplay) - (mode2->hdisplay > mode1->hdisplay);
+ if (cmp == 0)
+ cmp = (mode1->vrefresh > mode2->vrefresh) - (mode2->vrefresh > mode1->vrefresh);
+
+ return cmp;
}
/**
--
2.25.1
More information about the igt-dev
mailing list