History

media: v4l2_ctrl: Add V4L2_CTRL_TYPE_RECT

Add p_rect to struct v4l2_ext_control with basic support in v4l2-ctrls.

Yunke Cao committed 1 year ago

Commit 3b9d7341 parent f4b21176 files · +31 −1Browse files

Unified · Split

6 files
  1. Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst +4 −0
  2. Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst +7 −0
  3. Documentation/userspace-api/media/videodev2.h.rst.exceptions +1 −0
  4. drivers/media/v4l2-core/v4l2-ctrls-core.c +15 −1
  5. include/media/v4l2-ctrls.h +2 −0
  6. include/uapi/linux/videodev2.h +2 −0
Documentation/userspace-api/media/v4l/vidioc-g-ext-ctrls.rst+4−0
@@ -199,6 +199,10 @@ still cause this situation. · 198 unmodified lines
199199 - ``p_area``
200200 - A pointer to a struct :c:type:`v4l2_area`. Valid if this control is
201201 of type ``V4L2_CTRL_TYPE_AREA``.
202+ * - struct :c:type:`v4l2_rect` *
203+ - ``p_rect``
204+ - A pointer to a struct :c:type:`v4l2_rect`. Valid if this control is
205+ of type ``V4L2_CTRL_TYPE_RECT``.
202206 * - struct :c:type:`v4l2_ctrl_h264_sps` *
203207 - ``p_h264_sps``
204208 - A pointer to a struct :c:type:`v4l2_ctrl_h264_sps`. Valid if this control is
Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst+7−0
@@ -441,6 +441,13 @@ See also the examples in :ref:`control`. · 440 unmodified lines
441441 - n/a
442442 - A struct :c:type:`v4l2_area`, containing the width and the height
443443 of a rectangular area. Units depend on the use case.
444+ * - ``V4L2_CTRL_TYPE_RECT``
445+ - n/a
446+ - n/a
447+ - n/a
448+ - A struct :c:type:`v4l2_rect`, containing a rectangle described by
449+ the position of its top-left corner, the width and the height. Units
450+ depend on the use case.
444451 * - ``V4L2_CTRL_TYPE_H264_SPS``
445452 - n/a
446453 - n/a
Documentation/userspace-api/media/videodev2.h.rst.exceptions+1−0
@@ -150,6 +150,7 @@ replace symbol V4L2_CTRL_TYPE_HEVC_SPS :c:type:`v4l2_ctrl_type` · 149 unmodified lines
150150 replace symbol V4L2_CTRL_TYPE_HEVC_PPS :c:type:`v4l2_ctrl_type`
151151 replace symbol V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS :c:type:`v4l2_ctrl_type`
152152 replace symbol V4L2_CTRL_TYPE_AREA :c:type:`v4l2_ctrl_type`
153+replace symbol V4L2_CTRL_TYPE_RECT :c:type:`v4l2_ctrl_type`
153154 replace symbol V4L2_CTRL_TYPE_FWHT_PARAMS :c:type:`v4l2_ctrl_type`
154155 replace symbol V4L2_CTRL_TYPE_VP8_FRAME :c:type:`v4l2_ctrl_type`
155156 replace symbol V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR :c:type:`v4l2_ctrl_type`
drivers/media/v4l2-core/v4l2-ctrls-core.c+15−1
@@ -370,7 +370,11 @@ void v4l2_ctrl_type_op_log(const struct v4l2_ctrl *ctrl) · 369 unmodified lines
370370 case V4L2_CTRL_TYPE_AV1_FILM_GRAIN:
371371 pr_cont("AV1_FILM_GRAIN");
372372 break;
373−
373+ case V4L2_CTRL_TYPE_RECT:
374+ pr_cont("%ux%u@%dx%d",
375+ ptr.p_rect->width, ptr.p_rect->height,
376+ ptr.p_rect->left, ptr.p_rect->top);
377+ break;
374378 default:
375379 pr_cont("unknown type %d", ctrl->type);
376380 break;
@@ -815,6 +819,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, · 438 unmodified lines
815819 struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering;
816820 struct v4l2_ctrl_hevc_decode_params *p_hevc_decode_params;
817821 struct v4l2_area *area;
822+ struct v4l2_rect *rect;
818823 void *p = ptr.p + idx * ctrl->elem_size;
819824 unsigned int i;
820825
@@ -1172,6 +1177,12 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, · 351 unmodified lines
11721177 return -EINVAL;
11731178 break;
11741179
1180+ case V4L2_CTRL_TYPE_RECT:
1181+ rect = p;
1182+ if (!rect->width || !rect->height)
1183+ return -EINVAL;
1184+ break;
1185+
11751186 default:
11761187 return -EINVAL;
11771188 }
@@ -1872,6 +1883,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, · 694 unmodified lines
18721883 case V4L2_CTRL_TYPE_AREA:
18731884 elem_size = sizeof(struct v4l2_area);
18741885 break;
1886+ case V4L2_CTRL_TYPE_RECT:
1887+ elem_size = sizeof(struct v4l2_rect);
1888+ break;
18751889 default:
18761890 if (type < V4L2_CTRL_COMPOUND_TYPES)
18771891 elem_size = sizeof(s32);
include/media/v4l2-ctrls.h+2−0
@@ -56,6 +56,7 @@ struct video_device; · 55 unmodified lines
5656 * @p_av1_tile_group_entry: Pointer to an AV1 tile group entry structure.
5757 * @p_av1_frame: Pointer to an AV1 frame structure.
5858 * @p_av1_film_grain: Pointer to an AV1 film grain structure.
59+ * @p_rect: Pointer to a rectangle.
5960 * @p: Pointer to a compound value.
6061 * @p_const: Pointer to a constant compound value.
6162 */
@@ -89,6 +90,7 @@ union v4l2_ctrl_ptr { · 27 unmodified lines
8990 struct v4l2_ctrl_av1_tile_group_entry *p_av1_tile_group_entry;
9091 struct v4l2_ctrl_av1_frame *p_av1_frame;
9192 struct v4l2_ctrl_av1_film_grain *p_av1_film_grain;
93+ struct v4l2_rect *p_rect;
9294 void *p;
9395 const void *p_const;
9496 };
include/uapi/linux/videodev2.h+2−0
@@ -1859,6 +1859,7 @@ struct v4l2_ext_control { · 1858 unmodified lines
18591859 __s32 __user *p_s32;
18601860 __s64 __user *p_s64;
18611861 struct v4l2_area __user *p_area;
1862+ struct v4l2_rect __user *p_rect;
18621863 struct v4l2_ctrl_h264_sps __user *p_h264_sps;
18631864 struct v4l2_ctrl_h264_pps __user *p_h264_pps;
18641865 struct v4l2_ctrl_h264_scaling_matrix __user *p_h264_scaling_matrix;
@@ -1929,6 +1930,7 @@ enum v4l2_ctrl_type { · 64 unmodified lines
19291930 V4L2_CTRL_TYPE_U16 = 0x0101,
19301931 V4L2_CTRL_TYPE_U32 = 0x0102,
19311932 V4L2_CTRL_TYPE_AREA = 0x0106,
1933+ V4L2_CTRL_TYPE_RECT = 0x0107,
19321934
19331935 V4L2_CTRL_TYPE_HDR10_CLL_INFO = 0x0110,
19341936 V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY = 0x0111,