v2: possible_crtcs field is a bitmask, not a pointer. Suggested by Ville Syrjälä ville.syrjala@linux.intel.com
v3: document how userspace should find out CRTC index. Also, document that field 'gamma_size' represents the number of entries in the lookup table. Suggested by Pekka Paalanen ppaalanen@gmail.com and Daniel Vetter daniel@ffwll.ch
v4: document IN and OUT fields and make the description more concise. Suggested by Pekka Paalanen ppaalanen@gmail.com
Leandro Ribeiro (2): drm/doc: document how userspace should find out CRTC index drm/doc: document drm_mode_get_plane
Documentation/gpu/drm-uapi.rst | 13 +++++++++++ drivers/gpu/drm/drm_debugfs_crc.c | 8 +++---- include/uapi/drm/drm.h | 4 ++-- include/uapi/drm/drm_mode.h | 36 +++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 6 deletions(-)
-- 2.31.1
In this patch we add a section to document what userspace should do to find out the CRTC index. This is important as they may be many places in the documentation that need this, so it's better to just point to this section and avoid repetition.
Signed-off-by: Leandro Ribeiro leandro.ribeiro@collabora.com --- Documentation/gpu/drm-uapi.rst | 13 +++++++++++++ drivers/gpu/drm/drm_debugfs_crc.c | 8 ++++---- include/uapi/drm/drm.h | 4 ++-- 3 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/Documentation/gpu/drm-uapi.rst b/Documentation/gpu/drm-uapi.rst index 04bdc7a91d53..7e51dd40bf6e 100644 --- a/Documentation/gpu/drm-uapi.rst +++ b/Documentation/gpu/drm-uapi.rst @@ -457,6 +457,19 @@ Userspace API Structures .. kernel-doc:: include/uapi/drm/drm_mode.h :doc: overview
+.. _crtc_index: + +CRTC index +---------- + +CRTC's have both an object ID and an index, and they are not the same thing. +The index is used in cases where a densely packed identifier for a CRTC is +needed, for instance a bitmask of CRTC's. The member possible_crtcs of struct +drm_mode_get_plane is an example. + +DRM_IOCTL_MODE_GETRESOURCES populates a structure with an array of CRTC ID's, +and the CRTC index is its position in this array. + .. kernel-doc:: include/uapi/drm/drm.h :internal:
diff --git a/drivers/gpu/drm/drm_debugfs_crc.c b/drivers/gpu/drm/drm_debugfs_crc.c index 3dd70d813f69..bbc3bc4ba844 100644 --- a/drivers/gpu/drm/drm_debugfs_crc.c +++ b/drivers/gpu/drm/drm_debugfs_crc.c @@ -46,10 +46,10 @@ * it reached a given hardware component (a CRC sampling "source"). * * Userspace can control generation of CRCs in a given CRTC by writing to the - * file dri/0/crtc-N/crc/control in debugfs, with N being the index of the CRTC. - * Accepted values are source names (which are driver-specific) and the "auto" - * keyword, which will let the driver select a default source of frame CRCs - * for this CRTC. + * file dri/0/crtc-N/crc/control in debugfs, with N being the :ref:`index of + * the CRTC<crtc_index>`. Accepted values are source names (which are + * driver-specific) and the "auto" keyword, which will let the driver select a + * default source of frame CRCs for this CRTC. * * Once frame CRC generation is enabled, userspace can capture them by reading * the dri/0/crtc-N/crc/data file. Each line in that file contains the frame diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h index 67b94bc3c885..bbf4e76daa55 100644 --- a/include/uapi/drm/drm.h +++ b/include/uapi/drm/drm.h @@ -635,8 +635,8 @@ struct drm_gem_open { /** * DRM_CAP_VBLANK_HIGH_CRTC * - * If set to 1, the kernel supports specifying a CRTC index in the high bits of - * &drm_wait_vblank_request.type. + * If set to 1, the kernel supports specifying a :ref:`CRTC index<crtc_index>` + * in the high bits of &drm_wait_vblank_request.type. * * Starting kernel version 2.6.39, this capability is always set to 1. */ -- 2.31.1
On Wed, 9 Jun 2021 20:00:38 -0300 Leandro Ribeiro leandro.ribeiro@collabora.com wrote:
In this patch we add a section to document what userspace should do to find out the CRTC index. This is important as they may be many places in the documentation that need this, so it's better to just point to this section and avoid repetition.
Signed-off-by: Leandro Ribeiro leandro.ribeiro@collabora.com
Documentation/gpu/drm-uapi.rst | 13 +++++++++++++ drivers/gpu/drm/drm_debugfs_crc.c | 8 ++++---- include/uapi/drm/drm.h | 4 ++-- 3 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/Documentation/gpu/drm-uapi.rst b/Documentation/gpu/drm-uapi.rst index 04bdc7a91d53..7e51dd40bf6e 100644 --- a/Documentation/gpu/drm-uapi.rst +++ b/Documentation/gpu/drm-uapi.rst @@ -457,6 +457,19 @@ Userspace API Structures .. kernel-doc:: include/uapi/drm/drm_mode.h :doc: overview
+.. _crtc_index:
+CRTC index +----------
+CRTC's have both an object ID and an index, and they are not the same thing. +The index is used in cases where a densely packed identifier for a CRTC is +needed, for instance a bitmask of CRTC's. The member possible_crtcs of struct +drm_mode_get_plane is an example.
+DRM_IOCTL_MODE_GETRESOURCES populates a structure with an array of CRTC ID's, +and the CRTC index is its position in this array.
.. kernel-doc:: include/uapi/drm/drm.h :internal:
diff --git a/drivers/gpu/drm/drm_debugfs_crc.c b/drivers/gpu/drm/drm_debugfs_crc.c index 3dd70d813f69..bbc3bc4ba844 100644 --- a/drivers/gpu/drm/drm_debugfs_crc.c +++ b/drivers/gpu/drm/drm_debugfs_crc.c @@ -46,10 +46,10 @@
- it reached a given hardware component (a CRC sampling "source").
- Userspace can control generation of CRCs in a given CRTC by writing to the
- file dri/0/crtc-N/crc/control in debugfs, with N being the index of the CRTC.
- Accepted values are source names (which are driver-specific) and the "auto"
- keyword, which will let the driver select a default source of frame CRCs
- for this CRTC.
- file dri/0/crtc-N/crc/control in debugfs, with N being the :ref:`index of
- the CRTC<crtc_index>`. Accepted values are source names (which are
- driver-specific) and the "auto" keyword, which will let the driver select a
- default source of frame CRCs for this CRTC.
- Once frame CRC generation is enabled, userspace can capture them by reading
- the dri/0/crtc-N/crc/data file. Each line in that file contains the frame
diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h index 67b94bc3c885..bbf4e76daa55 100644 --- a/include/uapi/drm/drm.h +++ b/include/uapi/drm/drm.h @@ -635,8 +635,8 @@ struct drm_gem_open { /**
- DRM_CAP_VBLANK_HIGH_CRTC
- If set to 1, the kernel supports specifying a CRTC index in the high bits of
- &drm_wait_vblank_request.type.
- If set to 1, the kernel supports specifying a :ref:`CRTC index<crtc_index>`
*/
- in the high bits of &drm_wait_vblank_request.type.
- Starting kernel version 2.6.39, this capability is always set to 1.
-- 2.31.1
Hi,
with the caveat that I didn't actually build the docs and see how they look:
Reviewed-by: Pekka Paalanen pekka.paalanen@collabora.com
Thanks, pq
On Thu, Jun 10, 2021 at 11:27:42AM +0300, Pekka Paalanen wrote:
On Wed, 9 Jun 2021 20:00:38 -0300 Leandro Ribeiro leandro.ribeiro@collabora.com wrote:
In this patch we add a section to document what userspace should do to find out the CRTC index. This is important as they may be many places in the documentation that need this, so it's better to just point to this section and avoid repetition.
Signed-off-by: Leandro Ribeiro leandro.ribeiro@collabora.com
Documentation/gpu/drm-uapi.rst | 13 +++++++++++++ drivers/gpu/drm/drm_debugfs_crc.c | 8 ++++---- include/uapi/drm/drm.h | 4 ++-- 3 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/Documentation/gpu/drm-uapi.rst b/Documentation/gpu/drm-uapi.rst index 04bdc7a91d53..7e51dd40bf6e 100644 --- a/Documentation/gpu/drm-uapi.rst +++ b/Documentation/gpu/drm-uapi.rst @@ -457,6 +457,19 @@ Userspace API Structures .. kernel-doc:: include/uapi/drm/drm_mode.h :doc: overview
+.. _crtc_index:
+CRTC index +----------
+CRTC's have both an object ID and an index, and they are not the same thing. +The index is used in cases where a densely packed identifier for a CRTC is +needed, for instance a bitmask of CRTC's. The member possible_crtcs of struct +drm_mode_get_plane is an example.
+DRM_IOCTL_MODE_GETRESOURCES populates a structure with an array of CRTC ID's, +and the CRTC index is its position in this array.
.. kernel-doc:: include/uapi/drm/drm.h :internal:
diff --git a/drivers/gpu/drm/drm_debugfs_crc.c b/drivers/gpu/drm/drm_debugfs_crc.c index 3dd70d813f69..bbc3bc4ba844 100644 --- a/drivers/gpu/drm/drm_debugfs_crc.c +++ b/drivers/gpu/drm/drm_debugfs_crc.c @@ -46,10 +46,10 @@
- it reached a given hardware component (a CRC sampling "source").
- Userspace can control generation of CRCs in a given CRTC by writing to the
- file dri/0/crtc-N/crc/control in debugfs, with N being the index of the CRTC.
- Accepted values are source names (which are driver-specific) and the "auto"
- keyword, which will let the driver select a default source of frame CRCs
- for this CRTC.
- file dri/0/crtc-N/crc/control in debugfs, with N being the :ref:`index of
- the CRTC<crtc_index>`. Accepted values are source names (which are
- driver-specific) and the "auto" keyword, which will let the driver select a
- default source of frame CRCs for this CRTC.
- Once frame CRC generation is enabled, userspace can capture them by reading
- the dri/0/crtc-N/crc/data file. Each line in that file contains the frame
diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h index 67b94bc3c885..bbf4e76daa55 100644 --- a/include/uapi/drm/drm.h +++ b/include/uapi/drm/drm.h @@ -635,8 +635,8 @@ struct drm_gem_open { /**
- DRM_CAP_VBLANK_HIGH_CRTC
- If set to 1, the kernel supports specifying a CRTC index in the high bits of
- &drm_wait_vblank_request.type.
- If set to 1, the kernel supports specifying a :ref:`CRTC index<crtc_index>`
*/
- in the high bits of &drm_wait_vblank_request.type.
- Starting kernel version 2.6.39, this capability is always set to 1.
-- 2.31.1
Hi,
with the caveat that I didn't actually build the docs and see how they look:
Reviewed-by: Pekka Paalanen pekka.paalanen@collabora.com
Pushed to drm-misc-next, thanks for the patch&review. -Daniel
Thanks, pq
Add a small description and document struct fields of drm_mode_get_plane.
Signed-off-by: Leandro Ribeiro leandro.ribeiro@collabora.com --- include/uapi/drm/drm_mode.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index a5e76aa06ad5..67bcd8e1931c 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -312,16 +312,52 @@ struct drm_mode_set_plane { __u32 src_w; };
+/** + * struct drm_mode_get_plane - Get plane metadata. + * + * Userspace can perform a GETPLANE ioctl to retrieve information about a + * plane. + * + * To retrieve the number of formats supported, set @count_format_types to zero + * and call the ioctl. @count_format_types will be updated with the value. + * + * To retrieve these formats, allocate an array with the memory needed to store + * @count_format_types formats. Point @format_type_ptr to this array and call + * the ioctl again (with @count_format_types still set to the value returned in + * the first ioctl call). + * + * Between one ioctl and the other, the number of formats may change. + * Userspace should retry the last ioctl until this number stabilizes. The + * kernel won't fill any array which doesn't have the expected length. + */ struct drm_mode_get_plane { + /** + * @plane_id: Object ID of the plane whose information should be + * retrieved. Set by caller. + */ __u32 plane_id;
+ /** @crtc_id: Object ID of the current CRTC. */ __u32 crtc_id; + /** @fb_id: Object ID of the current fb. */ __u32 fb_id;
+ /** + * @possible_crtcs: Bitmask of CRTC's compatible with the plane. CRTC's + * are created and they receive an index, which corresponds to their + * position in the bitmask. Bit N corresponds to + * :ref:`CRTC index<crtc_index>` N. + */ __u32 possible_crtcs; + /** @gamma_size: Number of entries of the legacy gamma lookup table. */ __u32 gamma_size;
+ /** @count_format_types: Number of formats. */ __u32 count_format_types; + /** + * @format_type_ptr: Pointer to ``__u32`` array of formats that are + * supported by the plane. These formats do not require modifiers. + */ __u64 format_type_ptr; };
-- 2.31.1
On 6/9/21 8:00 PM, Leandro Ribeiro wrote:
Add a small description and document struct fields of drm_mode_get_plane.
Signed-off-by: Leandro Ribeiro leandro.ribeiro@collabora.com
include/uapi/drm/drm_mode.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index a5e76aa06ad5..67bcd8e1931c 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -312,16 +312,52 @@ struct drm_mode_set_plane { __u32 src_w; };
+/**
- struct drm_mode_get_plane - Get plane metadata.
- Userspace can perform a GETPLANE ioctl to retrieve information about a
- plane.
- To retrieve the number of formats supported, set @count_format_types to zero
- and call the ioctl. @count_format_types will be updated with the value.
- To retrieve these formats, allocate an array with the memory needed to store
- @count_format_types formats. Point @format_type_ptr to this array and call
- the ioctl again (with @count_format_types still set to the value returned in
- the first ioctl call).
- Between one ioctl and the other, the number of formats may change.
- Userspace should retry the last ioctl until this number stabilizes. The
- kernel won't fill any array which doesn't have the expected length.
- */
Actually I don't know if this last paragraph applies. For connectors, for instance, I can see this happening because of hot-plugging. But for plane formats I have no idea. As in libdrm we have this algorithm, I've decided to describe it here.
struct drm_mode_get_plane {
/**
* @plane_id: Object ID of the plane whose information should be
* retrieved. Set by caller.
*/
__u32 plane_id;
/** @crtc_id: Object ID of the current CRTC. */ __u32 crtc_id;
/** @fb_id: Object ID of the current fb. */ __u32 fb_id;
/**
* @possible_crtcs: Bitmask of CRTC's compatible with the plane. CRTC's
* are created and they receive an index, which corresponds to their
* position in the bitmask. Bit N corresponds to
* :ref:`CRTC index<crtc_index>` N.
*/
__u32 possible_crtcs;
/** @gamma_size: Number of entries of the legacy gamma lookup table. */ __u32 gamma_size;
/** @count_format_types: Number of formats. */ __u32 count_format_types;
/**
* @format_type_ptr: Pointer to ``__u32`` array of formats that are
* supported by the plane. These formats do not require modifiers.
*/
__u64 format_type_ptr;
};
-- 2.31.1
On Wed, 9 Jun 2021 20:05:06 -0300 Leandro Ribeiro leandro.ribeiro@collabora.com wrote:
On 6/9/21 8:00 PM, Leandro Ribeiro wrote:
Add a small description and document struct fields of drm_mode_get_plane.
Signed-off-by: Leandro Ribeiro leandro.ribeiro@collabora.com
include/uapi/drm/drm_mode.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index a5e76aa06ad5..67bcd8e1931c 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -312,16 +312,52 @@ struct drm_mode_set_plane { __u32 src_w; };
+/**
- struct drm_mode_get_plane - Get plane metadata.
- Userspace can perform a GETPLANE ioctl to retrieve information about a
- plane.
- To retrieve the number of formats supported, set @count_format_types to zero
- and call the ioctl. @count_format_types will be updated with the value.
- To retrieve these formats, allocate an array with the memory needed to store
- @count_format_types formats. Point @format_type_ptr to this array and call
- the ioctl again (with @count_format_types still set to the value returned in
- the first ioctl call).
- Between one ioctl and the other, the number of formats may change.
- Userspace should retry the last ioctl until this number stabilizes. The
- kernel won't fill any array which doesn't have the expected length.
- */
Actually I don't know if this last paragraph applies. For connectors, for instance, I can see this happening because of hot-plugging. But for plane formats I have no idea. As in libdrm we have this algorithm, I've decided to describe it here.
Hi,
I think it's fine.
However, the sentence "The kernel won't fill any array which doesn't have the expected length." seems to be inaccurate, reading the code of drm_mode_getplane(). It looks like it is enough for the array to have sufficient space, it does not need to be the exact size.
So the libdrm algorithm may be slightly too pedantic, but it shouldn't hurt.
Otherwise looks really good.
Thanks, pq
struct drm_mode_get_plane {
/**
* @plane_id: Object ID of the plane whose information should be
* retrieved. Set by caller.
*/
__u32 plane_id;
/** @crtc_id: Object ID of the current CRTC. */ __u32 crtc_id;
/** @fb_id: Object ID of the current fb. */ __u32 fb_id;
/**
* @possible_crtcs: Bitmask of CRTC's compatible with the plane. CRTC's
* are created and they receive an index, which corresponds to their
* position in the bitmask. Bit N corresponds to
* :ref:`CRTC index<crtc_index>` N.
*/
__u32 possible_crtcs;
/** @gamma_size: Number of entries of the legacy gamma lookup table. */ __u32 gamma_size;
/** @count_format_types: Number of formats. */ __u32 count_format_types;
/**
* @format_type_ptr: Pointer to ``__u32`` array of formats that are
* supported by the plane. These formats do not require modifiers.
*/
__u64 format_type_ptr;
};
-- 2.31.1
On Wed, Jun 09, 2021 at 08:00:39PM -0300, Leandro Ribeiro wrote:
Add a small description and document struct fields of drm_mode_get_plane.
Signed-off-by: Leandro Ribeiro leandro.ribeiro@collabora.com
include/uapi/drm/drm_mode.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index a5e76aa06ad5..67bcd8e1931c 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -312,16 +312,52 @@ struct drm_mode_set_plane { __u32 src_w; };
+/**
- struct drm_mode_get_plane - Get plane metadata.
- Userspace can perform a GETPLANE ioctl to retrieve information about a
- plane.
- To retrieve the number of formats supported, set @count_format_types to zero
- and call the ioctl. @count_format_types will be updated with the value.
- To retrieve these formats, allocate an array with the memory needed to store
- @count_format_types formats. Point @format_type_ptr to this array and call
- the ioctl again (with @count_format_types still set to the value returned in
- the first ioctl call).
- Between one ioctl and the other, the number of formats may change.
Can't happen.
- Userspace should retry the last ioctl until this number stabilizes. The
- kernel won't fill any array which doesn't have the expected length.
- */
struct drm_mode_get_plane {
/**
* @plane_id: Object ID of the plane whose information should be
* retrieved. Set by caller.
*/
__u32 plane_id;
/** @crtc_id: Object ID of the current CRTC. */ __u32 crtc_id;
/** @fb_id: Object ID of the current fb. */ __u32 fb_id;
/**
* @possible_crtcs: Bitmask of CRTC's compatible with the plane. CRTC's
* are created and they receive an index, which corresponds to their
* position in the bitmask. Bit N corresponds to
* :ref:`CRTC index<crtc_index>` N.
*/
__u32 possible_crtcs;
/** @gamma_size: Number of entries of the legacy gamma lookup table. */ __u32 gamma_size;
Should be marked deprecated. There is no plane gamma in the current uapi.
- /** @count_format_types: Number of formats. */ __u32 count_format_types;
- /**
* @format_type_ptr: Pointer to ``__u32`` array of formats that are
* supported by the plane. These formats do not require modifiers.
__u64 format_type_ptr;*/
};
-- 2.31.1
dri-devel@lists.freedesktop.org