blob: 16207aa689cf1248437fe8fd67050a40f10603ca [file] [log] [blame]
Yin-Chia Yehe074a932015-01-30 10:29:02 -08001/*
2 * Copyright (C) 2015 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#ifndef ANDROID_SERVERS_CAMERA_CAMERAMODULE_H
18#define ANDROID_SERVERS_CAMERA_CAMERAMODULE_H
19
20#include <hardware/camera.h>
21#include <camera/CameraMetadata.h>
22#include <utils/Mutex.h>
23
24/* This needs to be increased if we can have more cameras */
25#define MAX_CAMERAS_PER_MODULE 2
26
27
28namespace android {
29/**
30 * A wrapper class for HAL camera module.
31 *
32 * This class wraps camera_module_t returned from HAL to provide a wrapped
33 * get_camera_info implementation which CameraService generates some
34 * camera characteristics keys defined in newer HAL version on an older HAL.
35 */
36class CameraModule {
37public:
38 CameraModule(camera_module_t *module);
39
40 const hw_module_t* getRawModule();
41 int getCameraInfo(int cameraId, struct camera_info *info);
42 int getNumberOfCameras(void);
43 int open(const char* id, struct hw_device_t** device);
44 int openLegacy(const char* id, uint32_t halVersion, struct hw_device_t** device);
45 int setCallbacks(const camera_module_callbacks_t *callbacks);
46 bool isVendorTagDefined();
47 void getVendorTagOps(vendor_tag_ops_t* ops);
48 int setTorchMode(const char* camera_id, bool enable);
49
50private:
51 // Derive camera characteristics keys defined after HAL device version
52 static void deriveCameraCharacteristicsKeys(uint32_t deviceVersion, CameraMetadata &chars);
Chien-Yu Chend231fd62015-02-25 16:04:22 -080053 status_t filterOpenErrorCode(status_t err);
54
Yin-Chia Yehe074a932015-01-30 10:29:02 -080055 camera_module_t *mModule;
56 CameraMetadata mCameraCharacteristics[MAX_CAMERAS_PER_MODULE];
57 camera_info mCameraInfo[MAX_CAMERAS_PER_MODULE];
58 bool mCameraInfoCached[MAX_CAMERAS_PER_MODULE];
59 Mutex mCameraInfoLock;
60};
61
62} // namespace android
63
64#endif
65