From patchwork Tue Sep 12 09:36:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mattijs Korpershoek X-Patchwork-Id: 18987 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 172F3C32B1 for ; Tue, 12 Sep 2023 09:36:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3A722628FD; Tue, 12 Sep 2023 11:36:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1694511384; bh=+3dnsNjsMSU2OFhFNq6MlkaSCcQjIWhSpmvXdSKm+fE=; h=Date:References:In-Reply-To:To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=a/iDAztnGS+aCzz6DFC9k6XdrBAcc+/lMDxlXD0zIIRUcOhwQNKYwINvNqLvAq9q5 wpqIVncquZg9LM1YxRxyCqheLS9QWolao/DMp0wyza0cA7OyABP8rCdX+cF4gYDSHu Y5vyaBKVgCCnZrYij2agva0NvcT6IE9yK6UufmZ5CU33gWWXPBDWrcT+/6A+HanJ6C 4Yc7LR0L2AMNTcg3quXhY1PhuGI6fOjEdEizQtcdmfRnndZIqm//hsXp6JiZ9zuIEm H/2B0uy0zRM/Q5B+b4k6PTyqKCneej9Rxn0aW6PD7JlAaVdYpDdDLGkXDbAvOZPbcG hNDYXZaALd7KQ== Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CB680628ED for ; Tue, 12 Sep 2023 11:36:20 +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="13nRBv14"; dkim-atps=neutral Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-401bdff4cb4so57772895e9.3 for ; Tue, 12 Sep 2023 02:36:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1694511380; x=1695116180; 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=NpLe2ktemPeEsIRO+V+DPbMtVuaE1wO2VAeNe9UlQtU=; b=13nRBv14ZL2kBeJGMcH/70jGwctAnHuqGzJ/x6y/Zfhh5dogNNRFZIb1HaUz6P34F9 FPM0yHiTdsX1cYcmP6OP65uth/X5HEs9oAZzeVCjH05iyQcqDey7TvpPJJJnb+G39JbR ryUs0Sg2VtiWKJBfZ0YhebLCcRq+Tovx0pOIyDNs47KEY6GCr8hxtTZHk8Owwcgqgptb 2DKjzOuZQiwWEK23O+QD8CvjGt/cPNfqS3ShJEai+mEIv0WR0RnFC7E3tn4vLjCT8bQ4 c8VjhmEBdxh87yKDP6271TWiHWzxd//BNchApMqHRgFz5+SpW8MaNAHEJ02XUVlUPcJn h6bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694511380; x=1695116180; 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=NpLe2ktemPeEsIRO+V+DPbMtVuaE1wO2VAeNe9UlQtU=; b=edMWM7jI+6o/PO/Sv2dfPhoPrJRpKDxcvjOctDKjX/A4o9bYQF9G5Np8BOgeT5pvV6 kiZ8Yom3u+UsUP+95KgA+YhMrQzCT/8SiEGiA8Koe6yvhVIzlqcl9fp0HnYN1aDPU0fB iKOJCwiELfif1k1pYM/E7qiCwUvF10B0gz0UMeHLYatY4MJDd80xRw9DuW5PhKa2sRrH rYc2I40V5Y6Ivl56+UMXhbpZrYHuat2BxfNUaIC7oFVIjBBCI1AZyHAQLey0Vetp2YuZ 8YUgstJwZPg+YZ//LeX0SLgbYZKjdkJoo/zGlWY92jU0+BmeEdyy3Lzeo4ZPxpIq4XoU QyPg== X-Gm-Message-State: AOJu0YzYQNQzoIeqyMdirqYMxf83VPcH359wO3v9t7Gg5nYznRsi+aB8 KjmqoPDhTO0y6HeLJEy8INDq/Q== X-Google-Smtp-Source: AGHT+IGLszgiohfb4x3SNnZ7+oYKv52n4jVDR5imDmZ6UzN1BMudTCuEB/lGKmEPSXQ0lzZfT/l8NQ== X-Received: by 2002:a7b:cd82:0:b0:401:b6f6:d8fd with SMTP id y2-20020a7bcd82000000b00401b6f6d8fdmr10834831wmj.6.1694511380535; Tue, 12 Sep 2023 02:36:20 -0700 (PDT) Received: from [192.168.2.39] ([82.66.159.240]) by smtp.gmail.com with ESMTPSA id y10-20020a05600c364a00b00401b242e2e6sm15578253wmq.47.2023.09.12.02.36.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 02:36:20 -0700 (PDT) Date: Tue, 12 Sep 2023 11:36:12 +0200 MIME-Version: 1.0 Message-Id: <20230912-gralloc-api-v4-v1-3-0f80402d8e7a@baylibre.com> References: <20230912-gralloc-api-v4-v1-0-0f80402d8e7a@baylibre.com> In-Reply-To: <20230912-gralloc-api-v4-v1-0-0f80402d8e7a@baylibre.com> To: libcamera-devel@lists.libcamera.org X-Mailer: b4 0.12.3 Subject: [libcamera-devel] [PATCH 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 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. Signed-off-by: Mattijs Korpershoek --- .../libs/ui/include/ui/GraphicBufferAllocator.h | 30 ------------- src/android/mm/graphic_buffer_allocator_stub.cpp | 50 ++++++++++++++++++++++ src/android/mm/meson.build | 1 + 3 files changed, 51 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..4e2eab5754e7 --- /dev/null +++ b/src/android/mm/graphic_buffer_allocator_stub.cpp @@ -0,0 +1,50 @@ +/* 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 + */ + +#include + +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..e9ceb3afba67 100644 --- a/src/android/mm/meson.build +++ b/src/android/mm/meson.build @@ -11,6 +11,7 @@ if platform == 'generic' android_deps += [libhardware] else android_hal_sources += files(['libhardware_stub.c']) + android_hal_sources += files(['graphic_buffer_allocator_stub.cpp']) endif elif platform == 'cros' android_hal_sources += files(['cros_camera_buffer.cpp',