drm/i915: Add new helper to return current attached encoder for connector
authorZhenyu Wang <zhenyuw@linux.intel.com>
Tue, 30 Mar 2010 06:39:29 +0000 (14:39 +0800)
committerEric Anholt <eric@anholt.net>
Fri, 9 Apr 2010 21:16:38 +0000 (14:16 -0700)
For introducing splitted encoder/connector structure, this helper will return
connector's attached encoder when needed.

Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_drv.h

index 412b442dc941dc95dd3370e8eef68fdd1d5b28ad..f9e11e863428b6b98e6e535607f1d4da4d0c2e8d 100644 (file)
@@ -4982,6 +4982,31 @@ struct drm_encoder *intel_best_encoder(struct drm_connector *connector)
        return &intel_encoder->enc;
 }
 
+/*
+ * Return which encoder is currently attached for connector.
+ */
+struct drm_encoder *intel_attached_encoder (struct drm_connector *connector)
+{
+       struct drm_mode_object *obj;
+       struct drm_encoder *encoder;
+       int i;
+
+       for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
+               if (connector->encoder_ids[i] == 0)
+                       break;
+
+               obj = drm_mode_object_find(connector->dev,
+                                           connector->encoder_ids[i],
+                                           DRM_MODE_OBJECT_ENCODER);
+               if (!obj)
+                       continue;
+
+               encoder = obj_to_encoder(obj);
+               return encoder;
+       }
+       return NULL;
+}
+
 /*
  * set vga decode state - true == enable VGA decode
  */
index d48c31220e02445449caf65330cf0abad409e45a..5b2e3b21980155b55ca526982ab3c116c8539153 100644 (file)
@@ -190,6 +190,7 @@ extern void intel_encoder_prepare (struct drm_encoder *encoder);
 extern void intel_encoder_commit (struct drm_encoder *encoder);
 
 extern struct drm_encoder *intel_best_encoder(struct drm_connector *connector);
+extern struct drm_encoder *intel_attached_encoder(struct drm_connector *connector);
 
 extern struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
                                                    struct drm_crtc *crtc);