All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: document drm_mode_get_property
@ 2021-07-21  6:49 Simon Ser
  2021-07-21 11:39 ` Daniel Vetter
  2021-07-22  7:32 ` Pekka Paalanen
  0 siblings, 2 replies; 6+ messages in thread
From: Simon Ser @ 2021-07-21  6:49 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter, Pekka Paalanen, Leandro Ribeiro

It's not obvious what the fields mean and how they should be used.
The most important detail is the link to drm_property.flags, which
describes how property types work.

Signed-off-by: Simon Ser <contact@emersion.fr>
Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Leandro Ribeiro <leandro.ribeiro@collabora.com>
---
 include/uapi/drm/drm_mode.h | 52 ++++++++++++++++++++++++++++++++++---
 1 file changed, 48 insertions(+), 4 deletions(-)

diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
index 98bf130feda5..dfdb595875aa 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -546,17 +546,61 @@ struct drm_mode_property_enum {
 	char name[DRM_PROP_NAME_LEN];
 };
 
+/**
+ * struct drm_mode_get_property - Get property metadata.
+ *
+ * User-space can perform a GETPROPERTY ioctl to retrieve information about a
+ * property.
+ *
+ * The meaning of the @values_ptr field changes depending on the property type.
+ * See &drm_property.flags for more details.
+ *
+ * The @enum_blob_ptr and @count_enum_blobs fields are only meaningful when the
+ * property has the type &DRM_MODE_PROP_ENUM or &DRM_MODE_PROP_BITMASK. For
+ * backwards compatibility, the kernel will always set @count_enum_blobs to
+ * zero when the property has the type &DRM_MODE_PROP_BLOB. User-space must
+ * ignore these two fields if the property has a different type.
+ *
+ * User-space is expected to retrieve values and enums by performing this ioctl
+ * at least twice: the first time to retrieve the number of elements, the
+ * second time to retrieve the elements themselves.
+ *
+ * To retrieve the number of elements, set @count_values and @count_enum_blobs
+ * to zero, then call the ioctl. @count_values will be updated with the number
+ * of elements. If the property has the type &DRM_MODE_PROP_ENUM or
+ * &DRM_MODE_PROP_BITMASK, @count_enum_blobs will be updated as well.
+ *
+ * To retrieve the elements themselves, allocate an array for @values_ptr and
+ * set @count_values to its capacity. If the property has the type
+ * &DRM_MODE_PROP_ENUM or &DRM_MODE_PROP_BITMASK, allocate an array for
+ * @enum_blob_ptr and set @count_enum_blobs to its capacity. Calling the ioctl
+ * again will fill the arrays.
+ */
 struct drm_mode_get_property {
-	__u64 values_ptr; /* values and blob lengths */
-	__u64 enum_blob_ptr; /* enum and blob id ptrs */
+	/** @values_ptr: Pointer to a ``__u64`` array. */
+	__u64 values_ptr;
+	/** @enum_blob_ptr: Pointer to a struct drm_mode_property_enum array. */
+	__u64 enum_blob_ptr;
 
+	/**
+	 * @prop_id: Object ID of the property which should be retrieved. Set
+	 * by the caller.
+	 */
 	__u32 prop_id;
+	/**
+	 * @flags: ``DRM_MODE_PROP_*`` bitfield. See &drm_property.flags for
+	 * a definition of the flags.
+	 */
 	__u32 flags;
+	/**
+	 * @name: Symbolic property name. User-space should use this field to
+	 * recognize properties.
+	 */
 	char name[DRM_PROP_NAME_LEN];
 
+	/** @count_values: Number of elements in @values_ptr. */
 	__u32 count_values;
-	/* This is only used to count enum values, not blobs. The _blobs is
-	 * simply because of a historical reason, i.e. backwards compat. */
+	/** @count_enum_blobs: Number of elements in @enum_blob_ptr. */
 	__u32 count_enum_blobs;
 };
 
-- 
2.32.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm: document drm_mode_get_property
  2021-07-21  6:49 [PATCH] drm: document drm_mode_get_property Simon Ser
@ 2021-07-21 11:39 ` Daniel Vetter
  2021-07-26  8:34   ` Simon Ser
  2021-07-22  7:32 ` Pekka Paalanen
  1 sibling, 1 reply; 6+ messages in thread
From: Daniel Vetter @ 2021-07-21 11:39 UTC (permalink / raw)
  To: Simon Ser; +Cc: Daniel Vetter, Pekka Paalanen, Leandro Ribeiro, dri-devel

On Wed, Jul 21, 2021 at 06:49:32AM +0000, Simon Ser wrote:
> It's not obvious what the fields mean and how they should be used.
> The most important detail is the link to drm_property.flags, which
> describes how property types work.
> 
> Signed-off-by: Simon Ser <contact@emersion.fr>
> Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Leandro Ribeiro <leandro.ribeiro@collabora.com>
> ---
>  include/uapi/drm/drm_mode.h | 52 ++++++++++++++++++++++++++++++++++---
>  1 file changed, 48 insertions(+), 4 deletions(-)
> 
> diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> index 98bf130feda5..dfdb595875aa 100644
> --- a/include/uapi/drm/drm_mode.h
> +++ b/include/uapi/drm/drm_mode.h
> @@ -546,17 +546,61 @@ struct drm_mode_property_enum {
>  	char name[DRM_PROP_NAME_LEN];
>  };
>  
> +/**
> + * struct drm_mode_get_property - Get property metadata.
> + *
> + * User-space can perform a GETPROPERTY ioctl to retrieve information about a
> + * property.
> + *
> + * The meaning of the @values_ptr field changes depending on the property type.
> + * See &drm_property.flags for more details.
> + *
> + * The @enum_blob_ptr and @count_enum_blobs fields are only meaningful when the
> + * property has the type &DRM_MODE_PROP_ENUM or &DRM_MODE_PROP_BITMASK. For
> + * backwards compatibility, the kernel will always set @count_enum_blobs to
> + * zero when the property has the type &DRM_MODE_PROP_BLOB. User-space must
> + * ignore these two fields if the property has a different type.
> + *
> + * User-space is expected to retrieve values and enums by performing this ioctl
> + * at least twice: the first time to retrieve the number of elements, the
> + * second time to retrieve the elements themselves.
> + *
> + * To retrieve the number of elements, set @count_values and @count_enum_blobs
> + * to zero, then call the ioctl. @count_values will be updated with the number
> + * of elements. If the property has the type &DRM_MODE_PROP_ENUM or
> + * &DRM_MODE_PROP_BITMASK, @count_enum_blobs will be updated as well.
> + *
> + * To retrieve the elements themselves, allocate an array for @values_ptr and
> + * set @count_values to its capacity. If the property has the type
> + * &DRM_MODE_PROP_ENUM or &DRM_MODE_PROP_BITMASK, allocate an array for
> + * @enum_blob_ptr and set @count_enum_blobs to its capacity. Calling the ioctl
> + * again will fill the arrays.

I think it would be really good to link to

https://dri.freedesktop.org/docs/drm/gpu/drm-kms.html#modeset-base-object-abstraction

for all the property related ioctl. That entire class vs instance
confusion is pretty common I think, which is why I even made a nice
picture about it :-)

> + */
>  struct drm_mode_get_property {
> -	__u64 values_ptr; /* values and blob lengths */
> -	__u64 enum_blob_ptr; /* enum and blob id ptrs */
> +	/** @values_ptr: Pointer to a ``__u64`` array. */
> +	__u64 values_ptr;
> +	/** @enum_blob_ptr: Pointer to a struct drm_mode_property_enum array. */

I guess would be nice to also document that drm_mode_property_enum.
Especially whether we also have this nice confusion between value and
bitmask there too (I guess so).

> +	__u64 enum_blob_ptr;
>  
> +	/**
> +	 * @prop_id: Object ID of the property which should be retrieved. Set
> +	 * by the caller.
> +	 */
>  	__u32 prop_id;
> +	/**
> +	 * @flags: ``DRM_MODE_PROP_*`` bitfield. See &drm_property.flags for
> +	 * a definition of the flags.
> +	 */
>  	__u32 flags;
> +	/**
> +	 * @name: Symbolic property name. User-space should use this field to
> +	 * recognize properties.
> +	 */
>  	char name[DRM_PROP_NAME_LEN];
>  
> +	/** @count_values: Number of elements in @values_ptr. */
>  	__u32 count_values;
> -	/* This is only used to count enum values, not blobs. The _blobs is
> -	 * simply because of a historical reason, i.e. backwards compat. */
> +	/** @count_enum_blobs: Number of elements in @enum_blob_ptr. */
>  	__u32 count_enum_blobs;

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

>  };
>  
> -- 
> 2.32.0
> 
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm: document drm_mode_get_property
  2021-07-21  6:49 [PATCH] drm: document drm_mode_get_property Simon Ser
  2021-07-21 11:39 ` Daniel Vetter
@ 2021-07-22  7:32 ` Pekka Paalanen
  1 sibling, 0 replies; 6+ messages in thread
From: Pekka Paalanen @ 2021-07-22  7:32 UTC (permalink / raw)
  To: Simon Ser; +Cc: Daniel Vetter, Leandro Ribeiro, dri-devel

[-- Attachment #1: Type: text/plain, Size: 3785 bytes --]

On Wed, 21 Jul 2021 06:49:32 +0000
Simon Ser <contact@emersion.fr> wrote:

> It's not obvious what the fields mean and how they should be used.
> The most important detail is the link to drm_property.flags, which
> describes how property types work.
> 
> Signed-off-by: Simon Ser <contact@emersion.fr>
> Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Leandro Ribeiro <leandro.ribeiro@collabora.com>
> ---
>  include/uapi/drm/drm_mode.h | 52 ++++++++++++++++++++++++++++++++++---
>  1 file changed, 48 insertions(+), 4 deletions(-)
> 
> diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> index 98bf130feda5..dfdb595875aa 100644
> --- a/include/uapi/drm/drm_mode.h
> +++ b/include/uapi/drm/drm_mode.h
> @@ -546,17 +546,61 @@ struct drm_mode_property_enum {
>  	char name[DRM_PROP_NAME_LEN];
>  };
>  
> +/**
> + * struct drm_mode_get_property - Get property metadata.
> + *
> + * User-space can perform a GETPROPERTY ioctl to retrieve information about a
> + * property.
> + *
> + * The meaning of the @values_ptr field changes depending on the property type.
> + * See &drm_property.flags for more details.
> + *
> + * The @enum_blob_ptr and @count_enum_blobs fields are only meaningful when the
> + * property has the type &DRM_MODE_PROP_ENUM or &DRM_MODE_PROP_BITMASK. For
> + * backwards compatibility, the kernel will always set @count_enum_blobs to
> + * zero when the property has the type &DRM_MODE_PROP_BLOB. User-space must
> + * ignore these two fields if the property has a different type.
> + *
> + * User-space is expected to retrieve values and enums by performing this ioctl
> + * at least twice: the first time to retrieve the number of elements, the
> + * second time to retrieve the elements themselves.
> + *
> + * To retrieve the number of elements, set @count_values and @count_enum_blobs
> + * to zero, then call the ioctl. @count_values will be updated with the number
> + * of elements. If the property has the type &DRM_MODE_PROP_ENUM or
> + * &DRM_MODE_PROP_BITMASK, @count_enum_blobs will be updated as well.
> + *
> + * To retrieve the elements themselves, allocate an array for @values_ptr and
> + * set @count_values to its capacity. If the property has the type
> + * &DRM_MODE_PROP_ENUM or &DRM_MODE_PROP_BITMASK, allocate an array for
> + * @enum_blob_ptr and set @count_enum_blobs to its capacity. Calling the ioctl
> + * again will fill the arrays.
> + */
>  struct drm_mode_get_property {
> -	__u64 values_ptr; /* values and blob lengths */
> -	__u64 enum_blob_ptr; /* enum and blob id ptrs */
> +	/** @values_ptr: Pointer to a ``__u64`` array. */
> +	__u64 values_ptr;
> +	/** @enum_blob_ptr: Pointer to a struct drm_mode_property_enum array. */
> +	__u64 enum_blob_ptr;
>  
> +	/**
> +	 * @prop_id: Object ID of the property which should be retrieved. Set
> +	 * by the caller.
> +	 */
>  	__u32 prop_id;
> +	/**
> +	 * @flags: ``DRM_MODE_PROP_*`` bitfield. See &drm_property.flags for
> +	 * a definition of the flags.
> +	 */
>  	__u32 flags;
> +	/**
> +	 * @name: Symbolic property name. User-space should use this field to
> +	 * recognize properties.
> +	 */
>  	char name[DRM_PROP_NAME_LEN];
>  
> +	/** @count_values: Number of elements in @values_ptr. */
>  	__u32 count_values;
> -	/* This is only used to count enum values, not blobs. The _blobs is
> -	 * simply because of a historical reason, i.e. backwards compat. */
> +	/** @count_enum_blobs: Number of elements in @enum_blob_ptr. */
>  	__u32 count_enum_blobs;
>  };
>  

LGTM.

Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>

You can keep the ack after addressing Daniel's comments, too.


Thanks,
pq

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm: document drm_mode_get_property
  2021-07-21 11:39 ` Daniel Vetter
@ 2021-07-26  8:34   ` Simon Ser
  2021-07-27  9:26     ` Daniel Vetter
  0 siblings, 1 reply; 6+ messages in thread
From: Simon Ser @ 2021-07-26  8:34 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Pekka Paalanen, Leandro Ribeiro, dri-devel

On Wednesday, July 21st, 2021 at 13:39, Daniel Vetter <daniel@ffwll.ch> wrote:

> I think it would be really good to link to
>
> https://dri.freedesktop.org/docs/drm/gpu/drm-kms.html#modeset-base-object-abstraction
>
> for all the property related ioctl. That entire class vs instance
> confusion is pretty common I think, which is why I even made a nice
> picture about it :-)

I cannot figure out how to link to that page after blindly trying a bunch of
magical Sphinx invocations. I must say, links aren't RST's forte, inserting
them is as intuitive as mud.

Does anyone know how to do it?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm: document drm_mode_get_property
  2021-07-26  8:34   ` Simon Ser
@ 2021-07-27  9:26     ` Daniel Vetter
  2021-07-27  9:27       ` Simon Ser
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Vetter @ 2021-07-27  9:26 UTC (permalink / raw)
  To: Simon Ser; +Cc: Daniel Vetter, Leandro Ribeiro, Pekka Paalanen, dri-devel

On Mon, Jul 26, 2021 at 08:34:14AM +0000, Simon Ser wrote:
> On Wednesday, July 21st, 2021 at 13:39, Daniel Vetter <daniel@ffwll.ch> wrote:
> 
> > I think it would be really good to link to
> >
> > https://dri.freedesktop.org/docs/drm/gpu/drm-kms.html#modeset-base-object-abstraction
> >
> > for all the property related ioctl. That entire class vs instance
> > confusion is pretty common I think, which is why I even made a nice
> > picture about it :-)
> 
> I cannot figure out how to link to that page after blindly trying a bunch of
> magical Sphinx invocations. I must say, links aren't RST's forte, inserting
> them is as intuitive as mud.
> 
> Does anyone know how to do it?


I think the least intrusive one is `Title Test`_ or so. There's also other
places where we use :ref: but that's more cumbersome to read in plain
text.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm: document drm_mode_get_property
  2021-07-27  9:26     ` Daniel Vetter
@ 2021-07-27  9:27       ` Simon Ser
  0 siblings, 0 replies; 6+ messages in thread
From: Simon Ser @ 2021-07-27  9:27 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Pekka Paalanen, Leandro Ribeiro, dri-devel

On Tuesday, July 27th, 2021 at 11:26, Daniel Vetter <daniel@ffwll.ch> wrote:

> I think the least intrusive one is `Title Test`_ or so. There's also other
> places where we use :ref: but that's more cumbersome to read in plain
> text.

Yeah, tried it, doesn't work. The link doesn't appear.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-07-27  9:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-21  6:49 [PATCH] drm: document drm_mode_get_property Simon Ser
2021-07-21 11:39 ` Daniel Vetter
2021-07-26  8:34   ` Simon Ser
2021-07-27  9:26     ` Daniel Vetter
2021-07-27  9:27       ` Simon Ser
2021-07-22  7:32 ` Pekka Paalanen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.