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
199 - ``p_area``199 - ``p_area``
200 - A pointer to a struct :c:type:`v4l2_area`. Valid if this control is200 - A pointer to a struct :c:type:`v4l2_area`. Valid if this control is
201 of type ``V4L2_CTRL_TYPE_AREA``.201 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``.
202 * - struct :c:type:`v4l2_ctrl_h264_sps` *206 * - struct :c:type:`v4l2_ctrl_h264_sps` *
203 - ``p_h264_sps``207 - ``p_h264_sps``
204 - A pointer to a struct :c:type:`v4l2_ctrl_h264_sps`. Valid if this control is208 - 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
441 - n/a441 - n/a
442 - A struct :c:type:`v4l2_area`, containing the width and the height442 - A struct :c:type:`v4l2_area`, containing the width and the height
443 of a rectangular area. Units depend on the use case.443 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.
444 * - ``V4L2_CTRL_TYPE_H264_SPS``451 * - ``V4L2_CTRL_TYPE_H264_SPS``
445 - n/a452 - n/a
446 - n/a453 - 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
150replace symbol V4L2_CTRL_TYPE_HEVC_PPS :c:type:`v4l2_ctrl_type`150replace symbol V4L2_CTRL_TYPE_HEVC_PPS :c:type:`v4l2_ctrl_type`
151replace symbol V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS :c:type:`v4l2_ctrl_type`151replace symbol V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS :c:type:`v4l2_ctrl_type`
152replace symbol V4L2_CTRL_TYPE_AREA :c:type:`v4l2_ctrl_type`152replace symbol V4L2_CTRL_TYPE_AREA :c:type:`v4l2_ctrl_type`
153replace symbol V4L2_CTRL_TYPE_RECT :c:type:`v4l2_ctrl_type`
153replace symbol V4L2_CTRL_TYPE_FWHT_PARAMS :c:type:`v4l2_ctrl_type`154replace symbol V4L2_CTRL_TYPE_FWHT_PARAMS :c:type:`v4l2_ctrl_type`
154replace symbol V4L2_CTRL_TYPE_VP8_FRAME :c:type:`v4l2_ctrl_type`155replace symbol V4L2_CTRL_TYPE_VP8_FRAME :c:type:`v4l2_ctrl_type`
155replace symbol V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR :c:type:`v4l2_ctrl_type`156replace 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
370 case V4L2_CTRL_TYPE_AV1_FILM_GRAIN:370 case V4L2_CTRL_TYPE_AV1_FILM_GRAIN:
371 pr_cont("AV1_FILM_GRAIN");371 pr_cont("AV1_FILM_GRAIN");
372 break;372 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;
374 default:378 default:
375 pr_cont("unknown type %d", ctrl->type);379 pr_cont("unknown type %d", ctrl->type);
376 break;380 break;
@@ -815,6 +819,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, · 438 unmodified lines
815 struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering;819 struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering;
816 struct v4l2_ctrl_hevc_decode_params *p_hevc_decode_params;820 struct v4l2_ctrl_hevc_decode_params *p_hevc_decode_params;
817 struct v4l2_area *area;821 struct v4l2_area *area;
822 struct v4l2_rect *rect;
818 void *p = ptr.p + idx * ctrl->elem_size;823 void *p = ptr.p + idx * ctrl->elem_size;
819 unsigned int i;824 unsigned int i;
820 825
@@ -1172,6 +1177,12 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, · 351 unmodified lines
1172 return -EINVAL;1177 return -EINVAL;
1173 break;1178 break;
1174 1179
1180 case V4L2_CTRL_TYPE_RECT:
1181 rect = p;
1182 if (!rect->width || !rect->height)
1183 return -EINVAL;
1184 break;
1185
1175 default:1186 default:
1176 return -EINVAL;1187 return -EINVAL;
1177 }1188 }
@@ -1872,6 +1883,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, · 694 unmodified lines
1872 case V4L2_CTRL_TYPE_AREA:1883 case V4L2_CTRL_TYPE_AREA:
1873 elem_size = sizeof(struct v4l2_area);1884 elem_size = sizeof(struct v4l2_area);
1874 break;1885 break;
1886 case V4L2_CTRL_TYPE_RECT:
1887 elem_size = sizeof(struct v4l2_rect);
1888 break;
1875 default:1889 default:
1876 if (type < V4L2_CTRL_COMPOUND_TYPES)1890 if (type < V4L2_CTRL_COMPOUND_TYPES)
1877 elem_size = sizeof(s32);1891 elem_size = sizeof(s32);
include/media/v4l2-ctrls.h+2−0
@@ -56,6 +56,7 @@ struct video_device; · 55 unmodified lines
56 * @p_av1_tile_group_entry: Pointer to an AV1 tile group entry structure.56 * @p_av1_tile_group_entry: Pointer to an AV1 tile group entry structure.
57 * @p_av1_frame: Pointer to an AV1 frame structure.57 * @p_av1_frame: Pointer to an AV1 frame structure.
58 * @p_av1_film_grain: Pointer to an AV1 film grain structure.58 * @p_av1_film_grain: Pointer to an AV1 film grain structure.
59 * @p_rect: Pointer to a rectangle.
59 * @p: Pointer to a compound value.60 * @p: Pointer to a compound value.
60 * @p_const: Pointer to a constant compound value.61 * @p_const: Pointer to a constant compound value.
61 */62 */
@@ -89,6 +90,7 @@ union v4l2_ctrl_ptr { · 27 unmodified lines
89 struct v4l2_ctrl_av1_tile_group_entry *p_av1_tile_group_entry;90 struct v4l2_ctrl_av1_tile_group_entry *p_av1_tile_group_entry;
90 struct v4l2_ctrl_av1_frame *p_av1_frame;91 struct v4l2_ctrl_av1_frame *p_av1_frame;
91 struct v4l2_ctrl_av1_film_grain *p_av1_film_grain;92 struct v4l2_ctrl_av1_film_grain *p_av1_film_grain;
93 struct v4l2_rect *p_rect;
92 void *p;94 void *p;
93 const void *p_const;95 const void *p_const;
94};96};
include/uapi/linux/videodev2.h+2−0
@@ -1859,6 +1859,7 @@ struct v4l2_ext_control { · 1858 unmodified lines
1859 __s32 __user *p_s32;1859 __s32 __user *p_s32;
1860 __s64 __user *p_s64;1860 __s64 __user *p_s64;
1861 struct v4l2_area __user *p_area;1861 struct v4l2_area __user *p_area;
1862 struct v4l2_rect __user *p_rect;
1862 struct v4l2_ctrl_h264_sps __user *p_h264_sps;1863 struct v4l2_ctrl_h264_sps __user *p_h264_sps;
1863 struct v4l2_ctrl_h264_pps __user *p_h264_pps;1864 struct v4l2_ctrl_h264_pps __user *p_h264_pps;
1864 struct v4l2_ctrl_h264_scaling_matrix __user *p_h264_scaling_matrix;1865 struct v4l2_ctrl_h264_scaling_matrix __user *p_h264_scaling_matrix;
@@ -1929,6 +1930,7 @@ enum v4l2_ctrl_type { · 64 unmodified lines
1929 V4L2_CTRL_TYPE_U16 = 0x0101,1930 V4L2_CTRL_TYPE_U16 = 0x0101,
1930 V4L2_CTRL_TYPE_U32 = 0x0102,1931 V4L2_CTRL_TYPE_U32 = 0x0102,
1931 V4L2_CTRL_TYPE_AREA = 0x0106,1932 V4L2_CTRL_TYPE_AREA = 0x0106,
1933 V4L2_CTRL_TYPE_RECT = 0x0107,
1932 1934
1933 V4L2_CTRL_TYPE_HDR10_CLL_INFO = 0x0110,1935 V4L2_CTRL_TYPE_HDR10_CLL_INFO = 0x0110,
1934 V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY = 0x0111,1936 V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY = 0x0111,