]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: v4l2_ctrl: Add V4L2_CTRL_TYPE_RECT
authorYunke Cao <yunkec@google.com>
Mon, 3 Feb 2025 11:55:37 +0000 (11:55 +0000)
committerHans Verkuil <hverkuil@xs4all.nl>
Mon, 3 Mar 2025 17:23:35 +0000 (18:23 +0100)
Add p_rect to struct v4l2_ext_control with basic support in
v4l2-ctrls.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-by: Yunke Cao <yunkec@google.com>
Reviewed-by: Hans Verkuil <hverkuil@xs4all.nl>
Tested-by: Yunke Cao <yunkec@google.com>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Link: https://lore.kernel.org/r/20250203-uvc-roi-v17-1-5900a9fed613@chromium.org
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst
Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst
Documentation/userspace-api/media/videodev2.h.rst.exceptions
drivers/media/v4l2-core/v4l2-ctrls-core.c
include/media/v4l2-ctrls.h
include/uapi/linux/videodev2.h

index 4d56c0528ad7262b3acbb100edad139f29586917..b74a74ac06fc61cbc0d81d69d5b8a5eb07c3999f 100644 (file)
@@ -199,6 +199,10 @@ still cause this situation.
       - ``p_area``
       - A pointer to a struct :c:type:`v4l2_area`. Valid if this control is
         of type ``V4L2_CTRL_TYPE_AREA``.
+    * - struct :c:type:`v4l2_rect` *
+      - ``p_rect``
+      - A pointer to a struct :c:type:`v4l2_rect`. Valid if this control is
+        of type ``V4L2_CTRL_TYPE_RECT``.
     * - struct :c:type:`v4l2_ctrl_h264_sps` *
       - ``p_h264_sps``
       - A pointer to a struct :c:type:`v4l2_ctrl_h264_sps`. Valid if this control is
index 4d38acafe8e19309ecf1d4550f6578eddc446cc3..56d5c8b0b88b536e1cdd54fff89da426364e7a01 100644 (file)
@@ -441,6 +441,13 @@ See also the examples in :ref:`control`.
       - n/a
       - A struct :c:type:`v4l2_area`, containing the width and the height
         of a rectangular area. Units depend on the use case.
+    * - ``V4L2_CTRL_TYPE_RECT``
+      - n/a
+      - n/a
+      - n/a
+      - A struct :c:type:`v4l2_rect`, containing a rectangle described by
+       the position of its top-left corner, the width and the height. Units
+       depend on the use case.
     * - ``V4L2_CTRL_TYPE_H264_SPS``
       - n/a
       - n/a
index 429b5cdf05c39958a9c8c45b13a3f373c1ba5ad4..3cf1380b52b00254cc2fcedee58a533ba91860b0 100644 (file)
@@ -150,6 +150,7 @@ replace symbol V4L2_CTRL_TYPE_HEVC_SPS :c:type:`v4l2_ctrl_type`
 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_RECT :c:type:`v4l2_ctrl_type`
 replace symbol V4L2_CTRL_TYPE_FWHT_PARAMS :c:type:`v4l2_ctrl_type`
 replace symbol V4L2_CTRL_TYPE_VP8_FRAME :c:type:`v4l2_ctrl_type`
 replace symbol V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR :c:type:`v4l2_ctrl_type`
index eeab6a5eb7baca43985706b9809f5157aebc8e7e..4c8744c8cd9678b5b511497daacd81b7657a5ec2 100644 (file)
@@ -370,7 +370,11 @@ void v4l2_ctrl_type_op_log(const struct v4l2_ctrl *ctrl)
        case V4L2_CTRL_TYPE_AV1_FILM_GRAIN:
                pr_cont("AV1_FILM_GRAIN");
                break;
-
+       case V4L2_CTRL_TYPE_RECT:
+               pr_cont("%ux%u@%dx%d",
+                       ptr.p_rect->width, ptr.p_rect->height,
+                       ptr.p_rect->left, ptr.p_rect->top);
+               break;
        default:
                pr_cont("unknown type %d", ctrl->type);
                break;
@@ -815,6 +819,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
        struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering;
        struct v4l2_ctrl_hevc_decode_params *p_hevc_decode_params;
        struct v4l2_area *area;
+       struct v4l2_rect *rect;
        void *p = ptr.p + idx * ctrl->elem_size;
        unsigned int i;
 
@@ -1172,6 +1177,12 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
                        return -EINVAL;
                break;
 
+       case V4L2_CTRL_TYPE_RECT:
+               rect = p;
+               if (!rect->width || !rect->height)
+                       return -EINVAL;
+               break;
+
        default:
                return -EINVAL;
        }
@@ -1872,6 +1883,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,
        case V4L2_CTRL_TYPE_AREA:
                elem_size = sizeof(struct v4l2_area);
                break;
+       case V4L2_CTRL_TYPE_RECT:
+               elem_size = sizeof(struct v4l2_rect);
+               break;
        default:
                if (type < V4L2_CTRL_COMPOUND_TYPES)
                        elem_size = sizeof(s32);
index 59679a42b3e7f4d2c9b3cc8a2ead1552496de561..b0db167a3ac4c14587efe2379390b8a84ea7c59e 100644 (file)
@@ -56,6 +56,7 @@ struct video_device;
  * @p_av1_tile_group_entry:    Pointer to an AV1 tile group entry structure.
  * @p_av1_frame:               Pointer to an AV1 frame structure.
  * @p_av1_film_grain:          Pointer to an AV1 film grain structure.
+ * @p_rect:                    Pointer to a rectangle.
  * @p:                         Pointer to a compound value.
  * @p_const:                   Pointer to a constant compound value.
  */
@@ -89,6 +90,7 @@ union v4l2_ctrl_ptr {
        struct v4l2_ctrl_av1_tile_group_entry *p_av1_tile_group_entry;
        struct v4l2_ctrl_av1_frame *p_av1_frame;
        struct v4l2_ctrl_av1_film_grain *p_av1_film_grain;
+       struct v4l2_rect *p_rect;
        void *p;
        const void *p_const;
 };
index e7c4dce390074b8b69593f1cd252284616f1b9db..c1c2ae150d30afd12823dbf2bc7833d002110189 100644 (file)
@@ -1859,6 +1859,7 @@ struct v4l2_ext_control {
                __s32 __user *p_s32;
                __s64 __user *p_s64;
                struct v4l2_area __user *p_area;
+               struct v4l2_rect __user *p_rect;
                struct v4l2_ctrl_h264_sps __user *p_h264_sps;
                struct v4l2_ctrl_h264_pps __user *p_h264_pps;
                struct v4l2_ctrl_h264_scaling_matrix __user *p_h264_scaling_matrix;
@@ -1929,6 +1930,7 @@ enum v4l2_ctrl_type {
        V4L2_CTRL_TYPE_U16           = 0x0101,
        V4L2_CTRL_TYPE_U32           = 0x0102,
        V4L2_CTRL_TYPE_AREA          = 0x0106,
+       V4L2_CTRL_TYPE_RECT          = 0x0107,
 
        V4L2_CTRL_TYPE_HDR10_CLL_INFO           = 0x0110,
        V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY  = 0x0111,