am 6e324cc3: Merge "Cleanup Obsolete LOCAL_PRELINK_MODULE."
authorYing Wang <wangying@google.com>
Tue, 16 Dec 2014 20:49:48 +0000 (20:49 +0000)
committerAndroid Git Automerger <android-git-automerger@android.com>
Tue, 16 Dec 2014 20:49:48 +0000 (20:49 +0000)
* commit '6e324cc3a987b3aee665a5ec32993018d84479d4':
  Cleanup Obsolete LOCAL_PRELINK_MODULE.

libcamera2/ExynosCameraHWInterface2.cpp
libcamera2/ExynosCameraHWInterface2.h
libgscaler/exynos_gsc_utils.h
libgscaler/exynos_gscaler.c

index 8fce907870b2de6cff2ea1151c8813357a3687b0..cead7394757252ed0d6a5b26d1b4bce21f2ae5ed 100644 (file)
@@ -615,10 +615,15 @@ void RequestManager::ApplyDynamicMetadata(struct camera2_shot_ext *shot_ext)
     ALOGV("DEBUG(%s): frameCnt(%d)", __FUNCTION__, shot_ext->shot.ctl.request.frameCount);
 
     for (i = 0 ; i < NUM_MAX_REQUEST_MGR_ENTRY ; i++) {
-        if((entries[i].internal_shot.shot.ctl.request.frameCount == shot_ext->shot.ctl.request.frameCount)
-            && (entries[i].status == CAPTURED)){
-            entries[i].status = METADONE;
-            break;
+        if (entries[i].internal_shot.shot.ctl.request.frameCount
+                == shot_ext->shot.ctl.request.frameCount) {
+            if (entries[i].status == CAPTURED) {
+                entries[i].status = METADONE;
+                break;
+            }
+            if (entries[i].status == METADONE) {
+                return;
+            }
         }
     }
 
@@ -861,9 +866,10 @@ camera2_shot_ext *  RequestManager::GetInternalShotExt(int index)
     return &currentEntry->internal_shot;
 }
 
-int     RequestManager::FindFrameCnt(struct camera2_shot_ext * shot_ext)
+int     RequestManager::FindFrameCnt(struct camera2_shot_ext * shot_ext, bool drain)
 {
     Mutex::Autolock lock(m_requestMutex);
+    Mutex::Autolock lock2(m_numOfEntriesLock);
     int i;
 
     if (m_numOfEntries == 0) {
@@ -879,6 +885,9 @@ int     RequestManager::FindFrameCnt(struct camera2_shot_ext * shot_ext)
             entries[i].status = CAPTURED;
             return entries[i].internal_shot.shot.ctl.request.frameCount;
         }
+        if (drain && (entries[i].status >= CAPTURED)) {
+            return entries[i].internal_shot.shot.ctl.request.frameCount;
+        }
         CAM_LOGE("ERR(%s): frameCount(%d), index(%d), status(%d)", __FUNCTION__, shot_ext->shot.ctl.request.frameCount, i, entries[i].status);
 
     }
@@ -1052,7 +1061,7 @@ ExynosCameraHWInterface2::ExynosCameraHWInterface2(int cameraId, camera2_device_
         m_ctlInfo.flash.m_afFlashDoneFlg= false;
         m_ctlInfo.flash.m_flashEnableFlg = false;
         m_ctlInfo.flash.m_flashFrameCount = 0;
-        m_ctlInfo.flash.m_flashCnt = 0;
+        m_ctlInfo.flash.m_flashCnt = IS_FLASH_STATE_NONE;
         m_ctlInfo.flash.m_flashTimeOut = 0;
         m_ctlInfo.flash.m_flashDecisionResult = false;
         m_ctlInfo.flash.m_flashTorchMode = false;
@@ -2957,7 +2966,7 @@ void ExynosCameraHWInterface2::m_preCaptureSetter(struct camera2_shot_ext * shot
         shot_ext->request_scc = 0;
         shot_ext->request_scp = 0;
         m_ctlInfo.flash.m_flashEnableFlg = false;
-        m_ctlInfo.flash.m_flashCnt = 0;
+        m_ctlInfo.flash.m_flashCnt = IS_FLASH_STATE_NONE;
         m_ctlInfo.flash.m_afFlashDoneFlg= false;
         break;
     case IS_FLASH_STATE_NONE:
@@ -3154,7 +3163,7 @@ void ExynosCameraHWInterface2::m_sensorThreadFunc(SignalDrivenThread * self)
             matchedFrameCnt = m_ctlInfo.flash.m_flashFrameCount;
             ALOGV("Skip frame, request is fixed at %d", matchedFrameCnt);
         } else {
-            matchedFrameCnt = m_requestManager->FindFrameCnt(shot_ext);
+            matchedFrameCnt = m_requestManager->FindFrameCnt(shot_ext, m_isRequestQueueNull);
         }
 
         if (matchedFrameCnt == -1 && m_vdisBubbleCnt > 0) {
@@ -3231,7 +3240,7 @@ void ExynosCameraHWInterface2::m_sensorThreadFunc(SignalDrivenThread * self)
                         m_ctlInfo.flash.m_flashEnableFlg = false;
                         m_ctlInfo.flash.m_afFlashDoneFlg = false;
                         m_ctlInfo.flash.m_flashDecisionResult = false;
-                        m_ctlInfo.flash.m_flashCnt = 0;
+                        m_ctlInfo.flash.m_flashCnt = IS_FLASH_STATE_NONE;
                     }
                     m_ctlInfo.af.m_afTriggerTimeOut = 1;
                 }
@@ -3367,7 +3376,7 @@ void ExynosCameraHWInterface2::m_sensorThreadFunc(SignalDrivenThread * self)
                 if (!m_ctlInfo.flash.m_flashDecisionResult) {
                     m_ctlInfo.flash.m_flashEnableFlg = false;
                     m_ctlInfo.flash.m_afFlashDoneFlg = false;
-                    m_ctlInfo.flash.m_flashCnt = 0;
+                    m_ctlInfo.flash.m_flashCnt = IS_FLASH_STATE_NONE;
                 } else if ((m_ctlInfo.flash.m_flashCnt == IS_FLASH_STATE_AUTO_DONE) ||
                                           (m_ctlInfo.flash.m_flashCnt == IS_FLASH_STATE_AUTO_OFF)) {
                     ALOGD("(%s): [Flash] Flash capture start : skip request scc 1#####", __FUNCTION__);
@@ -3381,7 +3390,7 @@ void ExynosCameraHWInterface2::m_sensorThreadFunc(SignalDrivenThread * self)
                     shot_ext->shot.ctl.aa.aeflashMode = AA_FLASHMODE_OFF;
                     m_ctlInfo.flash.m_flashEnableFlg = false;
                     m_ctlInfo.flash.m_afFlashDoneFlg= false;
-                    m_ctlInfo.flash.m_flashCnt = 0;
+                    m_ctlInfo.flash.m_flashCnt = IS_FLASH_STATE_NONE;
                 }
             } else if (shot_ext->shot.ctl.aa.captureIntent == AA_CAPTURE_INTENT_STILL_CAPTURE) {
                 m_ctlInfo.flash.m_flashDecisionResult = false;
@@ -3408,8 +3417,14 @@ void ExynosCameraHWInterface2::m_sensorThreadFunc(SignalDrivenThread * self)
                 shot_ext->request_scc = 0;
                 m_reprocessingFrameCnt = shot_ext->shot.ctl.request.frameCount;
                 m_ctlInfo.flash.m_flashDecisionResult = false;
-                memcpy(&m_jpegMetadata, (void*)(m_requestManager->GetInternalShotExtByFrameCnt(m_reprocessingFrameCnt)),
-                    sizeof(struct camera2_shot_ext));
+                void *shot = m_requestManager->GetInternalShotExtByFrameCnt(m_reprocessingFrameCnt);
+                if (!shot) { // m_isRequestQueueNull reuse current
+                    ALOGD("(%s): isReprocessing: "
+                        "m_reprocessingFrameCnt missing, using shot_ext",
+                        __FUNCTION__);
+                    shot = shot_ext;
+                }
+                memcpy(&m_jpegMetadata, shot, sizeof(struct camera2_shot_ext));
                 m_streamThreads[1]->SetSignal(SIGNAL_STREAM_REPROCESSING_START);
                 m_ctlInfo.flash.m_flashEnableFlg = false;
             }
@@ -3512,11 +3527,17 @@ void ExynosCameraHWInterface2::m_sensorThreadFunc(SignalDrivenThread * self)
             if (shot_ext->request_scc) {
                 ALOGV("send SIGNAL_STREAM_DATA_COMING (SCC)");
                 if (shot_ext->shot.ctl.request.outputStreams[0] & STREAM_MASK_JPEG) {
-                    if (m_ctlInfo.flash.m_flashCnt < IS_FLASH_STATE_CAPTURE)
-                        memcpy(&m_jpegMetadata, (void*)(m_requestManager->GetInternalShotExtByFrameCnt(shot_ext->shot.ctl.request.frameCount)),
-                            sizeof(struct camera2_shot_ext));
-                    else
-                        memcpy(&m_jpegMetadata, (void*)shot_ext, sizeof(struct camera2_shot_ext));
+                    void *shot = shot_ext;
+                    if (m_ctlInfo.flash.m_flashCnt < IS_FLASH_STATE_CAPTURE) {
+                        shot = m_requestManager->GetInternalShotExtByFrameCnt(m_reprocessingFrameCnt);
+                        if (!shot) { // m_isRequestQueueNull reuse current
+                            ALOGD("(%s): request_scc: "
+                                "m_reprocessingFrameCnt missing, using shot_ext",
+                                __FUNCTION__);
+                            shot = shot_ext;
+                        }
+                    }
+                    memcpy(&m_jpegMetadata, shot, sizeof(struct camera2_shot_ext));
                 }
                 m_streamThreads[1]->SetSignal(SIGNAL_STREAM_DATA_COMING);
             }
index a8e334885e1665a3f4b19a276281144053905db5..927eace337d147248b6130d7f920132327ee4124 100644 (file)
@@ -283,7 +283,7 @@ public:
     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);
+    int     FindFrameCnt(struct camera2_shot_ext * shot_ext, bool drain);
     bool    IsVdisEnable(void);
     int     FindEntryIndexByFrameCnt(int frameCnt);
     void    Dump(void);
index 8c0217f1718df98ceb18b6e93560df3337f47fd4..8e5c49dbc2a6cbcec6791bf9b69e55ae065dceac 100644 (file)
@@ -128,6 +128,7 @@ struct GSC_HANDLE {
     void            *op_mutex;
     void            *obj_mutex[NUM_OF_GSC_HW];
     void            *cur_obj_mutex;
+    bool             destroy_cur_obj_mutex;
     bool             flag_local_path;
     bool             flag_exclusive_open;
     struct media_device *media0;
index 360812b89629ed95fbd6d8048dbb4fb3e77cdbea..0e7bb77c53fa88a88e93369e8da65c24efd39823 100644 (file)
@@ -561,9 +561,14 @@ bool m_exynos_gsc_find_and_trylock_and_create(
                     continue;
                 }
 
-                if (gsc_handle->cur_obj_mutex)
+                /* Trade temporary object for one in the pool */
+                if (gsc_handle->cur_obj_mutex) {
                     exynos_mutex_unlock(gsc_handle->cur_obj_mutex);
+                    if (gsc_handle->destroy_cur_obj_mutex)
+                        exynos_mutex_destroy(gsc_handle->cur_obj_mutex);
+                }
 
+                gsc_handle->destroy_cur_obj_mutex = false;
                 gsc_handle->cur_obj_mutex = gsc_handle->obj_mutex[i];
 
                 flag_find_new_gsc = true;
@@ -729,6 +734,7 @@ void *exynos_gsc_create(
         gsc_handle->obj_mutex[i] = NULL;
 
     gsc_handle->cur_obj_mutex = NULL;
+    gsc_handle->destroy_cur_obj_mutex = false;
     gsc_handle->flag_local_path = false;
     gsc_handle->flag_exclusive_open = false;
 
@@ -813,6 +819,7 @@ void *exynos_gsc_reserve(int dev_num)
     gsc_handle->gsc_fd = -1;
     gsc_handle->op_mutex = NULL;
     gsc_handle->cur_obj_mutex = NULL;
+    gsc_handle->destroy_cur_obj_mutex = true;
 
     sprintf(mutex_name, "%sObject%d", LOG_TAG, dev_num);
     gsc_handle->cur_obj_mutex = exynos_mutex_create(EXYNOS_MUTEX_TYPE_SHARED, mutex_name);
@@ -908,6 +915,7 @@ void *exynos_gsc_create_exclusive(
         gsc_handle->obj_mutex[i] = NULL;
 
     gsc_handle->cur_obj_mutex = NULL;
+    gsc_handle->destroy_cur_obj_mutex = false;
     gsc_handle->flag_local_path = false;
     gsc_handle->flag_exclusive_open = true;
 
@@ -928,6 +936,7 @@ void *exynos_gsc_create_exclusive(
         ALOGE("%s::exynos_mutex_create(%s) fail", __func__, mutex_name);
         goto err;
     }
+    gsc_handle->destroy_cur_obj_mutex = true;
 
     do {
         if (exynos_mutex_trylock(gsc_handle->cur_obj_mutex) == true) {
@@ -965,8 +974,11 @@ err:
     if (gsc_handle) {
         m_exynos_gsc_destroy(gsc_handle);
 
-        if (gsc_handle->cur_obj_mutex)
+        if (gsc_handle->cur_obj_mutex) {
             exynos_mutex_unlock(gsc_handle->cur_obj_mutex);
+            if (gsc_handle->destroy_cur_obj_mutex)
+                exynos_mutex_destroy(gsc_handle->cur_obj_mutex);
+        }
 
         for (i = 0; i < NUM_OF_GSC_HW; i++) {
             if ((gsc_handle->obj_mutex[i] != NULL) &&
@@ -1023,6 +1035,9 @@ void exynos_gsc_destroy(
         }
     }
 
+    if (gsc_handle->destroy_cur_obj_mutex)
+        exynos_mutex_destroy(gsc_handle->cur_obj_mutex);
+
     exynos_mutex_unlock(gsc_handle->op_mutex);
 
     if (exynos_mutex_destroy(gsc_handle->op_mutex) == false)