From 2d66a7d88306a23b305ca90023c9498be450ee4c Mon Sep 17 00:00:00 2001 From: Fabien Dessenne Date: Tue, 17 Jan 2017 17:17:21 +0100 Subject: [PATCH] compositor-drm: allow mode frequency selection As an option, allow to specify a mode (from the configuration file) by its refresh rate. Example of valid syntax: - "mode=1920x1080" Select a 1920x1080 mode, refresh rate undefined. - "mode=1920x1080@60" Select the (or one of the) 1920x1080 60 Hz mode. Signed-off-by: Fabien Dessenne Reviewed-by: Daniel Stone --- libweston/compositor-drm.c | 8 ++++++-- weston.ini.in | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c index ecc872ef..c7f7f636 100644 --- a/libweston/compositor-drm.c +++ b/libweston/compositor-drm.c @@ -2210,9 +2210,12 @@ drm_output_choose_initial_mode(struct drm_backend *backend, drmModeModeInfo drm_modeline; int32_t width = 0; int32_t height = 0; + uint32_t refresh = 0; + int n; if (mode == WESTON_DRM_BACKEND_OUTPUT_PREFERRED && modeline) { - if (sscanf(modeline, "%dx%d", &width, &height) != 2) { + n = sscanf(modeline, "%dx%d@%d", &width, &height, &refresh); + if (n != 2 && n != 3) { width = -1; if (parse_modeline(modeline, &drm_modeline) == 0) { @@ -2228,7 +2231,8 @@ drm_output_choose_initial_mode(struct drm_backend *backend, wl_list_for_each_reverse(drm_mode, &output->base.mode_list, base.link) { if (width == drm_mode->base.width && - height == drm_mode->base.height) + height == drm_mode->base.height && + (refresh == 0 || refresh == drm_mode->mode_info.vrefresh)) configured = drm_mode; if (memcmp(current_mode, &drm_mode->mode_info, diff --git a/weston.ini.in b/weston.ini.in index d837fb5d..71e879a9 100644 --- a/weston.ini.in +++ b/weston.ini.in @@ -55,7 +55,7 @@ path=@libexecdir@/weston-keyboard #[output] #name=X1 -#mode=1024x768 +#mode=1024x768@60 #transform=flipped-90 #[libinput]