From: Chaitanya Kumar Borah <chaitanya.kumar.borah@xxxxxxxxx> Add support for 3x3 Color Transformation Matrices in Color Pipeline. v2: Updated the documentation for 3x3 CTM colorop (Dmitry) Signed-off-by: Chaitanya Kumar Borah <chaitanya.kumar.borah@xxxxxxxxx> Signed-off-by: Uma Shankar <uma.shankar@xxxxxxxxx> --- drivers/gpu/drm/drm_atomic.c | 3 +++ drivers/gpu/drm/drm_atomic_uapi.c | 3 +++ drivers/gpu/drm/drm_colorop.c | 29 +++++++++++++++++++++++++++++ include/drm/drm_colorop.h | 10 ++++++++++ include/uapi/drm/drm_mode.h | 8 ++++++++ 5 files changed, 53 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index fabf09b88900..ab7d2ed9ee8c 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -800,6 +800,9 @@ static void drm_atomic_colorop_print_state(struct drm_printer *p, drm_get_colorop_lut1d_interpolation_name(colorop->lut1d_interpolation)); drm_printf(p, "\tdata blob id=%d\n", state->data ? state->data->base.id : 0); break; + case DRM_COLOROP_CTM_3X3: + drm_printf(p, "\tdata blob id=%d\n", state->data ? state->data->base.id : 0); + break; case DRM_COLOROP_CTM_3X4: drm_printf(p, "\tdata blob id=%d\n", state->data ? state->data->base.id : 0); break; diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index 195c7bfbae5f..8258558ff334 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -708,6 +708,9 @@ static int drm_atomic_color_set_data_property(struct drm_colorop *colorop, case DRM_COLOROP_CTM_3X4: size = sizeof(struct drm_color_ctm_3x4); break; + case DRM_COLOROP_CTM_3X3: + size = sizeof(struct drm_color_ctm); + break; case DRM_COLOROP_3D_LUT: size = colorop->lut_size * colorop->lut_size * colorop->lut_size * sizeof(struct drm_color_lut); diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c index 5245d6a4da39..7aa572f74193 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -362,6 +362,35 @@ int drm_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop } EXPORT_SYMBOL(drm_colorop_ctm_3x4_init); +/** + * drm_colorop_ctm_3x3_init - Initialize a DRM_COLOROP_CTM_3X3 + * + * @dev: DRM device + * @colorop: The drm_colorop object to initialize + * @plane: The associated drm_plane + * @allow_bypass: true if BYPASS property should be created, false if bypass of + * this colorop is not possible + * @return zero on success, -E value on failure + */ +int drm_colorop_ctm_3x3_init(struct drm_device *dev, struct drm_colorop *colorop, + struct drm_plane *plane, bool allow_bypass) +{ + int ret; + + ret = drm_colorop_init(dev, colorop, plane, DRM_COLOROP_CTM_3X3, allow_bypass); + if (ret) + return ret; + + ret = drm_colorop_create_data_prop(dev, colorop); + if (ret) + return ret; + + drm_colorop_reset(colorop); + + return 0; +} +EXPORT_SYMBOL(drm_colorop_ctm_3x3_init); + /** * drm_colorop_mult_init - Initialize a DRM_COLOROP_MULTIPLIER * diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h index 953eea079708..1cd8ce81224e 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -156,6 +156,14 @@ struct drm_colorop_state { * |G| = |4 5 6 7 | x | G | * |B| |8 9 10 12| | B | * + * For 3x3 matrix (DRM_COLOROP_CTM_3X3), the blob is of type struct drm_color_ctm + * which represents the Conversion matrix in S31.32 sign-magnitude + * (not two's complement!) format. + * out matrix in + * |R| |0 1 2| |R| + * |G| = |3 4 5| x |G| + * |B| |6 7 8| |B| + * * For 3D LUTs (DRM_COLOROP_3D_LUT), the blob is a 3D array of * struct drm_color_lut with dimension length of "lut_size". * The LUT elements are traversed like so: @@ -376,6 +384,8 @@ int drm_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *co struct drm_plane *plane, uint32_t lut_size, enum drm_colorop_lut1d_interpolation_type lut1d_interpolation, bool allow_bypass); +int drm_colorop_ctm_3x3_init(struct drm_device *dev, struct drm_colorop *colorop, + struct drm_plane *plane, bool allow_bypass); int drm_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop, struct drm_plane *plane, bool allow_bypass); int drm_colorop_mult_init(struct drm_device *dev, struct drm_colorop *colorop, diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index 316c643e0dea..c47788dc84c8 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -905,6 +905,14 @@ enum drm_colorop_type { */ DRM_COLOROP_CTM_3X4, + /** + * @DRM_COLOROP_CTM_3X3: + * + * A 3x3 matrix. Its values are specified via the + * &drm_color_ctm struct provided via the DATA property. + */ + DRM_COLOROP_CTM_3X3, + /** * @DRM_COLOROP_MULTIPLIER: * -- 2.42.0