[{"id":21892,"web_url":"https://patchwork.libcamera.org/comment/21892/","msgid":"<20211228110551.rxgzp77qfwpfj2n2@uno.localdomain>","date":"2021-12-28T11:05:51","subject":"Re: [libcamera-devel] [PATCH] android: Make libyaml dependency\n\toptional","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Roman,\n\ncc Hanlin Chen from ChromiumOS as he's planning to extend\nconfiguration file support for the ChromeOS Android HAL.\n\nBefore looking into the patch: is there any hope libyaml might become\npart of the standard AOSP distribution (or a process in place to request\nthat).\n\nThanks\n   j\n\nOn Tue, Dec 28, 2021 at 11:51:53AM +0200, Roman Stratiienko wrote:\n> Mainline Android has no libyaml in-tree. Moreover camera_hal_config.cpp\n> uses std::filesystem class that is not permitted for AOSP VNDK vendor\n> libraries.\n>\n> External configuration file is no longer mandatory and DTS overlays can\n> be used to specify camera location and rotation.\n>\n> Do not require external configuration file for cases where meson.build\n> can't find libyaml. Assume that cameras without location specified\n> by V4L2 properties are always external.\n>\n> Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>\n> ---\n>  src/android/camera_hal_manager.cpp | 13 +++++++++++++\n>  src/android/camera_hal_manager.h   |  2 ++\n>  src/android/meson.build            | 10 ++++++++--\n>  3 files changed, 23 insertions(+), 2 deletions(-)\n>\n> diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp\n> index 5f7bfe265c71b..9e575bfa5204a 100644\n> --- a/src/android/camera_hal_manager.cpp\n> +++ b/src/android/camera_hal_manager.cpp\n> @@ -48,6 +48,7 @@ int CameraHalManager::init()\n>  {\n>  \tcameraManager_ = std::make_unique<CameraManager>();\n>\n> +#ifdef HAVE_LIBYAML\n>  \t/*\n>  \t * If the configuration file is not available the HAL only supports\n>  \t * external cameras. If it exists but it's not valid then error out.\n> @@ -56,6 +57,7 @@ int CameraHalManager::init()\n>  \t\tLOG(HAL, Error) << \"HAL configuration file is not valid\";\n>  \t\treturn -EINVAL;\n>  \t}\n> +#endif\n>\n>  \t/* Support camera hotplug. */\n>  \tcameraManager_->cameraAdded.connect(this, &CameraHalManager::cameraAdded);\n> @@ -133,6 +135,7 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\n>  \t\t}\n>  \t}\n>\n> +#ifdef HAVE_LIBYAML\n>  \t/*\n>  \t * The configuration file must be valid, and contain a corresponding\n>  \t * entry for internal cameras. External cameras can be initialized\n> @@ -145,6 +148,16 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\n>  \t}\n>\n>  \tconst CameraConfigData *cameraConfigData = halConfig_.cameraConfigData(cam->id());\n> +#else\n> +\t/*\n> +\t * Assume that cameras without properties::Location specified are external.\n> +\t */\n> +\tconst CameraConfigData *cameraConfigData = nullptr;\n> +\tif (!isCameraExternal && cameraLocation(cam.get()) < 0) {\n> +\t\tisCameraExternal = true;\n> +\t\tid = nextExternalCameraId_;\n> +\t}\n> +#endif\n>\n>  \t/*\n>  \t * Some cameras whose location is reported by libcamera as external may\n> diff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h\n> index a5f8b933a7902..056abbb0d4e54 100644\n> --- a/src/android/camera_hal_manager.h\n> +++ b/src/android/camera_hal_manager.h\n> @@ -56,7 +56,9 @@ private:\n>  \tCameraDevice *cameraDeviceFromHalId(unsigned int id) LIBCAMERA_TSA_REQUIRES(mutex_);\n>\n>  \tstd::unique_ptr<libcamera::CameraManager> cameraManager_;\n> +#ifdef HAVE_LIBYAML\n>  \tCameraHalConfig halConfig_;\n> +#endif\n>\n>  \tconst camera_module_callbacks_t *callbacks_;\n>  \tstd::vector<std::unique_ptr<CameraDevice>> cameras_ LIBCAMERA_TSA_GUARDED_BY(mutex_);\n> diff --git a/src/android/meson.build b/src/android/meson.build\n> index 75b4bf2070851..1e471c291a1e4 100644\n> --- a/src/android/meson.build\n> +++ b/src/android/meson.build\n> @@ -3,7 +3,6 @@\n>  android_deps = [\n>      dependency('libexif', required : get_option('android')),\n>      dependency('libjpeg', required : get_option('android')),\n> -    dependency('yaml-0.1', required : get_option('android')),\n>      libcamera_private,\n>  ]\n>\n> @@ -41,7 +40,6 @@ android_hal_sources = files([\n>      'camera3_hal.cpp',\n>      'camera_capabilities.cpp',\n>      'camera_device.cpp',\n> -    'camera_hal_config.cpp',\n>      'camera_hal_manager.cpp',\n>      'camera_metadata.cpp',\n>      'camera_ops.cpp',\n> @@ -56,6 +54,14 @@ android_hal_sources = files([\n>\n>  android_cpp_args = []\n>\n> +libyaml_dep = dependency('yaml-0.1', required : false)\n> +if libyaml_dep.found()\n> +    config_h.set('HAVE_LIBYAML', 1)\n> +    android_hal_sources += files([\n> +        'camera_hal_config.cpp',\n> +    ])\n> +endif\n> +\n>  subdir('cros')\n>  subdir('mm')\n>\n> --\n> 2.30.2\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D9229BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 28 Dec 2021 11:04:58 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2D68C6090D;\n\tTue, 28 Dec 2021 12:04:58 +0100 (CET)","from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net\n\t[217.70.183.198])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8CF0C60868\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Dec 2021 12:04:56 +0100 (CET)","(Authenticated sender: jacopo@jmondi.org)\n\tby relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 18A6FC0009;\n\tTue, 28 Dec 2021 11:04:54 +0000 (UTC)"],"Date":"Tue, 28 Dec 2021 12:05:51 +0100","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Roman Stratiienko <r.stratiienko@gmail.com>","Message-ID":"<20211228110551.rxgzp77qfwpfj2n2@uno.localdomain>","References":"<20211228095153.611009-1-roman.o.stratiienko@globallogic.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20211228095153.611009-1-roman.o.stratiienko@globallogic.com>","Subject":"Re: [libcamera-devel] [PATCH] android: Make libyaml dependency\n\toptional","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org,\n\tRoman Stratiienko <roman.o.stratiienko@globallogic.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":21893,"web_url":"https://patchwork.libcamera.org/comment/21893/","msgid":"<CAGphcd=H0Ns5_1WL0YTsTvt9zkMCGNAaDygNcN4GXGhZfqkQMA@mail.gmail.com>","date":"2021-12-28T11:22:34","subject":"Re: [libcamera-devel] [PATCH] android: Make libyaml dependency\n\toptional","submitter":{"id":106,"url":"https://patchwork.libcamera.org/api/people/106/","name":"Roman Stratiienko","email":"r.stratiienko@gmail.com"},"content":"Hi Jacopo,\n\n\nвт, 28 дек. 2021 г., 13:04 Jacopo Mondi <jacopo@jmondi.org>:\n\n> Hi Roman,\n>\n> cc Hanlin Chen from ChromiumOS as he's planning to extend\n> configuration file support for the ChromeOS Android HAL.\n\n\n> Before looking into the patch: is there any hope libyaml might become\n> part of the standard AOSP distribution (or a process in place to request\n> that)\n>\n\nI am not aware of that, and I haven't initiated such a process. It will be\na very slow and bumpy road.\n\nNot sure what is planned for these properties in future, but now it is not\nnecessary to have it in libcamera to have fully functional hal. Also having\nno configuration file available will encourage developers to add\ncorresponding records to dts, which is also a great thing to align with\nlinux world.\n\n\n> Thanks\n>    j\n>\n> On Tue, Dec 28, 2021 at 11:51:53AM +0200, Roman Stratiienko wrote:\n> > Mainline Android has no libyaml in-tree. Moreover camera_hal_config.cpp\n> > uses std::filesystem class that is not permitted for AOSP VNDK vendor\n> > libraries.\n> >\n> > External configuration file is no longer mandatory and DTS overlays can\n> > be used to specify camera location and rotation.\n> >\n> > Do not require external configuration file for cases where meson.build\n> > can't find libyaml. Assume that cameras without location specified\n> > by V4L2 properties are always external.\n> >\n> > Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>\n> > ---\n> >  src/android/camera_hal_manager.cpp | 13 +++++++++++++\n> >  src/android/camera_hal_manager.h   |  2 ++\n> >  src/android/meson.build            | 10 ++++++++--\n> >  3 files changed, 23 insertions(+), 2 deletions(-)\n> >\n> > diff --git a/src/android/camera_hal_manager.cpp\n> b/src/android/camera_hal_manager.cpp\n> > index 5f7bfe265c71b..9e575bfa5204a 100644\n> > --- a/src/android/camera_hal_manager.cpp\n> > +++ b/src/android/camera_hal_manager.cpp\n> > @@ -48,6 +48,7 @@ int CameraHalManager::init()\n> >  {\n> >       cameraManager_ = std::make_unique<CameraManager>();\n> >\n> > +#ifdef HAVE_LIBYAML\n> >       /*\n> >        * If the configuration file is not available the HAL only supports\n> >        * external cameras. If it exists but it's not valid then error\n> out.\n> > @@ -56,6 +57,7 @@ int CameraHalManager::init()\n> >               LOG(HAL, Error) << \"HAL configuration file is not valid\";\n> >               return -EINVAL;\n> >       }\n> > +#endif\n> >\n> >       /* Support camera hotplug. */\n> >       cameraManager_->cameraAdded.connect(this,\n> &CameraHalManager::cameraAdded);\n> > @@ -133,6 +135,7 @@ void\n> CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\n> >               }\n> >       }\n> >\n> > +#ifdef HAVE_LIBYAML\n> >       /*\n> >        * The configuration file must be valid, and contain a\n> corresponding\n> >        * entry for internal cameras. External cameras can be initialized\n> > @@ -145,6 +148,16 @@ void\n> CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\n> >       }\n> >\n> >       const CameraConfigData *cameraConfigData =\n> halConfig_.cameraConfigData(cam->id());\n> > +#else\n> > +     /*\n> > +      * Assume that cameras without properties::Location specified are\n> external.\n> > +      */\n> > +     const CameraConfigData *cameraConfigData = nullptr;\n> > +     if (!isCameraExternal && cameraLocation(cam.get()) < 0) {\n> > +             isCameraExternal = true;\n> > +             id = nextExternalCameraId_;\n> > +     }\n> > +#endif\n> >\n> >       /*\n> >        * Some cameras whose location is reported by libcamera as\n> external may\n> > diff --git a/src/android/camera_hal_manager.h\n> b/src/android/camera_hal_manager.h\n> > index a5f8b933a7902..056abbb0d4e54 100644\n> > --- a/src/android/camera_hal_manager.h\n> > +++ b/src/android/camera_hal_manager.h\n> > @@ -56,7 +56,9 @@ private:\n> >       CameraDevice *cameraDeviceFromHalId(unsigned int id)\n> LIBCAMERA_TSA_REQUIRES(mutex_);\n> >\n> >       std::unique_ptr<libcamera::CameraManager> cameraManager_;\n> > +#ifdef HAVE_LIBYAML\n> >       CameraHalConfig halConfig_;\n> > +#endif\n> >\n> >       const camera_module_callbacks_t *callbacks_;\n> >       std::vector<std::unique_ptr<CameraDevice>> cameras_\n> LIBCAMERA_TSA_GUARDED_BY(mutex_);\n> > diff --git a/src/android/meson.build b/src/android/meson.build\n> > index 75b4bf2070851..1e471c291a1e4 100644\n> > --- a/src/android/meson.build\n> > +++ b/src/android/meson.build\n> > @@ -3,7 +3,6 @@\n> >  android_deps = [\n> >      dependency('libexif', required : get_option('android')),\n> >      dependency('libjpeg', required : get_option('android')),\n> > -    dependency('yaml-0.1', required : get_option('android')),\n> >      libcamera_private,\n> >  ]\n> >\n> > @@ -41,7 +40,6 @@ android_hal_sources = files([\n> >      'camera3_hal.cpp',\n> >      'camera_capabilities.cpp',\n> >      'camera_device.cpp',\n> > -    'camera_hal_config.cpp',\n> >      'camera_hal_manager.cpp',\n> >      'camera_metadata.cpp',\n> >      'camera_ops.cpp',\n> > @@ -56,6 +54,14 @@ android_hal_sources = files([\n> >\n> >  android_cpp_args = []\n> >\n> > +libyaml_dep = dependency('yaml-0.1', required : false)\n> > +if libyaml_dep.found()\n> > +    config_h.set('HAVE_LIBYAML', 1)\n> > +    android_hal_sources += files([\n> > +        'camera_hal_config.cpp',\n> > +    ])\n> > +endif\n> > +\n> >  subdir('cros')\n> >  subdir('mm')\n> >\n> > --\n> > 2.30.2\n> >\n>\n\nRegards,\nRoman.","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id C660CBE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 28 Dec 2021 11:22:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E501D6090D;\n\tTue, 28 Dec 2021 12:22:48 +0100 (CET)","from mail-pl1-x633.google.com (mail-pl1-x633.google.com\n\t[IPv6:2607:f8b0:4864:20::633])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 94E5460868\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Dec 2021 12:22:46 +0100 (CET)","by mail-pl1-x633.google.com with SMTP id n16so13383080plc.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Dec 2021 03:22:46 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"Es+k5l80\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=oL5CGOBIADnHukESDHl2BepE6nPi1G2hECKcIj6L+eg=;\n\tb=Es+k5l80yrf/PedJHr2rmyt1TB1fQNAckCQ63uEKwBVL81uoUB98Jh6pgbYpSrZRn9\n\t3vUax2EL+pZuUFQRig89i8LC56zBpdNgMwOIohScTtmSFUzcz+BxBbvrhsqZfUXe7mUP\n\tl3HboLGoMxpDtDGasQxifn5QGzwNB/HZ4OU2iXlsinpqGJI5CIse0hRHTmp9aA5oOwVo\n\tgnH0aJC70wMtNYcPR3+S33xWl7wmgQPgOoyBqHBZXSPxWExYvoIA090xqbdp+yN843qe\n\tEMl58aGR4Hlhjc8K90rmhP1rpT8Hr41RHbAtdxFQwNfv5x4gwVGIBw/H14z1TGhAHluZ\n\tGosQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=oL5CGOBIADnHukESDHl2BepE6nPi1G2hECKcIj6L+eg=;\n\tb=mth9Enk7+j+0Vi4MqPkYSs5vdeP6jxb8YsCTDgLqJYaxWxTSFm26bkY/u4TcHpJ5i1\n\tMB8l6RF4KiuNWNdhCFKmm3dX0/N2Aw90mCvBZ4O5B0vqMlgxjWBF1+HgmhQ6j1Urgwgv\n\taxruoFI5XodtbNUtQyUMNrTb5DVOlCRzGpmRgr0A2p9w9gjufSjWRYLBGhb915rbJjkr\n\tbBj03PtWz6LO+H8u1wE5DI1P/rlU/7Wuznlvs6OASmKstDwzTUBZLSZjWFvpPJnV7dW9\n\tvk2W3OdRlofV2rOvR6+G0gM9yPONvVNygVrSWUpCOgCl8Ct7OPxTt5NFiYlI1OpDl/hY\n\tGwbg==","X-Gm-Message-State":"AOAM531hq4hi3vmj42sSvp3VIViAIobt01uZXhBgNDj7yOg7QWJAIHBK\n\tETm3UAqiEt21njw41ESmgXYIHN9OkalQDWbrZMs=","X-Google-Smtp-Source":"ABdhPJy/IY3i0K09RzhxZRkQhkxA28TWHMh7k1OQ/+5V+UamZPkuyd28zLXrPdR/Ta14zR0aWvCasuNBGB90rwptwCg=","X-Received":"by 2002:a17:90a:db81:: with SMTP id\n\th1mr26260026pjv.163.1640690565001; \n\tTue, 28 Dec 2021 03:22:45 -0800 (PST)","MIME-Version":"1.0","References":"<20211228095153.611009-1-roman.o.stratiienko@globallogic.com>\n\t<20211228110551.rxgzp77qfwpfj2n2@uno.localdomain>","In-Reply-To":"<20211228110551.rxgzp77qfwpfj2n2@uno.localdomain>","From":"Roman Stratiienko <r.stratiienko@gmail.com>","Date":"Tue, 28 Dec 2021 13:22:34 +0200","Message-ID":"<CAGphcd=H0Ns5_1WL0YTsTvt9zkMCGNAaDygNcN4GXGhZfqkQMA@mail.gmail.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Content-Type":"multipart/alternative; boundary=\"0000000000005033c405d4330a3c\"","Subject":"Re: [libcamera-devel] [PATCH] android: Make libyaml dependency\n\toptional","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>,\n\tRoman Stratiienko <roman.o.stratiienko@globallogic.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":21895,"web_url":"https://patchwork.libcamera.org/comment/21895/","msgid":"<YctXI7T1elw77Rjr@pendragon.ideasonboard.com>","date":"2021-12-28T18:27:47","subject":"Re: [libcamera-devel] [PATCH] android: Make libyaml dependency\n\toptional","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Roman,\n\nOn Tue, Dec 28, 2021 at 01:22:34PM +0200, Roman Stratiienko wrote:\n> вт, 28 дек. 2021 г., 13:04 Jacopo Mondi:\n> > Hi Roman,\n> >\n> > cc Hanlin Chen from ChromiumOS as he's planning to extend\n> > configuration file support for the ChromeOS Android HAL.\n> \n> > Before looking into the patch: is there any hope libyaml might become\n> > part of the standard AOSP distribution (or a process in place to request\n> > that)\n> \n> I am not aware of that, and I haven't initiated such a process. It will be\n> a very slow and bumpy road.\n> \n> Not sure what is planned for these properties in future, but now it is not\n> necessary to have it in libcamera to have fully functional hal. Also having\n> no configuration file available will encourage developers to add\n> corresponding records to dts, which is also a great thing to align with\n> linux world.\n\nOur goals align here. This is exactly why we have decided not to set the\ncamera location in a configuration file for the libcamera core, but to\nisolate it in the HAL as a temporary (but in practice likely a long-term\ntemporary) measure, as we have to support platforms that will take some\ntime before a firmware (ACPI in this case) update can be deployed.\n\nThis being said, we will introduce a configuration file for the\nlibcamera core in the near future, and we also plan to use libyaml\nthere. The tuning files for the IPU3 and RkISP1 IPA modules will also\nuse YAML, and I'd like to move the Raspberry Pi tuning files from JSON\nto YAML for consistency.\n\nWe could merge this patch in the meantime, but compilation on Android\nwill likely break again soon. I wonder if we couldn't instead use a\nmeson wrap to include libyaml as a subproject. This should solve the\nissue in the longer term.\n\nBy the way, out of curiosity, how do you compile libcamera for Android ?\nWe have a look at Soong (as the Makefile-based build system is being\nphased out), but blueprint files don't support all our needs (and would\nbe annoying to maintain manually), and there's no way we found to\ngenerate Android.bp files from meson in a way that would integrate with\nSoong. This is still an unsolved problem, and I'm increasingly tempted\nto do the same as mesa3d and just document that libcamera should be\nbuilt outside of AOSP, using the NDK.\n\n> > On Tue, Dec 28, 2021 at 11:51:53AM +0200, Roman Stratiienko wrote:\n> > > Mainline Android has no libyaml in-tree. Moreover camera_hal_config.cpp\n> > > uses std::filesystem class that is not permitted for AOSP VNDK vendor\n> > > libraries.\n> > >\n> > > External configuration file is no longer mandatory and DTS overlays can\n> > > be used to specify camera location and rotation.\n> > >\n> > > Do not require external configuration file for cases where meson.build\n> > > can't find libyaml. Assume that cameras without location specified\n> > > by V4L2 properties are always external.\n> > >\n> > > Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>\n> > > ---\n> > >  src/android/camera_hal_manager.cpp | 13 +++++++++++++\n> > >  src/android/camera_hal_manager.h   |  2 ++\n> > >  src/android/meson.build            | 10 ++++++++--\n> > >  3 files changed, 23 insertions(+), 2 deletions(-)\n> > >\n> > > diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp\n> > > index 5f7bfe265c71b..9e575bfa5204a 100644\n> > > --- a/src/android/camera_hal_manager.cpp\n> > > +++ b/src/android/camera_hal_manager.cpp\n> > > @@ -48,6 +48,7 @@ int CameraHalManager::init()\n> > >  {\n> > >       cameraManager_ = std::make_unique<CameraManager>();\n> > >\n> > > +#ifdef HAVE_LIBYAML\n> > >       /*\n> > >        * If the configuration file is not available the HAL only supports\n> > >        * external cameras. If it exists but it's not valid then error out.\n> > > @@ -56,6 +57,7 @@ int CameraHalManager::init()\n> > >               LOG(HAL, Error) << \"HAL configuration file is not valid\";\n> > >               return -EINVAL;\n> > >       }\n> > > +#endif\n> > >\n> > >       /* Support camera hotplug. */\n> > >       cameraManager_->cameraAdded.connect(this, &CameraHalManager::cameraAdded);\n> > > @@ -133,6 +135,7 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\n> > >               }\n> > >       }\n> > >\n> > > +#ifdef HAVE_LIBYAML\n> > >       /*\n> > >        * The configuration file must be valid, and contain a corresponding\n> > >        * entry for internal cameras. External cameras can be initialized\n> > > @@ -145,6 +148,16 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\n> > >       }\n> > >\n> > >       const CameraConfigData *cameraConfigData = halConfig_.cameraConfigData(cam->id());\n> > > +#else\n> > > +     /*\n> > > +      * Assume that cameras without properties::Location specified are external.\n> > > +      */\n> > > +     const CameraConfigData *cameraConfigData = nullptr;\n> > > +     if (!isCameraExternal && cameraLocation(cam.get()) < 0) {\n> > > +             isCameraExternal = true;\n> > > +             id = nextExternalCameraId_;\n> > > +     }\n> > > +#endif\n> > >\n> > >       /*\n> > >        * Some cameras whose location is reported by libcamera as external may\n> > > diff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h\n> > > index a5f8b933a7902..056abbb0d4e54 100644\n> > > --- a/src/android/camera_hal_manager.h\n> > > +++ b/src/android/camera_hal_manager.h\n> > > @@ -56,7 +56,9 @@ private:\n> > >       CameraDevice *cameraDeviceFromHalId(unsigned int id) LIBCAMERA_TSA_REQUIRES(mutex_);\n> > >\n> > >       std::unique_ptr<libcamera::CameraManager> cameraManager_;\n> > > +#ifdef HAVE_LIBYAML\n> > >       CameraHalConfig halConfig_;\n> > > +#endif\n> > >\n> > >       const camera_module_callbacks_t *callbacks_;\n> > >       std::vector<std::unique_ptr<CameraDevice>> cameras_ LIBCAMERA_TSA_GUARDED_BY(mutex_);\n> > > diff --git a/src/android/meson.build b/src/android/meson.build\n> > > index 75b4bf2070851..1e471c291a1e4 100644\n> > > --- a/src/android/meson.build\n> > > +++ b/src/android/meson.build\n> > > @@ -3,7 +3,6 @@\n> > >  android_deps = [\n> > >      dependency('libexif', required : get_option('android')),\n> > >      dependency('libjpeg', required : get_option('android')),\n> > > -    dependency('yaml-0.1', required : get_option('android')),\n> > >      libcamera_private,\n> > >  ]\n> > >\n> > > @@ -41,7 +40,6 @@ android_hal_sources = files([\n> > >      'camera3_hal.cpp',\n> > >      'camera_capabilities.cpp',\n> > >      'camera_device.cpp',\n> > > -    'camera_hal_config.cpp',\n> > >      'camera_hal_manager.cpp',\n> > >      'camera_metadata.cpp',\n> > >      'camera_ops.cpp',\n> > > @@ -56,6 +54,14 @@ android_hal_sources = files([\n> > >\n> > >  android_cpp_args = []\n> > >\n> > > +libyaml_dep = dependency('yaml-0.1', required : false)\n> > > +if libyaml_dep.found()\n> > > +    config_h.set('HAVE_LIBYAML', 1)\n> > > +    android_hal_sources += files([\n> > > +        'camera_hal_config.cpp',\n> > > +    ])\n> > > +endif\n> > > +\n> > >  subdir('cros')\n> > >  subdir('mm')\n> > >","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 57971BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 28 Dec 2021 18:27:53 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 970646090D;\n\tTue, 28 Dec 2021 19:27:52 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2554760868\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Dec 2021 19:27:51 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 803F63E7;\n\tTue, 28 Dec 2021 19:27:50 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"vovHT5d2\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1640716070;\n\tbh=7PLn0t4YGbUiDqEZXiUUdR5NwTiCgmP3AkqnTcsVLwU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=vovHT5d2Mqf6T2j44k4dwwX9Q9/Gal/iDGqANTA/q11eQ1d3nf7gC+7iEhZuv6Mh0\n\t1uTbD0iymGmPInhmjX7WSvt8TunAq2oAoQL1W9uB9JgQ/Bh6AExICTZZk0t9nh3IP5\n\td334ck2m7Tnj/LdYH/Joms8s2kmja8HU00Diesx0=","Date":"Tue, 28 Dec 2021 20:27:47 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Roman Stratiienko <r.stratiienko@gmail.com>","Message-ID":"<YctXI7T1elw77Rjr@pendragon.ideasonboard.com>","References":"<20211228095153.611009-1-roman.o.stratiienko@globallogic.com>\n\t<20211228110551.rxgzp77qfwpfj2n2@uno.localdomain>\n\t<CAGphcd=H0Ns5_1WL0YTsTvt9zkMCGNAaDygNcN4GXGhZfqkQMA@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<CAGphcd=H0Ns5_1WL0YTsTvt9zkMCGNAaDygNcN4GXGhZfqkQMA@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH] android: Make libyaml dependency\n\toptional","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>,\n\tRoman Stratiienko <roman.o.stratiienko@globallogic.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":21897,"web_url":"https://patchwork.libcamera.org/comment/21897/","msgid":"<CAGphcd=jiw9-Cd_kYozvNVO2Q9+Mrr=eeURGJMR9+Z_kcV_BvQ@mail.gmail.com>","date":"2021-12-29T09:45:17","subject":"Re: [libcamera-devel] [PATCH] android: Make libyaml dependency\n\toptional","submitter":{"id":106,"url":"https://patchwork.libcamera.org/api/people/106/","name":"Roman Stratiienko","email":"r.stratiienko@gmail.com"},"content":"Hi Laurent,\n\nвт, 28 дек. 2021 г. в 20:27, Laurent Pinchart\n<laurent.pinchart@ideasonboard.com>:\n>\n> Hi Roman,\n>\n> On Tue, Dec 28, 2021 at 01:22:34PM +0200, Roman Stratiienko wrote:\n> > вт, 28 дек. 2021 г., 13:04 Jacopo Mondi:\n> > > Hi Roman,\n> > >\n> > > cc Hanlin Chen from ChromiumOS as he's planning to extend\n> > > configuration file support for the ChromeOS Android HAL.\n> >\n> > > Before looking into the patch: is there any hope libyaml might become\n> > > part of the standard AOSP distribution (or a process in place to request\n> > > that)\n> >\n> > I am not aware of that, and I haven't initiated such a process. It will be\n> > a very slow and bumpy road.\n> >\n> > Not sure what is planned for these properties in future, but now it is not\n> > necessary to have it in libcamera to have fully functional hal. Also having\n> > no configuration file available will encourage developers to add\n> > corresponding records to dts, which is also a great thing to align with\n> > linux world.\n>\n> Our goals align here. This is exactly why we have decided not to set the\n> camera location in a configuration file for the libcamera core, but to\n> isolate it in the HAL as a temporary (but in practice likely a long-term\n> temporary) measure, as we have to support platforms that will take some\n> time before a firmware (ACPI in this case) update can be deployed.\n>\n> This being said, we will introduce a configuration file for the\n> libcamera core in the near future, and we also plan to use libyaml\n> there. The tuning files for the IPU3 and RkISP1 IPA modules will also\n> use YAML, and I'd like to move the Raspberry Pi tuning files from JSON\n> to YAML for consistency.\n\nIt's a good idea to have a single file format. Currently we have to\nship boost to run raspberrypi cameras on Android.\n\n> We could merge this patch in the meantime, but compilation on Android\n> will likely break again soon. I wonder if we couldn't instead use a\n> meson wrap to include libyaml as a subproject. This should solve the\n> issue in the longer term.\n\nAt this moment we have libyaml with extra Android.bp, which can\nsatisfy libcamera needs.\nBut I really like to see it as an optional dependency only to help\nfine-tuning things or for ACPI-only platforms.\n\n> By the way, out of curiosity, how do you compile libcamera for Android ?\n> We have a look at Soong (as the Makefile-based build system is being\n> phased out), but blueprint files don't support all our needs (and would\n> be annoying to maintain manually), and there's no way we found to\n> generate Android.bp files from meson in a way that would integrate with\n> Soong. This is still an unsolved problem, and I'm increasingly tempted\n> to do the same as mesa3d and just document that libcamera should be\n> built outside of AOSP, using the NDK.\n\nWe shipped libcamera in our GloDroid project v0.7.0 release for\nraspberry pi about a month ago:\n1. https://github.com/GloDroid/glodroid_manifest/releases/tag/v0.7.0\n2. https://github.com/GloDroid/glodroid_forks/commits/libcamera-v0.7.0\n\nFor building using meson within AOSP we are using some tricks to\nextract dependencies from AOSP makesystem and inject them into\nmeson cross compilation file.\n\nFirst such kind of approach was integrated into mesa3d and replaced\nexisting Android.mk files (about 6 month ago).\nIt doesn't require continuous maintenance as previous Android.mk did\nand has proven to be reliable.\nIt also enables FULL support of mesa3d for Android. Previously only\nabout 60% of mesa3d drivers were covered with Android.mk files.\nReworking the same approach for libcamera was pretty easy.\n\nAnd yes, as an official approach for vendors NDK builds would be great\nto support.\nNDK approach and our meson.build within AOSP approach are 98% aligned.\n\n>\n> > > On Tue, Dec 28, 2021 at 11:51:53AM +0200, Roman Stratiienko wrote:\n> > > > Mainline Android has no libyaml in-tree. Moreover camera_hal_config.cpp\n> > > > uses std::filesystem class that is not permitted for AOSP VNDK vendor\n> > > > libraries.\n> > > >\n> > > > External configuration file is no longer mandatory and DTS overlays can\n> > > > be used to specify camera location and rotation.\n> > > >\n> > > > Do not require external configuration file for cases where meson.build\n> > > > can't find libyaml. Assume that cameras without location specified\n> > > > by V4L2 properties are always external.\n> > > >\n> > > > Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>\n> > > > ---\n> > > >  src/android/camera_hal_manager.cpp | 13 +++++++++++++\n> > > >  src/android/camera_hal_manager.h   |  2 ++\n> > > >  src/android/meson.build            | 10 ++++++++--\n> > > >  3 files changed, 23 insertions(+), 2 deletions(-)\n> > > >\n> > > > diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp\n> > > > index 5f7bfe265c71b..9e575bfa5204a 100644\n> > > > --- a/src/android/camera_hal_manager.cpp\n> > > > +++ b/src/android/camera_hal_manager.cpp\n> > > > @@ -48,6 +48,7 @@ int CameraHalManager::init()\n> > > >  {\n> > > >       cameraManager_ = std::make_unique<CameraManager>();\n> > > >\n> > > > +#ifdef HAVE_LIBYAML\n> > > >       /*\n> > > >        * If the configuration file is not available the HAL only supports\n> > > >        * external cameras. If it exists but it's not valid then error out.\n> > > > @@ -56,6 +57,7 @@ int CameraHalManager::init()\n> > > >               LOG(HAL, Error) << \"HAL configuration file is not valid\";\n> > > >               return -EINVAL;\n> > > >       }\n> > > > +#endif\n> > > >\n> > > >       /* Support camera hotplug. */\n> > > >       cameraManager_->cameraAdded.connect(this, &CameraHalManager::cameraAdded);\n> > > > @@ -133,6 +135,7 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\n> > > >               }\n> > > >       }\n> > > >\n> > > > +#ifdef HAVE_LIBYAML\n> > > >       /*\n> > > >        * The configuration file must be valid, and contain a corresponding\n> > > >        * entry for internal cameras. External cameras can be initialized\n> > > > @@ -145,6 +148,16 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\n> > > >       }\n> > > >\n> > > >       const CameraConfigData *cameraConfigData = halConfig_.cameraConfigData(cam->id());\n> > > > +#else\n> > > > +     /*\n> > > > +      * Assume that cameras without properties::Location specified are external.\n> > > > +      */\n> > > > +     const CameraConfigData *cameraConfigData = nullptr;\n> > > > +     if (!isCameraExternal && cameraLocation(cam.get()) < 0) {\n> > > > +             isCameraExternal = true;\n> > > > +             id = nextExternalCameraId_;\n> > > > +     }\n> > > > +#endif\n> > > >\n> > > >       /*\n> > > >        * Some cameras whose location is reported by libcamera as external may\n> > > > diff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h\n> > > > index a5f8b933a7902..056abbb0d4e54 100644\n> > > > --- a/src/android/camera_hal_manager.h\n> > > > +++ b/src/android/camera_hal_manager.h\n> > > > @@ -56,7 +56,9 @@ private:\n> > > >       CameraDevice *cameraDeviceFromHalId(unsigned int id) LIBCAMERA_TSA_REQUIRES(mutex_);\n> > > >\n> > > >       std::unique_ptr<libcamera::CameraManager> cameraManager_;\n> > > > +#ifdef HAVE_LIBYAML\n> > > >       CameraHalConfig halConfig_;\n> > > > +#endif\n> > > >\n> > > >       const camera_module_callbacks_t *callbacks_;\n> > > >       std::vector<std::unique_ptr<CameraDevice>> cameras_ LIBCAMERA_TSA_GUARDED_BY(mutex_);\n> > > > diff --git a/src/android/meson.build b/src/android/meson.build\n> > > > index 75b4bf2070851..1e471c291a1e4 100644\n> > > > --- a/src/android/meson.build\n> > > > +++ b/src/android/meson.build\n> > > > @@ -3,7 +3,6 @@\n> > > >  android_deps = [\n> > > >      dependency('libexif', required : get_option('android')),\n> > > >      dependency('libjpeg', required : get_option('android')),\n> > > > -    dependency('yaml-0.1', required : get_option('android')),\n> > > >      libcamera_private,\n> > > >  ]\n> > > >\n> > > > @@ -41,7 +40,6 @@ android_hal_sources = files([\n> > > >      'camera3_hal.cpp',\n> > > >      'camera_capabilities.cpp',\n> > > >      'camera_device.cpp',\n> > > > -    'camera_hal_config.cpp',\n> > > >      'camera_hal_manager.cpp',\n> > > >      'camera_metadata.cpp',\n> > > >      'camera_ops.cpp',\n> > > > @@ -56,6 +54,14 @@ android_hal_sources = files([\n> > > >\n> > > >  android_cpp_args = []\n> > > >\n> > > > +libyaml_dep = dependency('yaml-0.1', required : false)\n> > > > +if libyaml_dep.found()\n> > > > +    config_h.set('HAVE_LIBYAML', 1)\n> > > > +    android_hal_sources += files([\n> > > > +        'camera_hal_config.cpp',\n> > > > +    ])\n> > > > +endif\n> > > > +\n> > > >  subdir('cros')\n> > > >  subdir('mm')\n> > > >\n>\n> --\n> Regards,\n>\n> Laurent Pinchart\n\nRegards.\nRoman","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 2B23DBE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 29 Dec 2021 09:45:33 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 47C2A60911;\n\tWed, 29 Dec 2021 10:45:32 +0100 (CET)","from mail-pl1-x629.google.com (mail-pl1-x629.google.com\n\t[IPv6:2607:f8b0:4864:20::629])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 645A2604F7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 Dec 2021 10:45:30 +0100 (CET)","by mail-pl1-x629.google.com with SMTP id z3so15504583plg.8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 Dec 2021 01:45:30 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"YQ4NxDO6\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc:content-transfer-encoding;\n\tbh=Yvc7dAdKQU+8gUY107ysL7Fb7Ej0hJJE9wvodrAju70=;\n\tb=YQ4NxDO6iN4/Y64QfRI/SyvQW8h9c6Ks6z7AxvhCnaZql0cC6UV+m/l7Ddecm3kBHf\n\tvEvSam+89eUuHYXJs413OUKE/sLFbXiwcwqc0Z1/qYAHZyI2huecqvZpMkN3N5Ase0sm\n\tmPbuU3PtxFl/SEtGT5tINVowhI91Lj2veBgn6yX5Kj3K3aiwLReb8lR2sl9bj+lsWykl\n\tFAgptlE/h2ZXCmaQS52NqCiyGzuZPvy+zk5Z87ZmD+2wG9CqYYUx3kX2sIW7r6GK/72L\n\tEsu2f8gas+qNy1ERK0B6omN6/Iwk/CRQP6PqlDVi+2DtLnLKX+h/W6fZe4D/Im4VTo/h\n\tvjrg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc:content-transfer-encoding;\n\tbh=Yvc7dAdKQU+8gUY107ysL7Fb7Ej0hJJE9wvodrAju70=;\n\tb=f+kEpj2p+hQNcGvx0XlhNaao1AZ16KsUJfzWEPZBU825zHX3tbEoOF6gyyQEh+GFK7\n\t+bNWjVZN4XzNK0eHzQ9C1viOBlDk0sdyI/gAJi4y2hQQcXZeHtsASy7lRgidtJz6PEQ7\n\t4LfrR9MH9por7XScXIxT0733QzN88P9WbZzfm4RVQu9YSsCfZNv9P/haJ/VQw+GzEDz0\n\t9iwEqRFzQtbhHQhWT2PBiKH1qTIRIzgMP3BHYGQyPJ29Nt87wi4GDGrG/d8vnxpSTG2I\n\ttPRRongg51GeoXQS/5rQmRaDH8AfLso9TzG8J2X7uAGdD04/NhfgajEqc4kZO5mSncx4\n\txGKg==","X-Gm-Message-State":"AOAM531e3l3oi3maEE8WgWhR9NO1N1Xc6qFpA3Nz23Ze1mgGc43NQVl5\n\t0MXWnRaodnMstRMksPfphEBRUJuOvS55L2VI5IU=","X-Google-Smtp-Source":"ABdhPJwcwJD8oh9BSBvrg3FQ/AkDNHGJZFWL1IIflbroeZfvJ6UflHuiop8qUlPYO8yCKGdQds2T2mDN9r812i2/cxA=","X-Received":"by 2002:a17:90b:4a48:: with SMTP id\n\tlb8mr31213041pjb.29.1640771128366; \n\tWed, 29 Dec 2021 01:45:28 -0800 (PST)","MIME-Version":"1.0","References":"<20211228095153.611009-1-roman.o.stratiienko@globallogic.com>\n\t<20211228110551.rxgzp77qfwpfj2n2@uno.localdomain>\n\t<CAGphcd=H0Ns5_1WL0YTsTvt9zkMCGNAaDygNcN4GXGhZfqkQMA@mail.gmail.com>\n\t<YctXI7T1elw77Rjr@pendragon.ideasonboard.com>","In-Reply-To":"<YctXI7T1elw77Rjr@pendragon.ideasonboard.com>","From":"Roman Stratiienko <r.stratiienko@gmail.com>","Date":"Wed, 29 Dec 2021 11:45:17 +0200","Message-ID":"<CAGphcd=jiw9-Cd_kYozvNVO2Q9+Mrr=eeURGJMR9+Z_kcV_BvQ@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","Subject":"Re: [libcamera-devel] [PATCH] android: Make libyaml dependency\n\toptional","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>,\n\tRoman Stratiienko <roman.o.stratiienko@globallogic.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":21898,"web_url":"https://patchwork.libcamera.org/comment/21898/","msgid":"<Ycw1FPz5Qv8wQpFr@pendragon.ideasonboard.com>","date":"2021-12-29T10:14:44","subject":"Re: [libcamera-devel] [PATCH] android: Make libyaml dependency\n\toptional","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Roman,\n\nOn Wed, Dec 29, 2021 at 11:45:17AM +0200, Roman Stratiienko wrote:\n> вт, 28 дек. 2021 г. в 20:27, Laurent Pinchart:\n> > On Tue, Dec 28, 2021 at 01:22:34PM +0200, Roman Stratiienko wrote:\n> > > вт, 28 дек. 2021 г., 13:04 Jacopo Mondi:\n> > > > Hi Roman,\n> > > >\n> > > > cc Hanlin Chen from ChromiumOS as he's planning to extend\n> > > > configuration file support for the ChromeOS Android HAL.\n> > >\n> > > > Before looking into the patch: is there any hope libyaml might become\n> > > > part of the standard AOSP distribution (or a process in place to request\n> > > > that)\n> > >\n> > > I am not aware of that, and I haven't initiated such a process. It will be\n> > > a very slow and bumpy road.\n> > >\n> > > Not sure what is planned for these properties in future, but now it is not\n> > > necessary to have it in libcamera to have fully functional hal. Also having\n> > > no configuration file available will encourage developers to add\n> > > corresponding records to dts, which is also a great thing to align with\n> > > linux world.\n> >\n> > Our goals align here. This is exactly why we have decided not to set the\n> > camera location in a configuration file for the libcamera core, but to\n> > isolate it in the HAL as a temporary (but in practice likely a long-term\n> > temporary) measure, as we have to support platforms that will take some\n> > time before a firmware (ACPI in this case) update can be deployed.\n> >\n> > This being said, we will introduce a configuration file for the\n> > libcamera core in the near future, and we also plan to use libyaml\n> > there. The tuning files for the IPU3 and RkISP1 IPA modules will also\n> > use YAML, and I'd like to move the Raspberry Pi tuning files from JSON\n> > to YAML for consistency.\n> \n> It's a good idea to have a single file format. Currently we have to\n> ship boost to run raspberrypi cameras on Android.\n\nI'm happy you agree :-)\n\n> > We could merge this patch in the meantime, but compilation on Android\n> > will likely break again soon. I wonder if we couldn't instead use a\n> > meson wrap to include libyaml as a subproject. This should solve the\n> > issue in the longer term.\n> \n> At this moment we have libyaml with extra Android.bp, which can\n> satisfy libcamera needs.\n> But I really like to see it as an optional dependency only to help\n> fine-tuning things or for ACPI-only platforms.\n\nMaking it optional may cause difficulties in the future, with\npotentially lots of conditional compilation. I'd rather not go that way,\nunless we can wrap the yaml parser in a helper class with a dummy\nimplementation to hide the missing dependency from everything else.\n\nI've quickly tested compiling libyaml as a subproject, and it seems to\nwork:\n\n\ncommit f1d86859f522c7728d8f854b82296673291750fb\nAuthor: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nDate:   Wed Dec 29 12:07:35 2021 +0200\n\n    android: Compile libyaml as a subproject if not available on the system\n\n    AOSP doesn't ship libyaml, making it more difficult to compile libcamera\n    for Android. Use a meson wrap to compile libyaml as a subproject if the\n    dependency is not found.\n\n    Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\ndiff --git a/src/android/meson.build b/src/android/meson.build\nindex 75b4bf207085..1fa67746d058 100644\n--- a/src/android/meson.build\n+++ b/src/android/meson.build\n@@ -3,7 +3,6 @@\n android_deps = [\n     dependency('libexif', required : get_option('android')),\n     dependency('libjpeg', required : get_option('android')),\n-    dependency('yaml-0.1', required : get_option('android')),\n     libcamera_private,\n ]\n\n@@ -16,13 +15,35 @@ foreach dep : android_deps\n     endif\n endforeach\n\n+cmake = import('cmake')\n+\n+#\n+# libyaml\n+#\n+# Default to the system version, and fallback to a subproject if not found, as\n+# libyaml is not packaged in AOSP.\n+#\n+libyaml_dep = dependency('yaml-0.1', required : false)\n+\n+# Fallback to a subproject if libyaml isn't found, as it's not packed in AOSP.\n+if not libyaml_dep.found()\n+    libyaml_vars = cmake.subproject_options()\n+    libyaml_vars.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'})\n+    libyaml = cmake.subproject('libyaml', options : libyaml_vars)\n+    libyaml_dep = libyaml.dependency('yaml')\n+endif\n+\n+android_deps += [libyaml_dep]\n+\n+#\n+# libyuv\n+#\n+# Default to the system version, and fallback to a subproject if not found, as\n+# libyuv is typically not provided by distributions.\n+#\n libyuv_dep = dependency('libyuv', required : false)\n\n-# Fallback to a subproject if libyuv isn't found, as it's typically not\n-# provided by distributions.\n if not libyuv_dep.found()\n-    cmake = import('cmake')\n-\n     libyuv_vars = cmake.subproject_options()\n     libyuv_vars.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'})\n     libyuv_vars.set_override_option('cpp_std', 'c++17')\ndiff --git a/subprojects/.gitignore b/subprojects/.gitignore\nindex 391fde2ce1e0..f207720b271a 100644\n--- a/subprojects/.gitignore\n+++ b/subprojects/.gitignore\n@@ -1,3 +1,4 @@\n /googletest-release*\n+/libyaml\n /libyuv\n-/packagecache\n\\ No newline at end of file\n+/packagecache\ndiff --git a/subprojects/libyaml.wrap b/subprojects/libyaml.wrap\nnew file mode 100644\nindex 000000000000..e4426e44774f\n--- /dev/null\n+++ b/subprojects/libyaml.wrap\n@@ -0,0 +1,4 @@\n+[wrap-git]\n+directory = libyaml\n+url = https://github.com/yaml/libyaml\n+revision = 2c891fc7a770e8ba2fec34fc6b545c672beb37e6\n\n> > By the way, out of curiosity, how do you compile libcamera for Android ?\n> > We have a look at Soong (as the Makefile-based build system is being\n> > phased out), but blueprint files don't support all our needs (and would\n> > be annoying to maintain manually), and there's no way we found to\n> > generate Android.bp files from meson in a way that would integrate with\n> > Soong. This is still an unsolved problem, and I'm increasingly tempted\n> > to do the same as mesa3d and just document that libcamera should be\n> > built outside of AOSP, using the NDK.\n> \n> We shipped libcamera in our GloDroid project v0.7.0 release for\n> raspberry pi about a month ago:\n> 1. https://github.com/GloDroid/glodroid_manifest/releases/tag/v0.7.0\n> 2. https://github.com/GloDroid/glodroid_forks/commits/libcamera-v0.7.0\n> \n> For building using meson within AOSP we are using some tricks to\n> extract dependencies from AOSP makesystem and inject them into\n> meson cross compilation file.\n\nDoes this mean that you compile libcamera manually, separately from AOSP\n? That's probably the best option for now, until Android decides to\nintegrate support for other build systems (likely never...).\n\n> First such kind of approach was integrated into mesa3d and replaced\n> existing Android.mk files (about 6 month ago).\n> It doesn't require continuous maintenance as previous Android.mk did\n> and has proven to be reliable.\n> It also enables FULL support of mesa3d for Android. Previously only\n> about 60% of mesa3d drivers were covered with Android.mk files.\n> Reworking the same approach for libcamera was pretty easy.\n> \n> And yes, as an official approach for vendors NDK builds would be great\n> to support.\n> NDK approach and our meson.build within AOSP approach are 98% aligned.\n> \n> > > > On Tue, Dec 28, 2021 at 11:51:53AM +0200, Roman Stratiienko wrote:\n> > > > > Mainline Android has no libyaml in-tree. Moreover camera_hal_config.cpp\n> > > > > uses std::filesystem class that is not permitted for AOSP VNDK vendor\n> > > > > libraries.\n> > > > >\n> > > > > External configuration file is no longer mandatory and DTS overlays can\n> > > > > be used to specify camera location and rotation.\n> > > > >\n> > > > > Do not require external configuration file for cases where meson.build\n> > > > > can't find libyaml. Assume that cameras without location specified\n> > > > > by V4L2 properties are always external.\n> > > > >\n> > > > > Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>\n> > > > > ---\n> > > > >  src/android/camera_hal_manager.cpp | 13 +++++++++++++\n> > > > >  src/android/camera_hal_manager.h   |  2 ++\n> > > > >  src/android/meson.build            | 10 ++++++++--\n> > > > >  3 files changed, 23 insertions(+), 2 deletions(-)\n> > > > >\n> > > > > diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp\n> > > > > index 5f7bfe265c71b..9e575bfa5204a 100644\n> > > > > --- a/src/android/camera_hal_manager.cpp\n> > > > > +++ b/src/android/camera_hal_manager.cpp\n> > > > > @@ -48,6 +48,7 @@ int CameraHalManager::init()\n> > > > >  {\n> > > > >       cameraManager_ = std::make_unique<CameraManager>();\n> > > > >\n> > > > > +#ifdef HAVE_LIBYAML\n> > > > >       /*\n> > > > >        * If the configuration file is not available the HAL only supports\n> > > > >        * external cameras. If it exists but it's not valid then error out.\n> > > > > @@ -56,6 +57,7 @@ int CameraHalManager::init()\n> > > > >               LOG(HAL, Error) << \"HAL configuration file is not valid\";\n> > > > >               return -EINVAL;\n> > > > >       }\n> > > > > +#endif\n> > > > >\n> > > > >       /* Support camera hotplug. */\n> > > > >       cameraManager_->cameraAdded.connect(this, &CameraHalManager::cameraAdded);\n> > > > > @@ -133,6 +135,7 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\n> > > > >               }\n> > > > >       }\n> > > > >\n> > > > > +#ifdef HAVE_LIBYAML\n> > > > >       /*\n> > > > >        * The configuration file must be valid, and contain a corresponding\n> > > > >        * entry for internal cameras. External cameras can be initialized\n> > > > > @@ -145,6 +148,16 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\n> > > > >       }\n> > > > >\n> > > > >       const CameraConfigData *cameraConfigData = halConfig_.cameraConfigData(cam->id());\n> > > > > +#else\n> > > > > +     /*\n> > > > > +      * Assume that cameras without properties::Location specified are external.\n> > > > > +      */\n> > > > > +     const CameraConfigData *cameraConfigData = nullptr;\n> > > > > +     if (!isCameraExternal && cameraLocation(cam.get()) < 0) {\n> > > > > +             isCameraExternal = true;\n> > > > > +             id = nextExternalCameraId_;\n> > > > > +     }\n> > > > > +#endif\n> > > > >\n> > > > >       /*\n> > > > >        * Some cameras whose location is reported by libcamera as external may\n> > > > > diff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h\n> > > > > index a5f8b933a7902..056abbb0d4e54 100644\n> > > > > --- a/src/android/camera_hal_manager.h\n> > > > > +++ b/src/android/camera_hal_manager.h\n> > > > > @@ -56,7 +56,9 @@ private:\n> > > > >       CameraDevice *cameraDeviceFromHalId(unsigned int id) LIBCAMERA_TSA_REQUIRES(mutex_);\n> > > > >\n> > > > >       std::unique_ptr<libcamera::CameraManager> cameraManager_;\n> > > > > +#ifdef HAVE_LIBYAML\n> > > > >       CameraHalConfig halConfig_;\n> > > > > +#endif\n> > > > >\n> > > > >       const camera_module_callbacks_t *callbacks_;\n> > > > >       std::vector<std::unique_ptr<CameraDevice>> cameras_ LIBCAMERA_TSA_GUARDED_BY(mutex_);\n> > > > > diff --git a/src/android/meson.build b/src/android/meson.build\n> > > > > index 75b4bf2070851..1e471c291a1e4 100644\n> > > > > --- a/src/android/meson.build\n> > > > > +++ b/src/android/meson.build\n> > > > > @@ -3,7 +3,6 @@\n> > > > >  android_deps = [\n> > > > >      dependency('libexif', required : get_option('android')),\n> > > > >      dependency('libjpeg', required : get_option('android')),\n> > > > > -    dependency('yaml-0.1', required : get_option('android')),\n> > > > >      libcamera_private,\n> > > > >  ]\n> > > > >\n> > > > > @@ -41,7 +40,6 @@ android_hal_sources = files([\n> > > > >      'camera3_hal.cpp',\n> > > > >      'camera_capabilities.cpp',\n> > > > >      'camera_device.cpp',\n> > > > > -    'camera_hal_config.cpp',\n> > > > >      'camera_hal_manager.cpp',\n> > > > >      'camera_metadata.cpp',\n> > > > >      'camera_ops.cpp',\n> > > > > @@ -56,6 +54,14 @@ android_hal_sources = files([\n> > > > >\n> > > > >  android_cpp_args = []\n> > > > >\n> > > > > +libyaml_dep = dependency('yaml-0.1', required : false)\n> > > > > +if libyaml_dep.found()\n> > > > > +    config_h.set('HAVE_LIBYAML', 1)\n> > > > > +    android_hal_sources += files([\n> > > > > +        'camera_hal_config.cpp',\n> > > > > +    ])\n> > > > > +endif\n> > > > > +\n> > > > >  subdir('cros')\n> > > > >  subdir('mm')\n> > > > >","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 1729EBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 29 Dec 2021 10:14:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4DC3E608EB;\n\tWed, 29 Dec 2021 11:14:48 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6A9A4604F7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 Dec 2021 11:14:46 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BE7A1464;\n\tWed, 29 Dec 2021 11:14:45 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"OVDhCP5N\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1640772886;\n\tbh=LGCPqBw/cLRSe9SrYj4vLuq9W2q9VEO7jWDE4y2mZRA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=OVDhCP5NTrU/CxlX187wWWV5TzRKCqDT7FV92gv+znmqcdHrz3h7xh0ktQi7ST0gI\n\tHLUs0oQm7mV7yhYCRhet0A/L9gkMHHKWDlvGQq4ra0pwsDB5khgPETOKZMxYNmZVJh\n\tTE9naQGFUtpIlJUsya2ttjSLPy6BGPxieOugjuEc=","Date":"Wed, 29 Dec 2021 12:14:44 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Roman Stratiienko <r.stratiienko@gmail.com>","Message-ID":"<Ycw1FPz5Qv8wQpFr@pendragon.ideasonboard.com>","References":"<20211228095153.611009-1-roman.o.stratiienko@globallogic.com>\n\t<20211228110551.rxgzp77qfwpfj2n2@uno.localdomain>\n\t<CAGphcd=H0Ns5_1WL0YTsTvt9zkMCGNAaDygNcN4GXGhZfqkQMA@mail.gmail.com>\n\t<YctXI7T1elw77Rjr@pendragon.ideasonboard.com>\n\t<CAGphcd=jiw9-Cd_kYozvNVO2Q9+Mrr=eeURGJMR9+Z_kcV_BvQ@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<CAGphcd=jiw9-Cd_kYozvNVO2Q9+Mrr=eeURGJMR9+Z_kcV_BvQ@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH] android: Make libyaml dependency\n\toptional","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>,\n\tRoman Stratiienko <roman.o.stratiienko@globallogic.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":21899,"web_url":"https://patchwork.libcamera.org/comment/21899/","msgid":"<CAGphcdnYmrZR0ShYD7NiWx3XLdiBNoXzx_JgdsoOk1xwpTi8eA@mail.gmail.com>","date":"2021-12-29T10:24:48","subject":"Re: [libcamera-devel] [PATCH] android: Make libyaml dependency\n\toptional","submitter":{"id":106,"url":"https://patchwork.libcamera.org/api/people/106/","name":"Roman Stratiienko","email":"r.stratiienko@gmail.com"},"content":"ср, 29 дек. 2021 г. в 12:14, Laurent Pinchart\n<laurent.pinchart@ideasonboard.com>:\n>\n> Hi Roman,\n>\n> On Wed, Dec 29, 2021 at 11:45:17AM +0200, Roman Stratiienko wrote:\n> > вт, 28 дек. 2021 г. в 20:27, Laurent Pinchart:\n> > > On Tue, Dec 28, 2021 at 01:22:34PM +0200, Roman Stratiienko wrote:\n> > > > вт, 28 дек. 2021 г., 13:04 Jacopo Mondi:\n> > > > > Hi Roman,\n> > > > >\n> > > > > cc Hanlin Chen from ChromiumOS as he's planning to extend\n> > > > > configuration file support for the ChromeOS Android HAL.\n> > > >\n> > > > > Before looking into the patch: is there any hope libyaml might become\n> > > > > part of the standard AOSP distribution (or a process in place to request\n> > > > > that)\n> > > >\n> > > > I am not aware of that, and I haven't initiated such a process. It will be\n> > > > a very slow and bumpy road.\n> > > >\n> > > > Not sure what is planned for these properties in future, but now it is not\n> > > > necessary to have it in libcamera to have fully functional hal. Also having\n> > > > no configuration file available will encourage developers to add\n> > > > corresponding records to dts, which is also a great thing to align with\n> > > > linux world.\n> > >\n> > > Our goals align here. This is exactly why we have decided not to set the\n> > > camera location in a configuration file for the libcamera core, but to\n> > > isolate it in the HAL as a temporary (but in practice likely a long-term\n> > > temporary) measure, as we have to support platforms that will take some\n> > > time before a firmware (ACPI in this case) update can be deployed.\n> > >\n> > > This being said, we will introduce a configuration file for the\n> > > libcamera core in the near future, and we also plan to use libyaml\n> > > there. The tuning files for the IPU3 and RkISP1 IPA modules will also\n> > > use YAML, and I'd like to move the Raspberry Pi tuning files from JSON\n> > > to YAML for consistency.\n> >\n> > It's a good idea to have a single file format. Currently we have to\n> > ship boost to run raspberrypi cameras on Android.\n>\n> I'm happy you agree :-)\n>\n> > > We could merge this patch in the meantime, but compilation on Android\n> > > will likely break again soon. I wonder if we couldn't instead use a\n> > > meson wrap to include libyaml as a subproject. This should solve the\n> > > issue in the longer term.\n> >\n> > At this moment we have libyaml with extra Android.bp, which can\n> > satisfy libcamera needs.\n> > But I really like to see it as an optional dependency only to help\n> > fine-tuning things or for ACPI-only platforms.\n>\n> Making it optional may cause difficulties in the future, with\n> potentially lots of conditional compilation. I'd rather not go that way,\n> unless we can wrap the yaml parser in a helper class with a dummy\n> implementation to hide the missing dependency from everything else.\n>\n> I've quickly tested compiling libyaml as a subproject, and it seems to\n> work:\n>\n\nI have some doubts if such an approach supports cross-compilation.\nCould meson generate a single ninja.build from all sub-projects?\nImplementing the fallback stub sounds not so bad.\n\n>\n> commit f1d86859f522c7728d8f854b82296673291750fb\n> Author: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Date:   Wed Dec 29 12:07:35 2021 +0200\n>\n>     android: Compile libyaml as a subproject if not available on the system\n>\n>     AOSP doesn't ship libyaml, making it more difficult to compile libcamera\n>     for Android. Use a meson wrap to compile libyaml as a subproject if the\n>     dependency is not found.\n>\n>     Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>\n> diff --git a/src/android/meson.build b/src/android/meson.build\n> index 75b4bf207085..1fa67746d058 100644\n> --- a/src/android/meson.build\n> +++ b/src/android/meson.build\n> @@ -3,7 +3,6 @@\n>  android_deps = [\n>      dependency('libexif', required : get_option('android')),\n>      dependency('libjpeg', required : get_option('android')),\n> -    dependency('yaml-0.1', required : get_option('android')),\n>      libcamera_private,\n>  ]\n>\n> @@ -16,13 +15,35 @@ foreach dep : android_deps\n>      endif\n>  endforeach\n>\n> +cmake = import('cmake')\n> +\n> +#\n> +# libyaml\n> +#\n> +# Default to the system version, and fallback to a subproject if not found, as\n> +# libyaml is not packaged in AOSP.\n> +#\n> +libyaml_dep = dependency('yaml-0.1', required : false)\n> +\n> +# Fallback to a subproject if libyaml isn't found, as it's not packed in AOSP.\n> +if not libyaml_dep.found()\n> +    libyaml_vars = cmake.subproject_options()\n> +    libyaml_vars.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'})\n> +    libyaml = cmake.subproject('libyaml', options : libyaml_vars)\n> +    libyaml_dep = libyaml.dependency('yaml')\n> +endif\n> +\n> +android_deps += [libyaml_dep]\n> +\n> +#\n> +# libyuv\n> +#\n> +# Default to the system version, and fallback to a subproject if not found, as\n> +# libyuv is typically not provided by distributions.\n> +#\n>  libyuv_dep = dependency('libyuv', required : false)\n>\n> -# Fallback to a subproject if libyuv isn't found, as it's typically not\n> -# provided by distributions.\n>  if not libyuv_dep.found()\n> -    cmake = import('cmake')\n> -\n>      libyuv_vars = cmake.subproject_options()\n>      libyuv_vars.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'})\n>      libyuv_vars.set_override_option('cpp_std', 'c++17')\n> diff --git a/subprojects/.gitignore b/subprojects/.gitignore\n> index 391fde2ce1e0..f207720b271a 100644\n> --- a/subprojects/.gitignore\n> +++ b/subprojects/.gitignore\n> @@ -1,3 +1,4 @@\n>  /googletest-release*\n> +/libyaml\n>  /libyuv\n> -/packagecache\n> \\ No newline at end of file\n> +/packagecache\n> diff --git a/subprojects/libyaml.wrap b/subprojects/libyaml.wrap\n> new file mode 100644\n> index 000000000000..e4426e44774f\n> --- /dev/null\n> +++ b/subprojects/libyaml.wrap\n> @@ -0,0 +1,4 @@\n> +[wrap-git]\n> +directory = libyaml\n> +url = https://github.com/yaml/libyaml\n> +revision = 2c891fc7a770e8ba2fec34fc6b545c672beb37e6\n>\n> > > By the way, out of curiosity, how do you compile libcamera for Android ?\n> > > We have a look at Soong (as the Makefile-based build system is being\n> > > phased out), but blueprint files don't support all our needs (and would\n> > > be annoying to maintain manually), and there's no way we found to\n> > > generate Android.bp files from meson in a way that would integrate with\n> > > Soong. This is still an unsolved problem, and I'm increasingly tempted\n> > > to do the same as mesa3d and just document that libcamera should be\n> > > built outside of AOSP, using the NDK.\n> >\n> > We shipped libcamera in our GloDroid project v0.7.0 release for\n> > raspberry pi about a month ago:\n> > 1. https://github.com/GloDroid/glodroid_manifest/releases/tag/v0.7.0\n> > 2. https://github.com/GloDroid/glodroid_forks/commits/libcamera-v0.7.0\n> >\n> > For building using meson within AOSP we are using some tricks to\n> > extract dependencies from AOSP makesystem and inject them into\n> > meson cross compilation file.\n>\n> Does this mean that you compile libcamera manually, separately from AOSP\n> ? That's probably the best option for now, until Android decides to\n> integrate support for other build systems (likely never...).\n\nNo. Building within AOSP does mean building within AOSP.\nNot manually.\nIt utilizes the Kati (Android.mk) build system.\nAnd Kati is currently tightly bound to Soong, separating both would require some\ntime for Google if they decide to do so.\nAnd we always have \"building using NDK\" as a fallback once it happens.\n\n>\n> > First such kind of approach was integrated into mesa3d and replaced\n> > existing Android.mk files (about 6 month ago).\n> > It doesn't require continuous maintenance as previous Android.mk did\n> > and has proven to be reliable.\n> > It also enables FULL support of mesa3d for Android. Previously only\n> > about 60% of mesa3d drivers were covered with Android.mk files.\n> > Reworking the same approach for libcamera was pretty easy.\n> >\n> > And yes, as an official approach for vendors NDK builds would be great\n> > to support.\n> > NDK approach and our meson.build within AOSP approach are 98% aligned.\n> >\n> > > > > On Tue, Dec 28, 2021 at 11:51:53AM +0200, Roman Stratiienko wrote:\n> > > > > > Mainline Android has no libyaml in-tree. Moreover camera_hal_config.cpp\n> > > > > > uses std::filesystem class that is not permitted for AOSP VNDK vendor\n> > > > > > libraries.\n> > > > > >\n> > > > > > External configuration file is no longer mandatory and DTS overlays can\n> > > > > > be used to specify camera location and rotation.\n> > > > > >\n> > > > > > Do not require external configuration file for cases where meson.build\n> > > > > > can't find libyaml. Assume that cameras without location specified\n> > > > > > by V4L2 properties are always external.\n> > > > > >\n> > > > > > Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>\n> > > > > > ---\n> > > > > >  src/android/camera_hal_manager.cpp | 13 +++++++++++++\n> > > > > >  src/android/camera_hal_manager.h   |  2 ++\n> > > > > >  src/android/meson.build            | 10 ++++++++--\n> > > > > >  3 files changed, 23 insertions(+), 2 deletions(-)\n> > > > > >\n> > > > > > diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp\n> > > > > > index 5f7bfe265c71b..9e575bfa5204a 100644\n> > > > > > --- a/src/android/camera_hal_manager.cpp\n> > > > > > +++ b/src/android/camera_hal_manager.cpp\n> > > > > > @@ -48,6 +48,7 @@ int CameraHalManager::init()\n> > > > > >  {\n> > > > > >       cameraManager_ = std::make_unique<CameraManager>();\n> > > > > >\n> > > > > > +#ifdef HAVE_LIBYAML\n> > > > > >       /*\n> > > > > >        * If the configuration file is not available the HAL only supports\n> > > > > >        * external cameras. If it exists but it's not valid then error out.\n> > > > > > @@ -56,6 +57,7 @@ int CameraHalManager::init()\n> > > > > >               LOG(HAL, Error) << \"HAL configuration file is not valid\";\n> > > > > >               return -EINVAL;\n> > > > > >       }\n> > > > > > +#endif\n> > > > > >\n> > > > > >       /* Support camera hotplug. */\n> > > > > >       cameraManager_->cameraAdded.connect(this, &CameraHalManager::cameraAdded);\n> > > > > > @@ -133,6 +135,7 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\n> > > > > >               }\n> > > > > >       }\n> > > > > >\n> > > > > > +#ifdef HAVE_LIBYAML\n> > > > > >       /*\n> > > > > >        * The configuration file must be valid, and contain a corresponding\n> > > > > >        * entry for internal cameras. External cameras can be initialized\n> > > > > > @@ -145,6 +148,16 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\n> > > > > >       }\n> > > > > >\n> > > > > >       const CameraConfigData *cameraConfigData = halConfig_.cameraConfigData(cam->id());\n> > > > > > +#else\n> > > > > > +     /*\n> > > > > > +      * Assume that cameras without properties::Location specified are external.\n> > > > > > +      */\n> > > > > > +     const CameraConfigData *cameraConfigData = nullptr;\n> > > > > > +     if (!isCameraExternal && cameraLocation(cam.get()) < 0) {\n> > > > > > +             isCameraExternal = true;\n> > > > > > +             id = nextExternalCameraId_;\n> > > > > > +     }\n> > > > > > +#endif\n> > > > > >\n> > > > > >       /*\n> > > > > >        * Some cameras whose location is reported by libcamera as external may\n> > > > > > diff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h\n> > > > > > index a5f8b933a7902..056abbb0d4e54 100644\n> > > > > > --- a/src/android/camera_hal_manager.h\n> > > > > > +++ b/src/android/camera_hal_manager.h\n> > > > > > @@ -56,7 +56,9 @@ private:\n> > > > > >       CameraDevice *cameraDeviceFromHalId(unsigned int id) LIBCAMERA_TSA_REQUIRES(mutex_);\n> > > > > >\n> > > > > >       std::unique_ptr<libcamera::CameraManager> cameraManager_;\n> > > > > > +#ifdef HAVE_LIBYAML\n> > > > > >       CameraHalConfig halConfig_;\n> > > > > > +#endif\n> > > > > >\n> > > > > >       const camera_module_callbacks_t *callbacks_;\n> > > > > >       std::vector<std::unique_ptr<CameraDevice>> cameras_ LIBCAMERA_TSA_GUARDED_BY(mutex_);\n> > > > > > diff --git a/src/android/meson.build b/src/android/meson.build\n> > > > > > index 75b4bf2070851..1e471c291a1e4 100644\n> > > > > > --- a/src/android/meson.build\n> > > > > > +++ b/src/android/meson.build\n> > > > > > @@ -3,7 +3,6 @@\n> > > > > >  android_deps = [\n> > > > > >      dependency('libexif', required : get_option('android')),\n> > > > > >      dependency('libjpeg', required : get_option('android')),\n> > > > > > -    dependency('yaml-0.1', required : get_option('android')),\n> > > > > >      libcamera_private,\n> > > > > >  ]\n> > > > > >\n> > > > > > @@ -41,7 +40,6 @@ android_hal_sources = files([\n> > > > > >      'camera3_hal.cpp',\n> > > > > >      'camera_capabilities.cpp',\n> > > > > >      'camera_device.cpp',\n> > > > > > -    'camera_hal_config.cpp',\n> > > > > >      'camera_hal_manager.cpp',\n> > > > > >      'camera_metadata.cpp',\n> > > > > >      'camera_ops.cpp',\n> > > > > > @@ -56,6 +54,14 @@ android_hal_sources = files([\n> > > > > >\n> > > > > >  android_cpp_args = []\n> > > > > >\n> > > > > > +libyaml_dep = dependency('yaml-0.1', required : false)\n> > > > > > +if libyaml_dep.found()\n> > > > > > +    config_h.set('HAVE_LIBYAML', 1)\n> > > > > > +    android_hal_sources += files([\n> > > > > > +        'camera_hal_config.cpp',\n> > > > > > +    ])\n> > > > > > +endif\n> > > > > > +\n> > > > > >  subdir('cros')\n> > > > > >  subdir('mm')\n> > > > > >\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 81D57BE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 29 Dec 2021 10:25:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AD32C60911;\n\tWed, 29 Dec 2021 11:25:02 +0100 (CET)","from mail-pl1-x629.google.com (mail-pl1-x629.google.com\n\t[IPv6:2607:f8b0:4864:20::629])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1D55F604F7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 Dec 2021 11:25:01 +0100 (CET)","by mail-pl1-x629.google.com with SMTP id u16so15564377plg.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 Dec 2021 02:25:01 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"DL8zVvOg\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc:content-transfer-encoding;\n\tbh=bCDk9u3fghFCPM6NjCEIFM8yXqyfLBKw1ddnSnZQRi4=;\n\tb=DL8zVvOgv91BUcwS+S29vkHn57urcAE1s2BTstuwRYalPVhbn1w+0cVM+WH9x9bk9G\n\t1qKzqgBrCZokaJl++ZhttJGCaCCPxoD6WkQLod8emBKYBriz3eDOAaYHKmbT2zuqcnND\n\tpulBeMQu+8Mju0GkqE8LDUvm/93USdLLmBV0C/ox+3/yJgGrfhyNCZKGCiYntBfaTcL6\n\tqWLL0EGO7oi5nUe7S2c3otDYOEzEaEKKQxJ6VgBuwrSJ7nCXVqOQA2G+KD/G53XosPUc\n\tNUu9B1A7iMVsGzXGLDO5sZ/BmiyU3FY1TAMKaKbyxDIzWbd2Hfxq2LDOrcc29aUXzaKJ\n\tlVZQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc:content-transfer-encoding;\n\tbh=bCDk9u3fghFCPM6NjCEIFM8yXqyfLBKw1ddnSnZQRi4=;\n\tb=N2LMFoGHdL1nT+zmvSQYFB7ZUGlMUvH1tlUnHrIOALKdhrVcTlG2Tcjbpqkep9Citk\n\t8cwXYQ60p+rF4Ph8L2SU2PRnrpYajauTOjBSrg1JlKdzWYVJBZ9NXwwQR/T5x49V0u6o\n\tD2VchTMTTk9OnivfA79bdq8nHBnO3Y0uoAjqCaBoUSsV9UwJNhI2+oLsva7RyQafGHoT\n\t14flmyb7nMnAS5buBCxhL1NS1Hmjm0ZA7X3txLumNS/5oHWv5MlCaVNlMs6nOPbEPvPr\n\tHi+a9opHR1egEYMryOrdhAJnrDoXbFnYZWXd65i/Lh0krb0cFilPk8bBV1y7FO8ZvrUu\n\t3EUQ==","X-Gm-Message-State":"AOAM533+uTuWQGhxAuT27iViKRMUjvslzrlsTwiSUwpV5xcBVMbkFJIb\n\tjg9MIDUunGDkudWxy1mcgA/u8i/ETU7LPn8gkp8GyCsP","X-Google-Smtp-Source":"ABdhPJyM/kUw21dGE2IpupVo+gHsHQTl0O2baWrqkhfW7z+HA/gPCEXTzm3lVKS3zlnVS+L+HzuH99HrrX++MFY+kE0=","X-Received":"by 2002:a17:902:d48f:b0:149:2d71:7fa7 with SMTP id\n\tc15-20020a170902d48f00b001492d717fa7mr25742466plg.108.1640773499494;\n\tWed, 29 Dec 2021 02:24:59 -0800 (PST)","MIME-Version":"1.0","References":"<20211228095153.611009-1-roman.o.stratiienko@globallogic.com>\n\t<20211228110551.rxgzp77qfwpfj2n2@uno.localdomain>\n\t<CAGphcd=H0Ns5_1WL0YTsTvt9zkMCGNAaDygNcN4GXGhZfqkQMA@mail.gmail.com>\n\t<YctXI7T1elw77Rjr@pendragon.ideasonboard.com>\n\t<CAGphcd=jiw9-Cd_kYozvNVO2Q9+Mrr=eeURGJMR9+Z_kcV_BvQ@mail.gmail.com>\n\t<Ycw1FPz5Qv8wQpFr@pendragon.ideasonboard.com>","In-Reply-To":"<Ycw1FPz5Qv8wQpFr@pendragon.ideasonboard.com>","From":"Roman Stratiienko <r.stratiienko@gmail.com>","Date":"Wed, 29 Dec 2021 12:24:48 +0200","Message-ID":"<CAGphcdnYmrZR0ShYD7NiWx3XLdiBNoXzx_JgdsoOk1xwpTi8eA@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","Subject":"Re: [libcamera-devel] [PATCH] android: Make libyaml dependency\n\toptional","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>,\n\tRoman Stratiienko <roman.o.stratiienko@globallogic.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":21900,"web_url":"https://patchwork.libcamera.org/comment/21900/","msgid":"<CAGphcdkq=C6ZKD3caZk7npR+ZQvnEn4GirLfRbCeoeTmzmOx4A@mail.gmail.com>","date":"2021-12-29T12:17:03","subject":"Re: [libcamera-devel] [PATCH] android: Make libyaml dependency\n\toptional","submitter":{"id":106,"url":"https://patchwork.libcamera.org/api/people/106/","name":"Roman Stratiienko","email":"r.stratiienko@gmail.com"},"content":"+CC: John Stultz\n\nLaurent,\n\nI would like to make mainline libcamera work on mainline android\nwithout additional patches / extra packages and then give it to John\nStultz for testing with AOSP devboards in this shape.\nUnlike mesa3d libcamera doesn't have a lot of generated code,\ntherefore shipping this code / creating Android.bp is less painful.\nIn case this tricky plan will succeed and we will have libcamera\ninside AOSP, then rationale for adding libyaml into AOSP would be much\neasier to formulate.\n\nср, 29 дек. 2021 г. в 12:24, Roman Stratiienko <r.stratiienko@gmail.com>:\n>\n> ср, 29 дек. 2021 г. в 12:14, Laurent Pinchart\n> <laurent.pinchart@ideasonboard.com>:\n> >\n> > Hi Roman,\n> >\n> > On Wed, Dec 29, 2021 at 11:45:17AM +0200, Roman Stratiienko wrote:\n> > > вт, 28 дек. 2021 г. в 20:27, Laurent Pinchart:\n> > > > On Tue, Dec 28, 2021 at 01:22:34PM +0200, Roman Stratiienko wrote:\n> > > > > вт, 28 дек. 2021 г., 13:04 Jacopo Mondi:\n> > > > > > Hi Roman,\n> > > > > >\n> > > > > > cc Hanlin Chen from ChromiumOS as he's planning to extend\n> > > > > > configuration file support for the ChromeOS Android HAL.\n> > > > >\n> > > > > > Before looking into the patch: is there any hope libyaml might become\n> > > > > > part of the standard AOSP distribution (or a process in place to request\n> > > > > > that)\n> > > > >\n> > > > > I am not aware of that, and I haven't initiated such a process. It will be\n> > > > > a very slow and bumpy road.\n> > > > >\n> > > > > Not sure what is planned for these properties in future, but now it is not\n> > > > > necessary to have it in libcamera to have fully functional hal. Also having\n> > > > > no configuration file available will encourage developers to add\n> > > > > corresponding records to dts, which is also a great thing to align with\n> > > > > linux world.\n> > > >\n> > > > Our goals align here. This is exactly why we have decided not to set the\n> > > > camera location in a configuration file for the libcamera core, but to\n> > > > isolate it in the HAL as a temporary (but in practice likely a long-term\n> > > > temporary) measure, as we have to support platforms that will take some\n> > > > time before a firmware (ACPI in this case) update can be deployed.\n> > > >\n> > > > This being said, we will introduce a configuration file for the\n> > > > libcamera core in the near future, and we also plan to use libyaml\n> > > > there. The tuning files for the IPU3 and RkISP1 IPA modules will also\n> > > > use YAML, and I'd like to move the Raspberry Pi tuning files from JSON\n> > > > to YAML for consistency.\n> > >\n> > > It's a good idea to have a single file format. Currently we have to\n> > > ship boost to run raspberrypi cameras on Android.\n> >\n> > I'm happy you agree :-)\n> >\n> > > > We could merge this patch in the meantime, but compilation on Android\n> > > > will likely break again soon. I wonder if we couldn't instead use a\n> > > > meson wrap to include libyaml as a subproject. This should solve the\n> > > > issue in the longer term.\n> > >\n> > > At this moment we have libyaml with extra Android.bp, which can\n> > > satisfy libcamera needs.\n> > > But I really like to see it as an optional dependency only to help\n> > > fine-tuning things or for ACPI-only platforms.\n> >\n> > Making it optional may cause difficulties in the future, with\n> > potentially lots of conditional compilation. I'd rather not go that way,\n> > unless we can wrap the yaml parser in a helper class with a dummy\n> > implementation to hide the missing dependency from everything else.\n> >\n> > I've quickly tested compiling libyaml as a subproject, and it seems to\n> > work:\n> >\n>\n> I have some doubts if such an approach supports cross-compilation.\n> Could meson generate a single ninja.build from all sub-projects?\n> Implementing the fallback stub sounds not so bad.\n>\n> >\n> > commit f1d86859f522c7728d8f854b82296673291750fb\n> > Author: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > Date:   Wed Dec 29 12:07:35 2021 +0200\n> >\n> >     android: Compile libyaml as a subproject if not available on the system\n> >\n> >     AOSP doesn't ship libyaml, making it more difficult to compile libcamera\n> >     for Android. Use a meson wrap to compile libyaml as a subproject if the\n> >     dependency is not found.\n> >\n> >     Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> >\n> > diff --git a/src/android/meson.build b/src/android/meson.build\n> > index 75b4bf207085..1fa67746d058 100644\n> > --- a/src/android/meson.build\n> > +++ b/src/android/meson.build\n> > @@ -3,7 +3,6 @@\n> >  android_deps = [\n> >      dependency('libexif', required : get_option('android')),\n> >      dependency('libjpeg', required : get_option('android')),\n> > -    dependency('yaml-0.1', required : get_option('android')),\n> >      libcamera_private,\n> >  ]\n> >\n> > @@ -16,13 +15,35 @@ foreach dep : android_deps\n> >      endif\n> >  endforeach\n> >\n> > +cmake = import('cmake')\n> > +\n> > +#\n> > +# libyaml\n> > +#\n> > +# Default to the system version, and fallback to a subproject if not found, as\n> > +# libyaml is not packaged in AOSP.\n> > +#\n> > +libyaml_dep = dependency('yaml-0.1', required : false)\n> > +\n> > +# Fallback to a subproject if libyaml isn't found, as it's not packed in AOSP.\n> > +if not libyaml_dep.found()\n> > +    libyaml_vars = cmake.subproject_options()\n> > +    libyaml_vars.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'})\n> > +    libyaml = cmake.subproject('libyaml', options : libyaml_vars)\n> > +    libyaml_dep = libyaml.dependency('yaml')\n> > +endif\n> > +\n> > +android_deps += [libyaml_dep]\n> > +\n> > +#\n> > +# libyuv\n> > +#\n> > +# Default to the system version, and fallback to a subproject if not found, as\n> > +# libyuv is typically not provided by distributions.\n> > +#\n> >  libyuv_dep = dependency('libyuv', required : false)\n> >\n> > -# Fallback to a subproject if libyuv isn't found, as it's typically not\n> > -# provided by distributions.\n> >  if not libyuv_dep.found()\n> > -    cmake = import('cmake')\n> > -\n> >      libyuv_vars = cmake.subproject_options()\n> >      libyuv_vars.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'})\n> >      libyuv_vars.set_override_option('cpp_std', 'c++17')\n> > diff --git a/subprojects/.gitignore b/subprojects/.gitignore\n> > index 391fde2ce1e0..f207720b271a 100644\n> > --- a/subprojects/.gitignore\n> > +++ b/subprojects/.gitignore\n> > @@ -1,3 +1,4 @@\n> >  /googletest-release*\n> > +/libyaml\n> >  /libyuv\n> > -/packagecache\n> > \\ No newline at end of file\n> > +/packagecache\n> > diff --git a/subprojects/libyaml.wrap b/subprojects/libyaml.wrap\n> > new file mode 100644\n> > index 000000000000..e4426e44774f\n> > --- /dev/null\n> > +++ b/subprojects/libyaml.wrap\n> > @@ -0,0 +1,4 @@\n> > +[wrap-git]\n> > +directory = libyaml\n> > +url = https://github.com/yaml/libyaml\n> > +revision = 2c891fc7a770e8ba2fec34fc6b545c672beb37e6\n> >\n> > > > By the way, out of curiosity, how do you compile libcamera for Android ?\n> > > > We have a look at Soong (as the Makefile-based build system is being\n> > > > phased out), but blueprint files don't support all our needs (and would\n> > > > be annoying to maintain manually), and there's no way we found to\n> > > > generate Android.bp files from meson in a way that would integrate with\n> > > > Soong. This is still an unsolved problem, and I'm increasingly tempted\n> > > > to do the same as mesa3d and just document that libcamera should be\n> > > > built outside of AOSP, using the NDK.\n> > >\n> > > We shipped libcamera in our GloDroid project v0.7.0 release for\n> > > raspberry pi about a month ago:\n> > > 1. https://github.com/GloDroid/glodroid_manifest/releases/tag/v0.7.0\n> > > 2. https://github.com/GloDroid/glodroid_forks/commits/libcamera-v0.7.0\n> > >\n> > > For building using meson within AOSP we are using some tricks to\n> > > extract dependencies from AOSP makesystem and inject them into\n> > > meson cross compilation file.\n> >\n> > Does this mean that you compile libcamera manually, separately from AOSP\n> > ? That's probably the best option for now, until Android decides to\n> > integrate support for other build systems (likely never...).\n>\n> No. Building within AOSP does mean building within AOSP.\n> Not manually.\n> It utilizes the Kati (Android.mk) build system.\n> And Kati is currently tightly bound to Soong, separating both would require some\n> time for Google if they decide to do so.\n> And we always have \"building using NDK\" as a fallback once it happens.\n>\n> >\n> > > First such kind of approach was integrated into mesa3d and replaced\n> > > existing Android.mk files (about 6 month ago).\n> > > It doesn't require continuous maintenance as previous Android.mk did\n> > > and has proven to be reliable.\n> > > It also enables FULL support of mesa3d for Android. Previously only\n> > > about 60% of mesa3d drivers were covered with Android.mk files.\n> > > Reworking the same approach for libcamera was pretty easy.\n> > >\n> > > And yes, as an official approach for vendors NDK builds would be great\n> > > to support.\n> > > NDK approach and our meson.build within AOSP approach are 98% aligned.\n> > >\n> > > > > > On Tue, Dec 28, 2021 at 11:51:53AM +0200, Roman Stratiienko wrote:\n> > > > > > > Mainline Android has no libyaml in-tree. Moreover camera_hal_config.cpp\n> > > > > > > uses std::filesystem class that is not permitted for AOSP VNDK vendor\n> > > > > > > libraries.\n> > > > > > >\n> > > > > > > External configuration file is no longer mandatory and DTS overlays can\n> > > > > > > be used to specify camera location and rotation.\n> > > > > > >\n> > > > > > > Do not require external configuration file for cases where meson.build\n> > > > > > > can't find libyaml. Assume that cameras without location specified\n> > > > > > > by V4L2 properties are always external.\n> > > > > > >\n> > > > > > > Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>\n> > > > > > > ---\n> > > > > > >  src/android/camera_hal_manager.cpp | 13 +++++++++++++\n> > > > > > >  src/android/camera_hal_manager.h   |  2 ++\n> > > > > > >  src/android/meson.build            | 10 ++++++++--\n> > > > > > >  3 files changed, 23 insertions(+), 2 deletions(-)\n> > > > > > >\n> > > > > > > diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp\n> > > > > > > index 5f7bfe265c71b..9e575bfa5204a 100644\n> > > > > > > --- a/src/android/camera_hal_manager.cpp\n> > > > > > > +++ b/src/android/camera_hal_manager.cpp\n> > > > > > > @@ -48,6 +48,7 @@ int CameraHalManager::init()\n> > > > > > >  {\n> > > > > > >       cameraManager_ = std::make_unique<CameraManager>();\n> > > > > > >\n> > > > > > > +#ifdef HAVE_LIBYAML\n> > > > > > >       /*\n> > > > > > >        * If the configuration file is not available the HAL only supports\n> > > > > > >        * external cameras. If it exists but it's not valid then error out.\n> > > > > > > @@ -56,6 +57,7 @@ int CameraHalManager::init()\n> > > > > > >               LOG(HAL, Error) << \"HAL configuration file is not valid\";\n> > > > > > >               return -EINVAL;\n> > > > > > >       }\n> > > > > > > +#endif\n> > > > > > >\n> > > > > > >       /* Support camera hotplug. */\n> > > > > > >       cameraManager_->cameraAdded.connect(this, &CameraHalManager::cameraAdded);\n> > > > > > > @@ -133,6 +135,7 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\n> > > > > > >               }\n> > > > > > >       }\n> > > > > > >\n> > > > > > > +#ifdef HAVE_LIBYAML\n> > > > > > >       /*\n> > > > > > >        * The configuration file must be valid, and contain a corresponding\n> > > > > > >        * entry for internal cameras. External cameras can be initialized\n> > > > > > > @@ -145,6 +148,16 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\n> > > > > > >       }\n> > > > > > >\n> > > > > > >       const CameraConfigData *cameraConfigData = halConfig_.cameraConfigData(cam->id());\n> > > > > > > +#else\n> > > > > > > +     /*\n> > > > > > > +      * Assume that cameras without properties::Location specified are external.\n> > > > > > > +      */\n> > > > > > > +     const CameraConfigData *cameraConfigData = nullptr;\n> > > > > > > +     if (!isCameraExternal && cameraLocation(cam.get()) < 0) {\n> > > > > > > +             isCameraExternal = true;\n> > > > > > > +             id = nextExternalCameraId_;\n> > > > > > > +     }\n> > > > > > > +#endif\n> > > > > > >\n> > > > > > >       /*\n> > > > > > >        * Some cameras whose location is reported by libcamera as external may\n> > > > > > > diff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h\n> > > > > > > index a5f8b933a7902..056abbb0d4e54 100644\n> > > > > > > --- a/src/android/camera_hal_manager.h\n> > > > > > > +++ b/src/android/camera_hal_manager.h\n> > > > > > > @@ -56,7 +56,9 @@ private:\n> > > > > > >       CameraDevice *cameraDeviceFromHalId(unsigned int id) LIBCAMERA_TSA_REQUIRES(mutex_);\n> > > > > > >\n> > > > > > >       std::unique_ptr<libcamera::CameraManager> cameraManager_;\n> > > > > > > +#ifdef HAVE_LIBYAML\n> > > > > > >       CameraHalConfig halConfig_;\n> > > > > > > +#endif\n> > > > > > >\n> > > > > > >       const camera_module_callbacks_t *callbacks_;\n> > > > > > >       std::vector<std::unique_ptr<CameraDevice>> cameras_ LIBCAMERA_TSA_GUARDED_BY(mutex_);\n> > > > > > > diff --git a/src/android/meson.build b/src/android/meson.build\n> > > > > > > index 75b4bf2070851..1e471c291a1e4 100644\n> > > > > > > --- a/src/android/meson.build\n> > > > > > > +++ b/src/android/meson.build\n> > > > > > > @@ -3,7 +3,6 @@\n> > > > > > >  android_deps = [\n> > > > > > >      dependency('libexif', required : get_option('android')),\n> > > > > > >      dependency('libjpeg', required : get_option('android')),\n> > > > > > > -    dependency('yaml-0.1', required : get_option('android')),\n> > > > > > >      libcamera_private,\n> > > > > > >  ]\n> > > > > > >\n> > > > > > > @@ -41,7 +40,6 @@ android_hal_sources = files([\n> > > > > > >      'camera3_hal.cpp',\n> > > > > > >      'camera_capabilities.cpp',\n> > > > > > >      'camera_device.cpp',\n> > > > > > > -    'camera_hal_config.cpp',\n> > > > > > >      'camera_hal_manager.cpp',\n> > > > > > >      'camera_metadata.cpp',\n> > > > > > >      'camera_ops.cpp',\n> > > > > > > @@ -56,6 +54,14 @@ android_hal_sources = files([\n> > > > > > >\n> > > > > > >  android_cpp_args = []\n> > > > > > >\n> > > > > > > +libyaml_dep = dependency('yaml-0.1', required : false)\n> > > > > > > +if libyaml_dep.found()\n> > > > > > > +    config_h.set('HAVE_LIBYAML', 1)\n> > > > > > > +    android_hal_sources += files([\n> > > > > > > +        'camera_hal_config.cpp',\n> > > > > > > +    ])\n> > > > > > > +endif\n> > > > > > > +\n> > > > > > >  subdir('cros')\n> > > > > > >  subdir('mm')\n> > > > > > >\n> >\n> > --\n> > Regards,\n> >\n> > Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id B89EEBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 29 Dec 2021 12:17:18 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 257D0608EB;\n\tWed, 29 Dec 2021 13:17:18 +0100 (CET)","from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com\n\t[IPv6:2607:f8b0:4864:20::102b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 200DC608E9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 Dec 2021 13:17:16 +0100 (CET)","by mail-pj1-x102b.google.com with SMTP id\n\tc9-20020a17090a1d0900b001b2b54bd6c5so2875370pjd.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 Dec 2021 04:17:16 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"Gar8aESh\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc:content-transfer-encoding;\n\tbh=rSK0zeVWqCfxxLrEsDKa2o0NajnpfRb7qMbXTq1viOA=;\n\tb=Gar8aEShS4Op3rHpsHrOhEvVLpl5CMDsLXsZjdzQ8RcWP1B+vVGM2t9r5olYxxZD6W\n\t1CNhAZdn9fMR9/EQk+ATuKFXypJxaiB2ZJZW4LB+P75gJ6fGgRwkoJRJuZVkqygg55uH\n\tef0Nk6Lvnpa1TxEIlShVfhh0XepRLKLGP+P7j++6jJMFZcrAGa5xUUzxOZFTFdTaCwhA\n\tt9qau975geID7QXIMIfr7wxazwbaIpKwqGtoqxO7+xXuBZFAGJ8nK9gVprUePr9hJS+Y\n\tZ3Y0DNyt0TLrDxS8N3MCS4NMqa43/neARFPLvo8urmARGBk15Ms4yK1tfexeXCTote3E\n\tXWIA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc:content-transfer-encoding;\n\tbh=rSK0zeVWqCfxxLrEsDKa2o0NajnpfRb7qMbXTq1viOA=;\n\tb=LTNlLcuSscc7it10KSuJ9yLjRfKLvwB09qWt3ozW4P6u6fCIzLCC+dJu6HCItB311g\n\t2ZPqVwhRerQLZtahERa1s6+ql/Ywv0T6C/6cPI0KQyDoBsF7St5yMtM5xw8iINI12cVl\n\tVcFrSRStxzyitYD5wNPBQl2MniD+Xlbyx0+gsN7GlHNI6mlQTgAjWIEBkgQNO4bgFNhM\n\tcLvrS/FVECcrAl/D3IWiKFI0PYZad21WLA/RufdxiuHhNskee6vWJZmQyFYldmCtwjAa\n\t4DL+Jp+Jm3yYXDr4GvlAra0dO4yJIrC7kNkTQEM7FAoRpBUpPDx6HHzsY0m7og0qmGXZ\n\tWdPw==","X-Gm-Message-State":"AOAM533qIKqxuv7lKyudwqX7teaYxZ/+Cn6BOMv3M0bIOeEowLirGe93\n\tnSA13yFbUHfafM8h4qvyref7AYaTFrdPIRwmAiU=","X-Google-Smtp-Source":"ABdhPJxeS/VPSHFzT2NVjJ0aj5RheuO9DC+ZHhyUaOQ3qQFRHp0LqfgC931rqaiRtx0bU7HL+IiZu4lTMSy/IYAImgs=","X-Received":"by 2002:a17:902:f681:b0:148:e8be:3e1 with SMTP id\n\tl1-20020a170902f68100b00148e8be03e1mr26568759plg.158.1640780234415;\n\tWed, 29 Dec 2021 04:17:14 -0800 (PST)","MIME-Version":"1.0","References":"<20211228095153.611009-1-roman.o.stratiienko@globallogic.com>\n\t<20211228110551.rxgzp77qfwpfj2n2@uno.localdomain>\n\t<CAGphcd=H0Ns5_1WL0YTsTvt9zkMCGNAaDygNcN4GXGhZfqkQMA@mail.gmail.com>\n\t<YctXI7T1elw77Rjr@pendragon.ideasonboard.com>\n\t<CAGphcd=jiw9-Cd_kYozvNVO2Q9+Mrr=eeURGJMR9+Z_kcV_BvQ@mail.gmail.com>\n\t<Ycw1FPz5Qv8wQpFr@pendragon.ideasonboard.com>\n\t<CAGphcdnYmrZR0ShYD7NiWx3XLdiBNoXzx_JgdsoOk1xwpTi8eA@mail.gmail.com>","In-Reply-To":"<CAGphcdnYmrZR0ShYD7NiWx3XLdiBNoXzx_JgdsoOk1xwpTi8eA@mail.gmail.com>","From":"Roman Stratiienko <r.stratiienko@gmail.com>","Date":"Wed, 29 Dec 2021 14:17:03 +0200","Message-ID":"<CAGphcdkq=C6ZKD3caZk7npR+ZQvnEn4GirLfRbCeoeTmzmOx4A@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","Subject":"Re: [libcamera-devel] [PATCH] android: Make libyaml dependency\n\toptional","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"John Stultz <john.stultz@linaro.org>,\n\tlibcamera devel <libcamera-devel@lists.libcamera.org>,\n\tRoman Stratiienko <roman.o.stratiienko@globallogic.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":21901,"web_url":"https://patchwork.libcamera.org/comment/21901/","msgid":"<YcxynJKZgylxKgTy@pendragon.ideasonboard.com>","date":"2021-12-29T14:37:16","subject":"Re: [libcamera-devel] [PATCH] android: Make libyaml dependency\n\toptional","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Roman,\n\nOn Wed, Dec 29, 2021 at 12:24:48PM +0200, Roman Stratiienko wrote:\n> ср, 29 дек. 2021 г. в 12:14, Laurent Pinchart:\n> > On Wed, Dec 29, 2021 at 11:45:17AM +0200, Roman Stratiienko wrote:\n> > > вт, 28 дек. 2021 г. в 20:27, Laurent Pinchart:\n> > > > On Tue, Dec 28, 2021 at 01:22:34PM +0200, Roman Stratiienko wrote:\n> > > > > вт, 28 дек. 2021 г., 13:04 Jacopo Mondi:\n> > > > > > Hi Roman,\n> > > > > >\n> > > > > > cc Hanlin Chen from ChromiumOS as he's planning to extend\n> > > > > > configuration file support for the ChromeOS Android HAL.\n> > > > >\n> > > > > > Before looking into the patch: is there any hope libyaml might become\n> > > > > > part of the standard AOSP distribution (or a process in place to request\n> > > > > > that)\n> > > > >\n> > > > > I am not aware of that, and I haven't initiated such a process. It will be\n> > > > > a very slow and bumpy road.\n> > > > >\n> > > > > Not sure what is planned for these properties in future, but now it is not\n> > > > > necessary to have it in libcamera to have fully functional hal. Also having\n> > > > > no configuration file available will encourage developers to add\n> > > > > corresponding records to dts, which is also a great thing to align with\n> > > > > linux world.\n> > > >\n> > > > Our goals align here. This is exactly why we have decided not to set the\n> > > > camera location in a configuration file for the libcamera core, but to\n> > > > isolate it in the HAL as a temporary (but in practice likely a long-term\n> > > > temporary) measure, as we have to support platforms that will take some\n> > > > time before a firmware (ACPI in this case) update can be deployed.\n> > > >\n> > > > This being said, we will introduce a configuration file for the\n> > > > libcamera core in the near future, and we also plan to use libyaml\n> > > > there. The tuning files for the IPU3 and RkISP1 IPA modules will also\n> > > > use YAML, and I'd like to move the Raspberry Pi tuning files from JSON\n> > > > to YAML for consistency.\n> > >\n> > > It's a good idea to have a single file format. Currently we have to\n> > > ship boost to run raspberrypi cameras on Android.\n> >\n> > I'm happy you agree :-)\n> >\n> > > > We could merge this patch in the meantime, but compilation on Android\n> > > > will likely break again soon. I wonder if we couldn't instead use a\n> > > > meson wrap to include libyaml as a subproject. This should solve the\n> > > > issue in the longer term.\n> > >\n> > > At this moment we have libyaml with extra Android.bp, which can\n> > > satisfy libcamera needs.\n> > > But I really like to see it as an optional dependency only to help\n> > > fine-tuning things or for ACPI-only platforms.\n> >\n> > Making it optional may cause difficulties in the future, with\n> > potentially lots of conditional compilation. I'd rather not go that way,\n> > unless we can wrap the yaml parser in a helper class with a dummy\n> > implementation to hide the missing dependency from everything else.\n> >\n> > I've quickly tested compiling libyaml as a subproject, and it seems to\n> > work:\n> \n> I have some doubts if such an approach supports cross-compilation.\n> Could meson generate a single ninja.build from all sub-projects?\n> Implementing the fallback stub sounds not so bad.\n\nWith an additional\n\n\tlibyaml_vars.append_compile_args('c', '-Wno-unused-value')\n\nit cross-compiles fine for ARM64.\n\n> > commit f1d86859f522c7728d8f854b82296673291750fb\n> > Author: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > Date:   Wed Dec 29 12:07:35 2021 +0200\n> >\n> >     android: Compile libyaml as a subproject if not available on the system\n> >\n> >     AOSP doesn't ship libyaml, making it more difficult to compile libcamera\n> >     for Android. Use a meson wrap to compile libyaml as a subproject if the\n> >     dependency is not found.\n> >\n> >     Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> >\n> > diff --git a/src/android/meson.build b/src/android/meson.build\n> > index 75b4bf207085..1fa67746d058 100644\n> > --- a/src/android/meson.build\n> > +++ b/src/android/meson.build\n> > @@ -3,7 +3,6 @@\n> >  android_deps = [\n> >      dependency('libexif', required : get_option('android')),\n> >      dependency('libjpeg', required : get_option('android')),\n> > -    dependency('yaml-0.1', required : get_option('android')),\n> >      libcamera_private,\n> >  ]\n> >\n> > @@ -16,13 +15,35 @@ foreach dep : android_deps\n> >      endif\n> >  endforeach\n> >\n> > +cmake = import('cmake')\n> > +\n> > +#\n> > +# libyaml\n> > +#\n> > +# Default to the system version, and fallback to a subproject if not found, as\n> > +# libyaml is not packaged in AOSP.\n> > +#\n> > +libyaml_dep = dependency('yaml-0.1', required : false)\n> > +\n> > +# Fallback to a subproject if libyaml isn't found, as it's not packed in AOSP.\n> > +if not libyaml_dep.found()\n> > +    libyaml_vars = cmake.subproject_options()\n> > +    libyaml_vars.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'})\n> > +    libyaml = cmake.subproject('libyaml', options : libyaml_vars)\n> > +    libyaml_dep = libyaml.dependency('yaml')\n> > +endif\n> > +\n> > +android_deps += [libyaml_dep]\n> > +\n> > +#\n> > +# libyuv\n> > +#\n> > +# Default to the system version, and fallback to a subproject if not found, as\n> > +# libyuv is typically not provided by distributions.\n> > +#\n> >  libyuv_dep = dependency('libyuv', required : false)\n> >\n> > -# Fallback to a subproject if libyuv isn't found, as it's typically not\n> > -# provided by distributions.\n> >  if not libyuv_dep.found()\n> > -    cmake = import('cmake')\n> > -\n> >      libyuv_vars = cmake.subproject_options()\n> >      libyuv_vars.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'})\n> >      libyuv_vars.set_override_option('cpp_std', 'c++17')\n> > diff --git a/subprojects/.gitignore b/subprojects/.gitignore\n> > index 391fde2ce1e0..f207720b271a 100644\n> > --- a/subprojects/.gitignore\n> > +++ b/subprojects/.gitignore\n> > @@ -1,3 +1,4 @@\n> >  /googletest-release*\n> > +/libyaml\n> >  /libyuv\n> > -/packagecache\n> > \\ No newline at end of file\n> > +/packagecache\n> > diff --git a/subprojects/libyaml.wrap b/subprojects/libyaml.wrap\n> > new file mode 100644\n> > index 000000000000..e4426e44774f\n> > --- /dev/null\n> > +++ b/subprojects/libyaml.wrap\n> > @@ -0,0 +1,4 @@\n> > +[wrap-git]\n> > +directory = libyaml\n> > +url = https://github.com/yaml/libyaml\n> > +revision = 2c891fc7a770e8ba2fec34fc6b545c672beb37e6\n> >\n> > > > By the way, out of curiosity, how do you compile libcamera for Android ?\n> > > > We have a look at Soong (as the Makefile-based build system is being\n> > > > phased out), but blueprint files don't support all our needs (and would\n> > > > be annoying to maintain manually), and there's no way we found to\n> > > > generate Android.bp files from meson in a way that would integrate with\n> > > > Soong. This is still an unsolved problem, and I'm increasingly tempted\n> > > > to do the same as mesa3d and just document that libcamera should be\n> > > > built outside of AOSP, using the NDK.\n> > >\n> > > We shipped libcamera in our GloDroid project v0.7.0 release for\n> > > raspberry pi about a month ago:\n> > > 1. https://github.com/GloDroid/glodroid_manifest/releases/tag/v0.7.0\n> > > 2. https://github.com/GloDroid/glodroid_forks/commits/libcamera-v0.7.0\n> > >\n> > > For building using meson within AOSP we are using some tricks to\n> > > extract dependencies from AOSP makesystem and inject them into\n> > > meson cross compilation file.\n> >\n> > Does this mean that you compile libcamera manually, separately from AOSP\n> > ? That's probably the best option for now, until Android decides to\n> > integrate support for other build systems (likely never...).\n> \n> No. Building within AOSP does mean building within AOSP.\n> Not manually.\n> It utilizes the Kati (Android.mk) build system.\n> And Kati is currently tightly bound to Soong, separating both would require some\n> time for Google if they decide to do so.\n> And we always have \"building using NDK\" as a fallback once it happens.\n\nI thought they had mostly finished the conversion to Soong, but I could\nbe wrong. I remember finding a page that listed the timeline and what\ntypes of packages were still allowed to use Android.mk at different\npoints in the transition, but I can't locate that anymore.\n\nCould you point me to the sources that show how you built libcamera ?\n\nAnd if it wasn't \"fun\" enough, they're moving away from Soong to Bazel\n(https://android.googlesource.com/platform/build/bazel/+/refs/heads/master/docs/concepts.md).\n\n> > > First such kind of approach was integrated into mesa3d and replaced\n> > > existing Android.mk files (about 6 month ago).\n> > > It doesn't require continuous maintenance as previous Android.mk did\n> > > and has proven to be reliable.\n> > > It also enables FULL support of mesa3d for Android. Previously only\n> > > about 60% of mesa3d drivers were covered with Android.mk files.\n> > > Reworking the same approach for libcamera was pretty easy.\n> > >\n> > > And yes, as an official approach for vendors NDK builds would be great\n> > > to support.\n> > > NDK approach and our meson.build within AOSP approach are 98% aligned.\n> > >\n> > > > > > On Tue, Dec 28, 2021 at 11:51:53AM +0200, Roman Stratiienko wrote:\n> > > > > > > Mainline Android has no libyaml in-tree. Moreover camera_hal_config.cpp\n> > > > > > > uses std::filesystem class that is not permitted for AOSP VNDK vendor\n> > > > > > > libraries.\n> > > > > > >\n> > > > > > > External configuration file is no longer mandatory and DTS overlays can\n> > > > > > > be used to specify camera location and rotation.\n> > > > > > >\n> > > > > > > Do not require external configuration file for cases where meson.build\n> > > > > > > can't find libyaml. Assume that cameras without location specified\n> > > > > > > by V4L2 properties are always external.\n> > > > > > >\n> > > > > > > Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>\n> > > > > > > ---\n> > > > > > >  src/android/camera_hal_manager.cpp | 13 +++++++++++++\n> > > > > > >  src/android/camera_hal_manager.h   |  2 ++\n> > > > > > >  src/android/meson.build            | 10 ++++++++--\n> > > > > > >  3 files changed, 23 insertions(+), 2 deletions(-)\n> > > > > > >\n> > > > > > > diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp\n> > > > > > > index 5f7bfe265c71b..9e575bfa5204a 100644\n> > > > > > > --- a/src/android/camera_hal_manager.cpp\n> > > > > > > +++ b/src/android/camera_hal_manager.cpp\n> > > > > > > @@ -48,6 +48,7 @@ int CameraHalManager::init()\n> > > > > > >  {\n> > > > > > >       cameraManager_ = std::make_unique<CameraManager>();\n> > > > > > >\n> > > > > > > +#ifdef HAVE_LIBYAML\n> > > > > > >       /*\n> > > > > > >        * If the configuration file is not available the HAL only supports\n> > > > > > >        * external cameras. If it exists but it's not valid then error out.\n> > > > > > > @@ -56,6 +57,7 @@ int CameraHalManager::init()\n> > > > > > >               LOG(HAL, Error) << \"HAL configuration file is not valid\";\n> > > > > > >               return -EINVAL;\n> > > > > > >       }\n> > > > > > > +#endif\n> > > > > > >\n> > > > > > >       /* Support camera hotplug. */\n> > > > > > >       cameraManager_->cameraAdded.connect(this, &CameraHalManager::cameraAdded);\n> > > > > > > @@ -133,6 +135,7 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\n> > > > > > >               }\n> > > > > > >       }\n> > > > > > >\n> > > > > > > +#ifdef HAVE_LIBYAML\n> > > > > > >       /*\n> > > > > > >        * The configuration file must be valid, and contain a corresponding\n> > > > > > >        * entry for internal cameras. External cameras can be initialized\n> > > > > > > @@ -145,6 +148,16 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\n> > > > > > >       }\n> > > > > > >\n> > > > > > >       const CameraConfigData *cameraConfigData = halConfig_.cameraConfigData(cam->id());\n> > > > > > > +#else\n> > > > > > > +     /*\n> > > > > > > +      * Assume that cameras without properties::Location specified are external.\n> > > > > > > +      */\n> > > > > > > +     const CameraConfigData *cameraConfigData = nullptr;\n> > > > > > > +     if (!isCameraExternal && cameraLocation(cam.get()) < 0) {\n> > > > > > > +             isCameraExternal = true;\n> > > > > > > +             id = nextExternalCameraId_;\n> > > > > > > +     }\n> > > > > > > +#endif\n> > > > > > >\n> > > > > > >       /*\n> > > > > > >        * Some cameras whose location is reported by libcamera as external may\n> > > > > > > diff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h\n> > > > > > > index a5f8b933a7902..056abbb0d4e54 100644\n> > > > > > > --- a/src/android/camera_hal_manager.h\n> > > > > > > +++ b/src/android/camera_hal_manager.h\n> > > > > > > @@ -56,7 +56,9 @@ private:\n> > > > > > >       CameraDevice *cameraDeviceFromHalId(unsigned int id) LIBCAMERA_TSA_REQUIRES(mutex_);\n> > > > > > >\n> > > > > > >       std::unique_ptr<libcamera::CameraManager> cameraManager_;\n> > > > > > > +#ifdef HAVE_LIBYAML\n> > > > > > >       CameraHalConfig halConfig_;\n> > > > > > > +#endif\n> > > > > > >\n> > > > > > >       const camera_module_callbacks_t *callbacks_;\n> > > > > > >       std::vector<std::unique_ptr<CameraDevice>> cameras_ LIBCAMERA_TSA_GUARDED_BY(mutex_);\n> > > > > > > diff --git a/src/android/meson.build b/src/android/meson.build\n> > > > > > > index 75b4bf2070851..1e471c291a1e4 100644\n> > > > > > > --- a/src/android/meson.build\n> > > > > > > +++ b/src/android/meson.build\n> > > > > > > @@ -3,7 +3,6 @@\n> > > > > > >  android_deps = [\n> > > > > > >      dependency('libexif', required : get_option('android')),\n> > > > > > >      dependency('libjpeg', required : get_option('android')),\n> > > > > > > -    dependency('yaml-0.1', required : get_option('android')),\n> > > > > > >      libcamera_private,\n> > > > > > >  ]\n> > > > > > >\n> > > > > > > @@ -41,7 +40,6 @@ android_hal_sources = files([\n> > > > > > >      'camera3_hal.cpp',\n> > > > > > >      'camera_capabilities.cpp',\n> > > > > > >      'camera_device.cpp',\n> > > > > > > -    'camera_hal_config.cpp',\n> > > > > > >      'camera_hal_manager.cpp',\n> > > > > > >      'camera_metadata.cpp',\n> > > > > > >      'camera_ops.cpp',\n> > > > > > > @@ -56,6 +54,14 @@ android_hal_sources = files([\n> > > > > > >\n> > > > > > >  android_cpp_args = []\n> > > > > > >\n> > > > > > > +libyaml_dep = dependency('yaml-0.1', required : false)\n> > > > > > > +if libyaml_dep.found()\n> > > > > > > +    config_h.set('HAVE_LIBYAML', 1)\n> > > > > > > +    android_hal_sources += files([\n> > > > > > > +        'camera_hal_config.cpp',\n> > > > > > > +    ])\n> > > > > > > +endif\n> > > > > > > +\n> > > > > > >  subdir('cros')\n> > > > > > >  subdir('mm')\n> > > > > > >","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 5227FBE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 29 Dec 2021 14:37:21 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9BB5D60911;\n\tWed, 29 Dec 2021 15:37:20 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A2183608E9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 Dec 2021 15:37:19 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0A5EC464;\n\tWed, 29 Dec 2021 15:37:18 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"bXAwswOZ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1640788639;\n\tbh=UkteV0k6ghbt64x79Niz7+SS0HoV6veBifVRd3YFneA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=bXAwswOZ1A1B2Tugoo1day2YZUGNXs12OWBS4Yx/nqrg4UajDgwDmMovbQvmYi4R9\n\tDGdI2TmVR7oGDuaCPQRPGglc8tNOLyRfO0m04iVfqp9DVjEetWQUzHPMV9k2O8jPyG\n\tMgIR+asgwVJhCwiDpAWyPmOY6+ScjfQtfH6HFC/E=","Date":"Wed, 29 Dec 2021 16:37:16 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Roman Stratiienko <r.stratiienko@gmail.com>","Message-ID":"<YcxynJKZgylxKgTy@pendragon.ideasonboard.com>","References":"<20211228095153.611009-1-roman.o.stratiienko@globallogic.com>\n\t<20211228110551.rxgzp77qfwpfj2n2@uno.localdomain>\n\t<CAGphcd=H0Ns5_1WL0YTsTvt9zkMCGNAaDygNcN4GXGhZfqkQMA@mail.gmail.com>\n\t<YctXI7T1elw77Rjr@pendragon.ideasonboard.com>\n\t<CAGphcd=jiw9-Cd_kYozvNVO2Q9+Mrr=eeURGJMR9+Z_kcV_BvQ@mail.gmail.com>\n\t<Ycw1FPz5Qv8wQpFr@pendragon.ideasonboard.com>\n\t<CAGphcdnYmrZR0ShYD7NiWx3XLdiBNoXzx_JgdsoOk1xwpTi8eA@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<CAGphcdnYmrZR0ShYD7NiWx3XLdiBNoXzx_JgdsoOk1xwpTi8eA@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH] android: Make libyaml dependency\n\toptional","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>,\n\tRoman Stratiienko <roman.o.stratiienko@globallogic.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":21902,"web_url":"https://patchwork.libcamera.org/comment/21902/","msgid":"<YcxzTn9ZxDxuYQO3@pendragon.ideasonboard.com>","date":"2021-12-29T14:40:14","subject":"Re: [libcamera-devel] [PATCH] android: Make libyaml dependency\n\toptional","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Roman,\n\nOn Wed, Dec 29, 2021 at 02:17:03PM +0200, Roman Stratiienko wrote:\n> +CC: John Stultz\n> \n> Laurent,\n> \n> I would like to make mainline libcamera work on mainline android\n> without additional patches / extra packages and then give it to John\n> Stultz for testing with AOSP devboards in this shape.\n> Unlike mesa3d libcamera doesn't have a lot of generated code,\n> therefore shipping this code / creating Android.bp is less painful.\n\nHow do you envision this being done ? We don't want to commit generated\nsources to the libcamera git repository. Please note that one of the\nsource files generated during build contains a randomly generated\nprivate key which is thrown away at the end of the build. Committing a\nprivate key to a source tree will not be a very good idea :-)\n\n> In case this tricky plan will succeed and we will have libcamera\n> inside AOSP, then rationale for adding libyaml into AOSP would be much\n> easier to formulate.\n>\n> ср, 29 дек. 2021 г. в 12:24, Roman Stratiienko:\n> > ср, 29 дек. 2021 г. в 12:14, Laurent Pinchart:\n> > > On Wed, Dec 29, 2021 at 11:45:17AM +0200, Roman Stratiienko wrote:\n> > > > вт, 28 дек. 2021 г. в 20:27, Laurent Pinchart:\n> > > > > On Tue, Dec 28, 2021 at 01:22:34PM +0200, Roman Stratiienko wrote:\n> > > > > > вт, 28 дек. 2021 г., 13:04 Jacopo Mondi:\n> > > > > > > Hi Roman,\n> > > > > > >\n> > > > > > > cc Hanlin Chen from ChromiumOS as he's planning to extend\n> > > > > > > configuration file support for the ChromeOS Android HAL.\n> > > > > >\n> > > > > > > Before looking into the patch: is there any hope libyaml might become\n> > > > > > > part of the standard AOSP distribution (or a process in place to request\n> > > > > > > that)\n> > > > > >\n> > > > > > I am not aware of that, and I haven't initiated such a process. It will be\n> > > > > > a very slow and bumpy road.\n> > > > > >\n> > > > > > Not sure what is planned for these properties in future, but now it is not\n> > > > > > necessary to have it in libcamera to have fully functional hal. Also having\n> > > > > > no configuration file available will encourage developers to add\n> > > > > > corresponding records to dts, which is also a great thing to align with\n> > > > > > linux world.\n> > > > >\n> > > > > Our goals align here. This is exactly why we have decided not to set the\n> > > > > camera location in a configuration file for the libcamera core, but to\n> > > > > isolate it in the HAL as a temporary (but in practice likely a long-term\n> > > > > temporary) measure, as we have to support platforms that will take some\n> > > > > time before a firmware (ACPI in this case) update can be deployed.\n> > > > >\n> > > > > This being said, we will introduce a configuration file for the\n> > > > > libcamera core in the near future, and we also plan to use libyaml\n> > > > > there. The tuning files for the IPU3 and RkISP1 IPA modules will also\n> > > > > use YAML, and I'd like to move the Raspberry Pi tuning files from JSON\n> > > > > to YAML for consistency.\n> > > >\n> > > > It's a good idea to have a single file format. Currently we have to\n> > > > ship boost to run raspberrypi cameras on Android.\n> > >\n> > > I'm happy you agree :-)\n> > >\n> > > > > We could merge this patch in the meantime, but compilation on Android\n> > > > > will likely break again soon. I wonder if we couldn't instead use a\n> > > > > meson wrap to include libyaml as a subproject. This should solve the\n> > > > > issue in the longer term.\n> > > >\n> > > > At this moment we have libyaml with extra Android.bp, which can\n> > > > satisfy libcamera needs.\n> > > > But I really like to see it as an optional dependency only to help\n> > > > fine-tuning things or for ACPI-only platforms.\n> > >\n> > > Making it optional may cause difficulties in the future, with\n> > > potentially lots of conditional compilation. I'd rather not go that way,\n> > > unless we can wrap the yaml parser in a helper class with a dummy\n> > > implementation to hide the missing dependency from everything else.\n> > >\n> > > I've quickly tested compiling libyaml as a subproject, and it seems to\n> > > work:\n> > >\n> >\n> > I have some doubts if such an approach supports cross-compilation.\n> > Could meson generate a single ninja.build from all sub-projects?\n> > Implementing the fallback stub sounds not so bad.\n> >\n> > >\n> > > commit f1d86859f522c7728d8f854b82296673291750fb\n> > > Author: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > > Date:   Wed Dec 29 12:07:35 2021 +0200\n> > >\n> > >     android: Compile libyaml as a subproject if not available on the system\n> > >\n> > >     AOSP doesn't ship libyaml, making it more difficult to compile libcamera\n> > >     for Android. Use a meson wrap to compile libyaml as a subproject if the\n> > >     dependency is not found.\n> > >\n> > >     Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > >\n> > > diff --git a/src/android/meson.build b/src/android/meson.build\n> > > index 75b4bf207085..1fa67746d058 100644\n> > > --- a/src/android/meson.build\n> > > +++ b/src/android/meson.build\n> > > @@ -3,7 +3,6 @@\n> > >  android_deps = [\n> > >      dependency('libexif', required : get_option('android')),\n> > >      dependency('libjpeg', required : get_option('android')),\n> > > -    dependency('yaml-0.1', required : get_option('android')),\n> > >      libcamera_private,\n> > >  ]\n> > >\n> > > @@ -16,13 +15,35 @@ foreach dep : android_deps\n> > >      endif\n> > >  endforeach\n> > >\n> > > +cmake = import('cmake')\n> > > +\n> > > +#\n> > > +# libyaml\n> > > +#\n> > > +# Default to the system version, and fallback to a subproject if not found, as\n> > > +# libyaml is not packaged in AOSP.\n> > > +#\n> > > +libyaml_dep = dependency('yaml-0.1', required : false)\n> > > +\n> > > +# Fallback to a subproject if libyaml isn't found, as it's not packed in AOSP.\n> > > +if not libyaml_dep.found()\n> > > +    libyaml_vars = cmake.subproject_options()\n> > > +    libyaml_vars.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'})\n> > > +    libyaml = cmake.subproject('libyaml', options : libyaml_vars)\n> > > +    libyaml_dep = libyaml.dependency('yaml')\n> > > +endif\n> > > +\n> > > +android_deps += [libyaml_dep]\n> > > +\n> > > +#\n> > > +# libyuv\n> > > +#\n> > > +# Default to the system version, and fallback to a subproject if not found, as\n> > > +# libyuv is typically not provided by distributions.\n> > > +#\n> > >  libyuv_dep = dependency('libyuv', required : false)\n> > >\n> > > -# Fallback to a subproject if libyuv isn't found, as it's typically not\n> > > -# provided by distributions.\n> > >  if not libyuv_dep.found()\n> > > -    cmake = import('cmake')\n> > > -\n> > >      libyuv_vars = cmake.subproject_options()\n> > >      libyuv_vars.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'})\n> > >      libyuv_vars.set_override_option('cpp_std', 'c++17')\n> > > diff --git a/subprojects/.gitignore b/subprojects/.gitignore\n> > > index 391fde2ce1e0..f207720b271a 100644\n> > > --- a/subprojects/.gitignore\n> > > +++ b/subprojects/.gitignore\n> > > @@ -1,3 +1,4 @@\n> > >  /googletest-release*\n> > > +/libyaml\n> > >  /libyuv\n> > > -/packagecache\n> > > \\ No newline at end of file\n> > > +/packagecache\n> > > diff --git a/subprojects/libyaml.wrap b/subprojects/libyaml.wrap\n> > > new file mode 100644\n> > > index 000000000000..e4426e44774f\n> > > --- /dev/null\n> > > +++ b/subprojects/libyaml.wrap\n> > > @@ -0,0 +1,4 @@\n> > > +[wrap-git]\n> > > +directory = libyaml\n> > > +url = https://github.com/yaml/libyaml\n> > > +revision = 2c891fc7a770e8ba2fec34fc6b545c672beb37e6\n> > >\n> > > > > By the way, out of curiosity, how do you compile libcamera for Android ?\n> > > > > We have a look at Soong (as the Makefile-based build system is being\n> > > > > phased out), but blueprint files don't support all our needs (and would\n> > > > > be annoying to maintain manually), and there's no way we found to\n> > > > > generate Android.bp files from meson in a way that would integrate with\n> > > > > Soong. This is still an unsolved problem, and I'm increasingly tempted\n> > > > > to do the same as mesa3d and just document that libcamera should be\n> > > > > built outside of AOSP, using the NDK.\n> > > >\n> > > > We shipped libcamera in our GloDroid project v0.7.0 release for\n> > > > raspberry pi about a month ago:\n> > > > 1. https://github.com/GloDroid/glodroid_manifest/releases/tag/v0.7.0\n> > > > 2. https://github.com/GloDroid/glodroid_forks/commits/libcamera-v0.7.0\n> > > >\n> > > > For building using meson within AOSP we are using some tricks to\n> > > > extract dependencies from AOSP makesystem and inject them into\n> > > > meson cross compilation file.\n> > >\n> > > Does this mean that you compile libcamera manually, separately from AOSP\n> > > ? That's probably the best option for now, until Android decides to\n> > > integrate support for other build systems (likely never...).\n> >\n> > No. Building within AOSP does mean building within AOSP.\n> > Not manually.\n> > It utilizes the Kati (Android.mk) build system.\n> > And Kati is currently tightly bound to Soong, separating both would require some\n> > time for Google if they decide to do so.\n> > And we always have \"building using NDK\" as a fallback once it happens.\n> >\n> > >\n> > > > First such kind of approach was integrated into mesa3d and replaced\n> > > > existing Android.mk files (about 6 month ago).\n> > > > It doesn't require continuous maintenance as previous Android.mk did\n> > > > and has proven to be reliable.\n> > > > It also enables FULL support of mesa3d for Android. Previously only\n> > > > about 60% of mesa3d drivers were covered with Android.mk files.\n> > > > Reworking the same approach for libcamera was pretty easy.\n> > > >\n> > > > And yes, as an official approach for vendors NDK builds would be great\n> > > > to support.\n> > > > NDK approach and our meson.build within AOSP approach are 98% aligned.\n> > > >\n> > > > > > > On Tue, Dec 28, 2021 at 11:51:53AM +0200, Roman Stratiienko wrote:\n> > > > > > > > Mainline Android has no libyaml in-tree. Moreover camera_hal_config.cpp\n> > > > > > > > uses std::filesystem class that is not permitted for AOSP VNDK vendor\n> > > > > > > > libraries.\n> > > > > > > >\n> > > > > > > > External configuration file is no longer mandatory and DTS overlays can\n> > > > > > > > be used to specify camera location and rotation.\n> > > > > > > >\n> > > > > > > > Do not require external configuration file for cases where meson.build\n> > > > > > > > can't find libyaml. Assume that cameras without location specified\n> > > > > > > > by V4L2 properties are always external.\n> > > > > > > >\n> > > > > > > > Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>\n> > > > > > > > ---\n> > > > > > > >  src/android/camera_hal_manager.cpp | 13 +++++++++++++\n> > > > > > > >  src/android/camera_hal_manager.h   |  2 ++\n> > > > > > > >  src/android/meson.build            | 10 ++++++++--\n> > > > > > > >  3 files changed, 23 insertions(+), 2 deletions(-)\n> > > > > > > >\n> > > > > > > > diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp\n> > > > > > > > index 5f7bfe265c71b..9e575bfa5204a 100644\n> > > > > > > > --- a/src/android/camera_hal_manager.cpp\n> > > > > > > > +++ b/src/android/camera_hal_manager.cpp\n> > > > > > > > @@ -48,6 +48,7 @@ int CameraHalManager::init()\n> > > > > > > >  {\n> > > > > > > >       cameraManager_ = std::make_unique<CameraManager>();\n> > > > > > > >\n> > > > > > > > +#ifdef HAVE_LIBYAML\n> > > > > > > >       /*\n> > > > > > > >        * If the configuration file is not available the HAL only supports\n> > > > > > > >        * external cameras. If it exists but it's not valid then error out.\n> > > > > > > > @@ -56,6 +57,7 @@ int CameraHalManager::init()\n> > > > > > > >               LOG(HAL, Error) << \"HAL configuration file is not valid\";\n> > > > > > > >               return -EINVAL;\n> > > > > > > >       }\n> > > > > > > > +#endif\n> > > > > > > >\n> > > > > > > >       /* Support camera hotplug. */\n> > > > > > > >       cameraManager_->cameraAdded.connect(this, &CameraHalManager::cameraAdded);\n> > > > > > > > @@ -133,6 +135,7 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\n> > > > > > > >               }\n> > > > > > > >       }\n> > > > > > > >\n> > > > > > > > +#ifdef HAVE_LIBYAML\n> > > > > > > >       /*\n> > > > > > > >        * The configuration file must be valid, and contain a corresponding\n> > > > > > > >        * entry for internal cameras. External cameras can be initialized\n> > > > > > > > @@ -145,6 +148,16 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\n> > > > > > > >       }\n> > > > > > > >\n> > > > > > > >       const CameraConfigData *cameraConfigData = halConfig_.cameraConfigData(cam->id());\n> > > > > > > > +#else\n> > > > > > > > +     /*\n> > > > > > > > +      * Assume that cameras without properties::Location specified are external.\n> > > > > > > > +      */\n> > > > > > > > +     const CameraConfigData *cameraConfigData = nullptr;\n> > > > > > > > +     if (!isCameraExternal && cameraLocation(cam.get()) < 0) {\n> > > > > > > > +             isCameraExternal = true;\n> > > > > > > > +             id = nextExternalCameraId_;\n> > > > > > > > +     }\n> > > > > > > > +#endif\n> > > > > > > >\n> > > > > > > >       /*\n> > > > > > > >        * Some cameras whose location is reported by libcamera as external may\n> > > > > > > > diff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h\n> > > > > > > > index a5f8b933a7902..056abbb0d4e54 100644\n> > > > > > > > --- a/src/android/camera_hal_manager.h\n> > > > > > > > +++ b/src/android/camera_hal_manager.h\n> > > > > > > > @@ -56,7 +56,9 @@ private:\n> > > > > > > >       CameraDevice *cameraDeviceFromHalId(unsigned int id) LIBCAMERA_TSA_REQUIRES(mutex_);\n> > > > > > > >\n> > > > > > > >       std::unique_ptr<libcamera::CameraManager> cameraManager_;\n> > > > > > > > +#ifdef HAVE_LIBYAML\n> > > > > > > >       CameraHalConfig halConfig_;\n> > > > > > > > +#endif\n> > > > > > > >\n> > > > > > > >       const camera_module_callbacks_t *callbacks_;\n> > > > > > > >       std::vector<std::unique_ptr<CameraDevice>> cameras_ LIBCAMERA_TSA_GUARDED_BY(mutex_);\n> > > > > > > > diff --git a/src/android/meson.build b/src/android/meson.build\n> > > > > > > > index 75b4bf2070851..1e471c291a1e4 100644\n> > > > > > > > --- a/src/android/meson.build\n> > > > > > > > +++ b/src/android/meson.build\n> > > > > > > > @@ -3,7 +3,6 @@\n> > > > > > > >  android_deps = [\n> > > > > > > >      dependency('libexif', required : get_option('android')),\n> > > > > > > >      dependency('libjpeg', required : get_option('android')),\n> > > > > > > > -    dependency('yaml-0.1', required : get_option('android')),\n> > > > > > > >      libcamera_private,\n> > > > > > > >  ]\n> > > > > > > >\n> > > > > > > > @@ -41,7 +40,6 @@ android_hal_sources = files([\n> > > > > > > >      'camera3_hal.cpp',\n> > > > > > > >      'camera_capabilities.cpp',\n> > > > > > > >      'camera_device.cpp',\n> > > > > > > > -    'camera_hal_config.cpp',\n> > > > > > > >      'camera_hal_manager.cpp',\n> > > > > > > >      'camera_metadata.cpp',\n> > > > > > > >      'camera_ops.cpp',\n> > > > > > > > @@ -56,6 +54,14 @@ android_hal_sources = files([\n> > > > > > > >\n> > > > > > > >  android_cpp_args = []\n> > > > > > > >\n> > > > > > > > +libyaml_dep = dependency('yaml-0.1', required : false)\n> > > > > > > > +if libyaml_dep.found()\n> > > > > > > > +    config_h.set('HAVE_LIBYAML', 1)\n> > > > > > > > +    android_hal_sources += files([\n> > > > > > > > +        'camera_hal_config.cpp',\n> > > > > > > > +    ])\n> > > > > > > > +endif\n> > > > > > > > +\n> > > > > > > >  subdir('cros')\n> > > > > > > >  subdir('mm')\n> > > > > > > >","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 45299BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 29 Dec 2021 14:40:19 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B13AD60905;\n\tWed, 29 Dec 2021 15:40:18 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 20850608E9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 Dec 2021 15:40:17 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7C020464;\n\tWed, 29 Dec 2021 15:40:16 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"MlZF336i\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1640788816;\n\tbh=256qE3jWfsS6Vx6IO9JNgAVm09Jy2aqSaYbZFTfGCCo=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=MlZF336inhWRK4npRLZiYMiu8kPw5YGDQNg8Ei9irhjqiN77yvIBZsz9GiHUrTMC9\n\t+bp1z0vMSLWNffk+9Oh0SeQxMsBC/0yfwP3g2hgDSqrCaSoY2196M27sLKBCTw9z/7\n\tuFCpX+VCUCp02Zq9B8chUW4APau252ipCx9KNwtA=","Date":"Wed, 29 Dec 2021 16:40:14 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Roman Stratiienko <r.stratiienko@gmail.com>","Message-ID":"<YcxzTn9ZxDxuYQO3@pendragon.ideasonboard.com>","References":"<20211228095153.611009-1-roman.o.stratiienko@globallogic.com>\n\t<20211228110551.rxgzp77qfwpfj2n2@uno.localdomain>\n\t<CAGphcd=H0Ns5_1WL0YTsTvt9zkMCGNAaDygNcN4GXGhZfqkQMA@mail.gmail.com>\n\t<YctXI7T1elw77Rjr@pendragon.ideasonboard.com>\n\t<CAGphcd=jiw9-Cd_kYozvNVO2Q9+Mrr=eeURGJMR9+Z_kcV_BvQ@mail.gmail.com>\n\t<Ycw1FPz5Qv8wQpFr@pendragon.ideasonboard.com>\n\t<CAGphcdnYmrZR0ShYD7NiWx3XLdiBNoXzx_JgdsoOk1xwpTi8eA@mail.gmail.com>\n\t<CAGphcdkq=C6ZKD3caZk7npR+ZQvnEn4GirLfRbCeoeTmzmOx4A@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<CAGphcdkq=C6ZKD3caZk7npR+ZQvnEn4GirLfRbCeoeTmzmOx4A@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH] android: Make libyaml dependency\n\toptional","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"John Stultz <john.stultz@linaro.org>,\n\tlibcamera devel <libcamera-devel@lists.libcamera.org>,\n\tRoman Stratiienko <roman.o.stratiienko@globallogic.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":21903,"web_url":"https://patchwork.libcamera.org/comment/21903/","msgid":"<CAGphcdk_b_aig_UzXqrVodckjJ=h=eFm3uHdusV81fx7c=Gmrg@mail.gmail.com>","date":"2021-12-29T14:56:00","subject":"Re: [libcamera-devel] [PATCH] android: Make libyaml dependency\n\toptional","submitter":{"id":106,"url":"https://patchwork.libcamera.org/api/people/106/","name":"Roman Stratiienko","email":"r.stratiienko@gmail.com"},"content":"ср, 29 дек. 2021 г. в 16:37, Laurent Pinchart\n<laurent.pinchart@ideasonboard.com>:\n>\n> Hi Roman,\n>\n> On Wed, Dec 29, 2021 at 12:24:48PM +0200, Roman Stratiienko wrote:\n> > ср, 29 дек. 2021 г. в 12:14, Laurent Pinchart:\n> > > On Wed, Dec 29, 2021 at 11:45:17AM +0200, Roman Stratiienko wrote:\n> > > > вт, 28 дек. 2021 г. в 20:27, Laurent Pinchart:\n> > > > > On Tue, Dec 28, 2021 at 01:22:34PM +0200, Roman Stratiienko wrote:\n> > > > > > вт, 28 дек. 2021 г., 13:04 Jacopo Mondi:\n> > > > > > > Hi Roman,\n> > > > > > >\n> > > > > > > cc Hanlin Chen from ChromiumOS as he's planning to extend\n> > > > > > > configuration file support for the ChromeOS Android HAL.\n> > > > > >\n> > > > > > > Before looking into the patch: is there any hope libyaml might become\n> > > > > > > part of the standard AOSP distribution (or a process in place to request\n> > > > > > > that)\n> > > > > >\n> > > > > > I am not aware of that, and I haven't initiated such a process. It will be\n> > > > > > a very slow and bumpy road.\n> > > > > >\n> > > > > > Not sure what is planned for these properties in future, but now it is not\n> > > > > > necessary to have it in libcamera to have fully functional hal. Also having\n> > > > > > no configuration file available will encourage developers to add\n> > > > > > corresponding records to dts, which is also a great thing to align with\n> > > > > > linux world.\n> > > > >\n> > > > > Our goals align here. This is exactly why we have decided not to set the\n> > > > > camera location in a configuration file for the libcamera core, but to\n> > > > > isolate it in the HAL as a temporary (but in practice likely a long-term\n> > > > > temporary) measure, as we have to support platforms that will take some\n> > > > > time before a firmware (ACPI in this case) update can be deployed.\n> > > > >\n> > > > > This being said, we will introduce a configuration file for the\n> > > > > libcamera core in the near future, and we also plan to use libyaml\n> > > > > there. The tuning files for the IPU3 and RkISP1 IPA modules will also\n> > > > > use YAML, and I'd like to move the Raspberry Pi tuning files from JSON\n> > > > > to YAML for consistency.\n> > > >\n> > > > It's a good idea to have a single file format. Currently we have to\n> > > > ship boost to run raspberrypi cameras on Android.\n> > >\n> > > I'm happy you agree :-)\n> > >\n> > > > > We could merge this patch in the meantime, but compilation on Android\n> > > > > will likely break again soon. I wonder if we couldn't instead use a\n> > > > > meson wrap to include libyaml as a subproject. This should solve the\n> > > > > issue in the longer term.\n> > > >\n> > > > At this moment we have libyaml with extra Android.bp, which can\n> > > > satisfy libcamera needs.\n> > > > But I really like to see it as an optional dependency only to help\n> > > > fine-tuning things or for ACPI-only platforms.\n> > >\n> > > Making it optional may cause difficulties in the future, with\n> > > potentially lots of conditional compilation. I'd rather not go that way,\n> > > unless we can wrap the yaml parser in a helper class with a dummy\n> > > implementation to hide the missing dependency from everything else.\n> > >\n> > > I've quickly tested compiling libyaml as a subproject, and it seems to\n> > > work:\n> >\n> > I have some doubts if such an approach supports cross-compilation.\n> > Could meson generate a single ninja.build from all sub-projects?\n> > Implementing the fallback stub sounds not so bad.\n>\n> With an additional\n>\n>         libyaml_vars.append_compile_args('c', '-Wno-unused-value')\n>\n> it cross-compiles fine for ARM64.\n\nThanks. I'll try that within AOSP.\n\n> > > commit f1d86859f522c7728d8f854b82296673291750fb\n> > > Author: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > > Date:   Wed Dec 29 12:07:35 2021 +0200\n> > >\n> > >     android: Compile libyaml as a subproject if not available on the system\n> > >\n> > >     AOSP doesn't ship libyaml, making it more difficult to compile libcamera\n> > >     for Android. Use a meson wrap to compile libyaml as a subproject if the\n> > >     dependency is not found.\n> > >\n> > >     Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > >\n> > > diff --git a/src/android/meson.build b/src/android/meson.build\n> > > index 75b4bf207085..1fa67746d058 100644\n> > > --- a/src/android/meson.build\n> > > +++ b/src/android/meson.build\n> > > @@ -3,7 +3,6 @@\n> > >  android_deps = [\n> > >      dependency('libexif', required : get_option('android')),\n> > >      dependency('libjpeg', required : get_option('android')),\n> > > -    dependency('yaml-0.1', required : get_option('android')),\n> > >      libcamera_private,\n> > >  ]\n> > >\n> > > @@ -16,13 +15,35 @@ foreach dep : android_deps\n> > >      endif\n> > >  endforeach\n> > >\n> > > +cmake = import('cmake')\n> > > +\n> > > +#\n> > > +# libyaml\n> > > +#\n> > > +# Default to the system version, and fallback to a subproject if not found, as\n> > > +# libyaml is not packaged in AOSP.\n> > > +#\n> > > +libyaml_dep = dependency('yaml-0.1', required : false)\n> > > +\n> > > +# Fallback to a subproject if libyaml isn't found, as it's not packed in AOSP.\n> > > +if not libyaml_dep.found()\n> > > +    libyaml_vars = cmake.subproject_options()\n> > > +    libyaml_vars.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'})\n> > > +    libyaml = cmake.subproject('libyaml', options : libyaml_vars)\n> > > +    libyaml_dep = libyaml.dependency('yaml')\n> > > +endif\n> > > +\n> > > +android_deps += [libyaml_dep]\n> > > +\n> > > +#\n> > > +# libyuv\n> > > +#\n> > > +# Default to the system version, and fallback to a subproject if not found, as\n> > > +# libyuv is typically not provided by distributions.\n> > > +#\n> > >  libyuv_dep = dependency('libyuv', required : false)\n> > >\n> > > -# Fallback to a subproject if libyuv isn't found, as it's typically not\n> > > -# provided by distributions.\n> > >  if not libyuv_dep.found()\n> > > -    cmake = import('cmake')\n> > > -\n> > >      libyuv_vars = cmake.subproject_options()\n> > >      libyuv_vars.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'})\n> > >      libyuv_vars.set_override_option('cpp_std', 'c++17')\n> > > diff --git a/subprojects/.gitignore b/subprojects/.gitignore\n> > > index 391fde2ce1e0..f207720b271a 100644\n> > > --- a/subprojects/.gitignore\n> > > +++ b/subprojects/.gitignore\n> > > @@ -1,3 +1,4 @@\n> > >  /googletest-release*\n> > > +/libyaml\n> > >  /libyuv\n> > > -/packagecache\n> > > \\ No newline at end of file\n> > > +/packagecache\n> > > diff --git a/subprojects/libyaml.wrap b/subprojects/libyaml.wrap\n> > > new file mode 100644\n> > > index 000000000000..e4426e44774f\n> > > --- /dev/null\n> > > +++ b/subprojects/libyaml.wrap\n> > > @@ -0,0 +1,4 @@\n> > > +[wrap-git]\n> > > +directory = libyaml\n> > > +url = https://github.com/yaml/libyaml\n> > > +revision = 2c891fc7a770e8ba2fec34fc6b545c672beb37e6\n> > >\n> > > > > By the way, out of curiosity, how do you compile libcamera for Android ?\n> > > > > We have a look at Soong (as the Makefile-based build system is being\n> > > > > phased out), but blueprint files don't support all our needs (and would\n> > > > > be annoying to maintain manually), and there's no way we found to\n> > > > > generate Android.bp files from meson in a way that would integrate with\n> > > > > Soong. This is still an unsolved problem, and I'm increasingly tempted\n> > > > > to do the same as mesa3d and just document that libcamera should be\n> > > > > built outside of AOSP, using the NDK.\n> > > >\n> > > > We shipped libcamera in our GloDroid project v0.7.0 release for\n> > > > raspberry pi about a month ago:\n> > > > 1. https://github.com/GloDroid/glodroid_manifest/releases/tag/v0.7.0\n> > > > 2. https://github.com/GloDroid/glodroid_forks/commits/libcamera-v0.7.0\n> > > >\n> > > > For building using meson within AOSP we are using some tricks to\n> > > > extract dependencies from AOSP makesystem and inject them into\n> > > > meson cross compilation file.\n> > >\n> > > Does this mean that you compile libcamera manually, separately from AOSP\n> > > ? That's probably the best option for now, until Android decides to\n> > > integrate support for other build systems (likely never...).\n> >\n> > No. Building within AOSP does mean building within AOSP.\n> > Not manually.\n> > It utilizes the Kati (Android.mk) build system.\n> > And Kati is currently tightly bound to Soong, separating both would require some\n> > time for Google if they decide to do so.\n> > And we always have \"building using NDK\" as a fallback once it happens.\n>\n> I thought they had mostly finished the conversion to Soong, but I could\n> be wrong. I remember finding a page that listed the timeline and what\n> types of packages were still allowed to use Android.mk at different\n> points in the transition, but I can't locate that anymore.\n>\n> Could you point me to the sources that show how you built libcamera ?\n\n1. See link above for libcamera tree with downtree patches.\n2. https://github.com/GloDroid/glodroid_device/commit/5c258a304994e69e7257341e889953f1e728126b\n3. https://github.com/GloDroid/glodroid_device/commit/be6ba9a457c28a70f1307c69639a7caeecad0b22\n\n\n> And if it wasn't \"fun\" enough, they're moving away from Soong to Bazel\n> (https://android.googlesource.com/platform/build/bazel/+/refs/heads/master/docs/concepts.md).\n>\n> > > > First such kind of approach was integrated into mesa3d and replaced\n> > > > existing Android.mk files (about 6 month ago).\n> > > > It doesn't require continuous maintenance as previous Android.mk did\n> > > > and has proven to be reliable.\n> > > > It also enables FULL support of mesa3d for Android. Previously only\n> > > > about 60% of mesa3d drivers were covered with Android.mk files.\n> > > > Reworking the same approach for libcamera was pretty easy.\n> > > >\n> > > > And yes, as an official approach for vendors NDK builds would be great\n> > > > to support.\n> > > > NDK approach and our meson.build within AOSP approach are 98% aligned.\n> > > >\n> > > > > > > On Tue, Dec 28, 2021 at 11:51:53AM +0200, Roman Stratiienko wrote:\n> > > > > > > > Mainline Android has no libyaml in-tree. Moreover camera_hal_config.cpp\n> > > > > > > > uses std::filesystem class that is not permitted for AOSP VNDK vendor\n> > > > > > > > libraries.\n> > > > > > > >\n> > > > > > > > External configuration file is no longer mandatory and DTS overlays can\n> > > > > > > > be used to specify camera location and rotation.\n> > > > > > > >\n> > > > > > > > Do not require external configuration file for cases where meson.build\n> > > > > > > > can't find libyaml. Assume that cameras without location specified\n> > > > > > > > by V4L2 properties are always external.\n> > > > > > > >\n> > > > > > > > Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>\n> > > > > > > > ---\n> > > > > > > >  src/android/camera_hal_manager.cpp | 13 +++++++++++++\n> > > > > > > >  src/android/camera_hal_manager.h   |  2 ++\n> > > > > > > >  src/android/meson.build            | 10 ++++++++--\n> > > > > > > >  3 files changed, 23 insertions(+), 2 deletions(-)\n> > > > > > > >\n> > > > > > > > diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp\n> > > > > > > > index 5f7bfe265c71b..9e575bfa5204a 100644\n> > > > > > > > --- a/src/android/camera_hal_manager.cpp\n> > > > > > > > +++ b/src/android/camera_hal_manager.cpp\n> > > > > > > > @@ -48,6 +48,7 @@ int CameraHalManager::init()\n> > > > > > > >  {\n> > > > > > > >       cameraManager_ = std::make_unique<CameraManager>();\n> > > > > > > >\n> > > > > > > > +#ifdef HAVE_LIBYAML\n> > > > > > > >       /*\n> > > > > > > >        * If the configuration file is not available the HAL only supports\n> > > > > > > >        * external cameras. If it exists but it's not valid then error out.\n> > > > > > > > @@ -56,6 +57,7 @@ int CameraHalManager::init()\n> > > > > > > >               LOG(HAL, Error) << \"HAL configuration file is not valid\";\n> > > > > > > >               return -EINVAL;\n> > > > > > > >       }\n> > > > > > > > +#endif\n> > > > > > > >\n> > > > > > > >       /* Support camera hotplug. */\n> > > > > > > >       cameraManager_->cameraAdded.connect(this, &CameraHalManager::cameraAdded);\n> > > > > > > > @@ -133,6 +135,7 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\n> > > > > > > >               }\n> > > > > > > >       }\n> > > > > > > >\n> > > > > > > > +#ifdef HAVE_LIBYAML\n> > > > > > > >       /*\n> > > > > > > >        * The configuration file must be valid, and contain a corresponding\n> > > > > > > >        * entry for internal cameras. External cameras can be initialized\n> > > > > > > > @@ -145,6 +148,16 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\n> > > > > > > >       }\n> > > > > > > >\n> > > > > > > >       const CameraConfigData *cameraConfigData = halConfig_.cameraConfigData(cam->id());\n> > > > > > > > +#else\n> > > > > > > > +     /*\n> > > > > > > > +      * Assume that cameras without properties::Location specified are external.\n> > > > > > > > +      */\n> > > > > > > > +     const CameraConfigData *cameraConfigData = nullptr;\n> > > > > > > > +     if (!isCameraExternal && cameraLocation(cam.get()) < 0) {\n> > > > > > > > +             isCameraExternal = true;\n> > > > > > > > +             id = nextExternalCameraId_;\n> > > > > > > > +     }\n> > > > > > > > +#endif\n> > > > > > > >\n> > > > > > > >       /*\n> > > > > > > >        * Some cameras whose location is reported by libcamera as external may\n> > > > > > > > diff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h\n> > > > > > > > index a5f8b933a7902..056abbb0d4e54 100644\n> > > > > > > > --- a/src/android/camera_hal_manager.h\n> > > > > > > > +++ b/src/android/camera_hal_manager.h\n> > > > > > > > @@ -56,7 +56,9 @@ private:\n> > > > > > > >       CameraDevice *cameraDeviceFromHalId(unsigned int id) LIBCAMERA_TSA_REQUIRES(mutex_);\n> > > > > > > >\n> > > > > > > >       std::unique_ptr<libcamera::CameraManager> cameraManager_;\n> > > > > > > > +#ifdef HAVE_LIBYAML\n> > > > > > > >       CameraHalConfig halConfig_;\n> > > > > > > > +#endif\n> > > > > > > >\n> > > > > > > >       const camera_module_callbacks_t *callbacks_;\n> > > > > > > >       std::vector<std::unique_ptr<CameraDevice>> cameras_ LIBCAMERA_TSA_GUARDED_BY(mutex_);\n> > > > > > > > diff --git a/src/android/meson.build b/src/android/meson.build\n> > > > > > > > index 75b4bf2070851..1e471c291a1e4 100644\n> > > > > > > > --- a/src/android/meson.build\n> > > > > > > > +++ b/src/android/meson.build\n> > > > > > > > @@ -3,7 +3,6 @@\n> > > > > > > >  android_deps = [\n> > > > > > > >      dependency('libexif', required : get_option('android')),\n> > > > > > > >      dependency('libjpeg', required : get_option('android')),\n> > > > > > > > -    dependency('yaml-0.1', required : get_option('android')),\n> > > > > > > >      libcamera_private,\n> > > > > > > >  ]\n> > > > > > > >\n> > > > > > > > @@ -41,7 +40,6 @@ android_hal_sources = files([\n> > > > > > > >      'camera3_hal.cpp',\n> > > > > > > >      'camera_capabilities.cpp',\n> > > > > > > >      'camera_device.cpp',\n> > > > > > > > -    'camera_hal_config.cpp',\n> > > > > > > >      'camera_hal_manager.cpp',\n> > > > > > > >      'camera_metadata.cpp',\n> > > > > > > >      'camera_ops.cpp',\n> > > > > > > > @@ -56,6 +54,14 @@ android_hal_sources = files([\n> > > > > > > >\n> > > > > > > >  android_cpp_args = []\n> > > > > > > >\n> > > > > > > > +libyaml_dep = dependency('yaml-0.1', required : false)\n> > > > > > > > +if libyaml_dep.found()\n> > > > > > > > +    config_h.set('HAVE_LIBYAML', 1)\n> > > > > > > > +    android_hal_sources += files([\n> > > > > > > > +        'camera_hal_config.cpp',\n> > > > > > > > +    ])\n> > > > > > > > +endif\n> > > > > > > > +\n> > > > > > > >  subdir('cros')\n> > > > > > > >  subdir('mm')\n> > > > > > > >\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 036C2BE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 29 Dec 2021 14:56:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 602AD60911;\n\tWed, 29 Dec 2021 15:56:15 +0100 (CET)","from mail-pg1-x534.google.com (mail-pg1-x534.google.com\n\t[IPv6:2607:f8b0:4864:20::534])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 78948608E9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 Dec 2021 15:56:13 +0100 (CET)","by mail-pg1-x534.google.com with SMTP id 8so18704343pgc.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 Dec 2021 06:56:13 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"m3Vv+fja\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc:content-transfer-encoding;\n\tbh=/8++As40PhCQomuTVl0V9w1McYwTpPk+359egtwrCe4=;\n\tb=m3Vv+fjaUCL2QxXZEWRrBps/OaR1xEySO4B4KBEsknc7qiHwGbSiVKq4LnuabO5YeY\n\tMiKxSjfWbrOE9/Ani9aISHQKfwfMJV/PG2WJZqx4jG3PjxTv3qrBmjKgvijXKUwmxJEC\n\t2CRvR9QhTez115XKFTK5fVYrMf01U74Wr3d3QNvoGUzScAYbOfgPeDnuBA5X43nucrpm\n\tnMIVe0+2oRkohUX1cdNiBiLmdvA3O0Lii7qQB+NLn5AVzCZzjnUBprXnbDkfhOkH57Is\n\tKablMarYVELrH88uQrCQr1+2J3VOw8bLGb0LlyxshI4ePWVgGucxaA89wD3eVjcpiv84\n\tD8Lg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc:content-transfer-encoding;\n\tbh=/8++As40PhCQomuTVl0V9w1McYwTpPk+359egtwrCe4=;\n\tb=10KxUVoSBpUAw0II2bKRF8KB91mlY1xFTQyoAgpffoJPwuUhuECi9yUkzLdm2VL36y\n\tjrO70xzAXVlcV5vovRvEwNLLUJeZ6gKTsiIxJbE/jevcfYYlxAKcuwRl6yMFn5w8IJ3a\n\tCFNlSZY+jY+Ih7ncWscTBh+PVh94QpPqDlj1GYmsqD5wdQEaiqIQM10XDLpibImMD0FS\n\tFUAiN9/IoOMEn1N0rsWfWdISOGK67nISl4SQVY7QU/Lro+QWUyRMtrgEOWzDN4tiTNKL\n\t0zBGF6CshekfUL0yEZeq1sSnuc/AxdpD0PGtd/C/LcsM2DhFBoL/eQgJbxApvcjxlS+I\n\tGucw==","X-Gm-Message-State":"AOAM5334lwY9pPl/KgiqWC9r0zwwmWSm4guDhhk7joU3I39MZ4UL0Ci0\n\tOLXLrvjXjcuvu794QbTWD4lsnQ39iTh8FWhgAln41LgTz2I=","X-Google-Smtp-Source":"ABdhPJwlG/igNN98qeMWSGEK9ih1x+1zacsbIwPANmS9isTroY/NUYm9a3JbGCtPTRvwTJYSHkGO7E+tuCTu3JqsSkY=","X-Received":"by 2002:a63:1726:: with SMTP id\n\tx38mr23665890pgl.518.1640789771746; \n\tWed, 29 Dec 2021 06:56:11 -0800 (PST)","MIME-Version":"1.0","References":"<20211228095153.611009-1-roman.o.stratiienko@globallogic.com>\n\t<20211228110551.rxgzp77qfwpfj2n2@uno.localdomain>\n\t<CAGphcd=H0Ns5_1WL0YTsTvt9zkMCGNAaDygNcN4GXGhZfqkQMA@mail.gmail.com>\n\t<YctXI7T1elw77Rjr@pendragon.ideasonboard.com>\n\t<CAGphcd=jiw9-Cd_kYozvNVO2Q9+Mrr=eeURGJMR9+Z_kcV_BvQ@mail.gmail.com>\n\t<Ycw1FPz5Qv8wQpFr@pendragon.ideasonboard.com>\n\t<CAGphcdnYmrZR0ShYD7NiWx3XLdiBNoXzx_JgdsoOk1xwpTi8eA@mail.gmail.com>\n\t<YcxynJKZgylxKgTy@pendragon.ideasonboard.com>","In-Reply-To":"<YcxynJKZgylxKgTy@pendragon.ideasonboard.com>","From":"Roman Stratiienko <r.stratiienko@gmail.com>","Date":"Wed, 29 Dec 2021 16:56:00 +0200","Message-ID":"<CAGphcdk_b_aig_UzXqrVodckjJ=h=eFm3uHdusV81fx7c=Gmrg@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","Subject":"Re: [libcamera-devel] [PATCH] android: Make libyaml dependency\n\toptional","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>,\n\tRoman Stratiienko <roman.o.stratiienko@globallogic.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":21904,"web_url":"https://patchwork.libcamera.org/comment/21904/","msgid":"<CAGphcdnBFCj9C7hHsFhLRi4K7_sz8-zAoT8_1-kL502UsnabRQ@mail.gmail.com>","date":"2021-12-29T15:43:32","subject":"Re: [libcamera-devel] [PATCH] android: Make libyaml dependency\n\toptional","submitter":{"id":106,"url":"https://patchwork.libcamera.org/api/people/106/","name":"Roman Stratiienko","email":"r.stratiienko@gmail.com"},"content":"ср, 29 дек. 2021 г. в 16:40, Laurent Pinchart\n<laurent.pinchart@ideasonboard.com>:\n>\n> Hi Roman,\n>\n> On Wed, Dec 29, 2021 at 02:17:03PM +0200, Roman Stratiienko wrote:\n> > +CC: John Stultz\n> >\n> > Laurent,\n> >\n> > I would like to make mainline libcamera work on mainline android\n> > without additional patches / extra packages and then give it to John\n> > Stultz for testing with AOSP devboards in this shape.\n> > Unlike mesa3d libcamera doesn't have a lot of generated code,\n> > therefore shipping this code / creating Android.bp is less painful.\n>\n> How do you envision this being done ? We don't want to commit generated\n> sources to the libcamera git repository. Please note that one of the\n> source files generated during build contains a randomly generated\n> private key which is thrown away at the end of the build. Committing a\n> private key to a source tree will not be a very good idea :-)\n\nFor a couple of years, mesa3d was maintained within AOSP in the following way:\n\n1. Build mesa3d using NDK\n2. Copy all auto-generated sources from build/ directory into\n./prebuilt directory inside sources\n3. Create Android.bp , which includes sources, prebuilt sources,\ndefinitions used to build the sources by NDK.\n4. Push that into the AOSP's mesa3d/master branch.\n5. Upstream tracking branch lives at mesa3d/upstream-master without\nany modifications.\n\nThese 5 steps are a little simplified version, but overall it was like that.\n\nOf course that was not easy to maintain and delays between upgrading\nthe mesa3d version in AOSP were too big (years).\n\nPersonally I do not like this scenario, since it wastes a lot of\nengineering time. But do not see many other options at this moment for\nmainline AOSP.\n\n>\n> > In case this tricky plan will succeed and we will have libcamera\n> > inside AOSP, then rationale for adding libyaml into AOSP would be much\n> > easier to formulate.\n> >\n> > ср, 29 дек. 2021 г. в 12:24, Roman Stratiienko:\n> > > ср, 29 дек. 2021 г. в 12:14, Laurent Pinchart:\n> > > > On Wed, Dec 29, 2021 at 11:45:17AM +0200, Roman Stratiienko wrote:\n> > > > > вт, 28 дек. 2021 г. в 20:27, Laurent Pinchart:\n> > > > > > On Tue, Dec 28, 2021 at 01:22:34PM +0200, Roman Stratiienko wrote:\n> > > > > > > вт, 28 дек. 2021 г., 13:04 Jacopo Mondi:\n> > > > > > > > Hi Roman,\n> > > > > > > >\n> > > > > > > > cc Hanlin Chen from ChromiumOS as he's planning to extend\n> > > > > > > > configuration file support for the ChromeOS Android HAL.\n> > > > > > >\n> > > > > > > > Before looking into the patch: is there any hope libyaml might become\n> > > > > > > > part of the standard AOSP distribution (or a process in place to request\n> > > > > > > > that)\n> > > > > > >\n> > > > > > > I am not aware of that, and I haven't initiated such a process. It will be\n> > > > > > > a very slow and bumpy road.\n> > > > > > >\n> > > > > > > Not sure what is planned for these properties in future, but now it is not\n> > > > > > > necessary to have it in libcamera to have fully functional hal. Also having\n> > > > > > > no configuration file available will encourage developers to add\n> > > > > > > corresponding records to dts, which is also a great thing to align with\n> > > > > > > linux world.\n> > > > > >\n> > > > > > Our goals align here. This is exactly why we have decided not to set the\n> > > > > > camera location in a configuration file for the libcamera core, but to\n> > > > > > isolate it in the HAL as a temporary (but in practice likely a long-term\n> > > > > > temporary) measure, as we have to support platforms that will take some\n> > > > > > time before a firmware (ACPI in this case) update can be deployed.\n> > > > > >\n> > > > > > This being said, we will introduce a configuration file for the\n> > > > > > libcamera core in the near future, and we also plan to use libyaml\n> > > > > > there. The tuning files for the IPU3 and RkISP1 IPA modules will also\n> > > > > > use YAML, and I'd like to move the Raspberry Pi tuning files from JSON\n> > > > > > to YAML for consistency.\n> > > > >\n> > > > > It's a good idea to have a single file format. Currently we have to\n> > > > > ship boost to run raspberrypi cameras on Android.\n> > > >\n> > > > I'm happy you agree :-)\n> > > >\n> > > > > > We could merge this patch in the meantime, but compilation on Android\n> > > > > > will likely break again soon. I wonder if we couldn't instead use a\n> > > > > > meson wrap to include libyaml as a subproject. This should solve the\n> > > > > > issue in the longer term.\n> > > > >\n> > > > > At this moment we have libyaml with extra Android.bp, which can\n> > > > > satisfy libcamera needs.\n> > > > > But I really like to see it as an optional dependency only to help\n> > > > > fine-tuning things or for ACPI-only platforms.\n> > > >\n> > > > Making it optional may cause difficulties in the future, with\n> > > > potentially lots of conditional compilation. I'd rather not go that way,\n> > > > unless we can wrap the yaml parser in a helper class with a dummy\n> > > > implementation to hide the missing dependency from everything else.\n> > > >\n> > > > I've quickly tested compiling libyaml as a subproject, and it seems to\n> > > > work:\n> > > >\n> > >\n> > > I have some doubts if such an approach supports cross-compilation.\n> > > Could meson generate a single ninja.build from all sub-projects?\n> > > Implementing the fallback stub sounds not so bad.\n> > >\n> > > >\n> > > > commit f1d86859f522c7728d8f854b82296673291750fb\n> > > > Author: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > > > Date:   Wed Dec 29 12:07:35 2021 +0200\n> > > >\n> > > >     android: Compile libyaml as a subproject if not available on the system\n> > > >\n> > > >     AOSP doesn't ship libyaml, making it more difficult to compile libcamera\n> > > >     for Android. Use a meson wrap to compile libyaml as a subproject if the\n> > > >     dependency is not found.\n> > > >\n> > > >     Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > > >\n> > > > diff --git a/src/android/meson.build b/src/android/meson.build\n> > > > index 75b4bf207085..1fa67746d058 100644\n> > > > --- a/src/android/meson.build\n> > > > +++ b/src/android/meson.build\n> > > > @@ -3,7 +3,6 @@\n> > > >  android_deps = [\n> > > >      dependency('libexif', required : get_option('android')),\n> > > >      dependency('libjpeg', required : get_option('android')),\n> > > > -    dependency('yaml-0.1', required : get_option('android')),\n> > > >      libcamera_private,\n> > > >  ]\n> > > >\n> > > > @@ -16,13 +15,35 @@ foreach dep : android_deps\n> > > >      endif\n> > > >  endforeach\n> > > >\n> > > > +cmake = import('cmake')\n> > > > +\n> > > > +#\n> > > > +# libyaml\n> > > > +#\n> > > > +# Default to the system version, and fallback to a subproject if not found, as\n> > > > +# libyaml is not packaged in AOSP.\n> > > > +#\n> > > > +libyaml_dep = dependency('yaml-0.1', required : false)\n> > > > +\n> > > > +# Fallback to a subproject if libyaml isn't found, as it's not packed in AOSP.\n> > > > +if not libyaml_dep.found()\n> > > > +    libyaml_vars = cmake.subproject_options()\n> > > > +    libyaml_vars.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'})\n> > > > +    libyaml = cmake.subproject('libyaml', options : libyaml_vars)\n> > > > +    libyaml_dep = libyaml.dependency('yaml')\n> > > > +endif\n> > > > +\n> > > > +android_deps += [libyaml_dep]\n> > > > +\n> > > > +#\n> > > > +# libyuv\n> > > > +#\n> > > > +# Default to the system version, and fallback to a subproject if not found, as\n> > > > +# libyuv is typically not provided by distributions.\n> > > > +#\n> > > >  libyuv_dep = dependency('libyuv', required : false)\n> > > >\n> > > > -# Fallback to a subproject if libyuv isn't found, as it's typically not\n> > > > -# provided by distributions.\n> > > >  if not libyuv_dep.found()\n> > > > -    cmake = import('cmake')\n> > > > -\n> > > >      libyuv_vars = cmake.subproject_options()\n> > > >      libyuv_vars.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'})\n> > > >      libyuv_vars.set_override_option('cpp_std', 'c++17')\n> > > > diff --git a/subprojects/.gitignore b/subprojects/.gitignore\n> > > > index 391fde2ce1e0..f207720b271a 100644\n> > > > --- a/subprojects/.gitignore\n> > > > +++ b/subprojects/.gitignore\n> > > > @@ -1,3 +1,4 @@\n> > > >  /googletest-release*\n> > > > +/libyaml\n> > > >  /libyuv\n> > > > -/packagecache\n> > > > \\ No newline at end of file\n> > > > +/packagecache\n> > > > diff --git a/subprojects/libyaml.wrap b/subprojects/libyaml.wrap\n> > > > new file mode 100644\n> > > > index 000000000000..e4426e44774f\n> > > > --- /dev/null\n> > > > +++ b/subprojects/libyaml.wrap\n> > > > @@ -0,0 +1,4 @@\n> > > > +[wrap-git]\n> > > > +directory = libyaml\n> > > > +url = https://github.com/yaml/libyaml\n> > > > +revision = 2c891fc7a770e8ba2fec34fc6b545c672beb37e6\n> > > >\n> > > > > > By the way, out of curiosity, how do you compile libcamera for Android ?\n> > > > > > We have a look at Soong (as the Makefile-based build system is being\n> > > > > > phased out), but blueprint files don't support all our needs (and would\n> > > > > > be annoying to maintain manually), and there's no way we found to\n> > > > > > generate Android.bp files from meson in a way that would integrate with\n> > > > > > Soong. This is still an unsolved problem, and I'm increasingly tempted\n> > > > > > to do the same as mesa3d and just document that libcamera should be\n> > > > > > built outside of AOSP, using the NDK.\n> > > > >\n> > > > > We shipped libcamera in our GloDroid project v0.7.0 release for\n> > > > > raspberry pi about a month ago:\n> > > > > 1. https://github.com/GloDroid/glodroid_manifest/releases/tag/v0.7.0\n> > > > > 2. https://github.com/GloDroid/glodroid_forks/commits/libcamera-v0.7.0\n> > > > >\n> > > > > For building using meson within AOSP we are using some tricks to\n> > > > > extract dependencies from AOSP makesystem and inject them into\n> > > > > meson cross compilation file.\n> > > >\n> > > > Does this mean that you compile libcamera manually, separately from AOSP\n> > > > ? That's probably the best option for now, until Android decides to\n> > > > integrate support for other build systems (likely never...).\n> > >\n> > > No. Building within AOSP does mean building within AOSP.\n> > > Not manually.\n> > > It utilizes the Kati (Android.mk) build system.\n> > > And Kati is currently tightly bound to Soong, separating both would require some\n> > > time for Google if they decide to do so.\n> > > And we always have \"building using NDK\" as a fallback once it happens.\n> > >\n> > > >\n> > > > > First such kind of approach was integrated into mesa3d and replaced\n> > > > > existing Android.mk files (about 6 month ago).\n> > > > > It doesn't require continuous maintenance as previous Android.mk did\n> > > > > and has proven to be reliable.\n> > > > > It also enables FULL support of mesa3d for Android. Previously only\n> > > > > about 60% of mesa3d drivers were covered with Android.mk files.\n> > > > > Reworking the same approach for libcamera was pretty easy.\n> > > > >\n> > > > > And yes, as an official approach for vendors NDK builds would be great\n> > > > > to support.\n> > > > > NDK approach and our meson.build within AOSP approach are 98% aligned.\n> > > > >\n> > > > > > > > On Tue, Dec 28, 2021 at 11:51:53AM +0200, Roman Stratiienko wrote:\n> > > > > > > > > Mainline Android has no libyaml in-tree. Moreover camera_hal_config.cpp\n> > > > > > > > > uses std::filesystem class that is not permitted for AOSP VNDK vendor\n> > > > > > > > > libraries.\n> > > > > > > > >\n> > > > > > > > > External configuration file is no longer mandatory and DTS overlays can\n> > > > > > > > > be used to specify camera location and rotation.\n> > > > > > > > >\n> > > > > > > > > Do not require external configuration file for cases where meson.build\n> > > > > > > > > can't find libyaml. Assume that cameras without location specified\n> > > > > > > > > by V4L2 properties are always external.\n> > > > > > > > >\n> > > > > > > > > Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>\n> > > > > > > > > ---\n> > > > > > > > >  src/android/camera_hal_manager.cpp | 13 +++++++++++++\n> > > > > > > > >  src/android/camera_hal_manager.h   |  2 ++\n> > > > > > > > >  src/android/meson.build            | 10 ++++++++--\n> > > > > > > > >  3 files changed, 23 insertions(+), 2 deletions(-)\n> > > > > > > > >\n> > > > > > > > > diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp\n> > > > > > > > > index 5f7bfe265c71b..9e575bfa5204a 100644\n> > > > > > > > > --- a/src/android/camera_hal_manager.cpp\n> > > > > > > > > +++ b/src/android/camera_hal_manager.cpp\n> > > > > > > > > @@ -48,6 +48,7 @@ int CameraHalManager::init()\n> > > > > > > > >  {\n> > > > > > > > >       cameraManager_ = std::make_unique<CameraManager>();\n> > > > > > > > >\n> > > > > > > > > +#ifdef HAVE_LIBYAML\n> > > > > > > > >       /*\n> > > > > > > > >        * If the configuration file is not available the HAL only supports\n> > > > > > > > >        * external cameras. If it exists but it's not valid then error out.\n> > > > > > > > > @@ -56,6 +57,7 @@ int CameraHalManager::init()\n> > > > > > > > >               LOG(HAL, Error) << \"HAL configuration file is not valid\";\n> > > > > > > > >               return -EINVAL;\n> > > > > > > > >       }\n> > > > > > > > > +#endif\n> > > > > > > > >\n> > > > > > > > >       /* Support camera hotplug. */\n> > > > > > > > >       cameraManager_->cameraAdded.connect(this, &CameraHalManager::cameraAdded);\n> > > > > > > > > @@ -133,6 +135,7 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\n> > > > > > > > >               }\n> > > > > > > > >       }\n> > > > > > > > >\n> > > > > > > > > +#ifdef HAVE_LIBYAML\n> > > > > > > > >       /*\n> > > > > > > > >        * The configuration file must be valid, and contain a corresponding\n> > > > > > > > >        * entry for internal cameras. External cameras can be initialized\n> > > > > > > > > @@ -145,6 +148,16 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\n> > > > > > > > >       }\n> > > > > > > > >\n> > > > > > > > >       const CameraConfigData *cameraConfigData = halConfig_.cameraConfigData(cam->id());\n> > > > > > > > > +#else\n> > > > > > > > > +     /*\n> > > > > > > > > +      * Assume that cameras without properties::Location specified are external.\n> > > > > > > > > +      */\n> > > > > > > > > +     const CameraConfigData *cameraConfigData = nullptr;\n> > > > > > > > > +     if (!isCameraExternal && cameraLocation(cam.get()) < 0) {\n> > > > > > > > > +             isCameraExternal = true;\n> > > > > > > > > +             id = nextExternalCameraId_;\n> > > > > > > > > +     }\n> > > > > > > > > +#endif\n> > > > > > > > >\n> > > > > > > > >       /*\n> > > > > > > > >        * Some cameras whose location is reported by libcamera as external may\n> > > > > > > > > diff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h\n> > > > > > > > > index a5f8b933a7902..056abbb0d4e54 100644\n> > > > > > > > > --- a/src/android/camera_hal_manager.h\n> > > > > > > > > +++ b/src/android/camera_hal_manager.h\n> > > > > > > > > @@ -56,7 +56,9 @@ private:\n> > > > > > > > >       CameraDevice *cameraDeviceFromHalId(unsigned int id) LIBCAMERA_TSA_REQUIRES(mutex_);\n> > > > > > > > >\n> > > > > > > > >       std::unique_ptr<libcamera::CameraManager> cameraManager_;\n> > > > > > > > > +#ifdef HAVE_LIBYAML\n> > > > > > > > >       CameraHalConfig halConfig_;\n> > > > > > > > > +#endif\n> > > > > > > > >\n> > > > > > > > >       const camera_module_callbacks_t *callbacks_;\n> > > > > > > > >       std::vector<std::unique_ptr<CameraDevice>> cameras_ LIBCAMERA_TSA_GUARDED_BY(mutex_);\n> > > > > > > > > diff --git a/src/android/meson.build b/src/android/meson.build\n> > > > > > > > > index 75b4bf2070851..1e471c291a1e4 100644\n> > > > > > > > > --- a/src/android/meson.build\n> > > > > > > > > +++ b/src/android/meson.build\n> > > > > > > > > @@ -3,7 +3,6 @@\n> > > > > > > > >  android_deps = [\n> > > > > > > > >      dependency('libexif', required : get_option('android')),\n> > > > > > > > >      dependency('libjpeg', required : get_option('android')),\n> > > > > > > > > -    dependency('yaml-0.1', required : get_option('android')),\n> > > > > > > > >      libcamera_private,\n> > > > > > > > >  ]\n> > > > > > > > >\n> > > > > > > > > @@ -41,7 +40,6 @@ android_hal_sources = files([\n> > > > > > > > >      'camera3_hal.cpp',\n> > > > > > > > >      'camera_capabilities.cpp',\n> > > > > > > > >      'camera_device.cpp',\n> > > > > > > > > -    'camera_hal_config.cpp',\n> > > > > > > > >      'camera_hal_manager.cpp',\n> > > > > > > > >      'camera_metadata.cpp',\n> > > > > > > > >      'camera_ops.cpp',\n> > > > > > > > > @@ -56,6 +54,14 @@ android_hal_sources = files([\n> > > > > > > > >\n> > > > > > > > >  android_cpp_args = []\n> > > > > > > > >\n> > > > > > > > > +libyaml_dep = dependency('yaml-0.1', required : false)\n> > > > > > > > > +if libyaml_dep.found()\n> > > > > > > > > +    config_h.set('HAVE_LIBYAML', 1)\n> > > > > > > > > +    android_hal_sources += files([\n> > > > > > > > > +        'camera_hal_config.cpp',\n> > > > > > > > > +    ])\n> > > > > > > > > +endif\n> > > > > > > > > +\n> > > > > > > > >  subdir('cros')\n> > > > > > > > >  subdir('mm')\n> > > > > > > > >\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 85D59BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 29 Dec 2021 15:43:48 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B989B608EB;\n\tWed, 29 Dec 2021 16:43:47 +0100 (CET)","from mail-pg1-x530.google.com (mail-pg1-x530.google.com\n\t[IPv6:2607:f8b0:4864:20::530])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E7381608E9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 Dec 2021 16:43:45 +0100 (CET)","by mail-pg1-x530.google.com with SMTP id a23so18847713pgm.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 Dec 2021 07:43:45 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"Ycp7JG2A\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc:content-transfer-encoding;\n\tbh=YOIZ3kZD0C1pFdKpYC7qdP6bPa1bVVJ8+4dN8D+XRHU=;\n\tb=Ycp7JG2AKTArNH3RwNMxHYjEq/NWlZKbOyMnk3NemhAEhL0kswIjZPcycdVkzC2R+e\n\t64CbKXu8GniEs37FTr5tqhr59lm5v20FZFbFIkQLgIAKOhqAzReDBDQsPpye56zDezIQ\n\tpPR31MXq/Q8z0f8KpttCKxraFYatWUJps+sEVfRIM5FxaDZ7FAUib8LfDB89ES9VQ/2R\n\to6zfwoIsJQ+g6UP4/jxzEQvl72tyOnPowmIVMf+8FSgqJW9JQ+C2QpsvHHK/zkmkwB8Y\n\tlJxm5NBPYSM+fxsyLxSXzYgYx5oj1OkP2GiCH5Ace3ZE7RxLcALzUK6SGCT5y+GP+QFH\n\tNIqA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc:content-transfer-encoding;\n\tbh=YOIZ3kZD0C1pFdKpYC7qdP6bPa1bVVJ8+4dN8D+XRHU=;\n\tb=r3ib2Wq1FxUEQxwrC1vzll58OLr4N+Qt+XcBM2phCECKhMIY8oTh1nXVYWLzR6H1/z\n\tant2T2VmjuXHQ87AtC/RUntSZMD/NzMjhB/d83NGy95luTlH5awTljgi7iuZfIRyfOWF\n\t80AejiRh8w5UkeJZnBI2D8f6Ile50I9/E+4zP8BBE4TXaQWAscWu40BX3hozs023ATcC\n\tHKRgslgfZ/EAdtO0RcDngbsVz66u8nISoyqXPGRrd60WAeAEyk1edi79sLpH3xLJoV8R\n\t4+1g0wW7MvQbSw6ncfHcnUxxBbeWVmcJMEtZXakVcJ6SbkIeF46s3Ul8WSY+KW6vfqzJ\n\tctVQ==","X-Gm-Message-State":"AOAM532gYLdl/ZZXszYPll9NIougm4PLWjYE5feyhdaKWbEsBJX1Eren\n\t+FTggOoCZbRTokUVz/1U3JzM3ucnkwO8cMCanPc=","X-Google-Smtp-Source":"ABdhPJysJTM3LI4el5TJ22GeClyiHDnBBMfy/StZN/nTE11843rXWerFZFi1r5F5wr2h7I8Dk60SdUDUI7CUNdCOq6g=","X-Received":"by 2002:a65:5547:: with SMTP id\n\tt7mr24254556pgr.510.1640792624029; \n\tWed, 29 Dec 2021 07:43:44 -0800 (PST)","MIME-Version":"1.0","References":"<20211228095153.611009-1-roman.o.stratiienko@globallogic.com>\n\t<20211228110551.rxgzp77qfwpfj2n2@uno.localdomain>\n\t<CAGphcd=H0Ns5_1WL0YTsTvt9zkMCGNAaDygNcN4GXGhZfqkQMA@mail.gmail.com>\n\t<YctXI7T1elw77Rjr@pendragon.ideasonboard.com>\n\t<CAGphcd=jiw9-Cd_kYozvNVO2Q9+Mrr=eeURGJMR9+Z_kcV_BvQ@mail.gmail.com>\n\t<Ycw1FPz5Qv8wQpFr@pendragon.ideasonboard.com>\n\t<CAGphcdnYmrZR0ShYD7NiWx3XLdiBNoXzx_JgdsoOk1xwpTi8eA@mail.gmail.com>\n\t<CAGphcdkq=C6ZKD3caZk7npR+ZQvnEn4GirLfRbCeoeTmzmOx4A@mail.gmail.com>\n\t<YcxzTn9ZxDxuYQO3@pendragon.ideasonboard.com>","In-Reply-To":"<YcxzTn9ZxDxuYQO3@pendragon.ideasonboard.com>","From":"Roman Stratiienko <r.stratiienko@gmail.com>","Date":"Wed, 29 Dec 2021 17:43:32 +0200","Message-ID":"<CAGphcdnBFCj9C7hHsFhLRi4K7_sz8-zAoT8_1-kL502UsnabRQ@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","Subject":"Re: [libcamera-devel] [PATCH] android: Make libyaml dependency\n\toptional","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"John Stultz <john.stultz@linaro.org>,\n\tlibcamera devel <libcamera-devel@lists.libcamera.org>,\n\tRoman Stratiienko <roman.o.stratiienko@globallogic.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]