From patchwork Fri Aug 21 13:19:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 7051841 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5E0E3C05AC for ; Fri, 21 Aug 2015 13:21:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8CCCD20620 for ; Fri, 21 Aug 2015 13:21:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ABDA4205D6 for ; Fri, 21 Aug 2015 13:21:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753684AbbHUNTp (ORCPT ); Fri, 21 Aug 2015 09:19:45 -0400 Received: from mail-lb0-f177.google.com ([209.85.217.177]:33710 "EHLO mail-lb0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753653AbbHUNTn (ORCPT ); Fri, 21 Aug 2015 09:19:43 -0400 Received: by lbbsx3 with SMTP id sx3so43477494lbb.0; Fri, 21 Aug 2015 06:19:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TMLo3fwmbTWSChlJZJgP7zALZxJvePCAZeitYIZQRGQ=; b=YuGiD56O1t+P5xzVzyUu88dUMkUglmn/goFGff0goiUbqyN/oz+4vohzRwNn1MqlGx N44/BNYDvH7HK+OzxZTFgbECUjTDbLZjaU6uDzPhBaYwscyLR93fzt5pDSLZ9j8WdWhB bP0OfVmMT+YJUV6hk2lm1m9OUvUKS96wPO+Vsrm3J3DLTQp4PqDwTZSOqyJ+8LOfts3Y 7HwO/Xz0fZrjsfJNqD2D9C89GFTU0J2x/b5l0abj6H5B6ihCzw8POUpkZC1OP4UhBo8H kNCJjJb7S71F3kir5vFVHqKy/u8rnRRiUTVVT/iZ/hHaxIADgLmQX5pc+AzRgZwRFL0J 2+0Q== X-Received: by 10.152.5.228 with SMTP id v4mr7902463lav.36.1440163182000; Fri, 21 Aug 2015 06:19:42 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id ph4sm2293746lbb.3.2015.08.21.06.19.40 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 21 Aug 2015 06:19:40 -0700 (PDT) From: Ricardo Ribalda Delgado To: Mauro Carvalho Chehab , Mike Isely , Laurent Pinchart , Hans Verkuil , Steven Toth , Sakari Ailus , Vincent Palatin , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado Subject: [PATCH v2 06/10] usb/uvc: Support for V4L2_CTRL_WHICH_DEF_VAL Date: Fri, 21 Aug 2015 15:19:25 +0200 Message-Id: <1440163169-18047-7-git-send-email-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1440163169-18047-1-git-send-email-ricardo.ribalda@gmail.com> References: <1440163169-18047-1-git-send-email-ricardo.ribalda@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This driver does not use the control infrastructure. Add support for the new field which on structure v4l2_ext_controls Signed-off-by: Ricardo Ribalda Delgado --- drivers/media/usb/uvc/uvc_v4l2.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index 2764f43607c1..e6d3a1bcfa2f 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c @@ -980,6 +980,7 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file, void *fh, struct uvc_fh *handle = fh; struct uvc_video_chain *chain = handle->chain; struct v4l2_ext_control *ctrl = ctrls->controls; + struct v4l2_queryctrl qc; unsigned int i; int ret; @@ -988,7 +989,14 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file, void *fh, return ret; for (i = 0; i < ctrls->count; ++ctrl, ++i) { - ret = uvc_ctrl_get(chain, ctrl); + if (ctrls->which == V4L2_CTRL_WHICH_DEF_VAL) { + qc.id = ctrl->id; + ret = uvc_query_v4l2_ctrl(chain, &qc); + if (!ret) + ctrl->value = qc.default_value; + } else + ret = uvc_ctrl_get(chain, ctrl); + if (ret < 0) { uvc_ctrl_rollback(handle); ctrls->error_idx = i; @@ -1010,6 +1018,10 @@ static int uvc_ioctl_s_try_ext_ctrls(struct uvc_fh *handle, unsigned int i; int ret; + /* Default value cannot be changed */ + if (ctrls->which == V4L2_CTRL_WHICH_DEF_VAL) + return -EINVAL; + ret = uvc_ctrl_begin(chain); if (ret < 0) return ret;