Skip to contentSkip to conversation

drm/vkms: Add gamma 2.2 and 2.4 1D curve colorops

PATCH New Robert Mader 3 participants 9 messages Dec 4 – Dec 5

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover drm/vkms: Add gamma 2.2 and 2.4 1D curve colorops

This series implements two LUTs that are typically used for SDR content and falls into the context of pre- and post-blend pipelines.

It depends on the first commit of
https://lore.kernel.org/dri-devel/[email protected]/
and is implemented in the following Weston MR:
https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/2157

In that MR the curves are further tested to match the corresponding Weston GL implementations.

Changes in v2:
- Avoid overflow in test
- Fix wrong values in gamma22_inv_eotf

Robert Mader (4):
drm/vkms: Fix inverse lut naming scheme in script drm/vkms: Make LUT test reusable
drm/vkms: Add support for DRM_COLOROP_1D_CURVE_GAMMA22 drm/vkms: Add support for DRM_COLOROP_1D_CURVE_GAMMA24

 .../gpu/drm/vkms/scripts/color-curve-lut.py   |   40 +-
 drivers/gpu/drm/vkms/tests/vkms_color_test.c  |   44 +-
 drivers/gpu/drm/vkms/vkms_colorop.c           |    6 +-
 drivers/gpu/drm/vkms/vkms_composer.c          |   26 +
 drivers/gpu/drm/vkms/vkms_luts.c              | 1607 +++++++++++++++++
 drivers/gpu/drm/vkms/vkms_luts.h              |    4 +
 6 files changed, 1704 insertions(+), 23 deletions(-)
Signature · 1 line
2.56.1
#1 lore raw

PATCH v2 1/4 drm/vkms: Fix inverse lut naming scheme in script

We went with in srgb_inv instead of inv_srgb in commit 3c7c3c12dfc7 ("drm/vkms: replace uniform sRGB LUT and its inverse with optimal ones") thus adopt the script to reflect that.

Fixes e64f6256cd12 ("drm/vkms: add script to create optimized LUTs for color curves")
---
 .../gpu/drm/vkms/scripts/color-curve-lut.py   | 22 +++++++++----------
 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/gpu/drm/vkms/scripts/color-curve-lut.py +11 -11
index c8f13643bdb7..6a1fa804d16f 100644
@@ -371,7 +371,7 @@ class Functions:
         return pow(x, 2.2)
 
     @staticmethod
-    def inv_pow22(x):
+    def pow22_inv(x):
         return pow(x, 1.0 / 2.2)
 
     @staticmethod
@@ -381,7 +381,7 @@ class Functions:
         return pow(((x + 0.055) / 1.055), 2.4)
 
     @staticmethod
-    def inv_srgb(x):
+    def srgb_inv(x):
         if x <= 0.0031308:
             return 12.92 * x
         return 1.055 * pow(x, (1.0 / 2.4)) - 0.055
@@ -397,7 +397,7 @@ class Functions:
         return pow(max(aux - c1, 0.0) / (c2 - c3 * aux), m1_inv)
 
     @staticmethod
-    def inv_pq(x):
+    def pq_inv(x):
         m1 = 0.1593017578125
         m2 = 78.84375
         c1 = 0.8359375
@@ -414,7 +414,7 @@ class Functions:
         return a * (pow(x, 0.45)) - (a - 1.0)
 
     @staticmethod
-    def inv_bt2020_oetf(x):
+    def bt2020_oetf_inv(x):
         a = 1.0993
         if x < 0.081:
             return x / 4.5
@@ -472,7 +472,7 @@ def print_help_and_quit(function_table):
     print("Possible function names are:")
     for func in function_table.keys():
         print(f"  {func}")
-        print(f"  inv_{func}")
+        print(f"  {func}_inv")
     sys.exit(1)
 
 
@@ -491,8 +491,8 @@ def parse_cli_params(args, function_table):
         plot = True
 
     func_str = args[1]
-    use_inverse = func_str.startswith("inv_")
-    base_func_str = func_str[4:] if use_inverse else func_str
+    use_inverse = func_str.endswith("_inv")
+    base_func_str = func_str[:-4] if use_inverse else func_str
 
     func_pair = function_table.get(base_func_str)
     if func_pair is None:
@@ -517,10 +517,10 @@ def parse_cli_params(args, function_table):
 
 def main(args):
     function_table = {
-        "srgb": (Functions.srgb, Functions.inv_srgb),
-        "pow22": (Functions.pow22, Functions.inv_pow22),
-        "pq": (Functions.pq, Functions.inv_pq),
-        "bt2020_oetf": (Functions.bt2020_oetf, Functions.inv_bt2020_oetf),
+        "srgb": (Functions.srgb, Functions.srgb_inv),
+        "pow22": (Functions.pow22, Functions.pow22_inv),
+        "pq": (Functions.pq, Functions.pq_inv),
+        "bt2020_oetf": (Functions.bt2020_oetf, Functions.bt2020_oetf_inv),
     }
 
     func_str, func_pair, lut_size, plot = parse_cli_params(args, function_table)
Signature · 1 line
2.56.1
#2 lore raw

PATCH v2 2/4 drm/vkms: Make LUT test reusable

In reply to Robert Mader

Factor out the logic so we can reuse it for other LUTs and, While on it, add an average error which will become useful in follow-up commits.

---
 drivers/gpu/drm/vkms/tests/vkms_color_test.c | 32 +++++++++++++++-----
 1 file changed, 24 insertions(+), 8 deletions(-)
drivers/gpu/drm/vkms/tests/vkms_color_test.c +24 -8
index c3c61037cb71..c031718b0a41 100644
@@ -120,20 +120,36 @@ static void vkms_color_test_linear(struct kunit *test)
 	}
 }
 
-static void vkms_color_srgb_inv_srgb(struct kunit *test)
+static void vkms_color_test_inv_lut(struct kunit *test,
+				    const struct vkms_color_lut *lut,
+				    const struct vkms_color_lut *inv_lut,
+				    u16 tolerance_max,
+				    u16 tolerance_avg)
 {
-	u16 srgb, final;
-	u16 tolerance = 11;
-	u32 x;
+	u32 sum = 0;
+	u16 count = 0;
 
 	for (u32 i = 0; i <= 4095; i++) {
+		u16 tmp, final;
+		u32 x;
+
 		x = i * U16_MAX / 4095;
-		srgb = apply_lut_to_channel_value(&srgb_eotf, x, LUT_RED);
-		final = apply_lut_to_channel_value(&srgb_inv_eotf, srgb, LUT_RED);
+		tmp = apply_lut_to_channel_value(lut, x, LUT_RED);
+		final = apply_lut_to_channel_value(inv_lut, tmp, LUT_RED);
 
-		KUNIT_EXPECT_GE(test, final, (int)x - tolerance);
-		KUNIT_EXPECT_LE(test, final, (int)x + tolerance);
+		KUNIT_EXPECT_GE(test, final, (int)x - tolerance_max);
+		KUNIT_EXPECT_LE(test, final, (int)x + tolerance_max);
+
+		sum += abs((int)x - final);
+		count++;
 	}
+
+	KUNIT_EXPECT_LE(test, sum / count, tolerance_avg);
+}
+
+static void vkms_color_srgb_inv_srgb(struct kunit *test)
+{
+	vkms_color_test_inv_lut(test, &srgb_eotf, &srgb_inv_eotf, 11, 0);
 }
 
 #define FIXPT_HALF        (DRM_FIXED_ONE >> 1)
Signature · 1 line
2.56.1
#3 lore raw

PATCH v2 3/4 drm/vkms: Add support for DRM_COLOROP_1D_CURVE_GAMMA22

In reply to Robert Mader

And its inverse, using the pow22 function from the script with the suggested sizes from the top comment.

The Gamma 2.2 EOTF is what Wayland compositors like Weston implicitly assume for SDR content and thus important for the colorop transition.

---
 drivers/gpu/drm/vkms/tests/vkms_color_test.c |   6 +
 drivers/gpu/drm/vkms/vkms_colorop.c          |   4 +-
 drivers/gpu/drm/vkms/vkms_composer.c         |  13 +
 drivers/gpu/drm/vkms/vkms_luts.c             | 753 +++++++++++++++++++
 drivers/gpu/drm/vkms/vkms_luts.h             |   2 +
 5 files changed, 777 insertions(+), 1 deletion(-)
drivers/gpu/drm/vkms/tests/vkms_color_test.c +6 -0
index c031718b0a41..55b87fd248a7 100644
@@ -152,6 +152,11 @@ static void vkms_color_srgb_inv_srgb(struct kunit *test)
 	vkms_color_test_inv_lut(test, &srgb_eotf, &srgb_inv_eotf, 11, 0);
 }
 
+static void vkms_color_gamma22_inv_gamma22(struct kunit *test)
+{
+	vkms_color_test_inv_lut(test, &gamma22_eotf, &gamma22_inv_eotf, 304, 2);
+}
+
 #define FIXPT_HALF        (DRM_FIXED_ONE >> 1)
 #define FIXPT_QUARTER     (DRM_FIXED_ONE >> 2)
 
@@ -402,6 +407,7 @@ static struct kunit_case vkms_color_test_cases[] = {
 	KUNIT_CASE(vkms_color_test_lerp),
 	KUNIT_CASE(vkms_color_test_linear),
 	KUNIT_CASE(vkms_color_srgb_inv_srgb),
+	KUNIT_CASE(vkms_color_gamma22_inv_gamma22),
 	KUNIT_CASE(vkms_color_ctm_3x4_50_desat),
 	KUNIT_CASE(vkms_color_ctm_3x4_bt709),
 	{}
drivers/gpu/drm/vkms/vkms_colorop.c +3 -1
index 9424b1994239..625a590c6a2f 100644
@@ -10,7 +10,9 @@
 
 static const u64 supported_tfs =
 	BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF) |
-	BIT(DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF);
+	BIT(DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF) |
+	BIT(DRM_COLOROP_1D_CURVE_GAMMA22) |
+	BIT(DRM_COLOROP_1D_CURVE_GAMMA22_INV);
 
 static const u64 supported_fm =
 	BIT(DRM_COLOROP_FM_YCBCR601_FULL_RGB) |
drivers/gpu/drm/vkms/vkms_composer.c +13 -0
index 7a6a7875520c..8eaad80ad469 100644
@@ -264,6 +264,19 @@ static void apply_colorop(struct pixel_argb_s32 *pixel, struct drm_colorop *colo
 			pixel->g = apply_lut_to_channel_value(&srgb_eotf, pixel->g, LUT_GREEN);
 			pixel->b = apply_lut_to_channel_value(&srgb_eotf, pixel->b, LUT_BLUE);
 			break;
+		case DRM_COLOROP_1D_CURVE_GAMMA22:
+			pixel->r = apply_lut_to_channel_value(&gamma22_eotf, pixel->r, LUT_RED);
+			pixel->g = apply_lut_to_channel_value(&gamma22_eotf, pixel->g, LUT_GREEN);
+			pixel->b = apply_lut_to_channel_value(&gamma22_eotf, pixel->b, LUT_BLUE);
+			break;
+		case DRM_COLOROP_1D_CURVE_GAMMA22_INV:
+			pixel->r = apply_lut_to_channel_value(&gamma22_inv_eotf, pixel->r,
+							      LUT_RED);
+			pixel->g = apply_lut_to_channel_value(&gamma22_inv_eotf, pixel->g,
+							      LUT_GREEN);
+			pixel->b = apply_lut_to_channel_value(&gamma22_inv_eotf, pixel->b,
+							      LUT_BLUE);
+			break;
 		default:
 			drm_WARN_ONCE(dev, true,
 				      "unknown colorop 1D curve type %d\n",
drivers/gpu/drm/vkms/vkms_luts.c +753 -0

756 lines not on this page · raw message

drivers/gpu/drm/vkms/vkms_luts.h +2 -0
index 655e9553cd91..709ce12c8471 100644
@@ -5,5 +5,7 @@
 
 extern const struct vkms_color_lut srgb_eotf;
 extern const struct vkms_color_lut srgb_inv_eotf;
+extern const struct vkms_color_lut gamma22_eotf;
+extern const struct vkms_color_lut gamma22_inv_eotf;
 
 #endif /* _VKMS_LUTS_H_ */
Signature · 1 line
2.56.1
#4 lore raw

Re: [PATCH v2 3/4] drm/vkms: Add support for DRM_COLOROP_1D_CURVE_GAMMA22

Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] drm/vkms: unclamped s32-to-u16 wraparound in apply_colorop() 1D curve LUTs - [Low] drm/vkms…

Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Medium] drm/vkms: unclamped s32-to-u16 wraparound in apply_colorop() 1D curve LUTs
- [Low] drm/vkms: globally export KUnit-only gamma22 LUTs via EXPORT_SYMBOL()
--

commit b0ad0319d06f1020df30009f35dd9bb1429d38fb
Author: Robert Mader <[email protected]>

drm/vkms: Add support for DRM_COLOROP_1D_CURVE_GAMMA22

This commit adds non-uniform LUTs and colorop handling for the Gamma 2.2 EOTF and its inverse, along with a KUnit round-trip test.

Quoted 11 lines
drivers/gpu/drm/vkms/vkms_composer.c +3 -0
index 7a6a7875520ca..8eaad80ad4697 100644
@@ -264,6 +264,19 @@ static void apply_colorop(struct pixel_argb_s32 *pixel, struct drm_colorop *colo
 			pixel->g = apply_lut_to_channel_value(&srgb_eotf, pixel->g, LUT_GREEN);
 			pixel->b = apply_lut_to_channel_value(&srgb_eotf, pixel->b, LUT_BLUE);
 			break;
+		case DRM_COLOROP_1D_CURVE_GAMMA22:
+			pixel->r = apply_lut_to_channel_value(&gamma22_eotf, pixel->r, LUT_RED);
+			pixel->g = apply_lut_to_channel_value(&gamma22_eotf, pixel->g, LUT_GREEN);

drivers/gpu/drm/vkms/vkms_composer.c static void apply_colorop(struct pixel_argb_s32 *pixel, struct drm_colorop *colo · line 279

Quoted 10 lines
drivers/gpu/drm/vkms/vkms_composer.c +10 -0
+			pixel->b = apply_lut_to_channel_value(&gamma22_eotf, pixel->b, LUT_BLUE);
+			break;
+		case DRM_COLOROP_1D_CURVE_GAMMA22_INV:
+			pixel->r = apply_lut_to_channel_value(&gamma22_inv_eotf, pixel->r,
+							      LUT_RED);
+			pixel->g = apply_lut_to_channel_value(&gamma22_inv_eotf, pixel->g,
+							      LUT_GREEN);
+			pixel->b = apply_lut_to_channel_value(&gamma22_inv_eotf, pixel->b,
+							      LUT_BLUE);
+			break;

[Severity: Medium]
Can passing pixel->r, pixel->g, and pixel->b directly to apply_lut_to_channel_value() wrap out-of-range values modulo 65536?

pre_blend_color_transform() runs the pipeline in struct pixel_argb_s32 and only clamps channels to [0, 0xffff] after all colorops finish. Because vkms_initialize_color_pipeline() places a 1D curve stage after the 3x4 CTM stages, out-of-range CTM outputs reach this lookup as unclamped s32 values.

Since apply_lut_to_channel_value() takes a u16 channel_value, implicit narrowing turns -1 into 0xffff and 0x10000 into 0x0000, corrupting rendered pixels and CRCs. Clamping to [0, 0xffff] before the lookup avoids this.

[ ... ]

Quoted 4 lines
drivers/gpu/drm/vkms/vkms_luts.c +0 -0
index 4b766ae7c1254..5778226fc290f 100644

[ ... ]

Quoted 6 lines
drivers/gpu/drm/vkms/vkms_luts.c +6 -0
+const struct vkms_color_lut gamma22_eotf = {
+	.x = pow22_x,
+	.y = pow22_y,
+	.lut_length = ARRAY_SIZE(pow22_y)
+};
+EXPORT_SYMBOL(gamma22_eotf);

[ ... ]

drivers/gpu/drm/vkms/vkms_luts.c const struct vkms_color_lut srgb_inv_eotf = { · line 1461

Quoted 6 lines
drivers/gpu/drm/vkms/vkms_luts.c +6 -0
+const struct vkms_color_lut gamma22_inv_eotf = {
+	.x = pow22_inv_x,
+	.y = pow22_inv_y,
+	.lut_length = ARRAY_SIZE(pow22_inv_y)
+};
+EXPORT_SYMBOL(gamma22_inv_eotf);

[Severity: Low]
Should gamma22_eotf and gamma22_inv_eotf use EXPORT_SYMBOL_IF_KUNIT() instead of EXPORT_SYMBOL()?

vkms_luts.o is linked into vkms.o with vkms_composer.o, so the only external user is vkms_color_test.c, which already imports the EXPORTED_FOR_KUNIT_TESTING namespace. EXPORT_SYMBOL() exports these unprefixed names globally even without KUnit, risking symbol collisions.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
#5 lore raw

PATCH v2 4/4 drm/vkms: Add support for DRM_COLOROP_1D_CURVE_GAMMA24

In reply to Robert Mader

And its inverse. The sizes where determined to match the max error of the already existing functions, rounded to up to the next decimal value.

The Gamma 2.4 EOTF is typically used for SDR video content.

See
https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/539
for more context.

---
 .../gpu/drm/vkms/scripts/color-curve-lut.py   |  18 +-
 drivers/gpu/drm/vkms/tests/vkms_color_test.c  |   6 +
 drivers/gpu/drm/vkms/vkms_colorop.c           |   4 +-
 drivers/gpu/drm/vkms/vkms_composer.c          |  13 +
 drivers/gpu/drm/vkms/vkms_luts.c              | 854 ++++++++++++++++++
 drivers/gpu/drm/vkms/vkms_luts.h              |   2 +
 6 files changed, 893 insertions(+), 4 deletions(-)
drivers/gpu/drm/vkms/scripts/color-curve-lut.py +15 -3
index 6a1fa804d16f..e2a13cd0f7fe 100644
@@ -61,6 +61,8 @@ Function               LUT size   Max error
 ----------------------------------------------
 pow 2.2                270        9.320331e-06
 inverse pow 2.2        370        1.056258e-05
+pow 2.4                270        9.537672e-06
+inverse pow 2.4        460        1.071102e-05
 piece-wise sRGB        260        9.298192e-06
 inv piece-wise sRGB    330        1.001394e-05
 PQ                     380        9.159226e-06
@@ -69,9 +71,10 @@ BT.2020 OETF           270        9.762646e-06
 inv BT.2020 OETF       240        9.924004e-06
 ----------------------------------------------
 
-Note: inverse pow 2.2 and inverse piece-wise sRGB LUTs stopped improving with
-fewer taps than inverse PQ, but their max_error didn't drop below 10^-5, even
-with very large LUTs. This can be attributed to quantization error.
+Note: inverse pow 2.2, inverse pow 2.4 and inverse piece-wise sRGB LUTs stopped
+improving with fewer taps than inverse PQ, but their max_error didn't drop
+below 10^-5, even with very large LUTs. This can be attributed to quantization
+error.
 """
 
 import sys
@@ -374,6 +377,14 @@ class Functions:
     def pow22_inv(x):
         return pow(x, 1.0 / 2.2)
 
+    @staticmethod
+    def pow24(x):
+        return pow(x, 2.4)
+
+    @staticmethod
+    def pow24_inv(x):
+        return pow(x, 1.0 / 2.4)
+
     @staticmethod
     def srgb(x):
         if x <= 0.04045:
@@ -519,6 +530,7 @@ def main(args):
     function_table = {
         "srgb": (Functions.srgb, Functions.srgb_inv),
         "pow22": (Functions.pow22, Functions.pow22_inv),
+        "pow24": (Functions.pow24, Functions.pow24_inv),
         "pq": (Functions.pq, Functions.pq_inv),
         "bt2020_oetf": (Functions.bt2020_oetf, Functions.bt2020_oetf_inv),
     }
drivers/gpu/drm/vkms/tests/vkms_color_test.c +6 -0
index 55b87fd248a7..06be974de741 100644
@@ -157,6 +157,11 @@ static void vkms_color_gamma22_inv_gamma22(struct kunit *test)
 	vkms_color_test_inv_lut(test, &gamma22_eotf, &gamma22_inv_eotf, 304, 2);
 }
 
+static void vkms_color_gamma24_inv_gamma24(struct kunit *test)
+{
+	vkms_color_test_inv_lut(test, &gamma24_eotf, &gamma24_inv_eotf, 389, 3);
+}
+
 #define FIXPT_HALF        (DRM_FIXED_ONE >> 1)
 #define FIXPT_QUARTER     (DRM_FIXED_ONE >> 2)
 
@@ -408,6 +413,7 @@ static struct kunit_case vkms_color_test_cases[] = {
 	KUNIT_CASE(vkms_color_test_linear),
 	KUNIT_CASE(vkms_color_srgb_inv_srgb),
 	KUNIT_CASE(vkms_color_gamma22_inv_gamma22),
+	KUNIT_CASE(vkms_color_gamma24_inv_gamma24),
 	KUNIT_CASE(vkms_color_ctm_3x4_50_desat),
 	KUNIT_CASE(vkms_color_ctm_3x4_bt709),
 	{}
drivers/gpu/drm/vkms/vkms_colorop.c +3 -1
index 625a590c6a2f..db16d7e2a42f 100644
@@ -12,7 +12,9 @@ static const u64 supported_tfs =
 	BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF) |
 	BIT(DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF) |
 	BIT(DRM_COLOROP_1D_CURVE_GAMMA22) |
-	BIT(DRM_COLOROP_1D_CURVE_GAMMA22_INV);
+	BIT(DRM_COLOROP_1D_CURVE_GAMMA22_INV) |
+	BIT(DRM_COLOROP_1D_CURVE_GAMMA24) |
+	BIT(DRM_COLOROP_1D_CURVE_GAMMA24_INV);
 
 static const u64 supported_fm =
 	BIT(DRM_COLOROP_FM_YCBCR601_FULL_RGB) |
drivers/gpu/drm/vkms/vkms_composer.c +13 -0
index 8eaad80ad469..184ca8040f9e 100644
@@ -277,6 +277,19 @@ static void apply_colorop(struct pixel_argb_s32 *pixel, struct drm_colorop *colo
 			pixel->b = apply_lut_to_channel_value(&gamma22_inv_eotf, pixel->b,
 							      LUT_BLUE);
 			break;
+		case DRM_COLOROP_1D_CURVE_GAMMA24:
+			pixel->r = apply_lut_to_channel_value(&gamma24_eotf, pixel->r, LUT_RED);
+			pixel->g = apply_lut_to_channel_value(&gamma24_eotf, pixel->g, LUT_GREEN);
+			pixel->b = apply_lut_to_channel_value(&gamma24_eotf, pixel->b, LUT_BLUE);
+			break;
+		case DRM_COLOROP_1D_CURVE_GAMMA24_INV:
+			pixel->r = apply_lut_to_channel_value(&gamma24_inv_eotf, pixel->r,
+							      LUT_RED);
+			pixel->g = apply_lut_to_channel_value(&gamma24_inv_eotf, pixel->g,
+							      LUT_GREEN);
+			pixel->b = apply_lut_to_channel_value(&gamma24_inv_eotf, pixel->b,
+							      LUT_BLUE);
+			break;
 		default:
 			drm_WARN_ONCE(dev, true,
 				      "unknown colorop 1D curve type %d\n",
drivers/gpu/drm/vkms/vkms_luts.c +854 -0

857 lines not on this page · raw message

drivers/gpu/drm/vkms/vkms_luts.h +2 -0
index 709ce12c8471..698b729e125c 100644
@@ -7,5 +7,7 @@ extern const struct vkms_color_lut srgb_eotf;
 extern const struct vkms_color_lut srgb_inv_eotf;
 extern const struct vkms_color_lut gamma22_eotf;
 extern const struct vkms_color_lut gamma22_inv_eotf;
+extern const struct vkms_color_lut gamma24_eotf;
+extern const struct vkms_color_lut gamma24_inv_eotf;
 
 #endif /* _VKMS_LUTS_H_ */
Signature · 1 line
2.56.1
#6 lore raw

Re: [PATCH v2 4/4] drm/vkms: Add support for DRM_COLOROP_1D_CURVE_GAMMA24

Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] drm/vkms: undeclared DRM_COLOROP_1D_CURVE_GAMMA24 constants break build - [Low] drm/vkms…

Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [High] drm/vkms: undeclared DRM_COLOROP_1D_CURVE_GAMMA24 constants break build
- [Low] drm/vkms: unconditional EXPORT_SYMBOL() for KUnit-only Gamma 2.4 LUTs
--

commit b3b9cea1bd79f0143afef4e7f802c85dcba7344f
Author: Robert Mader <[email protected]>

drm/vkms: Add support for DRM_COLOROP_1D_CURVE_GAMMA24

This commit adds lookup tables and colorop handling for the Gamma 2.4 1D curve and its inverse in VKMS, along with a corresponding KUnit test and script entry.

drivers/gpu/drm/vkms/vkms_colorop.c static const u64 supported_tfs = · line 17

Quoted 12 lines
drivers/gpu/drm/vkms/vkms_colorop.c +3 -1
index 625a590c6a2fe..db16d7e2a42fe 100644
@@ -12,7 +12,9 @@ static const u64 supported_tfs =
 	BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF) |
 	BIT(DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF) |
 	BIT(DRM_COLOROP_1D_CURVE_GAMMA22) |
-	BIT(DRM_COLOROP_1D_CURVE_GAMMA22_INV);
+	BIT(DRM_COLOROP_1D_CURVE_GAMMA22_INV) |
+	BIT(DRM_COLOROP_1D_CURVE_GAMMA24) |
+	BIT(DRM_COLOROP_1D_CURVE_GAMMA24_INV);

[Severity: High]
Are DRM_COLOROP_1D_CURVE_GAMMA24 and DRM_COLOROP_1D_CURVE_GAMMA24_INV defined in enum drm_colorop_curve_1d_type?

Both constants are missing from include/drm/drm_colorop.h, and colorop_curve_1d_type_names[] in drivers/gpu/drm/drm_colorop.c has no entries for them. With CONFIG_DRM_VKMS enabled, this breaks compilation of vkms_colorop.c and apply_colorop() in vkms_composer.c.

It looks like a prerequisite DRM core patch adding these enum values and their property name strings is missing.

[ ... ]

Quoted 4 lines
drivers/gpu/drm/vkms/vkms_luts.c +0 -0
index 5778226fc290f..90a717ced70cd 100644

[ ... ]

Quoted 6 lines
drivers/gpu/drm/vkms/vkms_luts.c +6 -0
+const struct vkms_color_lut gamma24_eotf = {
+	.x = pow24_x,
+	.y = pow24_y,
+	.lut_length = ARRAY_SIZE(pow24_y)
+};
+EXPORT_SYMBOL(gamma24_eotf);

[ ... ]

drivers/gpu/drm/vkms/vkms_luts.c const struct vkms_color_lut gamma22_inv_eotf = { · line 2315

Quoted 6 lines
drivers/gpu/drm/vkms/vkms_luts.c +6 -0
+const struct vkms_color_lut gamma24_inv_eotf = {
+	.x = pow24_inv_x,
+	.y = pow24_inv_y,
+	.lut_length = ARRAY_SIZE(pow24_inv_y)
+};
+EXPORT_SYMBOL(gamma24_inv_eotf);

[Severity: Low]
Should gamma24_eotf and gamma24_inv_eotf use EXPORT_SYMBOL_IF_KUNIT() instead of EXPORT_SYMBOL()?

vkms_luts.o and vkms_composer.o are linked into the same vkms module, and the only external user is vkms_color_test.c, which already imports the EXPORTED_FOR_KUNIT_TESTING namespace. Unconditional EXPORT_SYMBOL() exposes these generic unprefixed names in the global symbol table even when CONFIG_KUNIT is disabled.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
#7 lore raw

Re: [PATCH v2 4/4] drm/vkms: Add support for DRM_COLOROP_1D_CURVE_GAMMA24

In reply to Robert Mader
kernel test robot noticed the following build errors:

Hi Robert,

kernel test robot noticed the following build errors:

[auto build test ERROR on drm-misc/drm-misc-next]
[also build test ERROR on drm/drm-next drm-tip/drm-tip next-20261203] [cannot apply to linus/master v7.4-rc5]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Robert-Mader/drm-vkms-Fix-inverse-lut-naming-scheme-in-script/20261204-155340
base:   https://gitlab.freedesktop.org/drm/misc/kernel.git drm-misc-next
patch link:    https://lore.kernel.org/r/20261204145427.221618-5-robert.mader%40collabora.com
patch subject: [PATCH v2 4/4] drm/vkms: Add support for DRM_COLOROP_1D_CURVE_GAMMA24
config: x86_64-rhel-9.4 (https://download.01.org/0day-ci/archive/20261205/[email protected]/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261205/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/gpu/drm/vkms/vkms_composer.c: In function 'apply_colorop':

>> drivers/gpu/drm/vkms/vkms_composer.c:280:22: error: 'DRM_COLOROP_1D_CURVE_GAMMA24' undeclared (first use in this function); did you mean 'DRM_COLOROP_1D_CURVE_GAMMA22'?
     280 |                 case DRM_COLOROP_1D_CURVE_GAMMA24:
         |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |                      DRM_COLOROP_1D_CURVE_GAMMA22
   drivers/gpu/drm/vkms/vkms_composer.c:280:22: note: each undeclared identifier is reported only once for each function it appears in
>> drivers/gpu/drm/vkms/vkms_composer.c:285:22: error: 'DRM_COLOROP_1D_CURVE_GAMMA24_INV' undeclared (first use in this function); did you mean 'DRM_COLOROP_1D_CURVE_GAMMA22_INV'?
     285 |                 case DRM_COLOROP_1D_CURVE_GAMMA24_INV:
         |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |                      DRM_COLOROP_1D_CURVE_GAMMA22_INV
--
   In file included from include/linux/bits.h:5,
                    from include/linux/ratelimit_types.h:5,
                    from include/linux/printk.h:9,
                    from include/asm-generic/bug.h:31,
                    from arch/x86/include/asm/bug.h:195,
                    from include/linux/bug.h:5,
                    from include/linux/slab.h:15,
                    from drivers/gpu/drm/vkms/vkms_colorop.c:3:
>> drivers/gpu/drm/vkms/vkms_colorop.c:16:13: error: 'DRM_COLOROP_1D_CURVE_GAMMA24' undeclared here (not in a function); did you mean 'DRM_COLOROP_1D_CURVE_GAMMA22'?
      16 |         BIT(DRM_COLOROP_1D_CURVE_GAMMA24) |
         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/vdso/bits.h:7:44: note: in definition of macro 'BIT'
       7 | #define BIT(nr)                 (UL(1) << (nr))
         |                                            ^~
>> drivers/gpu/drm/vkms/vkms_colorop.c:17:13: error: 'DRM_COLOROP_1D_CURVE_GAMMA24_INV' undeclared here (not in a function); did you mean 'DRM_COLOROP_1D_CURVE_GAMMA22_INV'?
      17 |         BIT(DRM_COLOROP_1D_CURVE_GAMMA24_INV);
         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/vdso/bits.h:7:44: note: in definition of macro 'BIT'
       7 | #define BIT(nr)                 (UL(1) << (nr))
         |                                            ^~

vim +280 drivers/gpu/drm/vkms/vkms_composer.c

249
250 static void apply_colorop(struct pixel_argb_s32 *pixel, struct drm_colorop *colorop)
251 {
252 struct drm_colorop_state *colorop_state = colorop->state;
253 struct drm_device *dev = colorop->dev;
254
255 if (colorop->type == DRM_COLOROP_1D_CURVE) {
256 switch (colorop_state->curve_1d_type) {
257 case DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF:
258 pixel->r = apply_lut_to_channel_value(&srgb_inv_eotf, pixel->r, LUT_RED);
259 pixel->g = apply_lut_to_channel_value(&srgb_inv_eotf, pixel->g, LUT_GREEN);
260 pixel->b = apply_lut_to_channel_value(&srgb_inv_eotf, pixel->b, LUT_BLUE);
261 break;
262 case DRM_COLOROP_1D_CURVE_SRGB_EOTF:
263 pixel->r = apply_lut_to_channel_value(&srgb_eotf, pixel->r, LUT_RED);
264 pixel->g = apply_lut_to_channel_value(&srgb_eotf, pixel->g, LUT_GREEN);
265 pixel->b = apply_lut_to_channel_value(&srgb_eotf, pixel->b, LUT_BLUE);
266 break;
267 case DRM_COLOROP_1D_CURVE_GAMMA22:
268 pixel->r = apply_lut_to_channel_value(&gamma22_eotf, pixel->r, LUT_RED);
269 pixel->g = apply_lut_to_channel_value(&gamma22_eotf, pixel->g, LUT_GREEN);
270 pixel->b = apply_lut_to_channel_value(&gamma22_eotf, pixel->b, LUT_BLUE);
271 break;
272 case DRM_COLOROP_1D_CURVE_GAMMA22_INV:
273 pixel->r = apply_lut_to_channel_value(&gamma22_inv_eotf, pixel->r,
274 LUT_RED);
275 pixel->g = apply_lut_to_channel_value(&gamma22_inv_eotf, pixel->g,
276 LUT_GREEN);
277 pixel->b = apply_lut_to_channel_value(&gamma22_inv_eotf, pixel->b,
278 LUT_BLUE);
279 break;

 > 280			case DRM_COLOROP_1D_CURVE_GAMMA24:
   281				pixel->r = apply_lut_to_channel_value(&gamma24_eotf, pixel->r, LUT_RED);
   282				pixel->g = apply_lut_to_channel_value(&gamma24_eotf, pixel->g, LUT_GREEN);
   283				pixel->b = apply_lut_to_channel_value(&gamma24_eotf, pixel->b, LUT_BLUE);
   284				break;
 > 285			case DRM_COLOROP_1D_CURVE_GAMMA24_INV:

286 pixel->r = apply_lut_to_channel_value(&gamma24_inv_eotf, pixel->r,
287 LUT_RED);
288 pixel->g = apply_lut_to_channel_value(&gamma24_inv_eotf, pixel->g,
289 LUT_GREEN);
290 pixel->b = apply_lut_to_channel_value(&gamma24_inv_eotf, pixel->b,
291 LUT_BLUE);
292 break;
293 default:
294 drm_WARN_ONCE(dev, true,
295 "unknown colorop 1D curve type %d\n",
296 colorop_state->curve_1d_type);
297 break;
298 }
299 } else if (colorop->type == DRM_COLOROP_CTM_3X4) {
300 if (colorop_state->data)
301 apply_3x4_matrix(pixel,
302 (struct drm_color_ctm_3x4 *)colorop_state->data->data);
303 } else if (colorop->type == DRM_COLOROP_FIXED_MATRIX) {
304 /*
305 * Fixed Matrix is a no-op here. YUV-to-RGB conversion
306 * is handled at format read time via the
307 * conversion_matrix set in vkms_plane_atomic_update().
308 */
309 }
310 }
311

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#8 lore raw

Re: [PATCH v2 4/4] drm/vkms: Add support for DRM_COLOROP_1D_CURVE_GAMMA24

In reply to Robert Mader
kernel test robot noticed the following build errors:

Hi Robert,

kernel test robot noticed the following build errors:

[auto build test ERROR on drm-misc/drm-misc-next]
[also build test ERROR on drm/drm-next drm-tip/drm-tip next-20261203] [cannot apply to linus/master v7.4-rc5]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Robert-Mader/drm-vkms-Fix-inverse-lut-naming-scheme-in-script/20261204-155340
base:   https://gitlab.freedesktop.org/drm/misc/kernel.git drm-misc-next
patch link:    https://lore.kernel.org/r/20261204145427.221618-5-robert.mader%40collabora.com
patch subject: [PATCH v2 4/4] drm/vkms: Add support for DRM_COLOROP_1D_CURVE_GAMMA24
config: powerpc64-randconfig-1001-20261205 (https://download.01.org/0day-ci/archive/20261205/[email protected]/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261205/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/gpu/drm/vkms/vkms_composer.c:280:8: error: use of undeclared identifier 'DRM_COLOROP_1D_CURVE_GAMMA24'; did you mean 'DRM_COLOROP_1D_CURVE_GAMMA22'?
     280 |                 case DRM_COLOROP_1D_CURVE_GAMMA24:
         |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |                      DRM_COLOROP_1D_CURVE_GAMMA22
   include/drm/drm_colorop.h:119:2: note: 'DRM_COLOROP_1D_CURVE_GAMMA22' declared here
     119 |         DRM_COLOROP_1D_CURVE_GAMMA22,
         |         ^
>> drivers/gpu/drm/vkms/vkms_composer.c:285:8: error: use of undeclared identifier 'DRM_COLOROP_1D_CURVE_GAMMA24_INV'; did you mean 'DRM_COLOROP_1D_CURVE_GAMMA22_INV'?
     285 |                 case DRM_COLOROP_1D_CURVE_GAMMA24_INV:
         |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |                      DRM_COLOROP_1D_CURVE_GAMMA22_INV
   include/drm/drm_colorop.h:128:2: note: 'DRM_COLOROP_1D_CURVE_GAMMA22_INV' declared here
     128 |         DRM_COLOROP_1D_CURVE_GAMMA22_INV,
         |         ^
>> drivers/gpu/drm/vkms/vkms_composer.c:280:8: error: duplicate case value 'DRM_COLOROP_1D_CURVE_GAMMA22'
     280 |                 case DRM_COLOROP_1D_CURVE_GAMMA24:
         |                      ^
   drivers/gpu/drm/vkms/vkms_composer.c:267:8: note: previous case defined here
     267 |                 case DRM_COLOROP_1D_CURVE_GAMMA22:
         |                      ^
>> drivers/gpu/drm/vkms/vkms_composer.c:285:8: error: duplicate case value 'DRM_COLOROP_1D_CURVE_GAMMA22_INV'

285 | case DRM_COLOROP_1D_CURVE_GAMMA24_INV:
| ^
drivers/gpu/drm/vkms/vkms_composer.c:272:8: note: previous case defined here
272 | case DRM_COLOROP_1D_CURVE_GAMMA22_INV:
| ^
4 errors generated.
--

>> drivers/gpu/drm/vkms/vkms_colorop.c:16:6: error: use of undeclared identifier 'DRM_COLOROP_1D_CURVE_GAMMA24'; did you mean 'DRM_COLOROP_1D_CURVE_GAMMA22'?
      16 |         BIT(DRM_COLOROP_1D_CURVE_GAMMA24) |
         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |             DRM_COLOROP_1D_CURVE_GAMMA22
   include/vdso/bits.h:7:30: note: expanded from macro 'BIT'
       7 | #define BIT(nr)                 (UL(1) << (nr))
         |                                            ^
   include/drm/drm_colorop.h:119:2: note: 'DRM_COLOROP_1D_CURVE_GAMMA22' declared here
     119 |         DRM_COLOROP_1D_CURVE_GAMMA22,
         |         ^
>> drivers/gpu/drm/vkms/vkms_colorop.c:17:6: error: use of undeclared identifier 'DRM_COLOROP_1D_CURVE_GAMMA24_INV'; did you mean 'DRM_COLOROP_1D_CURVE_GAMMA22_INV'?
      17 |         BIT(DRM_COLOROP_1D_CURVE_GAMMA24_INV);
         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |             DRM_COLOROP_1D_CURVE_GAMMA22_INV
   include/vdso/bits.h:7:30: note: expanded from macro 'BIT'
       7 | #define BIT(nr)                 (UL(1) << (nr))
         |                                            ^
   include/drm/drm_colorop.h:128:2: note: 'DRM_COLOROP_1D_CURVE_GAMMA22_INV' declared here
     128 |         DRM_COLOROP_1D_CURVE_GAMMA22_INV,
         |         ^

2 errors generated.

vim +280 drivers/gpu/drm/vkms/vkms_composer.c

249
250 static void apply_colorop(struct pixel_argb_s32 *pixel, struct drm_colorop *colorop)
251 {
252 struct drm_colorop_state *colorop_state = colorop->state;
253 struct drm_device *dev = colorop->dev;
254
255 if (colorop->type == DRM_COLOROP_1D_CURVE) {
256 switch (colorop_state->curve_1d_type) {
257 case DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF:
258 pixel->r = apply_lut_to_channel_value(&srgb_inv_eotf, pixel->r, LUT_RED);
259 pixel->g = apply_lut_to_channel_value(&srgb_inv_eotf, pixel->g, LUT_GREEN);
260 pixel->b = apply_lut_to_channel_value(&srgb_inv_eotf, pixel->b, LUT_BLUE);
261 break;
262 case DRM_COLOROP_1D_CURVE_SRGB_EOTF:
263 pixel->r = apply_lut_to_channel_value(&srgb_eotf, pixel->r, LUT_RED);
264 pixel->g = apply_lut_to_channel_value(&srgb_eotf, pixel->g, LUT_GREEN);
265 pixel->b = apply_lut_to_channel_value(&srgb_eotf, pixel->b, LUT_BLUE);
266 break;
267 case DRM_COLOROP_1D_CURVE_GAMMA22:
268 pixel->r = apply_lut_to_channel_value(&gamma22_eotf, pixel->r, LUT_RED);
269 pixel->g = apply_lut_to_channel_value(&gamma22_eotf, pixel->g, LUT_GREEN);
270 pixel->b = apply_lut_to_channel_value(&gamma22_eotf, pixel->b, LUT_BLUE);
271 break;
272 case DRM_COLOROP_1D_CURVE_GAMMA22_INV:
273 pixel->r = apply_lut_to_channel_value(&gamma22_inv_eotf, pixel->r,
274 LUT_RED);
275 pixel->g = apply_lut_to_channel_value(&gamma22_inv_eotf, pixel->g,
276 LUT_GREEN);
277 pixel->b = apply_lut_to_channel_value(&gamma22_inv_eotf, pixel->b,
278 LUT_BLUE);
279 break;

 > 280			case DRM_COLOROP_1D_CURVE_GAMMA24:
   281				pixel->r = apply_lut_to_channel_value(&gamma24_eotf, pixel->r, LUT_RED);
   282				pixel->g = apply_lut_to_channel_value(&gamma24_eotf, pixel->g, LUT_GREEN);
   283				pixel->b = apply_lut_to_channel_value(&gamma24_eotf, pixel->b, LUT_BLUE);
   284				break;
 > 285			case DRM_COLOROP_1D_CURVE_GAMMA24_INV:

286 pixel->r = apply_lut_to_channel_value(&gamma24_inv_eotf, pixel->r,
287 LUT_RED);
288 pixel->g = apply_lut_to_channel_value(&gamma24_inv_eotf, pixel->g,
289 LUT_GREEN);
290 pixel->b = apply_lut_to_channel_value(&gamma24_inv_eotf, pixel->b,
291 LUT_BLUE);
292 break;
293 default:
294 drm_WARN_ONCE(dev, true,
295 "unknown colorop 1D curve type %d\n",
296 colorop_state->curve_1d_type);
297 break;
298 }
299 } else if (colorop->type == DRM_COLOROP_CTM_3X4) {
300 if (colorop_state->data)
301 apply_3x4_matrix(pixel,
302 (struct drm_color_ctm_3x4 *)colorop_state->data->data);
303 } else if (colorop->type == DRM_COLOROP_FIXED_MATRIX) {
304 /*
305 * Fixed Matrix is a no-op here. YUV-to-RGB conversion
306 * is handled at format read time via the
307 * conversion_matrix set in vkms_plane_atomic_update().
308 */
309 }
310 }
311

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki