Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915/color: Create a transfer function color pipeline

Add a color pipeline with three colorops in the sequence

1D LUT - 3x4 CTM - 1D LUT

This pipeline can be used to do any color space conversion or HDR
tone mapping

v2: Change namespace to drm_plane_colorop*
v3: Use simpler/pre-existing colorops for first iteration
v4:
- s/*_tf_*/*_color_* (Jani)
- Refactor to separate files (Jani)
- Add missing space in comment (Suraj)
- Consolidate patch that adds/attaches pipeline property
v5:
- Limit MAX_COLOR_PIPELINES to 2.(Suraj)
Increase it as and when we add more pipelines.
- Remove redundant initialization code (Suraj)
v6:
- Use drm_plane_create_color_pipeline_property() (Arun)
Now MAX_COLOR_PIPELINES is 1

Reviewed-by: Suraj Kandpal <suraj.kandpal@intel.com>
Signed-off-by: Uma Shankar <uma.shankar@intel.com>
Signed-off-by: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>
Link: https://patch.msgid.link/20251203085211.3663374-5-uma.shankar@intel.com
Signed-off-by: Jani Nikula <jani.nikula@intel.com>

authored by

Chaitanya Kumar Borah and committed by
Jani Nikula
ef105316 730df506

+95
+1
drivers/gpu/drm/i915/Makefile
··· 240 240 display/intel_cmtg.o \ 241 241 display/intel_color.o \ 242 242 display/intel_colorop.o \ 243 + display/intel_color_pipeline.o \ 243 244 display/intel_combo_phy.o \ 244 245 display/intel_connector.o \ 245 246 display/intel_crtc.o \
+80
drivers/gpu/drm/i915/display/intel_color_pipeline.c
··· 1 + // SPDX-License-Identifier: MIT 2 + /* 3 + * Copyright © 2025 Intel Corporation 4 + */ 5 + #include "intel_colorop.h" 6 + #include "intel_color_pipeline.h" 7 + #include "intel_de.h" 8 + #include "intel_display_types.h" 9 + #include "skl_universal_plane.h" 10 + 11 + #define MAX_COLOR_PIPELINES 1 12 + #define PLANE_DEGAMMA_SIZE 128 13 + #define PLANE_GAMMA_SIZE 32 14 + 15 + static 16 + int _intel_color_pipeline_plane_init(struct drm_plane *plane, struct drm_prop_enum_list *list) 17 + { 18 + struct intel_colorop *colorop; 19 + struct drm_device *dev = plane->dev; 20 + int ret; 21 + struct drm_colorop *prev_op; 22 + 23 + colorop = intel_colorop_create(INTEL_PLANE_CB_PRE_CSC_LUT); 24 + 25 + ret = drm_plane_colorop_curve_1d_lut_init(dev, &colorop->base, plane, 26 + PLANE_DEGAMMA_SIZE, 27 + DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR, 28 + DRM_COLOROP_FLAG_ALLOW_BYPASS); 29 + 30 + if (ret) 31 + return ret; 32 + 33 + list->type = colorop->base.base.id; 34 + list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", colorop->base.base.id); 35 + 36 + /* TODO: handle failures and clean up */ 37 + prev_op = &colorop->base; 38 + 39 + colorop = intel_colorop_create(INTEL_PLANE_CB_CSC); 40 + ret = drm_plane_colorop_ctm_3x4_init(dev, &colorop->base, plane, 41 + DRM_COLOROP_FLAG_ALLOW_BYPASS); 42 + if (ret) 43 + return ret; 44 + 45 + drm_colorop_set_next_property(prev_op, &colorop->base); 46 + prev_op = &colorop->base; 47 + 48 + colorop = intel_colorop_create(INTEL_PLANE_CB_POST_CSC_LUT); 49 + ret = drm_plane_colorop_curve_1d_lut_init(dev, &colorop->base, plane, 50 + PLANE_GAMMA_SIZE, 51 + DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR, 52 + DRM_COLOROP_FLAG_ALLOW_BYPASS); 53 + if (ret) 54 + return ret; 55 + 56 + drm_colorop_set_next_property(prev_op, &colorop->base); 57 + 58 + return 0; 59 + } 60 + 61 + int intel_color_pipeline_plane_init(struct drm_plane *plane) 62 + { 63 + struct drm_device *dev = plane->dev; 64 + struct intel_display *display = to_intel_display(dev); 65 + struct drm_prop_enum_list pipelines[MAX_COLOR_PIPELINES]; 66 + int len = 0; 67 + int ret; 68 + 69 + /* Currently expose pipeline only for HDR planes */ 70 + if (!icl_is_hdr_plane(display, to_intel_plane(plane)->id)) 71 + return 0; 72 + 73 + /* Add pipeline consisting of transfer functions */ 74 + ret = _intel_color_pipeline_plane_init(plane, &pipelines[len]); 75 + if (ret) 76 + return ret; 77 + len++; 78 + 79 + return drm_plane_create_color_pipeline_property(plane, pipelines, len); 80 + }
+13
drivers/gpu/drm/i915/display/intel_color_pipeline.h
··· 1 + /* SPDX-License-Identifier: MIT */ 2 + /* 3 + * Copyright © 2025 Intel Corporation 4 + */ 5 + 6 + #ifndef __INTEL_COLOR_PIPELINE_H__ 7 + #define __INTEL_COLOR_PIPELINE_H__ 8 + 9 + struct drm_plane; 10 + 11 + int intel_color_pipeline_plane_init(struct drm_plane *plane); 12 + 13 + #endif /* __INTEL_COLOR_PIPELINE_H__ */
+1
drivers/gpu/drm/xe/Makefile
··· 243 243 i915-display/intel_cmtg.o \ 244 244 i915-display/intel_color.o \ 245 245 i915-display/intel_colorop.o \ 246 + i915-display/intel_color_pipeline.o \ 246 247 i915-display/intel_combo_phy.o \ 247 248 i915-display/intel_connector.o \ 248 249 i915-display/intel_crtc.o \