blob: 6fecf22f9c522c5ecc7dad57a4fc136a81d8904a
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 | |
18 | #define LOG_TAG "CAMHAL_CameraParameters" |
19 | #include "CameraHal.h" |
20 | #include "CameraProperties.h" |
21 | |
22 | namespace android { |
23 | |
24 | const char CameraProperties::INVALID[]="prop-invalid-key"; |
25 | const char CameraProperties::CAMERA_NAME[]="prop-camera-name"; |
26 | const char CameraProperties::CAMERA_SENSOR_INDEX[]="prop-sensor-index"; |
27 | const char CameraProperties::ORIENTATION_INDEX[]="prop-orientation"; |
28 | const char CameraProperties::FACING_INDEX[]="prop-facing"; |
29 | const char CameraProperties::S3D_SUPPORTED[]="prop-s3d-supported"; |
30 | const char CameraProperties::SUPPORTED_PREVIEW_SIZES[] = "prop-preview-size-values"; |
31 | const char CameraProperties::SUPPORTED_PREVIEW_FORMATS[] = "prop-preview-format-values"; |
32 | const char CameraProperties::SUPPORTED_PREVIEW_FRAME_RATES[] = "prop-preview-frame-rate-values"; |
33 | const char CameraProperties::SUPPORTED_PICTURE_SIZES[] = "prop-picture-size-values"; |
34 | const char CameraProperties::SUPPORTED_PICTURE_FORMATS[] = "prop-picture-format-values"; |
35 | const char CameraProperties::SUPPORTED_THUMBNAIL_SIZES[] = "prop-jpeg-thumbnail-size-values"; |
36 | const char CameraProperties::SUPPORTED_WHITE_BALANCE[] = "prop-whitebalance-values"; |
37 | const char CameraProperties::SUPPORTED_EFFECTS[] = "prop-effect-values"; |
38 | const char CameraProperties::SUPPORTED_ANTIBANDING[] = "prop-antibanding-values"; |
39 | const char CameraProperties::SUPPORTED_EXPOSURE_MODES[] = "prop-exposure-mode-values"; |
40 | const char CameraProperties::SUPPORTED_EV_MAX[] = "prop-ev-compensation-max"; |
41 | const char CameraProperties::SUPPORTED_EV_MIN[] = "prop-ev-compensation-min"; |
42 | const char CameraProperties::SUPPORTED_EV_STEP[] = "prop-ev-compensation-step"; |
43 | const char CameraProperties::SUPPORTED_ISO_VALUES[] = "prop-iso-mode-values"; |
44 | const char CameraProperties::SUPPORTED_SCENE_MODES[] = "prop-scene-mode-values"; |
45 | const char CameraProperties::SUPPORTED_FLASH_MODES[] = "prop-flash-mode-values"; |
46 | const char CameraProperties::SUPPORTED_FOCUS_MODES[] = "prop-focus-mode-values"; |
47 | const char CameraProperties::REQUIRED_PREVIEW_BUFS[] = "prop-required-preview-bufs"; |
48 | const char CameraProperties::REQUIRED_IMAGE_BUFS[] = "prop-required-image-bufs"; |
49 | const char CameraProperties::SUPPORTED_ZOOM_RATIOS[] = "prop-zoom-ratios"; |
50 | const char CameraProperties::SUPPORTED_ZOOM_STAGES[] = "prop-zoom-stages"; |
51 | const char CameraProperties::SUPPORTED_IPP_MODES[] = "prop-ipp-values"; |
52 | const char CameraProperties::SMOOTH_ZOOM_SUPPORTED[] = "prop-smooth-zoom-supported"; |
53 | const char CameraProperties::ZOOM_SUPPORTED[] = "prop-zoom-supported"; |
54 | const char CameraProperties::PREVIEW_SIZE[] = "prop-preview-size-default"; |
55 | const char CameraProperties::PREVIEW_FORMAT[] = "prop-preview-format-default"; |
56 | const char CameraProperties::PREVIEW_FRAME_RATE[] = "prop-preview-frame-rate-default"; |
57 | const char CameraProperties::ZOOM[] = "prop-zoom-default"; |
58 | const char CameraProperties::PICTURE_SIZE[] = "prop-picture-size-default"; |
59 | const char CameraProperties::PICTURE_FORMAT[] = "prop-picture-format-default"; |
60 | const char CameraProperties::JPEG_THUMBNAIL_SIZE[] = "prop-jpeg-thumbnail-size-default"; |
61 | const char CameraProperties::WHITEBALANCE[] = "prop-whitebalance-default"; |
62 | const char CameraProperties::EFFECT[] = "prop-effect-default"; |
63 | const char CameraProperties::ANTIBANDING[] = "prop-antibanding-default"; |
64 | const char CameraProperties::EXPOSURE_MODE[] = "prop-exposure-mode-default"; |
65 | const char CameraProperties::EV_COMPENSATION[] = "prop-ev-compensation-default"; |
66 | const char CameraProperties::ISO_MODE[] = "prop-iso-mode-default"; |
67 | const char CameraProperties::FOCUS_MODE[] = "prop-focus-mode-default"; |
68 | const char CameraProperties::SCENE_MODE[] = "prop-scene-mode-default"; |
69 | const char CameraProperties::FLASH_MODE[] = "prop-flash-mode-default"; |
70 | const char CameraProperties::JPEG_QUALITY[] = "prop-jpeg-quality-default"; |
71 | const char CameraProperties::CONTRAST[] = "prop-contrast-default"; |
72 | const char CameraProperties::BRIGHTNESS[] = "prop-brightness-default"; |
73 | const char CameraProperties::SATURATION[] = "prop-saturation-default"; |
74 | const char CameraProperties::SHARPNESS[] = "prop-sharpness-default"; |
75 | const char CameraProperties::IPP[] = "prop-ipp-default"; |
76 | const char CameraProperties::GBCE[] = "prop-gbce-default"; |
77 | const char CameraProperties::S3D2D_PREVIEW[] = "prop-s3d2d-preview"; |
78 | const char CameraProperties::S3D2D_PREVIEW_MODES[] = "prop-s3d2d-preview-values"; |
79 | const char CameraProperties::AUTOCONVERGENCE[] = "prop-auto-convergence"; |
80 | const char CameraProperties::AUTOCONVERGENCE_MODE[] = "prop-auto-convergence-mode"; |
81 | const char CameraProperties::MANUALCONVERGENCE_VALUES[] = "prop-manual-convergence-values"; |
82 | const char CameraProperties::VSTAB[] = "prop-vstab-default"; |
83 | const char CameraProperties::VSTAB_SUPPORTED[] = "prop-vstab-supported"; |
84 | const char CameraProperties::REVISION[] = "prop-revision"; |
85 | const char CameraProperties::FOCAL_LENGTH[] = "prop-focal-length"; |
86 | const char CameraProperties::HOR_ANGLE[] = "prop-horizontal-angle"; |
87 | const char CameraProperties::VER_ANGLE[] = "prop-vertical-angle"; |
88 | const char CameraProperties::FRAMERATE_RANGE[] = "prop-framerate-range-default"; |
89 | const char CameraProperties::FRAMERATE_RANGE_IMAGE[] = "prop-framerate-range-image-default"; |
90 | const char CameraProperties::FRAMERATE_RANGE_VIDEO[]="prop-framerate-range-video-default"; |
91 | const char CameraProperties::FRAMERATE_RANGE_SUPPORTED[]="prop-framerate-range-values"; |
92 | const char CameraProperties::SENSOR_ORIENTATION[]= "sensor-orientation"; |
93 | const char CameraProperties::SENSOR_ORIENTATION_VALUES[]= "sensor-orientation-values"; |
94 | const char CameraProperties::EXIF_MAKE[] = "prop-exif-make"; |
95 | const char CameraProperties::EXIF_MODEL[] = "prop-exif-model"; |
96 | const char CameraProperties::JPEG_THUMBNAIL_QUALITY[] = "prop-jpeg-thumbnail-quality-default"; |
97 | const char CameraProperties::MAX_FOCUS_AREAS[] = "prop-max-focus-areas"; |
98 | const char CameraProperties::MAX_FD_HW_FACES[] = "prop-max-fd-hw-faces"; |
99 | const char CameraProperties::MAX_FD_SW_FACES[] = "prop-max-fd-sw-faces"; |
100 | const char CameraProperties::AUTO_EXPOSURE_LOCK[] = "prop-auto-exposure-lock"; |
101 | const char CameraProperties::AUTO_EXPOSURE_LOCK_SUPPORTED[] = "prop-auto-exposure-lock-supported"; |
102 | const char CameraProperties::AUTO_WHITEBALANCE_LOCK[] = "prop-auto-whitebalance-lock"; |
103 | const char CameraProperties::AUTO_WHITEBALANCE_LOCK_SUPPORTED[] = "prop-auto-whitebalance-lock-supported"; |
104 | const char CameraProperties::MAX_NUM_METERING_AREAS[] = "prop-max-num-metering-areas"; |
105 | const char CameraProperties::METERING_AREAS[] = "prop-metering-areas"; |
106 | const char CameraProperties::VIDEO_SNAPSHOT_SUPPORTED[] = "prop-video-snapshot-supported"; |
107 | const char CameraProperties::VIDEO_SIZE[] = "video-size"; |
108 | const char CameraProperties::SUPPORTED_VIDEO_SIZES[] = "prop-video-size-values"; |
109 | const char CameraProperties::PREFERRED_PREVIEW_SIZE_FOR_VIDEO[] = "preferred-preview-size-for-video"; |
110 | |
111 | const char CameraProperties::PIXEL_FORMAT_RGB24[] = "rgb24"; |
112 | const char CameraProperties::RELOAD_WHEN_OPEN[]="prop-reload-key"; |
113 | #ifdef AMLOGIC_VIRTUAL_CAMERA_SUPPORT |
114 | const char CameraProperties::DEVICE_NAME[] = "device_name"; |
115 | #endif |
116 | |
117 | const char CameraProperties::DEFAULT_VALUE[] = ""; |
118 | |
119 | const char CameraProperties::PARAMS_DELIMITER []= ","; |
120 | |
121 | // Returns the properties class for a specific Camera |
122 | // Each value is indexed by the CameraProperties::CameraPropertyIndex enum |
123 | int CameraProperties::getProperties(int cameraIndex, CameraProperties::Properties** properties) |
124 | { |
125 | LOG_FUNCTION_NAME; |
126 | |
127 | //LOGD("%s %d cameraIndex=%d mCamerasSupported=%d", __func__, __LINE__, cameraIndex, mCamerasSupported); |
128 | if((unsigned int)cameraIndex >= mCamerasSupported) |
129 | { |
130 | LOG_FUNCTION_NAME_EXIT; |
131 | return -EINVAL; |
132 | } |
133 | |
134 | *properties = mCameraProps+cameraIndex; |
135 | |
136 | LOG_FUNCTION_NAME_EXIT; |
137 | return 0; |
138 | } |
139 | |
140 | ssize_t CameraProperties::Properties::set(const char *prop, const char *value) |
141 | { |
142 | if(!prop) |
143 | return -EINVAL; |
144 | if(!value) |
145 | value = DEFAULT_VALUE; |
146 | |
147 | return mProperties->replaceValueFor(String8(prop), String8(value)); |
148 | } |
149 | |
150 | ssize_t CameraProperties::Properties::set(const char *prop, int value) |
151 | { |
152 | char s_val[30]; |
153 | |
154 | sprintf(s_val, "%d", value); |
155 | |
156 | return set(prop, s_val); |
157 | } |
158 | |
159 | const char* CameraProperties::Properties::get(const char * prop) |
160 | { |
161 | String8 value = mProperties->valueFor(String8(prop)); |
162 | return value.string(); |
163 | } |
164 | |
165 | void CameraProperties::Properties::dump() |
166 | { |
167 | for (size_t i = 0; i < mProperties->size(); i++) |
168 | { |
169 | CAMHAL_LOGVB("%s = %s\n", |
170 | mProperties->keyAt(i).string(), |
171 | mProperties->valueAt(i).string()); |
172 | } |
173 | } |
174 | |
175 | const char* CameraProperties::Properties::keyAt(unsigned int index) |
176 | { |
177 | if(index < mProperties->size()) |
178 | { |
179 | return mProperties->keyAt(index).string(); |
180 | } |
181 | return NULL; |
182 | } |
183 | |
184 | const char* CameraProperties::Properties::valueAt(unsigned int index) |
185 | { |
186 | if(index < mProperties->size()) |
187 | { |
188 | return mProperties->valueAt(index).string(); |
189 | } |
190 | return NULL; |
191 | } |
192 | |
193 | }; |
194 |