[PATCH][Natty SRU] UBUNTU: SAUCE: uvcvideo: add SetInterface(0) in .reset_resume handler

Ming Lei ming.lei at canonical.com
Tue Jul 26 03:39:56 UTC 2011

From 2f485a24a5732b980f2d1c7097469f07cb848c70 Mon Sep 17 00:00:00 2001
From: Ming Lei <ming.lei at canonical.com>
Date: Sat, 16 Jul 2011 11:29:45 +0800
Subject: [PATCH][Natty SRU] UBUNTU: SAUCE: uvcvideo: add SetInterface(0) in .reset_resume handler

As commented in uvc_video_init,

	/* Alternate setting 0 should be the default, yet the XBox Live Vision
	 * Cam (and possibly other devices) crash or otherwise misbehave if
	 * they don't receive a SET_INTERFACE request before any other video
	 * control request.

so it does make sense to add the SetInterface(0) in .reset_resume
handler so that this kind of devices can work well if they are reseted
during resume from system or runtime suspend.

We have found, without the patch, Microdia camera(0c45:6437) can't send
stream data any longer after it is reseted during resume from
system suspend.

SRU Justification:

	- without the patch, the Microdia camera(0c45:6437) can't
	work after system resume

        - After applying the patch, the camera can work well after
	system resume

BugLink: http://bugs.launchpad.net/bugs/733509

upstream discusstion:  http://marc.info/?t=131037773100002&r=1&w=2

Signed-off-by: Ming Lei <ming.lei at canonical.com>
Cc: Jeremy Kerr <jeremy.kerr at canonical.com>
BTW: The patch will enter 3.1-rc later, not sure how Oneiric will merge
the patch. 
 drivers/media/video/uvc/uvc_driver.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/drivers/media/video/uvc/uvc_driver.c b/drivers/media/video/uvc/uvc_driver.c
index b6eae48..41c6d1a 100644
--- a/drivers/media/video/uvc/uvc_driver.c
+++ b/drivers/media/video/uvc/uvc_driver.c
@@ -1959,8 +1959,20 @@ static int __uvc_resume(struct usb_interface *intf, int reset)
 	list_for_each_entry(stream, &dev->streams, list) {
-		if (stream->intf == intf)
+		if (stream->intf == intf) {
+			/*
+			 * After usb bus reset, some devices may
+			 * misbehave if SetInterface(0) is not done, for
+			 * example, Microdia camera(0c45:6437) will stop
+			 * sending streaming data. Looks like XBox Live
+			 * Vision Cam needs it too, as commented in
+			 * uvc_video_init.
+			 */
+			if (reset)
+				usb_set_interface(stream->dev->udev,
+					stream->intfnum, 0);
 			return uvc_video_resume(stream);
+		}
 	uvc_trace(UVC_TRACE_SUSPEND, "Resume: video streaming USB interface "

Ming Lei

More information about the kernel-team mailing list