[libcamera-devel,v5,09/12] pipeline: raspberrypi: Validate OptionalStream in queueRequestDevice()
diff mbox series

Message ID 20230118085953.7027-10-naush@raspberrypi.com
State Superseded
Headers show
Series
  • Raspberry Pi: Platform configuration and buffer allocation improvements
Related show

Commit Message

Naushir Patuck Jan. 18, 2023, 8:59 a.m. UTC
Add some validation in queueRequestDevice() to ensure that a frame buffer is
provided in a Request if the MandatoryRequestBuffer flag has not been set in
the StreamConfiguration for every configured stream.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
---
 src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Kieran Bingham Jan. 20, 2023, 11:11 a.m. UTC | #1
Quoting Naushir Patuck via libcamera-devel (2023-01-18 08:59:50)
> Add some validation in queueRequestDevice() to ensure that a frame buffer is
> provided in a Request if the MandatoryRequestBuffer flag has not been set in
> the StreamConfiguration for every configured stream.

I think this should be handled in the core. This shouldn't be pipeline
specific. We mustn't have different behaviours in different pipelines.

(That's why it's important we get this right globally)

--
Kieran

 
> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
> ---
>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> index 13d0ab4c4968..39f48e0a57fb 100644
> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> @@ -1153,6 +1153,13 @@ int PipelineHandlerRPi::queueRequestDevice(Camera *camera, Request *request)
>                         stream->setExternalBuffer(buffer);
>                 }
>  
> +               if (!(stream->configuration().hints & StreamConfiguration::Hint::OptionalStream) &&
> +                   !buffer) {
> +                       LOG(RPI, Error) << "No buffer provided for mandatory stream "
> +                                       << stream->name();
> +                       return -EINVAL;
> +               }
> +
>                 /*
>                  * If no buffer is provided by the request for this stream, we
>                  * queue a nullptr to the stream to signify that it must use an
> -- 
> 2.25.1
>
Laurent Pinchart Jan. 22, 2023, 9:35 p.m. UTC | #2
On Fri, Jan 20, 2023 at 11:11:32AM +0000, Kieran Bingham via libcamera-devel wrote:
> Quoting Naushir Patuck via libcamera-devel (2023-01-18 08:59:50)
> > Add some validation in queueRequestDevice() to ensure that a frame buffer is
> > provided in a Request if the MandatoryRequestBuffer flag has not been set in
> > the StreamConfiguration for every configured stream.
> 
> I think this should be handled in the core. This shouldn't be pipeline
> specific. We mustn't have different behaviours in different pipelines.

Agreed. A test in lc-compliance would also be good.

> (That's why it's important we get this right globally)
>  
> > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
> > ---
> >  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 7 +++++++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> > index 13d0ab4c4968..39f48e0a57fb 100644
> > --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> > +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> > @@ -1153,6 +1153,13 @@ int PipelineHandlerRPi::queueRequestDevice(Camera *camera, Request *request)
> >                         stream->setExternalBuffer(buffer);
> >                 }
> >  
> > +               if (!(stream->configuration().hints & StreamConfiguration::Hint::OptionalStream) &&
> > +                   !buffer) {
> > +                       LOG(RPI, Error) << "No buffer provided for mandatory stream "
> > +                                       << stream->name();
> > +                       return -EINVAL;
> > +               }
> > +
> >                 /*
> >                  * If no buffer is provided by the request for this stream, we
> >                  * queue a nullptr to the stream to signify that it must use an
Naushir Patuck Jan. 25, 2023, 2:11 p.m. UTC | #3
Hi Laurent and Kieran,

On Sun, 22 Jan 2023 at 21:35, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> On Fri, Jan 20, 2023 at 11:11:32AM +0000, Kieran Bingham via libcamera-devel wrote:
> > Quoting Naushir Patuck via libcamera-devel (2023-01-18 08:59:50)
> > > Add some validation in queueRequestDevice() to ensure that a frame buffer is
> > > provided in a Request if the MandatoryRequestBuffer flag has not been set in
> > > the StreamConfiguration for every configured stream.
> >
> > I think this should be handled in the core. This shouldn't be pipeline
> > specific. We mustn't have different behaviours in different pipelines.
>
> Agreed. A test in lc-compliance would also be good.

Will add this test to lc-compliance.  As noted earlier, this may take some time
as I need to work my way round this app and first add multi-stream support.

Naush

>
> > (That's why it's important we get this right globally)
> >
> > > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
> > > ---
> > >  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 7 +++++++
> > >  1 file changed, 7 insertions(+)
> > >
> > > diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> > > index 13d0ab4c4968..39f48e0a57fb 100644
> > > --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> > > +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> > > @@ -1153,6 +1153,13 @@ int PipelineHandlerRPi::queueRequestDevice(Camera *camera, Request *request)
> > >                         stream->setExternalBuffer(buffer);
> > >                 }
> > >
> > > +               if (!(stream->configuration().hints & StreamConfiguration::Hint::OptionalStream) &&
> > > +                   !buffer) {
> > > +                       LOG(RPI, Error) << "No buffer provided for mandatory stream "
> > > +                                       << stream->name();
> > > +                       return -EINVAL;
> > > +               }
> > > +
> > >                 /*
> > >                  * If no buffer is provided by the request for this stream, we
> > >                  * queue a nullptr to the stream to signify that it must use an
>
> --
> Regards,
>
> Laurent Pinchart

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
index 13d0ab4c4968..39f48e0a57fb 100644
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
@@ -1153,6 +1153,13 @@  int PipelineHandlerRPi::queueRequestDevice(Camera *camera, Request *request)
 			stream->setExternalBuffer(buffer);
 		}
 
+		if (!(stream->configuration().hints & StreamConfiguration::Hint::OptionalStream) &&
+		    !buffer) {
+			LOG(RPI, Error) << "No buffer provided for mandatory stream "
+					<< stream->name();
+			return -EINVAL;
+		}
+
 		/*
 		 * If no buffer is provided by the request for this stream, we
 		 * queue a nullptr to the stream to signify that it must use an