From patchwork Sat Sep 23 16:23:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mattijs Korpershoek X-Patchwork-Id: 19082 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 4377FC326B for ; Sat, 23 Sep 2023 16:23:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 14DE46294D; Sat, 23 Sep 2023 18:23:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1695486225; bh=7OX63jm5dduEX5c+tg950hHKvEZVt60LzRJGFDLdW30=; h=Date:References:In-Reply-To:To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=hbRgnpFTxd+bm61BZl0JZv2dBFupkL42sR+glbBJE5JfI9aJeZj8xpSt5K6rHnM/p DIwfd+XwNn60E7uswUUfhrkKaBh1HcEstlK0/jslavpF5rbbJf6lkfDiDvJg9nQpKt T4c/OBToP607f+tiWWqBE4augxA4jvohO08nXnrIA7eKu2/elZjTQYPw2xSzHK8sFb TJym90uyUkjRHNkWso/0D0We14yrt3fU1EKMnrUNPOwkPaxyRyFm4khTnNmbVdWIbr wcSfJ3qmX8oz8oDYSbAnd/05sc9kq3PnCGmHHcHTyFIQxNB1FVUlD9rrxHiCa66lRS V+h6zpikUEx2Q== Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 04E1C62936 for ; Sat, 23 Sep 2023 18:23:41 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="0zQQEyJR"; dkim-atps=neutral Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4051fea48a8so43645385e9.2 for ; Sat, 23 Sep 2023 09:23:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1695486221; x=1696091021; darn=lists.libcamera.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=syzQyd55bfiNG/ZNBdoFgZkiR6y0jT/ireZI6tbrAfk=; b=0zQQEyJRlYEaiNH0YN4lx2zqeweTAFa0hSkyf7M3ToC+o1tzBsRN3lOJMPMLBGPlaF dZmtXIxmTJfT2mPds2DWz4uYOYJXX+uHv7k9c/K8bWieeKn4fTc29H33tMRPXRXLc5aT Dn7YL9Qlsrru2UunQPErT3AJb0eOCLezX9hYtE9aJUqO02Qt3w0E11Qq8f34gtq3wKyU DTnYKP0ZQI0F4K0tFDFPXxURTFY7XnjoyciwmPKniU82Bt6GiekFGfyvkR37mVE9rPDO kDeSBmgyrOKowA4AwsXOpqGYmbDGHwRQwL4lndoRQXvKoXmV/2hJZNcDI6R0yuM/s0b7 7jCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695486221; x=1696091021; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=syzQyd55bfiNG/ZNBdoFgZkiR6y0jT/ireZI6tbrAfk=; b=DBlfj2van4SHaiqdu9ooej2hAxW3at8RE0lr3/qssmEf/Ye73jPqEgQJmQa0KnjP+5 t0j4KqAAGlGc77Hm8DDNZCVmaMTmvv/FXA/x+vnGJZkYiaTK+chzLPsyCgM5ih7KtKhR 7L5+IC/PSw/XuWVtxHpDZLUjRQW4WgBMY/zT4NX9jIHCVCXpW8aGlI72SZhnFDgm8pbI 7+AeQRSjO/wJHPPllk3x5lnJEkOetYYLpgu+yFLSD+w5pJqyOc8lgApyP8NGH0cP7HGV DziTD8I4/HIffhC/VcNCY5wPW4eEv5FuDuiK7M2K7E4j2zHyvXEn6TZuzv9JyPnz/4HN Nsbw== X-Gm-Message-State: AOJu0YwLC626IKU0vXoNkztCCnjH/NSXM+KkxIZU66WwGq8LvKHglYSD kftf28QR30dDD4aZwd5mDzEKLg== X-Google-Smtp-Source: AGHT+IEwbKeibtjzBSmf+u9g5ZW1F0I5qpeXrRur9brQXpqrHF4x2DPRHv+qE4TUjaCMHA6Tv8D3hg== X-Received: by 2002:adf:f68a:0:b0:320:447:3bcc with SMTP id v10-20020adff68a000000b0032004473bccmr2293444wrp.51.1695486220946; Sat, 23 Sep 2023 09:23:40 -0700 (PDT) Received: from [192.168.0.39] ([2a01:e0a:324:38a0:25d4:3d10:65f9:654e]) by smtp.gmail.com with ESMTPSA id y7-20020adfd087000000b00317f70240afsm7200595wrh.27.2023.09.23.09.23.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 09:23:40 -0700 (PDT) Date: Sat, 23 Sep 2023 18:23:33 +0200 MIME-Version: 1.0 Message-Id: <20230923-gralloc-api-v4-v3-3-9a9e039284ba@baylibre.com> References: <20230923-gralloc-api-v4-v3-0-9a9e039284ba@baylibre.com> In-Reply-To: <20230923-gralloc-api-v4-v3-0-9a9e039284ba@baylibre.com> To: libcamera-devel@lists.libcamera.org X-Mailer: b4 0.12.4-dev-6aa5d Subject: [libcamera-devel] [PATCH v3 3/4] android: Stub GraphicBufferAllocator for build tests X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Mattijs Korpershoek via libcamera-devel From: Mattijs Korpershoek Reply-To: Mattijs Korpershoek Cc: Jacopo Mondi , Guillaume La Roque Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" If we want to keep building libcamera on traditional Linux systems with: -Dandroid=enabled -Dandroid_platform=generic We should stub GraphicBufferAllocator, which is not available. It's only available when building with the VNDK or when building within the AOSP tree. Also remove some deprecated methods and inclusions which are not needed for the stub class. Note: the imported headers from Android generate the -Wextra-semi warning. To avoid patching the files, a pragma has been added before inclusion. Signed-off-by: Mattijs Korpershoek Reviewed-by: Jacopo Mondi --- .../libs/ui/include/ui/GraphicBufferAllocator.h | 30 ------------ src/android/mm/graphic_buffer_allocator_stub.cpp | 54 ++++++++++++++++++++++ src/android/mm/meson.build | 7 +++ 3 files changed, 61 insertions(+), 30 deletions(-) diff --git a/include/android/frameworks/native/libs/ui/include/ui/GraphicBufferAllocator.h b/include/android/frameworks/native/libs/ui/include/ui/GraphicBufferAllocator.h index e4674d746e37..9eac5bbe8324 100644 --- a/include/android/frameworks/native/libs/ui/include/ui/GraphicBufferAllocator.h +++ b/include/android/frameworks/native/libs/ui/include/ui/GraphicBufferAllocator.h @@ -29,15 +29,10 @@ #include #include -#include -#include #include namespace android { -class GrallocAllocator; -class GraphicBufferMapper; - class GraphicBufferAllocator : public Singleton { public: @@ -52,25 +47,6 @@ public: uint64_t usage, buffer_handle_t* handle, uint32_t* stride, std::string requestorName); - /** - * Allocates and does NOT import a gralloc buffer. Buffers cannot be used until they have - * been imported. This function is for advanced use cases only. - * - * The raw native handle must be freed by calling native_handle_close() followed by - * native_handle_delete(). - */ - status_t allocateRawHandle(uint32_t w, uint32_t h, PixelFormat format, uint32_t layerCount, - uint64_t usage, buffer_handle_t* handle, uint32_t* stride, - std::string requestorName); - - /** - * DEPRECATED: GraphicBufferAllocator does not use the graphicBufferId. - */ - status_t allocate(uint32_t w, uint32_t h, PixelFormat format, - uint32_t layerCount, uint64_t usage, - buffer_handle_t* handle, uint32_t* stride, uint64_t graphicBufferId, - std::string requestorName); - status_t free(buffer_handle_t handle); uint64_t getTotalSize() const; @@ -94,15 +70,9 @@ protected: uint64_t usage, buffer_handle_t* handle, uint32_t* stride, std::string requestorName, bool importBuffer); - static Mutex sLock; - static KeyedVector sAllocList; - friend class Singleton; GraphicBufferAllocator(); ~GraphicBufferAllocator(); - - GraphicBufferMapper& mMapper; - std::unique_ptr mAllocator; }; // --------------------------------------------------------------------------- diff --git a/src/android/mm/graphic_buffer_allocator_stub.cpp b/src/android/mm/graphic_buffer_allocator_stub.cpp new file mode 100644 index 000000000000..7e412c956887 --- /dev/null +++ b/src/android/mm/graphic_buffer_allocator_stub.cpp @@ -0,0 +1,54 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* + * Copyright (C) 2023, Ideas on Board + * Copyright (C) 2023, BayLibre + * + * graphic_buffer_allocator_stub.cpp - Android GraphicBufferAllocator + * stub for compile-testing + */ + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wextra-semi" +#include +#pragma GCC diagnostic pop + +namespace android { + +ANDROID_SINGLETON_STATIC_INSTANCE(GraphicBufferAllocator) + +GraphicBufferAllocator::GraphicBufferAllocator() +{ +} + +GraphicBufferAllocator::~GraphicBufferAllocator() +{ +} + +uint64_t GraphicBufferAllocator::getTotalSize() const +{ + return 0; +} + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +status_t GraphicBufferAllocator::allocate(uint32_t width, + uint32_t height, + PixelFormat format, + uint32_t layerCount, + uint64_t usage, + buffer_handle_t *handle, + uint32_t *stride, + std::string requestorName) +{ + *handle = nullptr; + *stride = 0; + return INVALID_OPERATION; +} + +status_t GraphicBufferAllocator::free(buffer_handle_t handle) +{ + return INVALID_OPERATION; +} +#pragma GCC diagnostic pop + +} // namespace android diff --git a/src/android/mm/meson.build b/src/android/mm/meson.build index e3e0484c3720..4d1fb718e94e 100644 --- a/src/android/mm/meson.build +++ b/src/android/mm/meson.build @@ -12,6 +12,13 @@ if platform == 'generic' else android_hal_sources += files(['libhardware_stub.c']) endif + + libui = dependency('libui', required : false) + if libui.found() + android_deps += [libui] + else + android_hal_sources += files(['graphic_buffer_allocator_stub.cpp']) + endif elif platform == 'cros' android_hal_sources += files(['cros_camera_buffer.cpp', 'cros_frame_buffer_allocator.cpp'])