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_bTNRPreviewOn(false), 787 m_bTNRVideoOn(false), 788 m_bInited(false), 789 m_nBurstNum(1), 790 m_nRetroBurstNum(0), 791 m_nBurstLEDOnPeriod(100), 792 m_bUpdateEffects(false), 793 m_bSceneTransitionAuto(false), 794 m_bPreviewFlipChanged(false), 795 m_bVideoFlipChanged(false), 796 m_bSnapshotFlipChanged(false), 797 m_bFixedFrameRateSet(false), 798 m_bHDREnabled(false), 799 m_bAVTimerEnabled(false), 800 m_bDISEnabled(false), 801 m_MobiMask(0), 802 m_AdjustFPS(NULL), 803 m_bHDR1xFrameEnabled(true), 804 m_HDRSceneEnabled(false), 805 m_bHDRThumbnailProcessNeeded(false), 806 m_bHDR1xExtraBufferNeeded(true), 807 m_bHDROutputCropEnabled(false), 808 m_tempMap(), 809 m_bAFBracketingOn(false), 810 m_bReFocusOn(false), 811 m_bChromaFlashOn(false), 812 m_bOptiZoomOn(false), 813 m_bSceneSelection(false), 814 m_SelectedScene(CAM_SCENE_MODE_MAX), 815 m_bSeeMoreOn(false), 816 m_bStillMoreOn(false), 817 m_bHfrMode(false), 818 m_bSensorHDREnabled(false), 819 m_bRdiMode(false), 820 m_bDisplayFrame(true), 821 m_bSecureMode(false), 822 m_bAeBracketingEnabled(false), 823 mFlashValue(CAM_FLASH_MODE_OFF), 824 mFlashDaemonValue(CAM_FLASH_MODE_OFF), 825 mHfrMode(CAM_HFR_MODE_OFF), 826 m_bHDRModeSensor(true), 827 mOfflineRAW(false), 828 m_bTruePortraitOn(false), 829 mCds_mode(CAM_CDS_MODE_OFF) 830 { 831 char value[PROPERTY_VALUE_MAX]; 832 // TODO: may move to parameter instead of sysprop 833 property_get("persist.debug.sf.showfps", value, "0"); 834 m_bDebugFps = atoi(value) > 0 ? true : false; 835 836 // For thermal mode, it should be set as system property 837 // because system property applies to all applications, while 838 // parameters only apply to specific app. 839 property_get("persist.camera.thermal.mode", value, "fps"); 840 if (!strcmp(value, "frameskip")) { 841 m_ThermalMode = QCAMERA_THERMAL_ADJUST_FRAMESKIP; 842 } else { 843 if (strcmp(value, "fps")) 844 ALOGE("%s: Invalid camera thermal mode %s", __func__, value); 845 m_ThermalMode = QCAMERA_THERMAL_ADJUST_FPS; 846 } 847 848 memset(&m_LiveSnapshotSize, 0, sizeof(m_LiveSnapshotSize)); 849 memset(&m_default_fps_range, 0, sizeof(m_default_fps_range)); 850 memset(&m_hfrFpsRange, 0, sizeof(m_hfrFpsRange)); 851 memset(&m_stillmore_config, 0, sizeof(cam_still_more_t)); 852 memset(&m_captureFrameConfig, 0, sizeof(cam_capture_frame_config_t)); 853 mTotalPPCount = 0; 854 mZoomLevel = 0; 855 mParmZoomLevel = 0; 856 mCurPPCount = 0; 857 mBufBatchCnt = 0; 858 mRotation = 0; 859 mJpegRotation = 0; 860 } 861 862 /*=========================================================================== 863 * FUNCTION : QCameraParameters 864 * 865 * DESCRIPTION: constructor of QCameraParameters 866 * 867 * PARAMETERS : 868 * @params : parameters in string 869 * 870 * RETURN : None 871 *==========================================================================*/ 872 QCameraParameters::QCameraParameters(const String8 ¶ms) 873 : CameraParameters(params), 874 m_reprocScaleParam(this), 875 m_pCapability(NULL), 876 m_pCamOpsTbl(NULL), 877 m_pParamHeap(NULL), 878 m_pParamBuf(NULL), 879 m_bZslMode(false), 880 m_bZslMode_new(false), 881 m_bForceZslMode(false), 882 m_bRecordingHint(false), 883 m_bRecordingHint_new(false), 884 m_bHistogramEnabled(false), 885 m_nFaceProcMask(0), 886 m_bDebugFps(false), 887 mFocusMode(CAM_FOCUS_MODE_MAX), 888 mPreviewFormat(CAM_FORMAT_YUV_420_NV21), 889 mPictureFormat(CAM_FORMAT_JPEG), 890 m_bNeedRestart(false), 891 m_bNoDisplayMode(false), 892 m_bWNROn(false), 893 m_bTNRPreviewOn(false), 894 m_bTNRVideoOn(false), 895 m_bInited(false), 896 m_nBurstNum(1), 897 m_nRetroBurstNum(0), 898 m_nBurstLEDOnPeriod(100), 899 m_bPreviewFlipChanged(false), 900 m_bVideoFlipChanged(false), 901 m_bSnapshotFlipChanged(false), 902 m_bFixedFrameRateSet(false), 903 m_bHDREnabled(false), 904 m_bAVTimerEnabled(false), 905 m_AdjustFPS(NULL), 906 m_bHDR1xFrameEnabled(true), 907 m_HDRSceneEnabled(false), 908 m_bHDRThumbnailProcessNeeded(false), 909 m_bHDR1xExtraBufferNeeded(true), 910 m_bHDROutputCropEnabled(false), 911 m_tempMap(), 912 m_bAFBracketingOn(false), 913 m_bReFocusOn(false), 914 m_bChromaFlashOn(false), 915 m_bOptiZoomOn(false), 916 m_bSceneSelection(false), 917 m_SelectedScene(CAM_SCENE_MODE_MAX), 918 m_bSeeMoreOn(false), 919 m_bStillMoreOn(false), 920 m_bHfrMode(false), 921 m_bSensorHDREnabled(false), 922 m_bRdiMode(false), 923 m_bSecureMode(false), 924 m_bAeBracketingEnabled(false), 925 mFlashValue(CAM_FLASH_MODE_OFF), 926 mFlashDaemonValue(CAM_FLASH_MODE_OFF), 927 mHfrMode(CAM_HFR_MODE_OFF), 928 m_bHDRModeSensor(true), 929 mOfflineRAW(false), 930 m_bTruePortraitOn(false), 931 mCds_mode(CAM_CDS_MODE_OFF), 932 mParmEffect(CAM_EFFECT_MODE_OFF) 933 { 934 memset(&m_LiveSnapshotSize, 0, sizeof(m_LiveSnapshotSize)); 935 memset(&m_default_fps_range, 0, sizeof(m_default_fps_range)); 936 memset(&m_hfrFpsRange, 0, sizeof(m_hfrFpsRange)); 937 memset(&m_stillmore_config, 0, sizeof(cam_still_more_t)); 938 mTotalPPCount = 0; 939 mZoomLevel = 0; 940 mParmZoomLevel = 0; 941 mCurPPCount = 0; 942 mRotation = 0; 943 mJpegRotation = 0; 944 } 945 946 /*=========================================================================== 947 * FUNCTION : ~QCameraParameters 948 * 949 * DESCRIPTION: deconstructor of QCameraParameters 950 * 951 * PARAMETERS : none 952 * 953 * RETURN : None 954 *==========================================================================*/ 955 QCameraParameters::~QCameraParameters() 956 { 957 deinit(); 958 } 959 960 /*=========================================================================== 961 * FUNCTION : createSizesString 962 * 963 * DESCRIPTION: create string obj contains array of dimensions 964 * 965 * PARAMETERS : 966 * @sizes : array of dimensions 967 * @len : size of dimension array 968 * 969 * RETURN : string obj 970 *==========================================================================*/ 971 String8 QCameraParameters::createSizesString(const cam_dimension_t *sizes, size_t len) 972 { 973 String8 str; 974 char buffer[32]; 975 976 if (len > 0) { 977 snprintf(buffer, sizeof(buffer), "%dx%d", sizes[0].width, sizes[0].height); 978 str.append(buffer); 979 } 980 for (size_t i = 1; i < len; i++) { 981 snprintf(buffer, sizeof(buffer), ",%dx%d", 982 sizes[i].width, sizes[i].height); 983 str.append(buffer); 984 } 985 return str; 986 } 987 988 /*=========================================================================== 989 * FUNCTION : createValuesString 990 * 991 * DESCRIPTION: create string obj contains array of values from map when matched 992 * from input values array 993 * 994 * PARAMETERS : 995 * @values : array of values 996 * @len : size of values array 997 * @map : map contains the mapping between values and enums 998 * @map_len : size of the map 999 * 1000 * RETURN : string obj 1001 *==========================================================================*/ 1002 template <typename valuesType, class mapType> String8 createValuesString( 1003 const valuesType *values, size_t len, const mapType *map, size_t map_len) 1004 { 1005 String8 str; 1006 int count = 0; 1007 1008 for (size_t i = 0; i < len; i++ ) { 1009 for (size_t j = 0; j < map_len; j ++) 1010 if (map[j].val == values[i]) { 1011 if (NULL != map[j].desc) { 1012 if (count > 0) { 1013 str.append(","); 1014 } 1015 str.append(map[j].desc); 1016 count++; 1017 break; //loop j 1018 } 1019 } 1020 } 1021 return str; 1022 } 1023 1024 /*=========================================================================== 1025 * FUNCTION : createValuesStringFromMap 1026 * 1027 * DESCRIPTION: create string obj contains array of values directly from map 1028 * 1029 * PARAMETERS : 1030 * @map : map contains the mapping between values and enums 1031 * @map_len : size of the map 1032 * 1033 * RETURN : string obj 1034 *==========================================================================*/ 1035 template <class mapType> String8 createValuesStringFromMap( 1036 const mapType *map, size_t map_len) 1037 { 1038 String8 str; 1039 1040 for (size_t i = 0; i < map_len; i++) { 1041 if (NULL != map[i].desc) { 1042 if (i > 0) { 1043 str.append(","); 1044 } 1045 str.append(map[i].desc); 1046 } 1047 } 1048 return str; 1049 } 1050 1051 /*=========================================================================== 1052 * FUNCTION : createZoomRatioValuesString 1053 * 1054 * DESCRIPTION: create string obj contains array of zoom ratio values 1055 * 1056 * PARAMETERS : 1057 * @zoomRaios : array of zoom ratios 1058 * @length : size of the array 1059 * 1060 * RETURN : string obj 1061 *==========================================================================*/ 1062 String8 QCameraParameters::createZoomRatioValuesString(uint32_t *zoomRatios, 1063 size_t length) 1064 { 1065 String8 str; 1066 char buffer[32] = {0}; 1067 1068 if(length > 0){ 1069 snprintf(buffer, sizeof(buffer), "%d", zoomRatios[0]); 1070 str.append(buffer); 1071 } 1072 1073 for (size_t i = 1; i < length; i++) { 1074 memset(buffer, 0, sizeof(buffer)); 1075 snprintf(buffer, sizeof(buffer), ",%d", zoomRatios[i]); 1076 str.append(buffer); 1077 } 1078 return str; 1079 } 1080 1081 /*=========================================================================== 1082 * FUNCTION : createHfrValuesString 1083 * 1084 * DESCRIPTION: create string obj contains array of hfr values from map when 1085 * matched from input hfr values 1086 * 1087 * PARAMETERS : 1088 * @values : array of hfr info 1089 * @len : size of the array 1090 * @map : map of hfr string value and enum 1091 * map_len : size of map 1092 * 1093 * RETURN : string obj 1094 *==========================================================================*/ 1095 String8 QCameraParameters::createHfrValuesString(const cam_hfr_info_t *values, 1096 size_t len, const QCameraMap<cam_hfr_mode_t> *map, size_t map_len) 1097 { 1098 String8 str; 1099 int count = 0; 1100 1101 char value[PROPERTY_VALUE_MAX]; 1102 int8_t batch_count = 0; 1103 1104 property_get("persist.camera.batchcount", value, "0"); 1105 batch_count = atoi(value); 1106 1107 for (size_t i = 0; i < len; i++ ) { 1108 for (size_t j = 0; j < map_len; j ++) { 1109 if ((batch_count < CAMERA_MIN_BATCH_COUNT) 1110 && (map[j].val > CAM_HFR_MODE_120FPS)) { 1111 /*TODO: Work around. Need to revert when we have 1112 complete 240fps support*/ 1113 break; 1114 } 1115 if (map[j].val == (int)values[i].mode) { 1116 if (NULL != map[j].desc) { 1117 if (count > 0) { 1118 str.append(","); 1119 } 1120 str.append(map[j].desc); 1121 count++; 1122 break; //loop j 1123 } 1124 } 1125 } 1126 } 1127 if (count > 0) { 1128 str.append(","); 1129 } 1130 str.append(VIDEO_HFR_OFF); 1131 return str; 1132 } 1133 1134 /*=========================================================================== 1135 * FUNCTION : createHfrSizesString 1136 * 1137 * DESCRIPTION: create string obj contains array of hfr sizes 1138 * 1139 * PARAMETERS : 1140 * @values : array of hfr info 1141 * @len : size of the array 1142 * 1143 * RETURN : string obj 1144 *==========================================================================*/ 1145 String8 QCameraParameters::createHfrSizesString(const cam_hfr_info_t *values, size_t len) 1146 { 1147 String8 str; 1148 char buffer[32]; 1149 1150 if (len > 0) { 1151 snprintf(buffer, sizeof(buffer), "%dx%d", 1152 values[0].dim.width, values[0].dim.height); 1153 str.append(buffer); 1154 } 1155 for (size_t i = 1; i < len; i++) { 1156 snprintf(buffer, sizeof(buffer), ",%dx%d", 1157 values[i].dim.width, values[i].dim.height); 1158 str.append(buffer); 1159 } 1160 return str; 1161 } 1162 1163 /*=========================================================================== 1164 * FUNCTION : createFpsString 1165 * 1166 * DESCRIPTION: create string obj contains array of FPS rates 1167 * 1168 * PARAMETERS : 1169 * @fps : default fps range 1170 * 1171 * RETURN : string obj 1172 *==========================================================================*/ 1173 String8 QCameraParameters::createFpsString(cam_fps_range_t &fps) 1174 { 1175 char buffer[32]; 1176 String8 fpsValues; 1177 1178 int min_fps = int(fps.min_fps); 1179 int max_fps = int(fps.max_fps); 1180 1181 if (min_fps < fps.min_fps){ 1182 min_fps++; 1183 } 1184 if (max_fps > fps.max_fps) { 1185 max_fps--; 1186 } 1187 if (min_fps <= max_fps) { 1188 snprintf(buffer, sizeof(buffer), "%d", min_fps); 1189 fpsValues.append(buffer); 1190 } 1191 1192 for (int i = min_fps+1; i <= max_fps; i++) { 1193 snprintf(buffer, sizeof(buffer), ",%d", i); 1194 fpsValues.append(buffer); 1195 } 1196 1197 return fpsValues; 1198 } 1199 1200 /*=========================================================================== 1201 * FUNCTION : createFpsRangeString 1202 * 1203 * DESCRIPTION: create string obj contains array of FPS ranges 1204 * 1205 * PARAMETERS : 1206 * @fps : array of fps ranges 1207 * @len : size of the array 1208 * @default_fps_index : reference to index of default fps range 1209 * 1210 * RETURN : string obj 1211 *==========================================================================*/ 1212 String8 QCameraParameters::createFpsRangeString(const cam_fps_range_t* fps, 1213 size_t len, int &default_fps_index) 1214 { 1215 String8 str; 1216 char buffer[32]; 1217 int max_range = 0; 1218 int min_fps, max_fps; 1219 1220 if (len > 0) { 1221 min_fps = int(fps[0].min_fps * 1000); 1222 max_fps = int(fps[0].max_fps * 1000); 1223 max_range = max_fps - min_fps; 1224 default_fps_index = 0; 1225 snprintf(buffer, sizeof(buffer), "(%d,%d)", min_fps, max_fps); 1226 str.append(buffer); 1227 } 1228 for (size_t i = 1; i < len; i++) { 1229 min_fps = int(fps[i].min_fps * 1000); 1230 max_fps = int(fps[i].max_fps * 1000); 1231 if (max_range < (max_fps - min_fps)) { 1232 max_range = max_fps - min_fps; 1233 default_fps_index = (int)i; 1234 } 1235 snprintf(buffer, sizeof(buffer), ",(%d,%d)", min_fps, max_fps); 1236 str.append(buffer); 1237 } 1238 return str; 1239 } 1240 1241 /*=========================================================================== 1242 * FUNCTION : lookupAttr 1243 * 1244 * DESCRIPTION: lookup a value by its name 1245 * 1246 * PARAMETERS : 1247 * @attr : map contains <name, value> 1248 * @len : size of the map 1249 * @name : name to be looked up 1250 * 1251 * RETURN : valid value if found 1252 * NAME_NOT_FOUND if not found 1253 *==========================================================================*/ 1254 template <class mapType> int lookupAttr(const mapType *arr, 1255 size_t len, const char *name) 1256 { 1257 if (name) { 1258 for (size_t i = 0; i < len; i++) { 1259 if (!strcmp(arr[i].desc, name)) 1260 return arr[i].val; 1261 } 1262 } 1263 return NAME_NOT_FOUND; 1264 } 1265 1266 /*=========================================================================== 1267 * FUNCTION : lookupNameByValue 1268 * 1269 * DESCRIPTION: lookup a name by its value 1270 * 1271 * PARAMETERS : 1272 * @attr : map contains <name, value> 1273 * @len : size of the map 1274 * @value : value to be looked up 1275 * 1276 * RETURN : name str or NULL if not found 1277 *==========================================================================*/ 1278 template <class mapType> const char *lookupNameByValue(const mapType *arr, 1279 size_t len, int value) 1280 { 1281 for (size_t i = 0; i < len; i++) { 1282 if (arr[i].val == value) { 1283 return arr[i].desc; 1284 } 1285 } 1286 return NULL; 1287 } 1288 1289 /*=========================================================================== 1290 * FUNCTION : setPreviewSize 1291 * 1292 * DESCRIPTION: set preview size from user setting 1293 * 1294 * PARAMETERS : 1295 * @params : user setting parameters 1296 * 1297 * RETURN : int32_t type of status 1298 * NO_ERROR -- success 1299 * none-zero failure code 1300 *==========================================================================*/ 1301 int32_t QCameraParameters::setPreviewSize(const QCameraParameters& params) 1302 { 1303 int width, height; 1304 params.getPreviewSize(&width, &height); 1305 ALOGI("Requested preview size %d x %d", width, height); 1306 1307 // Validate the preview size 1308 for (size_t i = 0; i < m_pCapability->preview_sizes_tbl_cnt; ++i) { 1309 if (width == m_pCapability->preview_sizes_tbl[i].width 1310 && height == m_pCapability->preview_sizes_tbl[i].height) { 1311 // check if need to restart preview in case of preview size change 1312 int old_width, old_height; 1313 CameraParameters::getPreviewSize(&old_width, &old_height); 1314 if (width != old_width || height != old_height) { 1315 m_bNeedRestart = true; 1316 } 1317 1318 // set the new value 1319 CameraParameters::setPreviewSize(width, height); 1320 return NO_ERROR; 1321 } 1322 } 1323 ALOGE("Invalid preview size requested: %dx%d", width, height); 1324 return BAD_VALUE; 1325 } 1326 1327 /*=========================================================================== 1328 * FUNCTION : setPictureSize 1329 * 1330 * DESCRIPTION: set picture size from user setting 1331 * 1332 * PARAMETERS : 1333 * @params : user setting parameters 1334 * 1335 * RETURN : int32_t type of status 1336 * NO_ERROR -- success 1337 * none-zero failure code 1338 *==========================================================================*/ 1339 int32_t QCameraParameters::setPictureSize(const QCameraParameters& params) 1340 { 1341 int width, height; 1342 params.getPictureSize(&width, &height); 1343 ALOGI("Requested picture size %d x %d", width, height); 1344 1345 // Validate the picture size 1346 if(!m_reprocScaleParam.isScaleEnabled()){ 1347 for (size_t i = 0; i < m_pCapability->picture_sizes_tbl_cnt; ++i) { 1348 if (width == m_pCapability->picture_sizes_tbl[i].width 1349 && height == m_pCapability->picture_sizes_tbl[i].height) { 1350 // check if need to restart preview in case of picture size change 1351 int old_width, old_height; 1352 CameraParameters::getPictureSize(&old_width, &old_height); 1353 if ((m_bZslMode || m_bRecordingHint) && 1354 (width != old_width || height != old_height)) { 1355 m_bNeedRestart = true; 1356 } 1357 1358 // set the new value 1359 CameraParameters::setPictureSize(width, height); 1360 return NO_ERROR; 1361 } 1362 } 1363 }else{ 1364 //should use scaled picture size table to validate 1365 if(m_reprocScaleParam.setValidatePicSize(width, height) == NO_ERROR){ 1366 // check if need to restart preview in case of picture size change 1367 int old_width, old_height; 1368 CameraParameters::getPictureSize(&old_width, &old_height); 1369 if ((m_bZslMode || m_bRecordingHint) && 1370 (width != old_width || height != old_height)) { 1371 m_bNeedRestart = true; 1372 } 1373 1374 // set the new value 1375 char val[32]; 1376 snprintf(val, sizeof(val), "%dx%d", width, height); 1377 updateParamEntry(KEY_PICTURE_SIZE, val); 1378 CDBG("%s: %s", __func__, val); 1379 return NO_ERROR; 1380 } 1381 } 1382 ALOGE("Invalid picture size requested: %dx%d", width, height); 1383 return BAD_VALUE; 1384 } 1385 1386 /*=========================================================================== 1387 * FUNCTION : setVideoSize 1388 * 1389 * DESCRIPTION: set video size from user setting 1390 * 1391 * PARAMETERS : 1392 * @params : user setting parameters 1393 * 1394 * RETURN : int32_t type of status 1395 * NO_ERROR -- success 1396 * none-zero failure code 1397 *==========================================================================*/ 1398 int32_t QCameraParameters::setVideoSize(const QCameraParameters& params) 1399 { 1400 const char *str= NULL; 1401 int width, height; 1402 str = params.get(KEY_VIDEO_SIZE); 1403 if(!str) { 1404 //If application didn't set this parameter string, use the values from 1405 //getPreviewSize() as video dimensions. 1406 params.getPreviewSize(&width, &height); 1407 ALOGE("No Record Size requested, use the preview dimensions"); 1408 } else { 1409 params.getVideoSize(&width, &height); 1410 } 1411 1412 // Validate the video size 1413 for (size_t i = 0; i < m_pCapability->video_sizes_tbl_cnt; ++i) { 1414 if (width == m_pCapability->video_sizes_tbl[i].width 1415 && height == m_pCapability->video_sizes_tbl[i].height) { 1416 // check if need to restart preview in case of video size change 1417 int old_width, old_height; 1418 CameraParameters::getVideoSize(&old_width, &old_height); 1419 if (m_bRecordingHint && 1420 (width != old_width || height != old_height)) { 1421 m_bNeedRestart = true; 1422 } 1423 1424 // set the new value 1425 CameraParameters::setVideoSize(width, height); 1426 return NO_ERROR; 1427 } 1428 } 1429 1430 ALOGE("Invalid video size requested: %dx%d", width, height); 1431 return BAD_VALUE; 1432 } 1433 1434 /*=========================================================================== 1435 * FUNCTION : getLiveSnapshotSize 1436 * 1437 * DESCRIPTION: get live snapshot size 1438 * 1439 * PARAMETERS : dim - Update dim with the liveshot size 1440 * 1441 *==========================================================================*/ 1442 void QCameraParameters::getLiveSnapshotSize(cam_dimension_t &dim) 1443 { 1444 if(is4k2kVideoResolution()) { 1445 // We support maximum 8M liveshot @4K2K video resolution 1446 cam_dimension_t resolution = {0, 0}; 1447 CameraParameters::getVideoSize(&resolution.width, &resolution.height); 1448 if((m_LiveSnapshotSize.width > resolution.width) || 1449 (m_LiveSnapshotSize.height > resolution.height)) { 1450 m_LiveSnapshotSize.width = resolution.width; 1451 m_LiveSnapshotSize.height = resolution.height; 1452 } 1453 } 1454 dim = m_LiveSnapshotSize; 1455 CDBG_HIGH("%s: w x h: %d x %d", __func__, dim.width, dim.height); 1456 } 1457 1458 /*=========================================================================== 1459 * FUNCTION : setLiveSnapshotSize 1460 * 1461 * DESCRIPTION: set live snapshot size 1462 * 1463 * PARAMETERS : 1464 * @params : user setting parameters 1465 * 1466 * RETURN : int32_t type of status 1467 * NO_ERROR -- success 1468 * none-zero failure code 1469 *==========================================================================*/ 1470 int32_t QCameraParameters::setLiveSnapshotSize(const QCameraParameters& params) 1471 { 1472 char value[PROPERTY_VALUE_MAX]; 1473 property_get("persist.camera.opt.livepic", value, "1"); 1474 bool useOptimal = atoi(value) > 0 ? true : false; 1475 1476 // use picture size from user setting 1477 params.getPictureSize(&m_LiveSnapshotSize.width, &m_LiveSnapshotSize.height); 1478 1479 size_t livesnapshot_sizes_tbl_cnt = 1480 m_pCapability->livesnapshot_sizes_tbl_cnt; 1481 cam_dimension_t *livesnapshot_sizes_tbl = 1482 &m_pCapability->livesnapshot_sizes_tbl[0]; 1483 1484 if(is4k2kVideoResolution()) { 1485 // We support maximum 8M liveshot @4K2K video resolution 1486 cam_dimension_t resolution = {0, 0}; 1487 CameraParameters::getVideoSize(&resolution.width, &resolution.height); 1488 if((m_LiveSnapshotSize.width > resolution.width) || 1489 (m_LiveSnapshotSize.height > resolution.height)) { 1490 m_LiveSnapshotSize.width = resolution.width; 1491 m_LiveSnapshotSize.height = resolution.height; 1492 } 1493 } 1494 1495 // check if HFR is enabled 1496 const char *hfrStr = params.get(KEY_QC_VIDEO_HIGH_FRAME_RATE); 1497 cam_hfr_mode_t hfrMode = CAM_HFR_MODE_OFF; 1498 const char *hsrStr = params.get(KEY_QC_VIDEO_HIGH_SPEED_RECORDING); 1499 1500 if ((hsrStr != NULL) && strcmp(hsrStr, "off")) { 1501 int32_t hsr = lookupAttr(HFR_MODES_MAP, PARAM_MAP_SIZE(HFR_MODES_MAP), hsrStr); 1502 if ((hsr != NAME_NOT_FOUND) && (hsr > CAM_HFR_MODE_OFF)) { 1503 // if HSR is enabled, change live snapshot size 1504 for (size_t i = 0; i < m_pCapability->hfr_tbl_cnt; i++) { 1505 if (m_pCapability->hfr_tbl[i].mode == hsr) { 1506 livesnapshot_sizes_tbl_cnt = 1507 m_pCapability->hfr_tbl[i].livesnapshot_sizes_tbl_cnt; 1508 livesnapshot_sizes_tbl = 1509 &m_pCapability->hfr_tbl[i].livesnapshot_sizes_tbl[0]; 1510 hfrMode = m_pCapability->hfr_tbl[i].mode; 1511 break; 1512 } 1513 } 1514 } 1515 } else if ((hfrStr != NULL) && strcmp(hfrStr, "off")) { 1516 int32_t hfr = lookupAttr(HFR_MODES_MAP, PARAM_MAP_SIZE(HFR_MODES_MAP), hfrStr); 1517 if ((hfr != NAME_NOT_FOUND) && (hfr > CAM_HFR_MODE_OFF)) { 1518 // if HFR is enabled, change live snapshot size 1519 for (size_t i = 0; i < m_pCapability->hfr_tbl_cnt; i++) { 1520 if (m_pCapability->hfr_tbl[i].mode == hfr) { 1521 livesnapshot_sizes_tbl_cnt = 1522 m_pCapability->hfr_tbl[i].livesnapshot_sizes_tbl_cnt; 1523 livesnapshot_sizes_tbl = 1524 &m_pCapability->hfr_tbl[i].livesnapshot_sizes_tbl[0]; 1525 hfrMode = m_pCapability->hfr_tbl[i].mode; 1526 break; 1527 } 1528 } 1529 } 1530 } 1531 1532 if (useOptimal || hfrMode != CAM_HFR_MODE_OFF) { 1533 bool found = false; 1534 1535 // first check if picture size is within the list of supported sizes 1536 for (size_t i = 0; i < livesnapshot_sizes_tbl_cnt; ++i) { 1537 if (m_LiveSnapshotSize.width == livesnapshot_sizes_tbl[i].width && 1538 m_LiveSnapshotSize.height == livesnapshot_sizes_tbl[i].height) { 1539 found = true; 1540 break; 1541 } 1542 } 1543 1544 if (!found) { 1545 // use optimal live snapshot size from supported list, 1546 // that has same preview aspect ratio 1547 int width = 0, height = 0; 1548 params.getPreviewSize(&width, &height); 1549 1550 double previewAspectRatio = (double)width / height; 1551 for (size_t i = 0; i < livesnapshot_sizes_tbl_cnt; ++i) { 1552 double ratio = (double)livesnapshot_sizes_tbl[i].width / 1553 livesnapshot_sizes_tbl[i].height; 1554 if (fabs(previewAspectRatio - ratio) <= ASPECT_TOLERANCE) { 1555 m_LiveSnapshotSize = livesnapshot_sizes_tbl[i]; 1556 found = true; 1557 break; 1558 } 1559 } 1560 1561 if (!found && hfrMode != CAM_HFR_MODE_OFF) { 1562 // Cannot find matching aspect ration from supported live snapshot list 1563 // choose the max dim from preview and video size 1564 CDBG("%s: Cannot find matching aspect ratio, choose max of preview or video size", __func__); 1565 params.getVideoSize(&m_LiveSnapshotSize.width, &m_LiveSnapshotSize.height); 1566 if (m_LiveSnapshotSize.width < width && m_LiveSnapshotSize.height < height) { 1567 m_LiveSnapshotSize.width = width; 1568 m_LiveSnapshotSize.height = height; 1569 } 1570 } 1571 } 1572 } 1573 CDBG_HIGH("%s: live snapshot size %d x %d", __func__, 1574 m_LiveSnapshotSize.width, m_LiveSnapshotSize.height); 1575 1576 return NO_ERROR; 1577 } 1578 1579 1580 /*=========================================================================== 1581 * FUNCTION : setRawSize 1582 * 1583 * DESCRIPTION: set live snapshot size 1584 * 1585 * PARAMETERS : 1586 * @params : user setting parameters 1587 * 1588 * RETURN : int32_t type of status 1589 * NO_ERROR -- success 1590 * none-zero failure code 1591 *==========================================================================*/ 1592 int32_t QCameraParameters::setRawSize(cam_dimension_t &dim) 1593 { 1594 m_rawSize = dim; 1595 return NO_ERROR; 1596 } 1597 /*=========================================================================== 1598 * FUNCTION : setPreviewFormat 1599 * 1600 * DESCRIPTION: set preview format from user setting 1601 * 1602 * PARAMETERS : 1603 * @params : user setting parameters 1604 * 1605 * RETURN : int32_t type of status 1606 * NO_ERROR -- success 1607 * none-zero failure code 1608 *==========================================================================*/ 1609 int32_t QCameraParameters::setPreviewFormat(const QCameraParameters& params) 1610 { 1611 const char *str = params.getPreviewFormat(); 1612 int32_t previewFormat = lookupAttr(PREVIEW_FORMATS_MAP, 1613 PARAM_MAP_SIZE(PREVIEW_FORMATS_MAP), str); 1614 if (previewFormat != NAME_NOT_FOUND) { 1615 mPreviewFormat = (cam_format_t)previewFormat; 1616 1617 CameraParameters::setPreviewFormat(str); 1618 CDBG_HIGH("%s: format %d\n", __func__, mPreviewFormat); 1619 return NO_ERROR; 1620 } 1621 ALOGE("Invalid preview format value: %s", (str == NULL) ? "NULL" : str); 1622 return BAD_VALUE; 1623 } 1624 1625 /*=========================================================================== 1626 * FUNCTION : setPictureFormat 1627 * 1628 * DESCRIPTION: set picture format from user setting 1629 * 1630 * PARAMETERS : 1631 * @params : user setting parameters 1632 * 1633 * RETURN : int32_t type of status 1634 * NO_ERROR -- success 1635 * none-zero failure code 1636 *==========================================================================*/ 1637 int32_t QCameraParameters::setPictureFormat(const QCameraParameters& params) 1638 { 1639 const char *str = params.getPictureFormat(); 1640 int32_t pictureFormat = lookupAttr(PICTURE_TYPES_MAP, PARAM_MAP_SIZE(PICTURE_TYPES_MAP), str); 1641 if (pictureFormat != NAME_NOT_FOUND) { 1642 mPictureFormat = pictureFormat; 1643 1644 CameraParameters::setPictureFormat(str); 1645 CDBG_HIGH("%s: format %d\n", __func__, mPictureFormat); 1646 return NO_ERROR; 1647 } 1648 ALOGE("%s: Invalid picture format value: %s", __func__, (str == NULL) ? "NULL" : str); 1649 return BAD_VALUE; 1650 } 1651 1652 /*=========================================================================== 1653 * FUNCTION : setJpegThumbnailSize 1654 * 1655 * DESCRIPTION: set jpeg thumbnail size from user setting 1656 * 1657 * PARAMETERS : 1658 * @params : user setting parameters 1659 * 1660 * RETURN : int32_t type of status 1661 * NO_ERROR -- success 1662 * none-zero failure code 1663 *==========================================================================*/ 1664 int32_t QCameraParameters::setJpegThumbnailSize(const QCameraParameters& params) 1665 { 1666 int width = params.getInt(KEY_JPEG_THUMBNAIL_WIDTH); 1667 int height = params.getInt(KEY_JPEG_THUMBNAIL_HEIGHT); 1668 1669 CDBG("requested jpeg thumbnail size %d x %d", width, height); 1670 1671 size_t sizes_cnt = PARAM_MAP_SIZE(THUMBNAIL_SIZES_MAP); 1672 1673 cam_dimension_t dim; 1674 1675 // While taking livesnaphot match jpeg thumbnail size aspect 1676 // ratio to liveshot size. For normal snapshot match thumbnail 1677 // aspect ratio to picture size. 1678 if (m_bRecordingHint) { 1679 getLiveSnapshotSize(dim); 1680 } else { 1681 params.getPictureSize(&dim.width, &dim.height); 1682 } 1683 1684 if (0 == dim.height) { 1685 ALOGE("%s: picture size is invalid (%d x %d)", __func__, dim.width, dim.height); 1686 return BAD_VALUE; 1687 } 1688 double picAspectRatio = (double)dim.width / (double)dim.height; 1689 1690 int optimalWidth = 0, optimalHeight = 0; 1691 if (width != 0 || height != 0) { 1692 // If input jpeg thumnmail size is (0,0), meaning no thumbnail needed 1693 // hornor this setting. 1694 // Otherwise, search for optimal jpeg thumbnail size that has the same 1695 // aspect ratio as picture size. 1696 // If missign jpeg thumbnail size with appropriate aspect ratio, 1697 // just honor setting supplied by application. 1698 1699 // Try to find a size matches aspect ratio and has the largest width 1700 for (size_t i = 0; i < sizes_cnt; i++) { 1701 if (THUMBNAIL_SIZES_MAP[i].height == 0) { 1702 // No thumbnail case, just skip 1703 continue; 1704 } 1705 double ratio = 1706 (double)THUMBNAIL_SIZES_MAP[i].width / THUMBNAIL_SIZES_MAP[i].height; 1707 if (fabs(ratio - picAspectRatio) > ASPECT_TOLERANCE) { 1708 continue; 1709 } 1710 if (THUMBNAIL_SIZES_MAP[i].width > optimalWidth) { 1711 optimalWidth = THUMBNAIL_SIZES_MAP[i].width; 1712 optimalHeight = THUMBNAIL_SIZES_MAP[i].height; 1713 } 1714 } 1715 1716 if ((0 == optimalWidth) || (0 == optimalHeight)) { 1717 // Optimal size not found 1718 // Validate thumbnail size 1719 for (size_t i = 0; i < sizes_cnt; i++) { 1720 if (width == THUMBNAIL_SIZES_MAP[i].width && 1721 height == THUMBNAIL_SIZES_MAP[i].height) { 1722 optimalWidth = width; 1723 optimalHeight = height; 1724 break; 1725 } 1726 } 1727 } 1728 } 1729 1730 set(KEY_JPEG_THUMBNAIL_WIDTH, optimalWidth); 1731 set(KEY_JPEG_THUMBNAIL_HEIGHT, optimalHeight); 1732 return NO_ERROR; 1733 } 1734 1735 /*=========================================================================== 1736 1737 * FUNCTION : setBurstLEDOnPeriod 1738 * 1739 * DESCRIPTION: set burst LED on period 1740 * 1741 * PARAMETERS : 1742 * @params : user setting parameters 1743 * 1744 * RETURN : int32_t type of status 1745 * NO_ERROR -- success 1746 * none-zero failure code 1747 *==========================================================================*/ 1748 int32_t QCameraParameters::setBurstLEDOnPeriod(const QCameraParameters& params) 1749 { 1750 int nBurstLEDOnPeriod = params.getInt(KEY_QC_SNAPSHOT_BURST_LED_ON_PERIOD); 1751 //Check if the LED ON period is within limits 1752 if ((nBurstLEDOnPeriod <= 0) || (nBurstLEDOnPeriod > 800)) { 1753 // if burst led on period is not set in parameters, 1754 // read from sys prop 1755 char prop[PROPERTY_VALUE_MAX]; 1756 memset(prop, 0, sizeof(prop)); 1757 property_get("persist.camera.led.on.period", prop, "0"); 1758 nBurstLEDOnPeriod = atoi(prop); 1759 if (nBurstLEDOnPeriod <= 0) { 1760 nBurstLEDOnPeriod = 300; 1761 } 1762 } 1763 1764 set(KEY_QC_SNAPSHOT_BURST_LED_ON_PERIOD, nBurstLEDOnPeriod); 1765 m_nBurstLEDOnPeriod = nBurstLEDOnPeriod; 1766 CDBG_HIGH("%s: Burst LED on period %u", __func__, m_nBurstLEDOnPeriod); 1767 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_BURST_LED_ON_PERIOD, 1768 (uint32_t)nBurstLEDOnPeriod)) { 1769 return BAD_VALUE; 1770 } 1771 1772 return NO_ERROR; 1773 } 1774 1775 1776 1777 /*=========================================================================== 1778 * FUNCTION : setRetroActiveBurstNum 1779 * 1780 * DESCRIPTION: set retro active burst num 1781 * 1782 * PARAMETERS : 1783 * @params : user setting parameters 1784 * 1785 * RETURN : int32_t type of status 1786 * NO_ERROR -- success 1787 * none-zero failure code 1788 *==========================================================================*/ 1789 int32_t QCameraParameters::setRetroActiveBurstNum( 1790 const QCameraParameters& params) 1791 { 1792 int32_t nBurstNum = params.getInt(KEY_QC_NUM_RETRO_BURST_PER_SHUTTER); 1793 CDBG_HIGH("%s:[ZSL Retro] m_nRetroBurstNum = %d", __func__, m_nRetroBurstNum); 1794 if (nBurstNum <= 0) { 1795 // if burst number is not set in parameters, 1796 // read from sys prop 1797 char prop[PROPERTY_VALUE_MAX]; 1798 memset(prop, 0, sizeof(prop)); 1799 property_get("persist.camera.retro.number", prop, "0"); 1800 nBurstNum = atoi(prop); 1801 if (nBurstNum < 0) { 1802 nBurstNum = 0; 1803 } 1804 } 1805 1806 set(KEY_QC_NUM_RETRO_BURST_PER_SHUTTER, nBurstNum); 1807 1808 m_nRetroBurstNum = nBurstNum; 1809 CDBG_HIGH("%s: [ZSL Retro] m_nRetroBurstNum = %d", __func__, m_nRetroBurstNum); 1810 return NO_ERROR; 1811 } 1812 1813 /*=========================================================================== 1814 * FUNCTION : setJpegQuality 1815 * 1816 * DESCRIPTION: set jpeg encpding quality from user setting 1817 * 1818 * PARAMETERS : 1819 * @params : user setting parameters 1820 * 1821 * RETURN : int32_t type of status 1822 * NO_ERROR -- success 1823 * none-zero failure code 1824 *==========================================================================*/ 1825 int32_t QCameraParameters::setJpegQuality(const QCameraParameters& params) 1826 { 1827 int32_t rc = NO_ERROR; 1828 int quality = params.getInt(KEY_JPEG_QUALITY); 1829 if (quality >= 0 && quality <= 100) { 1830 set(KEY_JPEG_QUALITY, quality); 1831 } else { 1832 ALOGE("%s: Invalid jpeg quality=%d", __func__, quality); 1833 rc = BAD_VALUE; 1834 } 1835 1836 quality = params.getInt(KEY_JPEG_THUMBNAIL_QUALITY); 1837 if (quality >= 0 && quality <= 100) { 1838 set(KEY_JPEG_THUMBNAIL_QUALITY, quality); 1839 } else { 1840 ALOGE("%s: Invalid jpeg thumbnail quality=%d", __func__, quality); 1841 rc = BAD_VALUE; 1842 } 1843 return rc; 1844 } 1845 1846 /*=========================================================================== 1847 * FUNCTION : setOrientaion 1848 * 1849 * DESCRIPTION: set orientaion from user setting 1850 * 1851 * PARAMETERS : 1852 * @params : user setting parameters 1853 * 1854 * RETURN : int32_t type of status 1855 * NO_ERROR -- success 1856 * none-zero failure code 1857 *==========================================================================*/ 1858 int32_t QCameraParameters::setOrientation(const QCameraParameters& params) 1859 { 1860 const char *str = params.get(KEY_QC_ORIENTATION); 1861 1862 if (str != NULL) { 1863 if (strcmp(str, portrait) == 0 || strcmp(str, landscape) == 0) { 1864 // Camera service needs this to decide if the preview frames and raw 1865 // pictures should be rotated. 1866 set(KEY_QC_ORIENTATION, str); 1867 } else { 1868 ALOGE("%s: Invalid orientation value: %s", __func__, str); 1869 return BAD_VALUE; 1870 } 1871 } 1872 return NO_ERROR; 1873 } 1874 1875 /*=========================================================================== 1876 * FUNCTION : setAutoExposure 1877 * 1878 * DESCRIPTION: set auto exposure value from user setting 1879 * 1880 * PARAMETERS : 1881 * @params : user setting parameters 1882 * 1883 * RETURN : int32_t type of status 1884 * NO_ERROR -- success 1885 * none-zero failure code 1886 *==========================================================================*/ 1887 int32_t QCameraParameters::setAutoExposure(const QCameraParameters& params) 1888 { 1889 const char *str = params.get(KEY_QC_AUTO_EXPOSURE); 1890 const char *prev_str = get(KEY_QC_AUTO_EXPOSURE); 1891 if (str != NULL) { 1892 if (prev_str == NULL || 1893 strcmp(str, prev_str) != 0) { 1894 return setAutoExposure(str); 1895 } 1896 } 1897 return NO_ERROR; 1898 } 1899 1900 /*=========================================================================== 1901 * FUNCTION : setPreviewFpsRange 1902 * 1903 * DESCRIPTION: set preview FPS range from user setting 1904 * 1905 * PARAMETERS : 1906 * @params : user setting parameters 1907 * 1908 * RETURN : int32_t type of status 1909 * NO_ERROR -- success 1910 * none-zero failure code 1911 *==========================================================================*/ 1912 int32_t QCameraParameters::setPreviewFpsRange(const QCameraParameters& params) 1913 { 1914 int minFps,maxFps; 1915 int prevMinFps, prevMaxFps, vidMinFps, vidMaxFps; 1916 int rc = NO_ERROR; 1917 bool found = false, updateNeeded = false; 1918 1919 CameraParameters::getPreviewFpsRange(&prevMinFps, &prevMaxFps); 1920 params.getPreviewFpsRange(&minFps, &maxFps); 1921 1922 CDBG_HIGH("%s: FpsRange Values:(%d, %d)", __func__, prevMinFps, prevMaxFps); 1923 CDBG_HIGH("%s: Requested FpsRange Values:(%d, %d)", __func__, minFps, maxFps); 1924 1925 //first check if we need to change fps because of HFR mode change 1926 updateNeeded = UpdateHFRFrameRate(params); 1927 if (updateNeeded) { 1928 m_bNeedRestart = true; 1929 rc = setHighFrameRate(mHfrMode); 1930 if (rc != NO_ERROR) goto end; 1931 } 1932 CDBG_HIGH("%s: UpdateHFRFrameRate %d", __func__, updateNeeded); 1933 1934 vidMinFps = (int)m_hfrFpsRange.video_min_fps; 1935 vidMaxFps = (int)m_hfrFpsRange.video_max_fps; 1936 1937 if(minFps == prevMinFps && maxFps == prevMaxFps) { 1938 if ( m_bFixedFrameRateSet ) { 1939 minFps = params.getPreviewFrameRate() * 1000; 1940 maxFps = params.getPreviewFrameRate() * 1000; 1941 m_bFixedFrameRateSet = false; 1942 } else if (!updateNeeded) { 1943 CDBG_HIGH("%s: No change in FpsRange", __func__); 1944 rc = NO_ERROR; 1945 goto end; 1946 } 1947 } 1948 for(size_t i = 0; i < m_pCapability->fps_ranges_tbl_cnt; i++) { 1949 // if the value is in the supported list 1950 if (minFps >= m_pCapability->fps_ranges_tbl[i].min_fps * 1000 && 1951 maxFps <= m_pCapability->fps_ranges_tbl[i].max_fps * 1000) { 1952 found = true; 1953 CDBG_HIGH("%s: FPS i=%d : minFps = %d, maxFps = %d" 1954 " vidMinFps = %d, vidMaxFps = %d", 1955 __func__, i, minFps, maxFps, 1956 (int)m_hfrFpsRange.video_min_fps, 1957 (int)m_hfrFpsRange.video_max_fps); 1958 if ((0.0f >= m_hfrFpsRange.video_min_fps) || 1959 (0.0f >= m_hfrFpsRange.video_max_fps)) { 1960 vidMinFps = minFps; 1961 vidMaxFps = maxFps; 1962 } 1963 else { 1964 vidMinFps = (int)m_hfrFpsRange.video_min_fps; 1965 vidMaxFps = (int)m_hfrFpsRange.video_max_fps; 1966 } 1967 1968 setPreviewFpsRange(minFps, maxFps, vidMinFps, vidMaxFps); 1969 break; 1970 } 1971 } 1972 if(found == false){ 1973 ALOGE("%s: error: FPS range value not supported", __func__); 1974 rc = BAD_VALUE; 1975 } 1976 end: 1977 return rc; 1978 } 1979 1980 /*=========================================================================== 1981 * FUNCTION : UpdateHFRFrameRate 1982 * 1983 * DESCRIPTION: set preview FPS range based on HFR setting 1984 * 1985 * PARAMETERS : 1986 * @params : user setting parameters 1987 * 1988 * RETURN : bool true/false 1989 * true -if HAL needs to overwrite FPS range set by app, false otherwise. 1990 *==========================================================================*/ 1991 1992 bool QCameraParameters::UpdateHFRFrameRate(const QCameraParameters& params) 1993 { 1994 bool updateNeeded = false; 1995 int min_fps, max_fps; 1996 int32_t hfrMode = CAM_HFR_MODE_OFF; 1997 int32_t newHfrMode = CAM_HFR_MODE_OFF; 1998 1999 int parm_minfps,parm_maxfps; 2000 int prevMinFps, prevMaxFps; 2001 CameraParameters::getPreviewFpsRange(&prevMinFps, &prevMaxFps); 2002 params.getPreviewFpsRange(&parm_minfps, &parm_maxfps); 2003 CDBG_HIGH("%s: CameraParameters - : minFps = %d, maxFps = %d ", 2004 __func__, prevMinFps, prevMaxFps); 2005 CDBG_HIGH("%s: Requested params - : minFps = %d, maxFps = %d ", 2006 __func__, parm_minfps, parm_maxfps); 2007 2008 const char *hfrStr = params.get(KEY_QC_VIDEO_HIGH_FRAME_RATE); 2009 const char *hsrStr = params.get(KEY_QC_VIDEO_HIGH_SPEED_RECORDING); 2010 2011 const char *prev_hfrStr = CameraParameters::get(KEY_QC_VIDEO_HIGH_FRAME_RATE); 2012 const char *prev_hsrStr = CameraParameters::get(KEY_QC_VIDEO_HIGH_SPEED_RECORDING); 2013 2014 if ((hfrStr != NULL) && (prev_hfrStr != NULL) && strcmp(hfrStr, prev_hfrStr)) { 2015 updateParamEntry(KEY_QC_VIDEO_HIGH_FRAME_RATE, hfrStr); 2016 } 2017 2018 if ((hsrStr != NULL) && (prev_hsrStr != NULL) && strcmp(hsrStr, prev_hsrStr)) { 2019 updateParamEntry(KEY_QC_VIDEO_HIGH_SPEED_RECORDING, hsrStr); 2020 2021 } 2022 2023 // check if HFR is enabled 2024 if ((hfrStr != NULL) && strcmp(hfrStr, "off")) { 2025 hfrMode = lookupAttr(HFR_MODES_MAP, PARAM_MAP_SIZE(HFR_MODES_MAP), hfrStr); 2026 if (NAME_NOT_FOUND != hfrMode) newHfrMode = hfrMode; 2027 } 2028 // check if HSR is enabled 2029 else if ((hsrStr != NULL) && strcmp(hsrStr, "off")) { 2030 hfrMode = lookupAttr(HFR_MODES_MAP, PARAM_MAP_SIZE(HFR_MODES_MAP), hsrStr); 2031 if (NAME_NOT_FOUND != hfrMode) newHfrMode = hfrMode; 2032 } 2033 CDBG_HIGH("%s: prevHfrMode - %d, currentHfrMode = %d ", 2034 __func__, mHfrMode, newHfrMode); 2035 2036 if (mHfrMode != newHfrMode) { 2037 updateNeeded = true; 2038 mHfrMode = newHfrMode; 2039 switch (mHfrMode) { 2040 case CAM_HFR_MODE_60FPS: 2041 min_fps = 60000; 2042 max_fps = 60000; 2043 break; 2044 case CAM_HFR_MODE_90FPS: 2045 min_fps = 90000; 2046 max_fps = 90000; 2047 break; 2048 case CAM_HFR_MODE_120FPS: 2049 min_fps = 120000; 2050 max_fps = 120000; 2051 break; 2052 case CAM_HFR_MODE_150FPS: 2053 min_fps = 150000; 2054 max_fps = 150000; 2055 break; 2056 case CAM_HFR_MODE_180FPS: 2057 min_fps = 180000; 2058 max_fps = 180000; 2059 break; 2060 case CAM_HFR_MODE_210FPS: 2061 min_fps = 210000; 2062 max_fps = 210000; 2063 break; 2064 case CAM_HFR_MODE_240FPS: 2065 min_fps = 240000; 2066 max_fps = 240000; 2067 break; 2068 case CAM_HFR_MODE_480FPS: 2069 min_fps = 480000; 2070 max_fps = 480000; 2071 break; 2072 case CAM_HFR_MODE_OFF: 2073 default: 2074 // Set Video Fps to zero 2075 min_fps = 0; 2076 max_fps = 0; 2077 break; 2078 } 2079 m_hfrFpsRange.video_min_fps = (float)min_fps; 2080 m_hfrFpsRange.video_max_fps = (float)max_fps; 2081 2082 CDBG_HIGH("%s: HFR mode (%d) Set video FPS : minFps = %d, maxFps = %d ", 2083 __func__, mHfrMode, min_fps, max_fps); 2084 } 2085 2086 m_hfrFpsRange.min_fps = (float)parm_minfps; 2087 m_hfrFpsRange.max_fps = (float)parm_maxfps; 2088 2089 // Remember if HFR mode is ON 2090 if ((mHfrMode > CAM_HFR_MODE_OFF) && (mHfrMode < CAM_HFR_MODE_MAX)) { 2091 CDBG_HIGH("HFR mode is ON"); 2092 m_bHfrMode = true; 2093 } else { 2094 m_hfrFpsRange.video_min_fps = 0; 2095 m_hfrFpsRange.video_max_fps = 0; 2096 m_bHfrMode = false; 2097 CDBG_HIGH("HFR mode is OFF"); 2098 } 2099 2100 if (m_bHfrMode && (mHfrMode > CAM_HFR_MODE_120FPS) 2101 && (parm_maxfps != 0)) { 2102 /* Setting Buffer batch count to use batch mode for higher fps*/ 2103 setBufBatchCount((int8_t)(m_hfrFpsRange.video_max_fps / parm_maxfps)); 2104 } 2105 2106 return updateNeeded; 2107 } 2108 2109 /*=========================================================================== 2110 * FUNCTION : setPreviewFrameRate 2111 * 2112 * DESCRIPTION: set preview frame rate from user setting 2113 * 2114 * PARAMETERS : 2115 * @params : user setting parameters 2116 * 2117 * RETURN : int32_t type of status 2118 * NO_ERROR -- success 2119 * none-zero failure code 2120 *==========================================================================*/ 2121 int32_t QCameraParameters::setPreviewFrameRate(const QCameraParameters& params) 2122 { 2123 const char *str = params.get(KEY_PREVIEW_FRAME_RATE); 2124 const char *prev_str = get(KEY_PREVIEW_FRAME_RATE); 2125 2126 if ( str ) { 2127 if ( prev_str && 2128 strcmp(str, prev_str)) { 2129 CDBG("%s: Requested Fixed Frame Rate %s", __func__, str); 2130 updateParamEntry(KEY_PREVIEW_FRAME_RATE, str); 2131 m_bFixedFrameRateSet = true; 2132 } 2133 } 2134 return NO_ERROR; 2135 } 2136 2137 /*=========================================================================== 2138 * FUNCTION : setEffect 2139 * 2140 * DESCRIPTION: set effect value from user setting 2141 * 2142 * PARAMETERS : 2143 * @params : user setting parameters 2144 * 2145 * RETURN : int32_t type of status 2146 * NO_ERROR -- success 2147 * none-zero failure code 2148 *==========================================================================*/ 2149 int32_t QCameraParameters::setEffect(const QCameraParameters& params) 2150 { 2151 const char *str = params.get(KEY_EFFECT); 2152 const char *prev_str = get(KEY_EFFECT); 2153 if (str != NULL) { 2154 if (prev_str == NULL || 2155 strcmp(str, prev_str) != 0 || 2156 m_bUpdateEffects == true ) { 2157 m_bUpdateEffects = false; 2158 return setEffect(str); 2159 } 2160 } 2161 return NO_ERROR; 2162 } 2163 2164 /*=========================================================================== 2165 * FUNCTION : setFocusMode 2166 * 2167 * DESCRIPTION: set focus mode from user setting 2168 * 2169 * PARAMETERS : 2170 * @params : user setting parameters 2171 * 2172 * RETURN : int32_t type of status 2173 * NO_ERROR -- success 2174 * none-zero failure code 2175 *==========================================================================*/ 2176 int32_t QCameraParameters::setFocusMode(const QCameraParameters& params) 2177 { 2178 const char *str = params.get(KEY_FOCUS_MODE); 2179 const char *prev_str = get(KEY_FOCUS_MODE); 2180 if (str != NULL) { 2181 if (prev_str == NULL || 2182 strcmp(str, prev_str) != 0) { 2183 return setFocusMode(str); 2184 } 2185 } 2186 return NO_ERROR; 2187 } 2188 2189 /*=========================================================================== 2190 * FUNCTION : setFocusPosition 2191 * 2192 * DESCRIPTION: set focus position from user setting 2193 * 2194 * PARAMETERS : 2195 * @params : user setting parameters 2196 * 2197 * RETURN : int32_t type of status 2198 * NO_ERROR -- success 2199 * none-zero failure code 2200 *==========================================================================*/ 2201 int32_t QCameraParameters::setFocusPosition(const QCameraParameters& params) 2202 { 2203 const char *focus_str = params.get(KEY_FOCUS_MODE); 2204 2205 if (NULL == focus_str) { 2206 return NO_ERROR; 2207 } 2208 2209 CDBG("%s, current focus mode: %s", __func__, focus_str); 2210 if (strcmp(focus_str, FOCUS_MODE_MANUAL_POSITION)) { 2211 CDBG_HIGH("%s, dont set focus pos to back-end!", __func__); 2212 return NO_ERROR; 2213 } 2214 2215 const char *pos = params.get(KEY_QC_MANUAL_FOCUS_POSITION); 2216 const char *prev_pos = get(KEY_QC_MANUAL_FOCUS_POSITION); 2217 const char *type = params.get(KEY_QC_MANUAL_FOCUS_POS_TYPE); 2218 const char *prev_type = get(KEY_QC_MANUAL_FOCUS_POS_TYPE); 2219 2220 if ((pos != NULL) && (type != NULL)) { 2221 if (prev_pos == NULL || (strcmp(pos, prev_pos) != 0) || 2222 prev_type == NULL || (strcmp(type, prev_type) != 0)) { 2223 return setFocusPosition(type, pos); 2224 } 2225 } 2226 2227 return NO_ERROR; 2228 } 2229 2230 /*=========================================================================== 2231 * FUNCTION : setBrightness 2232 * 2233 * DESCRIPTION: set brightness control value from user setting 2234 * 2235 * PARAMETERS : 2236 * @params : user setting parameters 2237 * 2238 * RETURN : int32_t type of status 2239 * NO_ERROR -- success 2240 * none-zero failure code 2241 *==========================================================================*/ 2242 int32_t QCameraParameters::setBrightness(const QCameraParameters& params) 2243 { 2244 int currentBrightness = getInt(KEY_QC_BRIGHTNESS); 2245 int brightness = params.getInt(KEY_QC_BRIGHTNESS); 2246 2247 if(params.get(KEY_QC_BRIGHTNESS) == NULL) { 2248 CDBG_HIGH("%s: Brigtness not set by App ",__func__); 2249 return NO_ERROR; 2250 } 2251 if (currentBrightness != brightness) { 2252 if (brightness >= m_pCapability->brightness_ctrl.min_value && 2253 brightness <= m_pCapability->brightness_ctrl.max_value) { 2254 CDBG(" new brightness value : %d ", brightness); 2255 return setBrightness(brightness); 2256 } else { 2257 ALOGE("%s: invalid value %d out of (%d, %d)", 2258 __func__, brightness, 2259 m_pCapability->brightness_ctrl.min_value, 2260 m_pCapability->brightness_ctrl.max_value); 2261 return BAD_VALUE; 2262 } 2263 } else { 2264 CDBG("%s: No brightness value changed.", __func__); 2265 return NO_ERROR; 2266 } 2267 } 2268 2269 /*=========================================================================== 2270 * FUNCTION : getBrightness 2271 * 2272 * DESCRIPTION: get brightness control value from user setting 2273 * 2274 * PARAMETERS : 2275 * @params : user setting parameters 2276 * 2277 * RETURN : int32_t type of status 2278 * NO_ERROR -- success 2279 * none-zero failure code 2280 *==========================================================================*/ 2281 int QCameraParameters::getBrightness() 2282 { 2283 return getInt(KEY_QC_BRIGHTNESS); 2284 } 2285 2286 /*=========================================================================== 2287 * FUNCTION : setSharpness 2288 * 2289 * DESCRIPTION: set sharpness control value from user setting 2290 * 2291 * PARAMETERS : 2292 * @params : user setting parameters 2293 * 2294 * RETURN : int32_t type of status 2295 * NO_ERROR -- success 2296 * none-zero failure code 2297 *==========================================================================*/ 2298 int32_t QCameraParameters::setSharpness(const QCameraParameters& params) 2299 { 2300 int shaprness = params.getInt(KEY_QC_SHARPNESS); 2301 int prev_sharp = getInt(KEY_QC_SHARPNESS); 2302 2303 if(params.get(KEY_QC_SHARPNESS) == NULL) { 2304 CDBG_HIGH("%s: Sharpness not set by App ",__func__); 2305 return NO_ERROR; 2306 } 2307 if (prev_sharp != shaprness) { 2308 if((shaprness >= m_pCapability->sharpness_ctrl.min_value) && 2309 (shaprness <= m_pCapability->sharpness_ctrl.max_value)) { 2310 CDBG(" new sharpness value : %d ", shaprness); 2311 return setSharpness(shaprness); 2312 } else { 2313 ALOGE("%s: invalid value %d out of (%d, %d)", 2314 __func__, shaprness, 2315 m_pCapability->sharpness_ctrl.min_value, 2316 m_pCapability->sharpness_ctrl.max_value); 2317 return BAD_VALUE; 2318 } 2319 } else { 2320 CDBG("%s: No value change in shaprness", __func__); 2321 return NO_ERROR; 2322 } 2323 } 2324 2325 /*=========================================================================== 2326 * FUNCTION : setSkintoneEnahancement 2327 * 2328 * DESCRIPTION: set skin tone enhancement factor from user setting 2329 * 2330 * PARAMETERS : 2331 * @params : user setting parameters 2332 * 2333 * RETURN : int32_t type of status 2334 * NO_ERROR -- success 2335 * none-zero failure code 2336 *==========================================================================*/ 2337 int32_t QCameraParameters::setSkinToneEnhancement(const QCameraParameters& params) 2338 { 2339 int sceFactor = params.getInt(KEY_QC_SCE_FACTOR); 2340 int prev_sceFactor = getInt(KEY_QC_SCE_FACTOR); 2341 2342 if(params.get(KEY_QC_SCE_FACTOR) == NULL) { 2343 CDBG_HIGH("%s: Skintone enhancement not set by App ",__func__); 2344 return NO_ERROR; 2345 } 2346 if (prev_sceFactor != sceFactor) { 2347 if((sceFactor >= m_pCapability->sce_ctrl.min_value) && 2348 (sceFactor <= m_pCapability->sce_ctrl.max_value)) { 2349 CDBG(" new Skintone Enhancement value : %d ", sceFactor); 2350 return setSkinToneEnhancement(sceFactor); 2351 } else { 2352 ALOGE("%s: invalid value %d out of (%d, %d)", 2353 __func__, sceFactor, 2354 m_pCapability->sce_ctrl.min_value, 2355 m_pCapability->sce_ctrl.max_value); 2356 return BAD_VALUE; 2357 } 2358 } else { 2359 CDBG("%s: No value change in skintone enhancement factor", __func__); 2360 return NO_ERROR; 2361 } 2362 } 2363 2364 /*=========================================================================== 2365 * FUNCTION : setSaturation 2366 * 2367 * DESCRIPTION: set saturation control value from user setting 2368 * 2369 * PARAMETERS : 2370 * @params : user setting parameters 2371 * 2372 * RETURN : int32_t type of status 2373 * NO_ERROR -- success 2374 * none-zero failure code 2375 *==========================================================================*/ 2376 int32_t QCameraParameters::setSaturation(const QCameraParameters& params) 2377 { 2378 int saturation = params.getInt(KEY_QC_SATURATION); 2379 int prev_sat = getInt(KEY_QC_SATURATION); 2380 2381 if(params.get(KEY_QC_SATURATION) == NULL) { 2382 CDBG_HIGH("%s: Saturation not set by App ",__func__); 2383 return NO_ERROR; 2384 } 2385 if (prev_sat != saturation) { 2386 if((saturation >= m_pCapability->saturation_ctrl.min_value) && 2387 (saturation <= m_pCapability->saturation_ctrl.max_value)) { 2388 CDBG(" new saturation value : %d ", saturation); 2389 return setSaturation(saturation); 2390 } else { 2391 ALOGE("%s: invalid value %d out of (%d, %d)", 2392 __func__, saturation, 2393 m_pCapability->saturation_ctrl.min_value, 2394 m_pCapability->saturation_ctrl.max_value); 2395 return BAD_VALUE; 2396 } 2397 } else { 2398 CDBG("%s: No value change in saturation factor", __func__); 2399 return NO_ERROR; 2400 } 2401 } 2402 2403 /*=========================================================================== 2404 * FUNCTION : setContrast 2405 * 2406 * DESCRIPTION: set contrast control value from user setting 2407 * 2408 * PARAMETERS : 2409 * @params : user setting parameters 2410 * 2411 * RETURN : int32_t type of status 2412 * NO_ERROR -- success 2413 * none-zero failure code 2414 *==========================================================================*/ 2415 int32_t QCameraParameters::setContrast(const QCameraParameters& params) 2416 { 2417 int contrast = params.getInt(KEY_QC_CONTRAST); 2418 int prev_contrast = getInt(KEY_QC_CONTRAST); 2419 2420 if(params.get(KEY_QC_CONTRAST) == NULL) { 2421 CDBG_HIGH("%s: Contrast not set by App ",__func__); 2422 return NO_ERROR; 2423 } 2424 if (prev_contrast != contrast) { 2425 if((contrast >= m_pCapability->contrast_ctrl.min_value) && 2426 (contrast <= m_pCapability->contrast_ctrl.max_value)) { 2427 CDBG(" new contrast value : %d ", contrast); 2428 int32_t rc = setContrast(contrast); 2429 return rc; 2430 } else { 2431 ALOGE("%s: invalid value %d out of (%d, %d)", 2432 __func__, contrast, 2433 m_pCapability->contrast_ctrl.min_value, 2434 m_pCapability->contrast_ctrl.max_value); 2435 return BAD_VALUE; 2436 } 2437 } else { 2438 CDBG("%s: No value change in contrast", __func__); 2439 return NO_ERROR; 2440 } 2441 } 2442 2443 /*=========================================================================== 2444 * FUNCTION : setExposureCompensation 2445 * 2446 * DESCRIPTION: set exposure compensation value from user setting 2447 * 2448 * PARAMETERS : 2449 * @params : user setting parameters 2450 * 2451 * RETURN : int32_t type of status 2452 * NO_ERROR -- success 2453 * none-zero failure code 2454 *==========================================================================*/ 2455 int32_t QCameraParameters::setExposureCompensation(const QCameraParameters & params) 2456 { 2457 int expComp = params.getInt(KEY_EXPOSURE_COMPENSATION); 2458 int prev_expComp = getInt(KEY_EXPOSURE_COMPENSATION); 2459 2460 if(params.get(KEY_EXPOSURE_COMPENSATION) == NULL) { 2461 CDBG_HIGH("%s: Exposure compensation not set by App ",__func__); 2462 return NO_ERROR; 2463 } 2464 if (prev_expComp != expComp) { 2465 if((expComp >= m_pCapability->exposure_compensation_min) && 2466 (expComp <= m_pCapability->exposure_compensation_max)) { 2467 CDBG(" new Exposure Compensation value : %d ", expComp); 2468 return setExposureCompensation(expComp); 2469 } else { 2470 ALOGE("%s: invalid value %d out of (%d, %d)", 2471 __func__, expComp, 2472 m_pCapability->exposure_compensation_min, 2473 m_pCapability->exposure_compensation_max); 2474 return BAD_VALUE; 2475 } 2476 } else { 2477 CDBG("%s: No value change in Exposure Compensation", __func__); 2478 return NO_ERROR; 2479 } 2480 } 2481 2482 /*=========================================================================== 2483 * FUNCTION : setWhiteBalance 2484 * 2485 * DESCRIPTION: set white balance value from user setting 2486 * 2487 * PARAMETERS : 2488 * @params : user setting parameters 2489 * 2490 * RETURN : int32_t type of status 2491 * NO_ERROR -- success 2492 * none-zero failure code 2493 *==========================================================================*/ 2494 int32_t QCameraParameters::setWhiteBalance(const QCameraParameters& params) 2495 { 2496 const char *str = params.get(KEY_WHITE_BALANCE); 2497 const char *prev_str = get(KEY_WHITE_BALANCE); 2498 if (str != NULL) { 2499 if (prev_str == NULL || 2500 strcmp(str, prev_str) != 0) { 2501 return setWhiteBalance(str); 2502 } 2503 } 2504 return NO_ERROR; 2505 } 2506 2507 /*=========================================================================== 2508 * FUNCTION : setManualWhiteBalance 2509 * 2510 * DESCRIPTION: set manual white balance from user setting 2511 * 2512 * PARAMETERS : 2513 * @params : user setting parameters 2514 * 2515 * RETURN : int32_t type of status 2516 * NO_ERROR -- success 2517 * none-zero failure code 2518 *==========================================================================*/ 2519 int32_t QCameraParameters::setManualWhiteBalance(const QCameraParameters& params) 2520 { 2521 int32_t rc = NO_ERROR; 2522 const char *wb_str = params.get(KEY_WHITE_BALANCE); 2523 CDBG("%s, current wb mode: %s", __func__, wb_str); 2524 2525 if (wb_str != NULL) { 2526 if (strcmp(wb_str, WHITE_BALANCE_MANUAL)) { 2527 CDBG("%s, dont set cct to back-end.", __func__); 2528 return NO_ERROR; 2529 } 2530 } 2531 2532 const char *value = params.get(KEY_QC_MANUAL_WB_VALUE); 2533 const char *prev_value = get(KEY_QC_MANUAL_WB_VALUE); 2534 const char *type = params.get(KEY_QC_MANUAL_WB_TYPE); 2535 const char *prev_type = get(KEY_QC_MANUAL_WB_TYPE); 2536 2537 if ((value != NULL) && (type != NULL)) { 2538 if (prev_value == NULL || (strcmp(value, prev_value) != 0) || 2539 prev_type == NULL || (strcmp(type, prev_type) != 0)) { 2540 updateParamEntry(KEY_QC_MANUAL_WB_TYPE, type); 2541 updateParamEntry(KEY_QC_MANUAL_WB_VALUE, value); 2542 int32_t wb_type = atoi(type); 2543 if (wb_type == CAM_MANUAL_WB_MODE_CCT) { 2544 rc = setWBManualCCT(value); 2545 } else if (wb_type == CAM_MANUAL_WB_MODE_GAIN) { 2546 rc = setManualWBGains(value); 2547 } else { 2548 rc = BAD_VALUE; 2549 } 2550 } 2551 } 2552 return rc; 2553 } 2554 2555 /*=========================================================================== 2556 * FUNCTION : setAntibanding 2557 * 2558 * DESCRIPTION: set antibanding value from user setting 2559 * 2560 * PARAMETERS : 2561 * @params : user setting parameters 2562 * 2563 * RETURN : int32_t type of status 2564 * NO_ERROR -- success 2565 * none-zero failure code 2566 *==========================================================================*/ 2567 int32_t QCameraParameters::setAntibanding(const QCameraParameters& params) 2568 { 2569 const char *str = params.get(KEY_ANTIBANDING); 2570 const char *prev_str = get(KEY_ANTIBANDING); 2571 if (str != NULL) { 2572 if (prev_str == NULL || 2573 strcmp(str, prev_str) != 0) { 2574 return setAntibanding(str); 2575 } 2576 } 2577 return NO_ERROR; 2578 } 2579 2580 /*=========================================================================== 2581 * FUNCTION : setStatsDebugMask 2582 * 2583 * DESCRIPTION: get the value from persist file in Stats module that will 2584 * control funtionality in the module 2585 * 2586 * PARAMETERS : none 2587 * 2588 * RETURN : int32_t type of status 2589 * NO_ERROR -- success 2590 * none-zero failure code 2591 *==========================================================================*/ 2592 int32_t QCameraParameters::setStatsDebugMask() 2593 { 2594 uint32_t mask = 0; 2595 char value[PROPERTY_VALUE_MAX]; 2596 2597 property_get("persist.camera.stats.debug.mask", value, "0"); 2598 mask = (uint32_t)atoi(value); 2599 2600 CDBG_HIGH("%s: ctrl mask :%d", __func__, mask); 2601 2602 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_STATS_DEBUG_MASK, mask)) { 2603 return BAD_VALUE; 2604 } 2605 2606 return NO_ERROR; 2607 } 2608 2609 /*=========================================================================== 2610 * FUNCTION : setPAAF 2611 * 2612 * DESCRIPTION: get the value from persist file in Stats module that will 2613 * control the preview assisted AF in the module 2614 * 2615 * PARAMETERS : none 2616 * 2617 * RETURN : int32_t type of status 2618 * NO_ERROR -- success 2619 * none-zero failure code 2620 *==========================================================================*/ 2621 int32_t QCameraParameters::setPAAF() 2622 { 2623 uint32_t paaf = 0; 2624 char value[PROPERTY_VALUE_MAX]; 2625 2626 property_get("persist.camera.stats.af.paaf", value, "1"); 2627 paaf = (uint32_t)atoi(value); 2628 2629 CDBG_HIGH("%s: PAAF is: %s", __func__, paaf ? "ON": "OFF"); 2630 2631 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_STATS_AF_PAAF, paaf)) { 2632 return BAD_VALUE; 2633 } 2634 2635 return NO_ERROR; 2636 } 2637 2638 /*=========================================================================== 2639 * FUNCTION : setSceneDetect 2640 * 2641 * DESCRIPTION: set scenen detect value from user setting 2642 * 2643 * PARAMETERS : 2644 * @params : user setting parameters 2645 * 2646 * RETURN : int32_t type of status 2647 * NO_ERROR -- success 2648 * none-zero failure code 2649 *==========================================================================*/ 2650 int32_t QCameraParameters::setSceneDetect(const QCameraParameters& params) 2651 { 2652 const char *str = params.get(KEY_QC_SCENE_DETECT); 2653 const char *prev_str = get(KEY_QC_SCENE_DETECT); 2654 if (str != NULL) { 2655 if (prev_str == NULL || 2656 strcmp(str, prev_str) != 0) { 2657 return setSceneDetect(str); 2658 } 2659 } 2660 return NO_ERROR; 2661 } 2662 2663 /*=========================================================================== 2664 * FUNCTION : setVideoHDR 2665 * 2666 * DESCRIPTION: set video HDR value from user setting 2667 * 2668 * PARAMETERS : 2669 * @params : user setting parameters 2670 * 2671 * RETURN : int32_t type of status 2672 * NO_ERROR -- success 2673 * none-zero failure code 2674 *==========================================================================*/ 2675 int32_t QCameraParameters::setVideoHDR(const QCameraParameters& params) 2676 { 2677 const char *str = params.get(KEY_QC_VIDEO_HDR); 2678 const char *prev_str = get(KEY_QC_VIDEO_HDR); 2679 if (str != NULL) { 2680 if (prev_str == NULL || 2681 strcmp(str, prev_str) != 0) { 2682 return setVideoHDR(str); 2683 } 2684 } 2685 return NO_ERROR; 2686 } 2687 2688 /*=========================================================================== 2689 * FUNCTION : setVtEnable 2690 * 2691 * DESCRIPTION: set vt Time Stamp enable from user setting 2692 * 2693 * PARAMETERS : 2694 * @params : user setting parameters 2695 * 2696 * RETURN : int32_t type of status 2697 * NO_ERROR -- success 2698 * none-zero failure code 2699 *==========================================================================*/ 2700 int32_t QCameraParameters::setVtEnable(const QCameraParameters& params) 2701 { 2702 const char *str = params.get(KEY_QC_VT_ENABLE); 2703 const char *prev_str = get(KEY_QC_VT_ENABLE); 2704 if (str != NULL) { 2705 if (prev_str == NULL || 2706 strcmp(str, prev_str) != 0) { 2707 return setVtEnable(str); 2708 } 2709 } 2710 return NO_ERROR; 2711 } 2712 2713 /*=========================================================================== 2714 * FUNCTION : setFaceRecognition 2715 * 2716 * DESCRIPTION: set face recognition mode from user setting 2717 * 2718 * PARAMETERS : 2719 * @params : user setting parameters 2720 * 2721 * RETURN : int32_t type of status 2722 * NO_ERROR -- success 2723 * none-zero failure code 2724 *==========================================================================*/ 2725 int32_t QCameraParameters::setFaceRecognition(const QCameraParameters& params) 2726 { 2727 const char *str = params.get(KEY_QC_FACE_RECOGNITION); 2728 const char *prev_str = get(KEY_QC_FACE_RECOGNITION); 2729 if (str != NULL) { 2730 if (prev_str == NULL || 2731 strcmp(str, prev_str) != 0) { 2732 uint32_t maxFaces = (uint32_t)params.getInt(KEY_QC_MAX_NUM_REQUESTED_FACES); 2733 return setFaceRecognition(str, maxFaces); 2734 } 2735 } 2736 return NO_ERROR; 2737 } 2738 2739 /*=========================================================================== 2740 * FUNCTION : setZoom 2741 * 2742 * DESCRIPTION: set zoom value from user setting 2743 * 2744 * PARAMETERS : 2745 * @params : user setting parameters 2746 * 2747 * RETURN : int32_t type of status 2748 * NO_ERROR -- success 2749 * none-zero failure code 2750 *==========================================================================*/ 2751 int32_t QCameraParameters::setZoom(const QCameraParameters& params) 2752 { 2753 if ((m_pCapability->zoom_supported == 0 || 2754 m_pCapability->zoom_ratio_tbl_cnt == 0)) { 2755 CDBG_HIGH("%s: no zoom support", __func__); 2756 return NO_ERROR; 2757 } 2758 2759 int zoomLevel = params.getInt(KEY_ZOOM); 2760 mParmZoomLevel = zoomLevel; 2761 if ((zoomLevel < 0) || (zoomLevel >= (int)m_pCapability->zoom_ratio_tbl_cnt)) { 2762 ALOGE("%s: invalid value %d out of (%d, %d)", 2763 __func__, zoomLevel, 2764 0, m_pCapability->zoom_ratio_tbl_cnt-1); 2765 return BAD_VALUE; 2766 } 2767 2768 int prevZoomLevel = getInt(KEY_ZOOM); 2769 if (prevZoomLevel == zoomLevel) { 2770 CDBG("%s: No value change in zoom %d %d", __func__, prevZoomLevel, zoomLevel); 2771 return NO_ERROR; 2772 } 2773 2774 return setZoom(zoomLevel); 2775 } 2776 2777 /*=========================================================================== 2778 * FUNCTION : setISOValue 2779 * 2780 * DESCRIPTION: set ISO value from user setting 2781 * 2782 * PARAMETERS : 2783 * @params : user setting parameters 2784 * 2785 * RETURN : int32_t type of status 2786 * NO_ERROR -- success 2787 * none-zero failure code 2788 *==========================================================================*/ 2789 int32_t QCameraParameters::setISOValue(const QCameraParameters& params) 2790 { 2791 const char *str = params.get(KEY_QC_ISO_MODE); 2792 const char *prev_str = get(KEY_QC_ISO_MODE); 2793 if (str != NULL) { 2794 if (prev_str == NULL || 2795 strcmp(str, prev_str) != 0) { 2796 return setISOValue(str); 2797 } 2798 } 2799 return NO_ERROR; 2800 } 2801 2802 /*=========================================================================== 2803 * FUNCTION : setContinuousISO 2804 * 2805 * DESCRIPTION: set ISO value from user setting 2806 * 2807 * PARAMETERS : 2808 * @params : user setting parameters 2809 * 2810 * RETURN : int32_t type of status 2811 * NO_ERROR -- success 2812 * none-zero failure code 2813 *==========================================================================*/ 2814 int32_t QCameraParameters::setContinuousISO(const char *isoValue) 2815 { 2816 char iso[PROPERTY_VALUE_MAX]; 2817 int32_t continous_iso = 0; 2818 2819 // Check if continuous ISO is set through setproperty 2820 property_get("persist.camera.continuous.iso", iso, ""); 2821 if (strlen(iso) > 0) { 2822 continous_iso = atoi(iso); 2823 } else { 2824 continous_iso = atoi(isoValue); 2825 } 2826 2827 if ((continous_iso >= 0) && 2828 (continous_iso <= m_pCapability->sensitivity_range.max_sensitivity)) { 2829 CDBG_HIGH("%s: Setting continuous ISO value %d", __func__, continous_iso); 2830 updateParamEntry(KEY_QC_CONTINUOUS_ISO, isoValue); 2831 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_ISO, continous_iso)) { 2832 return BAD_VALUE; 2833 } 2834 return NO_ERROR; 2835 } 2836 ALOGE("Invalid iso value: %d", continous_iso); 2837 return BAD_VALUE; 2838 } 2839 2840 /*=========================================================================== 2841 * FUNCTION : setExposureTime 2842 * 2843 * DESCRIPTION: set exposure time from user setting 2844 * 2845 * PARAMETERS : 2846 * @params : user setting parameters 2847 * 2848 * RETURN : int32_t type of status 2849 * NO_ERROR -- success 2850 * none-zero failure code 2851 *==========================================================================*/ 2852 int32_t QCameraParameters::setExposureTime(const QCameraParameters& params) 2853 { 2854 const char *str = params.get(KEY_QC_EXPOSURE_TIME); 2855 const char *prev_str = get(KEY_QC_EXPOSURE_TIME); 2856 if (str != NULL) { 2857 if (prev_str == NULL || 2858 strcmp(str, prev_str) != 0) { 2859 return setExposureTime(str); 2860 } 2861 } 2862 2863 return NO_ERROR; 2864 } 2865 2866 /*=========================================================================== 2867 * FUNCTION : setVideoRotation 2868 * 2869 * DESCRIPTION: set rotation value from user setting 2870 * 2871 * PARAMETERS : 2872 * @params : user setting parameters 2873 * 2874 * RETURN : int32_t type of status 2875 * NO_ERROR -- success 2876 * none-zero failure code 2877 *==========================================================================*/ 2878 int32_t QCameraParameters::setVideoRotation(const QCameraParameters& params) 2879 { 2880 const char *str = params.get(KEY_QC_VIDEO_ROTATION); 2881 if(str != NULL) { 2882 int value = lookupAttr(VIDEO_ROTATION_MODES_MAP, 2883 PARAM_MAP_SIZE(VIDEO_ROTATION_MODES_MAP), str); 2884 if (value != NAME_NOT_FOUND) { 2885 updateParamEntry(KEY_QC_VIDEO_ROTATION, str); 2886 ALOGV("setVideoRotation: %s: %d: ", str, value); 2887 } else { 2888 ALOGE("Invalid rotation value: %d", value); 2889 return BAD_VALUE; 2890 } 2891 2892 } 2893 return NO_ERROR; 2894 } 2895 2896 /*=========================================================================== 2897 * FUNCTION : setRotation 2898 * 2899 * DESCRIPTION: set rotation value from user setting 2900 * 2901 * PARAMETERS : 2902 * @params : user setting parameters 2903 * 2904 * RETURN : int32_t type of status 2905 * NO_ERROR -- success 2906 * none-zero failure code 2907 *==========================================================================*/ 2908 int32_t QCameraParameters::setRotation(const QCameraParameters& params) 2909 { 2910 int32_t rotation = params.getInt(KEY_ROTATION); 2911 if (rotation != -1) { 2912 if (rotation == 0 || rotation == 90 || 2913 rotation == 180 || rotation == 270) { 2914 set(KEY_ROTATION, rotation); 2915 2916 ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_META_JPEG_ORIENTATION, 2917 rotation); 2918 mRotation = rotation; 2919 } else { 2920 ALOGE("Invalid rotation value: %d", rotation); 2921 return BAD_VALUE; 2922 } 2923 } 2924 return NO_ERROR; 2925 } 2926 2927 /*=========================================================================== 2928 * FUNCTION : setFlash 2929 * 2930 * DESCRIPTION: set flash mode from user setting 2931 * 2932 * PARAMETERS : 2933 * @params : user setting parameters 2934 * 2935 * RETURN : int32_t type of status 2936 * NO_ERROR -- success 2937 * none-zero failure code 2938 *==========================================================================*/ 2939 int32_t QCameraParameters::setFlash(const QCameraParameters& params) 2940 { 2941 const char *str = params.get(KEY_FLASH_MODE); 2942 const char *prev_str = get(KEY_FLASH_MODE); 2943 if (str != NULL) { 2944 if (prev_str == NULL || 2945 strcmp(str, prev_str) != 0) { 2946 return setFlash(str); 2947 } 2948 } 2949 return NO_ERROR; 2950 } 2951 2952 /*=========================================================================== 2953 * FUNCTION : setAecLock 2954 * 2955 * DESCRIPTION: set AEC lock value from user setting 2956 * 2957 * PARAMETERS : 2958 * @params : user setting parameters 2959 * 2960 * RETURN : int32_t type of status 2961 * NO_ERROR -- success 2962 * none-zero failure code 2963 *==========================================================================*/ 2964 int32_t QCameraParameters::setAecLock(const QCameraParameters& params) 2965 { 2966 const char *str = params.get(KEY_AUTO_EXPOSURE_LOCK); 2967 const char *prev_str = get(KEY_AUTO_EXPOSURE_LOCK); 2968 if (str != NULL) { 2969 if (prev_str == NULL || 2970 strcmp(str, prev_str) != 0) { 2971 return setAecLock(str); 2972 } 2973 } 2974 return NO_ERROR; 2975 } 2976 2977 /*=========================================================================== 2978 * FUNCTION : setAwbLock 2979 * 2980 * DESCRIPTION: set AWB lock from user setting 2981 * 2982 * PARAMETERS : 2983 * @params : user setting parameters 2984 * 2985 * RETURN : int32_t type of status 2986 * NO_ERROR -- success 2987 * none-zero failure code 2988 *==========================================================================*/ 2989 int32_t QCameraParameters::setAwbLock(const QCameraParameters& params) 2990 { 2991 const char *str = params.get(KEY_AUTO_WHITEBALANCE_LOCK); 2992 const char *prev_str = get(KEY_AUTO_WHITEBALANCE_LOCK); 2993 if (str != NULL) { 2994 if (prev_str == NULL || 2995 strcmp(str, prev_str) != 0) { 2996 return setAwbLock(str); 2997 } 2998 } 2999 return NO_ERROR; 3000 } 3001 3002 /*=========================================================================== 3003 * FUNCTION : setAutoHDR 3004 * 3005 * DESCRIPTION: Enable/disable auto HDR 3006 * 3007 * PARAMETERS : 3008 * @params : user setting parameters 3009 * 3010 * RETURN : int32_t type of status 3011 * NO_ERROR -- success 3012 * none-zero failure code 3013 *==========================================================================*/ 3014 int32_t QCameraParameters::setAutoHDR(const QCameraParameters& params) 3015 { 3016 const char *str = params.get(KEY_QC_AUTO_HDR_ENABLE); 3017 const char *prev_str = get(KEY_QC_AUTO_HDR_ENABLE); 3018 char prop[PROPERTY_VALUE_MAX]; 3019 3020 memset(prop, 0, sizeof(prop)); 3021 property_get("persist.camera.auto.hdr.enable", prop, VALUE_DISABLE); 3022 if (str != NULL) { 3023 if (prev_str == NULL || 3024 strcmp(str, prev_str) != 0) { 3025 CDBG_HIGH("%s : Auto HDR set to: %s", __func__, str); 3026 return updateParamEntry(KEY_QC_AUTO_HDR_ENABLE, str); 3027 } 3028 } else { 3029 if (prev_str == NULL || 3030 strcmp(prev_str, prop) != 0 ) { 3031 CDBG_HIGH("%s : Auto HDR set to: %s", __func__, prop); 3032 updateParamEntry(KEY_QC_AUTO_HDR_ENABLE, prop); 3033 } 3034 } 3035 3036 return NO_ERROR; 3037 } 3038 3039 /*=========================================================================== 3040 * FUNCTION : isAutoHDREnabled 3041 * 3042 * DESCRIPTION: Query auto HDR status 3043 * 3044 * PARAMETERS : None 3045 * 3046 * RETURN : bool true/false 3047 *==========================================================================*/ 3048 bool QCameraParameters::isAutoHDREnabled() 3049 { 3050 const char *str = get(KEY_QC_AUTO_HDR_ENABLE); 3051 if (str != NULL) { 3052 int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP, 3053 PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP), str); 3054 if (value == NAME_NOT_FOUND) { 3055 ALOGE("%s: Invalid Auto HDR value %s", __func__, str); 3056 return false; 3057 } 3058 3059 CDBG_HIGH("%s : Auto HDR status is: %d", __func__, value); 3060 return value ? true : false; 3061 } 3062 3063 CDBG_HIGH("%s : Auto HDR status not set!", __func__); 3064 return false; 3065 } 3066 3067 /*=========================================================================== 3068 * FUNCTION : setMCEValue 3069 * 3070 * DESCRIPTION: set memory color enhancement value from user setting 3071 * 3072 * PARAMETERS : 3073 * @params : user setting parameters 3074 * 3075 * RETURN : int32_t type of status 3076 * NO_ERROR -- success 3077 * none-zero failure code 3078 *==========================================================================*/ 3079 int32_t QCameraParameters::setMCEValue(const QCameraParameters& params) 3080 { 3081 const char *str = params.get(KEY_QC_MEMORY_COLOR_ENHANCEMENT); 3082 const char *prev_str = get(KEY_QC_MEMORY_COLOR_ENHANCEMENT); 3083 if (str != NULL) { 3084 if (prev_str == NULL || 3085 strcmp(str, prev_str) != 0) { 3086 return setMCEValue(str); 3087 } 3088 } 3089 return NO_ERROR; 3090 } 3091 3092 /*=========================================================================== 3093 * FUNCTION : setDISValue 3094 * 3095 * DESCRIPTION: enable/disable DIS from user setting 3096 * 3097 * PARAMETERS : 3098 * @params : user setting parameters 3099 * 3100 * RETURN : int32_t type of status 3101 * NO_ERROR -- success 3102 * none-zero failure code 3103 *==========================================================================*/ 3104 int32_t QCameraParameters::setDISValue(const QCameraParameters& params) 3105 { 3106 const char *str = params.get(KEY_QC_DIS); 3107 const char *prev_str = get(KEY_QC_DIS); 3108 if (str != NULL) { 3109 if (prev_str == NULL || 3110 strcmp(str, prev_str) != 0) { 3111 return setDISValue(str); 3112 } 3113 } 3114 return NO_ERROR; 3115 } 3116 3117 /*=========================================================================== 3118 * FUNCTION : setLensShadeValue 3119 * 3120 * DESCRIPTION: set lens shade value from user setting 3121 * 3122 * PARAMETERS : 3123 * @params : user setting parameters 3124 * 3125 * RETURN : int32_t type of status 3126 * NO_ERROR -- success 3127 * none-zero failure code 3128 *==========================================================================*/ 3129 int32_t QCameraParameters::setLensShadeValue(const QCameraParameters& params) 3130 { 3131 const char *str = params.get(KEY_QC_LENSSHADE); 3132 const char *prev_str = get(KEY_QC_LENSSHADE); 3133 if (str != NULL) { 3134 if (prev_str == NULL || 3135 strcmp(str, prev_str) != 0) { 3136 return setLensShadeValue(str); 3137 } 3138 } 3139 return NO_ERROR; 3140 } 3141 3142 /*=========================================================================== 3143 * FUNCTION : setFocusAreas 3144 * 3145 * DESCRIPTION: set focus areas from user setting 3146 * 3147 * PARAMETERS : 3148 * @params : user setting parameters 3149 * 3150 * RETURN : int32_t type of status 3151 * NO_ERROR -- success 3152 * none-zero failure code 3153 *==========================================================================*/ 3154 int32_t QCameraParameters::setFocusAreas(const QCameraParameters& params) 3155 { 3156 const char *str = params.get(KEY_FOCUS_AREAS); 3157 if (str != NULL) { 3158 int max_num_af_areas = getInt(KEY_MAX_NUM_FOCUS_AREAS); 3159 if(max_num_af_areas == 0) { 3160 ALOGE("%s: max num of AF area is 0, cannot set focus areas", __func__); 3161 return BAD_VALUE; 3162 } 3163 3164 const char *prev_str = get(KEY_FOCUS_AREAS); 3165 if (prev_str == NULL || 3166 strcmp(str, prev_str) != 0) { 3167 return setFocusAreas(str); 3168 } 3169 } 3170 return NO_ERROR; 3171 } 3172 3173 /*=========================================================================== 3174 * FUNCTION : setMeteringAreas 3175 * 3176 * DESCRIPTION: set metering areas from user setting 3177 * 3178 * PARAMETERS : 3179 * @params : user setting parameters 3180 * 3181 * RETURN : int32_t type of status 3182 * NO_ERROR -- success 3183 * none-zero failure code 3184 *==========================================================================*/ 3185 int32_t QCameraParameters::setMeteringAreas(const QCameraParameters& params) 3186 { 3187 const char *str = params.get(KEY_METERING_AREAS); 3188 if (str != NULL) { 3189 int max_num_mtr_areas = getInt(KEY_MAX_NUM_METERING_AREAS); 3190 if(max_num_mtr_areas == 0) { 3191 ALOGE("%s: max num of metering areas is 0, cannot set focus areas", __func__); 3192 return BAD_VALUE; 3193 } 3194 3195 const char *prev_str = get(KEY_METERING_AREAS); 3196 if (prev_str == NULL || 3197 strcmp(str, prev_str) != 0) { 3198 return setMeteringAreas(str); 3199 } 3200 } 3201 return NO_ERROR; 3202 } 3203 3204 /*=========================================================================== 3205 * FUNCTION : setSceneMode 3206 * 3207 * DESCRIPTION: set scenen mode from user setting 3208 * 3209 * PARAMETERS : 3210 * @params : user setting parameters 3211 * 3212 * RETURN : int32_t type of status 3213 * NO_ERROR -- success 3214 * none-zero failure code 3215 *==========================================================================*/ 3216 int32_t QCameraParameters::setSceneMode(const QCameraParameters& params) 3217 { 3218 const char *str = params.get(KEY_SCENE_MODE); 3219 const char *prev_str = get(KEY_SCENE_MODE); 3220 CDBG_HIGH("%s: str - %s, prev_str - %s",__func__, str, prev_str); 3221 3222 if (str != NULL) { 3223 if (prev_str == NULL || 3224 strcmp(str, prev_str) != 0) { 3225 3226 if(strcmp(str, SCENE_MODE_AUTO) == 0) { 3227 m_bSceneTransitionAuto = true; 3228 } 3229 if (strcmp(str, SCENE_MODE_HDR) == 0) { 3230 3231 // If HDR is set from client and the feature is not enabled in the backend, ignore it. 3232 if (m_bHDRModeSensor) { 3233 m_bSensorHDREnabled = true; 3234 CDBG_HIGH("%s: Sensor HDR mode Enabled",__func__); 3235 } else { 3236 m_bHDREnabled = true; 3237 CDBG_HIGH("%s: S/W HDR Enabled",__func__); 3238 } 3239 } else { 3240 m_bHDREnabled = false; 3241 if (m_bSensorHDREnabled) { 3242 m_bSensorHDREnabled = false; 3243 m_bNeedRestart = true; 3244 setSensorSnapshotHDR("off"); 3245 } 3246 } 3247 3248 if (m_bSensorHDREnabled) { 3249 setSensorSnapshotHDR("on"); 3250 m_bNeedRestart = true; 3251 } else if ((m_bHDREnabled) || 3252 ((prev_str != NULL) && (strcmp(prev_str, SCENE_MODE_HDR) == 0))) { 3253 CDBG_HIGH("%s: scene mode changed between HDR and non-HDR, need restart", __func__); 3254 3255 m_bNeedRestart = true; 3256 } 3257 3258 return setSceneMode(str); 3259 } 3260 } 3261 return NO_ERROR; 3262 } 3263 3264 /*=========================================================================== 3265 * FUNCTION : setSelectableZoneAf 3266 * 3267 * DESCRIPTION: set selectable zone auto focus value from user setting 3268 * 3269 * PARAMETERS : 3270 * @params : user setting parameters 3271 * 3272 * RETURN : int32_t type of status 3273 * NO_ERROR -- success 3274 * none-zero failure code 3275 *==========================================================================*/ 3276 int32_t QCameraParameters::setSelectableZoneAf(const QCameraParameters& params) 3277 { 3278 const char *str = params.get(KEY_QC_SELECTABLE_ZONE_AF); 3279 const char *prev_str = get(KEY_QC_SELECTABLE_ZONE_AF); 3280 if (str != NULL) { 3281 if (prev_str == NULL || 3282 strcmp(str, prev_str) != 0) { 3283 return setSelectableZoneAf(str); 3284 } 3285 } 3286 return NO_ERROR; 3287 } 3288 3289 /*=========================================================================== 3290 * FUNCTION : setAEBracket 3291 * 3292 * DESCRIPTION: set AE bracket from user setting 3293 * 3294 * PARAMETERS : 3295 * @params : user setting parameters 3296 * 3297 * RETURN : int32_t type of status 3298 * NO_ERROR -- success 3299 * none-zero failure code 3300 *==========================================================================*/ 3301 int32_t QCameraParameters::setAEBracket(const QCameraParameters& params) 3302 { 3303 if (isHDREnabled()) { 3304 CDBG_HIGH("%s: scene mode is HDR, overwrite AE bracket setting to off", __func__); 3305 return setAEBracket(AE_BRACKET_OFF); 3306 } 3307 3308 const char *expStr = params.get(KEY_QC_CAPTURE_BURST_EXPOSURE); 3309 if (NULL != expStr && strlen(expStr) > 0) { 3310 set(KEY_QC_CAPTURE_BURST_EXPOSURE, expStr); 3311 } else { 3312 char prop[PROPERTY_VALUE_MAX]; 3313 memset(prop, 0, sizeof(prop)); 3314 property_get("persist.capture.burst.exposures", prop, ""); 3315 if (strlen(prop) > 0) { 3316 set(KEY_QC_CAPTURE_BURST_EXPOSURE, prop); 3317 } else { 3318 remove(KEY_QC_CAPTURE_BURST_EXPOSURE); 3319 } 3320 } 3321 3322 const char *str = params.get(KEY_QC_AE_BRACKET_HDR); 3323 const char *prev_str = get(KEY_QC_AE_BRACKET_HDR); 3324 if (str != NULL) { 3325 if (prev_str == NULL || 3326 strcmp(str, prev_str) != 0) { 3327 return setAEBracket(str); 3328 } 3329 } 3330 return NO_ERROR; 3331 } 3332 3333 /*=========================================================================== 3334 * FUNCTION : setAFBracket 3335 * 3336 * DESCRIPTION: set AF bracket from user setting 3337 * 3338 * PARAMETERS : 3339 * @params : user setting parameters 3340 * 3341 * RETURN : int32_t type of status 3342 * NO_ERROR -- success 3343 * none-zero failure code 3344 *==========================================================================*/ 3345 int32_t QCameraParameters::setAFBracket(const QCameraParameters& params) 3346 { 3347 if ((m_pCapability->qcom_supported_feature_mask & 3348 (CAM_QCOM_FEATURE_REFOCUS | CAM_QCOM_FEATURE_UBIFOCUS)) == 0) { 3349 CDBG_HIGH("%s: AF Bracketing is not supported",__func__); 3350 return NO_ERROR; 3351 } 3352 const char *str = params.get(KEY_QC_AF_BRACKET); 3353 const char *prev_str = get(KEY_QC_AF_BRACKET); 3354 CDBG_HIGH("%s: str =%s & prev_str =%s",__func__, str, prev_str); 3355 if (str != NULL) { 3356 if (prev_str == NULL || 3357 strcmp(str, prev_str) != 0) { 3358 m_bNeedRestart = true; 3359 return setAFBracket(str); 3360 } 3361 } 3362 return NO_ERROR; 3363 } 3364 3365 /*=========================================================================== 3366 * FUNCTION : setReFocus 3367 * 3368 * DESCRIPTION: set refocus from user setting 3369 * 3370 * PARAMETERS : 3371 * @params : user setting parameters 3372 * 3373 * RETURN : int32_t type of status 3374 * NO_ERROR -- success 3375 * none-zero failure code 3376 *==========================================================================*/ 3377 int32_t QCameraParameters::setReFocus(const QCameraParameters& params) 3378 { 3379 if ((m_pCapability->qcom_supported_feature_mask & 3380 (CAM_QCOM_FEATURE_REFOCUS | CAM_QCOM_FEATURE_UBIFOCUS)) == 0) { 3381 ALOGD("%s: AF Bracketing is not supported",__func__); 3382 return NO_ERROR; 3383 } 3384 const char *str = params.get(KEY_QC_RE_FOCUS); 3385 const char *prev_str = get(KEY_QC_RE_FOCUS); 3386 CDBG_HIGH("%s: str =%s & prev_str =%s",__func__, str, prev_str); 3387 if (str != NULL) { 3388 if (prev_str == NULL || 3389 strcmp(str, prev_str) != 0) { 3390 m_bNeedRestart = true; 3391 return setReFocus(str); 3392 } 3393 } 3394 return NO_ERROR; 3395 } 3396 3397 /*=========================================================================== 3398 * FUNCTION : setChromaFlash 3399 * 3400 * DESCRIPTION: set chroma flash from user setting 3401 * 3402 * PARAMETERS : 3403 * @params : user setting parameters 3404 * 3405 * RETURN : int32_t type of status 3406 * NO_ERROR -- success 3407 * none-zero failure code 3408 *==========================================================================*/ 3409 int32_t QCameraParameters::setChromaFlash(const QCameraParameters& params) 3410 { 3411 if ((m_pCapability->qcom_supported_feature_mask & 3412 CAM_QCOM_FEATURE_CHROMA_FLASH) == 0) { 3413 CDBG_HIGH("%s: Chroma Flash is not supported",__func__); 3414 return NO_ERROR; 3415 } 3416 const char *str = params.get(KEY_QC_CHROMA_FLASH); 3417 const char *prev_str = get(KEY_QC_CHROMA_FLASH); 3418 CDBG_HIGH("%s: str =%s & prev_str =%s",__func__, str, prev_str); 3419 if (str != NULL) { 3420 if (prev_str == NULL || 3421 strcmp(str, prev_str) != 0) { 3422 m_bNeedRestart = true; 3423 return setChromaFlash(str); 3424 } 3425 } 3426 return NO_ERROR; 3427 } 3428 3429 /*=========================================================================== 3430 * FUNCTION : setOptiZoom 3431 * 3432 * DESCRIPTION: set opti zoom from user setting 3433 * 3434 * PARAMETERS : 3435 * @params : user setting parameters 3436 * 3437 * RETURN : int32_t type of status 3438 * NO_ERROR -- success 3439 * none-zero failure code 3440 *==========================================================================*/ 3441 int32_t QCameraParameters::setOptiZoom(const QCameraParameters& params) 3442 { 3443 if ((m_pCapability->qcom_supported_feature_mask & 3444 CAM_QCOM_FEATURE_OPTIZOOM) == 0){ 3445 CDBG_HIGH("%s: Opti Zoom is not supported",__func__); 3446 return NO_ERROR; 3447 } 3448 const char *str = params.get(KEY_QC_OPTI_ZOOM); 3449 const char *prev_str = get(KEY_QC_OPTI_ZOOM); 3450 CDBG_HIGH("%s: str =%s & prev_str =%s",__func__, str, prev_str); 3451 if (str != NULL) { 3452 if (prev_str == NULL || 3453 strcmp(str, prev_str) != 0) { 3454 m_bNeedRestart = true; 3455 return setOptiZoom(str); 3456 } 3457 } 3458 return NO_ERROR; 3459 } 3460 3461 /*=========================================================================== 3462 * FUNCTION : setTruePortrait 3463 * 3464 * DESCRIPTION: set true portrait from user setting 3465 * 3466 * PARAMETERS : 3467 * @params : user setting parameters 3468 * 3469 * RETURN : int32_t type of status 3470 * NO_ERROR -- success 3471 * none-zero failure code 3472 *==========================================================================*/ 3473 int32_t QCameraParameters::setTruePortrait(const QCameraParameters& params) 3474 { 3475 if ((m_pCapability->qcom_supported_feature_mask & 3476 CAM_QCOM_FEATURE_TRUEPORTRAIT) == 0) { 3477 CDBG("%s: True Portrait is not supported",__func__); 3478 return NO_ERROR; 3479 } 3480 const char *str = params.get(KEY_QC_TRUE_PORTRAIT); 3481 const char *prev_str = get(KEY_QC_TRUE_PORTRAIT); 3482 CDBG_HIGH("%s: str =%s & prev_str =%s", __func__, str, prev_str); 3483 if (str != NULL) { 3484 if (prev_str == NULL || 3485 strcmp(str, prev_str) != 0) { 3486 return setTruePortrait(str); 3487 } 3488 } 3489 return NO_ERROR; 3490 } 3491 3492 /*=========================================================================== 3493 * FUNCTION : setHDRMode 3494 * 3495 * DESCRIPTION: set HDR mode from user setting 3496 * 3497 * PARAMETERS : 3498 * @params : user setting parameters 3499 * 3500 * RETURN : int32_t type of status 3501 * NO_ERROR -- success 3502 * none-zero failure code 3503 *==========================================================================*/ 3504 int32_t QCameraParameters::setHDRMode(const QCameraParameters& params) 3505 { 3506 const char *str = params.get(KEY_QC_HDR_MODE); 3507 const char *prev_str = get(KEY_QC_HDR_MODE); 3508 uint32_t supported_hdr_modes = m_pCapability->qcom_supported_feature_mask & 3509 (CAM_QCOM_FEATURE_SENSOR_HDR | CAM_QCOM_FEATURE_HDR); 3510 3511 CDBG_HIGH("%s: str =%s & prev_str =%s",__func__, str, prev_str); 3512 if (str != NULL) { 3513 if ((CAM_QCOM_FEATURE_SENSOR_HDR == supported_hdr_modes) && 3514 (strncmp(str, HDR_MODE_SENSOR, strlen(HDR_MODE_SENSOR)))) { 3515 CDBG_HIGH("%s: Only sensor HDR is supported",__func__); 3516 return NO_ERROR; 3517 } else if ((CAM_QCOM_FEATURE_HDR == supported_hdr_modes) && 3518 (strncmp(str, HDR_MODE_SENSOR, strlen(HDR_MODE_MULTI_FRAME)))) { 3519 CDBG_HIGH("%s: Only multi frame HDR is supported",__func__); 3520 return NO_ERROR; 3521 } else if (!supported_hdr_modes) { 3522 CDBG_HIGH("%s: HDR is not supported",__func__); 3523 return NO_ERROR; 3524 } 3525 if (prev_str == NULL || 3526 strcmp(str, prev_str) != 0) { 3527 return setHDRMode(str); 3528 } 3529 } 3530 3531 return NO_ERROR; 3532 } 3533 3534 /*=========================================================================== 3535 * FUNCTION : setHDRNeed1x 3536 * 3537 * DESCRIPTION: set HDR need 1x from user setting 3538 * 3539 * PARAMETERS : 3540 * @params : user setting parameters 3541 * 3542 * RETURN : int32_t type of status 3543 * NO_ERROR -- success 3544 * none-zero failure code 3545 *==========================================================================*/ 3546 int32_t QCameraParameters::setHDRNeed1x(const QCameraParameters& params) 3547 { 3548 const char *str = params.get(KEY_QC_HDR_NEED_1X); 3549 const char *prev_str = get(KEY_QC_HDR_NEED_1X); 3550 3551 CDBG_HIGH("%s: str =%s & prev_str =%s", __func__, str, prev_str); 3552 if (str != NULL) { 3553 if (m_bHDRModeSensor) { 3554 CDBG_HIGH("%s: Only multi frame HDR supports 1x frame",__func__); 3555 return NO_ERROR; 3556 } 3557 if ((prev_str == NULL) || (strcmp(str, prev_str) != 0)) { 3558 return setHDRNeed1x(str); 3559 } 3560 } 3561 return NO_ERROR; 3562 } 3563 3564 /*=========================================================================== 3565 * FUNCTION : setSeeMore 3566 * 3567 * DESCRIPTION: set see more (llvd) from user setting 3568 * 3569 * PARAMETERS : 3570 * @params : user setting parameters 3571 * 3572 * RETURN : int32_t type of status 3573 * NO_ERROR -- success 3574 * none-zero failure code 3575 *==========================================================================*/ 3576 int32_t QCameraParameters::setSeeMore(const QCameraParameters& params) 3577 { 3578 if ((m_pCapability->qcom_supported_feature_mask & 3579 CAM_QCOM_FEATURE_LLVD) == 0) { 3580 CDBG("%s: See more is not supported", __func__); 3581 return NO_ERROR; 3582 } 3583 const char *str = params.get(KEY_QC_SEE_MORE); 3584 const char *prev_str = get(KEY_QC_SEE_MORE); 3585 CDBG_HIGH("%s: str =%s & prev_str =%s", __func__, str, prev_str); 3586 if (str != NULL) { 3587 if (prev_str == NULL || strcmp(str, prev_str) != 0) { 3588 m_bNeedRestart = true; 3589 return setSeeMore(str); 3590 } 3591 } 3592 return NO_ERROR; 3593 } 3594 3595 /*=========================================================================== 3596 * FUNCTION : setStillMore 3597 * 3598 * DESCRIPTION: set stillmore from user setting 3599 * 3600 * PARAMETERS : 3601 * @params : user setting parameters 3602 * 3603 * RETURN : int32_t type of status 3604 * NO_ERROR -- success 3605 * none-zero failure code 3606 *==========================================================================*/ 3607 int32_t QCameraParameters::setStillMore(const QCameraParameters& params) 3608 { 3609 if ((m_pCapability->qcom_supported_feature_mask & 3610 CAM_QCOM_FEATURE_STILLMORE) == 0) { 3611 CDBG("%s: Stillmore is not supported",__func__); 3612 return NO_ERROR; 3613 } 3614 const char *str = params.get(KEY_QC_STILL_MORE); 3615 const char *prev_str = get(KEY_QC_STILL_MORE); 3616 CDBG_HIGH("%s: str =%s & prev_str =%s", __func__, str, prev_str); 3617 if (str != NULL) { 3618 if (prev_str == NULL || strcmp(str, prev_str) != 0) { 3619 m_bNeedRestart = true; 3620 return setStillMore(str); 3621 } 3622 } 3623 return NO_ERROR; 3624 } 3625 3626 /*=========================================================================== 3627 * FUNCTION : setRedeyeReduction 3628 * 3629 * DESCRIPTION: set red eye reduction setting from user setting 3630 * 3631 * PARAMETERS : 3632 * @params : user setting parameters 3633 * 3634 * RETURN : int32_t type of status 3635 * NO_ERROR -- success 3636 * none-zero failure code 3637 *==========================================================================*/ 3638 int32_t QCameraParameters::setRedeyeReduction(const QCameraParameters& params) 3639 { 3640 const char *str = params.get(KEY_QC_REDEYE_REDUCTION); 3641 const char *prev_str = get(KEY_QC_REDEYE_REDUCTION); 3642 if (str != NULL) { 3643 if (prev_str == NULL || 3644 strcmp(str, prev_str) != 0) { 3645 return setRedeyeReduction(str); 3646 } 3647 } 3648 return NO_ERROR; 3649 } 3650 3651 /*=========================================================================== 3652 * FUNCTION : setGpsLocation 3653 * 3654 * DESCRIPTION: set GPS location information from user setting 3655 * 3656 * PARAMETERS : 3657 * @params : user setting parameters 3658 * 3659 * RETURN : int32_t type of status 3660 * NO_ERROR -- success 3661 * none-zero failure code 3662 *==========================================================================*/ 3663 int32_t QCameraParameters::setGpsLocation(const QCameraParameters& params) 3664 { 3665 const char *method = params.get(KEY_GPS_PROCESSING_METHOD); 3666 if (method) { 3667 set(KEY_GPS_PROCESSING_METHOD, method); 3668 }else { 3669 remove(KEY_GPS_PROCESSING_METHOD); 3670 } 3671 3672 const char *latitude = params.get(KEY_GPS_LATITUDE); 3673 if (latitude) { 3674 set(KEY_GPS_LATITUDE, latitude); 3675 }else { 3676 remove(KEY_GPS_LATITUDE); 3677 } 3678 3679 const char *latitudeRef = params.get(KEY_QC_GPS_LATITUDE_REF); 3680 if (latitudeRef) { 3681 set(KEY_QC_GPS_LATITUDE_REF, latitudeRef); 3682 }else { 3683 remove(KEY_QC_GPS_LATITUDE_REF); 3684 } 3685 3686 const char *longitude = params.get(KEY_GPS_LONGITUDE); 3687 if (longitude) { 3688 set(KEY_GPS_LONGITUDE, longitude); 3689 }else { 3690 remove(KEY_GPS_LONGITUDE); 3691 } 3692 3693 const char *longitudeRef = params.get(KEY_QC_GPS_LONGITUDE_REF); 3694 if (longitudeRef) { 3695 set(KEY_QC_GPS_LONGITUDE_REF, longitudeRef); 3696 }else { 3697 remove(KEY_QC_GPS_LONGITUDE_REF); 3698 } 3699 3700 const char *altitudeRef = params.get(KEY_QC_GPS_ALTITUDE_REF); 3701 if (altitudeRef) { 3702 set(KEY_QC_GPS_ALTITUDE_REF, altitudeRef); 3703 }else { 3704 remove(KEY_QC_GPS_ALTITUDE_REF); 3705 } 3706 3707 const char *altitude = params.get(KEY_GPS_ALTITUDE); 3708 if (altitude) { 3709 set(KEY_GPS_ALTITUDE, altitude); 3710 }else { 3711 remove(KEY_GPS_ALTITUDE); 3712 } 3713 3714 const char *status = params.get(KEY_QC_GPS_STATUS); 3715 if (status) { 3716 set(KEY_QC_GPS_STATUS, status); 3717 } else { 3718 remove(KEY_QC_GPS_STATUS); 3719 } 3720 3721 const char *timestamp = params.get(KEY_GPS_TIMESTAMP); 3722 if (timestamp) { 3723 set(KEY_GPS_TIMESTAMP, timestamp); 3724 }else { 3725 remove(KEY_GPS_TIMESTAMP); 3726 } 3727 return NO_ERROR; 3728 } 3729 3730 /*=========================================================================== 3731 * FUNCTION : setNumOfSnapshot 3732 * 3733 * DESCRIPTION: set number of snapshot per shutter from user setting 3734 * 3735 * PARAMETERS : none 3736 * 3737 * RETURN : int32_t type of status 3738 * NO_ERROR -- success 3739 * none-zero failure code 3740 *==========================================================================*/ 3741 int32_t QCameraParameters::setNumOfSnapshot() 3742 { 3743 int nBurstNum = getBurstNum(); 3744 int nExpnum = 0; 3745 3746 const char *bracket_str = get(KEY_QC_AE_BRACKET_HDR); 3747 if (bracket_str != NULL && strlen(bracket_str) > 0) { 3748 int value = lookupAttr(BRACKETING_MODES_MAP, PARAM_MAP_SIZE(BRACKETING_MODES_MAP), 3749 bracket_str); 3750 switch (value) { 3751 case CAM_EXP_BRACKETING_ON: 3752 { 3753 nExpnum = 0; 3754 const char *str_val = get(KEY_QC_CAPTURE_BURST_EXPOSURE); 3755 if ((str_val != NULL) && (strlen(str_val) > 0)) { 3756 char prop[PROPERTY_VALUE_MAX]; 3757 memset(prop, 0, sizeof(prop)); 3758 strlcpy(prop, str_val, PROPERTY_VALUE_MAX); 3759 char *saveptr = NULL; 3760 char *token = strtok_r(prop, ",", &saveptr); 3761 while (token != NULL) { 3762 token = strtok_r(NULL, ",", &saveptr); 3763 nExpnum++; 3764 } 3765 } 3766 if (nExpnum == 0) { 3767 nExpnum = 1; 3768 } 3769 } 3770 break; 3771 default: 3772 nExpnum = 1 + getNumOfExtraHDROutBufsIfNeeded(); 3773 break; 3774 } 3775 } 3776 3777 if (isUbiRefocus()) { 3778 nBurstNum = m_pCapability->refocus_af_bracketing_need.output_count + 1; 3779 } 3780 3781 CDBG_HIGH("%s: nBurstNum = %d, nExpnum = %d", __func__, nBurstNum, nExpnum); 3782 set(KEY_QC_NUM_SNAPSHOT_PER_SHUTTER, nBurstNum * nExpnum); 3783 return NO_ERROR; 3784 } 3785 3786 /*=========================================================================== 3787 * FUNCTION : setRecordingHint 3788 * 3789 * DESCRIPTION: set recording hint value from user setting 3790 * 3791 * PARAMETERS : 3792 * @params : user setting parameters 3793 * 3794 * RETURN : int32_t type of status 3795 * NO_ERROR -- success 3796 * none-zero failure code 3797 *==========================================================================*/ 3798 int32_t QCameraParameters::setRecordingHint(const QCameraParameters& params) 3799 { 3800 const char * str = params.get(KEY_RECORDING_HINT); 3801 const char *prev_str = get(KEY_RECORDING_HINT); 3802 if (str != NULL) { 3803 if (prev_str == NULL || strcmp(str, prev_str) != 0) { 3804 int32_t value = lookupAttr(TRUE_FALSE_MODES_MAP, PARAM_MAP_SIZE(TRUE_FALSE_MODES_MAP), 3805 str); 3806 if(value != NAME_NOT_FOUND){ 3807 updateParamEntry(KEY_RECORDING_HINT, str); 3808 setRecordingHintValue(value); 3809 if (getFaceDetectionOption() == true) { 3810 setFaceDetection(value > 0 ? false : true, false); 3811 } 3812 if (m_bDISEnabled) { 3813 CDBG_HIGH("%s: %d: Setting DIS value again", __func__, __LINE__); 3814 setDISValue(VALUE_ENABLE); 3815 } 3816 return NO_ERROR; 3817 } else { 3818 ALOGE("Invalid recording hint value: %s", str); 3819 return BAD_VALUE; 3820 } 3821 } 3822 } 3823 return NO_ERROR; 3824 } 3825 3826 /*=========================================================================== 3827 * FUNCTION : setNoDisplayMode 3828 * 3829 * DESCRIPTION: set no display mode from user setting 3830 * 3831 * PARAMETERS : 3832 * @params : user setting parameters 3833 * 3834 * RETURN : int32_t type of status 3835 * NO_ERROR -- success 3836 * none-zero failure code 3837 *==========================================================================*/ 3838 int32_t QCameraParameters::setNoDisplayMode(const QCameraParameters& params) 3839 { 3840 const char *str_val = params.get(KEY_QC_NO_DISPLAY_MODE); 3841 const char *prev_str = get(KEY_QC_NO_DISPLAY_MODE); 3842 char prop[PROPERTY_VALUE_MAX]; 3843 3844 if(str_val && strlen(str_val) > 0) { 3845 if (prev_str == NULL || strcmp(str_val, prev_str) != 0) { 3846 m_bNoDisplayMode = atoi(str_val); 3847 set(KEY_QC_NO_DISPLAY_MODE, str_val); 3848 m_bNeedRestart = true; 3849 } 3850 } else { 3851 memset(prop, 0, sizeof(prop)); 3852 property_get("persist.camera.no-display", prop, "0"); 3853 m_bNoDisplayMode = atoi(prop); 3854 } 3855 CDBG_HIGH("Param m_bNoDisplayMode = %d", m_bNoDisplayMode); 3856 return NO_ERROR; 3857 } 3858 3859 /*=========================================================================== 3860 * FUNCTION : setZslMode 3861 * 3862 * DESCRIPTION: set ZSL mode from user setting 3863 * 3864 * PARAMETERS : 3865 * @params : user setting parameters 3866 * 3867 * RETURN : int32_t type of status 3868 * NO_ERROR -- success 3869 * none-zero failure code 3870 *==========================================================================*/ 3871 int32_t QCameraParameters::setZslMode(const QCameraParameters& params) 3872 { 3873 const char *str_val = params.get(KEY_QC_ZSL); 3874 const char *prev_val = get(KEY_QC_ZSL); 3875 int32_t rc = NO_ERROR; 3876 3877 if(m_bForceZslMode && !m_bZslMode) { 3878 // Force ZSL mode to ON 3879 set(KEY_QC_ZSL, VALUE_ON); 3880 m_bZslMode_new = true; 3881 m_bZslMode = true; 3882 m_bNeedRestart = true; 3883 int32_t value = m_bForceZslMode; 3884 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_ZSL_MODE, value)) { 3885 rc = BAD_VALUE; 3886 } 3887 } else if (str_val != NULL) { 3888 if (prev_val == NULL || strcmp(str_val, prev_val) != 0) { 3889 int32_t value = lookupAttr(ON_OFF_MODES_MAP, PARAM_MAP_SIZE(ON_OFF_MODES_MAP), 3890 str_val); 3891 if (value != NAME_NOT_FOUND) { 3892 set(KEY_QC_ZSL, str_val); 3893 m_bZslMode_new = (value > 0)? true : false; 3894 3895 // ZSL mode changed, need restart preview 3896 m_bNeedRestart = true; 3897 3898 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_ZSL_MODE, value)) { 3899 rc = BAD_VALUE; 3900 } 3901 } else { 3902 ALOGE("Invalid ZSL mode value: %s", str_val); 3903 rc = BAD_VALUE; 3904 } 3905 } 3906 } 3907 ALOGI("%s: enabled: %d", __func__, m_bZslMode_new); 3908 return rc; 3909 } 3910 3911 /*=========================================================================== 3912 * FUNCTION : setWaveletDenoise 3913 * 3914 * DESCRIPTION: set wavelet denoise value from user setting 3915 * 3916 * PARAMETERS : 3917 * @params : user setting parameters 3918 * 3919 * RETURN : int32_t type of status 3920 * NO_ERROR -- success 3921 * none-zero failure code 3922 *==========================================================================*/ 3923 int32_t QCameraParameters::setWaveletDenoise(const QCameraParameters& params) 3924 { 3925 const char *str_pf = params.getPictureFormat(); 3926 int32_t pictureFormat = lookupAttr(PICTURE_TYPES_MAP, PARAM_MAP_SIZE(PICTURE_TYPES_MAP), 3927 str_pf); 3928 if (pictureFormat != NAME_NOT_FOUND) { 3929 if (CAM_FORMAT_YUV_422_NV16 == pictureFormat) { 3930 ALOGE("NV16 format isn't supported in denoise lib!"); 3931 return setWaveletDenoise(DENOISE_OFF); 3932 } 3933 } 3934 const char *str = params.get(KEY_QC_DENOISE); 3935 const char *prev_str = get(KEY_QC_DENOISE); 3936 if (str != NULL) { 3937 if (prev_str == NULL || 3938 strcmp(str, prev_str) != 0) { 3939 return setWaveletDenoise(str); 3940 } 3941 } 3942 return NO_ERROR; 3943 } 3944 3945 /*=========================================================================== 3946 * FUNCTION : setTemporalDenoise 3947 * 3948 * DESCRIPTION: set temporal denoise value from properties 3949 * 3950 * PARAMETERS : none 3951 * 3952 * RETURN : int32_t type of status 3953 * NO_ERROR -- success 3954 * none-zero failure code 3955 *==========================================================================*/ 3956 int32_t QCameraParameters::setTemporalDenoise(const QCameraParameters& params) 3957 { 3958 if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_CPP_TNR) == 0) { 3959 CDBG_HIGH("%s: TNR is not supported",__func__); 3960 return NO_ERROR; 3961 } 3962 const char *str = params.get(KEY_QC_TNR_MODE); 3963 const char *prev_str = get(KEY_QC_TNR_MODE); 3964 const char *video_str = params.get(KEY_QC_VIDEO_TNR_MODE); 3965 const char *video_prev_str = get(KEY_QC_VIDEO_TNR_MODE); 3966 3967 if (m_bRecordingHint_new == true) { 3968 if (video_str) { 3969 if ((video_prev_str == NULL) || (strcmp(video_str, video_prev_str) != 0)) { 3970 if (!strcmp(video_str, VALUE_ON)) { 3971 m_bTNRVideoOn = true; 3972 m_bTNRPreviewOn = true; 3973 } else { 3974 m_bTNRVideoOn = false; 3975 m_bTNRPreviewOn = false; 3976 } 3977 updateParamEntry(KEY_QC_VIDEO_TNR_MODE, video_str); 3978 } else { 3979 return NO_ERROR; 3980 } 3981 } else { 3982 char video_value[PROPERTY_VALUE_MAX]; 3983 memset(video_value, 0, sizeof(video_value)); 3984 property_get("persist.camera.tnr.video", video_value, VALUE_OFF); 3985 if (!strcmp(video_value, VALUE_ON)) { 3986 m_bTNRVideoOn = true; 3987 } else { 3988 m_bTNRVideoOn = false; 3989 } 3990 updateParamEntry(KEY_QC_VIDEO_TNR_MODE, video_value); 3991 3992 char preview_value[PROPERTY_VALUE_MAX]; 3993 memset(preview_value, 0, sizeof(preview_value)); 3994 property_get("persist.camera.tnr.preview", preview_value, video_value); 3995 if (!strcmp(preview_value, VALUE_ON)) { 3996 m_bTNRPreviewOn = true; 3997 } else { 3998 m_bTNRPreviewOn = false; 3999 } 4000 updateParamEntry(KEY_QC_TNR_MODE, preview_value); 4001 } 4002 4003 cam_denoise_param_t temp; 4004 memset(&temp, 0, sizeof(temp)); 4005 if (m_bTNRVideoOn || m_bTNRPreviewOn) { 4006 temp.denoise_enable = 1; 4007 temp.process_plates = getDenoiseProcessPlate(CAM_INTF_PARM_TEMPORAL_DENOISE); 4008 4009 int32_t cds_mode = lookupAttr(CDS_MODES_MAP, PARAM_MAP_SIZE(CDS_MODES_MAP), 4010 CDS_MODE_OFF); 4011 4012 if (cds_mode != NAME_NOT_FOUND) { 4013 updateParamEntry(KEY_QC_VIDEO_CDS_MODE, CDS_MODE_OFF); 4014 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_CDS_MODE, cds_mode)) { 4015 ALOGE("%s:Failed CDS MODE to update table", __func__); 4016 return BAD_VALUE; 4017 } 4018 CDBG("%s: CDS in video mode is set to = %s when TNR is enabled", 4019 __func__, CDS_MODE_OFF); 4020 mCds_mode = cds_mode; 4021 } else { 4022 ALOGE("%s: Invalid argument for video CDS MODE %d", __func__, cds_mode); 4023 } 4024 } 4025 CDBG("%s: TNR enable in video mode = %d, plates = %d", __func__, 4026 temp.denoise_enable, temp.process_plates); 4027 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_TEMPORAL_DENOISE, temp)) { 4028 return BAD_VALUE; 4029 } 4030 } else { 4031 if (str) { 4032 if ((prev_str == NULL) || (strcmp(str, prev_str) != 0)) { 4033 if (!strcmp(str, VALUE_ON)) { 4034 m_bTNRPreviewOn = true; 4035 } else { 4036 m_bTNRPreviewOn = false; 4037 } 4038 updateParamEntry(KEY_QC_TNR_MODE, str); 4039 } else { 4040 return NO_ERROR; 4041 } 4042 } else { 4043 char value[PROPERTY_VALUE_MAX]; 4044 memset(value, 0, sizeof(value)); 4045 property_get("persist.camera.tnr.preview", value, VALUE_OFF); 4046 if (!strcmp(value, VALUE_ON)) { 4047 m_bTNRPreviewOn = true; 4048 } else { 4049 m_bTNRPreviewOn = false; 4050 } 4051 updateParamEntry(KEY_QC_TNR_MODE, value); 4052 } 4053 cam_denoise_param_t temp; 4054 memset(&temp, 0, sizeof(temp)); 4055 if (m_bTNRPreviewOn) { 4056 temp.denoise_enable = 1; 4057 temp.process_plates = getDenoiseProcessPlate(CAM_INTF_PARM_TEMPORAL_DENOISE); 4058 4059 int32_t cds_mode = lookupAttr(CDS_MODES_MAP, PARAM_MAP_SIZE(CDS_MODES_MAP), 4060 CDS_MODE_OFF); 4061 4062 if (cds_mode != NAME_NOT_FOUND) { 4063 updateParamEntry(KEY_QC_CDS_MODE, CDS_MODE_OFF); 4064 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_CDS_MODE, cds_mode)) { 4065 ALOGE("%s:Failed CDS MODE to update table", __func__); 4066 return BAD_VALUE; 4067 } 4068 CDBG("%s: CDS in snapshot mode is set to = %s when TNR is enabled", 4069 __func__, CDS_MODE_OFF); 4070 mCds_mode = cds_mode; 4071 } else { 4072 ALOGE("%s: Invalid argument for snapshot CDS MODE %d", __func__, cds_mode); 4073 } 4074 } 4075 CDBG("%s: TNR enable in snapshot mode = %d, plates = %d", __func__, 4076 temp.denoise_enable, temp.process_plates); 4077 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_TEMPORAL_DENOISE, temp)) { 4078 return BAD_VALUE; 4079 } 4080 } 4081 4082 return NO_ERROR; 4083 } 4084 4085 /*=========================================================================== 4086 * FUNCTION : setCameraMode 4087 * 4088 * DESCRIPTION: set camera mode from user setting 4089 * 4090 * PARAMETERS : 4091 * @params : user setting parameters 4092 * 4093 * RETURN : int32_t type of status 4094 * NO_ERROR -- success 4095 * none-zero failure code 4096 *==========================================================================*/ 4097 int32_t QCameraParameters::setCameraMode(const QCameraParameters& params) 4098 { 4099 const char *str = params.get(KEY_QC_CAMERA_MODE); 4100 if (str != NULL) { 4101 set(KEY_QC_CAMERA_MODE, str); 4102 } else { 4103 remove(KEY_QC_CAMERA_MODE); 4104 } 4105 return NO_ERROR; 4106 } 4107 4108 /*=========================================================================== 4109 * FUNCTION : setSceneSelectionMode 4110 * 4111 * DESCRIPTION: set scene selection mode from user setting 4112 * 4113 * PARAMETERS : 4114 * @params : user setting parameters 4115 * 4116 * RETURN : int32_t type of status 4117 * NO_ERROR -- success 4118 * none-zero failure code 4119 *==========================================================================*/ 4120 int32_t QCameraParameters::setSceneSelectionMode(const QCameraParameters& params) 4121 { 4122 const char *str = params.get(KEY_QC_SCENE_SELECTION); 4123 const char *prev_str = get(KEY_QC_SCENE_SELECTION); 4124 if (NULL != str) { 4125 if ((NULL == prev_str) || (strcmp(str, prev_str) != 0)) { 4126 int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP, 4127 PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP), str); 4128 if (value != NAME_NOT_FOUND) { 4129 ALOGD("%s: Setting selection value %s", __func__, str); 4130 if (value && m_bZslMode_new) { 4131 updateParamEntry(KEY_QC_SCENE_SELECTION, str); 4132 m_bNeedRestart = true; 4133 m_bSceneSelection = true; 4134 } else if (!value) { 4135 updateParamEntry(KEY_QC_SCENE_SELECTION, str); 4136 m_bNeedRestart = true; 4137 m_bSceneSelection = false; 4138 } else { 4139 ALOGE("%s: Trying to enable scene selection in non ZSL mode!!!", 4140 __func__); 4141 return BAD_VALUE; 4142 } 4143 } else { 4144 ALOGE("%s: Trying to configure invalid scene selection value: %s", 4145 __func__, 4146 str); 4147 return BAD_VALUE; 4148 } 4149 } 4150 } 4151 4152 return NO_ERROR; 4153 } 4154 4155 /*=========================================================================== 4156 * FUNCTION : setSelectedScene 4157 * 4158 * DESCRIPTION: select specific scene 4159 * 4160 * PARAMETERS : 4161 * @scene : scene mode 4162 * 4163 * RETURN : int32_t type of status 4164 * NO_ERROR -- success 4165 * none-zero failure code 4166 *==========================================================================*/ 4167 int32_t QCameraParameters::setSelectedScene(cam_scene_mode_type scene) 4168 { 4169 Mutex::Autolock l(m_SceneSelectLock); 4170 m_SelectedScene = scene; 4171 return NO_ERROR; 4172 } 4173 4174 /*=========================================================================== 4175 * FUNCTION : getSelectedScene 4176 * 4177 * DESCRIPTION: get selected scene 4178 * 4179 * PARAMETERS : 4180 * 4181 * RETURN : currently selected scene 4182 *==========================================================================*/ 4183 cam_scene_mode_type QCameraParameters::getSelectedScene() 4184 { 4185 Mutex::Autolock l(m_SceneSelectLock); 4186 return m_SelectedScene; 4187 } 4188 4189 /*========================================================== 4190 * FUNCTION : setRdiMode 4191 * 4192 * DESCRIPTION: set Rdi mode from user setting 4193 * 4194 * PARAMETERS : 4195 * @params : user setting parameters 4196 * 4197 * RETURN : int32_t type of status 4198 * NO_ERROR -- success 4199 * none-zero failure code 4200 *===========================================================*/ 4201 int32_t QCameraParameters::setRdiMode(const QCameraParameters& params) 4202 { 4203 const char *str = params.get(KEY_QC_RDI_MODE); 4204 const char *prev_str = get(KEY_QC_RDI_MODE); 4205 char prop[PROPERTY_VALUE_MAX]; 4206 memset(prop, 0, sizeof(prop)); 4207 4208 property_get("persist.camera.rdi.mode", prop, VALUE_DISABLE); 4209 if ((str != NULL) && (prev_str == NULL || strcmp(str, prev_str) != 0)) { 4210 ALOGD("%s:%d : RDI mode set to %s", __func__, __LINE__, str); 4211 setRdiMode(str); 4212 } else if (prev_str == NULL || strcmp(prev_str, prop) != 0 ) { 4213 ALOGD("%s:%d : RDI mode set to prop: %s", __func__, __LINE__, prop); 4214 setRdiMode(prop); 4215 } 4216 return NO_ERROR; 4217 } 4218 4219 /*========================================================== 4220 * FUNCTION : setSecureMode 4221 * 4222 * DESCRIPTION: set secure mode from user setting 4223 * 4224 * PARAMETERS : 4225 * @params : user setting parameters 4226 * 4227 * RETURN : int32_t type of status 4228 * NO_ERROR -- success 4229 * none-zero failure code 4230 *===========================================================*/ 4231 4232 int32_t QCameraParameters::setSecureMode(const QCameraParameters& params) 4233 { 4234 const char *str = params.get(KEY_QC_SECURE_MODE); 4235 const char *prev_str = get(KEY_QC_SECURE_MODE); 4236 char prop[PROPERTY_VALUE_MAX]; 4237 memset(prop, 0, sizeof(prop)); 4238 4239 property_get("persist.camera.secure.mode", prop, VALUE_DISABLE); 4240 if ((str != NULL) && (prev_str == NULL || strcmp(str, prev_str) != 0)) { 4241 ALOGD("%s : Secure mode set to KEY: %s", __func__, str); 4242 setSecureMode(str); 4243 } else if (prev_str == NULL || strcmp(prev_str, prop) != 0 ) { 4244 ALOGD("%s : Secure mode set to prop: %s", __func__, prop); 4245 setSecureMode(prop); 4246 } 4247 return NO_ERROR; 4248 } 4249 4250 /*=========================================================================== 4251 * FUNCTION : setZslAttributes 4252 * 4253 * DESCRIPTION: set ZSL related attributes from user setting 4254 * 4255 * PARAMETERS : 4256 * @params : user setting parameters 4257 * 4258 * RETURN : int32_t type of status 4259 * NO_ERROR -- success 4260 * none-zero failure code 4261 *==========================================================================*/ 4262 int32_t QCameraParameters::setZslAttributes(const QCameraParameters& params) 4263 { 4264 // TODO: may switch to pure param instead of sysprop 4265 char prop[PROPERTY_VALUE_MAX]; 4266 4267 const char *str = params.get(KEY_QC_ZSL_BURST_INTERVAL); 4268 if (str != NULL) { 4269 set(KEY_QC_ZSL_BURST_INTERVAL, str); 4270 } else { 4271 memset(prop, 0, sizeof(prop)); 4272 property_get("persist.camera.zsl.interval", prop, "1"); 4273 set(KEY_QC_ZSL_BURST_INTERVAL, prop); 4274 CDBG_HIGH("%s: [ZSL Retro] burst interval: %s", __func__, prop); 4275 } 4276 4277 str = params.get(KEY_QC_ZSL_BURST_LOOKBACK); 4278 if (str != NULL) { 4279 set(KEY_QC_ZSL_BURST_LOOKBACK, str); 4280 } else { 4281 memset(prop, 0, sizeof(prop)); 4282 property_get("persist.camera.zsl.backlookcnt", prop, "2"); 4283 set(KEY_QC_ZSL_BURST_LOOKBACK, prop); 4284 CDBG_HIGH("%s: [ZSL Retro] look back count: %s", __func__, prop); 4285 } 4286 4287 str = params.get(KEY_QC_ZSL_QUEUE_DEPTH); 4288 if (str != NULL) { 4289 set(KEY_QC_ZSL_QUEUE_DEPTH, str); 4290 } else { 4291 memset(prop, 0, sizeof(prop)); 4292 property_get("persist.camera.zsl.queuedepth", prop, "2"); 4293 set(KEY_QC_ZSL_QUEUE_DEPTH, prop); 4294 CDBG_HIGH("%s: [ZSL Retro] queue depth: %s", __func__, prop); 4295 } 4296 4297 return NO_ERROR; 4298 } 4299 4300 /*=========================================================================== 4301 * FUNCTION : setFlip 4302 * 4303 * DESCRIPTION: set preview/ video/ picture flip mode from user setting 4304 * 4305 * PARAMETERS : 4306 * @params : user setting parameters 4307 * 4308 * RETURN : int32_t type of status 4309 * NO_ERROR -- success 4310 * none-zero failure code 4311 *==========================================================================*/ 4312 int32_t QCameraParameters::setFlip(const QCameraParameters& params) 4313 { 4314 if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_FLIP) == 0) { 4315 CDBG_HIGH("%s: flip is not supported.", __func__); 4316 return NO_ERROR; 4317 } 4318 4319 //check preview flip setting 4320 const char *str = params.get(KEY_QC_PREVIEW_FLIP); 4321 const char *prev_val = get(KEY_QC_PREVIEW_FLIP); 4322 if(str != NULL){ 4323 if (prev_val == NULL || strcmp(str, prev_val) != 0) { 4324 int32_t value = lookupAttr(FLIP_MODES_MAP, PARAM_MAP_SIZE(FLIP_MODES_MAP), str); 4325 if(value != NAME_NOT_FOUND){ 4326 set(KEY_QC_PREVIEW_FLIP, str); 4327 m_bPreviewFlipChanged = true; 4328 } 4329 } 4330 } 4331 4332 // check video filp setting 4333 str = params.get(KEY_QC_VIDEO_FLIP); 4334 prev_val = get(KEY_QC_VIDEO_FLIP); 4335 if(str != NULL){ 4336 if (prev_val == NULL || strcmp(str, prev_val) != 0) { 4337 int32_t value = lookupAttr(FLIP_MODES_MAP, PARAM_MAP_SIZE(FLIP_MODES_MAP), str); 4338 if(value != NAME_NOT_FOUND){ 4339 set(KEY_QC_VIDEO_FLIP, str); 4340 m_bVideoFlipChanged = true; 4341 } 4342 } 4343 } 4344 4345 // check picture filp setting 4346 str = params.get(KEY_QC_SNAPSHOT_PICTURE_FLIP); 4347 prev_val = get(KEY_QC_SNAPSHOT_PICTURE_FLIP); 4348 if(str != NULL){ 4349 if (prev_val == NULL || strcmp(str, prev_val) != 0) { 4350 int32_t value = lookupAttr(FLIP_MODES_MAP, PARAM_MAP_SIZE(FLIP_MODES_MAP), str); 4351 if(value != NAME_NOT_FOUND){ 4352 set(KEY_QC_SNAPSHOT_PICTURE_FLIP, str); 4353 m_bSnapshotFlipChanged = true; 4354 } 4355 } 4356 } 4357 4358 return NO_ERROR; 4359 } 4360 4361 /*=========================================================================== 4362 * FUNCTION : setBurstNum 4363 * 4364 * DESCRIPTION: set burst number of snapshot 4365 * 4366 * PARAMETERS : 4367 * @params : user setting parameters 4368 * 4369 * RETURN : int32_t type of status 4370 * NO_ERROR -- success 4371 * none-zero failure code 4372 *==========================================================================*/ 4373 int32_t QCameraParameters::setBurstNum(const QCameraParameters& params) 4374 { 4375 int nBurstNum = params.getInt(KEY_QC_SNAPSHOT_BURST_NUM); 4376 if (isAdvCamFeaturesEnabled()) { 4377 nBurstNum = 1; 4378 } 4379 if (nBurstNum <= 0) { 4380 // if burst number is not set in parameters, 4381 // read from sys prop 4382 char prop[PROPERTY_VALUE_MAX]; 4383 memset(prop, 0, sizeof(prop)); 4384 property_get("persist.camera.snapshot.number", prop, "0"); 4385 nBurstNum = atoi(prop); 4386 if (nBurstNum <= 0) { 4387 nBurstNum = 1; 4388 } 4389 } 4390 set(KEY_QC_SNAPSHOT_BURST_NUM, nBurstNum); 4391 m_nBurstNum = (uint8_t)nBurstNum; 4392 CDBG_HIGH("%s: [ZSL Retro] m_nBurstNum = %d", __func__, m_nBurstNum); 4393 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_BURST_NUM, (uint32_t)nBurstNum)) { 4394 return BAD_VALUE; 4395 } 4396 4397 return NO_ERROR; 4398 } 4399 4400 /*=========================================================================== 4401 * FUNCTION : setSnapshotFDReq 4402 * 4403 * DESCRIPTION: set requirement of Face Detection Metadata in Snapshot mode. 4404 * 4405 * PARAMETERS : 4406 * @params : user setting parameters 4407 * 4408 * RETURN : int32_t type of status 4409 * NO_ERROR -- success 4410 * none-zero failure code 4411 *==========================================================================*/ 4412 int32_t QCameraParameters::setSnapshotFDReq(const QCameraParameters& params) 4413 { 4414 char prop[PROPERTY_VALUE_MAX]; 4415 const char *str = params.get(KEY_QC_SNAPSHOT_FD_DATA); 4416 4417 if(str != NULL){ 4418 set(KEY_QC_SNAPSHOT_FD_DATA, str); 4419 }else{ 4420 memset(prop, 0, sizeof(prop)); 4421 property_get("persist.camera.snapshot.fd", prop, "0"); 4422 set(KEY_QC_SNAPSHOT_FD_DATA, prop); 4423 } 4424 return NO_ERROR; 4425 } 4426 4427 /*=========================================================================== 4428 * FUNCTION : setMobicat 4429 * 4430 * DESCRIPTION: set Mobicat on/off. 4431 * 4432 * PARAMETERS : 4433 * @params : user setting parameters 4434 * 4435 * RETURN : int32_t type of status 4436 * NO_ERROR -- success 4437 * none-zero failure code 4438 *==========================================================================*/ 4439 int32_t QCameraParameters::setMobicat(const QCameraParameters& ) 4440 { 4441 char value [PROPERTY_VALUE_MAX]; 4442 property_get("persist.camera.mobicat", value, "0"); 4443 int32_t ret = NO_ERROR; 4444 uint8_t enableMobi = (uint8_t)atoi(value); 4445 4446 if (enableMobi) { 4447 tune_cmd_t tune_cmd; 4448 tune_cmd.type = 2; 4449 tune_cmd.module = 0; 4450 tune_cmd.value = 1; 4451 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_SET_VFE_COMMAND, tune_cmd)) { 4452 return BAD_VALUE; 4453 } 4454 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_SET_PP_COMMAND, tune_cmd)) { 4455 ret = BAD_VALUE; 4456 } 4457 } 4458 m_MobiMask = enableMobi; 4459 4460 return ret; 4461 } 4462 4463 /*=========================================================================== 4464 * FUNCTION : updateParameters 4465 * 4466 * DESCRIPTION: update parameters from user setting 4467 * 4468 * PARAMETERS : 4469 * @params : user setting parameters 4470 * @needRestart : [output] if preview need restart upon setting changes 4471 * 4472 * RETURN : int32_t type of status 4473 * NO_ERROR -- success 4474 * none-zero failure code 4475 *==========================================================================*/ 4476 int32_t QCameraParameters::updateParameters(QCameraParameters& params, 4477 bool &needRestart) 4478 { 4479 int32_t final_rc = NO_ERROR; 4480 int32_t rc; 4481 m_bNeedRestart = false; 4482 4483 if(initBatchUpdate(m_pParamBuf) < 0 ) { 4484 ALOGE("%s:Failed to initialize group update table",__func__); 4485 rc = BAD_TYPE; 4486 goto UPDATE_PARAM_DONE; 4487 } 4488 4489 if ((rc = setPreviewSize(params))) final_rc = rc; 4490 if ((rc = setVideoSize(params))) final_rc = rc; 4491 if ((rc = setPictureSize(params))) final_rc = rc; 4492 if ((rc = setPreviewFormat(params))) final_rc = rc; 4493 if ((rc = setPictureFormat(params))) final_rc = rc; 4494 if ((rc = setJpegQuality(params))) final_rc = rc; 4495 if ((rc = setOrientation(params))) final_rc = rc; 4496 if ((rc = setRotation(params))) final_rc = rc; 4497 if ((rc = setVideoRotation(params))) final_rc = rc; 4498 if ((rc = setNoDisplayMode(params))) final_rc = rc; 4499 if ((rc = setZslMode(params))) final_rc = rc; 4500 if ((rc = setZslAttributes(params))) final_rc = rc; 4501 if ((rc = setCameraMode(params))) final_rc = rc; 4502 if ((rc = setSceneSelectionMode(params))) final_rc = rc; 4503 if ((rc = setRecordingHint(params))) final_rc = rc; 4504 if ((rc = setRdiMode(params))) final_rc = rc; 4505 if ((rc = setSecureMode(params))) final_rc = rc; 4506 if ((rc = setPreviewFrameRate(params))) final_rc = rc; 4507 if ((rc = setPreviewFpsRange(params))) final_rc = rc; 4508 if ((rc = setAutoExposure(params))) final_rc = rc; 4509 if ((rc = setEffect(params))) final_rc = rc; 4510 if ((rc = setBrightness(params))) final_rc = rc; 4511 if ((rc = setZoom(params))) final_rc = rc; 4512 if ((rc = setSharpness(params))) final_rc = rc; 4513 if ((rc = setSaturation(params))) final_rc = rc; 4514 if ((rc = setContrast(params))) final_rc = rc; 4515 if ((rc = setFocusMode(params))) final_rc = rc; 4516 if ((rc = setISOValue(params))) final_rc = rc; 4517 if ((rc = setContinuousISO(params))) final_rc = rc; 4518 if ((rc = setExposureTime(params))) final_rc = rc; 4519 if ((rc = setSkinToneEnhancement(params))) final_rc = rc; 4520 if ((rc = setFlash(params))) final_rc = rc; 4521 if ((rc = setAecLock(params))) final_rc = rc; 4522 if ((rc = setAwbLock(params))) final_rc = rc; 4523 if ((rc = setLensShadeValue(params))) final_rc = rc; 4524 if ((rc = setMCEValue(params))) final_rc = rc; 4525 if ((rc = setDISValue(params))) final_rc = rc; 4526 if ((rc = setAntibanding(params))) final_rc = rc; 4527 if ((rc = setExposureCompensation(params))) final_rc = rc; 4528 if ((rc = setWhiteBalance(params))) final_rc = rc; 4529 if ((rc = setHDRMode(params))) final_rc = rc; 4530 if ((rc = setHDRNeed1x(params))) final_rc = rc; 4531 if ((rc = setManualWhiteBalance(params))) final_rc = rc; 4532 if ((rc = setSceneMode(params))) final_rc = rc; 4533 if ((rc = setFocusAreas(params))) final_rc = rc; 4534 if ((rc = setFocusPosition(params))) final_rc = rc; 4535 if ((rc = setMeteringAreas(params))) final_rc = rc; 4536 if ((rc = setSelectableZoneAf(params))) final_rc = rc; 4537 if ((rc = setRedeyeReduction(params))) final_rc = rc; 4538 if ((rc = setAEBracket(params))) final_rc = rc; 4539 if ((rc = setAutoHDR(params))) final_rc = rc; 4540 if ((rc = setGpsLocation(params))) final_rc = rc; 4541 if ((rc = setWaveletDenoise(params))) final_rc = rc; 4542 if ((rc = setFaceRecognition(params))) final_rc = rc; 4543 if ((rc = setFlip(params))) final_rc = rc; 4544 if ((rc = setVideoHDR(params))) final_rc = rc; 4545 if ((rc = setVtEnable(params))) final_rc = rc; 4546 if ((rc = setAFBracket(params))) final_rc = rc; 4547 if ((rc = setReFocus(params))) final_rc = rc; 4548 if ((rc = setChromaFlash(params))) final_rc = rc; 4549 if ((rc = setTruePortrait(params))) final_rc = rc; 4550 if ((rc = setOptiZoom(params))) final_rc = rc; 4551 if ((rc = setBurstNum(params))) final_rc = rc; 4552 if ((rc = setBurstLEDOnPeriod(params))) final_rc = rc; 4553 if ((rc = setRetroActiveBurstNum(params))) final_rc = rc; 4554 if ((rc = setSnapshotFDReq(params))) final_rc = rc; 4555 if ((rc = setTintlessValue(params))) final_rc = rc; 4556 if ((rc = setCDSMode(params))) final_rc = rc; 4557 if ((rc = setTemporalDenoise(params))) final_rc = rc; 4558 4559 // update live snapshot size after all other parameters are set 4560 if ((rc = setLiveSnapshotSize(params))) final_rc = rc; 4561 if ((rc = setJpegThumbnailSize(params))) final_rc = rc; 4562 if ((rc = setStatsDebugMask())) final_rc = rc; 4563 if ((rc = setPAAF())) final_rc = rc; 4564 if ((rc = setMobicat(params))) final_rc = rc; 4565 if ((rc = setSeeMore(params))) final_rc = rc; 4566 if ((rc = setStillMore(params))) final_rc = rc; 4567 4568 if ((rc = updateFlash(false))) final_rc = rc; 4569 4570 UPDATE_PARAM_DONE: 4571 needRestart = m_bNeedRestart; 4572 return final_rc; 4573 } 4574 4575 /*=========================================================================== 4576 * FUNCTION : commitParameters 4577 * 4578 * DESCRIPTION: commit parameter changes to backend 4579 * 4580 * PARAMETERS : none 4581 * 4582 * RETURN : int32_t type of status 4583 * NO_ERROR -- success 4584 * none-zero failure code 4585 *==========================================================================*/ 4586 int32_t QCameraParameters::commitParameters() 4587 { 4588 return commitSetBatch(); 4589 } 4590 4591 /*=========================================================================== 4592 * FUNCTION : initDefaultParameters 4593 * 4594 * DESCRIPTION: initialize default parameters for the first time 4595 * 4596 * PARAMETERS : none 4597 * 4598 * RETURN : int32_t type of status 4599 * NO_ERROR -- success 4600 * none-zero failure code 4601 *==========================================================================*/ 4602 int32_t QCameraParameters::initDefaultParameters() 4603 { 4604 if(initBatchUpdate(m_pParamBuf) < 0 ) { 4605 ALOGE("%s:Failed to initialize group update table", __func__); 4606 return BAD_TYPE; 4607 } 4608 int32_t hal_version = CAM_HAL_V1; 4609 ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_HAL_VERSION, hal_version); 4610 4611 /*************************Initialize Values******************************/ 4612 // Set read only parameters from camera capability 4613 set(KEY_SMOOTH_ZOOM_SUPPORTED, 4614 m_pCapability->smooth_zoom_supported? VALUE_TRUE : VALUE_FALSE); 4615 set(KEY_ZOOM_SUPPORTED, 4616 m_pCapability->zoom_supported? VALUE_TRUE : VALUE_FALSE); 4617 set(KEY_VIDEO_SNAPSHOT_SUPPORTED, 4618 m_pCapability->video_snapshot_supported? VALUE_TRUE : VALUE_FALSE); 4619 set(KEY_VIDEO_STABILIZATION_SUPPORTED, 4620 m_pCapability->video_stablization_supported? VALUE_TRUE : VALUE_FALSE); 4621 set(KEY_AUTO_EXPOSURE_LOCK_SUPPORTED, 4622 m_pCapability->auto_exposure_lock_supported? VALUE_TRUE : VALUE_FALSE); 4623 set(KEY_AUTO_WHITEBALANCE_LOCK_SUPPORTED, 4624 m_pCapability->auto_wb_lock_supported? VALUE_TRUE : VALUE_FALSE); 4625 set(KEY_QC_SUPPORTED_CAMERA_FEATURES, 4626 (int)m_pCapability->qcom_supported_feature_mask); 4627 set(KEY_MAX_NUM_DETECTED_FACES_HW, m_pCapability->max_num_roi); 4628 set(KEY_MAX_NUM_DETECTED_FACES_SW, m_pCapability->max_num_roi); 4629 set(KEY_QC_MAX_NUM_REQUESTED_FACES, m_pCapability->max_num_roi); 4630 // Set focal length, horizontal view angle, and vertical view angle 4631 setFloat(KEY_FOCAL_LENGTH, m_pCapability->focal_length); 4632 setFloat(KEY_HORIZONTAL_VIEW_ANGLE, m_pCapability->hor_view_angle); 4633 setFloat(KEY_VERTICAL_VIEW_ANGLE, m_pCapability->ver_view_angle); 4634 set(QCameraParameters::KEY_FOCUS_DISTANCES, "Infinity,Infinity,Infinity"); 4635 set(KEY_QC_AUTO_HDR_SUPPORTED, 4636 (m_pCapability->auto_hdr_supported)? VALUE_TRUE : VALUE_FALSE); 4637 // Set supported preview sizes 4638 if (m_pCapability->preview_sizes_tbl_cnt > 0 && 4639 m_pCapability->preview_sizes_tbl_cnt <= MAX_SIZES_CNT) { 4640 String8 previewSizeValues = createSizesString( 4641 m_pCapability->preview_sizes_tbl, m_pCapability->preview_sizes_tbl_cnt); 4642 set(KEY_SUPPORTED_PREVIEW_SIZES, previewSizeValues.string()); 4643 CDBG_HIGH("%s: supported preview sizes: %s", __func__, previewSizeValues.string()); 4644 // Set default preview size 4645 CameraParameters::setPreviewSize(m_pCapability->preview_sizes_tbl[0].width, 4646 m_pCapability->preview_sizes_tbl[0].height); 4647 } else { 4648 ALOGE("%s: supported preview sizes cnt is 0 or exceeds max!!!", __func__); 4649 } 4650 4651 // Set supported video sizes 4652 if (m_pCapability->video_sizes_tbl_cnt > 0 && 4653 m_pCapability->video_sizes_tbl_cnt <= MAX_SIZES_CNT) { 4654 String8 videoSizeValues = createSizesString( 4655 m_pCapability->video_sizes_tbl, m_pCapability->video_sizes_tbl_cnt); 4656 set(KEY_SUPPORTED_VIDEO_SIZES, videoSizeValues.string()); 4657 CDBG_HIGH("%s: supported video sizes: %s", __func__, videoSizeValues.string()); 4658 // Set default video size 4659 CameraParameters::setVideoSize(m_pCapability->video_sizes_tbl[0].width, 4660 m_pCapability->video_sizes_tbl[0].height); 4661 4662 //Set preferred Preview size for video 4663 String8 vSize = createSizesString(&m_pCapability->preview_sizes_tbl[0], 1); 4664 set(KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO, vSize.string()); 4665 } else { 4666 ALOGE("%s: supported video sizes cnt is 0 or exceeds max!!!", __func__); 4667 } 4668 4669 // Set supported picture sizes 4670 if (m_pCapability->picture_sizes_tbl_cnt > 0 && 4671 m_pCapability->picture_sizes_tbl_cnt <= MAX_SIZES_CNT) { 4672 String8 pictureSizeValues = createSizesString( 4673 m_pCapability->picture_sizes_tbl, m_pCapability->picture_sizes_tbl_cnt); 4674 set(KEY_SUPPORTED_PICTURE_SIZES, pictureSizeValues.string()); 4675 CDBG_HIGH("%s: supported pic sizes: %s", __func__, pictureSizeValues.string()); 4676 // Set default picture size to the smallest resolution 4677 CameraParameters::setPictureSize( 4678 m_pCapability->picture_sizes_tbl[m_pCapability->picture_sizes_tbl_cnt-1].width, 4679 m_pCapability->picture_sizes_tbl[m_pCapability->picture_sizes_tbl_cnt-1].height); 4680 } else { 4681 ALOGE("%s: supported picture sizes cnt is 0 or exceeds max!!!", __func__); 4682 } 4683 4684 // Need check if scale should be enabled 4685 if (m_pCapability->scale_picture_sizes_cnt > 0 && 4686 m_pCapability->scale_picture_sizes_cnt <= MAX_SCALE_SIZES_CNT){ 4687 //get scale size, enable scaling. And re-set picture size table with scale sizes 4688 m_reprocScaleParam.setScaleEnable(true); 4689 int rc_s = m_reprocScaleParam.setScaleSizeTbl( 4690 m_pCapability->scale_picture_sizes_cnt, m_pCapability->scale_picture_sizes, 4691 m_pCapability->picture_sizes_tbl_cnt, m_pCapability->picture_sizes_tbl); 4692 if(rc_s == NO_ERROR){ 4693 cam_dimension_t *totalSizeTbl = m_reprocScaleParam.getTotalSizeTbl(); 4694 size_t totalSizeCnt = m_reprocScaleParam.getTotalSizeTblCnt(); 4695 String8 pictureSizeValues = createSizesString(totalSizeTbl, totalSizeCnt); 4696 set(KEY_SUPPORTED_PICTURE_SIZES, pictureSizeValues.string()); 4697 CDBG_HIGH("%s: scaled supported pic sizes: %s", __func__, pictureSizeValues.string()); 4698 }else{ 4699 m_reprocScaleParam.setScaleEnable(false); 4700 ALOGE("%s: reset scaled picture size table failed.", __func__); 4701 } 4702 }else{ 4703 m_reprocScaleParam.setScaleEnable(false); 4704 } 4705 4706 // Set supported thumbnail sizes 4707 String8 thumbnailSizeValues = createSizesString( 4708 THUMBNAIL_SIZES_MAP, 4709 PARAM_MAP_SIZE(THUMBNAIL_SIZES_MAP)); 4710 set(KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES, thumbnailSizeValues.string()); 4711 // Set default thumnail size 4712 set(KEY_JPEG_THUMBNAIL_WIDTH, THUMBNAIL_SIZES_MAP[0].width); 4713 set(KEY_JPEG_THUMBNAIL_HEIGHT, THUMBNAIL_SIZES_MAP[0].height); 4714 4715 // Set supported livesnapshot sizes 4716 if (m_pCapability->livesnapshot_sizes_tbl_cnt > 0 && 4717 m_pCapability->livesnapshot_sizes_tbl_cnt <= MAX_SIZES_CNT) { 4718 String8 liveSnpashotSizeValues = createSizesString( 4719 m_pCapability->livesnapshot_sizes_tbl, 4720 m_pCapability->livesnapshot_sizes_tbl_cnt); 4721 set(KEY_QC_SUPPORTED_LIVESNAPSHOT_SIZES, liveSnpashotSizeValues.string()); 4722 CDBG("%s: supported live snapshot sizes: %s", __func__, liveSnpashotSizeValues.string()); 4723 m_LiveSnapshotSize = 4724 m_pCapability->livesnapshot_sizes_tbl[m_pCapability->livesnapshot_sizes_tbl_cnt-1]; 4725 } 4726 4727 // Set supported preview formats 4728 String8 previewFormatValues = createValuesString( 4729 m_pCapability->supported_preview_fmts, 4730 m_pCapability->supported_preview_fmt_cnt, 4731 PREVIEW_FORMATS_MAP, 4732 PARAM_MAP_SIZE(PREVIEW_FORMATS_MAP)); 4733 set(KEY_SUPPORTED_PREVIEW_FORMATS, previewFormatValues.string()); 4734 // Set default preview format 4735 CameraParameters::setPreviewFormat(PIXEL_FORMAT_YUV420SP); 4736 4737 // Set default Video Format 4738 set(KEY_VIDEO_FRAME_FORMAT, PIXEL_FORMAT_YUV420SP); 4739 4740 // Set supported picture formats 4741 String8 pictureTypeValues(PIXEL_FORMAT_JPEG); 4742 String8 str = createValuesString( 4743 m_pCapability->supported_raw_fmts, 4744 m_pCapability->supported_raw_fmt_cnt, 4745 PICTURE_TYPES_MAP, 4746 PARAM_MAP_SIZE(PICTURE_TYPES_MAP)); 4747 if (str.string() != NULL) { 4748 pictureTypeValues.append(","); 4749 pictureTypeValues.append(str); 4750 } 4751 4752 set(KEY_SUPPORTED_PICTURE_FORMATS, pictureTypeValues.string()); 4753 // Set default picture Format 4754 CameraParameters::setPictureFormat(PIXEL_FORMAT_JPEG); 4755 // Set raw image size 4756 char raw_size_str[32]; 4757 snprintf(raw_size_str, sizeof(raw_size_str), "%dx%d", 4758 m_pCapability->raw_dim[0].width, m_pCapability->raw_dim[0].height); 4759 set(KEY_QC_RAW_PICUTRE_SIZE, raw_size_str); 4760 CDBG("%s: KEY_QC_RAW_PICUTRE_SIZE: w: %d, h: %d ", __func__, 4761 m_pCapability->raw_dim[0].width, m_pCapability->raw_dim[0].height); 4762 4763 //set default jpeg quality and thumbnail quality 4764 set(KEY_JPEG_QUALITY, 85); 4765 set(KEY_JPEG_THUMBNAIL_QUALITY, 85); 4766 4767 // Set FPS ranges 4768 if (m_pCapability->fps_ranges_tbl_cnt > 0 && 4769 m_pCapability->fps_ranges_tbl_cnt <= MAX_SIZES_CNT) { 4770 int default_fps_index = 0; 4771 String8 fpsRangeValues = createFpsRangeString(m_pCapability->fps_ranges_tbl, 4772 m_pCapability->fps_ranges_tbl_cnt, 4773 default_fps_index); 4774 set(KEY_SUPPORTED_PREVIEW_FPS_RANGE, fpsRangeValues.string()); 4775 4776 int min_fps = 4777 int(m_pCapability->fps_ranges_tbl[default_fps_index].min_fps * 1000); 4778 int max_fps = 4779 int(m_pCapability->fps_ranges_tbl[default_fps_index].max_fps * 1000); 4780 m_default_fps_range = m_pCapability->fps_ranges_tbl[default_fps_index]; 4781 //Set video fps same as preview fps 4782 setPreviewFpsRange(min_fps, max_fps, min_fps, max_fps); 4783 4784 // Set legacy preview fps 4785 String8 fpsValues = createFpsString(m_pCapability->fps_ranges_tbl[default_fps_index]); 4786 set(KEY_SUPPORTED_PREVIEW_FRAME_RATES, fpsValues.string()); 4787 CDBG_HIGH("%s: supported fps rates: %s", __func__, fpsValues.string()); 4788 CameraParameters::setPreviewFrameRate(int(m_pCapability->fps_ranges_tbl[default_fps_index].max_fps)); 4789 } else { 4790 ALOGE("%s: supported fps ranges cnt is 0 or exceeds max!!!", __func__); 4791 } 4792 4793 // Set supported focus modes 4794 if (m_pCapability->supported_focus_modes_cnt > 0) { 4795 String8 focusModeValues = createValuesString( 4796 m_pCapability->supported_focus_modes, 4797 m_pCapability->supported_focus_modes_cnt, 4798 FOCUS_MODES_MAP, 4799 PARAM_MAP_SIZE(FOCUS_MODES_MAP)); 4800 set(KEY_SUPPORTED_FOCUS_MODES, focusModeValues); 4801 4802 // Set default focus mode and update corresponding parameter buf 4803 const char *focusMode = lookupNameByValue(FOCUS_MODES_MAP, 4804 PARAM_MAP_SIZE(FOCUS_MODES_MAP), 4805 m_pCapability->supported_focus_modes[0]); 4806 if (focusMode != NULL) { 4807 setFocusMode(focusMode); 4808 } else { 4809 setFocusMode(FOCUS_MODE_FIXED); 4810 } 4811 } else { 4812 ALOGE("%s: supported focus modes cnt is 0!!!", __func__); 4813 } 4814 4815 // Set focus areas 4816 if (m_pCapability->max_num_focus_areas > MAX_ROI) { 4817 m_pCapability->max_num_focus_areas = MAX_ROI; 4818 } 4819 set(KEY_MAX_NUM_FOCUS_AREAS, m_pCapability->max_num_focus_areas); 4820 if (m_pCapability->max_num_focus_areas > 0) { 4821 setFocusAreas(DEFAULT_CAMERA_AREA); 4822 } 4823 4824 // Set metering areas 4825 if (m_pCapability->max_num_metering_areas > MAX_ROI) { 4826 m_pCapability->max_num_metering_areas = MAX_ROI; 4827 } 4828 set(KEY_MAX_NUM_METERING_AREAS, m_pCapability->max_num_metering_areas); 4829 if (m_pCapability->max_num_metering_areas > 0) { 4830 setMeteringAreas(DEFAULT_CAMERA_AREA); 4831 } 4832 4833 // set focus position, we should get them from m_pCapability 4834 m_pCapability->min_focus_pos[CAM_MANUAL_FOCUS_MODE_INDEX] = 0; 4835 m_pCapability->max_focus_pos[CAM_MANUAL_FOCUS_MODE_INDEX] = 1023; 4836 set(KEY_QC_MIN_FOCUS_POS_INDEX, 4837 (int) m_pCapability->min_focus_pos[CAM_MANUAL_FOCUS_MODE_INDEX]); 4838 set(KEY_QC_MAX_FOCUS_POS_INDEX, 4839 (int) m_pCapability->max_focus_pos[CAM_MANUAL_FOCUS_MODE_INDEX]); 4840 4841 m_pCapability->min_focus_pos[CAM_MANUAL_FOCUS_MODE_DAC_CODE] = 0; 4842 m_pCapability->max_focus_pos[CAM_MANUAL_FOCUS_MODE_DAC_CODE] = 1023; 4843 set(KEY_QC_MIN_FOCUS_POS_DAC, 4844 (int) m_pCapability->min_focus_pos[CAM_MANUAL_FOCUS_MODE_DAC_CODE]); 4845 set(KEY_QC_MAX_FOCUS_POS_DAC, 4846 (int) m_pCapability->max_focus_pos[CAM_MANUAL_FOCUS_MODE_DAC_CODE]); 4847 4848 m_pCapability->min_focus_pos[CAM_MANUAL_FOCUS_MODE_RATIO] = 0; 4849 m_pCapability->max_focus_pos[CAM_MANUAL_FOCUS_MODE_RATIO] = 100; 4850 set(KEY_QC_MIN_FOCUS_POS_RATIO, 4851 (int) m_pCapability->min_focus_pos[CAM_MANUAL_FOCUS_MODE_RATIO]); 4852 set(KEY_QC_MAX_FOCUS_POS_RATIO, 4853 (int) m_pCapability->max_focus_pos[CAM_MANUAL_FOCUS_MODE_RATIO]); 4854 4855 m_pCapability->min_focus_pos[CAM_MANUAL_FOCUS_MODE_DIOPTER] = 0; 4856 if (m_pCapability->min_focus_distance > 0) { 4857 m_pCapability->max_focus_pos[CAM_MANUAL_FOCUS_MODE_DIOPTER] = 4858 100.0f / m_pCapability->min_focus_distance; 4859 } else { 4860 m_pCapability->max_focus_pos[CAM_MANUAL_FOCUS_MODE_DIOPTER] = 0; 4861 } 4862 setFloat(KEY_QC_MIN_FOCUS_POS_DIOPTER, 4863 m_pCapability->min_focus_pos[CAM_MANUAL_FOCUS_MODE_DIOPTER]); 4864 setFloat(KEY_QC_MAX_FOCUS_POS_DIOPTER, 4865 m_pCapability->max_focus_pos[CAM_MANUAL_FOCUS_MODE_DIOPTER]); 4866 4867 //set supported manual focus modes 4868 String8 manualFocusModes(VALUE_OFF); 4869 if (m_pCapability->supported_focus_modes_cnt > 1 && 4870 m_pCapability->min_focus_distance > 0) { 4871 manualFocusModes.append(","); 4872 manualFocusModes.append(KEY_QC_FOCUS_SCALE_MODE); 4873 manualFocusModes.append(","); 4874 manualFocusModes.append(KEY_QC_FOCUS_DIOPTER_MODE); 4875 } 4876 set(KEY_QC_SUPPORTED_MANUAL_FOCUS_MODES, manualFocusModes.string()); 4877 4878 // Set Saturation 4879 set(KEY_QC_MIN_SATURATION, m_pCapability->saturation_ctrl.min_value); 4880 set(KEY_QC_MAX_SATURATION, m_pCapability->saturation_ctrl.max_value); 4881 set(KEY_QC_SATURATION_STEP, m_pCapability->saturation_ctrl.step); 4882 setSaturation(m_pCapability->saturation_ctrl.def_value); 4883 4884 // Set Sharpness 4885 set(KEY_QC_MIN_SHARPNESS, m_pCapability->sharpness_ctrl.min_value); 4886 set(KEY_QC_MAX_SHARPNESS, m_pCapability->sharpness_ctrl.max_value); 4887 set(KEY_QC_SHARPNESS_STEP, m_pCapability->sharpness_ctrl.step); 4888 setSharpness(m_pCapability->sharpness_ctrl.def_value); 4889 4890 // Set Contrast 4891 set(KEY_QC_MIN_CONTRAST, m_pCapability->contrast_ctrl.min_value); 4892 set(KEY_QC_MAX_CONTRAST, m_pCapability->contrast_ctrl.max_value); 4893 set(KEY_QC_CONTRAST_STEP, m_pCapability->contrast_ctrl.step); 4894 setContrast(m_pCapability->contrast_ctrl.def_value); 4895 4896 // Set SCE factor 4897 set(KEY_QC_MIN_SCE_FACTOR, m_pCapability->sce_ctrl.min_value); // -100 4898 set(KEY_QC_MAX_SCE_FACTOR, m_pCapability->sce_ctrl.max_value); // 100 4899 set(KEY_QC_SCE_FACTOR_STEP, m_pCapability->sce_ctrl.step); // 10 4900 setSkinToneEnhancement(m_pCapability->sce_ctrl.def_value); // 0 4901 4902 // Set Brightness 4903 set(KEY_QC_MIN_BRIGHTNESS, m_pCapability->brightness_ctrl.min_value); // 0 4904 set(KEY_QC_MAX_BRIGHTNESS, m_pCapability->brightness_ctrl.max_value); // 6 4905 set(KEY_QC_BRIGHTNESS_STEP, m_pCapability->brightness_ctrl.step); // 1 4906 setBrightness(m_pCapability->brightness_ctrl.def_value); 4907 4908 // Set Auto exposure 4909 String8 autoExposureValues = createValuesString( 4910 m_pCapability->supported_aec_modes, 4911 m_pCapability->supported_aec_modes_cnt, 4912 AUTO_EXPOSURE_MAP, 4913 PARAM_MAP_SIZE(AUTO_EXPOSURE_MAP)); 4914 set(KEY_QC_SUPPORTED_AUTO_EXPOSURE, autoExposureValues.string()); 4915 setAutoExposure(AUTO_EXPOSURE_FRAME_AVG); 4916 4917 // Set Exposure Compensation 4918 set(KEY_MAX_EXPOSURE_COMPENSATION, m_pCapability->exposure_compensation_max); // 12 4919 set(KEY_MIN_EXPOSURE_COMPENSATION, m_pCapability->exposure_compensation_min); // -12 4920 setFloat(KEY_EXPOSURE_COMPENSATION_STEP, m_pCapability->exposure_compensation_step); // 1/6 4921 setExposureCompensation(m_pCapability->exposure_compensation_default); // 0 4922 4923 // Set Antibanding 4924 String8 antibandingValues = createValuesString( 4925 m_pCapability->supported_antibandings, 4926 m_pCapability->supported_antibandings_cnt, 4927 ANTIBANDING_MODES_MAP, 4928 PARAM_MAP_SIZE(ANTIBANDING_MODES_MAP)); 4929 set(KEY_SUPPORTED_ANTIBANDING, antibandingValues); 4930 setAntibanding(ANTIBANDING_OFF); 4931 4932 // Set Effect 4933 String8 effectValues = createValuesString( 4934 m_pCapability->supported_effects, 4935 m_pCapability->supported_effects_cnt, 4936 EFFECT_MODES_MAP, 4937 PARAM_MAP_SIZE(EFFECT_MODES_MAP)); 4938 set(KEY_SUPPORTED_EFFECTS, effectValues); 4939 setEffect(EFFECT_NONE); 4940 4941 // Set WhiteBalance 4942 String8 whitebalanceValues = createValuesString( 4943 m_pCapability->supported_white_balances, 4944 m_pCapability->supported_white_balances_cnt, 4945 WHITE_BALANCE_MODES_MAP, 4946 PARAM_MAP_SIZE(WHITE_BALANCE_MODES_MAP)); 4947 set(KEY_SUPPORTED_WHITE_BALANCE, whitebalanceValues); 4948 setWhiteBalance(WHITE_BALANCE_AUTO); 4949 4950 // set supported wb cct, we should get them from m_pCapability 4951 m_pCapability->min_wb_cct = 2000; 4952 m_pCapability->max_wb_cct = 8000; 4953 set(KEY_QC_MIN_WB_CCT, m_pCapability->min_wb_cct); 4954 set(KEY_QC_MAX_WB_CCT, m_pCapability->max_wb_cct); 4955 4956 // set supported wb rgb gains, ideally we should get them from m_pCapability 4957 //but for now hardcode. 4958 m_pCapability->min_wb_gain = 1.0; 4959 m_pCapability->max_wb_gain = 4.0; 4960 setFloat(KEY_QC_MIN_WB_GAIN, m_pCapability->min_wb_gain); 4961 setFloat(KEY_QC_MAX_WB_GAIN, m_pCapability->max_wb_gain); 4962 4963 //set supported manual wb modes 4964 String8 manualWBModes(VALUE_OFF); 4965 if(m_pCapability->sensor_type.sens_type != CAM_SENSOR_YUV) { 4966 manualWBModes.append(","); 4967 manualWBModes.append(KEY_QC_WB_CCT_MODE); 4968 manualWBModes.append(","); 4969 manualWBModes.append(KEY_QC_WB_GAIN_MODE); 4970 } 4971 set(KEY_QC_SUPPORTED_MANUAL_WB_MODES, manualWBModes.string()); 4972 4973 // Set Flash mode 4974 if(m_pCapability->supported_flash_modes_cnt > 0) { 4975 String8 flashValues = createValuesString( 4976 m_pCapability->supported_flash_modes, 4977 m_pCapability->supported_flash_modes_cnt, 4978 FLASH_MODES_MAP, 4979 PARAM_MAP_SIZE(FLASH_MODES_MAP)); 4980 set(KEY_SUPPORTED_FLASH_MODES, flashValues); 4981 setFlash(FLASH_MODE_OFF); 4982 } else { 4983 ALOGE("%s: supported flash modes cnt is 0!!!", __func__); 4984 } 4985 4986 // Set Scene Mode 4987 String8 sceneModeValues = createValuesString( 4988 m_pCapability->supported_scene_modes, 4989 m_pCapability->supported_scene_modes_cnt, 4990 SCENE_MODES_MAP, 4991 PARAM_MAP_SIZE(SCENE_MODES_MAP)); 4992 set(KEY_SUPPORTED_SCENE_MODES, sceneModeValues); 4993 setSceneMode(SCENE_MODE_AUTO); 4994 4995 // Set CDS Mode 4996 String8 cdsModeValues = createValuesStringFromMap( 4997 CDS_MODES_MAP, 4998 PARAM_MAP_SIZE(CDS_MODES_MAP)); 4999 set(KEY_QC_SUPPORTED_CDS_MODES, cdsModeValues); 5000 5001 // Set video CDS Mode 5002 String8 videoCdsModeValues = createValuesStringFromMap( 5003 CDS_MODES_MAP, 5004 PARAM_MAP_SIZE(CDS_MODES_MAP)); 5005 set(KEY_QC_SUPPORTED_VIDEO_CDS_MODES, videoCdsModeValues); 5006 5007 // Set TNR Mode 5008 String8 tnrModeValues = createValuesStringFromMap( 5009 ON_OFF_MODES_MAP, 5010 PARAM_MAP_SIZE(ON_OFF_MODES_MAP)); 5011 set(KEY_QC_SUPPORTED_TNR_MODES, tnrModeValues); 5012 5013 // Set video TNR Mode 5014 String8 videoTnrModeValues = createValuesStringFromMap( 5015 ON_OFF_MODES_MAP, 5016 PARAM_MAP_SIZE(ON_OFF_MODES_MAP)); 5017 set(KEY_QC_SUPPORTED_VIDEO_TNR_MODES, videoTnrModeValues); 5018 5019 // Set ISO Mode 5020 String8 isoValues = createValuesString( 5021 m_pCapability->supported_iso_modes, 5022 m_pCapability->supported_iso_modes_cnt, 5023 ISO_MODES_MAP, 5024 PARAM_MAP_SIZE(ISO_MODES_MAP)); 5025 set(KEY_QC_SUPPORTED_ISO_MODES, isoValues); 5026 setISOValue(ISO_AUTO); 5027 5028 // Set exposure time 5029 String8 manualExpModes(VALUE_OFF); 5030 bool expTimeSupported = false; 5031 bool manualISOSupported = false; 5032 //capability values are in nano sec, convert to milli sec for upper layers 5033 char expTimeStr[20]; 5034 double min_exp_time = (double) m_pCapability->exposure_time_range[0] / 1000000.0; 5035 double max_exp_time = (double) m_pCapability->exposure_time_range[1] / 1000000.0; 5036 snprintf(expTimeStr, sizeof(expTimeStr), "%f", min_exp_time); 5037 set(KEY_QC_MIN_EXPOSURE_TIME, expTimeStr); 5038 snprintf(expTimeStr, sizeof(expTimeStr), "%f", max_exp_time); 5039 set(KEY_QC_MAX_EXPOSURE_TIME, expTimeStr); 5040 if ((min_exp_time > 0) && (max_exp_time > min_exp_time)) { 5041 manualExpModes.append(","); 5042 manualExpModes.append(KEY_QC_EXP_TIME_PRIORITY); 5043 expTimeSupported = true; 5044 } 5045 CDBG_HIGH("%s, Exposure time min %f ms, max %f ms", __func__, 5046 min_exp_time, max_exp_time); 5047 5048 // Set iso 5049 set(KEY_QC_MIN_ISO, m_pCapability->sensitivity_range.min_sensitivity); 5050 set(KEY_QC_MAX_ISO, m_pCapability->sensitivity_range.max_sensitivity); 5051 CDBG_HIGH("%s, ISO min %d, max %d", __func__, 5052 m_pCapability->sensitivity_range.min_sensitivity, 5053 m_pCapability->sensitivity_range.max_sensitivity); 5054 if ((m_pCapability->sensitivity_range.min_sensitivity > 0) && 5055 (m_pCapability->sensitivity_range.max_sensitivity > 5056 m_pCapability->sensitivity_range.min_sensitivity)) { 5057 manualExpModes.append(","); 5058 manualExpModes.append(KEY_QC_ISO_PRIORITY); 5059 manualISOSupported = true; 5060 } 5061 if (expTimeSupported && manualISOSupported) { 5062 manualExpModes.append(","); 5063 manualExpModes.append(KEY_QC_USER_SETTING); 5064 } 5065 //finally set supported manual exposure modes 5066 set(KEY_QC_SUPPORTED_MANUAL_EXPOSURE_MODES, manualExpModes.string()); 5067 5068 // Set HFR 5069 String8 hfrValues = createHfrValuesString( 5070 m_pCapability->hfr_tbl, 5071 m_pCapability->hfr_tbl_cnt, 5072 HFR_MODES_MAP, 5073 PARAM_MAP_SIZE(HFR_MODES_MAP)); 5074 set(KEY_QC_SUPPORTED_VIDEO_HIGH_FRAME_RATE_MODES, hfrValues.string()); 5075 set(KEY_QC_VIDEO_HIGH_SPEED_RECORDING, "off"); 5076 set(KEY_QC_VIDEO_HIGH_FRAME_RATE, "off"); 5077 String8 hfrSizeValues = createHfrSizesString( 5078 m_pCapability->hfr_tbl, 5079 m_pCapability->hfr_tbl_cnt); 5080 set(KEY_QC_SUPPORTED_HFR_SIZES, hfrSizeValues.string()); 5081 CDBG("HFR values %s HFR Sizes = %d", hfrValues.string(), hfrSizeValues.string()); 5082 setHighFrameRate(CAM_HFR_MODE_OFF); 5083 5084 // Set Focus algorithms 5085 String8 focusAlgoValues = createValuesString( 5086 m_pCapability->supported_focus_algos, 5087 m_pCapability->supported_focus_algos_cnt, 5088 FOCUS_ALGO_MAP, 5089 PARAM_MAP_SIZE(FOCUS_ALGO_MAP)); 5090 set(KEY_QC_SUPPORTED_FOCUS_ALGOS, focusAlgoValues); 5091 setSelectableZoneAf(FOCUS_ALGO_AUTO); 5092 5093 // Set Zoom Ratios 5094 if (m_pCapability->zoom_supported > 0) { 5095 String8 zoomRatioValues = createZoomRatioValuesString( 5096 m_pCapability->zoom_ratio_tbl, 5097 m_pCapability->zoom_ratio_tbl_cnt); 5098 set(KEY_ZOOM_RATIOS, zoomRatioValues); 5099 set(KEY_MAX_ZOOM, (int)(m_pCapability->zoom_ratio_tbl_cnt - 1)); 5100 setZoom(0); 5101 } 5102 5103 // Set Bracketing/HDR 5104 char prop[PROPERTY_VALUE_MAX]; 5105 memset(prop, 0, sizeof(prop)); 5106 property_get("persist.capture.burst.exposures", prop, ""); 5107 if (strlen(prop) > 0) { 5108 set(KEY_QC_CAPTURE_BURST_EXPOSURE, prop); 5109 } 5110 String8 bracketingValues = createValuesStringFromMap( 5111 BRACKETING_MODES_MAP, 5112 PARAM_MAP_SIZE(BRACKETING_MODES_MAP)); 5113 set(KEY_QC_SUPPORTED_AE_BRACKET_MODES, bracketingValues); 5114 setAEBracket(AE_BRACKET_OFF); 5115 5116 //Set AF Bracketing. 5117 for (size_t i = 0; i < m_pCapability->supported_focus_modes_cnt; i++) { 5118 if ((CAM_FOCUS_MODE_AUTO == m_pCapability->supported_focus_modes[i]) && 5119 ((m_pCapability->qcom_supported_feature_mask & 5120 CAM_QCOM_FEATURE_UBIFOCUS) > 0)) { 5121 String8 afBracketingValues = createValuesStringFromMap( 5122 AF_BRACKETING_MODES_MAP, 5123 PARAM_MAP_SIZE(AF_BRACKETING_MODES_MAP)); 5124 set(KEY_QC_SUPPORTED_AF_BRACKET_MODES, afBracketingValues); 5125 setAFBracket(AF_BRACKET_OFF); 5126 break; 5127 } 5128 } 5129 5130 //Set Refocus. 5131 //Re-use ubifocus flag for now. 5132 for (size_t i = 0; i < m_pCapability->supported_focus_modes_cnt; i++) { 5133 if ((CAM_FOCUS_MODE_AUTO == m_pCapability->supported_focus_modes[i]) && 5134 (m_pCapability->qcom_supported_feature_mask & 5135 CAM_QCOM_FEATURE_REFOCUS) > 0) { 5136 String8 reFocusValues = createValuesStringFromMap( 5137 RE_FOCUS_MODES_MAP, 5138 PARAM_MAP_SIZE(RE_FOCUS_MODES_MAP)); 5139 set(KEY_QC_SUPPORTED_RE_FOCUS_MODES, reFocusValues); 5140 setReFocus(RE_FOCUS_OFF); 5141 } 5142 } 5143 5144 //Set Chroma Flash. 5145 if ((m_pCapability->supported_flash_modes_cnt > 0) && 5146 (m_pCapability->qcom_supported_feature_mask & 5147 CAM_QCOM_FEATURE_CHROMA_FLASH) > 0) { 5148 String8 chromaFlashValues = createValuesStringFromMap( 5149 CHROMA_FLASH_MODES_MAP, 5150 PARAM_MAP_SIZE(CHROMA_FLASH_MODES_MAP)); 5151 set(KEY_QC_SUPPORTED_CHROMA_FLASH_MODES, chromaFlashValues); 5152 setChromaFlash(CHROMA_FLASH_OFF); 5153 } 5154 5155 //Set Opti Zoom. 5156 if (m_pCapability->zoom_supported && 5157 (m_pCapability->qcom_supported_feature_mask & 5158 CAM_QCOM_FEATURE_OPTIZOOM) > 0){ 5159 String8 optiZoomValues = createValuesStringFromMap( 5160 OPTI_ZOOM_MODES_MAP, 5161 PARAM_MAP_SIZE(OPTI_ZOOM_MODES_MAP)); 5162 set(KEY_QC_SUPPORTED_OPTI_ZOOM_MODES, optiZoomValues); 5163 setOptiZoom(OPTI_ZOOM_OFF); 5164 } 5165 5166 //Set HDR Type 5167 uint32_t supported_hdr_modes = m_pCapability->qcom_supported_feature_mask & 5168 (CAM_QCOM_FEATURE_SENSOR_HDR | CAM_QCOM_FEATURE_HDR); 5169 if (supported_hdr_modes) { 5170 if (CAM_QCOM_FEATURE_SENSOR_HDR == supported_hdr_modes) { 5171 String8 hdrModeValues; 5172 hdrModeValues.append(HDR_MODE_SENSOR); 5173 set(KEY_QC_SUPPORTED_KEY_QC_HDR_MODES, hdrModeValues); 5174 setHDRMode(HDR_MODE_SENSOR); 5175 } else if (CAM_QCOM_FEATURE_HDR == supported_hdr_modes) { 5176 String8 hdrModeValues; 5177 hdrModeValues.append(HDR_MODE_MULTI_FRAME); 5178 set(KEY_QC_SUPPORTED_KEY_QC_HDR_MODES, hdrModeValues); 5179 setHDRMode(HDR_MODE_MULTI_FRAME); 5180 } else { 5181 String8 hdrModeValues = createValuesStringFromMap( 5182 HDR_MODES_MAP, 5183 PARAM_MAP_SIZE(HDR_MODES_MAP)); 5184 set(KEY_QC_SUPPORTED_KEY_QC_HDR_MODES, hdrModeValues); 5185 setHDRMode(HDR_MODE_MULTI_FRAME); 5186 } 5187 } 5188 5189 //Set HDR need 1x 5190 String8 hdrNeed1xValues; 5191 if (!m_bHDRModeSensor) { 5192 hdrNeed1xValues = createValuesStringFromMap(TRUE_FALSE_MODES_MAP, 5193 PARAM_MAP_SIZE(TRUE_FALSE_MODES_MAP)); 5194 setHDRNeed1x(VALUE_TRUE); 5195 } else { 5196 hdrNeed1xValues.append(VALUE_FALSE); 5197 setHDRNeed1x(VALUE_FALSE); 5198 } 5199 set(KEY_QC_SUPPORTED_HDR_NEED_1X, hdrNeed1xValues); 5200 5201 //Set True Portrait 5202 if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_TRUEPORTRAIT) > 0) { 5203 String8 truePortraitValues = createValuesStringFromMap( 5204 TRUE_PORTRAIT_MODES_MAP, 5205 PARAM_MAP_SIZE(TRUE_PORTRAIT_MODES_MAP)); 5206 set(KEY_QC_SUPPORTED_TRUE_PORTRAIT_MODES, truePortraitValues); 5207 } 5208 5209 // Set Denoise 5210 if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_DENOISE2D) > 0){ 5211 String8 denoiseValues = createValuesStringFromMap( 5212 DENOISE_ON_OFF_MODES_MAP, PARAM_MAP_SIZE(DENOISE_ON_OFF_MODES_MAP)); 5213 set(KEY_QC_SUPPORTED_DENOISE, denoiseValues.string()); 5214 #ifdef DEFAULT_DENOISE_MODE_ON 5215 setWaveletDenoise(DENOISE_ON); 5216 #else 5217 setWaveletDenoise(DENOISE_OFF); 5218 #endif 5219 } 5220 5221 // Set feature enable/disable 5222 String8 enableDisableValues = createValuesStringFromMap( 5223 ENABLE_DISABLE_MODES_MAP, PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP)); 5224 5225 // Set Lens Shading 5226 set(KEY_QC_SUPPORTED_LENSSHADE_MODES, enableDisableValues); 5227 setLensShadeValue(VALUE_ENABLE); 5228 // Set MCE 5229 set(KEY_QC_SUPPORTED_MEM_COLOR_ENHANCE_MODES, enableDisableValues); 5230 setMCEValue(VALUE_ENABLE); 5231 5232 // Set DIS 5233 set(KEY_QC_SUPPORTED_DIS_MODES, enableDisableValues); 5234 setDISValue(VALUE_DISABLE); 5235 5236 // Set Histogram 5237 set(KEY_QC_SUPPORTED_HISTOGRAM_MODES, 5238 m_pCapability->histogram_supported ? enableDisableValues : ""); 5239 set(KEY_QC_HISTOGRAM, VALUE_DISABLE); 5240 5241 //Set Red Eye Reduction 5242 set(KEY_QC_SUPPORTED_REDEYE_REDUCTION, enableDisableValues); 5243 setRedeyeReduction(VALUE_DISABLE); 5244 5245 //Set SkinTone Enhancement 5246 set(KEY_QC_SUPPORTED_SKIN_TONE_ENHANCEMENT_MODES, enableDisableValues); 5247 5248 // Set feature on/off 5249 String8 onOffValues = createValuesStringFromMap( 5250 ON_OFF_MODES_MAP, PARAM_MAP_SIZE(ON_OFF_MODES_MAP)); 5251 5252 //Set See more (LLVD) 5253 if (m_pCapability->qcom_supported_feature_mask & 5254 CAM_QCOM_FEATURE_LLVD) { 5255 set(KEY_QC_SUPPORTED_SEE_MORE_MODES, onOffValues); 5256 setSeeMore(VALUE_OFF); 5257 } 5258 5259 //Set Still more 5260 if (m_pCapability->qcom_supported_feature_mask & 5261 CAM_QCOM_FEATURE_STILLMORE) { 5262 String8 stillMoreValues = createValuesStringFromMap( 5263 STILL_MORE_MODES_MAP, 5264 PARAM_MAP_SIZE(STILL_MORE_MODES_MAP)); 5265 set(KEY_QC_SUPPORTED_STILL_MORE_MODES, stillMoreValues); 5266 setStillMore(STILL_MORE_OFF); 5267 } 5268 5269 //Set Scene Detection 5270 set(KEY_QC_SUPPORTED_SCENE_DETECT, onOffValues); 5271 setSceneDetect(VALUE_OFF); 5272 m_bHDREnabled = false; 5273 m_bHDR1xFrameEnabled = true; 5274 5275 m_bHDRThumbnailProcessNeeded = false; 5276 m_bHDR1xExtraBufferNeeded = true; 5277 for (uint32_t i=0; i<m_pCapability->hdr_bracketing_setting.num_frames; i++) { 5278 if (0 == m_pCapability->hdr_bracketing_setting.exp_val.values[i]) { 5279 m_bHDR1xExtraBufferNeeded = false; 5280 break; 5281 } 5282 } 5283 5284 // Set HDR output scaling 5285 char value[PROPERTY_VALUE_MAX]; 5286 5287 property_get("persist.camera.hdr.outcrop", value, VALUE_DISABLE); 5288 if (strncmp(VALUE_ENABLE, value, sizeof(VALUE_ENABLE))) { 5289 m_bHDROutputCropEnabled = false; 5290 } else { 5291 m_bHDROutputCropEnabled = true; 5292 } 5293 5294 //Set Face Detection 5295 set(KEY_QC_SUPPORTED_FACE_DETECTION, onOffValues); 5296 set(KEY_QC_FACE_DETECTION, VALUE_OFF); 5297 5298 //Set Face Recognition 5299 //set(KEY_QC_SUPPORTED_FACE_RECOGNITION, onOffValues); 5300 //set(KEY_QC_FACE_RECOGNITION, VALUE_OFF); 5301 5302 //Set ZSL 5303 set(KEY_QC_SUPPORTED_ZSL_MODES, onOffValues); 5304 #ifdef DEFAULT_ZSL_MODE_ON 5305 set(KEY_QC_ZSL, VALUE_ON); 5306 m_bZslMode = true; 5307 #else 5308 set(KEY_QC_ZSL, VALUE_OFF); 5309 m_bZslMode = false; 5310 #endif 5311 5312 // Check if zsl mode property is enabled. 5313 // If yes, force the camera to be in zsl mode 5314 memset(value, 0x00, PROPERTY_VALUE_MAX); 5315 property_get("persist.camera.zsl.mode", value, "0"); 5316 int32_t zsl_mode = atoi(value); 5317 if(zsl_mode == 1) { 5318 CDBG_HIGH("%s: %d: Forcing Camera to ZSL mode ", __func__, __LINE__); 5319 set(KEY_QC_ZSL, VALUE_ON); 5320 m_bForceZslMode = true; 5321 m_bZslMode = true; 5322 } 5323 m_bZslMode_new = m_bZslMode; 5324 5325 set(KEY_QC_SCENE_SELECTION, VALUE_DISABLE); 5326 5327 // Rdi mode 5328 set(KEY_QC_SUPPORTED_RDI_MODES, enableDisableValues); 5329 setRdiMode(VALUE_DISABLE); 5330 5331 // Secure mode 5332 set(KEY_QC_SUPPORTED_SECURE_MODES, enableDisableValues); 5333 setSecureMode(VALUE_DISABLE); 5334 5335 //Set video HDR 5336 if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_VIDEO_HDR) > 0) { 5337 set(KEY_QC_SUPPORTED_VIDEO_HDR_MODES, onOffValues); 5338 set(KEY_QC_VIDEO_HDR, VALUE_OFF); 5339 } 5340 5341 //Set HW Sensor Snapshot HDR 5342 if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_SENSOR_HDR)> 0) { 5343 set(KEY_QC_SUPPORTED_SENSOR_HDR_MODES, onOffValues); 5344 set(KEY_QC_SENSOR_HDR, VALUE_OFF); 5345 m_bSensorHDREnabled = false; 5346 } 5347 5348 // Set VT TimeStamp 5349 set(KEY_QC_VT_ENABLE, VALUE_DISABLE); 5350 //Set Touch AF/AEC 5351 String8 touchValues = createValuesStringFromMap( 5352 TOUCH_AF_AEC_MODES_MAP, PARAM_MAP_SIZE(TOUCH_AF_AEC_MODES_MAP)); 5353 5354 set(KEY_QC_SUPPORTED_TOUCH_AF_AEC, touchValues); 5355 set(KEY_QC_TOUCH_AF_AEC, TOUCH_AF_AEC_OFF); 5356 5357 //set flip mode 5358 if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_FLIP) > 0) { 5359 String8 flipModes = createValuesStringFromMap( 5360 FLIP_MODES_MAP, PARAM_MAP_SIZE(FLIP_MODES_MAP)); 5361 set(KEY_QC_SUPPORTED_FLIP_MODES, flipModes); 5362 set(KEY_QC_PREVIEW_FLIP, FLIP_MODE_OFF); 5363 set(KEY_QC_VIDEO_FLIP, FLIP_MODE_OFF); 5364 set(KEY_QC_SNAPSHOT_PICTURE_FLIP, FLIP_MODE_OFF); 5365 } 5366 5367 // Set default Auto Exposure lock value 5368 setAecLock(VALUE_FALSE); 5369 5370 // Set default AWB_LOCK lock value 5371 setAwbLock(VALUE_FALSE); 5372 5373 // Set default Camera mode 5374 set(KEY_QC_CAMERA_MODE, 0); 5375 5376 // Add support for internal preview restart 5377 set(KEY_INTERNAL_PERVIEW_RESTART, VALUE_TRUE); 5378 // Set default burst number 5379 set(KEY_QC_SNAPSHOT_BURST_NUM, 0); 5380 set(KEY_QC_NUM_RETRO_BURST_PER_SHUTTER, 0); 5381 5382 //Get RAM size and disable features which are memory rich 5383 struct sysinfo info; 5384 sysinfo(&info); 5385 5386 CDBG_HIGH("%s: totalram = %ld, freeram = %ld ", __func__, info.totalram, 5387 info.freeram); 5388 if (info.totalram > TOTAL_RAM_SIZE_512MB) { 5389 set(KEY_QC_LONGSHOT_SUPPORTED, VALUE_TRUE); 5390 set(KEY_QC_ZSL_HDR_SUPPORTED, VALUE_TRUE); 5391 } else { 5392 set(KEY_QC_LONGSHOT_SUPPORTED, VALUE_FALSE); 5393 set(KEY_QC_ZSL_HDR_SUPPORTED, VALUE_FALSE); 5394 } 5395 5396 setOfflineRAW(); 5397 memset(mStreamPpMask, 0, sizeof(uint32_t)*CAM_STREAM_TYPE_MAX); 5398 5399 int32_t rc = commitParameters(); 5400 if (rc == NO_ERROR) { 5401 rc = setNumOfSnapshot(); 5402 } 5403 5404 //Set Video Rotation 5405 String8 videoRotationValues = createValuesStringFromMap(VIDEO_ROTATION_MODES_MAP, 5406 PARAM_MAP_SIZE(VIDEO_ROTATION_MODES_MAP)); 5407 5408 set(KEY_QC_SUPPORTED_VIDEO_ROTATION_VALUES, videoRotationValues.string()); 5409 set(KEY_QC_VIDEO_ROTATION, VIDEO_ROTATION_0); 5410 return rc; 5411 } 5412 5413 /*=========================================================================== 5414 * FUNCTION : init 5415 * 5416 * DESCRIPTION: initialize parameter obj 5417 * 5418 * PARAMETERS : 5419 * @capabilities : ptr to camera capabilities 5420 * @mmops : ptr to memory ops table for mapping/unmapping 5421 * @adjustFPS : object reference for additional (possibly thermal) 5422 * framerate adjustment 5423 * 5424 * RETURN : int32_t type of status 5425 * NO_ERROR -- success 5426 * none-zero failure code 5427 *==========================================================================*/ 5428 int32_t QCameraParameters::init(cam_capability_t *capabilities, 5429 mm_camera_vtbl_t *mmOps, QCameraAdjustFPS *adjustFPS) 5430 { 5431 int32_t rc = NO_ERROR; 5432 5433 m_pCapability = capabilities; 5434 m_pCamOpsTbl = mmOps; 5435 m_AdjustFPS = adjustFPS; 5436 5437 //Allocate Set Param Buffer 5438 m_pParamHeap = new QCameraHeapMemory(QCAMERA_ION_USE_CACHE); 5439 rc = m_pParamHeap->allocate(1, sizeof(parm_buffer_t), NON_SECURE); 5440 if(rc != OK) { 5441 rc = NO_MEMORY; 5442 ALOGE("Failed to allocate SETPARM Heap memory"); 5443 goto TRANS_INIT_ERROR1; 5444 } 5445 5446 //Map memory for parameters buffer 5447 rc = m_pCamOpsTbl->ops->map_buf(m_pCamOpsTbl->camera_handle, 5448 CAM_MAPPING_BUF_TYPE_PARM_BUF, 5449 m_pParamHeap->getFd(0), 5450 sizeof(parm_buffer_t)); 5451 if(rc < 0) { 5452 ALOGE("%s:failed to map SETPARM buffer",__func__); 5453 rc = FAILED_TRANSACTION; 5454 goto TRANS_INIT_ERROR2; 5455 } 5456 m_pParamBuf = (parm_buffer_t*) DATA_PTR(m_pParamHeap,0); 5457 5458 initDefaultParameters(); 5459 5460 m_bInited = true; 5461 5462 goto TRANS_INIT_DONE; 5463 5464 TRANS_INIT_ERROR2: 5465 m_pParamHeap->deallocate(); 5466 5467 TRANS_INIT_ERROR1: 5468 delete m_pParamHeap; 5469 m_pParamHeap = NULL; 5470 5471 TRANS_INIT_DONE: 5472 return rc; 5473 } 5474 5475 /*=========================================================================== 5476 * FUNCTION : deinit 5477 * 5478 * DESCRIPTION: deinitialize 5479 * 5480 * PARAMETERS : none 5481 * 5482 * RETURN : none 5483 *==========================================================================*/ 5484 void QCameraParameters::deinit() 5485 { 5486 if (!m_bInited) { 5487 return; 5488 } 5489 5490 //clear all entries in the map 5491 String8 emptyStr; 5492 QCameraParameters::unflatten(emptyStr); 5493 5494 if (NULL != m_pCamOpsTbl) { 5495 m_pCamOpsTbl->ops->unmap_buf( 5496 m_pCamOpsTbl->camera_handle, 5497 CAM_MAPPING_BUF_TYPE_PARM_BUF); 5498 m_pCamOpsTbl = NULL; 5499 } 5500 m_pCapability = NULL; 5501 if (NULL != m_pParamHeap) { 5502 m_pParamHeap->deallocate(); 5503 delete m_pParamHeap; 5504 m_pParamHeap = NULL; 5505 m_pParamBuf = NULL; 5506 } 5507 5508 m_AdjustFPS = NULL; 5509 5510 m_tempMap.clear(); 5511 5512 m_bInited = false; 5513 } 5514 5515 /*=========================================================================== 5516 * FUNCTION : parse_pair 5517 * 5518 * DESCRIPTION: helper function to parse string like "640x480" or "10000,20000" 5519 * 5520 * PARAMETERS : 5521 * @str : input string to be parse 5522 * @first : [output] first value of the pair 5523 * @second : [output] second value of the pair 5524 * @delim : [input] delimeter to seperate the pair 5525 * @endptr : [output] ptr to the end of the pair string 5526 * 5527 * RETURN : int32_t type of status 5528 * NO_ERROR -- success 5529 * none-zero failure code 5530 *==========================================================================*/ 5531 int32_t QCameraParameters::parse_pair(const char *str, 5532 int *first, 5533 int *second, 5534 char delim, 5535 char **endptr = NULL) 5536 { 5537 // Find the first integer. 5538 char *end; 5539 int w = (int)strtol(str, &end, 10); 5540 // If a delimeter does not immediately follow, give up. 5541 if (*end != delim) { 5542 ALOGE("Cannot find delimeter (%c) in str=%s", delim, str); 5543 return BAD_VALUE; 5544 } 5545 5546 // Find the second integer, immediately after the delimeter. 5547 int h = (int)strtol(end+1, &end, 10); 5548 5549 *first = w; 5550 *second = h; 5551 5552 if (endptr) { 5553 *endptr = end; 5554 } 5555 5556 return NO_ERROR; 5557 } 5558 5559 /*=========================================================================== 5560 * FUNCTION : parseSizesList 5561 * 5562 * DESCRIPTION: helper function to parse string containing sizes 5563 * 5564 * PARAMETERS : 5565 * @sizesStr: [input] input string to be parse 5566 * @sizes : [output] reference to store parsed sizes 5567 * 5568 * RETURN : none 5569 *==========================================================================*/ 5570 void QCameraParameters::parseSizesList(const char *sizesStr, Vector<Size> &sizes) 5571 { 5572 if (sizesStr == 0) { 5573 return; 5574 } 5575 5576 char *sizeStartPtr = (char *)sizesStr; 5577 5578 while (true) { 5579 int width, height; 5580 int success = parse_pair(sizeStartPtr, &width, &height, 'x', 5581 &sizeStartPtr); 5582 if (success == -1 || (*sizeStartPtr != ',' && *sizeStartPtr != '\0')) { 5583 ALOGE("Picture sizes string \"%s\" contains invalid character.", sizesStr); 5584 return; 5585 } 5586 sizes.push(Size(width, height)); 5587 5588 if (*sizeStartPtr == '\0') { 5589 return; 5590 } 5591 sizeStartPtr++; 5592 } 5593 } 5594 5595 /*=========================================================================== 5596 * FUNCTION : getSupportedHfrSizes 5597 * 5598 * DESCRIPTION: return supported HFR sizes 5599 * 5600 * PARAMETERS : 5601 * @sizes : [output] reference to a vector storing supported HFR sizes 5602 * 5603 * RETURN : none 5604 *==========================================================================*/ 5605 void QCameraParameters::getSupportedHfrSizes(Vector<Size> &sizes) 5606 { 5607 const char *hfrSizesStr = get(KEY_QC_SUPPORTED_HFR_SIZES); 5608 parseSizesList(hfrSizesStr, sizes); 5609 } 5610 5611 /*=========================================================================== 5612 * FUNCTION : adjustPreviewFpsRanges 5613 * 5614 * DESCRIPTION: adjust preview FPS ranges 5615 * according to external events 5616 * 5617 * PARAMETERS : 5618 * @minFPS : min FPS value 5619 * @maxFPS : max FPS value 5620 * 5621 * RETURN : int32_t type of status 5622 * NO_ERROR -- success 5623 * none-zero failure code 5624 *==========================================================================*/ 5625 int32_t QCameraParameters::adjustPreviewFpsRange(cam_fps_range_t *fpsRange) 5626 { 5627 if ( fpsRange == NULL ) { 5628 return BAD_VALUE; 5629 } 5630 5631 if ( m_pParamBuf == NULL ) { 5632 return NO_INIT; 5633 } 5634 5635 int32_t rc = initBatchUpdate(m_pParamBuf); 5636 if ( rc != NO_ERROR ) { 5637 ALOGE("%s:Failed to initialize group update table", __func__); 5638 return rc; 5639 } 5640 5641 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_FPS_RANGE, *fpsRange)) { 5642 ALOGE("%s: Parameters batch failed",__func__); 5643 return BAD_VALUE; 5644 } 5645 5646 rc = commitSetBatch(); 5647 if ( rc != NO_ERROR ) { 5648 ALOGE("%s:Failed to commit batch parameters", __func__); 5649 return rc; 5650 } 5651 5652 return rc; 5653 } 5654 5655 /*=========================================================================== 5656 * FUNCTION : setPreviewFpsRanges 5657 * 5658 * DESCRIPTION: set preview FPS ranges 5659 * 5660 * PARAMETERS : 5661 * @minFPS : min FPS value 5662 * @maxFPS : max FPS value 5663 * 5664 * RETURN : int32_t type of status 5665 * NO_ERROR -- success 5666 * none-zero failure code 5667 *==========================================================================*/ 5668 int32_t QCameraParameters::setPreviewFpsRange(int min_fps, 5669 int max_fps, int vid_min_fps,int vid_max_fps) 5670 { 5671 char str[32]; 5672 char value[PROPERTY_VALUE_MAX]; 5673 int fixedFpsValue; 5674 /*This property get value should be the fps that user needs*/ 5675 property_get("persist.debug.set.fixedfps", value, "0"); 5676 fixedFpsValue = atoi(value); 5677 5678 CDBG("%s: E minFps = %d, maxFps = %d , vid minFps = %d, vid maxFps = %d", 5679 __func__, min_fps, max_fps, vid_min_fps, vid_max_fps); 5680 5681 if(fixedFpsValue != 0) { 5682 min_fps = (int)fixedFpsValue*1000; 5683 max_fps = (int)fixedFpsValue*1000; 5684 } 5685 snprintf(str, sizeof(str), "%d,%d", min_fps, max_fps); 5686 CDBG_HIGH("%s: Setting preview fps range %s", __func__, str); 5687 updateParamEntry(KEY_PREVIEW_FPS_RANGE, str); 5688 cam_fps_range_t fps_range; 5689 memset(&fps_range, 0x00, sizeof(cam_fps_range_t)); 5690 fps_range.min_fps = (float)min_fps / 1000.0f; 5691 fps_range.max_fps = (float)max_fps / 1000.0f; 5692 fps_range.video_min_fps = (float)vid_min_fps / 1000.0f; 5693 fps_range.video_max_fps = (float)vid_max_fps / 1000.0f; 5694 5695 CDBG_HIGH("%s: Updated: minFps = %d, maxFps = %d ," 5696 " vid minFps = %d, vid maxFps = %d", 5697 __func__, min_fps, max_fps, vid_min_fps, vid_max_fps); 5698 5699 if ( NULL != m_AdjustFPS ) { 5700 m_AdjustFPS->recalcFPSRange(min_fps, max_fps, fps_range); 5701 CDBG_HIGH("%s: Thermal adjusted Preview fps range %3.2f,%3.2f, %3.2f, %3.2f", 5702 __func__, fps_range.min_fps, fps_range.max_fps, 5703 fps_range.video_min_fps, fps_range.video_max_fps); 5704 } 5705 5706 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_FPS_RANGE, fps_range)) { 5707 return BAD_VALUE; 5708 } 5709 5710 return NO_ERROR; 5711 } 5712 5713 5714 5715 /*=========================================================================== 5716 * FUNCTION : setAutoExposure 5717 * 5718 * DESCRIPTION: set auto exposure 5719 * 5720 * PARAMETERS : 5721 * @autoExp : auto exposure value string 5722 * 5723 * RETURN : int32_t type of status 5724 * NO_ERROR -- success 5725 * none-zero failure code 5726 *==========================================================================*/ 5727 int32_t QCameraParameters::setAutoExposure(const char *autoExp) 5728 { 5729 if (autoExp != NULL) { 5730 int32_t value = lookupAttr(AUTO_EXPOSURE_MAP, PARAM_MAP_SIZE(AUTO_EXPOSURE_MAP), autoExp); 5731 if (value != NAME_NOT_FOUND) { 5732 CDBG_HIGH("%s: Setting auto exposure %s", __func__, autoExp); 5733 updateParamEntry(KEY_QC_AUTO_EXPOSURE, autoExp); 5734 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_AEC_ALGO_TYPE, value)) { 5735 return BAD_VALUE; 5736 } 5737 return NO_ERROR; 5738 } 5739 } 5740 ALOGE("Invalid auto exposure value: %s", (autoExp == NULL) ? "NULL" : autoExp); 5741 return BAD_VALUE; 5742 } 5743 5744 /*=========================================================================== 5745 * FUNCTION : setEffect 5746 * 5747 * DESCRIPTION: set effect 5748 * 5749 * PARAMETERS : 5750 * @effect : effect value string 5751 * 5752 * RETURN : int32_t type of status 5753 * NO_ERROR -- success 5754 * none-zero failure code 5755 *==========================================================================*/ 5756 int32_t QCameraParameters::setEffect(const char *effect) 5757 { 5758 if (effect != NULL) { 5759 int32_t value = lookupAttr(EFFECT_MODES_MAP, PARAM_MAP_SIZE(EFFECT_MODES_MAP), effect); 5760 if (value != NAME_NOT_FOUND) { 5761 CDBG_HIGH("%s: Setting effect %s", __func__, effect); 5762 updateParamEntry(KEY_EFFECT, effect); 5763 uint8_t prmEffect = static_cast<uint8_t>(value); 5764 mParmEffect = prmEffect; 5765 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_EFFECT, prmEffect)) { 5766 return BAD_VALUE; 5767 } 5768 return NO_ERROR; 5769 } 5770 } 5771 ALOGE("Invalid effect value: %s", (effect == NULL) ? "NULL" : effect); 5772 return BAD_VALUE; 5773 } 5774 5775 /*=========================================================================== 5776 * FUNCTION : setBrightness 5777 * 5778 * DESCRIPTION: set brightness control value 5779 * 5780 * PARAMETERS : 5781 * @brightness : brightness control value 5782 * 5783 * RETURN : int32_t type of status 5784 * NO_ERROR -- success 5785 * none-zero failure code 5786 *==========================================================================*/ 5787 int32_t QCameraParameters::setBrightness(int brightness) 5788 { 5789 char val[16]; 5790 snprintf(val, sizeof(val), "%d", brightness); 5791 updateParamEntry(KEY_QC_BRIGHTNESS, val); 5792 5793 CDBG_HIGH("%s: Setting brightness %s", __func__, val); 5794 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_BRIGHTNESS, brightness)) { 5795 return BAD_VALUE; 5796 } 5797 5798 return NO_ERROR; 5799 } 5800 5801 /*=========================================================================== 5802 * FUNCTION : setFocusMode 5803 * 5804 * DESCRIPTION: set focus mode 5805 * 5806 * PARAMETERS : 5807 * @focusMode : focus mode value string 5808 * 5809 * RETURN : int32_t type of status 5810 * NO_ERROR -- success 5811 * none-zero failure code 5812 *==========================================================================*/ 5813 int32_t QCameraParameters::setFocusMode(const char *focusMode) 5814 { 5815 if (focusMode != NULL) { 5816 int32_t value = lookupAttr(FOCUS_MODES_MAP, PARAM_MAP_SIZE(FOCUS_MODES_MAP), focusMode); 5817 if (value != NAME_NOT_FOUND) { 5818 int32_t rc = NO_ERROR; 5819 CDBG_HIGH("%s: Setting focus mode %s", __func__, focusMode); 5820 mFocusMode = (cam_focus_mode_type)value; 5821 5822 updateParamEntry(KEY_FOCUS_MODE, focusMode); 5823 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, 5824 CAM_INTF_PARM_FOCUS_MODE, (uint8_t)value)) { 5825 rc = BAD_VALUE; 5826 } 5827 if (strcmp(focusMode,"infinity")==0){ 5828 set(QCameraParameters::KEY_FOCUS_DISTANCES, "Infinity,Infinity,Infinity"); 5829 } 5830 return rc; 5831 } 5832 } 5833 ALOGE("Invalid focus mode value: %s", (focusMode == NULL) ? "NULL" : focusMode); 5834 return BAD_VALUE; 5835 } 5836 5837 /*=========================================================================== 5838 * FUNCTION : setFocusPosition 5839 * 5840 * DESCRIPTION: set focus position 5841 * 5842 * PARAMETERS : 5843 * @typeStr : focus position type, index or dac_code 5844 * @posStr : focus positon. 5845 * 5846 * RETURN : int32_t type of status 5847 * NO_ERROR -- success 5848 * none-zero failure code 5849 *==========================================================================*/ 5850 int32_t QCameraParameters::setFocusPosition(const char *typeStr, const char *posStr) 5851 { 5852 CDBG_HIGH("%s, type:%s, pos: %s", __func__, typeStr, posStr); 5853 int32_t type = atoi(typeStr); 5854 float pos = (float) atof(posStr); 5855 5856 if ((type >= CAM_MANUAL_FOCUS_MODE_INDEX) && 5857 (type < CAM_MANUAL_FOCUS_MODE_MAX)) { 5858 // get max and min focus position from m_pCapability 5859 int32_t minFocusPos = (int32_t) m_pCapability->min_focus_pos[type]; 5860 int32_t maxFocusPos = (int32_t) m_pCapability->max_focus_pos[type]; 5861 CDBG_HIGH("%s, focusPos min: %d, max: %d", __func__, minFocusPos, maxFocusPos); 5862 5863 if (pos >= minFocusPos && pos <= maxFocusPos) { 5864 updateParamEntry(KEY_QC_MANUAL_FOCUS_POS_TYPE, typeStr); 5865 updateParamEntry(KEY_QC_MANUAL_FOCUS_POSITION, posStr); 5866 5867 cam_manual_focus_parm_t manual_focus; 5868 manual_focus.flag = (cam_manual_focus_mode_type)type; 5869 if (manual_focus.flag == CAM_MANUAL_FOCUS_MODE_DIOPTER) { 5870 manual_focus.af_manual_diopter = pos; 5871 } else if (manual_focus.flag == CAM_MANUAL_FOCUS_MODE_RATIO) { 5872 manual_focus.af_manual_lens_position_ratio = (int32_t) pos; 5873 } else if (manual_focus.flag == CAM_MANUAL_FOCUS_MODE_INDEX) { 5874 manual_focus.af_manual_lens_position_index = (int32_t) pos; 5875 } else { 5876 manual_focus.af_manual_lens_position_dac = (int32_t) pos; 5877 } 5878 5879 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_MANUAL_FOCUS_POS, 5880 manual_focus)) { 5881 return BAD_VALUE; 5882 } 5883 return NO_ERROR; 5884 } 5885 } 5886 5887 ALOGE("%s, invalid params, type:%d, pos: %d", __func__, type, pos); 5888 return BAD_VALUE; 5889 } 5890 5891 /*=========================================================================== 5892 * FUNCTION : updateAEInfo 5893 * 5894 * DESCRIPTION: update exposure information from metadata callback 5895 * 5896 * PARAMETERS : 5897 * @ae_params : auto exposure params 5898 * 5899 * RETURN : void 5900 *==========================================================================*/ 5901 void QCameraParameters::updateAEInfo(cam_3a_params_t &ae_params) 5902 { 5903 const char *prevExpTime = get(KEY_QC_CURRENT_EXPOSURE_TIME); 5904 char newExpTime[15]; 5905 snprintf(newExpTime, sizeof(newExpTime), "%f", ae_params.exp_time*1000.0); 5906 5907 if (prevExpTime == NULL || strcmp(prevExpTime, newExpTime)) { 5908 CDBG("update exposure time: old: %s, new: %s", prevExpTime, newExpTime); 5909 set(KEY_QC_CURRENT_EXPOSURE_TIME, newExpTime); 5910 } 5911 5912 int32_t prevISO = getInt(KEY_QC_CURRENT_ISO); 5913 int32_t newISO = ae_params.iso_value; 5914 if (prevISO != newISO) { 5915 CDBG("update iso: old:%d, new:%d", prevISO, newISO); 5916 set(KEY_QC_CURRENT_ISO, newISO); 5917 } 5918 } 5919 5920 /*=========================================================================== 5921 * FUNCTION : updateCurrentFocusPosition 5922 * 5923 * DESCRIPTION: update current focus position from metadata callback 5924 * 5925 * PARAMETERS : 5926 * @pos : current focus position 5927 * 5928 * RETURN : void 5929 *==========================================================================*/ 5930 void QCameraParameters::updateCurrentFocusPosition(cam_focus_pos_info_t &cur_pos_info) 5931 { 5932 int prevScalePos = getInt(KEY_QC_FOCUS_POSITION_SCALE); 5933 int newScalePos = (int) cur_pos_info.scale; 5934 if (prevScalePos != newScalePos) { 5935 CDBG("update focus scale: old:%d, new:%d", prevScalePos, newScalePos); 5936 set(KEY_QC_FOCUS_POSITION_SCALE, newScalePos); 5937 } 5938 5939 float prevDiopterPos = getFloat(KEY_QC_FOCUS_POSITION_DIOPTER); 5940 float newDiopterPos = cur_pos_info.diopter; 5941 if (prevDiopterPos != newDiopterPos) { 5942 CDBG("update focus diopter: old:%f, new:%f", prevDiopterPos, newDiopterPos); 5943 setFloat(KEY_QC_FOCUS_POSITION_DIOPTER, newDiopterPos); 5944 } 5945 } 5946 5947 /*=========================================================================== 5948 * FUNCTION : setSharpness 5949 * 5950 * DESCRIPTION: set sharpness control value 5951 * 5952 * PARAMETERS : 5953 * @sharpness : sharpness control value 5954 * 5955 * RETURN : int32_t type of status 5956 * NO_ERROR -- success 5957 * none-zero failure code 5958 *==========================================================================*/ 5959 int32_t QCameraParameters::setSharpness(int sharpness) 5960 { 5961 char val[16]; 5962 snprintf(val, sizeof(val), "%d", sharpness); 5963 updateParamEntry(KEY_QC_SHARPNESS, val); 5964 CDBG_HIGH("%s: Setting sharpness %s", __func__, val); 5965 m_nSharpness = sharpness; 5966 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_SHARPNESS, m_nSharpness)) { 5967 return BAD_VALUE; 5968 } 5969 5970 return NO_ERROR; 5971 } 5972 5973 /*=========================================================================== 5974 * FUNCTION : setSkinToneEnhancement 5975 * 5976 * DESCRIPTION: set skin tone enhancement value 5977 * 5978 * PARAMETERS : 5979 * @sceFactore : skin tone enhancement factor value 5980 * 5981 * RETURN : int32_t type of status 5982 * NO_ERROR -- success 5983 * none-zero failure code 5984 *==========================================================================*/ 5985 int32_t QCameraParameters::setSkinToneEnhancement(int sceFactor) 5986 { 5987 char val[16]; 5988 snprintf(val, sizeof(val), "%d", sceFactor); 5989 updateParamEntry(KEY_QC_SCE_FACTOR, val); 5990 CDBG_HIGH("%s: Setting skintone enhancement %s", __func__, val); 5991 5992 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_SCE_FACTOR, sceFactor)) { 5993 return BAD_VALUE; 5994 } 5995 5996 return NO_ERROR; 5997 } 5998 5999 /*=========================================================================== 6000 * FUNCTION : setSaturation 6001 * 6002 * DESCRIPTION: set saturation control value 6003 * 6004 * PARAMETERS : 6005 * @saturation : saturation control value 6006 * 6007 * RETURN : int32_t type of status 6008 * NO_ERROR -- success 6009 * none-zero failure code 6010 *==========================================================================*/ 6011 int32_t QCameraParameters::setSaturation(int saturation) 6012 { 6013 char val[16]; 6014 snprintf(val, sizeof(val), "%d", saturation); 6015 updateParamEntry(KEY_QC_SATURATION, val); 6016 CDBG_HIGH("%s: Setting saturation %s", __func__, val); 6017 6018 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_SATURATION, saturation)) { 6019 return BAD_VALUE; 6020 } 6021 6022 return NO_ERROR; 6023 } 6024 6025 /*=========================================================================== 6026 * FUNCTION : setContrast 6027 * 6028 * DESCRIPTION: set contrast control value 6029 * 6030 * PARAMETERS : 6031 * @contrast : contrast control value 6032 * 6033 * RETURN : int32_t type of status 6034 * NO_ERROR -- success 6035 * none-zero failure code 6036 *==========================================================================*/ 6037 int32_t QCameraParameters::setContrast(int contrast) 6038 { 6039 char val[16]; 6040 snprintf(val, sizeof(val), "%d", contrast); 6041 updateParamEntry(KEY_QC_CONTRAST, val); 6042 CDBG_HIGH("%s: Setting contrast %s", __func__, val); 6043 6044 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_CONTRAST, contrast)) { 6045 return BAD_VALUE; 6046 } 6047 6048 return NO_ERROR; 6049 } 6050 6051 /*=========================================================================== 6052 * FUNCTION : setSceneDetect 6053 * 6054 * DESCRIPTION: set scenen detect value 6055 * 6056 * PARAMETERS : 6057 * @sceneDetect : scene detect value string 6058 * 6059 * RETURN : int32_t type of status 6060 * NO_ERROR -- success 6061 * none-zero failure code 6062 *==========================================================================*/ 6063 int32_t QCameraParameters::setSceneDetect(const char *sceneDetect) 6064 { 6065 if (sceneDetect != NULL) { 6066 int32_t value = lookupAttr(ON_OFF_MODES_MAP, PARAM_MAP_SIZE(ON_OFF_MODES_MAP), 6067 sceneDetect); 6068 if (value != NAME_NOT_FOUND) { 6069 CDBG_HIGH("%s: Setting Scene Detect %s", __func__, sceneDetect); 6070 updateParamEntry(KEY_QC_SCENE_DETECT, sceneDetect); 6071 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_ASD_ENABLE, value)) { 6072 return BAD_VALUE; 6073 } 6074 return NO_ERROR; 6075 } 6076 } 6077 ALOGE("Invalid Scene Detect value: %s", 6078 (sceneDetect == NULL) ? "NULL" : sceneDetect); 6079 return BAD_VALUE; 6080 } 6081 6082 /*=========================================================================== 6083 * FUNCTION : setSensorSnapshotHDR 6084 * 6085 * DESCRIPTION: set snapshot HDR value 6086 * 6087 * PARAMETERS : 6088 * @snapshotHDR : snapshot HDR value string 6089 * 6090 * RETURN : int32_t type of status 6091 * NO_ERROR -- success 6092 * none-zero failure code 6093 *==========================================================================*/ 6094 int32_t QCameraParameters::setSensorSnapshotHDR(const char *snapshotHDR) 6095 { 6096 if (snapshotHDR != NULL) { 6097 int32_t value = lookupAttr(ON_OFF_MODES_MAP, PARAM_MAP_SIZE(ON_OFF_MODES_MAP), 6098 snapshotHDR); 6099 if (value != NAME_NOT_FOUND) { 6100 CDBG_HIGH("%s: Setting Sensor Snapshot HDR %s", __func__, snapshotHDR); 6101 updateParamEntry(KEY_QC_SENSOR_HDR, snapshotHDR); 6102 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_SENSOR_HDR, value)) { 6103 return BAD_VALUE; 6104 } 6105 return NO_ERROR; 6106 } 6107 } 6108 ALOGE("Invalid Snapshot HDR value: %s", 6109 (snapshotHDR == NULL) ? "NULL" : snapshotHDR); 6110 return BAD_VALUE; 6111 6112 } 6113 6114 6115 /*=========================================================================== 6116 * FUNCTION : setVideoHDR 6117 * 6118 * DESCRIPTION: set video HDR value 6119 * 6120 * PARAMETERS : 6121 * @videoHDR : svideo HDR value string 6122 * 6123 * RETURN : int32_t type of status 6124 * NO_ERROR -- success 6125 * none-zero failure code 6126 *==========================================================================*/ 6127 int32_t QCameraParameters::setVideoHDR(const char *videoHDR) 6128 { 6129 if (videoHDR != NULL) { 6130 int32_t value = lookupAttr(ON_OFF_MODES_MAP, PARAM_MAP_SIZE(ON_OFF_MODES_MAP), videoHDR); 6131 if (value != NAME_NOT_FOUND) { 6132 CDBG_HIGH("%s: Setting Video HDR %s", __func__, videoHDR); 6133 updateParamEntry(KEY_QC_VIDEO_HDR, videoHDR); 6134 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_VIDEO_HDR, value)) { 6135 return BAD_VALUE; 6136 } 6137 return NO_ERROR; 6138 } 6139 } 6140 ALOGE("Invalid Video HDR value: %s", 6141 (videoHDR == NULL) ? "NULL" : videoHDR); 6142 return BAD_VALUE; 6143 } 6144 6145 6146 6147 /*=========================================================================== 6148 * FUNCTION : setVtEnable 6149 * 6150 * DESCRIPTION: set vt Enable value 6151 * 6152 * PARAMETERS : 6153 * @videoHDR : svtEnable value string 6154 * 6155 * RETURN : int32_t type of status 6156 * NO_ERROR -- success 6157 * none-zero failure code 6158 *==========================================================================*/ 6159 int32_t QCameraParameters::setVtEnable(const char *vtEnable) 6160 { 6161 if (vtEnable != NULL) { 6162 int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP, 6163 PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP), vtEnable); 6164 if (value != NAME_NOT_FOUND) { 6165 CDBG_HIGH("%s: Setting Vt Enable %s", __func__, vtEnable); 6166 m_bAVTimerEnabled = true; 6167 updateParamEntry(KEY_QC_VT_ENABLE, vtEnable); 6168 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_VT, value)) { 6169 return BAD_VALUE; 6170 } 6171 return NO_ERROR; 6172 } 6173 } 6174 ALOGE("Invalid Vt Enable value: %s", 6175 (vtEnable == NULL) ? "NULL" : vtEnable); 6176 m_bAVTimerEnabled = false; 6177 return BAD_VALUE; 6178 } 6179 6180 /*=========================================================================== 6181 * FUNCTION : setFaceRecognition 6182 * 6183 * DESCRIPTION: set face recognition value 6184 * 6185 * PARAMETERS : 6186 * @faceRecog : face recognition value string 6187 * @maxFaces : number of max faces to be detected/recognized 6188 * 6189 * RETURN : int32_t type of status 6190 * NO_ERROR -- success 6191 * none-zero failure code 6192 *==========================================================================*/ 6193 int32_t QCameraParameters::setFaceRecognition(const char *faceRecog, 6194 uint32_t maxFaces) 6195 { 6196 if (faceRecog != NULL) { 6197 int32_t value = lookupAttr(ON_OFF_MODES_MAP, PARAM_MAP_SIZE(ON_OFF_MODES_MAP), faceRecog); 6198 if (value != NAME_NOT_FOUND) { 6199 CDBG_HIGH("%s: Setting face recognition %s", __func__, faceRecog); 6200 updateParamEntry(KEY_QC_FACE_RECOGNITION, faceRecog); 6201 6202 uint32_t faceProcMask = m_nFaceProcMask; 6203 if (value > 0) { 6204 faceProcMask |= CAM_FACE_PROCESS_MASK_RECOGNITION; 6205 } else { 6206 faceProcMask &= (uint32_t)(~CAM_FACE_PROCESS_MASK_RECOGNITION); 6207 } 6208 6209 if(m_nFaceProcMask == faceProcMask) { 6210 CDBG_HIGH("%s: face process mask not changed, no ops here", __func__); 6211 return NO_ERROR; 6212 } 6213 m_nFaceProcMask = faceProcMask; 6214 CDBG_HIGH("%s: FaceProcMask -> %d", __func__, m_nFaceProcMask); 6215 6216 // set parm for face process 6217 cam_fd_set_parm_t fd_set_parm; 6218 memset(&fd_set_parm, 0, sizeof(cam_fd_set_parm_t)); 6219 fd_set_parm.fd_mode = m_nFaceProcMask; 6220 fd_set_parm.num_fd = maxFaces; 6221 6222 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_FD, fd_set_parm)) { 6223 return BAD_VALUE; 6224 } 6225 return NO_ERROR; 6226 } 6227 } 6228 ALOGE("Invalid face recognition value: %s", (faceRecog == NULL) ? "NULL" : faceRecog); 6229 return BAD_VALUE; 6230 } 6231 6232 /*=========================================================================== 6233 * FUNCTION : setZoom 6234 * 6235 * DESCRIPTION: set zoom level 6236 * 6237 * PARAMETERS : 6238 * @zoom_level : zoom level 6239 * 6240 * RETURN : int32_t type of status 6241 * NO_ERROR -- success 6242 * none-zero failure code 6243 *==========================================================================*/ 6244 int32_t QCameraParameters::setZoom(int zoom_level) 6245 { 6246 char val[16]; 6247 snprintf(val, sizeof(val), "%d", zoom_level); 6248 updateParamEntry(KEY_ZOOM, val); 6249 CDBG_HIGH("%s: zoom level: %d", __func__, zoom_level); 6250 mZoomLevel = zoom_level; 6251 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_ZOOM, zoom_level)) { 6252 return BAD_VALUE; 6253 } 6254 6255 return NO_ERROR; 6256 } 6257 6258 /*=========================================================================== 6259 * FUNCTION : setISOValue 6260 * 6261 * DESCRIPTION: set ISO value 6262 * 6263 * PARAMETERS : 6264 * @isoValue : ISO value string 6265 * 6266 * RETURN : int32_t type of status 6267 * NO_ERROR -- success 6268 * none-zero failure code 6269 *==========================================================================*/ 6270 int32_t QCameraParameters::setISOValue(const char *isoValue) 6271 { 6272 if (isoValue != NULL) { 6273 if (!strcmp(isoValue, ISO_MANUAL)) { 6274 CDBG("%s, iso manual mode - use continuous iso", __func__); 6275 updateParamEntry(KEY_QC_ISO_MODE, isoValue); 6276 return NO_ERROR; 6277 } 6278 int32_t value = lookupAttr(ISO_MODES_MAP, PARAM_MAP_SIZE(ISO_MODES_MAP), isoValue); 6279 if (value != NAME_NOT_FOUND) { 6280 CDBG_HIGH("%s: Setting ISO value %s", __func__, isoValue); 6281 updateParamEntry(KEY_QC_ISO_MODE, isoValue); 6282 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_ISO, value)) { 6283 return BAD_VALUE; 6284 } 6285 return NO_ERROR; 6286 } 6287 } 6288 ALOGE("Invalid ISO value: %s", 6289 (isoValue == NULL) ? "NULL" : isoValue); 6290 return BAD_VALUE; 6291 } 6292 6293 6294 /*=========================================================================== 6295 * FUNCTION : setContinuousISO 6296 * 6297 * DESCRIPTION: set continuous ISO value 6298 * 6299 * PARAMETERS : 6300 * @params : ISO value parameter 6301 * 6302 * RETURN : int32_t type of status 6303 * NO_ERROR -- success 6304 * none-zero failure code 6305 *==========================================================================*/ 6306 int32_t QCameraParameters::setContinuousISO(const QCameraParameters& params) 6307 { 6308 const char *iso = params.get(KEY_QC_ISO_MODE); 6309 CDBG("%s, current iso mode: %s", __func__, iso); 6310 6311 if (iso != NULL) { 6312 if (strcmp(iso, ISO_MANUAL)) { 6313 CDBG("%s, dont set iso to back-end.", __func__); 6314 return NO_ERROR; 6315 } 6316 } 6317 6318 const char *str = params.get(KEY_QC_CONTINUOUS_ISO); 6319 const char *prev_str = get(KEY_QC_CONTINUOUS_ISO); 6320 if (str != NULL) { 6321 if (prev_str == NULL || 6322 strcmp(str, prev_str) != 0) { 6323 return setContinuousISO(str); 6324 } 6325 } 6326 return NO_ERROR; 6327 } 6328 6329 /*=========================================================================== 6330 * FUNCTION : setExposureTime 6331 * 6332 * DESCRIPTION: set exposure time 6333 * 6334 * PARAMETERS : 6335 * @expTimeStr : string of exposure time in ms 6336 * 6337 * RETURN : int32_t type of status 6338 * NO_ERROR -- success 6339 * none-zero failure code 6340 *==========================================================================*/ 6341 int32_t QCameraParameters::setExposureTime(const char *expTimeStr) 6342 { 6343 if (expTimeStr != NULL) { 6344 double expTimeMs = atof(expTimeStr); 6345 //input is in milli seconds. Convert to nano sec for backend 6346 int64_t expTimeNs = ((int64_t)expTimeMs)*1000000L; 6347 6348 // expTime == 0 means not to use manual exposure time. 6349 if ((0 <= expTimeNs) && 6350 ((expTimeNs == 0) || 6351 ((expTimeNs >= m_pCapability->exposure_time_range[0]) && 6352 (expTimeNs <= m_pCapability->exposure_time_range[1])))) { 6353 CDBG_HIGH("%s, exposure time: %f ms", __func__, expTimeMs); 6354 updateParamEntry(KEY_QC_EXPOSURE_TIME, expTimeStr); 6355 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_EXPOSURE_TIME, 6356 (uint64_t)expTimeNs)) { 6357 return BAD_VALUE; 6358 } 6359 return NO_ERROR; 6360 } 6361 } 6362 6363 ALOGE("Invalid exposure time, value: %s", 6364 (expTimeStr == NULL) ? "NULL" : expTimeStr); 6365 return BAD_VALUE; 6366 } 6367 6368 /*=========================================================================== 6369 * FUNCTION : setLongshotEnable 6370 * 6371 * DESCRIPTION: set a flag indicating longshot mode 6372 * 6373 * PARAMETERS : 6374 * @enable : true - Longshot enabled 6375 * false - Longshot disabled 6376 * 6377 * RETURN : int32_t type of status 6378 * NO_ERROR -- success 6379 * none-zero failure code 6380 *==========================================================================*/ 6381 int32_t QCameraParameters::setLongshotEnable(bool enable) 6382 { 6383 int32_t rc = NO_ERROR; 6384 int8_t value = enable ? 1 : 0; 6385 6386 if(initBatchUpdate(m_pParamBuf) < 0 ) { 6387 ALOGE("%s:Failed to initialize group update table", __func__); 6388 return BAD_TYPE; 6389 } 6390 6391 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_LONGSHOT_ENABLE, value)) { 6392 ALOGE("%s:Failed to update table", __func__); 6393 return BAD_VALUE; 6394 } 6395 6396 rc = commitSetBatch(); 6397 if (rc != NO_ERROR) { 6398 ALOGE("%s:Failed to parameter changes", __func__); 6399 return rc; 6400 } 6401 6402 return rc; 6403 } 6404 6405 /*=========================================================================== 6406 * FUNCTION : setFlash 6407 * 6408 * DESCRIPTION: set flash mode 6409 * 6410 * PARAMETERS : 6411 * @flashStr : LED flash mode value string 6412 * 6413 * RETURN : int32_t type of status 6414 * NO_ERROR -- success 6415 * none-zero failure code 6416 *==========================================================================*/ 6417 int32_t QCameraParameters::setFlash(const char *flashStr) 6418 { 6419 if (flashStr != NULL) { 6420 int32_t value = lookupAttr(FLASH_MODES_MAP, PARAM_MAP_SIZE(FLASH_MODES_MAP), flashStr); 6421 if (value != NAME_NOT_FOUND) { 6422 CDBG_HIGH("%s: Setting Flash value %s", __func__, flashStr); 6423 updateParamEntry(KEY_FLASH_MODE, flashStr); 6424 mFlashValue = value; 6425 return NO_ERROR; 6426 } 6427 } 6428 ALOGE("Invalid flash value: %s", (flashStr == NULL) ? "NULL" : flashStr); 6429 return BAD_VALUE; 6430 } 6431 6432 /*=========================================================================== 6433 * FUNCTION : updateFlashMode 6434 * 6435 * DESCRIPTION: update flash mode 6436 * 6437 * PARAMETERS : 6438 * @flashStr : LED flash mode value 6439 * 6440 * RETURN : int32_t type of status 6441 * NO_ERROR -- success 6442 * none-zero failure code 6443 *==========================================================================*/ 6444 int32_t QCameraParameters::updateFlashMode(cam_flash_mode_t flash_mode) 6445 { 6446 int32_t rc = NO_ERROR; 6447 if (flash_mode >= CAM_FLASH_MODE_MAX) { 6448 CDBG_HIGH("%s: Error!! Invalid flash mode (%d)", __func__, flash_mode); 6449 return BAD_VALUE; 6450 } 6451 CDBG_HIGH("%s: Setting Flash mode from EZTune %d", __func__, flash_mode); 6452 6453 const char *flash_mode_str = lookupNameByValue(FLASH_MODES_MAP, 6454 PARAM_MAP_SIZE(FLASH_MODES_MAP), flash_mode); 6455 if(initBatchUpdate(m_pParamBuf) < 0 ) { 6456 ALOGE("%s:Failed to initialize group update table", __func__); 6457 return BAD_TYPE; 6458 } 6459 rc = setFlash(flash_mode_str); 6460 if (rc != NO_ERROR) { 6461 ALOGE("%s:Failed to update Flash mode", __func__); 6462 return rc; 6463 } 6464 6465 CDBG_HIGH("%s: Setting Flash mode %d", __func__, mFlashValue); 6466 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_LED_MODE, mFlashValue)) { 6467 ALOGE("%s:Failed to set led mode", __func__); 6468 return BAD_VALUE; 6469 } 6470 6471 rc = commitSetBatch(); 6472 if (rc != NO_ERROR) { 6473 ALOGE("%s:Failed to commit parameters", __func__); 6474 return rc; 6475 } 6476 6477 return NO_ERROR; 6478 } 6479 6480 6481 /*=========================================================================== 6482 * FUNCTION : configureFlash 6483 * 6484 * DESCRIPTION: configure Flash Bracketing. 6485 * 6486 * PARAMETERS : 6487 * @frame_config : output configaration structure to fill in. 6488 * 6489 * RETURN : int32_t type of status 6490 * NO_ERROR -- success 6491 * none-zero failure code 6492 *==========================================================================*/ 6493 int32_t QCameraParameters::configureFlash(cam_capture_frame_config_t &frame_config) 6494 { 6495 CDBG_HIGH("%s: E",__func__); 6496 int32_t rc = NO_ERROR; 6497 uint32_t i = 0; 6498 6499 if (isChromaFlashEnabled()) { 6500 6501 rc = setToneMapMode(false, false); 6502 if (rc != NO_ERROR) { 6503 ALOGE("%s: Failed to configure tone map", __func__); 6504 return rc; 6505 } 6506 6507 rc = setCDSMode(CAM_CDS_MODE_OFF, false); 6508 if (rc != NO_ERROR) { 6509 ALOGE("%s: Failed to configure csd mode", __func__); 6510 return rc; 6511 } 6512 6513 CDBG_HIGH("%s : Enable Chroma Flash capture", __func__); 6514 cam_flash_mode_t flash_mode = CAM_FLASH_MODE_OFF; 6515 frame_config.num_batch = 6516 m_pCapability->chroma_flash_settings_need.burst_count; 6517 if (frame_config.num_batch > CAM_MAX_FLASH_BRACKETING) { 6518 frame_config.num_batch = CAM_MAX_FLASH_BRACKETING; 6519 } 6520 for (i = 0; i < frame_config.num_batch; i++) { 6521 flash_mode = (m_pCapability->chroma_flash_settings_need.flash_bracketing[i]) ? 6522 CAM_FLASH_MODE_ON:CAM_FLASH_MODE_OFF; 6523 frame_config.configs[i].num_frames = 1; 6524 frame_config.configs[i].type = CAM_CAPTURE_FLASH; 6525 frame_config.configs[i].flash_mode = flash_mode; 6526 } 6527 } else if (mFlashValue != CAM_FLASH_MODE_OFF) { 6528 frame_config.num_batch = 1; 6529 for (i = 0; i < frame_config.num_batch; i++) { 6530 frame_config.configs[i].num_frames = 1; 6531 frame_config.configs[i].type = CAM_CAPTURE_FLASH; 6532 frame_config.configs[i].flash_mode =(cam_flash_mode_t)mFlashValue; 6533 } 6534 } 6535 6536 CDBG("%s: Chroma Flash cnt = %d", __func__,frame_config.num_batch); 6537 return rc; 6538 } 6539 6540 /*=========================================================================== 6541 * FUNCTION : configureHDRBracketing 6542 * 6543 * DESCRIPTION: configure HDR Bracketing. 6544 * 6545 * PARAMETERS : 6546 * @frame_config : output configaration structure to fill in. 6547 * 6548 * RETURN : int32_t type of status 6549 * NO_ERROR -- success 6550 * none-zero failure code 6551 *==========================================================================*/ 6552 int32_t QCameraParameters::configureHDRBracketing(cam_capture_frame_config_t &frame_config) 6553 { 6554 CDBG_HIGH("%s: E",__func__); 6555 int32_t rc = NO_ERROR; 6556 uint32_t i = 0; 6557 6558 uint32_t hdrFrameCount = m_pCapability->hdr_bracketing_setting.num_frames; 6559 CDBG_HIGH("%s : HDR values %d, %d frame count: %u", 6560 __func__, 6561 (int8_t) m_pCapability->hdr_bracketing_setting.exp_val.values[0], 6562 (int8_t) m_pCapability->hdr_bracketing_setting.exp_val.values[1], 6563 hdrFrameCount); 6564 6565 frame_config.num_batch = hdrFrameCount; 6566 6567 cam_bracket_mode mode = 6568 m_pCapability->hdr_bracketing_setting.exp_val.mode; 6569 if (mode == CAM_EXP_BRACKETING_ON) { 6570 rc = setToneMapMode(false, true); 6571 if (rc != NO_ERROR) { 6572 ALOGE("%s: Failed to disable tone map during HDR", __func__); 6573 } 6574 } 6575 for (i = 0; i < frame_config.num_batch; i++) { 6576 frame_config.configs[i].num_frames = 1; 6577 frame_config.configs[i].type = CAM_CAPTURE_BRACKETING; 6578 frame_config.configs[i].hdr_mode.mode = mode; 6579 frame_config.configs[i].hdr_mode.values = 6580 m_pCapability->hdr_bracketing_setting.exp_val.values[i]; 6581 CDBG("%s: exp values %d", __func__, 6582 (int)frame_config.configs[i].hdr_mode.values); 6583 } 6584 return rc; 6585 } 6586 6587 /*=========================================================================== 6588 * FUNCTION : configureAEBracketing 6589 * 6590 * DESCRIPTION: configure AE Bracketing. 6591 * 6592 * PARAMETERS : 6593 * @frame_config : output configaration structure to fill in. 6594 * 6595 * RETURN : int32_t type of status 6596 * NO_ERROR -- success 6597 * none-zero failure code 6598 *==========================================================================*/ 6599 int32_t QCameraParameters::configureAEBracketing(cam_capture_frame_config_t &frame_config) 6600 { 6601 CDBG_HIGH("%s: E",__func__); 6602 int32_t rc = NO_ERROR; 6603 uint32_t i = 0; 6604 char exp_value[MAX_EXP_BRACKETING_LENGTH]; 6605 6606 rc = setToneMapMode(false, true); 6607 if (rc != NO_ERROR) { 6608 CDBG_HIGH("%s: Failed to disable tone map during AEBracketing", __func__); 6609 } 6610 6611 uint32_t burstCount = 0; 6612 const char *str_val = m_AEBracketingClient.values; 6613 if ((str_val != NULL) && (strlen(str_val) > 0)) { 6614 char prop[PROPERTY_VALUE_MAX]; 6615 memset(prop, 0, sizeof(prop)); 6616 strlcpy(prop, str_val, PROPERTY_VALUE_MAX); 6617 char *saveptr = NULL; 6618 char *token = strtok_r(prop, ",", &saveptr); 6619 if (token != NULL) { 6620 exp_value[burstCount++] = (char)atoi(token); 6621 while (token != NULL) { 6622 token = strtok_r(NULL, ",", &saveptr); 6623 if (token != NULL) { 6624 exp_value[burstCount++] = (char)atoi(token); 6625 } 6626 } 6627 } 6628 } 6629 6630 frame_config.num_batch = burstCount; 6631 cam_bracket_mode mode = m_AEBracketingClient.mode; 6632 6633 for (i = 0; i < frame_config.num_batch; i++) { 6634 frame_config.configs[i].num_frames = 1; 6635 frame_config.configs[i].type = CAM_CAPTURE_BRACKETING; 6636 frame_config.configs[i].hdr_mode.mode = mode; 6637 frame_config.configs[i].hdr_mode.values = 6638 m_AEBracketingClient.values[i]; 6639 CDBG("%s: exp values %d", __func__, (int)m_AEBracketingClient.values[i]); 6640 } 6641 6642 CDBG_HIGH("%s: num_frame = %d X",__func__, burstCount); 6643 return rc; 6644 } 6645 6646 /*=========================================================================== 6647 * FUNCTION : configFrameCapture 6648 * 6649 * DESCRIPTION: configuration for ZSL special captures (FLASH/HDR etc) 6650 * 6651 * PARAMETERS : 6652 * @commitSettings : flag to enable or disable commit this this settings 6653 * 6654 * RETURN : int32_t type of status 6655 * NO_ERROR -- success 6656 * none-zero failure code 6657 *==========================================================================*/ 6658 int32_t QCameraParameters::configFrameCapture(bool commitSettings) 6659 { 6660 int32_t rc = NO_ERROR; 6661 memset(&m_captureFrameConfig, 0, sizeof(cam_capture_frame_config_t)); 6662 6663 if (commitSettings) { 6664 if(initBatchUpdate(m_pParamBuf) < 0 ) { 6665 ALOGE("%s:Failed to initialize group update table", __func__); 6666 return BAD_TYPE; 6667 } 6668 } 6669 6670 if (isChromaFlashEnabled() || mFlashValue != CAM_FLASH_MODE_OFF) { 6671 configureFlash(m_captureFrameConfig); 6672 } else if(isHDREnabled()) { 6673 configureHDRBracketing (m_captureFrameConfig); 6674 } else if(isAEBracketEnabled()) { 6675 configureAEBracketing (m_captureFrameConfig); 6676 } 6677 6678 rc = ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_CAPTURE_FRAME_CONFIG, 6679 (cam_capture_frame_config_t)m_captureFrameConfig); 6680 if (rc != NO_ERROR) { 6681 rc = BAD_VALUE; 6682 ALOGE("%s:Failed to set capture settings", __func__); 6683 return rc; 6684 } 6685 6686 if (commitSettings) { 6687 rc = commitSetBatch(); 6688 if (rc != NO_ERROR) { 6689 ALOGE("%s:Failed to commit parameters", __func__); 6690 return rc; 6691 } 6692 } 6693 return rc; 6694 } 6695 6696 /*=========================================================================== 6697 * FUNCTION : resetFrameCapture 6698 * 6699 * DESCRIPTION: reset special captures settings(FLASH/HDR etc) 6700 * 6701 * PARAMETERS : 6702 * @commitSettings : flag to enable or disable commit this this settings 6703 * 6704 * RETURN : int32_t type of status 6705 * NO_ERROR -- success 6706 * none-zero failure code 6707 *==========================================================================*/ 6708 int32_t QCameraParameters::resetFrameCapture(bool commitSettings) 6709 { 6710 int32_t rc = NO_ERROR, i = 0; 6711 memset(&m_captureFrameConfig, 0, sizeof(cam_capture_frame_config_t)); 6712 6713 if (commitSettings) { 6714 if(initBatchUpdate(m_pParamBuf) < 0 ) { 6715 ALOGE("%s:Failed to initialize group update table", __func__); 6716 return BAD_TYPE; 6717 } 6718 } 6719 6720 if (isHDREnabled() || isAEBracketEnabled()) { 6721 rc = setToneMapMode(true, true); 6722 if (rc != NO_ERROR) { 6723 CDBG_HIGH("%s: Failed to enable tone map during HDR/AEBracketing", __func__); 6724 } 6725 rc = stopAEBracket(); 6726 } else if (isChromaFlashEnabled()) { 6727 rc = setToneMapMode(true, false); 6728 if (rc != NO_ERROR) { 6729 CDBG_HIGH("%s: Failed to enable tone map during chroma flash", __func__); 6730 } 6731 6732 rc = setCDSMode(mCds_mode, false); 6733 if (rc != NO_ERROR) { 6734 ALOGE("%s: Failed to configure csd mode", __func__); 6735 return rc; 6736 } 6737 } 6738 6739 rc = ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_CAPTURE_FRAME_CONFIG, 6740 (cam_capture_frame_config_t)m_captureFrameConfig); 6741 if (rc != NO_ERROR) { 6742 rc = BAD_VALUE; 6743 ALOGE("%s:Failed to set capture settings", __func__); 6744 return rc; 6745 } 6746 6747 if (commitSettings) { 6748 rc = commitSetBatch(); 6749 if (rc != NO_ERROR) { 6750 ALOGE("%s:Failed to commit parameters", __func__); 6751 return rc; 6752 } 6753 } 6754 return rc; 6755 } 6756 6757 /*=========================================================================== 6758 * FUNCTION : setAecLock 6759 * 6760 * DESCRIPTION: set AEC lock value 6761 * 6762 * PARAMETERS : 6763 * @aecLockStr : AEC lock value string 6764 * 6765 * RETURN : int32_t type of status 6766 * NO_ERROR -- success 6767 * none-zero failure code 6768 *==========================================================================*/ 6769 int32_t QCameraParameters::setAecLock(const char *aecLockStr) 6770 { 6771 if (aecLockStr != NULL) { 6772 int32_t value = lookupAttr(TRUE_FALSE_MODES_MAP, PARAM_MAP_SIZE(TRUE_FALSE_MODES_MAP), 6773 aecLockStr); 6774 if (value != NAME_NOT_FOUND) { 6775 CDBG_HIGH("%s: Setting AECLock value %s", __func__, aecLockStr); 6776 updateParamEntry(KEY_AUTO_EXPOSURE_LOCK, aecLockStr); 6777 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, 6778 CAM_INTF_PARM_AEC_LOCK, (uint32_t)value)) { 6779 return BAD_VALUE; 6780 } 6781 return NO_ERROR; 6782 } 6783 } 6784 ALOGE("Invalid AECLock value: %s", 6785 (aecLockStr == NULL) ? "NULL" : aecLockStr); 6786 return BAD_VALUE; 6787 } 6788 6789 /*=========================================================================== 6790 * FUNCTION : setAwbLock 6791 * 6792 * DESCRIPTION: set AWB lock value 6793 * 6794 * PARAMETERS : 6795 * @awbLockStr : AWB lock value string 6796 * 6797 * RETURN : int32_t type of status 6798 * NO_ERROR -- success 6799 * none-zero failure code 6800 *==========================================================================*/ 6801 int32_t QCameraParameters::setAwbLock(const char *awbLockStr) 6802 { 6803 if (awbLockStr != NULL) { 6804 int32_t value = lookupAttr(TRUE_FALSE_MODES_MAP, PARAM_MAP_SIZE(TRUE_FALSE_MODES_MAP), 6805 awbLockStr); 6806 if (value != NAME_NOT_FOUND) { 6807 CDBG_HIGH("%s: Setting AWBLock value %s", __func__, awbLockStr); 6808 updateParamEntry(KEY_AUTO_WHITEBALANCE_LOCK, awbLockStr); 6809 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, 6810 CAM_INTF_PARM_AWB_LOCK, (uint32_t)value)) { 6811 return BAD_VALUE; 6812 } 6813 return NO_ERROR; 6814 } 6815 } 6816 ALOGE("Invalid AWBLock value: %s", (awbLockStr == NULL) ? "NULL" : awbLockStr); 6817 return BAD_VALUE; 6818 } 6819 6820 /*=========================================================================== 6821 * FUNCTION : setMCEValue 6822 * 6823 * DESCRIPTION: set memory color enhancement value 6824 * 6825 * PARAMETERS : 6826 * @mceStr : MCE value string 6827 * 6828 * RETURN : int32_t type of status 6829 * NO_ERROR -- success 6830 * none-zero failure code 6831 *==========================================================================*/ 6832 int32_t QCameraParameters::setMCEValue(const char *mceStr) 6833 { 6834 if (mceStr != NULL) { 6835 int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP, 6836 PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP), mceStr); 6837 if (value != NAME_NOT_FOUND) { 6838 CDBG_HIGH("%s: Setting AWBLock value %s", __func__, mceStr); 6839 updateParamEntry(KEY_QC_MEMORY_COLOR_ENHANCEMENT, mceStr); 6840 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_MCE, value)) { 6841 return BAD_VALUE; 6842 } 6843 return NO_ERROR; 6844 } 6845 } 6846 ALOGE("Invalid MCE value: %s", (mceStr == NULL) ? "NULL" : mceStr); 6847 return BAD_VALUE; 6848 } 6849 6850 /*=========================================================================== 6851 * FUNCTION : setTintlessValue 6852 * 6853 * DESCRIPTION: enable/disable tintless from user setting 6854 * 6855 * PARAMETERS : 6856 * @params : user setting parameters 6857 * 6858 * RETURN : int32_t type of status 6859 * NO_ERROR -- success 6860 * none-zero failure code 6861 *==========================================================================*/ 6862 int32_t QCameraParameters::setTintlessValue(const QCameraParameters& params) 6863 { 6864 const char *str = params.get(KEY_QC_TINTLESS_ENABLE); 6865 const char *prev_str = get(KEY_QC_TINTLESS_ENABLE); 6866 char prop[PROPERTY_VALUE_MAX]; 6867 6868 memset(prop, 0, sizeof(prop)); 6869 property_get("persist.camera.tintless", prop, VALUE_ENABLE); 6870 if (str != NULL) { 6871 if (prev_str == NULL || 6872 strcmp(str, prev_str) != 0) { 6873 return setTintlessValue(str); 6874 } 6875 } else { 6876 if (prev_str == NULL || 6877 strcmp(prev_str, prop) != 0 ) { 6878 setTintlessValue(prop); 6879 } 6880 } 6881 6882 return NO_ERROR; 6883 } 6884 6885 /*=========================================================================== 6886 * FUNCTION : setTintless 6887 * 6888 * DESCRIPTION: set tintless mode 6889 * 6890 * PARAMETERS : 6891 * @enable : 1 = enable, 0 = disable 6892 * 6893 * RETURN : int32_t type of status 6894 * NO_ERROR -- success 6895 * none-zero failure code 6896 *==========================================================================*/ 6897 void QCameraParameters::setTintless(bool enable) 6898 { 6899 if (enable) { 6900 setTintlessValue(VALUE_ENABLE); 6901 } else { 6902 setTintlessValue(VALUE_DISABLE); 6903 } 6904 } 6905 6906 /*=========================================================================== 6907 * FUNCTION : setTintlessValue 6908 * 6909 * DESCRIPTION: set tintless value 6910 * 6911 * PARAMETERS : 6912 * @tintStr : Tintless value string 6913 * 6914 * RETURN : int32_t type of status 6915 * NO_ERROR -- success 6916 * none-zero failure code 6917 *==========================================================================*/ 6918 int32_t QCameraParameters::setTintlessValue(const char *tintStr) 6919 { 6920 if (tintStr != NULL) { 6921 int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP, 6922 PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP), tintStr); 6923 if (value != NAME_NOT_FOUND) { 6924 CDBG_HIGH("%s: Setting Tintless value %s", __func__, tintStr); 6925 updateParamEntry(KEY_QC_TINTLESS_ENABLE, tintStr); 6926 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_TINTLESS, value)) { 6927 return BAD_VALUE; 6928 } 6929 return NO_ERROR; 6930 } 6931 } 6932 ALOGE("Invalid Tintless value: %s", (tintStr == NULL) ? "NULL" : tintStr); 6933 return BAD_VALUE; 6934 } 6935 6936 /*=========================================================================== 6937 * FUNCTION : setCDSMode 6938 * 6939 * DESCRIPTION: Set CDS mode 6940 * 6941 * PARAMETERS : 6942 * @params : user setting parameters 6943 * 6944 * RETURN : int32_t type of status 6945 * NO_ERROR -- success 6946 * none-zero failure code 6947 *==========================================================================*/ 6948 int32_t QCameraParameters::setCDSMode(const QCameraParameters& params) 6949 { 6950 const char *str = params.get(KEY_QC_CDS_MODE); 6951 const char *prev_str = get(KEY_QC_CDS_MODE); 6952 const char *video_str = params.get(KEY_QC_VIDEO_CDS_MODE); 6953 const char *video_prev_str = get(KEY_QC_VIDEO_CDS_MODE); 6954 int32_t rc = NO_ERROR; 6955 6956 if (m_bRecordingHint_new == true) { 6957 if (video_str) { 6958 if ((video_prev_str == NULL) || (strcmp(video_str, video_prev_str) != 0)) { 6959 int32_t cds_mode = lookupAttr(CDS_MODES_MAP, PARAM_MAP_SIZE(CDS_MODES_MAP), 6960 video_str); 6961 if (cds_mode != NAME_NOT_FOUND) { 6962 updateParamEntry(KEY_QC_VIDEO_CDS_MODE, video_str); 6963 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_CDS_MODE, cds_mode)) { 6964 ALOGE("%s:Failed CDS MODE to update table", __func__); 6965 rc = BAD_VALUE; 6966 } else { 6967 CDBG("%s: Set CDS in video mode = %d", __func__, cds_mode); 6968 mCds_mode = cds_mode; 6969 } 6970 } else { 6971 ALOGE("%s: Invalid argument for video CDS MODE %d", __func__, cds_mode); 6972 rc = BAD_VALUE; 6973 } 6974 } 6975 } else { 6976 char video_prop[PROPERTY_VALUE_MAX]; 6977 memset(video_prop, 0, sizeof(video_prop)); 6978 property_get("persist.camera.video.CDS", video_prop, CDS_MODE_ON); 6979 int32_t cds_mode = lookupAttr(CDS_MODES_MAP, PARAM_MAP_SIZE(CDS_MODES_MAP), 6980 video_prop); 6981 if (cds_mode != NAME_NOT_FOUND) { 6982 updateParamEntry(KEY_QC_VIDEO_CDS_MODE, video_prop); 6983 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_CDS_MODE, cds_mode)) { 6984 ALOGE("%s:Failed CDS MODE to update table", __func__); 6985 rc = BAD_VALUE; 6986 } else { 6987 CDBG("%s: Set CDS in video mode from setprop = %d", __func__, cds_mode); 6988 mCds_mode = cds_mode; 6989 } 6990 } else { 6991 ALOGE("%s: Invalid prop for video CDS MODE %d", __func__, cds_mode); 6992 rc = BAD_VALUE; 6993 } 6994 } 6995 } else { 6996 if (str) { 6997 if ((prev_str == NULL) || (strcmp(str, prev_str) != 0)) { 6998 int32_t cds_mode = lookupAttr(CDS_MODES_MAP, PARAM_MAP_SIZE(CDS_MODES_MAP), 6999 str); 7000 if (cds_mode != NAME_NOT_FOUND) { 7001 updateParamEntry(KEY_QC_CDS_MODE, str); 7002 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_CDS_MODE, cds_mode)) { 7003 ALOGE("%s:Failed CDS MODE to update table", __func__); 7004 rc = BAD_VALUE; 7005 } else { 7006 CDBG("%s: Set CDS in capture mode = %d", __func__, cds_mode); 7007 mCds_mode = cds_mode; 7008 } 7009 } else { 7010 ALOGE("%s: Invalid argument for snapshot CDS MODE %d", __func__, cds_mode); 7011 rc = BAD_VALUE; 7012 } 7013 } 7014 } else { 7015 char prop[PROPERTY_VALUE_MAX]; 7016 memset(prop, 0, sizeof(prop)); 7017 property_get("persist.camera.CDS", prop, CDS_MODE_ON); 7018 int32_t cds_mode = lookupAttr(CDS_MODES_MAP, PARAM_MAP_SIZE(CDS_MODES_MAP), 7019 prop); 7020 if (cds_mode != NAME_NOT_FOUND) { 7021 updateParamEntry(KEY_QC_CDS_MODE, prop); 7022 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_CDS_MODE, cds_mode)) { 7023 ALOGE("%s:Failed CDS MODE to update table", __func__); 7024 rc = BAD_VALUE; 7025 } else { 7026 CDBG("%s: Set CDS in snapshot mode from setprop = %d", __func__, cds_mode); 7027 mCds_mode = cds_mode; 7028 } 7029 } else { 7030 ALOGE("%s: Invalid prop for snapshot CDS MODE %d", __func__, cds_mode); 7031 rc = BAD_VALUE; 7032 } 7033 } 7034 } 7035 7036 return rc; 7037 } 7038 7039 /*=========================================================================== 7040 * FUNCTION : setDISValue 7041 * 7042 * DESCRIPTION: set DIS value 7043 * 7044 * PARAMETERS : 7045 * @disStr : DIS value string 7046 * 7047 * RETURN : int32_t type of status 7048 * NO_ERROR -- success 7049 * none-zero failure code 7050 *==========================================================================*/ 7051 int32_t QCameraParameters::setDISValue(const char *disStr) 7052 { 7053 if (disStr != NULL) { 7054 int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP, 7055 PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP), disStr); 7056 if (value != NAME_NOT_FOUND) { 7057 //For some IS types (like EIS 2.0), when DIS value is changed, we need to restart 7058 //preview because of topology change in backend. But, for now, restart preview 7059 //for all IS types. 7060 m_bNeedRestart = true; 7061 CDBG_HIGH("%s: Setting DIS value %s", __func__, disStr); 7062 updateParamEntry(KEY_QC_DIS, disStr); 7063 if (!(strcmp(disStr,"enable"))) { 7064 m_bDISEnabled = true; 7065 } else { 7066 m_bDISEnabled = false; 7067 } 7068 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_DIS_ENABLE, value)) { 7069 return BAD_VALUE; 7070 } 7071 return NO_ERROR; 7072 } 7073 } 7074 ALOGE("Invalid DIS value: %s", (disStr == NULL) ? "NULL" : disStr); 7075 m_bDISEnabled = false; 7076 return BAD_VALUE; 7077 } 7078 7079 /*=========================================================================== 7080 * FUNCTION : updateOisValue 7081 * 7082 * DESCRIPTION: update OIS value 7083 * 7084 * PARAMETERS : 7085 * @oisValue : OIS value TRUE/FALSE 7086 * 7087 * RETURN : int32_t type of status 7088 * NO_ERROR -- success 7089 * none-zero failure code 7090 *==========================================================================*/ 7091 int32_t QCameraParameters::updateOisValue(bool oisValue) 7092 { 7093 uint8_t enable = 0; 7094 int32_t rc = NO_ERROR; 7095 7096 // Check for OIS disable 7097 char ois_prop[PROPERTY_VALUE_MAX]; 7098 memset(ois_prop, 0, sizeof(ois_prop)); 7099 property_get("persist.camera.ois.disable", ois_prop, "0"); 7100 uint8_t ois_disable = (uint8_t)atoi(ois_prop); 7101 7102 //Enable OIS if it is camera mode or Camcoder 4K mode 7103 if (!m_bRecordingHint || (is4k2kVideoResolution() && m_bRecordingHint)) { 7104 enable = 1; 7105 CDBG_HIGH("%s: Valid OIS mode!! ", __func__); 7106 } 7107 // Disable OIS if setprop is set 7108 if (ois_disable || !oisValue) { 7109 //Disable OIS 7110 enable = 0; 7111 CDBG_HIGH("%s: Disable OIS mode!! ois_disable(%d) oisValue(%d)", 7112 __func__, ois_disable, oisValue); 7113 7114 } 7115 m_bOISEnabled = enable; 7116 if (m_bOISEnabled) { 7117 updateParamEntry(KEY_QC_OIS, VALUE_ENABLE); 7118 } else { 7119 updateParamEntry(KEY_QC_OIS, VALUE_DISABLE); 7120 } 7121 7122 if (initBatchUpdate(m_pParamBuf) < 0 ) { 7123 ALOGE("%s:Failed to initialize group update table", __func__); 7124 return BAD_TYPE; 7125 } 7126 7127 CDBG_HIGH("%s: Sending OIS mode (%d)", __func__, enable); 7128 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_META_LENS_OPT_STAB_MODE, enable)) { 7129 ALOGE("%s:Failed to update table", __func__); 7130 return BAD_VALUE; 7131 } 7132 7133 rc = commitSetBatch(); 7134 if (rc != NO_ERROR) { 7135 ALOGE("%s:Failed to parameter changes", __func__); 7136 return rc; 7137 } 7138 7139 return rc; 7140 } 7141 7142 /*=========================================================================== 7143 * FUNCTION : setHighFrameRate 7144 * 7145 * DESCRIPTION: set high frame rate 7146 * 7147 * PARAMETERS : 7148 * @hfrMode : HFR mode 7149 * 7150 * RETURN : int32_t type of status 7151 * NO_ERROR -- success 7152 * none-zero failure code 7153 *==========================================================================*/ 7154 int32_t QCameraParameters::setHighFrameRate(const int32_t hfrMode) 7155 { 7156 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_HFR, hfrMode)) { 7157 return BAD_VALUE; 7158 } 7159 7160 return NO_ERROR; 7161 } 7162 7163 /*=========================================================================== 7164 * FUNCTION : setLensShadeValue 7165 * 7166 * DESCRIPTION: set lens shade value 7167 * 7168 * PARAMETERS : 7169 * @lensSahdeStr : lens shade value string 7170 * 7171 * RETURN : int32_t type of status 7172 * NO_ERROR -- success 7173 * none-zero failure code 7174 *==========================================================================*/ 7175 int32_t QCameraParameters::setLensShadeValue(const char *lensShadeStr) 7176 { 7177 if (lensShadeStr != NULL) { 7178 int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP, 7179 PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP), lensShadeStr); 7180 if (value != NAME_NOT_FOUND) { 7181 CDBG_HIGH("%s: Setting LensShade value %s", __func__, lensShadeStr); 7182 updateParamEntry(KEY_QC_LENSSHADE, lensShadeStr); 7183 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_ROLLOFF, value)) { 7184 return BAD_VALUE; 7185 } 7186 return NO_ERROR; 7187 } 7188 } 7189 ALOGE("Invalid LensShade value: %s", 7190 (lensShadeStr == NULL) ? "NULL" : lensShadeStr); 7191 return BAD_VALUE; 7192 } 7193 7194 /*=========================================================================== 7195 * FUNCTION : setExposureCompensation 7196 * 7197 * DESCRIPTION: set exposure compensation value 7198 * 7199 * PARAMETERS : 7200 * @expComp : exposure compensation value 7201 * 7202 * RETURN : int32_t type of status 7203 * NO_ERROR -- success 7204 * none-zero failure code 7205 *==========================================================================*/ 7206 int32_t QCameraParameters::setExposureCompensation(int expComp) 7207 { 7208 char val[16]; 7209 snprintf(val, sizeof(val), "%d", expComp); 7210 updateParamEntry(KEY_EXPOSURE_COMPENSATION, val); 7211 7212 // Don't need to pass step as part of setParameter because 7213 // camera daemon is already aware of it. 7214 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_EXPOSURE_COMPENSATION, expComp)) { 7215 return BAD_VALUE; 7216 } 7217 7218 return NO_ERROR; 7219 } 7220 7221 /*=========================================================================== 7222 * FUNCTION : setWhiteBalance 7223 * 7224 * DESCRIPTION: set white balance mode 7225 * 7226 * PARAMETERS : 7227 * @wbStr : white balance mode value string 7228 * 7229 * RETURN : int32_t type of status 7230 * NO_ERROR -- success 7231 * none-zero failure code 7232 *==========================================================================*/ 7233 int32_t QCameraParameters::setWhiteBalance(const char *wbStr) 7234 { 7235 if (wbStr != NULL) { 7236 int32_t value = lookupAttr(WHITE_BALANCE_MODES_MAP, 7237 PARAM_MAP_SIZE(WHITE_BALANCE_MODES_MAP), wbStr); 7238 if (value != NAME_NOT_FOUND) { 7239 CDBG_HIGH("%s: Setting WhiteBalance value %s", __func__, wbStr); 7240 updateParamEntry(KEY_WHITE_BALANCE, wbStr); 7241 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_WHITE_BALANCE, value)) { 7242 return BAD_VALUE; 7243 } 7244 return NO_ERROR; 7245 } 7246 } 7247 ALOGE("Invalid WhiteBalance value: %s", (wbStr == NULL) ? "NULL" : wbStr); 7248 return BAD_VALUE; 7249 } 7250 7251 /*=========================================================================== 7252 * FUNCTION : setWBManualCCT 7253 * 7254 * DESCRIPTION: set setWBManualCCT time 7255 * 7256 * PARAMETERS : 7257 * @cctStr : string of wb cct, range (2000, 8000) in K. 7258 * 7259 * RETURN : int32_t type of status 7260 * NO_ERROR -- success 7261 * none-zero failure code 7262 *==========================================================================*/ 7263 int32_t QCameraParameters::setWBManualCCT(const char *cctStr) 7264 { 7265 if (cctStr != NULL) { 7266 int32_t cctVal = atoi(cctStr); 7267 int32_t minCct = m_pCapability->min_wb_cct; /* 2000K */ 7268 int32_t maxCct = m_pCapability->max_wb_cct; /* 8000K */ 7269 7270 if (cctVal >= minCct && cctVal <= maxCct) { 7271 CDBG_HIGH("%s, cct value: %d", __func__, cctVal); 7272 updateParamEntry(KEY_QC_WB_MANUAL_CCT, cctStr); 7273 cam_manual_wb_parm_t manual_wb; 7274 manual_wb.type = CAM_MANUAL_WB_MODE_CCT; 7275 manual_wb.cct = cctVal; 7276 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_WB_MANUAL, manual_wb)) { 7277 return BAD_VALUE; 7278 } 7279 return NO_ERROR; 7280 } 7281 } 7282 7283 ALOGE("Invalid cct, value: %s", 7284 (cctStr == NULL) ? "NULL" : cctStr); 7285 return BAD_VALUE; 7286 } 7287 7288 /*=========================================================================== 7289 * FUNCTION : updateAWBParams 7290 * 7291 * DESCRIPTION: update CCT parameters key 7292 * 7293 * PARAMETERS : 7294 * @awb_params : WB parameters 7295 * 7296 * RETURN : int32_t type of status 7297 * NO_ERROR -- success 7298 * none-zero failure code 7299 *==========================================================================*/ 7300 int32_t QCameraParameters::updateAWBParams(cam_awb_params_t &awb_params) 7301 { 7302 //check and update CCT 7303 int32_t prev_cct = getInt(KEY_QC_WB_MANUAL_CCT); 7304 if (prev_cct != awb_params.cct_value) { 7305 CDBG("%s: update current cct value. old:%d, now:%d", __func__, 7306 prev_cct, awb_params.cct_value); 7307 set(KEY_QC_WB_MANUAL_CCT, awb_params.cct_value); 7308 } 7309 7310 //check and update WB gains 7311 const char *prev_gains = get(KEY_QC_MANUAL_WB_GAINS); 7312 char gainStr[30]; 7313 snprintf(gainStr, sizeof(gainStr), "%f,%f,%f", awb_params.rgb_gains.r_gain, 7314 awb_params.rgb_gains.g_gain, awb_params.rgb_gains.b_gain); 7315 7316 if (prev_gains == NULL || strcmp(prev_gains, gainStr)) { 7317 set(KEY_QC_MANUAL_WB_GAINS, gainStr); 7318 CDBG("%s: update currernt RGB gains: old %s new %s",__func__, prev_gains, gainStr); 7319 } 7320 return NO_ERROR; 7321 } 7322 7323 /*=========================================================================== 7324 * FUNCTION : parseGains 7325 * 7326 * DESCRIPTION: parse WB gains 7327 * 7328 * PARAMETERS : 7329 * @gainStr : WB result string 7330 * @r_gain : WB red gain 7331 * @g_gain : WB green gain 7332 * @b_gain : WB blue gain 7333 * 7334 * RETURN : int32_t type of status 7335 * NO_ERROR -- success 7336 * none-zero failure code 7337 *==========================================================================*/ 7338 int32_t QCameraParameters::parseGains(const char *gainStr, float &r_gain, 7339 float &g_gain, float &b_gain) 7340 { 7341 int32_t rc = NO_ERROR; 7342 char *saveptr = NULL; 7343 char* gains = (char*) calloc(1, strlen(gainStr) + 1); 7344 if (NULL == gains) { 7345 ALOGE("%s: No memory for gains", __func__); 7346 return NO_MEMORY; 7347 } 7348 strlcpy(gains, gainStr, strlen(gainStr) + 1); 7349 char *token = strtok_r(gains, ",", &saveptr); 7350 7351 if (NULL != token) { 7352 r_gain = atof(token); 7353 token = strtok_r(NULL, ",", &saveptr); 7354 } 7355 7356 if (NULL != token) { 7357 g_gain = atof(token); 7358 token = strtok_r(NULL, ",", &saveptr); 7359 } 7360 7361 if (NULL != token) { 7362 b_gain = (float) atof(token); 7363 } else { 7364 ALOGE("%s: Malformed string for gains", __func__); 7365 rc = BAD_VALUE; 7366 } 7367 7368 free(gains); 7369 return rc; 7370 } 7371 7372 /*=========================================================================== 7373 * FUNCTION : setManualWBGains 7374 * 7375 * DESCRIPTION: set manual wb gains for r,g,b 7376 * 7377 * PARAMETERS : 7378 * @cctStr : string of wb gains, range (1.0, 4.0). 7379 * 7380 * RETURN : int32_t type of status 7381 * NO_ERROR -- success 7382 * none-zero failure code 7383 *==========================================================================*/ 7384 int32_t QCameraParameters::setManualWBGains(const char *gainStr) 7385 { 7386 int32_t rc = NO_ERROR; 7387 if (gainStr != NULL) { 7388 float r_gain, g_gain, b_gain; 7389 rc = parseGains(gainStr, r_gain, g_gain, b_gain); 7390 if (rc != NO_ERROR) { 7391 return rc; 7392 } 7393 7394 float minGain = m_pCapability->min_wb_gain; 7395 float maxGain = m_pCapability->max_wb_gain; 7396 7397 if ((r_gain >= minGain) && (r_gain <= maxGain) && 7398 (g_gain >= minGain) && (g_gain <= maxGain) && 7399 (b_gain >= minGain) && (b_gain <= maxGain)) { 7400 CDBG_HIGH("%s, setting rgb gains: %s", __func__, gainStr); 7401 updateParamEntry(KEY_QC_MANUAL_WB_GAINS, gainStr); 7402 cam_manual_wb_parm_t manual_wb; 7403 manual_wb.type = CAM_MANUAL_WB_MODE_GAIN; 7404 manual_wb.gains.r_gain = r_gain; 7405 manual_wb.gains.g_gain = g_gain; 7406 manual_wb.gains.b_gain = b_gain; 7407 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_WB_MANUAL, manual_wb)) { 7408 return BAD_VALUE; 7409 } 7410 return NO_ERROR; 7411 } 7412 } 7413 7414 CDBG_HIGH("Invalid manual wb gains: %s", 7415 (gainStr == NULL) ? "NULL" : gainStr); 7416 return BAD_VALUE; 7417 } 7418 7419 int QCameraParameters::getAutoFlickerMode() 7420 { 7421 /* Enable Advanced Auto Antibanding where we can set 7422 any of the following option 7423 ie. CAM_ANTIBANDING_MODE_AUTO 7424 CAM_ANTIBANDING_MODE_AUTO_50HZ 7425 CAM_ANTIBANDING_MODE_AUTO_60HZ 7426 Currently setting it to default */ 7427 char prop[PROPERTY_VALUE_MAX]; 7428 memset(prop, 0, sizeof(prop)); 7429 property_get("persist.camera.set.afd", prop, "3"); 7430 return atoi(prop); 7431 } 7432 7433 /*=========================================================================== 7434 * FUNCTION : setAntibanding 7435 * 7436 * DESCRIPTION: set antibanding value 7437 * 7438 * PARAMETERS : 7439 * @antiBandingStr : antibanding value string 7440 * 7441 * RETURN : int32_t type of status 7442 * NO_ERROR -- success 7443 * none-zero failure code 7444 *==========================================================================*/ 7445 int32_t QCameraParameters::setAntibanding(const char *antiBandingStr) 7446 { 7447 if (antiBandingStr != NULL) { 7448 int32_t value = lookupAttr(ANTIBANDING_MODES_MAP, PARAM_MAP_SIZE(ANTIBANDING_MODES_MAP), 7449 antiBandingStr); 7450 if (value != NAME_NOT_FOUND) { 7451 CDBG_HIGH("%s: Setting AntiBanding value %s", __func__, antiBandingStr); 7452 updateParamEntry(KEY_ANTIBANDING, antiBandingStr); 7453 if(value == CAM_ANTIBANDING_MODE_AUTO) { 7454 value = getAutoFlickerMode(); 7455 } 7456 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, 7457 CAM_INTF_PARM_ANTIBANDING, (uint32_t)value)) { 7458 return BAD_VALUE; 7459 } 7460 return NO_ERROR; 7461 } 7462 } 7463 ALOGE("Invalid AntiBanding value: %s", 7464 (antiBandingStr == NULL) ? "NULL" : antiBandingStr); 7465 return BAD_VALUE; 7466 } 7467 7468 /*=========================================================================== 7469 * FUNCTION : setFocusAreas 7470 * 7471 * DESCRIPTION: set focus areas 7472 * 7473 * PARAMETERS : 7474 * @focusAreasStr : focus areas value string 7475 * 7476 * RETURN : int32_t type of status 7477 * NO_ERROR -- success 7478 * none-zero failure code 7479 *==========================================================================*/ 7480 int32_t QCameraParameters::setFocusAreas(const char *focusAreasStr) 7481 { 7482 if (m_pCapability->max_num_focus_areas == 0 || 7483 focusAreasStr == NULL) { 7484 CDBG("%s: Parameter string is null", __func__); 7485 return NO_ERROR; 7486 } 7487 7488 cam_area_t *areas = (cam_area_t *)malloc(sizeof(cam_area_t) * m_pCapability->max_num_focus_areas); 7489 if (NULL == areas) { 7490 ALOGE("%s: No memory for areas", __func__); 7491 return NO_MEMORY; 7492 } 7493 memset(areas, 0, sizeof(cam_area_t) * m_pCapability->max_num_focus_areas); 7494 int num_areas_found = 0; 7495 if (parseCameraAreaString(focusAreasStr, 7496 m_pCapability->max_num_focus_areas, 7497 areas, 7498 num_areas_found) != NO_ERROR) { 7499 ALOGE("%s: Failed to parse the string: %s", __func__, focusAreasStr); 7500 free(areas); 7501 return BAD_VALUE; 7502 } 7503 7504 if (validateCameraAreas(areas, num_areas_found) == false) { 7505 ALOGE("%s: invalid areas specified : %s", __func__, focusAreasStr); 7506 free(areas); 7507 return BAD_VALUE; 7508 } 7509 7510 updateParamEntry(KEY_FOCUS_AREAS, focusAreasStr); 7511 7512 //for special area string (0, 0, 0, 0, 0), set the num_areas_found to 0, 7513 //so no action is takenby the lower layer 7514 if (num_areas_found == 1 && 7515 areas[0].rect.left == 0 && 7516 areas[0].rect.top == 0 && 7517 areas[0].rect.width == 0 && 7518 areas[0].rect.height == 0 && 7519 areas[0].weight == 0) { 7520 num_areas_found = 0; 7521 } 7522 7523 int previewWidth, previewHeight; 7524 getPreviewSize(&previewWidth, &previewHeight); 7525 cam_roi_info_t af_roi_value; 7526 memset(&af_roi_value, 0, sizeof(cam_roi_info_t)); 7527 af_roi_value.num_roi = (uint8_t)num_areas_found; 7528 for (int i = 0; i < num_areas_found; i++) { 7529 CDBG_HIGH("%s: FocusArea[%d] = (%d, %d, %d, %d)", 7530 __func__, i, (areas[i].rect.top), (areas[i].rect.left), 7531 (areas[i].rect.width), (areas[i].rect.height)); 7532 7533 // Transform the coords from (-1000, 1000) 7534 // to (0, previewWidth or previewHeight). 7535 af_roi_value.roi[i].left = 7536 (int32_t)(((double)areas[i].rect.left + 1000.0) * 7537 ((double)previewWidth / 2000.0)); 7538 af_roi_value.roi[i].top = 7539 (int32_t)(((double)areas[i].rect.top + 1000.0) * 7540 ((double)previewHeight / 2000.0)); 7541 af_roi_value.roi[i].width = 7542 (int32_t)((double)areas[i].rect.width * 7543 (double)previewWidth / 2000.0); 7544 af_roi_value.roi[i].height = 7545 (int32_t)((double)areas[i].rect.height * 7546 (double)previewHeight / 2000.0); 7547 af_roi_value.weight[i] = areas[i].weight; 7548 } 7549 free(areas); 7550 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_AF_ROI, af_roi_value)) { 7551 return BAD_VALUE; 7552 } 7553 7554 return NO_ERROR; 7555 } 7556 7557 /*=========================================================================== 7558 * FUNCTION : setMeteringAreas 7559 * 7560 * DESCRIPTION: set metering areas value 7561 * 7562 * PARAMETERS : 7563 * @meteringAreasStr : metering areas value string 7564 * 7565 * RETURN : int32_t type of status 7566 * NO_ERROR -- success 7567 * none-zero failure code 7568 *==========================================================================*/ 7569 int32_t QCameraParameters::setMeteringAreas(const char *meteringAreasStr) 7570 { 7571 if (m_pCapability->max_num_metering_areas == 0 || 7572 meteringAreasStr == NULL) { 7573 CDBG("%s: Parameter string is null", __func__); 7574 return NO_ERROR; 7575 } 7576 7577 cam_area_t *areas = (cam_area_t *)malloc(sizeof(cam_area_t) * m_pCapability->max_num_metering_areas); 7578 if (NULL == areas) { 7579 ALOGE("%s: No memory for areas", __func__); 7580 return NO_MEMORY; 7581 } 7582 memset(areas, 0, sizeof(cam_area_t) * m_pCapability->max_num_metering_areas); 7583 int num_areas_found = 0; 7584 if (parseCameraAreaString(meteringAreasStr, 7585 m_pCapability->max_num_metering_areas, 7586 areas, 7587 num_areas_found) < 0) { 7588 ALOGE("%s: Failed to parse the string: %s", __func__, meteringAreasStr); 7589 free(areas); 7590 return BAD_VALUE; 7591 } 7592 7593 if (validateCameraAreas(areas, num_areas_found) == false) { 7594 ALOGE("%s: invalid areas specified : %s", __func__, meteringAreasStr); 7595 free(areas); 7596 return BAD_VALUE; 7597 } 7598 7599 updateParamEntry(KEY_METERING_AREAS, meteringAreasStr); 7600 7601 //for special area string (0, 0, 0, 0, 0), set the num_areas_found to 0, 7602 //so no action is takenby the lower layer 7603 if (num_areas_found == 1 && 7604 areas[0].rect.left == 0 && 7605 areas[0].rect.top == 0 && 7606 areas[0].rect.width == 0 && 7607 areas[0].rect.height == 0 && 7608 areas[0].weight == 0) { 7609 num_areas_found = 0; 7610 } 7611 cam_set_aec_roi_t aec_roi_value; 7612 int previewWidth, previewHeight; 7613 getPreviewSize(&previewWidth, &previewHeight); 7614 7615 memset(&aec_roi_value, 0, sizeof(cam_set_aec_roi_t)); 7616 if (num_areas_found > 0) { 7617 aec_roi_value.aec_roi_enable = CAM_AEC_ROI_ON; 7618 aec_roi_value.aec_roi_type = CAM_AEC_ROI_BY_COORDINATE; 7619 7620 for (int i = 0; i < num_areas_found; i++) { 7621 CDBG_HIGH("%s: MeteringArea[%d] = (%d, %d, %d, %d)", 7622 __func__, i, (areas[i].rect.top), (areas[i].rect.left), 7623 (areas[i].rect.width), (areas[i].rect.height)); 7624 7625 // Transform the coords from (-1000, 1000) to 7626 // (0, previewWidth or previewHeight). 7627 aec_roi_value.cam_aec_roi_position.coordinate[i].x = 7628 (uint32_t)((((double)areas[i].rect.left + 7629 (double)areas[i].rect.width / 2.0) + 1000.0) * 7630 (double)previewWidth / 2000.0); 7631 aec_roi_value.cam_aec_roi_position.coordinate[i].y = 7632 (uint32_t)((((double)areas[i].rect.top + 7633 (double)areas[i].rect.height / 2.0) + 1000.0) * 7634 (double)previewHeight / 2000.0); 7635 } 7636 } else { 7637 aec_roi_value.aec_roi_enable = CAM_AEC_ROI_OFF; 7638 } 7639 free(areas); 7640 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_AEC_ROI, aec_roi_value)) { 7641 return BAD_VALUE; 7642 } 7643 7644 return NO_ERROR; 7645 } 7646 7647 /*=========================================================================== 7648 * FUNCTION : setSceneMode 7649 * 7650 * DESCRIPTION: set scene mode 7651 * 7652 * PARAMETERS : 7653 * @sceneModeStr : scene mode value string 7654 * 7655 * RETURN : int32_t type of status 7656 * NO_ERROR -- success 7657 * none-zero failure code 7658 *==========================================================================*/ 7659 int32_t QCameraParameters::setSceneMode(const char *sceneModeStr) 7660 { 7661 if (sceneModeStr != NULL) { 7662 int32_t value = lookupAttr(SCENE_MODES_MAP, PARAM_MAP_SIZE(SCENE_MODES_MAP), sceneModeStr); 7663 if (value != NAME_NOT_FOUND) { 7664 CDBG("%s: Setting SceneMode %s", __func__, sceneModeStr); 7665 updateParamEntry(KEY_SCENE_MODE, sceneModeStr); 7666 if (m_bSensorHDREnabled) { 7667 // Incase of HW HDR mode, we do not update the same as Best shot mode. 7668 CDBG_HIGH("%s: H/W HDR mode enabled. Do not set Best Shot Mode", __func__); 7669 return NO_ERROR; 7670 } 7671 if (m_bSceneSelection) { 7672 setSelectedScene((cam_scene_mode_type) value); 7673 } 7674 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_BESTSHOT_MODE, 7675 (uint32_t)value)) { 7676 return BAD_VALUE; 7677 } 7678 return NO_ERROR; 7679 } 7680 } 7681 ALOGE("%s: Invalid Secene Mode: %s", 7682 __func__, (sceneModeStr == NULL) ? "NULL" : sceneModeStr); 7683 return BAD_VALUE; 7684 } 7685 7686 /*=========================================================================== 7687 * FUNCTION : setSelectableZoneAf 7688 * 7689 * DESCRIPTION: set selectable zone AF algorithm 7690 * 7691 * PARAMETERS : 7692 * @selZoneAFStr : selectable zone AF algorithm value string 7693 * 7694 * RETURN : int32_t type of status 7695 * NO_ERROR -- success 7696 * none-zero failure code 7697 *==========================================================================*/ 7698 int32_t QCameraParameters::setSelectableZoneAf(const char *selZoneAFStr) 7699 { 7700 if (selZoneAFStr != NULL) { 7701 int32_t value = lookupAttr(FOCUS_ALGO_MAP, PARAM_MAP_SIZE(FOCUS_ALGO_MAP), selZoneAFStr); 7702 if (value != NAME_NOT_FOUND) { 7703 CDBG("%s: Setting Selectable Zone AF value %s", __func__, selZoneAFStr); 7704 updateParamEntry(KEY_QC_SELECTABLE_ZONE_AF, selZoneAFStr); 7705 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_FOCUS_ALGO_TYPE, value)) { 7706 return BAD_VALUE; 7707 } 7708 return NO_ERROR; 7709 } 7710 } 7711 ALOGE("%s: Invalid selectable zone af value: %s", 7712 __func__, (selZoneAFStr == NULL) ? "NULL" : selZoneAFStr); 7713 return BAD_VALUE; 7714 } 7715 7716 /*=========================================================================== 7717 * FUNCTION : isAEBracketEnabled 7718 * 7719 * DESCRIPTION: checks if AE bracketing is enabled 7720 * 7721 * PARAMETERS : 7722 * 7723 * RETURN : TRUE/FALSE 7724 *==========================================================================*/ 7725 bool QCameraParameters::isAEBracketEnabled() 7726 { 7727 const char *str = get(KEY_QC_AE_BRACKET_HDR); 7728 if (str != NULL) { 7729 if (strcmp(str, AE_BRACKET_OFF) != 0) { 7730 return true; 7731 } 7732 } 7733 return false; 7734 } 7735 7736 /*=========================================================================== 7737 * FUNCTION : setAEBracket 7738 * 7739 * DESCRIPTION: set AE bracket value 7740 * 7741 * PARAMETERS : 7742 * @aecBracketStr : AE bracket value string 7743 * 7744 * RETURN : int32_t type of status 7745 * NO_ERROR -- success 7746 * none-zero failure code 7747 *==========================================================================*/ 7748 int32_t QCameraParameters::setAEBracket(const char *aecBracketStr) 7749 { 7750 if (aecBracketStr == NULL) { 7751 CDBG("%s: setAEBracket with NULL value", __func__); 7752 return NO_ERROR; 7753 } 7754 7755 cam_exp_bracketing_t expBracket; 7756 memset(&expBracket, 0, sizeof(expBracket)); 7757 7758 int value = lookupAttr(BRACKETING_MODES_MAP, PARAM_MAP_SIZE(BRACKETING_MODES_MAP), 7759 aecBracketStr); 7760 switch (value) { 7761 case CAM_EXP_BRACKETING_ON: 7762 { 7763 CDBG("%s, EXP_BRACKETING_ON", __func__); 7764 const char *str_val = get(KEY_QC_CAPTURE_BURST_EXPOSURE); 7765 if ((str_val != NULL) && (strlen(str_val)>0)) { 7766 expBracket.mode = CAM_EXP_BRACKETING_ON; 7767 m_bAeBracketingEnabled = true; 7768 strlcpy(expBracket.values, str_val, MAX_EXP_BRACKETING_LENGTH); 7769 CDBG("%s: setting Exposure Bracketing value of %s", 7770 __func__, expBracket.values); 7771 } 7772 else { 7773 /* Apps not set capture-burst-exposures, error case fall into bracketing off mode */ 7774 CDBG("%s: capture-burst-exposures not set, back to HDR OFF mode", __func__); 7775 m_bAeBracketingEnabled = false; 7776 expBracket.mode = CAM_EXP_BRACKETING_OFF; 7777 } 7778 } 7779 break; 7780 default: 7781 { 7782 m_bAeBracketingEnabled = false; 7783 CDBG_HIGH("%s, EXP_BRACKETING_OFF", __func__); 7784 expBracket.mode = CAM_EXP_BRACKETING_OFF; 7785 } 7786 break; 7787 } 7788 7789 // Cache client AE bracketing configuration 7790 memcpy(&m_AEBracketingClient, &expBracket, sizeof(cam_exp_bracketing_t)); 7791 7792 /* save the value*/ 7793 updateParamEntry(KEY_QC_AE_BRACKET_HDR, aecBracketStr); 7794 return NO_ERROR; 7795 } 7796 7797 /*=========================================================================== 7798 * FUNCTION : set3ALock 7799 * 7800 * DESCRIPTION: enable/disable 3A lock. 7801 * 7802 * PARAMETERS : 7803 * @lockStr : lock value string. 7804 * 7805 * RETURN : int32_t type of status 7806 * NO_ERROR -- success 7807 * none-zero failure code 7808 *==========================================================================*/ 7809 int32_t QCameraParameters::set3ALock(const char *lockStr) 7810 { 7811 int32_t rc = NO_ERROR; 7812 if (lockStr != NULL) { 7813 int value = lookupAttr(TRUE_FALSE_MODES_MAP, PARAM_MAP_SIZE(TRUE_FALSE_MODES_MAP), 7814 lockStr); 7815 if (value != NAME_NOT_FOUND) { 7816 CDBG_HIGH("%s: Setting Lock lockStr =%s", __func__, lockStr); 7817 if(initBatchUpdate(m_pParamBuf) < 0 ) { 7818 ALOGE("%s:Failed to initialize group update table", __func__); 7819 return BAD_TYPE; 7820 } 7821 uint32_t focus_mode = CAM_FOCUS_MODE_AUTO; 7822 if (value == 1) { 7823 if (isUbiFocusEnabled() || isUbiRefocus()) { 7824 //For Ubi focus move focus to infinity. 7825 focus_mode = CAM_FOCUS_MODE_INFINITY; 7826 } else if (isOptiZoomEnabled() || isStillMoreEnabled()) { 7827 //For optizoom and stillmore, set focus as fixed. 7828 focus_mode = CAM_FOCUS_MODE_FIXED; 7829 } 7830 } else { 7831 // retrieve previous focus value. 7832 const char *focus = get(KEY_FOCUS_MODE); 7833 int val = lookupAttr(FOCUS_MODES_MAP, PARAM_MAP_SIZE(FOCUS_MODES_MAP), focus); 7834 if (val != NAME_NOT_FOUND) { 7835 focus_mode = (uint32_t) val; 7836 CDBG("%s: focus mode %s", __func__, focus); 7837 } 7838 } 7839 //Lock AWB 7840 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_AWB_LOCK, (uint32_t)value)) { 7841 return BAD_VALUE; 7842 } 7843 //Lock AEC 7844 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_AEC_LOCK, (uint32_t)value)) { 7845 return BAD_VALUE; 7846 } 7847 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_FOCUS_MODE, focus_mode)) { 7848 return BAD_VALUE; 7849 } 7850 7851 rc = commitSetBatch(); 7852 if (rc != NO_ERROR) { 7853 ALOGE("%s:Failed to commit batch", __func__); 7854 } 7855 } 7856 } 7857 return rc; 7858 } 7859 7860 /*=========================================================================== 7861 * FUNCTION : setAndCommitZoom 7862 * 7863 * DESCRIPTION: set zoom. 7864 * 7865 * PARAMETERS : 7866 * @zoom_level : zoom level to set. 7867 * 7868 * RETURN : int32_t type of status 7869 * NO_ERROR -- success 7870 * none-zero failure code 7871 *==========================================================================*/ 7872 int32_t QCameraParameters::setAndCommitZoom(int zoom_level) 7873 { 7874 CDBG_HIGH("%s: E",__func__); 7875 int32_t rc = NO_ERROR; 7876 if (initBatchUpdate(m_pParamBuf) < 0 ) { 7877 ALOGE("%s:Failed to initialize group update table", __func__); 7878 return BAD_TYPE; 7879 } 7880 7881 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_ZOOM, zoom_level)) { 7882 ALOGE("%s:Failed to update table", __func__); 7883 return BAD_VALUE; 7884 } 7885 7886 rc = commitSetBatch(); 7887 if (rc != NO_ERROR) { 7888 ALOGE("%s:Failed to set Flash value", __func__); 7889 } 7890 7891 mZoomLevel = zoom_level; 7892 CDBG_HIGH("%s: X",__func__); 7893 7894 return rc; 7895 } 7896 7897 /*=========================================================================== 7898 * FUNCTION : isOptiZoomEnabled 7899 * 7900 * DESCRIPTION: checks whether optizoom is enabled 7901 * 7902 * PARAMETERS : 7903 * 7904 * RETURN : true - enabled, false - disabled 7905 * 7906 *==========================================================================*/ 7907 bool QCameraParameters::isOptiZoomEnabled() 7908 { 7909 if (m_bOptiZoomOn && (0 <= mParmZoomLevel)) { 7910 uint32_t zoom_level = (uint32_t) mParmZoomLevel; 7911 cam_opti_zoom_t *opti_zoom_settings_need = 7912 &(m_pCapability->opti_zoom_settings_need); 7913 uint32_t zoom_threshold = (uint32_t) opti_zoom_settings_need->zoom_threshold; 7914 CDBG_HIGH("%s: current zoom level =%u & zoom_threshold =%u", 7915 __func__, zoom_level, zoom_threshold); 7916 7917 if (zoom_level >= zoom_threshold) { 7918 return true; 7919 } 7920 } 7921 7922 return false; 7923 } 7924 7925 /*=========================================================================== 7926 * FUNCTION : commitAFBracket 7927 * 7928 * DESCRIPTION: commit AF Bracket. 7929 * 7930 * PARAMETERS : 7931 * @AFBracket : AF bracketing configuration 7932 * 7933 * RETURN : int32_t type of status 7934 * NO_ERROR -- success 7935 * none-zero failure code 7936 *==========================================================================*/ 7937 int32_t QCameraParameters::commitAFBracket(cam_af_bracketing_t afBracket) 7938 { 7939 7940 int32_t rc = NO_ERROR; 7941 if(initBatchUpdate(m_pParamBuf) < 0 ) { 7942 ALOGE("%s:Failed to initialize group update table", __func__); 7943 return BAD_TYPE; 7944 } 7945 7946 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_FOCUS_BRACKETING, afBracket)) { 7947 ALOGE("%s:Failed to update table", __func__); 7948 return BAD_VALUE; 7949 } 7950 7951 rc = commitSetBatch(); 7952 if (rc != NO_ERROR) { 7953 ALOGE("%s:Failed to commit batch", __func__); 7954 return rc; 7955 } 7956 7957 return rc; 7958 } 7959 7960 /*=========================================================================== 7961 * FUNCTION : commitFlashBracket 7962 * 7963 * DESCRIPTION: commit Flash Bracket. 7964 * 7965 * PARAMETERS : 7966 * @AFBracket : Flash bracketing configuration 7967 * 7968 * RETURN : int32_t type of status 7969 * NO_ERROR -- success 7970 * none-zero failure code 7971 *==========================================================================*/ 7972 int32_t QCameraParameters::commitFlashBracket(cam_flash_bracketing_t flashBracket) 7973 { 7974 CDBG_HIGH("%s: E",__func__); 7975 int32_t rc = NO_ERROR; 7976 if(initBatchUpdate(m_pParamBuf) < 0 ) { 7977 ALOGE("%s:Failed to initialize group update table", __func__); 7978 return BAD_TYPE; 7979 } 7980 7981 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, 7982 CAM_INTF_PARM_FLASH_BRACKETING, flashBracket)) { 7983 ALOGE("%s:Failed to update table", __func__); 7984 return BAD_VALUE; 7985 } 7986 7987 rc = commitSetBatch(); 7988 if (rc != NO_ERROR) { 7989 ALOGE("%s:Failed to commit batch", __func__); 7990 } 7991 7992 CDBG_HIGH("%s: X",__func__); 7993 return rc; 7994 } 7995 7996 /*=========================================================================== 7997 * FUNCTION : setAFBracket 7998 * 7999 * DESCRIPTION: set AF bracket value 8000 * 8001 * PARAMETERS : 8002 * @afBracketStr : AF bracket value string 8003 * 8004 * RETURN : int32_t type of status 8005 * NO_ERROR -- success 8006 * none-zero failure code 8007 *==========================================================================*/ 8008 int32_t QCameraParameters::setAFBracket(const char *afBracketStr) 8009 { 8010 CDBG_HIGH("%s: afBracketStr =%s",__func__,afBracketStr); 8011 8012 if(afBracketStr != NULL) { 8013 int value = lookupAttr(AF_BRACKETING_MODES_MAP, PARAM_MAP_SIZE(AF_BRACKETING_MODES_MAP), 8014 afBracketStr); 8015 if (value != NAME_NOT_FOUND) { 8016 m_bAFBracketingOn = (value != 0); 8017 updateParamEntry(KEY_QC_AF_BRACKET, afBracketStr); 8018 8019 return NO_ERROR; 8020 } 8021 } 8022 8023 ALOGE("Invalid af bracket value: %s", 8024 (afBracketStr == NULL) ? "NULL" : afBracketStr); 8025 return BAD_VALUE; 8026 } 8027 8028 /*=========================================================================== 8029 * FUNCTION : setReFocus 8030 * 8031 * DESCRIPTION: set refocus value 8032 * 8033 * PARAMETERS : 8034 * @afBracketStr : refocus value string 8035 * 8036 * RETURN : int32_t type of status 8037 * NO_ERROR -- success 8038 * none-zero failure code 8039 *==========================================================================*/ 8040 int32_t QCameraParameters::setReFocus(const char *reFocusStr) 8041 { 8042 CDBG_HIGH("%s: reFocusStr =%s",__func__,reFocusStr); 8043 8044 if (reFocusStr != NULL) { 8045 int value = lookupAttr(RE_FOCUS_MODES_MAP, PARAM_MAP_SIZE(RE_FOCUS_MODES_MAP), 8046 reFocusStr); 8047 if (value != NAME_NOT_FOUND) { 8048 m_bReFocusOn = (value != 0); 8049 updateParamEntry(KEY_QC_RE_FOCUS, reFocusStr); 8050 return NO_ERROR; 8051 } 8052 } 8053 8054 return NO_ERROR; 8055 } 8056 8057 /*=========================================================================== 8058 * FUNCTION : setChromaFlash 8059 * 8060 * DESCRIPTION: set chroma flash value 8061 * 8062 * PARAMETERS : 8063 * @aecBracketStr : chroma flash value string 8064 * 8065 * RETURN : int32_t type of status 8066 * NO_ERROR -- success 8067 * none-zero failure code 8068 *==========================================================================*/ 8069 int32_t QCameraParameters::setChromaFlash(const char *chromaFlashStr) 8070 { 8071 CDBG_HIGH("%s: chromaFlashStr =%s",__func__,chromaFlashStr); 8072 if(chromaFlashStr != NULL) { 8073 int value = lookupAttr(CHROMA_FLASH_MODES_MAP, PARAM_MAP_SIZE(CHROMA_FLASH_MODES_MAP), 8074 chromaFlashStr); 8075 if(value != NAME_NOT_FOUND) { 8076 m_bChromaFlashOn = (value != 0); 8077 updateParamEntry(KEY_QC_CHROMA_FLASH, chromaFlashStr); 8078 8079 return NO_ERROR; 8080 } 8081 } 8082 8083 ALOGE("Invalid chroma flash value: %s", 8084 (chromaFlashStr == NULL) ? "NULL" : chromaFlashStr); 8085 return BAD_VALUE; 8086 } 8087 8088 /*=========================================================================== 8089 * FUNCTION : setOptiZoom 8090 * 8091 * DESCRIPTION: set opti zoom value 8092 * 8093 * PARAMETERS : 8094 * @optiZoomStr : opti zoom value string 8095 * 8096 * RETURN : int32_t type of status 8097 * NO_ERROR -- success 8098 * none-zero failure code 8099 *==========================================================================*/ 8100 int32_t QCameraParameters::setOptiZoom(const char *optiZoomStr) 8101 { 8102 CDBG_HIGH("%s: optiZoomStr =%s",__func__,optiZoomStr); 8103 if(optiZoomStr != NULL) { 8104 int value = lookupAttr(OPTI_ZOOM_MODES_MAP, PARAM_MAP_SIZE(OPTI_ZOOM_MODES_MAP), 8105 optiZoomStr); 8106 if(value != NAME_NOT_FOUND) { 8107 m_bOptiZoomOn = (value != 0); 8108 updateParamEntry(KEY_QC_OPTI_ZOOM, optiZoomStr); 8109 8110 return NO_ERROR; 8111 } 8112 } 8113 ALOGE("Invalid opti zoom value: %s", 8114 (optiZoomStr == NULL) ? "NULL" : optiZoomStr); 8115 return BAD_VALUE; 8116 } 8117 8118 /*=========================================================================== 8119 * FUNCTION : setTruePortrait 8120 * 8121 * DESCRIPTION: set true portrait value 8122 * 8123 * PARAMETERS : 8124 * @optiZoomStr : true portrait value string 8125 * 8126 * RETURN : int32_t type of status 8127 * NO_ERROR -- success 8128 * none-zero failure code 8129 *==========================================================================*/ 8130 int32_t QCameraParameters::setTruePortrait(const char *truePortraitStr) 8131 { 8132 CDBG_HIGH("%s: truePortraitStr =%s", __func__, truePortraitStr); 8133 if (truePortraitStr != NULL) { 8134 int value = lookupAttr(TRUE_PORTRAIT_MODES_MAP, 8135 PARAM_MAP_SIZE(TRUE_PORTRAIT_MODES_MAP), 8136 truePortraitStr); 8137 if (value != NAME_NOT_FOUND) { 8138 m_bTruePortraitOn = (value != 0); 8139 updateParamEntry(KEY_QC_TRUE_PORTRAIT, truePortraitStr); 8140 return NO_ERROR; 8141 } 8142 } 8143 CDBG_HIGH("Invalid true portrait value: %s", 8144 (truePortraitStr == NULL) ? "NULL" : truePortraitStr); 8145 return BAD_VALUE; 8146 } 8147 8148 /*=========================================================================== 8149 * FUNCTION : setHDRMode 8150 * 8151 * DESCRIPTION: set hdr mode value 8152 * 8153 * PARAMETERS : 8154 * @hdrModeStr : hdr mode value string 8155 * 8156 * RETURN : int32_t type of status 8157 * NO_ERROR -- success 8158 * none-zero failure code 8159 *==========================================================================*/ 8160 int32_t QCameraParameters::setHDRMode(const char *hdrModeStr) 8161 { 8162 CDBG_HIGH("%s: hdrModeStr =%s", __func__, hdrModeStr); 8163 if (hdrModeStr != NULL) { 8164 int value = lookupAttr(HDR_MODES_MAP, PARAM_MAP_SIZE(HDR_MODES_MAP), hdrModeStr); 8165 if (value != NAME_NOT_FOUND) { 8166 const char *str = get(KEY_SCENE_MODE); 8167 8168 m_bHDRModeSensor = !strncmp(hdrModeStr, HDR_MODE_SENSOR, strlen(HDR_MODE_SENSOR)); 8169 8170 updateParamEntry(KEY_QC_HDR_MODE, hdrModeStr); 8171 8172 // If hdr is already selected, need to deselect it in local cache 8173 // So the new hdr mode will be applied 8174 if (str && !strncmp(str, SCENE_MODE_HDR, strlen(SCENE_MODE_HDR))) { 8175 updateParamEntry(KEY_SCENE_MODE, SCENE_MODE_AUTO); 8176 m_bNeedRestart = true; 8177 } 8178 8179 return NO_ERROR; 8180 } 8181 } 8182 CDBG_HIGH("Invalid hdr mode value: %s", 8183 (hdrModeStr == NULL) ? "NULL" : hdrModeStr); 8184 return BAD_VALUE; 8185 } 8186 8187 /*=========================================================================== 8188 * FUNCTION : setSeeMore 8189 * 8190 * DESCRIPTION: set see more value 8191 * 8192 * PARAMETERS : 8193 * @seeMoreStr : see more value string 8194 * 8195 * RETURN : int32_t type of status 8196 * NO_ERROR -- success 8197 * none-zero failure code 8198 *==========================================================================*/ 8199 int32_t QCameraParameters::setSeeMore(const char *seeMoreStr) 8200 { 8201 int32_t rc = NO_ERROR; 8202 8203 CDBG_HIGH("%s: seeMoreStr =%s", __func__, seeMoreStr); 8204 if (seeMoreStr != NULL) { 8205 int value = lookupAttr(ON_OFF_MODES_MAP, 8206 PARAM_MAP_SIZE(ON_OFF_MODES_MAP), 8207 seeMoreStr); 8208 if (value != NAME_NOT_FOUND) { 8209 m_bSeeMoreOn = (value != 0); 8210 8211 // If SeeMore is enabled, enable StillMore for live snapshot 8212 // and disable tone map 8213 if (m_bSeeMoreOn) { 8214 m_bStillMoreOn = TRUE; 8215 rc = setToneMapMode(false, false); 8216 if (rc != NO_ERROR) { 8217 CDBG_HIGH("%s: Failed to disable tone map during SeeMore", __func__); 8218 } 8219 } else { 8220 m_bStillMoreOn = FALSE; 8221 rc = setToneMapMode(true, false); 8222 if (rc != NO_ERROR) { 8223 CDBG_HIGH("%s: Failed to enable tone map during SeeMore", __func__); 8224 } 8225 } 8226 updateParamEntry(KEY_QC_SEE_MORE, seeMoreStr); 8227 return NO_ERROR; 8228 } 8229 } 8230 ALOGE("Invalid see more value: %s", 8231 (seeMoreStr == NULL) ? "NULL" : seeMoreStr); 8232 return BAD_VALUE; 8233 } 8234 8235 /*=========================================================================== 8236 * FUNCTION : setStillMore 8237 * 8238 * DESCRIPTION: set still more value 8239 * 8240 * PARAMETERS : 8241 * @seeMoreStr : still more value string 8242 * 8243 * RETURN : int32_t type of status 8244 * NO_ERROR -- success 8245 * none-zero failure code 8246 *==========================================================================*/ 8247 int32_t QCameraParameters::setStillMore(const char *stillMoreStr) 8248 { 8249 CDBG_HIGH("%s: stillMoreStr =%s", __func__, stillMoreStr); 8250 if (stillMoreStr != NULL) { 8251 int value = lookupAttr(STILL_MORE_MODES_MAP, PARAM_MAP_SIZE(STILL_MORE_MODES_MAP), 8252 stillMoreStr); 8253 if (value != NAME_NOT_FOUND) { 8254 m_bStillMoreOn = (value != 0); 8255 updateParamEntry(KEY_QC_STILL_MORE, stillMoreStr); 8256 8257 return NO_ERROR; 8258 } 8259 } 8260 ALOGE("Invalid still more value: %s", 8261 (stillMoreStr == NULL) ? "NULL" : stillMoreStr); 8262 return BAD_VALUE; 8263 } 8264 8265 /*=========================================================================== 8266 * FUNCTION : setHDRNeed1x 8267 * 8268 * DESCRIPTION: set hdr need 1x value 8269 * 8270 * PARAMETERS : 8271 * @hdrModeStr : hdr need 1x value string 8272 * 8273 * RETURN : int32_t type of status 8274 * NO_ERROR -- success 8275 * none-zero failure code 8276 *==========================================================================*/ 8277 int32_t QCameraParameters::setHDRNeed1x(const char *hdrNeed1xStr) 8278 { 8279 CDBG_HIGH("%s: hdrNeed1xStr =%s", __func__, hdrNeed1xStr); 8280 if (hdrNeed1xStr != NULL) { 8281 int value = lookupAttr(TRUE_FALSE_MODES_MAP, PARAM_MAP_SIZE(TRUE_FALSE_MODES_MAP), 8282 hdrNeed1xStr); 8283 if (value != NAME_NOT_FOUND) { 8284 updateParamEntry(KEY_QC_HDR_NEED_1X, hdrNeed1xStr); 8285 m_bHDR1xFrameEnabled = !strncmp(hdrNeed1xStr, VALUE_TRUE, strlen(VALUE_TRUE)); 8286 m_bNeedRestart = true; 8287 8288 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_HDR_NEED_1X, 8289 m_bHDR1xFrameEnabled)) { 8290 return BAD_VALUE; 8291 } 8292 return NO_ERROR; 8293 } 8294 } 8295 8296 CDBG_HIGH("Invalid hdr need 1x value: %s", 8297 (hdrNeed1xStr == NULL) ? "NULL" : hdrNeed1xStr); 8298 return BAD_VALUE; 8299 } 8300 8301 /*=========================================================================== 8302 * FUNCTION : setAEBracketing 8303 * 8304 * DESCRIPTION: enables AE bracketing 8305 * 8306 * PARAMETERS : 8307 * 8308 * RETURN : int32_t type of status 8309 * NO_ERROR -- success 8310 * none-zero failure code 8311 *==========================================================================*/ 8312 int32_t QCameraParameters::setAEBracketing() 8313 { 8314 int32_t rc = NO_ERROR; 8315 if(initBatchUpdate(m_pParamBuf) < 0 ) { 8316 ALOGE("%s:Failed to initialize group update table", __func__); 8317 return BAD_TYPE; 8318 } 8319 8320 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_HDR, m_AEBracketingClient)) { 8321 ALOGE("%s:Failed to update AE bracketing", __func__); 8322 return BAD_VALUE; 8323 } 8324 8325 rc = commitSetBatch(); 8326 if (rc != NO_ERROR) { 8327 ALOGE("%s:Failed to configure AE bracketing", __func__); 8328 return rc; 8329 } 8330 8331 return rc; 8332 } 8333 8334 /*=========================================================================== 8335 * FUNCTION : setHDRAEBracket 8336 * 8337 * DESCRIPTION: enables AE bracketing for HDR 8338 * 8339 * PARAMETERS : 8340 * @hdrBracket : HDR bracketing configuration 8341 * 8342 * RETURN : int32_t type of status 8343 * NO_ERROR -- success 8344 * none-zero failure code 8345 *==========================================================================*/ 8346 int32_t QCameraParameters::setHDRAEBracket(cam_exp_bracketing_t hdrBracket) 8347 { 8348 int32_t rc = NO_ERROR; 8349 if(initBatchUpdate(m_pParamBuf) < 0 ) { 8350 ALOGE("%s:Failed to initialize group update table", __func__); 8351 return BAD_TYPE; 8352 } 8353 8354 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_HDR, hdrBracket)) { 8355 ALOGE("%s:Failed to update table", __func__); 8356 return BAD_TYPE; 8357 } 8358 8359 rc = commitSetBatch(); 8360 if (rc != NO_ERROR) { 8361 ALOGE("%s:Failed to configure HDR bracketing", __func__); 8362 return rc; 8363 } 8364 8365 return rc; 8366 } 8367 8368 /*=========================================================================== 8369 * FUNCTION : restoreAEBracket 8370 * 8371 * DESCRIPTION: restores client AE bracketing configuration after HDR is done 8372 * 8373 * PARAMETERS : 8374 * 8375 * RETURN : int32_t type of status 8376 * NO_ERROR -- success 8377 * none-zero failure code 8378 *==========================================================================*/ 8379 int32_t QCameraParameters::stopAEBracket() 8380 { 8381 cam_exp_bracketing_t bracketing; 8382 8383 bracketing.mode = CAM_EXP_BRACKETING_OFF; 8384 8385 return setHDRAEBracket(bracketing); 8386 } 8387 8388 /*=========================================================================== 8389 * FUNCTION : updateFlash 8390 * 8391 * DESCRIPTION: restores client flash configuration or disables flash 8392 * 8393 * PARAMETERS : 8394 * @commitSettings : flag indicating whether settings need to be commited 8395 * 8396 * RETURN : int32_t type of status 8397 * NO_ERROR -- success 8398 * none-zero failure code 8399 *==========================================================================*/ 8400 int32_t QCameraParameters::updateFlash(bool commitSettings) 8401 { 8402 int32_t rc = NO_ERROR; 8403 int32_t value; 8404 8405 if (commitSettings) { 8406 if(initBatchUpdate(m_pParamBuf) < 0 ) { 8407 ALOGE("%s:Failed to initialize group update table", __func__); 8408 return BAD_TYPE; 8409 } 8410 } 8411 8412 if (isHDREnabled() || m_bAeBracketingEnabled || m_bAFBracketingOn || 8413 m_bOptiZoomOn || m_bReFocusOn) { 8414 value = CAM_FLASH_MODE_OFF; 8415 } else if (m_bChromaFlashOn) { 8416 value = CAM_FLASH_MODE_ON; 8417 } else { 8418 value = mFlashValue; 8419 } 8420 8421 if (value != mFlashDaemonValue) { 8422 CDBG("%s: Setting Flash value %d", __func__, value); 8423 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_LED_MODE, value)) { 8424 ALOGE("%s:Failed to set led mode", __func__); 8425 return BAD_VALUE; 8426 } 8427 mFlashDaemonValue = value; 8428 } else { 8429 rc = NO_ERROR; 8430 } 8431 8432 if (commitSettings) { 8433 rc = commitSetBatch(); 8434 if (rc != NO_ERROR) { 8435 ALOGE("%s:Failed to configure HDR bracketing", __func__); 8436 return rc; 8437 } 8438 } 8439 8440 return rc; 8441 } 8442 8443 /*=========================================================================== 8444 * FUNCTION : setRedeyeReduction 8445 * 8446 * DESCRIPTION: set red eye reduction value 8447 * 8448 * PARAMETERS : 8449 * @redeyeStr : red eye reduction value string 8450 * 8451 * RETURN : int32_t type of status 8452 * NO_ERROR -- success 8453 * none-zero failure code 8454 *==========================================================================*/ 8455 int32_t QCameraParameters::setRedeyeReduction(const char *redeyeStr) 8456 { 8457 if (redeyeStr != NULL) { 8458 int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP, 8459 PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP), redeyeStr); 8460 if (value != NAME_NOT_FOUND) { 8461 CDBG("%s: Setting RedEye Reduce value %s", __func__, redeyeStr); 8462 updateParamEntry(KEY_QC_REDEYE_REDUCTION, redeyeStr); 8463 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, 8464 CAM_INTF_PARM_REDEYE_REDUCTION, value)) { 8465 return BAD_VALUE; 8466 } 8467 return NO_ERROR; 8468 } 8469 } 8470 ALOGE("%s: Invalid RedEye Reduce value: %s", 8471 __func__, (redeyeStr == NULL) ? "NULL" : redeyeStr); 8472 return BAD_VALUE; 8473 } 8474 8475 /*=========================================================================== 8476 * FUNCTION : getDenoiseProcessPlate 8477 * 8478 * DESCRIPTION: query denoise process plate 8479 * 8480 * PARAMETERS : None 8481 * 8482 * RETURN : NR process plate vlaue 8483 *==========================================================================*/ 8484 cam_denoise_process_type_t 8485 QCameraParameters::getDenoiseProcessPlate(cam_intf_parm_type_t type) 8486 { 8487 char prop[PROPERTY_VALUE_MAX]; 8488 memset(prop, 0, sizeof(prop)); 8489 cam_denoise_process_type_t processPlate = CAM_WAVELET_DENOISE_CBCR_ONLY; 8490 if (CAM_INTF_PARM_WAVELET_DENOISE == type) { 8491 property_get("persist.denoise.process.plates", prop, ""); 8492 } else if (CAM_INTF_PARM_TEMPORAL_DENOISE == type) { 8493 property_get("persist.tnr.process.plates", prop, ""); 8494 } else { 8495 ALOGE("%s: Type not supported", __func__); 8496 prop[0] = '\0'; 8497 } 8498 if (strlen(prop) > 0) { 8499 switch(atoi(prop)) { 8500 case 0: 8501 processPlate = CAM_WAVELET_DENOISE_YCBCR_PLANE; 8502 break; 8503 case 1: 8504 processPlate = CAM_WAVELET_DENOISE_CBCR_ONLY; 8505 break; 8506 case 2: 8507 processPlate = CAM_WAVELET_DENOISE_STREAMLINE_YCBCR; 8508 break; 8509 case 3: 8510 processPlate = CAM_WAVELET_DENOISE_STREAMLINED_CBCR; 8511 break; 8512 default: 8513 processPlate = CAM_WAVELET_DENOISE_CBCR_ONLY; 8514 break; 8515 } 8516 } 8517 return processPlate; 8518 } 8519 8520 /*=========================================================================== 8521 * FUNCTION : setWaveletDenoise 8522 * 8523 * DESCRIPTION: set wavelet denoise value 8524 * 8525 * PARAMETERS : 8526 * @wnrStr : wavelet denoise value string 8527 * 8528 * RETURN : int32_t type of status 8529 * NO_ERROR -- success 8530 * none-zero failure code 8531 *==========================================================================*/ 8532 int32_t QCameraParameters::setWaveletDenoise(const char *wnrStr) 8533 { 8534 if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_DENOISE2D) == 0){ 8535 CDBG_HIGH("%s: WNR is not supported",__func__); 8536 return NO_ERROR; 8537 } 8538 8539 if (wnrStr != NULL) { 8540 int value = lookupAttr(DENOISE_ON_OFF_MODES_MAP, 8541 PARAM_MAP_SIZE(DENOISE_ON_OFF_MODES_MAP), wnrStr); 8542 if (value != NAME_NOT_FOUND) { 8543 updateParamEntry(KEY_QC_DENOISE, wnrStr); 8544 8545 cam_denoise_param_t temp; 8546 memset(&temp, 0, sizeof(temp)); 8547 temp.denoise_enable = (uint8_t)value; 8548 m_bWNROn = (value != 0); 8549 if (m_bWNROn) { 8550 temp.process_plates = getDenoiseProcessPlate(CAM_INTF_PARM_WAVELET_DENOISE); 8551 } 8552 CDBG("%s: Denoise enable=%d, plates=%d", 8553 __func__, temp.denoise_enable, temp.process_plates); 8554 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_WAVELET_DENOISE, temp)) { 8555 return BAD_VALUE; 8556 } 8557 return NO_ERROR; 8558 } 8559 } 8560 ALOGE("%s: Invalid Denoise value: %s", __func__, (wnrStr == NULL) ? "NULL" : wnrStr); 8561 return BAD_VALUE; 8562 } 8563 8564 /*=========================================================================== 8565 * FUNCTION : setRdiMode 8566 * 8567 * DESCRIPTION: set rdi mode value 8568 * 8569 * PARAMETERS : 8570 * @str : rdi mode value string 8571 * 8572 * RETURN : int32_t type of status 8573 * NO_ERROR -- success 8574 * none-zero failure code 8575 *==========================================================================*/ 8576 int32_t QCameraParameters::setRdiMode(const char *str) 8577 { 8578 CDBG("RDI_DEBUG %s: rdi mode value: %s", __func__, str); 8579 8580 if (str != NULL) { 8581 int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP, 8582 PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP), str); 8583 if (value != NAME_NOT_FOUND) { 8584 updateParamEntry(KEY_QC_RDI_MODE, str); 8585 m_bRdiMode = (value == 0) ? false : true; 8586 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_RDI_MODE, value)) { 8587 return BAD_VALUE; 8588 } 8589 return NO_ERROR; 8590 } 8591 } 8592 ALOGE("%s: Invalid rdi mode value: %s", __func__, (str == NULL) ? "NULL" : str); 8593 return BAD_VALUE; 8594 } 8595 8596 8597 /*=========================================================================== 8598 * FUNCTION : setSecureMode 8599 * 8600 * DESCRIPTION: set secure mode value 8601 * 8602 * PARAMETERS : 8603 * @str : secure mode value string 8604 * 8605 * RETURN : int32_t type of status 8606 * NO_ERROR -- success 8607 * none-zero failure code 8608 *==========================================================================*/ 8609 int32_t QCameraParameters::setSecureMode(const char *str) 8610 { 8611 ALOGD("%s: Secure mode value: %s", __func__, str); 8612 8613 if (str != NULL) { 8614 int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP, 8615 PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP), str); 8616 if (value != NAME_NOT_FOUND) { 8617 updateParamEntry(KEY_QC_SECURE_MODE, str); 8618 m_bSecureMode = (value == 0)? false : true; 8619 return NO_ERROR; 8620 } 8621 } 8622 ALOGE("%s: Invalid Secure mode value: %s", 8623 __func__, (str == NULL) ? "NULL" : str); 8624 return BAD_VALUE; 8625 } 8626 8627 /*=========================================================================== 8628 * FUNCTION : setPreviewFrameRateMode 8629 * 8630 * DESCRIPTION: set preview frame rate mode 8631 * 8632 * PARAMETERS : 8633 * @mode : preview frame rate mode 8634 * 8635 * RETURN : none 8636 *==========================================================================*/ 8637 void QCameraParameters::setPreviewFrameRateMode(const char *mode) 8638 { 8639 set(KEY_QC_PREVIEW_FRAME_RATE_MODE, mode); 8640 } 8641 8642 /*=========================================================================== 8643 * FUNCTION : getPreviewFrameRateMode 8644 * 8645 * DESCRIPTION: get preview frame rate mode 8646 * 8647 * PARAMETERS : none 8648 * 8649 * RETURN : preview frame rate mode string 8650 *==========================================================================*/ 8651 const char *QCameraParameters::getPreviewFrameRateMode() const 8652 { 8653 return get(KEY_QC_PREVIEW_FRAME_RATE_MODE); 8654 } 8655 8656 /*=========================================================================== 8657 * FUNCTION : setTouchIndexAec 8658 * 8659 * DESCRIPTION: set touch index AEC 8660 * 8661 * PARAMETERS : 8662 * @x,y : 8663 * 8664 * RETURN : none 8665 *==========================================================================*/ 8666 void QCameraParameters::setTouchIndexAec(int x, int y) 8667 { 8668 char str[32]; 8669 snprintf(str, sizeof(str), "%dx%d", x, y); 8670 set(KEY_QC_TOUCH_INDEX_AEC, str); 8671 } 8672 8673 /*=========================================================================== 8674 * FUNCTION : getTouchIndexAec 8675 * 8676 * DESCRIPTION: get touch index AEC 8677 * 8678 * PARAMETERS : 8679 * @x,y : 8680 * 8681 * RETURN : none 8682 *==========================================================================*/ 8683 void QCameraParameters::getTouchIndexAec(int *x, int *y) 8684 { 8685 *x = -1; 8686 *y = -1; 8687 8688 // Get the current string, if it doesn't exist, leave the -1x-1 8689 const char *p = get(KEY_QC_TOUCH_INDEX_AEC); 8690 if (p == 0) 8691 return; 8692 8693 int tempX, tempY; 8694 if (parse_pair(p, &tempX, &tempY, 'x') == 0) { 8695 *x = tempX; 8696 *y = tempY; 8697 } 8698 } 8699 8700 /*=========================================================================== 8701 * FUNCTION : setTouchIndexAf 8702 * 8703 * DESCRIPTION: set touch index AF 8704 * 8705 * PARAMETERS : 8706 * @x,y : 8707 * 8708 * RETURN : none 8709 *==========================================================================*/ 8710 void QCameraParameters::setTouchIndexAf(int x, int y) 8711 { 8712 char str[32]; 8713 snprintf(str, sizeof(str), "%dx%d", x, y); 8714 set(KEY_QC_TOUCH_INDEX_AF, str); 8715 } 8716 8717 /*=========================================================================== 8718 * FUNCTION : getTouchIndexAf 8719 * 8720 * DESCRIPTION: get touch index AF 8721 * 8722 * PARAMETERS : 8723 * @x,y : 8724 * 8725 * RETURN : none 8726 *==========================================================================*/ 8727 void QCameraParameters::getTouchIndexAf(int *x, int *y) 8728 { 8729 *x = -1; 8730 *y = -1; 8731 8732 // Get the current string, if it doesn't exist, leave the -1x-1 8733 const char *p = get(KEY_QC_TOUCH_INDEX_AF); 8734 if (p == 0) 8735 return; 8736 8737 int tempX, tempY; 8738 if (parse_pair(p, &tempX, &tempY, 'x') == 0) { 8739 *x = tempX; 8740 *y = tempY; 8741 } 8742 } 8743 8744 /*=========================================================================== 8745 * FUNCTION : getStreamFormat 8746 * 8747 * DESCRIPTION: get stream format by its type 8748 * 8749 * PARAMETERS : 8750 * @streamType : [input] stream type 8751 * @format : [output] stream format 8752 * 8753 * RETURN : int32_t type of status 8754 * NO_ERROR -- success 8755 * none-zero failure code 8756 *==========================================================================*/ 8757 int32_t QCameraParameters::getStreamRotation(cam_stream_type_t streamType, 8758 cam_pp_feature_config_t &featureConfig, 8759 cam_dimension_t &dim) 8760 { 8761 int32_t ret = NO_ERROR; 8762 const char *str = get(KEY_QC_VIDEO_ROTATION); 8763 int rotationParam = lookupAttr(VIDEO_ROTATION_MODES_MAP, 8764 PARAM_MAP_SIZE(VIDEO_ROTATION_MODES_MAP), str); 8765 featureConfig.rotation = ROTATE_0; 8766 int swapDim = 0; 8767 switch (streamType) { 8768 case CAM_STREAM_TYPE_VIDEO: 8769 switch(rotationParam) { 8770 case 90: 8771 featureConfig.feature_mask |= CAM_QCOM_FEATURE_ROTATION; 8772 featureConfig.rotation = ROTATE_90; 8773 swapDim = 1; 8774 break; 8775 case 180: 8776 featureConfig.feature_mask |= CAM_QCOM_FEATURE_ROTATION; 8777 featureConfig.rotation = ROTATE_180; 8778 break; 8779 case 270: 8780 featureConfig.feature_mask |= CAM_QCOM_FEATURE_ROTATION; 8781 featureConfig.rotation = ROTATE_270; 8782 swapDim = 1; 8783 break; 8784 default: 8785 featureConfig.rotation = ROTATE_0; 8786 } 8787 break; 8788 case CAM_STREAM_TYPE_PREVIEW: 8789 case CAM_STREAM_TYPE_POSTVIEW: 8790 case CAM_STREAM_TYPE_SNAPSHOT: 8791 case CAM_STREAM_TYPE_RAW: 8792 case CAM_STREAM_TYPE_METADATA: 8793 case CAM_STREAM_TYPE_OFFLINE_PROC: 8794 case CAM_STREAM_TYPE_DEFAULT: 8795 default: 8796 break; 8797 } 8798 8799 if (swapDim > 0) { 8800 int w = 0; 8801 w = dim.width; 8802 dim.width = dim.height; 8803 dim.height = w; 8804 } 8805 return ret; 8806 } 8807 8808 /*=========================================================================== 8809 * FUNCTION : getStreamFormat 8810 * 8811 * DESCRIPTION: get stream format by its type 8812 * 8813 * PARAMETERS : 8814 * @streamType : [input] stream type 8815 * @format : [output] stream format 8816 * 8817 * RETURN : int32_t type of status 8818 * NO_ERROR -- success 8819 * none-zero failure code 8820 *==========================================================================*/ 8821 int32_t QCameraParameters::getStreamFormat(cam_stream_type_t streamType, 8822 cam_format_t &format) 8823 { 8824 int32_t ret = NO_ERROR; 8825 8826 format = CAM_FORMAT_MAX; 8827 switch (streamType) { 8828 case CAM_STREAM_TYPE_PREVIEW: 8829 case CAM_STREAM_TYPE_POSTVIEW: 8830 case CAM_STREAM_TYPE_CALLBACK: 8831 format = mPreviewFormat; 8832 break; 8833 case CAM_STREAM_TYPE_ANALYSIS: 8834 if (m_pCapability->analysis_recommended_format == 8835 CAM_FORMAT_Y_ONLY) { 8836 format = m_pCapability->analysis_recommended_format; 8837 } else { 8838 ALOGE("%s:%d invalid analysis_recommended_format %d\n", 8839 m_pCapability->analysis_recommended_format); 8840 format = mPreviewFormat; 8841 } 8842 break; 8843 case CAM_STREAM_TYPE_SNAPSHOT: 8844 if ( mPictureFormat == CAM_FORMAT_YUV_422_NV16 ) { 8845 format = CAM_FORMAT_YUV_422_NV16; 8846 } else { 8847 char prop[PROPERTY_VALUE_MAX]; 8848 int snapshotFormat; 8849 memset(prop, 0, sizeof(prop)); 8850 property_get("persist.camera.snap.format", prop, "0"); 8851 snapshotFormat = atoi(prop); 8852 if(snapshotFormat == 1) { 8853 format = CAM_FORMAT_YUV_422_NV61; 8854 } else { 8855 format = CAM_FORMAT_YUV_420_NV21; 8856 } 8857 } 8858 break; 8859 case CAM_STREAM_TYPE_VIDEO: 8860 format = CAM_FORMAT_YUV_420_NV12; 8861 break; 8862 case CAM_STREAM_TYPE_RAW: 8863 if (isRdiMode()) { 8864 format = m_pCapability->rdi_mode_stream_fmt; 8865 } else if (mPictureFormat >= CAM_FORMAT_YUV_RAW_8BIT_YUYV) { 8866 format = (cam_format_t)mPictureFormat; 8867 } else if (getofflineRAW()) { 8868 format = CAM_FORMAT_BAYER_MIPI_RAW_10BPP_BGGR; 8869 } else { 8870 char raw_format[PROPERTY_VALUE_MAX]; 8871 int rawFormat; 8872 memset(raw_format, 0, sizeof(raw_format)); 8873 /*Default value is CAM_FORMAT_BAYER_QCOM_RAW_10BPP_GBRG*/ 8874 property_get("persist.camera.raw.format", raw_format, "16"); 8875 rawFormat = atoi(raw_format); 8876 format = (cam_format_t)rawFormat; 8877 CDBG_HIGH("%s: Raw stream format %d bundled with snapshot", 8878 __func__, format); 8879 } 8880 break; 8881 case CAM_STREAM_TYPE_METADATA: 8882 case CAM_STREAM_TYPE_OFFLINE_PROC: 8883 case CAM_STREAM_TYPE_DEFAULT: 8884 default: 8885 break; 8886 } 8887 8888 return ret; 8889 } 8890 8891 /*=========================================================================== 8892 * FUNCTION : getFlipMode 8893 * 8894 * DESCRIPTION: get flip mode 8895 * 8896 * PARAMETERS : 8897 * @cam_intf_parm_type_t : [input] stream type 8898 * 8899 * RETURN : int type of flip mode 8900 * 0 - no filp 8901 * 1 - FLIP_H 8902 * 2 - FLIP_V 8903 * 3 - FLIP_H | FLIP_V 8904 *==========================================================================*/ 8905 int QCameraParameters::getFlipMode(cam_stream_type_t type) 8906 { 8907 const char *str = NULL; 8908 int flipMode = 0; // no flip 8909 8910 switch(type){ 8911 case CAM_STREAM_TYPE_PREVIEW: 8912 if (!isRdiMode()) { 8913 str = get(KEY_QC_PREVIEW_FLIP); 8914 } 8915 break; 8916 case CAM_STREAM_TYPE_VIDEO: 8917 str = get(KEY_QC_VIDEO_FLIP); 8918 break; 8919 case CAM_STREAM_TYPE_SNAPSHOT: 8920 case CAM_STREAM_TYPE_POSTVIEW: 8921 str = get(KEY_QC_SNAPSHOT_PICTURE_FLIP); 8922 break; 8923 default: 8924 CDBG("%s: No flip mode for stream type %d", __func__, type); 8925 break; 8926 } 8927 8928 if(str != NULL){ 8929 //Need give corresponding filp value based on flip mode strings 8930 int value = lookupAttr(FLIP_MODES_MAP, PARAM_MAP_SIZE(FLIP_MODES_MAP), str); 8931 if(value != NAME_NOT_FOUND) 8932 flipMode = value; 8933 } 8934 8935 CDBG_HIGH("%s: the filp mode of stream type %d is %d .", __func__, type, flipMode); 8936 return flipMode; 8937 } 8938 8939 /*=========================================================================== 8940 * FUNCTION : isSnapshotFDNeeded 8941 * 8942 * DESCRIPTION: check whether Face Detection Metadata is needed 8943 * 8944 * PARAMETERS : none 8945 * 8946 * RETURN : bool type of status 8947 * 0 - need 8948 * 1 - not need 8949 *==========================================================================*/ 8950 bool QCameraParameters::isSnapshotFDNeeded() 8951 { 8952 return getInt(KEY_QC_SNAPSHOT_FD_DATA); 8953 } 8954 8955 /*=========================================================================== 8956 * FUNCTION : getStreamDimension 8957 * 8958 * DESCRIPTION: get stream dimension by its type 8959 * 8960 * PARAMETERS : 8961 * @streamType : [input] stream type 8962 * @dim : [output] stream dimension 8963 * 8964 * RETURN : int32_t type of status 8965 * NO_ERROR -- success 8966 * none-zero failure code 8967 *==========================================================================*/ 8968 int32_t QCameraParameters::getStreamDimension(cam_stream_type_t streamType, 8969 cam_dimension_t &dim) 8970 { 8971 int32_t ret = NO_ERROR; 8972 memset(&dim, 0, sizeof(cam_dimension_t)); 8973 8974 switch (streamType) { 8975 case CAM_STREAM_TYPE_PREVIEW: 8976 getPreviewSize(&dim.width, &dim.height); 8977 break; 8978 case CAM_STREAM_TYPE_POSTVIEW: 8979 getPreviewSize(&dim.width, &dim.height); 8980 break; 8981 case CAM_STREAM_TYPE_SNAPSHOT: 8982 if (getRecordingHintValue() == true) { 8983 // live snapshot 8984 getLiveSnapshotSize(dim); 8985 } else { 8986 getPictureSize(&dim.width, &dim.height); 8987 } 8988 break; 8989 case CAM_STREAM_TYPE_VIDEO: 8990 getVideoSize(&dim.width, &dim.height); 8991 break; 8992 case CAM_STREAM_TYPE_RAW: 8993 //dim = m_pCapability->raw_dim; 8994 getRawSize(dim); 8995 break; 8996 case CAM_STREAM_TYPE_METADATA: 8997 dim.width = (int32_t)sizeof(metadata_buffer_t); 8998 dim.height = 1; 8999 break; 9000 case CAM_STREAM_TYPE_OFFLINE_PROC: 9001 break; 9002 case CAM_STREAM_TYPE_ANALYSIS: 9003 cam_dimension_t prv_dim, max_dim; 9004 9005 /* Analysis stream need aspect ratio as preview stream */ 9006 getPreviewSize(&prv_dim.width, &prv_dim.height); 9007 9008 max_dim.width = m_pCapability->analysis_max_res.width; 9009 max_dim.height = m_pCapability->analysis_max_res.height; 9010 9011 if (prv_dim.width > max_dim.width || prv_dim.height > max_dim.height) { 9012 double max_ratio, requested_ratio; 9013 9014 max_ratio = (double)max_dim.width / (double)max_dim.height; 9015 requested_ratio = (double)prv_dim.width / (double)prv_dim.height; 9016 9017 if (max_ratio < requested_ratio) { 9018 dim.width = max_dim.width; 9019 dim.height = (int32_t)((double)dim.width / requested_ratio); 9020 } else { 9021 dim.height = max_dim.height; 9022 dim.width = (int32_t)((double)max_dim.height * requested_ratio); 9023 } 9024 dim.width &= ~0x1; 9025 dim.height &= ~0x1; 9026 } else { 9027 dim.width = prv_dim.width; 9028 dim.height = prv_dim.height; 9029 } 9030 break; 9031 case CAM_STREAM_TYPE_DEFAULT: 9032 default: 9033 ALOGE("%s: no dimension for unsupported stream type %d", 9034 __func__, streamType); 9035 ret = BAD_VALUE; 9036 break; 9037 } 9038 return ret; 9039 } 9040 9041 /*=========================================================================== 9042 * FUNCTION : getPreviewHalPixelFormat 9043 * 9044 * DESCRIPTION: get preview HAL pixel format 9045 * 9046 * PARAMETERS : none 9047 * 9048 * RETURN : HAL pixel format 9049 *==========================================================================*/ 9050 int QCameraParameters::getPreviewHalPixelFormat() const 9051 { 9052 int32_t halPixelFormat; 9053 9054 switch (mPreviewFormat) { 9055 case CAM_FORMAT_YUV_420_NV12: 9056 halPixelFormat = HAL_PIXEL_FORMAT_YCbCr_420_SP; 9057 break; 9058 case CAM_FORMAT_YUV_420_NV21: 9059 halPixelFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP; 9060 break; 9061 case CAM_FORMAT_YUV_420_NV21_ADRENO: 9062 halPixelFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO; 9063 break; 9064 case CAM_FORMAT_YUV_420_YV12: 9065 halPixelFormat = HAL_PIXEL_FORMAT_YV12; 9066 break; 9067 case CAM_FORMAT_YUV_420_NV12_VENUS: 9068 halPixelFormat = HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS; 9069 break; 9070 case CAM_FORMAT_YUV_422_NV16: 9071 case CAM_FORMAT_YUV_422_NV61: 9072 default: 9073 halPixelFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP; 9074 break; 9075 } 9076 CDBG_HIGH("%s: format %d\n", __func__, halPixelFormat); 9077 return halPixelFormat; 9078 } 9079 9080 /*=========================================================================== 9081 * FUNCTION : getthumbnailSize 9082 * 9083 * DESCRIPTION: get thumbnail size 9084 * 9085 * PARAMETERS : 9086 * @width, height : [output] thumbnail width and height 9087 * 9088 * RETURN : none 9089 *==========================================================================*/ 9090 void QCameraParameters::getThumbnailSize(int *width, int *height) const 9091 { 9092 *width = getInt(KEY_JPEG_THUMBNAIL_WIDTH); 9093 *height = getInt(KEY_JPEG_THUMBNAIL_HEIGHT); 9094 } 9095 9096 /*=========================================================================== 9097 * FUNCTION : getZSLBurstInterval 9098 * 9099 * DESCRIPTION: get ZSL burst interval setting 9100 * 9101 * PARAMETERS : none 9102 * 9103 * RETURN : ZSL burst interval value 9104 *==========================================================================*/ 9105 uint8_t QCameraParameters::getZSLBurstInterval() 9106 { 9107 int interval = getInt(KEY_QC_ZSL_BURST_INTERVAL); 9108 if (interval < 0) { 9109 interval = 1; 9110 } 9111 return (uint8_t)interval; 9112 } 9113 9114 /*=========================================================================== 9115 * FUNCTION : getZSLQueueDepth 9116 * 9117 * DESCRIPTION: get ZSL queue depth 9118 * 9119 * PARAMETERS : none 9120 * 9121 * RETURN : ZSL queue depth value 9122 *==========================================================================*/ 9123 uint8_t QCameraParameters::getZSLQueueDepth() 9124 { 9125 int qdepth = getInt(KEY_QC_ZSL_QUEUE_DEPTH); 9126 if (qdepth < 0) { 9127 qdepth = 2; 9128 } 9129 return (uint8_t)qdepth; 9130 } 9131 9132 /*=========================================================================== 9133 * FUNCTION : getZSLBackLookCount 9134 * 9135 * DESCRIPTION: get ZSL backlook count setting 9136 * 9137 * PARAMETERS : none 9138 * 9139 * RETURN : ZSL backlook count value 9140 *==========================================================================*/ 9141 uint8_t QCameraParameters::getZSLBackLookCount() 9142 { 9143 int look_back = getInt(KEY_QC_ZSL_BURST_LOOKBACK); 9144 if (look_back < 0) { 9145 look_back = 2; 9146 } 9147 return (uint8_t)look_back; 9148 } 9149 9150 /*=========================================================================== 9151 * FUNCTION : getZSLMaxUnmatchedFrames 9152 * 9153 * DESCRIPTION: get allowed ZSL max unmatched frames number 9154 * 9155 * PARAMETERS : none 9156 * 9157 * RETURN : ZSL backlook count value 9158 *==========================================================================*/ 9159 uint8_t QCameraParameters::getMaxUnmatchedFramesInQueue() 9160 { 9161 return (uint8_t)(m_pCapability->min_num_pp_bufs + (m_nBurstNum / 10)); 9162 } 9163 9164 /*=========================================================================== 9165 * FUNCTION : setRecordingHintValue 9166 * 9167 * DESCRIPTION: set recording hint 9168 * 9169 * PARAMETERS : 9170 * @value : video hint value 9171 * 9172 * RETURN : int32_t type of status 9173 * NO_ERROR -- success 9174 * none-zero failure code 9175 *==========================================================================*/ 9176 int QCameraParameters::setRecordingHintValue(int32_t value) 9177 { 9178 CDBG_HIGH("%s: VideoHint = %d", __func__, value); 9179 bool newValue = (value > 0)? true : false; 9180 9181 if ( m_bRecordingHint != newValue ) { 9182 m_bNeedRestart = true; 9183 m_bRecordingHint_new = newValue; 9184 } else { 9185 m_bRecordingHint_new = m_bRecordingHint; 9186 } 9187 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_RECORDING_HINT, value)) { 9188 return BAD_VALUE; 9189 } 9190 9191 return NO_ERROR; 9192 } 9193 9194 /*=========================================================================== 9195 * FUNCTION : getNumOfSnapshots 9196 * 9197 * DESCRIPTION: get number of snapshot per shutter 9198 * 9199 * PARAMETERS : none 9200 * 9201 * RETURN : number of snapshot per shutter 9202 *==========================================================================*/ 9203 uint8_t QCameraParameters::getNumOfSnapshots() 9204 { 9205 uint8_t numOfSnapshot = 1; 9206 int val = getInt(KEY_QC_NUM_SNAPSHOT_PER_SHUTTER); 9207 if (0 < val) { 9208 numOfSnapshot = (uint8_t)val; 9209 } 9210 9211 return (uint8_t)numOfSnapshot; 9212 } 9213 9214 /*=========================================================================== 9215 * FUNCTION : getBurstCountForAdvancedCapture 9216 * 9217 * DESCRIPTION: get burst count for advanced capture. 9218 * 9219 * PARAMETERS : none 9220 * 9221 * RETURN : number of snapshot required for advanced capture. 9222 *==========================================================================*/ 9223 uint8_t QCameraParameters::getBurstCountForAdvancedCapture() 9224 { 9225 uint32_t burstCount = 0; 9226 if (isUbiFocusEnabled()) { 9227 //number of snapshots required for Ubi Focus. 9228 burstCount = m_pCapability->ubifocus_af_bracketing_need.burst_count; 9229 } else if (isUbiRefocus()) { 9230 //number of snapshots required for Opti Zoom. 9231 burstCount = m_pCapability->refocus_af_bracketing_need.burst_count; 9232 } else if (isOptiZoomEnabled()) { 9233 //number of snapshots required for Opti Zoom. 9234 burstCount = m_pCapability->opti_zoom_settings_need.burst_count; 9235 } else if (isChromaFlashEnabled()) { 9236 //number of snapshots required for Chroma Flash. 9237 burstCount = m_pCapability->chroma_flash_settings_need.burst_count; 9238 } else if (isStillMoreEnabled()) { 9239 //number of snapshots required for Still More. 9240 if (isSeeMoreEnabled()) { 9241 burstCount = 1; 9242 } else if ((m_stillmore_config.burst_count >= 9243 m_pCapability->stillmore_settings_need.min_burst_count) && 9244 (m_stillmore_config.burst_count <= 9245 m_pCapability->stillmore_settings_need.max_burst_count)) { 9246 burstCount = m_stillmore_config.burst_count; 9247 } else { 9248 burstCount = m_pCapability->stillmore_settings_need.burst_count; 9249 } 9250 } else if (isHDREnabled()) { 9251 //number of snapshots required for HDR. 9252 burstCount = m_pCapability->hdr_bracketing_setting.num_frames; 9253 } else if (isAEBracketEnabled()) { 9254 burstCount = 0; 9255 const char *str_val = m_AEBracketingClient.values; 9256 if ((str_val != NULL) && (strlen(str_val) > 0)) { 9257 char prop[PROPERTY_VALUE_MAX]; 9258 memset(prop, 0, sizeof(prop)); 9259 strlcpy(prop, str_val, PROPERTY_VALUE_MAX); 9260 char *saveptr = NULL; 9261 char *token = strtok_r(prop, ",", &saveptr); 9262 while (token != NULL) { 9263 token = strtok_r(NULL, ",", &saveptr); 9264 burstCount++; 9265 } 9266 } 9267 } 9268 if (burstCount <= 0) { 9269 burstCount = 1; 9270 } 9271 9272 CDBG_HIGH("%s: Snapshot burst count = %d", __func__, burstCount); 9273 return (uint8_t)burstCount; 9274 } 9275 9276 /*=========================================================================== 9277 * FUNCTION : getNumOfRetroSnapshots 9278 * 9279 * DESCRIPTION: get number of retro active snapshots per shutter 9280 * 9281 * PARAMETERS : none 9282 * 9283 * RETURN : number of retro active snapshots per shutter 9284 *==========================================================================*/ 9285 uint8_t QCameraParameters::getNumOfRetroSnapshots() 9286 { 9287 int numOfRetroSnapshots = getInt(KEY_QC_NUM_RETRO_BURST_PER_SHUTTER); 9288 if (numOfRetroSnapshots < 0) { 9289 numOfRetroSnapshots = 0; 9290 } 9291 CDBG_HIGH("%s: [ZSL Retro] : numOfRetroSnaps - %d", __func__, numOfRetroSnapshots); 9292 return (uint8_t)numOfRetroSnapshots; 9293 } 9294 9295 /*=========================================================================== 9296 * FUNCTION : getBurstLEDOnPeriod 9297 * 9298 * DESCRIPTION: get burst LED on period 9299 * 9300 * PARAMETERS : none 9301 * 9302 * RETURN : burst LED on period 9303 *==========================================================================*/ 9304 int QCameraParameters::getBurstLEDOnPeriod() 9305 { 9306 CDBG_HIGH("%s: [ZSL Retro] burst LED ON period: %d", __func__, m_nBurstLEDOnPeriod); 9307 return m_nBurstLEDOnPeriod; 9308 } 9309 9310 /*=========================================================================== 9311 * FUNCTION : getNumOfExtraHDRInBufsIfNeeded 9312 * 9313 * DESCRIPTION: get number of extra input buffers needed by HDR 9314 * 9315 * PARAMETERS : none 9316 * 9317 * RETURN : number of extra buffers needed by HDR; 0 if not HDR enabled 9318 *==========================================================================*/ 9319 uint8_t QCameraParameters::getNumOfExtraHDRInBufsIfNeeded() 9320 { 9321 unsigned int numOfBufs = 0; 9322 9323 if (isHDREnabled()) { 9324 numOfBufs += m_pCapability->hdr_bracketing_setting.num_frames; 9325 if (isHDR1xFrameEnabled() && isHDR1xExtraBufferNeeded()) { 9326 numOfBufs++; 9327 } 9328 numOfBufs--; // Only additional buffers need to be returned 9329 } 9330 9331 return (uint8_t)(numOfBufs * getBurstNum()); 9332 } 9333 9334 /*=========================================================================== 9335 * FUNCTION : getNumOfExtraHDROutBufsIfNeeded 9336 * 9337 * DESCRIPTION: get number of extra output buffers needed by HDR 9338 * 9339 * PARAMETERS : none 9340 * 9341 * RETURN : number of extra buffers needed by HDR; 0 if not HDR enabled 9342 *==========================================================================*/ 9343 uint8_t QCameraParameters::getNumOfExtraHDROutBufsIfNeeded() 9344 { 9345 int numOfBufs = 0; 9346 9347 if (isHDREnabled() && isHDR1xFrameEnabled()) { 9348 numOfBufs++; 9349 } 9350 9351 return (uint8_t)(numOfBufs * getBurstNum()); 9352 } 9353 9354 /*=========================================================================== 9355 * FUNCTION : getBurstNum 9356 * 9357 * DESCRIPTION: get burst number of snapshot 9358 * 9359 * PARAMETERS : none 9360 * 9361 * RETURN : number of burst 9362 *==========================================================================*/ 9363 uint8_t QCameraParameters::getBurstNum() 9364 { 9365 CDBG_HIGH("%s: m_nBurstNum = %d", __func__, m_nBurstNum); 9366 return m_nBurstNum; 9367 } 9368 9369 /*=========================================================================== 9370 * FUNCTION : getJpegQuality 9371 * 9372 * DESCRIPTION: get jpeg encoding quality 9373 * 9374 * PARAMETERS : none 9375 * 9376 * RETURN : jpeg encoding quality 9377 *==========================================================================*/ 9378 uint32_t QCameraParameters::getJpegQuality() 9379 { 9380 int quality = getInt(KEY_JPEG_QUALITY); 9381 if (quality < 0) { 9382 quality = 85; // set to default quality value 9383 } 9384 return (uint32_t)quality; 9385 } 9386 9387 /*=========================================================================== 9388 * FUNCTION : getRotation 9389 * 9390 * DESCRIPTION: get application configured rotation 9391 * 9392 * PARAMETERS : none 9393 * 9394 * RETURN : rotation value 9395 *==========================================================================*/ 9396 uint32_t QCameraParameters::getRotation() { 9397 int rotation = 0; 9398 9399 //If exif rotation is set, do not rotate captured image 9400 if (!useJpegExifRotation()) { 9401 rotation = mRotation; 9402 if (rotation < 0) { 9403 rotation = 0; 9404 } 9405 } 9406 return (uint32_t)rotation; 9407 } 9408 9409 /*=========================================================================== 9410 * FUNCTION : setJpegRotation 9411 * 9412 * DESCRIPTION: set jpeg rotation value configured internally 9413 * 9414 * PARAMETERS : none 9415 * 9416 * RETURN : jpeg rotation value 9417 *==========================================================================*/ 9418 void QCameraParameters::setJpegRotation(int rotation) { 9419 if (rotation == 0 || rotation == 90 || 9420 rotation == 180 || rotation == 270) { 9421 mJpegRotation = (uint32_t)rotation; 9422 } 9423 } 9424 9425 /*=========================================================================== 9426 * FUNCTION : getDeviceRotation 9427 * 9428 * DESCRIPTION: get device rotation value 9429 * 9430 * PARAMETERS : none 9431 * 9432 * RETURN : device rotation value 9433 *==========================================================================*/ 9434 uint32_t QCameraParameters::getDeviceRotation() { 9435 int rotation = 0; 9436 9437 rotation = mRotation; 9438 if (rotation < 0) { 9439 rotation = 0; 9440 } 9441 9442 return (uint32_t)rotation; 9443 } 9444 9445 /*=========================================================================== 9446 * FUNCTION : getJpegExifRotation 9447 * 9448 * DESCRIPTION: get exif rotation value 9449 * 9450 * PARAMETERS : none 9451 * 9452 * RETURN : rotation value 9453 *==========================================================================*/ 9454 uint32_t QCameraParameters::getJpegExifRotation() { 9455 int rotation = 0; 9456 9457 if (useJpegExifRotation()) { 9458 rotation = mRotation; 9459 if (rotation < 0) { 9460 rotation = 0; 9461 } 9462 } 9463 return (uint32_t)rotation; 9464 } 9465 9466 /*=========================================================================== 9467 * FUNCTION : useJpegExifRotation 9468 * 9469 * DESCRIPTION: Check if jpeg exif rotation need to be used 9470 * 9471 * PARAMETERS : none 9472 * 9473 * RETURN : true if jpeg exif rotation need to be used 9474 *==========================================================================*/ 9475 bool QCameraParameters::useJpegExifRotation() { 9476 char exifRotation[PROPERTY_VALUE_MAX]; 9477 9478 property_get("persist.camera.exif.rotation", exifRotation, "off"); 9479 if (!strcmp(exifRotation, "on")) { 9480 return true; 9481 } 9482 return false; 9483 } 9484 9485 /*=========================================================================== 9486 * FUNCTION : getEffectValue 9487 * 9488 * DESCRIPTION: get effect value 9489 * 9490 * PARAMETERS : none 9491 * 9492 * RETURN : effect value 9493 *==========================================================================*/ 9494 int32_t QCameraParameters::getEffectValue() 9495 { 9496 uint32_t cnt = 0; 9497 const char *effect = get(KEY_EFFECT); 9498 if (effect) { 9499 while (NULL != EFFECT_MODES_MAP[cnt].desc) { 9500 if (!strcmp(EFFECT_MODES_MAP[cnt].desc, effect)) { 9501 return EFFECT_MODES_MAP[cnt].val; 9502 } 9503 cnt++; 9504 } 9505 } else { 9506 ALOGE("%s: Missing effect value", __func__); 9507 } 9508 return CAM_EFFECT_MODE_OFF; 9509 } 9510 9511 /*=========================================================================== 9512 * FUNCTION : parseGPSCoordinate 9513 * 9514 * DESCRIPTION: parse GPS coordinate string 9515 * 9516 * PARAMETERS : 9517 * @coord_str : [input] coordinate string 9518 * @coord : [output] ptr to struct to store coordinate 9519 * 9520 * RETURN : int32_t type of status 9521 * NO_ERROR -- success 9522 * none-zero failure code 9523 *==========================================================================*/ 9524 int QCameraParameters::parseGPSCoordinate(const char *coord_str, rat_t* coord) 9525 { 9526 if(coord == NULL) { 9527 ALOGE("%s: error, invalid argument coord == NULL", __func__); 9528 return BAD_VALUE; 9529 } 9530 double degF = atof(coord_str); 9531 if (degF < 0) { 9532 degF = -degF; 9533 } 9534 double minF = (degF - (double)(int) degF) * 60.0; 9535 double secF = (minF - (double)(int) minF) * 60.0; 9536 9537 getRational(&coord[0], (int)degF, 1); 9538 getRational(&coord[1], (int)minF, 1); 9539 getRational(&coord[2], (int)(secF * 10000.0), 10000); 9540 return NO_ERROR; 9541 } 9542 9543 /*=========================================================================== 9544 * FUNCTION : getExifDateTime 9545 * 9546 * DESCRIPTION: query exif date time 9547 * 9548 * PARAMETERS : 9549 * @dateTime : String to store exif date time. 9550 * Should be leaved unchanged in case of error. 9551 * @subsecTime : String to store exif time nanoseconds. 9552 * Should be leaved unchanged in case of error. 9553 * 9554 * RETURN : int32_t type of status 9555 * NO_ERROR -- success 9556 * none-zero failure code 9557 *==========================================================================*/ 9558 int32_t QCameraParameters::getExifDateTime(String8 &dateTime, String8 &subsecTime) 9559 { 9560 int32_t ret = NO_ERROR; 9561 9562 //get time and date from system 9563 struct timeval tv; 9564 struct tm timeinfo_data; 9565 9566 int res = gettimeofday(&tv, NULL); 9567 if (0 == res) { 9568 struct tm *timeinfo = localtime_r(&tv.tv_sec, &timeinfo_data); 9569 if (NULL != timeinfo) { 9570 //Write datetime according to EXIF Spec 9571 //"YYYY:MM:DD HH:MM:SS" (20 chars including \0) 9572 dateTime = String8::format("%04d:%02d:%02d %02d:%02d:%02d", 9573 timeinfo->tm_year + 1900, timeinfo->tm_mon + 1, 9574 timeinfo->tm_mday, timeinfo->tm_hour, 9575 timeinfo->tm_min, timeinfo->tm_sec); 9576 //Write subsec according to EXIF Sepc 9577 subsecTime = String8::format("%06ld", tv.tv_usec); 9578 } else { 9579 ALOGE("%s: localtime_r() error", __func__); 9580 ret = UNKNOWN_ERROR; 9581 } 9582 } else if (-1 == res) { 9583 ALOGE("%s: gettimeofday() error: %s", __func__, strerror(errno)); 9584 ret = UNKNOWN_ERROR; 9585 } else { 9586 ALOGE("%s: gettimeofday() unexpected return code: %d", __func__, res); 9587 ret = UNKNOWN_ERROR; 9588 } 9589 9590 return ret; 9591 } 9592 9593 /*=========================================================================== 9594 * FUNCTION : getRational 9595 * 9596 * DESCRIPTION: compose rational struct 9597 * 9598 * PARAMETERS : 9599 * @rat : ptr to struct to store rational info 9600 * @num :num of the rational 9601 * @denom : denom of the rational 9602 * 9603 * RETURN : int32_t type of status 9604 * NO_ERROR -- success 9605 * none-zero failure code 9606 *==========================================================================*/ 9607 int32_t QCameraParameters::getRational(rat_t *rat, int num, int denom) 9608 { 9609 if ((0 > num) || (0 > denom)) { 9610 ALOGE("%s: Negative values", __func__); 9611 return BAD_VALUE; 9612 } 9613 if (NULL == rat) { 9614 ALOGE("%s: NULL rat input", __func__); 9615 return BAD_VALUE; 9616 } 9617 rat->num = (uint32_t)num; 9618 rat->denom = (uint32_t)denom; 9619 return NO_ERROR; 9620 } 9621 9622 /*=========================================================================== 9623 * FUNCTION : getExifFocalLength 9624 * 9625 * DESCRIPTION: get exif focal lenght 9626 * 9627 * PARAMETERS : 9628 * @focalLength : ptr to rational strcut to store focal lenght 9629 * 9630 * RETURN : int32_t type of status 9631 * NO_ERROR -- success 9632 * none-zero failure code 9633 *==========================================================================*/ 9634 int32_t QCameraParameters::getExifFocalLength(rat_t *focalLength) 9635 { 9636 int focalLengthValue = 9637 (int)(getFloat(QCameraParameters::KEY_FOCAL_LENGTH) * FOCAL_LENGTH_DECIMAL_PRECISION); 9638 return getRational(focalLength, focalLengthValue, FOCAL_LENGTH_DECIMAL_PRECISION); 9639 } 9640 9641 /*=========================================================================== 9642 * FUNCTION : getExifIsoSpeed 9643 * 9644 * DESCRIPTION: get exif ISO speed 9645 * 9646 * PARAMETERS : none 9647 * 9648 * RETURN : ISO speed value 9649 *==========================================================================*/ 9650 uint16_t QCameraParameters::getExifIsoSpeed() 9651 { 9652 uint16_t isoSpeed = 0; 9653 const char *iso_str = get(QCameraParameters::KEY_QC_ISO_MODE); 9654 int iso_index = lookupAttr(ISO_MODES_MAP, PARAM_MAP_SIZE(ISO_MODES_MAP), iso_str); 9655 switch (iso_index) { 9656 case CAM_ISO_MODE_AUTO: 9657 isoSpeed = 0; 9658 break; 9659 case CAM_ISO_MODE_DEBLUR: 9660 isoSpeed = 1; 9661 break; 9662 case CAM_ISO_MODE_100: 9663 isoSpeed = 100; 9664 break; 9665 case CAM_ISO_MODE_200: 9666 isoSpeed = 200; 9667 break; 9668 case CAM_ISO_MODE_400: 9669 isoSpeed = 400; 9670 break; 9671 case CAM_ISO_MODE_800: 9672 isoSpeed = 800; 9673 break; 9674 case CAM_ISO_MODE_1600: 9675 isoSpeed = 1600; 9676 break; 9677 case CAM_ISO_MODE_3200: 9678 isoSpeed = 3200; 9679 break; 9680 } 9681 return isoSpeed; 9682 } 9683 9684 /*=========================================================================== 9685 * FUNCTION : getExifGpsProcessingMethod 9686 * 9687 * DESCRIPTION: get GPS processing method 9688 * 9689 * PARAMETERS : 9690 * @gpsProcessingMethod : string to store GPS process method 9691 * @count : lenght of the string 9692 * 9693 * RETURN : int32_t type of status 9694 * NO_ERROR -- success 9695 * none-zero failure code 9696 *==========================================================================*/ 9697 int32_t QCameraParameters::getExifGpsProcessingMethod(char *gpsProcessingMethod, 9698 uint32_t &count) 9699 { 9700 const char *str = get(KEY_GPS_PROCESSING_METHOD); 9701 if(str != NULL) { 9702 memcpy(gpsProcessingMethod, ExifAsciiPrefix, EXIF_ASCII_PREFIX_SIZE); 9703 count = EXIF_ASCII_PREFIX_SIZE; 9704 strlcpy(gpsProcessingMethod + EXIF_ASCII_PREFIX_SIZE, str, strlen(str)+1); 9705 count += (uint32_t)strlen(str); 9706 gpsProcessingMethod[count++] = '\0'; // increase 1 for the last NULL char 9707 return NO_ERROR; 9708 } else { 9709 return BAD_VALUE; 9710 } 9711 } 9712 9713 /*=========================================================================== 9714 * FUNCTION : getExifLatitude 9715 * 9716 * DESCRIPTION: get exif latitude 9717 * 9718 * PARAMETERS : 9719 * @latitude : ptr to rational struct to store latitude info 9720 * @ladRef : charater to indicate latitude reference 9721 * 9722 * RETURN : int32_t type of status 9723 * NO_ERROR -- success 9724 * none-zero failure code 9725 *==========================================================================*/ 9726 int32_t QCameraParameters::getExifLatitude(rat_t *latitude, 9727 char *latRef) 9728 { 9729 const char *str = get(KEY_GPS_LATITUDE); 9730 if(str != NULL) { 9731 parseGPSCoordinate(str, latitude); 9732 9733 //set Latitude Ref 9734 float latitudeValue = getFloat(KEY_GPS_LATITUDE); 9735 if(latitudeValue < 0.0f) { 9736 latRef[0] = 'S'; 9737 } else { 9738 latRef[0] = 'N'; 9739 } 9740 latRef[1] = '\0'; 9741 return NO_ERROR; 9742 }else{ 9743 return BAD_VALUE; 9744 } 9745 } 9746 9747 /*=========================================================================== 9748 * FUNCTION : getExifLongitude 9749 * 9750 * DESCRIPTION: get exif longitude 9751 * 9752 * PARAMETERS : 9753 * @longitude : ptr to rational struct to store longitude info 9754 * @lonRef : charater to indicate longitude reference 9755 * 9756 * RETURN : int32_t type of status 9757 * NO_ERROR -- success 9758 * none-zero failure code 9759 *==========================================================================*/ 9760 int32_t QCameraParameters::getExifLongitude(rat_t *longitude, 9761 char *lonRef) 9762 { 9763 const char *str = get(KEY_GPS_LONGITUDE); 9764 if(str != NULL) { 9765 parseGPSCoordinate(str, longitude); 9766 9767 //set Longitude Ref 9768 float longitudeValue = getFloat(KEY_GPS_LONGITUDE); 9769 if(longitudeValue < 0.0f) { 9770 lonRef[0] = 'W'; 9771 } else { 9772 lonRef[0] = 'E'; 9773 } 9774 lonRef[1] = '\0'; 9775 return NO_ERROR; 9776 }else{ 9777 return BAD_VALUE; 9778 } 9779 } 9780 9781 /*=========================================================================== 9782 * FUNCTION : getExifAltitude 9783 * 9784 * DESCRIPTION: get exif altitude 9785 * 9786 * PARAMETERS : 9787 * @altitude : ptr to rational struct to store altitude info 9788 * @altRef : charater to indicate altitude reference 9789 * 9790 * RETURN : int32_t type of status 9791 * NO_ERROR -- success 9792 * none-zero failure code 9793 *==========================================================================*/ 9794 int32_t QCameraParameters::getExifAltitude(rat_t *altitude, 9795 char *altRef) 9796 { 9797 const char *str = get(KEY_GPS_ALTITUDE); 9798 if(str != NULL) { 9799 double value = atof(str); 9800 *altRef = 0; 9801 if(value < 0){ 9802 *altRef = 1; 9803 value = -value; 9804 } 9805 return getRational(altitude, (int)(value*1000), 1000); 9806 }else{ 9807 return BAD_VALUE; 9808 } 9809 } 9810 9811 /*=========================================================================== 9812 * FUNCTION : getExifGpsDateTimeStamp 9813 * 9814 * DESCRIPTION: get exif GPS date time stamp 9815 * 9816 * PARAMETERS : 9817 * @gpsDateStamp : GPS date time stamp string 9818 * @bufLen : length of the string 9819 * @gpsTimeStamp : ptr to rational struct to store time stamp info 9820 * 9821 * RETURN : int32_t type of status 9822 * NO_ERROR -- success 9823 * none-zero failure code 9824 *==========================================================================*/ 9825 int32_t QCameraParameters::getExifGpsDateTimeStamp(char *gpsDateStamp, 9826 uint32_t bufLen, 9827 rat_t *gpsTimeStamp) 9828 { 9829 const char *str = get(KEY_GPS_TIMESTAMP); 9830 if(str != NULL) { 9831 time_t unixTime = (time_t)atol(str); 9832 struct tm *UTCTimestamp = gmtime(&unixTime); 9833 9834 if(!UTCTimestamp) { 9835 ALOGE("%s: UTCTimestamp is null\n", __func__); 9836 return BAD_VALUE; 9837 } 9838 9839 strftime(gpsDateStamp, bufLen, "%Y:%m:%d", UTCTimestamp); 9840 9841 getRational(&gpsTimeStamp[0], UTCTimestamp->tm_hour, 1); 9842 getRational(&gpsTimeStamp[1], UTCTimestamp->tm_min, 1); 9843 getRational(&gpsTimeStamp[2], UTCTimestamp->tm_sec, 1); 9844 9845 return NO_ERROR; 9846 } else { 9847 return BAD_VALUE; 9848 } 9849 } 9850 9851 /*=========================================================================== 9852 * FUNCTION : updateFocusDistances 9853 * 9854 * DESCRIPTION: update focus distances 9855 * 9856 * PARAMETERS : 9857 * @focusDistances : ptr to focus distance info 9858 * 9859 * RETURN : int32_t type of status 9860 * NO_ERROR -- success 9861 * none-zero failure code 9862 *==========================================================================*/ 9863 int32_t QCameraParameters::updateFocusDistances(cam_focus_distances_info_t *focusDistances) 9864 { 9865 String8 str; 9866 char buffer[32] = {0}; 9867 //set all distances to infinity if focus mode is infinity 9868 if(mFocusMode == CAM_FOCUS_MODE_INFINITY) { 9869 str.append("Infinity,Infinity,Infinity"); 9870 } else { 9871 snprintf(buffer, sizeof(buffer), "%f", focusDistances->focus_distance[0]); 9872 str.append(buffer); 9873 snprintf(buffer, sizeof(buffer), ",%f", focusDistances->focus_distance[1]); 9874 str.append(buffer); 9875 snprintf(buffer, sizeof(buffer), ",%f", focusDistances->focus_distance[2]); 9876 str.append(buffer); 9877 } 9878 CDBG_HIGH("%s: setting KEY_FOCUS_DISTANCES as %s", __FUNCTION__, str.string()); 9879 set(QCameraParameters::KEY_FOCUS_DISTANCES, str.string()); 9880 return NO_ERROR; 9881 } 9882 9883 /*=========================================================================== 9884 * FUNCTION : updateRecordingHintValue 9885 * 9886 * DESCRIPTION: update recording hint locally and to daemon 9887 * 9888 * PARAMETERS : 9889 * @value : video hint value 9890 * 9891 * RETURN : int32_t type of status 9892 * NO_ERROR -- success 9893 * none-zero failure code 9894 *==========================================================================*/ 9895 int32_t QCameraParameters::updateRecordingHintValue(int32_t value) 9896 { 9897 int32_t rc = NO_ERROR; 9898 if(initBatchUpdate(m_pParamBuf) < 0 ) { 9899 ALOGE("%s:Failed to initialize group update table", __func__); 9900 return BAD_TYPE; 9901 } 9902 9903 rc = setRecordingHintValue(value); 9904 if (rc != NO_ERROR) { 9905 ALOGE("%s:Failed to update table", __func__); 9906 return rc; 9907 } 9908 9909 if(m_bDISEnabled && (value==1)) { 9910 CDBG_HIGH("%s: %d: Setting DIS value again!!", __func__, __LINE__); 9911 setDISValue(VALUE_ENABLE); 9912 } 9913 9914 rc = commitSetBatch(); 9915 if (rc != NO_ERROR) { 9916 ALOGE("%s:Failed to update recording hint", __func__); 9917 return rc; 9918 } 9919 9920 return rc; 9921 } 9922 9923 /*=========================================================================== 9924 * FUNCTION : setHistogram 9925 * 9926 * DESCRIPTION: set histogram 9927 * 9928 * PARAMETERS : 9929 * @enabled : if histogram is enabled 9930 * 9931 * RETURN : int32_t type of status 9932 * NO_ERROR -- success 9933 * none-zero failure code 9934 *==========================================================================*/ 9935 int32_t QCameraParameters::setHistogram(bool enabled) 9936 { 9937 if(m_bHistogramEnabled == enabled) { 9938 CDBG_HIGH("%s: histogram flag not changed, no ops here", __func__); 9939 return NO_ERROR; 9940 } 9941 9942 // set parm for histogram 9943 if(initBatchUpdate(m_pParamBuf) < 0 ) { 9944 ALOGE("%s:Failed to initialize group update table", __func__); 9945 return BAD_TYPE; 9946 } 9947 9948 int32_t value = enabled ? 1 : 0; 9949 int32_t rc = NO_ERROR; 9950 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_HISTOGRAM, value)) { 9951 ALOGE("%s:Failed to update table", __func__); 9952 return BAD_VALUE; 9953 } 9954 9955 rc = commitSetBatch(); 9956 if (rc != NO_ERROR) { 9957 ALOGE("%s:Failed to set histogram", __func__); 9958 return rc; 9959 } 9960 9961 m_bHistogramEnabled = enabled; 9962 9963 CDBG_HIGH(" Histogram -> %s", m_bHistogramEnabled ? "Enabled" : "Disabled"); 9964 9965 return rc; 9966 } 9967 9968 /*=========================================================================== 9969 * FUNCTION : setIntEvent 9970 * 9971 * DESCRIPTION: set setIntEvent 9972 * 9973 * PARAMETERS : 9974 * @params : image size and dimensions 9975 * 9976 * RETURN : int32_t type of status 9977 * NO_ERROR -- success 9978 * none-zero failure code 9979 *==========================================================================*/ 9980 int32_t QCameraParameters::setIntEvent(cam_int_evt_params_t params) 9981 { 9982 int32_t rc = NO_ERROR; 9983 9984 if ( m_pParamBuf == NULL ) { 9985 return NO_INIT; 9986 } 9987 9988 if(initBatchUpdate(m_pParamBuf) < 0 ) { 9989 ALOGE("%s:Failed to initialize group update table", __func__); 9990 return BAD_TYPE; 9991 } 9992 9993 //Sending snapshot taken notification back to Eztune" 9994 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_INT_EVT, params)) { 9995 ALOGE("%s:Failed to update table", __func__); 9996 return BAD_VALUE; 9997 } 9998 9999 rc = commitSetBatch(); 10000 if (rc != NO_ERROR) { 10001 ALOGE("%s:Failed to set frameskip info parm", __func__); 10002 return rc; 10003 } 10004 10005 return rc; 10006 } 10007 10008 /*=========================================================================== 10009 * FUNCTION : setFaceDetectionOption 10010 * 10011 * DESCRIPTION: set if face detection is enabled by SendCommand 10012 * 10013 * PARAMETERS : 10014 * @enabled : bool flag if face detection should be enabled 10015 * 10016 * RETURN : int32_t type of status 10017 * NO_ERROR -- success 10018 * none-zero failure code 10019 *==========================================================================*/ 10020 int32_t QCameraParameters::setFaceDetectionOption(bool enabled) 10021 { 10022 m_bFaceDetectionOn = enabled; 10023 return NO_ERROR; 10024 } 10025 10026 /*=========================================================================== 10027 * FUNCTION : setFaceDetection 10028 * 10029 * DESCRIPTION: set face detection 10030 * 10031 * PARAMETERS : 10032 * @enabled : if face detection is enabled 10033 * @initCommit : if configuration list need to be initialized and commited 10034 * 10035 * RETURN : int32_t type of status 10036 * NO_ERROR -- success 10037 * none-zero failure code 10038 *==========================================================================*/ 10039 int32_t QCameraParameters::setFaceDetection(bool enabled, bool initCommit) 10040 { 10041 uint32_t faceProcMask = m_nFaceProcMask; 10042 // set face detection mask 10043 if (enabled) { 10044 faceProcMask |= CAM_FACE_PROCESS_MASK_DETECTION; 10045 } else { 10046 faceProcMask &= ~CAM_FACE_PROCESS_MASK_DETECTION; 10047 } 10048 10049 if(m_nFaceProcMask == faceProcMask) { 10050 CDBG_HIGH("%s: face process mask not changed, no ops here", __func__); 10051 return NO_ERROR; 10052 } 10053 10054 m_nFaceProcMask = faceProcMask; 10055 10056 // set parm for face detection 10057 uint32_t requested_faces = (uint32_t)getInt(KEY_QC_MAX_NUM_REQUESTED_FACES); 10058 cam_fd_set_parm_t fd_set_parm; 10059 memset(&fd_set_parm, 0, sizeof(cam_fd_set_parm_t)); 10060 fd_set_parm.fd_mode = faceProcMask; 10061 fd_set_parm.num_fd = requested_faces; 10062 10063 CDBG_HIGH("[KPI Perf] %s: PROFILE_FACE_DETECTION_VALUE = %d num_fd = %d", 10064 __func__, faceProcMask,requested_faces); 10065 10066 if (initCommit) { 10067 if(initBatchUpdate(m_pParamBuf) < 0 ) { 10068 ALOGE("%s:Failed to initialize group update table", __func__); 10069 return BAD_TYPE; 10070 } 10071 } 10072 10073 int32_t rc = NO_ERROR; 10074 10075 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_FD, fd_set_parm)) { 10076 ALOGE("%s:Failed to update table", __func__); 10077 return BAD_VALUE; 10078 } 10079 10080 if (initCommit) { 10081 rc = commitSetBatch(); 10082 if (rc != NO_ERROR) { 10083 ALOGE("%s:Failed to set face detection parm", __func__); 10084 return rc; 10085 } 10086 } 10087 10088 CDBG_HIGH("%s: FaceProcMask -> %d", __func__, m_nFaceProcMask); 10089 10090 return rc; 10091 } 10092 10093 /*=========================================================================== 10094 * FUNCTION : setFrameSkip 10095 * 10096 * DESCRIPTION: send ISP frame skip pattern to camera daemon 10097 * 10098 * PARAMETERS : 10099 * @pattern : skip pattern for ISP 10100 * 10101 * RETURN : int32_t type of status 10102 * NO_ERROR -- success 10103 * none-zero failure code 10104 *==========================================================================*/ 10105 int32_t QCameraParameters::setFrameSkip(enum msm_vfe_frame_skip_pattern pattern) 10106 { 10107 int32_t rc = NO_ERROR; 10108 10109 if ( m_pParamBuf == NULL ) { 10110 return NO_INIT; 10111 } 10112 10113 if(initBatchUpdate(m_pParamBuf) < 0 ) { 10114 ALOGE("%s:Failed to initialize group update table", __func__); 10115 return BAD_TYPE; 10116 } 10117 10118 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_FRAMESKIP, (int32_t)pattern)) { 10119 ALOGE("%s:Failed to update table", __func__); 10120 return BAD_VALUE; 10121 } 10122 10123 rc = commitSetBatch(); 10124 if (rc != NO_ERROR) { 10125 ALOGE("%s:Failed to set frameskip info parm", __func__); 10126 return rc; 10127 } 10128 10129 return rc; 10130 } 10131 10132 int32_t QCameraParameters::updateRAW(cam_dimension_t max_dim) 10133 { 10134 int32_t rc = NO_ERROR; 10135 cam_dimension_t raw_dim; 10136 10137 if (max_dim.width == 0 || max_dim.height == 0) { 10138 max_dim = m_pCapability->raw_dim[0]; 10139 } 10140 10141 if(initBatchUpdate(m_pParamBuf) < 0 ) { 10142 ALOGE("%s:Failed to initialize group update table", __func__); 10143 return BAD_TYPE; 10144 } 10145 10146 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_MAX_DIMENSION, max_dim)) { 10147 ALOGE("%s:Failed to update table for CAM_INTF_PARM_MAX_DIMENSION ", __func__); 10148 return BAD_VALUE; 10149 } 10150 10151 rc = commitSetBatch(); 10152 if (rc != NO_ERROR) { 10153 ALOGE("%s:Failed to set lock CAM_INTF_PARM_MAX_DIMENSION parm", __func__); 10154 return rc; 10155 } 10156 10157 if(initBatchUpdate(m_pParamBuf) < 0 ) { 10158 ALOGE("%s:Failed to initialize group update table", __func__); 10159 return BAD_TYPE; 10160 } 10161 10162 ADD_GET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_RAW_DIMENSION); 10163 10164 rc = commitGetBatch(); 10165 if (rc != NO_ERROR) { 10166 ALOGE("%s:Failed to get commit CAM_INTF_PARM_RAW_DIMENSION", __func__); 10167 return rc; 10168 } 10169 10170 READ_PARAM_ENTRY(m_pParamBuf, CAM_INTF_PARM_RAW_DIMENSION, raw_dim); 10171 10172 CDBG_HIGH("%s : RAW Dimension = %d X %d",__func__,raw_dim.width,raw_dim.height); 10173 if (raw_dim.width == 0 || raw_dim.height == 0) { 10174 ALOGE("%s: Error getting RAW size. Setting to Capability value",__func__); 10175 raw_dim = m_pCapability->raw_dim[0]; 10176 } 10177 setRawSize(raw_dim); 10178 return rc; 10179 } 10180 10181 /*=========================================================================== 10182 * FUNCTION : setHDRSceneEnable 10183 * 10184 * DESCRIPTION: sets hdr scene deteced flag 10185 * 10186 * PARAMETERS : 10187 * @bflag : hdr scene deteced 10188 * 10189 * RETURN : nothing 10190 *==========================================================================*/ 10191 void QCameraParameters::setHDRSceneEnable(bool bflag) 10192 { 10193 bool bupdate = false; 10194 if (m_HDRSceneEnabled != bflag) { 10195 bupdate = true; 10196 } 10197 m_HDRSceneEnabled = bflag; 10198 10199 if (bupdate) { 10200 updateFlash(true); 10201 } 10202 } 10203 10204 /*=========================================================================== 10205 * FUNCTION : getASDStateString 10206 * 10207 * DESCRIPTION: get ASD result in string format 10208 * 10209 * PARAMETERS : 10210 * @scene : selected scene mode 10211 * 10212 * RETURN : int32_t type of status 10213 * NO_ERROR -- success 10214 * none-zero failure code 10215 *==========================================================================*/ 10216 const char *QCameraParameters::getASDStateString(cam_auto_scene_t scene) 10217 { 10218 switch (scene) { 10219 case S_NORMAL : 10220 return "Normal"; 10221 case S_SCENERY: 10222 return "Scenery"; 10223 case S_PORTRAIT: 10224 return "Portrait"; 10225 case S_PORTRAIT_BACKLIGHT: 10226 return "Portrait-Backlight"; 10227 case S_SCENERY_BACKLIGHT: 10228 return "Scenery-Backlight"; 10229 case S_BACKLIGHT: 10230 return "Backlight"; 10231 default: 10232 return "<Unknown!>"; 10233 } 10234 } 10235 10236 /*=========================================================================== 10237 * FUNCTION : parseNDimVector 10238 * 10239 * DESCRIPTION: helper function to parse a string like "(1, 2, 3, 4, ..., N)" 10240 * into N-dimension vector 10241 * 10242 * PARAMETERS : 10243 * @str : string to be parsed 10244 * @num : output array of size N to store vector element values 10245 * @N : number of dimension 10246 * @delim : delimeter to seperete string 10247 * 10248 * RETURN : int32_t type of status 10249 * NO_ERROR -- success 10250 * none-zero failure code 10251 *==========================================================================*/ 10252 int32_t QCameraParameters::parseNDimVector(const char *str, int *num, int N, char delim = ',') 10253 { 10254 char *start, *end; 10255 if (num == NULL) { 10256 ALOGE("%s: Invalid output array (num == NULL)", __func__); 10257 return BAD_VALUE; 10258 } 10259 10260 //check if string starts and ends with parantheses 10261 if(str[0] != '(' || str[strlen(str)-1] != ')') { 10262 ALOGE("%s: Invalid format of string %s, valid format is (n1, n2, n3, n4 ...)", 10263 __func__, str); 10264 return BAD_VALUE; 10265 } 10266 start = (char*) str; 10267 start++; 10268 for(int i=0; i<N; i++) { 10269 *(num+i) = (int) strtol(start, &end, 10); 10270 if(*end != delim && i < N-1) { 10271 ALOGE("%s: Cannot find delimeter '%c' in string \"%s\". end = %c", 10272 __func__, delim, str, *end); 10273 return -1; 10274 } 10275 start = end+1; 10276 } 10277 return NO_ERROR; 10278 } 10279 10280 /*=========================================================================== 10281 * FUNCTION : parseCameraAreaString 10282 * 10283 * DESCRIPTION: helper function to parse a string of camera areas like 10284 * "(1, 2, 3, 4, 5),(1, 2, 3, 4, 5),..." 10285 * 10286 * PARAMETERS : 10287 * @str : string to be parsed 10288 * @max_num_areas : max number of areas 10289 * @pAreas : ptr to struct to store areas 10290 * @num_areas_found : number of areas found 10291 * 10292 * RETURN : int32_t type of status 10293 * NO_ERROR -- success 10294 * none-zero failure code 10295 *==========================================================================*/ 10296 int32_t QCameraParameters::parseCameraAreaString(const char *str, 10297 int max_num_areas, 10298 cam_area_t *pAreas, 10299 int& num_areas_found) 10300 { 10301 char area_str[32]; 10302 const char *start, *end, *p; 10303 start = str; end = NULL; 10304 int values[5], index=0; 10305 num_areas_found = 0; 10306 10307 memset(values, 0, sizeof(values)); 10308 while(start != NULL) { 10309 if(*start != '(') { 10310 ALOGE("%s: error: Ill formatted area string: %s", __func__, str); 10311 return BAD_VALUE; 10312 } 10313 end = strchr(start, ')'); 10314 if(end == NULL) { 10315 ALOGE("%s: error: Ill formatted area string: %s", __func__, str); 10316 return BAD_VALUE; 10317 } 10318 int i; 10319 for (i=0,p=start; p<=end; p++, i++) { 10320 area_str[i] = *p; 10321 } 10322 area_str[i] = '\0'; 10323 if(parseNDimVector(area_str, values, 5) < 0){ 10324 ALOGE("%s: error: Failed to parse the area string: %s", __func__, area_str); 10325 return BAD_VALUE; 10326 } 10327 // no more areas than max_num_areas are accepted. 10328 if(index >= max_num_areas) { 10329 ALOGE("%s: error: too many areas specified %s", __func__, str); 10330 return BAD_VALUE; 10331 } 10332 pAreas[index].rect.left = values[0]; 10333 pAreas[index].rect.top = values[1]; 10334 pAreas[index].rect.width = values[2] - values[0]; 10335 pAreas[index].rect.height = values[3] - values[1]; 10336 pAreas[index].weight = values[4]; 10337 10338 index++; 10339 start = strchr(end, '('); // serach for next '(' 10340 } 10341 num_areas_found = index; 10342 return 0; 10343 } 10344 10345 /*=========================================================================== 10346 * FUNCTION : validateCameraAreas 10347 * 10348 * DESCRIPTION: helper function to validate camera areas within (-1000, 1000) 10349 * 10350 * PARAMETERS : 10351 * @areas : ptr to array of areas 10352 * @num_areas : number of areas 10353 * 10354 * RETURN : true -- area is in valid range 10355 * false -- not valid 10356 *==========================================================================*/ 10357 bool QCameraParameters::validateCameraAreas(cam_area_t *areas, int num_areas) 10358 { 10359 // special case: default area 10360 if (num_areas == 1 && 10361 areas[0].rect.left == 0 && 10362 areas[0].rect.top == 0 && 10363 areas[0].rect.width == 0 && 10364 areas[0].rect.height == 0 && 10365 areas[0].weight == 0) { 10366 return true; 10367 } 10368 10369 for(int i = 0; i < num_areas; i++) { 10370 // left should be >= -1000 10371 if(areas[i].rect.left < -1000) { 10372 return false; 10373 } 10374 10375 // top should be >= -1000 10376 if(areas[i].rect.top < -1000) { 10377 return false; 10378 } 10379 10380 // width or height should be > 0 10381 if (areas[i].rect.width <= 0 || areas[i].rect.height <= 0) { 10382 return false; 10383 } 10384 10385 // right should be <= 1000 10386 if(areas[i].rect.left + areas[i].rect.width > 1000) { 10387 return false; 10388 } 10389 10390 // bottom should be <= 1000 10391 if(areas[i].rect.top + areas[i].rect.height > 1000) { 10392 return false; 10393 } 10394 10395 // weight should be within (1, 1000) 10396 if (areas[i].weight < 1 || areas[i].weight > 1000) { 10397 return false; 10398 } 10399 } 10400 return true; 10401 } 10402 10403 /*=========================================================================== 10404 * FUNCTION : isYUVFrameInfoNeeded 10405 * 10406 * DESCRIPTION: In AE-Bracket mode, we need set yuv buffer information for up-layer 10407 * 10408 * PARAMETERS : none 10409 * 10410 * RETURN : true: needed 10411 * false: no need 10412 *==========================================================================*/ 10413 bool QCameraParameters::isYUVFrameInfoNeeded() 10414 { 10415 //In AE-Bracket mode, we need set raw buffer information for up-layer 10416 if(!isNV21PictureFormat() && !isNV16PictureFormat()){ 10417 return false; 10418 } 10419 const char *aecBracketStr = get(KEY_QC_AE_BRACKET_HDR); 10420 10421 int value = lookupAttr(BRACKETING_MODES_MAP, PARAM_MAP_SIZE(BRACKETING_MODES_MAP), 10422 aecBracketStr); 10423 CDBG_HIGH("%s: aecBracketStr=%s, value=%d.", __func__, aecBracketStr, value); 10424 return (value == CAM_EXP_BRACKETING_ON); 10425 } 10426 10427 /*=========================================================================== 10428 * FUNCTION : getFrameFmtString 10429 * 10430 * DESCRIPTION: get string name of frame format 10431 * 10432 * PARAMETERS : 10433 * @frame : frame format 10434 * 10435 * RETURN : string name of frame format 10436 *==========================================================================*/ 10437 const char *QCameraParameters::getFrameFmtString(cam_format_t fmt) 10438 { 10439 return lookupNameByValue(PICTURE_TYPES_MAP, PARAM_MAP_SIZE(PICTURE_TYPES_MAP), fmt); 10440 } 10441 10442 /*=========================================================================== 10443 * FUNCTION : initBatchUpdate 10444 * 10445 * DESCRIPTION: init camera parameters buf entries 10446 * 10447 * PARAMETERS : 10448 * @p_table : ptr to parameter buffer 10449 * 10450 * RETURN : int32_t type of status 10451 * NO_ERROR -- success 10452 * none-zero failure code 10453 *==========================================================================*/ 10454 int32_t QCameraParameters::initBatchUpdate(parm_buffer_t *p_table) 10455 { 10456 m_tempMap.clear(); 10457 10458 clear_metadata_buffer(p_table); 10459 return NO_ERROR; 10460 } 10461 10462 /*=========================================================================== 10463 * FUNCTION : commitSetBatch 10464 * 10465 * DESCRIPTION: commit all set parameters in the batch work to backend 10466 * 10467 * PARAMETERS : none 10468 * 10469 * RETURN : int32_t type of status 10470 * NO_ERROR -- success 10471 * none-zero failure code 10472 *==========================================================================*/ 10473 int32_t QCameraParameters::commitSetBatch() 10474 { 10475 int32_t rc = NO_ERROR; 10476 int32_t i = 0; 10477 10478 if (NULL == m_pParamBuf) { 10479 ALOGE("%s: Params not initialized", __func__); 10480 return NO_INIT; 10481 } 10482 10483 /* Loop to check if atleast one entry is valid */ 10484 for(i = 0; i < CAM_INTF_PARM_MAX; i++){ 10485 if(m_pParamBuf->is_valid[i]) 10486 break; 10487 } 10488 10489 if (NULL == m_pCamOpsTbl) { 10490 ALOGE("%s: Ops not initialized", __func__); 10491 return NO_INIT; 10492 } 10493 10494 if (i < CAM_INTF_PARM_MAX) { 10495 rc = m_pCamOpsTbl->ops->set_parms(m_pCamOpsTbl->camera_handle, m_pParamBuf); 10496 } 10497 if (rc == NO_ERROR) { 10498 // commit change from temp storage into param map 10499 rc = commitParamChanges(); 10500 } 10501 return rc; 10502 } 10503 10504 /*=========================================================================== 10505 * FUNCTION : commitGetBatch 10506 * 10507 * DESCRIPTION: commit all get parameters in the batch work to backend 10508 * 10509 * PARAMETERS : none 10510 * 10511 * RETURN : int32_t type of status 10512 * NO_ERROR -- success 10513 * none-zero failure code 10514 *==========================================================================*/ 10515 int32_t QCameraParameters::commitGetBatch() 10516 { 10517 int32_t rc = NO_ERROR; 10518 int32_t i = 0; 10519 10520 if (NULL == m_pParamBuf) { 10521 ALOGE("%s: Params not initialized", __func__); 10522 return NO_INIT; 10523 } 10524 10525 /* Loop to check if atleast one entry is valid */ 10526 for(i = 0; i < CAM_INTF_PARM_MAX; i++){ 10527 if(m_pParamBuf->is_valid[i]) 10528 break; 10529 } 10530 10531 if (NULL == m_pCamOpsTbl) { 10532 ALOGE("%s: Ops not initialized", __func__); 10533 return NO_INIT; 10534 } 10535 10536 if (i < CAM_INTF_PARM_MAX) { 10537 return m_pCamOpsTbl->ops->get_parms(m_pCamOpsTbl->camera_handle, m_pParamBuf); 10538 } else { 10539 return NO_ERROR; 10540 } 10541 return rc; 10542 } 10543 10544 /*=========================================================================== 10545 * FUNCTION : updateParamEntry 10546 * 10547 * DESCRIPTION: update a parameter entry in the local temp map obj 10548 * 10549 * PARAMETERS : 10550 * @key : key of the entry 10551 * @value : value of the entry 10552 * 10553 * RETURN : int32_t type of status 10554 * NO_ERROR -- success 10555 * none-zero failure code 10556 *==========================================================================*/ 10557 int32_t QCameraParameters::updateParamEntry(const char *key, const char *value) 10558 { 10559 m_tempMap.replaceValueFor(String8(key), String8(value)); 10560 return NO_ERROR; 10561 } 10562 10563 /*=========================================================================== 10564 * FUNCTION : commitParamChanges 10565 * 10566 * DESCRIPTION: commit all changes in local temp map obj into parameter obj 10567 * 10568 * PARAMETERS : none 10569 * 10570 * RETURN : int32_t type of status 10571 * NO_ERROR -- success 10572 * none-zero failure code 10573 *==========================================================================*/ 10574 int32_t QCameraParameters::commitParamChanges() 10575 { 10576 size_t size = m_tempMap.size(); 10577 for (size_t i = 0; i < size; i++) { 10578 String8 k, v; 10579 k = m_tempMap.keyAt(i); 10580 v = m_tempMap.valueAt(i); 10581 set(k, v); 10582 } 10583 m_tempMap.clear(); 10584 10585 // update local changes 10586 m_bRecordingHint = m_bRecordingHint_new; 10587 m_bZslMode = m_bZslMode_new; 10588 10589 /* After applying scene mode auto, 10590 Camera effects need to be reapplied */ 10591 if ( m_bSceneTransitionAuto ) { 10592 m_bUpdateEffects = true; 10593 m_bSceneTransitionAuto = false; 10594 } 10595 10596 10597 return NO_ERROR; 10598 } 10599 10600 /*=========================================================================== 10601 * FUNCTION : QCameraReprocScaleParam 10602 * 10603 * DESCRIPTION: constructor of QCameraReprocScaleParam 10604 * 10605 * PARAMETERS : none 10606 * 10607 * RETURN : none 10608 *==========================================================================*/ 10609 QCameraReprocScaleParam::QCameraReprocScaleParam(QCameraParameters *parent) 10610 : mParent(parent), 10611 mScaleEnabled(false), 10612 mIsUnderScaling(false), 10613 mScaleDirection(0), 10614 mNeedScaleCnt(0), 10615 mSensorSizeTblCnt(0), 10616 mSensorSizeTbl(NULL), 10617 mTotalSizeTblCnt(0) 10618 { 10619 mPicSizeFromAPK.width = 0; 10620 mPicSizeFromAPK.height = 0; 10621 mPicSizeSetted.width = 0; 10622 mPicSizeSetted.height = 0; 10623 memset(mNeedScaledSizeTbl, 0, sizeof(mNeedScaledSizeTbl)); 10624 memset(mTotalSizeTbl, 0, sizeof(mTotalSizeTbl)); 10625 } 10626 10627 /*=========================================================================== 10628 * FUNCTION : ~~QCameraReprocScaleParam 10629 * 10630 * DESCRIPTION: destructor of QCameraReprocScaleParam 10631 * 10632 * PARAMETERS : none 10633 * 10634 * RETURN : none 10635 *==========================================================================*/ 10636 QCameraReprocScaleParam::~QCameraReprocScaleParam() 10637 { 10638 //do nothing now. 10639 } 10640 10641 /*=========================================================================== 10642 * FUNCTION : setScaledSizeTbl 10643 * 10644 * DESCRIPTION: re-set picture size table with dimensions that need scaling if Reproc Scale is enabled 10645 * 10646 * PARAMETERS : 10647 * @scale_cnt : count of picture sizes that want scale 10648 * @scale_tbl : picture size table that want scale 10649 * @org_cnt : sensor supported picture size count 10650 * @org_tbl : sensor supported picture size table 10651 * 10652 * RETURN : int32_t type of status 10653 * NO_ERROR -- success 10654 * none-zero failure code 10655 *==========================================================================*/ 10656 int32_t QCameraReprocScaleParam::setScaleSizeTbl(size_t scale_cnt, 10657 cam_dimension_t *scale_tbl, size_t org_cnt, cam_dimension_t *org_tbl) 10658 { 10659 int32_t rc = NO_ERROR; 10660 size_t i; 10661 mNeedScaleCnt = 0; 10662 10663 if(!mScaleEnabled || scale_cnt <=0 || scale_tbl == NULL || org_cnt <=0 || org_tbl == NULL){ 10664 return BAD_VALUE; // Do not need scale, so also need not reset picture size table 10665 } 10666 10667 mSensorSizeTblCnt = org_cnt; 10668 mSensorSizeTbl = org_tbl; 10669 mNeedScaleCnt = checkScaleSizeTable(scale_cnt, scale_tbl, org_cnt, org_tbl); 10670 if(mNeedScaleCnt <= 0){ 10671 ALOGE("%s: do not have picture sizes need scaling.", __func__); 10672 return BAD_VALUE; 10673 } 10674 10675 if(mNeedScaleCnt + org_cnt > MAX_SIZES_CNT){ 10676 ALOGE("%s: picture size list exceed the max count.", __func__); 10677 return BAD_VALUE; 10678 } 10679 10680 //get the total picture size table 10681 mTotalSizeTblCnt = mNeedScaleCnt + org_cnt; 10682 10683 if (mNeedScaleCnt > MAX_SCALE_SIZES_CNT) { 10684 ALOGE("%s: Error!! mNeedScaleCnt (%d) is more than MAX_SCALE_SIZES_CNT", 10685 __func__, mNeedScaleCnt); 10686 return BAD_VALUE; 10687 } 10688 10689 for(i = 0; i < mNeedScaleCnt; i++){ 10690 mTotalSizeTbl[i].width = mNeedScaledSizeTbl[i].width; 10691 mTotalSizeTbl[i].height = mNeedScaledSizeTbl[i].height; 10692 CDBG_HIGH("%s: scale picture size: i =%d, width=%d, height=%d.", __func__, 10693 i, mTotalSizeTbl[i].width, mTotalSizeTbl[i].height); 10694 } 10695 for(; i < mTotalSizeTblCnt; i++){ 10696 mTotalSizeTbl[i].width = org_tbl[i-mNeedScaleCnt].width; 10697 mTotalSizeTbl[i].height = org_tbl[i-mNeedScaleCnt].height; 10698 CDBG_HIGH("%s: sensor supportted picture size: i =%d, width=%d, height=%d.", __func__, 10699 i, mTotalSizeTbl[i].width, mTotalSizeTbl[i].height); 10700 } 10701 return rc; 10702 } 10703 10704 /*=========================================================================== 10705 * FUNCTION : getScaledSizeTblCnt 10706 * 10707 * DESCRIPTION: get picture size cnt that need scale 10708 * 10709 * PARAMETERS : none 10710 * 10711 * RETURN : uint8_t type of picture size count 10712 *==========================================================================*/ 10713 size_t QCameraReprocScaleParam::getScaleSizeTblCnt() 10714 { 10715 return mNeedScaleCnt; 10716 } 10717 10718 /*=========================================================================== 10719 * FUNCTION : getScaledSizeTbl 10720 * 10721 * DESCRIPTION: get picture size table that need scale 10722 * 10723 * PARAMETERS : none 10724 * 10725 * RETURN : cam_dimension_t list of picture size table 10726 *==========================================================================*/ 10727 cam_dimension_t *QCameraReprocScaleParam::getScaledSizeTbl() 10728 { 10729 if(!mScaleEnabled) 10730 return NULL; 10731 10732 return mNeedScaledSizeTbl; 10733 } 10734 10735 /*=========================================================================== 10736 * FUNCTION : setScaleEnable 10737 * 10738 * DESCRIPTION: enable or disable Reproc Scale 10739 * 10740 * PARAMETERS : 10741 * @enabled : enable: 1; disable 0 10742 * 10743 * RETURN : none 10744 *==========================================================================*/ 10745 void QCameraReprocScaleParam::setScaleEnable(bool enabled) 10746 { 10747 mScaleEnabled = enabled; 10748 } 10749 10750 /*=========================================================================== 10751 * FUNCTION : isScaleEnabled 10752 * 10753 * DESCRIPTION: check if Reproc Scale is enabled 10754 * 10755 * PARAMETERS : none 10756 * 10757 * RETURN : bool type of status 10758 *==========================================================================*/ 10759 bool QCameraReprocScaleParam::isScaleEnabled() 10760 { 10761 return mScaleEnabled; 10762 } 10763 10764 /*=========================================================================== 10765 * FUNCTION : isScalePicSize 10766 * 10767 * DESCRIPTION: check if current picture size is from Scale Table 10768 * 10769 * PARAMETERS : 10770 * @width : current picture width 10771 * @height : current picture height 10772 * 10773 * RETURN : bool type of status 10774 *==========================================================================*/ 10775 bool QCameraReprocScaleParam::isScalePicSize(int width, int height) 10776 { 10777 //Check if the picture size is in scale table 10778 if(mNeedScaleCnt <= 0) 10779 return FALSE; 10780 10781 for (size_t i = 0; i < mNeedScaleCnt; i++) { 10782 if ((mNeedScaledSizeTbl[i].width == width) && (mNeedScaledSizeTbl[i].height == height)) { 10783 //found match 10784 return TRUE; 10785 } 10786 } 10787 10788 ALOGE("%s: Not in scale picture size table.", __func__); 10789 return FALSE; 10790 } 10791 10792 /*=========================================================================== 10793 * FUNCTION : isValidatePicSize 10794 * 10795 * DESCRIPTION: check if current picture size is validate 10796 * 10797 * PARAMETERS : 10798 * @width : current picture width 10799 * @height : current picture height 10800 * 10801 * RETURN : bool type of status 10802 *==========================================================================*/ 10803 bool QCameraReprocScaleParam::isValidatePicSize(int width, int height) 10804 { 10805 size_t i = 0; 10806 10807 for(i = 0; i < mSensorSizeTblCnt; i++){ 10808 if(mSensorSizeTbl[i].width == width 10809 && mSensorSizeTbl[i].height== height){ 10810 return TRUE; 10811 } 10812 } 10813 10814 for(i = 0; i < mNeedScaleCnt; i++){ 10815 if(mNeedScaledSizeTbl[i].width == width 10816 && mNeedScaledSizeTbl[i].height== height){ 10817 return TRUE; 10818 } 10819 } 10820 10821 ALOGE("%s: Invalidate input picture size.", __func__); 10822 return FALSE; 10823 } 10824 10825 /*=========================================================================== 10826 * FUNCTION : setSensorSupportedPicSize 10827 * 10828 * DESCRIPTION: set sensor supported picture size. 10829 * For Snapshot stream size configuration, we need use sensor supported size. 10830 * We will use CPP to do Scaling based on output Snapshot stream. 10831 * 10832 * PARAMETERS : none 10833 * 10834 * RETURN : int32_t type of status 10835 * NO_ERROR -- success 10836 * none-zero failure code 10837 *==========================================================================*/ 10838 int32_t QCameraReprocScaleParam::setSensorSupportedPicSize() 10839 { 10840 //will find a suitable picture size (here we leave a prossibility to add other scale requirement) 10841 //Currently we only focus on upscaling, and checkScaleSizeTable() has guaranteed the dimension ratio. 10842 10843 if(!mIsUnderScaling || mSensorSizeTblCnt <= 0) 10844 return BAD_VALUE; 10845 10846 //We just get the max sensor supported size here. 10847 mPicSizeSetted.width = mSensorSizeTbl[0].width; 10848 mPicSizeSetted.height = mSensorSizeTbl[0].height; 10849 10850 return NO_ERROR; 10851 } 10852 10853 10854 /*=========================================================================== 10855 * FUNCTION : setValidatePicSize 10856 * 10857 * DESCRIPTION: set sensor supported size and change scale status. 10858 * 10859 * PARAMETERS : 10860 * @width : input picture width 10861 * @height : input picture height 10862 * 10863 * RETURN : int32_t type of status 10864 * NO_ERROR -- success 10865 * none-zero failure code 10866 *==========================================================================*/ 10867 int32_t QCameraReprocScaleParam::setValidatePicSize(int &width,int &height) 10868 { 10869 if(!mScaleEnabled) 10870 return BAD_VALUE; 10871 10872 mIsUnderScaling = FALSE; //default: not under scale 10873 10874 if(isScalePicSize(width, height)){ 10875 // input picture size need scaling operation. Record size from APK and setted 10876 mIsUnderScaling = TRUE; 10877 mPicSizeFromAPK.width = width; 10878 mPicSizeFromAPK.height = height; 10879 10880 if(setSensorSupportedPicSize() != NO_ERROR) 10881 return BAD_VALUE; 10882 10883 //re-set picture size to sensor supported size 10884 width = mPicSizeSetted.width; 10885 height = mPicSizeSetted.height; 10886 CDBG_HIGH("%s: mPicSizeFromAPK- with=%d, height=%d, mPicSizeSetted- with =%d, height=%d.", 10887 __func__, mPicSizeFromAPK.width, mPicSizeFromAPK.height, mPicSizeSetted.width, mPicSizeSetted.height); 10888 }else{ 10889 mIsUnderScaling = FALSE; 10890 //no scale is needed for input picture size 10891 if(!isValidatePicSize(width, height)){ 10892 ALOGE("%s: invalidate input picture size.", __func__); 10893 return BAD_VALUE; 10894 } 10895 mPicSizeSetted.width = width; 10896 mPicSizeSetted.height = height; 10897 } 10898 10899 CDBG_HIGH("%s: X. mIsUnderScaling=%d, width=%d, height=%d.", __func__, mIsUnderScaling, width, height); 10900 return NO_ERROR; 10901 } 10902 10903 /*=========================================================================== 10904 * FUNCTION : getPicSizeFromAPK 10905 * 10906 * DESCRIPTION: get picture size that get from APK 10907 * 10908 * PARAMETERS : 10909 * @width : input width 10910 * @height : input height 10911 * 10912 * RETURN : int32_t type of status 10913 * NO_ERROR -- success 10914 * none-zero failure code 10915 *==========================================================================*/ 10916 int32_t QCameraReprocScaleParam::getPicSizeFromAPK(int &width, int &height) 10917 { 10918 if(!mIsUnderScaling) 10919 return BAD_VALUE; 10920 10921 width = mPicSizeFromAPK.width; 10922 height = mPicSizeFromAPK.height; 10923 return NO_ERROR; 10924 } 10925 10926 /*=========================================================================== 10927 * FUNCTION : getPicSizeSetted 10928 * 10929 * DESCRIPTION: get picture size that setted into mm-camera 10930 * 10931 * PARAMETERS : 10932 * @width : input width 10933 * @height : input height 10934 * 10935 * RETURN : int32_t type of status 10936 * NO_ERROR -- success 10937 * none-zero failure code 10938 *==========================================================================*/ 10939 int32_t QCameraReprocScaleParam::getPicSizeSetted(int &width, int &height) 10940 { 10941 width = mPicSizeSetted.width; 10942 height = mPicSizeSetted.height; 10943 return NO_ERROR; 10944 } 10945 10946 /*=========================================================================== 10947 * FUNCTION : isUnderScaling 10948 * 10949 * DESCRIPTION: check if we are in Reproc Scaling requirment 10950 * 10951 * PARAMETERS : none 10952 * 10953 * RETURN : bool type of status 10954 *==========================================================================*/ 10955 bool QCameraReprocScaleParam::isUnderScaling() 10956 { 10957 return mIsUnderScaling; 10958 } 10959 10960 /*=========================================================================== 10961 * FUNCTION : checkScaleSizeTable 10962 * 10963 * DESCRIPTION: check PICTURE_SIZE_NEED_SCALE to choose 10964 * 10965 * PARAMETERS : 10966 * @scale_cnt : count of picture sizes that want scale 10967 * @scale_tbl : picture size table that want scale 10968 * @org_cnt : sensor supported picture size count 10969 * @org_tbl : sensor supported picture size table 10970 * 10971 * RETURN : bool type of status 10972 *==========================================================================*/ 10973 size_t QCameraReprocScaleParam::checkScaleSizeTable(size_t scale_cnt, 10974 cam_dimension_t *scale_tbl, size_t org_cnt, cam_dimension_t *org_tbl) 10975 { 10976 size_t stbl_cnt = 0; 10977 size_t temp_cnt = 0; 10978 ssize_t i = 0; 10979 if(scale_cnt <=0 || scale_tbl == NULL || org_tbl == NULL || org_cnt <= 0) 10980 return stbl_cnt; 10981 10982 //get validate scale size table. Currently we only support: 10983 // 1. upscale. The scale size must larger than max sensor supported size 10984 // 2. Scale dimension ratio must be same as the max sensor supported size. 10985 temp_cnt = scale_cnt; 10986 for (i = (ssize_t)(scale_cnt - 1); i >= 0; i--) { 10987 if (scale_tbl[i].width > org_tbl[0].width || 10988 (scale_tbl[i].width == org_tbl[0].width && 10989 scale_tbl[i].height > org_tbl[0].height)) { 10990 //get the smallest scale size 10991 break; 10992 } 10993 temp_cnt--; 10994 } 10995 10996 //check dimension ratio 10997 double supported_ratio = (double)org_tbl[0].width / (double)org_tbl[0].height; 10998 for (i = 0; i < (ssize_t)temp_cnt; i++) { 10999 double cur_ratio = (double)scale_tbl[i].width / (double)scale_tbl[i].height; 11000 if (fabs(supported_ratio - cur_ratio) > ASPECT_TOLERANCE) { 11001 continue; 11002 } 11003 mNeedScaledSizeTbl[stbl_cnt].width = scale_tbl[i].width; 11004 mNeedScaledSizeTbl[stbl_cnt].height= scale_tbl[i].height; 11005 stbl_cnt++; 11006 } 11007 11008 return stbl_cnt; 11009 } 11010 11011 /*=========================================================================== 11012 * FUNCTION : getTotalSizeTblCnt 11013 * 11014 * DESCRIPTION: get total picture size count after adding dimensions that need scaling 11015 * 11016 * PARAMETERS : none 11017 * 11018 * RETURN : uint8_t type of picture size count 11019 *==========================================================================*/ 11020 size_t QCameraReprocScaleParam::getTotalSizeTblCnt() 11021 { 11022 return mTotalSizeTblCnt; 11023 } 11024 11025 /*=========================================================================== 11026 * FUNCTION : getTotalSizeTbl 11027 * 11028 * DESCRIPTION: get picture size table after adding dimensions that need scaling 11029 * 11030 * PARAMETERS : none 11031 * 11032 * RETURN : cam_dimension_t list of picture size table 11033 *==========================================================================*/ 11034 cam_dimension_t *QCameraReprocScaleParam::getTotalSizeTbl() 11035 { 11036 if(!mScaleEnabled) 11037 return NULL; 11038 11039 return mTotalSizeTbl; 11040 } 11041 11042 /*=========================================================================== 11043 * FUNCTION : isHDREnabled 11044 * 11045 * DESCRIPTION: if HDR is enabled 11046 * 11047 * PARAMETERS : none 11048 * 11049 * RETURN : true: needed 11050 * false: no need 11051 *==========================================================================*/ 11052 bool QCameraParameters::isHDREnabled() 11053 { 11054 return ((m_nBurstNum == 1) && (m_bHDREnabled || m_HDRSceneEnabled)); 11055 } 11056 11057 /*=========================================================================== 11058 * FUNCTION : isAVTimerEnabled 11059 * 11060 * DESCRIPTION: if AVTimer is enabled 11061 * 11062 * PARAMETERS : none 11063 * 11064 * RETURN : true: needed 11065 * false: no need 11066 *==========================================================================*/ 11067 bool QCameraParameters::isAVTimerEnabled() 11068 { 11069 return m_bAVTimerEnabled; 11070 } 11071 11072 /*=========================================================================== 11073 * FUNCTION : isDISEnabled 11074 * 11075 * DESCRIPTION: if DIS is enabled 11076 * 11077 * PARAMETERS : none 11078 * 11079 * RETURN : true: needed 11080 * false: no need 11081 *==========================================================================*/ 11082 bool QCameraParameters::isDISEnabled() 11083 { 11084 return m_bDISEnabled; 11085 } 11086 11087 /*=========================================================================== 11088 * FUNCTION : getISType 11089 * 11090 * DESCRIPTION: returns IS type 11091 * 11092 * PARAMETERS : none 11093 * 11094 * RETURN : IS type 11095 * 11096 *==========================================================================*/ 11097 cam_is_type_t QCameraParameters::getISType() 11098 { 11099 return mIsType; 11100 } 11101 11102 /*=========================================================================== 11103 * FUNCTION : MobicatMask 11104 * 11105 * DESCRIPTION: returns mobicat mask 11106 * 11107 * PARAMETERS : none 11108 * 11109 * RETURN : mobicat mask 11110 * 11111 *==========================================================================*/ 11112 uint8_t QCameraParameters::getMobicatMask() 11113 { 11114 return m_MobiMask; 11115 } 11116 11117 /*=========================================================================== 11118 * FUNCTION : sendStreamConfigInfo 11119 * 11120 * DESCRIPTION: send Stream config info. 11121 * 11122 * PARAMETERS : 11123 * @stream_config_info: Stream config information 11124 * 11125 * RETURN : int32_t type of status 11126 * NO_ERROR -- success 11127 * none-zero failure code 11128 *==========================================================================*/ 11129 bool QCameraParameters::sendStreamConfigInfo(cam_stream_size_info_t &stream_config_info) { 11130 int32_t rc = NO_ERROR; 11131 if(initBatchUpdate(m_pParamBuf) < 0 ) { 11132 ALOGE("%s:Failed to initialize group update table", __func__); 11133 return BAD_TYPE; 11134 } 11135 11136 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, 11137 CAM_INTF_META_STREAM_INFO, stream_config_info)) { 11138 ALOGE("%s:Failed to update table", __func__); 11139 return BAD_VALUE; 11140 } 11141 11142 rc = commitSetBatch(); 11143 if (rc != NO_ERROR) { 11144 ALOGE("%s:Failed to set stream info parm", __func__); 11145 return rc; 11146 } 11147 11148 return rc; 11149 } 11150 11151 /*=========================================================================== 11152 * FUNCTION : setStreamConfigure 11153 * 11154 * DESCRIPTION: set stream type, stream dimension for all configured streams. 11155 * 11156 * PARAMETERS : 11157 * @isCapture: Whether this configureation is for an image capture 11158 * @previewAsPostview: Use preview as postview 11159 * 11160 * RETURN : int32_t type of status 11161 * NO_ERROR -- success 11162 * none-zero failure code 11163 *==========================================================================*/ 11164 bool QCameraParameters::setStreamConfigure(bool isCapture, 11165 bool previewAsPostview, bool resetConfig) { 11166 11167 int32_t rc = NO_ERROR; 11168 cam_stream_size_info_t stream_config_info; 11169 char value[PROPERTY_VALUE_MAX]; 11170 bool raw_yuv = false; 11171 bool raw_capture = false; 11172 11173 if ( m_pParamBuf == NULL ) { 11174 return NO_INIT; 11175 } 11176 11177 memset(&stream_config_info, 0, sizeof(stream_config_info)); 11178 stream_config_info.num_streams = 0; 11179 11180 if (m_bStreamsConfigured) { 11181 CDBG_HIGH("%s: Reset stream config!!", __func__); 11182 rc = sendStreamConfigInfo(stream_config_info); 11183 m_bStreamsConfigured = false; 11184 } 11185 if (resetConfig) { 11186 CDBG_HIGH("%s: Done Resetting stream config!!", __func__); 11187 return rc; 11188 } 11189 11190 property_get("persist.camera.raw_yuv", value, "0"); 11191 raw_yuv = atoi(value) > 0 ? true : false; 11192 11193 if (isZSLMode() && getRecordingHintValue() != true) { 11194 stream_config_info.type[stream_config_info.num_streams] = 11195 CAM_STREAM_TYPE_PREVIEW; 11196 getStreamDimension(CAM_STREAM_TYPE_PREVIEW, 11197 stream_config_info.stream_sizes[stream_config_info.num_streams]); 11198 updatePpFeatureMask(CAM_STREAM_TYPE_PREVIEW); 11199 stream_config_info.postprocess_mask[stream_config_info.num_streams] = 11200 mStreamPpMask[CAM_STREAM_TYPE_PREVIEW]; 11201 stream_config_info.num_streams++; 11202 11203 stream_config_info.type[stream_config_info.num_streams] = 11204 CAM_STREAM_TYPE_ANALYSIS; 11205 getStreamDimension(CAM_STREAM_TYPE_ANALYSIS, 11206 stream_config_info.stream_sizes[stream_config_info.num_streams]); 11207 updatePpFeatureMask(CAM_STREAM_TYPE_ANALYSIS); 11208 stream_config_info.postprocess_mask[stream_config_info.num_streams] = 11209 mStreamPpMask[CAM_STREAM_TYPE_ANALYSIS]; 11210 stream_config_info.num_streams++; 11211 11212 stream_config_info.type[stream_config_info.num_streams] = 11213 CAM_STREAM_TYPE_SNAPSHOT; 11214 getStreamDimension(CAM_STREAM_TYPE_SNAPSHOT, 11215 stream_config_info.stream_sizes[stream_config_info.num_streams]); 11216 updatePpFeatureMask(CAM_STREAM_TYPE_SNAPSHOT); 11217 stream_config_info.postprocess_mask[stream_config_info.num_streams] = 11218 mStreamPpMask[CAM_STREAM_TYPE_SNAPSHOT]; 11219 stream_config_info.num_streams++; 11220 11221 } else if (!isCapture) { 11222 if (m_bRecordingHint) { 11223 if (m_bDISEnabled) { 11224 char value[PROPERTY_VALUE_MAX]; 11225 // Make default value for IS_TYPE as IS_TYPE_EIS_2_0 11226 property_get("persist.camera.is_type", value, "4"); 11227 mIsType = static_cast<cam_is_type_t>(atoi(value)); 11228 } else { 11229 mIsType = IS_TYPE_NONE; 11230 } 11231 stream_config_info.is_type = mIsType; 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 stream_config_info.type[stream_config_info.num_streams] = 11242 CAM_STREAM_TYPE_VIDEO; 11243 getStreamDimension(CAM_STREAM_TYPE_VIDEO, 11244 stream_config_info.stream_sizes[stream_config_info.num_streams]); 11245 updatePpFeatureMask(CAM_STREAM_TYPE_VIDEO); 11246 stream_config_info.postprocess_mask[stream_config_info.num_streams] = 11247 mStreamPpMask[CAM_STREAM_TYPE_VIDEO]; 11248 stream_config_info.num_streams++; 11249 } 11250 11251 if (getRecordingHintValue() != true) { 11252 /* Analysis stream is used only in capture usecase */ 11253 stream_config_info.type[stream_config_info.num_streams] = 11254 CAM_STREAM_TYPE_ANALYSIS; 11255 getStreamDimension(CAM_STREAM_TYPE_ANALYSIS, 11256 stream_config_info.stream_sizes[stream_config_info.num_streams]); 11257 updatePpFeatureMask(CAM_STREAM_TYPE_ANALYSIS); 11258 stream_config_info.postprocess_mask[stream_config_info.num_streams] = 11259 mStreamPpMask[CAM_STREAM_TYPE_ANALYSIS]; 11260 stream_config_info.num_streams++; 11261 } 11262 11263 stream_config_info.type[stream_config_info.num_streams] = 11264 CAM_STREAM_TYPE_PREVIEW; 11265 getStreamDimension(CAM_STREAM_TYPE_PREVIEW, 11266 stream_config_info.stream_sizes[stream_config_info.num_streams]); 11267 updatePpFeatureMask(CAM_STREAM_TYPE_PREVIEW); 11268 stream_config_info.postprocess_mask[stream_config_info.num_streams] = 11269 mStreamPpMask[CAM_STREAM_TYPE_PREVIEW]; 11270 stream_config_info.num_streams++; 11271 11272 } else { 11273 if (isJpegPictureFormat() || isNV16PictureFormat() || isNV21PictureFormat()) { 11274 if (!getofflineRAW()) { 11275 stream_config_info.type[stream_config_info.num_streams] = 11276 CAM_STREAM_TYPE_SNAPSHOT; 11277 getStreamDimension(CAM_STREAM_TYPE_SNAPSHOT, 11278 stream_config_info.stream_sizes[stream_config_info.num_streams]); 11279 updatePpFeatureMask(CAM_STREAM_TYPE_SNAPSHOT); 11280 stream_config_info.postprocess_mask[stream_config_info.num_streams] = 11281 mStreamPpMask[CAM_STREAM_TYPE_SNAPSHOT]; 11282 stream_config_info.num_streams++; 11283 } 11284 11285 if (previewAsPostview) { 11286 stream_config_info.type[stream_config_info.num_streams] = 11287 CAM_STREAM_TYPE_PREVIEW; 11288 getStreamDimension(CAM_STREAM_TYPE_PREVIEW, 11289 stream_config_info.stream_sizes[stream_config_info.num_streams]); 11290 updatePpFeatureMask(CAM_STREAM_TYPE_PREVIEW); 11291 stream_config_info.postprocess_mask[stream_config_info.num_streams] = 11292 mStreamPpMask[CAM_STREAM_TYPE_PREVIEW]; 11293 stream_config_info.num_streams++; 11294 } else { 11295 stream_config_info.type[stream_config_info.num_streams] = 11296 CAM_STREAM_TYPE_POSTVIEW; 11297 getStreamDimension(CAM_STREAM_TYPE_POSTVIEW, 11298 stream_config_info.stream_sizes[stream_config_info.num_streams]); 11299 updatePpFeatureMask(CAM_STREAM_TYPE_POSTVIEW); 11300 stream_config_info.postprocess_mask[stream_config_info.num_streams] = 11301 mStreamPpMask[CAM_STREAM_TYPE_POSTVIEW]; 11302 stream_config_info.num_streams++; 11303 } 11304 } else { 11305 raw_capture = true; 11306 stream_config_info.type[stream_config_info.num_streams] = 11307 CAM_STREAM_TYPE_RAW; 11308 getStreamDimension(CAM_STREAM_TYPE_RAW, 11309 stream_config_info.stream_sizes[stream_config_info.num_streams]); 11310 updatePpFeatureMask(CAM_STREAM_TYPE_RAW); 11311 stream_config_info.postprocess_mask[stream_config_info.num_streams] = 11312 mStreamPpMask[CAM_STREAM_TYPE_RAW]; 11313 stream_config_info.num_streams++; 11314 } 11315 } 11316 if (raw_yuv && !raw_capture && (isZSLMode() || 11317 (getofflineRAW() && isCapture && !getRecordingHintValue()))) { 11318 cam_dimension_t max_dim = {0,0}; 11319 updateRAW(max_dim); 11320 stream_config_info.type[stream_config_info.num_streams] = 11321 CAM_STREAM_TYPE_RAW; 11322 getStreamDimension(CAM_STREAM_TYPE_RAW, 11323 stream_config_info.stream_sizes[stream_config_info.num_streams]); 11324 updatePpFeatureMask(CAM_STREAM_TYPE_RAW); 11325 stream_config_info.postprocess_mask[stream_config_info.num_streams] = 11326 mStreamPpMask[CAM_STREAM_TYPE_RAW]; 11327 stream_config_info.num_streams++; 11328 } 11329 for (uint32_t k = 0; k < stream_config_info.num_streams; k++) { 11330 ALOGI("%s: stream type %d, w x h: %d x %d, pp_mask: 0x%x", __func__, 11331 stream_config_info.type[k], 11332 stream_config_info.stream_sizes[k].width, 11333 stream_config_info.stream_sizes[k].height, 11334 stream_config_info.postprocess_mask[k]); 11335 } 11336 11337 rc = sendStreamConfigInfo(stream_config_info); 11338 m_bStreamsConfigured = true; 11339 11340 return rc; 11341 } 11342 11343 /*=========================================================================== 11344 * FUNCTION : addOnlineRotation 11345 * 11346 * DESCRIPTION: send additional rotation information for specific stream 11347 * 11348 * PARAMETERS : 11349 * @rotation: rotation 11350 * @streamId: internal stream id 11351 * @device_rotation: device rotation 11352 * 11353 * RETURN : int32_t type of status 11354 * NO_ERROR -- success 11355 * none-zero failure code 11356 *==========================================================================*/ 11357 int32_t QCameraParameters::addOnlineRotation(uint32_t rotation, uint32_t streamId, 11358 int32_t device_rotation) 11359 { 11360 int32_t rc = NO_ERROR; 11361 cam_rotation_info_t rotation_info; 11362 memset(&rotation_info, 0, sizeof(cam_rotation_info_t)); 11363 11364 /* Add jpeg rotation information */ 11365 if (rotation == 0) { 11366 rotation_info.rotation = ROTATE_0; 11367 } else if (rotation == 90) { 11368 rotation_info.rotation = ROTATE_90; 11369 } else if (rotation == 180) { 11370 rotation_info.rotation = ROTATE_180; 11371 } else if (rotation == 270) { 11372 rotation_info.rotation = ROTATE_270; 11373 } else { 11374 rotation_info.rotation = ROTATE_0; 11375 } 11376 rotation_info.streamId = streamId; 11377 11378 /* Add device rotation information */ 11379 if (device_rotation == 0) { 11380 rotation_info.device_rotation = ROTATE_0; 11381 } else if (device_rotation == 90) { 11382 rotation_info.device_rotation = ROTATE_90; 11383 } else if (device_rotation == 180) { 11384 rotation_info.device_rotation = ROTATE_180; 11385 } else if (device_rotation == 270) { 11386 rotation_info.device_rotation = ROTATE_270; 11387 } else { 11388 rotation_info.device_rotation = ROTATE_0; 11389 } 11390 11391 if(initBatchUpdate(m_pParamBuf) < 0 ) { 11392 ALOGE("%s:Failed to initialize group update table", __func__); 11393 return BAD_TYPE; 11394 } 11395 11396 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_ROTATION, rotation_info)) { 11397 ALOGE("%s:Failed to update table", __func__); 11398 return BAD_VALUE; 11399 } 11400 11401 rc = commitSetBatch(); 11402 if (rc != NO_ERROR) { 11403 ALOGE("%s:Failed to set stream info parm", __func__); 11404 return rc; 11405 } 11406 11407 return rc; 11408 } 11409 11410 /*=========================================================================== 11411 * FUNCTION : needThumbnailReprocess 11412 * 11413 * DESCRIPTION: Check if thumbnail reprocessing is needed 11414 * 11415 * PARAMETERS : @pFeatureMask - feature mask 11416 * 11417 * RETURN : true: needed 11418 * false: no need 11419 *==========================================================================*/ 11420 bool QCameraParameters::needThumbnailReprocess(uint32_t *pFeatureMask) 11421 { 11422 if (isUbiFocusEnabled() || isChromaFlashEnabled() || 11423 isOptiZoomEnabled() || isUbiRefocus() || 11424 isStillMoreEnabled()) { 11425 *pFeatureMask &= ~CAM_QCOM_FEATURE_CHROMA_FLASH; 11426 *pFeatureMask &= ~CAM_QCOM_FEATURE_UBIFOCUS; 11427 *pFeatureMask &= ~CAM_QCOM_FEATURE_REFOCUS; 11428 *pFeatureMask &= ~CAM_QCOM_FEATURE_OPTIZOOM; 11429 *pFeatureMask &= ~CAM_QCOM_FEATURE_STILLMORE; 11430 return false; 11431 } else { 11432 return true; 11433 } 11434 } 11435 11436 /*=========================================================================== 11437 * FUNCTION : getNumOfExtraBuffersForImageProc 11438 * 11439 * DESCRIPTION: get number of extra input buffers needed by image processing 11440 * 11441 * PARAMETERS : none 11442 * 11443 * RETURN : number of extra buffers needed by ImageProc; 11444 * 0 if not ImageProc enabled 11445 *==========================================================================*/ 11446 uint8_t QCameraParameters::getNumOfExtraBuffersForImageProc() 11447 { 11448 int numOfBufs = 0; 11449 11450 if (isUbiRefocus()) { 11451 return (uint8_t)(m_pCapability->refocus_af_bracketing_need.burst_count - 1); 11452 } else if (isUbiFocusEnabled()) { 11453 numOfBufs += m_pCapability->ubifocus_af_bracketing_need.burst_count - 1; 11454 } else if (m_bOptiZoomOn) { 11455 numOfBufs += m_pCapability->opti_zoom_settings_need.burst_count - 1; 11456 } else if (isChromaFlashEnabled()) { 11457 numOfBufs += m_pCapability->chroma_flash_settings_need.burst_count - 1; 11458 } else if (isStillMoreEnabled()) { 11459 if (isSeeMoreEnabled()) { 11460 m_stillmore_config.burst_count = 1; 11461 } else if ((m_stillmore_config.burst_count >= 11462 m_pCapability->stillmore_settings_need.min_burst_count) && 11463 (m_stillmore_config.burst_count <= 11464 m_pCapability->stillmore_settings_need.max_burst_count)) { 11465 numOfBufs += m_stillmore_config.burst_count - 1; 11466 } else { 11467 numOfBufs += m_pCapability->stillmore_settings_need.burst_count - 1; 11468 } 11469 } 11470 11471 return (uint8_t)(numOfBufs * getBurstNum()); 11472 } 11473 11474 /*=========================================================================== 11475 * FUNCTION : getExifBufIndex 11476 * 11477 * DESCRIPTION: get index of metadata to be used for EXIF 11478 * 11479 * PARAMETERS : @captureIndex - index of current captured frame 11480 * 11481 * RETURN : index of metadata to be used for EXIF 11482 *==========================================================================*/ 11483 uint32_t QCameraParameters::getExifBufIndex(uint32_t captureIndex) 11484 { 11485 uint32_t index = captureIndex; 11486 11487 if (isUbiRefocus()) { 11488 if (captureIndex < m_pCapability->refocus_af_bracketing_need.burst_count) { 11489 index = captureIndex; 11490 } else { 11491 index = 0; 11492 } 11493 } else if (isChromaFlashEnabled()) { 11494 index = m_pCapability->chroma_flash_settings_need.metadata_index; 11495 } else if (isHDREnabled()) { 11496 if (isHDR1xFrameEnabled() && isHDR1xExtraBufferNeeded()) { 11497 index = m_pCapability->hdr_bracketing_setting.num_frames; 11498 } else { 11499 for (index = 0; index < m_pCapability->hdr_bracketing_setting.num_frames; index++) { 11500 if (0 == m_pCapability->hdr_bracketing_setting.exp_val.values[index]) { 11501 break; 11502 } 11503 } 11504 if (index == m_pCapability->hdr_bracketing_setting.num_frames) { 11505 index = captureIndex; 11506 } 11507 } 11508 } 11509 11510 return index; 11511 } 11512 11513 /*=========================================================================== 11514 * FUNCTION : getNumberInBufsForSingleShot 11515 * 11516 * DESCRIPTION: get number of input buffers for single shot 11517 * 11518 * PARAMETERS : none 11519 * 11520 * RETURN : number of input buffers for single shot 11521 *==========================================================================*/ 11522 uint32_t QCameraParameters::getNumberInBufsForSingleShot() 11523 { 11524 uint32_t numOfBufs = 1; 11525 11526 if (isUbiRefocus()) { 11527 numOfBufs = m_pCapability->refocus_af_bracketing_need.burst_count; 11528 } else if (isUbiFocusEnabled()) { 11529 numOfBufs = m_pCapability->ubifocus_af_bracketing_need.burst_count; 11530 } else if (m_bOptiZoomOn) { 11531 numOfBufs = m_pCapability->opti_zoom_settings_need.burst_count; 11532 } else if (isChromaFlashEnabled()) { 11533 numOfBufs = m_pCapability->chroma_flash_settings_need.burst_count; 11534 } else if (isHDREnabled()) { 11535 numOfBufs = m_pCapability->hdr_bracketing_setting.num_frames; 11536 if (isHDR1xFrameEnabled() && isHDR1xExtraBufferNeeded()) { 11537 numOfBufs++; 11538 } 11539 } else if (isStillMoreEnabled()) { 11540 if (isSeeMoreEnabled()) { 11541 m_stillmore_config.burst_count = 1; 11542 numOfBufs = m_stillmore_config.burst_count; 11543 } else if ((m_stillmore_config.burst_count >= 11544 m_pCapability->stillmore_settings_need.min_burst_count) && 11545 (m_stillmore_config.burst_count <= 11546 m_pCapability->stillmore_settings_need.max_burst_count)) { 11547 numOfBufs = m_stillmore_config.burst_count; 11548 } else { 11549 numOfBufs = m_pCapability->stillmore_settings_need.burst_count; 11550 } 11551 } 11552 11553 return numOfBufs; 11554 } 11555 11556 /*=========================================================================== 11557 * FUNCTION : getNumberOutBufsForSingleShot 11558 * 11559 * DESCRIPTION: get number of output buffers for single shot 11560 * 11561 * PARAMETERS : none 11562 * 11563 * RETURN : number of output buffers for single shot 11564 *==========================================================================*/ 11565 uint32_t QCameraParameters::getNumberOutBufsForSingleShot() 11566 { 11567 uint32_t numOfBufs = 1; 11568 11569 if (isUbiRefocus()) { 11570 numOfBufs = m_pCapability->refocus_af_bracketing_need.output_count; 11571 } else if (isHDREnabled()) { 11572 if (isHDR1xFrameEnabled()) { 11573 numOfBufs++; 11574 } 11575 } 11576 11577 return numOfBufs; 11578 } 11579 11580 /*=========================================================================== 11581 * FUNCTION : is4k2kVideoResolution 11582 * 11583 * DESCRIPTION: if resolution is 4k x 2k or true 4k x 2k 11584 * 11585 * PARAMETERS : none 11586 * 11587 * RETURN : true: video resolution is 4k x 2k 11588 * false: video resolution is not 4k x 2k 11589 *==========================================================================*/ 11590 bool QCameraParameters::is4k2kVideoResolution() 11591 { 11592 bool enabled = false; 11593 cam_dimension_t resolution; 11594 getVideoSize(&resolution.width, &resolution.height); 11595 if (!(resolution.width < 3840 && resolution.height < 2160)) { 11596 enabled = true; 11597 } 11598 11599 return enabled; 11600 } 11601 11602 /*=========================================================================== 11603 * FUNCTION : updateDebugLevel 11604 * 11605 * DESCRIPTION: send CAM_INTF_PARM_UPDATE_DEBUG_LEVEL to backend 11606 * 11607 * PARAMETERS : none 11608 * 11609 * RETURN : NO_ERROR --success 11610 * int32_t type of status 11611 *==========================================================================*/ 11612 int32_t QCameraParameters::updateDebugLevel() 11613 { 11614 if ( m_pParamBuf == NULL ) { 11615 return NO_INIT; 11616 } 11617 11618 int32_t rc = initBatchUpdate(m_pParamBuf); 11619 if ( rc != NO_ERROR ) { 11620 ALOGE("%s:Failed to initialize group update table", __func__); 11621 return rc; 11622 } 11623 11624 uint32_t dummyDebugLevel = 0; 11625 /* The value of dummyDebugLevel is irrelavent. On 11626 * CAM_INTF_PARM_UPDATE_DEBUG_LEVEL, read debug property */ 11627 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_UPDATE_DEBUG_LEVEL, dummyDebugLevel)) { 11628 ALOGE("%s: Parameters batch failed",__func__); 11629 return BAD_VALUE; 11630 } 11631 11632 rc = commitSetBatch(); 11633 if ( rc != NO_ERROR ) { 11634 ALOGE("%s:Failed to commit batch parameters", __func__); 11635 return rc; 11636 } 11637 11638 return NO_ERROR; 11639 } 11640 11641 /*=========================================================================== 11642 * FUNCTION : setOfflineRAW 11643 * 11644 * DESCRIPTION: Function to decide Offline RAW feature. 11645 * 11646 * PARAMETERS : none 11647 * 11648 * RETURN : none 11649 *==========================================================================*/ 11650 void QCameraParameters::setOfflineRAW() 11651 { 11652 char value[PROPERTY_VALUE_MAX]; 11653 bool raw_yuv = false; 11654 bool offlineRaw = false; 11655 11656 property_get("persist.camera.raw_yuv", value, "0"); 11657 raw_yuv = atoi(value) > 0 ? true : false; 11658 property_get("persist.camera.offlineraw", value, "0"); 11659 offlineRaw = atoi(value) > 0 ? true : false; 11660 if((raw_yuv || isRdiMode()) && offlineRaw){ 11661 mOfflineRAW = true; 11662 }else{ 11663 mOfflineRAW = false; 11664 } 11665 CDBG_HIGH("%s: Offline Raw %d",__func__, mOfflineRAW); 11666 } 11667 11668 /*=========================================================================== 11669 * FUNCTION : updatePpFeatureMask 11670 * 11671 * DESCRIPTION: Updates the feature mask for a particular stream depending 11672 * on current client configuration. 11673 * 11674 * PARAMETERS : 11675 * @stream_type: Camera stream type 11676 * 11677 * RETURN : NO_ERROR --success 11678 * int32_t type of status 11679 *==========================================================================*/ 11680 int32_t QCameraParameters::updatePpFeatureMask(cam_stream_type_t stream_type) { 11681 11682 uint32_t feature_mask = 0; 11683 11684 if (stream_type >= CAM_STREAM_TYPE_MAX) { 11685 ALOGE("%s: Error!! stream type: %d not valid", __func__, stream_type); 11686 return -1; 11687 } 11688 11689 // Update feature mask for SeeMore in video and video preview 11690 if (isSeeMoreEnabled() && 11691 !is4k2kVideoResolution() && 11692 ((stream_type == CAM_STREAM_TYPE_VIDEO) || 11693 (stream_type == CAM_STREAM_TYPE_PREVIEW && getRecordingHintValue()))) { 11694 feature_mask |= CAM_QCOM_FEATURE_LLVD; 11695 } 11696 11697 // Do not enable feature mask for ZSL/non-ZSL/liveshot snapshot except for 4K2k case 11698 if ((getRecordingHintValue() && 11699 (stream_type == CAM_STREAM_TYPE_SNAPSHOT) && is4k2kVideoResolution()) || 11700 (stream_type != CAM_STREAM_TYPE_SNAPSHOT)) { 11701 if ((m_nMinRequiredPpMask & CAM_QCOM_FEATURE_SHARPNESS) && 11702 !isOptiZoomEnabled()) { 11703 feature_mask |= CAM_QCOM_FEATURE_SHARPNESS; 11704 } 11705 11706 if (m_nMinRequiredPpMask & CAM_QCOM_FEATURE_EFFECT) { 11707 feature_mask |= CAM_QCOM_FEATURE_EFFECT; 11708 } 11709 if (isWNREnabled() && (getRecordingHintValue() == false)) { 11710 feature_mask |= CAM_QCOM_FEATURE_DENOISE2D; 11711 } 11712 11713 //Set flip mode based on Stream type; 11714 int flipMode = getFlipMode(stream_type); 11715 if (flipMode > 0) { 11716 feature_mask |= CAM_QCOM_FEATURE_FLIP; 11717 } 11718 } 11719 11720 if ((isTNRVideoEnabled() && (CAM_STREAM_TYPE_VIDEO == stream_type)) 11721 || (isTNRPreviewEnabled() && (CAM_STREAM_TYPE_PREVIEW == stream_type))) { 11722 feature_mask |= CAM_QCOM_FEATURE_CPP_TNR; 11723 } 11724 11725 //Rotation could also have an effect on pp feature mask 11726 cam_pp_feature_config_t config; 11727 cam_dimension_t dim; 11728 memset(&config, 0, sizeof(cam_pp_feature_config_t)); 11729 getStreamRotation(stream_type, config, dim); 11730 feature_mask |= config.feature_mask; 11731 11732 // Store stream feature mask 11733 setStreamPpMask(stream_type, feature_mask); 11734 CDBG_HIGH("%s: stream type: %d, pp_mask: 0x%x", __func__, stream_type, feature_mask); 11735 11736 return NO_ERROR; 11737 } 11738 11739 /*=========================================================================== 11740 * FUNCTION : setStreamPpMask 11741 * 11742 * DESCRIPTION: Stores a particular feature mask for a given camera stream 11743 * 11744 * PARAMETERS : 11745 * @stream_type: Camera stream type 11746 * @pp_mask : Feature mask 11747 * 11748 * RETURN : NO_ERROR --success 11749 * int32_t type of status 11750 *==========================================================================*/ 11751 int32_t QCameraParameters::setStreamPpMask(cam_stream_type_t stream_type, 11752 uint32_t pp_mask) { 11753 11754 if(stream_type >= CAM_STREAM_TYPE_MAX) { 11755 return BAD_TYPE; 11756 } 11757 11758 mStreamPpMask[stream_type] = pp_mask; 11759 return NO_ERROR; 11760 } 11761 11762 /*=========================================================================== 11763 * FUNCTION : getStreamPpMask 11764 * 11765 * DESCRIPTION: Retrieves the feature mask for a given camera stream 11766 * 11767 * PARAMETERS : 11768 * @stream_type: Camera stream type 11769 * @pp_mask : Feature mask 11770 * 11771 * RETURN : NO_ERROR --success 11772 * int32_t type of status 11773 *==========================================================================*/ 11774 int32_t QCameraParameters::getStreamPpMask(cam_stream_type_t stream_type, 11775 uint32_t &pp_mask) { 11776 11777 if(stream_type >= CAM_STREAM_TYPE_MAX) { 11778 return BAD_TYPE; 11779 } 11780 11781 pp_mask = mStreamPpMask[stream_type]; 11782 return NO_ERROR; 11783 } 11784 11785 /*=========================================================================== 11786 * FUNCTION : setReprocCount 11787 * 11788 * DESCRIPTION: Set total reprocessing pass count 11789 * 11790 * PARAMETERS : none 11791 * 11792 * RETURN : None 11793 *==========================================================================*/ 11794 void QCameraParameters::setReprocCount() 11795 { 11796 mTotalPPCount = 1; //Default reprocessing Pass count 11797 char value[PROPERTY_VALUE_MAX]; 11798 int multpass = 0; 11799 11800 property_get("persist.camera.multi_pass", value, "0"); 11801 multpass = atoi(value); 11802 11803 if ( multpass == 0 ) { 11804 return; 11805 } 11806 11807 if ((getZoomLevel() != 0) && (isZSLMode())) { 11808 ALOGW("Zoom Present. Need 2nd pass for post processing"); 11809 mTotalPPCount++; 11810 } 11811 } 11812 11813 /*=========================================================================== 11814 * FUNCTION : setBufBatchCount 11815 * 11816 * DESCRIPTION: Function to configure batch buffer 11817 * 11818 * PARAMETERS : int8_t buf_cnt 11819 * Buffer batch count 11820 * 11821 * RETURN : None 11822 *==========================================================================*/ 11823 void QCameraParameters::setBufBatchCount(int8_t buf_cnt) 11824 { 11825 mBufBatchCnt = 0; 11826 char value[PROPERTY_VALUE_MAX]; 11827 int8_t count = 0; 11828 11829 property_get("persist.camera.batchcount", value, "0"); 11830 count = atoi(value); 11831 11832 if (!(count != 0 || buf_cnt > CAMERA_MIN_BATCH_COUNT)) { 11833 CDBG_HIGH("%s : Buffer batch count = %d", __func__, mBufBatchCnt); 11834 return; 11835 } 11836 11837 while((m_pCapability->max_batch_bufs_supported != 0) 11838 && (m_pCapability->max_batch_bufs_supported < buf_cnt)) { 11839 buf_cnt = buf_cnt / 2; 11840 } 11841 11842 if (count > 0) { 11843 mBufBatchCnt = count; 11844 CDBG_HIGH("%s : Buffer batch count = %d", __func__, mBufBatchCnt); 11845 return; 11846 } 11847 11848 if (buf_cnt > CAMERA_MIN_BATCH_COUNT) { 11849 mBufBatchCnt = buf_cnt; 11850 CDBG_HIGH("%s : Buffer batch count = %d", __func__, mBufBatchCnt); 11851 return; 11852 } 11853 } 11854 11855 /*=========================================================================== 11856 * FUNCTION : dump 11857 * 11858 * DESCRIPTION: Composes a string based on current configuration 11859 * 11860 * PARAMETERS : none 11861 * 11862 * RETURN : Formatted string 11863 *==========================================================================*/ 11864 String8 QCameraParameters::dump() 11865 { 11866 String8 str("\n"); 11867 char s[128]; 11868 11869 snprintf(s, 128, "Preview Pixel Fmt: %d\n", getPreviewHalPixelFormat()); 11870 str += s; 11871 11872 snprintf(s, 128, "ZSL Burst Interval: %d\n", getZSLBurstInterval()); 11873 str += s; 11874 11875 snprintf(s, 128, "ZSL Queue Depth: %d\n", getZSLQueueDepth()); 11876 str += s; 11877 11878 snprintf(s, 128, "ZSL Back Look Count %d\n", getZSLBackLookCount()); 11879 str += s; 11880 11881 snprintf(s, 128, "Max Unmatched Frames In Queue: %d\n", 11882 getMaxUnmatchedFramesInQueue()); 11883 str += s; 11884 11885 snprintf(s, 128, "Is ZSL Mode: %d\n", isZSLMode()); 11886 str += s; 11887 11888 snprintf(s, 128, "Is No Display Mode: %d\n", isNoDisplayMode()); 11889 str += s; 11890 11891 snprintf(s, 128, "Is WNR Enabled: %d\n", isWNREnabled()); 11892 str += s; 11893 11894 snprintf(s, 128, "isHfrMode: %d\n", isHfrMode()); 11895 str += s; 11896 11897 snprintf(s, 128, "getNumOfSnapshots: %d\n", getNumOfSnapshots()); 11898 str += s; 11899 11900 snprintf(s, 128, "getNumOfExtraHDRInBufsIfNeeded: %d\n", 11901 getNumOfExtraHDRInBufsIfNeeded()); 11902 str += s; 11903 11904 snprintf(s, 128, "getNumOfExtraHDROutBufsIfNeeded: %d\n", 11905 getNumOfExtraHDROutBufsIfNeeded()); 11906 str += s; 11907 11908 snprintf(s, 128, "getBurstNum: %d\n", getBurstNum()); 11909 str += s; 11910 11911 snprintf(s, 128, "getRecordingHintValue: %d\n", getRecordingHintValue()); 11912 str += s; 11913 11914 snprintf(s, 128, "getJpegQuality: %u\n", getJpegQuality()); 11915 str += s; 11916 11917 snprintf(s, 128, "getJpegRotation: %u\n", getJpegRotation()); 11918 str += s; 11919 11920 snprintf(s, 128, "isHistogramEnabled: %d\n", isHistogramEnabled()); 11921 str += s; 11922 11923 snprintf(s, 128, "isFaceDetectionEnabled: %d\n", isFaceDetectionEnabled()); 11924 str += s; 11925 11926 snprintf(s, 128, "isHDREnabled: %d\n", isHDREnabled()); 11927 str += s; 11928 11929 snprintf(s, 128, "isAutoHDREnabled: %d\n", isAutoHDREnabled()); 11930 str += s; 11931 11932 snprintf(s, 128, "isAVTimerEnabled: %d\n", isAVTimerEnabled()); 11933 str += s; 11934 11935 snprintf(s, 128, "getFocusMode: %d\n", getFocusMode()); 11936 str += s; 11937 11938 snprintf(s, 128, "isJpegPictureFormat: %d\n", isJpegPictureFormat()); 11939 str += s; 11940 11941 snprintf(s, 128, "isNV16PictureFormat: %d\n", isNV16PictureFormat()); 11942 str += s; 11943 11944 snprintf(s, 128, "isNV21PictureFormat: %d\n", isNV21PictureFormat()); 11945 str += s; 11946 11947 snprintf(s, 128, "isSnapshotFDNeeded: %d\n", isSnapshotFDNeeded()); 11948 str += s; 11949 11950 snprintf(s, 128, "isHDR1xFrameEnabled: %d\n", isHDR1xFrameEnabled()); 11951 str += s; 11952 11953 snprintf(s, 128, "isYUVFrameInfoNeeded: %d\n", isYUVFrameInfoNeeded()); 11954 str += s; 11955 11956 snprintf(s, 128, "isHDR1xExtraBufferNeeded: %d\n", 11957 isHDR1xExtraBufferNeeded()); 11958 str += s; 11959 11960 snprintf(s, 128, "isHDROutputCropEnabled: %d\n", isHDROutputCropEnabled()); 11961 str += s; 11962 11963 snprintf(s, 128, "isPreviewFlipChanged: %d\n", isPreviewFlipChanged()); 11964 str += s; 11965 11966 snprintf(s, 128, "isVideoFlipChanged: %d\n", isVideoFlipChanged()); 11967 str += s; 11968 11969 snprintf(s, 128, "isSnapshotFlipChanged: %d\n", isSnapshotFlipChanged()); 11970 str += s; 11971 11972 snprintf(s, 128, "isHDRThumbnailProcessNeeded: %d\n", 11973 isHDRThumbnailProcessNeeded()); 11974 str += s; 11975 11976 snprintf(s, 128, "getAutoFlickerMode: %d\n", getAutoFlickerMode()); 11977 str += s; 11978 11979 snprintf(s, 128, "getNumOfExtraBuffersForImageProc: %d\n", 11980 getNumOfExtraBuffersForImageProc()); 11981 str += s; 11982 11983 snprintf(s, 128, "isUbiFocusEnabled: %d\n", isUbiFocusEnabled()); 11984 str += s; 11985 11986 snprintf(s, 128, "isChromaFlashEnabled: %d\n", isChromaFlashEnabled()); 11987 str += s; 11988 11989 snprintf(s, 128, "isOptiZoomEnabled: %d\n", isOptiZoomEnabled()); 11990 str += s; 11991 11992 snprintf(s, 128, "isStillMoreEnabled: %d\n", isStillMoreEnabled()); 11993 str += s; 11994 11995 snprintf(s, 128, "getBurstCountForAdvancedCapture: %d\n", 11996 getBurstCountForAdvancedCapture()); 11997 str += s; 11998 11999 return str; 12000 } 12001 12002 /*=========================================================================== 12003 * FUNCTION : getNumOfExtraBuffersForVideo 12004 * 12005 * DESCRIPTION: get number of extra buffers needed by image processing 12006 * 12007 * PARAMETERS : none 12008 * 12009 * RETURN : number of extra buffers needed by ImageProc; 12010 * 0 if not ImageProc enabled 12011 *==========================================================================*/ 12012 uint8_t QCameraParameters::getNumOfExtraBuffersForVideo() 12013 { 12014 uint8_t numOfBufs = 0; 12015 12016 if (isSeeMoreEnabled()) { 12017 numOfBufs = 1; 12018 } 12019 12020 return numOfBufs; 12021 } 12022 12023 /*=========================================================================== 12024 * FUNCTION : getNumOfExtraBuffersForPreview 12025 * 12026 * DESCRIPTION: get number of extra buffers needed by image processing 12027 * 12028 * PARAMETERS : none 12029 * 12030 * RETURN : number of extra buffers needed by ImageProc; 12031 * 0 if not ImageProc enabled 12032 *==========================================================================*/ 12033 uint8_t QCameraParameters::getNumOfExtraBuffersForPreview() 12034 { 12035 uint8_t numOfBufs = 0; 12036 12037 if (isSeeMoreEnabled() && !isZSLMode() && getRecordingHintValue()) { 12038 numOfBufs = 1; 12039 } 12040 12041 return numOfBufs; 12042 } 12043 12044 /*=========================================================================== 12045 * FUNCTION : setToneMapMode 12046 * 12047 * DESCRIPTION: enable or disable tone map 12048 * 12049 * PARAMETERS : 12050 * @enable : enable: 1; disable 0 12051 * @initCommit: if configuration list needs to be initialized and commited 12052 * 12053 * RETURN : int32_t type of status 12054 * NO_ERROR -- success 12055 * none-zero failure code 12056 *==========================================================================*/ 12057 int32_t QCameraParameters::setToneMapMode(uint32_t enable, bool initCommit) 12058 { 12059 int32_t rc = NO_ERROR; 12060 CDBG_HIGH("%s: tone map mode %d ", __func__, enable); 12061 12062 if (initCommit) { 12063 if (initBatchUpdate(m_pParamBuf) < 0) { 12064 ALOGE("%s:Failed to initialize group update table", __func__); 12065 return FAILED_TRANSACTION; 12066 } 12067 } 12068 12069 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_TONE_MAP_MODE, enable)) { 12070 ALOGE("%s:Failed to update tone map mode", __func__); 12071 return BAD_VALUE; 12072 } 12073 12074 if (initCommit) { 12075 rc = commitSetBatch(); 12076 if (rc != NO_ERROR) { 12077 ALOGE("%s:Failed to commit tone map mode", __func__); 12078 return rc; 12079 } 12080 } 12081 12082 return rc; 12083 } 12084 12085 /*=========================================================================== 12086 * FUNCTION : setCDSMode 12087 * 12088 * DESCRIPTION: set CDS mode 12089 * 12090 * PARAMETERS : 12091 * @cds_mode : cds mode 12092 * @initCommit: if configuration list needs to be initialized and commited 12093 * 12094 * RETURN : int32_t type of status 12095 * NO_ERROR -- success 12096 * none-zero failure code 12097 *==========================================================================*/ 12098 int32_t QCameraParameters::setCDSMode(int32_t cds_mode, bool initCommit) 12099 { 12100 if (initCommit) { 12101 if (initBatchUpdate(m_pParamBuf) < 0) { 12102 ALOGE("%s:Failed to initialize group update table", __func__); 12103 return FAILED_TRANSACTION; 12104 } 12105 } 12106 12107 int32_t rc = NO_ERROR; 12108 if (ADD_SET_PARAM_ENTRY_TO_BATCH(m_pParamBuf, CAM_INTF_PARM_CDS_MODE, cds_mode)) { 12109 ALOGE("%s:Failed to update cds mode", __func__); 12110 return BAD_VALUE; 12111 } 12112 12113 if (initCommit) { 12114 rc = commitSetBatch(); 12115 if (NO_ERROR != rc) { 12116 ALOGE("%s:Failed to set cds mode", __func__); 12117 return rc; 12118 } 12119 } 12120 12121 CDBG_HIGH(" cds mode -> %d", cds_mode); 12122 12123 return rc; 12124 } 12125 12126 }; // namespace qcamera 12127