[libcamera-devel] [PATCH 2/3] include: aosp, cros: Pull in required headers for cros

Paul Elder paul.elder at ideasonboard.com
Thu Feb 25 11:42:16 CET 2021


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 <paul.elder at ideasonboard.com>
---
 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 <base/callback.h>
+#include <hardware/camera_common.h>
+
+#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<void(PrivacySwitchState state)>;
+
+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')
-- 
2.27.0



More information about the libcamera-devel mailing list