1 /* 2 ** Copyright (c) 2012 The Linux Foundation. All rights reserved. 3 ** 4 ** Not a Contribution, Apache license notifications and license are retained 5 ** for attribution purposes only. 6 ** 7 ** Licensed under the Apache License, Version 2.0 (the "License"); 8 ** you may not use this file except in compliance with the License. 9 ** You may obtain a copy of the License at 10 ** 11 ** http://www.apache.org/licenses/LICENSE-2.0 12 ** 13 ** Unless required by applicable law or agreed to in writing, software 14 ** distributed under the License is distributed on an "AS IS" BASIS, 15 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 ** See the License for the specific language governing permissions and 17 ** limitations under the License. 18 */ 19 20 //#define ALOG_NDEBUG 0 21 #define ALOG_NIDEBUG 0 22 #define LOG_TAG "QCameraHWI_Parm" 23 #include <utils/Log.h> 24 25 #include <utils/Errors.h> 26 #include <utils/threads.h> 27 #include <utils/String16.h> 28 #include <sys/types.h> 29 #include <sys/stat.h> 30 #include <unistd.h> 31 #include <fcntl.h> 32 #include <cutils/properties.h> 33 #include <math.h> 34 #if __ANDROID__ 35 #include <linux/android_pmem.h> 36 #endif 37 #include <linux/ioctl.h> 38 #include <camera/QCameraParameters.h> 39 #include <media/mediarecorder.h> 40 #include <gralloc_priv.h> 41 42 #include "linux/msm_mdp.h" 43 #include <linux/fb.h> 44 #include <limits.h> 45 46 47 extern "C" { 48 #include <fcntl.h> 49 #include <time.h> 50 #include <pthread.h> 51 #include <stdio.h> 52 #include <string.h> 53 #include <unistd.h> 54 #include <termios.h> 55 #include <assert.h> 56 #include <stdlib.h> 57 #include <ctype.h> 58 #include <signal.h> 59 #include <errno.h> 60 #include <sys/mman.h> 61 #include <sys/system_properties.h> 62 #include <sys/time.h> 63 #include <stdlib.h> 64 #include <linux/msm_ion.h> 65 #include <camera.h> 66 #include <cam_fifo.h> 67 #include <jpege.h> 68 69 } // extern "C" 70 71 #include "QCameraHWI.h" 72 73 /* QCameraHardwareInterface class implementation goes here*/ 74 /* following code implements the parameter logic of this class*/ 75 #define EXPOSURE_COMPENSATION_MAXIMUM_NUMERATOR 12 76 #define EXPOSURE_COMPENSATION_MINIMUM_NUMERATOR -12 77 #define EXPOSURE_COMPENSATION_DEFAULT_NUMERATOR 0 78 #define EXPOSURE_COMPENSATION_DENOMINATOR 6 79 #define EXPOSURE_COMPENSATION_STEP ((float (1))/EXPOSURE_COMPENSATION_DENOMINATOR) 80 #define DEFAULT_CAMERA_AREA "(0, 0, 0, 0, 0)" 81 82 #define HDR_HAL_FRAME 2 83 84 #define BURST_INTREVAL_MIN 1 85 #define BURST_INTREVAL_MAX 10 86 #define BURST_INTREVAL_DEFAULT 1 87 88 //Default FPS 89 #define MINIMUM_FPS 5 90 #define MAXIMUM_FPS 120 91 #define DEFAULT_FIXED_FPS 30 92 #define DEFAULT_FPS MAXIMUM_FPS 93 94 //Default Picture Width 95 #define DEFAULT_PICTURE_WIDTH 640 96 #define DEFAULT_PICTURE_HEIGHT 480 97 98 //Default Video Width 99 #define DEFAULT_VIDEO_WIDTH 1920 100 #define DEFAULT_VIDEO_HEIGHT 1080 101 102 #define THUMBNAIL_SIZE_COUNT (sizeof(thumbnail_sizes)/sizeof(thumbnail_size_type)) 103 #define DEFAULT_THUMBNAIL_SETTING 4 104 #define THUMBNAIL_WIDTH_STR "512" 105 #define THUMBNAIL_HEIGHT_STR "384" 106 #define THUMBNAIL_SMALL_HEIGHT 144 107 108 #define DONT_CARE_COORDINATE -1 109 110 // All fps ranges which can be supported. This list will be filtered according 111 // to the min and max fps supported by hardware 112 // this list must be sorted first by max_fps and then min_fps 113 // fps values are multiplied by 1000 114 static android::FPSRange allFpsRanges[] = { 115 android::FPSRange(7500, 7500), 116 android::FPSRange(10000, 10000), 117 android::FPSRange(7500, 15000), 118 android::FPSRange(15000, 15000), 119 android::FPSRange(7500, 20000), 120 android::FPSRange(20000, 20000), 121 android::FPSRange(7500, 30000), 122 android::FPSRange(10000, 30000), 123 android::FPSRange(15000, 30000), 124 android::FPSRange(30000, 30000) 125 }; 126 #define ALL_FPS_RANGES_COUNT (sizeof(allFpsRanges)/sizeof(android::FPSRange)) 127 128 typedef struct { 129 uint32_t aspect_ratio; 130 uint32_t width; 131 uint32_t height; 132 } thumbnail_size_type; 133 134 static thumbnail_size_type thumbnail_sizes[] = { 135 { 7281, 512, 288 }, //1.777778 136 { 6826, 480, 288 }, //1.666667 137 { 6808, 256, 154 }, //1.66233 138 { 6144, 432, 288 }, //1.5 139 { 5461, 512, 384 }, //1.333333 140 { 5006, 352, 288 }, //1.222222 141 { 5461, 320, 240 }, //1.33333 142 { 5006, 176, 144 }, //1.222222 143 144 }; 145 146 static struct camera_size_type zsl_picture_sizes[] = { 147 { 1024, 768}, // 1MP XGA 148 { 800, 600}, //SVGA 149 { 800, 480}, // WVGA 150 { 640, 480}, // VGA 151 { 352, 288}, //CIF 152 { 320, 240}, // QVGA 153 { 176, 144} // QCIF 154 }; 155 156 static camera_size_type default_picture_sizes[] = { 157 { 4000, 3000}, // 12MP 158 { 3200, 2400}, // 8MP 159 { 2592, 1944}, // 5MP 160 { 2048, 1536}, // 3MP QXGA 161 { 1920, 1080}, //HD1080 162 { 1600, 1200}, // 2MP UXGA 163 { 1280, 768}, //WXGA 164 { 1280, 720}, //HD720 165 { 1024, 768}, // 1MP XGA 166 { 800, 600}, //SVGA 167 { 800, 480}, // WVGA 168 { 720, 480}, 169 { 640, 480}, // VGA 170 { 352, 288}, //CIF 171 { 320, 240}, // QVGA 172 { 176, 144} // QCIF 173 }; 174 175 static int iso_speed_values[] = { 176 0, 1, 100, 200, 400, 800, 1600 177 }; 178 179 extern int HAL_numOfCameras; 180 extern camera_info_t HAL_cameraInfo[MSM_MAX_CAMERA_SENSORS]; 181 extern mm_camera_info_t * HAL_camerahandle[MSM_MAX_CAMERA_SENSORS]; 182 183 namespace android { 184 185 static uint32_t HFR_SIZE_COUNT=2; 186 static const int PICTURE_FORMAT_JPEG = 1; 187 static const int PICTURE_FORMAT_RAW = 2; 188 189 /********************************************************************/ 190 static const str_map effects[] = { 191 { QCameraParameters::EFFECT_NONE, CAMERA_EFFECT_OFF }, 192 { QCameraParameters::EFFECT_MONO, CAMERA_EFFECT_MONO }, 193 { QCameraParameters::EFFECT_NEGATIVE, CAMERA_EFFECT_NEGATIVE }, 194 { QCameraParameters::EFFECT_SOLARIZE, CAMERA_EFFECT_SOLARIZE }, 195 { QCameraParameters::EFFECT_SEPIA, CAMERA_EFFECT_SEPIA }, 196 { QCameraParameters::EFFECT_POSTERIZE, CAMERA_EFFECT_POSTERIZE }, 197 { QCameraParameters::EFFECT_WHITEBOARD, CAMERA_EFFECT_WHITEBOARD }, 198 { QCameraParameters::EFFECT_BLACKBOARD, CAMERA_EFFECT_BLACKBOARD }, 199 { QCameraParameters::EFFECT_AQUA, CAMERA_EFFECT_AQUA }, 200 { QCameraParameters::EFFECT_EMBOSS, CAMERA_EFFECT_EMBOSS }, 201 { QCameraParameters::EFFECT_SKETCH, CAMERA_EFFECT_SKETCH }, 202 { QCameraParameters::EFFECT_NEON, CAMERA_EFFECT_NEON } 203 }; 204 205 static const str_map iso[] = { 206 { QCameraParameters::ISO_AUTO, CAMERA_ISO_AUTO}, 207 { QCameraParameters::ISO_HJR, CAMERA_ISO_DEBLUR}, 208 { QCameraParameters::ISO_100, CAMERA_ISO_100}, 209 { QCameraParameters::ISO_200, CAMERA_ISO_200}, 210 { QCameraParameters::ISO_400, CAMERA_ISO_400}, 211 { QCameraParameters::ISO_800, CAMERA_ISO_800 }, 212 { QCameraParameters::ISO_1600, CAMERA_ISO_1600 } 213 }; 214 215 static const str_map scenemode[] = { 216 { QCameraParameters::SCENE_MODE_AUTO, CAMERA_BESTSHOT_OFF }, 217 { QCameraParameters::SCENE_MODE_ASD, CAMERA_BESTSHOT_AUTO }, 218 { QCameraParameters::SCENE_MODE_ACTION, CAMERA_BESTSHOT_ACTION }, 219 { QCameraParameters::SCENE_MODE_PORTRAIT, CAMERA_BESTSHOT_PORTRAIT }, 220 { QCameraParameters::SCENE_MODE_LANDSCAPE, CAMERA_BESTSHOT_LANDSCAPE }, 221 { QCameraParameters::SCENE_MODE_NIGHT, CAMERA_BESTSHOT_NIGHT }, 222 { QCameraParameters::SCENE_MODE_NIGHT_PORTRAIT, CAMERA_BESTSHOT_NIGHT_PORTRAIT }, 223 { QCameraParameters::SCENE_MODE_THEATRE, CAMERA_BESTSHOT_THEATRE }, 224 { QCameraParameters::SCENE_MODE_BEACH, CAMERA_BESTSHOT_BEACH }, 225 { QCameraParameters::SCENE_MODE_SNOW, CAMERA_BESTSHOT_SNOW }, 226 { QCameraParameters::SCENE_MODE_SUNSET, CAMERA_BESTSHOT_SUNSET }, 227 { QCameraParameters::SCENE_MODE_STEADYPHOTO, CAMERA_BESTSHOT_ANTISHAKE }, 228 { QCameraParameters::SCENE_MODE_FIREWORKS , CAMERA_BESTSHOT_FIREWORKS }, 229 { QCameraParameters::SCENE_MODE_SPORTS , CAMERA_BESTSHOT_SPORTS }, 230 { QCameraParameters::SCENE_MODE_PARTY, CAMERA_BESTSHOT_PARTY }, 231 { QCameraParameters::SCENE_MODE_CANDLELIGHT, CAMERA_BESTSHOT_CANDLELIGHT }, 232 { QCameraParameters::SCENE_MODE_BACKLIGHT, CAMERA_BESTSHOT_BACKLIGHT }, 233 { QCameraParameters::SCENE_MODE_FLOWERS, CAMERA_BESTSHOT_FLOWERS }, 234 { QCameraParameters::SCENE_MODE_AR, CAMERA_BESTSHOT_AR }, 235 }; 236 237 static const str_map scenedetect[] = { 238 { QCameraParameters::SCENE_DETECT_OFF, FALSE }, 239 { QCameraParameters::SCENE_DETECT_ON, TRUE }, 240 }; 241 242 #define DONT_CARE AF_MODE_MAX 243 static const str_map focus_modes[] = { 244 { QCameraParameters::FOCUS_MODE_AUTO, AF_MODE_AUTO}, 245 { QCameraParameters::FOCUS_MODE_INFINITY, AF_MODE_INFINITY }, 246 { QCameraParameters::FOCUS_MODE_NORMAL, AF_MODE_NORMAL }, 247 { QCameraParameters::FOCUS_MODE_MACRO, AF_MODE_MACRO }, 248 { QCameraParameters::FOCUS_MODE_CONTINUOUS_PICTURE, AF_MODE_CAF}, 249 { QCameraParameters::FOCUS_MODE_CONTINUOUS_VIDEO, AF_MODE_CAF } 250 }; 251 252 static const str_map selectable_zone_af[] = { 253 { QCameraParameters::SELECTABLE_ZONE_AF_AUTO, AUTO }, 254 { QCameraParameters::SELECTABLE_ZONE_AF_SPOT_METERING, SPOT }, 255 { QCameraParameters::SELECTABLE_ZONE_AF_CENTER_WEIGHTED, CENTER_WEIGHTED }, 256 { QCameraParameters::SELECTABLE_ZONE_AF_FRAME_AVERAGE, AVERAGE } 257 }; 258 259 // from qcamera/common/camera.h 260 static const str_map autoexposure[] = { 261 { QCameraParameters::AUTO_EXPOSURE_FRAME_AVG, CAMERA_AEC_FRAME_AVERAGE }, 262 { QCameraParameters::AUTO_EXPOSURE_CENTER_WEIGHTED, CAMERA_AEC_CENTER_WEIGHTED }, 263 { QCameraParameters::AUTO_EXPOSURE_SPOT_METERING, CAMERA_AEC_SPOT_METERING } 264 }; 265 266 // from aeecamera.h 267 static const str_map whitebalance[] = { 268 { QCameraParameters::WHITE_BALANCE_AUTO, CAMERA_WB_AUTO }, 269 { QCameraParameters::WHITE_BALANCE_INCANDESCENT, CAMERA_WB_INCANDESCENT }, 270 { QCameraParameters::WHITE_BALANCE_FLUORESCENT, CAMERA_WB_FLUORESCENT }, 271 { QCameraParameters::WHITE_BALANCE_DAYLIGHT, CAMERA_WB_DAYLIGHT }, 272 { QCameraParameters::WHITE_BALANCE_CLOUDY_DAYLIGHT, CAMERA_WB_CLOUDY_DAYLIGHT } 273 }; 274 275 static const str_map antibanding[] = { 276 { QCameraParameters::ANTIBANDING_OFF, CAMERA_ANTIBANDING_OFF }, 277 { QCameraParameters::ANTIBANDING_50HZ, CAMERA_ANTIBANDING_50HZ }, 278 { QCameraParameters::ANTIBANDING_60HZ, CAMERA_ANTIBANDING_60HZ }, 279 { QCameraParameters::ANTIBANDING_AUTO, CAMERA_ANTIBANDING_AUTO } 280 }; 281 282 static const str_map frame_rate_modes[] = { 283 {QCameraParameters::KEY_QC_PREVIEW_FRAME_RATE_AUTO_MODE, FPS_MODE_AUTO}, 284 {QCameraParameters::KEY_QC_PREVIEW_FRAME_RATE_FIXED_MODE, FPS_MODE_FIXED} 285 }; 286 287 static const str_map touchafaec[] = { 288 { QCameraParameters::TOUCH_AF_AEC_OFF, FALSE }, 289 { QCameraParameters::TOUCH_AF_AEC_ON, TRUE } 290 }; 291 292 static const str_map hfr[] = { 293 { QCameraParameters::VIDEO_HFR_OFF, CAMERA_HFR_MODE_OFF }, 294 { QCameraParameters::VIDEO_HFR_2X, CAMERA_HFR_MODE_60FPS }, 295 { QCameraParameters::VIDEO_HFR_3X, CAMERA_HFR_MODE_90FPS }, 296 { QCameraParameters::VIDEO_HFR_4X, CAMERA_HFR_MODE_120FPS }, 297 }; 298 static const int HFR_VALUES_COUNT = (sizeof(hfr)/sizeof(str_map)); 299 300 static const str_map flash[] = { 301 { QCameraParameters::FLASH_MODE_OFF, LED_MODE_OFF }, 302 { QCameraParameters::FLASH_MODE_AUTO, LED_MODE_AUTO }, 303 { QCameraParameters::FLASH_MODE_ON, LED_MODE_ON }, 304 { QCameraParameters::FLASH_MODE_TORCH, LED_MODE_TORCH} 305 }; 306 307 static const str_map lensshade[] = { 308 { QCameraParameters::LENSSHADE_ENABLE, TRUE }, 309 { QCameraParameters::LENSSHADE_DISABLE, FALSE } 310 }; 311 312 static const str_map mce[] = { 313 { QCameraParameters::MCE_ENABLE, TRUE }, 314 { QCameraParameters::MCE_DISABLE, FALSE } 315 }; 316 317 static const str_map histogram[] = { 318 { QCameraParameters::HISTOGRAM_ENABLE, TRUE }, 319 { QCameraParameters::HISTOGRAM_DISABLE, FALSE } 320 }; 321 322 static const str_map skinToneEnhancement[] = { 323 { QCameraParameters::SKIN_TONE_ENHANCEMENT_ENABLE, TRUE }, 324 { QCameraParameters::SKIN_TONE_ENHANCEMENT_DISABLE, FALSE } 325 }; 326 327 static const str_map denoise[] = { 328 { QCameraParameters::DENOISE_OFF, FALSE }, 329 { QCameraParameters::DENOISE_ON, TRUE } 330 }; 331 332 static const str_map facedetection[] = { 333 { QCameraParameters::FACE_DETECTION_OFF, FALSE }, 334 { QCameraParameters::FACE_DETECTION_ON, TRUE } 335 }; 336 337 static const str_map redeye_reduction[] = { 338 { QCameraParameters::REDEYE_REDUCTION_ENABLE, TRUE }, 339 { QCameraParameters::REDEYE_REDUCTION_DISABLE, FALSE } 340 }; 341 342 static const str_map picture_formats[] = { 343 {QCameraParameters::PIXEL_FORMAT_JPEG, PICTURE_FORMAT_JPEG}, 344 {QCameraParameters::PIXEL_FORMAT_RAW, PICTURE_FORMAT_RAW} 345 }; 346 347 static const str_map recording_Hints[] = { 348 {"false", FALSE}, 349 {"true", TRUE} 350 }; 351 352 static const str_map preview_formats[] = { 353 {QCameraParameters::PIXEL_FORMAT_YUV420SP, HAL_PIXEL_FORMAT_YCrCb_420_SP}, 354 {QCameraParameters::PIXEL_FORMAT_YUV420SP_ADRENO, HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO}, 355 {QCameraParameters::PIXEL_FORMAT_YV12, HAL_PIXEL_FORMAT_YV12}, 356 {QCameraParameters::PIXEL_FORMAT_YUV420P,HAL_PIXEL_FORMAT_YV12}, 357 {QCameraParameters::PIXEL_FORMAT_NV12, HAL_PIXEL_FORMAT_YCbCr_420_SP} 358 }; 359 360 static const preview_format_info_t preview_format_info_list[] = { 361 {HAL_PIXEL_FORMAT_YCrCb_420_SP, CAMERA_YUV_420_NV21, CAMERA_PAD_TO_WORD, 2}, 362 {HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO, CAMERA_YUV_420_NV21, CAMERA_PAD_TO_4K, 2}, 363 {HAL_PIXEL_FORMAT_YCbCr_420_SP, CAMERA_YUV_420_NV12, CAMERA_PAD_TO_WORD, 2}, 364 {HAL_PIXEL_FORMAT_YV12, CAMERA_YUV_420_YV12, CAMERA_PAD_TO_WORD, 3} 365 }; 366 367 static const str_map zsl_modes[] = { 368 { QCameraParameters::ZSL_OFF, FALSE }, 369 { QCameraParameters::ZSL_ON, TRUE }, 370 }; 371 372 373 static const str_map hdr_bracket[] = { 374 { QCameraParameters::AE_BRACKET_HDR_OFF,HDR_BRACKETING_OFF}, 375 { QCameraParameters::AE_BRACKET_HDR,HDR_MODE }, 376 { QCameraParameters::AE_BRACKET,EXP_BRACKETING_MODE } 377 }; 378 379 typedef enum { 380 NORMAL_POWER, 381 LOW_POWER 382 } power_mode; 383 384 static const str_map power_modes[] = { 385 { QCameraParameters::NORMAL_POWER,NORMAL_POWER }, 386 { QCameraParameters::LOW_POWER,LOW_POWER } 387 }; 388 389 /**************************************************************************/ 390 static int attr_lookup(const str_map arr[], int len, const char *name) 391 { 392 if (name) { 393 for (int i = 0; i < len; i++) { 394 if (!strcmp(arr[i].desc, name)) 395 return arr[i].val; 396 } 397 } 398 return NOT_FOUND; 399 } 400 401 bool QCameraHardwareInterface::native_set_parms( 402 mm_camera_parm_type_t type, uint16_t length, void *value) 403 { 404 ALOGV("%s : type : %d Value : %d",__func__,type,*((int *)value)); 405 if(mCameraHandle->ops->set_parm(mCameraHandle->camera_handle, type,value ) < 0) { 406 ALOGE("native_set_parms failed: type %d length %d error %s", 407 type, length, strerror(errno)); 408 return false; 409 } 410 411 return true; 412 413 } 414 415 bool QCameraHardwareInterface::native_set_parms( 416 mm_camera_parm_type_t type, uint16_t length, void *value, int *result) 417 { 418 *result= mCameraHandle->ops->set_parm(mCameraHandle->camera_handle, type,value ); 419 if( *result >=0 ) { 420 ALOGE("native_set_parms: succeeded : %d", *result); 421 return true; 422 } 423 424 ALOGV("native_set_parms failed: type %d length %d error str %s error# %d", 425 type, length, strerror(errno), errno); 426 return false; 427 } 428 429 //Filter Picture sizes based on max width and height 430 /* TBD: do we still need this - except for ZSL? */ 431 void QCameraHardwareInterface::filterPictureSizes(){ 432 unsigned int i; 433 if(mPictureSizeCount <= 0) 434 return; 435 maxSnapshotWidth = mPictureSizes[0].width; 436 maxSnapshotHeight = mPictureSizes[0].height; 437 // Iterate through all the width and height to find the max value 438 for(i =0; i<mPictureSizeCount;i++){ 439 if(((maxSnapshotWidth < mPictureSizes[i].width) && 440 (maxSnapshotHeight <= mPictureSizes[i].height))){ 441 maxSnapshotWidth = mPictureSizes[i].width; 442 maxSnapshotHeight = mPictureSizes[i].height; 443 } 444 } 445 if(myMode & CAMERA_ZSL_MODE){ 446 // due to lack of PMEM we restrict to lower resolution 447 mPictureSizesPtr = zsl_picture_sizes; 448 mSupportedPictureSizesCount = 7; 449 }else{ 450 mPictureSizesPtr = mPictureSizes; 451 mSupportedPictureSizesCount = mPictureSizeCount; 452 } 453 } 454 455 static String8 create_sizes_str(const camera_size_type *sizes, int len) { 456 String8 str; 457 char buffer[32]; 458 459 if (len > 0) { 460 snprintf(buffer, sizeof(buffer), "%dx%d", sizes[0].width, sizes[0].height); 461 str.append(buffer); 462 } 463 for (int i = 1; i < len; i++) { 464 snprintf(buffer, sizeof(buffer), ",%dx%d", sizes[i].width, sizes[i].height); 465 str.append(buffer); 466 } 467 return str; 468 } 469 470 String8 QCameraHardwareInterface::create_values_str(const str_map *values, int len) { 471 String8 str; 472 473 if (len > 0) { 474 str.append(values[0].desc); 475 } 476 for (int i = 1; i < len; i++) { 477 str.append(","); 478 str.append(values[i].desc); 479 } 480 return str; 481 } 482 483 static String8 create_fps_str(const android:: FPSRange* fps, int len) { 484 String8 str; 485 char buffer[32]; 486 487 if (len > 0) { 488 snprintf(buffer, sizeof(buffer), "(%d,%d)", fps[0].minFPS, fps[0].maxFPS); 489 str.append(buffer); 490 } 491 for (int i = 1; i < len; i++) { 492 snprintf(buffer, sizeof(buffer), ",(%d,%d)", fps[i].minFPS, fps[i].maxFPS); 493 str.append(buffer); 494 } 495 return str; 496 } 497 498 static String8 create_values_range_str(int min, int max){ 499 String8 str; 500 char buffer[32]; 501 502 if(min <= max){ 503 snprintf(buffer, sizeof(buffer), "%d", min); 504 str.append(buffer); 505 506 for (int i = min + 1; i <= max; i++) { 507 snprintf(buffer, sizeof(buffer), ",%d", i); 508 str.append(buffer); 509 } 510 } 511 return str; 512 } 513 514 static int parse_size(const char *str, int &width, int &height) 515 { 516 // Find the width. 517 char *end; 518 int w = (int)strtol(str, &end, 10); 519 // If an 'x' or 'X' does not immediately follow, give up. 520 if ( (*end != 'x') && (*end != 'X') ) 521 return -1; 522 523 // Find the height, immediately after the 'x'. 524 int h = (int)strtol(end+1, 0, 10); 525 526 width = w; 527 height = h; 528 529 return 0; 530 } 531 532 bool QCameraHardwareInterface::isValidDimension(int width, int height) { 533 bool retVal = FALSE; 534 /* This function checks if a given resolution is valid or not. 535 * A particular resolution is considered valid if it satisfies 536 * the following conditions: 537 * 1. width & height should be multiple of 16. 538 * 2. width & height should be less than/equal to the dimensions 539 * supported by the camera sensor. 540 * 3. the aspect ratio is a valid aspect ratio and is among the 541 * commonly used aspect ratio as determined by the thumbnail_sizes 542 * data structure. 543 */ 544 545 if( (width == CEILING16(width)) && (height == CEILING16(height)) 546 && (width <= maxSnapshotWidth) 547 && (height <= maxSnapshotHeight) ) 548 { 549 uint32_t pictureAspectRatio = (uint32_t)((width * Q12)/height); 550 for(uint32_t i = 0; i < THUMBNAIL_SIZE_COUNT; i++ ) { 551 if(thumbnail_sizes[i].aspect_ratio == pictureAspectRatio) { 552 retVal = TRUE; 553 break; 554 } 555 } 556 } 557 return retVal; 558 } 559 560 void QCameraHardwareInterface::hasAutoFocusSupport(){ 561 562 ALOGV("%s",__func__); 563 mHasAutoFocusSupport = false; 564 565 if(isZSLMode()){ 566 mHasAutoFocusSupport = false; 567 return; 568 } 569 570 if(mCameraHandle->ops->is_op_supported(mCameraHandle->camera_handle, MM_CAMERA_OPS_FOCUS)) { 571 mHasAutoFocusSupport = true; 572 } 573 else { 574 ALOGE("AutoFocus is not supported"); 575 mHasAutoFocusSupport = false; 576 } 577 ALOGV("%s:rc= %d",__func__, mHasAutoFocusSupport); 578 579 } 580 581 bool QCameraHardwareInterface::supportsSceneDetection() { 582 bool rc ; 583 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle,MM_CAMERA_PARM_ASD_ENABLE,(uint8_t*)&rc,(uint8_t*)&rc); 584 return rc; 585 } 586 587 bool QCameraHardwareInterface::supportsFaceDetection() { 588 bool rc ; 589 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle,MM_CAMERA_PARM_FD,(uint8_t*)&rc,(uint8_t*)&rc); 590 return rc; 591 } 592 593 bool QCameraHardwareInterface::supportsSelectableZoneAf() { 594 bool rc ; 595 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle,MM_CAMERA_PARM_FOCUS_RECT,(uint8_t*)&rc,(uint8_t*)&rc); 596 return rc; 597 } 598 599 bool QCameraHardwareInterface::supportsRedEyeReduction() { 600 bool rc ; 601 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle,MM_CAMERA_PARM_REDEYE_REDUCTION,(uint8_t*)&rc,(uint8_t*)&rc); 602 return rc; 603 } 604 605 static String8 create_str(int16_t *arr, int length){ 606 String8 str; 607 char buffer[32] = {0}; 608 609 if(length > 0){ 610 snprintf(buffer, sizeof(buffer), "%d", arr[0]); 611 str.append(buffer); 612 } 613 614 for (int i =1;i<length;i++){ 615 snprintf(buffer, sizeof(buffer), ",%d",arr[i]); 616 str.append(buffer); 617 } 618 return str; 619 } 620 621 bool QCameraHardwareInterface::getMaxPictureDimension(mm_camera_dimension_t *maxDim) 622 { 623 bool ret = NO_ERROR; 624 mm_camera_dimension_t dim; 625 626 ret = mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, 627 MM_CAMERA_PARM_MAX_PICTURE_SIZE, &dim); 628 if (ret != NO_ERROR) 629 return ret; 630 631 /* Find the first dimension in the mPictureSizes 632 * array which is smaller than the max dimension. 633 * This will be the valid max picture resolution */ 634 for (unsigned int i = 0; i < mPictureSizeCount; i++) { 635 if ((mPictureSizes[i].width <= dim.width) && 636 (mPictureSizes[i].height <= dim.height)) { 637 maxDim->height = mPictureSizes[i].height; 638 maxDim->width = mPictureSizes[i].width; 639 break; 640 } 641 } 642 ALOGD("%s: Found Max Picture dimension: %d x %d", __func__, 643 maxDim->width, maxDim->height); 644 return ret; 645 } 646 void QCameraHardwareInterface::loadTables() 647 { 648 649 bool ret = NO_ERROR; 650 ALOGV("%s: E", __func__); 651 652 ret = mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, 653 MM_CAMERA_PARM_PREVIEW_SIZES_CNT, &preview_sizes_count); 654 655 default_sizes_tbl_t preview_sizes_tbl; 656 preview_sizes_tbl.tbl_size=preview_sizes_count; 657 preview_sizes_tbl.sizes_tbl=&default_preview_sizes[0]; 658 if(mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, 659 MM_CAMERA_PARM_DEF_PREVIEW_SIZES, &preview_sizes_tbl)<0){ 660 ALOGE("%s:Failed to get default preview sizes",__func__); 661 } 662 ret = mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, 663 MM_CAMERA_PARM_VIDEO_SIZES_CNT, &video_sizes_count); 664 665 default_sizes_tbl_t video_sizes_tbl; 666 video_sizes_tbl.tbl_size=video_sizes_count; 667 video_sizes_tbl.sizes_tbl=&default_video_sizes[0]; 668 if(mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, 669 MM_CAMERA_PARM_DEF_VIDEO_SIZES, &video_sizes_tbl)<0){ 670 ALOGE("%s:Failed to get default video sizes",__func__); 671 } 672 673 ret = mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, 674 MM_CAMERA_PARM_THUMB_SIZES_CNT, &thumbnail_sizes_count); 675 676 default_sizes_tbl_t thumbnail_sizes_tbl; 677 thumbnail_sizes_tbl.tbl_size=thumbnail_sizes_count; 678 thumbnail_sizes_tbl.sizes_tbl=&default_thumbnail_sizes[0]; 679 if(mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, 680 MM_CAMERA_PARM_DEF_THUMB_SIZES, &thumbnail_sizes_tbl)<0){ 681 ALOGE("%s:Failed to get default thumbnail sizes",__func__); 682 } 683 684 ret = mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, 685 MM_CAMERA_PARM_HFR_SIZES_CNT, &hfr_sizes_count); 686 687 default_sizes_tbl_t hfr_sizes_tbl; 688 hfr_sizes_tbl.tbl_size=hfr_sizes_count; 689 hfr_sizes_tbl.sizes_tbl=&default_hfr_sizes[0]; 690 if(mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, 691 MM_CAMERA_PARM_DEF_HFR_SIZES, &hfr_sizes_tbl)<0){ 692 ALOGE("%s:Failed to get default HFR sizes",__func__); 693 } 694 ALOGE("%s: X", __func__); 695 } 696 void QCameraHardwareInterface::initDefaultParameters() 697 { 698 bool ret; 699 char prop[PROPERTY_VALUE_MAX]; 700 mm_camera_dimension_t maxDim; 701 int rc = 0; 702 ALOGI("%s: E", __func__); 703 uint8_t supported; 704 705 memset(&maxDim, 0, sizeof(mm_camera_dimension_t)); 706 ret = getMaxPictureDimension(&maxDim); 707 708 if (ret != NO_ERROR) { 709 ALOGE("%s: Cannot get Max picture size supported", __func__); 710 return; 711 } 712 if (!maxDim.width || !maxDim.height) { 713 maxDim.width = DEFAULT_LIVESHOT_WIDTH; 714 maxDim.height = DEFAULT_LIVESHOT_HEIGHT; 715 } 716 717 memset(prop, 0, sizeof(prop)); 718 property_get("persist.camera.snap.format", prop, "0"); 719 mSnapshotFormat = atoi(prop); 720 ALOGV("%s: prop =(%s), snap_format=%d", __func__, prop, mSnapshotFormat); 721 722 //cam_ctrl_dimension_t dim; 723 mHFRLevel = 0; 724 memset(&mDimension, 0, sizeof(cam_ctrl_dimension_t)); 725 memset(&mPreviewFormatInfo, 0, sizeof(preview_format_info_t)); 726 mDimension.video_width = DEFAULT_VIDEO_WIDTH; 727 mDimension.video_height = DEFAULT_VIDEO_HEIGHT; 728 mDimension.picture_width = maxDim.width; 729 mDimension.picture_height = maxDim.height; 730 mDimension.display_width = DEFAULT_STREAM_WIDTH; 731 mDimension.display_height = DEFAULT_STREAM_HEIGHT; 732 mDimension.orig_picture_dx = mDimension.picture_width; 733 mDimension.orig_picture_dy = mDimension.picture_height; 734 mDimension.ui_thumbnail_width = DEFAULT_STREAM_WIDTH; 735 mDimension.ui_thumbnail_height = DEFAULT_STREAM_HEIGHT; 736 mDimension.orig_video_width = DEFAULT_STREAM_WIDTH; 737 mDimension.orig_video_height = DEFAULT_STREAM_HEIGHT; 738 739 mDimension.prev_format = CAMERA_YUV_420_NV21; 740 mDimension.enc_format = CAMERA_YUV_420_NV12; 741 if (mSnapshotFormat == 1) { 742 mDimension.main_img_format = CAMERA_YUV_422_NV61; 743 } else { 744 mDimension.main_img_format = CAMERA_YUV_420_NV21; 745 } 746 mDimension.thumb_format = CAMERA_YUV_420_NV21; 747 ALOGV("%s: main_img_format =%d, thumb_format=%d", __func__, 748 mDimension.main_img_format, mDimension.thumb_format); 749 mDimension.prev_padding_format = CAMERA_PAD_TO_WORD; 750 751 ret = native_set_parms(MM_CAMERA_PARM_DIMENSION, 752 sizeof(cam_ctrl_dimension_t), (void *) &mDimension); 753 if(!ret) { 754 ALOGE("MM_CAMERA_PARM_DIMENSION Failed."); 755 return; 756 } 757 758 hasAutoFocusSupport(); 759 760 // Initialize constant parameter strings. This will happen only once in the 761 // lifetime of the mediaserver process. 762 if (true/*!mParamStringInitialized*/) { 763 //filter picture sizes 764 filterPictureSizes(); 765 mPictureSizeValues = create_sizes_str( 766 mPictureSizesPtr, mSupportedPictureSizesCount); 767 mPreviewSizeValues = create_sizes_str( 768 mPreviewSizes, mPreviewSizeCount); 769 mVideoSizeValues = create_sizes_str( 770 mVideoSizes, mVideoSizeCount); 771 772 //Query for max HFR value 773 camera_hfr_mode_t maxHFR; 774 mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, MM_CAMERA_PARM_MAX_HFR_MODE, (void *)&maxHFR); 775 //Filter HFR values and build parameter string 776 String8 str; 777 for(int i=0; i<HFR_VALUES_COUNT; i++){ 778 if(hfr[i].val <= maxHFR){ 779 if(i>0) str.append(","); 780 str.append(hfr[i].desc); 781 } 782 } 783 mHfrValues = str; 784 mHfrSizeValues = create_sizes_str( 785 default_hfr_sizes, hfr_sizes_count); 786 787 //Query for min and max fps values from lower layer 788 if(MM_CAMERA_OK != mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, 789 MM_CAMERA_PARM_FPS_RANGE, (void *)&mSensorFpsRange)){ 790 ALOGE("error: failed to get fps range from sensor"); 791 return; 792 } else { 793 ALOGD("sensor fps range = (%f, %f)", mSensorFpsRange.min_fps, 794 mSensorFpsRange.max_fps); 795 796 mSupportedFpsRanges = new android::FPSRange[ALL_FPS_RANGES_COUNT+1]; 797 798 //min and max fps in android format 799 int minFps = (int)(mSensorFpsRange.min_fps * 1000); 800 int maxFps = (int)(mSensorFpsRange.max_fps * 1000); 801 int idx=0; 802 //filter supported fps ranges according to sensor fps range 803 for(int i=0; i<(int)ALL_FPS_RANGES_COUNT; i++) { 804 if(allFpsRanges[i].maxFPS <= maxFps && allFpsRanges[i].minFPS >= minFps) { 805 memcpy(&mSupportedFpsRanges[idx], &allFpsRanges[i], sizeof(android::FPSRange)); 806 idx++; 807 } 808 } 809 mSupportedFpsRangesCount = idx; 810 //insert sensor absolute fps range as one entry, if 811 //its not already there in table 812 //find insertion point 813 int insertIndex = mSupportedFpsRangesCount; 814 for(int i=0; i<mSupportedFpsRangesCount; i++) { 815 if(mSupportedFpsRanges[i].maxFPS < maxFps) { 816 continue; 817 } else if (mSupportedFpsRanges[i].maxFPS == maxFps) { 818 if(mSupportedFpsRanges[i].minFPS > minFps) { 819 insertIndex = i; 820 break; 821 } else if (mSupportedFpsRanges[i].minFPS == minFps) { 822 //entry already exists, no need to insert 823 insertIndex = -1; 824 break; 825 } 826 } 827 } 828 if(insertIndex != -1) { 829 for(int i=mSupportedFpsRangesCount; i>=0; i--) { 830 if(insertIndex == i) { 831 mSupportedFpsRanges[i].maxFPS = maxFps; 832 mSupportedFpsRanges[i].minFPS = minFps; 833 mSupportedFpsRangesCount++; 834 break; 835 } 836 mSupportedFpsRanges[i].maxFPS = mSupportedFpsRanges[i-1].maxFPS; 837 mSupportedFpsRanges[i].minFPS = mSupportedFpsRanges[i-1].minFPS; 838 } 839 } 840 mFpsRangesSupportedValues = create_fps_str(mSupportedFpsRanges, mSupportedFpsRangesCount); 841 842 ALOGD("supported fps ranges = %s", mFpsRangesSupportedValues.string()); 843 mParameters.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FPS_RANGE, 844 mFpsRangesSupportedValues); 845 mParameters.setPreviewFpsRange(minFps, maxFps); 846 } 847 848 mFlashValues = create_values_str( 849 flash, sizeof(flash) / sizeof(str_map)); 850 mLensShadeValues = create_values_str( 851 lensshade,sizeof(lensshade)/sizeof(str_map)); 852 mMceValues = create_values_str( 853 mce,sizeof(mce)/sizeof(str_map)); 854 mEffectValues = create_values_str(effects, sizeof(effects) / sizeof(str_map)); 855 mAntibandingValues = create_values_str( 856 antibanding, sizeof(antibanding) / sizeof(str_map)); 857 mIsoValues = create_values_str(iso,sizeof(iso)/sizeof(str_map)); 858 mAutoExposureValues = create_values_str( 859 autoexposure, sizeof(autoexposure) / sizeof(str_map)); 860 mWhitebalanceValues = create_values_str( 861 whitebalance, sizeof(whitebalance) / sizeof(str_map)); 862 863 if(mHasAutoFocusSupport){ 864 mFocusModeValues = create_values_str( 865 focus_modes, sizeof(focus_modes) / sizeof(str_map)); 866 } 867 868 mSceneModeValues = create_values_str(scenemode, sizeof(scenemode) / sizeof(str_map)); 869 870 if(mHasAutoFocusSupport){ 871 mTouchAfAecValues = create_values_str( 872 touchafaec,sizeof(touchafaec)/sizeof(str_map)); 873 } 874 //Currently Enabling Histogram for 8x60 875 mHistogramValues = create_values_str( 876 histogram,sizeof(histogram)/sizeof(str_map)); 877 878 mSkinToneEnhancementValues = create_values_str( 879 skinToneEnhancement,sizeof(skinToneEnhancement)/sizeof(str_map)); 880 881 mPictureFormatValues = create_values_str( 882 picture_formats, sizeof(picture_formats)/sizeof(str_map)); 883 884 mZoomSupported=false; 885 mMaxZoom=0; 886 mm_camera_zoom_tbl_t zmt; 887 if( mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, 888 MM_CAMERA_PARM_MAXZOOM, &mMaxZoom)<0){ 889 ALOGE("%s:Failed to get max zoom",__func__); 890 }else{ 891 892 ALOGE("Max Zoom:%d",mMaxZoom); 893 /* Kernel driver limits the max amount of data that can be retreived through a control 894 command to 260 bytes hence we conservatively limit to 110 zoom ratios */ 895 if(mMaxZoom>MAX_ZOOM_RATIOS) { 896 ALOGE("%s:max zoom is larger than sizeof zoomRatios table",__func__); 897 mMaxZoom=MAX_ZOOM_RATIOS-1; 898 } 899 zmt.size=mMaxZoom; 900 zmt.zoom_ratio_tbl=&zoomRatios[0]; 901 if( mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, 902 MM_CAMERA_PARM_ZOOM_RATIO, &zmt)<0){ 903 ALOGE("%s:Failed to get max zoom ratios",__func__); 904 }else{ 905 mZoomSupported=true; 906 mZoomRatioValues = create_str(zoomRatios, mMaxZoom); 907 } 908 } 909 910 ALOGE("Zoom supported:%d",mZoomSupported); 911 912 denoise_value = create_values_str( 913 denoise, sizeof(denoise) / sizeof(str_map)); 914 915 if(supportsFaceDetection()) { 916 mFaceDetectionValues = create_values_str( 917 facedetection, sizeof(facedetection) / sizeof(str_map)); 918 } 919 920 if(mHasAutoFocusSupport){ 921 mSelectableZoneAfValues = create_values_str( 922 selectable_zone_af, sizeof(selectable_zone_af) / sizeof(str_map)); 923 } 924 925 mSceneDetectValues = create_values_str(scenedetect, sizeof(scenedetect) / sizeof(str_map)); 926 927 mRedeyeReductionValues = create_values_str( 928 redeye_reduction, sizeof(redeye_reduction) / sizeof(str_map)); 929 930 mZslValues = create_values_str( 931 zsl_modes,sizeof(zsl_modes)/sizeof(str_map)); 932 933 mParamStringInitialized = true; 934 } 935 936 //set supported video sizes 937 mParameters.set(QCameraParameters::KEY_SUPPORTED_VIDEO_SIZES, mVideoSizeValues.string()); 938 939 //set default video size to first one in supported table 940 String8 vSize = create_sizes_str(&mVideoSizes[0], 1); 941 mParameters.set(QCameraParameters::KEY_VIDEO_SIZE, vSize.string()); 942 943 //Set Preview size 944 int default_preview_width, default_preview_height; 945 mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, MM_CAMERA_PARM_DEFAULT_PREVIEW_WIDTH, 946 &default_preview_width); 947 mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, MM_CAMERA_PARM_DEFAULT_PREVIEW_HEIGHT, 948 &default_preview_height); 949 mParameters.setPreviewSize(default_preview_width, default_preview_height); 950 mParameters.set(QCameraParameters::KEY_SUPPORTED_PREVIEW_SIZES, 951 mPreviewSizeValues.string()); 952 mDimension.display_width = default_preview_width; 953 mDimension.display_height = default_preview_height; 954 955 mPreviewFrameRateValues = create_values_range_str( 956 MINIMUM_FPS, MAXIMUM_FPS); 957 958 959 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, MM_CAMERA_PARM_FPS,&supported,&supported); 960 if (supported) { 961 mParameters.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES, 962 mPreviewFrameRateValues.string()); 963 } else { 964 mParameters.set( 965 QCameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES, 966 DEFAULT_FIXED_FPS); 967 } 968 //Set Preview Format 969 //mParameters.setPreviewFormat("yuv420sp"); // informative 970 mParameters.setPreviewFormat(QCameraParameters::PIXEL_FORMAT_YUV420SP); 971 972 mPreviewFormatValues = create_values_str( 973 preview_formats, sizeof(preview_formats) / sizeof(str_map)); 974 mParameters.set(QCameraParameters::KEY_SUPPORTED_PREVIEW_FORMATS, 975 mPreviewFormatValues.string()); 976 977 //Set Overlay Format 978 mParameters.set("overlay-format", HAL_PIXEL_FORMAT_YCbCr_420_SP); 979 mParameters.set("max-num-detected-faces-hw", "2"); 980 981 // Set supported max faces 982 int maxNumFaces = 0; 983 if (supportsFaceDetection()) { 984 //Query the maximum number of faces supported by hardware. 985 if(MM_CAMERA_OK != mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, 986 MM_CAMERA_PARM_MAX_NUM_FACES_DECT, &maxNumFaces)){ 987 ALOGE("%s:Failed to get max number of faces supported",__func__); 988 } 989 } 990 mParameters.set(CameraParameters::KEY_MAX_NUM_DETECTED_FACES_HW, maxNumFaces); 991 //This paramtere is set to default here. This will be changed by application 992 //if it needs to support specific number of faces. See also setParameters. 993 mParameters.set(QCameraParameters::KEY_QC_MAX_NUM_REQUESTED_FACES, 2); 994 995 // Set camera features supported flag 996 int32_t featureFlag = 0; 997 if (supportsFaceDetection()) { 998 featureFlag |= 0x00000001; // bit 0 indicate faciral feature 999 } 1000 mParameters.set(QCameraParameters::KEY_QC_SUPPORTED_CAMERA_FEATURES, featureFlag); 1001 1002 //Set Picture Size 1003 mParameters.setPictureSize(DEFAULT_PICTURE_WIDTH, DEFAULT_PICTURE_HEIGHT); 1004 mParameters.set(QCameraParameters::KEY_SUPPORTED_PICTURE_SIZES, 1005 mPictureSizeValues.string()); 1006 1007 //Set Preview Frame Rate 1008 if(mFps >= MINIMUM_FPS && mFps <= MAXIMUM_FPS) { 1009 mParameters.setPreviewFrameRate(mFps); 1010 }else{ 1011 mParameters.setPreviewFrameRate(DEFAULT_FIXED_FPS); 1012 } 1013 1014 //Set Picture Format 1015 mParameters.setPictureFormat("jpeg"); // informative 1016 mParameters.set(QCameraParameters::KEY_SUPPORTED_PICTURE_FORMATS, 1017 mPictureFormatValues); 1018 1019 mParameters.set(QCameraParameters::KEY_JPEG_QUALITY, "85"); // max quality 1020 mJpegQuality = 85; 1021 //Set Video Format 1022 mParameters.set(QCameraParameters::KEY_VIDEO_FRAME_FORMAT, "yuv420sp"); 1023 1024 //Set Thumbnail parameters 1025 mParameters.set(QCameraParameters::KEY_JPEG_THUMBNAIL_WIDTH, 1026 THUMBNAIL_WIDTH_STR); // informative 1027 mParameters.set(QCameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT, 1028 THUMBNAIL_HEIGHT_STR); // informative 1029 mDimension.ui_thumbnail_width = 1030 thumbnail_sizes[DEFAULT_THUMBNAIL_SETTING].width; 1031 mDimension.ui_thumbnail_height = 1032 thumbnail_sizes[DEFAULT_THUMBNAIL_SETTING].height; 1033 mParameters.set(QCameraParameters::KEY_JPEG_THUMBNAIL_QUALITY, "90"); 1034 String8 valuesStr = create_sizes_str(default_thumbnail_sizes, thumbnail_sizes_count); 1035 mParameters.set(QCameraParameters::KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES, 1036 valuesStr.string()); 1037 // Define CAMERA_SMOOTH_ZOOM in Android.mk file , to enable smoothzoom 1038 #ifdef CAMERA_SMOOTH_ZOOM 1039 mParameters.set(QCameraParameters::KEY_SMOOTH_ZOOM_SUPPORTED, "true"); 1040 #endif 1041 if(mZoomSupported){ 1042 mParameters.set(QCameraParameters::KEY_ZOOM_SUPPORTED, "true"); 1043 ALOGE("max zoom is %d", mMaxZoom-1); 1044 /* mMaxZoom value that the query interface returns is the size 1045 ALOGV("max zoom is %d", mMaxZoom-1); 1046 * mMaxZoom value that the query interface returns is the size 1047 * of zoom table. So the actual max zoom value will be one 1048 * less than that value. */ 1049 1050 mParameters.set("max-zoom",mMaxZoom-1); 1051 mParameters.set(QCameraParameters::KEY_ZOOM_RATIOS, 1052 mZoomRatioValues); 1053 } else 1054 { 1055 mParameters.set(QCameraParameters::KEY_ZOOM_SUPPORTED, "false"); 1056 } 1057 1058 /* Enable zoom support for video application if VPE enabled */ 1059 if(mZoomSupported) { 1060 mParameters.set("video-zoom-support", "true"); 1061 } else { 1062 mParameters.set("video-zoom-support", "false"); 1063 } 1064 1065 //8960 supports Power modes : Low power, Normal Power. 1066 mParameters.set("power-mode-supported", "true"); 1067 //Set Live shot support 1068 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 1069 MM_CAMERA_PARM_LIVESHOT_MAIN, 1070 &supported,&supported); 1071 if(!supported) { 1072 ALOGE("%s:LIVESHOT is not supported", __func__); 1073 mParameters.set("video-snapshot-supported", "false"); 1074 mFullLiveshotEnabled = rc; 1075 } else { 1076 mParameters.set("video-snapshot-supported", "true"); 1077 } 1078 1079 //Set default power mode 1080 mParameters.set(QCameraParameters::KEY_QC_POWER_MODE,"Normal_Power"); 1081 1082 //Set Camera Mode 1083 mParameters.set(QCameraParameters::KEY_QC_CAMERA_MODE,0); 1084 mParameters.set(QCameraParameters::KEY_QC_AE_BRACKET_HDR,"Off"); 1085 1086 //Set Antibanding 1087 mParameters.set(QCameraParameters::KEY_ANTIBANDING, 1088 QCameraParameters::ANTIBANDING_OFF); 1089 mParameters.set(QCameraParameters::KEY_SUPPORTED_ANTIBANDING, 1090 mAntibandingValues); 1091 1092 //Set Effect 1093 mParameters.set(QCameraParameters::KEY_EFFECT, 1094 QCameraParameters::EFFECT_NONE); 1095 mParameters.set(QCameraParameters::KEY_SUPPORTED_EFFECTS, mEffectValues); 1096 1097 //Set Auto Exposure 1098 mParameters.set(QCameraParameters::KEY_QC_AUTO_EXPOSURE, 1099 QCameraParameters::AUTO_EXPOSURE_FRAME_AVG); 1100 mParameters.set(QCameraParameters::KEY_QC_SUPPORTED_AUTO_EXPOSURE, mAutoExposureValues); 1101 1102 //Set WhiteBalance 1103 mParameters.set(QCameraParameters::KEY_WHITE_BALANCE, 1104 QCameraParameters::WHITE_BALANCE_AUTO); 1105 mParameters.set(QCameraParameters::KEY_SUPPORTED_WHITE_BALANCE,mWhitebalanceValues); 1106 1107 //Set AEC_LOCK 1108 mParameters.set(CameraParameters::KEY_AUTO_EXPOSURE_LOCK, "false"); 1109 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 1110 MM_CAMERA_PARM_AEC_LOCK,&supported,&supported); 1111 if(supported){ 1112 mParameters.set(CameraParameters::KEY_AUTO_EXPOSURE_LOCK_SUPPORTED, "true"); 1113 } else { 1114 mParameters.set(QCameraParameters::KEY_AUTO_EXPOSURE_LOCK_SUPPORTED, "false"); 1115 } 1116 //Set AWB_LOCK 1117 mParameters.set(CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK, "false"); 1118 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 1119 MM_CAMERA_PARM_AWB_LOCK,&supported,&supported); 1120 if(supported) 1121 mParameters.set(CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK_SUPPORTED, "true"); 1122 else 1123 mParameters.set(QCameraParameters::KEY_AUTO_WHITEBALANCE_LOCK_SUPPORTED, "false"); 1124 1125 //Set Focus Mode 1126 if(mHasAutoFocusSupport){ 1127 mParameters.set(QCameraParameters::KEY_FOCUS_MODE, 1128 QCameraParameters::FOCUS_MODE_AUTO); 1129 mFocusMode = AF_MODE_AUTO; 1130 mParameters.set(QCameraParameters::KEY_SUPPORTED_FOCUS_MODES, 1131 mFocusModeValues); 1132 mParameters.set(QCameraParameters::KEY_MAX_NUM_FOCUS_AREAS, "1"); 1133 mParameters.set(QCameraParameters::KEY_MAX_NUM_METERING_AREAS, "1"); 1134 } else { 1135 mParameters.set(QCameraParameters::KEY_FOCUS_MODE, 1136 QCameraParameters::FOCUS_MODE_INFINITY); 1137 mFocusMode = DONT_CARE; 1138 mParameters.set(QCameraParameters::KEY_SUPPORTED_FOCUS_MODES, 1139 QCameraParameters::FOCUS_MODE_INFINITY); 1140 mParameters.set(QCameraParameters::KEY_MAX_NUM_FOCUS_AREAS, "0"); 1141 mParameters.set(QCameraParameters::KEY_MAX_NUM_METERING_AREAS, "0"); 1142 } 1143 1144 mParameters.set(QCameraParameters::KEY_FOCUS_AREAS, DEFAULT_CAMERA_AREA); 1145 mParameters.set(QCameraParameters::KEY_METERING_AREAS, DEFAULT_CAMERA_AREA); 1146 1147 //Set Flash 1148 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 1149 MM_CAMERA_PARM_LED_MODE,&supported,&supported); 1150 if(supported){ 1151 mParameters.set(CameraParameters::KEY_FLASH_MODE, 1152 CameraParameters::FLASH_MODE_OFF); 1153 mParameters.set(CameraParameters::KEY_SUPPORTED_FLASH_MODES, 1154 mFlashValues); 1155 } 1156 1157 //Set Sharpness 1158 mParameters.set(QCameraParameters::KEY_QC_MAX_SHARPNESS, 1159 CAMERA_MAX_SHARPNESS); 1160 mParameters.set(QCameraParameters::KEY_QC_SHARPNESS, 1161 CAMERA_DEF_SHARPNESS); 1162 1163 //Set Contrast 1164 mParameters.set(QCameraParameters::KEY_QC_MAX_CONTRAST, 1165 CAMERA_MAX_CONTRAST); 1166 mParameters.set(QCameraParameters::KEY_QC_CONTRAST, 1167 CAMERA_DEF_CONTRAST); 1168 1169 //Set Saturation 1170 mParameters.set(QCameraParameters::KEY_QC_MAX_SATURATION, 1171 CAMERA_MAX_SATURATION); 1172 mParameters.set(QCameraParameters::KEY_QC_SATURATION, 1173 CAMERA_DEF_SATURATION); 1174 1175 //Set Brightness/luma-adaptaion 1176 mParameters.set("luma-adaptation", "3"); 1177 1178 mParameters.set(QCameraParameters::KEY_PICTURE_FORMAT, 1179 QCameraParameters::PIXEL_FORMAT_JPEG); 1180 1181 //Set Lensshading 1182 mParameters.set(QCameraParameters::KEY_QC_LENSSHADE, 1183 QCameraParameters::LENSSHADE_ENABLE); 1184 mParameters.set(QCameraParameters::KEY_QC_SUPPORTED_LENSSHADE_MODES, 1185 mLensShadeValues); 1186 1187 //Set ISO Mode 1188 mParameters.set(QCameraParameters::KEY_QC_ISO_MODE, 1189 QCameraParameters::ISO_AUTO); 1190 mParameters.set(QCameraParameters::KEY_QC_SUPPORTED_ISO_MODES, 1191 mIsoValues); 1192 1193 //Set MCE 1194 mParameters.set(QCameraParameters::KEY_QC_MEMORY_COLOR_ENHANCEMENT, 1195 QCameraParameters::MCE_ENABLE); 1196 mParameters.set(QCameraParameters::KEY_QC_SUPPORTED_MEM_COLOR_ENHANCE_MODES, 1197 mMceValues); 1198 1199 //Set HFR 1200 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 1201 MM_CAMERA_PARM_HFR,&supported,&supported); 1202 if(supported){ 1203 mParameters.set(QCameraParameters::KEY_QC_VIDEO_HIGH_FRAME_RATE, 1204 QCameraParameters::VIDEO_HFR_OFF); 1205 mParameters.set(QCameraParameters::KEY_QC_SUPPORTED_HFR_SIZES, 1206 mHfrSizeValues.string()); 1207 mParameters.set(QCameraParameters::KEY_QC_SUPPORTED_VIDEO_HIGH_FRAME_RATE_MODES, 1208 mHfrValues); 1209 } else{ 1210 mParameters.set(QCameraParameters::KEY_QC_SUPPORTED_HFR_SIZES,""); 1211 } 1212 1213 //Set Histogram 1214 mParameters.set(QCameraParameters::KEY_QC_HISTOGRAM, 1215 QCameraParameters::HISTOGRAM_DISABLE); 1216 mParameters.set(QCameraParameters::KEY_QC_SUPPORTED_HISTOGRAM_MODES, 1217 mHistogramValues); 1218 1219 //Set SkinTone Enhancement 1220 mParameters.set(QCameraParameters::KEY_QC_SKIN_TONE_ENHANCEMENT, 1221 QCameraParameters::SKIN_TONE_ENHANCEMENT_DISABLE); 1222 mParameters.set("skinToneEnhancement", "0"); 1223 mParameters.set(QCameraParameters::KEY_QC_SUPPORTED_SKIN_TONE_ENHANCEMENT_MODES, 1224 mSkinToneEnhancementValues); 1225 1226 //Set Scene Mode 1227 mParameters.set(QCameraParameters::KEY_SCENE_MODE, 1228 QCameraParameters::SCENE_MODE_AUTO); 1229 mParameters.set(QCameraParameters::KEY_SUPPORTED_SCENE_MODES, 1230 mSceneModeValues); 1231 1232 //Set Streaming Textures 1233 mParameters.set("strtextures", "OFF"); 1234 1235 //Set Denoise 1236 mParameters.set(QCameraParameters::KEY_QC_DENOISE, 1237 QCameraParameters::DENOISE_OFF); 1238 mParameters.set(QCameraParameters::KEY_QC_SUPPORTED_DENOISE, 1239 denoise_value); 1240 //Set Touch AF/AEC 1241 mParameters.set(QCameraParameters::KEY_QC_TOUCH_AF_AEC, 1242 QCameraParameters::TOUCH_AF_AEC_OFF); 1243 mParameters.set(QCameraParameters::KEY_QC_SUPPORTED_TOUCH_AF_AEC, 1244 mTouchAfAecValues); 1245 mParameters.set("touchAfAec-dx","100"); 1246 mParameters.set("touchAfAec-dy","100"); 1247 1248 //Set Scene Detection 1249 mParameters.set(QCameraParameters::KEY_QC_SCENE_DETECT, 1250 QCameraParameters::SCENE_DETECT_OFF); 1251 mParameters.set(QCameraParameters::KEY_QC_SUPPORTED_SCENE_DETECT, 1252 mSceneDetectValues); 1253 1254 //Set Selectable Zone AF 1255 mParameters.set(QCameraParameters::KEY_QC_SELECTABLE_ZONE_AF, 1256 QCameraParameters::SELECTABLE_ZONE_AF_AUTO); 1257 mParameters.set(QCameraParameters::KEY_QC_SUPPORTED_SELECTABLE_ZONE_AF, 1258 mSelectableZoneAfValues); 1259 1260 //Set Face Detection 1261 mParameters.set(QCameraParameters::KEY_QC_FACE_DETECTION, 1262 QCameraParameters::FACE_DETECTION_OFF); 1263 mParameters.set(QCameraParameters::KEY_QC_SUPPORTED_FACE_DETECTION, 1264 mFaceDetectionValues); 1265 1266 //Set Red Eye Reduction 1267 mParameters.set(QCameraParameters::KEY_QC_REDEYE_REDUCTION, 1268 QCameraParameters::REDEYE_REDUCTION_DISABLE); 1269 mParameters.set(QCameraParameters::KEY_QC_SUPPORTED_REDEYE_REDUCTION, 1270 mRedeyeReductionValues); 1271 1272 //Set ZSL 1273 mParameters.set(QCameraParameters::KEY_QC_ZSL, 1274 QCameraParameters::ZSL_OFF); 1275 mParameters.set(QCameraParameters::KEY_QC_SUPPORTED_ZSL_MODES, 1276 mZslValues); 1277 1278 //Set Focal length, horizontal and vertical view angles 1279 float focalLength = 0.0f; 1280 float horizontalViewAngle = 0.0f; 1281 float verticalViewAngle = 0.0f; 1282 mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, MM_CAMERA_PARM_FOCAL_LENGTH, 1283 (void *)&focalLength); 1284 mParameters.setFloat(QCameraParameters::KEY_FOCAL_LENGTH, 1285 focalLength); 1286 mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, MM_CAMERA_PARM_HORIZONTAL_VIEW_ANGLE, 1287 (void *)&horizontalViewAngle); 1288 mParameters.setFloat(QCameraParameters::KEY_HORIZONTAL_VIEW_ANGLE, 1289 horizontalViewAngle); 1290 mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, MM_CAMERA_PARM_VERTICAL_VIEW_ANGLE, 1291 (void *)&verticalViewAngle); 1292 mParameters.setFloat(QCameraParameters::KEY_VERTICAL_VIEW_ANGLE, 1293 verticalViewAngle); 1294 1295 //Set Exposure Compensation 1296 mParameters.set( 1297 QCameraParameters::KEY_MAX_EXPOSURE_COMPENSATION, 1298 EXPOSURE_COMPENSATION_MAXIMUM_NUMERATOR); 1299 mParameters.set( 1300 QCameraParameters::KEY_MIN_EXPOSURE_COMPENSATION, 1301 EXPOSURE_COMPENSATION_MINIMUM_NUMERATOR); 1302 mParameters.set( 1303 QCameraParameters::KEY_EXPOSURE_COMPENSATION, 1304 EXPOSURE_COMPENSATION_DEFAULT_NUMERATOR); 1305 mParameters.setFloat( 1306 QCameraParameters::KEY_EXPOSURE_COMPENSATION_STEP, 1307 EXPOSURE_COMPENSATION_STEP); 1308 1309 mParameters.set("num-snaps-per-shutter", 1); 1310 1311 mParameters.set("capture-burst-captures-values", getZSLQueueDepth()); 1312 mParameters.set("capture-burst-interval-supported", "true"); 1313 mParameters.set("capture-burst-interval-max", BURST_INTREVAL_MAX); /*skip frames*/ 1314 mParameters.set("capture-burst-interval-min", BURST_INTREVAL_MIN); /*skip frames*/ 1315 mParameters.set("capture-burst-interval", BURST_INTREVAL_DEFAULT); /*skip frames*/ 1316 mParameters.set("capture-burst-retroactive", 0); 1317 mParameters.set("capture-burst-retroactive-max", getZSLQueueDepth()); 1318 mParameters.set("capture-burst-exposures", ""); 1319 mParameters.set("capture-burst-exposures-values", 1320 "-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10,11,12"); 1321 { 1322 String8 CamModeStr; 1323 char buffer[32]; 1324 int flag = 0; 1325 1326 for (int i = 0; i < HAL_CAM_MODE_MAX; i++) { 1327 if ( 0 ) { /*exclude some conflicting case*/ 1328 } else { 1329 if (flag == 0) { /*first item*/ 1330 snprintf(buffer, sizeof(buffer), "%d", i); 1331 } else { 1332 snprintf(buffer, sizeof(buffer), ",%d", i); 1333 } 1334 flag = 1; 1335 CamModeStr.append(buffer); 1336 } 1337 } 1338 mParameters.set("camera-mode-values", CamModeStr); 1339 } 1340 1341 mParameters.set("ae-bracket-hdr-values", 1342 create_values_str(hdr_bracket, sizeof(hdr_bracket)/sizeof(str_map) )); 1343 1344 mParameters.set("no-display-mode", 0); 1345 mParameters.set("zoom", 0); 1346 1347 int mNuberOfVFEOutputs; 1348 ret = mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, 1349 MM_CAMERA_PARM_VFE_OUTPUT_ENABLE, &mNuberOfVFEOutputs); 1350 if(ret < 0) { 1351 ALOGE("get parm MM_CAMERA_PARM_VFE_OUTPUT_ENABLE failed"); 1352 ret = BAD_VALUE; 1353 } 1354 if(mNuberOfVFEOutputs == 1) 1355 { 1356 mParameters.set(QCameraParameters::KEY_QC_SINGLE_ISP_OUTPUT_ENABLED, "true"); 1357 } else { 1358 mParameters.set(QCameraParameters::KEY_QC_SINGLE_ISP_OUTPUT_ENABLED, "false"); 1359 } 1360 1361 if (setParameters(mParameters) != NO_ERROR) { 1362 ALOGE("Failed to set default parameters?!"); 1363 } 1364 mInitialized = true; 1365 strTexturesOn = false; 1366 1367 ALOGI("%s: X", __func__); 1368 return; 1369 } 1370 1371 /** 1372 * Set the camera parameters. This returns BAD_VALUE if any parameter is 1373 * invalid or not supported. 1374 */ 1375 1376 int QCameraHardwareInterface::setParameters(const char *parms) 1377 { 1378 QCameraParameters param; 1379 String8 str = String8(parms); 1380 param.unflatten(str); 1381 status_t ret = setParameters(param); 1382 if(ret == NO_ERROR) 1383 return 0; 1384 else 1385 return -1; 1386 } 1387 1388 /** 1389 * Set the camera parameters. This returns BAD_VALUE if any parameter is 1390 * invalid or not supported. */ 1391 status_t QCameraHardwareInterface::setParameters(const QCameraParameters& params) 1392 { 1393 status_t ret = NO_ERROR; 1394 1395 ALOGI("%s: E", __func__); 1396 // Mutex::Autolock l(&mLock); 1397 status_t rc, final_rc = NO_ERROR; 1398 mRestartPreview = false; 1399 1400 if ((rc = setCameraMode(params))) final_rc = rc; 1401 // if ((rc = setChannelInterfaceMask(params))) final_rc = rc; 1402 if ((rc = setPowerMode(params))) final_rc = rc; 1403 if ((rc = setPreviewSize(params))) final_rc = rc; 1404 if ((rc = setVideoSize(params))) final_rc = rc; 1405 if ((rc = setPictureSize(params))) final_rc = rc; 1406 if ((rc = setJpegThumbnailSize(params))) final_rc = rc; 1407 if ((rc = setJpegQuality(params))) final_rc = rc; 1408 if ((rc = setEffect(params))) final_rc = rc; 1409 if ((rc = setGpsLocation(params))) final_rc = rc; 1410 if ((rc = setRotation(params))) final_rc = rc; 1411 if ((rc = setZoom(params))) final_rc = rc; 1412 if ((rc = setOrientation(params))) final_rc = rc; 1413 if ((rc = setLensshadeValue(params))) final_rc = rc; 1414 if ((rc = setMCEValue(params))) final_rc = rc; 1415 if ((rc = setPictureFormat(params))) final_rc = rc; 1416 if ((rc = setSharpness(params))) final_rc = rc; 1417 if ((rc = setSaturation(params))) final_rc = rc; 1418 if ((rc = setSceneMode(params))) final_rc = rc; 1419 if ((rc = setContrast(params))) final_rc = rc; 1420 if ((rc = setFaceDetect(params))) final_rc = rc; 1421 if ((rc = setStrTextures(params))) final_rc = rc; 1422 if ((rc = setPreviewFormat(params))) final_rc = rc; 1423 if ((rc = setSkinToneEnhancement(params))) final_rc = rc; 1424 if ((rc = setWaveletDenoise(params))) final_rc = rc; 1425 if ((rc = setAntibanding(params))) final_rc = rc; 1426 // if ((rc = setOverlayFormats(params))) final_rc = rc; 1427 if ((rc = setRedeyeReduction(params))) final_rc = rc; 1428 if ((rc = setCaptureBurstExp())) final_rc = rc; 1429 if ((rc = setRDIMode(params))) final_rc = rc; 1430 1431 const char *str_val = params.get("capture-burst-exposures"); 1432 if ( str_val == NULL || strlen(str_val)==0 ) { 1433 char burst_exp[PROPERTY_VALUE_MAX]; 1434 memset(burst_exp, 0, sizeof(burst_exp)); 1435 property_get("persist.capture.burst.exposures", burst_exp, ""); 1436 if ( strlen(burst_exp)>0 ) { 1437 mParameters.set("capture-burst-exposures", burst_exp); 1438 } 1439 } else { 1440 mParameters.set("capture-burst-exposures", str_val); 1441 } 1442 mParameters.set("num-snaps-per-shutter", params.get("num-snaps-per-shutter")); 1443 1444 if ((rc = setAEBracket(params))) final_rc = rc; 1445 // if ((rc = setDenoise(params))) final_rc = rc; 1446 if ((rc = setPreviewFpsRange(params))) final_rc = rc; 1447 if((rc = setRecordingHint(params))) final_rc = rc; 1448 if ((rc = setNumOfSnapshot(params))) final_rc = rc; 1449 if ((rc = setAecAwbLock(params))) final_rc = rc; 1450 1451 const char *str = params.get(QCameraParameters::KEY_SCENE_MODE); 1452 int32_t value = attr_lookup(scenemode, sizeof(scenemode) / sizeof(str_map), str); 1453 1454 if((value != NOT_FOUND) && (value == CAMERA_BESTSHOT_OFF )) { 1455 //if ((rc = setPreviewFrameRateMode(params))) final_rc = rc; 1456 if ((rc = setPreviewFrameRate(params))) final_rc = rc; 1457 if ((rc = setAutoExposure(params))) final_rc = rc; 1458 if ((rc = setExposureCompensation(params))) final_rc = rc; 1459 if ((rc = setWhiteBalance(params))) final_rc = rc; 1460 if ((rc = setFlash(params))) final_rc = rc; 1461 if ((rc = setFocusMode(params))) final_rc = rc; 1462 if ((rc = setBrightness(params))) final_rc = rc; 1463 if ((rc = setISOValue(params))) final_rc = rc; 1464 if ((rc = setFocusAreas(params))) final_rc = rc; 1465 if ((rc = setMeteringAreas(params))) final_rc = rc; 1466 } 1467 //selectableZoneAF needs to be invoked after continuous AF 1468 if ((rc = setSelectableZoneAf(params))) final_rc = rc; 1469 // setHighFrameRate needs to be done at end, as there can 1470 // be a preview restart, and need to use the updated parameters 1471 if ((rc = setHighFrameRate(params))) final_rc = rc; 1472 if ((rc = setZSLBurstLookBack(params))) final_rc = rc; 1473 if ((rc = setZSLBurstInterval(params))) final_rc = rc; 1474 if ((rc = setNoDisplayMode(params))) final_rc = rc; 1475 if ((rc = setMobiCat(params))) final_rc = rc; 1476 1477 //Update Exiftag values. 1478 setExifTags(); 1479 1480 if (mRestartPreview) { 1481 ALOGI("%s: need to restart preview", __func__); 1482 restartPreview(); 1483 mRestartPreview = false; 1484 } 1485 1486 ALOGI("%s: X", __func__); 1487 return final_rc; 1488 } 1489 1490 /** Retrieve the camera parameters. The buffer returned by the camera HAL 1491 must be returned back to it with put_parameters, if put_parameters 1492 is not NULL. 1493 */ 1494 int QCameraHardwareInterface::getParameters(char **parms) 1495 { 1496 char* rc = NULL; 1497 String8 str; 1498 QCameraParameters param = getParameters(); 1499 //param.dump(); 1500 str = param.flatten( ); 1501 rc = (char *)malloc(sizeof(char)*(str.length()+1)); 1502 if(rc != NULL){ 1503 memset(rc, 0, sizeof(char)*(str.length()+1)); 1504 strncpy(rc, str.string(), str.length()); 1505 rc[str.length()] = 0; 1506 *parms = rc; 1507 } 1508 return 0; 1509 } 1510 1511 /** The camera HAL uses its own memory to pass us the parameters when we 1512 call get_parameters. Use this function to return the memory back to 1513 the camera HAL, if put_parameters is not NULL. If put_parameters 1514 is NULL, then you have to use free() to release the memory. 1515 */ 1516 void QCameraHardwareInterface::putParameters(char *rc) 1517 { 1518 free(rc); 1519 rc = NULL; 1520 } 1521 1522 QCameraParameters& QCameraHardwareInterface::getParameters() 1523 { 1524 Mutex::Autolock lock(mLock); 1525 mParameters.set(QCameraParameters::KEY_FOCUS_DISTANCES, mFocusDistance.string()); 1526 return mParameters; 1527 } 1528 1529 status_t QCameraHardwareInterface::runFaceDetection() 1530 { 1531 bool ret = true; 1532 1533 const char *str = mParameters.get(QCameraParameters::KEY_QC_FACE_DETECTION); 1534 if (str != NULL) { 1535 int value = attr_lookup(facedetection, 1536 sizeof(facedetection) / sizeof(str_map), str); 1537 fd_set_parm_t fd_set_parm; 1538 int requested_faces = mParameters.getInt(QCameraParameters::KEY_QC_MAX_NUM_REQUESTED_FACES); 1539 fd_set_parm.fd_mode = value; 1540 fd_set_parm.num_fd = requested_faces; 1541 ret = native_set_parms(MM_CAMERA_PARM_FD, sizeof(int8_t), (void *)&value); 1542 return ret ? NO_ERROR : UNKNOWN_ERROR; 1543 } 1544 ALOGE("Invalid Face Detection value: %s", (str == NULL) ? "NULL" : str); 1545 return BAD_VALUE; 1546 } 1547 1548 status_t QCameraHardwareInterface::setSharpness(const QCameraParameters& params) 1549 { 1550 bool ret = false; 1551 int rc = MM_CAMERA_OK; 1552 ALOGV("%s",__func__); 1553 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 1554 MM_CAMERA_PARM_SHARPNESS,(uint8_t*)&rc,(uint8_t*)&rc); 1555 if(!rc) { 1556 ALOGE("%s:CONTRAST not supported", __func__); 1557 return NO_ERROR; 1558 } 1559 int sharpness = params.getInt(QCameraParameters::KEY_QC_SHARPNESS); 1560 if((sharpness < CAMERA_MIN_SHARPNESS 1561 || sharpness > CAMERA_MAX_SHARPNESS)) 1562 return UNKNOWN_ERROR; 1563 1564 ALOGV("setting sharpness %d", sharpness); 1565 mParameters.set(QCameraParameters::KEY_QC_SHARPNESS, sharpness); 1566 ret = native_set_parms(MM_CAMERA_PARM_SHARPNESS, sizeof(sharpness), 1567 (void *)&sharpness); 1568 return ret ? NO_ERROR : UNKNOWN_ERROR; 1569 } 1570 1571 status_t QCameraHardwareInterface::setSaturation(const QCameraParameters& params) 1572 { 1573 bool ret = false; 1574 int rc = MM_CAMERA_OK; 1575 ALOGV("%s",__func__); 1576 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 1577 MM_CAMERA_PARM_SATURATION,(uint8_t*)&rc,(uint8_t*)&rc); 1578 if(!rc) { 1579 ALOGE("%s:MM_CAMERA_PARM_SATURATION not supported", __func__); 1580 return NO_ERROR; 1581 } 1582 int result; 1583 int saturation = params.getInt(QCameraParameters::KEY_QC_SATURATION); 1584 1585 if((saturation < CAMERA_MIN_SATURATION) 1586 || (saturation > CAMERA_MAX_SATURATION)) 1587 return UNKNOWN_ERROR; 1588 1589 ALOGV("Setting saturation %d", saturation); 1590 mParameters.set(QCameraParameters::KEY_QC_SATURATION, saturation); 1591 ret = native_set_parms(MM_CAMERA_PARM_SATURATION, sizeof(saturation), 1592 (void *)&saturation, (int *)&result); 1593 if(result != MM_CAMERA_OK) 1594 ALOGI("Saturation Value: %d is not set as the selected value is not supported", saturation); 1595 return ret ? NO_ERROR : UNKNOWN_ERROR; 1596 } 1597 1598 status_t QCameraHardwareInterface::setContrast(const QCameraParameters& params) 1599 { 1600 ALOGV("%s E", __func__ ); 1601 int rc = MM_CAMERA_OK; 1602 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 1603 MM_CAMERA_PARM_CONTRAST,(uint8_t*)&rc,(uint8_t*)&rc); 1604 if(!rc) { 1605 ALOGE("%s:CONTRAST not supported", __func__); 1606 return NO_ERROR; 1607 } 1608 const char *str = params.get(QCameraParameters::KEY_SCENE_MODE); 1609 ALOGE("Contrast : %s",str); 1610 int32_t value = attr_lookup(scenemode, sizeof(scenemode) / sizeof(str_map), str); 1611 if(value == CAMERA_BESTSHOT_OFF) { 1612 int contrast = params.getInt(QCameraParameters::KEY_QC_CONTRAST); 1613 if((contrast < CAMERA_MIN_CONTRAST) 1614 || (contrast > CAMERA_MAX_CONTRAST)) 1615 { 1616 ALOGE("Contrast Value not matching"); 1617 return UNKNOWN_ERROR; 1618 } 1619 ALOGV("setting contrast %d", contrast); 1620 mParameters.set(QCameraParameters::KEY_QC_CONTRAST, contrast); 1621 ALOGE("Calling Contrast set on Lower layer"); 1622 bool ret = native_set_parms(MM_CAMERA_PARM_CONTRAST, sizeof(contrast), 1623 (void *)&contrast); 1624 ALOGE("Lower layer returned %d", ret); 1625 int bestshot_reconfigure; 1626 mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, 1627 MM_CAMERA_PARM_BESTSHOT_RECONFIGURE, 1628 &bestshot_reconfigure); 1629 if(bestshot_reconfigure) { 1630 if (mContrast != contrast) { 1631 mContrast = contrast; 1632 if (mPreviewState == QCAMERA_HAL_PREVIEW_STARTED && ret) { 1633 mRestartPreview = true; 1634 } 1635 } 1636 } 1637 return ret ? NO_ERROR : UNKNOWN_ERROR; 1638 } else { 1639 ALOGI(" Contrast value will not be set " \ 1640 "when the scenemode selected is %s", str); 1641 return NO_ERROR; 1642 } 1643 return BAD_VALUE; 1644 } 1645 1646 status_t QCameraHardwareInterface::setSceneDetect(const QCameraParameters& params) 1647 { 1648 ALOGV("%s",__func__); 1649 bool retParm; 1650 int rc = 0; 1651 1652 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 1653 MM_CAMERA_PARM_ASD_ENABLE,(uint8_t*)&rc,(uint8_t*)&rc); 1654 if(!rc) { 1655 ALOGE("%s:MM_CAMERA_PARM_ASD_ENABLE not supported", __func__); 1656 return NO_ERROR; 1657 } 1658 1659 const char *str = params.get(QCameraParameters::KEY_QC_SCENE_DETECT); 1660 ALOGE("Scene Detect string : %s",str); 1661 if (str != NULL) { 1662 int32_t value = attr_lookup(scenedetect, sizeof(scenedetect) / sizeof(str_map), str); 1663 ALOGE("Scenedetect Value : %d",value); 1664 if (value != NOT_FOUND) { 1665 mParameters.set(QCameraParameters::KEY_QC_SCENE_DETECT, str); 1666 1667 retParm = native_set_parms(MM_CAMERA_PARM_ASD_ENABLE, sizeof(value), 1668 (void *)&value); 1669 1670 return retParm ? NO_ERROR : UNKNOWN_ERROR; 1671 } 1672 } 1673 return BAD_VALUE; 1674 } 1675 1676 status_t QCameraHardwareInterface::setZoom(const QCameraParameters& params) 1677 { 1678 status_t rc = NO_ERROR; 1679 1680 ALOGV("%s: E",__func__); 1681 uint8_t supported; 1682 1683 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 1684 MM_CAMERA_PARM_ZOOM,&supported,&supported); 1685 if(!supported){ 1686 ALOGE("%s:MM_CAMERA_PARM_ZOOM not supported", __func__); 1687 return NO_ERROR; 1688 } 1689 // No matter how many different zoom values the driver can provide, HAL 1690 // provides applictations the same number of zoom levels. The maximum driver 1691 // zoom value depends on sensor output (VFE input) and preview size (VFE 1692 // output) because VFE can only crop and cannot upscale. If the preview size 1693 // is bigger, the maximum zoom ratio is smaller. However, we want the 1694 // zoom ratio of each zoom level is always the same whatever the preview 1695 // size is. Ex: zoom level 1 is always 1.2x, zoom level 2 is 1.44x, etc. So, 1696 // we need to have a fixed maximum zoom value and do read it from the 1697 // driver. 1698 static const int ZOOM_STEP = 1; 1699 int32_t zoom_level = params.getInt("zoom"); 1700 if(zoom_level >= 0 && zoom_level <= mMaxZoom-1) { 1701 mParameters.set("zoom", zoom_level); 1702 int32_t zoom_value = ZOOM_STEP * zoom_level; 1703 bool ret = native_set_parms(MM_CAMERA_PARM_ZOOM, 1704 sizeof(zoom_value), (void *)&zoom_value); 1705 if(ret) { 1706 mCurrentZoom=zoom_level; 1707 } 1708 rc = ret ? NO_ERROR : UNKNOWN_ERROR; 1709 } else { 1710 rc = BAD_VALUE; 1711 } 1712 ALOGV("%s X",__func__); 1713 return rc; 1714 1715 } 1716 1717 status_t QCameraHardwareInterface::setISOValue(const QCameraParameters& params) { 1718 1719 ALOGV("%s",__func__); 1720 uint8_t supported; 1721 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 1722 MM_CAMERA_PARM_ISO,&supported,&supported); 1723 if(!supported) { 1724 ALOGE("%s:MM_CAMERA_PARM_ISO not supported", __func__); 1725 return NO_ERROR; 1726 } 1727 const char *str = params.get(QCameraParameters::KEY_QC_ISO_MODE); 1728 ALOGV("ISO string : %s",str); 1729 int8_t temp_hjr; 1730 if (str != NULL) { 1731 int value = (camera_iso_mode_type)attr_lookup( 1732 iso, sizeof(iso) / sizeof(str_map), str); 1733 ALOGE("ISO Value : %d",value); 1734 if (value != NOT_FOUND) { 1735 camera_iso_mode_type temp = (camera_iso_mode_type) value; 1736 if (value == CAMERA_ISO_DEBLUR) { 1737 temp_hjr = true; 1738 native_set_parms(MM_CAMERA_PARM_HJR, sizeof(int8_t), (void*)&temp_hjr); 1739 mHJR = value; 1740 } 1741 else { 1742 if (mHJR == CAMERA_ISO_DEBLUR) { 1743 temp_hjr = false; 1744 native_set_parms(MM_CAMERA_PARM_HJR, sizeof(int8_t), (void*)&temp_hjr); 1745 mHJR = value; 1746 } 1747 } 1748 1749 mParameters.set(QCameraParameters::KEY_QC_ISO_MODE, str); 1750 native_set_parms(MM_CAMERA_PARM_ISO, sizeof(camera_iso_mode_type), (void *)&temp); 1751 return NO_ERROR; 1752 } 1753 } 1754 return BAD_VALUE; 1755 } 1756 1757 status_t QCameraHardwareInterface::updateFocusDistances() 1758 { 1759 ALOGV("%s: IN", __FUNCTION__); 1760 focus_distances_info_t focusDistances; 1761 if(mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, MM_CAMERA_PARM_FOCUS_DISTANCES, 1762 &focusDistances) >= 0) { 1763 String8 str; 1764 char buffer[32] = {0}; 1765 //set all distances to infinity if focus mode is infinity 1766 if(mFocusMode == AF_MODE_INFINITY) { 1767 snprintf(buffer, sizeof(buffer), "Infinity,"); 1768 str.append(buffer); 1769 snprintf(buffer, sizeof(buffer), "Infinity,"); 1770 str.append(buffer); 1771 snprintf(buffer, sizeof(buffer), "Infinity"); 1772 str.append(buffer); 1773 } else { 1774 snprintf(buffer, sizeof(buffer), "%f", focusDistances.focus_distance[0]); 1775 str.append(buffer); 1776 snprintf(buffer, sizeof(buffer), ",%f", focusDistances.focus_distance[1]); 1777 str.append(buffer); 1778 snprintf(buffer, sizeof(buffer), ",%f", focusDistances.focus_distance[2]); 1779 str.append(buffer); 1780 } 1781 ALOGE("%s: setting KEY_FOCUS_DISTANCES as %s", __FUNCTION__, str.string()); 1782 mFocusDistance = str; 1783 return NO_ERROR; 1784 } 1785 ALOGV("%s: get CAMERA_PARM_FOCUS_DISTANCES failed!!!", __FUNCTION__); 1786 return BAD_VALUE; 1787 } 1788 1789 // Parse string like "(1, 2, 3, 4, ..., N)" 1790 // num is pointer to an allocated array of size N 1791 static int parseNDimVector(const char *str, int *num, int N, char delim = ',') 1792 { 1793 char *start, *end; 1794 if(num == NULL) { 1795 ALOGE("Invalid output array (num == NULL)"); 1796 return -1; 1797 } 1798 //check if string starts and ends with parantheses 1799 if(str[0] != '(' || str[strlen(str)-1] != ')') { 1800 ALOGE("Invalid format of string %s, valid format is (n1, n2, n3, n4 ...)", str); 1801 return -1; 1802 } 1803 start = (char*) str; 1804 start++; 1805 for(int i=0; i<N; i++) { 1806 *(num+i) = (int) strtol(start, &end, 10); 1807 if(*end != delim && i < N-1) { 1808 ALOGE("Cannot find delimeter '%c' in string \"%s\". end = %c", delim, str, *end); 1809 return -1; 1810 } 1811 start = end+1; 1812 } 1813 return 0; 1814 } 1815 1816 // parse string like "(1, 2, 3, 4, 5),(1, 2, 3, 4, 5),..." 1817 static int parseCameraAreaString(const char* str, int max_num_areas, 1818 camera_area_t *pAreas, int *num_areas_found) 1819 { 1820 char area_str[32]; 1821 const char *start, *end, *p; 1822 start = str; end = NULL; 1823 int values[5], index=0; 1824 *num_areas_found = 0; 1825 1826 while(start != NULL) { 1827 if(*start != '(') { 1828 ALOGE("%s: error: Ill formatted area string: %s", __func__, str); 1829 return -1; 1830 } 1831 end = strchr(start, ')'); 1832 if(end == NULL) { 1833 ALOGE("%s: error: Ill formatted area string: %s", __func__, str); 1834 return -1; 1835 } 1836 int i; 1837 for (i=0,p=start; p<=end; p++, i++) { 1838 area_str[i] = *p; 1839 } 1840 area_str[i] = '\0'; 1841 if(parseNDimVector(area_str, values, 5) < 0){ 1842 ALOGE("%s: error: Failed to parse the area string: %s", __func__, area_str); 1843 return -1; 1844 } 1845 // no more areas than max_num_areas are accepted. 1846 if(index >= max_num_areas) { 1847 ALOGE("%s: error: too many areas specified %s", __func__, str); 1848 return -1; 1849 } 1850 pAreas[index].x1 = values[0]; 1851 pAreas[index].y1 = values[1]; 1852 pAreas[index].x2 = values[2]; 1853 pAreas[index].y2 = values[3]; 1854 pAreas[index].weight = values[4]; 1855 1856 index++; 1857 start = strchr(end, '('); // serach for next '(' 1858 } 1859 (*num_areas_found) = index; 1860 return 0; 1861 } 1862 static bool validateCameraAreas(camera_area_t *areas, int num_areas) 1863 { 1864 for(int i=0; i<num_areas; i++) { 1865 1866 // handle special case (0, 0, 0, 0, 0) 1867 if((areas[i].x1 == 0) && (areas[i].y1 == 0) 1868 && (areas[i].x2 == 0) && (areas[i].y2 == 0) && (areas[i].weight == 0)) { 1869 continue; 1870 } 1871 if(areas[i].x1 < -1000) return false; // left should be >= -1000 1872 if(areas[i].y1 < -1000) return false; // top should be >= -1000 1873 if(areas[i].x2 > 1000) return false; // right should be <= 1000 1874 if(areas[i].y2 > 1000) return false; // bottom should be <= 1000 1875 if(areas[i].weight <= 0 || areas[i].weight > 1000) // weight should be in [1, 1000] 1876 return false; 1877 if(areas[i].x1 >= areas[i].x2) { // left should be < right 1878 return false; 1879 } 1880 if(areas[i].y1 >= areas[i].y2) // top should be < bottom 1881 return false; 1882 } 1883 return true; 1884 } 1885 1886 status_t QCameraHardwareInterface::setFocusAreas(const QCameraParameters& params) 1887 { 1888 ALOGV("%s: E", __func__); 1889 status_t rc; 1890 int max_num_af_areas = mParameters.getInt(QCameraParameters::KEY_MAX_NUM_FOCUS_AREAS); 1891 if(max_num_af_areas == 0) { 1892 return NO_ERROR; 1893 } 1894 const char *str = params.get(QCameraParameters::KEY_FOCUS_AREAS); 1895 if (str == NULL) { 1896 ALOGE("%s: Parameter string is null", __func__); 1897 rc = NO_ERROR; 1898 } else { 1899 camera_area_t *areas = new camera_area_t[max_num_af_areas]; 1900 int num_areas_found=0; 1901 if(parseCameraAreaString(str, max_num_af_areas, areas, &num_areas_found) < 0) { 1902 ALOGE("%s: Failed to parse the string: %s", __func__, str); 1903 delete areas; 1904 return BAD_VALUE; 1905 } 1906 for(int i=0; i<num_areas_found; i++) { 1907 ALOGD("FocusArea[%d] = (%d, %d, %d, %d, %d)", i, (areas[i].x1), (areas[i].y1), 1908 (areas[i].x2), (areas[i].y2), (areas[i].weight)); 1909 } 1910 if(validateCameraAreas(areas, num_areas_found) == false) { 1911 ALOGE("%s: invalid areas specified : %s", __func__, str); 1912 delete areas; 1913 return BAD_VALUE; 1914 } 1915 mParameters.set(QCameraParameters::KEY_FOCUS_AREAS, str); 1916 num_areas_found = 1; //temp; need to change after the multi-roi is enabled 1917 1918 //if the native_set_parms is called when preview is not started, it 1919 //crashes in lower layer, so return of preview is not started 1920 if(mPreviewState == QCAMERA_HAL_PREVIEW_STOPPED) { 1921 delete areas; 1922 return NO_ERROR; 1923 } 1924 1925 //for special area string (0, 0, 0, 0, 0), set the num_areas_found to 0, 1926 //so no action is takenby the lower layer 1927 if(num_areas_found == 1 && (areas[0].x1 == 0) && (areas[0].y1 == 0) 1928 && (areas[0].x2 == 0) && (areas[0].y2 == 0) && (areas[0].weight == 0)) { 1929 num_areas_found = 0; 1930 } 1931 roi_info_t af_roi_value; 1932 memset(&af_roi_value, 0, sizeof(roi_info_t)); 1933 uint16_t x1, x2, y1, y2, dx, dy; 1934 int previewWidth, previewHeight; 1935 this->getPreviewSize(&previewWidth, &previewHeight); 1936 //transform the coords from (-1000, 1000) to (0, previewWidth or previewHeight) 1937 x1 = (uint16_t)((areas[0].x1 + 1000.0f)*(previewWidth/2000.0f)); 1938 y1 = (uint16_t)((areas[0].y1 + 1000.0f)*(previewHeight/2000.0f)); 1939 x2 = (uint16_t)((areas[0].x2 + 1000.0f)*(previewWidth/2000.0f)); 1940 y2 = (uint16_t)((areas[0].y2 + 1000.0f)*(previewHeight/2000.0f)); 1941 dx = x2 - x1; 1942 dy = y2 - y1; 1943 1944 af_roi_value.num_roi = num_areas_found; 1945 af_roi_value.roi[0].x = x1; 1946 af_roi_value.roi[0].y = y1; 1947 af_roi_value.roi[0].dx = dx; 1948 af_roi_value.roi[0].dy = dy; 1949 af_roi_value.is_multiwindow = 0; 1950 if (native_set_parms(MM_CAMERA_PARM_AF_ROI, sizeof(roi_info_t), (void*)&af_roi_value)) 1951 rc = NO_ERROR; 1952 else 1953 rc = BAD_VALUE; 1954 delete areas; 1955 } 1956 ALOGE("%s: X", __func__); 1957 return rc; 1958 } 1959 1960 status_t QCameraHardwareInterface::setMeteringAreas(const QCameraParameters& params) 1961 { 1962 ALOGV("%s: E", __func__); 1963 status_t rc; 1964 int max_num_mtr_areas = mParameters.getInt(QCameraParameters::KEY_MAX_NUM_METERING_AREAS); 1965 if(max_num_mtr_areas == 0) { 1966 return NO_ERROR; 1967 } 1968 1969 const char *str = params.get(QCameraParameters::KEY_METERING_AREAS); 1970 if (str == NULL) { 1971 ALOGE("%s: Parameter string is null", __func__); 1972 rc = NO_ERROR; 1973 } else { 1974 camera_area_t *areas = new camera_area_t[max_num_mtr_areas]; 1975 int num_areas_found=0; 1976 if(parseCameraAreaString(str, max_num_mtr_areas, areas, &num_areas_found) < 0) { 1977 ALOGE("%s: Failed to parse the string: %s", __func__, str); 1978 delete areas; 1979 return BAD_VALUE; 1980 } 1981 for(int i=0; i<num_areas_found; i++) { 1982 ALOGD("MeteringArea[%d] = (%d, %d, %d, %d, %d)", i, (areas[i].x1), (areas[i].y1), 1983 (areas[i].x2), (areas[i].y2), (areas[i].weight)); 1984 } 1985 if(validateCameraAreas(areas, num_areas_found) == false) { 1986 ALOGE("%s: invalid areas specified : %s", __func__, str); 1987 delete areas; 1988 return BAD_VALUE; 1989 } 1990 mParameters.set(QCameraParameters::KEY_METERING_AREAS, str); 1991 1992 //if the native_set_parms is called when preview is not started, it 1993 //crashes in lower layer, so return of preview is not started 1994 if(mPreviewState == QCAMERA_HAL_PREVIEW_STOPPED) { 1995 delete areas; 1996 return NO_ERROR; 1997 } 1998 1999 num_areas_found = 1; //temp; need to change after the multi-roi is enabled 2000 2001 //for special area string (0, 0, 0, 0, 0), set the num_areas_found to 0, 2002 //so no action is takenby the lower layer 2003 if(num_areas_found == 1 && (areas[0].x1 == 0) && (areas[0].y1 == 0) 2004 && (areas[0].x2 == 0) && (areas[0].y2 == 0) && (areas[0].weight == 0)) { 2005 num_areas_found = 0; 2006 } 2007 cam_set_aec_roi_t aec_roi_value; 2008 uint16_t x1, x2, y1, y2; 2009 int previewWidth, previewHeight; 2010 this->getPreviewSize(&previewWidth, &previewHeight); 2011 //transform the coords from (-1000, 1000) to (0, previewWidth or previewHeight) 2012 x1 = (uint16_t)((areas[0].x1 + 1000.0f)*(previewWidth/2000.0f)); 2013 y1 = (uint16_t)((areas[0].y1 + 1000.0f)*(previewHeight/2000.0f)); 2014 x2 = (uint16_t)((areas[0].x2 + 1000.0f)*(previewWidth/2000.0f)); 2015 y2 = (uint16_t)((areas[0].y2 + 1000.0f)*(previewHeight/2000.0f)); 2016 delete areas; 2017 2018 if(num_areas_found == 1) { 2019 aec_roi_value.aec_roi_enable = AEC_ROI_ON; 2020 aec_roi_value.aec_roi_type = AEC_ROI_BY_COORDINATE; 2021 aec_roi_value.aec_roi_position.coordinate.x = (x1+x2)/2; 2022 aec_roi_value.aec_roi_position.coordinate.y = (y1+y2)/2; 2023 } else { 2024 aec_roi_value.aec_roi_enable = AEC_ROI_OFF; 2025 aec_roi_value.aec_roi_type = AEC_ROI_BY_COORDINATE; 2026 aec_roi_value.aec_roi_position.coordinate.x = DONT_CARE_COORDINATE; 2027 aec_roi_value.aec_roi_position.coordinate.y = DONT_CARE_COORDINATE; 2028 } 2029 2030 if(native_set_parms(MM_CAMERA_PARM_AEC_ROI, sizeof(cam_set_aec_roi_t), (void *)&aec_roi_value)) 2031 rc = NO_ERROR; 2032 else 2033 rc = BAD_VALUE; 2034 } 2035 ALOGV("%s: X", __func__); 2036 return rc; 2037 } 2038 2039 status_t QCameraHardwareInterface::setFocusMode(const QCameraParameters& params) 2040 { 2041 const char *str = params.get(QCameraParameters::KEY_FOCUS_MODE); 2042 const char *prev_str = mParameters.get(QCameraParameters::KEY_FOCUS_MODE); 2043 ALOGV("%s",__func__); 2044 if (str != NULL) { 2045 ALOGE("Focus mode %s",str); 2046 int32_t value = attr_lookup(focus_modes, 2047 sizeof(focus_modes) / sizeof(str_map), str); 2048 if (value != NOT_FOUND) { 2049 mParameters.set(QCameraParameters::KEY_FOCUS_MODE, str); 2050 mFocusMode = value; 2051 2052 if(updateFocusDistances() != NO_ERROR) { 2053 ALOGE("%s: updateFocusDistances failed for %s", __FUNCTION__, str); 2054 return UNKNOWN_ERROR; 2055 } 2056 mParameters.set(QCameraParameters::KEY_FOCUS_DISTANCES, mFocusDistance.string()); 2057 if(mHasAutoFocusSupport){ 2058 bool ret = native_set_parms(MM_CAMERA_PARM_FOCUS_MODE, 2059 sizeof(value), 2060 (void *)&value); 2061 2062 int cafSupport = FALSE; 2063 if(!strcmp(str, QCameraParameters::FOCUS_MODE_CONTINUOUS_VIDEO) || 2064 !strcmp(str, QCameraParameters::FOCUS_MODE_CONTINUOUS_PICTURE)){ 2065 cafSupport = TRUE; 2066 } 2067 ALOGE("Continuous Auto Focus %d", cafSupport); 2068 ret = native_set_parms(MM_CAMERA_PARM_CONTINUOUS_AF, sizeof(cafSupport), 2069 (void *)&cafSupport); 2070 } 2071 2072 return NO_ERROR; 2073 } 2074 ALOGE("%s:Could not look up str value",__func__); 2075 } 2076 ALOGE("Invalid focus mode value: %s", (str == NULL) ? "NULL" : str); 2077 return BAD_VALUE; 2078 } 2079 2080 status_t QCameraHardwareInterface::setSceneMode(const QCameraParameters& params) 2081 { 2082 ALOGV("%s",__func__); 2083 uint8_t supported; 2084 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 2085 MM_CAMERA_PARM_BESTSHOT_MODE,&supported,&supported); 2086 if(!supported) { 2087 ALOGE("%s:Parameter Scenemode is not supported for this sensor", __func__); 2088 return NO_ERROR; 2089 } 2090 const char *str = params.get(QCameraParameters::KEY_SCENE_MODE); 2091 ALOGE("Scene Mode string : %s",str); 2092 2093 if (str != NULL) { 2094 int32_t value = attr_lookup(scenemode, sizeof(scenemode) / sizeof(str_map), str); 2095 ALOGE("Setting Scenemode value = %d",value ); 2096 if (value != NOT_FOUND) { 2097 if((value != CAMERA_BESTSHOT_OFF ) && (mColorEffects != CAMERA_EFFECT_OFF )) { 2098 int result; 2099 mColorEffects = CAMERA_EFFECT_OFF; 2100 native_set_parms(MM_CAMERA_PARM_EFFECT, sizeof(mColorEffects), 2101 (void *)&mColorEffects,(int *)&result); 2102 if(result != MM_CAMERA_OK) { 2103 ALOGI("Camera Effect is not set as the EFFECT_NONE and result is not OK"); 2104 } 2105 } 2106 mParameters.set(QCameraParameters::KEY_SCENE_MODE, str); 2107 bool ret = native_set_parms(MM_CAMERA_PARM_BESTSHOT_MODE, sizeof(value), 2108 (void *)&value); 2109 int bestshot_reconfigure; 2110 mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, 2111 MM_CAMERA_PARM_BESTSHOT_RECONFIGURE, 2112 &bestshot_reconfigure); 2113 if(bestshot_reconfigure) { 2114 if (mBestShotMode != value) { 2115 mBestShotMode = value; 2116 if (mPreviewState == QCAMERA_HAL_PREVIEW_STARTED && ret) { 2117 mRestartPreview = true; 2118 } 2119 } 2120 } 2121 return ret ? NO_ERROR : UNKNOWN_ERROR; 2122 } 2123 } 2124 ALOGE("Invalid scenemode value: %s", (str == NULL) ? "NULL" : str); 2125 return BAD_VALUE; 2126 } 2127 2128 status_t QCameraHardwareInterface::setSelectableZoneAf(const QCameraParameters& params) 2129 { 2130 ALOGV("%s",__func__); 2131 uint8_t supported; 2132 if(mHasAutoFocusSupport) { 2133 const char *str = params.get(QCameraParameters::KEY_QC_SELECTABLE_ZONE_AF); 2134 if (str != NULL) { 2135 int32_t value = attr_lookup(selectable_zone_af, sizeof(selectable_zone_af) / sizeof(str_map), str); 2136 if (value != NOT_FOUND) { 2137 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 2138 MM_CAMERA_PARM_FOCUS_RECT,&supported,&supported); 2139 if(!supported) { 2140 ALOGE("SelectableZoneAF is not supported for this sensor"); 2141 return NO_ERROR; 2142 }else { 2143 mParameters.set(QCameraParameters::KEY_QC_SELECTABLE_ZONE_AF, str); 2144 bool ret = native_set_parms(MM_CAMERA_PARM_FOCUS_RECT, sizeof(value), 2145 (void *)&value); 2146 return ret ? NO_ERROR : UNKNOWN_ERROR; 2147 } 2148 } 2149 } 2150 ALOGE("Invalid selectable zone af value: %s", (str == NULL) ? "NULL" : str); 2151 return BAD_VALUE; 2152 2153 } 2154 return NO_ERROR; 2155 } 2156 2157 status_t QCameraHardwareInterface::setEffect(const QCameraParameters& params) 2158 { 2159 ALOGV("%s",__func__); 2160 uint8_t supported; 2161 const char *str = params.get(CameraParameters::KEY_EFFECT); 2162 int result; 2163 mColorEffects = CAMERA_EFFECT_OFF; 2164 if (str != NULL) { 2165 ALOGE("Setting effect %s",str); 2166 int32_t value = attr_lookup(effects, sizeof(effects) / sizeof(str_map), str); 2167 if (value != NOT_FOUND) { 2168 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 2169 MM_CAMERA_PARM_EFFECT,&supported,&supported); 2170 if(!supported) { 2171 ALOGE("Camera Effect - %s mode is not supported for this sensor",str); 2172 return NO_ERROR; 2173 }else { 2174 mParameters.set(QCameraParameters::KEY_EFFECT, str); 2175 ALOGE("Setting effect to lower HAL : %d",value); 2176 mColorEffects = value; 2177 bool ret = native_set_parms(MM_CAMERA_PARM_EFFECT, sizeof(value), 2178 (void *)&value,(int *)&result); 2179 if(result != 0) { 2180 ALOGI("Camera Effect: %s is not set as the selected value is not supported ", str); 2181 } 2182 int bestshot_reconfigure; 2183 mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, 2184 MM_CAMERA_PARM_BESTSHOT_RECONFIGURE, 2185 &bestshot_reconfigure); 2186 if(bestshot_reconfigure) { 2187 if (mEffects != value) { 2188 mEffects = value; 2189 if (mPreviewState == QCAMERA_HAL_PREVIEW_STARTED && ret) { 2190 mRestartPreview = true; 2191 } 2192 } 2193 } 2194 return ret ? NO_ERROR : UNKNOWN_ERROR; 2195 } 2196 } 2197 } 2198 ALOGE("Invalid effect value: %s", (str == NULL) ? "NULL" : str); 2199 ALOGV("setEffect X"); 2200 return BAD_VALUE; 2201 } 2202 2203 status_t QCameraHardwareInterface::setBrightness(const QCameraParameters& params) { 2204 2205 ALOGV("%s",__func__); 2206 uint8_t supported; 2207 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 2208 MM_CAMERA_PARM_BRIGHTNESS,&supported,&supported); 2209 if(!supported) { 2210 ALOGE("MM_CAMERA_PARM_BRIGHTNESS mode is not supported for this sensor"); 2211 return NO_ERROR; 2212 } 2213 int brightness = params.getInt("luma-adaptation"); 2214 if (mBrightness != brightness) { 2215 ALOGV(" new brightness value : %d ", brightness); 2216 mBrightness = brightness; 2217 mParameters.set("luma-adaptation", brightness); 2218 bool ret = native_set_parms(MM_CAMERA_PARM_BRIGHTNESS, sizeof(mBrightness), 2219 (void *)&mBrightness); 2220 return ret ? NO_ERROR : UNKNOWN_ERROR; 2221 } 2222 2223 return NO_ERROR; 2224 } 2225 2226 status_t QCameraHardwareInterface::setAutoExposure(const QCameraParameters& params) 2227 { 2228 2229 ALOGV("%s",__func__); 2230 uint8_t supported; 2231 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 2232 MM_CAMERA_PARM_EXPOSURE,&supported,&supported); 2233 if(!supported) { 2234 ALOGE("MM_CAMERA_PARM_EXPOSURE mode is not supported for this sensor"); 2235 return NO_ERROR; 2236 } 2237 const char *str = params.get(QCameraParameters::KEY_QC_AUTO_EXPOSURE); 2238 if (str != NULL) { 2239 int32_t value = attr_lookup(autoexposure, sizeof(autoexposure) / sizeof(str_map), str); 2240 if (value != NOT_FOUND) { 2241 mParameters.set(QCameraParameters::KEY_QC_AUTO_EXPOSURE, str); 2242 bool ret = native_set_parms(MM_CAMERA_PARM_EXPOSURE, sizeof(value), 2243 (void *)&value); 2244 return ret ? NO_ERROR : UNKNOWN_ERROR; 2245 } 2246 } 2247 ALOGE("Invalid auto exposure value: %s", (str == NULL) ? "NULL" : str); 2248 return BAD_VALUE; 2249 } 2250 2251 status_t QCameraHardwareInterface::setExposureCompensation( 2252 const QCameraParameters & params){ 2253 ALOGV("%s",__func__); 2254 uint8_t supported; 2255 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 2256 MM_CAMERA_PARM_EXPOSURE_COMPENSATION,&supported,&supported); 2257 if(!supported) { 2258 ALOGE("MM_CAMERA_PARM_EXPOSURE_COMPENSATION mode is not supported for this sensor"); 2259 return NO_ERROR; 2260 } 2261 int numerator = params.getInt(QCameraParameters::KEY_EXPOSURE_COMPENSATION); 2262 if(EXPOSURE_COMPENSATION_MINIMUM_NUMERATOR <= numerator && 2263 numerator <= EXPOSURE_COMPENSATION_MAXIMUM_NUMERATOR){ 2264 int16_t numerator16 = (int16_t)(numerator & 0x0000ffff); 2265 uint16_t denominator16 = EXPOSURE_COMPENSATION_DENOMINATOR; 2266 uint32_t value = 0; 2267 value = numerator16 << 16 | denominator16; 2268 2269 mParameters.set(QCameraParameters::KEY_EXPOSURE_COMPENSATION, 2270 numerator); 2271 bool ret = native_set_parms(MM_CAMERA_PARM_EXPOSURE_COMPENSATION, 2272 sizeof(value), (void *)&value); 2273 return ret ? NO_ERROR : UNKNOWN_ERROR; 2274 } 2275 ALOGE("Invalid Exposure Compensation"); 2276 return BAD_VALUE; 2277 } 2278 2279 status_t QCameraHardwareInterface::setWhiteBalance(const QCameraParameters& params) 2280 { 2281 2282 ALOGV("%s",__func__); 2283 status_t rc = NO_ERROR; 2284 uint8_t supported; 2285 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 2286 MM_CAMERA_PARM_WHITE_BALANCE,&supported,&supported); 2287 if(!supported) { 2288 ALOGE("MM_CAMERA_PARM_WHITE_BALANCE mode is not supported for this sensor"); 2289 return NO_ERROR; 2290 } 2291 int result; 2292 2293 const char *str = params.get(QCameraParameters::KEY_WHITE_BALANCE); 2294 if (str != NULL) { 2295 int32_t value = attr_lookup(whitebalance, sizeof(whitebalance) / sizeof(str_map), str); 2296 if (value != NOT_FOUND) { 2297 mParameters.set(QCameraParameters::KEY_WHITE_BALANCE, str); 2298 bool ret = native_set_parms(MM_CAMERA_PARM_WHITE_BALANCE, sizeof(value), 2299 (void *)&value, (int *)&result); 2300 if(result != MM_CAMERA_OK) { 2301 ALOGI("WhiteBalance Value: %s is not set as the selected value is not supported ", str); 2302 } 2303 return ret ? NO_ERROR : UNKNOWN_ERROR; 2304 } 2305 } 2306 ALOGE("Invalid whitebalance value: %s", (str == NULL) ? "NULL" : str); 2307 return BAD_VALUE; 2308 } 2309 2310 int QCameraHardwareInterface::getAutoFlickerMode() 2311 { 2312 /* Enable Advanced Auto Antibanding where we can set 2313 any of the following option 2314 ie. CAMERA_ANTIBANDING_AUTO 2315 CAMERA_ANTIBANDING_AUTO_50HZ 2316 CAMERA_ANTIBANDING_AUTO_60HZ 2317 Currently setting it to default */ 2318 return CAMERA_ANTIBANDING_AUTO; 2319 } 2320 2321 status_t QCameraHardwareInterface::setAntibanding(const QCameraParameters& params) 2322 { 2323 int result; 2324 2325 ALOGV("%s",__func__); 2326 status_t rc = NO_ERROR; 2327 uint8_t supported; 2328 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 2329 MM_CAMERA_PARM_ANTIBANDING,&supported,&supported); 2330 if(!supported) { 2331 ALOGE("ANTIBANDING mode is not supported for this sensor"); 2332 return NO_ERROR; 2333 } 2334 const char *str = params.get(QCameraParameters::KEY_ANTIBANDING); 2335 if (str != NULL) { 2336 int value = (camera_antibanding_type)attr_lookup( 2337 antibanding, sizeof(antibanding) / sizeof(str_map), str); 2338 if (value != NOT_FOUND) { 2339 camera_antibanding_type temp = (camera_antibanding_type) value; 2340 ALOGE("Antibanding Value : %d",value); 2341 mParameters.set(QCameraParameters::KEY_ANTIBANDING, str); 2342 if(value == CAMERA_ANTIBANDING_AUTO) { 2343 value = getAutoFlickerMode(); 2344 } 2345 bool ret = native_set_parms(MM_CAMERA_PARM_ANTIBANDING, 2346 sizeof(camera_antibanding_type), (void *)&value ,(int *)&result); 2347 if(result != MM_CAMERA_OK) { 2348 ALOGI("AntiBanding Value: %s is not supported for the given BestShot Mode", str); 2349 } 2350 return ret ? NO_ERROR : UNKNOWN_ERROR; 2351 } 2352 } 2353 ALOGE("Invalid antibanding value: %s", (str == NULL) ? "NULL" : str); 2354 2355 return BAD_VALUE; 2356 } 2357 2358 status_t QCameraHardwareInterface::setPreviewFrameRate(const QCameraParameters& params) 2359 { 2360 ALOGV("%s: E",__func__); 2361 status_t rc = NO_ERROR; 2362 uint16_t fps = (uint16_t)params.getPreviewFrameRate(); 2363 ALOGV("%s: requested preview frame rate is %d", __func__, fps); 2364 2365 mParameters.setPreviewFrameRate(fps); 2366 ALOGV("%s: X",__func__); 2367 return NO_ERROR; 2368 } 2369 2370 status_t QCameraHardwareInterface::setPreviewFrameRateMode(const QCameraParameters& params) { 2371 2372 ALOGV("%s",__func__); 2373 uint8_t supported; 2374 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 2375 MM_CAMERA_PARM_FPS,&supported,&supported); 2376 if(!supported) { 2377 ALOGE(" CAMERA FPS mode is not supported for this sensor"); 2378 return NO_ERROR; 2379 } 2380 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 2381 MM_CAMERA_PARM_FPS_MODE,&supported,&supported); 2382 if(!supported) { 2383 ALOGE("CAMERA FPS MODE mode is not supported for this sensor"); 2384 return NO_ERROR; 2385 } 2386 2387 const char *previousMode = mParameters.getPreviewFrameRateMode(); 2388 const char *str = params.getPreviewFrameRateMode(); 2389 if (NULL == previousMode) { 2390 ALOGE("Preview Frame Rate Mode is NULL\n"); 2391 return NO_ERROR; 2392 } 2393 if (NULL == str) { 2394 ALOGE("Preview Frame Rate Mode is NULL\n"); 2395 return NO_ERROR; 2396 } 2397 if( mInitialized && !strcmp(previousMode, str)) { 2398 ALOGE("frame rate mode same as previous mode %s", previousMode); 2399 return NO_ERROR; 2400 } 2401 int32_t frameRateMode = attr_lookup(frame_rate_modes, sizeof(frame_rate_modes) / sizeof(str_map),str); 2402 if(frameRateMode != NOT_FOUND) { 2403 ALOGV("setPreviewFrameRateMode: %s ", str); 2404 mParameters.setPreviewFrameRateMode(str); 2405 bool ret = native_set_parms(MM_CAMERA_PARM_FPS_MODE, sizeof(frameRateMode), (void *)&frameRateMode); 2406 if(!ret) return ret; 2407 //set the fps value when chaging modes 2408 int16_t fps = (uint16_t)params.getPreviewFrameRate(); 2409 if(MINIMUM_FPS <= fps && fps <=MAXIMUM_FPS){ 2410 mParameters.setPreviewFrameRate(fps); 2411 ret = native_set_parms(MM_CAMERA_PARM_FPS, 2412 sizeof(fps), (void *)&fps); 2413 return ret ? NO_ERROR : UNKNOWN_ERROR; 2414 } 2415 ALOGE("Invalid preview frame rate value: %d", fps); 2416 return BAD_VALUE; 2417 } 2418 ALOGE("Invalid preview frame rate mode value: %s", (str == NULL) ? "NULL" : str); 2419 2420 return BAD_VALUE; 2421 } 2422 2423 status_t QCameraHardwareInterface::setSkinToneEnhancement(const QCameraParameters& params) { 2424 ALOGV("%s",__func__); 2425 uint8_t supported; 2426 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 2427 MM_CAMERA_PARM_SCE_FACTOR,&supported,&supported); 2428 if(!supported) { 2429 ALOGE("SkinToneEnhancement is not supported for this sensor"); 2430 return NO_ERROR; 2431 } 2432 int skinToneValue = params.getInt("skinToneEnhancement"); 2433 if (mSkinToneEnhancement != skinToneValue) { 2434 ALOGV(" new skinTone correction value : %d ", skinToneValue); 2435 mSkinToneEnhancement = skinToneValue; 2436 mParameters.set("skinToneEnhancement", skinToneValue); 2437 bool ret = native_set_parms(MM_CAMERA_PARM_SCE_FACTOR, sizeof(mSkinToneEnhancement), 2438 (void *)&mSkinToneEnhancement); 2439 return ret ? NO_ERROR : UNKNOWN_ERROR; 2440 } 2441 return NO_ERROR; 2442 } 2443 2444 status_t QCameraHardwareInterface::setWaveletDenoise(const QCameraParameters& params) { 2445 ALOGV("%s",__func__); 2446 uint8_t supported; 2447 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 2448 MM_CAMERA_PARM_WAVELET_DENOISE,&supported,&supported); 2449 if( !supported ) { 2450 ALOGE("Wavelet Denoise is not supported for this sensor"); 2451 /* TO DO */ 2452 // return NO_ERROR; 2453 } 2454 const char *str = params.get(QCameraParameters::KEY_QC_DENOISE); 2455 if (str != NULL) { 2456 int value = attr_lookup(denoise, 2457 sizeof(denoise) / sizeof(str_map), str); 2458 if ((value != NOT_FOUND) && (mDenoiseValue != value)) { 2459 mDenoiseValue = value; 2460 mParameters.set(QCameraParameters::KEY_QC_DENOISE, str); 2461 2462 char prop[PROPERTY_VALUE_MAX]; 2463 memset(prop, 0, sizeof(prop)); 2464 property_get("persist.denoise.process.plates", prop, "0"); 2465 2466 denoise_param_t temp; 2467 memset(&temp, 0, sizeof(denoise_param_t)); 2468 temp.denoise_enable = value; 2469 switch(atoi(prop)) { 2470 case 0: 2471 temp.process_plates = WAVELET_DENOISE_YCBCR_PLANE; 2472 break; 2473 case 1: 2474 temp.process_plates = WAVELET_DENOISE_CBCR_ONLY; 2475 break; 2476 case 2: 2477 temp.process_plates = WAVELET_DENOISE_STREAMLINE_YCBCR; 2478 break; 2479 case 3: 2480 temp.process_plates = WAVELET_DENOISE_STREAMLINED_CBCR; 2481 break; 2482 default: 2483 temp.process_plates = WAVELET_DENOISE_STREAMLINE_YCBCR; 2484 break; 2485 } 2486 ALOGE("Denoise enable=%d, plates=%d", temp.denoise_enable, temp.process_plates); 2487 bool ret = native_set_parms(MM_CAMERA_PARM_WAVELET_DENOISE, sizeof(temp), 2488 (void *)&temp); 2489 return ret ? NO_ERROR : UNKNOWN_ERROR; 2490 } 2491 return NO_ERROR; 2492 } 2493 ALOGE("Invalid Denoise value: %s", (str == NULL) ? "NULL" : str); 2494 return BAD_VALUE; 2495 } 2496 2497 status_t QCameraHardwareInterface::setVideoSize(const QCameraParameters& params) 2498 { 2499 const char *str= NULL; 2500 const char *str_t= NULL; 2501 int old_vid_w = 0, old_vid_h = 0; 2502 ALOGV("%s: E", __func__); 2503 str = params.get(QCameraParameters::KEY_VIDEO_SIZE); 2504 str_t = mParameters.get(CameraParameters::KEY_VIDEO_SIZE); 2505 if(!str) { 2506 mParameters.set(QCameraParameters::KEY_VIDEO_SIZE, ""); 2507 //If application didn't set this parameter string, use the values from 2508 //getPreviewSize() as video dimensions. 2509 ALOGE("No Record Size requested, use the preview dimensions"); 2510 videoWidth = mPreviewWidth; 2511 videoHeight = mPreviewHeight; 2512 } else { 2513 //Extract the record witdh and height that application requested. 2514 ALOGI("%s: requested record size %s", __func__, str); 2515 if(!parse_size(str, videoWidth, videoHeight)) { 2516 parse_size(str_t, old_vid_w, old_vid_h); 2517 mParameters.set(QCameraParameters::KEY_VIDEO_SIZE, str); 2518 if((QCAMERA_HAL_PREVIEW_STARTED == mPreviewState) && 2519 (old_vid_w != videoWidth || old_vid_h != videoHeight)) { 2520 ALOGE("%s: Video sizes changes to %s, Restart preview...", __func__, str); 2521 mRestartPreview = true; 2522 } 2523 } else { 2524 mParameters.set(QCameraParameters::KEY_VIDEO_SIZE, ""); 2525 ALOGE("%s: error :failed to parse parameter record-size (%s)", __func__, str); 2526 return BAD_VALUE; 2527 } 2528 } 2529 ALOGV("%s: preview dimensions: %dx%d", __func__, mPreviewWidth, mPreviewHeight); 2530 ALOGV("%s: video dimensions: %dx%d", __func__, videoWidth, videoHeight); 2531 mDimension.orig_video_width = videoWidth; 2532 mDimension.orig_video_height = videoHeight; 2533 mDimension.video_width = videoWidth; 2534 mDimension.video_height = videoHeight; 2535 2536 ALOGV("%s: X", __func__); 2537 return NO_ERROR; 2538 } 2539 2540 status_t QCameraHardwareInterface::setCameraMode(const QCameraParameters& params) { 2541 int32_t value = params.getInt(QCameraParameters::KEY_QC_CAMERA_MODE); 2542 mParameters.set(QCameraParameters::KEY_QC_CAMERA_MODE,value); 2543 2544 ALOGI("ZSL is enabled %d", value); 2545 if (value == 1) { 2546 myMode = (camera_mode_t)(myMode | CAMERA_ZSL_MODE); 2547 } else { 2548 myMode = (camera_mode_t)(myMode & ~CAMERA_ZSL_MODE); 2549 } 2550 return NO_ERROR; 2551 } 2552 2553 status_t QCameraHardwareInterface::setPowerMode(const QCameraParameters& params) { 2554 uint32_t value = NORMAL_POWER; 2555 const char *powermode = NULL; 2556 2557 powermode = params.get(QCameraParameters::KEY_QC_POWER_MODE); 2558 if (powermode != NULL) { 2559 value = attr_lookup(power_modes, 2560 sizeof(power_modes) / sizeof(str_map), powermode); 2561 if((value == LOW_POWER) || mHFRLevel > 1) { 2562 ALOGI("Enable Low Power Mode"); 2563 value = LOW_POWER; 2564 mPowerMode = value; 2565 mParameters.set(QCameraParameters::KEY_QC_POWER_MODE,"Low_Power"); 2566 } else { 2567 ALOGE("Enable Normal Power Mode"); 2568 mPowerMode = value; 2569 mParameters.set(QCameraParameters::KEY_QC_POWER_MODE,"Normal_Power"); 2570 } 2571 } 2572 2573 ALOGI("%s Low power mode %s value = %d", __func__, 2574 value ? "Enabled" : "Disabled", value); 2575 native_set_parms(MM_CAMERA_PARM_LOW_POWER_MODE, sizeof(value), 2576 (void *)&value); 2577 return NO_ERROR; 2578 } 2579 2580 2581 status_t QCameraHardwareInterface::setPreviewSize(const QCameraParameters& params) 2582 { 2583 int width, height; 2584 params.getPreviewSize(&width, &height); 2585 ALOGV("################requested preview size %d x %d", width, height); 2586 2587 // Validate the preview size 2588 for (size_t i = 0; i < mPreviewSizeCount; ++i) { 2589 if (width == mPreviewSizes[i].width 2590 && height == mPreviewSizes[i].height) { 2591 mParameters.setPreviewSize(width, height); 2592 ALOGE("setPreviewSize: width: %d heigh: %d", width, height); 2593 mPreviewWidth = width; 2594 mPreviewHeight = height; 2595 mDimension.display_width = width; 2596 mDimension.display_height = height; 2597 return NO_ERROR; 2598 } 2599 } 2600 ALOGE("Invalid preview size requested: %dx%d", width, height); 2601 return BAD_VALUE; 2602 } 2603 status_t QCameraHardwareInterface::setPreviewFpsRange(const QCameraParameters& params) 2604 { 2605 ALOGV("%s: E", __func__); 2606 int minFps,maxFps; 2607 int prevMinFps, prevMaxFps; 2608 int rc = NO_ERROR; 2609 bool found = false; 2610 2611 mParameters.getPreviewFpsRange(&prevMinFps, &prevMaxFps); 2612 ALOGV("%s: Existing FpsRange Values:(%d, %d)", __func__, prevMinFps, prevMaxFps); 2613 params.getPreviewFpsRange(&minFps,&maxFps); 2614 ALOGV("%s: Requested FpsRange Values:(%d, %d)", __func__, minFps, maxFps); 2615 2616 if(mInitialized && (minFps == prevMinFps && maxFps == prevMaxFps)) { 2617 ALOGE("%s: No change in FpsRange", __func__); 2618 rc = NO_ERROR; 2619 goto end; 2620 } 2621 for(int i=0; i<mSupportedFpsRangesCount; i++) { 2622 // if the value is in the supported list 2623 if(minFps >= mSupportedFpsRanges[i].minFPS && maxFps <= mSupportedFpsRanges[i].maxFPS) { 2624 found = true; 2625 ALOGE("FPS: i=%d : minFps = %d, maxFps = %d ", i, minFps, maxFps); 2626 mParameters.setPreviewFpsRange(minFps,maxFps); 2627 // validate the values 2628 bool valid = true; 2629 // FPS can not be negative 2630 if(minFps < 0 || maxFps < 0) valid = false; 2631 // minFps must be >= maxFps 2632 if(minFps > maxFps) valid = false; 2633 2634 if(valid) { 2635 //Set the FPS mode 2636 const char *str = (minFps == maxFps) ? 2637 QCameraParameters::KEY_QC_PREVIEW_FRAME_RATE_FIXED_MODE: 2638 QCameraParameters::KEY_QC_PREVIEW_FRAME_RATE_AUTO_MODE; 2639 ALOGE("%s FPS_MODE = %s", __func__, str); 2640 int32_t frameRateMode = attr_lookup(frame_rate_modes, 2641 sizeof(frame_rate_modes) / sizeof(str_map),str); 2642 bool ret; 2643 ret = native_set_parms(MM_CAMERA_PARM_FPS_MODE, sizeof(int32_t), 2644 (void *)&frameRateMode); 2645 2646 //set FPS values 2647 uint32_t fps; //lower 2 bytes specify maxFps and higher 2 bytes specify minFps 2648 fps = ((uint32_t)(minFps/1000) << 16) + ((uint16_t)(maxFps/1000)); 2649 2650 ret = native_set_parms(MM_CAMERA_PARM_FPS, sizeof(uint32_t), (void *)&fps); 2651 mParameters.setPreviewFpsRange(minFps, maxFps); 2652 if(ret) 2653 rc = NO_ERROR; 2654 else { 2655 rc = BAD_VALUE; 2656 ALOGE("%s: error: native_set_params failed", __func__); 2657 } 2658 } else { 2659 ALOGE("%s: error: invalid FPS range value", __func__); 2660 rc = BAD_VALUE; 2661 } 2662 } 2663 } 2664 if(found == false){ 2665 ALOGE("%s: error: FPS range value not supported", __func__); 2666 rc = BAD_VALUE; 2667 } 2668 end: 2669 ALOGV("%s: X", __func__); 2670 return rc; 2671 } 2672 2673 status_t QCameraHardwareInterface::setJpegThumbnailSize(const QCameraParameters& params){ 2674 int width = params.getInt(QCameraParameters::KEY_JPEG_THUMBNAIL_WIDTH); 2675 int height = params.getInt(QCameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT); 2676 2677 ALOGV("requested jpeg thumbnail size %d x %d", width, height); 2678 2679 // Validate the picture size 2680 for (unsigned int i = 0; i < thumbnail_sizes_count; ++i) { 2681 if (width == default_thumbnail_sizes[i].width 2682 && height == default_thumbnail_sizes[i].height) { 2683 thumbnailWidth = width; 2684 thumbnailHeight = height; 2685 mParameters.set(QCameraParameters::KEY_JPEG_THUMBNAIL_WIDTH, width); 2686 mParameters.set(QCameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT, height); 2687 return NO_ERROR; 2688 } 2689 } 2690 ALOGE("error: setting jpeg thumbnail size"); 2691 return BAD_VALUE; 2692 } 2693 status_t QCameraHardwareInterface::setPictureSize(const QCameraParameters& params) 2694 { 2695 int width, height; 2696 ALOGV("QualcommCameraHardware::setPictureSize E"); 2697 params.getPictureSize(&width, &height); 2698 ALOGE("requested picture size %d x %d", width, height); 2699 2700 // Validate the picture size 2701 for (int i = 0; i < mSupportedPictureSizesCount; ++i) { 2702 if (width == mPictureSizesPtr[i].width 2703 && height == mPictureSizesPtr[i].height) { 2704 int old_width, old_height; 2705 mParameters.getPictureSize(&old_width,&old_height); 2706 mParameters.setPictureSize(width, height); 2707 mDimension.picture_width = width; 2708 mDimension.picture_height = height; 2709 if((QCAMERA_HAL_PREVIEW_STARTED == mPreviewState) && 2710 (width != old_width || height != old_height)) { 2711 mRestartPreview = true; 2712 } 2713 return NO_ERROR; 2714 } 2715 } 2716 /* Dimension not among the ones in the list. Check if 2717 * its a valid dimension, if it is, then configure the 2718 * camera accordingly. else reject it. 2719 */ 2720 if( isValidDimension(width, height) ) { 2721 mParameters.setPictureSize(width, height); 2722 mDimension.picture_width = width; 2723 mDimension.picture_height = height; 2724 return NO_ERROR; 2725 } else 2726 ALOGE("Invalid picture size requested: %dx%d", width, height); 2727 return BAD_VALUE; 2728 } 2729 2730 status_t QCameraHardwareInterface::setJpegRotation(int isZsl) { 2731 // return mm_jpeg_encoder_setRotation(mRotation, isZsl); 2732 return NO_ERROR; 2733 } 2734 2735 int QCameraHardwareInterface::getJpegRotation(void) { 2736 ALOGE("%s : rotation is %d", __func__, mRotation); 2737 return mRotation; 2738 } 2739 2740 int QCameraHardwareInterface::getISOSpeedValue() 2741 { 2742 const char *iso_str = mParameters.get(QCameraParameters::KEY_QC_ISO_MODE); 2743 int iso_index = attr_lookup(iso, sizeof(iso) / sizeof(str_map), iso_str); 2744 int iso_value = iso_speed_values[iso_index]; 2745 return iso_value; 2746 } 2747 2748 2749 status_t QCameraHardwareInterface::setJpegQuality(const QCameraParameters& params) { 2750 status_t rc = NO_ERROR; 2751 int quality = params.getInt(QCameraParameters::KEY_JPEG_QUALITY); 2752 ALOGV("setJpegQuality E"); 2753 if (quality >= 0 && quality <= 100) { 2754 mParameters.set(QCameraParameters::KEY_JPEG_QUALITY, quality); 2755 mJpegQuality = quality; 2756 } else { 2757 ALOGE("Invalid jpeg quality=%d", quality); 2758 rc = BAD_VALUE; 2759 } 2760 2761 quality = params.getInt(QCameraParameters::KEY_JPEG_THUMBNAIL_QUALITY); 2762 if (quality >= 0 && quality <= 100) { 2763 mParameters.set(QCameraParameters::KEY_JPEG_THUMBNAIL_QUALITY, quality); 2764 } else { 2765 ALOGE("Invalid jpeg thumbnail quality=%d", quality); 2766 rc = BAD_VALUE; 2767 } 2768 ALOGV("setJpegQuality X"); 2769 return rc; 2770 } 2771 2772 status_t QCameraHardwareInterface:: 2773 setNumOfSnapshot(const QCameraParameters& params) { 2774 status_t rc = NO_ERROR; 2775 2776 int num_of_snapshot = getNumOfSnapshots(params); 2777 2778 if (num_of_snapshot <= 0) { 2779 num_of_snapshot = 1; 2780 } 2781 ALOGI("number of snapshots = %d", num_of_snapshot); 2782 mParameters.set("num-snaps-per-shutter", num_of_snapshot); 2783 2784 bool result = native_set_parms(MM_CAMERA_PARM_SNAPSHOT_BURST_NUM, 2785 sizeof(int), 2786 (void *)&num_of_snapshot); 2787 if(!result) 2788 ALOGI("%s:Failure setting number of snapshots!!!", __func__); 2789 return rc; 2790 } 2791 2792 status_t QCameraHardwareInterface::setPreviewFormat(const QCameraParameters& params) { 2793 const char *str = params.getPreviewFormat(); 2794 int32_t previewFormat = attr_lookup(preview_formats, sizeof(preview_formats) / sizeof(str_map), str); 2795 if(previewFormat != NOT_FOUND) { 2796 int num = sizeof(preview_format_info_list)/sizeof(preview_format_info_t); 2797 int i; 2798 2799 for (i = 0; i < num; i++) { 2800 if (preview_format_info_list[i].Hal_format == previewFormat) { 2801 mPreviewFormatInfo = preview_format_info_list[i]; 2802 break; 2803 } 2804 } 2805 2806 if (i == num) { 2807 mPreviewFormatInfo.mm_cam_format = CAMERA_YUV_420_NV21; 2808 mPreviewFormatInfo.padding = CAMERA_PAD_TO_WORD; 2809 return BAD_VALUE; 2810 } 2811 bool ret = native_set_parms(MM_CAMERA_PARM_PREVIEW_FORMAT, sizeof(cam_format_t), 2812 (void *)&mPreviewFormatInfo.mm_cam_format); 2813 mParameters.set(QCameraParameters::KEY_PREVIEW_FORMAT, str); 2814 mPreviewFormat = mPreviewFormatInfo.mm_cam_format; 2815 ALOGI("Setting preview format to %d, i =%d, num=%d, hal_format=%d", 2816 mPreviewFormat, i, num, mPreviewFormatInfo.Hal_format); 2817 return NO_ERROR; 2818 } else if ( strTexturesOn ) { 2819 mPreviewFormatInfo.mm_cam_format = CAMERA_YUV_420_NV21; 2820 mPreviewFormatInfo.padding = CAMERA_PAD_TO_4K; 2821 } else { 2822 mPreviewFormatInfo.mm_cam_format = CAMERA_YUV_420_NV21; 2823 mPreviewFormatInfo.padding = CAMERA_PAD_TO_WORD; 2824 } 2825 ALOGE("Invalid preview format value: %s", (str == NULL) ? "NULL" : str); 2826 return BAD_VALUE; 2827 } 2828 2829 status_t QCameraHardwareInterface::setStrTextures(const QCameraParameters& params) { 2830 const char *str = params.get("strtextures"); 2831 const char *prev_str = mParameters.get("strtextures"); 2832 2833 if(str != NULL) { 2834 if(!strcmp(str,prev_str)) { 2835 return NO_ERROR; 2836 } 2837 int str_size = strlen(str); 2838 mParameters.set("strtextures", str); 2839 if(str_size == 2) { 2840 if(!strncmp(str, "on", str_size) || !strncmp(str, "ON", str_size)){ 2841 ALOGI("Resetting mUseOverlay to false"); 2842 strTexturesOn = true; 2843 mUseOverlay = false; 2844 } 2845 }else if(str_size == 3){ 2846 if (!strncmp(str, "off", str_size) || !strncmp(str, "OFF", str_size)) { 2847 strTexturesOn = false; 2848 mUseOverlay = true; 2849 } 2850 } 2851 2852 } 2853 return NO_ERROR; 2854 } 2855 2856 status_t QCameraHardwareInterface::setFlash(const QCameraParameters& params) 2857 { 2858 ALOGI("%s: E",__func__); 2859 uint8_t supported; 2860 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 2861 MM_CAMERA_PARM_LED_MODE,&supported,&supported); 2862 if(!supported) { 2863 ALOGE("%s:LED FLASH not supported", __func__); 2864 return NO_ERROR; 2865 } 2866 2867 const char *str = params.get(QCameraParameters::KEY_FLASH_MODE); 2868 if (str != NULL) { 2869 int32_t value = attr_lookup(flash, sizeof(flash) / sizeof(str_map), str); 2870 if (value != NOT_FOUND) { 2871 mParameters.set(QCameraParameters::KEY_FLASH_MODE, str); 2872 bool ret = native_set_parms(MM_CAMERA_PARM_LED_MODE, 2873 sizeof(value), (void *)&value); 2874 return ret ? NO_ERROR : UNKNOWN_ERROR; 2875 } 2876 } 2877 ALOGE("Invalid flash mode value: %s", (str == NULL) ? "NULL" : str); 2878 2879 return BAD_VALUE; 2880 } 2881 2882 status_t QCameraHardwareInterface::setAecAwbLock(const QCameraParameters & params) 2883 { 2884 ALOGD("%s : E", __func__); 2885 status_t rc = NO_ERROR; 2886 int32_t value; 2887 const char* str; 2888 2889 //for AEC lock 2890 str = params.get(QCameraParameters::KEY_AUTO_EXPOSURE_LOCK); 2891 value = (strcmp(str, "true") == 0)? 1 : 0; 2892 mParameters.set(QCameraParameters::KEY_AUTO_EXPOSURE_LOCK, str); 2893 rc = (native_set_parms(MM_CAMERA_PARM_AEC_LOCK, sizeof(int32_t), (void *)(&value))) ? 2894 NO_ERROR : UNKNOWN_ERROR; 2895 2896 //for AWB lock 2897 str = params.get(QCameraParameters::KEY_AUTO_WHITEBALANCE_LOCK); 2898 value = (strcmp(str, "true") == 0)? 1 : 0; 2899 mParameters.set(QCameraParameters::KEY_AUTO_WHITEBALANCE_LOCK, str); 2900 rc = (native_set_parms(MM_CAMERA_PARM_AWB_LOCK, sizeof(int32_t), (void *)(&value))) ? 2901 NO_ERROR : UNKNOWN_ERROR; 2902 ALOGD("%s : X", __func__); 2903 return rc; 2904 } 2905 2906 status_t QCameraHardwareInterface::setOverlayFormats(const QCameraParameters& params) 2907 { 2908 mParameters.set("overlay-format", HAL_PIXEL_FORMAT_YCbCr_420_SP); 2909 if(mIs3DModeOn == true) { 2910 int ovFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP|HAL_3D_IN_SIDE_BY_SIDE_L_R|HAL_3D_OUT_SIDE_BY_SIDE; 2911 mParameters.set("overlay-format", ovFormat); 2912 } 2913 return NO_ERROR; 2914 } 2915 2916 status_t QCameraHardwareInterface::setMCEValue(const QCameraParameters& params) 2917 { 2918 ALOGE("%s",__func__); 2919 uint8_t supported; 2920 2921 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 2922 MM_CAMERA_PARM_MCE,&supported,&supported); 2923 if(!supported) { 2924 ALOGE("MM_CAMERA_PARM_MCE mode is not supported for this sensor"); 2925 return NO_ERROR; 2926 } 2927 const char *str = params.get(QCameraParameters::KEY_QC_MEMORY_COLOR_ENHANCEMENT); 2928 if (str != NULL) { 2929 int value = attr_lookup(mce, sizeof(mce) / sizeof(str_map), str); 2930 if (value != NOT_FOUND) { 2931 int temp = (int8_t)value; 2932 ALOGI("%s: setting MCE value of %s", __FUNCTION__, str); 2933 mParameters.set(QCameraParameters::KEY_QC_MEMORY_COLOR_ENHANCEMENT, str); 2934 2935 native_set_parms(MM_CAMERA_PARM_MCE, sizeof(int8_t), (void *)&temp); 2936 return NO_ERROR; 2937 } 2938 } 2939 ALOGE("Invalid MCE value: %s", (str == NULL) ? "NULL" : str); 2940 2941 return NO_ERROR; 2942 } 2943 2944 status_t QCameraHardwareInterface::setHighFrameRate(const QCameraParameters& params) 2945 { 2946 uint8_t supported; 2947 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 2948 MM_CAMERA_PARM_HFR,&supported,&supported); 2949 if(!supported) { 2950 ALOGE("%s: MM_CAMERA_PARM_HFR not supported", __func__); 2951 return NO_ERROR; 2952 } 2953 2954 const char *str = params.get(QCameraParameters::KEY_QC_VIDEO_HIGH_FRAME_RATE); 2955 if (str != NULL) { 2956 int value = attr_lookup(hfr, sizeof(hfr) / sizeof(str_map), str); 2957 if (value != NOT_FOUND) { 2958 mHFRLevel = (int32_t)value; 2959 //Check for change in HFR value 2960 const char *oldHfr = mParameters.get(QCameraParameters::KEY_QC_VIDEO_HIGH_FRAME_RATE); 2961 if(strcmp(oldHfr, str)){ 2962 mParameters.set(QCameraParameters::KEY_QC_VIDEO_HIGH_FRAME_RATE, str); 2963 if(QCAMERA_HAL_PREVIEW_STARTED == mPreviewState) { 2964 stopPreviewInternal(); 2965 mPreviewState = QCAMERA_HAL_PREVIEW_STOPPED; 2966 native_set_parms(MM_CAMERA_PARM_HFR, sizeof(int32_t), (void *)&mHFRLevel); 2967 mRestartPreview = true; 2968 return NO_ERROR; 2969 } 2970 } 2971 native_set_parms(MM_CAMERA_PARM_HFR, sizeof(int32_t), (void *)&mHFRLevel); 2972 return NO_ERROR; 2973 } 2974 } 2975 ALOGE("Invalid HFR value: %s", (str == NULL) ? "NULL" : str); 2976 return NO_ERROR; 2977 } 2978 2979 status_t QCameraHardwareInterface::setLensshadeValue(const QCameraParameters& params) 2980 { 2981 2982 uint8_t supported; 2983 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 2984 MM_CAMERA_PARM_ROLLOFF,&supported,&supported); 2985 if(!supported) { 2986 ALOGE("%s:LENS SHADING not supported", __func__); 2987 return NO_ERROR; 2988 } 2989 2990 const char *str = params.get(QCameraParameters::KEY_QC_LENSSHADE); 2991 if (str != NULL) { 2992 int value = attr_lookup(lensshade, 2993 sizeof(lensshade) / sizeof(str_map), str); 2994 if (value != NOT_FOUND) { 2995 int8_t temp = (int8_t)value; 2996 mParameters.set(QCameraParameters::KEY_QC_LENSSHADE, str); 2997 native_set_parms(MM_CAMERA_PARM_ROLLOFF, sizeof(int8_t), (void *)&temp); 2998 return NO_ERROR; 2999 } 3000 } 3001 ALOGE("Invalid lensShade value: %s", (str == NULL) ? "NULL" : str); 3002 return BAD_VALUE; 3003 } 3004 3005 status_t QCameraHardwareInterface::setFaceDetect(const QCameraParameters& params) 3006 { 3007 int requested_faces = params.getInt(QCameraParameters::KEY_QC_MAX_NUM_REQUESTED_FACES); 3008 int hardware_supported_faces = mParameters.getInt(CameraParameters::KEY_MAX_NUM_DETECTED_FACES_HW); 3009 if (requested_faces > hardware_supported_faces) { 3010 requested_faces = hardware_supported_faces; 3011 } 3012 mParameters.set(QCameraParameters::KEY_QC_MAX_NUM_REQUESTED_FACES, requested_faces); 3013 const char *str = params.get(QCameraParameters::KEY_QC_FACE_DETECTION); 3014 ALOGE("setFaceDetect: %s", str); 3015 if (str != NULL) { 3016 fd_set_parm_t fd_set_parm; 3017 int value = attr_lookup(facedetection, 3018 sizeof(facedetection) / sizeof(str_map), str); 3019 mFaceDetectOn = value; 3020 fd_set_parm.fd_mode = value; 3021 fd_set_parm.num_fd = requested_faces; 3022 ALOGE("%s Face detection value = %d, num_fd = %d",__func__, value, requested_faces); 3023 native_set_parms(MM_CAMERA_PARM_FD, sizeof(fd_set_parm_t), (void *)&fd_set_parm); 3024 mParameters.set(QCameraParameters::KEY_QC_FACE_DETECTION, str); 3025 return NO_ERROR; 3026 } 3027 ALOGE("Invalid Face Detection value: %s", (str == NULL) ? "NULL" : str); 3028 return BAD_VALUE; 3029 } 3030 status_t QCameraHardwareInterface::setFaceDetection(const char *str) 3031 { 3032 if(supportsFaceDetection() == false){ 3033 ALOGE("Face detection is not enabled"); 3034 return NO_ERROR; 3035 } 3036 if (str != NULL) { 3037 int requested_faces = mParameters.getInt(QCameraParameters::KEY_QC_MAX_NUM_REQUESTED_FACES); 3038 int value = attr_lookup(facedetection, 3039 sizeof(facedetection) / sizeof(str_map), str); 3040 if (value != NOT_FOUND) { 3041 fd_set_parm_t fd_set_parm; 3042 mFaceDetectOn = value; 3043 fd_set_parm.fd_mode = value; 3044 fd_set_parm.num_fd = requested_faces; 3045 ALOGE("%s Face detection value = %d, num_fd = %d",__func__, value, requested_faces); 3046 native_set_parms(MM_CAMERA_PARM_FD, sizeof(fd_set_parm_t), (void *)&fd_set_parm); 3047 mParameters.set(QCameraParameters::KEY_QC_FACE_DETECTION, str); 3048 return NO_ERROR; 3049 } 3050 } 3051 ALOGE("Invalid Face Detection value: %s", (str == NULL) ? "NULL" : str); 3052 return BAD_VALUE; 3053 } 3054 3055 status_t QCameraHardwareInterface::setAEBracket(const QCameraParameters& params) 3056 { 3057 uint8_t supported; 3058 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 3059 MM_CAMERA_PARM_HDR,&supported,&supported); 3060 if(!supported || (myMode & CAMERA_ZSL_MODE)) { 3061 ALOGI("Parameter HDR is not supported for this sensor/ ZSL mode"); 3062 3063 if (myMode & CAMERA_ZSL_MODE) { 3064 ALOGE("In ZSL mode, reset AEBBracket to HDR_OFF mode"); 3065 exp_bracketing_t temp; 3066 memset(&temp, 0, sizeof(temp)); 3067 mHdrMode = HDR_BRACKETING_OFF; 3068 temp.hdr_enable= FALSE; 3069 temp.mode = HDR_BRACKETING_OFF; 3070 native_set_parms(MM_CAMERA_PARM_HDR, sizeof(exp_bracketing_t), (void *)&temp); 3071 } 3072 return NO_ERROR; 3073 } 3074 const char *str = params.get(QCameraParameters::KEY_QC_AE_BRACKET_HDR); 3075 3076 if (str != NULL) { 3077 int value = attr_lookup(hdr_bracket, 3078 sizeof(hdr_bracket) / sizeof(str_map), str); 3079 exp_bracketing_t temp; 3080 memset(&temp, 0, sizeof(temp)); 3081 switch (value) { 3082 case HDR_MODE: 3083 { 3084 mHdrMode = HDR_MODE; 3085 ALOGE("%s, mHdrMode == HDR_MODE", __func__); 3086 /* temp.hdr_enable= TRUE; 3087 temp.mode = HDR_MODE; 3088 temp.total_frames = 3; 3089 temp.total_hal_frames = getNumOfSnapshots(); 3090 ALOGI("%s: setting HDR frames (%d)", __FUNCTION__, temp.total_hal_frames); 3091 native_set_parms(MM_CAMERA_PARM_HDR, sizeof(exp_bracketing_t), (void *)&temp); */ 3092 } 3093 break; 3094 case EXP_BRACKETING_MODE: 3095 { 3096 ALOGE("%s, mHdrMode == EXP_BRACKETING_MODE", __func__); 3097 int numFrames = getNumOfSnapshots(); 3098 const char *str_val = params.get("capture-burst-exposures"); 3099 if ((str_val != NULL) && (strlen(str_val)>0)) { 3100 ALOGI("%s: capture-burst-exposures %s", __FUNCTION__, str_val); 3101 3102 mHdrMode = EXP_BRACKETING_MODE; 3103 temp.hdr_enable = FALSE; 3104 temp.mode = EXP_BRACKETING_MODE; 3105 temp.total_frames = (numFrames > MAX_SNAPSHOT_BUFFERS -2) ? MAX_SNAPSHOT_BUFFERS -2 : numFrames; 3106 temp.total_hal_frames = temp.total_frames; 3107 strlcpy(temp.values, str_val, MAX_EXP_BRACKETING_LENGTH); 3108 ALOGI("%s: setting Exposure Bracketing value of %s, frame (%d)", __FUNCTION__, temp.values, temp.total_hal_frames); 3109 native_set_parms(MM_CAMERA_PARM_HDR, sizeof(exp_bracketing_t), (void *)&temp); 3110 } 3111 else { 3112 /* Apps not set capture-burst-exposures, error case fall into bracketing off mode */ 3113 ALOGI("%s: capture-burst-exposures not set, back to HDR OFF mode", __FUNCTION__); 3114 mHdrMode = HDR_BRACKETING_OFF; 3115 temp.hdr_enable= FALSE; 3116 temp.mode = HDR_BRACKETING_OFF; 3117 native_set_parms(MM_CAMERA_PARM_HDR, sizeof(exp_bracketing_t), (void *)&temp); 3118 } 3119 } 3120 break; 3121 case HDR_BRACKETING_OFF: 3122 ALOGE("%s, mHdrMode == HDR_BRACKETING_OFF", __func__); 3123 default: 3124 { 3125 ALOGE("%s, mHdrMode == HDR_BRACKETING_OFF", __func__); 3126 mHdrMode = HDR_BRACKETING_OFF; 3127 temp.hdr_enable= FALSE; 3128 temp.mode = HDR_BRACKETING_OFF; 3129 native_set_parms(MM_CAMERA_PARM_HDR, sizeof(exp_bracketing_t), (void *)&temp); 3130 } 3131 break; 3132 } 3133 3134 /* save the value*/ 3135 mParameters.set(QCameraParameters::KEY_QC_AE_BRACKET_HDR, str); 3136 } 3137 return NO_ERROR; 3138 } 3139 3140 status_t QCameraHardwareInterface::setCaptureBurstExp() 3141 { 3142 char burst_exp[PROPERTY_VALUE_MAX]; 3143 memset(burst_exp, 0, sizeof(burst_exp)); 3144 property_get("persist.capture.burst.exposures", burst_exp, ""); 3145 if (NULL != burst_exp) 3146 mParameters.set("capture-burst-exposures", burst_exp); 3147 return NO_ERROR; 3148 } 3149 3150 status_t QCameraHardwareInterface::setRedeyeReduction(const QCameraParameters& params) 3151 { 3152 if(supportsRedEyeReduction() == false) { 3153 ALOGE("Parameter Redeye Reduction is not supported for this sensor"); 3154 return NO_ERROR; 3155 } 3156 3157 const char *str = params.get(QCameraParameters::KEY_QC_REDEYE_REDUCTION); 3158 if (str != NULL) { 3159 int value = attr_lookup(redeye_reduction, sizeof(redeye_reduction) / sizeof(str_map), str); 3160 if (value != NOT_FOUND) { 3161 int8_t temp = (int8_t)value; 3162 ALOGI("%s: setting Redeye Reduction value of %s", __FUNCTION__, str); 3163 mParameters.set(QCameraParameters::KEY_QC_REDEYE_REDUCTION, str); 3164 3165 native_set_parms(MM_CAMERA_PARM_REDEYE_REDUCTION, sizeof(int8_t), (void *)&temp); 3166 return NO_ERROR; 3167 } 3168 } 3169 ALOGE("Invalid Redeye Reduction value: %s", (str == NULL) ? "NULL" : str); 3170 return BAD_VALUE; 3171 } 3172 3173 status_t QCameraHardwareInterface::setGpsLocation(const QCameraParameters& params) 3174 { 3175 const char *method = params.get(QCameraParameters::KEY_GPS_PROCESSING_METHOD); 3176 if (method) { 3177 mParameters.set(QCameraParameters::KEY_GPS_PROCESSING_METHOD, method); 3178 }else { 3179 mParameters.remove(QCameraParameters::KEY_GPS_PROCESSING_METHOD); 3180 } 3181 3182 const char *latitude = params.get(QCameraParameters::KEY_GPS_LATITUDE); 3183 if (latitude) { 3184 ALOGE("latitude %s",latitude); 3185 mParameters.set(QCameraParameters::KEY_GPS_LATITUDE, latitude); 3186 }else { 3187 mParameters.remove(QCameraParameters::KEY_GPS_LATITUDE); 3188 } 3189 3190 const char *latitudeRef = params.get(QCameraParameters::KEY_QC_GPS_LATITUDE_REF); 3191 if (latitudeRef) { 3192 mParameters.set(QCameraParameters::KEY_QC_GPS_LATITUDE_REF, latitudeRef); 3193 }else { 3194 mParameters.remove(QCameraParameters::KEY_QC_GPS_LATITUDE_REF); 3195 } 3196 3197 const char *longitude = params.get(QCameraParameters::KEY_GPS_LONGITUDE); 3198 if (longitude) { 3199 mParameters.set(QCameraParameters::KEY_GPS_LONGITUDE, longitude); 3200 }else { 3201 mParameters.remove(QCameraParameters::KEY_GPS_LONGITUDE); 3202 } 3203 3204 const char *longitudeRef = params.get(QCameraParameters::KEY_QC_GPS_LONGITUDE_REF); 3205 if (longitudeRef) { 3206 mParameters.set(QCameraParameters::KEY_QC_GPS_LONGITUDE_REF, longitudeRef); 3207 }else { 3208 mParameters.remove(QCameraParameters::KEY_QC_GPS_LONGITUDE_REF); 3209 } 3210 3211 const char *altitudeRef = params.get(QCameraParameters::KEY_QC_GPS_ALTITUDE_REF); 3212 if (altitudeRef) { 3213 mParameters.set(QCameraParameters::KEY_QC_GPS_ALTITUDE_REF, altitudeRef); 3214 }else { 3215 mParameters.remove(QCameraParameters::KEY_QC_GPS_ALTITUDE_REF); 3216 } 3217 3218 const char *altitude = params.get(QCameraParameters::KEY_GPS_ALTITUDE); 3219 if (altitude) { 3220 mParameters.set(QCameraParameters::KEY_GPS_ALTITUDE, altitude); 3221 }else { 3222 mParameters.remove(QCameraParameters::KEY_GPS_ALTITUDE); 3223 } 3224 3225 const char *status = params.get(QCameraParameters::KEY_QC_GPS_STATUS); 3226 if (status) { 3227 mParameters.set(QCameraParameters::KEY_QC_GPS_STATUS, status); 3228 } 3229 3230 const char *dateTime = params.get(QCameraParameters::KEY_QC_EXIF_DATETIME); 3231 if (dateTime) { 3232 mParameters.set(QCameraParameters::KEY_QC_EXIF_DATETIME, dateTime); 3233 }else { 3234 mParameters.remove(QCameraParameters::KEY_QC_EXIF_DATETIME); 3235 } 3236 3237 const char *timestamp = params.get(QCameraParameters::KEY_GPS_TIMESTAMP); 3238 if (timestamp) { 3239 mParameters.set(QCameraParameters::KEY_GPS_TIMESTAMP, timestamp); 3240 }else { 3241 mParameters.remove(QCameraParameters::KEY_GPS_TIMESTAMP); 3242 } 3243 ALOGE("setGpsLocation X"); 3244 return NO_ERROR; 3245 } 3246 3247 status_t QCameraHardwareInterface::setRotation(const QCameraParameters& params) 3248 { 3249 status_t rc = NO_ERROR; 3250 int rotation = params.getInt(QCameraParameters::KEY_ROTATION); 3251 if (rotation != NOT_FOUND) { 3252 if (rotation == 0 || rotation == 90 || rotation == 180 3253 || rotation == 270) { 3254 mParameters.set(QCameraParameters::KEY_ROTATION, rotation); 3255 mRotation = rotation; 3256 } else { 3257 ALOGE("Invalid rotation value: %d", rotation); 3258 rc = BAD_VALUE; 3259 } 3260 } 3261 ALOGE("setRotation"); 3262 return rc; 3263 } 3264 3265 status_t QCameraHardwareInterface::setDenoise(const QCameraParameters& params) 3266 { 3267 return BAD_VALUE; 3268 } 3269 3270 status_t QCameraHardwareInterface::setOrientation(const QCameraParameters& params) 3271 { 3272 const char *str = params.get("orientation"); 3273 3274 if (str != NULL) { 3275 if (strcmp(str, "portrait") == 0 || strcmp(str, "landscape") == 0) { 3276 // Camera service needs this to decide if the preview frames and raw 3277 // pictures should be rotated. 3278 mParameters.set("orientation", str); 3279 } else { 3280 ALOGE("Invalid orientation value: %s", str); 3281 return BAD_VALUE; 3282 } 3283 } 3284 return NO_ERROR; 3285 } 3286 3287 status_t QCameraHardwareInterface::setPictureFormat(const QCameraParameters& params) 3288 { 3289 const char * str = params.get(QCameraParameters::KEY_PICTURE_FORMAT); 3290 if(str != NULL){ 3291 int32_t value = attr_lookup(picture_formats, 3292 sizeof(picture_formats) / sizeof(str_map), str); 3293 if(value != NOT_FOUND){ 3294 if (isZSLMode() && !strcmp(str, "raw")) { 3295 mParameters.set(QCameraParameters::KEY_PICTURE_FORMAT, "jpeg"); 3296 } else { 3297 mParameters.set(QCameraParameters::KEY_PICTURE_FORMAT, str); 3298 } 3299 } else { 3300 ALOGE("Invalid Picture Format value: %s", str); 3301 return BAD_VALUE; 3302 } 3303 } 3304 return NO_ERROR; 3305 } 3306 3307 status_t QCameraHardwareInterface::setRecordingHintValue(const int32_t value) 3308 { 3309 native_set_parms(MM_CAMERA_PARM_RECORDING_HINT, sizeof(value), 3310 (void *)&value); 3311 if (value == TRUE){ 3312 native_set_parms(MM_CAMERA_PARM_CAF_ENABLE, sizeof(value), 3313 (void *)&value); 3314 } 3315 setDISMode(); 3316 setFullLiveshot(); 3317 return NO_ERROR; 3318 } 3319 3320 status_t QCameraHardwareInterface::setRecordingHint(const QCameraParameters& params) 3321 { 3322 3323 const char * str = params.get(QCameraParameters::KEY_RECORDING_HINT); 3324 3325 if(str != NULL){ 3326 int32_t value = attr_lookup(recording_Hints, 3327 sizeof(recording_Hints) / sizeof(str_map), str); 3328 if(value != NOT_FOUND){ 3329 mRecordingHint = value; 3330 setRecordingHintValue(mRecordingHint); 3331 mParameters.set(QCameraParameters::KEY_RECORDING_HINT, str); 3332 return NO_ERROR; 3333 } else { 3334 ALOGE("Invalid Picture Format value: %s", str); 3335 setDISMode(); 3336 setFullLiveshot(); 3337 return BAD_VALUE; 3338 } 3339 } 3340 setDISMode(); 3341 setFullLiveshot(); 3342 return NO_ERROR; 3343 } 3344 3345 status_t QCameraHardwareInterface::setDISMode() { 3346 /* Enable DIS only if 3347 * - Camcorder mode AND 3348 * - DIS property is set AND 3349 * - Not in Low power mode. */ 3350 uint32_t value = mRecordingHint && mDisEnabled 3351 && !isLowPowerCamcorder(); 3352 3353 ALOGI("%s DIS is %s value = %d", __func__, 3354 value ? "Enabled" : "Disabled", value); 3355 native_set_parms(MM_CAMERA_PARM_DIS_ENABLE, sizeof(value), 3356 (void *)&value); 3357 return NO_ERROR; 3358 } 3359 3360 status_t QCameraHardwareInterface::setFullLiveshot() 3361 { 3362 /* Enable full size liveshot only if 3363 * - Camcorder mode AND 3364 * - Full size liveshot is enabled. */ 3365 uint32_t value = mRecordingHint && mFullLiveshotEnabled 3366 && !isLowPowerCamcorder(); 3367 3368 if (((mDimension.picture_width == mDimension.video_width) && 3369 (mDimension.picture_height == mDimension.video_height))) { 3370 /* If video size matches the live snapshot size 3371 * turn off full size liveshot to get higher fps. */ 3372 value = 0; 3373 } 3374 3375 ALOGI("%s Full size liveshot %s value = %d", __func__, 3376 value ? "Enabled" : "Disabled", value); 3377 native_set_parms(MM_CAMERA_PARM_FULL_LIVESHOT, sizeof(value), 3378 (void *)&value); 3379 return NO_ERROR; 3380 } 3381 3382 status_t QCameraHardwareInterface::setMobiCat(const QCameraParameters& params) 3383 { 3384 mm_cam_mobicat_info_t mbc_info; 3385 char mbc_prop[PROPERTY_VALUE_MAX]; 3386 int propval; 3387 memset(mbc_prop, 0, sizeof(mbc_prop)); 3388 property_get("persist.camera.mobicat", mbc_prop, "0"); 3389 propval = atoi(mbc_prop); 3390 mbc_info.enable = (mParameters.getInt("mobicat") == 1) ? 1 : 0; 3391 ALOGV("%s:%d] prop %d %d", __func__, __LINE__, mbc_info.enable, propval); 3392 mbc_info.enable |= propval; 3393 3394 if (mbc_info.enable != mMobiCatEnabled) { 3395 ALOGV("%s:%d] enable %d", __func__, __LINE__, mbc_info.enable); 3396 native_set_parms(MM_CAMERA_PARM_MOBICAT, sizeof(mm_cam_mobicat_info_t), 3397 (void *)&mbc_info); 3398 mMobiCatEnabled = mbc_info.enable; 3399 } 3400 return NO_ERROR; 3401 } 3402 3403 3404 isp3a_af_mode_t QCameraHardwareInterface::getAutoFocusMode( 3405 const QCameraParameters& params) 3406 { 3407 isp3a_af_mode_t afMode = AF_MODE_MAX; 3408 afMode = (isp3a_af_mode_t)mFocusMode; 3409 return afMode; 3410 } 3411 3412 void QCameraHardwareInterface::getPictureSize(int *picture_width, 3413 int *picture_height) const 3414 { 3415 mParameters.getPictureSize(picture_width, picture_height); 3416 } 3417 3418 void QCameraHardwareInterface::getPreviewSize(int *preview_width, 3419 int *preview_height) const 3420 { 3421 mParameters.getPreviewSize(preview_width, preview_height); 3422 } 3423 3424 void QCameraHardwareInterface::getVideoSize(int *video_width, 3425 int *video_height) const 3426 { 3427 mParameters.getVideoSize(video_width, video_height); 3428 } 3429 3430 void QCameraHardwareInterface::getThumbnailSize(int *thumb_width, 3431 int *thumb_height) const 3432 { 3433 *thumb_width = mParameters.getInt(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH); 3434 *thumb_height = mParameters.getInt(CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT); 3435 } 3436 3437 cam_format_t QCameraHardwareInterface::getPreviewFormat() const 3438 { 3439 cam_format_t foramt = CAMERA_YUV_420_NV21; 3440 const char *str = mParameters.getPreviewFormat(); 3441 int32_t value = attr_lookup(preview_formats, 3442 sizeof(preview_formats)/sizeof(str_map), 3443 str); 3444 3445 if(value != NOT_FOUND) { 3446 int num = sizeof(preview_format_info_list)/sizeof(preview_format_info_t); 3447 int i; 3448 for (i = 0; i < num; i++) { 3449 if (preview_format_info_list[i].Hal_format == value) { 3450 foramt = preview_format_info_list[i].mm_cam_format; 3451 break; 3452 } 3453 } 3454 } 3455 3456 return foramt; 3457 } 3458 3459 cam_pad_format_t QCameraHardwareInterface::getPreviewPadding() const 3460 { 3461 return mPreviewFormatInfo.padding; 3462 } 3463 3464 int QCameraHardwareInterface::getJpegQuality() const 3465 { 3466 return mJpegQuality; 3467 } 3468 3469 int QCameraHardwareInterface::getNumOfSnapshots(void) const 3470 { 3471 char prop[PROPERTY_VALUE_MAX]; 3472 memset(prop, 0, sizeof(prop)); 3473 property_get("persist.camera.snapshot.number", prop, "0"); 3474 ALOGI("%s: prop enable/disable = %d", __func__, atoi(prop)); 3475 if (atoi(prop)) { 3476 ALOGE("%s: Reading maximum no of snapshots = %d" 3477 "from properties", __func__, atoi(prop)); 3478 return atoi(prop); 3479 } else { 3480 return mParameters.getInt("num-snaps-per-shutter"); 3481 } 3482 } 3483 3484 int QCameraHardwareInterface::getNumOfSnapshots(const QCameraParameters& params) 3485 { 3486 char prop[PROPERTY_VALUE_MAX]; 3487 memset(prop, 0, sizeof(prop)); 3488 property_get("persist.camera.snapshot.number", prop, "0"); 3489 ALOGI("%s: prop enable/disable = %d", __func__, atoi(prop)); 3490 if (atoi(prop)) { 3491 ALOGI("%s: Reading maximum no of snapshots = %d" 3492 "from properties", __func__, atoi(prop)); 3493 return atoi(prop); 3494 } else { 3495 return params.getInt("num-snaps-per-shutter"); 3496 } 3497 3498 } 3499 3500 int QCameraHardwareInterface:: 3501 getThumbSizesFromAspectRatio(uint32_t aspect_ratio, 3502 int *picture_width, 3503 int *picture_height) 3504 { 3505 for(unsigned int i = 0; i < THUMBNAIL_SIZE_COUNT; i++ ){ 3506 if(thumbnail_sizes[i].aspect_ratio == aspect_ratio) 3507 { 3508 *picture_width = thumbnail_sizes[i].width; 3509 *picture_height = thumbnail_sizes[i].height; 3510 return NO_ERROR; 3511 } 3512 } 3513 3514 return BAD_VALUE; 3515 } 3516 3517 bool QCameraHardwareInterface::isRawSnapshot() 3518 { 3519 const char *format = mParameters.getPictureFormat(); 3520 if( format!= NULL && 3521 !strcmp(format, QCameraParameters::PIXEL_FORMAT_RAW)){ 3522 return true; 3523 } 3524 else{ 3525 return false; 3526 } 3527 } 3528 3529 status_t QCameraHardwareInterface::setPreviewSizeTable(void) 3530 { 3531 status_t ret = NO_ERROR; 3532 mm_camera_dimension_t dim; 3533 struct camera_size_type* preview_size_table; 3534 int preview_table_size; 3535 int i = 0; 3536 char str[10] = {0}; 3537 3538 /* Initialize table with default values */ 3539 preview_size_table = default_preview_sizes; 3540 preview_table_size = preview_sizes_count; 3541 3542 3543 /* Get maximum preview size supported by sensor*/ 3544 memset(&dim, 0, sizeof(mm_camera_dimension_t)); 3545 ret = mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, 3546 MM_CAMERA_PARM_MAX_PREVIEW_SIZE, &dim); 3547 if (ret != NO_ERROR) { 3548 ALOGE("%s: Failure getting Max Preview Size supported by camera", 3549 __func__); 3550 goto end; 3551 } 3552 3553 ALOGD("%s: Max Preview Sizes Supported: %d X %d", __func__, 3554 dim.width, dim.height); 3555 3556 for (i = 0; i < preview_table_size; i++) { 3557 if ((preview_size_table->width <= dim.width) && 3558 (preview_size_table->height <= dim.height)) { 3559 ALOGD("%s: Camera Preview Size Table " 3560 "Max width: %d height %d table_size: %d", 3561 __func__, preview_size_table->width, 3562 preview_size_table->height, preview_table_size - i); 3563 break; 3564 } 3565 preview_size_table++; 3566 } 3567 //set preferred preview size to maximum preview size 3568 sprintf(str, "%dx%d", preview_size_table->width, preview_size_table->height); 3569 mParameters.set(QCameraParameters::KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO, str); 3570 ALOGD("KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO = %s", str); 3571 3572 end: 3573 /* Save the table in global member*/ 3574 mPreviewSizes = preview_size_table; 3575 mPreviewSizeCount = preview_table_size - i; 3576 3577 return ret; 3578 } 3579 3580 status_t QCameraHardwareInterface::setPictureSizeTable(void) 3581 { 3582 status_t ret = NO_ERROR; 3583 mm_camera_dimension_t dim; 3584 struct camera_size_type* picture_size_table; 3585 int picture_table_size; 3586 int i = 0, count = 0; 3587 3588 /* Initialize table with default values */ 3589 picture_table_size = sizeof(default_picture_sizes)/ 3590 sizeof(default_picture_sizes[0]); 3591 picture_size_table = default_picture_sizes; 3592 mPictureSizes = 3593 ( struct camera_size_type *)malloc(picture_table_size * 3594 sizeof(struct camera_size_type)); 3595 if (mPictureSizes == NULL) { 3596 ALOGE("%s: Failre allocating memory to store picture size table",__func__); 3597 goto end; 3598 } 3599 3600 /* Get maximum picture size supported by sensor*/ 3601 memset(&dim, 0, sizeof(mm_camera_dimension_t)); 3602 ret = mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, 3603 MM_CAMERA_PARM_MAX_PICTURE_SIZE, &dim); 3604 if (ret != NO_ERROR) { 3605 ALOGE("%s: Failure getting Max Picture Size supported by camera", 3606 __func__); 3607 ret = NO_MEMORY; 3608 free(mPictureSizes); 3609 mPictureSizes = NULL; 3610 goto end; 3611 } 3612 3613 ALOGD("%s: Max Picture Sizes Supported: %d X %d", __func__, 3614 dim.width, dim.height); 3615 3616 for (i = 0; i < picture_table_size; i++) { 3617 /* We'll store those dimensions whose width AND height 3618 are less than or equal to maximum supported */ 3619 if ((picture_size_table->width <= dim.width) && 3620 (picture_size_table->height <= dim.height)) { 3621 ALOGD("%s: Camera Picture Size Table " 3622 "Max width: %d height %d table_size: %d", 3623 __func__, picture_size_table->width, 3624 picture_size_table->height, count+1); 3625 mPictureSizes[count].height = picture_size_table->height; 3626 mPictureSizes[count].width = picture_size_table->width; 3627 count++; 3628 } 3629 picture_size_table++; 3630 } 3631 mPictureSizeCount = count; 3632 3633 end: 3634 /* In case of error, we use default picture sizes */ 3635 if (ret != NO_ERROR) { 3636 mPictureSizes = default_picture_sizes; 3637 mPictureSizeCount = picture_table_size; 3638 } 3639 return ret; 3640 } 3641 3642 status_t QCameraHardwareInterface::setVideoSizeTable(void) 3643 { 3644 status_t ret = NO_ERROR; 3645 mm_camera_dimension_t dim; 3646 struct camera_size_type* video_size_table; 3647 int video_table_size; 3648 int i = 0, count = 0; 3649 ALOGE("%s: E", __func__); 3650 3651 /* Initialize table with default values */ 3652 video_table_size = video_sizes_count; 3653 video_size_table = default_video_sizes; 3654 mVideoSizes = 3655 (struct camera_size_type *)malloc(video_table_size * 3656 sizeof(struct camera_size_type)); 3657 if(mVideoSizes == NULL) { 3658 ALOGE("%s: error allocating memory to store video size table",__func__); 3659 ret = BAD_VALUE; 3660 goto end; 3661 } 3662 3663 /* Get maximum video size supported by sensor*/ 3664 memset(&dim, 0, sizeof(mm_camera_dimension_t)); 3665 ret = mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, 3666 MM_CAMERA_PARM_MAX_VIDEO_SIZE, &dim); 3667 if(ret != NO_ERROR) { 3668 ALOGE("%s: error getting Max Video Size supported by camera", 3669 __func__); 3670 ret = NO_MEMORY; 3671 free(mVideoSizes); 3672 mVideoSizes = NULL; 3673 ret = BAD_VALUE; 3674 goto end; 3675 } 3676 3677 ALOGD("%s: Max Video Size Supported: %d X %d", __func__, 3678 dim.width, dim.height); 3679 3680 for(i=0; i < video_table_size; i++) { 3681 /* We'll store those dimensions whose width AND height 3682 are less than or equal to maximum supported */ 3683 if((video_size_table->width <= dim.width) && 3684 (video_size_table->height <= dim.height)) { 3685 ALOGD("%s: Supported Video Size [%d] = %dx%d", __func__, count, video_size_table->width, 3686 video_size_table->height); 3687 mVideoSizes[count].height = video_size_table->height; 3688 mVideoSizes[count].width = video_size_table->width; 3689 count++; 3690 } 3691 video_size_table++; 3692 } 3693 mVideoSizeCount = count; 3694 3695 end: 3696 ALOGE("%s: X", __func__); 3697 return ret; 3698 } 3699 3700 void QCameraHardwareInterface::freeVideoSizeTable(void) 3701 { 3702 if(mVideoSizes != NULL) 3703 { 3704 free(mVideoSizes); 3705 } 3706 mVideoSizeCount = 0; 3707 } 3708 3709 3710 void QCameraHardwareInterface::freePictureTable(void) 3711 { 3712 /* If we couldn't allocate memory to store picture table 3713 we use the picture table pointer to point to default 3714 picture table array. In that case we cannot free it.*/ 3715 if ((mPictureSizes != default_picture_sizes) && mPictureSizes) { 3716 free(mPictureSizes); 3717 } 3718 } 3719 3720 status_t QCameraHardwareInterface::setHistogram(int histogram_en) 3721 { 3722 status_t ret = NO_ERROR; 3723 3724 ALOGV("setHistogram: E"); 3725 if(mStatsOn == histogram_en) { 3726 return ret; 3727 } 3728 3729 status_t rc = NO_ERROR; 3730 mCameraHandle->ops->is_parm_supported(mCameraHandle->camera_handle, 3731 MM_CAMERA_PARM_HISTOGRAM, 3732 (uint8_t*)&rc,(uint8_t*)&rc); 3733 if(!rc) { 3734 ALOGE(" Histogram is not supported for this"); 3735 return NO_ERROR; 3736 } 3737 mSendData = histogram_en; 3738 mStatsOn = histogram_en; 3739 3740 if (histogram_en == QCAMERA_PARM_ENABLE) { 3741 ret = initHistogramBuffers(); 3742 if (ret != NO_ERROR) { 3743 ALOGE("%s Error initializing Histogram buffers ", __func__); 3744 return ret; 3745 } 3746 } 3747 ALOGI(" Histogram -> %s", histogram_en ? "Enabled" : "Disabled"); 3748 native_set_parms(MM_CAMERA_PARM_HISTOGRAM, sizeof(int), &histogram_en); 3749 if(histogram_en == QCAMERA_PARM_DISABLE) { 3750 ret = deInitHistogramBuffers(); 3751 if (ret != NO_ERROR) { 3752 ALOGE("%s Error deInitializing Histogram buffers ", __func__); 3753 return ret; 3754 } 3755 } 3756 ALOGV("setHistogram: X"); 3757 return ret; 3758 } 3759 3760 status_t QCameraHardwareInterface::setZSLBurstLookBack(const QCameraParameters& params) 3761 { 3762 const char *v = params.get("capture-burst-retroactive"); 3763 if (v) { 3764 int look_back = atoi(v); 3765 ALOGI("%s: look_back =%d", __func__, look_back); 3766 mParameters.set("capture-burst-retroactive", look_back); 3767 } 3768 return NO_ERROR; 3769 } 3770 3771 status_t QCameraHardwareInterface::setZSLBurstInterval(const QCameraParameters& params) 3772 { 3773 mZslInterval = BURST_INTREVAL_DEFAULT; 3774 const char *v = params.get("capture-burst-interval"); 3775 if (v) { 3776 int interval = atoi(v); 3777 ALOGI("%s: Interval =%d", __func__, interval); 3778 if(interval < BURST_INTREVAL_MIN ||interval > BURST_INTREVAL_MAX ) { 3779 return BAD_VALUE; 3780 } 3781 mZslInterval = interval; 3782 } 3783 return NO_ERROR; 3784 } 3785 3786 int QCameraHardwareInterface::getZSLBurstInterval( void ) 3787 { 3788 int val; 3789 3790 if (mZslInterval == BURST_INTREVAL_DEFAULT) { 3791 char prop[PROPERTY_VALUE_MAX]; 3792 memset(prop, 0, sizeof(prop)); 3793 property_get("persist.camera.zsl.interval", prop, "1"); 3794 val = atoi(prop); 3795 ALOGD("%s: prop interval = %d", __func__, val); 3796 } else { 3797 val = mZslInterval; 3798 } 3799 return val; 3800 } 3801 3802 3803 int QCameraHardwareInterface::getZSLQueueDepth(void) const 3804 { 3805 char prop[PROPERTY_VALUE_MAX]; 3806 memset(prop, 0, sizeof(prop)); 3807 property_get("persist.camera.zsl.queuedepth", prop, "2"); 3808 ALOGI("%s: prop = %d", __func__, atoi(prop)); 3809 return atoi(prop); 3810 } 3811 3812 int QCameraHardwareInterface::getZSLBackLookCount(void) const 3813 { 3814 int look_back; 3815 char prop[PROPERTY_VALUE_MAX]; 3816 memset(prop, 0, sizeof(prop)); 3817 property_get("persist.camera.zsl.backlookcnt", prop, "0"); 3818 ALOGI("%s: prop = %d", __func__, atoi(prop)); 3819 look_back = atoi(prop); 3820 if (look_back == 0 ) { 3821 look_back = mParameters.getInt("capture-burst-retroactive"); 3822 ALOGE("%s: look_back = %d", __func__, look_back); 3823 } 3824 return look_back; 3825 } 3826 3827 //EXIF functions 3828 void QCameraHardwareInterface::deinitExifData() 3829 { 3830 ALOGD("Clearing EXIF data"); 3831 memset(mExifData, 0, sizeof(exif_tags_info_t) * MAX_EXIF_TABLE_ENTRIES); 3832 mExifTableNumEntries = 0; 3833 } 3834 3835 void QCameraHardwareInterface::addExifTag(exif_tag_id_t tagid, exif_tag_type_t type, 3836 uint32_t count, uint8_t copy, void *data) { 3837 3838 if(mExifTableNumEntries >= MAX_EXIF_TABLE_ENTRIES) { 3839 ALOGE("%s: Number of entries exceeded limit", __func__); 3840 return; 3841 } 3842 int index = mExifTableNumEntries; 3843 mExifData[index].tag_id = tagid; 3844 mExifData[index].tag_entry.type = type; 3845 mExifData[index].tag_entry.count = count; 3846 mExifData[index].tag_entry.copy = copy; 3847 if((type == EXIF_RATIONAL) && (count > 1)) 3848 mExifData[index].tag_entry.data._rats = (rat_t *)data; 3849 if((type == EXIF_RATIONAL) && (count == 1)) 3850 mExifData[index].tag_entry.data._rat = *(rat_t *)data; 3851 else if(type == EXIF_ASCII) 3852 mExifData[index].tag_entry.data._ascii = (char *)data; 3853 else if(type == EXIF_BYTE) 3854 mExifData[index].tag_entry.data._byte = *(uint8_t *)data; 3855 else if((type == EXIF_SHORT) && (count > 1)) 3856 mExifData[index].tag_entry.data._shorts = (uint16_t *)data; 3857 else if((type == EXIF_SHORT) && (count == 1)) 3858 mExifData[index].tag_entry.data._short = *(uint16_t *)data; 3859 // Increase number of entries 3860 mExifTableNumEntries++; 3861 } 3862 3863 rat_t getRational(int num, int denom) 3864 { 3865 rat_t temp = {num, denom}; 3866 return temp; 3867 } 3868 3869 void QCameraHardwareInterface::initExifData(){ 3870 if(mExifValues.dateTime) { 3871 addExifTag(EXIFTAGID_EXIF_DATE_TIME_ORIGINAL, EXIF_ASCII, 3872 20, 1, (void *)mExifValues.dateTime); 3873 } 3874 addExifTag(EXIFTAGID_FOCAL_LENGTH, EXIF_RATIONAL, 1, 1, (void *)&(mExifValues.focalLength)); 3875 addExifTag(EXIFTAGID_ISO_SPEED_RATING,EXIF_SHORT,1,1,(void *)&(mExifValues.isoSpeed)); 3876 3877 if(mExifValues.mGpsProcess) { 3878 addExifTag(EXIFTAGID_GPS_PROCESSINGMETHOD, EXIF_ASCII, 3879 EXIF_ASCII_PREFIX_SIZE + strlen(mExifValues.gpsProcessingMethod + EXIF_ASCII_PREFIX_SIZE) + 1, 3880 1, (void *)mExifValues.gpsProcessingMethod); 3881 } 3882 3883 if(mExifValues.mLatitude) { 3884 addExifTag(EXIFTAGID_GPS_LATITUDE, EXIF_RATIONAL, 3, 1, (void *)mExifValues.latitude); 3885 3886 if(mExifValues.latRef) { 3887 addExifTag(EXIFTAGID_GPS_LATITUDE_REF, EXIF_ASCII, 2, 3888 1, (void *)mExifValues.latRef); 3889 } 3890 } 3891 3892 if(mExifValues.mLongitude) { 3893 addExifTag(EXIFTAGID_GPS_LONGITUDE, EXIF_RATIONAL, 3, 1, (void *)mExifValues.longitude); 3894 3895 if(mExifValues.lonRef) { 3896 addExifTag(EXIFTAGID_GPS_LONGITUDE_REF, EXIF_ASCII, 2, 3897 1, (void *)mExifValues.lonRef); 3898 } 3899 } 3900 3901 if(mExifValues.mAltitude) { 3902 addExifTag(EXIFTAGID_GPS_ALTITUDE, EXIF_RATIONAL, 1, 3903 1, (void *)&(mExifValues.altitude)); 3904 3905 addExifTag(EXIFTAGID_GPS_ALTITUDE_REF, EXIF_BYTE, 1, 1, (void *)&mExifValues.mAltitude_ref); 3906 } 3907 3908 if(mExifValues.mTimeStamp) { 3909 time_t unixTime; 3910 struct tm *UTCTimestamp; 3911 3912 unixTime = (time_t)mExifValues.mGPSTimestamp; 3913 UTCTimestamp = gmtime(&unixTime); 3914 3915 strftime(mExifValues.gpsDateStamp, sizeof(mExifValues.gpsDateStamp), "%Y:%m:%d", UTCTimestamp); 3916 addExifTag(EXIFTAGID_GPS_DATESTAMP, EXIF_ASCII, 3917 strlen(mExifValues.gpsDateStamp)+1 , 1, (void *)mExifValues.gpsDateStamp); 3918 3919 mExifValues.gpsTimeStamp[0] = getRational(UTCTimestamp->tm_hour, 1); 3920 mExifValues.gpsTimeStamp[1] = getRational(UTCTimestamp->tm_min, 1); 3921 mExifValues.gpsTimeStamp[2] = getRational(UTCTimestamp->tm_sec, 1); 3922 3923 addExifTag(EXIFTAGID_GPS_TIMESTAMP, EXIF_RATIONAL, 3924 3, 1, (void *)mExifValues.gpsTimeStamp); 3925 ALOGE("EXIFTAGID_GPS_TIMESTAMP set"); 3926 } 3927 3928 } 3929 3930 //Add all exif tags in this function 3931 void QCameraHardwareInterface::setExifTags() 3932 { 3933 const char *str; 3934 3935 //set TimeStamp 3936 str = mParameters.get(QCameraParameters::KEY_QC_EXIF_DATETIME); 3937 if(str != NULL) { 3938 strncpy(mExifValues.dateTime, str, 19); 3939 mExifValues.dateTime[19] = '\0'; 3940 } 3941 3942 //Set focal length 3943 int focalLengthValue = (int) (mParameters.getFloat( 3944 QCameraParameters::KEY_FOCAL_LENGTH) * FOCAL_LENGTH_DECIMAL_PRECISION); 3945 3946 mExifValues.focalLength = getRational(focalLengthValue, FOCAL_LENGTH_DECIMAL_PRECISION); 3947 3948 //Set ISO Speed 3949 mExifValues.isoSpeed = getISOSpeedValue(); 3950 3951 //get time and date from system 3952 time_t rawtime; 3953 struct tm * timeinfo; 3954 time(&rawtime); 3955 timeinfo = localtime (&rawtime); 3956 //Write datetime according to EXIF Spec 3957 //"YYYY:MM:DD HH:MM:SS" (20 chars including \0) 3958 snprintf(mExifValues.dateTime, 20, "%04d:%02d:%02d %02d:%02d:%02d", 3959 timeinfo->tm_year + 1900, timeinfo->tm_mon + 1, 3960 timeinfo->tm_mday, timeinfo->tm_hour, 3961 timeinfo->tm_min, timeinfo->tm_sec); 3962 3963 //set gps tags 3964 setExifTagsGPS(); 3965 } 3966 3967 void QCameraHardwareInterface::setExifTagsGPS() 3968 { 3969 const char *str = NULL; 3970 3971 //Set GPS processing method 3972 str = mParameters.get(QCameraParameters::KEY_GPS_PROCESSING_METHOD); 3973 if(str != NULL) { 3974 memcpy(mExifValues.gpsProcessingMethod, ExifAsciiPrefix, EXIF_ASCII_PREFIX_SIZE); 3975 strncpy(mExifValues.gpsProcessingMethod + EXIF_ASCII_PREFIX_SIZE, str, 3976 GPS_PROCESSING_METHOD_SIZE - 1); 3977 mExifValues.gpsProcessingMethod[EXIF_ASCII_PREFIX_SIZE + GPS_PROCESSING_METHOD_SIZE-1] = '\0'; 3978 ALOGE("EXIFTAGID_GPS_PROCESSINGMETHOD = %s %s", mExifValues.gpsProcessingMethod, 3979 mExifValues.gpsProcessingMethod+8); 3980 mExifValues.mGpsProcess = true; 3981 }else{ 3982 mExifValues.mGpsProcess = false; 3983 } 3984 str = NULL; 3985 3986 //Set Latitude 3987 str = mParameters.get(QCameraParameters::KEY_GPS_LATITUDE); 3988 if(str != NULL) { 3989 parseGPSCoordinate(str, mExifValues.latitude); 3990 ALOGE("EXIFTAGID_GPS_LATITUDE = %s", str); 3991 3992 //set Latitude Ref 3993 float latitudeValue = mParameters.getFloat(QCameraParameters::KEY_GPS_LATITUDE); 3994 if(latitudeValue < 0.0f) { 3995 mExifValues.latRef[0] = 'S'; 3996 } else { 3997 mExifValues.latRef[0] = 'N'; 3998 } 3999 mExifValues.latRef[1] = '\0'; 4000 mExifValues.mLatitude = true; 4001 mParameters.set(QCameraParameters::KEY_QC_GPS_LATITUDE_REF,mExifValues.latRef); 4002 ALOGE("EXIFTAGID_GPS_LATITUDE_REF = %s", mExifValues.latRef); 4003 }else{ 4004 mExifValues.mLatitude = false; 4005 } 4006 4007 //set Longitude 4008 str = NULL; 4009 str = mParameters.get(QCameraParameters::KEY_GPS_LONGITUDE); 4010 if(str != NULL) { 4011 parseGPSCoordinate(str, mExifValues.longitude); 4012 ALOGE("EXIFTAGID_GPS_LONGITUDE = %s", str); 4013 4014 //set Longitude Ref 4015 float longitudeValue = mParameters.getFloat(QCameraParameters::KEY_GPS_LONGITUDE); 4016 if(longitudeValue < 0.0f) { 4017 mExifValues.lonRef[0] = 'W'; 4018 } else { 4019 mExifValues.lonRef[0] = 'E'; 4020 } 4021 mExifValues.lonRef[1] = '\0'; 4022 mExifValues.mLongitude = true; 4023 ALOGE("EXIFTAGID_GPS_LONGITUDE_REF = %s", mExifValues.lonRef); 4024 mParameters.set(QCameraParameters::KEY_QC_GPS_LONGITUDE_REF, mExifValues.lonRef); 4025 }else{ 4026 mExifValues.mLongitude = false; 4027 } 4028 4029 //set Altitude 4030 str = mParameters.get(QCameraParameters::KEY_GPS_ALTITUDE); 4031 if(str != NULL) { 4032 double value = atof(str); 4033 mExifValues.mAltitude_ref = 0; 4034 if(value < 0){ 4035 mExifValues.mAltitude_ref = 1; 4036 value = -value; 4037 } 4038 mExifValues.altitude = getRational(value*1000, 1000); 4039 mExifValues.mAltitude = true; 4040 //set AltitudeRef 4041 mParameters.set(QCameraParameters::KEY_QC_GPS_ALTITUDE_REF, mExifValues.mAltitude_ref); 4042 ALOGE("EXIFTAGID_GPS_ALTITUDE = %f", value); 4043 }else{ 4044 mExifValues.mAltitude = false; 4045 } 4046 4047 //set Gps TimeStamp 4048 str = NULL; 4049 str = mParameters.get(QCameraParameters::KEY_GPS_TIMESTAMP); 4050 if(str != NULL) { 4051 mExifValues.mTimeStamp = true; 4052 mExifValues.mGPSTimestamp = atol(str); 4053 }else{ 4054 mExifValues.mTimeStamp = false; 4055 } 4056 } 4057 4058 //latlonString is string formatted coordinate 4059 //coord is rat_t[3] 4060 void QCameraHardwareInterface::parseGPSCoordinate(const char *latlonString, rat_t* coord) 4061 { 4062 if(coord == NULL) { 4063 ALOGE("%s: error, invalid argument coord == NULL", __func__); 4064 return; 4065 } 4066 float degF = fabs(atof(latlonString)); 4067 float minF = (degF- (int) degF) * 60; 4068 float secF = (minF - (int) minF) * 60; 4069 4070 coord[0] = getRational((int) degF, 1); 4071 coord[1] = getRational((int) minF, 1); 4072 coord[2] = getRational((int) (secF * 10000), 10000); 4073 } 4074 4075 bool QCameraHardwareInterface::isLowPowerCamcorder() { 4076 4077 if (mPowerMode == LOW_POWER) 4078 return true; 4079 4080 if(mHFRLevel > 1) /* hard code the value now. Need to move tgtcommon to camear.h */ 4081 return true; 4082 4083 return false; 4084 } 4085 4086 status_t QCameraHardwareInterface::setNoDisplayMode(const QCameraParameters& params) 4087 { 4088 char prop[PROPERTY_VALUE_MAX]; 4089 memset(prop, 0, sizeof(prop)); 4090 property_get("persist.camera.nodisplay", prop, "0"); 4091 int prop_val = atoi(prop); 4092 4093 if (prop_val == 0) { 4094 const char *str_val = params.get("no-display-mode"); 4095 if(str_val && strlen(str_val) > 0) { 4096 mNoDisplayMode = atoi(str_val); 4097 } else { 4098 mNoDisplayMode = 0; 4099 } 4100 ALOGD("Param mNoDisplayMode =%d", mNoDisplayMode); 4101 } else { 4102 mNoDisplayMode = prop_val; 4103 ALOGD("prop mNoDisplayMode =%d", mNoDisplayMode); 4104 } 4105 return NO_ERROR; 4106 } 4107 4108 status_t QCameraHardwareInterface::setRDIMode(const QCameraParameters& params) 4109 { 4110 char prop[PROPERTY_VALUE_MAX]; 4111 memset(prop, 0, sizeof(prop)); 4112 property_get("persist.camera.rdi.mode", prop, "0"); 4113 int prop_val = atoi(prop); 4114 rdiMode = prop_val; 4115 ALOGE("RDI Mode = %d",rdiMode); 4116 return NO_ERROR; 4117 } 4118 4119 status_t QCameraHardwareInterface::setDimension() 4120 { 4121 ALOGV("%s: E", __func__); 4122 cam_ctrl_dimension_t dim; 4123 int ret = MM_CAMERA_OK; 4124 int postviewWidth,postviewHeight; 4125 4126 memset(&dim, 0, sizeof(cam_ctrl_dimension_t)); 4127 ret = mCameraHandle->ops->get_parm(mCameraHandle->camera_handle, MM_CAMERA_PARM_DIMENSION,&dim); 4128 4129 if (MM_CAMERA_OK != ret) { 4130 ALOGE("%s: error - can't get preview dimension!", __func__); 4131 ALOGE("%s: X", __func__); 4132 return BAD_VALUE; 4133 } 4134 4135 getPreviewSize(&mPreviewWidth, &mPreviewHeight); 4136 dim.display_width = mPreviewWidth; 4137 dim.display_height = mPreviewHeight; 4138 4139 cam_format_t value = getPreviewFormat(); 4140 if(value != NOT_FOUND && value != dim.prev_format ) { 4141 //Setting to Parameter requested by the Upper layer 4142 dim.prev_format = value; 4143 }else{ 4144 //Setting to default Format. 4145 dim.prev_format = CAMERA_YUV_420_NV21; 4146 } 4147 dim.prev_padding_format = getPreviewPadding( ); 4148 4149 getVideoSize(&videoWidth, &videoHeight); 4150 dim.enc_format = CAMERA_YUV_420_NV12; 4151 dim.orig_video_width = videoWidth; 4152 dim.orig_video_height = videoHeight; 4153 dim.video_width = videoWidth; 4154 dim.video_height = videoHeight; 4155 dim.video_chroma_width = videoWidth; 4156 dim.video_chroma_height = videoHeight; 4157 4158 getPictureSize(&mPictureWidth, &mPictureHeight); 4159 dim.picture_width = mPictureWidth; 4160 dim.picture_height = mPictureHeight; 4161 4162 getThumbnailSize(&thumbnailWidth,&thumbnailHeight); 4163 dim.ui_thumbnail_width = thumbnailWidth; 4164 dim.ui_thumbnail_height = thumbnailHeight; 4165 4166 /* Reset the Main image and thumbnail formats here, 4167 * since they might have been changed when video size 4168 * livesnapshot was taken. */ 4169 if (mSnapshotFormat == 1) 4170 dim.main_img_format = CAMERA_YUV_422_NV61; 4171 else 4172 dim.main_img_format = CAMERA_YUV_420_NV21; 4173 dim.thumb_format = CAMERA_YUV_420_NV21; 4174 4175 //RDI Format 4176 dim.rdi0_format = CAMERA_BAYER_SBGGR10; 4177 4178 /*Code to handle different limitations*/ 4179 if (mRecordingHint && mFullLiveshotEnabled){ 4180 dim.ui_thumbnail_height = dim.display_height; 4181 dim.ui_thumbnail_width = dim.display_width; 4182 } 4183 if (isZSLMode()){ 4184 postviewWidth = mPreviewWidth; 4185 postviewHeight = mPreviewHeight; 4186 } else { 4187 postviewWidth = thumbnailWidth; 4188 postviewHeight = thumbnailHeight; 4189 } 4190 if (mPictureWidth < postviewWidth || mPictureHeight < postviewHeight) 4191 { 4192 //Changes to handle VFE limitation when primary o/p is main image 4193 dim.picture_width = postviewWidth; 4194 dim.picture_height = postviewHeight; 4195 } 4196 4197 //VFE output1 shouldn't be greater than VFE output2. 4198 if( (dim.display_width > dim.video_width) || 4199 (dim.display_height > dim.video_height)) { 4200 //Set preview sizes as record sizes. 4201 dim.display_width = dim.video_width; 4202 dim.display_height = dim.video_height; 4203 } 4204 if (mRecordingHint && mFullLiveshotEnabled){ 4205 if( (dim.picture_width < dim.video_width) || 4206 (dim.picture_height < dim.video_height)) { 4207 dim.picture_width = dim.video_width; 4208 dim.picture_height = dim.video_height; 4209 } 4210 } 4211 4212 if(mIs3DModeOn == true) { 4213 /* As preview and video frames are same in 3D mode, 4214 * preview size should be same as video size. This 4215 * cahnge is needed to take of video resolutions 4216 * like 720P and 1080p where the application can 4217 * request different preview sizes like 768x432 4218 */ 4219 ALOGE("3D mod is on"); 4220 dim.display_width = dim.video_width; 4221 dim.display_height = dim.video_height; 4222 } 4223 4224 /*End of limitation code*/ 4225 4226 ret = mCameraHandle->ops->set_parm(mCameraHandle->camera_handle, MM_CAMERA_PARM_DIMENSION,&dim); 4227 if (MM_CAMERA_OK != ret) { 4228 ALOGE("%s X: error - can't config preview parms!", __func__); 4229 return BAD_VALUE; 4230 } 4231 if(mStreams[MM_CAMERA_PREVIEW]) { 4232 mStreams[MM_CAMERA_PREVIEW]->mFormat = dim.prev_format; 4233 mStreams[MM_CAMERA_PREVIEW]->mWidth = dim.display_width; 4234 mStreams[MM_CAMERA_PREVIEW]->mHeight = dim.display_height; 4235 } 4236 if(mStreams[MM_CAMERA_VIDEO]) { 4237 mStreams[MM_CAMERA_VIDEO]->mFormat = dim.enc_format; 4238 mStreams[MM_CAMERA_VIDEO]->mWidth = dim.video_width; 4239 mStreams[MM_CAMERA_VIDEO]->mHeight = dim.video_height; 4240 } 4241 if(mStreams[MM_CAMERA_SNAPSHOT_MAIN]) { 4242 mStreams[MM_CAMERA_SNAPSHOT_MAIN]->mFormat = dim.main_img_format; 4243 if (!isRawSnapshot()) { 4244 mStreams[MM_CAMERA_SNAPSHOT_MAIN]->mWidth = dim.picture_width; 4245 mStreams[MM_CAMERA_SNAPSHOT_MAIN]->mHeight = dim.picture_height; 4246 } else { 4247 cam_frame_resolution_t raw_res; 4248 4249 /* the raw_picture_width in dimension is for RDI dump. 4250 * here, raw snapshot size is from camif. */ 4251 memset(&raw_res, 0, sizeof(raw_res)); 4252 raw_res.image_mode = MSM_V4L2_EXT_CAPTURE_MODE_RAW; 4253 raw_res.padding_format = CAMERA_PAD_TO_WORD; 4254 ret = mCameraHandle->ops->get_parm( 4255 mCameraHandle->camera_handle, 4256 MM_CAMERA_PARM_FRAME_RESOLUTION,&raw_res); 4257 if (MM_CAMERA_OK != ret) { 4258 ALOGE("%s error - config raw snapshot parms, rc = %d", 4259 __func__, ret); 4260 return BAD_VALUE; 4261 } 4262 mStreams[MM_CAMERA_SNAPSHOT_MAIN]->mWidth = raw_res.width; 4263 mStreams[MM_CAMERA_SNAPSHOT_MAIN]->mHeight = raw_res.height; 4264 mStreams[MM_CAMERA_SNAPSHOT_MAIN]->mFormat = raw_res.format; 4265 } 4266 } 4267 if(mStreams[MM_CAMERA_SNAPSHOT_THUMBNAIL]) { 4268 mStreams[MM_CAMERA_SNAPSHOT_THUMBNAIL]->mFormat = dim.thumb_format; 4269 mStreams[MM_CAMERA_SNAPSHOT_THUMBNAIL]->mWidth = dim.ui_thumbnail_width; 4270 mStreams[MM_CAMERA_SNAPSHOT_THUMBNAIL]->mHeight = dim.ui_thumbnail_height; 4271 } 4272 4273 memcpy(&mDimension, &dim, sizeof(mDimension)); 4274 ALOGV("%s: X", __func__); 4275 return NO_ERROR; 4276 } 4277 }; /*namespace android */ 4278