From patchwork Tue Aug 15 10:59:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Edgar Thier X-Patchwork-Id: 9901601 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1B36E60230 for ; Tue, 15 Aug 2017 10:59:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E88F28817 for ; Tue, 15 Aug 2017 10:59:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01DC62881B; Tue, 15 Aug 2017 10:59:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2FBDA28817 for ; Tue, 15 Aug 2017 10:59:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753571AbdHOK7u (ORCPT ); Tue, 15 Aug 2017 06:59:50 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:35775 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753542AbdHOK7t (ORCPT ); Tue, 15 Aug 2017 06:59:49 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id D194721309; Tue, 15 Aug 2017 06:59:48 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute4.internal (MEProxy); Tue, 15 Aug 2017 06:59:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=fm1; bh=ch0FJz89P/huzb/7zG Ks/IRqn21/yu81fMHgf6Rp2U8=; b=RwdhkfRt+Yz+j14zk0Ogmf7WfjQOtL7eqp pzzTRuZUU1SfpIUffGY6mM2/Lfjuhvdd8HamHicNJxxmZ7M/6yvhoPB6kVg82Ssl EERdoo2NJD4W5j4JWCTrk7CM+i5j3Q+MH6s1MPIKm+W0pcOuBCBJ9EHlG4O59vxi 78aYtb5UoLCcLsAwtpXl4KWEdSPMHkPScSUmkZCMD7Xf2U+4JSFPx/5TGnj4Wns2 yqLZMqOB/3SAbQ/JSP5NgG+QNONg1vtgezc53eqj0IgRjMMkARCKRBhLefh+GvPD lRGd34Kh+zoahJhsJo2f6Z0jVkltzgIWnI1kFaCuUeP9fIswAY5Q== X-ME-Sender: X-Sasl-enc: n3fcIjqWjR6yYyDK0Nm5mLwkyGXFOdInhoclxp0YNaI/ 1502794788 Received: from [192.168.0.146] (unknown [31.209.95.242]) by mail.messagingengine.com (Postfix) with ESMTPA id 656A224442; Tue, 15 Aug 2017 06:59:48 -0400 (EDT) From: Edgar Thier To: linux-media@vger.kernel.org Subject: [PATCH] uvcvideo: Apply flags from device to actual properties Cc: Laurent Pinchart Message-ID: Date: Tue, 15 Aug 2017 12:59:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 Content-Language: en-US Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use flags the device exposes for UVC controls. Signed-off-by: Edgar Thier --- drivers/media/usb/uvc/uvc_ctrl.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index c2ee6e3..bc69e92 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -1568,7 +1568,8 @@ int uvc_ctrl_set(struct uvc_video_chain *chain, return ret; } - ctrl->loaded = 1; + if (!(ctrl->info.flags && UVC_CTRL_FLAG_AUTO_UPDATE)) + ctrl->loaded = 1; } /* Backup the current value in case we need to rollback later. */ @@ -1889,8 +1890,13 @@ int uvc_ctrl_restore_values(struct uvc_device *dev) static int uvc_ctrl_add_info(struct uvc_device *dev, struct uvc_control *ctrl, const struct uvc_control_info *info) { + u8 *data; int ret = 0; + data = kmalloc(2, GFP_KERNEL); + if (data == NULL) + return -ENOMEM; + ctrl->info = *info; INIT_LIST_HEAD(&ctrl->info.mappings); @@ -1904,6 +1910,23 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, struct uvc_control *ctrl, ctrl->initialized = 1; + ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id, dev->intfnum, + info->selector, data, 1); + if (ret < 0) { + uvc_trace(UVC_TRACE_CONTROL, + "GET_INFO failed on control %pUl/%u (%d).\n", + info->entity, info->selector, ret); + } + else { + ctrl->info.flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX + | UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF + | (data[0] & UVC_CONTROL_CAP_GET ? + UVC_CTRL_FLAG_GET_CUR : 0) + | (data[0] & UVC_CONTROL_CAP_SET ? + UVC_CTRL_FLAG_SET_CUR : 0) + | (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ? + UVC_CTRL_FLAG_AUTO_UPDATE : 0); + } uvc_trace(UVC_TRACE_CONTROL, "Added control %pUl/%u to device %s " "entity %u\n", ctrl->info.entity, ctrl->info.selector, dev->udev->devpath, ctrl->entity->id); @@ -1911,6 +1934,7 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, struct uvc_control *ctrl, done: if (ret < 0) kfree(ctrl->uvc_data); + kfree(data); return ret; }