1 /* Copyright (c) 2012-2015, 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 <utils/Log.h> 36 #include <string.h> 37 #include <stdlib.h> 38 #include <gralloc_priv.h> 39 #include <sys/sysinfo.h> 40 #include "QCamera2HWI.h" 41 #include "QCameraParameters.h" 42 43 #define ASPECT_TOLERANCE 0.001 44 45 namespace qcamera { 46 // Parameter keys to communicate between camera application and driver. 47 const char QCameraParameters::KEY_QC_SUPPORTED_HFR_SIZES[] = "hfr-size-values"; 48 const char QCameraParameters::KEY_QC_PREVIEW_FRAME_RATE_MODE[] = "preview-frame-rate-mode"; 49 const char QCameraParameters::KEY_QC_SUPPORTED_PREVIEW_FRAME_RATE_MODES[] = "preview-frame-rate-modes"; 50 const char QCameraParameters::KEY_QC_PREVIEW_FRAME_RATE_AUTO_MODE[] = "frame-rate-auto"; 51 const char QCameraParameters::KEY_QC_PREVIEW_FRAME_RATE_FIXED_MODE[] = "frame-rate-fixed"; 52 const char QCameraParameters::KEY_QC_TOUCH_AF_AEC[] = "touch-af-aec"; 53 const char QCameraParameters::KEY_QC_SUPPORTED_TOUCH_AF_AEC[] = "touch-af-aec-values"; 54 const char QCameraParameters::KEY_QC_TOUCH_INDEX_AEC[] = "touch-index-aec"; 55 const char QCameraParameters::KEY_QC_TOUCH_INDEX_AF[] = "touch-index-af"; 56 const char QCameraParameters::KEY_QC_SCENE_DETECT[] = "scene-detect"; 57 const char QCameraParameters::KEY_QC_SUPPORTED_SCENE_DETECT[] = "scene-detect-values"; 58 const char QCameraParameters::KEY_QC_ISO_MODE[] = "iso"; 59 const char QCameraParameters::KEY_QC_CONTINUOUS_ISO[] = "continuous-iso"; 60 const char QCameraParameters::KEY_QC_MIN_ISO[] = "min-iso"; 61 const char QCameraParameters::KEY_QC_MAX_ISO[] = "max-iso"; 62 const char QCameraParameters::KEY_QC_SUPPORTED_ISO_MODES[] = "iso-values"; 63 const char QCameraParameters::KEY_QC_EXPOSURE_TIME[] = "exposure-time"; 64 const char QCameraParameters::KEY_QC_MIN_EXPOSURE_TIME[] = "min-exposure-time"; 65 const char QCameraParameters::KEY_QC_MAX_EXPOSURE_TIME[] = "max-exposure-time"; 66 const char QCameraParameters::KEY_QC_CURRENT_EXPOSURE_TIME[] = "cur-exposure-time"; 67 const char QCameraParameters::KEY_QC_CURRENT_ISO[] = "cur-iso"; 68 const char QCameraParameters::KEY_QC_LENSSHADE[] = "lensshade"; 69 const char QCameraParameters::KEY_QC_SUPPORTED_LENSSHADE_MODES[] = "lensshade-values"; 70 const char QCameraParameters::KEY_QC_AUTO_EXPOSURE[] = "auto-exposure"; 71 const char QCameraParameters::KEY_QC_SUPPORTED_AUTO_EXPOSURE[] = "auto-exposure-values"; 72 const char QCameraParameters::KEY_QC_DENOISE[] = "denoise"; 73 const char QCameraParameters::KEY_QC_SUPPORTED_DENOISE[] = "denoise-values"; 74 const char QCameraParameters::KEY_QC_FOCUS_ALGO[] = "selectable-zone-af"; 75 const char QCameraParameters::KEY_QC_SUPPORTED_FOCUS_ALGOS[] = "selectable-zone-af-values"; 76 const char QCameraParameters::KEY_QC_MANUAL_FOCUS_POSITION[] = "manual-focus-position"; 77 const char QCameraParameters::KEY_QC_MANUAL_FOCUS_POS_TYPE[] = "manual-focus-pos-type"; 78 const char QCameraParameters::KEY_QC_MIN_FOCUS_POS_INDEX[] = "min-focus-pos-index"; 79 const char QCameraParameters::KEY_QC_MAX_FOCUS_POS_INDEX[] = "max-focus-pos-index"; 80 const char QCameraParameters::KEY_QC_MIN_FOCUS_POS_DAC[] = "min-focus-pos-dac"; 81 const char QCameraParameters::KEY_QC_MAX_FOCUS_POS_DAC[] = "max-focus-pos-dac"; 82 const char QCameraParameters::KEY_QC_MIN_FOCUS_POS_RATIO[] = "min-focus-pos-ratio"; 83 const char QCameraParameters::KEY_QC_MAX_FOCUS_POS_RATIO[] = "max-focus-pos-ratio"; 84 const char QCameraParameters::KEY_QC_FOCUS_POSITION_SCALE[] = "cur-focus-scale"; 85 const char QCameraParameters::KEY_QC_MIN_FOCUS_POS_DIOPTER[] = "min-focus-pos-diopter"; 86 const char QCameraParameters::KEY_QC_MAX_FOCUS_POS_DIOPTER[] = "max-focus-pos-diopter"; 87 const char QCameraParameters::KEY_QC_FOCUS_POSITION_DIOPTER[] = "cur-focus-diopter"; 88 const char QCameraParameters::KEY_QC_FACE_DETECTION[] = "face-detection"; 89 const char QCameraParameters::KEY_QC_SUPPORTED_FACE_DETECTION[] = "face-detection-values"; 90 const char QCameraParameters::KEY_QC_FACE_RECOGNITION[] = "face-recognition"; 91 const char QCameraParameters::KEY_QC_SUPPORTED_FACE_RECOGNITION[] = "face-recognition-values"; 92 const char QCameraParameters::KEY_QC_MEMORY_COLOR_ENHANCEMENT[] = "mce"; 93 const char QCameraParameters::KEY_QC_SUPPORTED_MEM_COLOR_ENHANCE_MODES[] = "mce-values"; 94 const char QCameraParameters::KEY_QC_DIS[] = "dis"; 95 const char QCameraParameters::KEY_QC_OIS[] = "ois"; 96 const char QCameraParameters::KEY_QC_SUPPORTED_DIS_MODES[] = "dis-values"; 97 const char QCameraParameters::KEY_QC_SUPPORTED_OIS_MODES[] = "ois-values"; 98 const char QCameraParameters::KEY_QC_VIDEO_HIGH_FRAME_RATE[] = "video-hfr"; 99 const char QCameraParameters::KEY_QC_VIDEO_HIGH_SPEED_RECORDING[] = "video-hsr"; 100 const char QCameraParameters::KEY_QC_SUPPORTED_VIDEO_HIGH_FRAME_RATE_MODES[] = "video-hfr-values"; 101 const char QCameraParameters::KEY_QC_REDEYE_REDUCTION[] = "redeye-reduction"; 102 const char QCameraParameters::KEY_QC_SUPPORTED_REDEYE_REDUCTION[] = "redeye-reduction-values"; 103 const char QCameraParameters::KEY_QC_HIGH_DYNAMIC_RANGE_IMAGING[] = "hdr"; 104 const char QCameraParameters::KEY_QC_SUPPORTED_HDR_IMAGING_MODES[] = "hdr-values"; 105 const char QCameraParameters::KEY_QC_ZSL[] = "zsl"; 106 const char QCameraParameters::KEY_QC_SUPPORTED_ZSL_MODES[] = "zsl-values"; 107 const char QCameraParameters::KEY_QC_ZSL_BURST_INTERVAL[] = "capture-burst-interval"; 108 const char QCameraParameters::KEY_QC_ZSL_BURST_LOOKBACK[] = "capture-burst-retroactive"; 109 const char QCameraParameters::KEY_QC_ZSL_QUEUE_DEPTH[] = "capture-burst-queue-depth"; 110 const char QCameraParameters::KEY_QC_CAMERA_MODE[] = "camera-mode"; 111 const char QCameraParameters::KEY_QC_AE_BRACKET_HDR[] = "ae-bracket-hdr"; 112 const char QCameraParameters::KEY_QC_SUPPORTED_AE_BRACKET_MODES[] = "ae-bracket-hdr-values"; 113 const char QCameraParameters::KEY_QC_SUPPORTED_RAW_FORMATS[] = "raw-format-values"; 114 const char QCameraParameters::KEY_QC_RAW_FORMAT[] = "raw-format"; 115 const char QCameraParameters::KEY_QC_ORIENTATION[] = "orientation"; 116 const char QCameraParameters::KEY_QC_SELECTABLE_ZONE_AF[] = "selectable-zone-af"; 117 const char QCameraParameters::KEY_QC_CAPTURE_BURST_EXPOSURE[] = "capture-burst-exposures"; 118 const char QCameraParameters::KEY_QC_NUM_SNAPSHOT_PER_SHUTTER[] = "num-snaps-per-shutter"; 119 const char QCameraParameters::KEY_QC_NUM_RETRO_BURST_PER_SHUTTER[] = "num-retro-burst-per-shutter"; 120 const char QCameraParameters::KEY_QC_SNAPSHOT_BURST_LED_ON_PERIOD[] = "zsl-burst-led-on-period"; 121 const char QCameraParameters::KEY_QC_NO_DISPLAY_MODE[] = "no-display-mode"; 122 const char QCameraParameters::KEY_QC_RAW_PICUTRE_SIZE[] = "raw-size"; 123 const char QCameraParameters::KEY_QC_SUPPORTED_SKIN_TONE_ENHANCEMENT_MODES[] = "skinToneEnhancement-values"; 124 const char QCameraParameters::KEY_QC_SUPPORTED_LIVESNAPSHOT_SIZES[] = "supported-live-snapshot-sizes"; 125 const char QCameraParameters::KEY_QC_SUPPORTED_HDR_NEED_1X[] = "hdr-need-1x-values"; 126 const char QCameraParameters::KEY_QC_HDR_NEED_1X[] = "hdr-need-1x"; 127 const char QCameraParameters::KEY_QC_PREVIEW_FLIP[] = "preview-flip"; 128 const char QCameraParameters::KEY_QC_VIDEO_FLIP[] = "video-flip"; 129 const char QCameraParameters::KEY_QC_SNAPSHOT_PICTURE_FLIP[] = "snapshot-picture-flip"; 130 const char QCameraParameters::KEY_QC_SUPPORTED_FLIP_MODES[] = "flip-mode-values"; 131 const char QCameraParameters::KEY_QC_VIDEO_HDR[] = "video-hdr"; 132 const char QCameraParameters::KEY_QC_SENSOR_HDR[] = "sensor-hdr"; 133 const char QCameraParameters::KEY_QC_VT_ENABLE[] = "avtimer"; 134 const char QCameraParameters::KEY_QC_SUPPORTED_VIDEO_HDR_MODES[] = "video-hdr-values"; 135 const char QCameraParameters::KEY_QC_SUPPORTED_SENSOR_HDR_MODES[] = "sensor-hdr-values"; 136 const char QCameraParameters::KEY_QC_AUTO_HDR_ENABLE [] = "auto-hdr-enable"; 137 const char QCameraParameters::KEY_QC_SNAPSHOT_BURST_NUM[] = "snapshot-burst-num"; 138 const char QCameraParameters::KEY_QC_SNAPSHOT_FD_DATA[] = "snapshot-fd-data-enable"; 139 const char QCameraParameters::KEY_QC_TINTLESS_ENABLE[] = "tintless"; 140 const char QCameraParameters::KEY_QC_SCENE_SELECTION[] = "scene-selection"; 141 const char QCameraParameters::KEY_QC_CDS_MODE[] = "cds-mode"; 142 const char QCameraParameters::KEY_QC_VIDEO_CDS_MODE[] = "video-cds-mode"; 143 const char QCameraParameters::KEY_QC_SUPPORTED_CDS_MODES[] = "cds-mode-values"; 144 const char QCameraParameters::KEY_QC_SUPPORTED_VIDEO_CDS_MODES[] = "video-cds-mode-values"; 145 const char QCameraParameters::KEY_QC_TNR_MODE[] = "tnr-mode"; 146 const char QCameraParameters::KEY_QC_VIDEO_TNR_MODE[] = "video-tnr-mode"; 147 const char QCameraParameters::KEY_QC_SUPPORTED_TNR_MODES[] = "tnr-mode-values"; 148 const char QCameraParameters::KEY_QC_SUPPORTED_VIDEO_TNR_MODES[] = "video-tnr-mode-values"; 149 const char QCameraParameters::KEY_QC_VIDEO_ROTATION[] = "video-rotation"; 150 const char QCameraParameters::KEY_QC_SUPPORTED_VIDEO_ROTATION_VALUES[] = "video-rotation-values"; 151 const char QCameraParameters::KEY_QC_AF_BRACKET[] = "af-bracket"; 152 const char QCameraParameters::KEY_QC_SUPPORTED_AF_BRACKET_MODES[] = "af-bracket-values"; 153 const char QCameraParameters::KEY_QC_RE_FOCUS[] = "re-focus"; 154 const char QCameraParameters::KEY_QC_SUPPORTED_RE_FOCUS_MODES[] = "re-focus-values"; 155 const char QCameraParameters::KEY_QC_CHROMA_FLASH[] = "chroma-flash"; 156 const char QCameraParameters::KEY_QC_SUPPORTED_CHROMA_FLASH_MODES[] = "chroma-flash-values"; 157 const char QCameraParameters::KEY_QC_OPTI_ZOOM[] = "opti-zoom"; 158 const char QCameraParameters::KEY_QC_SEE_MORE[] = "see-more"; 159 const char QCameraParameters::KEY_QC_STILL_MORE[] = "still-more"; 160 const char QCameraParameters::KEY_QC_SUPPORTED_OPTI_ZOOM_MODES[] = "opti-zoom-values"; 161 const char QCameraParameters::KEY_QC_HDR_MODE[] = "hdr-mode"; 162 const char QCameraParameters::KEY_QC_SUPPORTED_KEY_QC_HDR_MODES[] = "hdr-mode-values"; 163 const char QCameraParameters::KEY_QC_TRUE_PORTRAIT[] = "true-portrait"; 164 const char QCameraParameters::KEY_QC_SUPPORTED_TRUE_PORTRAIT_MODES[] = "true-portrait-values"; 165 const char QCameraParameters::KEY_QC_SUPPORTED_SEE_MORE_MODES[] = "see-more-values"; 166 const char QCameraParameters::KEY_QC_SUPPORTED_STILL_MORE_MODES[] = "still-more-values"; 167 const char QCameraParameters::KEY_INTERNAL_PERVIEW_RESTART[] = "internal-restart"; 168 const char QCameraParameters::KEY_QC_RDI_MODE[] = "rdi-mode"; 169 const char QCameraParameters::KEY_QC_SUPPORTED_RDI_MODES[] = "rdi-mode-values"; 170 const char QCameraParameters::KEY_QC_SECURE_MODE[] = "secure-mode"; 171 const char QCameraParameters::KEY_QC_SUPPORTED_SECURE_MODES[] = "secure-mode-values"; 172 const char QCameraParameters::ISO_HJR[] = "ISO_HJR"; 173 const char QCameraParameters::KEY_QC_AUTO_HDR_SUPPORTED[] = "auto-hdr-supported"; 174 const char QCameraParameters::KEY_QC_LONGSHOT_SUPPORTED[] = "longshot-supported"; 175 const char QCameraParameters::KEY_QC_ZSL_HDR_SUPPORTED[] = "zsl-hdr-supported"; 176 const char QCameraParameters::KEY_QC_WB_MANUAL_CCT[] = "wb-manual-cct"; 177 const char QCameraParameters::KEY_QC_MIN_WB_CCT[] = "min-wb-cct"; 178 const char QCameraParameters::KEY_QC_MAX_WB_CCT[] = "max-wb-cct"; 179 180 const char QCameraParameters::KEY_QC_MANUAL_WB_GAINS[] = "manual-wb-gains"; 181 const char QCameraParameters::KEY_QC_MIN_WB_GAIN[] = "min-wb-gain"; 182 const char QCameraParameters::KEY_QC_MAX_WB_GAIN[] = "max-wb-gain"; 183 184 const char QCameraParameters::KEY_QC_MANUAL_WB_TYPE[] = "manual-wb-type"; 185 const char QCameraParameters::KEY_QC_MANUAL_WB_VALUE[] = "manual-wb-value"; 186 187 const char QCameraParameters::WHITE_BALANCE_MANUAL[] = "manual"; 188 const char QCameraParameters::FOCUS_MODE_MANUAL_POSITION[] = "manual"; 189 190 191 // Values for effect settings. 192 const char QCameraParameters::EFFECT_EMBOSS[] = "emboss"; 193 const char QCameraParameters::EFFECT_SKETCH[] = "sketch"; 194 const char QCameraParameters::EFFECT_NEON[] = "neon"; 195 196 // Values for auto exposure settings. 197 const char QCameraParameters::TOUCH_AF_AEC_OFF[] = "touch-off"; 198 const char QCameraParameters::TOUCH_AF_AEC_ON[] = "touch-on"; 199 200 // Values for scene mode settings. 201 const char QCameraParameters::SCENE_MODE_ASD[] = "asd"; // corresponds to CAMERA_BESTSHOT_AUTO in HAL 202 const char QCameraParameters::SCENE_MODE_BACKLIGHT[] = "backlight"; 203 const char QCameraParameters::SCENE_MODE_FLOWERS[] = "flowers"; 204 const char QCameraParameters::SCENE_MODE_AR[] = "AR"; 205 const char QCameraParameters::SCENE_MODE_HDR[] = "hdr"; 206 207 // Formats for setPreviewFormat and setPictureFormat. 208 const char QCameraParameters::PIXEL_FORMAT_YUV420SP_ADRENO[] = "yuv420sp-adreno"; 209 const char QCameraParameters::PIXEL_FORMAT_YV12[] = "yuv420p"; 210 const char QCameraParameters::PIXEL_FORMAT_NV12[] = "nv12"; 211 const char QCameraParameters::QC_PIXEL_FORMAT_NV12_VENUS[] = "nv12-venus"; 212 213 // Values for raw image formats 214 const char QCameraParameters::QC_PIXEL_FORMAT_YUV_RAW_8BIT_YUYV[] = "yuv-raw8-yuyv"; 215 const char QCameraParameters::QC_PIXEL_FORMAT_YUV_RAW_8BIT_YVYU[] = "yuv-raw8-yvyu"; 216 const char QCameraParameters::QC_PIXEL_FORMAT_YUV_RAW_8BIT_UYVY[] = "yuv-raw8-uyvy"; 217 const char QCameraParameters::QC_PIXEL_FORMAT_YUV_RAW_8BIT_VYUY[] = "yuv-raw8-vyuy"; 218 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8GBRG[] = "bayer-qcom-8gbrg"; 219 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8GRBG[] = "bayer-qcom-8grbg"; 220 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8RGGB[] = "bayer-qcom-8rggb"; 221 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8BGGR[] = "bayer-qcom-8bggr"; 222 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10GBRG[] = "bayer-qcom-10gbrg"; 223 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10GRBG[] = "bayer-qcom-10grbg"; 224 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10RGGB[] = "bayer-qcom-10rggb"; 225 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10BGGR[] = "bayer-qcom-10bggr"; 226 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12GBRG[] = "bayer-qcom-12gbrg"; 227 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12GRBG[] = "bayer-qcom-12grbg"; 228 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12RGGB[] = "bayer-qcom-12rggb"; 229 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12BGGR[] = "bayer-qcom-12bggr"; 230 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8GBRG[] = "bayer-mipi-8gbrg"; 231 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8GRBG[] = "bayer-mipi-8grbg"; 232 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8RGGB[] = "bayer-mipi-8rggb"; 233 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8BGGR[] = "bayer-mipi-8bggr"; 234 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10GBRG[] = "bayer-mipi-10gbrg"; 235 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10GRBG[] = "bayer-mipi-10grbg"; 236 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10RGGB[] = "bayer-mipi-10rggb"; 237 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10BGGR[] = "bayer-mipi-10bggr"; 238 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12GBRG[] = "bayer-mipi-12gbrg"; 239 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12GRBG[] = "bayer-mipi-12grbg"; 240 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12RGGB[] = "bayer-mipi-12rggb"; 241 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12BGGR[] = "bayer-mipi-12bggr"; 242 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8GBRG[] = "bayer-ideal-qcom-8gbrg"; 243 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8GRBG[] = "bayer-ideal-qcom-8grbg"; 244 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8RGGB[] = "bayer-ideal-qcom-8rggb"; 245 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8BGGR[] = "bayer-ideal-qcom-8bggr"; 246 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10GBRG[] = "bayer-ideal-qcom-10gbrg"; 247 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10GRBG[] = "bayer-ideal-qcom-10grbg"; 248 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10RGGB[] = "bayer-ideal-qcom-10rggb"; 249 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10BGGR[] = "bayer-ideal-qcom-10bggr"; 250 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12GBRG[] = "bayer-ideal-qcom-12gbrg"; 251 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12GRBG[] = "bayer-ideal-qcom-12grbg"; 252 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12RGGB[] = "bayer-ideal-qcom-12rggb"; 253 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12BGGR[] = "bayer-ideal-qcom-12bggr"; 254 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8GBRG[] = "bayer-ideal-mipi-8gbrg"; 255 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8GRBG[] = "bayer-ideal-mipi-8grbg"; 256 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8RGGB[] = "bayer-ideal-mipi-8rggb"; 257 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8BGGR[] = "bayer-ideal-mipi-8bggr"; 258 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10GBRG[] = "bayer-ideal-mipi-10gbrg"; 259 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10GRBG[] = "bayer-ideal-mipi-10grbg"; 260 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10RGGB[] = "bayer-ideal-mipi-10rggb"; 261 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10BGGR[] = "bayer-ideal-mipi-10bggr"; 262 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12GBRG[] = "bayer-ideal-mipi-12gbrg"; 263 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12GRBG[] = "bayer-ideal-mipi-12grbg"; 264 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12RGGB[] = "bayer-ideal-mipi-12rggb"; 265 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12BGGR[] = "bayer-ideal-mipi-12bggr"; 266 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8GBRG[] = "bayer-ideal-plain8-8gbrg"; 267 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8GRBG[] = "bayer-ideal-plain8-8grbg"; 268 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8RGGB[] = "bayer-ideal-plain8-8rggb"; 269 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8BGGR[] = "bayer-ideal-plain8-8bggr"; 270 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8GBRG[] = "bayer-ideal-plain16-8gbrg"; 271 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8GRBG[] = "bayer-ideal-plain16-8grbg"; 272 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8RGGB[] = "bayer-ideal-plain16-8rggb"; 273 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8BGGR[] = "bayer-ideal-plain16-8bggr"; 274 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10GBRG[] = "bayer-ideal-plain16-10gbrg"; 275 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10GRBG[] = "bayer-ideal-plain16-10grbg"; 276 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10RGGB[] = "bayer-ideal-plain16-10rggb"; 277 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10BGGR[] = "bayer-ideal-plain16-10bggr"; 278 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12GBRG[] = "bayer-ideal-plain16-12gbrg"; 279 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12GRBG[] = "bayer-ideal-plain16-12grbg"; 280 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12RGGB[] = "bayer-ideal-plain16-12rggb"; 281 const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12BGGR[] = "bayer-ideal-plain16-12bggr"; 282 283 // Values for ISO Settings 284 const char QCameraParameters::ISO_AUTO[] = "auto"; 285 const char QCameraParameters::ISO_100[] = "ISO100"; 286 const char QCameraParameters::ISO_200[] = "ISO200"; 287 const char QCameraParameters::ISO_400[] = "ISO400"; 288 const char QCameraParameters::ISO_800[] = "ISO800"; 289 const char QCameraParameters::ISO_1600[] = "ISO1600"; 290 const char QCameraParameters::ISO_3200[] = "ISO3200"; 291 const char QCameraParameters::ISO_MANUAL[] = "manual"; 292 293 294 // Values for auto exposure settings. 295 const char QCameraParameters::AUTO_EXPOSURE_FRAME_AVG[] = "frame-average"; 296 const char QCameraParameters::AUTO_EXPOSURE_CENTER_WEIGHTED[] = "center-weighted"; 297 const char QCameraParameters::AUTO_EXPOSURE_SPOT_METERING[] = "spot-metering"; 298 const char QCameraParameters::AUTO_EXPOSURE_SMART_METERING[] = "smart-metering"; 299 const char QCameraParameters::AUTO_EXPOSURE_USER_METERING[] = "user-metering"; 300 const char QCameraParameters::AUTO_EXPOSURE_SPOT_METERING_ADV[] = "spot-metering-adv"; 301 const char QCameraParameters::AUTO_EXPOSURE_CENTER_WEIGHTED_ADV[] = "center-weighted-adv"; 302 303 const char QCameraParameters::KEY_QC_GPS_LATITUDE_REF[] = "gps-latitude-ref"; 304 const char QCameraParameters::KEY_QC_GPS_LONGITUDE_REF[] = "gps-longitude-ref"; 305 const char QCameraParameters::KEY_QC_GPS_ALTITUDE_REF[] = "gps-altitude-ref"; 306 const char QCameraParameters::KEY_QC_GPS_STATUS[] = "gps-status"; 307 308 const char QCameraParameters::KEY_QC_HISTOGRAM[] = "histogram"; 309 const char QCameraParameters::KEY_QC_SUPPORTED_HISTOGRAM_MODES[] = "histogram-values"; 310 311 const char QCameraParameters::VALUE_ENABLE[] = "enable"; 312 const char QCameraParameters::VALUE_DISABLE[] = "disable"; 313 const char QCameraParameters::VALUE_OFF[] = "off"; 314 const char QCameraParameters::VALUE_ON[] = "on"; 315 const char QCameraParameters::VALUE_TRUE[] = "true"; 316 const char QCameraParameters::VALUE_FALSE[] = "false"; 317 318 const char QCameraParameters::KEY_QC_SHARPNESS[] = "sharpness"; 319 const char QCameraParameters::KEY_QC_MIN_SHARPNESS[] = "min-sharpness"; 320 const char QCameraParameters::KEY_QC_MAX_SHARPNESS[] = "max-sharpness"; 321 const char QCameraParameters::KEY_QC_SHARPNESS_STEP[] = "sharpness-step"; 322 const char QCameraParameters::KEY_QC_CONTRAST[] = "contrast"; 323 const char QCameraParameters::KEY_QC_MIN_CONTRAST[] = "min-contrast"; 324 const char QCameraParameters::KEY_QC_MAX_CONTRAST[] = "max-contrast"; 325 const char QCameraParameters::KEY_QC_CONTRAST_STEP[] = "contrast-step"; 326 const char QCameraParameters::KEY_QC_SATURATION[] = "saturation"; 327 const char QCameraParameters::KEY_QC_MIN_SATURATION[] = "min-saturation"; 328 const char QCameraParameters::KEY_QC_MAX_SATURATION[] = "max-saturation"; 329 const char QCameraParameters::KEY_QC_SATURATION_STEP[] = "saturation-step"; 330 const char QCameraParameters::KEY_QC_BRIGHTNESS[] = "luma-adaptation"; 331 const char QCameraParameters::KEY_QC_MIN_BRIGHTNESS[] = "min-brightness"; 332 const char QCameraParameters::KEY_QC_MAX_BRIGHTNESS[] = "max-brightness"; 333 const char QCameraParameters::KEY_QC_BRIGHTNESS_STEP[] = "brightness-step"; 334 const char QCameraParameters::KEY_QC_SCE_FACTOR[] = "skinToneEnhancement"; 335 const char QCameraParameters::KEY_QC_MIN_SCE_FACTOR[] = "min-sce-factor"; 336 const char QCameraParameters::KEY_QC_MAX_SCE_FACTOR[] = "max-sce-factor"; 337 const char QCameraParameters::KEY_QC_SCE_FACTOR_STEP[] = "sce-factor-step"; 338 339 const char QCameraParameters::KEY_QC_SUPPORTED_CAMERA_FEATURES[] = "qc-camera-features"; 340 const char QCameraParameters::KEY_QC_MAX_NUM_REQUESTED_FACES[] = "qc-max-num-requested-faces"; 341 342 //Values for DENOISE 343 const char QCameraParameters::DENOISE_OFF[] = "denoise-off"; 344 const char QCameraParameters::DENOISE_ON[] = "denoise-on"; 345 346 // Values for selectable zone af Settings 347 const char QCameraParameters::FOCUS_ALGO_AUTO[] = "auto"; 348 const char QCameraParameters::FOCUS_ALGO_SPOT_METERING[] = "spot-metering"; 349 const char QCameraParameters::FOCUS_ALGO_CENTER_WEIGHTED[] = "center-weighted"; 350 const char QCameraParameters::FOCUS_ALGO_FRAME_AVERAGE[] = "frame-average"; 351 352 // Values for HFR settings. 353 const char QCameraParameters::VIDEO_HFR_OFF[] = "off"; 354 const char QCameraParameters::VIDEO_HFR_2X[] = "60"; 355 const char QCameraParameters::VIDEO_HFR_3X[] = "90"; 356 const char QCameraParameters::VIDEO_HFR_4X[] = "120"; 357 const char QCameraParameters::VIDEO_HFR_5X[] = "150"; 358 const char QCameraParameters::VIDEO_HFR_6X[] = "180"; 359 const char QCameraParameters::VIDEO_HFR_7X[] = "210"; 360 const char QCameraParameters::VIDEO_HFR_8X[] = "240"; 361 const char QCameraParameters::VIDEO_HFR_9X[] = "480"; 362 363 // Values for HDR Bracketing settings. 364 const char QCameraParameters::AE_BRACKET_OFF[] = "Off"; 365 const char QCameraParameters::AE_BRACKET[] = "AE-Bracket"; 366 367 // Values for AF Bracketing setting. 368 const char QCameraParameters::AF_BRACKET_OFF[] = "af-bracket-off"; 369 const char QCameraParameters::AF_BRACKET_ON[] = "af-bracket-on"; 370 371 // Values for Refocus setting. 372 const char QCameraParameters::RE_FOCUS_OFF[] = "re-focus-off"; 373 const char QCameraParameters::RE_FOCUS_ON[] = "re-focus-on"; 374 375 // Values for Chroma Flash setting. 376 const char QCameraParameters::CHROMA_FLASH_OFF[] = "chroma-flash-off"; 377 const char QCameraParameters::CHROMA_FLASH_ON[] = "chroma-flash-on"; 378 379 // Values for Opti Zoom setting. 380 const char QCameraParameters::OPTI_ZOOM_OFF[] = "opti-zoom-off"; 381 const char QCameraParameters::OPTI_ZOOM_ON[] = "opti-zoom-on"; 382 383 // Values for Still More setting. 384 const char QCameraParameters::STILL_MORE_OFF[] = "still-more-off"; 385 const char QCameraParameters::STILL_MORE_ON[] = "still-more-on"; 386 387 // Values for HDR mode setting. 388 const char QCameraParameters::HDR_MODE_SENSOR[] = "hdr-mode-sensor"; 389 const char QCameraParameters::HDR_MODE_MULTI_FRAME[] = "hdr-mode-multiframe"; 390 391 // Values for True Portrait setting. 392 const char QCameraParameters::TRUE_PORTRAIT_OFF[] = "true-portrait-off"; 393 const char QCameraParameters::TRUE_PORTRAIT_ON[] = "true-portrait-on"; 394 395 // Values for FLIP settings. 396 const char QCameraParameters::FLIP_MODE_OFF[] = "off"; 397 const char QCameraParameters::FLIP_MODE_V[] = "flip-v"; 398 const char QCameraParameters::FLIP_MODE_H[] = "flip-h"; 399 const char QCameraParameters::FLIP_MODE_VH[] = "flip-vh"; 400 401 const char QCameraParameters::CDS_MODE_OFF[] = "off"; 402 const char QCameraParameters::CDS_MODE_ON[] = "on"; 403 const char QCameraParameters::CDS_MODE_AUTO[] = "auto"; 404 405 const char QCameraParameters::KEY_SELECTED_AUTO_SCENE[] = "selected-auto-scene"; 406 407 // Values for video rotation settings. 408 const char QCameraParameters::VIDEO_ROTATION_0[] = "0"; 409 const char QCameraParameters::VIDEO_ROTATION_90[] = "90"; 410 const char QCameraParameters::VIDEO_ROTATION_180[] = "180"; 411 const char QCameraParameters::VIDEO_ROTATION_270[] = "270"; 412 413 const char QCameraParameters::KEY_QC_SUPPORTED_MANUAL_FOCUS_MODES[] = "manual-focus-modes"; 414 const char QCameraParameters::KEY_QC_SUPPORTED_MANUAL_EXPOSURE_MODES[] = "manual-exposure-modes"; 415 const char QCameraParameters::KEY_QC_SUPPORTED_MANUAL_WB_MODES[] = "manual-wb-modes"; 416 const char QCameraParameters::KEY_QC_FOCUS_SCALE_MODE[] = "scale-mode"; 417 const char QCameraParameters::KEY_QC_FOCUS_DIOPTER_MODE[] = "diopter-mode"; 418 const char QCameraParameters::KEY_QC_ISO_PRIORITY[] = "iso-priority"; 419 const char QCameraParameters::KEY_QC_EXP_TIME_PRIORITY[] = "exp-time-priority"; 420 const char QCameraParameters::KEY_QC_USER_SETTING[] = "user-setting"; 421 const char QCameraParameters::KEY_QC_WB_CCT_MODE[] = "color-temperature"; 422 const char QCameraParameters::KEY_QC_WB_GAIN_MODE[] = "rbgb-gains"; 423 424 static const char* portrait = "portrait"; 425 static const char* landscape = "landscape"; 426 427 const cam_dimension_t QCameraParameters::THUMBNAIL_SIZES_MAP[] = { 428 { 512, 288 }, //1.777778 429 { 480, 288 }, //1.666667 430 { 256, 154 }, //1.66233 431 { 432, 288 }, //1.5 432 { 320, 320 }, //1.0 433 { 320, 240 }, //1.33333 434 { 176, 144 }, //1.222222 435 { 0, 0 } // required by Android SDK 436 }; 437 438 const QCameraParameters::QCameraMap<cam_auto_exposure_mode_type> 439 QCameraParameters::AUTO_EXPOSURE_MAP[] = { 440 { AUTO_EXPOSURE_FRAME_AVG, CAM_AEC_MODE_FRAME_AVERAGE }, 441 { AUTO_EXPOSURE_CENTER_WEIGHTED, CAM_AEC_MODE_CENTER_WEIGHTED }, 442 { AUTO_EXPOSURE_SPOT_METERING, CAM_AEC_MODE_SPOT_METERING }, 443 { AUTO_EXPOSURE_SMART_METERING, CAM_AEC_MODE_SMART_METERING }, 444 { AUTO_EXPOSURE_USER_METERING, CAM_AEC_MODE_USER_METERING }, 445 { AUTO_EXPOSURE_SPOT_METERING_ADV, CAM_AEC_MODE_SPOT_METERING_ADV }, 446 { AUTO_EXPOSURE_CENTER_WEIGHTED_ADV, CAM_AEC_MODE_CENTER_WEIGHTED_ADV }, 447 }; 448 449 const QCameraParameters::QCameraMap<cam_format_t> 450 QCameraParameters::PREVIEW_FORMATS_MAP[] = { 451 {PIXEL_FORMAT_YUV420SP, CAM_FORMAT_YUV_420_NV21}, 452 {PIXEL_FORMAT_YUV420P, CAM_FORMAT_YUV_420_YV12}, 453 {PIXEL_FORMAT_YUV420SP_ADRENO, CAM_FORMAT_YUV_420_NV21_ADRENO}, 454 {PIXEL_FORMAT_YV12, CAM_FORMAT_YUV_420_YV12}, 455 {PIXEL_FORMAT_NV12, CAM_FORMAT_YUV_420_NV12}, 456 {QC_PIXEL_FORMAT_NV12_VENUS, CAM_FORMAT_YUV_420_NV12_VENUS} 457 }; 458 459 const QCameraParameters::QCameraMap<cam_format_t> 460 QCameraParameters::PICTURE_TYPES_MAP[] = { 461 {PIXEL_FORMAT_JPEG, CAM_FORMAT_JPEG}, 462 {PIXEL_FORMAT_YUV420SP, CAM_FORMAT_YUV_420_NV21}, 463 {PIXEL_FORMAT_YUV422SP, CAM_FORMAT_YUV_422_NV16}, 464 {QC_PIXEL_FORMAT_YUV_RAW_8BIT_YUYV, CAM_FORMAT_YUV_RAW_8BIT_YUYV}, 465 {QC_PIXEL_FORMAT_YUV_RAW_8BIT_YVYU, CAM_FORMAT_YUV_RAW_8BIT_YVYU}, 466 {QC_PIXEL_FORMAT_YUV_RAW_8BIT_UYVY, CAM_FORMAT_YUV_RAW_8BIT_UYVY}, 467 {QC_PIXEL_FORMAT_YUV_RAW_8BIT_VYUY, CAM_FORMAT_YUV_RAW_8BIT_VYUY}, 468 {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8GBRG, CAM_FORMAT_BAYER_QCOM_RAW_8BPP_GBRG}, 469 {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8GRBG, CAM_FORMAT_BAYER_QCOM_RAW_8BPP_GRBG}, 470 {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8RGGB, CAM_FORMAT_BAYER_QCOM_RAW_8BPP_RGGB}, 471 {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8BGGR, CAM_FORMAT_BAYER_QCOM_RAW_8BPP_BGGR}, 472 {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10GBRG, CAM_FORMAT_BAYER_QCOM_RAW_10BPP_GBRG}, 473 {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10GRBG, CAM_FORMAT_BAYER_QCOM_RAW_10BPP_GRBG}, 474 {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10RGGB, CAM_FORMAT_BAYER_QCOM_RAW_10BPP_RGGB}, 475 {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10BGGR, CAM_FORMAT_BAYER_QCOM_RAW_10BPP_BGGR}, 476 {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12GBRG, CAM_FORMAT_BAYER_QCOM_RAW_12BPP_GBRG}, 477 {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12GRBG, CAM_FORMAT_BAYER_QCOM_RAW_12BPP_GRBG}, 478 {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12RGGB, CAM_FORMAT_BAYER_QCOM_RAW_12BPP_RGGB}, 479 {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12BGGR, CAM_FORMAT_BAYER_QCOM_RAW_12BPP_BGGR}, 480 {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8GBRG, CAM_FORMAT_BAYER_MIPI_RAW_8BPP_GBRG}, 481 {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8GRBG, CAM_FORMAT_BAYER_MIPI_RAW_8BPP_GRBG}, 482 {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8RGGB, CAM_FORMAT_BAYER_MIPI_RAW_8BPP_RGGB}, 483 {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8BGGR, CAM_FORMAT_BAYER_MIPI_RAW_8BPP_BGGR}, 484 {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10GBRG, CAM_FORMAT_BAYER_MIPI_RAW_10BPP_GBRG}, 485 {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10GRBG, CAM_FORMAT_BAYER_MIPI_RAW_10BPP_GRBG}, 486 {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10RGGB, CAM_FORMAT_BAYER_MIPI_RAW_10BPP_RGGB}, 487 {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10BGGR, CAM_FORMAT_BAYER_MIPI_RAW_10BPP_BGGR}, 488 {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12GBRG, CAM_FORMAT_BAYER_MIPI_RAW_12BPP_GBRG}, 489 {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12GRBG, CAM_FORMAT_BAYER_MIPI_RAW_12BPP_GRBG}, 490 {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12RGGB, CAM_FORMAT_BAYER_MIPI_RAW_12BPP_RGGB}, 491 {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12BGGR, CAM_FORMAT_BAYER_MIPI_RAW_12BPP_BGGR}, 492 {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_GBRG}, 493 {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_GRBG}, 494 {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_RGGB}, 495 {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_BGGR}, 496 {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_GBRG}, 497 {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_GRBG}, 498 {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_RGGB}, 499 {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_BGGR}, 500 {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_GBRG}, 501 {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_GRBG}, 502 {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_RGGB}, 503 {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_BGGR}, 504 {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_GBRG}, 505 {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_GRBG}, 506 {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_RGGB}, 507 {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_BGGR}, 508 {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_GBRG}, 509 {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_GRBG}, 510 {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_RGGB}, 511 {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_BGGR}, 512 {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_GBRG}, 513 {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_GRBG}, 514 {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_RGGB}, 515 {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_BGGR}, 516 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_GBRG}, 517 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_GRBG}, 518 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_RGGB}, 519 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_BGGR}, 520 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_GBRG}, 521 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_GRBG}, 522 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_RGGB}, 523 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_BGGR}, 524 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_GBRG}, 525 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_GRBG}, 526 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_RGGB}, 527 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_BGGR}, 528 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_GBRG}, 529 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_GRBG}, 530 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_RGGB}, 531 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_BGGR} 532 }; 533 534 const QCameraParameters::QCameraMap<cam_focus_mode_type> 535 QCameraParameters::FOCUS_MODES_MAP[] = { 536 { FOCUS_MODE_AUTO, CAM_FOCUS_MODE_AUTO }, 537 { FOCUS_MODE_INFINITY, CAM_FOCUS_MODE_INFINITY }, 538 { FOCUS_MODE_MACRO, CAM_FOCUS_MODE_MACRO }, 539 { FOCUS_MODE_FIXED, CAM_FOCUS_MODE_FIXED }, 540 { FOCUS_MODE_EDOF, CAM_FOCUS_MODE_EDOF }, 541 { FOCUS_MODE_CONTINUOUS_PICTURE, CAM_FOCUS_MODE_CONTINOUS_PICTURE }, 542 { FOCUS_MODE_CONTINUOUS_VIDEO, CAM_FOCUS_MODE_CONTINOUS_VIDEO }, 543 { FOCUS_MODE_MANUAL_POSITION, CAM_FOCUS_MODE_MANUAL}, 544 }; 545 546 const QCameraParameters::QCameraMap<cam_effect_mode_type> 547 QCameraParameters::EFFECT_MODES_MAP[] = { 548 { EFFECT_NONE, CAM_EFFECT_MODE_OFF }, 549 { EFFECT_MONO, CAM_EFFECT_MODE_MONO }, 550 { EFFECT_NEGATIVE, CAM_EFFECT_MODE_NEGATIVE }, 551 { EFFECT_SOLARIZE, CAM_EFFECT_MODE_SOLARIZE }, 552 { EFFECT_SEPIA, CAM_EFFECT_MODE_SEPIA }, 553 { EFFECT_POSTERIZE, CAM_EFFECT_MODE_POSTERIZE }, 554 { EFFECT_WHITEBOARD, CAM_EFFECT_MODE_WHITEBOARD }, 555 { EFFECT_BLACKBOARD, CAM_EFFECT_MODE_BLACKBOARD }, 556 { EFFECT_AQUA, CAM_EFFECT_MODE_AQUA }, 557 { EFFECT_EMBOSS, CAM_EFFECT_MODE_EMBOSS }, 558 { EFFECT_SKETCH, CAM_EFFECT_MODE_SKETCH }, 559 { EFFECT_NEON, CAM_EFFECT_MODE_NEON } 560 }; 561 562 const QCameraParameters::QCameraMap<cam_scene_mode_type> 563 QCameraParameters::SCENE_MODES_MAP[] = { 564 { SCENE_MODE_AUTO, CAM_SCENE_MODE_OFF }, 565 { SCENE_MODE_ACTION, CAM_SCENE_MODE_ACTION }, 566 { SCENE_MODE_PORTRAIT, CAM_SCENE_MODE_PORTRAIT }, 567 { SCENE_MODE_LANDSCAPE, CAM_SCENE_MODE_LANDSCAPE }, 568 { SCENE_MODE_NIGHT, CAM_SCENE_MODE_NIGHT }, 569 { SCENE_MODE_NIGHT_PORTRAIT, CAM_SCENE_MODE_NIGHT_PORTRAIT }, 570 { SCENE_MODE_THEATRE, CAM_SCENE_MODE_THEATRE }, 571 { SCENE_MODE_BEACH, CAM_SCENE_MODE_BEACH }, 572 { SCENE_MODE_SNOW, CAM_SCENE_MODE_SNOW }, 573 { SCENE_MODE_SUNSET, CAM_SCENE_MODE_SUNSET }, 574 { SCENE_MODE_STEADYPHOTO, CAM_SCENE_MODE_ANTISHAKE }, 575 { SCENE_MODE_FIREWORKS , CAM_SCENE_MODE_FIREWORKS }, 576 { SCENE_MODE_SPORTS , CAM_SCENE_MODE_SPORTS }, 577 { SCENE_MODE_PARTY, CAM_SCENE_MODE_PARTY }, 578 { SCENE_MODE_CANDLELIGHT, CAM_SCENE_MODE_CANDLELIGHT }, 579 { SCENE_MODE_ASD, CAM_SCENE_MODE_AUTO }, 580 { SCENE_MODE_BACKLIGHT, CAM_SCENE_MODE_BACKLIGHT }, 581 { SCENE_MODE_FLOWERS, CAM_SCENE_MODE_FLOWERS }, 582 { SCENE_MODE_AR, CAM_SCENE_MODE_AR }, 583 { SCENE_MODE_HDR, CAM_SCENE_MODE_HDR }, 584 }; 585 586 const QCameraParameters::QCameraMap<cam_flash_mode_t> 587 QCameraParameters::FLASH_MODES_MAP[] = { 588 { FLASH_MODE_OFF, CAM_FLASH_MODE_OFF }, 589 { FLASH_MODE_AUTO, CAM_FLASH_MODE_AUTO }, 590 { FLASH_MODE_ON, CAM_FLASH_MODE_ON }, 591 { FLASH_MODE_TORCH, CAM_FLASH_MODE_TORCH } 592 }; 593 594 const QCameraParameters::QCameraMap<cam_focus_algorithm_type> 595 QCameraParameters::FOCUS_ALGO_MAP[] = { 596 { FOCUS_ALGO_AUTO, CAM_FOCUS_ALGO_AUTO }, 597 { FOCUS_ALGO_SPOT_METERING, CAM_FOCUS_ALGO_SPOT }, 598 { FOCUS_ALGO_CENTER_WEIGHTED, CAM_FOCUS_ALGO_CENTER_WEIGHTED }, 599 { FOCUS_ALGO_FRAME_AVERAGE, CAM_FOCUS_ALGO_AVERAGE } 600 }; 601 602 const QCameraParameters::QCameraMap<cam_wb_mode_type> 603 QCameraParameters::WHITE_BALANCE_MODES_MAP[] = { 604 { WHITE_BALANCE_AUTO, CAM_WB_MODE_AUTO }, 605 { WHITE_BALANCE_INCANDESCENT, CAM_WB_MODE_INCANDESCENT }, 606 { WHITE_BALANCE_FLUORESCENT, CAM_WB_MODE_FLUORESCENT }, 607 { WHITE_BALANCE_WARM_FLUORESCENT,CAM_WB_MODE_WARM_FLUORESCENT}, 608 { WHITE_BALANCE_DAYLIGHT, CAM_WB_MODE_DAYLIGHT }, 609 { WHITE_BALANCE_CLOUDY_DAYLIGHT, CAM_WB_MODE_CLOUDY_DAYLIGHT }, 610 { WHITE_BALANCE_TWILIGHT, CAM_WB_MODE_TWILIGHT }, 611 { WHITE_BALANCE_SHADE, CAM_WB_MODE_SHADE }, 612 { WHITE_BALANCE_MANUAL, CAM_WB_MODE_MANUAL}, 613 }; 614 615 const QCameraParameters::QCameraMap<cam_antibanding_mode_type> 616 QCameraParameters::ANTIBANDING_MODES_MAP[] = { 617 { ANTIBANDING_OFF, CAM_ANTIBANDING_MODE_OFF }, 618 { ANTIBANDING_50HZ, CAM_ANTIBANDING_MODE_50HZ }, 619 { ANTIBANDING_60HZ, CAM_ANTIBANDING_MODE_60HZ }, 620 { ANTIBANDING_AUTO, CAM_ANTIBANDING_MODE_AUTO } 621 }; 622 623 const QCameraParameters::QCameraMap<cam_iso_mode_type> 624 QCameraParameters::ISO_MODES_MAP[] = { 625 { ISO_AUTO, CAM_ISO_MODE_AUTO }, 626 { ISO_HJR, CAM_ISO_MODE_DEBLUR }, 627 { ISO_100, CAM_ISO_MODE_100 }, 628 { ISO_200, CAM_ISO_MODE_200 }, 629 { ISO_400, CAM_ISO_MODE_400 }, 630 { ISO_800, CAM_ISO_MODE_800 }, 631 { ISO_1600, CAM_ISO_MODE_1600 }, 632 { ISO_3200, CAM_ISO_MODE_3200 } 633 }; 634 635 const QCameraParameters::QCameraMap<cam_hfr_mode_t> 636 QCameraParameters::HFR_MODES_MAP[] = { 637 { VIDEO_HFR_OFF, CAM_HFR_MODE_OFF }, 638 { VIDEO_HFR_2X, CAM_HFR_MODE_60FPS }, 639 { VIDEO_HFR_3X, CAM_HFR_MODE_90FPS }, 640 { VIDEO_HFR_4X, CAM_HFR_MODE_120FPS }, 641 { VIDEO_HFR_5X, CAM_HFR_MODE_150FPS }, 642 { VIDEO_HFR_6X, CAM_HFR_MODE_180FPS }, 643 { VIDEO_HFR_7X, CAM_HFR_MODE_210FPS }, 644 { VIDEO_HFR_8X, CAM_HFR_MODE_240FPS }, 645 { VIDEO_HFR_9X, CAM_HFR_MODE_480FPS } 646 }; 647 648 const QCameraParameters::QCameraMap<cam_bracket_mode> 649 QCameraParameters::BRACKETING_MODES_MAP[] = { 650 { AE_BRACKET_OFF, CAM_EXP_BRACKETING_OFF }, 651 { AE_BRACKET, CAM_EXP_BRACKETING_ON } 652 }; 653 654 const QCameraParameters::QCameraMap<int> 655 QCameraParameters::ON_OFF_MODES_MAP[] = { 656 { VALUE_OFF, 0 }, 657 { VALUE_ON, 1 } 658 }; 659 660 const QCameraParameters::QCameraMap<int> 661 QCameraParameters::TOUCH_AF_AEC_MODES_MAP[] = { 662 { QCameraParameters::TOUCH_AF_AEC_OFF, 0 }, 663 { QCameraParameters::TOUCH_AF_AEC_ON, 1 } 664 }; 665 666 const QCameraParameters::QCameraMap<int> 667 QCameraParameters::ENABLE_DISABLE_MODES_MAP[] = { 668 { VALUE_ENABLE, 1 }, 669 { VALUE_DISABLE, 0 } 670 }; 671 672 const QCameraParameters::QCameraMap<int> 673 QCameraParameters::DENOISE_ON_OFF_MODES_MAP[] = { 674 { DENOISE_OFF, 0 }, 675 { DENOISE_ON, 1 } 676 }; 677 678 const QCameraParameters::QCameraMap<int> 679 QCameraParameters::TRUE_FALSE_MODES_MAP[] = { 680 { VALUE_FALSE, 0}, 681 { VALUE_TRUE, 1} 682 }; 683 684 const QCameraParameters::QCameraMap<cam_flip_t> 685 QCameraParameters::FLIP_MODES_MAP[] = { 686 {FLIP_MODE_OFF, FLIP_NONE}, 687 {FLIP_MODE_V, FLIP_V}, 688 {FLIP_MODE_H, FLIP_H}, 689 {FLIP_MODE_VH, FLIP_V_H} 690 }; 691 692 const QCameraParameters::QCameraMap<int> 693 QCameraParameters::AF_BRACKETING_MODES_MAP[] = { 694 { AF_BRACKET_OFF, 0 }, 695 { AF_BRACKET_ON, 1 } 696 }; 697 698 const QCameraParameters::QCameraMap<int> 699 QCameraParameters::RE_FOCUS_MODES_MAP[] = { 700 { RE_FOCUS_OFF, 0 }, 701 { RE_FOCUS_ON, 1 } 702 }; 703 704 const QCameraParameters::QCameraMap<int> 705 QCameraParameters::CHROMA_FLASH_MODES_MAP[] = { 706 { CHROMA_FLASH_OFF, 0 }, 707 { CHROMA_FLASH_ON, 1 } 708 }; 709 710 const QCameraParameters::QCameraMap<int> 711 QCameraParameters::OPTI_ZOOM_MODES_MAP[] = { 712 { OPTI_ZOOM_OFF, 0 }, 713 { OPTI_ZOOM_ON, 1 } 714 }; 715 716 const QCameraParameters::QCameraMap<int> 717 QCameraParameters::TRUE_PORTRAIT_MODES_MAP[] = { 718 { TRUE_PORTRAIT_OFF, 0 }, 719 { TRUE_PORTRAIT_ON, 1 } 720 }; 721 722 const QCameraParameters::QCameraMap<int> 723 QCameraParameters::STILL_MORE_MODES_MAP[] = { 724 { STILL_MORE_OFF, 0 }, 725 { STILL_MORE_ON, 1 } 726 }; 727 728 const QCameraParameters::QCameraMap<cam_cds_mode_type_t> 729 QCameraParameters::CDS_MODES_MAP[] = { 730 { CDS_MODE_OFF, CAM_CDS_MODE_OFF }, 731 { CDS_MODE_ON, CAM_CDS_MODE_ON }, 732 { CDS_MODE_AUTO, CAM_CDS_MODE_AUTO} 733 }; 734 735 const QCameraParameters::QCameraMap<int> 736 QCameraParameters::HDR_MODES_MAP[] = { 737 { HDR_MODE_SENSOR, 0 }, 738 { HDR_MODE_MULTI_FRAME, 1 } 739 }; 740 741 const QCameraParameters::QCameraMap<int> 742 QCameraParameters::VIDEO_ROTATION_MODES_MAP[] = { 743 { VIDEO_ROTATION_0, 0 }, 744 { VIDEO_ROTATION_90, 90 }, 745 { VIDEO_ROTATION_180, 180 }, 746 { VIDEO_ROTATION_270, 270 } 747 }; 748 749 #define DEFAULT_CAMERA_AREA "(0, 0, 0, 0, 0)" 750 #define DATA_PTR(MEM_OBJ,INDEX) MEM_OBJ->getPtr( INDEX ) 751 #define TOTAL_RAM_SIZE_512MB 536870912 752 #define PARAM_MAP_SIZE(MAP) (sizeof(MAP)/sizeof(MAP[0])) 753 754 /*=========================================================================== 755 * FUNCTION : QCameraParameters 756 * 757 * DESCRIPTION: default constructor of QCameraParameters 758 * 759 * PARAMETERS : none 760 * 761 * RETURN : None 762 *==========================================================================*/ 763 QCameraParameters::QCameraParameters() 764 : CameraParameters(), 765 m_reprocScaleParam(this), 766 m_pCapability(NULL), 767 m_pCamOpsTbl(NULL), 768 m_pParamHeap(NULL), 769 m_pParamBuf(NULL), 770 mIsType(IS_TYPE_NONE), 771 m_bZslMode(false), 772 m_bZslMode_new(false), 773 m_bForceZslMode(false), 774 m_bRecordingHint(false), 775 m_bRecordingHint_new(false), 776 m_bHistogramEnabled(false), 777 m_nFaceProcMask(0), 778 m_bFaceDetectionOn(0), 779 m_bDebugFps(false), 780 mFocusMode(CAM_FOCUS_MODE_MAX), 781 mPreviewFormat(CAM_FORMAT_YUV_420_NV21), 782 mPictureFormat(CAM_FORMAT_JPEG), 783 m_bNeedRestart(false), 784 m_bNoDisplayMode(false), 785 m_bWNROn(false), 786 m_bInited(false), 787 m_nBurstNum(1), 788 m_nRetroBurstNum(0), 789 m_nBurstLEDOnPeriod(100), 790 m_bUpdateEffects(false), 791 m_bSceneTransitionAuto(false), 792 m_bPreviewFlipChanged(false), 793 m_bVideoFlipChanged(false), 794 m_bSnapshotFlipChanged(false), 795 m_bFixedFrameRateSet(false), 796 m_bHDREnabled(false), 797 m_bAVTimerEnabled(false), 798 m_bDISEnabled(false), 799 m_MobiMask(0), 800 m_AdjustFPS(NULL), 801 m_bHDR1xFrameEnabled(true), 802 m_HDRSceneEnabled(false), 803 m_bHDRThumbnailProcessNeeded(false), 804 m_bHDR1xExtraBufferNeeded(true), 805 m_bHDROutputCropEnabled(false), 806 m_tempMap(), 807 m_bAFBracketingOn(false), 808 m_bReFocusOn(false), 809 m_bChromaFlashOn(false), 810 m_bOptiZoomOn(false), 811 m_bSceneSelection(false), 812 m_SelectedScene(CAM_SCENE_MODE_MAX), 813 m_bSeeMoreOn(false), 814 m_bStillMoreOn(false), 815 m_bHfrMode(false), 816 m_bSensorHDREnabled(false), 817 m_bRdiMode(false), 818 m_bDisplayFrame(true), 819 m_bSecureMode(false), 820 m_bAeBracketingEnabled(false), 821 mFlashValue(CAM_FLASH_MODE_OFF), 822 mFlashDaemonValue(CAM_FLASH_MODE_OFF), 823 mHfrMode(CAM_HFR_MODE_OFF), 824 m_bHDRModeSensor(true), 825 mOfflineRAW(false), 826 m_bTruePortraitOn(false), 827 mCds_mode(CAM_CDS_MODE_OFF) 828 { 829 char value[PROPERTY_VALUE_MAX]; 830 // TODO: may move to parameter instead of sysprop 831 property_get("persist.debug.sf.showfps", value, "0"); 832 m_bDebugFps = atoi(value) > 0 ? true : false; 833 834 // For thermal mode, it should be set as system property 835 // because system property applies to all applications, while 836 // parameters only apply to specific app. 837 property_get("persist.camera.thermal.mode", value, "fps"); 838 if (!strcmp(value, "frameskip")) { 839 m_ThermalMode = QCAMERA_THERMAL_ADJUST_FRAMESKIP; 840 } else { 841 if (strcmp(value, "fps")) 842 ALOGE("%s: Invalid camera thermal mode %s", __func__, value); 843 m_ThermalMode = QCAMERA_THERMAL_ADJUST_FPS; 844 } 845 846 memset(&m_LiveSnapshotSize, 0, sizeof(m_LiveSnapshotSize)); 847 memset(&m_default_fps_range, 0, sizeof(m_default_fps_range)); 848 memset(&m_hfrFpsRange, 0, sizeof(m_hfrFpsRange)); 849 memset(&m_stillmore_config, 0, sizeof(cam_still_more_t)); 850 memset(&m_captureFrameConfig, 0, sizeof(cam_capture_frame_config_t)); 851 mTotalPPCount = 0; 852 mZoomLevel = 0; 853 mParmZoomLevel = 0; 854 mCurPPCount = 0; 855 mBufBatchCnt = 0; 856 mRotation = 0; 857 } 858 859 /*=========================================================================== 860 * FUNCTION : QCameraParameters 861 * 862 * DESCRIPTION: constructor of QCameraParameters 863 * 864 * PARAMETERS : 865 * @params : parameters in string 866 * 867 * RETURN : None 868 *==========================================================================*/ 869 QCameraParameters::QCameraParameters(const String8 ¶ms) 870 : CameraParameters(params), 871 m_reprocScaleParam(this), 872 m_pCapability(NULL), 873 m_pCamOpsTbl(NULL), 874 m_pParamHeap(NULL), 875 m_pParamBuf(NULL), 876 m_bZslMode(false), 877 m_bZslMode_new(false), 878 m_bForceZslMode(false), 879 m_bRecordingHint(false), 880 m_bRecordingHint_new(false), 881 m_bHistogramEnabled(false), 882 m_nFaceProcMask(0), 883 m_bDebugFps(false), 884 mFocusMode(CAM_FOCUS_MODE_MAX), 885 mPreviewFormat(CAM_FORMAT_YUV_420_NV21), 886 mPictureFormat(CAM_FORMAT_JPEG), 887 m_bNeedRestart(false), 888 m_bNoDisplayMode(false), 889 m_bWNROn(false), 890 m_bTNRPreviewOn(false), 891 m_bTNRVideoOn(false), 892 m_bInited(false), 893 m_nBurstNum(1), 894 m_nRetroBurstNum(0), 895 m_nBurstLEDOnPeriod(100), 896 m_bPreviewFlipChanged(false), 897 m_bVideoFlipChanged(false), 898 m_bSnapshotFlipChanged(false), 899 m_bFixedFrameRateSet(false), 900 m_bHDREnabled(false), 901 m_bAVTimerEnabled(false), 902 m_AdjustFPS(NULL), 903 m_bHDR1xFrameEnabled(true), 904 m_HDRSceneEnabled(false), 905 m_bHDRThumbnailProcessNeeded(false), 906 m_bHDR1xExtraBufferNeeded(true), 907 m_bHDROutputCropEnabled(false), 908 m_tempMap(), 909 m_bAFBracketingOn(false), 910 m_bReFocusOn(false), 911 m_bChromaFlashOn(false), 912 m_bOptiZoomOn(false), 913 m_bSceneSelection(false), 914 m_SelectedScene(CAM_SCENE_MODE_MAX), 915 m_bSeeMoreOn(false), 916 m_bStillMoreOn(false), 917 m_bHfrMode(false), 918 m_bSensorHDREnabled(false), 919 m_bRdiMode(false), 920 m_bSecureMode(false), 921 m_bAeBracketingEnabled(false), 922 mFlashValue(CAM_FLASH_MODE_OFF), 923 mFlashDaemonValue(CAM_FLASH_MODE_OFF), 924 mHfrMode(CAM_HFR_MODE_OFF), 925 m_bHDRModeSensor(true), 926 mOfflineRAW(false), 927 m_bTruePortraitOn(false), 928 mCds_mode(CAM_CDS_MODE_OFF), 929 mParmEffect(CAM_EFFECT_MODE_OFF) 930 { 931 memset(&m_LiveSnapshotSize, 0, sizeof(m_LiveSnapshotSize)); 932 memset(&m_default_fps_range, 0, sizeof(m_default_fps_range)); 933 memset(&m_hfrFpsRange, 0, sizeof(m_hfrFpsRange)); 934 memset(&m_stillmore_config, 0, sizeof(cam_still_more_t)); 935 mTotalPPCount = 0; 936 mZoomLevel = 0; 937 mParmZoomLevel = 0; 938 mCurPPCount = 0; 939 mRotation = 0; 940 } 941 942 /*=========================================================================== 943 * FUNCTION : ~QCameraParameters 944 * 945 * DESCRIPTION: deconstructor of QCameraParameters 946 * 947 * PARAMETERS : none 948 * 949 * RETURN : None 950 *==========================================================================*/ 951 QCameraParameters::~QCameraParameters() 952 { 953 deinit(); 954 } 955 956 /*=========================================================================== 957 * FUNCTION : createSizesString 958 * 959 * DESCRIPTION: create string obj contains array of dimensions 960 * 961 * PARAMETERS : 962 * @sizes : array of dimensions 963 * @len : size of dimension array 964 * 965 * RETURN : string obj 966 *==========================================================================*/ 967 String8 QCameraParameters::createSizesString(const cam_dimension_t *sizes, size_t len) 968 { 969 String8 str; 970 char buffer[32]; 971 972 if (len > 0) { 973 snprintf(buffer, sizeof(buffer), "%dx%d", sizes[0].width, sizes[0].height); 974 str.append(buffer); 975 } 976 for (size_t i = 1; i < len; i++) { 977 snprintf(buffer, sizeof(buffer), ",%dx%d", 978 sizes[i].width, sizes[i].height); 979 str.append(buffer); 980 } 981 return str; 982 } 983 984 /*=========================================================================== 985 * FUNCTION : createValuesString 986 * 987 * DESCRIPTION: create string obj contains array of values from map when matched 988 * from input values array 989 * 990 * PARAMETERS : 991 * @values : array of values 992 * @len : size of values array 993 * @map : map contains the mapping between values and enums 994 * @map_len : size of the map 995 * 996 * RETURN : string obj 997 *==========================================================================*/ 998 template <typename valuesType, class mapType> String8 createValuesString( 999 const valuesType *values, size_t len, const mapType *map, size_t map_len) 1000 { 1001 String8 str; 1002 int count = 0; 1003 1004 for (size_t i = 0; i < len; i++ ) { 1005 for (size_t j = 0; j < map_len; j ++) 1006 if (map[j].val == values[i]) { 1007 if (NULL != map[j].desc) { 1008 if (count > 0) { 1009 str.append(","); 1010 } 1011 str.append(map[j].desc); 1012 count++; 1013 break; //loop j 1014 } 1015 } 1016 } 1017 return str; 1018 } 1019 1020 /*=========================================================================== 1021 * FUNCTION : createValuesStringFromMap 1022 * 1023 * DESCRIPTION: create string obj contains array of values directly from map 1024 * 1025 * PARAMETERS : 1026 * @map : map contains the mapping between values and enums 1027 * @map_len : size of the map 1028 * 1029 * RETURN : string obj 1030 *==========================================================================*/ 1031 template <class mapType> String8 createValuesStringFromMap( 1032 const mapType *map, size_t map_len) 1033 { 1034 String8 str; 1035 1036 for (size_t i = 0; i < map_len; i++) { 1037 if (NULL != map[i].desc) { 1038 if (i > 0) { 1039 str.append(","); 1040 } 1041 str.append(map[i].desc); 1042 } 1043 } 1044 return str; 1045 } 1046 1047 /*=========================================================================== 1048 * FUNCTION : createZoomRatioValuesString 1049 * 1050 * DESCRIPTION: create string obj contains array of zoom ratio values 1051 * 1052 * PARAMETERS : 1053 * @zoomRaios : array of zoom ratios 1054 * @length : size of the array 1055 * 1056 * RETURN : string obj 1057 *==========================================================================*/ 1058 String8 QCameraParameters::createZoomRatioValuesString(uint32_t *zoomRatios, 1059 size_t length) 1060 { 1061 String8 str; 1062 char buffer[32] = {0}; 1063 1064 if(length > 0){ 1065 snprintf(buffer, sizeof(buffer), "%d", zoomRatios[0]); 1066 str.append(buffer); 1067 } 1068 1069 for (size_t i = 1; i < length; i++) { 1070 memset(buffer, 0, sizeof(buffer)); 1071 snprintf(buffer, sizeof(buffer), ",%d", zoomRatios[i]); 1072 str.append(buffer); 1073 } 1074 return str; 1075 } 1076 1077 /*=========================================================================== 1078 * FUNCTION : createHfrValuesString 1079 * 1080 * DESCRIPTION: create string obj contains array of hfr values from map when 1081 * matched from input hfr values 1082 * 1083 * PARAMETERS : 1084 * @values : array of hfr info 1085 * @len : size of the array 1086 * @map : map of hfr string value and enum 1087 * map_len : size of map 1088 * 1089 * RETURN : string obj 1090 *==========================================================================*/ 1091 String8 QCameraParameters::createHfrValuesString(const cam_hfr_info_t *values, 1092 size_t len, const QCameraMap<cam_hfr_mode_t> *map, size_t map_len) 1093 { 1094 String8 str; 1095 int count = 0; 1096 1097 char value[PROPERTY_VALUE_MAX]; 1098 int8_t batch_count = 0; 1099 1100 property_get("persist.camera.batchcount", value, "0"); 1101 batch_count = atoi(value); 1102 1103 for (size_t i = 0; i < len; i++ ) { 1104 for (size_t j = 0; j < map_len; j ++) { 1105 if ((batch_count < CAMERA_MIN_BATCH_COUNT) 1106 && (map[j].val > CAM_HFR_MODE_120FPS)) { 1107 /*TODO: Work around. Need to revert when we have 1108 complete 240fps support*/ 1109 break; 1110 } 1111 if (map[j].val == (int)values[i].mode) { 1112 if (NULL != map[j].desc) { 1113 if (count > 0) { 1114 str.append(","); 1115 } 1116 str.append(map[j].desc); 1117 count++; 1118 break; //loop j 1119 } 1120 } 1121 } 1122 } 1123 if (count > 0) { 1124 str.append(","); 1125 } 1126 str.append(VIDEO_HFR_OFF); 1127 return str; 1128 } 1129 1130 /*=========================================================================== 1131 * FUNCTION : createHfrSizesString 1132 * 1133 * DESCRIPTION: create string obj contains array of hfr sizes 1134 * 1135 * PARAMETERS : 1136 * @values : array of hfr info 1137 * @len : size of the array 1138 * 1139 * RETURN : string obj 1140 *==========================================================================*/ 1141 String8 QCameraParameters::createHfrSizesString(const cam_hfr_info_t *values, size_t len) 1142 { 1143 String8 str; 1144 char buffer[32]; 1145 1146 if (len > 0) { 1147 snprintf(buffer, sizeof(buffer), "%dx%d", 1148 values[0].dim.width, values[0].dim.height); 1149 str.append(buffer); 1150 } 1151 for (size_t i = 1; i < len; i++) { 1152 snprintf(buffer, sizeof(buffer), ",%dx%d", 1153 values[i].dim.width, values[i].dim.height); 1154 str.append(buffer); 1155 } 1156 return str; 1157 } 1158 1159 /*=========================================================================== 1160 * FUNCTION : createFpsString 1161 * 1162 * DESCRIPTION: create string obj contains array of FPS rates 1163 * 1164 * PARAMETERS : 1165 * @fps : default fps range 1166 * 1167 * RETURN : string obj 1168 *==========================================================================*/ 1169 String8 QCameraParameters::createFpsString(cam_fps_range_t &fps) 1170 { 1171 char buffer[32]; 1172 String8 fpsValues; 1173 1174 int min_fps = int(fps.min_fps); 1175 int max_fps = int(fps.max_fps); 1176 1177 if (min_fps < fps.min_fps){ 1178 min_fps++; 1179 } 1180 if (max_fps > fps.max_fps) { 1181 max_fps--; 1182 } 1183 if (min_fps <= max_fps) { 1184 snprintf(buffer, sizeof(buffer), "%d", min_fps); 1185 fpsValues.append(buffer); 1186 } 1187 1188 for (int i = min_fps+1; i <= max_fps; i++) { 1189 snprintf(buffer, sizeof(buffer), ",%d", i); 1190 fpsValues.append(buffer); 1191 } 1192 1193 return fpsValues; 1194 } 1195 1196 /*=========================================================================== 1197 * FUNCTION : createFpsRangeString 1198 * 1199 * DESCRIPTION: create string obj contains array of FPS ranges 1200 * 1201 * PARAMETERS : 1202 * @fps : array of fps ranges 1203 * @len : size of the array 1204 * @default_fps_index : reference to index of default fps range 1205 * 1206 * RETURN : string obj 1207 *==========================================================================*/ 1208 String8 QCameraParameters::createFpsRangeString(const cam_fps_range_t* fps, 1209 size_t len, int &default_fps_index) 1210 { 1211 String8 str; 1212 char buffer[32]; 1213 int max_range = 0; 1214 int min_fps, max_fps; 1215 1216 if (len > 0) { 1217 min_fps = int(fps[0].min_fps * 1000); 1218 max_fps = int(fps[0].max_fps * 1000); 1219 max_range = max_fps - min_fps; 1220 default_fps_index = 0; 1221 snprintf(buffer, sizeof(buffer), "(%d,%d)", min_fps, max_fps); 1222 str.append(buffer); 1223 } 1224 for (size_t i = 1; i < len; i++) { 1225 min_fps = int(fps[i].min_fps * 1000); 1226 max_fps = int(fps[i].max_fps * 1000); 1227 if (max_range < (max_fps - min_fps)) { 1228 max_range = max_fps - min_fps; 1229 default_fps_index = (int)i; 1230 } 1231 snprintf(buffer, sizeof(buffer), ",(%d,%d)", min_fps, max_fps); 1232 str.append(buffer); 1233 } 1234 return str; 1235 } 1236 1237 /*=========================================================================== 1238 * FUNCTION : lookupAttr 1239 * 1240 * DESCRIPTION: lookup a value by its name 1241 * 1242 * PARAMETERS : 1243 * @attr : map contains <name, value> 1244 * @len : size of the map 1245 * @name : name to be looked up 1246 * 1247 * RETURN : valid value if found 1248 * NAME_NOT_FOUND if not found 1249 *==========================================================================*/ 1250 template <class mapType> int lookupAttr(const mapType *arr, 1251 size_t len, const char *name) 1252 { 1253 if (name) { 1254 for (size_t i = 0; i < len; i++) { 1255 if (!strcmp(arr[i].desc, name)) 1256 return arr[i].val; 1257 } 1258 } 1259 return NAME_NOT_FOUND; 1260 } 1261 1262 /*=========================================================================== 1263 * FUNCTION : lookupNameByValue 1264 * 1265 * DESCRIPTION: lookup a name by its value 1266 * 1267 * PARAMETERS : 1268 * @attr : map contains <name, value> 1269 * @len : size of the map 1270 * @value : value to be looked up 1271 * 1272 * RETURN : name str or NULL if not found 1273 *==========================================================================*/ 1274 template <class mapType> const char *lookupNameByValue(const mapType *arr, 1275 size_t len, int value) 1276 { 1277 for (size_t i = 0; i < len; i++) { 1278 if (arr[i].val == value) { 1279 return arr[i].desc; 1280 } 1281 } 1282 return NULL; 1283 } 1284 1285 /*=========================================================================== 1286 * FUNCTION : setPreviewSize 1287 * 1288 * DESCRIPTION: set preview size from user setting 1289 * 1290 * PARAMETERS : 1291 * @params : user setting parameters 1292 * 1293 * RETURN : int32_t type of status 1294 * NO_ERROR -- success 1295 * none-zero failure code 1296 *==========================================================================*/ 1297 int32_t QCameraParameters::setPreviewSize(const QCameraParameters& params) 1298 { 1299 int width, height; 1300 params.getPreviewSize(&width, &height); 1301 ALOGI("Requested preview size %d x %d", width, height); 1302 1303 // Validate the preview size 1304 for (size_t i = 0; i < m_pCapability->preview_sizes_tbl_cnt; ++i) { 1305 if (width == m_pCapability->preview_sizes_tbl[i].width 1306 && height == m_pCapability->preview_sizes_tbl[i].height) { 1307 // check if need to restart preview in case of preview size change 1308 int old_width, old_height; 1309 CameraParameters::getPreviewSize(&old_width, &old_height); 1310 if (width != old_width || height != old_height) { 1311 m_bNeedRestart = true; 1312 } 1313 1314 // set the new value 1315 CameraParameters::setPreviewSize(width, height); 1316 return NO_ERROR; 1317 } 1318 } 1319 ALOGE("Invalid preview size requested: %dx%d", width, height); 1320 return BAD_VALUE; 1321 } 1322 1323 /*=========================================================================== 1324 * FUNCTION : setPictureSize 1325 * 1326 * DESCRIPTION: set picture size from user setting 1327 * 1328 * PARAMETERS : 1329 * @params : user setting parameters 1330 * 1331 * RETURN : int32_t type of status 1332 * NO_ERROR -- success 1333 * none-zero failure code 1334 *==========================================================================*/ 1335 int32_t QCameraParameters::setPictureSize(const QCameraParameters& params) 1336 { 1337 int width, height; 1338 params.getPictureSize(&width, &height); 1339 ALOGI("Requested picture size %d x %d", width, height); 1340 1341 // Validate the picture size 1342 if(!m_reprocScaleParam.isScaleEnabled()){ 1343 for (size_t i = 0; i < m_pCapability->picture_sizes_tbl_cnt; ++i) { 1344 if (width == m_pCapability->picture_sizes_tbl[i].width 1345 && height == m_pCapability->picture_sizes_tbl[i].height) { 1346 // check if need to restart preview in case of picture size change 1347 int old_width, old_height; 1348 CameraParameters::getPictureSize(&old_width, &old_height); 1349 if ((m_bZslMode || m_bRecordingHint) && 1350 (width != old_width || height != old_height)) { 1351 m_bNeedRestart = true; 1352 } 1353 1354 // set the new value 1355 CameraParameters::setPictureSize(width, height); 1356 return NO_ERROR; 1357 } 1358 } 1359 }else{ 1360 //should use scaled picture size table to validate 1361 if(m_reprocScaleParam.setValidatePicSize(width, height) == NO_ERROR){ 1362 // check if need to restart preview in case of picture size change 1363 int old_width, old_height; 1364 CameraParameters::getPictureSize(&old_width, &old_height); 1365 if ((m_bZslMode || m_bRecordingHint) && 1366 (width != old_width || height != old_height)) { 1367 m_bNeedRestart = true; 1368 } 1369 1370 // set the new value 1371 char val[32]; 1372 snprintf(val, sizeof(val), "%dx%d", width, height); 1373 updateParamEntry(KEY_PICTURE_SIZE, val); 1374 CDBG("%s: %s", __func__, val); 1375 return NO_ERROR; 1376 } 1377 } 1378 ALOGE("Invalid picture size requested: %dx%d", width, height); 1379 return BAD_VALUE; 1380 } 1381 1382 /*=========================================================================== 1383 * FUNCTION : setVideoSize 1384 * 1385 * DESCRIPTION: set video size from user setting 1386 * 1387 * PARAMETERS : 1388 * @params : user setting parameters 1389 * 1390 * RETURN : int32_t type of status 1391 * NO_ERROR -- success 1392 * none-zero failure code 1393 *==========================================================================*/ 1394 int32_t QCameraParameters::setVideoSize(const QCameraParameters& params) 1395 { 1396 const char *str= NULL; 1397 int width, height; 1398 str = params.get(KEY_VIDEO_SIZE); 1399 if(!str) { 1400 //If application didn't set this parameter string, use the values from 1401 //getPreviewSize() as video dimensions. 1402 params.getPreviewSize(&width, &height); 1403 ALOGE("No Record Size requested, use the preview dimensions"); 1404 } else { 1405 params.getVideoSize(&width, &height); 1406 } 1407 1408 // Validate the video size 1409 for (size_t i = 0; i < m_pCapability->video_sizes_tbl_cnt; ++i) { 1410 if (width == m_pCapability->video_sizes_tbl[i].width 1411 && height == m_pCapability->video_sizes_tbl[i].height) { 1412 // check if need to restart preview in case of video size change 1413 int old_width, old_height; 1414 CameraParameters::getVideoSize(&old_width, &old_height); 1415 if (m_bRecordingHint && 1416 (width != old_width || height != old_height)) { 1417 m_bNeedRestart = true; 1418 } 1419 1420 // set the new value 1421 CameraParameters::setVideoSize(width, height); 1422 return NO_ERROR; 1423 } 1424 } 1425 1426 ALOGE("Invalid video size requested: %dx%d", width, height); 1427 return BAD_VALUE; 1428 } 1429 1430 /*=========================================================================== 1431 * FUNCTION : getLiveSnapshotSize 1432 * 1433 * DESCRIPTION: get live snapshot size 1434 * 1435 * PARAMETERS : dim - Update dim with the liveshot size 1436 * 1437 *==========================================================================*/ 1438 void QCameraParameters::getLiveSnapshotSize(cam_dimension_t &dim) 1439 { 1440 if(is4k2kVideoResolution()) { 1441 // We support maximum 8M liveshot @4K2K video resolution 1442 cam_dimension_t resolution = {0, 0}; 1443 CameraParameters::getVideoSize(&resolution.width, &resolution.height); 1444 if((m_LiveSnapshotSize.width > resolution.width) || 1445 (m_LiveSnapshotSize.height > resolution.height)) { 1446 m_LiveSnapshotSize.width = resolution.width; 1447 m_LiveSnapshotSize.height = resolution.height; 1448 } 1449 } 1450 dim = m_LiveSnapshotSize; 1451 CDBG_HIGH("%s: w x h: %d x %d", __func__, dim.width, dim.height); 1452 } 1453 1454 /*=========================================================================== 1455 * FUNCTION : setLiveSnapshotSize 1456 * 1457 * DESCRIPTION: set live snapshot size 1458 * 1459 * PARAMETERS : 1460 * @params : user setting parameters 1461 * 1462 * RETURN : int32_t type of status 1463 * NO_ERROR -- success 1464 * none-zero failure code 1465 *==========================================================================*/ 1466 int32_t QCameraParameters::setLiveSnapshotSize(const QCameraParameters& params) 1467 { 1468 char value[PROPERTY_VALUE_MAX]; 1469 property_get("persist.camera.opt.livepic", value, "1"); 1470 bool useOptimal = atoi(value) > 0 ? true : false; 1471 1472 // use picture size from user setting 1473 params.getPictureSize(&m_LiveSnapshotSize.width, &m_LiveSnapshotSize.height); 1474 1475 size_t livesnapshot_sizes_tbl_cnt = 1476 m_pCapability->livesnapshot_sizes_tbl_cnt; 1477 cam_dimension_t *livesnapshot_sizes_tbl = 1478 &m_pCapability->livesnapshot_sizes_tbl[0]; 1479 1480 if(is4k2kVideoResolution()) { 1481 // We support maximum 8M liveshot @4K2K video resolution 1482 cam_dimension_t resolution = {0, 0}; 1483 CameraParameters::getVideoSize(&resolution.width, &resolution.height); 1484 if((m_LiveSnapshotSize.width > resolution.width) || 1485 (m_LiveSnapshotSize.height > resolution.height)) { 1486 m_LiveSnapshotSize.width = resolution.width; 1487 m_LiveSnapshotSize.height = resolution.height; 1488 } 1489 } 1490 1491 // check if HFR is enabled 1492 const char *hfrStr = params.get(KEY_QC_VIDEO_HIGH_FRAME_RATE); 1493 cam_hfr_mode_t hfrMode = CAM_HFR_MODE_OFF; 1494 const char *hsrStr = params.get(KEY_QC_VIDEO_HIGH_SPEED_RECORDING); 1495 1496 if ((hsrStr != NULL) && strcmp(hsrStr, "off")) { 1497 int32_t hsr = lookupAttr(HFR_MODES_MAP, PARAM_MAP_SIZE(HFR_MODES_MAP), hsrStr); 1498 if ((hsr != NAME_NOT_FOUND) && (hsr > CAM_HFR_MODE_OFF)) { 1499 // if HSR is enabled, change live snapshot size 1500 for (size_t i = 0; i < m_pCapability->hfr_tbl_cnt; i++) { 1501 if (m_pCapability->hfr_tbl[i].mode == hsr) { 1502 livesnapshot_sizes_tbl_cnt = 1503 m_pCapability->hfr_tbl[i].livesnapshot_sizes_tbl_cnt; 1504 livesnapshot_sizes_tbl = 1505 &m_pCapability->hfr_tbl[i].livesnapshot_sizes_tbl[0]; 1506 hfrMode = m_pCapability->hfr_tbl[i].mode; 1507 break; 1508 } 1509 } 1510 } 1511 } else if ((hfrStr != NULL) && strcmp(hfrStr, "off")) { 1512 int32_t hfr = lookupAttr(HFR_MODES_MAP, PARAM_MAP_SIZE(HFR_MODES_MAP), hfrStr); 1513 if ((hfr != NAME_NOT_FOUND) && (hfr > CAM_HFR_MODE_OFF)) { 1514 // if HFR is enabled, change live snapshot size 1515 for (size_t i = 0; i < m_pCapability->hfr_tbl_cnt; i++) { 1516 if (m_pCapability->hfr_tbl[i].mode == hfr) { 1517 livesnapshot_sizes_tbl_cnt = 1518 m_pCapability->hfr_tbl[i].livesnapshot_sizes_tbl_cnt; 1519 livesnapshot_sizes_tbl = 1520 &m_pCapability->hfr_tbl[i].livesnapshot_sizes_tbl[0]; 1521 hfrMode = m_pCapability->hfr_tbl[i].mode; 1522 break; 1523 } 1524 } 1525 } 1526 } 1527 1528 if (useOptimal || hfrMode != CAM_HFR_MODE_OFF) { 1529 bool found = false; 1530 1531 // first check if picture size is within the list of supported sizes 1532 for (size_t i = 0; i < livesnapshot_sizes_tbl_cnt; ++i) { 1533 if (m_LiveSnapshotSize.width == livesnapshot_sizes_tbl[i].width && 1534 m_LiveSnapshotSize.height == livesnapshot_sizes_tbl[i].height) { 1535 found = true; 1536 break; 1537 } 1538 } 1539 1540 if (!found) { 1541 // use optimal live snapshot size from supported list, 1542 // that has same preview aspect ratio 1543 int width = 0, height = 0; 1544 params.getPreviewSize(&width, &height); 1545 1546 double previewAspectRatio = (double)width / height; 1547 for (size_t i = 0; i < livesnapshot_sizes_tbl_cnt; ++i) { 1548 double ratio = (double)livesnapshot_sizes_tbl[i].width / 1549 livesnapshot_sizes_tbl[i].height; 1550 if (fabs(previewAspectRatio - ratio) <= ASPECT_TOLERANCE) { 1551 m_LiveSnapshotSize = livesnapshot_sizes_tbl[i]; 1552 found = true; 1553 break; 1554 } 1555 } 1556 1557 if (!found && hfrMode != CAM_HFR_MODE_OFF) { 1558 // Cannot find matching aspect ration from supported live snapshot list 1559 // choose the max dim from preview and video size 1560 CDBG("%s: Cannot find matching aspect ratio, choose max of preview or video size", __func__); 1561 params.getVideoSize(&m_LiveSnapshotSize.width, &m_LiveSnapshotSize.height); 1562 if (m_LiveSnapshotSize.width < width && m_LiveSnapshotSize.height < height) { 1563 m_LiveSnapshotSize.width = width; 1564 m_LiveSnapshotSize.height = height; 1565 } 1566 } 1567 } 1568 } 1569 CDBG_HIGH("%s: live snapshot size %d x %d", __func__, 1570 m_LiveSnapshotSize.width, m_LiveSnapshotSize.height); 1571 1572 return NO_ERROR; 1573 } 1574 1575 1576 /*=========================================================================== 1577 * FUNCTION : setRawSize 1578 * 1579 * DESCRIPTION: set live snapshot size 1580 * 1581 * PARAMETERS : 1582 * @params : user setting parameters 1583 * 1584 * RETURN : int32_t type of status 1585 * NO_ERROR -- success 1586 * none-zero failure code 1587 *==========================================================================*/ 1588 int32_t QCameraParameters::setRawSize(cam_dimension_t &dim) 1589 { 1590 m_rawSize = dim; 1591 return NO_ERROR; 1592 } 1593 /*=========================================================================== 1594 * FUNCTION : setPreviewFormat 1595 * 1596 * DESCRIPTION: set preview format from user setting 1597 * 1598 * PARAMETERS : 1599 * @params : user setting parameters 1600 * 1601 * RETURN : int32_t type of status 1602 * NO_ERROR -- success 1603 * none-zero failure code 1604 *==========================================================================*/ 1605 int32_t QCameraParameters::setPreviewFormat(const QCameraParameters& params) 1606 { 1607 const char *str = params.getPreviewFormat(); 1608 int32_t previewFormat = lookupAttr(PREVIEW_FORMATS_MAP, 1609 PARAM_MAP_SIZE(PREVIEW_FORMATS_MAP), str); 1610 if (previewFormat != NAME_NOT_FOUND) { 1611 mPreviewFormat = (cam_format_t)previewFormat; 1612 1613 CameraParameters::setPreviewFormat(str); 1614 CDBG_HIGH("%s: format %d\n", __func__, mPreviewFormat); 1615 return NO_ERROR; 1616 } 1617 ALOGE("Invalid preview format value: %s", (str == NULL) ? "NULL" : str); 1618 return BAD_VALUE; 1619 } 1620 1621 /*=========================================================================== 1622 * FUNCTION : setPictureFormat 1623 * 1624 * DESCRIPTION: set picture format from user setting 1625 * 1626 * PARAMETERS : 1627 * @params : user setting parameters 1628 * 1629 * RETURN : int32_t type of status 1630 * NO_ERROR -- success 1631 * none-zero failure code 1632 *==========================================================================*/ 1633 int32_t QCameraParameters::setPictureFormat(const QCameraParameters& params) 1634 { 1635 const char *str = params.getPictureFormat(); 1636 int32_t pictureFormat = lookupAttr(PICTURE_TYPES_MAP, PARAM_MAP_SIZE(PICTURE_TYPES_MAP), str); 1637 if (pictureFormat != NAME_NOT_FOUND) { 1638 mPictureFormat = pictureFormat; 1639 1640 CameraParameters::setPictureFormat(str); 1641 CDBG_HIGH("%s: format %d\n", __func__, mPictureFormat); 1642 return NO_ERROR; 1643 } 1644 ALOGE("%s: Invalid picture format value: %s", __func__, (str == NULL) ? "NULL" : str); 1645 return BAD_VALUE; 1646 } 1647 1648 /*=========================================================================== 1649 * FUNCTION : setJpegThumbnailSize 1650 * 1651 * DESCRIPTION: set jpeg thumbnail size 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 *==========================================================================*/ 1660 int32_t QCameraParameters::setJpegThumbnailSize(const QCameraParameters& params) 1661 { 1662 int width = params.getInt(KEY_JPEG_THUMBNAIL_WIDTH); 1663 int height = params.getInt(KEY_JPEG_THUMBNAIL_HEIGHT); 1664 1665 CDBG("requested jpeg thumbnail size %d x %d", width, height); 1666 1667 size_t sizes_cnt = PARAM_MAP_SIZE(THUMBNAIL_SIZES_MAP); 1668 1669 cam_dimension_t dim; 1670 1671 // While taking livesnaphot match jpeg thumbnail size aspect 1672 // ratio to liveshot size. For normal snapshot match thumbnail 1673 // aspect ratio to picture size. 1674 if (m_bRecordingHint) { 1675 getLiveSnapshotSize(dim); 1676 } else { 1677 params.getPictureSize(&dim.width, &dim.height); 1678 } 1679 1680 if (0 == dim.height) { 1681 ALOGE("%s: picture size is invalid (%d x %d)", __func__, dim.width, dim.height); 1682 return BAD_VALUE; 1683 } 1684 double picAspectRatio = (double)dim.width / (double)dim.height; 1685 1686 int optimalWidth = 0, optimalHeight = 0; 1687 if (width != 0 || height != 0) { 1688 // If input jpeg thumnmail size is (0,0), meaning no thumbnail needed 1689 // hornor this setting. 1690 // Otherwise, search for optimal jpeg thumbnail size that has the same 1691 // aspect ratio as picture size. 1692 // If missign jpeg thumbnail size with appropriate aspect ratio, 1693 // just honor setting supplied by application. 1694 1695 // Try to find a size matches aspect ratio and has the largest width 1696 for (size_t i = 0; i < sizes_cnt; i++) { 1697 if (THUMBNAIL_SIZES_MAP[i].height == 0) { 1698 // No thumbnail case, just skip 1699 continue; 1700 } 1701 double ratio = 1702 (double)THUMBNAIL_SIZES_MAP[i].width / THUMBNAIL_SIZES_MAP[i].height; 1703 if (fabs(ratio - picAspectRatio) > ASPECT_TOLERANCE) { 1704 continue; 1705 } 1706 if (THUMBNAIL_SIZES_MAP[i].width > optimalWidth) { 1707 optimalWidth = THUMBNAIL_SIZES_MAP[i].width; 1708 optimalHeight = THUMBNAIL_SIZES_MAP[i].height; 1709 } 1710 } 1711 1712 if ((0 == optimalWidth) || (0 == optimalHeight)) { 1713 // Optimal size not found 1714 // Validate thumbnail size 1715 for (size_t i = 0; i < sizes_cnt; i++) { 1716 if (width == THUMBNAIL_SIZES_MAP[i].width && 1717 height == THUMBNAIL_SIZES_MAP[i].height) { 1718 optimalWidth = width; 1719 optimalHeight = height; 1720 break; 1721 } 1722 } 1723 } 1724 } 1725 1726 set(KEY_JPEG_THUMBNAIL_WIDTH, optimalWidth); 1727 set(KEY_JPEG_THUMBNAIL_HEIGHT, optimalHeight); 1728 return NO_ERROR; 1729 } 1730 1731 /*=========================================================================== 1732 1733 * FUNCTION : setBurstLEDOnPeriod 1734 * 1735 * DESCRIPTION: set burst LED on period 1736 * 1737 * PARAMETERS : 1738 * @params : user setting parameters 1739 * 1740 * RETURN : int32_t type of status 1741 * NO_ERROR -- success 1742 * none-zero failure code 1743 *==========================================================================*/ 1744 int32_t QCameraParameters::setBurstLEDOnPeriod(const QCameraParameters& params) 1745 { 1746 int nBurstLEDOnPeriod = params.getInt(KEY_QC_SNAPSHOT_BURST_LED_ON_PERIOD); 1747 //Check if the LED ON period is within limits 1748 if ((nBurstLEDOnPeriod <= 0) || (nBurstLEDOnPeriod > 800)) { 1749 // if burst led on period is not set in parameters, 1750 // read from sys prop 1751 char prop[PROPERTY_VALUE_MAX]; 1752 memset(prop, 0, sizeof(prop)); 1753 property_get("persist.camera.led.on.period", prop, "0"); 1754 nBurstLEDOnPeriod = atoi(prop); 1755 if (nBurstLEDOnPeriod <= 0) { 1756 nBurstLEDOnPeriod = 300; 1757 } 1758 } 1759 1760 set(KEY_QC_SNAPSHOT_BURST_LED_ON_PERIOD, nBurstLEDOnPeriod); 1761 m_nBurstLEDOnPeriod = nBurstLEDOnPeriod; 1762 CDBG_HIGH("%s: Burst LED on period %u", __func__, m_nBurstLEDOnPeriod); 1763 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_BURST_LED_ON_PERIOD, 1764 (uint32_t)nBurstLEDOnPeriod)) { 1765 return BAD_VALUE; 1766 } 1767 1768 return NO_ERROR; 1769 } 1770 1771 1772 1773 /*=========================================================================== 1774 * FUNCTION : setRetroActiveBurstNum 1775 * 1776 * DESCRIPTION: set retro active burst num 1777 * 1778 * PARAMETERS : 1779 * @params : user setting parameters 1780 * 1781 * RETURN : int32_t type of status 1782 * NO_ERROR -- success 1783 * none-zero failure code 1784 *==========================================================================*/ 1785 int32_t QCameraParameters::setRetroActiveBurstNum( 1786 const QCameraParameters& params) 1787 { 1788 int32_t nBurstNum = params.getInt(KEY_QC_NUM_RETRO_BURST_PER_SHUTTER); 1789 CDBG_HIGH("%s:[ZSL Retro] m_nRetroBurstNum = %d", __func__, m_nRetroBurstNum); 1790 if (nBurstNum <= 0) { 1791 // if burst number is not set in parameters, 1792 // read from sys prop 1793 char prop[PROPERTY_VALUE_MAX]; 1794 memset(prop, 0, sizeof(prop)); 1795 property_get("persist.camera.retro.number", prop, "0"); 1796 nBurstNum = atoi(prop); 1797 if (nBurstNum < 0) { 1798 nBurstNum = 0; 1799 } 1800 } 1801 1802 set(KEY_QC_NUM_RETRO_BURST_PER_SHUTTER, nBurstNum); 1803 1804 m_nRetroBurstNum = nBurstNum; 1805 CDBG_HIGH("%s: [ZSL Retro] m_nRetroBurstNum = %d", __func__, m_nRetroBurstNum); 1806 return NO_ERROR; 1807 } 1808 1809 /*=========================================================================== 1810 * FUNCTION : setJpegQuality 1811 * 1812 * DESCRIPTION: set jpeg encpding quality from user setting 1813 * 1814 * PARAMETERS : 1815 * @params : user setting parameters 1816 * 1817 * RETURN : int32_t type of status 1818 * NO_ERROR -- success 1819 * none-zero failure code 1820 *==========================================================================*/ 1821 int32_t QCameraParameters::setJpegQuality(const QCameraParameters& params) 1822 { 1823 int32_t rc = NO_ERROR; 1824 int quality = params.getInt(KEY_JPEG_QUALITY); 1825 if (quality >= 0 && quality <= 100) { 1826 set(KEY_JPEG_QUALITY, quality); 1827 } else { 1828 ALOGE("%s: Invalid jpeg quality=%d", __func__, quality); 1829 rc = BAD_VALUE; 1830 } 1831 1832 quality = params.getInt(KEY_JPEG_THUMBNAIL_QUALITY); 1833 if (quality >= 0 && quality <= 100) { 1834 set(KEY_JPEG_THUMBNAIL_QUALITY, quality); 1835 } else { 1836 ALOGE("%s: Invalid jpeg thumbnail quality=%d", __func__, quality); 1837 rc = BAD_VALUE; 1838 } 1839 return rc; 1840 } 1841 1842 /*=========================================================================== 1843 * FUNCTION : setOrientaion 1844 * 1845 * DESCRIPTION: set orientaion from user setting 1846 * 1847 * PARAMETERS : 1848 * @params : user setting parameters 1849 * 1850 * RETURN : int32_t type of status 1851 * NO_ERROR -- success 1852 * none-zero failure code 1853 *==========================================================================*/ 1854 int32_t QCameraParameters::setOrientation(const QCameraParameters& params) 1855 { 1856 const char *str = params.get(KEY_QC_ORIENTATION); 1857 1858 if (str != NULL) { 1859 if (strcmp(str, portrait) == 0 || strcmp(str, landscape) == 0) { 1860 // Camera service needs this to decide if the preview frames and raw 1861 // pictures should be rotated. 1862 set(KEY_QC_ORIENTATION, str); 1863 } else { 1864 ALOGE("%s: Invalid orientation value: %s", __func__, str); 1865 return BAD_VALUE; 1866 } 1867 } 1868 return NO_ERROR; 1869 } 1870 1871 /*=========================================================================== 1872 * FUNCTION : setAutoExposure 1873 * 1874 * DESCRIPTION: set auto exposure value from user setting 1875 * 1876 * PARAMETERS : 1877 * @params : user setting parameters 1878 * 1879 * RETURN : int32_t type of status 1880 * NO_ERROR -- success 1881 * none-zero failure code 1882 *==========================================================================*/ 1883 int32_t QCameraParameters::setAutoExposure(const QCameraParameters& params) 1884 { 1885 const char *str = params.get(KEY_QC_AUTO_EXPOSURE); 1886 const char *prev_str = get(KEY_QC_AUTO_EXPOSURE); 1887 if (str != NULL) { 1888 if (prev_str == NULL || 1889 strcmp(str, prev_str) != 0) { 1890 return setAutoExposure(str); 1891 } 1892 } 1893 return NO_ERROR; 1894 } 1895 1896 /*=========================================================================== 1897 * FUNCTION : setPreviewFpsRange 1898 * 1899 * DESCRIPTION: set preview FPS range from user setting 1900 * 1901 * PARAMETERS : 1902 * @params : user setting parameters 1903 * 1904 * RETURN : int32_t type of status 1905 * NO_ERROR -- success 1906 * none-zero failure code 1907 *==========================================================================*/ 1908 int32_t QCameraParameters::setPreviewFpsRange(const QCameraParameters& params) 1909 { 1910 int minFps,maxFps; 1911 int prevMinFps, prevMaxFps, vidMinFps, vidMaxFps; 1912 int rc = NO_ERROR; 1913 bool found = false, updateNeeded = false; 1914 1915 CameraParameters::getPreviewFpsRange(&prevMinFps, &prevMaxFps); 1916 params.getPreviewFpsRange(&minFps, &maxFps); 1917 1918 CDBG_HIGH("%s: FpsRange Values:(%d, %d)", __func__, prevMinFps, prevMaxFps); 1919 CDBG_HIGH("%s: Requested FpsRange Values:(%d, %d)", __func__, minFps, maxFps); 1920 1921 //first check if we need to change fps because of HFR mode change 1922 updateNeeded = UpdateHFRFrameRate(params); 1923 if (updateNeeded) { 1924 m_bNeedRestart = true; 1925 rc = setHighFrameRate(mHfrMode); 1926 if (rc != NO_ERROR) goto end; 1927 } 1928 CDBG_HIGH("%s: UpdateHFRFrameRate %d", __func__, updateNeeded); 1929 1930 vidMinFps = (int)m_hfrFpsRange.video_min_fps; 1931 vidMaxFps = (int)m_hfrFpsRange.video_max_fps; 1932 1933 if(minFps == prevMinFps && maxFps == prevMaxFps) { 1934 if ( m_bFixedFrameRateSet ) { 1935 minFps = params.getPreviewFrameRate() * 1000; 1936 maxFps = params.getPreviewFrameRate() * 1000; 1937 m_bFixedFrameRateSet = false; 1938 } else if (!updateNeeded) { 1939 CDBG_HIGH("%s: No change in FpsRange", __func__); 1940 rc = NO_ERROR; 1941 goto end; 1942 } 1943 } 1944 for(size_t i = 0; i < m_pCapability->fps_ranges_tbl_cnt; i++) { 1945 // if the value is in the supported list 1946 if (minFps >= m_pCapability->fps_ranges_tbl[i].min_fps * 1000 && 1947 maxFps <= m_pCapability->fps_ranges_tbl[i].max_fps * 1000) { 1948 found = true; 1949 CDBG_HIGH("%s: FPS i=%d : minFps = %d, maxFps = %d" 1950 " vidMinFps = %d, vidMaxFps = %d", 1951 __func__, i, minFps, maxFps, 1952 (int)m_hfrFpsRange.video_min_fps, 1953 (int)m_hfrFpsRange.video_max_fps); 1954 if ((0.0f >= m_hfrFpsRange.video_min_fps) || 1955 (0.0f >= m_hfrFpsRange.video_max_fps)) { 1956 vidMinFps = minFps; 1957 vidMaxFps = maxFps; 1958 } 1959 else { 1960 vidMinFps = (int)m_hfrFpsRange.video_min_fps; 1961 vidMaxFps = (int)m_hfrFpsRange.video_max_fps; 1962 } 1963 1964 setPreviewFpsRange(minFps, maxFps, vidMinFps, vidMaxFps); 1965 break; 1966 } 1967 } 1968 if(found == false){ 1969 ALOGE("%s: error: FPS range value not supported", __func__); 1970 rc = BAD_VALUE; 1971 } 1972 end: 1973 return rc; 1974 } 1975 1976 /*=========================================================================== 1977 * FUNCTION : UpdateHFRFrameRate 1978 * 1979 * DESCRIPTION: set preview FPS range based on HFR setting 1980 * 1981 * PARAMETERS : 1982 * @params : user setting parameters 1983 * 1984 * RETURN : bool true/false 1985 * true -if HAL needs to overwrite FPS range set by app, false otherwise. 1986 *==========================================================================*/ 1987 1988 bool QCameraParameters::UpdateHFRFrameRate(const QCameraParameters& params) 1989 { 1990 bool updateNeeded = false; 1991 int min_fps, max_fps; 1992 int32_t hfrMode = CAM_HFR_MODE_OFF; 1993 int32_t newHfrMode = CAM_HFR_MODE_OFF; 1994 1995 int parm_minfps,parm_maxfps; 1996 int prevMinFps, prevMaxFps; 1997 CameraParameters::getPreviewFpsRange(&prevMinFps, &prevMaxFps); 1998 params.getPreviewFpsRange(&parm_minfps, &parm_maxfps); 1999 CDBG_HIGH("%s: CameraParameters - : minFps = %d, maxFps = %d ", 2000 __func__, prevMinFps, prevMaxFps); 2001 CDBG_HIGH("%s: Requested params - : minFps = %d, maxFps = %d ", 2002 __func__, parm_minfps, parm_maxfps); 2003 2004 const char *hfrStr = params.get(KEY_QC_VIDEO_HIGH_FRAME_RATE); 2005 const char *hsrStr = params.get(KEY_QC_VIDEO_HIGH_SPEED_RECORDING); 2006 2007 const char *prev_hfrStr = CameraParameters::get(KEY_QC_VIDEO_HIGH_FRAME_RATE); 2008 const char *prev_hsrStr = CameraParameters::get(KEY_QC_VIDEO_HIGH_SPEED_RECORDING); 2009 2010 if ((hfrStr != NULL) && (prev_hfrStr != NULL) && strcmp(hfrStr, prev_hfrStr)) { 2011 updateParamEntry(KEY_QC_VIDEO_HIGH_FRAME_RATE, hfrStr); 2012 } 2013 2014 if ((hsrStr != NULL) && (prev_hsrStr != NULL) && strcmp(hsrStr, prev_hsrStr)) { 2015 updateParamEntry(KEY_QC_VIDEO_HIGH_SPEED_RECORDING, hsrStr); 2016 2017 } 2018 2019 // check if HFR is enabled 2020 if ((hfrStr != NULL) && strcmp(hfrStr, "off")) { 2021 hfrMode = lookupAttr(HFR_MODES_MAP, PARAM_MAP_SIZE(HFR_MODES_MAP), hfrStr); 2022 if (NAME_NOT_FOUND != hfrMode) newHfrMode = hfrMode; 2023 } 2024 // check if HSR is enabled 2025 else if ((hsrStr != NULL) && strcmp(hsrStr, "off")) { 2026 hfrMode = lookupAttr(HFR_MODES_MAP, PARAM_MAP_SIZE(HFR_MODES_MAP), hsrStr); 2027 if (NAME_NOT_FOUND != hfrMode) newHfrMode = hfrMode; 2028 } 2029 CDBG_HIGH("%s: prevHfrMode - %d, currentHfrMode = %d ", 2030 __func__, mHfrMode, newHfrMode); 2031 2032 if (mHfrMode != newHfrMode) { 2033 updateNeeded = true; 2034 mHfrMode = newHfrMode; 2035 switch (mHfrMode) { 2036 case CAM_HFR_MODE_60FPS: 2037 min_fps = 60000; 2038 max_fps = 60000; 2039 break; 2040 case CAM_HFR_MODE_90FPS: 2041 min_fps = 90000; 2042 max_fps = 90000; 2043 break; 2044 case CAM_HFR_MODE_120FPS: 2045 min_fps = 120000; 2046 max_fps = 120000; 2047 break; 2048 case CAM_HFR_MODE_150FPS: 2049 min_fps = 150000; 2050 max_fps = 150000; 2051 break; 2052 case CAM_HFR_MODE_180FPS: 2053 min_fps = 180000; 2054 max_fps = 180000; 2055 break; 2056 case CAM_HFR_MODE_210FPS: 2057 min_fps = 210000; 2058 max_fps = 210000; 2059 break; 2060 case CAM_HFR_MODE_240FPS: 2061 min_fps = 240000; 2062 max_fps = 240000; 2063 break; 2064 case CAM_HFR_MODE_480FPS: 2065 min_fps = 480000; 2066 max_fps = 480000; 2067 break; 2068 case CAM_HFR_MODE_OFF: 2069 default: 2070 // Set Video Fps to zero 2071 min_fps = 0; 2072 max_fps = 0; 2073 break; 2074 } 2075 m_hfrFpsRange.video_min_fps = (float)min_fps; 2076 m_hfrFpsRange.video_max_fps = (float)max_fps; 2077 2078 CDBG_HIGH("%s: HFR mode (%d) Set video FPS : minFps = %d, maxFps = %d ", 2079 __func__, mHfrMode, min_fps, max_fps); 2080 } 2081 2082 m_hfrFpsRange.min_fps = (float)parm_minfps; 2083 m_hfrFpsRange.max_fps = (float)parm_maxfps; 2084 2085 // Remember if HFR mode is ON 2086 if ((mHfrMode > CAM_HFR_MODE_OFF) && (mHfrMode < CAM_HFR_MODE_MAX)) { 2087 CDBG_HIGH("HFR mode is ON"); 2088 m_bHfrMode = true; 2089 } else { 2090 m_hfrFpsRange.video_min_fps = 0; 2091 m_hfrFpsRange.video_max_fps = 0; 2092 m_bHfrMode = false; 2093 CDBG_HIGH("HFR mode is OFF"); 2094 } 2095 2096 if (m_bHfrMode && (mHfrMode > CAM_HFR_MODE_120FPS) 2097 && (parm_maxfps != 0)) { 2098 /* Setting Buffer batch count to use batch mode for higher fps*/ 2099 setBufBatchCount((int8_t)(m_hfrFpsRange.video_max_fps / parm_maxfps)); 2100 } 2101 2102 return updateNeeded; 2103 } 2104 2105 /*=========================================================================== 2106 * FUNCTION : setPreviewFrameRate 2107 * 2108 * DESCRIPTION: set preview frame rate from user setting 2109 * 2110 * PARAMETERS : 2111 * @params : user setting parameters 2112 * 2113 * RETURN : int32_t type of status 2114 * NO_ERROR -- success 2115 * none-zero failure code 2116 *==========================================================================*/ 2117 int32_t QCameraParameters::setPreviewFrameRate(const QCameraParameters& params) 2118 { 2119 const char *str = params.get(KEY_PREVIEW_FRAME_RATE); 2120 const char *prev_str = get(KEY_PREVIEW_FRAME_RATE); 2121 2122 if ( str ) { 2123 if ( prev_str && 2124 strcmp(str, prev_str)) { 2125 CDBG("%s: Requested Fixed Frame Rate %s", __func__, str); 2126 updateParamEntry(KEY_PREVIEW_FRAME_RATE, str); 2127 m_bFixedFrameRateSet = true; 2128 } 2129 } 2130 return NO_ERROR; 2131 } 2132 2133 /*=========================================================================== 2134 * FUNCTION : setEffect 2135 * 2136 * DESCRIPTION: set effect value from user setting 2137 * 2138 * PARAMETERS : 2139 * @params : user setting parameters 2140 * 2141 * RETURN : int32_t type of status 2142 * NO_ERROR -- success 2143 * none-zero failure code 2144 *==========================================================================*/ 2145 int32_t QCameraParameters::setEffect(const QCameraParameters& params) 2146 { 2147 const char *str = params.get(KEY_EFFECT); 2148 const char *prev_str = get(KEY_EFFECT); 2149 if (str != NULL) { 2150 if (prev_str == NULL || 2151 strcmp(str, prev_str) != 0 || 2152 m_bUpdateEffects == true ) { 2153 m_bUpdateEffects = false; 2154 return setEffect(str); 2155 } 2156 } 2157 return NO_ERROR; 2158 } 2159 2160 /*=========================================================================== 2161 * FUNCTION : setFocusMode 2162 * 2163 * DESCRIPTION: set focus mode from user setting 2164 * 2165 * PARAMETERS : 2166 * @params : user setting parameters 2167 * 2168 * RETURN : int32_t type of status 2169 * NO_ERROR -- success 2170 * none-zero failure code 2171 *==========================================================================*/ 2172 int32_t QCameraParameters::setFocusMode(const QCameraParameters& params) 2173 { 2174 const char *str = params.get(KEY_FOCUS_MODE); 2175 const char *prev_str = get(KEY_FOCUS_MODE); 2176 if (str != NULL) { 2177 if (prev_str == NULL || 2178 strcmp(str, prev_str) != 0) { 2179 return setFocusMode(str); 2180 } 2181 } 2182 return NO_ERROR; 2183 } 2184 2185 /*=========================================================================== 2186 * FUNCTION : setFocusPosition 2187 * 2188 * DESCRIPTION: set focus position from user setting 2189 * 2190 * PARAMETERS : 2191 * @params : user setting parameters 2192 * 2193 * RETURN : int32_t type of status 2194 * NO_ERROR -- success 2195 * none-zero failure code 2196 *==========================================================================*/ 2197 int32_t QCameraParameters::setFocusPosition(const QCameraParameters& params) 2198 { 2199 const char *focus_str = params.get(KEY_FOCUS_MODE); 2200 2201 if (NULL == focus_str) { 2202 return NO_ERROR; 2203 } 2204 2205 CDBG("%s, current focus mode: %s", __func__, focus_str); 2206 if (strcmp(focus_str, FOCUS_MODE_MANUAL_POSITION)) { 2207 CDBG_HIGH("%s, dont set focus pos to back-end!", __func__); 2208 return NO_ERROR; 2209 } 2210 2211 const char *pos = params.get(KEY_QC_MANUAL_FOCUS_POSITION); 2212 const char *prev_pos = get(KEY_QC_MANUAL_FOCUS_POSITION); 2213 const char *type = params.get(KEY_QC_MANUAL_FOCUS_POS_TYPE); 2214 const char *prev_type = get(KEY_QC_MANUAL_FOCUS_POS_TYPE); 2215 2216 if ((pos != NULL) && (type != NULL)) { 2217 if (prev_pos == NULL || (strcmp(pos, prev_pos) != 0) || 2218 prev_type == NULL || (strcmp(type, prev_type) != 0)) { 2219 return setFocusPosition(type, pos); 2220 } 2221 } 2222 2223 return NO_ERROR; 2224 } 2225 2226 /*=========================================================================== 2227 * FUNCTION : setBrightness 2228 * 2229 * DESCRIPTION: set brightness control value from user setting 2230 * 2231 * PARAMETERS : 2232 * @params : user setting parameters 2233 * 2234 * RETURN : int32_t type of status 2235 * NO_ERROR -- success 2236 * none-zero failure code 2237 *==========================================================================*/ 2238 int32_t QCameraParameters::setBrightness(const QCameraParameters& params) 2239 { 2240 int currentBrightness = getInt(KEY_QC_BRIGHTNESS); 2241 int brightness = params.getInt(KEY_QC_BRIGHTNESS); 2242 2243 if(params.get(KEY_QC_BRIGHTNESS) == NULL) { 2244 CDBG_HIGH("%s: Brigtness not set by App ",__func__); 2245 return NO_ERROR; 2246 } 2247 if (currentBrightness != brightness) { 2248 if (brightness >= m_pCapability->brightness_ctrl.min_value && 2249 brightness <= m_pCapability->brightness_ctrl.max_value) { 2250 CDBG(" new brightness value : %d ", brightness); 2251 return setBrightness(brightness); 2252 } else { 2253 ALOGE("%s: invalid value %d out of (%d, %d)", 2254 __func__, brightness, 2255 m_pCapability->brightness_ctrl.min_value, 2256 m_pCapability->brightness_ctrl.max_value); 2257 return BAD_VALUE; 2258 } 2259 } else { 2260 CDBG("%s: No brightness value changed.", __func__); 2261 return NO_ERROR; 2262 } 2263 } 2264 2265 /*=========================================================================== 2266 * FUNCTION : getBrightness 2267 * 2268 * DESCRIPTION: get brightness control value from user setting 2269 * 2270 * PARAMETERS : 2271 * @params : user setting parameters 2272 * 2273 * RETURN : int32_t type of status 2274 * NO_ERROR -- success 2275 * none-zero failure code 2276 *==========================================================================*/ 2277 int QCameraParameters::getBrightness() 2278 { 2279 return getInt(KEY_QC_BRIGHTNESS); 2280 } 2281 2282 /*=========================================================================== 2283 * FUNCTION : setSharpness 2284 * 2285 * DESCRIPTION: set sharpness control 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 *==========================================================================*/ 2294 int32_t QCameraParameters::setSharpness(const QCameraParameters& params) 2295 { 2296 int shaprness = params.getInt(KEY_QC_SHARPNESS); 2297 int prev_sharp = getInt(KEY_QC_SHARPNESS); 2298 2299 if(params.get(KEY_QC_SHARPNESS) == NULL) { 2300 CDBG_HIGH("%s: Sharpness not set by App ",__func__); 2301 return NO_ERROR; 2302 } 2303 if (prev_sharp != shaprness) { 2304 if((shaprness >= m_pCapability->sharpness_ctrl.min_value) && 2305 (shaprness <= m_pCapability->sharpness_ctrl.max_value)) { 2306 CDBG(" new sharpness value : %d ", shaprness); 2307 return setSharpness(shaprness); 2308 } else { 2309 ALOGE("%s: invalid value %d out of (%d, %d)", 2310 __func__, shaprness, 2311 m_pCapability->sharpness_ctrl.min_value, 2312 m_pCapability->sharpness_ctrl.max_value); 2313 return BAD_VALUE; 2314 } 2315 } else { 2316 CDBG("%s: No value change in shaprness", __func__); 2317 return NO_ERROR; 2318 } 2319 } 2320 2321 /*=========================================================================== 2322 * FUNCTION : setSkintoneEnahancement 2323 * 2324 * DESCRIPTION: set skin tone enhancement factor from user setting 2325 * 2326 * PARAMETERS : 2327 * @params : user setting parameters 2328 * 2329 * RETURN : int32_t type of status 2330 * NO_ERROR -- success 2331 * none-zero failure code 2332 *==========================================================================*/ 2333 int32_t QCameraParameters::setSkinToneEnhancement(const QCameraParameters& params) 2334 { 2335 int sceFactor = params.getInt(KEY_QC_SCE_FACTOR); 2336 int prev_sceFactor = getInt(KEY_QC_SCE_FACTOR); 2337 2338 if(params.get(KEY_QC_SCE_FACTOR) == NULL) { 2339 CDBG_HIGH("%s: Skintone enhancement not set by App ",__func__); 2340 return NO_ERROR; 2341 } 2342 if (prev_sceFactor != sceFactor) { 2343 if((sceFactor >= m_pCapability->sce_ctrl.min_value) && 2344 (sceFactor <= m_pCapability->sce_ctrl.max_value)) { 2345 CDBG(" new Skintone Enhancement value : %d ", sceFactor); 2346 return setSkinToneEnhancement(sceFactor); 2347 } else { 2348 ALOGE("%s: invalid value %d out of (%d, %d)", 2349 __func__, sceFactor, 2350 m_pCapability->sce_ctrl.min_value, 2351 m_pCapability->sce_ctrl.max_value); 2352 return BAD_VALUE; 2353 } 2354 } else { 2355 CDBG("%s: No value change in skintone enhancement factor", __func__); 2356 return NO_ERROR; 2357 } 2358 } 2359 2360 /*=========================================================================== 2361 * FUNCTION : setSaturation 2362 * 2363 * DESCRIPTION: set saturation control value from user setting 2364 * 2365 * PARAMETERS : 2366 * @params : user setting parameters 2367 * 2368 * RETURN : int32_t type of status 2369 * NO_ERROR -- success 2370 * none-zero failure code 2371 *==========================================================================*/ 2372 int32_t QCameraParameters::setSaturation(const QCameraParameters& params) 2373 { 2374 int saturation = params.getInt(KEY_QC_SATURATION); 2375 int prev_sat = getInt(KEY_QC_SATURATION); 2376 2377 if(params.get(KEY_QC_SATURATION) == NULL) { 2378 CDBG_HIGH("%s: Saturation not set by App ",__func__); 2379 return NO_ERROR; 2380 } 2381 if (prev_sat != saturation) { 2382 if((saturation >= m_pCapability->saturation_ctrl.min_value) && 2383 (saturation <= m_pCapability->saturation_ctrl.max_value)) { 2384 CDBG(" new saturation value : %d ", saturation); 2385 return setSaturation(saturation); 2386 } else { 2387 ALOGE("%s: invalid value %d out of (%d, %d)", 2388 __func__, saturation, 2389 m_pCapability->saturation_ctrl.min_value, 2390 m_pCapability->saturation_ctrl.max_value); 2391 return BAD_VALUE; 2392 } 2393 } else { 2394 CDBG("%s: No value change in saturation factor", __func__); 2395 return NO_ERROR; 2396 } 2397 } 2398 2399 /*=========================================================================== 2400 * FUNCTION : setContrast 2401 * 2402 * DESCRIPTION: set contrast control value from user setting 2403 * 2404 * PARAMETERS : 2405 * @params : user setting parameters 2406 * 2407 * RETURN : int32_t type of status 2408 * NO_ERROR -- success 2409 * none-zero failure code 2410 *==========================================================================*/ 2411 int32_t QCameraParameters::setContrast(const QCameraParameters& params) 2412 { 2413 int contrast = params.getInt(KEY_QC_CONTRAST); 2414 int prev_contrast = getInt(KEY_QC_CONTRAST); 2415 2416 if(params.get(KEY_QC_CONTRAST) == NULL) { 2417 CDBG_HIGH("%s: Contrast not set by App ",__func__); 2418 return NO_ERROR; 2419 } 2420 if (prev_contrast != contrast) { 2421 if((contrast >= m_pCapability->contrast_ctrl.min_value) && 2422 (contrast <= m_pCapability->contrast_ctrl.max_value)) { 2423 CDBG(" new contrast value : %d ", contrast); 2424 int32_t rc = setContrast(contrast); 2425 return rc; 2426 } else { 2427 ALOGE("%s: invalid value %d out of (%d, %d)", 2428 __func__, contrast, 2429 m_pCapability->contrast_ctrl.min_value, 2430 m_pCapability->contrast_ctrl.max_value); 2431 return BAD_VALUE; 2432 } 2433 } else { 2434 CDBG("%s: No value change in contrast", __func__); 2435 return NO_ERROR; 2436 } 2437 } 2438 2439 /*=========================================================================== 2440 * FUNCTION : setExposureCompensation 2441 * 2442 * DESCRIPTION: set exposure compensation value from user setting 2443 * 2444 * PARAMETERS : 2445 * @params : user setting parameters 2446 * 2447 * RETURN : int32_t type of status 2448 * NO_ERROR -- success 2449 * none-zero failure code 2450 *==========================================================================*/ 2451 int32_t QCameraParameters::setExposureCompensation(const QCameraParameters & params) 2452 { 2453 int expComp = params.getInt(KEY_EXPOSURE_COMPENSATION); 2454 int prev_expComp = getInt(KEY_EXPOSURE_COMPENSATION); 2455 2456 if(params.get(KEY_EXPOSURE_COMPENSATION) == NULL) { 2457 CDBG_HIGH("%s: Exposure compensation not set by App ",__func__); 2458 return NO_ERROR; 2459 } 2460 if (prev_expComp != expComp) { 2461 if((expComp >= m_pCapability->exposure_compensation_min) && 2462 (expComp <= m_pCapability->exposure_compensation_max)) { 2463 CDBG(" new Exposure Compensation value : %d ", expComp); 2464 return setExposureCompensation(expComp); 2465 } else { 2466 ALOGE("%s: invalid value %d out of (%d, %d)", 2467 __func__, expComp, 2468 m_pCapability->exposure_compensation_min, 2469 m_pCapability->exposure_compensation_max); 2470 return BAD_VALUE; 2471 } 2472 } else { 2473 CDBG("%s: No value change in Exposure Compensation", __func__); 2474 return NO_ERROR; 2475 } 2476 } 2477 2478 /*=========================================================================== 2479 * FUNCTION : setWhiteBalance 2480 * 2481 * DESCRIPTION: set white balance value from user setting 2482 * 2483 * PARAMETERS : 2484 * @params : user setting parameters 2485 * 2486 * RETURN : int32_t type of status 2487 * NO_ERROR -- success 2488 * none-zero failure code 2489 *==========================================================================*/ 2490 int32_t QCameraParameters::setWhiteBalance(const QCameraParameters& params) 2491 { 2492 const char *str = params.get(KEY_WHITE_BALANCE); 2493 const char *prev_str = get(KEY_WHITE_BALANCE); 2494 if (str != NULL) { 2495 if (prev_str == NULL || 2496 strcmp(str, prev_str) != 0) { 2497 return setWhiteBalance(str); 2498 } 2499 } 2500 return NO_ERROR; 2501 } 2502 2503 /*=========================================================================== 2504 * FUNCTION : setManualWhiteBalance 2505 * 2506 * DESCRIPTION: set manual white balance from user setting 2507 * 2508 * PARAMETERS : 2509 * @params : user setting parameters 2510 * 2511 * RETURN : int32_t type of status 2512 * NO_ERROR -- success 2513 * none-zero failure code 2514 *==========================================================================*/ 2515 int32_t QCameraParameters::setManualWhiteBalance(const QCameraParameters& params) 2516 { 2517 int32_t rc = NO_ERROR; 2518 const char *wb_str = params.get(KEY_WHITE_BALANCE); 2519 CDBG("%s, current wb mode: %s", __func__, wb_str); 2520 2521 if (wb_str != NULL) { 2522 if (strcmp(wb_str, WHITE_BALANCE_MANUAL)) { 2523 CDBG("%s, dont set cct to back-end.", __func__); 2524 return NO_ERROR; 2525 } 2526 } 2527 2528 const char *value = params.get(KEY_QC_MANUAL_WB_VALUE); 2529 const char *prev_value = get(KEY_QC_MANUAL_WB_VALUE); 2530 const char *type = params.get(KEY_QC_MANUAL_WB_TYPE); 2531 const char *prev_type = get(KEY_QC_MANUAL_WB_TYPE); 2532 2533 if ((value != NULL) && (type != NULL)) { 2534 if (prev_value == NULL || (strcmp(value, prev_value) != 0) || 2535 prev_type == NULL || (strcmp(type, prev_type) != 0)) { 2536 updateParamEntry(KEY_QC_MANUAL_WB_TYPE, type); 2537 updateParamEntry(KEY_QC_MANUAL_WB_VALUE, value); 2538 int32_t wb_type = atoi(type); 2539 if (wb_type == CAM_MANUAL_WB_MODE_CCT) { 2540 rc = setWBManualCCT(value); 2541 } else if (wb_type == CAM_MANUAL_WB_MODE_GAIN) { 2542 rc = setManualWBGains(value); 2543 } else { 2544 rc = BAD_VALUE; 2545 } 2546 } 2547 } 2548 return rc; 2549 } 2550 2551 /*=========================================================================== 2552 * FUNCTION : setAntibanding 2553 * 2554 * DESCRIPTION: set antibanding value from user setting 2555 * 2556 * PARAMETERS : 2557 * @params : user setting parameters 2558 * 2559 * RETURN : int32_t type of status 2560 * NO_ERROR -- success 2561 * none-zero failure code 2562 *==========================================================================*/ 2563 int32_t QCameraParameters::setAntibanding(const QCameraParameters& params) 2564 { 2565 const char *str = params.get(KEY_ANTIBANDING); 2566 const char *prev_str = get(KEY_ANTIBANDING); 2567 if (str != NULL) { 2568 if (prev_str == NULL || 2569 strcmp(str, prev_str) != 0) { 2570 return setAntibanding(str); 2571 } 2572 } 2573 return NO_ERROR; 2574 } 2575 2576 /*=========================================================================== 2577 * FUNCTION : setStatsDebugMask 2578 * 2579 * DESCRIPTION: get the value from persist file in Stats module that will 2580 * control funtionality in the module 2581 * 2582 * PARAMETERS : none 2583 * 2584 * RETURN : int32_t type of status 2585 * NO_ERROR -- success 2586 * none-zero failure code 2587 *==========================================================================*/ 2588 int32_t QCameraParameters::setStatsDebugMask() 2589 { 2590 uint32_t mask = 0; 2591 char value[PROPERTY_VALUE_MAX]; 2592 2593 property_get("persist.camera.stats.debug.mask", value, "0"); 2594 mask = (uint32_t)atoi(value); 2595 2596 CDBG_HIGH("%s: ctrl mask :%d", __func__, mask); 2597 2598 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_STATS_DEBUG_MASK, mask)) { 2599 return BAD_VALUE; 2600 } 2601 2602 return NO_ERROR; 2603 } 2604 2605 /*=========================================================================== 2606 * FUNCTION : setPAAF 2607 * 2608 * DESCRIPTION: get the value from persist file in Stats module that will 2609 * control the preview assisted AF in the module 2610 * 2611 * PARAMETERS : none 2612 * 2613 * RETURN : int32_t type of status 2614 * NO_ERROR -- success 2615 * none-zero failure code 2616 *==========================================================================*/ 2617 int32_t QCameraParameters::setPAAF() 2618 { 2619 uint32_t paaf = 0; 2620 char value[PROPERTY_VALUE_MAX]; 2621 2622 property_get("persist.camera.stats.af.paaf", value, "1"); 2623 paaf = (uint32_t)atoi(value); 2624 2625 CDBG_HIGH("%s: PAAF is: %s", __func__, paaf ? "ON": "OFF"); 2626 2627 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_STATS_AF_PAAF, paaf)) { 2628 return BAD_VALUE; 2629 } 2630 2631 return NO_ERROR; 2632 } 2633 2634 /*=========================================================================== 2635 * FUNCTION : setSceneDetect 2636 * 2637 * DESCRIPTION: set scenen detect value from user setting 2638 * 2639 * PARAMETERS : 2640 * @params : user setting parameters 2641 * 2642 * RETURN : int32_t type of status 2643 * NO_ERROR -- success 2644 * none-zero failure code 2645 *==========================================================================*/ 2646 int32_t QCameraParameters::setSceneDetect(const QCameraParameters& params) 2647 { 2648 const char *str = params.get(KEY_QC_SCENE_DETECT); 2649 const char *prev_str = get(KEY_QC_SCENE_DETECT); 2650 if (str != NULL) { 2651 if (prev_str == NULL || 2652 strcmp(str, prev_str) != 0) { 2653 return setSceneDetect(str); 2654 } 2655 } 2656 return NO_ERROR; 2657 } 2658 2659 /*=========================================================================== 2660 * FUNCTION : setVideoHDR 2661 * 2662 * DESCRIPTION: set video HDR value from user setting 2663 * 2664 * PARAMETERS : 2665 * @params : user setting parameters 2666 * 2667 * RETURN : int32_t type of status 2668 * NO_ERROR -- success 2669 * none-zero failure code 2670 *==========================================================================*/ 2671 int32_t QCameraParameters::setVideoHDR(const QCameraParameters& params) 2672 { 2673 const char *str = params.get(KEY_QC_VIDEO_HDR); 2674 const char *prev_str = get(KEY_QC_VIDEO_HDR); 2675 if (str != NULL) { 2676 if (prev_str == NULL || 2677 strcmp(str, prev_str) != 0) { 2678 return setVideoHDR(str); 2679 } 2680 } 2681 return NO_ERROR; 2682 } 2683 2684 /*=========================================================================== 2685 * FUNCTION : setVtEnable 2686 * 2687 * DESCRIPTION: set vt Time Stamp enable from user setting 2688 * 2689 * PARAMETERS : 2690 * @params : user setting parameters 2691 * 2692 * RETURN : int32_t type of status 2693 * NO_ERROR -- success 2694 * none-zero failure code 2695 *==========================================================================*/ 2696 int32_t QCameraParameters::setVtEnable(const QCameraParameters& params) 2697 { 2698 const char *str = params.get(KEY_QC_VT_ENABLE); 2699 const char *prev_str = get(KEY_QC_VT_ENABLE); 2700 if (str != NULL) { 2701 if (prev_str == NULL || 2702 strcmp(str, prev_str) != 0) { 2703 return setVtEnable(str); 2704 } 2705 } 2706 return NO_ERROR; 2707 } 2708 2709 /*=========================================================================== 2710 * FUNCTION : setFaceRecognition 2711 * 2712 * DESCRIPTION: set face recognition mode from user setting 2713 * 2714 * PARAMETERS : 2715 * @params : user setting parameters 2716 * 2717 * RETURN : int32_t type of status 2718 * NO_ERROR -- success 2719 * none-zero failure code 2720 *==========================================================================*/ 2721 int32_t QCameraParameters::setFaceRecognition(const QCameraParameters& params) 2722 { 2723 const char *str = params.get(KEY_QC_FACE_RECOGNITION); 2724 const char *prev_str = get(KEY_QC_FACE_RECOGNITION); 2725 if (str != NULL) { 2726 if (prev_str == NULL || 2727 strcmp(str, prev_str) != 0) { 2728 uint32_t maxFaces = (uint32_t)params.getInt(KEY_QC_MAX_NUM_REQUESTED_FACES); 2729 return setFaceRecognition(str, maxFaces); 2730 } 2731 } 2732 return NO_ERROR; 2733 } 2734 2735 /*=========================================================================== 2736 * FUNCTION : setZoom 2737 * 2738 * DESCRIPTION: set zoom value from user setting 2739 * 2740 * PARAMETERS : 2741 * @params : user setting parameters 2742 * 2743 * RETURN : int32_t type of status 2744 * NO_ERROR -- success 2745 * none-zero failure code 2746 *==========================================================================*/ 2747 int32_t QCameraParameters::setZoom(const QCameraParameters& params) 2748 { 2749 if ((m_pCapability->zoom_supported == 0 || 2750 m_pCapability->zoom_ratio_tbl_cnt == 0)) { 2751 CDBG_HIGH("%s: no zoom support", __func__); 2752 return NO_ERROR; 2753 } 2754 2755 int zoomLevel = params.getInt(KEY_ZOOM); 2756 mParmZoomLevel = zoomLevel; 2757 if ((zoomLevel < 0) || (zoomLevel >= (int)m_pCapability->zoom_ratio_tbl_cnt)) { 2758 ALOGE("%s: invalid value %d out of (%d, %d)", 2759 __func__, zoomLevel, 2760 0, m_pCapability->zoom_ratio_tbl_cnt-1); 2761 return BAD_VALUE; 2762 } 2763 2764 int prevZoomLevel = getInt(KEY_ZOOM); 2765 if (prevZoomLevel == zoomLevel) { 2766 CDBG("%s: No value change in zoom %d %d", __func__, prevZoomLevel, zoomLevel); 2767 return NO_ERROR; 2768 } 2769 2770 return setZoom(zoomLevel); 2771 } 2772 2773 /*=========================================================================== 2774 * FUNCTION : setISOValue 2775 * 2776 * DESCRIPTION: set ISO value from user setting 2777 * 2778 * PARAMETERS : 2779 * @params : user setting parameters 2780 * 2781 * RETURN : int32_t type of status 2782 * NO_ERROR -- success 2783 * none-zero failure code 2784 *==========================================================================*/ 2785 int32_t QCameraParameters::setISOValue(const QCameraParameters& params) 2786 { 2787 const char *str = params.get(KEY_QC_ISO_MODE); 2788 const char *prev_str = get(KEY_QC_ISO_MODE); 2789 if (str != NULL) { 2790 if (prev_str == NULL || 2791 strcmp(str, prev_str) != 0) { 2792 return setISOValue(str); 2793 } 2794 } 2795 return NO_ERROR; 2796 } 2797 2798 /*=========================================================================== 2799 * FUNCTION : setContinuousISO 2800 * 2801 * DESCRIPTION: set ISO value from user setting 2802 * 2803 * PARAMETERS : 2804 * @params : user setting parameters 2805 * 2806 * RETURN : int32_t type of status 2807 * NO_ERROR -- success 2808 * none-zero failure code 2809 *==========================================================================*/ 2810 int32_t QCameraParameters::setContinuousISO(const char *isoValue) 2811 { 2812 char iso[PROPERTY_VALUE_MAX]; 2813 int32_t continous_iso = 0; 2814 2815 // Check if continuous ISO is set through setproperty 2816 property_get("persist.camera.continuous.iso", iso, ""); 2817 if (strlen(iso) > 0) { 2818 continous_iso = atoi(iso); 2819 } else { 2820 continous_iso = atoi(isoValue); 2821 } 2822 2823 if ((continous_iso >= 0) && 2824 (continous_iso <= m_pCapability->sensitivity_range.max_sensitivity)) { 2825 CDBG_HIGH("%s: Setting continuous ISO value %d", __func__, continous_iso); 2826 updateParamEntry(KEY_QC_CONTINUOUS_ISO, isoValue); 2827 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_ISO, continous_iso)) { 2828 return BAD_VALUE; 2829 } 2830 return NO_ERROR; 2831 } 2832 ALOGE("Invalid iso value: %d", continous_iso); 2833 return BAD_VALUE; 2834 } 2835 2836 /*=========================================================================== 2837 * FUNCTION : setExposureTime 2838 * 2839 * DESCRIPTION: set exposure time from user setting 2840 * 2841 * PARAMETERS : 2842 * @params : user setting parameters 2843 * 2844 * RETURN : int32_t type of status 2845 * NO_ERROR -- success 2846 * none-zero failure code 2847 *==========================================================================*/ 2848 int32_t QCameraParameters::setExposureTime(const QCameraParameters& params) 2849 { 2850 const char *str = params.get(KEY_QC_EXPOSURE_TIME); 2851 const char *prev_str = get(KEY_QC_EXPOSURE_TIME); 2852 if (str != NULL) { 2853 if (prev_str == NULL || 2854 strcmp(str, prev_str) != 0) { 2855 return setExposureTime(str); 2856 } 2857 } 2858 2859 return NO_ERROR; 2860 } 2861 2862 /*=========================================================================== 2863 * FUNCTION : setVideoRotation 2864 * 2865 * DESCRIPTION: set rotation value from user setting 2866 * 2867 * PARAMETERS : 2868 * @params : user setting parameters 2869 * 2870 * RETURN : int32_t type of status 2871 * NO_ERROR -- success 2872 * none-zero failure code 2873 *==========================================================================*/ 2874 int32_t QCameraParameters::setVideoRotation(const QCameraParameters& params) 2875 { 2876 const char *str = params.get(KEY_QC_VIDEO_ROTATION); 2877 if(str != NULL) { 2878 int value = lookupAttr(VIDEO_ROTATION_MODES_MAP, 2879 PARAM_MAP_SIZE(VIDEO_ROTATION_MODES_MAP), str); 2880 if (value != NAME_NOT_FOUND) { 2881 updateParamEntry(KEY_QC_VIDEO_ROTATION, str); 2882 ALOGV("setVideoRotation: %s: %d: ", str, value); 2883 } else { 2884 ALOGE("Invalid rotation value: %d", value); 2885 return BAD_VALUE; 2886 } 2887 2888 } 2889 return NO_ERROR; 2890 } 2891 2892 /*=========================================================================== 2893 * FUNCTION : setRotation 2894 * 2895 * DESCRIPTION: set rotation value from user setting 2896 * 2897 * PARAMETERS : 2898 * @params : user setting parameters 2899 * 2900 * RETURN : int32_t type of status 2901 * NO_ERROR -- success 2902 * none-zero failure code 2903 *==========================================================================*/ 2904 int32_t QCameraParameters::setRotation(const QCameraParameters& params) 2905 { 2906 int32_t rotation = params.getInt(KEY_ROTATION); 2907 if (rotation != -1) { 2908 if (rotation == 0 || rotation == 90 || 2909 rotation == 180 || rotation == 270) { 2910 set(KEY_ROTATION, rotation); 2911 2912 ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_META_JPEG_ORIENTATION, 2913 rotation); 2914 mRotation = rotation; 2915 } else { 2916 ALOGE("Invalid rotation value: %d", rotation); 2917 return BAD_VALUE; 2918 } 2919 } 2920 return NO_ERROR; 2921 } 2922 2923 /*=========================================================================== 2924 * FUNCTION : setFlash 2925 * 2926 * DESCRIPTION: set flash mode from user setting 2927 * 2928 * PARAMETERS : 2929 * @params : user setting parameters 2930 * 2931 * RETURN : int32_t type of status 2932 * NO_ERROR -- success 2933 * none-zero failure code 2934 *==========================================================================*/ 2935 int32_t QCameraParameters::setFlash(const QCameraParameters& params) 2936 { 2937 const char *str = params.get(KEY_FLASH_MODE); 2938 const char *prev_str = get(KEY_FLASH_MODE); 2939 if (str != NULL) { 2940 if (prev_str == NULL || 2941 strcmp(str, prev_str) != 0) { 2942 return setFlash(str); 2943 } 2944 } 2945 return NO_ERROR; 2946 } 2947 2948 /*=========================================================================== 2949 * FUNCTION : setAecLock 2950 * 2951 * DESCRIPTION: set AEC lock value from user setting 2952 * 2953 * PARAMETERS : 2954 * @params : user setting parameters 2955 * 2956 * RETURN : int32_t type of status 2957 * NO_ERROR -- success 2958 * none-zero failure code 2959 *==========================================================================*/ 2960 int32_t QCameraParameters::setAecLock(const QCameraParameters& params) 2961 { 2962 const char *str = params.get(KEY_AUTO_EXPOSURE_LOCK); 2963 const char *prev_str = get(KEY_AUTO_EXPOSURE_LOCK); 2964 if (str != NULL) { 2965 if (prev_str == NULL || 2966 strcmp(str, prev_str) != 0) { 2967 return setAecLock(str); 2968 } 2969 } 2970 return NO_ERROR; 2971 } 2972 2973 /*=========================================================================== 2974 * FUNCTION : setAwbLock 2975 * 2976 * DESCRIPTION: set AWB lock from user setting 2977 * 2978 * PARAMETERS : 2979 * @params : user setting parameters 2980 * 2981 * RETURN : int32_t type of status 2982 * NO_ERROR -- success 2983 * none-zero failure code 2984 *==========================================================================*/ 2985 int32_t QCameraParameters::setAwbLock(const QCameraParameters& params) 2986 { 2987 const char *str = params.get(KEY_AUTO_WHITEBALANCE_LOCK); 2988 const char *prev_str = get(KEY_AUTO_WHITEBALANCE_LOCK); 2989 if (str != NULL) { 2990 if (prev_str == NULL || 2991 strcmp(str, prev_str) != 0) { 2992 return setAwbLock(str); 2993 } 2994 } 2995 return NO_ERROR; 2996 } 2997 2998 /*=========================================================================== 2999 * FUNCTION : setAutoHDR 3000 * 3001 * DESCRIPTION: Enable/disable auto HDR 3002 * 3003 * PARAMETERS : 3004 * @params : user setting parameters 3005 * 3006 * RETURN : int32_t type of status 3007 * NO_ERROR -- success 3008 * none-zero failure code 3009 *==========================================================================*/ 3010 int32_t QCameraParameters::setAutoHDR(const QCameraParameters& params) 3011 { 3012 const char *str = params.get(KEY_QC_AUTO_HDR_ENABLE); 3013 const char *prev_str = get(KEY_QC_AUTO_HDR_ENABLE); 3014 char prop[PROPERTY_VALUE_MAX]; 3015 3016 memset(prop, 0, sizeof(prop)); 3017 property_get("persist.camera.auto.hdr.enable", prop, VALUE_DISABLE); 3018 if (str != NULL) { 3019 if (prev_str == NULL || 3020 strcmp(str, prev_str) != 0) { 3021 CDBG_HIGH("%s : Auto HDR set to: %s", __func__, str); 3022 return updateParamEntry(KEY_QC_AUTO_HDR_ENABLE, str); 3023 } 3024 } else { 3025 if (prev_str == NULL || 3026 strcmp(prev_str, prop) != 0 ) { 3027 CDBG_HIGH("%s : Auto HDR set to: %s", __func__, prop); 3028 updateParamEntry(KEY_QC_AUTO_HDR_ENABLE, prop); 3029 } 3030 } 3031 3032 return NO_ERROR; 3033 } 3034 3035 /*=========================================================================== 3036 * FUNCTION : isAutoHDREnabled 3037 * 3038 * DESCRIPTION: Query auto HDR status 3039 * 3040 * PARAMETERS : None 3041 * 3042 * RETURN : bool true/false 3043 *==========================================================================*/ 3044 bool QCameraParameters::isAutoHDREnabled() 3045 { 3046 const char *str = get(KEY_QC_AUTO_HDR_ENABLE); 3047 if (str != NULL) { 3048 int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP, 3049 PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP), str); 3050 if (value == NAME_NOT_FOUND) { 3051 ALOGE("%s: Invalid Auto HDR value %s", __func__, str); 3052 return false; 3053 } 3054 3055 CDBG_HIGH("%s : Auto HDR status is: %d", __func__, value); 3056 return value ? true : false; 3057 } 3058 3059 CDBG_HIGH("%s : Auto HDR status not set!", __func__); 3060 return false; 3061 } 3062 3063 /*=========================================================================== 3064 * FUNCTION : setMCEValue 3065 * 3066 * DESCRIPTION: set memory color enhancement value from user setting 3067 * 3068 * PARAMETERS : 3069 * @params : user setting parameters 3070 * 3071 * RETURN : int32_t type of status 3072 * NO_ERROR -- success 3073 * none-zero failure code 3074 *==========================================================================*/ 3075 int32_t QCameraParameters::setMCEValue(const QCameraParameters& params) 3076 { 3077 const char *str = params.get(KEY_QC_MEMORY_COLOR_ENHANCEMENT); 3078 const char *prev_str = get(KEY_QC_MEMORY_COLOR_ENHANCEMENT); 3079 if (str != NULL) { 3080 if (prev_str == NULL || 3081 strcmp(str, prev_str) != 0) { 3082 return setMCEValue(str); 3083 } 3084 } 3085 return NO_ERROR; 3086 } 3087 3088 /*=========================================================================== 3089 * FUNCTION : setDISValue 3090 * 3091 * DESCRIPTION: enable/disable DIS from user setting 3092 * 3093 * PARAMETERS : 3094 * @params : user setting parameters 3095 * 3096 * RETURN : int32_t type of status 3097 * NO_ERROR -- success 3098 * none-zero failure code 3099 *==========================================================================*/ 3100 int32_t QCameraParameters::setDISValue(const QCameraParameters& params) 3101 { 3102 const char *str = params.get(KEY_QC_DIS); 3103 const char *prev_str = get(KEY_QC_DIS); 3104 if (str != NULL) { 3105 if (prev_str == NULL || 3106 strcmp(str, prev_str) != 0) { 3107 return setDISValue(str); 3108 } 3109 } 3110 return NO_ERROR; 3111 } 3112 3113 /*=========================================================================== 3114 * FUNCTION : setLensShadeValue 3115 * 3116 * DESCRIPTION: set lens shade value from user setting 3117 * 3118 * PARAMETERS : 3119 * @params : user setting parameters 3120 * 3121 * RETURN : int32_t type of status 3122 * NO_ERROR -- success 3123 * none-zero failure code 3124 *==========================================================================*/ 3125 int32_t QCameraParameters::setLensShadeValue(const QCameraParameters& params) 3126 { 3127 const char *str = params.get(KEY_QC_LENSSHADE); 3128 const char *prev_str = get(KEY_QC_LENSSHADE); 3129 if (str != NULL) { 3130 if (prev_str == NULL || 3131 strcmp(str, prev_str) != 0) { 3132 return setLensShadeValue(str); 3133 } 3134 } 3135 return NO_ERROR; 3136 } 3137 3138 /*=========================================================================== 3139 * FUNCTION : setFocusAreas 3140 * 3141 * DESCRIPTION: set focus areas from user setting 3142 * 3143 * PARAMETERS : 3144 * @params : user setting parameters 3145 * 3146 * RETURN : int32_t type of status 3147 * NO_ERROR -- success 3148 * none-zero failure code 3149 *==========================================================================*/ 3150 int32_t QCameraParameters::setFocusAreas(const QCameraParameters& params) 3151 { 3152 const char *str = params.get(KEY_FOCUS_AREAS); 3153 if (str != NULL) { 3154 int max_num_af_areas = getInt(KEY_MAX_NUM_FOCUS_AREAS); 3155 if(max_num_af_areas == 0) { 3156 ALOGE("%s: max num of AF area is 0, cannot set focus areas", __func__); 3157 return BAD_VALUE; 3158 } 3159 3160 const char *prev_str = get(KEY_FOCUS_AREAS); 3161 if (prev_str == NULL || 3162 strcmp(str, prev_str) != 0) { 3163 return setFocusAreas(str); 3164 } 3165 } 3166 return NO_ERROR; 3167 } 3168 3169 /*=========================================================================== 3170 * FUNCTION : setMeteringAreas 3171 * 3172 * DESCRIPTION: set metering areas from user setting 3173 * 3174 * PARAMETERS : 3175 * @params : user setting parameters 3176 * 3177 * RETURN : int32_t type of status 3178 * NO_ERROR -- success 3179 * none-zero failure code 3180 *==========================================================================*/ 3181 int32_t QCameraParameters::setMeteringAreas(const QCameraParameters& params) 3182 { 3183 const char *str = params.get(KEY_METERING_AREAS); 3184 if (str != NULL) { 3185 int max_num_mtr_areas = getInt(KEY_MAX_NUM_METERING_AREAS); 3186 if(max_num_mtr_areas == 0) { 3187 ALOGE("%s: max num of metering areas is 0, cannot set focus areas", __func__); 3188 return BAD_VALUE; 3189 } 3190 3191 const char *prev_str = get(KEY_METERING_AREAS); 3192 if (prev_str == NULL || 3193 strcmp(str, prev_str) != 0) { 3194 return setMeteringAreas(str); 3195 } 3196 } 3197 return NO_ERROR; 3198 } 3199 3200 /*=========================================================================== 3201 * FUNCTION : setSceneMode 3202 * 3203 * DESCRIPTION: set scenen mode from user setting 3204 * 3205 * PARAMETERS : 3206 * @params : user setting parameters 3207 * 3208 * RETURN : int32_t type of status 3209 * NO_ERROR -- success 3210 * none-zero failure code 3211 *==========================================================================*/ 3212 int32_t QCameraParameters::setSceneMode(const QCameraParameters& params) 3213 { 3214 const char *str = params.get(KEY_SCENE_MODE); 3215 const char *prev_str = get(KEY_SCENE_MODE); 3216 CDBG_HIGH("%s: str - %s, prev_str - %s",__func__, str, prev_str); 3217 3218 if (str != NULL) { 3219 if (prev_str == NULL || 3220 strcmp(str, prev_str) != 0) { 3221 3222 if(strcmp(str, SCENE_MODE_AUTO) == 0) { 3223 m_bSceneTransitionAuto = true; 3224 } 3225 if (strcmp(str, SCENE_MODE_HDR) == 0) { 3226 3227 // If HDR is set from client and the feature is not enabled in the backend, ignore it. 3228 if (m_bHDRModeSensor) { 3229 m_bSensorHDREnabled = true; 3230 CDBG_HIGH("%s: Sensor HDR mode Enabled",__func__); 3231 } else { 3232 m_bHDREnabled = true; 3233 CDBG_HIGH("%s: S/W HDR Enabled",__func__); 3234 } 3235 } else { 3236 m_bHDREnabled = false; 3237 if (m_bSensorHDREnabled) { 3238 m_bSensorHDREnabled = false; 3239 m_bNeedRestart = true; 3240 setSensorSnapshotHDR("off"); 3241 } 3242 } 3243 3244 if (m_bSensorHDREnabled) { 3245 setSensorSnapshotHDR("on"); 3246 m_bNeedRestart = true; 3247 } else if ((m_bHDREnabled) || 3248 ((prev_str != NULL) && (strcmp(prev_str, SCENE_MODE_HDR) == 0))) { 3249 CDBG_HIGH("%s: scene mode changed between HDR and non-HDR, need restart", __func__); 3250 3251 m_bNeedRestart = true; 3252 } 3253 3254 return setSceneMode(str); 3255 } 3256 } 3257 return NO_ERROR; 3258 } 3259 3260 /*=========================================================================== 3261 * FUNCTION : setSelectableZoneAf 3262 * 3263 * DESCRIPTION: set selectable zone auto focus value from user setting 3264 * 3265 * PARAMETERS : 3266 * @params : user setting parameters 3267 * 3268 * RETURN : int32_t type of status 3269 * NO_ERROR -- success 3270 * none-zero failure code 3271 *==========================================================================*/ 3272 int32_t QCameraParameters::setSelectableZoneAf(const QCameraParameters& params) 3273 { 3274 const char *str = params.get(KEY_QC_SELECTABLE_ZONE_AF); 3275 const char *prev_str = get(KEY_QC_SELECTABLE_ZONE_AF); 3276 if (str != NULL) { 3277 if (prev_str == NULL || 3278 strcmp(str, prev_str) != 0) { 3279 return setSelectableZoneAf(str); 3280 } 3281 } 3282 return NO_ERROR; 3283 } 3284 3285 /*=========================================================================== 3286 * FUNCTION : setAEBracket 3287 * 3288 * DESCRIPTION: set AE bracket from user setting 3289 * 3290 * PARAMETERS : 3291 * @params : user setting parameters 3292 * 3293 * RETURN : int32_t type of status 3294 * NO_ERROR -- success 3295 * none-zero failure code 3296 *==========================================================================*/ 3297 int32_t QCameraParameters::setAEBracket(const QCameraParameters& params) 3298 { 3299 if (isHDREnabled()) { 3300 CDBG_HIGH("%s: scene mode is HDR, overwrite AE bracket setting to off", __func__); 3301 return setAEBracket(AE_BRACKET_OFF); 3302 } 3303 3304 const char *expStr = params.get(KEY_QC_CAPTURE_BURST_EXPOSURE); 3305 if (NULL != expStr && strlen(expStr) > 0) { 3306 set(KEY_QC_CAPTURE_BURST_EXPOSURE, expStr); 3307 } else { 3308 char prop[PROPERTY_VALUE_MAX]; 3309 memset(prop, 0, sizeof(prop)); 3310 property_get("persist.capture.burst.exposures", prop, ""); 3311 if (strlen(prop) > 0) { 3312 set(KEY_QC_CAPTURE_BURST_EXPOSURE, prop); 3313 } else { 3314 remove(KEY_QC_CAPTURE_BURST_EXPOSURE); 3315 } 3316 } 3317 3318 const char *str = params.get(KEY_QC_AE_BRACKET_HDR); 3319 const char *prev_str = get(KEY_QC_AE_BRACKET_HDR); 3320 if (str != NULL) { 3321 if (prev_str == NULL || 3322 strcmp(str, prev_str) != 0) { 3323 return setAEBracket(str); 3324 } 3325 } 3326 return NO_ERROR; 3327 } 3328 3329 /*=========================================================================== 3330 * FUNCTION : setAFBracket 3331 * 3332 * DESCRIPTION: set AF bracket from user setting 3333 * 3334 * PARAMETERS : 3335 * @params : user setting parameters 3336 * 3337 * RETURN : int32_t type of status 3338 * NO_ERROR -- success 3339 * none-zero failure code 3340 *==========================================================================*/ 3341 int32_t QCameraParameters::setAFBracket(const QCameraParameters& params) 3342 { 3343 if ((m_pCapability->qcom_supported_feature_mask & 3344 (CAM_QCOM_FEATURE_REFOCUS | CAM_QCOM_FEATURE_UBIFOCUS)) == 0) { 3345 CDBG_HIGH("%s: AF Bracketing is not supported",__func__); 3346 return NO_ERROR; 3347 } 3348 const char *str = params.get(KEY_QC_AF_BRACKET); 3349 const char *prev_str = get(KEY_QC_AF_BRACKET); 3350 CDBG_HIGH("%s: str =%s & prev_str =%s",__func__, str, prev_str); 3351 if (str != NULL) { 3352 if (prev_str == NULL || 3353 strcmp(str, prev_str) != 0) { 3354 m_bNeedRestart = true; 3355 return setAFBracket(str); 3356 } 3357 } 3358 return NO_ERROR; 3359 } 3360 3361 /*=========================================================================== 3362 * FUNCTION : setReFocus 3363 * 3364 * DESCRIPTION: set refocus from user setting 3365 * 3366 * PARAMETERS : 3367 * @params : user setting parameters 3368 * 3369 * RETURN : int32_t type of status 3370 * NO_ERROR -- success 3371 * none-zero failure code 3372 *==========================================================================*/ 3373 int32_t QCameraParameters::setReFocus(const QCameraParameters& params) 3374 { 3375 if ((m_pCapability->qcom_supported_feature_mask & 3376 (CAM_QCOM_FEATURE_REFOCUS | CAM_QCOM_FEATURE_UBIFOCUS)) == 0) { 3377 ALOGD("%s: AF Bracketing is not supported",__func__); 3378 return NO_ERROR; 3379 } 3380 const char *str = params.get(KEY_QC_RE_FOCUS); 3381 const char *prev_str = get(KEY_QC_RE_FOCUS); 3382 CDBG_HIGH("%s: str =%s & prev_str =%s",__func__, str, prev_str); 3383 if (str != NULL) { 3384 if (prev_str == NULL || 3385 strcmp(str, prev_str) != 0) { 3386 m_bNeedRestart = true; 3387 return setReFocus(str); 3388 } 3389 } 3390 return NO_ERROR; 3391 } 3392 3393 /*=========================================================================== 3394 * FUNCTION : setChromaFlash 3395 * 3396 * DESCRIPTION: set chroma flash 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 *==========================================================================*/ 3405 int32_t QCameraParameters::setChromaFlash(const QCameraParameters& params) 3406 { 3407 if ((m_pCapability->qcom_supported_feature_mask & 3408 CAM_QCOM_FEATURE_CHROMA_FLASH) == 0) { 3409 CDBG_HIGH("%s: Chroma Flash is not supported",__func__); 3410 return NO_ERROR; 3411 } 3412 const char *str = params.get(KEY_QC_CHROMA_FLASH); 3413 const char *prev_str = get(KEY_QC_CHROMA_FLASH); 3414 CDBG_HIGH("%s: str =%s & prev_str =%s",__func__, str, prev_str); 3415 if (str != NULL) { 3416 if (prev_str == NULL || 3417 strcmp(str, prev_str) != 0) { 3418 m_bNeedRestart = true; 3419 return setChromaFlash(str); 3420 } 3421 } 3422 return NO_ERROR; 3423 } 3424 3425 /*=========================================================================== 3426 * FUNCTION : setOptiZoom 3427 * 3428 * DESCRIPTION: set opti zoom from user setting 3429 * 3430 * PARAMETERS : 3431 * @params : user setting parameters 3432 * 3433 * RETURN : int32_t type of status 3434 * NO_ERROR -- success 3435 * none-zero failure code 3436 *==========================================================================*/ 3437 int32_t QCameraParameters::setOptiZoom(const QCameraParameters& params) 3438 { 3439 if ((m_pCapability->qcom_supported_feature_mask & 3440 CAM_QCOM_FEATURE_OPTIZOOM) == 0){ 3441 CDBG_HIGH("%s: Opti Zoom is not supported",__func__); 3442 return NO_ERROR; 3443 } 3444 const char *str = params.get(KEY_QC_OPTI_ZOOM); 3445 const char *prev_str = get(KEY_QC_OPTI_ZOOM); 3446 CDBG_HIGH("%s: str =%s & prev_str =%s",__func__, str, prev_str); 3447 if (str != NULL) { 3448 if (prev_str == NULL || 3449 strcmp(str, prev_str) != 0) { 3450 m_bNeedRestart = true; 3451 return setOptiZoom(str); 3452 } 3453 } 3454 return NO_ERROR; 3455 } 3456 3457 /*=========================================================================== 3458 * FUNCTION : setTruePortrait 3459 * 3460 * DESCRIPTION: set true portrait from user setting 3461 * 3462 * PARAMETERS : 3463 * @params : user setting parameters 3464 * 3465 * RETURN : int32_t type of status 3466 * NO_ERROR -- success 3467 * none-zero failure code 3468 *==========================================================================*/ 3469 int32_t QCameraParameters::setTruePortrait(const QCameraParameters& params) 3470 { 3471 if ((m_pCapability->qcom_supported_feature_mask & 3472 CAM_QCOM_FEATURE_TRUEPORTRAIT) == 0) { 3473 CDBG("%s: True Portrait is not supported",__func__); 3474 return NO_ERROR; 3475 } 3476 const char *str = params.get(KEY_QC_TRUE_PORTRAIT); 3477 const char *prev_str = get(KEY_QC_TRUE_PORTRAIT); 3478 CDBG_HIGH("%s: str =%s & prev_str =%s", __func__, str, prev_str); 3479 if (str != NULL) { 3480 if (prev_str == NULL || 3481 strcmp(str, prev_str) != 0) { 3482 return setTruePortrait(str); 3483 } 3484 } 3485 return NO_ERROR; 3486 } 3487 3488 /*=========================================================================== 3489 * FUNCTION : setHDRMode 3490 * 3491 * DESCRIPTION: set HDR mode from user setting 3492 * 3493 * PARAMETERS : 3494 * @params : user setting parameters 3495 * 3496 * RETURN : int32_t type of status 3497 * NO_ERROR -- success 3498 * none-zero failure code 3499 *==========================================================================*/ 3500 int32_t QCameraParameters::setHDRMode(const QCameraParameters& params) 3501 { 3502 const char *str = params.get(KEY_QC_HDR_MODE); 3503 const char *prev_str = get(KEY_QC_HDR_MODE); 3504 uint32_t supported_hdr_modes = m_pCapability->qcom_supported_feature_mask & 3505 (CAM_QCOM_FEATURE_SENSOR_HDR | CAM_QCOM_FEATURE_HDR); 3506 3507 CDBG_HIGH("%s: str =%s & prev_str =%s",__func__, str, prev_str); 3508 if (str != NULL) { 3509 if ((CAM_QCOM_FEATURE_SENSOR_HDR == supported_hdr_modes) && 3510 (strncmp(str, HDR_MODE_SENSOR, strlen(HDR_MODE_SENSOR)))) { 3511 CDBG_HIGH("%s: Only sensor HDR is supported",__func__); 3512 return NO_ERROR; 3513 } else if ((CAM_QCOM_FEATURE_HDR == supported_hdr_modes) && 3514 (strncmp(str, HDR_MODE_SENSOR, strlen(HDR_MODE_MULTI_FRAME)))) { 3515 CDBG_HIGH("%s: Only multi frame HDR is supported",__func__); 3516 return NO_ERROR; 3517 } else if (!supported_hdr_modes) { 3518 CDBG_HIGH("%s: HDR is not supported",__func__); 3519 return NO_ERROR; 3520 } 3521 if (prev_str == NULL || 3522 strcmp(str, prev_str) != 0) { 3523 return setHDRMode(str); 3524 } 3525 } 3526 3527 return NO_ERROR; 3528 } 3529 3530 /*=========================================================================== 3531 * FUNCTION : setHDRNeed1x 3532 * 3533 * DESCRIPTION: set HDR need 1x from user setting 3534 * 3535 * PARAMETERS : 3536 * @params : user setting parameters 3537 * 3538 * RETURN : int32_t type of status 3539 * NO_ERROR -- success 3540 * none-zero failure code 3541 *==========================================================================*/ 3542 int32_t QCameraParameters::setHDRNeed1x(const QCameraParameters& params) 3543 { 3544 const char *str = params.get(KEY_QC_HDR_NEED_1X); 3545 const char *prev_str = get(KEY_QC_HDR_NEED_1X); 3546 3547 CDBG_HIGH("%s: str =%s & prev_str =%s", __func__, str, prev_str); 3548 if (str != NULL) { 3549 if (m_bHDRModeSensor) { 3550 CDBG_HIGH("%s: Only multi frame HDR supports 1x frame",__func__); 3551 return NO_ERROR; 3552 } 3553 if ((prev_str == NULL) || (strcmp(str, prev_str) != 0)) { 3554 return setHDRNeed1x(str); 3555 } 3556 } 3557 return NO_ERROR; 3558 } 3559 3560 /*=========================================================================== 3561 * FUNCTION : setSeeMore 3562 * 3563 * DESCRIPTION: set see more (llvd) 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 *==========================================================================*/ 3572 int32_t QCameraParameters::setSeeMore(const QCameraParameters& params) 3573 { 3574 if ((m_pCapability->qcom_supported_feature_mask & 3575 CAM_QCOM_FEATURE_LLVD) == 0) { 3576 CDBG("%s: See more is not supported", __func__); 3577 return NO_ERROR; 3578 } 3579 const char *str = params.get(KEY_QC_SEE_MORE); 3580 const char *prev_str = get(KEY_QC_SEE_MORE); 3581 CDBG_HIGH("%s: str =%s & prev_str =%s", __func__, str, prev_str); 3582 if (str != NULL) { 3583 if (prev_str == NULL || strcmp(str, prev_str) != 0) { 3584 m_bNeedRestart = true; 3585 return setSeeMore(str); 3586 } 3587 } 3588 return NO_ERROR; 3589 } 3590 3591 /*=========================================================================== 3592 * FUNCTION : setStillMore 3593 * 3594 * DESCRIPTION: set stillmore from user setting 3595 * 3596 * PARAMETERS : 3597 * @params : user setting parameters 3598 * 3599 * RETURN : int32_t type of status 3600 * NO_ERROR -- success 3601 * none-zero failure code 3602 *==========================================================================*/ 3603 int32_t QCameraParameters::setStillMore(const QCameraParameters& params) 3604 { 3605 if ((m_pCapability->qcom_supported_feature_mask & 3606 CAM_QCOM_FEATURE_STILLMORE) == 0) { 3607 CDBG("%s: Stillmore is not supported",__func__); 3608 return NO_ERROR; 3609 } 3610 const char *str = params.get(KEY_QC_STILL_MORE); 3611 const char *prev_str = get(KEY_QC_STILL_MORE); 3612 CDBG_HIGH("%s: str =%s & prev_str =%s", __func__, str, prev_str); 3613 if (str != NULL) { 3614 if (prev_str == NULL || strcmp(str, prev_str) != 0) { 3615 m_bNeedRestart = true; 3616 return setStillMore(str); 3617 } 3618 } 3619 return NO_ERROR; 3620 } 3621 3622 /*=========================================================================== 3623 * FUNCTION : setRedeyeReduction 3624 * 3625 * DESCRIPTION: set red eye reduction setting from user setting 3626 * 3627 * PARAMETERS : 3628 * @params : user setting parameters 3629 * 3630 * RETURN : int32_t type of status 3631 * NO_ERROR -- success 3632 * none-zero failure code 3633 *==========================================================================*/ 3634 int32_t QCameraParameters::setRedeyeReduction(const QCameraParameters& params) 3635 { 3636 const char *str = params.get(KEY_QC_REDEYE_REDUCTION); 3637 const char *prev_str = get(KEY_QC_REDEYE_REDUCTION); 3638 if (str != NULL) { 3639 if (prev_str == NULL || 3640 strcmp(str, prev_str) != 0) { 3641 return setRedeyeReduction(str); 3642 } 3643 } 3644 return NO_ERROR; 3645 } 3646 3647 /*=========================================================================== 3648 * FUNCTION : setGpsLocation 3649 * 3650 * DESCRIPTION: set GPS location information from user setting 3651 * 3652 * PARAMETERS : 3653 * @params : user setting parameters 3654 * 3655 * RETURN : int32_t type of status 3656 * NO_ERROR -- success 3657 * none-zero failure code 3658 *==========================================================================*/ 3659 int32_t QCameraParameters::setGpsLocation(const QCameraParameters& params) 3660 { 3661 const char *method = params.get(KEY_GPS_PROCESSING_METHOD); 3662 if (method) { 3663 set(KEY_GPS_PROCESSING_METHOD, method); 3664 }else { 3665 remove(KEY_GPS_PROCESSING_METHOD); 3666 } 3667 3668 const char *latitude = params.get(KEY_GPS_LATITUDE); 3669 if (latitude) { 3670 set(KEY_GPS_LATITUDE, latitude); 3671 }else { 3672 remove(KEY_GPS_LATITUDE); 3673 } 3674 3675 const char *latitudeRef = params.get(KEY_QC_GPS_LATITUDE_REF); 3676 if (latitudeRef) { 3677 set(KEY_QC_GPS_LATITUDE_REF, latitudeRef); 3678 }else { 3679 remove(KEY_QC_GPS_LATITUDE_REF); 3680 } 3681 3682 const char *longitude = params.get(KEY_GPS_LONGITUDE); 3683 if (longitude) { 3684 set(KEY_GPS_LONGITUDE, longitude); 3685 }else { 3686 remove(KEY_GPS_LONGITUDE); 3687 } 3688 3689 const char *longitudeRef = params.get(KEY_QC_GPS_LONGITUDE_REF); 3690 if (longitudeRef) { 3691 set(KEY_QC_GPS_LONGITUDE_REF, longitudeRef); 3692 }else { 3693 remove(KEY_QC_GPS_LONGITUDE_REF); 3694 } 3695 3696 const char *altitudeRef = params.get(KEY_QC_GPS_ALTITUDE_REF); 3697 if (altitudeRef) { 3698 set(KEY_QC_GPS_ALTITUDE_REF, altitudeRef); 3699 }else { 3700 remove(KEY_QC_GPS_ALTITUDE_REF); 3701 } 3702 3703 const char *altitude = params.get(KEY_GPS_ALTITUDE); 3704 if (altitude) { 3705 set(KEY_GPS_ALTITUDE, altitude); 3706 }else { 3707 remove(KEY_GPS_ALTITUDE); 3708 } 3709 3710 const char *status = params.get(KEY_QC_GPS_STATUS); 3711 if (status) { 3712 set(KEY_QC_GPS_STATUS, status); 3713 } else { 3714 remove(KEY_QC_GPS_STATUS); 3715 } 3716 3717 const char *timestamp = params.get(KEY_GPS_TIMESTAMP); 3718 if (timestamp) { 3719 set(KEY_GPS_TIMESTAMP, timestamp); 3720 }else { 3721 remove(KEY_GPS_TIMESTAMP); 3722 } 3723 return NO_ERROR; 3724 } 3725 3726 /*=========================================================================== 3727 * FUNCTION : setNumOfSnapshot 3728 * 3729 * DESCRIPTION: set number of snapshot per shutter from user setting 3730 * 3731 * PARAMETERS : none 3732 * 3733 * RETURN : int32_t type of status 3734 * NO_ERROR -- success 3735 * none-zero failure code 3736 *==========================================================================*/ 3737 int32_t QCameraParameters::setNumOfSnapshot() 3738 { 3739 int nBurstNum = getBurstNum(); 3740 int nExpnum = 0; 3741 3742 const char *bracket_str = get(KEY_QC_AE_BRACKET_HDR); 3743 if (bracket_str != NULL && strlen(bracket_str) > 0) { 3744 int value = lookupAttr(BRACKETING_MODES_MAP, PARAM_MAP_SIZE(BRACKETING_MODES_MAP), 3745 bracket_str); 3746 switch (value) { 3747 case CAM_EXP_BRACKETING_ON: 3748 { 3749 nExpnum = 0; 3750 const char *str_val = get(KEY_QC_CAPTURE_BURST_EXPOSURE); 3751 if ((str_val != NULL) && (strlen(str_val) > 0)) { 3752 char prop[PROPERTY_VALUE_MAX]; 3753 memset(prop, 0, sizeof(prop)); 3754 strlcpy(prop, str_val, PROPERTY_VALUE_MAX); 3755 char *saveptr = NULL; 3756 char *token = strtok_r(prop, ",", &saveptr); 3757 while (token != NULL) { 3758 token = strtok_r(NULL, ",", &saveptr); 3759 nExpnum++; 3760 } 3761 } 3762 if (nExpnum == 0) { 3763 nExpnum = 1; 3764 } 3765 } 3766 break; 3767 default: 3768 nExpnum = 1 + getNumOfExtraHDROutBufsIfNeeded(); 3769 break; 3770 } 3771 } 3772 3773 if (isUbiRefocus()) { 3774 nBurstNum = m_pCapability->refocus_af_bracketing_need.output_count + 1; 3775 } 3776 3777 CDBG_HIGH("%s: nBurstNum = %d, nExpnum = %d", __func__, nBurstNum, nExpnum); 3778 set(KEY_QC_NUM_SNAPSHOT_PER_SHUTTER, nBurstNum * nExpnum); 3779 return NO_ERROR; 3780 } 3781 3782 /*=========================================================================== 3783 * FUNCTION : setRecordingHint 3784 * 3785 * DESCRIPTION: set recording hint value from user setting 3786 * 3787 * PARAMETERS : 3788 * @params : user setting parameters 3789 * 3790 * RETURN : int32_t type of status 3791 * NO_ERROR -- success 3792 * none-zero failure code 3793 *==========================================================================*/ 3794 int32_t QCameraParameters::setRecordingHint(const QCameraParameters& params) 3795 { 3796 const char * str = params.get(KEY_RECORDING_HINT); 3797 const char *prev_str = get(KEY_RECORDING_HINT); 3798 if (str != NULL) { 3799 if (prev_str == NULL || strcmp(str, prev_str) != 0) { 3800 int32_t value = lookupAttr(TRUE_FALSE_MODES_MAP, PARAM_MAP_SIZE(TRUE_FALSE_MODES_MAP), 3801 str); 3802 if(value != NAME_NOT_FOUND){ 3803 updateParamEntry(KEY_RECORDING_HINT, str); 3804 setRecordingHintValue(value); 3805 if (getFaceDetectionOption() == true) { 3806 setFaceDetection(value > 0 ? false : true, false); 3807 } 3808 if (m_bDISEnabled) { 3809 CDBG_HIGH("%s: %d: Setting DIS value again", __func__, __LINE__); 3810 setDISValue(VALUE_ENABLE); 3811 } 3812 return NO_ERROR; 3813 } else { 3814 ALOGE("Invalid recording hint value: %s", str); 3815 return BAD_VALUE; 3816 } 3817 } 3818 } 3819 return NO_ERROR; 3820 } 3821 3822 /*=========================================================================== 3823 * FUNCTION : setNoDisplayMode 3824 * 3825 * DESCRIPTION: set no display mode from user setting 3826 * 3827 * PARAMETERS : 3828 * @params : user setting parameters 3829 * 3830 * RETURN : int32_t type of status 3831 * NO_ERROR -- success 3832 * none-zero failure code 3833 *==========================================================================*/ 3834 int32_t QCameraParameters::setNoDisplayMode(const QCameraParameters& params) 3835 { 3836 const char *str_val = params.get(KEY_QC_NO_DISPLAY_MODE); 3837 const char *prev_str = get(KEY_QC_NO_DISPLAY_MODE); 3838 char prop[PROPERTY_VALUE_MAX]; 3839 3840 if(str_val && strlen(str_val) > 0) { 3841 if (prev_str == NULL || strcmp(str_val, prev_str) != 0) { 3842 m_bNoDisplayMode = atoi(str_val); 3843 set(KEY_QC_NO_DISPLAY_MODE, str_val); 3844 m_bNeedRestart = true; 3845 } 3846 } else { 3847 memset(prop, 0, sizeof(prop)); 3848 property_get("persist.camera.no-display", prop, "0"); 3849 m_bNoDisplayMode = atoi(prop); 3850 } 3851 CDBG_HIGH("Param m_bNoDisplayMode = %d", m_bNoDisplayMode); 3852 return NO_ERROR; 3853 } 3854 3855 /*=========================================================================== 3856 * FUNCTION : setZslMode 3857 * 3858 * DESCRIPTION: set ZSL mode from user setting 3859 * 3860 * PARAMETERS : 3861 * @params : user setting parameters 3862 * 3863 * RETURN : int32_t type of status 3864 * NO_ERROR -- success 3865 * none-zero failure code 3866 *==========================================================================*/ 3867 int32_t QCameraParameters::setZslMode(const QCameraParameters& params) 3868 { 3869 const char *str_val = params.get(KEY_QC_ZSL); 3870 const char *prev_val = get(KEY_QC_ZSL); 3871 int32_t rc = NO_ERROR; 3872 3873 if(m_bForceZslMode && !m_bZslMode) { 3874 // Force ZSL mode to ON 3875 set(KEY_QC_ZSL, VALUE_ON); 3876 m_bZslMode_new = true; 3877 m_bZslMode = true; 3878 m_bNeedRestart = true; 3879 int32_t value = m_bForceZslMode; 3880 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_ZSL_MODE, value)) { 3881 rc = BAD_VALUE; 3882 } 3883 } else if (str_val != NULL) { 3884 if (prev_val == NULL || strcmp(str_val, prev_val) != 0) { 3885 int32_t value = lookupAttr(ON_OFF_MODES_MAP, PARAM_MAP_SIZE(ON_OFF_MODES_MAP), 3886 str_val); 3887 if (value != NAME_NOT_FOUND) { 3888 set(KEY_QC_ZSL, str_val); 3889 m_bZslMode_new = (value > 0)? true : false; 3890 3891 // ZSL mode changed, need restart preview 3892 m_bNeedRestart = true; 3893 3894 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_ZSL_MODE, value)) { 3895 rc = BAD_VALUE; 3896 } 3897 } else { 3898 ALOGE("Invalid ZSL mode value: %s", str_val); 3899 rc = BAD_VALUE; 3900 } 3901 } 3902 } 3903 ALOGI("%s: enabled: %d", __func__, m_bZslMode_new); 3904 return rc; 3905 } 3906 3907 /*=========================================================================== 3908 * FUNCTION : setWaveletDenoise 3909 * 3910 * DESCRIPTION: set wavelet denoise value from user setting 3911 * 3912 * PARAMETERS : 3913 * @params : user setting parameters 3914 * 3915 * RETURN : int32_t type of status 3916 * NO_ERROR -- success 3917 * none-zero failure code 3918 *==========================================================================*/ 3919 int32_t QCameraParameters::setWaveletDenoise(const QCameraParameters& params) 3920 { 3921 const char *str_pf = params.getPictureFormat(); 3922 int32_t pictureFormat = lookupAttr(PICTURE_TYPES_MAP, PARAM_MAP_SIZE(PICTURE_TYPES_MAP), 3923 str_pf); 3924 if (pictureFormat != NAME_NOT_FOUND) { 3925 if (CAM_FORMAT_YUV_422_NV16 == pictureFormat) { 3926 ALOGE("NV16 format isn't supported in denoise lib!"); 3927 return setWaveletDenoise(DENOISE_OFF); 3928 } 3929 } 3930 const char *str = params.get(KEY_QC_DENOISE); 3931 const char *prev_str = get(KEY_QC_DENOISE); 3932 if (str != NULL) { 3933 if (prev_str == NULL || 3934 strcmp(str, prev_str) != 0) { 3935 return setWaveletDenoise(str); 3936 } 3937 } 3938 return NO_ERROR; 3939 } 3940 3941 /*=========================================================================== 3942 * FUNCTION : setTemporalDenoise 3943 * 3944 * DESCRIPTION: set temporal denoise value from properties 3945 * 3946 * PARAMETERS : none 3947 * 3948 * RETURN : int32_t type of status 3949 * NO_ERROR -- success 3950 * none-zero failure code 3951 *==========================================================================*/ 3952 int32_t QCameraParameters::setTemporalDenoise(const QCameraParameters& params) 3953 { 3954 if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_CPP_TNR) == 0) { 3955 CDBG_HIGH("%s: TNR is not supported",__func__); 3956 return NO_ERROR; 3957 } 3958 const char *str = params.get(KEY_QC_TNR_MODE); 3959 const char *prev_str = get(KEY_QC_TNR_MODE); 3960 const char *video_str = params.get(KEY_QC_VIDEO_TNR_MODE); 3961 const char *video_prev_str = get(KEY_QC_VIDEO_TNR_MODE); 3962 3963 if (m_bRecordingHint_new == true) { 3964 if (video_str) { 3965 if ((video_prev_str == NULL) || (strcmp(video_str, video_prev_str) != 0)) { 3966 if (!strcmp(video_str, VALUE_ON)) { 3967 m_bTNRVideoOn = true; 3968 } else { 3969 m_bTNRVideoOn = false; 3970 } 3971 updateParamEntry(KEY_QC_VIDEO_TNR_MODE, video_str); 3972 } else { 3973 return NO_ERROR; 3974 } 3975 } else { 3976 char video_value[PROPERTY_VALUE_MAX]; 3977 memset(video_value, 0, sizeof(video_value)); 3978 property_get("persist.camera.tnr.video", video_value, VALUE_OFF); 3979 if (!strcmp(video_value, VALUE_ON)) { 3980 m_bTNRVideoOn = true; 3981 } else { 3982 m_bTNRVideoOn = false; 3983 } 3984 updateParamEntry(KEY_QC_VIDEO_TNR_MODE, video_value); 3985 } 3986 cam_denoise_param_t temp; 3987 memset(&temp, 0, sizeof(temp)); 3988 if (m_bTNRVideoOn) { 3989 temp.denoise_enable = 1; 3990 temp.process_plates = getDenoiseProcessPlate(CAM_INTF_PARM_TEMPORAL_DENOISE); 3991 3992 int32_t cds_mode = lookupAttr(CDS_MODES_MAP, PARAM_MAP_SIZE(CDS_MODES_MAP), 3993 CDS_MODE_OFF); 3994 3995 if (cds_mode != NAME_NOT_FOUND) { 3996 updateParamEntry(KEY_QC_VIDEO_CDS_MODE, CDS_MODE_OFF); 3997 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_CDS_MODE, cds_mode)) { 3998 ALOGE("%s:Failed CDS MODE to update table", __func__); 3999 return BAD_VALUE; 4000 } 4001 CDBG("%s: CDS in video mode is set to = %s when TNR is enabled", 4002 __func__, CDS_MODE_OFF); 4003 mCds_mode = cds_mode; 4004 } else { 4005 ALOGE("%s: Invalid argument for video CDS MODE %d", __func__, cds_mode); 4006 } 4007 } 4008 CDBG("%s: TNR enable in video mode = %d, plates = %d", __func__, 4009 temp.denoise_enable, temp.process_plates); 4010 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_TEMPORAL_DENOISE, temp)) { 4011 return BAD_VALUE; 4012 } 4013 } else { 4014 if (str) { 4015 if ((prev_str == NULL) || (strcmp(str, prev_str) != 0)) { 4016 if (!strcmp(str, VALUE_ON)) { 4017 m_bTNRPreviewOn = true; 4018 } else { 4019 m_bTNRPreviewOn = false; 4020 } 4021 updateParamEntry(KEY_QC_TNR_MODE, str); 4022 } else { 4023 return NO_ERROR; 4024 } 4025 } else { 4026 char value[PROPERTY_VALUE_MAX]; 4027 memset(value, 0, sizeof(value)); 4028 property_get("persist.camera.tnr.preview", value, VALUE_OFF); 4029 if (!strcmp(value, VALUE_ON)) { 4030 m_bTNRPreviewOn = true; 4031 } else { 4032 m_bTNRPreviewOn = false; 4033 } 4034 updateParamEntry(KEY_QC_TNR_MODE, value); 4035 } 4036 cam_denoise_param_t temp; 4037 memset(&temp, 0, sizeof(temp)); 4038 if (m_bTNRPreviewOn) { 4039 temp.denoise_enable = 1; 4040 temp.process_plates = getDenoiseProcessPlate(CAM_INTF_PARM_TEMPORAL_DENOISE); 4041 4042 int32_t cds_mode = lookupAttr(CDS_MODES_MAP, PARAM_MAP_SIZE(CDS_MODES_MAP), 4043 CDS_MODE_OFF); 4044 4045 if (cds_mode != NAME_NOT_FOUND) { 4046 updateParamEntry(KEY_QC_CDS_MODE, CDS_MODE_OFF); 4047 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_CDS_MODE, cds_mode)) { 4048 ALOGE("%s:Failed CDS MODE to update table", __func__); 4049 return BAD_VALUE; 4050 } 4051 CDBG("%s: CDS in snapshot mode is set to = %s when TNR is enabled", 4052 __func__, CDS_MODE_OFF); 4053 mCds_mode = cds_mode; 4054 } else { 4055 ALOGE("%s: Invalid argument for snapshot CDS MODE %d", __func__, cds_mode); 4056 } 4057 } 4058 CDBG("%s: TNR enable in snapshot mode = %d, plates = %d", __func__, 4059 temp.denoise_enable, temp.process_plates); 4060 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_TEMPORAL_DENOISE, temp)) { 4061 return BAD_VALUE; 4062 } 4063 } 4064 4065 return NO_ERROR; 4066 } 4067 4068 /*=========================================================================== 4069 * FUNCTION : setCameraMode 4070 * 4071 * DESCRIPTION: set camera mode from user setting 4072 * 4073 * PARAMETERS : 4074 * @params : user setting parameters 4075 * 4076 * RETURN : int32_t type of status 4077 * NO_ERROR -- success 4078 * none-zero failure code 4079 *==========================================================================*/ 4080 int32_t QCameraParameters::setCameraMode(const QCameraParameters& params) 4081 { 4082 const char *str = params.get(KEY_QC_CAMERA_MODE); 4083 if (str != NULL) { 4084 set(KEY_QC_CAMERA_MODE, str); 4085 } else { 4086 remove(KEY_QC_CAMERA_MODE); 4087 } 4088 return NO_ERROR; 4089 } 4090 4091 /*=========================================================================== 4092 * FUNCTION : setSceneSelectionMode 4093 * 4094 * DESCRIPTION: set scene selection mode from user setting 4095 * 4096 * PARAMETERS : 4097 * @params : user setting parameters 4098 * 4099 * RETURN : int32_t type of status 4100 * NO_ERROR -- success 4101 * none-zero failure code 4102 *==========================================================================*/ 4103 int32_t QCameraParameters::setSceneSelectionMode(const QCameraParameters& params) 4104 { 4105 const char *str = params.get(KEY_QC_SCENE_SELECTION); 4106 const char *prev_str = get(KEY_QC_SCENE_SELECTION); 4107 if (NULL != str) { 4108 if ((NULL == prev_str) || (strcmp(str, prev_str) != 0)) { 4109 int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP, 4110 PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP), str); 4111 if (value != NAME_NOT_FOUND) { 4112 ALOGD("%s: Setting selection value %s", __func__, str); 4113 if (value && m_bZslMode_new) { 4114 updateParamEntry(KEY_QC_SCENE_SELECTION, str); 4115 m_bNeedRestart = true; 4116 m_bSceneSelection = true; 4117 } else if (!value) { 4118 updateParamEntry(KEY_QC_SCENE_SELECTION, str); 4119 m_bNeedRestart = true; 4120 m_bSceneSelection = false; 4121 } else { 4122 ALOGE("%s: Trying to enable scene selection in non ZSL mode!!!", 4123 __func__); 4124 return BAD_VALUE; 4125 } 4126 } else { 4127 ALOGE("%s: Trying to configure invalid scene selection value: %s", 4128 __func__, 4129 str); 4130 return BAD_VALUE; 4131 } 4132 } 4133 } 4134 4135 return NO_ERROR; 4136 } 4137 4138 /*=========================================================================== 4139 * FUNCTION : setSelectedScene 4140 * 4141 * DESCRIPTION: select specific scene 4142 * 4143 * PARAMETERS : 4144 * @scene : scene mode 4145 * 4146 * RETURN : int32_t type of status 4147 * NO_ERROR -- success 4148 * none-zero failure code 4149 *==========================================================================*/ 4150 int32_t QCameraParameters::setSelectedScene(cam_scene_mode_type scene) 4151 { 4152 Mutex::Autolock l(m_SceneSelectLock); 4153 m_SelectedScene = scene; 4154 return NO_ERROR; 4155 } 4156 4157 /*=========================================================================== 4158 * FUNCTION : getSelectedScene 4159 * 4160 * DESCRIPTION: get selected scene 4161 * 4162 * PARAMETERS : 4163 * 4164 * RETURN : currently selected scene 4165 *==========================================================================*/ 4166 cam_scene_mode_type QCameraParameters::getSelectedScene() 4167 { 4168 Mutex::Autolock l(m_SceneSelectLock); 4169 return m_SelectedScene; 4170 } 4171 4172 /*========================================================== 4173 * FUNCTION : setRdiMode 4174 * 4175 * DESCRIPTION: set Rdi mode from user setting 4176 * 4177 * PARAMETERS : 4178 * @params : user setting parameters 4179 * 4180 * RETURN : int32_t type of status 4181 * NO_ERROR -- success 4182 * none-zero failure code 4183 *===========================================================*/ 4184 int32_t QCameraParameters::setRdiMode(const QCameraParameters& params) 4185 { 4186 const char *str = params.get(KEY_QC_RDI_MODE); 4187 const char *prev_str = get(KEY_QC_RDI_MODE); 4188 char prop[PROPERTY_VALUE_MAX]; 4189 memset(prop, 0, sizeof(prop)); 4190 4191 property_get("persist.camera.rdi.mode", prop, VALUE_DISABLE); 4192 if ((str != NULL) && (prev_str == NULL || strcmp(str, prev_str) != 0)) { 4193 ALOGD("%s:%d : RDI mode set to %s", __func__, __LINE__, str); 4194 setRdiMode(str); 4195 } else if (prev_str == NULL || strcmp(prev_str, prop) != 0 ) { 4196 ALOGD("%s:%d : RDI mode set to prop: %s", __func__, __LINE__, prop); 4197 setRdiMode(prop); 4198 } 4199 return NO_ERROR; 4200 } 4201 4202 /*========================================================== 4203 * FUNCTION : setSecureMode 4204 * 4205 * DESCRIPTION: set secure mode from user setting 4206 * 4207 * PARAMETERS : 4208 * @params : user setting parameters 4209 * 4210 * RETURN : int32_t type of status 4211 * NO_ERROR -- success 4212 * none-zero failure code 4213 *===========================================================*/ 4214 4215 int32_t QCameraParameters::setSecureMode(const QCameraParameters& params) 4216 { 4217 const char *str = params.get(KEY_QC_SECURE_MODE); 4218 const char *prev_str = get(KEY_QC_SECURE_MODE); 4219 char prop[PROPERTY_VALUE_MAX]; 4220 memset(prop, 0, sizeof(prop)); 4221 4222 property_get("persist.camera.secure.mode", prop, VALUE_DISABLE); 4223 if ((str != NULL) && (prev_str == NULL || strcmp(str, prev_str) != 0)) { 4224 ALOGD("%s : Secure mode set to KEY: %s", __func__, str); 4225 setSecureMode(str); 4226 } else if (prev_str == NULL || strcmp(prev_str, prop) != 0 ) { 4227 ALOGD("%s : Secure mode set to prop: %s", __func__, prop); 4228 setSecureMode(prop); 4229 } 4230 return NO_ERROR; 4231 } 4232 4233 /*=========================================================================== 4234 * FUNCTION : setZslAttributes 4235 * 4236 * DESCRIPTION: set ZSL related attributes from user setting 4237 * 4238 * PARAMETERS : 4239 * @params : user setting parameters 4240 * 4241 * RETURN : int32_t type of status 4242 * NO_ERROR -- success 4243 * none-zero failure code 4244 *==========================================================================*/ 4245 int32_t QCameraParameters::setZslAttributes(const QCameraParameters& params) 4246 { 4247 // TODO: may switch to pure param instead of sysprop 4248 char prop[PROPERTY_VALUE_MAX]; 4249 4250 const char *str = params.get(KEY_QC_ZSL_BURST_INTERVAL); 4251 if (str != NULL) { 4252 set(KEY_QC_ZSL_BURST_INTERVAL, str); 4253 } else { 4254 memset(prop, 0, sizeof(prop)); 4255 property_get("persist.camera.zsl.interval", prop, "1"); 4256 set(KEY_QC_ZSL_BURST_INTERVAL, prop); 4257 CDBG_HIGH("%s: [ZSL Retro] burst interval: %s", __func__, prop); 4258 } 4259 4260 str = params.get(KEY_QC_ZSL_BURST_LOOKBACK); 4261 if (str != NULL) { 4262 set(KEY_QC_ZSL_BURST_LOOKBACK, str); 4263 } else { 4264 memset(prop, 0, sizeof(prop)); 4265 property_get("persist.camera.zsl.backlookcnt", prop, "2"); 4266 set(KEY_QC_ZSL_BURST_LOOKBACK, prop); 4267 CDBG_HIGH("%s: [ZSL Retro] look back count: %s", __func__, prop); 4268 } 4269 4270 str = params.get(KEY_QC_ZSL_QUEUE_DEPTH); 4271 if (str != NULL) { 4272 set(KEY_QC_ZSL_QUEUE_DEPTH, str); 4273 } else { 4274 memset(prop, 0, sizeof(prop)); 4275 property_get("persist.camera.zsl.queuedepth", prop, "2"); 4276 set(KEY_QC_ZSL_QUEUE_DEPTH, prop); 4277 CDBG_HIGH("%s: [ZSL Retro] queue depth: %s", __func__, prop); 4278 } 4279 4280 return NO_ERROR; 4281 } 4282 4283 /*=========================================================================== 4284 * FUNCTION : setFlip 4285 * 4286 * DESCRIPTION: set preview/ video/ picture flip mode from user setting 4287 * 4288 * PARAMETERS : 4289 * @params : user setting parameters 4290 * 4291 * RETURN : int32_t type of status 4292 * NO_ERROR -- success 4293 * none-zero failure code 4294 *==========================================================================*/ 4295 int32_t QCameraParameters::setFlip(const QCameraParameters& params) 4296 { 4297 if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_FLIP) == 0) { 4298 CDBG_HIGH("%s: flip is not supported.", __func__); 4299 return NO_ERROR; 4300 } 4301 4302 //check preview flip setting 4303 const char *str = params.get(KEY_QC_PREVIEW_FLIP); 4304 const char *prev_val = get(KEY_QC_PREVIEW_FLIP); 4305 if(str != NULL){ 4306 if (prev_val == NULL || strcmp(str, prev_val) != 0) { 4307 int32_t value = lookupAttr(FLIP_MODES_MAP, PARAM_MAP_SIZE(FLIP_MODES_MAP), str); 4308 if(value != NAME_NOT_FOUND){ 4309 set(KEY_QC_PREVIEW_FLIP, str); 4310 m_bPreviewFlipChanged = true; 4311 } 4312 } 4313 } 4314 4315 // check video filp setting 4316 str = params.get(KEY_QC_VIDEO_FLIP); 4317 prev_val = get(KEY_QC_VIDEO_FLIP); 4318 if(str != NULL){ 4319 if (prev_val == NULL || strcmp(str, prev_val) != 0) { 4320 int32_t value = lookupAttr(FLIP_MODES_MAP, PARAM_MAP_SIZE(FLIP_MODES_MAP), str); 4321 if(value != NAME_NOT_FOUND){ 4322 set(KEY_QC_VIDEO_FLIP, str); 4323 m_bVideoFlipChanged = true; 4324 } 4325 } 4326 } 4327 4328 // check picture filp setting 4329 str = params.get(KEY_QC_SNAPSHOT_PICTURE_FLIP); 4330 prev_val = get(KEY_QC_SNAPSHOT_PICTURE_FLIP); 4331 if(str != NULL){ 4332 if (prev_val == NULL || strcmp(str, prev_val) != 0) { 4333 int32_t value = lookupAttr(FLIP_MODES_MAP, PARAM_MAP_SIZE(FLIP_MODES_MAP), str); 4334 if(value != NAME_NOT_FOUND){ 4335 set(KEY_QC_SNAPSHOT_PICTURE_FLIP, str); 4336 m_bSnapshotFlipChanged = true; 4337 } 4338 } 4339 } 4340 4341 return NO_ERROR; 4342 } 4343 4344 /*=========================================================================== 4345 * FUNCTION : setBurstNum 4346 * 4347 * DESCRIPTION: set burst number of snapshot 4348 * 4349 * PARAMETERS : 4350 * @params : user setting parameters 4351 * 4352 * RETURN : int32_t type of status 4353 * NO_ERROR -- success 4354 * none-zero failure code 4355 *==========================================================================*/ 4356 int32_t QCameraParameters::setBurstNum(const QCameraParameters& params) 4357 { 4358 int nBurstNum = params.getInt(KEY_QC_SNAPSHOT_BURST_NUM); 4359 if (isAdvCamFeaturesEnabled()) { 4360 nBurstNum = 1; 4361 } 4362 if (nBurstNum <= 0) { 4363 // if burst number is not set in parameters, 4364 // read from sys prop 4365 char prop[PROPERTY_VALUE_MAX]; 4366 memset(prop, 0, sizeof(prop)); 4367 property_get("persist.camera.snapshot.number", prop, "0"); 4368 nBurstNum = atoi(prop); 4369 if (nBurstNum <= 0) { 4370 nBurstNum = 1; 4371 } 4372 } 4373 set(KEY_QC_SNAPSHOT_BURST_NUM, nBurstNum); 4374 m_nBurstNum = (uint8_t)nBurstNum; 4375 CDBG_HIGH("%s: [ZSL Retro] m_nBurstNum = %d", __func__, m_nBurstNum); 4376 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_BURST_NUM, (uint32_t)nBurstNum)) { 4377 return BAD_VALUE; 4378 } 4379 4380 return NO_ERROR; 4381 } 4382 4383 /*=========================================================================== 4384 * FUNCTION : setSnapshotFDReq 4385 * 4386 * DESCRIPTION: set requirement of Face Detection Metadata in Snapshot mode. 4387 * 4388 * PARAMETERS : 4389 * @params : user setting parameters 4390 * 4391 * RETURN : int32_t type of status 4392 * NO_ERROR -- success 4393 * none-zero failure code 4394 *==========================================================================*/ 4395 int32_t QCameraParameters::setSnapshotFDReq(const QCameraParameters& params) 4396 { 4397 char prop[PROPERTY_VALUE_MAX]; 4398 const char *str = params.get(KEY_QC_SNAPSHOT_FD_DATA); 4399 4400 if(str != NULL){ 4401 set(KEY_QC_SNAPSHOT_FD_DATA, str); 4402 }else{ 4403 memset(prop, 0, sizeof(prop)); 4404 property_get("persist.camera.snapshot.fd", prop, "0"); 4405 set(KEY_QC_SNAPSHOT_FD_DATA, prop); 4406 } 4407 return NO_ERROR; 4408 } 4409 4410 /*=========================================================================== 4411 * FUNCTION : setMobicat 4412 * 4413 * DESCRIPTION: set Mobicat on/off. 4414 * 4415 * PARAMETERS : 4416 * @params : user setting parameters 4417 * 4418 * RETURN : int32_t type of status 4419 * NO_ERROR -- success 4420 * none-zero failure code 4421 *==========================================================================*/ 4422 int32_t QCameraParameters::setMobicat(const QCameraParameters& ) 4423 { 4424 char value [PROPERTY_VALUE_MAX]; 4425 property_get("persist.camera.mobicat", value, "0"); 4426 int32_t ret = NO_ERROR; 4427 uint8_t enableMobi = (uint8_t)atoi(value); 4428 4429 if (enableMobi) { 4430 tune_cmd_t tune_cmd; 4431 tune_cmd.type = 2; 4432 tune_cmd.module = 0; 4433 tune_cmd.value = 1; 4434 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_SET_VFE_COMMAND, tune_cmd)) { 4435 return BAD_VALUE; 4436 } 4437 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_SET_PP_COMMAND, tune_cmd)) { 4438 ret = BAD_VALUE; 4439 } 4440 } 4441 m_MobiMask = enableMobi; 4442 4443 return ret; 4444 } 4445 4446 /*=========================================================================== 4447 * FUNCTION : updateParameters 4448 * 4449 * DESCRIPTION: update parameters from user setting 4450 * 4451 * PARAMETERS : 4452 * @params : user setting parameters 4453 * @needRestart : [output] if preview need restart upon setting changes 4454 * 4455 * RETURN : int32_t type of status 4456 * NO_ERROR -- success 4457 * none-zero failure code 4458 *==========================================================================*/ 4459 int32_t QCameraParameters::updateParameters(QCameraParameters& params, 4460 bool &needRestart) 4461 { 4462 int32_t final_rc = NO_ERROR; 4463 int32_t rc; 4464 m_bNeedRestart = false; 4465 4466 if(initBatchUpdate(m_pParamBuf) < 0 ) { 4467 ALOGE("%s:Failed to initialize group update table",__func__); 4468 rc = BAD_TYPE; 4469 goto UPDATE_PARAM_DONE; 4470 } 4471 4472 if ((rc = setPreviewSize(params))) final_rc = rc; 4473 if ((rc = setVideoSize(params))) final_rc = rc; 4474 if ((rc = setPictureSize(params))) final_rc = rc; 4475 if ((rc = setPreviewFormat(params))) final_rc = rc; 4476 if ((rc = setPictureFormat(params))) final_rc = rc; 4477 if ((rc = setJpegQuality(params))) final_rc = rc; 4478 if ((rc = setOrientation(params))) final_rc = rc; 4479 if ((rc = setRotation(params))) final_rc = rc; 4480 if ((rc = setVideoRotation(params))) final_rc = rc; 4481 if ((rc = setNoDisplayMode(params))) final_rc = rc; 4482 if ((rc = setZslMode(params))) final_rc = rc; 4483 if ((rc = setZslAttributes(params))) final_rc = rc; 4484 if ((rc = setCameraMode(params))) final_rc = rc; 4485 if ((rc = setSceneSelectionMode(params))) final_rc = rc; 4486 if ((rc = setRecordingHint(params))) final_rc = rc; 4487 if ((rc = setRdiMode(params))) final_rc = rc; 4488 if ((rc = setSecureMode(params))) final_rc = rc; 4489 if ((rc = setPreviewFrameRate(params))) final_rc = rc; 4490 if ((rc = setPreviewFpsRange(params))) final_rc = rc; 4491 if ((rc = setAutoExposure(params))) final_rc = rc; 4492 if ((rc = setEffect(params))) final_rc = rc; 4493 if ((rc = setBrightness(params))) final_rc = rc; 4494 if ((rc = setZoom(params))) final_rc = rc; 4495 if ((rc = setSharpness(params))) final_rc = rc; 4496 if ((rc = setSaturation(params))) final_rc = rc; 4497 if ((rc = setContrast(params))) final_rc = rc; 4498 if ((rc = setFocusMode(params))) final_rc = rc; 4499 if ((rc = setISOValue(params))) final_rc = rc; 4500 if ((rc = setContinuousISO(params))) final_rc = rc; 4501 if ((rc = setExposureTime(params))) final_rc = rc; 4502 if ((rc = setSkinToneEnhancement(params))) final_rc = rc; 4503 if ((rc = setFlash(params))) final_rc = rc; 4504 if ((rc = setAecLock(params))) final_rc = rc; 4505 if ((rc = setAwbLock(params))) final_rc = rc; 4506 if ((rc = setLensShadeValue(params))) final_rc = rc; 4507 if ((rc = setMCEValue(params))) final_rc = rc; 4508 if ((rc = setDISValue(params))) final_rc = rc; 4509 if ((rc = setAntibanding(params))) final_rc = rc; 4510 if ((rc = setExposureCompensation(params))) final_rc = rc; 4511 if ((rc = setWhiteBalance(params))) final_rc = rc; 4512 if ((rc = setHDRMode(params))) final_rc = rc; 4513 if ((rc = setHDRNeed1x(params))) final_rc = rc; 4514 if ((rc = setManualWhiteBalance(params))) final_rc = rc; 4515 if ((rc = setSceneMode(params))) final_rc = rc; 4516 if ((rc = setFocusAreas(params))) final_rc = rc; 4517 if ((rc = setFocusPosition(params))) final_rc = rc; 4518 if ((rc = setMeteringAreas(params))) final_rc = rc; 4519 if ((rc = setSelectableZoneAf(params))) final_rc = rc; 4520 if ((rc = setRedeyeReduction(params))) final_rc = rc; 4521 if ((rc = setAEBracket(params))) final_rc = rc; 4522 if ((rc = setAutoHDR(params))) final_rc = rc; 4523 if ((rc = setGpsLocation(params))) final_rc = rc; 4524 if ((rc = setWaveletDenoise(params))) final_rc = rc; 4525 if ((rc = setFaceRecognition(params))) final_rc = rc; 4526 if ((rc = setFlip(params))) final_rc = rc; 4527 if ((rc = setVideoHDR(params))) final_rc = rc; 4528 if ((rc = setVtEnable(params))) final_rc = rc; 4529 if ((rc = setAFBracket(params))) final_rc = rc; 4530 if ((rc = setReFocus(params))) final_rc = rc; 4531 if ((rc = setChromaFlash(params))) final_rc = rc; 4532 if ((rc = setTruePortrait(params))) final_rc = rc; 4533 if ((rc = setOptiZoom(params))) final_rc = rc; 4534 if ((rc = setBurstNum(params))) final_rc = rc; 4535 if ((rc = setBurstLEDOnPeriod(params))) final_rc = rc; 4536 if ((rc = setRetroActiveBurstNum(params))) final_rc = rc; 4537 if ((rc = setSnapshotFDReq(params))) final_rc = rc; 4538 if ((rc = setTintlessValue(params))) final_rc = rc; 4539 if ((rc = setCDSMode(params))) final_rc = rc; 4540 if ((rc = setTemporalDenoise(params))) final_rc = rc; 4541 4542 // update live snapshot size after all other parameters are set 4543 if ((rc = setLiveSnapshotSize(params))) final_rc = rc; 4544 if ((rc = setJpegThumbnailSize(params))) final_rc = rc; 4545 if ((rc = setStatsDebugMask())) final_rc = rc; 4546 if ((rc = setPAAF())) final_rc = rc; 4547 if ((rc = setMobicat(params))) final_rc = rc; 4548 if ((rc = setSeeMore(params))) final_rc = rc; 4549 if ((rc = setStillMore(params))) final_rc = rc; 4550 4551 if ((rc = updateFlash(false))) final_rc = rc; 4552 4553 UPDATE_PARAM_DONE: 4554 needRestart = m_bNeedRestart; 4555 return final_rc; 4556 } 4557 4558 /*=========================================================================== 4559 * FUNCTION : commitParameters 4560 * 4561 * DESCRIPTION: commit parameter changes to backend 4562 * 4563 * PARAMETERS : none 4564 * 4565 * RETURN : int32_t type of status 4566 * NO_ERROR -- success 4567 * none-zero failure code 4568 *==========================================================================*/ 4569 int32_t QCameraParameters::commitParameters() 4570 { 4571 return commitSetBatch(); 4572 } 4573 4574 /*=========================================================================== 4575 * FUNCTION : initDefaultParameters 4576 * 4577 * DESCRIPTION: initialize default parameters for the first time 4578 * 4579 * PARAMETERS : none 4580 * 4581 * RETURN : int32_t type of status 4582 * NO_ERROR -- success 4583 * none-zero failure code 4584 *==========================================================================*/ 4585 int32_t QCameraParameters::initDefaultParameters() 4586 { 4587 if(initBatchUpdate(m_pParamBuf) < 0 ) { 4588 ALOGE("%s:Failed to initialize group update table", __func__); 4589 return BAD_TYPE; 4590 } 4591 int32_t hal_version = CAM_HAL_V1; 4592 ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_HAL_VERSION, hal_version); 4593 4594 /*************************Initialize Values******************************/ 4595 // Set read only parameters from camera capability 4596 set(KEY_SMOOTH_ZOOM_SUPPORTED, 4597 m_pCapability->smooth_zoom_supported? VALUE_TRUE : VALUE_FALSE); 4598 set(KEY_ZOOM_SUPPORTED, 4599 m_pCapability->zoom_supported? VALUE_TRUE : VALUE_FALSE); 4600 set(KEY_VIDEO_SNAPSHOT_SUPPORTED, 4601 m_pCapability->video_snapshot_supported? VALUE_TRUE : VALUE_FALSE); 4602 set(KEY_VIDEO_STABILIZATION_SUPPORTED, 4603 m_pCapability->video_stablization_supported? VALUE_TRUE : VALUE_FALSE); 4604 set(KEY_AUTO_EXPOSURE_LOCK_SUPPORTED, 4605 m_pCapability->auto_exposure_lock_supported? VALUE_TRUE : VALUE_FALSE); 4606 set(KEY_AUTO_WHITEBALANCE_LOCK_SUPPORTED, 4607 m_pCapability->auto_wb_lock_supported? VALUE_TRUE : VALUE_FALSE); 4608 set(KEY_QC_SUPPORTED_CAMERA_FEATURES, 4609 (int)m_pCapability->qcom_supported_feature_mask); 4610 set(KEY_MAX_NUM_DETECTED_FACES_HW, m_pCapability->max_num_roi); 4611 set(KEY_MAX_NUM_DETECTED_FACES_SW, m_pCapability->max_num_roi); 4612 set(KEY_QC_MAX_NUM_REQUESTED_FACES, m_pCapability->max_num_roi); 4613 // Set focal length, horizontal view angle, and vertical view angle 4614 setFloat(KEY_FOCAL_LENGTH, m_pCapability->focal_length); 4615 setFloat(KEY_HORIZONTAL_VIEW_ANGLE, m_pCapability->hor_view_angle); 4616 setFloat(KEY_VERTICAL_VIEW_ANGLE, m_pCapability->ver_view_angle); 4617 set(QCameraParameters::KEY_FOCUS_DISTANCES, "Infinity,Infinity,Infinity"); 4618 set(KEY_QC_AUTO_HDR_SUPPORTED, 4619 (m_pCapability->auto_hdr_supported)? VALUE_TRUE : VALUE_FALSE); 4620 // Set supported preview sizes 4621 if (m_pCapability->preview_sizes_tbl_cnt > 0 && 4622 m_pCapability->preview_sizes_tbl_cnt <= MAX_SIZES_CNT) { 4623 String8 previewSizeValues = createSizesString( 4624 m_pCapability->preview_sizes_tbl, m_pCapability->preview_sizes_tbl_cnt); 4625 set(KEY_SUPPORTED_PREVIEW_SIZES, previewSizeValues.string()); 4626 CDBG_HIGH("%s: supported preview sizes: %s", __func__, previewSizeValues.string()); 4627 // Set default preview size 4628 CameraParameters::setPreviewSize(m_pCapability->preview_sizes_tbl[0].width, 4629 m_pCapability->preview_sizes_tbl[0].height); 4630 } else { 4631 ALOGE("%s: supported preview sizes cnt is 0 or exceeds max!!!", __func__); 4632 } 4633 4634 // Set supported video sizes 4635 if (m_pCapability->video_sizes_tbl_cnt > 0 && 4636 m_pCapability->video_sizes_tbl_cnt <= MAX_SIZES_CNT) { 4637 String8 videoSizeValues = createSizesString( 4638 m_pCapability->video_sizes_tbl, m_pCapability->video_sizes_tbl_cnt); 4639 set(KEY_SUPPORTED_VIDEO_SIZES, videoSizeValues.string()); 4640 CDBG_HIGH("%s: supported video sizes: %s", __func__, videoSizeValues.string()); 4641 // Set default video size 4642 CameraParameters::setVideoSize(m_pCapability->video_sizes_tbl[0].width, 4643 m_pCapability->video_sizes_tbl[0].height); 4644 4645 //Set preferred Preview size for video 4646 String8 vSize = createSizesString(&m_pCapability->preview_sizes_tbl[0], 1); 4647 set(KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO, vSize.string()); 4648 } else { 4649 ALOGE("%s: supported video sizes cnt is 0 or exceeds max!!!", __func__); 4650 } 4651 4652 // Set supported picture sizes 4653 if (m_pCapability->picture_sizes_tbl_cnt > 0 && 4654 m_pCapability->picture_sizes_tbl_cnt <= MAX_SIZES_CNT) { 4655 String8 pictureSizeValues = createSizesString( 4656 m_pCapability->picture_sizes_tbl, m_pCapability->picture_sizes_tbl_cnt); 4657 set(KEY_SUPPORTED_PICTURE_SIZES, pictureSizeValues.string()); 4658 CDBG_HIGH("%s: supported pic sizes: %s", __func__, pictureSizeValues.string()); 4659 // Set default picture size to the smallest resolution 4660 CameraParameters::setPictureSize( 4661 m_pCapability->picture_sizes_tbl[m_pCapability->picture_sizes_tbl_cnt-1].width, 4662 m_pCapability->picture_sizes_tbl[m_pCapability->picture_sizes_tbl_cnt-1].height); 4663 } else { 4664 ALOGE("%s: supported picture sizes cnt is 0 or exceeds max!!!", __func__); 4665 } 4666 4667 // Need check if scale should be enabled 4668 if (m_pCapability->scale_picture_sizes_cnt > 0 && 4669 m_pCapability->scale_picture_sizes_cnt <= MAX_SCALE_SIZES_CNT){ 4670 //get scale size, enable scaling. And re-set picture size table with scale sizes 4671 m_reprocScaleParam.setScaleEnable(true); 4672 int rc_s = m_reprocScaleParam.setScaleSizeTbl( 4673 m_pCapability->scale_picture_sizes_cnt, m_pCapability->scale_picture_sizes, 4674 m_pCapability->picture_sizes_tbl_cnt, m_pCapability->picture_sizes_tbl); 4675 if(rc_s == NO_ERROR){ 4676 cam_dimension_t *totalSizeTbl = m_reprocScaleParam.getTotalSizeTbl(); 4677 size_t totalSizeCnt = m_reprocScaleParam.getTotalSizeTblCnt(); 4678 String8 pictureSizeValues = createSizesString(totalSizeTbl, totalSizeCnt); 4679 set(KEY_SUPPORTED_PICTURE_SIZES, pictureSizeValues.string()); 4680 CDBG_HIGH("%s: scaled supported pic sizes: %s", __func__, pictureSizeValues.string()); 4681 }else{ 4682 m_reprocScaleParam.setScaleEnable(false); 4683 ALOGE("%s: reset scaled picture size table failed.", __func__); 4684 } 4685 }else{ 4686 m_reprocScaleParam.setScaleEnable(false); 4687 } 4688 4689 // Set supported thumbnail sizes 4690 String8 thumbnailSizeValues = createSizesString( 4691 THUMBNAIL_SIZES_MAP, 4692 PARAM_MAP_SIZE(THUMBNAIL_SIZES_MAP)); 4693 set(KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES, thumbnailSizeValues.string()); 4694 // Set default thumnail size 4695 set(KEY_JPEG_THUMBNAIL_WIDTH, THUMBNAIL_SIZES_MAP[0].width); 4696 set(KEY_JPEG_THUMBNAIL_HEIGHT, THUMBNAIL_SIZES_MAP[0].height); 4697 4698 // Set supported livesnapshot sizes 4699 if (m_pCapability->livesnapshot_sizes_tbl_cnt > 0 && 4700 m_pCapability->livesnapshot_sizes_tbl_cnt <= MAX_SIZES_CNT) { 4701 String8 liveSnpashotSizeValues = createSizesString( 4702 m_pCapability->livesnapshot_sizes_tbl, 4703 m_pCapability->livesnapshot_sizes_tbl_cnt); 4704 set(KEY_QC_SUPPORTED_LIVESNAPSHOT_SIZES, liveSnpashotSizeValues.string()); 4705 CDBG("%s: supported live snapshot sizes: %s", __func__, liveSnpashotSizeValues.string()); 4706 m_LiveSnapshotSize = 4707 m_pCapability->livesnapshot_sizes_tbl[m_pCapability->livesnapshot_sizes_tbl_cnt-1]; 4708 } 4709 4710 // Set supported preview formats 4711 String8 previewFormatValues = createValuesString( 4712 m_pCapability->supported_preview_fmts, 4713 m_pCapability->supported_preview_fmt_cnt, 4714 PREVIEW_FORMATS_MAP, 4715 PARAM_MAP_SIZE(PREVIEW_FORMATS_MAP)); 4716 set(KEY_SUPPORTED_PREVIEW_FORMATS, previewFormatValues.string()); 4717 // Set default preview format 4718 CameraParameters::setPreviewFormat(PIXEL_FORMAT_YUV420SP); 4719 4720 // Set default Video Format 4721 set(KEY_VIDEO_FRAME_FORMAT, PIXEL_FORMAT_YUV420SP); 4722 4723 // Set supported picture formats 4724 String8 pictureTypeValues(PIXEL_FORMAT_JPEG); 4725 String8 str = createValuesString( 4726 m_pCapability->supported_raw_fmts, 4727 m_pCapability->supported_raw_fmt_cnt, 4728 PICTURE_TYPES_MAP, 4729 PARAM_MAP_SIZE(PICTURE_TYPES_MAP)); 4730 if (str.string() != NULL) { 4731 pictureTypeValues.append(","); 4732 pictureTypeValues.append(str); 4733 } 4734 4735 set(KEY_SUPPORTED_PICTURE_FORMATS, pictureTypeValues.string()); 4736 // Set default picture Format 4737 CameraParameters::setPictureFormat(PIXEL_FORMAT_JPEG); 4738 // Set raw image size 4739 char raw_size_str[32]; 4740 snprintf(raw_size_str, sizeof(raw_size_str), "%dx%d", 4741 m_pCapability->raw_dim[0].width, m_pCapability->raw_dim[0].height); 4742 set(KEY_QC_RAW_PICUTRE_SIZE, raw_size_str); 4743 CDBG("%s: KEY_QC_RAW_PICUTRE_SIZE: w: %d, h: %d ", __func__, 4744 m_pCapability->raw_dim[0].width, m_pCapability->raw_dim[0].height); 4745 4746 //set default jpeg quality and thumbnail quality 4747 set(KEY_JPEG_QUALITY, 85); 4748 set(KEY_JPEG_THUMBNAIL_QUALITY, 85); 4749 4750 // Set FPS ranges 4751 if (m_pCapability->fps_ranges_tbl_cnt > 0 && 4752 m_pCapability->fps_ranges_tbl_cnt <= MAX_SIZES_CNT) { 4753 int default_fps_index = 0; 4754 String8 fpsRangeValues = createFpsRangeString(m_pCapability->fps_ranges_tbl, 4755 m_pCapability->fps_ranges_tbl_cnt, 4756 default_fps_index); 4757 set(KEY_SUPPORTED_PREVIEW_FPS_RANGE, fpsRangeValues.string()); 4758 4759 int min_fps = 4760 int(m_pCapability->fps_ranges_tbl[default_fps_index].min_fps * 1000); 4761 int max_fps = 4762 int(m_pCapability->fps_ranges_tbl[default_fps_index].max_fps * 1000); 4763 m_default_fps_range = m_pCapability->fps_ranges_tbl[default_fps_index]; 4764 //Set video fps same as preview fps 4765 setPreviewFpsRange(min_fps, max_fps, min_fps, max_fps); 4766 4767 // Set legacy preview fps 4768 String8 fpsValues = createFpsString(m_pCapability->fps_ranges_tbl[default_fps_index]); 4769 set(KEY_SUPPORTED_PREVIEW_FRAME_RATES, fpsValues.string()); 4770 CDBG_HIGH("%s: supported fps rates: %s", __func__, fpsValues.string()); 4771 CameraParameters::setPreviewFrameRate(int(m_pCapability->fps_ranges_tbl[default_fps_index].max_fps)); 4772 } else { 4773 ALOGE("%s: supported fps ranges cnt is 0 or exceeds max!!!", __func__); 4774 } 4775 4776 // Set supported focus modes 4777 if (m_pCapability->supported_focus_modes_cnt > 0) { 4778 String8 focusModeValues = createValuesString( 4779 m_pCapability->supported_focus_modes, 4780 m_pCapability->supported_focus_modes_cnt, 4781 FOCUS_MODES_MAP, 4782 PARAM_MAP_SIZE(FOCUS_MODES_MAP)); 4783 set(KEY_SUPPORTED_FOCUS_MODES, focusModeValues); 4784 4785 // Set default focus mode and update corresponding parameter buf 4786 const char *focusMode = lookupNameByValue(FOCUS_MODES_MAP, 4787 PARAM_MAP_SIZE(FOCUS_MODES_MAP), 4788 m_pCapability->supported_focus_modes[0]); 4789 if (focusMode != NULL) { 4790 setFocusMode(focusMode); 4791 } else { 4792 setFocusMode(FOCUS_MODE_FIXED); 4793 } 4794 } else { 4795 ALOGE("%s: supported focus modes cnt is 0!!!", __func__); 4796 } 4797 4798 // Set focus areas 4799 if (m_pCapability->max_num_focus_areas > MAX_ROI) { 4800 m_pCapability->max_num_focus_areas = MAX_ROI; 4801 } 4802 set(KEY_MAX_NUM_FOCUS_AREAS, m_pCapability->max_num_focus_areas); 4803 if (m_pCapability->max_num_focus_areas > 0) { 4804 setFocusAreas(DEFAULT_CAMERA_AREA); 4805 } 4806 4807 // Set metering areas 4808 if (m_pCapability->max_num_metering_areas > MAX_ROI) { 4809 m_pCapability->max_num_metering_areas = MAX_ROI; 4810 } 4811 set(KEY_MAX_NUM_METERING_AREAS, m_pCapability->max_num_metering_areas); 4812 if (m_pCapability->max_num_metering_areas > 0) { 4813 setMeteringAreas(DEFAULT_CAMERA_AREA); 4814 } 4815 4816 // set focus position, we should get them from m_pCapability 4817 m_pCapability->min_focus_pos[CAM_MANUAL_FOCUS_MODE_INDEX] = 0; 4818 m_pCapability->max_focus_pos[CAM_MANUAL_FOCUS_MODE_INDEX] = 1023; 4819 set(KEY_QC_MIN_FOCUS_POS_INDEX, 4820 (int) m_pCapability->min_focus_pos[CAM_MANUAL_FOCUS_MODE_INDEX]); 4821 set(KEY_QC_MAX_FOCUS_POS_INDEX, 4822 (int) m_pCapability->max_focus_pos[CAM_MANUAL_FOCUS_MODE_INDEX]); 4823 4824 m_pCapability->min_focus_pos[CAM_MANUAL_FOCUS_MODE_DAC_CODE] = 0; 4825 m_pCapability->max_focus_pos[CAM_MANUAL_FOCUS_MODE_DAC_CODE] = 1023; 4826 set(KEY_QC_MIN_FOCUS_POS_DAC, 4827 (int) m_pCapability->min_focus_pos[CAM_MANUAL_FOCUS_MODE_DAC_CODE]); 4828 set(KEY_QC_MAX_FOCUS_POS_DAC, 4829 (int) m_pCapability->max_focus_pos[CAM_MANUAL_FOCUS_MODE_DAC_CODE]); 4830 4831 m_pCapability->min_focus_pos[CAM_MANUAL_FOCUS_MODE_RATIO] = 0; 4832 m_pCapability->max_focus_pos[CAM_MANUAL_FOCUS_MODE_RATIO] = 100; 4833 set(KEY_QC_MIN_FOCUS_POS_RATIO, 4834 (int) m_pCapability->min_focus_pos[CAM_MANUAL_FOCUS_MODE_RATIO]); 4835 set(KEY_QC_MAX_FOCUS_POS_RATIO, 4836 (int) m_pCapability->max_focus_pos[CAM_MANUAL_FOCUS_MODE_RATIO]); 4837 4838 m_pCapability->min_focus_pos[CAM_MANUAL_FOCUS_MODE_DIOPTER] = 0; 4839 if (m_pCapability->min_focus_distance > 0) { 4840 m_pCapability->max_focus_pos[CAM_MANUAL_FOCUS_MODE_DIOPTER] = 4841 100.0f / m_pCapability->min_focus_distance; 4842 } else { 4843 m_pCapability->max_focus_pos[CAM_MANUAL_FOCUS_MODE_DIOPTER] = 0; 4844 } 4845 setFloat(KEY_QC_MIN_FOCUS_POS_DIOPTER, 4846 m_pCapability->min_focus_pos[CAM_MANUAL_FOCUS_MODE_DIOPTER]); 4847 setFloat(KEY_QC_MAX_FOCUS_POS_DIOPTER, 4848 m_pCapability->max_focus_pos[CAM_MANUAL_FOCUS_MODE_DIOPTER]); 4849 4850 //set supported manual focus modes 4851 String8 manualFocusModes(VALUE_OFF); 4852 if (m_pCapability->supported_focus_modes_cnt > 1 && 4853 m_pCapability->min_focus_distance > 0) { 4854 manualFocusModes.append(","); 4855 manualFocusModes.append(KEY_QC_FOCUS_SCALE_MODE); 4856 manualFocusModes.append(","); 4857 manualFocusModes.append(KEY_QC_FOCUS_DIOPTER_MODE); 4858 } 4859 set(KEY_QC_SUPPORTED_MANUAL_FOCUS_MODES, manualFocusModes.string()); 4860 4861 // Set Saturation 4862 set(KEY_QC_MIN_SATURATION, m_pCapability->saturation_ctrl.min_value); 4863 set(KEY_QC_MAX_SATURATION, m_pCapability->saturation_ctrl.max_value); 4864 set(KEY_QC_SATURATION_STEP, m_pCapability->saturation_ctrl.step); 4865 setSaturation(m_pCapability->saturation_ctrl.def_value); 4866 4867 // Set Sharpness 4868 set(KEY_QC_MIN_SHARPNESS, m_pCapability->sharpness_ctrl.min_value); 4869 set(KEY_QC_MAX_SHARPNESS, m_pCapability->sharpness_ctrl.max_value); 4870 set(KEY_QC_SHARPNESS_STEP, m_pCapability->sharpness_ctrl.step); 4871 setSharpness(m_pCapability->sharpness_ctrl.def_value); 4872 4873 // Set Contrast 4874 set(KEY_QC_MIN_CONTRAST, m_pCapability->contrast_ctrl.min_value); 4875 set(KEY_QC_MAX_CONTRAST, m_pCapability->contrast_ctrl.max_value); 4876 set(KEY_QC_CONTRAST_STEP, m_pCapability->contrast_ctrl.step); 4877 setContrast(m_pCapability->contrast_ctrl.def_value); 4878 4879 // Set SCE factor 4880 set(KEY_QC_MIN_SCE_FACTOR, m_pCapability->sce_ctrl.min_value); // -100 4881 set(KEY_QC_MAX_SCE_FACTOR, m_pCapability->sce_ctrl.max_value); // 100 4882 set(KEY_QC_SCE_FACTOR_STEP, m_pCapability->sce_ctrl.step); // 10 4883 setSkinToneEnhancement(m_pCapability->sce_ctrl.def_value); // 0 4884 4885 // Set Brightness 4886 set(KEY_QC_MIN_BRIGHTNESS, m_pCapability->brightness_ctrl.min_value); // 0 4887 set(KEY_QC_MAX_BRIGHTNESS, m_pCapability->brightness_ctrl.max_value); // 6 4888 set(KEY_QC_BRIGHTNESS_STEP, m_pCapability->brightness_ctrl.step); // 1 4889 setBrightness(m_pCapability->brightness_ctrl.def_value); 4890 4891 // Set Auto exposure 4892 String8 autoExposureValues = createValuesString( 4893 m_pCapability->supported_aec_modes, 4894 m_pCapability->supported_aec_modes_cnt, 4895 AUTO_EXPOSURE_MAP, 4896 PARAM_MAP_SIZE(AUTO_EXPOSURE_MAP)); 4897 set(KEY_QC_SUPPORTED_AUTO_EXPOSURE, autoExposureValues.string()); 4898 setAutoExposure(AUTO_EXPOSURE_FRAME_AVG); 4899 4900 // Set Exposure Compensation 4901 set(KEY_MAX_EXPOSURE_COMPENSATION, m_pCapability->exposure_compensation_max); // 12 4902 set(KEY_MIN_EXPOSURE_COMPENSATION, m_pCapability->exposure_compensation_min); // -12 4903 setFloat(KEY_EXPOSURE_COMPENSATION_STEP, m_pCapability->exposure_compensation_step); // 1/6 4904 setExposureCompensation(m_pCapability->exposure_compensation_default); // 0 4905 4906 // Set Antibanding 4907 String8 antibandingValues = createValuesString( 4908 m_pCapability->supported_antibandings, 4909 m_pCapability->supported_antibandings_cnt, 4910 ANTIBANDING_MODES_MAP, 4911 PARAM_MAP_SIZE(ANTIBANDING_MODES_MAP)); 4912 set(KEY_SUPPORTED_ANTIBANDING, antibandingValues); 4913 setAntibanding(ANTIBANDING_OFF); 4914 4915 // Set Effect 4916 String8 effectValues = createValuesString( 4917 m_pCapability->supported_effects, 4918 m_pCapability->supported_effects_cnt, 4919 EFFECT_MODES_MAP, 4920 PARAM_MAP_SIZE(EFFECT_MODES_MAP)); 4921 set(KEY_SUPPORTED_EFFECTS, effectValues); 4922 setEffect(EFFECT_NONE); 4923 4924 // Set WhiteBalance 4925 String8 whitebalanceValues = createValuesString( 4926 m_pCapability->supported_white_balances, 4927 m_pCapability->supported_white_balances_cnt, 4928 WHITE_BALANCE_MODES_MAP, 4929 PARAM_MAP_SIZE(WHITE_BALANCE_MODES_MAP)); 4930 set(KEY_SUPPORTED_WHITE_BALANCE, whitebalanceValues); 4931 setWhiteBalance(WHITE_BALANCE_AUTO); 4932 4933 // set supported wb cct, we should get them from m_pCapability 4934 m_pCapability->min_wb_cct = 2000; 4935 m_pCapability->max_wb_cct = 8000; 4936 set(KEY_QC_MIN_WB_CCT, m_pCapability->min_wb_cct); 4937 set(KEY_QC_MAX_WB_CCT, m_pCapability->max_wb_cct); 4938 4939 // set supported wb rgb gains, ideally we should get them from m_pCapability 4940 //but for now hardcode. 4941 m_pCapability->min_wb_gain = 1.0; 4942 m_pCapability->max_wb_gain = 4.0; 4943 setFloat(KEY_QC_MIN_WB_GAIN, m_pCapability->min_wb_gain); 4944 setFloat(KEY_QC_MAX_WB_GAIN, m_pCapability->max_wb_gain); 4945 4946 //set supported manual wb modes 4947 String8 manualWBModes(VALUE_OFF); 4948 if(m_pCapability->sensor_type.sens_type != CAM_SENSOR_YUV) { 4949 manualWBModes.append(","); 4950 manualWBModes.append(KEY_QC_WB_CCT_MODE); 4951 manualWBModes.append(","); 4952 manualWBModes.append(KEY_QC_WB_GAIN_MODE); 4953 } 4954 set(KEY_QC_SUPPORTED_MANUAL_WB_MODES, manualWBModes.string()); 4955 4956 // Set Flash mode 4957 if(m_pCapability->supported_flash_modes_cnt > 0) { 4958 String8 flashValues = createValuesString( 4959 m_pCapability->supported_flash_modes, 4960 m_pCapability->supported_flash_modes_cnt, 4961 FLASH_MODES_MAP, 4962 PARAM_MAP_SIZE(FLASH_MODES_MAP)); 4963 set(KEY_SUPPORTED_FLASH_MODES, flashValues); 4964 setFlash(FLASH_MODE_OFF); 4965 } else { 4966 ALOGE("%s: supported flash modes cnt is 0!!!", __func__); 4967 } 4968 4969 // Set Scene Mode 4970 String8 sceneModeValues = createValuesString( 4971 m_pCapability->supported_scene_modes, 4972 m_pCapability->supported_scene_modes_cnt, 4973 SCENE_MODES_MAP, 4974 PARAM_MAP_SIZE(SCENE_MODES_MAP)); 4975 set(KEY_SUPPORTED_SCENE_MODES, sceneModeValues); 4976 setSceneMode(SCENE_MODE_AUTO); 4977 4978 // Set CDS Mode 4979 String8 cdsModeValues = createValuesStringFromMap( 4980 CDS_MODES_MAP, 4981 PARAM_MAP_SIZE(CDS_MODES_MAP)); 4982 set(KEY_QC_SUPPORTED_CDS_MODES, cdsModeValues); 4983 4984 // Set video CDS Mode 4985 String8 videoCdsModeValues = createValuesStringFromMap( 4986 CDS_MODES_MAP, 4987 PARAM_MAP_SIZE(CDS_MODES_MAP)); 4988 set(KEY_QC_SUPPORTED_VIDEO_CDS_MODES, videoCdsModeValues); 4989 4990 // Set TNR Mode 4991 String8 tnrModeValues = createValuesStringFromMap( 4992 ON_OFF_MODES_MAP, 4993 PARAM_MAP_SIZE(ON_OFF_MODES_MAP)); 4994 set(KEY_QC_SUPPORTED_TNR_MODES, tnrModeValues); 4995 4996 // Set video TNR Mode 4997 String8 videoTnrModeValues = createValuesStringFromMap( 4998 ON_OFF_MODES_MAP, 4999 PARAM_MAP_SIZE(ON_OFF_MODES_MAP)); 5000 set(KEY_QC_SUPPORTED_VIDEO_TNR_MODES, videoTnrModeValues); 5001 5002 // Set ISO Mode 5003 String8 isoValues = createValuesString( 5004 m_pCapability->supported_iso_modes, 5005 m_pCapability->supported_iso_modes_cnt, 5006 ISO_MODES_MAP, 5007 PARAM_MAP_SIZE(ISO_MODES_MAP)); 5008 set(KEY_QC_SUPPORTED_ISO_MODES, isoValues); 5009 setISOValue(ISO_AUTO); 5010 5011 // Set exposure time 5012 String8 manualExpModes(VALUE_OFF); 5013 bool expTimeSupported = false; 5014 bool manualISOSupported = false; 5015 //capability values are in nano sec, convert to milli sec for upper layers 5016 char expTimeStr[20]; 5017 double min_exp_time = (double) m_pCapability->exposure_time_range[0] / 1000000.0; 5018 double max_exp_time = (double) m_pCapability->exposure_time_range[1] / 1000000.0; 5019 snprintf(expTimeStr, sizeof(expTimeStr), "%f", min_exp_time); 5020 set(KEY_QC_MIN_EXPOSURE_TIME, expTimeStr); 5021 snprintf(expTimeStr, sizeof(expTimeStr), "%f", max_exp_time); 5022 set(KEY_QC_MAX_EXPOSURE_TIME, expTimeStr); 5023 if ((min_exp_time > 0) && (max_exp_time > min_exp_time)) { 5024 manualExpModes.append(","); 5025 manualExpModes.append(KEY_QC_EXP_TIME_PRIORITY); 5026 expTimeSupported = true; 5027 } 5028 CDBG_HIGH("%s, Exposure time min %f ms, max %f ms", __func__, 5029 min_exp_time, max_exp_time); 5030 5031 // Set iso 5032 set(KEY_QC_MIN_ISO, m_pCapability->sensitivity_range.min_sensitivity); 5033 set(KEY_QC_MAX_ISO, m_pCapability->sensitivity_range.max_sensitivity); 5034 CDBG_HIGH("%s, ISO min %d, max %d", __func__, 5035 m_pCapability->sensitivity_range.min_sensitivity, 5036 m_pCapability->sensitivity_range.max_sensitivity); 5037 if ((m_pCapability->sensitivity_range.min_sensitivity > 0) && 5038 (m_pCapability->sensitivity_range.max_sensitivity > 5039 m_pCapability->sensitivity_range.min_sensitivity)) { 5040 manualExpModes.append(","); 5041 manualExpModes.append(KEY_QC_ISO_PRIORITY); 5042 manualISOSupported = true; 5043 } 5044 if (expTimeSupported && manualISOSupported) { 5045 manualExpModes.append(","); 5046 manualExpModes.append(KEY_QC_USER_SETTING); 5047 } 5048 //finally set supported manual exposure modes 5049 set(KEY_QC_SUPPORTED_MANUAL_EXPOSURE_MODES, manualExpModes.string()); 5050 5051 // Set HFR 5052 String8 hfrValues = createHfrValuesString( 5053 m_pCapability->hfr_tbl, 5054 m_pCapability->hfr_tbl_cnt, 5055 HFR_MODES_MAP, 5056 PARAM_MAP_SIZE(HFR_MODES_MAP)); 5057 set(KEY_QC_SUPPORTED_VIDEO_HIGH_FRAME_RATE_MODES, hfrValues.string()); 5058 set(KEY_QC_VIDEO_HIGH_SPEED_RECORDING, "off"); 5059 set(KEY_QC_VIDEO_HIGH_FRAME_RATE, "off"); 5060 String8 hfrSizeValues = createHfrSizesString( 5061 m_pCapability->hfr_tbl, 5062 m_pCapability->hfr_tbl_cnt); 5063 set(KEY_QC_SUPPORTED_HFR_SIZES, hfrSizeValues.string()); 5064 CDBG("HFR values %s HFR Sizes = %d", hfrValues.string(), hfrSizeValues.string()); 5065 setHighFrameRate(CAM_HFR_MODE_OFF); 5066 5067 // Set Focus algorithms 5068 String8 focusAlgoValues = createValuesString( 5069 m_pCapability->supported_focus_algos, 5070 m_pCapability->supported_focus_algos_cnt, 5071 FOCUS_ALGO_MAP, 5072 PARAM_MAP_SIZE(FOCUS_ALGO_MAP)); 5073 set(KEY_QC_SUPPORTED_FOCUS_ALGOS, focusAlgoValues); 5074 setSelectableZoneAf(FOCUS_ALGO_AUTO); 5075 5076 // Set Zoom Ratios 5077 if (m_pCapability->zoom_supported > 0) { 5078 String8 zoomRatioValues = createZoomRatioValuesString( 5079 m_pCapability->zoom_ratio_tbl, 5080 m_pCapability->zoom_ratio_tbl_cnt); 5081 set(KEY_ZOOM_RATIOS, zoomRatioValues); 5082 set(KEY_MAX_ZOOM, (int)(m_pCapability->zoom_ratio_tbl_cnt - 1)); 5083 setZoom(0); 5084 } 5085 5086 // Set Bracketing/HDR 5087 char prop[PROPERTY_VALUE_MAX]; 5088 memset(prop, 0, sizeof(prop)); 5089 property_get("persist.capture.burst.exposures", prop, ""); 5090 if (strlen(prop) > 0) { 5091 set(KEY_QC_CAPTURE_BURST_EXPOSURE, prop); 5092 } 5093 String8 bracketingValues = createValuesStringFromMap( 5094 BRACKETING_MODES_MAP, 5095 PARAM_MAP_SIZE(BRACKETING_MODES_MAP)); 5096 set(KEY_QC_SUPPORTED_AE_BRACKET_MODES, bracketingValues); 5097 setAEBracket(AE_BRACKET_OFF); 5098 5099 //Set AF Bracketing. 5100 for (size_t i = 0; i < m_pCapability->supported_focus_modes_cnt; i++) { 5101 if ((CAM_FOCUS_MODE_AUTO == m_pCapability->supported_focus_modes[i]) && 5102 ((m_pCapability->qcom_supported_feature_mask & 5103 CAM_QCOM_FEATURE_UBIFOCUS) > 0)) { 5104 String8 afBracketingValues = createValuesStringFromMap( 5105 AF_BRACKETING_MODES_MAP, 5106 PARAM_MAP_SIZE(AF_BRACKETING_MODES_MAP)); 5107 set(KEY_QC_SUPPORTED_AF_BRACKET_MODES, afBracketingValues); 5108 setAFBracket(AF_BRACKET_OFF); 5109 break; 5110 } 5111 } 5112 5113 //Set Refocus. 5114 //Re-use ubifocus flag for now. 5115 for (size_t i = 0; i < m_pCapability->supported_focus_modes_cnt; i++) { 5116 if ((CAM_FOCUS_MODE_AUTO == m_pCapability->supported_focus_modes[i]) && 5117 (m_pCapability->qcom_supported_feature_mask & 5118 CAM_QCOM_FEATURE_REFOCUS) > 0) { 5119 String8 reFocusValues = createValuesStringFromMap( 5120 RE_FOCUS_MODES_MAP, 5121 PARAM_MAP_SIZE(RE_FOCUS_MODES_MAP)); 5122 set(KEY_QC_SUPPORTED_RE_FOCUS_MODES, reFocusValues); 5123 setReFocus(RE_FOCUS_OFF); 5124 } 5125 } 5126 5127 //Set Chroma Flash. 5128 if ((m_pCapability->supported_flash_modes_cnt > 0) && 5129 (m_pCapability->qcom_supported_feature_mask & 5130 CAM_QCOM_FEATURE_CHROMA_FLASH) > 0) { 5131 String8 chromaFlashValues = createValuesStringFromMap( 5132 CHROMA_FLASH_MODES_MAP, 5133 PARAM_MAP_SIZE(CHROMA_FLASH_MODES_MAP)); 5134 set(KEY_QC_SUPPORTED_CHROMA_FLASH_MODES, chromaFlashValues); 5135 setChromaFlash(CHROMA_FLASH_OFF); 5136 } 5137 5138 //Set Opti Zoom. 5139 if (m_pCapability->zoom_supported && 5140 (m_pCapability->qcom_supported_feature_mask & 5141 CAM_QCOM_FEATURE_OPTIZOOM) > 0){ 5142 String8 optiZoomValues = createValuesStringFromMap( 5143 OPTI_ZOOM_MODES_MAP, 5144 PARAM_MAP_SIZE(OPTI_ZOOM_MODES_MAP)); 5145 set(KEY_QC_SUPPORTED_OPTI_ZOOM_MODES, optiZoomValues); 5146 setOptiZoom(OPTI_ZOOM_OFF); 5147 } 5148 5149 //Set HDR Type 5150 uint32_t supported_hdr_modes = m_pCapability->qcom_supported_feature_mask & 5151 (CAM_QCOM_FEATURE_SENSOR_HDR | CAM_QCOM_FEATURE_HDR); 5152 if (supported_hdr_modes) { 5153 if (CAM_QCOM_FEATURE_SENSOR_HDR == supported_hdr_modes) { 5154 String8 hdrModeValues; 5155 hdrModeValues.append(HDR_MODE_SENSOR); 5156 set(KEY_QC_SUPPORTED_KEY_QC_HDR_MODES, hdrModeValues); 5157 setHDRMode(HDR_MODE_SENSOR); 5158 } else if (CAM_QCOM_FEATURE_HDR == supported_hdr_modes) { 5159 String8 hdrModeValues; 5160 hdrModeValues.append(HDR_MODE_MULTI_FRAME); 5161 set(KEY_QC_SUPPORTED_KEY_QC_HDR_MODES, hdrModeValues); 5162 setHDRMode(HDR_MODE_MULTI_FRAME); 5163 } else { 5164 String8 hdrModeValues = createValuesStringFromMap( 5165 HDR_MODES_MAP, 5166 PARAM_MAP_SIZE(HDR_MODES_MAP)); 5167 set(KEY_QC_SUPPORTED_KEY_QC_HDR_MODES, hdrModeValues); 5168 setHDRMode(HDR_MODE_MULTI_FRAME); 5169 } 5170 } 5171 5172 //Set HDR need 1x 5173 String8 hdrNeed1xValues; 5174 if (!m_bHDRModeSensor) { 5175 hdrNeed1xValues = createValuesStringFromMap(TRUE_FALSE_MODES_MAP, 5176 PARAM_MAP_SIZE(TRUE_FALSE_MODES_MAP)); 5177 setHDRNeed1x(VALUE_TRUE); 5178 } else { 5179 hdrNeed1xValues.append(VALUE_FALSE); 5180 setHDRNeed1x(VALUE_FALSE); 5181 } 5182 set(KEY_QC_SUPPORTED_HDR_NEED_1X, hdrNeed1xValues); 5183 5184 //Set True Portrait 5185 if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_TRUEPORTRAIT) > 0) { 5186 String8 truePortraitValues = createValuesStringFromMap( 5187 TRUE_PORTRAIT_MODES_MAP, 5188 PARAM_MAP_SIZE(TRUE_PORTRAIT_MODES_MAP)); 5189 set(KEY_QC_SUPPORTED_TRUE_PORTRAIT_MODES, truePortraitValues); 5190 } 5191 5192 // Set Denoise 5193 if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_DENOISE2D) > 0){ 5194 String8 denoiseValues = createValuesStringFromMap( 5195 DENOISE_ON_OFF_MODES_MAP, PARAM_MAP_SIZE(DENOISE_ON_OFF_MODES_MAP)); 5196 set(KEY_QC_SUPPORTED_DENOISE, denoiseValues.string()); 5197 #ifdef DEFAULT_DENOISE_MODE_ON 5198 setWaveletDenoise(DENOISE_ON); 5199 #else 5200 setWaveletDenoise(DENOISE_OFF); 5201 #endif 5202 } 5203 5204 // Set feature enable/disable 5205 String8 enableDisableValues = createValuesStringFromMap( 5206 ENABLE_DISABLE_MODES_MAP, PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP)); 5207 5208 // Set Lens Shading 5209 set(KEY_QC_SUPPORTED_LENSSHADE_MODES, enableDisableValues); 5210 setLensShadeValue(VALUE_ENABLE); 5211 // Set MCE 5212 set(KEY_QC_SUPPORTED_MEM_COLOR_ENHANCE_MODES, enableDisableValues); 5213 setMCEValue(VALUE_ENABLE); 5214 5215 // Set DIS 5216 set(KEY_QC_SUPPORTED_DIS_MODES, enableDisableValues); 5217 setDISValue(VALUE_DISABLE); 5218 5219 // Set Histogram 5220 set(KEY_QC_SUPPORTED_HISTOGRAM_MODES, 5221 m_pCapability->histogram_supported ? enableDisableValues : ""); 5222 set(KEY_QC_HISTOGRAM, VALUE_DISABLE); 5223 5224 //Set Red Eye Reduction 5225 set(KEY_QC_SUPPORTED_REDEYE_REDUCTION, enableDisableValues); 5226 setRedeyeReduction(VALUE_DISABLE); 5227 5228 //Set SkinTone Enhancement 5229 set(KEY_QC_SUPPORTED_SKIN_TONE_ENHANCEMENT_MODES, enableDisableValues); 5230 5231 // Set feature on/off 5232 String8 onOffValues = createValuesStringFromMap( 5233 ON_OFF_MODES_MAP, PARAM_MAP_SIZE(ON_OFF_MODES_MAP)); 5234 5235 //Set See more (LLVD) 5236 if (m_pCapability->qcom_supported_feature_mask & 5237 CAM_QCOM_FEATURE_LLVD) { 5238 set(KEY_QC_SUPPORTED_SEE_MORE_MODES, onOffValues); 5239 setSeeMore(VALUE_OFF); 5240 } 5241 5242 //Set Still more 5243 if (m_pCapability->qcom_supported_feature_mask & 5244 CAM_QCOM_FEATURE_STILLMORE) { 5245 String8 stillMoreValues = createValuesStringFromMap( 5246 STILL_MORE_MODES_MAP, 5247 PARAM_MAP_SIZE(STILL_MORE_MODES_MAP)); 5248 set(KEY_QC_SUPPORTED_STILL_MORE_MODES, stillMoreValues); 5249 setStillMore(STILL_MORE_OFF); 5250 } 5251 5252 //Set Scene Detection 5253 set(KEY_QC_SUPPORTED_SCENE_DETECT, onOffValues); 5254 setSceneDetect(VALUE_OFF); 5255 m_bHDREnabled = false; 5256 m_bHDR1xFrameEnabled = true; 5257 5258 m_bHDRThumbnailProcessNeeded = false; 5259 m_bHDR1xExtraBufferNeeded = true; 5260 for (uint32_t i=0; i<m_pCapability->hdr_bracketing_setting.num_frames; i++) { 5261 if (0 == m_pCapability->hdr_bracketing_setting.exp_val.values[i]) { 5262 m_bHDR1xExtraBufferNeeded = false; 5263 break; 5264 } 5265 } 5266 5267 // Set HDR output scaling 5268 char value[PROPERTY_VALUE_MAX]; 5269 5270 property_get("persist.camera.hdr.outcrop", value, VALUE_DISABLE); 5271 if (strncmp(VALUE_ENABLE, value, sizeof(VALUE_ENABLE))) { 5272 m_bHDROutputCropEnabled = false; 5273 } else { 5274 m_bHDROutputCropEnabled = true; 5275 } 5276 5277 //Set Face Detection 5278 set(KEY_QC_SUPPORTED_FACE_DETECTION, onOffValues); 5279 set(KEY_QC_FACE_DETECTION, VALUE_OFF); 5280 5281 //Set Face Recognition 5282 //set(KEY_QC_SUPPORTED_FACE_RECOGNITION, onOffValues); 5283 //set(KEY_QC_FACE_RECOGNITION, VALUE_OFF); 5284 5285 //Set ZSL 5286 set(KEY_QC_SUPPORTED_ZSL_MODES, onOffValues); 5287 #ifdef DEFAULT_ZSL_MODE_ON 5288 set(KEY_QC_ZSL, VALUE_ON); 5289 m_bZslMode = true; 5290 #else 5291 set(KEY_QC_ZSL, VALUE_OFF); 5292 m_bZslMode = false; 5293 #endif 5294 5295 // Check if zsl mode property is enabled. 5296 // If yes, force the camera to be in zsl mode 5297 memset(value, 0x00, PROPERTY_VALUE_MAX); 5298 property_get("persist.camera.zsl.mode", value, "0"); 5299 int32_t zsl_mode = atoi(value); 5300 if(zsl_mode == 1) { 5301 CDBG_HIGH("%s: %d: Forcing Camera to ZSL mode ", __func__, __LINE__); 5302 set(KEY_QC_ZSL, VALUE_ON); 5303 m_bForceZslMode = true; 5304 m_bZslMode = true; 5305 } 5306 m_bZslMode_new = m_bZslMode; 5307 5308 set(KEY_QC_SCENE_SELECTION, VALUE_DISABLE); 5309 5310 // Rdi mode 5311 set(KEY_QC_SUPPORTED_RDI_MODES, enableDisableValues); 5312 setRdiMode(VALUE_DISABLE); 5313 5314 // Secure mode 5315 set(KEY_QC_SUPPORTED_SECURE_MODES, enableDisableValues); 5316 setSecureMode(VALUE_DISABLE); 5317 5318 //Set video HDR 5319 if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_VIDEO_HDR) > 0) { 5320 set(KEY_QC_SUPPORTED_VIDEO_HDR_MODES, onOffValues); 5321 set(KEY_QC_VIDEO_HDR, VALUE_OFF); 5322 } 5323 5324 //Set HW Sensor Snapshot HDR 5325 if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_SENSOR_HDR)> 0) { 5326 set(KEY_QC_SUPPORTED_SENSOR_HDR_MODES, onOffValues); 5327 set(KEY_QC_SENSOR_HDR, VALUE_OFF); 5328 m_bSensorHDREnabled = false; 5329 } 5330 5331 // Set VT TimeStamp 5332 set(KEY_QC_VT_ENABLE, VALUE_DISABLE); 5333 //Set Touch AF/AEC 5334 String8 touchValues = createValuesStringFromMap( 5335 TOUCH_AF_AEC_MODES_MAP, PARAM_MAP_SIZE(TOUCH_AF_AEC_MODES_MAP)); 5336 5337 set(KEY_QC_SUPPORTED_TOUCH_AF_AEC, touchValues); 5338 set(KEY_QC_TOUCH_AF_AEC, TOUCH_AF_AEC_OFF); 5339 5340 //set flip mode 5341 if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_FLIP) > 0) { 5342 String8 flipModes = createValuesStringFromMap( 5343 FLIP_MODES_MAP, PARAM_MAP_SIZE(FLIP_MODES_MAP)); 5344 set(KEY_QC_SUPPORTED_FLIP_MODES, flipModes); 5345 set(KEY_QC_PREVIEW_FLIP, FLIP_MODE_OFF); 5346 set(KEY_QC_VIDEO_FLIP, FLIP_MODE_OFF); 5347 set(KEY_QC_SNAPSHOT_PICTURE_FLIP, FLIP_MODE_OFF); 5348 } 5349 5350 // Set default Auto Exposure lock value 5351 setAecLock(VALUE_FALSE); 5352 5353 // Set default AWB_LOCK lock value 5354 setAwbLock(VALUE_FALSE); 5355 5356 // Set default Camera mode 5357 set(KEY_QC_CAMERA_MODE, 0); 5358 5359 // Add support for internal preview restart 5360 set(KEY_INTERNAL_PERVIEW_RESTART, VALUE_TRUE); 5361 // Set default burst number 5362 set(KEY_QC_SNAPSHOT_BURST_NUM, 0); 5363 set(KEY_QC_NUM_RETRO_BURST_PER_SHUTTER, 0); 5364 5365 //Get RAM size and disable features which are memory rich 5366 struct sysinfo info; 5367 sysinfo(&info); 5368 5369 CDBG_HIGH("%s: totalram = %ld, freeram = %ld ", __func__, info.totalram, 5370 info.freeram); 5371 if (info.totalram > TOTAL_RAM_SIZE_512MB) { 5372 set(KEY_QC_LONGSHOT_SUPPORTED, VALUE_TRUE); 5373 set(KEY_QC_ZSL_HDR_SUPPORTED, VALUE_TRUE); 5374 } else { 5375 set(KEY_QC_LONGSHOT_SUPPORTED, VALUE_FALSE); 5376 set(KEY_QC_ZSL_HDR_SUPPORTED, VALUE_FALSE); 5377 } 5378 5379 setOfflineRAW(); 5380 memset(mStreamPpMask, 0, sizeof(uint32_t)*CAM_STREAM_TYPE_MAX); 5381 5382 int32_t rc = commitParameters(); 5383 if (rc == NO_ERROR) { 5384 rc = setNumOfSnapshot(); 5385 } 5386 5387 //Set Video Rotation 5388 String8 videoRotationValues = createValuesStringFromMap(VIDEO_ROTATION_MODES_MAP, 5389 PARAM_MAP_SIZE(VIDEO_ROTATION_MODES_MAP)); 5390 5391 set(KEY_QC_SUPPORTED_VIDEO_ROTATION_VALUES, videoRotationValues.string()); 5392 set(KEY_QC_VIDEO_ROTATION, VIDEO_ROTATION_0); 5393 return rc; 5394 } 5395 5396 /*=========================================================================== 5397 * FUNCTION : init 5398 * 5399 * DESCRIPTION: initialize parameter obj 5400 * 5401 * PARAMETERS : 5402 * @capabilities : ptr to camera capabilities 5403 * @mmops : ptr to memory ops table for mapping/unmapping 5404 * @adjustFPS : object reference for additional (possibly thermal) 5405 * framerate adjustment 5406 * 5407 * RETURN : int32_t type of status 5408 * NO_ERROR -- success 5409 * none-zero failure code 5410 *==========================================================================*/ 5411 int32_t QCameraParameters::init(cam_capability_t *capabilities, 5412 mm_camera_vtbl_t *mmOps, QCameraAdjustFPS *adjustFPS) 5413 { 5414 int32_t rc = NO_ERROR; 5415 5416 m_pCapability = capabilities; 5417 m_pCamOpsTbl = mmOps; 5418 m_AdjustFPS = adjustFPS; 5419 5420 //Allocate Set Param Buffer 5421 m_pParamHeap = new QCameraHeapMemory(QCAMERA_ION_USE_CACHE); 5422 rc = m_pParamHeap->allocate(1, sizeof(parm_buffer_t), NON_SECURE); 5423 if(rc != OK) { 5424 rc = NO_MEMORY; 5425 ALOGE("Failed to allocate SETPARM Heap memory"); 5426 goto TRANS_INIT_ERROR1; 5427 } 5428 5429 //Map memory for parameters buffer 5430 rc = m_pCamOpsTbl->ops->map_buf(m_pCamOpsTbl->camera_handle, 5431 CAM_MAPPING_BUF_TYPE_PARM_BUF, 5432 m_pParamHeap->getFd(0), 5433 sizeof(parm_buffer_t)); 5434 if(rc < 0) { 5435 ALOGE("%s:failed to map SETPARM buffer",__func__); 5436 rc = FAILED_TRANSACTION; 5437 goto TRANS_INIT_ERROR2; 5438 } 5439 m_pParamBuf = (parm_buffer_t*) DATA_PTR(m_pParamHeap,0); 5440 5441 initDefaultParameters(); 5442 5443 m_bInited = true; 5444 5445 goto TRANS_INIT_DONE; 5446 5447 TRANS_INIT_ERROR2: 5448 m_pParamHeap->deallocate(); 5449 5450 TRANS_INIT_ERROR1: 5451 delete m_pParamHeap; 5452 m_pParamHeap = NULL; 5453 5454 TRANS_INIT_DONE: 5455 return rc; 5456 } 5457 5458 /*=========================================================================== 5459 * FUNCTION : deinit 5460 * 5461 * DESCRIPTION: deinitialize 5462 * 5463 * PARAMETERS : none 5464 * 5465 * RETURN : none 5466 *==========================================================================*/ 5467 void QCameraParameters::deinit() 5468 { 5469 if (!m_bInited) { 5470 return; 5471 } 5472 5473 //clear all entries in the map 5474 String8 emptyStr; 5475 QCameraParameters::unflatten(emptyStr); 5476 5477 if (NULL != m_pCamOpsTbl) { 5478 m_pCamOpsTbl->ops->unmap_buf( 5479 m_pCamOpsTbl->camera_handle, 5480 CAM_MAPPING_BUF_TYPE_PARM_BUF); 5481 m_pCamOpsTbl = NULL; 5482 } 5483 m_pCapability = NULL; 5484 if (NULL != m_pParamHeap) { 5485 m_pParamHeap->deallocate(); 5486 delete m_pParamHeap; 5487 m_pParamHeap = NULL; 5488 m_pParamBuf = NULL; 5489 } 5490 5491 m_AdjustFPS = NULL; 5492 5493 m_tempMap.clear(); 5494 5495 m_bInited = false; 5496 } 5497 5498 /*=========================================================================== 5499 * FUNCTION : parse_pair 5500 * 5501 * DESCRIPTION: helper function to parse string like "640x480" or "10000,20000" 5502 * 5503 * PARAMETERS : 5504 * @str : input string to be parse 5505 * @first : [output] first value of the pair 5506 * @second : [output] second value of the pair 5507 * @delim : [input] delimeter to seperate the pair 5508 * @endptr : [output] ptr to the end of the pair string 5509 * 5510 * RETURN : int32_t type of status 5511 * NO_ERROR -- success 5512 * none-zero failure code 5513 *==========================================================================*/ 5514 int32_t QCameraParameters::parse_pair(const char *str, 5515 int *first, 5516 int *second, 5517 char delim, 5518 char **endptr = NULL) 5519 { 5520 // Find the first integer. 5521 char *end; 5522 int w = (int)strtol(str, &end, 10); 5523 // If a delimeter does not immediately follow, give up. 5524 if (*end != delim) { 5525 ALOGE("Cannot find delimeter (%c) in str=%s", delim, str); 5526 return BAD_VALUE; 5527 } 5528 5529 // Find the second integer, immediately after the delimeter. 5530 int h = (int)strtol(end+1, &end, 10); 5531 5532 *first = w; 5533 *second = h; 5534 5535 if (endptr) { 5536 *endptr = end; 5537 } 5538 5539 return NO_ERROR; 5540 } 5541 5542 /*=========================================================================== 5543 * FUNCTION : parseSizesList 5544 * 5545 * DESCRIPTION: helper function to parse string containing sizes 5546 * 5547 * PARAMETERS : 5548 * @sizesStr: [input] input string to be parse 5549 * @sizes : [output] reference to store parsed sizes 5550 * 5551 * RETURN : none 5552 *==========================================================================*/ 5553 void QCameraParameters::parseSizesList(const char *sizesStr, Vector<Size> &sizes) 5554 { 5555 if (sizesStr == 0) { 5556 return; 5557 } 5558 5559 char *sizeStartPtr = (char *)sizesStr; 5560 5561 while (true) { 5562 int width, height; 5563 int success = parse_pair(sizeStartPtr, &width, &height, 'x', 5564 &sizeStartPtr); 5565 if (success == -1 || (*sizeStartPtr != ',' && *sizeStartPtr != '\0')) { 5566 ALOGE("Picture sizes string \"%s\" contains invalid character.", sizesStr); 5567 return; 5568 } 5569 sizes.push(Size(width, height)); 5570 5571 if (*sizeStartPtr == '\0') { 5572 return; 5573 } 5574 sizeStartPtr++; 5575 } 5576 } 5577 5578 /*=========================================================================== 5579 * FUNCTION : getSupportedHfrSizes 5580 * 5581 * DESCRIPTION: return supported HFR sizes 5582 * 5583 * PARAMETERS : 5584 * @sizes : [output] reference to a vector storing supported HFR sizes 5585 * 5586 * RETURN : none 5587 *==========================================================================*/ 5588 void QCameraParameters::getSupportedHfrSizes(Vector<Size> &sizes) 5589 { 5590 const char *hfrSizesStr = get(KEY_QC_SUPPORTED_HFR_SIZES); 5591 parseSizesList(hfrSizesStr, sizes); 5592 } 5593 5594 /*=========================================================================== 5595 * FUNCTION : adjustPreviewFpsRanges 5596 * 5597 * DESCRIPTION: adjust preview FPS ranges 5598 * according to external events 5599 * 5600 * PARAMETERS : 5601 * @minFPS : min FPS value 5602 * @maxFPS : max FPS value 5603 * 5604 * RETURN : int32_t type of status 5605 * NO_ERROR -- success 5606 * none-zero failure code 5607 *==========================================================================*/ 5608 int32_t QCameraParameters::adjustPreviewFpsRange(cam_fps_range_t *fpsRange) 5609 { 5610 if ( fpsRange == NULL ) { 5611 return BAD_VALUE; 5612 } 5613 5614 if ( m_pParamBuf == NULL ) { 5615 return NO_INIT; 5616 } 5617 5618 int32_t rc = initBatchUpdate(m_pParamBuf); 5619 if ( rc != NO_ERROR ) { 5620 ALOGE("%s:Failed to initialize group update table", __func__); 5621 return rc; 5622 } 5623 5624 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_FPS_RANGE, *fpsRange)) { 5625 ALOGE("%s: Parameters batch failed",__func__); 5626 return BAD_VALUE; 5627 } 5628 5629 rc = commitSetBatch(); 5630 if ( rc != NO_ERROR ) { 5631 ALOGE("%s:Failed to commit batch parameters", __func__); 5632 return rc; 5633 } 5634 5635 return rc; 5636 } 5637 5638 /*=========================================================================== 5639 * FUNCTION : setPreviewFpsRanges 5640 * 5641 * DESCRIPTION: set preview FPS ranges 5642 * 5643 * PARAMETERS : 5644 * @minFPS : min FPS value 5645 * @maxFPS : max FPS value 5646 * 5647 * RETURN : int32_t type of status 5648 * NO_ERROR -- success 5649 * none-zero failure code 5650 *==========================================================================*/ 5651 int32_t QCameraParameters::setPreviewFpsRange(int min_fps, 5652 int max_fps, int vid_min_fps,int vid_max_fps) 5653 { 5654 char str[32]; 5655 char value[PROPERTY_VALUE_MAX]; 5656 int fixedFpsValue; 5657 /*This property get value should be the fps that user needs*/ 5658 property_get("persist.debug.set.fixedfps", value, "0"); 5659 fixedFpsValue = atoi(value); 5660 5661 CDBG("%s: E minFps = %d, maxFps = %d , vid minFps = %d, vid maxFps = %d", 5662 __func__, min_fps, max_fps, vid_min_fps, vid_max_fps); 5663 5664 if(fixedFpsValue != 0) { 5665 min_fps = (int)fixedFpsValue*1000; 5666 max_fps = (int)fixedFpsValue*1000; 5667 } 5668 snprintf(str, sizeof(str), "%d,%d", min_fps, max_fps); 5669 CDBG_HIGH("%s: Setting preview fps range %s", __func__, str); 5670 updateParamEntry(KEY_PREVIEW_FPS_RANGE, str); 5671 cam_fps_range_t fps_range; 5672 memset(&fps_range, 0x00, sizeof(cam_fps_range_t)); 5673 fps_range.min_fps = (float)min_fps / 1000.0f; 5674 fps_range.max_fps = (float)max_fps / 1000.0f; 5675 fps_range.video_min_fps = (float)vid_min_fps / 1000.0f; 5676 fps_range.video_max_fps = (float)vid_max_fps / 1000.0f; 5677 5678 CDBG_HIGH("%s: Updated: minFps = %d, maxFps = %d ," 5679 " vid minFps = %d, vid maxFps = %d", 5680 __func__, min_fps, max_fps, vid_min_fps, vid_max_fps); 5681 5682 if ( NULL != m_AdjustFPS ) { 5683 m_AdjustFPS->recalcFPSRange(min_fps, max_fps, fps_range); 5684 CDBG_HIGH("%s: Thermal adjusted Preview fps range %3.2f,%3.2f, %3.2f, %3.2f", 5685 __func__, fps_range.min_fps, fps_range.max_fps, 5686 fps_range.video_min_fps, fps_range.video_max_fps); 5687 } 5688 5689 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_FPS_RANGE, fps_range)) { 5690 return BAD_VALUE; 5691 } 5692 5693 return NO_ERROR; 5694 } 5695 5696 5697 5698 /*=========================================================================== 5699 * FUNCTION : setAutoExposure 5700 * 5701 * DESCRIPTION: set auto exposure 5702 * 5703 * PARAMETERS : 5704 * @autoExp : auto exposure value string 5705 * 5706 * RETURN : int32_t type of status 5707 * NO_ERROR -- success 5708 * none-zero failure code 5709 *==========================================================================*/ 5710 int32_t QCameraParameters::setAutoExposure(const char *autoExp) 5711 { 5712 if (autoExp != NULL) { 5713 int32_t value = lookupAttr(AUTO_EXPOSURE_MAP, PARAM_MAP_SIZE(AUTO_EXPOSURE_MAP), autoExp); 5714 if (value != NAME_NOT_FOUND) { 5715 CDBG_HIGH("%s: Setting auto exposure %s", __func__, autoExp); 5716 updateParamEntry(KEY_QC_AUTO_EXPOSURE, autoExp); 5717 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_AEC_ALGO_TYPE, value)) { 5718 return BAD_VALUE; 5719 } 5720 return NO_ERROR; 5721 } 5722 } 5723 ALOGE("Invalid auto exposure value: %s", (autoExp == NULL) ? "NULL" : autoExp); 5724 return BAD_VALUE; 5725 } 5726 5727 /*=========================================================================== 5728 * FUNCTION : setEffect 5729 * 5730 * DESCRIPTION: set effect 5731 * 5732 * PARAMETERS : 5733 * @effect : effect value string 5734 * 5735 * RETURN : int32_t type of status 5736 * NO_ERROR -- success 5737 * none-zero failure code 5738 *==========================================================================*/ 5739 int32_t QCameraParameters::setEffect(const char *effect) 5740 { 5741 if (effect != NULL) { 5742 int32_t value = lookupAttr(EFFECT_MODES_MAP, PARAM_MAP_SIZE(EFFECT_MODES_MAP), effect); 5743 if (value != NAME_NOT_FOUND) { 5744 CDBG_HIGH("%s: Setting effect %s", __func__, effect); 5745 updateParamEntry(KEY_EFFECT, effect); 5746 uint8_t prmEffect = static_cast<uint8_t>(value); 5747 mParmEffect = prmEffect; 5748 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_EFFECT, prmEffect)) { 5749 return BAD_VALUE; 5750 } 5751 return NO_ERROR; 5752 } 5753 } 5754 ALOGE("Invalid effect value: %s", (effect == NULL) ? "NULL" : effect); 5755 return BAD_VALUE; 5756 } 5757 5758 /*=========================================================================== 5759 * FUNCTION : setBrightness 5760 * 5761 * DESCRIPTION: set brightness control value 5762 * 5763 * PARAMETERS : 5764 * @brightness : brightness control value 5765 * 5766 * RETURN : int32_t type of status 5767 * NO_ERROR -- success 5768 * none-zero failure code 5769 *==========================================================================*/ 5770 int32_t QCameraParameters::setBrightness(int brightness) 5771 { 5772 char val[16]; 5773 snprintf(val, sizeof(val), "%d", brightness); 5774 updateParamEntry(KEY_QC_BRIGHTNESS, val); 5775 5776 CDBG_HIGH("%s: Setting brightness %s", __func__, val); 5777 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_BRIGHTNESS, brightness)) { 5778 return BAD_VALUE; 5779 } 5780 5781 return NO_ERROR; 5782 } 5783 5784 /*=========================================================================== 5785 * FUNCTION : setFocusMode 5786 * 5787 * DESCRIPTION: set focus mode 5788 * 5789 * PARAMETERS : 5790 * @focusMode : focus mode value string 5791 * 5792 * RETURN : int32_t type of status 5793 * NO_ERROR -- success 5794 * none-zero failure code 5795 *==========================================================================*/ 5796 int32_t QCameraParameters::setFocusMode(const char *focusMode) 5797 { 5798 if (focusMode != NULL) { 5799 int32_t value = lookupAttr(FOCUS_MODES_MAP, PARAM_MAP_SIZE(FOCUS_MODES_MAP), focusMode); 5800 if (value != NAME_NOT_FOUND) { 5801 int32_t rc = NO_ERROR; 5802 CDBG_HIGH("%s: Setting focus mode %s", __func__, focusMode); 5803 mFocusMode = (cam_focus_mode_type)value; 5804 5805 updateParamEntry(KEY_FOCUS_MODE, focusMode); 5806 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, 5807 CAM_INTF_PARM_FOCUS_MODE, (uint8_t)value)) { 5808 rc = BAD_VALUE; 5809 } 5810 if (strcmp(focusMode,"infinity")==0){ 5811 set(QCameraParameters::KEY_FOCUS_DISTANCES, "Infinity,Infinity,Infinity"); 5812 } 5813 return rc; 5814 } 5815 } 5816 ALOGE("Invalid focus mode value: %s", (focusMode == NULL) ? "NULL" : focusMode); 5817 return BAD_VALUE; 5818 } 5819 5820 /*=========================================================================== 5821 * FUNCTION : setFocusPosition 5822 * 5823 * DESCRIPTION: set focus position 5824 * 5825 * PARAMETERS : 5826 * @typeStr : focus position type, index or dac_code 5827 * @posStr : focus positon. 5828 * 5829 * RETURN : int32_t type of status 5830 * NO_ERROR -- success 5831 * none-zero failure code 5832 *==========================================================================*/ 5833 int32_t QCameraParameters::setFocusPosition(const char *typeStr, const char *posStr) 5834 { 5835 CDBG_HIGH("%s, type:%s, pos: %s", __func__, typeStr, posStr); 5836 int32_t type = atoi(typeStr); 5837 float pos = (float) atof(posStr); 5838 5839 if ((type >= CAM_MANUAL_FOCUS_MODE_INDEX) && 5840 (type < CAM_MANUAL_FOCUS_MODE_MAX)) { 5841 // get max and min focus position from m_pCapability 5842 int32_t minFocusPos = (int32_t) m_pCapability->min_focus_pos[type]; 5843 int32_t maxFocusPos = (int32_t) m_pCapability->max_focus_pos[type]; 5844 CDBG_HIGH("%s, focusPos min: %d, max: %d", __func__, minFocusPos, maxFocusPos); 5845 5846 if (pos >= minFocusPos && pos <= maxFocusPos) { 5847 updateParamEntry(KEY_QC_MANUAL_FOCUS_POS_TYPE, typeStr); 5848 updateParamEntry(KEY_QC_MANUAL_FOCUS_POSITION, posStr); 5849 5850 cam_manual_focus_parm_t manual_focus; 5851 manual_focus.flag = (cam_manual_focus_mode_type)type; 5852 if (manual_focus.flag == CAM_MANUAL_FOCUS_MODE_DIOPTER) { 5853 manual_focus.af_manual_diopter = pos; 5854 } else if (manual_focus.flag == CAM_MANUAL_FOCUS_MODE_RATIO) { 5855 manual_focus.af_manual_lens_position_ratio = (int32_t) pos; 5856 } else if (manual_focus.flag == CAM_MANUAL_FOCUS_MODE_INDEX) { 5857 manual_focus.af_manual_lens_position_index = (int32_t) pos; 5858 } else { 5859 manual_focus.af_manual_lens_position_dac = (int32_t) pos; 5860 } 5861 5862 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_MANUAL_FOCUS_POS, 5863 manual_focus)) { 5864 return BAD_VALUE; 5865 } 5866 return NO_ERROR; 5867 } 5868 } 5869 5870 ALOGE("%s, invalid params, type:%d, pos: %d", __func__, type, pos); 5871 return BAD_VALUE; 5872 } 5873 5874 /*=========================================================================== 5875 * FUNCTION : updateAEInfo 5876 * 5877 * DESCRIPTION: update exposure information from metadata callback 5878 * 5879 * PARAMETERS : 5880 * @ae_params : auto exposure params 5881 * 5882 * RETURN : void 5883 *==========================================================================*/ 5884 void QCameraParameters::updateAEInfo(cam_3a_params_t &ae_params) 5885 { 5886 const char *prevExpTime = get(KEY_QC_CURRENT_EXPOSURE_TIME); 5887 char newExpTime[15]; 5888 snprintf(newExpTime, sizeof(newExpTime), "%f", ae_params.exp_time*1000.0); 5889 5890 if (prevExpTime == NULL || strcmp(prevExpTime, newExpTime)) { 5891 CDBG("update exposure time: old: %s, new: %s", prevExpTime, newExpTime); 5892 set(KEY_QC_CURRENT_EXPOSURE_TIME, newExpTime); 5893 } 5894 5895 int32_t prevISO = getInt(KEY_QC_CURRENT_ISO); 5896 int32_t newISO = ae_params.iso_value; 5897 if (prevISO != newISO) { 5898 CDBG("update iso: old:%d, new:%d", prevISO, newISO); 5899 set(KEY_QC_CURRENT_ISO, newISO); 5900 } 5901 } 5902 5903 /*=========================================================================== 5904 * FUNCTION : updateCurrentFocusPosition 5905 * 5906 * DESCRIPTION: update current focus position from metadata callback 5907 * 5908 * PARAMETERS : 5909 * @pos : current focus position 5910 * 5911 * RETURN : void 5912 *==========================================================================*/ 5913 void QCameraParameters::updateCurrentFocusPosition(cam_focus_pos_info_t &cur_pos_info) 5914 { 5915 int prevScalePos = getInt(KEY_QC_FOCUS_POSITION_SCALE); 5916 int newScalePos = (int) cur_pos_info.scale; 5917 if (prevScalePos != newScalePos) { 5918 CDBG("update focus scale: old:%d, new:%d", prevScalePos, newScalePos); 5919 set(KEY_QC_FOCUS_POSITION_SCALE, newScalePos); 5920 } 5921 5922 float prevDiopterPos = getFloat(KEY_QC_FOCUS_POSITION_DIOPTER); 5923 float newDiopterPos = cur_pos_info.diopter; 5924 if (prevDiopterPos != newDiopterPos) { 5925 CDBG("update focus diopter: old:%f, new:%f", prevDiopterPos, newDiopterPos); 5926 setFloat(KEY_QC_FOCUS_POSITION_DIOPTER, newDiopterPos); 5927 } 5928 } 5929 5930 /*=========================================================================== 5931 * FUNCTION : setSharpness 5932 * 5933 * DESCRIPTION: set sharpness control value 5934 * 5935 * PARAMETERS : 5936 * @sharpness : sharpness control value 5937 * 5938 * RETURN : int32_t type of status 5939 * NO_ERROR -- success 5940 * none-zero failure code 5941 *==========================================================================*/ 5942 int32_t QCameraParameters::setSharpness(int sharpness) 5943 { 5944 char val[16]; 5945 snprintf(val, sizeof(val), "%d", sharpness); 5946 updateParamEntry(KEY_QC_SHARPNESS, val); 5947 CDBG_HIGH("%s: Setting sharpness %s", __func__, val); 5948 m_nSharpness = sharpness; 5949 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_SHARPNESS, m_nSharpness)) { 5950 return BAD_VALUE; 5951 } 5952 5953 return NO_ERROR; 5954 } 5955 5956 /*=========================================================================== 5957 * FUNCTION : setSkinToneEnhancement 5958 * 5959 * DESCRIPTION: set skin tone enhancement value 5960 * 5961 * PARAMETERS : 5962 * @sceFactore : skin tone enhancement factor value 5963 * 5964 * RETURN : int32_t type of status 5965 * NO_ERROR -- success 5966 * none-zero failure code 5967 *==========================================================================*/ 5968 int32_t QCameraParameters::setSkinToneEnhancement(int sceFactor) 5969 { 5970 char val[16]; 5971 snprintf(val, sizeof(val), "%d", sceFactor); 5972 updateParamEntry(KEY_QC_SCE_FACTOR, val); 5973 CDBG_HIGH("%s: Setting skintone enhancement %s", __func__, val); 5974 5975 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_SCE_FACTOR, sceFactor)) { 5976 return BAD_VALUE; 5977 } 5978 5979 return NO_ERROR; 5980 } 5981 5982 /*=========================================================================== 5983 * FUNCTION : setSaturation 5984 * 5985 * DESCRIPTION: set saturation control value 5986 * 5987 * PARAMETERS : 5988 * @saturation : saturation control value 5989 * 5990 * RETURN : int32_t type of status 5991 * NO_ERROR -- success 5992 * none-zero failure code 5993 *==========================================================================*/ 5994 int32_t QCameraParameters::setSaturation(int saturation) 5995 { 5996 char val[16]; 5997 snprintf(val, sizeof(val), "%d", saturation); 5998 updateParamEntry(KEY_QC_SATURATION, val); 5999 CDBG_HIGH("%s: Setting saturation %s", __func__, val); 6000 6001 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_SATURATION, saturation)) { 6002 return BAD_VALUE; 6003 } 6004 6005 return NO_ERROR; 6006 } 6007 6008 /*=========================================================================== 6009 * FUNCTION : setContrast 6010 * 6011 * DESCRIPTION: set contrast control value 6012 * 6013 * PARAMETERS : 6014 * @contrast : contrast control value 6015 * 6016 * RETURN : int32_t type of status 6017 * NO_ERROR -- success 6018 * none-zero failure code 6019 *==========================================================================*/ 6020 int32_t QCameraParameters::setContrast(int contrast) 6021 { 6022 char val[16]; 6023 snprintf(val, sizeof(val), "%d", contrast); 6024 updateParamEntry(KEY_QC_CONTRAST, val); 6025 CDBG_HIGH("%s: Setting contrast %s", __func__, val); 6026 6027 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_CONTRAST, contrast)) { 6028 return BAD_VALUE; 6029 } 6030 6031 return NO_ERROR; 6032 } 6033 6034 /*=========================================================================== 6035 * FUNCTION : setSceneDetect 6036 * 6037 * DESCRIPTION: set scenen detect value 6038 * 6039 * PARAMETERS : 6040 * @sceneDetect : scene detect value string 6041 * 6042 * RETURN : int32_t type of status 6043 * NO_ERROR -- success 6044 * none-zero failure code 6045 *==========================================================================*/ 6046 int32_t QCameraParameters::setSceneDetect(const char *sceneDetect) 6047 { 6048 if (sceneDetect != NULL) { 6049 int32_t value = lookupAttr(ON_OFF_MODES_MAP, PARAM_MAP_SIZE(ON_OFF_MODES_MAP), 6050 sceneDetect); 6051 if (value != NAME_NOT_FOUND) { 6052 CDBG_HIGH("%s: Setting Scene Detect %s", __func__, sceneDetect); 6053 updateParamEntry(KEY_QC_SCENE_DETECT, sceneDetect); 6054 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_ASD_ENABLE, value)) { 6055 return BAD_VALUE; 6056 } 6057 return NO_ERROR; 6058 } 6059 } 6060 ALOGE("Invalid Scene Detect value: %s", 6061 (sceneDetect == NULL) ? "NULL" : sceneDetect); 6062 return BAD_VALUE; 6063 } 6064 6065 /*=========================================================================== 6066 * FUNCTION : setSensorSnapshotHDR 6067 * 6068 * DESCRIPTION: set snapshot HDR value 6069 * 6070 * PARAMETERS : 6071 * @snapshotHDR : snapshot HDR value string 6072 * 6073 * RETURN : int32_t type of status 6074 * NO_ERROR -- success 6075 * none-zero failure code 6076 *==========================================================================*/ 6077 int32_t QCameraParameters::setSensorSnapshotHDR(const char *snapshotHDR) 6078 { 6079 if (snapshotHDR != NULL) { 6080 int32_t value = lookupAttr(ON_OFF_MODES_MAP, PARAM_MAP_SIZE(ON_OFF_MODES_MAP), 6081 snapshotHDR); 6082 if (value != NAME_NOT_FOUND) { 6083 CDBG_HIGH("%s: Setting Sensor Snapshot HDR %s", __func__, snapshotHDR); 6084 updateParamEntry(KEY_QC_SENSOR_HDR, snapshotHDR); 6085 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_SENSOR_HDR, value)) { 6086 return BAD_VALUE; 6087 } 6088 return NO_ERROR; 6089 } 6090 } 6091 ALOGE("Invalid Snapshot HDR value: %s", 6092 (snapshotHDR == NULL) ? "NULL" : snapshotHDR); 6093 return BAD_VALUE; 6094 6095 } 6096 6097 6098 /*=========================================================================== 6099 * FUNCTION : setVideoHDR 6100 * 6101 * DESCRIPTION: set video HDR value 6102 * 6103 * PARAMETERS : 6104 * @videoHDR : svideo HDR value string 6105 * 6106 * RETURN : int32_t type of status 6107 * NO_ERROR -- success 6108 * none-zero failure code 6109 *==========================================================================*/ 6110 int32_t QCameraParameters::setVideoHDR(const char *videoHDR) 6111 { 6112 if (videoHDR != NULL) { 6113 int32_t value = lookupAttr(ON_OFF_MODES_MAP, PARAM_MAP_SIZE(ON_OFF_MODES_MAP), videoHDR); 6114 if (value != NAME_NOT_FOUND) { 6115 CDBG_HIGH("%s: Setting Video HDR %s", __func__, videoHDR); 6116 updateParamEntry(KEY_QC_VIDEO_HDR, videoHDR); 6117 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_VIDEO_HDR, value)) { 6118 return BAD_VALUE; 6119 } 6120 return NO_ERROR; 6121 } 6122 } 6123 ALOGE("Invalid Video HDR value: %s", 6124 (videoHDR == NULL) ? "NULL" : videoHDR); 6125 return BAD_VALUE; 6126 } 6127 6128 6129 6130 /*=========================================================================== 6131 * FUNCTION : setVtEnable 6132 * 6133 * DESCRIPTION: set vt Enable value 6134 * 6135 * PARAMETERS : 6136 * @videoHDR : svtEnable value string 6137 * 6138 * RETURN : int32_t type of status 6139 * NO_ERROR -- success 6140 * none-zero failure code 6141 *==========================================================================*/ 6142 int32_t QCameraParameters::setVtEnable(const char *vtEnable) 6143 { 6144 if (vtEnable != NULL) { 6145 int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP, 6146 PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP), vtEnable); 6147 if (value != NAME_NOT_FOUND) { 6148 CDBG_HIGH("%s: Setting Vt Enable %s", __func__, vtEnable); 6149 m_bAVTimerEnabled = true; 6150 updateParamEntry(KEY_QC_VT_ENABLE, vtEnable); 6151 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_VT, value)) { 6152 return BAD_VALUE; 6153 } 6154 return NO_ERROR; 6155 } 6156 } 6157 ALOGE("Invalid Vt Enable value: %s", 6158 (vtEnable == NULL) ? "NULL" : vtEnable); 6159 m_bAVTimerEnabled = false; 6160 return BAD_VALUE; 6161 } 6162 6163 /*=========================================================================== 6164 * FUNCTION : setFaceRecognition 6165 * 6166 * DESCRIPTION: set face recognition value 6167 * 6168 * PARAMETERS : 6169 * @faceRecog : face recognition value string 6170 * @maxFaces : number of max faces to be detected/recognized 6171 * 6172 * RETURN : int32_t type of status 6173 * NO_ERROR -- success 6174 * none-zero failure code 6175 *==========================================================================*/ 6176 int32_t QCameraParameters::setFaceRecognition(const char *faceRecog, 6177 uint32_t maxFaces) 6178 { 6179 if (faceRecog != NULL) { 6180 int32_t value = lookupAttr(ON_OFF_MODES_MAP, PARAM_MAP_SIZE(ON_OFF_MODES_MAP), faceRecog); 6181 if (value != NAME_NOT_FOUND) { 6182 CDBG_HIGH("%s: Setting face recognition %s", __func__, faceRecog); 6183 updateParamEntry(KEY_QC_FACE_RECOGNITION, faceRecog); 6184 6185 uint32_t faceProcMask = m_nFaceProcMask; 6186 if (value > 0) { 6187 faceProcMask |= CAM_FACE_PROCESS_MASK_RECOGNITION; 6188 } else { 6189 faceProcMask &= (uint32_t)(~CAM_FACE_PROCESS_MASK_RECOGNITION); 6190 } 6191 6192 if(m_nFaceProcMask == faceProcMask) { 6193 CDBG_HIGH("%s: face process mask not changed, no ops here", __func__); 6194 return NO_ERROR; 6195 } 6196 m_nFaceProcMask = faceProcMask; 6197 CDBG_HIGH("%s: FaceProcMask -> %d", __func__, m_nFaceProcMask); 6198 6199 // set parm for face process 6200 cam_fd_set_parm_t fd_set_parm; 6201 memset(&fd_set_parm, 0, sizeof(cam_fd_set_parm_t)); 6202 fd_set_parm.fd_mode = m_nFaceProcMask; 6203 fd_set_parm.num_fd = maxFaces; 6204 6205 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_FD, fd_set_parm)) { 6206 return BAD_VALUE; 6207 } 6208 return NO_ERROR; 6209 } 6210 } 6211 ALOGE("Invalid face recognition value: %s", (faceRecog == NULL) ? "NULL" : faceRecog); 6212 return BAD_VALUE; 6213 } 6214 6215 /*=========================================================================== 6216 * FUNCTION : setZoom 6217 * 6218 * DESCRIPTION: set zoom level 6219 * 6220 * PARAMETERS : 6221 * @zoom_level : zoom level 6222 * 6223 * RETURN : int32_t type of status 6224 * NO_ERROR -- success 6225 * none-zero failure code 6226 *==========================================================================*/ 6227 int32_t QCameraParameters::setZoom(int zoom_level) 6228 { 6229 char val[16]; 6230 snprintf(val, sizeof(val), "%d", zoom_level); 6231 updateParamEntry(KEY_ZOOM, val); 6232 CDBG_HIGH("%s: zoom level: %d", __func__, zoom_level); 6233 mZoomLevel = zoom_level; 6234 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_ZOOM, zoom_level)) { 6235 return BAD_VALUE; 6236 } 6237 6238 return NO_ERROR; 6239 } 6240 6241 /*=========================================================================== 6242 * FUNCTION : setISOValue 6243 * 6244 * DESCRIPTION: set ISO value 6245 * 6246 * PARAMETERS : 6247 * @isoValue : ISO value string 6248 * 6249 * RETURN : int32_t type of status 6250 * NO_ERROR -- success 6251 * none-zero failure code 6252 *==========================================================================*/ 6253 int32_t QCameraParameters::setISOValue(const char *isoValue) 6254 { 6255 if (isoValue != NULL) { 6256 if (!strcmp(isoValue, ISO_MANUAL)) { 6257 CDBG("%s, iso manual mode - use continuous iso", __func__); 6258 updateParamEntry(KEY_QC_ISO_MODE, isoValue); 6259 return NO_ERROR; 6260 } 6261 int32_t value = lookupAttr(ISO_MODES_MAP, PARAM_MAP_SIZE(ISO_MODES_MAP), isoValue); 6262 if (value != NAME_NOT_FOUND) { 6263 CDBG_HIGH("%s: Setting ISO value %s", __func__, isoValue); 6264 updateParamEntry(KEY_QC_ISO_MODE, isoValue); 6265 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_ISO, value)) { 6266 return BAD_VALUE; 6267 } 6268 return NO_ERROR; 6269 } 6270 } 6271 ALOGE("Invalid ISO value: %s", 6272 (isoValue == NULL) ? "NULL" : isoValue); 6273 return BAD_VALUE; 6274 } 6275 6276 6277 /*=========================================================================== 6278 * FUNCTION : setContinuousISO 6279 * 6280 * DESCRIPTION: set continuous ISO value 6281 * 6282 * PARAMETERS : 6283 * @params : ISO value parameter 6284 * 6285 * RETURN : int32_t type of status 6286 * NO_ERROR -- success 6287 * none-zero failure code 6288 *==========================================================================*/ 6289 int32_t QCameraParameters::setContinuousISO(const QCameraParameters& params) 6290 { 6291 const char *iso = params.get(KEY_QC_ISO_MODE); 6292 CDBG("%s, current iso mode: %s", __func__, iso); 6293 6294 if (iso != NULL) { 6295 if (strcmp(iso, ISO_MANUAL)) { 6296 CDBG("%s, dont set iso to back-end.", __func__); 6297 return NO_ERROR; 6298 } 6299 } 6300 6301 const char *str = params.get(KEY_QC_CONTINUOUS_ISO); 6302 const char *prev_str = get(KEY_QC_CONTINUOUS_ISO); 6303 if (str != NULL) { 6304 if (prev_str == NULL || 6305 strcmp(str, prev_str) != 0) { 6306 return setContinuousISO(str); 6307 } 6308 } 6309 return NO_ERROR; 6310 } 6311 6312 /*=========================================================================== 6313 * FUNCTION : setExposureTime 6314 * 6315 * DESCRIPTION: set exposure time 6316 * 6317 * PARAMETERS : 6318 * @expTimeStr : string of exposure time in ms 6319 * 6320 * RETURN : int32_t type of status 6321 * NO_ERROR -- success 6322 * none-zero failure code 6323 *==========================================================================*/ 6324 int32_t QCameraParameters::setExposureTime(const char *expTimeStr) 6325 { 6326 if (expTimeStr != NULL) { 6327 double expTimeMs = atof(expTimeStr); 6328 //input is in milli seconds. Convert to nano sec for backend 6329 int64_t expTimeNs = ((int64_t)expTimeMs)*1000000L; 6330 6331 // expTime == 0 means not to use manual exposure time. 6332 if ((0 <= expTimeNs) && 6333 ((expTimeNs == 0) || 6334 ((expTimeNs >= m_pCapability->exposure_time_range[0]) && 6335 (expTimeNs <= m_pCapability->exposure_time_range[1])))) { 6336 CDBG_HIGH("%s, exposure time: %f ms", __func__, expTimeMs); 6337 updateParamEntry(KEY_QC_EXPOSURE_TIME, expTimeStr); 6338 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_EXPOSURE_TIME, 6339 (uint64_t)expTimeNs)) { 6340 return BAD_VALUE; 6341 } 6342 return NO_ERROR; 6343 } 6344 } 6345 6346 ALOGE("Invalid exposure time, value: %s", 6347 (expTimeStr == NULL) ? "NULL" : expTimeStr); 6348 return BAD_VALUE; 6349 } 6350 6351 /*=========================================================================== 6352 * FUNCTION : setLongshotEnable 6353 * 6354 * DESCRIPTION: set a flag indicating longshot mode 6355 * 6356 * PARAMETERS : 6357 * @enable : true - Longshot enabled 6358 * false - Longshot disabled 6359 * 6360 * RETURN : int32_t type of status 6361 * NO_ERROR -- success 6362 * none-zero failure code 6363 *==========================================================================*/ 6364 int32_t QCameraParameters::setLongshotEnable(bool enable) 6365 { 6366 int32_t rc = NO_ERROR; 6367 int8_t value = enable ? 1 : 0; 6368 6369 if(initBatchUpdate(m_pParamBuf) < 0 ) { 6370 ALOGE("%s:Failed to initialize group update table", __func__); 6371 return BAD_TYPE; 6372 } 6373 6374 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_LONGSHOT_ENABLE, value)) { 6375 ALOGE("%s:Failed to update table", __func__); 6376 return BAD_VALUE; 6377 } 6378 6379 rc = commitSetBatch(); 6380 if (rc != NO_ERROR) { 6381 ALOGE("%s:Failed to parameter changes", __func__); 6382 return rc; 6383 } 6384 6385 return rc; 6386 } 6387 6388 /*=========================================================================== 6389 * FUNCTION : setFlash 6390 * 6391 * DESCRIPTION: set flash mode 6392 * 6393 * PARAMETERS : 6394 * @flashStr : LED flash mode value string 6395 * 6396 * RETURN : int32_t type of status 6397 * NO_ERROR -- success 6398 * none-zero failure code 6399 *==========================================================================*/ 6400 int32_t QCameraParameters::setFlash(const char *flashStr) 6401 { 6402 if (flashStr != NULL) { 6403 int32_t value = lookupAttr(FLASH_MODES_MAP, PARAM_MAP_SIZE(FLASH_MODES_MAP), flashStr); 6404 if (value != NAME_NOT_FOUND) { 6405 CDBG_HIGH("%s: Setting Flash value %s", __func__, flashStr); 6406 updateParamEntry(KEY_FLASH_MODE, flashStr); 6407 mFlashValue = value; 6408 return NO_ERROR; 6409 } 6410 } 6411 ALOGE("Invalid flash value: %s", (flashStr == NULL) ? "NULL" : flashStr); 6412 return BAD_VALUE; 6413 } 6414 6415 /*=========================================================================== 6416 * FUNCTION : updateFlashMode 6417 * 6418 * DESCRIPTION: update flash mode 6419 * 6420 * PARAMETERS : 6421 * @flashStr : LED flash mode value 6422 * 6423 * RETURN : int32_t type of status 6424 * NO_ERROR -- success 6425 * none-zero failure code 6426 *==========================================================================*/ 6427 int32_t QCameraParameters::updateFlashMode(cam_flash_mode_t flash_mode) 6428 { 6429 int32_t rc = NO_ERROR; 6430 if (flash_mode >= CAM_FLASH_MODE_MAX) { 6431 CDBG_HIGH("%s: Error!! Invalid flash mode (%d)", __func__, flash_mode); 6432 return BAD_VALUE; 6433 } 6434 CDBG_HIGH("%s: Setting Flash mode from EZTune %d", __func__, flash_mode); 6435 6436 const char *flash_mode_str = lookupNameByValue(FLASH_MODES_MAP, 6437 PARAM_MAP_SIZE(FLASH_MODES_MAP), flash_mode); 6438 if(initBatchUpdate(m_pParamBuf) < 0 ) { 6439 ALOGE("%s:Failed to initialize group update table", __func__); 6440 return BAD_TYPE; 6441 } 6442 rc = setFlash(flash_mode_str); 6443 if (rc != NO_ERROR) { 6444 ALOGE("%s:Failed to update Flash mode", __func__); 6445 return rc; 6446 } 6447 6448 CDBG_HIGH("%s: Setting Flash mode %d", __func__, mFlashValue); 6449 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_LED_MODE, mFlashValue)) { 6450 ALOGE("%s:Failed to set led mode", __func__); 6451 return BAD_VALUE; 6452 } 6453 6454 rc = commitSetBatch(); 6455 if (rc != NO_ERROR) { 6456 ALOGE("%s:Failed to commit parameters", __func__); 6457 return rc; 6458 } 6459 6460 return NO_ERROR; 6461 } 6462 6463 6464 /*=========================================================================== 6465 * FUNCTION : configureFlash 6466 * 6467 * DESCRIPTION: configure Flash Bracketing. 6468 * 6469 * PARAMETERS : 6470 * @frame_config : output configaration structure to fill in. 6471 * 6472 * RETURN : int32_t type of status 6473 * NO_ERROR -- success 6474 * none-zero failure code 6475 *==========================================================================*/ 6476 int32_t QCameraParameters::configureFlash(cam_capture_frame_config_t &frame_config) 6477 { 6478 CDBG_HIGH("%s: E",__func__); 6479 int32_t rc = NO_ERROR; 6480 uint32_t i = 0; 6481 6482 if (isChromaFlashEnabled()) { 6483 6484 rc = setToneMapMode(false, false); 6485 if (rc != NO_ERROR) { 6486 ALOGE("%s: Failed to configure tone map", __func__); 6487 return rc; 6488 } 6489 6490 rc = setCDSMode(CAM_CDS_MODE_OFF, false); 6491 if (rc != NO_ERROR) { 6492 ALOGE("%s: Failed to configure csd mode", __func__); 6493 return rc; 6494 } 6495 6496 CDBG_HIGH("%s : Enable Chroma Flash capture", __func__); 6497 cam_flash_mode_t flash_mode = CAM_FLASH_MODE_OFF; 6498 frame_config.num_batch = 6499 m_pCapability->chroma_flash_settings_need.burst_count; 6500 if (frame_config.num_batch > CAM_MAX_FLASH_BRACKETING) { 6501 frame_config.num_batch = CAM_MAX_FLASH_BRACKETING; 6502 } 6503 for (i = 0; i < frame_config.num_batch; i++) { 6504 flash_mode = (m_pCapability->chroma_flash_settings_need.flash_bracketing[i]) ? 6505 CAM_FLASH_MODE_ON:CAM_FLASH_MODE_OFF; 6506 frame_config.configs[i].num_frames = 1; 6507 frame_config.configs[i].type = CAM_CAPTURE_FLASH; 6508 frame_config.configs[i].flash_mode = flash_mode; 6509 } 6510 } else if (mFlashValue != CAM_FLASH_MODE_OFF) { 6511 frame_config.num_batch = 1; 6512 for (i = 0; i < frame_config.num_batch; i++) { 6513 frame_config.configs[i].num_frames = 1; 6514 frame_config.configs[i].type = CAM_CAPTURE_FLASH; 6515 frame_config.configs[i].flash_mode =(cam_flash_mode_t)mFlashValue; 6516 } 6517 } 6518 6519 CDBG("%s: Chroma Flash cnt = %d", __func__,frame_config.num_batch); 6520 return rc; 6521 } 6522 6523 /*=========================================================================== 6524 * FUNCTION : configureHDRBracketing 6525 * 6526 * DESCRIPTION: configure HDR Bracketing. 6527 * 6528 * PARAMETERS : 6529 * @frame_config : output configaration structure to fill in. 6530 * 6531 * RETURN : int32_t type of status 6532 * NO_ERROR -- success 6533 * none-zero failure code 6534 *==========================================================================*/ 6535 int32_t QCameraParameters::configureHDRBracketing(cam_capture_frame_config_t &frame_config) 6536 { 6537 CDBG_HIGH("%s: E",__func__); 6538 int32_t rc = NO_ERROR; 6539 uint32_t i = 0; 6540 6541 uint32_t hdrFrameCount = m_pCapability->hdr_bracketing_setting.num_frames; 6542 CDBG_HIGH("%s : HDR values %d, %d frame count: %u", 6543 __func__, 6544 (int8_t) m_pCapability->hdr_bracketing_setting.exp_val.values[0], 6545 (int8_t) m_pCapability->hdr_bracketing_setting.exp_val.values[1], 6546 hdrFrameCount); 6547 6548 frame_config.num_batch = hdrFrameCount; 6549 6550 cam_bracket_mode mode = 6551 m_pCapability->hdr_bracketing_setting.exp_val.mode; 6552 if (mode == CAM_EXP_BRACKETING_ON) { 6553 rc = setToneMapMode(false, true); 6554 if (rc != NO_ERROR) { 6555 ALOGE("%s: Failed to disable tone map during HDR", __func__); 6556 } 6557 } 6558 for (i = 0; i < frame_config.num_batch; i++) { 6559 frame_config.configs[i].num_frames = 1; 6560 frame_config.configs[i].type = CAM_CAPTURE_BRACKETING; 6561 frame_config.configs[i].hdr_mode.mode = mode; 6562 frame_config.configs[i].hdr_mode.values = 6563 m_pCapability->hdr_bracketing_setting.exp_val.values[i]; 6564 CDBG("%s: exp values %d", __func__, 6565 (int)frame_config.configs[i].hdr_mode.values); 6566 } 6567 return rc; 6568 } 6569 6570 /*=========================================================================== 6571 * FUNCTION : configureAEBracketing 6572 * 6573 * DESCRIPTION: configure AE Bracketing. 6574 * 6575 * PARAMETERS : 6576 * @frame_config : output configaration structure to fill in. 6577 * 6578 * RETURN : int32_t type of status 6579 * NO_ERROR -- success 6580 * none-zero failure code 6581 *==========================================================================*/ 6582 int32_t QCameraParameters::configureAEBracketing(cam_capture_frame_config_t &frame_config) 6583 { 6584 CDBG_HIGH("%s: E",__func__); 6585 int32_t rc = NO_ERROR; 6586 uint32_t i = 0; 6587 char exp_value[MAX_EXP_BRACKETING_LENGTH]; 6588 6589 rc = setToneMapMode(false, true); 6590 if (rc != NO_ERROR) { 6591 CDBG_HIGH("%s: Failed to disable tone map during AEBracketing", __func__); 6592 } 6593 6594 uint32_t burstCount = 0; 6595 const char *str_val = m_AEBracketingClient.values; 6596 if ((str_val != NULL) && (strlen(str_val) > 0)) { 6597 char prop[PROPERTY_VALUE_MAX]; 6598 memset(prop, 0, sizeof(prop)); 6599 strlcpy(prop, str_val, PROPERTY_VALUE_MAX); 6600 char *saveptr = NULL; 6601 char *token = strtok_r(prop, ",", &saveptr); 6602 if (token != NULL) { 6603 exp_value[burstCount++] = (char)atoi(token); 6604 while (token != NULL) { 6605 token = strtok_r(NULL, ",", &saveptr); 6606 if (token != NULL) { 6607 exp_value[burstCount++] = (char)atoi(token); 6608 } 6609 } 6610 } 6611 } 6612 6613 frame_config.num_batch = burstCount; 6614 cam_bracket_mode mode = m_AEBracketingClient.mode; 6615 6616 for (i = 0; i < frame_config.num_batch; i++) { 6617 frame_config.configs[i].num_frames = 1; 6618 frame_config.configs[i].type = CAM_CAPTURE_BRACKETING; 6619 frame_config.configs[i].hdr_mode.mode = mode; 6620 frame_config.configs[i].hdr_mode.values = 6621 m_AEBracketingClient.values[i]; 6622 CDBG("%s: exp values %d", __func__, (int)m_AEBracketingClient.values[i]); 6623 } 6624 6625 CDBG_HIGH("%s: num_frame = %d X",__func__, burstCount); 6626 return rc; 6627 } 6628 6629 /*=========================================================================== 6630 * FUNCTION : configFrameCapture 6631 * 6632 * DESCRIPTION: configuration for ZSL special captures (FLASH/HDR etc) 6633 * 6634 * PARAMETERS : 6635 * @commitSettings : flag to enable or disable commit this this settings 6636 * 6637 * RETURN : int32_t type of status 6638 * NO_ERROR -- success 6639 * none-zero failure code 6640 *==========================================================================*/ 6641 int32_t QCameraParameters::configFrameCapture(bool commitSettings) 6642 { 6643 int32_t rc = NO_ERROR; 6644 memset(&m_captureFrameConfig, 0, sizeof(cam_capture_frame_config_t)); 6645 6646 if (commitSettings) { 6647 if(initBatchUpdate(m_pParamBuf) < 0 ) { 6648 ALOGE("%s:Failed to initialize group update table", __func__); 6649 return BAD_TYPE; 6650 } 6651 } 6652 6653 if (isChromaFlashEnabled() || mFlashValue != CAM_FLASH_MODE_OFF) { 6654 configureFlash(m_captureFrameConfig); 6655 } else if(isHDREnabled()) { 6656 configureHDRBracketing (m_captureFrameConfig); 6657 } else if(isAEBracketEnabled()) { 6658 configureAEBracketing (m_captureFrameConfig); 6659 } 6660 6661 rc = ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_CAPTURE_FRAME_CONFIG, 6662 (cam_capture_frame_config_t)m_captureFrameConfig); 6663 if (rc != NO_ERROR) { 6664 rc = BAD_VALUE; 6665 ALOGE("%s:Failed to set capture settings", __func__); 6666 return rc; 6667 } 6668 6669 if (commitSettings) { 6670 rc = commitSetBatch(); 6671 if (rc != NO_ERROR) { 6672 ALOGE("%s:Failed to commit parameters", __func__); 6673 return rc; 6674 } 6675 } 6676 return rc; 6677 } 6678 6679 /*=========================================================================== 6680 * FUNCTION : resetFrameCapture 6681 * 6682 * DESCRIPTION: reset special captures settings(FLASH/HDR etc) 6683 * 6684 * PARAMETERS : 6685 * @commitSettings : flag to enable or disable commit this this settings 6686 * 6687 * RETURN : int32_t type of status 6688 * NO_ERROR -- success 6689 * none-zero failure code 6690 *==========================================================================*/ 6691 int32_t QCameraParameters::resetFrameCapture(bool commitSettings) 6692 { 6693 int32_t rc = NO_ERROR, i = 0; 6694 memset(&m_captureFrameConfig, 0, sizeof(cam_capture_frame_config_t)); 6695 6696 if (commitSettings) { 6697 if(initBatchUpdate(m_pParamBuf) < 0 ) { 6698 ALOGE("%s:Failed to initialize group update table", __func__); 6699 return BAD_TYPE; 6700 } 6701 } 6702 6703 if (isHDREnabled() || isAEBracketEnabled()) { 6704 rc = setToneMapMode(true, true); 6705 if (rc != NO_ERROR) { 6706 CDBG_HIGH("%s: Failed to enable tone map during HDR/AEBracketing", __func__); 6707 } 6708 rc = stopAEBracket(); 6709 } else if (isChromaFlashEnabled()) { 6710 rc = setToneMapMode(true, false); 6711 if (rc != NO_ERROR) { 6712 CDBG_HIGH("%s: Failed to enable tone map during chroma flash", __func__); 6713 } 6714 6715 rc = setCDSMode(mCds_mode, false); 6716 if (rc != NO_ERROR) { 6717 ALOGE("%s: Failed to configure csd mode", __func__); 6718 return rc; 6719 } 6720 } 6721 6722 rc = ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_CAPTURE_FRAME_CONFIG, 6723 (cam_capture_frame_config_t)m_captureFrameConfig); 6724 if (rc != NO_ERROR) { 6725 rc = BAD_VALUE; 6726 ALOGE("%s:Failed to set capture settings", __func__); 6727 return rc; 6728 } 6729 6730 if (commitSettings) { 6731 rc = commitSetBatch(); 6732 if (rc != NO_ERROR) { 6733 ALOGE("%s:Failed to commit parameters", __func__); 6734 return rc; 6735 } 6736 } 6737 return rc; 6738 } 6739 6740 /*=========================================================================== 6741 * FUNCTION : setAecLock 6742 * 6743 * DESCRIPTION: set AEC lock value 6744 * 6745 * PARAMETERS : 6746 * @aecLockStr : AEC lock value string 6747 * 6748 * RETURN : int32_t type of status 6749 * NO_ERROR -- success 6750 * none-zero failure code 6751 *==========================================================================*/ 6752 int32_t QCameraParameters::setAecLock(const char *aecLockStr) 6753 { 6754 if (aecLockStr != NULL) { 6755 int32_t value = lookupAttr(TRUE_FALSE_MODES_MAP, PARAM_MAP_SIZE(TRUE_FALSE_MODES_MAP), 6756 aecLockStr); 6757 if (value != NAME_NOT_FOUND) { 6758 CDBG_HIGH("%s: Setting AECLock value %s", __func__, aecLockStr); 6759 updateParamEntry(KEY_AUTO_EXPOSURE_LOCK, aecLockStr); 6760 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, 6761 CAM_INTF_PARM_AEC_LOCK, (uint32_t)value)) { 6762 return BAD_VALUE; 6763 } 6764 return NO_ERROR; 6765 } 6766 } 6767 ALOGE("Invalid AECLock value: %s", 6768 (aecLockStr == NULL) ? "NULL" : aecLockStr); 6769 return BAD_VALUE; 6770 } 6771 6772 /*=========================================================================== 6773 * FUNCTION : setAwbLock 6774 * 6775 * DESCRIPTION: set AWB lock value 6776 * 6777 * PARAMETERS : 6778 * @awbLockStr : AWB lock value string 6779 * 6780 * RETURN : int32_t type of status 6781 * NO_ERROR -- success 6782 * none-zero failure code 6783 *==========================================================================*/ 6784 int32_t QCameraParameters::setAwbLock(const char *awbLockStr) 6785 { 6786 if (awbLockStr != NULL) { 6787 int32_t value = lookupAttr(TRUE_FALSE_MODES_MAP, PARAM_MAP_SIZE(TRUE_FALSE_MODES_MAP), 6788 awbLockStr); 6789 if (value != NAME_NOT_FOUND) { 6790 CDBG_HIGH("%s: Setting AWBLock value %s", __func__, awbLockStr); 6791 updateParamEntry(KEY_AUTO_WHITEBALANCE_LOCK, awbLockStr); 6792 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, 6793 CAM_INTF_PARM_AWB_LOCK, (uint32_t)value)) { 6794 return BAD_VALUE; 6795 } 6796 return NO_ERROR; 6797 } 6798 } 6799 ALOGE("Invalid AWBLock value: %s", (awbLockStr == NULL) ? "NULL" : awbLockStr); 6800 return BAD_VALUE; 6801 } 6802 6803 /*=========================================================================== 6804 * FUNCTION : setMCEValue 6805 * 6806 * DESCRIPTION: set memory color enhancement value 6807 * 6808 * PARAMETERS : 6809 * @mceStr : MCE value string 6810 * 6811 * RETURN : int32_t type of status 6812 * NO_ERROR -- success 6813 * none-zero failure code 6814 *==========================================================================*/ 6815 int32_t QCameraParameters::setMCEValue(const char *mceStr) 6816 { 6817 if (mceStr != NULL) { 6818 int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP, 6819 PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP), mceStr); 6820 if (value != NAME_NOT_FOUND) { 6821 CDBG_HIGH("%s: Setting AWBLock value %s", __func__, mceStr); 6822 updateParamEntry(KEY_QC_MEMORY_COLOR_ENHANCEMENT, mceStr); 6823 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_MCE, value)) { 6824 return BAD_VALUE; 6825 } 6826 return NO_ERROR; 6827 } 6828 } 6829 ALOGE("Invalid MCE value: %s", (mceStr == NULL) ? "NULL" : mceStr); 6830 return BAD_VALUE; 6831 } 6832 6833 /*=========================================================================== 6834 * FUNCTION : setTintlessValue 6835 * 6836 * DESCRIPTION: enable/disable tintless from user setting 6837 * 6838 * PARAMETERS : 6839 * @params : user setting parameters 6840 * 6841 * RETURN : int32_t type of status 6842 * NO_ERROR -- success 6843 * none-zero failure code 6844 *==========================================================================*/ 6845 int32_t QCameraParameters::setTintlessValue(const QCameraParameters& params) 6846 { 6847 const char *str = params.get(KEY_QC_TINTLESS_ENABLE); 6848 const char *prev_str = get(KEY_QC_TINTLESS_ENABLE); 6849 char prop[PROPERTY_VALUE_MAX]; 6850 6851 memset(prop, 0, sizeof(prop)); 6852 property_get("persist.camera.tintless", prop, VALUE_ENABLE); 6853 if (str != NULL) { 6854 if (prev_str == NULL || 6855 strcmp(str, prev_str) != 0) { 6856 return setTintlessValue(str); 6857 } 6858 } else { 6859 if (prev_str == NULL || 6860 strcmp(prev_str, prop) != 0 ) { 6861 setTintlessValue(prop); 6862 } 6863 } 6864 6865 return NO_ERROR; 6866 } 6867 6868 /*=========================================================================== 6869 * FUNCTION : setTintless 6870 * 6871 * DESCRIPTION: set tintless mode 6872 * 6873 * PARAMETERS : 6874 * @enable : 1 = enable, 0 = disable 6875 * 6876 * RETURN : int32_t type of status 6877 * NO_ERROR -- success 6878 * none-zero failure code 6879 *==========================================================================*/ 6880 void QCameraParameters::setTintless(bool enable) 6881 { 6882 if (enable) { 6883 setTintlessValue(VALUE_ENABLE); 6884 } else { 6885 setTintlessValue(VALUE_DISABLE); 6886 } 6887 } 6888 6889 /*=========================================================================== 6890 * FUNCTION : setTintlessValue 6891 * 6892 * DESCRIPTION: set tintless value 6893 * 6894 * PARAMETERS : 6895 * @tintStr : Tintless value string 6896 * 6897 * RETURN : int32_t type of status 6898 * NO_ERROR -- success 6899 * none-zero failure code 6900 *==========================================================================*/ 6901 int32_t QCameraParameters::setTintlessValue(const char *tintStr) 6902 { 6903 if (tintStr != NULL) { 6904 int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP, 6905 PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP), tintStr); 6906 if (value != NAME_NOT_FOUND) { 6907 CDBG_HIGH("%s: Setting Tintless value %s", __func__, tintStr); 6908 updateParamEntry(KEY_QC_TINTLESS_ENABLE, tintStr); 6909 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_TINTLESS, value)) { 6910 return BAD_VALUE; 6911 } 6912 return NO_ERROR; 6913 } 6914 } 6915 ALOGE("Invalid Tintless value: %s", (tintStr == NULL) ? "NULL" : tintStr); 6916 return BAD_VALUE; 6917 } 6918 6919 /*=========================================================================== 6920 * FUNCTION : setCDSMode 6921 * 6922 * DESCRIPTION: Set CDS mode 6923 * 6924 * PARAMETERS : 6925 * @params : user setting parameters 6926 * 6927 * RETURN : int32_t type of status 6928 * NO_ERROR -- success 6929 * none-zero failure code 6930 *==========================================================================*/ 6931 int32_t QCameraParameters::setCDSMode(const QCameraParameters& params) 6932 { 6933 const char *str = params.get(KEY_QC_CDS_MODE); 6934 const char *prev_str = get(KEY_QC_CDS_MODE); 6935 const char *video_str = params.get(KEY_QC_VIDEO_CDS_MODE); 6936 const char *video_prev_str = get(KEY_QC_VIDEO_CDS_MODE); 6937 int32_t rc = NO_ERROR; 6938 6939 if (m_bRecordingHint_new == true) { 6940 if (video_str) { 6941 if ((video_prev_str == NULL) || (strcmp(video_str, video_prev_str) != 0)) { 6942 int32_t cds_mode = lookupAttr(CDS_MODES_MAP, PARAM_MAP_SIZE(CDS_MODES_MAP), 6943 video_str); 6944 if (cds_mode != NAME_NOT_FOUND) { 6945 updateParamEntry(KEY_QC_VIDEO_CDS_MODE, video_str); 6946 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_CDS_MODE, cds_mode)) { 6947 ALOGE("%s:Failed CDS MODE to update table", __func__); 6948 rc = BAD_VALUE; 6949 } else { 6950 CDBG("%s: Set CDS in video mode = %d", __func__, cds_mode); 6951 mCds_mode = cds_mode; 6952 } 6953 } else { 6954 ALOGE("%s: Invalid argument for video CDS MODE %d", __func__, cds_mode); 6955 rc = BAD_VALUE; 6956 } 6957 } 6958 } else { 6959 char video_prop[PROPERTY_VALUE_MAX]; 6960 memset(video_prop, 0, sizeof(video_prop)); 6961 property_get("persist.camera.video.CDS", video_prop, CDS_MODE_ON); 6962 int32_t cds_mode = lookupAttr(CDS_MODES_MAP, PARAM_MAP_SIZE(CDS_MODES_MAP), 6963 video_prop); 6964 if (cds_mode != NAME_NOT_FOUND) { 6965 updateParamEntry(KEY_QC_VIDEO_CDS_MODE, video_prop); 6966 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_CDS_MODE, cds_mode)) { 6967 ALOGE("%s:Failed CDS MODE to update table", __func__); 6968 rc = BAD_VALUE; 6969 } else { 6970 CDBG("%s: Set CDS in video mode from setprop = %d", __func__, cds_mode); 6971 mCds_mode = cds_mode; 6972 } 6973 } else { 6974 ALOGE("%s: Invalid prop for video CDS MODE %d", __func__, cds_mode); 6975 rc = BAD_VALUE; 6976 } 6977 } 6978 } else { 6979 if (str) { 6980 if ((prev_str == NULL) || (strcmp(str, prev_str) != 0)) { 6981 int32_t cds_mode = lookupAttr(CDS_MODES_MAP, PARAM_MAP_SIZE(CDS_MODES_MAP), 6982 str); 6983 if (cds_mode != NAME_NOT_FOUND) { 6984 updateParamEntry(KEY_QC_CDS_MODE, str); 6985 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_CDS_MODE, cds_mode)) { 6986 ALOGE("%s:Failed CDS MODE to update table", __func__); 6987 rc = BAD_VALUE; 6988 } else { 6989 CDBG("%s: Set CDS in capture mode = %d", __func__, cds_mode); 6990 mCds_mode = cds_mode; 6991 } 6992 } else { 6993 ALOGE("%s: Invalid argument for snapshot CDS MODE %d", __func__, cds_mode); 6994 rc = BAD_VALUE; 6995 } 6996 } 6997 } else { 6998 char prop[PROPERTY_VALUE_MAX]; 6999 memset(prop, 0, sizeof(prop)); 7000 property_get("persist.camera.CDS", prop, CDS_MODE_ON); 7001 int32_t cds_mode = lookupAttr(CDS_MODES_MAP, PARAM_MAP_SIZE(CDS_MODES_MAP), 7002 prop); 7003 if (cds_mode != NAME_NOT_FOUND) { 7004 updateParamEntry(KEY_QC_CDS_MODE, prop); 7005 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_CDS_MODE, cds_mode)) { 7006 ALOGE("%s:Failed CDS MODE to update table", __func__); 7007 rc = BAD_VALUE; 7008 } else { 7009 CDBG("%s: Set CDS in snapshot mode from setprop = %d", __func__, cds_mode); 7010 mCds_mode = cds_mode; 7011 } 7012 } else { 7013 ALOGE("%s: Invalid prop for snapshot CDS MODE %d", __func__, cds_mode); 7014 rc = BAD_VALUE; 7015 } 7016 } 7017 } 7018 7019 return rc; 7020 } 7021 7022 /*=========================================================================== 7023 * FUNCTION : setDISValue 7024 * 7025 * DESCRIPTION: set DIS value 7026 * 7027 * PARAMETERS : 7028 * @disStr : DIS value string 7029 * 7030 * RETURN : int32_t type of status 7031 * NO_ERROR -- success 7032 * none-zero failure code 7033 *==========================================================================*/ 7034 int32_t QCameraParameters::setDISValue(const char *disStr) 7035 { 7036 if (disStr != NULL) { 7037 int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP, 7038 PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP), disStr); 7039 if (value != NAME_NOT_FOUND) { 7040 //For some IS types (like EIS 2.0), when DIS value is changed, we need to restart 7041 //preview because of topology change in backend. But, for now, restart preview 7042 //for all IS types. 7043 m_bNeedRestart = true; 7044 CDBG_HIGH("%s: Setting DIS value %s", __func__, disStr); 7045 updateParamEntry(KEY_QC_DIS, disStr); 7046 if (!(strcmp(disStr,"enable"))) { 7047 m_bDISEnabled = true; 7048 } else { 7049 m_bDISEnabled = false; 7050 } 7051 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_DIS_ENABLE, value)) { 7052 return BAD_VALUE; 7053 } 7054 return NO_ERROR; 7055 } 7056 } 7057 ALOGE("Invalid DIS value: %s", (disStr == NULL) ? "NULL" : disStr); 7058 m_bDISEnabled = false; 7059 return BAD_VALUE; 7060 } 7061 7062 /*=========================================================================== 7063 * FUNCTION : updateOisValue 7064 * 7065 * DESCRIPTION: update OIS value 7066 * 7067 * PARAMETERS : 7068 * @oisValue : OIS value TRUE/FALSE 7069 * 7070 * RETURN : int32_t type of status 7071 * NO_ERROR -- success 7072 * none-zero failure code 7073 *==========================================================================*/ 7074 int32_t QCameraParameters::updateOisValue(bool oisValue) 7075 { 7076 uint8_t enable = 0; 7077 int32_t rc = NO_ERROR; 7078 7079 // Check for OIS disable 7080 char ois_prop[PROPERTY_VALUE_MAX]; 7081 memset(ois_prop, 0, sizeof(ois_prop)); 7082 property_get("persist.camera.ois.disable", ois_prop, "0"); 7083 uint8_t ois_disable = (uint8_t)atoi(ois_prop); 7084 7085 //Enable OIS if it is camera mode or Camcoder 4K mode 7086 if (!m_bRecordingHint || (is4k2kVideoResolution() && m_bRecordingHint)) { 7087 enable = 1; 7088 CDBG_HIGH("%s: Valid OIS mode!! ", __func__); 7089 } 7090 // Disable OIS if setprop is set 7091 if (ois_disable || !oisValue) { 7092 //Disable OIS 7093 enable = 0; 7094 CDBG_HIGH("%s: Disable OIS mode!! ois_disable(%d) oisValue(%d)", 7095 __func__, ois_disable, oisValue); 7096 7097 } 7098 m_bOISEnabled = enable; 7099 if (m_bOISEnabled) { 7100 updateParamEntry(KEY_QC_OIS, VALUE_ENABLE); 7101 } else { 7102 updateParamEntry(KEY_QC_OIS, VALUE_DISABLE); 7103 } 7104 7105 if (initBatchUpdate(m_pParamBuf) < 0 ) { 7106 ALOGE("%s:Failed to initialize group update table", __func__); 7107 return BAD_TYPE; 7108 } 7109 7110 CDBG_HIGH("%s: Sending OIS mode (%d)", __func__, enable); 7111 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_META_LENS_OPT_STAB_MODE, enable)) { 7112 ALOGE("%s:Failed to update table", __func__); 7113 return BAD_VALUE; 7114 } 7115 7116 rc = commitSetBatch(); 7117 if (rc != NO_ERROR) { 7118 ALOGE("%s:Failed to parameter changes", __func__); 7119 return rc; 7120 } 7121 7122 return rc; 7123 } 7124 7125 /*=========================================================================== 7126 * FUNCTION : setHighFrameRate 7127 * 7128 * DESCRIPTION: set high frame rate 7129 * 7130 * PARAMETERS : 7131 * @hfrMode : HFR mode 7132 * 7133 * RETURN : int32_t type of status 7134 * NO_ERROR -- success 7135 * none-zero failure code 7136 *==========================================================================*/ 7137 int32_t QCameraParameters::setHighFrameRate(const int32_t hfrMode) 7138 { 7139 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_HFR, hfrMode)) { 7140 return BAD_VALUE; 7141 } 7142 7143 return NO_ERROR; 7144 } 7145 7146 /*=========================================================================== 7147 * FUNCTION : setLensShadeValue 7148 * 7149 * DESCRIPTION: set lens shade value 7150 * 7151 * PARAMETERS : 7152 * @lensSahdeStr : lens shade value string 7153 * 7154 * RETURN : int32_t type of status 7155 * NO_ERROR -- success 7156 * none-zero failure code 7157 *==========================================================================*/ 7158 int32_t QCameraParameters::setLensShadeValue(const char *lensShadeStr) 7159 { 7160 if (lensShadeStr != NULL) { 7161 int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP, 7162 PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP), lensShadeStr); 7163 if (value != NAME_NOT_FOUND) { 7164 CDBG_HIGH("%s: Setting LensShade value %s", __func__, lensShadeStr); 7165 updateParamEntry(KEY_QC_LENSSHADE, lensShadeStr); 7166 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_ROLLOFF, value)) { 7167 return BAD_VALUE; 7168 } 7169 return NO_ERROR; 7170 } 7171 } 7172 ALOGE("Invalid LensShade value: %s", 7173 (lensShadeStr == NULL) ? "NULL" : lensShadeStr); 7174 return BAD_VALUE; 7175 } 7176 7177 /*=========================================================================== 7178 * FUNCTION : setExposureCompensation 7179 * 7180 * DESCRIPTION: set exposure compensation value 7181 * 7182 * PARAMETERS : 7183 * @expComp : exposure compensation value 7184 * 7185 * RETURN : int32_t type of status 7186 * NO_ERROR -- success 7187 * none-zero failure code 7188 *==========================================================================*/ 7189 int32_t QCameraParameters::setExposureCompensation(int expComp) 7190 { 7191 char val[16]; 7192 snprintf(val, sizeof(val), "%d", expComp); 7193 updateParamEntry(KEY_EXPOSURE_COMPENSATION, val); 7194 7195 // Don't need to pass step as part of setParameter because 7196 // camera daemon is already aware of it. 7197 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_EXPOSURE_COMPENSATION, expComp)) { 7198 return BAD_VALUE; 7199 } 7200 7201 return NO_ERROR; 7202 } 7203 7204 /*=========================================================================== 7205 * FUNCTION : setWhiteBalance 7206 * 7207 * DESCRIPTION: set white balance mode 7208 * 7209 * PARAMETERS : 7210 * @wbStr : white balance mode value string 7211 * 7212 * RETURN : int32_t type of status 7213 * NO_ERROR -- success 7214 * none-zero failure code 7215 *==========================================================================*/ 7216 int32_t QCameraParameters::setWhiteBalance(const char *wbStr) 7217 { 7218 if (wbStr != NULL) { 7219 int32_t value = lookupAttr(WHITE_BALANCE_MODES_MAP, 7220 PARAM_MAP_SIZE(WHITE_BALANCE_MODES_MAP), wbStr); 7221 if (value != NAME_NOT_FOUND) { 7222 CDBG_HIGH("%s: Setting WhiteBalance value %s", __func__, wbStr); 7223 updateParamEntry(KEY_WHITE_BALANCE, wbStr); 7224 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_WHITE_BALANCE, value)) { 7225 return BAD_VALUE; 7226 } 7227 return NO_ERROR; 7228 } 7229 } 7230 ALOGE("Invalid WhiteBalance value: %s", (wbStr == NULL) ? "NULL" : wbStr); 7231 return BAD_VALUE; 7232 } 7233 7234 /*=========================================================================== 7235 * FUNCTION : setWBManualCCT 7236 * 7237 * DESCRIPTION: set setWBManualCCT time 7238 * 7239 * PARAMETERS : 7240 * @cctStr : string of wb cct, range (2000, 8000) in K. 7241 * 7242 * RETURN : int32_t type of status 7243 * NO_ERROR -- success 7244 * none-zero failure code 7245 *==========================================================================*/ 7246 int32_t QCameraParameters::setWBManualCCT(const char *cctStr) 7247 { 7248 if (cctStr != NULL) { 7249 int32_t cctVal = atoi(cctStr); 7250 int32_t minCct = m_pCapability->min_wb_cct; /* 2000K */ 7251 int32_t maxCct = m_pCapability->max_wb_cct; /* 8000K */ 7252 7253 if (cctVal >= minCct && cctVal <= maxCct) { 7254 CDBG_HIGH("%s, cct value: %d", __func__, cctVal); 7255 updateParamEntry(KEY_QC_WB_MANUAL_CCT, cctStr); 7256 cam_manual_wb_parm_t manual_wb; 7257 manual_wb.type = CAM_MANUAL_WB_MODE_CCT; 7258 manual_wb.cct = cctVal; 7259 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_WB_MANUAL, manual_wb)) { 7260 return BAD_VALUE; 7261 } 7262 return NO_ERROR; 7263 } 7264 } 7265 7266 ALOGE("Invalid cct, value: %s", 7267 (cctStr == NULL) ? "NULL" : cctStr); 7268 return BAD_VALUE; 7269 } 7270 7271 /*=========================================================================== 7272 * FUNCTION : updateAWBParams 7273 * 7274 * DESCRIPTION: update CCT parameters key 7275 * 7276 * PARAMETERS : 7277 * @awb_params : WB parameters 7278 * 7279 * RETURN : int32_t type of status 7280 * NO_ERROR -- success 7281 * none-zero failure code 7282 *==========================================================================*/ 7283 int32_t QCameraParameters::updateAWBParams(cam_awb_params_t &awb_params) 7284 { 7285 //check and update CCT 7286 int32_t prev_cct = getInt(KEY_QC_WB_MANUAL_CCT); 7287 if (prev_cct != awb_params.cct_value) { 7288 CDBG("%s: update current cct value. old:%d, now:%d", __func__, 7289 prev_cct, awb_params.cct_value); 7290 set(KEY_QC_WB_MANUAL_CCT, awb_params.cct_value); 7291 } 7292 7293 //check and update WB gains 7294 const char *prev_gains = get(KEY_QC_MANUAL_WB_GAINS); 7295 char gainStr[30]; 7296 snprintf(gainStr, sizeof(gainStr), "%f,%f,%f", awb_params.rgb_gains.r_gain, 7297 awb_params.rgb_gains.g_gain, awb_params.rgb_gains.b_gain); 7298 7299 if (prev_gains == NULL || strcmp(prev_gains, gainStr)) { 7300 set(KEY_QC_MANUAL_WB_GAINS, gainStr); 7301 CDBG("%s: update currernt RGB gains: old %s new %s",__func__, prev_gains, gainStr); 7302 } 7303 return NO_ERROR; 7304 } 7305 7306 /*=========================================================================== 7307 * FUNCTION : parseGains 7308 * 7309 * DESCRIPTION: parse WB gains 7310 * 7311 * PARAMETERS : 7312 * @gainStr : WB result string 7313 * @r_gain : WB red gain 7314 * @g_gain : WB green gain 7315 * @b_gain : WB blue gain 7316 * 7317 * RETURN : int32_t type of status 7318 * NO_ERROR -- success 7319 * none-zero failure code 7320 *==========================================================================*/ 7321 int32_t QCameraParameters::parseGains(const char *gainStr, float &r_gain, 7322 float &g_gain, float &b_gain) 7323 { 7324 int32_t rc = NO_ERROR; 7325 char *saveptr = NULL; 7326 char* gains = (char*) calloc(1, strlen(gainStr) + 1); 7327 if (NULL == gains) { 7328 ALOGE("%s: No memory for gains", __func__); 7329 return NO_MEMORY; 7330 } 7331 strlcpy(gains, gainStr, strlen(gainStr) + 1); 7332 char *token = strtok_r(gains, ",", &saveptr); 7333 7334 if (NULL != token) { 7335 r_gain = atof(token); 7336 token = strtok_r(NULL, ",", &saveptr); 7337 } 7338 7339 if (NULL != token) { 7340 g_gain = atof(token); 7341 token = strtok_r(NULL, ",", &saveptr); 7342 } 7343 7344 if (NULL != token) { 7345 b_gain = (float) atof(token); 7346 } else { 7347 ALOGE("%s: Malformed string for gains", __func__); 7348 rc = BAD_VALUE; 7349 } 7350 7351 free(gains); 7352 return rc; 7353 } 7354 7355 /*=========================================================================== 7356 * FUNCTION : setManualWBGains 7357 * 7358 * DESCRIPTION: set manual wb gains for r,g,b 7359 * 7360 * PARAMETERS : 7361 * @cctStr : string of wb gains, range (1.0, 4.0). 7362 * 7363 * RETURN : int32_t type of status 7364 * NO_ERROR -- success 7365 * none-zero failure code 7366 *==========================================================================*/ 7367 int32_t QCameraParameters::setManualWBGains(const char *gainStr) 7368 { 7369 int32_t rc = NO_ERROR; 7370 if (gainStr != NULL) { 7371 float r_gain, g_gain, b_gain; 7372 rc = parseGains(gainStr, r_gain, g_gain, b_gain); 7373 if (rc != NO_ERROR) { 7374 return rc; 7375 } 7376 7377 float minGain = m_pCapability->min_wb_gain; 7378 float maxGain = m_pCapability->max_wb_gain; 7379 7380 if ((r_gain >= minGain) && (r_gain <= maxGain) && 7381 (g_gain >= minGain) && (g_gain <= maxGain) && 7382 (b_gain >= minGain) && (b_gain <= maxGain)) { 7383 CDBG_HIGH("%s, setting rgb gains: %s", __func__, gainStr); 7384 updateParamEntry(KEY_QC_MANUAL_WB_GAINS, gainStr); 7385 cam_manual_wb_parm_t manual_wb; 7386 manual_wb.type = CAM_MANUAL_WB_MODE_GAIN; 7387 manual_wb.gains.r_gain = r_gain; 7388 manual_wb.gains.g_gain = g_gain; 7389 manual_wb.gains.b_gain = b_gain; 7390 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_WB_MANUAL, manual_wb)) { 7391 return BAD_VALUE; 7392 } 7393 return NO_ERROR; 7394 } 7395 } 7396 7397 CDBG_HIGH("Invalid manual wb gains: %s", 7398 (gainStr == NULL) ? "NULL" : gainStr); 7399 return BAD_VALUE; 7400 } 7401 7402 int QCameraParameters::getAutoFlickerMode() 7403 { 7404 /* Enable Advanced Auto Antibanding where we can set 7405 any of the following option 7406 ie. CAM_ANTIBANDING_MODE_AUTO 7407 CAM_ANTIBANDING_MODE_AUTO_50HZ 7408 CAM_ANTIBANDING_MODE_AUTO_60HZ 7409 Currently setting it to default */ 7410 char prop[PROPERTY_VALUE_MAX]; 7411 memset(prop, 0, sizeof(prop)); 7412 property_get("persist.camera.set.afd", prop, "3"); 7413 return atoi(prop); 7414 } 7415 7416 /*=========================================================================== 7417 * FUNCTION : setAntibanding 7418 * 7419 * DESCRIPTION: set antibanding value 7420 * 7421 * PARAMETERS : 7422 * @antiBandingStr : antibanding value string 7423 * 7424 * RETURN : int32_t type of status 7425 * NO_ERROR -- success 7426 * none-zero failure code 7427 *==========================================================================*/ 7428 int32_t QCameraParameters::setAntibanding(const char *antiBandingStr) 7429 { 7430 if (antiBandingStr != NULL) { 7431 int32_t value = lookupAttr(ANTIBANDING_MODES_MAP, PARAM_MAP_SIZE(ANTIBANDING_MODES_MAP), 7432 antiBandingStr); 7433 if (value != NAME_NOT_FOUND) { 7434 CDBG_HIGH("%s: Setting AntiBanding value %s", __func__, antiBandingStr); 7435 updateParamEntry(KEY_ANTIBANDING, antiBandingStr); 7436 if(value == CAM_ANTIBANDING_MODE_AUTO) { 7437 value = getAutoFlickerMode(); 7438 } 7439 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, 7440 CAM_INTF_PARM_ANTIBANDING, (uint32_t)value)) { 7441 return BAD_VALUE; 7442 } 7443 return NO_ERROR; 7444 } 7445 } 7446 ALOGE("Invalid AntiBanding value: %s", 7447 (antiBandingStr == NULL) ? "NULL" : antiBandingStr); 7448 return BAD_VALUE; 7449 } 7450 7451 /*=========================================================================== 7452 * FUNCTION : setFocusAreas 7453 * 7454 * DESCRIPTION: set focus areas 7455 * 7456 * PARAMETERS : 7457 * @focusAreasStr : focus areas value string 7458 * 7459 * RETURN : int32_t type of status 7460 * NO_ERROR -- success 7461 * none-zero failure code 7462 *==========================================================================*/ 7463 int32_t QCameraParameters::setFocusAreas(const char *focusAreasStr) 7464 { 7465 if (m_pCapability->max_num_focus_areas == 0 || 7466 focusAreasStr == NULL) { 7467 CDBG("%s: Parameter string is null", __func__); 7468 return NO_ERROR; 7469 } 7470 7471 cam_area_t *areas = (cam_area_t *)malloc(sizeof(cam_area_t) * m_pCapability->max_num_focus_areas); 7472 if (NULL == areas) { 7473 ALOGE("%s: No memory for areas", __func__); 7474 return NO_MEMORY; 7475 } 7476 memset(areas, 0, sizeof(cam_area_t) * m_pCapability->max_num_focus_areas); 7477 int num_areas_found = 0; 7478 if (parseCameraAreaString(focusAreasStr, 7479 m_pCapability->max_num_focus_areas, 7480 areas, 7481 num_areas_found) != NO_ERROR) { 7482 ALOGE("%s: Failed to parse the string: %s", __func__, focusAreasStr); 7483 free(areas); 7484 return BAD_VALUE; 7485 } 7486 7487 if (validateCameraAreas(areas, num_areas_found) == false) { 7488 ALOGE("%s: invalid areas specified : %s", __func__, focusAreasStr); 7489 free(areas); 7490 return BAD_VALUE; 7491 } 7492 7493 updateParamEntry(KEY_FOCUS_AREAS, focusAreasStr); 7494 7495 //for special area string (0, 0, 0, 0, 0), set the num_areas_found to 0, 7496 //so no action is takenby the lower layer 7497 if (num_areas_found == 1 && 7498 areas[0].rect.left == 0 && 7499 areas[0].rect.top == 0 && 7500 areas[0].rect.width == 0 && 7501 areas[0].rect.height == 0 && 7502 areas[0].weight == 0) { 7503 num_areas_found = 0; 7504 } 7505 7506 int previewWidth, previewHeight; 7507 getPreviewSize(&previewWidth, &previewHeight); 7508 cam_roi_info_t af_roi_value; 7509 memset(&af_roi_value, 0, sizeof(cam_roi_info_t)); 7510 af_roi_value.num_roi = (uint8_t)num_areas_found; 7511 for (int i = 0; i < num_areas_found; i++) { 7512 CDBG_HIGH("%s: FocusArea[%d] = (%d, %d, %d, %d)", 7513 __func__, i, (areas[i].rect.top), (areas[i].rect.left), 7514 (areas[i].rect.width), (areas[i].rect.height)); 7515 7516 // Transform the coords from (-1000, 1000) 7517 // to (0, previewWidth or previewHeight). 7518 af_roi_value.roi[i].left = 7519 (int32_t)(((double)areas[i].rect.left + 1000.0) * 7520 ((double)previewWidth / 2000.0)); 7521 af_roi_value.roi[i].top = 7522 (int32_t)(((double)areas[i].rect.top + 1000.0) * 7523 ((double)previewHeight / 2000.0)); 7524 af_roi_value.roi[i].width = 7525 (int32_t)((double)areas[i].rect.width * 7526 (double)previewWidth / 2000.0); 7527 af_roi_value.roi[i].height = 7528 (int32_t)((double)areas[i].rect.height * 7529 (double)previewHeight / 2000.0); 7530 af_roi_value.weight[i] = areas[i].weight; 7531 } 7532 free(areas); 7533 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_AF_ROI, af_roi_value)) { 7534 return BAD_VALUE; 7535 } 7536 7537 return NO_ERROR; 7538 } 7539 7540 /*=========================================================================== 7541 * FUNCTION : setMeteringAreas 7542 * 7543 * DESCRIPTION: set metering areas value 7544 * 7545 * PARAMETERS : 7546 * @meteringAreasStr : metering areas value string 7547 * 7548 * RETURN : int32_t type of status 7549 * NO_ERROR -- success 7550 * none-zero failure code 7551 *==========================================================================*/ 7552 int32_t QCameraParameters::setMeteringAreas(const char *meteringAreasStr) 7553 { 7554 if (m_pCapability->max_num_metering_areas == 0 || 7555 meteringAreasStr == NULL) { 7556 CDBG("%s: Parameter string is null", __func__); 7557 return NO_ERROR; 7558 } 7559 7560 cam_area_t *areas = (cam_area_t *)malloc(sizeof(cam_area_t) * m_pCapability->max_num_metering_areas); 7561 if (NULL == areas) { 7562 ALOGE("%s: No memory for areas", __func__); 7563 return NO_MEMORY; 7564 } 7565 memset(areas, 0, sizeof(cam_area_t) * m_pCapability->max_num_metering_areas); 7566 int num_areas_found = 0; 7567 if (parseCameraAreaString(meteringAreasStr, 7568 m_pCapability->max_num_metering_areas, 7569 areas, 7570 num_areas_found) < 0) { 7571 ALOGE("%s: Failed to parse the string: %s", __func__, meteringAreasStr); 7572 free(areas); 7573 return BAD_VALUE; 7574 } 7575 7576 if (validateCameraAreas(areas, num_areas_found) == false) { 7577 ALOGE("%s: invalid areas specified : %s", __func__, meteringAreasStr); 7578 free(areas); 7579 return BAD_VALUE; 7580 } 7581 7582 updateParamEntry(KEY_METERING_AREAS, meteringAreasStr); 7583 7584 //for special area string (0, 0, 0, 0, 0), set the num_areas_found to 0, 7585 //so no action is takenby the lower layer 7586 if (num_areas_found == 1 && 7587 areas[0].rect.left == 0 && 7588 areas[0].rect.top == 0 && 7589 areas[0].rect.width == 0 && 7590 areas[0].rect.height == 0 && 7591 areas[0].weight == 0) { 7592 num_areas_found = 0; 7593 } 7594 cam_set_aec_roi_t aec_roi_value; 7595 int previewWidth, previewHeight; 7596 getPreviewSize(&previewWidth, &previewHeight); 7597 7598 memset(&aec_roi_value, 0, sizeof(cam_set_aec_roi_t)); 7599 if (num_areas_found > 0) { 7600 aec_roi_value.aec_roi_enable = CAM_AEC_ROI_ON; 7601 aec_roi_value.aec_roi_type = CAM_AEC_ROI_BY_COORDINATE; 7602 7603 for (int i = 0; i < num_areas_found; i++) { 7604 CDBG_HIGH("%s: MeteringArea[%d] = (%d, %d, %d, %d)", 7605 __func__, i, (areas[i].rect.top), (areas[i].rect.left), 7606 (areas[i].rect.width), (areas[i].rect.height)); 7607 7608 // Transform the coords from (-1000, 1000) to 7609 // (0, previewWidth or previewHeight). 7610 aec_roi_value.cam_aec_roi_position.coordinate[i].x = 7611 (uint32_t)((((double)areas[i].rect.left + 7612 (double)areas[i].rect.width / 2.0) + 1000.0) * 7613 (double)previewWidth / 2000.0); 7614 aec_roi_value.cam_aec_roi_position.coordinate[i].y = 7615 (uint32_t)((((double)areas[i].rect.top + 7616 (double)areas[i].rect.height / 2.0) + 1000.0) * 7617 (double)previewHeight / 2000.0); 7618 } 7619 } else { 7620 aec_roi_value.aec_roi_enable = CAM_AEC_ROI_OFF; 7621 } 7622 free(areas); 7623 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_AEC_ROI, aec_roi_value)) { 7624 return BAD_VALUE; 7625 } 7626 7627 return NO_ERROR; 7628 } 7629 7630 /*=========================================================================== 7631 * FUNCTION : setSceneMode 7632 * 7633 * DESCRIPTION: set scene mode 7634 * 7635 * PARAMETERS : 7636 * @sceneModeStr : scene mode value string 7637 * 7638 * RETURN : int32_t type of status 7639 * NO_ERROR -- success 7640 * none-zero failure code 7641 *==========================================================================*/ 7642 int32_t QCameraParameters::setSceneMode(const char *sceneModeStr) 7643 { 7644 if (sceneModeStr != NULL) { 7645 int32_t value = lookupAttr(SCENE_MODES_MAP, PARAM_MAP_SIZE(SCENE_MODES_MAP), sceneModeStr); 7646 if (value != NAME_NOT_FOUND) { 7647 CDBG("%s: Setting SceneMode %s", __func__, sceneModeStr); 7648 updateParamEntry(KEY_SCENE_MODE, sceneModeStr); 7649 if (m_bSensorHDREnabled) { 7650 // Incase of HW HDR mode, we do not update the same as Best shot mode. 7651 CDBG_HIGH("%s: H/W HDR mode enabled. Do not set Best Shot Mode", __func__); 7652 return NO_ERROR; 7653 } 7654 if (m_bSceneSelection) { 7655 setSelectedScene((cam_scene_mode_type) value); 7656 } 7657 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_BESTSHOT_MODE, 7658 (uint32_t)value)) { 7659 return BAD_VALUE; 7660 } 7661 return NO_ERROR; 7662 } 7663 } 7664 ALOGE("%s: Invalid Secene Mode: %s", 7665 __func__, (sceneModeStr == NULL) ? "NULL" : sceneModeStr); 7666 return BAD_VALUE; 7667 } 7668 7669 /*=========================================================================== 7670 * FUNCTION : setSelectableZoneAf 7671 * 7672 * DESCRIPTION: set selectable zone AF algorithm 7673 * 7674 * PARAMETERS : 7675 * @selZoneAFStr : selectable zone AF algorithm value string 7676 * 7677 * RETURN : int32_t type of status 7678 * NO_ERROR -- success 7679 * none-zero failure code 7680 *==========================================================================*/ 7681 int32_t QCameraParameters::setSelectableZoneAf(const char *selZoneAFStr) 7682 { 7683 if (selZoneAFStr != NULL) { 7684 int32_t value = lookupAttr(FOCUS_ALGO_MAP, PARAM_MAP_SIZE(FOCUS_ALGO_MAP), selZoneAFStr); 7685 if (value != NAME_NOT_FOUND) { 7686 CDBG("%s: Setting Selectable Zone AF value %s", __func__, selZoneAFStr); 7687 updateParamEntry(KEY_QC_SELECTABLE_ZONE_AF, selZoneAFStr); 7688 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_FOCUS_ALGO_TYPE, value)) { 7689 return BAD_VALUE; 7690 } 7691 return NO_ERROR; 7692 } 7693 } 7694 ALOGE("%s: Invalid selectable zone af value: %s", 7695 __func__, (selZoneAFStr == NULL) ? "NULL" : selZoneAFStr); 7696 return BAD_VALUE; 7697 } 7698 7699 /*=========================================================================== 7700 * FUNCTION : isAEBracketEnabled 7701 * 7702 * DESCRIPTION: checks if AE bracketing is enabled 7703 * 7704 * PARAMETERS : 7705 * 7706 * RETURN : TRUE/FALSE 7707 *==========================================================================*/ 7708 bool QCameraParameters::isAEBracketEnabled() 7709 { 7710 const char *str = get(KEY_QC_AE_BRACKET_HDR); 7711 if (str != NULL) { 7712 if (strcmp(str, AE_BRACKET_OFF) != 0) { 7713 return true; 7714 } 7715 } 7716 return false; 7717 } 7718 7719 /*=========================================================================== 7720 * FUNCTION : setAEBracket 7721 * 7722 * DESCRIPTION: set AE bracket value 7723 * 7724 * PARAMETERS : 7725 * @aecBracketStr : AE bracket value string 7726 * 7727 * RETURN : int32_t type of status 7728 * NO_ERROR -- success 7729 * none-zero failure code 7730 *==========================================================================*/ 7731 int32_t QCameraParameters::setAEBracket(const char *aecBracketStr) 7732 { 7733 if (aecBracketStr == NULL) { 7734 CDBG("%s: setAEBracket with NULL value", __func__); 7735 return NO_ERROR; 7736 } 7737 7738 cam_exp_bracketing_t expBracket; 7739 memset(&expBracket, 0, sizeof(expBracket)); 7740 7741 int value = lookupAttr(BRACKETING_MODES_MAP, PARAM_MAP_SIZE(BRACKETING_MODES_MAP), 7742 aecBracketStr); 7743 switch (value) { 7744 case CAM_EXP_BRACKETING_ON: 7745 { 7746 CDBG("%s, EXP_BRACKETING_ON", __func__); 7747 const char *str_val = get(KEY_QC_CAPTURE_BURST_EXPOSURE); 7748 if ((str_val != NULL) && (strlen(str_val)>0)) { 7749 expBracket.mode = CAM_EXP_BRACKETING_ON; 7750 m_bAeBracketingEnabled = true; 7751 strlcpy(expBracket.values, str_val, MAX_EXP_BRACKETING_LENGTH); 7752 CDBG("%s: setting Exposure Bracketing value of %s", 7753 __func__, expBracket.values); 7754 } 7755 else { 7756 /* Apps not set capture-burst-exposures, error case fall into bracketing off mode */ 7757 CDBG("%s: capture-burst-exposures not set, back to HDR OFF mode", __func__); 7758 m_bAeBracketingEnabled = false; 7759 expBracket.mode = CAM_EXP_BRACKETING_OFF; 7760 } 7761 } 7762 break; 7763 default: 7764 { 7765 m_bAeBracketingEnabled = false; 7766 CDBG_HIGH("%s, EXP_BRACKETING_OFF", __func__); 7767 expBracket.mode = CAM_EXP_BRACKETING_OFF; 7768 } 7769 break; 7770 } 7771 7772 // Cache client AE bracketing configuration 7773 memcpy(&m_AEBracketingClient, &expBracket, sizeof(cam_exp_bracketing_t)); 7774 7775 /* save the value*/ 7776 updateParamEntry(KEY_QC_AE_BRACKET_HDR, aecBracketStr); 7777 return NO_ERROR; 7778 } 7779 7780 /*=========================================================================== 7781 * FUNCTION : set3ALock 7782 * 7783 * DESCRIPTION: enable/disable 3A lock. 7784 * 7785 * PARAMETERS : 7786 * @lockStr : lock value string. 7787 * 7788 * RETURN : int32_t type of status 7789 * NO_ERROR -- success 7790 * none-zero failure code 7791 *==========================================================================*/ 7792 int32_t QCameraParameters::set3ALock(const char *lockStr) 7793 { 7794 int32_t rc = NO_ERROR; 7795 if (lockStr != NULL) { 7796 int value = lookupAttr(TRUE_FALSE_MODES_MAP, PARAM_MAP_SIZE(TRUE_FALSE_MODES_MAP), 7797 lockStr); 7798 if (value != NAME_NOT_FOUND) { 7799 CDBG_HIGH("%s: Setting Lock lockStr =%s", __func__, lockStr); 7800 if(initBatchUpdate(m_pParamBuf) < 0 ) { 7801 ALOGE("%s:Failed to initialize group update table", __func__); 7802 return BAD_TYPE; 7803 } 7804 uint32_t focus_mode = CAM_FOCUS_MODE_AUTO; 7805 if (value == 1) { 7806 if (isUbiFocusEnabled() || isUbiRefocus()) { 7807 //For Ubi focus move focus to infinity. 7808 focus_mode = CAM_FOCUS_MODE_INFINITY; 7809 } else if (isOptiZoomEnabled() || isStillMoreEnabled()) { 7810 //For optizoom and stillmore, set focus as fixed. 7811 focus_mode = CAM_FOCUS_MODE_FIXED; 7812 } 7813 } else { 7814 // retrieve previous focus value. 7815 const char *focus = get(KEY_FOCUS_MODE); 7816 int val = lookupAttr(FOCUS_MODES_MAP, PARAM_MAP_SIZE(FOCUS_MODES_MAP), focus); 7817 if (val != NAME_NOT_FOUND) { 7818 focus_mode = (uint32_t) val; 7819 CDBG("%s: focus mode %s", __func__, focus); 7820 } 7821 } 7822 //Lock AWB 7823 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_AWB_LOCK, (uint32_t)value)) { 7824 return BAD_VALUE; 7825 } 7826 //Lock AEC 7827 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_AEC_LOCK, (uint32_t)value)) { 7828 return BAD_VALUE; 7829 } 7830 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_FOCUS_MODE, focus_mode)) { 7831 return BAD_VALUE; 7832 } 7833 7834 rc = commitSetBatch(); 7835 if (rc != NO_ERROR) { 7836 ALOGE("%s:Failed to commit batch", __func__); 7837 } 7838 } 7839 } 7840 return rc; 7841 } 7842 7843 /*=========================================================================== 7844 * FUNCTION : setAndCommitZoom 7845 * 7846 * DESCRIPTION: set zoom. 7847 * 7848 * PARAMETERS : 7849 * @zoom_level : zoom level to set. 7850 * 7851 * RETURN : int32_t type of status 7852 * NO_ERROR -- success 7853 * none-zero failure code 7854 *==========================================================================*/ 7855 int32_t QCameraParameters::setAndCommitZoom(int zoom_level) 7856 { 7857 CDBG_HIGH("%s: E",__func__); 7858 int32_t rc = NO_ERROR; 7859 if (initBatchUpdate(m_pParamBuf) < 0 ) { 7860 ALOGE("%s:Failed to initialize group update table", __func__); 7861 return BAD_TYPE; 7862 } 7863 7864 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_ZOOM, zoom_level)) { 7865 ALOGE("%s:Failed to update table", __func__); 7866 return BAD_VALUE; 7867 } 7868 7869 rc = commitSetBatch(); 7870 if (rc != NO_ERROR) { 7871 ALOGE("%s:Failed to set Flash value", __func__); 7872 } 7873 7874 mZoomLevel = zoom_level; 7875 CDBG_HIGH("%s: X",__func__); 7876 7877 return rc; 7878 } 7879 7880 /*=========================================================================== 7881 * FUNCTION : isOptiZoomEnabled 7882 * 7883 * DESCRIPTION: checks whether optizoom is enabled 7884 * 7885 * PARAMETERS : 7886 * 7887 * RETURN : true - enabled, false - disabled 7888 * 7889 *==========================================================================*/ 7890 bool QCameraParameters::isOptiZoomEnabled() 7891 { 7892 if (m_bOptiZoomOn && (0 <= mParmZoomLevel)) { 7893 uint32_t zoom_level = (uint32_t) mParmZoomLevel; 7894 cam_opti_zoom_t *opti_zoom_settings_need = 7895 &(m_pCapability->opti_zoom_settings_need); 7896 uint32_t zoom_threshold = (uint32_t) opti_zoom_settings_need->zoom_threshold; 7897 CDBG_HIGH("%s: current zoom level =%u & zoom_threshold =%u", 7898 __func__, zoom_level, zoom_threshold); 7899 7900 if (zoom_level >= zoom_threshold) { 7901 return true; 7902 } 7903 } 7904 7905 return false; 7906 } 7907 7908 /*=========================================================================== 7909 * FUNCTION : commitAFBracket 7910 * 7911 * DESCRIPTION: commit AF Bracket. 7912 * 7913 * PARAMETERS : 7914 * @AFBracket : AF bracketing configuration 7915 * 7916 * RETURN : int32_t type of status 7917 * NO_ERROR -- success 7918 * none-zero failure code 7919 *==========================================================================*/ 7920 int32_t QCameraParameters::commitAFBracket(cam_af_bracketing_t afBracket) 7921 { 7922 7923 int32_t rc = NO_ERROR; 7924 if(initBatchUpdate(m_pParamBuf) < 0 ) { 7925 ALOGE("%s:Failed to initialize group update table", __func__); 7926 return BAD_TYPE; 7927 } 7928 7929 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_FOCUS_BRACKETING, afBracket)) { 7930 ALOGE("%s:Failed to update table", __func__); 7931 return BAD_VALUE; 7932 } 7933 7934 rc = commitSetBatch(); 7935 if (rc != NO_ERROR) { 7936 ALOGE("%s:Failed to commit batch", __func__); 7937 return rc; 7938 } 7939 7940 return rc; 7941 } 7942 7943 /*=========================================================================== 7944 * FUNCTION : commitFlashBracket 7945 * 7946 * DESCRIPTION: commit Flash Bracket. 7947 * 7948 * PARAMETERS : 7949 * @AFBracket : Flash bracketing configuration 7950 * 7951 * RETURN : int32_t type of status 7952 * NO_ERROR -- success 7953 * none-zero failure code 7954 *==========================================================================*/ 7955 int32_t QCameraParameters::commitFlashBracket(cam_flash_bracketing_t flashBracket) 7956 { 7957 CDBG_HIGH("%s: E",__func__); 7958 int32_t rc = NO_ERROR; 7959 if(initBatchUpdate(m_pParamBuf) < 0 ) { 7960 ALOGE("%s:Failed to initialize group update table", __func__); 7961 return BAD_TYPE; 7962 } 7963 7964 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, 7965 CAM_INTF_PARM_FLASH_BRACKETING, flashBracket)) { 7966 ALOGE("%s:Failed to update table", __func__); 7967 return BAD_VALUE; 7968 } 7969 7970 rc = commitSetBatch(); 7971 if (rc != NO_ERROR) { 7972 ALOGE("%s:Failed to commit batch", __func__); 7973 } 7974 7975 CDBG_HIGH("%s: X",__func__); 7976 return rc; 7977 } 7978 7979 /*=========================================================================== 7980 * FUNCTION : setAFBracket 7981 * 7982 * DESCRIPTION: set AF bracket value 7983 * 7984 * PARAMETERS : 7985 * @afBracketStr : AF bracket value string 7986 * 7987 * RETURN : int32_t type of status 7988 * NO_ERROR -- success 7989 * none-zero failure code 7990 *==========================================================================*/ 7991 int32_t QCameraParameters::setAFBracket(const char *afBracketStr) 7992 { 7993 CDBG_HIGH("%s: afBracketStr =%s",__func__,afBracketStr); 7994 7995 if(afBracketStr != NULL) { 7996 int value = lookupAttr(AF_BRACKETING_MODES_MAP, PARAM_MAP_SIZE(AF_BRACKETING_MODES_MAP), 7997 afBracketStr); 7998 if (value != NAME_NOT_FOUND) { 7999 m_bAFBracketingOn = (value != 0); 8000 updateParamEntry(KEY_QC_AF_BRACKET, afBracketStr); 8001 8002 return NO_ERROR; 8003 } 8004 } 8005 8006 ALOGE("Invalid af bracket value: %s", 8007 (afBracketStr == NULL) ? "NULL" : afBracketStr); 8008 return BAD_VALUE; 8009 } 8010 8011 /*=========================================================================== 8012 * FUNCTION : setReFocus 8013 * 8014 * DESCRIPTION: set refocus value 8015 * 8016 * PARAMETERS : 8017 * @afBracketStr : refocus value string 8018 * 8019 * RETURN : int32_t type of status 8020 * NO_ERROR -- success 8021 * none-zero failure code 8022 *==========================================================================*/ 8023 int32_t QCameraParameters::setReFocus(const char *reFocusStr) 8024 { 8025 CDBG_HIGH("%s: reFocusStr =%s",__func__,reFocusStr); 8026 8027 if (reFocusStr != NULL) { 8028 int value = lookupAttr(RE_FOCUS_MODES_MAP, PARAM_MAP_SIZE(RE_FOCUS_MODES_MAP), 8029 reFocusStr); 8030 if (value != NAME_NOT_FOUND) { 8031 m_bReFocusOn = (value != 0); 8032 updateParamEntry(KEY_QC_RE_FOCUS, reFocusStr); 8033 return NO_ERROR; 8034 } 8035 } 8036 8037 return NO_ERROR; 8038 } 8039 8040 /*=========================================================================== 8041 * FUNCTION : setChromaFlash 8042 * 8043 * DESCRIPTION: set chroma flash value 8044 * 8045 * PARAMETERS : 8046 * @aecBracketStr : chroma flash value string 8047 * 8048 * RETURN : int32_t type of status 8049 * NO_ERROR -- success 8050 * none-zero failure code 8051 *==========================================================================*/ 8052 int32_t QCameraParameters::setChromaFlash(const char *chromaFlashStr) 8053 { 8054 CDBG_HIGH("%s: chromaFlashStr =%s",__func__,chromaFlashStr); 8055 if(chromaFlashStr != NULL) { 8056 int value = lookupAttr(CHROMA_FLASH_MODES_MAP, PARAM_MAP_SIZE(CHROMA_FLASH_MODES_MAP), 8057 chromaFlashStr); 8058 if(value != NAME_NOT_FOUND) { 8059 m_bChromaFlashOn = (value != 0); 8060 updateParamEntry(KEY_QC_CHROMA_FLASH, chromaFlashStr); 8061 8062 return NO_ERROR; 8063 } 8064 } 8065 8066 ALOGE("Invalid chroma flash value: %s", 8067 (chromaFlashStr == NULL) ? "NULL" : chromaFlashStr); 8068 return BAD_VALUE; 8069 } 8070 8071 /*=========================================================================== 8072 * FUNCTION : setOptiZoom 8073 * 8074 * DESCRIPTION: set opti zoom value 8075 * 8076 * PARAMETERS : 8077 * @optiZoomStr : opti zoom value string 8078 * 8079 * RETURN : int32_t type of status 8080 * NO_ERROR -- success 8081 * none-zero failure code 8082 *==========================================================================*/ 8083 int32_t QCameraParameters::setOptiZoom(const char *optiZoomStr) 8084 { 8085 CDBG_HIGH("%s: optiZoomStr =%s",__func__,optiZoomStr); 8086 if(optiZoomStr != NULL) { 8087 int value = lookupAttr(OPTI_ZOOM_MODES_MAP, PARAM_MAP_SIZE(OPTI_ZOOM_MODES_MAP), 8088 optiZoomStr); 8089 if(value != NAME_NOT_FOUND) { 8090 m_bOptiZoomOn = (value != 0); 8091 updateParamEntry(KEY_QC_OPTI_ZOOM, optiZoomStr); 8092 8093 return NO_ERROR; 8094 } 8095 } 8096 ALOGE("Invalid opti zoom value: %s", 8097 (optiZoomStr == NULL) ? "NULL" : optiZoomStr); 8098 return BAD_VALUE; 8099 } 8100 8101 /*=========================================================================== 8102 * FUNCTION : setTruePortrait 8103 * 8104 * DESCRIPTION: set true portrait value 8105 * 8106 * PARAMETERS : 8107 * @optiZoomStr : true portrait value string 8108 * 8109 * RETURN : int32_t type of status 8110 * NO_ERROR -- success 8111 * none-zero failure code 8112 *==========================================================================*/ 8113 int32_t QCameraParameters::setTruePortrait(const char *truePortraitStr) 8114 { 8115 CDBG_HIGH("%s: truePortraitStr =%s", __func__, truePortraitStr); 8116 if (truePortraitStr != NULL) { 8117 int value = lookupAttr(TRUE_PORTRAIT_MODES_MAP, 8118 PARAM_MAP_SIZE(TRUE_PORTRAIT_MODES_MAP), 8119 truePortraitStr); 8120 if (value != NAME_NOT_FOUND) { 8121 m_bTruePortraitOn = (value != 0); 8122 updateParamEntry(KEY_QC_TRUE_PORTRAIT, truePortraitStr); 8123 return NO_ERROR; 8124 } 8125 } 8126 CDBG_HIGH("Invalid true portrait value: %s", 8127 (truePortraitStr == NULL) ? "NULL" : truePortraitStr); 8128 return BAD_VALUE; 8129 } 8130 8131 /*=========================================================================== 8132 * FUNCTION : setHDRMode 8133 * 8134 * DESCRIPTION: set hdr mode value 8135 * 8136 * PARAMETERS : 8137 * @hdrModeStr : hdr mode value string 8138 * 8139 * RETURN : int32_t type of status 8140 * NO_ERROR -- success 8141 * none-zero failure code 8142 *==========================================================================*/ 8143 int32_t QCameraParameters::setHDRMode(const char *hdrModeStr) 8144 { 8145 CDBG_HIGH("%s: hdrModeStr =%s", __func__, hdrModeStr); 8146 if (hdrModeStr != NULL) { 8147 int value = lookupAttr(HDR_MODES_MAP, PARAM_MAP_SIZE(HDR_MODES_MAP), hdrModeStr); 8148 if (value != NAME_NOT_FOUND) { 8149 const char *str = get(KEY_SCENE_MODE); 8150 8151 m_bHDRModeSensor = !strncmp(hdrModeStr, HDR_MODE_SENSOR, strlen(HDR_MODE_SENSOR)); 8152 8153 updateParamEntry(KEY_QC_HDR_MODE, hdrModeStr); 8154 8155 // If hdr is already selected, need to deselect it in local cache 8156 // So the new hdr mode will be applied 8157 if (str && !strncmp(str, SCENE_MODE_HDR, strlen(SCENE_MODE_HDR))) { 8158 updateParamEntry(KEY_SCENE_MODE, SCENE_MODE_AUTO); 8159 m_bNeedRestart = true; 8160 } 8161 8162 return NO_ERROR; 8163 } 8164 } 8165 CDBG_HIGH("Invalid hdr mode value: %s", 8166 (hdrModeStr == NULL) ? "NULL" : hdrModeStr); 8167 return BAD_VALUE; 8168 } 8169 8170 /*=========================================================================== 8171 * FUNCTION : setSeeMore 8172 * 8173 * DESCRIPTION: set see more value 8174 * 8175 * PARAMETERS : 8176 * @seeMoreStr : see more value string 8177 * 8178 * RETURN : int32_t type of status 8179 * NO_ERROR -- success 8180 * none-zero failure code 8181 *==========================================================================*/ 8182 int32_t QCameraParameters::setSeeMore(const char *seeMoreStr) 8183 { 8184 int32_t rc = NO_ERROR; 8185 8186 CDBG_HIGH("%s: seeMoreStr =%s", __func__, seeMoreStr); 8187 if (seeMoreStr != NULL) { 8188 int value = lookupAttr(ON_OFF_MODES_MAP, 8189 PARAM_MAP_SIZE(ON_OFF_MODES_MAP), 8190 seeMoreStr); 8191 if (value != NAME_NOT_FOUND) { 8192 m_bSeeMoreOn = (value != 0); 8193 8194 // If SeeMore is enabled, enable StillMore for live snapshot 8195 // and disable tone map 8196 if (m_bSeeMoreOn) { 8197 m_bStillMoreOn = TRUE; 8198 rc = setToneMapMode(false, false); 8199 if (rc != NO_ERROR) { 8200 CDBG_HIGH("%s: Failed to disable tone map during SeeMore", __func__); 8201 } 8202 } else { 8203 m_bStillMoreOn = FALSE; 8204 rc = setToneMapMode(true, false); 8205 if (rc != NO_ERROR) { 8206 CDBG_HIGH("%s: Failed to enable tone map during SeeMore", __func__); 8207 } 8208 } 8209 updateParamEntry(KEY_QC_SEE_MORE, seeMoreStr); 8210 return NO_ERROR; 8211 } 8212 } 8213 ALOGE("Invalid see more value: %s", 8214 (seeMoreStr == NULL) ? "NULL" : seeMoreStr); 8215 return BAD_VALUE; 8216 } 8217 8218 /*=========================================================================== 8219 * FUNCTION : setStillMore 8220 * 8221 * DESCRIPTION: set still more value 8222 * 8223 * PARAMETERS : 8224 * @seeMoreStr : still more value string 8225 * 8226 * RETURN : int32_t type of status 8227 * NO_ERROR -- success 8228 * none-zero failure code 8229 *==========================================================================*/ 8230 int32_t QCameraParameters::setStillMore(const char *stillMoreStr) 8231 { 8232 CDBG_HIGH("%s: stillMoreStr =%s", __func__, stillMoreStr); 8233 if (stillMoreStr != NULL) { 8234 int value = lookupAttr(STILL_MORE_MODES_MAP, PARAM_MAP_SIZE(STILL_MORE_MODES_MAP), 8235 stillMoreStr); 8236 if (value != NAME_NOT_FOUND) { 8237 m_bStillMoreOn = (value != 0); 8238 updateParamEntry(KEY_QC_STILL_MORE, stillMoreStr); 8239 8240 return NO_ERROR; 8241 } 8242 } 8243 ALOGE("Invalid still more value: %s", 8244 (stillMoreStr == NULL) ? "NULL" : stillMoreStr); 8245 return BAD_VALUE; 8246 } 8247 8248 /*=========================================================================== 8249 * FUNCTION : setHDRNeed1x 8250 * 8251 * DESCRIPTION: set hdr need 1x value 8252 * 8253 * PARAMETERS : 8254 * @hdrModeStr : hdr need 1x value string 8255 * 8256 * RETURN : int32_t type of status 8257 * NO_ERROR -- success 8258 * none-zero failure code 8259 *==========================================================================*/ 8260 int32_t QCameraParameters::setHDRNeed1x(const char *hdrNeed1xStr) 8261 { 8262 CDBG_HIGH("%s: hdrNeed1xStr =%s", __func__, hdrNeed1xStr); 8263 if (hdrNeed1xStr != NULL) { 8264 int value = lookupAttr(TRUE_FALSE_MODES_MAP, PARAM_MAP_SIZE(TRUE_FALSE_MODES_MAP), 8265 hdrNeed1xStr); 8266 if (value != NAME_NOT_FOUND) { 8267 updateParamEntry(KEY_QC_HDR_NEED_1X, hdrNeed1xStr); 8268 m_bHDR1xFrameEnabled = !strncmp(hdrNeed1xStr, VALUE_TRUE, strlen(VALUE_TRUE)); 8269 m_bNeedRestart = true; 8270 8271 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_HDR_NEED_1X, 8272 m_bHDR1xFrameEnabled)) { 8273 return BAD_VALUE; 8274 } 8275 return NO_ERROR; 8276 } 8277 } 8278 8279 CDBG_HIGH("Invalid hdr need 1x value: %s", 8280 (hdrNeed1xStr == NULL) ? "NULL" : hdrNeed1xStr); 8281 return BAD_VALUE; 8282 } 8283 8284 /*=========================================================================== 8285 * FUNCTION : setAEBracketing 8286 * 8287 * DESCRIPTION: enables AE bracketing 8288 * 8289 * PARAMETERS : 8290 * 8291 * RETURN : int32_t type of status 8292 * NO_ERROR -- success 8293 * none-zero failure code 8294 *==========================================================================*/ 8295 int32_t QCameraParameters::setAEBracketing() 8296 { 8297 int32_t rc = NO_ERROR; 8298 if(initBatchUpdate(m_pParamBuf) < 0 ) { 8299 ALOGE("%s:Failed to initialize group update table", __func__); 8300 return BAD_TYPE; 8301 } 8302 8303 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_HDR, m_AEBracketingClient)) { 8304 ALOGE("%s:Failed to update AE bracketing", __func__); 8305 return BAD_VALUE; 8306 } 8307 8308 rc = commitSetBatch(); 8309 if (rc != NO_ERROR) { 8310 ALOGE("%s:Failed to configure AE bracketing", __func__); 8311 return rc; 8312 } 8313 8314 return rc; 8315 } 8316 8317 /*=========================================================================== 8318 * FUNCTION : setHDRAEBracket 8319 * 8320 * DESCRIPTION: enables AE bracketing for HDR 8321 * 8322 * PARAMETERS : 8323 * @hdrBracket : HDR bracketing configuration 8324 * 8325 * RETURN : int32_t type of status 8326 * NO_ERROR -- success 8327 * none-zero failure code 8328 *==========================================================================*/ 8329 int32_t QCameraParameters::setHDRAEBracket(cam_exp_bracketing_t hdrBracket) 8330 { 8331 int32_t rc = NO_ERROR; 8332 if(initBatchUpdate(m_pParamBuf) < 0 ) { 8333 ALOGE("%s:Failed to initialize group update table", __func__); 8334 return BAD_TYPE; 8335 } 8336 8337 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_HDR, hdrBracket)) { 8338 ALOGE("%s:Failed to update table", __func__); 8339 return BAD_TYPE; 8340 } 8341 8342 rc = commitSetBatch(); 8343 if (rc != NO_ERROR) { 8344 ALOGE("%s:Failed to configure HDR bracketing", __func__); 8345 return rc; 8346 } 8347 8348 return rc; 8349 } 8350 8351 /*=========================================================================== 8352 * FUNCTION : restoreAEBracket 8353 * 8354 * DESCRIPTION: restores client AE bracketing configuration after HDR is done 8355 * 8356 * PARAMETERS : 8357 * 8358 * RETURN : int32_t type of status 8359 * NO_ERROR -- success 8360 * none-zero failure code 8361 *==========================================================================*/ 8362 int32_t QCameraParameters::stopAEBracket() 8363 { 8364 cam_exp_bracketing_t bracketing; 8365 8366 bracketing.mode = CAM_EXP_BRACKETING_OFF; 8367 8368 return setHDRAEBracket(bracketing); 8369 } 8370 8371 /*=========================================================================== 8372 * FUNCTION : updateFlash 8373 * 8374 * DESCRIPTION: restores client flash configuration or disables flash 8375 * 8376 * PARAMETERS : 8377 * @commitSettings : flag indicating whether settings need to be commited 8378 * 8379 * RETURN : int32_t type of status 8380 * NO_ERROR -- success 8381 * none-zero failure code 8382 *==========================================================================*/ 8383 int32_t QCameraParameters::updateFlash(bool commitSettings) 8384 { 8385 int32_t rc = NO_ERROR; 8386 int32_t value; 8387 8388 if (commitSettings) { 8389 if(initBatchUpdate(m_pParamBuf) < 0 ) { 8390 ALOGE("%s:Failed to initialize group update table", __func__); 8391 return BAD_TYPE; 8392 } 8393 } 8394 8395 if (isHDREnabled() || m_bAeBracketingEnabled || m_bAFBracketingOn || 8396 m_bOptiZoomOn || m_bReFocusOn) { 8397 value = CAM_FLASH_MODE_OFF; 8398 } else if (m_bChromaFlashOn) { 8399 value = CAM_FLASH_MODE_ON; 8400 } else { 8401 value = mFlashValue; 8402 } 8403 8404 if (value != mFlashDaemonValue) { 8405 CDBG("%s: Setting Flash value %d", __func__, value); 8406 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_LED_MODE, value)) { 8407 ALOGE("%s:Failed to set led mode", __func__); 8408 return BAD_VALUE; 8409 } 8410 mFlashDaemonValue = value; 8411 } else { 8412 rc = NO_ERROR; 8413 } 8414 8415 if (commitSettings) { 8416 rc = commitSetBatch(); 8417 if (rc != NO_ERROR) { 8418 ALOGE("%s:Failed to configure HDR bracketing", __func__); 8419 return rc; 8420 } 8421 } 8422 8423 return rc; 8424 } 8425 8426 /*=========================================================================== 8427 * FUNCTION : setRedeyeReduction 8428 * 8429 * DESCRIPTION: set red eye reduction value 8430 * 8431 * PARAMETERS : 8432 * @redeyeStr : red eye reduction value string 8433 * 8434 * RETURN : int32_t type of status 8435 * NO_ERROR -- success 8436 * none-zero failure code 8437 *==========================================================================*/ 8438 int32_t QCameraParameters::setRedeyeReduction(const char *redeyeStr) 8439 { 8440 if (redeyeStr != NULL) { 8441 int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP, 8442 PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP), redeyeStr); 8443 if (value != NAME_NOT_FOUND) { 8444 CDBG("%s: Setting RedEye Reduce value %s", __func__, redeyeStr); 8445 updateParamEntry(KEY_QC_REDEYE_REDUCTION, redeyeStr); 8446 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, 8447 CAM_INTF_PARM_REDEYE_REDUCTION, value)) { 8448 return BAD_VALUE; 8449 } 8450 return NO_ERROR; 8451 } 8452 } 8453 ALOGE("%s: Invalid RedEye Reduce value: %s", 8454 __func__, (redeyeStr == NULL) ? "NULL" : redeyeStr); 8455 return BAD_VALUE; 8456 } 8457 8458 /*=========================================================================== 8459 * FUNCTION : getDenoiseProcessPlate 8460 * 8461 * DESCRIPTION: query denoise process plate 8462 * 8463 * PARAMETERS : None 8464 * 8465 * RETURN : NR process plate vlaue 8466 *==========================================================================*/ 8467 cam_denoise_process_type_t 8468 QCameraParameters::getDenoiseProcessPlate(cam_intf_parm_type_t type) 8469 { 8470 char prop[PROPERTY_VALUE_MAX]; 8471 memset(prop, 0, sizeof(prop)); 8472 cam_denoise_process_type_t processPlate = CAM_WAVELET_DENOISE_CBCR_ONLY; 8473 if (CAM_INTF_PARM_WAVELET_DENOISE == type) { 8474 property_get("persist.denoise.process.plates", prop, ""); 8475 } else if (CAM_INTF_PARM_TEMPORAL_DENOISE == type) { 8476 property_get("persist.tnr.process.plates", prop, ""); 8477 } else { 8478 ALOGE("%s: Type not supported", __func__); 8479 prop[0] = '\0'; 8480 } 8481 if (strlen(prop) > 0) { 8482 switch(atoi(prop)) { 8483 case 0: 8484 processPlate = CAM_WAVELET_DENOISE_YCBCR_PLANE; 8485 break; 8486 case 1: 8487 processPlate = CAM_WAVELET_DENOISE_CBCR_ONLY; 8488 break; 8489 case 2: 8490 processPlate = CAM_WAVELET_DENOISE_STREAMLINE_YCBCR; 8491 break; 8492 case 3: 8493 processPlate = CAM_WAVELET_DENOISE_STREAMLINED_CBCR; 8494 break; 8495 default: 8496 processPlate = CAM_WAVELET_DENOISE_CBCR_ONLY; 8497 break; 8498 } 8499 } 8500 return processPlate; 8501 } 8502 8503 /*=========================================================================== 8504 * FUNCTION : setWaveletDenoise 8505 * 8506 * DESCRIPTION: set wavelet denoise value 8507 * 8508 * PARAMETERS : 8509 * @wnrStr : wavelet denoise value string 8510 * 8511 * RETURN : int32_t type of status 8512 * NO_ERROR -- success 8513 * none-zero failure code 8514 *==========================================================================*/ 8515 int32_t QCameraParameters::setWaveletDenoise(const char *wnrStr) 8516 { 8517 if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_DENOISE2D) == 0){ 8518 CDBG_HIGH("%s: WNR is not supported",__func__); 8519 return NO_ERROR; 8520 } 8521 8522 if (wnrStr != NULL) { 8523 int value = lookupAttr(DENOISE_ON_OFF_MODES_MAP, 8524 PARAM_MAP_SIZE(DENOISE_ON_OFF_MODES_MAP), wnrStr); 8525 if (value != NAME_NOT_FOUND) { 8526 updateParamEntry(KEY_QC_DENOISE, wnrStr); 8527 8528 cam_denoise_param_t temp; 8529 memset(&temp, 0, sizeof(temp)); 8530 temp.denoise_enable = (uint8_t)value; 8531 m_bWNROn = (value != 0); 8532 if (m_bWNROn) { 8533 temp.process_plates = getDenoiseProcessPlate(CAM_INTF_PARM_WAVELET_DENOISE); 8534 } 8535 CDBG("%s: Denoise enable=%d, plates=%d", 8536 __func__, temp.denoise_enable, temp.process_plates); 8537 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_WAVELET_DENOISE, temp)) { 8538 return BAD_VALUE; 8539 } 8540 return NO_ERROR; 8541 } 8542 } 8543 ALOGE("%s: Invalid Denoise value: %s", __func__, (wnrStr == NULL) ? "NULL" : wnrStr); 8544 return BAD_VALUE; 8545 } 8546 8547 /*=========================================================================== 8548 * FUNCTION : setRdiMode 8549 * 8550 * DESCRIPTION: set rdi mode value 8551 * 8552 * PARAMETERS : 8553 * @str : rdi mode value string 8554 * 8555 * RETURN : int32_t type of status 8556 * NO_ERROR -- success 8557 * none-zero failure code 8558 *==========================================================================*/ 8559 int32_t QCameraParameters::setRdiMode(const char *str) 8560 { 8561 CDBG("RDI_DEBUG %s: rdi mode value: %s", __func__, str); 8562 8563 if (str != NULL) { 8564 int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP, 8565 PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP), str); 8566 if (value != NAME_NOT_FOUND) { 8567 updateParamEntry(KEY_QC_RDI_MODE, str); 8568 m_bRdiMode = (value == 0) ? false : true; 8569 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_RDI_MODE, value)) { 8570 return BAD_VALUE; 8571 } 8572 return NO_ERROR; 8573 } 8574 } 8575 ALOGE("%s: Invalid rdi mode value: %s", __func__, (str == NULL) ? "NULL" : str); 8576 return BAD_VALUE; 8577 } 8578 8579 8580 /*=========================================================================== 8581 * FUNCTION : setSecureMode 8582 * 8583 * DESCRIPTION: set secure mode value 8584 * 8585 * PARAMETERS : 8586 * @str : secure mode value string 8587 * 8588 * RETURN : int32_t type of status 8589 * NO_ERROR -- success 8590 * none-zero failure code 8591 *==========================================================================*/ 8592 int32_t QCameraParameters::setSecureMode(const char *str) 8593 { 8594 ALOGD("%s: Secure mode value: %s", __func__, str); 8595 8596 if (str != NULL) { 8597 int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP, 8598 PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP), str); 8599 if (value != NAME_NOT_FOUND) { 8600 updateParamEntry(KEY_QC_SECURE_MODE, str); 8601 m_bSecureMode = (value == 0)? false : true; 8602 return NO_ERROR; 8603 } 8604 } 8605 ALOGE("%s: Invalid Secure mode value: %s", 8606 __func__, (str == NULL) ? "NULL" : str); 8607 return BAD_VALUE; 8608 } 8609 8610 /*=========================================================================== 8611 * FUNCTION : setPreviewFrameRateMode 8612 * 8613 * DESCRIPTION: set preview frame rate mode 8614 * 8615 * PARAMETERS : 8616 * @mode : preview frame rate mode 8617 * 8618 * RETURN : none 8619 *==========================================================================*/ 8620 void QCameraParameters::setPreviewFrameRateMode(const char *mode) 8621 { 8622 set(KEY_QC_PREVIEW_FRAME_RATE_MODE, mode); 8623 } 8624 8625 /*=========================================================================== 8626 * FUNCTION : getPreviewFrameRateMode 8627 * 8628 * DESCRIPTION: get preview frame rate mode 8629 * 8630 * PARAMETERS : none 8631 * 8632 * RETURN : preview frame rate mode string 8633 *==========================================================================*/ 8634 const char *QCameraParameters::getPreviewFrameRateMode() const 8635 { 8636 return get(KEY_QC_PREVIEW_FRAME_RATE_MODE); 8637 } 8638 8639 /*=========================================================================== 8640 * FUNCTION : setTouchIndexAec 8641 * 8642 * DESCRIPTION: set touch index AEC 8643 * 8644 * PARAMETERS : 8645 * @x,y : 8646 * 8647 * RETURN : none 8648 *==========================================================================*/ 8649 void QCameraParameters::setTouchIndexAec(int x, int y) 8650 { 8651 char str[32]; 8652 snprintf(str, sizeof(str), "%dx%d", x, y); 8653 set(KEY_QC_TOUCH_INDEX_AEC, str); 8654 } 8655 8656 /*=========================================================================== 8657 * FUNCTION : getTouchIndexAec 8658 * 8659 * DESCRIPTION: get touch index AEC 8660 * 8661 * PARAMETERS : 8662 * @x,y : 8663 * 8664 * RETURN : none 8665 *==========================================================================*/ 8666 void QCameraParameters::getTouchIndexAec(int *x, int *y) 8667 { 8668 *x = -1; 8669 *y = -1; 8670 8671 // Get the current string, if it doesn't exist, leave the -1x-1 8672 const char *p = get(KEY_QC_TOUCH_INDEX_AEC); 8673 if (p == 0) 8674 return; 8675 8676 int tempX, tempY; 8677 if (parse_pair(p, &tempX, &tempY, 'x') == 0) { 8678 *x = tempX; 8679 *y = tempY; 8680 } 8681 } 8682 8683 /*=========================================================================== 8684 * FUNCTION : setTouchIndexAf 8685 * 8686 * DESCRIPTION: set touch index AF 8687 * 8688 * PARAMETERS : 8689 * @x,y : 8690 * 8691 * RETURN : none 8692 *==========================================================================*/ 8693 void QCameraParameters::setTouchIndexAf(int x, int y) 8694 { 8695 char str[32]; 8696 snprintf(str, sizeof(str), "%dx%d", x, y); 8697 set(KEY_QC_TOUCH_INDEX_AF, str); 8698 } 8699 8700 /*=========================================================================== 8701 * FUNCTION : getTouchIndexAf 8702 * 8703 * DESCRIPTION: get touch index AF 8704 * 8705 * PARAMETERS : 8706 * @x,y : 8707 * 8708 * RETURN : none 8709 *==========================================================================*/ 8710 void QCameraParameters::getTouchIndexAf(int *x, int *y) 8711 { 8712 *x = -1; 8713 *y = -1; 8714 8715 // Get the current string, if it doesn't exist, leave the -1x-1 8716 const char *p = get(KEY_QC_TOUCH_INDEX_AF); 8717 if (p == 0) 8718 return; 8719 8720 int tempX, tempY; 8721 if (parse_pair(p, &tempX, &tempY, 'x') == 0) { 8722 *x = tempX; 8723 *y = tempY; 8724 } 8725 } 8726 8727 /*=========================================================================== 8728 * FUNCTION : getStreamFormat 8729 * 8730 * DESCRIPTION: get stream format by its type 8731 * 8732 * PARAMETERS : 8733 * @streamType : [input] stream type 8734 * @format : [output] stream format 8735 * 8736 * RETURN : int32_t type of status 8737 * NO_ERROR -- success 8738 * none-zero failure code 8739 *==========================================================================*/ 8740 int32_t QCameraParameters::getStreamRotation(cam_stream_type_t streamType, 8741 cam_pp_feature_config_t &featureConfig, 8742 cam_dimension_t &dim) 8743 { 8744 int32_t ret = NO_ERROR; 8745 const char *str = get(KEY_QC_VIDEO_ROTATION); 8746 int rotationParam = lookupAttr(VIDEO_ROTATION_MODES_MAP, 8747 PARAM_MAP_SIZE(VIDEO_ROTATION_MODES_MAP), str); 8748 featureConfig.rotation = ROTATE_0; 8749 int swapDim = 0; 8750 switch (streamType) { 8751 case CAM_STREAM_TYPE_VIDEO: 8752 switch(rotationParam) { 8753 case 90: 8754 featureConfig.feature_mask |= CAM_QCOM_FEATURE_ROTATION; 8755 featureConfig.rotation = ROTATE_90; 8756 swapDim = 1; 8757 break; 8758 case 180: 8759 featureConfig.feature_mask |= CAM_QCOM_FEATURE_ROTATION; 8760 featureConfig.rotation = ROTATE_180; 8761 break; 8762 case 270: 8763 featureConfig.feature_mask |= CAM_QCOM_FEATURE_ROTATION; 8764 featureConfig.rotation = ROTATE_270; 8765 swapDim = 1; 8766 break; 8767 default: 8768 featureConfig.rotation = ROTATE_0; 8769 } 8770 break; 8771 case CAM_STREAM_TYPE_PREVIEW: 8772 case CAM_STREAM_TYPE_POSTVIEW: 8773 case CAM_STREAM_TYPE_SNAPSHOT: 8774 case CAM_STREAM_TYPE_RAW: 8775 case CAM_STREAM_TYPE_METADATA: 8776 case CAM_STREAM_TYPE_OFFLINE_PROC: 8777 case CAM_STREAM_TYPE_DEFAULT: 8778 default: 8779 break; 8780 } 8781 8782 if (swapDim > 0) { 8783 int w = 0; 8784 w = dim.width; 8785 dim.width = dim.height; 8786 dim.height = w; 8787 } 8788 return ret; 8789 } 8790 8791 /*=========================================================================== 8792 * FUNCTION : getStreamFormat 8793 * 8794 * DESCRIPTION: get stream format by its type 8795 * 8796 * PARAMETERS : 8797 * @streamType : [input] stream type 8798 * @format : [output] stream format 8799 * 8800 * RETURN : int32_t type of status 8801 * NO_ERROR -- success 8802 * none-zero failure code 8803 *==========================================================================*/ 8804 int32_t QCameraParameters::getStreamFormat(cam_stream_type_t streamType, 8805 cam_format_t &format) 8806 { 8807 int32_t ret = NO_ERROR; 8808 8809 format = CAM_FORMAT_MAX; 8810 switch (streamType) { 8811 case CAM_STREAM_TYPE_ANALYSIS: 8812 case CAM_STREAM_TYPE_PREVIEW: 8813 case CAM_STREAM_TYPE_POSTVIEW: 8814 format = mPreviewFormat; 8815 break; 8816 case CAM_STREAM_TYPE_SNAPSHOT: 8817 if ( mPictureFormat == CAM_FORMAT_YUV_422_NV16 ) { 8818 format = CAM_FORMAT_YUV_422_NV16; 8819 } else { 8820 char prop[PROPERTY_VALUE_MAX]; 8821 int snapshotFormat; 8822 memset(prop, 0, sizeof(prop)); 8823 property_get("persist.camera.snap.format", prop, "0"); 8824 snapshotFormat = atoi(prop); 8825 if(snapshotFormat == 1) { 8826 format = CAM_FORMAT_YUV_422_NV61; 8827 } else { 8828 format = CAM_FORMAT_YUV_420_NV21; 8829 } 8830 } 8831 break; 8832 case CAM_STREAM_TYPE_VIDEO: 8833 format = CAM_FORMAT_YUV_420_NV12; 8834 break; 8835 case CAM_STREAM_TYPE_RAW: 8836 if (isRdiMode()) { 8837 format = m_pCapability->rdi_mode_stream_fmt; 8838 } else if (mPictureFormat >= CAM_FORMAT_YUV_RAW_8BIT_YUYV) { 8839 format = (cam_format_t)mPictureFormat; 8840 } else if (getofflineRAW()) { 8841 format = CAM_FORMAT_BAYER_MIPI_RAW_10BPP_BGGR; 8842 } else { 8843 char raw_format[PROPERTY_VALUE_MAX]; 8844 int rawFormat; 8845 memset(raw_format, 0, sizeof(raw_format)); 8846 /*Default value is CAM_FORMAT_BAYER_QCOM_RAW_10BPP_GBRG*/ 8847 property_get("persist.camera.raw.format", raw_format, "16"); 8848 rawFormat = atoi(raw_format); 8849 format = (cam_format_t)rawFormat; 8850 CDBG_HIGH("%s: Raw stream format %d bundled with snapshot", 8851 __func__, format); 8852 } 8853 break; 8854 case CAM_STREAM_TYPE_METADATA: 8855 case CAM_STREAM_TYPE_OFFLINE_PROC: 8856 case CAM_STREAM_TYPE_DEFAULT: 8857 default: 8858 break; 8859 } 8860 8861 return ret; 8862 } 8863 8864 /*=========================================================================== 8865 * FUNCTION : getFlipMode 8866 * 8867 * DESCRIPTION: get flip mode 8868 * 8869 * PARAMETERS : 8870 * @cam_intf_parm_type_t : [input] stream type 8871 * 8872 * RETURN : int type of flip mode 8873 * 0 - no filp 8874 * 1 - FLIP_H 8875 * 2 - FLIP_V 8876 * 3 - FLIP_H | FLIP_V 8877 *==========================================================================*/ 8878 int QCameraParameters::getFlipMode(cam_stream_type_t type) 8879 { 8880 const char *str = NULL; 8881 int flipMode = 0; // no flip 8882 8883 switch(type){ 8884 case CAM_STREAM_TYPE_PREVIEW: 8885 if (!isRdiMode()) { 8886 str = get(KEY_QC_PREVIEW_FLIP); 8887 } 8888 break; 8889 case CAM_STREAM_TYPE_VIDEO: 8890 str = get(KEY_QC_VIDEO_FLIP); 8891 break; 8892 case CAM_STREAM_TYPE_SNAPSHOT: 8893 case CAM_STREAM_TYPE_POSTVIEW: 8894 str = get(KEY_QC_SNAPSHOT_PICTURE_FLIP); 8895 break; 8896 default: 8897 CDBG("%s: No flip mode for stream type %d", __func__, type); 8898 break; 8899 } 8900 8901 if(str != NULL){ 8902 //Need give corresponding filp value based on flip mode strings 8903 int value = lookupAttr(FLIP_MODES_MAP, PARAM_MAP_SIZE(FLIP_MODES_MAP), str); 8904 if(value != NAME_NOT_FOUND) 8905 flipMode = value; 8906 } 8907 8908 CDBG_HIGH("%s: the filp mode of stream type %d is %d .", __func__, type, flipMode); 8909 return flipMode; 8910 } 8911 8912 /*=========================================================================== 8913 * FUNCTION : isSnapshotFDNeeded 8914 * 8915 * DESCRIPTION: check whether Face Detection Metadata is needed 8916 * 8917 * PARAMETERS : none 8918 * 8919 * RETURN : bool type of status 8920 * 0 - need 8921 * 1 - not need 8922 *==========================================================================*/ 8923 bool QCameraParameters::isSnapshotFDNeeded() 8924 { 8925 return getInt(KEY_QC_SNAPSHOT_FD_DATA); 8926 } 8927 8928 /*=========================================================================== 8929 * FUNCTION : getStreamDimension 8930 * 8931 * DESCRIPTION: get stream dimension by its type 8932 * 8933 * PARAMETERS : 8934 * @streamType : [input] stream type 8935 * @dim : [output] stream dimension 8936 * 8937 * RETURN : int32_t type of status 8938 * NO_ERROR -- success 8939 * none-zero failure code 8940 *==========================================================================*/ 8941 int32_t QCameraParameters::getStreamDimension(cam_stream_type_t streamType, 8942 cam_dimension_t &dim) 8943 { 8944 int32_t ret = NO_ERROR; 8945 memset(&dim, 0, sizeof(cam_dimension_t)); 8946 8947 switch (streamType) { 8948 case CAM_STREAM_TYPE_PREVIEW: 8949 getPreviewSize(&dim.width, &dim.height); 8950 break; 8951 case CAM_STREAM_TYPE_POSTVIEW: 8952 getPreviewSize(&dim.width, &dim.height); 8953 break; 8954 case CAM_STREAM_TYPE_SNAPSHOT: 8955 if (getRecordingHintValue() == true) { 8956 // live snapshot 8957 getLiveSnapshotSize(dim); 8958 } else { 8959 getPictureSize(&dim.width, &dim.height); 8960 } 8961 break; 8962 case CAM_STREAM_TYPE_VIDEO: 8963 getVideoSize(&dim.width, &dim.height); 8964 break; 8965 case CAM_STREAM_TYPE_RAW: 8966 //dim = m_pCapability->raw_dim; 8967 getRawSize(dim); 8968 break; 8969 case CAM_STREAM_TYPE_METADATA: 8970 dim.width = (int32_t)sizeof(metadata_buffer_t); 8971 dim.height = 1; 8972 break; 8973 case CAM_STREAM_TYPE_OFFLINE_PROC: 8974 break; 8975 case CAM_STREAM_TYPE_ANALYSIS: 8976 cam_dimension_t prv_dim, max_dim; 8977 8978 /* Analysis stream need aspect ratio as preview stream */ 8979 getPreviewSize(&prv_dim.width, &prv_dim.height); 8980 8981 max_dim.width = m_pCapability->analysis_max_res.width; 8982 max_dim.height = m_pCapability->analysis_max_res.height; 8983 8984 if (prv_dim.width > max_dim.width || prv_dim.height > max_dim.height) { 8985 double max_ratio, requested_ratio; 8986 8987 max_ratio = (double)max_dim.width / (double)max_dim.height; 8988 requested_ratio = (double)prv_dim.width / (double)prv_dim.height; 8989 8990 if (max_ratio < requested_ratio) { 8991 dim.width = max_dim.width; 8992 dim.height = (int32_t)((double)dim.width / requested_ratio); 8993 } else { 8994 dim.height = max_dim.height; 8995 dim.width = (int32_t)((double)max_dim.height * requested_ratio); 8996 } 8997 dim.width &= ~0x1; 8998 dim.height &= ~0x1; 8999 } else { 9000 dim.width = prv_dim.width; 9001 dim.height = prv_dim.height; 9002 } 9003 break; 9004 case CAM_STREAM_TYPE_DEFAULT: 9005 default: 9006 ALOGE("%s: no dimension for unsupported stream type %d", 9007 __func__, streamType); 9008 ret = BAD_VALUE; 9009 break; 9010 } 9011 return ret; 9012 } 9013 9014 /*=========================================================================== 9015 * FUNCTION : getPreviewHalPixelFormat 9016 * 9017 * DESCRIPTION: get preview HAL pixel format 9018 * 9019 * PARAMETERS : none 9020 * 9021 * RETURN : HAL pixel format 9022 *==========================================================================*/ 9023 int QCameraParameters::getPreviewHalPixelFormat() const 9024 { 9025 int32_t halPixelFormat; 9026 9027 switch (mPreviewFormat) { 9028 case CAM_FORMAT_YUV_420_NV12: 9029 halPixelFormat = HAL_PIXEL_FORMAT_YCbCr_420_SP; 9030 break; 9031 case CAM_FORMAT_YUV_420_NV21: 9032 halPixelFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP; 9033 break; 9034 case CAM_FORMAT_YUV_420_NV21_ADRENO: 9035 halPixelFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO; 9036 break; 9037 case CAM_FORMAT_YUV_420_YV12: 9038 halPixelFormat = HAL_PIXEL_FORMAT_YV12; 9039 break; 9040 case CAM_FORMAT_YUV_420_NV12_VENUS: 9041 halPixelFormat = HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS; 9042 break; 9043 case CAM_FORMAT_YUV_422_NV16: 9044 case CAM_FORMAT_YUV_422_NV61: 9045 default: 9046 halPixelFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP; 9047 break; 9048 } 9049 CDBG_HIGH("%s: format %d\n", __func__, halPixelFormat); 9050 return halPixelFormat; 9051 } 9052 9053 /*=========================================================================== 9054 * FUNCTION : getthumbnailSize 9055 * 9056 * DESCRIPTION: get thumbnail size 9057 * 9058 * PARAMETERS : 9059 * @width, height : [output] thumbnail width and height 9060 * 9061 * RETURN : none 9062 *==========================================================================*/ 9063 void QCameraParameters::getThumbnailSize(int *width, int *height) const 9064 { 9065 *width = getInt(KEY_JPEG_THUMBNAIL_WIDTH); 9066 *height = getInt(KEY_JPEG_THUMBNAIL_HEIGHT); 9067 } 9068 9069 /*=========================================================================== 9070 * FUNCTION : getZSLBurstInterval 9071 * 9072 * DESCRIPTION: get ZSL burst interval setting 9073 * 9074 * PARAMETERS : none 9075 * 9076 * RETURN : ZSL burst interval value 9077 *==========================================================================*/ 9078 uint8_t QCameraParameters::getZSLBurstInterval() 9079 { 9080 int interval = getInt(KEY_QC_ZSL_BURST_INTERVAL); 9081 if (interval < 0) { 9082 interval = 1; 9083 } 9084 return (uint8_t)interval; 9085 } 9086 9087 /*=========================================================================== 9088 * FUNCTION : getZSLQueueDepth 9089 * 9090 * DESCRIPTION: get ZSL queue depth 9091 * 9092 * PARAMETERS : none 9093 * 9094 * RETURN : ZSL queue depth value 9095 *==========================================================================*/ 9096 uint8_t QCameraParameters::getZSLQueueDepth() 9097 { 9098 int qdepth = getInt(KEY_QC_ZSL_QUEUE_DEPTH); 9099 if (qdepth < 0) { 9100 qdepth = 2; 9101 } 9102 return (uint8_t)qdepth; 9103 } 9104 9105 /*=========================================================================== 9106 * FUNCTION : getZSLBackLookCount 9107 * 9108 * DESCRIPTION: get ZSL backlook count setting 9109 * 9110 * PARAMETERS : none 9111 * 9112 * RETURN : ZSL backlook count value 9113 *==========================================================================*/ 9114 uint8_t QCameraParameters::getZSLBackLookCount() 9115 { 9116 int look_back = getInt(KEY_QC_ZSL_BURST_LOOKBACK); 9117 if (look_back < 0) { 9118 look_back = 2; 9119 } 9120 return (uint8_t)look_back; 9121 } 9122 9123 /*=========================================================================== 9124 * FUNCTION : getZSLMaxUnmatchedFrames 9125 * 9126 * DESCRIPTION: get allowed ZSL max unmatched frames number 9127 * 9128 * PARAMETERS : none 9129 * 9130 * RETURN : ZSL backlook count value 9131 *==========================================================================*/ 9132 uint8_t QCameraParameters::getMaxUnmatchedFramesInQueue() 9133 { 9134 return (uint8_t)(m_pCapability->min_num_pp_bufs + (m_nBurstNum / 10)); 9135 } 9136 9137 /*=========================================================================== 9138 * FUNCTION : setRecordingHintValue 9139 * 9140 * DESCRIPTION: set recording hint 9141 * 9142 * PARAMETERS : 9143 * @value : video hint value 9144 * 9145 * RETURN : int32_t type of status 9146 * NO_ERROR -- success 9147 * none-zero failure code 9148 *==========================================================================*/ 9149 int QCameraParameters::setRecordingHintValue(int32_t value) 9150 { 9151 CDBG_HIGH("%s: VideoHint = %d", __func__, value); 9152 bool newValue = (value > 0)? true : false; 9153 9154 if ( m_bRecordingHint != newValue ) { 9155 m_bNeedRestart = true; 9156 m_bRecordingHint_new = newValue; 9157 } else { 9158 m_bRecordingHint_new = m_bRecordingHint; 9159 } 9160 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_RECORDING_HINT, value)) { 9161 return BAD_VALUE; 9162 } 9163 9164 return NO_ERROR; 9165 } 9166 9167 /*=========================================================================== 9168 * FUNCTION : getNumOfSnapshots 9169 * 9170 * DESCRIPTION: get number of snapshot per shutter 9171 * 9172 * PARAMETERS : none 9173 * 9174 * RETURN : number of snapshot per shutter 9175 *==========================================================================*/ 9176 uint8_t QCameraParameters::getNumOfSnapshots() 9177 { 9178 uint8_t numOfSnapshot = 1; 9179 int val = getInt(KEY_QC_NUM_SNAPSHOT_PER_SHUTTER); 9180 if (0 < val) { 9181 numOfSnapshot = (uint8_t)val; 9182 } 9183 9184 return (uint8_t)numOfSnapshot; 9185 } 9186 9187 /*=========================================================================== 9188 * FUNCTION : getBurstCountForAdvancedCapture 9189 * 9190 * DESCRIPTION: get burst count for advanced capture. 9191 * 9192 * PARAMETERS : none 9193 * 9194 * RETURN : number of snapshot required for advanced capture. 9195 *==========================================================================*/ 9196 uint8_t QCameraParameters::getBurstCountForAdvancedCapture() 9197 { 9198 uint32_t burstCount = 0; 9199 if (isUbiFocusEnabled()) { 9200 //number of snapshots required for Ubi Focus. 9201 burstCount = m_pCapability->ubifocus_af_bracketing_need.burst_count; 9202 } else if (isUbiRefocus()) { 9203 //number of snapshots required for Opti Zoom. 9204 burstCount = m_pCapability->refocus_af_bracketing_need.burst_count; 9205 } else if (isOptiZoomEnabled()) { 9206 //number of snapshots required for Opti Zoom. 9207 burstCount = m_pCapability->opti_zoom_settings_need.burst_count; 9208 } else if (isChromaFlashEnabled()) { 9209 //number of snapshots required for Chroma Flash. 9210 burstCount = m_pCapability->chroma_flash_settings_need.burst_count; 9211 } else if (isStillMoreEnabled()) { 9212 //number of snapshots required for Still More. 9213 if (isSeeMoreEnabled()) { 9214 burstCount = 1; 9215 } else if ((m_stillmore_config.burst_count >= 9216 m_pCapability->stillmore_settings_need.min_burst_count) && 9217 (m_stillmore_config.burst_count <= 9218 m_pCapability->stillmore_settings_need.max_burst_count)) { 9219 burstCount = m_stillmore_config.burst_count; 9220 } else { 9221 burstCount = m_pCapability->stillmore_settings_need.burst_count; 9222 } 9223 } else if (isHDREnabled()) { 9224 //number of snapshots required for HDR. 9225 burstCount = m_pCapability->hdr_bracketing_setting.num_frames; 9226 } else if (isAEBracketEnabled()) { 9227 burstCount = 0; 9228 const char *str_val = m_AEBracketingClient.values; 9229 if ((str_val != NULL) && (strlen(str_val) > 0)) { 9230 char prop[PROPERTY_VALUE_MAX]; 9231 memset(prop, 0, sizeof(prop)); 9232 strlcpy(prop, str_val, PROPERTY_VALUE_MAX); 9233 char *saveptr = NULL; 9234 char *token = strtok_r(prop, ",", &saveptr); 9235 while (token != NULL) { 9236 token = strtok_r(NULL, ",", &saveptr); 9237 burstCount++; 9238 } 9239 } 9240 } 9241 if (burstCount <= 0) { 9242 burstCount = 1; 9243 } 9244 9245 CDBG_HIGH("%s: Snapshot burst count = %d", __func__, burstCount); 9246 return (uint8_t)burstCount; 9247 } 9248 9249 /*=========================================================================== 9250 * FUNCTION : getNumOfRetroSnapshots 9251 * 9252 * DESCRIPTION: get number of retro active snapshots per shutter 9253 * 9254 * PARAMETERS : none 9255 * 9256 * RETURN : number of retro active snapshots per shutter 9257 *==========================================================================*/ 9258 uint8_t QCameraParameters::getNumOfRetroSnapshots() 9259 { 9260 int numOfRetroSnapshots = getInt(KEY_QC_NUM_RETRO_BURST_PER_SHUTTER); 9261 if (numOfRetroSnapshots < 0) { 9262 numOfRetroSnapshots = 0; 9263 } 9264 CDBG_HIGH("%s: [ZSL Retro] : numOfRetroSnaps - %d", __func__, numOfRetroSnapshots); 9265 return (uint8_t)numOfRetroSnapshots; 9266 } 9267 9268 /*=========================================================================== 9269 * FUNCTION : getBurstLEDOnPeriod 9270 * 9271 * DESCRIPTION: get burst LED on period 9272 * 9273 * PARAMETERS : none 9274 * 9275 * RETURN : burst LED on period 9276 *==========================================================================*/ 9277 int QCameraParameters::getBurstLEDOnPeriod() 9278 { 9279 CDBG_HIGH("%s: [ZSL Retro] burst LED ON period: %d", __func__, m_nBurstLEDOnPeriod); 9280 return m_nBurstLEDOnPeriod; 9281 } 9282 9283 /*=========================================================================== 9284 * FUNCTION : getNumOfExtraHDRInBufsIfNeeded 9285 * 9286 * DESCRIPTION: get number of extra input buffers needed by HDR 9287 * 9288 * PARAMETERS : none 9289 * 9290 * RETURN : number of extra buffers needed by HDR; 0 if not HDR enabled 9291 *==========================================================================*/ 9292 uint8_t QCameraParameters::getNumOfExtraHDRInBufsIfNeeded() 9293 { 9294 unsigned int numOfBufs = 0; 9295 9296 if (isHDREnabled()) { 9297 numOfBufs += m_pCapability->hdr_bracketing_setting.num_frames; 9298 if (isHDR1xFrameEnabled() && isHDR1xExtraBufferNeeded()) { 9299 numOfBufs++; 9300 } 9301 numOfBufs--; // Only additional buffers need to be returned 9302 } 9303 9304 return (uint8_t)(numOfBufs * getBurstNum()); 9305 } 9306 9307 /*=========================================================================== 9308 * FUNCTION : getNumOfExtraHDROutBufsIfNeeded 9309 * 9310 * DESCRIPTION: get number of extra output buffers needed by HDR 9311 * 9312 * PARAMETERS : none 9313 * 9314 * RETURN : number of extra buffers needed by HDR; 0 if not HDR enabled 9315 *==========================================================================*/ 9316 uint8_t QCameraParameters::getNumOfExtraHDROutBufsIfNeeded() 9317 { 9318 int numOfBufs = 0; 9319 9320 if (isHDREnabled() && isHDR1xFrameEnabled()) { 9321 numOfBufs++; 9322 } 9323 9324 return (uint8_t)(numOfBufs * getBurstNum()); 9325 } 9326 9327 /*=========================================================================== 9328 * FUNCTION : getBurstNum 9329 * 9330 * DESCRIPTION: get burst number of snapshot 9331 * 9332 * PARAMETERS : none 9333 * 9334 * RETURN : number of burst 9335 *==========================================================================*/ 9336 uint8_t QCameraParameters::getBurstNum() 9337 { 9338 CDBG_HIGH("%s: m_nBurstNum = %d", __func__, m_nBurstNum); 9339 return m_nBurstNum; 9340 } 9341 9342 /*=========================================================================== 9343 * FUNCTION : getJpegQuality 9344 * 9345 * DESCRIPTION: get jpeg encoding quality 9346 * 9347 * PARAMETERS : none 9348 * 9349 * RETURN : jpeg encoding quality 9350 *==========================================================================*/ 9351 uint32_t QCameraParameters::getJpegQuality() 9352 { 9353 int quality = getInt(KEY_JPEG_QUALITY); 9354 if (quality < 0) { 9355 quality = 85; // set to default quality value 9356 } 9357 return (uint32_t)quality; 9358 } 9359 9360 /*=========================================================================== 9361 * FUNCTION : getJpegRotation 9362 * 9363 * DESCRIPTION: get jpeg rotation value 9364 * 9365 * PARAMETERS : none 9366 * 9367 * RETURN : jpeg rotation value 9368 *==========================================================================*/ 9369 uint32_t QCameraParameters::getJpegRotation() { 9370 int rotation = 0; 9371 9372 //If exif rotation is set, do not rotate captured image 9373 if (!useJpegExifRotation()) { 9374 rotation = mRotation; 9375 if (rotation < 0) { 9376 rotation = 0; 9377 } 9378 } 9379 return (uint32_t)rotation; 9380 } 9381 9382 /*=========================================================================== 9383 * FUNCTION : getDeviceRotation 9384 * 9385 * DESCRIPTION: get device rotation value 9386 * 9387 * PARAMETERS : none 9388 * 9389 * RETURN : device rotation value 9390 *==========================================================================*/ 9391 uint32_t QCameraParameters::getDeviceRotation() { 9392 int rotation = 0; 9393 9394 rotation = mRotation; 9395 if (rotation < 0) { 9396 rotation = 0; 9397 } 9398 9399 return (uint32_t)rotation; 9400 } 9401 9402 /*=========================================================================== 9403 * FUNCTION : getJpegExifRotation 9404 * 9405 * DESCRIPTION: get exif rotation value 9406 * 9407 * PARAMETERS : none 9408 * 9409 * RETURN : rotation value 9410 *==========================================================================*/ 9411 uint32_t QCameraParameters::getJpegExifRotation() { 9412 int rotation = 0; 9413 9414 if (useJpegExifRotation()) { 9415 rotation = mRotation; 9416 if (rotation < 0) { 9417 rotation = 0; 9418 } 9419 } 9420 return (uint32_t)rotation; 9421 } 9422 9423 /*=========================================================================== 9424 * FUNCTION : useJpegExifRotation 9425 * 9426 * DESCRIPTION: Check if jpeg exif rotation need to be used 9427 * 9428 * PARAMETERS : none 9429 * 9430 * RETURN : true if jpeg exif rotation need to be used 9431 *==========================================================================*/ 9432 bool QCameraParameters::useJpegExifRotation() { 9433 char exifRotation[PROPERTY_VALUE_MAX]; 9434 9435 property_get("persist.camera.exif.rotation", exifRotation, "off"); 9436 if (!strcmp(exifRotation, "on")) { 9437 return true; 9438 } 9439 return false; 9440 } 9441 9442 /*=========================================================================== 9443 * FUNCTION : getEffectValue 9444 * 9445 * DESCRIPTION: get effect value 9446 * 9447 * PARAMETERS : none 9448 * 9449 * RETURN : effect value 9450 *==========================================================================*/ 9451 int32_t QCameraParameters::getEffectValue() 9452 { 9453 uint32_t cnt = 0; 9454 const char *effect = get(KEY_EFFECT); 9455 if (effect) { 9456 while (NULL != EFFECT_MODES_MAP[cnt].desc) { 9457 if (!strcmp(EFFECT_MODES_MAP[cnt].desc, effect)) { 9458 return EFFECT_MODES_MAP[cnt].val; 9459 } 9460 cnt++; 9461 } 9462 } else { 9463 ALOGE("%s: Missing effect value", __func__); 9464 } 9465 return CAM_EFFECT_MODE_OFF; 9466 } 9467 9468 /*=========================================================================== 9469 * FUNCTION : parseGPSCoordinate 9470 * 9471 * DESCRIPTION: parse GPS coordinate string 9472 * 9473 * PARAMETERS : 9474 * @coord_str : [input] coordinate string 9475 * @coord : [output] ptr to struct to store coordinate 9476 * 9477 * RETURN : int32_t type of status 9478 * NO_ERROR -- success 9479 * none-zero failure code 9480 *==========================================================================*/ 9481 int QCameraParameters::parseGPSCoordinate(const char *coord_str, rat_t* coord) 9482 { 9483 if(coord == NULL) { 9484 ALOGE("%s: error, invalid argument coord == NULL", __func__); 9485 return BAD_VALUE; 9486 } 9487 double degF = atof(coord_str); 9488 if (degF < 0) { 9489 degF = -degF; 9490 } 9491 double minF = (degF - (double)(int) degF) * 60.0; 9492 double secF = (minF - (double)(int) minF) * 60.0; 9493 9494 getRational(&coord[0], (int)degF, 1); 9495 getRational(&coord[1], (int)minF, 1); 9496 getRational(&coord[2], (int)(secF * 10000.0), 10000); 9497 return NO_ERROR; 9498 } 9499 9500 /*=========================================================================== 9501 * FUNCTION : getExifDateTime 9502 * 9503 * DESCRIPTION: query exif date time 9504 * 9505 * PARAMETERS : 9506 * @dateTime : String to store exif date time. 9507 * Should be leaved unchanged in case of error. 9508 * @subsecTime : String to store exif time nanoseconds. 9509 * Should be leaved unchanged in case of error. 9510 * 9511 * RETURN : int32_t type of status 9512 * NO_ERROR -- success 9513 * none-zero failure code 9514 *==========================================================================*/ 9515 int32_t QCameraParameters::getExifDateTime(String8 &dateTime, String8 &subsecTime) 9516 { 9517 int32_t ret = NO_ERROR; 9518 9519 //get time and date from system 9520 struct timeval tv; 9521 struct tm timeinfo_data; 9522 9523 int res = gettimeofday(&tv, NULL); 9524 if (0 == res) { 9525 struct tm *timeinfo = localtime_r(&tv.tv_sec, &timeinfo_data); 9526 if (NULL != timeinfo) { 9527 //Write datetime according to EXIF Spec 9528 //"YYYY:MM:DD HH:MM:SS" (20 chars including \0) 9529 dateTime = String8::format("%04d:%02d:%02d %02d:%02d:%02d", 9530 timeinfo->tm_year + 1900, timeinfo->tm_mon + 1, 9531 timeinfo->tm_mday, timeinfo->tm_hour, 9532 timeinfo->tm_min, timeinfo->tm_sec); 9533 //Write subsec according to EXIF Sepc 9534 subsecTime = String8::format("%06ld", tv.tv_usec); 9535 } else { 9536 ALOGE("%s: localtime_r() error", __func__); 9537 ret = UNKNOWN_ERROR; 9538 } 9539 } else if (-1 == res) { 9540 ALOGE("%s: gettimeofday() error: %s", __func__, strerror(errno)); 9541 ret = UNKNOWN_ERROR; 9542 } else { 9543 ALOGE("%s: gettimeofday() unexpected return code: %d", __func__, res); 9544 ret = UNKNOWN_ERROR; 9545 } 9546 9547 return ret; 9548 } 9549 9550 /*=========================================================================== 9551 * FUNCTION : getRational 9552 * 9553 * DESCRIPTION: compose rational struct 9554 * 9555 * PARAMETERS : 9556 * @rat : ptr to struct to store rational info 9557 * @num :num of the rational 9558 * @denom : denom of the rational 9559 * 9560 * RETURN : int32_t type of status 9561 * NO_ERROR -- success 9562 * none-zero failure code 9563 *==========================================================================*/ 9564 int32_t QCameraParameters::getRational(rat_t *rat, int num, int denom) 9565 { 9566 if ((0 > num) || (0 > denom)) { 9567 ALOGE("%s: Negative values", __func__); 9568 return BAD_VALUE; 9569 } 9570 if (NULL == rat) { 9571 ALOGE("%s: NULL rat input", __func__); 9572 return BAD_VALUE; 9573 } 9574 rat->num = (uint32_t)num; 9575 rat->denom = (uint32_t)denom; 9576 return NO_ERROR; 9577 } 9578 9579 /*=========================================================================== 9580 * FUNCTION : getExifFocalLength 9581 * 9582 * DESCRIPTION: get exif focal lenght 9583 * 9584 * PARAMETERS : 9585 * @focalLength : ptr to rational strcut to store focal lenght 9586 * 9587 * RETURN : int32_t type of status 9588 * NO_ERROR -- success 9589 * none-zero failure code 9590 *==========================================================================*/ 9591 int32_t QCameraParameters::getExifFocalLength(rat_t *focalLength) 9592 { 9593 int focalLengthValue = 9594 (int)(getFloat(QCameraParameters::KEY_FOCAL_LENGTH) * FOCAL_LENGTH_DECIMAL_PRECISION); 9595 return getRational(focalLength, focalLengthValue, FOCAL_LENGTH_DECIMAL_PRECISION); 9596 } 9597 9598 /*=========================================================================== 9599 * FUNCTION : getExifIsoSpeed 9600 * 9601 * DESCRIPTION: get exif ISO speed 9602 * 9603 * PARAMETERS : none 9604 * 9605 * RETURN : ISO speed value 9606 *==========================================================================*/ 9607 uint16_t QCameraParameters::getExifIsoSpeed() 9608 { 9609 uint16_t isoSpeed = 0; 9610 const char *iso_str = get(QCameraParameters::KEY_QC_ISO_MODE); 9611 int iso_index = lookupAttr(ISO_MODES_MAP, PARAM_MAP_SIZE(ISO_MODES_MAP), iso_str); 9612 switch (iso_index) { 9613 case CAM_ISO_MODE_AUTO: 9614 isoSpeed = 0; 9615 break; 9616 case CAM_ISO_MODE_DEBLUR: 9617 isoSpeed = 1; 9618 break; 9619 case CAM_ISO_MODE_100: 9620 isoSpeed = 100; 9621 break; 9622 case CAM_ISO_MODE_200: 9623 isoSpeed = 200; 9624 break; 9625 case CAM_ISO_MODE_400: 9626 isoSpeed = 400; 9627 break; 9628 case CAM_ISO_MODE_800: 9629 isoSpeed = 800; 9630 break; 9631 case CAM_ISO_MODE_1600: 9632 isoSpeed = 1600; 9633 break; 9634 case CAM_ISO_MODE_3200: 9635 isoSpeed = 3200; 9636 break; 9637 } 9638 return isoSpeed; 9639 } 9640 9641 /*=========================================================================== 9642 * FUNCTION : getExifGpsProcessingMethod 9643 * 9644 * DESCRIPTION: get GPS processing method 9645 * 9646 * PARAMETERS : 9647 * @gpsProcessingMethod : string to store GPS process method 9648 * @count : lenght of the string 9649 * 9650 * RETURN : int32_t type of status 9651 * NO_ERROR -- success 9652 * none-zero failure code 9653 *==========================================================================*/ 9654 int32_t QCameraParameters::getExifGpsProcessingMethod(char *gpsProcessingMethod, 9655 uint32_t &count) 9656 { 9657 const char *str = get(KEY_GPS_PROCESSING_METHOD); 9658 if(str != NULL) { 9659 memcpy(gpsProcessingMethod, ExifAsciiPrefix, EXIF_ASCII_PREFIX_SIZE); 9660 count = EXIF_ASCII_PREFIX_SIZE; 9661 strlcpy(gpsProcessingMethod + EXIF_ASCII_PREFIX_SIZE, str, strlen(str)+1); 9662 count += (uint32_t)strlen(str); 9663 gpsProcessingMethod[count++] = '\0'; // increase 1 for the last NULL char 9664 return NO_ERROR; 9665 } else { 9666 return BAD_VALUE; 9667 } 9668 } 9669 9670 /*=========================================================================== 9671 * FUNCTION : getExifLatitude 9672 * 9673 * DESCRIPTION: get exif latitude 9674 * 9675 * PARAMETERS : 9676 * @latitude : ptr to rational struct to store latitude info 9677 * @ladRef : charater to indicate latitude reference 9678 * 9679 * RETURN : int32_t type of status 9680 * NO_ERROR -- success 9681 * none-zero failure code 9682 *==========================================================================*/ 9683 int32_t QCameraParameters::getExifLatitude(rat_t *latitude, 9684 char *latRef) 9685 { 9686 const char *str = get(KEY_GPS_LATITUDE); 9687 if(str != NULL) { 9688 parseGPSCoordinate(str, latitude); 9689 9690 //set Latitude Ref 9691 float latitudeValue = getFloat(KEY_GPS_LATITUDE); 9692 if(latitudeValue < 0.0f) { 9693 latRef[0] = 'S'; 9694 } else { 9695 latRef[0] = 'N'; 9696 } 9697 latRef[1] = '\0'; 9698 return NO_ERROR; 9699 }else{ 9700 return BAD_VALUE; 9701 } 9702 } 9703 9704 /*=========================================================================== 9705 * FUNCTION : getExifLongitude 9706 * 9707 * DESCRIPTION: get exif longitude 9708 * 9709 * PARAMETERS : 9710 * @longitude : ptr to rational struct to store longitude info 9711 * @lonRef : charater to indicate longitude reference 9712 * 9713 * RETURN : int32_t type of status 9714 * NO_ERROR -- success 9715 * none-zero failure code 9716 *==========================================================================*/ 9717 int32_t QCameraParameters::getExifLongitude(rat_t *longitude, 9718 char *lonRef) 9719 { 9720 const char *str = get(KEY_GPS_LONGITUDE); 9721 if(str != NULL) { 9722 parseGPSCoordinate(str, longitude); 9723 9724 //set Longitude Ref 9725 float longitudeValue = getFloat(KEY_GPS_LONGITUDE); 9726 if(longitudeValue < 0.0f) { 9727 lonRef[0] = 'W'; 9728 } else { 9729 lonRef[0] = 'E'; 9730 } 9731 lonRef[1] = '\0'; 9732 return NO_ERROR; 9733 }else{ 9734 return BAD_VALUE; 9735 } 9736 } 9737 9738 /*=========================================================================== 9739 * FUNCTION : getExifAltitude 9740 * 9741 * DESCRIPTION: get exif altitude 9742 * 9743 * PARAMETERS : 9744 * @altitude : ptr to rational struct to store altitude info 9745 * @altRef : charater to indicate altitude reference 9746 * 9747 * RETURN : int32_t type of status 9748 * NO_ERROR -- success 9749 * none-zero failure code 9750 *==========================================================================*/ 9751 int32_t QCameraParameters::getExifAltitude(rat_t *altitude, 9752 char *altRef) 9753 { 9754 const char *str = get(KEY_GPS_ALTITUDE); 9755 if(str != NULL) { 9756 double value = atof(str); 9757 *altRef = 0; 9758 if(value < 0){ 9759 *altRef = 1; 9760 value = -value; 9761 } 9762 return getRational(altitude, (int)(value*1000), 1000); 9763 }else{ 9764 return BAD_VALUE; 9765 } 9766 } 9767 9768 /*=========================================================================== 9769 * FUNCTION : getExifGpsDateTimeStamp 9770 * 9771 * DESCRIPTION: get exif GPS date time stamp 9772 * 9773 * PARAMETERS : 9774 * @gpsDateStamp : GPS date time stamp string 9775 * @bufLen : length of the string 9776 * @gpsTimeStamp : ptr to rational struct to store time stamp info 9777 * 9778 * RETURN : int32_t type of status 9779 * NO_ERROR -- success 9780 * none-zero failure code 9781 *==========================================================================*/ 9782 int32_t QCameraParameters::getExifGpsDateTimeStamp(char *gpsDateStamp, 9783 uint32_t bufLen, 9784 rat_t *gpsTimeStamp) 9785 { 9786 const char *str = get(KEY_GPS_TIMESTAMP); 9787 if(str != NULL) { 9788 time_t unixTime = (time_t)atol(str); 9789 struct tm *UTCTimestamp = gmtime(&unixTime); 9790 9791 if(!UTCTimestamp) { 9792 ALOGE("%s: UTCTimestamp is null\n", __func__); 9793 return BAD_VALUE; 9794 } 9795 9796 strftime(gpsDateStamp, bufLen, "%Y:%m:%d", UTCTimestamp); 9797 9798 getRational(&gpsTimeStamp[0], UTCTimestamp->tm_hour, 1); 9799 getRational(&gpsTimeStamp[1], UTCTimestamp->tm_min, 1); 9800 getRational(&gpsTimeStamp[2], UTCTimestamp->tm_sec, 1); 9801 9802 return NO_ERROR; 9803 } else { 9804 return BAD_VALUE; 9805 } 9806 } 9807 9808 /*=========================================================================== 9809 * FUNCTION : updateFocusDistances 9810 * 9811 * DESCRIPTION: update focus distances 9812 * 9813 * PARAMETERS : 9814 * @focusDistances : ptr to focus distance info 9815 * 9816 * RETURN : int32_t type of status 9817 * NO_ERROR -- success 9818 * none-zero failure code 9819 *==========================================================================*/ 9820 int32_t QCameraParameters::updateFocusDistances(cam_focus_distances_info_t *focusDistances) 9821 { 9822 String8 str; 9823 char buffer[32] = {0}; 9824 //set all distances to infinity if focus mode is infinity 9825 if(mFocusMode == CAM_FOCUS_MODE_INFINITY) { 9826 str.append("Infinity,Infinity,Infinity"); 9827 } else { 9828 snprintf(buffer, sizeof(buffer), "%f", focusDistances->focus_distance[0]); 9829 str.append(buffer); 9830 snprintf(buffer, sizeof(buffer), ",%f", focusDistances->focus_distance[1]); 9831 str.append(buffer); 9832 snprintf(buffer, sizeof(buffer), ",%f", focusDistances->focus_distance[2]); 9833 str.append(buffer); 9834 } 9835 CDBG_HIGH("%s: setting KEY_FOCUS_DISTANCES as %s", __FUNCTION__, str.string()); 9836 set(QCameraParameters::KEY_FOCUS_DISTANCES, str.string()); 9837 return NO_ERROR; 9838 } 9839 9840 /*=========================================================================== 9841 * FUNCTION : updateRecordingHintValue 9842 * 9843 * DESCRIPTION: update recording hint locally and to daemon 9844 * 9845 * PARAMETERS : 9846 * @value : video hint value 9847 * 9848 * RETURN : int32_t type of status 9849 * NO_ERROR -- success 9850 * none-zero failure code 9851 *==========================================================================*/ 9852 int32_t QCameraParameters::updateRecordingHintValue(int32_t value) 9853 { 9854 int32_t rc = NO_ERROR; 9855 if(initBatchUpdate(m_pParamBuf) < 0 ) { 9856 ALOGE("%s:Failed to initialize group update table", __func__); 9857 return BAD_TYPE; 9858 } 9859 9860 rc = setRecordingHintValue(value); 9861 if (rc != NO_ERROR) { 9862 ALOGE("%s:Failed to update table", __func__); 9863 return rc; 9864 } 9865 9866 if(m_bDISEnabled && (value==1)) { 9867 CDBG_HIGH("%s: %d: Setting DIS value again!!", __func__, __LINE__); 9868 setDISValue(VALUE_ENABLE); 9869 } 9870 9871 rc = commitSetBatch(); 9872 if (rc != NO_ERROR) { 9873 ALOGE("%s:Failed to update recording hint", __func__); 9874 return rc; 9875 } 9876 9877 return rc; 9878 } 9879 9880 /*=========================================================================== 9881 * FUNCTION : setHistogram 9882 * 9883 * DESCRIPTION: set histogram 9884 * 9885 * PARAMETERS : 9886 * @enabled : if histogram is enabled 9887 * 9888 * RETURN : int32_t type of status 9889 * NO_ERROR -- success 9890 * none-zero failure code 9891 *==========================================================================*/ 9892 int32_t QCameraParameters::setHistogram(bool enabled) 9893 { 9894 if(m_bHistogramEnabled == enabled) { 9895 CDBG_HIGH("%s: histogram flag not changed, no ops here", __func__); 9896 return NO_ERROR; 9897 } 9898 9899 // set parm for histogram 9900 if(initBatchUpdate(m_pParamBuf) < 0 ) { 9901 ALOGE("%s:Failed to initialize group update table", __func__); 9902 return BAD_TYPE; 9903 } 9904 9905 int32_t value = enabled ? 1 : 0; 9906 int32_t rc = NO_ERROR; 9907 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_HISTOGRAM, value)) { 9908 ALOGE("%s:Failed to update table", __func__); 9909 return BAD_VALUE; 9910 } 9911 9912 rc = commitSetBatch(); 9913 if (rc != NO_ERROR) { 9914 ALOGE("%s:Failed to set histogram", __func__); 9915 return rc; 9916 } 9917 9918 m_bHistogramEnabled = enabled; 9919 9920 CDBG_HIGH(" Histogram -> %s", m_bHistogramEnabled ? "Enabled" : "Disabled"); 9921 9922 return rc; 9923 } 9924 9925 /*=========================================================================== 9926 * FUNCTION : setIntEvent 9927 * 9928 * DESCRIPTION: set setIntEvent 9929 * 9930 * PARAMETERS : 9931 * @params : image size and dimensions 9932 * 9933 * RETURN : int32_t type of status 9934 * NO_ERROR -- success 9935 * none-zero failure code 9936 *==========================================================================*/ 9937 int32_t QCameraParameters::setIntEvent(cam_int_evt_params_t params) 9938 { 9939 int32_t rc = NO_ERROR; 9940 9941 if ( m_pParamBuf == NULL ) { 9942 return NO_INIT; 9943 } 9944 9945 if(initBatchUpdate(m_pParamBuf) < 0 ) { 9946 ALOGE("%s:Failed to initialize group update table", __func__); 9947 return BAD_TYPE; 9948 } 9949 9950 //Sending snapshot taken notification back to Eztune" 9951 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_INT_EVT, params)) { 9952 ALOGE("%s:Failed to update table", __func__); 9953 return BAD_VALUE; 9954 } 9955 9956 rc = commitSetBatch(); 9957 if (rc != NO_ERROR) { 9958 ALOGE("%s:Failed to set frameskip info parm", __func__); 9959 return rc; 9960 } 9961 9962 return rc; 9963 } 9964 9965 /*=========================================================================== 9966 * FUNCTION : setFaceDetectionOption 9967 * 9968 * DESCRIPTION: set if face detection is enabled by SendCommand 9969 * 9970 * PARAMETERS : 9971 * @enabled : bool flag if face detection should be enabled 9972 * 9973 * RETURN : int32_t type of status 9974 * NO_ERROR -- success 9975 * none-zero failure code 9976 *==========================================================================*/ 9977 int32_t QCameraParameters::setFaceDetectionOption(bool enabled) 9978 { 9979 m_bFaceDetectionOn = enabled; 9980 return NO_ERROR; 9981 } 9982 9983 /*=========================================================================== 9984 * FUNCTION : setFaceDetection 9985 * 9986 * DESCRIPTION: set face detection 9987 * 9988 * PARAMETERS : 9989 * @enabled : if face detection is enabled 9990 * @initCommit : if configuration list need to be initialized and commited 9991 * 9992 * RETURN : int32_t type of status 9993 * NO_ERROR -- success 9994 * none-zero failure code 9995 *==========================================================================*/ 9996 int32_t QCameraParameters::setFaceDetection(bool enabled, bool initCommit) 9997 { 9998 uint32_t faceProcMask = m_nFaceProcMask; 9999 // set face detection mask 10000 if (enabled) { 10001 faceProcMask |= CAM_FACE_PROCESS_MASK_DETECTION; 10002 } else { 10003 faceProcMask &= ~CAM_FACE_PROCESS_MASK_DETECTION; 10004 } 10005 10006 if(m_nFaceProcMask == faceProcMask) { 10007 CDBG_HIGH("%s: face process mask not changed, no ops here", __func__); 10008 return NO_ERROR; 10009 } 10010 10011 m_nFaceProcMask = faceProcMask; 10012 10013 // set parm for face detection 10014 uint32_t requested_faces = (uint32_t)getInt(KEY_QC_MAX_NUM_REQUESTED_FACES); 10015 cam_fd_set_parm_t fd_set_parm; 10016 memset(&fd_set_parm, 0, sizeof(cam_fd_set_parm_t)); 10017 fd_set_parm.fd_mode = faceProcMask; 10018 fd_set_parm.num_fd = requested_faces; 10019 10020 CDBG_HIGH("[KPI Perf] %s: PROFILE_FACE_DETECTION_VALUE = %d num_fd = %d", 10021 __func__, faceProcMask,requested_faces); 10022 10023 if (initCommit) { 10024 if(initBatchUpdate(m_pParamBuf) < 0 ) { 10025 ALOGE("%s:Failed to initialize group update table", __func__); 10026 return BAD_TYPE; 10027 } 10028 } 10029 10030 int32_t rc = NO_ERROR; 10031 10032 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_FD, fd_set_parm)) { 10033 ALOGE("%s:Failed to update table", __func__); 10034 return BAD_VALUE; 10035 } 10036 10037 if (initCommit) { 10038 rc = commitSetBatch(); 10039 if (rc != NO_ERROR) { 10040 ALOGE("%s:Failed to set face detection parm", __func__); 10041 return rc; 10042 } 10043 } 10044 10045 CDBG_HIGH("%s: FaceProcMask -> %d", __func__, m_nFaceProcMask); 10046 10047 return rc; 10048 } 10049 10050 /*=========================================================================== 10051 * FUNCTION : setFrameSkip 10052 * 10053 * DESCRIPTION: send ISP frame skip pattern to camera daemon 10054 * 10055 * PARAMETERS : 10056 * @pattern : skip pattern for ISP 10057 * 10058 * RETURN : int32_t type of status 10059 * NO_ERROR -- success 10060 * none-zero failure code 10061 *==========================================================================*/ 10062 int32_t QCameraParameters::setFrameSkip(enum msm_vfe_frame_skip_pattern pattern) 10063 { 10064 int32_t rc = NO_ERROR; 10065 10066 if ( m_pParamBuf == NULL ) { 10067 return NO_INIT; 10068 } 10069 10070 if(initBatchUpdate(m_pParamBuf) < 0 ) { 10071 ALOGE("%s:Failed to initialize group update table", __func__); 10072 return BAD_TYPE; 10073 } 10074 10075 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_FRAMESKIP, (int32_t)pattern)) { 10076 ALOGE("%s:Failed to update table", __func__); 10077 return BAD_VALUE; 10078 } 10079 10080 rc = commitSetBatch(); 10081 if (rc != NO_ERROR) { 10082 ALOGE("%s:Failed to set frameskip info parm", __func__); 10083 return rc; 10084 } 10085 10086 return rc; 10087 } 10088 10089 int32_t QCameraParameters::updateRAW(cam_dimension_t max_dim) 10090 { 10091 int32_t rc = NO_ERROR; 10092 cam_dimension_t raw_dim; 10093 10094 if (max_dim.width == 0 || max_dim.height == 0) { 10095 max_dim = m_pCapability->raw_dim[0]; 10096 } 10097 10098 if(initBatchUpdate(m_pParamBuf) < 0 ) { 10099 ALOGE("%s:Failed to initialize group update table", __func__); 10100 return BAD_TYPE; 10101 } 10102 10103 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_MAX_DIMENSION, max_dim)) { 10104 ALOGE("%s:Failed to update table for CAM_INTF_PARM_MAX_DIMENSION ", __func__); 10105 return BAD_VALUE; 10106 } 10107 10108 rc = commitSetBatch(); 10109 if (rc != NO_ERROR) { 10110 ALOGE("%s:Failed to set lock CAM_INTF_PARM_MAX_DIMENSION parm", __func__); 10111 return rc; 10112 } 10113 10114 if(initBatchUpdate(m_pParamBuf) < 0 ) { 10115 ALOGE("%s:Failed to initialize group update table", __func__); 10116 return BAD_TYPE; 10117 } 10118 10119 ADD_GET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_RAW_DIMENSION); 10120 10121 rc = commitGetBatch(); 10122 if (rc != NO_ERROR) { 10123 ALOGE("%s:Failed to get commit CAM_INTF_PARM_RAW_DIMENSION", __func__); 10124 return rc; 10125 } 10126 10127 READ_PARAM_ENTRY(m_pParamBuf, CAM_INTF_PARM_RAW_DIMENSION, raw_dim); 10128 10129 CDBG_HIGH("%s : RAW Dimension = %d X %d",__func__,raw_dim.width,raw_dim.height); 10130 if (raw_dim.width == 0 || raw_dim.height == 0) { 10131 ALOGE("%s: Error getting RAW size. Setting to Capability value",__func__); 10132 raw_dim = m_pCapability->raw_dim[0]; 10133 } 10134 setRawSize(raw_dim); 10135 return rc; 10136 } 10137 10138 /*=========================================================================== 10139 * FUNCTION : setHDRSceneEnable 10140 * 10141 * DESCRIPTION: sets hdr scene deteced flag 10142 * 10143 * PARAMETERS : 10144 * @bflag : hdr scene deteced 10145 * 10146 * RETURN : nothing 10147 *==========================================================================*/ 10148 void QCameraParameters::setHDRSceneEnable(bool bflag) 10149 { 10150 bool bupdate = false; 10151 if (m_HDRSceneEnabled != bflag) { 10152 bupdate = true; 10153 } 10154 m_HDRSceneEnabled = bflag; 10155 10156 if (bupdate) { 10157 updateFlash(true); 10158 } 10159 } 10160 10161 /*=========================================================================== 10162 * FUNCTION : getASDStateString 10163 * 10164 * DESCRIPTION: get ASD result in string format 10165 * 10166 * PARAMETERS : 10167 * @scene : selected scene mode 10168 * 10169 * RETURN : int32_t type of status 10170 * NO_ERROR -- success 10171 * none-zero failure code 10172 *==========================================================================*/ 10173 const char *QCameraParameters::getASDStateString(cam_auto_scene_t scene) 10174 { 10175 switch (scene) { 10176 case S_NORMAL : 10177 return "Normal"; 10178 case S_SCENERY: 10179 return "Scenery"; 10180 case S_PORTRAIT: 10181 return "Portrait"; 10182 case S_PORTRAIT_BACKLIGHT: 10183 return "Portrait-Backlight"; 10184 case S_SCENERY_BACKLIGHT: 10185 return "Scenery-Backlight"; 10186 case S_BACKLIGHT: 10187 return "Backlight"; 10188 default: 10189 return "<Unknown!>"; 10190 } 10191 } 10192 10193 /*=========================================================================== 10194 * FUNCTION : parseNDimVector 10195 * 10196 * DESCRIPTION: helper function to parse a string like "(1, 2, 3, 4, ..., N)" 10197 * into N-dimension vector 10198 * 10199 * PARAMETERS : 10200 * @str : string to be parsed 10201 * @num : output array of size N to store vector element values 10202 * @N : number of dimension 10203 * @delim : delimeter to seperete string 10204 * 10205 * RETURN : int32_t type of status 10206 * NO_ERROR -- success 10207 * none-zero failure code 10208 *==========================================================================*/ 10209 int32_t QCameraParameters::parseNDimVector(const char *str, int *num, int N, char delim = ',') 10210 { 10211 char *start, *end; 10212 if (num == NULL) { 10213 ALOGE("%s: Invalid output array (num == NULL)", __func__); 10214 return BAD_VALUE; 10215 } 10216 10217 //check if string starts and ends with parantheses 10218 if(str[0] != '(' || str[strlen(str)-1] != ')') { 10219 ALOGE("%s: Invalid format of string %s, valid format is (n1, n2, n3, n4 ...)", 10220 __func__, str); 10221 return BAD_VALUE; 10222 } 10223 start = (char*) str; 10224 start++; 10225 for(int i=0; i<N; i++) { 10226 *(num+i) = (int) strtol(start, &end, 10); 10227 if(*end != delim && i < N-1) { 10228 ALOGE("%s: Cannot find delimeter '%c' in string \"%s\". end = %c", 10229 __func__, delim, str, *end); 10230 return -1; 10231 } 10232 start = end+1; 10233 } 10234 return NO_ERROR; 10235 } 10236 10237 /*=========================================================================== 10238 * FUNCTION : parseCameraAreaString 10239 * 10240 * DESCRIPTION: helper function to parse a string of camera areas like 10241 * "(1, 2, 3, 4, 5),(1, 2, 3, 4, 5),..." 10242 * 10243 * PARAMETERS : 10244 * @str : string to be parsed 10245 * @max_num_areas : max number of areas 10246 * @pAreas : ptr to struct to store areas 10247 * @num_areas_found : number of areas found 10248 * 10249 * RETURN : int32_t type of status 10250 * NO_ERROR -- success 10251 * none-zero failure code 10252 *==========================================================================*/ 10253 int32_t QCameraParameters::parseCameraAreaString(const char *str, 10254 int max_num_areas, 10255 cam_area_t *pAreas, 10256 int& num_areas_found) 10257 { 10258 char area_str[32]; 10259 const char *start, *end, *p; 10260 start = str; end = NULL; 10261 int values[5], index=0; 10262 num_areas_found = 0; 10263 10264 memset(values, 0, sizeof(values)); 10265 while(start != NULL) { 10266 if(*start != '(') { 10267 ALOGE("%s: error: Ill formatted area string: %s", __func__, str); 10268 return BAD_VALUE; 10269 } 10270 end = strchr(start, ')'); 10271 if(end == NULL) { 10272 ALOGE("%s: error: Ill formatted area string: %s", __func__, str); 10273 return BAD_VALUE; 10274 } 10275 int i; 10276 for (i=0,p=start; p<=end; p++, i++) { 10277 area_str[i] = *p; 10278 } 10279 area_str[i] = '\0'; 10280 if(parseNDimVector(area_str, values, 5) < 0){ 10281 ALOGE("%s: error: Failed to parse the area string: %s", __func__, area_str); 10282 return BAD_VALUE; 10283 } 10284 // no more areas than max_num_areas are accepted. 10285 if(index >= max_num_areas) { 10286 ALOGE("%s: error: too many areas specified %s", __func__, str); 10287 return BAD_VALUE; 10288 } 10289 pAreas[index].rect.left = values[0]; 10290 pAreas[index].rect.top = values[1]; 10291 pAreas[index].rect.width = values[2] - values[0]; 10292 pAreas[index].rect.height = values[3] - values[1]; 10293 pAreas[index].weight = values[4]; 10294 10295 index++; 10296 start = strchr(end, '('); // serach for next '(' 10297 } 10298 num_areas_found = index; 10299 return 0; 10300 } 10301 10302 /*=========================================================================== 10303 * FUNCTION : validateCameraAreas 10304 * 10305 * DESCRIPTION: helper function to validate camera areas within (-1000, 1000) 10306 * 10307 * PARAMETERS : 10308 * @areas : ptr to array of areas 10309 * @num_areas : number of areas 10310 * 10311 * RETURN : true -- area is in valid range 10312 * false -- not valid 10313 *==========================================================================*/ 10314 bool QCameraParameters::validateCameraAreas(cam_area_t *areas, int num_areas) 10315 { 10316 // special case: default area 10317 if (num_areas == 1 && 10318 areas[0].rect.left == 0 && 10319 areas[0].rect.top == 0 && 10320 areas[0].rect.width == 0 && 10321 areas[0].rect.height == 0 && 10322 areas[0].weight == 0) { 10323 return true; 10324 } 10325 10326 for(int i = 0; i < num_areas; i++) { 10327 // left should be >= -1000 10328 if(areas[i].rect.left < -1000) { 10329 return false; 10330 } 10331 10332 // top should be >= -1000 10333 if(areas[i].rect.top < -1000) { 10334 return false; 10335 } 10336 10337 // width or height should be > 0 10338 if (areas[i].rect.width <= 0 || areas[i].rect.height <= 0) { 10339 return false; 10340 } 10341 10342 // right should be <= 1000 10343 if(areas[i].rect.left + areas[i].rect.width > 1000) { 10344 return false; 10345 } 10346 10347 // bottom should be <= 1000 10348 if(areas[i].rect.top + areas[i].rect.height > 1000) { 10349 return false; 10350 } 10351 10352 // weight should be within (1, 1000) 10353 if (areas[i].weight < 1 || areas[i].weight > 1000) { 10354 return false; 10355 } 10356 } 10357 return true; 10358 } 10359 10360 /*=========================================================================== 10361 * FUNCTION : isYUVFrameInfoNeeded 10362 * 10363 * DESCRIPTION: In AE-Bracket mode, we need set yuv buffer information for up-layer 10364 * 10365 * PARAMETERS : none 10366 * 10367 * RETURN : true: needed 10368 * false: no need 10369 *==========================================================================*/ 10370 bool QCameraParameters::isYUVFrameInfoNeeded() 10371 { 10372 //In AE-Bracket mode, we need set raw buffer information for up-layer 10373 if(!isNV21PictureFormat() && !isNV16PictureFormat()){ 10374 return false; 10375 } 10376 const char *aecBracketStr = get(KEY_QC_AE_BRACKET_HDR); 10377 10378 int value = lookupAttr(BRACKETING_MODES_MAP, PARAM_MAP_SIZE(BRACKETING_MODES_MAP), 10379 aecBracketStr); 10380 CDBG_HIGH("%s: aecBracketStr=%s, value=%d.", __func__, aecBracketStr, value); 10381 return (value == CAM_EXP_BRACKETING_ON); 10382 } 10383 10384 /*=========================================================================== 10385 * FUNCTION : getFrameFmtString 10386 * 10387 * DESCRIPTION: get string name of frame format 10388 * 10389 * PARAMETERS : 10390 * @frame : frame format 10391 * 10392 * RETURN : string name of frame format 10393 *==========================================================================*/ 10394 const char *QCameraParameters::getFrameFmtString(cam_format_t fmt) 10395 { 10396 return lookupNameByValue(PICTURE_TYPES_MAP, PARAM_MAP_SIZE(PICTURE_TYPES_MAP), fmt); 10397 } 10398 10399 /*=========================================================================== 10400 * FUNCTION : initBatchUpdate 10401 * 10402 * DESCRIPTION: init camera parameters buf entries 10403 * 10404 * PARAMETERS : 10405 * @p_table : ptr to parameter buffer 10406 * 10407 * RETURN : int32_t type of status 10408 * NO_ERROR -- success 10409 * none-zero failure code 10410 *==========================================================================*/ 10411 int32_t QCameraParameters::initBatchUpdate(parm_buffer_t *p_table) 10412 { 10413 m_tempMap.clear(); 10414 10415 clear_metadata_buffer(p_table); 10416 return NO_ERROR; 10417 } 10418 10419 /*=========================================================================== 10420 * FUNCTION : commitSetBatch 10421 * 10422 * DESCRIPTION: commit all set parameters in the batch work to backend 10423 * 10424 * PARAMETERS : none 10425 * 10426 * RETURN : int32_t type of status 10427 * NO_ERROR -- success 10428 * none-zero failure code 10429 *==========================================================================*/ 10430 int32_t QCameraParameters::commitSetBatch() 10431 { 10432 int32_t rc = NO_ERROR; 10433 int32_t i = 0; 10434 10435 if (NULL == m_pParamBuf) { 10436 ALOGE("%s: Params not initialized", __func__); 10437 return NO_INIT; 10438 } 10439 10440 /* Loop to check if atleast one entry is valid */ 10441 for(i = 0; i < CAM_INTF_PARM_MAX; i++){ 10442 if(m_pParamBuf->is_valid[i]) 10443 break; 10444 } 10445 10446 if (NULL == m_pCamOpsTbl) { 10447 ALOGE("%s: Ops not initialized", __func__); 10448 return NO_INIT; 10449 } 10450 10451 if (i < CAM_INTF_PARM_MAX) { 10452 rc = m_pCamOpsTbl->ops->set_parms(m_pCamOpsTbl->camera_handle, m_pParamBuf); 10453 } 10454 if (rc == NO_ERROR) { 10455 // commit change from temp storage into param map 10456 rc = commitParamChanges(); 10457 } 10458 return rc; 10459 } 10460 10461 /*=========================================================================== 10462 * FUNCTION : commitGetBatch 10463 * 10464 * DESCRIPTION: commit all get parameters in the batch work to backend 10465 * 10466 * PARAMETERS : none 10467 * 10468 * RETURN : int32_t type of status 10469 * NO_ERROR -- success 10470 * none-zero failure code 10471 *==========================================================================*/ 10472 int32_t QCameraParameters::commitGetBatch() 10473 { 10474 int32_t rc = NO_ERROR; 10475 int32_t i = 0; 10476 10477 if (NULL == m_pParamBuf) { 10478 ALOGE("%s: Params not initialized", __func__); 10479 return NO_INIT; 10480 } 10481 10482 /* Loop to check if atleast one entry is valid */ 10483 for(i = 0; i < CAM_INTF_PARM_MAX; i++){ 10484 if(m_pParamBuf->is_valid[i]) 10485 break; 10486 } 10487 10488 if (NULL == m_pCamOpsTbl) { 10489 ALOGE("%s: Ops not initialized", __func__); 10490 return NO_INIT; 10491 } 10492 10493 if (i < CAM_INTF_PARM_MAX) { 10494 return m_pCamOpsTbl->ops->get_parms(m_pCamOpsTbl->camera_handle, m_pParamBuf); 10495 } else { 10496 return NO_ERROR; 10497 } 10498 return rc; 10499 } 10500 10501 /*=========================================================================== 10502 * FUNCTION : updateParamEntry 10503 * 10504 * DESCRIPTION: update a parameter entry in the local temp map obj 10505 * 10506 * PARAMETERS : 10507 * @key : key of the entry 10508 * @value : value of the entry 10509 * 10510 * RETURN : int32_t type of status 10511 * NO_ERROR -- success 10512 * none-zero failure code 10513 *==========================================================================*/ 10514 int32_t QCameraParameters::updateParamEntry(const char *key, const char *value) 10515 { 10516 m_tempMap.replaceValueFor(String8(key), String8(value)); 10517 return NO_ERROR; 10518 } 10519 10520 /*=========================================================================== 10521 * FUNCTION : commitParamChanges 10522 * 10523 * DESCRIPTION: commit all changes in local temp map obj into parameter obj 10524 * 10525 * PARAMETERS : none 10526 * 10527 * RETURN : int32_t type of status 10528 * NO_ERROR -- success 10529 * none-zero failure code 10530 *==========================================================================*/ 10531 int32_t QCameraParameters::commitParamChanges() 10532 { 10533 size_t size = m_tempMap.size(); 10534 for (size_t i = 0; i < size; i++) { 10535 String8 k, v; 10536 k = m_tempMap.keyAt(i); 10537 v = m_tempMap.valueAt(i); 10538 set(k, v); 10539 } 10540 m_tempMap.clear(); 10541 10542 // update local changes 10543 m_bRecordingHint = m_bRecordingHint_new; 10544 m_bZslMode = m_bZslMode_new; 10545 10546 /* After applying scene mode auto, 10547 Camera effects need to be reapplied */ 10548 if ( m_bSceneTransitionAuto ) { 10549 m_bUpdateEffects = true; 10550 m_bSceneTransitionAuto = false; 10551 } 10552 10553 10554 return NO_ERROR; 10555 } 10556 10557 /*=========================================================================== 10558 * FUNCTION : QCameraReprocScaleParam 10559 * 10560 * DESCRIPTION: constructor of QCameraReprocScaleParam 10561 * 10562 * PARAMETERS : none 10563 * 10564 * RETURN : none 10565 *==========================================================================*/ 10566 QCameraReprocScaleParam::QCameraReprocScaleParam(QCameraParameters *parent) 10567 : mParent(parent), 10568 mScaleEnabled(false), 10569 mIsUnderScaling(false), 10570 mScaleDirection(0), 10571 mNeedScaleCnt(0), 10572 mSensorSizeTblCnt(0), 10573 mSensorSizeTbl(NULL), 10574 mTotalSizeTblCnt(0) 10575 { 10576 mPicSizeFromAPK.width = 0; 10577 mPicSizeFromAPK.height = 0; 10578 mPicSizeSetted.width = 0; 10579 mPicSizeSetted.height = 0; 10580 memset(mNeedScaledSizeTbl, 0, sizeof(mNeedScaledSizeTbl)); 10581 memset(mTotalSizeTbl, 0, sizeof(mTotalSizeTbl)); 10582 } 10583 10584 /*=========================================================================== 10585 * FUNCTION : ~~QCameraReprocScaleParam 10586 * 10587 * DESCRIPTION: destructor of QCameraReprocScaleParam 10588 * 10589 * PARAMETERS : none 10590 * 10591 * RETURN : none 10592 *==========================================================================*/ 10593 QCameraReprocScaleParam::~QCameraReprocScaleParam() 10594 { 10595 //do nothing now. 10596 } 10597 10598 /*=========================================================================== 10599 * FUNCTION : setScaledSizeTbl 10600 * 10601 * DESCRIPTION: re-set picture size table with dimensions that need scaling if Reproc Scale is enabled 10602 * 10603 * PARAMETERS : 10604 * @scale_cnt : count of picture sizes that want scale 10605 * @scale_tbl : picture size table that want scale 10606 * @org_cnt : sensor supported picture size count 10607 * @org_tbl : sensor supported picture size table 10608 * 10609 * RETURN : int32_t type of status 10610 * NO_ERROR -- success 10611 * none-zero failure code 10612 *==========================================================================*/ 10613 int32_t QCameraReprocScaleParam::setScaleSizeTbl(size_t scale_cnt, 10614 cam_dimension_t *scale_tbl, size_t org_cnt, cam_dimension_t *org_tbl) 10615 { 10616 int32_t rc = NO_ERROR; 10617 size_t i; 10618 mNeedScaleCnt = 0; 10619 10620 if(!mScaleEnabled || scale_cnt <=0 || scale_tbl == NULL || org_cnt <=0 || org_tbl == NULL){ 10621 return BAD_VALUE; // Do not need scale, so also need not reset picture size table 10622 } 10623 10624 mSensorSizeTblCnt = org_cnt; 10625 mSensorSizeTbl = org_tbl; 10626 mNeedScaleCnt = checkScaleSizeTable(scale_cnt, scale_tbl, org_cnt, org_tbl); 10627 if(mNeedScaleCnt <= 0){ 10628 ALOGE("%s: do not have picture sizes need scaling.", __func__); 10629 return BAD_VALUE; 10630 } 10631 10632 if(mNeedScaleCnt + org_cnt > MAX_SIZES_CNT){ 10633 ALOGE("%s: picture size list exceed the max count.", __func__); 10634 return BAD_VALUE; 10635 } 10636 10637 //get the total picture size table 10638 mTotalSizeTblCnt = mNeedScaleCnt + org_cnt; 10639 10640 if (mNeedScaleCnt > MAX_SCALE_SIZES_CNT) { 10641 ALOGE("%s: Error!! mNeedScaleCnt (%d) is more than MAX_SCALE_SIZES_CNT", 10642 __func__, mNeedScaleCnt); 10643 return BAD_VALUE; 10644 } 10645 10646 for(i = 0; i < mNeedScaleCnt; i++){ 10647 mTotalSizeTbl[i].width = mNeedScaledSizeTbl[i].width; 10648 mTotalSizeTbl[i].height = mNeedScaledSizeTbl[i].height; 10649 CDBG_HIGH("%s: scale picture size: i =%d, width=%d, height=%d.", __func__, 10650 i, mTotalSizeTbl[i].width, mTotalSizeTbl[i].height); 10651 } 10652 for(; i < mTotalSizeTblCnt; i++){ 10653 mTotalSizeTbl[i].width = org_tbl[i-mNeedScaleCnt].width; 10654 mTotalSizeTbl[i].height = org_tbl[i-mNeedScaleCnt].height; 10655 CDBG_HIGH("%s: sensor supportted picture size: i =%d, width=%d, height=%d.", __func__, 10656 i, mTotalSizeTbl[i].width, mTotalSizeTbl[i].height); 10657 } 10658 return rc; 10659 } 10660 10661 /*=========================================================================== 10662 * FUNCTION : getScaledSizeTblCnt 10663 * 10664 * DESCRIPTION: get picture size cnt that need scale 10665 * 10666 * PARAMETERS : none 10667 * 10668 * RETURN : uint8_t type of picture size count 10669 *==========================================================================*/ 10670 size_t QCameraReprocScaleParam::getScaleSizeTblCnt() 10671 { 10672 return mNeedScaleCnt; 10673 } 10674 10675 /*=========================================================================== 10676 * FUNCTION : getScaledSizeTbl 10677 * 10678 * DESCRIPTION: get picture size table that need scale 10679 * 10680 * PARAMETERS : none 10681 * 10682 * RETURN : cam_dimension_t list of picture size table 10683 *==========================================================================*/ 10684 cam_dimension_t *QCameraReprocScaleParam::getScaledSizeTbl() 10685 { 10686 if(!mScaleEnabled) 10687 return NULL; 10688 10689 return mNeedScaledSizeTbl; 10690 } 10691 10692 /*=========================================================================== 10693 * FUNCTION : setScaleEnable 10694 * 10695 * DESCRIPTION: enable or disable Reproc Scale 10696 * 10697 * PARAMETERS : 10698 * @enabled : enable: 1; disable 0 10699 * 10700 * RETURN : none 10701 *==========================================================================*/ 10702 void QCameraReprocScaleParam::setScaleEnable(bool enabled) 10703 { 10704 mScaleEnabled = enabled; 10705 } 10706 10707 /*=========================================================================== 10708 * FUNCTION : isScaleEnabled 10709 * 10710 * DESCRIPTION: check if Reproc Scale is enabled 10711 * 10712 * PARAMETERS : none 10713 * 10714 * RETURN : bool type of status 10715 *==========================================================================*/ 10716 bool QCameraReprocScaleParam::isScaleEnabled() 10717 { 10718 return mScaleEnabled; 10719 } 10720 10721 /*=========================================================================== 10722 * FUNCTION : isScalePicSize 10723 * 10724 * DESCRIPTION: check if current picture size is from Scale Table 10725 * 10726 * PARAMETERS : 10727 * @width : current picture width 10728 * @height : current picture height 10729 * 10730 * RETURN : bool type of status 10731 *==========================================================================*/ 10732 bool QCameraReprocScaleParam::isScalePicSize(int width, int height) 10733 { 10734 //Check if the picture size is in scale table 10735 if(mNeedScaleCnt <= 0) 10736 return FALSE; 10737 10738 for (size_t i = 0; i < mNeedScaleCnt; i++) { 10739 if ((mNeedScaledSizeTbl[i].width == width) && (mNeedScaledSizeTbl[i].height == height)) { 10740 //found match 10741 return TRUE; 10742 } 10743 } 10744 10745 ALOGE("%s: Not in scale picture size table.", __func__); 10746 return FALSE; 10747 } 10748 10749 /*=========================================================================== 10750 * FUNCTION : isValidatePicSize 10751 * 10752 * DESCRIPTION: check if current picture size is validate 10753 * 10754 * PARAMETERS : 10755 * @width : current picture width 10756 * @height : current picture height 10757 * 10758 * RETURN : bool type of status 10759 *==========================================================================*/ 10760 bool QCameraReprocScaleParam::isValidatePicSize(int width, int height) 10761 { 10762 size_t i = 0; 10763 10764 for(i = 0; i < mSensorSizeTblCnt; i++){ 10765 if(mSensorSizeTbl[i].width == width 10766 && mSensorSizeTbl[i].height== height){ 10767 return TRUE; 10768 } 10769 } 10770 10771 for(i = 0; i < mNeedScaleCnt; i++){ 10772 if(mNeedScaledSizeTbl[i].width == width 10773 && mNeedScaledSizeTbl[i].height== height){ 10774 return TRUE; 10775 } 10776 } 10777 10778 ALOGE("%s: Invalidate input picture size.", __func__); 10779 return FALSE; 10780 } 10781 10782 /*=========================================================================== 10783 * FUNCTION : setSensorSupportedPicSize 10784 * 10785 * DESCRIPTION: set sensor supported picture size. 10786 * For Snapshot stream size configuration, we need use sensor supported size. 10787 * We will use CPP to do Scaling based on output Snapshot stream. 10788 * 10789 * PARAMETERS : none 10790 * 10791 * RETURN : int32_t type of status 10792 * NO_ERROR -- success 10793 * none-zero failure code 10794 *==========================================================================*/ 10795 int32_t QCameraReprocScaleParam::setSensorSupportedPicSize() 10796 { 10797 //will find a suitable picture size (here we leave a prossibility to add other scale requirement) 10798 //Currently we only focus on upscaling, and checkScaleSizeTable() has guaranteed the dimension ratio. 10799 10800 if(!mIsUnderScaling || mSensorSizeTblCnt <= 0) 10801 return BAD_VALUE; 10802 10803 //We just get the max sensor supported size here. 10804 mPicSizeSetted.width = mSensorSizeTbl[0].width; 10805 mPicSizeSetted.height = mSensorSizeTbl[0].height; 10806 10807 return NO_ERROR; 10808 } 10809 10810 10811 /*=========================================================================== 10812 * FUNCTION : setValidatePicSize 10813 * 10814 * DESCRIPTION: set sensor supported size and change scale status. 10815 * 10816 * PARAMETERS : 10817 * @width : input picture width 10818 * @height : input picture height 10819 * 10820 * RETURN : int32_t type of status 10821 * NO_ERROR -- success 10822 * none-zero failure code 10823 *==========================================================================*/ 10824 int32_t QCameraReprocScaleParam::setValidatePicSize(int &width,int &height) 10825 { 10826 if(!mScaleEnabled) 10827 return BAD_VALUE; 10828 10829 mIsUnderScaling = FALSE; //default: not under scale 10830 10831 if(isScalePicSize(width, height)){ 10832 // input picture size need scaling operation. Record size from APK and setted 10833 mIsUnderScaling = TRUE; 10834 mPicSizeFromAPK.width = width; 10835 mPicSizeFromAPK.height = height; 10836 10837 if(setSensorSupportedPicSize() != NO_ERROR) 10838 return BAD_VALUE; 10839 10840 //re-set picture size to sensor supported size 10841 width = mPicSizeSetted.width; 10842 height = mPicSizeSetted.height; 10843 CDBG_HIGH("%s: mPicSizeFromAPK- with=%d, height=%d, mPicSizeSetted- with =%d, height=%d.", 10844 __func__, mPicSizeFromAPK.width, mPicSizeFromAPK.height, mPicSizeSetted.width, mPicSizeSetted.height); 10845 }else{ 10846 mIsUnderScaling = FALSE; 10847 //no scale is needed for input picture size 10848 if(!isValidatePicSize(width, height)){ 10849 ALOGE("%s: invalidate input picture size.", __func__); 10850 return BAD_VALUE; 10851 } 10852 mPicSizeSetted.width = width; 10853 mPicSizeSetted.height = height; 10854 } 10855 10856 CDBG_HIGH("%s: X. mIsUnderScaling=%d, width=%d, height=%d.", __func__, mIsUnderScaling, width, height); 10857 return NO_ERROR; 10858 } 10859 10860 /*=========================================================================== 10861 * FUNCTION : getPicSizeFromAPK 10862 * 10863 * DESCRIPTION: get picture size that get from APK 10864 * 10865 * PARAMETERS : 10866 * @width : input width 10867 * @height : input height 10868 * 10869 * RETURN : int32_t type of status 10870 * NO_ERROR -- success 10871 * none-zero failure code 10872 *==========================================================================*/ 10873 int32_t QCameraReprocScaleParam::getPicSizeFromAPK(int &width, int &height) 10874 { 10875 if(!mIsUnderScaling) 10876 return BAD_VALUE; 10877 10878 width = mPicSizeFromAPK.width; 10879 height = mPicSizeFromAPK.height; 10880 return NO_ERROR; 10881 } 10882 10883 /*=========================================================================== 10884 * FUNCTION : getPicSizeSetted 10885 * 10886 * DESCRIPTION: get picture size that setted into mm-camera 10887 * 10888 * PARAMETERS : 10889 * @width : input width 10890 * @height : input height 10891 * 10892 * RETURN : int32_t type of status 10893 * NO_ERROR -- success 10894 * none-zero failure code 10895 *==========================================================================*/ 10896 int32_t QCameraReprocScaleParam::getPicSizeSetted(int &width, int &height) 10897 { 10898 width = mPicSizeSetted.width; 10899 height = mPicSizeSetted.height; 10900 return NO_ERROR; 10901 } 10902 10903 /*=========================================================================== 10904 * FUNCTION : isUnderScaling 10905 * 10906 * DESCRIPTION: check if we are in Reproc Scaling requirment 10907 * 10908 * PARAMETERS : none 10909 * 10910 * RETURN : bool type of status 10911 *==========================================================================*/ 10912 bool QCameraReprocScaleParam::isUnderScaling() 10913 { 10914 return mIsUnderScaling; 10915 } 10916 10917 /*=========================================================================== 10918 * FUNCTION : checkScaleSizeTable 10919 * 10920 * DESCRIPTION: check PICTURE_SIZE_NEED_SCALE to choose 10921 * 10922 * PARAMETERS : 10923 * @scale_cnt : count of picture sizes that want scale 10924 * @scale_tbl : picture size table that want scale 10925 * @org_cnt : sensor supported picture size count 10926 * @org_tbl : sensor supported picture size table 10927 * 10928 * RETURN : bool type of status 10929 *==========================================================================*/ 10930 size_t QCameraReprocScaleParam::checkScaleSizeTable(size_t scale_cnt, 10931 cam_dimension_t *scale_tbl, size_t org_cnt, cam_dimension_t *org_tbl) 10932 { 10933 size_t stbl_cnt = 0; 10934 size_t temp_cnt = 0; 10935 ssize_t i = 0; 10936 if(scale_cnt <=0 || scale_tbl == NULL || org_tbl == NULL || org_cnt <= 0) 10937 return stbl_cnt; 10938 10939 //get validate scale size table. Currently we only support: 10940 // 1. upscale. The scale size must larger than max sensor supported size 10941 // 2. Scale dimension ratio must be same as the max sensor supported size. 10942 temp_cnt = scale_cnt; 10943 for (i = (ssize_t)(scale_cnt - 1); i >= 0; i--) { 10944 if (scale_tbl[i].width > org_tbl[0].width || 10945 (scale_tbl[i].width == org_tbl[0].width && 10946 scale_tbl[i].height > org_tbl[0].height)) { 10947 //get the smallest scale size 10948 break; 10949 } 10950 temp_cnt--; 10951 } 10952 10953 //check dimension ratio 10954 double supported_ratio = (double)org_tbl[0].width / (double)org_tbl[0].height; 10955 for (i = 0; i < (ssize_t)temp_cnt; i++) { 10956 double cur_ratio = (double)scale_tbl[i].width / (double)scale_tbl[i].height; 10957 if (fabs(supported_ratio - cur_ratio) > ASPECT_TOLERANCE) { 10958 continue; 10959 } 10960 mNeedScaledSizeTbl[stbl_cnt].width = scale_tbl[i].width; 10961 mNeedScaledSizeTbl[stbl_cnt].height= scale_tbl[i].height; 10962 stbl_cnt++; 10963 } 10964 10965 return stbl_cnt; 10966 } 10967 10968 /*=========================================================================== 10969 * FUNCTION : getTotalSizeTblCnt 10970 * 10971 * DESCRIPTION: get total picture size count after adding dimensions that need scaling 10972 * 10973 * PARAMETERS : none 10974 * 10975 * RETURN : uint8_t type of picture size count 10976 *==========================================================================*/ 10977 size_t QCameraReprocScaleParam::getTotalSizeTblCnt() 10978 { 10979 return mTotalSizeTblCnt; 10980 } 10981 10982 /*=========================================================================== 10983 * FUNCTION : getTotalSizeTbl 10984 * 10985 * DESCRIPTION: get picture size table after adding dimensions that need scaling 10986 * 10987 * PARAMETERS : none 10988 * 10989 * RETURN : cam_dimension_t list of picture size table 10990 *==========================================================================*/ 10991 cam_dimension_t *QCameraReprocScaleParam::getTotalSizeTbl() 10992 { 10993 if(!mScaleEnabled) 10994 return NULL; 10995 10996 return mTotalSizeTbl; 10997 } 10998 10999 /*=========================================================================== 11000 * FUNCTION : isHDREnabled 11001 * 11002 * DESCRIPTION: if HDR is enabled 11003 * 11004 * PARAMETERS : none 11005 * 11006 * RETURN : true: needed 11007 * false: no need 11008 *==========================================================================*/ 11009 bool QCameraParameters::isHDREnabled() 11010 { 11011 return ((m_nBurstNum == 1) && (m_bHDREnabled || m_HDRSceneEnabled)); 11012 } 11013 11014 /*=========================================================================== 11015 * FUNCTION : isAVTimerEnabled 11016 * 11017 * DESCRIPTION: if AVTimer is enabled 11018 * 11019 * PARAMETERS : none 11020 * 11021 * RETURN : true: needed 11022 * false: no need 11023 *==========================================================================*/ 11024 bool QCameraParameters::isAVTimerEnabled() 11025 { 11026 return m_bAVTimerEnabled; 11027 } 11028 11029 /*=========================================================================== 11030 * FUNCTION : isDISEnabled 11031 * 11032 * DESCRIPTION: if DIS is enabled 11033 * 11034 * PARAMETERS : none 11035 * 11036 * RETURN : true: needed 11037 * false: no need 11038 *==========================================================================*/ 11039 bool QCameraParameters::isDISEnabled() 11040 { 11041 return m_bDISEnabled; 11042 } 11043 11044 /*=========================================================================== 11045 * FUNCTION : getISType 11046 * 11047 * DESCRIPTION: returns IS type 11048 * 11049 * PARAMETERS : none 11050 * 11051 * RETURN : IS type 11052 * 11053 *==========================================================================*/ 11054 cam_is_type_t QCameraParameters::getISType() 11055 { 11056 return mIsType; 11057 } 11058 11059 /*=========================================================================== 11060 * FUNCTION : MobicatMask 11061 * 11062 * DESCRIPTION: returns mobicat mask 11063 * 11064 * PARAMETERS : none 11065 * 11066 * RETURN : mobicat mask 11067 * 11068 *==========================================================================*/ 11069 uint8_t QCameraParameters::getMobicatMask() 11070 { 11071 return m_MobiMask; 11072 } 11073 11074 /*=========================================================================== 11075 * FUNCTION : sendStreamConfigInfo 11076 * 11077 * DESCRIPTION: send Stream config info. 11078 * 11079 * PARAMETERS : 11080 * @stream_config_info: Stream config information 11081 * 11082 * RETURN : int32_t type of status 11083 * NO_ERROR -- success 11084 * none-zero failure code 11085 *==========================================================================*/ 11086 bool QCameraParameters::sendStreamConfigInfo(cam_stream_size_info_t &stream_config_info) { 11087 int32_t rc = NO_ERROR; 11088 if(initBatchUpdate(m_pParamBuf) < 0 ) { 11089 ALOGE("%s:Failed to initialize group update table", __func__); 11090 return BAD_TYPE; 11091 } 11092 11093 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, 11094 CAM_INTF_META_STREAM_INFO, stream_config_info)) { 11095 ALOGE("%s:Failed to update table", __func__); 11096 return BAD_VALUE; 11097 } 11098 11099 rc = commitSetBatch(); 11100 if (rc != NO_ERROR) { 11101 ALOGE("%s:Failed to set stream info parm", __func__); 11102 return rc; 11103 } 11104 11105 return rc; 11106 } 11107 11108 /*=========================================================================== 11109 * FUNCTION : setStreamConfigure 11110 * 11111 * DESCRIPTION: set stream type, stream dimension for all configured streams. 11112 * 11113 * PARAMETERS : 11114 * @isCapture: Whether this configureation is for an image capture 11115 * @previewAsPostview: Use preview as postview 11116 * 11117 * RETURN : int32_t type of status 11118 * NO_ERROR -- success 11119 * none-zero failure code 11120 *==========================================================================*/ 11121 bool QCameraParameters::setStreamConfigure(bool isCapture, 11122 bool previewAsPostview, bool resetConfig) { 11123 11124 int32_t rc = NO_ERROR; 11125 cam_stream_size_info_t stream_config_info; 11126 char value[PROPERTY_VALUE_MAX]; 11127 bool raw_yuv = false; 11128 bool raw_capture = false; 11129 11130 if ( m_pParamBuf == NULL ) { 11131 return NO_INIT; 11132 } 11133 11134 memset(&stream_config_info, 0, sizeof(stream_config_info)); 11135 stream_config_info.num_streams = 0; 11136 11137 if (m_bStreamsConfigured) { 11138 CDBG_HIGH("%s: Reset stream config!!", __func__); 11139 rc = sendStreamConfigInfo(stream_config_info); 11140 m_bStreamsConfigured = false; 11141 } 11142 if (resetConfig) { 11143 CDBG_HIGH("%s: Done Resetting stream config!!", __func__); 11144 return rc; 11145 } 11146 11147 property_get("persist.camera.raw_yuv", value, "0"); 11148 raw_yuv = atoi(value) > 0 ? true : false; 11149 11150 if (isZSLMode() && getRecordingHintValue() != true) { 11151 stream_config_info.type[stream_config_info.num_streams] = 11152 CAM_STREAM_TYPE_PREVIEW; 11153 getStreamDimension(CAM_STREAM_TYPE_PREVIEW, 11154 stream_config_info.stream_sizes[stream_config_info.num_streams]); 11155 updatePpFeatureMask(CAM_STREAM_TYPE_PREVIEW); 11156 stream_config_info.postprocess_mask[stream_config_info.num_streams] = 11157 mStreamPpMask[CAM_STREAM_TYPE_PREVIEW]; 11158 stream_config_info.num_streams++; 11159 11160 stream_config_info.type[stream_config_info.num_streams] = 11161 CAM_STREAM_TYPE_ANALYSIS; 11162 getStreamDimension(CAM_STREAM_TYPE_ANALYSIS, 11163 stream_config_info.stream_sizes[stream_config_info.num_streams]); 11164 updatePpFeatureMask(CAM_STREAM_TYPE_ANALYSIS); 11165 stream_config_info.postprocess_mask[stream_config_info.num_streams] = 11166 mStreamPpMask[CAM_STREAM_TYPE_ANALYSIS]; 11167 stream_config_info.num_streams++; 11168 11169 stream_config_info.type[stream_config_info.num_streams] = 11170 CAM_STREAM_TYPE_SNAPSHOT; 11171 getStreamDimension(CAM_STREAM_TYPE_SNAPSHOT, 11172 stream_config_info.stream_sizes[stream_config_info.num_streams]); 11173 updatePpFeatureMask(CAM_STREAM_TYPE_SNAPSHOT); 11174 stream_config_info.postprocess_mask[stream_config_info.num_streams] = 11175 mStreamPpMask[CAM_STREAM_TYPE_SNAPSHOT]; 11176 stream_config_info.num_streams++; 11177 11178 } else if (!isCapture) { 11179 if (m_bRecordingHint) { 11180 if (m_bDISEnabled) { 11181 char value[PROPERTY_VALUE_MAX]; 11182 // Make default value for IS_TYPE as IS_TYPE_EIS_2_0 11183 property_get("persist.camera.is_type", value, "4"); 11184 mIsType = static_cast<cam_is_type_t>(atoi(value)); 11185 } else { 11186 mIsType = IS_TYPE_NONE; 11187 } 11188 stream_config_info.is_type = mIsType; 11189 stream_config_info.type[stream_config_info.num_streams] = 11190 CAM_STREAM_TYPE_SNAPSHOT; 11191 getStreamDimension(CAM_STREAM_TYPE_SNAPSHOT, 11192 stream_config_info.stream_sizes[stream_config_info.num_streams]); 11193 updatePpFeatureMask(CAM_STREAM_TYPE_SNAPSHOT); 11194 stream_config_info.postprocess_mask[stream_config_info.num_streams] = 11195 mStreamPpMask[CAM_STREAM_TYPE_SNAPSHOT]; 11196 stream_config_info.num_streams++; 11197 11198 stream_config_info.type[stream_config_info.num_streams] = 11199 CAM_STREAM_TYPE_VIDEO; 11200 getStreamDimension(CAM_STREAM_TYPE_VIDEO, 11201 stream_config_info.stream_sizes[stream_config_info.num_streams]); 11202 updatePpFeatureMask(CAM_STREAM_TYPE_VIDEO); 11203 stream_config_info.postprocess_mask[stream_config_info.num_streams] = 11204 mStreamPpMask[CAM_STREAM_TYPE_VIDEO]; 11205 stream_config_info.num_streams++; 11206 } 11207 11208 if (getRecordingHintValue() != true) { 11209 /* Analysis stream is used only in capture usecase */ 11210 stream_config_info.type[stream_config_info.num_streams] = 11211 CAM_STREAM_TYPE_ANALYSIS; 11212 getStreamDimension(CAM_STREAM_TYPE_ANALYSIS, 11213 stream_config_info.stream_sizes[stream_config_info.num_streams]); 11214 updatePpFeatureMask(CAM_STREAM_TYPE_ANALYSIS); 11215 stream_config_info.postprocess_mask[stream_config_info.num_streams] = 11216 mStreamPpMask[CAM_STREAM_TYPE_ANALYSIS]; 11217 stream_config_info.num_streams++; 11218 } 11219 11220 stream_config_info.type[stream_config_info.num_streams] = 11221 CAM_STREAM_TYPE_PREVIEW; 11222 getStreamDimension(CAM_STREAM_TYPE_PREVIEW, 11223 stream_config_info.stream_sizes[stream_config_info.num_streams]); 11224 updatePpFeatureMask(CAM_STREAM_TYPE_PREVIEW); 11225 stream_config_info.postprocess_mask[stream_config_info.num_streams] = 11226 mStreamPpMask[CAM_STREAM_TYPE_PREVIEW]; 11227 stream_config_info.num_streams++; 11228 11229 } else { 11230 if (isJpegPictureFormat() || isNV16PictureFormat() || isNV21PictureFormat()) { 11231 if (!getofflineRAW()) { 11232 stream_config_info.type[stream_config_info.num_streams] = 11233 CAM_STREAM_TYPE_SNAPSHOT; 11234 getStreamDimension(CAM_STREAM_TYPE_SNAPSHOT, 11235 stream_config_info.stream_sizes[stream_config_info.num_streams]); 11236 updatePpFeatureMask(CAM_STREAM_TYPE_SNAPSHOT); 11237 stream_config_info.postprocess_mask[stream_config_info.num_streams] = 11238 mStreamPpMask[CAM_STREAM_TYPE_SNAPSHOT]; 11239 stream_config_info.num_streams++; 11240 } 11241 11242 if (previewAsPostview) { 11243 stream_config_info.type[stream_config_info.num_streams] = 11244 CAM_STREAM_TYPE_PREVIEW; 11245 getStreamDimension(CAM_STREAM_TYPE_PREVIEW, 11246 stream_config_info.stream_sizes[stream_config_info.num_streams]); 11247 updatePpFeatureMask(CAM_STREAM_TYPE_PREVIEW); 11248 stream_config_info.postprocess_mask[stream_config_info.num_streams] = 11249 mStreamPpMask[CAM_STREAM_TYPE_PREVIEW]; 11250 stream_config_info.num_streams++; 11251 } else { 11252 stream_config_info.type[stream_config_info.num_streams] = 11253 CAM_STREAM_TYPE_POSTVIEW; 11254 getStreamDimension(CAM_STREAM_TYPE_POSTVIEW, 11255 stream_config_info.stream_sizes[stream_config_info.num_streams]); 11256 updatePpFeatureMask(CAM_STREAM_TYPE_POSTVIEW); 11257 stream_config_info.postprocess_mask[stream_config_info.num_streams] = 11258 mStreamPpMask[CAM_STREAM_TYPE_POSTVIEW]; 11259 stream_config_info.num_streams++; 11260 } 11261 } else { 11262 raw_capture = true; 11263 stream_config_info.type[stream_config_info.num_streams] = 11264 CAM_STREAM_TYPE_RAW; 11265 getStreamDimension(CAM_STREAM_TYPE_RAW, 11266 stream_config_info.stream_sizes[stream_config_info.num_streams]); 11267 updatePpFeatureMask(CAM_STREAM_TYPE_RAW); 11268 stream_config_info.postprocess_mask[stream_config_info.num_streams] = 11269 mStreamPpMask[CAM_STREAM_TYPE_RAW]; 11270 stream_config_info.num_streams++; 11271 } 11272 } 11273 if (raw_yuv && !raw_capture && (isZSLMode() || 11274 (getofflineRAW() && isCapture && !getRecordingHintValue()))) { 11275 cam_dimension_t max_dim = {0,0}; 11276 updateRAW(max_dim); 11277 stream_config_info.type[stream_config_info.num_streams] = 11278 CAM_STREAM_TYPE_RAW; 11279 getStreamDimension(CAM_STREAM_TYPE_RAW, 11280 stream_config_info.stream_sizes[stream_config_info.num_streams]); 11281 updatePpFeatureMask(CAM_STREAM_TYPE_RAW); 11282 stream_config_info.postprocess_mask[stream_config_info.num_streams] = 11283 mStreamPpMask[CAM_STREAM_TYPE_RAW]; 11284 stream_config_info.num_streams++; 11285 } 11286 for (uint32_t k = 0; k < stream_config_info.num_streams; k++) { 11287 ALOGI("%s: stream type %d, w x h: %d x %d, pp_mask: 0x%x", __func__, 11288 stream_config_info.type[k], 11289 stream_config_info.stream_sizes[k].width, 11290 stream_config_info.stream_sizes[k].height, 11291 stream_config_info.postprocess_mask[k]); 11292 } 11293 11294 rc = sendStreamConfigInfo(stream_config_info); 11295 m_bStreamsConfigured = true; 11296 11297 return rc; 11298 } 11299 11300 /*=========================================================================== 11301 * FUNCTION : addOnlineRotation 11302 * 11303 * DESCRIPTION: send additional rotation information for specific stream 11304 * 11305 * PARAMETERS : 11306 * @rotation: rotation 11307 * @streamId: internal stream id 11308 * @device_rotation: device rotation 11309 * 11310 * RETURN : int32_t type of status 11311 * NO_ERROR -- success 11312 * none-zero failure code 11313 *==========================================================================*/ 11314 int32_t QCameraParameters::addOnlineRotation(uint32_t rotation, uint32_t streamId, 11315 int32_t device_rotation) 11316 { 11317 int32_t rc = NO_ERROR; 11318 cam_rotation_info_t rotation_info; 11319 memset(&rotation_info, 0, sizeof(cam_rotation_info_t)); 11320 11321 /* Add jpeg rotation information */ 11322 if (rotation == 0) { 11323 rotation_info.rotation = ROTATE_0; 11324 } else if (rotation == 90) { 11325 rotation_info.rotation = ROTATE_90; 11326 } else if (rotation == 180) { 11327 rotation_info.rotation = ROTATE_180; 11328 } else if (rotation == 270) { 11329 rotation_info.rotation = ROTATE_270; 11330 } else { 11331 rotation_info.rotation = ROTATE_0; 11332 } 11333 rotation_info.streamId = streamId; 11334 11335 /* Add device rotation information */ 11336 if (device_rotation == 0) { 11337 rotation_info.device_rotation = ROTATE_0; 11338 } else if (device_rotation == 90) { 11339 rotation_info.device_rotation = ROTATE_90; 11340 } else if (device_rotation == 180) { 11341 rotation_info.device_rotation = ROTATE_180; 11342 } else if (device_rotation == 270) { 11343 rotation_info.device_rotation = ROTATE_270; 11344 } else { 11345 rotation_info.device_rotation = ROTATE_0; 11346 } 11347 11348 if(initBatchUpdate(m_pParamBuf) < 0 ) { 11349 ALOGE("%s:Failed to initialize group update table", __func__); 11350 return BAD_TYPE; 11351 } 11352 11353 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_ROTATION, rotation_info)) { 11354 ALOGE("%s:Failed to update table", __func__); 11355 return BAD_VALUE; 11356 } 11357 11358 rc = commitSetBatch(); 11359 if (rc != NO_ERROR) { 11360 ALOGE("%s:Failed to set stream info parm", __func__); 11361 return rc; 11362 } 11363 11364 return rc; 11365 } 11366 11367 /*=========================================================================== 11368 * FUNCTION : needThumbnailReprocess 11369 * 11370 * DESCRIPTION: Check if thumbnail reprocessing is needed 11371 * 11372 * PARAMETERS : @pFeatureMask - feature mask 11373 * 11374 * RETURN : true: needed 11375 * false: no need 11376 *==========================================================================*/ 11377 bool QCameraParameters::needThumbnailReprocess(uint32_t *pFeatureMask) 11378 { 11379 if (isUbiFocusEnabled() || isChromaFlashEnabled() || 11380 isOptiZoomEnabled() || isUbiRefocus() || 11381 isStillMoreEnabled()) { 11382 *pFeatureMask &= ~CAM_QCOM_FEATURE_CHROMA_FLASH; 11383 *pFeatureMask &= ~CAM_QCOM_FEATURE_UBIFOCUS; 11384 *pFeatureMask &= ~CAM_QCOM_FEATURE_REFOCUS; 11385 *pFeatureMask &= ~CAM_QCOM_FEATURE_OPTIZOOM; 11386 *pFeatureMask &= ~CAM_QCOM_FEATURE_STILLMORE; 11387 return false; 11388 } else { 11389 return true; 11390 } 11391 } 11392 11393 /*=========================================================================== 11394 * FUNCTION : getNumOfExtraBuffersForImageProc 11395 * 11396 * DESCRIPTION: get number of extra input buffers needed by image processing 11397 * 11398 * PARAMETERS : none 11399 * 11400 * RETURN : number of extra buffers needed by ImageProc; 11401 * 0 if not ImageProc enabled 11402 *==========================================================================*/ 11403 uint8_t QCameraParameters::getNumOfExtraBuffersForImageProc() 11404 { 11405 int numOfBufs = 0; 11406 11407 if (isUbiRefocus()) { 11408 return (uint8_t)(m_pCapability->refocus_af_bracketing_need.burst_count - 1); 11409 } else if (isUbiFocusEnabled()) { 11410 numOfBufs += m_pCapability->ubifocus_af_bracketing_need.burst_count - 1; 11411 } else if (m_bOptiZoomOn) { 11412 numOfBufs += m_pCapability->opti_zoom_settings_need.burst_count - 1; 11413 } else if (isChromaFlashEnabled()) { 11414 numOfBufs += m_pCapability->chroma_flash_settings_need.burst_count - 1; 11415 } else if (isStillMoreEnabled()) { 11416 if (isSeeMoreEnabled()) { 11417 m_stillmore_config.burst_count = 1; 11418 } else if ((m_stillmore_config.burst_count >= 11419 m_pCapability->stillmore_settings_need.min_burst_count) && 11420 (m_stillmore_config.burst_count <= 11421 m_pCapability->stillmore_settings_need.max_burst_count)) { 11422 numOfBufs += m_stillmore_config.burst_count - 1; 11423 } else { 11424 numOfBufs += m_pCapability->stillmore_settings_need.burst_count - 1; 11425 } 11426 } 11427 11428 return (uint8_t)(numOfBufs * getBurstNum()); 11429 } 11430 11431 /*=========================================================================== 11432 * FUNCTION : getExifBufIndex 11433 * 11434 * DESCRIPTION: get index of metadata to be used for EXIF 11435 * 11436 * PARAMETERS : @captureIndex - index of current captured frame 11437 * 11438 * RETURN : index of metadata to be used for EXIF 11439 *==========================================================================*/ 11440 uint32_t QCameraParameters::getExifBufIndex(uint32_t captureIndex) 11441 { 11442 uint32_t index = captureIndex; 11443 11444 if (isUbiRefocus()) { 11445 if (captureIndex < m_pCapability->refocus_af_bracketing_need.burst_count) { 11446 index = captureIndex; 11447 } else { 11448 index = 0; 11449 } 11450 } else if (isChromaFlashEnabled()) { 11451 index = m_pCapability->chroma_flash_settings_need.metadata_index; 11452 } else if (isHDREnabled()) { 11453 if (isHDR1xFrameEnabled() && isHDR1xExtraBufferNeeded()) { 11454 index = m_pCapability->hdr_bracketing_setting.num_frames; 11455 } else { 11456 for (index = 0; index < m_pCapability->hdr_bracketing_setting.num_frames; index++) { 11457 if (0 == m_pCapability->hdr_bracketing_setting.exp_val.values[index]) { 11458 break; 11459 } 11460 } 11461 if (index == m_pCapability->hdr_bracketing_setting.num_frames) { 11462 index = captureIndex; 11463 } 11464 } 11465 } 11466 11467 return index; 11468 } 11469 11470 /*=========================================================================== 11471 * FUNCTION : getNumberInBufsForSingleShot 11472 * 11473 * DESCRIPTION: get number of input buffers for single shot 11474 * 11475 * PARAMETERS : none 11476 * 11477 * RETURN : number of input buffers for single shot 11478 *==========================================================================*/ 11479 uint32_t QCameraParameters::getNumberInBufsForSingleShot() 11480 { 11481 uint32_t numOfBufs = 1; 11482 11483 if (isUbiRefocus()) { 11484 numOfBufs = m_pCapability->refocus_af_bracketing_need.burst_count; 11485 } else if (isUbiFocusEnabled()) { 11486 numOfBufs = m_pCapability->ubifocus_af_bracketing_need.burst_count; 11487 } else if (m_bOptiZoomOn) { 11488 numOfBufs = m_pCapability->opti_zoom_settings_need.burst_count; 11489 } else if (isChromaFlashEnabled()) { 11490 numOfBufs = m_pCapability->chroma_flash_settings_need.burst_count; 11491 } else if (isHDREnabled()) { 11492 numOfBufs = m_pCapability->hdr_bracketing_setting.num_frames; 11493 if (isHDR1xFrameEnabled() && isHDR1xExtraBufferNeeded()) { 11494 numOfBufs++; 11495 } 11496 } else if (isStillMoreEnabled()) { 11497 if (isSeeMoreEnabled()) { 11498 m_stillmore_config.burst_count = 1; 11499 numOfBufs = m_stillmore_config.burst_count; 11500 } else if ((m_stillmore_config.burst_count >= 11501 m_pCapability->stillmore_settings_need.min_burst_count) && 11502 (m_stillmore_config.burst_count <= 11503 m_pCapability->stillmore_settings_need.max_burst_count)) { 11504 numOfBufs = m_stillmore_config.burst_count; 11505 } else { 11506 numOfBufs = m_pCapability->stillmore_settings_need.burst_count; 11507 } 11508 } 11509 11510 return numOfBufs; 11511 } 11512 11513 /*=========================================================================== 11514 * FUNCTION : getNumberOutBufsForSingleShot 11515 * 11516 * DESCRIPTION: get number of output buffers for single shot 11517 * 11518 * PARAMETERS : none 11519 * 11520 * RETURN : number of output buffers for single shot 11521 *==========================================================================*/ 11522 uint32_t QCameraParameters::getNumberOutBufsForSingleShot() 11523 { 11524 uint32_t numOfBufs = 1; 11525 11526 if (isUbiRefocus()) { 11527 numOfBufs = m_pCapability->refocus_af_bracketing_need.output_count; 11528 } else if (isHDREnabled()) { 11529 if (isHDR1xFrameEnabled()) { 11530 numOfBufs++; 11531 } 11532 } 11533 11534 return numOfBufs; 11535 } 11536 11537 /*=========================================================================== 11538 * FUNCTION : is4k2kVideoResolution 11539 * 11540 * DESCRIPTION: if resolution is 4k x 2k or true 4k x 2k 11541 * 11542 * PARAMETERS : none 11543 * 11544 * RETURN : true: video resolution is 4k x 2k 11545 * false: video resolution is not 4k x 2k 11546 *==========================================================================*/ 11547 bool QCameraParameters::is4k2kVideoResolution() 11548 { 11549 bool enabled = false; 11550 cam_dimension_t resolution; 11551 getVideoSize(&resolution.width, &resolution.height); 11552 if (!(resolution.width < 3840 && resolution.height < 2160)) { 11553 enabled = true; 11554 } 11555 11556 return enabled; 11557 } 11558 11559 /*=========================================================================== 11560 * FUNCTION : updateDebugLevel 11561 * 11562 * DESCRIPTION: send CAM_INTF_PARM_UPDATE_DEBUG_LEVEL to backend 11563 * 11564 * PARAMETERS : none 11565 * 11566 * RETURN : NO_ERROR --success 11567 * int32_t type of status 11568 *==========================================================================*/ 11569 int32_t QCameraParameters::updateDebugLevel() 11570 { 11571 if ( m_pParamBuf == NULL ) { 11572 return NO_INIT; 11573 } 11574 11575 int32_t rc = initBatchUpdate(m_pParamBuf); 11576 if ( rc != NO_ERROR ) { 11577 ALOGE("%s:Failed to initialize group update table", __func__); 11578 return rc; 11579 } 11580 11581 uint32_t dummyDebugLevel = 0; 11582 /* The value of dummyDebugLevel is irrelavent. On 11583 * CAM_INTF_PARM_UPDATE_DEBUG_LEVEL, read debug property */ 11584 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_UPDATE_DEBUG_LEVEL, dummyDebugLevel)) { 11585 ALOGE("%s: Parameters batch failed",__func__); 11586 return BAD_VALUE; 11587 } 11588 11589 rc = commitSetBatch(); 11590 if ( rc != NO_ERROR ) { 11591 ALOGE("%s:Failed to commit batch parameters", __func__); 11592 return rc; 11593 } 11594 11595 return NO_ERROR; 11596 } 11597 11598 /*=========================================================================== 11599 * FUNCTION : setOfflineRAW 11600 * 11601 * DESCRIPTION: Function to decide Offline RAW feature. 11602 * 11603 * PARAMETERS : none 11604 * 11605 * RETURN : none 11606 *==========================================================================*/ 11607 void QCameraParameters::setOfflineRAW() 11608 { 11609 char value[PROPERTY_VALUE_MAX]; 11610 bool raw_yuv = false; 11611 bool offlineRaw = false; 11612 11613 property_get("persist.camera.raw_yuv", value, "0"); 11614 raw_yuv = atoi(value) > 0 ? true : false; 11615 property_get("persist.camera.offlineraw", value, "0"); 11616 offlineRaw = atoi(value) > 0 ? true : false; 11617 if((raw_yuv || isRdiMode()) && offlineRaw){ 11618 mOfflineRAW = true; 11619 }else{ 11620 mOfflineRAW = false; 11621 } 11622 CDBG_HIGH("%s: Offline Raw %d",__func__, mOfflineRAW); 11623 } 11624 11625 /*=========================================================================== 11626 * FUNCTION : updatePpFeatureMask 11627 * 11628 * DESCRIPTION: Updates the feature mask for a particular stream depending 11629 * on current client configuration. 11630 * 11631 * PARAMETERS : 11632 * @stream_type: Camera stream type 11633 * 11634 * RETURN : NO_ERROR --success 11635 * int32_t type of status 11636 *==========================================================================*/ 11637 int32_t QCameraParameters::updatePpFeatureMask(cam_stream_type_t stream_type) { 11638 11639 uint32_t feature_mask = 0; 11640 11641 if (stream_type >= CAM_STREAM_TYPE_MAX) { 11642 ALOGE("%s: Error!! stream type: %d not valid", __func__, stream_type); 11643 return -1; 11644 } 11645 11646 // Update feature mask for SeeMore in video and video preview 11647 if (isSeeMoreEnabled() && 11648 !is4k2kVideoResolution() && 11649 ((stream_type == CAM_STREAM_TYPE_VIDEO) || 11650 (stream_type == CAM_STREAM_TYPE_PREVIEW && getRecordingHintValue()))) { 11651 feature_mask |= CAM_QCOM_FEATURE_LLVD; 11652 } 11653 11654 // Do not enable feature mask for ZSL/non-ZSL/liveshot snapshot except for 4K2k case 11655 if ((getRecordingHintValue() && 11656 (stream_type == CAM_STREAM_TYPE_SNAPSHOT) && is4k2kVideoResolution()) || 11657 (stream_type != CAM_STREAM_TYPE_SNAPSHOT)) { 11658 if ((m_nMinRequiredPpMask & CAM_QCOM_FEATURE_SHARPNESS) && 11659 !isOptiZoomEnabled()) { 11660 feature_mask |= CAM_QCOM_FEATURE_SHARPNESS; 11661 } 11662 11663 if (m_nMinRequiredPpMask & CAM_QCOM_FEATURE_EFFECT) { 11664 feature_mask |= CAM_QCOM_FEATURE_EFFECT; 11665 } 11666 if (isWNREnabled() && (getRecordingHintValue() == false)) { 11667 feature_mask |= CAM_QCOM_FEATURE_DENOISE2D; 11668 } 11669 11670 //Set flip mode based on Stream type; 11671 int flipMode = getFlipMode(stream_type); 11672 if (flipMode > 0) { 11673 feature_mask |= CAM_QCOM_FEATURE_FLIP; 11674 } 11675 } 11676 11677 if ((isTNRVideoEnabled() && (CAM_STREAM_TYPE_VIDEO == stream_type)) 11678 || (isTNRPreviewEnabled() && (CAM_STREAM_TYPE_PREVIEW == stream_type))) { 11679 feature_mask |= CAM_QCOM_FEATURE_CPP_TNR; 11680 } 11681 11682 //Rotation could also have an effect on pp feature mask 11683 cam_pp_feature_config_t config; 11684 cam_dimension_t dim; 11685 memset(&config, 0, sizeof(cam_pp_feature_config_t)); 11686 getStreamRotation(stream_type, config, dim); 11687 feature_mask |= config.feature_mask; 11688 11689 // Store stream feature mask 11690 setStreamPpMask(stream_type, feature_mask); 11691 CDBG_HIGH("%s: stream type: %d, pp_mask: 0x%x", __func__, stream_type, feature_mask); 11692 11693 return NO_ERROR; 11694 } 11695 11696 /*=========================================================================== 11697 * FUNCTION : setStreamPpMask 11698 * 11699 * DESCRIPTION: Stores a particular feature mask for a given camera stream 11700 * 11701 * PARAMETERS : 11702 * @stream_type: Camera stream type 11703 * @pp_mask : Feature mask 11704 * 11705 * RETURN : NO_ERROR --success 11706 * int32_t type of status 11707 *==========================================================================*/ 11708 int32_t QCameraParameters::setStreamPpMask(cam_stream_type_t stream_type, 11709 uint32_t pp_mask) { 11710 11711 if(stream_type >= CAM_STREAM_TYPE_MAX) { 11712 return BAD_TYPE; 11713 } 11714 11715 mStreamPpMask[stream_type] = pp_mask; 11716 return NO_ERROR; 11717 } 11718 11719 /*=========================================================================== 11720 * FUNCTION : getStreamPpMask 11721 * 11722 * DESCRIPTION: Retrieves the feature mask for a given camera stream 11723 * 11724 * PARAMETERS : 11725 * @stream_type: Camera stream type 11726 * @pp_mask : Feature mask 11727 * 11728 * RETURN : NO_ERROR --success 11729 * int32_t type of status 11730 *==========================================================================*/ 11731 int32_t QCameraParameters::getStreamPpMask(cam_stream_type_t stream_type, 11732 uint32_t &pp_mask) { 11733 11734 if(stream_type >= CAM_STREAM_TYPE_MAX) { 11735 return BAD_TYPE; 11736 } 11737 11738 pp_mask = mStreamPpMask[stream_type]; 11739 return NO_ERROR; 11740 } 11741 11742 /*=========================================================================== 11743 * FUNCTION : setReprocCount 11744 * 11745 * DESCRIPTION: Set total reprocessing pass count 11746 * 11747 * PARAMETERS : none 11748 * 11749 * RETURN : None 11750 *==========================================================================*/ 11751 void QCameraParameters::setReprocCount() 11752 { 11753 mTotalPPCount = 1; //Default reprocessing Pass count 11754 char value[PROPERTY_VALUE_MAX]; 11755 int multpass = 0; 11756 11757 property_get("persist.camera.multi_pass", value, "0"); 11758 multpass = atoi(value); 11759 11760 if ( multpass == 0 ) { 11761 return; 11762 } 11763 11764 if ((getZoomLevel() != 0) && (isZSLMode())) { 11765 ALOGW("Zoom Present. Need 2nd pass for post processing"); 11766 mTotalPPCount++; 11767 } 11768 } 11769 11770 /*=========================================================================== 11771 * FUNCTION : setBufBatchCount 11772 * 11773 * DESCRIPTION: Function to configure batch buffer 11774 * 11775 * PARAMETERS : int8_t buf_cnt 11776 * Buffer batch count 11777 * 11778 * RETURN : None 11779 *==========================================================================*/ 11780 void QCameraParameters::setBufBatchCount(int8_t buf_cnt) 11781 { 11782 mBufBatchCnt = 0; 11783 char value[PROPERTY_VALUE_MAX]; 11784 int8_t count = 0; 11785 11786 property_get("persist.camera.batchcount", value, "0"); 11787 count = atoi(value); 11788 11789 if (!(count != 0 || buf_cnt > CAMERA_MIN_BATCH_COUNT)) { 11790 CDBG_HIGH("%s : Buffer batch count = %d", __func__, mBufBatchCnt); 11791 return; 11792 } 11793 11794 while((m_pCapability->max_batch_bufs_supported != 0) 11795 && (m_pCapability->max_batch_bufs_supported < buf_cnt)) { 11796 buf_cnt = buf_cnt / 2; 11797 } 11798 11799 if (count > 0) { 11800 mBufBatchCnt = count; 11801 CDBG_HIGH("%s : Buffer batch count = %d", __func__, mBufBatchCnt); 11802 return; 11803 } 11804 11805 if (buf_cnt > CAMERA_MIN_BATCH_COUNT) { 11806 mBufBatchCnt = buf_cnt; 11807 CDBG_HIGH("%s : Buffer batch count = %d", __func__, mBufBatchCnt); 11808 return; 11809 } 11810 } 11811 11812 /*=========================================================================== 11813 * FUNCTION : dump 11814 * 11815 * DESCRIPTION: Composes a string based on current configuration 11816 * 11817 * PARAMETERS : none 11818 * 11819 * RETURN : Formatted string 11820 *==========================================================================*/ 11821 String8 QCameraParameters::dump() 11822 { 11823 String8 str("\n"); 11824 char s[128]; 11825 11826 snprintf(s, 128, "Preview Pixel Fmt: %d\n", getPreviewHalPixelFormat()); 11827 str += s; 11828 11829 snprintf(s, 128, "ZSL Burst Interval: %d\n", getZSLBurstInterval()); 11830 str += s; 11831 11832 snprintf(s, 128, "ZSL Queue Depth: %d\n", getZSLQueueDepth()); 11833 str += s; 11834 11835 snprintf(s, 128, "ZSL Back Look Count %d\n", getZSLBackLookCount()); 11836 str += s; 11837 11838 snprintf(s, 128, "Max Unmatched Frames In Queue: %d\n", 11839 getMaxUnmatchedFramesInQueue()); 11840 str += s; 11841 11842 snprintf(s, 128, "Is ZSL Mode: %d\n", isZSLMode()); 11843 str += s; 11844 11845 snprintf(s, 128, "Is No Display Mode: %d\n", isNoDisplayMode()); 11846 str += s; 11847 11848 snprintf(s, 128, "Is WNR Enabled: %d\n", isWNREnabled()); 11849 str += s; 11850 11851 snprintf(s, 128, "isHfrMode: %d\n", isHfrMode()); 11852 str += s; 11853 11854 snprintf(s, 128, "getNumOfSnapshots: %d\n", getNumOfSnapshots()); 11855 str += s; 11856 11857 snprintf(s, 128, "getNumOfExtraHDRInBufsIfNeeded: %d\n", 11858 getNumOfExtraHDRInBufsIfNeeded()); 11859 str += s; 11860 11861 snprintf(s, 128, "getNumOfExtraHDROutBufsIfNeeded: %d\n", 11862 getNumOfExtraHDROutBufsIfNeeded()); 11863 str += s; 11864 11865 snprintf(s, 128, "getBurstNum: %d\n", getBurstNum()); 11866 str += s; 11867 11868 snprintf(s, 128, "getRecordingHintValue: %d\n", getRecordingHintValue()); 11869 str += s; 11870 11871 snprintf(s, 128, "getJpegQuality: %u\n", getJpegQuality()); 11872 str += s; 11873 11874 snprintf(s, 128, "getJpegRotation: %u\n", getJpegRotation()); 11875 str += s; 11876 11877 snprintf(s, 128, "isHistogramEnabled: %d\n", isHistogramEnabled()); 11878 str += s; 11879 11880 snprintf(s, 128, "isFaceDetectionEnabled: %d\n", isFaceDetectionEnabled()); 11881 str += s; 11882 11883 snprintf(s, 128, "isHDREnabled: %d\n", isHDREnabled()); 11884 str += s; 11885 11886 snprintf(s, 128, "isAutoHDREnabled: %d\n", isAutoHDREnabled()); 11887 str += s; 11888 11889 snprintf(s, 128, "isAVTimerEnabled: %d\n", isAVTimerEnabled()); 11890 str += s; 11891 11892 snprintf(s, 128, "getFocusMode: %d\n", getFocusMode()); 11893 str += s; 11894 11895 snprintf(s, 128, "isJpegPictureFormat: %d\n", isJpegPictureFormat()); 11896 str += s; 11897 11898 snprintf(s, 128, "isNV16PictureFormat: %d\n", isNV16PictureFormat()); 11899 str += s; 11900 11901 snprintf(s, 128, "isNV21PictureFormat: %d\n", isNV21PictureFormat()); 11902 str += s; 11903 11904 snprintf(s, 128, "isSnapshotFDNeeded: %d\n", isSnapshotFDNeeded()); 11905 str += s; 11906 11907 snprintf(s, 128, "isHDR1xFrameEnabled: %d\n", isHDR1xFrameEnabled()); 11908 str += s; 11909 11910 snprintf(s, 128, "isYUVFrameInfoNeeded: %d\n", isYUVFrameInfoNeeded()); 11911 str += s; 11912 11913 snprintf(s, 128, "isHDR1xExtraBufferNeeded: %d\n", 11914 isHDR1xExtraBufferNeeded()); 11915 str += s; 11916 11917 snprintf(s, 128, "isHDROutputCropEnabled: %d\n", isHDROutputCropEnabled()); 11918 str += s; 11919 11920 snprintf(s, 128, "isPreviewFlipChanged: %d\n", isPreviewFlipChanged()); 11921 str += s; 11922 11923 snprintf(s, 128, "isVideoFlipChanged: %d\n", isVideoFlipChanged()); 11924 str += s; 11925 11926 snprintf(s, 128, "isSnapshotFlipChanged: %d\n", isSnapshotFlipChanged()); 11927 str += s; 11928 11929 snprintf(s, 128, "isHDRThumbnailProcessNeeded: %d\n", 11930 isHDRThumbnailProcessNeeded()); 11931 str += s; 11932 11933 snprintf(s, 128, "getAutoFlickerMode: %d\n", getAutoFlickerMode()); 11934 str += s; 11935 11936 snprintf(s, 128, "getNumOfExtraBuffersForImageProc: %d\n", 11937 getNumOfExtraBuffersForImageProc()); 11938 str += s; 11939 11940 snprintf(s, 128, "isUbiFocusEnabled: %d\n", isUbiFocusEnabled()); 11941 str += s; 11942 11943 snprintf(s, 128, "isChromaFlashEnabled: %d\n", isChromaFlashEnabled()); 11944 str += s; 11945 11946 snprintf(s, 128, "isOptiZoomEnabled: %d\n", isOptiZoomEnabled()); 11947 str += s; 11948 11949 snprintf(s, 128, "isStillMoreEnabled: %d\n", isStillMoreEnabled()); 11950 str += s; 11951 11952 snprintf(s, 128, "getBurstCountForAdvancedCapture: %d\n", 11953 getBurstCountForAdvancedCapture()); 11954 str += s; 11955 11956 return str; 11957 } 11958 11959 /*=========================================================================== 11960 * FUNCTION : getNumOfExtraBuffersForVideo 11961 * 11962 * DESCRIPTION: get number of extra buffers needed by image processing 11963 * 11964 * PARAMETERS : none 11965 * 11966 * RETURN : number of extra buffers needed by ImageProc; 11967 * 0 if not ImageProc enabled 11968 *==========================================================================*/ 11969 uint8_t QCameraParameters::getNumOfExtraBuffersForVideo() 11970 { 11971 uint8_t numOfBufs = 0; 11972 11973 if (isSeeMoreEnabled()) { 11974 numOfBufs = 1; 11975 } 11976 11977 return numOfBufs; 11978 } 11979 11980 /*=========================================================================== 11981 * FUNCTION : getNumOfExtraBuffersForPreview 11982 * 11983 * DESCRIPTION: get number of extra buffers needed by image processing 11984 * 11985 * PARAMETERS : none 11986 * 11987 * RETURN : number of extra buffers needed by ImageProc; 11988 * 0 if not ImageProc enabled 11989 *==========================================================================*/ 11990 uint8_t QCameraParameters::getNumOfExtraBuffersForPreview() 11991 { 11992 uint8_t numOfBufs = 0; 11993 11994 if (isSeeMoreEnabled() && !isZSLMode() && getRecordingHintValue()) { 11995 numOfBufs = 1; 11996 } 11997 11998 return numOfBufs; 11999 } 12000 12001 /*=========================================================================== 12002 * FUNCTION : setToneMapMode 12003 * 12004 * DESCRIPTION: enable or disable tone map 12005 * 12006 * PARAMETERS : 12007 * @enable : enable: 1; disable 0 12008 * @initCommit: if configuration list needs to be initialized and commited 12009 * 12010 * RETURN : int32_t type of status 12011 * NO_ERROR -- success 12012 * none-zero failure code 12013 *==========================================================================*/ 12014 int32_t QCameraParameters::setToneMapMode(uint32_t enable, bool initCommit) 12015 { 12016 int32_t rc = NO_ERROR; 12017 CDBG_HIGH("%s: tone map mode %d ", __func__, enable); 12018 12019 if (initCommit) { 12020 if (initBatchUpdate(m_pParamBuf) < 0) { 12021 ALOGE("%s:Failed to initialize group update table", __func__); 12022 return FAILED_TRANSACTION; 12023 } 12024 } 12025 12026 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_TONE_MAP_MODE, enable)) { 12027 ALOGE("%s:Failed to update tone map mode", __func__); 12028 return BAD_VALUE; 12029 } 12030 12031 if (initCommit) { 12032 rc = commitSetBatch(); 12033 if (rc != NO_ERROR) { 12034 ALOGE("%s:Failed to commit tone map mode", __func__); 12035 return rc; 12036 } 12037 } 12038 12039 return rc; 12040 } 12041 12042 /*=========================================================================== 12043 * FUNCTION : setCDSMode 12044 * 12045 * DESCRIPTION: set CDS mode 12046 * 12047 * PARAMETERS : 12048 * @cds_mode : cds mode 12049 * @initCommit: if configuration list needs to be initialized and commited 12050 * 12051 * RETURN : int32_t type of status 12052 * NO_ERROR -- success 12053 * none-zero failure code 12054 *==========================================================================*/ 12055 int32_t QCameraParameters::setCDSMode(int32_t cds_mode, bool initCommit) 12056 { 12057 if (initCommit) { 12058 if (initBatchUpdate(m_pParamBuf) < 0) { 12059 ALOGE("%s:Failed to initialize group update table", __func__); 12060 return FAILED_TRANSACTION; 12061 } 12062 } 12063 12064 int32_t rc = NO_ERROR; 12065 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_CDS_MODE, cds_mode)) { 12066 ALOGE("%s:Failed to update cds mode", __func__); 12067 return BAD_VALUE; 12068 } 12069 12070 if (initCommit) { 12071 rc = commitSetBatch(); 12072 if (NO_ERROR != rc) { 12073 ALOGE("%s:Failed to set cds mode", __func__); 12074 return rc; 12075 } 12076 } 12077 12078 CDBG_HIGH(" cds mode -> %d", cds_mode); 12079 12080 return rc; 12081 } 12082 12083 }; // namespace qcamera 12084