From patchwork Tue Sep 12 14:15:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mattijs Korpershoek X-Patchwork-Id: 18998 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 A17B5C32B1 for ; Tue, 12 Sep 2023 14:15:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1A69461DF5; Tue, 12 Sep 2023 16:15:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1694528132; bh=V2D/LdkmUDAfRqKMRbj+jZnhKCfUbkzuSxal8+mMbio=; 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=gJYYzGa5kbHJ9eewS96oPjplNBdIC9GXWIO/0yFu1raJP2kP8I9cKTO/kKLCeIbzn J5x/0yyw8VRe9jr0eIWx7dS8mhwJTofq65LuV28FFTgycrXleGUQwXgz1vKL+s2Qdq omdWfoxTCS0ncSowBrlmYW4CGtYqSC2RLTe32aAIkZrDRtKHAUjPlku6/rAAVPI7u2 37cEaIWBIojxusM3CLFVwu6sDJ5kD6SnL2s5mDluAS6y8AiGnY1MTHyTrtiNEVwSpJ VXDSMaWo8hW13ui6cJw68kc9Ir5C+lhbvRybun4eJ6ciKhgP/ebSiSYDs/QYuSmCxv aFKGDZJBnPtow== Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3A7BB61DEF for ; Tue, 12 Sep 2023 16:15:29 +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="1HhHpkP4"; dkim-atps=neutral Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-402c46c49f4so60873635e9.1 for ; Tue, 12 Sep 2023 07:15:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1694528129; x=1695132929; 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=jJY1PFBJgOx+4SBSKhV/AleWign/9Y/+naFBKSS16jk=; b=1HhHpkP4wm72AvHSZYE+fg8GtnSvcp7cKB1Iq0SFYsFkGPbODYzbDj2lCB4GXjBZIV IgBQ2lY2eBzPyCDjzBHkoMYHBy1SPvez7c8C7NDm5vYaRfqKuyl4KkvAvaHTZJ41N/pi YjRkm5ejPVroevx7smwWvJ3M/1NslH4reh++5M4EOIRVQD2CdfpiaoEaeIiU6TfusEhP 8KVogB07WZqLKnXflfRHXv+RdxeV3XJgfbCEncb+SQI4qMMB+5G3/wOkvq65Z1gRObTL bIfRPF0+XMX0BbXqClEtdsgtQQIe+kuJ8MBrgHmHJftVRHSiVW8n3UX37BTTNYckftAm S7vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694528129; x=1695132929; 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=jJY1PFBJgOx+4SBSKhV/AleWign/9Y/+naFBKSS16jk=; b=r1OlfWs9WVXCzNhd0TwEChg3WL0D/xoQ5qmlFT+MwylHkiLDIOz8YpECcvRBg1//+d XCg/2sCzao++qRZgIEzfohjU9HtnrWSo0x9DhI+SonHTUXsXLrzLx/mN8rownD5W7TWX 159UE7x5GF6YtUoZhxr/g0GdJWFaYEoMoa7PVHW0Wg7HK1mm85bH2y0w/qCIcQrvp3ks HWqhC9bmFl2W/x66T7IkVzrKT8gAE//EXFSNgfzFPEktaxnsKv0mWwTnaP5c9QU3ihlx CMQSpkDxIBMO6gwM1rQLXI89q2xeXrGAC53m76hejSkMdNZYJojGT6c48TIDndnzeJmd Mo9g== X-Gm-Message-State: AOJu0Yxgk5IPdr8rGJqs9KmNPwjwuJeHES0eArJdSlJZUp9GzoZwO46M fMxtiOeyZxF3cd9LR/bPeNzmRdogrpx20cHVYMo= X-Google-Smtp-Source: AGHT+IGXyOTwPQZNLcdg8NLbroYPfNuuViNxyV2Ab6mJ6wObnl7uRNc8mfHD0Y0ANPryEBuZ772v5w== X-Received: by 2002:a05:600c:5007:b0:402:f555:6523 with SMTP id n7-20020a05600c500700b00402f5556523mr11370799wmr.9.1694528128922; Tue, 12 Sep 2023 07:15:28 -0700 (PDT) Received: from [192.168.2.39] ([82.66.159.240]) by smtp.gmail.com with ESMTPSA id y9-20020a7bcd89000000b003fed630f560sm12996380wmj.36.2023.09.12.07.15.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 07:15:28 -0700 (PDT) Date: Tue, 12 Sep 2023 16:15:22 +0200 MIME-Version: 1.0 Message-Id: <20230912-gralloc-api-v4-v2-3-e859da63f98c@baylibre.com> References: <20230912-gralloc-api-v4-v2-0-e859da63f98c@baylibre.com> In-Reply-To: <20230912-gralloc-api-v4-v2-0-e859da63f98c@baylibre.com> To: libcamera-devel@lists.libcamera.org X-Mailer: b4 0.12.3 Subject: [libcamera-devel] [PATCH v2 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: 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 | 53 ++++++++++++++++++++++ src/android/mm/meson.build | 1 + 3 files changed, 54 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..814b3d0e38bd --- /dev/null +++ b/src/android/mm/graphic_buffer_allocator_stub.cpp @@ -0,0 +1,53 @@ +/* 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..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',