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 
19 #ifndef OMX_CAMERA_ADAPTER_H
20 #define OMX_CAMERA_ADAPTER_H
21 
22 #include "CameraHal.h"
23 #include "OMX_Types.h"
24 #include "OMX_Core.h"
25 #include "OMX_CoreExt.h"
26 #include "OMX_IVCommon.h"
27 #include "OMX_Component.h"
28 #include "OMX_Index.h"
29 #include "OMX_IndexExt.h"
30 #include "OMX_TI_Index.h"
31 #include "OMX_TI_IVCommon.h"
32 #include "OMX_TI_Common.h"
33 #include "OMX_TI_Image.h"
34 #include "General3A_Settings.h"
35 #include "OMXSceneModeTables.h"
36 
37 #include "BaseCameraAdapter.h"
38 #include "Encoder_libjpeg.h"
39 #include "DebugUtils.h"
40 
41 
42 extern "C"
43 {
44 #include "timm_osal_error.h"
45 #include "timm_osal_events.h"
46 #include "timm_osal_trace.h"
47 #include "timm_osal_semaphores.h"
48 }
49 
50 
51 namespace Ti {
52 namespace Camera {
53 
54 #define Q16_OFFSET                  16
55 
56 #define OMX_CMD_TIMEOUT             3000000  //3 sec.
57 #define OMX_CAPTURE_TIMEOUT         5000000  //5 sec.
58 
59 #define FOCUS_THRESHOLD             5 //[s.]
60 
61 #define MIN_JPEG_QUALITY            1
62 #define MAX_JPEG_QUALITY            100
63 #define EXP_BRACKET_RANGE           10
64 #define ZOOM_BRACKET_RANGE          10
65 
66 #define FOCUS_DIST_SIZE             100
67 #define FOCUS_DIST_BUFFER_SIZE      500
68 
69 #define TOUCH_DATA_SIZE             200
70 #define DEFAULT_THUMB_WIDTH         160
71 #define DEFAULT_THUMB_HEIGHT        120
72 #define FRAME_RATE_FULL_HD          27
73 #define FRAME_RATE_HIGH_HD          60
74 
75 #define ZOOM_STAGES                 61
76 
77 #define FACE_DETECTION_BUFFER_SIZE  0x1000
78 #define MAX_NUM_FACES_SUPPORTED     35
79 
80 #define EXIF_MODEL_SIZE             100
81 #define EXIF_MAKE_SIZE              100
82 #define EXIF_DATE_TIME_SIZE         20
83 
84 #define GPS_MIN_DIV                 60
85 #define GPS_SEC_DIV                 60
86 #define GPS_SEC_ACCURACY            1000
87 #define GPS_TIMESTAMP_SIZE          6
88 #define GPS_DATESTAMP_SIZE          11
89 #define GPS_REF_SIZE                2
90 #define GPS_MAPDATUM_SIZE           100
91 #define GPS_PROCESSING_SIZE         100
92 #define GPS_VERSION_SIZE            4
93 #define GPS_NORTH_REF               "N"
94 #define GPS_SOUTH_REF               "S"
95 #define GPS_EAST_REF                "E"
96 #define GPS_WEST_REF                "W"
97 
98 /* Default portstartnumber of Camera component */
99 #define OMX_CAMERA_DEFAULT_START_PORT_NUM 0
100 
101 /* Define number of ports for differt domains */
102 #define OMX_CAMERA_PORT_OTHER_NUM 1
103 #define OMX_CAMERA_PORT_VIDEO_NUM 4
104 #define OMX_CAMERA_PORT_IMAGE_NUM 1
105 #define OMX_CAMERA_PORT_AUDIO_NUM 0
106 #define OMX_CAMERA_NUM_PORTS (OMX_CAMERA_PORT_OTHER_NUM + OMX_CAMERA_PORT_VIDEO_NUM + OMX_CAMERA_PORT_IMAGE_NUM + OMX_CAMERA_PORT_AUDIO_NUM)
107 
108 /* Define start port number for differt domains */
109 #define OMX_CAMERA_PORT_OTHER_START OMX_CAMERA_DEFAULT_START_PORT_NUM
110 #define OMX_CAMERA_PORT_VIDEO_START (OMX_CAMERA_PORT_OTHER_START + OMX_CAMERA_PORT_OTHER_NUM)
111 #define OMX_CAMERA_PORT_IMAGE_START (OMX_CAMERA_PORT_VIDEO_START + OMX_CAMERA_PORT_VIDEO_NUM)
112 #define OMX_CAMERA_PORT_AUDIO_START (OMX_CAMERA_PORT_IMAGE_START + OMX_CAMERA_PORT_IMAGE_NUM)
113 
114 /* Port index for camera component */
115 #define OMX_CAMERA_PORT_OTHER_IN (OMX_CAMERA_PORT_OTHER_START + 0)
116 #define OMX_CAMERA_PORT_VIDEO_IN_VIDEO (OMX_CAMERA_PORT_VIDEO_START + 0)
117 #define OMX_CAMERA_PORT_VIDEO_OUT_PREVIEW (OMX_CAMERA_PORT_VIDEO_START + 1)
118 #define OMX_CAMERA_PORT_VIDEO_OUT_VIDEO (OMX_CAMERA_PORT_VIDEO_START + 2)
119 #define OMX_CAMERA_PORT_VIDEO_OUT_MEASUREMENT (OMX_CAMERA_PORT_VIDEO_START + 3)
120 #define OMX_CAMERA_PORT_IMAGE_OUT_IMAGE (OMX_CAMERA_PORT_IMAGE_START + 0)
121 
122 
123 #define OMX_INIT_STRUCT(_s_, _name_)       \
124     memset(&(_s_), 0x0, sizeof(_name_));   \
125     (_s_).nSize = sizeof(_name_);          \
126     (_s_).nVersion.s.nVersionMajor = 0x1;  \
127     (_s_).nVersion.s.nVersionMinor = 0x1;  \
128     (_s_).nVersion.s.nRevision = 0x0;      \
129     (_s_).nVersion.s.nStep = 0x0
130 
131 #define OMX_INIT_STRUCT_PTR(_s_, _name_)   \
132     memset((_s_), 0x0, sizeof(_name_));    \
133     (_s_)->nSize = sizeof(_name_);         \
134     (_s_)->nVersion.s.nVersionMajor = 0x1; \
135     (_s_)->nVersion.s.nVersionMinor = 0x1; \
136     (_s_)->nVersion.s.nRevision = 0x0;     \
137     (_s_)->nVersion.s.nStep = 0x0
138 
139 #define GOTO_EXIT_IF(_CONDITION,_ERROR) {  \
140     if ((_CONDITION)) {                    \
141         eError = (_ERROR);                 \
142         goto EXIT;                         \
143     }                                      \
144 }
145 
146 const int64_t kCameraBufferLatencyNs = 250000000LL; // 250 ms
147 
148 ///OMX Specific Functions
149 static OMX_ERRORTYPE OMXCameraAdapterEventHandler(OMX_IN OMX_HANDLETYPE hComponent,
150                                         OMX_IN OMX_PTR pAppData,
151                                         OMX_IN OMX_EVENTTYPE eEvent,
152                                         OMX_IN OMX_U32 nData1,
153                                         OMX_IN OMX_U32 nData2,
154                                         OMX_IN OMX_PTR pEventData);
155 
156 static OMX_ERRORTYPE OMXCameraAdapterEmptyBufferDone(OMX_IN OMX_HANDLETYPE hComponent,
157                                         OMX_IN OMX_PTR pAppData,
158                                         OMX_IN OMX_BUFFERHEADERTYPE* pBuffer);
159 
160 static OMX_ERRORTYPE OMXCameraAdapterFillBufferDone(OMX_IN OMX_HANDLETYPE hComponent,
161                                         OMX_IN OMX_PTR pAppData,
162                                         OMX_IN OMX_BUFFERHEADERTYPE* pBuffHeader);
163 
164 struct CapResolution {
165     size_t width, height;
166     const char *param;
167 };
168 
169 struct CapPixelformat {
170     OMX_COLOR_FORMATTYPE pixelformat;
171     const char *param;
172 };
173 
174 struct CapCodingFormat {
175     OMX_IMAGE_CODINGTYPE imageCodingFormat;
176     const char *param;
177 };
178 
179 struct CapU32 {
180     OMX_U32 num;
181     const char *param;
182 };
183 
184 struct CapS32 {
185     OMX_S32 num;
186     const char *param;
187 };
188 
189 typedef CapU32 CapFramerate;
190 typedef CapU32 CapISO;
191 typedef CapU32 CapSensorName;
192 typedef CapS32 CapZoom;
193 
194 /**
195   * Class which completely abstracts the camera hardware interaction from camera hal
196   * TODO: Need to list down here, all the message types that will be supported by this class
197                 Need to implement BufferProvider interface to use AllocateBuffer of OMX if needed
198   */
199 class OMXCameraAdapter : public BaseCameraAdapter
200 {
201 public:
202 
203     /*--------------------Constant declarations----------------------------------------*/
204     static const int32_t MAX_NO_BUFFERS = 20;
205 
206     ///@remarks OMX Camera has six ports - buffer input, time input, preview, image, video, and meta data
207     static const int MAX_NO_PORTS = 6;
208 
209     ///Five second timeout
210     static const int CAMERA_ADAPTER_TIMEOUT = 5000*1000;
211 
212     enum CaptureMode
213         {
214         INITIAL_MODE = -1,
215         HIGH_SPEED = 1,
216         HIGH_QUALITY,
217         VIDEO_MODE,
218         HIGH_QUALITY_ZSL,
219         CP_CAM,
220         VIDEO_MODE_HQ,
221         };
222 
223     enum IPPMode
224         {
225         IPP_NULL = -1,
226         IPP_NONE = 0,
227         IPP_NSF,
228         IPP_LDC,
229         IPP_LDCNSF,
230         };
231 
232     enum CodingMode
233         {
234         CodingJPEG = 0,
235         CodingJPS,
236         CodingMPO,
237         };
238 
239     enum Algorithm3A
240         {
241         WHITE_BALANCE_ALGO = 0x1,
242         EXPOSURE_ALGO = 0x2,
243         FOCUS_ALGO = 0x4,
244         };
245 
246     enum AlgoPriority
247         {
248         FACE_PRIORITY = 0,
249         REGION_PRIORITY,
250         };
251 
252     enum BrightnessMode
253         {
254         BRIGHTNESS_OFF = 0,
255         BRIGHTNESS_ON,
256         BRIGHTNESS_AUTO,
257         };
258 
259     enum CaptureSettingsFlags {
260         SetFormat               = 1 << 0,
261         SetThumb                = 1 << 1,
262         SetBurstExpBracket      = 1 << 2,
263         SetQuality              = 1 << 3,
264         SetRotation             = 1 << 4,
265         ECaptureSettingMax,
266         ECapturesettingsAll = ( ((ECaptureSettingMax -1 ) << 1) -1 ), /// all possible flags raised
267         ECaptureParamSettings = SetFormat | SetThumb | SetQuality, // Settings set with SetParam
268         ECaptureConfigSettings = (ECapturesettingsAll & ~ECaptureParamSettings)
269     };
270 
271     enum PreviewSettingsFlags {
272         SetLDC                  = 1 << 0,
273         SetNSF                  = 1 << 1,
274         SetCapMode              = 1 << 2,
275         SetVNF                  = 1 << 3,
276         SetVSTAB                = 1 << 4,
277         EPreviewSettingMax,
278         EPreviewSettingsAll = ( ((EPreviewSettingMax -1 ) << 1) -1 ) /// all possible flags raised
279     };
280 
281     enum BracketingValueMode {
282         BracketingValueAbsolute,
283         BracketingValueRelative,
284         BracketingValueAbsoluteForced,
285         BracketingValueRelativeForced,
286         BracketingValueCompensation,
287         BracketingValueCompensationForced
288     };
289 
290     class GPSData
291     {
292         public:
293                 int mLongDeg, mLongMin, mLongSec, mLongSecDiv;
294                 char mLongRef[GPS_REF_SIZE];
295                 bool mLongValid;
296                 int mLatDeg, mLatMin, mLatSec, mLatSecDiv;
297                 char mLatRef[GPS_REF_SIZE];
298                 bool mLatValid;
299                 int mAltitude;
300                 unsigned char mAltitudeRef;
301                 bool mAltitudeValid;
302                 char mMapDatum[GPS_MAPDATUM_SIZE];
303                 bool mMapDatumValid;
304                 char mVersionId[GPS_VERSION_SIZE];
305                 bool mVersionIdValid;
306                 char mProcMethod[GPS_PROCESSING_SIZE];
307                 bool mProcMethodValid;
308                 char mDatestamp[GPS_DATESTAMP_SIZE];
309                 bool mDatestampValid;
310                 uint32_t mTimeStampHour;
311                 uint32_t mTimeStampMin;
312                 uint32_t mTimeStampSec;
313                 bool mTimeStampValid;
314     };
315 
316     class EXIFData
317     {
318         public:
319             GPSData mGPSData;
320             char mMake[EXIF_MODEL_SIZE];
321             char mModel[EXIF_MAKE_SIZE];
322             unsigned int mFocalNum, mFocalDen;
323             bool mMakeValid;
324             bool mModelValid;
325     };
326 
327     ///Parameters specific to any port of the OMX Camera component
328     class OMXCameraPortParameters
329     {
330         public:
331             //CameraBuffer *                  mHostBufaddr[MAX_NO_BUFFERS];
332             OMX_BUFFERHEADERTYPE           *mBufferHeader[MAX_NO_BUFFERS];
333             OMX_U8                          mStatus[MAX_NO_BUFFERS];
334             OMX_U32                         mWidth;
335             OMX_U32                         mHeight;
336             OMX_U32                         mStride;
337             OMX_U8                          mNumBufs;
338 
339             // defines maximum number of buffers our of mNumBufs
340             // queueable at given moment
341             OMX_U8                          mMaxQueueable;
342 
343             OMX_U32                         mBufSize;
344             OMX_COLOR_FORMATTYPE            mColorFormat;
345             OMX_PARAM_VIDEONOISEFILTERTYPE  mVNFMode;
346             OMX_PARAM_VIDEOYUVRANGETYPE     mYUVRange;
347             OMX_CONFIG_BOOLEANTYPE          mVidStabParam;
348             OMX_CONFIG_FRAMESTABTYPE        mVidStabConfig;
349             OMX_U32                         mCapFrame;
350             OMX_U32                         mFrameRate;
351             OMX_U32                         mMinFrameRate;
352             OMX_U32                         mMaxFrameRate;
353             CameraFrame::FrameType          mImageType;
354             OMX_TI_STEREOFRAMELAYOUTTYPE    mFrameLayoutType;
355             CameraBufferType                mBufferType;
356 
357             CameraBuffer * lookup_omx_buffer (OMX_BUFFERHEADERTYPE *pBufHeader);
358             enum {
359                IDLE = 0, // buffer is neither with HAL or Ducati
360                FILL, // buffer is with Ducati
361                DONE, // buffer is filled and sent to HAL
362             };
363     };
364 
365     ///Context of the OMX Camera component
366     class OMXCameraAdapterComponentContext
367     {
368         public:
369             OMX_HANDLETYPE              mHandleComp;
370             OMX_U32                     mNumPorts;
371             OMX_STATETYPE               mState ;
372             OMX_U32                     mVideoPortIndex;
373             OMX_U32                     mPrevPortIndex;
374             OMX_U32                     mImagePortIndex;
375             OMX_U32                     mMeasurementPortIndex;
376             OMX_U32                     mVideoInPortIndex;
377             OMXCameraPortParameters     mCameraPortParams[MAX_NO_PORTS];
378     };
379 
380     class CachedCaptureParameters
381     {
382         public:
383             unsigned int mPendingCaptureSettings;
384             unsigned int mPictureRotation;
385             int mExposureBracketingValues[EXP_BRACKET_RANGE];
386             int mExposureGainBracketingValues[EXP_BRACKET_RANGE];
387             int mExposureGainBracketingModes[EXP_BRACKET_RANGE];
388             size_t mExposureBracketingValidEntries;
389             OMX_BRACKETMODETYPE mExposureBracketMode;
390             unsigned int mBurstFrames;
391             bool mFlushShotConfigQueue;
392     };
393 
394 public:
395 
396     OMXCameraAdapter(size_t sensor_index);
397     ~OMXCameraAdapter();
398 
399     ///Initialzes the camera adapter creates any resources required
400     virtual status_t initialize(CameraProperties::Properties*);
401 
402     //APIs to configure Camera adapter and get the current parameter set
403     virtual status_t setParameters(const android::CameraParameters& params);
404     virtual void getParameters(android::CameraParameters& params);
405 
406     // API
407     status_t UseBuffersPreview(CameraBuffer *bufArr, int num);
408 
409     //API to flush the buffers
410     status_t flushBuffers(OMX_U32 port = OMX_CAMERA_PORT_VIDEO_OUT_PREVIEW);
411 
412     // API
413     virtual status_t setFormat(OMX_U32 port, OMXCameraPortParameters &cap);
414 
415     // Function to get and populate caps from handle
416     static status_t getCaps(int sensorId, CameraProperties::Properties* props, OMX_HANDLETYPE handle);
417     static const char* getLUTvalue_OMXtoHAL(int OMXValue, LUTtype LUT);
418     static int getMultipleLUTvalue_OMXtoHAL(int OMXValue, LUTtype LUT, char * supported);
419     static int getLUTvalue_HALtoOMX(const char * HalValue, LUTtype LUT);
420 
421  OMX_ERRORTYPE OMXCameraAdapterEventHandler(OMX_IN OMX_HANDLETYPE hComponent,
422                                     OMX_IN OMX_EVENTTYPE eEvent,
423                                     OMX_IN OMX_U32 nData1,
424                                     OMX_IN OMX_U32 nData2,
425                                     OMX_IN OMX_PTR pEventData);
426 
427  OMX_ERRORTYPE OMXCameraAdapterEmptyBufferDone(OMX_IN OMX_HANDLETYPE hComponent,
428                                     OMX_IN OMX_BUFFERHEADERTYPE* pBuffer);
429 
430  OMX_ERRORTYPE OMXCameraAdapterFillBufferDone(OMX_IN OMX_HANDLETYPE hComponent,
431                                     OMX_IN OMX_BUFFERHEADERTYPE* pBuffHeader);
432 
433  static OMX_ERRORTYPE OMXCameraGetHandle(OMX_HANDLETYPE *handle, OMX_PTR pAppData,
434         const OMX_CALLBACKTYPE & callbacks);
435 
436 protected:
437 
438     //Parent class method implementation
439     virtual status_t takePicture();
440     virtual status_t stopImageCapture();
441     virtual status_t startBracketing(int range);
442     virtual status_t stopBracketing();
443     virtual status_t autoFocus();
444     virtual status_t cancelAutoFocus();
445     virtual status_t startSmoothZoom(int targetIdx);
446     virtual status_t stopSmoothZoom();
447     virtual status_t startVideoCapture();
448     virtual status_t stopVideoCapture();
449     virtual status_t startPreview();
450     virtual status_t stopPreview();
451     virtual status_t useBuffers(CameraMode mode, CameraBuffer * bufArr, int num, size_t length, unsigned int queueable);
452     virtual status_t fillThisBuffer(CameraBuffer * frameBuf, CameraFrame::FrameType frameType);
453     virtual status_t getFrameSize(size_t &width, size_t &height);
454     virtual status_t getPictureBufferSize(CameraFrame &frame, size_t bufferCount);
455     virtual status_t getFrameDataSize(size_t &dataFrameSize, size_t bufferCount);
456     virtual status_t startFaceDetection();
457     virtual status_t stopFaceDetection();
458     virtual status_t switchToExecuting();
459     virtual void onOrientationEvent(uint32_t orientation, uint32_t tilt);
460 
461 private:
462 
463     // Caches and returns current set of parameters
464     CachedCaptureParameters* cacheCaptureParameters();
465 
466     status_t doSwitchToExecuting();
467 
468     void performCleanupAfterError();
469 
470     status_t switchToIdle();
471 
472     status_t switchToLoaded(bool bPortEnableRequired = false);
473     status_t prevPortEnable();
474 
475     OMXCameraPortParameters *getPortParams(CameraFrame::FrameType frameType);
476 
477     OMX_ERRORTYPE SignalEvent(OMX_IN OMX_HANDLETYPE hComponent,
478                                                   OMX_IN OMX_EVENTTYPE eEvent,
479                                                   OMX_IN OMX_U32 nData1,
480                                                   OMX_IN OMX_U32 nData2,
481                                                   OMX_IN OMX_PTR pEventData);
482     OMX_ERRORTYPE RemoveEvent(OMX_IN OMX_HANDLETYPE hComponent,
483                               OMX_IN OMX_EVENTTYPE eEvent,
484                               OMX_IN OMX_U32 nData1,
485                               OMX_IN OMX_U32 nData2,
486                               OMX_IN OMX_PTR pEventData);
487 
488     status_t RegisterForEvent(OMX_IN OMX_HANDLETYPE hComponent,
489                                           OMX_IN OMX_EVENTTYPE eEvent,
490                                           OMX_IN OMX_U32 nData1,
491                                           OMX_IN OMX_U32 nData2,
492                                           OMX_IN Utils::Semaphore &semaphore);
493 
494     status_t setPictureRotation(unsigned int degree);
495     status_t setSensorOrientation(unsigned int degree);
496     status_t setImageQuality(unsigned int quality);
497     status_t setThumbnailParams(unsigned int width, unsigned int height, unsigned int quality);
498     status_t setSensorQuirks(int orientation,
499                              OMXCameraPortParameters &portParams,
500                              bool &portConfigured);
501 
502     status_t setupTunnel(uint32_t SliceHeight, uint32_t EncoderHandle, uint32_t width, uint32_t height);
503     status_t destroyTunnel();
504 
505     //EXIF
506     status_t setParametersEXIF(const android::CameraParameters &params,
507                                BaseCameraAdapter::AdapterState state);
508     status_t convertGPSCoord(double coord, int &deg, int &min, int &sec, int &secDivisor);
509     status_t setupEXIF();
510     status_t setupEXIF_libjpeg(ExifElementsTable*, OMX_TI_ANCILLARYDATATYPE*,
511                                OMX_TI_WHITEBALANCERESULTTYPE*);
512 
513     //Focus functionality
514     status_t doAutoFocus();
515     status_t stopAutoFocus();
516     status_t checkFocus(OMX_PARAM_FOCUSSTATUSTYPE *eFocusStatus);
517     status_t returnFocusStatus(bool timeoutReached);
518     status_t getFocusMode(OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE &focusMode);
519     void handleFocusCallback();
520 
521 
522     //Focus distances
523     status_t setParametersFocus(const android::CameraParameters &params,
524                                 BaseCameraAdapter::AdapterState state);
525     status_t addFocusDistances(OMX_U32 &near,
526                                OMX_U32 &optimal,
527                                OMX_U32 &far,
528                                android::CameraParameters& params);
529     status_t encodeFocusDistance(OMX_U32 dist, char *buffer, size_t length);
530     status_t getFocusDistances(OMX_U32 &near,OMX_U32 &optimal, OMX_U32 &far);
531 
532     //VSTAB and VNF Functionality
533     status_t enableVideoNoiseFilter(bool enable);
534     status_t enableVideoStabilization(bool enable);
535 
536     //Digital zoom
537     status_t setParametersZoom(const android::CameraParameters &params,
538                                BaseCameraAdapter::AdapterState state);
539     status_t doZoom(int index);
540     status_t advanceZoom();
541 
542     //3A related parameters
543     status_t setParameters3A(const android::CameraParameters &params,
544                              BaseCameraAdapter::AdapterState state);
545     void declareParameter3ABool(const android::CameraParameters &params, const char *key,
546                                 OMX_BOOL &current_setting, E3ASettingsFlags pending,
547                                 const char *msg);
548 
549     // scene modes
550     status_t setScene(Gen3A_settings& Gen3A);
551     // returns pointer to SceneModesEntry from the LUT for camera given 'name' and 'scene'
552     static const SceneModesEntry* getSceneModeEntry(const char* name, OMX_SCENEMODETYPE scene);
553 
554 
555     //Flash modes
556     status_t setFlashMode(Gen3A_settings& Gen3A);
557     status_t getFlashMode(Gen3A_settings& Gen3A);
558 
559     // Focus modes
560     status_t setFocusMode(Gen3A_settings& Gen3A);
561     status_t getFocusMode(Gen3A_settings& Gen3A);
562 
563     //Exposure Modes
564     status_t setExposureMode(Gen3A_settings& Gen3A);
565     status_t setManualExposureVal(Gen3A_settings& Gen3A);
566     status_t setEVCompensation(Gen3A_settings& Gen3A);
567     status_t setWBMode(Gen3A_settings& Gen3A);
568     status_t setFlicker(Gen3A_settings& Gen3A);
569     status_t setBrightness(Gen3A_settings& Gen3A);
570     status_t setContrast(Gen3A_settings& Gen3A);
571     status_t setSharpness(Gen3A_settings& Gen3A);
572     status_t setSaturation(Gen3A_settings& Gen3A);
573     status_t setISO(Gen3A_settings& Gen3A);
574     status_t setEffect(Gen3A_settings& Gen3A);
575     status_t setMeteringAreas(Gen3A_settings& Gen3A);
576 
577     //TI extensions for enable/disable algos
578     status_t setParameter3ABool(const OMX_INDEXTYPE omx_idx,
579                                 const OMX_BOOL data, const char *msg);
580     status_t setParameter3ABoolInvert(const OMX_INDEXTYPE omx_idx,
581                                       const OMX_BOOL data, const char *msg);
582     status_t setAlgoExternalGamma(Gen3A_settings& Gen3A);
583     status_t setAlgoNSF1(Gen3A_settings& Gen3A);
584     status_t setAlgoNSF2(Gen3A_settings& Gen3A);
585     status_t setAlgoSharpening(Gen3A_settings& Gen3A);
586     status_t setAlgoThreeLinColorMap(Gen3A_settings& Gen3A);
587     status_t setAlgoGIC(Gen3A_settings& Gen3A);
588 
589     //Gamma table
590     void updateGammaTable(const char* gamma);
591     status_t setGammaTable(Gen3A_settings& Gen3A);
592 
593     status_t getEVCompensation(Gen3A_settings& Gen3A);
594     status_t getWBMode(Gen3A_settings& Gen3A);
595     status_t getSharpness(Gen3A_settings& Gen3A);
596     status_t getSaturation(Gen3A_settings& Gen3A);
597     status_t getISO(Gen3A_settings& Gen3A);
598 
599     // 3A locks
600     status_t setExposureLock(Gen3A_settings& Gen3A);
601     status_t setFocusLock(Gen3A_settings& Gen3A);
602     status_t setWhiteBalanceLock(Gen3A_settings& Gen3A);
603     status_t set3ALock(OMX_BOOL toggleExp, OMX_BOOL toggleWb, OMX_BOOL toggleFocus);
604 
605     //Stereo 3D
606     void setParamS3D(OMX_U32 port, const char *valstr);
607     status_t setS3DFrameLayout(OMX_U32 port) const;
608 
609     //API to set FrameRate using VFR interface
610     status_t setVFramerate(OMX_U32 minFrameRate,OMX_U32 maxFrameRate);
611 
612     status_t setParametersAlgo(const android::CameraParameters &params,
613                                BaseCameraAdapter::AdapterState state);
614 
615     //Noise filtering
616     status_t setNSF(OMXCameraAdapter::IPPMode mode);
617 
618     //LDC
619     status_t setLDC(OMXCameraAdapter::IPPMode mode);
620 
621     //GLBCE
622     status_t setGLBCE(OMXCameraAdapter::BrightnessMode mode);
623 
624     //GBCE
625     status_t setGBCE(OMXCameraAdapter::BrightnessMode mode);
626 
627     status_t printComponentVersion(OMX_HANDLETYPE handle);
628 
629     //Touch AF
630     status_t setTouchFocus();
631 
632     //Face detection
633     status_t setParametersFD(const android::CameraParameters &params,
634                              BaseCameraAdapter::AdapterState state);
635     status_t updateFocusDistances(android::CameraParameters &params);
636     status_t setFaceDetectionOrientation(OMX_U32 orientation);
637     status_t setFaceDetection(bool enable, OMX_U32 orientation);
638     status_t createPreviewMetadata(OMX_BUFFERHEADERTYPE* pBuffHeader,
639                          android::sp<CameraMetadataResult> &result,
640                          size_t previewWidth,
641                          size_t previewHeight);
642     status_t encodeFaceCoordinates(const OMX_FACEDETECTIONTYPE *faceData,
643                                    camera_frame_metadata_t *metadataResult,
644                                    size_t previewWidth,
645                                    size_t previewHeight);
646     status_t encodePreviewMetadata(camera_frame_metadata_t *meta, const OMX_PTR plat_pvt);
647 
648     void pauseFaceDetection(bool pause);
649 
650     //3A Algorithms priority configuration
651     status_t setAlgoPriority(AlgoPriority priority, Algorithm3A algo, bool enable);
652 
653     //Sensor overclocking
654     status_t setSensorOverclock(bool enable);
655 
656     // Utility methods for OMX Capabilities
657     static bool _checkOmxTiCap(const OMX_TI_CAPTYPE & caps);
658     static bool _dumpOmxTiCap(int sensorId, const OMX_TI_CAPTYPE & caps);
659 
660     static status_t insertCapabilities(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
661     static status_t encodeSizeCap(OMX_TI_CAPRESTYPE&, const CapResolution *, size_t, char *, size_t);
662     static status_t encodeISOCap(OMX_U32, const CapISO*, size_t, char*, size_t);
663     static size_t encodeZoomCap(OMX_S32, const CapZoom*, size_t, char*, size_t);
664     static void encodeFrameRates(int minFrameRate, int maxFrameRate, const OMX_TI_CAPTYPE & caps,
665             const CapFramerate * fixedFrameRates, int frameRateCount, android::Vector<FpsRange> & fpsRanges);
666     static status_t encodeImageCodingFormatCap(OMX_IMAGE_CODINGTYPE,
667                                                 const CapCodingFormat *,
668                                                 size_t,
669                                                 char *);
670     static status_t encodePixelformatCap(OMX_COLOR_FORMATTYPE,
671                                          const CapPixelformat*,
672                                          size_t,
673                                          char*,
674                                          size_t);
675     static status_t encodeSizeCap3D(OMX_TI_CAPRESTYPE&,
676                                     const CapResolution*,
677                                     size_t ,
678                                     char * ,
679                                     size_t);
680     static status_t insertImageSizes(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
681     static status_t insertPreviewSizes(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
682     static status_t insertThumbSizes(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
683     static status_t insertZoomStages(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
684     static status_t insertImageFormats(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
685     static status_t insertPreviewFormats(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
686     static status_t insertFramerates(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
687     static status_t insertEVs(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
688     static status_t insertISOModes(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
689     static status_t insertIPPModes(CameraProperties::Properties*, OMX_TI_CAPTYPE &);
690     static status_t insertWBModes(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
691     static status_t insertEffects(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
692     static status_t insertExpModes(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
693     static status_t insertManualExpRanges(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
694     static status_t insertSceneModes(CameraProperties::Properties*, OMX_TI_CAPTYPE &);
695     static status_t insertFocusModes(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
696     static status_t insertFlickerModes(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
697     static status_t insertFlashModes(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
698     static status_t insertSenMount(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
699     static status_t insertDefaults(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
700     static status_t insertLocks(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
701     static status_t insertAreas(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
702     static status_t insertMechanicalMisalignmentCorrection(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
703     static status_t insertCaptureModes(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
704     static status_t insertVideoSizes(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
705     static status_t insertFacing(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
706     static status_t insertFocalLength(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
707     static status_t insertAutoConvergenceModes(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
708     static status_t insertManualConvergenceRange(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
709     static status_t insertLayout(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
710     static status_t insertVideoSnapshotSupported(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
711     static status_t insertVNFSupported(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps);
712     static status_t insertVSTABSupported(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps);
713     static status_t insertGBCESupported(CameraProperties::Properties* params,
714                                         const OMX_TI_CAPTYPE &caps);
715     static status_t insertGLBCESupported(CameraProperties::Properties* params,
716                                          const OMX_TI_CAPTYPE &caps);
717     static status_t insertRaw(CameraProperties::Properties*, OMX_TI_CAPTYPE&);
718 
719     status_t setParametersCapture(const android::CameraParameters &params,
720                                   BaseCameraAdapter::AdapterState state);
721 
722     //Exposure Bracketing
723     status_t initVectorShot();
724     status_t setVectorShot(int *evValues, int *evValues2, int *evModes2,
725                            size_t evCount, size_t frameCount,
726                            bool flush, OMX_BRACKETMODETYPE bracketMode);
727     status_t setVectorStop(bool toPreview = false);
728     status_t setExposureBracketing(int *evValues, int *evValues2,
729                                    size_t evCount, size_t frameCount,
730                                    OMX_BRACKETMODETYPE bracketMode);
731     status_t doExposureBracketing(int *evValues, int *evValues2,
732                                   int *evModes2,
733                                   size_t evCount, size_t frameCount,
734                                   bool flush,
735                                   OMX_BRACKETMODETYPE bracketMode);
736     int getBracketingValueMode(const char *a, const char *b) const;
737     status_t parseExpRange(const char *rangeStr, int *expRange, int *gainRange,
738                            int *expGainModes,
739                            size_t count, size_t &validEntries);
740 
741     //Temporal Bracketing
742     status_t doBracketing(OMX_BUFFERHEADERTYPE *pBuffHeader, CameraFrame::FrameType typeOfFrame);
743     status_t sendBracketFrames(size_t &framesSent);
744 
745     // Image Capture Service
746     status_t startImageCapture(bool bracketing, CachedCaptureParameters*);
747     status_t disableImagePort();
748 
749     //Shutter callback notifications
750     status_t setShutterCallback(bool enabled);
751 
752     //Sets eithter HQ or HS mode and the frame count
753     status_t setCaptureMode(OMXCameraAdapter::CaptureMode mode);
754     status_t UseBuffersCapture(CameraBuffer *bufArr, int num);
755     status_t UseBuffersPreviewData(CameraBuffer *bufArr, int num);
756     status_t UseBuffersRawCapture(CameraBuffer *bufArr, int num);
757 
758     //Used for calculation of the average frame rate during preview
759     status_t recalculateFPS();
760 
761     //Sends the incoming OMX buffer header to subscribers
762     status_t sendCallBacks(CameraFrame frame, OMX_IN OMX_BUFFERHEADERTYPE *pBuffHeader, unsigned int mask, OMXCameraPortParameters *port);
763 
764     status_t apply3Asettings( Gen3A_settings& Gen3A );
765 
766     // AutoConvergence
767     status_t setAutoConvergence(const char *valstr, const char *pValManualstr, const android::CameraParameters &params);
768 
769     status_t setExtraData(bool enable, OMX_U32, OMX_EXT_EXTRADATATYPE);
770     OMX_OTHER_EXTRADATATYPE *getExtradata(const OMX_PTR ptrPrivate, OMX_EXTRADATATYPE type) const;
771 
772     // Meta data
773 #ifdef OMAP_ENHANCEMENT_CPCAM
774     camera_memory_t * getMetaData(const OMX_PTR plat_pvt,
775                                   camera_request_memory allocator) const;
776 #endif
777 
778     // Mechanical Misalignment Correction
779     status_t setMechanicalMisalignmentCorrection(bool enable);
780 
781     // DCC file data save
782     status_t initDccFileDataSave(OMX_HANDLETYPE* omxHandle, int portIndex);
783     status_t sniffDccFileDataSave(OMX_BUFFERHEADERTYPE* pBuffHeader);
784     status_t saveDccFileDataSave();
785     status_t closeDccFileDataSave();
786     status_t fseekDCCuseCasePos(FILE *pFile);
787     FILE * fopenCameraDCC(const char *dccFolderPath);
788     FILE * parseDCCsubDir(DIR *pDir, char *path);
789 
790 #ifdef CAMERAHAL_OMX_PROFILING
791     status_t storeProfilingData(OMX_BUFFERHEADERTYPE* pBuffHeader);
792 #endif
793 
794     // Internal buffers
795     status_t initInternalBuffers (OMX_U32);
796     status_t deinitInternalBuffers (OMX_U32);
797 
798     // Reprocess Methods -- implementation in OMXReprocess.cpp
799     status_t setParametersReprocess(const android::CameraParameters &params, CameraBuffer* bufs,
800                                   BaseCameraAdapter::AdapterState state);
801     status_t startReprocess();
802     status_t disableReprocess();
803     status_t stopReprocess();
804     status_t UseBuffersReprocess(CameraBuffer *bufArr, int num);
805 
806     class CommandHandler : public android::Thread {
807         public:
CommandHandler(OMXCameraAdapter * ca)808             CommandHandler(OMXCameraAdapter* ca)
809                 : android::Thread(false), mCameraAdapter(ca) { }
810 
threadLoop()811             virtual bool threadLoop() {
812                 bool ret;
813                 ret = Handler();
814                 return ret;
815             }
816 
put(Utils::Message * msg)817             status_t put(Utils::Message* msg){
818                 android::AutoMutex lock(mLock);
819                 return mCommandMsgQ.put(msg);
820             }
821 
clearCommandQ()822             void clearCommandQ()
823                 {
824                 android::AutoMutex lock(mLock);
825                 mCommandMsgQ.clear();
826                 }
827 
828             enum {
829                 COMMAND_EXIT = -1,
830                 CAMERA_START_IMAGE_CAPTURE = 0,
831                 CAMERA_PERFORM_AUTOFOCUS,
832                 CAMERA_SWITCH_TO_EXECUTING,
833                 CAMERA_START_REPROCESS
834             };
835 
836         private:
837             bool Handler();
838             Utils::MessageQueue mCommandMsgQ;
839             OMXCameraAdapter* mCameraAdapter;
840             android::Mutex mLock;
841     };
842     android::sp<CommandHandler> mCommandHandler;
843 
844 public:
845 
846     class OMXCallbackHandler : public android::Thread {
847         public:
OMXCallbackHandler(OMXCameraAdapter * ca)848         OMXCallbackHandler(OMXCameraAdapter* ca)
849             : Thread(false), mCameraAdapter(ca)
850         {
851             mIsProcessed = true;
852         }
853 
threadLoop()854         virtual bool threadLoop() {
855             bool ret;
856             ret = Handler();
857             return ret;
858         }
859 
put(Utils::Message * msg)860         status_t put(Utils::Message* msg){
861             android::AutoMutex lock(mLock);
862             mIsProcessed = false;
863             return mCommandMsgQ.put(msg);
864         }
865 
clearCommandQ()866         void clearCommandQ()
867             {
868             android::AutoMutex lock(mLock);
869             mCommandMsgQ.clear();
870             }
871 
872         void flush();
873 
874         enum {
875             COMMAND_EXIT = -1,
876             CAMERA_FILL_BUFFER_DONE,
877             CAMERA_FOCUS_STATUS
878         };
879 
880     private:
881         bool Handler();
882         Utils::MessageQueue mCommandMsgQ;
883         OMXCameraAdapter* mCameraAdapter;
884         android::Mutex mLock;
885         android::Condition mCondition;
886         bool mIsProcessed;
887     };
888 
889     android::sp<OMXCallbackHandler> mOMXCallbackHandler;
890 
891 private:
892 
893     //AF callback
894     status_t setFocusCallback(bool enabled);
895 
896     //OMX Capabilities data
897     static const CapResolution mImageCapRes [];
898     static const CapResolution mImageCapResSS [];
899     static const CapResolution mImageCapResTB [];
900     static const CapResolution mPreviewRes [];
901     static const CapResolution mPreviewResSS [];
902     static const CapResolution mPreviewResTB [];
903     static const CapResolution mPreviewPortraitRes [];
904     static const CapResolution mThumbRes [];
905     static const CapPixelformat mPixelformats [];
906     static const userToOMX_LUT mFrameLayout [];
907     static const LUTtype mLayoutLUT;
908     static const CapCodingFormat mImageCodingFormat[];
909     static const CapFramerate mFramerates [];
910     static const CapU32 mSensorNames[] ;
911     static const CapZoom mZoomStages [];
912     static const CapISO mISOStages [];
913     static const int SENSORID_IMX060;
914     static const int SENSORID_OV5650;
915     static const int SENSORID_OV5640;
916     static const int SENSORID_OV14825;
917     static const int SENSORID_S5K4E1GA;
918     static const int SENSORID_S5K6A1GX03;
919     static const int SENSORID_OV8830;
920     static const int SENSORID_OV2722;
921     static const CapU32 mFacing [];
922     static const userToOMX_LUT mAutoConvergence [];
923     static const LUTtype mAutoConvergenceLUT;
924     static const userToOMX_LUT mBracketingModes[];
925     static const LUTtype mBracketingModesLUT;
926 
927     static const int FPS_MIN;
928     static const int FPS_MAX;
929     static const int FPS_MAX_EXTENDED;
930 
931     // OMX Camera defaults
932     static const char DEFAULT_ANTIBANDING[];
933     static const char DEFAULT_BRIGHTNESS[];
934     static const char DEFAULT_CONTRAST[];
935     static const char DEFAULT_EFFECT[];
936     static const char DEFAULT_EV_COMPENSATION[];
937     static const char DEFAULT_EV_STEP[];
938     static const char DEFAULT_EXPOSURE_MODE[];
939     static const char DEFAULT_FLASH_MODE[];
940     static const char DEFAULT_FOCUS_MODE_PREFERRED[];
941     static const char DEFAULT_FOCUS_MODE[];
942     static const char DEFAULT_IPP[];
943     static const char DEFAULT_ISO_MODE[];
944     static const char DEFAULT_JPEG_QUALITY[];
945     static const char DEFAULT_THUMBNAIL_QUALITY[];
946     static const char DEFAULT_THUMBNAIL_SIZE[];
947     static const char DEFAULT_PICTURE_FORMAT[];
948     static const char DEFAULT_S3D_PICTURE_LAYOUT[];
949     static const char DEFAULT_PICTURE_SIZE[];
950     static const char DEFAULT_PICTURE_SS_SIZE[];
951     static const char DEFAULT_PICTURE_TB_SIZE[];
952     static const char DEFAULT_PREVIEW_FORMAT[];
953     static const char DEFAULT_FRAMERATE[];
954     static const char DEFAULT_S3D_PREVIEW_LAYOUT[];
955     static const char DEFAULT_PREVIEW_SIZE[];
956     static const char DEFAULT_PREVIEW_SS_SIZE[];
957     static const char DEFAULT_PREVIEW_TB_SIZE[];
958     static const char DEFAULT_NUM_PREV_BUFS[];
959     static const char DEFAULT_NUM_PIC_BUFS[];
960     static const char DEFAULT_SATURATION[];
961     static const char DEFAULT_SCENE_MODE[];
962     static const char DEFAULT_SHARPNESS[];
963     static const char * DEFAULT_VSTAB;
964     static const char * DEFAULT_VNF;
965     static const char DEFAULT_WB[];
966     static const char DEFAULT_ZOOM[];
967     static const char DEFAULT_MAX_FD_HW_FACES[];
968     static const char DEFAULT_MAX_FD_SW_FACES[];
969     static const char * DEFAULT_AE_LOCK;
970     static const char * DEFAULT_AWB_LOCK;
971     static const char DEFAULT_HOR_ANGLE[];
972     static const char DEFAULT_VER_ANGLE[];
973     static const char DEFAULT_VIDEO_SIZE[];
974     static const char DEFAULT_SENSOR_ORIENTATION[];
975     static const char DEFAULT_AUTOCONVERGENCE_MODE[];
976     static const char DEFAULT_MANUAL_CONVERGENCE[];
977     static const char * DEFAULT_MECHANICAL_MISALIGNMENT_CORRECTION_MODE;
978     static const char DEFAULT_EXIF_MODEL[];
979     static const char DEFAULT_EXIF_MAKE[];
980 
981     static const size_t MAX_FOCUS_AREAS;
982 
983 #ifdef CAMERAHAL_OMX_PROFILING
984 
985     static const char DEFAULT_PROFILE_PATH[];
986     int mDebugProfile;
987 
988 #endif
989 
990     OMX_VERSIONTYPE mCompRevision;
991 
992     //OMX Component UUID
993     OMX_UUIDTYPE mCompUUID;
994 
995     //Current Focus distances
996     char mFocusDistNear[FOCUS_DIST_SIZE];
997     char mFocusDistOptimal[FOCUS_DIST_SIZE];
998     char mFocusDistFar[FOCUS_DIST_SIZE];
999     char mFocusDistBuffer[FOCUS_DIST_BUFFER_SIZE];
1000 
1001     // Current Focus areas
1002     android::Vector<android::sp<CameraArea> > mFocusAreas;
1003     mutable android::Mutex mFocusAreasLock;
1004 
1005     // Current Touch convergence areas
1006     android::Vector<android::sp<CameraArea> > mTouchAreas;
1007     mutable android::Mutex mTouchAreasLock;
1008 
1009     // Current Metering areas
1010     android::Vector<android::sp<CameraArea> > mMeteringAreas;
1011     mutable android::Mutex mMeteringAreasLock;
1012 
1013     OperatingMode mCapabilitiesOpMode;
1014     CaptureMode mCapMode;
1015     // TODO(XXX): Do we really need this lock? Let's
1016     // try to merge temporal bracketing and burst
1017     // capture later
1018     mutable android::Mutex mBurstLock;
1019     size_t mBurstFrames;
1020     size_t mBurstFramesAccum;
1021     size_t mBurstFramesQueued;
1022     size_t mCapturedFrames;
1023     bool mFlushShotConfigQueue;
1024 
1025     bool mMeasurementEnabled;
1026 
1027     //Exposure Bracketing
1028     int mExposureBracketingValues[EXP_BRACKET_RANGE];
1029     int mExposureGainBracketingValues[EXP_BRACKET_RANGE];
1030     int mExposureGainBracketingModes[EXP_BRACKET_RANGE];
1031     size_t mExposureBracketingValidEntries;
1032     OMX_BRACKETMODETYPE mExposureBracketMode;
1033 
1034     //Zoom Bracketing
1035     int mZoomBracketingValues[ZOOM_BRACKET_RANGE];
1036     size_t mZoomBracketingValidEntries;
1037 
1038     static const uint32_t FACE_DETECTION_THRESHOLD;
1039     mutable android::Mutex mFaceDetectionLock;
1040     //Face detection status
1041     bool mFaceDetectionRunning;
1042     bool mFaceDetectionPaused;
1043     bool mFDSwitchAlgoPriority;
1044 
1045     camera_face_t  faceDetectionLastOutput[MAX_NUM_FACES_SUPPORTED];
1046     int faceDetectionNumFacesLastOutput;
1047     int metadataLastAnalogGain;
1048     int metadataLastExposureTime;
1049 
1050     //Geo-tagging
1051     EXIFData mEXIFData;
1052 
1053     //Image post-processing
1054     IPPMode mIPP;
1055 
1056     //jpeg Picture Quality
1057     unsigned int mPictureQuality;
1058 
1059     //thumbnail resolution
1060     unsigned int mThumbWidth, mThumbHeight;
1061 
1062     //thumbnail quality
1063     unsigned int mThumbQuality;
1064 
1065     //variables holding the estimated framerate
1066     float mFPS, mLastFPS;
1067 
1068     //automatically disable AF after a given amount of frames
1069     unsigned int mFocusThreshold;
1070 
1071     //This is needed for the CTS tests. They falsely assume, that during
1072     //smooth zoom the current zoom stage will not change within the
1073     //zoom callback scope, which in a real world situation is not always the
1074     //case. This variable will "simulate" the expected behavior
1075     unsigned int mZoomParameterIdx;
1076 
1077     //current zoom
1078     android::Mutex mZoomLock;
1079     unsigned int mCurrentZoomIdx, mTargetZoomIdx, mPreviousZoomIndx;
1080     bool mZoomUpdating, mZoomUpdate;
1081     int mZoomInc;
1082     bool mReturnZoomStatus;
1083     static const int32_t ZOOM_STEPS [];
1084 
1085      //local copy
1086     OMX_VERSIONTYPE mLocalVersionParam;
1087 
1088     unsigned int mPending3Asettings;
1089     android::Mutex m3ASettingsUpdateLock;
1090     Gen3A_settings mParameters3A;
1091     const char *mPictureFormatFromClient;
1092 
1093     BrightnessMode mGBCE;
1094     BrightnessMode mGLBCE;
1095 
1096     OMX_TI_CONFIG_3A_FACE_PRIORITY mFacePriority;
1097     OMX_TI_CONFIG_3A_REGION_PRIORITY mRegionPriority;
1098 
1099     android::CameraParameters mParams;
1100     CameraProperties::Properties* mCapabilities;
1101     unsigned int mPictureRotation;
1102     bool mWaitingForSnapshot;
1103     bool mCaptureConfigured;
1104     unsigned int mPendingCaptureSettings;
1105     unsigned int mPendingPreviewSettings;
1106     unsigned int mPendingReprocessSettings;
1107     OMX_TI_ANCILLARYDATATYPE* mCaptureAncillaryData;
1108     OMX_TI_WHITEBALANCERESULTTYPE* mWhiteBalanceData;
1109     bool mReprocConfigured;
1110 
1111     //Temporal bracketing management data
1112     bool mBracketingSet;
1113     mutable android::Mutex mBracketingLock;
1114     bool *mBracketingBuffersQueued;
1115     int mBracketingBuffersQueuedCount;
1116     int mLastBracetingBufferIdx;
1117     bool mBracketingEnabled;
1118     bool mZoomBracketingEnabled;
1119     size_t mBracketingRange;
1120     int mCurrentZoomBracketing;
1121     android::CameraParameters mParameters;
1122 
1123 #ifdef CAMERAHAL_TUNA
1124     bool mIternalRecordingHint;
1125 #endif
1126 
1127     bool mOmxInitialized;
1128     OMXCameraAdapterComponentContext mCameraAdapterParameters;
1129     bool mFirstTimeInit;
1130 
1131     ///Semaphores used internally
1132     Utils::Semaphore mInitSem;
1133     Utils::Semaphore mFlushSem;
1134     Utils::Semaphore mUsePreviewDataSem;
1135     Utils::Semaphore mUsePreviewSem;
1136     Utils::Semaphore mUseCaptureSem;
1137     Utils::Semaphore mStartPreviewSem;
1138     Utils::Semaphore mStopPreviewSem;
1139     Utils::Semaphore mStartCaptureSem;
1140     Utils::Semaphore mStopCaptureSem;
1141     Utils::Semaphore mSwitchToLoadedSem;
1142     Utils::Semaphore mSwitchToExecSem;
1143     Utils::Semaphore mStopReprocSem;
1144     Utils::Semaphore mUseReprocessSem;
1145 
1146     mutable android::Mutex mStateSwitchLock;
1147     mutable android::Mutex mIdleStateSwitchLock;
1148 
1149     android::Vector<Utils::Message *> mEventSignalQ;
1150     android::Mutex mEventLock;
1151 
1152     OMX_STATETYPE mComponentState;
1153 
1154     OMX_TI_AUTOCONVERGENCEMODETYPE mAutoConv;
1155     OMX_S32 mManualConv;
1156     bool mVnfEnabled;
1157     bool mVstabEnabled;
1158 
1159     int mSensorOrientation;
1160     int mDeviceOrientation;
1161     int mFaceOrientation;
1162     bool mSensorOverclock;
1163 
1164     //Indicates if we should leave
1165     //OMX_Executing state during
1166     //stop-/startPreview
1167     bool mOMXStateSwitch;
1168 
1169     int mFrameCount;
1170     int mLastFrameCount;
1171     unsigned int mIter;
1172     nsecs_t mLastFPSTime;
1173     android::Mutex mFrameCountMutex;
1174     android::Condition mFirstFrameCondition;
1175 
1176     static const nsecs_t CANCEL_AF_TIMEOUT;
1177     android::Mutex mCancelAFMutex;
1178     android::Condition mCancelAFCond;
1179 
1180     android::Mutex mDoAFMutex;
1181     android::Condition mDoAFCond;
1182 
1183     size_t mSensorIndex;
1184     CodingMode mCodingMode;
1185 
1186     // Time source delta of ducati & system time
1187     OMX_TICKS mTimeSourceDelta;
1188     bool onlyOnce;
1189 
1190     Utils::Semaphore mCaptureSem;
1191     bool mCaptureSignalled;
1192 
1193     OMX_BOOL mUserSetExpLock;
1194     OMX_BOOL mUserSetWbLock;
1195 
1196 #ifdef CAMERAHAL_USE_RAW_IMAGE_SAVING
1197     bool mRawCapture;
1198     bool mYuvCapture;
1199 #endif
1200 
1201     bool mSetFormatDone;
1202 
1203     OMX_TI_DCCDATATYPE mDccData;
1204     android::Mutex mDccDataLock;
1205 
1206     int mMaxZoomSupported;
1207     android::Mutex mImageCaptureLock;
1208 
1209     bool mTunnelDestroyed;
1210     bool mPreviewPortInitialized;
1211 
1212     // Used for allocations that need to be sent to Ducati
1213     MemoryManager mMemMgr;
1214 };
1215 
1216 } // namespace Camera
1217 } // namespace Ti
1218 
1219 #endif //OMX_CAMERA_ADAPTER_H
1220