drm/core: Add drm_encoder_index.
authorMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Thu, 7 Jan 2016 09:59:18 +0000 (10:59 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 9 Feb 2016 10:21:04 +0000 (11:21 +0100)
This is useful for adding encoder_mask in crtc_state.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1452160762-30487-2-git-send-email-maarten.lankhorst@linux.intel.com
drivers/gpu/drm/drm_crtc.c
include/drm/drm_crtc.h

index 6e6514ef996899c5df404a53573794c6ed304b92..4132d58dab93ed7fd10ac43ba4951042cd78b33d 100644 (file)
@@ -1160,6 +1160,29 @@ out_unlock:
 }
 EXPORT_SYMBOL(drm_encoder_init);
 
+/**
+ * drm_encoder_index - find the index of a registered encoder
+ * @encoder: encoder to find index for
+ *
+ * Given a registered encoder, return the index of that encoder within a DRM
+ * device's list of encoders.
+ */
+unsigned int drm_encoder_index(struct drm_encoder *encoder)
+{
+       unsigned int index = 0;
+       struct drm_encoder *tmp;
+
+       drm_for_each_encoder(tmp, encoder->dev) {
+               if (tmp == encoder)
+                       return index;
+
+               index++;
+       }
+
+       BUG();
+}
+EXPORT_SYMBOL(drm_encoder_index);
+
 /**
  * drm_encoder_cleanup - cleans up an initialised encoder
  * @encoder: encoder to cleanup
index c65a212db77e7a99b26735c262cb31a9b2504195..fd2ace4a18de869a8126fff44cb4eb617c903ee2 100644 (file)
@@ -2225,6 +2225,7 @@ int drm_encoder_init(struct drm_device *dev,
                     struct drm_encoder *encoder,
                     const struct drm_encoder_funcs *funcs,
                     int encoder_type, const char *name, ...);
+extern unsigned int drm_encoder_index(struct drm_encoder *encoder);
 
 /**
  * drm_encoder_crtc_ok - can a given crtc drive a given encoder?