Skip to contentSkip to conversation

media: uvcvideo: Automatically handle invalid uvc_versions

PATCH Superseded Ricardo Ribalda 3 participants 21 messages Sep 11 – Sep 28

Subsystems (3)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover media: uvcvideo: Automatically handle invalid uvc_versions

This series changes the way we handle invalid uvc_versions. Instead of just failing it will try to continue probing.

Now that we are at it fix the way we handle device warnings.

The last two patches are "optional". Feel free to ignore them.

Thanks!

---
Changes in v3:
- Move uvc_video_ctrl_size to uvc_video_init()
- Fixes for uvc_warn_once
- Remove bmVideoStandardParsing parsing
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Add quirk for Avermedia
- Change the way the compliance error message is printed and cache
ctrl_size
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Ricardo Ribalda (5):
media: uvcvideo: uvc_warn should warn not info
media: uvcvideo: Use uvc_warn_once when it make sense
media: uvcvideo: Automatically handle cameras with invalid uvc_version
media: uvcvideo: Do not parse bmVideoStandards
media: uvcvideo: Force UVC version for Avermedia GC515

 drivers/media/usb/uvc/uvc_driver.c | 17 ++++++++++-----
 drivers/media/usb/uvc/uvc_video.c  | 42 ++++++++++++++++++++++++--------------
 drivers/media/usb/uvc/uvcvideo.h   |  6 ++++--
 3 files changed, 43 insertions(+), 22 deletions(-)

---
base-commit: 27953c044974baf7e24dee3e9342fe0103dea80c
change-id: 20260907-uvc-version-aedefc4384ce

Best regards,

Signature · 1 line
Ricardo Ribalda <[email protected]>
#1 lore raw

PATCH v3 1/5 media: uvcvideo: uvc_warn should warn not info

Now the uvc_warn_once macro triggers a info message. Use the correct level.

---
 drivers/media/usb/uvc/uvcvideo.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/uvc/uvcvideo.h +1 -1
index b6bcee4a222f..a80406f20beb 100644
@@ -685,7 +685,7 @@ do {									\
 #define uvc_warn_once(_dev, warn, fmt, ...)				\
 do {									\
 	if (!test_and_set_bit(warn, &(_dev)->warnings))			\
-		dev_info(&(_dev)->intf->dev, fmt, ##__VA_ARGS__);	\
+		dev_warn(&(_dev)->intf->dev, fmt, ##__VA_ARGS__);	\
 } while (0)
 
 /* --------------------------------------------------------------------------
Signature · 1 line
2.55.0.1007.g17ff1f9808-goog
maintainer Reviewed-by on v3 1/5
#2 lore raw

Re: [PATCH v3 1/5] media: uvcvideo: uvc_warn should warn not info

Hi,

Quoted 4 lines · Ricardo Ribalda

Now the uvc_warn_once macro triggers a info message. Use the correct level.

Thanks, patch looks good to me:

Regards,

Hans

Quoted 18 lines
---
 drivers/media/usb/uvc/uvcvideo.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/uvc/uvcvideo.h +1 -1
index b6bcee4a222f..a80406f20beb 100644
@@ -685,7 +685,7 @@ do {									\
 #define uvc_warn_once(_dev, warn, fmt, ...)				\
 do {									\
 	if (!test_and_set_bit(warn, &(_dev)->warnings))			\
-		dev_info(&(_dev)->intf->dev, fmt, ##__VA_ARGS__);	\
+		dev_warn(&(_dev)->intf->dev, fmt, ##__VA_ARGS__);	\
 } while (0)
 
 /* --------------------------------------------------------------------------
maintainer Reviewed-by on v3 1/5
#3 lore raw

Re: [PATCH v3 1/5] media: uvcvideo: uvc_warn should warn not info

In reply to Ricardo Ribalda
Quoted 13 lines · Ricardo Ribalda

Now the uvc_warn_once macro triggers a info message. Use the correct level.

---
 drivers/media/usb/uvc/uvcvideo.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/uvc/uvcvideo.h +0 -0
index b6bcee4a222f..a80406f20beb 100644

drivers/media/usb/uvc/uvcvideo.h do { \ · line 688

Quoted 5 lines
drivers/media/usb/uvc/uvcvideo.h +1 -1
@@ -685,7 +685,7 @@ do {									\
 #define uvc_warn_once(_dev, warn, fmt, ...)				\
 do {									\
 	if (!test_and_set_bit(warn, &(_dev)->warnings))			\
-		dev_info(&(_dev)->intf->dev, fmt, ##__VA_ARGS__);	\
+		dev_warn(&(_dev)->intf->dev, fmt, ##__VA_ARGS__);	\

uvc_warn_once() is used to report UVC non-compliance, KERN_WARN makes sense.

Quoted 4 lines
drivers/media/usb/uvc/uvcvideo.h +0 -0
 } while (0)
 
 /* --------------------------------------------------------------------------
Signature · 3 lines
Regards,

Laurent Pinchart
#4 lore raw

PATCH v3 2/5 media: uvcvideo: Use uvc_warn_once when it make sense

In reply to Ricardo Ribalda

If there are multiple cameras in the system affected by a compliance error now we only show an error message for one of them.

Use uvc_warn_once() to print an error message per device.

---
 drivers/media/usb/uvc/uvc_video.c | 2 +-
 drivers/media/usb/uvc/uvcvideo.h  | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/media/usb/uvc/uvc_video.c +1 -1
index fc3536a4399f..2a3b7431cc68 100644
@@ -95,7 +95,7 @@ int uvc_query_ctrl(struct uvc_device *dev, u8 query, u8 unit,
 	 */
 	if (ret > 0 && query != UVC_GET_INFO) {
 		memset(data + ret, 0, size - ret);
-		dev_warn_once(&dev->intf->dev,
+		uvc_warn_once(dev, UVC_WARN_QUERY_CTRL,
 			      "UVC non compliance: %s control %u on unit %u returned %d bytes when we expected %u.\n",
 			      uvc_query_name(query), cs, unit, ret, size);
 		return 0;
drivers/media/usb/uvc/uvcvideo.h +1 -0
index a80406f20beb..abcafd929c9e 100644
@@ -661,6 +661,7 @@ static inline struct uvc_fh *to_uvc_fh(struct file *filp)
 #define UVC_WARN_MINMAX		0
 #define UVC_WARN_PROBE_DEF	1
 #define UVC_WARN_XU_GET_RES	2
+#define UVC_WARN_QUERY_CTRL	3
 
 extern unsigned int uvc_clock_param;
 extern unsigned int uvc_no_drop_param;
Signature · 1 line
2.55.0.1007.g17ff1f9808-goog
maintainer Reviewed-by on v3 2/5
#5 lore raw

Re: [PATCH v3 2/5] media: uvcvideo: Use uvc_warn_once when it make sense

Hi,

Quoted 6 lines · Ricardo Ribalda

If there are multiple cameras in the system affected by a compliance error now we only show an error message for one of them.

Use uvc_warn_once() to print an error message per device.

Thanks, patch looks good to me:

Regards,

Hans

Quoted 31 lines
---
 drivers/media/usb/uvc/uvc_video.c | 2 +-
 drivers/media/usb/uvc/uvcvideo.h  | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/media/usb/uvc/uvc_video.c +1 -1
index fc3536a4399f..2a3b7431cc68 100644
@@ -95,7 +95,7 @@ int uvc_query_ctrl(struct uvc_device *dev, u8 query, u8 unit,
 	 */
 	if (ret > 0 && query != UVC_GET_INFO) {
 		memset(data + ret, 0, size - ret);
-		dev_warn_once(&dev->intf->dev,
+		uvc_warn_once(dev, UVC_WARN_QUERY_CTRL,
 			      "UVC non compliance: %s control %u on unit %u returned %d bytes when we expected %u.\n",
 			      uvc_query_name(query), cs, unit, ret, size);
 		return 0;
drivers/media/usb/uvc/uvcvideo.h +1 -0
index a80406f20beb..abcafd929c9e 100644
@@ -661,6 +661,7 @@ static inline struct uvc_fh *to_uvc_fh(struct file *filp)
 #define UVC_WARN_MINMAX		0
 #define UVC_WARN_PROBE_DEF	1
 #define UVC_WARN_XU_GET_RES	2
+#define UVC_WARN_QUERY_CTRL	3
 
 extern unsigned int uvc_clock_param;
 extern unsigned int uvc_no_drop_param;
maintainer Reviewed-by on v3 2/5
#6 lore raw

Re: [PATCH v3 2/5] media: uvcvideo: Use uvc_warn_once when it make sense

In reply to Ricardo Ribalda
Quoted 16 lines · Ricardo Ribalda

If there are multiple cameras in the system affected by a compliance error now we only show an error message for one of them.

Use uvc_warn_once() to print an error message per device.

---
 drivers/media/usb/uvc/uvc_video.c | 2 +-
 drivers/media/usb/uvc/uvcvideo.h  | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/media/usb/uvc/uvc_video.c +0 -0
index fc3536a4399f..2a3b7431cc68 100644

drivers/media/usb/uvc/uvc_video.c int uvc_query_ctrl(struct uvc_device *dev, u8 query, u8 unit, · line 98

Quoted 5 lines
drivers/media/usb/uvc/uvc_video.c +1 -1
@@ -95,7 +95,7 @@ int uvc_query_ctrl(struct uvc_device *dev, u8 query, u8 unit,
 	 */
 	if (ret > 0 && query != UVC_GET_INFO) {
 		memset(data + ret, 0, size - ret);
-		dev_warn_once(&dev->intf->dev,
+		uvc_warn_once(dev, UVC_WARN_QUERY_CTRL,

I thought about submitting a patch for this when I read 1/5 :-)

The only other usage of dev_warn_once() in the driver logs bad access to the privacy control from userspace, which doesn't need to be logged per device.

Quoted 15 lines
drivers/media/usb/uvc/uvc_video.c +0 -0
 			      "UVC non compliance: %s control %u on unit %u returned %d bytes when we expected %u.\n",
 			      uvc_query_name(query), cs, unit, ret, size);
 		return 0;
drivers/media/usb/uvc/uvcvideo.h +1 -0
index a80406f20beb..abcafd929c9e 100644
@@ -661,6 +661,7 @@ static inline struct uvc_fh *to_uvc_fh(struct file *filp)
 #define UVC_WARN_MINMAX		0
 #define UVC_WARN_PROBE_DEF	1
 #define UVC_WARN_XU_GET_RES	2
+#define UVC_WARN_QUERY_CTRL	3
 
 extern unsigned int uvc_clock_param;
 extern unsigned int uvc_no_drop_param;
Signature · 3 lines
Regards,

Laurent Pinchart
#7 lore raw

PATCH v3 3/5 media: uvcvideo: Automatically handle cameras with invalid uvc_version

In reply to Ricardo Ribalda

Currently, the driver expects that cameras properly implement the spec version that they announce, and if they fail to do so, we do not continue probing the driver.

To make drivers more fun, some vendors decided to announce that they are a UVC version that they are not. Until now, we handled those cameras via quirks.

Unfortunately, reality has shown us that there are more cameras out there with an invalid uvc_version than we initially predicted.

This patch tries to handle these cameras with an identity crisis automatically. We still shame them in dmesg. But now they will work.

---
 drivers/media/usb/uvc/uvc_driver.c | 11 +++++++----
 drivers/media/usb/uvc/uvc_video.c  | 40 +++++++++++++++++++++++++-------------
 drivers/media/usb/uvc/uvcvideo.h   |  2 ++
 3 files changed, 35 insertions(+), 18 deletions(-)
drivers/media/usb/uvc/uvc_driver.c +7 -4
index e289cc71ba98..ca75f8d1ec46 100644
@@ -1169,9 +1169,7 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
 
 	case UVC_VC_PROCESSING_UNIT:
 		n = buflen >= 8 ? buffer[7] : 0;
-		p = dev->uvc_version >= 0x0110 ? 10 : 9;
-
-		if (buflen < p + n) {
+		if (buflen < 9 + n) {
 			uvc_dbg(dev, DESCR,
 				"device %d videocontrol interface %d PROCESSING_UNIT error\n",
 				udev->devnum, alts->desc.bInterfaceNumber);
@@ -1188,7 +1186,12 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
 		unit->processing.bControlSize = buffer[7];
 		unit->processing.bmControls = (u8 *)unit + sizeof(*unit);
 		memcpy(unit->processing.bmControls, &buffer[8], n);
-		if (dev->uvc_version >= 0x0110)
+
+		/*
+		 * We are not using bmVideoStandards, so there is no need to
+		 * warn the user if it is missing.
+		 */
+		if (dev->uvc_version >= 0x0110 && buflen >= (n + 10))
 			unit->processing.bmVideoStandards = buffer[9+n];
 
 		uvc_entity_set_name(dev, unit, "Processing", buffer[8+n]);
drivers/media/usb/uvc/uvc_video.c +26 -14
index 2a3b7431cc68..2f3daa920ffa 100644
@@ -273,6 +273,8 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
 	}
 }
 
+#define UVC_VIDEO_CTRL_MIN_SIZE 26
+
 static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
 {
 	/*
@@ -280,7 +282,7 @@ static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
 	 * on the protocol version.
 	 */
 	if (stream->dev->uvc_version < 0x0110)
-		return 26;
+		return UVC_VIDEO_CTRL_MIN_SIZE;
 	else if (stream->dev->uvc_version < 0x0150)
 		return 34;
 	else
@@ -290,7 +292,6 @@ static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
 static int uvc_get_video_ctrl(struct uvc_streaming *stream,
 	struct uvc_streaming_control *ctrl, int probe, u8 query)
 {
-	u16 size = uvc_video_ctrl_size(stream);
 	u8 *data;
 	int ret;
 
@@ -298,13 +299,13 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
 			query == UVC_GET_DEF)
 		return -EIO;
 
-	data = kmalloc(size, GFP_KERNEL);
+	data = kmalloc(stream->ctrl_size, GFP_KERNEL);
 	if (data == NULL)
 		return -ENOMEM;
 
 	ret = __uvc_query_ctrl(stream->dev, query, 0, stream->intfnum,
 		probe ? UVC_VS_PROBE_CONTROL : UVC_VS_COMMIT_CONTROL, data,
-		size, uvc_timeout_param);
+		stream->ctrl_size, uvc_timeout_param);
 
 	if ((query == UVC_GET_MIN || query == UVC_GET_MAX) && ret == 2) {
 		/*
@@ -319,7 +320,8 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
 		ctrl->wCompQuality = le16_to_cpup((__le16 *)data);
 		ret = 0;
 		goto out;
-	} else if (query == UVC_GET_DEF && probe == 1 && ret != size) {
+	} else if (query == UVC_GET_DEF && probe == 1 &&
+		   ret < UVC_VIDEO_CTRL_MIN_SIZE) {
 		/*
 		 * Many cameras don't support the GET_DEF request on their
 		 * video probe control. Warn once and return, the caller will
@@ -330,15 +332,24 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
 			"Enabling workaround.\n");
 		ret = -EIO;
 		goto out;
-	} else if (ret != size) {
+	} else if (ret < UVC_VIDEO_CTRL_MIN_SIZE) {
 		dev_err(&stream->intf->dev,
 			"Failed to query (%s) UVC %s control : %d (exp. %u).\n",
 			uvc_query_name(query), probe ? "probe" : "commit",
-			ret, size);
+			ret, stream->ctrl_size);
 		ret = (ret == -EPROTO) ? -EPROTO : -EIO;
 		goto out;
 	}
 
+	if (ret != stream->ctrl_size) {
+		uvc_warn_once(stream->dev, UVC_WARN_CTRL_SIZE,
+			      "UVC non compliance: Query (%s) UVC %s control had a size of %d instead of %u.\n",
+			      uvc_query_name(query),
+			      probe ? "probe" : "commit", ret,
+			      stream->ctrl_size);
+		stream->ctrl_size = ret;
+	}
+
 	ctrl->bmHint = le16_to_cpup((__le16 *)&data[0]);
 	ctrl->bFormatIndex = data[2];
 	ctrl->bFrameIndex = data[3];
@@ -351,7 +362,7 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
 	ctrl->dwMaxVideoFrameSize = get_unaligned_le32(&data[18]);
 	ctrl->dwMaxPayloadTransferSize = get_unaligned_le32(&data[22]);
 
-	if (size >= 34) {
+	if (ret >= 34) {
 		ctrl->dwClockFrequency = get_unaligned_le32(&data[26]);
 		ctrl->bmFramingInfo = data[30];
 		ctrl->bPreferedVersion = data[31];
@@ -381,11 +392,10 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
 static int uvc_set_video_ctrl(struct uvc_streaming *stream,
 	struct uvc_streaming_control *ctrl, int probe)
 {
-	u16 size = uvc_video_ctrl_size(stream);
 	u8 *data;
 	int ret;
 
-	data = kzalloc(size, GFP_KERNEL);
+	data = kzalloc(stream->ctrl_size, GFP_KERNEL);
 	if (data == NULL)
 		return -ENOMEM;
 
@@ -401,7 +411,7 @@ static int uvc_set_video_ctrl(struct uvc_streaming *stream,
 	put_unaligned_le32(ctrl->dwMaxVideoFrameSize, &data[18]);
 	put_unaligned_le32(ctrl->dwMaxPayloadTransferSize, &data[22]);
 
-	if (size >= 34) {
+	if (stream->ctrl_size >= 34) {
 		put_unaligned_le32(ctrl->dwClockFrequency, &data[26]);
 		data[30] = ctrl->bmFramingInfo;
 		data[31] = ctrl->bPreferedVersion;
@@ -411,11 +421,11 @@ static int uvc_set_video_ctrl(struct uvc_streaming *stream,
 
 	ret = __uvc_query_ctrl(stream->dev, UVC_SET_CUR, 0, stream->intfnum,
 		probe ? UVC_VS_PROBE_CONTROL : UVC_VS_COMMIT_CONTROL, data,
-		size, uvc_timeout_param);
-	if (ret != size) {
+		stream->ctrl_size, uvc_timeout_param);
+	if (ret != stream->ctrl_size) {
 		dev_err(&stream->intf->dev,
 			"Failed to set UVC %s control : %d (exp. %u).\n",
-			probe ? "probe" : "commit", ret, size);
+			probe ? "probe" : "commit", ret, stream->ctrl_size);
 		ret = -EIO;
 	}
 
@@ -2231,6 +2241,8 @@ int uvc_video_init(struct uvc_streaming *stream)
 
 	atomic_set(&stream->active, 0);
 
+	stream->ctrl_size = uvc_video_ctrl_size(stream);
+
 	/*
 	 * Alternate setting 0 should be the default, yet the XBox Live Vision
 	 * Cam (and possibly other devices) crash or otherwise misbehave if
drivers/media/usb/uvc/uvcvideo.h +2 -0
index abcafd929c9e..8d99e857a69f 100644
@@ -461,6 +461,7 @@ struct uvc_streaming {
 	struct usb_interface *intf;
 	int intfnum;
 	u32 maxpsize;
+	unsigned int ctrl_size;
 
 	struct uvc_streaming_header header;
 	enum v4l2_buf_type type;
@@ -662,6 +663,7 @@ static inline struct uvc_fh *to_uvc_fh(struct file *filp)
 #define UVC_WARN_PROBE_DEF	1
 #define UVC_WARN_XU_GET_RES	2
 #define UVC_WARN_QUERY_CTRL	3
+#define UVC_WARN_CTRL_SIZE	4
 
 extern unsigned int uvc_clock_param;
 extern unsigned int uvc_no_drop_param;
Signature · 1 line
2.55.0.1007.g17ff1f9808-goog
maintainer Reviewed-by on v3 3/5
#8 lore raw

Re: [PATCH v3 3/5] media: uvcvideo: Automatically handle cameras with invalid uvc_version

Hi,

Quoted 8 lines · Ricardo Ribalda

Currently, the driver expects that cameras properly implement the spec version that they announce, and if they fail to do so, we do not continue probing the driver.

To make drivers more fun, some vendors decided to announce that they are a UVC version that they are not. Until now, we handled those cameras via quirks.

Quoted 8 lines

Unfortunately, reality has shown us that there are more cameras out there with an invalid uvc_version than we initially predicted.

This patch tries to handle these cameras with an identity crisis automatically. We still shame them in dmesg. But now they will work.

Thanks, patch looks good to me:

Regards,

Hans

Quoted 194 lines
---
 drivers/media/usb/uvc/uvc_driver.c | 11 +++++++----
 drivers/media/usb/uvc/uvc_video.c  | 40 +++++++++++++++++++++++++-------------
 drivers/media/usb/uvc/uvcvideo.h   |  2 ++
 3 files changed, 35 insertions(+), 18 deletions(-)
drivers/media/usb/uvc/uvc_driver.c +7 -4
index e289cc71ba98..ca75f8d1ec46 100644
@@ -1169,9 +1169,7 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
 
 	case UVC_VC_PROCESSING_UNIT:
 		n = buflen >= 8 ? buffer[7] : 0;
-		p = dev->uvc_version >= 0x0110 ? 10 : 9;
-
-		if (buflen < p + n) {
+		if (buflen < 9 + n) {
 			uvc_dbg(dev, DESCR,
 				"device %d videocontrol interface %d PROCESSING_UNIT error\n",
 				udev->devnum, alts->desc.bInterfaceNumber);
@@ -1188,7 +1186,12 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
 		unit->processing.bControlSize = buffer[7];
 		unit->processing.bmControls = (u8 *)unit + sizeof(*unit);
 		memcpy(unit->processing.bmControls, &buffer[8], n);
-		if (dev->uvc_version >= 0x0110)
+
+		/*
+		 * We are not using bmVideoStandards, so there is no need to
+		 * warn the user if it is missing.
+		 */
+		if (dev->uvc_version >= 0x0110 && buflen >= (n + 10))
 			unit->processing.bmVideoStandards = buffer[9+n];
 
 		uvc_entity_set_name(dev, unit, "Processing", buffer[8+n]);
drivers/media/usb/uvc/uvc_video.c +26 -14
index 2a3b7431cc68..2f3daa920ffa 100644
@@ -273,6 +273,8 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
 	}
 }
 
+#define UVC_VIDEO_CTRL_MIN_SIZE 26
+
 static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
 {
 	/*
@@ -280,7 +282,7 @@ static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
 	 * on the protocol version.
 	 */
 	if (stream->dev->uvc_version < 0x0110)
-		return 26;
+		return UVC_VIDEO_CTRL_MIN_SIZE;
 	else if (stream->dev->uvc_version < 0x0150)
 		return 34;
 	else
@@ -290,7 +292,6 @@ static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
 static int uvc_get_video_ctrl(struct uvc_streaming *stream,
 	struct uvc_streaming_control *ctrl, int probe, u8 query)
 {
-	u16 size = uvc_video_ctrl_size(stream);
 	u8 *data;
 	int ret;
 
@@ -298,13 +299,13 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
 			query == UVC_GET_DEF)
 		return -EIO;
 
-	data = kmalloc(size, GFP_KERNEL);
+	data = kmalloc(stream->ctrl_size, GFP_KERNEL);
 	if (data == NULL)
 		return -ENOMEM;
 
 	ret = __uvc_query_ctrl(stream->dev, query, 0, stream->intfnum,
 		probe ? UVC_VS_PROBE_CONTROL : UVC_VS_COMMIT_CONTROL, data,
-		size, uvc_timeout_param);
+		stream->ctrl_size, uvc_timeout_param);
 
 	if ((query == UVC_GET_MIN || query == UVC_GET_MAX) && ret == 2) {
 		/*
@@ -319,7 +320,8 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
 		ctrl->wCompQuality = le16_to_cpup((__le16 *)data);
 		ret = 0;
 		goto out;
-	} else if (query == UVC_GET_DEF && probe == 1 && ret != size) {
+	} else if (query == UVC_GET_DEF && probe == 1 &&
+		   ret < UVC_VIDEO_CTRL_MIN_SIZE) {
 		/*
 		 * Many cameras don't support the GET_DEF request on their
 		 * video probe control. Warn once and return, the caller will
@@ -330,15 +332,24 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
 			"Enabling workaround.\n");
 		ret = -EIO;
 		goto out;
-	} else if (ret != size) {
+	} else if (ret < UVC_VIDEO_CTRL_MIN_SIZE) {
 		dev_err(&stream->intf->dev,
 			"Failed to query (%s) UVC %s control : %d (exp. %u).\n",
 			uvc_query_name(query), probe ? "probe" : "commit",
-			ret, size);
+			ret, stream->ctrl_size);
 		ret = (ret == -EPROTO) ? -EPROTO : -EIO;
 		goto out;
 	}
 
+	if (ret != stream->ctrl_size) {
+		uvc_warn_once(stream->dev, UVC_WARN_CTRL_SIZE,
+			      "UVC non compliance: Query (%s) UVC %s control had a size of %d instead of %u.\n",
+			      uvc_query_name(query),
+			      probe ? "probe" : "commit", ret,
+			      stream->ctrl_size);
+		stream->ctrl_size = ret;
+	}
+
 	ctrl->bmHint = le16_to_cpup((__le16 *)&data[0]);
 	ctrl->bFormatIndex = data[2];
 	ctrl->bFrameIndex = data[3];
@@ -351,7 +362,7 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
 	ctrl->dwMaxVideoFrameSize = get_unaligned_le32(&data[18]);
 	ctrl->dwMaxPayloadTransferSize = get_unaligned_le32(&data[22]);
 
-	if (size >= 34) {
+	if (ret >= 34) {
 		ctrl->dwClockFrequency = get_unaligned_le32(&data[26]);
 		ctrl->bmFramingInfo = data[30];
 		ctrl->bPreferedVersion = data[31];
@@ -381,11 +392,10 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
 static int uvc_set_video_ctrl(struct uvc_streaming *stream,
 	struct uvc_streaming_control *ctrl, int probe)
 {
-	u16 size = uvc_video_ctrl_size(stream);
 	u8 *data;
 	int ret;
 
-	data = kzalloc(size, GFP_KERNEL);
+	data = kzalloc(stream->ctrl_size, GFP_KERNEL);
 	if (data == NULL)
 		return -ENOMEM;
 
@@ -401,7 +411,7 @@ static int uvc_set_video_ctrl(struct uvc_streaming *stream,
 	put_unaligned_le32(ctrl->dwMaxVideoFrameSize, &data[18]);
 	put_unaligned_le32(ctrl->dwMaxPayloadTransferSize, &data[22]);
 
-	if (size >= 34) {
+	if (stream->ctrl_size >= 34) {
 		put_unaligned_le32(ctrl->dwClockFrequency, &data[26]);
 		data[30] = ctrl->bmFramingInfo;
 		data[31] = ctrl->bPreferedVersion;
@@ -411,11 +421,11 @@ static int uvc_set_video_ctrl(struct uvc_streaming *stream,
 
 	ret = __uvc_query_ctrl(stream->dev, UVC_SET_CUR, 0, stream->intfnum,
 		probe ? UVC_VS_PROBE_CONTROL : UVC_VS_COMMIT_CONTROL, data,
-		size, uvc_timeout_param);
-	if (ret != size) {
+		stream->ctrl_size, uvc_timeout_param);
+	if (ret != stream->ctrl_size) {
 		dev_err(&stream->intf->dev,
 			"Failed to set UVC %s control : %d (exp. %u).\n",
-			probe ? "probe" : "commit", ret, size);
+			probe ? "probe" : "commit", ret, stream->ctrl_size);
 		ret = -EIO;
 	}
 
@@ -2231,6 +2241,8 @@ int uvc_video_init(struct uvc_streaming *stream)
 
 	atomic_set(&stream->active, 0);
 
+	stream->ctrl_size = uvc_video_ctrl_size(stream);
+
 	/*
 	 * Alternate setting 0 should be the default, yet the XBox Live Vision
 	 * Cam (and possibly other devices) crash or otherwise misbehave if
drivers/media/usb/uvc/uvcvideo.h +2 -0
index abcafd929c9e..8d99e857a69f 100644
@@ -461,6 +461,7 @@ struct uvc_streaming {
 	struct usb_interface *intf;
 	int intfnum;
 	u32 maxpsize;
+	unsigned int ctrl_size;
 
 	struct uvc_streaming_header header;
 	enum v4l2_buf_type type;
@@ -662,6 +663,7 @@ static inline struct uvc_fh *to_uvc_fh(struct file *filp)
 #define UVC_WARN_PROBE_DEF	1
 #define UVC_WARN_XU_GET_RES	2
 #define UVC_WARN_QUERY_CTRL	3
+#define UVC_WARN_CTRL_SIZE	4
 
 extern unsigned int uvc_clock_param;
 extern unsigned int uvc_no_drop_param;
maintainer
#9 lore raw

Re: [PATCH v3 3/5] media: uvcvideo: Automatically handle cameras with invalid uvc_version

In reply to Ricardo Ribalda
Quoted 10 lines · Ricardo Ribalda

Currently, the driver expects that cameras properly implement the spec version that they announce, and if they fail to do so, we do not continue probing the driver.

To make drivers more fun, some vendors decided to announce that they are a UVC version that they are not. Until now, we handled those cameras via quirks.

Unfortunately, reality has shown us that there are more cameras out there with an invalid uvc_version than we initially predicted.

As far as I understand, this was triggered by the Avermedia GC515. Have you received other reports ?

Quoted 2 lines

This patch tries to handle these cameras with an identity crisis automatically. We still shame them in dmesg. But now they will work.

If the vendors ignored the fact that those cameras didn't work at all on Linux, do you think they will read dmesg ?

Jokes aside, UVC version override was added in November 2020, and the Avermedia GC515 is the fourth device we list in nearly 6 years. Let's see if there are any drawbacks in the implementation below that can be justified by such a small number of devices.

Quoted 24 lines
---
 drivers/media/usb/uvc/uvc_driver.c | 11 +++++++----
 drivers/media/usb/uvc/uvc_video.c  | 40 +++++++++++++++++++++++++-------------
 drivers/media/usb/uvc/uvcvideo.h   |  2 ++
 3 files changed, 35 insertions(+), 18 deletions(-)
drivers/media/usb/uvc/uvc_driver.c +1 -3
index e289cc71ba98..ca75f8d1ec46 100644
@@ -1169,9 +1169,7 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
 
 	case UVC_VC_PROCESSING_UNIT:
 		n = buflen >= 8 ? buffer[7] : 0;
-		p = dev->uvc_version >= 0x0110 ? 10 : 9;
-
-		if (buflen < p + n) {
+		if (buflen < 9 + n) {
 			uvc_dbg(dev, DESCR,
 				"device %d videocontrol interface %d PROCESSING_UNIT error\n",
 				udev->devnum, alts->desc.bInterfaceNumber);

drivers/media/usb/uvc/uvc_driver.c static int uvc_parse_standard_control(struct uvc_device *dev, · line 1192

Quoted 8 lines
drivers/media/usb/uvc/uvc_driver.c +4 -1
@@ -1188,7 +1186,12 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
 		unit->processing.bControlSize = buffer[7];
 		unit->processing.bmControls = (u8 *)unit + sizeof(*unit);
 		memcpy(unit->processing.bmControls, &buffer[8], n);
-		if (dev->uvc_version >= 0x0110)
+
+		/*
+		 * We are not using bmVideoStandards, so there is no need to
+		 * warn the user if it is missing.

There's value in warning the user about UVC non-compliance though. I'd like to see a warning that indicates the device reports an incorrect UVC version.

If I'm not mistaken, the Avermedia GC515 includes the bmVideoStandards field. This change is therefore not needed for any devices we know about, right ?

Quoted 74 lines
drivers/media/usb/uvc/uvc_driver.c +2 -0
+		 */
+		if (dev->uvc_version >= 0x0110 && buflen >= (n + 10))
 			unit->processing.bmVideoStandards = buffer[9+n];
 
 		uvc_entity_set_name(dev, unit, "Processing", buffer[8+n]);
drivers/media/usb/uvc/uvc_video.c +9 -7
index 2a3b7431cc68..2f3daa920ffa 100644
@@ -273,6 +273,8 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
 	}
 }
 
+#define UVC_VIDEO_CTRL_MIN_SIZE 26
+
 static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
 {
 	/*
@@ -280,7 +282,7 @@ static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
 	 * on the protocol version.
 	 */
 	if (stream->dev->uvc_version < 0x0110)
-		return 26;
+		return UVC_VIDEO_CTRL_MIN_SIZE;
 	else if (stream->dev->uvc_version < 0x0150)
 		return 34;
 	else
@@ -290,7 +292,6 @@ static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
 static int uvc_get_video_ctrl(struct uvc_streaming *stream,
 	struct uvc_streaming_control *ctrl, int probe, u8 query)
 {
-	u16 size = uvc_video_ctrl_size(stream);
 	u8 *data;
 	int ret;
 
@@ -298,13 +299,13 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
 			query == UVC_GET_DEF)
 		return -EIO;
 
-	data = kmalloc(size, GFP_KERNEL);
+	data = kmalloc(stream->ctrl_size, GFP_KERNEL);
 	if (data == NULL)
 		return -ENOMEM;
 
 	ret = __uvc_query_ctrl(stream->dev, query, 0, stream->intfnum,
 		probe ? UVC_VS_PROBE_CONTROL : UVC_VS_COMMIT_CONTROL, data,
-		size, uvc_timeout_param);
+		stream->ctrl_size, uvc_timeout_param);
 
 	if ((query == UVC_GET_MIN || query == UVC_GET_MAX) && ret == 2) {
 		/*
@@ -319,7 +320,8 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
 		ctrl->wCompQuality = le16_to_cpup((__le16 *)data);
 		ret = 0;
 		goto out;
-	} else if (query == UVC_GET_DEF && probe == 1 && ret != size) {
+	} else if (query == UVC_GET_DEF && probe == 1 &&
+		   ret < UVC_VIDEO_CTRL_MIN_SIZE) {
 		/*
 		 * Many cameras don't support the GET_DEF request on their
 		 * video probe control. Warn once and return, the caller will
@@ -330,15 +332,24 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
 			"Enabling workaround.\n");
 		ret = -EIO;
 		goto out;
-	} else if (ret != size) {
+	} else if (ret < UVC_VIDEO_CTRL_MIN_SIZE) {
 		dev_err(&stream->intf->dev,
 			"Failed to query (%s) UVC %s control : %d (exp. %u).\n",
 			uvc_query_name(query), probe ? "probe" : "commit",
-			ret, size);
+			ret, stream->ctrl_size);
 		ret = (ret == -EPROTO) ? -EPROTO : -EIO;
 		goto out;

drivers/media/usb/uvc/uvc_video.c static int uvc_get_video_ctrl(struct uvc_streaming *stream, · line 351

Quoted 10 lines
drivers/media/usb/uvc/uvc_video.c +8 -0
 	}
 
+	if (ret != stream->ctrl_size) {
+		uvc_warn_once(stream->dev, UVC_WARN_CTRL_SIZE,
+			      "UVC non compliance: Query (%s) UVC %s control had a size of %d instead of %u.\n",
+			      uvc_query_name(query),
+			      probe ? "probe" : "commit", ret,
+			      stream->ctrl_size);
+		stream->ctrl_size = ret;
+	}

There are two other locations where uvc_version is used:

- In uvc_fixup_video_ctrl() to implement a workaround for pre-1.10 devices that don't report dwMaxVideoFrameSize

- In uvc_ctrl_filter_plf_mapping() to stkip the power line frequency control on pre-1.50 devices

None of those are handled in this patch. Furthermore, more usage of uvc_version may be needed in the future. This patch seems a bit fragile to me in that regard. Could we instead detect the version and update the uvc_version field ?

Another option, given the small number of affected devices, is to just merge 5/5 (as well as 1/5 and 2/5 that are nice small improvements).

Quoted 64 lines
drivers/media/usb/uvc/uvc_video.c +9 -7
+
 	ctrl->bmHint = le16_to_cpup((__le16 *)&data[0]);
 	ctrl->bFormatIndex = data[2];
 	ctrl->bFrameIndex = data[3];
@@ -351,7 +362,7 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
 	ctrl->dwMaxVideoFrameSize = get_unaligned_le32(&data[18]);
 	ctrl->dwMaxPayloadTransferSize = get_unaligned_le32(&data[22]);
 
-	if (size >= 34) {
+	if (ret >= 34) {
 		ctrl->dwClockFrequency = get_unaligned_le32(&data[26]);
 		ctrl->bmFramingInfo = data[30];
 		ctrl->bPreferedVersion = data[31];
@@ -381,11 +392,10 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
 static int uvc_set_video_ctrl(struct uvc_streaming *stream,
 	struct uvc_streaming_control *ctrl, int probe)
 {
-	u16 size = uvc_video_ctrl_size(stream);
 	u8 *data;
 	int ret;
 
-	data = kzalloc(size, GFP_KERNEL);
+	data = kzalloc(stream->ctrl_size, GFP_KERNEL);
 	if (data == NULL)
 		return -ENOMEM;
 
@@ -401,7 +411,7 @@ static int uvc_set_video_ctrl(struct uvc_streaming *stream,
 	put_unaligned_le32(ctrl->dwMaxVideoFrameSize, &data[18]);
 	put_unaligned_le32(ctrl->dwMaxPayloadTransferSize, &data[22]);
 
-	if (size >= 34) {
+	if (stream->ctrl_size >= 34) {
 		put_unaligned_le32(ctrl->dwClockFrequency, &data[26]);
 		data[30] = ctrl->bmFramingInfo;
 		data[31] = ctrl->bPreferedVersion;
@@ -411,11 +421,11 @@ static int uvc_set_video_ctrl(struct uvc_streaming *stream,
 
 	ret = __uvc_query_ctrl(stream->dev, UVC_SET_CUR, 0, stream->intfnum,
 		probe ? UVC_VS_PROBE_CONTROL : UVC_VS_COMMIT_CONTROL, data,
-		size, uvc_timeout_param);
-	if (ret != size) {
+		stream->ctrl_size, uvc_timeout_param);
+	if (ret != stream->ctrl_size) {
 		dev_err(&stream->intf->dev,
 			"Failed to set UVC %s control : %d (exp. %u).\n",
-			probe ? "probe" : "commit", ret, size);
+			probe ? "probe" : "commit", ret, stream->ctrl_size);
 		ret = -EIO;
 	}
 
@@ -2231,6 +2241,8 @@ int uvc_video_init(struct uvc_streaming *stream)
 
 	atomic_set(&stream->active, 0);
 
+	stream->ctrl_size = uvc_video_ctrl_size(stream);
+
 	/*
 	 * Alternate setting 0 should be the default, yet the XBox Live Vision
 	 * Cam (and possibly other devices) crash or otherwise misbehave if
drivers/media/usb/uvc/uvcvideo.h +0 -0
index abcafd929c9e..8d99e857a69f 100644

drivers/media/usb/uvc/uvcvideo.h struct uvc_streaming { · line 464

Quoted 4 lines
drivers/media/usb/uvc/uvcvideo.h +1 -0
@@ -461,6 +461,7 @@ struct uvc_streaming {
 	struct usb_interface *intf;
 	int intfnum;
 	u32 maxpsize;
+	unsigned int ctrl_size;

That should be called video_ctrl_size, ctrl_size is ambiguous.

Quoted 11 lines
drivers/media/usb/uvc/uvcvideo.h +1 -0
 	struct uvc_streaming_header header;
 	enum v4l2_buf_type type;
@@ -662,6 +663,7 @@ static inline struct uvc_fh *to_uvc_fh(struct file *filp)
 #define UVC_WARN_PROBE_DEF	1
 #define UVC_WARN_XU_GET_RES	2
 #define UVC_WARN_QUERY_CTRL	3
+#define UVC_WARN_CTRL_SIZE	4
 
 extern unsigned int uvc_clock_param;
 extern unsigned int uvc_no_drop_param;
Signature · 3 lines
Regards,

Laurent Pinchart
#10 lore raw

Re: [PATCH v3 3/5] media: uvcvideo: Automatically handle cameras with invalid uvc_version

Quoted 10 lines · Laurent Pinchart
Quoted 8 lines · Ricardo Ribalda

Currently, the driver expects that cameras properly implement the spec version that they announce, and if they fail to do so, we do not continue probing the driver.

To make drivers more fun, some vendors decided to announce that they are a UVC version that they are not. Until now, we handled those cameras via quirks.

Quoted 5 lines
Quoted 2 lines

Unfortunately, reality has shown us that there are more cameras out there with an invalid uvc_version than we initially predicted.

As far as I understand, this was triggered by the Avermedia GC515. Have you received other reports ?

I have not, but we can agree that not that many people does the extra mile to report to this mailing list.

If multiple cameras, from different ISPs have this issue it makes me think that Windows is handling this uvc_version more naively than us, and unfortunately it is what most vendors use to validate their cameras.

I'd rather support more cameras than fewer.

Quoted 6 lines
Quoted 3 lines

This patch tries to handle these cameras with an identity crisis automatically. We still shame them in dmesg. But now they will work.

If the vendors ignored the fact that those cameras didn't work at all on Linux, do you think they will read dmesg ?

They wont, but distros might look into logs and keep track of warnings/logs.

Quoted 43 lines

Jokes aside, UVC version override was added in November 2020, and the Avermedia GC515 is the fourth device we list in nearly 6 years. Let's see if there are any drawbacks in the implementation below that can be justified by such a small number of devices.

Quoted 24 lines
---
 drivers/media/usb/uvc/uvc_driver.c | 11 +++++++----
 drivers/media/usb/uvc/uvc_video.c  | 40 +++++++++++++++++++++++++-------------
 drivers/media/usb/uvc/uvcvideo.h   |  2 ++
 3 files changed, 35 insertions(+), 18 deletions(-)
drivers/media/usb/uvc/uvc_driver.c +1 -3
index e289cc71ba98..ca75f8d1ec46 100644
@@ -1169,9 +1169,7 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
 
      case UVC_VC_PROCESSING_UNIT:
              n = buflen >= 8 ? buffer[7] : 0;
-             p = dev->uvc_version >= 0x0110 ? 10 : 9;
-
-             if (buflen < p + n) {
+             if (buflen < 9 + n) {
                      uvc_dbg(dev, DESCR,
                              "device %d videocontrol interface %d PROCESSING_UNIT error\n",
                              udev->devnum, alts->desc.bInterfaceNumber);

drivers/media/usb/uvc/uvc_driver.c static int uvc_parse_standard_control(struct uvc_device *dev, · line 1192

Quoted 8 lines
drivers/media/usb/uvc/uvc_driver.c +4 -1
@@ -1188,7 +1186,12 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
              unit->processing.bControlSize = buffer[7];
              unit->processing.bmControls = (u8 *)unit + sizeof(*unit);
              memcpy(unit->processing.bmControls, &buffer[8], n);
-             if (dev->uvc_version >= 0x0110)
+
+             /*
+              * We are not using bmVideoStandards, so there is no need to
+              * warn the user if it is missing.

There's value in warning the user about UVC non-compliance though. I'd like to see a warning that indicates the device reports an incorrect UVC version.

Quoted 3 lines

If I'm not mistaken, the Avermedia GC515 includes the bmVideoStandards field. This change is therefore not needed for any devices we know about, right ?

We do not know if it includes the bmVideoStandards or not. Wihout
https://lore.kernel.org/linux-media/[email protected]/T/#t
it might leaking the next control. (this is how I started working on the other patch).

Luckily for us bmVideoStandards is not used.

Quoted 91 lines
Quoted 75 lines
drivers/media/usb/uvc/uvc_driver.c +2 -0
+              */
+             if (dev->uvc_version >= 0x0110 && buflen >= (n + 10))
                      unit->processing.bmVideoStandards = buffer[9+n];
 
              uvc_entity_set_name(dev, unit, "Processing", buffer[8+n]);
drivers/media/usb/uvc/uvc_video.c +9 -7
index 2a3b7431cc68..2f3daa920ffa 100644
@@ -273,6 +273,8 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
      }
 }
 
+#define UVC_VIDEO_CTRL_MIN_SIZE 26
+
 static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
 {
      /*
@@ -280,7 +282,7 @@ static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
       * on the protocol version.
       */
      if (stream->dev->uvc_version < 0x0110)
-             return 26;
+             return UVC_VIDEO_CTRL_MIN_SIZE;
      else if (stream->dev->uvc_version < 0x0150)
              return 34;
      else
@@ -290,7 +292,6 @@ static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
 static int uvc_get_video_ctrl(struct uvc_streaming *stream,
      struct uvc_streaming_control *ctrl, int probe, u8 query)
 {
-     u16 size = uvc_video_ctrl_size(stream);
      u8 *data;
      int ret;
 
@@ -298,13 +299,13 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
                      query == UVC_GET_DEF)
              return -EIO;
 
-     data = kmalloc(size, GFP_KERNEL);
+     data = kmalloc(stream->ctrl_size, GFP_KERNEL);
      if (data == NULL)
              return -ENOMEM;
 
      ret = __uvc_query_ctrl(stream->dev, query, 0, stream->intfnum,
              probe ? UVC_VS_PROBE_CONTROL : UVC_VS_COMMIT_CONTROL, data,
-             size, uvc_timeout_param);
+             stream->ctrl_size, uvc_timeout_param);
 
      if ((query == UVC_GET_MIN || query == UVC_GET_MAX) && ret == 2) {
              /*
@@ -319,7 +320,8 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
              ctrl->wCompQuality = le16_to_cpup((__le16 *)data);
              ret = 0;
              goto out;
-     } else if (query == UVC_GET_DEF && probe == 1 && ret != size) {
+     } else if (query == UVC_GET_DEF && probe == 1 &&
+                ret < UVC_VIDEO_CTRL_MIN_SIZE) {
              /*
               * Many cameras don't support the GET_DEF request on their
               * video probe control. Warn once and return, the caller will
@@ -330,15 +332,24 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
                      "Enabling workaround.\n");
              ret = -EIO;
              goto out;
-     } else if (ret != size) {
+     } else if (ret < UVC_VIDEO_CTRL_MIN_SIZE) {
              dev_err(&stream->intf->dev,
                      "Failed to query (%s) UVC %s control : %d (exp. %u).\n",
                      uvc_query_name(query), probe ? "probe" : "commit",
-                     ret, size);
+                     ret, stream->ctrl_size);
              ret = (ret == -EPROTO) ? -EPROTO : -EIO;
              goto out;

drivers/media/usb/uvc/uvc_video.c static int uvc_get_video_ctrl(struct uvc_streaming *stream, · line 351

Quoted 10 lines
drivers/media/usb/uvc/uvc_video.c +8 -0
      }
 
+     if (ret != stream->ctrl_size) {
+             uvc_warn_once(stream->dev, UVC_WARN_CTRL_SIZE,
+                           "UVC non compliance: Query (%s) UVC %s control had a size of %d instead of %u.\n",
+                           uvc_query_name(query),
+                           probe ? "probe" : "commit", ret,
+                           stream->ctrl_size);
+             stream->ctrl_size = ret;
+     }

There are two other locations where uvc_version is used:

- In uvc_fixup_video_ctrl() to implement a workaround for pre-1.10 devices that don't report dwMaxVideoFrameSize

Quoted 7 lines

- In uvc_ctrl_filter_plf_mapping() to stkip the power line frequency control on pre-1.50 devices

None of those are handled in this patch. Furthermore, more usage of uvc_version may be needed in the future. This patch seems a bit fragile to me in that regard. Could we instead detect the version and update the uvc_version field ?

Will send a follow-up to fix dwMaxVideoFrameSize.

uvc_ctrl_filter_plf_mapping properly handes devices with invalid uvc_version. It automatically probes the control.

I though about parsing the uvc_version, but then I realised that some devices might implement video_ctrl_size correctly but not filter_plf (or the other way around).
So I decided that this was better.

Quoted 3 lines

Another option, given the small number of affected devices, is to just merge 5/5 (as well as 1/5 and 2/5 that are nice small improvements).

I'd argue that 4/5 is also a nice to have.

Quoted 55 lines
Quoted 55 lines
drivers/media/usb/uvc/uvc_video.c +7 -7
+
      ctrl->bmHint = le16_to_cpup((__le16 *)&data[0]);
      ctrl->bFormatIndex = data[2];
      ctrl->bFrameIndex = data[3];
@@ -351,7 +362,7 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
      ctrl->dwMaxVideoFrameSize = get_unaligned_le32(&data[18]);
      ctrl->dwMaxPayloadTransferSize = get_unaligned_le32(&data[22]);
 
-     if (size >= 34) {
+     if (ret >= 34) {
              ctrl->dwClockFrequency = get_unaligned_le32(&data[26]);
              ctrl->bmFramingInfo = data[30];
              ctrl->bPreferedVersion = data[31];
@@ -381,11 +392,10 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
 static int uvc_set_video_ctrl(struct uvc_streaming *stream,
      struct uvc_streaming_control *ctrl, int probe)
 {
-     u16 size = uvc_video_ctrl_size(stream);
      u8 *data;
      int ret;
 
-     data = kzalloc(size, GFP_KERNEL);
+     data = kzalloc(stream->ctrl_size, GFP_KERNEL);
      if (data == NULL)
              return -ENOMEM;
 
@@ -401,7 +411,7 @@ static int uvc_set_video_ctrl(struct uvc_streaming *stream,
      put_unaligned_le32(ctrl->dwMaxVideoFrameSize, &data[18]);
      put_unaligned_le32(ctrl->dwMaxPayloadTransferSize, &data[22]);
 
-     if (size >= 34) {
+     if (stream->ctrl_size >= 34) {
              put_unaligned_le32(ctrl->dwClockFrequency, &data[26]);
              data[30] = ctrl->bmFramingInfo;
              data[31] = ctrl->bPreferedVersion;
@@ -411,11 +421,11 @@ static int uvc_set_video_ctrl(struct uvc_streaming *stream,
 
      ret = __uvc_query_ctrl(stream->dev, UVC_SET_CUR, 0, stream->intfnum,
              probe ? UVC_VS_PROBE_CONTROL : UVC_VS_COMMIT_CONTROL, data,
-             size, uvc_timeout_param);
-     if (ret != size) {
+             stream->ctrl_size, uvc_timeout_param);
+     if (ret != stream->ctrl_size) {
              dev_err(&stream->intf->dev,
                      "Failed to set UVC %s control : %d (exp. %u).\n",
-                     probe ? "probe" : "commit", ret, size);
+                     probe ? "probe" : "commit", ret, stream->ctrl_size);
              ret = -EIO;
      }
 
@@ -2231,6 +2241,8 @@ int uvc_video_init(struct uvc_streaming *stream)
 
      atomic_set(&stream->active, 0);
 
Quoted 16 lines
Quoted 10 lines
drivers/media/usb/uvc/uvc_video.c +2 -0
+     stream->ctrl_size = uvc_video_ctrl_size(stream);
+
      /*
       * Alternate setting 0 should be the default, yet the XBox Live Vision
       * Cam (and possibly other devices) crash or otherwise misbehave if
drivers/media/usb/uvc/uvcvideo.h +0 -0
index abcafd929c9e..8d99e857a69f 100644

drivers/media/usb/uvc/uvcvideo.h struct uvc_streaming { · line 464

Quoted 4 lines
drivers/media/usb/uvc/uvcvideo.h +1 -0
@@ -461,6 +461,7 @@ struct uvc_streaming {
      struct usb_interface *intf;
      int intfnum;
      u32 maxpsize;
+     unsigned int ctrl_size;

That should be called video_ctrl_size, ctrl_size is ambiguous.

Ack

Quoted 17 lines

drivers/media/usb/uvc/uvcvideo.h static inline struct uvc_fh *to_uvc_fh(struct file *filp) · line 669

Quoted 12 lines
drivers/media/usb/uvc/uvcvideo.h +1 -0
      struct uvc_streaming_header header;
      enum v4l2_buf_type type;
@@ -662,6 +663,7 @@ static inline struct uvc_fh *to_uvc_fh(struct file *filp)
 #define UVC_WARN_PROBE_DEF   1
 #define UVC_WARN_XU_GET_RES  2
 #define UVC_WARN_QUERY_CTRL  3
+#define UVC_WARN_CTRL_SIZE   4
 
 extern unsigned int uvc_clock_param;
 extern unsigned int uvc_no_drop_param;

--
Regards,

Laurent Pinchart

Signature · 1 line
Ricardo Ribalda
maintainer
#11 lore raw

Re: [PATCH v3 3/5] media: uvcvideo: Automatically handle cameras with invalid uvc_version

Quoted 13 lines · Ricardo Ribalda
Quoted 12 lines · Laurent Pinchart
Quoted 10 lines · Ricardo Ribalda

Currently, the driver expects that cameras properly implement the spec version that they announce, and if they fail to do so, we do not continue probing the driver.

To make drivers more fun, some vendors decided to announce that they are a UVC version that they are not. Until now, we handled those cameras via quirks.

Unfortunately, reality has shown us that there are more cameras out there with an invalid uvc_version than we initially predicted.

Quoted 8 lines
Quoted 2 lines

As far as I understand, this was triggered by the Avermedia GC515. Have you received other reports ?

I have not, but we can agree that not that many people does the extra mile to report to this mailing list.

If multiple cameras, from different ISPs have this issue it makes me think that Windows is handling this uvc_version more naively than us,

That's likely a fair assumption. Who would have thought that we would still suffer from Microsoft's bad design decisions today ?

Quoted 5 lines

and unfortunately it is what most vendors use to validate their cameras.

I'd rather support more cameras than fewer.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

This patch tries to handle these cameras with an identity crisis automatically. We still shame them in dmesg. But now they will work.

If the vendors ignored the fact that those cameras didn't work at all on Linux, do you think they will read dmesg ?

They wont, but distros might look into logs and keep track of warnings/logs.

It was meant as a joke.

Quoted 42 lines
Quoted 42 lines

Jokes aside, UVC version override was added in November 2020, and the Avermedia GC515 is the fourth device we list in nearly 6 years. Let's see if there are any drawbacks in the implementation below that can be justified by such a small number of devices.

Quoted 24 lines
---
 drivers/media/usb/uvc/uvc_driver.c | 11 +++++++----
 drivers/media/usb/uvc/uvc_video.c  | 40 +++++++++++++++++++++++++-------------
 drivers/media/usb/uvc/uvcvideo.h   |  2 ++
 3 files changed, 35 insertions(+), 18 deletions(-)
drivers/media/usb/uvc/uvc_driver.c +1 -3
index e289cc71ba98..ca75f8d1ec46 100644
@@ -1169,9 +1169,7 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
 
      case UVC_VC_PROCESSING_UNIT:
              n = buflen >= 8 ? buffer[7] : 0;
-             p = dev->uvc_version >= 0x0110 ? 10 : 9;
-
-             if (buflen < p + n) {
+             if (buflen < 9 + n) {
                      uvc_dbg(dev, DESCR,
                              "device %d videocontrol interface %d PROCESSING_UNIT error\n",
                              udev->devnum, alts->desc.bInterfaceNumber);

drivers/media/usb/uvc/uvc_driver.c static int uvc_parse_standard_control(struct uvc_device *dev, · line 1192

Quoted 8 lines
drivers/media/usb/uvc/uvc_driver.c +4 -1
@@ -1188,7 +1186,12 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
              unit->processing.bControlSize = buffer[7];
              unit->processing.bmControls = (u8 *)unit + sizeof(*unit);
              memcpy(unit->processing.bmControls, &buffer[8], n);
-             if (dev->uvc_version >= 0x0110)
+
+             /*
+              * We are not using bmVideoStandards, so there is no need to
+              * warn the user if it is missing.

There's value in warning the user about UVC non-compliance though. I'd like to see a warning that indicates the device reports an incorrect UVC version.

Quoted 5 lines
Quoted 3 lines

If I'm not mistaken, the Avermedia GC515 includes the bmVideoStandards field. This change is therefore not needed for any devices we know about, right ?

We do not know if it includes the bmVideoStandards or not.

Don't we ? The descriptors show a 13-bytes PU with bControlSize set to 3, so there's 10 bytes for the fixed parts, compatible with UVC 1.10 and newer.

Quoted 3 lines

Wihout
https://lore.kernel.org/linux-media/[email protected]/T/#t
it might leaking the next control.

It would then use the next byte of the next control, which is the bLength field, equal to 0x29. lsusb reports bmVideoStandards 0x00.

Quoted 2 lines

(this is how I started working on
the other patch).

It makes sense now :-)

Quoted 102 lines

Luckily for us bmVideoStandards is not used.

Quoted 90 lines
Quoted 74 lines
drivers/media/usb/uvc/uvc_driver.c +2 -0
+              */
+             if (dev->uvc_version >= 0x0110 && buflen >= (n + 10))
                      unit->processing.bmVideoStandards = buffer[9+n];
 
              uvc_entity_set_name(dev, unit, "Processing", buffer[8+n]);
drivers/media/usb/uvc/uvc_video.c +9 -7
index 2a3b7431cc68..2f3daa920ffa 100644
@@ -273,6 +273,8 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
      }
 }
 
+#define UVC_VIDEO_CTRL_MIN_SIZE 26
+
 static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
 {
      /*
@@ -280,7 +282,7 @@ static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
       * on the protocol version.
       */
      if (stream->dev->uvc_version < 0x0110)
-             return 26;
+             return UVC_VIDEO_CTRL_MIN_SIZE;
      else if (stream->dev->uvc_version < 0x0150)
              return 34;
      else
@@ -290,7 +292,6 @@ static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
 static int uvc_get_video_ctrl(struct uvc_streaming *stream,
      struct uvc_streaming_control *ctrl, int probe, u8 query)
 {
-     u16 size = uvc_video_ctrl_size(stream);
      u8 *data;
      int ret;
 
@@ -298,13 +299,13 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
                      query == UVC_GET_DEF)
              return -EIO;
 
-     data = kmalloc(size, GFP_KERNEL);
+     data = kmalloc(stream->ctrl_size, GFP_KERNEL);
      if (data == NULL)
              return -ENOMEM;
 
      ret = __uvc_query_ctrl(stream->dev, query, 0, stream->intfnum,
              probe ? UVC_VS_PROBE_CONTROL : UVC_VS_COMMIT_CONTROL, data,
-             size, uvc_timeout_param);
+             stream->ctrl_size, uvc_timeout_param);
 
      if ((query == UVC_GET_MIN || query == UVC_GET_MAX) && ret == 2) {
              /*
@@ -319,7 +320,8 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
              ctrl->wCompQuality = le16_to_cpup((__le16 *)data);
              ret = 0;
              goto out;
-     } else if (query == UVC_GET_DEF && probe == 1 && ret != size) {
+     } else if (query == UVC_GET_DEF && probe == 1 &&
+                ret < UVC_VIDEO_CTRL_MIN_SIZE) {
              /*
               * Many cameras don't support the GET_DEF request on their
               * video probe control. Warn once and return, the caller will
@@ -330,15 +332,24 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
                      "Enabling workaround.\n");
              ret = -EIO;
              goto out;
-     } else if (ret != size) {
+     } else if (ret < UVC_VIDEO_CTRL_MIN_SIZE) {
              dev_err(&stream->intf->dev,
                      "Failed to query (%s) UVC %s control : %d (exp. %u).\n",
                      uvc_query_name(query), probe ? "probe" : "commit",
-                     ret, size);
+                     ret, stream->ctrl_size);
              ret = (ret == -EPROTO) ? -EPROTO : -EIO;
              goto out;

drivers/media/usb/uvc/uvc_video.c static int uvc_get_video_ctrl(struct uvc_streaming *stream, · line 351

Quoted 10 lines
drivers/media/usb/uvc/uvc_video.c +8 -0
      }
 
+     if (ret != stream->ctrl_size) {
+             uvc_warn_once(stream->dev, UVC_WARN_CTRL_SIZE,
+                           "UVC non compliance: Query (%s) UVC %s control had a size of %d instead of %u.\n",
+                           uvc_query_name(query),
+                           probe ? "probe" : "commit", ret,
+                           stream->ctrl_size);
+             stream->ctrl_size = ret;
+     }

There are two other locations where uvc_version is used:

- In uvc_fixup_video_ctrl() to implement a workaround for pre-1.10 devices that don't report dwMaxVideoFrameSize

Quoted 7 lines

- In uvc_ctrl_filter_plf_mapping() to stkip the power line frequency control on pre-1.50 devices

None of those are handled in this patch. Furthermore, more usage of uvc_version may be needed in the future. This patch seems a bit fragile to me in that regard. Could we instead detect the version and update the uvc_version field ?

Will send a follow-up to fix dwMaxVideoFrameSize.

Quoted 7 lines

uvc_ctrl_filter_plf_mapping properly handes devices with invalid uvc_version. It automatically probes the control.

I though about parsing the uvc_version, but then I realised that some devices might implement video_ctrl_size correctly but not filter_plf (or the other way around).
So I decided that this was better.

So you're thinking that the driver should implement some sort of hybrid version support ? That makes me fear for security as such a scheme is much more difficult to reason about.

Quoted 89 lines
Quoted 2 lines

Another option, given the small number of affected devices, is to just merge 5/5 (as well as 1/5 and 2/5 that are nice small improvements).

I'd argue that 4/5 is also a nice to have.

Quoted 54 lines
Quoted 54 lines
drivers/media/usb/uvc/uvc_video.c +7 -7
+
      ctrl->bmHint = le16_to_cpup((__le16 *)&data[0]);
      ctrl->bFormatIndex = data[2];
      ctrl->bFrameIndex = data[3];
@@ -351,7 +362,7 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
      ctrl->dwMaxVideoFrameSize = get_unaligned_le32(&data[18]);
      ctrl->dwMaxPayloadTransferSize = get_unaligned_le32(&data[22]);
 
-     if (size >= 34) {
+     if (ret >= 34) {
              ctrl->dwClockFrequency = get_unaligned_le32(&data[26]);
              ctrl->bmFramingInfo = data[30];
              ctrl->bPreferedVersion = data[31];
@@ -381,11 +392,10 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
 static int uvc_set_video_ctrl(struct uvc_streaming *stream,
      struct uvc_streaming_control *ctrl, int probe)
 {
-     u16 size = uvc_video_ctrl_size(stream);
      u8 *data;
      int ret;
 
-     data = kzalloc(size, GFP_KERNEL);
+     data = kzalloc(stream->ctrl_size, GFP_KERNEL);
      if (data == NULL)
              return -ENOMEM;
 
@@ -401,7 +411,7 @@ static int uvc_set_video_ctrl(struct uvc_streaming *stream,
      put_unaligned_le32(ctrl->dwMaxVideoFrameSize, &data[18]);
      put_unaligned_le32(ctrl->dwMaxPayloadTransferSize, &data[22]);
 
-     if (size >= 34) {
+     if (stream->ctrl_size >= 34) {
              put_unaligned_le32(ctrl->dwClockFrequency, &data[26]);
              data[30] = ctrl->bmFramingInfo;
              data[31] = ctrl->bPreferedVersion;
@@ -411,11 +421,11 @@ static int uvc_set_video_ctrl(struct uvc_streaming *stream,
 
      ret = __uvc_query_ctrl(stream->dev, UVC_SET_CUR, 0, stream->intfnum,
              probe ? UVC_VS_PROBE_CONTROL : UVC_VS_COMMIT_CONTROL, data,
-             size, uvc_timeout_param);
-     if (ret != size) {
+             stream->ctrl_size, uvc_timeout_param);
+     if (ret != stream->ctrl_size) {
              dev_err(&stream->intf->dev,
                      "Failed to set UVC %s control : %d (exp. %u).\n",
-                     probe ? "probe" : "commit", ret, size);
+                     probe ? "probe" : "commit", ret, stream->ctrl_size);
              ret = -EIO;
      }
 
@@ -2231,6 +2241,8 @@ int uvc_video_init(struct uvc_streaming *stream)
 
      atomic_set(&stream->active, 0);
 
Quoted 16 lines
Quoted 10 lines
drivers/media/usb/uvc/uvc_video.c +2 -0
+     stream->ctrl_size = uvc_video_ctrl_size(stream);
+
      /*
       * Alternate setting 0 should be the default, yet the XBox Live Vision
       * Cam (and possibly other devices) crash or otherwise misbehave if
drivers/media/usb/uvc/uvcvideo.h +0 -0
index abcafd929c9e..8d99e857a69f 100644

drivers/media/usb/uvc/uvcvideo.h struct uvc_streaming { · line 464

Quoted 4 lines
drivers/media/usb/uvc/uvcvideo.h +1 -0
@@ -461,6 +461,7 @@ struct uvc_streaming {
      struct usb_interface *intf;
      int intfnum;
      u32 maxpsize;
+     unsigned int ctrl_size;

That should be called video_ctrl_size, ctrl_size is ambiguous.

Ack

Quoted 11 lines
Quoted 11 lines
drivers/media/usb/uvc/uvcvideo.h +1 -0
      struct uvc_streaming_header header;
      enum v4l2_buf_type type;
@@ -662,6 +663,7 @@ static inline struct uvc_fh *to_uvc_fh(struct file *filp)
 #define UVC_WARN_PROBE_DEF   1
 #define UVC_WARN_XU_GET_RES  2
 #define UVC_WARN_QUERY_CTRL  3
+#define UVC_WARN_CTRL_SIZE   4
 
 extern unsigned int uvc_clock_param;
 extern unsigned int uvc_no_drop_param;
Signature · 3 lines
Regards,

Laurent Pinchart
#12 lore raw

Re: [PATCH v3 3/5] media: uvcvideo: Automatically handle cameras with invalid uvc_version

Quoted 211 lines · Laurent Pinchart
Quoted 13 lines · Ricardo Ribalda
Quoted 12 lines · Laurent Pinchart
Quoted 10 lines · Ricardo Ribalda

Currently, the driver expects that cameras properly implement the spec version that they announce, and if they fail to do so, we do not continue probing the driver.

To make drivers more fun, some vendors decided to announce that they are a UVC version that they are not. Until now, we handled those cameras via quirks.

Unfortunately, reality has shown us that there are more cameras out there with an invalid uvc_version than we initially predicted.

Quoted 8 lines
Quoted 2 lines

As far as I understand, this was triggered by the Avermedia GC515. Have you received other reports ?

I have not, but we can agree that not that many people does the extra mile to report to this mailing list.

If multiple cameras, from different ISPs have this issue it makes me think that Windows is handling this uvc_version more naively than us,

That's likely a fair assumption. Who would have thought that we would still suffer from Microsoft's bad design decisions today ?

Quoted 5 lines

and unfortunately it is what most vendors use to validate their cameras.

I'd rather support more cameras than fewer.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

This patch tries to handle these cameras with an identity crisis automatically. We still shame them in dmesg. But now they will work.

If the vendors ignored the fact that those cameras didn't work at all on Linux, do you think they will read dmesg ?

They wont, but distros might look into logs and keep track of warnings/logs.

It was meant as a joke.

Quoted 42 lines
Quoted 42 lines

Jokes aside, UVC version override was added in November 2020, and the Avermedia GC515 is the fourth device we list in nearly 6 years. Let's see if there are any drawbacks in the implementation below that can be justified by such a small number of devices.

Quoted 24 lines
---
 drivers/media/usb/uvc/uvc_driver.c | 11 +++++++----
 drivers/media/usb/uvc/uvc_video.c  | 40 +++++++++++++++++++++++++-------------
 drivers/media/usb/uvc/uvcvideo.h   |  2 ++
 3 files changed, 35 insertions(+), 18 deletions(-)
drivers/media/usb/uvc/uvc_driver.c +1 -3
index e289cc71ba98..ca75f8d1ec46 100644
@@ -1169,9 +1169,7 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
 
      case UVC_VC_PROCESSING_UNIT:
              n = buflen >= 8 ? buffer[7] : 0;
-             p = dev->uvc_version >= 0x0110 ? 10 : 9;
-
-             if (buflen < p + n) {
+             if (buflen < 9 + n) {
                      uvc_dbg(dev, DESCR,
                              "device %d videocontrol interface %d PROCESSING_UNIT error\n",
                              udev->devnum, alts->desc.bInterfaceNumber);

drivers/media/usb/uvc/uvc_driver.c static int uvc_parse_standard_control(struct uvc_device *dev, · line 1192

Quoted 8 lines
drivers/media/usb/uvc/uvc_driver.c +4 -1
@@ -1188,7 +1186,12 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
              unit->processing.bControlSize = buffer[7];
              unit->processing.bmControls = (u8 *)unit + sizeof(*unit);
              memcpy(unit->processing.bmControls, &buffer[8], n);
-             if (dev->uvc_version >= 0x0110)
+
+             /*
+              * We are not using bmVideoStandards, so there is no need to
+              * warn the user if it is missing.

There's value in warning the user about UVC non-compliance though. I'd like to see a warning that indicates the device reports an incorrect UVC version.

Quoted 5 lines
Quoted 3 lines

If I'm not mistaken, the Avermedia GC515 includes the bmVideoStandards field. This change is therefore not needed for any devices we know about, right ?

We do not know if it includes the bmVideoStandards or not.

Don't we ? The descriptors show a 13-bytes PU with bControlSize set to 3, so there's 10 bytes for the fixed parts, compatible with UVC 1.10 and newer.

Quoted 3 lines

Wihout
https://lore.kernel.org/linux-media/[email protected]/T/#t
it might leaking the next control.

It would then use the next byte of the next control, which is the bLength field, equal to 0x29. lsusb reports bmVideoStandards 0x00.

Quoted 2 lines

(this is how I started working on
the other patch).

It makes sense now :-)

Quoted 105 lines

Luckily for us bmVideoStandards is not used.

Quoted 90 lines
Quoted 74 lines
drivers/media/usb/uvc/uvc_driver.c +2 -0
+              */
+             if (dev->uvc_version >= 0x0110 && buflen >= (n + 10))
                      unit->processing.bmVideoStandards = buffer[9+n];
 
              uvc_entity_set_name(dev, unit, "Processing", buffer[8+n]);
drivers/media/usb/uvc/uvc_video.c +9 -7
index 2a3b7431cc68..2f3daa920ffa 100644
@@ -273,6 +273,8 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
      }
 }
 
+#define UVC_VIDEO_CTRL_MIN_SIZE 26
+
 static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
 {
      /*
@@ -280,7 +282,7 @@ static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
       * on the protocol version.
       */
      if (stream->dev->uvc_version < 0x0110)
-             return 26;
+             return UVC_VIDEO_CTRL_MIN_SIZE;
      else if (stream->dev->uvc_version < 0x0150)
              return 34;
      else
@@ -290,7 +292,6 @@ static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
 static int uvc_get_video_ctrl(struct uvc_streaming *stream,
      struct uvc_streaming_control *ctrl, int probe, u8 query)
 {
-     u16 size = uvc_video_ctrl_size(stream);
      u8 *data;
      int ret;
 
@@ -298,13 +299,13 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
                      query == UVC_GET_DEF)
              return -EIO;
 
-     data = kmalloc(size, GFP_KERNEL);
+     data = kmalloc(stream->ctrl_size, GFP_KERNEL);
      if (data == NULL)
              return -ENOMEM;
 
      ret = __uvc_query_ctrl(stream->dev, query, 0, stream->intfnum,
              probe ? UVC_VS_PROBE_CONTROL : UVC_VS_COMMIT_CONTROL, data,
-             size, uvc_timeout_param);
+             stream->ctrl_size, uvc_timeout_param);
 
      if ((query == UVC_GET_MIN || query == UVC_GET_MAX) && ret == 2) {
              /*
@@ -319,7 +320,8 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
              ctrl->wCompQuality = le16_to_cpup((__le16 *)data);
              ret = 0;
              goto out;
-     } else if (query == UVC_GET_DEF && probe == 1 && ret != size) {
+     } else if (query == UVC_GET_DEF && probe == 1 &&
+                ret < UVC_VIDEO_CTRL_MIN_SIZE) {
              /*
               * Many cameras don't support the GET_DEF request on their
               * video probe control. Warn once and return, the caller will
@@ -330,15 +332,24 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
                      "Enabling workaround.\n");
              ret = -EIO;
              goto out;
-     } else if (ret != size) {
+     } else if (ret < UVC_VIDEO_CTRL_MIN_SIZE) {
              dev_err(&stream->intf->dev,
                      "Failed to query (%s) UVC %s control : %d (exp. %u).\n",
                      uvc_query_name(query), probe ? "probe" : "commit",
-                     ret, size);
+                     ret, stream->ctrl_size);
              ret = (ret == -EPROTO) ? -EPROTO : -EIO;
              goto out;

drivers/media/usb/uvc/uvc_video.c static int uvc_get_video_ctrl(struct uvc_streaming *stream, · line 351

Quoted 10 lines
drivers/media/usb/uvc/uvc_video.c +8 -0
      }
 
+     if (ret != stream->ctrl_size) {
+             uvc_warn_once(stream->dev, UVC_WARN_CTRL_SIZE,
+                           "UVC non compliance: Query (%s) UVC %s control had a size of %d instead of %u.\n",
+                           uvc_query_name(query),
+                           probe ? "probe" : "commit", ret,
+                           stream->ctrl_size);
+             stream->ctrl_size = ret;
+     }

There are two other locations where uvc_version is used:

- In uvc_fixup_video_ctrl() to implement a workaround for pre-1.10 devices that don't report dwMaxVideoFrameSize

Quoted 7 lines

- In uvc_ctrl_filter_plf_mapping() to stkip the power line frequency control on pre-1.50 devices

None of those are handled in this patch. Furthermore, more usage of uvc_version may be needed in the future. This patch seems a bit fragile to me in that regard. Could we instead detect the version and update the uvc_version field ?

Will send a follow-up to fix dwMaxVideoFrameSize.

uvc_ctrl_filter_plf_mapping properly handes devices with invalid uvc_version. It automatically probes the control.

Quoted 8 lines
Quoted 4 lines

I though about parsing the uvc_version, but then I realised that some devices might implement video_ctrl_size correctly but not filter_plf (or the other way around).
So I decided that this was better.

So you're thinking that the driver should implement some sort of hybrid version support ? That makes me fear for security as such a scheme is much more difficult to reason about.

I think it is more secure for the driver to use the actual data lengths returned by the device (as this patch does) and rely on probing (like we do for PLF), rather than blindly trusting a version descriptor that we already know vendors get wrong.

I do not see this as hybrid versioning, I see it as defensive programming.

Quoted 95 lines
Quoted 88 lines
Quoted 3 lines

Another option, given the small number of affected devices, is to just merge 5/5 (as well as 1/5 and 2/5 that are nice small improvements).

I'd argue that 4/5 is also a nice to have.

Quoted 54 lines
Quoted 54 lines
drivers/media/usb/uvc/uvc_video.c +7 -7
+
      ctrl->bmHint = le16_to_cpup((__le16 *)&data[0]);
      ctrl->bFormatIndex = data[2];
      ctrl->bFrameIndex = data[3];
@@ -351,7 +362,7 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
      ctrl->dwMaxVideoFrameSize = get_unaligned_le32(&data[18]);
      ctrl->dwMaxPayloadTransferSize = get_unaligned_le32(&data[22]);
 
-     if (size >= 34) {
+     if (ret >= 34) {
              ctrl->dwClockFrequency = get_unaligned_le32(&data[26]);
              ctrl->bmFramingInfo = data[30];
              ctrl->bPreferedVersion = data[31];
@@ -381,11 +392,10 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
 static int uvc_set_video_ctrl(struct uvc_streaming *stream,
      struct uvc_streaming_control *ctrl, int probe)
 {
-     u16 size = uvc_video_ctrl_size(stream);
      u8 *data;
      int ret;
 
-     data = kzalloc(size, GFP_KERNEL);
+     data = kzalloc(stream->ctrl_size, GFP_KERNEL);
      if (data == NULL)
              return -ENOMEM;
 
@@ -401,7 +411,7 @@ static int uvc_set_video_ctrl(struct uvc_streaming *stream,
      put_unaligned_le32(ctrl->dwMaxVideoFrameSize, &data[18]);
      put_unaligned_le32(ctrl->dwMaxPayloadTransferSize, &data[22]);
 
-     if (size >= 34) {
+     if (stream->ctrl_size >= 34) {
              put_unaligned_le32(ctrl->dwClockFrequency, &data[26]);
              data[30] = ctrl->bmFramingInfo;
              data[31] = ctrl->bPreferedVersion;
@@ -411,11 +421,11 @@ static int uvc_set_video_ctrl(struct uvc_streaming *stream,
 
      ret = __uvc_query_ctrl(stream->dev, UVC_SET_CUR, 0, stream->intfnum,
              probe ? UVC_VS_PROBE_CONTROL : UVC_VS_COMMIT_CONTROL, data,
-             size, uvc_timeout_param);
-     if (ret != size) {
+             stream->ctrl_size, uvc_timeout_param);
+     if (ret != stream->ctrl_size) {
              dev_err(&stream->intf->dev,
                      "Failed to set UVC %s control : %d (exp. %u).\n",
-                     probe ? "probe" : "commit", ret, size);
+                     probe ? "probe" : "commit", ret, stream->ctrl_size);
              ret = -EIO;
      }
 
@@ -2231,6 +2241,8 @@ int uvc_video_init(struct uvc_streaming *stream)
 
      atomic_set(&stream->active, 0);
 
Quoted 16 lines
Quoted 10 lines
drivers/media/usb/uvc/uvc_video.c +2 -0
+     stream->ctrl_size = uvc_video_ctrl_size(stream);
+
      /*
       * Alternate setting 0 should be the default, yet the XBox Live Vision
       * Cam (and possibly other devices) crash or otherwise misbehave if
drivers/media/usb/uvc/uvcvideo.h +0 -0
index abcafd929c9e..8d99e857a69f 100644

drivers/media/usb/uvc/uvcvideo.h struct uvc_streaming { · line 464

Quoted 4 lines
drivers/media/usb/uvc/uvcvideo.h +1 -0
@@ -461,6 +461,7 @@ struct uvc_streaming {
      struct usb_interface *intf;
      int intfnum;
      u32 maxpsize;
+     unsigned int ctrl_size;

That should be called video_ctrl_size, ctrl_size is ambiguous.

Ack

Quoted 9 lines
Quoted 9 lines
drivers/media/usb/uvc/uvcvideo.h +1 -0
      struct uvc_streaming_header header;
      enum v4l2_buf_type type;
@@ -662,6 +663,7 @@ static inline struct uvc_fh *to_uvc_fh(struct file *filp)
 #define UVC_WARN_PROBE_DEF   1
 #define UVC_WARN_XU_GET_RES  2
 #define UVC_WARN_QUERY_CTRL  3
+#define UVC_WARN_CTRL_SIZE   4
 
Quoted 2 lines
Quoted 2 lines

drivers/media/usb/uvc/uvcvideo.h static inline struct uvc_fh *to_uvc_fh(struct file *filp) · line 669

Quoted 2 lines
drivers/media/usb/uvc/uvcvideo.h +0 -0
 extern unsigned int uvc_clock_param;
 extern unsigned int uvc_no_drop_param;

--
Regards,

Laurent Pinchart

Signature · 1 line
Ricardo Ribalda
#13 lore raw

Re: [PATCH v3 3/5] media: uvcvideo: Automatically handle cameras with invalid uvc_version

In reply to Ricardo Ribalda
Quoted 186 lines · Ricardo Ribalda
Quoted 10 lines · Laurent Pinchart
Quoted 8 lines · Ricardo Ribalda

Currently, the driver expects that cameras properly implement the spec version that they announce, and if they fail to do so, we do not continue probing the driver.

To make drivers more fun, some vendors decided to announce that they are a UVC version that they are not. Until now, we handled those cameras via quirks.

Quoted 5 lines
Quoted 2 lines

Unfortunately, reality has shown us that there are more cameras out there with an invalid uvc_version than we initially predicted.

As far as I understand, this was triggered by the Avermedia GC515. Have you received other reports ?

I have not, but we can agree that not that many people does the extra mile to report to this mailing list.

If multiple cameras, from different ISPs have this issue it makes me think that Windows is handling this uvc_version more naively than us, and unfortunately it is what most vendors use to validate their cameras.

I'd rather support more cameras than fewer.

Quoted 6 lines
Quoted 3 lines

This patch tries to handle these cameras with an identity crisis automatically. We still shame them in dmesg. But now they will work.

If the vendors ignored the fact that those cameras didn't work at all on Linux, do you think they will read dmesg ?

They wont, but distros might look into logs and keep track of warnings/logs.

Quoted 43 lines

Jokes aside, UVC version override was added in November 2020, and the Avermedia GC515 is the fourth device we list in nearly 6 years. Let's see if there are any drawbacks in the implementation below that can be justified by such a small number of devices.

Quoted 24 lines
---
 drivers/media/usb/uvc/uvc_driver.c | 11 +++++++----
 drivers/media/usb/uvc/uvc_video.c  | 40 +++++++++++++++++++++++++-------------
 drivers/media/usb/uvc/uvcvideo.h   |  2 ++
 3 files changed, 35 insertions(+), 18 deletions(-)
drivers/media/usb/uvc/uvc_driver.c +1 -3
index e289cc71ba98..ca75f8d1ec46 100644
@@ -1169,9 +1169,7 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
 
      case UVC_VC_PROCESSING_UNIT:
              n = buflen >= 8 ? buffer[7] : 0;
-             p = dev->uvc_version >= 0x0110 ? 10 : 9;
-
-             if (buflen < p + n) {
+             if (buflen < 9 + n) {
                      uvc_dbg(dev, DESCR,
                              "device %d videocontrol interface %d PROCESSING_UNIT error\n",
                              udev->devnum, alts->desc.bInterfaceNumber);

drivers/media/usb/uvc/uvc_driver.c static int uvc_parse_standard_control(struct uvc_device *dev, · line 1192

Quoted 8 lines
drivers/media/usb/uvc/uvc_driver.c +4 -1
@@ -1188,7 +1186,12 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
              unit->processing.bControlSize = buffer[7];
              unit->processing.bmControls = (u8 *)unit + sizeof(*unit);
              memcpy(unit->processing.bmControls, &buffer[8], n);
-             if (dev->uvc_version >= 0x0110)
+
+             /*
+              * We are not using bmVideoStandards, so there is no need to
+              * warn the user if it is missing.

There's value in warning the user about UVC non-compliance though. I'd like to see a warning that indicates the device reports an incorrect UVC version.

Quoted 3 lines

If I'm not mistaken, the Avermedia GC515 includes the bmVideoStandards field. This change is therefore not needed for any devices we know about, right ?

We do not know if it includes the bmVideoStandards or not. Wihout
https://lore.kernel.org/linux-media/[email protected]/T/#t
it might leaking the next control. (this is how I started working on the other patch).

Luckily for us bmVideoStandards is not used.

Quoted 94 lines
Quoted 75 lines
drivers/media/usb/uvc/uvc_driver.c +2 -0
+              */
+             if (dev->uvc_version >= 0x0110 && buflen >= (n + 10))
                      unit->processing.bmVideoStandards = buffer[9+n];
 
              uvc_entity_set_name(dev, unit, "Processing", buffer[8+n]);
drivers/media/usb/uvc/uvc_video.c +9 -7
index 2a3b7431cc68..2f3daa920ffa 100644
@@ -273,6 +273,8 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
      }
 }
 
+#define UVC_VIDEO_CTRL_MIN_SIZE 26
+
 static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
 {
      /*
@@ -280,7 +282,7 @@ static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
       * on the protocol version.
       */
      if (stream->dev->uvc_version < 0x0110)
-             return 26;
+             return UVC_VIDEO_CTRL_MIN_SIZE;
      else if (stream->dev->uvc_version < 0x0150)
              return 34;
      else
@@ -290,7 +292,6 @@ static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
 static int uvc_get_video_ctrl(struct uvc_streaming *stream,
      struct uvc_streaming_control *ctrl, int probe, u8 query)
 {
-     u16 size = uvc_video_ctrl_size(stream);
      u8 *data;
      int ret;
 
@@ -298,13 +299,13 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
                      query == UVC_GET_DEF)
              return -EIO;
 
-     data = kmalloc(size, GFP_KERNEL);
+     data = kmalloc(stream->ctrl_size, GFP_KERNEL);
      if (data == NULL)
              return -ENOMEM;
 
      ret = __uvc_query_ctrl(stream->dev, query, 0, stream->intfnum,
              probe ? UVC_VS_PROBE_CONTROL : UVC_VS_COMMIT_CONTROL, data,
-             size, uvc_timeout_param);
+             stream->ctrl_size, uvc_timeout_param);
 
      if ((query == UVC_GET_MIN || query == UVC_GET_MAX) && ret == 2) {
              /*
@@ -319,7 +320,8 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
              ctrl->wCompQuality = le16_to_cpup((__le16 *)data);
              ret = 0;
              goto out;
-     } else if (query == UVC_GET_DEF && probe == 1 && ret != size) {
+     } else if (query == UVC_GET_DEF && probe == 1 &&
+                ret < UVC_VIDEO_CTRL_MIN_SIZE) {
              /*
               * Many cameras don't support the GET_DEF request on their
               * video probe control. Warn once and return, the caller will
@@ -330,15 +332,24 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
                      "Enabling workaround.\n");
              ret = -EIO;
              goto out;
-     } else if (ret != size) {
+     } else if (ret < UVC_VIDEO_CTRL_MIN_SIZE) {
              dev_err(&stream->intf->dev,
                      "Failed to query (%s) UVC %s control : %d (exp. %u).\n",
                      uvc_query_name(query), probe ? "probe" : "commit",
-                     ret, size);
+                     ret, stream->ctrl_size);
              ret = (ret == -EPROTO) ? -EPROTO : -EIO;
              goto out;

drivers/media/usb/uvc/uvc_video.c static int uvc_get_video_ctrl(struct uvc_streaming *stream, · line 351

Quoted 10 lines
drivers/media/usb/uvc/uvc_video.c +8 -0
      }
 
+     if (ret != stream->ctrl_size) {
+             uvc_warn_once(stream->dev, UVC_WARN_CTRL_SIZE,
+                           "UVC non compliance: Query (%s) UVC %s control had a size of %d instead of %u.\n",
+                           uvc_query_name(query),
+                           probe ? "probe" : "commit", ret,
+                           stream->ctrl_size);
+             stream->ctrl_size = ret;
+     }

There are two other locations where uvc_version is used:

- In uvc_fixup_video_ctrl() to implement a workaround for pre-1.10 devices that don't report dwMaxVideoFrameSize

- In uvc_ctrl_filter_plf_mapping() to stkip the power line frequency control on pre-1.50 devices

Quoted 6 lines
Quoted 4 lines

None of those are handled in this patch. Furthermore, more usage of uvc_version may be needed in the future. This patch seems a bit fragile to me in that regard. Could we instead detect the version and update the uvc_version field ?

Will send a follow-up to fix dwMaxVideoFrameSize.

Would this work?

        if (!(format->flags & UVC_FMT_FLAG_COMPRESSED) ||

- (ctrl->dwMaxVideoFrameSize == 0 &&
- stream->dev->uvc_version < 0x0110))
- ctrl->dwMaxVideoFrameSize =
- frame->dwMaxVideoFrameBufferSize;
+ (ctrl->dwMaxVideoFrameSize == 0)) {
+ ctrl->dwMaxVideoFrameSize = frame->dwMaxVideoFrameBufferSize;
+ if (stream->dev->uvc_version >= 0x0110)
+ uvc_warn_once(stream->dev, UVC_WARN_CTRL_SIZE,
+ "UVC non compliance: Missing
dwMaxVideoFrameBufferSize from video_ctrl_size\n");
+ }

Quoted 109 lines

uvc_ctrl_filter_plf_mapping properly handes devices with invalid uvc_version. It automatically probes the control.

I though about parsing the uvc_version, but then I realised that some devices might implement video_ctrl_size correctly but not filter_plf (or the other way around).
So I decided that this was better.

Quoted 3 lines

Another option, given the small number of affected devices, is to just merge 5/5 (as well as 1/5 and 2/5 that are nice small improvements).

I'd argue that 4/5 is also a nice to have.

Quoted 55 lines
Quoted 55 lines
drivers/media/usb/uvc/uvc_video.c +7 -7
+
      ctrl->bmHint = le16_to_cpup((__le16 *)&data[0]);
      ctrl->bFormatIndex = data[2];
      ctrl->bFrameIndex = data[3];
@@ -351,7 +362,7 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
      ctrl->dwMaxVideoFrameSize = get_unaligned_le32(&data[18]);
      ctrl->dwMaxPayloadTransferSize = get_unaligned_le32(&data[22]);
 
-     if (size >= 34) {
+     if (ret >= 34) {
              ctrl->dwClockFrequency = get_unaligned_le32(&data[26]);
              ctrl->bmFramingInfo = data[30];
              ctrl->bPreferedVersion = data[31];
@@ -381,11 +392,10 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
 static int uvc_set_video_ctrl(struct uvc_streaming *stream,
      struct uvc_streaming_control *ctrl, int probe)
 {
-     u16 size = uvc_video_ctrl_size(stream);
      u8 *data;
      int ret;
 
-     data = kzalloc(size, GFP_KERNEL);
+     data = kzalloc(stream->ctrl_size, GFP_KERNEL);
      if (data == NULL)
              return -ENOMEM;
 
@@ -401,7 +411,7 @@ static int uvc_set_video_ctrl(struct uvc_streaming *stream,
      put_unaligned_le32(ctrl->dwMaxVideoFrameSize, &data[18]);
      put_unaligned_le32(ctrl->dwMaxPayloadTransferSize, &data[22]);
 
-     if (size >= 34) {
+     if (stream->ctrl_size >= 34) {
              put_unaligned_le32(ctrl->dwClockFrequency, &data[26]);
              data[30] = ctrl->bmFramingInfo;
              data[31] = ctrl->bPreferedVersion;
@@ -411,11 +421,11 @@ static int uvc_set_video_ctrl(struct uvc_streaming *stream,
 
      ret = __uvc_query_ctrl(stream->dev, UVC_SET_CUR, 0, stream->intfnum,
              probe ? UVC_VS_PROBE_CONTROL : UVC_VS_COMMIT_CONTROL, data,
-             size, uvc_timeout_param);
-     if (ret != size) {
+             stream->ctrl_size, uvc_timeout_param);
+     if (ret != stream->ctrl_size) {
              dev_err(&stream->intf->dev,
                      "Failed to set UVC %s control : %d (exp. %u).\n",
-                     probe ? "probe" : "commit", ret, size);
+                     probe ? "probe" : "commit", ret, stream->ctrl_size);
              ret = -EIO;
      }
 
@@ -2231,6 +2241,8 @@ int uvc_video_init(struct uvc_streaming *stream)
 
      atomic_set(&stream->active, 0);
 
Quoted 16 lines
Quoted 10 lines
drivers/media/usb/uvc/uvc_video.c +2 -0
+     stream->ctrl_size = uvc_video_ctrl_size(stream);
+
      /*
       * Alternate setting 0 should be the default, yet the XBox Live Vision
       * Cam (and possibly other devices) crash or otherwise misbehave if
drivers/media/usb/uvc/uvcvideo.h +0 -0
index abcafd929c9e..8d99e857a69f 100644

drivers/media/usb/uvc/uvcvideo.h struct uvc_streaming { · line 464

Quoted 4 lines
drivers/media/usb/uvc/uvcvideo.h +1 -0
@@ -461,6 +461,7 @@ struct uvc_streaming {
      struct usb_interface *intf;
      int intfnum;
      u32 maxpsize;
+     unsigned int ctrl_size;

That should be called video_ctrl_size, ctrl_size is ambiguous.

Ack

Quoted 10 lines
Quoted 10 lines
drivers/media/usb/uvc/uvcvideo.h +1 -0
      struct uvc_streaming_header header;
      enum v4l2_buf_type type;
@@ -662,6 +663,7 @@ static inline struct uvc_fh *to_uvc_fh(struct file *filp)
 #define UVC_WARN_PROBE_DEF   1
 #define UVC_WARN_XU_GET_RES  2
 #define UVC_WARN_QUERY_CTRL  3
+#define UVC_WARN_CTRL_SIZE   4
 
Quoted 7 lines

drivers/media/usb/uvc/uvcvideo.h static inline struct uvc_fh *to_uvc_fh(struct file *filp) · line 669

Quoted 2 lines
drivers/media/usb/uvc/uvcvideo.h +0 -0
 extern unsigned int uvc_clock_param;
 extern unsigned int uvc_no_drop_param;

--
Regards,

Laurent Pinchart

--
Ricardo Ribalda

Signature · 1 line
Ricardo Ribalda
#14 lore raw

PATCH v3 4/5 media: uvcvideo: Do not parse bmVideoStandards

In reply to Ricardo Ribalda

bmVideoStandards is write only, so there is no need to parse it.

Remove it.

---
 drivers/media/usb/uvc/uvc_driver.c | 7 -------
 drivers/media/usb/uvc/uvcvideo.h   | 1 -
 2 files changed, 8 deletions(-)
drivers/media/usb/uvc/uvc_driver.c +0 -7
index ca75f8d1ec46..adec9d1aa653 100644
@@ -1187,13 +1187,6 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
 		unit->processing.bmControls = (u8 *)unit + sizeof(*unit);
 		memcpy(unit->processing.bmControls, &buffer[8], n);
 
-		/*
-		 * We are not using bmVideoStandards, so there is no need to
-		 * warn the user if it is missing.
-		 */
-		if (dev->uvc_version >= 0x0110 && buflen >= (n + 10))
-			unit->processing.bmVideoStandards = buffer[9+n];
-
 		uvc_entity_set_name(dev, unit, "Processing", buffer[8+n]);
 
 		list_add_tail(&unit->list, &dev->entities);
drivers/media/usb/uvc/uvcvideo.h +0 -1
index 8d99e857a69f..65f232de7821 100644
@@ -228,7 +228,6 @@ struct uvc_entity {
 			u16 wMaxMultiplier;
 			u8  bControlSize;
 			u8  *bmControls;
-			u8  bmVideoStandards;
 		} processing;
 
 		struct {
Signature · 1 line
2.55.0.1007.g17ff1f9808-goog
maintainer Reviewed-by on v3 4/5
#15 lore raw

Re: [PATCH v3 4/5] media: uvcvideo: Do not parse bmVideoStandards

Hi,

Quoted 5 lines · Ricardo Ribalda

bmVideoStandards is write only, so there is no need to parse it.

Remove it.

Thanks, patch looks good to me:

Regards,

Hans

Quoted 36 lines
---
 drivers/media/usb/uvc/uvc_driver.c | 7 -------
 drivers/media/usb/uvc/uvcvideo.h   | 1 -
 2 files changed, 8 deletions(-)
drivers/media/usb/uvc/uvc_driver.c +0 -7
index ca75f8d1ec46..adec9d1aa653 100644
@@ -1187,13 +1187,6 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
 		unit->processing.bmControls = (u8 *)unit + sizeof(*unit);
 		memcpy(unit->processing.bmControls, &buffer[8], n);
 
-		/*
-		 * We are not using bmVideoStandards, so there is no need to
-		 * warn the user if it is missing.
-		 */
-		if (dev->uvc_version >= 0x0110 && buflen >= (n + 10))
-			unit->processing.bmVideoStandards = buffer[9+n];
-
 		uvc_entity_set_name(dev, unit, "Processing", buffer[8+n]);
 
 		list_add_tail(&unit->list, &dev->entities);
drivers/media/usb/uvc/uvcvideo.h +0 -1
index 8d99e857a69f..65f232de7821 100644
@@ -228,7 +228,6 @@ struct uvc_entity {
 			u16 wMaxMultiplier;
 			u8  bControlSize;
 			u8  *bmControls;
-			u8  bmVideoStandards;
 		} processing;
 
 		struct {
#16 lore raw

PATCH v3 5/5 media: uvcvideo: Force UVC version for Avermedia GC515

In reply to Ricardo Ribalda

The device announces itself as UVC 1.5, but it only accepts UVC 1.1 controls.

The camera can probably be handled by the automatic uvc_version handler, but it is more correct to add a quirk and keep some tracking of what vendors are more or less compliant. Also it might be more robust if we introduce more UVC version-dependent code.

Bus 003 Device 021: ID 07ca:1515 AVerMedia Technologies, Inc. X'tra Go GC515 Negotiated speed: High Speed (480Mbps)
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2 [unknown]
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
idVendor 0x07ca AVerMedia Technologies, Inc.
idProduct 0x1515 X'tra Go GC515
bcdDevice 0.10

  iManufacturer           1 AVerMedia
  iProduct                2 X'tra Go GC515
  iSerial                 3 5313180000221
  bNumConfigurations      1

Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x03fd
bNumInterfaces 4
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xc0
Self Powered
MaxPower 500mA
Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 0
bInterfaceCount 2
bFunctionClass 14 Video
bFunctionSubClass 3 Video Interface Collection
bFunctionProtocol 0
iFunction 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 14 Video
bInterfaceSubClass 1 Video Control
bInterfaceProtocol 1
iInterface 0
VideoControl Interface Descriptor:
bLength 13
bDescriptorType 36
bDescriptorSubtype 1 (HEADER)
bcdUVC 1.50
wTotalLength 0x0059
dwClockFrequency 30.000000MHz
bInCollection 1
baInterfaceNr( 0) 1
VideoControl Interface Descriptor:
bLength 18
bDescriptorType 36
bDescriptorSubtype 2 (INPUT_TERMINAL)
bTerminalID 1
wTerminalType 0x0201 Camera Sensor
bAssocTerminal 0
iTerminal 0
wObjectiveFocalLengthMin 0
wObjectiveFocalLengthMax 0
wOcularFocalLength 0
bControlSize 3
bmControls 0x00000000
VideoControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 3 (OUTPUT_TERMINAL)
bTerminalID 2
wTerminalType 0x0101 USB Streaming
bAssocTerminal 0
bSourceID 4
iTerminal 0
VideoControl Interface Descriptor:
bLength 7
bDescriptorType 36
bDescriptorSubtype 4 (SELECTOR_UNIT)
bUnitID 3
bNrInPins 1
baSource( 0) 1
iSelector 0
VideoControl Interface Descriptor:
bLength 13
bDescriptorType 36
bDescriptorSubtype 5 (PROCESSING_UNIT)
bUnitID 4
bSourceID 3
wMaxMultiplier 0
bControlSize 3
bmControls 0x00000000
iProcessing 0
bmVideoStandards 0x00
VideoControl Interface Descriptor:
bLength 29
bDescriptorType 36
bDescriptorSubtype 6 (EXTENSION_UNIT)
bUnitID 5
guidExtensionCode {55be8e1c-2fdb-4f7a-bd8d-b9b1108d20c3}
bNumControls 24
bNrInPins 1
baSourceID( 0) 4
bControlSize 4
bmControls( 0) 0xff
bmControls( 1) 0xff
bmControls( 2) 0xff
bmControls( 3) 0x00
iExtension 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x85 EP 5 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1
VideoControl Endpoint Descriptor:
bLength 5
bDescriptorType 37
bDescriptorSubtype 3 (EP_INTERRUPT)
wMaxTransferSize 64
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 14 Video
bInterfaceSubClass 2 Video Streaming
bInterfaceProtocol 1
iInterface 0
VideoStreaming Interface Descriptor:
bLength 16
bDescriptorType 36
bDescriptorSubtype 1 (INPUT_HEADER)
bNumFormats 3
wTotalLength 0x0303
bEndpointAddress 0x81 EP 1 IN
bmInfo 0
bTerminalLink 2
bStillCaptureMethod 1
bTriggerSupport 0
bTriggerUsage 0
bControlSize 1
bmaControls( 0) 4
bmaControls( 1) 4
bmaControls( 2) 0
VideoStreaming Interface Descriptor:
bLength 28
bDescriptorType 36
bDescriptorSubtype 16 (FORMAT_FRAME_BASED)
bFormatIndex 1
bNumFrameDescriptors 8
guidFormat {34363248-0000-0010-8000-00aa00389b71}
bBitsPerPixel 24
bDefaultFrameIndex 1
bAspectRatioX 0
bAspectRatioY 0
bmInterlaceFlags 0x00
Interlaced stream or variable: No
Fields per frame: 2 fields
Field 1 first: No
Field pattern: Field 1 only
bCopyProtect 1
bVariableSize 1
VideoStreaming Interface Descriptor:
bLength 62
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 1
bmCapabilities 0x01
Still image supported
wWidth 1920
wHeight 1080
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 9
dwBytesPerLine 0
dwFrameInterval( 0) 83333
dwFrameInterval( 1) 83416
dwFrameInterval( 2) 166666
dwFrameInterval( 3) 166833
dwFrameInterval( 4) 200000
dwFrameInterval( 5) 333333
dwFrameInterval( 6) 333667
dwFrameInterval( 7) 400000
dwFrameInterval( 8) 416666
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 2
bmCapabilities 0x01
Still image supported
wWidth 3840
wHeight 2160
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 333333
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 333333
dwFrameInterval( 1) 333667
dwFrameInterval( 2) 400000
dwFrameInterval( 3) 416666
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 3
bmCapabilities 0x01
Still image supported
wWidth 2560
wHeight 1440
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 4
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 800
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 38
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 5
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 720
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 3
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 200000
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 6
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 576
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 200000
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 200000
dwFrameInterval( 1) 400000
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 7
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 333333
dwFrameInterval( 3) 333667
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 8
bmCapabilities 0x01
Still image supported
wWidth 640
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 6
bDescriptorType 36
bDescriptorSubtype 13 (COLORFORMAT)
bColorPrimaries 0 (Unspecified)
bTransferCharacteristics 0 (Unspecified)
bMatrixCoefficients 0 (Unspecified)
VideoStreaming Interface Descriptor:
bLength 28
bDescriptorType 36
bDescriptorSubtype 16 (FORMAT_FRAME_BASED)
bFormatIndex 2
bNumFrameDescriptors 8
guidFormat {43564548-0000-0010-8000-00aa00389b71}
bBitsPerPixel 24
bDefaultFrameIndex 1
bAspectRatioX 0
bAspectRatioY 0
bmInterlaceFlags 0x00
Interlaced stream or variable: No
Fields per frame: 2 fields
Field 1 first: No
Field pattern: Field 1 only
bCopyProtect 1
bVariableSize 1
VideoStreaming Interface Descriptor:
bLength 62
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 1
bmCapabilities 0x01
Still image supported
wWidth 1920
wHeight 1080
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 9
dwBytesPerLine 0
dwFrameInterval( 0) 83333
dwFrameInterval( 1) 83416
dwFrameInterval( 2) 166666
dwFrameInterval( 3) 166833
dwFrameInterval( 4) 200000
dwFrameInterval( 5) 333333
dwFrameInterval( 6) 333667
dwFrameInterval( 7) 400000
dwFrameInterval( 8) 416666
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 2
bmCapabilities 0x01
Still image supported
wWidth 3840
wHeight 2160
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 333333
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 333333
dwFrameInterval( 1) 333667
dwFrameInterval( 2) 400000
dwFrameInterval( 3) 416666
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 3
bmCapabilities 0x01
Still image supported
wWidth 2560
wHeight 1440
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 4
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 800
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 38
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 5
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 720
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 3
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 200000
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 6
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 576
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 200000
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 200000
dwFrameInterval( 1) 400000
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 7
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 333333
dwFrameInterval( 3) 333667
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 8
bmCapabilities 0x01
Still image supported
wWidth 640
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 6
bDescriptorType 36
bDescriptorSubtype 13 (COLORFORMAT)
bColorPrimaries 0 (Unspecified)
bTransferCharacteristics 0 (Unspecified)
bMatrixCoefficients 0 (Unspecified)
VideoStreaming Interface Descriptor:
bLength 11
bDescriptorType 36
bDescriptorSubtype 6 (FORMAT_MJPEG)
bFormatIndex 3
bNumFrameDescriptors 1
bFlags 0
Fixed-size samples: No
bDefaultFrameIndex 1
bAspectRatioX 0
bAspectRatioY 0
bmInterlaceFlags 0x00
Interlaced stream or variable: No
Fields per frame: 1 fields
Field 1 first: No
Field pattern: Field 1 only
bCopyProtect 1
VideoStreaming Interface Descriptor:
bLength 30
bDescriptorType 36
bDescriptorSubtype 7 (FRAME_MJPEG)
bFrameIndex 1
bmCapabilities 0x01
Still image supported
wWidth 1920
wHeight 1080
dwMinBitRate 314572800
dwMaxBitRate 314572800
dwMaxVideoFrameBufferSize 4147200
dwDefaultFrameInterval 166666
bFrameIntervalType 1
dwFrameInterval( 0) 166666
VideoStreaming Interface Descriptor:
bLength 6
bDescriptorType 36
bDescriptorSubtype 13 (COLORFORMAT)
bColorPrimaries 0 (Unspecified)
bTransferCharacteristics 0 (Unspecified)
bMatrixCoefficients 0 (Unspecified)
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 2
bInterfaceCount 2
bFunctionClass 1 Audio
bFunctionSubClass 2 Streaming
bFunctionProtocol 0
iFunction 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 2
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 1 Audio
bInterfaceSubClass 1 Control Device
bInterfaceProtocol 0
iInterface 0
AudioControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 1 (HEADER)
bcdADC 1.00
wTotalLength 0x0026
bInCollection 1
baInterfaceNr(0) 3
AudioControl Interface Descriptor:
bLength 12
bDescriptorType 36
bDescriptorSubtype 2 (INPUT_TERMINAL)
bTerminalID 1
wTerminalType 0x0602 Digital Audio Interface
bAssocTerminal 0
bNrChannels 2
wChannelConfig 0x0003
Left Front (L)
Right Front (R)
iChannelNames 0
iTerminal 0
AudioControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 3 (OUTPUT_TERMINAL)
bTerminalID 2
wTerminalType 0x0101 USB Streaming
bAssocTerminal 0
bSourceID 3
iTerminal 0
AudioControl Interface Descriptor:
bLength 8
bDescriptorType 36
bDescriptorSubtype 6 (FEATURE_UNIT)
bUnitID 3
bSourceID 1
bControlSize 1
bmaControls(0) 0x03
Mute Control
Volume Control
iFeature 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 3
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 1 Audio
bInterfaceSubClass 2 Streaming
bInterfaceProtocol 0
iInterface 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 3
bAlternateSetting 1
bNumEndpoints 1
bInterfaceClass 1 Audio
bInterfaceSubClass 2 Streaming
bInterfaceProtocol 0
iInterface 0
AudioStreaming Interface Descriptor:
bLength 7
bDescriptorType 36
bDescriptorSubtype 1 (AS_GENERAL)
bTerminalLink 2
bDelay 1 frames
wFormatTag 0x0001 PCM
AudioStreaming Interface Descriptor:
bLength 11
bDescriptorType 36
bDescriptorSubtype 2 (FORMAT_TYPE)
bFormatType 1 (FORMAT_TYPE_I)
bNrChannels 2
bSubframeSize 2
bBitResolution 16
bSamFreqType 1 Discrete
tSamFreq[ 0] 48000
Endpoint Descriptor:
bLength 9
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 5
Transfer Type Isochronous
Synch Type Asynchronous
Usage Type Data
wMaxPacketSize 0x00c4 1x 196 bytes
bInterval 4
bRefresh 0
bSynchAddress 0
AudioStreaming Endpoint Descriptor:
bLength 7
bDescriptorType 37
bDescriptorSubtype 1 (EP_GENERAL)
bmAttributes 0x01
Sampling Frequency
bLockDelayUnits 0 Undefined
wLockDelay 0x0000

---
 drivers/media/usb/uvc/uvc_driver.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/media/usb/uvc/uvc_driver.c +11 -0
index adec9d1aa653..bbfc409c5167 100644
@@ -2847,6 +2847,17 @@ static const struct usb_device_id uvc_ids[] = {
 	  .bInterfaceSubClass	= 1,
 	  .bInterfaceProtocol	= 0,
 	  .driver_info		= (kernel_ulong_t)&uvc_quirk_fix_bandwidth },
+	/* Avermedia GC515 */
+	{ .match_flags		= USB_DEVICE_ID_MATCH_DEVICE
+				| USB_DEVICE_ID_MATCH_INT_INFO,
+	  .idVendor		= 0x07ca,
+	  .idProduct		= 0x1515,
+	  .bInterfaceClass	= USB_CLASS_VIDEO,
+	  .bInterfaceSubClass	= 1,
+	  .bInterfaceProtocol	= UVC_PC_PROTOCOL_15,
+	  .driver_info		= (kernel_ulong_t)&(const struct uvc_device_info){
+		.uvc_version = 0x0110,
+	  } },
 	/* ViMicro Vega */
 	{ .match_flags		= USB_DEVICE_ID_MATCH_DEVICE
 				| USB_DEVICE_ID_MATCH_INT_INFO,
Signature · 1 line
2.55.0.1007.g17ff1f9808-goog
maintainer Reviewed-by on v3 5/5
#17 lore raw

Re: [PATCH v3 5/5] media: uvcvideo: Force UVC version for Avermedia GC515

Hi,

Quoted 657 lines · Ricardo Ribalda

The device announces itself as UVC 1.5, but it only accepts UVC 1.1 controls.

The camera can probably be handled by the automatic uvc_version handler, but it is more correct to add a quirk and keep some tracking of what vendors are more or less compliant. Also it might be more robust if we introduce more UVC version-dependent code.

Bus 003 Device 021: ID 07ca:1515 AVerMedia Technologies, Inc. X'tra Go GC515 Negotiated speed: High Speed (480Mbps)
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2 [unknown]
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
idVendor 0x07ca AVerMedia Technologies, Inc.
idProduct 0x1515 X'tra Go GC515
bcdDevice 0.10

  iManufacturer           1 AVerMedia
  iProduct                2 X'tra Go GC515
  iSerial                 3 5313180000221
  bNumConfigurations      1

Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x03fd
bNumInterfaces 4
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xc0
Self Powered
MaxPower 500mA
Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 0
bInterfaceCount 2
bFunctionClass 14 Video
bFunctionSubClass 3 Video Interface Collection
bFunctionProtocol 0
iFunction 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 14 Video
bInterfaceSubClass 1 Video Control
bInterfaceProtocol 1
iInterface 0
VideoControl Interface Descriptor:
bLength 13
bDescriptorType 36
bDescriptorSubtype 1 (HEADER)
bcdUVC 1.50
wTotalLength 0x0059
dwClockFrequency 30.000000MHz
bInCollection 1
baInterfaceNr( 0) 1
VideoControl Interface Descriptor:
bLength 18
bDescriptorType 36
bDescriptorSubtype 2 (INPUT_TERMINAL)
bTerminalID 1
wTerminalType 0x0201 Camera Sensor
bAssocTerminal 0
iTerminal 0
wObjectiveFocalLengthMin 0
wObjectiveFocalLengthMax 0
wOcularFocalLength 0
bControlSize 3
bmControls 0x00000000
VideoControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 3 (OUTPUT_TERMINAL)
bTerminalID 2
wTerminalType 0x0101 USB Streaming
bAssocTerminal 0
bSourceID 4
iTerminal 0
VideoControl Interface Descriptor:
bLength 7
bDescriptorType 36
bDescriptorSubtype 4 (SELECTOR_UNIT)
bUnitID 3
bNrInPins 1
baSource( 0) 1
iSelector 0
VideoControl Interface Descriptor:
bLength 13
bDescriptorType 36
bDescriptorSubtype 5 (PROCESSING_UNIT)
bUnitID 4
bSourceID 3
wMaxMultiplier 0
bControlSize 3
bmControls 0x00000000
iProcessing 0
bmVideoStandards 0x00
VideoControl Interface Descriptor:
bLength 29
bDescriptorType 36
bDescriptorSubtype 6 (EXTENSION_UNIT)
bUnitID 5
guidExtensionCode {55be8e1c-2fdb-4f7a-bd8d-b9b1108d20c3}
bNumControls 24
bNrInPins 1
baSourceID( 0) 4
bControlSize 4
bmControls( 0) 0xff
bmControls( 1) 0xff
bmControls( 2) 0xff
bmControls( 3) 0x00
iExtension 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x85 EP 5 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1
VideoControl Endpoint Descriptor:
bLength 5
bDescriptorType 37
bDescriptorSubtype 3 (EP_INTERRUPT)
wMaxTransferSize 64
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 14 Video
bInterfaceSubClass 2 Video Streaming
bInterfaceProtocol 1
iInterface 0
VideoStreaming Interface Descriptor:
bLength 16
bDescriptorType 36
bDescriptorSubtype 1 (INPUT_HEADER)
bNumFormats 3
wTotalLength 0x0303
bEndpointAddress 0x81 EP 1 IN
bmInfo 0
bTerminalLink 2
bStillCaptureMethod 1
bTriggerSupport 0
bTriggerUsage 0
bControlSize 1
bmaControls( 0) 4
bmaControls( 1) 4
bmaControls( 2) 0
VideoStreaming Interface Descriptor:
bLength 28
bDescriptorType 36
bDescriptorSubtype 16 (FORMAT_FRAME_BASED)
bFormatIndex 1
bNumFrameDescriptors 8
guidFormat {34363248-0000-0010-8000-00aa00389b71}
bBitsPerPixel 24
bDefaultFrameIndex 1
bAspectRatioX 0
bAspectRatioY 0
bmInterlaceFlags 0x00
Interlaced stream or variable: No
Fields per frame: 2 fields
Field 1 first: No
Field pattern: Field 1 only
bCopyProtect 1
bVariableSize 1
VideoStreaming Interface Descriptor:
bLength 62
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 1
bmCapabilities 0x01
Still image supported
wWidth 1920
wHeight 1080
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 9
dwBytesPerLine 0
dwFrameInterval( 0) 83333
dwFrameInterval( 1) 83416
dwFrameInterval( 2) 166666
dwFrameInterval( 3) 166833
dwFrameInterval( 4) 200000
dwFrameInterval( 5) 333333
dwFrameInterval( 6) 333667
dwFrameInterval( 7) 400000
dwFrameInterval( 8) 416666
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 2
bmCapabilities 0x01
Still image supported
wWidth 3840
wHeight 2160
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 333333
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 333333
dwFrameInterval( 1) 333667
dwFrameInterval( 2) 400000
dwFrameInterval( 3) 416666
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 3
bmCapabilities 0x01
Still image supported
wWidth 2560
wHeight 1440
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 4
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 800
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 38
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 5
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 720
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 3
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 200000
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 6
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 576
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 200000
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 200000
dwFrameInterval( 1) 400000
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 7
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 333333
dwFrameInterval( 3) 333667
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 8
bmCapabilities 0x01
Still image supported
wWidth 640
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 6
bDescriptorType 36
bDescriptorSubtype 13 (COLORFORMAT)
bColorPrimaries 0 (Unspecified)
bTransferCharacteristics 0 (Unspecified)
bMatrixCoefficients 0 (Unspecified)
VideoStreaming Interface Descriptor:
bLength 28
bDescriptorType 36
bDescriptorSubtype 16 (FORMAT_FRAME_BASED)
bFormatIndex 2
bNumFrameDescriptors 8
guidFormat {43564548-0000-0010-8000-00aa00389b71}
bBitsPerPixel 24
bDefaultFrameIndex 1
bAspectRatioX 0
bAspectRatioY 0
bmInterlaceFlags 0x00
Interlaced stream or variable: No
Fields per frame: 2 fields
Field 1 first: No
Field pattern: Field 1 only
bCopyProtect 1
bVariableSize 1
VideoStreaming Interface Descriptor:
bLength 62
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 1
bmCapabilities 0x01
Still image supported
wWidth 1920
wHeight 1080
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 9
dwBytesPerLine 0
dwFrameInterval( 0) 83333
dwFrameInterval( 1) 83416
dwFrameInterval( 2) 166666
dwFrameInterval( 3) 166833
dwFrameInterval( 4) 200000
dwFrameInterval( 5) 333333
dwFrameInterval( 6) 333667
dwFrameInterval( 7) 400000
dwFrameInterval( 8) 416666
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 2
bmCapabilities 0x01
Still image supported
wWidth 3840
wHeight 2160
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 333333
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 333333
dwFrameInterval( 1) 333667
dwFrameInterval( 2) 400000
dwFrameInterval( 3) 416666
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 3
bmCapabilities 0x01
Still image supported
wWidth 2560
wHeight 1440
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 4
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 800
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 38
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 5
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 720
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 3
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 200000
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 6
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 576
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 200000
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 200000
dwFrameInterval( 1) 400000
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 7
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 333333
dwFrameInterval( 3) 333667
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 8
bmCapabilities 0x01
Still image supported
wWidth 640
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 6
bDescriptorType 36
bDescriptorSubtype 13 (COLORFORMAT)
bColorPrimaries 0 (Unspecified)
bTransferCharacteristics 0 (Unspecified)
bMatrixCoefficients 0 (Unspecified)
VideoStreaming Interface Descriptor:
bLength 11
bDescriptorType 36
bDescriptorSubtype 6 (FORMAT_MJPEG)
bFormatIndex 3
bNumFrameDescriptors 1
bFlags 0
Fixed-size samples: No
bDefaultFrameIndex 1
bAspectRatioX 0
bAspectRatioY 0
bmInterlaceFlags 0x00
Interlaced stream or variable: No
Fields per frame: 1 fields
Field 1 first: No
Field pattern: Field 1 only
bCopyProtect 1
VideoStreaming Interface Descriptor:
bLength 30
bDescriptorType 36
bDescriptorSubtype 7 (FRAME_MJPEG)
bFrameIndex 1
bmCapabilities 0x01
Still image supported
wWidth 1920
wHeight 1080
dwMinBitRate 314572800
dwMaxBitRate 314572800
dwMaxVideoFrameBufferSize 4147200
dwDefaultFrameInterval 166666
bFrameIntervalType 1
dwFrameInterval( 0) 166666
VideoStreaming Interface Descriptor:
bLength 6
bDescriptorType 36
bDescriptorSubtype 13 (COLORFORMAT)
bColorPrimaries 0 (Unspecified)
bTransferCharacteristics 0 (Unspecified)
bMatrixCoefficients 0 (Unspecified)
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 2
bInterfaceCount 2
bFunctionClass 1 Audio
bFunctionSubClass 2 Streaming
bFunctionProtocol 0
iFunction 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 2
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 1 Audio
bInterfaceSubClass 1 Control Device
bInterfaceProtocol 0
iInterface 0
AudioControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 1 (HEADER)
bcdADC 1.00
wTotalLength 0x0026
bInCollection 1
baInterfaceNr(0) 3
AudioControl Interface Descriptor:
bLength 12
bDescriptorType 36
bDescriptorSubtype 2 (INPUT_TERMINAL)
bTerminalID 1
wTerminalType 0x0602 Digital Audio Interface
bAssocTerminal 0
bNrChannels 2
wChannelConfig 0x0003
Left Front (L)
Right Front (R)
iChannelNames 0
iTerminal 0
AudioControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 3 (OUTPUT_TERMINAL)
bTerminalID 2
wTerminalType 0x0101 USB Streaming
bAssocTerminal 0
bSourceID 3
iTerminal 0
AudioControl Interface Descriptor:
bLength 8
bDescriptorType 36
bDescriptorSubtype 6 (FEATURE_UNIT)
bUnitID 3
bSourceID 1
bControlSize 1
bmaControls(0) 0x03
Mute Control
Volume Control
iFeature 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 3
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 1 Audio
bInterfaceSubClass 2 Streaming
bInterfaceProtocol 0
iInterface 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 3
bAlternateSetting 1
bNumEndpoints 1
bInterfaceClass 1 Audio
bInterfaceSubClass 2 Streaming
bInterfaceProtocol 0
iInterface 0
AudioStreaming Interface Descriptor:
bLength 7
bDescriptorType 36
bDescriptorSubtype 1 (AS_GENERAL)
bTerminalLink 2
bDelay 1 frames
wFormatTag 0x0001 PCM
AudioStreaming Interface Descriptor:
bLength 11
bDescriptorType 36
bDescriptorSubtype 2 (FORMAT_TYPE)
bFormatType 1 (FORMAT_TYPE_I)
bNrChannels 2
bSubframeSize 2
bBitResolution 16
bSamFreqType 1 Discrete
tSamFreq[ 0] 48000
Endpoint Descriptor:
bLength 9
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 5
Transfer Type Isochronous
Synch Type Asynchronous
Usage Type Data
wMaxPacketSize 0x00c4 1x 196 bytes
bInterval 4
bRefresh 0
bSynchAddress 0
AudioStreaming Endpoint Descriptor:
bLength 7
bDescriptorType 37
bDescriptorSubtype 1 (EP_GENERAL)
bmAttributes 0x01
Sampling Frequency
bLockDelayUnits 0 Undefined
wLockDelay 0x0000

Quoted 6 lines

Thanks, patch looks good to me:

Regards,

Hans

Quoted 27 lines
---
 drivers/media/usb/uvc/uvc_driver.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/media/usb/uvc/uvc_driver.c +11 -0
index adec9d1aa653..bbfc409c5167 100644
@@ -2847,6 +2847,17 @@ static const struct usb_device_id uvc_ids[] = {
 	  .bInterfaceSubClass	= 1,
 	  .bInterfaceProtocol	= 0,
 	  .driver_info		= (kernel_ulong_t)&uvc_quirk_fix_bandwidth },
+	/* Avermedia GC515 */
+	{ .match_flags		= USB_DEVICE_ID_MATCH_DEVICE
+				| USB_DEVICE_ID_MATCH_INT_INFO,
+	  .idVendor		= 0x07ca,
+	  .idProduct		= 0x1515,
+	  .bInterfaceClass	= USB_CLASS_VIDEO,
+	  .bInterfaceSubClass	= 1,
+	  .bInterfaceProtocol	= UVC_PC_PROTOCOL_15,
+	  .driver_info		= (kernel_ulong_t)&(const struct uvc_device_info){
+		.uvc_version = 0x0110,
+	  } },
 	/* ViMicro Vega */
 	{ .match_flags		= USB_DEVICE_ID_MATCH_DEVICE
 				| USB_DEVICE_ID_MATCH_INT_INFO,
maintainer Reviewed-by on v3 5/5
#18 lore raw

Re: [PATCH v3 5/5] media: uvcvideo: Force UVC version for Avermedia GC515

In reply to Ricardo Ribalda
Quoted 657 lines · Ricardo Ribalda

The device announces itself as UVC 1.5, but it only accepts UVC 1.1 controls.

The camera can probably be handled by the automatic uvc_version handler, but it is more correct to add a quirk and keep some tracking of what vendors are more or less compliant. Also it might be more robust if we introduce more UVC version-dependent code.

Bus 003 Device 021: ID 07ca:1515 AVerMedia Technologies, Inc. X'tra Go GC515 Negotiated speed: High Speed (480Mbps)
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2 [unknown]
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
idVendor 0x07ca AVerMedia Technologies, Inc.
idProduct 0x1515 X'tra Go GC515
bcdDevice 0.10

  iManufacturer           1 AVerMedia
  iProduct                2 X'tra Go GC515
  iSerial                 3 5313180000221
  bNumConfigurations      1

Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x03fd
bNumInterfaces 4
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xc0
Self Powered
MaxPower 500mA
Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 0
bInterfaceCount 2
bFunctionClass 14 Video
bFunctionSubClass 3 Video Interface Collection
bFunctionProtocol 0
iFunction 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 14 Video
bInterfaceSubClass 1 Video Control
bInterfaceProtocol 1
iInterface 0
VideoControl Interface Descriptor:
bLength 13
bDescriptorType 36
bDescriptorSubtype 1 (HEADER)
bcdUVC 1.50
wTotalLength 0x0059
dwClockFrequency 30.000000MHz
bInCollection 1
baInterfaceNr( 0) 1
VideoControl Interface Descriptor:
bLength 18
bDescriptorType 36
bDescriptorSubtype 2 (INPUT_TERMINAL)
bTerminalID 1
wTerminalType 0x0201 Camera Sensor
bAssocTerminal 0
iTerminal 0
wObjectiveFocalLengthMin 0
wObjectiveFocalLengthMax 0
wOcularFocalLength 0
bControlSize 3
bmControls 0x00000000
VideoControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 3 (OUTPUT_TERMINAL)
bTerminalID 2
wTerminalType 0x0101 USB Streaming
bAssocTerminal 0
bSourceID 4
iTerminal 0
VideoControl Interface Descriptor:
bLength 7
bDescriptorType 36
bDescriptorSubtype 4 (SELECTOR_UNIT)
bUnitID 3
bNrInPins 1
baSource( 0) 1
iSelector 0
VideoControl Interface Descriptor:
bLength 13
bDescriptorType 36
bDescriptorSubtype 5 (PROCESSING_UNIT)
bUnitID 4
bSourceID 3
wMaxMultiplier 0
bControlSize 3
bmControls 0x00000000
iProcessing 0
bmVideoStandards 0x00
VideoControl Interface Descriptor:
bLength 29
bDescriptorType 36
bDescriptorSubtype 6 (EXTENSION_UNIT)
bUnitID 5
guidExtensionCode {55be8e1c-2fdb-4f7a-bd8d-b9b1108d20c3}
bNumControls 24
bNrInPins 1
baSourceID( 0) 4
bControlSize 4
bmControls( 0) 0xff
bmControls( 1) 0xff
bmControls( 2) 0xff
bmControls( 3) 0x00
iExtension 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x85 EP 5 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1
VideoControl Endpoint Descriptor:
bLength 5
bDescriptorType 37
bDescriptorSubtype 3 (EP_INTERRUPT)
wMaxTransferSize 64
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 14 Video
bInterfaceSubClass 2 Video Streaming
bInterfaceProtocol 1
iInterface 0
VideoStreaming Interface Descriptor:
bLength 16
bDescriptorType 36
bDescriptorSubtype 1 (INPUT_HEADER)
bNumFormats 3
wTotalLength 0x0303
bEndpointAddress 0x81 EP 1 IN
bmInfo 0
bTerminalLink 2
bStillCaptureMethod 1
bTriggerSupport 0
bTriggerUsage 0
bControlSize 1
bmaControls( 0) 4
bmaControls( 1) 4
bmaControls( 2) 0
VideoStreaming Interface Descriptor:
bLength 28
bDescriptorType 36
bDescriptorSubtype 16 (FORMAT_FRAME_BASED)
bFormatIndex 1
bNumFrameDescriptors 8
guidFormat {34363248-0000-0010-8000-00aa00389b71}
bBitsPerPixel 24
bDefaultFrameIndex 1
bAspectRatioX 0
bAspectRatioY 0
bmInterlaceFlags 0x00
Interlaced stream or variable: No
Fields per frame: 2 fields
Field 1 first: No
Field pattern: Field 1 only
bCopyProtect 1
bVariableSize 1
VideoStreaming Interface Descriptor:
bLength 62
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 1
bmCapabilities 0x01
Still image supported
wWidth 1920
wHeight 1080
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 9
dwBytesPerLine 0
dwFrameInterval( 0) 83333
dwFrameInterval( 1) 83416
dwFrameInterval( 2) 166666
dwFrameInterval( 3) 166833
dwFrameInterval( 4) 200000
dwFrameInterval( 5) 333333
dwFrameInterval( 6) 333667
dwFrameInterval( 7) 400000
dwFrameInterval( 8) 416666
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 2
bmCapabilities 0x01
Still image supported
wWidth 3840
wHeight 2160
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 333333
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 333333
dwFrameInterval( 1) 333667
dwFrameInterval( 2) 400000
dwFrameInterval( 3) 416666
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 3
bmCapabilities 0x01
Still image supported
wWidth 2560
wHeight 1440
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 4
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 800
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 38
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 5
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 720
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 3
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 200000
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 6
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 576
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 200000
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 200000
dwFrameInterval( 1) 400000
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 7
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 333333
dwFrameInterval( 3) 333667
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 8
bmCapabilities 0x01
Still image supported
wWidth 640
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 6
bDescriptorType 36
bDescriptorSubtype 13 (COLORFORMAT)
bColorPrimaries 0 (Unspecified)
bTransferCharacteristics 0 (Unspecified)
bMatrixCoefficients 0 (Unspecified)
VideoStreaming Interface Descriptor:
bLength 28
bDescriptorType 36
bDescriptorSubtype 16 (FORMAT_FRAME_BASED)
bFormatIndex 2
bNumFrameDescriptors 8
guidFormat {43564548-0000-0010-8000-00aa00389b71}
bBitsPerPixel 24
bDefaultFrameIndex 1
bAspectRatioX 0
bAspectRatioY 0
bmInterlaceFlags 0x00
Interlaced stream or variable: No
Fields per frame: 2 fields
Field 1 first: No
Field pattern: Field 1 only
bCopyProtect 1
bVariableSize 1
VideoStreaming Interface Descriptor:
bLength 62
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 1
bmCapabilities 0x01
Still image supported
wWidth 1920
wHeight 1080
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 9
dwBytesPerLine 0
dwFrameInterval( 0) 83333
dwFrameInterval( 1) 83416
dwFrameInterval( 2) 166666
dwFrameInterval( 3) 166833
dwFrameInterval( 4) 200000
dwFrameInterval( 5) 333333
dwFrameInterval( 6) 333667
dwFrameInterval( 7) 400000
dwFrameInterval( 8) 416666
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 2
bmCapabilities 0x01
Still image supported
wWidth 3840
wHeight 2160
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 333333
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 333333
dwFrameInterval( 1) 333667
dwFrameInterval( 2) 400000
dwFrameInterval( 3) 416666
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 3
bmCapabilities 0x01
Still image supported
wWidth 2560
wHeight 1440
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 4
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 800
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 38
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 5
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 720
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 3
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 200000
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 6
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 576
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 200000
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 200000
dwFrameInterval( 1) 400000
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 7
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 333333
dwFrameInterval( 3) 333667
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 8
bmCapabilities 0x01
Still image supported
wWidth 640
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 6
bDescriptorType 36
bDescriptorSubtype 13 (COLORFORMAT)
bColorPrimaries 0 (Unspecified)
bTransferCharacteristics 0 (Unspecified)
bMatrixCoefficients 0 (Unspecified)
VideoStreaming Interface Descriptor:
bLength 11
bDescriptorType 36
bDescriptorSubtype 6 (FORMAT_MJPEG)
bFormatIndex 3
bNumFrameDescriptors 1
bFlags 0
Fixed-size samples: No
bDefaultFrameIndex 1
bAspectRatioX 0
bAspectRatioY 0
bmInterlaceFlags 0x00
Interlaced stream or variable: No
Fields per frame: 1 fields
Field 1 first: No
Field pattern: Field 1 only
bCopyProtect 1
VideoStreaming Interface Descriptor:
bLength 30
bDescriptorType 36
bDescriptorSubtype 7 (FRAME_MJPEG)
bFrameIndex 1
bmCapabilities 0x01
Still image supported
wWidth 1920
wHeight 1080
dwMinBitRate 314572800
dwMaxBitRate 314572800
dwMaxVideoFrameBufferSize 4147200
dwDefaultFrameInterval 166666
bFrameIntervalType 1
dwFrameInterval( 0) 166666
VideoStreaming Interface Descriptor:
bLength 6
bDescriptorType 36
bDescriptorSubtype 13 (COLORFORMAT)
bColorPrimaries 0 (Unspecified)
bTransferCharacteristics 0 (Unspecified)
bMatrixCoefficients 0 (Unspecified)
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 2
bInterfaceCount 2
bFunctionClass 1 Audio
bFunctionSubClass 2 Streaming
bFunctionProtocol 0
iFunction 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 2
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 1 Audio
bInterfaceSubClass 1 Control Device
bInterfaceProtocol 0
iInterface 0
AudioControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 1 (HEADER)
bcdADC 1.00
wTotalLength 0x0026
bInCollection 1
baInterfaceNr(0) 3
AudioControl Interface Descriptor:
bLength 12
bDescriptorType 36
bDescriptorSubtype 2 (INPUT_TERMINAL)
bTerminalID 1
wTerminalType 0x0602 Digital Audio Interface
bAssocTerminal 0
bNrChannels 2
wChannelConfig 0x0003
Left Front (L)
Right Front (R)
iChannelNames 0
iTerminal 0
AudioControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 3 (OUTPUT_TERMINAL)
bTerminalID 2
wTerminalType 0x0101 USB Streaming
bAssocTerminal 0
bSourceID 3
iTerminal 0
AudioControl Interface Descriptor:
bLength 8
bDescriptorType 36
bDescriptorSubtype 6 (FEATURE_UNIT)
bUnitID 3
bSourceID 1
bControlSize 1
bmaControls(0) 0x03
Mute Control
Volume Control
iFeature 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 3
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 1 Audio
bInterfaceSubClass 2 Streaming
bInterfaceProtocol 0
iInterface 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 3
bAlternateSetting 1
bNumEndpoints 1
bInterfaceClass 1 Audio
bInterfaceSubClass 2 Streaming
bInterfaceProtocol 0
iInterface 0
AudioStreaming Interface Descriptor:
bLength 7
bDescriptorType 36
bDescriptorSubtype 1 (AS_GENERAL)
bTerminalLink 2
bDelay 1 frames
wFormatTag 0x0001 PCM
AudioStreaming Interface Descriptor:
bLength 11
bDescriptorType 36
bDescriptorSubtype 2 (FORMAT_TYPE)
bFormatType 1 (FORMAT_TYPE_I)
bNrChannels 2
bSubframeSize 2
bBitResolution 16
bSamFreqType 1 Discrete
tSamFreq[ 0] 48000
Endpoint Descriptor:
bLength 9
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 5
Transfer Type Isochronous
Synch Type Asynchronous
Usage Type Data
wMaxPacketSize 0x00c4 1x 196 bytes
bInterval 4
bRefresh 0
bSynchAddress 0
AudioStreaming Endpoint Descriptor:
bLength 7
bDescriptorType 37
bDescriptorSubtype 1 (EP_GENERAL)
bmAttributes 0x01
Sampling Frequency
bLockDelayUnits 0 Undefined
wLockDelay 0x0000

Quoted 2 lines
Fixes b400b6f28af0 ("media: uvcvideo: Force UVC version to 1.0a for 1bcf:0b40") # When version overwritte was added

That doesn't seem quite right, this patch doesn't fix that commit. I think you can omit the Fixes tag. With that,

Quoted 30 lines
---
 drivers/media/usb/uvc/uvc_driver.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/media/usb/uvc/uvc_driver.c +11 -0
index adec9d1aa653..bbfc409c5167 100644
@@ -2847,6 +2847,17 @@ static const struct usb_device_id uvc_ids[] = {
 	  .bInterfaceSubClass	= 1,
 	  .bInterfaceProtocol	= 0,
 	  .driver_info		= (kernel_ulong_t)&uvc_quirk_fix_bandwidth },
+	/* Avermedia GC515 */
+	{ .match_flags		= USB_DEVICE_ID_MATCH_DEVICE
+				| USB_DEVICE_ID_MATCH_INT_INFO,
+	  .idVendor		= 0x07ca,
+	  .idProduct		= 0x1515,
+	  .bInterfaceClass	= USB_CLASS_VIDEO,
+	  .bInterfaceSubClass	= 1,
+	  .bInterfaceProtocol	= UVC_PC_PROTOCOL_15,
+	  .driver_info		= (kernel_ulong_t)&(const struct uvc_device_info){
+		.uvc_version = 0x0110,
+	  } },
 	/* ViMicro Vega */
 	{ .match_flags		= USB_DEVICE_ID_MATCH_DEVICE
 				| USB_DEVICE_ID_MATCH_INT_INFO,
Signature · 3 lines
Regards,

Laurent Pinchart
#19 lore raw

Re: [PATCH v3 5/5] media: uvcvideo: Force UVC version for Avermedia GC515

Quoted 659 lines · Laurent Pinchart
Quoted 657 lines · Ricardo Ribalda

The device announces itself as UVC 1.5, but it only accepts UVC 1.1 controls.

The camera can probably be handled by the automatic uvc_version handler, but it is more correct to add a quirk and keep some tracking of what vendors are more or less compliant. Also it might be more robust if we introduce more UVC version-dependent code.

Bus 003 Device 021: ID 07ca:1515 AVerMedia Technologies, Inc. X'tra Go GC515 Negotiated speed: High Speed (480Mbps)
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2 [unknown]
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
idVendor 0x07ca AVerMedia Technologies, Inc.
idProduct 0x1515 X'tra Go GC515
bcdDevice 0.10

  iManufacturer           1 AVerMedia
  iProduct                2 X'tra Go GC515
  iSerial                 3 5313180000221
  bNumConfigurations      1

Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x03fd
bNumInterfaces 4
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xc0
Self Powered
MaxPower 500mA
Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 0
bInterfaceCount 2
bFunctionClass 14 Video
bFunctionSubClass 3 Video Interface Collection
bFunctionProtocol 0
iFunction 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 14 Video
bInterfaceSubClass 1 Video Control
bInterfaceProtocol 1
iInterface 0
VideoControl Interface Descriptor:
bLength 13
bDescriptorType 36
bDescriptorSubtype 1 (HEADER)
bcdUVC 1.50
wTotalLength 0x0059
dwClockFrequency 30.000000MHz
bInCollection 1
baInterfaceNr( 0) 1
VideoControl Interface Descriptor:
bLength 18
bDescriptorType 36
bDescriptorSubtype 2 (INPUT_TERMINAL)
bTerminalID 1
wTerminalType 0x0201 Camera Sensor
bAssocTerminal 0
iTerminal 0
wObjectiveFocalLengthMin 0
wObjectiveFocalLengthMax 0
wOcularFocalLength 0
bControlSize 3
bmControls 0x00000000
VideoControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 3 (OUTPUT_TERMINAL)
bTerminalID 2
wTerminalType 0x0101 USB Streaming
bAssocTerminal 0
bSourceID 4
iTerminal 0
VideoControl Interface Descriptor:
bLength 7
bDescriptorType 36
bDescriptorSubtype 4 (SELECTOR_UNIT)
bUnitID 3
bNrInPins 1
baSource( 0) 1
iSelector 0
VideoControl Interface Descriptor:
bLength 13
bDescriptorType 36
bDescriptorSubtype 5 (PROCESSING_UNIT)
bUnitID 4
bSourceID 3
wMaxMultiplier 0
bControlSize 3
bmControls 0x00000000
iProcessing 0
bmVideoStandards 0x00
VideoControl Interface Descriptor:
bLength 29
bDescriptorType 36
bDescriptorSubtype 6 (EXTENSION_UNIT)
bUnitID 5
guidExtensionCode {55be8e1c-2fdb-4f7a-bd8d-b9b1108d20c3}
bNumControls 24
bNrInPins 1
baSourceID( 0) 4
bControlSize 4
bmControls( 0) 0xff
bmControls( 1) 0xff
bmControls( 2) 0xff
bmControls( 3) 0x00
iExtension 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x85 EP 5 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1
VideoControl Endpoint Descriptor:
bLength 5
bDescriptorType 37
bDescriptorSubtype 3 (EP_INTERRUPT)
wMaxTransferSize 64
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 14 Video
bInterfaceSubClass 2 Video Streaming
bInterfaceProtocol 1
iInterface 0
VideoStreaming Interface Descriptor:
bLength 16
bDescriptorType 36
bDescriptorSubtype 1 (INPUT_HEADER)
bNumFormats 3
wTotalLength 0x0303
bEndpointAddress 0x81 EP 1 IN
bmInfo 0
bTerminalLink 2
bStillCaptureMethod 1
bTriggerSupport 0
bTriggerUsage 0
bControlSize 1
bmaControls( 0) 4
bmaControls( 1) 4
bmaControls( 2) 0
VideoStreaming Interface Descriptor:
bLength 28
bDescriptorType 36
bDescriptorSubtype 16 (FORMAT_FRAME_BASED)
bFormatIndex 1
bNumFrameDescriptors 8
guidFormat {34363248-0000-0010-8000-00aa00389b71}
bBitsPerPixel 24
bDefaultFrameIndex 1
bAspectRatioX 0
bAspectRatioY 0
bmInterlaceFlags 0x00
Interlaced stream or variable: No
Fields per frame: 2 fields
Field 1 first: No
Field pattern: Field 1 only
bCopyProtect 1
bVariableSize 1
VideoStreaming Interface Descriptor:
bLength 62
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 1
bmCapabilities 0x01
Still image supported
wWidth 1920
wHeight 1080
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 9
dwBytesPerLine 0
dwFrameInterval( 0) 83333
dwFrameInterval( 1) 83416
dwFrameInterval( 2) 166666
dwFrameInterval( 3) 166833
dwFrameInterval( 4) 200000
dwFrameInterval( 5) 333333
dwFrameInterval( 6) 333667
dwFrameInterval( 7) 400000
dwFrameInterval( 8) 416666
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 2
bmCapabilities 0x01
Still image supported
wWidth 3840
wHeight 2160
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 333333
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 333333
dwFrameInterval( 1) 333667
dwFrameInterval( 2) 400000
dwFrameInterval( 3) 416666
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 3
bmCapabilities 0x01
Still image supported
wWidth 2560
wHeight 1440
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 4
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 800
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 38
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 5
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 720
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 3
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 200000
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 6
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 576
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 200000
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 200000
dwFrameInterval( 1) 400000
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 7
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 333333
dwFrameInterval( 3) 333667
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 8
bmCapabilities 0x01
Still image supported
wWidth 640
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 6
bDescriptorType 36
bDescriptorSubtype 13 (COLORFORMAT)
bColorPrimaries 0 (Unspecified)
bTransferCharacteristics 0 (Unspecified)
bMatrixCoefficients 0 (Unspecified)
VideoStreaming Interface Descriptor:
bLength 28
bDescriptorType 36
bDescriptorSubtype 16 (FORMAT_FRAME_BASED)
bFormatIndex 2
bNumFrameDescriptors 8
guidFormat {43564548-0000-0010-8000-00aa00389b71}
bBitsPerPixel 24
bDefaultFrameIndex 1
bAspectRatioX 0
bAspectRatioY 0
bmInterlaceFlags 0x00
Interlaced stream or variable: No
Fields per frame: 2 fields
Field 1 first: No
Field pattern: Field 1 only
bCopyProtect 1
bVariableSize 1
VideoStreaming Interface Descriptor:
bLength 62
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 1
bmCapabilities 0x01
Still image supported
wWidth 1920
wHeight 1080
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 9
dwBytesPerLine 0
dwFrameInterval( 0) 83333
dwFrameInterval( 1) 83416
dwFrameInterval( 2) 166666
dwFrameInterval( 3) 166833
dwFrameInterval( 4) 200000
dwFrameInterval( 5) 333333
dwFrameInterval( 6) 333667
dwFrameInterval( 7) 400000
dwFrameInterval( 8) 416666
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 2
bmCapabilities 0x01
Still image supported
wWidth 3840
wHeight 2160
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 333333
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 333333
dwFrameInterval( 1) 333667
dwFrameInterval( 2) 400000
dwFrameInterval( 3) 416666
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 3
bmCapabilities 0x01
Still image supported
wWidth 2560
wHeight 1440
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 4
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 800
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 38
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 5
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 720
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 3
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 200000
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 6
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 576
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 200000
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 200000
dwFrameInterval( 1) 400000
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 7
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 333333
dwFrameInterval( 3) 333667
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 8
bmCapabilities 0x01
Still image supported
wWidth 640
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 6
bDescriptorType 36
bDescriptorSubtype 13 (COLORFORMAT)
bColorPrimaries 0 (Unspecified)
bTransferCharacteristics 0 (Unspecified)
bMatrixCoefficients 0 (Unspecified)
VideoStreaming Interface Descriptor:
bLength 11
bDescriptorType 36
bDescriptorSubtype 6 (FORMAT_MJPEG)
bFormatIndex 3
bNumFrameDescriptors 1
bFlags 0
Fixed-size samples: No
bDefaultFrameIndex 1
bAspectRatioX 0
bAspectRatioY 0
bmInterlaceFlags 0x00
Interlaced stream or variable: No
Fields per frame: 1 fields
Field 1 first: No
Field pattern: Field 1 only
bCopyProtect 1
VideoStreaming Interface Descriptor:
bLength 30
bDescriptorType 36
bDescriptorSubtype 7 (FRAME_MJPEG)
bFrameIndex 1
bmCapabilities 0x01
Still image supported
wWidth 1920
wHeight 1080
dwMinBitRate 314572800
dwMaxBitRate 314572800
dwMaxVideoFrameBufferSize 4147200
dwDefaultFrameInterval 166666
bFrameIntervalType 1
dwFrameInterval( 0) 166666
VideoStreaming Interface Descriptor:
bLength 6
bDescriptorType 36
bDescriptorSubtype 13 (COLORFORMAT)
bColorPrimaries 0 (Unspecified)
bTransferCharacteristics 0 (Unspecified)
bMatrixCoefficients 0 (Unspecified)
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 2
bInterfaceCount 2
bFunctionClass 1 Audio
bFunctionSubClass 2 Streaming
bFunctionProtocol 0
iFunction 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 2
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 1 Audio
bInterfaceSubClass 1 Control Device
bInterfaceProtocol 0
iInterface 0
AudioControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 1 (HEADER)
bcdADC 1.00
wTotalLength 0x0026
bInCollection 1
baInterfaceNr(0) 3
AudioControl Interface Descriptor:
bLength 12
bDescriptorType 36
bDescriptorSubtype 2 (INPUT_TERMINAL)
bTerminalID 1
wTerminalType 0x0602 Digital Audio Interface
bAssocTerminal 0
bNrChannels 2
wChannelConfig 0x0003
Left Front (L)
Right Front (R)
iChannelNames 0
iTerminal 0
AudioControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 3 (OUTPUT_TERMINAL)
bTerminalID 2
wTerminalType 0x0101 USB Streaming
bAssocTerminal 0
bSourceID 3
iTerminal 0
AudioControl Interface Descriptor:
bLength 8
bDescriptorType 36
bDescriptorSubtype 6 (FEATURE_UNIT)
bUnitID 3
bSourceID 1
bControlSize 1
bmaControls(0) 0x03
Mute Control
Volume Control
iFeature 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 3
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 1 Audio
bInterfaceSubClass 2 Streaming
bInterfaceProtocol 0
iInterface 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 3
bAlternateSetting 1
bNumEndpoints 1
bInterfaceClass 1 Audio
bInterfaceSubClass 2 Streaming
bInterfaceProtocol 0
iInterface 0
AudioStreaming Interface Descriptor:
bLength 7
bDescriptorType 36
bDescriptorSubtype 1 (AS_GENERAL)
bTerminalLink 2
bDelay 1 frames
wFormatTag 0x0001 PCM
AudioStreaming Interface Descriptor:
bLength 11
bDescriptorType 36
bDescriptorSubtype 2 (FORMAT_TYPE)
bFormatType 1 (FORMAT_TYPE_I)
bNrChannels 2
bSubframeSize 2
bBitResolution 16
bSamFreqType 1 Discrete
tSamFreq[ 0] 48000
Endpoint Descriptor:
bLength 9
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 5
Transfer Type Isochronous
Synch Type Asynchronous
Usage Type Data
wMaxPacketSize 0x00c4 1x 196 bytes
bInterval 4
bRefresh 0
bSynchAddress 0
AudioStreaming Endpoint Descriptor:
bLength 7
bDescriptorType 37
bDescriptorSubtype 1 (EP_GENERAL)
bmAttributes 0x01
Sampling Frequency
bLockDelayUnits 0 Undefined
wLockDelay 0x0000

Quoted 5 lines
Quoted 2 lines
Fixes b400b6f28af0 ("media: uvcvideo: Force UVC version to 1.0a for 1bcf:0b40") # When version overwritte was added

That doesn't seem quite right, this patch doesn't fix that commit. I think you can omit the Fixes tag. With that,

Without the Fixes tag, how to I let stable know until what version it should backport the patch?

Quoted 38 lines
Quoted 20 lines
---
 drivers/media/usb/uvc/uvc_driver.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/media/usb/uvc/uvc_driver.c +4 -0
index adec9d1aa653..bbfc409c5167 100644
@@ -2847,6 +2847,17 @@ static const struct usb_device_id uvc_ids[] = {
        .bInterfaceSubClass   = 1,
        .bInterfaceProtocol   = 0,
        .driver_info          = (kernel_ulong_t)&uvc_quirk_fix_bandwidth },
+     /* Avermedia GC515 */
+     { .match_flags          = USB_DEVICE_ID_MATCH_DEVICE
+                             | USB_DEVICE_ID_MATCH_INT_INFO,
+       .idVendor             = 0x07ca,

drivers/media/usb/uvc/uvc_driver.c static const struct usb_device_id uvc_ids[] = { · line 2863

Quoted 10 lines
drivers/media/usb/uvc/uvc_driver.c +7 -0
+       .idProduct            = 0x1515,
+       .bInterfaceClass      = USB_CLASS_VIDEO,
+       .bInterfaceSubClass   = 1,
+       .bInterfaceProtocol   = UVC_PC_PROTOCOL_15,
+       .driver_info          = (kernel_ulong_t)&(const struct uvc_device_info){
+             .uvc_version = 0x0110,
+       } },
      /* ViMicro Vega */
      { .match_flags          = USB_DEVICE_ID_MATCH_DEVICE
                              | USB_DEVICE_ID_MATCH_INT_INFO,

--
Regards,

Laurent Pinchart

Signature · 1 line
Ricardo Ribalda
maintainer
#20 lore raw

Re: [PATCH v3 5/5] media: uvcvideo: Force UVC version for Avermedia GC515

Quoted 659 lines · Ricardo Ribalda
Quoted 658 lines · Laurent Pinchart
Quoted 657 lines · Ricardo Ribalda

The device announces itself as UVC 1.5, but it only accepts UVC 1.1 controls.

The camera can probably be handled by the automatic uvc_version handler, but it is more correct to add a quirk and keep some tracking of what vendors are more or less compliant. Also it might be more robust if we introduce more UVC version-dependent code.

Bus 003 Device 021: ID 07ca:1515 AVerMedia Technologies, Inc. X'tra Go GC515 Negotiated speed: High Speed (480Mbps)
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2 [unknown]
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
idVendor 0x07ca AVerMedia Technologies, Inc.
idProduct 0x1515 X'tra Go GC515
bcdDevice 0.10

  iManufacturer           1 AVerMedia
  iProduct                2 X'tra Go GC515
  iSerial                 3 5313180000221
  bNumConfigurations      1

Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x03fd
bNumInterfaces 4
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xc0
Self Powered
MaxPower 500mA
Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 0
bInterfaceCount 2
bFunctionClass 14 Video
bFunctionSubClass 3 Video Interface Collection
bFunctionProtocol 0
iFunction 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 14 Video
bInterfaceSubClass 1 Video Control
bInterfaceProtocol 1
iInterface 0
VideoControl Interface Descriptor:
bLength 13
bDescriptorType 36
bDescriptorSubtype 1 (HEADER)
bcdUVC 1.50
wTotalLength 0x0059
dwClockFrequency 30.000000MHz
bInCollection 1
baInterfaceNr( 0) 1
VideoControl Interface Descriptor:
bLength 18
bDescriptorType 36
bDescriptorSubtype 2 (INPUT_TERMINAL)
bTerminalID 1
wTerminalType 0x0201 Camera Sensor
bAssocTerminal 0
iTerminal 0
wObjectiveFocalLengthMin 0
wObjectiveFocalLengthMax 0
wOcularFocalLength 0
bControlSize 3
bmControls 0x00000000
VideoControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 3 (OUTPUT_TERMINAL)
bTerminalID 2
wTerminalType 0x0101 USB Streaming
bAssocTerminal 0
bSourceID 4
iTerminal 0
VideoControl Interface Descriptor:
bLength 7
bDescriptorType 36
bDescriptorSubtype 4 (SELECTOR_UNIT)
bUnitID 3
bNrInPins 1
baSource( 0) 1
iSelector 0
VideoControl Interface Descriptor:
bLength 13
bDescriptorType 36
bDescriptorSubtype 5 (PROCESSING_UNIT)
bUnitID 4
bSourceID 3
wMaxMultiplier 0
bControlSize 3
bmControls 0x00000000
iProcessing 0
bmVideoStandards 0x00
VideoControl Interface Descriptor:
bLength 29
bDescriptorType 36
bDescriptorSubtype 6 (EXTENSION_UNIT)
bUnitID 5
guidExtensionCode {55be8e1c-2fdb-4f7a-bd8d-b9b1108d20c3}
bNumControls 24
bNrInPins 1
baSourceID( 0) 4
bControlSize 4
bmControls( 0) 0xff
bmControls( 1) 0xff
bmControls( 2) 0xff
bmControls( 3) 0x00
iExtension 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x85 EP 5 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1
VideoControl Endpoint Descriptor:
bLength 5
bDescriptorType 37
bDescriptorSubtype 3 (EP_INTERRUPT)
wMaxTransferSize 64
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 14 Video
bInterfaceSubClass 2 Video Streaming
bInterfaceProtocol 1
iInterface 0
VideoStreaming Interface Descriptor:
bLength 16
bDescriptorType 36
bDescriptorSubtype 1 (INPUT_HEADER)
bNumFormats 3
wTotalLength 0x0303
bEndpointAddress 0x81 EP 1 IN
bmInfo 0
bTerminalLink 2
bStillCaptureMethod 1
bTriggerSupport 0
bTriggerUsage 0
bControlSize 1
bmaControls( 0) 4
bmaControls( 1) 4
bmaControls( 2) 0
VideoStreaming Interface Descriptor:
bLength 28
bDescriptorType 36
bDescriptorSubtype 16 (FORMAT_FRAME_BASED)
bFormatIndex 1
bNumFrameDescriptors 8
guidFormat {34363248-0000-0010-8000-00aa00389b71}
bBitsPerPixel 24
bDefaultFrameIndex 1
bAspectRatioX 0
bAspectRatioY 0
bmInterlaceFlags 0x00
Interlaced stream or variable: No
Fields per frame: 2 fields
Field 1 first: No
Field pattern: Field 1 only
bCopyProtect 1
bVariableSize 1
VideoStreaming Interface Descriptor:
bLength 62
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 1
bmCapabilities 0x01
Still image supported
wWidth 1920
wHeight 1080
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 9
dwBytesPerLine 0
dwFrameInterval( 0) 83333
dwFrameInterval( 1) 83416
dwFrameInterval( 2) 166666
dwFrameInterval( 3) 166833
dwFrameInterval( 4) 200000
dwFrameInterval( 5) 333333
dwFrameInterval( 6) 333667
dwFrameInterval( 7) 400000
dwFrameInterval( 8) 416666
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 2
bmCapabilities 0x01
Still image supported
wWidth 3840
wHeight 2160
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 333333
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 333333
dwFrameInterval( 1) 333667
dwFrameInterval( 2) 400000
dwFrameInterval( 3) 416666
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 3
bmCapabilities 0x01
Still image supported
wWidth 2560
wHeight 1440
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 4
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 800
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 38
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 5
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 720
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 3
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 200000
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 6
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 576
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 200000
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 200000
dwFrameInterval( 1) 400000
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 7
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 333333
dwFrameInterval( 3) 333667
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 8
bmCapabilities 0x01
Still image supported
wWidth 640
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 6
bDescriptorType 36
bDescriptorSubtype 13 (COLORFORMAT)
bColorPrimaries 0 (Unspecified)
bTransferCharacteristics 0 (Unspecified)
bMatrixCoefficients 0 (Unspecified)
VideoStreaming Interface Descriptor:
bLength 28
bDescriptorType 36
bDescriptorSubtype 16 (FORMAT_FRAME_BASED)
bFormatIndex 2
bNumFrameDescriptors 8
guidFormat {43564548-0000-0010-8000-00aa00389b71}
bBitsPerPixel 24
bDefaultFrameIndex 1
bAspectRatioX 0
bAspectRatioY 0
bmInterlaceFlags 0x00
Interlaced stream or variable: No
Fields per frame: 2 fields
Field 1 first: No
Field pattern: Field 1 only
bCopyProtect 1
bVariableSize 1
VideoStreaming Interface Descriptor:
bLength 62
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 1
bmCapabilities 0x01
Still image supported
wWidth 1920
wHeight 1080
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 9
dwBytesPerLine 0
dwFrameInterval( 0) 83333
dwFrameInterval( 1) 83416
dwFrameInterval( 2) 166666
dwFrameInterval( 3) 166833
dwFrameInterval( 4) 200000
dwFrameInterval( 5) 333333
dwFrameInterval( 6) 333667
dwFrameInterval( 7) 400000
dwFrameInterval( 8) 416666
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 2
bmCapabilities 0x01
Still image supported
wWidth 3840
wHeight 2160
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 333333
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 333333
dwFrameInterval( 1) 333667
dwFrameInterval( 2) 400000
dwFrameInterval( 3) 416666
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 3
bmCapabilities 0x01
Still image supported
wWidth 2560
wHeight 1440
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 4
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 800
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 38
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 5
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 720
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 3
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 200000
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 6
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 576
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 200000
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 200000
dwFrameInterval( 1) 400000
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 7
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 333333
dwFrameInterval( 3) 333667
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 8
bmCapabilities 0x01
Still image supported
wWidth 640
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 6
bDescriptorType 36
bDescriptorSubtype 13 (COLORFORMAT)
bColorPrimaries 0 (Unspecified)
bTransferCharacteristics 0 (Unspecified)
bMatrixCoefficients 0 (Unspecified)
VideoStreaming Interface Descriptor:
bLength 11
bDescriptorType 36
bDescriptorSubtype 6 (FORMAT_MJPEG)
bFormatIndex 3
bNumFrameDescriptors 1
bFlags 0
Fixed-size samples: No
bDefaultFrameIndex 1
bAspectRatioX 0
bAspectRatioY 0
bmInterlaceFlags 0x00
Interlaced stream or variable: No
Fields per frame: 1 fields
Field 1 first: No
Field pattern: Field 1 only
bCopyProtect 1
VideoStreaming Interface Descriptor:
bLength 30
bDescriptorType 36
bDescriptorSubtype 7 (FRAME_MJPEG)
bFrameIndex 1
bmCapabilities 0x01
Still image supported
wWidth 1920
wHeight 1080
dwMinBitRate 314572800
dwMaxBitRate 314572800
dwMaxVideoFrameBufferSize 4147200
dwDefaultFrameInterval 166666
bFrameIntervalType 1
dwFrameInterval( 0) 166666
VideoStreaming Interface Descriptor:
bLength 6
bDescriptorType 36
bDescriptorSubtype 13 (COLORFORMAT)
bColorPrimaries 0 (Unspecified)
bTransferCharacteristics 0 (Unspecified)
bMatrixCoefficients 0 (Unspecified)
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 2
bInterfaceCount 2
bFunctionClass 1 Audio
bFunctionSubClass 2 Streaming
bFunctionProtocol 0
iFunction 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 2
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 1 Audio
bInterfaceSubClass 1 Control Device
bInterfaceProtocol 0
iInterface 0
AudioControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 1 (HEADER)
bcdADC 1.00
wTotalLength 0x0026
bInCollection 1
baInterfaceNr(0) 3
AudioControl Interface Descriptor:
bLength 12
bDescriptorType 36
bDescriptorSubtype 2 (INPUT_TERMINAL)
bTerminalID 1
wTerminalType 0x0602 Digital Audio Interface
bAssocTerminal 0
bNrChannels 2
wChannelConfig 0x0003
Left Front (L)
Right Front (R)
iChannelNames 0
iTerminal 0
AudioControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 3 (OUTPUT_TERMINAL)
bTerminalID 2
wTerminalType 0x0101 USB Streaming
bAssocTerminal 0
bSourceID 3
iTerminal 0
AudioControl Interface Descriptor:
bLength 8
bDescriptorType 36
bDescriptorSubtype 6 (FEATURE_UNIT)
bUnitID 3
bSourceID 1
bControlSize 1
bmaControls(0) 0x03
Mute Control
Volume Control
iFeature 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 3
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 1 Audio
bInterfaceSubClass 2 Streaming
bInterfaceProtocol 0
iInterface 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 3
bAlternateSetting 1
bNumEndpoints 1
bInterfaceClass 1 Audio
bInterfaceSubClass 2 Streaming
bInterfaceProtocol 0
iInterface 0
AudioStreaming Interface Descriptor:
bLength 7
bDescriptorType 36
bDescriptorSubtype 1 (AS_GENERAL)
bTerminalLink 2
bDelay 1 frames
wFormatTag 0x0001 PCM
AudioStreaming Interface Descriptor:
bLength 11
bDescriptorType 36
bDescriptorSubtype 2 (FORMAT_TYPE)
bFormatType 1 (FORMAT_TYPE_I)
bNrChannels 2
bSubframeSize 2
bBitResolution 16
bSamFreqType 1 Discrete
tSamFreq[ 0] 48000
Endpoint Descriptor:
bLength 9
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 5
Transfer Type Isochronous
Synch Type Asynchronous
Usage Type Data
wMaxPacketSize 0x00c4 1x 196 bytes
bInterval 4
bRefresh 0
bSynchAddress 0
AudioStreaming Endpoint Descriptor:
bLength 7
bDescriptorType 37
bDescriptorSubtype 1 (EP_GENERAL)
bmAttributes 0x01
Sampling Frequency
bLockDelayUnits 0 Undefined
wLockDelay 0x0000

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Fixes b400b6f28af0 ("media: uvcvideo: Force UVC version to 1.0a for 1bcf:0b40") # When version overwritte was added

That doesn't seem quite right, this patch doesn't fix that commit. I think you can omit the Fixes tag. With that,

Without the Fixes tag, how to I let stable know until what version it should backport the patch?

I think that would be

Cc [email protected] # 5.12.x

See Documentation/process/stable-kernel-rules.rst, Option 1:

* Point out kernel version prerequisites::

    Cc: <[email protected]> # 3.3.x

The tag has the meaning of::

git cherry-pick <this commit>

For each "-stable" tree starting with the specified version.

Note, such tagging is unnecessary if the stable team can derive the appropriate versions from Fixes: tags.

No need to resend just for this. If you're fine with the above it can be adjusted when applying.

Quoted 32 lines
Quoted 32 lines
Quoted 30 lines
---
 drivers/media/usb/uvc/uvc_driver.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/media/usb/uvc/uvc_driver.c +11 -0
index adec9d1aa653..bbfc409c5167 100644
@@ -2847,6 +2847,17 @@ static const struct usb_device_id uvc_ids[] = {
        .bInterfaceSubClass   = 1,
        .bInterfaceProtocol   = 0,
        .driver_info          = (kernel_ulong_t)&uvc_quirk_fix_bandwidth },
+     /* Avermedia GC515 */
+     { .match_flags          = USB_DEVICE_ID_MATCH_DEVICE
+                             | USB_DEVICE_ID_MATCH_INT_INFO,
+       .idVendor             = 0x07ca,
+       .idProduct            = 0x1515,
+       .bInterfaceClass      = USB_CLASS_VIDEO,
+       .bInterfaceSubClass   = 1,
+       .bInterfaceProtocol   = UVC_PC_PROTOCOL_15,
+       .driver_info          = (kernel_ulong_t)&(const struct uvc_device_info){
+             .uvc_version = 0x0110,
+       } },
      /* ViMicro Vega */
      { .match_flags          = USB_DEVICE_ID_MATCH_DEVICE
                              | USB_DEVICE_ID_MATCH_INT_INFO,
Signature · 3 lines
Regards,

Laurent Pinchart