• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 OMXAlgo.cpp
19 *
20 * This file contains functionality for handling algorithm configurations.
21 *
22 */
23 
24 #include "CameraHal.h"
25 #include "OMXCameraAdapter.h"
26 #include "ErrorUtils.h"
27 
28 #undef TRUE
29 
30 namespace Ti {
31 namespace Camera {
32 
setParametersAlgo(const android::CameraParameters & params,BaseCameraAdapter::AdapterState state)33 status_t OMXCameraAdapter::setParametersAlgo(const android::CameraParameters &params,
34                                              BaseCameraAdapter::AdapterState state)
35 {
36     status_t ret = NO_ERROR;
37     const char *valstr = NULL;
38     const char *valManualStr = NULL;
39     const char *oldstr = NULL;
40     OMXCameraPortParameters *cap;
41     BrightnessMode gbce = BRIGHTNESS_OFF;
42     BrightnessMode glbce = BRIGHTNESS_OFF;
43 
44     LOG_FUNCTION_NAME;
45 
46     CaptureMode capMode;
47     CAMHAL_LOGDB("Capture mode %s",  params.get(TICameraParameters::KEY_CAP_MODE));
48     if ( (valstr = params.get(TICameraParameters::KEY_CAP_MODE)) != NULL ) {
49         if (strcmp(valstr, (const char *) TICameraParameters::HIGH_PERFORMANCE_MODE) == 0) {
50             capMode = OMXCameraAdapter::HIGH_SPEED;
51             mCapabilitiesOpMode = MODE_HIGH_SPEED;
52         } else if (strcmp(valstr, (const char *) TICameraParameters::EXPOSURE_BRACKETING) == 0) {
53             capMode = OMXCameraAdapter::HIGH_SPEED;
54             mCapabilitiesOpMode = MODE_HIGH_SPEED;
55         } else if (strcmp(valstr, (const char *) TICameraParameters::ZOOM_BRACKETING) == 0) {
56             capMode = OMXCameraAdapter::HIGH_SPEED;
57             mCapabilitiesOpMode = MODE_HIGH_SPEED;
58         } else if (strcmp(valstr, (const char *) TICameraParameters::HIGH_QUALITY_MODE) == 0) {
59             capMode = OMXCameraAdapter::HIGH_QUALITY;
60             mCapabilitiesOpMode = MODE_HIGH_QUALITY;
61         } else if (strcmp(valstr, (const char *) TICameraParameters::HIGH_QUALITY_ZSL_MODE) == 0) {
62             capMode = OMXCameraAdapter::HIGH_QUALITY_ZSL;
63             mCapabilitiesOpMode = MODE_ZEROSHUTTERLAG;
64         } else if (strcmp(valstr, (const char *) TICameraParameters::VIDEO_MODE) == 0) {
65             capMode = OMXCameraAdapter::VIDEO_MODE;
66             mCapabilitiesOpMode = MODE_VIDEO;
67         } else if (strcmp(valstr, (const char *) TICameraParameters::VIDEO_MODE_HQ) == 0) {
68               capMode = OMXCameraAdapter::VIDEO_MODE_HQ;
69               mCapabilitiesOpMode = MODE_VIDEO_HIGH_QUALITY;
70         } else if (strcmp(valstr, (const char *) TICameraParameters::CP_CAM_MODE) == 0) {
71             capMode = OMXCameraAdapter::CP_CAM;
72             mCapabilitiesOpMode = MODE_CPCAM;
73         } else if (strcmp(valstr, (const char *) TICameraParameters::TEMP_BRACKETING) == 0) {
74             capMode = OMXCameraAdapter::HIGH_SPEED;
75             mCapabilitiesOpMode = MODE_HIGH_SPEED;
76         } else {
77             capMode = OMXCameraAdapter::HIGH_QUALITY;
78             mCapabilitiesOpMode = MODE_HIGH_QUALITY;
79         }
80 
81     } else {
82         capMode = OMXCameraAdapter::HIGH_QUALITY;
83         mCapabilitiesOpMode = MODE_HIGH_QUALITY;
84     }
85 
86     if ( mSensorIndex == 2 ) {
87        mCapabilitiesOpMode = MODE_STEREO;
88     }
89 
90     if ( mCapMode != capMode ) {
91         mCapMode = capMode;
92         mOMXStateSwitch = true;
93         mPendingPreviewSettings |= SetCapMode;
94     }
95 
96     CAMHAL_LOGDB("Capture Mode set %d", mCapMode);
97 
98     /// Configure IPP, LDCNSF, GBCE and GLBCE only in HQ mode
99     IPPMode ipp;
100     if((mCapMode == OMXCameraAdapter::HIGH_QUALITY) || (mCapMode == OMXCameraAdapter::HIGH_QUALITY_ZSL)
101             || (mCapMode == OMXCameraAdapter::VIDEO_MODE)
102             || (mCapMode == OMXCameraAdapter::CP_CAM))
103         {
104           if ( (valstr = params.get(TICameraParameters::KEY_IPP)) != NULL )
105             {
106             if (strcmp(valstr, (const char *) TICameraParameters::IPP_LDCNSF) == 0)
107                 {
108                 ipp = OMXCameraAdapter::IPP_LDCNSF;
109                 }
110             else if (strcmp(valstr, (const char *) TICameraParameters::IPP_LDC) == 0)
111                 {
112                 ipp = OMXCameraAdapter::IPP_LDC;
113                 }
114             else if (strcmp(valstr, (const char *) TICameraParameters::IPP_NSF) == 0)
115                 {
116                 ipp = OMXCameraAdapter::IPP_NSF;
117                 }
118             else if (strcmp(valstr, (const char *) TICameraParameters::IPP_NONE) == 0)
119                 {
120                 ipp = OMXCameraAdapter::IPP_NONE;
121                 }
122             else
123                 {
124                 ipp = OMXCameraAdapter::IPP_NONE;
125                 }
126             }
127         else
128             {
129             ipp = OMXCameraAdapter::IPP_NONE;
130             }
131 
132         CAMHAL_LOGVB("IPP Mode set %d", ipp);
133 
134         if (((valstr = params.get(TICameraParameters::KEY_GBCE)) != NULL) ) {
135             if (strcmp(valstr, android::CameraParameters::TRUE ) == 0) {
136                 gbce = BRIGHTNESS_ON;
137             } else {
138                 gbce = BRIGHTNESS_OFF;
139             }
140 
141             if ( gbce != mGBCE ) {
142                 mGBCE = gbce;
143                 setGBCE(mGBCE);
144             }
145 
146         } else if(mFirstTimeInit) {
147             //Disable GBCE by default
148             setGBCE(OMXCameraAdapter::BRIGHTNESS_OFF);
149         }
150 
151         if ( ( valstr = params.get(TICameraParameters::KEY_GLBCE) ) != NULL ) {
152 
153             if (strcmp(valstr, android::CameraParameters::TRUE) == 0) {
154                 glbce = BRIGHTNESS_ON;
155             } else {
156                 glbce = BRIGHTNESS_OFF;
157             }
158 
159             if ( glbce != mGLBCE ) {
160                 mGLBCE = glbce;
161                 setGLBCE(mGLBCE);
162             }
163 
164         } else if(mFirstTimeInit) {
165             //Disable GLBCE by default
166             setGLBCE(OMXCameraAdapter::BRIGHTNESS_OFF);
167         }
168 
169     } else {
170         ipp = OMXCameraAdapter::IPP_NONE;
171     }
172 
173     if ( mIPP != ipp )
174         {
175         mIPP = ipp;
176         mOMXStateSwitch = true;
177         mPendingPreviewSettings |= SetLDC;
178         mPendingPreviewSettings |= SetNSF;
179         }
180 
181     ///Set VNF Configuration
182     bool vnfEnabled = false;
183     valstr = params.get(TICameraParameters::KEY_VNF);
184     if (valstr && strcmp(valstr, android::CameraParameters::TRUE) == 0)
185         {
186         CAMHAL_LOGDA("VNF Enabled");
187         vnfEnabled = true;
188         }
189     else
190         {
191         CAMHAL_LOGDA("VNF Disabled");
192         vnfEnabled = false;
193         }
194 
195     if ( mVnfEnabled != vnfEnabled )
196         {
197         mVnfEnabled = vnfEnabled;
198         mOMXStateSwitch = true;
199         mPendingPreviewSettings |= SetVNF;
200         }
201 
202     ///Set VSTAB Configuration
203     bool vstabEnabled = false;
204     valstr = params.get(android::CameraParameters::KEY_VIDEO_STABILIZATION);
205     if (valstr && strcmp(valstr, android::CameraParameters::TRUE) == 0) {
206         CAMHAL_LOGDA("VSTAB Enabled");
207         vstabEnabled = true;
208         }
209     else
210         {
211         CAMHAL_LOGDA("VSTAB Disabled");
212         vstabEnabled = false;
213         }
214 
215     if ( mVstabEnabled != vstabEnabled )
216         {
217         mVstabEnabled = vstabEnabled;
218         mOMXStateSwitch = true;
219         mPendingPreviewSettings |= SetVSTAB;
220         }
221 
222     //A work-around for a failing call to OMX flush buffers
223     if ( ( capMode = OMXCameraAdapter::VIDEO_MODE ) &&
224          ( mVstabEnabled ) )
225         {
226         mOMXStateSwitch = true;
227         }
228 
229 #ifdef OMAP_ENHANCEMENT
230 
231     //Set Auto Convergence Mode
232     valstr = params.get((const char *) TICameraParameters::KEY_AUTOCONVERGENCE_MODE);
233     valManualStr = params.get(TICameraParameters::KEY_MANUAL_CONVERGENCE);
234 
235     cap = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex];
236 
237     if (cap->mFrameLayoutType != OMX_TI_StereoFrameLayout2D) {
238         if ((valstr != NULL) || (valManualStr != NULL)) {
239             setAutoConvergence(valstr, valManualStr, params);
240             if (valstr != NULL) {
241                 CAMHAL_LOGDB("AutoConvergenceMode %s", valstr);
242             }
243             if (valManualStr != NULL) {
244                 CAMHAL_LOGDB("Manual Convergence  %s", valManualStr);
245             }
246         }
247 
248         //Set Mechanical Misalignment Correction
249         valstr = params.get(TICameraParameters::KEY_MECHANICAL_MISALIGNMENT_CORRECTION);
250         if ( valstr != NULL ) {
251             setMechanicalMisalignmentCorrection(strcmp(valstr, android::CameraParameters::TRUE) == 0);
252             CAMHAL_LOGDB("Mechanical Misalignment Correction %s", valstr);
253         }
254     }
255 
256 #endif
257 
258     LOG_FUNCTION_NAME_EXIT;
259 
260     return ret;
261 }
262 
263 // Set AutoConvergence
setAutoConvergence(const char * pValstr,const char * pValManualstr,const android::CameraParameters & params)264 status_t OMXCameraAdapter::setAutoConvergence(const char *pValstr, const char *pValManualstr, const android::CameraParameters &params)
265 {
266     status_t ret = NO_ERROR;
267     OMX_ERRORTYPE eError = OMX_ErrorNone;
268     OMX_TI_CONFIG_CONVERGENCETYPE ACParams;
269     const char *str = NULL;
270     android::Vector<android::sp<CameraArea> > tempAreas;
271     int mode;
272     int changed = 0;
273 
274     LOG_FUNCTION_NAME;
275 
276     if ( pValManualstr != NULL ) {
277         OMX_S32 manualConvergence = (OMX_S32)strtol(pValManualstr ,0 ,0);
278 
279         if (mManualConv != manualConvergence) {
280             mManualConv = manualConvergence;
281             changed = 1;
282         }
283     }
284 
285     if ( pValstr != NULL ) {
286         mode = getLUTvalue_HALtoOMX(pValstr, mAutoConvergenceLUT);
287 
288         if ( NAME_NOT_FOUND == mode ) {
289             CAMHAL_LOGEB("Wrong convergence mode: %s", pValstr);
290             LOG_FUNCTION_NAME_EXIT;
291             return mode;
292         }
293 
294         if ( mAutoConv != static_cast<OMX_TI_AUTOCONVERGENCEMODETYPE> (mode) ) {
295             mAutoConv = static_cast<OMX_TI_AUTOCONVERGENCEMODETYPE> (mode);
296             changed = 1;
297         }
298     }
299 
300     if ( OMX_TI_AutoConvergenceModeFocusFaceTouch == mAutoConv ) {
301         android::AutoMutex lock(mTouchAreasLock);
302 
303         str = params.get(android::CameraParameters::KEY_METERING_AREAS);
304 
305         if ( NULL != str ) {
306             ret = CameraArea::parseAreas(str, ( strlen(str) + 1 ), tempAreas);
307         } else {
308             CAMHAL_LOGEB("Touch areas not received in %s",
309                          android::CameraParameters::KEY_METERING_AREAS);
310             LOG_FUNCTION_NAME_EXIT;
311             return BAD_VALUE;
312         }
313 
314         if ( CameraArea::areAreasDifferent(mTouchAreas, tempAreas) ) {
315             mTouchAreas.clear();
316             mTouchAreas = tempAreas;
317             changed = 1;
318         }
319     }
320 
321     if (!changed) {
322         LOG_FUNCTION_NAME_EXIT;
323         return NO_ERROR;
324     }
325 
326     OMXCameraPortParameters * mPreviewData;
327     mPreviewData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex];
328 
329     ACParams.nSize = (OMX_U32)sizeof(OMX_TI_CONFIG_CONVERGENCETYPE);
330     ACParams.nVersion = mLocalVersionParam;
331     ACParams.nPortIndex = mCameraAdapterParameters.mPrevPortIndex;
332 
333     OMX_GetConfig(mCameraAdapterParameters.mHandleComp,
334                   (OMX_INDEXTYPE)OMX_TI_IndexConfigAutoConvergence,
335                   &ACParams);
336 
337     ACParams.eACMode = mAutoConv;
338     ACParams.nManualConverence = mManualConv;
339 
340     if (1 == mTouchAreas.size()) {
341         int widthDivisor = 1;
342         int heightDivisor = 1;
343 
344         if (mPreviewData->mFrameLayoutType == OMX_TI_StereoFrameLayoutTopBottom) {
345             heightDivisor = 2;
346         }
347         if (mPreviewData->mFrameLayoutType == OMX_TI_StereoFrameLayoutLeftRight) {
348             widthDivisor = 2;
349         }
350 
351         // transform the coordinates to 3A-type coordinates
352         mTouchAreas.itemAt(0)->transfrom((size_t)mPreviewData->mWidth/widthDivisor,
353                                          (size_t)mPreviewData->mHeight/heightDivisor,
354                                          (size_t&) ACParams.nACProcWinStartY,
355                                          (size_t&) ACParams.nACProcWinStartX,
356                                          (size_t&) ACParams.nACProcWinWidth,
357                                          (size_t&) ACParams.nACProcWinHeight);
358     }
359 
360     CAMHAL_LOGDB("nSize %d", (int)ACParams.nSize);
361     CAMHAL_LOGDB("nPortIndex %d", (int)ACParams.nPortIndex);
362     CAMHAL_LOGDB("nManualConverence %d", (int)ACParams.nManualConverence);
363     CAMHAL_LOGDB("eACMode %d", (int)ACParams.eACMode);
364     CAMHAL_LOGDB("nACProcWinStartX %d", (int)ACParams.nACProcWinStartX);
365     CAMHAL_LOGDB("nACProcWinStartY %d", (int)ACParams.nACProcWinStartY);
366     CAMHAL_LOGDB("nACProcWinWidth %d", (int)ACParams.nACProcWinWidth);
367     CAMHAL_LOGDB("nACProcWinHeight %d", (int)ACParams.nACProcWinHeight);
368     CAMHAL_LOGDB("bACStatus %d", (int)ACParams.bACStatus);
369 
370     eError =  OMX_SetConfig(mCameraAdapterParameters.mHandleComp,
371                             (OMX_INDEXTYPE)OMX_TI_IndexConfigAutoConvergence,
372                             &ACParams);
373 
374     if ( eError != OMX_ErrorNone ) {
375         CAMHAL_LOGEB("Error while setting AutoConvergence 0x%x", eError);
376         ret = BAD_VALUE;
377     } else {
378         CAMHAL_LOGDA("AutoConvergence applied successfully");
379     }
380 
381     LOG_FUNCTION_NAME_EXIT;
382 
383     return ret;
384 }
385 
enableVideoNoiseFilter(bool enable)386 status_t OMXCameraAdapter::enableVideoNoiseFilter(bool enable)
387 {
388     status_t ret = NO_ERROR;
389     OMX_ERRORTYPE eError = OMX_ErrorNone;
390     OMX_PARAM_VIDEONOISEFILTERTYPE vnfCfg;
391 
392 
393     LOG_FUNCTION_NAME;
394 
395     if ( NO_ERROR == ret )
396         {
397         OMX_INIT_STRUCT_PTR (&vnfCfg, OMX_PARAM_VIDEONOISEFILTERTYPE);
398 
399         if ( enable )
400             {
401             CAMHAL_LOGDA("VNF is enabled");
402             vnfCfg.eMode = OMX_VideoNoiseFilterModeOn;
403             }
404         else
405             {
406             CAMHAL_LOGDA("VNF is disabled");
407             vnfCfg.eMode = OMX_VideoNoiseFilterModeOff;
408             }
409 
410         eError =  OMX_SetParameter(mCameraAdapterParameters.mHandleComp,
411                                    ( OMX_INDEXTYPE ) OMX_IndexParamVideoNoiseFilter,
412                                    &vnfCfg);
413         if ( OMX_ErrorNone != eError )
414             {
415             CAMHAL_LOGEB("Error while configuring video noise filter 0x%x", eError);
416             ret = -1;
417             }
418         else
419             {
420             CAMHAL_LOGDA("Video noise filter is configured successfully");
421             }
422         }
423 
424     LOG_FUNCTION_NAME_EXIT;
425 
426     return ret;
427 }
428 
enableVideoStabilization(bool enable)429 status_t OMXCameraAdapter::enableVideoStabilization(bool enable)
430 {
431     status_t ret = NO_ERROR;
432     OMX_ERRORTYPE eError = OMX_ErrorNone;
433     OMX_CONFIG_FRAMESTABTYPE frameStabCfg;
434 
435 
436     LOG_FUNCTION_NAME;
437 
438     if ( NO_ERROR == ret )
439         {
440         OMX_CONFIG_BOOLEANTYPE vstabp;
441         OMX_INIT_STRUCT_PTR (&vstabp, OMX_CONFIG_BOOLEANTYPE);
442         if(enable)
443             {
444             vstabp.bEnabled = OMX_TRUE;
445             }
446         else
447             {
448             vstabp.bEnabled = OMX_FALSE;
449             }
450 
451         eError = OMX_SetParameter(mCameraAdapterParameters.mHandleComp,
452                                   (OMX_INDEXTYPE)OMX_IndexParamFrameStabilisation,
453                                   &vstabp);
454         if ( OMX_ErrorNone != eError )
455             {
456             CAMHAL_LOGEB("Error while configuring video stabilization param 0x%x", eError);
457             ret = -1;
458             }
459         else
460             {
461             CAMHAL_LOGDA("Video stabilization param configured successfully");
462             }
463 
464         }
465 
466     if ( NO_ERROR == ret )
467         {
468 
469         OMX_INIT_STRUCT_PTR (&frameStabCfg, OMX_CONFIG_FRAMESTABTYPE);
470 
471 
472         eError =  OMX_GetConfig(mCameraAdapterParameters.mHandleComp,
473                                 ( OMX_INDEXTYPE ) OMX_IndexConfigCommonFrameStabilisation,
474                                 &frameStabCfg);
475         if ( OMX_ErrorNone != eError )
476             {
477             CAMHAL_LOGEB("Error while getting video stabilization mode 0x%x",
478                          (unsigned int)eError);
479             ret = -1;
480             }
481 
482         CAMHAL_LOGDB("VSTAB Port Index = %d", (int)frameStabCfg.nPortIndex);
483 
484         frameStabCfg.nPortIndex = mCameraAdapterParameters.mPrevPortIndex;
485         if ( enable )
486             {
487             CAMHAL_LOGDA("VSTAB is enabled");
488             frameStabCfg.bStab = OMX_TRUE;
489             }
490         else
491             {
492             CAMHAL_LOGDA("VSTAB is disabled");
493             frameStabCfg.bStab = OMX_FALSE;
494 
495             }
496 
497         eError =  OMX_SetConfig(mCameraAdapterParameters.mHandleComp,
498                                 ( OMX_INDEXTYPE ) OMX_IndexConfigCommonFrameStabilisation,
499                                 &frameStabCfg);
500         if ( OMX_ErrorNone != eError )
501             {
502             CAMHAL_LOGEB("Error while configuring video stabilization mode 0x%x", eError);
503             ret = -1;
504             }
505         else
506             {
507             CAMHAL_LOGDA("Video stabilization mode configured successfully");
508             }
509         }
510 
511     LOG_FUNCTION_NAME_EXIT;
512 
513     return ret;
514 }
515 
setGBCE(OMXCameraAdapter::BrightnessMode mode)516 status_t OMXCameraAdapter::setGBCE(OMXCameraAdapter::BrightnessMode mode)
517 {
518     status_t ret = NO_ERROR;
519     OMX_ERRORTYPE eError = OMX_ErrorNone;
520     OMX_TI_CONFIG_LOCAL_AND_GLOBAL_BRIGHTNESSCONTRASTTYPE bControl;
521 
522     LOG_FUNCTION_NAME;
523 
524     if ( OMX_StateInvalid == mComponentState )
525         {
526         CAMHAL_LOGEA("OMX component is in invalid state");
527         ret = -EINVAL;
528         }
529 
530     if ( NO_ERROR == ret )
531         {
532         OMX_INIT_STRUCT_PTR (&bControl, OMX_TI_CONFIG_LOCAL_AND_GLOBAL_BRIGHTNESSCONTRASTTYPE);
533 
534         bControl.nPortIndex = OMX_ALL;
535 
536         switch ( mode )
537             {
538             case OMXCameraAdapter::BRIGHTNESS_ON:
539                 {
540                 bControl.eControl = OMX_TI_BceModeOn;
541                 break;
542                 }
543             case OMXCameraAdapter::BRIGHTNESS_AUTO:
544                 {
545                 bControl.eControl = OMX_TI_BceModeAuto;
546                 break;
547                 }
548             case OMXCameraAdapter::BRIGHTNESS_OFF:
549             default:
550                 {
551                 bControl.eControl = OMX_TI_BceModeOff;
552                 break;
553                 }
554             }
555 
556         eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp,
557                                ( OMX_INDEXTYPE ) OMX_TI_IndexConfigGlobalBrightnessContrastEnhance,
558                                &bControl);
559         if ( OMX_ErrorNone != eError )
560             {
561             CAMHAL_LOGEB("Error while setting GBCE 0x%x", eError);
562             }
563         else
564             {
565             CAMHAL_LOGDB("GBCE configured successfully 0x%x", mode);
566             }
567         }
568 
569     LOG_FUNCTION_NAME_EXIT;
570 
571     return ret;
572 }
573 
setGLBCE(OMXCameraAdapter::BrightnessMode mode)574 status_t OMXCameraAdapter::setGLBCE(OMXCameraAdapter::BrightnessMode mode)
575 {
576     status_t ret = NO_ERROR;
577     OMX_ERRORTYPE eError = OMX_ErrorNone;
578     OMX_TI_CONFIG_LOCAL_AND_GLOBAL_BRIGHTNESSCONTRASTTYPE bControl;
579 
580     LOG_FUNCTION_NAME;
581 
582     if ( OMX_StateInvalid == mComponentState )
583         {
584         CAMHAL_LOGEA("OMX component is in invalid state");
585         ret = -EINVAL;
586         }
587 
588     if ( NO_ERROR == ret )
589         {
590         OMX_INIT_STRUCT_PTR (&bControl, OMX_TI_CONFIG_LOCAL_AND_GLOBAL_BRIGHTNESSCONTRASTTYPE);
591         bControl.nPortIndex = OMX_ALL;
592 
593         switch ( mode )
594             {
595             case OMXCameraAdapter::BRIGHTNESS_ON:
596                 {
597                 bControl.eControl = OMX_TI_BceModeOn;
598                 break;
599                 }
600             case OMXCameraAdapter::BRIGHTNESS_AUTO:
601                 {
602                 bControl.eControl = OMX_TI_BceModeAuto;
603                 break;
604                 }
605             case OMXCameraAdapter::BRIGHTNESS_OFF:
606             default:
607                 {
608                 bControl.eControl = OMX_TI_BceModeOff;
609                 break;
610                 }
611             }
612 
613         eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp,
614                                ( OMX_INDEXTYPE ) OMX_TI_IndexConfigLocalBrightnessContrastEnhance,
615                                &bControl);
616         if ( OMX_ErrorNone != eError )
617             {
618             CAMHAL_LOGEB("Error while configure GLBCE 0x%x", eError);
619             }
620         else
621             {
622             CAMHAL_LOGDA("GLBCE configured successfully");
623             }
624         }
625 
626     LOG_FUNCTION_NAME_EXIT;
627 
628     return ret;
629 }
630 
setCaptureMode(OMXCameraAdapter::CaptureMode mode)631 status_t OMXCameraAdapter::setCaptureMode(OMXCameraAdapter::CaptureMode mode)
632 {
633     status_t ret = NO_ERROR;
634     OMX_ERRORTYPE eError = OMX_ErrorNone;
635     OMX_CONFIG_CAMOPERATINGMODETYPE camMode;
636     OMX_CONFIG_BOOLEANTYPE bCAC;
637     OMX_TI_CONFIG_SINGLEPREVIEWMODETYPE singlePrevMode;
638 
639     LOG_FUNCTION_NAME;
640 
641     //CAC is disabled by default
642     OMX_INIT_STRUCT_PTR (&bCAC, OMX_CONFIG_BOOLEANTYPE);
643     OMX_INIT_STRUCT_PTR (&singlePrevMode, OMX_TI_CONFIG_SINGLEPREVIEWMODETYPE);
644     bCAC.bEnabled = OMX_FALSE;
645 
646     if ( NO_ERROR == ret )
647         {
648 
649         OMX_INIT_STRUCT_PTR (&camMode, OMX_CONFIG_CAMOPERATINGMODETYPE);
650         if ( mSensorIndex == OMX_TI_StereoSensor ) {
651             if ( OMXCameraAdapter::VIDEO_MODE == mode ) {
652                 CAMHAL_LOGDA("Camera mode: STEREO VIDEO");
653                 camMode.eCamOperatingMode = OMX_TI_StereoVideo;
654             } else {
655                 CAMHAL_LOGDA("Camera mode: STEREO");
656                 camMode.eCamOperatingMode = OMX_CaptureStereoImageCapture;
657             }
658         } else if ( OMXCameraAdapter::HIGH_SPEED == mode ) {
659             CAMHAL_LOGDA("Camera mode: HIGH SPEED");
660             camMode.eCamOperatingMode = OMX_CaptureImageHighSpeedTemporalBracketing;
661         } else if ( OMXCameraAdapter::CP_CAM == mode ) {
662             CAMHAL_LOGDA("Camera mode: CP CAM");
663             camMode.eCamOperatingMode = OMX_TI_CPCam;
664             // TODO(XXX): Hardcode for now until we implement re-proc pipe
665             singlePrevMode.eMode = OMX_TI_SinglePreviewMode_ImageCaptureHighSpeed;
666         } else if( OMXCameraAdapter::HIGH_QUALITY == mode ) {
667             CAMHAL_LOGDA("Camera mode: HIGH QUALITY");
668             camMode.eCamOperatingMode = OMX_CaptureImageProfileBase;
669         } else if( OMXCameraAdapter::HIGH_QUALITY_ZSL== mode ) {
670             const char* valstr = NULL;
671             CAMHAL_LOGDA("Camera mode: HIGH QUALITY_ZSL");
672             camMode.eCamOperatingMode = OMX_TI_CaptureImageProfileZeroShutterLag;
673 
674 #ifdef CAMERAHAL_TUNA
675             if ( !mIternalRecordingHint ) {
676                 zslHistoryLen.nHistoryLen = 5;
677             }
678 #endif
679 
680         } else if( OMXCameraAdapter::VIDEO_MODE == mode ) {
681             CAMHAL_LOGDA("Camera mode: VIDEO MODE");
682             camMode.eCamOperatingMode = OMX_CaptureVideo;
683         } else if( OMXCameraAdapter::VIDEO_MODE_HQ == mode ) {
684             CAMHAL_LOGDA("Camera mode: VIDEO MODE HQ");
685             camMode.eCamOperatingMode = OMX_CaptureHighQualityVideo;
686         } else {
687             CAMHAL_LOGEA("Camera mode: INVALID mode passed!");
688             return BAD_VALUE;
689         }
690 
691         if( NO_ERROR == ret )
692             {
693             eError =  OMX_SetParameter(mCameraAdapterParameters.mHandleComp,
694                                        ( OMX_INDEXTYPE ) OMX_IndexCameraOperatingMode,
695                                        &camMode);
696             if ( OMX_ErrorNone != eError )
697                 {
698                 CAMHAL_LOGEB("Error while configuring camera mode 0x%x", eError);
699                 ret = Utils::ErrorUtils::omxToAndroidError(eError);
700                 }
701             else
702                 {
703                 CAMHAL_LOGDA("Camera mode configured successfully");
704                 }
705             }
706 
707         if((NO_ERROR == ret) && (OMXCameraAdapter::CP_CAM == mode)) {
708             //Configure Single Preview Mode
709             eError =  OMX_SetConfig(mCameraAdapterParameters.mHandleComp,
710                                     ( OMX_INDEXTYPE ) OMX_TI_IndexConfigSinglePreviewMode,
711                                     &singlePrevMode);
712             if ( OMX_ErrorNone != eError ) {
713                 CAMHAL_LOGEB("Error while configuring single preview mode 0x%x", eError);
714                 ret = Utils::ErrorUtils::omxToAndroidError(eError);
715             } else {
716                 CAMHAL_LOGDA("single preview mode configured successfully");
717             }
718         }
719 
720 
721         if( NO_ERROR == ret )
722             {
723             //Configure CAC
724             eError =  OMX_SetConfig(mCameraAdapterParameters.mHandleComp,
725                                     ( OMX_INDEXTYPE ) OMX_IndexConfigChromaticAberrationCorrection,
726                                     &bCAC);
727             if ( OMX_ErrorNone != eError )
728                 {
729                 CAMHAL_LOGEB("Error while configuring CAC 0x%x", eError);
730                 ret = Utils::ErrorUtils::omxToAndroidError(eError);
731                 }
732             else
733                 {
734                 CAMHAL_LOGDA("CAC configured successfully");
735                 }
736             }
737         }
738 
739     LOG_FUNCTION_NAME_EXIT;
740 
741     return ret;
742 }
743 
setLDC(OMXCameraAdapter::IPPMode mode)744 status_t OMXCameraAdapter::setLDC(OMXCameraAdapter::IPPMode mode)
745 {
746     status_t ret = NO_ERROR;
747     OMX_ERRORTYPE eError = OMX_ErrorNone;
748     OMX_CONFIG_BOOLEANTYPE bOMX;
749 
750     LOG_FUNCTION_NAME;
751 
752     if ( OMX_StateLoaded != mComponentState )
753         {
754         CAMHAL_LOGEA("OMX component is not in loaded state");
755         ret = -EINVAL;
756         }
757 
758     if ( NO_ERROR == ret )
759         {
760         OMX_INIT_STRUCT_PTR (&bOMX, OMX_CONFIG_BOOLEANTYPE);
761 
762         switch ( mode )
763             {
764             case OMXCameraAdapter::IPP_LDCNSF:
765             case OMXCameraAdapter::IPP_LDC:
766                 {
767                 bOMX.bEnabled = OMX_TRUE;
768                 break;
769                 }
770             case OMXCameraAdapter::IPP_NONE:
771             case OMXCameraAdapter::IPP_NSF:
772             default:
773                 {
774                 bOMX.bEnabled = OMX_FALSE;
775                 break;
776                 }
777             }
778 
779         CAMHAL_LOGVB("Configuring LDC mode 0x%x", bOMX.bEnabled);
780         eError = OMX_SetParameter(mCameraAdapterParameters.mHandleComp,
781                                   ( OMX_INDEXTYPE ) OMX_IndexParamLensDistortionCorrection,
782                                   &bOMX);
783         if ( OMX_ErrorNone != eError )
784             {
785             CAMHAL_LOGEA("Error while setting LDC");
786             ret = -1;
787             }
788         }
789 
790     LOG_FUNCTION_NAME_EXIT;
791 
792     return ret;
793 }
794 
setNSF(OMXCameraAdapter::IPPMode mode)795 status_t OMXCameraAdapter::setNSF(OMXCameraAdapter::IPPMode mode)
796 {
797     status_t ret = NO_ERROR;
798     OMX_ERRORTYPE eError = OMX_ErrorNone;
799     OMX_PARAM_ISONOISEFILTERTYPE nsf;
800 
801     LOG_FUNCTION_NAME;
802 
803     if ( OMX_StateLoaded != mComponentState )
804         {
805         CAMHAL_LOGEA("OMX component is not in loaded state");
806         ret = -EINVAL;
807         }
808 
809     if ( NO_ERROR == ret )
810         {
811         OMX_INIT_STRUCT_PTR (&nsf, OMX_PARAM_ISONOISEFILTERTYPE);
812         nsf.nPortIndex = OMX_ALL;
813 
814         switch ( mode )
815             {
816             case OMXCameraAdapter::IPP_LDCNSF:
817             case OMXCameraAdapter::IPP_NSF:
818                 {
819                 nsf.eMode = OMX_ISONoiseFilterModeOn;
820                 break;
821                 }
822             case OMXCameraAdapter::IPP_LDC:
823             case OMXCameraAdapter::IPP_NONE:
824             default:
825                 {
826                 nsf.eMode = OMX_ISONoiseFilterModeOff;
827                 break;
828                 }
829             }
830 
831         CAMHAL_LOGVB("Configuring NSF mode 0x%x", nsf.eMode);
832         eError = OMX_SetParameter(mCameraAdapterParameters.mHandleComp,
833                                   (OMX_INDEXTYPE)OMX_IndexParamHighISONoiseFiler,
834                                   &nsf);
835         if ( OMX_ErrorNone != eError )
836             {
837             CAMHAL_LOGEA("Error while setting NSF");
838             ret = -1;
839             }
840         }
841 
842     LOG_FUNCTION_NAME_EXIT;
843 
844     return ret;
845 }
846 
setImageQuality(unsigned int quality)847 status_t OMXCameraAdapter::setImageQuality(unsigned int quality)
848 {
849     status_t ret = NO_ERROR;
850     OMX_ERRORTYPE eError = OMX_ErrorNone;
851     OMX_IMAGE_PARAM_QFACTORTYPE jpegQualityConf;
852 
853     LOG_FUNCTION_NAME;
854 
855     if ( OMX_StateInvalid == mComponentState )
856         {
857         CAMHAL_LOGEA("OMX component is in invalid state");
858         ret = -EINVAL;
859         }
860 
861     if ( NO_ERROR == ret )
862         {
863         OMX_INIT_STRUCT(jpegQualityConf, OMX_IMAGE_PARAM_QFACTORTYPE);
864         jpegQualityConf.nQFactor = quality;
865         jpegQualityConf.nPortIndex = mCameraAdapterParameters.mImagePortIndex;
866 
867         eError = OMX_SetParameter(mCameraAdapterParameters.mHandleComp,
868                                   OMX_IndexParamQFactor,
869                                   &jpegQualityConf);
870         if ( OMX_ErrorNone != eError )
871             {
872             CAMHAL_LOGEB("Error while configuring jpeg Quality 0x%x", eError);
873             ret = -1;
874             }
875         }
876 
877     LOG_FUNCTION_NAME_EXIT;
878 
879     return ret;
880 }
881 
setThumbnailParams(unsigned int width,unsigned int height,unsigned int quality)882 status_t OMXCameraAdapter::setThumbnailParams(unsigned int width,
883                                               unsigned int height,
884                                               unsigned int quality)
885 {
886     status_t ret = NO_ERROR;
887     OMX_ERRORTYPE eError = OMX_ErrorNone;
888     OMX_PARAM_THUMBNAILTYPE thumbConf;
889 
890     LOG_FUNCTION_NAME;
891 
892     if ( OMX_StateInvalid == mComponentState )
893         {
894         CAMHAL_LOGEA("OMX component is in invalid state");
895         ret = -EINVAL;
896         }
897 
898     if ( NO_ERROR == ret )
899         {
900         OMX_INIT_STRUCT(thumbConf, OMX_PARAM_THUMBNAILTYPE);
901         thumbConf.nPortIndex = mCameraAdapterParameters.mImagePortIndex;
902 
903         eError = OMX_GetParameter(mCameraAdapterParameters.mHandleComp,
904                                   ( OMX_INDEXTYPE ) OMX_IndexParamThumbnail,
905                                   &thumbConf);
906         if ( OMX_ErrorNone != eError )
907             {
908             CAMHAL_LOGEB("Error while retrieving thumbnail size 0x%x", eError);
909             ret = -1;
910             }
911 
912         //CTS Requirement: width or height equal to zero should
913         //result in absent EXIF thumbnail
914         if ( ( 0 == width ) || ( 0 == height ) )
915             {
916             thumbConf.nWidth = mThumbRes[0].width;
917             thumbConf.nHeight = mThumbRes[0].height;
918             thumbConf.eCompressionFormat = OMX_IMAGE_CodingUnused;
919             }
920         else
921             {
922             thumbConf.nWidth = width;
923             thumbConf.nHeight = height;
924             thumbConf.nQuality = quality;
925             thumbConf.eCompressionFormat = OMX_IMAGE_CodingJPEG;
926             }
927 
928         CAMHAL_LOGDB("Thumbnail width = %d, Thumbnail Height = %d", width, height);
929 
930         eError = OMX_SetParameter(mCameraAdapterParameters.mHandleComp,
931                                   ( OMX_INDEXTYPE ) OMX_IndexParamThumbnail,
932                                   &thumbConf);
933         if ( OMX_ErrorNone != eError )
934             {
935             CAMHAL_LOGEB("Error while configuring thumbnail size 0x%x", eError);
936             ret = -1;
937             }
938         }
939 
940     LOG_FUNCTION_NAME_EXIT;
941 
942     return ret;
943 }
944 
setAlgoPriority(AlgoPriority priority,Algorithm3A algo,bool enable)945 status_t OMXCameraAdapter::setAlgoPriority(AlgoPriority priority,
946                                            Algorithm3A algo,
947                                            bool enable)
948 {
949     OMX_ERRORTYPE eError = OMX_ErrorNone;
950 
951     LOG_FUNCTION_NAME;
952 
953     if ( OMX_StateInvalid == mComponentState ) {
954         CAMHAL_LOGEA("OMX component is in invalid state");
955         return NO_INIT;
956     }
957 
958     if ( FACE_PRIORITY == priority ) {
959 
960         if ( algo & WHITE_BALANCE_ALGO ) {
961             if ( enable ) {
962                 mFacePriority.bAwbFaceEnable =  OMX_TRUE;
963             } else {
964                 mFacePriority.bAwbFaceEnable =  OMX_FALSE;
965             }
966         }
967 
968         if ( algo & EXPOSURE_ALGO ) {
969             if ( enable ) {
970                 mFacePriority.bAeFaceEnable =  OMX_TRUE;
971             } else {
972                 mFacePriority.bAeFaceEnable =  OMX_FALSE;
973             }
974         }
975 
976         if ( algo & FOCUS_ALGO ) {
977             if ( enable ) {
978                 mFacePriority.bAfFaceEnable =  OMX_TRUE;
979             } else {
980                 mFacePriority.bAfFaceEnable =  OMX_FALSE;
981             }
982         }
983 
984         eError =  OMX_SetConfig(mCameraAdapterParameters.mHandleComp,
985                                 ( OMX_INDEXTYPE ) OMX_TI_IndexConfigFacePriority3a,
986                                 &mFacePriority);
987         if ( OMX_ErrorNone != eError ) {
988             CAMHAL_LOGEB("Error while configuring face priority 0x%x", eError);
989         } else {
990             CAMHAL_LOGDB("Face priority for algorithms set successfully 0x%x, 0x%x, 0x%x",
991                          mFacePriority.bAfFaceEnable,
992                          mFacePriority.bAeFaceEnable,
993                          mFacePriority.bAwbFaceEnable);
994         }
995 
996     } else if ( REGION_PRIORITY == priority ) {
997 
998         if ( algo & WHITE_BALANCE_ALGO ) {
999             if ( enable ) {
1000                 mRegionPriority.bAwbRegionEnable= OMX_TRUE;
1001             } else {
1002                 mRegionPriority.bAwbRegionEnable = OMX_FALSE;
1003             }
1004         }
1005 
1006         if ( algo & EXPOSURE_ALGO ) {
1007             if ( enable ) {
1008                 mRegionPriority.bAeRegionEnable = OMX_TRUE;
1009             } else {
1010                 mRegionPriority.bAeRegionEnable = OMX_FALSE;
1011             }
1012         }
1013 
1014         if ( algo & FOCUS_ALGO ) {
1015             if ( enable ) {
1016                 mRegionPriority.bAfRegionEnable = OMX_TRUE;
1017             } else {
1018                 mRegionPriority.bAfRegionEnable = OMX_FALSE;
1019             }
1020         }
1021 
1022         eError =  OMX_SetConfig(mCameraAdapterParameters.mHandleComp,
1023                                 ( OMX_INDEXTYPE ) OMX_TI_IndexConfigRegionPriority3a,
1024                                 &mRegionPriority);
1025         if ( OMX_ErrorNone != eError ) {
1026             CAMHAL_LOGEB("Error while configuring region priority 0x%x", eError);
1027         } else {
1028             CAMHAL_LOGDB("Region priority for algorithms set successfully 0x%x, 0x%x, 0x%x",
1029                          mRegionPriority.bAfRegionEnable,
1030                          mRegionPriority.bAeRegionEnable,
1031                          mRegionPriority.bAwbRegionEnable);
1032         }
1033 
1034     }
1035 
1036     LOG_FUNCTION_NAME_EXIT;
1037 
1038     return Utils::ErrorUtils::omxToAndroidError(eError);
1039 }
1040 
setPictureRotation(unsigned int degree)1041 status_t OMXCameraAdapter::setPictureRotation(unsigned int degree)
1042 {
1043     status_t ret = NO_ERROR;
1044     OMX_ERRORTYPE eError = OMX_ErrorNone;
1045     OMX_CONFIG_ROTATIONTYPE rotation;
1046 
1047     LOG_FUNCTION_NAME;
1048 
1049     if ( OMX_StateInvalid == mComponentState )
1050         {
1051         CAMHAL_LOGEA("OMX component is in invalid state");
1052         ret = -1;
1053         }
1054 
1055     if ( NO_ERROR == ret )
1056         {
1057         OMX_INIT_STRUCT(rotation, OMX_CONFIG_ROTATIONTYPE);
1058         rotation.nRotation = degree;
1059         rotation.nPortIndex = mCameraAdapterParameters.mImagePortIndex;
1060 
1061         eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp,
1062                                OMX_IndexConfigCommonRotate,
1063                                &rotation);
1064         if ( OMX_ErrorNone != eError )
1065             {
1066             CAMHAL_LOGEB("Error while configuring rotation 0x%x", eError);
1067             }
1068         }
1069 
1070     LOG_FUNCTION_NAME_EXIT;
1071 
1072     return ret;
1073 }
1074 
setSensorOrientation(unsigned int degree)1075 status_t OMXCameraAdapter::setSensorOrientation(unsigned int degree)
1076 {
1077     status_t ret = NO_ERROR;
1078     OMX_ERRORTYPE eError = OMX_ErrorNone;
1079     OMX_CONFIG_ROTATIONTYPE sensorOrientation;
1080     int tmpHeight, tmpWidth;
1081     OMXCameraPortParameters *mPreviewData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex];
1082 
1083     LOG_FUNCTION_NAME;
1084     if ( OMX_StateInvalid == mComponentState ) {
1085         CAMHAL_LOGEA("OMX component is in invalid state");
1086         ret = -1;
1087     }
1088 
1089     /* Set Temproary Port resolution.
1090     * For resolution with height >= 720,
1091     * resolution cannot be set without configuring orientation.
1092     * So we first set a temp resolution. We have used VGA
1093     */
1094     if ( mPreviewData->mHeight >= 720 ) {
1095         tmpHeight = mPreviewData->mHeight;
1096         tmpWidth = mPreviewData->mWidth;
1097         mPreviewData->mWidth = 640;
1098         mPreviewData->mHeight = 480;
1099 
1100         ret = setFormat(OMX_CAMERA_PORT_VIDEO_OUT_PREVIEW, *mPreviewData);
1101         if ( NO_ERROR != ret ) {
1102             CAMHAL_LOGEB("Error while configuring format 0x%x", ret);
1103             return ret;
1104         }
1105 
1106         mPreviewData->mWidth = tmpWidth;
1107         mPreviewData->mHeight = tmpHeight;
1108         mPreviewPortInitialized = true;
1109     }
1110     else if (!mPreviewPortInitialized) {
1111         ret = setFormat(OMX_CAMERA_PORT_VIDEO_OUT_PREVIEW, *mPreviewData);
1112         if ( NO_ERROR != ret ) {
1113             CAMHAL_LOGEB("Error while configuring format 0x%x", ret);
1114             return ret;
1115         }
1116         mPreviewPortInitialized = true;
1117     }
1118 
1119     /* Now set Required Orientation*/
1120     if ( NO_ERROR == ret ) {
1121         OMX_INIT_STRUCT(sensorOrientation, OMX_CONFIG_ROTATIONTYPE);
1122         sensorOrientation.nPortIndex = mCameraAdapterParameters.mPrevPortIndex;
1123         sensorOrientation.nRotation = degree;
1124         eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp,
1125                                OMX_IndexConfigCommonRotate,
1126                                &sensorOrientation);
1127         if ( OMX_ErrorNone != eError ) {
1128             CAMHAL_LOGEB("Error while configuring rotation 0x%x", eError);
1129         }
1130         CAMHAL_LOGVB(" Currently Sensor Orientation is set to : %d",
1131                      ( unsigned int ) sensorOrientation.nRotation);
1132         CAMHAL_LOGVB(" Sensor Configured for Port : %d",
1133                      ( unsigned int ) sensorOrientation.nPortIndex);
1134     }
1135 
1136     /* Now set the required resolution as requested */
1137     if ( NO_ERROR == ret ) {
1138         bool portConfigured = false;
1139         ret = setSensorQuirks(degree,
1140                 mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex],
1141                 portConfigured);
1142         if ( NO_ERROR != ret ) {
1143             CAMHAL_LOGEB("Error while configuring setSensorQuirks 0x%x", ret);
1144             return ret;
1145         }
1146 
1147         if ( !portConfigured ) {
1148             ret = setFormat (mCameraAdapterParameters.mPrevPortIndex,
1149                              mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex]);
1150             if ( NO_ERROR != ret ) {
1151                 CAMHAL_LOGEB("Error while configuring format 0x%x", ret);
1152                 return ret;
1153             }
1154 
1155             // Another WA: Setting the port definition will reset the VFR
1156             //             configuration.
1157             setVFramerate(mPreviewData->mMinFrameRate,
1158                           mPreviewData->mMaxFrameRate);
1159         }
1160     }
1161 
1162     LOG_FUNCTION_NAME_EXIT;
1163 
1164     return ret;
1165 }
1166 
setVFramerate(OMX_U32 minFrameRate,OMX_U32 maxFrameRate)1167 status_t OMXCameraAdapter::setVFramerate(OMX_U32 minFrameRate, OMX_U32 maxFrameRate)
1168 {
1169     status_t ret = NO_ERROR;
1170     OMX_ERRORTYPE eError = OMX_ErrorNone;
1171     OMX_TI_CONFIG_VARFRMRANGETYPE vfr;
1172     OMXCameraPortParameters * mPreviewData =
1173         &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex];
1174 
1175     LOG_FUNCTION_NAME;
1176 
1177     if ( OMX_StateInvalid == mComponentState ) {
1178         CAMHAL_LOGEA("OMX component is in invalid state");
1179         ret = -EINVAL;
1180     }
1181 
1182     if ( !mSetFormatDone ) {
1183         return NO_INIT;
1184     }
1185 
1186     if ( NO_ERROR == ret ) {
1187         OMX_INIT_STRUCT_PTR (&vfr, OMX_TI_CONFIG_VARFRMRANGETYPE);
1188 
1189         vfr.xMin = minFrameRate<<16;
1190         vfr.xMax = maxFrameRate<<16;
1191 
1192         eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp,
1193                                (OMX_INDEXTYPE)OMX_TI_IndexConfigVarFrmRange,
1194                                &vfr);
1195         if(OMX_ErrorNone != eError) {
1196             CAMHAL_LOGEB("Error while setting VFR min = %d, max = %d, error = 0x%x",
1197                          ( unsigned int ) minFrameRate,
1198                          ( unsigned int ) maxFrameRate,
1199                          eError);
1200             ret = -1;
1201         } else {
1202             CAMHAL_LOGDB("VFR Configured Successfully [%d:%d]",
1203                         ( unsigned int ) minFrameRate,
1204                         ( unsigned int ) maxFrameRate);
1205         }
1206     }
1207 
1208     return ret;
1209  }
1210 
setMechanicalMisalignmentCorrection(const bool enable)1211 status_t OMXCameraAdapter::setMechanicalMisalignmentCorrection(const bool enable)
1212 {
1213     status_t ret = NO_ERROR;
1214     OMX_ERRORTYPE eError = OMX_ErrorNone;
1215     OMX_TI_CONFIG_MM mm;
1216 
1217     LOG_FUNCTION_NAME;
1218 
1219     mm.nVersion = mLocalVersionParam;
1220     mm.nSize = sizeof(OMX_TI_CONFIG_MM);
1221     mm.nPortIndex = mCameraAdapterParameters.mPrevPortIndex;
1222     mm.bMM = enable ? OMX_TRUE : OMX_FALSE;
1223 
1224     eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp,
1225                            (OMX_INDEXTYPE)OMX_TI_IndexConfigMechanicalMisalignment,
1226                            &mm);
1227 
1228     if(OMX_ErrorNone != eError) {
1229         CAMHAL_LOGEB("Error while enabling mechanical misalignment correction. error = 0x%x", eError);
1230         ret = -1;
1231     }
1232 
1233     LOG_FUNCTION_NAME_EXIT;
1234 
1235     return ret;
1236 }
1237 
1238 } // namespace Camera
1239 } // namespace Ti
1240