Ari Hausman-Cohen | 7344215 | 2016-06-08 15:50:49 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "V4L2Camera.h" |
| 18 | |
| 19 | #include <camera/CameraMetadata.h> |
| 20 | #include <hardware/camera3.h> |
| 21 | |
| 22 | #include "Common.h" |
| 23 | |
| 24 | namespace v4l2_camera_hal { |
| 25 | |
| 26 | V4L2Camera::V4L2Camera(int id, std::string path) |
| 27 | : default_camera_hal::Camera(id), mDevicePath(std::move(path)) { |
| 28 | HAL_LOG_ENTER(); |
| 29 | } |
| 30 | |
| 31 | V4L2Camera::~V4L2Camera() { |
| 32 | HAL_LOG_ENTER(); |
| 33 | } |
| 34 | |
| 35 | camera_metadata_t* V4L2Camera::initStaticInfo() { |
| 36 | HAL_LOG_ENTER(); |
| 37 | |
| 38 | android::CameraMetadata metadata(1); |
| 39 | // TODO(b/29214516): fill this in. |
Ari Hausman-Cohen | 63f6982 | 2016-06-10 11:40:35 -0700 | [diff] [blame^] | 40 | uint8_t scene_mode = ANDROID_CONTROL_SCENE_MODE_DISABLED; |
| 41 | metadata.update(ANDROID_CONTROL_AVAILABLE_SCENE_MODES, &scene_mode, 1); |
| 42 | |
Ari Hausman-Cohen | 7344215 | 2016-06-08 15:50:49 -0700 | [diff] [blame] | 43 | return metadata.release(); |
| 44 | } |
| 45 | |
| 46 | void V4L2Camera::initDeviceInfo(camera_info_t* info) { |
| 47 | HAL_LOG_ENTER(); |
| 48 | |
| 49 | // For now, just constants. |
| 50 | info->facing = CAMERA_FACING_EXTERNAL; |
| 51 | info->orientation = 0; |
| 52 | info->resource_cost = 100; |
| 53 | info->conflicting_devices = nullptr; |
| 54 | info->conflicting_devices_length = 0; |
| 55 | } |
| 56 | |
| 57 | int V4L2Camera::initDevice() { |
| 58 | HAL_LOG_ENTER(); |
| 59 | |
| 60 | // TODO(b/29221795): fill in templates, etc. |
| 61 | return 0; |
| 62 | } |
| 63 | |
| 64 | bool V4L2Camera::isValidCaptureSettings(const camera_metadata_t* settings) { |
| 65 | HAL_LOG_ENTER(); |
| 66 | |
| 67 | // TODO(b): reject capture settings this camera isn't capable of. |
| 68 | return true; |
| 69 | } |
| 70 | |
| 71 | } // namespace v4l2_camera_hal |