hardware: samsung_slsi: libcamera2: Bug fixes and stability enhancements
authorSungjoong Kang <sj3.kang@samsung.com>
Sat, 1 Sep 2012 04:31:34 +0000 (21:31 -0700)
committerRebecca Schultz Zavin <rebecca@android.com>
Wed, 5 Sep 2012 21:59:16 +0000 (14:59 -0700)
1. Optimize preview buffer size and dequeue count
2. Fix crash when Stillshot/Record mode change
3. 30 FPS fix for video recording

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

index dcf937e0ca70a2061da00664c4e1fcd0466fec16..b557603633f82e4d29a83919c22e1ba605088417 100644 (file)
@@ -432,7 +432,7 @@ status_t ExynosCamera2::constructStaticInfo(camera_metadata_t **info,
             availableFaceDetectModes,
             sizeof(availableFaceDetectModes));
 
-    m_curCameraInfo->maxFaceCount = 16;
+    m_curCameraInfo->maxFaceCount = 3;
     ADD_OR_SIZE(ANDROID_STATS_MAX_FACE_COUNT,
             &(m_curCameraInfo->maxFaceCount), 1);
 
index b2b9a01e9ca94695d8f82cd03d5e31cb4002ad04..905ce47fea69cd0b4f07b8393b80ef70c3fdbcad 100644 (file)
@@ -847,6 +847,9 @@ ExynosCameraHWInterface2::ExynosCameraHWInterface2(int cameraId, camera2_device_
             m_IsAfTriggerRequired(false),
             m_IsAfLockRequired(false),
             m_wideAspect(false),
+            m_aspectChanged(false),
+            m_scpOutputSignalCnt(0),
+            m_scpOutputImageCnt(0),
             m_afTriggerId(0),
             m_afPendingTriggerId(0),
             m_afModeWaitingCnt(0),
@@ -1381,6 +1384,7 @@ int ExynosCameraHWInterface2::allocateStream(uint32_t width, uint32_t height, in
         else {
             m_wideAspect = false;
         }
+        m_aspectChanged = true;
         ALOGV("DEBUG(%s): m_wideAspect (%d)", __FUNCTION__, m_wideAspect);
 
         if (allocCase == 0 || allocCase == 2) {
@@ -1397,7 +1401,7 @@ int ExynosCameraHWInterface2::allocateStream(uint32_t width, uint32_t height, in
 
             *format_actual = HAL_PIXEL_FORMAT_EXYNOS_YV12;
             *usage = GRALLOC_USAGE_SW_WRITE_OFTEN;
-            *max_buffers = 8;
+            *max_buffers = 6;
 
             newParameters.streamType    = STREAM_TYPE_DIRECT;
             newParameters.outputWidth   = width;
@@ -1602,7 +1606,6 @@ int ExynosCameraHWInterface2::registerStreamBuffers(uint32_t stream_id,
         }
     }
     else if (stream_id == 2) {
-        m_need_streamoff = 0;
         targetRecordParms = &(m_streamThreads[0]->m_recordParameters);
 
         targetRecordParms->numSvcBuffers = num_buffers;
@@ -2729,13 +2732,20 @@ void ExynosCameraHWInterface2::m_sensorThreadFunc(SignalDrivenThread * self)
             else {
                 shot_ext->shot.ctl.aa.afTrigger = 0;
             }
-            if (m_wideAspect) {
-                shot_ext->setfile = ISS_SUB_SCENARIO_VIDEO;
-                shot_ext->shot.ctl.aa.aeTargetFpsRange[0] = 30;
+            if (m_aspectChanged) {
+                shot_ext->shot.ctl.aa.aeTargetFpsRange[0] = 15;
                 shot_ext->shot.ctl.aa.aeTargetFpsRange[1] = 30;
+                m_aspectChanged = false;
             }
             else {
-                shot_ext->setfile = ISS_SUB_SCENARIO_STILL;
+                if (m_wideAspect) {
+                    shot_ext->setfile = ISS_SUB_SCENARIO_VIDEO;
+                    shot_ext->shot.ctl.aa.aeTargetFpsRange[0] = 30;
+                    shot_ext->shot.ctl.aa.aeTargetFpsRange[1] = 30;
+                }
+                else {
+                    shot_ext->setfile = ISS_SUB_SCENARIO_STILL;
+                }
             }
             if (triggered)
                 shot_ext->shot.ctl.aa.afTrigger = 1;
@@ -2844,6 +2854,7 @@ void ExynosCameraHWInterface2::m_sensorThreadFunc(SignalDrivenThread * self)
             m_previewOutput = 0;
             if (shot_ext->request_scp) {
                 m_previewOutput = 1;
+                m_scpOutputSignalCnt++;
                 m_streamThreads[0]->SetSignal(SIGNAL_STREAM_DATA_COMING);
             }
             if (shot_ext->request_scc) {
@@ -3148,6 +3159,53 @@ void ExynosCameraHWInterface2::m_streamFunc0(SignalDrivenThread *self)
         ALOGV("DEBUG(%s): processing SIGNAL_STREAM_CHANGE_PARAMETER DONE", __FUNCTION__);
     }
 
+    if (currentSignal & SIGNAL_THREAD_RELEASE) {
+        int i, index = -1, cnt_to_dq = 0;
+        status_t res;
+        ALOGV("DEBUG(%s): processing SIGNAL_THREAD_RELEASE", __FUNCTION__);
+        ALOGD("(%s):(%d) SIGNAL_THREAD_RELEASE", __FUNCTION__, selfStreamParms->streamType);
+
+        if (selfThread->m_isBufferInit) {
+            for ( i=0 ; i < selfStreamParms->numSvcBuffers; i++) {
+                ALOGV("DEBUG(%s): checking buffer index[%d] - status(%d)",
+                    __FUNCTION__, i, selfStreamParms->svcBufStatus[i]);
+                if (selfStreamParms->svcBufStatus[i] ==ON_DRIVER) cnt_to_dq++;
+            }
+
+            ALOGV("DEBUG(%s): calling stream(%d) streamoff (fd:%d)", __FUNCTION__,
+            selfThread->m_index, selfStreamParms->fd);
+            if (cam_int_streamoff(&(selfStreamParms->node)) < 0 ){
+                ALOGE("ERR(%s): stream off fail", __FUNCTION__);
+            } else {
+                    m_scp_closing = true;
+            }
+            ALOGV("DEBUG(%s): calling stream(%d) streamoff done", __FUNCTION__, selfThread->m_index);
+            ALOGV("DEBUG(%s): calling stream(%d) reqbuf 0 (fd:%d)", __FUNCTION__,
+                    selfThread->m_index, selfStreamParms->fd);
+            currentNode->buffers = 0;
+            cam_int_reqbufs(currentNode);
+            ALOGV("DEBUG(%s): calling stream(%d) reqbuf 0 DONE(fd:%d)", __FUNCTION__,
+                    selfThread->m_index, selfStreamParms->fd);
+        }
+#ifdef ENABLE_FRAME_SYNC
+        // free metabuffers
+        for(i = 0; i < NUM_MAX_CAMERA_BUFFERS; i++)
+            if(selfStreamParms->metaBuffers[i].fd.extFd[0] != 0){
+                freeCameraMemory(&(selfStreamParms->metaBuffers[i]), 1);
+                selfStreamParms->metaBuffers[i].fd.extFd[0] = 0;
+                selfStreamParms->metaBuffers[i].size.extS[0] = 0;
+            }
+#endif
+        selfThread->m_isBufferInit = false;
+        selfThread->m_index = 255;
+
+        selfThread->m_releasing = false;
+
+        ALOGV("DEBUG(%s): processing SIGNAL_THREAD_RELEASE DONE", __FUNCTION__);
+
+        return;
+    }
+
     if (currentSignal & SIGNAL_STREAM_DATA_COMING) {
         buffer_handle_t * buf = NULL;
         status_t res;
@@ -3173,8 +3231,9 @@ void ExynosCameraHWInterface2::m_streamFunc0(SignalDrivenThread *self)
 #else
             index = cam_int_dqbuf(&(selfStreamParms->node));
 #endif
-            ALOGV("DEBUG(%s): stream(%d) type(%d) DQBUF done index(%d)",__FUNCTION__,
-                selfThread->m_index, selfStreamParms->streamType, index);
+            m_scpOutputImageCnt++;
+            ALOGV("DEBUG(%s): stream(%d) DQBUF done index(%d)  sigcnt(%d) imgcnt(%d)",__FUNCTION__,
+                selfThread->m_index, index, m_scpOutputSignalCnt, m_scpOutputImageCnt);
 
             if (selfStreamParms->svcBufStatus[index] !=  ON_DRIVER)
                 ALOGV("DBG(%s): DQed buffer status abnormal (%d) ",
@@ -3453,7 +3512,7 @@ void ExynosCameraHWInterface2::m_streamFunc0(SignalDrivenThread *self)
             } while (0);
         }
 
-        while (selfStreamParms->numSvcBufsInHal < selfStreamParms->numOwnSvcBuffers) {
+        while (selfStreamParms->numSvcBufsInHal < selfStreamParms->numOwnSvcBuffers - 1) {
             res = selfStreamParms->streamOps->dequeue_buffer(selfStreamParms->streamOps, &buf);
             if (res != NO_ERROR || buf == NULL) {
                 ALOGV("DEBUG(%s): stream(%d) dequeue_buffer fail res(%d)",__FUNCTION__ , selfThread->m_index,  res);
@@ -3518,55 +3577,6 @@ void ExynosCameraHWInterface2::m_streamFunc0(SignalDrivenThread *self)
         ALOGV("DEBUG(%s): stream(%d) processing SIGNAL_STREAM_DATA_COMING DONE",
             __FUNCTION__,selfThread->m_index);
     }
-
-
-    if (currentSignal & SIGNAL_THREAD_RELEASE) {
-        int i, index = -1, cnt_to_dq = 0;
-        status_t res;
-        ALOGV("DEBUG(%s): processing SIGNAL_THREAD_RELEASE", __FUNCTION__);
-        ALOGD("(%s):(%d) SIGNAL_THREAD_RELEASE", __FUNCTION__, selfStreamParms->streamType);
-
-        if (selfThread->m_isBufferInit) {
-            for ( i=0 ; i < selfStreamParms->numSvcBuffers; i++) {
-                ALOGV("DEBUG(%s): checking buffer index[%d] - status(%d)",
-                    __FUNCTION__, i, selfStreamParms->svcBufStatus[i]);
-                if (selfStreamParms->svcBufStatus[i] ==ON_DRIVER) cnt_to_dq++;
-            }
-
-            ALOGV("DEBUG(%s): calling stream(%d) streamoff (fd:%d)", __FUNCTION__,
-            selfThread->m_index, selfStreamParms->fd);
-            if (cam_int_streamoff(&(selfStreamParms->node)) < 0 ){
-                ALOGE("ERR(%s): stream off fail", __FUNCTION__);
-            } else {
-                    m_scp_closing = true;
-            }
-            ALOGV("DEBUG(%s): calling stream(%d) streamoff done", __FUNCTION__, selfThread->m_index);
-            ALOGV("DEBUG(%s): calling stream(%d) reqbuf 0 (fd:%d)", __FUNCTION__,
-                    selfThread->m_index, selfStreamParms->fd);
-            currentNode->buffers = 0;
-            cam_int_reqbufs(currentNode);
-            ALOGV("DEBUG(%s): calling stream(%d) reqbuf 0 DONE(fd:%d)", __FUNCTION__,
-                    selfThread->m_index, selfStreamParms->fd);
-        }
-#ifdef ENABLE_FRAME_SYNC
-        // free metabuffers
-        for(i = 0; i < NUM_MAX_CAMERA_BUFFERS; i++)
-            if(selfStreamParms->metaBuffers[i].fd.extFd[0] != 0){
-                freeCameraMemory(&(selfStreamParms->metaBuffers[i]), 1);
-                selfStreamParms->metaBuffers[i].fd.extFd[0] = 0;
-                selfStreamParms->metaBuffers[i].size.extS[0] = 0;
-            }
-#endif
-        selfThread->m_isBufferInit = false;
-        selfThread->m_index = 255;
-
-        selfThread->m_releasing = false;
-
-        ALOGV("DEBUG(%s): processing SIGNAL_THREAD_RELEASE DONE", __FUNCTION__);
-
-        return;
-    }
-
     return;
 }
 
index 85d3bb8913f023645b36ce40088688e89532fb6f..57c5ee907badee6c523c4270f13d051c27903b13 100644 (file)
@@ -606,6 +606,7 @@ class MainThread : public SignalDrivenThread {
     bool                                m_scp_closing;
     bool                                m_scp_closed;
     bool                                m_wideAspect;
+    bool                                m_aspectChanged;
     uint32_t                            lastAfRegion[4];
 
     mutable Mutex    m_qbufLock;
@@ -622,6 +623,8 @@ class MainThread : public SignalDrivenThread {
     int                                 m_afPendingTriggerId;
     int                                 m_afModeWaitingCnt;
     struct camera2_shot                 m_jpegMetadata;
+    int                                 m_scpOutputSignalCnt;
+    int                                 m_scpOutputImageCnt;
     int                                 m_nightCaptureCnt;
     int                                 m_nightCaptureFrameCnt;
     int                                 m_thumbNailW;
index f314fe4d417d36813172e92ccb4a99feb1f8bdf8..015faaa4785567e56eb451e3b0bcbc80d2e85511 100644 (file)
@@ -496,7 +496,7 @@ status_t MetadataConverter::ToDynamicMetadata(struct camera2_shot_ext * metadata
                 &byteData, 1))
         return NO_MEMORY;
 
-    int maxFacecount = 16;
+    int maxFacecount = 3;
     if (0 != add_camera_metadata_entry(dst, ANDROID_STATS_MAX_FACE_COUNT,
                 &maxFacecount, 1))
         return NO_MEMORY;