Document drm_mode_get_plane
Subsystems (3)
v4 cover Document drm_mode_get_plane
v2: possible_crtcs field is a bitmask, not a pointer. Suggested by Ville Syrjälä <[email protected]>
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 <[email protected]> and Daniel Vetter <[email protected]>
v4: document IN and OUT fields and make the description more concise. Suggested by Pekka Paalanen <[email protected]>
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
PATCH v4 1/2 drm/doc: document how userspace should find out CRTC index
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.
--- 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(-)
Documentation/gpu/drm-uapi.rst +13 -0
@@ -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:
drivers/gpu/drm/drm_debugfs_crc.c +4 -4
@@ -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
include/uapi/drm/drm.h +2 -2
@@ -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
Re: [PATCH v4 1/2] drm/doc: document how userspace should find out CRTC index
Quoted 71 lines · On Wed, 9 Jun 2021 20:00:38 -0300 Leandro Ribeiro…
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 <[email protected]>--- 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(-)Documentation/gpu/drm-uapi.rst +13
-0@@ -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:drivers/gpu/drm/drm_debugfs_crc.c +4
-4@@ -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 include/uapi/drm/drm.h +2
-3@@ -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. */ --
Quoted 2 lines
2.31.1
Hi,
with the caveat that I didn't actually build the docs and see how they look:
Thanks,
pq
Daniel Vetter
AppliedRe: [PATCH v4 1/2] drm/doc: document how userspace should find out CRTC index
Quoted 79 lines · Pekka Paalanen
Quoted 71 lines · On Wed, 9 Jun 2021 20:00:38 -0300 Leandro Ribeiro…
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 <[email protected]>--- 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(-)Documentation/gpu/drm-uapi.rst +13
-0@@ -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:drivers/gpu/drm/drm_debugfs_crc.c +4
-4@@ -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 include/uapi/drm/drm.h +2
-3@@ -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. */ --Quoted 2 lines
2.31.1
Hi,
Quoted 4 lines
with the caveat that I didn't actually build the docs and see how they look:
Reviewed-by Pekka Paalanen <[email protected]>
Pushed to drm-misc-next, thanks for the patch&review. -Daniel
Quoted 4 lines
Thanks,
pq
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
PATCH v4 2/2 drm/doc: document drm_mode_get_plane
In reply to Leandro RibeiroAdd a small description and document struct fields of drm_mode_get_plane.
--- include/uapi/drm/drm_mode.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
include/uapi/drm/drm_mode.h +36 -0
@@ -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
Re: [PATCH v4 2/2] drm/doc: document drm_mode_get_plane
Quoted 24 lines · Leandro Ribeiro
Add a small description and document struct fields of
drm_mode_get_plane.Signed-off-by Leandro Ribeiro <[email protected]>--- include/uapi/drm/drm_mode.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)include/uapi/drm/drm_mode.h +8
-0@@ -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.
include/uapi/drm/drm_mode.h struct drm_mode_set_plane { · line 332
Quoted 10 lines
include/uapi/drm/drm_mode.h +10
-0+* +* 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.
Quoted 35 lines
include/uapi/drm/drm_mode.h +18
-1struct 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
Re: [PATCH v4 2/2] drm/doc: document drm_mode_get_plane
Quoted 32 lines · On Wed, 9 Jun 2021 20:05:06 -0300 Leandro Ribeiro…
Quoted 31 lines · Leandro Ribeiro
Add a small description and document struct fields of
drm_mode_get_plane.Signed-off-by Leandro Ribeiro <[email protected]>--- include/uapi/drm/drm_mode.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)include/uapi/drm/drm_mode.h +15
-0@@ -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.
Quoted 8 lines
include/uapi/drm/drm_mode.h struct drm_mode_set_plane { · line 332
Quoted 3 lines
include/uapi/drm/drm_mode.h +3
-0+* 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
Quoted 35 lines
Quoted 35 lines
include/uapi/drm/drm_mode.h +18
-1struct 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
Re: [PATCH v4 2/2] drm/doc: document drm_mode_get_plane
In reply to Leandro RibeiroQuoted 21 lines · Leandro Ribeiro
Add a small description and document struct fields of
drm_mode_get_plane.Signed-off-by Leandro Ribeiro <[email protected]>--- include/uapi/drm/drm_mode.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)include/uapi/drm/drm_mode.h +5
-0@@ -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.
include/uapi/drm/drm_mode.h struct drm_mode_set_plane { · line 329
Quoted 10 lines
include/uapi/drm/drm_mode.h +10
-0+* +* 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.
Quoted 14 lines
include/uapi/drm/drm_mode.h +9
-0+* 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;
include/uapi/drm/drm_mode.h struct drm_mode_set_plane { · line 353
Quoted 10 lines
include/uapi/drm/drm_mode.h +7
-0+/** +* @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.
Quoted 12 lines
include/uapi/drm/drm_mode.h +5
-1+/** @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
Signature · 2 lines
Ville Syrjälä Intel