[libcamera-devel] [PATCH] android: Make libyaml dependency optional

Roman Stratiienko r.stratiienko at gmail.com
Tue Dec 28 12:22:34 CET 2021


Hi Jacopo,


вт, 28 дек. 2021 г., 13:04 Jacopo Mondi <jacopo at jmondi.org>:

> Hi Roman,
>
> cc Hanlin Chen from ChromiumOS as he's planning to extend
> configuration file support for the ChromeOS Android HAL.


> Before looking into the patch: is there any hope libyaml might become
> part of the standard AOSP distribution (or a process in place to request
> that)
>

I am not aware of that, and I haven't initiated such a process. It will be
a very slow and bumpy road.

Not sure what is planned for these properties in future, but now it is not
necessary to have it in libcamera to have fully functional hal. Also having
no configuration file available will encourage developers to add
corresponding records to dts, which is also a great thing to align with
linux world.


> Thanks
>    j
>
> On Tue, Dec 28, 2021 at 11:51:53AM +0200, Roman Stratiienko wrote:
> > Mainline Android has no libyaml in-tree. Moreover camera_hal_config.cpp
> > uses std::filesystem class that is not permitted for AOSP VNDK vendor
> > libraries.
> >
> > External configuration file is no longer mandatory and DTS overlays can
> > be used to specify camera location and rotation.
> >
> > Do not require external configuration file for cases where meson.build
> > can't find libyaml. Assume that cameras without location specified
> > by V4L2 properties are always external.
> >
> > Signed-off-by: Roman Stratiienko <roman.o.stratiienko at globallogic.com>
> > ---
> >  src/android/camera_hal_manager.cpp | 13 +++++++++++++
> >  src/android/camera_hal_manager.h   |  2 ++
> >  src/android/meson.build            | 10 ++++++++--
> >  3 files changed, 23 insertions(+), 2 deletions(-)
> >
> > diff --git a/src/android/camera_hal_manager.cpp
> b/src/android/camera_hal_manager.cpp
> > index 5f7bfe265c71b..9e575bfa5204a 100644
> > --- a/src/android/camera_hal_manager.cpp
> > +++ b/src/android/camera_hal_manager.cpp
> > @@ -48,6 +48,7 @@ int CameraHalManager::init()
> >  {
> >       cameraManager_ = std::make_unique<CameraManager>();
> >
> > +#ifdef HAVE_LIBYAML
> >       /*
> >        * If the configuration file is not available the HAL only supports
> >        * external cameras. If it exists but it's not valid then error
> out.
> > @@ -56,6 +57,7 @@ int CameraHalManager::init()
> >               LOG(HAL, Error) << "HAL configuration file is not valid";
> >               return -EINVAL;
> >       }
> > +#endif
> >
> >       /* Support camera hotplug. */
> >       cameraManager_->cameraAdded.connect(this,
> &CameraHalManager::cameraAdded);
> > @@ -133,6 +135,7 @@ void
> CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)
> >               }
> >       }
> >
> > +#ifdef HAVE_LIBYAML
> >       /*
> >        * The configuration file must be valid, and contain a
> corresponding
> >        * entry for internal cameras. External cameras can be initialized
> > @@ -145,6 +148,16 @@ void
> CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)
> >       }
> >
> >       const CameraConfigData *cameraConfigData =
> halConfig_.cameraConfigData(cam->id());
> > +#else
> > +     /*
> > +      * Assume that cameras without properties::Location specified are
> external.
> > +      */
> > +     const CameraConfigData *cameraConfigData = nullptr;
> > +     if (!isCameraExternal && cameraLocation(cam.get()) < 0) {
> > +             isCameraExternal = true;
> > +             id = nextExternalCameraId_;
> > +     }
> > +#endif
> >
> >       /*
> >        * Some cameras whose location is reported by libcamera as
> external may
> > diff --git a/src/android/camera_hal_manager.h
> b/src/android/camera_hal_manager.h
> > index a5f8b933a7902..056abbb0d4e54 100644
> > --- a/src/android/camera_hal_manager.h
> > +++ b/src/android/camera_hal_manager.h
> > @@ -56,7 +56,9 @@ private:
> >       CameraDevice *cameraDeviceFromHalId(unsigned int id)
> LIBCAMERA_TSA_REQUIRES(mutex_);
> >
> >       std::unique_ptr<libcamera::CameraManager> cameraManager_;
> > +#ifdef HAVE_LIBYAML
> >       CameraHalConfig halConfig_;
> > +#endif
> >
> >       const camera_module_callbacks_t *callbacks_;
> >       std::vector<std::unique_ptr<CameraDevice>> cameras_
> LIBCAMERA_TSA_GUARDED_BY(mutex_);
> > diff --git a/src/android/meson.build b/src/android/meson.build
> > index 75b4bf2070851..1e471c291a1e4 100644
> > --- a/src/android/meson.build
> > +++ b/src/android/meson.build
> > @@ -3,7 +3,6 @@
> >  android_deps = [
> >      dependency('libexif', required : get_option('android')),
> >      dependency('libjpeg', required : get_option('android')),
> > -    dependency('yaml-0.1', required : get_option('android')),
> >      libcamera_private,
> >  ]
> >
> > @@ -41,7 +40,6 @@ android_hal_sources = files([
> >      'camera3_hal.cpp',
> >      'camera_capabilities.cpp',
> >      'camera_device.cpp',
> > -    'camera_hal_config.cpp',
> >      'camera_hal_manager.cpp',
> >      'camera_metadata.cpp',
> >      'camera_ops.cpp',
> > @@ -56,6 +54,14 @@ android_hal_sources = files([
> >
> >  android_cpp_args = []
> >
> > +libyaml_dep = dependency('yaml-0.1', required : false)
> > +if libyaml_dep.found()
> > +    config_h.set('HAVE_LIBYAML', 1)
> > +    android_hal_sources += files([
> > +        'camera_hal_config.cpp',
> > +    ])
> > +endif
> > +
> >  subdir('cros')
> >  subdir('mm')
> >
> > --
> > 2.30.2
> >
>

Regards,
Roman.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.libcamera.org/pipermail/libcamera-devel/attachments/20211228/6f9aa7d1/attachment.htm>


More information about the libcamera-devel mailing list