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