Home | History | Annotate | Download | only in HAL
      1 /* Copyright (c) 2012-2014, The Linux Foundataion. All rights reserved.
      2  *
      3  * Redistribution and use in source and binary forms, with or without
      4  * modification, are permitted provided that the following conditions are
      5  * met:
      6  *     * Redistributions of source code must retain the above copyright
      7  *       notice, this list of conditions and the following disclaimer.
      8  *     * Redistributions in binary form must reproduce the above
      9  *       copyright notice, this list of conditions and the following
     10  *       disclaimer in the documentation and/or other materials provided
     11  *       with the distribution.
     12  *     * Neither the name of The Linux Foundation nor the names of its
     13  *       contributors may be used to endorse or promote products derived
     14  *       from this software without specific prior written permission.
     15  *
     16  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
     17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
     19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
     20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
     23  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
     25  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
     26  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27  *
     28  */
     29 
     30 #ifndef __QCAMERA2HARDWAREINTERFACE_H__
     31 #define __QCAMERA2HARDWAREINTERFACE_H__
     32 
     33 #include <hardware/camera.h>
     34 #include <hardware/power.h>
     35 #include <utils/Log.h>
     36 #include <utils/Mutex.h>
     37 #include <utils/Condition.h>
     38 #include <QCameraParameters.h>
     39 
     40 #include "QCameraQueue.h"
     41 #include "QCameraCmdThread.h"
     42 #include "QCameraChannel.h"
     43 #include "QCameraStream.h"
     44 #include "QCameraStateMachine.h"
     45 #include "QCameraAllocator.h"
     46 #include "QCameraPostProc.h"
     47 #include "QCameraThermalAdapter.h"
     48 #include "QCameraMem.h"
     49 
     50 extern "C" {
     51 #include <mm_camera_interface.h>
     52 #include <mm_jpeg_interface.h>
     53 }
     54 
     55 #if DISABLE_DEBUG_LOG
     56 
     57 inline void __null_log(int, const char *, const char *, ...) {}
     58 
     59 #ifdef ALOGD
     60 #undef ALOGD
     61 #define ALOGD(...) do { __null_log(0, LOG_TAG,__VA_ARGS__); } while (0)
     62 #endif
     63 
     64 #ifdef ALOGI
     65 #undef ALOGI
     66 #define ALOGI(...) do { __null_log(0, LOG_TAG,__VA_ARGS__); } while (0)
     67 #endif
     68 
     69 #ifdef CDBG
     70 #undef CDBG
     71 #define CDBG(...) do{} while(0)
     72 #endif
     73 
     74 #else
     75 
     76 
     77 #ifdef CDBG
     78 #undef CDBG
     79 #endif //#ifdef CDBG
     80 #define CDBG(fmt, args...) ALOGD_IF(gCamHalLogLevel >= 2, fmt, ##args)
     81 
     82 #ifdef CDBG_HIGH
     83 #undef CDBG_HIGH
     84 #endif //#ifdef CDBG_HIGH
     85 #define CDBG_HIGH(fmt, args...) ALOGD_IF(gCamHalLogLevel >= 1, fmt, ##args)
     86 
     87 #endif // DISABLE_DEBUG_LOG
     88 
     89 namespace qcamera {
     90 
     91 #ifndef TRUE
     92 #define TRUE 1
     93 #endif
     94 
     95 #ifndef FALSE
     96 #define FALSE 0
     97 #endif
     98 
     99 typedef enum {
    100     QCAMERA_CH_TYPE_ZSL,
    101     QCAMERA_CH_TYPE_CAPTURE,
    102     QCAMERA_CH_TYPE_PREVIEW,
    103     QCAMERA_CH_TYPE_VIDEO,
    104     QCAMERA_CH_TYPE_SNAPSHOT,
    105     QCAMERA_CH_TYPE_RAW,
    106     QCAMERA_CH_TYPE_METADATA,
    107     QCAMERA_CH_TYPE_MAX
    108 } qcamera_ch_type_enum_t;
    109 
    110 typedef struct {
    111     int32_t msg_type;
    112     int32_t ext1;
    113     int32_t ext2;
    114 } qcamera_evt_argm_t;
    115 
    116 #define QCAMERA_DUMP_FRM_PREVIEW    1
    117 #define QCAMERA_DUMP_FRM_VIDEO      (1<<1)
    118 #define QCAMERA_DUMP_FRM_SNAPSHOT   (1<<2)
    119 #define QCAMERA_DUMP_FRM_THUMBNAIL  (1<<3)
    120 #define QCAMERA_DUMP_FRM_RAW        (1<<4)
    121 #define QCAMERA_DUMP_FRM_JPEG       (1<<5)
    122 
    123 #define QCAMERA_DUMP_FRM_MASK_ALL    0x000000ff
    124 
    125 #define QCAMERA_ION_USE_CACHE   true
    126 #define QCAMERA_ION_USE_NOCACHE false
    127 #define MAX_ONGOING_JOBS 25
    128 
    129 extern volatile uint32_t gCamHalLogLevel;
    130 
    131 typedef enum {
    132     QCAMERA_NOTIFY_CALLBACK,
    133     QCAMERA_DATA_CALLBACK,
    134     QCAMERA_DATA_TIMESTAMP_CALLBACK,
    135     QCAMERA_DATA_SNAPSHOT_CALLBACK
    136 } qcamera_callback_type_m;
    137 
    138 typedef void (*camera_release_callback)(void *user_data,
    139                                         void *cookie,
    140                                         int32_t cb_status);
    141 
    142 typedef struct {
    143     qcamera_callback_type_m  cb_type;    // event type
    144     int32_t                  msg_type;   // msg type
    145     int32_t                  ext1;       // extended parameter
    146     int32_t                  ext2;       // extended parameter
    147     camera_memory_t *        data;       // ptr to data memory struct
    148     unsigned int             index;      // index of the buf in the whole buffer
    149     int64_t                  timestamp;  // buffer timestamp
    150     camera_frame_metadata_t *metadata;   // meta data
    151     void                    *user_data;  // any data needs to be released after callback
    152     void                    *cookie;     // release callback cookie
    153     camera_release_callback  release_cb; // release callback
    154 } qcamera_callback_argm_t;
    155 
    156 class QCameraCbNotifier {
    157 public:
    158     QCameraCbNotifier(QCamera2HardwareInterface *parent) :
    159                           mNotifyCb (NULL),
    160                           mDataCb (NULL),
    161                           mDataCbTimestamp (NULL),
    162                           mCallbackCookie (NULL),
    163                           mParent (parent),
    164                           mDataQ(releaseNotifications, this),
    165                           mActive(false){}
    166 
    167     virtual ~QCameraCbNotifier();
    168 
    169     virtual int32_t notifyCallback(qcamera_callback_argm_t &cbArgs);
    170     virtual void setCallbacks(camera_notify_callback notifyCb,
    171                               camera_data_callback dataCb,
    172                               camera_data_timestamp_callback dataCbTimestamp,
    173                               void *callbackCookie);
    174     virtual int32_t startSnapshots();
    175     virtual void stopSnapshots();
    176     virtual void exit();
    177     static void * cbNotifyRoutine(void * data);
    178     static void releaseNotifications(void *data, void *user_data);
    179     static bool matchSnapshotNotifications(void *data, void *user_data);
    180 private:
    181 
    182     camera_notify_callback         mNotifyCb;
    183     camera_data_callback           mDataCb;
    184     camera_data_timestamp_callback mDataCbTimestamp;
    185     void                          *mCallbackCookie;
    186     QCamera2HardwareInterface     *mParent;
    187 
    188     QCameraQueue     mDataQ;
    189     QCameraCmdThread mProcTh;
    190     bool             mActive;
    191 };
    192 
    193 class QCamera2HardwareInterface : public QCameraAllocator,
    194                                   public QCameraThermalCallback,
    195                                   public QCameraAdjustFPS,
    196                                   public QCameraTorchInterface
    197 {
    198 public:
    199     /* static variable and functions accessed by camera service */
    200     static camera_device_ops_t mCameraOps;
    201 
    202     static int set_preview_window(struct camera_device *,
    203         struct preview_stream_ops *window);
    204     static void set_CallBacks(struct camera_device *,
    205         camera_notify_callback notify_cb,
    206         camera_data_callback data_cb,
    207         camera_data_timestamp_callback data_cb_timestamp,
    208         camera_request_memory get_memory,
    209         void *user);
    210     static void enable_msg_type(struct camera_device *, int32_t msg_type);
    211     static void disable_msg_type(struct camera_device *, int32_t msg_type);
    212     static int msg_type_enabled(struct camera_device *, int32_t msg_type);
    213     static int start_preview(struct camera_device *);
    214     static void stop_preview(struct camera_device *);
    215     static int preview_enabled(struct camera_device *);
    216     static int store_meta_data_in_buffers(struct camera_device *, int enable);
    217     static int start_recording(struct camera_device *);
    218     static void stop_recording(struct camera_device *);
    219     static int recording_enabled(struct camera_device *);
    220     static void release_recording_frame(struct camera_device *, const void *opaque);
    221     static int auto_focus(struct camera_device *);
    222     static int cancel_auto_focus(struct camera_device *);
    223     static int take_picture(struct camera_device *);
    224     int takeLiveSnapshot_internal();
    225     static int cancel_picture(struct camera_device *);
    226     static int set_parameters(struct camera_device *, const char *parms);
    227     static char* get_parameters(struct camera_device *);
    228     static void put_parameters(struct camera_device *, char *);
    229     static int send_command(struct camera_device *,
    230               int32_t cmd, int32_t arg1, int32_t arg2);
    231     static void release(struct camera_device *);
    232     static int dump(struct camera_device *, int fd);
    233     static int close_camera_device(hw_device_t *);
    234 
    235     static int register_face_image(struct camera_device *,
    236                                    void *img_ptr,
    237                                    cam_pp_offline_src_config_t *config);
    238 public:
    239     QCamera2HardwareInterface(int cameraId);
    240     virtual ~QCamera2HardwareInterface();
    241     int openCamera(struct hw_device_t **hw_device);
    242 
    243     static int getCapabilities(int cameraId, struct camera_info *info);
    244     static int initCapabilities(int cameraId,mm_camera_vtbl_t *cameraHandle);
    245 
    246     // Implementation of QCameraAllocator
    247     virtual QCameraMemory *allocateStreamBuf(cam_stream_type_t stream_type,
    248                                              int size,
    249                                              int stride,
    250                                              int scanline,
    251                                              uint8_t &bufferCnt);
    252     virtual int32_t allocateMoreStreamBuf(QCameraMemory *mem_obj,
    253                                           int size,
    254                                           uint8_t &bufferCnt);
    255 
    256     virtual QCameraHeapMemory *allocateStreamInfoBuf(cam_stream_type_t stream_type);
    257 
    258     // Implementation of QCameraThermalCallback
    259     virtual int thermalEvtHandle(qcamera_thermal_level_enum_t level,
    260             void *userdata, void *data);
    261 
    262     virtual int recalcFPSRange(int &minFPS, int &maxFPS,
    263             int &vidMinFps, int &vidMaxFps);
    264 
    265     // Implementation of QCameraTorchInterface
    266     virtual int prepareTorchCamera();
    267     virtual int releaseTorchCamera();
    268 
    269     friend class QCameraStateMachine;
    270     friend class QCameraPostProcessor;
    271     friend class QCameraCbNotifier;
    272 
    273 private:
    274     int setPreviewWindow(struct preview_stream_ops *window);
    275     int setCallBacks(
    276         camera_notify_callback notify_cb,
    277         camera_data_callback data_cb,
    278         camera_data_timestamp_callback data_cb_timestamp,
    279         camera_request_memory get_memory,
    280         void *user);
    281     int enableMsgType(int32_t msg_type);
    282     int disableMsgType(int32_t msg_type);
    283     int msgTypeEnabled(int32_t msg_type);
    284     int msgTypeEnabledWithLock(int32_t msg_type);
    285     int startPreview();
    286     int stopPreview();
    287     int storeMetaDataInBuffers(int enable);
    288     int startRecording();
    289     int stopRecording();
    290     int releaseRecordingFrame(const void *opaque);
    291     int autoFocus();
    292     int cancelAutoFocus();
    293     int takePicture();
    294     int stopCaptureChannel(bool destroy);
    295     int cancelPicture();
    296     int takeLiveSnapshot();
    297     int cancelLiveSnapshot();
    298     char* getParameters();
    299     int putParameters(char *);
    300     int sendCommand(int32_t cmd, int32_t arg1, int32_t arg2);
    301     int release();
    302     int dump(int fd);
    303     int registerFaceImage(void *img_ptr,
    304                           cam_pp_offline_src_config_t *config,
    305                           int32_t &faceID);
    306     int32_t longShot();
    307 
    308     int openCamera();
    309     int closeCamera();
    310 
    311     int processAPI(qcamera_sm_evt_enum_t api, void *api_payload);
    312     int processEvt(qcamera_sm_evt_enum_t evt, void *evt_payload);
    313     int processSyncEvt(qcamera_sm_evt_enum_t evt, void *evt_payload);
    314     void lockAPI();
    315     void waitAPIResult(qcamera_sm_evt_enum_t api_evt, qcamera_api_result_t *apiResult);
    316     void unlockAPI();
    317     void signalAPIResult(qcamera_api_result_t *result);
    318     void signalEvtResult(qcamera_api_result_t *result);
    319 
    320     int calcThermalLevel(
    321                 qcamera_thermal_level_enum_t level,
    322                 const int minFPS,
    323                 const int maxFPS,
    324                 cam_fps_range_t &adjustedRange,
    325                 enum msm_vfe_frame_skip_pattern &skipPattern);
    326     int updateThermalLevel(qcamera_thermal_level_enum_t level);
    327 
    328     // update entris to set parameters and check if restart is needed
    329     int updateParameters(const char *parms, bool &needRestart);
    330     // send request to server to set parameters
    331     int commitParameterChanges();
    332 
    333     bool isCaptureShutterEnabled();
    334     bool needDebugFps();
    335     bool isRegularCapture();
    336     bool isCACEnabled();
    337     bool is4k2kResolution(cam_dimension_t* resolution);
    338     bool isAFRunning();
    339     bool isPreviewRestartEnabled();
    340     bool needReprocess();
    341     bool needRotationReprocess();
    342     bool needScaleReprocess();
    343     void debugShowVideoFPS();
    344     void debugShowPreviewFPS();
    345     void dumpJpegToFile(const void *data, uint32_t size, int index);
    346     void dumpFrameToFile(QCameraStream *stream,
    347                          mm_camera_buf_def_t *frame,
    348                          int dump_type);
    349     void dumpMetadataToFile(QCameraStream *stream,
    350                             mm_camera_buf_def_t *frame,char *type);
    351     void releaseSuperBuf(mm_camera_super_buf_t *super_buf);
    352     void playShutter();
    353     void getThumbnailSize(cam_dimension_t &dim);
    354     int getJpegQuality();
    355     int getJpegRotation();
    356     void getOrientation();
    357     QCameraExif *getExifData();
    358 
    359     int32_t processAutoFocusEvent(cam_auto_focus_data_t &focus_data);
    360     int32_t processZoomEvent(cam_crop_data_t &crop_info);
    361     int32_t processPrepSnapshotDoneEvent(cam_prep_snapshot_state_t prep_snapshot_state);
    362     int32_t processASDUpdate(cam_auto_scene_t scene);
    363     int32_t processJpegNotify(qcamera_jpeg_evt_payload_t *jpeg_job);
    364     int32_t processHDRData(cam_asd_hdr_scene_data_t hdr_scene);
    365     int32_t processSceneData(cam_scene_mode_type scene);
    366 
    367     int32_t sendEvtNotify(int32_t msg_type, int32_t ext1, int32_t ext2);
    368     int32_t sendDataNotify(int32_t msg_type,
    369                            camera_memory_t *data,
    370                            uint8_t index,
    371                            camera_frame_metadata_t *metadata);
    372 
    373     int32_t sendPreviewCallback(QCameraStream *stream,
    374             QCameraGrallocMemory *memory, int32_t idx);
    375     int32_t selectScene(QCameraChannel *pChannel,
    376             mm_camera_super_buf_t *recvd_frame);
    377 
    378     int32_t addChannel(qcamera_ch_type_enum_t ch_type);
    379     int32_t startChannel(qcamera_ch_type_enum_t ch_type);
    380     int32_t stopChannel(qcamera_ch_type_enum_t ch_type);
    381     int32_t delChannel(qcamera_ch_type_enum_t ch_type, bool destroy = true);
    382     int32_t addPreviewChannel();
    383     int32_t addSnapshotChannel();
    384     int32_t addVideoChannel();
    385     int32_t addZSLChannel();
    386     int32_t addCaptureChannel();
    387     int32_t addRawChannel();
    388     int32_t addMetaDataChannel();
    389     QCameraReprocessChannel *addReprocChannel(QCameraChannel *pInputChannel);
    390     QCameraReprocessChannel *addOfflineReprocChannel(
    391                                                 cam_pp_offline_src_config_t &img_config,
    392                                                 cam_pp_feature_config_t &pp_feature,
    393                                                 stream_cb_routine stream_cb,
    394                                                 void *userdata);
    395     int32_t addStreamToChannel(QCameraChannel *pChannel,
    396                                cam_stream_type_t streamType,
    397                                stream_cb_routine streamCB,
    398                                void *userData);
    399     int32_t preparePreview();
    400     void unpreparePreview();
    401     int32_t prepareRawStream(QCameraChannel *pChannel);
    402     QCameraChannel *getChannelByHandle(uint32_t channelHandle);
    403     mm_camera_buf_def_t *getSnapshotFrame(mm_camera_super_buf_t *recvd_frame);
    404     int32_t processFaceDetectionResult(cam_face_detection_data_t *fd_data);
    405     int32_t processHistogramStats(cam_hist_stats_t &stats_data);
    406     int32_t setHistogram(bool histogram_en);
    407     int32_t setFaceDetection(bool enabled);
    408     int32_t prepareHardwareForSnapshot(int32_t afNeeded);
    409     bool needProcessPreviewFrame();
    410     bool isNoDisplayMode() {return mParameters.isNoDisplayMode();};
    411     bool isZSLMode() {return mParameters.isZSLMode();};
    412     bool isRdiMode() {return mParameters.isRdiMode();};
    413     uint8_t numOfSnapshotsExpected() {
    414         return mParameters.isUbiRefocus() ? 1 : mParameters.getNumOfSnapshots();};
    415     bool isSecureMode() {return mParameters.isSecureMode();};
    416     bool isLongshotEnabled() { return mLongshotEnabled; };
    417     bool isHFRMode() {return mParameters.isHfrMode();};
    418     bool isLiveSnapshot() {return m_stateMachine.isRecording();};
    419     void setRetroPicture(bool enable) { bRetroPicture = enable; };
    420     bool isRetroPicture() {return bRetroPicture; };
    421     bool isHDRMode() {return mParameters.isHDREnabled();};
    422     uint8_t getBufNumRequired(cam_stream_type_t stream_type);
    423     bool needFDMetadata(qcamera_ch_type_enum_t channel_type);
    424     int32_t declareSnapshotStreams();
    425 
    426     bool removeSizeFromList(cam_dimension_t* size_list,
    427                             uint8_t length,
    428                             cam_dimension_t size);
    429     int32_t configureAdvancedCapture();
    430     int32_t configureAFBracketing(bool enable = true);
    431     int32_t configureFlashBracketing(bool enable = true);
    432     int32_t configureHDRBracketing();
    433     int32_t startAdvancedCapture(QCameraPicChannel *pChannel);
    434     int32_t configureOptiZoom();
    435     int32_t configureAEBracketing();
    436     inline void setOutputImageCount(uint32_t aCount) {mOutputCount = aCount;}
    437     inline uint32_t getOutputImageCount() {return mOutputCount;}
    438     bool processUFDumps(qcamera_jpeg_evt_payload_t *evt);
    439 
    440     static void copyList(cam_dimension_t* src_list,
    441                    cam_dimension_t* dst_list, uint8_t len);
    442     static void camEvtHandle(uint32_t camera_handle,
    443                           mm_camera_event_t *evt,
    444                           void *user_data);
    445     static void jpegEvtHandle(jpeg_job_status_t status,
    446                               uint32_t client_hdl,
    447                               uint32_t jobId,
    448                               mm_jpeg_output_t *p_buf,
    449                               void *userdata);
    450 
    451     static void *evtNotifyRoutine(void *data);
    452 
    453     // functions for different data notify cb
    454     static void zsl_channel_cb(mm_camera_super_buf_t *recvd_frame, void *userdata);
    455     static void capture_channel_cb_routine(mm_camera_super_buf_t *recvd_frame,
    456                                            void *userdata);
    457     static void postproc_channel_cb_routine(mm_camera_super_buf_t *recvd_frame,
    458                                             void *userdata);
    459     static void rdi_mode_stream_cb_routine(mm_camera_super_buf_t *frame,
    460                                               QCameraStream *stream,
    461                                               void *userdata);
    462     static void nodisplay_preview_stream_cb_routine(mm_camera_super_buf_t *frame,
    463                                                     QCameraStream *stream,
    464                                                     void *userdata);
    465     static void preview_stream_cb_routine(mm_camera_super_buf_t *frame,
    466                                           QCameraStream *stream,
    467                                           void *userdata);
    468     static void postview_stream_cb_routine(mm_camera_super_buf_t *frame,
    469                                            QCameraStream *stream,
    470                                            void *userdata);
    471     static void video_stream_cb_routine(mm_camera_super_buf_t *frame,
    472                                         QCameraStream *stream,
    473                                         void *userdata);
    474     static void snapshot_stream_cb_routine(mm_camera_super_buf_t *frame,
    475                                            QCameraStream *stream,
    476                                            void *userdata);
    477     static void raw_stream_cb_routine(mm_camera_super_buf_t *frame,
    478                                       QCameraStream *stream,
    479                                       void *userdata);
    480     static void preview_raw_stream_cb_routine(mm_camera_super_buf_t * super_frame,
    481                                               QCameraStream * stream,
    482                                               void * userdata);
    483     static void snapshot_raw_stream_cb_routine(mm_camera_super_buf_t * super_frame,
    484                                                QCameraStream * stream,
    485                                                void * userdata);
    486     static void metadata_stream_cb_routine(mm_camera_super_buf_t *frame,
    487                                            QCameraStream *stream,
    488                                            void *userdata);
    489     static void reprocess_stream_cb_routine(mm_camera_super_buf_t *frame,
    490                                             QCameraStream *stream,
    491                                             void *userdata);
    492 
    493     static void releaseCameraMemory(void *data,
    494                                     void *cookie,
    495                                     int32_t cbStatus);
    496     static void returnStreamBuffer(void *data,
    497                                    void *cookie,
    498                                    int32_t cbStatus);
    499     static int32_t getEffectValue(const char *effect);
    500     static void getLogLevel();
    501 private:
    502     camera_device_t   mCameraDevice;
    503     uint8_t           mCameraId;
    504     mm_camera_vtbl_t *mCameraHandle;
    505     bool mCameraOpened;
    506 
    507     preview_stream_ops_t *mPreviewWindow;
    508     QCameraParameters mParameters;
    509     int32_t               mMsgEnabled;
    510     int                   mStoreMetaDataInFrame;
    511 
    512     camera_notify_callback         mNotifyCb;
    513     camera_data_callback           mDataCb;
    514     camera_data_timestamp_callback mDataCbTimestamp;
    515     camera_request_memory          mGetMemory;
    516     void                          *mCallbackCookie;
    517 
    518     QCameraStateMachine m_stateMachine;   // state machine
    519     QCameraPostProcessor m_postprocessor; // post processor
    520     QCameraThermalAdapter &m_thermalAdapter;
    521     QCameraCbNotifier m_cbNotifier;
    522     pthread_mutex_t m_lock;
    523     pthread_cond_t m_cond;
    524     api_result_list *m_apiResultList;
    525     QCameraMemoryPool m_memoryPool;
    526 
    527     pthread_mutex_t m_evtLock;
    528     pthread_cond_t m_evtCond;
    529     qcamera_api_result_t m_evtResult;
    530 
    531     pthread_mutex_t m_parm_lock;
    532 
    533     QCameraChannel *m_channels[QCAMERA_CH_TYPE_MAX]; // array holding channel ptr
    534 
    535     bool m_bShutterSoundPlayed;         // if shutter sound had been played
    536     bool m_bPreviewStarted;             //flag indicates first preview frame callback is received
    537     bool m_bRecordStarted;             //flag indicates Recording is started for first time
    538 
    539 
    540     // if auto focus is running, in other words, when auto_focus is called from service,
    541     // and beforeany focus callback/cancel_focus happens. This flag is not an indication
    542     // of whether lens is moving or not.
    543     bool m_bAutoFocusRunning;
    544     // Signifies if ZSL Retro Snapshots are enabled
    545     bool bRetroPicture;
    546     // Signifies AEC locked during zsl snapshots
    547     bool m_bLedAfAecLock;
    548     cam_autofocus_state_t m_currentFocusState;
    549 
    550     power_module_t *m_pPowerModule;   // power module
    551 
    552     int mDumpFrmCnt;  // frame dump count
    553     int mDumpSkipCnt; // frame skip count
    554     mm_jpeg_exif_params_t mExifParams;
    555     qcamera_thermal_level_enum_t mThermalLevel;
    556     bool m_HDRSceneEnabled;
    557     bool mLongshotEnabled;
    558 
    559     int32_t m_max_pic_width;
    560     int32_t m_max_pic_height;
    561     pthread_t mLiveSnapshotThread;
    562     uint8_t mFlashNeeded;
    563     int mCaptureRotation;
    564     int32_t mFlash;
    565     int32_t mRedEye;
    566     int32_t mFlashPresence;
    567     bool mIs3ALocked;
    568     int32_t mZoomLevel;
    569 
    570     enum DefferedWorkCmd {
    571         CMD_DEFF_ALLOCATE_BUFF,
    572         CMD_DEFF_PPROC_START,
    573         CMD_DEFF_MAX
    574     };
    575 
    576     typedef struct {
    577         QCameraChannel *ch;
    578         cam_stream_type_t type;
    579     } DefferAllocBuffArgs;
    580 
    581     typedef union {
    582         DefferAllocBuffArgs allocArgs;
    583         QCameraChannel *pprocArgs;
    584     } DefferWorkArgs;
    585 
    586     bool mDeffOngoingJobs[MAX_ONGOING_JOBS];
    587 
    588     struct DeffWork
    589     {
    590         DeffWork(DefferedWorkCmd cmd,
    591                  uint32_t id,
    592                  DefferWorkArgs args)
    593             : cmd(cmd),
    594               id(id),
    595               args(args){};
    596 
    597         DefferedWorkCmd cmd;
    598         uint32_t id;
    599         DefferWorkArgs args;
    600     };
    601 
    602     QCameraCmdThread      mDefferedWorkThread;
    603     QCameraQueue          mCmdQueue;
    604 
    605     Mutex                 mDeffLock;
    606     Condition             mDeffCond;
    607 
    608     int32_t queueDefferedWork(DefferedWorkCmd cmd,
    609                               DefferWorkArgs args);
    610     int32_t waitDefferedWork(int32_t &job_id);
    611     static void *defferedWorkRoutine(void *obj);
    612 
    613     int32_t mSnapshotJob;
    614     int32_t mPostviewJob;
    615     int32_t mMetadataJob;
    616     int32_t mReprocJob;
    617     int32_t mRawdataJob;
    618     int32_t mOutputCount;
    619 };
    620 
    621 }; // namespace qcamera
    622 
    623 #endif /* __QCAMERA2HARDWAREINTERFACE_H__ */
    624