1 /*
2 * Copyright (C) Texas Instruments - http://www.ti.com/
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 CameraProperties.cpp
19 *
20 * This file maps the CameraHardwareInterface to the Camera interfaces on OMAP4 (mainly OMX).
21 *
22 */
23
24 #include "CameraProperties.h"
25
26 namespace Ti {
27 namespace Camera {
28
29 const char CameraProperties::INVALID[]="prop-invalid-key";
30 const char CameraProperties::CAMERA_NAME[]="prop-camera-name";
31 const char CameraProperties::CAMERA_SENSOR_INDEX[]="prop-sensor-index";
32 const char CameraProperties::CAMERA_SENSOR_ID[] = "prop-sensor-id";
33 const char CameraProperties::ORIENTATION_INDEX[]="prop-orientation";
34 const char CameraProperties::FACING_INDEX[]="prop-facing";
35 const char CameraProperties::SUPPORTED_PREVIEW_SIZES[] = "prop-preview-size-values";
36 const char CameraProperties::SUPPORTED_PREVIEW_SUBSAMPLED_SIZES[] = "prop-preview-subsampled-size-values";
37 const char CameraProperties::SUPPORTED_PREVIEW_TOPBOTTOM_SIZES[] = "prop-preview-topbottom-size-values";
38 const char CameraProperties::SUPPORTED_PREVIEW_SIDEBYSIDE_SIZES[] = "prop-preview-sidebyside-size-values";
39 const char CameraProperties::SUPPORTED_PREVIEW_FORMATS[] = "prop-preview-format-values";
40 const char CameraProperties::SUPPORTED_PREVIEW_FRAME_RATES[] = "prop-preview-frame-rate-values";
41 const char CameraProperties::SUPPORTED_PREVIEW_FRAME_RATES_EXT[] = "prop-preview-frame-rate-ext-values";
42 const char CameraProperties::SUPPORTED_PICTURE_SIZES[] = "prop-picture-size-values";
43 const char CameraProperties::SUPPORTED_PICTURE_SUBSAMPLED_SIZES[] = "prop-picture-subsampled-size-values";
44 const char CameraProperties::SUPPORTED_PICTURE_TOPBOTTOM_SIZES[] = "prop-picture-topbottom-size-values";
45 const char CameraProperties::SUPPORTED_PICTURE_SIDEBYSIDE_SIZES[] = "prop-picture-sidebyside-size-values";
46 const char CameraProperties::SUPPORTED_PICTURE_FORMATS[] = "prop-picture-format-values";
47 const char CameraProperties::SUPPORTED_THUMBNAIL_SIZES[] = "prop-jpeg-thumbnail-size-values";
48 const char CameraProperties::SUPPORTED_WHITE_BALANCE[] = "prop-whitebalance-values";
49 const char CameraProperties::SUPPORTED_EFFECTS[] = "prop-effect-values";
50 const char CameraProperties::SUPPORTED_ANTIBANDING[] = "prop-antibanding-values";
51 const char CameraProperties::SUPPORTED_EXPOSURE_MODES[] = "prop-exposure-mode-values";
52 const char CameraProperties::SUPPORTED_MANUAL_EXPOSURE_MIN[] = "prop-manual-exposure-min";
53 const char CameraProperties::SUPPORTED_MANUAL_EXPOSURE_MAX[] = "prop-manual-exposure-max";
54 const char CameraProperties::SUPPORTED_MANUAL_EXPOSURE_STEP[] = "prop-manual-exposure-step";
55 const char CameraProperties::SUPPORTED_MANUAL_GAIN_ISO_MIN[] = "prop-manual-gain-iso-min";
56 const char CameraProperties::SUPPORTED_MANUAL_GAIN_ISO_MAX[] = "prop-manual-gain-iso-max";
57 const char CameraProperties::SUPPORTED_MANUAL_GAIN_ISO_STEP[] = "prop-manual-gain-iso-step";
58 const char CameraProperties::SUPPORTED_EV_MAX[] = "prop-ev-compensation-max";
59 const char CameraProperties::SUPPORTED_EV_MIN[] = "prop-ev-compensation-min";
60 const char CameraProperties::SUPPORTED_EV_STEP[] = "prop-ev-compensation-step";
61 const char CameraProperties::SUPPORTED_ISO_VALUES[] = "prop-iso-mode-values";
62 const char CameraProperties::SUPPORTED_SCENE_MODES[] = "prop-scene-mode-values";
63 const char CameraProperties::SUPPORTED_FLASH_MODES[] = "prop-flash-mode-values";
64 const char CameraProperties::SUPPORTED_FOCUS_MODES[] = "prop-focus-mode-values";
65 const char CameraProperties::REQUIRED_PREVIEW_BUFS[] = "prop-required-preview-bufs";
66 const char CameraProperties::REQUIRED_IMAGE_BUFS[] = "prop-required-image-bufs";
67 const char CameraProperties::SUPPORTED_ZOOM_RATIOS[] = "prop-zoom-ratios";
68 const char CameraProperties::SUPPORTED_ZOOM_STAGES[] = "prop-zoom-stages";
69 const char CameraProperties::SUPPORTED_IPP_MODES[] = "prop-ipp-values";
70 const char CameraProperties::SMOOTH_ZOOM_SUPPORTED[] = "prop-smooth-zoom-supported";
71 const char CameraProperties::ZOOM_SUPPORTED[] = "prop-zoom-supported";
72 const char CameraProperties::PREVIEW_SIZE[] = "prop-preview-size-default";
73 const char CameraProperties::PREVIEW_FORMAT[] = "prop-preview-format-default";
74 const char CameraProperties::PREVIEW_FRAME_RATE[] = "prop-preview-frame-rate-default";
75 const char CameraProperties::ZOOM[] = "prop-zoom-default";
76 const char CameraProperties::PICTURE_SIZE[] = "prop-picture-size-default";
77 const char CameraProperties::PICTURE_FORMAT[] = "prop-picture-format-default";
78 const char CameraProperties::JPEG_THUMBNAIL_SIZE[] = "prop-jpeg-thumbnail-size-default";
79 const char CameraProperties::WHITEBALANCE[] = "prop-whitebalance-default";
80 const char CameraProperties::EFFECT[] = "prop-effect-default";
81 const char CameraProperties::ANTIBANDING[] = "prop-antibanding-default";
82 const char CameraProperties::EXPOSURE_MODE[] = "prop-exposure-mode-default";
83 const char CameraProperties::EV_COMPENSATION[] = "prop-ev-compensation-default";
84 const char CameraProperties::ISO_MODE[] = "prop-iso-mode-default";
85 const char CameraProperties::FOCUS_MODE[] = "prop-focus-mode-default";
86 const char CameraProperties::SCENE_MODE[] = "prop-scene-mode-default";
87 const char CameraProperties::FLASH_MODE[] = "prop-flash-mode-default";
88 const char CameraProperties::JPEG_QUALITY[] = "prop-jpeg-quality-default";
89 const char CameraProperties::CONTRAST[] = "prop-contrast-default";
90 const char CameraProperties::BRIGHTNESS[] = "prop-brightness-default";
91 const char CameraProperties::SATURATION[] = "prop-saturation-default";
92 const char CameraProperties::SHARPNESS[] = "prop-sharpness-default";
93 const char CameraProperties::IPP[] = "prop-ipp-default";
94 const char CameraProperties::GBCE[] = "prop-gbce-default";
95 const char CameraProperties::SUPPORTED_GBCE[] = "prop-gbce-supported";
96 const char CameraProperties::GLBCE[] = "prop-glbce-default";
97 const char CameraProperties::SUPPORTED_GLBCE[] = "prop-glbce-supported";
98 const char CameraProperties::S3D_PRV_FRAME_LAYOUT[] = "prop-s3d-prv-frame-layout";
99 const char CameraProperties::S3D_PRV_FRAME_LAYOUT_VALUES[] = "prop-s3d-prv-frame-layout-values";
100 const char CameraProperties::S3D_CAP_FRAME_LAYOUT[] = "prop-s3d-cap-frame-layout";
101 const char CameraProperties::S3D_CAP_FRAME_LAYOUT_VALUES[] = "prop-s3d-cap-frame-layout-values";
102 const char CameraProperties::AUTOCONVERGENCE_MODE[] = "prop-auto-convergence-mode";
103 const char CameraProperties::AUTOCONVERGENCE_MODE_VALUES[] = "prop-auto-convergence-mode-values";
104 const char CameraProperties::MANUAL_CONVERGENCE[] = "prop-manual-convergence";
105 const char CameraProperties::SUPPORTED_MANUAL_CONVERGENCE_MIN[] = "prop-supported-manual-convergence-min";
106 const char CameraProperties::SUPPORTED_MANUAL_CONVERGENCE_MAX[] = "prop-supported-manual-convergence-max";
107 const char CameraProperties::SUPPORTED_MANUAL_CONVERGENCE_STEP[] = "prop-supported-manual-convergence-step";
108 const char CameraProperties::VSTAB[] = "prop-vstab-default";
109 const char CameraProperties::VSTAB_SUPPORTED[] = "prop-vstab-supported";
110 const char CameraProperties::VNF[] = "prop-vnf-default";
111 const char CameraProperties::VNF_SUPPORTED[] = "prop-vnf-supported";
112 const char CameraProperties::REVISION[] = "prop-revision";
113 const char CameraProperties::FOCAL_LENGTH[] = "prop-focal-length";
114 const char CameraProperties::HOR_ANGLE[] = "prop-horizontal-angle";
115 const char CameraProperties::VER_ANGLE[] = "prop-vertical-angle";
116 const char CameraProperties::FRAMERATE_RANGE[] = "prop-framerate-range-default";
117 const char CameraProperties::FRAMERATE_RANGE_SUPPORTED[]="prop-framerate-range-values";
118 const char CameraProperties::FRAMERATE_RANGE_EXT_SUPPORTED[]="prop-framerate-range-ext-values";
119 const char CameraProperties::SENSOR_ORIENTATION[]= "sensor-orientation";
120 const char CameraProperties::SENSOR_ORIENTATION_VALUES[]= "sensor-orientation-values";
121 const char CameraProperties::EXIF_MAKE[] = "prop-exif-make";
122 const char CameraProperties::EXIF_MODEL[] = "prop-exif-model";
123 const char CameraProperties::JPEG_THUMBNAIL_QUALITY[] = "prop-jpeg-thumbnail-quality-default";
124 const char CameraProperties::MAX_FOCUS_AREAS[] = "prop-max-focus-areas";
125 const char CameraProperties::MAX_FD_HW_FACES[] = "prop-max-fd-hw-faces";
126 const char CameraProperties::MAX_FD_SW_FACES[] = "prop-max-fd-sw-faces";
127 const char CameraProperties::AUTO_EXPOSURE_LOCK[] = "prop-auto-exposure-lock";
128 const char CameraProperties::AUTO_EXPOSURE_LOCK_SUPPORTED[] = "prop-auto-exposure-lock-supported";
129 const char CameraProperties::AUTO_WHITEBALANCE_LOCK[] = "prop-auto-whitebalance-lock";
130 const char CameraProperties::AUTO_WHITEBALANCE_LOCK_SUPPORTED[] = "prop-auto-whitebalance-lock-supported";
131 const char CameraProperties::MAX_NUM_METERING_AREAS[] = "prop-max-num-metering-areas";
132 const char CameraProperties::METERING_AREAS[] = "prop-metering-areas";
133 const char CameraProperties::VIDEO_SNAPSHOT_SUPPORTED[] = "prop-video-snapshot-supported";
134 const char CameraProperties::VIDEO_SIZE[] = "video-size";
135 const char CameraProperties::SUPPORTED_VIDEO_SIZES[] = "video-size-values";
136 const char CameraProperties::MECHANICAL_MISALIGNMENT_CORRECTION_SUPPORTED[] = "prop-mechanical-misalignment-correction-supported";
137 const char CameraProperties::MECHANICAL_MISALIGNMENT_CORRECTION[] = "prop-mechanical-misalignment-correction";
138 const char CameraProperties::CAP_MODE_VALUES[] = "prop-mode-values";
139 const char CameraProperties::RAW_WIDTH[] = "prop-raw-width-values";
140 const char CameraProperties::RAW_HEIGHT[] = "prop-raw-height-values";
141 const char CameraProperties::MAX_PICTURE_WIDTH[] = "prop-max-picture-width";
142 const char CameraProperties::MAX_PICTURE_HEIGHT[] = "prop-max-picture-height";
143
144 const char CameraProperties::DEFAULT_VALUE[] = "";
145
146 const char CameraProperties::PARAMS_DELIMITER []= ",";
147
148 // Returns the properties class for a specific Camera
149 // Each value is indexed by the CameraProperties::CameraPropertyIndex enum
getProperties(int cameraIndex,CameraProperties::Properties ** properties)150 int CameraProperties::getProperties(int cameraIndex, CameraProperties::Properties** properties)
151 {
152 LOG_FUNCTION_NAME;
153
154 if(cameraIndex >= mCamerasSupported)
155 {
156 LOG_FUNCTION_NAME_EXIT;
157 return -EINVAL;
158 }
159
160 *properties = mCameraProps+cameraIndex;
161
162 LOG_FUNCTION_NAME_EXIT;
163 return 0;
164 }
165
set(const char * const prop,const char * const value)166 void CameraProperties::Properties::set(const char * const prop, const char * const value) {
167 CAMHAL_ASSERT(prop);
168
169 if ( !value ) {
170 mProperties[mCurrentMode].removeItem(android::String8(prop));
171 } else {
172 mProperties[mCurrentMode].replaceValueFor(android::String8(prop), android::String8(value));
173 }
174 }
175
set(const char * const prop,const int value)176 void CameraProperties::Properties::set(const char * const prop, const int value) {
177 char s_val[30];
178 sprintf(s_val, "%d", value);
179 set(prop, s_val);
180 }
181
get(const char * prop) const182 const char* CameraProperties::Properties::get(const char * prop) const {
183 return mProperties[mCurrentMode].valueFor(android::String8(prop)).string();
184 }
185
getInt(const char * prop) const186 int CameraProperties::Properties::getInt(const char * prop) const {
187 android::String8 value = mProperties[mCurrentMode].valueFor(android::String8(prop));
188 if (value.isEmpty()) {
189 return -1;
190 }
191 return strtol(value, 0, 0);
192 }
193
setSensorIndex(int idx)194 void CameraProperties::Properties::setSensorIndex(int idx) {
195 OperatingMode originalMode = getMode();
196 for ( int i = 0 ; i < MODE_MAX ; i++ ) {
197 setMode(static_cast<OperatingMode>(i));
198 set(CAMERA_SENSOR_INDEX, idx);
199 }
200 setMode(originalMode);
201 }
202
setMode(OperatingMode mode)203 void CameraProperties::Properties::setMode(OperatingMode mode) {
204 CAMHAL_ASSERT(mode >= 0 && mode < MODE_MAX);
205 mCurrentMode = mode;
206 }
207
getMode() const208 OperatingMode CameraProperties::Properties::getMode() const {
209 return mCurrentMode;
210 }
211
dump()212 void CameraProperties::Properties::dump() {
213 CAMHAL_LOGD("================================");
214 CAMHAL_LOGD("Dumping properties for camera: %d", getInt("prop-sensor-index"));
215
216 for (size_t i = 0; i < mProperties[mCurrentMode].size(); i++) {
217 CAMHAL_LOGD("%s = %s",
218 mProperties[mCurrentMode].keyAt(i).string(),
219 mProperties[mCurrentMode].valueAt(i).string());
220 }
221
222 CAMHAL_LOGD("--------------------------------");
223 }
224
keyAt(const unsigned int index) const225 const char* CameraProperties::Properties::keyAt(const unsigned int index) const {
226 if (index < mProperties[mCurrentMode].size()) {
227 return mProperties[mCurrentMode].keyAt(index).string();
228 }
229 return NULL;
230 }
231
valueAt(const unsigned int index) const232 const char* CameraProperties::Properties::valueAt(const unsigned int index) const {
233 if (index < mProperties[mCurrentMode].size()) {
234 return mProperties[mCurrentMode].valueAt(index).string();
235 }
236 return NULL;
237 }
238
239 } // namespace Camera
240 } // namespace Ti
241