[libcamera-devel,03/13] libcamera: pipeline: Add method to prepare buffer for IPA

Message ID 20190828011710.32128-4-niklas.soderlund@ragnatech.se
State Superseded
Headers show
Series
  • libcamera: ipa: Add basic IPA support
Related show

Commit Message

Niklas Söderlund Aug. 28, 2019, 1:17 a.m. UTC
The pipeline handlers dealing with buffers outside the request coming
from an application needs to prepare Buffer objects before they can be
used by other the libcamera functions. For objects coming from the user
this is done by the Camera before the Buffers reach the pipeline
handler. Add a new method prepareInternalBuffer() to aid with this
preparation.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
 src/libcamera/include/pipeline_handler.h |  2 ++
 src/libcamera/pipeline_handler.cpp       | 18 ++++++++++++++++++
 2 files changed, 20 insertions(+)

Comments

Jacopo Mondi Aug. 28, 2019, 4:02 p.m. UTC | #1
Hi Niklas,

On Wed, Aug 28, 2019 at 03:17:00AM +0200, Niklas Söderlund wrote:
> The pipeline handlers dealing with buffers outside the request coming
> from an application needs to prepare Buffer objects before they can be
> used by other the libcamera functions. For objects coming from the user
> this is done by the Camera before the Buffers reach the pipeline
> handler. Add a new method prepareInternalBuffer() to aid with this
> preparation.

As clarified offline, this should be reworded to specify you're here
talking about internal buffers used by pipelines for
statistics/controls (also for internal buffer queues, like the
CIO2->IMGU one in the IPU3 ? )

>
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> ---
>  src/libcamera/include/pipeline_handler.h |  2 ++
>  src/libcamera/pipeline_handler.cpp       | 18 ++++++++++++++++++
>  2 files changed, 20 insertions(+)
>
> diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h
> index ffc7adb802215313..91d40ef40a465c4e 100644
> --- a/src/libcamera/include/pipeline_handler.h
> +++ b/src/libcamera/include/pipeline_handler.h
> @@ -98,6 +98,8 @@ protected:
>
>  	CameraData *cameraData(const Camera *camera);
>
> +	void prepareInternalBuffer(Buffer *buffer, Request *request,
> +				   BufferMemory *mem);

Do you think this will expand ? Otherwise I wonder if this should not
be made Buffer operation, like Buffer::prepare(req, mem); or other
names that better convey the idea of initialization
outside-of-a-request...


>  	CameraManager *manager_;
>
>  private:
> diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp
> index 89b67806597728f9..766fd496306ece9c 100644
> --- a/src/libcamera/pipeline_handler.cpp
> +++ b/src/libcamera/pipeline_handler.cpp
> @@ -484,6 +484,24 @@ void PipelineHandler::hotplugMediaDevice(MediaDevice *media)
>  	media->disconnected.connect(this, &PipelineHandler::mediaDeviceDisconnected);
>  }
>
> +/**
> + * \brief Prepare buffer for internal usage by a pipeline handler
> + * \param[in,out] buffer The buffer to prepare
> + * \param[in] request The request to associate the \a buffer with
> + * \param[in] mem The memory to associate the \a buffer with
> + *
> + * Pipeline handlers creating internal buffers to facilitate data flow in the
> + * pipeline need to prepare the buffers by setting up the buffer object state.
> + * This function help pipeline handler implementations to perform this
> + * preparation.
> + */
> +void PipelineHandler::prepareInternalBuffer(Buffer *buffer, Request *request,
> +					    BufferMemory *mem)
> +{
> +	buffer->request_ = request;
> +	buffer->mem_ = mem;
> +}
> +
>  /**
>   * \brief Slot for the MediaDevice disconnected signal
>   */
> --
> 2.22.1
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Niklas Söderlund Aug. 29, 2019, 6:57 p.m. UTC | #2
Hi Jacopo,

Thanks for your feedback.

On 2019-08-28 18:02:49 +0200, Jacopo Mondi wrote:
> Hi Niklas,
> 
> On Wed, Aug 28, 2019 at 03:17:00AM +0200, Niklas Söderlund wrote:
> > The pipeline handlers dealing with buffers outside the request coming
> > from an application needs to prepare Buffer objects before they can be
> > used by other the libcamera functions. For objects coming from the user
> > this is done by the Camera before the Buffers reach the pipeline
> > handler. Add a new method prepareInternalBuffer() to aid with this
> > preparation.
> 
> As clarified offline, this should be reworded to specify you're here

Yes this should be reworded for v2.

> talking about internal buffers used by pipelines for
> statistics/controls (also for internal buffer queues, like the
> CIO2->IMGU one in the IPU3 ? )

It could be used for the buffers between CIO2->IMGU indeed.

> >
> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> > ---
> >  src/libcamera/include/pipeline_handler.h |  2 ++
> >  src/libcamera/pipeline_handler.cpp       | 18 ++++++++++++++++++
> >  2 files changed, 20 insertions(+)
> >
> > diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h
> > index ffc7adb802215313..91d40ef40a465c4e 100644
> > --- a/src/libcamera/include/pipeline_handler.h
> > +++ b/src/libcamera/include/pipeline_handler.h
> > @@ -98,6 +98,8 @@ protected:
> >
> >  	CameraData *cameraData(const Camera *camera);
> >
> > +	void prepareInternalBuffer(Buffer *buffer, Request *request,
> > +				   BufferMemory *mem);
> 
> Do you think this will expand ? Otherwise I wonder if this should not
> be made Buffer operation, like Buffer::prepare(req, mem); or other
> names that better convey the idea of initialization
> outside-of-a-request...

I thought about adding this helper on the Buffer object directly, but 
decided against it as it would then be exposed to applications. This is 
something we don't want as the sole user of this should be pipeline 
handler implementations.

> 
> 
> >  	CameraManager *manager_;
> >
> >  private:
> > diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp
> > index 89b67806597728f9..766fd496306ece9c 100644
> > --- a/src/libcamera/pipeline_handler.cpp
> > +++ b/src/libcamera/pipeline_handler.cpp
> > @@ -484,6 +484,24 @@ void PipelineHandler::hotplugMediaDevice(MediaDevice *media)
> >  	media->disconnected.connect(this, &PipelineHandler::mediaDeviceDisconnected);
> >  }
> >
> > +/**
> > + * \brief Prepare buffer for internal usage by a pipeline handler
> > + * \param[in,out] buffer The buffer to prepare
> > + * \param[in] request The request to associate the \a buffer with
> > + * \param[in] mem The memory to associate the \a buffer with
> > + *
> > + * Pipeline handlers creating internal buffers to facilitate data flow in the
> > + * pipeline need to prepare the buffers by setting up the buffer object state.
> > + * This function help pipeline handler implementations to perform this
> > + * preparation.
> > + */
> > +void PipelineHandler::prepareInternalBuffer(Buffer *buffer, Request *request,
> > +					    BufferMemory *mem)
> > +{
> > +	buffer->request_ = request;
> > +	buffer->mem_ = mem;
> > +}
> > +
> >  /**
> >   * \brief Slot for the MediaDevice disconnected signal
> >   */
> > --
> > 2.22.1
> >
> > _______________________________________________
> > libcamera-devel mailing list
> > libcamera-devel@lists.libcamera.org
> > https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h
index ffc7adb802215313..91d40ef40a465c4e 100644
--- a/src/libcamera/include/pipeline_handler.h
+++ b/src/libcamera/include/pipeline_handler.h
@@ -98,6 +98,8 @@  protected:
 
 	CameraData *cameraData(const Camera *camera);
 
+	void prepareInternalBuffer(Buffer *buffer, Request *request,
+				   BufferMemory *mem);
 	CameraManager *manager_;
 
 private:
diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp
index 89b67806597728f9..766fd496306ece9c 100644
--- a/src/libcamera/pipeline_handler.cpp
+++ b/src/libcamera/pipeline_handler.cpp
@@ -484,6 +484,24 @@  void PipelineHandler::hotplugMediaDevice(MediaDevice *media)
 	media->disconnected.connect(this, &PipelineHandler::mediaDeviceDisconnected);
 }
 
+/**
+ * \brief Prepare buffer for internal usage by a pipeline handler
+ * \param[in,out] buffer The buffer to prepare
+ * \param[in] request The request to associate the \a buffer with
+ * \param[in] mem The memory to associate the \a buffer with
+ *
+ * Pipeline handlers creating internal buffers to facilitate data flow in the
+ * pipeline need to prepare the buffers by setting up the buffer object state.
+ * This function help pipeline handler implementations to perform this
+ * preparation.
+ */
+void PipelineHandler::prepareInternalBuffer(Buffer *buffer, Request *request,
+					    BufferMemory *mem)
+{
+	buffer->request_ = request;
+	buffer->mem_ = mem;
+}
+
 /**
  * \brief Slot for the MediaDevice disconnected signal
  */