From: Takashi Iwai <tiwai@suse.de>
Subject: drm: qxl: Workaround for buggy user-space
Patch-mainline: Never, SLE12 specific
References: bsc#981344

This is essentially the revert of
  commit 95b8eca09144b18187d8254c0aa88ccdbf1cc129
  drm/qxl: only report first monitor as connected if we have no state

Although the commit above allows the disconnection of the first
monitor, it relies on user-space giving the proper monitor config
information.  As one can be skeptical, we can't rely on user-space.
Indeed, SLE12 SP0/SP1 usr-space passes the invalid monitor config data
(all zero positions), effectively telling as if all monitors are off.
This caused weird effects on desktops like KDE5.

Of course, the best would be to fix user-space side, and it will be
done in SP2.  OTOH, since this kernel change affects too badly with
the existing user-spcae, it's safer to take it back and assumes the
fixed connection of the first monitor as before.

Signed-off-by: Takashi Iwai <tiwai@suse.de>

---
 drivers/gpu/drm/qxl/qxl_display.c |   12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -899,15 +899,13 @@ static enum drm_connector_status qxl_con
 		drm_connector_to_qxl_output(connector);
 	struct drm_device *ddev = connector->dev;
 	struct qxl_device *qdev = ddev->dev_private;
-	bool connected = false;
+	int connected;
 
 	/* The first monitor is always connected */
-	if (!qdev->client_monitors_config) {
-		if (output->index == 0)
-			connected = true;
-	} else
-		connected = qdev->client_monitors_config->count > output->index &&
-		     qxl_head_enabled(&qdev->client_monitors_config->heads[output->index]);
+	connected = (output->index == 0) ||
+		    (qdev->client_monitors_config &&
+		     qdev->client_monitors_config->count > output->index &&
+		     qxl_head_enabled(&qdev->client_monitors_config->heads[output->index]));
 
 	DRM_DEBUG("#%d connected: %d\n", output->index, connected);
 	if (!connected)
