Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/colorop: Add 1D Curve Custom LUT type

We've previously introduced DRM_COLOROP_1D_CURVE for
pre-defined 1D curves. But we also have HW that supports
custom curves and userspace needs the ability to pass
custom curves, aka LUTs.

This patch introduces a new colorop type, called
DRM_COLOROP_1D_LUT that provides a SIZE property which
is used by a driver to advertise the supported SIZE
of the LUT, as well as a DATA property which userspace
uses to set the LUT.

DATA and size function in the same way as current drm_crtc
GAMMA and DEGAMMA LUTs.

Reviewed-by: Simon Ser <contact@emersion.fr>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Co-developed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Harry Wentland <harry.wentland@amd.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Simon Ser <contact@emersion.fr>
Link: https://patch.msgid.link/20251115000237.3561250-38-alex.hung@amd.com

authored by

Alex Hung and committed by
Simon Ser
99a4e4f0 94529775

+82
+4
drivers/gpu/drm/drm_atomic.c
··· 794 794 drm_printf(p, "\tcurve_1d_type=%s\n", 795 795 drm_get_colorop_curve_1d_type_name(state->curve_1d_type)); 796 796 break; 797 + case DRM_COLOROP_1D_LUT: 798 + drm_printf(p, "\tsize=%d\n", colorop->size); 799 + drm_printf(p, "\tdata blob id=%d\n", state->data ? state->data->base.id : 0); 800 + break; 797 801 case DRM_COLOROP_CTM_3X4: 798 802 drm_printf(p, "\tdata blob id=%d\n", state->data ? state->data->base.id : 0); 799 803 break;
+5
drivers/gpu/drm/drm_atomic_uapi.c
··· 699 699 bool replaced = false; 700 700 701 701 switch (colorop->type) { 702 + case DRM_COLOROP_1D_LUT: 703 + size = colorop->size * sizeof(struct drm_color_lut32); 704 + break; 702 705 case DRM_COLOROP_CTM_3X4: 703 706 size = sizeof(struct drm_color_ctm_3x4); 704 707 break; ··· 753 750 *val = state->bypass; 754 751 else if (property == colorop->curve_1d_type_property) 755 752 *val = state->curve_1d_type; 753 + else if (property == colorop->size_property) 754 + *val = colorop->size; 756 755 else if (property == colorop->data_property) 757 756 *val = (state->data) ? state->data->base.id : 0; 758 757 else
+43
drivers/gpu/drm/drm_colorop.c
··· 64 64 65 65 static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { 66 66 { DRM_COLOROP_1D_CURVE, "1D Curve" }, 67 + { DRM_COLOROP_1D_LUT, "1D LUT" }, 67 68 { DRM_COLOROP_CTM_3X4, "3x4 Matrix"}, 68 69 }; 69 70 ··· 265 264 return 0; 266 265 } 267 266 267 + /** 268 + * drm_plane_colorop_curve_1d_lut_init - Initialize a DRM_COLOROP_1D_LUT 269 + * 270 + * @dev: DRM device 271 + * @colorop: The drm_colorop object to initialize 272 + * @plane: The associated drm_plane 273 + * @lut_size: LUT size supported by driver 274 + * @return zero on success, -E value on failure 275 + */ 276 + int drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *colorop, 277 + struct drm_plane *plane, uint32_t lut_size) 278 + { 279 + struct drm_property *prop; 280 + int ret; 281 + 282 + ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_1D_LUT); 283 + if (ret) 284 + return ret; 285 + 286 + /* initialize 1D LUT only attribute */ 287 + /* LUT size */ 288 + prop = drm_property_create_range(dev, DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_ATOMIC, 289 + "SIZE", 0, UINT_MAX); 290 + if (!prop) 291 + return -ENOMEM; 292 + 293 + colorop->size_property = prop; 294 + drm_object_attach_property(&colorop->base, colorop->size_property, lut_size); 295 + colorop->size = lut_size; 296 + 297 + /* data */ 298 + ret = drm_colorop_create_data_prop(dev, colorop); 299 + if (ret) 300 + return ret; 301 + 302 + drm_colorop_reset(colorop); 303 + 304 + return 0; 305 + } 306 + EXPORT_SYMBOL(drm_plane_colorop_curve_1d_lut_init); 307 + 268 308 int drm_plane_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop, 269 309 struct drm_plane *plane) 270 310 { ··· 413 371 414 372 static const char * const colorop_type_name[] = { 415 373 [DRM_COLOROP_1D_CURVE] = "1D Curve", 374 + [DRM_COLOROP_1D_LUT] = "1D LUT", 416 375 [DRM_COLOROP_CTM_3X4] = "3x4 Matrix", 417 376 }; 418 377
+16
include/drm/drm_colorop.h
··· 258 258 struct drm_property *bypass_property; 259 259 260 260 /** 261 + * @size: 262 + * 263 + * Number of entries of the custom LUT. This should be read-only. 264 + */ 265 + uint32_t size; 266 + 267 + /** 261 268 * @curve_1d_type_property: 262 269 * 263 270 * Sub-type for DRM_COLOROP_1D_CURVE type. 264 271 */ 265 272 struct drm_property *curve_1d_type_property; 273 + 274 + /** 275 + * @size_property: 276 + * 277 + * Size property for custom LUT from userspace. 278 + */ 279 + struct drm_property *size_property; 266 280 267 281 /** 268 282 * @data_property: ··· 325 311 326 312 int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop, 327 313 struct drm_plane *plane, u64 supported_tfs); 314 + int drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *colorop, 315 + struct drm_plane *plane, uint32_t lut_size); 328 316 int drm_plane_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop, 329 317 struct drm_plane *plane); 330 318
+14
include/uapi/drm/drm_mode.h
··· 903 903 DRM_COLOROP_1D_CURVE, 904 904 905 905 /** 906 + * @DRM_COLOROP_1D_LUT: 907 + * 908 + * enum string "1D LUT" 909 + * 910 + * A simple 1D LUT of uniformly spaced &drm_color_lut32 entries, 911 + * packed into a blob via the DATA property. The driver's 912 + * expected LUT size is advertised via the SIZE property. 913 + * 914 + * The DATA blob is an array of struct drm_color_lut32 with size 915 + * of "size". 916 + */ 917 + DRM_COLOROP_1D_LUT, 918 + 919 + /** 906 920 * @DRM_COLOROP_CTM_3X4: 907 921 * 908 922 * enum string "3x4 Matrix"