{"id":691,"url":"https://patchwork.libcamera.org/api/patches/691/?format=json","web_url":"https://patchwork.libcamera.org/patch/691/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190301115139.11060-3-jacopo@jmondi.org>","date":"2019-03-01T11:51:36","name":"[libcamera-devel,v6,2/5] test: v4l2_subdevice: Add ListFormat test","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"99e8d0e869dfc1222b343adf447d8257022a9c27","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/691/mbox/","series":[{"id":200,"url":"https://patchwork.libcamera.org/api/series/200/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=200","date":"2019-03-01T11:51:34","name":"v4l2_(sub)dev: improvements and tests","version":6,"mbox":"https://patchwork.libcamera.org/series/200/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/691/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/691/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net\n\t[217.70.183.198])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 824F3610C3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  1 Mar 2019 12:52:45 +0100 (CET)","from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay6-d.mail.gandi.net (Postfix) with ESMTPSA id D389CC0014;\n\tFri,  1 Mar 2019 11:52:43 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri,  1 Mar 2019 12:51:36 +0100","Message-Id":"<20190301115139.11060-3-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20190301115139.11060-1-jacopo@jmondi.org>","References":"<20190301115139.11060-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v6 2/5] test: v4l2_subdevice: Add\n\tListFormat 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":"Fri, 01 Mar 2019 11:52:45 -0000"},"content":"Add test to list formats on a v4l2 subdevice.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n test/v4l2_subdevice/list_formats.cpp | 81 ++++++++++++++++++++++++++++\n test/v4l2_subdevice/meson.build      |  1 +\n 2 files changed, 82 insertions(+)\n create mode 100644 test/v4l2_subdevice/list_formats.cpp","diff":"diff --git a/test/v4l2_subdevice/list_formats.cpp b/test/v4l2_subdevice/list_formats.cpp\nnew file mode 100644\nindex 000000000000..b4eab68f9f7e\n--- /dev/null\n+++ b/test/v4l2_subdevice/list_formats.cpp\n@@ -0,0 +1,81 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * libcamera V4L2 Subdevice format handling test\n+ */\n+\n+#include <iomanip>\n+#include <iostream>\n+#include <vector>\n+\n+#include \"geometry.h\"\n+#include \"v4l2_subdevice.h\"\n+#include \"v4l2_subdevice_test.h\"\n+\n+using namespace std;\n+using namespace libcamera;\n+\n+/* List image formats on the \"Scaler\" subdevice of vimc media device.  */\n+\n+class ListFormatsTest : public V4L2SubdeviceTest\n+{\n+protected:\n+\tint run() override;\n+\n+private:\n+\tvoid printFormats(unsigned int pad, unsigned code,\n+\t\t\t  std::vector<SizeRange> &formats);\n+};\n+\n+void ListFormatsTest::printFormats(unsigned int pad,\n+\t\t\t\t   unsigned int code,\n+\t\t\t\t   std::vector<SizeRange> &sizes)\n+{\n+\tcout << \"Enumerate formats on pad \" << pad << endl;\n+\tfor (SizeRange &size : sizes) {\n+\t\tcout << \"\tmbus code: 0x\" << setfill('0') << setw(4)\n+\t\t     << hex << code << endl;\n+\t\tcout << \"\tmin width: \" << dec << size.minWidth << endl;\n+\t\tcout << \"\tmin height: \" << dec << size.minHeight << endl;\n+\t\tcout << \"\tmax width: \" << dec << size.maxWidth << endl;\n+\t\tcout << \"\tmax height: \" << dec << size.maxHeight << endl;\n+\t}\n+}\n+\n+int ListFormatsTest::run()\n+{\n+\t/* List all formats available on existing \"Scaler\" pads. */\n+\tstd::map<unsigned int, std::vector<SizeRange>> formats;\n+\n+\tformats = scaler_->formats(0);\n+\tif (formats.size() == 0) {\n+\t\tcerr << \"Failed to list formats on pad 0 of subdevice \"\n+\t\t     << scaler_->deviceName() << endl;\n+\t\treturn TestFail;\n+\t}\n+\tfor (auto it = formats.begin(); it != formats.end(); ++it)\n+\t\tprintFormats(0, it->first, it->second);\n+\n+\tformats = scaler_->formats(1);\n+\tif (formats.size() == 0) {\n+\t\tcerr << \"Failed to list formats on pad 1 of subdevice \"\n+\t\t     << scaler_->deviceName() << endl;\n+\t\treturn TestFail;\n+\t}\n+\tfor (auto it = formats.begin(); it != formats.end(); ++it)\n+\t\tprintFormats(1, it->first, it->second);\n+\n+\t/* List format on a non-existing pad, format vector shall be empty. */\n+\tformats = scaler_->formats(2);\n+\tif (formats.size() != 0) {\n+\t\tcerr << \"Listing formats on non-existing pad 2 of subdevice \"\n+\t\t     << scaler_->deviceName()\n+\t\t     << \" should return an empty format list\" << endl;\n+\t\treturn TestFail;\n+\t}\n+\n+\treturn TestPass;\n+}\n+\n+TEST_REGISTER(ListFormatsTest);\ndiff --git a/test/v4l2_subdevice/meson.build b/test/v4l2_subdevice/meson.build\nindex f45dca0d23d7..80cfbbbf9413 100644\n--- a/test/v4l2_subdevice/meson.build\n+++ b/test/v4l2_subdevice/meson.build\n@@ -1,4 +1,5 @@\n v4l2_subdevice_tests = [\n+  [ 'list_formats',             'list_formats.cpp'],\n   [ 'test_formats',             'test_formats.cpp'],\n ]\n \n","prefixes":["libcamera-devel","v6","2/5"]}