V4L2 HALv3 initial check in
Decent outline of an initial HALv3. Still a lot to be filled in.
Adapted from the reference implementation in libhardware.
BUG: 29006356
TEST: Ran simple test program. Connects to the HAL and then
fails because there are no cameras (expected behavior right now).
Change-Id: I11c7e00dca1bbb6ade6b5a0f55fedac3d2d01695
diff --git a/modules/camera/3_4/V4L2Camera.cpp b/modules/camera/3_4/V4L2Camera.cpp
new file mode 100644
index 0000000..1529756
--- /dev/null
+++ b/modules/camera/3_4/V4L2Camera.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "V4L2Camera.h"
+
+#include <camera/CameraMetadata.h>
+#include <hardware/camera3.h>
+
+#include "Common.h"
+
+namespace v4l2_camera_hal {
+
+V4L2Camera::V4L2Camera(int id, std::string path)
+ : default_camera_hal::Camera(id), mDevicePath(std::move(path)) {
+ HAL_LOG_ENTER();
+}
+
+V4L2Camera::~V4L2Camera() {
+ HAL_LOG_ENTER();
+}
+
+camera_metadata_t* V4L2Camera::initStaticInfo() {
+ HAL_LOG_ENTER();
+
+ android::CameraMetadata metadata(1);
+ // TODO(b/29214516): fill this in.
+ return metadata.release();
+}
+
+void V4L2Camera::initDeviceInfo(camera_info_t* info) {
+ HAL_LOG_ENTER();
+
+ // For now, just constants.
+ info->facing = CAMERA_FACING_EXTERNAL;
+ info->orientation = 0;
+ info->resource_cost = 100;
+ info->conflicting_devices = nullptr;
+ info->conflicting_devices_length = 0;
+}
+
+int V4L2Camera::initDevice() {
+ HAL_LOG_ENTER();
+
+ // TODO(b/29221795): fill in templates, etc.
+ return 0;
+}
+
+bool V4L2Camera::isValidCaptureSettings(const camera_metadata_t* settings) {
+ HAL_LOG_ENTER();
+
+ // TODO(b): reject capture settings this camera isn't capable of.
+ return true;
+}
+
+} // namespace v4l2_camera_hal