Since we created a new DRM object we need new IOCTLs (and new libdrm functions) to retrieve those objects.
TODO: Can we make these IOCTLs and libdrm functions generic to allow for new DRM objects in the future without the need for new IOCTLs and libdrm functions? Signed-off-by: Harry Wentland <harry.wentl...@amd.com> Cc: Ville Syrjala <ville.syrj...@linux.intel.com> Cc: Pekka Paalanen <pekka.paala...@collabora.com> Cc: Simon Ser <cont...@emersion.fr> Cc: Harry Wentland <harry.wentl...@amd.com> Cc: Melissa Wen <m...@igalia.com> Cc: Jonas Ådahl <jad...@redhat.com> Cc: Sebastian Wick <sebastian.w...@redhat.com> Cc: Shashank Sharma <shashank.sha...@amd.com> Cc: Alexander Goins <ago...@nvidia.com> Cc: Joshua Ashton <jos...@froggi.es> Cc: Michel Dänzer <mdaen...@redhat.com> Cc: Aleix Pol <aleix...@kde.org> Cc: Xaver Hugl <xaver.h...@gmail.com> Cc: Victoria Brekenfeld <victo...@system76.com> Cc: Daniel Vetter <dan...@ffwll.ch> Cc: Uma Shankar <uma.shan...@intel.com> Cc: Naseer Ahmed <quic_nas...@quicinc.com> Cc: Christopher Braga <quic_cbr...@quicinc.com> --- drivers/gpu/drm/drm_colorop.c | 51 +++++++++++++++++++++++++++++ drivers/gpu/drm/drm_crtc_internal.h | 4 +++ drivers/gpu/drm/drm_ioctl.c | 5 +++ include/uapi/drm/drm_mode.h | 21 ++++++++++++ 4 files changed, 81 insertions(+) diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c index a92e170aed87..fb85b5c41cc4 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -32,6 +32,57 @@ /* TODO big colorop doc, including properties, etc. */ +/* IOCTLs */ + +int drm_mode_getcolorop_res(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + struct drm_mode_get_colorop_res *colorop_resp = data; + struct drm_colorop *colorop; + uint32_t __user *colorop_ptr; + int count = 0; + + if (!drm_core_check_feature(dev, DRIVER_MODESET)) + return -EOPNOTSUPP; + + colorop_ptr = u64_to_user_ptr(colorop_resp->colorop_id_ptr); + + /* + * This ioctl is called twice, once to determine how much space is + * needed, and the 2nd time to fill it. + */ + drm_for_each_colorop(colorop, dev) { + if (drm_lease_held(file_priv, colorop->base.id)) { + if (count < colorop_resp->count_colorops && + put_user(colorop->base.id, colorop_ptr + count)) + return -EFAULT; + count++; + } + } + colorop_resp->count_colorops = count; + + return 0; +} + +int drm_mode_getcolorop(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + struct drm_mode_get_colorop *colorop_resp = data; + struct drm_colorop *colorop; + + if (!drm_core_check_feature(dev, DRIVER_MODESET)) + return -EOPNOTSUPP; + + colorop = drm_colorop_find(dev, file_priv, colorop_resp->colorop_id); + if (!colorop) + return -ENOENT; + + colorop_resp->colorop_id = colorop->base.id; + colorop_resp->plane_id = colorop->plane ? colorop->plane->base.id : 0; + + return 0; +} + static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { { DRM_COLOROP_1D_CURVE, "1D Curve" }, }; diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h index 501a10edd0e1..b68e05c2cf57 100644 --- a/drivers/gpu/drm/drm_crtc_internal.h +++ b/drivers/gpu/drm/drm_crtc_internal.h @@ -278,6 +278,10 @@ int drm_mode_getplane(struct drm_device *dev, void *data, struct drm_file *file_priv); int drm_mode_setplane(struct drm_device *dev, void *data, struct drm_file *file_priv); +int drm_mode_getcolorop_res(struct drm_device *dev, void *data, + struct drm_file *file_priv); +int drm_mode_getcolorop(struct drm_device *dev, void *data, + struct drm_file *file_priv); int drm_mode_cursor_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv); int drm_mode_cursor2_ioctl(struct drm_device *dev, diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index 7c9d66ee917d..a3c137ac88c6 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -716,6 +716,11 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_IOCTL_DEF(DRM_IOCTL_MODE_LIST_LESSEES, drm_mode_list_lessees_ioctl, DRM_MASTER), DRM_IOCTL_DEF(DRM_IOCTL_MODE_GET_LEASE, drm_mode_get_lease_ioctl, DRM_MASTER), DRM_IOCTL_DEF(DRM_IOCTL_MODE_REVOKE_LEASE, drm_mode_revoke_lease_ioctl, DRM_MASTER), + + DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETCOLOROPRESOURCES, drm_mode_getcolorop_res, 0), + /* TODO do we need GETCOLOROP? */ + DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETCOLOROP, drm_mode_getcolorop, 0), + }; #define DRM_CORE_IOCTL_COUNT ARRAY_SIZE(drm_ioctls) diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index 6dcf628def56..9e37eec55291 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -357,6 +357,27 @@ struct drm_mode_get_plane { __u64 format_type_ptr; }; +struct drm_mode_get_colorop_res { + __u64 colorop_id_ptr; + __u32 count_colorops; +}; + + +/** + * struct drm_mode_get_colorop - Get colorop metadata. + * + * Userspace can perform a GETCOLOROP ioctl to retrieve information about a + * colorop. + */ +struct drm_mode_get_colorop { + /** + * @colorop_id: Object ID of the colorop whose information should be + * retrieved. Set by caller. + */ + __u32 colorop_id; + __u32 plane_id; +}; + struct drm_mode_get_plane_res { __u64 plane_id_ptr; __u32 count_planes; -- 2.42.0