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 subtype

Add a new drm_colorop with DRM_COLOROP_1D_CURVE with two subtypes:
DRM_COLOROP_1D_CURVE_SRGB_EOTF and DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF.

Reviewed-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
Signed-off-by: Harry Wentland <harry.wentland@amd.com>
Co-developed-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Alex Hung <alex.hung@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-7-alex.hung@amd.com

authored by

Harry Wentland and committed by
Simon Ser
41651f9d 84423e56

+207 -4
+13 -4
drivers/gpu/drm/drm_atomic_uapi.c
··· 655 655 struct drm_property *property, 656 656 uint64_t val) 657 657 { 658 - drm_dbg_atomic(colorop->dev, 659 - "[COLOROP:%d] unknown property [PROP:%d:%s]]\n", 660 - colorop->base.id, property->base.id, property->name); 661 - return -EINVAL; 658 + if (property == colorop->curve_1d_type_property) { 659 + state->curve_1d_type = val; 660 + } else { 661 + drm_dbg_atomic(colorop->dev, 662 + "[COLOROP:%d:%d] unknown property [PROP:%d:%s]\n", 663 + colorop->base.id, colorop->type, 664 + property->base.id, property->name); 665 + return -EINVAL; 666 + } 667 + 668 + return 0; 662 669 } 663 670 664 671 static int ··· 675 668 { 676 669 if (property == colorop->type_property) 677 670 *val = colorop->type; 671 + else if (property == colorop->curve_1d_type_property) 672 + *val = state->curve_1d_type; 678 673 else 679 674 return -EINVAL; 680 675
+132
drivers/gpu/drm/drm_colorop.c
··· 31 31 32 32 #include "drm_crtc_internal.h" 33 33 34 + static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { 35 + { DRM_COLOROP_1D_CURVE, "1D Curve" }, 36 + }; 37 + 38 + static const char * const colorop_curve_1d_type_names[] = { 39 + [DRM_COLOROP_1D_CURVE_SRGB_EOTF] = "sRGB EOTF", 40 + [DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF] = "sRGB Inverse EOTF", 41 + }; 42 + 43 + /* Init Helpers */ 44 + 45 + static int drm_plane_colorop_init(struct drm_device *dev, struct drm_colorop *colorop, 46 + struct drm_plane *plane, enum drm_colorop_type type) 47 + { 48 + struct drm_mode_config *config = &dev->mode_config; 49 + struct drm_property *prop; 50 + int ret = 0; 51 + 52 + ret = drm_mode_object_add(dev, &colorop->base, DRM_MODE_OBJECT_COLOROP); 53 + if (ret) 54 + return ret; 55 + 56 + colorop->base.properties = &colorop->properties; 57 + colorop->dev = dev; 58 + colorop->type = type; 59 + colorop->plane = plane; 60 + 61 + list_add_tail(&colorop->head, &config->colorop_list); 62 + colorop->index = config->num_colorop++; 63 + 64 + /* add properties */ 65 + 66 + /* type */ 67 + prop = drm_property_create_enum(dev, 68 + DRM_MODE_PROP_IMMUTABLE, 69 + "TYPE", drm_colorop_type_enum_list, 70 + ARRAY_SIZE(drm_colorop_type_enum_list)); 71 + 72 + if (!prop) 73 + return -ENOMEM; 74 + 75 + colorop->type_property = prop; 76 + 77 + drm_object_attach_property(&colorop->base, 78 + colorop->type_property, 79 + colorop->type); 80 + 81 + return ret; 82 + } 83 + 84 + /** 85 + * drm_plane_colorop_curve_1d_init - Initialize a DRM_COLOROP_1D_CURVE 86 + * 87 + * @dev: DRM device 88 + * @colorop: The drm_colorop object to initialize 89 + * @plane: The associated drm_plane 90 + * @supported_tfs: A bitfield of supported drm_plane_colorop_curve_1d_init enum values, 91 + * created using BIT(curve_type) and combined with the OR '|' 92 + * operator. 93 + * @return zero on success, -E value on failure 94 + */ 95 + int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop, 96 + struct drm_plane *plane, u64 supported_tfs) 97 + { 98 + struct drm_prop_enum_list enum_list[DRM_COLOROP_1D_CURVE_COUNT]; 99 + int i, len; 100 + 101 + struct drm_property *prop; 102 + int ret; 103 + 104 + if (!supported_tfs) { 105 + drm_err(dev, 106 + "No supported TFs for new 1D curve colorop on [PLANE:%d:%s]\n", 107 + plane->base.id, plane->name); 108 + return -EINVAL; 109 + } 110 + 111 + if ((supported_tfs & -BIT(DRM_COLOROP_1D_CURVE_COUNT)) != 0) { 112 + drm_err(dev, "Unknown TF provided on [PLANE:%d:%s]\n", 113 + plane->base.id, plane->name); 114 + return -EINVAL; 115 + } 116 + 117 + ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_1D_CURVE); 118 + if (ret) 119 + return ret; 120 + 121 + len = 0; 122 + for (i = 0; i < DRM_COLOROP_1D_CURVE_COUNT; i++) { 123 + if ((supported_tfs & BIT(i)) == 0) 124 + continue; 125 + 126 + enum_list[len].type = i; 127 + enum_list[len].name = colorop_curve_1d_type_names[i]; 128 + len++; 129 + } 130 + 131 + if (WARN_ON(len <= 0)) 132 + return -EINVAL; 133 + 134 + /* initialize 1D curve only attribute */ 135 + prop = drm_property_create_enum(dev, DRM_MODE_PROP_ATOMIC, "CURVE_1D_TYPE", 136 + enum_list, len); 137 + if (!prop) 138 + return -ENOMEM; 139 + 140 + colorop->curve_1d_type_property = prop; 141 + drm_object_attach_property(&colorop->base, colorop->curve_1d_type_property, 142 + enum_list[0].type); 143 + drm_colorop_reset(colorop); 144 + 145 + return 0; 146 + } 147 + EXPORT_SYMBOL(drm_plane_colorop_curve_1d_init); 148 + 34 149 static void __drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop, 35 150 struct drm_colorop_state *state) 36 151 { ··· 184 69 static void __drm_colorop_state_reset(struct drm_colorop_state *colorop_state, 185 70 struct drm_colorop *colorop) 186 71 { 72 + u64 val; 73 + 187 74 colorop_state->colorop = colorop; 75 + 76 + if (colorop->curve_1d_type_property) { 77 + drm_object_property_get_default_value(&colorop->base, 78 + colorop->curve_1d_type_property, 79 + &val); 80 + colorop_state->curve_1d_type = val; 81 + } 188 82 } 189 83 190 84 /** ··· 236 112 return "unknown"; 237 113 238 114 return colorop_type_name[type]; 115 + } 116 + 117 + const char *drm_get_colorop_curve_1d_type_name(enum drm_colorop_curve_1d_type type) 118 + { 119 + if (WARN_ON(type >= ARRAY_SIZE(colorop_curve_1d_type_names))) 120 + return "unknown"; 121 + 122 + return colorop_curve_1d_type_names[type]; 239 123 }
+62
include/drm/drm_colorop.h
··· 32 32 #include <drm/drm_property.h> 33 33 34 34 /** 35 + * enum drm_colorop_curve_1d_type - type of 1D curve 36 + * 37 + * Describes a 1D curve to be applied by the DRM_COLOROP_1D_CURVE colorop. 38 + */ 39 + enum drm_colorop_curve_1d_type { 40 + /** 41 + * @DRM_COLOROP_1D_CURVE_SRGB_EOTF: 42 + * 43 + * enum string "sRGB EOTF" 44 + * 45 + * sRGB piece-wise electro-optical transfer function. Transfer 46 + * characteristics as defined by IEC 61966-2-1 sRGB. Equivalent 47 + * to H.273 TransferCharacteristics code point 13 with 48 + * MatrixCoefficients set to 0. 49 + */ 50 + DRM_COLOROP_1D_CURVE_SRGB_EOTF, 51 + 52 + /** 53 + * @DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF: 54 + * 55 + * enum string "sRGB Inverse EOTF" 56 + * 57 + * The inverse of &DRM_COLOROP_1D_CURVE_SRGB_EOTF 58 + */ 59 + DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF, 60 + 61 + /** 62 + * @DRM_COLOROP_1D_CURVE_COUNT: 63 + * 64 + * enum value denoting the size of the enum 65 + */ 66 + DRM_COLOROP_1D_CURVE_COUNT 67 + }; 68 + 69 + /** 35 70 * struct drm_colorop_state - mutable colorop state 36 71 */ 37 72 struct drm_colorop_state { ··· 80 45 * on the colorop type. See their associated comment for more 81 46 * information. 82 47 */ 48 + 49 + /** 50 + * @curve_1d_type: 51 + * 52 + * Type of 1D curve. 53 + */ 54 + enum drm_colorop_curve_1d_type curve_1d_type; 83 55 84 56 /** @state: backpointer to global drm_atomic_state */ 85 57 struct drm_atomic_state *state; ··· 169 127 * this color operation. The type is enum drm_colorop_type. 170 128 */ 171 129 struct drm_property *type_property; 130 + 131 + /** 132 + * @curve_1d_type_property: 133 + * 134 + * Sub-type for DRM_COLOROP_1D_CURVE type. 135 + */ 136 + struct drm_property *curve_1d_type_property; 137 + 172 138 }; 173 139 174 140 #define obj_to_colorop(x) container_of(x, struct drm_colorop, base) ··· 200 150 mo = drm_mode_object_find(dev, file_priv, id, DRM_MODE_OBJECT_COLOROP); 201 151 return mo ? obj_to_colorop(mo) : NULL; 202 152 } 153 + 154 + int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop, 155 + struct drm_plane *plane, u64 supported_tfs); 203 156 204 157 struct drm_colorop_state * 205 158 drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop); ··· 242 189 * const pointer and hence is threadsafe. 243 190 */ 244 191 const char *drm_get_colorop_type_name(enum drm_colorop_type type); 192 + 193 + /** 194 + * drm_get_colorop_curve_1d_type_name - return a string for 1D curve type 195 + * @type: 1d curve type to compute name of 196 + * 197 + * In contrast to the other drm_get_*_name functions this one here returns a 198 + * const pointer and hence is threadsafe. 199 + */ 200 + const char *drm_get_colorop_curve_1d_type_name(enum drm_colorop_curve_1d_type type); 245 201 246 202 #endif /* __DRM_COLOROP_H__ */