compositor-drm: allow mode frequency selection
authorFabien Dessenne <fabien.dessenne@st.com>
Tue, 17 Jan 2017 16:17:21 +0000 (17:17 +0100)
committerDaniel Stone <daniels@collabora.com>
Tue, 17 Jan 2017 16:38:43 +0000 (16:38 +0000)
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@st.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
libweston/compositor-drm.c
weston.ini.in

index ecc872e..c7f7f63 100644 (file)
@@ -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,
index d837fb5..71e879a 100644 (file)
@@ -55,7 +55,7 @@ path=@libexecdir@/weston-keyboard
 
 #[output]
 #name=X1
-#mode=1024x768
+#mode=1024x768@60
 #transform=flipped-90
 
 #[libinput]