[{"id":906,"web_url":"https://patchwork.libcamera.org/comment/906/","msgid":"<6e2c7065-60ad-32e7-3f09-550dea0955a6@ideasonboard.com>","date":"2019-02-26T23:54:57","subject":"Re: [libcamera-devel] [PATCH v3 7/8] test: v4l2_device: Add format\n\thandling test","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn 26/02/2019 16:26, Jacopo Mondi wrote:\n> Add test for V4L2Device set and get format methods.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n\nWith minor topics below tackled,\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n>  test/v4l2_device/meson.build      |  1 +\n>  test/v4l2_device/test_formats.cpp | 65 +++++++++++++++++++++++++++++++\n>  2 files changed, 66 insertions(+)\n>  create mode 100644 test/v4l2_device/test_formats.cpp\n> \n> diff --git a/test/v4l2_device/meson.build b/test/v4l2_device/meson.build\n> index 9f7a7545ac9b..e5e50faac282 100644\n> --- a/test/v4l2_device/meson.build\n> +++ b/test/v4l2_device/meson.build\n> @@ -6,6 +6,7 @@ v4l2_device_tests = [\n>    [ 'stream_on_off',      'stream_on_off.cpp' ],\n>    [ 'capture_async',      'capture_async.cpp' ],\n>    [ 'buffer_sharing',     'buffer_sharing.cpp' ],\n> +  [ 'test_formats',\t  'test_formats.cpp' ],\n\nIt looks like there might be a trivial whitespace issue in the table here.\n\n>  ]\n>  \n>  foreach t : v4l2_device_tests\n> diff --git a/test/v4l2_device/test_formats.cpp b/test/v4l2_device/test_formats.cpp\n> new file mode 100644\n> index 000000000000..dcb05a3904f7\n> --- /dev/null\n> +++ b/test/v4l2_device/test_formats.cpp\n> @@ -0,0 +1,65 @@\n> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> +/*\n> + * Copyright (C) 2019, Google Inc.\n> + *\n> + * libcamera V4L2 device format handling test\n> + */\n> +\n> +#include <climits>\n> +#include <iostream>\n> +\n> +#include \"v4l2_device.h\"\n> +\n> +#include \"v4l2_device_test.h\"\n> +\n> +using namespace std;\n> +using namespace libcamera;\n> +\n> +class Format : public V4L2DeviceTest\n> +{\n> +protected:\n> +\tint run();\n> +};\n> +\n> +int Format::run()\n> +{\n> +\tV4L2DeviceFormat format = {};\n> +\n> +\tint ret = capture_->getFormat(&format);\n> +\tif (ret) {\n> +\t\tcerr << \"Failed to get format\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\tformat.width = UINT_MAX;\n> +\tformat.height = UINT_MAX;\n> +\tret = capture_->setFormat(&format);\n> +\tif (ret) {\n> +\t\tcerr << \"Failed to set format: image resolution is wrong, but \"\n\ns/wrong/unsupported/ ? or (invalid, incompatible...)?\n\n\n\n> +\t\t     << \"setFormat() should not fail.\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\tif (format.width == UINT_MAX || format.height == UINT_MAX) {\n> +\t\tcerr << \"Failed to update image format\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\tformat.width = 0;\n> +\tformat.height = 0;\n> +\tret = capture_->setFormat(&format);\n> +\tif (ret) {\n> +\t\tcerr << \"Failed to set format: image resolution is wrong, but \"\n\nCould we distinguish the error message between the minimum test and\nmaximum test failures so that if one fails it can be identified easily?\n\n> +\t\t     << \"setFormat() should not fail.\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\tif (format.width == 0 || format.height == 0) {\n> +\t\tcerr << \"Failed to update image format\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\treturn TestPass;\n> +}\n> +\n> +TEST_REGISTER(Format);\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 A0FCC610B2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Feb 2019 00:55:01 +0100 (CET)","from [192.168.0.21]\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 0CBA167;\n\tWed, 27 Feb 2019 00:55:00 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1551225301;\n\tbh=0/LHknPTeji9KUf/H+fewSKFpN02P+oU353wONOkLMM=;\n\th=Reply-To:Subject:To:References:From:Date:In-Reply-To:From;\n\tb=I3jAIgIU0wI2BOmTSb0zOnTiQkvSERipDe3g+OtsNxusEhrVbrjKLJYAdqGW6xuta\n\tfRIbW1IyqyNQV9Ee2coGdyg7Aa36ljcGnP1p0nCShJZ+Vabd+wn9Bdj5Hnq4ysOrJO\n\tBGpSBmqDSskAB4aTQnhVSZDFpWd9umfSm8VgHzJo=","Reply-To":"kieran.bingham@ideasonboard.com","To":"Jacopo Mondi <jacopo@jmondi.org>, libcamera-devel@lists.libcamera.org","References":"<20190226162641.12116-1-jacopo@jmondi.org>\n\t<20190226162641.12116-8-jacopo@jmondi.org>","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+nIk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LSczM0s6XMeO\n\tVcE77UFtJ/+hLo4PRFKm5X1Pcar6g5m4xGqa+Xfzi9tRkwC29KMCoQOag1BhHChgqYaUH3yo\n\tUzaPwT/fY75iVI+yD0ih/e6j8qYvP8pvGwMQfrmN9YB0zB39YzCSdaUaNrWGD3iCBxg6lwSO\n\tLKeRhxxfiXCIYEf3vwOsP3YMx2JkD5doseXmWBGW1U0T/oJF+DVfKB6mv5UfsTzpVhJRgee7\n\t4jkjqFq4qsUGxcvF2xtRkfHFpZDbRgRlVmiWkqDkT4qMA+4q1y/dWwshSKi/uwVZNycuLsz+\n\t+OD8xPNCsMTqeUkAKfbD8xW4LCay3r/dD2ckoxRxtMD9eOAyu5wYzo/ydIPTh1QEj9SYyvp8\n\tO0g6CpxEwyHUQtF5oh15O018z3ZLztFJKR3RD42VKVsrnNDKnoY0f4U0z7eJv2NeF8xHMuiU\n\tRCIzqxX1GVYaNkKTnb/Qja8hnYnkUzY1Lc+OtwiGmXTwYsPZjjAaDX35J/RSKAoy5wGo/YFA\n\tJxB1gWThL4kOTbsqqXj9GLcyOImkW0lJGGR3o/fV91Zh63S5TKnf2YGGGzxki+ADdxVQAm+Q\n\tsbsRB8KNNvVXBOVNwko86rQqF9drZuw=","Organization":"Ideas on Board","Message-ID":"<6e2c7065-60ad-32e7-3f09-550dea0955a6@ideasonboard.com>","Date":"Tue, 26 Feb 2019 23:54:57 +0000","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101\n\tThunderbird/60.4.0","MIME-Version":"1.0","In-Reply-To":"<20190226162641.12116-8-jacopo@jmondi.org>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v3 7/8] test: v4l2_device: Add format\n\thandling test","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":"Tue, 26 Feb 2019 23:55:01 -0000"}},{"id":934,"web_url":"https://patchwork.libcamera.org/comment/934/","msgid":"<20190227184402.GQ4813@pendragon.ideasonboard.com>","date":"2019-02-27T18:44:02","subject":"Re: [libcamera-devel] [PATCH v3 7/8] test: v4l2_device: Add format\n\thandling test","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn Tue, Feb 26, 2019 at 05:26:40PM +0100, Jacopo Mondi wrote:\n> Add test for V4L2Device set and get format methods.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  test/v4l2_device/meson.build      |  1 +\n>  test/v4l2_device/test_formats.cpp | 65 +++++++++++++++++++++++++++++++\n>  2 files changed, 66 insertions(+)\n>  create mode 100644 test/v4l2_device/test_formats.cpp\n> \n> diff --git a/test/v4l2_device/meson.build b/test/v4l2_device/meson.build\n> index 9f7a7545ac9b..e5e50faac282 100644\n> --- a/test/v4l2_device/meson.build\n> +++ b/test/v4l2_device/meson.build\n> @@ -6,6 +6,7 @@ v4l2_device_tests = [\n>    [ 'stream_on_off',      'stream_on_off.cpp' ],\n>    [ 'capture_async',      'capture_async.cpp' ],\n>    [ 'buffer_sharing',     'buffer_sharing.cpp' ],\n> +  [ 'test_formats',\t  'test_formats.cpp' ],\n\nV4L2Device tests are soretd by order of increasing complexity, I think\nthink this one should be last in the list.\n\n>  ]\n>  \n>  foreach t : v4l2_device_tests\n> diff --git a/test/v4l2_device/test_formats.cpp b/test/v4l2_device/test_formats.cpp\n> new file mode 100644\n> index 000000000000..dcb05a3904f7\n> --- /dev/null\n> +++ b/test/v4l2_device/test_formats.cpp\n> @@ -0,0 +1,65 @@\n> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> +/*\n> + * Copyright (C) 2019, Google Inc.\n> + *\n> + * libcamera V4L2 device format handling test\n> + */\n> +\n> +#include <climits>\n> +#include <iostream>\n> +\n> +#include \"v4l2_device.h\"\n> +\n> +#include \"v4l2_device_test.h\"\n> +\n> +using namespace std;\n> +using namespace libcamera;\n> +\n> +class Format : public V4L2DeviceTest\n> +{\n> +protected:\n> +\tint run();\n\noverride\n\n> +};\n> +\n> +int Format::run()\n> +{\n> +\tV4L2DeviceFormat format = {};\n> +\n> +\tint ret = capture_->getFormat(&format);\n> +\tif (ret) {\n> +\t\tcerr << \"Failed to get format\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\tformat.width = UINT_MAX;\n> +\tformat.height = UINT_MAX;\n> +\tret = capture_->setFormat(&format);\n> +\tif (ret) {\n> +\t\tcerr << \"Failed to set format: image resolution is wrong, but \"\n> +\t\t     << \"setFormat() should not fail.\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\tif (format.width == UINT_MAX || format.height == UINT_MAX) {\n> +\t\tcerr << \"Failed to update image format\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\tformat.width = 0;\n> +\tformat.height = 0;\n> +\tret = capture_->setFormat(&format);\n> +\tif (ret) {\n> +\t\tcerr << \"Failed to set format: image resolution is wrong, but \"\n> +\t\t     << \"setFormat() should not fail.\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\tif (format.width == 0 || format.height == 0) {\n> +\t\tcerr << \"Failed to update image format\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\treturn TestPass;\n\nWith Kieran's comment addressed,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n(I however wonder if we need both the 0 and UINT_MAX tests. Testing that\nthe setFormat() function correctly updates the passed format is useful\nto test our implementation, but testing both 0 and UINT_MAX feels like\ntesting the kernel instead, which is a bit out of scope)\n\n> +}\n> +\n> +TEST_REGISTER(Format);","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 287C2610B3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Feb 2019 19:44:10 +0100 (CET)","from pendragon.ideasonboard.com (unknown [83.145.195.18])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6733949;\n\tWed, 27 Feb 2019 19:44:09 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1551293049;\n\tbh=k413ahEdVV6SGHpBIkdg74DrJt/H55stInN+zRhRyTw=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Ow47WnQ17idDyOYSgoOCoegLPpsudJ2hYxp6lC2hjQd+ox6s9KAevYcdWHvDijEyd\n\tVyAjzAmxKu6G8bAGokaxxTXKGWgOC10i2U8Aus5GwQV0Q0ej6i2IZenUYuVmBO+RQK\n\tlJq64MnAh501m0LelyIf4qvXvQUwa4ugGJevlxLg=","Date":"Wed, 27 Feb 2019 20:44:02 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190227184402.GQ4813@pendragon.ideasonboard.com>","References":"<20190226162641.12116-1-jacopo@jmondi.org>\n\t<20190226162641.12116-8-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190226162641.12116-8-jacopo@jmondi.org>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v3 7/8] test: v4l2_device: Add format\n\thandling test","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, 27 Feb 2019 18:44:10 -0000"}},{"id":943,"web_url":"https://patchwork.libcamera.org/comment/943/","msgid":"<20190228085455.jfypp6tpa7fvljzp@uno.localdomain>","date":"2019-02-28T08:54:55","subject":"Re: [libcamera-devel] [PATCH v3 7/8] test: v4l2_device: Add format\n\thandling test","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent,\n\nOn Wed, Feb 27, 2019 at 08:44:02PM +0200, Laurent Pinchart wrote:\n> Hi Jacopo,\n>\n> On Tue, Feb 26, 2019 at 05:26:40PM +0100, Jacopo Mondi wrote:\n> > Add test for V4L2Device set and get format methods.\n> >\n> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > ---\n> >  test/v4l2_device/meson.build      |  1 +\n> >  test/v4l2_device/test_formats.cpp | 65 +++++++++++++++++++++++++++++++\n> >  2 files changed, 66 insertions(+)\n> >  create mode 100644 test/v4l2_device/test_formats.cpp\n> >\n> > diff --git a/test/v4l2_device/meson.build b/test/v4l2_device/meson.build\n> > index 9f7a7545ac9b..e5e50faac282 100644\n> > --- a/test/v4l2_device/meson.build\n> > +++ b/test/v4l2_device/meson.build\n> > @@ -6,6 +6,7 @@ v4l2_device_tests = [\n> >    [ 'stream_on_off',      'stream_on_off.cpp' ],\n> >    [ 'capture_async',      'capture_async.cpp' ],\n> >    [ 'buffer_sharing',     'buffer_sharing.cpp' ],\n> > +  [ 'test_formats',\t  'test_formats.cpp' ],\n>\n> V4L2Device tests are soretd by order of increasing complexity, I think\n> think this one should be last in the list.\n>\n\nMay I say this is not the most intuitive ordering method?\nlast in the complexity list == first in the array?\n\n> >  ]\n> >\n> >  foreach t : v4l2_device_tests\n> > diff --git a/test/v4l2_device/test_formats.cpp b/test/v4l2_device/test_formats.cpp\n> > new file mode 100644\n> > index 000000000000..dcb05a3904f7\n> > --- /dev/null\n> > +++ b/test/v4l2_device/test_formats.cpp\n> > @@ -0,0 +1,65 @@\n> > +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> > +/*\n> > + * Copyright (C) 2019, Google Inc.\n> > + *\n> > + * libcamera V4L2 device format handling test\n> > + */\n> > +\n> > +#include <climits>\n> > +#include <iostream>\n> > +\n> > +#include \"v4l2_device.h\"\n> > +\n> > +#include \"v4l2_device_test.h\"\n> > +\n> > +using namespace std;\n> > +using namespace libcamera;\n> > +\n> > +class Format : public V4L2DeviceTest\n> > +{\n> > +protected:\n> > +\tint run();\n>\n> override\n>\n> > +};\n> > +\n> > +int Format::run()\n> > +{\n> > +\tV4L2DeviceFormat format = {};\n> > +\n> > +\tint ret = capture_->getFormat(&format);\n> > +\tif (ret) {\n> > +\t\tcerr << \"Failed to get format\" << endl;\n> > +\t\treturn TestFail;\n> > +\t}\n> > +\n> > +\tformat.width = UINT_MAX;\n> > +\tformat.height = UINT_MAX;\n> > +\tret = capture_->setFormat(&format);\n> > +\tif (ret) {\n> > +\t\tcerr << \"Failed to set format: image resolution is wrong, but \"\n> > +\t\t     << \"setFormat() should not fail.\" << endl;\n> > +\t\treturn TestFail;\n> > +\t}\n> > +\n> > +\tif (format.width == UINT_MAX || format.height == UINT_MAX) {\n> > +\t\tcerr << \"Failed to update image format\" << endl;\n> > +\t\treturn TestFail;\n> > +\t}\n> > +\n> > +\tformat.width = 0;\n> > +\tformat.height = 0;\n> > +\tret = capture_->setFormat(&format);\n> > +\tif (ret) {\n> > +\t\tcerr << \"Failed to set format: image resolution is wrong, but \"\n> > +\t\t     << \"setFormat() should not fail.\" << endl;\n> > +\t\treturn TestFail;\n> > +\t}\n> > +\n> > +\tif (format.width == 0 || format.height == 0) {\n> > +\t\tcerr << \"Failed to update image format\" << endl;\n> > +\t\treturn TestFail;\n> > +\t}\n> > +\n> > +\treturn TestPass;\n>\n> With Kieran's comment addressed,\n>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>\n> (I however wonder if we need both the 0 and UINT_MAX tests. Testing that\n> the setFormat() function correctly updates the passed format is useful\n> to test our implementation, but testing both 0 and UINT_MAX feels like\n> testing the kernel instead, which is a bit out of scope)\n\nAh, I re-wrote this stupid tests a million times, as everytime I did\nsomething a bit more complex I was actually testing the kernel driver\ninstead of the library. This seemed to me as a compromise between\ngoing for testing the driver and a test with no actual value, but I\ncan drop one of the cases.\n\nThanks\n   j\n\n>\n> > +}\n> > +\n> > +TEST_REGISTER(Format);\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net\n\t[217.70.183.195])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7FE31600FC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Feb 2019 09:54:25 +0100 (CET)","from uno.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 0A07C60013;\n\tThu, 28 Feb 2019 08:54:24 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Thu, 28 Feb 2019 09:54:55 +0100","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190228085455.jfypp6tpa7fvljzp@uno.localdomain>","References":"<20190226162641.12116-1-jacopo@jmondi.org>\n\t<20190226162641.12116-8-jacopo@jmondi.org>\n\t<20190227184402.GQ4813@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"y72y7mt6a2ecfdrr\"","Content-Disposition":"inline","In-Reply-To":"<20190227184402.GQ4813@pendragon.ideasonboard.com>","User-Agent":"NeoMutt/20180716","Subject":"Re: [libcamera-devel] [PATCH v3 7/8] test: v4l2_device: Add format\n\thandling test","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":"Thu, 28 Feb 2019 08:54:25 -0000"}},{"id":944,"web_url":"https://patchwork.libcamera.org/comment/944/","msgid":"<302a435d-614a-5a67-56b9-ca60f480a549@ideasonboard.com>","date":"2019-02-28T10:15:16","subject":"Re: [libcamera-devel] [PATCH v3 7/8] test: v4l2_device: Add format\n\thandling test","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Jacopo, Laurent,\n\nOn 28/02/2019 08:54, Jacopo Mondi wrote:\n> Hi Laurent,\n> \n> On Wed, Feb 27, 2019 at 08:44:02PM +0200, Laurent Pinchart wrote:\n>> Hi Jacopo,\n>>\n>> On Tue, Feb 26, 2019 at 05:26:40PM +0100, Jacopo Mondi wrote:\n>>> Add test for V4L2Device set and get format methods.\n>>>\n>>> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n>>> ---\n>>>  test/v4l2_device/meson.build      |  1 +\n>>>  test/v4l2_device/test_formats.cpp | 65 +++++++++++++++++++++++++++++++\n>>>  2 files changed, 66 insertions(+)\n>>>  create mode 100644 test/v4l2_device/test_formats.cpp\n>>>\n>>> diff --git a/test/v4l2_device/meson.build b/test/v4l2_device/meson.build\n>>> index 9f7a7545ac9b..e5e50faac282 100644\n>>> --- a/test/v4l2_device/meson.build\n>>> +++ b/test/v4l2_device/meson.build\n>>> @@ -6,6 +6,7 @@ v4l2_device_tests = [\n>>>    [ 'stream_on_off',      'stream_on_off.cpp' ],\n>>>    [ 'capture_async',      'capture_async.cpp' ],\n>>>    [ 'buffer_sharing',     'buffer_sharing.cpp' ],\n>>> +  [ 'test_formats',\t  'test_formats.cpp' ],\n>>\n>> V4L2Device tests are soretd by order of increasing complexity, I think\n>> think this one should be last in the list.\n\n\nYes, the intention was that the tests are increasing in complexity, and\nthe simplest test gets run first.\n\nAlso - the tests should somewhat follow the order of the expected API\nusage... so hence open/request_buffers is before stream_on_off.\n\n\nThe tests execute in the order that they are listed in the array.\n\nmeson test --suite v4l2_device\n1/6 libcamera:v4l2_device / double_open     SKIP     0.00 s\n2/6 libcamera:v4l2_device / request_buffers  SKIP     0.00 s\n3/6 libcamera:v4l2_device / stream_on_off   SKIP     0.00 s\n4/6 libcamera:v4l2_device / capture_async   SKIP     0.00 s\n5/6 libcamera:v4l2_device / buffer_sharing  SKIP     0.00 s\n6/6 libcamera:v4l2_device / test_formats    SKIP     0.00 s\n\n(Yes, they all skip on my x86 host because I'm still on v4.18 which\ndoesn't have a media controlled vivid)\n\n\n> May I say this is not the most intuitive ordering method?\n> last in the complexity list == first in the array?\n\nI think laurent made a typo, and should have said:\n\n> I don't think this one should be last in the list.\n\n\nI would consider this 'test_formats' to be after double open, and before\nstream_on_off.\n\nActually, as setting the formats is an API that you would use before\ngetting buffers, I would say it goes before request_buffers too.\n\nSo that would put in at position 2?\n\nI might also suggest dropping the \"test_\" prefix from the file name too\n... but it's not important. The other tests are not for example called\n\"test_buffer_sharing\".\n\n--\nKieran\n\n\n> \n>>>  ]\n>>>\n>>>  foreach t : v4l2_device_tests\n>>> diff --git a/test/v4l2_device/test_formats.cpp b/test/v4l2_device/test_formats.cpp\n>>> new file mode 100644\n>>> index 000000000000..dcb05a3904f7\n>>> --- /dev/null\n>>> +++ b/test/v4l2_device/test_formats.cpp\n>>> @@ -0,0 +1,65 @@\n>>> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n>>> +/*\n>>> + * Copyright (C) 2019, Google Inc.\n>>> + *\n>>> + * libcamera V4L2 device format handling test\n>>> + */\n>>> +\n>>> +#include <climits>\n>>> +#include <iostream>\n>>> +\n>>> +#include \"v4l2_device.h\"\n>>> +\n>>> +#include \"v4l2_device_test.h\"\n>>> +\n>>> +using namespace std;\n>>> +using namespace libcamera;\n>>> +\n>>> +class Format : public V4L2DeviceTest\n>>> +{\n>>> +protected:\n>>> +\tint run();\n>>\n>> override\n>>\n>>> +};\n>>> +\n>>> +int Format::run()\n>>> +{\n>>> +\tV4L2DeviceFormat format = {};\n>>> +\n>>> +\tint ret = capture_->getFormat(&format);\n>>> +\tif (ret) {\n>>> +\t\tcerr << \"Failed to get format\" << endl;\n>>> +\t\treturn TestFail;\n>>> +\t}\n>>> +\n>>> +\tformat.width = UINT_MAX;\n>>> +\tformat.height = UINT_MAX;\n>>> +\tret = capture_->setFormat(&format);\n>>> +\tif (ret) {\n>>> +\t\tcerr << \"Failed to set format: image resolution is wrong, but \"\n>>> +\t\t     << \"setFormat() should not fail.\" << endl;\n>>> +\t\treturn TestFail;\n>>> +\t}\n>>> +\n>>> +\tif (format.width == UINT_MAX || format.height == UINT_MAX) {\n>>> +\t\tcerr << \"Failed to update image format\" << endl;\n>>> +\t\treturn TestFail;\n>>> +\t}\n>>> +\n>>> +\tformat.width = 0;\n>>> +\tformat.height = 0;\n>>> +\tret = capture_->setFormat(&format);\n>>> +\tif (ret) {\n>>> +\t\tcerr << \"Failed to set format: image resolution is wrong, but \"\n>>> +\t\t     << \"setFormat() should not fail.\" << endl;\n>>> +\t\treturn TestFail;\n>>> +\t}\n>>> +\n>>> +\tif (format.width == 0 || format.height == 0) {\n>>> +\t\tcerr << \"Failed to update image format\" << endl;\n>>> +\t\treturn TestFail;\n>>> +\t}\n>>> +\n>>> +\treturn TestPass;\n>>\n>> With Kieran's comment addressed,\n>>\n>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>>\n>> (I however wonder if we need both the 0 and UINT_MAX tests. Testing that\n>> the setFormat() function correctly updates the passed format is useful\n>> to test our implementation, but testing both 0 and UINT_MAX feels like\n>> testing the kernel instead, which is a bit out of scope)\n> \n> Ah, I re-wrote this stupid tests a million times, as everytime I did\n> something a bit more complex I was actually testing the kernel driver\n> instead of the library. This seemed to me as a compromise between\n> going for testing the driver and a test with no actual value, but I\n> can drop one of the cases.\n> Thanks\n>    j\n> \n>>\n>>> +}\n>>> +\n>>> +TEST_REGISTER(Format);\n>>\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":"<kieran.bingham@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 077EB600FC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Feb 2019 11:15:20 +0100 (CET)","from [192.168.0.21]\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 54BA62E6;\n\tThu, 28 Feb 2019 11:15:19 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1551348919;\n\tbh=BJkO3e9eVUeXrYPEAs1tHw6CuyQSi4hrhe/DZIhMm6o=;\n\th=Reply-To:Subject:To:Cc:References:From:Date:In-Reply-To:From;\n\tb=Wq8ROVLMmHzYQnUYUIhpjVOpuiOJgF8rcFLjpeZ1XvrkMT0MrMA+sKqsgdbgNquj0\n\tIojOZDbwFE/m6OV9vWioLtRIBzStRgx/IN62BkqVgynRknzFm/GEg03khD/RUbMJQd\n\tg/spur/6V+UaiyOPuzn8U5N5FCPUyuE6VBJJRZRI=","Reply-To":"kieran.bingham@ideasonboard.com","To":"Jacopo Mondi <jacopo@jmondi.org>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","References":"<20190226162641.12116-1-jacopo@jmondi.org>\n\t<20190226162641.12116-8-jacopo@jmondi.org>\n\t<20190227184402.GQ4813@pendragon.ideasonboard.com>\n\t<20190228085455.jfypp6tpa7fvljzp@uno.localdomain>","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\tcSAZRx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GdK1kTAm2RTFg+w9oOp2Xjqfhds2PAhFFvrHQg1XfQR/UF/SjeUmaOmLSczM0s6XMeO\n\tVcE77UFtJ/+hLo4PRFKm5X1Pcar6g5m4xGqa+Xfzi9tRkwC29KMCoQOag1BhHChgqYaUH3yo\n\tUzaPwT/fY75iVI+yD0ih/e6j8qYvP8pvGwMQfrmN9YB0zB39YzCSdaUaNrWGD3iCBxg6lwSO\n\tLKeRhxxfiXCIYEf3vwOsP3YMx2JkD5doseXmWBGW1U0T/oJF+DVfKB6mv5UfsTzpVhJRgee7\n\t4jkjqFq4qsUGxcvF2xtRkfHFpZDbRgRlVmiWkqDkT4qMA+4q1y/dWwshSKi/uwVZNycuLsz+\n\t+OD8xPNCsMTqeUkAKfbD8xW4LCay3r/dD2ckoxRxtMD9eOAyu5wYzo/ydIPTh1QEj9SYyvp8\n\tO0g6CpxEwyHUQtF5oh15O018z3ZLztFJKR3RD42VKVsrnNDKnoY0f4U0z7eJv2NeF8xHMuiU\n\tRCIzqxX1GVYaNkKTnb/Qja8hnYnkUzY1Lc+OtwiGmXTwYsPZjjAaDX35J/RSKAoy5wGo/YFA\n\tJxB1gWThL4kOTbsqqXj9GLcyOImkW0lJGGR3o/fV91Zh63S5TKnf2YGGGzxki+ADdxVQAm+Q\n\tsbsRB8KNNvVXBOVNwko86rQqF9drZuw=","Organization":"Ideas on Board","Message-ID":"<302a435d-614a-5a67-56b9-ca60f480a549@ideasonboard.com>","Date":"Thu, 28 Feb 2019 10:15:16 +0000","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101\n\tThunderbird/60.4.0","MIME-Version":"1.0","In-Reply-To":"<20190228085455.jfypp6tpa7fvljzp@uno.localdomain>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH v3 7/8] test: v4l2_device: Add format\n\thandling test","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":"Thu, 28 Feb 2019 10:15:20 -0000"}},{"id":958,"web_url":"https://patchwork.libcamera.org/comment/958/","msgid":"<20190228172721.GE7811@pendragon.ideasonboard.com>","date":"2019-02-28T17:27:21","subject":"Re: [libcamera-devel] [PATCH v3 7/8] test: v4l2_device: Add format\n\thandling test","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn Thu, Feb 28, 2019 at 09:54:55AM +0100, Jacopo Mondi wrote:\n> On Wed, Feb 27, 2019 at 08:44:02PM +0200, Laurent Pinchart wrote:\n> > On Tue, Feb 26, 2019 at 05:26:40PM +0100, Jacopo Mondi wrote:\n> >> Add test for V4L2Device set and get format methods.\n> >>\n> >> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> >> ---\n> >>  test/v4l2_device/meson.build      |  1 +\n> >>  test/v4l2_device/test_formats.cpp | 65 +++++++++++++++++++++++++++++++\n> >>  2 files changed, 66 insertions(+)\n> >>  create mode 100644 test/v4l2_device/test_formats.cpp\n> >>\n> >> diff --git a/test/v4l2_device/meson.build b/test/v4l2_device/meson.build\n> >> index 9f7a7545ac9b..e5e50faac282 100644\n> >> --- a/test/v4l2_device/meson.build\n> >> +++ b/test/v4l2_device/meson.build\n> >> @@ -6,6 +6,7 @@ v4l2_device_tests = [\n> >>    [ 'stream_on_off',      'stream_on_off.cpp' ],\n> >>    [ 'capture_async',      'capture_async.cpp' ],\n> >>    [ 'buffer_sharing',     'buffer_sharing.cpp' ],\n> >> +  [ 'test_formats',\t  'test_formats.cpp' ],\n> >\n> > V4L2Device tests are soretd by order of increasing complexity, I think\n> > think this one should be last in the list.\n> >\n> \n> May I say this is not the most intuitive ordering method?\n> last in the complexity list == first in the array?\n\nSorry, I meant \"shoult not be last in the array\".\n\n> >>  ]\n> >>\n> >>  foreach t : v4l2_device_tests\n> >> diff --git a/test/v4l2_device/test_formats.cpp b/test/v4l2_device/test_formats.cpp\n> >> new file mode 100644\n> >> index 000000000000..dcb05a3904f7\n> >> --- /dev/null\n> >> +++ b/test/v4l2_device/test_formats.cpp\n> >> @@ -0,0 +1,65 @@\n> >> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> >> +/*\n> >> + * Copyright (C) 2019, Google Inc.\n> >> + *\n> >> + * libcamera V4L2 device format handling test\n> >> + */\n> >> +\n> >> +#include <climits>\n> >> +#include <iostream>\n> >> +\n> >> +#include \"v4l2_device.h\"\n> >> +\n> >> +#include \"v4l2_device_test.h\"\n> >> +\n> >> +using namespace std;\n> >> +using namespace libcamera;\n> >> +\n> >> +class Format : public V4L2DeviceTest\n> >> +{\n> >> +protected:\n> >> +\tint run();\n> >\n> > override\n> >\n> >> +};\n> >> +\n> >> +int Format::run()\n> >> +{\n> >> +\tV4L2DeviceFormat format = {};\n> >> +\n> >> +\tint ret = capture_->getFormat(&format);\n> >> +\tif (ret) {\n> >> +\t\tcerr << \"Failed to get format\" << endl;\n> >> +\t\treturn TestFail;\n> >> +\t}\n> >> +\n> >> +\tformat.width = UINT_MAX;\n> >> +\tformat.height = UINT_MAX;\n> >> +\tret = capture_->setFormat(&format);\n> >> +\tif (ret) {\n> >> +\t\tcerr << \"Failed to set format: image resolution is wrong, but \"\n> >> +\t\t     << \"setFormat() should not fail.\" << endl;\n> >> +\t\treturn TestFail;\n> >> +\t}\n> >> +\n> >> +\tif (format.width == UINT_MAX || format.height == UINT_MAX) {\n> >> +\t\tcerr << \"Failed to update image format\" << endl;\n> >> +\t\treturn TestFail;\n> >> +\t}\n> >> +\n> >> +\tformat.width = 0;\n> >> +\tformat.height = 0;\n> >> +\tret = capture_->setFormat(&format);\n> >> +\tif (ret) {\n> >> +\t\tcerr << \"Failed to set format: image resolution is wrong, but \"\n> >> +\t\t     << \"setFormat() should not fail.\" << endl;\n> >> +\t\treturn TestFail;\n> >> +\t}\n> >> +\n> >> +\tif (format.width == 0 || format.height == 0) {\n> >> +\t\tcerr << \"Failed to update image format\" << endl;\n> >> +\t\treturn TestFail;\n> >> +\t}\n> >> +\n> >> +\treturn TestPass;\n> >\n> > With Kieran's comment addressed,\n> >\n> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> >\n> > (I however wonder if we need both the 0 and UINT_MAX tests. Testing that\n> > the setFormat() function correctly updates the passed format is useful\n> > to test our implementation, but testing both 0 and UINT_MAX feels like\n> > testing the kernel instead, which is a bit out of scope)\n> \n> Ah, I re-wrote this stupid tests a million times, as everytime I did\n> something a bit more complex I was actually testing the kernel driver\n> instead of the library. This seemed to me as a compromise between\n> going for testing the driver and a test with no actual value, but I\n> can drop one of the cases.\n\nUp to you.\n\n> >> +}\n> >> +\n> >> +TEST_REGISTER(Format);","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 69C60610B6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Feb 2019 18:27:27 +0100 (CET)","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 E55BE49;\n\tThu, 28 Feb 2019 18:27:26 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1551374847;\n\tbh=4NhmpUV6hDvJnS2Sp1jX6wE5q4P7nymexkjwsRcbJNQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=oDwV5ZpWnrk/JlYhny8nRmhjOQpTQc+NJ3qjFzSo5OXBsywsE7DVzg/JCBBKrY3EL\n\tT0Tran419N62T7OYj5J2F04Jx3wyAP+g1kE4gPG3nOJFvl3A5R4CJlG5wFCbL0IuG/\n\to1SHDxK4qUSdtWuLo05zNmOrJOzzJe5x6CTjCXAU=","Date":"Thu, 28 Feb 2019 19:27:21 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190228172721.GE7811@pendragon.ideasonboard.com>","References":"<20190226162641.12116-1-jacopo@jmondi.org>\n\t<20190226162641.12116-8-jacopo@jmondi.org>\n\t<20190227184402.GQ4813@pendragon.ideasonboard.com>\n\t<20190228085455.jfypp6tpa7fvljzp@uno.localdomain>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190228085455.jfypp6tpa7fvljzp@uno.localdomain>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v3 7/8] test: v4l2_device: Add format\n\thandling test","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":"Thu, 28 Feb 2019 17:27:27 -0000"}}]