Home | History | Annotate | Download | only in libcamera2
      1 /*
      2 **
      3 ** Copyright 2008, The Android Open Source Project
      4 ** Copyright 2012, Samsung Electronics Co. LTD
      5 **
      6 ** Licensed under the Apache License, Version 2.0 (the "License");
      7 ** you may not use this file except in compliance with the License.
      8 ** You may obtain a copy of the License at
      9 **
     10 **     http://www.apache.org/licenses/LICENSE-2.0
     11 **
     12 ** Unless required by applicable law or agreed to in writing, software
     13 ** distributed under the License is distributed on an "AS IS" BASIS,
     14 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     15 ** See the License for the specific language governing permissions and
     16 ** limitations under the License.
     17 */
     18 
     19 /*!
     20  * \file      ExynosCameraHWInterface2.h
     21  * \brief     header file for Android Camera API 2.0 HAL
     22  * \author    Sungjoong Kang(sj3.kang (at) samsung.com)
     23  * \date      2012/07/10
     24  *
     25  * <b>Revision History: </b>
     26  * - 2012/05/31 : Sungjoong Kang(sj3.kang (at) samsung.com) \n
     27  *   Initial Release
     28   *
     29  * - 2012/07/10 : Sungjoong Kang(sj3.kang (at) samsung.com) \n
     30  *   2nd Release
     31  *
     32  */
     33 
     34 #ifndef EXYNOS_CAMERA_HW_INTERFACE_2_H
     35 #define EXYNOS_CAMERA_HW_INTERFACE_2_H
     36 
     37 #include <hardware/camera2.h>
     38 #include <camera/Camera.h>
     39 #include <camera/CameraParameters.h>
     40 #include <utils/List.h>
     41 #include "SignalDrivenThread.h"
     42 #include "MetadataConverter.h"
     43 #include "exynos_v4l2.h"
     44 #include "ExynosRect.h"
     45 #include "ExynosBuffer.h"
     46 #include "videodev2_exynos_camera.h"
     47 #include "gralloc_priv.h"
     48 #include "ExynosJpegEncoderForCamera.h"
     49 #include <fcntl.h>
     50 #include "fimc-is-metadata.h"
     51 #include "ion.h"
     52 #include "ExynosExif.h"
     53 #include "csc.h"
     54 #include "ExynosCamera2.h"
     55 #include "cutils/properties.h"
     56 
     57 namespace android {
     58 
     59 //#define EXYNOS_CAMERA_LOG
     60 #define ENABLE_FRAME_SYNC
     61 #define NODE_PREFIX     "/dev/video"
     62 
     63 #define NUM_MAX_STREAM_THREAD       (5)
     64 #define NUM_MAX_REQUEST_MGR_ENTRY   (5)
     65 #define NUM_MAX_CAMERA_BUFFERS      (16)
     66 #define NUM_BAYER_BUFFERS           (8)
     67 #define NUM_SCC_BUFFERS             (8)
     68 #define NUM_SCP_BUFFERS             (8)
     69 #define NUM_MIN_SENSOR_QBUF         (3)
     70 #define NUM_MAX_SUBSTREAM           (4)
     71 
     72 #define PICTURE_GSC_NODE_NUM (2)
     73 #define VIDEO_GSC_NODE_NUM (1)
     74 
     75 #define STREAM_TYPE_DIRECT   (0)
     76 #define STREAM_TYPE_INDIRECT (1)
     77 
     78 #define SIGNAL_MAIN_REQ_Q_NOT_EMPTY             (SIGNAL_THREAD_COMMON_LAST<<1)
     79 
     80 #define SIGNAL_MAIN_STREAM_OUTPUT_DONE          (SIGNAL_THREAD_COMMON_LAST<<3)
     81 #define SIGNAL_SENSOR_START_REQ_PROCESSING      (SIGNAL_THREAD_COMMON_LAST<<4)
     82 
     83 #define SIGNAL_THREAD_RELEASE                   (SIGNAL_THREAD_COMMON_LAST<<8)
     84 
     85 #define SIGNAL_STREAM_REPROCESSING_START        (SIGNAL_THREAD_COMMON_LAST<<14)
     86 #define SIGNAL_STREAM_DATA_COMING               (SIGNAL_THREAD_COMMON_LAST<<15)
     87 
     88 #define NO_TRANSITION                   (0)
     89 #define HAL_AFSTATE_INACTIVE            (1)
     90 #define HAL_AFSTATE_NEEDS_COMMAND       (2)
     91 #define HAL_AFSTATE_STARTED             (3)
     92 #define HAL_AFSTATE_SCANNING            (4)
     93 #define HAL_AFSTATE_LOCKED              (5)
     94 #define HAL_AFSTATE_FAILED              (6)
     95 #define HAL_AFSTATE_NEEDS_DETERMINATION (7)
     96 #define HAL_AFSTATE_PASSIVE_FOCUSED     (8)
     97 
     98 #define STREAM_ID_PREVIEW           (0)
     99 #define STREAM_MASK_PREVIEW         (1<<STREAM_ID_PREVIEW)
    100 #define STREAM_ID_RECORD            (1)
    101 #define STREAM_MASK_RECORD          (1<<STREAM_ID_RECORD)
    102 #define STREAM_ID_PRVCB             (2)
    103 #define STREAM_MASK_PRVCB           (1<<STREAM_ID_PRVCB)
    104 #define STREAM_ID_JPEG              (4)
    105 #define STREAM_MASK_JPEG            (1<<STREAM_ID_JPEG)
    106 #define STREAM_ID_ZSL               (5)
    107 #define STREAM_MASK_ZSL             (1<<STREAM_ID_ZSL)
    108 
    109 #define STREAM_ID_JPEG_REPROCESS    (8)
    110 #define STREAM_ID_LAST              STREAM_ID_JPEG_REPROCESS
    111 
    112 #define MASK_OUTPUT_SCP             (STREAM_MASK_PREVIEW|STREAM_MASK_RECORD|STREAM_MASK_PRVCB)
    113 #define MASK_OUTPUT_SCC             (STREAM_MASK_JPEG|STREAM_MASK_ZSL)
    114 
    115 #define SUBSTREAM_TYPE_NONE         (0)
    116 #define SUBSTREAM_TYPE_JPEG         (1)
    117 #define SUBSTREAM_TYPE_RECORD       (2)
    118 #define SUBSTREAM_TYPE_PRVCB        (3)
    119 #define FLASH_STABLE_WAIT_TIMEOUT        (10)
    120 
    121 #define SIG_WAITING_TICK            (5000)
    122 
    123 #ifdef EXYNOS_CAMERA_LOG
    124 #define CAM_LOGV(...) ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
    125 #define CAM_LOGD(...) ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__))
    126 #define CAM_LOGW(...) ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__))
    127 #define CAM_LOGE(...) ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__))
    128 #else
    129 #define CAM_LOGV(...) ((void)0)
    130 #define CAM_LOGD(...) ((void)0)
    131 #define CAM_LOGW(...) ((void)0)
    132 #define CAM_LOGE(...) ((void)0)
    133 #endif
    134 
    135 enum sensor_name {
    136     SENSOR_NAME_S5K3H2  = 1,
    137     SENSOR_NAME_S5K6A3  = 2,
    138     SENSOR_NAME_S5K4E5  = 3,
    139     SENSOR_NAME_S5K3H7  = 4,
    140     SENSOR_NAME_CUSTOM  = 5,
    141     SENSOR_NAME_END
    142 };
    143 
    144 enum is_subscenario_id {
    145 	ISS_SUB_SCENARIO_STILL,
    146 	ISS_SUB_SCENARIO_VIDEO,
    147 	ISS_SUB_SCENARIO_SCENE1,
    148 	ISS_SUB_SCENARIO_SCENE2,
    149 	ISS_SUB_SCENARIO_SCENE3,
    150 	ISS_SUB_END
    151 };
    152 
    153 int SUPPORT_THUMBNAIL_REAR_SIZE[][2] =
    154 {
    155     {160, 120},
    156     {160, 90},
    157     {144, 96}
    158 };
    159 
    160 int SUPPORT_THUMBNAIL_FRONT_SIZE[][2] =
    161 {
    162     {160, 120},
    163     {160, 160},
    164     {160, 90},
    165     {144, 96}
    166 };
    167 
    168 enum is_set_flash_command_state {
    169     IS_FLASH_STATE_NONE = 0,
    170     IS_FLASH_STATE_ON = 1,
    171     IS_FLASH_STATE_ON_WAIT,
    172     IS_FLASH_STATE_ON_DONE,
    173     IS_FLASH_STATE_AUTO_AE_AWB_LOCK,
    174     IS_FLASH_STATE_AE_AWB_LOCK_WAIT,
    175     IS_FLASH_STATE_AUTO_WAIT,
    176     IS_FLASH_STATE_AUTO_DONE,
    177     IS_FLASH_STATE_AUTO_OFF,
    178     IS_FLASH_STATE_CAPTURE,
    179     IS_FLASH_STATE_CAPTURE_WAIT,
    180     IS_FLASH_STATE_CAPTURE_JPEG,
    181     IS_FLASH_STATE_CAPTURE_END,
    182     IS_FALSH_STATE_MAX
    183 };
    184 
    185 enum is_set_command_state {
    186     IS_COMMAND_NONE = 0,
    187     IS_COMMAND_EXECUTION,
    188     IS_COMMAND_CLEAR,
    189     IS_COMMAND_MAX
    190 };
    191 
    192 typedef struct node_info {
    193     int fd;
    194     int width;
    195     int height;
    196     int format;
    197     int planes;
    198     int buffers;
    199     enum v4l2_memory memory;
    200     enum v4l2_buf_type type;
    201     ExynosBuffer buffer[NUM_MAX_CAMERA_BUFFERS];
    202     int status;
    203 } node_info_t;
    204 
    205 
    206 typedef struct camera_hw_info {
    207     int sensor_id;
    208 
    209     node_info_t sensor;
    210     node_info_t isp;
    211     node_info_t capture;
    212     node_info_t scp;
    213 
    214     /*shot*/  // temp
    215     struct camera2_shot_ext dummy_shot;
    216 
    217 } camera_hw_info_t;
    218 
    219 typedef enum request_entry_status {
    220     EMPTY,
    221     REGISTERED,
    222     REQUESTED,
    223     CAPTURED,
    224     METADONE,
    225     COMPLETED
    226 } request_entry_status_t;
    227 
    228 typedef struct request_manager_entry {
    229     request_entry_status_t      status;
    230     camera_metadata_t           *original_request;
    231     struct camera2_shot_ext     internal_shot;
    232     int                         output_stream_count;
    233 } request_manager_entry_t;
    234 
    235 // structure related to a specific function of camera
    236 typedef struct af_control_info {
    237     int    m_afTriggerTimeOut;
    238 } ctl_af_info_t;
    239 
    240 typedef struct flash_control_info {
    241     // UI flash mode indicator
    242     enum aa_aemode    i_flashMode;
    243     // AF flash
    244     bool        m_afFlashDoneFlg;
    245     // Capture flash
    246     bool        m_flashEnableFlg;
    247     int         m_flashFrameCount;
    248     int         m_flashCnt;
    249     int        m_flashTimeOut;
    250     // Flash decision
    251     // At flash auto mode only : 1 -> flash is needed, 0 -> normal case
    252     bool        m_flashDecisionResult;
    253     // torch indicator. this will be replaced by flashMode meta
    254     bool        m_flashTorchMode;
    255     // for precapture metering
    256     int        m_precaptureState;
    257     int        m_precaptureTriggerId;
    258 } ctl_flash_info_t;
    259 
    260 typedef struct ae_control_info {
    261     // pre-capture notification state
    262     enum ae_state    aeStateNoti;
    263 } ctl_ae_info_t;
    264 
    265 typedef struct scene_control_info {
    266     // pre-capture notification state
    267     enum aa_scene_mode    prevSceneMode;
    268 } ctl_scene_info_t;
    269 
    270 typedef struct request_control_info {
    271     ctl_flash_info_t flash;
    272     ctl_ae_info_t ae;
    273     ctl_af_info_t af;
    274     ctl_scene_info_t scene;
    275 } ctl_request_info_t;
    276 
    277 class RequestManager {
    278 public:
    279     RequestManager(SignalDrivenThread* main_thread);
    280     ~RequestManager();
    281     void    ResetEntry();
    282     int     GetNumEntries();
    283     bool    IsRequestQueueFull();
    284 
    285     void    RegisterRequest(camera_metadata_t *new_request, int * afMode, uint32_t * afRegion);
    286     void    DeregisterRequest(camera_metadata_t **deregistered_request);
    287     bool    PrepareFrame(size_t *num_entries, size_t *frame_size,
    288                 camera_metadata_t **prepared_frame, int afState);
    289     int     MarkProcessingRequest(ExynosBuffer * buf);
    290     void    NotifyStreamOutput(int frameCnt);
    291     void    ApplyDynamicMetadata(struct camera2_shot_ext *shot_ext);
    292     void    CheckCompleted(int index);
    293     void    UpdateIspParameters(struct camera2_shot_ext *shot_ext, int frameCnt, ctl_request_info_t *ctl_info);
    294     void    RegisterTimestamp(int frameCnt, nsecs_t *frameTime);
    295     nsecs_t  GetTimestampByFrameCnt(int frameCnt);
    296     nsecs_t  GetTimestamp(int index);
    297     uint8_t  GetOutputStreamByFrameCnt(int frameCnt);
    298     uint8_t  GetOutputStream(int index);
    299     camera2_shot_ext *  GetInternalShotExtByFrameCnt(int frameCnt);
    300     camera2_shot_ext *  GetInternalShotExt(int index);
    301     int     FindFrameCnt(struct camera2_shot_ext * shot_ext);
    302     bool    IsVdisEnable(void);
    303     int     FindEntryIndexByFrameCnt(int frameCnt);
    304     void    Dump(void);
    305     int     GetNextIndex(int index);
    306     int     GetPrevIndex(int index);
    307     void    SetDefaultParameters(int cropX);
    308     void    SetInitialSkip(int count);
    309     int     GetSkipCnt();
    310     int     GetCompletedIndex();
    311     void    pushSensorQ(int index);
    312     int     popSensorQ();
    313     void    releaseSensorQ();
    314 
    315     bool    m_vdisEnable;
    316 
    317 private:
    318 
    319     MetadataConverter               *m_metadataConverter;
    320     SignalDrivenThread              *m_mainThread;
    321     Mutex                           m_numOfEntriesLock;
    322     int                             m_numOfEntries;
    323     int                             m_entryInsertionIndex;
    324     int                             m_entryProcessingIndex;
    325     int                             m_entryFrameOutputIndex;
    326     request_manager_entry_t         entries[NUM_MAX_REQUEST_MGR_ENTRY];
    327     int                             m_completedIndex;
    328 
    329     Mutex                           m_requestMutex;
    330 
    331     //TODO : alloc dynamically
    332     char                            m_tempFrameMetadataBuf[2000];
    333     camera_metadata_t               *m_tempFrameMetadata;
    334 
    335     int                             m_sensorPipelineSkipCnt;
    336     int                             m_cropX;
    337     int                             m_lastCompletedFrameCnt;
    338     int                             m_lastAeMode;
    339     int                             m_lastAaMode;
    340     int                             m_lastAwbMode;
    341     int                             m_lastAeComp;
    342     bool                            m_vdisBubbleEn;
    343     nsecs_t                         m_lastTimeStamp;
    344     List<int>                   m_sensorQ;
    345 };
    346 
    347 
    348 typedef struct bayer_buf_entry {
    349     int     status;
    350     int     reqFrameCnt;
    351     nsecs_t timeStamp;
    352 } bayer_buf_entry_t;
    353 
    354 
    355 class BayerBufManager {
    356 public:
    357     BayerBufManager();
    358     ~BayerBufManager();
    359     int                 GetIndexForSensorEnqueue();
    360     int                 MarkSensorEnqueue(int index);
    361     int                 MarkSensorDequeue(int index, int reqFrameCnt, nsecs_t *timeStamp);
    362     int                 GetIndexForIspEnqueue(int *reqFrameCnt);
    363     int                 GetIndexForIspDequeue(int *reqFrameCnt);
    364     int                 MarkIspEnqueue(int index);
    365     int                 MarkIspDequeue(int index);
    366     int                 GetNumOnSensor();
    367     int                 GetNumOnHalFilled();
    368     int                 GetNumOnIsp();
    369 
    370 private:
    371     int                 GetNextIndex(int index);
    372 
    373     int                 sensorEnqueueHead;
    374     int                 sensorDequeueHead;
    375     int                 ispEnqueueHead;
    376     int                 ispDequeueHead;
    377     int                 numOnSensor;
    378     int                 numOnIsp;
    379     int                 numOnHalFilled;
    380     int                 numOnHalEmpty;
    381 
    382     bayer_buf_entry_t   entries[NUM_BAYER_BUFFERS];
    383 };
    384 
    385 
    386 #define NOT_AVAILABLE           (0)
    387 #define REQUIRES_DQ_FROM_SVC    (1)
    388 #define ON_DRIVER               (2)
    389 #define ON_HAL                  (3)
    390 #define ON_SERVICE              (4)
    391 
    392 #define BAYER_NOT_AVAILABLE     (0)
    393 #define BAYER_ON_SENSOR         (1)
    394 #define BAYER_ON_HAL_FILLED     (2)
    395 #define BAYER_ON_ISP            (3)
    396 #define BAYER_ON_SERVICE        (4)
    397 #define BAYER_ON_HAL_EMPTY      (5)
    398 
    399 typedef struct stream_parameters {
    400             uint32_t                width;
    401             uint32_t                height;
    402             int                     format;
    403     const   camera2_stream_ops_t*   streamOps;
    404             uint32_t                usage;
    405             int                     numHwBuffers;
    406             int                     numSvcBuffers;
    407             int                     numOwnSvcBuffers;
    408             int                     planes;
    409             int                     metaPlanes;
    410             int                     numSvcBufsInHal;
    411             buffer_handle_t         svcBufHandle[NUM_MAX_CAMERA_BUFFERS];
    412             ExynosBuffer            svcBuffers[NUM_MAX_CAMERA_BUFFERS];
    413             ExynosBuffer            metaBuffers[NUM_MAX_CAMERA_BUFFERS];
    414             int                     svcBufStatus[NUM_MAX_CAMERA_BUFFERS];
    415             int                     bufIndex;
    416             node_info_t             *node;
    417             int                     minUndequedBuffer;
    418             bool                    needsIonMap;
    419 } stream_parameters_t;
    420 
    421 typedef struct substream_parameters {
    422             int                     type;
    423             uint32_t                width;
    424             uint32_t                height;
    425             int                     format;
    426     const   camera2_stream_ops_t*   streamOps;
    427             uint32_t                usage;
    428             int                     numSvcBuffers;
    429             int                     numOwnSvcBuffers;
    430             int                     internalFormat;
    431             int                     internalPlanes;
    432             int                     svcPlanes;
    433             buffer_handle_t         svcBufHandle[NUM_MAX_CAMERA_BUFFERS];
    434             ExynosBuffer            svcBuffers[NUM_MAX_CAMERA_BUFFERS];
    435             int                     svcBufStatus[NUM_MAX_CAMERA_BUFFERS];
    436             int                     svcBufIndex;
    437             int                     numSvcBufsInHal;
    438             bool                    needBufferInit;
    439             int                     minUndequedBuffer;
    440 } substream_parameters_t;
    441 
    442 typedef struct substream_entry {
    443     int                     priority;
    444     int                     streamId;
    445 } substream_entry_t;
    446 
    447 class ExynosCameraHWInterface2 : public virtual RefBase {
    448 public:
    449     ExynosCameraHWInterface2(int cameraId, camera2_device_t *dev, ExynosCamera2 * camera, int *openInvalid);
    450     virtual             ~ExynosCameraHWInterface2();
    451 
    452     virtual void        release();
    453 
    454     inline  int         getCameraId() const;
    455 
    456     virtual int         setRequestQueueSrcOps(const camera2_request_queue_src_ops_t *request_src_ops);
    457     virtual int         notifyRequestQueueNotEmpty();
    458     virtual int         setFrameQueueDstOps(const camera2_frame_queue_dst_ops_t *frame_dst_ops);
    459     virtual int         getInProgressCount();
    460     virtual int         flushCapturesInProgress();
    461     virtual int         constructDefaultRequest(int request_template, camera_metadata_t **request);
    462     virtual int         allocateStream(uint32_t width, uint32_t height,
    463                                     int format, const camera2_stream_ops_t *stream_ops,
    464                                     uint32_t *stream_id, uint32_t *format_actual, uint32_t *usage, uint32_t *max_buffers);
    465     virtual int         registerStreamBuffers(uint32_t stream_id, int num_buffers, buffer_handle_t *buffers);
    466     virtual int         releaseStream(uint32_t stream_id);
    467     virtual int         allocateReprocessStream(uint32_t width, uint32_t height,
    468                                     uint32_t format, const camera2_stream_in_ops_t *reprocess_stream_ops,
    469                                     uint32_t *stream_id, uint32_t *consumer_usage, uint32_t *max_buffers);
    470     virtual int         allocateReprocessStreamFromStream(uint32_t output_stream_id,
    471                                 const camera2_stream_in_ops_t *reprocess_stream_ops, uint32_t *stream_id);
    472     virtual int         releaseReprocessStream(uint32_t stream_id);
    473     virtual int         triggerAction(uint32_t trigger_id, int ext1, int ext2);
    474     virtual int         setNotifyCallback(camera2_notify_callback notify_cb, void *user);
    475     virtual int         getMetadataVendorTagOps(vendor_tag_query_ops_t **ops);
    476     virtual int         dump(int fd);
    477 private:
    478 class MainThread : public SignalDrivenThread {
    479         ExynosCameraHWInterface2 *mHardware;
    480     public:
    481         MainThread(ExynosCameraHWInterface2 *hw):
    482             SignalDrivenThread(),
    483             mHardware(hw) { }
    484         ~MainThread();
    485         void threadFunctionInternal()
    486 	    {
    487             mHardware->m_mainThreadFunc(this);
    488             return;
    489         }
    490         void        release(void);
    491         bool        m_releasing;
    492     };
    493 
    494     class SensorThread : public SignalDrivenThread {
    495         ExynosCameraHWInterface2 *mHardware;
    496     public:
    497         SensorThread(ExynosCameraHWInterface2 *hw):
    498             SignalDrivenThread(),
    499             mHardware(hw) { }
    500         ~SensorThread();
    501         void threadFunctionInternal() {
    502             mHardware->m_sensorThreadFunc(this);
    503             return;
    504         }
    505         void            release(void);
    506     //private:
    507         bool            m_releasing;
    508     };
    509 
    510     class StreamThread : public SignalDrivenThread {
    511         ExynosCameraHWInterface2 *mHardware;
    512     public:
    513         StreamThread(ExynosCameraHWInterface2 *hw, uint8_t new_index):
    514             SignalDrivenThread(),
    515             mHardware(hw),
    516             m_index(new_index) { }
    517         ~StreamThread();
    518         void threadFunctionInternal() {
    519             mHardware->m_streamThreadFunc(this);
    520             return;
    521         }
    522         void        setParameter(stream_parameters_t * new_parameters);
    523         status_t    attachSubStream(int stream_id, int priority);
    524         status_t    detachSubStream(int stream_id);
    525         void        release(void);
    526         int         findBufferIndex(void * bufAddr);
    527         int         findBufferIndex(buffer_handle_t * bufHandle);
    528 
    529         uint8_t                         m_index;
    530         bool                            m_activated;
    531     //private:
    532         stream_parameters_t             m_parameters;
    533         stream_parameters_t             *m_tempParameters;
    534         substream_entry_t               m_attachedSubStreams[NUM_MAX_SUBSTREAM];
    535         bool                            m_isBufferInit;
    536         bool                            m_releasing;
    537         int                             streamType;
    538         int                             m_numRegisteredStream;
    539      };
    540 
    541     sp<MainThread>      m_mainThread;
    542     sp<SensorThread>    m_sensorThread;
    543     sp<StreamThread>    m_streamThreads[NUM_MAX_STREAM_THREAD];
    544     substream_parameters_t  m_subStreams[STREAM_ID_LAST+1];
    545 
    546 
    547 
    548     RequestManager      *m_requestManager;
    549     BayerBufManager     *m_BayerManager;
    550     ExynosCamera2       *m_camera2;
    551 
    552     void                m_mainThreadFunc(SignalDrivenThread * self);
    553     void                m_sensorThreadFunc(SignalDrivenThread * self);
    554     void                m_streamThreadFunc(SignalDrivenThread * self);
    555     void                m_streamThreadInitialize(SignalDrivenThread * self);
    556 
    557     void                m_streamFunc_direct(SignalDrivenThread *self);
    558     void                m_streamFunc_indirect(SignalDrivenThread *self);
    559 
    560     void                m_streamBufferInit(SignalDrivenThread *self);
    561 
    562     int                 m_runSubStreamFunc(StreamThread *selfThread, ExynosBuffer *srcImageBuf,
    563                             int stream_id, nsecs_t frameTimeStamp);
    564     int                 m_jpegCreator(StreamThread *selfThread, ExynosBuffer *srcImageBuf, nsecs_t frameTimeStamp);
    565     int                 m_recordCreator(StreamThread *selfThread, ExynosBuffer *srcImageBuf, nsecs_t frameTimeStamp);
    566     int                 m_prvcbCreator(StreamThread *selfThread, ExynosBuffer *srcImageBuf, nsecs_t frameTimeStamp);
    567     void                m_getAlignedYUVSize(int colorFormat, int w, int h,
    568                                                 ExynosBuffer *buf);
    569     bool                m_getRatioSize(int  src_w,  int   src_h,
    570                                              int  dst_w,  int   dst_h,
    571                                              int *crop_x, int *crop_y,
    572                                              int *crop_w, int *crop_h,
    573                                              int zoom);
    574 	int				createIonClient(ion_client ionClient);
    575 	int					deleteIonClient(ion_client ionClient);
    576 
    577     int				allocCameraMemory(ion_client ionClient, ExynosBuffer *buf, int iMemoryNum);
    578     int             allocCameraMemory(ion_client ionClient, ExynosBuffer *buf, int iMemoryNum, int cacheFlag);
    579 	void				freeCameraMemory(ExynosBuffer *buf, int iMemoryNum);
    580 	void				initCameraMemory(ExynosBuffer *buf, int iMemoryNum);
    581 
    582     void            DumpInfoWithShot(struct camera2_shot_ext * shot_ext);
    583     bool            m_checkThumbnailSize(int w, int h);
    584     bool            yuv2Jpeg(ExynosBuffer *yuvBuf,
    585                             ExynosBuffer *jpegBuf,
    586                             ExynosRect *rect);
    587     int             InitializeISPChain();
    588     void            StartISP();
    589     void            StartSCCThread(bool threadExists);
    590     int             GetAfState();
    591     void            SetAfMode(enum aa_afmode afMode);
    592     void            SetAfRegion(uint32_t * afRegion);
    593     void            OnAfTrigger(int id);
    594     void            OnAfTriggerAutoMacro(int id);
    595     void            OnAfTriggerCAFPicture(int id);
    596     void            OnAfTriggerCAFVideo(int id);
    597     void            OnPrecaptureMeteringTriggerStart(int id);
    598     void            OnAfCancel(int id);
    599     void            OnAfCancelAutoMacro(int id);
    600     void            OnAfCancelCAFPicture(int id);
    601     void            OnAfCancelCAFVideo(int id);
    602     void            OnPrecaptureMeteringNotificationISP();
    603     void            OnPrecaptureMeteringNotificationSensor();
    604     void            OnAfNotification(enum aa_afstate noti);
    605     void            OnAfNotificationAutoMacro(enum aa_afstate noti);
    606     void            OnAfNotificationCAFPicture(enum aa_afstate noti);
    607     void            OnAfNotificationCAFVideo(enum aa_afstate noti);
    608     void            SetAfStateForService(int newState);
    609     int             GetAfStateForService();
    610     exif_attribute_t    mExifInfo;
    611     void            m_setExifFixedAttribute(void);
    612     void            m_setExifChangedAttribute(exif_attribute_t *exifInfo, ExynosRect *rect,
    613                          camera2_shot_ext *currentEntry);
    614     void            m_preCaptureSetter(struct camera2_shot_ext * shot_ext);
    615     void            m_preCaptureListenerSensor(struct camera2_shot_ext * shot_ext);
    616     void            m_preCaptureListenerISP(struct camera2_shot_ext * shot_ext);
    617     void            m_preCaptureAeState(struct camera2_shot_ext * shot_ext);
    618     void            m_updateAfRegion(struct camera2_shot_ext * shot_ext);
    619     void            m_afTrigger(struct camera2_shot_ext * shot_ext, int mode);
    620     void               *m_exynosPictureCSC;
    621     void               *m_exynosVideoCSC;
    622 
    623 
    624     camera2_request_queue_src_ops_t     *m_requestQueueOps;
    625     camera2_frame_queue_dst_ops_t       *m_frameQueueOps;
    626     camera2_notify_callback             m_notifyCb;
    627     void                                *m_callbackCookie;
    628 
    629     int                                 m_numOfRemainingReqInSvc;
    630     bool                                m_isRequestQueuePending;
    631     bool                                m_isRequestQueueNull;
    632     camera2_device_t                    *m_halDevice;
    633     static gralloc_module_t const*      m_grallocHal;
    634 
    635 
    636     camera_hw_info_t                     m_camera_info;
    637 
    638 	ion_client m_ionCameraClient;
    639 
    640     bool                                m_isIspStarted;
    641 
    642     int                                 m_need_streamoff;
    643     ExynosBuffer                        m_sccLocalBuffer[NUM_MAX_CAMERA_BUFFERS];
    644     bool                                m_sccLocalBufferValid;
    645 
    646     int                                 indexToQueue[3+1];
    647 
    648     bool                                m_scp_flushing;
    649     bool                                m_closing;
    650     ExynosBuffer                        m_resizeBuf;
    651 #ifndef ENABLE_FRAME_SYNC
    652     int                                 m_currentOutputStreams;
    653 #endif
    654     int                                 m_currentReprocessOutStreams;
    655     ExynosBuffer                        m_previewCbBuf;
    656     int             				    m_cameraId;
    657     bool                                m_scp_closing;
    658     bool                                m_scp_closed;
    659     bool                                m_wideAspect;
    660     uint32_t                            currentAfRegion[4];
    661     float                               m_zoomRatio;
    662 
    663     int                                 m_vdisBubbleCnt;
    664     int                                 m_vdisDupFrame;
    665 
    666     mutable Mutex                       m_qbufLock;
    667     mutable Mutex                       m_jpegEncoderLock;
    668     int                                 m_jpegEncodingCount;
    669     mutable Mutex                       m_afModeTriggerLock;
    670 
    671     bool                                m_scpForceSuspended;
    672     int                                 m_afState;
    673     int                                 m_afTriggerId;
    674     enum aa_afmode                      m_afMode;
    675     enum aa_afmode                      m_afMode2;
    676     bool                                m_IsAfModeUpdateRequired;
    677     bool                                m_IsAfTriggerRequired;
    678     bool                                m_IsAfLockRequired;
    679     int                                 m_serviceAfState;
    680     bool                                m_AfHwStateFailed;
    681     int                                 m_afPendingTriggerId;
    682     int                                 m_afModeWaitingCnt;
    683     struct camera2_shot_ext             m_jpegMetadata;
    684     int                                 m_scpOutputSignalCnt;
    685     int                                 m_scpOutputImageCnt;
    686     int                                 m_nightCaptureCnt;
    687     int                                 m_nightCaptureFrameCnt;
    688     int                                 m_lastSceneMode;
    689     int                                 m_thumbNailW;
    690     int                                 m_thumbNailH;
    691     int                                 m_reprocessStreamId;
    692     const camera2_stream_in_ops_t *     m_reprocessOps;
    693     int                                 m_reprocessOutputStreamId;
    694     int                                 m_reprocessingFrameCnt;
    695     ctl_request_info_t        m_ctlInfo;
    696 };
    697 
    698 }; // namespace android
    699 
    700 #endif
    701