From patchwork Fri Aug 21 09:29:42 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: 7050621 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A06F69F358 for ; Fri, 21 Aug 2015 09:32:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CCB8D204D1 for ; Fri, 21 Aug 2015 09:32:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EB18A2047D for ; Fri, 21 Aug 2015 09:32:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752409AbbHUJcP (ORCPT ); Fri, 21 Aug 2015 05:32:15 -0400 Received: from mail-lb0-f177.google.com ([209.85.217.177]:34064 "EHLO mail-lb0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753363AbbHUJ34 (ORCPT ); Fri, 21 Aug 2015 05:29:56 -0400 Received: by lbbtg9 with SMTP id tg9so40172841lbb.1; Fri, 21 Aug 2015 02:29:54 -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=rLUiMOQTkq+u/MXWXyHppxmuBrEdDDc2YS1UGA7HhMKH4PozDk/GP9oirLyTLJw5y/ ggtD367a5Wg7d9sPo2AfvgCHG0IAk4RI5iX7YXj17Qpbci9YOzlahkT1/1HSvbfLEnaD CDvond5XtiHg+y9ZyY5NcathkHNCwnRagexCXA3X4oCnoQBMZTosYugJTG9dwluOS0zF ocwobVtZVjmzdXY7l+rnFQpEaTOXwzA0g4pmVm0zUvukHdqcwntqsSdqQmWu2tg/Zqss ebSrkJ0nL6++y3LpBhPTW2AidcBeH0sfGREwwoVJXi2FvElk3pFTB7fe8OlqA9Wrdaus wTmw== X-Received: by 10.152.43.194 with SMTP id y2mr6927856lal.29.1440149394795; Fri, 21 Aug 2015 02:29:54 -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 f10sm2112680lae.23.2015.08.21.02.29.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 21 Aug 2015 02:29:54 -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 4/8] usb/uvc: Support for V4L2_CTRL_WHICH_DEF_VAL Date: Fri, 21 Aug 2015 11:29:42 +0200 Message-Id: <1440149386-19783-5-git-send-email-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1440149386-19783-1-git-send-email-ricardo.ribalda@gmail.com> References: <1440149386-19783-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;