Commit b0807423 authored by Marc-André Lureau's avatar Marc-André Lureau Committed by Dave Airlie

drm/qxl: prefer the monitor config resolution

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: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 3fbd6439
...@@ -115,7 +115,9 @@ void qxl_display_read_client_monitors_config(struct qxl_device *qdev) ...@@ -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 drm_device *dev = connector->dev;
struct qxl_device *qdev = dev->dev_private; struct qxl_device *qdev = dev->dev_private;
...@@ -131,11 +133,15 @@ static int qxl_add_monitors_config_modes(struct drm_connector *connector) ...@@ -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, mode = drm_cvt_mode(dev, head->width, head->height, 60, false, false,
false); false);
mode->type |= DRM_MODE_TYPE_PREFERRED; mode->type |= DRM_MODE_TYPE_PREFERRED;
*pwidth = head->width;
*pheight = head->height;
drm_mode_probed_add(connector, mode); drm_mode_probed_add(connector, mode);
return 1; 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_device *dev = connector->dev;
struct drm_display_mode *mode = NULL; struct drm_display_mode *mode = NULL;
...@@ -169,7 +175,7 @@ static int qxl_add_common_modes(struct drm_connector *connector) ...@@ -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, mode = drm_cvt_mode(dev, common_modes[i].w, common_modes[i].h,
60, false, false, false); 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; mode->type |= DRM_MODE_TYPE_PREFERRED;
drm_mode_probed_add(connector, mode); drm_mode_probed_add(connector, mode);
} }
...@@ -725,16 +731,18 @@ static int qxl_conn_get_modes(struct drm_connector *connector) ...@@ -725,16 +731,18 @@ static int qxl_conn_get_modes(struct drm_connector *connector)
{ {
int ret = 0; int ret = 0;
struct qxl_device *qdev = connector->dev->dev_private; struct qxl_device *qdev = connector->dev->dev_private;
unsigned pwidth = 1024;
unsigned pheight = 768;
DRM_DEBUG_KMS("monitors_config=%p\n", qdev->monitors_config); DRM_DEBUG_KMS("monitors_config=%p\n", qdev->monitors_config);
/* TODO: what should we do here? only show the configured modes for the /* TODO: what should we do here? only show the configured modes for the
* device, or allow the full list, or both? */ * device, or allow the full list, or both? */
if (qdev->monitors_config && qdev->monitors_config->count) { 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) if (ret < 0)
return ret; return ret;
} }
ret += qxl_add_common_modes(connector); ret += qxl_add_common_modes(connector, pwidth, pheight);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment