[PATCH] compositor-drm: allow mode frequency selection

Fabien Dessenne fabien.dessenne at st.com
Mon Jan 2 16:42:18 UTC 2017


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 <fabien.dessenne at st.com>
---
 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 70514ea..0add22b 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 d837fb5..b2ccde3 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]
-- 
2.7.4



More information about the wayland-devel mailing list