1 /*
2  * Copyright (C) Texas Instruments - http://www.ti.com/
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /**
18 * @file OMX3A.cpp
19 *
20 * This file contains functionality for handling 3A configurations.
21 *
22 */
23 
24 #undef LOG_TAG
25 
26 #define LOG_TAG "CameraHAL"
27 
28 #include "CameraHal.h"
29 #include "OMXCameraAdapter.h"
30 #include "ErrorUtils.h"
31 
32 #include <cutils/properties.h>
33 
34 #undef TRUE
35 #undef FALSE
36 #define TRUE "true"
37 #define FALSE "false"
38 
39 #define METERING_AREAS_RANGE 0xFF
40 
41 namespace android {
getSceneModeEntry(const char * name,OMX_SCENEMODETYPE scene)42 const SceneModesEntry* OMXCameraAdapter::getSceneModeEntry(const char* name,
43                                                                   OMX_SCENEMODETYPE scene) {
44     const SceneModesEntry* cameraLUT = NULL;
45     const SceneModesEntry* entry = NULL;
46     unsigned int numEntries = 0;
47 
48     // 1. Find camera's scene mode LUT
49     for (unsigned int i = 0; i < ARRAY_SIZE(CameraToSensorModesLUT); i++) {
50         if (strcmp(CameraToSensorModesLUT[i].name, name) == 0) {
51             cameraLUT = CameraToSensorModesLUT[i].Table;
52             numEntries = CameraToSensorModesLUT[i].size;
53             break;
54         }
55     }
56 
57     // 2. Find scene mode entry in table
58     if (!cameraLUT) {
59         goto EXIT;
60     }
61 
62     for (unsigned int i = 0; i < numEntries; i++) {
63         if(cameraLUT[i].scene == scene) {
64             entry = cameraLUT + i;
65             break;
66         }
67     }
68  EXIT:
69     return entry;
70 }
71 
setParameters3A(const CameraParameters & params,BaseCameraAdapter::AdapterState state)72 status_t OMXCameraAdapter::setParameters3A(const CameraParameters &params,
73                                            BaseCameraAdapter::AdapterState state)
74 {
75     status_t ret = NO_ERROR;
76     int mode = 0;
77     const char *str = NULL;
78     int varint = 0;
79     BaseCameraAdapter::AdapterState nextState;
80     BaseCameraAdapter::getNextState(nextState);
81 
82     LOG_FUNCTION_NAME;
83 
84     Mutex::Autolock lock(m3ASettingsUpdateLock);
85 
86     str = params.get(CameraParameters::KEY_SCENE_MODE);
87     mode = getLUTvalue_HALtoOMX( str, SceneLUT);
88     if ( mFirstTimeInit || ((str != NULL) && ( mParameters3A.SceneMode != mode )) ) {
89         if ( 0 <= mode ) {
90             mParameters3A.SceneMode = mode;
91             if ((mode == OMX_Manual) && (mFirstTimeInit == false)){//Auto mode
92                 mFirstTimeInit = true;
93             }
94             if ((mode != OMX_Manual) &&
95                 (state & PREVIEW_ACTIVE) && !(nextState & CAPTURE_ACTIVE)) {
96                 // if setting preset scene mode, previewing, and not in the middle of capture
97                 // set preset scene mode immediately instead of in next FBD
98                 // for feedback params to work properly since they need to be read
99                 // by application in subsequent getParameters()
100                 ret |= setScene(mParameters3A);
101                 // re-apply EV compensation after setting scene mode since it probably reset it
102                 if(mParameters3A.EVCompensation) {
103                    setEVCompensation(mParameters3A);
104                 }
105                 return ret;
106             } else {
107                 mPending3Asettings |= SetSceneMode;
108             }
109         } else {
110             mParameters3A.SceneMode = OMX_Manual;
111         }
112         CAMHAL_LOGVB("SceneMode %d", mParameters3A.SceneMode);
113     }
114 
115 #ifdef OMAP_ENHANCEMENT
116 
117     str = params.get(TICameraParameters::KEY_EXPOSURE_MODE);
118     mode = getLUTvalue_HALtoOMX( str, ExpLUT);
119     if ( ( str != NULL ) && ( mParameters3A.Exposure != mode ))
120         {
121         mParameters3A.Exposure = mode;
122         CAMHAL_LOGDB("Exposure mode %d", mode);
123         if ( 0 <= mParameters3A.Exposure )
124             {
125             mPending3Asettings |= SetExpMode;
126             }
127         }
128 
129 #endif
130 
131     str = params.get(CameraParameters::KEY_WHITE_BALANCE);
132     mode = getLUTvalue_HALtoOMX( str, WBalLUT);
133     if (mFirstTimeInit || ((str != NULL) && (mode != mParameters3A.WhiteBallance)))
134         {
135         mParameters3A.WhiteBallance = mode;
136         CAMHAL_LOGDB("Whitebalance mode %d", mode);
137         if ( 0 <= mParameters3A.WhiteBallance )
138             {
139             mPending3Asettings |= SetWhiteBallance;
140             }
141         }
142 
143 #ifdef OMAP_ENHANCEMENT
144 
145     varint = params.getInt(TICameraParameters::KEY_CONTRAST);
146     if ( 0 <= varint )
147         {
148         if ( mFirstTimeInit ||
149              ( (mParameters3A.Contrast  + CONTRAST_OFFSET) != varint ) )
150             {
151             mParameters3A.Contrast = varint - CONTRAST_OFFSET;
152             CAMHAL_LOGDB("Contrast %d", mParameters3A.Contrast);
153             mPending3Asettings |= SetContrast;
154             }
155         }
156 
157     varint = params.getInt(TICameraParameters::KEY_SHARPNESS);
158     if ( 0 <= varint )
159         {
160         if ( mFirstTimeInit ||
161              ((mParameters3A.Sharpness + SHARPNESS_OFFSET) != varint ))
162             {
163             mParameters3A.Sharpness = varint - SHARPNESS_OFFSET;
164             CAMHAL_LOGDB("Sharpness %d", mParameters3A.Sharpness);
165             mPending3Asettings |= SetSharpness;
166             }
167         }
168 
169     varint = params.getInt(TICameraParameters::KEY_SATURATION);
170     if ( 0 <= varint )
171         {
172         if ( mFirstTimeInit ||
173              ((mParameters3A.Saturation + SATURATION_OFFSET) != varint ) )
174             {
175             mParameters3A.Saturation = varint - SATURATION_OFFSET;
176             CAMHAL_LOGDB("Saturation %d", mParameters3A.Saturation);
177             mPending3Asettings |= SetSaturation;
178             }
179         }
180 
181     varint = params.getInt(TICameraParameters::KEY_BRIGHTNESS);
182     if ( 0 <= varint )
183         {
184         if ( mFirstTimeInit ||
185              (( mParameters3A.Brightness != varint )) )
186             {
187             mParameters3A.Brightness = (unsigned) varint;
188             CAMHAL_LOGDB("Brightness %d", mParameters3A.Brightness);
189             mPending3Asettings |= SetBrightness;
190             }
191         }
192 
193 #endif
194 
195     str = params.get(CameraParameters::KEY_ANTIBANDING);
196     mode = getLUTvalue_HALtoOMX(str,FlickerLUT);
197     if ( mFirstTimeInit || ( ( str != NULL ) && ( mParameters3A.Flicker != mode ) ))
198         {
199         mParameters3A.Flicker = mode;
200         CAMHAL_LOGDB("Flicker %d", mParameters3A.Flicker);
201         if ( 0 <= mParameters3A.Flicker )
202             {
203             mPending3Asettings |= SetFlicker;
204             }
205         }
206 
207 #ifdef OMAP_ENHANCEMENT
208 
209     str = params.get(TICameraParameters::KEY_ISO);
210     mode = getLUTvalue_HALtoOMX(str, IsoLUT);
211     CAMHAL_LOGVB("ISO mode arrived in HAL : %s", str);
212     if ( mFirstTimeInit || (  ( str != NULL ) && ( mParameters3A.ISO != mode )) )
213         {
214         mParameters3A.ISO = mode;
215         CAMHAL_LOGDB("ISO %d", mParameters3A.ISO);
216         if ( 0 <= mParameters3A.ISO )
217             {
218             mPending3Asettings |= SetISO;
219             }
220         }
221 
222 #endif
223 
224     str = params.get(CameraParameters::KEY_FOCUS_MODE);
225     mode = getLUTvalue_HALtoOMX(str, FocusLUT);
226     if ( (mFirstTimeInit || ((str != NULL) && (mParameters3A.Focus != mode))))
227         {
228         mPending3Asettings |= SetFocus;
229 
230         mParameters3A.Focus = mode;
231 
232         // if focus mode is set to infinity...update focus distance immediately
233         if (mode == OMX_IMAGE_FocusControlAutoInfinity) {
234             updateFocusDistances(mParameters);
235         }
236 
237         CAMHAL_LOGDB("Focus %x", mParameters3A.Focus);
238         }
239 
240     str = params.get(CameraParameters::KEY_EXPOSURE_COMPENSATION);
241     varint = params.getInt(CameraParameters::KEY_EXPOSURE_COMPENSATION);
242     if ( mFirstTimeInit ||
243           (( str != NULL ) &&
244                   (mParameters3A.EVCompensation != varint )))
245         {
246         CAMHAL_LOGDB("Setting EV Compensation to %d", varint);
247 
248         mParameters3A.EVCompensation = varint;
249         mPending3Asettings |= SetEVCompensation;
250         }
251 
252     str = params.get(CameraParameters::KEY_FLASH_MODE);
253     mode = getLUTvalue_HALtoOMX( str, FlashLUT);
254     if (  mFirstTimeInit || (( str != NULL ) && ( mParameters3A.FlashMode != mode )) )
255         {
256         if ( 0 <= mode )
257             {
258             mParameters3A.FlashMode = mode;
259             mPending3Asettings |= SetFlash;
260             }
261         else
262             {
263             mParameters3A.FlashMode = OMX_Manual;
264             }
265         }
266 
267     CAMHAL_LOGVB("Flash Setting %s", str);
268     CAMHAL_LOGVB("FlashMode %d", mParameters3A.FlashMode);
269 
270     str = params.get(CameraParameters::KEY_EFFECT);
271     mode = getLUTvalue_HALtoOMX( str, EffLUT);
272     if (  mFirstTimeInit || (( str != NULL ) && ( mParameters3A.Effect != mode )) )
273         {
274         mParameters3A.Effect = mode;
275         CAMHAL_LOGDB("Effect %d", mParameters3A.Effect);
276         if ( 0 <= mParameters3A.Effect )
277             {
278             mPending3Asettings |= SetEffect;
279             }
280         }
281 
282     str = params.get(CameraParameters::KEY_AUTO_EXPOSURE_LOCK_SUPPORTED);
283     if ( (str != NULL) && (!strcmp(str, "true")) )
284       {
285         OMX_BOOL lock = OMX_FALSE;
286         mUserSetExpLock = OMX_FALSE;
287         str = params.get(CameraParameters::KEY_AUTO_EXPOSURE_LOCK);
288         if (str && ((strcmp(str, "true")) == 0))
289           {
290             CAMHAL_LOGVA("Locking Exposure");
291             lock = OMX_TRUE;
292             mUserSetExpLock = OMX_TRUE;
293           }
294         else
295           {
296             CAMHAL_LOGVA("UnLocking Exposure");
297           }
298 
299         if (mParameters3A.ExposureLock != lock)
300           {
301             mParameters3A.ExposureLock = lock;
302             CAMHAL_LOGDB("ExposureLock %d", lock);
303             mPending3Asettings |= SetExpLock;
304           }
305       }
306 
307     str = params.get(CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK_SUPPORTED);
308     if ( (str != NULL) && (!strcmp(str, "true")) )
309       {
310         OMX_BOOL lock = OMX_FALSE;
311         mUserSetWbLock = OMX_FALSE;
312         str = params.get(CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK);
313         if (str && ((strcmp(str, "true")) == 0))
314           {
315             CAMHAL_LOGVA("Locking WhiteBalance");
316             lock = OMX_TRUE;
317             mUserSetWbLock = OMX_TRUE;
318           }
319         else
320           {
321             CAMHAL_LOGVA("UnLocking WhiteBalance");
322           }
323         if (mParameters3A.WhiteBalanceLock != lock)
324           {
325             mParameters3A.WhiteBalanceLock = lock;
326             CAMHAL_LOGDB("WhiteBalanceLock %d", lock);
327             mPending3Asettings |= SetWBLock;
328           }
329       }
330 
331     str = params.get(TICameraParameters::KEY_AUTO_FOCUS_LOCK);
332     if (str && (strcmp(str, TRUE) == 0) && (mParameters3A.FocusLock != OMX_TRUE)) {
333         CAMHAL_LOGVA("Locking Focus");
334         mParameters3A.FocusLock = OMX_TRUE;
335         setFocusLock(mParameters3A);
336     } else if (str && (strcmp(str, FALSE) == 0) && (mParameters3A.FocusLock != OMX_FALSE)) {
337         CAMHAL_LOGVA("UnLocking Focus");
338         mParameters3A.FocusLock = OMX_FALSE;
339         setFocusLock(mParameters3A);
340     }
341 
342     str = params.get(CameraParameters::KEY_METERING_AREAS);
343     if ( (str != NULL) ) {
344         size_t MAX_METERING_AREAS;
345         Vector< sp<CameraArea> > tempAreas;
346 
347         MAX_METERING_AREAS = atoi(params.get(CameraParameters::KEY_MAX_NUM_METERING_AREAS));
348 
349         Mutex::Autolock lock(mMeteringAreasLock);
350 
351         ret = CameraArea::parseAreas(str, ( strlen(str) + 1 ), tempAreas);
352 
353         CAMHAL_LOGVB("areAreasDifferent? = %d",
354                      CameraArea::areAreasDifferent(mMeteringAreas, tempAreas));
355 
356         if ( (NO_ERROR == ret) && CameraArea::areAreasDifferent(mMeteringAreas, tempAreas) ) {
357             mMeteringAreas.clear();
358             mMeteringAreas = tempAreas;
359 
360             if ( MAX_METERING_AREAS >= mMeteringAreas.size() ) {
361                 CAMHAL_LOGDB("Setting Metering Areas %s",
362                         params.get(CameraParameters::KEY_METERING_AREAS));
363 
364                 mPending3Asettings |= SetMeteringAreas;
365             } else {
366                 CAMHAL_LOGEB("Metering areas supported %d, metering areas set %d",
367                              MAX_METERING_AREAS, mMeteringAreas.size());
368                 ret = -EINVAL;
369             }
370         }
371     }
372 
373     LOG_FUNCTION_NAME_EXIT;
374 
375     return ret;
376 }
377 
getLUTvalue_HALtoOMX(const char * HalValue,LUTtype LUT)378 int OMXCameraAdapter::getLUTvalue_HALtoOMX(const char * HalValue, LUTtype LUT)
379 {
380     int LUTsize = LUT.size;
381     if( HalValue )
382         for(int i = 0; i < LUTsize; i++)
383             if( 0 == strcmp(LUT.Table[i].userDefinition, HalValue) )
384                 return LUT.Table[i].omxDefinition;
385 
386     return -ENOENT;
387 }
388 
getLUTvalue_OMXtoHAL(int OMXValue,LUTtype LUT)389 const char* OMXCameraAdapter::getLUTvalue_OMXtoHAL(int OMXValue, LUTtype LUT)
390 {
391     int LUTsize = LUT.size;
392     for(int i = 0; i < LUTsize; i++)
393         if( LUT.Table[i].omxDefinition == OMXValue )
394             return LUT.Table[i].userDefinition;
395 
396     return NULL;
397 }
398 
init3AParams(Gen3A_settings & Gen3A)399 status_t OMXCameraAdapter::init3AParams(Gen3A_settings &Gen3A)
400 {
401     LOG_FUNCTION_NAME;
402 
403     Gen3A.Effect = getLUTvalue_HALtoOMX(OMXCameraAdapter::DEFAULT_EFFECT, EffLUT);
404     Gen3A.FlashMode = getLUTvalue_HALtoOMX(OMXCameraAdapter::DEFAULT_FLASH_MODE, FlashLUT);
405     Gen3A.SceneMode = getLUTvalue_HALtoOMX(OMXCameraAdapter::DEFAULT_SCENE_MODE, SceneLUT);
406     Gen3A.EVCompensation = atoi(OMXCameraAdapter::DEFAULT_EV_COMPENSATION);
407     Gen3A.Focus = getLUTvalue_HALtoOMX(OMXCameraAdapter::DEFAULT_FOCUS_MODE, FocusLUT);
408     Gen3A.ISO = getLUTvalue_HALtoOMX(OMXCameraAdapter::DEFAULT_ISO_MODE, IsoLUT);
409     Gen3A.Flicker = getLUTvalue_HALtoOMX(OMXCameraAdapter::DEFAULT_ANTIBANDING, FlickerLUT);
410     Gen3A.Brightness = atoi(OMXCameraAdapter::DEFAULT_BRIGHTNESS);
411     Gen3A.Saturation = atoi(OMXCameraAdapter::DEFAULT_SATURATION) - SATURATION_OFFSET;
412     Gen3A.Sharpness = atoi(OMXCameraAdapter::DEFAULT_SHARPNESS) - SHARPNESS_OFFSET;
413     Gen3A.Contrast = atoi(OMXCameraAdapter::DEFAULT_CONTRAST) - CONTRAST_OFFSET;
414     Gen3A.WhiteBallance = getLUTvalue_HALtoOMX(OMXCameraAdapter::DEFAULT_WB, WBalLUT);
415     Gen3A.Exposure = getLUTvalue_HALtoOMX(OMXCameraAdapter::DEFAULT_EXPOSURE_MODE, ExpLUT);
416     Gen3A.ExposureLock = OMX_FALSE;
417     Gen3A.FocusLock = OMX_FALSE;
418     Gen3A.WhiteBalanceLock = OMX_FALSE;
419 
420     LOG_FUNCTION_NAME_EXIT;
421 
422     return NO_ERROR;
423 }
424 
setExposureMode(Gen3A_settings & Gen3A)425 status_t OMXCameraAdapter::setExposureMode(Gen3A_settings& Gen3A)
426 {
427     OMX_ERRORTYPE eError = OMX_ErrorNone;
428     OMX_CONFIG_EXPOSURECONTROLTYPE exp;
429 
430     LOG_FUNCTION_NAME;
431 
432     if ( OMX_StateInvalid == mComponentState )
433         {
434         CAMHAL_LOGEA("OMX component is in invalid state");
435         return NO_INIT;
436         }
437 
438     OMX_INIT_STRUCT_PTR (&exp, OMX_CONFIG_EXPOSURECONTROLTYPE);
439     exp.nPortIndex = OMX_ALL;
440     exp.eExposureControl = (OMX_EXPOSURECONTROLTYPE)Gen3A.Exposure;
441 
442     eError =  OMX_SetConfig(mCameraAdapterParameters.mHandleComp,
443                             OMX_IndexConfigCommonExposure,
444                             &exp);
445     if ( OMX_ErrorNone != eError )
446         {
447         CAMHAL_LOGEB("Error while configuring exposure mode 0x%x", eError);
448         }
449     else
450         {
451         CAMHAL_LOGDA("Camera exposure mode configured successfully");
452         }
453 
454     LOG_FUNCTION_NAME_EXIT;
455 
456     return ErrorUtils::omxToAndroidError(eError);
457 }
458 
isFlashDisabled()459 static bool isFlashDisabled() {
460 #if (PROPERTY_VALUE_MAX < 5)
461 #error "PROPERTY_VALUE_MAX must be at least 5"
462 #endif
463 
464     // Ignore flash_off system property for user build.
465     char buildType[PROPERTY_VALUE_MAX];
466     if (property_get("ro.build.type", buildType, NULL) &&
467         !strcasecmp(buildType, "user")) {
468         return false;
469     }
470 
471     char value[PROPERTY_VALUE_MAX];
472     if (property_get("camera.flash_off", value, NULL) &&
473         (!strcasecmp(value, "true") || !strcasecmp(value, "1"))) {
474         ALOGW("flash is disabled for testing purpose");
475         return true;
476     }
477 
478     return false;
479 }
480 
setFlashMode(Gen3A_settings & Gen3A)481 status_t OMXCameraAdapter::setFlashMode(Gen3A_settings& Gen3A)
482 {
483     status_t ret = NO_ERROR;
484     OMX_ERRORTYPE eError = OMX_ErrorNone;
485     OMX_IMAGE_PARAM_FLASHCONTROLTYPE flash;
486     OMX_CONFIG_FOCUSASSISTTYPE focusAssist;
487 
488     LOG_FUNCTION_NAME;
489 
490     if ( OMX_StateInvalid == mComponentState )
491         {
492         CAMHAL_LOGEA("OMX component is in invalid state");
493         return NO_INIT;
494         }
495 
496     OMX_INIT_STRUCT_PTR (&flash, OMX_IMAGE_PARAM_FLASHCONTROLTYPE);
497     flash.nPortIndex = OMX_ALL;
498 
499     if (isFlashDisabled()) {
500         flash.eFlashControl = ( OMX_IMAGE_FLASHCONTROLTYPE ) OMX_IMAGE_FlashControlOff;
501     } else {
502         flash.eFlashControl = ( OMX_IMAGE_FLASHCONTROLTYPE ) Gen3A.FlashMode;
503     }
504 
505     CAMHAL_LOGDB("Configuring flash mode 0x%x", flash.eFlashControl);
506     eError =  OMX_SetConfig(mCameraAdapterParameters.mHandleComp,
507                             (OMX_INDEXTYPE) OMX_IndexConfigFlashControl,
508                             &flash);
509     if ( OMX_ErrorNone != eError )
510         {
511         CAMHAL_LOGEB("Error while configuring flash mode 0x%x", eError);
512         }
513     else
514         {
515         CAMHAL_LOGDA("Camera flash mode configured successfully");
516         }
517 
518     if ( OMX_ErrorNone == eError )
519         {
520         OMX_INIT_STRUCT_PTR (&focusAssist, OMX_CONFIG_FOCUSASSISTTYPE);
521         focusAssist.nPortIndex = OMX_ALL;
522         if ( flash.eFlashControl == OMX_IMAGE_FlashControlOff )
523             {
524             focusAssist.bFocusAssist = OMX_FALSE;
525             }
526         else
527             {
528             focusAssist.bFocusAssist = OMX_TRUE;
529             }
530 
531         CAMHAL_LOGDB("Configuring AF Assist mode 0x%x", focusAssist.bFocusAssist);
532         eError =  OMX_SetConfig(mCameraAdapterParameters.mHandleComp,
533                                 (OMX_INDEXTYPE) OMX_IndexConfigFocusAssist,
534                                 &focusAssist);
535         if ( OMX_ErrorNone != eError )
536             {
537             CAMHAL_LOGEB("Error while configuring AF Assist mode 0x%x", eError);
538             }
539         else
540             {
541             CAMHAL_LOGDA("Camera AF Assist  mode configured successfully");
542             }
543         }
544 
545     LOG_FUNCTION_NAME_EXIT;
546 
547     return ErrorUtils::omxToAndroidError(eError);
548 }
549 
getFlashMode(Gen3A_settings & Gen3A)550 status_t OMXCameraAdapter::getFlashMode(Gen3A_settings& Gen3A)
551 {
552     status_t ret = NO_ERROR;
553     OMX_ERRORTYPE eError = OMX_ErrorNone;
554     OMX_IMAGE_PARAM_FLASHCONTROLTYPE flash;
555 
556     LOG_FUNCTION_NAME;
557 
558     if ( OMX_StateInvalid == mComponentState ) {
559         CAMHAL_LOGEA("OMX component is in invalid state");
560         return NO_INIT;
561     }
562 
563     OMX_INIT_STRUCT_PTR (&flash, OMX_IMAGE_PARAM_FLASHCONTROLTYPE);
564     flash.nPortIndex = OMX_ALL;
565 
566     eError =  OMX_GetConfig(mCameraAdapterParameters.mHandleComp,
567                             (OMX_INDEXTYPE) OMX_IndexConfigFlashControl,
568                             &flash);
569 
570     if ( OMX_ErrorNone != eError ) {
571         CAMHAL_LOGEB("Error while getting flash mode 0x%x", eError);
572     } else {
573         Gen3A.FlashMode = flash.eFlashControl;
574         CAMHAL_LOGDB("Gen3A.FlashMode 0x%x", Gen3A.FlashMode);
575     }
576 
577     LOG_FUNCTION_NAME_EXIT;
578 
579     return ErrorUtils::omxToAndroidError(eError);
580 }
581 
setFocusMode(Gen3A_settings & Gen3A)582 status_t OMXCameraAdapter::setFocusMode(Gen3A_settings& Gen3A)
583 {
584     status_t ret = NO_ERROR;
585     OMX_ERRORTYPE eError = OMX_ErrorNone;
586     OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE focus;
587     size_t top, left, width, height, weight;
588     OMX_CONFIG_BOOLEANTYPE bOMX;
589 
590     LOG_FUNCTION_NAME;
591 
592     BaseCameraAdapter::AdapterState state;
593     BaseCameraAdapter::getState(state);
594 
595     if ( OMX_StateInvalid == mComponentState )
596         {
597         CAMHAL_LOGEA("OMX component is in invalid state");
598         return NO_INIT;
599         }
600 
601 
602     ///Face detection takes precedence over touch AF
603     if ( mFaceDetectionRunning )
604         {
605         //Disable region priority first
606         setAlgoPriority(REGION_PRIORITY, FOCUS_ALGO, false);
607 
608         //Enable face algorithm priority for focus
609         setAlgoPriority(FACE_PRIORITY, FOCUS_ALGO , true);
610 
611         //Do normal focus afterwards
612         ////FIXME: Check if the extended focus control is needed? this overrides caf
613         //focusControl.eFocusControl = ( OMX_IMAGE_FOCUSCONTROLTYPE ) OMX_IMAGE_FocusControlExtended;
614         }
615     else if ( (!mFocusAreas.isEmpty()) && (!mFocusAreas.itemAt(0)->isZeroArea()) )
616         {
617 
618         //Disable face priority first
619         setAlgoPriority(FACE_PRIORITY, FOCUS_ALGO, false);
620 
621         //Enable region algorithm priority
622         setAlgoPriority(REGION_PRIORITY, FOCUS_ALGO, true);
623 
624 
625         //Do normal focus afterwards
626         //FIXME: Check if the extended focus control is needed? this overrides caf
627         //focus.eFocusControl = ( OMX_IMAGE_FOCUSCONTROLTYPE ) OMX_IMAGE_FocusControlExtended;
628 
629         }
630     else
631         {
632 
633         //Disable both region and face priority
634         setAlgoPriority(REGION_PRIORITY, FOCUS_ALGO, false);
635 
636         setAlgoPriority(FACE_PRIORITY, FOCUS_ALGO, false);
637 
638         }
639 
640     if ( NO_ERROR == ret && ((state & AF_ACTIVE) == 0) )
641         {
642         OMX_INIT_STRUCT_PTR (&bOMX, OMX_CONFIG_BOOLEANTYPE);
643 
644         if ( Gen3A.Focus == OMX_IMAGE_FocusControlAutoInfinity)
645             {
646             // Don't lock at infinity, otherwise the AF cannot drive
647             // the lens at infinity position
648             if( set3ALock(mUserSetExpLock, mUserSetWbLock, OMX_FALSE) != NO_ERROR)
649                 {
650                 CAMHAL_LOGEA("Error Applying 3A locks");
651                 } else {
652                 CAMHAL_LOGDA("Focus locked. Applied focus locks successfully");
653                 }
654             }
655         if ( Gen3A.Focus == OMX_IMAGE_FocusControlAuto ||
656              Gen3A.Focus == OMX_IMAGE_FocusControlAutoInfinity)
657             {
658             // Run focus scanning if switching to continuous infinity focus mode
659             bOMX.bEnabled = OMX_TRUE;
660             }
661         else
662             {
663             bOMX.bEnabled = OMX_FALSE;
664             }
665 
666         eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp,
667                                (OMX_INDEXTYPE)OMX_TI_IndexConfigAutofocusEnable,
668                                &bOMX);
669 
670         OMX_INIT_STRUCT_PTR (&focus, OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE);
671         focus.nPortIndex = mCameraAdapterParameters.mPrevPortIndex;
672         focus.eFocusControl = (OMX_IMAGE_FOCUSCONTROLTYPE)Gen3A.Focus;
673 
674         CAMHAL_LOGDB("Configuring focus mode 0x%x", focus.eFocusControl);
675         eError = OMX_SetConfig( mCameraAdapterParameters.mHandleComp, OMX_IndexConfigFocusControl, &focus);
676         if ( OMX_ErrorNone != eError )
677             {
678             CAMHAL_LOGEB("Error while configuring focus mode 0x%x", eError);
679             }
680         else
681             {
682             CAMHAL_LOGDA("Camera focus mode configured successfully");
683             }
684         }
685 
686     LOG_FUNCTION_NAME_EXIT;
687 
688     return ErrorUtils::omxToAndroidError(eError);
689 }
690 
getFocusMode(Gen3A_settings & Gen3A)691 status_t OMXCameraAdapter::getFocusMode(Gen3A_settings& Gen3A)
692 {
693     status_t ret = NO_ERROR;
694     OMX_ERRORTYPE eError = OMX_ErrorNone;
695     OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE focus;
696     size_t top, left, width, height, weight;
697 
698     LOG_FUNCTION_NAME;
699 
700     if (OMX_StateInvalid == mComponentState) {
701         CAMHAL_LOGEA("OMX component is in invalid state");
702         return NO_INIT;
703     }
704 
705     OMX_INIT_STRUCT_PTR (&focus, OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE);
706     focus.nPortIndex = mCameraAdapterParameters.mPrevPortIndex;
707     eError = OMX_GetConfig(mCameraAdapterParameters.mHandleComp,
708                            OMX_IndexConfigFocusControl, &focus);
709 
710     if (OMX_ErrorNone != eError) {
711         CAMHAL_LOGEB("Error while configuring focus mode 0x%x", eError);
712     } else {
713         Gen3A.Focus = focus.eFocusControl;
714         CAMHAL_LOGDB("Gen3A.Focus 0x%x", Gen3A.Focus);
715     }
716 
717     LOG_FUNCTION_NAME_EXIT;
718 
719     return ErrorUtils::omxToAndroidError(eError);
720 }
721 
setScene(Gen3A_settings & Gen3A)722 status_t OMXCameraAdapter::setScene(Gen3A_settings& Gen3A)
723 {
724     OMX_ERRORTYPE eError = OMX_ErrorNone;
725     OMX_CONFIG_SCENEMODETYPE scene;
726 
727     LOG_FUNCTION_NAME;
728 
729     if ( OMX_StateInvalid == mComponentState )
730         {
731         CAMHAL_LOGEA("OMX component is in invalid state");
732         return NO_INIT;
733         }
734 
735     OMX_INIT_STRUCT_PTR (&scene, OMX_CONFIG_SCENEMODETYPE);
736     scene.nPortIndex = OMX_ALL;
737     scene.eSceneMode = ( OMX_SCENEMODETYPE ) Gen3A.SceneMode;
738 
739     CAMHAL_LOGDB("Configuring scene mode 0x%x", scene.eSceneMode);
740     eError =  OMX_SetConfig(mCameraAdapterParameters.mHandleComp,
741                             ( OMX_INDEXTYPE ) OMX_TI_IndexConfigSceneMode,
742                             &scene);
743 
744     if (OMX_ErrorNone != eError) {
745         CAMHAL_LOGEB("Error while configuring scene mode 0x%x", eError);
746     } else {
747         CAMHAL_LOGDA("Camera scene configured successfully");
748         if (Gen3A.SceneMode != OMX_Manual) {
749             // Get preset scene mode feedback
750             getFocusMode(Gen3A);
751             getFlashMode(Gen3A);
752             getWBMode(Gen3A);
753 
754             // TODO(XXX): Re-enable these for mainline
755             // getSharpness(Gen3A);
756             // getSaturation(Gen3A);
757             // getISO(Gen3A);
758         }
759     }
760 
761     LOG_FUNCTION_NAME_EXIT;
762 
763     return ErrorUtils::omxToAndroidError(eError);
764 }
765 
setEVCompensation(Gen3A_settings & Gen3A)766 status_t OMXCameraAdapter::setEVCompensation(Gen3A_settings& Gen3A)
767 {
768     OMX_ERRORTYPE eError = OMX_ErrorNone;
769     OMX_CONFIG_EXPOSUREVALUETYPE expValues;
770 
771     LOG_FUNCTION_NAME;
772 
773     if ( OMX_StateInvalid == mComponentState )
774         {
775         CAMHAL_LOGEA("OMX component is in invalid state");
776         return NO_INIT;
777         }
778 
779     OMX_INIT_STRUCT_PTR (&expValues, OMX_CONFIG_EXPOSUREVALUETYPE);
780     expValues.nPortIndex = mCameraAdapterParameters.mPrevPortIndex;
781 
782     OMX_GetConfig( mCameraAdapterParameters.mHandleComp,
783                    OMX_IndexConfigCommonExposureValue,
784                    &expValues);
785     CAMHAL_LOGDB("old EV Compensation for OMX = 0x%x", (int)expValues.xEVCompensation);
786     CAMHAL_LOGDB("EV Compensation for HAL = %d", Gen3A.EVCompensation);
787 
788     expValues.xEVCompensation = ( Gen3A.EVCompensation * ( 1 << Q16_OFFSET ) )  / 10;
789     eError = OMX_SetConfig( mCameraAdapterParameters.mHandleComp,
790                             OMX_IndexConfigCommonExposureValue,
791                             &expValues);
792     CAMHAL_LOGDB("new EV Compensation for OMX = 0x%x", (int)expValues.xEVCompensation);
793     if ( OMX_ErrorNone != eError )
794         {
795         CAMHAL_LOGEB("Error while configuring EV Compensation 0x%x error = 0x%x",
796                      ( unsigned int ) expValues.xEVCompensation,
797                      eError);
798         }
799     else
800         {
801         CAMHAL_LOGDB("EV Compensation 0x%x configured successfully",
802                      ( unsigned int ) expValues.xEVCompensation);
803         }
804 
805     LOG_FUNCTION_NAME_EXIT;
806 
807     return ErrorUtils::omxToAndroidError(eError);
808 }
809 
getEVCompensation(Gen3A_settings & Gen3A)810 status_t OMXCameraAdapter::getEVCompensation(Gen3A_settings& Gen3A)
811 {
812     OMX_ERRORTYPE eError = OMX_ErrorNone;
813     OMX_CONFIG_EXPOSUREVALUETYPE expValues;
814 
815     LOG_FUNCTION_NAME;
816 
817     if ( OMX_StateInvalid == mComponentState ) {
818         CAMHAL_LOGEA("OMX component is in invalid state");
819         return NO_INIT;
820     }
821 
822     OMX_INIT_STRUCT_PTR (&expValues, OMX_CONFIG_EXPOSUREVALUETYPE);
823     expValues.nPortIndex = mCameraAdapterParameters.mPrevPortIndex;
824 
825     OMX_GetConfig(mCameraAdapterParameters.mHandleComp,
826                   OMX_IndexConfigCommonExposureValue,
827                   &expValues);
828 
829     if ( OMX_ErrorNone != eError ) {
830         CAMHAL_LOGEB("Error while getting EV Compensation error = 0x%x", eError);
831     } else {
832         Gen3A.EVCompensation = (10 * expValues.xEVCompensation) / (1 << Q16_OFFSET);
833         CAMHAL_LOGDB("Gen3A.EVCompensation 0x%x", Gen3A.EVCompensation);
834     }
835 
836     LOG_FUNCTION_NAME_EXIT;
837 
838     return ErrorUtils::omxToAndroidError(eError);
839 }
840 
setWBMode(Gen3A_settings & Gen3A)841 status_t OMXCameraAdapter::setWBMode(Gen3A_settings& Gen3A)
842 {
843     OMX_ERRORTYPE eError = OMX_ErrorNone;
844     OMX_CONFIG_WHITEBALCONTROLTYPE wb;
845 
846     LOG_FUNCTION_NAME;
847 
848     if ( OMX_StateInvalid == mComponentState )
849         {
850         CAMHAL_LOGEA("OMX component is in invalid state");
851         return NO_INIT;
852         }
853 
854     OMX_INIT_STRUCT_PTR (&wb, OMX_CONFIG_WHITEBALCONTROLTYPE);
855     wb.nPortIndex = mCameraAdapterParameters.mPrevPortIndex;
856     wb.eWhiteBalControl = ( OMX_WHITEBALCONTROLTYPE ) Gen3A.WhiteBallance;
857 
858     if ( WB_FACE_PRIORITY == Gen3A.WhiteBallance )
859         {
860         //Disable Region priority and enable Face priority
861         setAlgoPriority(REGION_PRIORITY, WHITE_BALANCE_ALGO, false);
862         setAlgoPriority(FACE_PRIORITY, WHITE_BALANCE_ALGO, true);
863 
864         //Then set the mode to auto
865         wb.eWhiteBalControl = OMX_WhiteBalControlAuto;
866         }
867     else
868         {
869         //Disable Face and Region priority
870         setAlgoPriority(FACE_PRIORITY, WHITE_BALANCE_ALGO, false);
871         setAlgoPriority(REGION_PRIORITY, WHITE_BALANCE_ALGO, false);
872         }
873 
874     eError = OMX_SetConfig( mCameraAdapterParameters.mHandleComp,
875                          OMX_IndexConfigCommonWhiteBalance,
876                          &wb);
877     if ( OMX_ErrorNone != eError )
878         {
879         CAMHAL_LOGEB("Error while configuring Whitebalance mode 0x%x error = 0x%x",
880                      ( unsigned int ) wb.eWhiteBalControl,
881                      eError);
882         }
883     else
884         {
885         CAMHAL_LOGDB("Whitebalance mode 0x%x configured successfully",
886                      ( unsigned int ) wb.eWhiteBalControl);
887         }
888 
889     LOG_FUNCTION_NAME_EXIT;
890 
891     return eError;
892 }
893 
getWBMode(Gen3A_settings & Gen3A)894 status_t OMXCameraAdapter::getWBMode(Gen3A_settings& Gen3A)
895 {
896     OMX_ERRORTYPE eError = OMX_ErrorNone;
897     OMX_CONFIG_WHITEBALCONTROLTYPE wb;
898 
899     LOG_FUNCTION_NAME;
900 
901     if ( OMX_StateInvalid == mComponentState ) {
902         CAMHAL_LOGEA("OMX component is in invalid state");
903         return NO_INIT;
904     }
905 
906     OMX_INIT_STRUCT_PTR (&wb, OMX_CONFIG_WHITEBALCONTROLTYPE);
907     wb.nPortIndex = mCameraAdapterParameters.mPrevPortIndex;
908 
909     eError = OMX_GetConfig(mCameraAdapterParameters.mHandleComp,
910                            OMX_IndexConfigCommonWhiteBalance,
911                            &wb);
912 
913     if (OMX_ErrorNone != eError) {
914         CAMHAL_LOGEB("Error while getting Whitebalance mode error = 0x%x", eError);
915     } else {
916         Gen3A.WhiteBallance = wb.eWhiteBalControl;
917         CAMHAL_LOGDB("Gen3A.WhiteBallance 0x%x", Gen3A.WhiteBallance);
918     }
919 
920     LOG_FUNCTION_NAME_EXIT;
921 
922     return eError;
923 }
924 
setFlicker(Gen3A_settings & Gen3A)925 status_t OMXCameraAdapter::setFlicker(Gen3A_settings& Gen3A)
926 {
927     OMX_ERRORTYPE eError = OMX_ErrorNone;
928     OMX_CONFIG_FLICKERCANCELTYPE flicker;
929 
930     LOG_FUNCTION_NAME;
931 
932     if ( OMX_StateInvalid == mComponentState )
933         {
934         CAMHAL_LOGEA("OMX component is in invalid state");
935         return NO_INIT;
936         }
937 
938     OMX_INIT_STRUCT_PTR (&flicker, OMX_CONFIG_FLICKERCANCELTYPE);
939     flicker.nPortIndex = mCameraAdapterParameters.mPrevPortIndex;
940     flicker.eFlickerCancel = (OMX_COMMONFLICKERCANCELTYPE)Gen3A.Flicker;
941 
942     eError = OMX_SetConfig( mCameraAdapterParameters.mHandleComp,
943                             (OMX_INDEXTYPE)OMX_IndexConfigFlickerCancel,
944                             &flicker );
945     if ( OMX_ErrorNone != eError )
946         {
947         CAMHAL_LOGEB("Error while configuring Flicker mode 0x%x error = 0x%x",
948                      ( unsigned int ) flicker.eFlickerCancel,
949                      eError);
950         }
951     else
952         {
953         CAMHAL_LOGDB("Flicker mode 0x%x configured successfully",
954                      ( unsigned int ) flicker.eFlickerCancel);
955         }
956 
957     LOG_FUNCTION_NAME_EXIT;
958 
959     return ErrorUtils::omxToAndroidError(eError);
960 }
961 
setBrightness(Gen3A_settings & Gen3A)962 status_t OMXCameraAdapter::setBrightness(Gen3A_settings& Gen3A)
963 {
964     OMX_ERRORTYPE eError = OMX_ErrorNone;
965     OMX_CONFIG_BRIGHTNESSTYPE brightness;
966 
967     LOG_FUNCTION_NAME;
968 
969     if ( OMX_StateInvalid == mComponentState )
970         {
971         CAMHAL_LOGEA("OMX component is in invalid state");
972         return NO_INIT;
973         }
974 
975     OMX_INIT_STRUCT_PTR (&brightness, OMX_CONFIG_BRIGHTNESSTYPE);
976     brightness.nPortIndex = mCameraAdapterParameters.mPrevPortIndex;
977     brightness.nBrightness = Gen3A.Brightness;
978 
979     eError = OMX_SetConfig( mCameraAdapterParameters.mHandleComp,
980                          OMX_IndexConfigCommonBrightness,
981                          &brightness);
982     if ( OMX_ErrorNone != eError )
983         {
984         CAMHAL_LOGEB("Error while configuring Brightness 0x%x error = 0x%x",
985                      ( unsigned int ) brightness.nBrightness,
986                      eError);
987         }
988     else
989         {
990         CAMHAL_LOGDB("Brightness 0x%x configured successfully",
991                      ( unsigned int ) brightness.nBrightness);
992         }
993 
994     LOG_FUNCTION_NAME_EXIT;
995 
996     return ErrorUtils::omxToAndroidError(eError);
997 }
998 
setContrast(Gen3A_settings & Gen3A)999 status_t OMXCameraAdapter::setContrast(Gen3A_settings& Gen3A)
1000 {
1001     OMX_ERRORTYPE eError = OMX_ErrorNone;
1002     OMX_CONFIG_CONTRASTTYPE contrast;
1003 
1004     LOG_FUNCTION_NAME;
1005 
1006     if ( OMX_StateInvalid == mComponentState )
1007         {
1008         CAMHAL_LOGEA("OMX component is in invalid state");
1009         return NO_INIT;
1010         }
1011 
1012     OMX_INIT_STRUCT_PTR (&contrast, OMX_CONFIG_CONTRASTTYPE);
1013     contrast.nPortIndex = mCameraAdapterParameters.mPrevPortIndex;
1014     contrast.nContrast = Gen3A.Contrast;
1015 
1016     eError = OMX_SetConfig( mCameraAdapterParameters.mHandleComp,
1017                          OMX_IndexConfigCommonContrast,
1018                          &contrast);
1019     if ( OMX_ErrorNone != eError )
1020         {
1021         CAMHAL_LOGEB("Error while configuring Contrast 0x%x error = 0x%x",
1022                      ( unsigned int ) contrast.nContrast,
1023                      eError);
1024         }
1025     else
1026         {
1027         CAMHAL_LOGDB("Contrast 0x%x configured successfully",
1028                      ( unsigned int ) contrast.nContrast);
1029         }
1030 
1031     LOG_FUNCTION_NAME_EXIT;
1032 
1033     return eError;
1034 }
1035 
setSharpness(Gen3A_settings & Gen3A)1036 status_t OMXCameraAdapter::setSharpness(Gen3A_settings& Gen3A)
1037 {
1038     OMX_ERRORTYPE eError = OMX_ErrorNone;
1039     OMX_IMAGE_CONFIG_PROCESSINGLEVELTYPE procSharpness;
1040 
1041     LOG_FUNCTION_NAME;
1042 
1043     if ( OMX_StateInvalid == mComponentState )
1044         {
1045         CAMHAL_LOGEA("OMX component is in invalid state");
1046         return NO_INIT;
1047         }
1048 
1049     OMX_INIT_STRUCT_PTR (&procSharpness, OMX_IMAGE_CONFIG_PROCESSINGLEVELTYPE);
1050     procSharpness.nPortIndex = mCameraAdapterParameters.mPrevPortIndex;
1051     procSharpness.nLevel = Gen3A.Sharpness;
1052 
1053     if( procSharpness.nLevel == 0 )
1054         {
1055         procSharpness.bAuto = OMX_TRUE;
1056         }
1057     else
1058         {
1059         procSharpness.bAuto = OMX_FALSE;
1060         }
1061 
1062     eError = OMX_SetConfig( mCameraAdapterParameters.mHandleComp,
1063                          (OMX_INDEXTYPE)OMX_IndexConfigSharpeningLevel,
1064                          &procSharpness);
1065     if ( OMX_ErrorNone != eError )
1066         {
1067         CAMHAL_LOGEB("Error while configuring Sharpness 0x%x error = 0x%x",
1068                      ( unsigned int ) procSharpness.nLevel,
1069                      eError);
1070         }
1071     else
1072         {
1073         CAMHAL_LOGDB("Sharpness 0x%x configured successfully",
1074                      ( unsigned int ) procSharpness.nLevel);
1075         }
1076 
1077     LOG_FUNCTION_NAME_EXIT;
1078 
1079     return ErrorUtils::omxToAndroidError(eError);
1080 }
1081 
getSharpness(Gen3A_settings & Gen3A)1082 status_t OMXCameraAdapter::getSharpness(Gen3A_settings& Gen3A)
1083 {
1084     OMX_ERRORTYPE eError = OMX_ErrorNone;
1085     OMX_IMAGE_CONFIG_PROCESSINGLEVELTYPE procSharpness;
1086 
1087     LOG_FUNCTION_NAME;
1088 
1089     if (OMX_StateInvalid == mComponentState) {
1090         CAMHAL_LOGEA("OMX component is in invalid state");
1091         return NO_INIT;
1092     }
1093 
1094     OMX_INIT_STRUCT_PTR (&procSharpness, OMX_IMAGE_CONFIG_PROCESSINGLEVELTYPE);
1095     procSharpness.nPortIndex = mCameraAdapterParameters.mPrevPortIndex;
1096 
1097     eError = OMX_GetConfig(mCameraAdapterParameters.mHandleComp,
1098                            (OMX_INDEXTYPE)OMX_IndexConfigSharpeningLevel,
1099                            &procSharpness);
1100 
1101     if (OMX_ErrorNone != eError) {
1102         CAMHAL_LOGEB("Error while configuring Sharpness error = 0x%x", eError);
1103     } else {
1104         Gen3A.Sharpness = procSharpness.nLevel;
1105         CAMHAL_LOGDB("Gen3A.Sharpness 0x%x", Gen3A.Sharpness);
1106     }
1107 
1108     LOG_FUNCTION_NAME_EXIT;
1109 
1110     return ErrorUtils::omxToAndroidError(eError);
1111 }
1112 
setSaturation(Gen3A_settings & Gen3A)1113 status_t OMXCameraAdapter::setSaturation(Gen3A_settings& Gen3A)
1114 {
1115     OMX_ERRORTYPE eError = OMX_ErrorNone;
1116     OMX_CONFIG_SATURATIONTYPE saturation;
1117 
1118     LOG_FUNCTION_NAME;
1119 
1120     if ( OMX_StateInvalid == mComponentState )
1121         {
1122         CAMHAL_LOGEA("OMX component is in invalid state");
1123         return NO_INIT;
1124         }
1125 
1126     OMX_INIT_STRUCT_PTR (&saturation, OMX_CONFIG_SATURATIONTYPE);
1127     saturation.nPortIndex = mCameraAdapterParameters.mPrevPortIndex;
1128     saturation.nSaturation = Gen3A.Saturation;
1129 
1130     eError = OMX_SetConfig( mCameraAdapterParameters.mHandleComp,
1131                          OMX_IndexConfigCommonSaturation,
1132                          &saturation);
1133     if ( OMX_ErrorNone != eError )
1134         {
1135         CAMHAL_LOGEB("Error while configuring Saturation 0x%x error = 0x%x",
1136                      ( unsigned int ) saturation.nSaturation,
1137                      eError);
1138         }
1139     else
1140         {
1141         CAMHAL_LOGDB("Saturation 0x%x configured successfully",
1142                      ( unsigned int ) saturation.nSaturation);
1143         }
1144 
1145     LOG_FUNCTION_NAME_EXIT;
1146 
1147     return ErrorUtils::omxToAndroidError(eError);
1148 }
1149 
getSaturation(Gen3A_settings & Gen3A)1150 status_t OMXCameraAdapter::getSaturation(Gen3A_settings& Gen3A)
1151 {
1152     OMX_ERRORTYPE eError = OMX_ErrorNone;
1153     OMX_CONFIG_SATURATIONTYPE saturation;
1154 
1155     LOG_FUNCTION_NAME;
1156 
1157     if (OMX_StateInvalid == mComponentState) {
1158         CAMHAL_LOGEA("OMX component is in invalid state");
1159         return NO_INIT;
1160     }
1161 
1162     OMX_INIT_STRUCT_PTR (&saturation, OMX_CONFIG_SATURATIONTYPE);
1163     saturation.nPortIndex = mCameraAdapterParameters.mPrevPortIndex;
1164 
1165     eError = OMX_GetConfig( mCameraAdapterParameters.mHandleComp,
1166                          OMX_IndexConfigCommonSaturation,
1167                          &saturation);
1168 
1169     if (OMX_ErrorNone != eError) {
1170         CAMHAL_LOGEB("Error while getting Saturation error = 0x%x", eError);
1171     } else {
1172         Gen3A.Saturation = saturation.nSaturation;
1173         CAMHAL_LOGDB("Gen3A.Saturation 0x%x", Gen3A.Saturation);
1174     }
1175 
1176     LOG_FUNCTION_NAME_EXIT;
1177 
1178     return ErrorUtils::omxToAndroidError(eError);
1179 }
1180 
setISO(Gen3A_settings & Gen3A)1181 status_t OMXCameraAdapter::setISO(Gen3A_settings& Gen3A)
1182 {
1183     OMX_ERRORTYPE eError = OMX_ErrorNone;
1184     OMX_CONFIG_EXPOSUREVALUETYPE expValues;
1185 
1186     LOG_FUNCTION_NAME;
1187 
1188     if ( OMX_StateInvalid == mComponentState )
1189         {
1190         CAMHAL_LOGEA("OMX component is in invalid state");
1191         return NO_INIT;
1192         }
1193 
1194     OMX_INIT_STRUCT_PTR (&expValues, OMX_CONFIG_EXPOSUREVALUETYPE);
1195     expValues.nPortIndex = mCameraAdapterParameters.mPrevPortIndex;
1196 
1197     OMX_GetConfig( mCameraAdapterParameters.mHandleComp,
1198                    OMX_IndexConfigCommonExposureValue,
1199                    &expValues);
1200 
1201     if( 0 == Gen3A.ISO )
1202         {
1203         expValues.bAutoSensitivity = OMX_TRUE;
1204         }
1205     else
1206         {
1207         expValues.bAutoSensitivity = OMX_FALSE;
1208         expValues.nSensitivity = Gen3A.ISO;
1209         }
1210 
1211     eError = OMX_SetConfig( mCameraAdapterParameters.mHandleComp,
1212                          OMX_IndexConfigCommonExposureValue,
1213                          &expValues);
1214     if ( OMX_ErrorNone != eError )
1215         {
1216         CAMHAL_LOGEB("Error while configuring ISO 0x%x error = 0x%x",
1217                      ( unsigned int ) expValues.nSensitivity,
1218                      eError);
1219         }
1220     else
1221         {
1222         CAMHAL_LOGDB("ISO 0x%x configured successfully",
1223                      ( unsigned int ) expValues.nSensitivity);
1224         }
1225 
1226     LOG_FUNCTION_NAME_EXIT;
1227 
1228     return ErrorUtils::omxToAndroidError(eError);
1229 }
1230 
getISO(Gen3A_settings & Gen3A)1231 status_t OMXCameraAdapter::getISO(Gen3A_settings& Gen3A)
1232 {
1233     OMX_ERRORTYPE eError = OMX_ErrorNone;
1234     OMX_CONFIG_EXPOSUREVALUETYPE expValues;
1235 
1236     LOG_FUNCTION_NAME;
1237 
1238     if (OMX_StateInvalid == mComponentState) {
1239         CAMHAL_LOGEA("OMX component is in invalid state");
1240         return NO_INIT;
1241     }
1242 
1243     OMX_INIT_STRUCT_PTR (&expValues, OMX_CONFIG_EXPOSUREVALUETYPE);
1244     expValues.nPortIndex = mCameraAdapterParameters.mPrevPortIndex;
1245 
1246     OMX_GetConfig( mCameraAdapterParameters.mHandleComp,
1247                    OMX_IndexConfigCommonExposureValue,
1248                    &expValues);
1249 
1250     if (OMX_ErrorNone != eError) {
1251         CAMHAL_LOGEB("Error while getting ISO error = 0x%x", eError);
1252     } else {
1253         Gen3A.ISO = expValues.nSensitivity;
1254         CAMHAL_LOGDB("Gen3A.ISO %d", Gen3A.ISO);
1255     }
1256 
1257     LOG_FUNCTION_NAME_EXIT;
1258 
1259     return ErrorUtils::omxToAndroidError(eError);
1260 }
1261 
setEffect(Gen3A_settings & Gen3A)1262 status_t OMXCameraAdapter::setEffect(Gen3A_settings& Gen3A)
1263 {
1264     OMX_ERRORTYPE eError = OMX_ErrorNone;
1265     OMX_CONFIG_IMAGEFILTERTYPE effect;
1266 
1267     LOG_FUNCTION_NAME;
1268 
1269     if ( OMX_StateInvalid == mComponentState )
1270         {
1271         CAMHAL_LOGEA("OMX component is in invalid state");
1272         return NO_INIT;
1273         }
1274 
1275     OMX_INIT_STRUCT_PTR (&effect, OMX_CONFIG_IMAGEFILTERTYPE);
1276     effect.nPortIndex = mCameraAdapterParameters.mPrevPortIndex;
1277     effect.eImageFilter = (OMX_IMAGEFILTERTYPE ) Gen3A.Effect;
1278 
1279     eError = OMX_SetConfig( mCameraAdapterParameters.mHandleComp,
1280                          OMX_IndexConfigCommonImageFilter,
1281                          &effect);
1282     if ( OMX_ErrorNone != eError )
1283         {
1284         CAMHAL_LOGEB("Error while configuring Effect 0x%x error = 0x%x",
1285                      ( unsigned int )  effect.eImageFilter,
1286                      eError);
1287         }
1288     else
1289         {
1290         CAMHAL_LOGDB("Effect 0x%x configured successfully",
1291                      ( unsigned int )  effect.eImageFilter);
1292         }
1293 
1294     LOG_FUNCTION_NAME_EXIT;
1295 
1296     return ErrorUtils::omxToAndroidError(eError);
1297 }
1298 
setWhiteBalanceLock(Gen3A_settings & Gen3A)1299 status_t OMXCameraAdapter::setWhiteBalanceLock(Gen3A_settings& Gen3A)
1300 {
1301   OMX_ERRORTYPE eError = OMX_ErrorNone;
1302   OMX_IMAGE_CONFIG_LOCKTYPE lock;
1303 
1304   LOG_FUNCTION_NAME
1305 
1306   if ( OMX_StateInvalid == mComponentState )
1307     {
1308       CAMHAL_LOGEA("OMX component is in invalid state");
1309       return NO_INIT;
1310     }
1311 
1312   OMX_INIT_STRUCT_PTR (&lock, OMX_IMAGE_CONFIG_LOCKTYPE);
1313   lock.nPortIndex = mCameraAdapterParameters.mPrevPortIndex;
1314   lock.bLock = Gen3A.WhiteBalanceLock;
1315   eError = OMX_SetConfig( mCameraAdapterParameters.mHandleComp,
1316                           (OMX_INDEXTYPE)OMX_IndexConfigImageWhiteBalanceLock,
1317                           &lock);
1318   if ( OMX_ErrorNone != eError )
1319     {
1320       CAMHAL_LOGEB("Error while configuring WhiteBalance Lock error = 0x%x", eError);
1321     }
1322   else
1323     {
1324       CAMHAL_LOGDB("WhiteBalance Lock configured successfully %d ", lock.bLock);
1325     }
1326   LOG_FUNCTION_NAME_EXIT
1327 
1328   return ErrorUtils::omxToAndroidError(eError);
1329 }
1330 
setExposureLock(Gen3A_settings & Gen3A)1331 status_t OMXCameraAdapter::setExposureLock(Gen3A_settings& Gen3A)
1332 {
1333   OMX_ERRORTYPE eError = OMX_ErrorNone;
1334   OMX_IMAGE_CONFIG_LOCKTYPE lock;
1335 
1336   LOG_FUNCTION_NAME
1337 
1338   if ( OMX_StateInvalid == mComponentState )
1339     {
1340       CAMHAL_LOGEA("OMX component is in invalid state");
1341       return NO_INIT;
1342     }
1343 
1344   OMX_INIT_STRUCT_PTR (&lock, OMX_IMAGE_CONFIG_LOCKTYPE);
1345   lock.nPortIndex = mCameraAdapterParameters.mPrevPortIndex;
1346   lock.bLock = Gen3A.ExposureLock;
1347   eError = OMX_SetConfig( mCameraAdapterParameters.mHandleComp,
1348                           (OMX_INDEXTYPE)OMX_IndexConfigImageExposureLock,
1349                           &lock);
1350   if ( OMX_ErrorNone != eError )
1351     {
1352       CAMHAL_LOGEB("Error while configuring Exposure Lock error = 0x%x", eError);
1353     }
1354   else
1355     {
1356       CAMHAL_LOGDB("Exposure Lock configured successfully %d ", lock.bLock);
1357     }
1358   LOG_FUNCTION_NAME_EXIT
1359 
1360     return ErrorUtils::omxToAndroidError(eError);
1361 }
1362 
setFocusLock(Gen3A_settings & Gen3A)1363 status_t OMXCameraAdapter::setFocusLock(Gen3A_settings& Gen3A)
1364 {
1365     OMX_ERRORTYPE eError = OMX_ErrorNone;
1366     OMX_IMAGE_CONFIG_LOCKTYPE lock;
1367 
1368     LOG_FUNCTION_NAME
1369 
1370     if ( OMX_StateInvalid == mComponentState ) {
1371         CAMHAL_LOGEA("OMX component is in invalid state");
1372         return NO_INIT;
1373     }
1374 
1375     OMX_INIT_STRUCT_PTR (&lock, OMX_IMAGE_CONFIG_LOCKTYPE);
1376     lock.nPortIndex = mCameraAdapterParameters.mPrevPortIndex;
1377 
1378     lock.bLock = Gen3A.FocusLock;
1379     eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp,
1380                            (OMX_INDEXTYPE)OMX_IndexConfigImageFocusLock,
1381                            &lock);
1382 
1383     if ( OMX_ErrorNone != eError ) {
1384         CAMHAL_LOGEB("Error while configuring Focus Lock error = 0x%x", eError);
1385     } else {
1386         CAMHAL_LOGDB("Focus Lock configured successfully %d ", lock.bLock);
1387     }
1388 
1389     LOG_FUNCTION_NAME_EXIT
1390 
1391     return ErrorUtils::omxToAndroidError(eError);
1392 }
1393 
set3ALock(OMX_BOOL toggleExp,OMX_BOOL toggleWb,OMX_BOOL toggleFocus)1394 status_t OMXCameraAdapter::set3ALock(OMX_BOOL toggleExp, OMX_BOOL toggleWb, OMX_BOOL toggleFocus)
1395 {
1396     OMX_ERRORTYPE eError = OMX_ErrorNone;
1397     OMX_IMAGE_CONFIG_LOCKTYPE lock;
1398 
1399     LOG_FUNCTION_NAME
1400 
1401     if ( OMX_StateInvalid == mComponentState )
1402     {
1403       CAMHAL_LOGEA("OMX component is in invalid state");
1404       return NO_INIT;
1405     }
1406 
1407     OMX_INIT_STRUCT_PTR (&lock, OMX_IMAGE_CONFIG_LOCKTYPE);
1408     lock.nPortIndex = mCameraAdapterParameters.mPrevPortIndex;
1409 
1410     mParameters3A.ExposureLock = toggleExp;
1411     mParameters3A.FocusLock = toggleFocus;
1412     mParameters3A.WhiteBalanceLock = toggleWb;
1413 
1414     eError = OMX_GetConfig( mCameraAdapterParameters.mHandleComp,
1415                             (OMX_INDEXTYPE)OMX_IndexConfigImageExposureLock,
1416                             &lock);
1417 
1418     if ( OMX_ErrorNone != eError )
1419     {
1420         CAMHAL_LOGEB("Error GetConfig Exposure Lock error = 0x%x", eError);
1421         goto EXIT;
1422     }
1423     else
1424     {
1425         const char *lock_state_exp = toggleExp ? TRUE : FALSE;
1426         CAMHAL_LOGDA("Exposure Lock GetConfig successfull");
1427 
1428         /* Apply locks only when not applied already */
1429         if ( lock.bLock  != toggleExp )
1430         {
1431             setExposureLock(mParameters3A);
1432         }
1433 
1434         mParams.set(CameraParameters::KEY_AUTO_EXPOSURE_LOCK, lock_state_exp);
1435     }
1436 
1437     OMX_INIT_STRUCT_PTR (&lock, OMX_IMAGE_CONFIG_LOCKTYPE);
1438     lock.nPortIndex = mCameraAdapterParameters.mPrevPortIndex;
1439     eError = OMX_GetConfig( mCameraAdapterParameters.mHandleComp,
1440                             (OMX_INDEXTYPE)OMX_IndexConfigImageFocusLock,
1441                             &lock);
1442 
1443     if ( OMX_ErrorNone != eError )
1444     {
1445         CAMHAL_LOGEB("Error GetConfig Focus Lock error = 0x%x", eError);
1446         goto EXIT;
1447     }
1448     else
1449     {
1450         CAMHAL_LOGDB("Focus Lock GetConfig successfull bLock(%d)", lock.bLock);
1451 
1452         /* Apply locks only when not applied already */
1453         if ( lock.bLock  != toggleFocus )
1454         {
1455             setFocusLock(mParameters3A);
1456         }
1457     }
1458 
1459     OMX_INIT_STRUCT_PTR (&lock, OMX_IMAGE_CONFIG_LOCKTYPE);
1460     lock.nPortIndex = mCameraAdapterParameters.mPrevPortIndex;
1461     eError = OMX_GetConfig( mCameraAdapterParameters.mHandleComp,
1462                             (OMX_INDEXTYPE)OMX_IndexConfigImageWhiteBalanceLock,
1463                             &lock);
1464 
1465     if ( OMX_ErrorNone != eError )
1466     {
1467         CAMHAL_LOGEB("Error GetConfig WhiteBalance Lock error = 0x%x", eError);
1468         goto EXIT;
1469     }
1470     else
1471     {
1472         const char *lock_state_wb = toggleWb ? TRUE : FALSE;
1473         CAMHAL_LOGDA("WhiteBalance Lock GetConfig successfull");
1474 
1475         /* Apply locks only when not applied already */
1476         if ( lock.bLock != toggleWb )
1477         {
1478             setWhiteBalanceLock(mParameters3A);
1479         }
1480 
1481         mParams.set(CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK, lock_state_wb);
1482     }
1483  EXIT:
1484     return ErrorUtils::omxToAndroidError(eError);
1485 }
1486 
setMeteringAreas(Gen3A_settings & Gen3A)1487 status_t OMXCameraAdapter::setMeteringAreas(Gen3A_settings& Gen3A)
1488 {
1489   status_t ret = NO_ERROR;
1490   OMX_ERRORTYPE eError = OMX_ErrorNone;
1491 
1492   OMX_ALGOAREASTYPE **meteringAreas;
1493   OMX_TI_CONFIG_SHAREDBUFFER sharedBuffer;
1494   MemoryManager memMgr;
1495   int areasSize = 0;
1496 
1497   LOG_FUNCTION_NAME
1498 
1499   Mutex::Autolock lock(mMeteringAreasLock);
1500 
1501   if ( OMX_StateInvalid == mComponentState )
1502     {
1503       CAMHAL_LOGEA("OMX component is in invalid state");
1504       return NO_INIT;
1505     }
1506 
1507   areasSize = ((sizeof(OMX_ALGOAREASTYPE)+4095)/4096)*4096;
1508   meteringAreas = (OMX_ALGOAREASTYPE**) memMgr.allocateBuffer(0, 0, NULL, areasSize, 1);
1509 
1510   OMXCameraPortParameters * mPreviewData = NULL;
1511   mPreviewData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex];
1512 
1513   if (!meteringAreas)
1514       {
1515       CAMHAL_LOGEB("Error allocating buffer for metering areas %d", eError);
1516       return -ENOMEM;
1517       }
1518 
1519   OMX_INIT_STRUCT_PTR (meteringAreas[0], OMX_ALGOAREASTYPE);
1520 
1521   meteringAreas[0]->nPortIndex = OMX_ALL;
1522   meteringAreas[0]->nNumAreas = mMeteringAreas.size();
1523   meteringAreas[0]->nAlgoAreaPurpose = OMX_AlgoAreaExposure;
1524 
1525   for ( unsigned int n = 0; n < mMeteringAreas.size(); n++)
1526       {
1527       // transform the coordinates to 3A-type coordinates
1528       mMeteringAreas.itemAt(n)->transfrom((size_t)mPreviewData->mWidth,
1529                                       (size_t)mPreviewData->mHeight,
1530                                       (size_t&)meteringAreas[0]->tAlgoAreas[n].nTop,
1531                                       (size_t&)meteringAreas[0]->tAlgoAreas[n].nLeft,
1532                                       (size_t&)meteringAreas[0]->tAlgoAreas[n].nWidth,
1533                                       (size_t&)meteringAreas[0]->tAlgoAreas[n].nHeight);
1534 
1535       meteringAreas[0]->tAlgoAreas[n].nLeft =
1536               ( meteringAreas[0]->tAlgoAreas[n].nLeft * METERING_AREAS_RANGE ) / mPreviewData->mWidth;
1537       meteringAreas[0]->tAlgoAreas[n].nTop =
1538               ( meteringAreas[0]->tAlgoAreas[n].nTop* METERING_AREAS_RANGE ) / mPreviewData->mHeight;
1539       meteringAreas[0]->tAlgoAreas[n].nWidth =
1540               ( meteringAreas[0]->tAlgoAreas[n].nWidth * METERING_AREAS_RANGE ) / mPreviewData->mWidth;
1541       meteringAreas[0]->tAlgoAreas[n].nHeight =
1542               ( meteringAreas[0]->tAlgoAreas[n].nHeight * METERING_AREAS_RANGE ) / mPreviewData->mHeight;
1543 
1544       meteringAreas[0]->tAlgoAreas[n].nPriority = mMeteringAreas.itemAt(n)->getWeight();
1545 
1546       CAMHAL_LOGDB("Metering area %d : top = %d left = %d width = %d height = %d prio = %d",
1547               n, (int)meteringAreas[0]->tAlgoAreas[n].nTop, (int)meteringAreas[0]->tAlgoAreas[n].nLeft,
1548               (int)meteringAreas[0]->tAlgoAreas[n].nWidth, (int)meteringAreas[0]->tAlgoAreas[n].nHeight,
1549               (int)meteringAreas[0]->tAlgoAreas[n].nPriority);
1550 
1551       }
1552 
1553   OMX_INIT_STRUCT_PTR (&sharedBuffer, OMX_TI_CONFIG_SHAREDBUFFER);
1554 
1555   sharedBuffer.nPortIndex = OMX_ALL;
1556   sharedBuffer.nSharedBuffSize = areasSize;
1557   sharedBuffer.pSharedBuff = (OMX_U8 *) meteringAreas[0];
1558 
1559   if ( NULL == sharedBuffer.pSharedBuff )
1560       {
1561       CAMHAL_LOGEA("No resources to allocate OMX shared buffer");
1562       ret = -ENOMEM;
1563       goto EXIT;
1564       }
1565 
1566       eError =  OMX_SetConfig(mCameraAdapterParameters.mHandleComp,
1567                                 (OMX_INDEXTYPE) OMX_TI_IndexConfigAlgoAreas, &sharedBuffer);
1568 
1569   if ( OMX_ErrorNone != eError )
1570       {
1571       CAMHAL_LOGEB("Error while setting Focus Areas configuration 0x%x", eError);
1572       ret = -EINVAL;
1573       }
1574   else
1575       {
1576       CAMHAL_LOGDA("Metering Areas SetConfig successfull.");
1577       }
1578 
1579  EXIT:
1580   if (NULL != meteringAreas)
1581       {
1582       memMgr.freeBuffer((void*) meteringAreas);
1583       meteringAreas = NULL;
1584       }
1585 
1586   return ret;
1587 }
1588 
apply3Asettings(Gen3A_settings & Gen3A)1589 status_t OMXCameraAdapter::apply3Asettings( Gen3A_settings& Gen3A )
1590 {
1591     status_t ret = NO_ERROR;
1592     unsigned int currSett; // 32 bit
1593     int portIndex;
1594 
1595     LOG_FUNCTION_NAME;
1596 
1597     Mutex::Autolock lock(m3ASettingsUpdateLock);
1598 
1599     /*
1600      * Scenes have a priority during the process
1601      * of applying 3A related parameters.
1602      * They can override pretty much all other 3A
1603      * settings and similarly get overridden when
1604      * for instance the focus mode gets switched.
1605      * There is only one exception to this rule,
1606      * the manual a.k.a. auto scene.
1607      */
1608     if (SetSceneMode & mPending3Asettings) {
1609         mPending3Asettings &= ~SetSceneMode;
1610         ret |= setScene(Gen3A);
1611         // re-apply EV compensation after setting scene mode since it probably reset it
1612         if(Gen3A.EVCompensation) {
1613             setEVCompensation(Gen3A);
1614         }
1615         return ret;
1616     } else if (OMX_Manual != Gen3A.SceneMode) {
1617         // only certain settings are allowed when scene mode is set
1618         mPending3Asettings &= (SetEVCompensation | SetFocus | SetWBLock |
1619                                SetExpLock | SetWhiteBallance | SetFlash);
1620         if ( mPending3Asettings == 0 ) return NO_ERROR;
1621     }
1622 
1623     for( currSett = 1; currSett < E3aSettingMax; currSett <<= 1)
1624         {
1625         if( currSett & mPending3Asettings )
1626             {
1627             switch( currSett )
1628                 {
1629                 case SetEVCompensation:
1630                     {
1631                     ret |= setEVCompensation(Gen3A);
1632                     break;
1633                     }
1634 
1635                 case SetWhiteBallance:
1636                     {
1637                     ret |= setWBMode(Gen3A);
1638                     break;
1639                     }
1640 
1641                 case SetFlicker:
1642                     {
1643                     ret |= setFlicker(Gen3A);
1644                     break;
1645                     }
1646 
1647                 case SetBrightness:
1648                     {
1649                     ret |= setBrightness(Gen3A);
1650                     break;
1651                     }
1652 
1653                 case SetContrast:
1654                     {
1655                     ret |= setContrast(Gen3A);
1656                     break;
1657                     }
1658 
1659                 case SetSharpness:
1660                     {
1661                     ret |= setSharpness(Gen3A);
1662                     break;
1663                     }
1664 
1665                 case SetSaturation:
1666                     {
1667                     ret |= setSaturation(Gen3A);
1668                     break;
1669                     }
1670 
1671                 case SetISO:
1672                     {
1673                     ret |= setISO(Gen3A);
1674                     break;
1675                     }
1676 
1677                 case SetEffect:
1678                     {
1679                     ret |= setEffect(Gen3A);
1680                     break;
1681                     }
1682 
1683                 case SetFocus:
1684                     {
1685                     ret |= setFocusMode(Gen3A);
1686                     break;
1687                     }
1688 
1689                 case SetExpMode:
1690                     {
1691                     ret |= setExposureMode(Gen3A);
1692                     break;
1693                     }
1694 
1695                 case SetFlash:
1696                     {
1697                     ret |= setFlashMode(Gen3A);
1698                     break;
1699                     }
1700 
1701                 case SetExpLock:
1702                   {
1703                     ret |= setExposureLock(Gen3A);
1704                     break;
1705                   }
1706 
1707                 case SetWBLock:
1708                   {
1709                     ret |= setWhiteBalanceLock(Gen3A);
1710                     break;
1711                   }
1712                 case SetMeteringAreas:
1713                   {
1714                     ret |= setMeteringAreas(Gen3A);
1715                   }
1716                   break;
1717                 default:
1718                     CAMHAL_LOGEB("this setting (0x%x) is still not supported in CameraAdapter ",
1719                                  currSett);
1720                     break;
1721                 }
1722                 mPending3Asettings &= ~currSett;
1723             }
1724         }
1725 
1726         LOG_FUNCTION_NAME_EXIT;
1727 
1728         return ret;
1729 }
1730 
1731 };
1732