blob: d1d1a9e7582035854883ffd886b3ff5e5e58be59 [file] [log] [blame]
Ari Hausman-Cohen73442152016-06-08 15:50:49 -07001/*
2 * Copyright (C) 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// Modified from hardware/libhardware/modules/camera/Camera.cpp
18
19#include <cstdlib>
20#include <stdio.h>
21#include <hardware/camera3.h>
22#include <sync/sync.h>
23#include <system/camera_metadata.h>
24#include <system/graphics.h>
25#include <utils/Mutex.h>
26#include "Stream.h"
27
28//#define LOG_NDEBUG 0
29#define LOG_TAG "Camera"
30#include <cutils/log.h>
31
32#define ATRACE_TAG (ATRACE_TAG_CAMERA | ATRACE_TAG_HAL)
33#include <utils/Trace.h>
34
35#include "Camera.h"
36
37#define CAMERA_SYNC_TIMEOUT 5000 // in msecs
38
39namespace default_camera_hal {
40
41extern "C" {
42// Shim passed to the framework to close an opened device.
43static int close_device(hw_device_t* dev)
44{
45 camera3_device_t* cam_dev = reinterpret_cast<camera3_device_t*>(dev);
46 Camera* cam = static_cast<Camera*>(cam_dev->priv);
47 return cam->close();
48}
49} // extern "C"
50
51Camera::Camera(int id)
52 : mId(id),
53 mStaticInfo(NULL),
54 mBusy(false),
55 mCallbackOps(NULL),
56 mStreams(NULL),
57 mNumStreams(0),
58 mSettings(NULL)
59{
60 memset(&mTemplates, 0, sizeof(mTemplates));
61 memset(&mDevice, 0, sizeof(mDevice));
62 mDevice.common.tag = HARDWARE_DEVICE_TAG;
Ari Hausman-Cohen900c1e32016-06-20 16:52:41 -070063 mDevice.common.version = CAMERA_DEVICE_API_VERSION_3_4;
Ari Hausman-Cohen73442152016-06-08 15:50:49 -070064 mDevice.common.close = close_device;
65 mDevice.ops = const_cast<camera3_device_ops_t*>(&sOps);
66 mDevice.priv = this;
67}
68
69Camera::~Camera()
70{
71 if (mStaticInfo != NULL) {
72 free_camera_metadata(mStaticInfo);
73 }
74 if (mSettings != NULL) {
75 free_camera_metadata(mSettings);
76 }
77 for (camera_metadata_t* metadata : mTemplates) {
78 if (metadata != NULL) {
79 free_camera_metadata(metadata);
80 }
81 }
82}
83
Ari Hausman-Cohen345bd3a2016-06-13 15:33:53 -070084int Camera::openDevice(const hw_module_t *module, hw_device_t **device)
Ari Hausman-Cohen73442152016-06-08 15:50:49 -070085{
86 ALOGI("%s:%d: Opening camera device", __func__, mId);
87 ATRACE_CALL();
88 android::Mutex::Autolock al(mDeviceLock);
89
90 if (mBusy) {
91 ALOGE("%s:%d: Error! Camera device already opened", __func__, mId);
92 return -EBUSY;
93 }
94
Ari Hausman-Cohen345bd3a2016-06-13 15:33:53 -070095 int connectResult = connect();
96 if (connectResult != 0) {
97 return connectResult;
98 }
Ari Hausman-Cohen73442152016-06-08 15:50:49 -070099 mBusy = true;
100 mDevice.common.module = const_cast<hw_module_t*>(module);
101 *device = &mDevice.common;
102 return 0;
103}
104
105int Camera::getInfo(struct camera_info *info)
106{
107 android::Mutex::Autolock al(mStaticInfoLock);
108
109 info->device_version = mDevice.common.version;
110 initDeviceInfo(info);
111 if (mStaticInfo == NULL) {
Ari Hausman-Cohen900c1e32016-06-20 16:52:41 -0700112 if (initStaticInfo(&mStaticInfo)) {
113 return -ENODEV;
114 }
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700115 }
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700116 info->static_camera_characteristics = mStaticInfo;
117 return 0;
118}
119
120int Camera::close()
121{
122 ALOGI("%s:%d: Closing camera device", __func__, mId);
123 ATRACE_CALL();
124 android::Mutex::Autolock al(mDeviceLock);
125
126 if (!mBusy) {
127 ALOGE("%s:%d: Error! Camera device not open", __func__, mId);
128 return -EINVAL;
129 }
130
Ari Hausman-Cohen345bd3a2016-06-13 15:33:53 -0700131 disconnect();
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700132 mBusy = false;
133 return 0;
134}
135
136int Camera::initialize(const camera3_callback_ops_t *callback_ops)
137{
138 int res;
139
140 ALOGV("%s:%d: callback_ops=%p", __func__, mId, callback_ops);
141 mCallbackOps = callback_ops;
142 // per-device specific initialization
143 res = initDevice();
144 if (res != 0) {
145 ALOGE("%s:%d: Failed to initialize device!", __func__, mId);
146 return res;
147 }
148 return 0;
149}
150
151int Camera::configureStreams(camera3_stream_configuration_t *stream_config)
152{
153 camera3_stream_t *astream;
154 Stream **newStreams = NULL;
Ari Hausman-Cohen72fddb32016-06-30 16:53:31 -0700155 int res = 0;
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700156
157 ALOGV("%s:%d: stream_config=%p", __func__, mId, stream_config);
158 ATRACE_CALL();
159 android::Mutex::Autolock al(mDeviceLock);
160
161 if (stream_config == NULL) {
162 ALOGE("%s:%d: NULL stream configuration array", __func__, mId);
163 return -EINVAL;
164 }
165 if (stream_config->num_streams == 0) {
166 ALOGE("%s:%d: Empty stream configuration array", __func__, mId);
167 return -EINVAL;
168 }
169
170 // Create new stream array
171 newStreams = new Stream*[stream_config->num_streams];
172 ALOGV("%s:%d: Number of Streams: %d", __func__, mId,
173 stream_config->num_streams);
174
175 // Mark all current streams unused for now
176 for (int i = 0; i < mNumStreams; i++)
177 mStreams[i]->mReuse = false;
178 // Fill new stream array with reused streams and new streams
179 for (unsigned int i = 0; i < stream_config->num_streams; i++) {
180 astream = stream_config->streams[i];
181 if (astream->max_buffers > 0) {
182 ALOGV("%s:%d: Reusing stream %d", __func__, mId, i);
183 newStreams[i] = reuseStream(astream);
184 } else {
185 ALOGV("%s:%d: Creating new stream %d", __func__, mId, i);
186 newStreams[i] = new Stream(mId, astream);
187 }
188
189 if (newStreams[i] == NULL) {
190 ALOGE("%s:%d: Error processing stream %d", __func__, mId, i);
191 goto err_out;
192 }
193 astream->priv = newStreams[i];
194 }
195
196 // Verify the set of streams in aggregate
Ari Hausman-Cohen72fddb32016-06-30 16:53:31 -0700197 if (!isValidStreamSet(newStreams, stream_config->num_streams,
198 stream_config->operation_mode)) {
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700199 ALOGE("%s:%d: Invalid stream set", __func__, mId);
200 goto err_out;
201 }
202
Ari Hausman-Cohen72fddb32016-06-30 16:53:31 -0700203 // Set up all streams (calculate usage/max_buffers for each,
204 // do any device-specific initialization)
205 res = setupStreams(newStreams, stream_config->num_streams);
206 if (res) {
207 ALOGE("%s:%d: Failed to setup stream set", __func__, mId);
208 goto err_out;
209 }
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700210
211 // Destroy all old streams and replace stream array with new one
212 destroyStreams(mStreams, mNumStreams);
213 mStreams = newStreams;
214 mNumStreams = stream_config->num_streams;
215
216 // Clear out last seen settings metadata
217 setSettings(NULL);
218 return 0;
219
220err_out:
221 // Clean up temporary streams, preserve existing mStreams/mNumStreams
222 destroyStreams(newStreams, stream_config->num_streams);
Ari Hausman-Cohen72fddb32016-06-30 16:53:31 -0700223 // Set error if it wasn't specified.
224 if (!res) {
225 res = -EINVAL;
226 }
227 return res;
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700228}
229
230void Camera::destroyStreams(Stream **streams, int count)
231{
232 if (streams == NULL)
233 return;
234 for (int i = 0; i < count; i++) {
235 // Only destroy streams that weren't reused
236 if (streams[i] != NULL && !streams[i]->mReuse)
237 delete streams[i];
238 }
239 delete [] streams;
240}
241
242Stream *Camera::reuseStream(camera3_stream_t *astream)
243{
244 Stream *priv = reinterpret_cast<Stream*>(astream->priv);
245 // Verify the re-used stream's parameters match
246 if (!priv->isValidReuseStream(mId, astream)) {
247 ALOGE("%s:%d: Mismatched parameter in reused stream", __func__, mId);
248 return NULL;
249 }
250 // Mark stream to be reused
251 priv->mReuse = true;
252 return priv;
253}
254
Ari Hausman-Cohen72fddb32016-06-30 16:53:31 -0700255bool Camera::isValidStreamSet(Stream **streams, int count, uint32_t mode)
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700256{
257 int inputs = 0;
258 int outputs = 0;
259
260 if (streams == NULL) {
261 ALOGE("%s:%d: NULL stream configuration streams", __func__, mId);
262 return false;
263 }
264 if (count == 0) {
265 ALOGE("%s:%d: Zero count stream configuration streams", __func__, mId);
266 return false;
267 }
268 // Validate there is at most one input stream and at least one output stream
269 for (int i = 0; i < count; i++) {
270 // A stream may be both input and output (bidirectional)
271 if (streams[i]->isInputType())
272 inputs++;
273 if (streams[i]->isOutputType())
274 outputs++;
275 }
276 ALOGV("%s:%d: Configuring %d output streams and %d input streams",
277 __func__, mId, outputs, inputs);
278 if (outputs < 1) {
279 ALOGE("%s:%d: Stream config must have >= 1 output", __func__, mId);
280 return false;
281 }
282 if (inputs > 1) {
283 ALOGE("%s:%d: Stream config must have <= 1 input", __func__, mId);
284 return false;
285 }
Ari Hausman-Cohen72fddb32016-06-30 16:53:31 -0700286
287 // check for correct number of Bayer/YUV/JPEG/Encoder streams
288 return isSupportedStreamSet(streams, count, mode);
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700289}
290
Ari Hausman-Cohen72fddb32016-06-30 16:53:31 -0700291int Camera::setupStreams(Stream **streams, int count)
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700292{
293 /*
294 * This is where the HAL has to decide internally how to handle all of the
295 * streams, and then produce usage and max_buffer values for each stream.
296 * Note, the stream array has been checked before this point for ALL invalid
297 * conditions, so it must find a successful configuration for this stream
Ari Hausman-Cohen72fddb32016-06-30 16:53:31 -0700298 * array. The only errors should be from individual streams requesting
299 * unsupported features (such as data_space or rotation).
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700300 */
301 for (int i = 0; i < count; i++) {
302 uint32_t usage = 0;
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700303 if (streams[i]->isOutputType())
Ari Hausman-Cohen72fddb32016-06-30 16:53:31 -0700304 usage |= GRALLOC_USAGE_HW_CAMERA_WRITE;
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700305 if (streams[i]->isInputType())
Ari Hausman-Cohen72fddb32016-06-30 16:53:31 -0700306 usage |= GRALLOC_USAGE_HW_CAMERA_READ;
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700307 streams[i]->setUsage(usage);
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700308
Ari Hausman-Cohen72fddb32016-06-30 16:53:31 -0700309 uint32_t max_buffers;
310 int res = setupStream(streams[i], &max_buffers);
311 if (res) {
312 return res;
313 }
314 streams[i]->setMaxBuffers(max_buffers);
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700315 }
Ari Hausman-Cohen72fddb32016-06-30 16:53:31 -0700316 return 0;
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700317}
318
319bool Camera::isValidTemplateType(int type)
320{
Ari Hausman-Cohen900c1e32016-06-20 16:52:41 -0700321 return type > 0 && type < CAMERA3_TEMPLATE_COUNT;
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700322}
323
324const camera_metadata_t* Camera::constructDefaultRequestSettings(int type)
325{
326 ALOGV("%s:%d: type=%d", __func__, mId, type);
327
328 if (!isValidTemplateType(type)) {
329 ALOGE("%s:%d: Invalid template request type: %d", __func__, mId, type);
330 return NULL;
331 }
Ari Hausman-Cohen49925842016-06-21 14:07:58 -0700332
333 // Will return NULL (indicating unsupported) if the template is not
334 // initialized.
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700335 return mTemplates[type];
336}
337
338int Camera::processCaptureRequest(camera3_capture_request_t *request)
339{
Ari Hausman-Cohen2934eb92016-07-20 17:25:39 +0000340 camera3_capture_result result;
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700341
342 ALOGV("%s:%d: request=%p", __func__, mId, request);
343 ATRACE_CALL();
344
345 if (request == NULL) {
346 ALOGE("%s:%d: NULL request recieved", __func__, mId);
347 return -EINVAL;
348 }
349
350 ALOGV("%s:%d: Request Frame:%d Settings:%p", __func__, mId,
351 request->frame_number, request->settings);
352
353 // NULL indicates use last settings
354 if (request->settings == NULL) {
355 if (mSettings == NULL) {
356 ALOGE("%s:%d: NULL settings without previous set Frame:%d Req:%p",
357 __func__, mId, request->frame_number, request);
358 return -EINVAL;
359 }
360 } else {
361 setSettings(request->settings);
362 }
363
364 if (request->input_buffer != NULL) {
365 ALOGV("%s:%d: Reprocessing input buffer %p", __func__, mId,
366 request->input_buffer);
367
368 if (!isValidReprocessSettings(request->settings)) {
369 ALOGE("%s:%d: Invalid settings for reprocess request: %p",
370 __func__, mId, request->settings);
371 return -EINVAL;
372 }
373 } else {
374 ALOGV("%s:%d: Capturing new frame.", __func__, mId);
375
376 if (!isValidCaptureSettings(request->settings)) {
377 ALOGE("%s:%d: Invalid settings for capture request: %p",
378 __func__, mId, request->settings);
379 return -EINVAL;
380 }
381 }
382
383 if (request->num_output_buffers <= 0) {
384 ALOGE("%s:%d: Invalid number of output buffers: %d", __func__, mId,
385 request->num_output_buffers);
386 return -EINVAL;
387 }
Ari Hausman-Cohen784c8492016-07-06 13:28:53 -0700388 result.num_output_buffers = request->num_output_buffers;
Ari Hausman-Cohen2934eb92016-07-20 17:25:39 +0000389 result.output_buffers = new camera3_stream_buffer_t[result.num_output_buffers];
Ari Hausman-Cohen784c8492016-07-06 13:28:53 -0700390 for (unsigned int i = 0; i < request->num_output_buffers; i++) {
Ari Hausman-Cohen2934eb92016-07-20 17:25:39 +0000391 int res = processCaptureBuffer(&request->output_buffers[i],
392 const_cast<camera3_stream_buffer_t*>(&result.output_buffers[i]));
Ari Hausman-Cohen784c8492016-07-06 13:28:53 -0700393 if (res)
Ari Hausman-Cohen2934eb92016-07-20 17:25:39 +0000394 goto err_out;
Ari Hausman-Cohen784c8492016-07-06 13:28:53 -0700395 }
Ari Hausman-Cohen784c8492016-07-06 13:28:53 -0700396
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700397 result.frame_number = request->frame_number;
Ari Hausman-Cohen2934eb92016-07-20 17:25:39 +0000398 // TODO: return actual captured/reprocessed settings
399 result.result = request->settings;
400 // TODO: asynchronously return results
401 notifyShutter(request->frame_number, 0);
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700402 mCallbackOps->process_capture_result(mCallbackOps, &result);
403
404 return 0;
Ari Hausman-Cohen2934eb92016-07-20 17:25:39 +0000405
406err_out:
407 delete [] result.output_buffers;
408 // TODO: this should probably be a total device failure; transient for now
409 return -EINVAL;
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700410}
411
412void Camera::setSettings(const camera_metadata_t *new_settings)
413{
414 if (mSettings != NULL) {
415 free_camera_metadata(mSettings);
416 mSettings = NULL;
417 }
418
419 if (new_settings != NULL)
420 mSettings = clone_camera_metadata(new_settings);
421}
422
423bool Camera::isValidReprocessSettings(const camera_metadata_t* /*settings*/)
424{
425 // TODO: reject settings that cannot be reprocessed
426 // input buffers unimplemented, use this to reject reprocessing requests
427 ALOGE("%s:%d: Input buffer reprocessing not implemented", __func__, mId);
428 return false;
429}
430
431int Camera::processCaptureBuffer(const camera3_stream_buffer_t *in,
432 camera3_stream_buffer_t *out)
433{
434 if (in->acquire_fence != -1) {
Ari Hausman-Cohen2934eb92016-07-20 17:25:39 +0000435 int res = sync_wait(in->acquire_fence, CAMERA_SYNC_TIMEOUT);
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700436 if (res == -ETIME) {
437 ALOGE("%s:%d: Timeout waiting on buffer acquire fence",
438 __func__, mId);
439 return res;
440 } else if (res) {
441 ALOGE("%s:%d: Error waiting on buffer acquire fence: %s(%d)",
442 __func__, mId, strerror(-res), res);
443 return res;
444 }
445 }
446
447 out->stream = in->stream;
448 out->buffer = in->buffer;
449 out->status = CAMERA3_BUFFER_STATUS_OK;
450 // TODO: use driver-backed release fences
451 out->acquire_fence = -1;
452 out->release_fence = -1;
Ari Hausman-Cohen2934eb92016-07-20 17:25:39 +0000453
454 // TODO: lock and software-paint buffer
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700455 return 0;
456}
457
458void Camera::notifyShutter(uint32_t frame_number, uint64_t timestamp)
459{
460 int res;
461 struct timespec ts;
462
463 // If timestamp is 0, get timestamp from right now instead
464 if (timestamp == 0) {
465 ALOGW("%s:%d: No timestamp provided, using CLOCK_BOOTTIME",
466 __func__, mId);
467 res = clock_gettime(CLOCK_BOOTTIME, &ts);
468 if (res == 0) {
469 timestamp = ts.tv_sec * 1000000000ULL + ts.tv_nsec;
470 } else {
471 ALOGE("%s:%d: No timestamp and failed to get CLOCK_BOOTTIME %s(%d)",
472 __func__, mId, strerror(errno), errno);
473 }
474 }
475 camera3_notify_msg_t m;
476 memset(&m, 0, sizeof(m));
477 m.type = CAMERA3_MSG_SHUTTER;
478 m.message.shutter.frame_number = frame_number;
479 m.message.shutter.timestamp = timestamp;
480 mCallbackOps->notify(mCallbackOps, &m);
481}
482
483void Camera::dump(int fd)
484{
485 ALOGV("%s:%d: Dumping to fd %d", __func__, mId, fd);
486 ATRACE_CALL();
487 android::Mutex::Autolock al(mDeviceLock);
488
489 dprintf(fd, "Camera ID: %d (Busy: %d)\n", mId, mBusy);
490
491 // TODO: dump all settings
492 dprintf(fd, "Most Recent Settings: (%p)\n", mSettings);
493
494 dprintf(fd, "Number of streams: %d\n", mNumStreams);
495 for (int i = 0; i < mNumStreams; i++) {
496 dprintf(fd, "Stream %d/%d:\n", i, mNumStreams);
497 mStreams[i]->dump(fd);
498 }
499}
500
501const char* Camera::templateToString(int type)
502{
503 switch (type) {
504 case CAMERA3_TEMPLATE_PREVIEW:
505 return "CAMERA3_TEMPLATE_PREVIEW";
506 case CAMERA3_TEMPLATE_STILL_CAPTURE:
507 return "CAMERA3_TEMPLATE_STILL_CAPTURE";
508 case CAMERA3_TEMPLATE_VIDEO_RECORD:
509 return "CAMERA3_TEMPLATE_VIDEO_RECORD";
510 case CAMERA3_TEMPLATE_VIDEO_SNAPSHOT:
511 return "CAMERA3_TEMPLATE_VIDEO_SNAPSHOT";
512 case CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG:
513 return "CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG";
514 }
515 // TODO: support vendor templates
516 return "Invalid template type!";
517}
518
Ari Hausman-Cohen900c1e32016-06-20 16:52:41 -0700519int Camera::setTemplate(int type, const camera_metadata_t *settings)
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700520{
521 android::Mutex::Autolock al(mDeviceLock);
522
523 if (!isValidTemplateType(type)) {
524 ALOGE("%s:%d: Invalid template request type: %d", __func__, mId, type);
525 return -EINVAL;
526 }
527
528 if (mTemplates[type] != NULL) {
529 ALOGE("%s:%d: Setting already constructed template type %s(%d)",
530 __func__, mId, templateToString(type), type);
531 return -EINVAL;
532 }
533
534 // Make a durable copy of the underlying metadata
535 mTemplates[type] = clone_camera_metadata(settings);
536 if (mTemplates[type] == NULL) {
537 ALOGE("%s:%d: Failed to clone metadata %p for template type %s(%d)",
538 __func__, mId, settings, templateToString(type), type);
539 return -EINVAL;
540 }
541 return 0;
542}
543
544extern "C" {
545// Get handle to camera from device priv data
546static Camera *camdev_to_camera(const camera3_device_t *dev)
547{
548 return reinterpret_cast<Camera*>(dev->priv);
549}
550
551static int initialize(const camera3_device_t *dev,
552 const camera3_callback_ops_t *callback_ops)
553{
554 return camdev_to_camera(dev)->initialize(callback_ops);
555}
556
557static int configure_streams(const camera3_device_t *dev,
558 camera3_stream_configuration_t *stream_list)
559{
560 return camdev_to_camera(dev)->configureStreams(stream_list);
561}
562
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700563static const camera_metadata_t *construct_default_request_settings(
564 const camera3_device_t *dev, int type)
565{
566 return camdev_to_camera(dev)->constructDefaultRequestSettings(type);
567}
568
569static int process_capture_request(const camera3_device_t *dev,
570 camera3_capture_request_t *request)
571{
572 return camdev_to_camera(dev)->processCaptureRequest(request);
573}
574
575static void dump(const camera3_device_t *dev, int fd)
576{
577 camdev_to_camera(dev)->dump(fd);
578}
579
580static int flush(const camera3_device_t*)
581{
Ari Hausman-Cohen72fddb32016-06-30 16:53:31 -0700582 // TODO(b/29937783)
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700583 ALOGE("%s: unimplemented.", __func__);
584 return -1;
585}
586
587} // extern "C"
588
589const camera3_device_ops_t Camera::sOps = {
590 .initialize = default_camera_hal::initialize,
591 .configure_streams = default_camera_hal::configure_streams,
Ari Hausman-Cohen900c1e32016-06-20 16:52:41 -0700592 .register_stream_buffers = nullptr,
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700593 .construct_default_request_settings
594 = default_camera_hal::construct_default_request_settings,
595 .process_capture_request = default_camera_hal::process_capture_request,
Ari Hausman-Cohen72fddb32016-06-30 16:53:31 -0700596 .get_metadata_vendor_tag_ops = nullptr,
Ari Hausman-Cohen73442152016-06-08 15:50:49 -0700597 .dump = default_camera_hal::dump,
598 .flush = default_camera_hal::flush,
599 .reserved = {0},
600};
601
602} // namespace default_camera_hal