History

drm/colorop: Add multiplier type

This introduces a new drm_colorop_type: DRM_COLOROP_MULTIPLIER. It's a simple multiplier to all pixel values. The value is specified via a S31.32 fixed point provided via the "MULTIPLIER" property.

Alex Hung committed 12 months ago

Commit 34101081 parent 16e0f785 files · +67 −0Browse files

Unified · Split

5 files
  1. drivers/gpu/drm/drm_atomic.c +3 −0
  2. drivers/gpu/drm/drm_atomic_uapi.c +4 −0
  3. drivers/gpu/drm/drm_colorop.c +33 −0
  4. include/drm/drm_colorop.h +16 −0
  5. include/uapi/drm/drm_mode.h +11 −0
drivers/gpu/drm/drm_atomic.c+3−0
@@ -801,6 +801,9 @@ static void drm_atomic_colorop_print_state(struct drm_printer *p, · 800 unmodified lines
801801 case DRM_COLOROP_CTM_3X4:
802802 drm_printf(p, "\tdata blob id=%d\n", state->data ? state->data->base.id : 0);
803803 break;
804+ case DRM_COLOROP_MULTIPLIER:
805+ drm_printf(p, "\tmultiplier=%llu\n", state->multiplier);
806+ break;
804807 default:
805808 break;
806809 }
drivers/gpu/drm/drm_atomic_uapi.c+4−0
@@ -728,6 +728,8 @@ static int drm_atomic_colorop_set_property(struct drm_colorop *colorop, · 727 unmodified lines
728728 state->bypass = val;
729729 } else if (property == colorop->curve_1d_type_property) {
730730 state->curve_1d_type = val;
731+ } else if (property == colorop->multiplier_property) {
732+ state->multiplier = val;
731733 } else if (property == colorop->data_property) {
732734 return drm_atomic_color_set_data_property(colorop, state,
733735 property, val);
@@ -753,6 +755,8 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop, · 19 unmodified lines
753755 *val = state->bypass;
754756 else if (property == colorop->curve_1d_type_property)
755757 *val = state->curve_1d_type;
758+ else if (property == colorop->multiplier_property)
759+ *val = state->multiplier;
756760 else if (property == colorop->size_property)
757761 *val = colorop->size;
758762 else if (property == colorop->data_property)
drivers/gpu/drm/drm_colorop.c+33−0
@@ -66,6 +66,7 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { · 65 unmodified lines
6666 { DRM_COLOROP_1D_CURVE, "1D Curve" },
6767 { DRM_COLOROP_1D_LUT, "1D LUT" },
6868 { DRM_COLOROP_CTM_3X4, "3x4 Matrix"},
69+ { DRM_COLOROP_MULTIPLIER, "Multiplier"},
6970 };
7071
7172 static const char * const colorop_curve_1d_type_names[] = {
@@ -325,6 +326,37 @@ int drm_plane_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *c · 253 unmodified lines
325326 }
326327 EXPORT_SYMBOL(drm_plane_colorop_ctm_3x4_init);
327328
329+/**
330+ * drm_plane_colorop_mult_init - Initialize a DRM_COLOROP_MULTIPLIER
331+ *
332+ * @dev: DRM device
333+ * @colorop: The drm_colorop object to initialize
334+ * @plane: The associated drm_plane
335+ * @return zero on success, -E value on failure
336+ */
337+int drm_plane_colorop_mult_init(struct drm_device *dev, struct drm_colorop *colorop,
338+ struct drm_plane *plane)
339+{
340+ struct drm_property *prop;
341+ int ret;
342+
343+ ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_MULTIPLIER);
344+ if (ret)
345+ return ret;
346+
347+ prop = drm_property_create_range(dev, DRM_MODE_PROP_ATOMIC, "MULTIPLIER", 0, U64_MAX);
348+ if (!prop)
349+ return -ENOMEM;
350+
351+ colorop->multiplier_property = prop;
352+ drm_object_attach_property(&colorop->base, colorop->multiplier_property, 0);
353+
354+ drm_colorop_reset(colorop);
355+
356+ return 0;
357+}
358+EXPORT_SYMBOL(drm_plane_colorop_mult_init);
359+
328360 static void __drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop,
329361 struct drm_colorop_state *state)
330362 {
@@ -415,6 +447,7 @@ static const char * const colorop_type_name[] = { · 84 unmodified lines
415447 [DRM_COLOROP_1D_CURVE] = "1D Curve",
416448 [DRM_COLOROP_1D_LUT] = "1D LUT",
417449 [DRM_COLOROP_CTM_3X4] = "3x4 Matrix",
450+ [DRM_COLOROP_MULTIPLIER] = "Multiplier",
418451 };
419452
420453 const char *drm_get_colorop_type_name(enum drm_colorop_type type)
include/drm/drm_colorop.h+16−0
@@ -144,6 +144,13 @@ struct drm_colorop_state { · 143 unmodified lines
144144 */
145145 enum drm_colorop_curve_1d_type curve_1d_type;
146146
147+ /**
148+ * @multiplier:
149+ *
150+ * Multiplier to 'gain' the plane. Format is S31.32 sign-magnitude.
151+ */
152+ uint64_t multiplier;
153+
147154 /**
148155 * @data:
149156 *
@@ -271,6 +278,13 @@ struct drm_colorop { · 121 unmodified lines
271278 */
272279 struct drm_property *curve_1d_type_property;
273280
281+ /**
282+ * @multiplier_property:
283+ *
284+ * Multiplier property for plane gain
285+ */
286+ struct drm_property *multiplier_property;
287+
274288 /**
275289 * @size_property:
276290 *
@@ -329,6 +343,8 @@ int drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_color · 52 unmodified lines
329343 struct drm_plane *plane, uint32_t lut_size);
330344 int drm_plane_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop,
331345 struct drm_plane *plane);
346+int drm_plane_colorop_mult_init(struct drm_device *dev, struct drm_colorop *colorop,
347+ struct drm_plane *plane);
332348
333349 struct drm_colorop_state *
334350 drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop);
include/uapi/drm/drm_mode.h+11−0
@@ -931,6 +931,17 @@ enum drm_colorop_type { · 930 unmodified lines
931931 * | B | | 8 9 10 12 | | B |
932932 */
933933 DRM_COLOROP_CTM_3X4,
934+
935+ /**
936+ * @DRM_COLOROP_MULTIPLIER:
937+ *
938+ * enum string "Multiplier"
939+ *
940+ * A simple multiplier, applied to all color values. The
941+ * multiplier is specified as a S31.32 via the MULTIPLIER
942+ * property.
943+ */
944+ DRM_COLOROP_MULTIPLIER,
934945 };
935946
936947 /**