Skip to contentSkip to conversation

media: uvcvideo: fix HP True Vision 5MP color streaming

PATCH In review Parmjot Singh 3 participants 5 messages Nov 22 – Nov 23

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover media: uvcvideo: fix HP True Vision 5MP color streaming

The HP True Vision 5MP Camera (04f2:b767, USB revision 0.05) can disconnect from USB during initialization or shortly after starting color capture. The first patch skips a malformed default probe response using the existing UVC_QUIRK_PROBE_DEF. The second adds a startup delay for the color interface between SET_INTERFACE and the first ISO URB.

On stock Arch Linux 7.2.14, selecting 1280x720 MJPEG succeeded. With streaming enabled, COMMIT and SET_INTERFACE succeeded and ISO URBs completed before the camera disconnected about 127 ms after SET_INTERFACE. To reproduce, use the color capture node:

  v4l2-ctl -d /dev/video0 --set-fmt-video=width=1280,height=720,pixelformat=MJPG \
      --stream-mmap=4 --stream-count=90 --stream-to=/dev/null

With both patches active on Arch Linux 7.2.14, FFmpeg decoded 90 frames each at 720p MJPEG, 640x480 YUYV and 2592x1944 MJPEG, followed by 300 frames on a 720p restart. Color capture was also reported working after a reboot. The media-next series was build-tested on x86-64.

350 ms is the tested delay. The minimum reliable delay is unknown. Infrared capture still disconnects and is outside the streaming fix.

OpenAI Codex (GPT-6.2 Sol) helped draft the fixes and analyze USB and V4L2 traces. Testing used usbmon, v4l2-ctl, strace and FFmpeg.

Parmjot Singh (2):
media: uvcvideo: skip GET_DEF(PROBE) for HP True Vision 5MP
media: uvcvideo: delay HP True Vision 5MP isochronous start

 drivers/media/usb/uvc/uvc_driver.c | 23 +++++++++++++++++++++++
 drivers/media/usb/uvc/uvc_video.c  |  4 ++++
 drivers/media/usb/uvc/uvcvideo.h   |  1 +
 3 files changed, 28 insertions(+)

base-commit: ccf78740d63813c452c035b57d17a650492562fa

Signature · 1 line
2.56.0
#1 lore raw

PATCH 1/2 media: uvcvideo: skip GET_DEF(PROBE) for HP True Vision 5MP

The HP True Vision 5MP Camera (04f2:b767, revision 0.05) was observed returning zero format and frame indices in GET_DEF(PROBE). The driver can send those indices back in SET_CUR(PROBE) during initialization.

Use the existing UVC_QUIRK_PROBE_DEF workaround so initialization reads the current probe settings without replaying the default. Match the UVC 1.5 VideoControl interfaces used by the color and IR streams.

OpenAI Codex (GPT-6.2 Sol) helped turn the reported USB trace into a device table entry and checked the reported protocol on both interfaces.

---
 drivers/media/usb/uvc/uvc_driver.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/media/usb/uvc/uvc_driver.c +9 -0
index cbc145697..99c28991b 100644
@@ -2754,6 +2754,15 @@ static const struct usb_device_id uvc_ids[] = {
 	  .bInterfaceSubClass	= 1,
 	  .bInterfaceProtocol	= 0,
 	  .driver_info		= UVC_INFO_QUIRK(UVC_QUIRK_RESTRICT_FRAME_RATE) },
+	/* HP True Vision 5MP Camera */
+	{ .match_flags		= USB_DEVICE_ID_MATCH_DEVICE
+				| USB_DEVICE_ID_MATCH_INT_INFO,
+	  .idVendor		= 0x04f2,
+	  .idProduct		= 0xb767,
+	  .bInterfaceClass	= USB_CLASS_VIDEO,
+	  .bInterfaceSubClass	= 1,
+	  .bInterfaceProtocol	= UVC_PC_PROTOCOL_15,
+	  .driver_info		= (kernel_ulong_t)&uvc_quirk_probe_def },
 	/* Alcor Micro AU3820 (Future Boy PC USB Webcam) */
 	{ .match_flags		= USB_DEVICE_ID_MATCH_DEVICE
 				| USB_DEVICE_ID_MATCH_INT_INFO,
Signature · 1 line
2.56.0
#2 lore raw

PATCH 2/2 media: uvcvideo: delay HP True Vision 5MP isochronous start

In reply to Parmjot Singh

The HP True Vision 5MP Camera (04f2:b767, revision 0.05) accepts COMMIT and SET_INTERFACE, then may disconnect shortly after starting isochronous transfers. A 350 ms pause between SET_INTERFACE and the first video URB allowed color streaming in MJPEG and YUYV modes.

Add a per-device isochronous startup delay and apply it to the color interface.

On Arch Linux 7.2.14, FFmpeg decoded 90 frames each in 720p MJPEG, 640x480 YUYV and 2592x1944 MJPEG, plus 300 frames after a 720p restart. The infrared stream still disconnected during the delay experiment, before the first video URB was submitted.

OpenAI Codex (GPT-6.2 Sol) helped design and analyze the USB timing experiment and write the driver change.

---
 drivers/media/usb/uvc/uvc_driver.c | 14 ++++++++++++++
 drivers/media/usb/uvc/uvc_video.c  |  4 ++++
 drivers/media/usb/uvc/uvcvideo.h   |  1 +
 3 files changed, 19 insertions(+)
drivers/media/usb/uvc/uvc_driver.c +14 -0
index 99c28991b..cfc626a15 100644
@@ -2754,6 +2754,20 @@ static const struct usb_device_id uvc_ids[] = {
 	  .bInterfaceSubClass	= 1,
 	  .bInterfaceProtocol	= 0,
 	  .driver_info		= UVC_INFO_QUIRK(UVC_QUIRK_RESTRICT_FRAME_RATE) },
+	/* HP True Vision 5MP Camera (color) */
+	{ .match_flags		= USB_DEVICE_ID_MATCH_DEVICE
+				| USB_DEVICE_ID_MATCH_INT_INFO
+				| USB_DEVICE_ID_MATCH_INT_NUMBER,
+	  .idVendor		= 0x04f2,
+	  .idProduct		= 0xb767,
+	  .bInterfaceClass	= USB_CLASS_VIDEO,
+	  .bInterfaceSubClass	= 1,
+	  .bInterfaceProtocol	= UVC_PC_PROTOCOL_15,
+	  .bInterfaceNumber	= 0,
+	  .driver_info		= (kernel_ulong_t)&(const struct uvc_device_info){
+		.quirks = UVC_QUIRK_PROBE_DEF,
+		.isoc_start_delay_ms = 350,
+	  } },
 	/* HP True Vision 5MP Camera */
 	{ .match_flags		= USB_DEVICE_ID_MATCH_DEVICE
 				| USB_DEVICE_ID_MATCH_INT_INFO,
drivers/media/usb/uvc/uvc_video.c +4 -0
index a92a986ab..e20330998 100644
@@ -6,6 +6,7 @@
  *          Laurent Pinchart ([email protected])
  */
 
+#include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/highmem.h>
 #include <linux/kernel.h>
@@ -2103,6 +2104,9 @@ static int uvc_video_start_transfer(struct uvc_streaming *stream,
 		if (ret < 0)
 			return ret;
 
+		if (stream->dev->info->isoc_start_delay_ms)
+			msleep(stream->dev->info->isoc_start_delay_ms);
+
 		ret = uvc_init_video_isoc(stream, best_ep, gfp_flags);
 	} else {
 		/* Bulk endpoint, proceed to URB initialization. */
drivers/media/usb/uvc/uvcvideo.h +1 -0
index af8cef94f..eb949c6d8 100644
@@ -545,6 +545,7 @@ struct uvc_device_info {
 	u32	quirks;
 	u32	meta_format;
 	u16	uvc_version;
+	u16	isoc_start_delay_ms;
 };
 
 struct uvc_rect {
Signature · 1 line
2.56.0
#3 lore raw

Re: [PATCH 2/2] media: uvcvideo: delay HP True Vision 5MP isochronous start

Hi Parmjot

Could you provide the whole USB descriptor of the device lsusb -v -d 04f2:b767

Is it a internal camera (it looks so based on the name) if it is not, could you try connecting it to USB2 hub?

Quoted 30 lines · Parmjot Singh

The HP True Vision 5MP Camera (04f2:b767, revision 0.05) accepts COMMIT and SET_INTERFACE, then may disconnect shortly after starting isochronous transfers. A 350 ms pause between SET_INTERFACE and the first video URB allowed color streaming in MJPEG and YUYV modes.

Add a per-device isochronous startup delay and apply it to the color interface.

On Arch Linux 7.2.14, FFmpeg decoded 90 frames each in 720p MJPEG, 640x480 YUYV and 2592x1944 MJPEG, plus 300 frames after a 720p restart. The infrared stream still disconnected during the delay experiment, before the first video URB was submitted.

OpenAI Codex (GPT-6.2 Sol) helped design and analyze the USB timing experiment and write the driver change.

---
 drivers/media/usb/uvc/uvc_driver.c | 14 ++++++++++++++
 drivers/media/usb/uvc/uvc_video.c  |  4 ++++
 drivers/media/usb/uvc/uvcvideo.h   |  1 +
 3 files changed, 19 insertions(+)
drivers/media/usb/uvc/uvc_driver.c +0 -0
index 99c28991b..cfc626a15 100644

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

Quoted 7 lines
drivers/media/usb/uvc/uvc_driver.c +4 -0
@@ -2754,6 +2754,20 @@ static const struct usb_device_id uvc_ids[] = {
          .bInterfaceSubClass   = 1,
          .bInterfaceProtocol   = 0,
          .driver_info          = UVC_INFO_QUIRK(UVC_QUIRK_RESTRICT_FRAME_RATE) },
+       /* HP True Vision 5MP Camera (color) */
+       { .match_flags          = USB_DEVICE_ID_MATCH_DEVICE
+                               | USB_DEVICE_ID_MATCH_INT_INFO
+                               | USB_DEVICE_ID_MATCH_INT_NUMBER,

Why dont you add this to the previous quirk instead of adding a new fied?

We usually do not need to match int number.

Quoted 51 lines
drivers/media/usb/uvc/uvc_driver.c +10 -0
+         .idVendor             = 0x04f2,
+         .idProduct            = 0xb767,
+         .bInterfaceClass      = USB_CLASS_VIDEO,
+         .bInterfaceSubClass   = 1,
+         .bInterfaceProtocol   = UVC_PC_PROTOCOL_15,
+         .bInterfaceNumber     = 0,
+         .driver_info          = (kernel_ulong_t)&(const struct uvc_device_info){
+               .quirks = UVC_QUIRK_PROBE_DEF,
+               .isoc_start_delay_ms = 350,
+         } },
        /* HP True Vision 5MP Camera */
        { .match_flags          = USB_DEVICE_ID_MATCH_DEVICE
                                | USB_DEVICE_ID_MATCH_INT_INFO,
drivers/media/usb/uvc/uvc_video.c +4 -0
index a92a986ab..e20330998 100644
@@ -6,6 +6,7 @@
  *          Laurent Pinchart ([email protected])
  */
 
+#include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/highmem.h>
 #include <linux/kernel.h>
@@ -2103,6 +2104,9 @@ static int uvc_video_start_transfer(struct uvc_streaming *stream,
                if (ret < 0)
                        return ret;
 
+               if (stream->dev->info->isoc_start_delay_ms)
+                       msleep(stream->dev->info->isoc_start_delay_ms);
+
                ret = uvc_init_video_isoc(stream, best_ep, gfp_flags);
        } else {
                /* Bulk endpoint, proceed to URB initialization. */
drivers/media/usb/uvc/uvcvideo.h +1 -1
index af8cef94f..eb949c6d8 100644
@@ -545,6 +545,7 @@ struct uvc_device_info {
        u32     quirks;
        u32     meta_format;
        u16     uvc_version;
+       u16     isoc_start_delay_ms;
 };
 
 struct uvc_rect {
--

2.56.0

Signature · 1 line
Ricardo Ribalda
maintainer
#4 lore raw

Re: [PATCH 2/2] media: uvcvideo: delay HP True Vision 5MP isochronous start

Quoted 80 lines · Ricardo Ribalda

Hi Parmjot

Could you provide the whole USB descriptor of the device lsusb -v -d 04f2:b767

Is it a internal camera (it looks so based on the name) if it is not, could you try connecting it to USB2 hub?

Quoted 30 lines · Parmjot Singh

The HP True Vision 5MP Camera (04f2:b767, revision 0.05) accepts COMMIT and SET_INTERFACE, then may disconnect shortly after starting isochronous transfers. A 350 ms pause between SET_INTERFACE and the first video URB allowed color streaming in MJPEG and YUYV modes.

Add a per-device isochronous startup delay and apply it to the color interface.

On Arch Linux 7.2.14, FFmpeg decoded 90 frames each in 720p MJPEG, 640x480 YUYV and 2592x1944 MJPEG, plus 300 frames after a 720p restart. The infrared stream still disconnected during the delay experiment, before the first video URB was submitted.

OpenAI Codex (GPT-6.2 Sol) helped design and analyze the USB timing experiment and write the driver change.

---
 drivers/media/usb/uvc/uvc_driver.c | 14 ++++++++++++++
 drivers/media/usb/uvc/uvc_video.c  |  4 ++++
 drivers/media/usb/uvc/uvcvideo.h   |  1 +
 3 files changed, 19 insertions(+)
drivers/media/usb/uvc/uvc_driver.c +0 -0
index 99c28991b..cfc626a15 100644

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

Quoted 7 lines
drivers/media/usb/uvc/uvc_driver.c +4 -0
@@ -2754,6 +2754,20 @@ static const struct usb_device_id uvc_ids[] = {
          .bInterfaceSubClass   = 1,
          .bInterfaceProtocol   = 0,
          .driver_info          = UVC_INFO_QUIRK(UVC_QUIRK_RESTRICT_FRAME_RATE) },
+       /* HP True Vision 5MP Camera (color) */
+       { .match_flags          = USB_DEVICE_ID_MATCH_DEVICE
+                               | USB_DEVICE_ID_MATCH_INT_INFO
+                               | USB_DEVICE_ID_MATCH_INT_NUMBER,

Why dont you add this to the previous quirk instead of adding a new fied?

We usually do not need to match int number.

Quoted 29 lines
drivers/media/usb/uvc/uvc_driver.c +10 -0
+         .idVendor             = 0x04f2,
+         .idProduct            = 0xb767,
+         .bInterfaceClass      = USB_CLASS_VIDEO,
+         .bInterfaceSubClass   = 1,
+         .bInterfaceProtocol   = UVC_PC_PROTOCOL_15,
+         .bInterfaceNumber     = 0,
+         .driver_info          = (kernel_ulong_t)&(const struct uvc_device_info){
+               .quirks = UVC_QUIRK_PROBE_DEF,
+               .isoc_start_delay_ms = 350,
+         } },
        /* HP True Vision 5MP Camera */
        { .match_flags          = USB_DEVICE_ID_MATCH_DEVICE
                                | USB_DEVICE_ID_MATCH_INT_INFO,
drivers/media/usb/uvc/uvc_video.c +1 -0
index a92a986ab..e20330998 100644
@@ -6,6 +6,7 @@
  *          Laurent Pinchart ([email protected])
  */
 
+#include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/highmem.h>
 #include <linux/kernel.h>
@@ -2103,6 +2104,9 @@ static int uvc_video_start_transfer(struct uvc_streaming *stream,
                if (ret < 0)
                        return ret;
 
Quoted 15 lines
Quoted 11 lines
drivers/media/usb/uvc/uvc_video.c +3 -0
+               if (stream->dev->info->isoc_start_delay_ms)
+                       msleep(stream->dev->info->isoc_start_delay_ms);
+
                ret = uvc_init_video_isoc(stream, best_ep, gfp_flags);
        } else {
                /* Bulk endpoint, proceed to URB initialization. */
drivers/media/usb/uvc/uvcvideo.h +0 -0
index af8cef94f..eb949c6d8 100644

drivers/media/usb/uvc/uvcvideo.h struct uvc_device_info { · line 548

Quoted 4 lines
drivers/media/usb/uvc/uvcvideo.h +1 -0
@@ -545,6 +545,7 @@ struct uvc_device_info {
        u32     quirks;
        u32     meta_format;
        u16     uvc_version;
+       u16     isoc_start_delay_ms;

Adding a new type of quirk requires a root cause analysis.

Quoted 3 lines
Quoted 3 lines
drivers/media/usb/uvc/uvcvideo.h +0 -0
 };
 
 struct uvc_rect {
Signature · 3 lines
Regards,

Laurent Pinchart