Patch Detail
Show a patch.
GET /api/1.1/patches/806/?format=api
{ "id": 806, "url": "https://patchwork.libcamera.org/api/1.1/patches/806/?format=api", "web_url": "https://patchwork.libcamera.org/patch/806/", "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": "<20190326083902.26121-12-jacopo@jmondi.org>", "date": "2019-03-26T08:38:54", "name": "[libcamera-devel,v5,11/19] libcamera: ipu3: Create ImgUDevice class", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "4595e6e1d18061bc5d2078e59d8c1ee3089d4ec6", "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/806/mbox/", "series": [ { "id": 219, "url": "https://patchwork.libcamera.org/api/1.1/series/219/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=219", "date": "2019-03-26T08:38:43", "name": "libcamera: ipu3: Add ImgU support", "version": 5, "mbox": "https://patchwork.libcamera.org/series/219/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/806/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/806/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay10.mail.gandi.net (relay10.mail.gandi.net\n\t[217.70.178.230])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 665F56110D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 Mar 2019 09:38:37 +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 relay10.mail.gandi.net (Postfix) with ESMTPSA id E32ED240011;\n\tTue, 26 Mar 2019 08:38:36 +0000 (UTC)" ], "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 26 Mar 2019 09:38:54 +0100", "Message-Id": "<20190326083902.26121-12-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.21.0", "In-Reply-To": "<20190326083902.26121-1-jacopo@jmondi.org>", "References": "<20190326083902.26121-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v5 11/19] libcamera: ipu3: Create\n\tImgUDevice class", "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 Mar 2019 08:38:37 -0000" }, "content": "Group ImgU components in a class associated with a camera at camera\nregistration time and provide an intialization method to create and open\nall video devices and subdevices of the ImgU.\n\nStatically assign imgu0 to the first camera and imgu1 to the second one\nand limit support to two cameras. This will have to be revised in the future.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/pipeline/ipu3/ipu3.cpp | 154 +++++++++++++++++++++++++--\n 1 file changed, 145 insertions(+), 9 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 21205b39afee..0a059b75cadf 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -44,6 +44,43 @@ static int mediaBusToCIO2Format(unsigned int code)\n \t}\n }\n \n+class ImgUDevice\n+{\n+public:\n+\tstatic constexpr unsigned int PAD_INPUT = 0;\n+\tstatic constexpr unsigned int PAD_OUTPUT = 2;\n+\tstatic constexpr unsigned int PAD_VF = 3;\n+\tstatic constexpr unsigned int PAD_STAT = 4;\n+\n+\tImgUDevice()\n+\t\t: imgu_(nullptr), input_(nullptr), output_(nullptr),\n+\t\t viewfinder_(nullptr), stat_(nullptr)\n+\t{\n+\t}\n+\n+\t~ImgUDevice()\n+\t{\n+\t\tdelete imgu_;\n+\t\tdelete input_;\n+\t\tdelete output_;\n+\t\tdelete viewfinder_;\n+\t\tdelete stat_;\n+\t}\n+\n+\tint init(MediaDevice *media, unsigned int index);\n+\n+\tunsigned int index_;\n+\tstd::string name_;\n+\tMediaDevice *media_;\n+\n+\tV4L2Subdevice *imgu_;\n+\tV4L2Device *input_;\n+\tV4L2Device *output_;\n+\tV4L2Device *viewfinder_;\n+\tV4L2Device *stat_;\n+\t/* \\todo Add param video device for 3A tuning */\n+};\n+\n class CIO2Device\n {\n public:\n@@ -106,6 +143,7 @@ private:\n \t\tvoid bufferReady(Buffer *buffer);\n \n \t\tCIO2Device cio2_;\n+\t\tImgUDevice *imgu_;\n \n \t\tStream stream_;\n \t};\n@@ -116,8 +154,10 @@ private:\n \t\t\tPipelineHandler::cameraData(camera));\n \t}\n \n-\tvoid registerCameras();\n+\tint registerCameras();\n \n+\tImgUDevice imgu0_;\n+\tImgUDevice imgu1_;\n \tstd::shared_ptr<MediaDevice> cio2MediaDev_;\n \tstd::shared_ptr<MediaDevice> imguMediaDev_;\n };\n@@ -303,6 +343,8 @@ int PipelineHandlerIPU3::queueRequest(Camera *camera, Request *request)\n \n bool PipelineHandlerIPU3::match(DeviceEnumerator *enumerator)\n {\n+\tint ret;\n+\n \tDeviceMatch cio2_dm(\"ipu3-cio2\");\n \tcio2_dm.add(\"ipu3-csi2 0\");\n \tcio2_dm.add(\"ipu3-cio2 0\");\n@@ -358,36 +400,75 @@ bool PipelineHandlerIPU3::match(DeviceEnumerator *enumerator)\n \t\treturn false;\n \t}\n \n-\tregisterCameras();\n+\tif (imguMediaDev_->open()) {\n+\t\tcio2MediaDev_->close();\n+\t\treturn false;\n+\t}\n+\n+\tif (imguMediaDev_->disableLinks())\n+\t\tgoto error;\n+\n+\tret = registerCameras();\n+\tif (ret)\n+\t\tgoto error;\n \n \tcio2MediaDev_->close();\n+\timguMediaDev_->close();\n \n \treturn true;\n+\n+error:\n+\tcio2MediaDev_->close();\n+\timguMediaDev_->close();\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+ * \\brief Initialize ImgU devices and CIO2 ones associated with cameras\n+ *\n+ * Initialize the two ImgU instances and create cameras with an associated\n+ * CIO2 device instance.\n+ *\n+ * \\return 0 on success or a negative error code for error or if no camera\n+ * has been created\n+ * \\retval -ENODEV no camera has been created\n */\n-void PipelineHandlerIPU3::registerCameras()\n+int PipelineHandlerIPU3::registerCameras()\n {\n+\tint ret;\n+\n+\tret = imgu0_.init(imguMediaDev_.get(), 0);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = imgu1_.init(imguMediaDev_.get(), 1);\n+\tif (ret)\n+\t\treturn ret;\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 and it can produce images in\n \t * a compatible format.\n \t */\n \tunsigned int numCameras = 0;\n-\tfor (unsigned int id = 0; id < 4; ++id) {\n+\tfor (unsigned int id = 0; id < 4 && numCameras < 2; ++id) {\n \t\tstd::unique_ptr<IPU3CameraData> data =\n \t\t\tutils::make_unique<IPU3CameraData>(this);\n \t\tstd::set<Stream *> streams{ &data->stream_ };\n \t\tCIO2Device *cio2 = &data->cio2_;\n \n-\t\tint ret = cio2->init(cio2MediaDev_.get(), id);\n+\t\tret = cio2->init(cio2MediaDev_.get(), id);\n \t\tif (ret)\n \t\t\tcontinue;\n \n+\t\t/**\n+\t\t * \\todo Dynamically assign ImgU devices; as of now, limit\n+\t\t * support to two cameras only, and assign imgu0 to the first\n+\t\t * one and imgu1 to the second.\n+\t\t */\n+\t\tdata->imgu_ = numCameras ? &imgu1_ : &imgu0_;\n+\n \t\tstd::string cameraName = cio2->name() + \" \"\n \t\t\t\t + std::to_string(id);\n \t\tstd::shared_ptr<Camera> camera = Camera::create(this,\n@@ -406,6 +487,8 @@ void PipelineHandlerIPU3::registerCameras()\n \n \t\tnumCameras++;\n \t}\n+\n+\treturn numCameras ? 0 : -ENODEV;\n }\n \n void PipelineHandlerIPU3::IPU3CameraData::bufferReady(Buffer *buffer)\n@@ -416,6 +499,59 @@ void PipelineHandlerIPU3::IPU3CameraData::bufferReady(Buffer *buffer)\n \tpipe_->completeRequest(camera_, request);\n }\n \n+/* -----------------------------------------------------------------------------\n+ * ImgU Device\n+ */\n+\n+/**\n+ * \\brief Initialize components of the ImgU instance\n+ * \\param[in] mediaDevice The ImgU instance media device\n+ * \\param[in] index The ImgU instance index\n+ *\n+ * Create and open the V4L2 devices and subdevices of the ImgU instance\n+ * with \\a index.\n+ *\n+ * In case of errors the created V4L2Device and V4L2Subdevice instances\n+ * are destroyed at pipeline handler delete time.\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+int ImgUDevice::init(MediaDevice *media, unsigned int index)\n+{\n+\tint ret;\n+\n+\tindex_ = index;\n+\tname_ = \"ipu3-imgu \" + std::to_string(index_);\n+\tmedia_ = media;\n+\n+\timgu_ = V4L2Subdevice::fromEntityName(media, name_);\n+\tret = imgu_->open();\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tinput_ = V4L2Device::fromEntityName(media, name_ + \" input\");\n+\tret = input_->open();\n+\tif (ret)\n+\t\treturn ret;\n+\n+\toutput_ = V4L2Device::fromEntityName(media, name_ + \" output\");\n+\tret = output_->open();\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tviewfinder_ = V4L2Device::fromEntityName(media, name_ + \" viewfinder\");\n+\tret = viewfinder_->open();\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tstat_ = V4L2Device::fromEntityName(media, name_ + \" 3a stat\");\n+\tret = stat_->open();\n+\tif (ret)\n+\t\treturn ret;\n+\n+\treturn 0;\n+}\n+\n /*------------------------------------------------------------------------------\n * CIO2 Device\n */\n", "prefixes": [ "libcamera-devel", "v5", "11/19" ] }