{"id":3895,"url":"https://patchwork.libcamera.org/api/1.1/patches/3895/?format=json","web_url":"https://patchwork.libcamera.org/patch/3895/","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":"<20200602013909.3170593-7-niklas.soderlund@ragnatech.se>","date":"2020-06-02T01:39:05","name":"[libcamera-devel,06/10] libcamera: ipu3: cio2: Move the CIO2Device class to separate files","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"9e6073c1a58342f32ff71339f03489800f94106f","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/1.1/people/5/?format=json","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/3895/mbox/","series":[{"id":943,"url":"https://patchwork.libcamera.org/api/1.1/series/943/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=943","date":"2020-06-02T01:38:59","name":"libcamera: ipu3: Allow zero-copy RAW stream","version":1,"mbox":"https://patchwork.libcamera.org/series/943/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3895/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3895/checks/","tags":{},"headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net\n\t[195.74.38.229])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7BA8861080\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Jun 2020 03:39:31 +0200 (CEST)","from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de\n\t[79.202.35.146]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA\n\tid d5c542fa-a471-11ea-a73e-0050569116f7;\n\tTue, 02 Jun 2020 03:39:01 +0200 (CEST)"],"X-Halon-ID":"d5c542fa-a471-11ea-a73e-0050569116f7","Authorized-sender":"niklas@soderlund.pp.se","From":"=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue,  2 Jun 2020 03:39:05 +0200","Message-Id":"<20200602013909.3170593-7-niklas.soderlund@ragnatech.se>","X-Mailer":"git-send-email 2.26.2","In-Reply-To":"<20200602013909.3170593-1-niklas.soderlund@ragnatech.se>","References":"<20200602013909.3170593-1-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 06/10] libcamera: ipu3: cio2: Move the\n\tCIO2Device class to separate files","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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, 02 Jun 2020 01:39:33 -0000"},"content":"In preparation of refactoring the IPU3 pipeline handler breakout the\nCIO2Device into its own .cpp and .h file, no functional change.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/libcamera/pipeline/ipu3/cio2.cpp    | 233 ++++++++++++++++++++++\n src/libcamera/pipeline/ipu3/cio2.h      |  64 ++++++\n src/libcamera/pipeline/ipu3/ipu3.cpp    | 249 +-----------------------\n src/libcamera/pipeline/ipu3/meson.build |   1 +\n 4 files changed, 300 insertions(+), 247 deletions(-)\n create mode 100644 src/libcamera/pipeline/ipu3/cio2.cpp\n create mode 100644 src/libcamera/pipeline/ipu3/cio2.h","diff":"diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp\nnew file mode 100644\nindex 0000000000000000..113486e3e3d0f2f1\n--- /dev/null\n+++ b/src/libcamera/pipeline/ipu3/cio2.cpp\n@@ -0,0 +1,233 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2020, Google Inc.\n+ *\n+ * cio2.cpp - Intel IPU3 CIO2\n+ */\n+\n+#include \"cio2.h\"\n+\n+namespace libcamera {\n+\n+LOG_DECLARE_CATEGORY(IPU3)\n+\n+/**\n+ * \\brief Initialize components of the CIO2 device with \\a index\n+ * \\param[in] media The CIO2 media device\n+ * \\param[in] index The CIO2 device index\n+ *\n+ * Create and open the video device and subdevices in the CIO2 instance at \\a\n+ * index, if a supported image sensor is connected to the CSI-2 receiver of\n+ * this CIO2 instance.  Enable the media links connecting the CIO2 components\n+ * to prepare for capture operations and cached the sensor maximum size.\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ * \\retval -ENODEV No supported image sensor is connected to this CIO2 instance\n+ */\n+int CIO2Device::init(const MediaDevice *media, unsigned int index)\n+{\n+\tint ret;\n+\n+\t/*\n+\t * Verify that a sensor subdevice is connected to this CIO2 instance\n+\t * and enable the media link between the two.\n+\t */\n+\tstd::string csi2Name = \"ipu3-csi2 \" + std::to_string(index);\n+\tMediaEntity *csi2Entity = media->getEntityByName(csi2Name);\n+\tconst std::vector<MediaPad *> &pads = csi2Entity->pads();\n+\tif (pads.empty())\n+\t\treturn -ENODEV;\n+\n+\t/* IPU3 CSI-2 receivers have a single sink pad at index 0. */\n+\tMediaPad *sink = pads[0];\n+\tconst std::vector<MediaLink *> &links = sink->links();\n+\tif (links.empty())\n+\t\treturn -ENODEV;\n+\n+\tMediaLink *link = links[0];\n+\tMediaEntity *sensorEntity = link->source()->entity();\n+\tsensor_ = new CameraSensor(sensorEntity);\n+\tret = sensor_->init();\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = link->setEnabled(true);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\t/*\n+\t * Make sure the sensor produces at least one format compatible with\n+\t * the CIO2 requirements.\n+\t *\n+\t * utils::set_overlap requires the ranges to be sorted, keep the\n+\t * cio2Codes vector sorted in ascending order.\n+\t */\n+\tconst std::vector<unsigned int> cio2Codes{ MEDIA_BUS_FMT_SBGGR10_1X10,\n+\t\t\t\t\t\t   MEDIA_BUS_FMT_SGRBG10_1X10,\n+\t\t\t\t\t\t   MEDIA_BUS_FMT_SGBRG10_1X10,\n+\t\t\t\t\t\t   MEDIA_BUS_FMT_SRGGB10_1X10 };\n+\tconst std::vector<unsigned int> &sensorCodes = sensor_->mbusCodes();\n+\tif (!utils::set_overlap(sensorCodes.begin(), sensorCodes.end(),\n+\t\t\t\tcio2Codes.begin(), cio2Codes.end())) {\n+\t\tLOG(IPU3, Error)\n+\t\t\t<< \"Sensor \" << sensor_->entity()->name()\n+\t\t\t<< \" has not format compatible with the IPU3\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/*\n+\t * \\todo Define when to open and close video device nodes, as they\n+\t * might impact on power consumption.\n+\t */\n+\n+\tcsi2_ = new V4L2Subdevice(csi2Entity);\n+\tret = csi2_->open();\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tstd::string cio2Name = \"ipu3-cio2 \" + std::to_string(index);\n+\toutput_ = V4L2VideoDevice::fromEntityName(media, cio2Name);\n+\tret = output_->open();\n+\tif (ret)\n+\t\treturn ret;\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * \\brief Configure the CIO2 unit\n+ * \\param[in] size The requested CIO2 output frame size\n+ * \\param[out] outputFormat The CIO2 unit output image format\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+int CIO2Device::configure(const Size &size, V4L2DeviceFormat *outputFormat)\n+{\n+\tV4L2SubdeviceFormat sensorFormat;\n+\tint ret;\n+\n+\t/*\n+\t * Apply the selected format to the sensor, the CSI-2 receiver and\n+\t * the CIO2 output device.\n+\t */\n+\tsensorFormat = sensor_->getFormat({ MEDIA_BUS_FMT_SBGGR10_1X10,\n+\t\t\t\t\t    MEDIA_BUS_FMT_SGBRG10_1X10,\n+\t\t\t\t\t    MEDIA_BUS_FMT_SGRBG10_1X10,\n+\t\t\t\t\t    MEDIA_BUS_FMT_SRGGB10_1X10 },\n+\t\t\t\t\t  size);\n+\tret = sensor_->setFormat(&sensorFormat);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = csi2_->setFormat(0, &sensorFormat);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tV4L2PixelFormat v4l2Format;\n+\tswitch (sensorFormat.mbus_code) {\n+\tcase MEDIA_BUS_FMT_SBGGR10_1X10:\n+\t\tv4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SBGGR10);\n+\t\tbreak;\n+\tcase MEDIA_BUS_FMT_SGBRG10_1X10:\n+\t\tv4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGBRG10);\n+\t\tbreak;\n+\tcase MEDIA_BUS_FMT_SGRBG10_1X10:\n+\t\tv4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGRBG10);\n+\t\tbreak;\n+\tcase MEDIA_BUS_FMT_SRGGB10_1X10:\n+\t\tv4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SRGGB10);\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -EINVAL;\n+\t}\n+\n+\toutputFormat->fourcc = v4l2Format;\n+\toutputFormat->size = sensorFormat.size;\n+\toutputFormat->planesCount = 1;\n+\n+\tret = output_->setFormat(outputFormat);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tLOG(IPU3, Debug) << \"CIO2 output format \" << outputFormat->toString();\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * \\brief Allocate frame buffers for the CIO2 output\n+ *\n+ * Allocate frame buffers in the CIO2 video device to be used to capture frames\n+ * from the CIO2 output. The buffers are stored in the CIO2Device::buffers_\n+ * vector.\n+ *\n+ * \\return Number of buffers allocated or negative error code\n+ */\n+int CIO2Device::allocateBuffers()\n+{\n+\tint ret = output_->allocateBuffers(CIO2_BUFFER_COUNT, &buffers_);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n+\tfor (std::unique_ptr<FrameBuffer> &buffer : buffers_)\n+\t\tavailableBuffers_.push(buffer.get());\n+\n+\treturn ret;\n+}\n+\n+void CIO2Device::freeBuffers()\n+{\n+\t/* The default std::queue constructor is explicit with gcc 5 and 6. */\n+\tavailableBuffers_ = std::queue<FrameBuffer *>{};\n+\n+\tbuffers_.clear();\n+\n+\tif (output_->releaseBuffers())\n+\t\tLOG(IPU3, Error) << \"Failed to release CIO2 buffers\";\n+}\n+\n+FrameBuffer *CIO2Device::getBuffer()\n+{\n+\tif (availableBuffers_.empty()) {\n+\t\tLOG(IPU3, Error) << \"CIO2 buffer underrun\";\n+\t\treturn nullptr;\n+\t}\n+\n+\tFrameBuffer *buffer = availableBuffers_.front();\n+\n+\tavailableBuffers_.pop();\n+\n+\treturn buffer;\n+}\n+\n+void CIO2Device::putBuffer(FrameBuffer *buffer)\n+{\n+\tavailableBuffers_.push(buffer);\n+}\n+\n+int CIO2Device::start()\n+{\n+\treturn output_->streamOn();\n+}\n+\n+int CIO2Device::stop()\n+{\n+\treturn output_->streamOff();\n+}\n+\n+V4L2PixelFormat CIO2Device::mediaBusToFormat(unsigned int code)\n+{\n+\tswitch (code) {\n+\tcase MEDIA_BUS_FMT_SBGGR10_1X10:\n+\t\treturn V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SBGGR10);\n+\tcase MEDIA_BUS_FMT_SGBRG10_1X10:\n+\t\treturn V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGBRG10);\n+\tcase MEDIA_BUS_FMT_SGRBG10_1X10:\n+\t\treturn V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGRBG10);\n+\tcase MEDIA_BUS_FMT_SRGGB10_1X10:\n+\t\treturn V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SRGGB10);\n+\tdefault:\n+\t\treturn {};\n+\t}\n+}\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/pipeline/ipu3/cio2.h b/src/libcamera/pipeline/ipu3/cio2.h\nnew file mode 100644\nindex 0000000000000000..d923038bb4ba356f\n--- /dev/null\n+++ b/src/libcamera/pipeline/ipu3/cio2.h\n@@ -0,0 +1,64 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2020, Google Inc.\n+ *\n+ * cio2.h - Intel IPU3 CIO2\n+ */\n+#ifndef __LIBCAMERA_PIPELINE_IPU3_CIO2_H__\n+#define __LIBCAMERA_PIPELINE_IPU3_CIO2_H__\n+\n+#include <queue>\n+#include <vector>\n+\n+#include <linux/media-bus-format.h>\n+\n+#include \"libcamera/internal/camera_sensor.h\"\n+#include \"libcamera/internal/media_device.h\"\n+#include \"libcamera/internal/v4l2_subdevice.h\"\n+#include \"libcamera/internal/v4l2_videodevice.h\"\n+\n+namespace libcamera {\n+\n+class CIO2Device\n+{\n+public:\n+\tstatic constexpr unsigned int CIO2_BUFFER_COUNT = 4;\n+\n+\tCIO2Device()\n+\t\t: output_(nullptr), csi2_(nullptr), sensor_(nullptr)\n+\t{\n+\t}\n+\n+\t~CIO2Device()\n+\t{\n+\t\tdelete output_;\n+\t\tdelete csi2_;\n+\t\tdelete sensor_;\n+\t}\n+\n+\tint init(const MediaDevice *media, unsigned int index);\n+\tint configure(const Size &size, V4L2DeviceFormat *outputFormat);\n+\n+\tint allocateBuffers();\n+\tvoid freeBuffers();\n+\n+\tFrameBuffer *getBuffer();\n+\tvoid putBuffer(FrameBuffer *buffer);\n+\n+\tint start();\n+\tint stop();\n+\n+\tstatic V4L2PixelFormat mediaBusToFormat(unsigned int code);\n+\n+\tV4L2VideoDevice *output_;\n+\tV4L2Subdevice *csi2_;\n+\tCameraSensor *sensor_;\n+\n+private:\n+\tstd::vector<std::unique_ptr<FrameBuffer>> buffers_;\n+\tstd::queue<FrameBuffer *> availableBuffers_;\n+};\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_PIPELINE_IPU3_CIO2_H__ */\ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex f4759715c6ae7572..2047deac299dbf75 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -27,6 +27,8 @@\n #include \"libcamera/internal/v4l2_subdevice.h\"\n #include \"libcamera/internal/v4l2_videodevice.h\"\n \n+#include \"cio2.h\"\n+\n namespace libcamera {\n \n LOG_DEFINE_CATEGORY(IPU3)\n@@ -103,45 +105,6 @@ public:\n \t/* \\todo Add param video device for 3A tuning */\n };\n \n-class CIO2Device\n-{\n-public:\n-\tstatic constexpr unsigned int CIO2_BUFFER_COUNT = 4;\n-\n-\tCIO2Device()\n-\t\t: output_(nullptr), csi2_(nullptr), sensor_(nullptr)\n-\t{\n-\t}\n-\n-\t~CIO2Device()\n-\t{\n-\t\tdelete output_;\n-\t\tdelete csi2_;\n-\t\tdelete sensor_;\n-\t}\n-\n-\tint init(const MediaDevice *media, unsigned int index);\n-\tint configure(const Size &size,\n-\t\t      V4L2DeviceFormat *outputFormat);\n-\n-\tint allocateBuffers();\n-\tvoid freeBuffers();\n-\n-\tFrameBuffer *getBuffer();\n-\tvoid putBuffer(FrameBuffer *buffer);\n-\n-\tint start();\n-\tint stop();\n-\n-\tV4L2VideoDevice *output_;\n-\tV4L2Subdevice *csi2_;\n-\tCameraSensor *sensor_;\n-\n-private:\n-\tstd::vector<std::unique_ptr<FrameBuffer>> buffers_;\n-\tstd::queue<FrameBuffer *> availableBuffers_;\n-};\n-\n class IPU3Stream : public Stream\n {\n public:\n@@ -1407,214 +1370,6 @@ int ImgUDevice::enableLinks(bool enable)\n \treturn linkSetup(name_, PAD_STAT, statName, 0, enable);\n }\n \n-/*------------------------------------------------------------------------------\n- * CIO2 Device\n- */\n-\n-/**\n- * \\brief Initialize components of the CIO2 device with \\a index\n- * \\param[in] media The CIO2 media device\n- * \\param[in] index The CIO2 device index\n- *\n- * Create and open the video device and subdevices in the CIO2 instance at \\a\n- * index, if a supported image sensor is connected to the CSI-2 receiver of\n- * this CIO2 instance.  Enable the media links connecting the CIO2 components\n- * to prepare for capture operations and cached the sensor maximum size.\n- *\n- * \\return 0 on success or a negative error code otherwise\n- * \\retval -ENODEV No supported image sensor is connected to this CIO2 instance\n- */\n-int CIO2Device::init(const MediaDevice *media, unsigned int index)\n-{\n-\tint ret;\n-\n-\t/*\n-\t * Verify that a sensor subdevice is connected to this CIO2 instance\n-\t * and enable the media link between the two.\n-\t */\n-\tstd::string csi2Name = \"ipu3-csi2 \" + std::to_string(index);\n-\tMediaEntity *csi2Entity = media->getEntityByName(csi2Name);\n-\tconst std::vector<MediaPad *> &pads = csi2Entity->pads();\n-\tif (pads.empty())\n-\t\treturn -ENODEV;\n-\n-\t/* IPU3 CSI-2 receivers have a single sink pad at index 0. */\n-\tMediaPad *sink = pads[0];\n-\tconst std::vector<MediaLink *> &links = sink->links();\n-\tif (links.empty())\n-\t\treturn -ENODEV;\n-\n-\tMediaLink *link = links[0];\n-\tMediaEntity *sensorEntity = link->source()->entity();\n-\tsensor_ = new CameraSensor(sensorEntity);\n-\tret = sensor_->init();\n-\tif (ret)\n-\t\treturn ret;\n-\n-\tret = link->setEnabled(true);\n-\tif (ret)\n-\t\treturn ret;\n-\n-\t/*\n-\t * Make sure the sensor produces at least one format compatible with\n-\t * the CIO2 requirements.\n-\t *\n-\t * utils::set_overlap requires the ranges to be sorted, keep the\n-\t * cio2Codes vector sorted in ascending order.\n-\t */\n-\tconst std::vector<unsigned int> cio2Codes{ MEDIA_BUS_FMT_SBGGR10_1X10,\n-\t\t\t\t\t\t   MEDIA_BUS_FMT_SGRBG10_1X10,\n-\t\t\t\t\t\t   MEDIA_BUS_FMT_SGBRG10_1X10,\n-\t\t\t\t\t\t   MEDIA_BUS_FMT_SRGGB10_1X10 };\n-\tconst std::vector<unsigned int> &sensorCodes = sensor_->mbusCodes();\n-\tif (!utils::set_overlap(sensorCodes.begin(), sensorCodes.end(),\n-\t\t\t\tcio2Codes.begin(), cio2Codes.end())) {\n-\t\tLOG(IPU3, Error)\n-\t\t\t<< \"Sensor \" << sensor_->entity()->name()\n-\t\t\t<< \" has not format compatible with the IPU3\";\n-\t\treturn -EINVAL;\n-\t}\n-\n-\t/*\n-\t * \\todo Define when to open and close video device nodes, as they\n-\t * might impact on power consumption.\n-\t */\n-\n-\tcsi2_ = new V4L2Subdevice(csi2Entity);\n-\tret = csi2_->open();\n-\tif (ret)\n-\t\treturn ret;\n-\n-\tstd::string cio2Name = \"ipu3-cio2 \" + std::to_string(index);\n-\toutput_ = V4L2VideoDevice::fromEntityName(media, cio2Name);\n-\tret = output_->open();\n-\tif (ret)\n-\t\treturn ret;\n-\n-\treturn 0;\n-}\n-\n-/**\n- * \\brief Configure the CIO2 unit\n- * \\param[in] size The requested CIO2 output frame size\n- * \\param[out] outputFormat The CIO2 unit output image format\n- * \\return 0 on success or a negative error code otherwise\n- */\n-int CIO2Device::configure(const Size &size,\n-\t\t\t  V4L2DeviceFormat *outputFormat)\n-{\n-\tV4L2SubdeviceFormat sensorFormat;\n-\tint ret;\n-\n-\t/*\n-\t * Apply the selected format to the sensor, the CSI-2 receiver and\n-\t * the CIO2 output device.\n-\t */\n-\tsensorFormat = sensor_->getFormat({ MEDIA_BUS_FMT_SBGGR10_1X10,\n-\t\t\t\t\t    MEDIA_BUS_FMT_SGBRG10_1X10,\n-\t\t\t\t\t    MEDIA_BUS_FMT_SGRBG10_1X10,\n-\t\t\t\t\t    MEDIA_BUS_FMT_SRGGB10_1X10 },\n-\t\t\t\t\t  size);\n-\tret = sensor_->setFormat(&sensorFormat);\n-\tif (ret)\n-\t\treturn ret;\n-\n-\tret = csi2_->setFormat(0, &sensorFormat);\n-\tif (ret)\n-\t\treturn ret;\n-\n-\tV4L2PixelFormat v4l2Format;\n-\tswitch (sensorFormat.mbus_code) {\n-\tcase MEDIA_BUS_FMT_SBGGR10_1X10:\n-\t\tv4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SBGGR10);\n-\t\tbreak;\n-\tcase MEDIA_BUS_FMT_SGBRG10_1X10:\n-\t\tv4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGBRG10);\n-\t\tbreak;\n-\tcase MEDIA_BUS_FMT_SGRBG10_1X10:\n-\t\tv4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGRBG10);\n-\t\tbreak;\n-\tcase MEDIA_BUS_FMT_SRGGB10_1X10:\n-\t\tv4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SRGGB10);\n-\t\tbreak;\n-\tdefault:\n-\t\treturn -EINVAL;\n-\t}\n-\n-\toutputFormat->fourcc = v4l2Format;\n-\toutputFormat->size = sensorFormat.size;\n-\toutputFormat->planesCount = 1;\n-\n-\tret = output_->setFormat(outputFormat);\n-\tif (ret)\n-\t\treturn ret;\n-\n-\tLOG(IPU3, Debug) << \"CIO2 output format \" << outputFormat->toString();\n-\n-\treturn 0;\n-}\n-\n-/**\n- * \\brief Allocate frame buffers for the CIO2 output\n- *\n- * Allocate frame buffers in the CIO2 video device to be used to capture frames\n- * from the CIO2 output. The buffers are stored in the CIO2Device::buffers_\n- * vector.\n- *\n- * \\return Number of buffers allocated or negative error code\n- */\n-int CIO2Device::allocateBuffers()\n-{\n-\tint ret = output_->allocateBuffers(CIO2_BUFFER_COUNT, &buffers_);\n-\tif (ret < 0)\n-\t\treturn ret;\n-\n-\tfor (std::unique_ptr<FrameBuffer> &buffer : buffers_)\n-\t\tavailableBuffers_.push(buffer.get());\n-\n-\treturn ret;\n-}\n-\n-void CIO2Device::freeBuffers()\n-{\n-\t/* The default std::queue constructor is explicit with gcc 5 and 6. */\n-\tavailableBuffers_ = std::queue<FrameBuffer *>{};\n-\n-\tbuffers_.clear();\n-\n-\tif (output_->releaseBuffers())\n-\t\tLOG(IPU3, Error) << \"Failed to release CIO2 buffers\";\n-}\n-\n-FrameBuffer *CIO2Device::getBuffer()\n-{\n-\tif (availableBuffers_.empty()) {\n-\t\tLOG(IPU3, Error) << \"CIO2 buffer underrun\";\n-\t\treturn nullptr;\n-\t}\n-\n-\tFrameBuffer *buffer = availableBuffers_.front();\n-\n-\tavailableBuffers_.pop();\n-\n-\treturn buffer;\n-}\n-\n-void CIO2Device::putBuffer(FrameBuffer *buffer)\n-{\n-\tavailableBuffers_.push(buffer);\n-}\n-\n-int CIO2Device::start()\n-{\n-\treturn output_->streamOn();\n-}\n-\n-int CIO2Device::stop()\n-{\n-\treturn output_->streamOff();\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\nindex 0e8c5a14f2b3317b..b2602d30123f908d 100644\n--- a/src/libcamera/pipeline/ipu3/meson.build\n+++ b/src/libcamera/pipeline/ipu3/meson.build\n@@ -1,5 +1,6 @@\n # SPDX-License-Identifier: CC0-1.0\n \n libcamera_sources += files([\n+    'cio2.cpp',\n     'ipu3.cpp',\n ])\n","prefixes":["libcamera-devel","06/10"]}