{"id":295,"url":"https://patchwork.libcamera.org/api/1.1/patches/295/?format=json","web_url":"https://patchwork.libcamera.org/patch/295/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20190121150756.14982-3-jacopo@jmondi.org>","date":"2019-01-21T15:07:56","name":"[libcamera-devel,v4,2/2] test: pipeline: IPU3: Add IPU3 pipeline test","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"894d68a64851aa16d823aa9280abb6bcbd4f411b","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/295/mbox/","series":[{"id":101,"url":"https://patchwork.libcamera.org/api/1.1/series/101/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=101","date":"2019-01-21T15:07:54","name":"libcamera: pipeline: Add Intel IPU3 pipeline handler","version":4,"mbox":"https://patchwork.libcamera.org/series/101/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/295/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/295/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay12.mail.gandi.net (relay12.mail.gandi.net\n\t[217.70.178.232])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EBF0860C83\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Jan 2019 16:08:01 +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 relay12.mail.gandi.net (Postfix) with ESMTPSA id 7FE3320000E;\n\tMon, 21 Jan 2019 15:08:01 +0000 (UTC)"],"From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 21 Jan 2019 16:07:56 +0100","Message-Id":"<20190121150756.14982-3-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20190121150756.14982-1-jacopo@jmondi.org>","References":"<20190121150756.14982-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 2/2] test: pipeline: IPU3: Add IPU3\n\tpipeline 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":"Mon, 21 Jan 2019 15:08:02 -0000"},"content":"Add test for the Intel IPU3 pipeline that lists all the cameras\nregistered in the system and verifies the result matches the expected.\n\nThis test is meant to be run on IPU3 platforms, it gets skipped\notherwise.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n test/meson.build                          |   3 +\n test/pipeline/ipu3/ipu3_pipeline_test.cpp | 140 ++++++++++++++++++++++\n test/pipeline/ipu3/meson.build            |  11 ++\n test/pipeline/meson.build                 |   1 +\n 4 files changed, 155 insertions(+)\n create mode 100644 test/pipeline/ipu3/ipu3_pipeline_test.cpp\n create mode 100644 test/pipeline/ipu3/meson.build\n create mode 100644 test/pipeline/meson.build","diff":"diff --git a/test/meson.build b/test/meson.build\nindex fb6b115..594082a 100644\n--- a/test/meson.build\n+++ b/test/meson.build\n@@ -1,6 +1,9 @@\n subdir('libtest')\n \n subdir('media_device')\n+\n+subdir('pipeline')\n+\n subdir('v4l2_device')\n \n public_tests = [\ndiff --git a/test/pipeline/ipu3/ipu3_pipeline_test.cpp b/test/pipeline/ipu3/ipu3_pipeline_test.cpp\nnew file mode 100644\nindex 0000000..deaee40\n--- /dev/null\n+++ b/test/pipeline/ipu3/ipu3_pipeline_test.cpp\n@@ -0,0 +1,140 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2018, Google Inc.\n+ *\n+ * ipu3_pipeline_test.cpp - Intel IPU3 pipeline test\n+ */\n+\n+#include <iostream>\n+\n+#include <sys/types.h>\n+#include <sys/stat.h>\n+#include <unistd.h>\n+\n+#include <libcamera/camera.h>\n+#include <libcamera/camera_manager.h>\n+\n+#include \"media_device.h\"\n+#include \"media_object.h\"\n+#include \"test.h\"\n+\n+using namespace std;\n+using namespace libcamera;\n+\n+/*\n+ * Verify that the Intel IPU3 pipeline handler gets matched and cameras\n+ * are enumerated correctly.\n+ *\n+ * The test is supposed to be run on an IPU3 platform, otherwise it gets\n+ * skipped.\n+ *\n+ * The test lists all cameras registered in the system, if any camera is\n+ * available at all.\n+ */\n+class IPU3PipelineTest : public Test\n+{\n+protected:\n+\tint init();\n+\tint run();\n+\tvoid cleanup();\n+\n+private:\n+\tCameraManager *cameraManager_;\n+\tunsigned int sensors_;\n+};\n+\n+int IPU3PipelineTest::init()\n+{\n+\tconst string devnode(\"/dev/media\");\n+\tbool cio2 = false;\n+\tbool imgu = false;\n+\tunsigned int i;\n+\tint ret;\n+\n+\tsensors_ = 0;\n+\n+\t/*\n+\t * Test all media devices from /dev/media0 to /dev/media256.\n+\t * Media device numbering might not be continue, and we cannot stop\n+\t * as soon as we hit a non accessible media device.\n+\t */\n+\tfor (i = 0; i < 256; i++) {\n+\t\tstring mediadev = devnode + to_string(i);\n+\t\tstruct stat pstat = { };\n+\n+\t\tif (stat(mediadev.c_str(), &pstat))\n+\t\t\tcontinue;\n+\n+\t\tMediaDevice dev(mediadev);\n+\t\tif (dev.open()) {\n+\t\t\tcerr << \"Failed to open media device \" << mediadev << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tif (dev.driver() == \"ipu3-imgu\") {\n+\t\t\timgu = true;\n+\t\t} else if (dev.driver() == \"ipu3-cio2\") {\n+\t\t\t/*\n+\t\t\t * Camera sensor are connected to the CIO2 unit.\n+\t\t\t * Count how many sensors are connected in the system\n+\t\t\t * and later verify this matches the number of registered\n+\t\t\t * cameras.\n+\t\t\t */\n+\t\t\tret = dev.populate();\n+\t\t\tif (ret) {\n+\t\t\t\tcerr << \"Failed to populate media device \" << dev.devnode() << endl;\n+\t\t\t\treturn TestFail;\n+\t\t\t}\n+\n+\t\t\tvector<MediaEntity *> entities = dev.entities();\n+\t\t\tfor (MediaEntity *entity : entities) {\n+\t\t\t\tif (entity->function() == MEDIA_ENT_F_CAM_SENSOR)\n+\t\t\t\t\tsensors_++;\n+\t\t\t}\n+\n+\t\t\tcio2 = true;\n+\t\t}\n+\n+\t\tdev.close();\n+\n+\t\tif (imgu && cio2)\n+\t\t\tbreak;\n+\t}\n+\n+\t/* Not running on an IPU3 system: skip test. */\n+\tif (!(imgu && cio2))\n+\t\treturn TestSkip;\n+\n+\tcameraManager_ = CameraManager::instance();\n+\tret = cameraManager_->start();\n+\tif (ret) {\n+\t\tcerr << \"Failed to start the CameraManager\" << endl;\n+\t\treturn TestFail;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+int IPU3PipelineTest::run()\n+{\n+\tunsigned int cameras = 0;\n+\tfor (const shared_ptr<Camera> &cam : cameraManager_->cameras()) {\n+\t\tcout << \"Found camera '\" << cam->name() << \"'\" << endl;\n+\t\tcameras++;\n+\t}\n+\n+\tif (cameras != sensors_) {\n+\t\tcerr << cameras << \" cameras registered, but \" << sensors_\n+\t\t     << \" were expected\" << endl;\n+\t\treturn TestFail;\n+\t}\n+\n+\treturn TestPass;\n+}\n+\n+void IPU3PipelineTest::cleanup()\n+{\n+\tcameraManager_->stop();\n+}\n+\n+TEST_REGISTER(IPU3PipelineTest)\ndiff --git a/test/pipeline/ipu3/meson.build b/test/pipeline/ipu3/meson.build\nnew file mode 100644\nindex 0000000..caba5c7\n--- /dev/null\n+++ b/test/pipeline/ipu3/meson.build\n@@ -0,0 +1,11 @@\n+ipu3_test = [\n+    ['ipu3_pipeline_test',\t      'ipu3_pipeline_test.cpp'],\n+]\n+\n+foreach t : ipu3_test\n+    exe = executable(t[0], t[1],\n+                     link_with : test_libraries,\n+                     include_directories : test_includes_internal)\n+\n+    test(t[0], exe, suite: 'ipu3', is_parallel: false)\n+endforeach\ndiff --git a/test/pipeline/meson.build b/test/pipeline/meson.build\nnew file mode 100644\nindex 0000000..f434c79\n--- /dev/null\n+++ b/test/pipeline/meson.build\n@@ -0,0 +1 @@\n+subdir('ipu3')\n","prefixes":["libcamera-devel","v4","2/2"]}