diff mbox

[RFCv1,05/12] drm: helpers to find mode objects (BEFORE drm: split property values out)

Message ID 1381020350-1125-6-git-send-email-robdclark@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Rob Clark Oct. 6, 2013, 12:45 a.m. UTC
---
 include/drm/drm_crtc.h | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

Comments

Rob Clark Oct. 6, 2013, 12:48 a.m. UTC | #1
Oh, and this one was half stolen from rmk's Armada driver with a
couple extra helper's that I needed added

BR,
-R

On Sat, Oct 5, 2013 at 8:45 PM, Rob Clark <robdclark@gmail.com> wrote:
> ---
>  include/drm/drm_crtc.h | 40 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 40 insertions(+)
>
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index e042d12..0ea61b3 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -1067,6 +1067,46 @@ drm_property_get_obj(struct drm_property *property, uint64_t value)
>         return drm_mode_object_find(property->dev, value, property->values[0]);
>  }
>
> +static inline struct drm_plane *drm_plane_find(struct drm_device *dev,
> +               uint32_t id)
> +{
> +       struct drm_mode_object *mo;
> +       mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_PLANE);
> +       return mo ? obj_to_plane(mo) : NULL;
> +}
> +
> +static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,
> +               uint32_t id)
> +{
> +       struct drm_mode_object *mo;
> +       mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CRTC);
> +       return mo ? obj_to_crtc(mo) : NULL;
> +}
> +
> +static inline struct drm_encoder *drm_encoder_find(struct drm_device *dev,
> +               uint32_t id)
> +{
> +       struct drm_mode_object *mo;
> +       mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_ENCODER);
> +       return mo ? obj_to_encoder(mo) : NULL;
> +}
> +
> +static inline struct drm_connector *drm_connector_find(struct drm_device *dev,
> +               uint32_t id)
> +{
> +       struct drm_mode_object *mo;
> +       mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CONNECTOR);
> +       return mo ? obj_to_connector(mo) : NULL;
> +}
> +
> +static inline struct drm_property_blob *
> +drm_property_blob_find(struct drm_device *dev, uint32_t id)
> +{
> +       struct drm_mode_object *mo;
> +       mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_BLOB);
> +       return mo ? obj_to_blob(mo) : NULL;
> +}
> +
>  /* IOCTLs */
>  extern int drm_mode_getresources(struct drm_device *dev,
>                                  void *data, struct drm_file *file_priv);
> --
> 1.8.3.1
>
diff mbox

Patch

diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index e042d12..0ea61b3 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -1067,6 +1067,46 @@  drm_property_get_obj(struct drm_property *property, uint64_t value)
 	return drm_mode_object_find(property->dev, value, property->values[0]);
 }
 
+static inline struct drm_plane *drm_plane_find(struct drm_device *dev,
+		uint32_t id)
+{
+	struct drm_mode_object *mo;
+	mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_PLANE);
+	return mo ? obj_to_plane(mo) : NULL;
+}
+
+static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,
+		uint32_t id)
+{
+	struct drm_mode_object *mo;
+	mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CRTC);
+	return mo ? obj_to_crtc(mo) : NULL;
+}
+
+static inline struct drm_encoder *drm_encoder_find(struct drm_device *dev,
+		uint32_t id)
+{
+	struct drm_mode_object *mo;
+	mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_ENCODER);
+	return mo ? obj_to_encoder(mo) : NULL;
+}
+
+static inline struct drm_connector *drm_connector_find(struct drm_device *dev,
+		uint32_t id)
+{
+	struct drm_mode_object *mo;
+	mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CONNECTOR);
+	return mo ? obj_to_connector(mo) : NULL;
+}
+
+static inline struct drm_property_blob *
+drm_property_blob_find(struct drm_device *dev, uint32_t id)
+{
+	struct drm_mode_object *mo;
+	mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_BLOB);
+	return mo ? obj_to_blob(mo) : NULL;
+}
+
 /* IOCTLs */
 extern int drm_mode_getresources(struct drm_device *dev,
 				 void *data, struct drm_file *file_priv);