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: Define LUT_1D interpolation

We want to make sure userspace is aware of the 1D LUT
interpolation. While linear interpolation is common it
might not be supported on all HW. Give driver implementers
a way to specify their interpolation.

Reviewed-by: Simon Ser <contact@emersion.fr>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Harry Wentland <harry.wentland@amd.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Melissa Wen <mwen@igalia.com>
Reviewed-by: Sebastian Wick <sebastian.wick@redhat.com>
Signed-off-by: Simon Ser <contact@emersion.fr>
Link: https://patch.msgid.link/20251115000237.3561250-44-alex.hung@amd.com

authored by

Harry Wentland and committed by
Simon Ser
7fa3ee8c 68186c73

+79 -4
+4 -2
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
··· 126 126 goto cleanup; 127 127 } 128 128 129 - ret = drm_plane_colorop_curve_1d_lut_init(dev, ops[i], plane, MAX_COLOR_LUT_ENTRIES); 129 + ret = drm_plane_colorop_curve_1d_lut_init(dev, ops[i], plane, MAX_COLOR_LUT_ENTRIES, 130 + DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR); 130 131 if (ret) 131 132 goto cleanup; 132 133 ··· 157 156 goto cleanup; 158 157 } 159 158 160 - ret = drm_plane_colorop_curve_1d_lut_init(dev, ops[i], plane, MAX_COLOR_LUT_ENTRIES); 159 + ret = drm_plane_colorop_curve_1d_lut_init(dev, ops[i], plane, MAX_COLOR_LUT_ENTRIES, 160 + DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR); 161 161 if (ret) 162 162 goto cleanup; 163 163
+2
drivers/gpu/drm/drm_atomic.c
··· 796 796 break; 797 797 case DRM_COLOROP_1D_LUT: 798 798 drm_printf(p, "\tsize=%d\n", colorop->size); 799 + drm_printf(p, "\tinterpolation=%s\n", 800 + drm_get_colorop_lut1d_interpolation_name(colorop->lut1d_interpolation)); 799 801 drm_printf(p, "\tdata blob id=%d\n", state->data ? state->data->base.id : 0); 800 802 break; 801 803 case DRM_COLOROP_CTM_3X4:
+4
drivers/gpu/drm/drm_atomic_uapi.c
··· 726 726 { 727 727 if (property == colorop->bypass_property) { 728 728 state->bypass = val; 729 + } else if (property == colorop->lut1d_interpolation_property) { 730 + colorop->lut1d_interpolation = val; 729 731 } else if (property == colorop->curve_1d_type_property) { 730 732 state->curve_1d_type = val; 731 733 } else if (property == colorop->multiplier_property) { ··· 755 753 *val = colorop->type; 756 754 else if (property == colorop->bypass_property) 757 755 *val = state->bypass; 756 + else if (property == colorop->lut1d_interpolation_property) 757 + *val = colorop->lut1d_interpolation; 758 758 else if (property == colorop->curve_1d_type_property) 759 759 *val = state->curve_1d_type; 760 760 else if (property == colorop->multiplier_property)
+36 -1
drivers/gpu/drm/drm_colorop.c
··· 78 78 [DRM_COLOROP_1D_CURVE_BT2020_OETF] = "BT.2020 OETF", 79 79 }; 80 80 81 + static const struct drm_prop_enum_list drm_colorop_lut1d_interpolation_list[] = { 82 + { DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR, "Linear" }, 83 + }; 84 + 81 85 /* Init Helpers */ 82 86 83 87 static int drm_plane_colorop_init(struct drm_device *dev, struct drm_colorop *colorop, ··· 277 273 * @colorop: The drm_colorop object to initialize 278 274 * @plane: The associated drm_plane 279 275 * @lut_size: LUT size supported by driver 276 + * @interpolation: 1D LUT interpolation type 280 277 * @return zero on success, -E value on failure 281 278 */ 282 279 int drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *colorop, 283 - struct drm_plane *plane, uint32_t lut_size) 280 + struct drm_plane *plane, uint32_t lut_size, 281 + enum drm_colorop_lut1d_interpolation_type interpolation) 284 282 { 285 283 struct drm_property *prop; 286 284 int ret; ··· 301 295 colorop->size_property = prop; 302 296 drm_object_attach_property(&colorop->base, colorop->size_property, lut_size); 303 297 colorop->size = lut_size; 298 + 299 + /* interpolation */ 300 + prop = drm_property_create_enum(dev, 0, "LUT1D_INTERPOLATION", 301 + drm_colorop_lut1d_interpolation_list, 302 + ARRAY_SIZE(drm_colorop_lut1d_interpolation_list)); 303 + if (!prop) 304 + return -ENOMEM; 305 + 306 + colorop->lut1d_interpolation_property = prop; 307 + drm_object_attach_property(&colorop->base, prop, interpolation); 308 + colorop->lut1d_interpolation = interpolation; 304 309 305 310 /* data */ 306 311 ret = drm_colorop_create_data_prop(dev, colorop); ··· 466 449 [DRM_COLOROP_CTM_3X4] = "3x4 Matrix", 467 450 [DRM_COLOROP_MULTIPLIER] = "Multiplier", 468 451 }; 452 + static const char * const colorop_lut1d_interpolation_name[] = { 453 + [DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR] = "Linear", 454 + }; 469 455 470 456 const char *drm_get_colorop_type_name(enum drm_colorop_type type) 471 457 { ··· 484 464 return "unknown"; 485 465 486 466 return colorop_curve_1d_type_names[type]; 467 + } 468 + 469 + /** 470 + * drm_get_colorop_lut1d_interpolation_name: return a string for interpolation type 471 + * @type: interpolation type to compute name of 472 + * 473 + * In contrast to the other drm_get_*_name functions this one here returns a 474 + * const pointer and hence is threadsafe. 475 + */ 476 + const char *drm_get_colorop_lut1d_interpolation_name(enum drm_colorop_lut1d_interpolation_type type) 477 + { 478 + if (WARN_ON(type >= ARRAY_SIZE(colorop_lut1d_interpolation_name))) 479 + return "unknown"; 480 + 481 + return colorop_lut1d_interpolation_name[type]; 487 482 } 488 483 489 484 /**
+20 -1
include/drm/drm_colorop.h
··· 272 272 uint32_t size; 273 273 274 274 /** 275 + * @lut1d_interpolation: 276 + * 277 + * Read-only 278 + * Interpolation for DRM_COLOROP_1D_LUT 279 + */ 280 + enum drm_colorop_lut1d_interpolation_type lut1d_interpolation; 281 + 282 + /** 283 + * @lut1d_interpolation_property: 284 + * 285 + * Read-only property for DRM_COLOROP_1D_LUT interpolation 286 + */ 287 + struct drm_property *lut1d_interpolation_property; 288 + 289 + /** 275 290 * @curve_1d_type_property: 276 291 * 277 292 * Sub-type for DRM_COLOROP_1D_CURVE type. ··· 355 340 int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop, 356 341 struct drm_plane *plane, u64 supported_tfs); 357 342 int drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *colorop, 358 - struct drm_plane *plane, uint32_t lut_size); 343 + struct drm_plane *plane, uint32_t lut_size, 344 + enum drm_colorop_lut1d_interpolation_type interpolation); 359 345 int drm_plane_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop, 360 346 struct drm_plane *plane); 361 347 int drm_plane_colorop_mult_init(struct drm_device *dev, struct drm_colorop *colorop, ··· 409 393 * const pointer and hence is threadsafe. 410 394 */ 411 395 const char *drm_get_colorop_curve_1d_type_name(enum drm_colorop_curve_1d_type type); 396 + 397 + const char * 398 + drm_get_colorop_lut1d_interpolation_name(enum drm_colorop_lut1d_interpolation_type type); 412 399 413 400 void drm_colorop_set_next_property(struct drm_colorop *colorop, struct drm_colorop *next); 414 401
+13
include/uapi/drm/drm_mode.h
··· 945 945 }; 946 946 947 947 /** 948 + * enum drm_colorop_lut1d_interpolation_type - type of interpolation for 1D LUTs 949 + */ 950 + enum drm_colorop_lut1d_interpolation_type { 951 + /** 952 + * @DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR: 953 + * 954 + * Linear interpolation. Values between points of the LUT will be 955 + * linearly interpolated. 956 + */ 957 + DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR, 958 + }; 959 + 960 + /** 948 961 * struct drm_plane_size_hint - Plane size hints 949 962 * @width: The width of the plane in pixel 950 963 * @height: The height of the plane in pixel