Message ID | 20221025055528.1117251-3-yunkec@google.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Laurent Pinchart |
Headers |
Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from <linux-media-owner@vger.kernel.org>) id 1onCuk-00A7e6-JO; Tue, 25 Oct 2022 05:55:51 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229785AbiJYFzs (ORCPT <rfc822;mkrufky@linuxtv.org> + 1 other); Tue, 25 Oct 2022 01:55:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230525AbiJYFzr (ORCPT <rfc822;linux-media@vger.kernel.org>); Tue, 25 Oct 2022 01:55:47 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D62CA402C3 for <linux-media@vger.kernel.org>; Mon, 24 Oct 2022 22:55:45 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-368e6c449f2so109025397b3.5 for <linux-media@vger.kernel.org>; Mon, 24 Oct 2022 22:55:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=8WUw8DbrB9vOMp1sQYuLlmg+N/S18v3TkuImlQpQcV0=; b=m79MqKB7e74+Nz2HbMqQ4e1DZ5LLXiPzE8iHEGPnP1H6qzw7BPN0Sdj0p2wMTPFuN9 zrzrsLsBo/+KfVvWAw4B0eUc4ZZgrEOLQGRKBT9IhB7Ta7qw3fqf+1zYSEa8R+qnPwC3 TxeJaqTymP995JllkE6UJ+E833Un8IbzSb7WOEfn88Z1+lKZiw1UKgZN4jirn5BTRKXC jiBHd17TvbcaYJVkHRfEw8GGUimIBVwpzOldU4U4J/CzWt1qPaoahP2naeMeF6WgvzhL 8NIwF4XYiowmiBqZxBubHQJ7OzVj386SYTHY4EIUiA23YysGDrUtXgYBvAIWzVZRueKs QlbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8WUw8DbrB9vOMp1sQYuLlmg+N/S18v3TkuImlQpQcV0=; b=goM45PdD/OZXuyecmW9J+sy/AWTEwxth9NqQ5EXvX9o6+wD0HvqdsODzJrMcfLg0ic RCNvx9OwajgFEzoLnhlR2uscgSwV6UF5MQ0f1yHD+gn6yUaKAT0m+sd/C15XUn0gf2PN BOQg6Wie9gm1PFE490boFGLcQgDR481K8Ae5/TI+H1rpvU7JpIvtt6Y445gbWye3REmN GD934w5k2+mhuG7uaqcl8myL/glr7hPUTfZ5FdrjNxbRS++GwUdJFO+pKdirWbc0CHrw lMlo4ePNz3SypL7Bfg7os/VEkxM6ixOvvrUu7ebEBLAABBOjQlM6Gb4UUvvkSNFq1Twl 1bhw== X-Gm-Message-State: ACrzQf2IX/493eEtkWG2rH3TUevSs+kALiH/jxgv1z62tLPcMbpSG2re OiEYvxhO10BjTtkGY/bNMlmHgt9TA5I= X-Google-Smtp-Source: AMsMyM67e3O3kDGqeZgezGO6c5nTzTC/zLcRqj5A2A99Ea7nG+I941tEVaWaCW30IdJoqLsua4huvx+doAc= X-Received: from yunkec1.tok.corp.google.com ([2401:fa00:8f:203:7ee8:fa64:12b0:14f3]) (user=yunkec job=sendgmr) by 2002:a25:4fc1:0:b0:6bc:c570:f99e with SMTP id d184-20020a254fc1000000b006bcc570f99emr32209399ybb.58.1666677345164; Mon, 24 Oct 2022 22:55:45 -0700 (PDT) Date: Tue, 25 Oct 2022 14:55:19 +0900 In-Reply-To: <20221025055528.1117251-1-yunkec@google.com> Mime-Version: 1.0 References: <20221025055528.1117251-1-yunkec@google.com> X-Mailer: git-send-email 2.38.0.135.g90850a2211-goog Message-ID: <20221025055528.1117251-3-yunkec@google.com> Subject: [PATCH v9 02/11] media: uvcvideo: add uvc_ctrl_get_boundary for getting default value From: Yunke Cao <yunkec@google.com> To: Hans Verkuil <hverkuil-cisco@xs4all.nl>, Laurent Pinchart <laurent.pinchart@ideasonboard.com> Cc: Nicolas Dufresne <nicolas@ndufresne.ca>, Mauro Carvalho Chehab <mchehab@kernel.org>, Tomasz Figa <tfiga@chromium.org>, Sergey Senozhatsky <senozhatsky@chromium.org>, Ricardo Ribalda <ribalda@chromium.org>, linux-media@vger.kernel.org, Yunke Cao <yunkec@google.com> Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-media.vger.kernel.org> X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -10.0 (----------) X-LSpam-Report: No, score=-10.0 required=5.0 tests=BAYES_00=-1.9,DKIMWL_WL_MED=0.001,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no |
Series |
media: Implement UVC v1.5 ROI
|
|
Commit Message
Yunke Cao
Oct. 25, 2022, 5:55 a.m. UTC
Introduce uvc_ctrl_get_boundary(), making it easier to extend to support compound controls and V4L2_CTRL_WHICH_MIN/MAX_VAL in the following patches. For now, it simply returns EINVAL for compound controls and calls __query_v4l2_ctrl() for non-compound controls. Reviewed-by: Ricardo Ribalda <ribalda@chromium.org> Signed-off-by: Yunke Cao <yunkec@google.com> --- Changelog since v8: - No Change. Changelog since v7: - Rename uvc_ctrl_get_fixed() to uvc_ctrl_get_boundary(). - Move refactor (introduce __uvc_ctrl_get_boundary_std()) in this patch instead of in the patch where we implement compound control. - Fix locking. uvc_ctrl_get_boundary() now acquires ctrl_mutex. __uvc_ctrl_get_boundary_std() calls __uvc_query_v4l2_ctrl() while holding the mutex. - Define a uvc_ctrl_mapping_is_compound() for readability. drivers/media/usb/uvc/uvc_ctrl.c | 48 ++++++++++++++++++++++++++++++++ drivers/media/usb/uvc/uvc_v4l2.c | 6 +--- drivers/media/usb/uvc/uvcvideo.h | 2 ++ 3 files changed, 51 insertions(+), 5 deletions(-)
Comments
Hi Yunke, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on media-tree/master] [also build test WARNING on linus/master v6.1-rc2 next-20221025] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Yunke-Cao/media-Implement-UVC-v1-5-ROI/20221025-135821 base: git://linuxtv.org/media_tree.git master patch link: https://lore.kernel.org/r/20221025055528.1117251-3-yunkec%40google.com patch subject: [PATCH v9 02/11] media: uvcvideo: add uvc_ctrl_get_boundary for getting default value config: m68k-allyesconfig (attached as .config) compiler: m68k-linux-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/3a37413c0b49718560da555fa58b7278de10202d git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Yunke-Cao/media-Implement-UVC-v1-5-ROI/20221025-135821 git checkout 3a37413c0b49718560da555fa58b7278de10202d # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash drivers/media/usb/uvc/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): >> drivers/media/usb/uvc/uvc_ctrl.c:1752:5: warning: no previous prototype for '__uvc_ctrl_get_boundary_std' [-Wmissing-prototypes] 1752 | int __uvc_ctrl_get_boundary_std(struct uvc_video_chain *chain, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ vim +/__uvc_ctrl_get_boundary_std +1752 drivers/media/usb/uvc/uvc_ctrl.c 1751 > 1752 int __uvc_ctrl_get_boundary_std(struct uvc_video_chain *chain, 1753 struct uvc_control *ctrl, 1754 struct uvc_control_mapping *mapping, 1755 struct v4l2_ext_control *xctrl) 1756 { 1757 struct v4l2_queryctrl qc = { .id = xctrl->id }; 1758 1759 int ret = __uvc_query_v4l2_ctrl(chain, ctrl, mapping, &qc); 1760 1761 if (ret < 0) 1762 return ret; 1763 1764 xctrl->value = qc.default_value; 1765 return 0; 1766 } 1767
On (22/10/25 14:55), Yunke Cao wrote: > > +int __uvc_ctrl_get_boundary_std(struct uvc_video_chain *chain, > + struct uvc_control *ctrl, > + struct uvc_control_mapping *mapping, > + struct v4l2_ext_control *xctrl) This should be static, as far as I can tell.
On Tue, Oct 25, 2022 at 6:58 PM Sergey Senozhatsky <senozhatsky@chromium.org> wrote: > > On (22/10/25 14:55), Yunke Cao wrote: > > > > +int __uvc_ctrl_get_boundary_std(struct uvc_video_chain *chain, > > + struct uvc_control *ctrl, > > + struct uvc_control_mapping *mapping, > > + struct v4l2_ext_control *xctrl) > > This should be static, as far as I can tell. Ah, thanks!
Hi Yunke, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on media-tree/master] [also build test WARNING on linus/master v6.1-rc2 next-20221025] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Yunke-Cao/media-Implement-UVC-v1-5-ROI/20221025-135821 base: git://linuxtv.org/media_tree.git master patch link: https://lore.kernel.org/r/20221025055528.1117251-3-yunkec%40google.com patch subject: [PATCH v9 02/11] media: uvcvideo: add uvc_ctrl_get_boundary for getting default value config: riscv-randconfig-r042-20221025 (attached as .config) compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 791a7ae1ba3efd6bca96338e10ffde557ba83920) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install riscv cross compiling tool for clang build # apt-get install binutils-riscv64-linux-gnu # https://github.com/intel-lab-lkp/linux/commit/3a37413c0b49718560da555fa58b7278de10202d git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Yunke-Cao/media-Implement-UVC-v1-5-ROI/20221025-135821 git checkout 3a37413c0b49718560da555fa58b7278de10202d # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash drivers/media/usb/uvc/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): ~~~~~~~~~~ ^ include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:743:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] insb(addr, buffer, count); ^~~~~~~~~~~~~~~~~~~~~~~~~ arch/riscv/include/asm/io.h:104:53: note: expanded from macro 'insb' #define insb(addr, buffer, count) __insb(PCI_IOBASE + (addr), buffer, count) ~~~~~~~~~~ ^ In file included from drivers/media/usb/uvc/uvc_ctrl.c:14: In file included from include/linux/usb.h:16: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:11: In file included from ./arch/riscv/include/generated/asm/hardirq.h:1: In file included from include/asm-generic/hardirq.h:17: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/riscv/include/asm/io.h:136: include/asm-generic/io.h:751:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] insw(addr, buffer, count); ^~~~~~~~~~~~~~~~~~~~~~~~~ arch/riscv/include/asm/io.h:105:53: note: expanded from macro 'insw' #define insw(addr, buffer, count) __insw(PCI_IOBASE + (addr), buffer, count) ~~~~~~~~~~ ^ In file included from drivers/media/usb/uvc/uvc_ctrl.c:14: In file included from include/linux/usb.h:16: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:11: In file included from ./arch/riscv/include/generated/asm/hardirq.h:1: In file included from include/asm-generic/hardirq.h:17: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/riscv/include/asm/io.h:136: include/asm-generic/io.h:759:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] insl(addr, buffer, count); ^~~~~~~~~~~~~~~~~~~~~~~~~ arch/riscv/include/asm/io.h:106:53: note: expanded from macro 'insl' #define insl(addr, buffer, count) __insl(PCI_IOBASE + (addr), buffer, count) ~~~~~~~~~~ ^ In file included from drivers/media/usb/uvc/uvc_ctrl.c:14: In file included from include/linux/usb.h:16: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:11: In file included from ./arch/riscv/include/generated/asm/hardirq.h:1: In file included from include/asm-generic/hardirq.h:17: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/riscv/include/asm/io.h:136: include/asm-generic/io.h:768:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] outsb(addr, buffer, count); ^~~~~~~~~~~~~~~~~~~~~~~~~~ arch/riscv/include/asm/io.h:118:55: note: expanded from macro 'outsb' #define outsb(addr, buffer, count) __outsb(PCI_IOBASE + (addr), buffer, count) ~~~~~~~~~~ ^ In file included from drivers/media/usb/uvc/uvc_ctrl.c:14: In file included from include/linux/usb.h:16: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:11: In file included from ./arch/riscv/include/generated/asm/hardirq.h:1: In file included from include/asm-generic/hardirq.h:17: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/riscv/include/asm/io.h:136: include/asm-generic/io.h:777:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] outsw(addr, buffer, count); ^~~~~~~~~~~~~~~~~~~~~~~~~~ arch/riscv/include/asm/io.h:119:55: note: expanded from macro 'outsw' #define outsw(addr, buffer, count) __outsw(PCI_IOBASE + (addr), buffer, count) ~~~~~~~~~~ ^ In file included from drivers/media/usb/uvc/uvc_ctrl.c:14: In file included from include/linux/usb.h:16: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:11: In file included from ./arch/riscv/include/generated/asm/hardirq.h:1: In file included from include/asm-generic/hardirq.h:17: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/riscv/include/asm/io.h:136: include/asm-generic/io.h:786:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] outsl(addr, buffer, count); ^~~~~~~~~~~~~~~~~~~~~~~~~~ arch/riscv/include/asm/io.h:120:55: note: expanded from macro 'outsl' #define outsl(addr, buffer, count) __outsl(PCI_IOBASE + (addr), buffer, count) ~~~~~~~~~~ ^ In file included from drivers/media/usb/uvc/uvc_ctrl.c:14: In file included from include/linux/usb.h:16: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:11: In file included from ./arch/riscv/include/generated/asm/hardirq.h:1: In file included from include/asm-generic/hardirq.h:17: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/riscv/include/asm/io.h:136: include/asm-generic/io.h:1134:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port; ~~~~~~~~~~ ^ >> drivers/media/usb/uvc/uvc_ctrl.c:1752:5: warning: no previous prototype for function '__uvc_ctrl_get_boundary_std' [-Wmissing-prototypes] int __uvc_ctrl_get_boundary_std(struct uvc_video_chain *chain, ^ drivers/media/usb/uvc/uvc_ctrl.c:1752:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int __uvc_ctrl_get_boundary_std(struct uvc_video_chain *chain, ^ static 14 warnings generated. vim +/__uvc_ctrl_get_boundary_std +1752 drivers/media/usb/uvc/uvc_ctrl.c 1751 > 1752 int __uvc_ctrl_get_boundary_std(struct uvc_video_chain *chain, 1753 struct uvc_control *ctrl, 1754 struct uvc_control_mapping *mapping, 1755 struct v4l2_ext_control *xctrl) 1756 { 1757 struct v4l2_queryctrl qc = { .id = xctrl->id }; 1758 1759 int ret = __uvc_query_v4l2_ctrl(chain, ctrl, mapping, &qc); 1760 1761 if (ret < 0) 1762 return ret; 1763 1764 xctrl->value = qc.default_value; 1765 return 0; 1766 } 1767
Hi Yunke,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on media-tree/master]
[also build test WARNING on linus/master v6.1-rc2 next-20221025]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Yunke-Cao/media-Implement-UVC-v1-5-ROI/20221025-135821
base: git://linuxtv.org/media_tree.git master
patch link: https://lore.kernel.org/r/20221025055528.1117251-3-yunkec%40google.com
patch subject: [PATCH v9 02/11] media: uvcvideo: add uvc_ctrl_get_boundary for getting default value
config: i386-randconfig-s003 (attached as .config)
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://github.com/intel-lab-lkp/linux/commit/3a37413c0b49718560da555fa58b7278de10202d
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Yunke-Cao/media-Implement-UVC-v1-5-ROI/20221025-135821
git checkout 3a37413c0b49718560da555fa58b7278de10202d
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 SHELL=/bin/bash drivers/media/usb/uvc/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
>> drivers/media/usb/uvc/uvc_ctrl.c:1752:5: sparse: sparse: symbol '__uvc_ctrl_get_boundary_std' was not declared. Should it be static?
diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index c95a2229f4fa..6997e7466a2b 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -837,6 +837,12 @@ static void uvc_set_le_value(struct uvc_control_mapping *mapping, } } +static bool +uvc_ctrl_mapping_is_compound(const struct uvc_control_mapping *mapping) +{ + return mapping->v4l2_type >= V4L2_CTRL_COMPOUND_TYPES; +} + /* ------------------------------------------------------------------------ * Terminal and unit management */ @@ -1743,6 +1749,48 @@ int uvc_ctrl_get(struct uvc_video_chain *chain, return __uvc_ctrl_get(chain, ctrl, mapping, &xctrl->value); } +int __uvc_ctrl_get_boundary_std(struct uvc_video_chain *chain, + struct uvc_control *ctrl, + struct uvc_control_mapping *mapping, + struct v4l2_ext_control *xctrl) +{ + struct v4l2_queryctrl qc = { .id = xctrl->id }; + + int ret = __uvc_query_v4l2_ctrl(chain, ctrl, mapping, &qc); + + if (ret < 0) + return ret; + + xctrl->value = qc.default_value; + return 0; +} + +int uvc_ctrl_get_boundary(struct uvc_video_chain *chain, + struct v4l2_ext_control *xctrl) +{ + struct uvc_control *ctrl; + struct uvc_control_mapping *mapping; + int ret; + + if (mutex_lock_interruptible(&chain->ctrl_mutex)) + return -ERESTARTSYS; + + ctrl = uvc_find_control(chain, xctrl->id, &mapping); + if (!ctrl) { + ret = -EINVAL; + goto done; + } + + if (uvc_ctrl_mapping_is_compound(mapping)) + ret = -EINVAL; + else + ret = __uvc_ctrl_get_boundary_std(chain, ctrl, mapping, xctrl); + +done: + mutex_unlock(&chain->ctrl_mutex); + return ret; +} + int uvc_ctrl_set(struct uvc_fh *handle, struct v4l2_ext_control *xctrl) { diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index f4d4c33b6dfb..e807e348aa41 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c @@ -1046,15 +1046,11 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file, void *fh, if (ctrls->which == V4L2_CTRL_WHICH_DEF_VAL) { for (i = 0; i < ctrls->count; ++ctrl, ++i) { - struct v4l2_queryctrl qc = { .id = ctrl->id }; - - ret = uvc_query_v4l2_ctrl(chain, &qc); + ret = uvc_ctrl_get_boundary(chain, ctrl); if (ret < 0) { ctrls->error_idx = i; return ret; } - - ctrl->value = qc.default_value; } return 0; diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index df93db259312..b2ee3d59a4c8 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -759,6 +759,8 @@ static inline int uvc_ctrl_rollback(struct uvc_fh *handle) } int uvc_ctrl_get(struct uvc_video_chain *chain, struct v4l2_ext_control *xctrl); +int uvc_ctrl_get_boundary(struct uvc_video_chain *chain, + struct v4l2_ext_control *xctrl); int uvc_ctrl_set(struct uvc_fh *handle, struct v4l2_ext_control *xctrl); int uvc_ctrl_is_accessible(struct uvc_video_chain *chain, u32 v4l2_id, bool read);