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
27namespace android {
28
29const char CameraProperties::INVALID[]="prop-invalid-key";
30const char CameraProperties::CAMERA_NAME[]="prop-camera-name";
31const char CameraProperties::CAMERA_SENSOR_INDEX[]="prop-sensor-index";
32const char CameraProperties::ORIENTATION_INDEX[]="prop-orientation";
33const char CameraProperties::FACING_INDEX[]="prop-facing";
34const char CameraProperties::S3D_SUPPORTED[]="prop-s3d-supported";
35const char CameraProperties::SUPPORTED_PREVIEW_SIZES[] = "prop-preview-size-values";
36const char CameraProperties::SUPPORTED_PREVIEW_FORMATS[] = "prop-preview-format-values";
37const char CameraProperties::SUPPORTED_PREVIEW_FRAME_RATES[] = "prop-preview-frame-rate-values";
38const char CameraProperties::SUPPORTED_PICTURE_SIZES[] = "prop-picture-size-values";
39const char CameraProperties::SUPPORTED_PICTURE_FORMATS[] = "prop-picture-format-values";
40const char CameraProperties::SUPPORTED_THUMBNAIL_SIZES[] = "prop-jpeg-thumbnail-size-values";
41const char CameraProperties::SUPPORTED_WHITE_BALANCE[] = "prop-whitebalance-values";
42const char CameraProperties::SUPPORTED_EFFECTS[] = "prop-effect-values";
43const char CameraProperties::SUPPORTED_ANTIBANDING[] = "prop-antibanding-values";
44const char CameraProperties::SUPPORTED_EXPOSURE_MODES[] = "prop-exposure-mode-values";
45const char CameraProperties::SUPPORTED_EV_MAX[] = "prop-ev-compensation-max";
46const char CameraProperties::SUPPORTED_EV_MIN[] = "prop-ev-compensation-min";
47const char CameraProperties::SUPPORTED_EV_STEP[] = "prop-ev-compensation-step";
48const char CameraProperties::SUPPORTED_ISO_VALUES[] = "prop-iso-mode-values";
49const char CameraProperties::SUPPORTED_SCENE_MODES[] = "prop-scene-mode-values";
50const char CameraProperties::SUPPORTED_FLASH_MODES[] = "prop-flash-mode-values";
51const char CameraProperties::SUPPORTED_FOCUS_MODES[] = "prop-focus-mode-values";
52const char CameraProperties::REQUIRED_PREVIEW_BUFS[] = "prop-required-preview-bufs";
53const char CameraProperties::REQUIRED_IMAGE_BUFS[] = "prop-required-image-bufs";
54const char CameraProperties::SUPPORTED_ZOOM_RATIOS[] = "prop-zoom-ratios";
55const char CameraProperties::SUPPORTED_ZOOM_STAGES[] = "prop-zoom-stages";
56const char CameraProperties::SUPPORTED_IPP_MODES[] = "prop-ipp-values";
57const char CameraProperties::SMOOTH_ZOOM_SUPPORTED[] = "prop-smooth-zoom-supported";
58const char CameraProperties::ZOOM_SUPPORTED[] = "prop-zoom-supported";
59const char CameraProperties::PREVIEW_SIZE[] = "prop-preview-size-default";
60const char CameraProperties::PREVIEW_FORMAT[] = "prop-preview-format-default";
61const char CameraProperties::PREVIEW_FRAME_RATE[] = "prop-preview-frame-rate-default";
62const char CameraProperties::ZOOM[] = "prop-zoom-default";
63const char CameraProperties::PICTURE_SIZE[] = "prop-picture-size-default";
64const char CameraProperties::PICTURE_FORMAT[] = "prop-picture-format-default";
65const char CameraProperties::JPEG_THUMBNAIL_SIZE[] = "prop-jpeg-thumbnail-size-default";
66const char CameraProperties::WHITEBALANCE[] = "prop-whitebalance-default";
67const char CameraProperties::EFFECT[] = "prop-effect-default";
68const char CameraProperties::ANTIBANDING[] = "prop-antibanding-default";
69const char CameraProperties::EXPOSURE_MODE[] = "prop-exposure-mode-default";
70const char CameraProperties::EV_COMPENSATION[] = "prop-ev-compensation-default";
71const char CameraProperties::ISO_MODE[] = "prop-iso-mode-default";
72const char CameraProperties::FOCUS_MODE[] = "prop-focus-mode-default";
73const char CameraProperties::SCENE_MODE[] = "prop-scene-mode-default";
74const char CameraProperties::FLASH_MODE[] = "prop-flash-mode-default";
75const char CameraProperties::JPEG_QUALITY[] = "prop-jpeg-quality-default";
76const char CameraProperties::CONTRAST[] = "prop-contrast-default";
77const char CameraProperties::BRIGHTNESS[] = "prop-brightness-default";
78const char CameraProperties::SATURATION[] = "prop-saturation-default";
79const char CameraProperties::SHARPNESS[] = "prop-sharpness-default";
80const char CameraProperties::IPP[] = "prop-ipp-default";
81const char CameraProperties::GBCE[] = "prop-gbce-default";
82const char CameraProperties::S3D2D_PREVIEW[] = "prop-s3d2d-preview";
83const char CameraProperties::S3D2D_PREVIEW_MODES[] = "prop-s3d2d-preview-values";
84const char CameraProperties::AUTOCONVERGENCE[] = "prop-auto-convergence";
85const char CameraProperties::AUTOCONVERGENCE_MODE[] = "prop-auto-convergence-mode";
86const char CameraProperties::MANUALCONVERGENCE_VALUES[] = "prop-manual-convergence-values";
87const char CameraProperties::VSTAB[] = "prop-vstab-default";
88const char CameraProperties::VSTAB_SUPPORTED[] = "prop-vstab-supported";
89const char CameraProperties::REVISION[] = "prop-revision";
90const char CameraProperties::FOCAL_LENGTH[] = "prop-focal-length";
91const char CameraProperties::HOR_ANGLE[] = "prop-horizontal-angle";
92const char CameraProperties::VER_ANGLE[] = "prop-vertical-angle";
93const char CameraProperties::FRAMERATE_RANGE[] = "prop-framerate-range-default";
94const char CameraProperties::FRAMERATE_RANGE_IMAGE[] = "prop-framerate-range-image-default";
95const char CameraProperties::FRAMERATE_RANGE_VIDEO[]="prop-framerate-range-video-default";
96const char CameraProperties::FRAMERATE_RANGE_SUPPORTED[]="prop-framerate-range-values";
97const char CameraProperties::SENSOR_ORIENTATION[]= "sensor-orientation";
98const char CameraProperties::SENSOR_ORIENTATION_VALUES[]= "sensor-orientation-values";
99const char CameraProperties::EXIF_MAKE[] = "prop-exif-make";
100const char CameraProperties::EXIF_MODEL[] = "prop-exif-model";
101const char CameraProperties::JPEG_THUMBNAIL_QUALITY[] = "prop-jpeg-thumbnail-quality-default";
102const char CameraProperties::MAX_FOCUS_AREAS[] = "prop-max-focus-areas";
103const char CameraProperties::MAX_FD_HW_FACES[] = "prop-max-fd-hw-faces";
104const char CameraProperties::MAX_FD_SW_FACES[] = "prop-max-fd-sw-faces";
105const char CameraProperties::AUTO_EXPOSURE_LOCK[] = "prop-auto-exposure-lock";
106const char CameraProperties::AUTO_EXPOSURE_LOCK_SUPPORTED[] = "prop-auto-exposure-lock-supported";
107const char CameraProperties::AUTO_WHITEBALANCE_LOCK[] = "prop-auto-whitebalance-lock";
108const char CameraProperties::AUTO_WHITEBALANCE_LOCK_SUPPORTED[] = "prop-auto-whitebalance-lock-supported";
109const char CameraProperties::MAX_NUM_METERING_AREAS[] = "prop-max-num-metering-areas";
110const char CameraProperties::METERING_AREAS[] = "prop-metering-areas";
111const char CameraProperties::VIDEO_SNAPSHOT_SUPPORTED[] = "prop-video-snapshot-supported";
112const char CameraProperties::VIDEO_SIZE[] = "video-size";
113const char CameraProperties::SUPPORTED_VIDEO_SIZES[] = "video-size-values";
114const char CameraProperties::PREFERRED_PREVIEW_SIZE_FOR_VIDEO[] = "preferred-preview-size-for-video";
115
116
117const char CameraProperties::DEFAULT_VALUE[] = "";
118
119const char CameraProperties::PARAMS_DELIMITER []= ",";
120
121// Returns the properties class for a specific Camera
122// Each value is indexed by the CameraProperties::CameraPropertyIndex enum
123int 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
139ssize_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
149ssize_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
158const char* CameraProperties::Properties::get(const char * prop)
159{
160    String8 value = mProperties->valueFor(String8(prop));
161    return value.string();
162}
163
164void 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
174const 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
183const 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