[{"id":4474,"web_url":"https://patchwork.libcamera.org/comment/4474/","msgid":"<202004211204.i8UsTCQo%lkp@intel.com>","date":"2020-04-21T04:58:22","subject":"Re: [libcamera-devel] [PATCH v4 4/5] v4l2-subdev: add\n\tVIDIOC_SUBDEV_QUERYCAP ioctl","submitter":{"id":45,"url":"https://patchwork.libcamera.org/api/people/45/","name":"kernel test robot","email":"lkp@intel.com"},"content":"Hi Jacopo,\n\nI love your patch! Yet something to improve:\n\n[auto build test ERROR on linuxtv-media/master]\n[also build test ERROR on linus/master v5.7-rc2 next-20200420]\n[if your patch is applied to the wrong git tree, please drop us a note to help\nimprove the system. BTW, we also suggest to use '--base' option to specify the\nbase tree in git format-patch, please see https://stackoverflow.com/a/37406982]\n\nurl:    https://github.com/0day-ci/linux/commits/Jacopo-Mondi/media-Register-read-only-sub-dev-devnode/20200421-053419\nbase:   git://linuxtv.org/media_tree.git master\nconfig: arm-bcm2835_defconfig (attached as .config)\ncompiler: clang version 11.0.0 (https://github.com/llvm/llvm-project a9b137f9ffba8cb25dfd7dd1fb613e8aac121b37)\nreproduce:\n        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross\n        chmod +x ~/bin/make.cross\n        # install arm cross compiling tool for clang build\n        # apt-get install binutils-arm-linux-gnueabi\n        # save the attached .config to linux build tree\n        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm \n\nIf you fix the issue, kindly add following tag as appropriate\nReported-by: kbuild test robot <lkp@intel.com>\n\nAll errors (new ones prefixed by >>):\n\n>> drivers/media/v4l2-core/v4l2-subdev.c:345:23: error: use of undeclared identifier 'ro_subdev'\n                   cap->subdev_caps |= ro_subdev ? V4L2_SUBDEV_CAP_RO_SUBDEV\n                                       ^\n   1 error generated.\n\nvim +/ro_subdev +345 drivers/media/v4l2-core/v4l2-subdev.c\n\n   327\t\n   328\tstatic long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)\n   329\t{\n   330\t\tstruct video_device *vdev = video_devdata(file);\n   331\t\tstruct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);\n   332\t\tstruct v4l2_fh *vfh = file->private_data;\n   333\t#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)\n   334\t\tstruct v4l2_subdev_fh *subdev_fh = to_v4l2_subdev_fh(vfh);\n   335\t\tbool ro_subdev = test_bit(V4L2_FL_SUBDEV_RO_DEVNODE, &vdev->flags);\n   336\t#endif\n   337\t\tint rval;\n   338\t\n   339\t\tswitch (cmd) {\n   340\t\tcase VIDIOC_SUBDEV_QUERYCAP: {\n   341\t\t\tstruct v4l2_subdev_capability *cap = arg;\n   342\t\n   343\t\t\tmemset(cap, 0, sizeof(*cap));\n   344\t\t\tcap->version = LINUX_VERSION_CODE;\n > 345\t\t\tcap->subdev_caps |= ro_subdev ? V4L2_SUBDEV_CAP_RO_SUBDEV\n   346\t\t\t\t\t\t      : V4L2_SUBDEV_CAP_RW_SUBDEV;\n   347\t\n   348\t\t\treturn 0;\n   349\t\t}\n   350\t\n   351\t\tcase VIDIOC_QUERYCTRL:\n   352\t\t\t/*\n   353\t\t\t * TODO: this really should be folded into v4l2_queryctrl (this\n   354\t\t\t * currently returns -EINVAL for NULL control handlers).\n   355\t\t\t * However, v4l2_queryctrl() is still called directly by\n   356\t\t\t * drivers as well and until that has been addressed I believe\n   357\t\t\t * it is safer to do the check here. The same is true for the\n   358\t\t\t * other control ioctls below.\n   359\t\t\t */\n   360\t\t\tif (!vfh->ctrl_handler)\n   361\t\t\t\treturn -ENOTTY;\n   362\t\t\treturn v4l2_queryctrl(vfh->ctrl_handler, arg);\n   363\t\n   364\t\tcase VIDIOC_QUERY_EXT_CTRL:\n   365\t\t\tif (!vfh->ctrl_handler)\n   366\t\t\t\treturn -ENOTTY;\n   367\t\t\treturn v4l2_query_ext_ctrl(vfh->ctrl_handler, arg);\n   368\t\n   369\t\tcase VIDIOC_QUERYMENU:\n   370\t\t\tif (!vfh->ctrl_handler)\n   371\t\t\t\treturn -ENOTTY;\n   372\t\t\treturn v4l2_querymenu(vfh->ctrl_handler, arg);\n   373\t\n   374\t\tcase VIDIOC_G_CTRL:\n   375\t\t\tif (!vfh->ctrl_handler)\n   376\t\t\t\treturn -ENOTTY;\n   377\t\t\treturn v4l2_g_ctrl(vfh->ctrl_handler, arg);\n   378\t\n   379\t\tcase VIDIOC_S_CTRL:\n   380\t\t\tif (!vfh->ctrl_handler)\n   381\t\t\t\treturn -ENOTTY;\n   382\t\t\treturn v4l2_s_ctrl(vfh, vfh->ctrl_handler, arg);\n   383\t\n   384\t\tcase VIDIOC_G_EXT_CTRLS:\n   385\t\t\tif (!vfh->ctrl_handler)\n   386\t\t\t\treturn -ENOTTY;\n   387\t\t\treturn v4l2_g_ext_ctrls(vfh->ctrl_handler,\n   388\t\t\t\t\t\tvdev, sd->v4l2_dev->mdev, arg);\n   389\t\n   390\t\tcase VIDIOC_S_EXT_CTRLS:\n   391\t\t\tif (!vfh->ctrl_handler)\n   392\t\t\t\treturn -ENOTTY;\n   393\t\t\treturn v4l2_s_ext_ctrls(vfh, vfh->ctrl_handler,\n   394\t\t\t\t\t\tvdev, sd->v4l2_dev->mdev, arg);\n   395\t\n   396\t\tcase VIDIOC_TRY_EXT_CTRLS:\n   397\t\t\tif (!vfh->ctrl_handler)\n   398\t\t\t\treturn -ENOTTY;\n   399\t\t\treturn v4l2_try_ext_ctrls(vfh->ctrl_handler,\n   400\t\t\t\t\t\t  vdev, sd->v4l2_dev->mdev, arg);\n   401\t\n   402\t\tcase VIDIOC_DQEVENT:\n   403\t\t\tif (!(sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS))\n   404\t\t\t\treturn -ENOIOCTLCMD;\n   405\t\n   406\t\t\treturn v4l2_event_dequeue(vfh, arg, file->f_flags & O_NONBLOCK);\n   407\t\n   408\t\tcase VIDIOC_DQEVENT_TIME32: {\n   409\t\t\tstruct v4l2_event_time32 *ev32 = arg;\n   410\t\t\tstruct v4l2_event ev = { };\n   411\t\n   412\t\t\tif (!(sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS))\n   413\t\t\t\treturn -ENOIOCTLCMD;\n   414\t\n   415\t\t\trval = v4l2_event_dequeue(vfh, &ev, file->f_flags & O_NONBLOCK);\n   416\t\n   417\t\t\t*ev32 = (struct v4l2_event_time32) {\n   418\t\t\t\t.type\t\t= ev.type,\n   419\t\t\t\t.pending\t= ev.pending,\n   420\t\t\t\t.sequence\t= ev.sequence,\n   421\t\t\t\t.timestamp.tv_sec  = ev.timestamp.tv_sec,\n   422\t\t\t\t.timestamp.tv_nsec = ev.timestamp.tv_nsec,\n   423\t\t\t\t.id\t\t= ev.id,\n   424\t\t\t};\n   425\t\n   426\t\t\tmemcpy(&ev32->u, &ev.u, sizeof(ev.u));\n   427\t\t\tmemcpy(&ev32->reserved, &ev.reserved, sizeof(ev.reserved));\n   428\t\n   429\t\t\treturn rval;\n   430\t\t}\n   431\t\n   432\t\tcase VIDIOC_SUBSCRIBE_EVENT:\n   433\t\t\treturn v4l2_subdev_call(sd, core, subscribe_event, vfh, arg);\n   434\t\n   435\t\tcase VIDIOC_UNSUBSCRIBE_EVENT:\n   436\t\t\treturn v4l2_subdev_call(sd, core, unsubscribe_event, vfh, arg);\n   437\t\n\n---\n0-DAY CI Kernel Test Service, Intel Corporation\nhttps://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org","headers":{"Return-Path":"<lkp@intel.com>","Received":["from mga04.intel.com (mga04.intel.com [192.55.52.120])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 40A29603FC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 21 Apr 2020 06:58:38 +0200 (CEST)","from orsmga008.jf.intel.com ([10.7.209.65])\n\tby fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; \n\t20 Apr 2020 21:58:33 -0700","from lkp-server01.sh.intel.com (HELO lkp-server01)\n\t([10.239.97.150])\n\tby orsmga008.jf.intel.com with ESMTP; 20 Apr 2020 21:58:29 -0700","from kbuild by lkp-server01 with local (Exim 4.89)\n\t(envelope-from <lkp@intel.com>)\n\tid 1jQkzM-000C4M-OU; Tue, 21 Apr 2020 12:58:28 +0800"],"IronPort-SDR":["mFEpQifMWInKxJt3UYIaM/EVx2NqNAo5n6GiOgnNw+UCwgoZGQGCsWM/tFfKxCAfynrmtEtJF2\n\t7WPGk9nhZi5Q==","7owsC65rb0MC5ZsnXQB0rPCaUr2gzrX4QetXs6+jMxDUT2xekTV2DQY+wAvKk44v4BC+AJCIVJ\n\tk+y58zzxpuaw=="],"X-Amp-Result":"UNKNOWN","X-Amp-Original-Verdict":"FILE UNKNOWN","X-Amp-File-Uploaded":"False","X-ExtLoop1":"1","X-IronPort-AV":"E=Sophos;i=\"5.72,409,1580803200\"; \n\td=\"gz'50?scan'50,208,50\";a=\"291482792\"","Date":"Tue, 21 Apr 2020 12:58:22 +0800","From":"kbuild test robot <lkp@intel.com>","To":"Jacopo Mondi <jacopo@jmondi.org>, linux-media@vger.kernel.org,\n\tlibcamera-devel@lists.libcamera.org","Cc":"kbuild-all@lists.01.org, clang-built-linux@googlegroups.com,\n\tJacopo Mondi <jacopo@jmondi.org>, mchehab@kernel.org,\n\thverkuil-cisco@xs4all.nl, sakari.ailus@linux.intel.com,\n\tandrey.konovalov@linaro.org, laurent.pinchart@ideasonboard.com,\n\tHans Verkuil <hverkuil@xs4all.nl>","Message-ID":"<202004211204.i8UsTCQo%lkp@intel.com>","References":"<20200418103216.140572-5-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"multipart/mixed; boundary=\"ZPt4rx8FFjLCG7dd\"","Content-Disposition":"inline","In-Reply-To":"<20200418103216.140572-5-jacopo@jmondi.org>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v4 4/5] v4l2-subdev: add\n\tVIDIOC_SUBDEV_QUERYCAP ioctl","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Tue, 21 Apr 2020 04:58:40 -0000"}},{"id":4484,"web_url":"https://patchwork.libcamera.org/comment/4484/","msgid":"<20200421214958.GD5381@paasikivi.fi.intel.com>","date":"2020-04-21T21:49:58","subject":"Re: [libcamera-devel] [PATCH v4 4/5] v4l2-subdev: add\n\tVIDIOC_SUBDEV_QUERYCAP ioctl","submitter":{"id":37,"url":"https://patchwork.libcamera.org/api/people/37/","name":"Sakari Ailus","email":"sakari.ailus@linux.intel.com"},"content":"Hi Jacopo,\n\nThanks for the patch.\n\nOn Sat, Apr 18, 2020 at 12:32:15PM +0200, Jacopo Mondi wrote:\n> From: Hans Verkuil <hans.verkuil@cisco.com>\n> \n> While normal video/radio/vbi/swradio nodes have a proper QUERYCAP ioctl\n> that apps can call to determine that it is indeed a V4L2 device, there\n> is currently no equivalent for v4l-subdev nodes. Adding this ioctl will\n> solve that, and it will allow utilities like v4l2-compliance to be used\n> with these devices as well.\n> \n> SUBDEV_QUERYCAP currently returns the version and subdev_caps of the\n> subdevice. Define as the initial set of subdev_caps the read-only or\n> read/write flags, to signal to userspace which set of IOCTLs are\n> available on the subdevice.\n> \n> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>\n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  drivers/media/v4l2-core/v4l2-subdev.c | 12 ++++++++++++\n>  include/uapi/linux/v4l2-subdev.h      | 15 +++++++++++++++\n>  2 files changed, 27 insertions(+)\n> \n> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c\n> index 1dc263c2ca0a..ca0aa54429c5 100644\n> --- a/drivers/media/v4l2-core/v4l2-subdev.c\n> +++ b/drivers/media/v4l2-core/v4l2-subdev.c\n> @@ -15,6 +15,7 @@\n>  #include <linux/types.h>\n>  #include <linux/videodev2.h>\n>  #include <linux/export.h>\n> +#include <linux/version.h>\n>  \n>  #include <media/v4l2-ctrls.h>\n>  #include <media/v4l2-device.h>\n> @@ -336,6 +337,17 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)\n>  \tint rval;\n>  \n>  \tswitch (cmd) {\n> +\tcase VIDIOC_SUBDEV_QUERYCAP: {\n> +\t\tstruct v4l2_subdev_capability *cap = arg;\n> +\n> +\t\tmemset(cap, 0, sizeof(*cap));\n> +\t\tcap->version = LINUX_VERSION_CODE;\n> +\t\tcap->subdev_caps |= ro_subdev ? V4L2_SUBDEV_CAP_RO_SUBDEV\n> +\t\t\t\t\t      : V4L2_SUBDEV_CAP_RW_SUBDEV;\n> +\n> +\t\treturn 0;\n> +\t}\n> +\n>  \tcase VIDIOC_QUERYCTRL:\n>  \t\t/*\n>  \t\t * TODO: this really should be folded into v4l2_queryctrl (this\n> diff --git a/include/uapi/linux/v4l2-subdev.h b/include/uapi/linux/v4l2-subdev.h\n> index 03970ce30741..0886f88be193 100644\n> --- a/include/uapi/linux/v4l2-subdev.h\n> +++ b/include/uapi/linux/v4l2-subdev.h\n> @@ -155,9 +155,24 @@ struct v4l2_subdev_selection {\n>  \t__u32 reserved[8];\n>  };\n>  \n> +/**\n> + * struct v4l2_subdev_capability - subdev capabilities\n> + * @device_caps: the subdev capabilities, see V4L2_SUBDEV_CAP_*.\n> + */\n> +struct v4l2_subdev_capability {\n> +\t__u32 version;\n> +\t__u32 subdev_caps;\n\nNo reserved fields? Is the intent to extend this later on based on the size\nof the IOCTL argument?\n\n> +};\n> +\n> +/* The v4l2 sub-device video device node is registered in read-only mode. */\n> +#define V4L2_SUBDEV_CAP_RO_SUBDEV\t\t(1 << 0)\n\n1U << 0\n\n> +/* The v4l2 sub-device video device node is registered in read/write mode. */\n> +#define V4L2_SUBDEV_CAP_RW_SUBDEV\t\t(1 << 1)\n\n1U << 1\n\n> +\n>  /* Backwards compatibility define --- to be removed */\n>  #define v4l2_subdev_edid v4l2_edid\n>  \n> +#define VIDIOC_SUBDEV_QUERYCAP\t\t\t_IOR('V',  0, struct v4l2_subdev_capability)\n>  #define VIDIOC_SUBDEV_G_FMT\t\t\t_IOWR('V',  4, struct v4l2_subdev_format)\n>  #define VIDIOC_SUBDEV_S_FMT\t\t\t_IOWR('V',  5, struct v4l2_subdev_format)\n>  #define VIDIOC_SUBDEV_G_FRAME_INTERVAL\t\t_IOWR('V', 21, struct v4l2_subdev_frame_interval)","headers":{"Return-Path":"<sakari.ailus@linux.intel.com>","Received":["from mga07.intel.com (mga07.intel.com [134.134.136.100])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C347460406\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 21 Apr 2020 23:50:04 +0200 (CEST)","from orsmga004.jf.intel.com ([10.7.209.38])\n\tby orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; \n\t21 Apr 2020 14:50:02 -0700","from paasikivi.fi.intel.com ([10.237.72.42])\n\tby orsmga004-auth.jf.intel.com with\n\tESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Apr 2020 14:50:00 -0700","by paasikivi.fi.intel.com (Postfix, from userid 1000)\n\tid A11AF204D0; Wed, 22 Apr 2020 00:49:58 +0300 (EEST)"],"IronPort-SDR":["zXzF5hrKnkJ49b/dHnZ/ilfIUOyUlr+bbFWlyTZAHr8tZWxUK+hzS41gQSX4UPaxWz0OVSYGWW\n\tB8OPlW80euyg==","z1UETDf5I2yEaDNWyhkFj4ZOg0jbAul3v7gyMa3Dg4yr7Re6po1veZEvaJrbFd8psSPyr5IlzY\n\tuJCEP6NmOnag=="],"X-Amp-Result":"SKIPPED(no attachment in message)","X-Amp-File-Uploaded":"False","X-IronPort-AV":"E=Sophos;i=\"5.72,411,1580803200\"; d=\"scan'208\";a=\"402325444\"","Date":"Wed, 22 Apr 2020 00:49:58 +0300","From":"Sakari Ailus <sakari.ailus@linux.intel.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"linux-media@vger.kernel.org, libcamera-devel@lists.libcamera.org,\n\tmchehab@kernel.org, hverkuil-cisco@xs4all.nl,\n\tandrey.konovalov@linaro.org, laurent.pinchart@ideasonboard.com,\n\tHans Verkuil <hans.verkuil@cisco.com>","Message-ID":"<20200421214958.GD5381@paasikivi.fi.intel.com>","References":"<20200418103216.140572-1-jacopo@jmondi.org>\n\t<20200418103216.140572-5-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20200418103216.140572-5-jacopo@jmondi.org>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v4 4/5] v4l2-subdev: add\n\tVIDIOC_SUBDEV_QUERYCAP ioctl","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Tue, 21 Apr 2020 21:50:05 -0000"}},{"id":4486,"web_url":"https://patchwork.libcamera.org/comment/4486/","msgid":"<20200421234232.GI5983@pendragon.ideasonboard.com>","date":"2020-04-21T23:42:32","subject":"Re: [libcamera-devel] [PATCH v4 4/5] v4l2-subdev: add\n\tVIDIOC_SUBDEV_QUERYCAP ioctl","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Sakari,\n\nOn Wed, Apr 22, 2020 at 12:49:58AM +0300, Sakari Ailus wrote:\n> On Sat, Apr 18, 2020 at 12:32:15PM +0200, Jacopo Mondi wrote:\n> > From: Hans Verkuil <hans.verkuil@cisco.com>\n> > \n> > While normal video/radio/vbi/swradio nodes have a proper QUERYCAP ioctl\n> > that apps can call to determine that it is indeed a V4L2 device, there\n> > is currently no equivalent for v4l-subdev nodes. Adding this ioctl will\n> > solve that, and it will allow utilities like v4l2-compliance to be used\n> > with these devices as well.\n> > \n> > SUBDEV_QUERYCAP currently returns the version and subdev_caps of the\n> > subdevice. Define as the initial set of subdev_caps the read-only or\n> > read/write flags, to signal to userspace which set of IOCTLs are\n> > available on the subdevice.\n> > \n> > Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>\n> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > ---\n> >  drivers/media/v4l2-core/v4l2-subdev.c | 12 ++++++++++++\n> >  include/uapi/linux/v4l2-subdev.h      | 15 +++++++++++++++\n> >  2 files changed, 27 insertions(+)\n> > \n> > diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c\n> > index 1dc263c2ca0a..ca0aa54429c5 100644\n> > --- a/drivers/media/v4l2-core/v4l2-subdev.c\n> > +++ b/drivers/media/v4l2-core/v4l2-subdev.c\n> > @@ -15,6 +15,7 @@\n> >  #include <linux/types.h>\n> >  #include <linux/videodev2.h>\n> >  #include <linux/export.h>\n> > +#include <linux/version.h>\n> >  \n> >  #include <media/v4l2-ctrls.h>\n> >  #include <media/v4l2-device.h>\n> > @@ -336,6 +337,17 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)\n> >  \tint rval;\n> >  \n> >  \tswitch (cmd) {\n> > +\tcase VIDIOC_SUBDEV_QUERYCAP: {\n> > +\t\tstruct v4l2_subdev_capability *cap = arg;\n> > +\n> > +\t\tmemset(cap, 0, sizeof(*cap));\n> > +\t\tcap->version = LINUX_VERSION_CODE;\n> > +\t\tcap->subdev_caps |= ro_subdev ? V4L2_SUBDEV_CAP_RO_SUBDEV\n> > +\t\t\t\t\t      : V4L2_SUBDEV_CAP_RW_SUBDEV;\n> > +\n> > +\t\treturn 0;\n> > +\t}\n> > +\n> >  \tcase VIDIOC_QUERYCTRL:\n> >  \t\t/*\n> >  \t\t * TODO: this really should be folded into v4l2_queryctrl (this\n> > diff --git a/include/uapi/linux/v4l2-subdev.h b/include/uapi/linux/v4l2-subdev.h\n> > index 03970ce30741..0886f88be193 100644\n> > --- a/include/uapi/linux/v4l2-subdev.h\n> > +++ b/include/uapi/linux/v4l2-subdev.h\n> > @@ -155,9 +155,24 @@ struct v4l2_subdev_selection {\n> >  \t__u32 reserved[8];\n> >  };\n> >  \n> > +/**\n> > + * struct v4l2_subdev_capability - subdev capabilities\n> > + * @device_caps: the subdev capabilities, see V4L2_SUBDEV_CAP_*.\n> > + */\n> > +struct v4l2_subdev_capability {\n> > +\t__u32 version;\n> > +\t__u32 subdev_caps;\n> \n> No reserved fields? Is the intent to extend this later on based on the size\n> of the IOCTL argument?\n\nThat would be my preferred option.\n\n> > +};\n> > +\n> > +/* The v4l2 sub-device video device node is registered in read-only mode. */\n> > +#define V4L2_SUBDEV_CAP_RO_SUBDEV\t\t(1 << 0)\n> \n> 1U << 0\n\nBIT(0)\n\n> \n> > +/* The v4l2 sub-device video device node is registered in read/write mode. */\n> > +#define V4L2_SUBDEV_CAP_RW_SUBDEV\t\t(1 << 1)\n> \n> 1U << 1\n\nBIT(1)\n\n> > +\n> >  /* Backwards compatibility define --- to be removed */\n> >  #define v4l2_subdev_edid v4l2_edid\n> >  \n> > +#define VIDIOC_SUBDEV_QUERYCAP\t\t\t_IOR('V',  0, struct v4l2_subdev_capability)\n> >  #define VIDIOC_SUBDEV_G_FMT\t\t\t_IOWR('V',  4, struct v4l2_subdev_format)\n> >  #define VIDIOC_SUBDEV_S_FMT\t\t\t_IOWR('V',  5, struct v4l2_subdev_format)\n> >  #define VIDIOC_SUBDEV_G_FRAME_INTERVAL\t\t_IOWR('V', 21, struct v4l2_subdev_frame_interval)","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CB21362E55\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Apr 2020 01:42:47 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E9516528;\n\tWed, 22 Apr 2020 01:42:46 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"hb8KprDt\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1587512567;\n\tbh=24GSLSwcx7mBs0pvWOGY5eUgfCS4JvoAB/r4rouU9R8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=hb8KprDt7MA9HXoQ/fWMElE+CTco+coA7bu7hO0e/3rdM6OeSv8QkH4/QgbDU5qMF\n\tknOeL5CC7gSzQGIwcAtZG7nELZADDwOftDYLkvp0Xs6KVDt/KeO0i34p6AZjtlnE/X\n\tY/qKrnpt5UeAcoxBpXiYUJm2WaDX0UX0sTGYL7i8=","Date":"Wed, 22 Apr 2020 02:42:32 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Sakari Ailus <sakari.ailus@linux.intel.com>","Cc":"Jacopo Mondi <jacopo@jmondi.org>, linux-media@vger.kernel.org,\n\tlibcamera-devel@lists.libcamera.org, mchehab@kernel.org,\n\thverkuil-cisco@xs4all.nl, andrey.konovalov@linaro.org,\n\tHans Verkuil <hans.verkuil@cisco.com>","Message-ID":"<20200421234232.GI5983@pendragon.ideasonboard.com>","References":"<20200418103216.140572-1-jacopo@jmondi.org>\n\t<20200418103216.140572-5-jacopo@jmondi.org>\n\t<20200421214958.GD5381@paasikivi.fi.intel.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20200421214958.GD5381@paasikivi.fi.intel.com>","Subject":"Re: [libcamera-devel] [PATCH v4 4/5] v4l2-subdev: add\n\tVIDIOC_SUBDEV_QUERYCAP ioctl","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Tue, 21 Apr 2020 23:42:48 -0000"}},{"id":4487,"web_url":"https://patchwork.libcamera.org/comment/4487/","msgid":"<20200422065746.wuaiv3tr7eqe6pwv@uno.localdomain>","date":"2020-04-22T06:57:46","subject":"Re: [libcamera-devel] [PATCH v4 4/5] v4l2-subdev: add\n\tVIDIOC_SUBDEV_QUERYCAP ioctl","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Sakari,\n\nOn Wed, Apr 22, 2020 at 02:42:32AM +0300, Laurent Pinchart wrote:\n> Hi Sakari,\n>\n> On Wed, Apr 22, 2020 at 12:49:58AM +0300, Sakari Ailus wrote:\n> > On Sat, Apr 18, 2020 at 12:32:15PM +0200, Jacopo Mondi wrote:\n> > > From: Hans Verkuil <hans.verkuil@cisco.com>\n> > >\n> > > While normal video/radio/vbi/swradio nodes have a proper QUERYCAP ioctl\n> > > that apps can call to determine that it is indeed a V4L2 device, there\n> > > is currently no equivalent for v4l-subdev nodes. Adding this ioctl will\n> > > solve that, and it will allow utilities like v4l2-compliance to be used\n> > > with these devices as well.\n> > >\n> > > SUBDEV_QUERYCAP currently returns the version and subdev_caps of the\n> > > subdevice. Define as the initial set of subdev_caps the read-only or\n> > > read/write flags, to signal to userspace which set of IOCTLs are\n> > > available on the subdevice.\n> > >\n> > > Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>\n> > > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > > ---\n> > >  drivers/media/v4l2-core/v4l2-subdev.c | 12 ++++++++++++\n> > >  include/uapi/linux/v4l2-subdev.h      | 15 +++++++++++++++\n> > >  2 files changed, 27 insertions(+)\n> > >\n> > > diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c\n> > > index 1dc263c2ca0a..ca0aa54429c5 100644\n> > > --- a/drivers/media/v4l2-core/v4l2-subdev.c\n> > > +++ b/drivers/media/v4l2-core/v4l2-subdev.c\n> > > @@ -15,6 +15,7 @@\n> > >  #include <linux/types.h>\n> > >  #include <linux/videodev2.h>\n> > >  #include <linux/export.h>\n> > > +#include <linux/version.h>\n> > >\n> > >  #include <media/v4l2-ctrls.h>\n> > >  #include <media/v4l2-device.h>\n> > > @@ -336,6 +337,17 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)\n> > >  \tint rval;\n> > >\n> > >  \tswitch (cmd) {\n> > > +\tcase VIDIOC_SUBDEV_QUERYCAP: {\n> > > +\t\tstruct v4l2_subdev_capability *cap = arg;\n> > > +\n> > > +\t\tmemset(cap, 0, sizeof(*cap));\n> > > +\t\tcap->version = LINUX_VERSION_CODE;\n> > > +\t\tcap->subdev_caps |= ro_subdev ? V4L2_SUBDEV_CAP_RO_SUBDEV\n> > > +\t\t\t\t\t      : V4L2_SUBDEV_CAP_RW_SUBDEV;\n> > > +\n> > > +\t\treturn 0;\n> > > +\t}\n> > > +\n> > >  \tcase VIDIOC_QUERYCTRL:\n> > >  \t\t/*\n> > >  \t\t * TODO: this really should be folded into v4l2_queryctrl (this\n> > > diff --git a/include/uapi/linux/v4l2-subdev.h b/include/uapi/linux/v4l2-subdev.h\n> > > index 03970ce30741..0886f88be193 100644\n> > > --- a/include/uapi/linux/v4l2-subdev.h\n> > > +++ b/include/uapi/linux/v4l2-subdev.h\n> > > @@ -155,9 +155,24 @@ struct v4l2_subdev_selection {\n> > >  \t__u32 reserved[8];\n> > >  };\n> > >\n> > > +/**\n> > > + * struct v4l2_subdev_capability - subdev capabilities\n> > > + * @device_caps: the subdev capabilities, see V4L2_SUBDEV_CAP_*.\n> > > + */\n> > > +struct v4l2_subdev_capability {\n> > > +\t__u32 version;\n> > > +\t__u32 subdev_caps;\n> >\n> > No reserved fields? Is the intent to extend this later on based on the size\n> > of the IOCTL argument?\n>\n> That would be my preferred option.\n>\n\nThat would be my preferred opinion as well, we would have versioning\nand would not be tied to the available reserved fields.","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net\n\t[217.70.183.201])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 130DC603FB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Apr 2020 08:54:43 +0200 (CEST)","from uno.localdomain\n\t(host240-55-dynamic.3-87-r.retail.telecomitalia.it [87.3.55.240])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 084E41BF204;\n\tWed, 22 Apr 2020 06:54:38 +0000 (UTC)"],"X-Originating-IP":"87.3.55.240","Date":"Wed, 22 Apr 2020 08:57:46 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"Sakari Ailus <sakari.ailus@linux.intel.com>,\n\tlinux-media@vger.kernel.org, libcamera-devel@lists.libcamera.org,\n\tmchehab@kernel.org, hverkuil-cisco@xs4all.nl,\n\tandrey.konovalov@linaro.org, Hans Verkuil <hans.verkuil@cisco.com>","Message-ID":"<20200422065746.wuaiv3tr7eqe6pwv@uno.localdomain>","References":"<20200418103216.140572-1-jacopo@jmondi.org>\n\t<20200418103216.140572-5-jacopo@jmondi.org>\n\t<20200421214958.GD5381@paasikivi.fi.intel.com>\n\t<20200421234232.GI5983@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20200421234232.GI5983@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v4 4/5] v4l2-subdev: add\n\tVIDIOC_SUBDEV_QUERYCAP ioctl","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Wed, 22 Apr 2020 06:54:43 -0000"}}]