[libcamera-devel] [PATCH 02/13] libcamera: ipa_proxy: Allow a prefix for the configuration file

Naushir Patuck naush at raspberrypi.com
Thu Apr 27 08:53:00 CEST 2023


Hi Jacopo,

Thank you for your review on this and other patches in the series!

On Wed, 26 Apr 2023 at 17:13, Jacopo Mondi
<jacopo.mondi at ideasonboard.com> wrote:
>
> Hi Naush
>
> On Wed, Apr 26, 2023 at 02:10:46PM +0100, Naushir Patuck via libcamera-devel wrote:
> > Add a prefix parameter to IPAProxy::configurationFile(). This prefix is
> > added to the search path when locating IPA configuration files in the
> > system directories.
> >
> > For example, the system directories etc/libcamera/ipa/<prefix>/ and
> > share/libcamera/ipa/<prefix>/ will be used to search for the IPA
> > configuration files.
> >
> > Signed-off-by: Naushir Patuck <naush at raspberrypi.com>
> > ---
> >  include/libcamera/internal/ipa_proxy.h             |  3 ++-
> >  src/libcamera/ipa_proxy.cpp                        | 11 +++++++----
> >  src/libcamera/pipeline/ipu3/ipu3.cpp               |  4 ++--
> >  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp |  2 +-
> >  src/libcamera/pipeline/rkisp1/rkisp1.cpp           |  4 ++--
> >  src/libcamera/pipeline/vimc/vimc.cpp               |  2 +-
> >  test/ipa/ipa_interface_test.cpp                    |  2 +-
> >  7 files changed, 16 insertions(+), 12 deletions(-)
> >
> > diff --git a/include/libcamera/internal/ipa_proxy.h b/include/libcamera/internal/ipa_proxy.h
> > index 781c8b623605..4ec357425fd3 100644
> > --- a/include/libcamera/internal/ipa_proxy.h
> > +++ b/include/libcamera/internal/ipa_proxy.h
> > @@ -31,7 +31,8 @@ public:
> >
> >       bool isValid() const { return valid_; }
> >
> > -     std::string configurationFile(const std::string &file) const;
> > +     std::string configurationFile(const std::string &file,
> > +                                   const std::string &prefix) const;
>
> This could have a default value of "" for platforms that do not need a
> vendor prefix

I did consider this, but backed out at the last minute because I thought we may
want to have the prefix explicit.  However, since you have separately suggested
it as well, I'll make the change.  I'll reply-to this patch with the update.

Regards,
Naush

>
> With that
> Reviewed-by: Jacopo Mondi <jacopo.mondi at ideasonboard.com>
>
> Thanks
>   j
>
> >
> >  protected:
> >       std::string resolvePath(const std::string &file) const;
> > diff --git a/src/libcamera/ipa_proxy.cpp b/src/libcamera/ipa_proxy.cpp
> > index 3f2cc6b89f60..4a27b0a993fa 100644
> > --- a/src/libcamera/ipa_proxy.cpp
> > +++ b/src/libcamera/ipa_proxy.cpp
> > @@ -72,6 +72,7 @@ IPAProxy::~IPAProxy()
> >  /**
> >   * \brief Retrieve the absolute path to an IPA configuration file
> >   * \param[in] name The configuration file name
> > + * \param[in] prefix The configuration directory prefix when searching system paths
> >   *
> >   * This function locates the configuration file for an IPA and returns its
> >   * absolute path. It searches the following directories, in order:
> > @@ -80,8 +81,8 @@ IPAProxy::~IPAProxy()
> >   *   environment variable ; or
> >   * - If libcamera is not installed, the src/ipa/ directory within the source
> >   *   tree ; otherwise
> > - * - The system sysconf (etc/libcamera/ipa) and the data (share/libcamera/ipa/)
> > - *   directories.
> > + * - The system sysconf (etc/libcamera/ipa/<prefix>/) and the data
> > + *   (share/libcamera/ipa/<prefix>/) directories.
> >   *
> >   * The system directories are not searched if libcamera is not installed.
> >   *
> > @@ -92,7 +93,8 @@ IPAProxy::~IPAProxy()
> >   * \return The full path to the IPA configuration file, or an empty string if
> >   * no configuration file can be found
> >   */
> > -std::string IPAProxy::configurationFile(const std::string &name) const
> > +std::string IPAProxy::configurationFile(const std::string &name,
> > +                                     const std::string &prefix) const
> >  {
> >       struct stat statbuf;
> >       int ret;
> > @@ -139,7 +141,8 @@ std::string IPAProxy::configurationFile(const std::string &name) const
> >       } else {
> >               /* Else look in the system locations. */
> >               for (const auto &dir : utils::split(IPA_CONFIG_DIR, ":")) {
> > -                     std::string confPath = dir + "/" + ipaName + "/" + name;
> > +                     std::string confPath = dir + "/" + prefix + "/" +
> > +                                            ipaName + "/" + name;
> >                       ret = stat(confPath.c_str(), &statbuf);
> >                       if (ret == 0 && (statbuf.st_mode & S_IFMT) == S_IFREG)
> >                               return confPath;
> > diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> > index 355cb0cb76b8..a48d7e78d25e 100644
> > --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> > +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> > @@ -1186,9 +1186,9 @@ int IPU3CameraData::loadIPA()
> >        * The API tuning file is made from the sensor name. If the tuning file
> >        * isn't found, fall back to the 'uncalibrated' file.
> >        */
> > -     std::string ipaTuningFile = ipa_->configurationFile(sensor->model() + ".yaml");
> > +     std::string ipaTuningFile = ipa_->configurationFile(sensor->model() + ".yaml", "");
> >       if (ipaTuningFile.empty())
> > -             ipaTuningFile = ipa_->configurationFile("uncalibrated.yaml");
> > +             ipaTuningFile = ipa_->configurationFile("uncalibrated.yaml", "");
> >
> >       ret = ipa_->init(IPASettings{ ipaTuningFile, sensor->model() },
> >                        sensorInfo, sensor->controls(), &ipaControls_);
> > diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> > index 0060044143cc..a4fff28bf198 100644
> > --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> > +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> > @@ -1668,7 +1668,7 @@ int RPiCameraData::loadIPA(ipa::RPi::IPAInitResult *result)
> >               std::string model = sensor_->model();
> >               if (isMonoSensor(sensor_))
> >                       model += "_mono";
> > -             configurationFile = ipa_->configurationFile(model + ".json");
> > +             configurationFile = ipa_->configurationFile(model + ".json", "");
> >       } else {
> >               configurationFile = std::string(configFromEnv);
> >       }
> > diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> > index 8a30fe061d04..e338cdee2a2d 100644
> > --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> > +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> > @@ -349,13 +349,13 @@ int RkISP1CameraData::loadIPA(unsigned int hwRevision)
> >       std::string ipaTuningFile;
> >       char const *configFromEnv = utils::secure_getenv("LIBCAMERA_RKISP1_TUNING_FILE");
> >       if (!configFromEnv || *configFromEnv == '\0') {
> > -             ipaTuningFile = ipa_->configurationFile(sensor_->model() + ".yaml");
> > +             ipaTuningFile = ipa_->configurationFile(sensor_->model() + ".yaml", "");
> >               /*
> >                * If the tuning file isn't found, fall back to the
> >                * 'uncalibrated' configuration file.
> >                */
> >               if (ipaTuningFile.empty())
> > -                     ipaTuningFile = ipa_->configurationFile("uncalibrated.yaml");
> > +                     ipaTuningFile = ipa_->configurationFile("uncalibrated.yaml", "");
> >       } else {
> >               ipaTuningFile = std::string(configFromEnv);
> >       }
> > diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp
> > index 204f5ad73f6d..5fbabcc5763d 100644
> > --- a/src/libcamera/pipeline/vimc/vimc.cpp
> > +++ b/src/libcamera/pipeline/vimc/vimc.cpp
> > @@ -472,7 +472,7 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator)
> >
> >       data->ipa_->paramsBufferReady.connect(data.get(), &VimcCameraData::paramsBufferReady);
> >
> > -     std::string conf = data->ipa_->configurationFile("vimc.conf");
> > +     std::string conf = data->ipa_->configurationFile("vimc.conf", "");
> >       Flags<ipa::vimc::TestFlag> inFlags = ipa::vimc::TestFlag::Flag2;
> >       Flags<ipa::vimc::TestFlag> outFlags;
> >       data->ipa_->init(IPASettings{ conf, data->sensor_->model() },
> > diff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp
> > index 051ef96e7ed2..b25de222b9b4 100644
> > --- a/test/ipa/ipa_interface_test.cpp
> > +++ b/test/ipa/ipa_interface_test.cpp
> > @@ -105,7 +105,7 @@ protected:
> >               }
> >
> >               /* Test initialization of IPA module. */
> > -             std::string conf = ipa_->configurationFile("vimc.conf");
> > +             std::string conf = ipa_->configurationFile("vimc.conf", "");
> >               Flags<ipa::vimc::TestFlag> inFlags;
> >               Flags<ipa::vimc::TestFlag> outFlags;
> >               int ret = ipa_->init(IPASettings{ conf, "vimc" },
> > --
> > 2.34.1
> >


More information about the libcamera-devel mailing list