diff mbox

[PATCH/RFC] uvcvideo: Disable USB autosuspend for Creative Live! Cam Optia AF

Message ID 1364471612-31792-1-git-send-email-laurent.pinchart@ideasonboard.com (mailing list archive)
State New, archived
Headers show

Commit Message

Laurent Pinchart March 28, 2013, 11:53 a.m. UTC
The camera fails to start video streaming after having been autosuspend.
Add a new quirk to selectively disable autosuspend for devices that
don't support it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/media/usb/uvc/uvc_driver.c | 14 +++++++++++++-
 drivers/media/usb/uvc/uvcvideo.h   |  1 +
 2 files changed, 14 insertions(+), 1 deletion(-)

I've tried to set the reset resume quirk for this device in the USB core but
the camera still failed to start video streaming after having been
autosuspended. Regardless of whether the reset resume quirk was set, it would
respond to control messages but wouldn't send video data.

This solution below is a hack, but I'm not sure what else I can try. Crazy
ideas are welcome.

Comments

Alan Stern March 28, 2013, 2:45 p.m. UTC | #1
On Thu, 28 Mar 2013, Laurent Pinchart wrote:

> The camera fails to start video streaming after having been autosuspend.
> Add a new quirk to selectively disable autosuspend for devices that
> don't support it.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  drivers/media/usb/uvc/uvc_driver.c | 14 +++++++++++++-
>  drivers/media/usb/uvc/uvcvideo.h   |  1 +
>  2 files changed, 14 insertions(+), 1 deletion(-)
> 
> I've tried to set the reset resume quirk for this device in the USB core but
> the camera still failed to start video streaming after having been
> autosuspended. Regardless of whether the reset resume quirk was set, it would
> respond to control messages but wouldn't send video data.

Presumably the camera won't work after a system suspend, either.

> This solution below is a hack, but I'm not sure what else I can try. Crazy
> ideas are welcome.

It's not a hack; it's a normal use for a quirk flag.  Of course, if you 
can figure out what's wrong with the camera and see how to fix it, that 
would be best.

How does the camera perform on a Windows system after being put to
sleep and then woken up?

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Laurent Pinchart April 4, 2013, 3:28 p.m. UTC | #2
Hi Alan,

On Thursday 28 March 2013 10:45:27 Alan Stern wrote:
> On Thu, 28 Mar 2013, Laurent Pinchart wrote:
> > The camera fails to start video streaming after having been autosuspend.
> > Add a new quirk to selectively disable autosuspend for devices that
> > don't support it.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> > 
> >  drivers/media/usb/uvc/uvc_driver.c | 14 +++++++++++++-
> >  drivers/media/usb/uvc/uvcvideo.h   |  1 +
> >  2 files changed, 14 insertions(+), 1 deletion(-)
> > 
> > I've tried to set the reset resume quirk for this device in the USB core
> > but the camera still failed to start video streaming after having been
> > autosuspended. Regardless of whether the reset resume quirk was set, it
> > would respond to control messages but wouldn't send video data.
> 
> Presumably the camera won't work after a system suspend, either.

That was my expectation as well, but the device has survived system suspend 
without being reenumerated. I don't know if the USB port power got cut off 
during system suspend.

> > This solution below is a hack, but I'm not sure what else I can try. Crazy
> > ideas are welcome.
> 
> It's not a hack; it's a normal use for a quirk flag.  Of course, if you
> can figure out what's wrong with the camera and see how to fix it, that
> would be best.

I've tried to but I can't figure out what goes wrong exactly.

> How does the camera perform on a Windows system after being put to
> sleep and then woken up?

I don't know, I have no Windows system to test the camera on.
diff mbox

Patch

diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index 5dbefa6..99e2de0 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -1913,8 +1913,11 @@  static int uvc_probe(struct usb_interface *intf,
 			"supported.\n", ret);
 	}
 
+	if (!(dev->quirks & UVC_QUIRK_DISABLE_AUTOSUSPEND))
+		usb_enable_autosuspend(udev);
+
 	uvc_trace(UVC_TRACE_PROBE, "UVC device initialized.\n");
-	usb_enable_autosuspend(udev);
+
 	return 0;
 
 error:
@@ -2061,6 +2064,15 @@  static struct usb_device_id uvc_ids[] = {
 	  .bInterfaceSubClass	= 1,
 	  .bInterfaceProtocol	= 0,
 	  .driver_info		= UVC_QUIRK_PROBE_MINMAX },
+	/* Creative Live! Cam Optia AF */
+	{ .match_flags		= USB_DEVICE_ID_MATCH_DEVICE
+				| USB_DEVICE_ID_MATCH_INT_INFO,
+	  .idVendor		= 0x041e,
+	  .idProduct		= 0x4058,
+	  .bInterfaceClass	= USB_CLASS_VIDEO,
+	  .bInterfaceSubClass	= 1,
+	  .bInterfaceProtocol	= 0,
+	  .driver_info		= UVC_QUIRK_DISABLE_AUTOSUSPEND },
 	/* Genius eFace 2025 */
 	{ .match_flags		= USB_DEVICE_ID_MATCH_DEVICE
 				| USB_DEVICE_ID_MATCH_INT_INFO,
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index af505fd..9cd584a 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -137,6 +137,7 @@ 
 #define UVC_QUIRK_FIX_BANDWIDTH		0x00000080
 #define UVC_QUIRK_PROBE_DEF		0x00000100
 #define UVC_QUIRK_RESTRICT_FRAME_RATE	0x00000200
+#define UVC_QUIRK_DISABLE_AUTOSUSPEND	0x00000400
 
 /* Format flags */
 #define UVC_FMT_FLAG_COMPRESSED		0x00000001