[{"id":27181,"web_url":"https://patchwork.libcamera.org/comment/27181/","msgid":"<874jntkfp5.fsf@baylibre.com>","date":"2023-05-30T15:21:42","subject":"Re: [libcamera-devel] [PATCH] android: mm: Stub libhardware for\n\tbuild tests","submitter":{"id":153,"url":"https://patchwork.libcamera.org/api/people/153/","name":"Mattijs Korpershoek","email":"mkorpershoek@baylibre.com"},"content":"Hi Laurent,\n\nThank you for this patch. I was about to look into this. You are making\nmy life easier :)\n\n\nOn mar., mai 30, 2023 at 17:47, Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote:\n\n> Commit 66c618f378aa (\"android: mm: generic: use\n> GRALLOC_HARDWARE_MODULE_ID\") made libhardware a required dependency for\n> the Android camera HAL on non-Chrome OS platforms. This isn't an issue\n> for real devices, as Android provides libhardware, but it prevents\n> compile-testing the camera HAL on traditional Linux systems.\n>\n> To restore the compile-test coverage, stub the libhardware function used\n> by the camera HAL when libhardware isn't found.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>\nTested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> # meson build test\n\n> ---\n>  src/android/mm/libhardware_stub.c | 17 +++++++++++++++++\n>  src/android/mm/meson.build        | 12 ++++++++----\n>  2 files changed, 25 insertions(+), 4 deletions(-)\n>  create mode 100644 src/android/mm/libhardware_stub.c\n>\n> diff --git a/src/android/mm/libhardware_stub.c b/src/android/mm/libhardware_stub.c\n> new file mode 100644\n> index 000000000000..00f15cd90cac\n> --- /dev/null\n> +++ b/src/android/mm/libhardware_stub.c\n> @@ -0,0 +1,17 @@\n> +/* SPDX-License-Identifier: Apache-2.0 */\n> +/*\n> + * Copyright (C) 2023, Ideas on Board\n> + *\n> + * libhardware_stub.c - Android libhardware stub for test compilation\n> + */\n> +\n> +#include <errno.h>\n> +\n> +#include <hardware/hardware.h>\n> +\n> +int hw_get_module(const char *id __attribute__((__unused__)),\n> +\t\t  const struct hw_module_t **module)\n> +{\n> +\t*module = NULL;\n> +\treturn -ENOTSUP;\n> +}\n> diff --git a/src/android/mm/meson.build b/src/android/mm/meson.build\n> index 85f12f910198..e3e0484c3720 100644\n> --- a/src/android/mm/meson.build\n> +++ b/src/android/mm/meson.build\n> @@ -4,10 +4,14 @@ platform = get_option('android_platform')\n>  if platform == 'generic'\n>      android_hal_sources += files(['generic_camera_buffer.cpp',\n>                                    'generic_frame_buffer_allocator.cpp'])\n> -    android_deps += [\n> -        libdl,\n> -        dependency('libhardware'),\n> -    ]\n> +    android_deps += [libdl]\n> +\n> +    libhardware = dependency('libhardware', required : false)\n> +    if libhardware.found()\n> +        android_deps += [libhardware]\n> +    else\n> +        android_hal_sources += files(['libhardware_stub.c'])\n> +    endif\n>  elif platform == 'cros'\n>      android_hal_sources += files(['cros_camera_buffer.cpp',\n>                                    'cros_frame_buffer_allocator.cpp'])\n>\n> base-commit: 76e1cb9f7176b4e7a935295d4e633ee24a0fef67\n> prerequisite-patch-id: 2e7126df41498860ace9c0cd6b1e2ed748bac2f9\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 AB923C3213\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 30 May 2023 15:21:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DC10160599;\n\tTue, 30 May 2023 17:21:46 +0200 (CEST)","from mail-ed1-x531.google.com (mail-ed1-x531.google.com\n\t[IPv6:2a00:1450:4864:20::531])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 96EF360595\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 May 2023 17:21:44 +0200 (CEST)","by mail-ed1-x531.google.com with SMTP id\n\t4fb4d7f45d1cf-5147aee9d7cso6488783a12.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 May 2023 08:21:44 -0700 (PDT)","from localhost (abordeaux-655-1-129-86.w90-5.abo.wanadoo.fr.\n\t[90.5.10.86]) by smtp.gmail.com with ESMTPSA id\n\tf19-20020a056402069300b005149461b1e0sm3583316edy.25.2023.05.30.08.21.43\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 30 May 2023 08:21:43 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1685460106;\n\tbh=L4BOW/8mdaHxKkJX055Kz5wGp60SWSyz9zZT+WHQf0E=;\n\th=To:In-Reply-To:References:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=OqcNTN6r+btDnUAUcX3a8nUmWyNFu5TWjbuCJXl+TK9p8M2/Lhdld1UspMRyp5Da5\n\tbKYS4UGLeYVeCplASFboXV+6Kq16/7rRxaKfK/C/moWZt6dKrvb3QT1j078hcyFaQ0\n\twxXG0A957hf0k2Q5cYGMXkQF79qGBFieEALIDq88E2ALhEboycdK/7Nyr3tQd94jml\n\tCPptKA0Ozutu7CM1qYv8MpweEnnTFAcDnKAGTsVeBFW10ApdHQcOAsJWoO7WoryePE\n\txWJfzUV+m2LNFDJPX+BhNOT0XS9klAIwUa1aCwrwUNpqGEYYsv4FZXzSmJUPVuLG8d\n\tNrWQyky5IqrFw==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1685460104;\n\tx=1688052104; \n\th=mime-version:message-id:date:references:in-reply-to:subject:cc:to\n\t:from:from:to:cc:subject:date:message-id:reply-to;\n\tbh=BVn5eDfiA/Zib7NaXHYqzRD0YyHG6px9q4KrhmHQ05g=;\n\tb=h+88d+0ZiG7jLga4L3vkxPz0KqQDCzfFNWiJeRYXVCBGajR8q3yFOho9KtHy9OXDj5\n\ttFYoYAivkmUK8m/SDh3u7kXv6oEihUMRv+Mw5LkI8aYliKeS1BzFtL36bWhDHapb+KFH\n\t1WsasOEio03Ne/ocRicPV0hIMV1jSYHuB3HGbzxp5NgxmIYUp3dCgO6Eqr4IGypba5tX\n\tCEuk3nL0e+dAI75FGbhudWmJf1kicuJVn4iQTOkJjq7h1aCHVxUmjF8v6csjSGYOStPA\n\tPoJL2Q8L7wD2YGZXREUNiS6CG1WJnf02kKJcIRrv0dCBwOo50QvYixIFajq3ab7ECVsg\n\tBtrQ=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=baylibre-com.20221208.gappssmtp.com\n\theader.i=@baylibre-com.20221208.gappssmtp.com header.b=\"h+88d+0Z\"; \n\tdkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20221208; t=1685460104; x=1688052104;\n\th=mime-version:message-id:date:references:in-reply-to:subject:cc:to\n\t:from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; \n\tbh=BVn5eDfiA/Zib7NaXHYqzRD0YyHG6px9q4KrhmHQ05g=;\n\tb=Yi5n3v1Wy0xGu6F23M5pYbmEVOyHIXhIrGVo9pho+janvK4Zkv9cM+4iNi0j/Ravq5\n\ty9AHkc0lA0SdLpl4OZiRg+mDEBBF+1bSTlilenmJrD9NsQ1y74C7bQdoxbxO10ST4zjA\n\t5F+1aEK7H+OwxOElm/LkuvCUJz+Nf9EKJkZaJkgpF2Xjh7CTCBbAuc5eAalhfQKIERF7\n\t3XJg72stfFFPf4Nkbp5fZ3zLNBIP0CgrFqIDJY35CXmhZoJkkWH83iCeCTkonNn96scH\n\tN9nDwE2TrFCttwaYr74ZHHMFInrt3H/G2SjgwR/uzG81FmM3omNMsky66wbz3m7JSqjL\n\tIO9A==","X-Gm-Message-State":"AC+VfDwThies+QsDPWsbo90qMOM1vvG1X4bkm7DG7kidSdc5bcOWWw7y\n\t9dE7+8LXmNinzjIpE+8hW+3uIw==","X-Google-Smtp-Source":"ACHHUZ5nWn1HGraBK4TG5vHWH2kP2kdLc4hfM0LNIGyIsyHX0xMQFCn1MXHrlbnbkF+7MdI3F4Phmw==","X-Received":"by 2002:a05:6402:7d3:b0:50b:81bf:9e4f with SMTP id\n\tu19-20020a05640207d300b0050b81bf9e4fmr1769210edy.12.1685460104036; \n\tTue, 30 May 2023 08:21:44 -0700 (PDT)","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","In-Reply-To":"<20230530144719.2711-1-laurent.pinchart@ideasonboard.com>","References":"<20230530144719.2711-1-laurent.pinchart@ideasonboard.com>","Date":"Tue, 30 May 2023 17:21:42 +0200","Message-ID":"<874jntkfp5.fsf@baylibre.com>","MIME-Version":"1.0","Content-Type":"text/plain","Subject":"Re: [libcamera-devel] [PATCH] android: mm: Stub libhardware for\n\tbuild tests","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>","From":"Mattijs Korpershoek via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Mattijs Korpershoek <mkorpershoek@baylibre.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":27182,"web_url":"https://patchwork.libcamera.org/comment/27182/","msgid":"<168546012306.1107811.5776091739615817660@Monstersaurus>","date":"2023-05-30T15:22:03","subject":"Re: [libcamera-devel] [PATCH] android: mm: Stub libhardware for\n\tbuild tests","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2023-05-30 15:47:19)\n> Commit 66c618f378aa (\"android: mm: generic: use\n> GRALLOC_HARDWARE_MODULE_ID\") made libhardware a required dependency for\n> the Android camera HAL on non-Chrome OS platforms. This isn't an issue\n> for real devices, as Android provides libhardware, but it prevents\n> compile-testing the camera HAL on traditional Linux systems.\n> \n> To restore the compile-test coverage, stub the libhardware function used\n> by the camera HAL when libhardware isn't found.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  src/android/mm/libhardware_stub.c | 17 +++++++++++++++++\n>  src/android/mm/meson.build        | 12 ++++++++----\n>  2 files changed, 25 insertions(+), 4 deletions(-)\n>  create mode 100644 src/android/mm/libhardware_stub.c\n> \n> diff --git a/src/android/mm/libhardware_stub.c b/src/android/mm/libhardware_stub.c\n> new file mode 100644\n> index 000000000000..00f15cd90cac\n> --- /dev/null\n> +++ b/src/android/mm/libhardware_stub.c\n> @@ -0,0 +1,17 @@\n> +/* SPDX-License-Identifier: Apache-2.0 */\n> +/*\n> + * Copyright (C) 2023, Ideas on Board\n> + *\n> + * libhardware_stub.c - Android libhardware stub for test compilation\n> + */\n> +\n> +#include <errno.h>\n> +\n> +#include <hardware/hardware.h>\n> +\n> +int hw_get_module(const char *id __attribute__((__unused__)),\n> +                 const struct hw_module_t **module)\n> +{\n> +       *module = NULL;\n> +       return -ENOTSUP;\n> +}\n> diff --git a/src/android/mm/meson.build b/src/android/mm/meson.build\n> index 85f12f910198..e3e0484c3720 100644\n> --- a/src/android/mm/meson.build\n> +++ b/src/android/mm/meson.build\n> @@ -4,10 +4,14 @@ platform = get_option('android_platform')\n>  if platform == 'generic'\n>      android_hal_sources += files(['generic_camera_buffer.cpp',\n>                                    'generic_frame_buffer_allocator.cpp'])\n> -    android_deps += [\n> -        libdl,\n> -        dependency('libhardware'),\n> -    ]\n> +    android_deps += [libdl]\n> +\n> +    libhardware = dependency('libhardware', required : false)\n> +    if libhardware.found()\n> +        android_deps += [libhardware]\n> +    else\n> +        android_hal_sources += files(['libhardware_stub.c'])\n> +    endif\n\nLGTM,\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n>  elif platform == 'cros'\n>      android_hal_sources += files(['cros_camera_buffer.cpp',\n>                                    'cros_frame_buffer_allocator.cpp'])\n> \n> base-commit: 76e1cb9f7176b4e7a935295d4e633ee24a0fef67\n> prerequisite-patch-id: 2e7126df41498860ace9c0cd6b1e2ed748bac2f9\n> -- \n> Regards,\n> \n> Laurent Pinchart\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 C5665C31E9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 30 May 2023 15:22:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 778C862720;\n\tTue, 30 May 2023 17:22:07 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C856260595\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 May 2023 17:22:05 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net\n\t[82.37.23.78])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DFF967F3;\n\tTue, 30 May 2023 17:21:44 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1685460127;\n\tbh=E5id7XtKpSqaZFI7WQ9+XeGHP7jpKrTQxVi73Jiyfeo=;\n\th=In-Reply-To:References:To:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=YBnRHjett7naSkhF8rE1rO5lvRfzRTxIRsXsXlYvrTK8DBghKXvBpDlnNmxJu2rMH\n\thus8a4LL5ZTxxBmPxlxjUCIwQvhXILO8Rt1ATO60zBZd/fzd+ogsIKbvpUW4HpbI4l\n\tBOKwBTVLV5TMDM1C0smLXPmkNFS/GENEgETW4noo2dLVfdfjtnJ7TwDl4S9Ct20DBC\n\thpGddACCGjdn8eJ+bl2J2eTVzS3ZAGKuvtKah3Xe2dpB0hmmZNpJesJ5Nwp9Jsg+Nl\n\t1VH5VcMDXIeskvRT9s5UlcXvsOvCKbeUQ9GqElTx3iJLe14c4JvdoNZhqqKS+8jWTL\n\tpsIH399pvvzng==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1685460105;\n\tbh=E5id7XtKpSqaZFI7WQ9+XeGHP7jpKrTQxVi73Jiyfeo=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=Sm/Orw96y0EldYocZ8M1tjzBXo8t4eeqi+vyxwRuLwk8VBhfX1HQ5r/dmAOGkUlg6\n\tgcTVMGZOBpm+GURNd+d5n9jhWC11ar1x87ifcQlWI/HTVvJq1E6RBItTTq7nGSLVyl\n\tmHmEUxIooCg89rUNaFWZXwEAAhTb6pdUPJyX0pAg="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"Sm/Orw96\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20230530144719.2711-1-laurent.pinchart@ideasonboard.com>","References":"<20230530144719.2711-1-laurent.pinchart@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Tue, 30 May 2023 16:22:03 +0100","Message-ID":"<168546012306.1107811.5776091739615817660@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH] android: mm: Stub libhardware for\n\tbuild tests","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>","From":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]