blob: 5ee7b48a76771e5fa43757184e820bb792101cd6
1 | /* |
2 | * Copyright (C) 2011 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 | //#define LOG_NDEBUG 0 |
18 | #define LOG_TAG "CameraProperties " |
19 | |
20 | //#include "CameraHal.h" |
21 | #include <utils/threads.h> |
22 | |
23 | #include "DebugUtils.h" |
24 | #include "CameraProperties.h" |
25 | |
26 | #define CAMERA_ROOT "CameraRoot" |
27 | #define CAMERA_INSTANCE "CameraInstance" |
28 | |
29 | namespace android { |
30 | |
31 | extern "C" int CameraAdapter_CameraNum(); |
32 | extern "C" void loadCaps(int camera_id, CameraProperties::Properties* params); |
33 | |
34 | /********************************************************* |
35 | CameraProperties - public function implemetation |
36 | **********************************************************/ |
37 | |
38 | CameraProperties::CameraProperties() : mCamerasSupported(0) |
39 | { |
40 | LOG_FUNCTION_NAME; |
41 | |
42 | mCamerasSupported = 0; |
43 | mInitialized = 0; |
44 | |
45 | LOG_FUNCTION_NAME_EXIT; |
46 | } |
47 | |
48 | CameraProperties::~CameraProperties() |
49 | { |
50 | LOG_FUNCTION_NAME; |
51 | |
52 | LOG_FUNCTION_NAME_EXIT; |
53 | } |
54 | |
55 | // Initializes the CameraProperties class |
56 | status_t CameraProperties::initialize(int cameraid) |
57 | { |
58 | LOG_FUNCTION_NAME; |
59 | |
60 | status_t ret = NO_ERROR; |
61 | |
62 | Mutex::Autolock lock(mLock); |
63 | |
64 | CAMHAL_LOGDB("%s, mCamerasSupported=%d\n", |
65 | mInitialized?"initialized":"no initialize", mCamerasSupported); |
66 | |
67 | if( !mInitialized ){ |
68 | |
69 | int temp = CameraAdapter_CameraNum(); |
70 | for ( int i = 0; i < temp; i++) { |
71 | mInitialized |= (1 << cameraid); |
72 | mCamerasSupported ++; |
73 | mCameraProps[i].set(CameraProperties::CAMERA_SENSOR_INDEX, i); |
74 | loadCaps(i, &mCameraProps[i]); |
75 | mCameraProps[i].dump(); |
76 | } |
77 | |
78 | }else{ |
79 | |
80 | if(!strcmp( mCameraProps[cameraid].get(CameraProperties::RELOAD_WHEN_OPEN), "1")){ |
81 | CAMHAL_LOGDB("cameraid %d reload\n", cameraid); |
82 | loadCaps(cameraid, &mCameraProps[cameraid]); |
83 | }else{ |
84 | CAMHAL_LOGDA("device don't need reload\n"); |
85 | } |
86 | |
87 | } |
88 | |
89 | LOG_FUNCTION_NAME_EXIT; |
90 | return ret; |
91 | |
92 | } |
93 | |
94 | extern "C" int CameraAdapter_Capabilities(CameraProperties::Properties* properties_array, |
95 | const unsigned int starting_camera, |
96 | const unsigned int camera_num); |
97 | |
98 | ///Loads all the Camera related properties |
99 | status_t CameraProperties::loadProperties() |
100 | { |
101 | LOG_FUNCTION_NAME; |
102 | |
103 | status_t ret = NO_ERROR; |
104 | CAMHAL_LOGDA("this func delete!!!\n"); |
105 | return ret; |
106 | } |
107 | |
108 | // Returns the number of Cameras found |
109 | int CameraProperties::camerasSupported() |
110 | { |
111 | LOG_FUNCTION_NAME; |
112 | return mCamerasSupported; |
113 | } |
114 | |
115 | }; |
116 |