[1/2] libcamera: pipeline_handler: Enable silent configuration file lookup
diff mbox series

Message ID 20250110023920.28502-1-laurent.pinchart@ideasonboard.com
State Accepted
Commit 31a7378c879a09e88c8908c6743c9a120c66a3c5
Headers show
Series
  • [1/2] libcamera: pipeline_handler: Enable silent configuration file lookup
Related show

Commit Message

Laurent Pinchart Jan. 10, 2025, 2:39 a.m. UTC
The PipelineHandler::configurationFile() function prints an error
message when no configuration file is found. It can be useful for
pipeline handlers to silence the lookup operation and handle errors
themselves. Add a silent parameter to the function to enable this.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 include/libcamera/internal/pipeline_handler.h |  3 ++-
 src/libcamera/pipeline_handler.cpp            | 12 ++++++++----
 2 files changed, 10 insertions(+), 5 deletions(-)


base-commit: d49a84a4f3aa63efc900564ff32558e4f5d85b04

Comments

Julien Vuillaumier Jan. 10, 2025, 2:30 p.m. UTC | #1
Hi Laurent,

On 10/01/2025 03:39, Laurent Pinchart wrote:
> 
> The PipelineHandler::configurationFile() function prints an error
> message when no configuration file is found. It can be useful for
> pipeline handlers to silence the lookup operation and handle errors
> themselves. Add a silent parameter to the function to enable this.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Those patches mute the noisy logs indeed. Thank you for looking at it.
If tag is appropriate (otherwise please ignore), for the series:

Tested-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>

Regards,
Julien

> ---
>   include/libcamera/internal/pipeline_handler.h |  3 ++-
>   src/libcamera/pipeline_handler.cpp            | 12 ++++++++----
>   2 files changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h
> index fb28a18d0f4668ab..972a2fa65310e1d9 100644
> --- a/include/libcamera/internal/pipeline_handler.h
> +++ b/include/libcamera/internal/pipeline_handler.h
> @@ -63,7 +63,8 @@ public:
>          void cancelRequest(Request *request);
> 
>          std::string configurationFile(const std::string &subdir,
> -                                     const std::string &name) const;
> +                                     const std::string &name,
> +                                     bool silent = false) const;
> 
>          const char *name() const { return name_; }
> 
> diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp
> index caa5c20e74836956..d84dff3c9f198756 100644
> --- a/src/libcamera/pipeline_handler.cpp
> +++ b/src/libcamera/pipeline_handler.cpp
> @@ -581,6 +581,7 @@ void PipelineHandler::cancelRequest(Request *request)
>    * \brief Retrieve the absolute path to a platform configuration file
>    * \param[in] subdir The pipeline handler specific subdirectory name
>    * \param[in] name The configuration file name
> + * \param[in] silent Disable error messages
>    *
>    * This function locates a named platform configuration file and returns
>    * its absolute path to the pipeline handler. It searches the following
> @@ -596,7 +597,8 @@ void PipelineHandler::cancelRequest(Request *request)
>    * string if no configuration file can be found
>    */
>   std::string PipelineHandler::configurationFile(const std::string &subdir,
> -                                              const std::string &name) const
> +                                              const std::string &name,
> +                                              bool silent) const
>   {
>          std::string confPath;
>          struct stat statbuf;
> @@ -626,9 +628,11 @@ std::string PipelineHandler::configurationFile(const std::string &subdir,
>          if (ret == 0 && (statbuf.st_mode & S_IFMT) == S_IFREG)
>                  return confPath;
> 
> -       LOG(Pipeline, Error)
> -               << "Configuration file '" << confPath
> -               << "' not found for pipeline handler '" << PipelineHandler::name() << "'";
> +       if (!silent)
> +               LOG(Pipeline, Error)
> +                       << "Configuration file '" << confPath
> +                       << "' not found for pipeline handler '"
> +                       << PipelineHandler::name() << "'";
> 
>          return std::string();
>   }
> 
> base-commit: d49a84a4f3aa63efc900564ff32558e4f5d85b04
> --
> Regards,
> 
> Laurent Pinchart
>
Kieran Bingham Jan. 10, 2025, 3:21 p.m. UTC | #2
Quoting Julien Vuillaumier (2025-01-10 14:30:22)
> 
> Hi Laurent,
> 
> On 10/01/2025 03:39, Laurent Pinchart wrote:
> > 
> > The PipelineHandler::configurationFile() function prints an error
> > message when no configuration file is found. It can be useful for
> > pipeline handlers to silence the lookup operation and handle errors
> > themselves. Add a silent parameter to the function to enable this.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> Those patches mute the noisy logs indeed. Thank you for looking at it.
> If tag is appropriate (otherwise please ignore), for the series:
> 
> Tested-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>

Tags are enormously valuable and welcome, thanks!

Also for both patches from me:


Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> 
> Regards,
> Julien
> 
> > ---
> >   include/libcamera/internal/pipeline_handler.h |  3 ++-
> >   src/libcamera/pipeline_handler.cpp            | 12 ++++++++----
> >   2 files changed, 10 insertions(+), 5 deletions(-)
> > 
> > diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h
> > index fb28a18d0f4668ab..972a2fa65310e1d9 100644
> > --- a/include/libcamera/internal/pipeline_handler.h
> > +++ b/include/libcamera/internal/pipeline_handler.h
> > @@ -63,7 +63,8 @@ public:
> >          void cancelRequest(Request *request);
> > 
> >          std::string configurationFile(const std::string &subdir,
> > -                                     const std::string &name) const;
> > +                                     const std::string &name,
> > +                                     bool silent = false) const;
> > 
> >          const char *name() const { return name_; }
> > 
> > diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp
> > index caa5c20e74836956..d84dff3c9f198756 100644
> > --- a/src/libcamera/pipeline_handler.cpp
> > +++ b/src/libcamera/pipeline_handler.cpp
> > @@ -581,6 +581,7 @@ void PipelineHandler::cancelRequest(Request *request)
> >    * \brief Retrieve the absolute path to a platform configuration file
> >    * \param[in] subdir The pipeline handler specific subdirectory name
> >    * \param[in] name The configuration file name
> > + * \param[in] silent Disable error messages
> >    *
> >    * This function locates a named platform configuration file and returns
> >    * its absolute path to the pipeline handler. It searches the following
> > @@ -596,7 +597,8 @@ void PipelineHandler::cancelRequest(Request *request)
> >    * string if no configuration file can be found
> >    */
> >   std::string PipelineHandler::configurationFile(const std::string &subdir,
> > -                                              const std::string &name) const
> > +                                              const std::string &name,
> > +                                              bool silent) const
> >   {
> >          std::string confPath;
> >          struct stat statbuf;
> > @@ -626,9 +628,11 @@ std::string PipelineHandler::configurationFile(const std::string &subdir,
> >          if (ret == 0 && (statbuf.st_mode & S_IFMT) == S_IFREG)
> >                  return confPath;
> > 
> > -       LOG(Pipeline, Error)
> > -               << "Configuration file '" << confPath
> > -               << "' not found for pipeline handler '" << PipelineHandler::name() << "'";
> > +       if (!silent)
> > +               LOG(Pipeline, Error)
> > +                       << "Configuration file '" << confPath
> > +                       << "' not found for pipeline handler '"
> > +                       << PipelineHandler::name() << "'";
> > 
> >          return std::string();
> >   }
> > 
> > base-commit: d49a84a4f3aa63efc900564ff32558e4f5d85b04
> > --
> > Regards,
> > 
> > Laurent Pinchart
> > 
>

Patch
diff mbox series

diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h
index fb28a18d0f4668ab..972a2fa65310e1d9 100644
--- a/include/libcamera/internal/pipeline_handler.h
+++ b/include/libcamera/internal/pipeline_handler.h
@@ -63,7 +63,8 @@  public:
 	void cancelRequest(Request *request);
 
 	std::string configurationFile(const std::string &subdir,
-				      const std::string &name) const;
+				      const std::string &name,
+				      bool silent = false) const;
 
 	const char *name() const { return name_; }
 
diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp
index caa5c20e74836956..d84dff3c9f198756 100644
--- a/src/libcamera/pipeline_handler.cpp
+++ b/src/libcamera/pipeline_handler.cpp
@@ -581,6 +581,7 @@  void PipelineHandler::cancelRequest(Request *request)
  * \brief Retrieve the absolute path to a platform configuration file
  * \param[in] subdir The pipeline handler specific subdirectory name
  * \param[in] name The configuration file name
+ * \param[in] silent Disable error messages
  *
  * This function locates a named platform configuration file and returns
  * its absolute path to the pipeline handler. It searches the following
@@ -596,7 +597,8 @@  void PipelineHandler::cancelRequest(Request *request)
  * string if no configuration file can be found
  */
 std::string PipelineHandler::configurationFile(const std::string &subdir,
-					       const std::string &name) const
+					       const std::string &name,
+					       bool silent) const
 {
 	std::string confPath;
 	struct stat statbuf;
@@ -626,9 +628,11 @@  std::string PipelineHandler::configurationFile(const std::string &subdir,
 	if (ret == 0 && (statbuf.st_mode & S_IFMT) == S_IFREG)
 		return confPath;
 
-	LOG(Pipeline, Error)
-		<< "Configuration file '" << confPath
-		<< "' not found for pipeline handler '" << PipelineHandler::name() << "'";
+	if (!silent)
+		LOG(Pipeline, Error)
+			<< "Configuration file '" << confPath
+			<< "' not found for pipeline handler '"
+			<< PipelineHandler::name() << "'";
 
 	return std::string();
 }