From patchwork Wed Mar 5 23:01:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Manley X-Patchwork-Id: 22822 X-Patchwork-Delegate: laurent.pinchart@ideasonboard.com Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1WLKoH-00050a-83; Thu, 06 Mar 2014 00:01:09 +0100 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.72/mailfrontend-7) with esmtp id 1WLKoE-0003qu-1t; Thu, 06 Mar 2014 00:01:08 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756994AbaCEXBE (ORCPT + 1 other); Wed, 5 Mar 2014 18:01:04 -0500 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:52393 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755323AbaCEXBC (ORCPT ); Wed, 5 Mar 2014 18:01:02 -0500 Received: from compute3.internal (compute3.nyi.mail.srv.osa [10.202.2.43]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 808872109A for ; Wed, 5 Mar 2014 18:01:01 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute3.internal (MEProxy); Wed, 05 Mar 2014 18:01:01 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=williammanley.net; h=message-id:date:from:mime-version:to:subject:content-type :content-transfer-encoding; s=mesmtp; bh=RDBOc2pOsNC2cH+qdjfuDWK 1CrA=; b=dd5Yva/u+DicuRjyOotiQctlcDOXxDcIFIy1kCauG4q3YgqDDodaZ8a tcKXS604Tv7UypKciOew59fSjFJ4vI06lcntai0gbNDfwiTz6nPjS5lxwC9ts4vk fP2DLG6MqwQXqYdaM7i5HcsN6PpqFAgdabY8nTsUjYBS7nb2Qxw8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:date:from:mime-version:to :subject:content-type:content-transfer-encoding; s=smtpout; bh=R DBOc2pOsNC2cH+qdjfuDWK1CrA=; b=gwmsytheufHJMOppkLBvzWXMIKF6zobT0 ZTHevlTXu3VrmuHlnKMjGyLiRtPUQgbfdT/DDMcEx01W7Dw1urYLJ0l5Vtv5hyie KK01PlNwBYBLeLGLLywBxNmz6H5arFPyQZS1RWfr9GuNuWxnnUGLCQSTrTCkQXIe pxorxOlqxk= X-Sasl-enc: RH+4bCI+5lrwS+4Abw8eRBxzDqgUYpT2FBNDm/QaZX8V 1394060461 Received: from [192.168.0.8] (unknown [86.26.230.106]) by mail.messagingengine.com (Postfix) with ESMTPA id 1FBC7C00005 for ; Wed, 5 Mar 2014 18:01:01 -0500 (EST) Message-ID: <5317ACAC.8000008@williammanley.net> Date: Wed, 05 Mar 2014 23:01:00 +0000 From: William Manley User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131103 Icedove/17.0.10 MIME-Version: 1.0 To: linux-media@vger.kernel.org Subject: uvcvideo: logitech C920 resets controls during VIDIOC_STREAMON X-Enigmail-Version: 1.6 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2014.3.5.225715 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_4000_4999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DKIM_SIGNATURE 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __MOZILLA_MSGID 0, __MOZILLA_USER_AGENT 0, __SANE_MSGID 0, __SUBJ_ALPHA_NEGATE 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS , __USER_AGENT 0' Hi All I've been attempting to use the Logitech C920 with the uvcvideo driver. I set the controls with v4l2-ctl but some of them change during VIDIOC_STREAMON. My understanding is that the values of controls should be preserved. Minimal test case: #include #include #include #include #include #include #include #include #define DEVICE "/dev/video2" int main() { int fd, type; fd = open(DEVICE, O_RDWR | O_CLOEXEC); if (fd < 0) { perror("Failed to open " DEVICE "\n"); return 1; } struct v4l2_requestbuffers reqbuf = { .type = V4L2_BUF_TYPE_VIDEO_CAPTURE, .memory = V4L2_MEMORY_MMAP, .count = 1, }; if (-1 == ioctl (fd, VIDIOC_REQBUFS, &reqbuf)) { perror("VIDIOC_REQBUFS"); return 1; } system("v4l2-ctl -d" DEVICE " -l | grep exposure_absolute"); type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (ioctl (fd, VIDIOC_STREAMON, &type) != 0) { perror("VIDIOC_STREAMON"); return 1; } printf("VIDIOC_STREAMON\n"); usleep(100000); system("v4l2-ctl -d" DEVICE " -l | grep exposure_absolute"); return 0; } None of the other controls seem to be affected. Note: to get the C920 to report exposure_absolute correctly I also had to make this change to the uvcvideo kernel driver: At this point the backtrace looks something like: uvc_init_video uvc_video_enable uvc_v4l2_do_ioctl (in the case VIDIOC_STREAMON:) The call to uvc_ctrl_resume_device() has the effect that the v4l2 ctrls which are cached in the kernel get resubmitted to the camera as if it were coming out of suspend/resume. I've looked at the wireshark capture of USB traffic and I can't find anywhere where the host causes exposure_auto to change. The camera does have a mode where it would change by itself but that is disabled (exposure_auto=1). I've uploaded the wireshark trace to: http://williammanley.net/usb-wireshark-streamon.pcapng I'm guessing that this is a hardware bug. One fix would be modify the driver to save all values at the beginning of STREAMON and then restore them at the end. What do you think? Thanks Will --- 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 diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index a2f4501..e7c805b 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -227,7 +227,8 @@ static struct uvc_control_info uvc_ctrls[] = { .size = 4, .flags = UVC_CTRL_FLAG_SET_CUR | UVC_CTRL_FLAG_GET_RANGE - | UVC_CTRL_FLAG_RESTORE, + | UVC_CTRL_FLAG_RESTORE + | UVC_CTRL_FLAG_AUTO_UPDATE, }, { .entity = UVC_GUID_UVC_CAMERA, The variables seem to be changed when the URBs are Submitted. To investigate I made the following change to the uvc driver: diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c index 3394c34..f2f66f6 100644 --- a/drivers/media/usb/uvc/uvc_video.c +++ b/drivers/media/usb/uvc/uvc_video.c @@ -1649,17 +1649,23 @@ static int uvc_init_video(struct uvc_streaming *stream, gfp_t gfp_flags) if (ret < 0) return ret; + /* No effect: */ + uvc_ctrl_resume_device(stream->dev); + /* Submit the URBs. */ for (i = 0; i < UVC_URBS; ++i) { ret = usb_submit_urb(stream->urb[i], gfp_flags); if (ret < 0) { uvc_printk(KERN_ERR, "Failed to submit URB %u " "(%d).\n", i, ret); uvc_uninit_video(stream, 1); return ret; } } + /* "Fixes" the issue: */ + uvc_ctrl_resume_device(stream->dev); + return 0; }