[{"id":4415,"web_url":"https://patchwork.libcamera.org/comment/4415/","msgid":"<20200407233834.GE1716317@oden.dyn.berto.se>","date":"2020-04-07T23:38:34","subject":"Re: [libcamera-devel] [PATCH v4 05/11] libcamera: v4l2_videodevice:\n\tSupport filtering formats by media bus code","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your patch.\n\nOn 2020-04-04 03:44:32 +0300, Laurent Pinchart wrote:\n> Add support for the recent V4L2 extension to VIDIOC_ENUM_FMT that allows\n> filtering pixel formats by media bus codes.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nIs your intent to try and merge this ahead of V4L2_CAP_IO_MC upstream?  \nIf not I think we shall try and remember to update the commit message \nwith which kernel version is needed make use of this feature.\n\nProvided the patches on their way upstream stay the same,\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  src/libcamera/include/v4l2_videodevice.h |  4 ++--\n>  src/libcamera/v4l2_videodevice.cpp       | 16 +++++++++++++---\n>  2 files changed, 15 insertions(+), 5 deletions(-)\n> \n> diff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h\n> index 7d7c4a9e6ebd..7b011d3b4e87 100644\n> --- a/src/libcamera/include/v4l2_videodevice.h\n> +++ b/src/libcamera/include/v4l2_videodevice.h\n> @@ -207,7 +207,7 @@ public:\n>  \n>  \tint getFormat(V4L2DeviceFormat *format);\n>  \tint setFormat(V4L2DeviceFormat *format);\n> -\tstd::map<V4L2PixelFormat, std::vector<SizeRange>> formats();\n> +\tstd::map<V4L2PixelFormat, std::vector<SizeRange>> formats(uint32_t code = 0);\n>  \n>  \tint setCrop(Rectangle *rect);\n>  \tint setCompose(Rectangle *rect);\n> @@ -246,7 +246,7 @@ private:\n>  \tint getFormatSingleplane(V4L2DeviceFormat *format);\n>  \tint setFormatSingleplane(V4L2DeviceFormat *format);\n>  \n> -\tstd::vector<V4L2PixelFormat> enumPixelformats();\n> +\tstd::vector<V4L2PixelFormat> enumPixelformats(uint32_t code);\n>  \tstd::vector<SizeRange> enumSizes(V4L2PixelFormat pixelFormat);\n>  \n>  \tint setSelection(unsigned int target, Rectangle *rect);\n> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> index eb33a68e50d6..f7b98272d247 100644\n> --- a/src/libcamera/v4l2_videodevice.cpp\n> +++ b/src/libcamera/v4l2_videodevice.cpp\n> @@ -973,16 +973,19 @@ int V4L2VideoDevice::setFormatSingleplane(V4L2DeviceFormat *format)\n>  \n>  /**\n>   * \\brief Enumerate all pixel formats and frame sizes\n> + * \\param[in] code Restrict formats to this media bus code.\n>   *\n>   * Enumerate all pixel formats and frame sizes supported by the video device.\n> + * If the \\a code argument is not zero, only formats compatible with that media\n> + * bus code will be enumerated.\n>   *\n>   * \\return A list of the supported video device formats\n>   */\n> -std::map<V4L2PixelFormat, std::vector<SizeRange>> V4L2VideoDevice::formats()\n> +std::map<V4L2PixelFormat, std::vector<SizeRange>> V4L2VideoDevice::formats(uint32_t code)\n>  {\n>  \tstd::map<V4L2PixelFormat, std::vector<SizeRange>> formats;\n>  \n> -\tfor (V4L2PixelFormat pixelFormat : enumPixelformats()) {\n> +\tfor (V4L2PixelFormat pixelFormat : enumPixelformats(code)) {\n>  \t\tstd::vector<SizeRange> sizes = enumSizes(pixelFormat);\n>  \t\tif (sizes.empty())\n>  \t\t\treturn {};\n> @@ -1000,15 +1003,22 @@ std::map<V4L2PixelFormat, std::vector<SizeRange>> V4L2VideoDevice::formats()\n>  \treturn formats;\n>  }\n>  \n> -std::vector<V4L2PixelFormat> V4L2VideoDevice::enumPixelformats()\n> +std::vector<V4L2PixelFormat> V4L2VideoDevice::enumPixelformats(uint32_t code)\n>  {\n>  \tstd::vector<V4L2PixelFormat> formats;\n>  \tint ret;\n>  \n> +\tif (code && !(caps_.device_caps() & V4L2_CAP_IO_MC)) {\n> +\t\tLOG(V4L2, Error)\n> +\t\t\t<< \"Media bus code filtering not supported by the device\";\n> +\t\treturn {};\n> +\t}\n> +\n>  \tfor (unsigned int index = 0; ; index++) {\n>  \t\tstruct v4l2_fmtdesc pixelformatEnum = {};\n>  \t\tpixelformatEnum.index = index;\n>  \t\tpixelformatEnum.type = bufferType_;\n> +\t\tpixelformatEnum.mbus_code = code;\n>  \n>  \t\tret = ioctl(VIDIOC_ENUM_FMT, &pixelformatEnum);\n>  \t\tif (ret)\n> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lf1-x142.google.com (mail-lf1-x142.google.com\n\t[IPv6:2a00:1450:4864:20::142])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 46A47600F3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Apr 2020 01:38:36 +0200 (CEST)","by mail-lf1-x142.google.com with SMTP id k28so3714797lfe.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 07 Apr 2020 16:38:36 -0700 (PDT)","from localhost (h-200-138.A463.priv.bahnhof.se. [176.10.200.138])\n\tby smtp.gmail.com with ESMTPSA id\n\ta22sm12393450ljm.28.2020.04.07.16.38.34\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 07 Apr 2020 16:38:34 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com header.b=\"eWpxXkEk\"; \n\tdkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=PNR9NeLw5yhH7YgPhG1x/9r5vJmnDym8GDe05ra7uVE=;\n\tb=eWpxXkEkmR7xFEsCHcS6K4VrUdoaV1APmrX4gLToz1i30jwfygXEuJG5S5o/hCG9S9\n\tjqxJor/yulHTKnJ2SKy77vnaLIMrqgR96f+qpEdhjHoYXV6iBWHNX1DmfAK2NV62W//r\n\t5Fr0Q7P0ZsA1ltuIbwch/TQNqSVWrCWqL495d5Fh3kd/Q5Y5g9ftYgOqX3M0nQhVhubL\n\t3Hn86S+FX+BmBGo3QyiVBdHZJlu2e4R7s860eZ0l4YDOw6JWI61rxxnaj4QjklTUT45I\n\trabFvsL+CfSIMWKEcMqZ/icB/RNXi4k4qH3PJET8h+DJGiU/ss3jatS5CyPuGfwIL7nL\n\tuYjg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=PNR9NeLw5yhH7YgPhG1x/9r5vJmnDym8GDe05ra7uVE=;\n\tb=gL0B1G2kv524a5gE+aj+NoBtVV86nUhwf8KGHpncZ9gWg3skqY7wanH/GEjLeIYUdV\n\t3V0YbmIdR5WvJurtS4JOTmIZjeObhpFvA1xuXYwHa+DjSoPpLK+wGw54Nao1IBOb4oeR\n\tfvzxpwNQYfR3GUKDcFPdDrKCn2COYuce79qIcowBn1jfsPmelymnbV9TpwXFdpBhBI+R\n\t3D7SpiavN1CFQorgDc0jTo8uy00cZNdBkXJJcAfpi88wdZQKJZTDHf9q0JqqywZnS+pu\n\tHrutIOLN/Gy1h0Udm5P6pezjY5qAw+ZvpEkiEa5jYq+8+3eoNnCpjwDCxfgmBUa2xKwT\n\tTWYw==","X-Gm-Message-State":"AGi0PuYVd3Qid6Lc5HVWJqLJYsH22ruEwCsWU+9dyTQZMr/xN5kdcf/w\n\tqSt9NjUA33IMkl7liMMaP1BC1A==","X-Google-Smtp-Source":"APiQypLu2+C+UKlPKnOLwsUGTQdYED8cxTVdjXaUWRwPRYtAPqxuN14BfwNcrT+q2EdCvsRZTT4gCg==","X-Received":"by 2002:ac2:5e26:: with SMTP id o6mr2690516lfg.49.1586302715515; \n\tTue, 07 Apr 2020 16:38:35 -0700 (PDT)","Date":"Wed, 8 Apr 2020 01:38:34 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, Martijn Braam <martijn@brixit.nl>, \n\tBenjamin GAIGNARD <benjamin.gaignard@st.com>","Message-ID":"<20200407233834.GE1716317@oden.dyn.berto.se>","References":"<20200404004438.17992-1-laurent.pinchart@ideasonboard.com>\n\t<20200404004438.17992-6-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200404004438.17992-6-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v4 05/11] libcamera: v4l2_videodevice:\n\tSupport filtering formats by media bus code","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, 07 Apr 2020 23:38:36 -0000"}},{"id":4422,"web_url":"https://patchwork.libcamera.org/comment/4422/","msgid":"<20200408002902.GP4751@pendragon.ideasonboard.com>","date":"2020-04-08T00:29:02","subject":"Re: [libcamera-devel] [PATCH v4 05/11] libcamera: v4l2_videodevice:\n\tSupport filtering formats by media bus code","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Niklas,\n\nOn Wed, Apr 08, 2020 at 01:38:34AM +0200, Niklas Söderlund wrote:\n> On 2020-04-04 03:44:32 +0300, Laurent Pinchart wrote:\n> > Add support for the recent V4L2 extension to VIDIOC_ENUM_FMT that allows\n> > filtering pixel formats by media bus codes.\n> > \n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> Is your intent to try and merge this ahead of V4L2_CAP_IO_MC upstream?  \n> If not I think we shall try and remember to update the commit message \n> with which kernel version is needed make use of this feature.\n\nI'd prefer getting the kernel patches merged first if possible. I don't\nthink they're very far from being ready. If more work is needed on the\nkernel side I would possibly consider merging this series already, as\nit's easier to develop it further with the code in master, but I won't\npush too much for that (for now at least :-)).\n\n> Provided the patches on their way upstream stay the same,\n> \n> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> \n> > ---\n> >  src/libcamera/include/v4l2_videodevice.h |  4 ++--\n> >  src/libcamera/v4l2_videodevice.cpp       | 16 +++++++++++++---\n> >  2 files changed, 15 insertions(+), 5 deletions(-)\n> > \n> > diff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h\n> > index 7d7c4a9e6ebd..7b011d3b4e87 100644\n> > --- a/src/libcamera/include/v4l2_videodevice.h\n> > +++ b/src/libcamera/include/v4l2_videodevice.h\n> > @@ -207,7 +207,7 @@ public:\n> >  \n> >  \tint getFormat(V4L2DeviceFormat *format);\n> >  \tint setFormat(V4L2DeviceFormat *format);\n> > -\tstd::map<V4L2PixelFormat, std::vector<SizeRange>> formats();\n> > +\tstd::map<V4L2PixelFormat, std::vector<SizeRange>> formats(uint32_t code = 0);\n> >  \n> >  \tint setCrop(Rectangle *rect);\n> >  \tint setCompose(Rectangle *rect);\n> > @@ -246,7 +246,7 @@ private:\n> >  \tint getFormatSingleplane(V4L2DeviceFormat *format);\n> >  \tint setFormatSingleplane(V4L2DeviceFormat *format);\n> >  \n> > -\tstd::vector<V4L2PixelFormat> enumPixelformats();\n> > +\tstd::vector<V4L2PixelFormat> enumPixelformats(uint32_t code);\n> >  \tstd::vector<SizeRange> enumSizes(V4L2PixelFormat pixelFormat);\n> >  \n> >  \tint setSelection(unsigned int target, Rectangle *rect);\n> > diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> > index eb33a68e50d6..f7b98272d247 100644\n> > --- a/src/libcamera/v4l2_videodevice.cpp\n> > +++ b/src/libcamera/v4l2_videodevice.cpp\n> > @@ -973,16 +973,19 @@ int V4L2VideoDevice::setFormatSingleplane(V4L2DeviceFormat *format)\n> >  \n> >  /**\n> >   * \\brief Enumerate all pixel formats and frame sizes\n> > + * \\param[in] code Restrict formats to this media bus code.\n> >   *\n> >   * Enumerate all pixel formats and frame sizes supported by the video device.\n> > + * If the \\a code argument is not zero, only formats compatible with that media\n> > + * bus code will be enumerated.\n> >   *\n> >   * \\return A list of the supported video device formats\n> >   */\n> > -std::map<V4L2PixelFormat, std::vector<SizeRange>> V4L2VideoDevice::formats()\n> > +std::map<V4L2PixelFormat, std::vector<SizeRange>> V4L2VideoDevice::formats(uint32_t code)\n> >  {\n> >  \tstd::map<V4L2PixelFormat, std::vector<SizeRange>> formats;\n> >  \n> > -\tfor (V4L2PixelFormat pixelFormat : enumPixelformats()) {\n> > +\tfor (V4L2PixelFormat pixelFormat : enumPixelformats(code)) {\n> >  \t\tstd::vector<SizeRange> sizes = enumSizes(pixelFormat);\n> >  \t\tif (sizes.empty())\n> >  \t\t\treturn {};\n> > @@ -1000,15 +1003,22 @@ std::map<V4L2PixelFormat, std::vector<SizeRange>> V4L2VideoDevice::formats()\n> >  \treturn formats;\n> >  }\n> >  \n> > -std::vector<V4L2PixelFormat> V4L2VideoDevice::enumPixelformats()\n> > +std::vector<V4L2PixelFormat> V4L2VideoDevice::enumPixelformats(uint32_t code)\n> >  {\n> >  \tstd::vector<V4L2PixelFormat> formats;\n> >  \tint ret;\n> >  \n> > +\tif (code && !(caps_.device_caps() & V4L2_CAP_IO_MC)) {\n> > +\t\tLOG(V4L2, Error)\n> > +\t\t\t<< \"Media bus code filtering not supported by the device\";\n> > +\t\treturn {};\n> > +\t}\n> > +\n> >  \tfor (unsigned int index = 0; ; index++) {\n> >  \t\tstruct v4l2_fmtdesc pixelformatEnum = {};\n> >  \t\tpixelformatEnum.index = index;\n> >  \t\tpixelformatEnum.type = bufferType_;\n> > +\t\tpixelformatEnum.mbus_code = code;\n> >  \n> >  \t\tret = ioctl(VIDIOC_ENUM_FMT, &pixelformatEnum);\n> >  \t\tif (ret)","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 EBEE7600F3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Apr 2020 02:29:12 +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 63FF859E;\n\tWed,  8 Apr 2020 02:29:12 +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=\"ssYfORP7\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1586305752;\n\tbh=Ee4iH+Rqc+CPWNcOVcpE3Vi7ZnBybwygEWFKJaB72Ac=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=ssYfORP7gBSH2BvFVehBcAQnLCMrEt+1Zuhre9+hrDzuGX8v0hgphzIkr1kbf8dm4\n\tEakd18ka3oRhbAG1XD1DNzM1Sr4fAup4EqmL63jVDFihR36jEEorkX7KXCmJxivTkK\n\tf/qPKGxAS8q0VCs7VcT5D5K4qqOS3Fhc/4ZHFnWg=","Date":"Wed, 8 Apr 2020 03:29:02 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org, Martijn Braam <martijn@brixit.nl>, \n\tBenjamin GAIGNARD <benjamin.gaignard@st.com>","Message-ID":"<20200408002902.GP4751@pendragon.ideasonboard.com>","References":"<20200404004438.17992-1-laurent.pinchart@ideasonboard.com>\n\t<20200404004438.17992-6-laurent.pinchart@ideasonboard.com>\n\t<20200407233834.GE1716317@oden.dyn.berto.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200407233834.GE1716317@oden.dyn.berto.se>","Subject":"Re: [libcamera-devel] [PATCH v4 05/11] libcamera: v4l2_videodevice:\n\tSupport filtering formats by media bus code","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, 08 Apr 2020 00:29:13 -0000"}}]