Fix JPEG thumbnail size check.
[GitHub/LineageOS/android_hardware_samsung_slsi_exynos5.git] / libcamera2 / ExynosCameraHWInterface2.h
index 75f5cf0b9de3813fa6390fe9234f3ea065e461cb..a8e334885e1665a3f4b19a276281144053905db5 100644 (file)
@@ -61,7 +61,7 @@ namespace android {
 #define NODE_PREFIX     "/dev/video"
 
 #define NUM_MAX_STREAM_THREAD       (5)
-#define NUM_MAX_REQUEST_MGR_ENTRY   (4)
+#define NUM_MAX_REQUEST_MGR_ENTRY   (5)
 #define NUM_MAX_CAMERA_BUFFERS      (16)
 #define NUM_BAYER_BUFFERS           (8)
 #define NUM_SCC_BUFFERS             (8)
@@ -118,6 +118,8 @@ namespace android {
 #define SUBSTREAM_TYPE_PRVCB        (3)
 #define FLASH_STABLE_WAIT_TIMEOUT        (10)
 
+#define SIG_WAITING_TICK            (5000)
+
 #ifdef EXYNOS_CAMERA_LOG
 #define CAM_LOGV(...) ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
 #define CAM_LOGD(...) ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__))
@@ -148,21 +150,6 @@ enum is_subscenario_id {
        ISS_SUB_END
 };
 
-int SUPPORT_THUMBNAIL_REAR_SIZE[][2] =
-{
-    {160, 120},
-    {160, 90},
-    {144, 96}
-};
-
-int SUPPORT_THUMBNAIL_FRONT_SIZE[][2] =
-{
-    {160, 120},
-    {160, 160},
-    {160, 90},
-    {144, 96}
-};
-
 enum is_set_flash_command_state {
     IS_FLASH_STATE_NONE = 0,
     IS_FLASH_STATE_ON = 1,
@@ -219,7 +206,8 @@ typedef enum request_entry_status {
     REGISTERED,
     REQUESTED,
     CAPTURED,
-    METADONE
+    METADONE,
+    COMPLETED
 } request_entry_status_t;
 
 typedef struct request_manager_entry {
@@ -254,21 +242,21 @@ typedef struct flash_control_info {
     int        m_precaptureTriggerId;
 } ctl_flash_info_t;
 
-typedef struct awb_control_info {
-     // UI awb mode indicator
-    enum aa_awbmode    i_awbMode;
-} ctl_awb_info_t;
-
 typedef struct ae_control_info {
     // pre-capture notification state
     enum ae_state    aeStateNoti;
 } ctl_ae_info_t;
 
+typedef struct scene_control_info {
+    // pre-capture notification state
+    enum aa_scene_mode    prevSceneMode;
+} ctl_scene_info_t;
+
 typedef struct request_control_info {
     ctl_flash_info_t flash;
-    ctl_awb_info_t awb;
     ctl_ae_info_t ae;
     ctl_af_info_t af;
+    ctl_scene_info_t scene;
 } ctl_request_info_t;
 
 class RequestManager {
@@ -279,11 +267,11 @@ public:
     int     GetNumEntries();
     bool    IsRequestQueueFull();
 
-    void    RegisterRequest(camera_metadata_t *new_request);
+    void    RegisterRequest(camera_metadata_t *new_request, int * afMode, uint32_t * afRegion);
     void    DeregisterRequest(camera_metadata_t **deregistered_request);
     bool    PrepareFrame(size_t *num_entries, size_t *frame_size,
                 camera_metadata_t **prepared_frame, int afState);
-    int     MarkProcessingRequest(ExynosBuffer * buf, int *afMode);
+    int     MarkProcessingRequest(ExynosBuffer * buf);
     void    NotifyStreamOutput(int frameCnt);
     void    ApplyDynamicMetadata(struct camera2_shot_ext *shot_ext);
     void    CheckCompleted(int index);
@@ -293,23 +281,29 @@ public:
     nsecs_t  GetTimestamp(int index);
     uint8_t  GetOutputStreamByFrameCnt(int frameCnt);
     uint8_t  GetOutputStream(int index);
+    camera2_shot_ext *  GetInternalShotExtByFrameCnt(int frameCnt);
+    camera2_shot_ext *  GetInternalShotExt(int index);
     int     FindFrameCnt(struct camera2_shot_ext * shot_ext);
     bool    IsVdisEnable(void);
     int     FindEntryIndexByFrameCnt(int frameCnt);
     void    Dump(void);
     int     GetNextIndex(int index);
+    int     GetPrevIndex(int index);
     void    SetDefaultParameters(int cropX);
     void    SetInitialSkip(int count);
     int     GetSkipCnt();
-    void    SetFrameIndex(int index);
-    int    GetFrameIndex();
-    void  pushSensorQ(int index);
-    int popSensorQ();
-    void releaseSensorQ();
+    int     GetCompletedIndex();
+    void    pushSensorQ(int index);
+    int     popSensorQ();
+    void    releaseSensorQ();
+
+    bool    m_vdisEnable;
+
 private:
 
     MetadataConverter               *m_metadataConverter;
     SignalDrivenThread              *m_mainThread;
+    Mutex                           m_numOfEntriesLock;
     int                             m_numOfEntries;
     int                             m_entryInsertionIndex;
     int                             m_entryProcessingIndex;
@@ -325,7 +319,7 @@ private:
 
     int                             m_sensorPipelineSkipCnt;
     int                             m_cropX;
-    int                         m_frameIndex;
+    int                             m_lastCompletedFrameCnt;
     int                             m_lastAeMode;
     int                             m_lastAaMode;
     int                             m_lastAwbMode;
@@ -406,6 +400,7 @@ typedef struct stream_parameters {
             int                     bufIndex;
             node_info_t             *node;
             int                     minUndequedBuffer;
+            bool                    needsIonMap;
 } stream_parameters_t;
 
 typedef struct substream_parameters {
@@ -579,7 +574,7 @@ class MainThread : public SignalDrivenThread {
     void            StartSCCThread(bool threadExists);
     int             GetAfState();
     void            SetAfMode(enum aa_afmode afMode);
-    void            OnAfTriggerStart(int id);
+    void            SetAfRegion(uint32_t * afRegion);
     void            OnAfTrigger(int id);
     void            OnAfTriggerAutoMacro(int id);
     void            OnAfTriggerCAFPicture(int id);
@@ -600,12 +595,13 @@ class MainThread : public SignalDrivenThread {
     exif_attribute_t    mExifInfo;
     void            m_setExifFixedAttribute(void);
     void            m_setExifChangedAttribute(exif_attribute_t *exifInfo, ExynosRect *rect,
-                         camera2_shot *currentEntry);
+                         camera2_shot_ext *currentEntry);
     void            m_preCaptureSetter(struct camera2_shot_ext * shot_ext);
     void            m_preCaptureListenerSensor(struct camera2_shot_ext * shot_ext);
     void            m_preCaptureListenerISP(struct camera2_shot_ext * shot_ext);
+    void            m_preCaptureAeState(struct camera2_shot_ext * shot_ext);
     void            m_updateAfRegion(struct camera2_shot_ext * shot_ext);
-    void            m_afTrigger(struct camera2_shot_ext * shot_ext);
+    void            m_afTrigger(struct camera2_shot_ext * shot_ext, int mode);
     void               *m_exynosPictureCSC;
     void               *m_exynosVideoCSC;
 
@@ -646,14 +642,18 @@ class MainThread : public SignalDrivenThread {
     bool                                m_scp_closing;
     bool                                m_scp_closed;
     bool                                m_wideAspect;
-    uint32_t                            lastAfRegion[4];
+    uint32_t                            currentAfRegion[4];
     float                               m_zoomRatio;
 
     int                                 m_vdisBubbleCnt;
     int                                 m_vdisDupFrame;
 
     mutable Mutex                       m_qbufLock;
+    mutable Mutex                       m_jpegEncoderLock;
+    int                                 m_jpegEncodingCount;
+    mutable Mutex                       m_afModeTriggerLock;
 
+    bool                                m_scpForceSuspended;
     int                                 m_afState;
     int                                 m_afTriggerId;
     enum aa_afmode                      m_afMode;
@@ -665,11 +665,12 @@ class MainThread : public SignalDrivenThread {
     bool                                m_AfHwStateFailed;
     int                                 m_afPendingTriggerId;
     int                                 m_afModeWaitingCnt;
-    struct camera2_shot                 m_jpegMetadata;
+    struct camera2_shot_ext             m_jpegMetadata;
     int                                 m_scpOutputSignalCnt;
     int                                 m_scpOutputImageCnt;
     int                                 m_nightCaptureCnt;
     int                                 m_nightCaptureFrameCnt;
+    int                                 m_lastSceneMode;
     int                                 m_thumbNailW;
     int                                 m_thumbNailH;
     int                                 m_reprocessStreamId;