2022-12-02 17:01:35

by Ricardo Ribalda

[permalink] [raw]
Subject: [PATCH RESEND v2 2/2] media: uvcvideo: Limit power line control for Lenovo Integrated Camera

The device does not implement the power line control correctly. Add a
corresponding control mapping override.

Bus 003 Device 002: ID 30c9:0093 Lenovo Integrated Camera
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.01
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
idVendor 0x30c9
idProduct 0x0093
bcdDevice 0.07
iManufacturer 3 Lenovo
iProduct 1 Integrated Camera
iSerial 2 8SSC21J75356V1SR2830069
bNumConfigurations 1

Signed-off-by: Ricardo Ribalda <[email protected]>
---
drivers/media/usb/uvc/uvc_driver.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)

diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index cca3012c8912..e0bb21f2e133 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -2373,6 +2373,30 @@ MODULE_PARM_DESC(timeout, "Streaming control requests timeout");
* Driver initialization and cleanup
*/

+static const struct uvc_menu_info power_line_frequency_controls_uvc11[] = {
+ { 0, "Disabled" },
+ { 1, "50 Hz" },
+ { 2, "60 Hz" },
+};
+
+static const struct uvc_control_mapping uvc_ctrl_power_line_mapping_uvc11 = {
+ .id = V4L2_CID_POWER_LINE_FREQUENCY,
+ .entity = UVC_GUID_UVC_PROCESSING,
+ .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL,
+ .size = 2,
+ .offset = 0,
+ .v4l2_type = V4L2_CTRL_TYPE_MENU,
+ .data_type = UVC_CTRL_DATA_TYPE_ENUM,
+ .menu_info = power_line_frequency_controls_uvc11,
+ .menu_count = ARRAY_SIZE(power_line_frequency_controls_uvc11),
+};
+
+static const struct uvc_device_info uvc_ctrl_power_line_uvc11 = {
+ .mappings = (const struct uvc_control_mapping *[]) {
+ &uvc_ctrl_power_line_mapping_uvc11,
+ NULL, /* Sentinel */
+ },
+};
static const struct uvc_menu_info power_line_frequency_controls_limited[] = {
{ 1, "50 Hz" },
{ 2, "60 Hz" },
@@ -2976,6 +3000,15 @@ static const struct usb_device_id uvc_ids[] = {
.bInterfaceSubClass = 1,
.bInterfaceProtocol = 0,
.driver_info = UVC_INFO_QUIRK(UVC_QUIRK_FORCE_BPP) },
+ /* Lenovo Integrated Camera */
+ { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
+ | USB_DEVICE_ID_MATCH_INT_INFO,
+ .idVendor = 0x30c9,
+ .idProduct = 0x0093,
+ .bInterfaceClass = USB_CLASS_VIDEO,
+ .bInterfaceSubClass = 1,
+ .bInterfaceProtocol = UVC_PC_PROTOCOL_15,
+ .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_uvc11 },
/* Sonix Technology USB 2.0 Camera */
{ .match_flags = USB_DEVICE_ID_MATCH_DEVICE
| USB_DEVICE_ID_MATCH_INT_INFO,

--
2.39.0.rc0.267.gcb52ba06e7-goog-b4-0.11.0-dev-696ae


2022-12-29 02:47:04

by Laurent Pinchart

[permalink] [raw]
Subject: Re: [PATCH RESEND v2 2/2] media: uvcvideo: Limit power line control for Lenovo Integrated Camera

Hi Ricardo,

Thank you for the patch.

On Fri, Dec 02, 2022 at 05:45:07PM +0100, Ricardo Ribalda wrote:
> The device does not implement the power line control correctly. Add a
> corresponding control mapping override.

Do I understand correctly that this device advertises UVC 1.5 support
buth implements the power line frequency control as if it was a UVC 1.1
device ? Could you record this in the commit message ?

I wonder how all these cameras can pass the UVC conformance test suite.
Either they don't even bother trying, or the test suite is useless.

> Bus 003 Device 002: ID 30c9:0093 Lenovo Integrated Camera
> Device Descriptor:
> bLength 18
> bDescriptorType 1
> bcdUSB 2.01
> bDeviceClass 239 Miscellaneous Device
> bDeviceSubClass 2
> bDeviceProtocol 1 Interface Association
> bMaxPacketSize0 64
> idVendor 0x30c9
> idProduct 0x0093
> bcdDevice 0.07
> iManufacturer 3 Lenovo
> iProduct 1 Integrated Camera
> iSerial 2 8SSC21J75356V1SR2830069
> bNumConfigurations 1
>
> Signed-off-by: Ricardo Ribalda <[email protected]>
> ---
> drivers/media/usb/uvc/uvc_driver.c | 33 +++++++++++++++++++++++++++++++++
> 1 file changed, 33 insertions(+)
>
> diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
> index cca3012c8912..e0bb21f2e133 100644
> --- a/drivers/media/usb/uvc/uvc_driver.c
> +++ b/drivers/media/usb/uvc/uvc_driver.c
> @@ -2373,6 +2373,30 @@ MODULE_PARM_DESC(timeout, "Streaming control requests timeout");
> * Driver initialization and cleanup
> */
>
> +static const struct uvc_menu_info power_line_frequency_controls_uvc11[] = {
> + { 0, "Disabled" },
> + { 1, "50 Hz" },
> + { 2, "60 Hz" },
> +};
> +
> +static const struct uvc_control_mapping uvc_ctrl_power_line_mapping_uvc11 = {
> + .id = V4L2_CID_POWER_LINE_FREQUENCY,
> + .entity = UVC_GUID_UVC_PROCESSING,
> + .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL,
> + .size = 2,
> + .offset = 0,
> + .v4l2_type = V4L2_CTRL_TYPE_MENU,
> + .data_type = UVC_CTRL_DATA_TYPE_ENUM,
> + .menu_info = power_line_frequency_controls_uvc11,
> + .menu_count = ARRAY_SIZE(power_line_frequency_controls_uvc11),
> +};

It would be nice to avoid duplicating the data, do you think we could
reference uvc_ctrl_mappings_uvc11 from uvc_ctrl.c instead ?

> +
> +static const struct uvc_device_info uvc_ctrl_power_line_uvc11 = {
> + .mappings = (const struct uvc_control_mapping *[]) {
> + &uvc_ctrl_power_line_mapping_uvc11,
> + NULL, /* Sentinel */
> + },
> +};
> static const struct uvc_menu_info power_line_frequency_controls_limited[] = {
> { 1, "50 Hz" },
> { 2, "60 Hz" },
> @@ -2976,6 +3000,15 @@ static const struct usb_device_id uvc_ids[] = {
> .bInterfaceSubClass = 1,
> .bInterfaceProtocol = 0,
> .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_FORCE_BPP) },
> + /* Lenovo Integrated Camera */
> + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
> + | USB_DEVICE_ID_MATCH_INT_INFO,
> + .idVendor = 0x30c9,
> + .idProduct = 0x0093,
> + .bInterfaceClass = USB_CLASS_VIDEO,
> + .bInterfaceSubClass = 1,
> + .bInterfaceProtocol = UVC_PC_PROTOCOL_15,
> + .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_uvc11 },
> /* Sonix Technology USB 2.0 Camera */
> { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
> | USB_DEVICE_ID_MATCH_INT_INFO,

--
Regards,

Laurent Pinchart