commit 7f991195c20d9dd57e14faf88cd36db0c77df424
Author: Wang Quanxian <quanxian.wang@intel.com>
Date:   Thu Jul 19 19:11:04 2012 +0800
    User sends SIGKILL to weston, KMS will clean up encoder
    attached with connector. When weston restarts again, it causes
    exit of weston because no active encoder is attached to connector.
    This patch will ignore the checking and weston will initilialize 
    encoder again and re-attach it to connector in the following process.
    
    Sign-Off-By Quanxian Wang <quanxian.wang@intel.com>

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 47cd512..bb1b138 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -1348,26 +1348,28 @@ create_output_for_connector(struct drm_compositor *ec,
 	/* Get the current mode on the crtc that's currently driving
 	 * this connector. */
 	encoder = drmModeGetEncoder(ec->drm.fd, connector->encoder_id);
-	if (encoder == NULL)
-		goto err_free;
-	crtc = drmModeGetCrtc(ec->drm.fd, encoder->crtc_id);
-	drmModeFreeEncoder(encoder);
-	if (crtc == NULL)
-		goto err_free;
-
-	/* if don't get mode from drm driver, use default 800x480 */
-        if (crtc->mode.clock != 0)
-	{
+	if (encoder != NULL)
+        {
+		crtc = drmModeGetCrtc(ec->drm.fd, encoder->crtc_id);
+		drmModeFreeEncoder(encoder);
+		if (crtc == NULL)
+			goto err_free;
 		crtc_mode = crtc->mode;
-	} else {
+ 		drmModeFreeCrtc(crtc);
+	}
+	/*
+	 * No actiave encoder is connected with the connector
+	 * If connector has no mode available, takes detault mode
+ 	 * Or takes the first mode from connector
+	 */
+	if (encoder == NULL || crtc_mode.clock == 0)
+        {
 		if (connector->count_modes == 0)
 			crtc_mode = builtin_800x480;
 		else
 			crtc_mode = connector->modes[0];
 	}
 
-	drmModeFreeCrtc(crtc);
-
 	if (connector->count_modes == 0) {
 		ret = drm_output_add_mode(output, &crtc_mode);
 		if (ret)
