This type is used to support a 3x4 matrix in colorops. A 3x4 matrix uses the last column as a "bias" column. Some HW exposes support for 3x4. The calculation looks like: out matrix in |R| |0 1 2 3 | | R | |G| = |4 5 6 7 | x | G | |B| |8 9 10 11| | B | |1.0| This is also the first colorop where we need a blob property to program the property. For that we'll introduce a new DATA property that can be used by all colorop TYPEs requiring a blob. The way a DATA blob is read depends on the TYPE of the colorop. We only create the DATA property for property types that need it.
Unified · Split
| @@ -794,6 +794,9 @@ static void drm_atomic_colorop_print_state(struct drm_printer *p, · 793 unmodified lines | ||
| 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_CTM_3X4: | |
| 798 | + drm_printf(p, "\tdata blob id=%d\n", state->data ? state->data->base.id : 0); | |
| 799 | + break; | |
| 797 | 800 | default: |
| 798 | 801 | break; |
| 799 | 802 | } |
| @@ -689,6 +689,32 @@ drm_atomic_plane_get_property(struct drm_plane *plane, · 688 unmodified lines | ||
| 689 | 689 | return 0; |
| 690 | 690 | } |
| 691 | 691 | |
| 692 | +static int drm_atomic_color_set_data_property(struct drm_colorop *colorop, | |
| 693 | + struct drm_colorop_state *state, | |
| 694 | + struct drm_property *property, | |
| 695 | + uint64_t val) | |
| 696 | +{ | |
| 697 | + ssize_t elem_size = -1; | |
| 698 | + ssize_t size = -1; | |
| 699 | + bool replaced = false; | |
| 700 | + | |
| 701 | + switch (colorop->type) { | |
| 702 | + case DRM_COLOROP_CTM_3X4: | |
| 703 | + size = sizeof(struct drm_color_ctm_3x4); | |
| 704 | + break; | |
| 705 | + default: | |
| 706 | + /* should never get here */ | |
| 707 | + return -EINVAL; | |
| 708 | + } | |
| 709 | + | |
| 710 | + return drm_property_replace_blob_from_id(colorop->dev, | |
| 711 | + &state->data, | |
| 712 | + val, | |
| 713 | + size, | |
| 714 | + elem_size, | |
| 715 | + &replaced); | |
| 716 | +} | |
| 717 | + | |
| 692 | 718 | static int drm_atomic_colorop_set_property(struct drm_colorop *colorop, |
| 693 | 719 | struct drm_colorop_state *state, |
| 694 | 720 | struct drm_file *file_priv, |
| @@ -699,6 +725,9 @@ static int drm_atomic_colorop_set_property(struct drm_colorop *colorop, · 4 unmodified lines | ||
| 699 | 725 | state->bypass = val; |
| 700 | 726 | } else if (property == colorop->curve_1d_type_property) { |
| 701 | 727 | state->curve_1d_type = val; |
| 728 | + } else if (property == colorop->data_property) { | |
| 729 | + return drm_atomic_color_set_data_property(colorop, state, | |
| 730 | + property, val); | |
| 702 | 731 | } else { |
| 703 | 732 | drm_dbg_atomic(colorop->dev, |
| 704 | 733 | "[COLOROP:%d:%d] unknown property [PROP:%d:%s]\n", |
| @@ -721,6 +750,8 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop, · 16 unmodified lines | ||
| 721 | 750 | *val = state->bypass; |
| 722 | 751 | else if (property == colorop->curve_1d_type_property) |
| 723 | 752 | *val = state->curve_1d_type; |
| 753 | + else if (property == colorop->data_property) | |
| 754 | + *val = (state->data) ? state->data->base.id : 0; | |
| 724 | 755 | else |
| 725 | 756 | return -EINVAL; |
| 726 | 757 | |
| @@ -64,6 +64,7 @@ · 63 unmodified lines | ||
| 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_CTM_3X4, "3x4 Matrix"}, | |
| 67 | 68 | }; |
| 68 | 69 | |
| 69 | 70 | static const char * const colorop_curve_1d_type_names[] = { |
| @@ -147,6 +148,11 @@ void drm_colorop_cleanup(struct drm_colorop *colorop) · 77 unmodified lines | ||
| 147 | 148 | list_del(&colorop->head); |
| 148 | 149 | config->num_colorop--; |
| 149 | 150 | |
| 151 | + if (colorop->state && colorop->state->data) { | |
| 152 | + drm_property_blob_put(colorop->state->data); | |
| 153 | + colorop->state->data = NULL; | |
| 154 | + } | |
| 155 | + | |
| 150 | 156 | kfree(colorop->state); |
| 151 | 157 | } |
| 152 | 158 | EXPORT_SYMBOL(drm_colorop_cleanup); |
| @@ -236,11 +242,51 @@ int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop * · 83 unmodified lines | ||
| 236 | 242 | } |
| 237 | 243 | EXPORT_SYMBOL(drm_plane_colorop_curve_1d_init); |
| 238 | 244 | |
| 245 | +static int drm_colorop_create_data_prop(struct drm_device *dev, struct drm_colorop *colorop) | |
| 246 | +{ | |
| 247 | + struct drm_property *prop; | |
| 248 | + | |
| 249 | + /* data */ | |
| 250 | + prop = drm_property_create(dev, DRM_MODE_PROP_ATOMIC | DRM_MODE_PROP_BLOB, | |
| 251 | + "DATA", 0); | |
| 252 | + if (!prop) | |
| 253 | + return -ENOMEM; | |
| 254 | + | |
| 255 | + colorop->data_property = prop; | |
| 256 | + drm_object_attach_property(&colorop->base, | |
| 257 | + colorop->data_property, | |
| 258 | + 0); | |
| 259 | + | |
| 260 | + return 0; | |
| 261 | +} | |
| 262 | + | |
| 263 | +int drm_plane_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop, | |
| 264 | + struct drm_plane *plane) | |
| 265 | +{ | |
| 266 | + int ret; | |
| 267 | + | |
| 268 | + ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_CTM_3X4); | |
| 269 | + if (ret) | |
| 270 | + return ret; | |
| 271 | + | |
| 272 | + ret = drm_colorop_create_data_prop(dev, colorop); | |
| 273 | + if (ret) | |
| 274 | + return ret; | |
| 275 | + | |
| 276 | + drm_colorop_reset(colorop); | |
| 277 | + | |
| 278 | + return 0; | |
| 279 | +} | |
| 280 | +EXPORT_SYMBOL(drm_plane_colorop_ctm_3x4_init); | |
| 281 | + | |
| 239 | 282 | static void __drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop, |
| 240 | 283 | struct drm_colorop_state *state) |
| 241 | 284 | { |
| 242 | 285 | memcpy(state, colorop->state, sizeof(*state)); |
| 243 | 286 | |
| 287 | + if (state->data) | |
| 288 | + drm_property_blob_get(state->data); | |
| 289 | + | |
| 244 | 290 | state->bypass = true; |
| 245 | 291 | } |
| 246 | 292 | |
| @@ -321,6 +367,7 @@ void drm_colorop_reset(struct drm_colorop *colorop) · 74 unmodified lines | ||
| 321 | 367 | |
| 322 | 368 | static const char * const colorop_type_name[] = { |
| 323 | 369 | [DRM_COLOROP_1D_CURVE] = "1D Curve", |
| 370 | + [DRM_COLOROP_CTM_3X4] = "3x4 Matrix", | |
| 324 | 371 | }; |
| 325 | 372 | |
| 326 | 373 | const char *drm_get_colorop_type_name(enum drm_colorop_type type) |
| @@ -97,6 +97,17 @@ struct drm_colorop_state { · 96 unmodified lines | ||
| 97 | 97 | */ |
| 98 | 98 | enum drm_colorop_curve_1d_type curve_1d_type; |
| 99 | 99 | |
| 100 | + /** | |
| 101 | + * @data: | |
| 102 | + * | |
| 103 | + * Data blob for any TYPE that requires such a blob. The | |
| 104 | + * interpretation of the blob is TYPE-specific. | |
| 105 | + * | |
| 106 | + * See the &drm_colorop_type documentation for how blob is laid | |
| 107 | + * out. | |
| 108 | + */ | |
| 109 | + struct drm_property_blob *data; | |
| 110 | + | |
| 100 | 111 | /** @state: backpointer to global drm_atomic_state */ |
| 101 | 112 | struct drm_atomic_state *state; |
| 102 | 113 | }; |
| @@ -206,6 +217,17 @@ struct drm_colorop { · 103 unmodified lines | ||
| 206 | 217 | */ |
| 207 | 218 | struct drm_property *curve_1d_type_property; |
| 208 | 219 | |
| 220 | + /** | |
| 221 | + * @data_property: | |
| 222 | + * | |
| 223 | + * blob property for any TYPE that requires a blob of data, | |
| 224 | + * such as 1DLUT, CTM, 3DLUT, etc. | |
| 225 | + * | |
| 226 | + * The way this blob is interpreted depends on the TYPE of | |
| 227 | + * this | |
| 228 | + */ | |
| 229 | + struct drm_property *data_property; | |
| 230 | + | |
| 209 | 231 | /** |
| 210 | 232 | * @next_property: |
| 211 | 233 | * |
| @@ -242,6 +264,8 @@ void drm_colorop_cleanup(struct drm_colorop *colorop); · 30 unmodified lines | ||
| 242 | 264 | |
| 243 | 265 | int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop, |
| 244 | 266 | struct drm_plane *plane, u64 supported_tfs); |
| 267 | +int drm_plane_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop, | |
| 268 | + struct drm_plane *plane); | |
| 245 | 269 | |
| 246 | 270 | struct drm_colorop_state * |
| 247 | 271 | drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop); |
| @@ -1656,15 +1656,6 @@ struct drm_amdgpu_info_uq_metadata { · 1655 unmodified lines | ||
| 1656 | 1656 | #define AMDGPU_FAMILY_GC_11_5_0 150 /* GC 11.5.0 */ |
| 1657 | 1657 | #define AMDGPU_FAMILY_GC_12_0_0 152 /* GC 12.0.0 */ |
| 1658 | 1658 | |
| 1659 | −/* FIXME wrong namespace! */ | |
| 1660 | −struct drm_color_ctm_3x4 { | |
| 1661 | − /* | |
| 1662 | − * Conversion matrix with 3x4 dimensions in S31.32 sign-magnitude | |
| 1663 | − * (not two's complement!) format. | |
| 1664 | − */ | |
| 1665 | − __u64 matrix[12]; | |
| 1666 | −}; | |
| 1667 | − | |
| 1668 | 1659 | #if defined(__cplusplus) |
| 1669 | 1660 | } |
| 1670 | 1661 | #endif |
| @@ -847,6 +847,20 @@ struct drm_color_ctm { · 846 unmodified lines | ||
| 847 | 847 | __u64 matrix[9]; |
| 848 | 848 | }; |
| 849 | 849 | |
| 850 | +struct drm_color_ctm_3x4 { | |
| 851 | + /* | |
| 852 | + * Conversion matrix with 3x4 dimensions in S31.32 sign-magnitude | |
| 853 | + * (not two's complement!) format. | |
| 854 | + * | |
| 855 | + * out matrix in | |
| 856 | + * |R| |0 1 2 3 | | R | | |
| 857 | + * |G| = |4 5 6 7 | x | G | | |
| 858 | + * |B| |8 9 10 11| | B | | |
| 859 | + * |1.0| | |
| 860 | + */ | |
| 861 | + __u64 matrix[12]; | |
| 862 | +}; | |
| 863 | + | |
| 850 | 864 | struct drm_color_lut { |
| 851 | 865 | /* |
| 852 | 866 | * Values are mapped linearly to 0.0 - 1.0 range, with 0x0 == 0.0 and |
| @@ -874,7 +888,23 @@ enum drm_colorop_type { · 21 unmodified lines | ||
| 874 | 888 | * A 1D curve that is being applied to all color channels. The |
| 875 | 889 | * curve is specified via the CURVE_1D_TYPE colorop property. |
| 876 | 890 | */ |
| 877 | − DRM_COLOROP_1D_CURVE | |
| 891 | + DRM_COLOROP_1D_CURVE, | |
| 892 | + | |
| 893 | + /** | |
| 894 | + * @DRM_COLOROP_CTM_3X4: | |
| 895 | + * | |
| 896 | + * enum string "3x4 Matrix" | |
| 897 | + * | |
| 898 | + * A 3x4 matrix. Its values are specified via the | |
| 899 | + * &drm_color_ctm_3x4 struct provided via the DATA property. | |
| 900 | + * | |
| 901 | + * The DATA blob is a float[12]: | |
| 902 | + * out matrix in | |
| 903 | + * | R | | 0 1 2 3 | | R | | |
| 904 | + * | G | = | 4 5 6 7 | x | G | | |
| 905 | + * | B | | 8 9 10 12 | | B | | |
| 906 | + */ | |
| 907 | + DRM_COLOROP_CTM_3X4, | |
| 878 | 908 | }; |
| 879 | 909 | |
| 880 | 910 | /** |