@@ -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" },
};
@@ -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,
@@ -717,6 +717,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)
@@ -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;
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.wentland@amd.com> Cc: Ville Syrjala <ville.syrjala@linux.intel.com> Cc: Pekka Paalanen <pekka.paalanen@collabora.com> Cc: Simon Ser <contact@emersion.fr> Cc: Harry Wentland <harry.wentland@amd.com> Cc: Melissa Wen <mwen@igalia.com> Cc: Jonas Ådahl <jadahl@redhat.com> Cc: Sebastian Wick <sebastian.wick@redhat.com> Cc: Shashank Sharma <shashank.sharma@amd.com> Cc: Alexander Goins <agoins@nvidia.com> Cc: Joshua Ashton <joshua@froggi.es> Cc: Michel Dänzer <mdaenzer@redhat.com> Cc: Aleix Pol <aleixpol@kde.org> Cc: Xaver Hugl <xaver.hugl@gmail.com> Cc: Victoria Brekenfeld <victoria@system76.com> Cc: Sima <daniel@ffwll.ch> Cc: Uma Shankar <uma.shankar@intel.com> Cc: Naseer Ahmed <quic_naseer@quicinc.com> Cc: Christopher Braga <quic_cbraga@quicinc.com> Cc: Abhinav Kumar <quic_abhinavk@quicinc.com> Cc: Arthur Grillo <arthurgrillo@riseup.net> Cc: Hector Martin <marcan@marcan.st> Cc: Liviu Dudau <Liviu.Dudau@arm.com> Cc: Sasha McIntosh <sashamcintosh@google.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(+)