History

drm/colorop: Add 3x4 CTM type

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.

Harry Wentland committed 1 year ago

Commit e5719e71 parent cb500b46 files · +136 −10Browse files

Unified · Split

6 files
  1. drivers/gpu/drm/drm_atomic.c +3 −0
  2. drivers/gpu/drm/drm_atomic_uapi.c +31 −0
  3. drivers/gpu/drm/drm_colorop.c +47 −0
  4. include/drm/drm_colorop.h +24 −0
  5. include/uapi/drm/amdgpu_drm.h +0 −9
  6. include/uapi/drm/drm_mode.h +31 −1
drivers/gpu/drm/drm_atomic.c+3−0
@@ -794,6 +794,9 @@ static void drm_atomic_colorop_print_state(struct drm_printer *p, · 793 unmodified lines
794794 drm_printf(p, "\tcurve_1d_type=%s\n",
795795 drm_get_colorop_curve_1d_type_name(state->curve_1d_type));
796796 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;
797800 default:
798801 break;
799802 }
drivers/gpu/drm/drm_atomic_uapi.c+31−0
@@ -689,6 +689,32 @@ drm_atomic_plane_get_property(struct drm_plane *plane, · 688 unmodified lines
689689 return 0;
690690 }
691691
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+
692718 static int drm_atomic_colorop_set_property(struct drm_colorop *colorop,
693719 struct drm_colorop_state *state,
694720 struct drm_file *file_priv,
@@ -699,6 +725,9 @@ static int drm_atomic_colorop_set_property(struct drm_colorop *colorop, · 4 unmodified lines
699725 state->bypass = val;
700726 } else if (property == colorop->curve_1d_type_property) {
701727 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);
702731 } else {
703732 drm_dbg_atomic(colorop->dev,
704733 "[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
721750 *val = state->bypass;
722751 else if (property == colorop->curve_1d_type_property)
723752 *val = state->curve_1d_type;
753+ else if (property == colorop->data_property)
754+ *val = (state->data) ? state->data->base.id : 0;
724755 else
725756 return -EINVAL;
726757
drivers/gpu/drm/drm_colorop.c+47−0
@@ -64,6 +64,7 @@ · 63 unmodified lines
6464
6565 static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = {
6666 { DRM_COLOROP_1D_CURVE, "1D Curve" },
67+ { DRM_COLOROP_CTM_3X4, "3x4 Matrix"},
6768 };
6869
6970 static const char * const colorop_curve_1d_type_names[] = {
@@ -147,6 +148,11 @@ void drm_colorop_cleanup(struct drm_colorop *colorop) · 77 unmodified lines
147148 list_del(&colorop->head);
148149 config->num_colorop--;
149150
151+ if (colorop->state && colorop->state->data) {
152+ drm_property_blob_put(colorop->state->data);
153+ colorop->state->data = NULL;
154+ }
155+
150156 kfree(colorop->state);
151157 }
152158 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
236242 }
237243 EXPORT_SYMBOL(drm_plane_colorop_curve_1d_init);
238244
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+
239282 static void __drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop,
240283 struct drm_colorop_state *state)
241284 {
242285 memcpy(state, colorop->state, sizeof(*state));
243286
287+ if (state->data)
288+ drm_property_blob_get(state->data);
289+
244290 state->bypass = true;
245291 }
246292
@@ -321,6 +367,7 @@ void drm_colorop_reset(struct drm_colorop *colorop) · 74 unmodified lines
321367
322368 static const char * const colorop_type_name[] = {
323369 [DRM_COLOROP_1D_CURVE] = "1D Curve",
370+ [DRM_COLOROP_CTM_3X4] = "3x4 Matrix",
324371 };
325372
326373 const char *drm_get_colorop_type_name(enum drm_colorop_type type)
include/drm/drm_colorop.h+24−0
@@ -97,6 +97,17 @@ struct drm_colorop_state { · 96 unmodified lines
9797 */
9898 enum drm_colorop_curve_1d_type curve_1d_type;
9999
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+
100111 /** @state: backpointer to global drm_atomic_state */
101112 struct drm_atomic_state *state;
102113 };
@@ -206,6 +217,17 @@ struct drm_colorop { · 103 unmodified lines
206217 */
207218 struct drm_property *curve_1d_type_property;
208219
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+
209231 /**
210232 * @next_property:
211233 *
@@ -242,6 +264,8 @@ void drm_colorop_cleanup(struct drm_colorop *colorop); · 30 unmodified lines
242264
243265 int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop,
244266 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);
245269
246270 struct drm_colorop_state *
247271 drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop);
include/uapi/drm/amdgpu_drm.h+0−9
@@ -1656,15 +1656,6 @@ struct drm_amdgpu_info_uq_metadata { · 1655 unmodified lines
16561656 #define AMDGPU_FAMILY_GC_11_5_0 150 /* GC 11.5.0 */
16571657 #define AMDGPU_FAMILY_GC_12_0_0 152 /* GC 12.0.0 */
16581658
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−
16681659 #if defined(__cplusplus)
16691660 }
16701661 #endif
include/uapi/drm/drm_mode.h+31−1
@@ -847,6 +847,20 @@ struct drm_color_ctm { · 846 unmodified lines
847847 __u64 matrix[9];
848848 };
849849
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+
850864 struct drm_color_lut {
851865 /*
852866 * 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
874888 * A 1D curve that is being applied to all color channels. The
875889 * curve is specified via the CURVE_1D_TYPE colorop property.
876890 */
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,
878908 };
879909
880910 /**

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t