Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 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 <cstdlib> |
| 18 | #include <pthread.h> |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 19 | #include <hardware/camera3.h> |
Alex Ray | 083315c | 2013-04-26 19:32:29 -0700 | [diff] [blame] | 20 | #include <sync/sync.h> |
Alex Ray | bfcbd95 | 2013-03-20 13:20:02 -0700 | [diff] [blame] | 21 | #include <system/camera_metadata.h> |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 22 | #include <system/graphics.h> |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 23 | #include "CameraHAL.h" |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 24 | #include "Metadata.h" |
Alex Ray | bcaf788 | 2013-02-28 16:04:35 -0800 | [diff] [blame] | 25 | #include "Stream.h" |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 26 | |
Alex Ray | ed6b8a7 | 2012-12-27 10:42:22 -0800 | [diff] [blame] | 27 | //#define LOG_NDEBUG 0 |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 28 | #define LOG_TAG "Camera" |
| 29 | #include <cutils/log.h> |
| 30 | |
Alex Ray | ed6b8a7 | 2012-12-27 10:42:22 -0800 | [diff] [blame] | 31 | #define ATRACE_TAG (ATRACE_TAG_CAMERA | ATRACE_TAG_HAL) |
| 32 | #include <cutils/trace.h> |
Alex Ray | c16e56d | 2013-04-29 12:24:49 -0700 | [diff] [blame] | 33 | #include "ScopedTrace.h" |
Alex Ray | ed6b8a7 | 2012-12-27 10:42:22 -0800 | [diff] [blame] | 34 | |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 35 | #include "Camera.h" |
| 36 | |
Alex Ray | 083315c | 2013-04-26 19:32:29 -0700 | [diff] [blame] | 37 | #define CAMERA_SYNC_TIMEOUT 5000 // in msecs |
| 38 | |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 39 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) |
| 40 | |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 41 | namespace default_camera_hal { |
| 42 | |
| 43 | extern "C" { |
| 44 | // Shim passed to the framework to close an opened device. |
| 45 | static int close_device(hw_device_t* dev) |
| 46 | { |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 47 | camera3_device_t* cam_dev = reinterpret_cast<camera3_device_t*>(dev); |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 48 | Camera* cam = static_cast<Camera*>(cam_dev->priv); |
| 49 | return cam->close(); |
| 50 | } |
| 51 | } // extern "C" |
| 52 | |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 53 | Camera::Camera(int id) |
| 54 | : mId(id), |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 55 | mStaticInfo(NULL), |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 56 | mBusy(false), |
Alex Ray | bcaf788 | 2013-02-28 16:04:35 -0800 | [diff] [blame] | 57 | mCallbackOps(NULL), |
| 58 | mStreams(NULL), |
Alex Ray | bfcbd95 | 2013-03-20 13:20:02 -0700 | [diff] [blame] | 59 | mNumStreams(0), |
| 60 | mSettings(NULL) |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 61 | { |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 62 | pthread_mutex_init(&mMutex, NULL); |
| 63 | pthread_mutex_init(&mStaticInfoMutex, NULL); |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 64 | |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 65 | memset(&mDevice, 0, sizeof(mDevice)); |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 66 | mDevice.common.tag = HARDWARE_DEVICE_TAG; |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 67 | mDevice.common.version = CAMERA_DEVICE_API_VERSION_3_0; |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 68 | mDevice.common.close = close_device; |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 69 | mDevice.ops = const_cast<camera3_device_ops_t*>(&sOps); |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 70 | mDevice.priv = this; |
| 71 | } |
| 72 | |
| 73 | Camera::~Camera() |
| 74 | { |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 75 | pthread_mutex_destroy(&mMutex); |
| 76 | pthread_mutex_destroy(&mStaticInfoMutex); |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 77 | } |
| 78 | |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 79 | int Camera::open(const hw_module_t *module, hw_device_t **device) |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 80 | { |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 81 | ALOGI("%s:%d: Opening camera device", __func__, mId); |
Alex Ray | c16e56d | 2013-04-29 12:24:49 -0700 | [diff] [blame] | 82 | CAMTRACE_CALL(); |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 83 | pthread_mutex_lock(&mMutex); |
| 84 | if (mBusy) { |
| 85 | pthread_mutex_unlock(&mMutex); |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 86 | ALOGE("%s:%d: Error! Camera device already opened", __func__, mId); |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 87 | return -EBUSY; |
| 88 | } |
| 89 | |
| 90 | // TODO: open camera dev nodes, etc |
| 91 | mBusy = true; |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 92 | mDevice.common.module = const_cast<hw_module_t*>(module); |
| 93 | *device = &mDevice.common; |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 94 | |
| 95 | pthread_mutex_unlock(&mMutex); |
| 96 | return 0; |
| 97 | } |
| 98 | |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 99 | int Camera::getInfo(struct camera_info *info) |
| 100 | { |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 101 | info->facing = CAMERA_FACING_FRONT; |
| 102 | info->orientation = 0; |
| 103 | info->device_version = mDevice.common.version; |
| 104 | |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 105 | pthread_mutex_lock(&mStaticInfoMutex); |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 106 | if (mStaticInfo == NULL) { |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 107 | mStaticInfo = initStaticInfo(); |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 108 | } |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 109 | pthread_mutex_unlock(&mStaticInfoMutex); |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 110 | |
| 111 | info->static_camera_characteristics = mStaticInfo; |
| 112 | |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 113 | return 0; |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 114 | } |
| 115 | |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 116 | int Camera::close() |
| 117 | { |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 118 | ALOGI("%s:%d: Closing camera device", __func__, mId); |
Alex Ray | c16e56d | 2013-04-29 12:24:49 -0700 | [diff] [blame] | 119 | CAMTRACE_CALL(); |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 120 | pthread_mutex_lock(&mMutex); |
| 121 | if (!mBusy) { |
| 122 | pthread_mutex_unlock(&mMutex); |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 123 | ALOGE("%s:%d: Error! Camera device not open", __func__, mId); |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 124 | return -EINVAL; |
| 125 | } |
| 126 | |
| 127 | // TODO: close camera dev nodes, etc |
| 128 | mBusy = false; |
| 129 | |
| 130 | pthread_mutex_unlock(&mMutex); |
| 131 | return 0; |
| 132 | } |
| 133 | |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 134 | int Camera::initialize(const camera3_callback_ops_t *callback_ops) |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 135 | { |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 136 | ALOGV("%s:%d: callback_ops=%p", __func__, mId, callback_ops); |
| 137 | mCallbackOps = callback_ops; |
Alex Ray | 89a8266 | 2013-05-28 20:32:48 -0700 | [diff] [blame] | 138 | // Create standard settings templates |
| 139 | // 0 is invalid as template |
| 140 | mTemplates[0] = NULL; |
| 141 | // CAMERA3_TEMPLATE_PREVIEW = 1 |
| 142 | mTemplates[1] = new Metadata(ANDROID_CONTROL_MODE_OFF, |
| 143 | ANDROID_CONTROL_CAPTURE_INTENT_PREVIEW); |
| 144 | // CAMERA3_TEMPLATE_STILL_CAPTURE = 2 |
| 145 | mTemplates[2] = new Metadata(ANDROID_CONTROL_MODE_OFF, |
| 146 | ANDROID_CONTROL_CAPTURE_INTENT_STILL_CAPTURE); |
| 147 | // CAMERA3_TEMPLATE_VIDEO_RECORD = 3 |
| 148 | mTemplates[3] = new Metadata(ANDROID_CONTROL_MODE_OFF, |
| 149 | ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_RECORD); |
| 150 | // CAMERA3_TEMPLATE_VIDEO_SNAPSHOT = 4 |
| 151 | mTemplates[4] = new Metadata(ANDROID_CONTROL_MODE_OFF, |
| 152 | ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_SNAPSHOT); |
| 153 | // CAMERA3_TEMPLATE_STILL_ZERO_SHUTTER_LAG = 5 |
| 154 | mTemplates[5] = new Metadata(ANDROID_CONTROL_MODE_OFF, |
| 155 | ANDROID_CONTROL_CAPTURE_INTENT_ZERO_SHUTTER_LAG); |
| 156 | // Pre-generate metadata structures |
| 157 | for (int i = 1; i < CAMERA3_TEMPLATE_COUNT; i++) { |
| 158 | mTemplates[i]->generate(); |
| 159 | } |
| 160 | // TODO: create vendor templates |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 161 | return 0; |
| 162 | } |
| 163 | |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 164 | camera_metadata_t *Camera::initStaticInfo() |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 165 | { |
| 166 | /* |
| 167 | * Setup static camera info. This will have to customized per camera |
| 168 | * device. |
| 169 | */ |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 170 | Metadata m; |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 171 | |
| 172 | /* android.control */ |
| 173 | int32_t android_control_ae_available_target_fps_ranges[] = {30, 30}; |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 174 | m.addInt32(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES, |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 175 | ARRAY_SIZE(android_control_ae_available_target_fps_ranges), |
| 176 | android_control_ae_available_target_fps_ranges); |
| 177 | |
| 178 | int32_t android_control_ae_compensation_range[] = {-4, 4}; |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 179 | m.addInt32(ANDROID_CONTROL_AE_COMPENSATION_RANGE, |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 180 | ARRAY_SIZE(android_control_ae_compensation_range), |
| 181 | android_control_ae_compensation_range); |
| 182 | |
| 183 | camera_metadata_rational_t android_control_ae_compensation_step[] = {{2,1}}; |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 184 | m.addRational(ANDROID_CONTROL_AE_COMPENSATION_STEP, |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 185 | ARRAY_SIZE(android_control_ae_compensation_step), |
| 186 | android_control_ae_compensation_step); |
| 187 | |
| 188 | int32_t android_control_max_regions[] = {1}; |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 189 | m.addInt32(ANDROID_CONTROL_MAX_REGIONS, |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 190 | ARRAY_SIZE(android_control_max_regions), |
| 191 | android_control_max_regions); |
| 192 | |
| 193 | /* android.jpeg */ |
| 194 | int32_t android_jpeg_available_thumbnail_sizes[] = {0, 0, 128, 96}; |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 195 | m.addInt32(ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES, |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 196 | ARRAY_SIZE(android_jpeg_available_thumbnail_sizes), |
| 197 | android_jpeg_available_thumbnail_sizes); |
| 198 | |
| 199 | /* android.lens */ |
| 200 | float android_lens_info_available_focal_lengths[] = {1.0}; |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 201 | m.addFloat(ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS, |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 202 | ARRAY_SIZE(android_lens_info_available_focal_lengths), |
| 203 | android_lens_info_available_focal_lengths); |
| 204 | |
| 205 | /* android.request */ |
| 206 | int32_t android_request_max_num_output_streams[] = {0, 3, 1}; |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 207 | m.addInt32(ANDROID_REQUEST_MAX_NUM_OUTPUT_STREAMS, |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 208 | ARRAY_SIZE(android_request_max_num_output_streams), |
| 209 | android_request_max_num_output_streams); |
| 210 | |
| 211 | /* android.scaler */ |
| 212 | int32_t android_scaler_available_formats[] = { |
| 213 | HAL_PIXEL_FORMAT_RAW_SENSOR, |
| 214 | HAL_PIXEL_FORMAT_BLOB, |
| 215 | HAL_PIXEL_FORMAT_RGBA_8888, |
| 216 | HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, |
| 217 | // These are handled by YCbCr_420_888 |
| 218 | // HAL_PIXEL_FORMAT_YV12, |
| 219 | // HAL_PIXEL_FORMAT_YCrCb_420_SP, |
| 220 | HAL_PIXEL_FORMAT_YCbCr_420_888}; |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 221 | m.addInt32(ANDROID_SCALER_AVAILABLE_FORMATS, |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 222 | ARRAY_SIZE(android_scaler_available_formats), |
| 223 | android_scaler_available_formats); |
| 224 | |
| 225 | int64_t android_scaler_available_jpeg_min_durations[] = {1}; |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 226 | m.addInt64(ANDROID_SCALER_AVAILABLE_JPEG_MIN_DURATIONS, |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 227 | ARRAY_SIZE(android_scaler_available_jpeg_min_durations), |
| 228 | android_scaler_available_jpeg_min_durations); |
| 229 | |
| 230 | int32_t android_scaler_available_jpeg_sizes[] = {640, 480}; |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 231 | m.addInt32(ANDROID_SCALER_AVAILABLE_JPEG_SIZES, |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 232 | ARRAY_SIZE(android_scaler_available_jpeg_sizes), |
| 233 | android_scaler_available_jpeg_sizes); |
| 234 | |
| 235 | float android_scaler_available_max_digital_zoom[] = {1}; |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 236 | m.addFloat(ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM, |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 237 | ARRAY_SIZE(android_scaler_available_max_digital_zoom), |
| 238 | android_scaler_available_max_digital_zoom); |
| 239 | |
| 240 | int64_t android_scaler_available_processed_min_durations[] = {1}; |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 241 | m.addInt64(ANDROID_SCALER_AVAILABLE_PROCESSED_MIN_DURATIONS, |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 242 | ARRAY_SIZE(android_scaler_available_processed_min_durations), |
| 243 | android_scaler_available_processed_min_durations); |
| 244 | |
| 245 | int32_t android_scaler_available_processed_sizes[] = {640, 480}; |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 246 | m.addInt32(ANDROID_SCALER_AVAILABLE_PROCESSED_SIZES, |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 247 | ARRAY_SIZE(android_scaler_available_processed_sizes), |
| 248 | android_scaler_available_processed_sizes); |
| 249 | |
| 250 | int64_t android_scaler_available_raw_min_durations[] = {1}; |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 251 | m.addInt64(ANDROID_SCALER_AVAILABLE_RAW_MIN_DURATIONS, |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 252 | ARRAY_SIZE(android_scaler_available_raw_min_durations), |
| 253 | android_scaler_available_raw_min_durations); |
| 254 | |
| 255 | int32_t android_scaler_available_raw_sizes[] = {640, 480}; |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 256 | m.addInt32(ANDROID_SCALER_AVAILABLE_RAW_SIZES, |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 257 | ARRAY_SIZE(android_scaler_available_raw_sizes), |
| 258 | android_scaler_available_raw_sizes); |
| 259 | |
| 260 | /* android.sensor */ |
| 261 | |
| 262 | int32_t android_sensor_info_active_array_size[] = {0, 0, 640, 480}; |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 263 | m.addInt32(ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE, |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 264 | ARRAY_SIZE(android_sensor_info_active_array_size), |
| 265 | android_sensor_info_active_array_size); |
| 266 | |
Zhijun He | bd14689 | 2013-07-18 17:59:30 -0700 | [diff] [blame] | 267 | int32_t android_sensor_info_sensitivity_range[] = |
| 268 | {100, 1600}; |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 269 | m.addInt32(ANDROID_SENSOR_INFO_SENSITIVITY_RANGE, |
Zhijun He | bd14689 | 2013-07-18 17:59:30 -0700 | [diff] [blame] | 270 | ARRAY_SIZE(android_sensor_info_sensitivity_range), |
| 271 | android_sensor_info_sensitivity_range); |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 272 | |
| 273 | int64_t android_sensor_info_max_frame_duration[] = {30000000000}; |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 274 | m.addInt64(ANDROID_SENSOR_INFO_MAX_FRAME_DURATION, |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 275 | ARRAY_SIZE(android_sensor_info_max_frame_duration), |
| 276 | android_sensor_info_max_frame_duration); |
| 277 | |
| 278 | float android_sensor_info_physical_size[] = {3.2, 2.4}; |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 279 | m.addFloat(ANDROID_SENSOR_INFO_PHYSICAL_SIZE, |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 280 | ARRAY_SIZE(android_sensor_info_physical_size), |
| 281 | android_sensor_info_physical_size); |
| 282 | |
| 283 | int32_t android_sensor_info_pixel_array_size[] = {640, 480}; |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 284 | m.addInt32(ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 285 | ARRAY_SIZE(android_sensor_info_pixel_array_size), |
| 286 | android_sensor_info_pixel_array_size); |
| 287 | |
| 288 | int32_t android_sensor_orientation[] = {0}; |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 289 | m.addInt32(ANDROID_SENSOR_ORIENTATION, |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 290 | ARRAY_SIZE(android_sensor_orientation), |
| 291 | android_sensor_orientation); |
| 292 | |
| 293 | /* End of static camera characteristics */ |
| 294 | |
Alex Ray | 0f82f5a | 2013-07-17 14:23:04 -0700 | [diff] [blame^] | 295 | return clone_camera_metadata(m.generate()); |
Alex Ray | b0be103 | 2013-05-28 15:52:47 -0700 | [diff] [blame] | 296 | } |
| 297 | |
Alex Ray | bcaf788 | 2013-02-28 16:04:35 -0800 | [diff] [blame] | 298 | int Camera::configureStreams(camera3_stream_configuration_t *stream_config) |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 299 | { |
Alex Ray | bcaf788 | 2013-02-28 16:04:35 -0800 | [diff] [blame] | 300 | camera3_stream_t *astream; |
| 301 | Stream **newStreams = NULL; |
| 302 | |
| 303 | CAMTRACE_CALL(); |
| 304 | ALOGV("%s:%d: stream_config=%p", __func__, mId, stream_config); |
| 305 | |
| 306 | if (stream_config == NULL) { |
| 307 | ALOGE("%s:%d: NULL stream configuration array", __func__, mId); |
| 308 | return -EINVAL; |
| 309 | } |
| 310 | if (stream_config->num_streams == 0) { |
| 311 | ALOGE("%s:%d: Empty stream configuration array", __func__, mId); |
| 312 | return -EINVAL; |
| 313 | } |
| 314 | |
| 315 | // Create new stream array |
| 316 | newStreams = new Stream*[stream_config->num_streams]; |
| 317 | ALOGV("%s:%d: Number of Streams: %d", __func__, mId, |
| 318 | stream_config->num_streams); |
| 319 | |
| 320 | pthread_mutex_lock(&mMutex); |
| 321 | |
| 322 | // Mark all current streams unused for now |
| 323 | for (int i = 0; i < mNumStreams; i++) |
| 324 | mStreams[i]->mReuse = false; |
| 325 | // Fill new stream array with reused streams and new streams |
Alex Ray | c6bf2f2 | 2013-05-28 15:52:04 -0700 | [diff] [blame] | 326 | for (unsigned int i = 0; i < stream_config->num_streams; i++) { |
Alex Ray | bcaf788 | 2013-02-28 16:04:35 -0800 | [diff] [blame] | 327 | astream = stream_config->streams[i]; |
Alex Ray | 2b286da | 2013-05-29 15:08:29 -0700 | [diff] [blame] | 328 | if (astream->max_buffers > 0) { |
| 329 | ALOGV("%s:%d: Reusing stream %d", __func__, mId, i); |
Alex Ray | bcaf788 | 2013-02-28 16:04:35 -0800 | [diff] [blame] | 330 | newStreams[i] = reuseStream(astream); |
Alex Ray | 2b286da | 2013-05-29 15:08:29 -0700 | [diff] [blame] | 331 | } else { |
| 332 | ALOGV("%s:%d: Creating new stream %d", __func__, mId, i); |
Alex Ray | bcaf788 | 2013-02-28 16:04:35 -0800 | [diff] [blame] | 333 | newStreams[i] = new Stream(mId, astream); |
Alex Ray | 2b286da | 2013-05-29 15:08:29 -0700 | [diff] [blame] | 334 | } |
Alex Ray | bcaf788 | 2013-02-28 16:04:35 -0800 | [diff] [blame] | 335 | |
| 336 | if (newStreams[i] == NULL) { |
| 337 | ALOGE("%s:%d: Error processing stream %d", __func__, mId, i); |
| 338 | goto err_out; |
| 339 | } |
| 340 | astream->priv = newStreams[i]; |
| 341 | } |
| 342 | |
| 343 | // Verify the set of streams in aggregate |
| 344 | if (!isValidStreamSet(newStreams, stream_config->num_streams)) { |
| 345 | ALOGE("%s:%d: Invalid stream set", __func__, mId); |
| 346 | goto err_out; |
| 347 | } |
| 348 | |
| 349 | // Set up all streams (calculate usage/max_buffers for each) |
| 350 | setupStreams(newStreams, stream_config->num_streams); |
| 351 | |
| 352 | // Destroy all old streams and replace stream array with new one |
| 353 | destroyStreams(mStreams, mNumStreams); |
| 354 | mStreams = newStreams; |
| 355 | mNumStreams = stream_config->num_streams; |
| 356 | |
Alex Ray | bfcbd95 | 2013-03-20 13:20:02 -0700 | [diff] [blame] | 357 | // Clear out last seen settings metadata |
| 358 | setSettings(NULL); |
| 359 | |
Alex Ray | bcaf788 | 2013-02-28 16:04:35 -0800 | [diff] [blame] | 360 | pthread_mutex_unlock(&mMutex); |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 361 | return 0; |
Alex Ray | bcaf788 | 2013-02-28 16:04:35 -0800 | [diff] [blame] | 362 | |
| 363 | err_out: |
| 364 | // Clean up temporary streams, preserve existing mStreams/mNumStreams |
| 365 | destroyStreams(newStreams, stream_config->num_streams); |
| 366 | pthread_mutex_unlock(&mMutex); |
| 367 | return -EINVAL; |
| 368 | } |
| 369 | |
| 370 | void Camera::destroyStreams(Stream **streams, int count) |
| 371 | { |
| 372 | if (streams == NULL) |
| 373 | return; |
| 374 | for (int i = 0; i < count; i++) { |
| 375 | // Only destroy streams that weren't reused |
| 376 | if (streams[i] != NULL && !streams[i]->mReuse) |
| 377 | delete streams[i]; |
| 378 | } |
| 379 | delete [] streams; |
| 380 | } |
| 381 | |
| 382 | Stream *Camera::reuseStream(camera3_stream_t *astream) |
| 383 | { |
| 384 | Stream *priv = reinterpret_cast<Stream*>(astream->priv); |
| 385 | // Verify the re-used stream's parameters match |
| 386 | if (!priv->isValidReuseStream(mId, astream)) { |
| 387 | ALOGE("%s:%d: Mismatched parameter in reused stream", __func__, mId); |
| 388 | return NULL; |
| 389 | } |
| 390 | // Mark stream to be reused |
| 391 | priv->mReuse = true; |
| 392 | return priv; |
| 393 | } |
| 394 | |
| 395 | bool Camera::isValidStreamSet(Stream **streams, int count) |
| 396 | { |
| 397 | int inputs = 0; |
| 398 | int outputs = 0; |
| 399 | |
| 400 | if (streams == NULL) { |
| 401 | ALOGE("%s:%d: NULL stream configuration streams", __func__, mId); |
| 402 | return false; |
| 403 | } |
| 404 | if (count == 0) { |
| 405 | ALOGE("%s:%d: Zero count stream configuration streams", __func__, mId); |
| 406 | return false; |
| 407 | } |
| 408 | // Validate there is at most one input stream and at least one output stream |
| 409 | for (int i = 0; i < count; i++) { |
| 410 | // A stream may be both input and output (bidirectional) |
| 411 | if (streams[i]->isInputType()) |
| 412 | inputs++; |
| 413 | if (streams[i]->isOutputType()) |
| 414 | outputs++; |
| 415 | } |
Alex Ray | 768216e | 2013-07-02 16:56:14 -0700 | [diff] [blame] | 416 | ALOGV("%s:%d: Configuring %d output streams and %d input streams", |
| 417 | __func__, mId, outputs, inputs); |
Alex Ray | bcaf788 | 2013-02-28 16:04:35 -0800 | [diff] [blame] | 418 | if (outputs < 1) { |
| 419 | ALOGE("%s:%d: Stream config must have >= 1 output", __func__, mId); |
| 420 | return false; |
| 421 | } |
| 422 | if (inputs > 1) { |
| 423 | ALOGE("%s:%d: Stream config must have <= 1 input", __func__, mId); |
| 424 | return false; |
| 425 | } |
| 426 | // TODO: check for correct number of Bayer/YUV/JPEG/Encoder streams |
| 427 | return true; |
| 428 | } |
| 429 | |
| 430 | void Camera::setupStreams(Stream **streams, int count) |
| 431 | { |
| 432 | /* |
| 433 | * This is where the HAL has to decide internally how to handle all of the |
| 434 | * streams, and then produce usage and max_buffer values for each stream. |
| 435 | * Note, the stream array has been checked before this point for ALL invalid |
| 436 | * conditions, so it must find a successful configuration for this stream |
| 437 | * array. The HAL may not return an error from this point. |
| 438 | * |
| 439 | * In this demo HAL, we just set all streams to be the same dummy values; |
| 440 | * real implementations will want to avoid USAGE_SW_{READ|WRITE}_OFTEN. |
| 441 | */ |
| 442 | for (int i = 0; i < count; i++) { |
| 443 | uint32_t usage = 0; |
| 444 | |
| 445 | if (streams[i]->isOutputType()) |
| 446 | usage |= GRALLOC_USAGE_SW_WRITE_OFTEN | |
| 447 | GRALLOC_USAGE_HW_CAMERA_WRITE; |
| 448 | if (streams[i]->isInputType()) |
| 449 | usage |= GRALLOC_USAGE_SW_READ_OFTEN | |
| 450 | GRALLOC_USAGE_HW_CAMERA_READ; |
| 451 | |
| 452 | streams[i]->setUsage(usage); |
| 453 | streams[i]->setMaxBuffers(1); |
| 454 | } |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 455 | } |
| 456 | |
| 457 | int Camera::registerStreamBuffers(const camera3_stream_buffer_set_t *buf_set) |
| 458 | { |
| 459 | ALOGV("%s:%d: buffer_set=%p", __func__, mId, buf_set); |
Alex Ray | 8a8f86b | 2013-03-01 01:32:21 -0800 | [diff] [blame] | 460 | if (buf_set == NULL) { |
| 461 | ALOGE("%s:%d: NULL buffer set", __func__, mId); |
| 462 | return -EINVAL; |
| 463 | } |
| 464 | if (buf_set->stream == NULL) { |
| 465 | ALOGE("%s:%d: NULL stream handle", __func__, mId); |
| 466 | return -EINVAL; |
| 467 | } |
| 468 | Stream *stream = reinterpret_cast<Stream*>(buf_set->stream->priv); |
| 469 | return stream->registerBuffers(buf_set); |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 470 | } |
| 471 | |
| 472 | const camera_metadata_t* Camera::constructDefaultRequestSettings(int type) |
| 473 | { |
| 474 | ALOGV("%s:%d: type=%d", __func__, mId, type); |
Alex Ray | 89a8266 | 2013-05-28 20:32:48 -0700 | [diff] [blame] | 475 | |
| 476 | if (type < 1 || type >= CAMERA3_TEMPLATE_COUNT) { |
| 477 | ALOGE("%s:%d: Invalid template request type: %d", __func__, mId, type); |
| 478 | return NULL; |
| 479 | } |
| 480 | return mTemplates[type]->generate(); |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 481 | } |
| 482 | |
| 483 | int Camera::processCaptureRequest(camera3_capture_request_t *request) |
| 484 | { |
Alex Ray | 083315c | 2013-04-26 19:32:29 -0700 | [diff] [blame] | 485 | camera3_capture_result result; |
| 486 | |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 487 | ALOGV("%s:%d: request=%p", __func__, mId, request); |
Alex Ray | c16e56d | 2013-04-29 12:24:49 -0700 | [diff] [blame] | 488 | CAMTRACE_CALL(); |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 489 | |
| 490 | if (request == NULL) { |
| 491 | ALOGE("%s:%d: NULL request recieved", __func__, mId); |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 492 | return -EINVAL; |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 493 | } |
| 494 | |
Alex Ray | bfcbd95 | 2013-03-20 13:20:02 -0700 | [diff] [blame] | 495 | ALOGV("%s:%d: Request Frame:%d Settings:%p", __func__, mId, |
| 496 | request->frame_number, request->settings); |
| 497 | |
| 498 | // NULL indicates use last settings |
| 499 | if (request->settings == NULL) { |
| 500 | if (mSettings == NULL) { |
| 501 | ALOGE("%s:%d: NULL settings without previous set Frame:%d Req:%p", |
| 502 | __func__, mId, request->frame_number, request); |
| 503 | return -EINVAL; |
| 504 | } |
| 505 | } else { |
| 506 | setSettings(request->settings); |
| 507 | } |
| 508 | |
Alex Ray | 11bbeef | 2013-04-26 14:47:08 -0700 | [diff] [blame] | 509 | if (request->input_buffer != NULL) { |
| 510 | ALOGV("%s:%d: Reprocessing input buffer %p", __func__, mId, |
| 511 | request->input_buffer); |
| 512 | |
| 513 | if (!isValidReprocessSettings(request->settings)) { |
| 514 | ALOGE("%s:%d: Invalid settings for reprocess request: %p", |
| 515 | __func__, mId, request->settings); |
| 516 | return -EINVAL; |
| 517 | } |
| 518 | } else { |
| 519 | ALOGV("%s:%d: Capturing new frame.", __func__, mId); |
| 520 | |
| 521 | if (!isValidCaptureSettings(request->settings)) { |
| 522 | ALOGE("%s:%d: Invalid settings for capture request: %p", |
| 523 | __func__, mId, request->settings); |
| 524 | return -EINVAL; |
| 525 | } |
| 526 | } |
| 527 | |
Alex Ray | 083315c | 2013-04-26 19:32:29 -0700 | [diff] [blame] | 528 | if (request->num_output_buffers <= 0) { |
| 529 | ALOGE("%s:%d: Invalid number of output buffers: %d", __func__, mId, |
| 530 | request->num_output_buffers); |
| 531 | return -EINVAL; |
| 532 | } |
| 533 | result.num_output_buffers = request->num_output_buffers; |
| 534 | result.output_buffers = new camera3_stream_buffer_t[result.num_output_buffers]; |
| 535 | for (unsigned int i = 0; i < request->num_output_buffers; i++) { |
| 536 | int res = processCaptureBuffer(&request->output_buffers[i], |
| 537 | const_cast<camera3_stream_buffer_t*>(&result.output_buffers[i])); |
| 538 | if (res) |
| 539 | goto err_out; |
| 540 | } |
| 541 | |
| 542 | result.frame_number = request->frame_number; |
| 543 | // TODO: return actual captured/reprocessed settings |
| 544 | result.result = request->settings; |
| 545 | // TODO: asynchronously return results |
Alex Ray | 764e442 | 2013-06-04 12:38:07 -0700 | [diff] [blame] | 546 | notifyShutter(request->frame_number, 0); |
Alex Ray | 083315c | 2013-04-26 19:32:29 -0700 | [diff] [blame] | 547 | mCallbackOps->process_capture_result(mCallbackOps, &result); |
| 548 | |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 549 | return 0; |
Alex Ray | 083315c | 2013-04-26 19:32:29 -0700 | [diff] [blame] | 550 | |
| 551 | err_out: |
| 552 | delete [] result.output_buffers; |
| 553 | // TODO: this should probably be a total device failure; transient for now |
| 554 | return -EINVAL; |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 555 | } |
| 556 | |
Alex Ray | bfcbd95 | 2013-03-20 13:20:02 -0700 | [diff] [blame] | 557 | void Camera::setSettings(const camera_metadata_t *new_settings) |
| 558 | { |
| 559 | if (mSettings != NULL) { |
| 560 | free_camera_metadata(mSettings); |
| 561 | mSettings = NULL; |
| 562 | } |
| 563 | |
| 564 | if (new_settings != NULL) |
| 565 | mSettings = clone_camera_metadata(new_settings); |
| 566 | } |
| 567 | |
Alex Ray | c6bf2f2 | 2013-05-28 15:52:04 -0700 | [diff] [blame] | 568 | bool Camera::isValidCaptureSettings(const camera_metadata_t* /*settings*/) |
Alex Ray | 11bbeef | 2013-04-26 14:47:08 -0700 | [diff] [blame] | 569 | { |
| 570 | // TODO: reject settings that cannot be captured |
| 571 | return true; |
| 572 | } |
| 573 | |
Alex Ray | c6bf2f2 | 2013-05-28 15:52:04 -0700 | [diff] [blame] | 574 | bool Camera::isValidReprocessSettings(const camera_metadata_t* /*settings*/) |
Alex Ray | 11bbeef | 2013-04-26 14:47:08 -0700 | [diff] [blame] | 575 | { |
| 576 | // TODO: reject settings that cannot be reprocessed |
| 577 | // input buffers unimplemented, use this to reject reprocessing requests |
| 578 | ALOGE("%s:%d: Input buffer reprocessing not implemented", __func__, mId); |
| 579 | return false; |
| 580 | } |
| 581 | |
Alex Ray | 083315c | 2013-04-26 19:32:29 -0700 | [diff] [blame] | 582 | int Camera::processCaptureBuffer(const camera3_stream_buffer_t *in, |
| 583 | camera3_stream_buffer_t *out) |
| 584 | { |
Alex Ray | 77ecfd7 | 2013-05-30 00:19:04 -0700 | [diff] [blame] | 585 | if (in->acquire_fence != -1) { |
| 586 | int res = sync_wait(in->acquire_fence, CAMERA_SYNC_TIMEOUT); |
| 587 | if (res == -ETIME) { |
| 588 | ALOGE("%s:%d: Timeout waiting on buffer acquire fence", |
| 589 | __func__, mId); |
| 590 | return res; |
| 591 | } else if (res) { |
| 592 | ALOGE("%s:%d: Error waiting on buffer acquire fence: %s(%d)", |
| 593 | __func__, mId, strerror(-res), res); |
| 594 | return res; |
| 595 | } |
Alex Ray | 083315c | 2013-04-26 19:32:29 -0700 | [diff] [blame] | 596 | } |
| 597 | |
| 598 | out->stream = in->stream; |
| 599 | out->buffer = in->buffer; |
| 600 | out->status = CAMERA3_BUFFER_STATUS_OK; |
| 601 | // TODO: use driver-backed release fences |
| 602 | out->acquire_fence = -1; |
| 603 | out->release_fence = -1; |
| 604 | |
| 605 | // TODO: lock and software-paint buffer |
| 606 | return 0; |
| 607 | } |
| 608 | |
Alex Ray | 764e442 | 2013-06-04 12:38:07 -0700 | [diff] [blame] | 609 | void Camera::notifyShutter(uint32_t frame_number, uint64_t timestamp) |
| 610 | { |
| 611 | int res; |
| 612 | struct timespec ts; |
| 613 | |
| 614 | // If timestamp is 0, get timestamp from right now instead |
| 615 | if (timestamp == 0) { |
| 616 | ALOGW("%s:%d: No timestamp provided, using CLOCK_BOOTTIME", |
| 617 | __func__, mId); |
| 618 | res = clock_gettime(CLOCK_BOOTTIME, &ts); |
| 619 | if (res == 0) { |
| 620 | timestamp = ts.tv_sec * 1000000000ULL + ts.tv_nsec; |
| 621 | } else { |
| 622 | ALOGE("%s:%d: No timestamp and failed to get CLOCK_BOOTTIME %s(%d)", |
| 623 | __func__, mId, strerror(errno), errno); |
| 624 | } |
| 625 | } |
| 626 | camera3_notify_msg_t m; |
| 627 | memset(&m, 0, sizeof(m)); |
| 628 | m.type = CAMERA3_MSG_SHUTTER; |
| 629 | m.message.shutter.frame_number = frame_number; |
| 630 | m.message.shutter.timestamp = timestamp; |
| 631 | mCallbackOps->notify(mCallbackOps, &m); |
| 632 | } |
| 633 | |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 634 | void Camera::getMetadataVendorTagOps(vendor_tag_query_ops_t *ops) |
| 635 | { |
| 636 | ALOGV("%s:%d: ops=%p", __func__, mId, ops); |
| 637 | // TODO: return vendor tag ops |
| 638 | } |
| 639 | |
| 640 | void Camera::dump(int fd) |
| 641 | { |
Alex Ray | af3a461 | 2013-04-29 14:16:10 -0700 | [diff] [blame] | 642 | ALOGV("%s:%d: Dumping to fd %d", __func__, mId, fd); |
Alex Ray | a0ed4be | 2013-02-25 15:02:16 -0800 | [diff] [blame] | 643 | // TODO: dprintf all relevant state to fd |
| 644 | } |
| 645 | |
| 646 | extern "C" { |
| 647 | // Get handle to camera from device priv data |
| 648 | static Camera *camdev_to_camera(const camera3_device_t *dev) |
| 649 | { |
| 650 | return reinterpret_cast<Camera*>(dev->priv); |
| 651 | } |
| 652 | |
| 653 | static int initialize(const camera3_device_t *dev, |
| 654 | const camera3_callback_ops_t *callback_ops) |
| 655 | { |
| 656 | return camdev_to_camera(dev)->initialize(callback_ops); |
| 657 | } |
| 658 | |
| 659 | static int configure_streams(const camera3_device_t *dev, |
| 660 | camera3_stream_configuration_t *stream_list) |
| 661 | { |
| 662 | return camdev_to_camera(dev)->configureStreams(stream_list); |
| 663 | } |
| 664 | |
| 665 | static int register_stream_buffers(const camera3_device_t *dev, |
| 666 | const camera3_stream_buffer_set_t *buffer_set) |
| 667 | { |
| 668 | return camdev_to_camera(dev)->registerStreamBuffers(buffer_set); |
| 669 | } |
| 670 | |
| 671 | static const camera_metadata_t *construct_default_request_settings( |
| 672 | const camera3_device_t *dev, int type) |
| 673 | { |
| 674 | return camdev_to_camera(dev)->constructDefaultRequestSettings(type); |
| 675 | } |
| 676 | |
| 677 | static int process_capture_request(const camera3_device_t *dev, |
| 678 | camera3_capture_request_t *request) |
| 679 | { |
| 680 | return camdev_to_camera(dev)->processCaptureRequest(request); |
| 681 | } |
| 682 | |
| 683 | static void get_metadata_vendor_tag_ops(const camera3_device_t *dev, |
| 684 | vendor_tag_query_ops_t *ops) |
| 685 | { |
| 686 | camdev_to_camera(dev)->getMetadataVendorTagOps(ops); |
| 687 | } |
| 688 | |
| 689 | static void dump(const camera3_device_t *dev, int fd) |
| 690 | { |
| 691 | camdev_to_camera(dev)->dump(fd); |
| 692 | } |
| 693 | } // extern "C" |
| 694 | |
| 695 | const camera3_device_ops_t Camera::sOps = { |
| 696 | .initialize = default_camera_hal::initialize, |
| 697 | .configure_streams = default_camera_hal::configure_streams, |
| 698 | .register_stream_buffers = default_camera_hal::register_stream_buffers, |
| 699 | .construct_default_request_settings = |
| 700 | default_camera_hal::construct_default_request_settings, |
| 701 | .process_capture_request = default_camera_hal::process_capture_request, |
| 702 | .get_metadata_vendor_tag_ops = |
| 703 | default_camera_hal::get_metadata_vendor_tag_ops, |
| 704 | .dump = default_camera_hal::dump |
| 705 | }; |
| 706 | |
Alex Ray | 7ee0b7a | 2012-11-06 00:12:49 -0800 | [diff] [blame] | 707 | } // namespace default_camera_hal |