{"id":3897,"url":"https://patchwork.libcamera.org/api/1.1/patches/3897/?format=json","web_url":"https://patchwork.libcamera.org/patch/3897/","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-9-niklas.soderlund@ragnatech.se>","date":"2020-06-02T01:39:07","name":"[libcamera-devel,08/10] libcamera: ipu3: cio2: Make the V4L2 devices private","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"5565fabd0431ce1d18d8e6dca1fa54acd0032384","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/3897/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/3897/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3897/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 0DD03610BF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Jun 2020 03:39:33 +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 d70968d6-a471-11ea-a73e-0050569116f7;\n\tTue, 02 Jun 2020 03:39:03 +0200 (CEST)"],"X-Halon-ID":"d70968d6-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:07 +0200","Message-Id":"<20200602013909.3170593-9-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 08/10] libcamera: ipu3: cio2: Make the\n\tV4L2 devices private","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 order to make the CIO2 easier to extend with new features make the\nV4L2 deices (sensor, CIO2 and video device) private members. This\nrequires a few helper functions to be added to allow for the IPU3 driver\nto still be able to interact with all parts of the CIO2. These helper\nfunctions will later be extended to add new features to the IPU3\npipeline.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/libcamera/pipeline/ipu3/cio2.cpp | 18 ++++++++++++++++++\n src/libcamera/pipeline/ipu3/cio2.h   | 19 +++++++++++++++----\n src/libcamera/pipeline/ipu3/ipu3.cpp | 16 +++++++---------\n 3 files changed, 40 insertions(+), 13 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp\nindex 2263d6530ec6b672..63a46959f3cac06a 100644\n--- a/src/libcamera/pipeline/ipu3/cio2.cpp\n+++ b/src/libcamera/pipeline/ipu3/cio2.cpp\n@@ -98,6 +98,8 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)\n \tif (ret)\n \t\treturn ret;\n \n+\toutput_->bufferReady.connect(this, &CIO2Device::cio2BufferReady);\n+\n \treturn 0;\n }\n \n@@ -218,6 +220,12 @@ int CIO2Device::allocateBuffers()\n \treturn ret;\n }\n \n+int CIO2Device::exportBuffers(unsigned int count,\n+\t\t\t      std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n+{\n+\treturn output_->exportBuffers(count, buffers);\n+}\n+\n void CIO2Device::freeBuffers()\n {\n \t/* The default std::queue constructor is explicit with gcc 5 and 6. */\n@@ -258,6 +266,11 @@ int CIO2Device::stop()\n \treturn output_->streamOff();\n }\n \n+int CIO2Device::queueBuffer(FrameBuffer *buffer)\n+{\n+\treturn output_->queueBuffer(buffer);\n+}\n+\n V4L2PixelFormat CIO2Device::mediaBusToFormat(unsigned int code)\n {\n \tswitch (code) {\n@@ -274,4 +287,9 @@ V4L2PixelFormat CIO2Device::mediaBusToFormat(unsigned int code)\n \t}\n }\n \n+void CIO2Device::cio2BufferReady(FrameBuffer *buffer)\n+{\n+\tbufferReady.emit(buffer);\n+}\n+\n } /* namespace libcamera */\ndiff --git a/src/libcamera/pipeline/ipu3/cio2.h b/src/libcamera/pipeline/ipu3/cio2.h\nindex 2e268a7154b2d241..465c0778f27e4066 100644\n--- a/src/libcamera/pipeline/ipu3/cio2.h\n+++ b/src/libcamera/pipeline/ipu3/cio2.h\n@@ -27,7 +27,7 @@ public:\n \tstatic constexpr unsigned int CIO2_BUFFER_COUNT = 4;\n \n \tCIO2Device()\n-\t\t: output_(nullptr), csi2_(nullptr), sensor_(nullptr)\n+\t\t: sensor_(nullptr), csi2_(nullptr), output_(nullptr)\n \t{\n \t}\n \n@@ -45,6 +45,8 @@ public:\n \t\t\t\t\t\t  const Size desiredSize = {}) const;\n \n \tint allocateBuffers();\n+\tint exportBuffers(unsigned int count,\n+\t\t\t  std::vector<std::unique_ptr<FrameBuffer>> *buffers);\n \tvoid freeBuffers();\n \n \tFrameBuffer *getBuffer();\n@@ -53,13 +55,22 @@ public:\n \tint start();\n \tint stop();\n \n+\tconst std::string &name() const { return sensor_->entity()->name(); }\n+\tSize resolution() const { return sensor_->resolution(); }\n+\tControlList properties() const { return sensor_->properties(); }\n+\n+\tint queueBuffer(FrameBuffer *buffer);\n+\tSignal<FrameBuffer *> bufferReady;\n+\n+private:\n \tstatic V4L2PixelFormat mediaBusToFormat(unsigned int code);\n \n-\tV4L2VideoDevice *output_;\n-\tV4L2Subdevice *csi2_;\n+\tvoid cio2BufferReady(FrameBuffer *buffer);\n+\n \tCameraSensor *sensor_;\n+\tV4L2Subdevice *csi2_;\n+\tV4L2VideoDevice *output_;\n \n-private:\n \tstd::vector<std::unique_ptr<FrameBuffer>> buffers_;\n \tstd::queue<FrameBuffer *> availableBuffers_;\n };\ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 56cc3ca10414f0d2..2d636f0944587a17 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -454,7 +454,7 @@ CameraConfiguration *PipelineHandlerIPU3::generateConfiguration(Camera *camera,\n \t\t\t * available sensor resolution and to the IPU3\n \t\t\t * alignment constraints.\n \t\t\t */\n-\t\t\tconst Size &res = data->cio2_.sensor_->resolution();\n+\t\t\tconst Size &res = data->cio2_.resolution();\n \t\t\tunsigned int width = std::min(1280U, res.width);\n \t\t\tunsigned int height = std::min(720U, res.height);\n \t\t\tcfg.size = { width & ~7, height & ~3 };\n@@ -634,13 +634,11 @@ int PipelineHandlerIPU3::exportFrameBuffers(Camera *camera, Stream *stream,\n \tIPU3CameraData *data = cameraData(camera);\n \tIPU3Stream *ipu3stream = static_cast<IPU3Stream *>(stream);\n \tunsigned int count = stream->configuration().bufferCount;\n-\tV4L2VideoDevice *video;\n \n \tif (ipu3stream->raw_)\n-\t\tvideo = data->cio2_.output_;\n-\telse\n-\t\tvideo = ipu3stream->device_->dev;\n+\t\treturn data->cio2_.exportBuffers(count, buffers);\n \n+\tV4L2VideoDevice *video = ipu3stream->device_->dev;\n \treturn video->exportBuffers(count, buffers);\n }\n \n@@ -749,7 +747,7 @@ int PipelineHandlerIPU3::queueRequestDevice(Camera *camera, Request *request)\n \t\treturn -EINVAL;\n \n \tbuffer->setRequest(request);\n-\tdata->cio2_.output_->queueBuffer(buffer);\n+\tdata->cio2_.queueBuffer(buffer);\n \n \tfor (auto it : request->buffers()) {\n \t\tIPU3Stream *stream = static_cast<IPU3Stream *>(it.first);\n@@ -862,7 +860,7 @@ int PipelineHandlerIPU3::registerCameras()\n \t\t\tcontinue;\n \n \t\t/* Initialize the camera properties. */\n-\t\tdata->properties_ = cio2->sensor_->properties();\n+\t\tdata->properties_ = cio2->properties();\n \n \t\t/**\n \t\t * \\todo Dynamically assign ImgU and output devices to each\n@@ -886,7 +884,7 @@ int PipelineHandlerIPU3::registerCameras()\n \t\t * associated ImgU input where they get processed and\n \t\t * returned through the ImgU main and secondary outputs.\n \t\t */\n-\t\tdata->cio2_.output_->bufferReady.connect(data.get(),\n+\t\tdata->cio2_.bufferReady.connect(data.get(),\n \t\t\t\t\t&IPU3CameraData::cio2BufferReady);\n \t\tdata->imgu_->input_->bufferReady.connect(data.get(),\n \t\t\t\t\t&IPU3CameraData::imguInputBufferReady);\n@@ -896,7 +894,7 @@ int PipelineHandlerIPU3::registerCameras()\n \t\t\t\t\t&IPU3CameraData::imguOutputBufferReady);\n \n \t\t/* Create and register the Camera instance. */\n-\t\tstd::string cameraName = cio2->sensor_->entity()->name();\n+\t\tstd::string cameraName = cio2->name();\n \t\tstd::shared_ptr<Camera> camera = Camera::create(this,\n \t\t\t\t\t\t\t\tcameraName,\n \t\t\t\t\t\t\t\tstreams);\n","prefixes":["libcamera-devel","08/10"]}