2021-02-09 16:28:22

by Stanimir Varbanov

[permalink] [raw]
Subject: [PATCH v5 0/5] HDR10 static metadata

Changes since v4:
* 1/5 - fixed a typo (Hans)
* 2/5 - add some mode info about new colorimetry class (Hans)
* 4/5 - correct cd/m2 -> cd/m\ :sup:`2`
- change to US spelling for color word
- use correct v4l2_ctrl_type in videodev2.h.rst.exceptions
- documented p_hdr10_cll and p_hdr10_mastering in vidioc-g-ext-ctrls.rst

Comments are welcome!

regards,
Stan

Stanimir Varbanov (5):
v4l: Add new Colorimetry Class
docs: Document colorimetry class
v4l: Add HDR10 static metadata controls
docs: Document CLL and Mastering display colorimetry controls
venus: venc: Add support for CLL and Mastering display controls

.../userspace-api/media/v4l/common.rst | 1 +
.../media/v4l/ext-ctrls-colorimetry.rst | 93 +++++++++++++++++++
.../media/v4l/vidioc-g-ext-ctrls.rst | 12 +++
.../media/videodev2.h.rst.exceptions | 2 +
drivers/media/platform/qcom/venus/core.h | 2 +
drivers/media/platform/qcom/venus/hfi_cmds.c | 8 ++
.../media/platform/qcom/venus/hfi_helper.h | 20 ++++
drivers/media/platform/qcom/venus/venc.c | 29 ++++++
.../media/platform/qcom/venus/venc_ctrls.c | 16 +++-
drivers/media/v4l2-core/v4l2-ctrls.c | 74 ++++++++++++++-
include/media/v4l2-ctrls.h | 4 +
include/uapi/linux/v4l2-controls.h | 35 +++++++
include/uapi/linux/videodev2.h | 3 +
13 files changed, 297 insertions(+), 2 deletions(-)
create mode 100644 Documentation/userspace-api/media/v4l/ext-ctrls-colorimetry.rst

--
2.25.1


2021-02-09 16:29:55

by Stanimir Varbanov

[permalink] [raw]
Subject: [PATCH v5 3/5] v4l: Add HDR10 static metadata controls

Introduce Content light level and Mastering display colour
volume Colorimetry compound controls with relevant payload
structures and validation.

Signed-off-by: Stanimir Varbanov <[email protected]>
---
drivers/media/v4l2-core/v4l2-ctrls.c | 67 ++++++++++++++++++++++++++++
include/media/v4l2-ctrls.h | 4 ++
include/uapi/linux/v4l2-controls.h | 31 +++++++++++++
include/uapi/linux/videodev2.h | 3 ++
4 files changed, 105 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
index 335cf354f51b..8bd3cf0e1e4f 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -1205,6 +1205,8 @@ const char *v4l2_ctrl_get_name(u32 id)
/* Colorimetry controls */
/* Keep the order of the 'case's the same as in v4l2-controls.h! */
case V4L2_CID_COLORIMETRY_CLASS: return "Colorimetry Controls";
+ case V4L2_CID_COLORIMETRY_HDR10_CLL_INFO: return "HDR10 Content Light Info";
+ case V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY: return "HDR10 Mastering Display";
default:
return NULL;
}
@@ -1491,6 +1493,12 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
*type = V4L2_CTRL_TYPE_AREA;
*flags |= V4L2_CTRL_FLAG_READ_ONLY;
break;
+ case V4L2_CID_COLORIMETRY_HDR10_CLL_INFO:
+ *type = V4L2_CTRL_TYPE_HDR10_CLL_INFO;
+ break;
+ case V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY:
+ *type = V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY;
+ break;
default:
*type = V4L2_CTRL_TYPE_INTEGER;
break;
@@ -1786,6 +1794,12 @@ static void std_log(const struct v4l2_ctrl *ctrl)
case V4L2_CTRL_TYPE_FWHT_PARAMS:
pr_cont("FWHT_PARAMS");
break;
+ case V4L2_CTRL_TYPE_HDR10_CLL_INFO:
+ pr_cont("HDR10_CLL_INFO");
+ break;
+ case V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY:
+ pr_cont("HDR10_MASTERING_DISPLAY");
+ break;
default:
pr_cont("unknown type %d", ctrl->type);
break;
@@ -1838,6 +1852,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
struct v4l2_ctrl_hevc_sps *p_hevc_sps;
struct v4l2_ctrl_hevc_pps *p_hevc_pps;
struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params;
+ struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering;
struct v4l2_area *area;
void *p = ptr.p + idx * ctrl->elem_size;
unsigned int i;
@@ -2133,6 +2148,52 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
zero_padding(*p_hevc_slice_params);
break;

+ case V4L2_CTRL_TYPE_HDR10_CLL_INFO:
+ break;
+
+ case V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY:
+ p_hdr10_mastering = p;
+
+ for (i = 0; i < 3; ++i) {
+ if (p_hdr10_mastering->display_primaries_x[i] <
+ V4L2_HDR10_MASTERING_PRIMARIES_X_LOW ||
+ p_hdr10_mastering->display_primaries_x[i] >
+ V4L2_HDR10_MASTERING_PRIMARIES_X_HIGH ||
+ p_hdr10_mastering->display_primaries_y[i] <
+ V4L2_HDR10_MASTERING_PRIMARIES_Y_LOW ||
+ p_hdr10_mastering->display_primaries_y[i] >
+ V4L2_HDR10_MASTERING_PRIMARIES_Y_HIGH)
+ 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)
+ return -EINVAL;
+
+ if (p_hdr10_mastering->max_display_mastering_luminance ==
+ V4L2_HDR10_MASTERING_MAX_LUMA_LOW &&
+ p_hdr10_mastering->min_display_mastering_luminance ==
+ V4L2_HDR10_MASTERING_MIN_LUMA_HIGH)
+ return -EINVAL;
+
+ break;
+
case V4L2_CTRL_TYPE_AREA:
area = p;
if (!area->width || !area->height)
@@ -2826,6 +2887,12 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,
case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
elem_size = sizeof(struct v4l2_ctrl_hevc_slice_params);
break;
+ case V4L2_CTRL_TYPE_HDR10_CLL_INFO:
+ elem_size = sizeof(struct v4l2_ctrl_hdr10_cll_info);
+ break;
+ case V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY:
+ elem_size = sizeof(struct v4l2_ctrl_hdr10_mastering_display);
+ break;
case V4L2_CTRL_TYPE_AREA:
elem_size = sizeof(struct v4l2_area);
break;
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index 167ca8c8424f..9c3ddbf3d099 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -54,6 +54,8 @@ struct video_device;
* @p_hevc_sps: Pointer to an HEVC sequence parameter set structure.
* @p_hevc_pps: Pointer to an HEVC picture parameter set structure.
* @p_hevc_slice_params: Pointer to an HEVC slice parameters structure.
+ * @p_hdr10_cll: Pointer to an HDR10 Content Light Level structure.
+ * @p_hdr10_mastering: Pointer to an HDR10 Mastering Display structure.
* @p_area: Pointer to an area.
* @p: Pointer to a compound value.
* @p_const: Pointer to a constant compound value.
@@ -78,6 +80,8 @@ union v4l2_ctrl_ptr {
struct v4l2_ctrl_hevc_sps *p_hevc_sps;
struct v4l2_ctrl_hevc_pps *p_hevc_pps;
struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params;
+ struct v4l2_ctrl_hdr10_cll_info *p_hdr10_cll;
+ struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering;
struct v4l2_area *p_area;
void *p;
const void *p_const;
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index a41039559193..349e86b18af7 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -1661,6 +1661,37 @@ struct v4l2_ctrl_fwht_params {
#define V4L2_CID_COLORIMETRY_CLASS_BASE (V4L2_CTRL_CLASS_COLORIMETRY | 0x900)
#define V4L2_CID_COLORIMETRY_CLASS (V4L2_CTRL_CLASS_COLORIMETRY | 1)

+#define V4L2_CID_COLORIMETRY_HDR10_CLL_INFO (V4L2_CID_COLORIMETRY_CLASS_BASE + 0)
+
+struct v4l2_ctrl_hdr10_cll_info {
+ __u16 max_content_light_level;
+ __u16 max_pic_average_light_level;
+};
+
+#define V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY (V4L2_CID_COLORIMETRY_CLASS_BASE + 1)
+
+#define V4L2_HDR10_MASTERING_PRIMARIES_X_LOW 5
+#define V4L2_HDR10_MASTERING_PRIMARIES_X_HIGH 37000
+#define V4L2_HDR10_MASTERING_PRIMARIES_Y_LOW 5
+#define V4L2_HDR10_MASTERING_PRIMARIES_Y_HIGH 42000
+#define V4L2_HDR10_MASTERING_WHITE_POINT_X_LOW 5
+#define V4L2_HDR10_MASTERING_WHITE_POINT_X_HIGH 37000
+#define V4L2_HDR10_MASTERING_WHITE_POINT_Y_LOW 5
+#define V4L2_HDR10_MASTERING_WHITE_POINT_Y_HIGH 42000
+#define V4L2_HDR10_MASTERING_MAX_LUMA_LOW 50000
+#define V4L2_HDR10_MASTERING_MAX_LUMA_HIGH 100000000
+#define V4L2_HDR10_MASTERING_MIN_LUMA_LOW 1
+#define V4L2_HDR10_MASTERING_MIN_LUMA_HIGH 50000
+
+struct v4l2_ctrl_hdr10_mastering_display {
+ __u16 display_primaries_x[3];
+ __u16 display_primaries_y[3];
+ __u16 white_point_x;
+ __u16 white_point_y;
+ __u32 max_display_mastering_luminance;
+ __u32 min_display_mastering_luminance;
+};
+
/* MPEG-compression definitions kept for backwards compatibility */
#ifndef __KERNEL__
#define V4L2_CTRL_CLASS_MPEG V4L2_CTRL_CLASS_CODEC
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 79dbde3bcf8d..f5f971407b66 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -1784,6 +1784,9 @@ enum v4l2_ctrl_type {
V4L2_CTRL_TYPE_U32 = 0x0102,
V4L2_CTRL_TYPE_AREA = 0x0106,

+ V4L2_CTRL_TYPE_HDR10_CLL_INFO = 0x0110,
+ V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY = 0x0111,
+
V4L2_CTRL_TYPE_H264_SPS = 0x0200,
V4L2_CTRL_TYPE_H264_PPS = 0x0201,
V4L2_CTRL_TYPE_H264_SCALING_MATRIX = 0x0202,
--
2.25.1

2021-02-09 16:30:18

by Stanimir Varbanov

[permalink] [raw]
Subject: [PATCH v5 1/5] v4l: Add new Colorimetry Class

Add Colorimetry control class for colorimetry controls

Signed-off-by: Stanimir Varbanov <[email protected]>
---
drivers/media/v4l2-core/v4l2-ctrls.c | 7 ++++++-
include/uapi/linux/v4l2-controls.h | 4 ++++
2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
index 016cf6204cbb..335cf354f51b 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -1201,6 +1201,10 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_STATELESS_H264_SLICE_PARAMS: return "H264 Slice Parameters";
case V4L2_CID_STATELESS_H264_DECODE_PARAMS: return "H264 Decode Parameters";
case V4L2_CID_STATELESS_FWHT_PARAMS: return "FWHT Stateless Parameters";
+
+ /* Colorimetry controls */
+ /* Keep the order of the 'case's the same as in v4l2-controls.h! */
+ case V4L2_CID_COLORIMETRY_CLASS: return "Colorimetry Controls";
default:
return NULL;
}
@@ -1389,8 +1393,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
case V4L2_CID_RF_TUNER_CLASS:
case V4L2_CID_DETECT_CLASS:
case V4L2_CID_CODEC_STATELESS_CLASS:
+ case V4L2_CID_COLORIMETRY_CLASS:
*type = V4L2_CTRL_TYPE_CTRL_CLASS;
- /* You can neither read not write these */
+ /* You can neither read nor write these */
*flags |= V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_WRITE_ONLY;
*min = *max = *step = *def = 0;
break;
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index 039c0d7add1b..a41039559193 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -66,6 +66,7 @@
#define V4L2_CTRL_CLASS_RF_TUNER 0x00a20000 /* RF tuner controls */
#define V4L2_CTRL_CLASS_DETECT 0x00a30000 /* Detection controls */
#define V4L2_CTRL_CLASS_CODEC_STATELESS 0x00a40000 /* Stateless codecs controls */
+#define V4L2_CTRL_CLASS_COLORIMETRY 0x00a50000 /* Colorimetry controls */

/* User-class control IDs */

@@ -1657,6 +1658,9 @@ struct v4l2_ctrl_fwht_params {
__u32 quantization;
};

+#define V4L2_CID_COLORIMETRY_CLASS_BASE (V4L2_CTRL_CLASS_COLORIMETRY | 0x900)
+#define V4L2_CID_COLORIMETRY_CLASS (V4L2_CTRL_CLASS_COLORIMETRY | 1)
+
/* MPEG-compression definitions kept for backwards compatibility */
#ifndef __KERNEL__
#define V4L2_CTRL_CLASS_MPEG V4L2_CTRL_CLASS_CODEC
--
2.25.1

2021-02-09 16:31:46

by Stanimir Varbanov

[permalink] [raw]
Subject: [PATCH v5 2/5] docs: Document colorimetry class

Add a document for ext control colorimetry class.

Signed-off-by: Stanimir Varbanov <[email protected]>
---
.../userspace-api/media/v4l/common.rst | 1 +
.../media/v4l/ext-ctrls-colorimetry.rst | 22 +++++++++++++++++++
.../media/v4l/vidioc-g-ext-ctrls.rst | 4 ++++
3 files changed, 27 insertions(+)
create mode 100644 Documentation/userspace-api/media/v4l/ext-ctrls-colorimetry.rst

diff --git a/Documentation/userspace-api/media/v4l/common.rst b/Documentation/userspace-api/media/v4l/common.rst
index 8c263c5a85d8..ea0435182e44 100644
--- a/Documentation/userspace-api/media/v4l/common.rst
+++ b/Documentation/userspace-api/media/v4l/common.rst
@@ -51,6 +51,7 @@ applicable to all devices.
ext-ctrls-fm-tx
ext-ctrls-fm-rx
ext-ctrls-detect
+ ext-ctrls-colorimetry
fourcc
format
planar-apis
diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-colorimetry.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-colorimetry.rst
new file mode 100644
index 000000000000..862f78b41b32
--- /dev/null
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-colorimetry.rst
@@ -0,0 +1,22 @@
+.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
+
+.. _colorimetry-controls:
+
+*****************************
+Colorimetry Control Reference
+*****************************
+
+The Colorimetry class includes controls for High Dynamic Range
+imaging for representing colors in digital images and video. The
+controls should be used for video and image encoding and decoding
+as well as in HDMI receivers and transmitters.
+
+Colorimetry Control IDs
+-----------------------
+
+.. _colorimetry-control-id:
+
+``V4L2_CID_COLORIMETRY_CLASS (class)``
+ The Colorimetry class descriptor. Calling
+ :ref:`VIDIOC_QUERYCTRL` for this control will
+ return a description of this control class.
diff --git a/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst b/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst
index b9c62affbb5a..8a95ebdd499a 100644
--- a/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst
+++ b/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst
@@ -394,6 +394,10 @@ still cause this situation.
- 0xa40000
- The class containing stateless codec controls. These controls are
described in :ref:`codec-stateless-controls`.
+ * - ``V4L2_CTRL_CLASS_COLORIMETRY``
+ - 0xa50000
+ - The class containing colorimetry controls. These controls are
+ described in :ref:`colorimetry-controls`.

Return Value
============
--
2.25.1

2021-02-09 16:32:30

by Stanimir Varbanov

[permalink] [raw]
Subject: [PATCH v5 4/5] docs: Document CLL and Mastering display colorimetry controls

Document Content Light Level and Mastering Display v4l2 colorimetry
controls.

Signed-off-by: Stanimir Varbanov <[email protected]>
---
.../media/v4l/ext-ctrls-colorimetry.rst | 71 +++++++++++++++++++
.../media/v4l/vidioc-g-ext-ctrls.rst | 8 +++
.../media/videodev2.h.rst.exceptions | 2 +
3 files changed, 81 insertions(+)

diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-colorimetry.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-colorimetry.rst
index 862f78b41b32..a9f206a46175 100644
--- a/Documentation/userspace-api/media/v4l/ext-ctrls-colorimetry.rst
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-colorimetry.rst
@@ -20,3 +20,74 @@ Colorimetry Control IDs
The Colorimetry class descriptor. Calling
:ref:`VIDIOC_QUERYCTRL` for this control will
return a description of this control class.
+
+``V4L2_CID_COLORIMETRY_HDR10_CLL_INFO (struct)``
+ The Content Light Level defines upper bounds for the nominal target
+ brightness light level of the pictures.
+
+.. c:type:: v4l2_ctrl_hdr10_cll_info
+
+.. cssclass:: longtable
+
+.. flat-table:: struct v4l2_ctrl_hdr10_cll_info
+ :header-rows: 0
+ :stub-columns: 0
+ :widths: 1 1 2
+
+ * - __u16
+ - ``max_content_light_level``
+ - The upper bound for the maximum light level among all individual
+ samples for the pictures of a coded video sequence, cd/m\ :sup:`2`.
+ When equal to 0 no such upper bound is present.
+ * - __u16
+ - ``max_pic_average_light_level``
+ - The upper bound for the maximum average light level among the
+ samples for any individual picture of a coded video sequence,
+ cd/m\ :sup:`2`. When equal to 0 no such upper bound is present.
+
+``V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY (struct)``
+ The mastering display defines the color volume (the color primaries,
+ white point and luminance range) of a display considered to be the
+ mastering display for the current video content.
+
+.. c:type:: v4l2_ctrl_hdr10_mastering_display
+
+.. cssclass:: longtable
+
+.. flat-table:: struct v4l2_ctrl_hdr10_mastering_display
+ :header-rows: 0
+ :stub-columns: 0
+ :widths: 1 1 2
+
+ * - __u16
+ - ``display_primaries_x[3]``
+ - Specifies the normalized x chromaticity coordinate of the color
+ primary component c of the mastering display in increments of 0.00002.
+ For describing the mastering display that uses Red, Green and Blue
+ color primaries, index value c equal to 0 corresponds to the Green
+ primary, c equal to 1 corresponds to Blue primary and c equal to 2
+ corresponds to the Red color primary.
+ * - __u16
+ - ``display_primaries_y[3]``
+ - Specifies the normalized y chromaticity coordinate of the color
+ primary component c of the mastering display in increments of 0.00002.
+ For describing the mastering display that uses Red, Green and Blue
+ color primaries, index value c equal to 0 corresponds to the Green
+ primary, c equal to 1 corresponds to Blue primary and c equal to 2
+ corresponds to Red color primary.
+ * - __u16
+ - ``white_point_x``
+ - Specifies the normalized x chromaticity coordinate of the white
+ point of the mastering display in increments of 0.00002.
+ * - __u16
+ - ``white_point_y``
+ - Specifies the normalized y chromaticity coordinate of the white
+ point of the mastering display in increments of 0.00002.
+ * - __u32
+ - ``max_luminance``
+ - Specifies the nominal maximum display luminance of the mastering
+ display in units of 0.0001 cd/m\ :sup:`2`.
+ * - __u32
+ - ``min_luminance``
+ - specifies the nominal minimum display luminance of the mastering
+ display in units of 0.0001 cd/m\ :sup:`2`.
diff --git a/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst b/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst
index 8a95ebdd499a..2f6d0539fb93 100644
--- a/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst
+++ b/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst
@@ -212,6 +212,14 @@ still cause this situation.
- ``p_fwht_params``
- A pointer to a struct :c:type:`v4l2_ctrl_fwht_params`. Valid if this control is
of type ``V4L2_CTRL_TYPE_FWHT_PARAMS``.
+ * - struct :c:type:`v4l2_ctrl_hdr10_cll_info` *
+ - ``p_hdr10_cll``
+ - A pointer to a struct :c:type:`v4l2_ctrl_hdr10_cll_info`. Valid if this control is
+ of type ``V4L2_CTRL_TYPE_HDR10_CLL_INFO``.
+ * - struct :c:type:`v4l2_ctrl_hdr10_mastering_display` *
+ - ``p_hdr10_mastering``
+ - A pointer to a struct :c:type:`v4l2_ctrl_hdr10_mastering_display`. Valid if this control is
+ of type ``V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY``.
* - void *
- ``ptr``
- A pointer to a compound type which can be an N-dimensional array
diff --git a/Documentation/userspace-api/media/videodev2.h.rst.exceptions b/Documentation/userspace-api/media/videodev2.h.rst.exceptions
index 0ed170c6e720..38b31a9b9580 100644
--- a/Documentation/userspace-api/media/videodev2.h.rst.exceptions
+++ b/Documentation/userspace-api/media/videodev2.h.rst.exceptions
@@ -147,6 +147,8 @@ replace symbol V4L2_CTRL_TYPE_HEVC_PPS :c:type:`v4l2_ctrl_type`
replace symbol V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS :c:type:`v4l2_ctrl_type`
replace symbol V4L2_CTRL_TYPE_AREA :c:type:`v4l2_ctrl_type`
replace symbol V4L2_CTRL_TYPE_FWHT_PARAMS :c:type:`v4l2_ctrl_type`
+replace symbol V4L2_CTRL_TYPE_HDR10_CLL_INFO :c:type:`v4l2_ctrl_type`
+replace symbol V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY :c:type:`v4l2_ctrl_type`

# V4L2 capability defines
replace define V4L2_CAP_VIDEO_CAPTURE device-capabilities
--
2.25.1

2021-02-09 16:32:47

by Stanimir Varbanov

[permalink] [raw]
Subject: [PATCH v5 5/5] venus: venc: Add support for CLL and Mastering display controls

Create CLL and Mastering display colour volume v4l2 controls for
encoder, add handling of HDR10 PQ SEI packet payloads for v4.

Signed-off-by: Stanimir Varbanov <[email protected]>
---
drivers/media/platform/qcom/venus/core.h | 2 ++
drivers/media/platform/qcom/venus/hfi_cmds.c | 8 +++++
.../media/platform/qcom/venus/hfi_helper.h | 20 +++++++++++++
drivers/media/platform/qcom/venus/venc.c | 29 +++++++++++++++++++
.../media/platform/qcom/venus/venc_ctrls.c | 16 +++++++++-
5 files changed, 74 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h
index a252ed32cc14..adbcda6e9386 100644
--- a/drivers/media/platform/qcom/venus/core.h
+++ b/drivers/media/platform/qcom/venus/core.h
@@ -238,6 +238,8 @@ struct venc_controls {
} level;

u32 base_priority_id;
+ struct v4l2_ctrl_hdr10_cll_info cll;
+ struct v4l2_ctrl_hdr10_mastering_display mastering;
};

struct venus_buffer {
diff --git a/drivers/media/platform/qcom/venus/hfi_cmds.c b/drivers/media/platform/qcom/venus/hfi_cmds.c
index 4f7565834469..d2edf3896cf1 100644
--- a/drivers/media/platform/qcom/venus/hfi_cmds.c
+++ b/drivers/media/platform/qcom/venus/hfi_cmds.c
@@ -1217,6 +1217,14 @@ pkt_session_set_property_4xx(struct hfi_session_set_property_pkt *pkt,
pkt->shdr.hdr.size += sizeof(u32) + sizeof(*info);
break;
}
+ case HFI_PROPERTY_PARAM_VENC_HDR10_PQ_SEI: {
+ struct hfi_hdr10_pq_sei *in = pdata, *hdr10 = prop_data;
+
+ memcpy(hdr10, in, sizeof(*hdr10));
+ pkt->shdr.hdr.size += sizeof(u32) + sizeof(*hdr10);
+ break;
+ }
+
case HFI_PROPERTY_CONFIG_VENC_MAX_BITRATE:
case HFI_PROPERTY_CONFIG_VDEC_POST_LOOP_DEBLOCKER:
case HFI_PROPERTY_PARAM_BUFFER_ALLOC_MODE:
diff --git a/drivers/media/platform/qcom/venus/hfi_helper.h b/drivers/media/platform/qcom/venus/hfi_helper.h
index 6b524c7cde5f..d32d926c7b2c 100644
--- a/drivers/media/platform/qcom/venus/hfi_helper.h
+++ b/drivers/media/platform/qcom/venus/hfi_helper.h
@@ -513,6 +513,7 @@
#define HFI_PROPERTY_PARAM_VENC_VPX_ERROR_RESILIENCE_MODE 0x2005029
#define HFI_PROPERTY_PARAM_VENC_HIER_B_MAX_NUM_ENH_LAYER 0x200502c
#define HFI_PROPERTY_PARAM_VENC_HIER_P_HYBRID_MODE 0x200502f
+#define HFI_PROPERTY_PARAM_VENC_HDR10_PQ_SEI 0x2005036

/*
* HFI_PROPERTY_CONFIG_VENC_COMMON_START
@@ -809,6 +810,25 @@ struct hfi_ltr_mark {
u32 mark_frame;
};

+struct hfi_mastering_display_colour_sei_payload {
+ u32 display_primaries_x[3];
+ u32 display_primaries_y[3];
+ u32 white_point_x;
+ u32 white_point_y;
+ u32 max_display_mastering_luminance;
+ u32 min_display_mastering_luminance;
+};
+
+struct hfi_content_light_level_sei_payload {
+ u32 max_content_light;
+ u32 max_pic_average_light;
+};
+
+struct hfi_hdr10_pq_sei {
+ struct hfi_mastering_display_colour_sei_payload mastering;
+ struct hfi_content_light_level_sei_payload cll;
+};
+
struct hfi_framesize {
u32 buffer_type;
u32 width;
diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c
index 6976ed553647..192b8c4ef778 100644
--- a/drivers/media/platform/qcom/venus/venc.c
+++ b/drivers/media/platform/qcom/venus/venc.c
@@ -612,6 +612,35 @@ static int venc_set_properties(struct venus_inst *inst)
return ret;
}

+ if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) {
+ struct hfi_hdr10_pq_sei hdr10;
+ unsigned int c;
+
+ ptype = HFI_PROPERTY_PARAM_VENC_HDR10_PQ_SEI;
+
+ for (c = 0; c < 3; c++) {
+ hdr10.mastering.display_primaries_x[c] =
+ ctr->mastering.display_primaries_x[c];
+ hdr10.mastering.display_primaries_y[c] =
+ ctr->mastering.display_primaries_y[c];
+ }
+
+ hdr10.mastering.white_point_x = ctr->mastering.white_point_x;
+ hdr10.mastering.white_point_y = ctr->mastering.white_point_y;
+ hdr10.mastering.max_display_mastering_luminance =
+ ctr->mastering.max_display_mastering_luminance;
+ hdr10.mastering.min_display_mastering_luminance =
+ ctr->mastering.min_display_mastering_luminance;
+
+ hdr10.cll.max_content_light = ctr->cll.max_content_light_level;
+ hdr10.cll.max_pic_average_light =
+ ctr->cll.max_pic_average_light_level;
+
+ ret = hfi_session_set_property(inst, ptype, &hdr10);
+ if (ret)
+ return ret;
+ }
+
if (ctr->num_b_frames) {
u32 max_num_b_frames = NUM_B_FRAMES_MAX;

diff --git a/drivers/media/platform/qcom/venus/venc_ctrls.c b/drivers/media/platform/qcom/venus/venc_ctrls.c
index a52b80055173..52ae665f361e 100644
--- a/drivers/media/platform/qcom/venus/venc_ctrls.c
+++ b/drivers/media/platform/qcom/venus/venc_ctrls.c
@@ -276,6 +276,12 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl)
case V4L2_CID_MPEG_VIDEO_BASELAYER_PRIORITY_ID:
ctr->base_priority_id = ctrl->val;
break;
+ case V4L2_CID_COLORIMETRY_HDR10_CLL_INFO:
+ ctr->cll = *ctrl->p_new.p_hdr10_cll;
+ break;
+ case V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY:
+ ctr->mastering = *ctrl->p_new.p_hdr10_mastering;
+ break;
default:
return -EINVAL;
}
@@ -291,7 +297,7 @@ int venc_ctrl_init(struct venus_inst *inst)
{
int ret;

- ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 51);
+ ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 53);
if (ret)
return ret;

@@ -498,6 +504,14 @@ int venc_ctrl_init(struct venus_inst *inst)
V4L2_CID_MPEG_VIDEO_BASELAYER_PRIORITY_ID, 0,
6, 1, 0);

+ v4l2_ctrl_new_std_compound(&inst->ctrl_handler, &venc_ctrl_ops,
+ V4L2_CID_COLORIMETRY_HDR10_CLL_INFO,
+ v4l2_ctrl_ptr_create(NULL));
+
+ v4l2_ctrl_new_std_compound(&inst->ctrl_handler, &venc_ctrl_ops,
+ V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY,
+ v4l2_ctrl_ptr_create(NULL));
+
ret = inst->ctrl_handler.error;
if (ret)
goto err;
--
2.25.1

2021-03-16 15:38:26

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v5 2/5] docs: Document colorimetry class

On 09/02/2021 17:24, Stanimir Varbanov wrote:
> Add a document for ext control colorimetry class.
>
> Signed-off-by: Stanimir Varbanov <[email protected]>
> ---
> .../userspace-api/media/v4l/common.rst | 1 +
> .../media/v4l/ext-ctrls-colorimetry.rst | 22 +++++++++++++++++++
> .../media/v4l/vidioc-g-ext-ctrls.rst | 4 ++++
> 3 files changed, 27 insertions(+)
> create mode 100644 Documentation/userspace-api/media/v4l/ext-ctrls-colorimetry.rst
>
> diff --git a/Documentation/userspace-api/media/v4l/common.rst b/Documentation/userspace-api/media/v4l/common.rst
> index 8c263c5a85d8..ea0435182e44 100644
> --- a/Documentation/userspace-api/media/v4l/common.rst
> +++ b/Documentation/userspace-api/media/v4l/common.rst
> @@ -51,6 +51,7 @@ applicable to all devices.
> ext-ctrls-fm-tx
> ext-ctrls-fm-rx
> ext-ctrls-detect
> + ext-ctrls-colorimetry
> fourcc
> format
> planar-apis
> diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-colorimetry.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-colorimetry.rst
> new file mode 100644
> index 000000000000..862f78b41b32
> --- /dev/null
> +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-colorimetry.rst
> @@ -0,0 +1,22 @@
> +.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
> +
> +.. _colorimetry-controls:
> +
> +*****************************
> +Colorimetry Control Reference
> +*****************************
> +
> +The Colorimetry class includes controls for High Dynamic Range
> +imaging for representing colors in digital images and video. The
> +controls should be used for video and image encoding and decoding
> +as well as in HDMI receivers and transmitters.
> +
> +Colorimetry Control IDs
> +-----------------------
> +
> +.. _colorimetry-control-id:
> +
> +``V4L2_CID_COLORIMETRY_CLASS (class)``
> + The Colorimetry class descriptor. Calling
> + :ref:`VIDIOC_QUERYCTRL` for this control will
> + return a description of this control class.
> diff --git a/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst b/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst
> index b9c62affbb5a..8a95ebdd499a 100644
> --- a/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst
> +++ b/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst
> @@ -394,6 +394,10 @@ still cause this situation.
> - 0xa40000
> - The class containing stateless codec controls. These controls are
> described in :ref:`codec-stateless-controls`.
> + * - ``V4L2_CTRL_CLASS_COLORIMETRY``
> + - 0xa50000
> + - The class containing colorimetry controls. These controls are
> + described in :ref:`colorimetry-controls`.
>
> Return Value
> ============
>

Reviewed-by: Hans Verkuil <[email protected]>

Regards,

Hans

2021-03-16 15:47:08

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v5 4/5] docs: Document CLL and Mastering display colorimetry controls

On 09/02/2021 17:24, Stanimir Varbanov wrote:
> Document Content Light Level and Mastering Display v4l2 colorimetry
> controls.
>
> Signed-off-by: Stanimir Varbanov <[email protected]>
> ---
> .../media/v4l/ext-ctrls-colorimetry.rst | 71 +++++++++++++++++++
> .../media/v4l/vidioc-g-ext-ctrls.rst | 8 +++
> .../media/videodev2.h.rst.exceptions | 2 +
> 3 files changed, 81 insertions(+)
>
> diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-colorimetry.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-colorimetry.rst
> index 862f78b41b32..a9f206a46175 100644
> --- a/Documentation/userspace-api/media/v4l/ext-ctrls-colorimetry.rst
> +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-colorimetry.rst
> @@ -20,3 +20,74 @@ Colorimetry Control IDs
> The Colorimetry class descriptor. Calling
> :ref:`VIDIOC_QUERYCTRL` for this control will
> return a description of this control class.
> +
> +``V4L2_CID_COLORIMETRY_HDR10_CLL_INFO (struct)``
> + The Content Light Level defines upper bounds for the nominal target
> + brightness light level of the pictures.
> +
> +.. c:type:: v4l2_ctrl_hdr10_cll_info
> +
> +.. cssclass:: longtable
> +
> +.. flat-table:: struct v4l2_ctrl_hdr10_cll_info
> + :header-rows: 0
> + :stub-columns: 0
> + :widths: 1 1 2
> +
> + * - __u16
> + - ``max_content_light_level``
> + - The upper bound for the maximum light level among all individual
> + samples for the pictures of a coded video sequence, cd/m\ :sup:`2`.

I think 'coded' should be removed. This is equally valid when receiving
uncoded HDMI video, after all.

> + When equal to 0 no such upper bound is present.
> + * - __u16
> + - ``max_pic_average_light_level``
> + - The upper bound for the maximum average light level among the
> + samples for any individual picture of a coded video sequence,

ditto.

> + cd/m\ :sup:`2`. When equal to 0 no such upper bound is present.
> +
> +``V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY (struct)``
> + The mastering display defines the color volume (the color primaries,
> + white point and luminance range) of a display considered to be the
> + mastering display for the current video content.
> +
> +.. c:type:: v4l2_ctrl_hdr10_mastering_display
> +
> +.. cssclass:: longtable
> +
> +.. flat-table:: struct v4l2_ctrl_hdr10_mastering_display
> + :header-rows: 0
> + :stub-columns: 0
> + :widths: 1 1 2
> +
> + * - __u16
> + - ``display_primaries_x[3]``
> + - Specifies the normalized x chromaticity coordinate of the color
> + primary component c of the mastering display in increments of 0.00002.
> + For describing the mastering display that uses Red, Green and Blue
> + color primaries, index value c equal to 0 corresponds to the Green
> + primary, c equal to 1 corresponds to Blue primary and c equal to 2
> + corresponds to the Red color primary.
> + * - __u16
> + - ``display_primaries_y[3]``
> + - Specifies the normalized y chromaticity coordinate of the color
> + primary component c of the mastering display in increments of 0.00002.
> + For describing the mastering display that uses Red, Green and Blue
> + color primaries, index value c equal to 0 corresponds to the Green
> + primary, c equal to 1 corresponds to Blue primary and c equal to 2
> + corresponds to Red color primary.
> + * - __u16
> + - ``white_point_x``
> + - Specifies the normalized x chromaticity coordinate of the white
> + point of the mastering display in increments of 0.00002.
> + * - __u16
> + - ``white_point_y``
> + - Specifies the normalized y chromaticity coordinate of the white
> + point of the mastering display in increments of 0.00002.
> + * - __u32
> + - ``max_luminance``
> + - Specifies the nominal maximum display luminance of the mastering
> + display in units of 0.0001 cd/m\ :sup:`2`.
> + * - __u32
> + - ``min_luminance``
> + - specifies the nominal minimum display luminance of the mastering
> + display in units of 0.0001 cd/m\ :sup:`2`.
> diff --git a/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst b/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst
> index 8a95ebdd499a..2f6d0539fb93 100644
> --- a/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst
> +++ b/Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst
> @@ -212,6 +212,14 @@ still cause this situation.
> - ``p_fwht_params``
> - A pointer to a struct :c:type:`v4l2_ctrl_fwht_params`. Valid if this control is
> of type ``V4L2_CTRL_TYPE_FWHT_PARAMS``.
> + * - struct :c:type:`v4l2_ctrl_hdr10_cll_info` *
> + - ``p_hdr10_cll``
> + - A pointer to a struct :c:type:`v4l2_ctrl_hdr10_cll_info`. Valid if this control is
> + of type ``V4L2_CTRL_TYPE_HDR10_CLL_INFO``.
> + * - struct :c:type:`v4l2_ctrl_hdr10_mastering_display` *
> + - ``p_hdr10_mastering``
> + - A pointer to a struct :c:type:`v4l2_ctrl_hdr10_mastering_display`. Valid if this control is
> + of type ``V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY``.
> * - void *
> - ``ptr``
> - A pointer to a compound type which can be an N-dimensional array
> diff --git a/Documentation/userspace-api/media/videodev2.h.rst.exceptions b/Documentation/userspace-api/media/videodev2.h.rst.exceptions
> index 0ed170c6e720..38b31a9b9580 100644
> --- a/Documentation/userspace-api/media/videodev2.h.rst.exceptions
> +++ b/Documentation/userspace-api/media/videodev2.h.rst.exceptions
> @@ -147,6 +147,8 @@ replace symbol V4L2_CTRL_TYPE_HEVC_PPS :c:type:`v4l2_ctrl_type`
> replace symbol V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS :c:type:`v4l2_ctrl_type`
> replace symbol V4L2_CTRL_TYPE_AREA :c:type:`v4l2_ctrl_type`
> replace symbol V4L2_CTRL_TYPE_FWHT_PARAMS :c:type:`v4l2_ctrl_type`
> +replace symbol V4L2_CTRL_TYPE_HDR10_CLL_INFO :c:type:`v4l2_ctrl_type`
> +replace symbol V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY :c:type:`v4l2_ctrl_type`
>
> # V4L2 capability defines
> replace define V4L2_CAP_VIDEO_CAPTURE device-capabilities
>

After making the change suggested above, you can add my:

Reviewed-by: Hans Verkuil <[email protected]>

Regards,

Hans

2021-03-16 18:31:30

by Stanimir Varbanov

[permalink] [raw]
Subject: Re: [PATCH v5 0/5] HDR10 static metadata

Hans, any comments?

On 2/9/21 6:24 PM, Stanimir Varbanov wrote:
> Changes since v4:
> * 1/5 - fixed a typo (Hans)
> * 2/5 - add some mode info about new colorimetry class (Hans)
> * 4/5 - correct cd/m2 -> cd/m\ :sup:`2`
> - change to US spelling for color word
> - use correct v4l2_ctrl_type in videodev2.h.rst.exceptions
> - documented p_hdr10_cll and p_hdr10_mastering in vidioc-g-ext-ctrls.rst
>
> Comments are welcome!
>
> regards,
> Stan
>
> Stanimir Varbanov (5):
> v4l: Add new Colorimetry Class
> docs: Document colorimetry class
> v4l: Add HDR10 static metadata controls
> docs: Document CLL and Mastering display colorimetry controls
> venus: venc: Add support for CLL and Mastering display controls
>
> .../userspace-api/media/v4l/common.rst | 1 +
> .../media/v4l/ext-ctrls-colorimetry.rst | 93 +++++++++++++++++++
> .../media/v4l/vidioc-g-ext-ctrls.rst | 12 +++
> .../media/videodev2.h.rst.exceptions | 2 +
> drivers/media/platform/qcom/venus/core.h | 2 +
> drivers/media/platform/qcom/venus/hfi_cmds.c | 8 ++
> .../media/platform/qcom/venus/hfi_helper.h | 20 ++++
> drivers/media/platform/qcom/venus/venc.c | 29 ++++++
> .../media/platform/qcom/venus/venc_ctrls.c | 16 +++-
> drivers/media/v4l2-core/v4l2-ctrls.c | 74 ++++++++++++++-
> include/media/v4l2-ctrls.h | 4 +
> include/uapi/linux/v4l2-controls.h | 35 +++++++
> include/uapi/linux/videodev2.h | 3 +
> 13 files changed, 297 insertions(+), 2 deletions(-)
> create mode 100644 Documentation/userspace-api/media/v4l/ext-ctrls-colorimetry.rst
>

--
regards,
Stan

2021-03-16 18:46:07

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v5 1/5] v4l: Add new Colorimetry Class

On 09/02/2021 17:24, Stanimir Varbanov wrote:
> Add Colorimetry control class for colorimetry controls
>
> Signed-off-by: Stanimir Varbanov <[email protected]>
> ---
> drivers/media/v4l2-core/v4l2-ctrls.c | 7 ++++++-
> include/uapi/linux/v4l2-controls.h | 4 ++++
> 2 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
> index 016cf6204cbb..335cf354f51b 100644
> --- a/drivers/media/v4l2-core/v4l2-ctrls.c
> +++ b/drivers/media/v4l2-core/v4l2-ctrls.c
> @@ -1201,6 +1201,10 @@ const char *v4l2_ctrl_get_name(u32 id)
> case V4L2_CID_STATELESS_H264_SLICE_PARAMS: return "H264 Slice Parameters";
> case V4L2_CID_STATELESS_H264_DECODE_PARAMS: return "H264 Decode Parameters";
> case V4L2_CID_STATELESS_FWHT_PARAMS: return "FWHT Stateless Parameters";
> +
> + /* Colorimetry controls */
> + /* Keep the order of the 'case's the same as in v4l2-controls.h! */
> + case V4L2_CID_COLORIMETRY_CLASS: return "Colorimetry Controls";
> default:
> return NULL;
> }
> @@ -1389,8 +1393,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
> case V4L2_CID_RF_TUNER_CLASS:
> case V4L2_CID_DETECT_CLASS:
> case V4L2_CID_CODEC_STATELESS_CLASS:
> + case V4L2_CID_COLORIMETRY_CLASS:
> *type = V4L2_CTRL_TYPE_CTRL_CLASS;
> - /* You can neither read not write these */
> + /* You can neither read nor write these */
> *flags |= V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_WRITE_ONLY;
> *min = *max = *step = *def = 0;
> break;
> diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
> index 039c0d7add1b..a41039559193 100644
> --- a/include/uapi/linux/v4l2-controls.h
> +++ b/include/uapi/linux/v4l2-controls.h
> @@ -66,6 +66,7 @@
> #define V4L2_CTRL_CLASS_RF_TUNER 0x00a20000 /* RF tuner controls */
> #define V4L2_CTRL_CLASS_DETECT 0x00a30000 /* Detection controls */
> #define V4L2_CTRL_CLASS_CODEC_STATELESS 0x00a40000 /* Stateless codecs controls */
> +#define V4L2_CTRL_CLASS_COLORIMETRY 0x00a50000 /* Colorimetry controls */
>
> /* User-class control IDs */
>
> @@ -1657,6 +1658,9 @@ struct v4l2_ctrl_fwht_params {
> __u32 quantization;
> };
>
> +#define V4L2_CID_COLORIMETRY_CLASS_BASE (V4L2_CTRL_CLASS_COLORIMETRY | 0x900)
> +#define V4L2_CID_COLORIMETRY_CLASS (V4L2_CTRL_CLASS_COLORIMETRY | 1)
> +
> /* MPEG-compression definitions kept for backwards compatibility */
> #ifndef __KERNEL__
> #define V4L2_CTRL_CLASS_MPEG V4L2_CTRL_CLASS_CODEC
>

Reviewed-by: Hans Verkuil <[email protected]>

Regards,

Hans

2021-03-16 18:50:22

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v5 3/5] v4l: Add HDR10 static metadata controls

On 09/02/2021 17:24, Stanimir Varbanov wrote:
> Introduce Content light level and Mastering display colour
> volume Colorimetry compound controls with relevant payload
> structures and validation.
>
> Signed-off-by: Stanimir Varbanov <[email protected]>
> ---
> drivers/media/v4l2-core/v4l2-ctrls.c | 67 ++++++++++++++++++++++++++++
> include/media/v4l2-ctrls.h | 4 ++
> include/uapi/linux/v4l2-controls.h | 31 +++++++++++++
> include/uapi/linux/videodev2.h | 3 ++
> 4 files changed, 105 insertions(+)
>
> diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
> index 335cf354f51b..8bd3cf0e1e4f 100644
> --- a/drivers/media/v4l2-core/v4l2-ctrls.c
> +++ b/drivers/media/v4l2-core/v4l2-ctrls.c
> @@ -1205,6 +1205,8 @@ const char *v4l2_ctrl_get_name(u32 id)
> /* Colorimetry controls */
> /* Keep the order of the 'case's the same as in v4l2-controls.h! */
> case V4L2_CID_COLORIMETRY_CLASS: return "Colorimetry Controls";
> + case V4L2_CID_COLORIMETRY_HDR10_CLL_INFO: return "HDR10 Content Light Info";
> + case V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY: return "HDR10 Mastering Display";
> default:
> return NULL;
> }
> @@ -1491,6 +1493,12 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
> *type = V4L2_CTRL_TYPE_AREA;
> *flags |= V4L2_CTRL_FLAG_READ_ONLY;
> break;
> + case V4L2_CID_COLORIMETRY_HDR10_CLL_INFO:
> + *type = V4L2_CTRL_TYPE_HDR10_CLL_INFO;
> + break;
> + case V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY:
> + *type = V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY;
> + break;
> default:
> *type = V4L2_CTRL_TYPE_INTEGER;
> break;
> @@ -1786,6 +1794,12 @@ static void std_log(const struct v4l2_ctrl *ctrl)
> case V4L2_CTRL_TYPE_FWHT_PARAMS:
> pr_cont("FWHT_PARAMS");
> break;
> + case V4L2_CTRL_TYPE_HDR10_CLL_INFO:
> + pr_cont("HDR10_CLL_INFO");
> + break;
> + case V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY:
> + pr_cont("HDR10_MASTERING_DISPLAY");
> + break;
> default:
> pr_cont("unknown type %d", ctrl->type);
> break;
> @@ -1838,6 +1852,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
> struct v4l2_ctrl_hevc_sps *p_hevc_sps;
> struct v4l2_ctrl_hevc_pps *p_hevc_pps;
> struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params;
> + struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering;
> struct v4l2_area *area;
> void *p = ptr.p + idx * ctrl->elem_size;
> unsigned int i;
> @@ -2133,6 +2148,52 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
> zero_padding(*p_hevc_slice_params);
> break;
>
> + case V4L2_CTRL_TYPE_HDR10_CLL_INFO:
> + break;
> +
> + case V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY:
> + p_hdr10_mastering = p;
> +
> + for (i = 0; i < 3; ++i) {
> + if (p_hdr10_mastering->display_primaries_x[i] <
> + V4L2_HDR10_MASTERING_PRIMARIES_X_LOW ||
> + p_hdr10_mastering->display_primaries_x[i] >
> + V4L2_HDR10_MASTERING_PRIMARIES_X_HIGH ||
> + p_hdr10_mastering->display_primaries_y[i] <
> + V4L2_HDR10_MASTERING_PRIMARIES_Y_LOW ||
> + p_hdr10_mastering->display_primaries_y[i] >
> + V4L2_HDR10_MASTERING_PRIMARIES_Y_HIGH)
> + 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)
> + return -EINVAL;
> +
> + if (p_hdr10_mastering->max_display_mastering_luminance ==
> + V4L2_HDR10_MASTERING_MAX_LUMA_LOW &&
> + p_hdr10_mastering->min_display_mastering_luminance ==
> + V4L2_HDR10_MASTERING_MIN_LUMA_HIGH)

I had to think about this one :-)

Isn't it clearer to write:

if (p_hdr10_mastering->min_display_mastering_luminance >=
p_hdr10_mastering->max_display_mastering_luminance)

(even though it can't be >, but >= is probably more robust and future proof)

And is it indeed invalid if both are the same?

> + return -EINVAL;
> +
> + break;
> +
> case V4L2_CTRL_TYPE_AREA:
> area = p;
> if (!area->width || !area->height)
> @@ -2826,6 +2887,12 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,
> case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
> elem_size = sizeof(struct v4l2_ctrl_hevc_slice_params);
> break;
> + case V4L2_CTRL_TYPE_HDR10_CLL_INFO:
> + elem_size = sizeof(struct v4l2_ctrl_hdr10_cll_info);
> + break;
> + case V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY:
> + elem_size = sizeof(struct v4l2_ctrl_hdr10_mastering_display);
> + break;
> case V4L2_CTRL_TYPE_AREA:
> elem_size = sizeof(struct v4l2_area);
> break;
> diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
> index 167ca8c8424f..9c3ddbf3d099 100644
> --- a/include/media/v4l2-ctrls.h
> +++ b/include/media/v4l2-ctrls.h
> @@ -54,6 +54,8 @@ struct video_device;
> * @p_hevc_sps: Pointer to an HEVC sequence parameter set structure.
> * @p_hevc_pps: Pointer to an HEVC picture parameter set structure.
> * @p_hevc_slice_params: Pointer to an HEVC slice parameters structure.
> + * @p_hdr10_cll: Pointer to an HDR10 Content Light Level structure.
> + * @p_hdr10_mastering: Pointer to an HDR10 Mastering Display structure.
> * @p_area: Pointer to an area.
> * @p: Pointer to a compound value.
> * @p_const: Pointer to a constant compound value.
> @@ -78,6 +80,8 @@ union v4l2_ctrl_ptr {
> struct v4l2_ctrl_hevc_sps *p_hevc_sps;
> struct v4l2_ctrl_hevc_pps *p_hevc_pps;
> struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params;
> + struct v4l2_ctrl_hdr10_cll_info *p_hdr10_cll;
> + struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering;
> struct v4l2_area *p_area;
> void *p;
> const void *p_const;
> diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
> index a41039559193..349e86b18af7 100644
> --- a/include/uapi/linux/v4l2-controls.h
> +++ b/include/uapi/linux/v4l2-controls.h
> @@ -1661,6 +1661,37 @@ struct v4l2_ctrl_fwht_params {
> #define V4L2_CID_COLORIMETRY_CLASS_BASE (V4L2_CTRL_CLASS_COLORIMETRY | 0x900)
> #define V4L2_CID_COLORIMETRY_CLASS (V4L2_CTRL_CLASS_COLORIMETRY | 1)
>
> +#define V4L2_CID_COLORIMETRY_HDR10_CLL_INFO (V4L2_CID_COLORIMETRY_CLASS_BASE + 0)
> +
> +struct v4l2_ctrl_hdr10_cll_info {
> + __u16 max_content_light_level;
> + __u16 max_pic_average_light_level;
> +};
> +
> +#define V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY (V4L2_CID_COLORIMETRY_CLASS_BASE + 1)
> +
> +#define V4L2_HDR10_MASTERING_PRIMARIES_X_LOW 5
> +#define V4L2_HDR10_MASTERING_PRIMARIES_X_HIGH 37000
> +#define V4L2_HDR10_MASTERING_PRIMARIES_Y_LOW 5
> +#define V4L2_HDR10_MASTERING_PRIMARIES_Y_HIGH 42000
> +#define V4L2_HDR10_MASTERING_WHITE_POINT_X_LOW 5
> +#define V4L2_HDR10_MASTERING_WHITE_POINT_X_HIGH 37000
> +#define V4L2_HDR10_MASTERING_WHITE_POINT_Y_LOW 5
> +#define V4L2_HDR10_MASTERING_WHITE_POINT_Y_HIGH 42000
> +#define V4L2_HDR10_MASTERING_MAX_LUMA_LOW 50000
> +#define V4L2_HDR10_MASTERING_MAX_LUMA_HIGH 100000000
> +#define V4L2_HDR10_MASTERING_MIN_LUMA_LOW 1
> +#define V4L2_HDR10_MASTERING_MIN_LUMA_HIGH 50000
> +
> +struct v4l2_ctrl_hdr10_mastering_display {
> + __u16 display_primaries_x[3];
> + __u16 display_primaries_y[3];
> + __u16 white_point_x;
> + __u16 white_point_y;
> + __u32 max_display_mastering_luminance;
> + __u32 min_display_mastering_luminance;
> +};
> +
> /* MPEG-compression definitions kept for backwards compatibility */
> #ifndef __KERNEL__
> #define V4L2_CTRL_CLASS_MPEG V4L2_CTRL_CLASS_CODEC
> diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
> index 79dbde3bcf8d..f5f971407b66 100644
> --- a/include/uapi/linux/videodev2.h
> +++ b/include/uapi/linux/videodev2.h
> @@ -1784,6 +1784,9 @@ enum v4l2_ctrl_type {
> V4L2_CTRL_TYPE_U32 = 0x0102,
> V4L2_CTRL_TYPE_AREA = 0x0106,
>
> + V4L2_CTRL_TYPE_HDR10_CLL_INFO = 0x0110,
> + V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY = 0x0111,
> +
> V4L2_CTRL_TYPE_H264_SPS = 0x0200,
> V4L2_CTRL_TYPE_H264_PPS = 0x0201,
> V4L2_CTRL_TYPE_H264_SCALING_MATRIX = 0x0202,
>

Regards,

Hans

2021-03-22 13:11:54

by Stanimir Varbanov

[permalink] [raw]
Subject: Re: [PATCH v5 3/5] v4l: Add HDR10 static metadata controls

Hi Hans,

On 3/16/21 2:16 PM, Hans Verkuil wrote:
> On 09/02/2021 17:24, Stanimir Varbanov wrote:
>> Introduce Content light level and Mastering display colour
>> volume Colorimetry compound controls with relevant payload
>> structures and validation.
>>
>> Signed-off-by: Stanimir Varbanov <[email protected]>
>> ---
>> drivers/media/v4l2-core/v4l2-ctrls.c | 67 ++++++++++++++++++++++++++++
>> include/media/v4l2-ctrls.h | 4 ++
>> include/uapi/linux/v4l2-controls.h | 31 +++++++++++++
>> include/uapi/linux/videodev2.h | 3 ++
>> 4 files changed, 105 insertions(+)
>>
>> diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
>> index 335cf354f51b..8bd3cf0e1e4f 100644
>> --- a/drivers/media/v4l2-core/v4l2-ctrls.c
>> +++ b/drivers/media/v4l2-core/v4l2-ctrls.c
>> @@ -1205,6 +1205,8 @@ const char *v4l2_ctrl_get_name(u32 id)
>> /* Colorimetry controls */
>> /* Keep the order of the 'case's the same as in v4l2-controls.h! */
>> case V4L2_CID_COLORIMETRY_CLASS: return "Colorimetry Controls";
>> + case V4L2_CID_COLORIMETRY_HDR10_CLL_INFO: return "HDR10 Content Light Info";
>> + case V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY: return "HDR10 Mastering Display";
>> default:
>> return NULL;
>> }
>> @@ -1491,6 +1493,12 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
>> *type = V4L2_CTRL_TYPE_AREA;
>> *flags |= V4L2_CTRL_FLAG_READ_ONLY;
>> break;
>> + case V4L2_CID_COLORIMETRY_HDR10_CLL_INFO:
>> + *type = V4L2_CTRL_TYPE_HDR10_CLL_INFO;
>> + break;
>> + case V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY:
>> + *type = V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY;
>> + break;
>> default:
>> *type = V4L2_CTRL_TYPE_INTEGER;
>> break;
>> @@ -1786,6 +1794,12 @@ static void std_log(const struct v4l2_ctrl *ctrl)
>> case V4L2_CTRL_TYPE_FWHT_PARAMS:
>> pr_cont("FWHT_PARAMS");
>> break;
>> + case V4L2_CTRL_TYPE_HDR10_CLL_INFO:
>> + pr_cont("HDR10_CLL_INFO");
>> + break;
>> + case V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY:
>> + pr_cont("HDR10_MASTERING_DISPLAY");
>> + break;
>> default:
>> pr_cont("unknown type %d", ctrl->type);
>> break;
>> @@ -1838,6 +1852,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
>> struct v4l2_ctrl_hevc_sps *p_hevc_sps;
>> struct v4l2_ctrl_hevc_pps *p_hevc_pps;
>> struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params;
>> + struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering;
>> struct v4l2_area *area;
>> void *p = ptr.p + idx * ctrl->elem_size;
>> unsigned int i;
>> @@ -2133,6 +2148,52 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
>> zero_padding(*p_hevc_slice_params);
>> break;
>>
>> + case V4L2_CTRL_TYPE_HDR10_CLL_INFO:
>> + break;
>> +
>> + case V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY:
>> + p_hdr10_mastering = p;
>> +
>> + for (i = 0; i < 3; ++i) {
>> + if (p_hdr10_mastering->display_primaries_x[i] <
>> + V4L2_HDR10_MASTERING_PRIMARIES_X_LOW ||
>> + p_hdr10_mastering->display_primaries_x[i] >
>> + V4L2_HDR10_MASTERING_PRIMARIES_X_HIGH ||
>> + p_hdr10_mastering->display_primaries_y[i] <
>> + V4L2_HDR10_MASTERING_PRIMARIES_Y_LOW ||
>> + p_hdr10_mastering->display_primaries_y[i] >
>> + V4L2_HDR10_MASTERING_PRIMARIES_Y_HIGH)
>> + 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)
>> + return -EINVAL;
>> +
>> + if (p_hdr10_mastering->max_display_mastering_luminance ==
>> + V4L2_HDR10_MASTERING_MAX_LUMA_LOW &&
>> + p_hdr10_mastering->min_display_mastering_luminance ==
>> + V4L2_HDR10_MASTERING_MIN_LUMA_HIGH)
>
> I had to think about this one :-)
>
> Isn't it clearer to write:
>
> if (p_hdr10_mastering->min_display_mastering_luminance >=
> p_hdr10_mastering->max_display_mastering_luminance)
>
> (even though it can't be >, but >= is probably more robust and future proof)
>
> And is it indeed invalid if both are the same?

This what the ITU-T Rec. H.265 spec says:

"When max_display_mastering_luminance is equal to 50 000,
min_display_mastering_luminance shall not be equal to 50 000."


--
regards,
Stan

2021-03-22 13:56:39

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v5 3/5] v4l: Add HDR10 static metadata controls

On 22/03/2021 13:56, Stanimir Varbanov wrote:
> Hi Hans,
>
> On 3/16/21 2:16 PM, Hans Verkuil wrote:
>> On 09/02/2021 17:24, Stanimir Varbanov wrote:
>>> Introduce Content light level and Mastering display colour
>>> volume Colorimetry compound controls with relevant payload
>>> structures and validation.
>>>
>>> Signed-off-by: Stanimir Varbanov <[email protected]>
>>> ---
>>> drivers/media/v4l2-core/v4l2-ctrls.c | 67 ++++++++++++++++++++++++++++
>>> include/media/v4l2-ctrls.h | 4 ++
>>> include/uapi/linux/v4l2-controls.h | 31 +++++++++++++
>>> include/uapi/linux/videodev2.h | 3 ++
>>> 4 files changed, 105 insertions(+)
>>>
>>> diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
>>> index 335cf354f51b..8bd3cf0e1e4f 100644
>>> --- a/drivers/media/v4l2-core/v4l2-ctrls.c
>>> +++ b/drivers/media/v4l2-core/v4l2-ctrls.c
>>> @@ -1205,6 +1205,8 @@ const char *v4l2_ctrl_get_name(u32 id)
>>> /* Colorimetry controls */
>>> /* Keep the order of the 'case's the same as in v4l2-controls.h! */
>>> case V4L2_CID_COLORIMETRY_CLASS: return "Colorimetry Controls";
>>> + case V4L2_CID_COLORIMETRY_HDR10_CLL_INFO: return "HDR10 Content Light Info";
>>> + case V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY: return "HDR10 Mastering Display";
>>> default:
>>> return NULL;
>>> }
>>> @@ -1491,6 +1493,12 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
>>> *type = V4L2_CTRL_TYPE_AREA;
>>> *flags |= V4L2_CTRL_FLAG_READ_ONLY;
>>> break;
>>> + case V4L2_CID_COLORIMETRY_HDR10_CLL_INFO:
>>> + *type = V4L2_CTRL_TYPE_HDR10_CLL_INFO;
>>> + break;
>>> + case V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY:
>>> + *type = V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY;
>>> + break;
>>> default:
>>> *type = V4L2_CTRL_TYPE_INTEGER;
>>> break;
>>> @@ -1786,6 +1794,12 @@ static void std_log(const struct v4l2_ctrl *ctrl)
>>> case V4L2_CTRL_TYPE_FWHT_PARAMS:
>>> pr_cont("FWHT_PARAMS");
>>> break;
>>> + case V4L2_CTRL_TYPE_HDR10_CLL_INFO:
>>> + pr_cont("HDR10_CLL_INFO");
>>> + break;
>>> + case V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY:
>>> + pr_cont("HDR10_MASTERING_DISPLAY");
>>> + break;
>>> default:
>>> pr_cont("unknown type %d", ctrl->type);
>>> break;
>>> @@ -1838,6 +1852,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
>>> struct v4l2_ctrl_hevc_sps *p_hevc_sps;
>>> struct v4l2_ctrl_hevc_pps *p_hevc_pps;
>>> struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params;
>>> + struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering;
>>> struct v4l2_area *area;
>>> void *p = ptr.p + idx * ctrl->elem_size;
>>> unsigned int i;
>>> @@ -2133,6 +2148,52 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
>>> zero_padding(*p_hevc_slice_params);
>>> break;
>>>
>>> + case V4L2_CTRL_TYPE_HDR10_CLL_INFO:
>>> + break;
>>> +
>>> + case V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY:
>>> + p_hdr10_mastering = p;
>>> +
>>> + for (i = 0; i < 3; ++i) {
>>> + if (p_hdr10_mastering->display_primaries_x[i] <
>>> + V4L2_HDR10_MASTERING_PRIMARIES_X_LOW ||
>>> + p_hdr10_mastering->display_primaries_x[i] >
>>> + V4L2_HDR10_MASTERING_PRIMARIES_X_HIGH ||
>>> + p_hdr10_mastering->display_primaries_y[i] <
>>> + V4L2_HDR10_MASTERING_PRIMARIES_Y_LOW ||
>>> + p_hdr10_mastering->display_primaries_y[i] >
>>> + V4L2_HDR10_MASTERING_PRIMARIES_Y_HIGH)
>>> + 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)
>>> + return -EINVAL;
>>> +
>>> + if (p_hdr10_mastering->max_display_mastering_luminance ==
>>> + V4L2_HDR10_MASTERING_MAX_LUMA_LOW &&
>>> + p_hdr10_mastering->min_display_mastering_luminance ==
>>> + V4L2_HDR10_MASTERING_MIN_LUMA_HIGH)
>>
>> I had to think about this one :-)
>>
>> Isn't it clearer to write:
>>
>> if (p_hdr10_mastering->min_display_mastering_luminance >=
>> p_hdr10_mastering->max_display_mastering_luminance)
>>
>> (even though it can't be >, but >= is probably more robust and future proof)
>>
>> And is it indeed invalid if both are the same?
>
> This what the ITU-T Rec. H.265 spec says:
>
> "When max_display_mastering_luminance is equal to 50 000,
> min_display_mastering_luminance shall not be equal to 50 000."

OK. Just add a comment explaining that that restriction comes from the
H.265 spec.

Regards,

Hans

>
>