[{"id":1727,"web_url":"https://patchwork.libcamera.org/comment/1727/","msgid":"<c20ff33f-2e5a-3b49-8b9c-5c06f6f9e5f9@ideasonboard.com>","date":"2019-05-29T21:53:27","subject":"Re: [libcamera-devel] [PATCH 09/17] libcamera: v4l2_device: Add\n\tenumeration of pixelformats and frame sizes","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Niklas,\n\nOn 27/05/2019 01:15, Niklas Söderlund wrote:\n> Add methods to enumerate pixelformats and frame sizes from a v4l2\n> device. The interface is similar to how V4L2Subdevice enumerates mbus\n> codes and frame sizes.\n> \n\nCould we add a test or two to test/v4l2_device/formats.cpp for this\npublic API addition?\n\n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n>  src/libcamera/include/v4l2_device.h |   5 ++\n>  src/libcamera/v4l2_device.cpp       | 104 ++++++++++++++++++++++++++++\n>  2 files changed, 109 insertions(+)\n> \n> diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\n> index 2e7bd1e7f4cce276..db2d12757c6f564a 100644\n> --- a/src/libcamera/include/v4l2_device.h\n> +++ b/src/libcamera/include/v4l2_device.h\n> @@ -16,6 +16,7 @@\n>  #include <libcamera/geometry.h>\n>  #include <libcamera/signal.h>\n>  \n> +#include \"formats.h\"\n>  #include \"log.h\"\n>  \n>  namespace libcamera {\n> @@ -126,6 +127,7 @@ public:\n>  \n>  \tint getFormat(V4L2DeviceFormat *format);\n>  \tint setFormat(V4L2DeviceFormat *format);\n> +\tV4L2DeviceFormats formats();\n>  \n>  \tint exportBuffers(BufferPool *pool);\n>  \tint importBuffers(BufferPool *pool);\n> @@ -154,6 +156,9 @@ private:\n>  \tint createPlane(Buffer *buffer, unsigned int plane,\n>  \t\t\tunsigned int length);\n>  \n> +\tstd::vector<unsigned int> enumPixelformats();\n> +\tstd::vector<SizeRange> enumSizes(unsigned int pixelformat);\n> +\n>  \tBuffer *dequeueBuffer();\n>  \tvoid bufferAvailable(EventNotifier *notifier);\n>  \n> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> index 8366ffc4db559520..a9667092a20505d9 100644\n> --- a/src/libcamera/v4l2_device.cpp\n> +++ b/src/libcamera/v4l2_device.cpp\n> @@ -564,6 +564,23 @@ int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format)\n>  \treturn 0;\n>  }\n>  \n> +/**\n> + * \\brief Enumerate all pixelformats and frame sizes\n> + *\n> + * Enumerate all pixelformats and frame sizes reported by the video device.\n> + *\n> + * \\return All pixelformats and frame sizes\n\nHow about:\n\n \\return A list of the supported device formats\n\n<except s/list/some-other-type-description/ >\n\n> + */\n> +V4L2DeviceFormats V4L2Device::formats()\n\nEeep, we have a V4L2DeviceFormat class and a V4L2DeviceFormats class\nwhich do (somewhat) different things ...\n\nI hope that won't be too confusing... <I've gone back and noted this in\nreply to the patch that adds the types.>\n\n\n> +{\n> +\tstd::map<unsigned int, std::vector<SizeRange>> formatMap = {};\n> +\n> +\tfor (unsigned int pixelformat : enumPixelformats())\n> +\t\tformatMap[pixelformat] = enumSizes(pixelformat);\n> +\n> +\treturn V4L2DeviceFormats(formatMap);\n> +}\n> +\n>  int V4L2Device::requestBuffers(unsigned int count)\n>  {\n>  \tstruct v4l2_requestbuffers rb = {};\n> @@ -692,6 +709,93 @@ int V4L2Device::createPlane(Buffer *buffer, unsigned int planeIndex,\n>  \n>  \treturn 0;\n>  }\n\nnewline required here.\n\n> +std::vector<unsigned int> V4L2Device::enumPixelformats()\n> +{\n> +\tstd::vector<unsigned int> pixelformats;\n> +\tint ret;\n> +\n> +\tfor (unsigned int index = 0;; index++) {\n> +\t\tstruct v4l2_fmtdesc pixelformatEnum = {\n> +\t\t\t.index = index,\n> +\t\t\t.type = bufferType_,\n> +\t\t};\n> +\n> +\t\tret = ioctl(fd_, VIDIOC_ENUM_FMT, &pixelformatEnum);\n> +\t\tif (ret)\n> +\t\t\tbreak;\n> +\n> +\t\tpixelformats.push_back(pixelformatEnum.pixelformat);\n> +\t}\n> +\n> +\tif (ret && errno != EINVAL) {\n> +\t\tret = errno;\n> +\t\tLOG(V4L2, Error)\n> +\t\t\t<< \"Unable to enumerate pixelformats: \"\n> +\t\t\t<< strerror(ret);\n> +\t\treturn {};\n> +\t}\n> +\n> +\treturn pixelformats;\n> +}\n> +\n> +std::vector<SizeRange> V4L2Device::enumSizes(unsigned int pixelformat)\n> +{\n> +\tstd::vector<SizeRange> sizes;\n> +\tint ret;\n> +\n> +\tfor (unsigned int index = 0;; index++) {\n> +\t\tstruct v4l2_frmsizeenum frameSize = {\n> +\t\t\t.index = index,\n> +\t\t\t.pixel_format = pixelformat,\n> +\t\t};\n> +\n> +\t\tret = ioctl(fd_, VIDIOC_ENUM_FRAMESIZES, &frameSize);\n> +\t\tif (ret)\n> +\t\t\tbreak;\n> +\n> +\t\tif (index != 0 &&\n> +\t\t    frameSize.type != V4L2_FRMSIZE_TYPE_DISCRETE) {\n> +\t\t\tLOG(V4L2, Error)\n> +\t\t\t\t<< \"None 0 index for none discrete type\";\n\nNon-zero index for non discrete type\n\n> +\t\t\treturn {};\n> +\t\t}\n> +\n> +\t\tswitch (frameSize.type) {\n> +\t\tcase V4L2_FRMSIZE_TYPE_DISCRETE:\n> +\t\t\tsizes.emplace_back(frameSize.discrete.width,\n> +\t\t\t\t\t   frameSize.discrete.height);\n> +\t\t\tbreak;\n> +\t\tcase V4L2_FRMSIZE_TYPE_CONTINUOUS:\n> +\t\t\tsizes.emplace_back(frameSize.stepwise.min_width,\n> +\t\t\t\t\t   frameSize.stepwise.min_height,\n> +\t\t\t\t\t   frameSize.stepwise.max_width,\n> +\t\t\t\t\t   frameSize.stepwise.max_height);\n> +\t\t\tbreak;\n> +\t\tcase V4L2_FRMSIZE_TYPE_STEPWISE:\n> +\t\t\tsizes.emplace_back(frameSize.stepwise.min_width,\n> +\t\t\t\t\t   frameSize.stepwise.min_height,\n> +\t\t\t\t\t   frameSize.stepwise.max_width,\n> +\t\t\t\t\t   frameSize.stepwise.max_height,\n> +\t\t\t\t\t   frameSize.stepwise.step_width,\n> +\t\t\t\t\t   frameSize.stepwise.step_height);\n> +\t\t\tbreak;\n> +\t\tdefault:\n> +\t\t\tLOG(V4L2, Error)\n> +\t\t\t\t<< \"Unkown VIDIOC_ENUM_FRAMESIZES type \"\n\ns/Unkown/Unknown/\n\n> +\t\t\t\t<< frameSize.type;\n> +\t\t\treturn {};\n> +\t\t}\n> +\t}\n> +\n> +\tif (ret && errno != EINVAL) {\n> +\t\tret = errno;\n> +\t\tLOG(V4L2, Error)\n> +\t\t\t<< \"Unable to enumerate frame sizes: \" << strerror(ret);\n> +\t\treturn {};\n> +\t}\n> +\n> +\treturn sizes;\n> +}\n>  \n>  /**\n>   * \\brief Import the externally allocated \\a pool of buffers\n>","headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F3EBF60E46\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 May 2019 23:53:31 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4DDB3524;\n\tWed, 29 May 2019 23:53:31 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1559166811;\n\tbh=RD853lcWJ0zclwCEAGyoUY63idYfIPuMl9suqtr6ATE=;\n\th=Reply-To:Subject:To:References:From:Date:In-Reply-To:From;\n\tb=AUtCHI2n+UdCzHdhciCgekjz2ruMFQvdkIxQni6LmcO2euIWsvf5DElKE5eMdgjQ/\n\tMsdJExcW8z/6oncFHujicbYLiSUK6EYDo5J3/s++9+H9wrCrC/UQSaPGkOdv90Gnov\n\tmPSQX4l27geyu93QuE1fAVir9oXjhx5pjLiT2jG8=","Reply-To":"kieran.bingham@ideasonboard.com","To":"=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20190527001543.13593-1-niklas.soderlund@ragnatech.se>\n\t<20190527001543.13593-10-niklas.soderlund@ragnatech.se>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Openpgp":"preference=signencrypt","Autocrypt":"addr=kieran.bingham@ideasonboard.com; keydata=\n\tmQINBFYE/WYBEACs1PwjMD9rgCu1hlIiUA1AXR4rv2v+BCLUq//vrX5S5bjzxKAryRf0uHat\n\tV/zwz6hiDrZuHUACDB7X8OaQcwhLaVlq6byfoBr25+hbZG7G3+5EUl9cQ7dQEdvNj6V6y/SC\n\trRanWfelwQThCHckbobWiQJfK9n7rYNcPMq9B8e9F020LFH7Kj6YmO95ewJGgLm+idg1Kb3C\n\tpotzWkXc1xmPzcQ1fvQMOfMwdS+4SNw4rY9f07Xb2K99rjMwZVDgESKIzhsDB5GY465sCsiQ\n\tcSAZRxqE49RTBq2+EQsbrQpIc8XiffAB8qexh5/QPzCmR4kJgCGeHIXBtgRj+nIkCJPZvZtf\n\tKr2EAbc6tgg6DkAEHJb+1okosV09+0+TXywYvtEop/WUOWQ+zo+Y/OBd+8Ptgt1pDRyOBzL8\n\tRXa8ZqRf0Mwg75D+dKntZeJHzPRJyrlfQokngAAs4PaFt6UfS+ypMAF37T6CeDArQC41V3ko\n\tlPn1yMsVD0p+6i3DPvA/GPIksDC4owjnzVX9kM8Zc5Cx+XoAN0w5Eqo4t6qEVbuettxx55gq\n\t8K8FieAjgjMSxngo/HST8TpFeqI5nVeq0/lqtBRQKumuIqDg+Bkr4L1V/PSB6XgQcOdhtd36\n\tOe9X9dXB8YSNt7VjOcO7BTmFn/Z8r92mSAfHXpb07YJWJosQOQARAQABtDBLaWVyYW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ydIPTh1QEj9SYyvp8\n\tO0g6CpxEwyHUQtF5oh15O018z3ZLztFJKR3RD42VKVsrnNDKnoY0f4U0z7eJv2NeF8xHMuiU\n\tRCIzqxX1GVYaNkKTnb/Qja8hnYnkUzY1Lc+OtwiGmXTwYsPZjjAaDX35J/RSKAoy5wGo/YFA\n\tJxB1gWThL4kOTbsqqXj9GLcyOImkW0lJGGR3o/fV91Zh63S5TKnf2YGGGzxki+ADdxVQAm+Q\n\tsbsRB8KNNvVXBOVNwko86rQqF9drZuw=","Organization":"Ideas on Board","Message-ID":"<c20ff33f-2e5a-3b49-8b9c-5c06f6f9e5f9@ideasonboard.com>","Date":"Wed, 29 May 2019 22:53:27 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101\n\tThunderbird/60.6.1","MIME-Version":"1.0","In-Reply-To":"<20190527001543.13593-10-niklas.soderlund@ragnatech.se>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH 09/17] libcamera: v4l2_device: Add\n\tenumeration of pixelformats and frame sizes","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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, 29 May 2019 21:53:32 -0000"}},{"id":1806,"web_url":"https://patchwork.libcamera.org/comment/1806/","msgid":"<20190609203637.GI4778@pendragon.ideasonboard.com>","date":"2019-06-09T20:36:37","subject":"Re: [libcamera-devel] [PATCH 09/17] libcamera: v4l2_device: Add\n\tenumeration of pixelformats and frame sizes","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Niklas,\n\nThank you for the patch.\n\nOn Wed, May 29, 2019 at 10:53:27PM +0100, Kieran Bingham wrote:\n> On 27/05/2019 01:15, Niklas Söderlund wrote:\n> > Add methods to enumerate pixelformats and frame sizes from a v4l2\n> > device. The interface is similar to how V4L2Subdevice enumerates mbus\n> > codes and frame sizes.\n> \n> Could we add a test or two to test/v4l2_device/formats.cpp for this\n> public API addition?\n> \n> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> > ---\n> >  src/libcamera/include/v4l2_device.h |   5 ++\n> >  src/libcamera/v4l2_device.cpp       | 104 ++++++++++++++++++++++++++++\n> >  2 files changed, 109 insertions(+)\n> > \n> > diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\n> > index 2e7bd1e7f4cce276..db2d12757c6f564a 100644\n> > --- a/src/libcamera/include/v4l2_device.h\n> > +++ b/src/libcamera/include/v4l2_device.h\n> > @@ -16,6 +16,7 @@\n> >  #include <libcamera/geometry.h>\n> >  #include <libcamera/signal.h>\n> >  \n> > +#include \"formats.h\"\n> >  #include \"log.h\"\n> >  \n> >  namespace libcamera {\n> > @@ -126,6 +127,7 @@ public:\n> >  \n> >  \tint getFormat(V4L2DeviceFormat *format);\n> >  \tint setFormat(V4L2DeviceFormat *format);\n> > +\tV4L2DeviceFormats formats();\n> >  \n> >  \tint exportBuffers(BufferPool *pool);\n> >  \tint importBuffers(BufferPool *pool);\n> > @@ -154,6 +156,9 @@ private:\n> >  \tint createPlane(Buffer *buffer, unsigned int plane,\n> >  \t\t\tunsigned int length);\n> >  \n> > +\tstd::vector<unsigned int> enumPixelformats();\n> > +\tstd::vector<SizeRange> enumSizes(unsigned int pixelformat);\n> > +\n> >  \tBuffer *dequeueBuffer();\n> >  \tvoid bufferAvailable(EventNotifier *notifier);\n> >  \n> > diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> > index 8366ffc4db559520..a9667092a20505d9 100644\n> > --- a/src/libcamera/v4l2_device.cpp\n> > +++ b/src/libcamera/v4l2_device.cpp\n> > @@ -564,6 +564,23 @@ int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format)\n> >  \treturn 0;\n> >  }\n> >  \n> > +/**\n> > + * \\brief Enumerate all pixelformats and frame sizes\n\ns/pixelformats/pixel formats/ (same below)\n\n> > + *\n> > + * Enumerate all pixelformats and frame sizes reported by the video device.\n\n\"reported\" or \"supported\" ?\n\n> > + *\n> > + * \\return All pixelformats and frame sizes\n> \n> How about:\n> \n>  \\return A list of the supported device formats\n> \n> <except s/list/some-other-type-description/ >\n> \n> > + */\n> > +V4L2DeviceFormats V4L2Device::formats()\n> \n> Eeep, we have a V4L2DeviceFormat class and a V4L2DeviceFormats class\n> which do (somewhat) different things ...\n> \n> I hope that won't be too confusing... <I've gone back and noted this in\n> reply to the patch that adds the types.>\n\nIt can be a bit confusing indeed, but so far I think this is the best\nsolution I've seen. If anyone can think of a better option, please say\nso. We can always change it later anyway.\n\n> > +{\n> > +\tstd::map<unsigned int, std::vector<SizeRange>> formatMap = {};\n> > +\n> > +\tfor (unsigned int pixelformat : enumPixelformats())\n> > +\t\tformatMap[pixelformat] = enumSizes(pixelformat);\n> > +\n> > +\treturn V4L2DeviceFormats(formatMap);\n> > +}\n> > +\n> >  int V4L2Device::requestBuffers(unsigned int count)\n> >  {\n> >  \tstruct v4l2_requestbuffers rb = {};\n> > @@ -692,6 +709,93 @@ int V4L2Device::createPlane(Buffer *buffer, unsigned int planeIndex,\n> >  \n> >  \treturn 0;\n> >  }\n> \n> newline required here.\n> \n> > +std::vector<unsigned int> V4L2Device::enumPixelformats()\n> > +{\n> > +\tstd::vector<unsigned int> pixelformats;\n\ns/pixelformats/pixelFormats/ (or just formats) ?\n\n> > +\tint ret;\n> > +\n> > +\tfor (unsigned int index = 0;; index++) {\n\ns/;;/; ;/\n\n> > +\t\tstruct v4l2_fmtdesc pixelformatEnum = {\n> > +\t\t\t.index = index,\n> > +\t\t\t.type = bufferType_,\n> > +\t\t};\n> > +\n> > +\t\tret = ioctl(fd_, VIDIOC_ENUM_FMT, &pixelformatEnum);\n> > +\t\tif (ret)\n> > +\t\t\tbreak;\n> > +\n> > +\t\tpixelformats.push_back(pixelformatEnum.pixelformat);\n> > +\t}\n> > +\n> > +\tif (ret && errno != EINVAL) {\n> > +\t\tret = errno;\n> > +\t\tLOG(V4L2, Error)\n> > +\t\t\t<< \"Unable to enumerate pixelformats: \"\n> > +\t\t\t<< strerror(ret);\n> > +\t\treturn {};\n> > +\t}\n> > +\n> > +\treturn pixelformats;\n> > +}\n> > +\n> > +std::vector<SizeRange> V4L2Device::enumSizes(unsigned int pixelformat)\n\ns/pixelformat/pixelFormat/ ?\n\n> > +{\n> > +\tstd::vector<SizeRange> sizes;\n> > +\tint ret;\n> > +\n> > +\tfor (unsigned int index = 0;; index++) {\n> > +\t\tstruct v4l2_frmsizeenum frameSize = {\n> > +\t\t\t.index = index,\n> > +\t\t\t.pixel_format = pixelformat,\n> > +\t\t};\n> > +\n> > +\t\tret = ioctl(fd_, VIDIOC_ENUM_FRAMESIZES, &frameSize);\n> > +\t\tif (ret)\n> > +\t\t\tbreak;\n> > +\n> > +\t\tif (index != 0 &&\n> > +\t\t    frameSize.type != V4L2_FRMSIZE_TYPE_DISCRETE) {\n> > +\t\t\tLOG(V4L2, Error)\n> > +\t\t\t\t<< \"None 0 index for none discrete type\";\n> \n> Non-zero index for non discrete type\n> \n> > +\t\t\treturn {};\n> > +\t\t}\n> > +\n> > +\t\tswitch (frameSize.type) {\n> > +\t\tcase V4L2_FRMSIZE_TYPE_DISCRETE:\n> > +\t\t\tsizes.emplace_back(frameSize.discrete.width,\n> > +\t\t\t\t\t   frameSize.discrete.height);\n> > +\t\t\tbreak;\n> > +\t\tcase V4L2_FRMSIZE_TYPE_CONTINUOUS:\n> > +\t\t\tsizes.emplace_back(frameSize.stepwise.min_width,\n> > +\t\t\t\t\t   frameSize.stepwise.min_height,\n> > +\t\t\t\t\t   frameSize.stepwise.max_width,\n> > +\t\t\t\t\t   frameSize.stepwise.max_height);\n> > +\t\t\tbreak;\n> > +\t\tcase V4L2_FRMSIZE_TYPE_STEPWISE:\n> > +\t\t\tsizes.emplace_back(frameSize.stepwise.min_width,\n> > +\t\t\t\t\t   frameSize.stepwise.min_height,\n> > +\t\t\t\t\t   frameSize.stepwise.max_width,\n> > +\t\t\t\t\t   frameSize.stepwise.max_height,\n> > +\t\t\t\t\t   frameSize.stepwise.step_width,\n> > +\t\t\t\t\t   frameSize.stepwise.step_height);\n> > +\t\t\tbreak;\n> > +\t\tdefault:\n> > +\t\t\tLOG(V4L2, Error)\n> > +\t\t\t\t<< \"Unkown VIDIOC_ENUM_FRAMESIZES type \"\n> \n> s/Unkown/Unknown/\n> \n> > +\t\t\t\t<< frameSize.type;\n> > +\t\t\treturn {};\n> > +\t\t}\n> > +\t}\n> > +\n> > +\tif (ret && errno != EINVAL) {\n> > +\t\tret = errno;\n> > +\t\tLOG(V4L2, Error)\n> > +\t\t\t<< \"Unable to enumerate frame sizes: \" << strerror(ret);\n\nWhile it makes no big difference as we then don't do anything with ret,\nwe usually assign ret with -errno and use strerror(-ret). It may make\nsense to use this construct here as well, to avoid possible bugs in case\nwe later change the function to return ret. I won't push much though,\nit's up to you.\n\n> > +\t\treturn {};\n> > +\t}\n> > +\n> > +\treturn sizes;\n> > +}\n> >  \n> >  /**\n> >   * \\brief Import the externally allocated \\a pool of buffers","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C09D160BDC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  9 Jun 2019 22:36:52 +0200 (CEST)","from pendragon.ideasonboard.com (unknown\n\t[IPv6:2a02:a03f:44f0:8500:ca05:8177:199c:fed4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 30E315D;\n\tSun,  9 Jun 2019 22:36:52 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1560112612;\n\tbh=5eWcEGRkM6PdoktqiRwQjO5AvW1Hkk6nvrcViytYncE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=ZFP97tiQCz//A16Zxa6G9aT3e1daSP5wFet3bSQsKlAllmk4/xnVIhIRvUoW8wINv\n\tK6TJ/KnFV6uUH+dmWuwH/bQcOZpkjZsKlKAFPVK/kRsJ3MRCfIaC57MVmzISYpE6Tv\n\tNDX1zsxHjL2+pOk00F4Han1aWNy1XhYDVPa/scII=","Date":"Sun, 9 Jun 2019 23:36:37 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Message-ID":"<20190609203637.GI4778@pendragon.ideasonboard.com>","References":"<20190527001543.13593-1-niklas.soderlund@ragnatech.se>\n\t<20190527001543.13593-10-niklas.soderlund@ragnatech.se>\n\t<c20ff33f-2e5a-3b49-8b9c-5c06f6f9e5f9@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<c20ff33f-2e5a-3b49-8b9c-5c06f6f9e5f9@ideasonboard.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH 09/17] libcamera: v4l2_device: Add\n\tenumeration of pixelformats and frame sizes","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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":"Sun, 09 Jun 2019 20:36:53 -0000"}}]