summaryrefslogtreecommitdiff
path: root/src/android/camera_device.h
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2019-05-10 17:40:02 +0200
committerJacopo Mondi <jacopo@jmondi.org>2019-08-12 11:55:46 +0200
commit667d8ea8fd4bda35e8888792d2b6c055fdb4be18 (patch)
tree786462c9f8dfce3d3d05d69dc8befcd67e94db07 /src/android/camera_device.h
parent6bed34da161bb8c4e86821116dcff2205e29c58a (diff)
android: hal: Add Camera3 HAL
Add libcamera Android Camera HALv3 implementation. The initial camera HAL implementation supports the LIMITED hardware level and uses statically defined metadata and camera characteristics. Add a build option named 'android' and adjust the build system to selectively compile the Android camera HAL and link it against the required Android libraries. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src/android/camera_device.h')
-rw-r--r--src/android/camera_device.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/android/camera_device.h b/src/android/camera_device.h
new file mode 100644
index 00000000..ac5b95c9
--- /dev/null
+++ b/src/android/camera_device.h
@@ -0,0 +1,71 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2019, Google Inc.
+ *
+ * camera_device.h - libcamera Android Camera Device
+ */
+#ifndef __ANDROID_CAMERA_DEVICE_H__
+#define __ANDROID_CAMERA_DEVICE_H__
+
+#include <memory>
+
+#include <hardware/camera3.h>
+
+#include <libcamera/buffer.h>
+#include <libcamera/camera.h>
+#include <libcamera/object.h>
+#include <libcamera/request.h>
+#include <libcamera/stream.h>
+
+#include "message.h"
+
+#define METADATA_ASSERT(_r) \
+ do { \
+ if (!(_r)) break; \
+ LOG(HAL, Error) << "Error: " << __func__ << ":" << __LINE__; \
+ return nullptr; \
+ } while(0);
+
+class CameraDevice : public libcamera::Object
+{
+public:
+ CameraDevice(unsigned int id, std::shared_ptr<libcamera::Camera> &camera);
+ ~CameraDevice();
+
+ void message(libcamera::Message *message);
+
+ int open();
+ void close();
+ void setCallbacks(const camera3_callback_ops_t *callbacks);
+ camera_metadata_t *getStaticMetadata();
+ const camera_metadata_t *constructDefaultRequestSettings(int type);
+ int configureStreams(camera3_stream_configuration_t *stream_list);
+ int processCaptureRequest(camera3_capture_request_t *request);
+ void requestComplete(libcamera::Request *request,
+ const std::map<libcamera::Stream *, libcamera::Buffer *> &buffers);
+
+private:
+ struct Camera3RequestDescriptor {
+ Camera3RequestDescriptor(unsigned int frameNumber,
+ unsigned int numBuffers);
+ ~Camera3RequestDescriptor();
+
+ uint32_t frameNumber;
+ uint32_t numBuffers;
+ camera3_stream_buffer_t *buffers;
+ };
+
+ void notifyShutter(uint32_t frameNumber, uint64_t timestamp);
+ void notifyError(uint32_t frameNumber, camera3_stream_t *stream);
+ camera_metadata_t *getResultMetadata(int frame_number, int64_t timestamp);
+
+ bool running_;
+ std::shared_ptr<libcamera::Camera> camera_;
+ std::unique_ptr<libcamera::CameraConfiguration> config_;
+
+ camera_metadata_t *staticMetadata_;
+ camera_metadata_t *requestTemplate_;
+ const camera3_callback_ops_t *callbacks_;
+};
+
+#endif /* __ANDROID_CAMERA_DEVICE_H__ */