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 enum is_set_flash_command_state {
    154     IS_FLASH_STATE_NONE = 0,
    155     IS_FLASH_STATE_ON = 1,
    156     IS_FLASH_STATE_ON_WAIT,
    157     IS_FLASH_STATE_ON_DONE,
    158     IS_FLASH_STATE_AUTO_AE_AWB_LOCK,
    159     IS_FLASH_STATE_AE_AWB_LOCK_WAIT,
    160     IS_FLASH_STATE_AUTO_WAIT,
    161     IS_FLASH_STATE_AUTO_DONE,
    162     IS_FLASH_STATE_AUTO_OFF,
    163     IS_FLASH_STATE_CAPTURE,
    164     IS_FLASH_STATE_CAPTURE_WAIT,
    165     IS_FLASH_STATE_CAPTURE_JPEG,
    166     IS_FLASH_STATE_CAPTURE_END,
    167     IS_FALSH_STATE_MAX
    168 };
    169 
    170 enum is_set_command_state {
    171     IS_COMMAND_NONE = 0,
    172     IS_COMMAND_EXECUTION,
    173     IS_COMMAND_CLEAR,
    174     IS_COMMAND_MAX
    175 };
    176 
    177 typedef struct node_info {
    178     int fd;
    179     int width;
    180     int height;
    181     int format;
    182     int planes;
    183     int buffers;
    184     enum v4l2_memory memory;
    185     enum v4l2_buf_type type;
    186     ExynosBuffer buffer[NUM_MAX_CAMERA_BUFFERS];
    187     int status;
    188 } node_info_t;
    189 
    190 
    191 typedef struct camera_hw_info {
    192     int sensor_id;
    193 
    194     node_info_t sensor;
    195     node_info_t isp;
    196     node_info_t capture;
    197     node_info_t scp;
    198 
    199     /*shot*/  // temp
    200     struct camera2_shot_ext dummy_shot;
    201 
    202 } camera_hw_info_t;
    203 
    204 typedef enum request_entry_status {
    205     EMPTY,
    206     REGISTERED,
    207     REQUESTED,
    208     CAPTURED,
    209     METADONE,
    210     COMPLETED
    211 } request_entry_status_t;
    212 
    213 typedef struct request_manager_entry {
    214     request_entry_status_t      status;
    215     camera_metadata_t           *original_request;
    216     struct camera2_shot_ext     internal_shot;
    217     int                         output_stream_count;
    218 } request_manager_entry_t;
    219 
    220 // structure related to a specific function of camera
    221 typedef struct af_control_info {
    222     int    m_afTriggerTimeOut;
    223 } ctl_af_info_t;
    224 
    225 typedef struct flash_control_info {
    226     // UI flash mode indicator
    227     enum aa_aemode    i_flashMode;
    228     // AF flash
    229     bool        m_afFlashDoneFlg;
    230     // Capture flash
    231     bool        m_flashEnableFlg;
    232     int         m_flashFrameCount;
    233     int         m_flashCnt;
    234     int        m_flashTimeOut;
    235     // Flash decision
    236     // At flash auto mode only : 1 -> flash is needed, 0 -> normal case
    237     bool        m_flashDecisionResult;
    238     // torch indicator. this will be replaced by flashMode meta
    239     bool        m_flashTorchMode;
    240     // for precapture metering
    241     int        m_precaptureState;
    242     int        m_precaptureTriggerId;
    243 } ctl_flash_info_t;
    244 
    245 typedef struct ae_control_info {
    246     // pre-capture notification state
    247     enum ae_state    aeStateNoti;
    248 } ctl_ae_info_t;
    249 
    250 typedef struct scene_control_info {
    251     // pre-capture notification state
    252     enum aa_scene_mode    prevSceneMode;
    253 } ctl_scene_info_t;
    254 
    255 typedef struct request_control_info {
    256     ctl_flash_info_t flash;
    257     ctl_ae_info_t ae;
    258     ctl_af_info_t af;
    259     ctl_scene_info_t scene;
    260 } ctl_request_info_t;
    261 
    262 class RequestManager {
    263 public:
    264     RequestManager(SignalDrivenThread* main_thread);
    265     ~RequestManager();
    266     void    ResetEntry();
    267     int     GetNumEntries();
    268     bool    IsRequestQueueFull();
    269 
    270     void    RegisterRequest(camera_metadata_t *new_request, int * afMode, uint32_t * afRegion);
    271     void    DeregisterRequest(camera_metadata_t **deregistered_request);
    272     bool    PrepareFrame(size_t *num_entries, size_t *frame_size,
    273                 camera_metadata_t **prepared_frame, int afState);
    274     int     MarkProcessingRequest(ExynosBuffer * buf);
    275     void    NotifyStreamOutput(int frameCnt);
    276     void    ApplyDynamicMetadata(struct camera2_shot_ext *shot_ext);
    277     void    CheckCompleted(int index);
    278     void    UpdateIspParameters(struct camera2_shot_ext *shot_ext, int frameCnt, ctl_request_info_t *ctl_info);
    279     void    RegisterTimestamp(int frameCnt, nsecs_t *frameTime);
    280     nsecs_t  GetTimestampByFrameCnt(int frameCnt);
    281     nsecs_t  GetTimestamp(int index);
    282     uint8_t  GetOutputStreamByFrameCnt(int frameCnt);
    283     uint8_t  GetOutputStream(int index);
    284     camera2_shot_ext *  GetInternalShotExtByFrameCnt(int frameCnt);
    285     camera2_shot_ext *  GetInternalShotExt(int index);
    286     int     FindFrameCnt(struct camera2_shot_ext * shot_ext, bool drain);
    287     bool    IsVdisEnable(void);
    288     int     FindEntryIndexByFrameCnt(int frameCnt);
    289     void    Dump(void);
    290     int     GetNextIndex(int index);
    291     int     GetPrevIndex(int index);
    292     void    SetDefaultParameters(int cropX);
    293     void    SetInitialSkip(int count);
    294     int     GetSkipCnt();
    295     int     GetCompletedIndex();
    296     void    pushSensorQ(int index);
    297     int     popSensorQ();
    298     void    releaseSensorQ();
    299 
    300     bool    m_vdisEnable;
    301 
    302 private:
    303 
    304     MetadataConverter               *m_metadataConverter;
    305     SignalDrivenThread              *m_mainThread;
    306     Mutex                           m_numOfEntriesLock;
    307     int                             m_numOfEntries;
    308     int                             m_entryInsertionIndex;
    309     int                             m_entryProcessingIndex;
    310     int                             m_entryFrameOutputIndex;
    311     request_manager_entry_t         entries[NUM_MAX_REQUEST_MGR_ENTRY];
    312     int                             m_completedIndex;
    313 
    314     Mutex                           m_requestMutex;
    315 
    316     //TODO : alloc dynamically
    317     char                            m_tempFrameMetadataBuf[2000];
    318     camera_metadata_t               *m_tempFrameMetadata;
    319 
    320     int                             m_sensorPipelineSkipCnt;
    321     int                             m_cropX;
    322     int                             m_lastCompletedFrameCnt;
    323     int                             m_lastAeMode;
    324     int                             m_lastAaMode;
    325     int                             m_lastAwbMode;
    326     int                             m_lastAeComp;
    327     bool                            m_vdisBubbleEn;
    328     nsecs_t                         m_lastTimeStamp;
    329     List<int>                   m_sensorQ;
    330 };
    331 
    332 
    333 typedef struct bayer_buf_entry {
    334     int     status;
    335     int     reqFrameCnt;
    336     nsecs_t timeStamp;
    337 } bayer_buf_entry_t;
    338 
    339 
    340 class BayerBufManager {
    341 public:
    342     BayerBufManager();
    343     ~BayerBufManager();
    344     int                 GetIndexForSensorEnqueue();
    345     int                 MarkSensorEnqueue(int index);
    346     int                 MarkSensorDequeue(int index, int reqFrameCnt, nsecs_t *timeStamp);
    347     int                 GetIndexForIspEnqueue(int *reqFrameCnt);
    348     int                 GetIndexForIspDequeue(int *reqFrameCnt);
    349     int                 MarkIspEnqueue(int index);
    350     int                 MarkIspDequeue(int index);
    351     int                 GetNumOnSensor();
    352     int                 GetNumOnHalFilled();
    353     int                 GetNumOnIsp();
    354 
    355 private:
    356     int                 GetNextIndex(int index);
    357 
    358     int                 sensorEnqueueHead;
    359     int                 sensorDequeueHead;
    360     int                 ispEnqueueHead;
    361     int                 ispDequeueHead;
    362     int                 numOnSensor;
    363     int                 numOnIsp;
    364     int                 numOnHalFilled;
    365     int                 numOnHalEmpty;
    366 
    367     bayer_buf_entry_t   entries[NUM_BAYER_BUFFERS];
    368 };
    369 
    370 
    371 #define NOT_AVAILABLE           (0)
    372 #define REQUIRES_DQ_FROM_SVC    (1)
    373 #define ON_DRIVER               (2)
    374 #define ON_HAL                  (3)
    375 #define ON_SERVICE              (4)
    376 
    377 #define BAYER_NOT_AVAILABLE     (0)
    378 #define BAYER_ON_SENSOR         (1)
    379 #define BAYER_ON_HAL_FILLED     (2)
    380 #define BAYER_ON_ISP            (3)
    381 #define BAYER_ON_SERVICE        (4)
    382 #define BAYER_ON_HAL_EMPTY      (5)
    383 
    384 typedef struct stream_parameters {
    385             uint32_t                width;
    386             uint32_t                height;
    387             int                     format;
    388     const   camera2_stream_ops_t*   streamOps;
    389             uint32_t                usage;
    390             int                     numHwBuffers;
    391             int                     numSvcBuffers;
    392             int                     numOwnSvcBuffers;
    393             int                     planes;
    394             int                     metaPlanes;
    395             int                     numSvcBufsInHal;
    396             buffer_handle_t         svcBufHandle[NUM_MAX_CAMERA_BUFFERS];
    397             ExynosBuffer            svcBuffers[NUM_MAX_CAMERA_BUFFERS];
    398             ExynosBuffer            metaBuffers[NUM_MAX_CAMERA_BUFFERS];
    399             int                     svcBufStatus[NUM_MAX_CAMERA_BUFFERS];
    400             int                     bufIndex;
    401             node_info_t             *node;
    402             int                     minUndequedBuffer;
    403             bool                    needsIonMap;
    404 } stream_parameters_t;
    405 
    406 typedef struct substream_parameters {
    407             int                     type;
    408             uint32_t                width;
    409             uint32_t                height;
    410             int                     format;
    411     const   camera2_stream_ops_t*   streamOps;
    412             uint32_t                usage;
    413             int                     numSvcBuffers;
    414             int                     numOwnSvcBuffers;
    415             int                     internalFormat;
    416             int                     internalPlanes;
    417             int                     svcPlanes;
    418             buffer_handle_t         svcBufHandle[NUM_MAX_CAMERA_BUFFERS];
    419             ExynosBuffer            svcBuffers[NUM_MAX_CAMERA_BUFFERS];
    420             int                     svcBufStatus[NUM_MAX_CAMERA_BUFFERS];
    421             int                     svcBufIndex;
    422             int                     numSvcBufsInHal;
    423             bool                    needBufferInit;
    424             int                     minUndequedBuffer;
    425 } substream_parameters_t;
    426 
    427 typedef struct substream_entry {
    428     int                     priority;
    429     int                     streamId;
    430 } substream_entry_t;
    431 
    432 class ExynosCameraHWInterface2 : public virtual RefBase {
    433 public:
    434     ExynosCameraHWInterface2(int cameraId, camera2_device_t *dev, ExynosCamera2 * camera, int *openInvalid);
    435     virtual             ~ExynosCameraHWInterface2();
    436 
    437     virtual void        release();
    438 
    439     inline  int         getCameraId() const;
    440 
    441     virtual int         setRequestQueueSrcOps(const camera2_request_queue_src_ops_t *request_src_ops);
    442     virtual int         notifyRequestQueueNotEmpty();
    443     virtual int         setFrameQueueDstOps(const camera2_frame_queue_dst_ops_t *frame_dst_ops);
    444     virtual int         getInProgressCount();
    445     virtual int         flushCapturesInProgress();
    446     virtual int         constructDefaultRequest(int request_template, camera_metadata_t **request);
    447     virtual int         allocateStream(uint32_t width, uint32_t height,
    448                                     int format, const camera2_stream_ops_t *stream_ops,
    449                                     uint32_t *stream_id, uint32_t *format_actual, uint32_t *usage, uint32_t *max_buffers);
    450     virtual int         registerStreamBuffers(uint32_t stream_id, int num_buffers, buffer_handle_t *buffers);
    451     virtual int         releaseStream(uint32_t stream_id);
    452     virtual int         allocateReprocessStream(uint32_t width, uint32_t height,
    453                                     uint32_t format, const camera2_stream_in_ops_t *reprocess_stream_ops,
    454                                     uint32_t *stream_id, uint32_t *consumer_usage, uint32_t *max_buffers);
    455     virtual int         allocateReprocessStreamFromStream(uint32_t output_stream_id,
    456                                 const camera2_stream_in_ops_t *reprocess_stream_ops, uint32_t *stream_id);
    457     virtual int         releaseReprocessStream(uint32_t stream_id);
    458     virtual int         triggerAction(uint32_t trigger_id, int ext1, int ext2);
    459     virtual int         setNotifyCallback(camera2_notify_callback notify_cb, void *user);
    460     virtual int         getMetadataVendorTagOps(vendor_tag_query_ops_t **ops);
    461     virtual int         dump(int fd);
    462 private:
    463 class MainThread : public SignalDrivenThread {
    464         ExynosCameraHWInterface2 *mHardware;
    465     public:
    466         MainThread(ExynosCameraHWInterface2 *hw):
    467             SignalDrivenThread(),
    468             mHardware(hw) { }
    469         ~MainThread();
    470         void threadFunctionInternal()
    471 	    {
    472             mHardware->m_mainThreadFunc(this);
    473             return;
    474         }
    475         void        release(void);
    476         bool        m_releasing;
    477     };
    478 
    479     class SensorThread : public SignalDrivenThread {
    480         ExynosCameraHWInterface2 *mHardware;
    481     public:
    482         SensorThread(ExynosCameraHWInterface2 *hw):
    483             SignalDrivenThread(),
    484             mHardware(hw) { }
    485         ~SensorThread();
    486         void threadFunctionInternal() {
    487             mHardware->m_sensorThreadFunc(this);
    488             return;
    489         }
    490         void            release(void);
    491     //private:
    492         bool            m_releasing;
    493     };
    494 
    495     class StreamThread : public SignalDrivenThread {
    496         ExynosCameraHWInterface2 *mHardware;
    497     public:
    498         StreamThread(ExynosCameraHWInterface2 *hw, uint8_t new_index):
    499             SignalDrivenThread(),
    500             mHardware(hw),
    501             m_index(new_index) { }
    502         ~StreamThread();
    503         void threadFunctionInternal() {
    504             mHardware->m_streamThreadFunc(this);
    505             return;
    506         }
    507         void        setParameter(stream_parameters_t * new_parameters);
    508         status_t    attachSubStream(int stream_id, int priority);
    509         status_t    detachSubStream(int stream_id);
    510         void        release(void);
    511         int         findBufferIndex(void * bufAddr);
    512         int         findBufferIndex(buffer_handle_t * bufHandle);
    513 
    514         uint8_t                         m_index;
    515         bool                            m_activated;
    516     //private:
    517         stream_parameters_t             m_parameters;
    518         stream_parameters_t             *m_tempParameters;
    519         substream_entry_t               m_attachedSubStreams[NUM_MAX_SUBSTREAM];
    520         bool                            m_isBufferInit;
    521         bool                            m_releasing;
    522         int                             streamType;
    523         int                             m_numRegisteredStream;
    524      };
    525 
    526     sp<MainThread>      m_mainThread;
    527     sp<SensorThread>    m_sensorThread;
    528     sp<StreamThread>    m_streamThreads[NUM_MAX_STREAM_THREAD];
    529     substream_parameters_t  m_subStreams[STREAM_ID_LAST+1];
    530 
    531 
    532 
    533     RequestManager      *m_requestManager;
    534     BayerBufManager     *m_BayerManager;
    535     ExynosCamera2       *m_camera2;
    536 
    537     void                m_mainThreadFunc(SignalDrivenThread * self);
    538     void                m_sensorThreadFunc(SignalDrivenThread * self);
    539     void                m_streamThreadFunc(SignalDrivenThread * self);
    540     void                m_streamThreadInitialize(SignalDrivenThread * self);
    541 
    542     void                m_streamFunc_direct(SignalDrivenThread *self);
    543     void                m_streamFunc_indirect(SignalDrivenThread *self);
    544 
    545     void                m_streamBufferInit(SignalDrivenThread *self);
    546 
    547     int                 m_runSubStreamFunc(StreamThread *selfThread, ExynosBuffer *srcImageBuf,
    548                             int stream_id, nsecs_t frameTimeStamp);
    549     int                 m_jpegCreator(StreamThread *selfThread, ExynosBuffer *srcImageBuf, nsecs_t frameTimeStamp);
    550     int                 m_recordCreator(StreamThread *selfThread, ExynosBuffer *srcImageBuf, nsecs_t frameTimeStamp);
    551     int                 m_prvcbCreator(StreamThread *selfThread, ExynosBuffer *srcImageBuf, nsecs_t frameTimeStamp);
    552     void                m_getAlignedYUVSize(int colorFormat, int w, int h,
    553                                                 ExynosBuffer *buf);
    554     bool                m_getRatioSize(int  src_w,  int   src_h,
    555                                              int  dst_w,  int   dst_h,
    556                                              int *crop_x, int *crop_y,
    557                                              int *crop_w, int *crop_h,
    558                                              int zoom);
    559 	int				createIonClient(ion_client ionClient);
    560 	int					deleteIonClient(ion_client ionClient);
    561 
    562     int				allocCameraMemory(ion_client ionClient, ExynosBuffer *buf, int iMemoryNum);
    563     int             allocCameraMemory(ion_client ionClient, ExynosBuffer *buf, int iMemoryNum, int cacheFlag);
    564 	void				freeCameraMemory(ExynosBuffer *buf, int iMemoryNum);
    565 	void				initCameraMemory(ExynosBuffer *buf, int iMemoryNum);
    566 
    567     void            DumpInfoWithShot(struct camera2_shot_ext * shot_ext);
    568     bool            m_checkThumbnailSize(int w, int h);
    569     bool            yuv2Jpeg(ExynosBuffer *yuvBuf,
    570                             ExynosBuffer *jpegBuf,
    571                             ExynosRect *rect);
    572     int             InitializeISPChain();
    573     void            StartISP();
    574     void            StartSCCThread(bool threadExists);
    575     int             GetAfState();
    576     void            SetAfMode(enum aa_afmode afMode);
    577     void            SetAfRegion(uint32_t * afRegion);
    578     void            OnAfTrigger(int id);
    579     void            OnAfTriggerAutoMacro(int id);
    580     void            OnAfTriggerCAFPicture(int id);
    581     void            OnAfTriggerCAFVideo(int id);
    582     void            OnPrecaptureMeteringTriggerStart(int id);
    583     void            OnAfCancel(int id);
    584     void            OnAfCancelAutoMacro(int id);
    585     void            OnAfCancelCAFPicture(int id);
    586     void            OnAfCancelCAFVideo(int id);
    587     void            OnPrecaptureMeteringNotificationISP();
    588     void            OnPrecaptureMeteringNotificationSensor();
    589     void            OnAfNotification(enum aa_afstate noti);
    590     void            OnAfNotificationAutoMacro(enum aa_afstate noti);
    591     void            OnAfNotificationCAFPicture(enum aa_afstate noti);
    592     void            OnAfNotificationCAFVideo(enum aa_afstate noti);
    593     void            SetAfStateForService(int newState);
    594     int             GetAfStateForService();
    595     exif_attribute_t    mExifInfo;
    596     void            m_setExifFixedAttribute(void);
    597     void            m_setExifChangedAttribute(exif_attribute_t *exifInfo, ExynosRect *rect,
    598                          camera2_shot_ext *currentEntry);
    599     void            m_preCaptureSetter(struct camera2_shot_ext * shot_ext);
    600     void            m_preCaptureListenerSensor(struct camera2_shot_ext * shot_ext);
    601     void            m_preCaptureListenerISP(struct camera2_shot_ext * shot_ext);
    602     void            m_preCaptureAeState(struct camera2_shot_ext * shot_ext);
    603     void            m_updateAfRegion(struct camera2_shot_ext * shot_ext);
    604     void            m_afTrigger(struct camera2_shot_ext * shot_ext, int mode);
    605     void               *m_exynosPictureCSC;
    606     void               *m_exynosVideoCSC;
    607 
    608 
    609     camera2_request_queue_src_ops_t     *m_requestQueueOps;
    610     camera2_frame_queue_dst_ops_t       *m_frameQueueOps;
    611     camera2_notify_callback             m_notifyCb;
    612     void                                *m_callbackCookie;
    613 
    614     int                                 m_numOfRemainingReqInSvc;
    615     bool                                m_isRequestQueuePending;
    616     bool                                m_isRequestQueueNull;
    617     camera2_device_t                    *m_halDevice;
    618     static gralloc_module_t const*      m_grallocHal;
    619 
    620 
    621     camera_hw_info_t                     m_camera_info;
    622 
    623 	ion_client m_ionCameraClient;
    624 
    625     bool                                m_isIspStarted;
    626 
    627     int                                 m_need_streamoff;
    628     ExynosBuffer                        m_sccLocalBuffer[NUM_MAX_CAMERA_BUFFERS];
    629     bool                                m_sccLocalBufferValid;
    630 
    631     int                                 indexToQueue[3+1];
    632 
    633     bool                                m_scp_flushing;
    634     bool                                m_closing;
    635     ExynosBuffer                        m_resizeBuf;
    636 #ifndef ENABLE_FRAME_SYNC
    637     int                                 m_currentOutputStreams;
    638 #endif
    639     int                                 m_currentReprocessOutStreams;
    640     ExynosBuffer                        m_previewCbBuf;
    641     int             				    m_cameraId;
    642     bool                                m_scp_closing;
    643     bool                                m_scp_closed;
    644     bool                                m_wideAspect;
    645     uint32_t                            currentAfRegion[4];
    646     float                               m_zoomRatio;
    647 
    648     int                                 m_vdisBubbleCnt;
    649     int                                 m_vdisDupFrame;
    650 
    651     mutable Mutex                       m_qbufLock;
    652     mutable Mutex                       m_jpegEncoderLock;
    653     int                                 m_jpegEncodingCount;
    654     mutable Mutex                       m_afModeTriggerLock;
    655 
    656     bool                                m_scpForceSuspended;
    657     int                                 m_afState;
    658     int                                 m_afTriggerId;
    659     enum aa_afmode                      m_afMode;
    660     enum aa_afmode                      m_afMode2;
    661     bool                                m_IsAfModeUpdateRequired;
    662     bool                                m_IsAfTriggerRequired;
    663     bool                                m_IsAfLockRequired;
    664     int                                 m_serviceAfState;
    665     bool                                m_AfHwStateFailed;
    666     int                                 m_afPendingTriggerId;
    667     int                                 m_afModeWaitingCnt;
    668     struct camera2_shot_ext             m_jpegMetadata;
    669     int                                 m_scpOutputSignalCnt;
    670     int                                 m_scpOutputImageCnt;
    671     int                                 m_nightCaptureCnt;
    672     int                                 m_nightCaptureFrameCnt;
    673     int                                 m_lastSceneMode;
    674     int                                 m_thumbNailW;
    675     int                                 m_thumbNailH;
    676     int                                 m_reprocessStreamId;
    677     const camera2_stream_in_ops_t *     m_reprocessOps;
    678     int                                 m_reprocessOutputStreamId;
    679     int                                 m_reprocessingFrameCnt;
    680     ctl_request_info_t        m_ctlInfo;
    681 };
    682 
    683 }; // namespace android
    684 
    685 #endif
    686