blob: d3bd65dbb0dbe057c9e180a63ca2c4ebfcb6dc0a [file] [log] [blame]
Zvikomborero VIncent Zvikaramba93777912016-07-24 00:51:04 -04001/*
2 * Copyright (C) 2014, The CyanogenMod 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/**
18* @file CameraWrapper.cpp
19*
20* This file wraps a vendor camera module.
21*
22*/
23
Zvikomborero VIncent Zvikaramba9d515802016-08-18 13:51:48 -040024#define LOG_NDEBUG 0
Zvikomborero VIncent Zvikaramba93777912016-07-24 00:51:04 -040025
26#define LOG_TAG "CameraWrapper"
27#include <cutils/log.h>
28
29#include <utils/threads.h>
30#include <utils/String8.h>
31#include <hardware/hardware.h>
32#include <hardware/camera.h>
33#include <camera/Camera.h>
34#include <camera/CameraParameters.h>
35
36static android::Mutex gCameraWrapperLock;
37static camera_module_t *gVendorModule = 0;
38
39static char **fixed_set_params = NULL;
40
41static int camera_device_open(const hw_module_t *module, const char *name,
42 hw_device_t **device);
43static int camera_get_number_of_cameras(void);
44static int camera_get_camera_info(int camera_id, struct camera_info *info);
45static int camera_send_command(struct camera_device *device, int32_t cmd,
46 int32_t arg1, int32_t arg2);
47
48static struct hw_module_methods_t camera_module_methods = {
Zvikomborero VIncent Zvikaramba9d515802016-08-18 13:51:48 -040049 .open = camera_device_open
Zvikomborero VIncent Zvikaramba93777912016-07-24 00:51:04 -040050};
51
52camera_module_t HAL_MODULE_INFO_SYM = {
53 .common = {
54 .tag = HARDWARE_MODULE_TAG,
55 .module_api_version = CAMERA_MODULE_API_VERSION_1_0,
56 .hal_api_version = HARDWARE_HAL_API_VERSION,
57 .id = CAMERA_HARDWARE_MODULE_ID,
58 .name = "Samsung MSM8916 Camera Wrapper",
59 .author = "The CyanogenMod Project",
60 .methods = &camera_module_methods,
61 .dso = NULL, /* remove compilation warnings */
62 .reserved = {0}, /* remove compilation warnings */
63 },
Zvikomborero VIncent Zvikaramba93777912016-07-24 00:51:04 -040064 .get_number_of_cameras = camera_get_number_of_cameras,
65 .get_camera_info = camera_get_camera_info,
66 .set_callbacks = NULL, /* remove compilation warnings */
67 .get_vendor_tag_ops = NULL, /* remove compilation warnings */
68 .open_legacy = NULL, /* remove compilation warnings */
69 .reserved = {0}, /* remove compilation warnings */
70};
71
72typedef struct wrapper_camera_device {
73 camera_device_t base;
74 int id;
75 camera_device_t *vendor;
76} wrapper_camera_device_t;
77
78#define VENDOR_CALL(device, func, ...) ({ \
79 wrapper_camera_device_t *__wrapper_dev = (wrapper_camera_device_t*) device; \
80 __wrapper_dev->vendor->ops->func(__wrapper_dev->vendor, ##__VA_ARGS__); \
81})
82
83#define CAMERA_ID(device) (((wrapper_camera_device_t *)(device))->id)
84
85static int check_vendor_module()
86{
87 int rv = 0;
88 ALOGV("%s", __FUNCTION__);
89
90 if (gVendorModule)
91 return 0;
92
93 rv = hw_get_module_by_class("camera", "vendor",
94 (const hw_module_t**)&gVendorModule);
95 if (rv)
96 ALOGE("failed to open vendor camera module");
97 return rv;
98}
99
Zvikomborero VIncent Zvikaramba93777912016-07-24 00:51:04 -0400100#define KEY_VIDEO_HFR_VALUES "video-hfr-values"
101
Zvikomborero VIncent Zvikarambaa0af1ff2016-08-19 20:50:50 -0400102const static char * iso_values[] = {"auto,ISO_HJR,ISO100,ISO200,ISO400,ISO800,ISO1600,auto"};
Zvikomborero VIncent Zvikaramba93777912016-07-24 00:51:04 -0400103
104static char *camera_fixup_getparams(int id, const char *settings)
105{
106 android::CameraParameters params;
107 params.unflatten(android::String8(settings));
108
109#if !LOG_NDEBUG
110 ALOGV("%s: original parameters:", __FUNCTION__);
111 params.dump();
112#endif
113
114 // fix params here
Zvikomborero VIncent Zvikaramba9d515802016-08-18 13:51:48 -0400115 params.set(android::CameraParameters::KEY_SUPPORTED_ISO_MODES, iso_values[id]);
Zvikomborero VIncent Zvikaramba93777912016-07-24 00:51:04 -0400116 params.set(android::CameraParameters::KEY_EXPOSURE_COMPENSATION_STEP, "0.5");
Zvikomborero VIncent Zvikaramba9d515802016-08-18 13:51:48 -0400117 params.set(android::CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION, "-2");
118 params.set(android::CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION, "2");
119
Zvikomborero VIncent Zvikaramba93777912016-07-24 00:51:04 -0400120 /* If the vendor has HFR values but doesn't also expose that
121 * this can be turned off, fixup the params to tell the Camera
122 * that it really is okay to turn it off.
123 */
124 const char *hfrValues = params.get(KEY_VIDEO_HFR_VALUES);
125 if (hfrValues && *hfrValues && ! strstr(hfrValues, "off")) {
126 char tmp[strlen(hfrValues) + 4 + 1];
127 sprintf(tmp, "%s,off", hfrValues);
128 params.set(KEY_VIDEO_HFR_VALUES, tmp);
129 }
Zvikomborero VIncent Zvikaramba9d515802016-08-18 13:51:48 -0400130
131 params.set("whitebalance-values", "auto,incandescent,fluorescent,daylight,cloudy-daylight");
132 params.set("effect-values", "none,mono,negative,sepia");
Zvikomborero VIncent Zvikaramba93777912016-07-24 00:51:04 -0400133
134 android::String8 strParams = params.flatten();
135 char *ret = strdup(strParams.string());
136
137#if !LOG_NDEBUG
138 ALOGV("%s: fixed parameters:", __FUNCTION__);
139 params.dump();
140#endif
141
142 return ret;
143}
144
145static char *camera_fixup_setparams(struct camera_device *device, const char *settings)
146{
147 int id = CAMERA_ID(device);
148 android::CameraParameters params;
149 params.unflatten(android::String8(settings));
150
151#if !LOG_NDEBUG
152 ALOGV("%s: original parameters:", __FUNCTION__);
153 params.dump();
154#endif
155
Zvikomborero VIncent Zvikaramba9d515802016-08-18 13:51:48 -0400156 // No need to fix-up ISO_HJR, it is the same for userspace and the camera lib
157 if (params.get("iso")) {
158 const char *isoMode = params.get(android::CameraParameters::KEY_ISO_MODE);
159 if (strcmp(isoMode, "ISO100") == 0)
160 params.set(android::CameraParameters::KEY_ISO_MODE, "100");
161 else if (strcmp(isoMode, "ISO200") == 0)
162 params.set(android::CameraParameters::KEY_ISO_MODE, "200");
163 else if (strcmp(isoMode, "ISO400") == 0)
164 params.set(android::CameraParameters::KEY_ISO_MODE, "400");
165 else if (strcmp(isoMode, "ISO800") == 0)
166 params.set(android::CameraParameters::KEY_ISO_MODE, "800");
Zvikomborero VIncent Zvikarambaa0af1ff2016-08-19 20:50:50 -0400167 else if (strcmp(isoMode, "ISO1600") == 0)
168 params.set(android::CameraParameters::KEY_ISO_MODE, "1600");
Zvikomborero VIncent Zvikaramba9d515802016-08-18 13:51:48 -0400169 }
170
171 // fix params here
172 int video_width, video_height;
173 params.getPreviewSize(&video_width, &video_height);
174 if(video_width*video_height <= 960*540){
Zvikomborero VIncent Zvikaramba93777912016-07-24 00:51:04 -0400175 params.set("preview-format", "yuv420p");
176 }
Zvikomborero VIncent Zvikaramba9d515802016-08-18 13:51:48 -0400177
178 params.set("scene-detect", "off");
179
180 bool isVideo = false;
181 if (params.get(android::CameraParameters::KEY_RECORDING_HINT))
182 isVideo = !strcmp(params.get(android::CameraParameters::KEY_RECORDING_HINT), "true");
Zvikomborero VIncent Zvikaramba93777912016-07-24 00:51:04 -0400183
Zvikomborero VIncent Zvikaramba9d515802016-08-18 13:51:48 -0400184 if (id == 0) {
185 int camMode;
186 if (params.get(android::CameraParameters::KEY_SAMSUNG_CAMERA_MODE)) {
187 camMode = params.getInt(android::CameraParameters::KEY_SAMSUNG_CAMERA_MODE);
188 } else {
189 camMode = -1;
190 }
Zvikomborero VIncent Zvikaramba93777912016-07-24 00:51:04 -0400191
Zvikomborero VIncent Zvikaramba9d515802016-08-18 13:51:48 -0400192 if (camMode == -1) {
193 params.set(android::CameraParameters::KEY_SAMSUNG_CAMERA_MODE, "1");
194 } else {
195 params.set(android::CameraParameters::KEY_SAMSUNG_CAMERA_MODE, isVideo ? "1" : "0");
196 }
197 }
198
Zvikomborero VIncent Zvikaramba93777912016-07-24 00:51:04 -0400199 android::String8 strParams = params.flatten();
200
201 if (fixed_set_params[id])
202 free(fixed_set_params[id]);
203 fixed_set_params[id] = strdup(strParams.string());
204 char *ret = fixed_set_params[id];
205
206#if !LOG_NDEBUG
207 ALOGV("%s: fixed parameters:", __FUNCTION__);
208 params.dump();
209#endif
210
211 return ret;
212}
213
214/*******************************************************************
215 * implementation of camera_device_ops functions
216 *******************************************************************/
217
218static int camera_set_preview_window(struct camera_device *device,
219 struct preview_stream_ops *window)
220{
221 ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
222 (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
223
224 if (!device)
225 return -EINVAL;
226
227 return VENDOR_CALL(device, set_preview_window, window);
228}
229
230static void camera_set_callbacks(struct camera_device *device,
231 camera_notify_callback notify_cb,
232 camera_data_callback data_cb,
233 camera_data_timestamp_callback data_cb_timestamp,
234 camera_request_memory get_memory,
235 void *user)
236{
237 ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
238 (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
239
240 if (!device)
241 return;
242
243 VENDOR_CALL(device, set_callbacks, notify_cb, data_cb, data_cb_timestamp,
244 get_memory, user);
245}
246
247static void camera_enable_msg_type(struct camera_device *device,
248 int32_t msg_type)
249{
250 ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
251 (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
252
253 if (!device)
254 return;
255
256 VENDOR_CALL(device, enable_msg_type, msg_type);
257}
258
259static void camera_disable_msg_type(struct camera_device *device,
260 int32_t msg_type)
261{
262 ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
263 (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
264
265 if (!device)
266 return;
267
268 VENDOR_CALL(device, disable_msg_type, msg_type);
269}
270
271static int camera_msg_type_enabled(struct camera_device *device,
272 int32_t msg_type)
273{
274 ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
275 (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
276
277 if (!device)
278 return 0;
279
280 return VENDOR_CALL(device, msg_type_enabled, msg_type);
281}
282
283static int camera_start_preview(struct camera_device *device)
284{
285 ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
286 (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
287
288 if (!device)
289 return -EINVAL;
290
291 return VENDOR_CALL(device, start_preview);
292}
293
294static void camera_stop_preview(struct camera_device *device)
295{
296 ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
297 (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
298
299 if (!device)
300 return;
301
302 VENDOR_CALL(device, stop_preview);
303}
304
305static int camera_preview_enabled(struct camera_device *device)
306{
307 ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
308 (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
309
310 if (!device)
311 return -EINVAL;
312
313 return VENDOR_CALL(device, preview_enabled);
314}
315
316static int camera_store_meta_data_in_buffers(struct camera_device *device,
317 int enable)
318{
319 ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
320 (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
321
322 if (!device)
323 return -EINVAL;
324
325 return VENDOR_CALL(device, store_meta_data_in_buffers, enable);
326}
327
328static int camera_start_recording(struct camera_device *device)
329{
330 ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
331 (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
332
333 if (!device)
334 return EINVAL;
335
336 return VENDOR_CALL(device, start_recording);
337}
338
339static void camera_stop_recording(struct camera_device *device)
340{
341 ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
342 (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
343
344 if (!device)
345 return;
346
347 VENDOR_CALL(device, stop_recording);
348}
349
350static int camera_recording_enabled(struct camera_device *device)
351{
352 ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
353 (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
354
355 if (!device)
356 return -EINVAL;
357
358 return VENDOR_CALL(device, recording_enabled);
359}
360
361static void camera_release_recording_frame(struct camera_device *device,
362 const void *opaque)
363{
364 ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
365 (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
366
367 if (!device)
368 return;
369
370 VENDOR_CALL(device, release_recording_frame, opaque);
371}
372
373static int camera_auto_focus(struct camera_device *device)
374{
375 ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
376 (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
377
378 if (!device)
379 return -EINVAL;
380
381 return VENDOR_CALL(device, auto_focus);
382}
383
384static int camera_cancel_auto_focus(struct camera_device *device)
385{
386 ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
387 (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
388
389 if (!device)
390 return -EINVAL;
391
392 return VENDOR_CALL(device, cancel_auto_focus);
393}
394
395static int camera_take_picture(struct camera_device *device)
396{
397 ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
398 (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
399
400 if (!device)
401 return -EINVAL;
402
403 return VENDOR_CALL(device, take_picture);
404}
405
406static int camera_cancel_picture(struct camera_device *device)
407{
408 ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
409 (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
410
411 if (!device)
412 return -EINVAL;
413
414 return VENDOR_CALL(device, cancel_picture);
415}
416
417static int camera_set_parameters(struct camera_device *device,
418 const char *params)
419{
420 ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
421 (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
422
423 if (!device)
424 return -EINVAL;
425
426 char *tmp = NULL;
427 tmp = camera_fixup_setparams(device, params);
428
429 int ret = VENDOR_CALL(device, set_parameters, tmp);
430 return ret;
431}
432
433static char *camera_get_parameters(struct camera_device *device)
434{
435 ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
436 (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
437
438 if (!device)
439 return NULL;
440
441 char *params = VENDOR_CALL(device, get_parameters);
442
443 char *tmp = camera_fixup_getparams(CAMERA_ID(device), params);
444 VENDOR_CALL(device, put_parameters, params);
445 params = tmp;
446
447 return params;
448}
449
450static void camera_put_parameters(struct camera_device *device, char *params)
451{
452 ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
453 (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
454
455 if (params)
456 free(params);
457}
458
459static int camera_send_command(struct camera_device *device,
460 int32_t cmd, int32_t arg1, int32_t arg2)
461{
462 ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
463 (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
464
465 if (!device)
466 return -EINVAL;
467
468 return VENDOR_CALL(device, send_command, cmd, arg1, arg2);
469}
470
471static void camera_release(struct camera_device *device)
472{
473 ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
474 (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
475
476 if (!device)
477 return;
478
479 VENDOR_CALL(device, release);
480}
481
482static int camera_dump(struct camera_device *device, int fd)
483{
484 ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
485 (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
486
487 if (!device)
488 return -EINVAL;
489
490 return VENDOR_CALL(device, dump, fd);
491}
492
493extern "C" void heaptracker_free_leaked_memory(void);
494
495static int camera_device_close(hw_device_t *device)
496{
497 int ret = 0;
498 wrapper_camera_device_t *wrapper_dev = NULL;
499
500 ALOGV("%s", __FUNCTION__);
501
502 android::Mutex::Autolock lock(gCameraWrapperLock);
503
504 if (!device) {
505 ret = -EINVAL;
506 goto done;
507 }
508
509 for (int i = 0; i < camera_get_number_of_cameras(); i++) {
510 if (fixed_set_params[i])
511 free(fixed_set_params[i]);
512 }
513
514 wrapper_dev = (wrapper_camera_device_t*) device;
515
516 wrapper_dev->vendor->common.close((hw_device_t*)wrapper_dev->vendor);
517 if (wrapper_dev->base.ops)
518 free(wrapper_dev->base.ops);
519 free(wrapper_dev);
520done:
521#ifdef HEAPTRACKER
522 heaptracker_free_leaked_memory();
523#endif
524 return ret;
525}
526
527/*******************************************************************
528 * implementation of camera_module functions
529 *******************************************************************/
530
531/* open device handle to one of the cameras
532 *
533 * assume camera service will keep singleton of each camera
534 * so this function will always only be called once per camera instance
535 */
536
537static int camera_device_open(const hw_module_t *module, const char *name,
538 hw_device_t **device)
539{
540 int rv = 0;
541 int num_cameras = 0;
542 int cameraid;
543 wrapper_camera_device_t *camera_device = NULL;
544 camera_device_ops_t *camera_ops = NULL;
545
546 android::Mutex::Autolock lock(gCameraWrapperLock);
547
548 ALOGV("%s", __FUNCTION__);
549
550 if (name != NULL) {
551 if (check_vendor_module())
552 return -EINVAL;
553
554 cameraid = atoi(name);
555 num_cameras = gVendorModule->get_number_of_cameras();
556
557 fixed_set_params = (char **) malloc(sizeof(char *) * num_cameras);
558 if (!fixed_set_params) {
559 ALOGE("parameter memory allocation fail");
560 rv = -ENOMEM;
561 goto fail;
562 }
563 memset(fixed_set_params, 0, sizeof(char *) * num_cameras);
564
565 if (cameraid > num_cameras) {
566 ALOGE("camera service provided cameraid out of bounds, "
567 "cameraid = %d, num supported = %d",
568 cameraid, num_cameras);
569 rv = -EINVAL;
570 goto fail;
571 }
572
573 camera_device = (wrapper_camera_device_t*)malloc(sizeof(*camera_device));
574 if (!camera_device) {
575 ALOGE("camera_device allocation fail");
576 rv = -ENOMEM;
577 goto fail;
578 }
579 memset(camera_device, 0, sizeof(*camera_device));
580 camera_device->id = cameraid;
581
582 rv = gVendorModule->common.methods->open(
583 (const hw_module_t*)gVendorModule, name,
584 (hw_device_t**)&(camera_device->vendor));
585 if (rv) {
586 ALOGE("vendor camera open fail");
587 goto fail;
588 }
589 ALOGV("%s: got vendor camera device 0x%08X",
590 __FUNCTION__, (uintptr_t)(camera_device->vendor));
591
592 camera_ops = (camera_device_ops_t*)malloc(sizeof(*camera_ops));
593 if (!camera_ops) {
594 ALOGE("camera_ops allocation fail");
595 rv = -ENOMEM;
596 goto fail;
597 }
598
599 memset(camera_ops, 0, sizeof(*camera_ops));
600
601 camera_device->base.common.tag = HARDWARE_DEVICE_TAG;
602 camera_device->base.common.version = HARDWARE_DEVICE_API_VERSION(1, 0);
603 camera_device->base.common.module = (hw_module_t *)(module);
604 camera_device->base.common.close = camera_device_close;
605 camera_device->base.ops = camera_ops;
606
607 camera_ops->set_preview_window = camera_set_preview_window;
608 camera_ops->set_callbacks = camera_set_callbacks;
609 camera_ops->enable_msg_type = camera_enable_msg_type;
610 camera_ops->disable_msg_type = camera_disable_msg_type;
611 camera_ops->msg_type_enabled = camera_msg_type_enabled;
612 camera_ops->start_preview = camera_start_preview;
613 camera_ops->stop_preview = camera_stop_preview;
614 camera_ops->preview_enabled = camera_preview_enabled;
615 camera_ops->store_meta_data_in_buffers = camera_store_meta_data_in_buffers;
616 camera_ops->start_recording = camera_start_recording;
617 camera_ops->stop_recording = camera_stop_recording;
618 camera_ops->recording_enabled = camera_recording_enabled;
619 camera_ops->release_recording_frame = camera_release_recording_frame;
620 camera_ops->auto_focus = camera_auto_focus;
621 camera_ops->cancel_auto_focus = camera_cancel_auto_focus;
622 camera_ops->take_picture = camera_take_picture;
623 camera_ops->cancel_picture = camera_cancel_picture;
624 camera_ops->set_parameters = camera_set_parameters;
625 camera_ops->get_parameters = camera_get_parameters;
626 camera_ops->put_parameters = camera_put_parameters;
627 camera_ops->send_command = camera_send_command;
628 camera_ops->release = camera_release;
629 camera_ops->dump = camera_dump;
630
631 *device = &camera_device->base.common;
632 }
633
634 return rv;
635
636fail:
637 if (camera_device) {
638 free(camera_device);
639 camera_device = NULL;
640 }
641 if (camera_ops) {
642 free(camera_ops);
643 camera_ops = NULL;
644 }
645 *device = NULL;
646 return rv;
647}
648
649static int camera_get_number_of_cameras(void)
650{
651 ALOGV("%s", __FUNCTION__);
652 if (check_vendor_module())
653 return 0;
654 return gVendorModule->get_number_of_cameras();
655}
656
657static int camera_get_camera_info(int camera_id, struct camera_info *info)
658{
659 ALOGV("%s", __FUNCTION__);
660 if (check_vendor_module())
661 return 0;
662 return gVendorModule->get_camera_info(camera_id, info);
663}