From patchwork Thu Feb 25 10:42:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 11376 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 CA77BBD1F1 for ; Thu, 25 Feb 2021 10:42:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 937EB68A48; Thu, 25 Feb 2021 11:42:29 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ki/Anbmp"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B089B60106 for ; Thu, 25 Feb 2021 11:42:28 +0100 (CET) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 43C7E58E; Thu, 25 Feb 2021 11:42:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1614249748; bh=yawJSHkI5tjxhkQXyk3AQ2+SoITFZHBkojbSO/a2okA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ki/AnbmpMV/Ry4+VqMveilZDBr5krSS1hfgaU+lFoihlYVEaWqrj5A8O4VYypWO7c 8El0s6eZtHwfdXySP1BzldjBIDkiyjUe1KB9vO9KcBrKUuyjuNi/tsWReN2LQ7+rTb 12DK6NZ/ARUUutjBif4/A1hll8qNNAvf0muCrWYQ= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Thu, 25 Feb 2021 19:42:15 +0900 Message-Id: <20210225104217.108792-2-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210225104217.108792-1-paul.elder@ideasonboard.com> References: <20210225104217.108792-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/3] meson: Add cros build option 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a cros build option to prepare for adding the symbols required for the new cros camera API. Signed-off-by: Paul Elder --- meson_options.txt | 5 +++++ src/android/meson.build | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/meson_options.txt b/meson_options.txt index 53f2675e..22efb323 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -5,6 +5,11 @@ option('android', value : 'disabled', description : 'Compile libcamera with Android Camera3 HAL interface') +option('cros', + type : 'boolean', + value : 'false', + description : 'Compile libcamera with the cros Camera3 HAL interface (depends on android option)') + option('documentation', type : 'feature', description : 'Generate the project documentation') diff --git a/src/android/meson.build b/src/android/meson.build index 9719c42b..a13ce63b 100644 --- a/src/android/meson.build +++ b/src/android/meson.build @@ -37,6 +37,11 @@ if android_enabled android_deps += [libyuv_dep] endif +if get_option('cros') and not android_enabled + warning('cros option enabled but android is not, cros option will be ignored') +endif +cros_enabled = get_option('cros') and android_enabled + android_hal_sources = files([ 'camera3_hal.cpp', 'camera_hal_manager.cpp', From patchwork Thu Feb 25 10:42:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 11377 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 28655BD1F1 for ; Thu, 25 Feb 2021 10:42:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E847D68A4B; Thu, 25 Feb 2021 11:42:31 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="FE8ZaToY"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8B62D60106 for ; Thu, 25 Feb 2021 11:42:30 +0100 (CET) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2517E8AD; Thu, 25 Feb 2021 11:42:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1614249750; bh=2f59zvma7YxL8/8pTKajAgoatFQn9/IxaemdCOwxzt0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FE8ZaToYZ4e6bBVLANqTWjNdS9LgELdnQDhYUp3MvpyqCvctA8S8ssqlrsY5KVFo0 ApbeyS1Y8QGOEfpUP7cRbr/p7Dt5qGDjgShsAvLRqaAiavPGqElIRTfEqWpw5Kt8pJ 8tMp6AfHmSnzWW15iag2EhQYgJ/xi/F6D2d3NP40= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Thu, 25 Feb 2021 19:42:16 +0900 Message-Id: <20210225104217.108792-3-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210225104217.108792-1-paul.elder@ideasonboard.com> References: <20210225104217.108792-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/3] include: aosp, cros: Pull in required headers for cros 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add include directories for cros, and pull in the required headers for supporting the new cros camera API. Also add an include directory for aosp, as there is one file that is required that is difficult to include otherwise. Signed-off-by: Paul Elder --- include/aosp/gtest/gtest_prod.h | 61 ++++++++++++++ .../camera_mojo_channel_manager_token.h | 22 ++++++ include/cros/cros-camera/cros_camera_hal.h | 79 +++++++++++++++++++ include/cros/cros-camera/export.h | 11 +++ include/meson.build | 5 ++ 5 files changed, 178 insertions(+) create mode 100644 include/aosp/gtest/gtest_prod.h create mode 100644 include/cros/cros-camera/camera_mojo_channel_manager_token.h create mode 100644 include/cros/cros-camera/cros_camera_hal.h create mode 100644 include/cros/cros-camera/export.h diff --git a/include/aosp/gtest/gtest_prod.h b/include/aosp/gtest/gtest_prod.h new file mode 100644 index 00000000..e651671e --- /dev/null +++ b/include/aosp/gtest/gtest_prod.h @@ -0,0 +1,61 @@ +// Copyright 2006, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// +// Google C++ Testing and Mocking Framework definitions useful in production code. +// GOOGLETEST_CM0003 DO NOT DELETE + +#ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_ +#define GTEST_INCLUDE_GTEST_GTEST_PROD_H_ + +// When you need to test the private or protected members of a class, +// use the FRIEND_TEST macro to declare your tests as friends of the +// class. For example: +// +// class MyClass { +// private: +// void PrivateMethod(); +// FRIEND_TEST(MyClassTest, PrivateMethodWorks); +// }; +// +// class MyClassTest : public testing::Test { +// // ... +// }; +// +// TEST_F(MyClassTest, PrivateMethodWorks) { +// // Can call MyClass::PrivateMethod() here. +// } +// +// Note: The test class must be in the same namespace as the class being tested. +// For example, putting MyClassTest in an anonymous namespace will not work. + +#define FRIEND_TEST(test_case_name, test_name)\ +friend class test_case_name##_##test_name##_Test + +#endif // GTEST_INCLUDE_GTEST_GTEST_PROD_H_ diff --git a/include/cros/cros-camera/camera_mojo_channel_manager_token.h b/include/cros/cros-camera/camera_mojo_channel_manager_token.h new file mode 100644 index 00000000..9da4b797 --- /dev/null +++ b/include/cros/cros-camera/camera_mojo_channel_manager_token.h @@ -0,0 +1,22 @@ +/* + * Copyright 2020 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef CAMERA_INCLUDE_CROS_CAMERA_CAMERA_MOJO_CHANNEL_MANAGER_TOKEN_H_ +#define CAMERA_INCLUDE_CROS_CAMERA_CAMERA_MOJO_CHANNEL_MANAGER_TOKEN_H_ + +#include "cros-camera/export.h" + +namespace cros { + +class CROS_CAMERA_EXPORT CameraMojoChannelManagerToken { + public: + static CameraMojoChannelManagerToken* CreateInstance(); + virtual ~CameraMojoChannelManagerToken() {} +}; + +} // namespace cros + +#endif // CAMERA_INCLUDE_CROS_CAMERA_CAMERA_MOJO_CHANNEL_MANAGER_TOKEN_H_ diff --git a/include/cros/cros-camera/cros_camera_hal.h b/include/cros/cros-camera/cros_camera_hal.h new file mode 100644 index 00000000..d445a2e8 --- /dev/null +++ b/include/cros/cros-camera/cros_camera_hal.h @@ -0,0 +1,79 @@ +/* + * Copyright 2020 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef CAMERA_INCLUDE_CROS_CAMERA_CROS_CAMERA_HAL_H_ +#define CAMERA_INCLUDE_CROS_CAMERA_CROS_CAMERA_HAL_H_ + +#define CROS_CAMERA_HAL_INFO_SYM CCHI +#define CROS_CAMERA_HAL_INFO_SYM_AS_STR "CCHI" + +#include +#include + +#include "cros-camera/camera_mojo_channel_manager_token.h" + +namespace cros { + +enum class PrivacySwitchState { + kUnknown, + kOn, + kOff, +}; + +// Synced with CameraClientType in cros_camera_service.mojom. +enum class ClientType { + kUnknown = 0, + kTesting = 1, + kChrome = 2, + kAndroid = 3, + kPluginVm = 4, + kAshChrome = 5, + kLacrosChrome = 6 +}; + +using PrivacySwitchStateChangeCallback = + base::RepeatingCallback; + +typedef struct cros_camera_hal { + /** + * Sets up the camera HAL. The |token| can be used for communication through + * Mojo. + */ + void (*set_up)(CameraMojoChannelManagerToken* token); + + /** + * Tears down the camera HAL. + */ + void (*tear_down)(); + + /** + * Registers camera privacy switch observer. + */ + void (*set_privacy_switch_callback)( + PrivacySwitchStateChangeCallback callback); + + /** + * Open the camera device by client type. + */ + int (*camera_device_open_ext)(const hw_module_t* module, + const char* name, + hw_device_t** device, + ClientType client_type); + + /** + * Gets the camera info by client type. + */ + int (*get_camera_info_ext)(int id, + struct camera_info* info, + ClientType client_type); + + /* reserved for future use */ + void* reserved[4]; +} cros_camera_hal_t; + +} // namespace cros + +#endif // CAMERA_INCLUDE_CROS_CAMERA_CROS_CAMERA_HAL_H_ diff --git a/include/cros/cros-camera/export.h b/include/cros/cros-camera/export.h new file mode 100644 index 00000000..67353e63 --- /dev/null +++ b/include/cros/cros-camera/export.h @@ -0,0 +1,11 @@ +/* Copyright 2018 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef CAMERA_INCLUDE_CROS_CAMERA_EXPORT_H_ +#define CAMERA_INCLUDE_CROS_CAMERA_EXPORT_H_ + +#define CROS_CAMERA_EXPORT __attribute__((visibility("default"))) + +#endif // CAMERA_INCLUDE_CROS_CAMERA_EXPORT_H_ diff --git a/include/meson.build b/include/meson.build index 2ac9a3a0..6f2e6cec 100644 --- a/include/meson.build +++ b/include/meson.build @@ -2,5 +2,10 @@ libcamera_include_dir = 'libcamera' +cros_includes = ([ + include_directories('aosp'), + include_directories('cros') +]) + subdir('android') subdir('libcamera') From patchwork Thu Feb 25 10:42:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 11378 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 B1AF0BD1F1 for ; Thu, 25 Feb 2021 10:42:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7FA6B68A51; Thu, 25 Feb 2021 11:42:34 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="VxODHMTv"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E186A68A3F for ; Thu, 25 Feb 2021 11:42:32 +0100 (CET) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id F2BF058E; Thu, 25 Feb 2021 11:42:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1614249752; bh=ERxrHaqfzX4hVm/VZIEgRUDP3yD7A3bongyaX2Khpd8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VxODHMTvHwdiTgHqjeswf5eN1062Q2d7o6ZXGTdhIyoxlW8EhBcVl52l6RUJ3UsrE li7sxsdGGdNdFP56CU+AlmZgD8O4c9mABvUFOtfPaL0KKYELFbjYhAy4q0Mugqf8HI aU9FJmIJqR4fP+j3GCf9BaN3qHNEamT1gof2L134= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Thu, 25 Feb 2021 19:42:17 +0900 Message-Id: <20210225104217.108792-4-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210225104217.108792-1-paul.elder@ideasonboard.com> References: <20210225104217.108792-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/3] cros: Support the new cros camera API with set_up and tear_down 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Implement and expose the symbol and functions that the new cros camera API requires. Since we don't actually need them, leave them empty. Signed-off-by: Paul Elder --- src/cros/camera3_hal.cpp | 21 +++++++++++++++++++++ src/cros/meson.build | 16 ++++++++++++++++ src/libcamera/meson.build | 6 ++++++ src/meson.build | 4 ++++ 4 files changed, 47 insertions(+) create mode 100644 src/cros/camera3_hal.cpp create mode 100644 src/cros/meson.build diff --git a/src/cros/camera3_hal.cpp b/src/cros/camera3_hal.cpp new file mode 100644 index 00000000..31ad36ac --- /dev/null +++ b/src/cros/camera3_hal.cpp @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021, Google Inc. + * + * camera3_hal.cpp - cros-specific components of Android Camera HALv3 module + */ + +#include + +static void set_up(cros::CameraMojoChannelManagerToken *token) +{ +} + +static void tear_down() +{ +} + +cros::cros_camera_hal_t CROS_CAMERA_EXPORT CROS_CAMERA_HAL_INFO_SYM = { + .set_up = set_up, + .tear_down = tear_down +}; diff --git a/src/cros/meson.build b/src/cros/meson.build new file mode 100644 index 00000000..31aa58c9 --- /dev/null +++ b/src/cros/meson.build @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: CC0-1.0 + +cros_hal_include_dir = '/mnt/host/source/src/aosp/external/libchrome' + +cros_hal_info_sources = files([ + 'camera3_hal.cpp', +]) + +cros_hal_info = static_library('cros_hal_info', + cros_hal_info_sources, + c_args : '-Wno-shadow', + include_directories : [cros_includes, + cros_hal_include_dir, + android_includes]) + +cros_hal_info_obj = cros_hal_info.extract_objects('camera3_hal.cpp') diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index 4b5e33ce..c40eb41f 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -139,6 +139,11 @@ if android_enabled libcamera_deps += android_deps endif +libcamera_objects = [] +if cros_enabled + libcamera_objects += cros_hal_info_obj +endif + # We add '/' to the build_rpath as a 'safe' path to act as a boolean flag. # The build_rpath is stripped at install time by meson, so we determine at # runtime if the library is running from an installed location by checking @@ -149,6 +154,7 @@ libcamera = shared_library('camera', install : true, link_with : libcamera_link_with, include_directories : includes, + objects : libcamera_objects, build_rpath : '/', dependencies : libcamera_deps) diff --git a/src/meson.build b/src/meson.build index 0b26ca70..ec85cc47 100644 --- a/src/meson.build +++ b/src/meson.build @@ -15,6 +15,10 @@ endif # are included directly into the libcamera library when this is enabled. subdir('android') +if cros_enabled + subdir('cros') +endif + subdir('libcamera') subdir('ipa')