Disable CRTCs and Outputs on EnterVT?

Keith Packard keithp at keithp.com
Tue May 1 22:33:45 PDT 2007

Dave Airlie was poking at one of his weird gambling devices and
discovered that the intel driver wasn't setting modes quite right -- the
VGA output was getting scrambled at server startup time. Turns out the
problem was that a rogue SDVO output was hooked up to the CRTC that the
VGA output wanted to use; leaving that enabled while hooking up the VGA
really broke things badly.

As a simple fix, he turned off all of the outputs before setting any
modes from EnterVT and it fixed the problem nicely. He pushed a patch to
the intel driver that does this, but I'm thinking we want to do this up
in the generic X server code and turn off the CRTCs as well.

I'm wondering how many other random weird modesetting problems this
might help with. Here's a patch I'm thinking of applying; if you've got
modesetting pain, please give it a try and report back.


# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#	modified:   hw/xfree86/modes/xf86Crtc.c
diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 00ec56c..88c31af 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -1723,8 +1723,26 @@ Bool
 xf86SetDesiredModes (ScrnInfoPtr scrn)
     xf86CrtcConfigPtr   config = XF86_CRTC_CONFIG_PTR(scrn);
-    int			c;
+    int			c, o;
+    /*
+     * Turn off everything so mode setting is done
+     * with hardware in a consistent state
+     */
+    for (o = 0; o < config->num_output; o++) 
+    {
+	xf86OutputPtr  output = config->output[o];
+	(*output->funcs->dpms)(output, DPMSModeOff);
+    }
+    for (c = 0; c < config->num_crtc; c++) 
+    {
+	xf86CrtcPtr crtc = config->crtc[c];
+	crtc->funcs->dpms(crtc, DPMSModeOff);
+	memset(&crtc->mode, 0, sizeof(crtc->mode));
+    }
     for (c = 0; c < config->num_crtc; c++)
 	xf86CrtcPtr	crtc = config->crtc[c];

keith.packard at intel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.x.org/archives/xorg/attachments/20070501/c1becf18/attachment.pgp>

More information about the xorg mailing list