Patch Detail
Show a patch.
GET /api/1.1/patches/290/?format=api
{ "id": 290, "url": "https://patchwork.libcamera.org/api/1.1/patches/290/?format=api", "web_url": "https://patchwork.libcamera.org/patch/290/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20190121105725.8351-2-jacopo@jmondi.org>", "date": "2019-01-21T10:57:24", "name": "[libcamera-devel,v3,1/2] libcamera: pipeline: Add Intel IPU3 pipeline", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "c5206f0781a712cafa94469e3e344e31e3dd221d", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/290/mbox/", "series": [ { "id": 99, "url": "https://patchwork.libcamera.org/api/1.1/series/99/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=99", "date": "2019-01-21T10:57:23", "name": "libcamera: pipeline: Add Intel IPU3 pipeline handler", "version": 3, "mbox": "https://patchwork.libcamera.org/series/99/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/290/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/290/checks/", "tags": {}, "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 E44CD60B21\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Jan 2019 11:57:21 +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 relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 7F4C860004;\n\tMon, 21 Jan 2019 10:57:21 +0000 (UTC)" ], "X-Originating-IP": "2.224.242.101", "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 21 Jan 2019 11:57:24 +0100", "Message-Id": "<20190121105725.8351-2-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20190121105725.8351-1-jacopo@jmondi.org>", "References": "<20190121105725.8351-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 1/2] libcamera: pipeline: Add Intel\n\tIPU3 pipeline", "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 10:57:22 -0000" }, "content": "Add a pipeline handler for the Intel IPU3 device.\n\nThe pipeline handler creates a Camera for each image sensor it finds to be\nconnected to an IPU3 CSI-2 receiver, and enables the link between the two.\n\nTested on Soraka, listing detected cameras on the system, verifying the\npipeline handler gets matched and links properly enabled.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/pipeline/ipu3/ipu3.cpp | 216 ++++++++++++++++++++++++\n src/libcamera/pipeline/ipu3/meson.build | 3 +\n src/libcamera/pipeline/meson.build | 2 +\n 3 files changed, 221 insertions(+)\n create mode 100644 src/libcamera/pipeline/ipu3/ipu3.cpp\n create mode 100644 src/libcamera/pipeline/ipu3/meson.build", "diff": "diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nnew file mode 100644\nindex 0000000..2081743\n--- /dev/null\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -0,0 +1,216 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * ipu3.cpp - Pipeline handler for Intel IPU3\n+ */\n+\n+#include <memory>\n+#include <vector>\n+\n+#include <libcamera/camera.h>\n+#include <libcamera/camera_manager.h>\n+\n+#include \"device_enumerator.h\"\n+#include \"log.h\"\n+#include \"media_device.h\"\n+#include \"pipeline_handler.h\"\n+\n+namespace libcamera {\n+\n+class PipelineHandlerIPU3 : public PipelineHandler\n+{\n+public:\n+\tPipelineHandlerIPU3();\n+\t~PipelineHandlerIPU3();\n+\n+\tbool match(CameraManager *manager, DeviceEnumerator *enumerator);\n+\n+private:\n+\tMediaDevice *cio2_;\n+\tMediaDevice *imgu_;\n+\n+\tvoid registerCameras(CameraManager *manager);\n+};\n+\n+PipelineHandlerIPU3::PipelineHandlerIPU3()\n+\t: cio2_(nullptr), imgu_(nullptr)\n+{\n+}\n+\n+PipelineHandlerIPU3::~PipelineHandlerIPU3()\n+{\n+\tif (cio2_)\n+\t\tcio2_->release();\n+\n+\tif (imgu_)\n+\t\timgu_->release();\n+\n+\tcio2_ = nullptr;\n+\timgu_ = nullptr;\n+}\n+\n+bool PipelineHandlerIPU3::match(CameraManager *manager, DeviceEnumerator *enumerator)\n+{\n+\tDeviceMatch cio2_dm(\"ipu3-cio2\");\n+\tcio2_dm.add(\"ipu3-csi2 0\");\n+\tcio2_dm.add(\"ipu3-cio2 0\");\n+\tcio2_dm.add(\"ipu3-csi2 1\");\n+\tcio2_dm.add(\"ipu3-cio2 1\");\n+\tcio2_dm.add(\"ipu3-csi2 2\");\n+\tcio2_dm.add(\"ipu3-cio2 2\");\n+\tcio2_dm.add(\"ipu3-csi2 3\");\n+\tcio2_dm.add(\"ipu3-cio2 3\");\n+\n+\tDeviceMatch imgu_dm(\"ipu3-imgu\");\n+\timgu_dm.add(\"ipu3-imgu 0\");\n+\timgu_dm.add(\"ipu3-imgu 0 input\");\n+\timgu_dm.add(\"ipu3-imgu 0 parameters\");\n+\timgu_dm.add(\"ipu3-imgu 0 output\");\n+\timgu_dm.add(\"ipu3-imgu 0 viewfinder\");\n+\timgu_dm.add(\"ipu3-imgu 0 3a stat\");\n+\timgu_dm.add(\"ipu3-imgu 1\");\n+\timgu_dm.add(\"ipu3-imgu 1 input\");\n+\timgu_dm.add(\"ipu3-imgu 1 parameters\");\n+\timgu_dm.add(\"ipu3-imgu 1 output\");\n+\timgu_dm.add(\"ipu3-imgu 1 viewfinder\");\n+\timgu_dm.add(\"ipu3-imgu 1 3a stat\");\n+\n+\tcio2_ = enumerator->search(cio2_dm);\n+\tif (!cio2_)\n+\t\treturn false;\n+\n+\timgu_ = enumerator->search(imgu_dm);\n+\tif (!imgu_)\n+\t\treturn false;\n+\n+\t/*\n+\t * It is safe to acquire both media devices at this point as\n+\t * DeviceEnumerator::search() skips the busy ones for us.\n+\t */\n+\tcio2_->acquire();\n+\timgu_->acquire();\n+\n+\t/*\n+\t * Disable all links that are enabled by default on CIO2, as camera\n+\t * creation enables all valid links it finds.\n+\t *\n+\t * Close the CIO2 media device after, as links are enabled and should\n+\t * not need to be changed after.\n+\t */\n+\tif (cio2_->open())\n+\t\tgoto error_release_mdev;\n+\n+\tif (cio2_->disableLinks())\n+\t\tgoto error_close_cio2;\n+\n+\tregisterCameras(manager);\n+\tLOG(Debug) << \"\\\"Intel IPU3\\\" pipeline handler initialized\";\n+\n+\tcio2_->close();\n+\n+\treturn true;\n+\n+error_close_cio2:\n+\tcio2_->close();\n+\n+error_release_mdev:\n+\tcio2_->release();\n+\timgu_->release();\n+\n+\treturn false;\n+}\n+\n+/*\n+ * Cameras are created associating an image sensor (represented by a\n+ * media entity with function MEDIA_ENT_F_CAM_SENSOR) to one of the four\n+ * CIO2 CSI-2 receivers.\n+ */\n+void PipelineHandlerIPU3::registerCameras(CameraManager *manager)\n+{\n+\tconst std::vector<MediaEntity *> entities = cio2_->entities();\n+\tstruct {\n+\t\tunsigned int id;\n+\t\tMediaEntity *csi2;\n+\t} csi2Receivers[] = {\n+\t\t{ 0, cio2_->getEntityByName(\"ipu3-csi2 0\") },\n+\t\t{ 1, cio2_->getEntityByName(\"ipu3-csi2 1\") },\n+\t\t{ 2, cio2_->getEntityByName(\"ipu3-csi2 2\") },\n+\t\t{ 3, cio2_->getEntityByName(\"ipu3-csi2 3\") },\n+\t};\n+\n+\t/*\n+\t * For each CSI-2 receiver on the IPU3, create a Camera if an\n+\t * image sensor is connected to it.\n+\t */\n+\tunsigned int numCameras = 0;\n+\tfor (auto csi2Receiver : csi2Receivers) {\n+\t\tMediaEntity *csi2 = csi2Receiver.csi2;\n+\t\tunsigned int id = csi2Receiver.id;\n+\n+\t\t/*\n+\t\t * This shall not happen, as the device enumerator matched\n+\t\t * all entities described in the cio2_dm DeviceMatch.\n+\t\t *\n+\t\t * As this check is basically free, better stay safe than sorry.\n+\t\t */\n+\t\tif (!csi2)\n+\t\t\tcontinue;\n+\n+\t\tstd::vector<MediaPad *> pads = csi2->pads();\n+\t\tMediaPad *sink;\n+\t\tfor (MediaPad *pad : pads) {\n+\t\t\tif (!(pad->flags() & MEDIA_PAD_FL_SINK))\n+\t\t\t\tcontinue;\n+\n+\t\t\t/* IPU3 CSI-2 receivers have a single sink pad. */\n+\t\t\tsink = pad;\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tstd::vector<MediaLink *> links = sink->links();\n+\t\tif (links.empty())\n+\t\t\tcontinue;\n+\n+\t\t/*\n+\t\t * Verify that the receiver is connected to a sensor, enable\n+\t\t * the media link between the two, and create a Camera with\n+\t\t * a unique name.\n+\t\t *\n+\t\t * FIXME: This supports creating a single camera per CSI-2 receiver.\n+\t\t */\n+\t\tfor (MediaLink *link : links) {\n+\t\t\t/* Again, this shall not happen, but better stay safe. */\n+\t\t\tif (!link->source())\n+\t\t\t\tcontinue;\n+\n+\t\t\tMediaEntity *sensor = link->source()->entity();\n+\t\t\tif (!sensor)\n+\t\t\t\tcontinue;\n+\n+\t\t\tif (sensor->function() != MEDIA_ENT_F_CAM_SENSOR)\n+\t\t\t\tcontinue;\n+\n+\t\t\tif (link->setEnabled(true))\n+\t\t\t\tcontinue;\n+\n+\t\t\tstd::size_t pos = sensor->name().find(\" \");\n+\t\t\tstd::string cameraName = sensor->name().substr(0, pos);\n+\t\t\tcameraName += \" \" + std::to_string(id);\n+\n+\t\t\tstd::shared_ptr<Camera> camera = Camera::create(cameraName);\n+\t\t\tmanager->addCamera(std::move(camera));\n+\n+\t\t\tLOG(Info) << \"Registered Camera[\" << numCameras\n+\t\t\t\t << \"] \\\"\" << cameraName << \"\\\"\"\n+\t\t\t\t << \" connected to CSI-2 receiver \" << id;\n+\n+\t\t\tnumCameras++;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+}\n+\n+REGISTER_PIPELINE_HANDLER(PipelineHandlerIPU3);\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/pipeline/ipu3/meson.build b/src/libcamera/pipeline/ipu3/meson.build\nnew file mode 100644\nindex 0000000..0ab766a\n--- /dev/null\n+++ b/src/libcamera/pipeline/ipu3/meson.build\n@@ -0,0 +1,3 @@\n+libcamera_sources += files([\n+ 'ipu3.cpp',\n+])\ndiff --git a/src/libcamera/pipeline/meson.build b/src/libcamera/pipeline/meson.build\nindex 615ecd2..811c075 100644\n--- a/src/libcamera/pipeline/meson.build\n+++ b/src/libcamera/pipeline/meson.build\n@@ -1,3 +1,5 @@\n libcamera_sources += files([\n 'vimc.cpp',\n ])\n+\n+subdir('ipu3')\n", "prefixes": [ "libcamera-devel", "v3", "1/2" ] }