[PATCH xserver] modesetting: Just inherit output states during PreInit

Daniel Martin daniel.martin at secunet.com
Wed Nov 4 02:26:15 PST 2015


From: Daniel Martin <consume.noise at gmail.com>

During PreInit, we just want to inherit the output states from the
kernel. If there's a connected output without an encoder assigned, there
must be a reason for this. Don't try to activate it, treat it as
disconnected for the moment. Because, if we fail to set it up during
PreInit the server will exit.

rfc..v2:
- changed subject and description, was
  "modesetting: Treat inactive outputs as disconnected during PreInit"
- move check above switch (Adam Jackson)
- don't drmModeGetConnector() if !configured, we just did that
- add log message for affected outputs

Signed-off-by: Daniel Martin <consume.noise at gmail.com>
---
 hw/xfree86/drivers/modesetting/drmmode_display.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index 4421578..1a73601 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -858,13 +858,30 @@ drmmode_output_detect(xf86OutputPtr output)
     if (drmmode_output->output_id == -1)
         return XF86OutputStatusDisconnected;
 
-    drmModeFreeConnector(drmmode_output->mode_output);
+    if (output->scrn->configured) {
+        drmModeFreeConnector(drmmode_output->mode_output);
+
+        drmmode_output->mode_output =
+            drmModeGetConnector(drmmode->fd, drmmode_output->output_id);
+    } /* else, we just fetched connector infos via drmmode_pre_init() */
 
-    drmmode_output->mode_output =
-        drmModeGetConnector(drmmode->fd, drmmode_output->output_id);
     if (!drmmode_output->mode_output)
         return XF86OutputStatusDisconnected;
 
+    /* During PreInit (!configured), we shouldn't try to setup an output
+     * where the kernel didn't assigned an encoder yet.
+     * First, we just want to inherit the current state and second, if we
+     * fail to set it up at this point the server will exit. */
+    if (!output->scrn->configured &&
+        !drmmode_output->mode_output->encoder_id &&
+        drmmode_output->mode_output->connection != DRM_MODE_DISCONNECTED) {
+        xf86DrvMsg(output->scrn->scrnIndex, X_INFO,
+                   "Output %s has no encoder assigned, "
+                   "treat as disconnected during PreInit\n",
+                   output->name);
+        return XF86OutputStatusDisconnected;
+    }
+
     switch (drmmode_output->mode_output->connection) {
     case DRM_MODE_CONNECTED:
         status = XF86OutputStatusConnected;
-- 
2.6.1



More information about the xorg-devel mailing list