Message ID | 20210311122040.1264410-12-ribalda@chromium.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | uvcvideo: Pass v4l2-compliance test | expand |
On 11/03/2021 13:20, Ricardo Ribalda wrote: > Do not create Control Classes for empty classes. Shouldn't this be squashed with patch 06/10? Regards, Hans > > 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. >
Hi Hans Thanks for your review! On Thu, Mar 11, 2021 at 3:32 PM Hans Verkuil <hverkuil@xs4all.nl> wrote: > > On 11/03/2021 13:20, Ricardo Ribalda wrote: > > Do not create Control Classes for empty classes. > > Shouldn't this be squashed with patch 06/10? Most of the cameras I have used have the two classes, So I am not sure if squash with 6/10, or remove it. I separated it to feel what Laurent has to say :) > > Regards, > > Hans > > > > > 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. > > >
Hi Ricardo, On Thu, Mar 11, 2021 at 04:21:38PM +0100, Ricardo Ribalda Delgado wrote: > On Thu, Mar 11, 2021 at 3:32 PM Hans Verkuil <hverkuil@xs4all.nl> wrote: > > > > On 11/03/2021 13:20, Ricardo Ribalda wrote: > > > Do not create Control Classes for empty classes. > > > > Shouldn't this be squashed with patch 06/10? > > Most of the cameras I have used have the two classes, So I am not > sure if squash with 6/10, or remove it. I separated it to feel what > Laurent has to say :) I think it makes sense to only expose the classes that are being used, so the change is good. As it fixes a bug introduced in 06/10, I'd squash it. > > > 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.
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.
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(-)