1 /* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
2  *
3  * Redistribution and use in source and binary forms, with or without
4  * modification, are permitted provided that the following conditions are
5  * met:
6  *     * Redistributions of source code must retain the above copyright
7  *       notice, this list of conditions and the following disclaimer.
8  *     * Redistributions in binary form must reproduce the above
9  *       copyright notice, this list of conditions and the following
10  *       disclaimer in the documentation and/or other materials provided
11  *       with the distribution.
12  *     * Neither the name of The Linux Foundation nor the names of its
13  *       contributors may be used to endorse or promote products derived
14  *       from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  */
29 
30 #define LOG_TAG "QCameraParameters"
31 
32 #include <cutils/properties.h>
33 #include <math.h>
34 #include <utils/Errors.h>
35 #include <string.h>
36 #include <stdlib.h>
37 #include <gralloc_priv.h>
38 #include "QCamera2HWI.h"
39 #include "QCameraParameters.h"
40 
41 #define ASPECT_TOLERANCE 0.001
42 #define FLIP_V_H (FLIP_H | FLIP_V)
43 
44 namespace qcamera {
45 // Parameter keys to communicate between camera application and driver.
46 const char QCameraParameters::KEY_QC_SUPPORTED_HFR_SIZES[] = "hfr-size-values";
47 const char QCameraParameters::KEY_QC_PREVIEW_FRAME_RATE_MODE[] = "preview-frame-rate-mode";
48 const char QCameraParameters::KEY_QC_SUPPORTED_PREVIEW_FRAME_RATE_MODES[] = "preview-frame-rate-modes";
49 const char QCameraParameters::KEY_QC_PREVIEW_FRAME_RATE_AUTO_MODE[] = "frame-rate-auto";
50 const char QCameraParameters::KEY_QC_PREVIEW_FRAME_RATE_FIXED_MODE[] = "frame-rate-fixed";
51 const char QCameraParameters::KEY_QC_TOUCH_AF_AEC[] = "touch-af-aec";
52 const char QCameraParameters::KEY_QC_SUPPORTED_TOUCH_AF_AEC[] = "touch-af-aec-values";
53 const char QCameraParameters::KEY_QC_TOUCH_INDEX_AEC[] = "touch-index-aec";
54 const char QCameraParameters::KEY_QC_TOUCH_INDEX_AF[] = "touch-index-af";
55 const char QCameraParameters::KEY_QC_SCENE_DETECT[] = "scene-detect";
56 const char QCameraParameters::KEY_QC_SUPPORTED_SCENE_DETECT[] = "scene-detect-values";
57 const char QCameraParameters::KEY_QC_ISO_MODE[] = "iso";
58 const char QCameraParameters::KEY_QC_SUPPORTED_ISO_MODES[] = "iso-values";
59 const char QCameraParameters::KEY_QC_LENSSHADE[] = "lensshade";
60 const char QCameraParameters::KEY_QC_SUPPORTED_LENSSHADE_MODES[] = "lensshade-values";
61 const char QCameraParameters::KEY_QC_AUTO_EXPOSURE[] = "auto-exposure";
62 const char QCameraParameters::KEY_QC_SUPPORTED_AUTO_EXPOSURE[] = "auto-exposure-values";
63 const char QCameraParameters::KEY_QC_DENOISE[] = "denoise";
64 const char QCameraParameters::KEY_QC_SUPPORTED_DENOISE[] = "denoise-values";
65 const char QCameraParameters::KEY_QC_FOCUS_ALGO[] = "selectable-zone-af";
66 const char QCameraParameters::KEY_QC_SUPPORTED_FOCUS_ALGOS[] = "selectable-zone-af-values";
67 const char QCameraParameters::KEY_QC_FACE_DETECTION[] = "face-detection";
68 const char QCameraParameters::KEY_QC_SUPPORTED_FACE_DETECTION[] = "face-detection-values";
69 const char QCameraParameters::KEY_QC_FACE_RECOGNITION[] = "face-recognition";
70 const char QCameraParameters::KEY_QC_SUPPORTED_FACE_RECOGNITION[] = "face-recognition-values";
71 const char QCameraParameters::KEY_QC_MEMORY_COLOR_ENHANCEMENT[] = "mce";
72 const char QCameraParameters::KEY_QC_SUPPORTED_MEM_COLOR_ENHANCE_MODES[] = "mce-values";
73 const char QCameraParameters::KEY_QC_DIS[] = "dis";
74 const char QCameraParameters::KEY_QC_SUPPORTED_DIS_MODES[] = "dis-values";
75 const char QCameraParameters::KEY_QC_VIDEO_HIGH_FRAME_RATE[] = "video-hfr";
76 const char QCameraParameters::KEY_QC_VIDEO_HIGH_SPEED_RECORDING[] = "video-hsr";
77 const char QCameraParameters::KEY_QC_SUPPORTED_VIDEO_HIGH_FRAME_RATE_MODES[] = "video-hfr-values";
78 const char QCameraParameters::KEY_QC_REDEYE_REDUCTION[] = "redeye-reduction";
79 const char QCameraParameters::KEY_QC_SUPPORTED_REDEYE_REDUCTION[] = "redeye-reduction-values";
80 const char QCameraParameters::KEY_QC_HIGH_DYNAMIC_RANGE_IMAGING[] = "hdr";
81 const char QCameraParameters::KEY_QC_SUPPORTED_HDR_IMAGING_MODES[] = "hdr-values";
82 const char QCameraParameters::KEY_QC_ZSL[] = "zsl";
83 const char QCameraParameters::KEY_QC_SUPPORTED_ZSL_MODES[] = "zsl-values";
84 const char QCameraParameters::KEY_QC_ZSL_BURST_INTERVAL[] = "capture-burst-interval";
85 const char QCameraParameters::KEY_QC_ZSL_BURST_LOOKBACK[] = "capture-burst-retroactive";
86 const char QCameraParameters::KEY_QC_ZSL_QUEUE_DEPTH[] = "capture-burst-queue-depth";
87 const char QCameraParameters::KEY_QC_CAMERA_MODE[] = "camera-mode";
88 const char QCameraParameters::KEY_QC_AE_BRACKET_HDR[] = "ae-bracket-hdr";
89 const char QCameraParameters::KEY_QC_SUPPORTED_AE_BRACKET_MODES[] = "ae-bracket-hdr-values";
90 const char QCameraParameters::KEY_QC_SUPPORTED_RAW_FORMATS[] = "raw-format-values";
91 const char QCameraParameters::KEY_QC_RAW_FORMAT[] = "raw-format";
92 const char QCameraParameters::KEY_QC_ORIENTATION[] = "orientation";
93 const char QCameraParameters::KEY_QC_SELECTABLE_ZONE_AF[] = "selectable-zone-af";
94 const char QCameraParameters::KEY_QC_CAPTURE_BURST_EXPOSURE[] = "capture-burst-exposures";
95 const char QCameraParameters::KEY_QC_NUM_SNAPSHOT_PER_SHUTTER[] = "num-snaps-per-shutter";
96 const char QCameraParameters::KEY_QC_NUM_RETRO_BURST_PER_SHUTTER[] = "num-retro-burst-per-shutter";
97 const char QCameraParameters::KEY_QC_SNAPSHOT_BURST_LED_ON_PERIOD[] = "zsl-burst-led-on-period";
98 const char QCameraParameters::KEY_QC_NO_DISPLAY_MODE[] = "no-display-mode";
99 const char QCameraParameters::KEY_QC_RAW_PICUTRE_SIZE[] = "raw-size";
100 const char QCameraParameters::KEY_QC_SUPPORTED_SKIN_TONE_ENHANCEMENT_MODES[] = "skinToneEnhancement-values";
101 const char QCameraParameters::KEY_QC_SUPPORTED_LIVESNAPSHOT_SIZES[] = "supported-live-snapshot-sizes";
102 const char QCameraParameters::KEY_QC_HDR_NEED_1X[] = "hdr-need-1x";
103 const char QCameraParameters::KEY_QC_PREVIEW_FLIP[] = "preview-flip";
104 const char QCameraParameters::KEY_QC_VIDEO_FLIP[] = "video-flip";
105 const char QCameraParameters::KEY_QC_SNAPSHOT_PICTURE_FLIP[] = "snapshot-picture-flip";
106 const char QCameraParameters::KEY_QC_SUPPORTED_FLIP_MODES[] = "flip-mode-values";
107 const char QCameraParameters::KEY_QC_VIDEO_HDR[] = "video-hdr";
108 const char QCameraParameters::KEY_QC_SENSOR_HDR[] = "sensor-hdr";
109 const char QCameraParameters::KEY_QC_VT_ENABLE[] = "avtimer";
110 const char QCameraParameters::KEY_QC_SUPPORTED_VIDEO_HDR_MODES[] = "video-hdr-values";
111 const char QCameraParameters::KEY_QC_SUPPORTED_SENSOR_HDR_MODES[] = "sensor-hdr-values";
112 const char QCameraParameters::KEY_QC_AUTO_HDR_ENABLE [] = "auto-hdr-enable";
113 const char QCameraParameters::KEY_QC_SNAPSHOT_BURST_NUM[] = "snapshot-burst-num";
114 const char QCameraParameters::KEY_QC_SNAPSHOT_FD_DATA[] = "snapshot-fd-data-enable";
115 const char QCameraParameters::KEY_QC_TINTLESS_ENABLE[] = "tintless";
116 const char QCameraParameters::KEY_QC_SCENE_SELECTION[] = "scene-selection";
117 const char QCameraParameters::KEY_QC_CDS_MODE[] = "cds-mode";
118 const char QCameraParameters::KEY_QC_VIDEO_ROTATION[] = "video-rotation";
119 const char QCameraParameters::KEY_QC_AF_BRACKET[] = "af-bracket";
120 const char QCameraParameters::KEY_QC_SUPPORTED_AF_BRACKET_MODES[] = "af-bracket-values";
121 const char QCameraParameters::KEY_QC_RE_FOCUS[] = "re-focus";
122 const char QCameraParameters::KEY_QC_SUPPORTED_RE_FOCUS_MODES[] = "re-focus-values";
123 const char QCameraParameters::KEY_QC_CHROMA_FLASH[] = "chroma-flash";
124 const char QCameraParameters::KEY_QC_SUPPORTED_CHROMA_FLASH_MODES[] = "chroma-flash-values";
125 const char QCameraParameters::KEY_QC_OPTI_ZOOM[] = "opti-zoom";
126 const char QCameraParameters::KEY_QC_SUPPORTED_OPTI_ZOOM_MODES[] = "opti-zoom-values";
127 const char QCameraParameters::KEY_INTERNAL_PERVIEW_RESTART[] = "internal-restart";
128 const char QCameraParameters::KEY_QC_RDI_MODE[] = "rdi-mode";
129 const char QCameraParameters::KEY_QC_SUPPORTED_RDI_MODES[] = "rdi-mode-values";
130 const char QCameraParameters::KEY_QC_SECURE_MODE[] = "secure-mode";
131 const char QCameraParameters::KEY_QC_SUPPORTED_SECURE_MODES[] = "secure-mode-values";
132 const char QCameraParameters::KEY_QC_AUTO_HDR_SUPPORTED[] = "auto-hdr-supported";
133 
134 // Values for effect settings.
135 const char QCameraParameters::EFFECT_EMBOSS[] = "emboss";
136 const char QCameraParameters::EFFECT_SKETCH[] = "sketch";
137 const char QCameraParameters::EFFECT_NEON[] = "neon";
138 
139 // Values for auto exposure settings.
140 const char QCameraParameters::TOUCH_AF_AEC_OFF[] = "touch-off";
141 const char QCameraParameters::TOUCH_AF_AEC_ON[] = "touch-on";
142 
143 // Values for scene mode settings.
144 const char QCameraParameters::SCENE_MODE_ASD[] = "asd";   // corresponds to CAMERA_BESTSHOT_AUTO in HAL
145 const char QCameraParameters::SCENE_MODE_BACKLIGHT[] = "backlight";
146 const char QCameraParameters::SCENE_MODE_FLOWERS[] = "flowers";
147 const char QCameraParameters::SCENE_MODE_AR[] = "AR";
148 const char QCameraParameters::SCENE_MODE_HDR[] = "hdr";
149 
150 // Formats for setPreviewFormat and setPictureFormat.
151 const char QCameraParameters::PIXEL_FORMAT_YUV420SP_ADRENO[] = "yuv420sp-adreno";
152 const char QCameraParameters::PIXEL_FORMAT_YV12[] = "yuv420p";
153 const char QCameraParameters::PIXEL_FORMAT_NV12[] = "nv12";
154 const char QCameraParameters::QC_PIXEL_FORMAT_NV12_VENUS[] = "nv12-venus";
155 
156 // Values for raw image formats
157 const char QCameraParameters::QC_PIXEL_FORMAT_YUV_RAW_8BIT_YUYV[] = "yuv-raw8-yuyv";
158 const char QCameraParameters::QC_PIXEL_FORMAT_YUV_RAW_8BIT_YVYU[] = "yuv-raw8-yvyu";
159 const char QCameraParameters::QC_PIXEL_FORMAT_YUV_RAW_8BIT_UYVY[] = "yuv-raw8-uyvy";
160 const char QCameraParameters::QC_PIXEL_FORMAT_YUV_RAW_8BIT_VYUY[] = "yuv-raw8-vyuy";
161 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8GBRG[] = "bayer-qcom-8gbrg";
162 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8GRBG[] = "bayer-qcom-8grbg";
163 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8RGGB[] = "bayer-qcom-8rggb";
164 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8BGGR[] = "bayer-qcom-8bggr";
165 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10GBRG[] = "bayer-qcom-10gbrg";
166 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10GRBG[] = "bayer-qcom-10grbg";
167 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10RGGB[] = "bayer-qcom-10rggb";
168 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10BGGR[] = "bayer-qcom-10bggr";
169 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12GBRG[] = "bayer-qcom-12gbrg";
170 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12GRBG[] = "bayer-qcom-12grbg";
171 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12RGGB[] = "bayer-qcom-12rggb";
172 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12BGGR[] = "bayer-qcom-12bggr";
173 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8GBRG[] = "bayer-mipi-8gbrg";
174 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8GRBG[] = "bayer-mipi-8grbg";
175 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8RGGB[] = "bayer-mipi-8rggb";
176 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8BGGR[] = "bayer-mipi-8bggr";
177 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10GBRG[] = "bayer-mipi-10gbrg";
178 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10GRBG[] = "bayer-mipi-10grbg";
179 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10RGGB[] = "bayer-mipi-10rggb";
180 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10BGGR[] = "bayer-mipi-10bggr";
181 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12GBRG[] = "bayer-mipi-12gbrg";
182 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12GRBG[] = "bayer-mipi-12grbg";
183 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12RGGB[] = "bayer-mipi-12rggb";
184 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12BGGR[] = "bayer-mipi-12bggr";
185 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8GBRG[] = "bayer-ideal-qcom-8gbrg";
186 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8GRBG[] = "bayer-ideal-qcom-8grbg";
187 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8RGGB[] = "bayer-ideal-qcom-8rggb";
188 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8BGGR[] = "bayer-ideal-qcom-8bggr";
189 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10GBRG[] = "bayer-ideal-qcom-10gbrg";
190 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10GRBG[] = "bayer-ideal-qcom-10grbg";
191 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10RGGB[] = "bayer-ideal-qcom-10rggb";
192 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10BGGR[] = "bayer-ideal-qcom-10bggr";
193 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12GBRG[] = "bayer-ideal-qcom-12gbrg";
194 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12GRBG[] = "bayer-ideal-qcom-12grbg";
195 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12RGGB[] = "bayer-ideal-qcom-12rggb";
196 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12BGGR[] = "bayer-ideal-qcom-12bggr";
197 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8GBRG[] = "bayer-ideal-mipi-8gbrg";
198 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8GRBG[] = "bayer-ideal-mipi-8grbg";
199 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8RGGB[] = "bayer-ideal-mipi-8rggb";
200 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8BGGR[] = "bayer-ideal-mipi-8bggr";
201 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10GBRG[] = "bayer-ideal-mipi-10gbrg";
202 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10GRBG[] = "bayer-ideal-mipi-10grbg";
203 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10RGGB[] = "bayer-ideal-mipi-10rggb";
204 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10BGGR[] = "bayer-ideal-mipi-10bggr";
205 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12GBRG[] = "bayer-ideal-mipi-12gbrg";
206 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12GRBG[] = "bayer-ideal-mipi-12grbg";
207 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12RGGB[] = "bayer-ideal-mipi-12rggb";
208 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12BGGR[] = "bayer-ideal-mipi-12bggr";
209 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8GBRG[] = "bayer-ideal-plain8-8gbrg";
210 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8GRBG[] = "bayer-ideal-plain8-8grbg";
211 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8RGGB[] = "bayer-ideal-plain8-8rggb";
212 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8BGGR[] = "bayer-ideal-plain8-8bggr";
213 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8GBRG[] = "bayer-ideal-plain16-8gbrg";
214 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8GRBG[] = "bayer-ideal-plain16-8grbg";
215 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8RGGB[] = "bayer-ideal-plain16-8rggb";
216 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8BGGR[] = "bayer-ideal-plain16-8bggr";
217 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10GBRG[] = "bayer-ideal-plain16-10gbrg";
218 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10GRBG[] = "bayer-ideal-plain16-10grbg";
219 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10RGGB[] = "bayer-ideal-plain16-10rggb";
220 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10BGGR[] = "bayer-ideal-plain16-10bggr";
221 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12GBRG[] = "bayer-ideal-plain16-12gbrg";
222 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12GRBG[] = "bayer-ideal-plain16-12grbg";
223 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12RGGB[] = "bayer-ideal-plain16-12rggb";
224 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12BGGR[] = "bayer-ideal-plain16-12bggr";
225 
226 // Values for ISO Settings
227 const char QCameraParameters::ISO_AUTO[] = "auto";
228 const char QCameraParameters::ISO_HJR[] = "ISO_HJR";
229 const char QCameraParameters::ISO_100[] = "ISO100";
230 const char QCameraParameters::ISO_200[] = "ISO200";
231 const char QCameraParameters::ISO_400[] = "ISO400";
232 const char QCameraParameters::ISO_800[] = "ISO800";
233 const char QCameraParameters::ISO_1600[] = "ISO1600";
234 
235 // Values for auto exposure settings.
236 const char QCameraParameters::AUTO_EXPOSURE_FRAME_AVG[] = "frame-average";
237 const char QCameraParameters::AUTO_EXPOSURE_CENTER_WEIGHTED[] = "center-weighted";
238 const char QCameraParameters::AUTO_EXPOSURE_SPOT_METERING[] = "spot-metering";
239 const char QCameraParameters::AUTO_EXPOSURE_SMART_METERING[] = "smart-metering";
240 const char QCameraParameters::AUTO_EXPOSURE_USER_METERING[] = "user-metering";
241 const char QCameraParameters::AUTO_EXPOSURE_SPOT_METERING_ADV[] = "spot-metering-adv";
242 const char QCameraParameters::AUTO_EXPOSURE_CENTER_WEIGHTED_ADV[] = "center-weighted-adv";
243 
244 const char QCameraParameters::KEY_QC_GPS_LATITUDE_REF[] = "gps-latitude-ref";
245 const char QCameraParameters::KEY_QC_GPS_LONGITUDE_REF[] = "gps-longitude-ref";
246 const char QCameraParameters::KEY_QC_GPS_ALTITUDE_REF[] = "gps-altitude-ref";
247 const char QCameraParameters::KEY_QC_GPS_STATUS[] = "gps-status";
248 
249 const char QCameraParameters::KEY_QC_HISTOGRAM[] = "histogram";
250 const char QCameraParameters::KEY_QC_SUPPORTED_HISTOGRAM_MODES[] = "histogram-values";
251 
252 const char QCameraParameters::VALUE_ENABLE[] = "enable";
253 const char QCameraParameters::VALUE_DISABLE[] = "disable";
254 const char QCameraParameters::VALUE_OFF[] = "off";
255 const char QCameraParameters::VALUE_ON[] = "on";
256 const char QCameraParameters::VALUE_TRUE[] = "true";
257 const char QCameraParameters::VALUE_FALSE[] = "false";
258 
259 const char QCameraParameters::KEY_QC_SHARPNESS[] = "sharpness";
260 const char QCameraParameters::KEY_QC_MIN_SHARPNESS[] = "min-sharpness";
261 const char QCameraParameters::KEY_QC_MAX_SHARPNESS[] = "max-sharpness";
262 const char QCameraParameters::KEY_QC_SHARPNESS_STEP[] = "sharpness-step";
263 const char QCameraParameters::KEY_QC_CONTRAST[] = "contrast";
264 const char QCameraParameters::KEY_QC_MIN_CONTRAST[] = "min-contrast";
265 const char QCameraParameters::KEY_QC_MAX_CONTRAST[] = "max-contrast";
266 const char QCameraParameters::KEY_QC_CONTRAST_STEP[] = "contrast-step";
267 const char QCameraParameters::KEY_QC_SATURATION[] = "saturation";
268 const char QCameraParameters::KEY_QC_MIN_SATURATION[] = "min-saturation";
269 const char QCameraParameters::KEY_QC_MAX_SATURATION[] = "max-saturation";
270 const char QCameraParameters::KEY_QC_SATURATION_STEP[] = "saturation-step";
271 const char QCameraParameters::KEY_QC_BRIGHTNESS[] = "luma-adaptation";
272 const char QCameraParameters::KEY_QC_MIN_BRIGHTNESS[] = "min-brightness";
273 const char QCameraParameters::KEY_QC_MAX_BRIGHTNESS[] = "max-brightness";
274 const char QCameraParameters::KEY_QC_BRIGHTNESS_STEP[] = "brightness-step";
275 const char QCameraParameters::KEY_QC_SCE_FACTOR[] = "skinToneEnhancement";
276 const char QCameraParameters::KEY_QC_MIN_SCE_FACTOR[] = "min-sce-factor";
277 const char QCameraParameters::KEY_QC_MAX_SCE_FACTOR[] = "max-sce-factor";
278 const char QCameraParameters::KEY_QC_SCE_FACTOR_STEP[] = "sce-factor-step";
279 
280 const char QCameraParameters::KEY_QC_SUPPORTED_CAMERA_FEATURES[] = "qc-camera-features";
281 const char QCameraParameters::KEY_QC_MAX_NUM_REQUESTED_FACES[] = "qc-max-num-requested-faces";
282 
283 //Values for DENOISE
284 const char QCameraParameters::DENOISE_OFF[] = "denoise-off";
285 const char QCameraParameters::DENOISE_ON[] = "denoise-on";
286 
287 // Values for selectable zone af Settings
288 const char QCameraParameters::FOCUS_ALGO_AUTO[] = "auto";
289 const char QCameraParameters::FOCUS_ALGO_SPOT_METERING[] = "spot-metering";
290 const char QCameraParameters::FOCUS_ALGO_CENTER_WEIGHTED[] = "center-weighted";
291 const char QCameraParameters::FOCUS_ALGO_FRAME_AVERAGE[] = "frame-average";
292 
293 // Values for HFR settings.
294 const char QCameraParameters::VIDEO_HFR_OFF[] = "off";
295 const char QCameraParameters::VIDEO_HFR_2X[] = "60";
296 const char QCameraParameters::VIDEO_HFR_3X[] = "90";
297 const char QCameraParameters::VIDEO_HFR_4X[] = "120";
298 const char QCameraParameters::VIDEO_HFR_5X[] = "150";
299 
300 // Values for HDR Bracketing settings.
301 const char QCameraParameters::AE_BRACKET_OFF[] = "Off";
302 const char QCameraParameters::AE_BRACKET[] = "AE-Bracket";
303 
304 // Values for AF Bracketing setting.
305 const char QCameraParameters::AF_BRACKET_OFF[] = "af-bracket-off";
306 const char QCameraParameters::AF_BRACKET_ON[] = "af-bracket-on";
307 
308 // Values for Refocus setting.
309 const char QCameraParameters::RE_FOCUS_OFF[] = "re-focus-off";
310 const char QCameraParameters::RE_FOCUS_ON[] = "re-focus-on";
311 
312 // Values for Chroma Flash setting.
313 const char QCameraParameters::CHROMA_FLASH_OFF[] = "chroma-flash-off";
314 const char QCameraParameters::CHROMA_FLASH_ON[] = "chroma-flash-on";
315 
316 // Values for Opti Zoom setting.
317 const char QCameraParameters::OPTI_ZOOM_OFF[] = "opti-zoom-off";
318 const char QCameraParameters::OPTI_ZOOM_ON[] = "opti-zoom-on";
319 
320 // Values for FLIP settings.
321 const char QCameraParameters::FLIP_MODE_OFF[] = "off";
322 const char QCameraParameters::FLIP_MODE_V[] = "flip-v";
323 const char QCameraParameters::FLIP_MODE_H[] = "flip-h";
324 const char QCameraParameters::FLIP_MODE_VH[] = "flip-vh";
325 
326 const char QCameraParameters::CDS_MODE_OFF[] = "off";
327 const char QCameraParameters::CDS_MODE_ON[] = "on";
328 const char QCameraParameters::CDS_MODE_AUTO[] = "auto";
329 
330 const char QCameraParameters::KEY_SELECTED_AUTO_SCENE[] = "selected-auto-scene";
331 
332 static const char* portrait = "portrait";
333 static const char* landscape = "landscape";
334 
335 const cam_dimension_t QCameraParameters::THUMBNAIL_SIZES_MAP[] = {
336     { 512, 288 }, //1.777778
337     { 480, 288 }, //1.666667
338     { 256, 154 }, //1.66233
339     { 432, 288 }, //1.5
340     { 320, 240 }, //1.33333
341     { 176, 144 }, //1.222222
342     { 0, 0 }      // required by Android SDK
343 };
344 
345 const QCameraParameters::QCameraMap QCameraParameters::AUTO_EXPOSURE_MAP[] = {
346     { AUTO_EXPOSURE_FRAME_AVG,           CAM_AEC_MODE_FRAME_AVERAGE },
347     { AUTO_EXPOSURE_CENTER_WEIGHTED,     CAM_AEC_MODE_CENTER_WEIGHTED },
348     { AUTO_EXPOSURE_SPOT_METERING,       CAM_AEC_MODE_SPOT_METERING },
349     { AUTO_EXPOSURE_SMART_METERING,      CAM_AEC_MODE_SMART_METERING },
350     { AUTO_EXPOSURE_USER_METERING,       CAM_AEC_MODE_USER_METERING },
351     { AUTO_EXPOSURE_SPOT_METERING_ADV,   CAM_AEC_MODE_SPOT_METERING_ADV },
352     { AUTO_EXPOSURE_CENTER_WEIGHTED_ADV, CAM_AEC_MODE_CENTER_WEIGHTED_ADV },
353 };
354 
355 const QCameraParameters::QCameraMap QCameraParameters::PREVIEW_FORMATS_MAP[] = {
356     {PIXEL_FORMAT_YUV420SP,        CAM_FORMAT_YUV_420_NV21},
357     {PIXEL_FORMAT_YUV420P,         CAM_FORMAT_YUV_420_YV12},
358     {PIXEL_FORMAT_YUV420SP_ADRENO, CAM_FORMAT_YUV_420_NV21_ADRENO},
359     {PIXEL_FORMAT_YV12,            CAM_FORMAT_YUV_420_YV12},
360     {PIXEL_FORMAT_NV12,            CAM_FORMAT_YUV_420_NV12},
361     {QC_PIXEL_FORMAT_NV12_VENUS,   CAM_FORMAT_YUV_420_NV12_VENUS}
362 };
363 
364 const QCameraParameters::QCameraMap QCameraParameters::PICTURE_TYPES_MAP[] = {
365     {PIXEL_FORMAT_JPEG,                          CAM_FORMAT_JPEG},
366     {PIXEL_FORMAT_YUV420SP,                      CAM_FORMAT_YUV_420_NV21},
367     {PIXEL_FORMAT_YUV422SP,                      CAM_FORMAT_YUV_422_NV16},
368     {QC_PIXEL_FORMAT_YUV_RAW_8BIT_YUYV,          CAM_FORMAT_YUV_RAW_8BIT_YUYV},
369     {QC_PIXEL_FORMAT_YUV_RAW_8BIT_YVYU,          CAM_FORMAT_YUV_RAW_8BIT_YVYU},
370     {QC_PIXEL_FORMAT_YUV_RAW_8BIT_UYVY,          CAM_FORMAT_YUV_RAW_8BIT_UYVY},
371     {QC_PIXEL_FORMAT_YUV_RAW_8BIT_VYUY,          CAM_FORMAT_YUV_RAW_8BIT_VYUY},
372     {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8GBRG,       CAM_FORMAT_BAYER_QCOM_RAW_8BPP_GBRG},
373     {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8GRBG,       CAM_FORMAT_BAYER_QCOM_RAW_8BPP_GRBG},
374     {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8RGGB,       CAM_FORMAT_BAYER_QCOM_RAW_8BPP_RGGB},
375     {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8BGGR,       CAM_FORMAT_BAYER_QCOM_RAW_8BPP_BGGR},
376     {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10GBRG,      CAM_FORMAT_BAYER_QCOM_RAW_10BPP_GBRG},
377     {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10GRBG,      CAM_FORMAT_BAYER_QCOM_RAW_10BPP_GRBG},
378     {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10RGGB,      CAM_FORMAT_BAYER_QCOM_RAW_10BPP_RGGB},
379     {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10BGGR,      CAM_FORMAT_BAYER_QCOM_RAW_10BPP_BGGR},
380     {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12GBRG,      CAM_FORMAT_BAYER_QCOM_RAW_12BPP_GBRG},
381     {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12GRBG,      CAM_FORMAT_BAYER_QCOM_RAW_12BPP_GRBG},
382     {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12RGGB,      CAM_FORMAT_BAYER_QCOM_RAW_12BPP_RGGB},
383     {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12BGGR,      CAM_FORMAT_BAYER_QCOM_RAW_12BPP_BGGR},
384     {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8GBRG,       CAM_FORMAT_BAYER_MIPI_RAW_8BPP_GBRG},
385     {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8GRBG,       CAM_FORMAT_BAYER_MIPI_RAW_8BPP_GRBG},
386     {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8RGGB,       CAM_FORMAT_BAYER_MIPI_RAW_8BPP_RGGB},
387     {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8BGGR,       CAM_FORMAT_BAYER_MIPI_RAW_8BPP_BGGR},
388     {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10GBRG,      CAM_FORMAT_BAYER_MIPI_RAW_10BPP_GBRG},
389     {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10GRBG,      CAM_FORMAT_BAYER_MIPI_RAW_10BPP_GRBG},
390     {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10RGGB,      CAM_FORMAT_BAYER_MIPI_RAW_10BPP_RGGB},
391     {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10BGGR,      CAM_FORMAT_BAYER_MIPI_RAW_10BPP_BGGR},
392     {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12GBRG,      CAM_FORMAT_BAYER_MIPI_RAW_12BPP_GBRG},
393     {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12GRBG,      CAM_FORMAT_BAYER_MIPI_RAW_12BPP_GRBG},
394     {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12RGGB,      CAM_FORMAT_BAYER_MIPI_RAW_12BPP_RGGB},
395     {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12BGGR,      CAM_FORMAT_BAYER_MIPI_RAW_12BPP_BGGR},
396     {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8GBRG,     CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_GBRG},
397     {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8GRBG,     CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_GRBG},
398     {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8RGGB,     CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_RGGB},
399     {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8BGGR,     CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_BGGR},
400     {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10GBRG,    CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_GBRG},
401     {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10GRBG,    CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_GRBG},
402     {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10RGGB,    CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_RGGB},
403     {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10BGGR,    CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_BGGR},
404     {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12GBRG,    CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_GBRG},
405     {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12GRBG,    CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_GRBG},
406     {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12RGGB,    CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_RGGB},
407     {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12BGGR,    CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_BGGR},
408     {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8GBRG,     CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_GBRG},
409     {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8GRBG,     CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_GRBG},
410     {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8RGGB,     CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_RGGB},
411     {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8BGGR,     CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_BGGR},
412     {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10GBRG,    CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_GBRG},
413     {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10GRBG,    CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_GRBG},
414     {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10RGGB,    CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_RGGB},
415     {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10BGGR,    CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_BGGR},
416     {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12GBRG,    CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_GBRG},
417     {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12GRBG,    CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_GRBG},
418     {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12RGGB,    CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_RGGB},
419     {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12BGGR,    CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_BGGR},
420     {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8GBRG,   CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_GBRG},
421     {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8GRBG,   CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_GRBG},
422     {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8RGGB,   CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_RGGB},
423     {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8BGGR,   CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_BGGR},
424     {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8GBRG,  CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_GBRG},
425     {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8GRBG,  CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_GRBG},
426     {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8RGGB,  CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_RGGB},
427     {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8BGGR,  CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_BGGR},
428     {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_GBRG},
429     {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_GRBG},
430     {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_RGGB},
431     {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_BGGR},
432     {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_GBRG},
433     {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_GRBG},
434     {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_RGGB},
435     {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_BGGR}
436 };
437 
438 const QCameraParameters::QCameraMap QCameraParameters::RAW_FORMATS_MAP[] = {
439 };
440 
441 const QCameraParameters::QCameraMap QCameraParameters::FOCUS_MODES_MAP[] = {
442     { FOCUS_MODE_AUTO,               CAM_FOCUS_MODE_AUTO },
443     { FOCUS_MODE_INFINITY,           CAM_FOCUS_MODE_INFINITY },
444     { FOCUS_MODE_MACRO,              CAM_FOCUS_MODE_MACRO },
445     { FOCUS_MODE_FIXED,              CAM_FOCUS_MODE_FIXED },
446     { FOCUS_MODE_EDOF,               CAM_FOCUS_MODE_EDOF },
447     { FOCUS_MODE_CONTINUOUS_PICTURE, CAM_FOCUS_MODE_CONTINOUS_PICTURE },
448     { FOCUS_MODE_CONTINUOUS_VIDEO,   CAM_FOCUS_MODE_CONTINOUS_VIDEO }
449 };
450 
451 const QCameraParameters::QCameraMap QCameraParameters::EFFECT_MODES_MAP[] = {
452     { EFFECT_NONE,       CAM_EFFECT_MODE_OFF },
453     { EFFECT_MONO,       CAM_EFFECT_MODE_MONO },
454     { EFFECT_NEGATIVE,   CAM_EFFECT_MODE_NEGATIVE },
455     { EFFECT_SOLARIZE,   CAM_EFFECT_MODE_SOLARIZE },
456     { EFFECT_SEPIA,      CAM_EFFECT_MODE_SEPIA },
457     { EFFECT_POSTERIZE,  CAM_EFFECT_MODE_POSTERIZE },
458     { EFFECT_WHITEBOARD, CAM_EFFECT_MODE_WHITEBOARD },
459     { EFFECT_BLACKBOARD, CAM_EFFECT_MODE_BLACKBOARD },
460     { EFFECT_AQUA,       CAM_EFFECT_MODE_AQUA },
461     { EFFECT_EMBOSS,     CAM_EFFECT_MODE_EMBOSS },
462     { EFFECT_SKETCH,     CAM_EFFECT_MODE_SKETCH },
463     { EFFECT_NEON,       CAM_EFFECT_MODE_NEON }
464 };
465 
466 const QCameraParameters::QCameraMap QCameraParameters::SCENE_MODES_MAP[] = {
467     { SCENE_MODE_AUTO,           CAM_SCENE_MODE_OFF },
468     { SCENE_MODE_ACTION,         CAM_SCENE_MODE_ACTION },
469     { SCENE_MODE_PORTRAIT,       CAM_SCENE_MODE_PORTRAIT },
470     { SCENE_MODE_LANDSCAPE,      CAM_SCENE_MODE_LANDSCAPE },
471     { SCENE_MODE_NIGHT,          CAM_SCENE_MODE_NIGHT },
472     { SCENE_MODE_NIGHT_PORTRAIT, CAM_SCENE_MODE_NIGHT_PORTRAIT },
473     { SCENE_MODE_THEATRE,        CAM_SCENE_MODE_THEATRE },
474     { SCENE_MODE_BEACH,          CAM_SCENE_MODE_BEACH },
475     { SCENE_MODE_SNOW,           CAM_SCENE_MODE_SNOW },
476     { SCENE_MODE_SUNSET,         CAM_SCENE_MODE_SUNSET },
477     { SCENE_MODE_STEADYPHOTO,    CAM_SCENE_MODE_ANTISHAKE },
478     { SCENE_MODE_FIREWORKS ,     CAM_SCENE_MODE_FIREWORKS },
479     { SCENE_MODE_SPORTS ,        CAM_SCENE_MODE_SPORTS },
480     { SCENE_MODE_PARTY,          CAM_SCENE_MODE_PARTY },
481     { SCENE_MODE_CANDLELIGHT,    CAM_SCENE_MODE_CANDLELIGHT },
482     { SCENE_MODE_ASD,            CAM_SCENE_MODE_AUTO },
483     { SCENE_MODE_BACKLIGHT,      CAM_SCENE_MODE_BACKLIGHT },
484     { SCENE_MODE_FLOWERS,        CAM_SCENE_MODE_FLOWERS },
485     { SCENE_MODE_AR,             CAM_SCENE_MODE_AR },
486     { SCENE_MODE_HDR,            CAM_SCENE_MODE_HDR },
487 };
488 
489 const QCameraParameters::QCameraMap QCameraParameters::FLASH_MODES_MAP[] = {
490     { FLASH_MODE_OFF,   CAM_FLASH_MODE_OFF },
491     { FLASH_MODE_AUTO,  CAM_FLASH_MODE_AUTO },
492     { FLASH_MODE_ON,    CAM_FLASH_MODE_ON },
493     { FLASH_MODE_TORCH, CAM_FLASH_MODE_TORCH }
494 };
495 
496 const QCameraParameters::QCameraMap QCameraParameters::FOCUS_ALGO_MAP[] = {
497     { FOCUS_ALGO_AUTO,            CAM_FOCUS_ALGO_AUTO },
498     { FOCUS_ALGO_SPOT_METERING,   CAM_FOCUS_ALGO_SPOT },
499     { FOCUS_ALGO_CENTER_WEIGHTED, CAM_FOCUS_ALGO_CENTER_WEIGHTED },
500     { FOCUS_ALGO_FRAME_AVERAGE,   CAM_FOCUS_ALGO_AVERAGE }
501 };
502 
503 const QCameraParameters::QCameraMap QCameraParameters::WHITE_BALANCE_MODES_MAP[] = {
504     { WHITE_BALANCE_AUTO,            CAM_WB_MODE_AUTO },
505     { WHITE_BALANCE_INCANDESCENT,    CAM_WB_MODE_INCANDESCENT },
506     { WHITE_BALANCE_FLUORESCENT,     CAM_WB_MODE_FLUORESCENT },
507     { WHITE_BALANCE_WARM_FLUORESCENT,CAM_WB_MODE_WARM_FLUORESCENT},
508     { WHITE_BALANCE_DAYLIGHT,        CAM_WB_MODE_DAYLIGHT },
509     { WHITE_BALANCE_CLOUDY_DAYLIGHT, CAM_WB_MODE_CLOUDY_DAYLIGHT },
510     { WHITE_BALANCE_TWILIGHT,        CAM_WB_MODE_TWILIGHT },
511     { WHITE_BALANCE_SHADE,           CAM_WB_MODE_SHADE }
512 };
513 
514 const QCameraParameters::QCameraMap QCameraParameters::ANTIBANDING_MODES_MAP[] = {
515     { ANTIBANDING_OFF,  CAM_ANTIBANDING_MODE_OFF },
516     { ANTIBANDING_50HZ, CAM_ANTIBANDING_MODE_50HZ },
517     { ANTIBANDING_60HZ, CAM_ANTIBANDING_MODE_60HZ },
518     { ANTIBANDING_AUTO, CAM_ANTIBANDING_MODE_AUTO }
519 };
520 
521 const QCameraParameters::QCameraMap QCameraParameters::ISO_MODES_MAP[] = {
522     { ISO_AUTO,  CAM_ISO_MODE_AUTO },
523     { ISO_HJR,   CAM_ISO_MODE_DEBLUR },
524     { ISO_100,   CAM_ISO_MODE_100 },
525     { ISO_200,   CAM_ISO_MODE_200 },
526     { ISO_400,   CAM_ISO_MODE_400 },
527     { ISO_800,   CAM_ISO_MODE_800 },
528     { ISO_1600,  CAM_ISO_MODE_1600 }
529 };
530 
531 const QCameraParameters::QCameraMap QCameraParameters::HFR_MODES_MAP[] = {
532     { VIDEO_HFR_OFF, CAM_HFR_MODE_OFF },
533     { VIDEO_HFR_2X,  CAM_HFR_MODE_60FPS },
534     { VIDEO_HFR_3X,  CAM_HFR_MODE_90FPS },
535     { VIDEO_HFR_4X,  CAM_HFR_MODE_120FPS },
536     { VIDEO_HFR_5X,  CAM_HFR_MODE_150FPS }
537 };
538 
539 const QCameraParameters::QCameraMap QCameraParameters::BRACKETING_MODES_MAP[] = {
540     { AE_BRACKET_OFF, CAM_EXP_BRACKETING_OFF },
541     { AE_BRACKET,     CAM_EXP_BRACKETING_ON }
542 };
543 
544 const QCameraParameters::QCameraMap QCameraParameters::ON_OFF_MODES_MAP[] = {
545     { VALUE_OFF, 0 },
546     { VALUE_ON,  1 }
547 };
548 
549 const QCameraParameters::QCameraMap QCameraParameters::TOUCH_AF_AEC_MODES_MAP[] = {
550     { QCameraParameters::TOUCH_AF_AEC_OFF, 0 },
551     { QCameraParameters::TOUCH_AF_AEC_ON, 1 }
552 };
553 
554 const QCameraParameters::QCameraMap QCameraParameters::ENABLE_DISABLE_MODES_MAP[] = {
555     { VALUE_ENABLE,  1 },
556     { VALUE_DISABLE, 0 }
557 };
558 
559 const QCameraParameters::QCameraMap QCameraParameters::DENOISE_ON_OFF_MODES_MAP[] = {
560     { DENOISE_OFF, 0 },
561     { DENOISE_ON,  1 }
562 };
563 
564 const QCameraParameters::QCameraMap QCameraParameters::TRUE_FALSE_MODES_MAP[] = {
565     { VALUE_FALSE, 0},
566     { VALUE_TRUE,  1}
567 };
568 
569 const QCameraParameters::QCameraMap QCameraParameters::FLIP_MODES_MAP[] = {
570     {FLIP_MODE_OFF, 0},
571     {FLIP_MODE_V, FLIP_V},
572     {FLIP_MODE_H, FLIP_H},
573     {FLIP_MODE_VH, FLIP_V_H}
574 };
575 
576 const QCameraParameters::QCameraMap QCameraParameters::AF_BRACKETING_MODES_MAP[] = {
577     { AF_BRACKET_OFF, 0 },
578     { AF_BRACKET_ON,  1 }
579 };
580 
581 const QCameraParameters::QCameraMap QCameraParameters::RE_FOCUS_MODES_MAP[] = {
582     { RE_FOCUS_OFF, 0 },
583     { RE_FOCUS_ON,  1 }
584 };
585 
586 const QCameraParameters::QCameraMap QCameraParameters::CHROMA_FLASH_MODES_MAP[] = {
587     { CHROMA_FLASH_OFF, 0 },
588     { CHROMA_FLASH_ON,  1 }
589 };
590 
591 const QCameraParameters::QCameraMap QCameraParameters::OPTI_ZOOM_MODES_MAP[] = {
592     { OPTI_ZOOM_OFF, 0 },
593     { OPTI_ZOOM_ON,  1 }
594 };
595 
596 const QCameraParameters::QCameraMap QCameraParameters::CDS_MODES_MAP[] = {
597     { CDS_MODE_OFF, CAM_CDS_MODE_OFF },
598     { CDS_MODE_ON, CAM_CDS_MODE_ON },
599     { CDS_MODE_AUTO, CAM_CDS_MODE_AUTO}
600 };
601 
602 #define DEFAULT_CAMERA_AREA "(0, 0, 0, 0, 0)"
603 #define DATA_PTR(MEM_OBJ,INDEX) MEM_OBJ->getPtr( INDEX )
604 
605 /*===========================================================================
606  * FUNCTION   : QCameraParameters
607  *
608  * DESCRIPTION: default constructor of QCameraParameters
609  *
610  * PARAMETERS : none
611  *
612  * RETURN     : None
613  *==========================================================================*/
QCameraParameters()614 QCameraParameters::QCameraParameters()
615     : CameraParameters(),
616       m_reprocScaleParam(this),
617       m_pCapability(NULL),
618       m_pCamOpsTbl(NULL),
619       m_pParamHeap(NULL),
620       m_pParamBuf(NULL),
621       m_bZslMode(false),
622       m_bZslMode_new(false),
623       m_bRecordingHint(false),
624       m_bRecordingHint_new(false),
625       m_bHistogramEnabled(false),
626       m_nFaceProcMask(0),
627       m_bFaceDetectionOn(0),
628       m_bDebugFps(false),
629       mFocusMode(CAM_FOCUS_MODE_MAX),
630       mPreviewFormat(CAM_FORMAT_YUV_420_NV21),
631       mPictureFormat(CAM_FORMAT_JPEG),
632       m_bNeedRestart(false),
633       m_bNoDisplayMode(false),
634       m_bWNROn(false),
635       m_bInited(false),
636       m_nBurstNum(1),
637       m_nRetroBurstNum(0),
638       m_nBurstLEDOnPeriod(100),
639       m_bUpdateEffects(false),
640       m_bSceneTransitionAuto(false),
641       m_bPreviewFlipChanged(false),
642       m_bVideoFlipChanged(false),
643       m_bSnapshotFlipChanged(false),
644       m_bFixedFrameRateSet(false),
645       m_bHDREnabled(false),
646       m_bAVTimerEnabled(false),
647       m_bDISEnabled(false),
648       m_AdjustFPS(NULL),
649       m_bHDR1xFrameEnabled(true),
650       m_HDRSceneEnabled(false),
651       m_bHDRThumbnailProcessNeeded(false),
652       m_bHDR1xExtraBufferNeeded(true),
653       m_bHDROutputCropEnabled(false),
654       m_tempMap(),
655       m_bAFBracketingOn(false),
656       m_bChromaFlashOn(false),
657       m_bOptiZoomOn(false),
658       m_bSceneSelection(false),
659       m_SelectedScene(CAM_SCENE_MODE_MAX),
660       m_bHfrMode(false),
661       m_bSensorHDREnabled(false),
662       m_bRdiMode(false),
663       m_bDisplayFrame(true),
664       m_bSecureMode(false),
665       m_bAeBracketingEnabled(false),
666       mFlashValue(CAM_FLASH_MODE_OFF),
667       mFlashDaemonValue(CAM_FLASH_MODE_OFF)
668 {
669     char value[PROPERTY_VALUE_MAX];
670     // TODO: may move to parameter instead of sysprop
671     property_get("persist.debug.sf.showfps", value, "0");
672     m_bDebugFps = atoi(value) > 0 ? true : false;
673     m_bReleaseTorchCamera = false;
674     m_pTorch = NULL;
675 
676     // For thermal mode, it should be set as system property
677     // because system property applies to all applications, while
678     // parameters only apply to specific app.
679     property_get("persist.camera.thermal.mode", value, "fps");
680     if (!strcmp(value, "frameskip")) {
681         m_ThermalMode = QCAMERA_THERMAL_ADJUST_FRAMESKIP;
682     } else {
683         if (strcmp(value, "fps"))
684             ALOGE("%s: Invalid camera thermal mode %s", __func__, value);
685         m_ThermalMode = QCAMERA_THERMAL_ADJUST_FPS;
686     }
687 
688     memset(&m_LiveSnapshotSize, 0, sizeof(m_LiveSnapshotSize));
689     memset(&m_default_fps_range, 0, sizeof(m_default_fps_range));
690     memset(&m_hfrFpsRange, 0, sizeof(m_hfrFpsRange));
691 }
692 
693 /*===========================================================================
694  * FUNCTION   : QCameraParameters
695  *
696  * DESCRIPTION: constructor of QCameraParameters
697  *
698  * PARAMETERS :
699  *   @params  : parameters in string
700  *
701  * RETURN     : None
702  *==========================================================================*/
QCameraParameters(const String8 & params)703 QCameraParameters::QCameraParameters(const String8 &params)
704     : CameraParameters(params),
705     m_reprocScaleParam(this),
706     m_pCapability(NULL),
707     m_pCamOpsTbl(NULL),
708     m_pParamHeap(NULL),
709     m_pParamBuf(NULL),
710     m_bZslMode(false),
711     m_bZslMode_new(false),
712     m_bRecordingHint(false),
713     m_bRecordingHint_new(false),
714     m_bHistogramEnabled(false),
715     m_nFaceProcMask(0),
716     m_bDebugFps(false),
717     mFocusMode(CAM_FOCUS_MODE_MAX),
718     mPreviewFormat(CAM_FORMAT_YUV_420_NV21),
719     mPictureFormat(CAM_FORMAT_JPEG),
720     m_bNeedRestart(false),
721     m_bNoDisplayMode(false),
722     m_bWNROn(false),
723     m_bInited(false),
724     m_nBurstNum(1),
725     m_nRetroBurstNum(0),
726     m_nBurstLEDOnPeriod(100),
727     m_bPreviewFlipChanged(false),
728     m_bVideoFlipChanged(false),
729     m_bSnapshotFlipChanged(false),
730     m_bFixedFrameRateSet(false),
731     m_bHDREnabled(false),
732     m_bAVTimerEnabled(false),
733     m_AdjustFPS(NULL),
734     m_bHDR1xFrameEnabled(true),
735     m_HDRSceneEnabled(false),
736     m_bHDRThumbnailProcessNeeded(false),
737     m_bHDR1xExtraBufferNeeded(true),
738     m_bHDROutputCropEnabled(false),
739     m_tempMap(),
740     m_bAFBracketingOn(false),
741     m_bChromaFlashOn(false),
742     m_bOptiZoomOn(false),
743     m_bSceneSelection(false),
744     m_SelectedScene(CAM_SCENE_MODE_MAX),
745     m_bHfrMode(false),
746     m_bSensorHDREnabled(false),
747     m_bRdiMode(false),
748     m_bSecureMode(false),
749     m_bAeBracketingEnabled(false),
750     mFlashValue(CAM_FLASH_MODE_OFF),
751     mFlashDaemonValue(CAM_FLASH_MODE_OFF)
752 {
753     memset(&m_LiveSnapshotSize, 0, sizeof(m_LiveSnapshotSize));
754     memset(&m_default_fps_range, 0, sizeof(m_default_fps_range));
755     memset(&m_hfrFpsRange, 0, sizeof(m_hfrFpsRange));
756     m_pTorch = NULL;
757     m_bReleaseTorchCamera = false;
758 }
759 
760 /*===========================================================================
761  * FUNCTION   : ~QCameraParameters
762  *
763  * DESCRIPTION: deconstructor of QCameraParameters
764  *
765  * PARAMETERS : none
766  *
767  * RETURN     : None
768  *==========================================================================*/
~QCameraParameters()769 QCameraParameters::~QCameraParameters()
770 {
771     deinit();
772 }
773 
774 /*===========================================================================
775  * FUNCTION   : createSizesString
776  *
777  * DESCRIPTION: create string obj contains array of dimensions
778  *
779  * PARAMETERS :
780  *   @sizes   : array of dimensions
781  *   @len     : size of dimension array
782  *
783  * RETURN     : string obj
784  *==========================================================================*/
createSizesString(const cam_dimension_t * sizes,int len)785 String8 QCameraParameters::createSizesString(const cam_dimension_t *sizes, int len)
786 {
787     String8 str;
788     char buffer[32];
789 
790     if (len > 0) {
791         snprintf(buffer, sizeof(buffer), "%dx%d", sizes[0].width, sizes[0].height);
792         str.append(buffer);
793     }
794     for (int i = 1; i < len; i++) {
795         snprintf(buffer, sizeof(buffer), ",%dx%d", sizes[i].width, sizes[i].height);
796         str.append(buffer);
797     }
798     return str;
799 }
800 
801 /*===========================================================================
802  * FUNCTION   : createValuesString
803  *
804  * DESCRIPTION: create string obj contains array of values from map when matched
805  *              from input values array
806  *
807  * PARAMETERS :
808  *   @values  : array of values
809  *   @len     : size of values array
810  *   @map     : map contains the mapping between values and enums
811  *   @map_len : size of the map
812  *
813  * RETURN     : string obj
814  *==========================================================================*/
createValuesString(const int * values,int len,const QCameraMap * map,int map_len)815 String8 QCameraParameters::createValuesString(const int *values,
816                                               int len,
817                                               const QCameraMap* map,
818                                               int map_len)
819 {
820     String8 str;
821     int count = 0;
822 
823     for (int i = 0; i < len; i++ ) {
824         for (int j = 0; j < map_len; j ++)
825             if (map[j].val == values[i]) {
826                 if (NULL != map[j].desc) {
827                     if (count > 0) {
828                         str.append(",");
829                     }
830                     str.append(map[j].desc);
831                     count++;
832                     break; //loop j
833                 }
834             }
835     }
836     return str;
837 }
838 
839 /*===========================================================================
840  * FUNCTION   : createValuesStringFromMap
841  *
842  * DESCRIPTION: create string obj contains array of values directly from map
843  *
844  * PARAMETERS :
845  *   @map     : map contains the mapping between values and enums
846  *   @map_len : size of the map
847  *
848  * RETURN     : string obj
849  *==========================================================================*/
createValuesStringFromMap(const QCameraMap * map,int map_len)850 String8 QCameraParameters::createValuesStringFromMap(const QCameraMap* map,
851                                                      int map_len)
852 {
853     String8 str;
854 
855     for (int i = 0; i < map_len; i++) {
856         if (NULL != map[i].desc) {
857             if (i > 0) {
858                 str.append(",");
859             }
860             str.append(map[i].desc);
861         }
862     }
863     return str;
864 }
865 
866 /*===========================================================================
867  * FUNCTION   : createZoomRatioValuesString
868  *
869  * DESCRIPTION: create string obj contains array of zoom ratio values
870  *
871  * PARAMETERS :
872  *   @zoomRaios  : array of zoom ratios
873  *   @length     : size of the array
874  *
875  * RETURN     : string obj
876  *==========================================================================*/
createZoomRatioValuesString(int * zoomRatios,int length)877 String8 QCameraParameters::createZoomRatioValuesString(int *zoomRatios, int length)
878 {
879     String8 str;
880     char buffer[32] = {0};
881 
882     if(length > 0){
883         snprintf(buffer, sizeof(buffer), "%d", zoomRatios[0]);
884         str.append(buffer);
885     }
886 
887     for (int i =1;i<length;i++){
888         memset(buffer, 0, sizeof(buffer));
889         snprintf(buffer, sizeof(buffer), ",%d", zoomRatios[i]);
890         str.append(buffer);
891     }
892     return str;
893 }
894 
895 /*===========================================================================
896  * FUNCTION   : createHfrValuesString
897  *
898  * DESCRIPTION: create string obj contains array of hfr values from map when
899  *              matched from input hfr values
900  *
901  * PARAMETERS :
902  *   @values  : array of hfr info
903  *   @len     : size of the array
904  *   @map     : map of hfr string value and enum
905  *   map_len  : size of map
906  *
907  * RETURN     : string obj
908  *==========================================================================*/
createHfrValuesString(const cam_hfr_info_t * values,int len,const QCameraMap * map,int map_len)909 String8 QCameraParameters::createHfrValuesString(
910                                 const cam_hfr_info_t *values,
911                                 int len,
912                                 const QCameraMap* map,
913                                 int map_len)
914 {
915     String8 str;
916     int count = 0;
917 
918     for (int i = 0; i < len; i++ ) {
919         for (int j = 0; j < map_len; j ++)
920             if (map[j].val == (int)values[i].mode) {
921                 if (NULL != map[j].desc) {
922                     if (count > 0) {
923                         str.append(",");
924                     }
925                      str.append(map[j].desc);
926                      count++;
927                      break; //loop j
928                 }
929             }
930     }
931     if (count > 0) {
932         str.append(",");
933     }
934     str.append(VIDEO_HFR_OFF);
935     return str;
936 }
937 
938 /*===========================================================================
939  * FUNCTION   : createHfrSizesString
940  *
941  * DESCRIPTION: create string obj contains array of hfr sizes
942  *
943  * PARAMETERS :
944  *   @values  : array of hfr info
945  *   @len     : size of the array
946  *
947  * RETURN     : string obj
948  *==========================================================================*/
createHfrSizesString(const cam_hfr_info_t * values,int len)949 String8 QCameraParameters::createHfrSizesString(
950                                 const cam_hfr_info_t *values,
951                                 int len)
952 {
953     String8 str;
954     char buffer[32];
955 
956     if (len > 0) {
957         snprintf(buffer, sizeof(buffer), "%dx%d",
958                  values[0].dim.width, values[0].dim.height);
959         str.append(buffer);
960     }
961     for (int i = 1; i < len; i++) {
962         snprintf(buffer, sizeof(buffer), ",%dx%d",
963                  values[i].dim.width, values[i].dim.height);
964         str.append(buffer);
965     }
966     return str;
967 }
968 
969 /*===========================================================================
970  * FUNCTION   : createFpsString
971  *
972  * DESCRIPTION: create string obj contains array of FPS rates
973  *
974  * PARAMETERS :
975  *   @fps     : default fps range
976  *
977  * RETURN     : string obj
978  *==========================================================================*/
createFpsString(cam_fps_range_t & fps)979 String8 QCameraParameters::createFpsString(cam_fps_range_t &fps)
980 {
981     char buffer[32];
982     String8 fpsValues;
983 
984     int min_fps = int(fps.min_fps);
985     int max_fps = int(fps.max_fps);
986 
987     if (min_fps < fps.min_fps){
988         min_fps++;
989     }
990     if (max_fps > fps.max_fps) {
991         max_fps--;
992     }
993     if (min_fps <= max_fps) {
994         snprintf(buffer, sizeof(buffer), "%d", min_fps);
995         fpsValues.append(buffer);
996     }
997 
998     for (int i = min_fps+1; i <= max_fps; i++) {
999         snprintf(buffer, sizeof(buffer), ",%d", i);
1000         fpsValues.append(buffer);
1001     }
1002 
1003     return fpsValues;
1004 }
1005 
1006 /*===========================================================================
1007  * FUNCTION   : createFpsRangeString
1008  *
1009  * DESCRIPTION: create string obj contains array of FPS ranges
1010  *
1011  * PARAMETERS :
1012  *   @fps     : array of fps ranges
1013  *   @len     : size of the array
1014  *   @default_fps_index : reference to index of default fps range
1015  *
1016  * RETURN     : string obj
1017  *==========================================================================*/
createFpsRangeString(const cam_fps_range_t * fps,int len,int & default_fps_index)1018 String8 QCameraParameters::createFpsRangeString(const cam_fps_range_t* fps,
1019                                                 int len,
1020                                                 int &default_fps_index)
1021 {
1022     String8 str;
1023     char buffer[32];
1024     int max_range = 0;
1025     int min_fps, max_fps;
1026 
1027     if (len > 0) {
1028         min_fps = int(fps[0].min_fps * 1000);
1029         max_fps = int(fps[0].max_fps * 1000);
1030         max_range = max_fps - min_fps;
1031         default_fps_index = 0;
1032         snprintf(buffer, sizeof(buffer), "(%d,%d)", min_fps, max_fps);
1033         str.append(buffer);
1034     }
1035     for (int i = 1; i < len; i++) {
1036         min_fps = int(fps[i].min_fps * 1000);
1037         max_fps = int(fps[i].max_fps * 1000);
1038         if (max_range < (max_fps - min_fps)) {
1039             max_range = max_fps - min_fps;
1040             default_fps_index = i;
1041         }
1042         snprintf(buffer, sizeof(buffer), ",(%d,%d)", min_fps, max_fps);
1043         str.append(buffer);
1044     }
1045     return str;
1046 }
1047 
1048 /*===========================================================================
1049  * FUNCTION   : lookupAttr
1050  *
1051  * DESCRIPTION: lookup a value by its name
1052  *
1053  * PARAMETERS :
1054  *   @attr    : map contains <name, value>
1055  *   @len     : size of the map
1056  *   @name    : name to be looked up
1057  *
1058  * RETURN     : valid value if found
1059  *              NAME_NOT_FOUND if not found
1060  *==========================================================================*/
lookupAttr(const QCameraMap arr[],int len,const char * name)1061 int QCameraParameters::lookupAttr(const QCameraMap arr[], int len, const char *name)
1062 {
1063     if (name) {
1064         for (int i = 0; i < len; i++) {
1065             if (!strcmp(arr[i].desc, name))
1066                 return arr[i].val;
1067         }
1068     }
1069     return NAME_NOT_FOUND;
1070 }
1071 
1072 /*===========================================================================
1073  * FUNCTION   : lookupNameByValue
1074  *
1075  * DESCRIPTION: lookup a name by its value
1076  *
1077  * PARAMETERS :
1078  *   @attr    : map contains <name, value>
1079  *   @len     : size of the map
1080  *   @value   : value to be looked up
1081  *
1082  * RETURN     : name str or NULL if not found
1083  *==========================================================================*/
lookupNameByValue(const QCameraMap arr[],int len,int value)1084 const char *QCameraParameters::lookupNameByValue(const QCameraMap arr[], int len, int value)
1085 {
1086     for (int i = 0; i < len; i++) {
1087         if (arr[i].val == value) {
1088             return arr[i].desc;
1089         }
1090     }
1091     return NULL;
1092 }
1093 
1094 /*===========================================================================
1095  * FUNCTION   : setPreviewSize
1096  *
1097  * DESCRIPTION: set preview size from user setting
1098  *
1099  * PARAMETERS :
1100  *   @params  : user setting parameters
1101  *
1102  * RETURN     : int32_t type of status
1103  *              NO_ERROR  -- success
1104  *              none-zero failure code
1105  *==========================================================================*/
setPreviewSize(const QCameraParameters & params)1106 int32_t QCameraParameters::setPreviewSize(const QCameraParameters& params)
1107 {
1108     int width, height;
1109     params.getPreviewSize(&width, &height);
1110     CDBG("Requested preview size %d x %d", width, height);
1111 
1112     // Validate the preview size
1113     for (size_t i = 0; i < m_pCapability->preview_sizes_tbl_cnt; ++i) {
1114         if (width ==  m_pCapability->preview_sizes_tbl[i].width
1115            && height ==  m_pCapability->preview_sizes_tbl[i].height) {
1116             // check if need to restart preview in case of preview size change
1117             int old_width, old_height;
1118             CameraParameters::getPreviewSize(&old_width, &old_height);
1119             if (width != old_width || height != old_height) {
1120                 m_bNeedRestart = true;
1121             }
1122 
1123             // set the new value
1124             CameraParameters::setPreviewSize(width, height);
1125             return NO_ERROR;
1126         }
1127     }
1128     ALOGE("Invalid preview size requested: %dx%d", width, height);
1129     return BAD_VALUE;
1130 }
1131 
1132 /*===========================================================================
1133  * FUNCTION   : setPictureSize
1134  *
1135  * DESCRIPTION: set picture size from user setting
1136  *
1137  * PARAMETERS :
1138  *   @params  : user setting parameters
1139  *
1140  * RETURN     : int32_t type of status
1141  *              NO_ERROR  -- success
1142  *              none-zero failure code
1143  *==========================================================================*/
setPictureSize(const QCameraParameters & params)1144 int32_t QCameraParameters::setPictureSize(const QCameraParameters& params)
1145 {
1146     int width, height;
1147     params.getPictureSize(&width, &height);
1148     CDBG("Requested picture size %d x %d", width, height);
1149 
1150     // Validate the picture size
1151     if(!m_reprocScaleParam.isScaleEnabled()){
1152         for (size_t i = 0; i < m_pCapability->picture_sizes_tbl_cnt; ++i) {
1153             if (width ==  m_pCapability->picture_sizes_tbl[i].width
1154                && height ==  m_pCapability->picture_sizes_tbl[i].height) {
1155                 // check if need to restart preview in case of picture size change
1156                 int old_width, old_height;
1157                 CameraParameters::getPictureSize(&old_width, &old_height);
1158                 if ((m_bZslMode || m_bRecordingHint) &&
1159                     (width != old_width || height != old_height)) {
1160                     m_bNeedRestart = true;
1161                 }
1162 
1163                 // set the new value
1164                 CameraParameters::setPictureSize(width, height);
1165                 return NO_ERROR;
1166             }
1167         }
1168     }else{
1169         //should use scaled picture size table to validate
1170         if(m_reprocScaleParam.setValidatePicSize(width, height) == NO_ERROR){
1171             // check if need to restart preview in case of picture size change
1172             int old_width, old_height;
1173             CameraParameters::getPictureSize(&old_width, &old_height);
1174             if ((m_bZslMode || m_bRecordingHint) &&
1175                 (width != old_width || height != old_height)) {
1176                 m_bNeedRestart = true;
1177             }
1178 
1179             // set the new value
1180             char val[32];
1181             sprintf(val, "%dx%d", width, height);
1182             updateParamEntry(KEY_PICTURE_SIZE, val);
1183             CDBG("%s: %s", __func__, val);
1184             return NO_ERROR;
1185         }
1186     }
1187     ALOGE("Invalid picture size requested: %dx%d", width, height);
1188     return BAD_VALUE;
1189 }
1190 
1191 /*===========================================================================
1192  * FUNCTION   : setVideoSize
1193  *
1194  * DESCRIPTION: set video size from user setting
1195  *
1196  * PARAMETERS :
1197  *   @params  : user setting parameters
1198  *
1199  * RETURN     : int32_t type of status
1200  *              NO_ERROR  -- success
1201  *              none-zero failure code
1202  *==========================================================================*/
setVideoSize(const QCameraParameters & params)1203 int32_t QCameraParameters::setVideoSize(const QCameraParameters& params)
1204 {
1205     const char *str= NULL;
1206     int width, height;
1207     str = params.get(KEY_VIDEO_SIZE);
1208     if(!str) {
1209         //If application didn't set this parameter string, use the values from
1210         //getPreviewSize() as video dimensions.
1211         params.getPreviewSize(&width, &height);
1212         ALOGE("No Record Size requested, use the preview dimensions");
1213     } else {
1214         params.getVideoSize(&width, &height);
1215     }
1216 
1217     // Validate the video size
1218     for (size_t i = 0; i < m_pCapability->video_sizes_tbl_cnt; ++i) {
1219         if (width ==  m_pCapability->video_sizes_tbl[i].width
1220                 && height ==  m_pCapability->video_sizes_tbl[i].height) {
1221             // check if need to restart preview in case of video size change
1222             int old_width, old_height;
1223             CameraParameters::getVideoSize(&old_width, &old_height);
1224             if (m_bRecordingHint &&
1225                (width != old_width || height != old_height)) {
1226                 m_bNeedRestart = true;
1227             }
1228 
1229             // set the new value
1230             CameraParameters::setVideoSize(width, height);
1231             return NO_ERROR;
1232         }
1233     }
1234 
1235     ALOGE("Invalid video size requested: %dx%d", width, height);
1236     return BAD_VALUE;
1237 }
1238 
1239 /*===========================================================================
1240  * FUNCTION   : setLiveSnapshotSize
1241  *
1242  * DESCRIPTION: set live snapshot size
1243  *
1244  * PARAMETERS :
1245  *   @params  : user setting parameters
1246  *
1247  * RETURN     : int32_t type of status
1248  *              NO_ERROR  -- success
1249  *              none-zero failure code
1250  *==========================================================================*/
setLiveSnapshotSize(const QCameraParameters & params)1251 int32_t QCameraParameters::setLiveSnapshotSize(const QCameraParameters& params)
1252 {
1253     char value[PROPERTY_VALUE_MAX];
1254     property_get("persist.camera.opt.livepic", value, "1");
1255     bool useOptimal = atoi(value) > 0 ? true : false;
1256 
1257     // use picture size from user setting
1258     params.getPictureSize(&m_LiveSnapshotSize.width, &m_LiveSnapshotSize.height);
1259 
1260     uint8_t livesnapshot_sizes_tbl_cnt = m_pCapability->livesnapshot_sizes_tbl_cnt;
1261     cam_dimension_t *livesnapshot_sizes_tbl = &m_pCapability->livesnapshot_sizes_tbl[0];
1262 
1263     // check if HFR is enabled
1264     const char *hfrStr = params.get(KEY_QC_VIDEO_HIGH_FRAME_RATE);
1265     cam_hfr_mode_t hfrMode = CAM_HFR_MODE_OFF;
1266     const char *hsrStr = params.get(KEY_QC_VIDEO_HIGH_SPEED_RECORDING);
1267 
1268     if (hsrStr != NULL && !strcmp(hsrStr, "on")) {
1269         for (int i = 0; i < m_pCapability->hfr_tbl_cnt; i++) {
1270             if (m_pCapability->hfr_tbl[i].mode == CAM_HFR_MODE_120FPS) {
1271                 livesnapshot_sizes_tbl_cnt =
1272                     m_pCapability->hfr_tbl[i].livesnapshot_sizes_tbl_cnt;
1273                 livesnapshot_sizes_tbl =
1274                     &m_pCapability->hfr_tbl[i].livesnapshot_sizes_tbl[0];
1275                 hfrMode = m_pCapability->hfr_tbl[i].mode;
1276                 break;
1277             }
1278         }
1279     }
1280     else if (hfrStr != NULL) {
1281         int32_t value = lookupAttr(HFR_MODES_MAP,
1282                                    sizeof(HFR_MODES_MAP)/sizeof(QCameraMap),
1283                                    hfrStr);
1284         if (value != NAME_NOT_FOUND) {
1285             // if HFR is enabled, change live snapshot size
1286             if (value > CAM_HFR_MODE_OFF) {
1287                 for (int i = 0; i < m_pCapability->hfr_tbl_cnt; i++) {
1288                     if (m_pCapability->hfr_tbl[i].mode == value) {
1289                         livesnapshot_sizes_tbl_cnt =
1290                             m_pCapability->hfr_tbl[i].livesnapshot_sizes_tbl_cnt;
1291                         livesnapshot_sizes_tbl =
1292                             &m_pCapability->hfr_tbl[i].livesnapshot_sizes_tbl[0];
1293                         hfrMode = m_pCapability->hfr_tbl[i].mode;
1294                         break;
1295                     }
1296                 }
1297             }
1298         }
1299     }
1300 
1301     if (useOptimal || hfrMode != CAM_HFR_MODE_OFF) {
1302         bool found = false;
1303 
1304         // first check if picture size is within the list of supported sizes
1305         for (int i = 0; i < livesnapshot_sizes_tbl_cnt; ++i) {
1306             if (m_LiveSnapshotSize.width == livesnapshot_sizes_tbl[i].width &&
1307                 m_LiveSnapshotSize.height == livesnapshot_sizes_tbl[i].height) {
1308                 found = true;
1309                 break;
1310             }
1311         }
1312 
1313         if (!found) {
1314             // use optimal live snapshot size from supported list,
1315             // that has same preview aspect ratio
1316             int width = 0, height = 0;
1317             params.getPreviewSize(&width, &height);
1318 
1319             double previewAspectRatio = (double)width / height;
1320             for (int i = 0; i < livesnapshot_sizes_tbl_cnt; ++i) {
1321                 double ratio = (double)livesnapshot_sizes_tbl[i].width /
1322                                 livesnapshot_sizes_tbl[i].height;
1323                 if (fabs(previewAspectRatio - ratio) <= ASPECT_TOLERANCE) {
1324                     m_LiveSnapshotSize = livesnapshot_sizes_tbl[i];
1325                     found = true;
1326                     break;
1327                 }
1328             }
1329 
1330             if (!found && hfrMode != CAM_HFR_MODE_OFF) {
1331                 // Cannot find matching aspect ration from supported live snapshot list
1332                 // choose the max dim from preview and video size
1333                 CDBG("%s: Cannot find matching aspect ratio, choose max of preview or video size", __func__);
1334                 params.getVideoSize(&m_LiveSnapshotSize.width, &m_LiveSnapshotSize.height);
1335                 if (m_LiveSnapshotSize.width < width && m_LiveSnapshotSize.height < height) {
1336                     m_LiveSnapshotSize.width = width;
1337                     m_LiveSnapshotSize.height = height;
1338                 }
1339             }
1340         }
1341     }
1342     CDBG("%s: live snapshot size %d x %d", __func__,
1343           m_LiveSnapshotSize.width, m_LiveSnapshotSize.height);
1344 
1345     return NO_ERROR;
1346 }
1347 
1348 
1349 /*===========================================================================
1350  * FUNCTION   : setRawSize
1351  *
1352  * DESCRIPTION: set live snapshot size
1353  *
1354  * PARAMETERS :
1355  *   @params  : user setting parameters
1356  *
1357  * RETURN     : int32_t type of status
1358  *              NO_ERROR  -- success
1359  *              none-zero failure code
1360  *==========================================================================*/
setRawSize(cam_dimension_t & dim)1361 int32_t QCameraParameters::setRawSize(cam_dimension_t &dim)
1362 {
1363     m_rawSize = dim;
1364     return NO_ERROR;
1365 }
1366 /*===========================================================================
1367  * FUNCTION   : setPreviewFormat
1368  *
1369  * DESCRIPTION: set preview format from user setting
1370  *
1371  * PARAMETERS :
1372  *   @params  : user setting parameters
1373  *
1374  * RETURN     : int32_t type of status
1375  *              NO_ERROR  -- success
1376  *              none-zero failure code
1377  *==========================================================================*/
setPreviewFormat(const QCameraParameters & params)1378 int32_t QCameraParameters::setPreviewFormat(const QCameraParameters& params)
1379 {
1380     const char *str = params.getPreviewFormat();
1381     int32_t previewFormat =
1382         lookupAttr(PREVIEW_FORMATS_MAP,
1383                    sizeof(PREVIEW_FORMATS_MAP) / sizeof(QCameraMap),
1384                    str);
1385     if (previewFormat != NAME_NOT_FOUND) {
1386         mPreviewFormat = (cam_format_t)previewFormat;
1387 
1388         CameraParameters::setPreviewFormat(str);
1389         CDBG_HIGH("%s: format %d\n", __func__, mPreviewFormat);
1390         return NO_ERROR;
1391     }
1392     ALOGE("Invalid preview format value: %s", (str == NULL) ? "NULL" : str);
1393     return BAD_VALUE;
1394 }
1395 
1396 /*===========================================================================
1397  * FUNCTION   : setPictureFormat
1398  *
1399  * DESCRIPTION: set picture format from user setting
1400  *
1401  * PARAMETERS :
1402  *   @params  : user setting parameters
1403  *
1404  * RETURN     : int32_t type of status
1405  *              NO_ERROR  -- success
1406  *              none-zero failure code
1407  *==========================================================================*/
setPictureFormat(const QCameraParameters & params)1408 int32_t QCameraParameters::setPictureFormat(const QCameraParameters& params)
1409 {
1410     const char *str = params.getPictureFormat();
1411     int32_t pictureFormat =
1412         lookupAttr(PICTURE_TYPES_MAP,
1413                    sizeof(PICTURE_TYPES_MAP) / sizeof(QCameraMap),
1414                    str);
1415     if (pictureFormat != NAME_NOT_FOUND) {
1416         mPictureFormat = pictureFormat;
1417 
1418         CameraParameters::setPictureFormat(str);
1419         CDBG_HIGH("%s: format %d\n", __func__, mPictureFormat);
1420         return NO_ERROR;
1421     }
1422     ALOGE("%s: Invalid picture format value: %s", __func__, (str == NULL) ? "NULL" : str);
1423     return BAD_VALUE;
1424 }
1425 
1426 /*===========================================================================
1427  * FUNCTION   : setJpegThumbnailSize
1428  *
1429  * DESCRIPTION: set jpeg thumbnail size from user setting
1430  *
1431  * PARAMETERS :
1432  *   @params  : user setting parameters
1433  *
1434  * RETURN     : int32_t type of status
1435  *              NO_ERROR  -- success
1436  *              none-zero failure code
1437  *==========================================================================*/
setJpegThumbnailSize(const QCameraParameters & params)1438 int32_t QCameraParameters::setJpegThumbnailSize(const QCameraParameters& params)
1439 {
1440     int width = params.getInt(KEY_JPEG_THUMBNAIL_WIDTH);
1441     int height = params.getInt(KEY_JPEG_THUMBNAIL_HEIGHT);
1442 
1443     CDBG("requested jpeg thumbnail size %d x %d", width, height);
1444 
1445     int sizes_cnt = sizeof(THUMBNAIL_SIZES_MAP) / sizeof(cam_dimension_t);
1446 
1447     cam_dimension_t dim;
1448 
1449     // While taking livesnaphot match jpeg thumbnail size aspect
1450     // ratio to liveshot size. For normal snapshot match thumbnail
1451     // aspect ratio to picture size.
1452     if (m_bRecordingHint) {
1453         getLiveSnapshotSize(dim);
1454     } else {
1455         params.getPictureSize(&dim.width, &dim.height);
1456     }
1457 
1458     if (0 == dim.height) {
1459         ALOGE("%s: picture size is invalid (%d x %d)", __func__, dim.width, dim.height);
1460         return BAD_VALUE;
1461     }
1462     double picAspectRatio = (double)dim.width / (double)dim.height;
1463 
1464     int optimalWidth = 0, optimalHeight = 0;
1465     if (width != 0 || height != 0) {
1466         // If input jpeg thumnmail size is (0,0), meaning no thumbnail needed
1467         // hornor this setting.
1468         // Otherwise, search for optimal jpeg thumbnail size that has the same
1469         // aspect ratio as picture size.
1470         // If missign jpeg thumbnail size with appropriate aspect ratio,
1471         // just honor setting supplied by application.
1472 
1473         // Try to find a size matches aspect ratio and has the largest width
1474         for (int i = 0; i < sizes_cnt; i++) {
1475             if (THUMBNAIL_SIZES_MAP[i].height == 0) {
1476                 // No thumbnail case, just skip
1477                 continue;
1478             }
1479             double ratio =
1480                 (double)THUMBNAIL_SIZES_MAP[i].width / THUMBNAIL_SIZES_MAP[i].height;
1481             if (fabs(ratio - picAspectRatio) > ASPECT_TOLERANCE)  {
1482                 continue;
1483             }
1484             if (THUMBNAIL_SIZES_MAP[i].width > optimalWidth) {
1485                 optimalWidth = THUMBNAIL_SIZES_MAP[i].width;
1486                 optimalHeight = THUMBNAIL_SIZES_MAP[i].height;
1487             }
1488         }
1489 
1490         if ((0 == optimalWidth) || (0 == optimalHeight)) {
1491             // Optimal size not found
1492             // Validate thumbnail size
1493             for (int i = 0; i < sizes_cnt; i++) {
1494                 if (width == THUMBNAIL_SIZES_MAP[i].width &&
1495                     height == THUMBNAIL_SIZES_MAP[i].height) {
1496                     optimalWidth = width;
1497                     optimalHeight = height;
1498                     break;
1499                 }
1500             }
1501         }
1502     }
1503 
1504     set(KEY_JPEG_THUMBNAIL_WIDTH, optimalWidth);
1505     set(KEY_JPEG_THUMBNAIL_HEIGHT, optimalHeight);
1506     return NO_ERROR;
1507 }
1508 
1509 /*===========================================================================
1510 
1511  * FUNCTION   : setBurstLEDOnPeriod
1512  *
1513  * DESCRIPTION: set burst LED on period
1514  *
1515  * PARAMETERS :
1516  *   @params  : user setting parameters
1517  *
1518  * RETURN     : int32_t type of status
1519  *              NO_ERROR  -- success
1520  *              none-zero failure code
1521  *==========================================================================*/
setBurstLEDOnPeriod(const QCameraParameters & params)1522 int32_t QCameraParameters::setBurstLEDOnPeriod(const QCameraParameters& params)
1523 {
1524     uint32_t nBurstLEDOnPeriod =
1525       params.getInt(KEY_QC_SNAPSHOT_BURST_LED_ON_PERIOD);
1526     //Check if the LED ON period is within limits
1527     if ((nBurstLEDOnPeriod <= 0) || (nBurstLEDOnPeriod > 800)) {
1528         // if burst led on period is not set in parameters,
1529         // read from sys prop
1530         char prop[PROPERTY_VALUE_MAX];
1531         memset(prop, 0, sizeof(prop));
1532         property_get("persist.camera.led.on.period", prop, "0");
1533         nBurstLEDOnPeriod = atoi(prop);
1534         if (nBurstLEDOnPeriod <= 0) {
1535             nBurstLEDOnPeriod = 100;
1536         }
1537     }
1538 
1539     set(KEY_QC_SNAPSHOT_BURST_LED_ON_PERIOD, nBurstLEDOnPeriod);
1540     m_nBurstLEDOnPeriod = nBurstLEDOnPeriod;
1541     CDBG_HIGH("%s: Burst LED on period  %d", __func__, nBurstLEDOnPeriod);
1542     return AddSetParmEntryToBatch(m_pParamBuf,
1543                                   CAM_INTF_PARM_BURST_LED_ON_PERIOD,
1544                                   sizeof(nBurstLEDOnPeriod),
1545                                   &nBurstLEDOnPeriod);
1546 }
1547 
1548 
1549 
1550 /*===========================================================================
1551  * FUNCTION   : setRetroActiveBurstNum
1552  *
1553  * DESCRIPTION: set retro active burst num
1554  *
1555  * PARAMETERS :
1556  *   @params  : user setting parameters
1557  *
1558  * RETURN     : int32_t type of status
1559  *              NO_ERROR  -- success
1560  *              none-zero failure code
1561  *==========================================================================*/
setRetroActiveBurstNum(const QCameraParameters & params)1562 int32_t QCameraParameters::setRetroActiveBurstNum(
1563     const QCameraParameters& params)
1564 {
1565     int32_t nBurstNum = params.getInt(KEY_QC_NUM_RETRO_BURST_PER_SHUTTER);
1566     CDBG_HIGH("%s:[ZSL Retro] m_nRetroBurstNum = %d", __func__, m_nRetroBurstNum);
1567     if (nBurstNum <= 0) {
1568         // if burst number is not set in parameters,
1569         // read from sys prop
1570         char prop[PROPERTY_VALUE_MAX];
1571         memset(prop, 0, sizeof(prop));
1572         property_get("persist.camera.retro.number", prop, "0");
1573         nBurstNum = atoi(prop);
1574         if (nBurstNum < 0) {
1575             nBurstNum = 0;
1576         }
1577     }
1578 
1579     set(KEY_QC_NUM_RETRO_BURST_PER_SHUTTER, nBurstNum);
1580 
1581     m_nRetroBurstNum = nBurstNum;
1582     CDBG_HIGH("%s: [ZSL Retro] m_nRetroBurstNum = %d", __func__, m_nRetroBurstNum);
1583     return NO_ERROR;
1584 }
1585 
1586 /*===========================================================================
1587  * FUNCTION   : setJpegQuality
1588  *
1589  * DESCRIPTION: set jpeg encpding quality from user setting
1590  *
1591  * PARAMETERS :
1592  *   @params  : user setting parameters
1593  *
1594  * RETURN     : int32_t type of status
1595  *              NO_ERROR  -- success
1596  *              none-zero failure code
1597  *==========================================================================*/
setJpegQuality(const QCameraParameters & params)1598 int32_t QCameraParameters::setJpegQuality(const QCameraParameters& params)
1599 {
1600     int32_t rc = NO_ERROR;
1601     int quality = params.getInt(KEY_JPEG_QUALITY);
1602     if (quality >= 0 && quality <= 100) {
1603         set(KEY_JPEG_QUALITY, quality);
1604     } else {
1605         ALOGE("%s: Invalid jpeg quality=%d", __func__, quality);
1606         rc = BAD_VALUE;
1607     }
1608 
1609     quality = params.getInt(KEY_JPEG_THUMBNAIL_QUALITY);
1610     if (quality >= 0 && quality <= 100) {
1611         set(KEY_JPEG_THUMBNAIL_QUALITY, quality);
1612     } else {
1613         ALOGE("%s: Invalid jpeg thumbnail quality=%d", __func__, quality);
1614         rc = BAD_VALUE;
1615     }
1616     return rc;
1617 }
1618 
1619 /*===========================================================================
1620  * FUNCTION   : setOrientaion
1621  *
1622  * DESCRIPTION: set orientaion from user setting
1623  *
1624  * PARAMETERS :
1625  *   @params  : user setting parameters
1626  *
1627  * RETURN     : int32_t type of status
1628  *              NO_ERROR  -- success
1629  *              none-zero failure code
1630  *==========================================================================*/
setOrientation(const QCameraParameters & params)1631 int32_t QCameraParameters::setOrientation(const QCameraParameters& params)
1632 {
1633     const char *str = params.get(KEY_QC_ORIENTATION);
1634 
1635     if (str != NULL) {
1636         if (strcmp(str, portrait) == 0 || strcmp(str, landscape) == 0) {
1637             // Camera service needs this to decide if the preview frames and raw
1638             // pictures should be rotated.
1639             set(KEY_QC_ORIENTATION, str);
1640         } else {
1641             ALOGE("%s: Invalid orientation value: %s", __func__, str);
1642             return BAD_VALUE;
1643         }
1644     }
1645     return NO_ERROR;
1646 }
1647 
1648 /*===========================================================================
1649  * FUNCTION   : setAutoExposure
1650  *
1651  * DESCRIPTION: set auto exposure value from user setting
1652  *
1653  * PARAMETERS :
1654  *   @params  : user setting parameters
1655  *
1656  * RETURN     : int32_t type of status
1657  *              NO_ERROR  -- success
1658  *              none-zero failure code
1659  *==========================================================================*/
setAutoExposure(const QCameraParameters & params)1660 int32_t QCameraParameters::setAutoExposure(const QCameraParameters& params)
1661 {
1662     const char *str = params.get(KEY_QC_AUTO_EXPOSURE);
1663     const char *prev_str = get(KEY_QC_AUTO_EXPOSURE);
1664     if (str != NULL) {
1665         if (prev_str == NULL ||
1666             strcmp(str, prev_str) != 0) {
1667             return setAutoExposure(str);
1668         }
1669     }
1670     return NO_ERROR;
1671 }
1672 
1673 /*===========================================================================
1674  * FUNCTION   : setPreviewFpsRange
1675  *
1676  * DESCRIPTION: set preview FPS range from user setting
1677  *
1678  * PARAMETERS :
1679  *   @params  : user setting parameters
1680  *
1681  * RETURN     : int32_t type of status
1682  *              NO_ERROR  -- success
1683  *              none-zero failure code
1684  *==========================================================================*/
setPreviewFpsRange(const QCameraParameters & params)1685 int32_t QCameraParameters::setPreviewFpsRange(const QCameraParameters& params)
1686 {
1687     int minFps,maxFps;
1688     int prevMinFps, prevMaxFps, vidMinFps, vidMaxFps;
1689     int rc = NO_ERROR;
1690     bool found = false, updateNeeded = false;
1691 
1692     CameraParameters::getPreviewFpsRange(&prevMinFps, &prevMaxFps);
1693     params.getPreviewFpsRange(&minFps, &maxFps);
1694 
1695     CDBG_HIGH("%s: FpsRange Values:(%d, %d)", __func__, prevMinFps, prevMaxFps);
1696     CDBG_HIGH("%s: Requested FpsRange Values:(%d, %d)", __func__, minFps, maxFps);
1697 
1698     //first check if we need to change fps because of HFR mode change
1699     updateNeeded = UpdateHFRFrameRate(params);
1700     CDBG_HIGH("%s: UpdateHFRFrameRate %d", __func__, updateNeeded);
1701 
1702     vidMinFps = m_hfrFpsRange.video_min_fps;
1703     vidMaxFps = m_hfrFpsRange.video_max_fps;
1704 
1705     if(minFps == prevMinFps && maxFps == prevMaxFps) {
1706         if ( m_bFixedFrameRateSet ) {
1707             minFps = params.getPreviewFrameRate() * 1000;
1708             maxFps = params.getPreviewFrameRate() * 1000;
1709             m_bFixedFrameRateSet = false;
1710         } else if (!updateNeeded) {
1711             CDBG_HIGH("%s: No change in FpsRange", __func__);
1712             rc = NO_ERROR;
1713             goto end;
1714         }
1715     }
1716     for(int i = 0; i < m_pCapability->fps_ranges_tbl_cnt; i++) {
1717         // if the value is in the supported list
1718         if(minFps >= m_pCapability->fps_ranges_tbl[i].min_fps * 1000 &&
1719            maxFps <= m_pCapability->fps_ranges_tbl[i].max_fps * 1000) {
1720             found = true;
1721             CDBG_HIGH("%s: FPS i=%d : minFps = %d, maxFps = %d"
1722                     " vidMinFps = %d, vidMaxFps = %d",
1723                     __func__, i, minFps, maxFps,
1724                     (int)m_hfrFpsRange.video_min_fps,
1725                     (int)m_hfrFpsRange.video_max_fps);
1726             if ((m_hfrFpsRange.video_min_fps == 0) ||
1727                     (m_hfrFpsRange.video_max_fps == 0)) {
1728                 vidMinFps = minFps;
1729                 vidMaxFps = maxFps;
1730             }
1731             else {
1732                 vidMinFps = m_hfrFpsRange.video_min_fps;
1733                 vidMaxFps = m_hfrFpsRange.video_max_fps;
1734             }
1735 
1736             setPreviewFpsRange(minFps, maxFps, vidMinFps, vidMaxFps);
1737             break;
1738         }
1739     }
1740     if(found == false){
1741         ALOGE("%s: error: FPS range value not supported", __func__);
1742         rc = BAD_VALUE;
1743     }
1744 end:
1745     return rc;
1746 }
1747 
1748 /*===========================================================================
1749  * FUNCTION   : UpdateHFRFrameRate
1750  *
1751  * DESCRIPTION: set preview FPS range based on HFR setting
1752  *
1753  * PARAMETERS :
1754  *   @params  : user setting parameters
1755  *
1756  * RETURN     : bool true/false
1757  *                  true -if HAL needs to overwrite FPS range set by app, false otherwise.
1758  *==========================================================================*/
1759 
UpdateHFRFrameRate(const QCameraParameters & params)1760 bool QCameraParameters::UpdateHFRFrameRate(const QCameraParameters& params)
1761 {
1762     bool updateNeeded = false;
1763     int min_fps, max_fps;
1764     int32_t hfrMode = CAM_HFR_MODE_OFF;
1765 
1766     int parm_minfps,parm_maxfps;
1767     int prevMinFps, prevMaxFps;
1768     CameraParameters::getPreviewFpsRange(&prevMinFps, &prevMaxFps);
1769     params.getPreviewFpsRange(&parm_minfps, &parm_maxfps);
1770     CDBG_HIGH("%s: CameraParameters - : minFps = %d, maxFps = %d ",
1771                 __func__, prevMinFps, prevMaxFps);
1772     CDBG_HIGH("%s: Requested params - : minFps = %d, maxFps = %d ",
1773                 __func__, parm_minfps, parm_maxfps);
1774 
1775     // check if HFR is enabled
1776     const char *hfrStr = params.get(KEY_QC_VIDEO_HIGH_FRAME_RATE);
1777     const char *prev_hfrStr = get(KEY_QC_VIDEO_HIGH_FRAME_RATE);
1778     CDBG_HIGH("%s: prevHfrStr - %s, hfrStr = %s ",
1779                 __func__, prev_hfrStr, hfrStr);
1780     if(hfrStr != NULL){
1781         hfrMode = lookupAttr(HFR_MODES_MAP,
1782                                sizeof(HFR_MODES_MAP)/sizeof(QCameraMap),
1783                                hfrStr);
1784     }
1785     // check if HSR is enabled
1786     const char *hsrStr = params.get(KEY_QC_VIDEO_HIGH_SPEED_RECORDING);
1787     const char *prev_hsrStr = get(KEY_QC_VIDEO_HIGH_SPEED_RECORDING);
1788 
1789     if (hsrStr != NULL && !strcmp(hsrStr, "on")) {
1790         CDBG_HIGH("%s: HSR mode enabled ", __func__);
1791         hfrMode = CAM_HFR_MODE_120FPS;
1792     }
1793 
1794     // if HSR is made ON just now
1795     if(hsrStr != NULL && (prev_hsrStr == NULL || (strcmp(hsrStr, prev_hsrStr))) &&
1796         !strcmp(hsrStr, "on")) {
1797         min_fps = 120000;
1798         max_fps = 120000;
1799         m_hfrFpsRange.video_min_fps = min_fps;
1800         m_hfrFpsRange.video_max_fps = max_fps;
1801 
1802         CDBG_HIGH("%s: HFR mode change - Set FPS : minFps = %d, maxFps = %d ",
1803                __func__,min_fps,max_fps);
1804         updateNeeded = true;
1805     }
1806 
1807     // else if HSR is made OFF just now or HSR is OFF for some time
1808     // and HFR is changed just now
1809     else if (hfrStr != NULL && ((prev_hfrStr == NULL || strcmp(hfrStr,prev_hfrStr)) ||
1810         (hsrStr != NULL && (prev_hsrStr == NULL || strcmp(hsrStr, prev_hsrStr)))) &&
1811         ((hsrStr != NULL && strcmp(hsrStr, "on"))|| hsrStr == NULL)) {
1812         if (hfrMode != NAME_NOT_FOUND) {
1813             // if HFR is enabled, change fps range
1814             switch(hfrMode){
1815                 case CAM_HFR_MODE_60FPS:
1816                     min_fps = 60000;
1817                     max_fps = 60000;
1818                     break;
1819                 case CAM_HFR_MODE_90FPS:
1820                     min_fps = 90000;
1821                     max_fps = 90000;
1822                     break;
1823                 case CAM_HFR_MODE_120FPS:
1824                     min_fps = 120000;
1825                     max_fps = 120000;
1826                     break;
1827                 case CAM_HFR_MODE_150FPS:
1828                     min_fps = 150000;
1829                     max_fps = 150000;
1830                     break;
1831                 case CAM_HFR_MODE_OFF:
1832                 default:
1833                     // Set Video Fps to zero
1834                     min_fps = 0;
1835                     max_fps = 0;
1836                     break;
1837             }
1838             m_hfrFpsRange.video_min_fps = min_fps;
1839             m_hfrFpsRange.video_max_fps = max_fps;
1840 
1841             CDBG_HIGH("%s: HFR mode (%d) Set video FPS : minFps = %d, maxFps = %d ",
1842                    __func__, hfrMode, min_fps, max_fps);
1843             // Signifies that there is a change in video FPS and need to set Fps
1844             updateNeeded = true;
1845         }
1846     }
1847     // Remember if HFR mode is ON
1848     if ((hfrMode > CAM_HFR_MODE_OFF) && (hfrMode < CAM_HFR_MODE_MAX)){
1849         CDBG_HIGH("HFR mode is ON");
1850         m_bHfrMode = true;
1851     }
1852     else {
1853         m_hfrFpsRange.video_min_fps = 0;
1854         m_hfrFpsRange.video_max_fps = 0;
1855         m_bHfrMode = false;
1856         CDBG_HIGH("HFR mode is OFF");
1857     }
1858     return updateNeeded;
1859 }
1860 
1861 /*===========================================================================
1862  * FUNCTION   : setPreviewFrameRate
1863  *
1864  * DESCRIPTION: set preview frame rate from user setting
1865  *
1866  * PARAMETERS :
1867  *   @params  : user setting parameters
1868  *
1869  * RETURN     : int32_t type of status
1870  *              NO_ERROR  -- success
1871  *              none-zero failure code
1872  *==========================================================================*/
setPreviewFrameRate(const QCameraParameters & params)1873 int32_t QCameraParameters::setPreviewFrameRate(const QCameraParameters& params)
1874 {
1875     const char *str = params.get(KEY_PREVIEW_FRAME_RATE);
1876     const char *prev_str = get(KEY_PREVIEW_FRAME_RATE);
1877 
1878     if ( str ) {
1879         if ( prev_str &&
1880              strcmp(str, prev_str)) {
1881             CDBG("%s: Requested Fixed Frame Rate %s", __func__, str);
1882             updateParamEntry(KEY_PREVIEW_FRAME_RATE, str);
1883             m_bFixedFrameRateSet = true;
1884         }
1885     }
1886     return NO_ERROR;
1887 }
1888 
1889 /*===========================================================================
1890  * FUNCTION   : setEffect
1891  *
1892  * DESCRIPTION: set effect value from user setting
1893  *
1894  * PARAMETERS :
1895  *   @params  : user setting parameters
1896  *
1897  * RETURN     : int32_t type of status
1898  *              NO_ERROR  -- success
1899  *              none-zero failure code
1900  *==========================================================================*/
setEffect(const QCameraParameters & params)1901 int32_t QCameraParameters::setEffect(const QCameraParameters& params)
1902 {
1903     const char *str = params.get(KEY_EFFECT);
1904     const char *prev_str = get(KEY_EFFECT);
1905     if (str != NULL) {
1906         if (prev_str == NULL ||
1907             strcmp(str, prev_str) != 0 ||
1908             m_bUpdateEffects == true ) {
1909             m_bUpdateEffects = false;
1910             return setEffect(str);
1911         }
1912     }
1913     return NO_ERROR;
1914 }
1915 
1916 /*===========================================================================
1917  * FUNCTION   : setFocusMode
1918  *
1919  * DESCRIPTION: set focus mode from user setting
1920  *
1921  * PARAMETERS :
1922  *   @params  : user setting parameters
1923  *
1924  * RETURN     : int32_t type of status
1925  *              NO_ERROR  -- success
1926  *              none-zero failure code
1927  *==========================================================================*/
setFocusMode(const QCameraParameters & params)1928 int32_t QCameraParameters::setFocusMode(const QCameraParameters& params)
1929 {
1930     const char *str = params.get(KEY_FOCUS_MODE);
1931     const char *prev_str = get(KEY_FOCUS_MODE);
1932     if (str != NULL) {
1933         if (prev_str == NULL ||
1934             strcmp(str, prev_str) != 0) {
1935             return setFocusMode(str);
1936         }
1937     }
1938     return NO_ERROR;
1939 }
1940 
1941 /*===========================================================================
1942  * FUNCTION   : setBrightness
1943  *
1944  * DESCRIPTION: set brightness control value from user setting
1945  *
1946  * PARAMETERS :
1947  *   @params  : user setting parameters
1948  *
1949  * RETURN     : int32_t type of status
1950  *              NO_ERROR  -- success
1951  *              none-zero failure code
1952  *==========================================================================*/
setBrightness(const QCameraParameters & params)1953 int32_t QCameraParameters::setBrightness(const QCameraParameters& params)
1954 {
1955     int currentBrightness = getInt(KEY_QC_BRIGHTNESS);
1956     int brightness = params.getInt(KEY_QC_BRIGHTNESS);
1957 
1958     if(params.get(KEY_QC_BRIGHTNESS) == NULL) {
1959        CDBG_HIGH("%s: Brigtness not set by App ",__func__);
1960        return NO_ERROR;
1961     }
1962     if (currentBrightness !=  brightness) {
1963         if (brightness >= m_pCapability->brightness_ctrl.min_value &&
1964             brightness <= m_pCapability->brightness_ctrl.max_value) {
1965             CDBG(" new brightness value : %d ", brightness);
1966             return setBrightness(brightness);
1967         } else {
1968             ALOGE("%s: invalid value %d out of (%d, %d)",
1969                   __func__, brightness,
1970                   m_pCapability->brightness_ctrl.min_value,
1971                   m_pCapability->brightness_ctrl.max_value);
1972             return BAD_VALUE;
1973         }
1974     } else {
1975         CDBG("%s: No brightness value changed.", __func__);
1976         return NO_ERROR;
1977     }
1978 }
1979 
1980 /*===========================================================================
1981  * FUNCTION   : setSharpness
1982  *
1983  * DESCRIPTION: set sharpness control value from user setting
1984  *
1985  * PARAMETERS :
1986  *   @params  : user setting parameters
1987  *
1988  * RETURN     : int32_t type of status
1989  *              NO_ERROR  -- success
1990  *              none-zero failure code
1991  *==========================================================================*/
setSharpness(const QCameraParameters & params)1992 int32_t QCameraParameters::setSharpness(const QCameraParameters& params)
1993 {
1994     int shaprness = params.getInt(KEY_QC_SHARPNESS);
1995     int prev_sharp = getInt(KEY_QC_SHARPNESS);
1996 
1997     if(params.get(KEY_QC_SHARPNESS) == NULL) {
1998        CDBG_HIGH("%s: Sharpness not set by App ",__func__);
1999        return NO_ERROR;
2000     }
2001     if (prev_sharp !=  shaprness) {
2002         if((shaprness >= m_pCapability->sharpness_ctrl.min_value) &&
2003            (shaprness <= m_pCapability->sharpness_ctrl.max_value)) {
2004             CDBG(" new sharpness value : %d ", shaprness);
2005             return setSharpness(shaprness);
2006         } else {
2007             ALOGE("%s: invalid value %d out of (%d, %d)",
2008                   __func__, shaprness,
2009                   m_pCapability->sharpness_ctrl.min_value,
2010                   m_pCapability->sharpness_ctrl.max_value);
2011             return BAD_VALUE;
2012         }
2013     } else {
2014         CDBG("%s: No value change in shaprness", __func__);
2015         return NO_ERROR;
2016     }
2017 }
2018 
2019 /*===========================================================================
2020  * FUNCTION   : setSkintoneEnahancement
2021  *
2022  * DESCRIPTION: set skin tone enhancement factor from user setting
2023  *
2024  * PARAMETERS :
2025  *   @params  : user setting parameters
2026  *
2027  * RETURN     : int32_t type of status
2028  *              NO_ERROR  -- success
2029  *              none-zero failure code
2030  *==========================================================================*/
setSkinToneEnhancement(const QCameraParameters & params)2031 int32_t QCameraParameters::setSkinToneEnhancement(const QCameraParameters& params)
2032 {
2033     int sceFactor = params.getInt(KEY_QC_SCE_FACTOR);
2034     int prev_sceFactor = getInt(KEY_QC_SCE_FACTOR);
2035 
2036     if(params.get(KEY_QC_SCE_FACTOR) == NULL) {
2037        CDBG_HIGH("%s: Skintone enhancement not set by App ",__func__);
2038        return NO_ERROR;
2039     }
2040     if (prev_sceFactor != sceFactor) {
2041         if((sceFactor >= m_pCapability->sce_ctrl.min_value) &&
2042            (sceFactor <= m_pCapability->sce_ctrl.max_value)) {
2043             CDBG(" new Skintone Enhancement value : %d ", sceFactor);
2044             return setSkinToneEnhancement(sceFactor);
2045         } else {
2046             ALOGE("%s: invalid value %d out of (%d, %d)",
2047                   __func__, sceFactor,
2048                   m_pCapability->sce_ctrl.min_value,
2049                   m_pCapability->sce_ctrl.max_value);
2050             return BAD_VALUE;
2051         }
2052     } else {
2053         CDBG("%s: No value change in skintone enhancement factor", __func__);
2054         return NO_ERROR;
2055     }
2056 }
2057 
2058 /*===========================================================================
2059  * FUNCTION   : setSaturation
2060  *
2061  * DESCRIPTION: set saturation control value from user setting
2062  *
2063  * PARAMETERS :
2064  *   @params  : user setting parameters
2065  *
2066  * RETURN     : int32_t type of status
2067  *              NO_ERROR  -- success
2068  *              none-zero failure code
2069  *==========================================================================*/
setSaturation(const QCameraParameters & params)2070 int32_t QCameraParameters::setSaturation(const QCameraParameters& params)
2071 {
2072     int saturation = params.getInt(KEY_QC_SATURATION);
2073     int prev_sat = getInt(KEY_QC_SATURATION);
2074 
2075     if(params.get(KEY_QC_SATURATION) == NULL) {
2076        CDBG_HIGH("%s: Saturation not set by App ",__func__);
2077        return NO_ERROR;
2078     }
2079     if (prev_sat !=  saturation) {
2080         if((saturation >= m_pCapability->saturation_ctrl.min_value) &&
2081            (saturation <= m_pCapability->saturation_ctrl.max_value)) {
2082             CDBG(" new saturation value : %d ", saturation);
2083             return setSaturation(saturation);
2084         } else {
2085             ALOGE("%s: invalid value %d out of (%d, %d)",
2086                   __func__, saturation,
2087                   m_pCapability->saturation_ctrl.min_value,
2088                   m_pCapability->saturation_ctrl.max_value);
2089             return BAD_VALUE;
2090         }
2091     } else {
2092         CDBG("%s: No value change in saturation factor", __func__);
2093         return NO_ERROR;
2094     }
2095 }
2096 
2097 /*===========================================================================
2098  * FUNCTION   : setContrast
2099  *
2100  * DESCRIPTION: set contrast control value from user setting
2101  *
2102  * PARAMETERS :
2103  *   @params  : user setting parameters
2104  *
2105  * RETURN     : int32_t type of status
2106  *              NO_ERROR  -- success
2107  *              none-zero failure code
2108  *==========================================================================*/
setContrast(const QCameraParameters & params)2109 int32_t QCameraParameters::setContrast(const QCameraParameters& params)
2110 {
2111     int contrast = params.getInt(KEY_QC_CONTRAST);
2112     int prev_contrast = getInt(KEY_QC_CONTRAST);
2113 
2114     if(params.get(KEY_QC_CONTRAST) == NULL) {
2115        CDBG_HIGH("%s: Contrast not set by App ",__func__);
2116        return NO_ERROR;
2117     }
2118     if (prev_contrast !=  contrast) {
2119         if((contrast >= m_pCapability->contrast_ctrl.min_value) &&
2120            (contrast <= m_pCapability->contrast_ctrl.max_value)) {
2121             CDBG(" new contrast value : %d ", contrast);
2122             int32_t rc = setContrast(contrast);
2123             return rc;
2124         } else {
2125             ALOGE("%s: invalid value %d out of (%d, %d)",
2126                   __func__, contrast,
2127                   m_pCapability->contrast_ctrl.min_value,
2128                   m_pCapability->contrast_ctrl.max_value);
2129             return BAD_VALUE;
2130         }
2131     } else {
2132         CDBG("%s: No value change in contrast", __func__);
2133         return NO_ERROR;
2134     }
2135 }
2136 
2137 /*===========================================================================
2138  * FUNCTION   : setExposureCompensation
2139  *
2140  * DESCRIPTION: set exposure compensation value from user setting
2141  *
2142  * PARAMETERS :
2143  *   @params  : user setting parameters
2144  *
2145  * RETURN     : int32_t type of status
2146  *              NO_ERROR  -- success
2147  *              none-zero failure code
2148  *==========================================================================*/
setExposureCompensation(const QCameraParameters & params)2149 int32_t QCameraParameters::setExposureCompensation(const QCameraParameters & params)
2150 {
2151     int expComp = params.getInt(KEY_EXPOSURE_COMPENSATION);
2152     int prev_expComp = getInt(KEY_EXPOSURE_COMPENSATION);
2153 
2154     if(params.get(KEY_EXPOSURE_COMPENSATION) == NULL) {
2155        CDBG_HIGH("%s: Exposure compensation not set by App ",__func__);
2156        return NO_ERROR;
2157     }
2158     if (prev_expComp != expComp) {
2159         if((expComp >= m_pCapability->exposure_compensation_min) &&
2160            (expComp <= m_pCapability->exposure_compensation_max)) {
2161             CDBG(" new Exposure Compensation value : %d ", expComp);
2162             return setExposureCompensation(expComp);
2163         } else {
2164             ALOGE("%s: invalid value %d out of (%d, %d)",
2165                   __func__, expComp,
2166                   m_pCapability->exposure_compensation_min,
2167                   m_pCapability->exposure_compensation_max);
2168             return BAD_VALUE;
2169         }
2170     } else {
2171         CDBG("%s: No value change in Exposure Compensation", __func__);
2172         return NO_ERROR;
2173     }
2174 }
2175 
2176 /*===========================================================================
2177  * FUNCTION   : setWhiteBalance
2178  *
2179  * DESCRIPTION: set white balance value from user setting
2180  *
2181  * PARAMETERS :
2182  *   @params  : user setting parameters
2183  *
2184  * RETURN     : int32_t type of status
2185  *              NO_ERROR  -- success
2186  *              none-zero failure code
2187  *==========================================================================*/
setWhiteBalance(const QCameraParameters & params)2188 int32_t QCameraParameters::setWhiteBalance(const QCameraParameters& params)
2189 {
2190     const char *str = params.get(KEY_WHITE_BALANCE);
2191     const char *prev_str = get(KEY_WHITE_BALANCE);
2192     if (str != NULL) {
2193         if (prev_str == NULL ||
2194             strcmp(str, prev_str) != 0) {
2195             return setWhiteBalance(str);
2196         }
2197     }
2198     return NO_ERROR;
2199 }
2200 
2201 /*===========================================================================
2202  * FUNCTION   : setAntibanding
2203  *
2204  * DESCRIPTION: set antibanding value from user setting
2205  *
2206  * PARAMETERS :
2207  *   @params  : user setting parameters
2208  *
2209  * RETURN     : int32_t type of status
2210  *              NO_ERROR  -- success
2211  *              none-zero failure code
2212  *==========================================================================*/
setAntibanding(const QCameraParameters & params)2213 int32_t QCameraParameters::setAntibanding(const QCameraParameters& params)
2214 {
2215     const char *str = params.get(KEY_ANTIBANDING);
2216     const char *prev_str = get(KEY_ANTIBANDING);
2217     if (str != NULL) {
2218         if (prev_str == NULL ||
2219             strcmp(str, prev_str) != 0) {
2220             return setAntibanding(str);
2221         }
2222     }
2223     return NO_ERROR;
2224 }
2225 
2226 /*===========================================================================
2227  * FUNCTION   : setStatsDebugMask
2228  *
2229  * DESCRIPTION: get the value from persist file in Stats module that will
2230  *              control funtionality in the module
2231  *
2232  * PARAMETERS : none
2233  *
2234  * RETURN     : int32_t type of status
2235  *              NO_ERROR  -- success
2236  *              none-zero failure code
2237  *==========================================================================*/
setStatsDebugMask()2238 int32_t QCameraParameters::setStatsDebugMask()
2239 {
2240     uint32_t mask = 0;
2241     char value[PROPERTY_VALUE_MAX];
2242 
2243     property_get("persist.camera.stats.debug.mask", value, "0");
2244     mask = (uint32_t)atoi(value);
2245 
2246     CDBG_HIGH("%s: ctrl mask :%d", __func__, mask);
2247 
2248     return AddSetParmEntryToBatch(m_pParamBuf,
2249                                   CAM_INTF_PARM_STATS_DEBUG_MASK,
2250                                   sizeof(mask),
2251                                   &mask);
2252 }
2253 
2254 /*===========================================================================
2255  * FUNCTION   : setPAAF
2256  *
2257  * DESCRIPTION: get the value from persist file in Stats module that will
2258  *              control the preview assisted AF in the module
2259  *
2260  * PARAMETERS : none
2261  *
2262  * RETURN     : int32_t type of status
2263  *              NO_ERROR  -- success
2264  *              none-zero failure code
2265  *==========================================================================*/
setPAAF()2266 int32_t QCameraParameters::setPAAF()
2267 {
2268     uint32_t paaf = 0;
2269     char value[PROPERTY_VALUE_MAX];
2270 
2271     property_get("persist.camera.stats.af.paaf", value, "1");
2272     paaf = (uint32_t)atoi(value);
2273 
2274     ALOGE("%s: PAAF is: %s", __func__, paaf ? "ON": "OFF");
2275 
2276     return AddSetParmEntryToBatch(m_pParamBuf,
2277                                   CAM_INTF_PARM_STATS_AF_PAAF,
2278                                   sizeof(paaf),
2279                                   &paaf);
2280 }
2281 
2282 /*===========================================================================
2283  * FUNCTION   : setSceneDetect
2284  *
2285  * DESCRIPTION: set scenen detect value from user setting
2286  *
2287  * PARAMETERS :
2288  *   @params  : user setting parameters
2289  *
2290  * RETURN     : int32_t type of status
2291  *              NO_ERROR  -- success
2292  *              none-zero failure code
2293  *==========================================================================*/
setSceneDetect(const QCameraParameters & params)2294 int32_t QCameraParameters::setSceneDetect(const QCameraParameters& params)
2295 {
2296     const char *str = params.get(KEY_QC_SCENE_DETECT);
2297     const char *prev_str = get(KEY_QC_SCENE_DETECT);
2298     if (str != NULL) {
2299         if (prev_str == NULL ||
2300             strcmp(str, prev_str) != 0) {
2301             return setSceneDetect(str);
2302         }
2303     }
2304     return NO_ERROR;
2305 }
2306 
2307 /*===========================================================================
2308  * FUNCTION   : setVideoHDR
2309  *
2310  * DESCRIPTION: set video HDR value from user setting
2311  *
2312  * PARAMETERS :
2313  *   @params  : user setting parameters
2314  *
2315  * RETURN     : int32_t type of status
2316  *              NO_ERROR  -- success
2317  *              none-zero failure code
2318  *==========================================================================*/
setVideoHDR(const QCameraParameters & params)2319 int32_t QCameraParameters::setVideoHDR(const QCameraParameters& params)
2320 {
2321     const char *str = params.get(KEY_QC_VIDEO_HDR);
2322     const char *prev_str = get(KEY_QC_VIDEO_HDR);
2323     if (str != NULL) {
2324         if (prev_str == NULL ||
2325             strcmp(str, prev_str) != 0) {
2326             return setVideoHDR(str);
2327         }
2328     }
2329     return NO_ERROR;
2330 }
2331 
2332 /*===========================================================================
2333  * FUNCTION   : setVtEnable
2334  *
2335  * DESCRIPTION: set vt Time Stamp enable from user setting
2336  *
2337  * PARAMETERS :
2338  *   @params  : user setting parameters
2339  *
2340  * RETURN     : int32_t type of status
2341  *              NO_ERROR  -- success
2342  *              none-zero failure code
2343  *==========================================================================*/
setVtEnable(const QCameraParameters & params)2344 int32_t QCameraParameters::setVtEnable(const QCameraParameters& params)
2345 {
2346     const char *str = params.get(KEY_QC_VT_ENABLE);
2347     const char *prev_str = get(KEY_QC_VT_ENABLE);
2348     if (str != NULL) {
2349         if (prev_str == NULL ||
2350             strcmp(str, prev_str) != 0) {
2351             return setVtEnable(str);
2352         }
2353     }
2354     return NO_ERROR;
2355 }
2356 
2357 /*===========================================================================
2358  * FUNCTION   : setFaceRecognition
2359  *
2360  * DESCRIPTION: set face recognition mode from user setting
2361  *
2362  * PARAMETERS :
2363  *   @params  : user setting parameters
2364  *
2365  * RETURN     : int32_t type of status
2366  *              NO_ERROR  -- success
2367  *              none-zero failure code
2368  *==========================================================================*/
setFaceRecognition(const QCameraParameters & params)2369 int32_t QCameraParameters::setFaceRecognition(const QCameraParameters& params)
2370 {
2371     const char *str = params.get(KEY_QC_FACE_RECOGNITION);
2372     const char *prev_str = get(KEY_QC_FACE_RECOGNITION);
2373     if (str != NULL) {
2374         if (prev_str == NULL ||
2375             strcmp(str, prev_str) != 0) {
2376             int maxFaces = params.getInt(KEY_QC_MAX_NUM_REQUESTED_FACES);
2377             return setFaceRecognition(str, maxFaces);
2378         }
2379     }
2380     return NO_ERROR;
2381 }
2382 
2383 /*===========================================================================
2384  * FUNCTION   : setZoom
2385  *
2386  * DESCRIPTION: set zoom value from user setting
2387  *
2388  * PARAMETERS :
2389  *   @params  : user setting parameters
2390  *
2391  * RETURN     : int32_t type of status
2392  *              NO_ERROR  -- success
2393  *              none-zero failure code
2394  *==========================================================================*/
setZoom(const QCameraParameters & params)2395 int32_t QCameraParameters::setZoom(const QCameraParameters& params)
2396 {
2397     if ((m_pCapability->zoom_supported == 0 ||
2398          m_pCapability->zoom_ratio_tbl_cnt == 0)) {
2399         CDBG_HIGH("%s: no zoom support", __func__);
2400         return NO_ERROR;
2401     }
2402 
2403     int zoomLevel = params.getInt(KEY_ZOOM);
2404     if((zoomLevel < 0) ||
2405        (zoomLevel >= m_pCapability->zoom_ratio_tbl_cnt)) {
2406         ALOGE("%s: invalid value %d out of (%d, %d)",
2407               __func__, zoomLevel,
2408               0, m_pCapability->zoom_ratio_tbl_cnt-1);
2409         return BAD_VALUE;
2410     }
2411 
2412     int prevZoomLevel = getInt(KEY_ZOOM);
2413     if (prevZoomLevel == zoomLevel) {
2414         CDBG("%s: No value change in contrast", __func__);
2415         return NO_ERROR;
2416     }
2417 
2418     return setZoom(zoomLevel);
2419 }
2420 
2421 /*===========================================================================
2422  * FUNCTION   : setISOValue
2423  *
2424  * DESCRIPTION: set ISO value from user setting
2425  *
2426  * PARAMETERS :
2427  *   @params  : user setting parameters
2428  *
2429  * RETURN     : int32_t type of status
2430  *              NO_ERROR  -- success
2431  *              none-zero failure code
2432  *==========================================================================*/
setISOValue(const QCameraParameters & params)2433 int32_t  QCameraParameters::setISOValue(const QCameraParameters& params)
2434 {
2435     const char *str = params.get(KEY_QC_ISO_MODE);
2436     const char *prev_str = get(KEY_QC_ISO_MODE);
2437     if (str != NULL) {
2438         if (prev_str == NULL ||
2439             strcmp(str, prev_str) != 0) {
2440             return setISOValue(str);
2441         }
2442     }
2443     return NO_ERROR;
2444 }
2445 
2446 /*===========================================================================
2447  * FUNCTION   : setVideoRotation
2448  *
2449  * DESCRIPTION: set rotation value from user setting
2450  *
2451  * PARAMETERS :
2452  *   @params  : user setting parameters
2453  *
2454  * RETURN     : int32_t type of status
2455  *              NO_ERROR  -- success
2456  *              none-zero failure code
2457  *==========================================================================*/
setVideoRotation(const QCameraParameters & params)2458 int32_t QCameraParameters::setVideoRotation(const QCameraParameters& params)
2459 {
2460     int rotation = params.getInt(KEY_QC_VIDEO_ROTATION);
2461     if (rotation != -1) {
2462         if (rotation == 0 || rotation == 90 ||
2463             rotation == 180 || rotation == 270) {
2464             set(KEY_QC_VIDEO_ROTATION, rotation);
2465         } else {
2466             ALOGE("Invalid rotation value: %d", rotation);
2467             return BAD_VALUE;
2468         }
2469     }
2470     return NO_ERROR;
2471 }
2472 
2473 /*===========================================================================
2474  * FUNCTION   : setRotation
2475  *
2476  * DESCRIPTION: set rotation value from user setting
2477  *
2478  * PARAMETERS :
2479  *   @params  : user setting parameters
2480  *
2481  * RETURN     : int32_t type of status
2482  *              NO_ERROR  -- success
2483  *              none-zero failure code
2484  *==========================================================================*/
setRotation(const QCameraParameters & params)2485 int32_t QCameraParameters::setRotation(const QCameraParameters& params)
2486 {
2487     int rotation = params.getInt(KEY_ROTATION);
2488     if (rotation != -1) {
2489         if (rotation == 0 || rotation == 90 ||
2490             rotation == 180 || rotation == 270) {
2491             set(KEY_ROTATION, rotation);
2492         } else {
2493             ALOGE("Invalid rotation value: %d", rotation);
2494             return BAD_VALUE;
2495         }
2496     }
2497     return NO_ERROR;
2498 }
2499 
2500 /*===========================================================================
2501  * FUNCTION   : setFlash
2502  *
2503  * DESCRIPTION: set flash mode from user setting
2504  *
2505  * PARAMETERS :
2506  *   @params  : user setting parameters
2507  *
2508  * RETURN     : int32_t type of status
2509  *              NO_ERROR  -- success
2510  *              none-zero failure code
2511  *==========================================================================*/
setFlash(const QCameraParameters & params)2512 int32_t QCameraParameters::setFlash(const QCameraParameters& params)
2513 {
2514     const char *str = params.get(KEY_FLASH_MODE);
2515     const char *prev_str = get(KEY_FLASH_MODE);
2516     if (str != NULL) {
2517         if (prev_str == NULL ||
2518             strcmp(str, prev_str) != 0) {
2519             return setFlash(str);
2520         }
2521     }
2522     return NO_ERROR;
2523 }
2524 
2525 /*===========================================================================
2526  * FUNCTION   : setAecLock
2527  *
2528  * DESCRIPTION: set AEC lock value from user setting
2529  *
2530  * PARAMETERS :
2531  *   @params  : user setting parameters
2532  *
2533  * RETURN     : int32_t type of status
2534  *              NO_ERROR  -- success
2535  *              none-zero failure code
2536  *==========================================================================*/
setAecLock(const QCameraParameters & params)2537 int32_t QCameraParameters::setAecLock(const QCameraParameters& params)
2538 {
2539     const char *str = params.get(KEY_AUTO_EXPOSURE_LOCK);
2540     const char *prev_str = get(KEY_AUTO_EXPOSURE_LOCK);
2541     if (str != NULL) {
2542         if (prev_str == NULL ||
2543             strcmp(str, prev_str) != 0) {
2544             return setAecLock(str);
2545         }
2546     }
2547     return NO_ERROR;
2548 }
2549 
2550 /*===========================================================================
2551  * FUNCTION   : setAwbLock
2552  *
2553  * DESCRIPTION: set AWB lock from user setting
2554  *
2555  * PARAMETERS :
2556  *   @params  : user setting parameters
2557  *
2558  * RETURN     : int32_t type of status
2559  *              NO_ERROR  -- success
2560  *              none-zero failure code
2561  *==========================================================================*/
setAwbLock(const QCameraParameters & params)2562 int32_t QCameraParameters::setAwbLock(const QCameraParameters& params)
2563 {
2564     const char *str = params.get(KEY_AUTO_WHITEBALANCE_LOCK);
2565     const char *prev_str = get(KEY_AUTO_WHITEBALANCE_LOCK);
2566     if (str != NULL) {
2567         if (prev_str == NULL ||
2568             strcmp(str, prev_str) != 0) {
2569             return setAwbLock(str);
2570         }
2571     }
2572     return NO_ERROR;
2573 }
2574 
2575 /*===========================================================================
2576  * FUNCTION   : setAutoHDR
2577  *
2578  * DESCRIPTION: Enable/disable auto HDR
2579  *
2580  * PARAMETERS :
2581  *   @params  : user setting parameters
2582  *
2583  * RETURN     : int32_t type of status
2584  *              NO_ERROR  -- success
2585  *              none-zero failure code
2586  *==========================================================================*/
setAutoHDR(const QCameraParameters & params)2587 int32_t QCameraParameters::setAutoHDR(const QCameraParameters& params)
2588 {
2589     const char *str = params.get(KEY_QC_AUTO_HDR_ENABLE);
2590     const char *prev_str = get(KEY_QC_AUTO_HDR_ENABLE);
2591     char prop[PROPERTY_VALUE_MAX];
2592 
2593     memset(prop, 0, sizeof(prop));
2594     property_get("persist.camera.auto.hdr.enable", prop, VALUE_DISABLE);
2595     if (str != NULL) {
2596        if (prev_str == NULL ||
2597            strcmp(str, prev_str) != 0) {
2598            CDBG_HIGH("%s : Auto HDR set to: %s", __func__, str);
2599            return updateParamEntry(KEY_QC_AUTO_HDR_ENABLE, str);
2600        }
2601     } else {
2602        if (prev_str == NULL ||
2603            strcmp(prev_str, prop) != 0 ) {
2604            CDBG_HIGH("%s : Auto HDR set to: %s", __func__, prop);
2605            updateParamEntry(KEY_QC_AUTO_HDR_ENABLE, prop);
2606        }
2607     }
2608 
2609        return NO_ERROR;
2610 }
2611 
2612 /*===========================================================================
2613 * FUNCTION   : isAutoHDREnabled
2614 *
2615 * DESCRIPTION: Query auto HDR status
2616 *
2617 * PARAMETERS : None
2618 *
2619 * RETURN     : bool true/false
2620 *==========================================================================*/
isAutoHDREnabled()2621 bool QCameraParameters::isAutoHDREnabled()
2622 {
2623     const char *str = get(KEY_QC_AUTO_HDR_ENABLE);
2624     if (str != NULL) {
2625         int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP,
2626                                    sizeof(ENABLE_DISABLE_MODES_MAP)/sizeof(QCameraMap),
2627                                    str);
2628         if (value == NAME_NOT_FOUND) {
2629             ALOGE("%s: Invalid Auto HDR value %s", __func__, str);
2630             return false;
2631         }
2632 
2633         CDBG_HIGH("%s : Auto HDR status is: %d", __func__, value);
2634         return value ? true : false;
2635     }
2636 
2637     CDBG_HIGH("%s : Auto HDR status not set!", __func__);
2638     return false;
2639 }
2640 
2641 /*===========================================================================
2642  * FUNCTION   : setMCEValue
2643  *
2644  * DESCRIPTION: set memory color enhancement value from user setting
2645  *
2646  * PARAMETERS :
2647  *   @params  : user setting parameters
2648  *
2649  * RETURN     : int32_t type of status
2650  *              NO_ERROR  -- success
2651  *              none-zero failure code
2652  *==========================================================================*/
setMCEValue(const QCameraParameters & params)2653 int32_t QCameraParameters::setMCEValue(const QCameraParameters& params)
2654 {
2655     const char *str = params.get(KEY_QC_MEMORY_COLOR_ENHANCEMENT);
2656     const char *prev_str = get(KEY_QC_MEMORY_COLOR_ENHANCEMENT);
2657     if (str != NULL) {
2658         if (prev_str == NULL ||
2659             strcmp(str, prev_str) != 0) {
2660             return setMCEValue(str);
2661         }
2662     }
2663     return NO_ERROR;
2664 }
2665 
2666 /*===========================================================================
2667  * FUNCTION   : setDISValue
2668  *
2669  * DESCRIPTION: enable/disable DIS from user setting
2670  *
2671  * PARAMETERS :
2672  *   @params  : user setting parameters
2673  *
2674  * RETURN     : int32_t type of status
2675  *              NO_ERROR  -- success
2676  *              none-zero failure code
2677  *==========================================================================*/
setDISValue(const QCameraParameters & params)2678 int32_t QCameraParameters::setDISValue(const QCameraParameters& params)
2679 {
2680     const char *str = params.get(KEY_QC_DIS);
2681     const char *prev_str = get(KEY_QC_DIS);
2682     if (str != NULL) {
2683         if (prev_str == NULL ||
2684             strcmp(str, prev_str) != 0) {
2685             return setDISValue(str);
2686         }
2687     }
2688     return NO_ERROR;
2689 }
2690 
2691 /*===========================================================================
2692  * FUNCTION   : setHighFrameRate
2693  *
2694  * DESCRIPTION: set hight frame rate value from user setting
2695  *
2696  * PARAMETERS :
2697  *   @params  : user setting parameters
2698  *
2699  * RETURN     : int32_t type of status
2700  *              NO_ERROR  -- success
2701  *              none-zero failure code
2702  *==========================================================================*/
setHighFrameRate(const QCameraParameters & params)2703 int32_t QCameraParameters::setHighFrameRate(const QCameraParameters& params)
2704 {
2705     const char *str = params.get(KEY_QC_VIDEO_HIGH_FRAME_RATE);
2706     const char *prev_str = get(KEY_QC_VIDEO_HIGH_FRAME_RATE);
2707     if (str != NULL) {
2708         if (prev_str == NULL ||
2709             strcmp(str, prev_str) != 0) {
2710             return setHighFrameRate(str);
2711         }
2712     }
2713     return NO_ERROR;
2714 }
2715 
2716 /*===========================================================================
2717  * FUNCTION   : setHighSpeedRecording
2718  *
2719  * DESCRIPTION: set high speed recording value from user setting
2720  *
2721  * PARAMETERS :
2722  *   @params  : user setting parameters
2723  *
2724  * RETURN     : int32_t type of status
2725  *              NO_ERROR  -- success
2726  *              none-zero failure code
2727  *==========================================================================*/
setHighSpeedRecording(const QCameraParameters & params)2728 int32_t QCameraParameters::setHighSpeedRecording(const QCameraParameters& params)
2729 {
2730     const char *str = params.get(KEY_QC_VIDEO_HIGH_SPEED_RECORDING);
2731     const char *prev_str = get(KEY_QC_VIDEO_HIGH_SPEED_RECORDING);
2732     const char *hfr_str = params.get(KEY_QC_VIDEO_HIGH_FRAME_RATE);
2733     int32_t hfr_mode = CAM_HFR_MODE_OFF;
2734     if (hfr_str != NULL) {
2735         hfr_mode = lookupAttr(HFR_MODES_MAP,
2736                 sizeof(HFR_MODES_MAP)/sizeof(QCameraMap),
2737                 hfr_str);
2738     }
2739     if (str != NULL) {
2740         if (prev_str == NULL ||
2741             strcmp(str, prev_str) != 0) {
2742             int32_t value;
2743             // if HSR is off, take HFR fps value
2744             if (!strcmp(str,"on")) value = CAM_HFR_MODE_120FPS;
2745             else value = hfr_mode;
2746             // HFR value changed, need to restart preview
2747             m_bNeedRestart = true;
2748             // Set HFR value
2749             updateParamEntry(KEY_QC_VIDEO_HIGH_SPEED_RECORDING, str);
2750             return AddSetParmEntryToBatch(m_pParamBuf,
2751                                           CAM_INTF_PARM_HFR,
2752                                           sizeof(value),
2753                                           &value);
2754         }
2755     }
2756     return NO_ERROR;
2757 }
2758 
2759 /*===========================================================================
2760  * FUNCTION   : setLensShadeValue
2761  *
2762  * DESCRIPTION: set lens shade value from user setting
2763  *
2764  * PARAMETERS :
2765  *   @params  : user setting parameters
2766  *
2767  * RETURN     : int32_t type of status
2768  *              NO_ERROR  -- success
2769  *              none-zero failure code
2770  *==========================================================================*/
setLensShadeValue(const QCameraParameters & params)2771 int32_t QCameraParameters::setLensShadeValue(const QCameraParameters& params)
2772 {
2773     const char *str = params.get(KEY_QC_LENSSHADE);
2774     const char *prev_str = get(KEY_QC_LENSSHADE);
2775     if (str != NULL) {
2776         if (prev_str == NULL ||
2777             strcmp(str, prev_str) != 0) {
2778             return setLensShadeValue(str);
2779         }
2780     }
2781     return NO_ERROR;
2782 }
2783 
2784 /*===========================================================================
2785  * FUNCTION   : setFocusAreas
2786  *
2787  * DESCRIPTION: set focus areas from user setting
2788  *
2789  * PARAMETERS :
2790  *   @params  : user setting parameters
2791  *
2792  * RETURN     : int32_t type of status
2793  *              NO_ERROR  -- success
2794  *              none-zero failure code
2795  *==========================================================================*/
setFocusAreas(const QCameraParameters & params)2796 int32_t QCameraParameters::setFocusAreas(const QCameraParameters& params)
2797 {
2798     const char *str = params.get(KEY_FOCUS_AREAS);
2799     if (str != NULL) {
2800         int max_num_af_areas = getInt(KEY_MAX_NUM_FOCUS_AREAS);
2801         if(max_num_af_areas == 0) {
2802             ALOGE("%s: max num of AF area is 0, cannot set focus areas", __func__);
2803             return BAD_VALUE;
2804         }
2805 
2806         const char *prev_str = get(KEY_FOCUS_AREAS);
2807         if (prev_str == NULL ||
2808             strcmp(str, prev_str) != 0) {
2809             return setFocusAreas(str);
2810         }
2811     }
2812     return NO_ERROR;
2813 }
2814 
2815 /*===========================================================================
2816  * FUNCTION   : setMeteringAreas
2817  *
2818  * DESCRIPTION: set metering areas from user setting
2819  *
2820  * PARAMETERS :
2821  *   @params  : user setting parameters
2822  *
2823  * RETURN     : int32_t type of status
2824  *              NO_ERROR  -- success
2825  *              none-zero failure code
2826  *==========================================================================*/
setMeteringAreas(const QCameraParameters & params)2827 int32_t QCameraParameters::setMeteringAreas(const QCameraParameters& params)
2828 {
2829     const char *str = params.get(KEY_METERING_AREAS);
2830     if (str != NULL) {
2831         int max_num_mtr_areas = getInt(KEY_MAX_NUM_METERING_AREAS);
2832         if(max_num_mtr_areas == 0) {
2833             ALOGE("%s: max num of metering areas is 0, cannot set focus areas", __func__);
2834             return BAD_VALUE;
2835         }
2836 
2837         const char *prev_str = get(KEY_METERING_AREAS);
2838         if (prev_str == NULL ||
2839             strcmp(str, prev_str) != 0) {
2840             return setMeteringAreas(str);
2841         }
2842     }
2843     return NO_ERROR;
2844 }
2845 
2846 /*===========================================================================
2847  * FUNCTION   : setSceneMode
2848  *
2849  * DESCRIPTION: set scenen mode from user setting
2850  *
2851  * PARAMETERS :
2852  *   @params  : user setting parameters
2853  *
2854  * RETURN     : int32_t type of status
2855  *              NO_ERROR  -- success
2856  *              none-zero failure code
2857  *==========================================================================*/
setSceneMode(const QCameraParameters & params)2858 int32_t QCameraParameters::setSceneMode(const QCameraParameters& params)
2859 {
2860     const char *str = params.get(KEY_SCENE_MODE);
2861     const char *prev_str = get(KEY_SCENE_MODE);
2862     CDBG_HIGH("%s: str - %s, prev_str - %s",__func__, str, prev_str);
2863 
2864     if (str != NULL) {
2865         if (prev_str == NULL ||
2866             strcmp(str, prev_str) != 0) {
2867 
2868             if(strcmp(str, SCENE_MODE_AUTO) == 0) {
2869                 m_bSceneTransitionAuto = true;
2870             }
2871             if (strcmp(str, SCENE_MODE_HDR) == 0) {
2872                 // If HDR is set from client  and the feature is not enabled in the backend, ignore it.
2873                 if (m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_SENSOR_HDR) {
2874                     m_bSensorHDREnabled = true;
2875                     CDBG_HIGH("%s: Sensor HDR mode Enabled",__func__);
2876 
2877                 }
2878                 else if (m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_HDR) {
2879                     m_bHDREnabled = true;
2880                     CDBG_HIGH("%s: S/W HDR Enabled",__func__);
2881                 }
2882                 else {
2883                     return NO_ERROR;
2884                 }
2885             } else {
2886                 m_bHDREnabled = false;
2887                 if (m_bSensorHDREnabled) {
2888                     m_bSensorHDREnabled = false;
2889                     m_bNeedRestart = true;
2890                     setSensorSnapshotHDR("off");
2891                 }
2892             }
2893 
2894             if (m_bSensorHDREnabled) {
2895                 setSensorSnapshotHDR("on");
2896                 m_bNeedRestart = true;
2897             } else if ((m_bHDREnabled) ||
2898                 ((prev_str != NULL) && (strcmp(prev_str, SCENE_MODE_HDR) == 0))) {
2899                 CDBG_HIGH("%s: scene mode changed between HDR and non-HDR, need restart", __func__);
2900 
2901                 m_bNeedRestart = true;
2902                 // set if hdr 1x image is needed
2903                 const char *need_hdr_1x = params.get(KEY_QC_HDR_NEED_1X);
2904                 if (need_hdr_1x != NULL) {
2905                     if (strcmp(need_hdr_1x, VALUE_TRUE) == 0) {
2906                         m_bHDR1xFrameEnabled = true;
2907                     } else {
2908                         m_bHDR1xFrameEnabled = false;
2909                     }
2910 
2911                     updateParamEntry(KEY_QC_HDR_NEED_1X, need_hdr_1x);
2912                 }
2913 
2914                 AddSetParmEntryToBatch(m_pParamBuf,
2915                                        CAM_INTF_PARM_HDR_NEED_1X,
2916                                        sizeof(m_bHDR1xFrameEnabled),
2917                                        &m_bHDR1xFrameEnabled);
2918             }
2919 
2920             return setSceneMode(str);
2921         }
2922     }
2923     return NO_ERROR;
2924 }
2925 
2926 /*===========================================================================
2927  * FUNCTION   : setSelectableZoneAf
2928  *
2929  * DESCRIPTION: set selectable zone auto focus value from user setting
2930  *
2931  * PARAMETERS :
2932  *   @params  : user setting parameters
2933  *
2934  * RETURN     : int32_t type of status
2935  *              NO_ERROR  -- success
2936  *              none-zero failure code
2937  *==========================================================================*/
setSelectableZoneAf(const QCameraParameters & params)2938 int32_t QCameraParameters::setSelectableZoneAf(const QCameraParameters& params)
2939 {
2940     const char *str = params.get(KEY_QC_SELECTABLE_ZONE_AF);
2941     const char *prev_str = get(KEY_QC_SELECTABLE_ZONE_AF);
2942     if (str != NULL) {
2943         if (prev_str == NULL ||
2944             strcmp(str, prev_str) != 0) {
2945             return setSelectableZoneAf(str);
2946         }
2947     }
2948     return NO_ERROR;
2949 }
2950 
2951 /*===========================================================================
2952  * FUNCTION   : setAEBracket
2953  *
2954  * DESCRIPTION: set AE bracket from user setting
2955  *
2956  * PARAMETERS :
2957  *   @params  : user setting parameters
2958  *
2959  * RETURN     : int32_t type of status
2960  *              NO_ERROR  -- success
2961  *              none-zero failure code
2962  *==========================================================================*/
setAEBracket(const QCameraParameters & params)2963 int32_t QCameraParameters::setAEBracket(const QCameraParameters& params)
2964 {
2965     if (isHDREnabled()) {
2966         CDBG_HIGH("%s: scene mode is HDR, overwrite AE bracket setting to off", __func__);
2967         return setAEBracket(AE_BRACKET_OFF);
2968     }
2969 
2970     const char *expStr = params.get(KEY_QC_CAPTURE_BURST_EXPOSURE);
2971     if (NULL != expStr && strlen(expStr) > 0) {
2972         set(KEY_QC_CAPTURE_BURST_EXPOSURE, expStr);
2973     } else {
2974         char prop[PROPERTY_VALUE_MAX];
2975         memset(prop, 0, sizeof(prop));
2976         property_get("persist.capture.burst.exposures", prop, "");
2977         if (strlen(prop) > 0) {
2978             set(KEY_QC_CAPTURE_BURST_EXPOSURE, prop);
2979         } else {
2980             remove(KEY_QC_CAPTURE_BURST_EXPOSURE);
2981         }
2982     }
2983 
2984     const char *str = params.get(KEY_QC_AE_BRACKET_HDR);
2985     const char *prev_str = get(KEY_QC_AE_BRACKET_HDR);
2986     if (str != NULL) {
2987         if (prev_str == NULL ||
2988             strcmp(str, prev_str) != 0) {
2989             return setAEBracket(str);
2990         }
2991     }
2992     return NO_ERROR;
2993 }
2994 
2995 /*===========================================================================
2996  * FUNCTION   : setAFBracket
2997  *
2998  * DESCRIPTION: set AF bracket from user setting
2999  *
3000  * PARAMETERS :
3001  *   @params  : user setting parameters
3002  *
3003  * RETURN     : int32_t type of status
3004  *              NO_ERROR  -- success
3005  *              none-zero failure code
3006  *==========================================================================*/
setAFBracket(const QCameraParameters & params)3007 int32_t QCameraParameters::setAFBracket(const QCameraParameters& params)
3008 {
3009     if ((m_pCapability->qcom_supported_feature_mask &
3010         CAM_QCOM_FEATURE_UBIFOCUS) == 0){
3011         CDBG_HIGH("%s: AF Bracketing is not supported",__func__);
3012         return NO_ERROR;
3013     }
3014     const char *str = params.get(KEY_QC_AF_BRACKET);
3015     const char *prev_str = get(KEY_QC_AF_BRACKET);
3016     CDBG_HIGH("%s: str =%s & prev_str =%s",__func__, str, prev_str);
3017     if (str != NULL) {
3018         if (prev_str == NULL ||
3019             strcmp(str, prev_str) != 0) {
3020             m_bNeedRestart = true;
3021             return setAFBracket(str);
3022         }
3023     }
3024     return NO_ERROR;
3025 }
3026 
3027 /*===========================================================================
3028  * FUNCTION   : setChromaFlash
3029  *
3030  * DESCRIPTION: set chroma flash from user setting
3031  *
3032  * PARAMETERS :
3033  *   @params  : user setting parameters
3034  *
3035  * RETURN     : int32_t type of status
3036  *              NO_ERROR  -- success
3037  *              none-zero failure code
3038  *==========================================================================*/
setChromaFlash(const QCameraParameters & params)3039 int32_t QCameraParameters::setChromaFlash(const QCameraParameters& params)
3040 {
3041     if ((m_pCapability->qcom_supported_feature_mask &
3042         CAM_QCOM_FEATURE_CHROMA_FLASH) == 0) {
3043         CDBG_HIGH("%s: Chroma Flash is not supported",__func__);
3044         return NO_ERROR;
3045     }
3046     const char *str = params.get(KEY_QC_CHROMA_FLASH);
3047     const char *prev_str = get(KEY_QC_CHROMA_FLASH);
3048     CDBG_HIGH("%s: str =%s & prev_str =%s",__func__, str, prev_str);
3049     if (str != NULL) {
3050         if (prev_str == NULL ||
3051             strcmp(str, prev_str) != 0) {
3052             m_bNeedRestart = true;
3053             return setChromaFlash(str);
3054         }
3055     }
3056     return NO_ERROR;
3057 }
3058 
3059 /*===========================================================================
3060  * FUNCTION   : setOptiZoom
3061  *
3062  * DESCRIPTION: set opti zoom from user setting
3063  *
3064  * PARAMETERS :
3065  *   @params  : user setting parameters
3066  *
3067  * RETURN     : int32_t type of status
3068  *              NO_ERROR  -- success
3069  *              none-zero failure code
3070  *==========================================================================*/
setOptiZoom(const QCameraParameters & params)3071 int32_t QCameraParameters::setOptiZoom(const QCameraParameters& params)
3072 {
3073     if ((m_pCapability->qcom_supported_feature_mask &
3074         CAM_QCOM_FEATURE_OPTIZOOM) == 0){
3075         CDBG_HIGH("%s: Opti Zoom is not supported",__func__);
3076         return NO_ERROR;
3077     }
3078     const char *str = params.get(KEY_QC_OPTI_ZOOM);
3079     const char *prev_str = get(KEY_QC_OPTI_ZOOM);
3080     CDBG_HIGH("%s: str =%s & prev_str =%s",__func__, str, prev_str);
3081     if (str != NULL) {
3082         if (prev_str == NULL ||
3083             strcmp(str, prev_str) != 0) {
3084             m_bNeedRestart = true;
3085             return setOptiZoom(str);
3086         }
3087     }
3088     return NO_ERROR;
3089 }
3090 
3091 
3092 /*===========================================================================
3093  * FUNCTION   : setRedeyeReduction
3094  *
3095  * DESCRIPTION: set red eye reduction setting from user setting
3096  *
3097  * PARAMETERS :
3098  *   @params  : user setting parameters
3099  *
3100  * RETURN     : int32_t type of status
3101  *              NO_ERROR  -- success
3102  *              none-zero failure code
3103  *==========================================================================*/
setRedeyeReduction(const QCameraParameters & params)3104 int32_t QCameraParameters::setRedeyeReduction(const QCameraParameters& params)
3105 {
3106     const char *str = params.get(KEY_QC_REDEYE_REDUCTION);
3107     const char *prev_str = get(KEY_QC_REDEYE_REDUCTION);
3108     if (str != NULL) {
3109         if (prev_str == NULL ||
3110             strcmp(str, prev_str) != 0) {
3111             return setRedeyeReduction(str);
3112         }
3113     }
3114     return NO_ERROR;
3115 }
3116 
3117 /*===========================================================================
3118  * FUNCTION   : setGpsLocation
3119  *
3120  * DESCRIPTION: set GPS location information from user setting
3121  *
3122  * PARAMETERS :
3123  *   @params  : user setting parameters
3124  *
3125  * RETURN     : int32_t type of status
3126  *              NO_ERROR  -- success
3127  *              none-zero failure code
3128  *==========================================================================*/
setGpsLocation(const QCameraParameters & params)3129 int32_t QCameraParameters::setGpsLocation(const QCameraParameters& params)
3130 {
3131     const char *method = params.get(KEY_GPS_PROCESSING_METHOD);
3132     if (method) {
3133         set(KEY_GPS_PROCESSING_METHOD, method);
3134     }else {
3135         remove(KEY_GPS_PROCESSING_METHOD);
3136     }
3137 
3138     const char *latitude = params.get(KEY_GPS_LATITUDE);
3139     if (latitude) {
3140         set(KEY_GPS_LATITUDE, latitude);
3141     }else {
3142         remove(KEY_GPS_LATITUDE);
3143     }
3144 
3145     const char *latitudeRef = params.get(KEY_QC_GPS_LATITUDE_REF);
3146     if (latitudeRef) {
3147         set(KEY_QC_GPS_LATITUDE_REF, latitudeRef);
3148     }else {
3149         remove(KEY_QC_GPS_LATITUDE_REF);
3150     }
3151 
3152     const char *longitude = params.get(KEY_GPS_LONGITUDE);
3153     if (longitude) {
3154         set(KEY_GPS_LONGITUDE, longitude);
3155     }else {
3156         remove(KEY_GPS_LONGITUDE);
3157     }
3158 
3159     const char *longitudeRef = params.get(KEY_QC_GPS_LONGITUDE_REF);
3160     if (longitudeRef) {
3161         set(KEY_QC_GPS_LONGITUDE_REF, longitudeRef);
3162     }else {
3163         remove(KEY_QC_GPS_LONGITUDE_REF);
3164     }
3165 
3166     const char *altitudeRef = params.get(KEY_QC_GPS_ALTITUDE_REF);
3167     if (altitudeRef) {
3168         set(KEY_QC_GPS_ALTITUDE_REF, altitudeRef);
3169     }else {
3170         remove(KEY_QC_GPS_ALTITUDE_REF);
3171     }
3172 
3173     const char *altitude = params.get(KEY_GPS_ALTITUDE);
3174     if (altitude) {
3175         set(KEY_GPS_ALTITUDE, altitude);
3176     }else {
3177         remove(KEY_GPS_ALTITUDE);
3178     }
3179 
3180     const char *status = params.get(KEY_QC_GPS_STATUS);
3181     if (status) {
3182         set(KEY_QC_GPS_STATUS, status);
3183     } else {
3184         remove(KEY_QC_GPS_STATUS);
3185     }
3186 
3187     const char *timestamp = params.get(KEY_GPS_TIMESTAMP);
3188     if (timestamp) {
3189         set(KEY_GPS_TIMESTAMP, timestamp);
3190     }else {
3191         remove(KEY_GPS_TIMESTAMP);
3192     }
3193     return NO_ERROR;
3194 }
3195 
3196 /*===========================================================================
3197  * FUNCTION   : setNumOfSnapshot
3198  *
3199  * DESCRIPTION: set number of snapshot per shutter from user setting
3200  *
3201  * PARAMETERS : none
3202  *
3203  * RETURN     : int32_t type of status
3204  *              NO_ERROR  -- success
3205  *              none-zero failure code
3206  *==========================================================================*/
setNumOfSnapshot()3207 int32_t QCameraParameters::setNumOfSnapshot()
3208 {
3209     int nBurstNum = getBurstNum();
3210     uint8_t nExpnum = 0;
3211 
3212     const char *bracket_str = get(KEY_QC_AE_BRACKET_HDR);
3213     if (bracket_str != NULL && strlen(bracket_str) > 0) {
3214         int value = lookupAttr(BRACKETING_MODES_MAP,
3215                                sizeof(BRACKETING_MODES_MAP)/sizeof(QCameraMap),
3216                                bracket_str);
3217         switch (value) {
3218         case CAM_EXP_BRACKETING_ON:
3219             {
3220                 nExpnum = 0;
3221                 const char *str_val = get(KEY_QC_CAPTURE_BURST_EXPOSURE);
3222                 if ((str_val != NULL) && (strlen(str_val) > 0)) {
3223                     char prop[PROPERTY_VALUE_MAX];
3224                     memset(prop, 0, sizeof(prop));
3225                     strcpy(prop, str_val);
3226                     char *saveptr = NULL;
3227                     char *token = strtok_r(prop, ",", &saveptr);
3228                     while (token != NULL) {
3229                         token = strtok_r(NULL, ",", &saveptr);
3230                         nExpnum++;
3231                     }
3232                 }
3233                 if (nExpnum == 0) {
3234                     nExpnum = 1;
3235                 }
3236             }
3237             break;
3238         default:
3239             nExpnum = 1 + getNumOfExtraHDROutBufsIfNeeded();
3240             break;
3241         }
3242     }
3243 
3244     CDBG_HIGH("%s: nBurstNum = %d, nExpnum = %d", __func__, nBurstNum, nExpnum);
3245     set(KEY_QC_NUM_SNAPSHOT_PER_SHUTTER, nBurstNum * nExpnum);
3246     return NO_ERROR;
3247 }
3248 
3249 /*===========================================================================
3250  * FUNCTION   : setRecordingHint
3251  *
3252  * DESCRIPTION: set recording hint value from user setting
3253  *
3254  * PARAMETERS :
3255  *   @params  : user setting parameters
3256  *
3257  * RETURN     : int32_t type of status
3258  *              NO_ERROR  -- success
3259  *              none-zero failure code
3260  *==========================================================================*/
setRecordingHint(const QCameraParameters & params)3261 int32_t QCameraParameters::setRecordingHint(const QCameraParameters& params)
3262 {
3263     const char * str = params.get(KEY_RECORDING_HINT);
3264     const char *prev_str = get(KEY_RECORDING_HINT);
3265     if (str != NULL) {
3266         if (prev_str == NULL || strcmp(str, prev_str) != 0) {
3267             int32_t value = lookupAttr(TRUE_FALSE_MODES_MAP,
3268                                        sizeof(TRUE_FALSE_MODES_MAP)/sizeof(QCameraMap),
3269                                        str);
3270             if(value != NAME_NOT_FOUND){
3271                 updateParamEntry(KEY_RECORDING_HINT, str);
3272                 setRecordingHintValue(value);
3273                 if (getFaceDetectionOption() == true) {
3274                     setFaceDetection(value > 0 ? false : true, false);
3275                 }
3276                 return NO_ERROR;
3277             } else {
3278                 ALOGE("Invalid recording hint value: %s", str);
3279                 return BAD_VALUE;
3280             }
3281         }
3282     }
3283     return NO_ERROR;
3284 }
3285 
3286 /*===========================================================================
3287  * FUNCTION   : setNoDisplayMode
3288  *
3289  * DESCRIPTION: set no display mode from user setting
3290  *
3291  * PARAMETERS :
3292  *   @params  : user setting parameters
3293  *
3294  * RETURN     : int32_t type of status
3295  *              NO_ERROR  -- success
3296  *              none-zero failure code
3297  *==========================================================================*/
setNoDisplayMode(const QCameraParameters & params)3298 int32_t QCameraParameters::setNoDisplayMode(const QCameraParameters& params)
3299 {
3300     const char *str_val  = params.get(KEY_QC_NO_DISPLAY_MODE);
3301     const char *prev_str = get(KEY_QC_NO_DISPLAY_MODE);
3302     if(str_val && strlen(str_val) > 0) {
3303         if (prev_str == NULL || strcmp(str_val, prev_str) != 0) {
3304             m_bNoDisplayMode = atoi(str_val);
3305             set(KEY_QC_NO_DISPLAY_MODE, str_val);
3306             m_bNeedRestart = true;
3307         }
3308     } else {
3309         m_bNoDisplayMode = false;
3310     }
3311     CDBG_HIGH("Param m_bNoDisplayMode = %d", m_bNoDisplayMode);
3312     return NO_ERROR;
3313 }
3314 
3315 /*===========================================================================
3316  * FUNCTION   : setZslMode
3317  *
3318  * DESCRIPTION: set ZSL mode from user setting
3319  *
3320  * PARAMETERS :
3321  *   @params  : user setting parameters
3322  *
3323  * RETURN     : int32_t type of status
3324  *              NO_ERROR  -- success
3325  *              none-zero failure code
3326  *==========================================================================*/
setZslMode(const QCameraParameters & params)3327 int32_t QCameraParameters::setZslMode(const QCameraParameters& params)
3328 {
3329     const char *str_val  = params.get(KEY_QC_ZSL);
3330     const char *prev_val  = get(KEY_QC_ZSL);
3331 
3332     if (str_val != NULL) {
3333         if (prev_val == NULL || strcmp(str_val, prev_val) != 0) {
3334             int32_t value = lookupAttr(ON_OFF_MODES_MAP,
3335                                        sizeof(ON_OFF_MODES_MAP)/sizeof(QCameraMap),
3336                                        str_val);
3337             if (value != NAME_NOT_FOUND) {
3338                 set(KEY_QC_ZSL, str_val);
3339                 m_bZslMode_new = (value > 0)? true : false;
3340 
3341                 // ZSL mode changed, need restart preview
3342                 m_bNeedRestart = true;
3343 
3344                 return AddSetParmEntryToBatch(m_pParamBuf,
3345                                               CAM_INTF_PARM_ZSL_MODE,
3346                                               sizeof(value),
3347                                               &value);
3348             } else {
3349                 ALOGE("Invalid ZSL mode value: %s", str_val);
3350                 return BAD_VALUE;
3351             }
3352         }
3353     }
3354     return NO_ERROR;
3355 }
3356 
3357 /*===========================================================================
3358  * FUNCTION   : setWaveletDenoise
3359  *
3360  * DESCRIPTION: set wavelet denoise value from user setting
3361  *
3362  * PARAMETERS :
3363  *   @params  : user setting parameters
3364  *
3365  * RETURN     : int32_t type of status
3366  *              NO_ERROR  -- success
3367  *              none-zero failure code
3368  *==========================================================================*/
setWaveletDenoise(const QCameraParameters & params)3369 int32_t QCameraParameters::setWaveletDenoise(const QCameraParameters& params)
3370 {
3371     const char *str_pf = params.getPictureFormat();
3372     int32_t pictureFormat =
3373         lookupAttr(PICTURE_TYPES_MAP,
3374                    sizeof(PICTURE_TYPES_MAP) / sizeof(QCameraMap),
3375                    str_pf);
3376     if (pictureFormat != NAME_NOT_FOUND) {
3377         if (CAM_FORMAT_YUV_422_NV16 == pictureFormat) {
3378             ALOGE("NV16 format isn't supported in denoise lib!");
3379             return setWaveletDenoise(DENOISE_OFF);
3380         }
3381     }
3382     const char *str = params.get(KEY_QC_DENOISE);
3383     const char *prev_str = get(KEY_QC_DENOISE);
3384     if (str != NULL) {
3385         if (prev_str == NULL ||
3386             strcmp(str, prev_str) != 0) {
3387             return setWaveletDenoise(str);
3388         }
3389     }
3390     return NO_ERROR;
3391 }
3392 
3393 /*===========================================================================
3394  * FUNCTION   : setCameraMode
3395  *
3396  * DESCRIPTION: set camera mode from user setting
3397  *
3398  * PARAMETERS :
3399  *   @params  : user setting parameters
3400  *
3401  * RETURN     : int32_t type of status
3402  *              NO_ERROR  -- success
3403  *              none-zero failure code
3404  *==========================================================================*/
setCameraMode(const QCameraParameters & params)3405 int32_t QCameraParameters::setCameraMode(const QCameraParameters& params)
3406 {
3407     const char *str = params.get(KEY_QC_CAMERA_MODE);
3408     if (str != NULL) {
3409         set(KEY_QC_CAMERA_MODE, str);
3410     } else {
3411         remove(KEY_QC_CAMERA_MODE);
3412     }
3413     return NO_ERROR;
3414 }
3415 
3416 /*===========================================================================
3417  * FUNCTION   : setSceneSelectionMode
3418  *
3419  * DESCRIPTION: set scene selection mode from user setting
3420  *
3421  * PARAMETERS :
3422  *   @params  : user setting parameters
3423  *
3424  * RETURN     : int32_t type of status
3425  *              NO_ERROR  -- success
3426  *              none-zero failure code
3427  *==========================================================================*/
setSceneSelectionMode(const QCameraParameters & params)3428 int32_t QCameraParameters::setSceneSelectionMode(const QCameraParameters& params)
3429 {
3430     const char *str = params.get(KEY_QC_SCENE_SELECTION);
3431     const char *prev_str = get(KEY_QC_SCENE_SELECTION);
3432     if (NULL != str) {
3433         if ((NULL == prev_str) || (strcmp(str, prev_str) != 0)) {
3434             int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP,
3435                     sizeof(ENABLE_DISABLE_MODES_MAP)/sizeof(QCameraMap),
3436                     str);
3437             if (value != NAME_NOT_FOUND) {
3438                 ALOGD("%s: Setting selection value %s", __func__, str);
3439                 if (value && m_bZslMode_new) {
3440                     updateParamEntry(KEY_QC_SCENE_SELECTION, str);
3441                     m_bNeedRestart = true;
3442                     m_bSceneSelection = true;
3443                 } else if (!value) {
3444                     updateParamEntry(KEY_QC_SCENE_SELECTION, str);
3445                     m_bNeedRestart = true;
3446                     m_bSceneSelection = false;
3447                 } else {
3448                     ALOGE("%s: Trying to enable scene selection in non ZSL mode!!!",
3449                             __func__);
3450                     return BAD_VALUE;
3451                 }
3452             } else {
3453                 ALOGE("%s: Trying to configure invalid scene selection value: %s",
3454                         __func__,
3455                         str);
3456                 return BAD_VALUE;
3457             }
3458         }
3459     }
3460 
3461     return NO_ERROR;
3462 }
3463 
3464 /*===========================================================================
3465  * FUNCTION   : setSelectedScene
3466  *
3467  * DESCRIPTION: select specific scene
3468  *
3469  * PARAMETERS :
3470  *   @scene   : scene mode
3471  *
3472  * RETURN     : int32_t type of status
3473  *              NO_ERROR  -- success
3474  *              none-zero failure code
3475  *==========================================================================*/
setSelectedScene(cam_scene_mode_type scene)3476 int32_t QCameraParameters::setSelectedScene(cam_scene_mode_type scene)
3477 {
3478     Mutex::Autolock l(m_SceneSelectLock);
3479     m_SelectedScene = scene;
3480     return NO_ERROR;
3481 }
3482 
3483 /*===========================================================================
3484  * FUNCTION   : getSelectedScene
3485  *
3486  * DESCRIPTION: get selected scene
3487  *
3488  * PARAMETERS :
3489  *
3490  * RETURN     : currently selected scene
3491  *==========================================================================*/
getSelectedScene()3492 cam_scene_mode_type QCameraParameters::getSelectedScene()
3493 {
3494     Mutex::Autolock l(m_SceneSelectLock);
3495     return m_SelectedScene;
3496 }
3497 
3498 /*==========================================================
3499  * FUNCTION   : setRdiMode
3500  *
3501  * DESCRIPTION: set Rdi mode from user setting
3502  *
3503  * PARAMETERS :
3504  *   @params  : user setting parameters
3505  *
3506  * RETURN     : int32_t type of status
3507  *              NO_ERROR  -- success
3508  *              none-zero failure code
3509  *===========================================================*/
setRdiMode(const QCameraParameters & params)3510 int32_t QCameraParameters::setRdiMode(const QCameraParameters& params)
3511 {
3512     const char *str = params.get(KEY_QC_RDI_MODE);
3513     const char *prev_str = get(KEY_QC_RDI_MODE);
3514     char prop[PROPERTY_VALUE_MAX];
3515     memset(prop, 0, sizeof(prop));
3516 
3517     property_get("persist.camera.rdi.mode", prop, VALUE_DISABLE);
3518     if ((str != NULL) && (prev_str == NULL || strcmp(str, prev_str) != 0)) {
3519         ALOGD("%s:%d : RDI mode set to %s", __func__, __LINE__, str);
3520         setRdiMode(str);
3521     } else if (prev_str == NULL || strcmp(prev_str, prop) != 0 ) {
3522         ALOGD("%s:%d : RDI mode set to prop: %s", __func__, __LINE__, prop);
3523         setRdiMode(prop);
3524     }
3525     return NO_ERROR;
3526 }
3527 
3528 /*==========================================================
3529  * FUNCTION   : setSecureMode
3530  *
3531  * DESCRIPTION: set secure mode from user setting
3532  *
3533  * PARAMETERS :
3534  *   @params  : user setting parameters
3535  *
3536  * RETURN     : int32_t type of status
3537  *              NO_ERROR  -- success
3538  *              none-zero failure code
3539  *===========================================================*/
3540 
setSecureMode(const QCameraParameters & params)3541 int32_t QCameraParameters::setSecureMode(
3542   const QCameraParameters& params)
3543 {
3544     const char *str = params.get(KEY_QC_SECURE_MODE);
3545     const char *prev_str = get(KEY_QC_SECURE_MODE);
3546     char prop[PROPERTY_VALUE_MAX];
3547     memset(prop, 0, sizeof(prop));
3548 
3549     property_get("persist.camera.secure.mode", prop, VALUE_DISABLE);
3550     if ((str != NULL) && (prev_str == NULL || strcmp(str, prev_str) != 0)) {
3551         ALOGD("%s : Secure mode set to KEY: %s", __func__, str);
3552         setSecureMode(str);
3553     } else if (prev_str == NULL || strcmp(prev_str, prop) != 0 ) {
3554         ALOGD("%s : Secure mode set to prop: %s", __func__, prop);
3555         setSecureMode(prop);
3556     }
3557     return NO_ERROR;
3558 }
3559 
3560 /*===========================================================================
3561  * FUNCTION   : setZslAttributes
3562  *
3563  * DESCRIPTION: set ZSL related attributes from user setting
3564  *
3565  * PARAMETERS :
3566  *   @params  : user setting parameters
3567  *
3568  * RETURN     : int32_t type of status
3569  *              NO_ERROR  -- success
3570  *              none-zero failure code
3571  *==========================================================================*/
setZslAttributes(const QCameraParameters & params)3572 int32_t QCameraParameters::setZslAttributes(const QCameraParameters& params)
3573 {
3574     // TODO: may switch to pure param instead of sysprop
3575     char prop[PROPERTY_VALUE_MAX];
3576 
3577     const char *str = params.get(KEY_QC_ZSL_BURST_INTERVAL);
3578     if (str != NULL) {
3579         set(KEY_QC_ZSL_BURST_INTERVAL, str);
3580     } else {
3581         memset(prop, 0, sizeof(prop));
3582         property_get("persist.camera.zsl.interval", prop, "1");
3583         set(KEY_QC_ZSL_BURST_INTERVAL, prop);
3584         CDBG_HIGH("%s: [ZSL Retro] burst interval: %s", __func__, prop);
3585     }
3586 
3587     str = params.get(KEY_QC_ZSL_BURST_LOOKBACK);
3588     if (str != NULL) {
3589         set(KEY_QC_ZSL_BURST_LOOKBACK, str);
3590     } else {
3591         memset(prop, 0, sizeof(prop));
3592         property_get("persist.camera.zsl.backlookcnt", prop, "2");
3593         set(KEY_QC_ZSL_BURST_LOOKBACK, prop);
3594         CDBG_HIGH("%s: [ZSL Retro] look back count: %s", __func__, prop);
3595     }
3596 
3597     str = params.get(KEY_QC_ZSL_QUEUE_DEPTH);
3598     if (str != NULL) {
3599         set(KEY_QC_ZSL_QUEUE_DEPTH, str);
3600     } else {
3601         memset(prop, 0, sizeof(prop));
3602         property_get("persist.camera.zsl.queuedepth", prop, "2");
3603         set(KEY_QC_ZSL_QUEUE_DEPTH, prop);
3604         CDBG_HIGH("%s: [ZSL Retro] queue depth: %s", __func__, prop);
3605     }
3606 
3607     return NO_ERROR;
3608 }
3609 
3610 /*===========================================================================
3611  * FUNCTION   : setFlip
3612  *
3613  * DESCRIPTION: set preview/ video/ picture flip mode from user setting
3614  *
3615  * PARAMETERS :
3616  *   @params  : user setting parameters
3617  *
3618  * RETURN     : int32_t type of status
3619  *              NO_ERROR  -- success
3620  *              none-zero failure code
3621  *==========================================================================*/
setFlip(const QCameraParameters & params)3622 int32_t QCameraParameters::setFlip(const QCameraParameters& params)
3623 {
3624     if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_FLIP) == 0) {
3625         CDBG_HIGH("%s: flip is not supported.", __func__);
3626         return NO_ERROR;
3627     }
3628 
3629     //check preview flip setting
3630     const char *str = params.get(KEY_QC_PREVIEW_FLIP);
3631     const char *prev_val = get(KEY_QC_PREVIEW_FLIP);
3632     if(str != NULL){
3633         if (prev_val == NULL || strcmp(str, prev_val) != 0) {
3634             int32_t value = lookupAttr(FLIP_MODES_MAP,
3635                                        sizeof(FLIP_MODES_MAP)/sizeof(QCameraMap),
3636                                        str);
3637             if(value != NAME_NOT_FOUND){
3638                 set(KEY_QC_PREVIEW_FLIP, str);
3639                 m_bPreviewFlipChanged = true;
3640             }
3641         }
3642     }
3643 
3644     // check video filp setting
3645     str = params.get(KEY_QC_VIDEO_FLIP);
3646     prev_val = get(KEY_QC_VIDEO_FLIP);
3647     if(str != NULL){
3648         if (prev_val == NULL || strcmp(str, prev_val) != 0) {
3649             int32_t value = lookupAttr(FLIP_MODES_MAP,
3650                                        sizeof(FLIP_MODES_MAP)/sizeof(QCameraMap),
3651                                        str);
3652             if(value != NAME_NOT_FOUND){
3653                 set(KEY_QC_VIDEO_FLIP, str);
3654                 m_bVideoFlipChanged = true;
3655             }
3656         }
3657     }
3658 
3659     // check picture filp setting
3660     str = params.get(KEY_QC_SNAPSHOT_PICTURE_FLIP);
3661     prev_val = get(KEY_QC_SNAPSHOT_PICTURE_FLIP);
3662     if(str != NULL){
3663         if (prev_val == NULL || strcmp(str, prev_val) != 0) {
3664             int32_t value = lookupAttr(FLIP_MODES_MAP,
3665                                        sizeof(FLIP_MODES_MAP)/sizeof(QCameraMap),
3666                                        str);
3667             if(value != NAME_NOT_FOUND){
3668                 set(KEY_QC_SNAPSHOT_PICTURE_FLIP, str);
3669                 m_bSnapshotFlipChanged = true;
3670             }
3671         }
3672     }
3673 
3674     return NO_ERROR;
3675 }
3676 
3677 /*===========================================================================
3678  * FUNCTION   : setBurstNum
3679  *
3680  * DESCRIPTION: set burst number of snapshot
3681  *
3682  * PARAMETERS :
3683  *   @params  : user setting parameters
3684  *
3685  * RETURN     : int32_t type of status
3686  *              NO_ERROR  -- success
3687  *              none-zero failure code
3688  *==========================================================================*/
setBurstNum(const QCameraParameters & params)3689 int32_t QCameraParameters::setBurstNum(const QCameraParameters& params)
3690 {
3691     int nBurstNum = params.getInt(KEY_QC_SNAPSHOT_BURST_NUM);
3692     if (isAdvCamFeaturesEnabled()) {
3693         nBurstNum = 1;
3694     }
3695     if (nBurstNum <= 0) {
3696         // if burst number is not set in parameters,
3697         // read from sys prop
3698         char prop[PROPERTY_VALUE_MAX];
3699         memset(prop, 0, sizeof(prop));
3700         property_get("persist.camera.snapshot.number", prop, "0");
3701         nBurstNum = atoi(prop);
3702         if (nBurstNum <= 0) {
3703             nBurstNum = 1;
3704         }
3705     }
3706     set(KEY_QC_SNAPSHOT_BURST_NUM, nBurstNum);
3707     m_nBurstNum = nBurstNum;
3708     CDBG_HIGH("%s: [ZSL Retro] m_nBurstNum = %d", __func__, m_nBurstNum);
3709     return AddSetParmEntryToBatch(m_pParamBuf,
3710                                   CAM_INTF_PARM_BURST_NUM,
3711                                   sizeof(nBurstNum),
3712                                   &nBurstNum);
3713 }
3714 
3715 /*===========================================================================
3716  * FUNCTION   : setSnapshotFDReq
3717  *
3718  * DESCRIPTION: set requirement of Face Detection Metadata in Snapshot mode.
3719  *
3720  * PARAMETERS :
3721  *   @params  : user setting parameters
3722  *
3723  * RETURN     : int32_t type of status
3724  *              NO_ERROR  -- success
3725  *              none-zero failure code
3726  *==========================================================================*/
setSnapshotFDReq(const QCameraParameters & params)3727 int32_t QCameraParameters::setSnapshotFDReq(const QCameraParameters& params)
3728 {
3729     char prop[PROPERTY_VALUE_MAX];
3730     const char *str = params.get(KEY_QC_SNAPSHOT_FD_DATA);
3731 
3732     if(str != NULL){
3733         set(KEY_QC_SNAPSHOT_FD_DATA, str);
3734     }else{
3735         memset(prop, 0, sizeof(prop));
3736         property_get("persist.camera.snapshot.fd", prop, "0");
3737         set(KEY_QC_SNAPSHOT_FD_DATA, prop);
3738     }
3739     return NO_ERROR;
3740 }
3741 
3742 /*===========================================================================
3743  * FUNCTION   : setMobicat
3744  *
3745  * DESCRIPTION: set Mobicat on/off.
3746  *
3747  * PARAMETERS :
3748  *   @params  : user setting parameters
3749  *
3750  * RETURN     : int32_t type of status
3751  *              NO_ERROR  -- success
3752  *              none-zero failure code
3753  *==========================================================================*/
setMobicat(const QCameraParameters &)3754 int32_t QCameraParameters::setMobicat(const QCameraParameters& )
3755 {
3756     char value [PROPERTY_VALUE_MAX];
3757     property_get("persist.camera.mobicat", value, "0");
3758     bool enableMobi = atoi(value) > 0 ? true : false;
3759     int32_t ret = NO_ERROR;;
3760 
3761     if (enableMobi) {
3762         tune_cmd_t tune_cmd;
3763         tune_cmd.type = 2;
3764         tune_cmd.module = 0;
3765         tune_cmd.value = 1;
3766 
3767         ret = AddSetParmEntryToBatch(m_pParamBuf,
3768                                 CAM_INTF_PARM_SET_VFE_COMMAND,
3769                                 sizeof(tune_cmd_t),
3770                                 &tune_cmd);
3771         if (NO_ERROR != ret) {
3772             return ret;
3773         }
3774         tune_cmd.module = 0;
3775 
3776         ret = AddSetParmEntryToBatch(m_pParamBuf,
3777                                 CAM_INTF_PARM_SET_PP_COMMAND,
3778                                 sizeof(tune_cmd_t),
3779                                 &tune_cmd);
3780     }
3781 
3782     return ret;
3783 }
3784 
3785 /*===========================================================================
3786  * FUNCTION   : updateParameters
3787  *
3788  * DESCRIPTION: update parameters from user setting
3789  *
3790  * PARAMETERS :
3791  *   @params  : user setting parameters
3792  *   @needRestart : [output] if preview need restart upon setting changes
3793  *
3794  * RETURN     : int32_t type of status
3795  *              NO_ERROR  -- success
3796  *              none-zero failure code
3797  *==========================================================================*/
updateParameters(QCameraParameters & params,bool & needRestart)3798 int32_t QCameraParameters::updateParameters(QCameraParameters& params,
3799                                             bool &needRestart)
3800 {
3801     int32_t final_rc = NO_ERROR;
3802     int32_t rc;
3803     m_bNeedRestart = false;
3804 
3805     if(initBatchUpdate(m_pParamBuf) < 0 ) {
3806         ALOGE("%s:Failed to initialize group update table",__func__);
3807         rc = BAD_TYPE;
3808         goto UPDATE_PARAM_DONE;
3809     }
3810 
3811     if ((rc = setPreviewSize(params)))                  final_rc = rc;
3812     if ((rc = setVideoSize(params)))                    final_rc = rc;
3813     if ((rc = setPictureSize(params)))                  final_rc = rc;
3814     if ((rc = setPreviewFormat(params)))                final_rc = rc;
3815     if ((rc = setPictureFormat(params)))                final_rc = rc;
3816     if ((rc = setJpegQuality(params)))                  final_rc = rc;
3817     if ((rc = setOrientation(params)))                  final_rc = rc;
3818     if ((rc = setRotation(params)))                     final_rc = rc;
3819     if ((rc = setVideoRotation(params)))                final_rc = rc;
3820     if ((rc = setNoDisplayMode(params)))                final_rc = rc;
3821     if ((rc = setZslMode(params)))                      final_rc = rc;
3822     if ((rc = setZslAttributes(params)))                final_rc = rc;
3823     if ((rc = setCameraMode(params)))                   final_rc = rc;
3824     if ((rc = setSceneSelectionMode(params)))           final_rc = rc;
3825     if ((rc = setRecordingHint(params)))                final_rc = rc;
3826     if ((rc = setRdiMode(params)))                      final_rc = rc;
3827     if ((rc = setSecureMode(params)))                   final_rc = rc;
3828     if ((rc = setPreviewFrameRate(params)))             final_rc = rc;
3829     if ((rc = setPreviewFpsRange(params)))              final_rc = rc;
3830     if ((rc = setAutoExposure(params)))                 final_rc = rc;
3831     if ((rc = setEffect(params)))                       final_rc = rc;
3832     if ((rc = setBrightness(params)))                   final_rc = rc;
3833     if ((rc = setZoom(params)))                         final_rc = rc;
3834     if ((rc = setSharpness(params)))                    final_rc = rc;
3835     if ((rc = setSaturation(params)))                   final_rc = rc;
3836     if ((rc = setContrast(params)))                     final_rc = rc;
3837     if ((rc = setFocusMode(params)))                    final_rc = rc;
3838     if ((rc = setISOValue(params)))                     final_rc = rc;
3839     if ((rc = setSkinToneEnhancement(params)))          final_rc = rc;
3840     if ((rc = setFlash(params)))                        final_rc = rc;
3841     if ((rc = setAecLock(params)))                      final_rc = rc;
3842     if ((rc = setAwbLock(params)))                      final_rc = rc;
3843     if ((rc = setLensShadeValue(params)))               final_rc = rc;
3844     if ((rc = setMCEValue(params)))                     final_rc = rc;
3845     if ((rc = setDISValue(params)))                     final_rc = rc;
3846     if ((rc = setHighFrameRate(params)))                final_rc = rc;
3847     if ((rc = setHighSpeedRecording(params)))           final_rc = rc;
3848     if ((rc = setAntibanding(params)))                  final_rc = rc;
3849     if ((rc = setExposureCompensation(params)))         final_rc = rc;
3850     if ((rc = setWhiteBalance(params)))                 final_rc = rc;
3851     if ((rc = setSceneMode(params)))                    final_rc = rc;
3852     if ((rc = setFocusAreas(params)))                   final_rc = rc;
3853     if ((rc = setMeteringAreas(params)))                final_rc = rc;
3854     if ((rc = setSelectableZoneAf(params)))             final_rc = rc;
3855     if ((rc = setRedeyeReduction(params)))              final_rc = rc;
3856     if ((rc = setAEBracket(params)))                    final_rc = rc;
3857     if ((rc = setAutoHDR(params)))                      final_rc = rc;
3858     if ((rc = setGpsLocation(params)))                  final_rc = rc;
3859     if ((rc = setWaveletDenoise(params)))               final_rc = rc;
3860     if ((rc = setFaceRecognition(params)))              final_rc = rc;
3861     if ((rc = setFlip(params)))                         final_rc = rc;
3862     if ((rc = setVideoHDR(params)))                     final_rc = rc;
3863     if ((rc = setVtEnable(params)))                     final_rc = rc;
3864     if ((rc = setAFBracket(params)))                    final_rc = rc;
3865     if ((rc = setChromaFlash(params)))                  final_rc = rc;
3866     if ((rc = setOptiZoom(params)))                     final_rc = rc;
3867     if ((rc = setBurstNum(params)))                     final_rc = rc;
3868     if ((rc = setBurstLEDOnPeriod(params)))             final_rc = rc;
3869     if ((rc = setRetroActiveBurstNum(params)))          final_rc = rc;
3870     if ((rc = setSnapshotFDReq(params)))                final_rc = rc;
3871     if ((rc = setTintlessValue(params)))                final_rc = rc;
3872     if ((rc = setCDSMode(params)))                      final_rc = rc;
3873 
3874     // update live snapshot size after all other parameters are set
3875     if ((rc = setLiveSnapshotSize(params)))             final_rc = rc;
3876     if ((rc = setJpegThumbnailSize(params)))            final_rc = rc;
3877     if ((rc = setStatsDebugMask()))                     final_rc = rc;
3878     if ((rc = setPAAF()))                               final_rc = rc;
3879     if ((rc = setMobicat(params)))                      final_rc = rc;
3880 
3881     if ((rc = updateFlash(false)))                      final_rc = rc;
3882 
3883 UPDATE_PARAM_DONE:
3884     needRestart = m_bNeedRestart;
3885     return final_rc;
3886 }
3887 
3888 /*===========================================================================
3889  * FUNCTION   : commitParameters
3890  *
3891  * DESCRIPTION: commit parameter changes to backend
3892  *
3893  * PARAMETERS : none
3894  *
3895  * RETURN     : int32_t type of status
3896  *              NO_ERROR  -- success
3897  *              none-zero failure code
3898  *==========================================================================*/
commitParameters()3899 int32_t QCameraParameters::commitParameters()
3900 {
3901     return commitSetBatch();
3902 }
3903 
3904 /*===========================================================================
3905  * FUNCTION   : initDefaultParameters
3906  *
3907  * DESCRIPTION: initialize default parameters for the first time
3908  *
3909  * PARAMETERS : none
3910  *
3911  * RETURN     : int32_t type of status
3912  *              NO_ERROR  -- success
3913  *              none-zero failure code
3914  *==========================================================================*/
initDefaultParameters()3915 int32_t QCameraParameters::initDefaultParameters()
3916 {
3917     if(initBatchUpdate(m_pParamBuf) < 0 ) {
3918         ALOGE("%s:Failed to initialize group update table", __func__);
3919         return BAD_TYPE;
3920     }
3921     int32_t hal_version = CAM_HAL_V1;
3922     AddSetParmEntryToBatch(m_pParamBuf,
3923                            CAM_INTF_PARM_HAL_VERSION,
3924                            sizeof(hal_version),
3925                            &hal_version);
3926 
3927     /*************************Initialize Values******************************/
3928     // Set read only parameters from camera capability
3929     set(KEY_SMOOTH_ZOOM_SUPPORTED,
3930         m_pCapability->smooth_zoom_supported? VALUE_TRUE : VALUE_FALSE);
3931     set(KEY_ZOOM_SUPPORTED,
3932         m_pCapability->zoom_supported? VALUE_TRUE : VALUE_FALSE);
3933     set(KEY_VIDEO_SNAPSHOT_SUPPORTED,
3934         m_pCapability->video_snapshot_supported? VALUE_TRUE : VALUE_FALSE);
3935     set(KEY_VIDEO_STABILIZATION_SUPPORTED,
3936         m_pCapability->video_stablization_supported? VALUE_TRUE : VALUE_FALSE);
3937     set(KEY_AUTO_EXPOSURE_LOCK_SUPPORTED,
3938         m_pCapability->auto_exposure_lock_supported? VALUE_TRUE : VALUE_FALSE);
3939     set(KEY_AUTO_WHITEBALANCE_LOCK_SUPPORTED,
3940         m_pCapability->auto_wb_lock_supported? VALUE_TRUE : VALUE_FALSE);
3941     set(KEY_QC_SUPPORTED_CAMERA_FEATURES,
3942         m_pCapability->qcom_supported_feature_mask);
3943     set(KEY_MAX_NUM_DETECTED_FACES_HW, m_pCapability->max_num_roi);
3944     set(KEY_MAX_NUM_DETECTED_FACES_SW, m_pCapability->max_num_roi);
3945     set(KEY_QC_MAX_NUM_REQUESTED_FACES, m_pCapability->max_num_roi);
3946     // Set focal length, horizontal view angle, and vertical view angle
3947     setFloat(KEY_FOCAL_LENGTH, m_pCapability->focal_length);
3948     setFloat(KEY_HORIZONTAL_VIEW_ANGLE, m_pCapability->hor_view_angle);
3949     setFloat(KEY_VERTICAL_VIEW_ANGLE, m_pCapability->ver_view_angle);
3950     set(QCameraParameters::KEY_FOCUS_DISTANCES, "Infinity,Infinity,Infinity");
3951     set(KEY_QC_AUTO_HDR_SUPPORTED,
3952         (m_pCapability->auto_hdr_supported)? VALUE_TRUE : VALUE_FALSE);
3953     // Set supported preview sizes
3954     if (m_pCapability->preview_sizes_tbl_cnt > 0 &&
3955         m_pCapability->preview_sizes_tbl_cnt <= MAX_SIZES_CNT) {
3956         String8 previewSizeValues = createSizesString(
3957                 m_pCapability->preview_sizes_tbl, m_pCapability->preview_sizes_tbl_cnt);
3958         set(KEY_SUPPORTED_PREVIEW_SIZES, previewSizeValues.string());
3959         CDBG_HIGH("%s: supported preview sizes: %s", __func__, previewSizeValues.string());
3960         // Set default preview size
3961         CameraParameters::setPreviewSize(m_pCapability->preview_sizes_tbl[0].width,
3962                                          m_pCapability->preview_sizes_tbl[0].height);
3963     } else {
3964         ALOGE("%s: supported preview sizes cnt is 0 or exceeds max!!!", __func__);
3965     }
3966 
3967     // Set supported video sizes
3968     if (m_pCapability->video_sizes_tbl_cnt > 0 &&
3969         m_pCapability->video_sizes_tbl_cnt <= MAX_SIZES_CNT) {
3970         String8 videoSizeValues = createSizesString(
3971                 m_pCapability->video_sizes_tbl, m_pCapability->video_sizes_tbl_cnt);
3972         set(KEY_SUPPORTED_VIDEO_SIZES, videoSizeValues.string());
3973         CDBG_HIGH("%s: supported video sizes: %s", __func__, videoSizeValues.string());
3974         // Set default video size
3975         CameraParameters::setVideoSize(m_pCapability->video_sizes_tbl[0].width,
3976                                        m_pCapability->video_sizes_tbl[0].height);
3977 
3978         //Set preferred Preview size for video
3979         String8 vSize = createSizesString(&m_pCapability->preview_sizes_tbl[0], 1);
3980         set(KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO, vSize.string());
3981     } else {
3982         ALOGE("%s: supported video sizes cnt is 0 or exceeds max!!!", __func__);
3983     }
3984 
3985     // Set supported picture sizes
3986     if (m_pCapability->picture_sizes_tbl_cnt > 0 &&
3987         m_pCapability->picture_sizes_tbl_cnt <= MAX_SIZES_CNT) {
3988         String8 pictureSizeValues = createSizesString(
3989                 m_pCapability->picture_sizes_tbl, m_pCapability->picture_sizes_tbl_cnt);
3990         set(KEY_SUPPORTED_PICTURE_SIZES, pictureSizeValues.string());
3991         CDBG_HIGH("%s: supported pic sizes: %s", __func__, pictureSizeValues.string());
3992         // Set default picture size to the smallest resolution
3993         CameraParameters::setPictureSize(
3994            m_pCapability->picture_sizes_tbl[m_pCapability->picture_sizes_tbl_cnt-1].width,
3995            m_pCapability->picture_sizes_tbl[m_pCapability->picture_sizes_tbl_cnt-1].height);
3996     } else {
3997         ALOGE("%s: supported picture sizes cnt is 0 or exceeds max!!!", __func__);
3998     }
3999 
4000     // Need check if scale should be enabled
4001     if (m_pCapability->scale_picture_sizes_cnt > 0 &&
4002         m_pCapability->scale_picture_sizes_cnt <= MAX_SCALE_SIZES_CNT){
4003         //get scale size, enable scaling. And re-set picture size table with scale sizes
4004         m_reprocScaleParam.setScaleEnable(true);
4005         int rc_s = m_reprocScaleParam.setScaleSizeTbl(
4006             m_pCapability->scale_picture_sizes_cnt, m_pCapability->scale_picture_sizes,
4007             m_pCapability->picture_sizes_tbl_cnt, m_pCapability->picture_sizes_tbl);
4008         if(rc_s == NO_ERROR){
4009             cam_dimension_t *totalSizeTbl = m_reprocScaleParam.getTotalSizeTbl();
4010             uint8_t totalSizeCnt = m_reprocScaleParam.getTotalSizeTblCnt();
4011             String8 pictureSizeValues = createSizesString(totalSizeTbl, totalSizeCnt);
4012             set(KEY_SUPPORTED_PICTURE_SIZES, pictureSizeValues.string());
4013             CDBG_HIGH("%s: scaled supported pic sizes: %s", __func__, pictureSizeValues.string());
4014         }else{
4015             m_reprocScaleParam.setScaleEnable(false);
4016             ALOGE("%s: reset scaled picture size table failed.", __func__);
4017         }
4018     }else{
4019         m_reprocScaleParam.setScaleEnable(false);
4020     }
4021 
4022     // Set supported thumbnail sizes
4023     String8 thumbnailSizeValues = createSizesString(
4024             THUMBNAIL_SIZES_MAP,
4025             sizeof(THUMBNAIL_SIZES_MAP)/sizeof(cam_dimension_t));
4026     set(KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES, thumbnailSizeValues.string());
4027     // Set default thumnail size
4028     set(KEY_JPEG_THUMBNAIL_WIDTH, THUMBNAIL_SIZES_MAP[0].width);
4029     set(KEY_JPEG_THUMBNAIL_HEIGHT, THUMBNAIL_SIZES_MAP[0].height);
4030 
4031     // Set supported livesnapshot sizes
4032     if (m_pCapability->livesnapshot_sizes_tbl_cnt > 0 &&
4033         m_pCapability->livesnapshot_sizes_tbl_cnt <= MAX_SIZES_CNT) {
4034         String8 liveSnpashotSizeValues = createSizesString(
4035                 m_pCapability->livesnapshot_sizes_tbl,
4036                 m_pCapability->livesnapshot_sizes_tbl_cnt);
4037         set(KEY_QC_SUPPORTED_LIVESNAPSHOT_SIZES, liveSnpashotSizeValues.string());
4038         CDBG("%s: supported live snapshot sizes: %s", __func__, liveSnpashotSizeValues.string());
4039         m_LiveSnapshotSize =
4040             m_pCapability->livesnapshot_sizes_tbl[m_pCapability->livesnapshot_sizes_tbl_cnt-1];
4041     }
4042 
4043     // Set supported preview formats
4044     String8 previewFormatValues = createValuesString(
4045             (int *)m_pCapability->supported_preview_fmts,
4046             m_pCapability->supported_preview_fmt_cnt,
4047             PREVIEW_FORMATS_MAP,
4048             sizeof(PREVIEW_FORMATS_MAP)/sizeof(QCameraMap));
4049     set(KEY_SUPPORTED_PREVIEW_FORMATS, previewFormatValues.string());
4050     // Set default preview format
4051     CameraParameters::setPreviewFormat(PIXEL_FORMAT_YUV420SP);
4052 
4053     // Set default Video Format
4054     set(KEY_VIDEO_FRAME_FORMAT, PIXEL_FORMAT_YUV420SP);
4055 
4056     // Set supported picture formats
4057     String8 pictureTypeValues(PIXEL_FORMAT_JPEG);
4058     String8 str = createValuesString(
4059             (int *)m_pCapability->supported_raw_fmts,
4060             m_pCapability->supported_raw_fmt_cnt,
4061             PICTURE_TYPES_MAP,
4062             sizeof(PICTURE_TYPES_MAP)/sizeof(QCameraMap));
4063     if (str.string() != NULL) {
4064         pictureTypeValues.append(",");
4065         pictureTypeValues.append(str);
4066     }
4067 
4068     set(KEY_SUPPORTED_PICTURE_FORMATS, pictureTypeValues.string());
4069     // Set default picture Format
4070     CameraParameters::setPictureFormat(PIXEL_FORMAT_JPEG);
4071     // Set raw image size
4072     char raw_size_str[32];
4073     snprintf(raw_size_str, sizeof(raw_size_str), "%dx%d",
4074              m_pCapability->raw_dim[0].width, m_pCapability->raw_dim[0].height);
4075     set(KEY_QC_RAW_PICUTRE_SIZE, raw_size_str);
4076     CDBG("%s: KEY_QC_RAW_PICUTRE_SIZE: w: %d, h: %d ", __func__,
4077        m_pCapability->raw_dim[0].width, m_pCapability->raw_dim[0].height);
4078 
4079     //set default jpeg quality and thumbnail quality
4080     set(KEY_JPEG_QUALITY, 85);
4081     set(KEY_JPEG_THUMBNAIL_QUALITY, 85);
4082 
4083     // Set FPS ranges
4084     if (m_pCapability->fps_ranges_tbl_cnt > 0 &&
4085         m_pCapability->fps_ranges_tbl_cnt <= MAX_SIZES_CNT) {
4086         int default_fps_index = 0;
4087         String8 fpsRangeValues = createFpsRangeString(m_pCapability->fps_ranges_tbl,
4088                                                       m_pCapability->fps_ranges_tbl_cnt,
4089                                                       default_fps_index);
4090         set(KEY_SUPPORTED_PREVIEW_FPS_RANGE, fpsRangeValues.string());
4091 
4092         int min_fps =
4093             int(m_pCapability->fps_ranges_tbl[default_fps_index].min_fps * 1000);
4094         int max_fps =
4095             int(m_pCapability->fps_ranges_tbl[default_fps_index].max_fps * 1000);
4096         m_default_fps_range = m_pCapability->fps_ranges_tbl[default_fps_index];
4097         //Set video fps same as preview fps
4098         setPreviewFpsRange(min_fps, max_fps, min_fps, max_fps);
4099 
4100         // Set legacy preview fps
4101         String8 fpsValues = createFpsString(m_pCapability->fps_ranges_tbl[default_fps_index]);
4102         set(KEY_SUPPORTED_PREVIEW_FRAME_RATES, fpsValues.string());
4103         CDBG_HIGH("%s: supported fps rates: %s", __func__, fpsValues.string());
4104         CameraParameters::setPreviewFrameRate(int(m_pCapability->fps_ranges_tbl[default_fps_index].max_fps));
4105     } else {
4106         ALOGE("%s: supported fps ranges cnt is 0 or exceeds max!!!", __func__);
4107     }
4108 
4109     // Set supported focus modes
4110     if (m_pCapability->supported_focus_modes_cnt > 0) {
4111         String8 focusModeValues = createValuesString(
4112                 (int *)m_pCapability->supported_focus_modes,
4113                 m_pCapability->supported_focus_modes_cnt,
4114                 FOCUS_MODES_MAP,
4115                 sizeof(FOCUS_MODES_MAP)/sizeof(QCameraMap));
4116         set(KEY_SUPPORTED_FOCUS_MODES, focusModeValues);
4117 
4118         // Set default focus mode and update corresponding parameter buf
4119         const char *focusMode = lookupNameByValue(FOCUS_MODES_MAP,
4120                                              sizeof(FOCUS_MODES_MAP)/sizeof(QCameraMap),
4121                                              m_pCapability->supported_focus_modes[0]);
4122         if (focusMode != NULL) {
4123             setFocusMode(focusMode);
4124         } else {
4125             setFocusMode(FOCUS_MODE_FIXED);
4126         }
4127     } else {
4128         ALOGE("%s: supported focus modes cnt is 0!!!", __func__);
4129     }
4130 
4131     // Set focus areas
4132     if (m_pCapability->max_num_focus_areas > MAX_ROI) {
4133         m_pCapability->max_num_focus_areas = MAX_ROI;
4134     }
4135     set(KEY_MAX_NUM_FOCUS_AREAS, m_pCapability->max_num_focus_areas);
4136     if (m_pCapability->max_num_focus_areas > 0) {
4137         setFocusAreas(DEFAULT_CAMERA_AREA);
4138     }
4139 
4140     // Set metering areas
4141     if (m_pCapability->max_num_metering_areas > MAX_ROI) {
4142         m_pCapability->max_num_metering_areas = MAX_ROI;
4143     }
4144     set(KEY_MAX_NUM_METERING_AREAS, m_pCapability->max_num_metering_areas);
4145     if (m_pCapability->max_num_metering_areas > 0) {
4146         setMeteringAreas(DEFAULT_CAMERA_AREA);
4147     }
4148 
4149     // Set Saturation
4150     set(KEY_QC_MIN_SATURATION, m_pCapability->saturation_ctrl.min_value);
4151     set(KEY_QC_MAX_SATURATION, m_pCapability->saturation_ctrl.max_value);
4152     set(KEY_QC_SATURATION_STEP, m_pCapability->saturation_ctrl.step);
4153     setSaturation(m_pCapability->saturation_ctrl.def_value);
4154 
4155     // Set Sharpness
4156     set(KEY_QC_MIN_SHARPNESS, m_pCapability->sharpness_ctrl.min_value);
4157     set(KEY_QC_MAX_SHARPNESS, m_pCapability->sharpness_ctrl.max_value);
4158     set(KEY_QC_SHARPNESS_STEP, m_pCapability->sharpness_ctrl.step);
4159     setSharpness(m_pCapability->sharpness_ctrl.def_value);
4160 
4161     // Set Contrast
4162     set(KEY_QC_MIN_CONTRAST, m_pCapability->contrast_ctrl.min_value);
4163     set(KEY_QC_MAX_CONTRAST, m_pCapability->contrast_ctrl.max_value);
4164     set(KEY_QC_CONTRAST_STEP, m_pCapability->contrast_ctrl.step);
4165     setContrast(m_pCapability->contrast_ctrl.def_value);
4166 
4167     // Set SCE factor
4168     set(KEY_QC_MIN_SCE_FACTOR, m_pCapability->sce_ctrl.min_value); // -100
4169     set(KEY_QC_MAX_SCE_FACTOR, m_pCapability->sce_ctrl.max_value); // 100
4170     set(KEY_QC_SCE_FACTOR_STEP, m_pCapability->sce_ctrl.step);     // 10
4171     setSkinToneEnhancement(m_pCapability->sce_ctrl.def_value);     // 0
4172 
4173     // Set Brightness
4174     set(KEY_QC_MIN_BRIGHTNESS, m_pCapability->brightness_ctrl.min_value); // 0
4175     set(KEY_QC_MAX_BRIGHTNESS, m_pCapability->brightness_ctrl.max_value); // 6
4176     set(KEY_QC_BRIGHTNESS_STEP, m_pCapability->brightness_ctrl.step);     // 1
4177     setBrightness(m_pCapability->brightness_ctrl.def_value);
4178 
4179     // Set Auto exposure
4180     String8 autoExposureValues = createValuesString(
4181             (int *)m_pCapability->supported_aec_modes,
4182             m_pCapability->supported_aec_modes_cnt,
4183             AUTO_EXPOSURE_MAP,
4184             sizeof(AUTO_EXPOSURE_MAP) / sizeof(QCameraMap));
4185     set(KEY_QC_SUPPORTED_AUTO_EXPOSURE, autoExposureValues.string());
4186     setAutoExposure(AUTO_EXPOSURE_FRAME_AVG);
4187 
4188     // Set Exposure Compensation
4189     set(KEY_MAX_EXPOSURE_COMPENSATION, m_pCapability->exposure_compensation_max); // 12
4190     set(KEY_MIN_EXPOSURE_COMPENSATION, m_pCapability->exposure_compensation_min); // -12
4191     setFloat(KEY_EXPOSURE_COMPENSATION_STEP, m_pCapability->exposure_compensation_step); // 1/6
4192     setExposureCompensation(m_pCapability->exposure_compensation_default); // 0
4193 
4194     // Set Antibanding
4195     String8 antibandingValues = createValuesString(
4196             (int *)m_pCapability->supported_antibandings,
4197             m_pCapability->supported_antibandings_cnt,
4198             ANTIBANDING_MODES_MAP,
4199             sizeof(ANTIBANDING_MODES_MAP) / sizeof(QCameraMap));
4200     set(KEY_SUPPORTED_ANTIBANDING, antibandingValues);
4201     setAntibanding(ANTIBANDING_OFF);
4202 
4203     // Set Effect
4204     String8 effectValues = createValuesString(
4205             (int *)m_pCapability->supported_effects,
4206             m_pCapability->supported_effects_cnt,
4207             EFFECT_MODES_MAP,
4208             sizeof(EFFECT_MODES_MAP) / sizeof(QCameraMap));
4209     set(KEY_SUPPORTED_EFFECTS, effectValues);
4210     setEffect(EFFECT_NONE);
4211 
4212     // Set WhiteBalance
4213     String8 whitebalanceValues = createValuesString(
4214             (int *)m_pCapability->supported_white_balances,
4215             m_pCapability->supported_white_balances_cnt,
4216             WHITE_BALANCE_MODES_MAP,
4217             sizeof(WHITE_BALANCE_MODES_MAP) / sizeof(QCameraMap));
4218     set(KEY_SUPPORTED_WHITE_BALANCE, whitebalanceValues);
4219     setWhiteBalance(WHITE_BALANCE_AUTO);
4220 
4221     // Set Flash mode
4222     if(m_pCapability->supported_flash_modes_cnt > 0) {
4223        String8 flashValues = createValuesString(
4224                (int *)m_pCapability->supported_flash_modes,
4225                m_pCapability->supported_flash_modes_cnt,
4226                FLASH_MODES_MAP,
4227                sizeof(FLASH_MODES_MAP) / sizeof(QCameraMap));
4228        set(KEY_SUPPORTED_FLASH_MODES, flashValues);
4229        setFlash(FLASH_MODE_OFF);
4230     } else {
4231         ALOGE("%s: supported flash modes cnt is 0!!!", __func__);
4232     }
4233 
4234     // Set Scene Mode
4235     String8 sceneModeValues = createValuesString(
4236             (int *)m_pCapability->supported_scene_modes,
4237             m_pCapability->supported_scene_modes_cnt,
4238             SCENE_MODES_MAP,
4239             sizeof(SCENE_MODES_MAP) / sizeof(QCameraMap));
4240     set(KEY_SUPPORTED_SCENE_MODES, sceneModeValues);
4241     setSceneMode(SCENE_MODE_AUTO);
4242 
4243     // Set ISO Mode
4244     String8 isoValues = createValuesString(
4245             (int *)m_pCapability->supported_iso_modes,
4246             m_pCapability->supported_iso_modes_cnt,
4247             ISO_MODES_MAP,
4248             sizeof(ISO_MODES_MAP) / sizeof(QCameraMap));
4249     set(KEY_QC_SUPPORTED_ISO_MODES, isoValues);
4250     setISOValue(ISO_AUTO);
4251 
4252     // Set HFR
4253     String8 hfrValues = createHfrValuesString(
4254             m_pCapability->hfr_tbl,
4255             m_pCapability->hfr_tbl_cnt,
4256             HFR_MODES_MAP,
4257             sizeof(HFR_MODES_MAP) / sizeof(QCameraMap));
4258     set(KEY_QC_SUPPORTED_VIDEO_HIGH_FRAME_RATE_MODES, hfrValues.string());
4259     set(KEY_QC_VIDEO_HIGH_SPEED_RECORDING, "off");
4260     String8 hfrSizeValues = createHfrSizesString(
4261             m_pCapability->hfr_tbl,
4262             m_pCapability->hfr_tbl_cnt);
4263     set(KEY_QC_SUPPORTED_HFR_SIZES, hfrSizeValues.string());
4264     setHighFrameRate(VIDEO_HFR_OFF);
4265 
4266     // Set Focus algorithms
4267     String8 focusAlgoValues = createValuesString(
4268             (int *)m_pCapability->supported_focus_algos,
4269             m_pCapability->supported_focus_algos_cnt,
4270             FOCUS_ALGO_MAP,
4271             sizeof(FOCUS_ALGO_MAP) / sizeof(QCameraMap));
4272     set(KEY_QC_SUPPORTED_FOCUS_ALGOS, focusAlgoValues);
4273     setSelectableZoneAf(FOCUS_ALGO_AUTO);
4274 
4275     // Set Zoom Ratios
4276     if (m_pCapability->zoom_supported > 0) {
4277         String8 zoomRatioValues = createZoomRatioValuesString(
4278                 m_pCapability->zoom_ratio_tbl,
4279                 m_pCapability->zoom_ratio_tbl_cnt);
4280         set(KEY_ZOOM_RATIOS, zoomRatioValues);
4281         set(KEY_MAX_ZOOM, m_pCapability->zoom_ratio_tbl_cnt - 1);
4282         setZoom(0);
4283     }
4284 
4285     // Set Bracketing/HDR
4286     char prop[PROPERTY_VALUE_MAX];
4287     memset(prop, 0, sizeof(prop));
4288     property_get("persist.capture.burst.exposures", prop, "");
4289     if (strlen(prop) > 0) {
4290         set(KEY_QC_CAPTURE_BURST_EXPOSURE, prop);
4291     }
4292     String8 bracketingValues = createValuesStringFromMap(
4293             BRACKETING_MODES_MAP,
4294             sizeof(BRACKETING_MODES_MAP) / sizeof(QCameraMap));
4295     set(KEY_QC_SUPPORTED_AE_BRACKET_MODES, bracketingValues);
4296     setAEBracket(AE_BRACKET_OFF);
4297 
4298     //Set AF Bracketing.
4299     for(int i = 0; i < m_pCapability->supported_focus_modes_cnt; i++) {
4300         if ((CAM_FOCUS_MODE_AUTO == m_pCapability->supported_focus_modes[i]) &&
4301                 ((m_pCapability->qcom_supported_feature_mask &
4302                         CAM_QCOM_FEATURE_UBIFOCUS) > 0)) {
4303             String8 afBracketingValues = createValuesStringFromMap(
4304                     AF_BRACKETING_MODES_MAP,
4305                     sizeof(AF_BRACKETING_MODES_MAP) / sizeof(QCameraMap));
4306             set(KEY_QC_SUPPORTED_AF_BRACKET_MODES, afBracketingValues);
4307             setAFBracket(AF_BRACKET_OFF);
4308             break;
4309          }
4310     }
4311 
4312     //Set Refocus.
4313     //Re-use ubifocus flag for now.
4314     if ((m_pCapability->qcom_supported_feature_mask &
4315         CAM_QCOM_FEATURE_UBIFOCUS) > 0){
4316             String8 reFocusValues = createValuesStringFromMap(
4317                 RE_FOCUS_MODES_MAP,
4318                 sizeof(RE_FOCUS_MODES_MAP) / sizeof(QCameraMap));
4319             set(KEY_QC_SUPPORTED_RE_FOCUS_MODES, reFocusValues);
4320     }
4321 
4322     //Set Chroma Flash.
4323     if ((m_pCapability->supported_flash_modes_cnt > 0) &&
4324             (m_pCapability->qcom_supported_feature_mask &
4325             CAM_QCOM_FEATURE_CHROMA_FLASH) > 0) {
4326         String8 chromaFlashValues = createValuesStringFromMap(
4327                 CHROMA_FLASH_MODES_MAP,
4328                 sizeof(CHROMA_FLASH_MODES_MAP) / sizeof(QCameraMap));
4329         set(KEY_QC_SUPPORTED_CHROMA_FLASH_MODES, chromaFlashValues);
4330         setChromaFlash(CHROMA_FLASH_OFF);
4331     }
4332 
4333     //Set Opti Zoom.
4334     if (m_pCapability->zoom_supported &&
4335             (m_pCapability->qcom_supported_feature_mask &
4336             CAM_QCOM_FEATURE_OPTIZOOM) > 0){
4337         String8 optiZoomValues = createValuesStringFromMap(
4338                 OPTI_ZOOM_MODES_MAP,
4339                 sizeof(OPTI_ZOOM_MODES_MAP) / sizeof(QCameraMap));
4340         set(KEY_QC_SUPPORTED_OPTI_ZOOM_MODES, optiZoomValues);
4341         setOptiZoom(OPTI_ZOOM_OFF);
4342     }
4343 
4344     // Set Denoise
4345     if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_DENOISE2D) > 0){
4346     String8 denoiseValues = createValuesStringFromMap(
4347        DENOISE_ON_OFF_MODES_MAP, sizeof(DENOISE_ON_OFF_MODES_MAP) / sizeof(QCameraMap));
4348     set(KEY_QC_SUPPORTED_DENOISE, denoiseValues.string());
4349 #ifdef DEFAULT_DENOISE_MODE_ON
4350     setWaveletDenoise(DENOISE_ON);
4351 #else
4352     setWaveletDenoise(DENOISE_OFF);
4353 #endif
4354     }
4355 
4356     // Set feature enable/disable
4357     String8 enableDisableValues = createValuesStringFromMap(
4358         ENABLE_DISABLE_MODES_MAP, sizeof(ENABLE_DISABLE_MODES_MAP) / sizeof(QCameraMap));
4359 
4360     // Set Lens Shading
4361     set(KEY_QC_SUPPORTED_LENSSHADE_MODES, enableDisableValues);
4362     setLensShadeValue(VALUE_ENABLE);
4363 
4364     // Set MCE
4365     set(KEY_QC_SUPPORTED_MEM_COLOR_ENHANCE_MODES, enableDisableValues);
4366     setMCEValue(VALUE_ENABLE);
4367 
4368     // Set DIS
4369     set(KEY_QC_SUPPORTED_DIS_MODES, enableDisableValues);
4370     setDISValue(VALUE_DISABLE);
4371 
4372     // Set Histogram
4373     set(KEY_QC_SUPPORTED_HISTOGRAM_MODES,
4374         m_pCapability->histogram_supported ? enableDisableValues : "");
4375     set(KEY_QC_HISTOGRAM, VALUE_DISABLE);
4376 
4377     //Set Red Eye Reduction
4378     set(KEY_QC_SUPPORTED_REDEYE_REDUCTION, enableDisableValues);
4379     setRedeyeReduction(VALUE_DISABLE);
4380 
4381     //Set SkinTone Enhancement
4382     set(KEY_QC_SUPPORTED_SKIN_TONE_ENHANCEMENT_MODES, enableDisableValues);
4383 
4384     // Set feature on/off
4385     String8 onOffValues = createValuesStringFromMap(
4386         ON_OFF_MODES_MAP, sizeof(ON_OFF_MODES_MAP) / sizeof(QCameraMap));
4387 
4388     //Set Scene Detection
4389     set(KEY_QC_SUPPORTED_SCENE_DETECT, onOffValues);
4390     setSceneDetect(VALUE_OFF);
4391     m_bHDREnabled = false;
4392     m_bHDR1xFrameEnabled = true;
4393 
4394     m_bHDRThumbnailProcessNeeded = false;
4395     m_bHDR1xExtraBufferNeeded = true;
4396     for (uint32_t i=0; i<m_pCapability->hdr_bracketing_setting.num_frames; i++) {
4397         if (0 == m_pCapability->hdr_bracketing_setting.exp_val.values[i]) {
4398             m_bHDR1xExtraBufferNeeded = false;
4399             break;
4400         }
4401     }
4402 
4403     // Set HDR output scaling
4404     char value[PROPERTY_VALUE_MAX];
4405 
4406     property_get("persist.camera.hdr.outcrop", value, VALUE_DISABLE);
4407     if (strncmp(VALUE_ENABLE, value, sizeof(VALUE_ENABLE))) {
4408       m_bHDROutputCropEnabled = false;
4409     } else {
4410       m_bHDROutputCropEnabled = true;
4411     }
4412 
4413     //Set Face Detection
4414     set(KEY_QC_SUPPORTED_FACE_DETECTION, onOffValues);
4415     set(KEY_QC_FACE_DETECTION, VALUE_OFF);
4416 
4417     //Set Face Recognition
4418     //set(KEY_QC_SUPPORTED_FACE_RECOGNITION, onOffValues);
4419     //set(KEY_QC_FACE_RECOGNITION, VALUE_OFF);
4420 
4421     //Set ZSL
4422     set(KEY_QC_SUPPORTED_ZSL_MODES, onOffValues);
4423 #ifdef DEFAULT_ZSL_MODE_ON
4424     set(KEY_QC_ZSL, VALUE_ON);
4425     m_bZslMode = true;
4426 #else
4427     set(KEY_QC_ZSL, VALUE_OFF);
4428     m_bZslMode = false;
4429 #endif
4430     m_bZslMode_new = m_bZslMode;
4431 
4432     set(KEY_QC_SCENE_SELECTION, VALUE_DISABLE);
4433 
4434     // Rdi mode
4435     set(KEY_QC_SUPPORTED_RDI_MODES, enableDisableValues);
4436     setRdiMode(VALUE_DISABLE);
4437 
4438     // Secure mode
4439     set(KEY_QC_SUPPORTED_SECURE_MODES, enableDisableValues);
4440     setSecureMode(VALUE_DISABLE);
4441 
4442     //Set video HDR
4443     if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_VIDEO_HDR) > 0) {
4444         set(KEY_QC_SUPPORTED_VIDEO_HDR_MODES, onOffValues);
4445         set(KEY_QC_VIDEO_HDR, VALUE_OFF);
4446     }
4447 
4448     //Set HW Sensor Snapshot HDR
4449     if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_SENSOR_HDR)> 0) {
4450         set(KEY_QC_SUPPORTED_SENSOR_HDR_MODES, onOffValues);
4451         set(KEY_QC_SENSOR_HDR, VALUE_OFF);
4452         m_bSensorHDREnabled = false;
4453     }
4454 
4455     // Set VT TimeStamp
4456     set(KEY_QC_VT_ENABLE, VALUE_DISABLE);
4457     //Set Touch AF/AEC
4458     String8 touchValues = createValuesStringFromMap(
4459        TOUCH_AF_AEC_MODES_MAP, sizeof(TOUCH_AF_AEC_MODES_MAP) / sizeof(QCameraMap));
4460 
4461     set(KEY_QC_SUPPORTED_TOUCH_AF_AEC, touchValues);
4462     set(KEY_QC_TOUCH_AF_AEC, TOUCH_AF_AEC_OFF);
4463 
4464     //set flip mode
4465     if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_FLIP) > 0) {
4466         String8 flipModes = createValuesStringFromMap(
4467            FLIP_MODES_MAP, sizeof(FLIP_MODES_MAP) / sizeof(QCameraMap));
4468         set(KEY_QC_SUPPORTED_FLIP_MODES, flipModes);
4469         set(KEY_QC_PREVIEW_FLIP, FLIP_MODE_OFF);
4470         set(KEY_QC_VIDEO_FLIP, FLIP_MODE_OFF);
4471         set(KEY_QC_SNAPSHOT_PICTURE_FLIP, FLIP_MODE_OFF);
4472     }
4473 
4474     // Set default Auto Exposure lock value
4475     setAecLock(VALUE_FALSE);
4476 
4477     // Set default AWB_LOCK lock value
4478     setAwbLock(VALUE_FALSE);
4479 
4480     // Set default Camera mode
4481     set(KEY_QC_CAMERA_MODE, 0);
4482 
4483     // Add support for internal preview restart
4484     set(KEY_INTERNAL_PERVIEW_RESTART, VALUE_TRUE);
4485     // Set default burst number
4486     set(KEY_QC_SNAPSHOT_BURST_NUM, 0);
4487     set(KEY_QC_NUM_RETRO_BURST_PER_SHUTTER, 0);
4488 
4489     int32_t rc = commitParameters();
4490     if (rc == NO_ERROR) {
4491         rc = setNumOfSnapshot();
4492     }
4493     return rc;
4494 }
4495 
4496 /*===========================================================================
4497  * FUNCTION   : init
4498  *
4499  * DESCRIPTION: initialize parameter obj
4500  *
4501  * PARAMETERS :
4502  *   @capabilities  : ptr to camera capabilities
4503  *   @mmops         : ptr to memory ops table for mapping/unmapping
4504  *
4505  * RETURN     : int32_t type of status
4506  *              NO_ERROR  -- success
4507  *              none-zero failure code
4508  *==========================================================================*/
init(cam_capability_t * capabilities,mm_camera_vtbl_t * mmOps,QCameraAdjustFPS * adjustFPS,QCameraTorchInterface * torch)4509 int32_t QCameraParameters::init(cam_capability_t *capabilities,
4510                                 mm_camera_vtbl_t *mmOps,
4511                                 QCameraAdjustFPS *adjustFPS,
4512                                 QCameraTorchInterface *torch)
4513 {
4514     int32_t rc = NO_ERROR;
4515 
4516     m_pCapability = capabilities;
4517     m_pCamOpsTbl = mmOps;
4518     m_AdjustFPS = adjustFPS;
4519     m_pTorch = torch;
4520 
4521     //Allocate Set Param Buffer
4522     m_pParamHeap = new QCameraHeapMemory(QCAMERA_ION_USE_CACHE);
4523     rc = m_pParamHeap->allocate(1, sizeof(parm_buffer_t), NON_SECURE);
4524     if(rc != OK) {
4525         rc = NO_MEMORY;
4526         ALOGE("Failed to allocate SETPARM Heap memory");
4527         goto TRANS_INIT_ERROR1;
4528     }
4529 
4530     //Map memory for parameters buffer
4531     rc = m_pCamOpsTbl->ops->map_buf(m_pCamOpsTbl->camera_handle,
4532                              CAM_MAPPING_BUF_TYPE_PARM_BUF,
4533                              m_pParamHeap->getFd(0),
4534                              sizeof(parm_buffer_t));
4535     if(rc < 0) {
4536         ALOGE("%s:failed to map SETPARM buffer",__func__);
4537         rc = FAILED_TRANSACTION;
4538         goto TRANS_INIT_ERROR2;
4539     }
4540     m_pParamBuf = (parm_buffer_t*) DATA_PTR(m_pParamHeap,0);
4541 
4542     initDefaultParameters();
4543 
4544     m_bInited = true;
4545 
4546     goto TRANS_INIT_DONE;
4547 
4548 TRANS_INIT_ERROR2:
4549     m_pParamHeap->deallocate();
4550 
4551 TRANS_INIT_ERROR1:
4552     delete m_pParamHeap;
4553     m_pParamHeap = NULL;
4554 
4555 TRANS_INIT_DONE:
4556     return rc;
4557 }
4558 
4559 /*===========================================================================
4560  * FUNCTION   : deinit
4561  *
4562  * DESCRIPTION: deinitialize
4563  *
4564  * PARAMETERS : none
4565  *
4566  * RETURN     : none
4567  *==========================================================================*/
deinit()4568 void QCameraParameters::deinit()
4569 {
4570     if (!m_bInited) {
4571         return;
4572     }
4573 
4574     //clear all entries in the map
4575     String8 emptyStr;
4576     QCameraParameters::unflatten(emptyStr);
4577 
4578     if (NULL != m_pCamOpsTbl) {
4579         m_pCamOpsTbl->ops->unmap_buf(
4580                              m_pCamOpsTbl->camera_handle,
4581                              CAM_MAPPING_BUF_TYPE_PARM_BUF);
4582         m_pCamOpsTbl = NULL;
4583     }
4584     m_pCapability = NULL;
4585     if (NULL != m_pParamHeap) {
4586         m_pParamHeap->deallocate();
4587         delete m_pParamHeap;
4588         m_pParamHeap = NULL;
4589         m_pParamBuf = NULL;
4590     }
4591 
4592     m_AdjustFPS = NULL;
4593 
4594     m_tempMap.clear();
4595 
4596     m_bInited = false;
4597 }
4598 
4599 /*===========================================================================
4600  * FUNCTION   : parse_pair
4601  *
4602  * DESCRIPTION: helper function to parse string like "640x480" or "10000,20000"
4603  *
4604  * PARAMETERS :
4605  *   @str     : input string to be parse
4606  *   @first   : [output] first value of the pair
4607  *   @second  : [output]  second value of the pair
4608  *   @delim   : [input] delimeter to seperate the pair
4609  *   @endptr  : [output] ptr to the end of the pair string
4610  *
4611  * RETURN     : int32_t type of status
4612  *              NO_ERROR  -- success
4613  *              none-zero failure code
4614  *==========================================================================*/
parse_pair(const char * str,int * first,int * second,char delim,char ** endptr=NULL)4615 int32_t QCameraParameters::parse_pair(const char *str,
4616                                       int *first,
4617                                       int *second,
4618                                       char delim,
4619                                       char **endptr = NULL)
4620 {
4621     // Find the first integer.
4622     char *end;
4623     int w = (int)strtol(str, &end, 10);
4624     // If a delimeter does not immediately follow, give up.
4625     if (*end != delim) {
4626         ALOGE("Cannot find delimeter (%c) in str=%s", delim, str);
4627         return BAD_VALUE;
4628     }
4629 
4630     // Find the second integer, immediately after the delimeter.
4631     int h = (int)strtol(end+1, &end, 10);
4632 
4633     *first = w;
4634     *second = h;
4635 
4636     if (endptr) {
4637         *endptr = end;
4638     }
4639 
4640     return NO_ERROR;
4641 }
4642 
4643 /*===========================================================================
4644  * FUNCTION   : parseSizesList
4645  *
4646  * DESCRIPTION: helper function to parse string containing sizes
4647  *
4648  * PARAMETERS :
4649  *   @sizesStr: [input] input string to be parse
4650  *   @sizes   : [output] reference to store parsed sizes
4651  *
4652  * RETURN     : none
4653  *==========================================================================*/
parseSizesList(const char * sizesStr,Vector<Size> & sizes)4654 void QCameraParameters::parseSizesList(const char *sizesStr, Vector<Size> &sizes)
4655 {
4656     if (sizesStr == 0) {
4657         return;
4658     }
4659 
4660     char *sizeStartPtr = (char *)sizesStr;
4661 
4662     while (true) {
4663         int width, height;
4664         int success = parse_pair(sizeStartPtr, &width, &height, 'x',
4665                                  &sizeStartPtr);
4666         if (success == -1 || (*sizeStartPtr != ',' && *sizeStartPtr != '\0')) {
4667             ALOGE("Picture sizes string \"%s\" contains invalid character.", sizesStr);
4668             return;
4669         }
4670         sizes.push(Size(width, height));
4671 
4672         if (*sizeStartPtr == '\0') {
4673             return;
4674         }
4675         sizeStartPtr++;
4676     }
4677 }
4678 
4679 /*===========================================================================
4680  * FUNCTION   : getSupportedHfrSizes
4681  *
4682  * DESCRIPTION: return supported HFR sizes
4683  *
4684  * PARAMETERS :
4685  *   @sizes  : [output] reference to a vector storing supported HFR sizes
4686  *
4687  * RETURN     : none
4688  *==========================================================================*/
getSupportedHfrSizes(Vector<Size> & sizes)4689 void QCameraParameters::getSupportedHfrSizes(Vector<Size> &sizes)
4690 {
4691     const char *hfrSizesStr = get(KEY_QC_SUPPORTED_HFR_SIZES);
4692     parseSizesList(hfrSizesStr, sizes);
4693 }
4694 
4695 /*===========================================================================
4696  * FUNCTION   : adjustPreviewFpsRanges
4697  *
4698  * DESCRIPTION: adjust preview FPS ranges
4699  *              according to external events
4700  *
4701  * PARAMETERS :
4702  *   @minFPS  : min FPS value
4703  *   @maxFPS  : max FPS value
4704  *
4705  * RETURN     : int32_t type of status
4706  *              NO_ERROR  -- success
4707  *              none-zero failure code
4708  *==========================================================================*/
adjustPreviewFpsRange(cam_fps_range_t * fpsRange)4709 int32_t QCameraParameters::adjustPreviewFpsRange(cam_fps_range_t *fpsRange)
4710 {
4711     if ( fpsRange == NULL ) {
4712         return BAD_VALUE;
4713     }
4714 
4715     if ( m_pParamBuf == NULL ) {
4716         return NO_INIT;
4717     }
4718 
4719     int32_t rc = initBatchUpdate(m_pParamBuf);
4720     if ( rc != NO_ERROR ) {
4721         ALOGE("%s:Failed to initialize group update table", __func__);
4722         return rc;
4723     }
4724 
4725     rc = AddSetParmEntryToBatch(m_pParamBuf,
4726                                   CAM_INTF_PARM_FPS_RANGE,
4727                                   sizeof(cam_fps_range_t),
4728                                   fpsRange);
4729     if ( rc != NO_ERROR ) {
4730         ALOGE("%s: Parameters batch failed",__func__);
4731         return rc;
4732     }
4733 
4734     rc = commitSetBatch();
4735     if ( rc != NO_ERROR ) {
4736         ALOGE("%s:Failed to commit batch parameters", __func__);
4737         return rc;
4738     }
4739 
4740     return rc;
4741 }
4742 
4743 /*===========================================================================
4744  * FUNCTION   : setPreviewFpsRanges
4745  *
4746  * DESCRIPTION: set preview FPS ranges
4747  *
4748  * PARAMETERS :
4749  *   @minFPS  : min FPS value
4750  *   @maxFPS  : max FPS value
4751  *
4752  * RETURN     : int32_t type of status
4753  *              NO_ERROR  -- success
4754  *              none-zero failure code
4755  *==========================================================================*/
setPreviewFpsRange(int min_fps,int max_fps,int vid_min_fps,int vid_max_fps)4756 int32_t QCameraParameters::setPreviewFpsRange(int min_fps,
4757         int max_fps, int vid_min_fps,int vid_max_fps)
4758 {
4759     char str[32];
4760     char value[PROPERTY_VALUE_MAX];
4761     int fixedFpsValue;
4762     /*This property get value should be the fps that user needs*/
4763     property_get("persist.debug.set.fixedfps", value, "0");
4764     fixedFpsValue = atoi(value);
4765 
4766     CDBG_HIGH("%s: E minFps = %d, maxFps = %d , vid minFps = %d, vid maxFps = %d",
4767                 __func__, min_fps, max_fps, vid_min_fps, vid_max_fps);
4768 
4769     if(fixedFpsValue != 0) {
4770       min_fps = (int)fixedFpsValue*1000;
4771       max_fps = (int)fixedFpsValue*1000;
4772     }
4773     snprintf(str, sizeof(str), "%d,%d", min_fps, max_fps);
4774     CDBG_HIGH("%s: Setting preview fps range %s", __func__, str);
4775     updateParamEntry(KEY_PREVIEW_FPS_RANGE, str);
4776     cam_fps_range_t fps_range;
4777     memset(&fps_range, 0x00, sizeof(cam_fps_range_t));
4778     fps_range.min_fps = min_fps / float (1000.0);
4779     fps_range.max_fps = max_fps / float (1000.0);
4780     fps_range.video_min_fps = vid_min_fps / float (1000.0);
4781     fps_range.video_max_fps = vid_max_fps / float (1000.0);
4782 
4783 
4784     CDBG_HIGH("%s: Updated: minFps = %d, maxFps = %d ,"
4785             " vid minFps = %d, vid maxFps = %d",
4786             __func__, min_fps, max_fps, vid_min_fps, vid_max_fps);
4787 
4788     if ( NULL != m_AdjustFPS ) {
4789         m_AdjustFPS->recalcFPSRange(min_fps, max_fps, vid_min_fps, vid_max_fps);
4790         CDBG_HIGH("%s: Thermal adjusted preview fps range %d,%d, %d, %d",
4791               __func__,
4792               min_fps,
4793               max_fps, vid_min_fps, vid_max_fps);
4794         fps_range.min_fps = min_fps;
4795         fps_range.max_fps = max_fps;
4796         fps_range.video_min_fps = vid_min_fps;
4797         fps_range.video_max_fps = vid_max_fps;
4798 
4799     }
4800 
4801     return AddSetParmEntryToBatch(m_pParamBuf,
4802                                   CAM_INTF_PARM_FPS_RANGE,
4803                                   sizeof(cam_fps_range_t),
4804                                   &fps_range);
4805 }
4806 
4807 
4808 
4809 /*===========================================================================
4810  * FUNCTION   : setAutoExposure
4811  *
4812  * DESCRIPTION: set auto exposure
4813  *
4814  * PARAMETERS :
4815  *   @autoExp : auto exposure value string
4816  *
4817  * RETURN     : int32_t type of status
4818  *              NO_ERROR  -- success
4819  *              none-zero failure code
4820  *==========================================================================*/
setAutoExposure(const char * autoExp)4821 int32_t QCameraParameters::setAutoExposure(const char *autoExp)
4822 {
4823     if (autoExp != NULL) {
4824         int32_t value = lookupAttr(AUTO_EXPOSURE_MAP,
4825                                    sizeof(AUTO_EXPOSURE_MAP)/sizeof(AUTO_EXPOSURE_MAP[0]),
4826                                    autoExp);
4827         if (value != NAME_NOT_FOUND) {
4828             CDBG_HIGH("%s: Setting auto exposure %s", __func__, autoExp);
4829             updateParamEntry(KEY_QC_AUTO_EXPOSURE, autoExp);
4830             return AddSetParmEntryToBatch(m_pParamBuf,
4831                                           CAM_INTF_PARM_AEC_ALGO_TYPE,
4832                                           sizeof(value),
4833                                           &value);
4834         }
4835     }
4836     ALOGE("Invalid auto exposure value: %s", (autoExp == NULL) ? "NULL" : autoExp);
4837     return BAD_VALUE;
4838 }
4839 
4840 /*===========================================================================
4841  * FUNCTION   : setEffect
4842  *
4843  * DESCRIPTION: set effect
4844  *
4845  * PARAMETERS :
4846  *   @effect  : effect value string
4847  *
4848  * RETURN     : int32_t type of status
4849  *              NO_ERROR  -- success
4850  *              none-zero failure code
4851  *==========================================================================*/
setEffect(const char * effect)4852 int32_t QCameraParameters::setEffect(const char *effect)
4853 {
4854     if (effect != NULL) {
4855         int32_t value = lookupAttr(EFFECT_MODES_MAP,
4856                                    sizeof(EFFECT_MODES_MAP)/sizeof(QCameraMap),
4857                                    effect);
4858         if (value != NAME_NOT_FOUND) {
4859             CDBG_HIGH("%s: Setting effect %s", __func__, effect);
4860             updateParamEntry(KEY_EFFECT, effect);
4861             uint8_t prmEffect = static_cast<uint8_t>(value);
4862             return AddSetParmEntryToBatch(m_pParamBuf,
4863                                           CAM_INTF_PARM_EFFECT,
4864                                           sizeof(prmEffect),
4865                                           &prmEffect);
4866         }
4867     }
4868     ALOGE("Invalid effect value: %s", (effect == NULL) ? "NULL" : effect);
4869     return BAD_VALUE;
4870 }
4871 
4872 /*===========================================================================
4873  * FUNCTION   : setBrightness
4874  *
4875  * DESCRIPTION: set brightness control value
4876  *
4877  * PARAMETERS :
4878  *   @brightness  : brightness control value
4879  *
4880  * RETURN     : int32_t type of status
4881  *              NO_ERROR  -- success
4882  *              none-zero failure code
4883  *==========================================================================*/
setBrightness(int brightness)4884 int32_t QCameraParameters::setBrightness(int brightness)
4885 {
4886     char val[16];
4887     sprintf(val, "%d", brightness);
4888     updateParamEntry(KEY_QC_BRIGHTNESS, val);
4889 
4890     int32_t value = brightness;
4891     CDBG_HIGH("%s: Setting brightness %s", __func__, val);
4892     return AddSetParmEntryToBatch(m_pParamBuf,
4893                                   CAM_INTF_PARM_BRIGHTNESS,
4894                                   sizeof(value),
4895                                   &value);
4896 }
4897 
4898 /*===========================================================================
4899  * FUNCTION   : setFocusMode
4900  *
4901  * DESCRIPTION: set focus mode
4902  *
4903  * PARAMETERS :
4904  *   @focusMode  : focus mode value string
4905  *
4906  * RETURN     : int32_t type of status
4907  *              NO_ERROR  -- success
4908  *              none-zero failure code
4909  *==========================================================================*/
setFocusMode(const char * focusMode)4910 int32_t QCameraParameters::setFocusMode(const char *focusMode)
4911 {
4912     int32_t rc;
4913     if (focusMode != NULL) {
4914         int32_t value = lookupAttr(FOCUS_MODES_MAP,
4915                                    sizeof(FOCUS_MODES_MAP)/sizeof(QCameraMap),
4916                                    focusMode);
4917         if (value != NAME_NOT_FOUND) {
4918             CDBG_HIGH("%s: Setting focus mode %s", __func__, focusMode);
4919             uint8_t fm = (uint8_t)value;
4920             mFocusMode = (cam_focus_mode_type)value;
4921 
4922             updateParamEntry(KEY_FOCUS_MODE, focusMode);
4923             rc = AddSetParmEntryToBatch(m_pParamBuf,
4924                                           CAM_INTF_PARM_FOCUS_MODE,
4925                                           sizeof(fm),
4926                                           &fm);
4927             if (strcmp(focusMode,"infinity")==0){
4928                 set(QCameraParameters::KEY_FOCUS_DISTANCES, "Infinity,Infinity,Infinity");
4929             }
4930             return rc;
4931         }
4932     }
4933     ALOGE("Invalid focus mode value: %s", (focusMode == NULL) ? "NULL" : focusMode);
4934     return BAD_VALUE;
4935 }
4936 
4937 /*===========================================================================
4938  * FUNCTION   : setSharpness
4939  *
4940  * DESCRIPTION: set sharpness control value
4941  *
4942  * PARAMETERS :
4943  *   @sharpness  : sharpness control value
4944  *
4945  * RETURN     : int32_t type of status
4946  *              NO_ERROR  -- success
4947  *              none-zero failure code
4948  *==========================================================================*/
setSharpness(int sharpness)4949 int32_t QCameraParameters::setSharpness(int sharpness)
4950 {
4951     char val[16];
4952     sprintf(val, "%d", sharpness);
4953     updateParamEntry(KEY_QC_SHARPNESS, val);
4954     CDBG_HIGH("%s: Setting sharpness %s", __func__, val);
4955 
4956     int32_t value = sharpness;
4957     return AddSetParmEntryToBatch(m_pParamBuf,
4958                                   CAM_INTF_PARM_SHARPNESS,
4959                                   sizeof(value),
4960                                   &value);
4961 }
4962 
4963 /*===========================================================================
4964  * FUNCTION   : setSkinToneEnhancement
4965  *
4966  * DESCRIPTION: set skin tone enhancement value
4967  *
4968  * PARAMETERS :
4969  *   @sceFactore  : skin tone enhancement factor value
4970  *
4971  * RETURN     : int32_t type of status
4972  *              NO_ERROR  -- success
4973  *              none-zero failure code
4974  *==========================================================================*/
setSkinToneEnhancement(int sceFactor)4975 int32_t QCameraParameters::setSkinToneEnhancement(int sceFactor)
4976 {
4977     char val[16];
4978     sprintf(val, "%d", sceFactor);
4979     updateParamEntry(KEY_QC_SCE_FACTOR, val);
4980     CDBG_HIGH("%s: Setting skintone enhancement %s", __func__, val);
4981 
4982     int32_t value = sceFactor;
4983     return AddSetParmEntryToBatch(m_pParamBuf,
4984                                   CAM_INTF_PARM_SCE_FACTOR,
4985                                   sizeof(value),
4986                                   &value);
4987 }
4988 
4989 /*===========================================================================
4990  * FUNCTION   : setSaturation
4991  *
4992  * DESCRIPTION: set saturation control value
4993  *
4994  * PARAMETERS :
4995  *   @saturation : saturation control value
4996  *
4997  * RETURN     : int32_t type of status
4998  *              NO_ERROR  -- success
4999  *              none-zero failure code
5000  *==========================================================================*/
setSaturation(int saturation)5001 int32_t QCameraParameters::setSaturation(int saturation)
5002 {
5003     char val[16];
5004     sprintf(val, "%d", saturation);
5005     updateParamEntry(KEY_QC_SATURATION, val);
5006     CDBG_HIGH("%s: Setting saturation %s", __func__, val);
5007 
5008     int32_t value = saturation;
5009     return AddSetParmEntryToBatch(m_pParamBuf,
5010                                   CAM_INTF_PARM_SATURATION,
5011                                   sizeof(value),
5012                                   &value);
5013 }
5014 
5015 /*===========================================================================
5016  * FUNCTION   : setContrast
5017  *
5018  * DESCRIPTION: set contrast control value
5019  *
5020  * PARAMETERS :
5021  *   @contrast : contrast control value
5022  *
5023  * RETURN     : int32_t type of status
5024  *              NO_ERROR  -- success
5025  *              none-zero failure code
5026  *==========================================================================*/
setContrast(int contrast)5027 int32_t QCameraParameters::setContrast(int contrast)
5028 {
5029     char val[16];
5030     sprintf(val, "%d", contrast);
5031     updateParamEntry(KEY_QC_CONTRAST, val);
5032     CDBG_HIGH("%s: Setting contrast %s", __func__, val);
5033 
5034     int32_t value = contrast;
5035     return AddSetParmEntryToBatch(m_pParamBuf,
5036                                   CAM_INTF_PARM_CONTRAST,
5037                                   sizeof(value),
5038                                   &value);
5039 }
5040 
5041 /*===========================================================================
5042  * FUNCTION   : setSceneDetect
5043  *
5044  * DESCRIPTION: set scenen detect value
5045  *
5046  * PARAMETERS :
5047  *   @sceneDetect  : scene detect value string
5048  *
5049  * RETURN     : int32_t type of status
5050  *              NO_ERROR  -- success
5051  *              none-zero failure code
5052  *==========================================================================*/
setSceneDetect(const char * sceneDetect)5053 int32_t QCameraParameters::setSceneDetect(const char *sceneDetect)
5054 {
5055     if (sceneDetect != NULL) {
5056         int32_t value = lookupAttr(ON_OFF_MODES_MAP,
5057                                    sizeof(ON_OFF_MODES_MAP)/sizeof(QCameraMap),
5058                                    sceneDetect);
5059         if (value != NAME_NOT_FOUND) {
5060             CDBG_HIGH("%s: Setting Scene Detect %s", __func__, sceneDetect);
5061             updateParamEntry(KEY_QC_SCENE_DETECT, sceneDetect);
5062             return AddSetParmEntryToBatch(m_pParamBuf,
5063                                           CAM_INTF_PARM_ASD_ENABLE,
5064                                           sizeof(value),
5065                                           &value);
5066         }
5067     }
5068     ALOGE("Invalid Scene Detect value: %s",
5069           (sceneDetect == NULL) ? "NULL" : sceneDetect);
5070     return BAD_VALUE;
5071 }
5072 
5073 /*===========================================================================
5074  * FUNCTION   : setSensorSnapshotHDR
5075  *
5076  * DESCRIPTION: set snapshot HDR value
5077  *
5078  * PARAMETERS :
5079  *   @snapshotHDR  : snapshot HDR value string
5080  *
5081  * RETURN     : int32_t type of status
5082  *              NO_ERROR  -- success
5083  *              none-zero failure code
5084  *==========================================================================*/
setSensorSnapshotHDR(const char * snapshotHDR)5085 int32_t QCameraParameters::setSensorSnapshotHDR(const char *snapshotHDR)
5086 {
5087     if (snapshotHDR != NULL) {
5088         int32_t value = lookupAttr(ON_OFF_MODES_MAP,
5089                                    sizeof(ON_OFF_MODES_MAP)/sizeof(QCameraMap),
5090                                    snapshotHDR);
5091         if (value != NAME_NOT_FOUND) {
5092             CDBG_HIGH("%s: Setting Sensor Snapshot HDR %s", __func__, snapshotHDR);
5093             updateParamEntry(KEY_QC_SENSOR_HDR, snapshotHDR);
5094             return AddSetParmEntryToBatch(m_pParamBuf,
5095                                           CAM_INTF_PARM_SENSOR_HDR,
5096                                           sizeof(value),
5097                                           &value);
5098         }
5099     }
5100     ALOGE("Invalid Snapshot HDR value: %s",
5101           (snapshotHDR == NULL) ? "NULL" : snapshotHDR);
5102     return BAD_VALUE;
5103 
5104 }
5105 
5106 
5107 /*===========================================================================
5108  * FUNCTION   : setVideoHDR
5109  *
5110  * DESCRIPTION: set video HDR value
5111  *
5112  * PARAMETERS :
5113  *   @videoHDR  : svideo HDR value string
5114  *
5115  * RETURN     : int32_t type of status
5116  *              NO_ERROR  -- success
5117  *              none-zero failure code
5118  *==========================================================================*/
setVideoHDR(const char * videoHDR)5119 int32_t QCameraParameters::setVideoHDR(const char *videoHDR)
5120 {
5121     if (videoHDR != NULL) {
5122         int32_t value = lookupAttr(ON_OFF_MODES_MAP,
5123                                    sizeof(ON_OFF_MODES_MAP)/sizeof(QCameraMap),
5124                                    videoHDR);
5125         if (value != NAME_NOT_FOUND) {
5126             CDBG_HIGH("%s: Setting Video HDR %s", __func__, videoHDR);
5127             updateParamEntry(KEY_QC_VIDEO_HDR, videoHDR);
5128             return AddSetParmEntryToBatch(m_pParamBuf,
5129                                           CAM_INTF_PARM_VIDEO_HDR,
5130                                           sizeof(value),
5131                                           &value);
5132         }
5133     }
5134     ALOGE("Invalid Video HDR value: %s",
5135           (videoHDR == NULL) ? "NULL" : videoHDR);
5136     return BAD_VALUE;
5137 }
5138 
5139 
5140 
5141 /*===========================================================================
5142  * FUNCTION   : setVtEnable
5143  *
5144  * DESCRIPTION: set vt Enable value
5145  *
5146  * PARAMETERS :
5147  *   @videoHDR  : svtEnable value string
5148  *
5149  * RETURN     : int32_t type of status
5150  *              NO_ERROR  -- success
5151  *              none-zero failure code
5152  *==========================================================================*/
setVtEnable(const char * vtEnable)5153 int32_t QCameraParameters::setVtEnable(const char *vtEnable)
5154 {
5155     if (vtEnable != NULL) {
5156         int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP,
5157                                    sizeof(ENABLE_DISABLE_MODES_MAP)/sizeof(QCameraMap),
5158                                    vtEnable);
5159         if (value != NAME_NOT_FOUND) {
5160             CDBG_HIGH("%s: Setting Vt Enable %s", __func__, vtEnable);
5161             m_bAVTimerEnabled = true;
5162             updateParamEntry(KEY_QC_VT_ENABLE, vtEnable);
5163             return AddSetParmEntryToBatch(m_pParamBuf,
5164                                           CAM_INTF_PARM_VT,
5165                                           sizeof(value),
5166                                           &value);
5167         }
5168     }
5169     ALOGE("Invalid Vt Enable value: %s",
5170           (vtEnable == NULL) ? "NULL" : vtEnable);
5171     m_bAVTimerEnabled = false;
5172     return BAD_VALUE;
5173 }
5174 
5175 /*===========================================================================
5176  * FUNCTION   : setFaceRecognition
5177  *
5178  * DESCRIPTION: set face recognition value
5179  *
5180  * PARAMETERS :
5181  *   @faceRecog  : face recognition value string
5182  *   @maxFaces   : number of max faces to be detected/recognized
5183  *
5184  * RETURN     : int32_t type of status
5185  *              NO_ERROR  -- success
5186  *              none-zero failure code
5187  *==========================================================================*/
setFaceRecognition(const char * faceRecog,int maxFaces)5188 int32_t QCameraParameters::setFaceRecognition(const char *faceRecog, int maxFaces)
5189 {
5190     if (faceRecog != NULL) {
5191         int32_t value = lookupAttr(ON_OFF_MODES_MAP,
5192                                    sizeof(ON_OFF_MODES_MAP)/sizeof(QCameraMap),
5193                                    faceRecog);
5194         if (value != NAME_NOT_FOUND) {
5195             CDBG_HIGH("%s: Setting face recognition %s", __func__, faceRecog);
5196             updateParamEntry(KEY_QC_FACE_RECOGNITION, faceRecog);
5197 
5198             int faceProcMask = m_nFaceProcMask;
5199             if (value > 0) {
5200                 faceProcMask |= CAM_FACE_PROCESS_MASK_RECOGNITION;
5201             } else {
5202                 faceProcMask &= ~CAM_FACE_PROCESS_MASK_RECOGNITION;
5203             }
5204 
5205             if(m_nFaceProcMask == faceProcMask) {
5206                 CDBG_HIGH("%s: face process mask not changed, no ops here", __func__);
5207                 return NO_ERROR;
5208             }
5209             m_nFaceProcMask = faceProcMask;
5210             CDBG_HIGH("%s: FaceProcMask -> %d", __func__, m_nFaceProcMask);
5211 
5212             // set parm for face process
5213             cam_fd_set_parm_t fd_set_parm;
5214             memset(&fd_set_parm, 0, sizeof(cam_fd_set_parm_t));
5215             fd_set_parm.fd_mode = m_nFaceProcMask;
5216             fd_set_parm.num_fd = maxFaces;
5217 
5218             return AddSetParmEntryToBatch(m_pParamBuf,
5219                                         CAM_INTF_PARM_FD,
5220                                         sizeof(fd_set_parm),
5221                                         &fd_set_parm);
5222         }
5223     }
5224     ALOGE("Invalid face recognition value: %s", (faceRecog == NULL) ? "NULL" : faceRecog);
5225     return BAD_VALUE;
5226 }
5227 
5228 /*===========================================================================
5229  * FUNCTION   : setZoom
5230  *
5231  * DESCRIPTION: set zoom level
5232  *
5233  * PARAMETERS :
5234  *   @zoom_level : zoom level
5235  *
5236  * RETURN     : int32_t type of status
5237  *              NO_ERROR  -- success
5238  *              none-zero failure code
5239  *==========================================================================*/
setZoom(int zoom_level)5240 int32_t QCameraParameters::setZoom(int zoom_level)
5241 {
5242     char val[16];
5243     sprintf(val, "%d", zoom_level);
5244     updateParamEntry(KEY_ZOOM, val);
5245 
5246     return AddSetParmEntryToBatch(m_pParamBuf,
5247                                   CAM_INTF_PARM_ZOOM,
5248                                   sizeof(zoom_level),
5249                                   &zoom_level);
5250 }
5251 
5252 /*===========================================================================
5253  * FUNCTION   : setISOValue
5254  *
5255  * DESCRIPTION: set ISO value
5256  *
5257  * PARAMETERS :
5258  *   @isoValue : ISO value string
5259  *
5260  * RETURN     : int32_t type of status
5261  *              NO_ERROR  -- success
5262  *              none-zero failure code
5263  *==========================================================================*/
setISOValue(const char * isoValue)5264 int32_t  QCameraParameters::setISOValue(const char *isoValue)
5265 {
5266     if (isoValue != NULL) {
5267         int32_t value = lookupAttr(ISO_MODES_MAP,
5268                                    sizeof(ISO_MODES_MAP)/sizeof(QCameraMap),
5269                                    isoValue);
5270         if (value != NAME_NOT_FOUND) {
5271             CDBG_HIGH("%s: Setting ISO value %s", __func__, isoValue);
5272             updateParamEntry(KEY_QC_ISO_MODE, isoValue);
5273             return AddSetParmEntryToBatch(m_pParamBuf,
5274                                           CAM_INTF_PARM_ISO,
5275                                           sizeof(value),
5276                                           &value);
5277         }
5278     }
5279     ALOGE("Invalid ISO value: %s",
5280           (isoValue == NULL) ? "NULL" : isoValue);
5281     return BAD_VALUE;
5282 }
5283 
5284 /*===========================================================================
5285  * FUNCTION   : setLongshotEnable
5286  *
5287  * DESCRIPTION: set a flag indicating longshot mode
5288  *
5289  * PARAMETERS :
5290  *   @enable  : true - Longshot enabled
5291  *              false - Longshot disabled
5292  *
5293  * RETURN     : int32_t type of status
5294  *              NO_ERROR  -- success
5295  *              none-zero failure code
5296  *==========================================================================*/
setLongshotEnable(bool enable)5297 int32_t QCameraParameters::setLongshotEnable(bool enable)
5298 {
5299     int32_t rc = NO_ERROR;
5300     int8_t value = enable;
5301 
5302     if(initBatchUpdate(m_pParamBuf) < 0 ) {
5303         ALOGE("%s:Failed to initialize group update table", __func__);
5304         return BAD_TYPE;
5305     }
5306 
5307     rc = AddSetParmEntryToBatch(m_pParamBuf,
5308           CAM_INTF_PARM_LONGSHOT_ENABLE,
5309           sizeof(value),
5310           &value);
5311     if (rc != NO_ERROR) {
5312         ALOGE("%s:Failed to update table", __func__);
5313         return rc;
5314     }
5315 
5316     rc = commitSetBatch();
5317     if (rc != NO_ERROR) {
5318         ALOGE("%s:Failed to parameter changes", __func__);
5319         return rc;
5320     }
5321 
5322     return rc;
5323 }
5324 
5325 /*===========================================================================
5326  * FUNCTION   : setFlash
5327  *
5328  * DESCRIPTION: set flash mode
5329  *
5330  * PARAMETERS :
5331  *   @flashStr : LED flash mode value string
5332  *
5333  * RETURN     : int32_t type of status
5334  *              NO_ERROR  -- success
5335  *              none-zero failure code
5336  *==========================================================================*/
setFlash(const char * flashStr)5337 int32_t QCameraParameters::setFlash(const char *flashStr)
5338 {
5339     if (flashStr != NULL) {
5340         int32_t value = lookupAttr(FLASH_MODES_MAP,
5341                                    sizeof(FLASH_MODES_MAP)/sizeof(QCameraMap),
5342                                    flashStr);
5343         if (value != NAME_NOT_FOUND) {
5344             CDBG_HIGH("%s: Setting Flash value %s", __func__, flashStr);
5345 
5346             if (NULL != m_pTorch && !m_bRecordingHint_new) {
5347                 if ( value == CAM_FLASH_MODE_TORCH ) {
5348                     m_pTorch->prepareTorchCamera();
5349                 } else {
5350                     m_bReleaseTorchCamera = true;
5351                 }
5352             }
5353 
5354             updateParamEntry(KEY_FLASH_MODE, flashStr);
5355             mFlashValue = value;
5356             return NO_ERROR;
5357         }
5358     }
5359     ALOGE("Invalid flash value: %s", (flashStr == NULL) ? "NULL" : flashStr);
5360     return BAD_VALUE;
5361 }
5362 
5363 /*===========================================================================
5364  * FUNCTION   : setAecLock
5365  *
5366  * DESCRIPTION: set AEC lock value
5367  *
5368  * PARAMETERS :
5369  *   @aecLockStr : AEC lock value string
5370  *
5371  * RETURN     : int32_t type of status
5372  *              NO_ERROR  -- success
5373  *              none-zero failure code
5374  *==========================================================================*/
setAecLock(const char * aecLockStr)5375 int32_t QCameraParameters::setAecLock(const char *aecLockStr)
5376 {
5377     if (aecLockStr != NULL) {
5378         int32_t value = lookupAttr(TRUE_FALSE_MODES_MAP,
5379                                   sizeof(TRUE_FALSE_MODES_MAP)/
5380                                       sizeof(QCameraMap),
5381                                   aecLockStr);
5382         if (value != NAME_NOT_FOUND) {
5383             CDBG_HIGH("%s: Setting AECLock value %s", __func__, aecLockStr);
5384             updateParamEntry(KEY_AUTO_EXPOSURE_LOCK, aecLockStr);
5385             return AddSetParmEntryToBatch(m_pParamBuf,
5386                                           CAM_INTF_PARM_AEC_LOCK,
5387                                           sizeof(value),
5388                                           &value);
5389         }
5390     }
5391     ALOGE("Invalid AECLock value: %s",
5392         (aecLockStr == NULL) ? "NULL" : aecLockStr);
5393     return BAD_VALUE;
5394 }
5395 
5396 /*===========================================================================
5397  * FUNCTION   : setAwbLock
5398  *
5399  * DESCRIPTION: set AWB lock value
5400  *
5401  * PARAMETERS :
5402  *   @awbLockStr : AWB lock value string
5403  *
5404  * RETURN     : int32_t type of status
5405  *              NO_ERROR  -- success
5406  *              none-zero failure code
5407  *==========================================================================*/
setAwbLock(const char * awbLockStr)5408 int32_t QCameraParameters::setAwbLock(const char *awbLockStr)
5409 {
5410     if (awbLockStr != NULL) {
5411         int32_t value = lookupAttr(TRUE_FALSE_MODES_MAP,
5412                                    sizeof(TRUE_FALSE_MODES_MAP)/sizeof(QCameraMap),
5413                                    awbLockStr);
5414         if (value != NAME_NOT_FOUND) {
5415             CDBG_HIGH("%s: Setting AWBLock value %s", __func__, awbLockStr);
5416             updateParamEntry(KEY_AUTO_WHITEBALANCE_LOCK, awbLockStr);
5417             return AddSetParmEntryToBatch(m_pParamBuf,
5418                                           CAM_INTF_PARM_AWB_LOCK,
5419                                           sizeof(value),
5420                                           &value);
5421         }
5422     }
5423     ALOGE("Invalid AWBLock value: %s", (awbLockStr == NULL) ? "NULL" : awbLockStr);
5424     return BAD_VALUE;
5425 }
5426 
5427 /*===========================================================================
5428  * FUNCTION   : setMCEValue
5429  *
5430  * DESCRIPTION: set memory color enhancement value
5431  *
5432  * PARAMETERS :
5433  *   @mceStr : MCE value string
5434  *
5435  * RETURN     : int32_t type of status
5436  *              NO_ERROR  -- success
5437  *              none-zero failure code
5438  *==========================================================================*/
setMCEValue(const char * mceStr)5439 int32_t QCameraParameters::setMCEValue(const char *mceStr)
5440 {
5441     if (mceStr != NULL) {
5442         int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP,
5443                                    sizeof(ENABLE_DISABLE_MODES_MAP)/sizeof(QCameraMap),
5444                                    mceStr);
5445         if (value != NAME_NOT_FOUND) {
5446             CDBG_HIGH("%s: Setting AWBLock value %s", __func__, mceStr);
5447             updateParamEntry(KEY_QC_MEMORY_COLOR_ENHANCEMENT, mceStr);
5448             return AddSetParmEntryToBatch(m_pParamBuf,
5449                                           CAM_INTF_PARM_MCE,
5450                                           sizeof(value),
5451                                           &value);
5452         }
5453     }
5454     ALOGE("Invalid MCE value: %s", (mceStr == NULL) ? "NULL" : mceStr);
5455     return BAD_VALUE;
5456 }
5457 
5458 /*===========================================================================
5459  * FUNCTION   : setTintlessValue
5460  *
5461  * DESCRIPTION: enable/disable tintless from user setting
5462  *
5463  * PARAMETERS :
5464  *   @params  : user setting parameters
5465  *
5466  * RETURN     : int32_t type of status
5467  *              NO_ERROR  -- success
5468  *              none-zero failure code
5469  *==========================================================================*/
setTintlessValue(const QCameraParameters & params)5470 int32_t QCameraParameters::setTintlessValue(const QCameraParameters& params)
5471 {
5472     const char *str = params.get(KEY_QC_TINTLESS_ENABLE);
5473     const char *prev_str = get(KEY_QC_TINTLESS_ENABLE);
5474     char prop[PROPERTY_VALUE_MAX];
5475 
5476     memset(prop, 0, sizeof(prop));
5477     property_get("persist.camera.tintless", prop, VALUE_DISABLE);
5478     if (str != NULL) {
5479         if (prev_str == NULL ||
5480             strcmp(str, prev_str) != 0) {
5481             return setTintlessValue(str);
5482         }
5483     } else {
5484         if (prev_str == NULL ||
5485             strcmp(prev_str, prop) != 0 ) {
5486             setTintlessValue(prop);
5487         }
5488     }
5489 
5490     return NO_ERROR;
5491 }
5492 
5493 /*===========================================================================
5494  * FUNCTION   : setTintlessValue
5495  *
5496  * DESCRIPTION: set tintless value
5497  *
5498  * PARAMETERS :
5499  *   @tintStr : Tintless value string
5500  *
5501  * RETURN     : int32_t type of status
5502  *              NO_ERROR  -- success
5503  *              none-zero failure code
5504  *==========================================================================*/
setTintlessValue(const char * tintStr)5505 int32_t QCameraParameters::setTintlessValue(const char *tintStr)
5506 {
5507     if (tintStr != NULL) {
5508         int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP,
5509                                    sizeof(ENABLE_DISABLE_MODES_MAP)/sizeof(QCameraMap),
5510                                    tintStr);
5511         if (value != NAME_NOT_FOUND) {
5512             CDBG_HIGH("%s: Setting Tintless value %s", __func__, tintStr);
5513             updateParamEntry(KEY_QC_TINTLESS_ENABLE, tintStr);
5514             return AddSetParmEntryToBatch(m_pParamBuf,
5515                                           CAM_INTF_PARM_TINTLESS,
5516                                           sizeof(value),
5517                                           &value);
5518         }
5519     }
5520     ALOGE("Invalid Tintless value: %s", (tintStr == NULL) ? "NULL" : tintStr);
5521     return BAD_VALUE;
5522 }
5523 
5524 /*===========================================================================
5525  * FUNCTION   : setCDSMode
5526  *
5527  * DESCRIPTION: Set CDS mode
5528  *
5529  * PARAMETERS :
5530  *   @params  : user setting parameters
5531  *
5532  * RETURN     : int32_t type of status
5533  *              NO_ERROR  -- success
5534  *              none-zero failure code
5535  *==========================================================================*/
setCDSMode(const QCameraParameters & params)5536 int32_t QCameraParameters::setCDSMode(const QCameraParameters& params)
5537 {
5538     const char *str = params.get(KEY_QC_CDS_MODE);
5539     const char *prev_str = get(KEY_QC_CDS_MODE);
5540     char *cds_mode_str = NULL;
5541     int32_t rc = NO_ERROR;
5542 
5543     if (str) {
5544         if (!prev_str || !strcmp(str, prev_str)) {
5545             cds_mode_str = (char *)str;
5546         }
5547     } else {
5548         char prop[PROPERTY_VALUE_MAX];
5549         memset(prop, 0, sizeof(prop));
5550         property_get("persist.camera.CDS", prop, CDS_MODE_AUTO);
5551         cds_mode_str = prop;
5552     }
5553 
5554     if (cds_mode_str) {
5555         ALOGV("%s: Set CDS mode = %s", __func__, cds_mode_str);
5556 
5557         int32_t cds_mode = lookupAttr(CDS_MODES_MAP,
5558                                   sizeof(CDS_MODES_MAP) / sizeof(QCameraMap),
5559                                   cds_mode_str);
5560 
5561         rc = AddSetParmEntryToBatch(m_pParamBuf,
5562                                     CAM_INTF_PARM_CDS_MODE,
5563                                     sizeof(cds_mode),
5564                                     &cds_mode);
5565         if (rc != NO_ERROR) {
5566             ALOGE("%s:Failed CDS MODE to update table", __func__);
5567         }
5568     }
5569     return rc;
5570 }
5571 
5572 /*===========================================================================
5573  * FUNCTION   : setDISValue
5574  *
5575  * DESCRIPTION: set DIS value
5576  *
5577  * PARAMETERS :
5578  *   @disStr : DIS value string
5579  *
5580  * RETURN     : int32_t type of status
5581  *              NO_ERROR  -- success
5582  *              none-zero failure code
5583  *==========================================================================*/
setDISValue(const char * disStr)5584 int32_t QCameraParameters::setDISValue(const char *disStr)
5585 {
5586     if (disStr != NULL) {
5587         int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP,
5588                                    sizeof(ENABLE_DISABLE_MODES_MAP)/sizeof(QCameraMap),
5589                                    disStr);
5590         if (value != NAME_NOT_FOUND) {
5591             //For some IS types (like EIS 2.0), when DIS value is changed, we need to restart
5592             //preview because of topology change in backend. But, for now, restart preview
5593             //for all IS types.
5594             m_bNeedRestart = true;
5595             CDBG("%s: Setting DIS value %s", __func__, disStr);
5596             updateParamEntry(KEY_QC_DIS, disStr);
5597             if (!(strcmp(disStr,"enable"))) {
5598                 m_bDISEnabled = true;
5599             } else {
5600                 m_bDISEnabled = false;
5601             }
5602             return AddSetParmEntryToBatch(m_pParamBuf,
5603                                           CAM_INTF_PARM_DIS_ENABLE,
5604                                           sizeof(value),
5605                                           &value);
5606         }
5607     }
5608     ALOGE("Invalid DIS value: %s", (disStr == NULL) ? "NULL" : disStr);
5609     m_bDISEnabled = false;
5610     return BAD_VALUE;
5611 }
5612 
5613 /*===========================================================================
5614  * FUNCTION   : setHighFrameRate
5615  *
5616  * DESCRIPTION: set high frame rate
5617  *
5618  * PARAMETERS :
5619  *   @hfrStr : HFR value string
5620  *
5621  * RETURN     : int32_t type of status
5622  *              NO_ERROR  -- success
5623  *              none-zero failure code
5624  *==========================================================================*/
setHighFrameRate(const char * hfrStr)5625 int32_t QCameraParameters::setHighFrameRate(const char *hfrStr)
5626 {
5627     if (hfrStr != NULL) {
5628         int32_t value = lookupAttr(HFR_MODES_MAP,
5629                                    sizeof(HFR_MODES_MAP)/sizeof(QCameraMap),
5630                                    hfrStr);
5631         if (value != NAME_NOT_FOUND) {
5632             // HFR value changed, need to restart preview
5633             m_bNeedRestart = true;
5634             // Set HFR value
5635             CDBG_HIGH("%s: Setting HFR value %s", __func__, hfrStr);
5636             updateParamEntry(KEY_QC_VIDEO_HIGH_FRAME_RATE, hfrStr);
5637             return AddSetParmEntryToBatch(m_pParamBuf,
5638                                           CAM_INTF_PARM_HFR,
5639                                           sizeof(value),
5640                                           &value);
5641         }
5642     }
5643     ALOGE("Invalid HFR value: %s", (hfrStr == NULL) ? "NULL" : hfrStr);
5644     return BAD_VALUE;
5645 }
5646 
5647 /*===========================================================================
5648  * FUNCTION   : setLensShadeValue
5649  *
5650  * DESCRIPTION: set lens shade value
5651  *
5652  * PARAMETERS :
5653  *   @lensSahdeStr : lens shade value string
5654  *
5655  * RETURN     : int32_t type of status
5656  *              NO_ERROR  -- success
5657  *              none-zero failure code
5658  *==========================================================================*/
setLensShadeValue(const char * lensShadeStr)5659 int32_t QCameraParameters::setLensShadeValue(const char *lensShadeStr)
5660 {
5661     if (lensShadeStr != NULL) {
5662         int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP,
5663                                    sizeof(ENABLE_DISABLE_MODES_MAP)/sizeof(QCameraMap),
5664                                    lensShadeStr);
5665         if (value != NAME_NOT_FOUND) {
5666             CDBG_HIGH("%s: Setting LensShade value %s", __func__, lensShadeStr);
5667             updateParamEntry(KEY_QC_LENSSHADE, lensShadeStr);
5668             return AddSetParmEntryToBatch(m_pParamBuf,
5669                                           CAM_INTF_PARM_ROLLOFF,
5670                                           sizeof(value),
5671                                           &value);
5672         }
5673     }
5674     ALOGE("Invalid LensShade value: %s",
5675           (lensShadeStr == NULL) ? "NULL" : lensShadeStr);
5676     return BAD_VALUE;
5677 }
5678 
5679 /*===========================================================================
5680  * FUNCTION   : setExposureCompensation
5681  *
5682  * DESCRIPTION: set exposure compensation value
5683  *
5684  * PARAMETERS :
5685  *   @expComp : exposure compensation value
5686  *
5687  * RETURN     : int32_t type of status
5688  *              NO_ERROR  -- success
5689  *              none-zero failure code
5690  *==========================================================================*/
setExposureCompensation(int expComp)5691 int32_t QCameraParameters::setExposureCompensation(int expComp)
5692 {
5693     char val[16];
5694     sprintf(val, "%d", expComp);
5695     updateParamEntry(KEY_EXPOSURE_COMPENSATION, val);
5696 
5697     // Don't need to pass step as part of setParameter because
5698     // camera daemon is already aware of it.
5699     return AddSetParmEntryToBatch(m_pParamBuf,
5700                                   CAM_INTF_PARM_EXPOSURE_COMPENSATION,
5701                                   sizeof(expComp),
5702                                   &expComp);
5703 }
5704 
5705 /*===========================================================================
5706  * FUNCTION   : setWhiteBalance
5707  *
5708  * DESCRIPTION: set white balance mode
5709  *
5710  * PARAMETERS :
5711  *   @wbStr   : white balance mode value string
5712  *
5713  * RETURN     : int32_t type of status
5714  *              NO_ERROR  -- success
5715  *              none-zero failure code
5716  *==========================================================================*/
setWhiteBalance(const char * wbStr)5717 int32_t QCameraParameters::setWhiteBalance(const char *wbStr)
5718 {
5719     if (wbStr != NULL) {
5720         int32_t value = lookupAttr(WHITE_BALANCE_MODES_MAP,
5721                                    sizeof(WHITE_BALANCE_MODES_MAP)/sizeof(QCameraMap),
5722                                    wbStr);
5723         if (value != NAME_NOT_FOUND) {
5724             CDBG_HIGH("%s: Setting WhiteBalance value %s", __func__, wbStr);
5725             updateParamEntry(KEY_WHITE_BALANCE, wbStr);
5726             return AddSetParmEntryToBatch(m_pParamBuf,
5727                                           CAM_INTF_PARM_WHITE_BALANCE,
5728                                           sizeof(value),
5729                                           &value);
5730         }
5731     }
5732     ALOGE("Invalid WhiteBalance value: %s", (wbStr == NULL) ? "NULL" : wbStr);
5733     return BAD_VALUE;
5734 }
getAutoFlickerMode()5735 int QCameraParameters::getAutoFlickerMode()
5736 {
5737     /* Enable Advanced Auto Antibanding where we can set
5738        any of the following option
5739        ie. CAM_ANTIBANDING_MODE_AUTO
5740            CAM_ANTIBANDING_MODE_AUTO_50HZ
5741            CAM_ANTIBANDING_MODE_AUTO_60HZ
5742       Currently setting it to default    */
5743     char prop[PROPERTY_VALUE_MAX];
5744     memset(prop, 0, sizeof(prop));
5745     property_get("persist.camera.set.afd", prop, "3");
5746     return atoi(prop);
5747 }
5748 
5749 /*===========================================================================
5750  * FUNCTION   : setAntibanding
5751  *
5752  * DESCRIPTION: set antibanding value
5753  *
5754  * PARAMETERS :
5755  *   @antiBandingStr : antibanding value string
5756  *
5757  * RETURN     : int32_t type of status
5758  *              NO_ERROR  -- success
5759  *              none-zero failure code
5760  *==========================================================================*/
setAntibanding(const char * antiBandingStr)5761 int32_t QCameraParameters::setAntibanding(const char *antiBandingStr)
5762 {
5763     if (antiBandingStr != NULL) {
5764         int32_t value = lookupAttr(ANTIBANDING_MODES_MAP,
5765                                    sizeof(ANTIBANDING_MODES_MAP)/sizeof(QCameraMap),
5766                                    antiBandingStr);
5767         if (value != NAME_NOT_FOUND) {
5768             CDBG_HIGH("%s: Setting AntiBanding value %s", __func__, antiBandingStr);
5769             updateParamEntry(KEY_ANTIBANDING, antiBandingStr);
5770             if(value == CAM_ANTIBANDING_MODE_AUTO) {
5771                value = getAutoFlickerMode();
5772             }
5773             return AddSetParmEntryToBatch(m_pParamBuf,
5774                                           CAM_INTF_PARM_ANTIBANDING,
5775                                           sizeof(value),
5776                                           &value);
5777         }
5778     }
5779     ALOGE("Invalid AntiBanding value: %s",
5780           (antiBandingStr == NULL) ? "NULL" : antiBandingStr);
5781     return BAD_VALUE;
5782 }
5783 
5784 /*===========================================================================
5785  * FUNCTION   : setFocusAreas
5786  *
5787  * DESCRIPTION: set focus areas
5788  *
5789  * PARAMETERS :
5790  *   @focusAreasStr : focus areas value string
5791  *
5792  * RETURN     : int32_t type of status
5793  *              NO_ERROR  -- success
5794  *              none-zero failure code
5795  *==========================================================================*/
setFocusAreas(const char * focusAreasStr)5796 int32_t QCameraParameters::setFocusAreas(const char *focusAreasStr)
5797 {
5798     if (m_pCapability->max_num_focus_areas == 0 ||
5799         focusAreasStr == NULL) {
5800         CDBG("%s: Parameter string is null", __func__);
5801         return NO_ERROR;
5802     }
5803 
5804     cam_area_t *areas = (cam_area_t *)malloc(sizeof(cam_area_t) * m_pCapability->max_num_focus_areas);
5805     if (NULL == areas) {
5806         ALOGE("%s: No memory for areas", __func__);
5807         return NO_MEMORY;
5808     }
5809     memset(areas, 0, sizeof(cam_area_t) * m_pCapability->max_num_focus_areas);
5810     int num_areas_found = 0;
5811     if (parseCameraAreaString(focusAreasStr,
5812                               m_pCapability->max_num_focus_areas,
5813                               areas,
5814                               num_areas_found) != NO_ERROR) {
5815         ALOGE("%s: Failed to parse the string: %s", __func__, focusAreasStr);
5816         free(areas);
5817         return BAD_VALUE;
5818     }
5819 
5820     if (validateCameraAreas(areas, num_areas_found) == false) {
5821         ALOGE("%s: invalid areas specified : %s", __func__, focusAreasStr);
5822         free(areas);
5823         return BAD_VALUE;
5824     }
5825 
5826     updateParamEntry(KEY_FOCUS_AREAS, focusAreasStr);
5827 
5828     //for special area string (0, 0, 0, 0, 0), set the num_areas_found to 0,
5829     //so no action is takenby the lower layer
5830     if (num_areas_found == 1 &&
5831         areas[0].rect.left == 0 &&
5832         areas[0].rect.top == 0 &&
5833         areas[0].rect.width == 0 &&
5834         areas[0].rect.height == 0 &&
5835         areas[0].weight == 0) {
5836         num_areas_found = 0;
5837     }
5838 
5839     int previewWidth, previewHeight;
5840     getPreviewSize(&previewWidth, &previewHeight);
5841     cam_roi_info_t af_roi_value;
5842     memset(&af_roi_value, 0, sizeof(cam_roi_info_t));
5843     af_roi_value.num_roi = num_areas_found;
5844     for (int i = 0; i < num_areas_found; i++) {
5845         CDBG_HIGH("%s: FocusArea[%d] = (%d, %d, %d, %d)",
5846               __func__, i, (areas[i].rect.top), (areas[i].rect.left),
5847               (areas[i].rect.width), (areas[i].rect.height));
5848 
5849         //transform the coords from (-1000, 1000) to (0, previewWidth or previewHeight)
5850         af_roi_value.roi[i].left = (int32_t)((areas[i].rect.left + 1000.0f) * (previewWidth / 2000.0f));
5851         af_roi_value.roi[i].top = (int32_t)((areas[i].rect.top + 1000.0f) * (previewHeight / 2000.0f));
5852         af_roi_value.roi[i].width = (int32_t)(areas[i].rect.width * previewWidth / 2000.0f);
5853         af_roi_value.roi[i].height = (int32_t)(areas[i].rect.height * previewHeight / 2000.0f);
5854         af_roi_value.weight[i] = areas[i].weight;
5855     }
5856     free(areas);
5857     return AddSetParmEntryToBatch(m_pParamBuf,
5858                                   CAM_INTF_PARM_AF_ROI,
5859                                   sizeof(af_roi_value),
5860                                   &af_roi_value);
5861 }
5862 
5863 /*===========================================================================
5864  * FUNCTION   : setMeteringAreas
5865  *
5866  * DESCRIPTION: set metering areas value
5867  *
5868  * PARAMETERS :
5869  *   @meteringAreasStr : metering areas value string
5870  *
5871  * RETURN     : int32_t type of status
5872  *              NO_ERROR  -- success
5873  *              none-zero failure code
5874  *==========================================================================*/
setMeteringAreas(const char * meteringAreasStr)5875 int32_t QCameraParameters::setMeteringAreas(const char *meteringAreasStr)
5876 {
5877     if (m_pCapability->max_num_metering_areas == 0 ||
5878         meteringAreasStr == NULL) {
5879         CDBG("%s: Parameter string is null", __func__);
5880         return NO_ERROR;
5881     }
5882 
5883     cam_area_t *areas = (cam_area_t *)malloc(sizeof(cam_area_t) * m_pCapability->max_num_metering_areas);
5884     if (NULL == areas) {
5885         ALOGE("%s: No memory for areas", __func__);
5886         return NO_MEMORY;
5887     }
5888     memset(areas, 0, sizeof(cam_area_t) * m_pCapability->max_num_metering_areas);
5889     int num_areas_found = 0;
5890     if (parseCameraAreaString(meteringAreasStr,
5891                               m_pCapability->max_num_metering_areas,
5892                               areas,
5893                               num_areas_found) < 0) {
5894         ALOGE("%s: Failed to parse the string: %s", __func__, meteringAreasStr);
5895         free(areas);
5896         return BAD_VALUE;
5897     }
5898 
5899     if (validateCameraAreas(areas, num_areas_found) == false) {
5900         ALOGE("%s: invalid areas specified : %s", __func__, meteringAreasStr);
5901         free(areas);
5902         return BAD_VALUE;
5903     }
5904 
5905     updateParamEntry(KEY_METERING_AREAS, meteringAreasStr);
5906 
5907     //for special area string (0, 0, 0, 0, 0), set the num_areas_found to 0,
5908     //so no action is takenby the lower layer
5909     if (num_areas_found == 1 &&
5910         areas[0].rect.left == 0 &&
5911         areas[0].rect.top == 0 &&
5912         areas[0].rect.width == 0 &&
5913         areas[0].rect.height == 0 &&
5914         areas[0].weight == 0) {
5915         num_areas_found = 0;
5916     }
5917     cam_set_aec_roi_t aec_roi_value;
5918     int previewWidth, previewHeight;
5919     getPreviewSize(&previewWidth, &previewHeight);
5920 
5921     memset(&aec_roi_value, 0, sizeof(cam_set_aec_roi_t));
5922     if (num_areas_found > 0) {
5923         aec_roi_value.aec_roi_enable = CAM_AEC_ROI_ON;
5924         aec_roi_value.aec_roi_type = CAM_AEC_ROI_BY_COORDINATE;
5925 
5926         for (int i = 0; i < num_areas_found; i++) {
5927             CDBG_HIGH("%s: MeteringArea[%d] = (%d, %d, %d, %d)",
5928                   __func__, i, (areas[i].rect.top), (areas[i].rect.left),
5929                   (areas[i].rect.width), (areas[i].rect.height));
5930 
5931             //transform the coords from (-1000, 1000) to (0, previewWidth or previewHeight)
5932             aec_roi_value.cam_aec_roi_position.coordinate[i].x =
5933                 (uint32_t)(((areas[i].rect.left + areas[i].rect.width / 2) + 1000.0f) * previewWidth / 2000.0f) ;
5934             aec_roi_value.cam_aec_roi_position.coordinate[i].y =
5935                 (uint32_t)(((areas[i].rect.top + areas[i].rect.height / 2) + 1000.0f) * previewHeight / 2000.0f) ;
5936         }
5937     } else {
5938         aec_roi_value.aec_roi_enable = CAM_AEC_ROI_OFF;
5939     }
5940     free(areas);
5941     return AddSetParmEntryToBatch(m_pParamBuf,
5942                                   CAM_INTF_PARM_AEC_ROI,
5943                                   sizeof(aec_roi_value),
5944                                   &aec_roi_value);
5945 }
5946 
5947 /*===========================================================================
5948  * FUNCTION   : setSceneMode
5949  *
5950  * DESCRIPTION: set scene mode
5951  *
5952  * PARAMETERS :
5953  *   @sceneModeStr : scene mode value string
5954  *
5955  * RETURN     : int32_t type of status
5956  *              NO_ERROR  -- success
5957  *              none-zero failure code
5958  *==========================================================================*/
setSceneMode(const char * sceneModeStr)5959 int32_t QCameraParameters::setSceneMode(const char *sceneModeStr)
5960 {
5961     if (sceneModeStr != NULL) {
5962         int32_t value = lookupAttr(SCENE_MODES_MAP,
5963                                    sizeof(SCENE_MODES_MAP)/sizeof(QCameraMap),
5964                                    sceneModeStr);
5965         if (value != NAME_NOT_FOUND) {
5966             CDBG("%s: Setting SceneMode %s", __func__, sceneModeStr);
5967             updateParamEntry(KEY_SCENE_MODE, sceneModeStr);
5968             if (m_bSensorHDREnabled) {
5969               // Incase of HW HDR mode, we do not update the same as Best shot mode.
5970               CDBG_HIGH("%s: H/W HDR mode enabled. Do not set Best Shot Mode", __func__);
5971               return NO_ERROR;
5972             }
5973             if (m_bSceneSelection) {
5974                 setSelectedScene((cam_scene_mode_type) value);
5975             }
5976             int32_t rc = AddSetParmEntryToBatch(m_pParamBuf,
5977                                                 CAM_INTF_PARM_BESTSHOT_MODE,
5978                                                 sizeof(value),
5979                                                 &value);
5980             return rc;
5981         }
5982     }
5983     ALOGE("%s: Invalid Secene Mode: %s",
5984           __func__, (sceneModeStr == NULL) ? "NULL" : sceneModeStr);
5985     return BAD_VALUE;
5986 }
5987 
5988 /*===========================================================================
5989  * FUNCTION   : setSelectableZoneAf
5990  *
5991  * DESCRIPTION: set selectable zone AF algorithm
5992  *
5993  * PARAMETERS :
5994  *   @selZoneAFStr : selectable zone AF algorithm value string
5995  *
5996  * RETURN     : int32_t type of status
5997  *              NO_ERROR  -- success
5998  *              none-zero failure code
5999  *==========================================================================*/
setSelectableZoneAf(const char * selZoneAFStr)6000 int32_t QCameraParameters::setSelectableZoneAf(const char *selZoneAFStr)
6001 {
6002     if (selZoneAFStr != NULL) {
6003         int32_t value = lookupAttr(FOCUS_ALGO_MAP,
6004                                    sizeof(FOCUS_ALGO_MAP)/sizeof(QCameraMap),
6005                                    selZoneAFStr);
6006         if (value != NAME_NOT_FOUND) {
6007             CDBG("%s: Setting Selectable Zone AF value %s", __func__, selZoneAFStr);
6008             updateParamEntry(KEY_QC_SELECTABLE_ZONE_AF, selZoneAFStr);
6009             return AddSetParmEntryToBatch(m_pParamBuf,
6010                                           CAM_INTF_PARM_FOCUS_ALGO_TYPE,
6011                                           sizeof(value),
6012                                           &value);
6013         }
6014     }
6015     ALOGE("%s: Invalid selectable zone af value: %s",
6016           __func__, (selZoneAFStr == NULL) ? "NULL" : selZoneAFStr);
6017     return BAD_VALUE;
6018 }
6019 
6020 /*===========================================================================
6021  * FUNCTION   : isAEBracketEnabled
6022  *
6023  * DESCRIPTION: checks if AE bracketing is enabled
6024  *
6025  * PARAMETERS :
6026  *
6027  * RETURN     : TRUE/FALSE
6028  *==========================================================================*/
isAEBracketEnabled()6029 bool QCameraParameters::isAEBracketEnabled()
6030 {
6031     const char *str = get(KEY_QC_AE_BRACKET_HDR);
6032     if (str != NULL) {
6033         if (strcmp(str, AE_BRACKET_OFF) != 0) {
6034             return true;
6035         }
6036     }
6037     return false;
6038 }
6039 
6040 /*===========================================================================
6041  * FUNCTION   : setAEBracket
6042  *
6043  * DESCRIPTION: set AE bracket value
6044  *
6045  * PARAMETERS :
6046  *   @aecBracketStr : AE bracket value string
6047  *
6048  * RETURN     : int32_t type of status
6049  *              NO_ERROR  -- success
6050  *              none-zero failure code
6051  *==========================================================================*/
setAEBracket(const char * aecBracketStr)6052 int32_t QCameraParameters::setAEBracket(const char *aecBracketStr)
6053 {
6054     if (aecBracketStr == NULL) {
6055         CDBG("%s: setAEBracket with NULL value", __func__);
6056         return NO_ERROR;
6057     }
6058 
6059     cam_exp_bracketing_t expBracket;
6060     memset(&expBracket, 0, sizeof(expBracket));
6061 
6062     int value = lookupAttr(BRACKETING_MODES_MAP,
6063                            sizeof(BRACKETING_MODES_MAP)/sizeof(QCameraMap),
6064                            aecBracketStr);
6065     switch (value) {
6066     case CAM_EXP_BRACKETING_ON:
6067         {
6068             CDBG("%s, EXP_BRACKETING_ON", __func__);
6069             const char *str_val = get(KEY_QC_CAPTURE_BURST_EXPOSURE);
6070             if ((str_val != NULL) && (strlen(str_val)>0)) {
6071                 expBracket.mode = CAM_EXP_BRACKETING_ON;
6072                 m_bAeBracketingEnabled = true;
6073                 strlcpy(expBracket.values, str_val, MAX_EXP_BRACKETING_LENGTH);
6074                 CDBG("%s: setting Exposure Bracketing value of %s",
6075                       __func__, expBracket.values);
6076             }
6077             else {
6078                 /* Apps not set capture-burst-exposures, error case fall into bracketing off mode */
6079                 CDBG("%s: capture-burst-exposures not set, back to HDR OFF mode", __func__);
6080                 m_bAeBracketingEnabled = false;
6081                 expBracket.mode = CAM_EXP_BRACKETING_OFF;
6082             }
6083         }
6084         break;
6085     default:
6086         {
6087             m_bAeBracketingEnabled = false;
6088             CDBG_HIGH("%s, EXP_BRACKETING_OFF", __func__);
6089             expBracket.mode = CAM_EXP_BRACKETING_OFF;
6090         }
6091         break;
6092     }
6093 
6094     // Cache client AE bracketing configuration
6095     memcpy(&m_AEBracketingClient, &expBracket, sizeof(cam_exp_bracketing_t));
6096 
6097     /* save the value*/
6098     updateParamEntry(KEY_QC_AE_BRACKET_HDR, aecBracketStr);
6099     return NO_ERROR;
6100 }
6101 
6102 /*===========================================================================
6103  * FUNCTION   : set3ALock
6104  *
6105  * DESCRIPTION: enable/disable 3A lock.
6106  *
6107  * PARAMETERS :
6108  *   @lockStr : lock value string.
6109  *
6110  * RETURN     : int32_t type of status
6111  *              NO_ERROR  -- success
6112  *              none-zero failure code
6113  *==========================================================================*/
set3ALock(const char * lockStr)6114 int32_t QCameraParameters::set3ALock(const char *lockStr)
6115 {
6116     int32_t rc = NO_ERROR;
6117     if (lockStr != NULL) {
6118         int32_t value = lookupAttr(TRUE_FALSE_MODES_MAP,
6119                                    sizeof(TRUE_FALSE_MODES_MAP)/sizeof(QCameraMap),
6120                                    lockStr);
6121         if (value != NAME_NOT_FOUND) {
6122             CDBG_HIGH("%s: Setting Lock lockStr =%s", __func__, lockStr);
6123             if(initBatchUpdate(m_pParamBuf) < 0 ) {
6124                 ALOGE("%s:Failed to initialize group update table", __func__);
6125                 return BAD_TYPE;
6126             }
6127             int32_t focus_mode;
6128             if (value == 1) {
6129                 if (isUbiFocusEnabled()) {
6130                     //For Ubi focus move focus to infinity.
6131                     focus_mode = CAM_FOCUS_MODE_INFINITY;
6132                 } else if (isOptiZoomEnabled()){
6133                     //For optizoom set focus as fixed.
6134                     focus_mode = CAM_FOCUS_MODE_FIXED;
6135                 }
6136             } else {
6137                // retrieve previous focus value.
6138                const char *focus = get(KEY_FOCUS_MODE);
6139                focus_mode = lookupAttr(FOCUS_MODES_MAP,
6140                                sizeof(FOCUS_MODES_MAP)/sizeof(QCameraMap),
6141                                focus);
6142                CDBG("%s: focus mode %s", __func__, focus);
6143             }
6144             //Lock AWB
6145             rc = AddSetParmEntryToBatch(m_pParamBuf,
6146                                     CAM_INTF_PARM_AWB_LOCK,
6147                                     sizeof(value),
6148                                     &value);
6149             if (NO_ERROR != rc) {
6150                 return rc;
6151             }
6152             //Lock AEC
6153             rc = AddSetParmEntryToBatch(m_pParamBuf,
6154                                     CAM_INTF_PARM_AEC_LOCK,
6155                                     sizeof(value),
6156                                     &value);
6157             if (NO_ERROR != rc) {
6158                 return rc;
6159             }
6160             rc = AddSetParmEntryToBatch(m_pParamBuf,
6161                                     CAM_INTF_PARM_FOCUS_MODE,
6162                                     sizeof(focus_mode),
6163                                     &focus_mode);
6164             if (NO_ERROR != rc) {
6165                 return rc;
6166             }
6167 
6168             rc = commitSetBatch();
6169             if (rc != NO_ERROR) {
6170                 ALOGE("%s:Failed to commit batch", __func__);
6171             }
6172         }
6173     }
6174     return rc;
6175 }
6176 
6177 /*===========================================================================
6178  * FUNCTION   : setAndCommitZoom
6179  *
6180  * DESCRIPTION: set zoom.
6181  *
6182  * PARAMETERS :
6183  *     @zoom_level : zoom level to set.
6184  *
6185  * RETURN     : int32_t type of status
6186  *              NO_ERROR  -- success
6187  *              none-zero failure code
6188  *==========================================================================*/
setAndCommitZoom(int zoom_level)6189 int32_t QCameraParameters::setAndCommitZoom(int zoom_level)
6190 {
6191     CDBG_HIGH("%s: E",__func__);
6192     int32_t rc = NO_ERROR;
6193         if(initBatchUpdate(m_pParamBuf) < 0 ) {
6194             ALOGE("%s:Failed to initialize group update table", __func__);
6195             return BAD_TYPE;
6196         }
6197         rc = AddSetParmEntryToBatch(m_pParamBuf,
6198                               CAM_INTF_PARM_ZOOM,
6199                               sizeof(zoom_level),
6200                               &zoom_level);
6201 
6202         if (rc != NO_ERROR) {
6203              ALOGE("%s:Failed to update table", __func__);
6204              return rc;
6205         }
6206     rc = commitSetBatch();
6207     if (rc != NO_ERROR) {
6208         ALOGE("%s:Failed to set Flash value", __func__);
6209     }
6210     CDBG_HIGH("%s: X",__func__);
6211     return rc;
6212 }
6213 
6214 /*===========================================================================
6215  * FUNCTION   : isOptiZoomEnabled
6216  *
6217  * DESCRIPTION: checks whether optizoom is enabled
6218  *
6219  * PARAMETERS :
6220  *
6221  * RETURN     : true - enabled, false - disabled
6222  *
6223  *==========================================================================*/
isOptiZoomEnabled()6224 bool QCameraParameters::isOptiZoomEnabled()
6225 {
6226     if (m_bOptiZoomOn) {
6227         uint8_t zoom_level = (uint8_t) getInt(CameraParameters::KEY_ZOOM);
6228         cam_opti_zoom_t *opti_zoom_settings_need =
6229                 &(m_pCapability->opti_zoom_settings_need);
6230         uint8_t zoom_threshold = opti_zoom_settings_need->zoom_threshold;
6231         CDBG_HIGH("%s: current zoom level =%d & zoom_threshold =%d",
6232                 __func__, zoom_level, zoom_threshold);
6233 
6234         if (zoom_level >= zoom_threshold) {
6235             return true;
6236         }
6237     }
6238 
6239     return false;
6240 }
6241 
6242 /*===========================================================================
6243  * FUNCTION   : commitAFBracket
6244  *
6245  * DESCRIPTION: commit AF Bracket.
6246  *
6247  * PARAMETERS :
6248  *   @AFBracket : AF bracketing configuration
6249  *
6250  * RETURN     : int32_t type of status
6251  *              NO_ERROR  -- success
6252  *              none-zero failure code
6253  *==========================================================================*/
commitAFBracket(cam_af_bracketing_t afBracket)6254 int32_t QCameraParameters::commitAFBracket(cam_af_bracketing_t afBracket)
6255 {
6256 
6257     int32_t rc = NO_ERROR;
6258     if(initBatchUpdate(m_pParamBuf) < 0 ) {
6259         ALOGE("%s:Failed to initialize group update table", __func__);
6260         return BAD_TYPE;
6261     }
6262 
6263     rc = AddSetParmEntryToBatch(m_pParamBuf,
6264             CAM_INTF_PARM_FOCUS_BRACKETING,
6265             sizeof(afBracket),
6266             &afBracket);
6267     if (rc != NO_ERROR) {
6268         ALOGE("%s:Failed to update table", __func__);
6269         return rc;
6270     }
6271 
6272     rc = commitSetBatch();
6273     if (rc != NO_ERROR) {
6274         ALOGE("%s:Failed to commit batch", __func__);
6275     }
6276 
6277     return rc;
6278 }
6279 
6280 /*===========================================================================
6281  * FUNCTION   : commitFlashBracket
6282  *
6283  * DESCRIPTION: commit Flash Bracket.
6284  *
6285  * PARAMETERS :
6286  *   @AFBracket : Flash bracketing configuration
6287  *
6288  * RETURN     : int32_t type of status
6289  *              NO_ERROR  -- success
6290  *              none-zero failure code
6291  *==========================================================================*/
commitFlashBracket(cam_flash_bracketing_t flashBracket)6292 int32_t QCameraParameters::commitFlashBracket(
6293     cam_flash_bracketing_t flashBracket)
6294 {
6295     CDBG_HIGH("%s: E",__func__);
6296     int32_t rc = NO_ERROR;
6297     if(initBatchUpdate(m_pParamBuf) < 0 ) {
6298         ALOGE("%s:Failed to initialize group update table", __func__);
6299         return BAD_TYPE;
6300     }
6301 
6302     rc = AddSetParmEntryToBatch(m_pParamBuf,
6303             CAM_INTF_PARM_FLASH_BRACKETING,
6304             sizeof(flashBracket),
6305             &flashBracket);
6306     if (rc != NO_ERROR) {
6307         ALOGE("%s:Failed to update table", __func__);
6308         return rc;
6309     }
6310 
6311     rc = commitSetBatch();
6312     if (rc != NO_ERROR) {
6313         ALOGE("%s:Failed to commit batch", __func__);
6314     }
6315 
6316     CDBG_HIGH("%s: X",__func__);
6317     return rc;
6318 }
6319 
6320 /*===========================================================================
6321  * FUNCTION   : setAFBracket
6322  *
6323  * DESCRIPTION: set AF bracket value
6324  *
6325  * PARAMETERS :
6326  *   @afBracketStr : AF bracket value string
6327  *
6328  * RETURN     : int32_t type of status
6329  *              NO_ERROR  -- success
6330  *              none-zero failure code
6331  *==========================================================================*/
setAFBracket(const char * afBracketStr)6332 int32_t QCameraParameters::setAFBracket(const char *afBracketStr)
6333 {
6334     CDBG_HIGH("%s: afBracketStr =%s",__func__,afBracketStr);
6335 
6336     if(afBracketStr != NULL) {
6337         int value = lookupAttr(AF_BRACKETING_MODES_MAP,
6338                               sizeof(AF_BRACKETING_MODES_MAP)/
6339                                   sizeof(QCameraMap),
6340                               afBracketStr);
6341         if (value != NAME_NOT_FOUND) {
6342             m_bAFBracketingOn = (value != 0);
6343             updateParamEntry(KEY_QC_AF_BRACKET, afBracketStr);
6344 
6345             return NO_ERROR;
6346         }
6347     }
6348 
6349     ALOGE("Invalid af bracket value: %s",
6350         (afBracketStr == NULL) ? "NULL" : afBracketStr);
6351     return BAD_VALUE;
6352 }
6353 
6354 /*===========================================================================
6355  * FUNCTION   : setChromaFlash
6356  *
6357  * DESCRIPTION: set chroma flash value
6358  *
6359  * PARAMETERS :
6360  *   @aecBracketStr : chroma flash value string
6361  *
6362  * RETURN     : int32_t type of status
6363  *              NO_ERROR  -- success
6364  *              none-zero failure code
6365  *==========================================================================*/
setChromaFlash(const char * chromaFlashStr)6366 int32_t QCameraParameters::setChromaFlash(const char *chromaFlashStr)
6367 {
6368     CDBG_HIGH("%s: chromaFlashStr =%s",__func__,chromaFlashStr);
6369     if(chromaFlashStr != NULL) {
6370         int value = lookupAttr(CHROMA_FLASH_MODES_MAP,
6371                               sizeof(CHROMA_FLASH_MODES_MAP)/sizeof(QCameraMap),
6372                               chromaFlashStr);
6373         if(value != NAME_NOT_FOUND) {
6374             m_bChromaFlashOn = (value != 0);
6375             updateParamEntry(KEY_QC_CHROMA_FLASH, chromaFlashStr);
6376 
6377             return NO_ERROR;
6378         }
6379     }
6380 
6381     ALOGE("Invalid chroma flash value: %s",
6382         (chromaFlashStr == NULL) ? "NULL" : chromaFlashStr);
6383     return BAD_VALUE;
6384 }
6385 
6386 /*===========================================================================
6387  * FUNCTION   : setOptiZoom
6388  *
6389  * DESCRIPTION: set opti zoom value
6390  *
6391  * PARAMETERS :
6392  *   @aecBracketStr : opti zoom value string
6393  *
6394  * RETURN     : int32_t type of status
6395  *              NO_ERROR  -- success
6396  *              none-zero failure code
6397  *==========================================================================*/
setOptiZoom(const char * optiZoomStr)6398 int32_t QCameraParameters::setOptiZoom(const char *optiZoomStr)
6399 {
6400     CDBG_HIGH("%s: optiZoomStr =%s",__func__,optiZoomStr);
6401     if(optiZoomStr != NULL) {
6402         int value = lookupAttr(OPTI_ZOOM_MODES_MAP,
6403                                sizeof(OPTI_ZOOM_MODES_MAP)/sizeof(QCameraMap),
6404                                optiZoomStr);
6405         if(value != NAME_NOT_FOUND) {
6406             m_bOptiZoomOn = (value != 0);
6407             updateParamEntry(KEY_QC_OPTI_ZOOM, optiZoomStr);
6408 
6409             return NO_ERROR;
6410         }
6411     }
6412     ALOGE("Invalid opti zoom value: %s",
6413         (optiZoomStr == NULL) ? "NULL" : optiZoomStr);
6414     return BAD_VALUE;
6415 }
6416 
6417 /*===========================================================================
6418  * FUNCTION   : setAEBracketing
6419  *
6420  * DESCRIPTION: enables AE bracketing
6421  *
6422  * PARAMETERS :
6423  *
6424  * RETURN     : int32_t type of status
6425  *              NO_ERROR  -- success
6426  *              none-zero failure code
6427  *==========================================================================*/
setAEBracketing()6428 int32_t QCameraParameters::setAEBracketing()
6429 {
6430     int32_t rc = NO_ERROR;
6431     if(initBatchUpdate(m_pParamBuf) < 0 ) {
6432         ALOGE("%s:Failed to initialize group update table", __func__);
6433         return BAD_TYPE;
6434     }
6435 
6436     rc = AddSetParmEntryToBatch(m_pParamBuf,
6437             CAM_INTF_PARM_HDR,
6438             sizeof(m_AEBracketingClient),
6439             &m_AEBracketingClient);
6440     if (rc != NO_ERROR) {
6441         ALOGE("%s:Failed to update AE bracketing", __func__);
6442         return rc;
6443     }
6444 
6445     rc = commitSetBatch();
6446     if (rc != NO_ERROR) {
6447         ALOGE("%s:Failed to configure AE bracketing", __func__);
6448         return rc;
6449     }
6450 
6451     return rc;
6452 }
6453 
6454 /*===========================================================================
6455  * FUNCTION   : setHDRAEBracket
6456  *
6457  * DESCRIPTION: enables AE bracketing for HDR
6458  *
6459  * PARAMETERS :
6460  *   @hdrBracket : HDR bracketing configuration
6461  *
6462  * RETURN     : int32_t type of status
6463  *              NO_ERROR  -- success
6464  *              none-zero failure code
6465  *==========================================================================*/
setHDRAEBracket(cam_exp_bracketing_t hdrBracket)6466 int32_t QCameraParameters::setHDRAEBracket(cam_exp_bracketing_t hdrBracket)
6467 {
6468     int32_t rc = NO_ERROR;
6469     if(initBatchUpdate(m_pParamBuf) < 0 ) {
6470         ALOGE("%s:Failed to initialize group update table", __func__);
6471         return BAD_TYPE;
6472     }
6473 
6474     rc = AddSetParmEntryToBatch(m_pParamBuf,
6475             CAM_INTF_PARM_HDR,
6476             sizeof(hdrBracket),
6477             &hdrBracket);
6478     if (rc != NO_ERROR) {
6479         ALOGE("%s:Failed to update table", __func__);
6480         return rc;
6481     }
6482 
6483     rc = commitSetBatch();
6484     if (rc != NO_ERROR) {
6485         ALOGE("%s:Failed to configure HDR bracketing", __func__);
6486         return rc;
6487     }
6488 
6489     return rc;
6490 }
6491 
6492 /*===========================================================================
6493  * FUNCTION   : restoreAEBracket
6494  *
6495  * DESCRIPTION: restores client AE bracketing configuration after HDR is done
6496  *
6497  * PARAMETERS :
6498  *
6499  * RETURN     : int32_t type of status
6500  *              NO_ERROR  -- success
6501  *              none-zero failure code
6502  *==========================================================================*/
stopAEBracket()6503 int32_t QCameraParameters::stopAEBracket()
6504 {
6505   cam_exp_bracketing_t bracketing;
6506 
6507   bracketing.mode = CAM_EXP_BRACKETING_OFF;
6508 
6509   return setHDRAEBracket(bracketing);
6510 }
6511 
6512 /*===========================================================================
6513  * FUNCTION   : updateFlash
6514  *
6515  * DESCRIPTION: restores client flash configuration or disables flash
6516  *
6517  * PARAMETERS :
6518  *   @commitSettings : flag indicating whether settings need to be commited
6519  *
6520  * RETURN     : int32_t type of status
6521  *              NO_ERROR  -- success
6522  *              none-zero failure code
6523  *==========================================================================*/
updateFlash(bool commitSettings)6524 int32_t QCameraParameters::updateFlash(bool commitSettings)
6525 {
6526     int32_t rc = NO_ERROR;
6527     int32_t value;
6528 
6529     if (commitSettings) {
6530       if(initBatchUpdate(m_pParamBuf) < 0 ) {
6531           ALOGE("%s:Failed to initialize group update table", __func__);
6532           return BAD_TYPE;
6533       }
6534     }
6535 
6536     if (isHDREnabled() || m_bAeBracketingEnabled || m_bAFBracketingOn ||
6537           m_bOptiZoomOn) {
6538         value = CAM_FLASH_MODE_OFF;
6539     } else if (m_bChromaFlashOn) {
6540         value = CAM_FLASH_MODE_ON;
6541     } else {
6542         value = mFlashValue;
6543     }
6544 
6545     if (value != mFlashDaemonValue) {
6546         CDBG("%s: Setting Flash value %d", __func__, value);
6547         rc = AddSetParmEntryToBatch(m_pParamBuf,
6548                                       CAM_INTF_PARM_LED_MODE,
6549                                       sizeof(value),
6550                                       &value);
6551         if (rc != NO_ERROR) {
6552             rc = BAD_VALUE;
6553             ALOGE("%s:Failed to set led mode", __func__);
6554             return rc;
6555         }
6556 
6557         mFlashDaemonValue = value;
6558     } else {
6559         rc = NO_ERROR;
6560     }
6561 
6562     if (commitSettings) {
6563       rc = commitSetBatch();
6564       if (rc != NO_ERROR) {
6565           ALOGE("%s:Failed to configure HDR bracketing", __func__);
6566           return rc;
6567       }
6568     }
6569 
6570     return rc;
6571 }
6572 
6573 /*===========================================================================
6574  * FUNCTION   : setRedeyeReduction
6575  *
6576  * DESCRIPTION: set red eye reduction value
6577  *
6578  * PARAMETERS :
6579  *   @redeyeStr : red eye reduction value string
6580  *
6581  * RETURN     : int32_t type of status
6582  *              NO_ERROR  -- success
6583  *              none-zero failure code
6584  *==========================================================================*/
setRedeyeReduction(const char * redeyeStr)6585 int32_t QCameraParameters::setRedeyeReduction(const char *redeyeStr)
6586 {
6587     if (redeyeStr != NULL) {
6588         int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP,
6589                                    sizeof(ENABLE_DISABLE_MODES_MAP)/sizeof(QCameraMap),
6590                                    redeyeStr);
6591         if (value != NAME_NOT_FOUND) {
6592             CDBG("%s: Setting RedEye Reduce value %s", __func__, redeyeStr);
6593             updateParamEntry(KEY_QC_REDEYE_REDUCTION, redeyeStr);
6594             return AddSetParmEntryToBatch(m_pParamBuf,
6595                                           CAM_INTF_PARM_REDEYE_REDUCTION,
6596                                           sizeof(value),
6597                                           &value);
6598         }
6599     }
6600     ALOGE("%s: Invalid RedEye Reduce value: %s",
6601           __func__, (redeyeStr == NULL) ? "NULL" : redeyeStr);
6602     return BAD_VALUE;
6603 }
6604 
6605 /*===========================================================================
6606  * FUNCTION   : getWaveletDenoiseProcessPlate
6607  *
6608  * DESCRIPTION: query wavelet denoise process plate
6609  *
6610  * PARAMETERS : None
6611  *
6612  * RETURN     : WNR prcocess plate vlaue
6613  *==========================================================================*/
getWaveletDenoiseProcessPlate()6614 cam_denoise_process_type_t QCameraParameters::getWaveletDenoiseProcessPlate()
6615 {
6616     char prop[PROPERTY_VALUE_MAX];
6617     memset(prop, 0, sizeof(prop));
6618     cam_denoise_process_type_t processPlate = CAM_WAVELET_DENOISE_CBCR_ONLY;
6619     property_get("persist.denoise.process.plates", prop, "");
6620     if (strlen(prop) > 0) {
6621         switch(atoi(prop)) {
6622         case 0:
6623             processPlate = CAM_WAVELET_DENOISE_YCBCR_PLANE;
6624             break;
6625         case 1:
6626             processPlate = CAM_WAVELET_DENOISE_CBCR_ONLY;
6627             break;
6628         case 2:
6629             processPlate = CAM_WAVELET_DENOISE_STREAMLINE_YCBCR;
6630             break;
6631         case 3:
6632             processPlate = CAM_WAVELET_DENOISE_STREAMLINED_CBCR;
6633             break;
6634         default:
6635             processPlate = CAM_WAVELET_DENOISE_CBCR_ONLY;
6636             break;
6637         }
6638     }
6639     return processPlate;
6640 }
6641 
6642 /*===========================================================================
6643  * FUNCTION   : setWaveletDenoise
6644  *
6645  * DESCRIPTION: set wavelet denoise value
6646  *
6647  * PARAMETERS :
6648  *   @wnrStr : wavelet denoise value string
6649  *
6650  * RETURN     : int32_t type of status
6651  *              NO_ERROR  -- success
6652  *              none-zero failure code
6653  *==========================================================================*/
setWaveletDenoise(const char * wnrStr)6654 int32_t QCameraParameters::setWaveletDenoise(const char *wnrStr)
6655 {
6656     if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_DENOISE2D) == 0){
6657         CDBG_HIGH("%s: WNR is not supported",__func__);
6658         return NO_ERROR;
6659     }
6660 
6661     if (wnrStr != NULL) {
6662         int value = lookupAttr(DENOISE_ON_OFF_MODES_MAP,
6663                                sizeof(DENOISE_ON_OFF_MODES_MAP)/sizeof(QCameraMap),
6664                                wnrStr);
6665         if (value != NAME_NOT_FOUND) {
6666             updateParamEntry(KEY_QC_DENOISE, wnrStr);
6667 
6668             cam_denoise_param_t temp;
6669             memset(&temp, 0, sizeof(temp));
6670             temp.denoise_enable = value;
6671             m_bWNROn = (value != 0);
6672             if (m_bWNROn) {
6673                 temp.process_plates = getWaveletDenoiseProcessPlate();
6674             }
6675             CDBG("%s: Denoise enable=%d, plates=%d",
6676                   __func__, temp.denoise_enable, temp.process_plates);
6677             return AddSetParmEntryToBatch(m_pParamBuf,
6678                                           CAM_INTF_PARM_WAVELET_DENOISE,
6679                                           sizeof(temp),
6680                                           &temp);
6681         }
6682     }
6683     ALOGE("%s: Invalid Denoise value: %s", __func__, (wnrStr == NULL) ? "NULL" : wnrStr);
6684     return BAD_VALUE;
6685 }
6686 
6687 /*===========================================================================
6688  * FUNCTION   : setRdiMode
6689  *
6690  * DESCRIPTION: set rdi mode value
6691  *
6692  * PARAMETERS :
6693  *   @str     : rdi mode value string
6694  *
6695  * RETURN     : int32_t type of status
6696  *              NO_ERROR  -- success
6697  *              none-zero failure code
6698  *==========================================================================*/
setRdiMode(const char * str)6699 int32_t QCameraParameters::setRdiMode(const char *str)
6700 {
6701   CDBG("RDI_DEBUG %s: rdi mode value: %s", __func__, str);
6702 
6703   if (str != NULL) {
6704     int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP,
6705                            sizeof(ENABLE_DISABLE_MODES_MAP)/sizeof(QCameraMap),
6706                            str);
6707     if (value != NAME_NOT_FOUND) {
6708       updateParamEntry(KEY_QC_RDI_MODE, str);
6709       m_bRdiMode = (value == 0)? false : true;
6710       return AddSetParmEntryToBatch(m_pParamBuf,
6711                                     CAM_INTF_PARM_RDI_MODE,
6712                                     sizeof(value),
6713                                     &value);
6714     }
6715   }
6716   ALOGE("%s: Invalid rdi mode value: %s",
6717     __func__, (str == NULL) ? "NULL" : str);
6718   return BAD_VALUE;
6719 }
6720 
6721 
6722 /*===========================================================================
6723  * FUNCTION   : setSecureMode
6724  *
6725  * DESCRIPTION: set secure mode value
6726  *
6727  * PARAMETERS :
6728  *   @str     : secure mode value string
6729  *
6730  * RETURN     : int32_t type of status
6731  *              NO_ERROR  -- success
6732  *              none-zero failure code
6733  *==========================================================================*/
setSecureMode(const char * str)6734 int32_t QCameraParameters::setSecureMode(const char *str)
6735 {
6736   ALOGD("%s: Secure mode value: %s", __func__, str);
6737 
6738   if (str != NULL) {
6739     int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP,
6740             sizeof(ENABLE_DISABLE_MODES_MAP)/sizeof(QCameraMap),
6741             str);
6742     if (value != NAME_NOT_FOUND) {
6743       updateParamEntry(KEY_QC_SECURE_MODE, str);
6744       m_bSecureMode = (value == 0)? false : true;
6745       return NO_ERROR;
6746     }
6747   }
6748   ALOGE("%s: Invalid Secure mode value: %s",
6749     __func__, (str == NULL) ? "NULL" : str);
6750   return BAD_VALUE;
6751 }
6752 
6753 /*===========================================================================
6754  * FUNCTION   : setPreviewFrameRateMode
6755  *
6756  * DESCRIPTION: set preview frame rate mode
6757  *
6758  * PARAMETERS :
6759  *   @mode    : preview frame rate mode
6760  *
6761  * RETURN     : none
6762  *==========================================================================*/
setPreviewFrameRateMode(const char * mode)6763 void QCameraParameters::setPreviewFrameRateMode(const char *mode)
6764 {
6765     set(KEY_QC_PREVIEW_FRAME_RATE_MODE, mode);
6766 }
6767 
6768 /*===========================================================================
6769  * FUNCTION   : getPreviewFrameRateMode
6770  *
6771  * DESCRIPTION: get preview frame rate mode
6772  *
6773  * PARAMETERS : none
6774  *
6775  * RETURN     : preview frame rate mode string
6776  *==========================================================================*/
getPreviewFrameRateMode() const6777 const char *QCameraParameters::getPreviewFrameRateMode() const
6778 {
6779     return get(KEY_QC_PREVIEW_FRAME_RATE_MODE);
6780 }
6781 
6782 /*===========================================================================
6783  * FUNCTION   : setTouchIndexAec
6784  *
6785  * DESCRIPTION: set touch index AEC
6786  *
6787  * PARAMETERS :
6788  *   @x,y     :
6789  *
6790  * RETURN     : none
6791  *==========================================================================*/
setTouchIndexAec(int x,int y)6792 void QCameraParameters::setTouchIndexAec(int x, int y)
6793 {
6794     char str[32];
6795     snprintf(str, sizeof(str), "%dx%d", x, y);
6796     set(KEY_QC_TOUCH_INDEX_AEC, str);
6797 }
6798 
6799 /*===========================================================================
6800  * FUNCTION   : getTouchIndexAec
6801  *
6802  * DESCRIPTION: get touch index AEC
6803  *
6804  * PARAMETERS :
6805  *   @x,y     :
6806  *
6807  * RETURN     : none
6808  *==========================================================================*/
getTouchIndexAec(int * x,int * y)6809 void QCameraParameters::getTouchIndexAec(int *x, int *y)
6810 {
6811     *x = -1;
6812     *y = -1;
6813 
6814     // Get the current string, if it doesn't exist, leave the -1x-1
6815     const char *p = get(KEY_QC_TOUCH_INDEX_AEC);
6816     if (p == 0)
6817         return;
6818 
6819     int tempX, tempY;
6820     if (parse_pair(p, &tempX, &tempY, 'x') == 0) {
6821         *x = tempX;
6822         *y = tempY;
6823     }
6824 }
6825 
6826 /*===========================================================================
6827  * FUNCTION   : setTouchIndexAf
6828  *
6829  * DESCRIPTION: set touch index AF
6830  *
6831  * PARAMETERS :
6832  *   @x,y     :
6833  *
6834  * RETURN     : none
6835  *==========================================================================*/
setTouchIndexAf(int x,int y)6836 void QCameraParameters::setTouchIndexAf(int x, int y)
6837 {
6838     char str[32];
6839     snprintf(str, sizeof(str), "%dx%d", x, y);
6840     set(KEY_QC_TOUCH_INDEX_AF, str);
6841 }
6842 
6843 /*===========================================================================
6844  * FUNCTION   : getTouchIndexAf
6845  *
6846  * DESCRIPTION: get touch index AF
6847  *
6848  * PARAMETERS :
6849  *   @x,y     :
6850  *
6851  * RETURN     : none
6852  *==========================================================================*/
getTouchIndexAf(int * x,int * y)6853 void QCameraParameters::getTouchIndexAf(int *x, int *y)
6854 {
6855     *x = -1;
6856     *y = -1;
6857 
6858     // Get the current string, if it doesn't exist, leave the -1x-1
6859     const char *p = get(KEY_QC_TOUCH_INDEX_AF);
6860     if (p == 0)
6861         return;
6862 
6863     int tempX, tempY;
6864     if (parse_pair(p, &tempX, &tempY, 'x') == 0) {
6865         *x = tempX;
6866         *y = tempY;
6867     }
6868 }
6869 
6870 /*===========================================================================
6871  * FUNCTION   : getStreamFormat
6872  *
6873  * DESCRIPTION: get stream format by its type
6874  *
6875  * PARAMETERS :
6876  *   @streamType : [input] stream type
6877  *   @format     : [output] stream format
6878  *
6879  * RETURN     : int32_t type of status
6880  *              NO_ERROR  -- success
6881  *              none-zero failure code
6882  *==========================================================================*/
getStreamRotation(cam_stream_type_t streamType,cam_pp_feature_config_t & featureConfig,cam_dimension_t & dim)6883 int32_t QCameraParameters::getStreamRotation(cam_stream_type_t streamType,
6884                                             cam_pp_feature_config_t &featureConfig,
6885                                             cam_dimension_t &dim)
6886 {
6887     int32_t ret = NO_ERROR;
6888     int rotationParam = getInt(KEY_QC_VIDEO_ROTATION);
6889     featureConfig.rotation = ROTATE_0;
6890     int swapDim = 0;
6891     switch (streamType) {
6892     case CAM_STREAM_TYPE_VIDEO:
6893            switch(rotationParam) {
6894             case 90:
6895                featureConfig.feature_mask |= CAM_QCOM_FEATURE_ROTATION;
6896                featureConfig.rotation = ROTATE_90;
6897                swapDim = 1;
6898                break;
6899             case 180:
6900                featureConfig.feature_mask |= CAM_QCOM_FEATURE_ROTATION;
6901                featureConfig.rotation = ROTATE_180;
6902                break;
6903             case 270:
6904                featureConfig.feature_mask |= CAM_QCOM_FEATURE_ROTATION;
6905                featureConfig.rotation = ROTATE_270;
6906                swapDim = 1;
6907               break;
6908             default:
6909                featureConfig.rotation = ROTATE_0;
6910         }
6911         break;
6912     case CAM_STREAM_TYPE_PREVIEW:
6913     case CAM_STREAM_TYPE_POSTVIEW:
6914     case CAM_STREAM_TYPE_SNAPSHOT:
6915     case CAM_STREAM_TYPE_RAW:
6916     case CAM_STREAM_TYPE_METADATA:
6917     case CAM_STREAM_TYPE_OFFLINE_PROC:
6918     case CAM_STREAM_TYPE_DEFAULT:
6919     default:
6920         break;
6921     }
6922 
6923     if (swapDim > 0) {
6924         int w = 0;
6925         w = dim.width;
6926         dim.width = dim.height;
6927         dim.height = w;
6928     }
6929     return ret;
6930 }
6931 
6932 /*===========================================================================
6933  * FUNCTION   : getStreamFormat
6934  *
6935  * DESCRIPTION: get stream format by its type
6936  *
6937  * PARAMETERS :
6938  *   @streamType : [input] stream type
6939  *   @format     : [output] stream format
6940  *
6941  * RETURN     : int32_t type of status
6942  *              NO_ERROR  -- success
6943  *              none-zero failure code
6944  *==========================================================================*/
getStreamFormat(cam_stream_type_t streamType,cam_format_t & format)6945 int32_t QCameraParameters::getStreamFormat(cam_stream_type_t streamType,
6946                                             cam_format_t &format)
6947 {
6948     int32_t ret = NO_ERROR;
6949 
6950     format = CAM_FORMAT_MAX;
6951     switch (streamType) {
6952     case CAM_STREAM_TYPE_PREVIEW:
6953     case CAM_STREAM_TYPE_POSTVIEW:
6954         format = mPreviewFormat;
6955         break;
6956     case CAM_STREAM_TYPE_SNAPSHOT:
6957         if ( mPictureFormat == CAM_FORMAT_YUV_422_NV16 ) {
6958             format = CAM_FORMAT_YUV_422_NV16;
6959         } else {
6960             char prop[PROPERTY_VALUE_MAX];
6961             int snapshotFormat;
6962             memset(prop, 0, sizeof(prop));
6963             property_get("persist.camera.snap.format", prop, "0");
6964             snapshotFormat = atoi(prop);
6965             if(snapshotFormat == 1) {
6966                 format = CAM_FORMAT_YUV_422_NV61;
6967             } else {
6968                 format = CAM_FORMAT_YUV_420_NV21;
6969             }
6970         }
6971         break;
6972     case CAM_STREAM_TYPE_VIDEO:
6973         format = CAM_FORMAT_YUV_420_NV12;
6974         break;
6975     case CAM_STREAM_TYPE_RAW:
6976         if (isRdiMode()) {
6977             format = m_pCapability->rdi_mode_stream_fmt;
6978         } else if (mPictureFormat >= CAM_FORMAT_YUV_RAW_8BIT_YUYV) {
6979             format = (cam_format_t)mPictureFormat;
6980         } else {
6981             char raw_format[PROPERTY_VALUE_MAX];
6982             int rawFormat;
6983             memset(raw_format, 0, sizeof(raw_format));
6984             /*Default value is CAM_FORMAT_BAYER_QCOM_RAW_10BPP_GBRG*/
6985             property_get("persist.camera.raw.format", raw_format, "16");
6986             rawFormat = atoi(raw_format);
6987             format = (cam_format_t)rawFormat;
6988             CDBG_HIGH("%s: Raw stream format %d bundled with snapshot",
6989                    __func__, format);
6990         }
6991         break;
6992     case CAM_STREAM_TYPE_METADATA:
6993     case CAM_STREAM_TYPE_OFFLINE_PROC:
6994     case CAM_STREAM_TYPE_DEFAULT:
6995     default:
6996         break;
6997     }
6998 
6999     return ret;
7000 }
7001 
7002 /*===========================================================================
7003  * FUNCTION   : getFlipMode
7004  *
7005  * DESCRIPTION: get flip mode
7006  *
7007  * PARAMETERS :
7008  *   @cam_intf_parm_type_t : [input] stream type
7009  *
7010  * RETURN     : int type of flip mode
7011  *              0 - no filp
7012  *              1 - FLIP_H
7013  *              2 - FLIP_V
7014  *              3 - FLIP_H | FLIP_V
7015  *==========================================================================*/
getFlipMode(cam_stream_type_t type)7016 int QCameraParameters::getFlipMode(cam_stream_type_t type)
7017 {
7018     const char *str = NULL;
7019     int flipMode = 0; // no flip
7020 
7021     switch(type){
7022     case CAM_STREAM_TYPE_PREVIEW:
7023         if (!isRdiMode()) {
7024             str = get(KEY_QC_PREVIEW_FLIP);
7025         }
7026         break;
7027     case CAM_STREAM_TYPE_VIDEO:
7028         str = get(KEY_QC_VIDEO_FLIP);
7029         break;
7030     case CAM_STREAM_TYPE_SNAPSHOT:
7031     case CAM_STREAM_TYPE_POSTVIEW:
7032         str = get(KEY_QC_SNAPSHOT_PICTURE_FLIP);
7033         break;
7034     default:
7035         CDBG("%s: No flip mode for stream type %d", __func__, type);
7036         break;
7037     }
7038 
7039     if(str != NULL){
7040         //Need give corresponding filp value based on flip mode strings
7041         int value = lookupAttr(FLIP_MODES_MAP,
7042                 sizeof(FLIP_MODES_MAP)/sizeof(QCameraMap), str);
7043         if(value != NAME_NOT_FOUND)
7044             flipMode = value;
7045         }
7046 
7047     CDBG_HIGH("%s: the filp mode of stream type %d is %d .", __func__, type, flipMode);
7048     return flipMode;
7049 }
7050 
7051 /*===========================================================================
7052  * FUNCTION   : isSnapshotFDNeeded
7053  *
7054  * DESCRIPTION: check whether Face Detection Metadata is needed
7055  *
7056  * PARAMETERS : none
7057  *
7058  * RETURN     : bool type of status
7059  *              0 - need
7060  *              1 - not need
7061  *==========================================================================*/
isSnapshotFDNeeded()7062 bool QCameraParameters::isSnapshotFDNeeded()
7063 {
7064     return getInt(KEY_QC_SNAPSHOT_FD_DATA);
7065 }
7066 
7067 /*===========================================================================
7068  * FUNCTION   : getStreamDimension
7069  *
7070  * DESCRIPTION: get stream dimension by its type
7071  *
7072  * PARAMETERS :
7073  *   @streamType : [input] stream type
7074  *   @dim        : [output] stream dimension
7075  *
7076  * RETURN     : int32_t type of status
7077  *              NO_ERROR  -- success
7078  *              none-zero failure code
7079  *==========================================================================*/
getStreamDimension(cam_stream_type_t streamType,cam_dimension_t & dim)7080 int32_t QCameraParameters::getStreamDimension(cam_stream_type_t streamType,
7081                                                cam_dimension_t &dim)
7082 {
7083     int32_t ret = NO_ERROR;
7084     memset(&dim, 0, sizeof(cam_dimension_t));
7085 
7086     switch (streamType) {
7087     case CAM_STREAM_TYPE_PREVIEW:
7088         getPreviewSize(&dim.width, &dim.height);
7089         break;
7090     case CAM_STREAM_TYPE_POSTVIEW:
7091         getPreviewSize(&dim.width, &dim.height);
7092         break;
7093     case CAM_STREAM_TYPE_SNAPSHOT:
7094         if (getRecordingHintValue() == true) {
7095             // live snapshot
7096             getLiveSnapshotSize(dim);
7097         } else {
7098             getPictureSize(&dim.width, &dim.height);
7099         }
7100         break;
7101     case CAM_STREAM_TYPE_VIDEO:
7102         getVideoSize(&dim.width, &dim.height);
7103         break;
7104     case CAM_STREAM_TYPE_RAW:
7105         //dim = m_pCapability->raw_dim;
7106         getRawSize(dim);
7107         break;
7108     case CAM_STREAM_TYPE_METADATA:
7109         dim.width = sizeof(metadata_buffer_t);
7110         dim.height = 1;
7111         break;
7112     case CAM_STREAM_TYPE_OFFLINE_PROC:
7113         break;
7114     case CAM_STREAM_TYPE_DEFAULT:
7115     default:
7116         ALOGE("%s: no dimension for unsupported stream type %d",
7117               __func__, streamType);
7118         ret = BAD_VALUE;
7119         break;
7120     }
7121     return ret;
7122 }
7123 
7124 /*===========================================================================
7125  * FUNCTION   : getPreviewHalPixelFormat
7126  *
7127  * DESCRIPTION: get preview HAL pixel format
7128  *
7129  * PARAMETERS : none
7130  *
7131  * RETURN     : HAL pixel format
7132  *==========================================================================*/
getPreviewHalPixelFormat() const7133 int QCameraParameters::getPreviewHalPixelFormat() const
7134 {
7135     int32_t halPixelFormat;
7136 
7137     switch (mPreviewFormat) {
7138     case CAM_FORMAT_YUV_420_NV12:
7139         halPixelFormat = HAL_PIXEL_FORMAT_YCbCr_420_SP;
7140         break;
7141     case CAM_FORMAT_YUV_420_NV21:
7142         halPixelFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP;
7143         break;
7144     case CAM_FORMAT_YUV_420_NV21_ADRENO:
7145         halPixelFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO;
7146         break;
7147     case CAM_FORMAT_YUV_420_YV12:
7148         halPixelFormat = HAL_PIXEL_FORMAT_YV12;
7149         break;
7150     case CAM_FORMAT_YUV_420_NV12_VENUS:
7151         halPixelFormat = HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS;
7152         break;
7153     case CAM_FORMAT_YUV_422_NV16:
7154     case CAM_FORMAT_YUV_422_NV61:
7155     default:
7156         halPixelFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP;
7157         break;
7158     }
7159     CDBG_HIGH("%s: format %d\n", __func__, halPixelFormat);
7160     return halPixelFormat;
7161 }
7162 
7163 /*===========================================================================
7164  * FUNCTION   : getthumbnailSize
7165  *
7166  * DESCRIPTION: get thumbnail size
7167  *
7168  * PARAMETERS :
7169  *   @width, height : [output] thumbnail width and height
7170  *
7171  * RETURN     : none
7172  *==========================================================================*/
getThumbnailSize(int * width,int * height) const7173 void QCameraParameters::getThumbnailSize(int *width, int *height) const
7174 {
7175     *width = getInt(KEY_JPEG_THUMBNAIL_WIDTH);
7176     *height = getInt(KEY_JPEG_THUMBNAIL_HEIGHT);
7177 }
7178 
7179 /*===========================================================================
7180  * FUNCTION   : getZSLBurstInterval
7181  *
7182  * DESCRIPTION: get ZSL burst interval setting
7183  *
7184  * PARAMETERS : none
7185  *
7186  * RETURN     : ZSL burst interval value
7187  *==========================================================================*/
getZSLBurstInterval()7188 int QCameraParameters::getZSLBurstInterval()
7189 {
7190     int interval = getInt(KEY_QC_ZSL_BURST_INTERVAL);
7191     if (interval < 0) {
7192         interval = 1;
7193     }
7194     return interval;
7195 }
7196 
7197 /*===========================================================================
7198  * FUNCTION   : getZSLQueueDepth
7199  *
7200  * DESCRIPTION: get ZSL queue depth
7201  *
7202  * PARAMETERS : none
7203  *
7204  * RETURN     : ZSL queue depth value
7205  *==========================================================================*/
getZSLQueueDepth()7206 int QCameraParameters::getZSLQueueDepth()
7207 {
7208     int qdepth = getInt(KEY_QC_ZSL_QUEUE_DEPTH);
7209     if (qdepth < 0) {
7210         qdepth = 2;
7211     }
7212     return qdepth;
7213 }
7214 
7215 /*===========================================================================
7216  * FUNCTION   : getZSLBackLookCount
7217  *
7218  * DESCRIPTION: get ZSL backlook count setting
7219  *
7220  * PARAMETERS : none
7221  *
7222  * RETURN     : ZSL backlook count value
7223  *==========================================================================*/
getZSLBackLookCount()7224 int QCameraParameters::getZSLBackLookCount()
7225 {
7226     int look_back = getInt(KEY_QC_ZSL_BURST_LOOKBACK);
7227     if (look_back < 0) {
7228         look_back = 2;
7229     }
7230     return look_back;
7231 }
7232 
7233 /*===========================================================================
7234  * FUNCTION   : getZSLMaxUnmatchedFrames
7235  *
7236  * DESCRIPTION: get allowed ZSL max unmatched frames number
7237  *
7238  * PARAMETERS : none
7239  *
7240  * RETURN     : ZSL backlook count value
7241  *==========================================================================*/
getMaxUnmatchedFramesInQueue()7242 int QCameraParameters::getMaxUnmatchedFramesInQueue()
7243 {
7244     return m_pCapability->min_num_pp_bufs + (m_nBurstNum / 10);
7245 }
7246 
7247 /*===========================================================================
7248  * FUNCTION   : setRecordingHintValue
7249  *
7250  * DESCRIPTION: set recording hint
7251  *
7252  * PARAMETERS :
7253  *   @value   : video hint value
7254  *
7255  * RETURN     : int32_t type of status
7256  *              NO_ERROR  -- success
7257  *              none-zero failure code
7258  *==========================================================================*/
setRecordingHintValue(int32_t value)7259 int QCameraParameters::setRecordingHintValue(int32_t value)
7260 {
7261     CDBG_HIGH("%s: VideoHint = %d", __func__, value);
7262     bool newValue = (value > 0)? true : false;
7263 
7264     if ( m_bRecordingHint != newValue ) {
7265         m_bNeedRestart = true;
7266         m_bRecordingHint_new = newValue;
7267     } else {
7268         m_bRecordingHint_new = m_bRecordingHint;
7269     }
7270     return AddSetParmEntryToBatch(m_pParamBuf,
7271                                   CAM_INTF_PARM_RECORDING_HINT,
7272                                   sizeof(value),
7273                                   &value);
7274 }
7275 
7276 /*===========================================================================
7277  * FUNCTION   : getNumOfSnapshots
7278  *
7279  * DESCRIPTION: get number of snapshot per shutter
7280  *
7281  * PARAMETERS : none
7282  *
7283  * RETURN     : number of snapshot per shutter
7284  *==========================================================================*/
getNumOfSnapshots()7285 uint8_t QCameraParameters::getNumOfSnapshots()
7286 {
7287     int numOfSnapshot = getInt(KEY_QC_NUM_SNAPSHOT_PER_SHUTTER);
7288     if (numOfSnapshot <= 0) {
7289         numOfSnapshot = 1; // set to default value
7290     }
7291 
7292     /* update the count for refocus */
7293     if (isUbiRefocus())
7294        numOfSnapshot += UfOutputCount();
7295 
7296     return (uint8_t)numOfSnapshot;
7297 }
7298 
7299 /*===========================================================================
7300  * FUNCTION   : getBurstCountForAdvancedCapture
7301  *
7302  * DESCRIPTION: get burst count for advanced capture.
7303  *
7304  * PARAMETERS : none
7305  *
7306  * RETURN     : number of snapshot required for advanced capture.
7307  *==========================================================================*/
getBurstCountForAdvancedCapture()7308 uint8_t QCameraParameters::getBurstCountForAdvancedCapture()
7309 {
7310     int burstCount = 0;
7311     if (isUbiFocusEnabled()) {
7312         //number of snapshots required for Ubi Focus.
7313         burstCount = m_pCapability->ubifocus_af_bracketing_need.burst_count;
7314     } else if (isOptiZoomEnabled()) {
7315         //number of snapshots required for Opti Zoom.
7316         burstCount = m_pCapability->opti_zoom_settings_need.burst_count;
7317     } else if (isChromaFlashEnabled()) {
7318         //number of snapshots required for Chroma Flash.
7319         //TODO: remove hardcoded value, add in capability.
7320         burstCount = 2;
7321     } else if (isHDREnabled()) {
7322         //number of snapshots required for HDR.
7323         burstCount = m_pCapability->hdr_bracketing_setting.num_frames;
7324     } else if (isAEBracketEnabled()) {
7325       burstCount = 0;
7326       const char *str_val = m_AEBracketingClient.values;
7327       if ((str_val != NULL) && (strlen(str_val) > 0)) {
7328           char prop[PROPERTY_VALUE_MAX];
7329           memset(prop, 0, sizeof(prop));
7330           strcpy(prop, str_val);
7331           char *saveptr = NULL;
7332           char *token = strtok_r(prop, ",", &saveptr);
7333           while (token != NULL) {
7334               token = strtok_r(NULL, ",", &saveptr);
7335               burstCount++;
7336           }
7337       }
7338     }
7339 
7340     if (burstCount <= 0) {
7341         burstCount = 1;
7342     }
7343     return (uint8_t)burstCount;
7344 }
7345 
7346 /*===========================================================================
7347  * FUNCTION   : getNumOfRetroSnapshots
7348  *
7349  * DESCRIPTION: get number of retro active snapshots per shutter
7350  *
7351  * PARAMETERS : none
7352  *
7353  * RETURN     : number of retro active snapshots per shutter
7354  *==========================================================================*/
getNumOfRetroSnapshots()7355 uint8_t QCameraParameters::getNumOfRetroSnapshots()
7356 {
7357     int numOfRetroSnapshots = getInt(KEY_QC_NUM_RETRO_BURST_PER_SHUTTER);
7358     if (numOfRetroSnapshots < 0) {
7359         numOfRetroSnapshots = 0;
7360     }
7361     CDBG_HIGH("%s: [ZSL Retro] : numOfRetroSnaps - %d", __func__, numOfRetroSnapshots);
7362     return (uint8_t)numOfRetroSnapshots;
7363 }
7364 
7365 /*===========================================================================
7366  * FUNCTION   : getBurstLEDOnPeriod
7367  *
7368  * DESCRIPTION: get burst LED on period
7369  *
7370  * PARAMETERS : none
7371  *
7372  * RETURN     : burst LED on period
7373  *==========================================================================*/
getBurstLEDOnPeriod()7374 int QCameraParameters::getBurstLEDOnPeriod()
7375 {
7376   CDBG_HIGH("%s: [ZSL Retro] burst LED ON period: %d", __func__, m_nBurstLEDOnPeriod);
7377   return m_nBurstLEDOnPeriod;
7378 }
7379 
7380 /*===========================================================================
7381  * FUNCTION   : getNumOfExtraHDRInBufsIfNeeded
7382  *
7383  * DESCRIPTION: get number of extra input buffers needed by HDR
7384  *
7385  * PARAMETERS : none
7386  *
7387  * RETURN     : number of extra buffers needed by HDR; 0 if not HDR enabled
7388  *==========================================================================*/
getNumOfExtraHDRInBufsIfNeeded()7389 uint8_t QCameraParameters::getNumOfExtraHDRInBufsIfNeeded()
7390 {
7391     uint8_t numOfBufs = 0;
7392 
7393     if (isHDREnabled()) {
7394         numOfBufs += m_pCapability->hdr_bracketing_setting.num_frames;
7395         if (isHDR1xFrameEnabled() && isHDR1xExtraBufferNeeded()) {
7396             numOfBufs++;
7397         }
7398         numOfBufs--; // Only additional buffers need to be returned
7399     }
7400 
7401     return numOfBufs * getBurstNum();
7402 }
7403 
7404 /*===========================================================================
7405  * FUNCTION   : getNumOfExtraHDROutBufsIfNeeded
7406  *
7407  * DESCRIPTION: get number of extra output buffers needed by HDR
7408  *
7409  * PARAMETERS : none
7410  *
7411  * RETURN     : number of extra buffers needed by HDR; 0 if not HDR enabled
7412  *==========================================================================*/
getNumOfExtraHDROutBufsIfNeeded()7413 uint8_t QCameraParameters::getNumOfExtraHDROutBufsIfNeeded()
7414 {
7415     uint8_t numOfBufs = 0;
7416 
7417     if (isHDREnabled() && isHDR1xFrameEnabled()) {
7418         numOfBufs++;
7419     }
7420 
7421     return numOfBufs * getBurstNum();
7422 }
7423 
7424 /*===========================================================================
7425  * FUNCTION   : getBurstNum
7426  *
7427  * DESCRIPTION: get burst number of snapshot
7428  *
7429  * PARAMETERS : none
7430  *
7431  * RETURN     : number of burst
7432  *==========================================================================*/
getBurstNum()7433 int QCameraParameters::getBurstNum()
7434 {
7435     CDBG_HIGH("%s: m_nBurstNum = %d", __func__, m_nBurstNum);
7436     return m_nBurstNum;
7437 }
7438 
7439 /*===========================================================================
7440  * FUNCTION   : getJpegQuality
7441  *
7442  * DESCRIPTION: get jpeg encoding quality
7443  *
7444  * PARAMETERS : none
7445  *
7446  * RETURN     : jpeg encoding quality
7447  *==========================================================================*/
getJpegQuality()7448 int QCameraParameters::getJpegQuality()
7449 {
7450     int quality = getInt(KEY_JPEG_QUALITY);
7451     if (quality < 0) {
7452         quality = 85; // set to default quality value
7453     }
7454     return quality;
7455 }
7456 
7457 /*===========================================================================
7458  * FUNCTION   : getJpegRotation
7459  *
7460  * DESCRIPTION: get rotation value
7461  *
7462  * PARAMETERS : none
7463  *
7464  * RETURN     : rotation value
7465  *==========================================================================*/
getJpegRotation()7466 int QCameraParameters::getJpegRotation() {
7467     int rotation = getInt(KEY_ROTATION);
7468     if (rotation < 0) {
7469         rotation = 0;
7470     }
7471     return rotation;
7472 }
7473 
7474 /*===========================================================================
7475  * FUNCTION   : parseGPSCoordinate
7476  *
7477  * DESCRIPTION: parse GPS coordinate string
7478  *
7479  * PARAMETERS :
7480  *   @coord_str : [input] coordinate string
7481  *   @coord     : [output]  ptr to struct to store coordinate
7482  *
7483  * RETURN     : int32_t type of status
7484  *              NO_ERROR  -- success
7485  *              none-zero failure code
7486  *==========================================================================*/
parseGPSCoordinate(const char * coord_str,rat_t * coord)7487 int QCameraParameters::parseGPSCoordinate(const char *coord_str, rat_t* coord)
7488 {
7489     if(coord == NULL) {
7490         ALOGE("%s: error, invalid argument coord == NULL", __func__);
7491         return BAD_VALUE;
7492     }
7493     float degF = atof(coord_str);
7494     if (degF < 0) {
7495         degF = -degF;
7496     }
7497     float minF = (degF - (int) degF) * 60;
7498     float secF = (minF - (int) minF) * 60;
7499 
7500     getRational(&coord[0], (int)degF, 1);
7501     getRational(&coord[1], (int)minF, 1);
7502     getRational(&coord[2], (int)(secF * 10000), 10000);
7503     return NO_ERROR;
7504 }
7505 
7506 /*===========================================================================
7507  * FUNCTION   : getExifDateTime
7508  *
7509  * DESCRIPTION: query exif date time
7510  *
7511  * PARAMETERS :
7512  *   @dateTime : string to store exif date time
7513  *   @count    : lenght of the dateTime string
7514  *
7515  * RETURN     : int32_t type of status
7516  *              NO_ERROR  -- success
7517  *              none-zero failure code
7518  *==========================================================================*/
getExifDateTime(char * dateTime,uint32_t & count)7519 int32_t QCameraParameters::getExifDateTime(char *dateTime, uint32_t &count)
7520 {
7521     //get time and date from system
7522     time_t rawtime;
7523     struct tm * timeinfo = NULL;
7524     memset(&rawtime, 0, sizeof(rawtime));
7525     time(&rawtime);
7526     timeinfo = localtime (&rawtime);
7527     if (timeinfo != NULL && count >= 20) {
7528         //Write datetime according to EXIF Spec
7529         //"YYYY:MM:DD HH:MM:SS" (20 chars including \0)
7530         snprintf(dateTime, 20, "%04d:%02d:%02d %02d:%02d:%02d",
7531                  timeinfo->tm_year + 1900, timeinfo->tm_mon + 1,
7532                  timeinfo->tm_mday, timeinfo->tm_hour,
7533                  timeinfo->tm_min, timeinfo->tm_sec);
7534         count = 20;
7535         return NO_ERROR;
7536     }
7537     return UNKNOWN_ERROR;
7538 }
7539 
7540 /*===========================================================================
7541  * FUNCTION   : getRational
7542  *
7543  * DESCRIPTION: compose rational struct
7544  *
7545  * PARAMETERS :
7546  *   @rat     : ptr to struct to store rational info
7547  *   @num     :num of the rational
7548  *   @denom   : denom of the rational
7549  *
7550  * RETURN     : int32_t type of status
7551  *              NO_ERROR  -- success
7552  *              none-zero failure code
7553  *==========================================================================*/
getRational(rat_t * rat,int num,int denom)7554 int32_t QCameraParameters::getRational(rat_t *rat, int num, int denom)
7555 {
7556     if (NULL == rat) {
7557         ALOGE("%s: NULL rat input", __func__);
7558         return BAD_VALUE;
7559     }
7560     rat->num = num;
7561     rat->denom = denom;
7562     return NO_ERROR;
7563 }
7564 
7565 /*===========================================================================
7566  * FUNCTION   : getExifFocalLength
7567  *
7568  * DESCRIPTION: get exif focal lenght
7569  *
7570  * PARAMETERS :
7571  *   @focalLength : ptr to rational strcut to store focal lenght
7572  *
7573  * RETURN     : int32_t type of status
7574  *              NO_ERROR  -- success
7575  *              none-zero failure code
7576  *==========================================================================*/
getExifFocalLength(rat_t * focalLength)7577 int32_t QCameraParameters::getExifFocalLength(rat_t *focalLength)
7578 {
7579     int focalLengthValue =
7580         (int)(getFloat(QCameraParameters::KEY_FOCAL_LENGTH) * FOCAL_LENGTH_DECIMAL_PRECISION);
7581     return getRational(focalLength, focalLengthValue, FOCAL_LENGTH_DECIMAL_PRECISION);
7582 }
7583 
7584 /*===========================================================================
7585  * FUNCTION   : getExifIsoSpeed
7586  *
7587  * DESCRIPTION: get exif ISO speed
7588  *
7589  * PARAMETERS : none
7590  *
7591  * RETURN     : ISO speed value
7592  *==========================================================================*/
getExifIsoSpeed()7593 uint16_t QCameraParameters::getExifIsoSpeed()
7594 {
7595     uint16_t isoSpeed = 0;
7596     const char *iso_str = get(QCameraParameters::KEY_QC_ISO_MODE);
7597     int iso_index = lookupAttr(ISO_MODES_MAP,
7598         sizeof(ISO_MODES_MAP)/sizeof(ISO_MODES_MAP[0]), iso_str);
7599     switch (iso_index) {
7600     case CAM_ISO_MODE_AUTO:
7601         isoSpeed = 0;
7602         break;
7603     case CAM_ISO_MODE_DEBLUR:
7604         isoSpeed = 1;
7605         break;
7606     case CAM_ISO_MODE_100:
7607         isoSpeed = 100;
7608         break;
7609     case CAM_ISO_MODE_200:
7610         isoSpeed = 200;
7611         break;
7612     case CAM_ISO_MODE_400:
7613         isoSpeed = 400;
7614         break;
7615     case CAM_ISO_MODE_800:
7616         isoSpeed = 800;
7617         break;
7618     case CAM_ISO_MODE_1600:
7619         isoSpeed = 1600;
7620         break;
7621     }
7622     return isoSpeed;
7623 }
7624 
7625 /*===========================================================================
7626  * FUNCTION   : getExifGpsProcessingMethod
7627  *
7628  * DESCRIPTION: get GPS processing method
7629  *
7630  * PARAMETERS :
7631  *   @gpsProcessingMethod : string to store GPS process method
7632  *   @count               : lenght of the string
7633  *
7634  * RETURN     : int32_t type of status
7635  *              NO_ERROR  -- success
7636  *              none-zero failure code
7637  *==========================================================================*/
getExifGpsProcessingMethod(char * gpsProcessingMethod,uint32_t & count)7638 int32_t QCameraParameters::getExifGpsProcessingMethod(char *gpsProcessingMethod,
7639                                                       uint32_t &count)
7640 {
7641     const char *str = get(KEY_GPS_PROCESSING_METHOD);
7642     if(str != NULL) {
7643         memcpy(gpsProcessingMethod, ExifAsciiPrefix, EXIF_ASCII_PREFIX_SIZE);
7644         count = EXIF_ASCII_PREFIX_SIZE;
7645         strncpy(gpsProcessingMethod + EXIF_ASCII_PREFIX_SIZE, str, strlen(str));
7646         count += strlen(str);
7647         gpsProcessingMethod[count++] = '\0'; // increase 1 for the last NULL char
7648         return NO_ERROR;
7649     } else {
7650         return BAD_VALUE;
7651     }
7652 }
7653 
7654 /*===========================================================================
7655  * FUNCTION   : getExifLatitude
7656  *
7657  * DESCRIPTION: get exif latitude
7658  *
7659  * PARAMETERS :
7660  *   @latitude : ptr to rational struct to store latitude info
7661  *   @ladRef   : charater to indicate latitude reference
7662  *
7663  * RETURN     : int32_t type of status
7664  *              NO_ERROR  -- success
7665  *              none-zero failure code
7666  *==========================================================================*/
getExifLatitude(rat_t * latitude,char * latRef)7667 int32_t QCameraParameters::getExifLatitude(rat_t *latitude,
7668                                            char *latRef)
7669 {
7670     const char *str = get(KEY_GPS_LATITUDE);
7671     if(str != NULL) {
7672         parseGPSCoordinate(str, latitude);
7673 
7674         //set Latitude Ref
7675         float latitudeValue = getFloat(KEY_GPS_LATITUDE);
7676         if(latitudeValue < 0.0f) {
7677             latRef[0] = 'S';
7678         } else {
7679             latRef[0] = 'N';
7680         }
7681         latRef[1] = '\0';
7682         return NO_ERROR;
7683     }else{
7684         return BAD_VALUE;
7685     }
7686 }
7687 
7688 /*===========================================================================
7689  * FUNCTION   : getExifLongitude
7690  *
7691  * DESCRIPTION: get exif longitude
7692  *
7693  * PARAMETERS :
7694  *   @longitude : ptr to rational struct to store longitude info
7695  *   @lonRef    : charater to indicate longitude reference
7696  *
7697  * RETURN     : int32_t type of status
7698  *              NO_ERROR  -- success
7699  *              none-zero failure code
7700  *==========================================================================*/
getExifLongitude(rat_t * longitude,char * lonRef)7701 int32_t QCameraParameters::getExifLongitude(rat_t *longitude,
7702                                             char *lonRef)
7703 {
7704     const char *str = get(KEY_GPS_LONGITUDE);
7705     if(str != NULL) {
7706         parseGPSCoordinate(str, longitude);
7707 
7708         //set Longitude Ref
7709         float longitudeValue = getFloat(KEY_GPS_LONGITUDE);
7710         if(longitudeValue < 0.0f) {
7711             lonRef[0] = 'W';
7712         } else {
7713             lonRef[0] = 'E';
7714         }
7715         lonRef[1] = '\0';
7716         return NO_ERROR;
7717     }else{
7718         return BAD_VALUE;
7719     }
7720 }
7721 
7722 /*===========================================================================
7723  * FUNCTION   : getExifAltitude
7724  *
7725  * DESCRIPTION: get exif altitude
7726  *
7727  * PARAMETERS :
7728  *   @altitude : ptr to rational struct to store altitude info
7729  *   @altRef   : charater to indicate altitude reference
7730  *
7731  * RETURN     : int32_t type of status
7732  *              NO_ERROR  -- success
7733  *              none-zero failure code
7734  *==========================================================================*/
getExifAltitude(rat_t * altitude,char * altRef)7735 int32_t QCameraParameters::getExifAltitude(rat_t *altitude,
7736                                            char *altRef)
7737 {
7738     const char *str = get(KEY_GPS_ALTITUDE);
7739     if(str != NULL) {
7740         double value = atof(str);
7741         *altRef = 0;
7742         if(value < 0){
7743             *altRef = 1;
7744             value = -value;
7745         }
7746         return getRational(altitude, value*1000, 1000);
7747     }else{
7748         return BAD_VALUE;
7749     }
7750 }
7751 
7752 /*===========================================================================
7753  * FUNCTION   : getExifGpsDateTimeStamp
7754  *
7755  * DESCRIPTION: get exif GPS date time stamp
7756  *
7757  * PARAMETERS :
7758  *   @gpsDateStamp : GPS date time stamp string
7759  *   @bufLen       : length of the string
7760  *   @gpsTimeStamp : ptr to rational struct to store time stamp info
7761  *
7762  * RETURN     : int32_t type of status
7763  *              NO_ERROR  -- success
7764  *              none-zero failure code
7765  *==========================================================================*/
getExifGpsDateTimeStamp(char * gpsDateStamp,uint32_t bufLen,rat_t * gpsTimeStamp)7766 int32_t QCameraParameters::getExifGpsDateTimeStamp(char *gpsDateStamp,
7767                                                    uint32_t bufLen,
7768                                                    rat_t *gpsTimeStamp)
7769 {
7770     const char *str = get(KEY_GPS_TIMESTAMP);
7771     if(str != NULL) {
7772         time_t unixTime = (time_t)atol(str);
7773         struct tm *UTCTimestamp = gmtime(&unixTime);
7774 
7775         strftime(gpsDateStamp, bufLen, "%Y:%m:%d", UTCTimestamp);
7776 
7777         getRational(&gpsTimeStamp[0], UTCTimestamp->tm_hour, 1);
7778         getRational(&gpsTimeStamp[1], UTCTimestamp->tm_min, 1);
7779         getRational(&gpsTimeStamp[2], UTCTimestamp->tm_sec, 1);
7780 
7781         return NO_ERROR;
7782     } else {
7783         return BAD_VALUE;
7784     }
7785 }
7786 
7787 /*===========================================================================
7788  * FUNCTION   : updateFocusDistances
7789  *
7790  * DESCRIPTION: update focus distances
7791  *
7792  * PARAMETERS :
7793  *   @focusDistances : ptr to focus distance info
7794  *
7795  * RETURN     : int32_t type of status
7796  *              NO_ERROR  -- success
7797  *              none-zero failure code
7798  *==========================================================================*/
updateFocusDistances(cam_focus_distances_info_t * focusDistances)7799 int32_t QCameraParameters::updateFocusDistances(cam_focus_distances_info_t *focusDistances)
7800 {
7801     String8 str;
7802     char buffer[32] = {0};
7803     //set all distances to infinity if focus mode is infinity
7804     if(mFocusMode == CAM_FOCUS_MODE_INFINITY) {
7805         str.append("Infinity,Infinity,Infinity");
7806     } else {
7807         snprintf(buffer, sizeof(buffer), "%f", focusDistances->focus_distance[0]);
7808         str.append(buffer);
7809         snprintf(buffer, sizeof(buffer), ",%f", focusDistances->focus_distance[1]);
7810         str.append(buffer);
7811         snprintf(buffer, sizeof(buffer), ",%f", focusDistances->focus_distance[2]);
7812         str.append(buffer);
7813     }
7814     CDBG_HIGH("%s: setting KEY_FOCUS_DISTANCES as %s", __FUNCTION__, str.string());
7815     set(QCameraParameters::KEY_FOCUS_DISTANCES, str.string());
7816     return NO_ERROR;
7817 }
7818 
7819 /*===========================================================================
7820  * FUNCTION   : updateRecordingHintValue
7821  *
7822  * DESCRIPTION: update recording hint locally and to daemon
7823  *
7824  * PARAMETERS :
7825  *   @value   : video hint value
7826  *
7827  * RETURN     : int32_t type of status
7828  *              NO_ERROR  -- success
7829  *              none-zero failure code
7830  *==========================================================================*/
updateRecordingHintValue(int32_t value)7831 int32_t QCameraParameters::updateRecordingHintValue(int32_t value)
7832 {
7833     int32_t rc = NO_ERROR;
7834     if(initBatchUpdate(m_pParamBuf) < 0 ) {
7835         ALOGE("%s:Failed to initialize group update table", __func__);
7836         return BAD_TYPE;
7837     }
7838 
7839     rc = setRecordingHintValue(value);
7840     if (rc != NO_ERROR) {
7841         ALOGE("%s:Failed to update table", __func__);
7842         return rc;
7843     }
7844 
7845     rc = commitSetBatch();
7846     if (rc != NO_ERROR) {
7847         ALOGE("%s:Failed to update recording hint", __func__);
7848         return rc;
7849     }
7850 
7851     return rc;
7852 }
7853 
7854 /*===========================================================================
7855  * FUNCTION   : setHistogram
7856  *
7857  * DESCRIPTION: set histogram
7858  *
7859  * PARAMETERS :
7860  *   @enabled : if histogram is enabled
7861  *
7862  * RETURN     : int32_t type of status
7863  *              NO_ERROR  -- success
7864  *              none-zero failure code
7865  *==========================================================================*/
setHistogram(bool enabled)7866 int32_t QCameraParameters::setHistogram(bool enabled)
7867 {
7868     if(m_bHistogramEnabled == enabled) {
7869         CDBG_HIGH("%s: histogram flag not changed, no ops here", __func__);
7870         return NO_ERROR;
7871     }
7872 
7873     // set parm for histogram
7874     if(initBatchUpdate(m_pParamBuf) < 0 ) {
7875         ALOGE("%s:Failed to initialize group update table", __func__);
7876         return BAD_TYPE;
7877     }
7878 
7879     int32_t value = enabled;
7880     int32_t rc = NO_ERROR;
7881     rc = AddSetParmEntryToBatch(m_pParamBuf,
7882                                 CAM_INTF_PARM_HISTOGRAM,
7883                                 sizeof(value),
7884                                 &value);
7885     if (rc != NO_ERROR) {
7886         ALOGE("%s:Failed to update table", __func__);
7887         return rc;
7888     }
7889 
7890     rc = commitSetBatch();
7891     if (rc != NO_ERROR) {
7892         ALOGE("%s:Failed to set histogram", __func__);
7893         return rc;
7894     }
7895 
7896     m_bHistogramEnabled = enabled;
7897 
7898     CDBG_HIGH(" Histogram -> %s", m_bHistogramEnabled ? "Enabled" : "Disabled");
7899 
7900     return rc;
7901 }
7902 
7903 /*===========================================================================
7904  * FUNCTION   : setFaceDetectionOption
7905  *
7906  * DESCRIPTION: set if face detection is enabled by SendCommand
7907  *
7908  * PARAMETERS :
7909  *   @enabled : bool flag if face detection should be enabled
7910  *
7911  * RETURN     : int32_t type of status
7912  *              NO_ERROR  -- success
7913  *              none-zero failure code
7914  *==========================================================================*/
setFaceDetectionOption(bool enabled)7915  int32_t QCameraParameters::setFaceDetectionOption(bool enabled)
7916 {
7917     m_bFaceDetectionOn = enabled;
7918     return NO_ERROR;
7919 }
7920 
7921 /*===========================================================================
7922  * FUNCTION   : setFaceDetection
7923  *
7924  * DESCRIPTION: set face detection
7925  *
7926  * PARAMETERS :
7927  *   @enabled : if face detection is enabled
7928  *   @initCommit : if configuration list need to be initialized and commited
7929  *
7930  * RETURN     : int32_t type of status
7931  *              NO_ERROR  -- success
7932  *              none-zero failure code
7933  *==========================================================================*/
setFaceDetection(bool enabled,bool initCommit)7934 int32_t QCameraParameters::setFaceDetection(bool enabled, bool initCommit)
7935 {
7936     int faceProcMask = m_nFaceProcMask;
7937     // set face detection mask
7938     if (enabled) {
7939         faceProcMask |= CAM_FACE_PROCESS_MASK_DETECTION;
7940     } else {
7941         faceProcMask &= ~CAM_FACE_PROCESS_MASK_DETECTION;
7942     }
7943 
7944     if(m_nFaceProcMask == faceProcMask) {
7945         CDBG_HIGH("%s: face process mask not changed, no ops here", __func__);
7946         return NO_ERROR;
7947     }
7948 
7949     m_nFaceProcMask = faceProcMask;
7950 
7951     // set parm for face detection
7952     int requested_faces = getInt(KEY_QC_MAX_NUM_REQUESTED_FACES);
7953     cam_fd_set_parm_t fd_set_parm;
7954     memset(&fd_set_parm, 0, sizeof(cam_fd_set_parm_t));
7955     fd_set_parm.fd_mode = faceProcMask;
7956     fd_set_parm.num_fd = requested_faces;
7957 
7958     CDBG_HIGH("[KPI Perf] %s: PROFILE_FACE_DETECTION_VALUE = %d num_fd = %d",
7959           __func__, faceProcMask,requested_faces);
7960 
7961     if (initCommit) {
7962         if(initBatchUpdate(m_pParamBuf) < 0 ) {
7963             ALOGE("%s:Failed to initialize group update table", __func__);
7964             return BAD_TYPE;
7965         }
7966     }
7967 
7968     int32_t rc = NO_ERROR;
7969 
7970     rc = AddSetParmEntryToBatch(m_pParamBuf,
7971                                 CAM_INTF_PARM_FD,
7972                                 sizeof(fd_set_parm),
7973                                 &fd_set_parm);
7974     if (rc != NO_ERROR) {
7975         ALOGE("%s:Failed to update table", __func__);
7976         return rc;
7977     }
7978 
7979     if (initCommit) {
7980         rc = commitSetBatch();
7981         if (rc != NO_ERROR) {
7982             ALOGE("%s:Failed to set face detection parm", __func__);
7983             return rc;
7984         }
7985     }
7986 
7987     CDBG_HIGH("%s: FaceProcMask -> %d", __func__, m_nFaceProcMask);
7988 
7989     return rc;
7990 }
7991 
7992 /*===========================================================================
7993  * FUNCTION   : setFrameSkip
7994  *
7995  * DESCRIPTION: send ISP frame skip pattern to camera daemon
7996  *
7997  * PARAMETERS :
7998  *   @pattern : skip pattern for ISP
7999  *
8000  * RETURN     : int32_t type of status
8001  *              NO_ERROR  -- success
8002  *              none-zero failure code
8003  *==========================================================================*/
setFrameSkip(enum msm_vfe_frame_skip_pattern pattern)8004 int32_t QCameraParameters::setFrameSkip(enum msm_vfe_frame_skip_pattern pattern)
8005 {
8006     int32_t rc = NO_ERROR;
8007     int32_t value = (int32_t)pattern;
8008 
8009     if ( m_pParamBuf == NULL ) {
8010         return NO_INIT;
8011     }
8012 
8013     if(initBatchUpdate(m_pParamBuf) < 0 ) {
8014         ALOGE("%s:Failed to initialize group update table", __func__);
8015         return BAD_TYPE;
8016     }
8017 
8018     rc = AddSetParmEntryToBatch(m_pParamBuf,
8019                                 CAM_INTF_PARM_FRAMESKIP,
8020                                 sizeof(value),
8021                                 &value);
8022     if (rc != NO_ERROR) {
8023         ALOGE("%s:Failed to update table", __func__);
8024         return rc;
8025     }
8026 
8027     rc = commitSetBatch();
8028     if (rc != NO_ERROR) {
8029         ALOGE("%s:Failed to set frameskip info parm", __func__);
8030         return rc;
8031     }
8032 
8033     return rc;
8034 }
8035 
updateRAW(cam_dimension_t max_dim)8036 int32_t QCameraParameters::updateRAW(cam_dimension_t max_dim)
8037 {
8038     int32_t rc = NO_ERROR;
8039     cam_dimension_t raw_dim;
8040 
8041     if (max_dim.width == 0 || max_dim.height == 0) {
8042         max_dim = m_pCapability->raw_dim[0];
8043     }
8044 
8045     if(initBatchUpdate(m_pParamBuf) < 0 ) {
8046         ALOGE("%s:Failed to initialize group update table", __func__);
8047         return BAD_TYPE;
8048     }
8049 
8050     rc = AddSetParmEntryToBatch(m_pParamBuf,
8051                                 CAM_INTF_PARM_MAX_DIMENSION,
8052                                 sizeof(cam_dimension_t),
8053                                 &max_dim);
8054     if (rc != NO_ERROR) {
8055         ALOGE("%s:Failed to update table for CAM_INTF_PARM_MAX_DIMENSION ", __func__);
8056         return rc;
8057     }
8058 
8059     rc = commitSetBatch();
8060     if (rc != NO_ERROR) {
8061         ALOGE("%s:Failed to set lock CAM_INTF_PARM_MAX_DIMENSION parm", __func__);
8062         return rc;
8063     }
8064 
8065     if(initBatchUpdate(m_pParamBuf) < 0 ) {
8066         ALOGE("%s:Failed to initialize group update table", __func__);
8067         return BAD_TYPE;
8068     }
8069 
8070     rc = AddGetParmEntryToBatch(m_pParamBuf,
8071                                 CAM_INTF_PARM_RAW_DIMENSION);
8072     if (rc != NO_ERROR) {
8073         ALOGE("%s:Failed to get CAM_INTF_PARM_RAW_DIMENSION", __func__);
8074         return rc;
8075     }
8076 
8077     rc = commitGetBatch();
8078     if (rc != NO_ERROR) {
8079         ALOGE("%s:Failed to get commit CAM_INTF_PARM_RAW_DIMENSION", __func__);
8080         return rc;
8081     }
8082     memcpy(&raw_dim,
8083             POINTER_OF_PARAM(CAM_INTF_PARM_RAW_DIMENSION,m_pParamBuf),
8084             sizeof(cam_dimension_t));
8085     CDBG_HIGH("%s : RAW Dimension = %d X %d",__func__,raw_dim.width,raw_dim.height);
8086     if (raw_dim.width == 0 || raw_dim.height == 0) {
8087         ALOGE("%s: Error getting RAW size. Setting to Capability value",__func__);
8088         raw_dim = m_pCapability->raw_dim[0];
8089     }
8090     setRawSize(raw_dim);
8091     return rc;
8092 }
8093 
8094 /*===========================================================================
8095  * FUNCTION   : setHDRSceneEnable
8096  *
8097  * DESCRIPTION: sets hdr scene deteced flag
8098  *
8099  * PARAMETERS :
8100  *   @bflag : hdr scene deteced
8101  *
8102  * RETURN     : nothing
8103  *==========================================================================*/
setHDRSceneEnable(bool bflag)8104 void QCameraParameters::setHDRSceneEnable(bool bflag)
8105 {
8106     bool bupdate = false;
8107     if (m_HDRSceneEnabled != bflag) {
8108         bupdate = true;
8109     }
8110     m_HDRSceneEnabled = bflag;
8111 
8112     if (bupdate) {
8113         updateFlash(true);
8114     }
8115 }
8116 
8117 /*===========================================================================
8118  * FUNCTION   : getASDStateString
8119  *
8120  * DESCRIPTION: get ASD result in string format
8121  *
8122  * PARAMETERS :
8123  *   @scene : selected scene mode
8124  *
8125  * RETURN     : int32_t type of status
8126  *              NO_ERROR  -- success
8127  *              none-zero failure code
8128  *==========================================================================*/
getASDStateString(cam_auto_scene_t scene)8129  const char *QCameraParameters::getASDStateString(cam_auto_scene_t scene)
8130 {
8131     switch (scene) {
8132       case S_NORMAL :
8133         return "Normal";
8134       case S_SCENERY:
8135         return "Scenery";
8136       case S_PORTRAIT:
8137         return "Portrait";
8138       case S_PORTRAIT_BACKLIGHT:
8139         return "Portrait-Backlight";
8140       case S_SCENERY_BACKLIGHT:
8141         return "Scenery-Backlight";
8142       case S_BACKLIGHT:
8143         return "Backlight";
8144       default:
8145         return "<Unknown!>";
8146       }
8147 }
8148 
8149 /*===========================================================================
8150  * FUNCTION   : parseNDimVector
8151  *
8152  * DESCRIPTION: helper function to parse a string like "(1, 2, 3, 4, ..., N)"
8153  *              into N-dimension vector
8154  *
8155  * PARAMETERS :
8156  *   @str     : string to be parsed
8157  *   @num     : output array of size N to store vector element values
8158  *   @N       : number of dimension
8159  *   @delim   : delimeter to seperete string
8160  *
8161  * RETURN     : int32_t type of status
8162  *              NO_ERROR  -- success
8163  *              none-zero failure code
8164  *==========================================================================*/
parseNDimVector(const char * str,int * num,int N,char delim=',')8165 int32_t QCameraParameters::parseNDimVector(const char *str, int *num, int N, char delim = ',')
8166 {
8167     char *start, *end;
8168     if (num == NULL) {
8169         ALOGE("%s: Invalid output array (num == NULL)", __func__);
8170         return BAD_VALUE;
8171     }
8172 
8173     //check if string starts and ends with parantheses
8174     if(str[0] != '(' || str[strlen(str)-1] != ')') {
8175         ALOGE("%s: Invalid format of string %s, valid format is (n1, n2, n3, n4 ...)",
8176               __func__, str);
8177         return BAD_VALUE;
8178     }
8179     start = (char*) str;
8180     start++;
8181     for(int i=0; i<N; i++) {
8182         *(num+i) = (int) strtol(start, &end, 10);
8183         if(*end != delim && i < N-1) {
8184             ALOGE("%s: Cannot find delimeter '%c' in string \"%s\". end = %c",
8185                   __func__, delim, str, *end);
8186             return -1;
8187         }
8188         start = end+1;
8189     }
8190     return NO_ERROR;
8191 }
8192 
8193 /*===========================================================================
8194  * FUNCTION   : parseCameraAreaString
8195  *
8196  * DESCRIPTION: helper function to parse a string of camera areas like
8197  *              "(1, 2, 3, 4, 5),(1, 2, 3, 4, 5),..."
8198  *
8199  * PARAMETERS :
8200  *   @str             : string to be parsed
8201  *   @max_num_areas   : max number of areas
8202  *   @pAreas          : ptr to struct to store areas
8203  *   @num_areas_found : number of areas found
8204  *
8205  * RETURN     : int32_t type of status
8206  *              NO_ERROR  -- success
8207  *              none-zero failure code
8208  *==========================================================================*/
parseCameraAreaString(const char * str,int max_num_areas,cam_area_t * pAreas,int & num_areas_found)8209 int32_t QCameraParameters::parseCameraAreaString(const char *str,
8210                                                  int max_num_areas,
8211                                                  cam_area_t *pAreas,
8212                                                  int& num_areas_found)
8213 {
8214     char area_str[32];
8215     const char *start, *end, *p;
8216     start = str; end = NULL;
8217     int values[5], index=0;
8218     num_areas_found = 0;
8219 
8220     memset(values, 0, sizeof(values));
8221     while(start != NULL) {
8222        if(*start != '(') {
8223             ALOGE("%s: error: Ill formatted area string: %s", __func__, str);
8224             return BAD_VALUE;
8225        }
8226        end = strchr(start, ')');
8227        if(end == NULL) {
8228             ALOGE("%s: error: Ill formatted area string: %s", __func__, str);
8229             return BAD_VALUE;
8230        }
8231        int i;
8232        for (i=0,p=start; p<=end; p++, i++) {
8233            area_str[i] = *p;
8234        }
8235        area_str[i] = '\0';
8236        if(parseNDimVector(area_str, values, 5) < 0){
8237             ALOGE("%s: error: Failed to parse the area string: %s", __func__, area_str);
8238             return BAD_VALUE;
8239        }
8240        // no more areas than max_num_areas are accepted.
8241        if(index >= max_num_areas) {
8242             ALOGE("%s: error: too many areas specified %s", __func__, str);
8243             return BAD_VALUE;
8244        }
8245        pAreas[index].rect.left = values[0];
8246        pAreas[index].rect.top = values[1];
8247        pAreas[index].rect.width = values[2] - values[0];
8248        pAreas[index].rect.height = values[3] - values[1];
8249        pAreas[index].weight = values[4];
8250 
8251        index++;
8252        start = strchr(end, '('); // serach for next '('
8253     }
8254     num_areas_found = index;
8255     return 0;
8256 }
8257 
8258 /*===========================================================================
8259  * FUNCTION   : validateCameraAreas
8260  *
8261  * DESCRIPTION: helper function to validate camera areas within (-1000, 1000)
8262  *
8263  * PARAMETERS :
8264  *   @areas     : ptr to array of areas
8265  *   @num_areas : number of areas
8266  *
8267  * RETURN     : true --  area is in valid range
8268  *              false -- not valid
8269  *==========================================================================*/
validateCameraAreas(cam_area_t * areas,int num_areas)8270 bool QCameraParameters::validateCameraAreas(cam_area_t *areas, int num_areas)
8271 {
8272     // special case: default area
8273     if (num_areas == 1 &&
8274         areas[0].rect.left == 0 &&
8275         areas[0].rect.top == 0 &&
8276         areas[0].rect.width == 0 &&
8277         areas[0].rect.height == 0 &&
8278         areas[0].weight == 0) {
8279         return true;
8280     }
8281 
8282     for(int i = 0; i < num_areas; i++) {
8283         // left should be >= -1000
8284         if(areas[i].rect.left < -1000) {
8285             return false;
8286         }
8287 
8288         // top  should be >= -1000
8289         if(areas[i].rect.top < -1000) {
8290             return false;
8291         }
8292 
8293         // width or height should be > 0
8294         if (areas[i].rect.width <= 0 || areas[i].rect.height <= 0) {
8295             return false;
8296         }
8297 
8298         // right  should be <= 1000
8299         if(areas[i].rect.left + areas[i].rect.width > 1000) {
8300             return false;
8301         }
8302 
8303         // bottom should be <= 1000
8304         if(areas[i].rect.top + areas[i].rect.height > 1000) {
8305             return false;
8306         }
8307 
8308         // weight should be within (1, 1000)
8309         if (areas[i].weight < 1 || areas[i].weight > 1000) {
8310             return false;
8311         }
8312     }
8313     return true;
8314 }
8315 
8316 /*===========================================================================
8317  * FUNCTION   : isYUVFrameInfoNeeded
8318  *
8319  * DESCRIPTION: In AE-Bracket mode, we need set yuv buffer information for up-layer
8320  *
8321  * PARAMETERS : none
8322  *
8323  * RETURN     : true: needed
8324  *              false: no need
8325  *==========================================================================*/
isYUVFrameInfoNeeded()8326 bool QCameraParameters::isYUVFrameInfoNeeded()
8327 {
8328     //In AE-Bracket mode, we need set raw buffer information for up-layer
8329     if(!isNV21PictureFormat() && !isNV16PictureFormat()){
8330         return false;
8331     }
8332     const char *aecBracketStr =  get(KEY_QC_AE_BRACKET_HDR);
8333 
8334     int value = lookupAttr(BRACKETING_MODES_MAP,
8335                    sizeof(BRACKETING_MODES_MAP)/sizeof(QCameraMap),
8336                            aecBracketStr);
8337     CDBG_HIGH("%s: aecBracketStr=%s, value=%d.", __func__, aecBracketStr, value);
8338     return (value == CAM_EXP_BRACKETING_ON);
8339 }
8340 
8341 /*===========================================================================
8342  * FUNCTION   : getFrameFmtString
8343  *
8344  * DESCRIPTION: get string name of frame format
8345  *
8346  * PARAMETERS :
8347  *   @frame   : frame format
8348  *
8349  * RETURN     : string name of frame format
8350  *==========================================================================*/
getFrameFmtString(cam_format_t fmt)8351 const char *QCameraParameters::getFrameFmtString(cam_format_t fmt)
8352 {
8353     return lookupNameByValue(PICTURE_TYPES_MAP,
8354                              sizeof(PICTURE_TYPES_MAP)/sizeof(QCameraMap),
8355                              fmt);
8356 }
8357 
8358 /*===========================================================================
8359  * FUNCTION   : initBatchUpdate
8360  *
8361  * DESCRIPTION: init camera parameters buf entries
8362  *
8363  * PARAMETERS :
8364  *   @p_table : ptr to parameter buffer
8365  *
8366  * RETURN     : int32_t type of status
8367  *              NO_ERROR  -- success
8368  *              none-zero failure code
8369  *==========================================================================*/
initBatchUpdate(parm_buffer_t * p_table)8370 int32_t QCameraParameters::initBatchUpdate(parm_buffer_t *p_table)
8371 {
8372     m_tempMap.clear();
8373 
8374     memset(p_table, 0, sizeof(parm_buffer_t));
8375     return NO_ERROR;
8376 }
8377 
8378 /*===========================================================================
8379  * FUNCTION   : AddSetParmEntryToBatch
8380  *
8381  * DESCRIPTION: add set parameter entry into batch
8382  *
8383  * PARAMETERS :
8384  *   @p_table     : ptr to parameter buffer
8385  *   @paramType   : parameter type
8386  *   @paramLength : length of parameter value
8387  *   @paramValue  : ptr to parameter value
8388  *
8389  * RETURN     : int32_t type of status
8390  *              NO_ERROR  -- success
8391  *              none-zero failure code
8392  *==========================================================================*/
AddSetParmEntryToBatch(parm_buffer_t * p_table,cam_intf_parm_type_t paramType,uint32_t paramLength,void * paramValue)8393 int32_t QCameraParameters::AddSetParmEntryToBatch(parm_buffer_t *p_table,
8394                                                   cam_intf_parm_type_t paramType,
8395                                                   uint32_t paramLength,
8396                                                   void *paramValue)
8397 {
8398     void* dst;
8399     if ((NULL == p_table) || (NULL == paramValue) ||
8400         (paramType >= CAM_INTF_PARM_MAX)) {
8401         ALOGE("%s: Error invalid param. p_table: %p, paramValue: %p, "
8402             "paramType: %d", __func__, p_table, paramValue, paramType);
8403         return BAD_VALUE;
8404     }
8405     /*************************************************************************
8406     *                   Copy contents into entry                             *
8407     *************************************************************************/
8408     if (paramLength > get_size_of(paramType)) {
8409         ALOGE("%s:Size of input larger than max entry size. paramType: %d "
8410             "paramLength: %d sizeof(paramType): %d",
8411             __func__, paramType, paramLength, get_size_of(paramType));
8412         return BAD_VALUE;
8413     }
8414 
8415     dst = get_pointer_of(paramType, p_table);
8416     if (NULL != dst) {
8417         memcpy(dst, paramValue, paramLength);
8418         p_table->is_valid[paramType] = 1;
8419     }
8420     return NO_ERROR;
8421 }
8422 
8423 /*===========================================================================
8424  * FUNCTION   : AddGetParmEntryToBatch
8425  *
8426  * DESCRIPTION: add get parameter entry into batch
8427  *
8428  * PARAMETERS :
8429  *   @p_table     : ptr to parameter buffer
8430  *   @paramType   : parameter type
8431  *
8432  * RETURN     : int32_t type of status
8433  *              NO_ERROR  -- success
8434  *              none-zero failure code
8435  *==========================================================================*/
AddGetParmEntryToBatch(parm_buffer_t * p_table,cam_intf_parm_type_t paramType)8436 int32_t QCameraParameters::AddGetParmEntryToBatch(parm_buffer_t *p_table,
8437                                                 cam_intf_parm_type_t paramType)
8438 {
8439     if ((p_table == NULL) || (paramType >= CAM_INTF_PARM_MAX)) {
8440         ALOGE("%s: Error invalid param. p_table: %p, paramType: %d",
8441             __func__, p_table, paramType);
8442         return BAD_VALUE;
8443     }
8444     /* Set the is_reqd flag for this param so that backend can fill the value*/
8445     p_table->is_reqd[paramType] = 1;
8446 
8447     return NO_ERROR;
8448 }
8449 
8450 /*===========================================================================
8451  * FUNCTION   : commitSetBatch
8452  *
8453  * DESCRIPTION: commit all set parameters in the batch work to backend
8454  *
8455  * PARAMETERS : none
8456  *
8457  * RETURN     : int32_t type of status
8458  *              NO_ERROR  -- success
8459  *              none-zero failure code
8460  *==========================================================================*/
commitSetBatch()8461 int32_t QCameraParameters::commitSetBatch()
8462 {
8463     int32_t rc = NO_ERROR;
8464     int32_t i = 0;
8465 
8466     /* Loop to check if atleast one entry is valid */
8467     for(i = 0; i < CAM_INTF_PARM_MAX; i++){
8468         if(m_pParamBuf->is_valid[i])
8469             break;
8470     }
8471 
8472     if (i < CAM_INTF_PARM_MAX) {
8473         rc = m_pCamOpsTbl->ops->set_parms(m_pCamOpsTbl->camera_handle, m_pParamBuf);
8474     }
8475     if (rc == NO_ERROR) {
8476         // commit change from temp storage into param map
8477         rc = commitParamChanges();
8478     }
8479     return rc;
8480 }
8481 
8482 /*===========================================================================
8483  * FUNCTION   : commitGetBatch
8484  *
8485  * DESCRIPTION: commit all get parameters in the batch work to backend
8486  *
8487  * PARAMETERS : none
8488  *
8489  * RETURN     : int32_t type of status
8490  *              NO_ERROR  -- success
8491  *              none-zero failure code
8492  *==========================================================================*/
commitGetBatch()8493 int32_t QCameraParameters::commitGetBatch()
8494 {
8495     int32_t rc = NO_ERROR;
8496     int32_t i = 0;
8497 
8498     /* Loop to check if atleast one entry is valid */
8499     for(i = 0; i < CAM_INTF_PARM_MAX; i++){
8500         if(m_pParamBuf->is_valid[i])
8501             break;
8502     }
8503 
8504     if (i < CAM_INTF_PARM_MAX) {
8505         return m_pCamOpsTbl->ops->get_parms(m_pCamOpsTbl->camera_handle, m_pParamBuf);
8506     } else {
8507         return NO_ERROR;
8508     }
8509     return rc;
8510 }
8511 
8512 /*===========================================================================
8513  * FUNCTION   : updateParamEntry
8514  *
8515  * DESCRIPTION: update a parameter entry in the local temp map obj
8516  *
8517  * PARAMETERS :
8518  *   @key     : key of the entry
8519  *   @value   : value of the entry
8520  *
8521  * RETURN     : int32_t type of status
8522  *              NO_ERROR  -- success
8523  *              none-zero failure code
8524  *==========================================================================*/
updateParamEntry(const char * key,const char * value)8525 int32_t QCameraParameters::updateParamEntry(const char *key, const char *value)
8526 {
8527     m_tempMap.replaceValueFor(String8(key), String8(value));
8528     return NO_ERROR;
8529 }
8530 
8531 /*===========================================================================
8532  * FUNCTION   : commitParamChanges
8533  *
8534  * DESCRIPTION: commit all changes in local temp map obj into parameter obj
8535  *
8536  * PARAMETERS : none
8537  *
8538  * RETURN     : int32_t type of status
8539  *              NO_ERROR  -- success
8540  *              none-zero failure code
8541  *==========================================================================*/
commitParamChanges()8542 int32_t QCameraParameters::commitParamChanges()
8543 {
8544     size_t size = m_tempMap.size();
8545     for (size_t i = 0; i < size; i++) {
8546         String8 k, v;
8547         k = m_tempMap.keyAt(i);
8548         v = m_tempMap.valueAt(i);
8549         set(k, v);
8550     }
8551     m_tempMap.clear();
8552 
8553     // update local changes
8554     m_bRecordingHint = m_bRecordingHint_new;
8555     m_bZslMode = m_bZslMode_new;
8556 
8557     /* After applying scene mode auto,
8558       Camera effects need to be reapplied */
8559     if ( m_bSceneTransitionAuto ) {
8560         m_bUpdateEffects = true;
8561         m_bSceneTransitionAuto = false;
8562     }
8563 
8564     if ( m_bReleaseTorchCamera && ( NULL != m_pTorch) ) {
8565         m_pTorch->releaseTorchCamera();
8566         m_bReleaseTorchCamera = false;
8567     }
8568 
8569 
8570     return NO_ERROR;
8571 }
8572 
8573 /*===========================================================================
8574  * FUNCTION   : QCameraReprocScaleParam
8575  *
8576  * DESCRIPTION: constructor of QCameraReprocScaleParam
8577  *
8578  * PARAMETERS : none
8579  *
8580  * RETURN     : none
8581  *==========================================================================*/
QCameraReprocScaleParam(QCameraParameters * parent)8582 QCameraReprocScaleParam::QCameraReprocScaleParam(QCameraParameters *parent)
8583   : mParent(parent),
8584     mScaleEnabled(false),
8585     mIsUnderScaling(false),
8586     mScaleDirection(0),
8587     mNeedScaleCnt(0),
8588     mSensorSizeTblCnt(0),
8589     mSensorSizeTbl(NULL),
8590     mTotalSizeTblCnt(0)
8591 {
8592     mPicSizeFromAPK.width = 0;
8593     mPicSizeFromAPK.height = 0;
8594     mPicSizeSetted.width = 0;
8595     mPicSizeSetted.height = 0;
8596     memset(mNeedScaledSizeTbl, 0, sizeof(mNeedScaledSizeTbl));
8597     memset(mTotalSizeTbl, 0, sizeof(mTotalSizeTbl));
8598 }
8599 
8600 /*===========================================================================
8601  * FUNCTION   : ~~QCameraReprocScaleParam
8602  *
8603  * DESCRIPTION: destructor of QCameraReprocScaleParam
8604  *
8605  * PARAMETERS : none
8606  *
8607  * RETURN     : none
8608  *==========================================================================*/
~QCameraReprocScaleParam()8609 QCameraReprocScaleParam::~QCameraReprocScaleParam()
8610 {
8611     //do nothing now.
8612 }
8613 
8614 /*===========================================================================
8615  * FUNCTION   : setScaledSizeTbl
8616  *
8617  * DESCRIPTION: re-set picture size table with dimensions that need scaling if Reproc Scale is enabled
8618  *
8619  * PARAMETERS :
8620  *   @scale_cnt   : count of picture sizes that want scale
8621  *   @scale_tbl    : picture size table that want scale
8622  *   @org_cnt     : sensor supported picture size count
8623  *   @org_tbl      : sensor supported picture size table
8624  *
8625  * RETURN     : int32_t type of status
8626  *              NO_ERROR  -- success
8627  *              none-zero failure code
8628  *==========================================================================*/
setScaleSizeTbl(uint8_t scale_cnt,cam_dimension_t * scale_tbl,uint8_t org_cnt,cam_dimension_t * org_tbl)8629 int32_t QCameraReprocScaleParam::setScaleSizeTbl(uint8_t scale_cnt, cam_dimension_t *scale_tbl, uint8_t org_cnt, cam_dimension_t *org_tbl)
8630 {
8631     int32_t rc = NO_ERROR;
8632     int i;
8633     mNeedScaleCnt = 0;
8634 
8635     if(!mScaleEnabled || scale_cnt <=0 || scale_tbl == NULL || org_cnt <=0 || org_tbl == NULL){
8636         return BAD_VALUE;    // Do not need scale, so also need not reset picture size table
8637     }
8638 
8639     mSensorSizeTblCnt = org_cnt;
8640     mSensorSizeTbl = org_tbl;
8641     mNeedScaleCnt = checkScaleSizeTable(scale_cnt, scale_tbl, org_cnt, org_tbl);
8642     if(mNeedScaleCnt <= 0){
8643         ALOGE("%s: do not have picture sizes need scaling.", __func__);
8644         return BAD_VALUE;
8645     }
8646 
8647     if(mNeedScaleCnt + org_cnt > MAX_SIZES_CNT){
8648         ALOGE("%s: picture size list exceed the max count.", __func__);
8649         return BAD_VALUE;
8650     }
8651 
8652     //get the total picture size table
8653     mTotalSizeTblCnt = mNeedScaleCnt + org_cnt;
8654     for(i = 0; i < mNeedScaleCnt; i++){
8655         mTotalSizeTbl[i].width = mNeedScaledSizeTbl[i].width;
8656         mTotalSizeTbl[i].height = mNeedScaledSizeTbl[i].height;
8657         CDBG_HIGH("%s: scale picture size: i =%d, width=%d, height=%d.", __func__,
8658             i, mTotalSizeTbl[i].width, mTotalSizeTbl[i].height);
8659     }
8660     for(; i < mTotalSizeTblCnt; i++){
8661         mTotalSizeTbl[i].width = org_tbl[i-mNeedScaleCnt].width;
8662         mTotalSizeTbl[i].height = org_tbl[i-mNeedScaleCnt].height;
8663         CDBG_HIGH("%s: sensor supportted picture size: i =%d, width=%d, height=%d.", __func__,
8664             i, mTotalSizeTbl[i].width, mTotalSizeTbl[i].height);
8665     }
8666     return rc;
8667 }
8668 
8669 /*===========================================================================
8670  * FUNCTION   : getScaledSizeTblCnt
8671  *
8672  * DESCRIPTION: get picture size cnt that need scale
8673  *
8674  * PARAMETERS : none
8675  *
8676  * RETURN     : uint8_t type of picture size count
8677  *==========================================================================*/
getScaleSizeTblCnt()8678 uint8_t QCameraReprocScaleParam::getScaleSizeTblCnt()
8679 {
8680     return mNeedScaleCnt;
8681 }
8682 
8683 /*===========================================================================
8684  * FUNCTION   : getScaledSizeTbl
8685  *
8686  * DESCRIPTION: get picture size table that need scale
8687  *
8688  * PARAMETERS :  none
8689  *
8690  * RETURN     : cam_dimension_t list of picture size table
8691  *==========================================================================*/
getScaledSizeTbl()8692 cam_dimension_t *QCameraReprocScaleParam::getScaledSizeTbl()
8693 {
8694     if(!mScaleEnabled)
8695         return NULL;
8696 
8697     return mNeedScaledSizeTbl;
8698 }
8699 
8700 /*===========================================================================
8701  * FUNCTION   : setScaleEnable
8702  *
8703  * DESCRIPTION: enable or disable Reproc Scale
8704  *
8705  * PARAMETERS :
8706  *   @enabled : enable: 1; disable 0
8707  *
8708  * RETURN     : none
8709  *==========================================================================*/
setScaleEnable(bool enabled)8710 void QCameraReprocScaleParam::setScaleEnable(bool enabled)
8711 {
8712     mScaleEnabled = enabled;
8713 }
8714 
8715 /*===========================================================================
8716  * FUNCTION   : isScaleEnabled
8717  *
8718  * DESCRIPTION: check if Reproc Scale is enabled
8719  *
8720  * PARAMETERS :  none
8721  *
8722  * RETURN     : bool type of status
8723  *==========================================================================*/
isScaleEnabled()8724 bool QCameraReprocScaleParam::isScaleEnabled()
8725 {
8726     return mScaleEnabled;
8727 }
8728 
8729 /*===========================================================================
8730  * FUNCTION   : isScalePicSize
8731  *
8732  * DESCRIPTION: check if current picture size is from Scale Table
8733  *
8734  * PARAMETERS :
8735  *   @width     : current picture width
8736  *   @height    : current picture height
8737  *
8738  * RETURN     : bool type of status
8739  *==========================================================================*/
isScalePicSize(int width,int height)8740 bool QCameraReprocScaleParam::isScalePicSize(int width, int height)
8741 {
8742     //Check if the picture size is in scale table
8743     if(mNeedScaleCnt <= 0)
8744         return FALSE;
8745 
8746     for(int i = 0; i < mNeedScaleCnt; i++){
8747         if(mNeedScaledSizeTbl[i].width == width
8748             && mNeedScaledSizeTbl[i].height == height){
8749             //found match
8750             return TRUE;
8751         }
8752     }
8753 
8754     ALOGE("%s: Not in scale picture size table.", __func__);
8755     return FALSE;
8756 }
8757 
8758 /*===========================================================================
8759  * FUNCTION   : isValidatePicSize
8760  *
8761  * DESCRIPTION: check if current picture size is validate
8762  *
8763  * PARAMETERS :
8764  *   @width     : current picture width
8765  *   @height    : current picture height
8766  *
8767  * RETURN     : bool type of status
8768  *==========================================================================*/
isValidatePicSize(int width,int height)8769 bool QCameraReprocScaleParam::isValidatePicSize(int width, int height)
8770 {
8771     int i = 0;
8772 
8773     for(i = 0; i < mSensorSizeTblCnt; i++){
8774         if(mSensorSizeTbl[i].width == width
8775             && mSensorSizeTbl[i].height== height){
8776             return TRUE;
8777         }
8778     }
8779 
8780     for(i = 0; i < mNeedScaleCnt; i++){
8781         if(mNeedScaledSizeTbl[i].width == width
8782             && mNeedScaledSizeTbl[i].height== height){
8783             return TRUE;
8784         }
8785     }
8786 
8787     ALOGE("%s: Invalidate input picture size.", __func__);
8788     return FALSE;
8789 }
8790 
8791 /*===========================================================================
8792  * FUNCTION   : setSensorSupportedPicSize
8793  *
8794  * DESCRIPTION: set sensor supported picture size.
8795  *    For Snapshot stream size configuration, we need use sensor supported size.
8796  *    We will use CPP to do Scaling based on output Snapshot stream.
8797  *
8798  * PARAMETERS : none
8799  *
8800  * RETURN     : int32_t type of status
8801  *              NO_ERROR  -- success
8802  *              none-zero failure code
8803  *==========================================================================*/
setSensorSupportedPicSize()8804 int32_t QCameraReprocScaleParam::setSensorSupportedPicSize()
8805 {
8806     //will find a suitable picture size (here we leave a prossibility to add other scale requirement)
8807     //Currently we only focus on upscaling, and checkScaleSizeTable() has guaranteed the dimension ratio.
8808 
8809     if(!mIsUnderScaling || mSensorSizeTblCnt <= 0)
8810         return BAD_VALUE;
8811 
8812     //We just get the max sensor supported size here.
8813     mPicSizeSetted.width = mSensorSizeTbl[0].width;
8814     mPicSizeSetted.height = mSensorSizeTbl[0].height;
8815 
8816     return NO_ERROR;
8817 }
8818 
8819 
8820 /*===========================================================================
8821  * FUNCTION   : setValidatePicSize
8822  *
8823  * DESCRIPTION: set sensor supported size and change scale status.
8824  *
8825  * PARAMETERS :
8826  *   @width    : input picture width
8827  *   @height   : input picture height
8828  *
8829  * RETURN     : int32_t type of status
8830  *              NO_ERROR  -- success
8831  *              none-zero failure code
8832  *==========================================================================*/
setValidatePicSize(int & width,int & height)8833 int32_t QCameraReprocScaleParam::setValidatePicSize(int &width,int &height)
8834 {
8835     if(!mScaleEnabled)
8836         return BAD_VALUE;
8837 
8838     mIsUnderScaling = FALSE; //default: not under scale
8839 
8840     if(isScalePicSize(width, height)){
8841         // input picture size need scaling operation. Record size from APK and setted
8842         mIsUnderScaling = TRUE;
8843         mPicSizeFromAPK.width = width;
8844         mPicSizeFromAPK.height = height;
8845 
8846         if(setSensorSupportedPicSize() != NO_ERROR)
8847             return BAD_VALUE;
8848 
8849         //re-set picture size to sensor supported size
8850         width = mPicSizeSetted.width;
8851         height = mPicSizeSetted.height;
8852         CDBG_HIGH("%s: mPicSizeFromAPK- with=%d, height=%d, mPicSizeSetted- with =%d, height=%d.",
8853             __func__, mPicSizeFromAPK.width, mPicSizeFromAPK.height, mPicSizeSetted.width, mPicSizeSetted.height);
8854     }else{
8855         mIsUnderScaling = FALSE;
8856         //no scale is needed for input picture size
8857         if(!isValidatePicSize(width, height)){
8858             ALOGE("%s: invalidate input picture size.", __func__);
8859             return BAD_VALUE;
8860         }
8861         mPicSizeSetted.width = width;
8862         mPicSizeSetted.height = height;
8863     }
8864 
8865     CDBG_HIGH("%s: X. mIsUnderScaling=%d, width=%d, height=%d.", __func__, mIsUnderScaling, width, height);
8866     return NO_ERROR;
8867 }
8868 
8869 /*===========================================================================
8870  * FUNCTION   : getPicSizeFromAPK
8871  *
8872  * DESCRIPTION: get picture size that get from APK
8873  *
8874  * PARAMETERS :
8875  *   @width     : input width
8876  *   @height    : input height
8877  *
8878  * RETURN     : int32_t type of status
8879  *              NO_ERROR  -- success
8880  *              none-zero failure code
8881  *==========================================================================*/
getPicSizeFromAPK(int & width,int & height)8882 int32_t QCameraReprocScaleParam::getPicSizeFromAPK(int &width, int &height)
8883 {
8884     if(!mIsUnderScaling)
8885         return BAD_VALUE;
8886 
8887     width = mPicSizeFromAPK.width;
8888     height = mPicSizeFromAPK.height;
8889     return NO_ERROR;
8890 }
8891 
8892 /*===========================================================================
8893  * FUNCTION   : getPicSizeSetted
8894  *
8895  * DESCRIPTION: get picture size that setted into mm-camera
8896  *
8897  * PARAMETERS :
8898  *   @width     : input width
8899  *   @height    : input height
8900  *
8901  * RETURN     : int32_t type of status
8902  *              NO_ERROR  -- success
8903  *              none-zero failure code
8904  *==========================================================================*/
getPicSizeSetted(int & width,int & height)8905 int32_t QCameraReprocScaleParam::getPicSizeSetted(int &width, int &height)
8906 {
8907     width = mPicSizeSetted.width;
8908     height = mPicSizeSetted.height;
8909     return NO_ERROR;
8910 }
8911 
8912 /*===========================================================================
8913  * FUNCTION   : isUnderScaling
8914  *
8915  * DESCRIPTION: check if we are in Reproc Scaling requirment
8916  *
8917  * PARAMETERS :  none
8918  *
8919  * RETURN     : bool type of status
8920  *==========================================================================*/
isUnderScaling()8921 bool QCameraReprocScaleParam::isUnderScaling()
8922 {
8923     return mIsUnderScaling;
8924 }
8925 
8926 /*===========================================================================
8927  * FUNCTION   : checkScaleSizeTable
8928  *
8929  * DESCRIPTION: check PICTURE_SIZE_NEED_SCALE to choose
8930  *
8931  * PARAMETERS :
8932  *   @scale_cnt   : count of picture sizes that want scale
8933  *   @scale_tbl    : picture size table that want scale
8934  *   @org_cnt     : sensor supported picture size count
8935  *   @org_tbl      : sensor supported picture size table
8936  *
8937  * RETURN     : bool type of status
8938  *==========================================================================*/
checkScaleSizeTable(uint8_t scale_cnt,cam_dimension_t * scale_tbl,uint8_t org_cnt,cam_dimension_t * org_tbl)8939 uint8_t QCameraReprocScaleParam::checkScaleSizeTable(uint8_t scale_cnt, cam_dimension_t *scale_tbl, uint8_t org_cnt, cam_dimension_t *org_tbl)
8940 {
8941     uint8_t stbl_cnt = 0;
8942     uint8_t temp_cnt = 0;
8943     int i = 0;
8944     if(scale_cnt <=0 || scale_tbl == NULL || org_tbl == NULL || org_cnt <= 0)
8945         return stbl_cnt;
8946 
8947     //get validate scale size table. Currently we only support:
8948     // 1. upscale. The scale size must larger than max sensor supported size
8949     // 2. Scale dimension ratio must be same as the max sensor supported size.
8950     temp_cnt = scale_cnt;
8951     for(i = scale_cnt-1; i >= 0; i--){
8952         if(scale_tbl[i].width > org_tbl[0].width ||
8953             (scale_tbl[i].width == org_tbl[0].width &&
8954              scale_tbl[i].height > org_tbl[0].height)){
8955             //get the smallest scale size
8956             break;
8957         }
8958         temp_cnt--;
8959     }
8960 
8961     //check dimension ratio
8962     double supported_ratio = (double)org_tbl[0].width/ (double)org_tbl[0].height;
8963     for(i = 0; i < temp_cnt; i++){
8964         double cur_ratio = (double)scale_tbl[i].width/ (double)scale_tbl[i].height;
8965         if(fabs(supported_ratio - cur_ratio) > ASPECT_TOLERANCE){
8966             continue;
8967         }
8968         mNeedScaledSizeTbl[stbl_cnt].width = scale_tbl[i].width;
8969         mNeedScaledSizeTbl[stbl_cnt].height= scale_tbl[i].height;
8970         stbl_cnt++;
8971     }
8972 
8973     return stbl_cnt;
8974 }
8975 
8976 /*===========================================================================
8977  * FUNCTION   : getTotalSizeTblCnt
8978  *
8979  * DESCRIPTION: get total picture size count after adding dimensions that need scaling
8980  *
8981  * PARAMETERS : none
8982  *
8983  * RETURN     : uint8_t type of picture size count
8984  *==========================================================================*/
getTotalSizeTblCnt()8985 uint8_t QCameraReprocScaleParam::getTotalSizeTblCnt()
8986 {
8987     return mTotalSizeTblCnt;
8988 }
8989 
8990 /*===========================================================================
8991  * FUNCTION   : getTotalSizeTbl
8992  *
8993  * DESCRIPTION: get picture size table after adding dimensions that need scaling
8994  *
8995  * PARAMETERS :  none
8996  *
8997  * RETURN     : cam_dimension_t list of picture size table
8998  *==========================================================================*/
getTotalSizeTbl()8999 cam_dimension_t *QCameraReprocScaleParam::getTotalSizeTbl()
9000 {
9001     if(!mScaleEnabled)
9002         return NULL;
9003 
9004     return mTotalSizeTbl;
9005 }
9006 
9007 /*===========================================================================
9008  * FUNCTION   : isHDREnabled
9009  *
9010  * DESCRIPTION: if HDR is enabled
9011  *
9012  * PARAMETERS : none
9013  *
9014  * RETURN     : true: needed
9015  *              false: no need
9016  *==========================================================================*/
isHDREnabled()9017 bool QCameraParameters::isHDREnabled()
9018 {
9019     return ((m_nBurstNum == 1) && (m_bHDREnabled || m_HDRSceneEnabled));
9020 }
9021 
9022 /*===========================================================================
9023  * FUNCTION   : isAVTimerEnabled
9024  *
9025  * DESCRIPTION: if AVTimer is enabled
9026  *
9027  * PARAMETERS : none
9028  *
9029  * RETURN     : true: needed
9030  *              false: no need
9031  *==========================================================================*/
isAVTimerEnabled()9032 bool QCameraParameters::isAVTimerEnabled()
9033 {
9034     return m_bAVTimerEnabled;
9035 }
9036 
9037 /*===========================================================================
9038 * FUNCTION   : isDISEnabled
9039 *
9040 * DESCRIPTION: if DIS is enabled
9041 *
9042 * PARAMETERS : none
9043 *
9044 * RETURN    : true: needed
9045 *               false: no need
9046 *==========================================================================*/
isDISEnabled()9047 bool QCameraParameters::isDISEnabled()
9048 {
9049     return m_bDISEnabled;
9050 }
9051 
9052 /*===========================================================================
9053  * FUNCTION   : setStreamConfigure
9054  *
9055  * DESCRIPTION: set stream type, stream dimension for all configured streams.
9056  *
9057  * PARAMETERS :
9058  *   @isCapture: Whether this configureation is for an image capture
9059  *   @previewAsPostview: Use preview as postview
9060  *
9061  * RETURN     : int32_t type of status
9062  *              NO_ERROR  -- success
9063  *              none-zero failure code
9064  *==========================================================================*/
setStreamConfigure(bool isCapture,bool previewAsPostview)9065 bool QCameraParameters::setStreamConfigure(bool isCapture, bool previewAsPostview)
9066 {
9067     int32_t rc = NO_ERROR;
9068     cam_stream_size_info_t stream_config_info;
9069     char value[PROPERTY_VALUE_MAX];
9070     bool raw_yuv = false;
9071 
9072     if ( m_pParamBuf == NULL ) {
9073         return NO_INIT;
9074     }
9075 
9076     memset(&stream_config_info, 0, sizeof(stream_config_info));
9077     stream_config_info.num_streams = 0;
9078 
9079     property_get("persist.camera.raw_yuv", value, "0");
9080     raw_yuv = atoi(value) > 0 ? true : false;
9081 
9082     if (isZSLMode() && getRecordingHintValue() != true) {
9083         stream_config_info.type[stream_config_info.num_streams] =
9084             CAM_STREAM_TYPE_PREVIEW;
9085         getStreamDimension(CAM_STREAM_TYPE_PREVIEW,
9086             stream_config_info.stream_sizes[stream_config_info.num_streams]);
9087         stream_config_info.num_streams++;
9088 
9089         stream_config_info.type[stream_config_info.num_streams] =
9090             CAM_STREAM_TYPE_SNAPSHOT;
9091         getStreamDimension(CAM_STREAM_TYPE_SNAPSHOT,
9092             stream_config_info.stream_sizes[stream_config_info.num_streams]);
9093         stream_config_info.num_streams++;
9094 
9095     } else if (!isCapture) {
9096         if (m_bRecordingHint) {
9097            if (!is4k2kVideoResolution()) {
9098                stream_config_info.type[stream_config_info.num_streams] =
9099                    CAM_STREAM_TYPE_SNAPSHOT;
9100                getStreamDimension(CAM_STREAM_TYPE_SNAPSHOT,
9101                    stream_config_info.stream_sizes[stream_config_info.num_streams]);
9102                stream_config_info.num_streams++;
9103            }
9104 
9105             stream_config_info.type[stream_config_info.num_streams] =
9106                 CAM_STREAM_TYPE_VIDEO;
9107             getStreamDimension(CAM_STREAM_TYPE_VIDEO,
9108                 stream_config_info.stream_sizes[stream_config_info.num_streams]);
9109             stream_config_info.num_streams++;
9110         }
9111 
9112         stream_config_info.type[stream_config_info.num_streams] =
9113             CAM_STREAM_TYPE_PREVIEW;
9114         getStreamDimension(CAM_STREAM_TYPE_PREVIEW,
9115             stream_config_info.stream_sizes[stream_config_info.num_streams]);
9116         stream_config_info.num_streams++;
9117     } else {
9118         if (isJpegPictureFormat() || isNV16PictureFormat() || isNV21PictureFormat()) {
9119             stream_config_info.type[stream_config_info.num_streams] =
9120                 CAM_STREAM_TYPE_SNAPSHOT;
9121             getStreamDimension(CAM_STREAM_TYPE_SNAPSHOT,
9122                 stream_config_info.stream_sizes[stream_config_info.num_streams]);
9123             stream_config_info.num_streams++;
9124 
9125             if (previewAsPostview) {
9126                 stream_config_info.type[stream_config_info.num_streams] =
9127                     CAM_STREAM_TYPE_PREVIEW;
9128                 getStreamDimension(CAM_STREAM_TYPE_PREVIEW,
9129                     stream_config_info.stream_sizes[stream_config_info.num_streams]);
9130                 stream_config_info.num_streams++;
9131             } else {
9132                 stream_config_info.type[stream_config_info.num_streams] =
9133                     CAM_STREAM_TYPE_POSTVIEW;
9134                 getStreamDimension(CAM_STREAM_TYPE_POSTVIEW,
9135                     stream_config_info.stream_sizes[stream_config_info.num_streams]);
9136                 stream_config_info.num_streams++;
9137             }
9138         }
9139     }
9140     if (raw_yuv) {
9141         stream_config_info.type[stream_config_info.num_streams] =
9142             CAM_STREAM_TYPE_RAW;
9143         getStreamDimension(CAM_STREAM_TYPE_RAW,
9144             stream_config_info.stream_sizes[stream_config_info.num_streams]);
9145         stream_config_info.num_streams++;
9146     }
9147 
9148     if(initBatchUpdate(m_pParamBuf) < 0 ) {
9149         ALOGE("%s:Failed to initialize group update table", __func__);
9150         return BAD_TYPE;
9151     }
9152 
9153     rc = AddSetParmEntryToBatch(m_pParamBuf,
9154                                 CAM_INTF_META_STREAM_INFO,
9155                                 sizeof(stream_config_info),
9156                                 &stream_config_info);
9157     if (rc != NO_ERROR) {
9158         ALOGE("%s:Failed to update table", __func__);
9159         return rc;
9160     }
9161 
9162     rc = commitSetBatch();
9163     if (rc != NO_ERROR) {
9164         ALOGE("%s:Failed to set stream info parm", __func__);
9165         return rc;
9166     }
9167 
9168     return rc;
9169 }
9170 
9171 /*===========================================================================
9172  * FUNCTION   : needThumbnailReprocess
9173  *
9174  * DESCRIPTION: Check if thumbnail reprocessing is needed
9175  *
9176  * PARAMETERS : @pFeatureMask - feature mask
9177  *
9178  * RETURN     : true: needed
9179  *              false: no need
9180  *==========================================================================*/
needThumbnailReprocess(uint32_t * pFeatureMask)9181 bool QCameraParameters::needThumbnailReprocess(uint32_t *pFeatureMask)
9182 {
9183     if (isUbiFocusEnabled() || isChromaFlashEnabled() ||
9184         isOptiZoomEnabled()) {
9185         *pFeatureMask &= ~CAM_QCOM_FEATURE_CHROMA_FLASH;
9186         *pFeatureMask &= ~CAM_QCOM_FEATURE_UBIFOCUS;
9187         *pFeatureMask &= ~CAM_QCOM_FEATURE_OPTIZOOM;
9188         return false;
9189     } else {
9190         return true;
9191     }
9192 }
9193 
9194 /*===========================================================================
9195  * FUNCTION   : getNumOfExtraBuffersForImageProc
9196  *
9197  * DESCRIPTION: get number of extra input buffers needed by image processing
9198  *
9199  * PARAMETERS : none
9200  *
9201  * RETURN     : number of extra buffers needed by ImageProc;
9202  *              0 if not ImageProc enabled
9203  *==========================================================================*/
getNumOfExtraBuffersForImageProc()9204 uint8_t QCameraParameters::getNumOfExtraBuffersForImageProc()
9205 {
9206     uint8_t numOfBufs = 0;
9207 
9208     if (isUbiFocusEnabled()) {
9209         numOfBufs += m_pCapability->ubifocus_af_bracketing_need.burst_count - 1;
9210         if (isUbiRefocus()) {
9211             numOfBufs +=
9212                 m_pCapability->ubifocus_af_bracketing_need.burst_count + 1;
9213         }
9214     } else if (m_bOptiZoomOn) {
9215         numOfBufs += m_pCapability->opti_zoom_settings_need.burst_count - 1;
9216     } else if (isChromaFlashEnabled()) {
9217         numOfBufs += 1; /* flash and non flash */
9218     }
9219 
9220     return numOfBufs * getBurstNum();
9221 }
9222 
9223 /*===========================================================================
9224  * FUNCTION   : is4k2kVideoResolution
9225  *
9226  * DESCRIPTION: if resolution is 4k x 2k or true 4k x 2k
9227  *
9228  * PARAMETERS : none
9229  *
9230  * RETURN     : true: video resolution is 4k x 2k
9231  *              false: video resolution is not 4k x 2k
9232  *==========================================================================*/
is4k2kVideoResolution()9233 bool QCameraParameters::is4k2kVideoResolution()
9234 {
9235    bool enabled = false;
9236    cam_dimension_t resolution;
9237    getVideoSize(&resolution.width, &resolution.height);
9238    if (!(resolution.width < 3840 && resolution.height < 2160)) {
9239       enabled = true;
9240    }
9241    return enabled;
9242 }
9243 /*===========================================================================
9244  * FUNCTION   : dump
9245  *
9246  * DESCRIPTION: Composes a string based on current configuration
9247  *
9248  * PARAMETERS : none
9249  *
9250  * RETURN     : Formatted string
9251  *==========================================================================*/
dump()9252 String8 QCameraParameters::dump()
9253 {
9254     String8 str("\n");
9255     char s[128];
9256 
9257     snprintf(s, 128, "Preview Pixel Fmt: %d\n", getPreviewHalPixelFormat());
9258     str += s;
9259 
9260     snprintf(s, 128, "ZSL Burst Interval: %d\n", getZSLBurstInterval());
9261     str += s;
9262 
9263     snprintf(s, 128, "ZSL Queue Depth: %d\n", getZSLQueueDepth());
9264     str += s;
9265 
9266     snprintf(s, 128, "ZSL Back Look Count %d\n", getZSLBackLookCount());
9267     str += s;
9268 
9269     snprintf(s, 128, "Max Unmatched Frames In Queue: %d\n",
9270         getMaxUnmatchedFramesInQueue());
9271     str += s;
9272 
9273     snprintf(s, 128, "Is ZSL Mode: %d\n", isZSLMode());
9274     str += s;
9275 
9276     snprintf(s, 128, "Is No Display Mode: %d\n", isNoDisplayMode());
9277     str += s;
9278 
9279     snprintf(s, 128, "Is WNR Enabled: %d\n", isWNREnabled());
9280     str += s;
9281 
9282     snprintf(s, 128, "isHfrMode: %d\n", isHfrMode());
9283     str += s;
9284 
9285     snprintf(s, 128, "getNumOfSnapshots: %d\n", getNumOfSnapshots());
9286     str += s;
9287 
9288     snprintf(s, 128, "getNumOfExtraHDRInBufsIfNeeded: %d\n",
9289         getNumOfExtraHDRInBufsIfNeeded());
9290     str += s;
9291 
9292     snprintf(s, 128, "getNumOfExtraHDROutBufsIfNeeded: %d\n",
9293         getNumOfExtraHDROutBufsIfNeeded());
9294     str += s;
9295 
9296     snprintf(s, 128, "getBurstNum: %d\n", getBurstNum());
9297     str += s;
9298 
9299     snprintf(s, 128, "getRecordingHintValue: %d\n", getRecordingHintValue());
9300     str += s;
9301 
9302     snprintf(s, 128, "getJpegQuality: %d\n", getJpegQuality());
9303     str += s;
9304 
9305     snprintf(s, 128, "getJpegRotation: %d\n", getJpegRotation());
9306     str += s;
9307 
9308     snprintf(s, 128, "isHistogramEnabled: %d\n", isHistogramEnabled());
9309     str += s;
9310 
9311     snprintf(s, 128, "isFaceDetectionEnabled: %d\n", isFaceDetectionEnabled());
9312     str += s;
9313 
9314     snprintf(s, 128, "isHDREnabled: %d\n", isHDREnabled());
9315     str += s;
9316 
9317     snprintf(s, 128, "isAutoHDREnabled: %d\n", isAutoHDREnabled());
9318     str += s;
9319 
9320     snprintf(s, 128, "isAVTimerEnabled: %d\n", isAVTimerEnabled());
9321     str += s;
9322 
9323     snprintf(s, 128, "getFocusMode: %d\n", getFocusMode());
9324     str += s;
9325 
9326     snprintf(s, 128, "isJpegPictureFormat: %d\n", isJpegPictureFormat());
9327     str += s;
9328 
9329     snprintf(s, 128, "isNV16PictureFormat: %d\n", isNV16PictureFormat());
9330     str += s;
9331 
9332     snprintf(s, 128, "isNV21PictureFormat: %d\n", isNV21PictureFormat());
9333     str += s;
9334 
9335     snprintf(s, 128, "isSnapshotFDNeeded: %d\n", isSnapshotFDNeeded());
9336     str += s;
9337 
9338     snprintf(s, 128, "isHDR1xFrameEnabled: %d\n", isHDR1xFrameEnabled());
9339     str += s;
9340 
9341     snprintf(s, 128, "isYUVFrameInfoNeeded: %d\n", isYUVFrameInfoNeeded());
9342     str += s;
9343 
9344     snprintf(s, 128, "isHDR1xExtraBufferNeeded: %d\n",
9345         isHDR1xExtraBufferNeeded());
9346     str += s;
9347 
9348     snprintf(s, 128, "isHDROutputCropEnabled: %d\n", isHDROutputCropEnabled());
9349     str += s;
9350 
9351     snprintf(s, 128, "isPreviewFlipChanged: %d\n", isPreviewFlipChanged());
9352     str += s;
9353 
9354     snprintf(s, 128, "isVideoFlipChanged: %d\n", isVideoFlipChanged());
9355     str += s;
9356 
9357     snprintf(s, 128, "isSnapshotFlipChanged: %d\n", isSnapshotFlipChanged());
9358     str += s;
9359 
9360     snprintf(s, 128, "isHDRThumbnailProcessNeeded: %d\n",
9361         isHDRThumbnailProcessNeeded());
9362     str += s;
9363 
9364     snprintf(s, 128, "getAutoFlickerMode: %d\n", getAutoFlickerMode());
9365     str += s;
9366 
9367     snprintf(s, 128, "getNumOfExtraBuffersForImageProc: %d\n",
9368         getNumOfExtraBuffersForImageProc());
9369     str += s;
9370 
9371     snprintf(s, 128, "isUbiFocusEnabled: %d\n", isUbiFocusEnabled());
9372     str += s;
9373 
9374     snprintf(s, 128, "isChromaFlashEnabled: %d\n", isChromaFlashEnabled());
9375     str += s;
9376 
9377     snprintf(s, 128, "isOptiZoomEnabled: %d\n", isOptiZoomEnabled());
9378     str += s;
9379 
9380     snprintf(s, 128, "getBurstCountForAdvancedCapture: %d\n",
9381         getBurstCountForAdvancedCapture());
9382     str += s;
9383 
9384     return str;
9385 }
9386 }; // namespace qcamera
9387