From 36481b8d211d516af2a94d83c02ef7054a6f80fc Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Thu, 30 Dec 2021 19:40:47 +0100 Subject: [PATCH] gen_default_modes: Add more refresh rates to fallback modes Refresh rates >60Hz become ever more common. In order to allow users to keep hight refresh rates when not running at a natively advertized resolution, add common refresh rates to our fallback modes. Part-of: --- src/backends/native/gen-default-modes.py | 35 ++++++++++++++++-------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/backends/native/gen-default-modes.py b/src/backends/native/gen-default-modes.py index fed514d45..79542f82f 100755 --- a/src/backends/native/gen-default-modes.py +++ b/src/backends/native/gen-default-modes.py @@ -55,6 +55,15 @@ common_resolutions = [ (5120, 2880), ] +common_refresh_rates = [ + 60, + 90, + 120, + 144, + 165, + 240, +] + output_lines = [ "/* Generated by gen-default-modes.py */\n", "static const drmModeModeInfo meta_default_landscape_drm_mode_infos[] = {", @@ -84,7 +93,7 @@ def drm_mode_info_from_modeline(line): def portrait_drm_mode_info_from_modeline(line): sline = line.split() - return "{ %d, %d, %d, %d, %d, 0, %d, %d, %d, %d, 0, 0, %s, DRM_MODE_TYPE_DEFAULT, \"%dx%d_60.00\" }," % \ + return "{ %d, %d, %d, %d, %d, 0, %d, %d, %d, %d, 0, 0, %s, DRM_MODE_TYPE_DEFAULT, \"%dx%d_%s }," % \ (int(float(sline[2]) * 1000), int(sline[7]), int(sline[8]), @@ -95,24 +104,26 @@ def portrait_drm_mode_info_from_modeline(line): int(sline[5]), int(sline[6]), sync_flags(sline[12], sline[11]), - int(sline[7]), int(sline[3])) + int(sline[7]), int(sline[3]), sline[1].split("_")[1]) for resolution in common_resolutions: - cvt = os.popen("%s %s %s" % ('cvt', resolution[0], resolution[1])) - cvt.readline() # discard comment line - line = cvt.readline() - output_lines.append(drm_mode_info_from_modeline(line)) - cvt.close() + for refresh_rate in common_refresh_rates: + cvt = os.popen("%s %s %s %s" % ('cvt', resolution[0], resolution[1], refresh_rate)) + cvt.readline() # discard comment line + line = cvt.readline() + output_lines.append(drm_mode_info_from_modeline(line)) + cvt.close() output_lines.append("};") output_lines.append("") output_lines.append("static const drmModeModeInfo meta_default_portrait_drm_mode_infos[] = {") for resolution in common_resolutions: - cvt = os.popen("%s %s %s" % ('cvt', resolution[0], resolution[1])) - cvt.readline() # discard comment line - line = cvt.readline() - output_lines.append(portrait_drm_mode_info_from_modeline(line)) - cvt.close() + for refresh_rate in common_refresh_rates: + cvt = os.popen("%s %s %s %s" % ('cvt', resolution[0], resolution[1], refresh_rate)) + cvt.readline() # discard comment line + line = cvt.readline() + output_lines.append(portrait_drm_mode_info_from_modeline(line)) + cvt.close() output_lines.append("};") try: