linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4] media: uvcvideo: Recover stalled ElGato devices
@ 2022-12-05 23:15 Ricardo Ribalda
  2022-12-29  2:16 ` Laurent Pinchart
  0 siblings, 1 reply; 2+ messages in thread
From: Ricardo Ribalda @ 2022-12-05 23:15 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Ricardo Ribalda, linux-media, Sergey Senozhatsky,
	Laurent Pinchart, linux-kernel, Yunke Cao

Elgato Cam Link 4k can be in a stalled state if the resolution of
the external source has changed while the firmware initializes.
Once in this state, the device is useless until it receives a
USB reset. It has even been observed that the stalled state will
continue even after unplugging the device.

lsusb -v

Bus 002 Device 002: ID 0fd9:0066 Elgato Systems GmbH Cam Link 4K
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               3.00
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0         9
  idVendor           0x0fd9 Elgato Systems GmbH
  idProduct          0x0066
  bcdDevice            0.00
  iManufacturer           1 Elgato
  iProduct                2 Cam Link 4K
  iSerial                 4 0005AC52FE000
  bNumConfigurations      1

Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
Recover stalled ElGato devices

Just a resend of this hw fix.

To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Yunke Cao <yunkec@chromium.org>
---
Changes in v4:
- Add Reviewed-by: Laurent
- Update error messages (Thanks Laurent!)
- Swap checks on if (Thanks Laurent)
- Link to v3: https://lore.kernel.org/r/20220920-resend-elgato-v3-0-57668054127f@chromium.org

Changes in v3:
- Add Reviewed-by: Sergey
- Improve identation (Thanks Sergey!)
- Link to v2: https://lore.kernel.org/r/20220920-resend-elgato-v2-0-06b48b3b486a@chromium.org

Changes in v2:
- Remove info from lsusb 
- Link to v1: https://lore.kernel.org/r/20220920-resend-elgato-v1-0-8672a2380e3d@chromium.org
---
 drivers/media/usb/uvc/uvc_video.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index 170a008f4006..ba7c159cb2a6 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -129,12 +129,13 @@ int uvc_query_ctrl(struct uvc_device *dev, u8 query, u8 unit,
 	return -EPIPE;
 }
 
+static const struct usb_device_id elgato_cam_link_4k = {
+	USB_DEVICE(0x0fd9, 0x0066)
+};
+
 static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
 	struct uvc_streaming_control *ctrl)
 {
-	static const struct usb_device_id elgato_cam_link_4k = {
-		USB_DEVICE(0x0fd9, 0x0066)
-	};
 	struct uvc_format *format = NULL;
 	struct uvc_frame *frame = NULL;
 	unsigned int i;
@@ -297,7 +298,7 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
 		dev_err(&stream->intf->dev,
 			"Failed to query (%u) UVC %s control : %d (exp. %u).\n",
 			query, probe ? "probe" : "commit", ret, size);
-		ret = -EIO;
+		ret = (ret == -EPROTO) ? -EPROTO : -EIO;
 		goto out;
 	}
 
@@ -2121,6 +2122,21 @@ int uvc_video_init(struct uvc_streaming *stream)
 	 * request on the probe control, as required by the UVC specification.
 	 */
 	ret = uvc_get_video_ctrl(stream, probe, 1, UVC_GET_CUR);
+
+	/*
+	 * Elgato Cam Link 4k can be in a stalled state if the resolution of
+	 * the external source has changed while the firmware initializes.
+	 * Once in this state, the device is useless until it receives a
+	 * USB reset. It has even been observed that the stalled state will
+	 * continue even after unplugging the device.
+	 */
+	if (ret == -EPROTO &&
+	    usb_match_one_id(stream->dev->intf, &elgato_cam_link_4k)) {
+		dev_err(&stream->intf->dev, "Elgato Cam Link 4K firmware crash detected\n");
+		dev_err(&stream->intf->dev, "Resetting the device, unplug and replug to recover\n");
+		usb_reset_device(stream->dev->udev);
+	}
+
 	if (ret < 0)
 		return ret;
 

---
base-commit: 521a547ced6477c54b4b0cc206000406c221b4d6
change-id: 20220920-resend-elgato-a845482bdd02

Best regards,
-- 
Ricardo Ribalda <ribalda@chromium.org>

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v4] media: uvcvideo: Recover stalled ElGato devices
  2022-12-05 23:15 [PATCH v4] media: uvcvideo: Recover stalled ElGato devices Ricardo Ribalda
@ 2022-12-29  2:16 ` Laurent Pinchart
  0 siblings, 0 replies; 2+ messages in thread
From: Laurent Pinchart @ 2022-12-29  2:16 UTC (permalink / raw)
  To: Ricardo Ribalda
  Cc: Mauro Carvalho Chehab, linux-media, Sergey Senozhatsky,
	linux-kernel, Yunke Cao

Hi Ricardo,

On Tue, Dec 06, 2022 at 12:15:04AM +0100, Ricardo Ribalda wrote:
> Elgato Cam Link 4k can be in a stalled state if the resolution of
> the external source has changed while the firmware initializes.
> Once in this state, the device is useless until it receives a
> USB reset. It has even been observed that the stalled state will
> continue even after unplugging the device.
> 
> lsusb -v
> 
> Bus 002 Device 002: ID 0fd9:0066 Elgato Systems GmbH Cam Link 4K
> Device Descriptor:
>   bLength                18
>   bDescriptorType         1
>   bcdUSB               3.00
>   bDeviceClass          239 Miscellaneous Device
>   bDeviceSubClass         2
>   bDeviceProtocol         1 Interface Association
>   bMaxPacketSize0         9
>   idVendor           0x0fd9 Elgato Systems GmbH
>   idProduct          0x0066
>   bcdDevice            0.00
>   iManufacturer           1 Elgato
>   iProduct                2 Cam Link 4K
>   iSerial                 4 0005AC52FE000
>   bNumConfigurations      1
> 
> Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
> Recover stalled ElGato devices
> 
> Just a resend of this hw fix.

Taken in my tree, thanks.

> To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> To: Mauro Carvalho Chehab <mchehab@kernel.org>
> Cc: linux-media@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
> Cc: Yunke Cao <yunkec@chromium.org>
> ---
> Changes in v4:
> - Add Reviewed-by: Laurent
> - Update error messages (Thanks Laurent!)
> - Swap checks on if (Thanks Laurent)
> - Link to v3: https://lore.kernel.org/r/20220920-resend-elgato-v3-0-57668054127f@chromium.org
> 
> Changes in v3:
> - Add Reviewed-by: Sergey
> - Improve identation (Thanks Sergey!)
> - Link to v2: https://lore.kernel.org/r/20220920-resend-elgato-v2-0-06b48b3b486a@chromium.org
> 
> Changes in v2:
> - Remove info from lsusb 
> - Link to v1: https://lore.kernel.org/r/20220920-resend-elgato-v1-0-8672a2380e3d@chromium.org
> ---
>  drivers/media/usb/uvc/uvc_video.c | 24 ++++++++++++++++++++----
>  1 file changed, 20 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
> index 170a008f4006..ba7c159cb2a6 100644
> --- a/drivers/media/usb/uvc/uvc_video.c
> +++ b/drivers/media/usb/uvc/uvc_video.c
> @@ -129,12 +129,13 @@ int uvc_query_ctrl(struct uvc_device *dev, u8 query, u8 unit,
>  	return -EPIPE;
>  }
>  
> +static const struct usb_device_id elgato_cam_link_4k = {
> +	USB_DEVICE(0x0fd9, 0x0066)
> +};
> +
>  static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
>  	struct uvc_streaming_control *ctrl)
>  {
> -	static const struct usb_device_id elgato_cam_link_4k = {
> -		USB_DEVICE(0x0fd9, 0x0066)
> -	};
>  	struct uvc_format *format = NULL;
>  	struct uvc_frame *frame = NULL;
>  	unsigned int i;
> @@ -297,7 +298,7 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
>  		dev_err(&stream->intf->dev,
>  			"Failed to query (%u) UVC %s control : %d (exp. %u).\n",
>  			query, probe ? "probe" : "commit", ret, size);
> -		ret = -EIO;
> +		ret = (ret == -EPROTO) ? -EPROTO : -EIO;
>  		goto out;
>  	}
>  
> @@ -2121,6 +2122,21 @@ int uvc_video_init(struct uvc_streaming *stream)
>  	 * request on the probe control, as required by the UVC specification.
>  	 */
>  	ret = uvc_get_video_ctrl(stream, probe, 1, UVC_GET_CUR);
> +
> +	/*
> +	 * Elgato Cam Link 4k can be in a stalled state if the resolution of
> +	 * the external source has changed while the firmware initializes.
> +	 * Once in this state, the device is useless until it receives a
> +	 * USB reset. It has even been observed that the stalled state will
> +	 * continue even after unplugging the device.
> +	 */
> +	if (ret == -EPROTO &&
> +	    usb_match_one_id(stream->dev->intf, &elgato_cam_link_4k)) {
> +		dev_err(&stream->intf->dev, "Elgato Cam Link 4K firmware crash detected\n");
> +		dev_err(&stream->intf->dev, "Resetting the device, unplug and replug to recover\n");
> +		usb_reset_device(stream->dev->udev);
> +	}
> +
>  	if (ret < 0)
>  		return ret;
>  
> 
> ---
> base-commit: 521a547ced6477c54b4b0cc206000406c221b4d6
> change-id: 20220920-resend-elgato-a845482bdd02

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-12-29  2:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-05 23:15 [PATCH v4] media: uvcvideo: Recover stalled ElGato devices Ricardo Ribalda
2022-12-29  2:16 ` Laurent Pinchart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).