lkml.org 
[lkml]   [2021]   [Mar]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 10/10] media: uvcvideo: Populate only active control classes
Date
Do not create Control Classes for empty classes.

Fixes v4l2-compliance:

Control ioctls (Input 0):
fail: v4l2-test-controls.cpp(255): no controls in class 009d0000
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: FAIL

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
drivers/media/usb/uvc/uvc_ctrl.c | 11 +++++++++++
drivers/media/usb/uvc/uvc_driver.c | 1 -
drivers/media/usb/uvc/uvcvideo.h | 1 -
3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index 433342efc63f..5efbb3b5aa5b 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -2128,6 +2128,17 @@ static int __uvc_ctrl_add_mapping(struct uvc_device *dev,
if (map->set == NULL)
map->set = uvc_set_le_value;

+ switch (V4L2_CTRL_ID2WHICH(map->id)) {
+ case V4L2_CTRL_ID2WHICH(V4L2_CID_CAMERA_CLASS):
+ dev->ctrl_class_unit->ctrl_class.bmControls[0] |=
+ BIT(UVC_CC_CAMERA_CLASS);
+ break;
+ case V4L2_CTRL_ID2WHICH(V4L2_CID_USER_CLASS):
+ dev->ctrl_class_unit->ctrl_class.bmControls[0] |=
+ BIT(UVC_CC_USER_CLASS);
+ break;
+ }
+
list_add_tail(&map->list, &ctrl->info.mappings);
uvc_dbg(dev, CONTROL, "Adding mapping '%s' to control %pUl/%u\n",
map->name, ctrl->info.entity, ctrl->info.selector);
diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index 996e8bd06ac5..4f368ab3a1f1 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -1501,7 +1501,6 @@ static int uvc_ctrl_class_parse(struct uvc_device *dev)

unit->ctrl_class.bControlSize = 1;
unit->ctrl_class.bmControls = (u8 *)unit + sizeof(*unit);
- unit->ctrl_class.bmControls[0] = (1 << (UVC_CC_LAST_CLASS + 1)) - 1;
unit->get_info = uvc_ctrl_class_get_info;
strncpy(unit->name, "Control Class", sizeof(unit->name) - 1);

diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index 1d59ac10c2eb..cc573d63e459 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -186,7 +186,6 @@
*/
#define UVC_CC_CAMERA_CLASS 0
#define UVC_CC_USER_CLASS 1
-#define UVC_CC_LAST_CLASS UVC_CC_USER_CLASS

/* ------------------------------------------------------------------------
* Driver specific constants.
--
2.31.0.rc2.261.g7f71774620-goog
\
 
 \ /
  Last update: 2021-03-11 13:40    [W:0.138 / U:0.136 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site