Skip to content

Commit 86441c2

Browse files
committed
drm/i915/color: Create a transfer function color pipeline
Add a color pipeline with three colorops in the sequence 1D LUT MULTSEG - CTM - 1D LUT MULTSEG This pipeline can be used to do any color space conversion or HDR tone mapping Signed-off-by: Uma Shankar <uma.shankar@intel.com> Signed-off-by: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>
1 parent f174545 commit 86441c2

File tree

Image for: File tree

2 files changed

Image for: 2 files changed
+149
-0
lines changed

2 files changed

Image for: 2 files changed
+149
-0
lines changed

‎drivers/gpu/drm/i915/display/intel_color.c

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "intel_de.h"
2929
#include "intel_display_types.h"
3030
#include "intel_dsb.h"
31+
#include "skl_universal_plane.h"
3132

3233
struct intel_color_funcs {
3334
int (*color_check)(struct intel_crtc_state *crtc_state);
@@ -3810,6 +3811,105 @@ static const struct intel_color_funcs ilk_color_funcs = {
38103811
.get_config = ilk_get_config,
38113812
};
38123813

3814+
static const struct drm_color_lut_range xelpd_degamma_hdr[] = {
3815+
/* segment 1 */
3816+
{
3817+
.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
3818+
DRM_MODE_LUT_INTERPOLATE |
3819+
DRM_MODE_LUT_NON_DECREASING),
3820+
.count = 128,
3821+
.input_bpc = 24, .output_bpc = 16,
3822+
.start = 0, .end = (1 << 24) - 1,
3823+
.min = 0, .max = (1 << 24) - 1,
3824+
},
3825+
/* segment 2 */
3826+
{
3827+
.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
3828+
DRM_MODE_LUT_INTERPOLATE |
3829+
DRM_MODE_LUT_REUSE_LAST |
3830+
DRM_MODE_LUT_NON_DECREASING),
3831+
.count = 1,
3832+
.input_bpc = 24, .output_bpc = 16,
3833+
.start = (1 << 24) - 1, .end = 1 << 24,
3834+
.min = 0, .max = (1 << 27) - 1,
3835+
},
3836+
/* Segment 3 */
3837+
{
3838+
.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
3839+
DRM_MODE_LUT_INTERPOLATE |
3840+
DRM_MODE_LUT_REUSE_LAST |
3841+
DRM_MODE_LUT_NON_DECREASING),
3842+
.count = 1,
3843+
.input_bpc = 24, .output_bpc = 16,
3844+
.start = 1 << 24, .end = 3 << 24,
3845+
.min = 0, .max = (1 << 27) - 1,
3846+
},
3847+
/* Segment 4 */
3848+
{
3849+
.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
3850+
DRM_MODE_LUT_INTERPOLATE |
3851+
DRM_MODE_LUT_REUSE_LAST |
3852+
DRM_MODE_LUT_NON_DECREASING),
3853+
.count = 1,
3854+
.input_bpc = 24, .output_bpc = 16,
3855+
.start = 3 << 24, .end = 7 << 24,
3856+
.min = 0, .max = (1 << 27) - 1,
3857+
}
3858+
};
3859+
3860+
/* FIXME input bpc? */
3861+
static const struct drm_color_lut_range xelpd_gamma_hdr[] = {
3862+
/*
3863+
* ToDo: Add Segment 1
3864+
* There is an optional fine segment added with 9 lut values
3865+
* Will be added later
3866+
*/
3867+
3868+
/* segment 2 */
3869+
{
3870+
.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
3871+
DRM_MODE_LUT_INTERPOLATE |
3872+
DRM_MODE_LUT_NON_DECREASING),
3873+
.count = 32,
3874+
.input_bpc = 24, .output_bpc = 16,
3875+
.start = 0, .end = (1 << 24) - 1,
3876+
.min = 0, .max = (1 << 24) - 1,
3877+
},
3878+
/* segment 3 */
3879+
{
3880+
.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
3881+
DRM_MODE_LUT_INTERPOLATE |
3882+
DRM_MODE_LUT_REUSE_LAST |
3883+
DRM_MODE_LUT_NON_DECREASING),
3884+
.count = 1,
3885+
.input_bpc = 24, .output_bpc = 16,
3886+
.start = (1 << 24) - 1, .end = 1 << 24,
3887+
.min = 0, .max = 1 << 24,
3888+
},
3889+
/* Segment 4 */
3890+
{
3891+
.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
3892+
DRM_MODE_LUT_INTERPOLATE |
3893+
DRM_MODE_LUT_REUSE_LAST |
3894+
DRM_MODE_LUT_NON_DECREASING),
3895+
.count = 1,
3896+
.input_bpc = 24, .output_bpc = 16,
3897+
.start = 1 << 24, .end = 3 << 24,
3898+
.min = 0, .max = (3 << 24),
3899+
},
3900+
/* Segment 5 */
3901+
{
3902+
.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
3903+
DRM_MODE_LUT_INTERPOLATE |
3904+
DRM_MODE_LUT_REUSE_LAST |
3905+
DRM_MODE_LUT_NON_DECREASING),
3906+
.count = 1,
3907+
.input_bpc = 24, .output_bpc = 16,
3908+
.start = 3 << 24, .end = 7 << 24,
3909+
.min = 0, .max = (7 << 24),
3910+
},
3911+
};
3912+
38133913
/* TODO: Move to another file */
38143914
struct intel_plane_colorop *intel_colorop_alloc(void)
38153915
{
@@ -3849,6 +3949,52 @@ struct intel_plane_colorop *intel_plane_colorop_create(enum intel_color_block id
38493949
return colorop;
38503950
}
38513951

3952+
int intel_plane_tf_pipeline_init(struct drm_plane *plane, struct drm_prop_enum_list *list)
3953+
{
3954+
struct intel_plane_colorop *colorop;
3955+
struct drm_device *dev = plane->dev;
3956+
struct drm_i915_private *i915 = to_i915(dev);
3957+
int ret;
3958+
struct drm_colorop *prev_op;
3959+
3960+
/* Currently expose pipeline only for HDR planes*/
3961+
if (!icl_is_hdr_plane(i915, to_intel_plane(plane)->id))
3962+
return 0;
3963+
3964+
colorop = intel_plane_colorop_create(CB_PLANE_PRE_CSC_LUT);
3965+
3966+
ret = drm_colorop_curve_1d_lut_multseg_init(dev, &colorop->base,
3967+
plane, xelpd_degamma_hdr,
3968+
sizeof(xelpd_degamma_hdr));
3969+
if (ret)
3970+
return ret;
3971+
3972+
list->type = colorop->base.base.id;
3973+
list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", colorop->base.base.id);
3974+
3975+
/* TODO: handle failures and clean up*/
3976+
prev_op = &colorop->base;
3977+
3978+
colorop = intel_plane_colorop_create(CB_PLANE_CSC);
3979+
ret = drm_colorop_ctm_3x3_init(dev, &colorop->base,plane);
3980+
if (ret)
3981+
return ret;
3982+
3983+
drm_colorop_set_next_property(prev_op, &colorop->base);
3984+
prev_op = &colorop->base;
3985+
3986+
colorop = intel_plane_colorop_create(CB_PLANE_POST_CSC_LUT);
3987+
ret = drm_colorop_curve_1d_lut_multseg_init(dev, &colorop->base,
3988+
plane, xelpd_gamma_hdr,
3989+
sizeof(xelpd_gamma_hdr));
3990+
if (ret)
3991+
return ret;
3992+
3993+
drm_colorop_set_next_property(prev_op, &colorop->base);
3994+
3995+
return 0;
3996+
}
3997+
38523998
void intel_color_crtc_init(struct intel_crtc *crtc)
38533999
{
38544000
struct drm_i915_private *i915 = to_i915(crtc->base.dev);

‎drivers/gpu/drm/i915/display/intel_color.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ struct intel_crtc_state;
1212
struct intel_crtc;
1313
struct drm_i915_private;
1414
struct drm_property_blob;
15+
struct drm_plane;
16+
struct drm_prop_enum_list;
1517
enum intel_color_block;
1618

1719
void intel_color_init_hooks(struct drm_i915_private *i915);
@@ -34,5 +36,6 @@ bool intel_color_lut_equal(const struct intel_crtc_state *crtc_state,
3436
void intel_color_assert_luts(const struct intel_crtc_state *crtc_state);
3537
struct intel_plane_colorop *intel_colorop_alloc(void);
3638
struct intel_plane_colorop *intel_plane_colorop_create(enum intel_color_block id);
39+
int intel_plane_tf_pipeline_init(struct drm_plane *plane, struct drm_prop_enum_list *list);
3740

3841
#endif /* __INTEL_COLOR_H__ */

0 commit comments

Image for: 0 commit comments
Comments
 (0)