| From abef90bb09619e227bbaf07f9d2f5f8b38f0673f Mon Sep 17 00:00:00 2001 |
| From: Yunke Cao <yunkec@chromium.org> |
| Date: Mon, 3 Jul 2023 13:27:42 +0900 |
| Subject: [PATCH] CHROMIUM:Revert "media: uvcvideo: add UVC 1.5 ROI control" |
| |
| This reverts commit c70c554ab0388dd1c04f90d3d2ff7f7c9fb78861. |
| |
| UPSTREAM-TASK=b:191930245 |
| BUG=b:295243598 |
| TEST=v4l2-ctl |
| |
| Cq-Depend: I1b074339cb47f51a1875245b7336e23f3cbcc8c0 |
| Change-Id: I1f50eca91e47a912f866a1e42d4122d69dcdedcc |
| Signed-off-by: Yunke Cao <yunkec@chromium.org> |
| Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/4663709 |
| Reviewed-by: Ricardo Ribalda <ribalda@chromium.org> |
| (cherry picked from commit 18fafe1d0df46c0184c13ba7d82a01501c13226b) |
| Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/5531314 |
| --- |
| .../media/v4l/extended-controls.rst | 25 --- |
| drivers/media/usb/uvc/uvc_ctrl.c | 91 --------- |
| drivers/media/usb/uvc/uvc_v4l2.c | 180 +----------------- |
| drivers/media/v4l2-core/v4l2-ctrls-defs.c | 1 - |
| include/uapi/linux/usb/video.h | 1 - |
| include/uapi/linux/v4l2-controls.h | 19 -- |
| 6 files changed, 4 insertions(+), 313 deletions(-) |
| |
| diff --git a/Documentation/userspace-api/media/v4l/extended-controls.rst b/Documentation/userspace-api/media/v4l/extended-controls.rst |
| index 874f6fd5fbf52524cbf0427fbd09cc712a95a8ea..44fcd67f20bf14683ab0ab55a6aac7f9df02fe94 100644 |
| --- a/Documentation/userspace-api/media/v4l/extended-controls.rst |
| +++ b/Documentation/userspace-api/media/v4l/extended-controls.rst |
| @@ -155,31 +155,6 @@ control should be used (see :ref:`enum_all_controls`). But if it is |
| supported, then it is guaranteed to enumerate over all controls, |
| including driver-private controls. |
| |
| -``V4L2_CID_REGION_OF_INTEREST_AUTO (bitmask)`` |
| - This determines which, if any, on board features should track to the |
| - Region of Interest. |
| - |
| -.. flat-table:: |
| - :header-rows: 0 |
| - :stub-columns: 0 |
| - |
| - * - ``V4L2_CID_REGION_OF_INTEREST_AUTO_EXPOSURE`` |
| - - Auto Exposure. |
| - * - ``V4L2_CID_REGION_OF_INTEREST_AUTO_IRIS`` |
| - - Auto Iris. |
| - * - ``V4L2_CID_REGION_OF_INTEREST_AUTO_WHITE_BALANCE`` |
| - - Auto White Balance. |
| - * - ``V4L2_CID_REGION_OF_INTEREST_AUTO_FOCUS`` |
| - - Auto Focus. |
| - * - ``V4L2_CID_REGION_OF_INTEREST_AUTO_FACE_DETECT`` |
| - - Auto Face Detect. |
| - * - ``V4L2_CID_REGION_OF_INTEREST_AUTO_DETECT_AND_TRACK`` |
| - - Auto Detect and Track. |
| - * - ``V4L2_CID_REGION_OF_INTEREST_AUTO_IMAGE_STABILIZATION`` |
| - - Image Stabilization. |
| - * - ``V4L2_CID_REGION_OF_INTEREST_AUTO_HIGHER_QUALITY`` |
| - - Higher Quality. |
| - |
| |
| Creating Control Panels |
| ======================= |
| diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c |
| index 9a96d4caa777f76037780c6707177500b6ad56bd..2118fabb96d2f05d484205d2abd14affd5beb663 100644 |
| --- a/drivers/media/usb/uvc/uvc_ctrl.c |
| +++ b/drivers/media/usb/uvc/uvc_ctrl.c |
| @@ -358,15 +358,6 @@ static const struct uvc_control_info uvc_ctrls[] = { |
| .flags = UVC_CTRL_FLAG_GET_CUR |
| | UVC_CTRL_FLAG_AUTO_UPDATE, |
| }, |
| - { |
| - .entity = UVC_GUID_UVC_CAMERA, |
| - .selector = UVC_CT_REGION_OF_INTEREST_CONTROL, |
| - .index = 21, |
| - .size = 10, |
| - .flags = UVC_CTRL_FLAG_SET_CUR | UVC_CTRL_FLAG_GET_CUR |
| - | UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX |
| - | UVC_CTRL_FLAG_GET_DEF |
| - }, |
| }; |
| |
| static const u32 uvc_control_classes[] = { |
| @@ -850,15 +841,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { |
| .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL, |
| .filter_mapping = uvc_ctrl_filter_plf_mapping, |
| }, |
| - { |
| - .id = V4L2_CID_REGION_OF_INTEREST_AUTO, |
| - .entity = UVC_GUID_UVC_CAMERA, |
| - .selector = UVC_CT_REGION_OF_INTEREST_CONTROL, |
| - .size = 16, |
| - .offset = 64, |
| - .v4l2_type = V4L2_CTRL_TYPE_BITMASK, |
| - .data_type = UVC_CTRL_DATA_TYPE_BITMASK, |
| - }, |
| }; |
| |
| /* ------------------------------------------------------------------------ |
| @@ -2701,75 +2683,6 @@ static void uvc_ctrl_prune_entity(struct uvc_device *dev, |
| } |
| } |
| |
| -static int uvc_ctrl_init_roi(struct uvc_device *dev, struct uvc_control *ctrl) |
| -{ |
| - struct uvc_roi *def; |
| - int ret; |
| - |
| - if (WARN_ON(sizeof(struct uvc_roi) != ctrl->info.size)) |
| - return -EINVAL; |
| - |
| - def = (struct uvc_roi *)uvc_ctrl_data(ctrl, UVC_CTRL_DATA_DEF); |
| - |
| - ret = uvc_query_ctrl(dev, UVC_GET_DEF, ctrl->entity->id, dev->intfnum, |
| - UVC_CT_REGION_OF_INTEREST_CONTROL, def, |
| - sizeof(struct uvc_roi)); |
| - if (ret) |
| - goto out; |
| - |
| - /* |
| - * Some firmwares have wrong GET_CURRENT configuration. E.g. it's |
| - * below GET_MIN, or have rectangle coordinates mixed up. This |
| - * causes problems sometimes, because we are unable to set |
| - * auto-controls value without first setting ROI rectangle to |
| - * valid configuration. |
| - * |
| - * We expect that default configuration is always correct and |
| - * is within the GET_MIN / GET_MAX boundaries. |
| - * |
| - * Set current ROI configuration to GET_DEF, so that we will |
| - * always have properly configured ROI. |
| - */ |
| - ret = uvc_query_ctrl(dev, UVC_SET_CUR, 1, dev->intfnum, |
| - UVC_CT_REGION_OF_INTEREST_CONTROL, def, |
| - sizeof(struct uvc_roi)); |
| -out: |
| - if (ret) |
| - dev_err(&dev->udev->dev, "Failed to fixup ROI (%d).\n", ret); |
| - return ret; |
| -} |
| - |
| -struct uvc_roi *uvc_ctrl_roi(struct uvc_video_chain *chain, u8 query) |
| -{ |
| - struct uvc_control_mapping *mapping; |
| - struct uvc_control *ctrl; |
| - int id; |
| - |
| - switch (query) { |
| - case UVC_GET_CUR: |
| - id = UVC_CTRL_DATA_CURRENT; |
| - break; |
| - case UVC_GET_DEF: |
| - id = UVC_CTRL_DATA_DEF; |
| - break; |
| - case UVC_GET_MIN: |
| - id = UVC_CTRL_DATA_MIN; |
| - break; |
| - case UVC_GET_MAX: |
| - id = UVC_CTRL_DATA_MAX; |
| - break; |
| - default: |
| - return NULL; |
| - } |
| - |
| - ctrl = uvc_find_control(chain, V4L2_CID_REGION_OF_INTEREST_AUTO, |
| - &mapping); |
| - if (!ctrl) |
| - return NULL; |
| - |
| - return (struct uvc_roi *)uvc_ctrl_data(ctrl, id); |
| -} |
| - |
| /* |
| * Add control information and hardcoded stock control mappings to the given |
| * device. |
| @@ -2778,7 +2691,6 @@ static void uvc_ctrl_init_ctrl(struct uvc_video_chain *chain, |
| struct uvc_control *ctrl) |
| { |
| unsigned int i; |
| - const u8 camera_entity[16] = UVC_GUID_UVC_CAMERA; |
| |
| /* |
| * XU controls initialization requires querying the device for control |
| @@ -2802,9 +2714,6 @@ static void uvc_ctrl_init_ctrl(struct uvc_video_chain *chain, |
| * GET_INFO on standard controls. |
| */ |
| uvc_ctrl_get_flags(chain->dev, ctrl, &ctrl->info); |
| - if (ctrl->info.selector == UVC_CT_REGION_OF_INTEREST_CONTROL && |
| - uvc_entity_match_guid(ctrl->entity, camera_entity)) |
| - uvc_ctrl_init_roi(chain->dev, ctrl); |
| break; |
| } |
| } |
| diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c |
| index 27c57b8f9ce9b25777fa16e289dc55d43f5fde6c..5a4f9cc7db686cfbb45db3f5df1d39e98f768b13 100644 |
| --- a/drivers/media/usb/uvc/uvc_v4l2.c |
| +++ b/drivers/media/usb/uvc/uvc_v4l2.c |
| @@ -1231,71 +1231,15 @@ static int uvc_ioctl_querymenu(struct file *file, void *fh, |
| return uvc_query_v4l2_menu(chain, qm); |
| } |
| |
| -static int uvc_ioctl_g_roi_target(struct file *file, void *fh, |
| - struct v4l2_selection *sel) |
| + |
| +static int uvc_ioctl_g_selection(struct file *file, void *fh, |
| + struct v4l2_selection *sel) |
| { |
| struct uvc_fh *handle = fh; |
| struct uvc_streaming *stream = handle->stream; |
| - struct uvc_video_chain *chain = handle->chain; |
| - struct uvc_roi *roi; |
| - u8 query; |
| - int ret; |
| |
| - switch (sel->target) { |
| - case V4L2_SEL_TGT_ROI: |
| - query = UVC_GET_CUR; |
| - break; |
| - case V4L2_SEL_TGT_ROI_DEFAULT: |
| - query = UVC_GET_DEF; |
| - break; |
| - case V4L2_SEL_TGT_ROI_BOUNDS_MIN: |
| - query = UVC_GET_MIN; |
| - break; |
| - case V4L2_SEL_TGT_ROI_BOUNDS_MAX: |
| - query = UVC_GET_MAX; |
| - break; |
| - default: |
| + if (sel->type != stream->type) |
| return -EINVAL; |
| - } |
| - |
| - /* |
| - * Synchronize with uvc_ioctl_query_ext_ctrl() that can set |
| - * ROI auto_controls concurrently. |
| - */ |
| - mutex_lock(&chain->ctrl_mutex); |
| - |
| - roi = uvc_ctrl_roi(chain, query); |
| - if (!roi) { |
| - ret = -EINVAL; |
| - goto out; |
| - } |
| - |
| - /* |
| - * This reads actual configuration from the firmware and at the |
| - * same updates cached UVC control data. |
| - */ |
| - ret = uvc_query_ctrl(stream->dev, query, 1, stream->dev->intfnum, |
| - UVC_CT_REGION_OF_INTEREST_CONTROL, roi, |
| - sizeof(struct uvc_roi)); |
| - if (ret) |
| - goto out; |
| - |
| - /* ROI left, top, right, bottom are global coordinates. */ |
| - sel->r.top = roi->wROI_Top; |
| - sel->r.left = roi->wROI_Left; |
| - sel->r.height = roi->wROI_Bottom - roi->wROI_Top + 1; |
| - sel->r.width = roi->wROI_Right - roi->wROI_Left + 1; |
| - |
| -out: |
| - mutex_unlock(&chain->ctrl_mutex); |
| - return ret; |
| -} |
| - |
| -static int uvc_ioctl_g_sel_target(struct file *file, void *fh, |
| - struct v4l2_selection *sel) |
| -{ |
| - struct uvc_fh *handle = fh; |
| - struct uvc_streaming *stream = handle->stream; |
| |
| switch (sel->target) { |
| case V4L2_SEL_TGT_CROP_DEFAULT: |
| @@ -1322,121 +1266,6 @@ static int uvc_ioctl_g_sel_target(struct file *file, void *fh, |
| return 0; |
| } |
| |
| -static int uvc_ioctl_g_selection(struct file *file, void *fh, |
| - struct v4l2_selection *sel) |
| -{ |
| - struct uvc_fh *handle = fh; |
| - struct uvc_streaming *stream = handle->stream; |
| - |
| - if (sel->type != stream->type) |
| - return -EINVAL; |
| - |
| - switch (sel->target) { |
| - case V4L2_SEL_TGT_CROP_DEFAULT: |
| - case V4L2_SEL_TGT_CROP_BOUNDS: |
| - case V4L2_SEL_TGT_COMPOSE_DEFAULT: |
| - case V4L2_SEL_TGT_COMPOSE_BOUNDS: |
| - return uvc_ioctl_g_sel_target(file, fh, sel); |
| - case V4L2_SEL_TGT_ROI: |
| - case V4L2_SEL_TGT_ROI_DEFAULT: |
| - case V4L2_SEL_TGT_ROI_BOUNDS_MIN: |
| - case V4L2_SEL_TGT_ROI_BOUNDS_MAX: |
| - return uvc_ioctl_g_roi_target(file, fh, sel); |
| - } |
| - |
| - return -EINVAL; |
| -} |
| - |
| -static void validate_roi_bounds(struct uvc_streaming *stream, |
| - struct v4l2_selection *sel) |
| -{ |
| - lockdep_assert_held(&stream->mutex); |
| - |
| - if (sel->r.left > USHRT_MAX) |
| - sel->r.left = 0; |
| - |
| - if (sel->r.top > USHRT_MAX) |
| - sel->r.top = 0; |
| - |
| - if (sel->r.width + sel->r.left > USHRT_MAX || !sel->r.width) { |
| - sel->r.left = 0; |
| - sel->r.width = stream->cur_frame->wWidth; |
| - } |
| - |
| - if (sel->r.height + sel->r.top > USHRT_MAX || !sel->r.height) { |
| - sel->r.top = 0; |
| - sel->r.height = stream->cur_frame->wHeight; |
| - } |
| -} |
| - |
| -static int uvc_ioctl_s_roi(struct file *file, void *fh, |
| - struct v4l2_selection *sel) |
| -{ |
| - struct uvc_fh *handle = fh; |
| - struct uvc_streaming *stream = handle->stream; |
| - struct uvc_video_chain *chain = handle->chain; |
| - struct uvc_roi roi_backup; |
| - struct uvc_roi *roi; |
| - int ret; |
| - |
| - /* |
| - * Synchronize with uvc_ioctl_query_ext_ctrl() that can set |
| - * ROI auto_controls concurrently. |
| - */ |
| - mutex_lock(&chain->ctrl_mutex); |
| - |
| - roi = uvc_ctrl_roi(chain, UVC_GET_CUR); |
| - if (!roi) { |
| - mutex_unlock(&chain->ctrl_mutex); |
| - return -EINVAL; |
| - } |
| - |
| - mutex_lock(&stream->mutex); |
| - |
| - validate_roi_bounds(stream, sel); |
| - |
| - roi_backup = *roi; |
| - |
| - /* |
| - * ROI left, top, right, bottom are global coordinates. |
| - * Note that we use ->auto_controls value which we read earlier. |
| - */ |
| - roi->wROI_Top = sel->r.top; |
| - roi->wROI_Left = sel->r.left; |
| - roi->wROI_Bottom = sel->r.height + sel->r.top - 1; |
| - roi->wROI_Right = sel->r.width + sel->r.left - 1; |
| - |
| - ret = uvc_query_ctrl(stream->dev, UVC_SET_CUR, 1, stream->dev->intfnum, |
| - UVC_CT_REGION_OF_INTEREST_CONTROL, roi, |
| - sizeof(struct uvc_roi)); |
| - if (ret) { |
| - *roi = roi_backup; |
| - goto out; |
| - } |
| - |
| -out: |
| - mutex_unlock(&stream->mutex); |
| - mutex_unlock(&chain->ctrl_mutex); |
| - return ret; |
| -} |
| - |
| -static int uvc_ioctl_s_selection(struct file *file, void *fh, |
| - struct v4l2_selection *sel) |
| -{ |
| - struct uvc_fh *handle = fh; |
| - struct uvc_streaming *stream = handle->stream; |
| - |
| - if (sel->type != stream->type) |
| - return -EINVAL; |
| - |
| - switch (sel->target) { |
| - case V4L2_SEL_TGT_ROI: |
| - return uvc_ioctl_s_roi(file, fh, sel); |
| - } |
| - |
| - return -EINVAL; |
| -} |
| - |
| static int uvc_ioctl_g_parm(struct file *file, void *fh, |
| struct v4l2_streamparm *parm) |
| { |
| @@ -1795,7 +1624,6 @@ const struct v4l2_ioctl_ops uvc_ioctl_ops = { |
| .vidioc_try_ext_ctrls = uvc_ioctl_try_ext_ctrls, |
| .vidioc_querymenu = uvc_ioctl_querymenu, |
| .vidioc_g_selection = uvc_ioctl_g_selection, |
| - .vidioc_s_selection = uvc_ioctl_s_selection, |
| .vidioc_g_parm = uvc_ioctl_g_parm, |
| .vidioc_s_parm = uvc_ioctl_s_parm, |
| .vidioc_enum_framesizes = uvc_ioctl_enum_framesizes, |
| diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c |
| index 5b17c3bdba2af53873f7ce00e7c446cad78b6fd0..1ea52011247accc51d0261f56eab1cf13c0624a0 100644 |
| --- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c |
| +++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c |
| @@ -831,7 +831,6 @@ const char *v4l2_ctrl_get_name(u32 id) |
| case V4L2_CID_ALPHA_COMPONENT: return "Alpha Component"; |
| case V4L2_CID_COLORFX_CBCR: return "Color Effects, CbCr"; |
| case V4L2_CID_COLORFX_RGB: return "Color Effects, RGB"; |
| - case V4L2_CID_REGION_OF_INTEREST_AUTO: return "Region Of Interest Auto Controls"; |
| |
| /* |
| * Codec controls |
| diff --git a/include/uapi/linux/usb/video.h b/include/uapi/linux/usb/video.h |
| index 2afb4420e6c4ac101457295928818086d4ac58ee..2ff0e8a3a683dcd0dec4d2269041096831d88ea9 100644 |
| --- a/include/uapi/linux/usb/video.h |
| +++ b/include/uapi/linux/usb/video.h |
| @@ -104,7 +104,6 @@ |
| #define UVC_CT_ROLL_ABSOLUTE_CONTROL 0x0f |
| #define UVC_CT_ROLL_RELATIVE_CONTROL 0x10 |
| #define UVC_CT_PRIVACY_CONTROL 0x11 |
| -#define UVC_CT_REGION_OF_INTEREST_CONTROL 0x14 |
| |
| /* A.9.5. Processing Unit Control Selectors */ |
| #define UVC_PU_CONTROL_UNDEFINED 0x00 |
| diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h |
| index 8345c2b4ba7eddc7743d21b7f431766251c50534..974fd254e57309e6def95b4a4f8e4de13a3972a7 100644 |
| --- a/include/uapi/linux/v4l2-controls.h |
| +++ b/include/uapi/linux/v4l2-controls.h |
| @@ -1089,25 +1089,6 @@ enum v4l2_auto_focus_range { |
| |
| #define V4L2_CID_HDR_SENSOR_MODE (V4L2_CID_CAMERA_CLASS_BASE+36) |
| |
| -/* |
| - * senozhatsky@ b:191930245 |
| - * |
| - * These are FROMLIST defines. Use very high value to avoid collisions |
| - * with upstream patches. Controls classes are USHRT_MAX apart from each |
| - * other, but the lower 0x900 are not being used. This leaves us with the |
| - * USHRT_MAX - 0x900 values. Use SHRT_MAX. |
| - */ |
| -#define V4L2_CID_REGION_OF_INTEREST_AUTO \ |
| - (V4L2_CID_CAMERA_CLASS_BASE + SHRT_MAX) |
| -#define V4L2_CID_REGION_OF_INTEREST_AUTO_EXPOSURE (1 << 0) |
| -#define V4L2_CID_REGION_OF_INTEREST_AUTO_IRIS (1 << 1) |
| -#define V4L2_CID_REGION_OF_INTEREST_AUTO_WHITE_BALANCE (1 << 2) |
| -#define V4L2_CID_REGION_OF_INTEREST_AUTO_FOCUS (1 << 3) |
| -#define V4L2_CID_REGION_OF_INTEREST_AUTO_FACE_DETECT (1 << 4) |
| -#define V4L2_CID_REGION_OF_INTEREST_AUTO_DETECT_AND_TRACK (1 << 5) |
| -#define V4L2_CID_REGION_OF_INTEREST_AUTO_IMAGE_STABILIZATION (1 << 6) |
| -#define V4L2_CID_REGION_OF_INTEREST_AUTO_HIGHER_QUALITY (1 << 7) |
| - |
| /* FM Modulator class control IDs */ |
| |
| #define V4L2_CID_FM_TX_CLASS_BASE (V4L2_CTRL_CLASS_FM_TX | 0x900) |
| -- |
| 2.46.0.rc2.264.g509ed76dc8-goog |
| |