On Mon Jul 20 18:17:26 2026 +0900, Ming Qian wrote:
> SMPTE ST 2086 defines the nominal ranges for mastering display
> chromaticity and luminance values. Its Annex A also documents that
> CTA 861-G uses zero maximum and minimum luminance values to signal
> that the corresponding values are unknown, and the xy chromaticity
> coordinate (0, 0) to signal that the white point chromaticity is
> unknown.
> 
> The V4L2 HDR10 mastering display compound control currently rejects
> these values. Consequently, an unknown white point or luminance value
> prevents the entire compound control from being updated, making the
> other valid mastering display metadata unavailable to userspace.
> 
> Accept (0, 0) as an unknown white point and zero as an unknown maximum
> or minimum mastering luminance. Continue to reject partially zero white
> point coordinates and non-zero values outside the nominal ranges.
> Display primary validation remains unchanged.
> 
> Document the newly accepted unknown values in the V4L2 userspace API.
> 
> Fixes: 1ad0de78e794 ("media: v4l: Add HDR10 static metadata controls")
> Cc: [email protected]
> Signed-off-by: Ming Qian <[email protected]>
> Signed-off-by: Hans Verkuil <[email protected]>

Patch committed.

Thanks,
Hans Verkuil

 .../media/v4l/ext-ctrls-colorimetry.rst            | 12 ++++-
 drivers/media/v4l2-core/v4l2-ctrls-core.c          | 53 ++++++++++++++--------
 2 files changed, 46 insertions(+), 19 deletions(-)

---

diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-colorimetry.rst 
b/Documentation/userspace-api/media/v4l/ext-ctrls-colorimetry.rst
index 38a4136d7220..0a7da2f16850 100644
--- a/Documentation/userspace-api/media/v4l/ext-ctrls-colorimetry.rst
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-colorimetry.rst
@@ -80,15 +80,25 @@ Colorimetry Control IDs
       - ``white_point_x``
       - Specifies the normalized x chromaticity coordinate of the white
         point of the mastering display in increments of 0.00002.
+        When both ``white_point_x`` and ``white_point_y`` are zero,
+        the white point chromaticity is unknown. If either coordinate is
+        non-zero, both coordinates shall be within their valid ranges.
     * - __u16
       - ``white_point_y``
       - Specifies the normalized y chromaticity coordinate of the white
         point of the mastering display in increments of 0.00002.
+        When both ``white_point_x`` and ``white_point_y`` are zero,
+        the white point chromaticity is unknown. If either coordinate is
+        non-zero, both coordinates shall be within their valid ranges.
     * - __u32
       - ``max_luminance``
       - Specifies the nominal maximum display luminance of the mastering
         display in units of 0.0001 cd/m\ :sup:`2`.
+        A value of zero indicates that the nominal maximum display
+        luminance is unknown.
     * - __u32
       - ``min_luminance``
-      - specifies the nominal minimum display luminance of the mastering
+      - Specifies the nominal minimum display luminance of the mastering
         display in units of 0.0001 cd/m\ :sup:`2`.
+        A value of zero indicates that the nominal minimum display
+        luminance is unknown.
diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c 
b/drivers/media/v4l2-core/v4l2-ctrls-core.c
index 1214e7744ac0..5b8a594fb9e2 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls-core.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c
@@ -1322,24 +1322,41 @@ static int std_validate_compound(const struct v4l2_ctrl 
*ctrl, u32 idx,
                                return -EINVAL;
                }
 
-               if (p_hdr10_mastering->white_point_x <
-                       V4L2_HDR10_MASTERING_WHITE_POINT_X_LOW ||
-                   p_hdr10_mastering->white_point_x >
-                       V4L2_HDR10_MASTERING_WHITE_POINT_X_HIGH ||
-                   p_hdr10_mastering->white_point_y <
-                       V4L2_HDR10_MASTERING_WHITE_POINT_Y_LOW ||
-                   p_hdr10_mastering->white_point_y >
-                       V4L2_HDR10_MASTERING_WHITE_POINT_Y_HIGH)
-                       return -EINVAL;
-
-               if (p_hdr10_mastering->max_display_mastering_luminance <
-                       V4L2_HDR10_MASTERING_MAX_LUMA_LOW ||
-                   p_hdr10_mastering->max_display_mastering_luminance >
-                       V4L2_HDR10_MASTERING_MAX_LUMA_HIGH ||
-                   p_hdr10_mastering->min_display_mastering_luminance <
-                       V4L2_HDR10_MASTERING_MIN_LUMA_LOW ||
-                   p_hdr10_mastering->min_display_mastering_luminance >
-                       V4L2_HDR10_MASTERING_MIN_LUMA_HIGH)
+               /*
+                * SMPTE ST 2086 Annex A documents that CTA 861-G uses
+                * (0, 0) to indicate that the white point chromaticity
+                * is unknown.
+                */
+               if (p_hdr10_mastering->white_point_x ||
+                   p_hdr10_mastering->white_point_y) {
+                       if (p_hdr10_mastering->white_point_x <
+                               V4L2_HDR10_MASTERING_WHITE_POINT_X_LOW ||
+                           p_hdr10_mastering->white_point_x >
+                               V4L2_HDR10_MASTERING_WHITE_POINT_X_HIGH ||
+                           p_hdr10_mastering->white_point_y <
+                               V4L2_HDR10_MASTERING_WHITE_POINT_Y_LOW ||
+                           p_hdr10_mastering->white_point_y >
+                               V4L2_HDR10_MASTERING_WHITE_POINT_Y_HIGH)
+                               return -EINVAL;
+               }
+
+               /*
+                * SMPTE ST 2086 Annex A documents that CTA 861-G uses zero
+                * maximum and minimum luminance values to indicate that
+                * the corresponding values are unknown.
+                */
+               if (p_hdr10_mastering->max_display_mastering_luminance &&
+                   (p_hdr10_mastering->max_display_mastering_luminance <
+                               V4L2_HDR10_MASTERING_MAX_LUMA_LOW ||
+                    p_hdr10_mastering->max_display_mastering_luminance >
+                               V4L2_HDR10_MASTERING_MAX_LUMA_HIGH))
+                       return -EINVAL;
+
+               if (p_hdr10_mastering->min_display_mastering_luminance &&
+                   (p_hdr10_mastering->min_display_mastering_luminance <
+                               V4L2_HDR10_MASTERING_MIN_LUMA_LOW ||
+                    p_hdr10_mastering->min_display_mastering_luminance >
+                               V4L2_HDR10_MASTERING_MIN_LUMA_HIGH))
                        return -EINVAL;
 
                /* The following restriction comes from ITU-T Rec. H.265 spec */
_______________________________________________
linuxtv-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to