From patchwork Fri Jul 15 13:53:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 978162 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6FDrmwl017483 for ; Fri, 15 Jul 2011 13:53:48 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751865Ab1GONxh (ORCPT ); Fri, 15 Jul 2011 09:53:37 -0400 Received: from mail-gx0-f174.google.com ([209.85.161.174]:45601 "EHLO mail-gx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750865Ab1GONxf convert rfc822-to-8bit (ORCPT ); Fri, 15 Jul 2011 09:53:35 -0400 Received: by gxk21 with SMTP id 21so535797gxk.19 for ; Fri, 15 Jul 2011 06:53:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=X5SAKXTS9pKv5xxSIlxzihtWYKpqlcJNwlOsHoDqCnI=; b=aIz8MuX8T8tJHnm1rUz0jBzXjLZXsG2cuIcJkX+E+Axa58ytNArOBAJW5Sn2vVNJnT f5GC9HcU4hP5pYYf4jTB1yputbtHcEo0BAoch/3dk+vgy2/Y7W459aVB5BY4SfGf08P2 XLBv8rbDx+DrI/2yiEpjEVt50w9NTN3xG9Q7U= MIME-Version: 1.0 Received: by 10.236.187.70 with SMTP id x46mr1018178yhm.351.1310738014782; Fri, 15 Jul 2011 06:53:34 -0700 (PDT) Received: by 10.236.70.101 with HTTP; Fri, 15 Jul 2011 06:53:34 -0700 (PDT) In-Reply-To: References: Date: Fri, 15 Jul 2011 21:53:34 +0800 Message-ID: Subject: Re: [PATCH] uvcvideo: add fix suspend/resume quirk for Microdia camera From: Ming Lei To: Alan Stern Cc: Laurent Pinchart , Ming Lei , linux-media@vger.kernel.org, linux-usb@vger.kernel.org, Jeremy Kerr , Mauro Carvalho Chehab Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 15 Jul 2011 13:53:48 +0000 (UTC) Hi, On Thu, Jul 14, 2011 at 11:03 PM, Alan Stern wrote: > More likely, the reset erases some device setting that uvcvideo > installed while binding.  Evidently uvcvideo does not re-install the > setting during reset-resume; this is probably a bug in the driver. Alan, you are right. I think I have found the root cause. Given many devices can't handle set_interface(0) if the interfaces were already in altsetting 0, usb_reset_and_verify_device does not run set_interface(0). So we need to do it in .reset_resume handler of uvc driver and it is always safe for uvc devices. I have tested the below patch, and it can make the uvc device work well after rpm resume and system resume(reset resume), both in streaming on and off case. Alan, Laurent, if you have no objections, I will submit a formal one. uvc_trace(UVC_TRACE_SUSPEND, "Resume: video streaming USB interface " thanks, diff --git a/drivers/media/video/uvc/uvc_driver.c b/drivers/media/video/uvc/uvc_driver.c index b6eae48..4055dfc 100644 --- a/drivers/media/video/uvc/uvc_driver.c +++ b/drivers/media/video/uvc/uvc_driver.c @@ -1959,8 +1959,12 @@ 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) { + if (reset) + usb_set_interface(stream->dev->udev, + stream->intfnum, 0); return uvc_video_resume(stream); + } }