blob: 1fa37622497c15944eff877897d7c5a21479efb3 [file] [log] [blame]
/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#define LOG_TAG "QCameraParameters"
#include <cutils/properties.h>
#include <math.h>
#include <utils/Errors.h>
#include <string.h>
#include <stdlib.h>
#include <gralloc_priv.h>
#include "QCamera2HWI.h"
#include "QCameraParameters.h"
#define ASPECT_TOLERANCE 0.001
#define FLIP_V_H (FLIP_H | FLIP_V)
namespace qcamera {
// Parameter keys to communicate between camera application and driver.
const char QCameraParameters::KEY_QC_SUPPORTED_HFR_SIZES[] = "hfr-size-values";
const char QCameraParameters::KEY_QC_PREVIEW_FRAME_RATE_MODE[] = "preview-frame-rate-mode";
const char QCameraParameters::KEY_QC_SUPPORTED_PREVIEW_FRAME_RATE_MODES[] = "preview-frame-rate-modes";
const char QCameraParameters::KEY_QC_PREVIEW_FRAME_RATE_AUTO_MODE[] = "frame-rate-auto";
const char QCameraParameters::KEY_QC_PREVIEW_FRAME_RATE_FIXED_MODE[] = "frame-rate-fixed";
const char QCameraParameters::KEY_QC_TOUCH_AF_AEC[] = "touch-af-aec";
const char QCameraParameters::KEY_QC_SUPPORTED_TOUCH_AF_AEC[] = "touch-af-aec-values";
const char QCameraParameters::KEY_QC_TOUCH_INDEX_AEC[] = "touch-index-aec";
const char QCameraParameters::KEY_QC_TOUCH_INDEX_AF[] = "touch-index-af";
const char QCameraParameters::KEY_QC_SCENE_DETECT[] = "scene-detect";
const char QCameraParameters::KEY_QC_SUPPORTED_SCENE_DETECT[] = "scene-detect-values";
const char QCameraParameters::KEY_QC_ISO_MODE[] = "iso";
const char QCameraParameters::KEY_QC_SUPPORTED_ISO_MODES[] = "iso-values";
const char QCameraParameters::KEY_QC_LENSSHADE[] = "lensshade";
const char QCameraParameters::KEY_QC_SUPPORTED_LENSSHADE_MODES[] = "lensshade-values";
const char QCameraParameters::KEY_QC_AUTO_EXPOSURE[] = "auto-exposure";
const char QCameraParameters::KEY_QC_SUPPORTED_AUTO_EXPOSURE[] = "auto-exposure-values";
const char QCameraParameters::KEY_QC_DENOISE[] = "denoise";
const char QCameraParameters::KEY_QC_SUPPORTED_DENOISE[] = "denoise-values";
const char QCameraParameters::KEY_QC_FOCUS_ALGO[] = "selectable-zone-af";
const char QCameraParameters::KEY_QC_SUPPORTED_FOCUS_ALGOS[] = "selectable-zone-af-values";
const char QCameraParameters::KEY_QC_FACE_DETECTION[] = "face-detection";
const char QCameraParameters::KEY_QC_SUPPORTED_FACE_DETECTION[] = "face-detection-values";
const char QCameraParameters::KEY_QC_FACE_RECOGNITION[] = "face-recognition";
const char QCameraParameters::KEY_QC_SUPPORTED_FACE_RECOGNITION[] = "face-recognition-values";
const char QCameraParameters::KEY_QC_MEMORY_COLOR_ENHANCEMENT[] = "mce";
const char QCameraParameters::KEY_QC_SUPPORTED_MEM_COLOR_ENHANCE_MODES[] = "mce-values";
const char QCameraParameters::KEY_QC_DIS[] = "dis";
const char QCameraParameters::KEY_QC_SUPPORTED_DIS_MODES[] = "dis-values";
const char QCameraParameters::KEY_QC_VIDEO_HIGH_FRAME_RATE[] = "video-hfr";
const char QCameraParameters::KEY_QC_VIDEO_HIGH_SPEED_RECORDING[] = "video-hsr";
const char QCameraParameters::KEY_QC_SUPPORTED_VIDEO_HIGH_FRAME_RATE_MODES[] = "video-hfr-values";
const char QCameraParameters::KEY_QC_REDEYE_REDUCTION[] = "redeye-reduction";
const char QCameraParameters::KEY_QC_SUPPORTED_REDEYE_REDUCTION[] = "redeye-reduction-values";
const char QCameraParameters::KEY_QC_HIGH_DYNAMIC_RANGE_IMAGING[] = "hdr";
const char QCameraParameters::KEY_QC_SUPPORTED_HDR_IMAGING_MODES[] = "hdr-values";
const char QCameraParameters::KEY_QC_ZSL[] = "zsl";
const char QCameraParameters::KEY_QC_SUPPORTED_ZSL_MODES[] = "zsl-values";
const char QCameraParameters::KEY_QC_ZSL_BURST_INTERVAL[] = "capture-burst-interval";
const char QCameraParameters::KEY_QC_ZSL_BURST_LOOKBACK[] = "capture-burst-retroactive";
const char QCameraParameters::KEY_QC_ZSL_QUEUE_DEPTH[] = "capture-burst-queue-depth";
const char QCameraParameters::KEY_QC_CAMERA_MODE[] = "camera-mode";
const char QCameraParameters::KEY_QC_AE_BRACKET_HDR[] = "ae-bracket-hdr";
const char QCameraParameters::KEY_QC_SUPPORTED_AE_BRACKET_MODES[] = "ae-bracket-hdr-values";
const char QCameraParameters::KEY_QC_SUPPORTED_RAW_FORMATS[] = "raw-format-values";
const char QCameraParameters::KEY_QC_RAW_FORMAT[] = "raw-format";
const char QCameraParameters::KEY_QC_ORIENTATION[] = "orientation";
const char QCameraParameters::KEY_QC_SELECTABLE_ZONE_AF[] = "selectable-zone-af";
const char QCameraParameters::KEY_QC_CAPTURE_BURST_EXPOSURE[] = "capture-burst-exposures";
const char QCameraParameters::KEY_QC_NUM_SNAPSHOT_PER_SHUTTER[] = "num-snaps-per-shutter";
const char QCameraParameters::KEY_QC_NUM_RETRO_BURST_PER_SHUTTER[] = "num-retro-burst-per-shutter";
const char QCameraParameters::KEY_QC_SNAPSHOT_BURST_LED_ON_PERIOD[] = "zsl-burst-led-on-period";
const char QCameraParameters::KEY_QC_NO_DISPLAY_MODE[] = "no-display-mode";
const char QCameraParameters::KEY_QC_RAW_PICUTRE_SIZE[] = "raw-size";
const char QCameraParameters::KEY_QC_SUPPORTED_SKIN_TONE_ENHANCEMENT_MODES[] = "skinToneEnhancement-values";
const char QCameraParameters::KEY_QC_SUPPORTED_LIVESNAPSHOT_SIZES[] = "supported-live-snapshot-sizes";
const char QCameraParameters::KEY_QC_HDR_NEED_1X[] = "hdr-need-1x";
const char QCameraParameters::KEY_QC_PREVIEW_FLIP[] = "preview-flip";
const char QCameraParameters::KEY_QC_VIDEO_FLIP[] = "video-flip";
const char QCameraParameters::KEY_QC_SNAPSHOT_PICTURE_FLIP[] = "snapshot-picture-flip";
const char QCameraParameters::KEY_QC_SUPPORTED_FLIP_MODES[] = "flip-mode-values";
const char QCameraParameters::KEY_QC_VIDEO_HDR[] = "video-hdr";
const char QCameraParameters::KEY_QC_SENSOR_HDR[] = "sensor-hdr";
const char QCameraParameters::KEY_QC_VT_ENABLE[] = "avtimer";
const char QCameraParameters::KEY_QC_SUPPORTED_VIDEO_HDR_MODES[] = "video-hdr-values";
const char QCameraParameters::KEY_QC_SUPPORTED_SENSOR_HDR_MODES[] = "sensor-hdr-values";
const char QCameraParameters::KEY_QC_AUTO_HDR_ENABLE [] = "auto-hdr-enable";
const char QCameraParameters::KEY_QC_SNAPSHOT_BURST_NUM[] = "snapshot-burst-num";
const char QCameraParameters::KEY_QC_SNAPSHOT_FD_DATA[] = "snapshot-fd-data-enable";
const char QCameraParameters::KEY_QC_TINTLESS_ENABLE[] = "tintless";
const char QCameraParameters::KEY_QC_SCENE_SELECTION[] = "scene-selection";
const char QCameraParameters::KEY_QC_CDS_MODE[] = "cds-mode";
const char QCameraParameters::KEY_QC_VIDEO_ROTATION[] = "video-rotation";
const char QCameraParameters::KEY_QC_AF_BRACKET[] = "af-bracket";
const char QCameraParameters::KEY_QC_SUPPORTED_AF_BRACKET_MODES[] = "af-bracket-values";
const char QCameraParameters::KEY_QC_RE_FOCUS[] = "re-focus";
const char QCameraParameters::KEY_QC_SUPPORTED_RE_FOCUS_MODES[] = "re-focus-values";
const char QCameraParameters::KEY_QC_CHROMA_FLASH[] = "chroma-flash";
const char QCameraParameters::KEY_QC_SUPPORTED_CHROMA_FLASH_MODES[] = "chroma-flash-values";
const char QCameraParameters::KEY_QC_OPTI_ZOOM[] = "opti-zoom";
const char QCameraParameters::KEY_QC_SUPPORTED_OPTI_ZOOM_MODES[] = "opti-zoom-values";
const char QCameraParameters::KEY_INTERNAL_PERVIEW_RESTART[] = "internal-restart";
const char QCameraParameters::KEY_QC_RDI_MODE[] = "rdi-mode";
const char QCameraParameters::KEY_QC_SUPPORTED_RDI_MODES[] = "rdi-mode-values";
const char QCameraParameters::KEY_QC_SECURE_MODE[] = "secure-mode";
const char QCameraParameters::KEY_QC_SUPPORTED_SECURE_MODES[] = "secure-mode-values";
const char QCameraParameters::KEY_QC_AUTO_HDR_SUPPORTED[] = "auto-hdr-supported";
// Values for effect settings.
const char QCameraParameters::EFFECT_EMBOSS[] = "emboss";
const char QCameraParameters::EFFECT_SKETCH[] = "sketch";
const char QCameraParameters::EFFECT_NEON[] = "neon";
// Values for auto exposure settings.
const char QCameraParameters::TOUCH_AF_AEC_OFF[] = "touch-off";
const char QCameraParameters::TOUCH_AF_AEC_ON[] = "touch-on";
// Values for scene mode settings.
const char QCameraParameters::SCENE_MODE_ASD[] = "asd"; // corresponds to CAMERA_BESTSHOT_AUTO in HAL
const char QCameraParameters::SCENE_MODE_BACKLIGHT[] = "backlight";
const char QCameraParameters::SCENE_MODE_FLOWERS[] = "flowers";
const char QCameraParameters::SCENE_MODE_AR[] = "AR";
const char QCameraParameters::SCENE_MODE_HDR[] = "hdr";
// Formats for setPreviewFormat and setPictureFormat.
const char QCameraParameters::PIXEL_FORMAT_YUV420SP_ADRENO[] = "yuv420sp-adreno";
const char QCameraParameters::PIXEL_FORMAT_YV12[] = "yuv420p";
const char QCameraParameters::PIXEL_FORMAT_NV12[] = "nv12";
const char QCameraParameters::QC_PIXEL_FORMAT_NV12_VENUS[] = "nv12-venus";
// Values for raw image formats
const char QCameraParameters::QC_PIXEL_FORMAT_YUV_RAW_8BIT_YUYV[] = "yuv-raw8-yuyv";
const char QCameraParameters::QC_PIXEL_FORMAT_YUV_RAW_8BIT_YVYU[] = "yuv-raw8-yvyu";
const char QCameraParameters::QC_PIXEL_FORMAT_YUV_RAW_8BIT_UYVY[] = "yuv-raw8-uyvy";
const char QCameraParameters::QC_PIXEL_FORMAT_YUV_RAW_8BIT_VYUY[] = "yuv-raw8-vyuy";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8GBRG[] = "bayer-qcom-8gbrg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8GRBG[] = "bayer-qcom-8grbg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8RGGB[] = "bayer-qcom-8rggb";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8BGGR[] = "bayer-qcom-8bggr";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10GBRG[] = "bayer-qcom-10gbrg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10GRBG[] = "bayer-qcom-10grbg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10RGGB[] = "bayer-qcom-10rggb";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10BGGR[] = "bayer-qcom-10bggr";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12GBRG[] = "bayer-qcom-12gbrg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12GRBG[] = "bayer-qcom-12grbg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12RGGB[] = "bayer-qcom-12rggb";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12BGGR[] = "bayer-qcom-12bggr";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8GBRG[] = "bayer-mipi-8gbrg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8GRBG[] = "bayer-mipi-8grbg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8RGGB[] = "bayer-mipi-8rggb";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8BGGR[] = "bayer-mipi-8bggr";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10GBRG[] = "bayer-mipi-10gbrg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10GRBG[] = "bayer-mipi-10grbg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10RGGB[] = "bayer-mipi-10rggb";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10BGGR[] = "bayer-mipi-10bggr";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12GBRG[] = "bayer-mipi-12gbrg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12GRBG[] = "bayer-mipi-12grbg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12RGGB[] = "bayer-mipi-12rggb";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12BGGR[] = "bayer-mipi-12bggr";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8GBRG[] = "bayer-ideal-qcom-8gbrg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8GRBG[] = "bayer-ideal-qcom-8grbg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8RGGB[] = "bayer-ideal-qcom-8rggb";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8BGGR[] = "bayer-ideal-qcom-8bggr";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10GBRG[] = "bayer-ideal-qcom-10gbrg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10GRBG[] = "bayer-ideal-qcom-10grbg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10RGGB[] = "bayer-ideal-qcom-10rggb";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10BGGR[] = "bayer-ideal-qcom-10bggr";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12GBRG[] = "bayer-ideal-qcom-12gbrg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12GRBG[] = "bayer-ideal-qcom-12grbg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12RGGB[] = "bayer-ideal-qcom-12rggb";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12BGGR[] = "bayer-ideal-qcom-12bggr";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8GBRG[] = "bayer-ideal-mipi-8gbrg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8GRBG[] = "bayer-ideal-mipi-8grbg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8RGGB[] = "bayer-ideal-mipi-8rggb";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8BGGR[] = "bayer-ideal-mipi-8bggr";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10GBRG[] = "bayer-ideal-mipi-10gbrg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10GRBG[] = "bayer-ideal-mipi-10grbg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10RGGB[] = "bayer-ideal-mipi-10rggb";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10BGGR[] = "bayer-ideal-mipi-10bggr";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12GBRG[] = "bayer-ideal-mipi-12gbrg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12GRBG[] = "bayer-ideal-mipi-12grbg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12RGGB[] = "bayer-ideal-mipi-12rggb";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12BGGR[] = "bayer-ideal-mipi-12bggr";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8GBRG[] = "bayer-ideal-plain8-8gbrg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8GRBG[] = "bayer-ideal-plain8-8grbg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8RGGB[] = "bayer-ideal-plain8-8rggb";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8BGGR[] = "bayer-ideal-plain8-8bggr";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8GBRG[] = "bayer-ideal-plain16-8gbrg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8GRBG[] = "bayer-ideal-plain16-8grbg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8RGGB[] = "bayer-ideal-plain16-8rggb";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8BGGR[] = "bayer-ideal-plain16-8bggr";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10GBRG[] = "bayer-ideal-plain16-10gbrg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10GRBG[] = "bayer-ideal-plain16-10grbg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10RGGB[] = "bayer-ideal-plain16-10rggb";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10BGGR[] = "bayer-ideal-plain16-10bggr";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12GBRG[] = "bayer-ideal-plain16-12gbrg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12GRBG[] = "bayer-ideal-plain16-12grbg";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12RGGB[] = "bayer-ideal-plain16-12rggb";
const char QCameraParameters::QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12BGGR[] = "bayer-ideal-plain16-12bggr";
// Values for ISO Settings
const char QCameraParameters::ISO_AUTO[] = "auto";
const char QCameraParameters::ISO_HJR[] = "ISO_HJR";
const char QCameraParameters::ISO_100[] = "ISO100";
const char QCameraParameters::ISO_200[] = "ISO200";
const char QCameraParameters::ISO_400[] = "ISO400";
const char QCameraParameters::ISO_800[] = "ISO800";
const char QCameraParameters::ISO_1600[] = "ISO1600";
// Values for auto exposure settings.
const char QCameraParameters::AUTO_EXPOSURE_FRAME_AVG[] = "frame-average";
const char QCameraParameters::AUTO_EXPOSURE_CENTER_WEIGHTED[] = "center-weighted";
const char QCameraParameters::AUTO_EXPOSURE_SPOT_METERING[] = "spot-metering";
const char QCameraParameters::AUTO_EXPOSURE_SMART_METERING[] = "smart-metering";
const char QCameraParameters::AUTO_EXPOSURE_USER_METERING[] = "user-metering";
const char QCameraParameters::AUTO_EXPOSURE_SPOT_METERING_ADV[] = "spot-metering-adv";
const char QCameraParameters::AUTO_EXPOSURE_CENTER_WEIGHTED_ADV[] = "center-weighted-adv";
const char QCameraParameters::KEY_QC_GPS_LATITUDE_REF[] = "gps-latitude-ref";
const char QCameraParameters::KEY_QC_GPS_LONGITUDE_REF[] = "gps-longitude-ref";
const char QCameraParameters::KEY_QC_GPS_ALTITUDE_REF[] = "gps-altitude-ref";
const char QCameraParameters::KEY_QC_GPS_STATUS[] = "gps-status";
const char QCameraParameters::KEY_QC_HISTOGRAM[] = "histogram";
const char QCameraParameters::KEY_QC_SUPPORTED_HISTOGRAM_MODES[] = "histogram-values";
const char QCameraParameters::VALUE_ENABLE[] = "enable";
const char QCameraParameters::VALUE_DISABLE[] = "disable";
const char QCameraParameters::VALUE_OFF[] = "off";
const char QCameraParameters::VALUE_ON[] = "on";
const char QCameraParameters::VALUE_TRUE[] = "true";
const char QCameraParameters::VALUE_FALSE[] = "false";
const char QCameraParameters::KEY_QC_SHARPNESS[] = "sharpness";
const char QCameraParameters::KEY_QC_MIN_SHARPNESS[] = "min-sharpness";
const char QCameraParameters::KEY_QC_MAX_SHARPNESS[] = "max-sharpness";
const char QCameraParameters::KEY_QC_SHARPNESS_STEP[] = "sharpness-step";
const char QCameraParameters::KEY_QC_CONTRAST[] = "contrast";
const char QCameraParameters::KEY_QC_MIN_CONTRAST[] = "min-contrast";
const char QCameraParameters::KEY_QC_MAX_CONTRAST[] = "max-contrast";
const char QCameraParameters::KEY_QC_CONTRAST_STEP[] = "contrast-step";
const char QCameraParameters::KEY_QC_SATURATION[] = "saturation";
const char QCameraParameters::KEY_QC_MIN_SATURATION[] = "min-saturation";
const char QCameraParameters::KEY_QC_MAX_SATURATION[] = "max-saturation";
const char QCameraParameters::KEY_QC_SATURATION_STEP[] = "saturation-step";
const char QCameraParameters::KEY_QC_BRIGHTNESS[] = "luma-adaptation";
const char QCameraParameters::KEY_QC_MIN_BRIGHTNESS[] = "min-brightness";
const char QCameraParameters::KEY_QC_MAX_BRIGHTNESS[] = "max-brightness";
const char QCameraParameters::KEY_QC_BRIGHTNESS_STEP[] = "brightness-step";
const char QCameraParameters::KEY_QC_SCE_FACTOR[] = "skinToneEnhancement";
const char QCameraParameters::KEY_QC_MIN_SCE_FACTOR[] = "min-sce-factor";
const char QCameraParameters::KEY_QC_MAX_SCE_FACTOR[] = "max-sce-factor";
const char QCameraParameters::KEY_QC_SCE_FACTOR_STEP[] = "sce-factor-step";
const char QCameraParameters::KEY_QC_SUPPORTED_CAMERA_FEATURES[] = "qc-camera-features";
const char QCameraParameters::KEY_QC_MAX_NUM_REQUESTED_FACES[] = "qc-max-num-requested-faces";
//Values for DENOISE
const char QCameraParameters::DENOISE_OFF[] = "denoise-off";
const char QCameraParameters::DENOISE_ON[] = "denoise-on";
// Values for selectable zone af Settings
const char QCameraParameters::FOCUS_ALGO_AUTO[] = "auto";
const char QCameraParameters::FOCUS_ALGO_SPOT_METERING[] = "spot-metering";
const char QCameraParameters::FOCUS_ALGO_CENTER_WEIGHTED[] = "center-weighted";
const char QCameraParameters::FOCUS_ALGO_FRAME_AVERAGE[] = "frame-average";
// Values for HFR settings.
const char QCameraParameters::VIDEO_HFR_OFF[] = "off";
const char QCameraParameters::VIDEO_HFR_2X[] = "60";
const char QCameraParameters::VIDEO_HFR_3X[] = "90";
const char QCameraParameters::VIDEO_HFR_4X[] = "120";
const char QCameraParameters::VIDEO_HFR_5X[] = "150";
// Values for HDR Bracketing settings.
const char QCameraParameters::AE_BRACKET_OFF[] = "Off";
const char QCameraParameters::AE_BRACKET[] = "AE-Bracket";
// Values for AF Bracketing setting.
const char QCameraParameters::AF_BRACKET_OFF[] = "af-bracket-off";
const char QCameraParameters::AF_BRACKET_ON[] = "af-bracket-on";
// Values for Refocus setting.
const char QCameraParameters::RE_FOCUS_OFF[] = "re-focus-off";
const char QCameraParameters::RE_FOCUS_ON[] = "re-focus-on";
// Values for Chroma Flash setting.
const char QCameraParameters::CHROMA_FLASH_OFF[] = "chroma-flash-off";
const char QCameraParameters::CHROMA_FLASH_ON[] = "chroma-flash-on";
// Values for Opti Zoom setting.
const char QCameraParameters::OPTI_ZOOM_OFF[] = "opti-zoom-off";
const char QCameraParameters::OPTI_ZOOM_ON[] = "opti-zoom-on";
// Values for FLIP settings.
const char QCameraParameters::FLIP_MODE_OFF[] = "off";
const char QCameraParameters::FLIP_MODE_V[] = "flip-v";
const char QCameraParameters::FLIP_MODE_H[] = "flip-h";
const char QCameraParameters::FLIP_MODE_VH[] = "flip-vh";
const char QCameraParameters::CDS_MODE_OFF[] = "off";
const char QCameraParameters::CDS_MODE_ON[] = "on";
const char QCameraParameters::CDS_MODE_AUTO[] = "auto";
const char QCameraParameters::KEY_SELECTED_AUTO_SCENE[] = "selected-auto-scene";
static const char* portrait = "portrait";
static const char* landscape = "landscape";
const cam_dimension_t QCameraParameters::THUMBNAIL_SIZES_MAP[] = {
{ 512, 288 }, //1.777778
{ 480, 288 }, //1.666667
{ 256, 154 }, //1.66233
{ 432, 288 }, //1.5
{ 320, 240 }, //1.33333
{ 176, 144 }, //1.222222
{ 0, 0 } // required by Android SDK
};
const QCameraParameters::QCameraMap QCameraParameters::AUTO_EXPOSURE_MAP[] = {
{ AUTO_EXPOSURE_FRAME_AVG, CAM_AEC_MODE_FRAME_AVERAGE },
{ AUTO_EXPOSURE_CENTER_WEIGHTED, CAM_AEC_MODE_CENTER_WEIGHTED },
{ AUTO_EXPOSURE_SPOT_METERING, CAM_AEC_MODE_SPOT_METERING },
{ AUTO_EXPOSURE_SMART_METERING, CAM_AEC_MODE_SMART_METERING },
{ AUTO_EXPOSURE_USER_METERING, CAM_AEC_MODE_USER_METERING },
{ AUTO_EXPOSURE_SPOT_METERING_ADV, CAM_AEC_MODE_SPOT_METERING_ADV },
{ AUTO_EXPOSURE_CENTER_WEIGHTED_ADV, CAM_AEC_MODE_CENTER_WEIGHTED_ADV },
};
const QCameraParameters::QCameraMap QCameraParameters::PREVIEW_FORMATS_MAP[] = {
{PIXEL_FORMAT_YUV420SP, CAM_FORMAT_YUV_420_NV21},
{PIXEL_FORMAT_YUV420P, CAM_FORMAT_YUV_420_YV12},
{PIXEL_FORMAT_YUV420SP_ADRENO, CAM_FORMAT_YUV_420_NV21_ADRENO},
{PIXEL_FORMAT_YV12, CAM_FORMAT_YUV_420_YV12},
{PIXEL_FORMAT_NV12, CAM_FORMAT_YUV_420_NV12},
{QC_PIXEL_FORMAT_NV12_VENUS, CAM_FORMAT_YUV_420_NV12_VENUS}
};
const QCameraParameters::QCameraMap QCameraParameters::PICTURE_TYPES_MAP[] = {
{PIXEL_FORMAT_JPEG, CAM_FORMAT_JPEG},
{PIXEL_FORMAT_YUV420SP, CAM_FORMAT_YUV_420_NV21},
{PIXEL_FORMAT_YUV422SP, CAM_FORMAT_YUV_422_NV16},
{QC_PIXEL_FORMAT_YUV_RAW_8BIT_YUYV, CAM_FORMAT_YUV_RAW_8BIT_YUYV},
{QC_PIXEL_FORMAT_YUV_RAW_8BIT_YVYU, CAM_FORMAT_YUV_RAW_8BIT_YVYU},
{QC_PIXEL_FORMAT_YUV_RAW_8BIT_UYVY, CAM_FORMAT_YUV_RAW_8BIT_UYVY},
{QC_PIXEL_FORMAT_YUV_RAW_8BIT_VYUY, CAM_FORMAT_YUV_RAW_8BIT_VYUY},
{QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8GBRG, CAM_FORMAT_BAYER_QCOM_RAW_8BPP_GBRG},
{QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8GRBG, CAM_FORMAT_BAYER_QCOM_RAW_8BPP_GRBG},
{QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8RGGB, CAM_FORMAT_BAYER_QCOM_RAW_8BPP_RGGB},
{QC_PIXEL_FORMAT_BAYER_QCOM_RAW_8BGGR, CAM_FORMAT_BAYER_QCOM_RAW_8BPP_BGGR},
{QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10GBRG, CAM_FORMAT_BAYER_QCOM_RAW_10BPP_GBRG},
{QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10GRBG, CAM_FORMAT_BAYER_QCOM_RAW_10BPP_GRBG},
{QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10RGGB, CAM_FORMAT_BAYER_QCOM_RAW_10BPP_RGGB},
{QC_PIXEL_FORMAT_BAYER_QCOM_RAW_10BGGR, CAM_FORMAT_BAYER_QCOM_RAW_10BPP_BGGR},
{QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12GBRG, CAM_FORMAT_BAYER_QCOM_RAW_12BPP_GBRG},
{QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12GRBG, CAM_FORMAT_BAYER_QCOM_RAW_12BPP_GRBG},
{QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12RGGB, CAM_FORMAT_BAYER_QCOM_RAW_12BPP_RGGB},
{QC_PIXEL_FORMAT_BAYER_QCOM_RAW_12BGGR, CAM_FORMAT_BAYER_QCOM_RAW_12BPP_BGGR},
{QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8GBRG, CAM_FORMAT_BAYER_MIPI_RAW_8BPP_GBRG},
{QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8GRBG, CAM_FORMAT_BAYER_MIPI_RAW_8BPP_GRBG},
{QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8RGGB, CAM_FORMAT_BAYER_MIPI_RAW_8BPP_RGGB},
{QC_PIXEL_FORMAT_BAYER_MIPI_RAW_8BGGR, CAM_FORMAT_BAYER_MIPI_RAW_8BPP_BGGR},
{QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10GBRG, CAM_FORMAT_BAYER_MIPI_RAW_10BPP_GBRG},
{QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10GRBG, CAM_FORMAT_BAYER_MIPI_RAW_10BPP_GRBG},
{QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10RGGB, CAM_FORMAT_BAYER_MIPI_RAW_10BPP_RGGB},
{QC_PIXEL_FORMAT_BAYER_MIPI_RAW_10BGGR, CAM_FORMAT_BAYER_MIPI_RAW_10BPP_BGGR},
{QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12GBRG, CAM_FORMAT_BAYER_MIPI_RAW_12BPP_GBRG},
{QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12GRBG, CAM_FORMAT_BAYER_MIPI_RAW_12BPP_GRBG},
{QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12RGGB, CAM_FORMAT_BAYER_MIPI_RAW_12BPP_RGGB},
{QC_PIXEL_FORMAT_BAYER_MIPI_RAW_12BGGR, CAM_FORMAT_BAYER_MIPI_RAW_12BPP_BGGR},
{QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_GBRG},
{QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_GRBG},
{QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_RGGB},
{QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_8BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_8BPP_BGGR},
{QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_GBRG},
{QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_GRBG},
{QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_RGGB},
{QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_10BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_10BPP_BGGR},
{QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_GBRG},
{QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_GRBG},
{QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_RGGB},
{QC_PIXEL_FORMAT_BAYER_IDEAL_QCOM_12BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_QCOM_12BPP_BGGR},
{QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_GBRG},
{QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_GRBG},
{QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_RGGB},
{QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_8BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_8BPP_BGGR},
{QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_GBRG},
{QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_GRBG},
{QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_RGGB},
{QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_10BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_10BPP_BGGR},
{QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_GBRG},
{QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_GRBG},
{QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_RGGB},
{QC_PIXEL_FORMAT_BAYER_IDEAL_MIPI_12BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_MIPI_12BPP_BGGR},
{QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_GBRG},
{QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_GRBG},
{QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_RGGB},
{QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN8_8BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN8_8BPP_BGGR},
{QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_GBRG},
{QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_GRBG},
{QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_RGGB},
{QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_8BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_BGGR},
{QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_GBRG},
{QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_GRBG},
{QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_RGGB},
{QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_10BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_10BPP_BGGR},
{QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12GBRG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_GBRG},
{QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12GRBG, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_GRBG},
{QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12RGGB, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_RGGB},
{QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_BGGR}
};
const QCameraParameters::QCameraMap QCameraParameters::RAW_FORMATS_MAP[] = {
};
const QCameraParameters::QCameraMap QCameraParameters::FOCUS_MODES_MAP[] = {
{ FOCUS_MODE_AUTO, CAM_FOCUS_MODE_AUTO },
{ FOCUS_MODE_INFINITY, CAM_FOCUS_MODE_INFINITY },
{ FOCUS_MODE_MACRO, CAM_FOCUS_MODE_MACRO },
{ FOCUS_MODE_FIXED, CAM_FOCUS_MODE_FIXED },
{ FOCUS_MODE_EDOF, CAM_FOCUS_MODE_EDOF },
{ FOCUS_MODE_CONTINUOUS_PICTURE, CAM_FOCUS_MODE_CONTINOUS_PICTURE },
{ FOCUS_MODE_CONTINUOUS_VIDEO, CAM_FOCUS_MODE_CONTINOUS_VIDEO }
};
const QCameraParameters::QCameraMap QCameraParameters::EFFECT_MODES_MAP[] = {
{ EFFECT_NONE, CAM_EFFECT_MODE_OFF },
{ EFFECT_MONO, CAM_EFFECT_MODE_MONO },
{ EFFECT_NEGATIVE, CAM_EFFECT_MODE_NEGATIVE },
{ EFFECT_SOLARIZE, CAM_EFFECT_MODE_SOLARIZE },
{ EFFECT_SEPIA, CAM_EFFECT_MODE_SEPIA },
{ EFFECT_POSTERIZE, CAM_EFFECT_MODE_POSTERIZE },
{ EFFECT_WHITEBOARD, CAM_EFFECT_MODE_WHITEBOARD },
{ EFFECT_BLACKBOARD, CAM_EFFECT_MODE_BLACKBOARD },
{ EFFECT_AQUA, CAM_EFFECT_MODE_AQUA },
{ EFFECT_EMBOSS, CAM_EFFECT_MODE_EMBOSS },
{ EFFECT_SKETCH, CAM_EFFECT_MODE_SKETCH },
{ EFFECT_NEON, CAM_EFFECT_MODE_NEON }
};
const QCameraParameters::QCameraMap QCameraParameters::SCENE_MODES_MAP[] = {
{ SCENE_MODE_AUTO, CAM_SCENE_MODE_OFF },
{ SCENE_MODE_ACTION, CAM_SCENE_MODE_ACTION },
{ SCENE_MODE_PORTRAIT, CAM_SCENE_MODE_PORTRAIT },
{ SCENE_MODE_LANDSCAPE, CAM_SCENE_MODE_LANDSCAPE },
{ SCENE_MODE_NIGHT, CAM_SCENE_MODE_NIGHT },
{ SCENE_MODE_NIGHT_PORTRAIT, CAM_SCENE_MODE_NIGHT_PORTRAIT },
{ SCENE_MODE_THEATRE, CAM_SCENE_MODE_THEATRE },
{ SCENE_MODE_BEACH, CAM_SCENE_MODE_BEACH },
{ SCENE_MODE_SNOW, CAM_SCENE_MODE_SNOW },
{ SCENE_MODE_SUNSET, CAM_SCENE_MODE_SUNSET },
{ SCENE_MODE_STEADYPHOTO, CAM_SCENE_MODE_ANTISHAKE },
{ SCENE_MODE_FIREWORKS , CAM_SCENE_MODE_FIREWORKS },
{ SCENE_MODE_SPORTS , CAM_SCENE_MODE_SPORTS },
{ SCENE_MODE_PARTY, CAM_SCENE_MODE_PARTY },
{ SCENE_MODE_CANDLELIGHT, CAM_SCENE_MODE_CANDLELIGHT },
{ SCENE_MODE_ASD, CAM_SCENE_MODE_AUTO },
{ SCENE_MODE_BACKLIGHT, CAM_SCENE_MODE_BACKLIGHT },
{ SCENE_MODE_FLOWERS, CAM_SCENE_MODE_FLOWERS },
{ SCENE_MODE_AR, CAM_SCENE_MODE_AR },
{ SCENE_MODE_HDR, CAM_SCENE_MODE_HDR },
};
const QCameraParameters::QCameraMap QCameraParameters::FLASH_MODES_MAP[] = {
{ FLASH_MODE_OFF, CAM_FLASH_MODE_OFF },
{ FLASH_MODE_AUTO, CAM_FLASH_MODE_AUTO },
{ FLASH_MODE_ON, CAM_FLASH_MODE_ON },
{ FLASH_MODE_TORCH, CAM_FLASH_MODE_TORCH }
};
const QCameraParameters::QCameraMap QCameraParameters::FOCUS_ALGO_MAP[] = {
{ FOCUS_ALGO_AUTO, CAM_FOCUS_ALGO_AUTO },
{ FOCUS_ALGO_SPOT_METERING, CAM_FOCUS_ALGO_SPOT },
{ FOCUS_ALGO_CENTER_WEIGHTED, CAM_FOCUS_ALGO_CENTER_WEIGHTED },
{ FOCUS_ALGO_FRAME_AVERAGE, CAM_FOCUS_ALGO_AVERAGE }
};
const QCameraParameters::QCameraMap QCameraParameters::WHITE_BALANCE_MODES_MAP[] = {
{ WHITE_BALANCE_AUTO, CAM_WB_MODE_AUTO },
{ WHITE_BALANCE_INCANDESCENT, CAM_WB_MODE_INCANDESCENT },
{ WHITE_BALANCE_FLUORESCENT, CAM_WB_MODE_FLUORESCENT },
{ WHITE_BALANCE_WARM_FLUORESCENT,CAM_WB_MODE_WARM_FLUORESCENT},
{ WHITE_BALANCE_DAYLIGHT, CAM_WB_MODE_DAYLIGHT },
{ WHITE_BALANCE_CLOUDY_DAYLIGHT, CAM_WB_MODE_CLOUDY_DAYLIGHT },
{ WHITE_BALANCE_TWILIGHT, CAM_WB_MODE_TWILIGHT },
{ WHITE_BALANCE_SHADE, CAM_WB_MODE_SHADE }
};
const QCameraParameters::QCameraMap QCameraParameters::ANTIBANDING_MODES_MAP[] = {
{ ANTIBANDING_OFF, CAM_ANTIBANDING_MODE_OFF },
{ ANTIBANDING_50HZ, CAM_ANTIBANDING_MODE_50HZ },
{ ANTIBANDING_60HZ, CAM_ANTIBANDING_MODE_60HZ },
{ ANTIBANDING_AUTO, CAM_ANTIBANDING_MODE_AUTO }
};
const QCameraParameters::QCameraMap QCameraParameters::ISO_MODES_MAP[] = {
{ ISO_AUTO, CAM_ISO_MODE_AUTO },
{ ISO_HJR, CAM_ISO_MODE_DEBLUR },
{ ISO_100, CAM_ISO_MODE_100 },
{ ISO_200, CAM_ISO_MODE_200 },
{ ISO_400, CAM_ISO_MODE_400 },
{ ISO_800, CAM_ISO_MODE_800 },
{ ISO_1600, CAM_ISO_MODE_1600 }
};
const QCameraParameters::QCameraMap QCameraParameters::HFR_MODES_MAP[] = {
{ VIDEO_HFR_OFF, CAM_HFR_MODE_OFF },
{ VIDEO_HFR_2X, CAM_HFR_MODE_60FPS },
{ VIDEO_HFR_3X, CAM_HFR_MODE_90FPS },
{ VIDEO_HFR_4X, CAM_HFR_MODE_120FPS },
{ VIDEO_HFR_5X, CAM_HFR_MODE_150FPS }
};
const QCameraParameters::QCameraMap QCameraParameters::BRACKETING_MODES_MAP[] = {
{ AE_BRACKET_OFF, CAM_EXP_BRACKETING_OFF },
{ AE_BRACKET, CAM_EXP_BRACKETING_ON }
};
const QCameraParameters::QCameraMap QCameraParameters::ON_OFF_MODES_MAP[] = {
{ VALUE_OFF, 0 },
{ VALUE_ON, 1 }
};
const QCameraParameters::QCameraMap QCameraParameters::TOUCH_AF_AEC_MODES_MAP[] = {
{ QCameraParameters::TOUCH_AF_AEC_OFF, 0 },
{ QCameraParameters::TOUCH_AF_AEC_ON, 1 }
};
const QCameraParameters::QCameraMap QCameraParameters::ENABLE_DISABLE_MODES_MAP[] = {
{ VALUE_ENABLE, 1 },
{ VALUE_DISABLE, 0 }
};
const QCameraParameters::QCameraMap QCameraParameters::DENOISE_ON_OFF_MODES_MAP[] = {
{ DENOISE_OFF, 0 },
{ DENOISE_ON, 1 }
};
const QCameraParameters::QCameraMap QCameraParameters::TRUE_FALSE_MODES_MAP[] = {
{ VALUE_FALSE, 0},
{ VALUE_TRUE, 1}
};
const QCameraParameters::QCameraMap QCameraParameters::FLIP_MODES_MAP[] = {
{FLIP_MODE_OFF, 0},
{FLIP_MODE_V, FLIP_V},
{FLIP_MODE_H, FLIP_H},
{FLIP_MODE_VH, FLIP_V_H}
};
const QCameraParameters::QCameraMap QCameraParameters::AF_BRACKETING_MODES_MAP[] = {
{ AF_BRACKET_OFF, 0 },
{ AF_BRACKET_ON, 1 }
};
const QCameraParameters::QCameraMap QCameraParameters::RE_FOCUS_MODES_MAP[] = {
{ RE_FOCUS_OFF, 0 },
{ RE_FOCUS_ON, 1 }
};
const QCameraParameters::QCameraMap QCameraParameters::CHROMA_FLASH_MODES_MAP[] = {
{ CHROMA_FLASH_OFF, 0 },
{ CHROMA_FLASH_ON, 1 }
};
const QCameraParameters::QCameraMap QCameraParameters::OPTI_ZOOM_MODES_MAP[] = {
{ OPTI_ZOOM_OFF, 0 },
{ OPTI_ZOOM_ON, 1 }
};
const QCameraParameters::QCameraMap QCameraParameters::CDS_MODES_MAP[] = {
{ CDS_MODE_OFF, CAM_CDS_MODE_OFF },
{ CDS_MODE_ON, CAM_CDS_MODE_ON },
{ CDS_MODE_AUTO, CAM_CDS_MODE_AUTO}
};
#define DEFAULT_CAMERA_AREA "(0, 0, 0, 0, 0)"
#define DATA_PTR(MEM_OBJ,INDEX) MEM_OBJ->getPtr( INDEX )
/*===========================================================================
* FUNCTION : QCameraParameters
*
* DESCRIPTION: default constructor of QCameraParameters
*
* PARAMETERS : none
*
* RETURN : None
*==========================================================================*/
QCameraParameters::QCameraParameters()
: CameraParameters(),
m_reprocScaleParam(this),
m_pCapability(NULL),
m_pCamOpsTbl(NULL),
m_pParamHeap(NULL),
m_pParamBuf(NULL),
m_bZslMode(false),
m_bZslMode_new(false),
m_bRecordingHint(false),
m_bRecordingHint_new(false),
m_bHistogramEnabled(false),
m_nFaceProcMask(0),
m_bFaceDetectionOn(0),
m_bDebugFps(false),
mFocusMode(CAM_FOCUS_MODE_MAX),
mPreviewFormat(CAM_FORMAT_YUV_420_NV21),
mPictureFormat(CAM_FORMAT_JPEG),
m_bNeedRestart(false),
m_bNoDisplayMode(false),
m_bWNROn(false),
m_bInited(false),
m_nBurstNum(1),
m_nRetroBurstNum(0),
m_nBurstLEDOnPeriod(100),
m_bUpdateEffects(false),
m_bSceneTransitionAuto(false),
m_bPreviewFlipChanged(false),
m_bVideoFlipChanged(false),
m_bSnapshotFlipChanged(false),
m_bFixedFrameRateSet(false),
m_bHDREnabled(false),
m_bAVTimerEnabled(false),
m_bDISEnabled(false),
m_AdjustFPS(NULL),
m_bHDR1xFrameEnabled(true),
m_HDRSceneEnabled(false),
m_bHDRThumbnailProcessNeeded(false),
m_bHDR1xExtraBufferNeeded(true),
m_bHDROutputCropEnabled(false),
m_tempMap(),
m_bAFBracketingOn(false),
m_bChromaFlashOn(false),
m_bOptiZoomOn(false),
m_bSceneSelection(false),
m_SelectedScene(CAM_SCENE_MODE_MAX),
m_bHfrMode(false),
m_bSensorHDREnabled(false),
m_bRdiMode(false),
m_bDisplayFrame(true),
m_bSecureMode(false),
m_bAeBracketingEnabled(false),
mFlashValue(CAM_FLASH_MODE_OFF),
mFlashDaemonValue(CAM_FLASH_MODE_OFF)
{
char value[PROPERTY_VALUE_MAX];
// TODO: may move to parameter instead of sysprop
property_get("persist.debug.sf.showfps", value, "0");
m_bDebugFps = atoi(value) > 0 ? true : false;
m_bReleaseTorchCamera = false;
m_pTorch = NULL;
// For thermal mode, it should be set as system property
// because system property applies to all applications, while
// parameters only apply to specific app.
property_get("persist.camera.thermal.mode", value, "fps");
if (!strcmp(value, "frameskip")) {
m_ThermalMode = QCAMERA_THERMAL_ADJUST_FRAMESKIP;
} else {
if (strcmp(value, "fps"))
ALOGE("%s: Invalid camera thermal mode %s", __func__, value);
m_ThermalMode = QCAMERA_THERMAL_ADJUST_FPS;
}
memset(&m_LiveSnapshotSize, 0, sizeof(m_LiveSnapshotSize));
memset(&m_default_fps_range, 0, sizeof(m_default_fps_range));
memset(&m_hfrFpsRange, 0, sizeof(m_hfrFpsRange));
}
/*===========================================================================
* FUNCTION : QCameraParameters
*
* DESCRIPTION: constructor of QCameraParameters
*
* PARAMETERS :
* @params : parameters in string
*
* RETURN : None
*==========================================================================*/
QCameraParameters::QCameraParameters(const String8 &params)
: CameraParameters(params),
m_reprocScaleParam(this),
m_pCapability(NULL),
m_pCamOpsTbl(NULL),
m_pParamHeap(NULL),
m_pParamBuf(NULL),
m_bZslMode(false),
m_bZslMode_new(false),
m_bRecordingHint(false),
m_bRecordingHint_new(false),
m_bHistogramEnabled(false),
m_nFaceProcMask(0),
m_bDebugFps(false),
mFocusMode(CAM_FOCUS_MODE_MAX),
mPreviewFormat(CAM_FORMAT_YUV_420_NV21),
mPictureFormat(CAM_FORMAT_JPEG),
m_bNeedRestart(false),
m_bNoDisplayMode(false),
m_bWNROn(false),
m_bInited(false),
m_nBurstNum(1),
m_nRetroBurstNum(0),
m_nBurstLEDOnPeriod(100),
m_bPreviewFlipChanged(false),
m_bVideoFlipChanged(false),
m_bSnapshotFlipChanged(false),
m_bFixedFrameRateSet(false),
m_bHDREnabled(false),
m_bAVTimerEnabled(false),
m_AdjustFPS(NULL),
m_bHDR1xFrameEnabled(true),
m_HDRSceneEnabled(false),
m_bHDRThumbnailProcessNeeded(false),
m_bHDR1xExtraBufferNeeded(true),
m_bHDROutputCropEnabled(false),
m_tempMap(),
m_bAFBracketingOn(false),
m_bChromaFlashOn(false),
m_bOptiZoomOn(false),
m_bSceneSelection(false),
m_SelectedScene(CAM_SCENE_MODE_MAX),
m_bHfrMode(false),
m_bSensorHDREnabled(false),
m_bRdiMode(false),
m_bSecureMode(false),
m_bAeBracketingEnabled(false),
mFlashValue(CAM_FLASH_MODE_OFF),
mFlashDaemonValue(CAM_FLASH_MODE_OFF)
{
memset(&m_LiveSnapshotSize, 0, sizeof(m_LiveSnapshotSize));
memset(&m_default_fps_range, 0, sizeof(m_default_fps_range));
memset(&m_hfrFpsRange, 0, sizeof(m_hfrFpsRange));
m_pTorch = NULL;
m_bReleaseTorchCamera = false;
}
/*===========================================================================
* FUNCTION : ~QCameraParameters
*
* DESCRIPTION: deconstructor of QCameraParameters
*
* PARAMETERS : none
*
* RETURN : None
*==========================================================================*/
QCameraParameters::~QCameraParameters()
{
deinit();
}
/*===========================================================================
* FUNCTION : createSizesString
*
* DESCRIPTION: create string obj contains array of dimensions
*
* PARAMETERS :
* @sizes : array of dimensions
* @len : size of dimension array
*
* RETURN : string obj
*==========================================================================*/
String8 QCameraParameters::createSizesString(const cam_dimension_t *sizes, int len)
{
String8 str;
char buffer[32];
if (len > 0) {
snprintf(buffer, sizeof(buffer), "%dx%d", sizes[0].width, sizes[0].height);
str.append(buffer);
}
for (int i = 1; i < len; i++) {
snprintf(buffer, sizeof(buffer), ",%dx%d", sizes[i].width, sizes[i].height);
str.append(buffer);
}
return str;
}
/*===========================================================================
* FUNCTION : createValuesString
*
* DESCRIPTION: create string obj contains array of values from map when matched
* from input values array
*
* PARAMETERS :
* @values : array of values
* @len : size of values array
* @map : map contains the mapping between values and enums
* @map_len : size of the map
*
* RETURN : string obj
*==========================================================================*/
String8 QCameraParameters::createValuesString(const int *values,
int len,
const QCameraMap* map,
int map_len)
{
String8 str;
int count = 0;
for (int i = 0; i < len; i++ ) {
for (int j = 0; j < map_len; j ++)
if (map[j].val == values[i]) {
if (NULL != map[j].desc) {
if (count > 0) {
str.append(",");
}
str.append(map[j].desc);
count++;
break; //loop j
}
}
}
return str;
}
/*===========================================================================
* FUNCTION : createValuesStringFromMap
*
* DESCRIPTION: create string obj contains array of values directly from map
*
* PARAMETERS :
* @map : map contains the mapping between values and enums
* @map_len : size of the map
*
* RETURN : string obj
*==========================================================================*/
String8 QCameraParameters::createValuesStringFromMap(const QCameraMap* map,
int map_len)
{
String8 str;
for (int i = 0; i < map_len; i++) {
if (NULL != map[i].desc) {
if (i > 0) {
str.append(",");
}
str.append(map[i].desc);
}
}
return str;
}
/*===========================================================================
* FUNCTION : createZoomRatioValuesString
*
* DESCRIPTION: create string obj contains array of zoom ratio values
*
* PARAMETERS :
* @zoomRaios : array of zoom ratios
* @length : size of the array
*
* RETURN : string obj
*==========================================================================*/
String8 QCameraParameters::createZoomRatioValuesString(int *zoomRatios, int length)
{
String8 str;
char buffer[32] = {0};
if(length > 0){
snprintf(buffer, sizeof(buffer), "%d", zoomRatios[0]);
str.append(buffer);
}
for (int i =1;i<length;i++){
memset(buffer, 0, sizeof(buffer));
snprintf(buffer, sizeof(buffer), ",%d", zoomRatios[i]);
str.append(buffer);
}
return str;
}
/*===========================================================================
* FUNCTION : createHfrValuesString
*
* DESCRIPTION: create string obj contains array of hfr values from map when
* matched from input hfr values
*
* PARAMETERS :
* @values : array of hfr info
* @len : size of the array
* @map : map of hfr string value and enum
* map_len : size of map
*
* RETURN : string obj
*==========================================================================*/
String8 QCameraParameters::createHfrValuesString(
const cam_hfr_info_t *values,
int len,
const QCameraMap* map,
int map_len)
{
String8 str;
int count = 0;
for (int i = 0; i < len; i++ ) {
for (int j = 0; j < map_len; j ++)
if (map[j].val == (int)values[i].mode) {
if (NULL != map[j].desc) {
if (count > 0) {
str.append(",");
}
str.append(map[j].desc);
count++;
break; //loop j
}
}
}
if (count > 0) {
str.append(",");
}
str.append(VIDEO_HFR_OFF);
return str;
}
/*===========================================================================
* FUNCTION : createHfrSizesString
*
* DESCRIPTION: create string obj contains array of hfr sizes
*
* PARAMETERS :
* @values : array of hfr info
* @len : size of the array
*
* RETURN : string obj
*==========================================================================*/
String8 QCameraParameters::createHfrSizesString(
const cam_hfr_info_t *values,
int len)
{
String8 str;
char buffer[32];
if (len > 0) {
snprintf(buffer, sizeof(buffer), "%dx%d",
values[0].dim.width, values[0].dim.height);
str.append(buffer);
}
for (int i = 1; i < len; i++) {
snprintf(buffer, sizeof(buffer), ",%dx%d",
values[i].dim.width, values[i].dim.height);
str.append(buffer);
}
return str;
}
/*===========================================================================
* FUNCTION : createFpsString
*
* DESCRIPTION: create string obj contains array of FPS rates
*
* PARAMETERS :
* @fps : default fps range
*
* RETURN : string obj
*==========================================================================*/
String8 QCameraParameters::createFpsString(cam_fps_range_t &fps)
{
char buffer[32];
String8 fpsValues;
int min_fps = int(fps.min_fps);
int max_fps = int(fps.max_fps);
if (min_fps < fps.min_fps){
min_fps++;
}
if (max_fps > fps.max_fps) {
max_fps--;
}
if (min_fps <= max_fps) {
snprintf(buffer, sizeof(buffer), "%d", min_fps);
fpsValues.append(buffer);
}
for (int i = min_fps+1; i <= max_fps; i++) {
snprintf(buffer, sizeof(buffer), ",%d", i);
fpsValues.append(buffer);
}
return fpsValues;
}
/*===========================================================================
* FUNCTION : createFpsRangeString
*
* DESCRIPTION: create string obj contains array of FPS ranges
*
* PARAMETERS :
* @fps : array of fps ranges
* @len : size of the array
* @default_fps_index : reference to index of default fps range
*
* RETURN : string obj
*==========================================================================*/
String8 QCameraParameters::createFpsRangeString(const cam_fps_range_t* fps,
int len,
int &default_fps_index)
{
String8 str;
char buffer[32];
int max_range = 0;
int min_fps, max_fps;
if (len > 0) {
min_fps = int(fps[0].min_fps * 1000);
max_fps = int(fps[0].max_fps * 1000);
max_range = max_fps - min_fps;
default_fps_index = 0;
snprintf(buffer, sizeof(buffer), "(%d,%d)", min_fps, max_fps);
str.append(buffer);
}
for (int i = 1; i < len; i++) {
min_fps = int(fps[i].min_fps * 1000);
max_fps = int(fps[i].max_fps * 1000);
if (max_range < (max_fps - min_fps)) {
max_range = max_fps - min_fps;
default_fps_index = i;
}
snprintf(buffer, sizeof(buffer), ",(%d,%d)", min_fps, max_fps);
str.append(buffer);
}
return str;
}
/*===========================================================================
* FUNCTION : lookupAttr
*
* DESCRIPTION: lookup a value by its name
*
* PARAMETERS :
* @attr : map contains <name, value>
* @len : size of the map
* @name : name to be looked up
*
* RETURN : valid value if found
* NAME_NOT_FOUND if not found
*==========================================================================*/
int QCameraParameters::lookupAttr(const QCameraMap arr[], int len, const char *name)
{
if (name) {
for (int i = 0; i < len; i++) {
if (!strcmp(arr[i].desc, name))
return arr[i].val;
}
}
return NAME_NOT_FOUND;
}
/*===========================================================================
* FUNCTION : lookupNameByValue
*
* DESCRIPTION: lookup a name by its value
*
* PARAMETERS :
* @attr : map contains <name, value>
* @len : size of the map
* @value : value to be looked up
*
* RETURN : name str or NULL if not found
*==========================================================================*/
const char *QCameraParameters::lookupNameByValue(const QCameraMap arr[], int len, int value)
{
for (int i = 0; i < len; i++) {
if (arr[i].val == value) {
return arr[i].desc;
}
}
return NULL;
}
/*===========================================================================
* FUNCTION : setPreviewSize
*
* DESCRIPTION: set preview size from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setPreviewSize(const QCameraParameters& params)
{
int width, height;
params.getPreviewSize(&width, &height);
CDBG("Requested preview size %d x %d", width, height);
// Validate the preview size
for (size_t i = 0; i < m_pCapability->preview_sizes_tbl_cnt; ++i) {
if (width == m_pCapability->preview_sizes_tbl[i].width
&& height == m_pCapability->preview_sizes_tbl[i].height) {
// check if need to restart preview in case of preview size change
int old_width, old_height;
CameraParameters::getPreviewSize(&old_width, &old_height);
if (width != old_width || height != old_height) {
m_bNeedRestart = true;
}
// set the new value
CameraParameters::setPreviewSize(width, height);
return NO_ERROR;
}
}
ALOGE("Invalid preview size requested: %dx%d", width, height);
return BAD_VALUE;
}
/*===========================================================================
* FUNCTION : setPictureSize
*
* DESCRIPTION: set picture size from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setPictureSize(const QCameraParameters& params)
{
int width, height;
params.getPictureSize(&width, &height);
CDBG("Requested picture size %d x %d", width, height);
// Validate the picture size
if(!m_reprocScaleParam.isScaleEnabled()){
for (size_t i = 0; i < m_pCapability->picture_sizes_tbl_cnt; ++i) {
if (width == m_pCapability->picture_sizes_tbl[i].width
&& height == m_pCapability->picture_sizes_tbl[i].height) {
// check if need to restart preview in case of picture size change
int old_width, old_height;
CameraParameters::getPictureSize(&old_width, &old_height);
if ((m_bZslMode || m_bRecordingHint) &&
(width != old_width || height != old_height)) {
m_bNeedRestart = true;
}
// set the new value
CameraParameters::setPictureSize(width, height);
return NO_ERROR;
}
}
}else{
//should use scaled picture size table to validate
if(m_reprocScaleParam.setValidatePicSize(width, height) == NO_ERROR){
// check if need to restart preview in case of picture size change
int old_width, old_height;
CameraParameters::getPictureSize(&old_width, &old_height);
if ((m_bZslMode || m_bRecordingHint) &&
(width != old_width || height != old_height)) {
m_bNeedRestart = true;
}
// set the new value
char val[32];
sprintf(val, "%dx%d", width, height);
updateParamEntry(KEY_PICTURE_SIZE, val);
CDBG("%s: %s", __func__, val);
return NO_ERROR;
}
}
ALOGE("Invalid picture size requested: %dx%d", width, height);
return BAD_VALUE;
}
/*===========================================================================
* FUNCTION : setVideoSize
*
* DESCRIPTION: set video size from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setVideoSize(const QCameraParameters& params)
{
const char *str= NULL;
int width, height;
str = params.get(KEY_VIDEO_SIZE);
if(!str) {
//If application didn't set this parameter string, use the values from
//getPreviewSize() as video dimensions.
params.getPreviewSize(&width, &height);
ALOGE("No Record Size requested, use the preview dimensions");
} else {
params.getVideoSize(&width, &height);
}
// Validate the video size
for (size_t i = 0; i < m_pCapability->video_sizes_tbl_cnt; ++i) {
if (width == m_pCapability->video_sizes_tbl[i].width
&& height == m_pCapability->video_sizes_tbl[i].height) {
// check if need to restart preview in case of video size change
int old_width, old_height;
CameraParameters::getVideoSize(&old_width, &old_height);
if (m_bRecordingHint &&
(width != old_width || height != old_height)) {
m_bNeedRestart = true;
}
// set the new value
CameraParameters::setVideoSize(width, height);
return NO_ERROR;
}
}
ALOGE("Invalid video size requested: %dx%d", width, height);
return BAD_VALUE;
}
/*===========================================================================
* FUNCTION : setLiveSnapshotSize
*
* DESCRIPTION: set live snapshot size
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setLiveSnapshotSize(const QCameraParameters& params)
{
char value[PROPERTY_VALUE_MAX];
property_get("persist.camera.opt.livepic", value, "1");
bool useOptimal = atoi(value) > 0 ? true : false;
// use picture size from user setting
params.getPictureSize(&m_LiveSnapshotSize.width, &m_LiveSnapshotSize.height);
uint8_t livesnapshot_sizes_tbl_cnt = m_pCapability->livesnapshot_sizes_tbl_cnt;
cam_dimension_t *livesnapshot_sizes_tbl = &m_pCapability->livesnapshot_sizes_tbl[0];
// check if HFR is enabled
const char *hfrStr = params.get(KEY_QC_VIDEO_HIGH_FRAME_RATE);
cam_hfr_mode_t hfrMode = CAM_HFR_MODE_OFF;
const char *hsrStr = params.get(KEY_QC_VIDEO_HIGH_SPEED_RECORDING);
if (hsrStr != NULL && !strcmp(hsrStr, "on")) {
for (int i = 0; i < m_pCapability->hfr_tbl_cnt; i++) {
if (m_pCapability->hfr_tbl[i].mode == CAM_HFR_MODE_120FPS) {
livesnapshot_sizes_tbl_cnt =
m_pCapability->hfr_tbl[i].livesnapshot_sizes_tbl_cnt;
livesnapshot_sizes_tbl =
&m_pCapability->hfr_tbl[i].livesnapshot_sizes_tbl[0];
hfrMode = m_pCapability->hfr_tbl[i].mode;
break;
}
}
}
else if (hfrStr != NULL) {
int32_t value = lookupAttr(HFR_MODES_MAP,
sizeof(HFR_MODES_MAP)/sizeof(QCameraMap),
hfrStr);
if (value != NAME_NOT_FOUND) {
// if HFR is enabled, change live snapshot size
if (value > CAM_HFR_MODE_OFF) {
for (int i = 0; i < m_pCapability->hfr_tbl_cnt; i++) {
if (m_pCapability->hfr_tbl[i].mode == value) {
livesnapshot_sizes_tbl_cnt =
m_pCapability->hfr_tbl[i].livesnapshot_sizes_tbl_cnt;
livesnapshot_sizes_tbl =
&m_pCapability->hfr_tbl[i].livesnapshot_sizes_tbl[0];
hfrMode = m_pCapability->hfr_tbl[i].mode;
break;
}
}
}
}
}
if (useOptimal || hfrMode != CAM_HFR_MODE_OFF) {
bool found = false;
// first check if picture size is within the list of supported sizes
for (int i = 0; i < livesnapshot_sizes_tbl_cnt; ++i) {
if (m_LiveSnapshotSize.width == livesnapshot_sizes_tbl[i].width &&
m_LiveSnapshotSize.height == livesnapshot_sizes_tbl[i].height) {
found = true;
break;
}
}
if (!found) {
// use optimal live snapshot size from supported list,
// that has same preview aspect ratio
int width = 0, height = 0;
params.getPreviewSize(&width, &height);
double previewAspectRatio = (double)width / height;
for (int i = 0; i < livesnapshot_sizes_tbl_cnt; ++i) {
double ratio = (double)livesnapshot_sizes_tbl[i].width /
livesnapshot_sizes_tbl[i].height;
if (fabs(previewAspectRatio - ratio) <= ASPECT_TOLERANCE) {
m_LiveSnapshotSize = livesnapshot_sizes_tbl[i];
found = true;
break;
}
}
if (!found && hfrMode != CAM_HFR_MODE_OFF) {
// Cannot find matching aspect ration from supported live snapshot list
// choose the max dim from preview and video size
CDBG("%s: Cannot find matching aspect ratio, choose max of preview or video size", __func__);
params.getVideoSize(&m_LiveSnapshotSize.width, &m_LiveSnapshotSize.height);
if (m_LiveSnapshotSize.width < width && m_LiveSnapshotSize.height < height) {
m_LiveSnapshotSize.width = width;
m_LiveSnapshotSize.height = height;
}
}
}
}
CDBG("%s: live snapshot size %d x %d", __func__,
m_LiveSnapshotSize.width, m_LiveSnapshotSize.height);
return NO_ERROR;
}
/*===========================================================================
* FUNCTION : setRawSize
*
* DESCRIPTION: set live snapshot size
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setRawSize(cam_dimension_t &dim)
{
m_rawSize = dim;
return NO_ERROR;
}
/*===========================================================================
* FUNCTION : setPreviewFormat
*
* DESCRIPTION: set preview format from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setPreviewFormat(const QCameraParameters& params)
{
const char *str = params.getPreviewFormat();
int32_t previewFormat =
lookupAttr(PREVIEW_FORMATS_MAP,
sizeof(PREVIEW_FORMATS_MAP) / sizeof(QCameraMap),
str);
if (previewFormat != NAME_NOT_FOUND) {
mPreviewFormat = (cam_format_t)previewFormat;
CameraParameters::setPreviewFormat(str);
CDBG_HIGH("%s: format %d\n", __func__, mPreviewFormat);
return NO_ERROR;
}
ALOGE("Invalid preview format value: %s", (str == NULL) ? "NULL" : str);
return BAD_VALUE;
}
/*===========================================================================
* FUNCTION : setPictureFormat
*
* DESCRIPTION: set picture format from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setPictureFormat(const QCameraParameters& params)
{
const char *str = params.getPictureFormat();
int32_t pictureFormat =
lookupAttr(PICTURE_TYPES_MAP,
sizeof(PICTURE_TYPES_MAP) / sizeof(QCameraMap),
str);
if (pictureFormat != NAME_NOT_FOUND) {
mPictureFormat = pictureFormat;
CameraParameters::setPictureFormat(str);
CDBG_HIGH("%s: format %d\n", __func__, mPictureFormat);
return NO_ERROR;
}
ALOGE("%s: Invalid picture format value: %s", __func__, (str == NULL) ? "NULL" : str);
return BAD_VALUE;
}
/*===========================================================================
* FUNCTION : setJpegThumbnailSize
*
* DESCRIPTION: set jpeg thumbnail size from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setJpegThumbnailSize(const QCameraParameters& params)
{
int width = params.getInt(KEY_JPEG_THUMBNAIL_WIDTH);
int height = params.getInt(KEY_JPEG_THUMBNAIL_HEIGHT);
CDBG("requested jpeg thumbnail size %d x %d", width, height);
int sizes_cnt = sizeof(THUMBNAIL_SIZES_MAP) / sizeof(cam_dimension_t);
cam_dimension_t dim;
// While taking livesnaphot match jpeg thumbnail size aspect
// ratio to liveshot size. For normal snapshot match thumbnail
// aspect ratio to picture size.
if (m_bRecordingHint) {
getLiveSnapshotSize(dim);
} else {
params.getPictureSize(&dim.width, &dim.height);
}
if (0 == dim.height) {
ALOGE("%s: picture size is invalid (%d x %d)", __func__, dim.width, dim.height);
return BAD_VALUE;
}
double picAspectRatio = (double)dim.width / (double)dim.height;
int optimalWidth = 0, optimalHeight = 0;
if (width != 0 || height != 0) {
// If input jpeg thumnmail size is (0,0), meaning no thumbnail needed
// hornor this setting.
// Otherwise, search for optimal jpeg thumbnail size that has the same
// aspect ratio as picture size.
// If missign jpeg thumbnail size with appropriate aspect ratio,
// just honor setting supplied by application.
// Try to find a size matches aspect ratio and has the largest width
for (int i = 0; i < sizes_cnt; i++) {
if (THUMBNAIL_SIZES_MAP[i].height == 0) {
// No thumbnail case, just skip
continue;
}
double ratio =
(double)THUMBNAIL_SIZES_MAP[i].width / THUMBNAIL_SIZES_MAP[i].height;
if (fabs(ratio - picAspectRatio) > ASPECT_TOLERANCE) {
continue;
}
if (THUMBNAIL_SIZES_MAP[i].width > optimalWidth) {
optimalWidth = THUMBNAIL_SIZES_MAP[i].width;
optimalHeight = THUMBNAIL_SIZES_MAP[i].height;
}
}
if ((0 == optimalWidth) || (0 == optimalHeight)) {
// Optimal size not found
// Validate thumbnail size
for (int i = 0; i < sizes_cnt; i++) {
if (width == THUMBNAIL_SIZES_MAP[i].width &&
height == THUMBNAIL_SIZES_MAP[i].height) {
optimalWidth = width;
optimalHeight = height;
break;
}
}
}
}
set(KEY_JPEG_THUMBNAIL_WIDTH, optimalWidth);
set(KEY_JPEG_THUMBNAIL_HEIGHT, optimalHeight);
return NO_ERROR;
}
/*===========================================================================
* FUNCTION : setBurstLEDOnPeriod
*
* DESCRIPTION: set burst LED on period
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setBurstLEDOnPeriod(const QCameraParameters& params)
{
uint32_t nBurstLEDOnPeriod =
params.getInt(KEY_QC_SNAPSHOT_BURST_LED_ON_PERIOD);
//Check if the LED ON period is within limits
if ((nBurstLEDOnPeriod <= 0) || (nBurstLEDOnPeriod > 800)) {
// if burst led on period is not set in parameters,
// read from sys prop
char prop[PROPERTY_VALUE_MAX];
memset(prop, 0, sizeof(prop));
property_get("persist.camera.led.on.period", prop, "0");
nBurstLEDOnPeriod = atoi(prop);
if (nBurstLEDOnPeriod <= 0) {
nBurstLEDOnPeriod = 100;
}
}
set(KEY_QC_SNAPSHOT_BURST_LED_ON_PERIOD, nBurstLEDOnPeriod);
m_nBurstLEDOnPeriod = nBurstLEDOnPeriod;
CDBG_HIGH("%s: Burst LED on period %d", __func__, nBurstLEDOnPeriod);
return AddSetParmEntryToBatch(m_pParamBuf,
CAM_INTF_PARM_BURST_LED_ON_PERIOD,
sizeof(nBurstLEDOnPeriod),
&nBurstLEDOnPeriod);
}
/*===========================================================================
* FUNCTION : setRetroActiveBurstNum
*
* DESCRIPTION: set retro active burst num
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setRetroActiveBurstNum(
const QCameraParameters& params)
{
int32_t nBurstNum = params.getInt(KEY_QC_NUM_RETRO_BURST_PER_SHUTTER);
CDBG_HIGH("%s:[ZSL Retro] m_nRetroBurstNum = %d", __func__, m_nRetroBurstNum);
if (nBurstNum <= 0) {
// if burst number is not set in parameters,
// read from sys prop
char prop[PROPERTY_VALUE_MAX];
memset(prop, 0, sizeof(prop));
property_get("persist.camera.retro.number", prop, "0");
nBurstNum = atoi(prop);
if (nBurstNum < 0) {
nBurstNum = 0;
}
}
set(KEY_QC_NUM_RETRO_BURST_PER_SHUTTER, nBurstNum);
m_nRetroBurstNum = nBurstNum;
CDBG_HIGH("%s: [ZSL Retro] m_nRetroBurstNum = %d", __func__, m_nRetroBurstNum);
return NO_ERROR;
}
/*===========================================================================
* FUNCTION : setJpegQuality
*
* DESCRIPTION: set jpeg encpding quality from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setJpegQuality(const QCameraParameters& params)
{
int32_t rc = NO_ERROR;
int quality = params.getInt(KEY_JPEG_QUALITY);
if (quality >= 0 && quality <= 100) {
set(KEY_JPEG_QUALITY, quality);
} else {
ALOGE("%s: Invalid jpeg quality=%d", __func__, quality);
rc = BAD_VALUE;
}
quality = params.getInt(KEY_JPEG_THUMBNAIL_QUALITY);
if (quality >= 0 && quality <= 100) {
set(KEY_JPEG_THUMBNAIL_QUALITY, quality);
} else {
ALOGE("%s: Invalid jpeg thumbnail quality=%d", __func__, quality);
rc = BAD_VALUE;
}
return rc;
}
/*===========================================================================
* FUNCTION : setOrientaion
*
* DESCRIPTION: set orientaion from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setOrientation(const QCameraParameters& params)
{
const char *str = params.get(KEY_QC_ORIENTATION);
if (str != NULL) {
if (strcmp(str, portrait) == 0 || strcmp(str, landscape) == 0) {
// Camera service needs this to decide if the preview frames and raw
// pictures should be rotated.
set(KEY_QC_ORIENTATION, str);
} else {
ALOGE("%s: Invalid orientation value: %s", __func__, str);
return BAD_VALUE;
}
}
return NO_ERROR;
}
/*===========================================================================
* FUNCTION : setAutoExposure
*
* DESCRIPTION: set auto exposure value from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setAutoExposure(const QCameraParameters& params)
{
const char *str = params.get(KEY_QC_AUTO_EXPOSURE);
const char *prev_str = get(KEY_QC_AUTO_EXPOSURE);
if (str != NULL) {
if (prev_str == NULL ||
strcmp(str, prev_str) != 0) {
return setAutoExposure(str);
}
}
return NO_ERROR;
}
/*===========================================================================
* FUNCTION : setPreviewFpsRange
*
* DESCRIPTION: set preview FPS range from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setPreviewFpsRange(const QCameraParameters& params)
{
int minFps,maxFps;
int prevMinFps, prevMaxFps, vidMinFps, vidMaxFps;
int rc = NO_ERROR;
bool found = false, updateNeeded = false;
CameraParameters::getPreviewFpsRange(&prevMinFps, &prevMaxFps);
params.getPreviewFpsRange(&minFps, &maxFps);
CDBG_HIGH("%s: FpsRange Values:(%d, %d)", __func__, prevMinFps, prevMaxFps);
CDBG_HIGH("%s: Requested FpsRange Values:(%d, %d)", __func__, minFps, maxFps);
//first check if we need to change fps because of HFR mode change
updateNeeded = UpdateHFRFrameRate(params);
CDBG_HIGH("%s: UpdateHFRFrameRate %d", __func__, updateNeeded);
vidMinFps = m_hfrFpsRange.video_min_fps;
vidMaxFps = m_hfrFpsRange.video_max_fps;
if(minFps == prevMinFps && maxFps == prevMaxFps) {
if ( m_bFixedFrameRateSet ) {
minFps = params.getPreviewFrameRate() * 1000;
maxFps = params.getPreviewFrameRate() * 1000;
m_bFixedFrameRateSet = false;
} else if (!updateNeeded) {
CDBG_HIGH("%s: No change in FpsRange", __func__);
rc = NO_ERROR;
goto end;
}
}
for(int i = 0; i < m_pCapability->fps_ranges_tbl_cnt; i++) {
// if the value is in the supported list
if(minFps >= m_pCapability->fps_ranges_tbl[i].min_fps * 1000 &&
maxFps <= m_pCapability->fps_ranges_tbl[i].max_fps * 1000) {
found = true;
CDBG_HIGH("%s: FPS i=%d : minFps = %d, maxFps = %d"
" vidMinFps = %d, vidMaxFps = %d",
__func__, i, minFps, maxFps,
(int)m_hfrFpsRange.video_min_fps,
(int)m_hfrFpsRange.video_max_fps);
if ((m_hfrFpsRange.video_min_fps == 0) ||
(m_hfrFpsRange.video_max_fps == 0)) {
vidMinFps = minFps;
vidMaxFps = maxFps;
}
else {
vidMinFps = m_hfrFpsRange.video_min_fps;
vidMaxFps = m_hfrFpsRange.video_max_fps;
}
setPreviewFpsRange(minFps, maxFps, vidMinFps, vidMaxFps);
break;
}
}
if(found == false){
ALOGE("%s: error: FPS range value not supported", __func__);
rc = BAD_VALUE;
}
end:
return rc;
}
/*===========================================================================
* FUNCTION : UpdateHFRFrameRate
*
* DESCRIPTION: set preview FPS range based on HFR setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : bool true/false
* true -if HAL needs to overwrite FPS range set by app, false otherwise.
*==========================================================================*/
bool QCameraParameters::UpdateHFRFrameRate(const QCameraParameters& params)
{
bool updateNeeded = false;
int min_fps, max_fps;
int32_t hfrMode = CAM_HFR_MODE_OFF;
int parm_minfps,parm_maxfps;
int prevMinFps, prevMaxFps;
CameraParameters::getPreviewFpsRange(&prevMinFps, &prevMaxFps);
params.getPreviewFpsRange(&parm_minfps, &parm_maxfps);
CDBG_HIGH("%s: CameraParameters - : minFps = %d, maxFps = %d ",
__func__, prevMinFps, prevMaxFps);
CDBG_HIGH("%s: Requested params - : minFps = %d, maxFps = %d ",
__func__, parm_minfps, parm_maxfps);
// check if HFR is enabled
const char *hfrStr = params.get(KEY_QC_VIDEO_HIGH_FRAME_RATE);
const char *prev_hfrStr = get(KEY_QC_VIDEO_HIGH_FRAME_RATE);
CDBG_HIGH("%s: prevHfrStr - %s, hfrStr = %s ",
__func__, prev_hfrStr, hfrStr);
if(hfrStr != NULL){
hfrMode = lookupAttr(HFR_MODES_MAP,
sizeof(HFR_MODES_MAP)/sizeof(QCameraMap),
hfrStr);
}
// check if HSR is enabled
const char *hsrStr = params.get(KEY_QC_VIDEO_HIGH_SPEED_RECORDING);
const char *prev_hsrStr = get(KEY_QC_VIDEO_HIGH_SPEED_RECORDING);
if (hsrStr != NULL && !strcmp(hsrStr, "on")) {
CDBG_HIGH("%s: HSR mode enabled ", __func__);
hfrMode = CAM_HFR_MODE_120FPS;
}
// if HSR is made ON just now
if(hsrStr != NULL && (prev_hsrStr == NULL || (strcmp(hsrStr, prev_hsrStr))) &&
!strcmp(hsrStr, "on")) {
min_fps = 120000;
max_fps = 120000;
m_hfrFpsRange.video_min_fps = min_fps;
m_hfrFpsRange.video_max_fps = max_fps;
CDBG_HIGH("%s: HFR mode change - Set FPS : minFps = %d, maxFps = %d ",
__func__,min_fps,max_fps);
updateNeeded = true;
}
// else if HSR is made OFF just now or HSR is OFF for some time
// and HFR is changed just now
else if (hfrStr != NULL && ((prev_hfrStr == NULL || strcmp(hfrStr,prev_hfrStr)) ||
(hsrStr != NULL && (prev_hsrStr == NULL || strcmp(hsrStr, prev_hsrStr)))) &&
((hsrStr != NULL && strcmp(hsrStr, "on"))|| hsrStr == NULL)) {
if (hfrMode != NAME_NOT_FOUND) {
// if HFR is enabled, change fps range
switch(hfrMode){
case CAM_HFR_MODE_60FPS:
min_fps = 60000;
max_fps = 60000;
break;
case CAM_HFR_MODE_90FPS:
min_fps = 90000;
max_fps = 90000;
break;
case CAM_HFR_MODE_120FPS:
min_fps = 120000;
max_fps = 120000;
break;
case CAM_HFR_MODE_150FPS:
min_fps = 150000;
max_fps = 150000;
break;
case CAM_HFR_MODE_OFF:
default:
// Set Video Fps to zero
min_fps = 0;
max_fps = 0;
break;
}
m_hfrFpsRange.video_min_fps = min_fps;
m_hfrFpsRange.video_max_fps = max_fps;
CDBG_HIGH("%s: HFR mode (%d) Set video FPS : minFps = %d, maxFps = %d ",
__func__, hfrMode, min_fps, max_fps);
// Signifies that there is a change in video FPS and need to set Fps
updateNeeded = true;
}
}
// Remember if HFR mode is ON
if ((hfrMode > CAM_HFR_MODE_OFF) && (hfrMode < CAM_HFR_MODE_MAX)){
CDBG_HIGH("HFR mode is ON");
m_bHfrMode = true;
}
else {
m_hfrFpsRange.video_min_fps = 0;
m_hfrFpsRange.video_max_fps = 0;
m_bHfrMode = false;
CDBG_HIGH("HFR mode is OFF");
}
return updateNeeded;
}
/*===========================================================================
* FUNCTION : setPreviewFrameRate
*
* DESCRIPTION: set preview frame rate from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setPreviewFrameRate(const QCameraParameters& params)
{
const char *str = params.get(KEY_PREVIEW_FRAME_RATE);
const char *prev_str = get(KEY_PREVIEW_FRAME_RATE);
if ( str ) {
if ( prev_str &&
strcmp(str, prev_str)) {
CDBG("%s: Requested Fixed Frame Rate %s", __func__, str);
updateParamEntry(KEY_PREVIEW_FRAME_RATE, str);
m_bFixedFrameRateSet = true;
}
}
return NO_ERROR;
}
/*===========================================================================
* FUNCTION : setEffect
*
* DESCRIPTION: set effect value from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setEffect(const QCameraParameters& params)
{
const char *str = params.get(KEY_EFFECT);
const char *prev_str = get(KEY_EFFECT);
if (str != NULL) {
if (prev_str == NULL ||
strcmp(str, prev_str) != 0 ||
m_bUpdateEffects == true ) {
m_bUpdateEffects = false;
return setEffect(str);
}
}
return NO_ERROR;
}
/*===========================================================================
* FUNCTION : setFocusMode
*
* DESCRIPTION: set focus mode from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setFocusMode(const QCameraParameters& params)
{
const char *str = params.get(KEY_FOCUS_MODE);
const char *prev_str = get(KEY_FOCUS_MODE);
if (str != NULL) {
if (prev_str == NULL ||
strcmp(str, prev_str) != 0) {
return setFocusMode(str);
}
}
return NO_ERROR;
}
/*===========================================================================
* FUNCTION : setBrightness
*
* DESCRIPTION: set brightness control value from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setBrightness(const QCameraParameters& params)
{
int currentBrightness = getInt(KEY_QC_BRIGHTNESS);
int brightness = params.getInt(KEY_QC_BRIGHTNESS);
if(params.get(KEY_QC_BRIGHTNESS) == NULL) {
CDBG_HIGH("%s: Brigtness not set by App ",__func__);
return NO_ERROR;
}
if (currentBrightness != brightness) {
if (brightness >= m_pCapability->brightness_ctrl.min_value &&
brightness <= m_pCapability->brightness_ctrl.max_value) {
CDBG(" new brightness value : %d ", brightness);
return setBrightness(brightness);
} else {
ALOGE("%s: invalid value %d out of (%d, %d)",
__func__, brightness,
m_pCapability->brightness_ctrl.min_value,
m_pCapability->brightness_ctrl.max_value);
return BAD_VALUE;
}
} else {
CDBG("%s: No brightness value changed.", __func__);
return NO_ERROR;
}
}
/*===========================================================================
* FUNCTION : setSharpness
*
* DESCRIPTION: set sharpness control value from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setSharpness(const QCameraParameters& params)
{
int shaprness = params.getInt(KEY_QC_SHARPNESS);
int prev_sharp = getInt(KEY_QC_SHARPNESS);
if(params.get(KEY_QC_SHARPNESS) == NULL) {
CDBG_HIGH("%s: Sharpness not set by App ",__func__);
return NO_ERROR;
}
if (prev_sharp != shaprness) {
if((shaprness >= m_pCapability->sharpness_ctrl.min_value) &&
(shaprness <= m_pCapability->sharpness_ctrl.max_value)) {
CDBG(" new sharpness value : %d ", shaprness);
return setSharpness(shaprness);
} else {
ALOGE("%s: invalid value %d out of (%d, %d)",
__func__, shaprness,
m_pCapability->sharpness_ctrl.min_value,
m_pCapability->sharpness_ctrl.max_value);
return BAD_VALUE;
}
} else {
CDBG("%s: No value change in shaprness", __func__);
return NO_ERROR;
}
}
/*===========================================================================
* FUNCTION : setSkintoneEnahancement
*
* DESCRIPTION: set skin tone enhancement factor from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setSkinToneEnhancement(const QCameraParameters& params)
{
int sceFactor = params.getInt(KEY_QC_SCE_FACTOR);
int prev_sceFactor = getInt(KEY_QC_SCE_FACTOR);
if(params.get(KEY_QC_SCE_FACTOR) == NULL) {
CDBG_HIGH("%s: Skintone enhancement not set by App ",__func__);
return NO_ERROR;
}
if (prev_sceFactor != sceFactor) {
if((sceFactor >= m_pCapability->sce_ctrl.min_value) &&
(sceFactor <= m_pCapability->sce_ctrl.max_value)) {
CDBG(" new Skintone Enhancement value : %d ", sceFactor);
return setSkinToneEnhancement(sceFactor);
} else {
ALOGE("%s: invalid value %d out of (%d, %d)",
__func__, sceFactor,
m_pCapability->sce_ctrl.min_value,
m_pCapability->sce_ctrl.max_value);
return BAD_VALUE;
}
} else {
CDBG("%s: No value change in skintone enhancement factor", __func__);
return NO_ERROR;
}
}
/*===========================================================================
* FUNCTION : setSaturation
*
* DESCRIPTION: set saturation control value from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setSaturation(const QCameraParameters& params)
{
int saturation = params.getInt(KEY_QC_SATURATION);
int prev_sat = getInt(KEY_QC_SATURATION);
if(params.get(KEY_QC_SATURATION) == NULL) {
CDBG_HIGH("%s: Saturation not set by App ",__func__);
return NO_ERROR;
}
if (prev_sat != saturation) {
if((saturation >= m_pCapability->saturation_ctrl.min_value) &&
(saturation <= m_pCapability->saturation_ctrl.max_value)) {
CDBG(" new saturation value : %d ", saturation);
return setSaturation(saturation);
} else {
ALOGE("%s: invalid value %d out of (%d, %d)",
__func__, saturation,
m_pCapability->saturation_ctrl.min_value,
m_pCapability->saturation_ctrl.max_value);
return BAD_VALUE;
}
} else {
CDBG("%s: No value change in saturation factor", __func__);
return NO_ERROR;
}
}
/*===========================================================================
* FUNCTION : setContrast
*
* DESCRIPTION: set contrast control value from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setContrast(const QCameraParameters& params)
{
int contrast = params.getInt(KEY_QC_CONTRAST);
int prev_contrast = getInt(KEY_QC_CONTRAST);
if(params.get(KEY_QC_CONTRAST) == NULL) {
CDBG_HIGH("%s: Contrast not set by App ",__func__);
return NO_ERROR;
}
if (prev_contrast != contrast) {
if((contrast >= m_pCapability->contrast_ctrl.min_value) &&
(contrast <= m_pCapability->contrast_ctrl.max_value)) {
CDBG(" new contrast value : %d ", contrast);
int32_t rc = setContrast(contrast);
return rc;
} else {
ALOGE("%s: invalid value %d out of (%d, %d)",
__func__, contrast,
m_pCapability->contrast_ctrl.min_value,
m_pCapability->contrast_ctrl.max_value);
return BAD_VALUE;
}
} else {
CDBG("%s: No value change in contrast", __func__);
return NO_ERROR;
}
}
/*===========================================================================
* FUNCTION : setExposureCompensation
*
* DESCRIPTION: set exposure compensation value from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setExposureCompensation(const QCameraParameters & params)
{
int expComp = params.getInt(KEY_EXPOSURE_COMPENSATION);
int prev_expComp = getInt(KEY_EXPOSURE_COMPENSATION);
if(params.get(KEY_EXPOSURE_COMPENSATION) == NULL) {
CDBG_HIGH("%s: Exposure compensation not set by App ",__func__);
return NO_ERROR;
}
if (prev_expComp != expComp) {
if((expComp >= m_pCapability->exposure_compensation_min) &&
(expComp <= m_pCapability->exposure_compensation_max)) {
CDBG(" new Exposure Compensation value : %d ", expComp);
return setExposureCompensation(expComp);
} else {
ALOGE("%s: invalid value %d out of (%d, %d)",
__func__, expComp,
m_pCapability->exposure_compensation_min,
m_pCapability->exposure_compensation_max);
return BAD_VALUE;
}
} else {
CDBG("%s: No value change in Exposure Compensation", __func__);
return NO_ERROR;
}
}
/*===========================================================================
* FUNCTION : setWhiteBalance
*
* DESCRIPTION: set white balance value from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setWhiteBalance(const QCameraParameters& params)
{
const char *str = params.get(KEY_WHITE_BALANCE);
const char *prev_str = get(KEY_WHITE_BALANCE);
if (str != NULL) {
if (prev_str == NULL ||
strcmp(str, prev_str) != 0) {
return setWhiteBalance(str);
}
}
return NO_ERROR;
}
/*===========================================================================
* FUNCTION : setAntibanding
*
* DESCRIPTION: set antibanding value from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setAntibanding(const QCameraParameters& params)
{
const char *str = params.get(KEY_ANTIBANDING);
const char *prev_str = get(KEY_ANTIBANDING);
if (str != NULL) {
if (prev_str == NULL ||
strcmp(str, prev_str) != 0) {
return setAntibanding(str);
}
}
return NO_ERROR;
}
/*===========================================================================
* FUNCTION : setStatsDebugMask
*
* DESCRIPTION: get the value from persist file in Stats module that will
* control funtionality in the module
*
* PARAMETERS : none
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setStatsDebugMask()
{
uint32_t mask = 0;
char value[PROPERTY_VALUE_MAX];
property_get("persist.camera.stats.debug.mask", value, "0");
mask = (uint32_t)atoi(value);
CDBG_HIGH("%s: ctrl mask :%d", __func__, mask);
return AddSetParmEntryToBatch(m_pParamBuf,
CAM_INTF_PARM_STATS_DEBUG_MASK,
sizeof(mask),
&mask);
}
/*===========================================================================
* FUNCTION : setPAAF
*
* DESCRIPTION: get the value from persist file in Stats module that will
* control the preview assisted AF in the module
*
* PARAMETERS : none
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setPAAF()
{
uint32_t paaf = 0;
char value[PROPERTY_VALUE_MAX];
property_get("persist.camera.stats.af.paaf", value, "1");
paaf = (uint32_t)atoi(value);
ALOGE("%s: PAAF is: %s", __func__, paaf ? "ON": "OFF");
return AddSetParmEntryToBatch(m_pParamBuf,
CAM_INTF_PARM_STATS_AF_PAAF,
sizeof(paaf),
&paaf);
}
/*===========================================================================
* FUNCTION : setSceneDetect
*
* DESCRIPTION: set scenen detect value from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setSceneDetect(const QCameraParameters& params)
{
const char *str = params.get(KEY_QC_SCENE_DETECT);
const char *prev_str = get(KEY_QC_SCENE_DETECT);
if (str != NULL) {
if (prev_str == NULL ||
strcmp(str, prev_str) != 0) {
return setSceneDetect(str);
}
}
return NO_ERROR;
}
/*===========================================================================
* FUNCTION : setVideoHDR
*
* DESCRIPTION: set video HDR value from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setVideoHDR(const QCameraParameters& params)
{
const char *str = params.get(KEY_QC_VIDEO_HDR);
const char *prev_str = get(KEY_QC_VIDEO_HDR);
if (str != NULL) {
if (prev_str == NULL ||
strcmp(str, prev_str) != 0) {
return setVideoHDR(str);
}
}
return NO_ERROR;
}
/*===========================================================================
* FUNCTION : setVtEnable
*
* DESCRIPTION: set vt Time Stamp enable from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setVtEnable(const QCameraParameters& params)
{
const char *str = params.get(KEY_QC_VT_ENABLE);
const char *prev_str = get(KEY_QC_VT_ENABLE);
if (str != NULL) {
if (prev_str == NULL ||
strcmp(str, prev_str) != 0) {
return setVtEnable(str);
}
}
return NO_ERROR;
}
/*===========================================================================
* FUNCTION : setFaceRecognition
*
* DESCRIPTION: set face recognition mode from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setFaceRecognition(const QCameraParameters& params)
{
const char *str = params.get(KEY_QC_FACE_RECOGNITION);
const char *prev_str = get(KEY_QC_FACE_RECOGNITION);
if (str != NULL) {
if (prev_str == NULL ||
strcmp(str, prev_str) != 0) {
int maxFaces = params.getInt(KEY_QC_MAX_NUM_REQUESTED_FACES);
return setFaceRecognition(str, maxFaces);
}
}
return NO_ERROR;
}
/*===========================================================================
* FUNCTION : setZoom
*
* DESCRIPTION: set zoom value from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setZoom(const QCameraParameters& params)
{
if ((m_pCapability->zoom_supported == 0 ||
m_pCapability->zoom_ratio_tbl_cnt == 0)) {
CDBG_HIGH("%s: no zoom support", __func__);
return NO_ERROR;
}
int zoomLevel = params.getInt(KEY_ZOOM);
if((zoomLevel < 0) ||
(zoomLevel >= m_pCapability->zoom_ratio_tbl_cnt)) {
ALOGE("%s: invalid value %d out of (%d, %d)",
__func__, zoomLevel,
0, m_pCapability->zoom_ratio_tbl_cnt-1);
return BAD_VALUE;
}
int prevZoomLevel = getInt(KEY_ZOOM);
if (prevZoomLevel == zoomLevel) {
CDBG("%s: No value change in contrast", __func__);
return NO_ERROR;
}
return setZoom(zoomLevel);
}
/*===========================================================================
* FUNCTION : setISOValue
*
* DESCRIPTION: set ISO value from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setISOValue(const QCameraParameters& params)
{
const char *str = params.get(KEY_QC_ISO_MODE);
const char *prev_str = get(KEY_QC_ISO_MODE);
if (str != NULL) {
if (prev_str == NULL ||
strcmp(str, prev_str) != 0) {
return setISOValue(str);
}
}
return NO_ERROR;
}
/*===========================================================================
* FUNCTION : setVideoRotation
*
* DESCRIPTION: set rotation value from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setVideoRotation(const QCameraParameters& params)
{
int rotation = params.getInt(KEY_QC_VIDEO_ROTATION);
if (rotation != -1) {
if (rotation == 0 || rotation == 90 ||
rotation == 180 || rotation == 270) {
set(KEY_QC_VIDEO_ROTATION, rotation);
} else {
ALOGE("Invalid rotation value: %d", rotation);
return BAD_VALUE;
}
}
return NO_ERROR;
}
/*===========================================================================
* FUNCTION : setRotation
*
* DESCRIPTION: set rotation value from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setRotation(const QCameraParameters& params)
{
int rotation = params.getInt(KEY_ROTATION);
if (rotation != -1) {
if (rotation == 0 || rotation == 90 ||
rotation == 180 || rotation == 270) {
set(KEY_ROTATION, rotation);
} else {
ALOGE("Invalid rotation value: %d", rotation);
return BAD_VALUE;
}
}
return NO_ERROR;
}
/*===========================================================================
* FUNCTION : setFlash
*
* DESCRIPTION: set flash mode from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setFlash(const QCameraParameters& params)
{
const char *str = params.get(KEY_FLASH_MODE);
const char *prev_str = get(KEY_FLASH_MODE);
if (str != NULL) {
if (prev_str == NULL ||
strcmp(str, prev_str) != 0) {
return setFlash(str);
}
}
return NO_ERROR;
}
/*===========================================================================
* FUNCTION : setAecLock
*
* DESCRIPTION: set AEC lock value from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setAecLock(const QCameraParameters& params)
{
const char *str = params.get(KEY_AUTO_EXPOSURE_LOCK);
const char *prev_str = get(KEY_AUTO_EXPOSURE_LOCK);
if (str != NULL) {
if (prev_str == NULL ||
strcmp(str, prev_str) != 0) {
return setAecLock(str);
}
}
return NO_ERROR;
}
/*===========================================================================
* FUNCTION : setAwbLock
*
* DESCRIPTION: set AWB lock from user setting
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setAwbLock(const QCameraParameters& params)
{
const char *str = params.get(KEY_AUTO_WHITEBALANCE_LOCK);
const char *prev_str = get(KEY_AUTO_WHITEBALANCE_LOCK);
if (str != NULL) {
if (prev_str == NULL ||
strcmp(str, prev_str) != 0) {
return setAwbLock(str);
}
}
return NO_ERROR;
}
/*===========================================================================
* FUNCTION : setAutoHDR
*
* DESCRIPTION: Enable/disable auto HDR
*
* PARAMETERS :
* @params : user setting parameters
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::setAutoHDR(const QCameraParameters& params)
{
const char *str = params.get(KEY_QC_AUTO_HDR_ENABLE);
const char *prev_str = get(KEY_QC_AUTO_HDR_ENABLE);
char prop[PROPERTY_VALUE_MAX];
memset(prop, 0, sizeof(prop));
property_get("persist.camera.auto.hdr.enable", prop, VALUE_DISABLE);
if (str != NULL) {
if (prev_str == NULL ||
strcmp(str, prev_str) != 0) {
CDBG_HIGH("%s : Auto HDR set to: %s", __func__, str);
return updateParamEntry(KEY_QC_AUTO_HDR_ENABLE, str);
}
} else {
if (prev_str == NULL ||
strcmp(prev_str, prop) != 0 ) {
CDBG_HIGH("%s : Auto HDR set to: %s", __func__, prop);
updateParamEntry(KEY_QC_AUTO_HDR_ENABLE, prop);
}
}
return NO_ERROR;
}
/*===========================================================================
* FUNCTION : isAutoHDREnabled
*
* DESCRIPTION: Query auto HDR status
*
* PARAMETERS : None
*
* RETURN : bool true/false
*==========================================================================*/
bool QCameraParameters::isAutoHDREnabled()
{
const char *str = get(KEY_QC_AUTO_HDR_ENABLE);
if (str != NULL) {
int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP,
sizeof(ENABLE_DISABLE_MODES_MAP)/sizeof(QCameraMap),