QCameraParameters.cpp revision 6c6d887243f26c81543d33c2f8aa169862324b40
1/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. 2 * 3 * Redistribution and use in source and binary forms, with or without 4 * modification, are permitted provided that the following conditions are 5 * met: 6 * * Redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer. 8 * * Redistributions in binary form must reproduce the above 9 * copyright notice, this list of conditions and the following 10 * disclaimer in the documentation and/or other materials provided 11 * with the distribution. 12 * * Neither the name of The Linux Foundation nor the names of its 13 * contributors may be used to endorse or promote products derived 14 * from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 */ 29 30#define LOG_TAG "QCameraParameters" 31 32#include <cutils/properties.h> 33#include <math.h> 34#include <utils/Errors.h> 35#include <string.h> 36#include <stdlib.h> 37#include <gralloc_priv.h> 38#include "QCamera2HWI.h" 39#include "QCameraParameters.h" 40 41#define ASPECT_TOLERANCE 0.001 42#define FLIP_V_H (FLIP_H | FLIP_V) 43 44namespace qcamera { 45// Parameter keys to communicate between camera application and driver. 46const char QCameraParameters::KEY_QC_SUPPORTED_HFR_SIZES[] = "hfr-size-values"; 47const char QCameraParameters::KEY_QC_PREVIEW_FRAME_RATE_MODE[] = "preview-frame-rate-mode"; 48const char QCameraParameters::KEY_QC_SUPPORTED_PREVIEW_FRAME_RATE_MODES[] = "preview-frame-rate-modes"; 49const char QCameraParameters::KEY_QC_PREVIEW_FRAME_RATE_AUTO_MODE[] = "frame-rate-auto"; 50const char QCameraParameters::KEY_QC_PREVIEW_FRAME_RATE_FIXED_MODE[] = "frame-rate-fixed"; 51const char QCameraParameters::KEY_QC_TOUCH_AF_AEC[] = "touch-af-aec"; 52const char QCameraParameters::KEY_QC_SUPPORTED_TOUCH_AF_AEC[] = "touch-af-aec-values"; 53const char QCameraParameters::KEY_QC_TOUCH_INDEX_AEC[] = "touch-index-aec"; 54const char QCameraParameters::KEY_QC_TOUCH_INDEX_AF[] = "touch-index-af"; 55const char QCameraParameters::KEY_QC_SCENE_DETECT[] = "scene-detect"; 56const char QCameraParameters::KEY_QC_SUPPORTED_SCENE_DETECT[] = "scene-detect-values"; 57const char QCameraParameters::KEY_QC_ISO_MODE[] = "iso"; 58const char QCameraParameters::KEY_QC_SUPPORTED_ISO_MODES[] = "iso-values"; 59const char QCameraParameters::KEY_QC_LENSSHADE[] = "lensshade"; 60const char QCameraParameters::KEY_QC_SUPPORTED_LENSSHADE_MODES[] = "lensshade-values"; 61const char QCameraParameters::KEY_QC_AUTO_EXPOSURE[] = "auto-exposure"; 62const char QCameraParameters::KEY_QC_SUPPORTED_AUTO_EXPOSURE[] = "auto-exposure-values"; 63const char QCameraParameters::KEY_QC_DENOISE[] = "denoise"; 64const char QCameraParameters::KEY_QC_SUPPORTED_DENOISE[] = "denoise-values"; 65const char QCameraParameters::KEY_QC_FOCUS_ALGO[] = "selectable-zone-af"; 66const char QCameraParameters::KEY_QC_SUPPORTED_FOCUS_ALGOS[] = "selectable-zone-af-values"; 67const char QCameraParameters::KEY_QC_FACE_DETECTION[] = "face-detection"; 68const char QCameraParameters::KEY_QC_SUPPORTED_FACE_DETECTION[] = "face-detection-values"; 69const char QCameraParameters::KEY_QC_FACE_RECOGNITION[] = "face-recognition"; 70const char QCameraParameters::KEY_QC_SUPPORTED_FACE_RECOGNITION[] = "face-recognition-values"; 71const char QCameraParameters::KEY_QC_MEMORY_COLOR_ENHANCEMENT[] = "mce"; 72const char QCameraParameters::KEY_QC_SUPPORTED_MEM_COLOR_ENHANCE_MODES[] = "mce-values"; 73const char QCameraParameters::KEY_QC_DIS[] = "dis"; 74const char QCameraParameters::KEY_QC_SUPPORTED_DIS_MODES[] = "dis-values"; 75const char QCameraParameters::KEY_QC_VIDEO_HIGH_FRAME_RATE[] = "video-hfr"; 76const char QCameraParameters::KEY_QC_SUPPORTED_VIDEO_HIGH_FRAME_RATE_MODES[] = "video-hfr-values"; 77const char QCameraParameters::KEY_QC_REDEYE_REDUCTION[] = "redeye-reduction"; 78const char QCameraParameters::KEY_QC_SUPPORTED_REDEYE_REDUCTION[] = "redeye-reduction-values"; 79const char QCameraParameters::KEY_QC_HIGH_DYNAMIC_RANGE_IMAGING[] = "hdr"; 80const char QCameraParameters::KEY_QC_SUPPORTED_HDR_IMAGING_MODES[] = "hdr-values"; 81const char QCameraParameters::KEY_QC_ZSL[] = "zsl"; 82const char QCameraParameters::KEY_QC_SUPPORTED_ZSL_MODES[] = "zsl-values"; 83const char QCameraParameters::KEY_QC_ZSL_BURST_INTERVAL[] = "capture-burst-interval"; 84const char QCameraParameters::KEY_QC_ZSL_BURST_LOOKBACK[] = "capture-burst-retroactive"; 85const char QCameraParameters::KEY_QC_ZSL_QUEUE_DEPTH[] = "capture-burst-queue-depth"; 86const char QCameraParameters::KEY_QC_CAMERA_MODE[] = "camera-mode"; 87const char QCameraParameters::KEY_QC_AE_BRACKET_HDR[] = "ae-bracket-hdr"; 88const char QCameraParameters::KEY_QC_SUPPORTED_AE_BRACKET_MODES[] = "ae-bracket-hdr-values"; 89const char QCameraParameters::KEY_QC_SUPPORTED_RAW_FORMATS[] = "raw-format-values"; 90const char QCameraParameters::KEY_QC_RAW_FORMAT[] = "raw-format"; 91const char QCameraParameters::KEY_QC_ORIENTATION[] = "orientation"; 92const char QCameraParameters::KEY_QC_SELECTABLE_ZONE_AF[] = "selectable-zone-af"; 93const char QCameraParameters::KEY_QC_CAPTURE_BURST_EXPOSURE[] = "capture-burst-exposures"; 94const char QCameraParameters::KEY_QC_NUM_SNAPSHOT_PER_SHUTTER[] = "num-snaps-per-shutter"; 95const char QCameraParameters::KEY_QC_NO_DISPLAY_MODE[] = "no-display-mode"; 96const char QCameraParameters::KEY_QC_RAW_PICUTRE_SIZE[] = "raw-size"; 97const char QCameraParameters::KEY_QC_SUPPORTED_SKIN_TONE_ENHANCEMENT_MODES[] = "skinToneEnhancement-values"; 98const char QCameraParameters::KEY_QC_SUPPORTED_LIVESNAPSHOT_SIZES[] = "supported-live-snapshot-sizes"; 99const char QCameraParameters::KEY_QC_HDR_NEED_1X[] = "hdr-need-1x"; 100const char QCameraParameters::KEY_QC_PREVIEW_FLIP[] = "preview-flip"; 101const char QCameraParameters::KEY_QC_VIDEO_FLIP[] = "video-flip"; 102const char QCameraParameters::KEY_QC_SNAPSHOT_PICTURE_FLIP[] = "snapshot-picture-flip"; 103const char QCameraParameters::KEY_QC_SUPPORTED_FLIP_MODES[] = "flip-mode-values"; 104const char QCameraParameters::KEY_QC_VIDEO_HDR[] = "video-hdr"; 105const char QCameraParameters::KEY_QC_SUPPORTED_VIDEO_HDR_MODES[] = "video-hdr-values"; 106 107// Values for effect settings. 108const char QCameraParameters::EFFECT_EMBOSS[] = "emboss"; 109const char QCameraParameters::EFFECT_SKETCH[] = "sketch"; 110const char QCameraParameters::EFFECT_NEON[] = "neon"; 111 112// Values for auto exposure settings. 113const char QCameraParameters::TOUCH_AF_AEC_OFF[] = "touch-off"; 114const char QCameraParameters::TOUCH_AF_AEC_ON[] = "touch-on"; 115 116// Values for scene mode settings. 117const char QCameraParameters::SCENE_MODE_ASD[] = "asd"; // corresponds to CAMERA_BESTSHOT_AUTO in HAL 118const char QCameraParameters::SCENE_MODE_BACKLIGHT[] = "backlight"; 119const char QCameraParameters::SCENE_MODE_FLOWERS[] = "flowers"; 120const char QCameraParameters::SCENE_MODE_AR[] = "AR"; 121const char QCameraParameters::SCENE_MODE_HDR[] = "hdr"; 122 123// Formats for setPreviewFormat and setPictureFormat. 124const char QCameraParameters::PIXEL_FORMAT_YUV420SP_ADRENO[] = "yuv420sp-adreno"; 125const char QCameraParameters::PIXEL_FORMAT_YV12[] = "yuv420p"; 126const char QCameraParameters::PIXEL_FORMAT_NV12[] = "nv12"; 127 128// Values for raw image formats 129const char QCameraParameters::QC_PIXEL_FORMAT_YUV_RAW_8BIT_YUYV[] = "yuv-raw8-yuyv"; 130const char QCameraParameters::QC_PIXEL_FORMAT_YUV_RAW_8BIT_YVYU[] = "yuv-raw8-yvyu"; 131const char QCameraParameters::QC_PIXEL_FORMAT_YUV_RAW_8BIT_UYVY[] = "yuv-raw8-uyvy"; 132const char QCameraParameters::QC_PIXEL_FORMAT_YUV_RAW_8BIT_VYUY[] = "yuv-raw8-vyuy"; 133const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8GBRG[] = "bayer-qcom-8gbrg"; 134const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8GRBG[] = "bayer-qcom-8grbg"; 135const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8RGGB[] = "bayer-qcom-8rggb"; 136const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8BGGR[] = "bayer-qcom-8bggr"; 137const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10GBRG[] = "bayer-qcom-10gbrg"; 138const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10GRBG[] = "bayer-qcom-10grbg"; 139const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10RGGB[] = "bayer-qcom-10rggb"; 140const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10BGGR[] = "bayer-qcom-10bggr"; 141const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12GBRG[] = "bayer-qcom-12gbrg"; 142const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12GRBG[] = "bayer-qcom-12grbg"; 143const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12RGGB[] = "bayer-qcom-12rggb"; 144const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12BGGR[] = "bayer-qcom-12bggr"; 145const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8GBRG[] = "bayer-mipi-8gbrg"; 146const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8GRBG[] = "bayer-mipi-8grbg"; 147const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8RGGB[] = "bayer-mipi-8rggb"; 148const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8BGGR[] = "bayer-mipi-8bggr"; 149const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10GBRG[] = "bayer-mipi-10gbrg"; 150const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10GRBG[] = "bayer-mipi-10grbg"; 151const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10RGGB[] = "bayer-mipi-10rggb"; 152const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10BGGR[] = "bayer-mipi-10bggr"; 153const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12GBRG[] = "bayer-mipi-12gbrg"; 154const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12GRBG[] = "bayer-mipi-12grbg"; 155const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12RGGB[] = "bayer-mipi-12rggb"; 156const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12BGGR[] = "bayer-mipi-12bggr"; 157const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8GBRG[] = "bayer-ideal-qcom-8gbrg"; 158const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8GRBG[] = "bayer-ideal-qcom-8grbg"; 159const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8RGGB[] = "bayer-ideal-qcom-8rggb"; 160const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8BGGR[] = "bayer-ideal-qcom-8bggr"; 161const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10GBRG[] = "bayer-ideal-qcom-10gbrg"; 162const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10GRBG[] = "bayer-ideal-qcom-10grbg"; 163const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10RGGB[] = "bayer-ideal-qcom-10rggb"; 164const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10BGGR[] = "bayer-ideal-qcom-10bggr"; 165const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12GBRG[] = "bayer-ideal-qcom-12gbrg"; 166const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12GRBG[] = "bayer-ideal-qcom-12grbg"; 167const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12RGGB[] = "bayer-ideal-qcom-12rggb"; 168const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12BGGR[] = "bayer-ideal-qcom-12bggr"; 169const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8GBRG[] = "bayer-ideal-mipi-8gbrg"; 170const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8GRBG[] = "bayer-ideal-mipi-8grbg"; 171const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8RGGB[] = "bayer-ideal-mipi-8rggb"; 172const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8BGGR[] = "bayer-ideal-mipi-8bggr"; 173const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10GBRG[] = "bayer-ideal-mipi-10gbrg"; 174const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10GRBG[] = "bayer-ideal-mipi-10grbg"; 175const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10RGGB[] = "bayer-ideal-mipi-10rggb"; 176const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10BGGR[] = "bayer-ideal-mipi-10bggr"; 177const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12GBRG[] = "bayer-ideal-mipi-12gbrg"; 178const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12GRBG[] = "bayer-ideal-mipi-12grbg"; 179const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12RGGB[] = "bayer-ideal-mipi-12rggb"; 180const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12BGGR[] = "bayer-ideal-mipi-12bggr"; 181const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8GBRG[] = "bayer-ideal-plain8-8gbrg"; 182const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8GRBG[] = "bayer-ideal-plain8-8grbg"; 183const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8RGGB[] = "bayer-ideal-plain8-8rggb"; 184const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8BGGR[] = "bayer-ideal-plain8-8bggr"; 185const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8GBRG[] = "bayer-ideal-plain16-8gbrg"; 186const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8GRBG[] = "bayer-ideal-plain16-8grbg"; 187const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8RGGB[] = "bayer-ideal-plain16-8rggb"; 188const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8BGGR[] = "bayer-ideal-plain16-8bggr"; 189const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10GBRG[] = "bayer-ideal-plain16-10gbrg"; 190const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10GRBG[] = "bayer-ideal-plain16-10grbg"; 191const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10RGGB[] = "bayer-ideal-plain16-10rggb"; 192const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10BGGR[] = "bayer-ideal-plain16-10bggr"; 193const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12GBRG[] = "bayer-ideal-plain16-12gbrg"; 194const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12GRBG[] = "bayer-ideal-plain16-12grbg"; 195const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12RGGB[] = "bayer-ideal-plain16-12rggb"; 196const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12BGGR[] = "bayer-ideal-plain16-12bggr"; 197 198// Values for ISO Settings 199const char QCameraParameters::ISO_AUTO[] = "auto"; 200const char QCameraParameters::ISO_HJR[] = "ISO_HJR"; 201const char QCameraParameters::ISO_100[] = "ISO100"; 202const char QCameraParameters::ISO_200[] = "ISO200"; 203const char QCameraParameters::ISO_400[] = "ISO400"; 204const char QCameraParameters::ISO_800[] = "ISO800"; 205const char QCameraParameters::ISO_1600[] = "ISO1600"; 206 207// Values for auto exposure settings. 208const char QCameraParameters::AUTO_EXPOSURE_FRAME_AVG[] = "frame-average"; 209const char QCameraParameters::AUTO_EXPOSURE_CENTER_WEIGHTED[] = "center-weighted"; 210const char QCameraParameters::AUTO_EXPOSURE_SPOT_METERING[] = "spot-metering"; 211const char QCameraParameters::AUTO_EXPOSURE_SMART_METERING[] = "smart-metering"; 212const char QCameraParameters::AUTO_EXPOSURE_USER_METERING[] = "user-metering"; 213const char QCameraParameters::AUTO_EXPOSURE_SPOT_METERING_ADV[] = "spot-metering-adv"; 214const char QCameraParameters::AUTO_EXPOSURE_CENTER_WEIGHTED_ADV[] = "center-weighted-adv"; 215 216const char QCameraParameters::KEY_QC_GPS_LATITUDE_REF[] = "gps-latitude-ref"; 217const char QCameraParameters::KEY_QC_GPS_LONGITUDE_REF[] = "gps-longitude-ref"; 218const char QCameraParameters::KEY_QC_GPS_ALTITUDE_REF[] = "gps-altitude-ref"; 219const char QCameraParameters::KEY_QC_GPS_STATUS[] = "gps-status"; 220 221const char QCameraParameters::KEY_QC_HISTOGRAM[] = "histogram"; 222const char QCameraParameters::KEY_QC_SUPPORTED_HISTOGRAM_MODES[] = "histogram-values"; 223 224const char QCameraParameters::VALUE_ENABLE[] = "enable"; 225const char QCameraParameters::VALUE_DISABLE[] = "disable"; 226const char QCameraParameters::VALUE_OFF[] = "off"; 227const char QCameraParameters::VALUE_ON[] = "on"; 228const char QCameraParameters::VALUE_TRUE[] = "true"; 229const char QCameraParameters::VALUE_FALSE[] = "false"; 230 231const char QCameraParameters::KEY_QC_SHARPNESS[] = "sharpness"; 232const char QCameraParameters::KEY_QC_MIN_SHARPNESS[] = "min-sharpness"; 233const char QCameraParameters::KEY_QC_MAX_SHARPNESS[] = "max-sharpness"; 234const char QCameraParameters::KEY_QC_SHARPNESS_STEP[] = "sharpness-step"; 235const char QCameraParameters::KEY_QC_CONTRAST[] = "contrast"; 236const char QCameraParameters::KEY_QC_MIN_CONTRAST[] = "min-contrast"; 237const char QCameraParameters::KEY_QC_MAX_CONTRAST[] = "max-contrast"; 238const char QCameraParameters::KEY_QC_CONTRAST_STEP[] = "contrast-step"; 239const char QCameraParameters::KEY_QC_SATURATION[] = "saturation"; 240const char QCameraParameters::KEY_QC_MIN_SATURATION[] = "min-saturation"; 241const char QCameraParameters::KEY_QC_MAX_SATURATION[] = "max-saturation"; 242const char QCameraParameters::KEY_QC_SATURATION_STEP[] = "saturation-step"; 243const char QCameraParameters::KEY_QC_BRIGHTNESS[] = "luma-adaptation"; 244const char QCameraParameters::KEY_QC_MIN_BRIGHTNESS[] = "min-brightness"; 245const char QCameraParameters::KEY_QC_MAX_BRIGHTNESS[] = "max-brightness"; 246const char QCameraParameters::KEY_QC_BRIGHTNESS_STEP[] = "brightness-step"; 247const char QCameraParameters::KEY_QC_SCE_FACTOR[] = "skinToneEnhancement"; 248const char QCameraParameters::KEY_QC_MIN_SCE_FACTOR[] = "min-sce-factor"; 249const char QCameraParameters::KEY_QC_MAX_SCE_FACTOR[] = "max-sce-factor"; 250const char QCameraParameters::KEY_QC_SCE_FACTOR_STEP[] = "sce-factor-step"; 251 252const char QCameraParameters::KEY_QC_SUPPORTED_CAMERA_FEATURES[] = "qc-camera-features"; 253const char QCameraParameters::KEY_QC_MAX_NUM_REQUESTED_FACES[] = "qc-max-num-requested-faces"; 254 255//Values for DENOISE 256const char QCameraParameters::DENOISE_OFF[] = "denoise-off"; 257const char QCameraParameters::DENOISE_ON[] = "denoise-on"; 258 259// Values for selectable zone af Settings 260const char QCameraParameters::FOCUS_ALGO_AUTO[] = "auto"; 261const char QCameraParameters::FOCUS_ALGO_SPOT_METERING[] = "spot-metering"; 262const char QCameraParameters::FOCUS_ALGO_CENTER_WEIGHTED[] = "center-weighted"; 263const char QCameraParameters::FOCUS_ALGO_FRAME_AVERAGE[] = "frame-average"; 264 265// Values for HFR settings. 266const char QCameraParameters::VIDEO_HFR_OFF[] = "off"; 267const char QCameraParameters::VIDEO_HFR_2X[] = "60"; 268const char QCameraParameters::VIDEO_HFR_3X[] = "90"; 269const char QCameraParameters::VIDEO_HFR_4X[] = "120"; 270const char QCameraParameters::VIDEO_HFR_5X[] = "150"; 271 272// Values for HDR Bracketing settings. 273const char QCameraParameters::AE_BRACKET_OFF[] = "Off"; 274const char QCameraParameters::AE_BRACKET[] = "AE-Bracket"; 275 276// Values for FLIP settings. 277const char QCameraParameters::FLIP_MODE_OFF[] = "off"; 278const char QCameraParameters::FLIP_MODE_V[] = "flip-v"; 279const char QCameraParameters::FLIP_MODE_H[] = "flip-h"; 280const char QCameraParameters::FLIP_MODE_VH[] = "flip-vh"; 281 282static const char* portrait = "portrait"; 283static const char* landscape = "landscape"; 284 285const cam_dimension_t QCameraParameters::THUMBNAIL_SIZES_MAP[] = { 286 { 512, 288 }, //1.777778 287 { 480, 288 }, //1.666667 288 { 256, 154 }, //1.66233 289 { 432, 288 }, //1.5 290 { 320, 240 }, //1.33333 291 { 176, 144 }, //1.222222 292 { 0, 0 } // required by Android SDK 293}; 294 295const QCameraParameters::QCameraMap QCameraParameters::AUTO_EXPOSURE_MAP[] = { 296 { AUTO_EXPOSURE_FRAME_AVG, CAM_AEC_MODE_FRAME_AVERAGE }, 297 { AUTO_EXPOSURE_CENTER_WEIGHTED, CAM_AEC_MODE_CENTER_WEIGHTED }, 298 { AUTO_EXPOSURE_SPOT_METERING, CAM_AEC_MODE_SPOT_METERING }, 299 { AUTO_EXPOSURE_SMART_METERING, CAM_AEC_MODE_SMART_METERING }, 300 { AUTO_EXPOSURE_USER_METERING, CAM_AEC_MODE_USER_METERING }, 301 { AUTO_EXPOSURE_SPOT_METERING_ADV, CAM_AEC_MODE_SPOT_METERING_ADV }, 302 { AUTO_EXPOSURE_CENTER_WEIGHTED_ADV, CAM_AEC_MODE_CENTER_WEIGHTED_ADV }, 303}; 304 305const QCameraParameters::QCameraMap QCameraParameters::PREVIEW_FORMATS_MAP[] = { 306 {PIXEL_FORMAT_YUV420SP, CAM_FORMAT_YUV_420_NV21}, 307 {PIXEL_FORMAT_YUV420P, CAM_FORMAT_YUV_420_YV12}, 308 {PIXEL_FORMAT_YUV420SP_ADRENO, CAM_FORMAT_YUV_420_NV21_ADRENO}, 309 {PIXEL_FORMAT_YV12, CAM_FORMAT_YUV_420_YV12}, 310 {PIXEL_FORMAT_NV12, CAM_FORMAT_YUV_420_NV12} 311}; 312 313const QCameraParameters::QCameraMap QCameraParameters::PICTURE_TYPES_MAP[] = { 314 {PIXEL_FORMAT_JPEG, CAM_FORMAT_JPEG}, 315 {PIXEL_FORMAT_YUV422SP, CAM_FORMAT_YUV_422_NV16}, 316 {QC_PIXEL_FORMAT_YUV_RAW_8BIT_YUYV, CAM_FORMAT_YUV_RAW_8BIT_YUYV}, 317 {QC_PIXEL_FORMAT_YUV_RAW_8BIT_YVYU, CAM_FORMAT_YUV_RAW_8BIT_YVYU}, 318 {QC_PIXEL_FORMAT_YUV_RAW_8BIT_UYVY, CAM_FORMAT_YUV_RAW_8BIT_UYVY}, 319 {QC_PIXEL_FORMAT_YUV_RAW_8BIT_VYUY, CAM_FORMAT_YUV_RAW_8BIT_VYUY}, 320 {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8GBRG, CAM_FORMAT_BAYER_QCOM_RAW_8BPP_GBRG}, 321 {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8GRBG, CAM_FORMAT_BAYER_QCOM_RAW_8BPP_GRBG}, 322 {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8RGGB, CAM_FORMAT_BAYER_QCOM_RAW_8BPP_RGGB}, 323 {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8BGGR, CAM_FORMAT_BAYER_QCOM_RAW_8BPP_BGGR}, 324 {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10GBRG, CAM_FORMAT_BAYER_QCOM_RAW_10BPP_GBRG}, 325 {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10GRBG, CAM_FORMAT_BAYER_QCOM_RAW_10BPP_GRBG}, 326 {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10RGGB, CAM_FORMAT_BAYER_QCOM_RAW_10BPP_RGGB}, 327 {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10BGGR, CAM_FORMAT_BAYER_QCOM_RAW_10BPP_BGGR}, 328 {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12GBRG, CAM_FORMAT_BAYER_QCOM_RAW_12BPP_GBRG}, 329 {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12GRBG, CAM_FORMAT_BAYER_QCOM_RAW_12BPP_GRBG}, 330 {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12RGGB, CAM_FORMAT_BAYER_QCOM_RAW_12BPP_RGGB}, 331 {QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12BGGR, CAM_FORMAT_BAYER_QCOM_RAW_12BPP_BGGR}, 332 {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8GBRG, CAM_FORMAT_BAYER_MIPI_RAW_8BPP_GBRG}, 333 {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8GRBG, CAM_FORMAT_BAYER_MIPI_RAW_8BPP_GRBG}, 334 {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8RGGB, CAM_FORMAT_BAYER_MIPI_RAW_8BPP_RGGB}, 335 {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8BGGR, CAM_FORMAT_BAYER_MIPI_RAW_8BPP_BGGR}, 336 {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10GBRG, CAM_FORMAT_BAYER_MIPI_RAW_10BPP_GBRG}, 337 {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10GRBG, CAM_FORMAT_BAYER_MIPI_RAW_10BPP_GRBG}, 338 {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10RGGB, CAM_FORMAT_BAYER_MIPI_RAW_10BPP_RGGB}, 339 {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10BGGR, CAM_FORMAT_BAYER_MIPI_RAW_10BPP_BGGR}, 340 {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12GBRG, CAM_FORMAT_BAYER_MIPI_RAW_12BPP_GBRG}, 341 {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12GRBG, CAM_FORMAT_BAYER_MIPI_RAW_12BPP_GRBG}, 342 {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12RGGB, CAM_FORMAT_BAYER_MIPI_RAW_12BPP_RGGB}, 343 {QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12BGGR, CAM_FORMAT_BAYER_MIPI_RAW_12BPP_BGGR}, 344 {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_GBRG}, 345 {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_GRBG}, 346 {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_RGGB}, 347 {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_BGGR}, 348 {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_GBRG}, 349 {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_GRBG}, 350 {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_RGGB}, 351 {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_BGGR}, 352 {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_GBRG}, 353 {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_GRBG}, 354 {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_RGGB}, 355 {QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_BGGR}, 356 {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_GBRG}, 357 {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_GRBG}, 358 {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_RGGB}, 359 {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_BGGR}, 360 {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_GBRG}, 361 {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_GRBG}, 362 {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_RGGB}, 363 {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_BGGR}, 364 {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_GBRG}, 365 {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_GRBG}, 366 {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_RGGB}, 367 {QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_BGGR}, 368 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_GBRG}, 369 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_GRBG}, 370 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_RGGB}, 371 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_BGGR}, 372 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_GBRG}, 373 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_GRBG}, 374 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_RGGB}, 375 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_BGGR}, 376 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_GBRG}, 377 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_GRBG}, 378 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_RGGB}, 379 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_BGGR}, 380 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_GBRG}, 381 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_GRBG}, 382 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_RGGB}, 383 {QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_BGGR} 384}; 385 386const QCameraParameters::QCameraMap QCameraParameters::RAW_FORMATS_MAP[] = { 387}; 388 389const QCameraParameters::QCameraMap QCameraParameters::FOCUS_MODES_MAP[] = { 390 { FOCUS_MODE_AUTO, CAM_FOCUS_MODE_AUTO }, 391 { FOCUS_MODE_INFINITY, CAM_FOCUS_MODE_INFINITY }, 392 { FOCUS_MODE_MACRO, CAM_FOCUS_MODE_MACRO }, 393 { FOCUS_MODE_FIXED, CAM_FOCUS_MODE_FIXED }, 394 { FOCUS_MODE_EDOF, CAM_FOCUS_MODE_EDOF }, 395 { FOCUS_MODE_CONTINUOUS_PICTURE, CAM_FOCUS_MODE_CONTINOUS_PICTURE }, 396 { FOCUS_MODE_CONTINUOUS_VIDEO, CAM_FOCUS_MODE_CONTINOUS_VIDEO } 397}; 398 399const QCameraParameters::QCameraMap QCameraParameters::EFFECT_MODES_MAP[] = { 400 { EFFECT_NONE, CAM_EFFECT_MODE_OFF }, 401 { EFFECT_MONO, CAM_EFFECT_MODE_MONO }, 402 { EFFECT_NEGATIVE, CAM_EFFECT_MODE_NEGATIVE }, 403 { EFFECT_SOLARIZE, CAM_EFFECT_MODE_SOLARIZE }, 404 { EFFECT_SEPIA, CAM_EFFECT_MODE_SEPIA }, 405 { EFFECT_POSTERIZE, CAM_EFFECT_MODE_POSTERIZE }, 406 { EFFECT_WHITEBOARD, CAM_EFFECT_MODE_WHITEBOARD }, 407 { EFFECT_BLACKBOARD, CAM_EFFECT_MODE_BLACKBOARD }, 408 { EFFECT_AQUA, CAM_EFFECT_MODE_AQUA }, 409 { EFFECT_EMBOSS, CAM_EFFECT_MODE_EMBOSS }, 410 { EFFECT_SKETCH, CAM_EFFECT_MODE_SKETCH }, 411 { EFFECT_NEON, CAM_EFFECT_MODE_NEON } 412}; 413 414const QCameraParameters::QCameraMap QCameraParameters::SCENE_MODES_MAP[] = { 415 { SCENE_MODE_AUTO, CAM_SCENE_MODE_OFF }, 416 { SCENE_MODE_ACTION, CAM_SCENE_MODE_ACTION }, 417 { SCENE_MODE_PORTRAIT, CAM_SCENE_MODE_PORTRAIT }, 418 { SCENE_MODE_LANDSCAPE, CAM_SCENE_MODE_LANDSCAPE }, 419 { SCENE_MODE_NIGHT, CAM_SCENE_MODE_NIGHT }, 420 { SCENE_MODE_NIGHT_PORTRAIT, CAM_SCENE_MODE_NIGHT_PORTRAIT }, 421 { SCENE_MODE_THEATRE, CAM_SCENE_MODE_THEATRE }, 422 { SCENE_MODE_BEACH, CAM_SCENE_MODE_BEACH }, 423 { SCENE_MODE_SNOW, CAM_SCENE_MODE_SNOW }, 424 { SCENE_MODE_SUNSET, CAM_SCENE_MODE_SUNSET }, 425 { SCENE_MODE_STEADYPHOTO, CAM_SCENE_MODE_ANTISHAKE }, 426 { SCENE_MODE_FIREWORKS , CAM_SCENE_MODE_FIREWORKS }, 427 { SCENE_MODE_SPORTS , CAM_SCENE_MODE_SPORTS }, 428 { SCENE_MODE_PARTY, CAM_SCENE_MODE_PARTY }, 429 { SCENE_MODE_CANDLELIGHT, CAM_SCENE_MODE_CANDLELIGHT }, 430 { SCENE_MODE_ASD, CAM_SCENE_MODE_AUTO }, 431 { SCENE_MODE_BACKLIGHT, CAM_SCENE_MODE_BACKLIGHT }, 432 { SCENE_MODE_FLOWERS, CAM_SCENE_MODE_FLOWERS }, 433 { SCENE_MODE_AR, CAM_SCENE_MODE_AR }, 434 { SCENE_MODE_HDR, CAM_SCENE_MODE_OFF }, 435}; 436 437const QCameraParameters::QCameraMap QCameraParameters::FLASH_MODES_MAP[] = { 438 { FLASH_MODE_OFF, CAM_FLASH_MODE_OFF }, 439 { FLASH_MODE_AUTO, CAM_FLASH_MODE_AUTO }, 440 { FLASH_MODE_ON, CAM_FLASH_MODE_ON }, 441 { FLASH_MODE_TORCH, CAM_FLASH_MODE_TORCH } 442}; 443 444const QCameraParameters::QCameraMap QCameraParameters::FOCUS_ALGO_MAP[] = { 445 { FOCUS_ALGO_AUTO, CAM_FOCUS_ALGO_AUTO }, 446 { FOCUS_ALGO_SPOT_METERING, CAM_FOCUS_ALGO_SPOT }, 447 { FOCUS_ALGO_CENTER_WEIGHTED, CAM_FOCUS_ALGO_CENTER_WEIGHTED }, 448 { FOCUS_ALGO_FRAME_AVERAGE, CAM_FOCUS_ALGO_AVERAGE } 449}; 450 451const QCameraParameters::QCameraMap QCameraParameters::WHITE_BALANCE_MODES_MAP[] = { 452 { WHITE_BALANCE_AUTO, CAM_WB_MODE_AUTO }, 453 { WHITE_BALANCE_INCANDESCENT, CAM_WB_MODE_INCANDESCENT }, 454 { WHITE_BALANCE_FLUORESCENT, CAM_WB_MODE_FLUORESCENT }, 455 { WHITE_BALANCE_WARM_FLUORESCENT,CAM_WB_MODE_WARM_FLUORESCENT}, 456 { WHITE_BALANCE_DAYLIGHT, CAM_WB_MODE_DAYLIGHT }, 457 { WHITE_BALANCE_CLOUDY_DAYLIGHT, CAM_WB_MODE_CLOUDY_DAYLIGHT }, 458 { WHITE_BALANCE_TWILIGHT, CAM_WB_MODE_TWILIGHT }, 459 { WHITE_BALANCE_SHADE, CAM_WB_MODE_SHADE } 460}; 461 462const QCameraParameters::QCameraMap QCameraParameters::ANTIBANDING_MODES_MAP[] = { 463 { ANTIBANDING_OFF, CAM_ANTIBANDING_MODE_OFF }, 464 { ANTIBANDING_50HZ, CAM_ANTIBANDING_MODE_50HZ }, 465 { ANTIBANDING_60HZ, CAM_ANTIBANDING_MODE_60HZ }, 466 { ANTIBANDING_AUTO, CAM_ANTIBANDING_MODE_AUTO } 467}; 468 469const QCameraParameters::QCameraMap QCameraParameters::ISO_MODES_MAP[] = { 470 { ISO_AUTO, CAM_ISO_MODE_AUTO }, 471 { ISO_HJR, CAM_ISO_MODE_DEBLUR }, 472 { ISO_100, CAM_ISO_MODE_100 }, 473 { ISO_200, CAM_ISO_MODE_200 }, 474 { ISO_400, CAM_ISO_MODE_400 }, 475 { ISO_800, CAM_ISO_MODE_800 }, 476 { ISO_1600, CAM_ISO_MODE_1600 } 477}; 478 479const QCameraParameters::QCameraMap QCameraParameters::HFR_MODES_MAP[] = { 480 { VIDEO_HFR_OFF, CAM_HFR_MODE_OFF }, 481 { VIDEO_HFR_2X, CAM_HFR_MODE_60FPS }, 482 { VIDEO_HFR_3X, CAM_HFR_MODE_90FPS }, 483 { VIDEO_HFR_4X, CAM_HFR_MODE_120FPS }, 484 { VIDEO_HFR_5X, CAM_HFR_MODE_150FPS } 485}; 486 487const QCameraParameters::QCameraMap QCameraParameters::BRACKETING_MODES_MAP[] = { 488 { AE_BRACKET_OFF, CAM_EXP_BRACKETING_OFF }, 489 { AE_BRACKET, CAM_EXP_BRACKETING_ON } 490}; 491 492const QCameraParameters::QCameraMap QCameraParameters::ON_OFF_MODES_MAP[] = { 493 { VALUE_OFF, 0 }, 494 { VALUE_ON, 1 } 495}; 496 497const QCameraParameters::QCameraMap QCameraParameters::TOUCH_AF_AEC_MODES_MAP[] = { 498 { QCameraParameters::TOUCH_AF_AEC_OFF, 0 }, 499 { QCameraParameters::TOUCH_AF_AEC_ON, 1 } 500}; 501 502const QCameraParameters::QCameraMap QCameraParameters::ENABLE_DISABLE_MODES_MAP[] = { 503 { VALUE_ENABLE, 1 }, 504 { VALUE_DISABLE, 0 } 505}; 506 507const QCameraParameters::QCameraMap QCameraParameters::DENOISE_ON_OFF_MODES_MAP[] = { 508 { DENOISE_OFF, 0 }, 509 { DENOISE_ON, 1 } 510}; 511 512const QCameraParameters::QCameraMap QCameraParameters::TRUE_FALSE_MODES_MAP[] = { 513 { VALUE_FALSE, 0}, 514 { VALUE_TRUE, 1} 515}; 516 517const QCameraParameters::QCameraMap QCameraParameters::FLIP_MODES_MAP[] = { 518 {FLIP_MODE_OFF, 0}, 519 {FLIP_MODE_V, FLIP_V}, 520 {FLIP_MODE_H, FLIP_H}, 521 {FLIP_MODE_VH, FLIP_V_H} 522}; 523 524#define DEFAULT_CAMERA_AREA "(0, 0, 0, 0, 0)" 525#define DATA_PTR(MEM_OBJ,INDEX) MEM_OBJ->getPtr( INDEX ) 526 527/*=========================================================================== 528 * FUNCTION : QCameraParameters 529 * 530 * DESCRIPTION: default constructor of QCameraParameters 531 * 532 * PARAMETERS : none 533 * 534 * RETURN : None 535 *==========================================================================*/ 536QCameraParameters::QCameraParameters() 537 : CameraParameters(), 538 m_pCapability(NULL), 539 m_pCamOpsTbl(NULL), 540 m_pParamHeap(NULL), 541 m_pParamBuf(NULL), 542 m_bZslMode(false), 543 m_bRecordingHint(false), 544 m_bHistogramEnabled(false), 545 m_nFaceProcMask(0), 546 m_bDebugFps(false), 547 mFocusMode(CAM_FOCUS_MODE_MAX), 548 mPreviewFormat(CAM_FORMAT_YUV_420_NV21), 549 mPictureFormat(CAM_FORMAT_JPEG), 550 m_bNeedRestart(false), 551 m_bNoDisplayMode(false), 552 m_bWNROn(false), 553 m_bNeedLockCAF(false), 554 m_bCAFLocked(false), 555 m_bAFRunning(false), 556 m_tempMap() 557{ 558 char value[32]; 559 // TODO: may move to parameter instead of sysprop 560 property_get("persist.debug.sf.showfps", value, "0"); 561 m_bDebugFps = atoi(value) > 0 ? true : false; 562 563 // For thermal mode, it should be set as system property 564 // because system property applies to all applications, while 565 // parameters only apply to specific app. 566 property_get("persist.camera.thermal.mode", value, "fps"); 567 if (!strcmp(value, "frameskip")) { 568 m_ThermalMode = QCAMERA_THERMAL_ADJUST_FRAMESKIP; 569 } else { 570 if (strcmp(value, "fps")) 571 ALOGE("%s: Invalid camera thermal mode %s", __func__, value); 572 m_ThermalMode = QCAMERA_THERMAL_ADJUST_FPS; 573 } 574 575 memset(&m_LiveSnapshotSize, 0, sizeof(m_LiveSnapshotSize)); 576} 577 578/*=========================================================================== 579 * FUNCTION : QCameraParameters 580 * 581 * DESCRIPTION: constructor of QCameraParameters 582 * 583 * PARAMETERS : 584 * @params : parameters in string 585 * 586 * RETURN : None 587 *==========================================================================*/ 588QCameraParameters::QCameraParameters(const String8 ¶ms) 589 : CameraParameters(params), 590 m_pCapability(NULL), 591 m_pCamOpsTbl(NULL), 592 m_pParamHeap(NULL), 593 m_pParamBuf(NULL), 594 m_bZslMode(false), 595 m_bRecordingHint(false), 596 m_bHistogramEnabled(false), 597 m_nFaceProcMask(0), 598 m_bDebugFps(false), 599 mFocusMode(CAM_FOCUS_MODE_MAX), 600 mPreviewFormat(CAM_FORMAT_YUV_420_NV21), 601 mPictureFormat(CAM_FORMAT_JPEG), 602 m_bNeedRestart(false), 603 m_bNoDisplayMode(false), 604 m_bWNROn(false), 605 m_bNeedLockCAF(false), 606 m_bCAFLocked(false), 607 m_bAFRunning(false), 608 m_tempMap() 609{ 610 memset(&m_LiveSnapshotSize, 0, sizeof(m_LiveSnapshotSize)); 611} 612 613/*=========================================================================== 614 * FUNCTION : ~QCameraParameters 615 * 616 * DESCRIPTION: deconstructor of QCameraParameters 617 * 618 * PARAMETERS : none 619 * 620 * RETURN : None 621 *==========================================================================*/ 622QCameraParameters::~QCameraParameters() 623{ 624 deinit(); 625} 626 627/*=========================================================================== 628 * FUNCTION : createSizesString 629 * 630 * DESCRIPTION: create string obj contains array of dimensions 631 * 632 * PARAMETERS : 633 * @sizes : array of dimensions 634 * @len : size of dimension array 635 * 636 * RETURN : string obj 637 *==========================================================================*/ 638String8 QCameraParameters::createSizesString(const cam_dimension_t *sizes, int len) 639{ 640 String8 str; 641 char buffer[32]; 642 643 if (len > 0) { 644 snprintf(buffer, sizeof(buffer), "%dx%d", sizes[0].width, sizes[0].height); 645 str.append(buffer); 646 } 647 for (int i = 1; i < len; i++) { 648 snprintf(buffer, sizeof(buffer), ",%dx%d", sizes[i].width, sizes[i].height); 649 str.append(buffer); 650 } 651 return str; 652} 653 654/*=========================================================================== 655 * FUNCTION : createValuesString 656 * 657 * DESCRIPTION: create string obj contains array of values from map when matched 658 * from input values array 659 * 660 * PARAMETERS : 661 * @values : array of values 662 * @len : size of values array 663 * @map : map contains the mapping between values and enums 664 * @map_len : size of the map 665 * 666 * RETURN : string obj 667 *==========================================================================*/ 668String8 QCameraParameters::createValuesString(const int *values, 669 int len, 670 const QCameraMap* map, 671 int map_len) 672{ 673 String8 str; 674 int count = 0; 675 676 for (int i = 0; i < len; i++ ) { 677 for (int j = 0; j < map_len; j ++) 678 if (map[j].val == values[i]) { 679 if (NULL != map[j].desc) { 680 if (count > 0) { 681 str.append(","); 682 } 683 str.append(map[j].desc); 684 count++; 685 break; //loop j 686 } 687 } 688 } 689 return str; 690} 691 692/*=========================================================================== 693 * FUNCTION : createValuesStringFromMap 694 * 695 * DESCRIPTION: create string obj contains array of values directly from map 696 * 697 * PARAMETERS : 698 * @map : map contains the mapping between values and enums 699 * @map_len : size of the map 700 * 701 * RETURN : string obj 702 *==========================================================================*/ 703String8 QCameraParameters::createValuesStringFromMap(const QCameraMap* map, 704 int map_len) 705{ 706 String8 str; 707 708 for (int i = 0; i < map_len; i++) { 709 if (NULL != map[i].desc) { 710 if (i > 0) { 711 str.append(","); 712 } 713 str.append(map[i].desc); 714 } 715 } 716 return str; 717} 718 719/*=========================================================================== 720 * FUNCTION : createZoomRatioValuesString 721 * 722 * DESCRIPTION: create string obj contains array of zoom ratio values 723 * 724 * PARAMETERS : 725 * @zoomRaios : array of zoom ratios 726 * @length : size of the array 727 * 728 * RETURN : string obj 729 *==========================================================================*/ 730String8 QCameraParameters::createZoomRatioValuesString(int *zoomRatios, int length) 731{ 732 String8 str; 733 char buffer[32] = {0}; 734 735 if(length > 0){ 736 snprintf(buffer, sizeof(buffer), "%d", zoomRatios[0]); 737 str.append(buffer); 738 } 739 740 for (int i =1;i<length;i++){ 741 memset(buffer, 0, sizeof(buffer)); 742 snprintf(buffer, sizeof(buffer), ",%d", zoomRatios[i]); 743 str.append(buffer); 744 } 745 return str; 746} 747 748/*=========================================================================== 749 * FUNCTION : createHfrValuesString 750 * 751 * DESCRIPTION: create string obj contains array of hfr values from map when 752 * matched from input hfr values 753 * 754 * PARAMETERS : 755 * @values : array of hfr info 756 * @len : size of the array 757 * @map : map of hfr string value and enum 758 * map_len : size of map 759 * 760 * RETURN : string obj 761 *==========================================================================*/ 762String8 QCameraParameters::createHfrValuesString( 763 const cam_hfr_info_t *values, 764 int len, 765 const QCameraMap* map, 766 int map_len) 767{ 768 String8 str; 769 int count = 0; 770 771 for (int i = 0; i < len; i++ ) { 772 for (int j = 0; j < map_len; j ++) 773 if (map[j].val == (int)values[i].mode) { 774 if (NULL != map[j].desc) { 775 if (count > 0) { 776 str.append(","); 777 } 778 str.append(map[j].desc); 779 count++; 780 break; //loop j 781 } 782 } 783 } 784 return str; 785} 786 787/*=========================================================================== 788 * FUNCTION : createHfrSizesString 789 * 790 * DESCRIPTION: create string obj contains array of hfr sizes 791 * 792 * PARAMETERS : 793 * @values : array of hfr info 794 * @len : size of the array 795 * 796 * RETURN : string obj 797 *==========================================================================*/ 798String8 QCameraParameters::createHfrSizesString( 799 const cam_hfr_info_t *values, 800 int len) 801{ 802 String8 str; 803 char buffer[32]; 804 805 if (len > 0) { 806 snprintf(buffer, sizeof(buffer), "%dx%d", 807 values[0].dim.width, values[0].dim.height); 808 str.append(buffer); 809 } 810 for (int i = 1; i < len; i++) { 811 snprintf(buffer, sizeof(buffer), ",%dx%d", 812 values[i].dim.width, values[i].dim.height); 813 str.append(buffer); 814 } 815 return str; 816} 817 818/*=========================================================================== 819 * FUNCTION : createFpsString 820 * 821 * DESCRIPTION: create string obj contains array of FPS rates 822 * 823 * PARAMETERS : 824 * @fps : array of fps ranges 825 * @len : size of the array 826 * 827 * RETURN : string obj 828 *==========================================================================*/ 829String8 QCameraParameters::createFpsString(const cam_fps_range_t *fps, int len) 830{ 831 String8 str; 832 char buffer[32]; 833 834 for (int i = 0; i < len; i++ ) { 835 snprintf(buffer, sizeof(buffer), "%d", int(fps[i].max_fps * 1000)); 836 str.append(buffer); 837 if (i < len-1) 838 str.append(","); 839 } 840 return str; 841} 842 843/*=========================================================================== 844 * FUNCTION : createFpsRangeString 845 * 846 * DESCRIPTION: create string obj contains array of FPS ranges 847 * 848 * PARAMETERS : 849 * @fps : array of fps ranges 850 * @len : size of the array 851 * @default_fps_index : reference to index of default fps range 852 * 853 * RETURN : string obj 854 *==========================================================================*/ 855String8 QCameraParameters::createFpsRangeString(const cam_fps_range_t* fps, 856 int len, 857 int &default_fps_index) 858{ 859 String8 str; 860 char buffer[32]; 861 int max_range = 0; 862 int min_fps, max_fps; 863 864 if (len > 0) { 865 min_fps = int(fps[0].min_fps * 1000); 866 max_fps = int(fps[0].max_fps * 1000); 867 max_range = max_fps - min_fps; 868 default_fps_index = 0; 869 snprintf(buffer, sizeof(buffer), "(%d,%d)", min_fps, max_fps); 870 str.append(buffer); 871 } 872 for (int i = 1; i < len; i++) { 873 min_fps = int(fps[i].min_fps * 1000); 874 max_fps = int(fps[i].max_fps * 1000); 875 if (max_range < (max_fps - min_fps)) { 876 max_range = max_fps - min_fps; 877 default_fps_index = i; 878 } 879 snprintf(buffer, sizeof(buffer), ",(%d,%d)", min_fps, max_fps); 880 str.append(buffer); 881 } 882 return str; 883} 884 885/*=========================================================================== 886 * FUNCTION : lookupAttr 887 * 888 * DESCRIPTION: lookup a value by its name 889 * 890 * PARAMETERS : 891 * @attr : map contains <name, value> 892 * @len : size of the map 893 * @name : name to be looked up 894 * 895 * RETURN : valid value if found 896 * NAME_NOT_FOUND if not found 897 *==========================================================================*/ 898int QCameraParameters::lookupAttr(const QCameraMap arr[], int len, const char *name) 899{ 900 if (name) { 901 for (int i = 0; i < len; i++) { 902 if (!strcmp(arr[i].desc, name)) 903 return arr[i].val; 904 } 905 } 906 return NAME_NOT_FOUND; 907} 908 909/*=========================================================================== 910 * FUNCTION : lookupNameByValue 911 * 912 * DESCRIPTION: lookup a name by its value 913 * 914 * PARAMETERS : 915 * @attr : map contains <name, value> 916 * @len : size of the map 917 * @value : value to be looked up 918 * 919 * RETURN : name str or NULL if not found 920 *==========================================================================*/ 921const char *QCameraParameters::lookupNameByValue(const QCameraMap arr[], int len, int value) 922{ 923 for (int i = 0; i < len; i++) { 924 if (arr[i].val == value) { 925 return arr[i].desc; 926 } 927 } 928 return NULL; 929} 930 931/*=========================================================================== 932 * FUNCTION : setPreviewSize 933 * 934 * DESCRIPTION: set preview size from user setting 935 * 936 * PARAMETERS : 937 * @params : user setting parameters 938 * 939 * RETURN : int32_t type of status 940 * NO_ERROR -- success 941 * none-zero failure code 942 *==========================================================================*/ 943int32_t QCameraParameters::setPreviewSize(const QCameraParameters& params) 944{ 945 int width, height; 946 params.getPreviewSize(&width, &height); 947 ALOGV("Requested preview size %d x %d", width, height); 948 949 // Validate the preview size 950 for (size_t i = 0; i < m_pCapability->preview_sizes_tbl_cnt; ++i) { 951 if (width == m_pCapability->preview_sizes_tbl[i].width 952 && height == m_pCapability->preview_sizes_tbl[i].height) { 953 // check if need to restart preview in case of preview size change 954 int old_width, old_height; 955 CameraParameters::getPreviewSize(&old_width, &old_height); 956 if (width != old_width || height != old_height) { 957 m_bNeedRestart = true; 958 } 959 960 // set the new value 961 char val[32]; 962 sprintf(val, "%dx%d", width, height); 963 updateParamEntry(KEY_PREVIEW_SIZE, val); 964 ALOGV("%s: %s", __func__, val); 965 return NO_ERROR; 966 } 967 } 968 ALOGE("Invalid preview size requested: %dx%d", width, height); 969 return BAD_VALUE; 970} 971 972/*=========================================================================== 973 * FUNCTION : setPictureSize 974 * 975 * DESCRIPTION: set picture size from user setting 976 * 977 * PARAMETERS : 978 * @params : user setting parameters 979 * 980 * RETURN : int32_t type of status 981 * NO_ERROR -- success 982 * none-zero failure code 983 *==========================================================================*/ 984int32_t QCameraParameters::setPictureSize(const QCameraParameters& params) 985{ 986 int width, height; 987 params.getPictureSize(&width, &height); 988 ALOGV("Requested picture size %d x %d", width, height); 989 990 // Validate the picture size 991 for (size_t i = 0; i < m_pCapability->picture_sizes_tbl_cnt; ++i) { 992 if (width == m_pCapability->picture_sizes_tbl[i].width 993 && height == m_pCapability->picture_sizes_tbl[i].height) { 994 // check if need to restart preview in case of picture size change 995 int old_width, old_height; 996 CameraParameters::getPictureSize(&old_width, &old_height); 997 if ((m_bZslMode || m_bRecordingHint) && 998 (width != old_width || height != old_height)) { 999 m_bNeedRestart = true; 1000 } 1001 1002 // set the new value 1003 char val[32]; 1004 sprintf(val, "%dx%d", width, height); 1005 updateParamEntry(KEY_PICTURE_SIZE, val); 1006 ALOGV("%s: %s", __func__, val); 1007 return NO_ERROR; 1008 } 1009 } 1010 ALOGE("Invalid picture size requested: %dx%d", width, height); 1011 return BAD_VALUE; 1012} 1013 1014/*=========================================================================== 1015 * FUNCTION : setVideoSize 1016 * 1017 * DESCRIPTION: set video size from user setting 1018 * 1019 * PARAMETERS : 1020 * @params : user setting parameters 1021 * 1022 * RETURN : int32_t type of status 1023 * NO_ERROR -- success 1024 * none-zero failure code 1025 *==========================================================================*/ 1026int32_t QCameraParameters::setVideoSize(const QCameraParameters& params) 1027{ 1028 const char *str= NULL; 1029 int width, height; 1030 str = params.get(KEY_VIDEO_SIZE); 1031 if(!str) { 1032 //If application didn't set this parameter string, use the values from 1033 //getPreviewSize() as video dimensions. 1034 params.getPreviewSize(&width, &height); 1035 ALOGE("No Record Size requested, use the preview dimensions"); 1036 } else { 1037 params.getVideoSize(&width, &height); 1038 } 1039 1040 // Validate the video size 1041 for (size_t i = 0; i < m_pCapability->video_sizes_tbl_cnt; ++i) { 1042 if (width == m_pCapability->video_sizes_tbl[i].width 1043 && height == m_pCapability->video_sizes_tbl[i].height) { 1044 // check if need to restart preview in case of video size change 1045 int old_width, old_height; 1046 CameraParameters::getVideoSize(&old_width, &old_height); 1047 if (m_bRecordingHint && 1048 (width != old_width || height != old_height)) { 1049 m_bNeedRestart = true; 1050 } 1051 1052 // set the new value 1053 char val[32]; 1054 sprintf(val, "%dx%d", width, height); 1055 updateParamEntry(KEY_VIDEO_SIZE, val); 1056 ALOGV("%s: %s", __func__, val); 1057 return NO_ERROR; 1058 } 1059 } 1060 1061 ALOGE("Invalid video size requested: %dx%d", width, height); 1062 return BAD_VALUE; 1063} 1064 1065/*=========================================================================== 1066 * FUNCTION : setLiveSnapshotSize 1067 * 1068 * DESCRIPTION: set live snapshot size 1069 * 1070 * PARAMETERS : 1071 * @params : user setting parameters 1072 * 1073 * RETURN : int32_t type of status 1074 * NO_ERROR -- success 1075 * none-zero failure code 1076 *==========================================================================*/ 1077int32_t QCameraParameters::setLiveSnapshotSize(const QCameraParameters& params) 1078{ 1079 char value[32]; 1080 property_get("persist.camera.opt.livepic", value, "1"); 1081 bool useOptimal = atoi(value) > 0 ? true : false; 1082 1083 // use picture size from user setting 1084 params.getPictureSize(&m_LiveSnapshotSize.width, &m_LiveSnapshotSize.height); 1085 1086 uint8_t livesnapshot_sizes_tbl_cnt = m_pCapability->livesnapshot_sizes_tbl_cnt; 1087 cam_dimension_t *livesnapshot_sizes_tbl = &m_pCapability->livesnapshot_sizes_tbl[0]; 1088 1089 // check if HFR is enabled 1090 const char *hfrStr = params.get(KEY_QC_VIDEO_HIGH_FRAME_RATE); 1091 cam_hfr_mode_t hfrMode = CAM_HFR_MODE_OFF; 1092 if (hfrStr != NULL) { 1093 int32_t value = lookupAttr(HFR_MODES_MAP, 1094 sizeof(HFR_MODES_MAP)/sizeof(QCameraMap), 1095 hfrStr); 1096 if (value != NAME_NOT_FOUND) { 1097 // if HFR is enabled, change live snapshot size 1098 if (value > CAM_HFR_MODE_OFF) { 1099 for (int i = 0; i < m_pCapability->hfr_tbl_cnt; i++) { 1100 if (m_pCapability->hfr_tbl[i].mode == value) { 1101 livesnapshot_sizes_tbl_cnt = 1102 m_pCapability->hfr_tbl[i].livesnapshot_sizes_tbl_cnt; 1103 livesnapshot_sizes_tbl = 1104 &m_pCapability->hfr_tbl[i].livesnapshot_sizes_tbl[0]; 1105 hfrMode = m_pCapability->hfr_tbl[i].mode; 1106 break; 1107 } 1108 } 1109 } 1110 } 1111 } 1112 1113 if (useOptimal || hfrMode != CAM_HFR_MODE_OFF) { 1114 bool found = false; 1115 1116 // first check if picture size is within the list of supported sizes 1117 for (int i = 0; i < livesnapshot_sizes_tbl_cnt; ++i) { 1118 if (m_LiveSnapshotSize.width == livesnapshot_sizes_tbl[i].width && 1119 m_LiveSnapshotSize.height == livesnapshot_sizes_tbl[i].height) { 1120 found = true; 1121 break; 1122 } 1123 } 1124 1125 if (!found) { 1126 // use optimal live snapshot size from supported list, 1127 // that has same preview aspect ratio 1128 int width = 0, height = 0; 1129 params.getPreviewSize(&width, &height); 1130 1131 double previewAspectRatio = (double)width / height; 1132 for (int i = 0; i < livesnapshot_sizes_tbl_cnt; ++i) { 1133 double ratio = (double)livesnapshot_sizes_tbl[i].width / 1134 livesnapshot_sizes_tbl[i].height; 1135 if (fabs(previewAspectRatio - ratio) <= ASPECT_TOLERANCE) { 1136 m_LiveSnapshotSize = livesnapshot_sizes_tbl[i]; 1137 found = true; 1138 break; 1139 } 1140 } 1141 1142 if (!found && hfrMode != CAM_HFR_MODE_OFF) { 1143 // Cannot find matching aspect ration from supported live snapshot list 1144 // choose the max dim from preview and video size 1145 ALOGI("%s: Cannot find matching aspect ratio, choose max of preview or video size", __func__); 1146 params.getVideoSize(&m_LiveSnapshotSize.width, &m_LiveSnapshotSize.height); 1147 if (m_LiveSnapshotSize.width < width && m_LiveSnapshotSize.height < height) { 1148 m_LiveSnapshotSize.width = width; 1149 m_LiveSnapshotSize.height = height; 1150 } 1151 } 1152 } 1153 } 1154 ALOGI("%s: live snapshot size %d x %d", __func__, 1155 m_LiveSnapshotSize.width, m_LiveSnapshotSize.height); 1156 1157 return NO_ERROR; 1158} 1159 1160/*=========================================================================== 1161 * FUNCTION : setPreviewFormat 1162 * 1163 * DESCRIPTION: set preview format from user setting 1164 * 1165 * PARAMETERS : 1166 * @params : user setting parameters 1167 * 1168 * RETURN : int32_t type of status 1169 * NO_ERROR -- success 1170 * none-zero failure code 1171 *==========================================================================*/ 1172int32_t QCameraParameters::setPreviewFormat(const QCameraParameters& params) 1173{ 1174 const char *str = params.getPreviewFormat(); 1175 int32_t previewFormat = 1176 lookupAttr(PREVIEW_FORMATS_MAP, 1177 sizeof(PREVIEW_FORMATS_MAP) / sizeof(QCameraMap), 1178 str); 1179 if (previewFormat != NAME_NOT_FOUND) { 1180 mPreviewFormat = (cam_format_t)previewFormat; 1181 1182 updateParamEntry(KEY_PREVIEW_FORMAT, str); 1183 ALOGV("%s: format %d\n", __func__, mPreviewFormat); 1184 return NO_ERROR; 1185 } 1186 ALOGE("Invalid preview format value: %s", (str == NULL) ? "NULL" : str); 1187 return BAD_VALUE; 1188} 1189 1190/*=========================================================================== 1191 * FUNCTION : setPictureFormat 1192 * 1193 * DESCRIPTION: set picture format from user setting 1194 * 1195 * PARAMETERS : 1196 * @params : user setting parameters 1197 * 1198 * RETURN : int32_t type of status 1199 * NO_ERROR -- success 1200 * none-zero failure code 1201 *==========================================================================*/ 1202int32_t QCameraParameters::setPictureFormat(const QCameraParameters& params) 1203{ 1204 const char *str = params.getPictureFormat(); 1205 int32_t pictureFormat = 1206 lookupAttr(PICTURE_TYPES_MAP, 1207 sizeof(PICTURE_TYPES_MAP) / sizeof(QCameraMap), 1208 str); 1209 if (pictureFormat != NAME_NOT_FOUND) { 1210 mPictureFormat = pictureFormat; 1211 1212 updateParamEntry(KEY_PICTURE_FORMAT, str); 1213 ALOGE("%s: format %d\n", __func__, mPictureFormat); 1214 return NO_ERROR; 1215 } 1216 ALOGE("Invalid picture format value: %s", (str == NULL) ? "NULL" : str); 1217 return BAD_VALUE; 1218} 1219 1220/*=========================================================================== 1221 * FUNCTION : setJpegThumbnailSize 1222 * 1223 * DESCRIPTION: set jpeg thumbnail size from user setting 1224 * 1225 * PARAMETERS : 1226 * @params : user setting parameters 1227 * 1228 * RETURN : int32_t type of status 1229 * NO_ERROR -- success 1230 * none-zero failure code 1231 *==========================================================================*/ 1232int32_t QCameraParameters::setJpegThumbnailSize(const QCameraParameters& params) 1233{ 1234 int width = params.getInt(KEY_JPEG_THUMBNAIL_WIDTH); 1235 int height = params.getInt(KEY_JPEG_THUMBNAIL_HEIGHT); 1236 1237 ALOGV("requested jpeg thumbnail size %d x %d", width, height); 1238 1239 int sizes_cnt = sizeof(THUMBNAIL_SIZES_MAP) / sizeof(cam_dimension_t); 1240 1241 int pic_width = 0, pic_height = 0; 1242 params.getPictureSize(&pic_width, &pic_height); 1243 if (pic_height == 0) { 1244 ALOGE("%s: picture size is invalid (%d x %d)", __func__, pic_width, pic_height); 1245 return BAD_VALUE; 1246 } 1247 double picAspectRatio = (double)pic_width / pic_height; 1248 1249 int optimalWidth = 0, optimalHeight = 0; 1250 if (width != 0 || height != 0) { 1251 // If input jpeg thumnmail size is (0,0), meaning no thumbnail needed 1252 // hornor this setting. 1253 // Otherwise, find optimal jpeg thumbnail size that has same aspect ration 1254 // as picture size 1255 1256 // Try to find a size matches aspect ratio and has the largest width 1257 for (int i = 0; i < sizes_cnt; i++) { 1258 if (THUMBNAIL_SIZES_MAP[i].height == 0) { 1259 // No thumbnail case, just skip 1260 continue; 1261 } 1262 double ratio = 1263 (double)THUMBNAIL_SIZES_MAP[i].width / THUMBNAIL_SIZES_MAP[i].height; 1264 if (fabs(ratio - picAspectRatio) > ASPECT_TOLERANCE) { 1265 continue; 1266 } 1267 if (THUMBNAIL_SIZES_MAP[i].width > optimalWidth) { 1268 optimalWidth = THUMBNAIL_SIZES_MAP[i].width; 1269 optimalHeight = THUMBNAIL_SIZES_MAP[i].height; 1270 } 1271 } 1272 } 1273 1274 char val[16]; 1275 sprintf(val, "%d", optimalWidth); 1276 updateParamEntry(KEY_JPEG_THUMBNAIL_WIDTH, val); 1277 sprintf(val, "%d", optimalHeight); 1278 updateParamEntry(KEY_JPEG_THUMBNAIL_HEIGHT, val); 1279 return NO_ERROR; 1280} 1281 1282/*=========================================================================== 1283 * FUNCTION : setJpegQuality 1284 * 1285 * DESCRIPTION: set jpeg encpding quality from user setting 1286 * 1287 * PARAMETERS : 1288 * @params : user setting parameters 1289 * 1290 * RETURN : int32_t type of status 1291 * NO_ERROR -- success 1292 * none-zero failure code 1293 *==========================================================================*/ 1294int32_t QCameraParameters::setJpegQuality(const QCameraParameters& params) 1295{ 1296 int32_t rc = NO_ERROR; 1297 int quality = params.getInt(KEY_JPEG_QUALITY); 1298 if (quality >= 0 && quality <= 100) { 1299 set(KEY_JPEG_QUALITY, quality); 1300 } else { 1301 ALOGE("%s: Invalid jpeg quality=%d", __func__, quality); 1302 rc = BAD_VALUE; 1303 } 1304 1305 quality = params.getInt(KEY_JPEG_THUMBNAIL_QUALITY); 1306 if (quality >= 0 && quality <= 100) { 1307 char val[16]; 1308 sprintf(val, "%d", quality); 1309 updateParamEntry(KEY_JPEG_THUMBNAIL_QUALITY, val); 1310 } else { 1311 ALOGE("%s: Invalid jpeg thumbnail quality=%d", __func__, quality); 1312 rc = BAD_VALUE; 1313 } 1314 return rc; 1315} 1316 1317/*=========================================================================== 1318 * FUNCTION : setOrientaion 1319 * 1320 * DESCRIPTION: set orientaion from user setting 1321 * 1322 * PARAMETERS : 1323 * @params : user setting parameters 1324 * 1325 * RETURN : int32_t type of status 1326 * NO_ERROR -- success 1327 * none-zero failure code 1328 *==========================================================================*/ 1329int32_t QCameraParameters::setOrientation(const QCameraParameters& params) 1330{ 1331 const char *str = params.get(KEY_QC_ORIENTATION); 1332 1333 if (str != NULL) { 1334 if (strcmp(str, portrait) == 0 || strcmp(str, landscape) == 0) { 1335 // Camera service needs this to decide if the preview frames and raw 1336 // pictures should be rotated. 1337 updateParamEntry(KEY_QC_ORIENTATION, str); 1338 } else { 1339 ALOGE("%s: Invalid orientation value: %s", __func__, str); 1340 return BAD_VALUE; 1341 } 1342 } 1343 return NO_ERROR; 1344} 1345 1346/*=========================================================================== 1347 * FUNCTION : setAutoExposure 1348 * 1349 * DESCRIPTION: set auto exposure value from user setting 1350 * 1351 * PARAMETERS : 1352 * @params : user setting parameters 1353 * 1354 * RETURN : int32_t type of status 1355 * NO_ERROR -- success 1356 * none-zero failure code 1357 *==========================================================================*/ 1358int32_t QCameraParameters::setAutoExposure(const QCameraParameters& params) 1359{ 1360 const char *str = params.get(KEY_QC_AUTO_EXPOSURE); 1361 const char *prev_str = get(KEY_QC_AUTO_EXPOSURE); 1362 if (str != NULL) { 1363 if (prev_str == NULL || 1364 strcmp(str, prev_str) != 0) { 1365 return setAutoExposure(str); 1366 } 1367 } 1368 return NO_ERROR; 1369} 1370 1371/*=========================================================================== 1372 * FUNCTION : setPreviewFpsRange 1373 * 1374 * DESCRIPTION: set preview FPS range from user setting 1375 * 1376 * PARAMETERS : 1377 * @params : user setting parameters 1378 * 1379 * RETURN : int32_t type of status 1380 * NO_ERROR -- success 1381 * none-zero failure code 1382 *==========================================================================*/ 1383int32_t QCameraParameters::setPreviewFpsRange(const QCameraParameters& params) 1384{ 1385 int minFps,maxFps; 1386 int prevMinFps, prevMaxFps; 1387 int rc = NO_ERROR; 1388 bool found = false; 1389 1390 CameraParameters::getPreviewFpsRange(&prevMinFps, &prevMaxFps); 1391 ALOGV("%s: Existing FpsRange Values:(%d, %d)", __func__, prevMinFps, prevMaxFps); 1392 params.getPreviewFpsRange(&minFps, &maxFps); 1393 ALOGV("%s: Requested FpsRange Values:(%d, %d)", __func__, minFps, maxFps); 1394 1395 if(minFps == prevMinFps && maxFps == prevMaxFps) { 1396 ALOGV("%s: No change in FpsRange", __func__); 1397 rc = NO_ERROR; 1398 goto end; 1399 } 1400 for(int i = 0; i < m_pCapability->fps_ranges_tbl_cnt; i++) { 1401 // if the value is in the supported list 1402 if(minFps >= m_pCapability->fps_ranges_tbl[i].min_fps * 1000 && 1403 maxFps <= m_pCapability->fps_ranges_tbl[i].max_fps * 1000) { 1404 found = true; 1405 ALOGV("%s: FPS i=%d : minFps = %d, maxFps = %d ", __func__, i, minFps, maxFps); 1406 setPreviewFpsRange(minFps, maxFps); 1407 break; 1408 } 1409 } 1410 if(found == false){ 1411 ALOGE("%s: error: FPS range value not supported", __func__); 1412 rc = BAD_VALUE; 1413 } 1414end: 1415 return rc; 1416} 1417 1418/*=========================================================================== 1419 * FUNCTION : setPreviewFrameRate 1420 * 1421 * DESCRIPTION: set preview frame rate from user setting 1422 * 1423 * PARAMETERS : 1424 * @params : user setting parameters 1425 * 1426 * RETURN : int32_t type of status 1427 * NO_ERROR -- success 1428 * none-zero failure code 1429 *==========================================================================*/ 1430int32_t QCameraParameters::setPreviewFrameRate(const QCameraParameters& params) 1431{ 1432 uint16_t fps = (uint16_t)params.getPreviewFrameRate(); 1433 ALOGV("%s: requested preview frame rate is %d", __func__, fps); 1434 CameraParameters::setPreviewFrameRate(fps); 1435 return NO_ERROR; 1436} 1437 1438/*=========================================================================== 1439 * FUNCTION : setEffect 1440 * 1441 * DESCRIPTION: set effect value from user setting 1442 * 1443 * PARAMETERS : 1444 * @params : user setting parameters 1445 * 1446 * RETURN : int32_t type of status 1447 * NO_ERROR -- success 1448 * none-zero failure code 1449 *==========================================================================*/ 1450int32_t QCameraParameters::setEffect(const QCameraParameters& params) 1451{ 1452 const char *str = params.get(KEY_EFFECT); 1453 const char *prev_str = get(KEY_EFFECT); 1454 if (str != NULL) { 1455 if (prev_str == NULL || 1456 strcmp(str, prev_str) != 0) { 1457 return setEffect(str); 1458 } 1459 } 1460 return NO_ERROR; 1461} 1462 1463/*=========================================================================== 1464 * FUNCTION : setFocusMode 1465 * 1466 * DESCRIPTION: set focus mode from user setting 1467 * 1468 * PARAMETERS : 1469 * @params : user setting parameters 1470 * 1471 * RETURN : int32_t type of status 1472 * NO_ERROR -- success 1473 * none-zero failure code 1474 *==========================================================================*/ 1475int32_t QCameraParameters::setFocusMode(const QCameraParameters& params) 1476{ 1477 const char *str = params.get(KEY_FOCUS_MODE); 1478 const char *prev_str = get(KEY_FOCUS_MODE); 1479 if (str != NULL) { 1480 if (prev_str == NULL || 1481 strcmp(str, prev_str) != 0) { 1482 return setFocusMode(str); 1483 } 1484 } 1485 return NO_ERROR; 1486} 1487 1488/*=========================================================================== 1489 * FUNCTION : setBrightness 1490 * 1491 * DESCRIPTION: set brightness control value from user setting 1492 * 1493 * PARAMETERS : 1494 * @params : user setting parameters 1495 * 1496 * RETURN : int32_t type of status 1497 * NO_ERROR -- success 1498 * none-zero failure code 1499 *==========================================================================*/ 1500int32_t QCameraParameters::setBrightness(const QCameraParameters& params) 1501{ 1502 int currentBrightness = getInt(KEY_QC_BRIGHTNESS); 1503 int brightness = params.getInt(KEY_QC_BRIGHTNESS); 1504 if (currentBrightness != brightness) { 1505 if (brightness >= m_pCapability->brightness_ctrl.min_value && 1506 brightness <= m_pCapability->brightness_ctrl.max_value) { 1507 ALOGV(" new brightness value : %d ", brightness); 1508 return setBrightness(brightness); 1509 } else { 1510 ALOGE("%s: invalid value %d out of (%d, %d)", 1511 __func__, brightness, 1512 m_pCapability->brightness_ctrl.min_value, 1513 m_pCapability->brightness_ctrl.max_value); 1514 return BAD_VALUE; 1515 } 1516 } else { 1517 ALOGV("%s: No brightness value changed.", __func__); 1518 return NO_ERROR; 1519 } 1520} 1521 1522/*=========================================================================== 1523 * FUNCTION : setSharpness 1524 * 1525 * DESCRIPTION: set sharpness control value from user setting 1526 * 1527 * PARAMETERS : 1528 * @params : user setting parameters 1529 * 1530 * RETURN : int32_t type of status 1531 * NO_ERROR -- success 1532 * none-zero failure code 1533 *==========================================================================*/ 1534int32_t QCameraParameters::setSharpness(const QCameraParameters& params) 1535{ 1536 int shaprness = params.getInt(KEY_QC_SHARPNESS); 1537 int prev_sharp = getInt(KEY_QC_SHARPNESS); 1538 if (prev_sharp != shaprness) { 1539 if((shaprness >= m_pCapability->sharpness_ctrl.min_value) && 1540 (shaprness <= m_pCapability->sharpness_ctrl.max_value)) { 1541 ALOGV(" new sharpness value : %d ", shaprness); 1542 return setSharpness(shaprness); 1543 } else { 1544 ALOGE("%s: invalid value %d out of (%d, %d)", 1545 __func__, shaprness, 1546 m_pCapability->sharpness_ctrl.min_value, 1547 m_pCapability->sharpness_ctrl.max_value); 1548 return BAD_VALUE; 1549 } 1550 } else { 1551 ALOGV("%s: No value change in shaprness", __func__); 1552 return NO_ERROR; 1553 } 1554} 1555 1556/*=========================================================================== 1557 * FUNCTION : setSkintoneEnahancement 1558 * 1559 * DESCRIPTION: set skin tone enhancement factor from user setting 1560 * 1561 * PARAMETERS : 1562 * @params : user setting parameters 1563 * 1564 * RETURN : int32_t type of status 1565 * NO_ERROR -- success 1566 * none-zero failure code 1567 *==========================================================================*/ 1568int32_t QCameraParameters::setSkinToneEnhancement(const QCameraParameters& params) 1569{ 1570 int sceFactor = params.getInt(KEY_QC_SCE_FACTOR); 1571 int prev_sceFactor = getInt(KEY_QC_SCE_FACTOR); 1572 if (prev_sceFactor != sceFactor) { 1573 if((sceFactor >= m_pCapability->sce_ctrl.min_value) && 1574 (sceFactor <= m_pCapability->sce_ctrl.max_value)) { 1575 ALOGV(" new Skintone Enhancement value : %d ", sceFactor); 1576 return setSkinToneEnhancement(sceFactor); 1577 } else { 1578 ALOGE("%s: invalid value %d out of (%d, %d)", 1579 __func__, sceFactor, 1580 m_pCapability->sce_ctrl.min_value, 1581 m_pCapability->sce_ctrl.max_value); 1582 return BAD_VALUE; 1583 } 1584 } else { 1585 ALOGV("%s: No value change in skintone enhancement factor", __func__); 1586 return NO_ERROR; 1587 } 1588} 1589 1590/*=========================================================================== 1591 * FUNCTION : setSaturation 1592 * 1593 * DESCRIPTION: set saturation control value from user setting 1594 * 1595 * PARAMETERS : 1596 * @params : user setting parameters 1597 * 1598 * RETURN : int32_t type of status 1599 * NO_ERROR -- success 1600 * none-zero failure code 1601 *==========================================================================*/ 1602int32_t QCameraParameters::setSaturation(const QCameraParameters& params) 1603{ 1604 int saturation = params.getInt(KEY_QC_SATURATION); 1605 int prev_sat = getInt(KEY_QC_SATURATION); 1606 if (prev_sat != saturation) { 1607 if((saturation >= m_pCapability->saturation_ctrl.min_value) && 1608 (saturation <= m_pCapability->saturation_ctrl.max_value)) { 1609 ALOGV(" new saturation value : %d ", saturation); 1610 return setSaturation(saturation); 1611 } else { 1612 ALOGE("%s: invalid value %d out of (%d, %d)", 1613 __func__, saturation, 1614 m_pCapability->saturation_ctrl.min_value, 1615 m_pCapability->saturation_ctrl.max_value); 1616 return BAD_VALUE; 1617 } 1618 } else { 1619 ALOGV("%s: No value change in saturation factor", __func__); 1620 return NO_ERROR; 1621 } 1622} 1623 1624/*=========================================================================== 1625 * FUNCTION : setContrast 1626 * 1627 * DESCRIPTION: set contrast control value from user setting 1628 * 1629 * PARAMETERS : 1630 * @params : user setting parameters 1631 * 1632 * RETURN : int32_t type of status 1633 * NO_ERROR -- success 1634 * none-zero failure code 1635 *==========================================================================*/ 1636int32_t QCameraParameters::setContrast(const QCameraParameters& params) 1637{ 1638 int contrast = params.getInt(KEY_QC_CONTRAST); 1639 int prev_contrast = getInt(KEY_QC_CONTRAST); 1640 if (prev_contrast != contrast) { 1641 if((contrast >= m_pCapability->contrast_ctrl.min_value) && 1642 (contrast <= m_pCapability->contrast_ctrl.max_value)) { 1643 ALOGV(" new contrast value : %d ", contrast); 1644 int32_t rc = setContrast(contrast); 1645 return rc; 1646 } else { 1647 ALOGE("%s: invalid value %d out of (%d, %d)", 1648 __func__, contrast, 1649 m_pCapability->contrast_ctrl.min_value, 1650 m_pCapability->contrast_ctrl.max_value); 1651 return BAD_VALUE; 1652 } 1653 } else { 1654 ALOGV("%s: No value change in contrast", __func__); 1655 return NO_ERROR; 1656 } 1657} 1658 1659/*=========================================================================== 1660 * FUNCTION : setExposureCompensation 1661 * 1662 * DESCRIPTION: set exposure compensation value from user setting 1663 * 1664 * PARAMETERS : 1665 * @params : user setting parameters 1666 * 1667 * RETURN : int32_t type of status 1668 * NO_ERROR -- success 1669 * none-zero failure code 1670 *==========================================================================*/ 1671int32_t QCameraParameters::setExposureCompensation(const QCameraParameters & params) 1672{ 1673 int expComp = params.getInt(KEY_EXPOSURE_COMPENSATION); 1674 int prev_expComp = getInt(KEY_EXPOSURE_COMPENSATION); 1675 if (prev_expComp != expComp) { 1676 if((expComp >= m_pCapability->exposure_compensation_min) && 1677 (expComp <= m_pCapability->exposure_compensation_max)) { 1678 ALOGV(" new Exposure Compensation value : %d ", expComp); 1679 return setExposureCompensation(expComp); 1680 } else { 1681 ALOGE("%s: invalid value %d out of (%d, %d)", 1682 __func__, expComp, 1683 m_pCapability->exposure_compensation_min, 1684 m_pCapability->exposure_compensation_max); 1685 return BAD_VALUE; 1686 } 1687 } else { 1688 ALOGV("%s: No value change in Exposure Compensation", __func__); 1689 return NO_ERROR; 1690 } 1691} 1692 1693/*=========================================================================== 1694 * FUNCTION : setWhiteBalance 1695 * 1696 * DESCRIPTION: set white balance value from user setting 1697 * 1698 * PARAMETERS : 1699 * @params : user setting parameters 1700 * 1701 * RETURN : int32_t type of status 1702 * NO_ERROR -- success 1703 * none-zero failure code 1704 *==========================================================================*/ 1705int32_t QCameraParameters::setWhiteBalance(const QCameraParameters& params) 1706{ 1707 const char *str = params.get(KEY_WHITE_BALANCE); 1708 const char *prev_str = get(KEY_WHITE_BALANCE); 1709 if (str != NULL) { 1710 if (prev_str == NULL || 1711 strcmp(str, prev_str) != 0) { 1712 return setWhiteBalance(str); 1713 } 1714 } 1715 return NO_ERROR; 1716} 1717 1718/*=========================================================================== 1719 * FUNCTION : setAntibanding 1720 * 1721 * DESCRIPTION: set antibanding value from user setting 1722 * 1723 * PARAMETERS : 1724 * @params : user setting parameters 1725 * 1726 * RETURN : int32_t type of status 1727 * NO_ERROR -- success 1728 * none-zero failure code 1729 *==========================================================================*/ 1730int32_t QCameraParameters::setAntibanding(const QCameraParameters& params) 1731{ 1732 const char *str = params.get(KEY_ANTIBANDING); 1733 const char *prev_str = get(KEY_ANTIBANDING); 1734 if (str != NULL) { 1735 if (prev_str == NULL || 1736 strcmp(str, prev_str) != 0) { 1737 return setAntibanding(str); 1738 } 1739 } 1740 return NO_ERROR; 1741} 1742 1743/*=========================================================================== 1744 * FUNCTION : setSceneDetect 1745 * 1746 * DESCRIPTION: set scenen detect value from user setting 1747 * 1748 * PARAMETERS : 1749 * @params : user setting parameters 1750 * 1751 * RETURN : int32_t type of status 1752 * NO_ERROR -- success 1753 * none-zero failure code 1754 *==========================================================================*/ 1755int32_t QCameraParameters::setSceneDetect(const QCameraParameters& params) 1756{ 1757 const char *str = params.get(KEY_QC_SCENE_DETECT); 1758 const char *prev_str = get(KEY_QC_SCENE_DETECT); 1759 if (str != NULL) { 1760 if (prev_str == NULL || 1761 strcmp(str, prev_str) != 0) { 1762 return setSceneDetect(str); 1763 } 1764 } 1765 return NO_ERROR; 1766} 1767 1768/*=========================================================================== 1769 * FUNCTION : setVideoHDR 1770 * 1771 * DESCRIPTION: set video HDR value from user setting 1772 * 1773 * PARAMETERS : 1774 * @params : user setting parameters 1775 * 1776 * RETURN : int32_t type of status 1777 * NO_ERROR -- success 1778 * none-zero failure code 1779 *==========================================================================*/ 1780int32_t QCameraParameters::setVideoHDR(const QCameraParameters& params) 1781{ 1782 const char *str = params.get(KEY_QC_VIDEO_HDR); 1783 const char *prev_str = get(KEY_QC_VIDEO_HDR); 1784 if (str != NULL) { 1785 if (prev_str == NULL || 1786 strcmp(str, prev_str) != 0) { 1787 return setVideoHDR(str); 1788 } 1789 } 1790 return NO_ERROR; 1791} 1792 1793/*=========================================================================== 1794 * FUNCTION : setFaceRecognition 1795 * 1796 * DESCRIPTION: set face recognition mode from user setting 1797 * 1798 * PARAMETERS : 1799 * @params : user setting parameters 1800 * 1801 * RETURN : int32_t type of status 1802 * NO_ERROR -- success 1803 * none-zero failure code 1804 *==========================================================================*/ 1805int32_t QCameraParameters::setFaceRecognition(const QCameraParameters& params) 1806{ 1807 const char *str = params.get(KEY_QC_FACE_RECOGNITION); 1808 const char *prev_str = get(KEY_QC_FACE_RECOGNITION); 1809 if (str != NULL) { 1810 if (prev_str == NULL || 1811 strcmp(str, prev_str) != 0) { 1812 int maxFaces = params.getInt(KEY_QC_MAX_NUM_REQUESTED_FACES); 1813 return setFaceRecognition(str, maxFaces); 1814 } 1815 } 1816 return NO_ERROR; 1817} 1818 1819/*=========================================================================== 1820 * FUNCTION : setZoom 1821 * 1822 * DESCRIPTION: set zoom value from user setting 1823 * 1824 * PARAMETERS : 1825 * @params : user setting parameters 1826 * 1827 * RETURN : int32_t type of status 1828 * NO_ERROR -- success 1829 * none-zero failure code 1830 *==========================================================================*/ 1831int32_t QCameraParameters::setZoom(const QCameraParameters& params) 1832{ 1833 if ((m_pCapability->zoom_supported == 0 || 1834 m_pCapability->zoom_ratio_tbl_cnt == 0)) { 1835 ALOGD("%s: no zoom support", __func__); 1836 return NO_ERROR; 1837 } 1838 1839 int zoomLevel = params.getInt(KEY_ZOOM); 1840 if((zoomLevel < 0) || 1841 (zoomLevel >= m_pCapability->zoom_ratio_tbl_cnt)) { 1842 ALOGE("%s: invalid value %d out of (%d, %d)", 1843 __func__, zoomLevel, 1844 0, m_pCapability->zoom_ratio_tbl_cnt-1); 1845 return BAD_VALUE; 1846 } 1847 1848 int prevZoomLevel = getInt(KEY_ZOOM); 1849 if (prevZoomLevel == zoomLevel) { 1850 ALOGV("%s: No value change in contrast", __func__); 1851 return NO_ERROR; 1852 } 1853 1854 return setZoom(zoomLevel); 1855} 1856 1857/*=========================================================================== 1858 * FUNCTION : setISOValue 1859 * 1860 * DESCRIPTION: set ISO value from user setting 1861 * 1862 * PARAMETERS : 1863 * @params : user setting parameters 1864 * 1865 * RETURN : int32_t type of status 1866 * NO_ERROR -- success 1867 * none-zero failure code 1868 *==========================================================================*/ 1869int32_t QCameraParameters::setISOValue(const QCameraParameters& params) 1870{ 1871 const char *str = params.get(KEY_QC_ISO_MODE); 1872 const char *prev_str = get(KEY_QC_ISO_MODE); 1873 if (str != NULL) { 1874 if (prev_str == NULL || 1875 strcmp(str, prev_str) != 0) { 1876 return setISOValue(str); 1877 } 1878 } 1879 return NO_ERROR; 1880} 1881 1882/*=========================================================================== 1883 * FUNCTION : setRotation 1884 * 1885 * DESCRIPTION: set rotation value from user setting 1886 * 1887 * PARAMETERS : 1888 * @params : user setting parameters 1889 * 1890 * RETURN : int32_t type of status 1891 * NO_ERROR -- success 1892 * none-zero failure code 1893 *==========================================================================*/ 1894int32_t QCameraParameters::setRotation(const QCameraParameters& params) 1895{ 1896 int rotation = params.getInt(KEY_ROTATION); 1897 if (rotation != -1) { 1898 if (rotation == 0 || rotation == 90 || 1899 rotation == 180 || rotation == 270) { 1900 set(KEY_ROTATION, rotation); 1901 } else { 1902 ALOGE("Invalid rotation value: %d", rotation); 1903 return BAD_VALUE; 1904 } 1905 } 1906 return NO_ERROR; 1907} 1908 1909/*=========================================================================== 1910 * FUNCTION : setFlash 1911 * 1912 * DESCRIPTION: set flash mode from user setting 1913 * 1914 * PARAMETERS : 1915 * @params : user setting parameters 1916 * 1917 * RETURN : int32_t type of status 1918 * NO_ERROR -- success 1919 * none-zero failure code 1920 *==========================================================================*/ 1921int32_t QCameraParameters::setFlash(const QCameraParameters& params) 1922{ 1923 const char *str = params.get(KEY_FLASH_MODE); 1924 const char *prev_str = get(KEY_FLASH_MODE); 1925 if (str != NULL) { 1926 if (prev_str == NULL || 1927 strcmp(str, prev_str) != 0) { 1928 return setFlash(str); 1929 } 1930 } 1931 return NO_ERROR; 1932} 1933 1934/*=========================================================================== 1935 * FUNCTION : setAecLock 1936 * 1937 * DESCRIPTION: set AEC lock value from user setting 1938 * 1939 * PARAMETERS : 1940 * @params : user setting parameters 1941 * 1942 * RETURN : int32_t type of status 1943 * NO_ERROR -- success 1944 * none-zero failure code 1945 *==========================================================================*/ 1946int32_t QCameraParameters::setAecLock(const QCameraParameters& params) 1947{ 1948 const char *str = params.get(KEY_AUTO_EXPOSURE_LOCK); 1949 const char *prev_str = get(KEY_AUTO_EXPOSURE_LOCK); 1950 if (str != NULL) { 1951 if (prev_str == NULL || 1952 strcmp(str, prev_str) != 0) { 1953 return setAecLock(str); 1954 } 1955 } 1956 return NO_ERROR; 1957} 1958 1959/*=========================================================================== 1960 * FUNCTION : setAwbLock 1961 * 1962 * DESCRIPTION: set AWB lock from user setting 1963 * 1964 * PARAMETERS : 1965 * @params : user setting parameters 1966 * 1967 * RETURN : int32_t type of status 1968 * NO_ERROR -- success 1969 * none-zero failure code 1970 *==========================================================================*/ 1971int32_t QCameraParameters::setAwbLock(const QCameraParameters& params) 1972{ 1973 const char *str = params.get(KEY_AUTO_WHITEBALANCE_LOCK); 1974 const char *prev_str = get(KEY_AUTO_WHITEBALANCE_LOCK); 1975 if (str != NULL) { 1976 if (prev_str == NULL || 1977 strcmp(str, prev_str) != 0) { 1978 return setAwbLock(str); 1979 } 1980 } 1981 return NO_ERROR; 1982} 1983 1984/*=========================================================================== 1985 * FUNCTION : setMCEValue 1986 * 1987 * DESCRIPTION: set memory color enhancement value from user setting 1988 * 1989 * PARAMETERS : 1990 * @params : user setting parameters 1991 * 1992 * RETURN : int32_t type of status 1993 * NO_ERROR -- success 1994 * none-zero failure code 1995 *==========================================================================*/ 1996int32_t QCameraParameters::setMCEValue(const QCameraParameters& params) 1997{ 1998 const char *str = params.get(KEY_QC_MEMORY_COLOR_ENHANCEMENT); 1999 const char *prev_str = get(KEY_QC_MEMORY_COLOR_ENHANCEMENT); 2000 if (str != NULL) { 2001 if (prev_str == NULL || 2002 strcmp(str, prev_str) != 0) { 2003 return setMCEValue(str); 2004 } 2005 } 2006 return NO_ERROR; 2007} 2008 2009/*=========================================================================== 2010 * FUNCTION : setDISValue 2011 * 2012 * DESCRIPTION: enable/disable DIS from user setting 2013 * 2014 * PARAMETERS : 2015 * @params : user setting parameters 2016 * 2017 * RETURN : int32_t type of status 2018 * NO_ERROR -- success 2019 * none-zero failure code 2020 *==========================================================================*/ 2021int32_t QCameraParameters::setDISValue(const QCameraParameters& params) 2022{ 2023 const char *str = params.get(KEY_QC_DIS); 2024 const char *prev_str = get(KEY_QC_DIS); 2025 if (str != NULL) { 2026 if (prev_str == NULL || 2027 strcmp(str, prev_str) != 0) { 2028 return setDISValue(str); 2029 } 2030 } 2031 return NO_ERROR; 2032} 2033 2034/*=========================================================================== 2035 * FUNCTION : setHighFrameRate 2036 * 2037 * DESCRIPTION: set hight frame rate value from user setting 2038 * 2039 * PARAMETERS : 2040 * @params : user setting parameters 2041 * 2042 * RETURN : int32_t type of status 2043 * NO_ERROR -- success 2044 * none-zero failure code 2045 *==========================================================================*/ 2046int32_t QCameraParameters::setHighFrameRate(const QCameraParameters& params) 2047{ 2048 const char *str = params.get(KEY_QC_VIDEO_HIGH_FRAME_RATE); 2049 const char *prev_str = get(KEY_QC_VIDEO_HIGH_FRAME_RATE); 2050 if (str != NULL) { 2051 if (prev_str == NULL || 2052 strcmp(str, prev_str) != 0) { 2053 return setHighFrameRate(str); 2054 } 2055 } 2056 return NO_ERROR; 2057} 2058 2059/*=========================================================================== 2060 * FUNCTION : setLensShadeValue 2061 * 2062 * DESCRIPTION: set lens shade value from user setting 2063 * 2064 * PARAMETERS : 2065 * @params : user setting parameters 2066 * 2067 * RETURN : int32_t type of status 2068 * NO_ERROR -- success 2069 * none-zero failure code 2070 *==========================================================================*/ 2071int32_t QCameraParameters::setLensShadeValue(const QCameraParameters& params) 2072{ 2073 const char *str = params.get(KEY_QC_LENSSHADE); 2074 const char *prev_str = get(KEY_QC_LENSSHADE); 2075 if (str != NULL) { 2076 if (prev_str == NULL || 2077 strcmp(str, prev_str) != 0) { 2078 return setLensShadeValue(str); 2079 } 2080 } 2081 return NO_ERROR; 2082} 2083 2084/*=========================================================================== 2085 * FUNCTION : setFocusAreas 2086 * 2087 * DESCRIPTION: set focus areas from user setting 2088 * 2089 * PARAMETERS : 2090 * @params : user setting parameters 2091 * 2092 * RETURN : int32_t type of status 2093 * NO_ERROR -- success 2094 * none-zero failure code 2095 *==========================================================================*/ 2096int32_t QCameraParameters::setFocusAreas(const QCameraParameters& params) 2097{ 2098 const char *str = params.get(KEY_FOCUS_AREAS); 2099 if (str != NULL) { 2100 int max_num_af_areas = getInt(KEY_MAX_NUM_FOCUS_AREAS); 2101 if(max_num_af_areas == 0) { 2102 ALOGE("%s: max num of AF area is 0, cannot set focus areas", __func__); 2103 return BAD_VALUE; 2104 } 2105 2106 const char *prev_str = get(KEY_FOCUS_AREAS); 2107 if (prev_str == NULL || 2108 strcmp(str, prev_str) != 0) { 2109 return setFocusAreas(str); 2110 } 2111 } 2112 return NO_ERROR; 2113} 2114 2115/*=========================================================================== 2116 * FUNCTION : setMeteringAreas 2117 * 2118 * DESCRIPTION: set metering areas from user setting 2119 * 2120 * PARAMETERS : 2121 * @params : user setting parameters 2122 * 2123 * RETURN : int32_t type of status 2124 * NO_ERROR -- success 2125 * none-zero failure code 2126 *==========================================================================*/ 2127int32_t QCameraParameters::setMeteringAreas(const QCameraParameters& params) 2128{ 2129 const char *str = params.get(KEY_METERING_AREAS); 2130 if (str != NULL) { 2131 int max_num_mtr_areas = getInt(KEY_MAX_NUM_METERING_AREAS); 2132 if(max_num_mtr_areas == 0) { 2133 ALOGE("%s: max num of metering areas is 0, cannot set focus areas", __func__); 2134 return BAD_VALUE; 2135 } 2136 2137 const char *prev_str = get(KEY_METERING_AREAS); 2138 if (prev_str == NULL || 2139 strcmp(str, prev_str) != 0) { 2140 return setMeteringAreas(str); 2141 } 2142 } 2143 return NO_ERROR; 2144} 2145 2146/*=========================================================================== 2147 * FUNCTION : setSceneMode 2148 * 2149 * DESCRIPTION: set scenen mode from user setting 2150 * 2151 * PARAMETERS : 2152 * @params : user setting parameters 2153 * 2154 * RETURN : int32_t type of status 2155 * NO_ERROR -- success 2156 * none-zero failure code 2157 *==========================================================================*/ 2158int32_t QCameraParameters::setSceneMode(const QCameraParameters& params) 2159{ 2160 const char *str = params.get(KEY_SCENE_MODE); 2161 const char *prev_str = get(KEY_SCENE_MODE); 2162 if (str != NULL) { 2163 if (prev_str == NULL || 2164 strcmp(str, prev_str) != 0) { 2165 if ((strcmp(str, SCENE_MODE_HDR) == 0) || 2166 ((prev_str != NULL) && (strcmp(prev_str, SCENE_MODE_HDR) == 0))) { 2167 ALOGD("%s: scene mode changed between HDR and non-HDR, need restart", __func__); 2168 m_bNeedRestart = true; 2169 2170 // set if hdr 1x image is needed 2171 const char *need_hdr_1x = params.get(KEY_QC_HDR_NEED_1X); 2172 int32_t value = 0; 2173 if (need_hdr_1x != NULL && strcmp(need_hdr_1x, VALUE_TRUE) == 0) { 2174 value = 1; 2175 updateParamEntry(KEY_QC_HDR_NEED_1X, need_hdr_1x); 2176 AddSetParmEntryToBatch(m_pParamBuf, 2177 CAM_INTF_PARM_HDR_NEED_1X, 2178 sizeof(value), 2179 &value); 2180 } 2181 } 2182 return setSceneMode(str); 2183 } 2184 } 2185 return NO_ERROR; 2186} 2187 2188/*=========================================================================== 2189 * FUNCTION : setSelectableZoneAf 2190 * 2191 * DESCRIPTION: set selectable zone auto focus value from user setting 2192 * 2193 * PARAMETERS : 2194 * @params : user setting parameters 2195 * 2196 * RETURN : int32_t type of status 2197 * NO_ERROR -- success 2198 * none-zero failure code 2199 *==========================================================================*/ 2200int32_t QCameraParameters::setSelectableZoneAf(const QCameraParameters& params) 2201{ 2202 const char *str = params.get(KEY_QC_SELECTABLE_ZONE_AF); 2203 const char *prev_str = get(KEY_QC_SELECTABLE_ZONE_AF); 2204 if (str != NULL) { 2205 if (prev_str == NULL || 2206 strcmp(str, prev_str) != 0) { 2207 return setSelectableZoneAf(str); 2208 } 2209 } 2210 return NO_ERROR; 2211} 2212 2213/*=========================================================================== 2214 * FUNCTION : setAEBracket 2215 * 2216 * DESCRIPTION: set AE bracket from user setting 2217 * 2218 * PARAMETERS : 2219 * @params : user setting parameters 2220 * 2221 * RETURN : int32_t type of status 2222 * NO_ERROR -- success 2223 * none-zero failure code 2224 *==========================================================================*/ 2225int32_t QCameraParameters::setAEBracket(const QCameraParameters& params) 2226{ 2227 const char *scene_mode = params.get(KEY_SCENE_MODE); 2228 if (scene_mode != NULL && strcmp(scene_mode, SCENE_MODE_HDR) == 0) { 2229 ALOGE("%s: scene mode is HDR, overwrite AE bracket setting to off", __func__); 2230 return setAEBracket(AE_BRACKET_OFF); 2231 } 2232 2233 const char *expStr = params.get(KEY_QC_CAPTURE_BURST_EXPOSURE); 2234 if (NULL != expStr && strlen(expStr) > 0) { 2235 set(KEY_QC_CAPTURE_BURST_EXPOSURE, expStr); 2236 } else { 2237 char prop[PROPERTY_VALUE_MAX]; 2238 memset(prop, 0, sizeof(prop)); 2239 property_get("persist.capture.burst.exposures", prop, ""); 2240 if (strlen(prop) > 0) { 2241 set(KEY_QC_CAPTURE_BURST_EXPOSURE, prop); 2242 } else { 2243 remove(KEY_QC_CAPTURE_BURST_EXPOSURE); 2244 } 2245 } 2246 2247 const char *str = params.get(KEY_QC_AE_BRACKET_HDR); 2248 const char *prev_str = get(KEY_QC_AE_BRACKET_HDR); 2249 if (str != NULL) { 2250 if (prev_str == NULL || 2251 strcmp(str, prev_str) != 0) { 2252 return setAEBracket(str); 2253 } 2254 } 2255 return NO_ERROR; 2256} 2257 2258/*=========================================================================== 2259 * FUNCTION : setRedeyeReduction 2260 * 2261 * DESCRIPTION: set red eye reduction setting from user setting 2262 * 2263 * PARAMETERS : 2264 * @params : user setting parameters 2265 * 2266 * RETURN : int32_t type of status 2267 * NO_ERROR -- success 2268 * none-zero failure code 2269 *==========================================================================*/ 2270int32_t QCameraParameters::setRedeyeReduction(const QCameraParameters& params) 2271{ 2272 const char *str = params.get(KEY_QC_REDEYE_REDUCTION); 2273 const char *prev_str = get(KEY_QC_REDEYE_REDUCTION); 2274 if (str != NULL) { 2275 if (prev_str == NULL || 2276 strcmp(str, prev_str) != 0) { 2277 return setRedeyeReduction(str); 2278 } 2279 } 2280 return NO_ERROR; 2281} 2282 2283/*=========================================================================== 2284 * FUNCTION : setGpsLocation 2285 * 2286 * DESCRIPTION: set GPS location information from user setting 2287 * 2288 * PARAMETERS : 2289 * @params : user setting parameters 2290 * 2291 * RETURN : int32_t type of status 2292 * NO_ERROR -- success 2293 * none-zero failure code 2294 *==========================================================================*/ 2295int32_t QCameraParameters::setGpsLocation(const QCameraParameters& params) 2296{ 2297 const char *method = params.get(KEY_GPS_PROCESSING_METHOD); 2298 if (method) { 2299 set(KEY_GPS_PROCESSING_METHOD, method); 2300 }else { 2301 remove(KEY_GPS_PROCESSING_METHOD); 2302 } 2303 2304 const char *latitude = params.get(KEY_GPS_LATITUDE); 2305 if (latitude) { 2306 set(KEY_GPS_LATITUDE, latitude); 2307 }else { 2308 remove(KEY_GPS_LATITUDE); 2309 } 2310 2311 const char *latitudeRef = params.get(KEY_QC_GPS_LATITUDE_REF); 2312 if (latitudeRef) { 2313 set(KEY_QC_GPS_LATITUDE_REF, latitudeRef); 2314 }else { 2315 remove(KEY_QC_GPS_LATITUDE_REF); 2316 } 2317 2318 const char *longitude = params.get(KEY_GPS_LONGITUDE); 2319 if (longitude) { 2320 set(KEY_GPS_LONGITUDE, longitude); 2321 }else { 2322 remove(KEY_GPS_LONGITUDE); 2323 } 2324 2325 const char *longitudeRef = params.get(KEY_QC_GPS_LONGITUDE_REF); 2326 if (longitudeRef) { 2327 set(KEY_QC_GPS_LONGITUDE_REF, longitudeRef); 2328 }else { 2329 remove(KEY_QC_GPS_LONGITUDE_REF); 2330 } 2331 2332 const char *altitudeRef = params.get(KEY_QC_GPS_ALTITUDE_REF); 2333 if (altitudeRef) { 2334 set(KEY_QC_GPS_ALTITUDE_REF, altitudeRef); 2335 }else { 2336 remove(KEY_QC_GPS_ALTITUDE_REF); 2337 } 2338 2339 const char *altitude = params.get(KEY_GPS_ALTITUDE); 2340 if (altitude) { 2341 set(KEY_GPS_ALTITUDE, altitude); 2342 }else { 2343 remove(KEY_GPS_ALTITUDE); 2344 } 2345 2346 const char *status = params.get(KEY_QC_GPS_STATUS); 2347 if (status) { 2348 set(KEY_QC_GPS_STATUS, status); 2349 } else { 2350 remove(KEY_QC_GPS_STATUS); 2351 } 2352 2353 const char *timestamp = params.get(KEY_GPS_TIMESTAMP); 2354 if (timestamp) { 2355 set(KEY_GPS_TIMESTAMP, timestamp); 2356 }else { 2357 remove(KEY_GPS_TIMESTAMP); 2358 } 2359 return NO_ERROR; 2360} 2361 2362/*=========================================================================== 2363 * FUNCTION : setNumOfSnapshot 2364 * 2365 * DESCRIPTION: set number of snapshot per shutter from user setting 2366 * 2367 * PARAMETERS : none 2368 * 2369 * RETURN : int32_t type of status 2370 * NO_ERROR -- success 2371 * none-zero failure code 2372 *==========================================================================*/ 2373int32_t QCameraParameters::setNumOfSnapshot() 2374{ 2375 int nBurstNum = getBurstNum(); 2376 uint8_t nExpnum = 0; 2377 2378 const char *scene_mode = get(KEY_SCENE_MODE); 2379 if (scene_mode != NULL && strcmp(scene_mode, SCENE_MODE_HDR) == 0) { 2380 /* According to Android SDK, only one snapshot, 2381 * but OEM might have different requirement */ 2382 const char *need_hdr_1x = get(KEY_QC_HDR_NEED_1X); 2383 if (need_hdr_1x != NULL && strcmp(need_hdr_1x, VALUE_TRUE) == 0) { 2384 nExpnum = 2; // HDR needs both 1X and processed img 2385 } else { 2386 nExpnum = 1; // HDR only needs processed img 2387 } 2388 } else { 2389 const char *bracket_str = get(KEY_QC_AE_BRACKET_HDR); 2390 if (bracket_str != NULL && strlen(bracket_str) > 0) { 2391 int value = lookupAttr(BRACKETING_MODES_MAP, 2392 sizeof(BRACKETING_MODES_MAP)/sizeof(QCameraMap), 2393 bracket_str); 2394 switch (value) { 2395 case CAM_EXP_BRACKETING_ON: 2396 { 2397 nExpnum = 0; 2398 const char *str_val = get(KEY_QC_CAPTURE_BURST_EXPOSURE); 2399 if ((str_val != NULL) && (strlen(str_val) > 0)) { 2400 char prop[PROPERTY_VALUE_MAX]; 2401 memset(prop, 0, sizeof(prop)); 2402 strcpy(prop, str_val); 2403 char *saveptr = NULL; 2404 char *token = strtok_r(prop, ",", &saveptr); 2405 while (token != NULL) { 2406 token = strtok_r(NULL, ",", &saveptr); 2407 nExpnum++; 2408 } 2409 } 2410 if (nExpnum == 0) { 2411 nExpnum = 1; 2412 } 2413 } 2414 break; 2415 default: 2416 nExpnum = 1; 2417 break; 2418 } 2419 } 2420 } 2421 2422 ALOGD("%s: nBurstNum = %d, nExpnum = %d", __func__, nBurstNum, nExpnum); 2423 set(KEY_QC_NUM_SNAPSHOT_PER_SHUTTER, nBurstNum * nExpnum); 2424 return NO_ERROR; 2425} 2426 2427/*=========================================================================== 2428 * FUNCTION : setRecordingHint 2429 * 2430 * DESCRIPTION: set recording hint value from user setting 2431 * 2432 * PARAMETERS : 2433 * @params : user setting parameters 2434 * 2435 * RETURN : int32_t type of status 2436 * NO_ERROR -- success 2437 * none-zero failure code 2438 *==========================================================================*/ 2439int32_t QCameraParameters::setRecordingHint(const QCameraParameters& params) 2440{ 2441 const char * str = params.get(KEY_RECORDING_HINT); 2442 const char *prev_str = get(KEY_RECORDING_HINT); 2443 if (str != NULL) { 2444 if (prev_str == NULL || strcmp(str, prev_str) != 0) { 2445 int32_t value = lookupAttr(TRUE_FALSE_MODES_MAP, 2446 sizeof(TRUE_FALSE_MODES_MAP)/sizeof(QCameraMap), 2447 str); 2448 if(value != NAME_NOT_FOUND){ 2449 updateParamEntry(KEY_RECORDING_HINT, str); 2450 setRecordingHintValue(value); 2451 return NO_ERROR; 2452 } else { 2453 ALOGE("Invalid recording hint value: %s", str); 2454 return BAD_VALUE; 2455 } 2456 } 2457 } 2458 return NO_ERROR; 2459} 2460 2461/*=========================================================================== 2462 * FUNCTION : setNoDisplayMode 2463 * 2464 * DESCRIPTION: set no display mode from user setting 2465 * 2466 * PARAMETERS : 2467 * @params : user setting parameters 2468 * 2469 * RETURN : int32_t type of status 2470 * NO_ERROR -- success 2471 * none-zero failure code 2472 *==========================================================================*/ 2473int32_t QCameraParameters::setNoDisplayMode(const QCameraParameters& params) 2474{ 2475 const char *str_val = params.get(KEY_QC_NO_DISPLAY_MODE); 2476 const char *prev_str = get(KEY_QC_NO_DISPLAY_MODE); 2477 if(str_val && strlen(str_val) > 0) { 2478 if (prev_str == NULL || strcmp(str_val, prev_str) != 0) { 2479 m_bNoDisplayMode = atoi(str_val); 2480 updateParamEntry(KEY_QC_NO_DISPLAY_MODE, str_val); 2481 m_bNeedRestart = true; 2482 } 2483 } else { 2484 m_bNoDisplayMode = false; 2485 } 2486 ALOGD("Param m_bNoDisplayMode = %d", m_bNoDisplayMode); 2487 return NO_ERROR; 2488} 2489 2490/*=========================================================================== 2491 * FUNCTION : setZslMode 2492 * 2493 * DESCRIPTION: set ZSL mode from user setting 2494 * 2495 * PARAMETERS : 2496 * @params : user setting parameters 2497 * 2498 * RETURN : int32_t type of status 2499 * NO_ERROR -- success 2500 * none-zero failure code 2501 *==========================================================================*/ 2502int32_t QCameraParameters::setZslMode(const QCameraParameters& params) 2503{ 2504 const char *str_val = params.get(KEY_QC_ZSL); 2505 const char *prev_val = get(KEY_QC_ZSL); 2506 2507 if (str_val != NULL) { 2508 if (prev_val == NULL || strcmp(str_val, prev_val) != 0) { 2509 int32_t value = lookupAttr(ON_OFF_MODES_MAP, 2510 sizeof(ON_OFF_MODES_MAP)/sizeof(QCameraMap), 2511 str_val); 2512 if (value != NAME_NOT_FOUND) { 2513 updateParamEntry(KEY_QC_ZSL, str_val); 2514 m_bZslMode = (value > 0)? true : false; 2515 2516 // ZSL mode changed, need restart preview 2517 m_bNeedRestart = true; 2518 2519 return AddSetParmEntryToBatch(m_pParamBuf, 2520 CAM_INTF_PARM_ZSL_MODE, 2521 sizeof(value), 2522 &value); 2523 } else { 2524 ALOGE("Invalid ZSL mode value: %s", str_val); 2525 return BAD_VALUE; 2526 } 2527 } 2528 } 2529 return NO_ERROR; 2530} 2531 2532/*=========================================================================== 2533 * FUNCTION : setWaveletDenoise 2534 * 2535 * DESCRIPTION: set wavelet denoise value from user setting 2536 * 2537 * PARAMETERS : 2538 * @params : user setting parameters 2539 * 2540 * RETURN : int32_t type of status 2541 * NO_ERROR -- success 2542 * none-zero failure code 2543 *==========================================================================*/ 2544int32_t QCameraParameters::setWaveletDenoise(const QCameraParameters& params) 2545{ 2546 const char *str = params.get(KEY_QC_DENOISE); 2547 const char *prev_str = get(KEY_QC_DENOISE); 2548 if (str != NULL) { 2549 if (prev_str == NULL || 2550 strcmp(str, prev_str) != 0) { 2551 return setWaveletDenoise(str); 2552 } 2553 } 2554 return NO_ERROR; 2555} 2556 2557/*=========================================================================== 2558 * FUNCTION : setCameraMode 2559 * 2560 * DESCRIPTION: set camera mode from user setting 2561 * 2562 * PARAMETERS : 2563 * @params : user setting parameters 2564 * 2565 * RETURN : int32_t type of status 2566 * NO_ERROR -- success 2567 * none-zero failure code 2568 *==========================================================================*/ 2569int32_t QCameraParameters::setCameraMode(const QCameraParameters& params) 2570{ 2571 const char *str = params.get(KEY_QC_CAMERA_MODE); 2572 if (str != NULL) { 2573 set(KEY_QC_CAMERA_MODE, str); 2574 } else { 2575 remove(KEY_QC_CAMERA_MODE); 2576 } 2577 return NO_ERROR; 2578} 2579 2580/*=========================================================================== 2581 * FUNCTION : setZslAttributes 2582 * 2583 * DESCRIPTION: set ZSL related attributes from user setting 2584 * 2585 * PARAMETERS : 2586 * @params : user setting parameters 2587 * 2588 * RETURN : int32_t type of status 2589 * NO_ERROR -- success 2590 * none-zero failure code 2591 *==========================================================================*/ 2592int32_t QCameraParameters::setZslAttributes(const QCameraParameters& params) 2593{ 2594 // TODO: may switch to pure param instead of sysprop 2595 char prop[32]; 2596 2597 const char *str = params.get(KEY_QC_ZSL_BURST_INTERVAL); 2598 if (str != NULL) { 2599 set(KEY_QC_ZSL_BURST_INTERVAL, str); 2600 } else { 2601 memset(prop, 0, sizeof(prop)); 2602 property_get("persist.camera.zsl.interval", prop, "1"); 2603 set(KEY_QC_ZSL_BURST_INTERVAL, prop); 2604 } 2605 2606 str = params.get(KEY_QC_ZSL_BURST_LOOKBACK); 2607 if (str != NULL) { 2608 set(KEY_QC_ZSL_BURST_LOOKBACK, str); 2609 } else { 2610 memset(prop, 0, sizeof(prop)); 2611 property_get("persist.camera.zsl.backlookcnt", prop, "2"); 2612 set(KEY_QC_ZSL_BURST_LOOKBACK, prop); 2613 } 2614 2615 str = params.get(KEY_QC_ZSL_QUEUE_DEPTH); 2616 if (str != NULL) { 2617 set(KEY_QC_ZSL_QUEUE_DEPTH, str); 2618 } else { 2619 memset(prop, 0, sizeof(prop)); 2620 property_get("persist.camera.zsl.queuedepth", prop, "2"); 2621 set(KEY_QC_ZSL_QUEUE_DEPTH, prop); 2622 } 2623 2624 return NO_ERROR; 2625} 2626 2627/*=========================================================================== 2628 * FUNCTION : setFlip 2629 * 2630 * DESCRIPTION: set preview/ video/ picture flip mode from user setting 2631 * 2632 * PARAMETERS : 2633 * @params : user setting parameters 2634 * 2635 * RETURN : int32_t type of status 2636 * NO_ERROR -- success 2637 * none-zero failure code 2638 *==========================================================================*/ 2639int32_t QCameraParameters::setFlip(const QCameraParameters& params) 2640{ 2641 if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_FLIP) == 0) { 2642 ALOGD("%s: flip is not supported.", __func__); 2643 return NO_ERROR; 2644 } 2645 2646 //check preview flip setting 2647 const char *str = params.get(KEY_QC_PREVIEW_FLIP); 2648 if(str != NULL){ 2649 int32_t value = lookupAttr(FLIP_MODES_MAP, 2650 sizeof(FLIP_MODES_MAP)/sizeof(QCameraMap), 2651 str); 2652 if(value != NAME_NOT_FOUND){ 2653 set(KEY_QC_PREVIEW_FLIP, str); 2654 } 2655 } 2656 2657 // check video filp setting 2658 str = params.get(KEY_QC_VIDEO_FLIP); 2659 if(str != NULL){ 2660 int32_t value = lookupAttr(FLIP_MODES_MAP, 2661 sizeof(FLIP_MODES_MAP)/sizeof(QCameraMap), 2662 str); 2663 if(value != NAME_NOT_FOUND){ 2664 set(KEY_QC_VIDEO_FLIP, str); 2665 } 2666 } 2667 2668 // check picture filp setting 2669 str = params.get(KEY_QC_SNAPSHOT_PICTURE_FLIP); 2670 if(str != NULL){ 2671 int32_t value = lookupAttr(FLIP_MODES_MAP, 2672 sizeof(FLIP_MODES_MAP)/sizeof(QCameraMap), 2673 str); 2674 if(value != NAME_NOT_FOUND){ 2675 set(KEY_QC_SNAPSHOT_PICTURE_FLIP, str); 2676 } 2677 } 2678 2679 return NO_ERROR; 2680} 2681 2682/*=========================================================================== 2683 * FUNCTION : updateParameters 2684 * 2685 * DESCRIPTION: update parameters from user setting 2686 * 2687 * PARAMETERS : 2688 * @params : user setting parameters 2689 * @needRestart : [output] if preview need restart upon setting changes 2690 * 2691 * RETURN : int32_t type of status 2692 * NO_ERROR -- success 2693 * none-zero failure code 2694 *==========================================================================*/ 2695int32_t QCameraParameters::updateParameters(QCameraParameters& params, 2696 bool &needRestart) 2697{ 2698 int32_t final_rc = NO_ERROR; 2699 int32_t rc; 2700 m_bNeedRestart = false; 2701 2702 if(initBatchUpdate(m_pParamBuf) < 0 ) { 2703 ALOGE("%s:Failed to initialize group update table",__func__); 2704 rc = BAD_TYPE; 2705 goto UPDATE_PARAM_DONE; 2706 } 2707 2708 if ((rc = setPreviewSize(params))) final_rc = rc; 2709 if ((rc = setVideoSize(params))) final_rc = rc; 2710 if ((rc = setPictureSize(params))) final_rc = rc; 2711 if ((rc = setPreviewFormat(params))) final_rc = rc; 2712 if ((rc = setPictureFormat(params))) final_rc = rc; 2713 if ((rc = setJpegThumbnailSize(params))) final_rc = rc; 2714 if ((rc = setJpegQuality(params))) final_rc = rc; 2715 if ((rc = setOrientation(params))) final_rc = rc; 2716 if ((rc = setRotation(params))) final_rc = rc; 2717 if ((rc = setNoDisplayMode(params))) final_rc = rc; 2718 if ((rc = setZslMode(params))) final_rc = rc; 2719 if ((rc = setZslAttributes(params))) final_rc = rc; 2720 if ((rc = setCameraMode(params))) final_rc = rc; 2721 if ((rc = setRecordingHint(params))) final_rc = rc; 2722 2723 if ((rc = setPreviewFpsRange(params))) final_rc = rc; 2724 if ((rc = setPreviewFrameRate(params))) final_rc = rc; 2725 if ((rc = setAutoExposure(params))) final_rc = rc; 2726 if ((rc = setEffect(params))) final_rc = rc; 2727 if ((rc = setBrightness(params))) final_rc = rc; 2728 if ((rc = setZoom(params))) final_rc = rc; 2729 if ((rc = setSharpness(params))) final_rc = rc; 2730 if ((rc = setSaturation(params))) final_rc = rc; 2731 if ((rc = setContrast(params))) final_rc = rc; 2732 if ((rc = setFocusMode(params))) final_rc = rc; 2733 if ((rc = setISOValue(params))) final_rc = rc; 2734 if ((rc = setSkinToneEnhancement(params))) final_rc = rc; 2735 if ((rc = setFlash(params))) final_rc = rc; 2736 if ((rc = setAecLock(params))) final_rc = rc; 2737 if ((rc = setAwbLock(params))) final_rc = rc; 2738 if ((rc = setLensShadeValue(params))) final_rc = rc; 2739 if ((rc = setMCEValue(params))) final_rc = rc; 2740 if ((rc = setDISValue(params))) final_rc = rc; 2741 if ((rc = setHighFrameRate(params))) final_rc = rc; 2742 if ((rc = setAntibanding(params))) final_rc = rc; 2743 if ((rc = setExposureCompensation(params))) final_rc = rc; 2744 if ((rc = setWhiteBalance(params))) final_rc = rc; 2745 if ((rc = setSceneMode(params))) final_rc = rc; 2746 if ((rc = setFocusAreas(params))) final_rc = rc; 2747 if ((rc = setMeteringAreas(params))) final_rc = rc; 2748 if ((rc = setSelectableZoneAf(params))) final_rc = rc; 2749 if ((rc = setRedeyeReduction(params))) final_rc = rc; 2750 if ((rc = setAEBracket(params))) final_rc = rc; 2751 if ((rc = setGpsLocation(params))) final_rc = rc; 2752 if ((rc = setWaveletDenoise(params))) final_rc = rc; 2753 if ((rc = setFaceRecognition(params))) final_rc = rc; 2754 if ((rc = setFlip(params))) final_rc = rc; 2755 if ((rc = setVideoHDR(params))) final_rc = rc; 2756 2757 // update live snapshot size after all other parameters are set 2758 if ((rc = setLiveSnapshotSize(params))) final_rc = rc; 2759 2760UPDATE_PARAM_DONE: 2761 needRestart = m_bNeedRestart; 2762 return final_rc; 2763} 2764 2765/*=========================================================================== 2766 * FUNCTION : commitParameters 2767 * 2768 * DESCRIPTION: commit parameter changes to backend 2769 * 2770 * PARAMETERS : none 2771 * 2772 * RETURN : int32_t type of status 2773 * NO_ERROR -- success 2774 * none-zero failure code 2775 *==========================================================================*/ 2776int32_t QCameraParameters::commitParameters() 2777{ 2778 return commitSetBatch(); 2779} 2780 2781/*=========================================================================== 2782 * FUNCTION : initDefaultParameters 2783 * 2784 * DESCRIPTION: initialize default parameters for the first time 2785 * 2786 * PARAMETERS : none 2787 * 2788 * RETURN : int32_t type of status 2789 * NO_ERROR -- success 2790 * none-zero failure code 2791 *==========================================================================*/ 2792int32_t QCameraParameters::initDefaultParameters() 2793{ 2794 if(initBatchUpdate(m_pParamBuf) < 0 ) { 2795 ALOGE("%s:Failed to initialize group update table", __func__); 2796 return BAD_TYPE; 2797 } 2798 2799 /*************************Initialize Values******************************/ 2800 // Set read only parameters from camera capability 2801 set(KEY_SMOOTH_ZOOM_SUPPORTED, 2802 m_pCapability->smooth_zoom_supported? VALUE_TRUE : VALUE_FALSE); 2803 set(KEY_ZOOM_SUPPORTED, 2804 m_pCapability->zoom_supported? VALUE_TRUE : VALUE_FALSE); 2805 set(KEY_VIDEO_SNAPSHOT_SUPPORTED, 2806 m_pCapability->video_snapshot_supported? VALUE_TRUE : VALUE_FALSE); 2807 set(KEY_VIDEO_STABILIZATION_SUPPORTED, 2808 m_pCapability->video_stablization_supported? VALUE_TRUE : VALUE_FALSE); 2809 set(KEY_AUTO_EXPOSURE_LOCK_SUPPORTED, 2810 m_pCapability->auto_exposure_lock_supported? VALUE_TRUE : VALUE_FALSE); 2811 set(KEY_AUTO_WHITEBALANCE_LOCK_SUPPORTED, 2812 m_pCapability->auto_wb_lock_supported? VALUE_TRUE : VALUE_FALSE); 2813 set(KEY_QC_SUPPORTED_CAMERA_FEATURES, 2814 m_pCapability->qcom_supported_feature_mask); 2815 set(KEY_MAX_NUM_DETECTED_FACES_HW, m_pCapability->max_num_roi); 2816 set(KEY_MAX_NUM_DETECTED_FACES_SW, m_pCapability->max_num_roi); 2817 set(KEY_QC_MAX_NUM_REQUESTED_FACES, m_pCapability->max_num_roi); 2818 // Set focal length, horizontal view angle, and vertical view angle 2819 setFloat(KEY_FOCAL_LENGTH, m_pCapability->focal_length); 2820 setFloat(KEY_HORIZONTAL_VIEW_ANGLE, m_pCapability->hor_view_angle); 2821 setFloat(KEY_VERTICAL_VIEW_ANGLE, m_pCapability->ver_view_angle); 2822 2823 // Set supported preview sizes 2824 if (m_pCapability->preview_sizes_tbl_cnt > 0 && 2825 m_pCapability->preview_sizes_tbl_cnt <= MAX_SIZES_CNT) { 2826 String8 previewSizeValues = createSizesString( 2827 m_pCapability->preview_sizes_tbl, m_pCapability->preview_sizes_tbl_cnt); 2828 set(KEY_SUPPORTED_PREVIEW_SIZES, previewSizeValues.string()); 2829 ALOGD("%s: supported preview sizes: %s", __func__, previewSizeValues.string()); 2830 // Set default preview size 2831 CameraParameters::setPreviewSize(m_pCapability->preview_sizes_tbl[0].width, 2832 m_pCapability->preview_sizes_tbl[0].height); 2833 } else { 2834 ALOGE("%s: supported preview sizes cnt is 0 or exceeds max!!!", __func__); 2835 } 2836 2837 // Set supported video sizes 2838 if (m_pCapability->video_sizes_tbl_cnt > 0 && 2839 m_pCapability->video_sizes_tbl_cnt <= MAX_SIZES_CNT) { 2840 String8 videoSizeValues = createSizesString( 2841 m_pCapability->video_sizes_tbl, m_pCapability->video_sizes_tbl_cnt); 2842 set(KEY_SUPPORTED_VIDEO_SIZES, videoSizeValues.string()); 2843 ALOGD("%s: supported video sizes: %s", __func__, videoSizeValues.string()); 2844 // Set default video size 2845 CameraParameters::setVideoSize(m_pCapability->video_sizes_tbl[0].width, 2846 m_pCapability->video_sizes_tbl[0].height); 2847 2848 //Set preferred Preview size for video 2849 String8 vSize = createSizesString(&m_pCapability->video_sizes_tbl[0], 1); 2850 set(KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO, vSize.string()); 2851 } else { 2852 ALOGE("%s: supported video sizes cnt is 0 or exceeds max!!!", __func__); 2853 } 2854 2855 // Set supported picture sizes 2856 if (m_pCapability->picture_sizes_tbl_cnt > 0 && 2857 m_pCapability->picture_sizes_tbl_cnt <= MAX_SIZES_CNT) { 2858 String8 pictureSizeValues = createSizesString( 2859 m_pCapability->picture_sizes_tbl, m_pCapability->picture_sizes_tbl_cnt); 2860 set(KEY_SUPPORTED_PICTURE_SIZES, pictureSizeValues.string()); 2861 ALOGD("%s: supported pic sizes: %s", __func__, pictureSizeValues.string()); 2862 // Set default picture size to the smallest resolution 2863 CameraParameters::setPictureSize( 2864 m_pCapability->picture_sizes_tbl[m_pCapability->picture_sizes_tbl_cnt-1].width, 2865 m_pCapability->picture_sizes_tbl[m_pCapability->picture_sizes_tbl_cnt-1].height); 2866 } else { 2867 ALOGE("%s: supported picture sizes cnt is 0 or exceeds max!!!", __func__); 2868 } 2869 2870 // Set supported thumbnail sizes 2871 String8 thumbnailSizeValues = createSizesString( 2872 THUMBNAIL_SIZES_MAP, 2873 sizeof(THUMBNAIL_SIZES_MAP)/sizeof(cam_dimension_t)); 2874 set(KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES, thumbnailSizeValues.string()); 2875 // Set default thumnail size 2876 set(KEY_JPEG_THUMBNAIL_WIDTH, THUMBNAIL_SIZES_MAP[0].width); 2877 set(KEY_JPEG_THUMBNAIL_HEIGHT, THUMBNAIL_SIZES_MAP[0].height); 2878 2879 // Set supported livesnapshot sizes 2880 if (m_pCapability->livesnapshot_sizes_tbl_cnt > 0 && 2881 m_pCapability->livesnapshot_sizes_tbl_cnt <= MAX_SIZES_CNT) { 2882 String8 liveSnpashotSizeValues = createSizesString( 2883 m_pCapability->livesnapshot_sizes_tbl, 2884 m_pCapability->livesnapshot_sizes_tbl_cnt); 2885 set(KEY_QC_SUPPORTED_LIVESNAPSHOT_SIZES, liveSnpashotSizeValues.string()); 2886 ALOGI("%s: supported live snapshot sizes: %s", __func__, liveSnpashotSizeValues.string()); 2887 m_LiveSnapshotSize = 2888 m_pCapability->livesnapshot_sizes_tbl[m_pCapability->livesnapshot_sizes_tbl_cnt-1]; 2889 } 2890 2891 // Set supported preview formats 2892 String8 previewFormatValues = createValuesString( 2893 (int *)m_pCapability->supported_preview_fmts, 2894 m_pCapability->supported_preview_fmt_cnt, 2895 PREVIEW_FORMATS_MAP, 2896 sizeof(PREVIEW_FORMATS_MAP)/sizeof(QCameraMap)); 2897 set(KEY_SUPPORTED_PREVIEW_FORMATS, previewFormatValues.string()); 2898 // Set default preview format 2899 CameraParameters::setPreviewFormat(PIXEL_FORMAT_YUV420SP); 2900 2901 // Set default Video Format 2902 set(KEY_VIDEO_FRAME_FORMAT, PIXEL_FORMAT_YUV420SP); 2903 2904 // Set supported picture formats 2905 String8 pictureTypeValues(PIXEL_FORMAT_JPEG); 2906 String8 str = createValuesString( 2907 (int *)m_pCapability->supported_raw_fmts, 2908 m_pCapability->supported_raw_fmt_cnt, 2909 PICTURE_TYPES_MAP, 2910 sizeof(PICTURE_TYPES_MAP)/sizeof(QCameraMap)); 2911 if (str.string() != NULL) { 2912 pictureTypeValues.append(","); 2913 pictureTypeValues.append(str); 2914 } 2915 2916 set(KEY_SUPPORTED_PICTURE_FORMATS, pictureTypeValues.string()); 2917 // Set default picture Format 2918 CameraParameters::setPictureFormat(PIXEL_FORMAT_JPEG); 2919 // Set raw image size 2920 char raw_size_str[32]; 2921 snprintf(raw_size_str, sizeof(raw_size_str), "%dx%d", 2922 m_pCapability->raw_dim.width, m_pCapability->raw_dim.height); 2923 set(KEY_QC_RAW_PICUTRE_SIZE, raw_size_str); 2924 2925 //set default jpeg quality and thumbnail quality 2926 set(KEY_JPEG_QUALITY, 85); 2927 set(KEY_JPEG_THUMBNAIL_QUALITY, 85); 2928 2929 // Set FPS ranges 2930 if (m_pCapability->fps_ranges_tbl_cnt > 0 && 2931 m_pCapability->fps_ranges_tbl_cnt <= MAX_SIZES_CNT) { 2932 int default_fps_index = 0; 2933 String8 fpsRangeValues = createFpsRangeString(m_pCapability->fps_ranges_tbl, 2934 m_pCapability->fps_ranges_tbl_cnt, 2935 default_fps_index); 2936 set(KEY_SUPPORTED_PREVIEW_FPS_RANGE, fpsRangeValues.string()); 2937 2938 int min_fps = 2939 int(m_pCapability->fps_ranges_tbl[default_fps_index].min_fps * 1000); 2940 int max_fps = 2941 int(m_pCapability->fps_ranges_tbl[default_fps_index].max_fps * 1000); 2942 setPreviewFpsRange(min_fps, max_fps); 2943 2944 // Set legacy preview fps 2945 String8 fpsValues = createFpsString(m_pCapability->fps_ranges_tbl, 2946 m_pCapability->fps_ranges_tbl_cnt); 2947 set(KEY_SUPPORTED_PREVIEW_FRAME_RATES, fpsValues.string()); 2948 CameraParameters::setPreviewFrameRate(max_fps); 2949 } else { 2950 ALOGE("%s: supported fps ranges cnt is 0 or exceeds max!!!", __func__); 2951 } 2952 2953 // Set supported focus modes 2954 if (m_pCapability->supported_focus_modes_cnt > 0) { 2955 String8 focusModeValues = createValuesString( 2956 (int *)m_pCapability->supported_focus_modes, 2957 m_pCapability->supported_focus_modes_cnt, 2958 FOCUS_MODES_MAP, 2959 sizeof(FOCUS_MODES_MAP)/sizeof(QCameraMap)); 2960 set(KEY_SUPPORTED_FOCUS_MODES, focusModeValues); 2961 2962 // Set default focus mode and update corresponding parameter buf 2963 const char *focusMode = lookupNameByValue(FOCUS_MODES_MAP, 2964 sizeof(FOCUS_MODES_MAP)/sizeof(QCameraMap), 2965 m_pCapability->supported_focus_modes[0]); 2966 if (focusMode != NULL) { 2967 setFocusMode(focusMode); 2968 } else { 2969 setFocusMode(FOCUS_MODE_FIXED); 2970 } 2971 } else { 2972 ALOGE("%s: supported focus modes cnt is 0!!!", __func__); 2973 } 2974 2975 // Set focus areas 2976 if (m_pCapability->max_num_focus_areas > MAX_ROI) { 2977 m_pCapability->max_num_focus_areas = MAX_ROI; 2978 } 2979 set(KEY_MAX_NUM_FOCUS_AREAS, m_pCapability->max_num_focus_areas); 2980 if (m_pCapability->max_num_focus_areas > 0) { 2981 setFocusAreas(DEFAULT_CAMERA_AREA); 2982 } 2983 2984 // Set metering areas 2985 if (m_pCapability->max_num_metering_areas > MAX_ROI) { 2986 m_pCapability->max_num_metering_areas = MAX_ROI; 2987 } 2988 set(KEY_MAX_NUM_METERING_AREAS, m_pCapability->max_num_metering_areas); 2989 if (m_pCapability->max_num_metering_areas > 0) { 2990 setMeteringAreas(DEFAULT_CAMERA_AREA); 2991 } 2992 2993 // Set Saturation 2994 set(KEY_QC_MIN_SATURATION, m_pCapability->saturation_ctrl.min_value); 2995 set(KEY_QC_MAX_SATURATION, m_pCapability->saturation_ctrl.max_value); 2996 set(KEY_QC_SATURATION_STEP, m_pCapability->saturation_ctrl.step); 2997 setSaturation(m_pCapability->saturation_ctrl.def_value); 2998 2999 // Set Sharpness 3000 set(KEY_QC_MIN_SHARPNESS, m_pCapability->sharpness_ctrl.min_value); 3001 set(KEY_QC_MAX_SHARPNESS, m_pCapability->sharpness_ctrl.max_value); 3002 set(KEY_QC_SHARPNESS_STEP, m_pCapability->sharpness_ctrl.step); 3003 setSharpness(m_pCapability->sharpness_ctrl.def_value); 3004 3005 // Set Contrast 3006 set(KEY_QC_MIN_CONTRAST, m_pCapability->contrast_ctrl.min_value); 3007 set(KEY_QC_MAX_CONTRAST, m_pCapability->contrast_ctrl.max_value); 3008 set(KEY_QC_CONTRAST_STEP, m_pCapability->contrast_ctrl.step); 3009 setContrast(m_pCapability->contrast_ctrl.def_value); 3010 3011 // Set SCE factor 3012 set(KEY_QC_MIN_SCE_FACTOR, m_pCapability->sce_ctrl.min_value); // -100 3013 set(KEY_QC_MAX_SCE_FACTOR, m_pCapability->sce_ctrl.max_value); // 100 3014 set(KEY_QC_SCE_FACTOR_STEP, m_pCapability->sce_ctrl.step); // 10 3015 setSkinToneEnhancement(m_pCapability->sce_ctrl.def_value); // 0 3016 3017 // Set Brightness 3018 set(KEY_QC_MIN_BRIGHTNESS, m_pCapability->brightness_ctrl.min_value); // 0 3019 set(KEY_QC_MAX_BRIGHTNESS, m_pCapability->brightness_ctrl.max_value); // 6 3020 set(KEY_QC_BRIGHTNESS_STEP, m_pCapability->brightness_ctrl.step); // 1 3021 setBrightness(m_pCapability->brightness_ctrl.def_value); 3022 3023 // Set Auto exposure 3024 String8 autoExposureValues = createValuesString( 3025 (int *)m_pCapability->supported_aec_modes, 3026 m_pCapability->supported_aec_modes_cnt, 3027 AUTO_EXPOSURE_MAP, 3028 sizeof(AUTO_EXPOSURE_MAP) / sizeof(QCameraMap)); 3029 set(KEY_QC_SUPPORTED_AUTO_EXPOSURE, autoExposureValues.string()); 3030 setAutoExposure(AUTO_EXPOSURE_FRAME_AVG); 3031 3032 // Set Exposure Compensation 3033 set(KEY_MAX_EXPOSURE_COMPENSATION, m_pCapability->exposure_compensation_max); // 12 3034 set(KEY_MIN_EXPOSURE_COMPENSATION, m_pCapability->exposure_compensation_min); // -12 3035 setFloat(KEY_EXPOSURE_COMPENSATION_STEP, m_pCapability->exposure_compensation_step); // 1/6 3036 setExposureCompensation(m_pCapability->exposure_compensation_default); // 0 3037 3038 // Set Antibanding 3039 String8 antibandingValues = createValuesString( 3040 (int *)m_pCapability->supported_antibandings, 3041 m_pCapability->supported_antibandings_cnt, 3042 ANTIBANDING_MODES_MAP, 3043 sizeof(ANTIBANDING_MODES_MAP) / sizeof(QCameraMap)); 3044 set(KEY_SUPPORTED_ANTIBANDING, antibandingValues); 3045 setAntibanding(ANTIBANDING_OFF); 3046 3047 // Set Effect 3048 String8 effectValues = createValuesString( 3049 (int *)m_pCapability->supported_effects, 3050 m_pCapability->supported_effects_cnt, 3051 EFFECT_MODES_MAP, 3052 sizeof(EFFECT_MODES_MAP) / sizeof(QCameraMap)); 3053 set(KEY_SUPPORTED_EFFECTS, effectValues); 3054 setEffect(EFFECT_NONE); 3055 3056 // Set WhiteBalance 3057 String8 whitebalanceValues = createValuesString( 3058 (int *)m_pCapability->supported_white_balances, 3059 m_pCapability->supported_white_balances_cnt, 3060 WHITE_BALANCE_MODES_MAP, 3061 sizeof(WHITE_BALANCE_MODES_MAP) / sizeof(QCameraMap)); 3062 set(KEY_SUPPORTED_WHITE_BALANCE, whitebalanceValues); 3063 setWhiteBalance(WHITE_BALANCE_AUTO); 3064 3065 // Set Flash mode 3066 String8 flashValues = createValuesString( 3067 (int *)m_pCapability->supported_flash_modes, 3068 m_pCapability->supported_flash_modes_cnt, 3069 FLASH_MODES_MAP, 3070 sizeof(FLASH_MODES_MAP) / sizeof(QCameraMap)); 3071 set(KEY_SUPPORTED_FLASH_MODES, flashValues); 3072 setFlash(FLASH_MODE_OFF); 3073 3074 // Set Scene Mode 3075 String8 sceneModeValues = createValuesString( 3076 (int *)m_pCapability->supported_scene_modes, 3077 m_pCapability->supported_scene_modes_cnt, 3078 SCENE_MODES_MAP, 3079 sizeof(SCENE_MODES_MAP) / sizeof(QCameraMap)); 3080 set(KEY_SUPPORTED_SCENE_MODES, sceneModeValues); 3081 setSceneMode(SCENE_MODE_AUTO); 3082 3083 // Set ISO Mode 3084 String8 isoValues = createValuesString( 3085 (int *)m_pCapability->supported_iso_modes, 3086 m_pCapability->supported_iso_modes_cnt, 3087 ISO_MODES_MAP, 3088 sizeof(ISO_MODES_MAP) / sizeof(QCameraMap)); 3089 set(KEY_QC_SUPPORTED_ISO_MODES, isoValues); 3090 setISOValue(ISO_AUTO); 3091 3092 // Set HFR 3093 String8 hfrValues = createHfrValuesString( 3094 m_pCapability->hfr_tbl, 3095 m_pCapability->hfr_tbl_cnt, 3096 HFR_MODES_MAP, 3097 sizeof(HFR_MODES_MAP) / sizeof(QCameraMap)); 3098 set(KEY_QC_SUPPORTED_VIDEO_HIGH_FRAME_RATE_MODES, hfrValues.string()); 3099 String8 hfrSizeValues = createHfrSizesString( 3100 m_pCapability->hfr_tbl, 3101 m_pCapability->hfr_tbl_cnt); 3102 set(KEY_QC_SUPPORTED_HFR_SIZES, hfrSizeValues.string()); 3103 setHighFrameRate(VIDEO_HFR_OFF); 3104 3105 // Set Focus algorithms 3106 String8 focusAlgoValues = createValuesString( 3107 (int *)m_pCapability->supported_focus_algos, 3108 m_pCapability->supported_focus_algos_cnt, 3109 FOCUS_ALGO_MAP, 3110 sizeof(FOCUS_ALGO_MAP) / sizeof(QCameraMap)); 3111 set(KEY_QC_SUPPORTED_FOCUS_ALGOS, focusAlgoValues); 3112 setSelectableZoneAf(FOCUS_ALGO_AUTO); 3113 3114 // Set Zoom Ratios 3115 if (m_pCapability->zoom_supported > 0) { 3116 String8 zoomRatioValues = createZoomRatioValuesString( 3117 m_pCapability->zoom_ratio_tbl, 3118 m_pCapability->zoom_ratio_tbl_cnt); 3119 set(KEY_ZOOM_RATIOS, zoomRatioValues); 3120 set(KEY_MAX_ZOOM, m_pCapability->zoom_ratio_tbl_cnt - 1); 3121 setZoom(0); 3122 } 3123 3124 // Set Bracketing/HDR 3125 char prop[PROPERTY_VALUE_MAX]; 3126 memset(prop, 0, sizeof(prop)); 3127 property_get("persist.capture.burst.exposures", prop, ""); 3128 if (strlen(prop) > 0) { 3129 set(KEY_QC_CAPTURE_BURST_EXPOSURE, prop); 3130 } 3131 String8 bracketingValues = createValuesStringFromMap( 3132 BRACKETING_MODES_MAP, 3133 sizeof(BRACKETING_MODES_MAP) / sizeof(QCameraMap)); 3134 set(KEY_QC_SUPPORTED_AE_BRACKET_MODES, bracketingValues); 3135 setAEBracket(AE_BRACKET_OFF); 3136 3137 // Set Denoise 3138 String8 denoiseValues = createValuesStringFromMap( 3139 DENOISE_ON_OFF_MODES_MAP, sizeof(DENOISE_ON_OFF_MODES_MAP) / sizeof(QCameraMap)); 3140 set(KEY_QC_SUPPORTED_DENOISE, denoiseValues.string()); 3141#ifdef DEFAULT_DENOISE_MODE_ON 3142 setWaveletDenoise(DENOISE_ON); 3143#else 3144 setWaveletDenoise(DENOISE_OFF); 3145#endif 3146 3147 // Set feature enable/disable 3148 String8 enableDisableValues = createValuesStringFromMap( 3149 ENABLE_DISABLE_MODES_MAP, sizeof(ENABLE_DISABLE_MODES_MAP) / sizeof(QCameraMap)); 3150 3151 // Set Lens Shading 3152 set(KEY_QC_SUPPORTED_LENSSHADE_MODES, enableDisableValues); 3153 setLensShadeValue(VALUE_ENABLE); 3154 3155 // Set MCE 3156 set(KEY_QC_SUPPORTED_MEM_COLOR_ENHANCE_MODES, enableDisableValues); 3157 setMCEValue(VALUE_ENABLE); 3158 3159 // Set DIS 3160 set(KEY_QC_SUPPORTED_DIS_MODES, enableDisableValues); 3161 setDISValue(VALUE_DISABLE); 3162 3163 // Set Histogram 3164 set(KEY_QC_SUPPORTED_HISTOGRAM_MODES, enableDisableValues); 3165 set(KEY_QC_HISTOGRAM, VALUE_DISABLE); 3166 3167 //Set Red Eye Reduction 3168 set(KEY_QC_SUPPORTED_REDEYE_REDUCTION, enableDisableValues); 3169 setRedeyeReduction(VALUE_DISABLE); 3170 3171 //Set SkinTone Enhancement 3172 set(KEY_QC_SUPPORTED_SKIN_TONE_ENHANCEMENT_MODES, enableDisableValues); 3173 3174 // Set feature on/off 3175 String8 onOffValues = createValuesStringFromMap( 3176 ON_OFF_MODES_MAP, sizeof(ON_OFF_MODES_MAP) / sizeof(QCameraMap)); 3177 3178 //Set Scene Detection 3179 set(KEY_QC_SUPPORTED_SCENE_DETECT, onOffValues); 3180 setSceneDetect(VALUE_OFF); 3181 3182 //Set Face Detection 3183 set(KEY_QC_SUPPORTED_FACE_DETECTION, onOffValues); 3184 set(KEY_QC_FACE_DETECTION, VALUE_OFF); 3185 3186 //Set Face Recognition 3187 set(KEY_QC_SUPPORTED_FACE_RECOGNITION, onOffValues); 3188 set(KEY_QC_FACE_RECOGNITION, VALUE_OFF); 3189 3190 //Set ZSL 3191 set(KEY_QC_SUPPORTED_ZSL_MODES, onOffValues); 3192#ifdef DEFAULT_ZSL_MODE_ON 3193 set(KEY_QC_ZSL, VALUE_ON); 3194 m_bZslMode = true; 3195#else 3196 set(KEY_QC_ZSL, VALUE_OFF); 3197 m_bZslMode = false; 3198#endif 3199 3200 //Set video HDR 3201 if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_VIDEO_HDR) > 0) { 3202 set(KEY_QC_SUPPORTED_VIDEO_HDR_MODES, onOffValues); 3203 set(KEY_QC_VIDEO_HDR, VALUE_OFF); 3204 } 3205 3206 //Set Touch AF/AEC 3207 String8 touchValues = createValuesStringFromMap( 3208 TOUCH_AF_AEC_MODES_MAP, sizeof(TOUCH_AF_AEC_MODES_MAP) / sizeof(QCameraMap)); 3209 3210 set(KEY_QC_SUPPORTED_TOUCH_AF_AEC, touchValues); 3211 set(KEY_QC_TOUCH_AF_AEC, TOUCH_AF_AEC_OFF); 3212 3213 //set flip mode 3214 if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_FLIP) > 0) { 3215 String8 flipModes = createValuesStringFromMap( 3216 FLIP_MODES_MAP, sizeof(FLIP_MODES_MAP) / sizeof(QCameraMap)); 3217 set(KEY_QC_SUPPORTED_FLIP_MODES, flipModes); 3218 set(KEY_QC_PREVIEW_FLIP, FLIP_MODE_OFF); 3219 set(KEY_QC_VIDEO_FLIP, FLIP_MODE_OFF); 3220 set(KEY_QC_SNAPSHOT_PICTURE_FLIP, FLIP_MODE_OFF); 3221 } 3222 3223 // Set default Auto Exposure lock value 3224 setAecLock(VALUE_FALSE); 3225 3226 // Set default AWB_LOCK lock value 3227 setAwbLock(VALUE_FALSE); 3228 3229 // Set default Camera mode 3230 set(KEY_QC_CAMERA_MODE, 0); 3231 3232 // TODO: hardcode for now until mctl add support for min_num_pp_bufs 3233 m_pCapability->min_num_pp_bufs = 3; 3234 3235 int32_t rc = commitParameters(); 3236 if (rc == NO_ERROR) { 3237 rc = setNumOfSnapshot(); 3238 } 3239 return rc; 3240} 3241 3242/*=========================================================================== 3243 * FUNCTION : init 3244 * 3245 * DESCRIPTION: initialize parameter obj 3246 * 3247 * PARAMETERS : 3248 * @capabilities : ptr to camera capabilities 3249 * @mmops : ptr to memory ops table for mapping/unmapping 3250 * 3251 * RETURN : int32_t type of status 3252 * NO_ERROR -- success 3253 * none-zero failure code 3254 *==========================================================================*/ 3255int32_t QCameraParameters::init(cam_capability_t *capabilities, mm_camera_vtbl_t *mmOps) 3256{ 3257 int32_t rc = NO_ERROR; 3258 3259 m_pCapability = capabilities; 3260 m_pCamOpsTbl = mmOps; 3261 3262 //Allocate Set Param Buffer 3263 m_pParamHeap = new QCameraHeapMemory(); 3264 rc = m_pParamHeap->allocate(1, sizeof(parm_buffer_t)); 3265 if(rc != OK) { 3266 rc = NO_MEMORY; 3267 ALOGE("Failed to allocate SETPARM Heap memory"); 3268 goto TRANS_INIT_ERROR1; 3269 } 3270 3271 //Map memory for parameters buffer 3272 rc = m_pCamOpsTbl->ops->map_buf(m_pCamOpsTbl->camera_handle, 3273 CAM_MAPPING_BUF_TYPE_PARM_BUF, 3274 m_pParamHeap->getFd(0), 3275 sizeof(parm_buffer_t)); 3276 if(rc < 0) { 3277 ALOGE("%s:failed to map SETPARM buffer",__func__); 3278 rc = FAILED_TRANSACTION; 3279 goto TRANS_INIT_ERROR2; 3280 } 3281 m_pParamBuf = (parm_buffer_t*) DATA_PTR(m_pParamHeap,0); 3282 3283 initDefaultParameters(); 3284 3285 goto TRANS_INIT_DONE; 3286 3287TRANS_INIT_ERROR2: 3288 m_pParamHeap->deallocate(); 3289 3290TRANS_INIT_ERROR1: 3291 delete m_pParamHeap; 3292 m_pParamHeap = NULL; 3293 3294TRANS_INIT_DONE: 3295 return rc; 3296} 3297 3298/*=========================================================================== 3299 * FUNCTION : deinit 3300 * 3301 * DESCRIPTION: deinitialize 3302 * 3303 * PARAMETERS : none 3304 * 3305 * RETURN : none 3306 *==========================================================================*/ 3307void QCameraParameters::deinit() 3308{ 3309 //clear all entries in the map 3310 String8 emptyStr; 3311 QCameraParameters::unflatten(emptyStr); 3312 3313 if (NULL != m_pCamOpsTbl) { 3314 m_pCamOpsTbl->ops->unmap_buf( 3315 m_pCamOpsTbl->camera_handle, 3316 CAM_MAPPING_BUF_TYPE_PARM_BUF); 3317 m_pCamOpsTbl = NULL; 3318 } 3319 m_pCapability = NULL; 3320 if (NULL != m_pParamHeap) { 3321 m_pParamHeap->deallocate(); 3322 delete m_pParamHeap; 3323 m_pParamHeap = NULL; 3324 m_pParamBuf = NULL; 3325 } 3326 3327 m_tempMap.clear(); 3328} 3329 3330/*=========================================================================== 3331 * FUNCTION : parse_pair 3332 * 3333 * DESCRIPTION: helper function to parse string like "640x480" or "10000,20000" 3334 * 3335 * PARAMETERS : 3336 * @str : input string to be parse 3337 * @first : [output] first value of the pair 3338 * @second : [output] second value of the pair 3339 * @delim : [input] delimeter to seperate the pair 3340 * @endptr : [output] ptr to the end of the pair string 3341 * 3342 * RETURN : int32_t type of status 3343 * NO_ERROR -- success 3344 * none-zero failure code 3345 *==========================================================================*/ 3346int32_t QCameraParameters::parse_pair(const char *str, 3347 int *first, 3348 int *second, 3349 char delim, 3350 char **endptr = NULL) 3351{ 3352 // Find the first integer. 3353 char *end; 3354 int w = (int)strtol(str, &end, 10); 3355 // If a delimeter does not immediately follow, give up. 3356 if (*end != delim) { 3357 ALOGE("Cannot find delimeter (%c) in str=%s", delim, str); 3358 return BAD_VALUE; 3359 } 3360 3361 // Find the second integer, immediately after the delimeter. 3362 int h = (int)strtol(end+1, &end, 10); 3363 3364 *first = w; 3365 *second = h; 3366 3367 if (endptr) { 3368 *endptr = end; 3369 } 3370 3371 return NO_ERROR; 3372} 3373 3374/*=========================================================================== 3375 * FUNCTION : parseSizesList 3376 * 3377 * DESCRIPTION: helper function to parse string containing sizes 3378 * 3379 * PARAMETERS : 3380 * @sizesStr: [input] input string to be parse 3381 * @sizes : [output] reference to store parsed sizes 3382 * 3383 * RETURN : none 3384 *==========================================================================*/ 3385void QCameraParameters::parseSizesList(const char *sizesStr, Vector<Size> &sizes) 3386{ 3387 if (sizesStr == 0) { 3388 return; 3389 } 3390 3391 char *sizeStartPtr = (char *)sizesStr; 3392 3393 while (true) { 3394 int width, height; 3395 int success = parse_pair(sizeStartPtr, &width, &height, 'x', 3396 &sizeStartPtr); 3397 if (success == -1 || (*sizeStartPtr != ',' && *sizeStartPtr != '\0')) { 3398 ALOGE("Picture sizes string \"%s\" contains invalid character.", sizesStr); 3399 return; 3400 } 3401 sizes.push(Size(width, height)); 3402 3403 if (*sizeStartPtr == '\0') { 3404 return; 3405 } 3406 sizeStartPtr++; 3407 } 3408} 3409 3410/*=========================================================================== 3411 * FUNCTION : getSupportedHfrSizes 3412 * 3413 * DESCRIPTION: return supported HFR sizes 3414 * 3415 * PARAMETERS : 3416 * @sizes : [output] reference to a vector storing supported HFR sizes 3417 * 3418 * RETURN : none 3419 *==========================================================================*/ 3420void QCameraParameters::getSupportedHfrSizes(Vector<Size> &sizes) 3421{ 3422 const char *hfrSizesStr = get(KEY_QC_SUPPORTED_HFR_SIZES); 3423 parseSizesList(hfrSizesStr, sizes); 3424} 3425 3426/*=========================================================================== 3427 * FUNCTION : adjustPreviewFpsRanges 3428 * 3429 * DESCRIPTION: adjust preview FPS ranges 3430 * according to external events 3431 * 3432 * PARAMETERS : 3433 * @minFPS : min FPS value 3434 * @maxFPS : max FPS value 3435 * 3436 * RETURN : int32_t type of status 3437 * NO_ERROR -- success 3438 * none-zero failure code 3439 *==========================================================================*/ 3440int32_t QCameraParameters::adjustPreviewFpsRange(cam_fps_range_t *fpsRange) 3441{ 3442 if ( fpsRange == NULL ) { 3443 return BAD_VALUE; 3444 } 3445 3446 int32_t rc = initBatchUpdate(m_pParamBuf); 3447 if ( rc != NO_ERROR ) { 3448 ALOGE("%s:Failed to initialize group update table", __func__); 3449 return rc; 3450 } 3451 3452 rc = AddSetParmEntryToBatch(m_pParamBuf, 3453 CAM_INTF_PARM_FPS_RANGE, 3454 sizeof(cam_fps_range_t), 3455 fpsRange); 3456 if ( rc != NO_ERROR ) { 3457 ALOGE("%s: Parameters batch failed",__func__); 3458 return rc; 3459 } 3460 3461 rc = commitSetBatch(); 3462 if ( rc != NO_ERROR ) { 3463 ALOGE("%s:Failed to commit batch parameters", __func__); 3464 return rc; 3465 } 3466 3467 return rc; 3468} 3469 3470/*=========================================================================== 3471 * FUNCTION : setPreviewFpsRanges 3472 * 3473 * DESCRIPTION: set preview FPS ranges 3474 * 3475 * PARAMETERS : 3476 * @minFPS : min FPS value 3477 * @maxFPS : max FPS value 3478 * 3479 * RETURN : int32_t type of status 3480 * NO_ERROR -- success 3481 * none-zero failure code 3482 *==========================================================================*/ 3483int32_t QCameraParameters::setPreviewFpsRange(int minFPS, int maxFPS) 3484{ 3485 char str[32]; 3486 snprintf(str, sizeof(str), "%d,%d", minFPS, maxFPS); 3487 ALOGD("%s: Setting preview fps range %s", __func__, str); 3488 updateParamEntry(KEY_PREVIEW_FPS_RANGE, str); 3489 cam_fps_range_t fps_range = {(float)(minFPS / 1000.0), (float)(maxFPS / 1000.0)}; 3490 return AddSetParmEntryToBatch(m_pParamBuf, 3491 CAM_INTF_PARM_FPS_RANGE, 3492 sizeof(cam_fps_range_t), 3493 &fps_range); 3494} 3495 3496/*=========================================================================== 3497 * FUNCTION : setAutoExposure 3498 * 3499 * DESCRIPTION: set auto exposure 3500 * 3501 * PARAMETERS : 3502 * @autoExp : auto exposure value string 3503 * 3504 * RETURN : int32_t type of status 3505 * NO_ERROR -- success 3506 * none-zero failure code 3507 *==========================================================================*/ 3508int32_t QCameraParameters::setAutoExposure(const char *autoExp) 3509{ 3510 if (autoExp != NULL) { 3511 int32_t value = lookupAttr(AUTO_EXPOSURE_MAP, 3512 sizeof(AUTO_EXPOSURE_MAP)/sizeof(AUTO_EXPOSURE_MAP[0]), 3513 autoExp); 3514 if (value != NAME_NOT_FOUND) { 3515 ALOGD("%s: Setting auto exposure %s", __func__, autoExp); 3516 updateParamEntry(KEY_QC_AUTO_EXPOSURE, autoExp); 3517 return AddSetParmEntryToBatch(m_pParamBuf, 3518 CAM_INTF_PARM_AEC_ALGO_TYPE, 3519 sizeof(value), 3520 &value); 3521 } 3522 } 3523 ALOGE("Invalid auto exposure value: %s", (autoExp == NULL) ? "NULL" : autoExp); 3524 return BAD_VALUE; 3525} 3526 3527/*=========================================================================== 3528 * FUNCTION : setEffect 3529 * 3530 * DESCRIPTION: set effect 3531 * 3532 * PARAMETERS : 3533 * @effect : effect value string 3534 * 3535 * RETURN : int32_t type of status 3536 * NO_ERROR -- success 3537 * none-zero failure code 3538 *==========================================================================*/ 3539int32_t QCameraParameters::setEffect(const char *effect) 3540{ 3541 if (effect != NULL) { 3542 int32_t value = lookupAttr(EFFECT_MODES_MAP, 3543 sizeof(EFFECT_MODES_MAP)/sizeof(QCameraMap), 3544 effect); 3545 if (value != NAME_NOT_FOUND) { 3546 ALOGD("%s: Setting effect %s", __func__, effect); 3547 updateParamEntry(KEY_EFFECT, effect); 3548 return AddSetParmEntryToBatch(m_pParamBuf, 3549 CAM_INTF_PARM_EFFECT, 3550 sizeof(value), 3551 &value); 3552 } 3553 } 3554 ALOGE("Invalid effect value: %s", (effect == NULL) ? "NULL" : effect); 3555 return BAD_VALUE; 3556} 3557 3558/*=========================================================================== 3559 * FUNCTION : setBrightness 3560 * 3561 * DESCRIPTION: set brightness control value 3562 * 3563 * PARAMETERS : 3564 * @brightness : brightness control value 3565 * 3566 * RETURN : int32_t type of status 3567 * NO_ERROR -- success 3568 * none-zero failure code 3569 *==========================================================================*/ 3570int32_t QCameraParameters::setBrightness(int brightness) 3571{ 3572 char val[16]; 3573 sprintf(val, "%d", brightness); 3574 updateParamEntry(KEY_QC_BRIGHTNESS, val); 3575 3576 int32_t value = brightness; 3577 ALOGD("%s: Setting brightness %s", __func__, val); 3578 return AddSetParmEntryToBatch(m_pParamBuf, 3579 CAM_INTF_PARM_BRIGHTNESS, 3580 sizeof(value), 3581 &value); 3582} 3583 3584/*=========================================================================== 3585 * FUNCTION : setFocusMode 3586 * 3587 * DESCRIPTION: set focus mode 3588 * 3589 * PARAMETERS : 3590 * @focusMode : focus mode value string 3591 * 3592 * RETURN : int32_t type of status 3593 * NO_ERROR -- success 3594 * none-zero failure code 3595 *==========================================================================*/ 3596int32_t QCameraParameters::setFocusMode(const char *focusMode) 3597{ 3598 if (focusMode != NULL) { 3599 int32_t value = lookupAttr(FOCUS_MODES_MAP, 3600 sizeof(FOCUS_MODES_MAP)/sizeof(QCameraMap), 3601 focusMode); 3602 if (value != NAME_NOT_FOUND) { 3603 ALOGD("%s: Setting focus mode %s", __func__, focusMode); 3604 mFocusMode = (cam_focus_mode_type)value; 3605 3606 // reset need lock CAF flag 3607 m_bNeedLockCAF = false; 3608 m_bCAFLocked = false; 3609 m_bAFRunning = false; 3610 3611 updateParamEntry(KEY_FOCUS_MODE, focusMode); 3612 return AddSetParmEntryToBatch(m_pParamBuf, 3613 CAM_INTF_PARM_FOCUS_MODE, 3614 sizeof(value), 3615 &value); 3616 } 3617 } 3618 ALOGE("Invalid focus mode value: %s", (focusMode == NULL) ? "NULL" : focusMode); 3619 return BAD_VALUE; 3620} 3621 3622/*=========================================================================== 3623 * FUNCTION : setSharpness 3624 * 3625 * DESCRIPTION: set sharpness control value 3626 * 3627 * PARAMETERS : 3628 * @sharpness : sharpness control value 3629 * 3630 * RETURN : int32_t type of status 3631 * NO_ERROR -- success 3632 * none-zero failure code 3633 *==========================================================================*/ 3634int32_t QCameraParameters::setSharpness(int sharpness) 3635{ 3636 char val[16]; 3637 sprintf(val, "%d", sharpness); 3638 updateParamEntry(KEY_QC_SHARPNESS, val); 3639 ALOGD("%s: Setting sharpness %s", __func__, val); 3640 3641 int32_t value = sharpness; 3642 return AddSetParmEntryToBatch(m_pParamBuf, 3643 CAM_INTF_PARM_SHARPNESS, 3644 sizeof(value), 3645 &value); 3646} 3647 3648/*=========================================================================== 3649 * FUNCTION : setSkinToneEnhancement 3650 * 3651 * DESCRIPTION: set skin tone enhancement value 3652 * 3653 * PARAMETERS : 3654 * @sceFactore : skin tone enhancement factor value 3655 * 3656 * RETURN : int32_t type of status 3657 * NO_ERROR -- success 3658 * none-zero failure code 3659 *==========================================================================*/ 3660int32_t QCameraParameters::setSkinToneEnhancement(int sceFactor) 3661{ 3662 char val[16]; 3663 sprintf(val, "%d", sceFactor); 3664 updateParamEntry(KEY_QC_SCE_FACTOR, val); 3665 ALOGD("%s: Setting skintone enhancement %s", __func__, val); 3666 3667 int32_t value = sceFactor; 3668 return AddSetParmEntryToBatch(m_pParamBuf, 3669 CAM_INTF_PARM_SCE_FACTOR, 3670 sizeof(value), 3671 &value); 3672} 3673 3674/*=========================================================================== 3675 * FUNCTION : setSaturation 3676 * 3677 * DESCRIPTION: set saturation control value 3678 * 3679 * PARAMETERS : 3680 * @saturation : saturation control value 3681 * 3682 * RETURN : int32_t type of status 3683 * NO_ERROR -- success 3684 * none-zero failure code 3685 *==========================================================================*/ 3686int32_t QCameraParameters::setSaturation(int saturation) 3687{ 3688 char val[16]; 3689 sprintf(val, "%d", saturation); 3690 updateParamEntry(KEY_QC_SATURATION, val); 3691 ALOGD("%s: Setting saturation %s", __func__, val); 3692 3693 int32_t value = saturation; 3694 return AddSetParmEntryToBatch(m_pParamBuf, 3695 CAM_INTF_PARM_SATURATION, 3696 sizeof(value), 3697 &value); 3698} 3699 3700/*=========================================================================== 3701 * FUNCTION : setContrast 3702 * 3703 * DESCRIPTION: set contrast control value 3704 * 3705 * PARAMETERS : 3706 * @contrast : contrast control value 3707 * 3708 * RETURN : int32_t type of status 3709 * NO_ERROR -- success 3710 * none-zero failure code 3711 *==========================================================================*/ 3712int32_t QCameraParameters::setContrast(int contrast) 3713{ 3714 char val[16]; 3715 sprintf(val, "%d", contrast); 3716 updateParamEntry(KEY_QC_CONTRAST, val); 3717 ALOGD("%s: Setting contrast %s", __func__, val); 3718 3719 int32_t value = contrast; 3720 return AddSetParmEntryToBatch(m_pParamBuf, 3721 CAM_INTF_PARM_CONTRAST, 3722 sizeof(value), 3723 &value); 3724} 3725 3726/*=========================================================================== 3727 * FUNCTION : setSceneDetect 3728 * 3729 * DESCRIPTION: set scenen detect value 3730 * 3731 * PARAMETERS : 3732 * @sceneDetect : scene detect value string 3733 * 3734 * RETURN : int32_t type of status 3735 * NO_ERROR -- success 3736 * none-zero failure code 3737 *==========================================================================*/ 3738int32_t QCameraParameters::setSceneDetect(const char *sceneDetect) 3739{ 3740 if (sceneDetect != NULL) { 3741 int32_t value = lookupAttr(ON_OFF_MODES_MAP, 3742 sizeof(ON_OFF_MODES_MAP)/sizeof(QCameraMap), 3743 sceneDetect); 3744 if (value != NAME_NOT_FOUND) { 3745 ALOGD("%s: Setting Scene Detect %s", __func__, sceneDetect); 3746 updateParamEntry(KEY_QC_SCENE_DETECT, sceneDetect); 3747 return AddSetParmEntryToBatch(m_pParamBuf, 3748 CAM_INTF_PARM_ASD_ENABLE, 3749 sizeof(value), 3750 &value); 3751 } 3752 } 3753 ALOGE("Invalid Scene Detect value: %s", 3754 (sceneDetect == NULL) ? "NULL" : sceneDetect); 3755 return BAD_VALUE; 3756} 3757 3758/*=========================================================================== 3759 * FUNCTION : setVideoHDR 3760 * 3761 * DESCRIPTION: set video HDR value 3762 * 3763 * PARAMETERS : 3764 * @videoHDR : svideo HDR value string 3765 * 3766 * RETURN : int32_t type of status 3767 * NO_ERROR -- success 3768 * none-zero failure code 3769 *==========================================================================*/ 3770int32_t QCameraParameters::setVideoHDR(const char *videoHDR) 3771{ 3772 if (videoHDR != NULL) { 3773 int32_t value = lookupAttr(ON_OFF_MODES_MAP, 3774 sizeof(ON_OFF_MODES_MAP)/sizeof(QCameraMap), 3775 videoHDR); 3776 if (value != NAME_NOT_FOUND) { 3777 ALOGD("%s: Setting Video HDR %s", __func__, videoHDR); 3778 updateParamEntry(KEY_QC_VIDEO_HDR, videoHDR); 3779 return AddSetParmEntryToBatch(m_pParamBuf, 3780 CAM_INTF_PARM_VIDEO_HDR, 3781 sizeof(value), 3782 &value); 3783 } 3784 } 3785 ALOGE("Invalid Video HDR value: %s", 3786 (videoHDR == NULL) ? "NULL" : videoHDR); 3787 return BAD_VALUE; 3788} 3789 3790/*=========================================================================== 3791 * FUNCTION : setFaceRecognition 3792 * 3793 * DESCRIPTION: set face recognition value 3794 * 3795 * PARAMETERS : 3796 * @faceRecog : face recognition value string 3797 * @maxFaces : number of max faces to be detected/recognized 3798 * 3799 * RETURN : int32_t type of status 3800 * NO_ERROR -- success 3801 * none-zero failure code 3802 *==========================================================================*/ 3803int32_t QCameraParameters::setFaceRecognition(const char *faceRecog, int maxFaces) 3804{ 3805 if (faceRecog != NULL) { 3806 int32_t value = lookupAttr(ON_OFF_MODES_MAP, 3807 sizeof(ON_OFF_MODES_MAP)/sizeof(QCameraMap), 3808 faceRecog); 3809 if (value != NAME_NOT_FOUND) { 3810 ALOGD("%s: Setting face recognition %s", __func__, faceRecog); 3811 updateParamEntry(KEY_QC_FACE_RECOGNITION, faceRecog); 3812 3813 int faceProcMask = m_nFaceProcMask; 3814 if (value > 0) { 3815 faceProcMask |= CAM_FACE_PROCESS_MASK_RECOGNITION; 3816 } else { 3817 faceProcMask &= ~CAM_FACE_PROCESS_MASK_RECOGNITION; 3818 } 3819 3820 if(m_nFaceProcMask == faceProcMask) { 3821 ALOGD("%s: face process mask not changed, no ops here", __func__); 3822 return NO_ERROR; 3823 } 3824 m_nFaceProcMask = faceProcMask; 3825 ALOGD("%s: FaceProcMask -> %d", __func__, m_nFaceProcMask); 3826 3827 // set parm for face process 3828 cam_fd_set_parm_t fd_set_parm; 3829 memset(&fd_set_parm, 0, sizeof(cam_fd_set_parm_t)); 3830 fd_set_parm.fd_mode = m_nFaceProcMask; 3831 fd_set_parm.num_fd = maxFaces; 3832 3833 return AddSetParmEntryToBatch(m_pParamBuf, 3834 CAM_INTF_PARM_FD, 3835 sizeof(fd_set_parm), 3836 &fd_set_parm); 3837 } 3838 } 3839 ALOGE("Invalid face recognition value: %s", (faceRecog == NULL) ? "NULL" : faceRecog); 3840 return BAD_VALUE; 3841} 3842 3843/*=========================================================================== 3844 * FUNCTION : setZoom 3845 * 3846 * DESCRIPTION: set zoom level 3847 * 3848 * PARAMETERS : 3849 * @zoom_level : zoom level 3850 * 3851 * RETURN : int32_t type of status 3852 * NO_ERROR -- success 3853 * none-zero failure code 3854 *==========================================================================*/ 3855int32_t QCameraParameters::setZoom(int zoom_level) 3856{ 3857 char val[16]; 3858 sprintf(val, "%d", zoom_level); 3859 updateParamEntry(KEY_ZOOM, val); 3860 3861 return AddSetParmEntryToBatch(m_pParamBuf, 3862 CAM_INTF_PARM_ZOOM, 3863 sizeof(zoom_level), 3864 &zoom_level); 3865} 3866 3867/*=========================================================================== 3868 * FUNCTION : setISOValue 3869 * 3870 * DESCRIPTION: set ISO value 3871 * 3872 * PARAMETERS : 3873 * @isoValue : ISO value string 3874 * 3875 * RETURN : int32_t type of status 3876 * NO_ERROR -- success 3877 * none-zero failure code 3878 *==========================================================================*/ 3879int32_t QCameraParameters::setISOValue(const char *isoValue) 3880{ 3881 if (isoValue != NULL) { 3882 int32_t value = lookupAttr(ISO_MODES_MAP, 3883 sizeof(ISO_MODES_MAP)/sizeof(QCameraMap), 3884 isoValue); 3885 if (value != NAME_NOT_FOUND) { 3886 ALOGD("%s: Setting ISO value %s", __func__, isoValue); 3887 updateParamEntry(KEY_QC_ISO_MODE, isoValue); 3888 return AddSetParmEntryToBatch(m_pParamBuf, 3889 CAM_INTF_PARM_ISO, 3890 sizeof(value), 3891 &value); 3892 } 3893 } 3894 ALOGE("Invalid ISO value: %s", 3895 (isoValue == NULL) ? "NULL" : isoValue); 3896 return BAD_VALUE; 3897} 3898 3899/*=========================================================================== 3900 * FUNCTION : setFlash 3901 * 3902 * DESCRIPTION: set f;ash mode 3903 * 3904 * PARAMETERS : 3905 * @flashStr : LED flash mode value string 3906 * 3907 * RETURN : int32_t type of status 3908 * NO_ERROR -- success 3909 * none-zero failure code 3910 *==========================================================================*/ 3911int32_t QCameraParameters::setFlash(const char *flashStr) 3912{ 3913 if (flashStr != NULL) { 3914 int32_t value = lookupAttr(FLASH_MODES_MAP, 3915 sizeof(FLASH_MODES_MAP)/sizeof(QCameraMap), 3916 flashStr); 3917 if (value != NAME_NOT_FOUND) { 3918 ALOGD("%s: Setting Flash value %s", __func__, flashStr); 3919 updateParamEntry(KEY_FLASH_MODE, flashStr); 3920 return AddSetParmEntryToBatch(m_pParamBuf, 3921 CAM_INTF_PARM_LED_MODE, 3922 sizeof(value), 3923 &value); 3924 } 3925 } 3926 ALOGE("Invalid flash value: %s", (flashStr == NULL) ? "NULL" : flashStr); 3927 return BAD_VALUE; 3928} 3929 3930/*=========================================================================== 3931 * FUNCTION : setAecLock 3932 * 3933 * DESCRIPTION: set AEC lock value 3934 * 3935 * PARAMETERS : 3936 * @aecLockStr : AEC lock value string 3937 * 3938 * RETURN : int32_t type of status 3939 * NO_ERROR -- success 3940 * none-zero failure code 3941 *==========================================================================*/ 3942int32_t QCameraParameters::setAecLock(const char *aecLockStr) 3943{ 3944 if (aecLockStr != NULL) { 3945 int32_t value = lookupAttr(TRUE_FALSE_MODES_MAP, 3946 sizeof(TRUE_FALSE_MODES_MAP)/sizeof(QCameraMap), 3947 aecLockStr); 3948 if (value != NAME_NOT_FOUND) { 3949 ALOGD("%s: Setting AECLock value %s", __func__, aecLockStr); 3950 updateParamEntry(KEY_AUTO_EXPOSURE_LOCK, aecLockStr); 3951 return AddSetParmEntryToBatch(m_pParamBuf, 3952 CAM_INTF_PARM_AEC_LOCK, 3953 sizeof(value), 3954 &value); 3955 } 3956 } 3957 ALOGE("Invalid AECLock value: %s", (aecLockStr == NULL) ? "NULL" : aecLockStr); 3958 return BAD_VALUE; 3959} 3960 3961/*=========================================================================== 3962 * FUNCTION : setAwbLock 3963 * 3964 * DESCRIPTION: set AWB lock value 3965 * 3966 * PARAMETERS : 3967 * @awbLockStr : AWB lock value string 3968 * 3969 * RETURN : int32_t type of status 3970 * NO_ERROR -- success 3971 * none-zero failure code 3972 *==========================================================================*/ 3973int32_t QCameraParameters::setAwbLock(const char *awbLockStr) 3974{ 3975 if (awbLockStr != NULL) { 3976 int32_t value = lookupAttr(TRUE_FALSE_MODES_MAP, 3977 sizeof(TRUE_FALSE_MODES_MAP)/sizeof(QCameraMap), 3978 awbLockStr); 3979 if (value != NAME_NOT_FOUND) { 3980 ALOGD("%s: Setting AWBLock value %s", __func__, awbLockStr); 3981 updateParamEntry(KEY_AUTO_WHITEBALANCE_LOCK, awbLockStr); 3982 return AddSetParmEntryToBatch(m_pParamBuf, 3983 CAM_INTF_PARM_AWB_LOCK, 3984 sizeof(value), 3985 &value); 3986 } 3987 } 3988 ALOGE("Invalid AWBLock value: %s", (awbLockStr == NULL) ? "NULL" : awbLockStr); 3989 return BAD_VALUE; 3990} 3991 3992/*=========================================================================== 3993 * FUNCTION : setMCEValue 3994 * 3995 * DESCRIPTION: set memory color enhancement value 3996 * 3997 * PARAMETERS : 3998 * @mceStr : MCE value string 3999 * 4000 * RETURN : int32_t type of status 4001 * NO_ERROR -- success 4002 * none-zero failure code 4003 *==========================================================================*/ 4004int32_t QCameraParameters::setMCEValue(const char *mceStr) 4005{ 4006 if (mceStr != NULL) { 4007 int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP, 4008 sizeof(ENABLE_DISABLE_MODES_MAP)/sizeof(QCameraMap), 4009 mceStr); 4010 if (value != NAME_NOT_FOUND) { 4011 ALOGD("%s: Setting AWBLock value %s", __func__, mceStr); 4012 updateParamEntry(KEY_QC_MEMORY_COLOR_ENHANCEMENT, mceStr); 4013 return AddSetParmEntryToBatch(m_pParamBuf, 4014 CAM_INTF_PARM_MCE, 4015 sizeof(value), 4016 &value); 4017 } 4018 } 4019 ALOGE("Invalid MCE value: %s", (mceStr == NULL) ? "NULL" : mceStr); 4020 return BAD_VALUE; 4021} 4022 4023/*=========================================================================== 4024 * FUNCTION : setDISValue 4025 * 4026 * DESCRIPTION: set DIS value 4027 * 4028 * PARAMETERS : 4029 * @disStr : DIS value string 4030 * 4031 * RETURN : int32_t type of status 4032 * NO_ERROR -- success 4033 * none-zero failure code 4034 *==========================================================================*/ 4035int32_t QCameraParameters::setDISValue(const char *disStr) 4036{ 4037 if (disStr != NULL) { 4038 int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP, 4039 sizeof(ENABLE_DISABLE_MODES_MAP)/sizeof(QCameraMap), 4040 disStr); 4041 if (value != NAME_NOT_FOUND) { 4042 ALOGD("%s: Setting DIS value %s", __func__, disStr); 4043 updateParamEntry(KEY_QC_DIS, disStr); 4044 return AddSetParmEntryToBatch(m_pParamBuf, 4045 CAM_INTF_PARM_DIS_ENABLE, 4046 sizeof(value), 4047 &value); 4048 } 4049 } 4050 ALOGE("Invalid DIS value: %s", (disStr == NULL) ? "NULL" : disStr); 4051 return BAD_VALUE; 4052} 4053 4054/*=========================================================================== 4055 * FUNCTION : setHighFrameRate 4056 * 4057 * DESCRIPTION: set high frame rate 4058 * 4059 * PARAMETERS : 4060 * @hfrStr : HFR value string 4061 * 4062 * RETURN : int32_t type of status 4063 * NO_ERROR -- success 4064 * none-zero failure code 4065 *==========================================================================*/ 4066int32_t QCameraParameters::setHighFrameRate(const char *hfrStr) 4067{ 4068 if (hfrStr != NULL) { 4069 int32_t value = lookupAttr(HFR_MODES_MAP, 4070 sizeof(HFR_MODES_MAP)/sizeof(QCameraMap), 4071 hfrStr); 4072 if (value != NAME_NOT_FOUND) { 4073 // HFR value changed, need to restart preview 4074 m_bNeedRestart = true; 4075 // Set HFR value 4076 ALOGD("%s: Setting HFR value %s", __func__, hfrStr); 4077 updateParamEntry(KEY_QC_VIDEO_HIGH_FRAME_RATE, hfrStr); 4078 return AddSetParmEntryToBatch(m_pParamBuf, 4079 CAM_INTF_PARM_HFR, 4080 sizeof(value), 4081 &value); 4082 } 4083 } 4084 ALOGE("Invalid HFR value: %s", (hfrStr == NULL) ? "NULL" : hfrStr); 4085 return BAD_VALUE; 4086} 4087 4088/*=========================================================================== 4089 * FUNCTION : setLensShadeValue 4090 * 4091 * DESCRIPTION: set lens shade value 4092 * 4093 * PARAMETERS : 4094 * @lensSahdeStr : lens shade value string 4095 * 4096 * RETURN : int32_t type of status 4097 * NO_ERROR -- success 4098 * none-zero failure code 4099 *==========================================================================*/ 4100int32_t QCameraParameters::setLensShadeValue(const char *lensShadeStr) 4101{ 4102 if (lensShadeStr != NULL) { 4103 int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP, 4104 sizeof(ENABLE_DISABLE_MODES_MAP)/sizeof(QCameraMap), 4105 lensShadeStr); 4106 if (value != NAME_NOT_FOUND) { 4107 ALOGD("%s: Setting LensShade value %s", __func__, lensShadeStr); 4108 updateParamEntry(KEY_QC_LENSSHADE, lensShadeStr); 4109 return AddSetParmEntryToBatch(m_pParamBuf, 4110 CAM_INTF_PARM_ROLLOFF, 4111 sizeof(value), 4112 &value); 4113 } 4114 } 4115 ALOGE("Invalid LensShade value: %s", 4116 (lensShadeStr == NULL) ? "NULL" : lensShadeStr); 4117 return BAD_VALUE; 4118} 4119 4120/*=========================================================================== 4121 * FUNCTION : setExposureCompensation 4122 * 4123 * DESCRIPTION: set exposure compensation value 4124 * 4125 * PARAMETERS : 4126 * @expComp : exposure compensation value 4127 * 4128 * RETURN : int32_t type of status 4129 * NO_ERROR -- success 4130 * none-zero failure code 4131 *==========================================================================*/ 4132int32_t QCameraParameters::setExposureCompensation(int expComp) 4133{ 4134 char val[16]; 4135 sprintf(val, "%d", expComp); 4136 updateParamEntry(KEY_EXPOSURE_COMPENSATION, val); 4137 4138 // Don't need to pass step as part of setParameter because 4139 // camera daemon is already aware of it. 4140 return AddSetParmEntryToBatch(m_pParamBuf, 4141 CAM_INTF_PARM_EXPOSURE_COMPENSATION, 4142 sizeof(expComp), 4143 &expComp); 4144} 4145 4146/*=========================================================================== 4147 * FUNCTION : setWhiteBalance 4148 * 4149 * DESCRIPTION: set white balance mode 4150 * 4151 * PARAMETERS : 4152 * @wbStr : white balance mode value string 4153 * 4154 * RETURN : int32_t type of status 4155 * NO_ERROR -- success 4156 * none-zero failure code 4157 *==========================================================================*/ 4158int32_t QCameraParameters::setWhiteBalance(const char *wbStr) 4159{ 4160 if (wbStr != NULL) { 4161 int32_t value = lookupAttr(WHITE_BALANCE_MODES_MAP, 4162 sizeof(WHITE_BALANCE_MODES_MAP)/sizeof(QCameraMap), 4163 wbStr); 4164 if (value != NAME_NOT_FOUND) { 4165 ALOGD("%s: Setting WhiteBalance value %s", __func__, wbStr); 4166 updateParamEntry(KEY_WHITE_BALANCE, wbStr); 4167 return AddSetParmEntryToBatch(m_pParamBuf, 4168 CAM_INTF_PARM_WHITE_BALANCE, 4169 sizeof(value), 4170 &value); 4171 } 4172 } 4173 ALOGE("Invalid WhiteBalance value: %s", (wbStr == NULL) ? "NULL" : wbStr); 4174 return BAD_VALUE; 4175} 4176 4177/*=========================================================================== 4178 * FUNCTION : setAntibanding 4179 * 4180 * DESCRIPTION: set antibanding value 4181 * 4182 * PARAMETERS : 4183 * @antiBandingStr : antibanding value string 4184 * 4185 * RETURN : int32_t type of status 4186 * NO_ERROR -- success 4187 * none-zero failure code 4188 *==========================================================================*/ 4189int32_t QCameraParameters::setAntibanding(const char *antiBandingStr) 4190{ 4191 if (antiBandingStr != NULL) { 4192 int32_t value = lookupAttr(ANTIBANDING_MODES_MAP, 4193 sizeof(ANTIBANDING_MODES_MAP)/sizeof(QCameraMap), 4194 antiBandingStr); 4195 if (value != NAME_NOT_FOUND) { 4196 ALOGD("%s: Setting AntiBanding value %s", __func__, antiBandingStr); 4197 updateParamEntry(KEY_ANTIBANDING, antiBandingStr); 4198 return AddSetParmEntryToBatch(m_pParamBuf, 4199 CAM_INTF_PARM_ANTIBANDING, 4200 sizeof(value), 4201 &value); 4202 } 4203 } 4204 ALOGE("Invalid AntiBanding value: %s", 4205 (antiBandingStr == NULL) ? "NULL" : antiBandingStr); 4206 return BAD_VALUE; 4207} 4208 4209/*=========================================================================== 4210 * FUNCTION : setFocusAreas 4211 * 4212 * DESCRIPTION: set focus areas 4213 * 4214 * PARAMETERS : 4215 * @focusAreasStr : focus areas value string 4216 * 4217 * RETURN : int32_t type of status 4218 * NO_ERROR -- success 4219 * none-zero failure code 4220 *==========================================================================*/ 4221int32_t QCameraParameters::setFocusAreas(const char *focusAreasStr) 4222{ 4223 if (m_pCapability->max_num_focus_areas == 0 || 4224 focusAreasStr == NULL) { 4225 ALOGI("%s: Parameter string is null", __func__); 4226 return NO_ERROR; 4227 } 4228 4229 cam_area_t *areas = (cam_area_t *)malloc(sizeof(cam_area_t) * m_pCapability->max_num_focus_areas); 4230 if (NULL == areas) { 4231 ALOGE("%s: No memory for areas", __func__); 4232 return NO_MEMORY; 4233 } 4234 memset(areas, 0, sizeof(cam_area_t) * m_pCapability->max_num_focus_areas); 4235 int num_areas_found = 0; 4236 if (parseCameraAreaString(focusAreasStr, 4237 m_pCapability->max_num_focus_areas, 4238 areas, 4239 num_areas_found) != NO_ERROR) { 4240 ALOGE("%s: Failed to parse the string: %s", __func__, focusAreasStr); 4241 free(areas); 4242 return BAD_VALUE; 4243 } 4244 4245 if (validateCameraAreas(areas, num_areas_found) == false) { 4246 ALOGE("%s: invalid areas specified : %s", __func__, focusAreasStr); 4247 free(areas); 4248 return BAD_VALUE; 4249 } 4250 4251 updateParamEntry(KEY_FOCUS_AREAS, focusAreasStr); 4252 4253 //for special area string (0, 0, 0, 0, 0), set the num_areas_found to 0, 4254 //so no action is takenby the lower layer 4255 if (num_areas_found == 1 && 4256 areas[0].rect.left == 0 && 4257 areas[0].rect.top == 0 && 4258 areas[0].rect.width == 0 && 4259 areas[0].rect.height == 0 && 4260 areas[0].weight == 0) { 4261 num_areas_found = 0; 4262 } 4263 4264 int previewWidth, previewHeight; 4265 getPreviewSize(&previewWidth, &previewHeight); 4266 cam_roi_info_t af_roi_value; 4267 memset(&af_roi_value, 0, sizeof(cam_roi_info_t)); 4268 af_roi_value.num_roi = num_areas_found; 4269 for (int i = 0; i < num_areas_found; i++) { 4270 ALOGD("%s: FocusArea[%d] = (%d, %d, %d, %d)", 4271 __func__, i, (areas[i].rect.top), (areas[i].rect.left), 4272 (areas[i].rect.width), (areas[i].rect.height)); 4273 4274 //transform the coords from (-1000, 1000) to (0, previewWidth or previewHeight) 4275 af_roi_value.roi[i].left = (int32_t)((areas[i].rect.left + 1000.0f) * (previewWidth / 2000.0f)); 4276 af_roi_value.roi[i].top = (int32_t)((areas[i].rect.top + 1000.0f) * (previewHeight / 2000.0f)); 4277 af_roi_value.roi[i].width = (int32_t)(areas[i].rect.width * previewWidth / 2000.0f); 4278 af_roi_value.roi[i].height = (int32_t)(areas[i].rect.height * previewHeight / 2000.0f); 4279 af_roi_value.weight[i] = areas[i].weight; 4280 } 4281 free(areas); 4282 return AddSetParmEntryToBatch(m_pParamBuf, 4283 CAM_INTF_PARM_AF_ROI, 4284 sizeof(af_roi_value), 4285 &af_roi_value); 4286} 4287 4288/*=========================================================================== 4289 * FUNCTION : setMeteringAreas 4290 * 4291 * DESCRIPTION: set metering areas value 4292 * 4293 * PARAMETERS : 4294 * @meteringAreasStr : metering areas value string 4295 * 4296 * RETURN : int32_t type of status 4297 * NO_ERROR -- success 4298 * none-zero failure code 4299 *==========================================================================*/ 4300int32_t QCameraParameters::setMeteringAreas(const char *meteringAreasStr) 4301{ 4302 if (m_pCapability->max_num_metering_areas == 0 || 4303 meteringAreasStr == NULL) { 4304 ALOGI("%s: Parameter string is null", __func__); 4305 return NO_ERROR; 4306 } 4307 4308 cam_area_t *areas = (cam_area_t *)malloc(sizeof(cam_area_t) * m_pCapability->max_num_metering_areas); 4309 if (NULL == areas) { 4310 ALOGE("%s: No memory for areas", __func__); 4311 return NO_MEMORY; 4312 } 4313 memset(areas, 0, sizeof(cam_area_t) * m_pCapability->max_num_metering_areas); 4314 int num_areas_found = 0; 4315 if (parseCameraAreaString(meteringAreasStr, 4316 m_pCapability->max_num_metering_areas, 4317 areas, 4318 num_areas_found) < 0) { 4319 ALOGE("%s: Failed to parse the string: %s", __func__, meteringAreasStr); 4320 free(areas); 4321 return BAD_VALUE; 4322 } 4323 4324 if (validateCameraAreas(areas, num_areas_found) == false) { 4325 ALOGE("%s: invalid areas specified : %s", __func__, meteringAreasStr); 4326 free(areas); 4327 return BAD_VALUE; 4328 } 4329 4330 updateParamEntry(KEY_METERING_AREAS, meteringAreasStr); 4331 4332 //for special area string (0, 0, 0, 0, 0), set the num_areas_found to 0, 4333 //so no action is takenby the lower layer 4334 if (num_areas_found == 1 && 4335 areas[0].rect.left == 0 && 4336 areas[0].rect.top == 0 && 4337 areas[0].rect.width == 0 && 4338 areas[0].rect.height == 0 && 4339 areas[0].weight == 0) { 4340 num_areas_found = 0; 4341 } 4342 cam_set_aec_roi_t aec_roi_value; 4343 int previewWidth, previewHeight; 4344 getPreviewSize(&previewWidth, &previewHeight); 4345 4346 memset(&aec_roi_value, 0, sizeof(cam_set_aec_roi_t)); 4347 if (num_areas_found > 0) { 4348 aec_roi_value.aec_roi_enable = CAM_AEC_ROI_ON; 4349 aec_roi_value.aec_roi_type = CAM_AEC_ROI_BY_COORDINATE; 4350 4351 for (int i = 0; i < num_areas_found; i++) { 4352 ALOGD("%s: MeteringArea[%d] = (%d, %d, %d, %d)", 4353 __func__, i, (areas[i].rect.top), (areas[i].rect.left), 4354 (areas[i].rect.width), (areas[i].rect.height)); 4355 4356 //transform the coords from (-1000, 1000) to (0, previewWidth or previewHeight) 4357 aec_roi_value.cam_aec_roi_position.coordinate[i].x = 4358 (uint32_t)(((areas[i].rect.left + areas[i].rect.width / 2) + 1000.0f) * previewWidth / 2000.0f) ; 4359 aec_roi_value.cam_aec_roi_position.coordinate[i].y = 4360 (uint32_t)(((areas[i].rect.top + areas[i].rect.height / 2) + 1000.0f) * previewHeight / 2000.0f) ; 4361 } 4362 } else { 4363 aec_roi_value.aec_roi_enable = CAM_AEC_ROI_OFF; 4364 } 4365 free(areas); 4366 return AddSetParmEntryToBatch(m_pParamBuf, 4367 CAM_INTF_PARM_AEC_ROI, 4368 sizeof(aec_roi_value), 4369 &aec_roi_value); 4370} 4371 4372/*=========================================================================== 4373 * FUNCTION : setSceneMode 4374 * 4375 * DESCRIPTION: set scene mode 4376 * 4377 * PARAMETERS : 4378 * @sceneModeStr : scene mode value string 4379 * 4380 * RETURN : int32_t type of status 4381 * NO_ERROR -- success 4382 * none-zero failure code 4383 *==========================================================================*/ 4384int32_t QCameraParameters::setSceneMode(const char *sceneModeStr) 4385{ 4386 if (sceneModeStr != NULL) { 4387 int32_t value = lookupAttr(SCENE_MODES_MAP, 4388 sizeof(SCENE_MODES_MAP)/sizeof(QCameraMap), 4389 sceneModeStr); 4390 if (value != NAME_NOT_FOUND) { 4391 ALOGV("%s: Setting SceneMode %s", __func__, sceneModeStr); 4392 updateParamEntry(KEY_SCENE_MODE, sceneModeStr); 4393 int32_t rc = AddSetParmEntryToBatch(m_pParamBuf, 4394 CAM_INTF_PARM_BESTSHOT_MODE, 4395 sizeof(value), 4396 &value); 4397 return rc; 4398 } 4399 } 4400 ALOGE("%s: Invalid Secene Mode: %s", 4401 __func__, (sceneModeStr == NULL) ? "NULL" : sceneModeStr); 4402 return BAD_VALUE; 4403} 4404 4405/*=========================================================================== 4406 * FUNCTION : setSelectableZoneAf 4407 * 4408 * DESCRIPTION: set selectable zone AF algorithm 4409 * 4410 * PARAMETERS : 4411 * @selZoneAFStr : selectable zone AF algorithm value string 4412 * 4413 * RETURN : int32_t type of status 4414 * NO_ERROR -- success 4415 * none-zero failure code 4416 *==========================================================================*/ 4417int32_t QCameraParameters::setSelectableZoneAf(const char *selZoneAFStr) 4418{ 4419 if (selZoneAFStr != NULL) { 4420 int32_t value = lookupAttr(FOCUS_ALGO_MAP, 4421 sizeof(FOCUS_ALGO_MAP)/sizeof(QCameraMap), 4422 selZoneAFStr); 4423 if (value != NAME_NOT_FOUND) { 4424 ALOGV("%s: Setting Selectable Zone AF value %s", __func__, selZoneAFStr); 4425 updateParamEntry(KEY_QC_SELECTABLE_ZONE_AF, selZoneAFStr); 4426 return AddSetParmEntryToBatch(m_pParamBuf, 4427 CAM_INTF_PARM_FOCUS_ALGO_TYPE, 4428 sizeof(value), 4429 &value); 4430 } 4431 } 4432 ALOGE("%s: Invalid selectable zone af value: %s", 4433 __func__, (selZoneAFStr == NULL) ? "NULL" : selZoneAFStr); 4434 return BAD_VALUE; 4435} 4436 4437/*=========================================================================== 4438 * FUNCTION : setAEBracket 4439 * 4440 * DESCRIPTION: set AE bracket value 4441 * 4442 * PARAMETERS : 4443 * @aecBracketStr : AE bracket value string 4444 * 4445 * RETURN : int32_t type of status 4446 * NO_ERROR -- success 4447 * none-zero failure code 4448 *==========================================================================*/ 4449int32_t QCameraParameters::setAEBracket(const char *aecBracketStr) 4450{ 4451 if (aecBracketStr == NULL) { 4452 ALOGI("%s: setAEBracket with NULL value", __func__); 4453 return NO_ERROR; 4454 } 4455 4456 cam_exp_bracketing_t expBracket; 4457 memset(&expBracket, 0, sizeof(expBracket)); 4458 4459 int value = lookupAttr(BRACKETING_MODES_MAP, 4460 sizeof(BRACKETING_MODES_MAP)/sizeof(QCameraMap), 4461 aecBracketStr); 4462 switch (value) { 4463 case CAM_EXP_BRACKETING_ON: 4464 { 4465 ALOGV("%s, EXP_BRACKETING_ON", __func__); 4466 const char *str_val = get(KEY_QC_CAPTURE_BURST_EXPOSURE); 4467 if ((str_val != NULL) && (strlen(str_val)>0)) { 4468 expBracket.mode = CAM_EXP_BRACKETING_ON; 4469 strlcpy(expBracket.values, str_val, MAX_EXP_BRACKETING_LENGTH); 4470 ALOGI("%s: setting Exposure Bracketing value of %s", 4471 __func__, expBracket.values); 4472 } 4473 else { 4474 /* Apps not set capture-burst-exposures, error case fall into bracketing off mode */ 4475 ALOGI("%s: capture-burst-exposures not set, back to HDR OFF mode", __func__); 4476 expBracket.mode = CAM_EXP_BRACKETING_OFF; 4477 } 4478 } 4479 break; 4480 default: 4481 { 4482 ALOGD("%s, EXP_BRACKETING_OFF", __func__); 4483 expBracket.mode = CAM_EXP_BRACKETING_OFF; 4484 } 4485 break; 4486 } 4487 4488 /* save the value*/ 4489 updateParamEntry(KEY_QC_AE_BRACKET_HDR, aecBracketStr); 4490 return AddSetParmEntryToBatch(m_pParamBuf, 4491 CAM_INTF_PARM_HDR, 4492 sizeof(expBracket), 4493 &expBracket); 4494} 4495 4496/*=========================================================================== 4497 * FUNCTION : setRedeyeReduction 4498 * 4499 * DESCRIPTION: set red eye reduction value 4500 * 4501 * PARAMETERS : 4502 * @redeyeStr : red eye reduction value string 4503 * 4504 * RETURN : int32_t type of status 4505 * NO_ERROR -- success 4506 * none-zero failure code 4507 *==========================================================================*/ 4508int32_t QCameraParameters::setRedeyeReduction(const char *redeyeStr) 4509{ 4510 if (redeyeStr != NULL) { 4511 int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP, 4512 sizeof(ENABLE_DISABLE_MODES_MAP)/sizeof(QCameraMap), 4513 redeyeStr); 4514 if (value != NAME_NOT_FOUND) { 4515 ALOGV("%s: Setting RedEye Reduce value %s", __func__, redeyeStr); 4516 updateParamEntry(KEY_QC_REDEYE_REDUCTION, redeyeStr); 4517 return AddSetParmEntryToBatch(m_pParamBuf, 4518 CAM_INTF_PARM_REDEYE_REDUCTION, 4519 sizeof(value), 4520 &value); 4521 } 4522 } 4523 ALOGE("%s: Invalid RedEye Reduce value: %s", 4524 __func__, (redeyeStr == NULL) ? "NULL" : redeyeStr); 4525 return BAD_VALUE; 4526} 4527 4528/*=========================================================================== 4529 * FUNCTION : getWaveletDenoiseProcessPlate 4530 * 4531 * DESCRIPTION: query wavelet denoise process plate 4532 * 4533 * PARAMETERS : None 4534 * 4535 * RETURN : WNR prcocess plate vlaue 4536 *==========================================================================*/ 4537cam_denoise_process_type_t QCameraParameters::getWaveletDenoiseProcessPlate() 4538{ 4539 char prop[PROPERTY_VALUE_MAX]; 4540 memset(prop, 0, sizeof(prop)); 4541 property_get("persist.denoise.process.plates", prop, "0"); 4542 int processPlate = atoi(prop); 4543 switch(processPlate) { 4544 case 0: 4545 return CAM_WAVELET_DENOISE_YCBCR_PLANE; 4546 case 1: 4547 return CAM_WAVELET_DENOISE_CBCR_ONLY; 4548 case 2: 4549 return CAM_WAVELET_DENOISE_STREAMLINE_YCBCR; 4550 case 3: 4551 return CAM_WAVELET_DENOISE_STREAMLINED_CBCR; 4552 default: 4553 return CAM_WAVELET_DENOISE_STREAMLINE_YCBCR; 4554 } 4555} 4556 4557/*=========================================================================== 4558 * FUNCTION : setWaveletDenoise 4559 * 4560 * DESCRIPTION: set wavelet denoise value 4561 * 4562 * PARAMETERS : 4563 * @wnrStr : wavelet denoise value string 4564 * 4565 * RETURN : int32_t type of status 4566 * NO_ERROR -- success 4567 * none-zero failure code 4568 *==========================================================================*/ 4569int32_t QCameraParameters::setWaveletDenoise(const char *wnrStr) 4570{ 4571 if (wnrStr != NULL) { 4572 int value = lookupAttr(DENOISE_ON_OFF_MODES_MAP, 4573 sizeof(DENOISE_ON_OFF_MODES_MAP)/sizeof(QCameraMap), 4574 wnrStr); 4575 if (value != NAME_NOT_FOUND) { 4576 updateParamEntry(KEY_QC_DENOISE, wnrStr); 4577 4578 cam_denoise_param_t temp; 4579 memset(&temp, 0, sizeof(temp)); 4580 temp.denoise_enable = value; 4581 m_bWNROn = (value != 0); 4582 if (m_bWNROn) { 4583 temp.process_plates = getWaveletDenoiseProcessPlate(); 4584 } 4585 ALOGI("%s: Denoise enable=%d, plates=%d", 4586 __func__, temp.denoise_enable, temp.process_plates); 4587 return AddSetParmEntryToBatch(m_pParamBuf, 4588 CAM_INTF_PARM_WAVELET_DENOISE, 4589 sizeof(temp), 4590 &temp); 4591 } 4592 } 4593 ALOGE("%s: Invalid Denoise value: %s", __func__, (wnrStr == NULL) ? "NULL" : wnrStr); 4594 return BAD_VALUE; 4595} 4596 4597/*=========================================================================== 4598 * FUNCTION : setPreviewFrameRateMode 4599 * 4600 * DESCRIPTION: set preview frame rate mode 4601 * 4602 * PARAMETERS : 4603 * @mode : preview frame rate mode 4604 * 4605 * RETURN : none 4606 *==========================================================================*/ 4607void QCameraParameters::setPreviewFrameRateMode(const char *mode) 4608{ 4609 set(KEY_QC_PREVIEW_FRAME_RATE_MODE, mode); 4610} 4611 4612/*=========================================================================== 4613 * FUNCTION : getPreviewFrameRateMode 4614 * 4615 * DESCRIPTION: get preview frame rate mode 4616 * 4617 * PARAMETERS : none 4618 * 4619 * RETURN : preview frame rate mode string 4620 *==========================================================================*/ 4621const char *QCameraParameters::getPreviewFrameRateMode() const 4622{ 4623 return get(KEY_QC_PREVIEW_FRAME_RATE_MODE); 4624} 4625 4626/*=========================================================================== 4627 * FUNCTION : setTouchIndexAec 4628 * 4629 * DESCRIPTION: set touch index AEC 4630 * 4631 * PARAMETERS : 4632 * @x,y : 4633 * 4634 * RETURN : none 4635 *==========================================================================*/ 4636void QCameraParameters::setTouchIndexAec(int x, int y) 4637{ 4638 char str[32]; 4639 snprintf(str, sizeof(str), "%dx%d", x, y); 4640 set(KEY_QC_TOUCH_INDEX_AEC, str); 4641} 4642 4643/*=========================================================================== 4644 * FUNCTION : getTouchIndexAec 4645 * 4646 * DESCRIPTION: get touch index AEC 4647 * 4648 * PARAMETERS : 4649 * @x,y : 4650 * 4651 * RETURN : none 4652 *==========================================================================*/ 4653void QCameraParameters::getTouchIndexAec(int *x, int *y) 4654{ 4655 *x = -1; 4656 *y = -1; 4657 4658 // Get the current string, if it doesn't exist, leave the -1x-1 4659 const char *p = get(KEY_QC_TOUCH_INDEX_AEC); 4660 if (p == 0) 4661 return; 4662 4663 int tempX, tempY; 4664 if (parse_pair(p, &tempX, &tempY, 'x') == 0) { 4665 *x = tempX; 4666 *y = tempY; 4667 } 4668} 4669 4670/*=========================================================================== 4671 * FUNCTION : setTouchIndexAf 4672 * 4673 * DESCRIPTION: set touch index AF 4674 * 4675 * PARAMETERS : 4676 * @x,y : 4677 * 4678 * RETURN : none 4679 *==========================================================================*/ 4680void QCameraParameters::setTouchIndexAf(int x, int y) 4681{ 4682 char str[32]; 4683 snprintf(str, sizeof(str), "%dx%d", x, y); 4684 set(KEY_QC_TOUCH_INDEX_AF, str); 4685} 4686 4687/*=========================================================================== 4688 * FUNCTION : getTouchIndexAf 4689 * 4690 * DESCRIPTION: get touch index AF 4691 * 4692 * PARAMETERS : 4693 * @x,y : 4694 * 4695 * RETURN : none 4696 *==========================================================================*/ 4697void QCameraParameters::getTouchIndexAf(int *x, int *y) 4698{ 4699 *x = -1; 4700 *y = -1; 4701 4702 // Get the current string, if it doesn't exist, leave the -1x-1 4703 const char *p = get(KEY_QC_TOUCH_INDEX_AF); 4704 if (p == 0) 4705 return; 4706 4707 int tempX, tempY; 4708 if (parse_pair(p, &tempX, &tempY, 'x') == 0) { 4709 *x = tempX; 4710 *y = tempY; 4711 } 4712} 4713 4714/*=========================================================================== 4715 * FUNCTION : getStreamFormat 4716 * 4717 * DESCRIPTION: get stream format by its type 4718 * 4719 * PARAMETERS : 4720 * @streamType : [input] stream type 4721 * @format : [output] stream format 4722 * 4723 * RETURN : int32_t type of status 4724 * NO_ERROR -- success 4725 * none-zero failure code 4726 *==========================================================================*/ 4727int32_t QCameraParameters::getStreamFormat(cam_stream_type_t streamType, 4728 cam_format_t &format) 4729{ 4730 int32_t ret = NO_ERROR; 4731 4732 format = CAM_FORMAT_MAX; 4733 switch (streamType) { 4734 case CAM_STREAM_TYPE_PREVIEW: 4735 case CAM_STREAM_TYPE_POSTVIEW: 4736 format = mPreviewFormat; 4737 break; 4738 case CAM_STREAM_TYPE_SNAPSHOT: 4739 if ( mPictureFormat == CAM_FORMAT_YUV_422_NV16 ) { 4740 format = CAM_FORMAT_YUV_422_NV16; 4741 } else { 4742 char prop[PROPERTY_VALUE_MAX]; 4743 int snapshotFormat; 4744 memset(prop, 0, sizeof(prop)); 4745 property_get("persist.camera.snap.format", prop, "0"); 4746 snapshotFormat = atoi(prop); 4747 if(snapshotFormat == 1) { 4748 format = CAM_FORMAT_YUV_422_NV61; 4749 } else { 4750 format = CAM_FORMAT_YUV_420_NV21; 4751 } 4752 } 4753 break; 4754 case CAM_STREAM_TYPE_VIDEO: 4755 format = CAM_FORMAT_YUV_420_NV12; 4756 break; 4757 case CAM_STREAM_TYPE_RAW: 4758 if (mPictureFormat >= CAM_FORMAT_YUV_RAW_8BIT_YUYV) { 4759 format = (cam_format_t)mPictureFormat; 4760 } else { 4761 ALOGE("%s: invalid raw picture format: %d", __func__, mPictureFormat); 4762 ret = BAD_VALUE; 4763 } 4764 break; 4765 case CAM_STREAM_TYPE_METADATA: 4766 case CAM_STREAM_TYPE_OFFLINE_PROC: 4767 case CAM_STREAM_TYPE_DEFAULT: 4768 default: 4769 break; 4770 } 4771 4772 return ret; 4773} 4774 4775/*=========================================================================== 4776 * FUNCTION : getFlipMode 4777 * 4778 * DESCRIPTION: get flip mode 4779 * 4780 * PARAMETERS : 4781 * @cam_intf_parm_type_t : [input] stream type 4782 * 4783 * RETURN : int type of flip mode 4784 * 0 - no filp 4785 * 1 - FLIP_H 4786 * 2 - FLIP_V 4787 * 3 - FLIP_H | FLIP_V 4788 *==========================================================================*/ 4789int QCameraParameters::getFlipMode(cam_stream_type_t type) 4790{ 4791 const char *str = NULL; 4792 int flipMode = 0; // no flip 4793 4794 switch(type){ 4795 case CAM_STREAM_TYPE_PREVIEW: 4796 str = get(KEY_QC_PREVIEW_FLIP); 4797 break; 4798 case CAM_STREAM_TYPE_VIDEO: 4799 str = get(KEY_QC_VIDEO_FLIP); 4800 break; 4801 case CAM_STREAM_TYPE_SNAPSHOT: 4802 str = get(KEY_QC_SNAPSHOT_PICTURE_FLIP); 4803 break; 4804 default: 4805 ALOGI("%s: No flip mode for stream type %d", __func__, type); 4806 break; 4807 } 4808 4809 if(str != NULL){ 4810 //Need give corresponding filp value based on flip mode strings 4811 int value = lookupAttr(FLIP_MODES_MAP, 4812 sizeof(FLIP_MODES_MAP)/sizeof(QCameraMap), str); 4813 if(value != NAME_NOT_FOUND) 4814 flipMode = value; 4815 } 4816 4817 ALOGD("%s: the filp mode of stream type %d is %d .", __func__, type, flipMode); 4818 return flipMode; 4819} 4820 4821/*=========================================================================== 4822 * FUNCTION : getStreamDimension 4823 * 4824 * DESCRIPTION: get stream dimension by its type 4825 * 4826 * PARAMETERS : 4827 * @streamType : [input] stream type 4828 * @dim : [output] stream dimension 4829 * 4830 * RETURN : int32_t type of status 4831 * NO_ERROR -- success 4832 * none-zero failure code 4833 *==========================================================================*/ 4834int32_t QCameraParameters::getStreamDimension(cam_stream_type_t streamType, 4835 cam_dimension_t &dim) 4836{ 4837 int32_t ret = NO_ERROR; 4838 memset(&dim, 0, sizeof(cam_dimension_t)); 4839 4840 switch (streamType) { 4841 case CAM_STREAM_TYPE_PREVIEW: 4842 getPreviewSize(&dim.width, &dim.height); 4843 break; 4844 case CAM_STREAM_TYPE_POSTVIEW: 4845 getPreviewSize(&dim.width, &dim.height); 4846 break; 4847 case CAM_STREAM_TYPE_SNAPSHOT: 4848 if (getRecordingHintValue() == true) { 4849 // live snapshot 4850 getLiveSnapshotSize(dim); 4851 } else { 4852 getPictureSize(&dim.width, &dim.height); 4853 } 4854 break; 4855 case CAM_STREAM_TYPE_VIDEO: 4856 getVideoSize(&dim.width, &dim.height); 4857 break; 4858 case CAM_STREAM_TYPE_RAW: 4859 dim = m_pCapability->raw_dim; 4860 break; 4861 case CAM_STREAM_TYPE_METADATA: 4862 dim.width = sizeof(cam_metadata_info_t); 4863 dim.height = 1; 4864 break; 4865 case CAM_STREAM_TYPE_OFFLINE_PROC: 4866 break; 4867 case CAM_STREAM_TYPE_DEFAULT: 4868 default: 4869 ALOGE("%s: no dimension for unsupported stream type %d", 4870 __func__, streamType); 4871 ret = BAD_VALUE; 4872 break; 4873 } 4874 return ret; 4875} 4876 4877/*=========================================================================== 4878 * FUNCTION : getPreviewHalPixelFormat 4879 * 4880 * DESCRIPTION: get preview HAL pixel format 4881 * 4882 * PARAMETERS : none 4883 * 4884 * RETURN : HAL pixel format 4885 *==========================================================================*/ 4886int QCameraParameters::getPreviewHalPixelFormat() const 4887{ 4888 int32_t halPixelFormat; 4889 4890 switch (mPreviewFormat) { 4891 case CAM_FORMAT_YUV_420_NV12: 4892 halPixelFormat = HAL_PIXEL_FORMAT_YCbCr_420_SP; 4893 break; 4894 case CAM_FORMAT_YUV_420_NV21: 4895 halPixelFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP; 4896 break; 4897 case CAM_FORMAT_YUV_420_NV21_ADRENO: 4898 halPixelFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO; 4899 break; 4900 case CAM_FORMAT_YUV_420_YV12: 4901 halPixelFormat = HAL_PIXEL_FORMAT_YV12; 4902 break; 4903 case CAM_FORMAT_YUV_422_NV16: 4904 case CAM_FORMAT_YUV_422_NV61: 4905 default: 4906 halPixelFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP; 4907 break; 4908 } 4909 ALOGE("%s: format %d\n", __func__, halPixelFormat); 4910 return halPixelFormat; 4911} 4912 4913/*=========================================================================== 4914 * FUNCTION : getthumbnailSize 4915 * 4916 * DESCRIPTION: get thumbnail size 4917 * 4918 * PARAMETERS : 4919 * @width, height : [output] thumbnail width and height 4920 * 4921 * RETURN : none 4922 *==========================================================================*/ 4923void QCameraParameters::getThumbnailSize(int *width, int *height) const 4924{ 4925 *width = getInt(KEY_JPEG_THUMBNAIL_WIDTH); 4926 *height = getInt(KEY_JPEG_THUMBNAIL_HEIGHT); 4927} 4928 4929/*=========================================================================== 4930 * FUNCTION : getZSLBurstInterval 4931 * 4932 * DESCRIPTION: get ZSL burst interval setting 4933 * 4934 * PARAMETERS : none 4935 * 4936 * RETURN : ZSL burst interval value 4937 *==========================================================================*/ 4938int QCameraParameters::getZSLBurstInterval() 4939{ 4940 int interval = getInt(KEY_QC_ZSL_BURST_INTERVAL); 4941 if (interval < 0) { 4942 interval = 1; 4943 } 4944 return interval; 4945} 4946 4947/*=========================================================================== 4948 * FUNCTION : getZSLQueueDepth 4949 * 4950 * DESCRIPTION: get ZSL queue depth 4951 * 4952 * PARAMETERS : none 4953 * 4954 * RETURN : ZSL queue depth value 4955 *==========================================================================*/ 4956int QCameraParameters::getZSLQueueDepth() 4957{ 4958 int qdepth = getInt(KEY_QC_ZSL_QUEUE_DEPTH); 4959 if (qdepth < 0) { 4960 qdepth = 2; 4961 } 4962 return qdepth; 4963} 4964 4965/*=========================================================================== 4966 * FUNCTION : getZSLBackLookCount 4967 * 4968 * DESCRIPTION: get ZSL backlook count setting 4969 * 4970 * PARAMETERS : none 4971 * 4972 * RETURN : ZSL backlook count value 4973 *==========================================================================*/ 4974int QCameraParameters::getZSLBackLookCount() 4975{ 4976 int look_back = getInt(KEY_QC_ZSL_BURST_LOOKBACK); 4977 if (look_back < 0) { 4978 look_back = 2; 4979 } 4980 return look_back; 4981} 4982 4983/*=========================================================================== 4984 * FUNCTION : getZSLMaxUnmatchedFrames 4985 * 4986 * DESCRIPTION: get allowed ZSL max unmatched frames number 4987 * 4988 * PARAMETERS : none 4989 * 4990 * RETURN : ZSL backlook count value 4991 *==========================================================================*/ 4992int QCameraParameters::getMaxUnmatchedFramesInQueue() 4993{ 4994 return m_pCapability->min_num_pp_bufs; 4995} 4996 4997/*=========================================================================== 4998 * FUNCTION : setRecordingHintValue 4999 * 5000 * DESCRIPTION: set recording hint 5001 * 5002 * PARAMETERS : 5003 * @value : video hint value 5004 * 5005 * RETURN : int32_t type of status 5006 * NO_ERROR -- success 5007 * none-zero failure code 5008 *==========================================================================*/ 5009int QCameraParameters::setRecordingHintValue(int32_t value) 5010{ 5011 ALOGD("%s: VideoHint = %d", __func__, value); 5012 m_bRecordingHint = (value > 0)? true : false; 5013 return AddSetParmEntryToBatch(m_pParamBuf, 5014 CAM_INTF_PARM_RECORDING_HINT, 5015 sizeof(value), 5016 &value); 5017} 5018 5019/*=========================================================================== 5020 * FUNCTION : getNumOfSnapshots 5021 * 5022 * DESCRIPTION: get number of snapshot per shutter 5023 * 5024 * PARAMETERS : none 5025 * 5026 * RETURN : number of snapshot per shutter 5027 *==========================================================================*/ 5028uint8_t QCameraParameters::getNumOfSnapshots() 5029{ 5030 int numOfSnapshot = getInt(KEY_QC_NUM_SNAPSHOT_PER_SHUTTER); 5031 if (numOfSnapshot <= 0) { 5032 numOfSnapshot = 1; // set to default value 5033 } 5034 return (uint8_t)numOfSnapshot; 5035} 5036 5037/*=========================================================================== 5038 * FUNCTION : getNumOfExtraHDRBufsIfNeeded 5039 * 5040 * DESCRIPTION: get number of extra buffers needed by HDR if HDR is enabled 5041 * 5042 * PARAMETERS : none 5043 * 5044 * RETURN : number of extra buffer needed by HDR; 0 if not HDR enabled 5045 *==========================================================================*/ 5046uint8_t QCameraParameters::getNumOfExtraHDRBufsIfNeeded() 5047{ 5048 uint8_t numOfBufs = 0; 5049 const char *scene_mode = get(KEY_SCENE_MODE); 5050 if (scene_mode != NULL && strcmp(scene_mode, SCENE_MODE_HDR) == 0) { 5051 // HDR mode 5052 numOfBufs = getBurstNum() * m_pCapability->min_num_hdr_bufs; 5053 } 5054 return numOfBufs; 5055} 5056 5057/*=========================================================================== 5058 * FUNCTION : getNumOfHDRBufsIfNeeded 5059 * 5060 * DESCRIPTION: get number of buffers needed by HDR if HDR is enabled 5061 * 5062 * PARAMETERS : none 5063 * 5064 * RETURN : number of buffer needed by HDR; 0 if not HDR enabled 5065 *==========================================================================*/ 5066uint8_t QCameraParameters::getNumOfHDRBufsIfNeeded() 5067{ 5068 uint8_t numOfBufs = 0; 5069 const char *scene_mode = get(KEY_SCENE_MODE); 5070 if (scene_mode != NULL && strcmp(scene_mode, SCENE_MODE_HDR) == 0) { 5071 // HDR mode 5072 const char *need_hdr_1x = get(KEY_QC_HDR_NEED_1X); 5073 if (need_hdr_1x != NULL && strcmp(need_hdr_1x, VALUE_TRUE) == 0) { 5074 numOfBufs = 2; // HDR needs both 1X and processed img 5075 } else { 5076 numOfBufs = 1; // HDR only needs processed img 5077 } 5078 5079 numOfBufs += m_pCapability->min_num_hdr_bufs; 5080 } 5081 return numOfBufs; 5082} 5083 5084/*=========================================================================== 5085 * FUNCTION : getBurstNum 5086 * 5087 * DESCRIPTION: get burst number of snapshot 5088 * 5089 * PARAMETERS : none 5090 * 5091 * RETURN : number of burst 5092 *==========================================================================*/ 5093int QCameraParameters::getBurstNum() 5094{ 5095 char prop[PROPERTY_VALUE_MAX]; 5096 memset(prop, 0, sizeof(prop)); 5097 property_get("persist.camera.snapshot.number", prop, "0"); 5098 int nBurstNum = atoi(prop); 5099 if (nBurstNum > 0) { 5100 ALOGD("%s: Reading burst number = %d from properties", 5101 __func__, nBurstNum); 5102 } else { 5103 nBurstNum = 1; 5104 } 5105 return nBurstNum; 5106} 5107 5108/*=========================================================================== 5109 * FUNCTION : getJpegQuality 5110 * 5111 * DESCRIPTION: get jpeg encoding quality 5112 * 5113 * PARAMETERS : none 5114 * 5115 * RETURN : jpeg encoding quality 5116 *==========================================================================*/ 5117int QCameraParameters::getJpegQuality() 5118{ 5119 int quality = getInt(KEY_JPEG_QUALITY); 5120 if (quality < 0) { 5121 quality = 85; // set to default quality value 5122 } 5123 return quality; 5124} 5125 5126/*=========================================================================== 5127 * FUNCTION : getJpegRotation 5128 * 5129 * DESCRIPTION: get rotation value 5130 * 5131 * PARAMETERS : none 5132 * 5133 * RETURN : rotation value 5134 *==========================================================================*/ 5135int QCameraParameters::getJpegRotation() { 5136 int rotation = getInt(KEY_ROTATION); 5137 if (rotation < 0) { 5138 rotation = 0; 5139 } 5140 return rotation; 5141} 5142 5143/*=========================================================================== 5144 * FUNCTION : parseGPSCoordinate 5145 * 5146 * DESCRIPTION: parse GPS coordinate string 5147 * 5148 * PARAMETERS : 5149 * @coord_str : [input] coordinate string 5150 * @coord : [output] ptr to struct to store coordinate 5151 * 5152 * RETURN : int32_t type of status 5153 * NO_ERROR -- success 5154 * none-zero failure code 5155 *==========================================================================*/ 5156int QCameraParameters::parseGPSCoordinate(const char *coord_str, rat_t* coord) 5157{ 5158 if(coord == NULL) { 5159 ALOGE("%s: error, invalid argument coord == NULL", __func__); 5160 return BAD_VALUE; 5161 } 5162 float degF = atof(coord_str); 5163 if (degF < 0) { 5164 degF = -degF; 5165 } 5166 float minF = (degF - (int) degF) * 60; 5167 float secF = (minF - (int) minF) * 60; 5168 5169 getRational(&coord[0], (int)degF, 1); 5170 getRational(&coord[1], (int)minF, 1); 5171 getRational(&coord[2], (int)(secF * 10000), 10000); 5172 return NO_ERROR; 5173} 5174 5175/*=========================================================================== 5176 * FUNCTION : getExifDateTime 5177 * 5178 * DESCRIPTION: query exif date time 5179 * 5180 * PARAMETERS : 5181 * @dateTime : string to store exif date time 5182 * @count : lenght of the dateTime string 5183 * 5184 * RETURN : int32_t type of status 5185 * NO_ERROR -- success 5186 * none-zero failure code 5187 *==========================================================================*/ 5188int32_t QCameraParameters::getExifDateTime(char *dateTime, uint32_t &count) 5189{ 5190 //get time and date from system 5191 time_t rawtime; 5192 struct tm * timeinfo = NULL; 5193 memset(&rawtime, 0, sizeof(rawtime)); 5194 time(&rawtime); 5195 timeinfo = localtime (&rawtime); 5196 if (timeinfo != NULL && count >= 20) { 5197 //Write datetime according to EXIF Spec 5198 //"YYYY:MM:DD HH:MM:SS" (20 chars including \0) 5199 snprintf(dateTime, 20, "%04d:%02d:%02d %02d:%02d:%02d", 5200 timeinfo->tm_year + 1900, timeinfo->tm_mon + 1, 5201 timeinfo->tm_mday, timeinfo->tm_hour, 5202 timeinfo->tm_min, timeinfo->tm_sec); 5203 count = 20; 5204 return NO_ERROR; 5205 } 5206 return UNKNOWN_ERROR; 5207} 5208 5209/*=========================================================================== 5210 * FUNCTION : getRational 5211 * 5212 * DESCRIPTION: compose rational struct 5213 * 5214 * PARAMETERS : 5215 * @rat : ptr to struct to store rational info 5216 * @num :num of the rational 5217 * @denom : denom of the rational 5218 * 5219 * RETURN : int32_t type of status 5220 * NO_ERROR -- success 5221 * none-zero failure code 5222 *==========================================================================*/ 5223int32_t QCameraParameters::getRational(rat_t *rat, int num, int denom) 5224{ 5225 if (NULL == rat) { 5226 ALOGE("%s: NULL rat input", __func__); 5227 return BAD_VALUE; 5228 } 5229 rat->num = num; 5230 rat->denom = denom; 5231 return NO_ERROR; 5232} 5233 5234/*=========================================================================== 5235 * FUNCTION : getExifFocalLength 5236 * 5237 * DESCRIPTION: get exif focal lenght 5238 * 5239 * PARAMETERS : 5240 * @focalLength : ptr to rational strcut to store focal lenght 5241 * 5242 * RETURN : int32_t type of status 5243 * NO_ERROR -- success 5244 * none-zero failure code 5245 *==========================================================================*/ 5246int32_t QCameraParameters::getExifFocalLength(rat_t *focalLength) 5247{ 5248 int focalLengthValue = 5249 (int)(getFloat(QCameraParameters::KEY_FOCAL_LENGTH) * FOCAL_LENGTH_DECIMAL_PRECISION); 5250 return getRational(focalLength, focalLengthValue, FOCAL_LENGTH_DECIMAL_PRECISION); 5251} 5252 5253/*=========================================================================== 5254 * FUNCTION : getExifIsoSpeed 5255 * 5256 * DESCRIPTION: get exif ISO speed 5257 * 5258 * PARAMETERS : none 5259 * 5260 * RETURN : ISO speed value 5261 *==========================================================================*/ 5262uint16_t QCameraParameters::getExifIsoSpeed() 5263{ 5264 uint16_t isoSpeed = 0; 5265 const char *iso_str = get(QCameraParameters::KEY_QC_ISO_MODE); 5266 int iso_index = lookupAttr(ISO_MODES_MAP, 5267 sizeof(ISO_MODES_MAP)/sizeof(ISO_MODES_MAP[0]), iso_str); 5268 switch (iso_index) { 5269 case CAM_ISO_MODE_AUTO: 5270 isoSpeed = 0; 5271 break; 5272 case CAM_ISO_MODE_DEBLUR: 5273 isoSpeed = 1; 5274 break; 5275 case CAM_ISO_MODE_100: 5276 isoSpeed = 100; 5277 break; 5278 case CAM_ISO_MODE_200: 5279 isoSpeed = 200; 5280 break; 5281 case CAM_ISO_MODE_400: 5282 isoSpeed = 400; 5283 break; 5284 case CAM_ISO_MODE_800: 5285 isoSpeed = 800; 5286 break; 5287 case CAM_ISO_MODE_1600: 5288 isoSpeed = 1600; 5289 break; 5290 } 5291 return isoSpeed; 5292} 5293 5294/*=========================================================================== 5295 * FUNCTION : getExifGpsProcessingMethod 5296 * 5297 * DESCRIPTION: get GPS processing method 5298 * 5299 * PARAMETERS : 5300 * @gpsProcessingMethod : string to store GPS process method 5301 * @count : lenght of the string 5302 * 5303 * RETURN : int32_t type of status 5304 * NO_ERROR -- success 5305 * none-zero failure code 5306 *==========================================================================*/ 5307int32_t QCameraParameters::getExifGpsProcessingMethod(char *gpsProcessingMethod, 5308 uint32_t &count) 5309{ 5310 const char *str = get(KEY_GPS_PROCESSING_METHOD); 5311 if(str != NULL) { 5312 memcpy(gpsProcessingMethod, ExifAsciiPrefix, EXIF_ASCII_PREFIX_SIZE); 5313 count = EXIF_ASCII_PREFIX_SIZE; 5314 strncpy(gpsProcessingMethod + EXIF_ASCII_PREFIX_SIZE, str, strlen(str)); 5315 count += strlen(str); 5316 gpsProcessingMethod[count++] = '\0'; // increase 1 for the last NULL char 5317 return NO_ERROR; 5318 } else { 5319 return BAD_VALUE; 5320 } 5321} 5322 5323/*=========================================================================== 5324 * FUNCTION : getExifLatitude 5325 * 5326 * DESCRIPTION: get exif latitude 5327 * 5328 * PARAMETERS : 5329 * @latitude : ptr to rational struct to store latitude info 5330 * @ladRef : charater to indicate latitude reference 5331 * 5332 * RETURN : int32_t type of status 5333 * NO_ERROR -- success 5334 * none-zero failure code 5335 *==========================================================================*/ 5336int32_t QCameraParameters::getExifLatitude(rat_t *latitude, 5337 char *latRef) 5338{ 5339 const char *str = get(KEY_GPS_LATITUDE); 5340 if(str != NULL) { 5341 parseGPSCoordinate(str, latitude); 5342 5343 //set Latitude Ref 5344 float latitudeValue = getFloat(KEY_GPS_LATITUDE); 5345 if(latitudeValue < 0.0f) { 5346 latRef[0] = 'S'; 5347 } else { 5348 latRef[0] = 'N'; 5349 } 5350 latRef[1] = '\0'; 5351 return NO_ERROR; 5352 }else{ 5353 return BAD_VALUE; 5354 } 5355} 5356 5357/*=========================================================================== 5358 * FUNCTION : getExifLongitude 5359 * 5360 * DESCRIPTION: get exif longitude 5361 * 5362 * PARAMETERS : 5363 * @longitude : ptr to rational struct to store longitude info 5364 * @lonRef : charater to indicate longitude reference 5365 * 5366 * RETURN : int32_t type of status 5367 * NO_ERROR -- success 5368 * none-zero failure code 5369 *==========================================================================*/ 5370int32_t QCameraParameters::getExifLongitude(rat_t *longitude, 5371 char *lonRef) 5372{ 5373 const char *str = get(KEY_GPS_LONGITUDE); 5374 if(str != NULL) { 5375 parseGPSCoordinate(str, longitude); 5376 5377 //set Longitude Ref 5378 float longitudeValue = getFloat(KEY_GPS_LONGITUDE); 5379 if(longitudeValue < 0.0f) { 5380 lonRef[0] = 'W'; 5381 } else { 5382 lonRef[0] = 'E'; 5383 } 5384 lonRef[1] = '\0'; 5385 return NO_ERROR; 5386 }else{ 5387 return BAD_VALUE; 5388 } 5389} 5390 5391/*=========================================================================== 5392 * FUNCTION : getExifAltitude 5393 * 5394 * DESCRIPTION: get exif altitude 5395 * 5396 * PARAMETERS : 5397 * @altitude : ptr to rational struct to store altitude info 5398 * @altRef : charater to indicate altitude reference 5399 * 5400 * RETURN : int32_t type of status 5401 * NO_ERROR -- success 5402 * none-zero failure code 5403 *==========================================================================*/ 5404int32_t QCameraParameters::getExifAltitude(rat_t *altitude, 5405 char *altRef) 5406{ 5407 const char *str = get(KEY_GPS_ALTITUDE); 5408 if(str != NULL) { 5409 double value = atof(str); 5410 *altRef = 0; 5411 if(value < 0){ 5412 *altRef = 1; 5413 value = -value; 5414 } 5415 return getRational(altitude, value*1000, 1000); 5416 }else{ 5417 return BAD_VALUE; 5418 } 5419} 5420 5421/*=========================================================================== 5422 * FUNCTION : getExifGpsDateTimeStamp 5423 * 5424 * DESCRIPTION: get exif GPS date time stamp 5425 * 5426 * PARAMETERS : 5427 * @gpsDateStamp : GPS date time stamp string 5428 * @bufLen : length of the string 5429 * @gpsTimeStamp : ptr to rational struct to store time stamp info 5430 * 5431 * RETURN : int32_t type of status 5432 * NO_ERROR -- success 5433 * none-zero failure code 5434 *==========================================================================*/ 5435int32_t QCameraParameters::getExifGpsDateTimeStamp(char *gpsDateStamp, 5436 uint32_t bufLen, 5437 rat_t *gpsTimeStamp) 5438{ 5439 const char *str = get(KEY_GPS_TIMESTAMP); 5440 if(str != NULL) { 5441 time_t unixTime = (time_t)atol(str); 5442 struct tm *UTCTimestamp = gmtime(&unixTime); 5443 5444 strftime(gpsDateStamp, bufLen, "%Y:%m:%d", UTCTimestamp); 5445 5446 getRational(&gpsTimeStamp[0], UTCTimestamp->tm_hour, 1); 5447 getRational(&gpsTimeStamp[1], UTCTimestamp->tm_min, 1); 5448 getRational(&gpsTimeStamp[2], UTCTimestamp->tm_sec, 1); 5449 5450 return NO_ERROR; 5451 } else { 5452 return BAD_VALUE; 5453 } 5454} 5455 5456/*=========================================================================== 5457 * FUNCTION : updateFocusDistances 5458 * 5459 * DESCRIPTION: update focus distances 5460 * 5461 * PARAMETERS : 5462 * @focusDistances : ptr to focus distance info 5463 * 5464 * RETURN : int32_t type of status 5465 * NO_ERROR -- success 5466 * none-zero failure code 5467 *==========================================================================*/ 5468int32_t QCameraParameters::updateFocusDistances(cam_focus_distances_info_t *focusDistances) 5469{ 5470 String8 str; 5471 char buffer[32] = {0}; 5472 //set all distances to infinity if focus mode is infinity 5473 if(mFocusMode == CAM_FOCUS_MODE_INFINITY) { 5474 str.append("Infinity,Infinity,Infinity"); 5475 } else { 5476 snprintf(buffer, sizeof(buffer), "%f", focusDistances->focus_distance[0]); 5477 str.append(buffer); 5478 snprintf(buffer, sizeof(buffer), ",%f", focusDistances->focus_distance[1]); 5479 str.append(buffer); 5480 snprintf(buffer, sizeof(buffer), ",%f", focusDistances->focus_distance[2]); 5481 str.append(buffer); 5482 } 5483 ALOGD("%s: setting KEY_FOCUS_DISTANCES as %s", __FUNCTION__, str.string()); 5484 set(QCameraParameters::KEY_FOCUS_DISTANCES, str.string()); 5485 return NO_ERROR; 5486} 5487 5488/*=========================================================================== 5489 * FUNCTION : setHistogram 5490 * 5491 * DESCRIPTION: set histogram 5492 * 5493 * PARAMETERS : 5494 * @enabled : if histogram is enabled 5495 * 5496 * RETURN : int32_t type of status 5497 * NO_ERROR -- success 5498 * none-zero failure code 5499 *==========================================================================*/ 5500int32_t QCameraParameters::setHistogram(bool enabled) 5501{ 5502 if(m_bHistogramEnabled == enabled) { 5503 ALOGD("%s: histogram flag not changed, no ops here", __func__); 5504 return NO_ERROR; 5505 } 5506 5507 // set parm for histogram 5508 if(initBatchUpdate(m_pParamBuf) < 0 ) { 5509 ALOGE("%s:Failed to initialize group update table", __func__); 5510 return BAD_TYPE; 5511 } 5512 5513 int32_t value = enabled; 5514 int32_t rc = NO_ERROR; 5515 rc = AddSetParmEntryToBatch(m_pParamBuf, 5516 CAM_INTF_PARM_HISTOGRAM, 5517 sizeof(value), 5518 &value); 5519 if (rc != NO_ERROR) { 5520 ALOGE("%s:Failed to update table", __func__); 5521 return rc; 5522 } 5523 5524 rc = commitSetBatch(); 5525 if (rc != NO_ERROR) { 5526 ALOGE("%s:Failed to set histogram", __func__); 5527 return rc; 5528 } 5529 5530 m_bHistogramEnabled = enabled; 5531 5532 ALOGD(" Histogram -> %s", m_bHistogramEnabled ? "Enabled" : "Disabled"); 5533 5534 return rc; 5535} 5536 5537/*=========================================================================== 5538 * FUNCTION : setFaceDetection 5539 * 5540 * DESCRIPTION: set face detection 5541 * 5542 * PARAMETERS : 5543 * @enabled : if face detection is enabled 5544 * 5545 * RETURN : int32_t type of status 5546 * NO_ERROR -- success 5547 * none-zero failure code 5548 *==========================================================================*/ 5549int32_t QCameraParameters::setFaceDetection(bool enabled) 5550{ 5551 int faceProcMask = m_nFaceProcMask; 5552 // set face detection mask 5553 if (enabled) { 5554 faceProcMask |= CAM_FACE_PROCESS_MASK_DETECTION; 5555 } else { 5556 faceProcMask &= ~CAM_FACE_PROCESS_MASK_DETECTION; 5557 } 5558 5559 if(m_nFaceProcMask == faceProcMask) { 5560 ALOGD("%s: face process mask not changed, no ops here", __func__); 5561 return NO_ERROR; 5562 } 5563 5564 // set parm for face detection 5565 int requested_faces = getInt(KEY_QC_MAX_NUM_REQUESTED_FACES); 5566 cam_fd_set_parm_t fd_set_parm; 5567 memset(&fd_set_parm, 0, sizeof(cam_fd_set_parm_t)); 5568 fd_set_parm.fd_mode = faceProcMask; 5569 fd_set_parm.num_fd = requested_faces; 5570 5571 if(initBatchUpdate(m_pParamBuf) < 0 ) { 5572 ALOGE("%s:Failed to initialize group update table", __func__); 5573 return BAD_TYPE; 5574 } 5575 int32_t rc = NO_ERROR; 5576 5577 rc = AddSetParmEntryToBatch(m_pParamBuf, 5578 CAM_INTF_PARM_FD, 5579 sizeof(fd_set_parm), 5580 &fd_set_parm); 5581 if (rc != NO_ERROR) { 5582 ALOGE("%s:Failed to update table", __func__); 5583 return rc; 5584 } 5585 5586 rc = commitSetBatch(); 5587 if (rc != NO_ERROR) { 5588 ALOGE("%s:Failed to set face detection parm", __func__); 5589 return rc; 5590 } 5591 5592 m_nFaceProcMask = faceProcMask; 5593 ALOGD("%s: FaceProcMask -> %d", __func__, m_nFaceProcMask); 5594 5595 return rc; 5596} 5597 5598/*=========================================================================== 5599 * FUNCTION : setLockCAF 5600 * 5601 * DESCRIPTION: Lock CAF 5602 * 5603 * PARAMETERS : 5604 * @bLock : if CAF needs to be locked 5605 * 5606 * RETURN : int32_t type of status 5607 * NO_ERROR -- success 5608 * none-zero failure code 5609 *==========================================================================*/ 5610int32_t QCameraParameters::setLockCAF(bool bLock) 5611{ 5612 if(initBatchUpdate(m_pParamBuf) < 0 ) { 5613 ALOGE("%s:Failed to initialize group update table", __func__); 5614 return BAD_TYPE; 5615 } 5616 int32_t rc = NO_ERROR; 5617 int32_t value = bLock; 5618 5619 rc = AddSetParmEntryToBatch(m_pParamBuf, 5620 CAM_INTF_PARM_LOCK_CAF, 5621 sizeof(value), 5622 &value); 5623 if (rc != NO_ERROR) { 5624 ALOGE("%s:Failed to update table", __func__); 5625 return rc; 5626 } 5627 5628 rc = commitSetBatch(); 5629 if (rc != NO_ERROR) { 5630 ALOGE("%s:Failed to set lock CAF parm", __func__); 5631 return rc; 5632 } else { 5633 m_bCAFLocked = bLock; 5634 return NO_ERROR; 5635 } 5636} 5637 5638/*=========================================================================== 5639 * FUNCTION : setFrameSkip 5640 * 5641 * DESCRIPTION: send ISP frame skip pattern to camera daemon 5642 * 5643 * PARAMETERS : 5644 * @pattern : skip pattern for ISP 5645 * 5646 * RETURN : int32_t type of status 5647 * NO_ERROR -- success 5648 * none-zero failure code 5649 *==========================================================================*/ 5650int32_t QCameraParameters::setFrameSkip(enum msm_vfe_frame_skip_pattern pattern) 5651{ 5652 int32_t rc = NO_ERROR; 5653 int32_t value = (int32_t)pattern; 5654 5655 if(initBatchUpdate(m_pParamBuf) < 0 ) { 5656 ALOGE("%s:Failed to initialize group update table", __func__); 5657 return BAD_TYPE; 5658 } 5659 5660 rc = AddSetParmEntryToBatch(m_pParamBuf, 5661 CAM_INTF_PARM_FRAMESKIP, 5662 sizeof(value), 5663 &value); 5664 if (rc != NO_ERROR) { 5665 ALOGE("%s:Failed to update table", __func__); 5666 return rc; 5667 } 5668 5669 rc = commitSetBatch(); 5670 if (rc != NO_ERROR) { 5671 ALOGE("%s:Failed to set frameskip info parm", __func__); 5672 return rc; 5673 } 5674 5675 return rc; 5676} 5677 5678/*=========================================================================== 5679 * FUNCTION : parseNDimVector 5680 * 5681 * DESCRIPTION: helper function to parse a string like "(1, 2, 3, 4, ..., N)" 5682 * into N-dimension vector 5683 * 5684 * PARAMETERS : 5685 * @str : string to be parsed 5686 * @num : output array of size N to store vector element values 5687 * @N : number of dimension 5688 * @delim : delimeter to seperete string 5689 * 5690 * RETURN : int32_t type of status 5691 * NO_ERROR -- success 5692 * none-zero failure code 5693 *==========================================================================*/ 5694int32_t QCameraParameters::parseNDimVector(const char *str, int *num, int N, char delim = ',') 5695{ 5696 char *start, *end; 5697 if (num == NULL) { 5698 ALOGE("%s: Invalid output array (num == NULL)", __func__); 5699 return BAD_VALUE; 5700 } 5701 5702 //check if string starts and ends with parantheses 5703 if(str[0] != '(' || str[strlen(str)-1] != ')') { 5704 ALOGE("%s: Invalid format of string %s, valid format is (n1, n2, n3, n4 ...)", 5705 __func__, str); 5706 return BAD_VALUE; 5707 } 5708 start = (char*) str; 5709 start++; 5710 for(int i=0; i<N; i++) { 5711 *(num+i) = (int) strtol(start, &end, 10); 5712 if(*end != delim && i < N-1) { 5713 ALOGE("%s: Cannot find delimeter '%c' in string \"%s\". end = %c", 5714 __func__, delim, str, *end); 5715 return -1; 5716 } 5717 start = end+1; 5718 } 5719 return NO_ERROR; 5720} 5721 5722/*=========================================================================== 5723 * FUNCTION : parseCameraAreaString 5724 * 5725 * DESCRIPTION: helper function to parse a string of camera areas like 5726 * "(1, 2, 3, 4, 5),(1, 2, 3, 4, 5),..." 5727 * 5728 * PARAMETERS : 5729 * @str : string to be parsed 5730 * @max_num_areas : max number of areas 5731 * @pAreas : ptr to struct to store areas 5732 * @num_areas_found : number of areas found 5733 * 5734 * RETURN : int32_t type of status 5735 * NO_ERROR -- success 5736 * none-zero failure code 5737 *==========================================================================*/ 5738int32_t QCameraParameters::parseCameraAreaString(const char *str, 5739 int max_num_areas, 5740 cam_area_t *pAreas, 5741 int& num_areas_found) 5742{ 5743 char area_str[32]; 5744 const char *start, *end, *p; 5745 start = str; end = NULL; 5746 int values[5], index=0; 5747 num_areas_found = 0; 5748 5749 memset(values, 0, sizeof(values)); 5750 while(start != NULL) { 5751 if(*start != '(') { 5752 ALOGE("%s: error: Ill formatted area string: %s", __func__, str); 5753 return BAD_VALUE; 5754 } 5755 end = strchr(start, ')'); 5756 if(end == NULL) { 5757 ALOGE("%s: error: Ill formatted area string: %s", __func__, str); 5758 return BAD_VALUE; 5759 } 5760 int i; 5761 for (i=0,p=start; p<=end; p++, i++) { 5762 area_str[i] = *p; 5763 } 5764 area_str[i] = '\0'; 5765 if(parseNDimVector(area_str, values, 5) < 0){ 5766 ALOGE("%s: error: Failed to parse the area string: %s", __func__, area_str); 5767 return BAD_VALUE; 5768 } 5769 // no more areas than max_num_areas are accepted. 5770 if(index >= max_num_areas) { 5771 ALOGE("%s: error: too many areas specified %s", __func__, str); 5772 return BAD_VALUE; 5773 } 5774 pAreas[index].rect.left = values[0]; 5775 pAreas[index].rect.top = values[1]; 5776 pAreas[index].rect.width = values[2] - values[0]; 5777 pAreas[index].rect.height = values[3] - values[1]; 5778 pAreas[index].weight = values[4]; 5779 5780 index++; 5781 start = strchr(end, '('); // serach for next '(' 5782 } 5783 num_areas_found = index; 5784 return 0; 5785} 5786 5787/*=========================================================================== 5788 * FUNCTION : validateCameraAreas 5789 * 5790 * DESCRIPTION: helper function to validate camera areas within (-1000, 1000) 5791 * 5792 * PARAMETERS : 5793 * @areas : ptr to array of areas 5794 * @num_areas : number of areas 5795 * 5796 * RETURN : true -- area is in valid range 5797 * false -- not valid 5798 *==========================================================================*/ 5799bool QCameraParameters::validateCameraAreas(cam_area_t *areas, int num_areas) 5800{ 5801 // special case: default area 5802 if (num_areas == 1 && 5803 areas[0].rect.left == 0 && 5804 areas[0].rect.top == 0 && 5805 areas[0].rect.width == 0 && 5806 areas[0].rect.height == 0 && 5807 areas[0].weight == 0) { 5808 return true; 5809 } 5810 5811 for(int i = 0; i < num_areas; i++) { 5812 // left should be >= -1000 5813 if(areas[i].rect.left < -1000) { 5814 return false; 5815 } 5816 5817 // top should be >= -1000 5818 if(areas[i].rect.top < -1000) { 5819 return false; 5820 } 5821 5822 // width or height should be > 0 5823 if (areas[i].rect.width <= 0 || areas[i].rect.height <= 0) { 5824 return false; 5825 } 5826 5827 // right should be <= 1000 5828 if(areas[i].rect.left + areas[i].rect.width > 1000) { 5829 return false; 5830 } 5831 5832 // bottom should be <= 1000 5833 if(areas[i].rect.top + areas[i].rect.height > 1000) { 5834 return false; 5835 } 5836 5837 // weight should be within (1, 1000) 5838 if (areas[i].weight < 1 || areas[i].weight > 1000) { 5839 return false; 5840 } 5841 } 5842 return true; 5843} 5844 5845/*=========================================================================== 5846 * FUNCTION : initBatchUpdate 5847 * 5848 * DESCRIPTION: init camera parameters buf entries 5849 * 5850 * PARAMETERS : 5851 * @p_table : ptr to parameter buffer 5852 * 5853 * RETURN : int32_t type of status 5854 * NO_ERROR -- success 5855 * none-zero failure code 5856 *==========================================================================*/ 5857int32_t QCameraParameters::initBatchUpdate(parm_buffer_t *p_table) 5858{ 5859 int32_t hal_version = CAM_HAL_V1; 5860 m_tempMap.clear(); 5861 5862 memset(p_table, 0, sizeof(parm_buffer_t)); 5863 p_table->first_flagged_entry = CAM_INTF_PARM_MAX; 5864 AddSetParmEntryToBatch(p_table, CAM_INTF_PARM_HAL_VERSION, 5865 sizeof(hal_version), &hal_version); 5866 return NO_ERROR; 5867} 5868 5869/*=========================================================================== 5870 * FUNCTION : AddSetParmEntryToBatch 5871 * 5872 * DESCRIPTION: add set parameter entry into batch 5873 * 5874 * PARAMETERS : 5875 * @p_table : ptr to parameter buffer 5876 * @paramType : parameter type 5877 * @paramLength : length of parameter value 5878 * @paramValue : ptr to parameter value 5879 * 5880 * RETURN : int32_t type of status 5881 * NO_ERROR -- success 5882 * none-zero failure code 5883 *==========================================================================*/ 5884int32_t QCameraParameters::AddSetParmEntryToBatch(parm_buffer_t *p_table, 5885 cam_intf_parm_type_t paramType, 5886 uint32_t paramLength, 5887 void *paramValue) 5888{ 5889 int position = paramType; 5890 int current, next; 5891 5892 /************************************************************************* 5893 * Code to take care of linking next flags * 5894 *************************************************************************/ 5895 current = GET_FIRST_PARAM_ID(p_table); 5896 if (position == current){ 5897 //DO NOTHING 5898 } else if (position < current){ 5899 SET_NEXT_PARAM_ID(position, p_table, current); 5900 SET_FIRST_PARAM_ID(p_table, position); 5901 } else { 5902 /* Search for the position in the linked list where we need to slot in*/ 5903 while (position > GET_NEXT_PARAM_ID(current, p_table)) 5904 current = GET_NEXT_PARAM_ID(current, p_table); 5905 5906 /*If node already exists no need to alter linking*/ 5907 if (position != GET_NEXT_PARAM_ID(current, p_table)) { 5908 next = GET_NEXT_PARAM_ID(current, p_table); 5909 SET_NEXT_PARAM_ID(current, p_table, position); 5910 SET_NEXT_PARAM_ID(position, p_table, next); 5911 } 5912 } 5913 5914 /************************************************************************* 5915 * Copy contents into entry * 5916 *************************************************************************/ 5917 5918 if (paramLength > sizeof(parm_type_t)) { 5919 ALOGE("%s:Size of input larger than max entry size",__func__); 5920 return BAD_VALUE; 5921 } 5922 memcpy(POINTER_OF(paramType,p_table), paramValue, paramLength); 5923 return NO_ERROR; 5924} 5925 5926/*=========================================================================== 5927 * FUNCTION : AddGetParmEntryToBatch 5928 * 5929 * DESCRIPTION: add get parameter entry into batch 5930 * 5931 * PARAMETERS : 5932 * @p_table : ptr to parameter buffer 5933 * @paramType : parameter type 5934 * 5935 * RETURN : int32_t type of status 5936 * NO_ERROR -- success 5937 * none-zero failure code 5938 *==========================================================================*/ 5939int32_t QCameraParameters::AddGetParmEntryToBatch(parm_buffer_t *p_table, 5940 cam_intf_parm_type_t paramType) 5941{ 5942 int position = paramType; 5943 int current, next; 5944 5945 /************************************************************************* 5946 * Code to take care of linking next flags * 5947 *************************************************************************/ 5948 current = GET_FIRST_PARAM_ID(p_table); 5949 if (position == current){ 5950 //DO NOTHING 5951 } else if (position < current){ 5952 SET_NEXT_PARAM_ID(position, p_table, current); 5953 SET_FIRST_PARAM_ID(p_table, position); 5954 } else { 5955 /* Search for the position in the linked list where we need to slot in*/ 5956 while (position > GET_NEXT_PARAM_ID(current, p_table)) 5957 current = GET_NEXT_PARAM_ID(current, p_table); 5958 5959 /*If node already exists no need to alter linking*/ 5960 if (position != GET_NEXT_PARAM_ID(current, p_table)) { 5961 next=GET_NEXT_PARAM_ID(current, p_table); 5962 SET_NEXT_PARAM_ID(current, p_table, position); 5963 SET_NEXT_PARAM_ID(position, p_table, next); 5964 } 5965 } 5966 5967 return NO_ERROR; 5968} 5969 5970/*=========================================================================== 5971 * FUNCTION : commitSetBatch 5972 * 5973 * DESCRIPTION: commit all set parameters in the batch work to backend 5974 * 5975 * PARAMETERS : none 5976 * 5977 * RETURN : int32_t type of status 5978 * NO_ERROR -- success 5979 * none-zero failure code 5980 *==========================================================================*/ 5981int32_t QCameraParameters::commitSetBatch() 5982{ 5983 int32_t rc = NO_ERROR; 5984 if (m_pParamBuf->first_flagged_entry < CAM_INTF_PARM_MAX) { 5985 rc = m_pCamOpsTbl->ops->set_parms(m_pCamOpsTbl->camera_handle, m_pParamBuf); 5986 } 5987 if (rc == NO_ERROR) { 5988 // commit change from temp storage into param map 5989 rc = commitParamChanges(); 5990 } 5991 return rc; 5992} 5993 5994/*=========================================================================== 5995 * FUNCTION : commitGetBatch 5996 * 5997 * DESCRIPTION: commit all get parameters in the batch work to backend 5998 * 5999 * PARAMETERS : none 6000 * 6001 * RETURN : int32_t type of status 6002 * NO_ERROR -- success 6003 * none-zero failure code 6004 *==========================================================================*/ 6005int32_t QCameraParameters::commitGetBatch() 6006{ 6007 if (m_pParamBuf->first_flagged_entry < CAM_INTF_PARM_MAX) { 6008 return m_pCamOpsTbl->ops->get_parms(m_pCamOpsTbl->camera_handle, m_pParamBuf); 6009 } else { 6010 return NO_ERROR; 6011 } 6012} 6013 6014/*=========================================================================== 6015 * FUNCTION : updateParamEntry 6016 * 6017 * DESCRIPTION: update a parameter entry in the local temp map obj 6018 * 6019 * PARAMETERS : 6020 * @key : key of the entry 6021 * @value : value of the entry 6022 * 6023 * RETURN : int32_t type of status 6024 * NO_ERROR -- success 6025 * none-zero failure code 6026 *==========================================================================*/ 6027int32_t QCameraParameters::updateParamEntry(const char *key, const char *value) 6028{ 6029 m_tempMap.replaceValueFor(String8(key), String8(value)); 6030 return NO_ERROR; 6031} 6032 6033/*=========================================================================== 6034 * FUNCTION : commitParamChanges 6035 * 6036 * DESCRIPTION: commit all changes in local temp map obj into parameter obj 6037 * 6038 * PARAMETERS : none 6039 * 6040 * RETURN : int32_t type of status 6041 * NO_ERROR -- success 6042 * none-zero failure code 6043 *==========================================================================*/ 6044int32_t QCameraParameters::commitParamChanges() 6045{ 6046 size_t size = m_tempMap.size(); 6047 for (size_t i = 0; i < size; i++) { 6048 String8 k, v; 6049 k = m_tempMap.keyAt(i); 6050 v = m_tempMap.valueAt(i); 6051 set(k, v); 6052 } 6053 m_tempMap.clear(); 6054 return NO_ERROR; 6055} 6056 6057}; // namespace qcamera 6058