drm/qxl: prefer the monitor config resolution
authorMarc-André Lureau <marcandre.lureau@gmail.com>
Fri, 18 Oct 2013 14:11:31 +0000 (16:11 +0200)
committerDave Airlie <airlied@redhat.com>
Wed, 23 Oct 2013 13:21:22 +0000 (14:21 +0100)
By default, 1024x768 is the preferred resolution. However, when a
monitor config is given, it should be the only preferred resolution.

Note that the monitor config resolution is passed to
qxl_add_common_modes() to avoid adding a duplicate mode without the
preferred resolution. That would discard the previous monitor config
preferred bit.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/qxl/qxl_display.c

index c2cc9b52d330b92a0c098c608f12115c1bfb933c..9f33578986312b4229ae3028c32306bbfe2896aa 100644 (file)
@@ -115,7 +115,9 @@ void qxl_display_read_client_monitors_config(struct qxl_device *qdev)
        }
 }
 
-static int qxl_add_monitors_config_modes(struct drm_connector *connector)
+static int qxl_add_monitors_config_modes(struct drm_connector *connector,
+                                         unsigned *pwidth,
+                                         unsigned *pheight)
 {
        struct drm_device *dev = connector->dev;
        struct qxl_device *qdev = dev->dev_private;
@@ -131,11 +133,15 @@ static int qxl_add_monitors_config_modes(struct drm_connector *connector)
        mode = drm_cvt_mode(dev, head->width, head->height, 60, false, false,
                            false);
        mode->type |= DRM_MODE_TYPE_PREFERRED;
+       *pwidth = head->width;
+       *pheight = head->height;
        drm_mode_probed_add(connector, mode);
        return 1;
 }
 
-static int qxl_add_common_modes(struct drm_connector *connector)
+static int qxl_add_common_modes(struct drm_connector *connector,
+                                unsigned pwidth,
+                                unsigned pheight)
 {
        struct drm_device *dev = connector->dev;
        struct drm_display_mode *mode = NULL;
@@ -169,7 +175,7 @@ static int qxl_add_common_modes(struct drm_connector *connector)
 
                mode = drm_cvt_mode(dev, common_modes[i].w, common_modes[i].h,
                                    60, false, false, false);
-               if (common_modes[i].w == 1024 && common_modes[i].h == 768)
+               if (common_modes[i].w == pwidth && common_modes[i].h == pheight)
                        mode->type |= DRM_MODE_TYPE_PREFERRED;
                drm_mode_probed_add(connector, mode);
        }
@@ -725,16 +731,18 @@ static int qxl_conn_get_modes(struct drm_connector *connector)
 {
        int ret = 0;
        struct qxl_device *qdev = connector->dev->dev_private;
+       unsigned pwidth = 1024;
+       unsigned pheight = 768;
 
        DRM_DEBUG_KMS("monitors_config=%p\n", qdev->monitors_config);
        /* TODO: what should we do here? only show the configured modes for the
         * device, or allow the full list, or both? */
        if (qdev->monitors_config && qdev->monitors_config->count) {
-               ret = qxl_add_monitors_config_modes(connector);
+               ret = qxl_add_monitors_config_modes(connector, &pwidth, &pheight);
                if (ret < 0)
                        return ret;
        }
-       ret += qxl_add_common_modes(connector);
+       ret += qxl_add_common_modes(connector, pwidth, pheight);
        return ret;
 }