drm: add crtc helper drm_crtc_from_index()
authorShawn Guo <shawn.guo@linaro.org>
Thu, 29 Dec 2016 12:41:28 +0000 (20:41 +0800)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 30 Dec 2016 11:11:59 +0000 (12:11 +0100)
It adds a crtc helper drm_crtc_from_index() to find the registered CRTC
with a given index, just like drm_plane_from_index().

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1483015290-16660-2-git-send-email-shawnguo@kernel.org
drivers/gpu/drm/drm_crtc.c
include/drm/drm_crtc.h

index 080c8d361f1fc8917d8e84963625e41d9559a91a..75e0beeb37938a8b7e8b27be180420950a4f65fc 100644 (file)
 #include "drm_crtc_internal.h"
 #include "drm_internal.h"
 
+/**
+ * drm_crtc_from_index - find the registered CRTC at an index
+ * @dev: DRM device
+ * @idx: index of registered CRTC to find for
+ *
+ * Given a CRTC index, return the registered CRTC from DRM device's
+ * list of CRTCs with matching index.
+ */
+struct drm_crtc *drm_crtc_from_index(struct drm_device *dev, int idx)
+{
+       struct drm_crtc *crtc;
+
+       drm_for_each_crtc(crtc, dev)
+               if (idx == crtc->index)
+                       return crtc;
+
+       return NULL;
+}
+EXPORT_SYMBOL(drm_crtc_from_index);
+
 /**
  * drm_crtc_force_disable - Forcibly turn off a CRTC
  * @crtc: CRTC to turn off
index 6920dee3a2d1e9ba1701c8e6706b36772ad1c802..89daa77c37fcad6874aaa1dc548ea97fa4a3ed7f 100644 (file)
@@ -822,6 +822,7 @@ int drm_crtc_force_disable(struct drm_crtc *crtc);
 int drm_crtc_force_disable_all(struct drm_device *dev);
 
 int drm_mode_set_config_internal(struct drm_mode_set *set);
+struct drm_crtc *drm_crtc_from_index(struct drm_device *dev, int idx);
 
 /* Helpers */
 static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,