hardware: samsung_slsi: libcamera2: ZSL Bug fixes
authorSungjoong Kang <sj3.kang@samsung.com>
Wed, 19 Sep 2012 07:13:43 +0000 (00:13 -0700)
committerRebecca Schultz Zavin <rebecca@android.com>
Wed, 19 Sep 2012 18:42:23 +0000 (11:42 -0700)
Fixed crash on switching modes.
Reprocessed stream data will have proper timestamp.

Change-Id: I4453aa237eef6911f4c44a7f02a8494f32f58072
Signed-off-by: Sungjoong Kang <sj3.kang@samsung.com>
libcamera2/ExynosCameraHWInterface2.cpp
libcamera2/MetadataConverter.cpp

index b9dd4392a23538204502a9cfb9b65f63c6a4f578..aacccd201d253afa07bffabc98834b21a0e1c029 100644 (file)
@@ -416,7 +416,7 @@ bool RequestManager::PrepareFrame(size_t* num_entries, size_t* frame_size,
         return false;
     }
     m_entryFrameOutputIndex = tempFrameOutputIndex;
-    m_tempFrameMetadata = place_camera_metadata(m_tempFrameMetadataBuf, 2000, 20, 500); //estimated
+    m_tempFrameMetadata = place_camera_metadata(m_tempFrameMetadataBuf, 2000, 25, 500); //estimated
     add_camera_metadata_entry(m_tempFrameMetadata, ANDROID_CONTROL_AF_STATE, &afState, 1);
     res = m_metadataConverter->ToDynamicMetadata(&(currentEntry->internal_shot),
                 m_tempFrameMetadata);
@@ -760,9 +760,14 @@ void    RequestManager::RegisterTimestamp(int frameCnt, nsecs_t * frameTime)
     }
 
     request_manager_entry * currentEntry = &(entries[index]);
-    currentEntry->internal_shot.shot.dm.sensor.timeStamp = *((uint64_t*)frameTime);
-    ALOGV("DEBUG(%s): applied timestamp for reqIndex(%d) frameCnt(%d) (%lld)", __FUNCTION__,
+    if (currentEntry->internal_shot.isReprocessing == 1) {
+        ALOGV("DEBUG(%s): REPROCESSING : preserving timestamp for reqIndex(%d) frameCnt(%d) (%lld)", __FUNCTION__,
         index, frameCnt, currentEntry->internal_shot.shot.dm.sensor.timeStamp);
+    } else {
+        currentEntry->internal_shot.shot.dm.sensor.timeStamp = *((uint64_t*)frameTime);
+        ALOGV("DEBUG(%s): applied timestamp for reqIndex(%d) frameCnt(%d) (%lld)", __FUNCTION__,
+            index, frameCnt, currentEntry->internal_shot.shot.dm.sensor.timeStamp);
+    }
 }
 
 
@@ -2068,10 +2073,11 @@ int ExynosCameraHWInterface2::releaseStream(uint32_t stream_id)
             targetStream->release();
             usleep(33000);
         } while (targetStream->m_releasing);
+        m_camera_info.capture.status = false;
         ALOGD("END   stream thread release %d", __LINE__);
     }
 
-    if (releasingScpMain || (m_streamThreads[0]->m_numRegisteredStream == 0 && m_streamThreads[0]->m_activated)) {
+    if (releasingScpMain || (m_streamThreads[0].get() != NULL && m_streamThreads[0]->m_numRegisteredStream == 0 && m_streamThreads[0]->m_activated)) {
         ALOGV("(%s): deactivating stream thread 0", __FUNCTION__);
         targetStream = (StreamThread*)(m_streamThreads[0].get());
         targetStream->m_releasing = true;
@@ -2109,10 +2115,10 @@ int ExynosCameraHWInterface2::releaseStream(uint32_t stream_id)
                 m_camera_info.capture.status = false;
             }
             ALOGV("(%s): calling capture streamoff done", __FUNCTION__);
-                m_camera_info.capture.buffers = 0;
-                ALOGV("DEBUG(%s): capture calling reqbuf 0 ", __FUNCTION__);
-                cam_int_reqbufs(&(m_camera_info.capture));
-                ALOGV("DEBUG(%s): capture calling reqbuf 0 done", __FUNCTION__);
+            m_camera_info.capture.buffers = 0;
+            ALOGV("DEBUG(%s): capture calling reqbuf 0 ", __FUNCTION__);
+            cam_int_reqbufs(&(m_camera_info.capture));
+            ALOGV("DEBUG(%s): capture calling reqbuf 0 done", __FUNCTION__);
         }
         m_isIspStarted = false;
     }
@@ -3422,17 +3428,19 @@ void ExynosCameraHWInterface2::m_streamFunc_direct(SignalDrivenThread *self)
         CAM_LOGD("(%s): [%d] START SIGNAL_THREAD_RELEASE", __FUNCTION__, selfThread->m_index);
 
         if (selfThread->m_isBufferInit) {
-            ALOGV("(%s): [%d] calling streamoff (fd:%d)", __FUNCTION__,
-                selfThread->m_index, currentNode->fd);
-            if (cam_int_streamoff(currentNode) < 0 ) {
-                ALOGE("ERR(%s): stream off fail", __FUNCTION__);
-            }
-            ALOGV("(%s): [%d] streamoff done and calling reqbuf 0 (fd:%d)", __FUNCTION__,
-                    selfThread->m_index, currentNode->fd);
-            currentNode->buffers = 0;
-            cam_int_reqbufs(currentNode);
-            ALOGV("(%s): [%d] reqbuf 0 DONE (fd:%d)", __FUNCTION__,
+            if (!(currentNode->fd == m_camera_info.capture.fd && m_camera_info.capture.status == false)) {
+                ALOGV("(%s): [%d] calling streamoff (fd:%d)", __FUNCTION__,
                     selfThread->m_index, currentNode->fd);
+                if (cam_int_streamoff(currentNode) < 0 ) {
+                    ALOGE("ERR(%s): stream off fail", __FUNCTION__);
+                }
+                ALOGV("(%s): [%d] streamoff done and calling reqbuf 0 (fd:%d)", __FUNCTION__,
+                        selfThread->m_index, currentNode->fd);
+                currentNode->buffers = 0;
+                cam_int_reqbufs(currentNode);
+                ALOGV("(%s): [%d] reqbuf 0 DONE (fd:%d)", __FUNCTION__,
+                        selfThread->m_index, currentNode->fd);
+            }
         }
 #ifdef ENABLE_FRAME_SYNC
         // free metabuffers
@@ -3478,8 +3486,7 @@ void ExynosCameraHWInterface2::m_streamFunc_direct(SignalDrivenThread *self)
                 continue;
 
 #ifdef ENABLE_FRAME_SYNC
-            // TODO: check real timestamp
-            frameTimeStamp = m_requestManager->GetTimestamp(m_requestManager->GetFrameIndex());
+            frameTimeStamp = m_requestManager->GetTimestampByFrameCnt(m_reprocessingFrameCnt);
             m_requestManager->NotifyStreamOutput(m_reprocessingFrameCnt);
 #else
             frameTimeStamp = m_requestManager->GetTimestamp(m_requestManager->GetFrameIndex());
index 9d1a3cffce544c5383f9d07589a612267e4a345f..167c55317f7e2c2d9b08f12f1dea1a021fa46128 100644 (file)
@@ -130,6 +130,12 @@ status_t MetadataConverter::ToInternalShot(camera_metadata_t * request, struct c
                 break;
 
 
+            case ANDROID_SENSOR_TIMESTAMP:
+                if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_INT64, 1))
+                    break;
+                dst->dm.sensor.timeStamp = curr_entry.data.i64[0];
+                ALOGE("DEBUG(%s): ANDROID_SENSOR_TIMESTAMP (%lld)",  __FUNCTION__, dst->dm.sensor.timeStamp);
+                break;
 
 
             case ANDROID_FLASH_MODE: