libcamera: pipeline_handler: Enable silent configuration file lookup

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>
Tested-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Laurent Pinchart 2025-01-10 04:30:03 +02:00
parent 2ae7b2ff74
commit 31a7378c87
2 changed files with 10 additions and 5 deletions

View file

@ -63,7 +63,8 @@ public:
void cancelRequest(Request *request); void cancelRequest(Request *request);
std::string configurationFile(const std::string &subdir, 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_; } const char *name() const { return name_; }

View file

@ -581,6 +581,7 @@ void PipelineHandler::cancelRequest(Request *request)
* \brief Retrieve the absolute path to a platform configuration file * \brief Retrieve the absolute path to a platform configuration file
* \param[in] subdir The pipeline handler specific subdirectory name * \param[in] subdir The pipeline handler specific subdirectory name
* \param[in] name The configuration file name * \param[in] name The configuration file name
* \param[in] silent Disable error messages
* *
* This function locates a named platform configuration file and returns * This function locates a named platform configuration file and returns
* its absolute path to the pipeline handler. It searches the following * 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 * string if no configuration file can be found
*/ */
std::string PipelineHandler::configurationFile(const std::string &subdir, std::string PipelineHandler::configurationFile(const std::string &subdir,
const std::string &name) const const std::string &name,
bool silent) const
{ {
std::string confPath; std::string confPath;
struct stat statbuf; 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) if (ret == 0 && (statbuf.st_mode & S_IFMT) == S_IFREG)
return confPath; return confPath;
LOG(Pipeline, Error) if (!silent)
<< "Configuration file '" << confPath LOG(Pipeline, Error)
<< "' not found for pipeline handler '" << PipelineHandler::name() << "'"; << "Configuration file '" << confPath
<< "' not found for pipeline handler '"
<< PipelineHandler::name() << "'";
return std::string(); return std::string();
} }