[{"id":5386,"web_url":"https://patchwork.libcamera.org/comment/5386/","msgid":"<20200625013053.GR5980@pendragon.ideasonboard.com>","date":"2020-06-25T01:30:53","subject":"Re: [libcamera-devel] [PATCH v3 08/10] libcamera: ipu3: cio2: Make\n\tthe V4L2 devices private","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo and Niklas,\n\nOn Wed, Jun 24, 2020 at 12:31:10PM +0200, Jacopo Mondi wrote:\n> On Tue, Jun 23, 2020 at 04:09:28AM +0200, Niklas Söderlund wrote:\n> > In order to make the CIO2 easier to extend with new features make the\n> > V4L2 devices (sensor, CIO2 and video device) private members. This\n> > requires a few helper functions to be added to allow for the IPU3 driver\n> > to still be able to interact with all parts of the CIO2. These helper\n> > functions will later be extended to add new features to the IPU3\n> > pipeline.\n> >\n> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> \n> Much better than accessing parts of the CIO2 device from the other\n> components.\n> \n> > ---\n> > * Changes since v2\n> > - Style changes.\n> >\n> > * Changes since v1\n> > - Drop sensor access helpers and replace with a sensor() call to get\n> >   hold of the CameraSensor pointer directly.\n> > ---\n> >  src/libcamera/pipeline/ipu3/cio2.cpp | 20 +++++++++++++++++++-\n> >  src/libcamera/pipeline/ipu3/cio2.h   | 17 ++++++++++++++---\n> >  src/libcamera/pipeline/ipu3/ipu3.cpp | 19 ++++++++-----------\n> >  3 files changed, 41 insertions(+), 15 deletions(-)\n> >\n> > diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp\n> > index d6bab896706dd60e..3d7348782b0fa6cb 100644\n> > --- a/src/libcamera/pipeline/ipu3/cio2.cpp\n> > +++ b/src/libcamera/pipeline/ipu3/cio2.cpp\n> > @@ -38,7 +38,7 @@ static const std::map<uint32_t, MbusInfo> mbusCodesToInfo = {\n> >  } /* namespace */\n> >\n> >  CIO2Device::CIO2Device()\n> > -\t: output_(nullptr), csi2_(nullptr), sensor_(nullptr)\n> > +\t: sensor_(nullptr), csi2_(nullptr), output_(nullptr)\n> >  {\n> >  }\n> >\n> > @@ -126,6 +126,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> There's a bit of signal ping-pong here...\n> Could this be avoided by providing a registerBufferReady() method that\n> the pipielinehandler can call and provide a slot to connect to the\n> video device signal ? I can't actually tell how bad this is tbh\n\nHow about\n\n-\tSignal<FrameBuffer *> bufferReady;\n+\tSignal<FrameBuffer *> &bufferReady() { return output_->bufferReady; }\n\n? That would avoid proxying the signal while still not exposing the\nV4L2VideoDevice.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> > +\n> >  \treturn 0;\n> >  }\n> >\n> > @@ -226,6 +228,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> > @@ -266,4 +274,14 @@ int CIO2Device::stop()\n> >  \treturn output_->streamOff();\n> >  }\n> >\n> > +int CIO2Device::queueBuffer(FrameBuffer *buffer)\n> > +{\n> > +\treturn output_->queueBuffer(buffer);\n> > +}\n> > +\n> > +void CIO2Device::cio2BufferReady(FrameBuffer *buffer)\n> > +{\n> > +\tbufferReady.emit(buffer);\n> > +}\n> > +\n> >  } /* namespace libcamera */\n> > diff --git a/src/libcamera/pipeline/ipu3/cio2.h b/src/libcamera/pipeline/ipu3/cio2.h\n> > index 6276573f2b585b25..cc898f13fd73f865 100644\n> > --- a/src/libcamera/pipeline/ipu3/cio2.h\n> > +++ b/src/libcamera/pipeline/ipu3/cio2.h\n> > @@ -11,6 +11,8 @@\n> >  #include <queue>\n> >  #include <vector>\n> >\n> > +#include <libcamera/signal.h>\n> > +\n> >  namespace libcamera {\n> >\n> >  class CameraSensor;\n> > @@ -36,6 +38,8 @@ public:\n> >  \tStreamConfiguration generateConfiguration(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> > @@ -44,11 +48,18 @@ public:\n> >  \tint start();\n> >  \tint stop();\n> >\n> > -\tV4L2VideoDevice *output_;\n> > -\tV4L2Subdevice *csi2_;\n> > -\tCameraSensor *sensor_;\n> > +\tCameraSensor *sensor() { return sensor_; }\n> > +\n> > +\tint queueBuffer(FrameBuffer *buffer);\n> > +\tSignal<FrameBuffer *> bufferReady;\n> >\n> >  private:\n> > +\tvoid cio2BufferReady(FrameBuffer *buffer);\n> > +\n> > +\tCameraSensor *sensor_;\n> > +\tV4L2Subdevice *csi2_;\n> > +\tV4L2VideoDevice *output_;\n> > +\n> >  \tstd::vector<std::unique_ptr<FrameBuffer>> buffers_;\n> >  \tstd::queue<FrameBuffer *> availableBuffers_;\n> >  };\n> > diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > index c0e727e592f46883..2d1ec707ea4b08fe 100644\n> > --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > @@ -431,7 +431,7 @@ CameraConfiguration *PipelineHandlerIPU3::generateConfiguration(Camera *camera,\n> >\n> >  \t\t\tstream = &data->rawStream_;\n> >\n> > -\t\t\tcfg.size = data->cio2_.sensor_->resolution();\n> > +\t\t\tcfg.size = data->cio2_.sensor()->resolution();\n> >\n> >  \t\t\tcfg = data->cio2_.generateConfiguration(cfg.size);\n> >  \t\t\tbreak;\n> > @@ -460,7 +460,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_.sensor()->resolution();\n> \n> This could actually be Cio2Device::resolution().\n> Up to you.\n> \n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> \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> > @@ -640,14 +640,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> > -\treturn video->exportBuffers(count, buffers);\n> > +\treturn ipu3stream->device_->dev->exportBuffers(count, buffers);\n> >  }\n> >\n> >  /**\n> > @@ -757,7 +754,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> > @@ -870,7 +867,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->sensor()->properties();\n> >\n> >  \t\t/**\n> >  \t\t * \\todo Dynamically assign ImgU and output devices to each\n> > @@ -894,7 +891,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> > @@ -904,7 +901,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->sensor()->entity()->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);","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 0663AC0100\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 25 Jun 2020 01:30:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 69ACD609A9;\n\tThu, 25 Jun 2020 03:30:56 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 216FE603BB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 25 Jun 2020 03:30:55 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7E5312A8;\n\tThu, 25 Jun 2020 03:30:54 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"n2/C1sCj\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1593048654;\n\tbh=uefyvBbDVP3/2BK9iRVP6TJvyDTVWQRHMpupUKCqh/8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=n2/C1sCjJNUW6SGbnZ4zzwf8iw9OcPMGUchEJXjFCJfhjB+Kdx4+FQkTVG2GuPWc5\n\ttsbAEhLuXYYkz/j/jsmVM6DUs0u2dUhSbESz/QGuZNu27TEFRJhPxsqyYDyrBEj60I\n\t59BOQ21CHnONxNkFANMBMddb6b1ts/dSBJBYb9CM=","Date":"Thu, 25 Jun 2020 04:30:53 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<20200625013053.GR5980@pendragon.ideasonboard.com>","References":"<20200623020930.1781469-1-niklas.soderlund@ragnatech.se>\n\t<20200623020930.1781469-9-niklas.soderlund@ragnatech.se>\n\t<20200624103110.vtodlvedfqvgpqgn@uno.localdomain>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200624103110.vtodlvedfqvgpqgn@uno.localdomain>","Subject":"Re: [libcamera-devel] [PATCH v3 08/10] libcamera: ipu3: cio2: Make\n\tthe V4L2 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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":10799,"web_url":"https://patchwork.libcamera.org/comment/10799/","msgid":"<20200624103110.vtodlvedfqvgpqgn@uno.localdomain>","date":"2020-06-24T10:31:10","subject":"Re: [libcamera-devel] [PATCH v3 08/10] libcamera: ipu3: cio2: Make\n\tthe V4L2 devices private","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Niklas,\n\nOn Tue, Jun 23, 2020 at 04:09:28AM +0200, Niklas Söderlund wrote:\n> In order to make the CIO2 easier to extend with new features make the\n> V4L2 devices (sensor, CIO2 and video device) private members. This\n> requires a few helper functions to be added to allow for the IPU3 driver\n> to still be able to interact with all parts of the CIO2. These helper\n> functions will later be extended to add new features to the IPU3\n> pipeline.\n>\n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\nMuch better than accessing parts of the CIO2 device from the other\ncomponents.\n\n> ---\n> * Changes since v2\n> - Style changes.\n>\n> * Changes since v1\n> - Drop sensor access helpers and replace with a sensor() call to get\n>   hold of the CameraSensor pointer directly.\n> ---\n>  src/libcamera/pipeline/ipu3/cio2.cpp | 20 +++++++++++++++++++-\n>  src/libcamera/pipeline/ipu3/cio2.h   | 17 ++++++++++++++---\n>  src/libcamera/pipeline/ipu3/ipu3.cpp | 19 ++++++++-----------\n>  3 files changed, 41 insertions(+), 15 deletions(-)\n>\n> diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp\n> index d6bab896706dd60e..3d7348782b0fa6cb 100644\n> --- a/src/libcamera/pipeline/ipu3/cio2.cpp\n> +++ b/src/libcamera/pipeline/ipu3/cio2.cpp\n> @@ -38,7 +38,7 @@ static const std::map<uint32_t, MbusInfo> mbusCodesToInfo = {\n>  } /* namespace */\n>\n>  CIO2Device::CIO2Device()\n> -\t: output_(nullptr), csi2_(nullptr), sensor_(nullptr)\n> +\t: sensor_(nullptr), csi2_(nullptr), output_(nullptr)\n>  {\n>  }\n>\n> @@ -126,6 +126,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\nThere's a bit of signal ping-pong here...\nCould this be avoided by providing a registerBufferReady() method that\nthe pipielinehandler can call and provide a slot to connect to the\nvideo device signal ? I can't actually tell how bad this is tbh\n\n> +\n>  \treturn 0;\n>  }\n>\n> @@ -226,6 +228,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> @@ -266,4 +274,14 @@ int CIO2Device::stop()\n>  \treturn output_->streamOff();\n>  }\n>\n> +int CIO2Device::queueBuffer(FrameBuffer *buffer)\n> +{\n> +\treturn output_->queueBuffer(buffer);\n> +}\n> +\n> +void CIO2Device::cio2BufferReady(FrameBuffer *buffer)\n> +{\n> +\tbufferReady.emit(buffer);\n> +}\n> +\n>  } /* namespace libcamera */\n> diff --git a/src/libcamera/pipeline/ipu3/cio2.h b/src/libcamera/pipeline/ipu3/cio2.h\n> index 6276573f2b585b25..cc898f13fd73f865 100644\n> --- a/src/libcamera/pipeline/ipu3/cio2.h\n> +++ b/src/libcamera/pipeline/ipu3/cio2.h\n> @@ -11,6 +11,8 @@\n>  #include <queue>\n>  #include <vector>\n>\n> +#include <libcamera/signal.h>\n> +\n>  namespace libcamera {\n>\n>  class CameraSensor;\n> @@ -36,6 +38,8 @@ public:\n>  \tStreamConfiguration generateConfiguration(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> @@ -44,11 +48,18 @@ public:\n>  \tint start();\n>  \tint stop();\n>\n> -\tV4L2VideoDevice *output_;\n> -\tV4L2Subdevice *csi2_;\n> -\tCameraSensor *sensor_;\n> +\tCameraSensor *sensor() { return sensor_; }\n> +\n> +\tint queueBuffer(FrameBuffer *buffer);\n> +\tSignal<FrameBuffer *> bufferReady;\n>\n>  private:\n> +\tvoid cio2BufferReady(FrameBuffer *buffer);\n> +\n> +\tCameraSensor *sensor_;\n> +\tV4L2Subdevice *csi2_;\n> +\tV4L2VideoDevice *output_;\n> +\n>  \tstd::vector<std::unique_ptr<FrameBuffer>> buffers_;\n>  \tstd::queue<FrameBuffer *> availableBuffers_;\n>  };\n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index c0e727e592f46883..2d1ec707ea4b08fe 100644\n> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> @@ -431,7 +431,7 @@ CameraConfiguration *PipelineHandlerIPU3::generateConfiguration(Camera *camera,\n>\n>  \t\t\tstream = &data->rawStream_;\n>\n> -\t\t\tcfg.size = data->cio2_.sensor_->resolution();\n> +\t\t\tcfg.size = data->cio2_.sensor()->resolution();\n>\n>  \t\t\tcfg = data->cio2_.generateConfiguration(cfg.size);\n>  \t\t\tbreak;\n> @@ -460,7 +460,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_.sensor()->resolution();\n\nThis could actually be Cio2Device::resolution().\nUp to you.\n\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n  j\n\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> @@ -640,14 +640,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> -\treturn video->exportBuffers(count, buffers);\n> +\treturn ipu3stream->device_->dev->exportBuffers(count, buffers);\n>  }\n>\n>  /**\n> @@ -757,7 +754,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> @@ -870,7 +867,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->sensor()->properties();\n>\n>  \t\t/**\n>  \t\t * \\todo Dynamically assign ImgU and output devices to each\n> @@ -894,7 +891,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> @@ -904,7 +901,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->sensor()->entity()->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> --\n> 2.27.0\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net\n\t[217.70.183.197])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4E83F60103\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Jun 2020 12:27:43 +0200 (CEST)","from uno.localdomain (93-34-118-233.ip49.fastwebnet.it\n\t[93.34.118.233]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay5-d.mail.gandi.net (Postfix) with ESMTPSA id D68F41C0008;\n\tWed, 24 Jun 2020 10:27:42 +0000 (UTC)"],"X-Originating-IP":"93.34.118.233","Date":"Wed, 24 Jun 2020 12:31:10 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200624103110.vtodlvedfqvgpqgn@uno.localdomain>","References":"<20200623020930.1781469-1-niklas.soderlund@ragnatech.se>\n\t<20200623020930.1781469-9-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200623020930.1781469-9-niklas.soderlund@ragnatech.se>","Subject":"Re: [libcamera-devel] [PATCH v3 08/10] libcamera: ipu3: cio2: Make\n\tthe V4L2 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":"Wed, 24 Jun 2020 10:27:43 -0000"}},{"id":10863,"web_url":"https://patchwork.libcamera.org/comment/10863/","msgid":"<20200625200505.GC303959@oden.dyn.berto.se>","date":"2020-06-25T20:05:05","subject":"Re: [libcamera-devel] [PATCH v3 08/10] libcamera: ipu3: cio2: Make\n\tthe V4L2 devices private","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent and Jacopo,\n\nThanks for your feedback.\n\nOn 2020-06-25 04:30:53 +0300, Laurent Pinchart wrote:\n> Hi Jacopo and Niklas,\n> \n> On Wed, Jun 24, 2020 at 12:31:10PM +0200, Jacopo Mondi wrote:\n> > On Tue, Jun 23, 2020 at 04:09:28AM +0200, Niklas Söderlund wrote:\n> > > In order to make the CIO2 easier to extend with new features make the\n> > > V4L2 devices (sensor, CIO2 and video device) private members. This\n> > > requires a few helper functions to be added to allow for the IPU3 driver\n> > > to still be able to interact with all parts of the CIO2. These helper\n> > > functions will later be extended to add new features to the IPU3\n> > > pipeline.\n> > >\n> > > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> > \n> > Much better than accessing parts of the CIO2 device from the other\n> > components.\n> > \n> > > ---\n> > > * Changes since v2\n> > > - Style changes.\n> > >\n> > > * Changes since v1\n> > > - Drop sensor access helpers and replace with a sensor() call to get\n> > >   hold of the CameraSensor pointer directly.\n> > > ---\n> > >  src/libcamera/pipeline/ipu3/cio2.cpp | 20 +++++++++++++++++++-\n> > >  src/libcamera/pipeline/ipu3/cio2.h   | 17 ++++++++++++++---\n> > >  src/libcamera/pipeline/ipu3/ipu3.cpp | 19 ++++++++-----------\n> > >  3 files changed, 41 insertions(+), 15 deletions(-)\n> > >\n> > > diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp\n> > > index d6bab896706dd60e..3d7348782b0fa6cb 100644\n> > > --- a/src/libcamera/pipeline/ipu3/cio2.cpp\n> > > +++ b/src/libcamera/pipeline/ipu3/cio2.cpp\n> > > @@ -38,7 +38,7 @@ static const std::map<uint32_t, MbusInfo> mbusCodesToInfo = {\n> > >  } /* namespace */\n> > >\n> > >  CIO2Device::CIO2Device()\n> > > -\t: output_(nullptr), csi2_(nullptr), sensor_(nullptr)\n> > > +\t: sensor_(nullptr), csi2_(nullptr), output_(nullptr)\n> > >  {\n> > >  }\n> > >\n> > > @@ -126,6 +126,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> > There's a bit of signal ping-pong here...\n> > Could this be avoided by providing a registerBufferReady() method that\n> > the pipielinehandler can call and provide a slot to connect to the\n> > video device signal ? I can't actually tell how bad this is tbh\n> \n> How about\n> \n> -\tSignal<FrameBuffer *> bufferReady;\n> +\tSignal<FrameBuffer *> &bufferReady() { return output_->bufferReady; }\n> \n> ? That would avoid proxying the signal while still not exposing the\n> V4L2VideoDevice.\n\nThat would work in this pathc but 10/10 I inject code into \nCIO2Device::cio2BufferReady() which require the signal to be proxied. So \ntaking this in here I fear would only be busy work :-)\n\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> > > +\n> > >  \treturn 0;\n> > >  }\n> > >\n> > > @@ -226,6 +228,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> > > @@ -266,4 +274,14 @@ int CIO2Device::stop()\n> > >  \treturn output_->streamOff();\n> > >  }\n> > >\n> > > +int CIO2Device::queueBuffer(FrameBuffer *buffer)\n> > > +{\n> > > +\treturn output_->queueBuffer(buffer);\n> > > +}\n> > > +\n> > > +void CIO2Device::cio2BufferReady(FrameBuffer *buffer)\n> > > +{\n> > > +\tbufferReady.emit(buffer);\n> > > +}\n> > > +\n> > >  } /* namespace libcamera */\n> > > diff --git a/src/libcamera/pipeline/ipu3/cio2.h b/src/libcamera/pipeline/ipu3/cio2.h\n> > > index 6276573f2b585b25..cc898f13fd73f865 100644\n> > > --- a/src/libcamera/pipeline/ipu3/cio2.h\n> > > +++ b/src/libcamera/pipeline/ipu3/cio2.h\n> > > @@ -11,6 +11,8 @@\n> > >  #include <queue>\n> > >  #include <vector>\n> > >\n> > > +#include <libcamera/signal.h>\n> > > +\n> > >  namespace libcamera {\n> > >\n> > >  class CameraSensor;\n> > > @@ -36,6 +38,8 @@ public:\n> > >  \tStreamConfiguration generateConfiguration(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> > > @@ -44,11 +48,18 @@ public:\n> > >  \tint start();\n> > >  \tint stop();\n> > >\n> > > -\tV4L2VideoDevice *output_;\n> > > -\tV4L2Subdevice *csi2_;\n> > > -\tCameraSensor *sensor_;\n> > > +\tCameraSensor *sensor() { return sensor_; }\n> > > +\n> > > +\tint queueBuffer(FrameBuffer *buffer);\n> > > +\tSignal<FrameBuffer *> bufferReady;\n> > >\n> > >  private:\n> > > +\tvoid cio2BufferReady(FrameBuffer *buffer);\n> > > +\n> > > +\tCameraSensor *sensor_;\n> > > +\tV4L2Subdevice *csi2_;\n> > > +\tV4L2VideoDevice *output_;\n> > > +\n> > >  \tstd::vector<std::unique_ptr<FrameBuffer>> buffers_;\n> > >  \tstd::queue<FrameBuffer *> availableBuffers_;\n> > >  };\n> > > diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > > index c0e727e592f46883..2d1ec707ea4b08fe 100644\n> > > --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > > +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > > @@ -431,7 +431,7 @@ CameraConfiguration *PipelineHandlerIPU3::generateConfiguration(Camera *camera,\n> > >\n> > >  \t\t\tstream = &data->rawStream_;\n> > >\n> > > -\t\t\tcfg.size = data->cio2_.sensor_->resolution();\n> > > +\t\t\tcfg.size = data->cio2_.sensor()->resolution();\n> > >\n> > >  \t\t\tcfg = data->cio2_.generateConfiguration(cfg.size);\n> > >  \t\t\tbreak;\n> > > @@ -460,7 +460,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_.sensor()->resolution();\n> > \n> > This could actually be Cio2Device::resolution().\n> > Up to you.\n> > \n> > Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> > \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> > > @@ -640,14 +640,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> > > -\treturn video->exportBuffers(count, buffers);\n> > > +\treturn ipu3stream->device_->dev->exportBuffers(count, buffers);\n> > >  }\n> > >\n> > >  /**\n> > > @@ -757,7 +754,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> > > @@ -870,7 +867,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->sensor()->properties();\n> > >\n> > >  \t\t/**\n> > >  \t\t * \\todo Dynamically assign ImgU and output devices to each\n> > > @@ -894,7 +891,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> > > @@ -904,7 +901,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->sensor()->entity()->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> \n> -- \n> Regards,\n> \n> Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 7BCC0C0100\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 25 Jun 2020 20:05:09 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E8AF0609C5;\n\tThu, 25 Jun 2020 22:05:08 +0200 (CEST)","from mail-lj1-x244.google.com (mail-lj1-x244.google.com\n\t[IPv6:2a00:1450:4864:20::244])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 82D48609A5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 25 Jun 2020 22:05:07 +0200 (CEST)","by mail-lj1-x244.google.com with SMTP id 9so7926165ljv.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 25 Jun 2020 13:05:07 -0700 (PDT)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\t193sm7198143lfa.90.2020.06.25.13.05.05\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 25 Jun 2020 13:05:05 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com\n\theader.b=\"ixh3u6iL\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=qCbdMgKpbxDoESPzRev72/FgmEsvhPRGGbjAFLh8Q/Y=;\n\tb=ixh3u6iLW9MtXe6wWjbqxLoSUvpliUXvDyDkB1tWwVulG6jY0SZFCpI08bryY7h4O0\n\tu5XsTFZhcgkC1Ta31uAnlEavbaX1ae02GVugZD1qwO71mmMgJpFXcCq+Q+IrG5qPisqM\n\thugSX37kOFl6O6YsZWiqX1ogt3yMorIu9VEQ60kypOpBTA0pE7rJFp/YGDvAdO0Uom5I\n\t5eO8HkS/ywKIw/kcK/b0wBn1sbv3v1WJv+YULUkdY7Olo/uPRf2hM8nTPe5hPVIhmgPf\n\tkX8PHpaqitwNYTwsHwOxaC086l06vjKUxjG9D+yIvX3QJJrZgxatHHxu8Db0cZ6A26V2\n\tOchA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=qCbdMgKpbxDoESPzRev72/FgmEsvhPRGGbjAFLh8Q/Y=;\n\tb=TIY98XsyAfDIXnSX+1Ir6HPDsU44cEeFsrx4qprC6kGmvLTFe48qPFelJvqZ5EQ69W\n\tskvcfrRfH0g/TwUZSXTKsbbihGfUL6GnJhwhmhhJgfPOURdaytvk35goqry8xqTWcC6a\n\tcBSug3U24UM35fwRtx3GM7F8iB78oSdXIMdTq9hxuD+pwKbNM3QuX7mF7kM2ZMSIdWH7\n\tL6RWBjk+ZVv+GAKqjYCxhy4iy1uDusW07dNXJnEkaA9zOKfKuhk0gs/NEH6Ky289GtSk\n\t0j6IIYnV6XfrNVXciP+Yg9yiM48ziRRHwt4rVCczohgs4eFL8Ya2cHB8atkr50I7gCmm\n\tD0jw==","X-Gm-Message-State":"AOAM533JJLOvEqO4Z6VXA3Pbv/g/EhukUtFWGArkN5yvpNox0kf1CFZO\n\tma8dgyrcbBHrZcw3Sw7dAnNzXIvQdBk=","X-Google-Smtp-Source":"ABdhPJyNlQrjvpkpZ/lA6XUWo7+X26p8L0r7BOz/70zNcL2GnGOVgp46vxautQVVJMGqH5tArfUqhA==","X-Received":"by 2002:a2e:5c47:: with SMTP id\n\tq68mr18723343ljb.30.1593115506697; \n\tThu, 25 Jun 2020 13:05:06 -0700 (PDT)","Date":"Thu, 25 Jun 2020 22:05:05 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20200625200505.GC303959@oden.dyn.berto.se>","References":"<20200623020930.1781469-1-niklas.soderlund@ragnatech.se>\n\t<20200623020930.1781469-9-niklas.soderlund@ragnatech.se>\n\t<20200624103110.vtodlvedfqvgpqgn@uno.localdomain>\n\t<20200625013053.GR5980@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200625013053.GR5980@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v3 08/10] libcamera: ipu3: cio2: Make\n\tthe V4L2 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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"iso-8859-1\"","Content-Transfer-Encoding":"quoted-printable","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]