hardware: samsung_slsi: libcamera2: Fix Night scene mode
authorSungjoong Kang <sj3.kang@samsung.com>
Tue, 28 Aug 2012 19:55:39 +0000 (12:55 -0700)
committerRebecca Schultz Zavin <rebecca@android.com>
Wed, 29 Aug 2012 00:26:55 +0000 (17:26 -0700)
When using night scnee mode, separate parameter will be appiled
for preview/capture operation.

Change-Id: I2875baa0d404fd92cc6df98f7c174bf86adbd9db
Signed-off-by: Sungjoong Kang <sj3.kang@samsung.com>
libcamera2/ExynosCameraHWInterface2.cpp
libcamera2/ExynosCameraHWInterface2.h
libcamera2/MetadataConverter.cpp
libcamera2/fimc-is-metadata.h

index a0c08606c0dd275afb36aa5398f00f6ce5c91aee..1c8c282d4f6915a49448dbf3fbf387787d08081c 100644 (file)
@@ -835,6 +835,7 @@ ExynosCameraHWInterface2::ExynosCameraHWInterface2(int cameraId, camera2_device_
             m_afModeWaitingCnt(0),
             m_halDevice(dev),
             m_need_streamoff(0),
+            m_nightCaptureCnt(0),
             m_cameraId(cameraId)
 {
     ALOGV("DEBUG(%s):", __FUNCTION__);
@@ -2380,7 +2381,12 @@ void ExynosCameraHWInterface2::m_sensorThreadFunc(SignalDrivenThread * self)
 
         m_recordOutput = shot_ext->shot.ctl.request.outputStreams[2];
 
-        matchedFrameCnt = m_requestManager->FindFrameCnt(shot_ext);
+        if (m_nightCaptureCnt != 0) {
+            matchedFrameCnt = m_nightCaptureFrameCnt;
+        }
+        else {
+            matchedFrameCnt = m_requestManager->FindFrameCnt(shot_ext);
+        }
 
         if (matchedFrameCnt != -1) {
             frameTime = systemTime();
@@ -2432,12 +2438,12 @@ void ExynosCameraHWInterface2::m_sensorThreadFunc(SignalDrivenThread * self)
                 shot_ext->shot.ctl.aa.afTrigger = 0;
             }
             if (m_wideAspect) {
-                //shot_ext->setfile = ISS_SUB_SCENARIO_VIDEO;
+                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;
+                shot_ext->setfile = ISS_SUB_SCENARIO_STILL;
             }
             if (triggered)
                 shot_ext->shot.ctl.aa.afTrigger = 1;
@@ -2453,7 +2459,7 @@ void ExynosCameraHWInterface2::m_sensorThreadFunc(SignalDrivenThread * self)
                 shot_ext->request_scp,
                 shot_ext->request_scc,
                 shot_ext->dis_bypass, sizeof(camera2_shot));
-
+            ALOGV("### m_nightCaptureCnt (%d)", m_nightCaptureCnt);
             if (0 == shot_ext->shot.ctl.aa.afRegions[0] && 0 == shot_ext->shot.ctl.aa.afRegions[1]
                 && 0 == shot_ext->shot.ctl.aa.afRegions[2] && 0 == shot_ext->shot.ctl.aa.afRegions[3]) {
                 ALOGV("(%s): AF region resetting", __FUNCTION__);
@@ -2475,6 +2481,31 @@ void ExynosCameraHWInterface2::m_sensorThreadFunc(SignalDrivenThread * self)
                     lastAfRegion[3] = shot_ext->shot.ctl.aa.afRegions[3];
                 }
             }
+            if (m_nightCaptureCnt == 0) {
+                if (shot_ext->shot.ctl.aa.captureIntent == ANDROID_CONTROL_INTENT_STILL_CAPTURE
+                        && shot_ext->shot.ctl.aa.sceneMode == AA_SCENE_MODE_NIGHT) {
+                    shot_ext->shot.ctl.aa.sceneMode = AA_SCENE_MODE_NIGHT_CAPTURE;
+                    shot_ext->shot.ctl.aa.aeTargetFpsRange[0] = 2;
+                    shot_ext->shot.ctl.aa.aeTargetFpsRange[1] = 30;
+                    m_nightCaptureCnt = 4;
+                    m_nightCaptureFrameCnt = matchedFrameCnt;
+                    shot_ext->request_scc = 0;
+                }
+            }
+            else if (m_nightCaptureCnt == 1) {
+                shot_ext->shot.ctl.aa.sceneMode = AA_SCENE_MODE_NIGHT_CAPTURE;
+                    shot_ext->shot.ctl.aa.aeTargetFpsRange[0] = 2;
+                    shot_ext->shot.ctl.aa.aeTargetFpsRange[1] = 30;
+                m_nightCaptureCnt--;
+                shot_ext->request_scc = 1;
+            }
+            else if (m_nightCaptureCnt == 2 || m_nightCaptureCnt == 3 || m_nightCaptureCnt == 4) {
+                shot_ext->shot.ctl.aa.sceneMode = AA_SCENE_MODE_NIGHT_CAPTURE;
+                    shot_ext->shot.ctl.aa.aeTargetFpsRange[0] = 2;
+                    shot_ext->shot.ctl.aa.aeTargetFpsRange[1] = 30;
+                m_nightCaptureCnt--;
+                shot_ext->request_scc = 0;
+            }
             ALOGV("(%s): queued  aa(%d) aemode(%d) awb(%d) afmode(%d) trigger(%d)", __FUNCTION__,
             (int)(shot_ext->shot.ctl.aa.mode), (int)(shot_ext->shot.ctl.aa.aeMode),
             (int)(shot_ext->shot.ctl.aa.awbMode), (int)(shot_ext->shot.ctl.aa.afMode),
@@ -2505,8 +2536,14 @@ void ExynosCameraHWInterface2::m_sensorThreadFunc(SignalDrivenThread * self)
                 m_previewOutput = 1;
                 m_streamThreads[0]->SetSignal(SIGNAL_STREAM_DATA_COMING);
             }
-
             if (shot_ext->request_scc) {
+                 ALOGV("### m_nightCaptureCnt (%d) request_scc true", m_nightCaptureCnt);
+                memcpy(&m_jpegMetadata, &shot_ext->shot, sizeof(struct camera2_shot));
+                int shutterSpeed = (m_jpegMetadata.dm.sensor.exposureTime/1000);
+
+                if (shutterSpeed < 0) {
+                    shutterSpeed = 100;
+                }
                 m_streamThreads[1]->SetSignal(SIGNAL_STREAM_DATA_COMING);
             }
 
@@ -2540,8 +2577,9 @@ void ExynosCameraHWInterface2::m_sensorThreadFunc(SignalDrivenThread * self)
                                                                                                 / m_streamThreads[0].get()->m_parameters.outputHeight;
                 }
             }
-
-            m_requestManager->ApplyDynamicMetadata(shot_ext);
+            if (m_nightCaptureCnt == 0) {
+                m_requestManager->ApplyDynamicMetadata(shot_ext);
+            }
             OnAfNotification(shot_ext->shot.dm.aa.afState);
         }
 
index 9289cff547a42dcba6f29210912a8cd7791168cb..ca76f1dcbcfd4b057889fcd3ce1f60b7eb3fdd3a 100644 (file)
@@ -560,6 +560,8 @@ class MainThread : public SignalDrivenThread {
     int                                 m_afPendingTriggerId;
     int                                 m_afModeWaitingCnt;
     struct camera2_shot                 m_jpegMetadata;
+    int                                 m_nightCaptureCnt;
+    int                                 m_nightCaptureFrameCnt;
 };
 
 }; // namespace android
index bc069aa4724b9ed7cf70dc5775cedebcb4544a91..3976a266320283e8b15f8c12ec9499ae19400d3a 100644 (file)
@@ -392,12 +392,11 @@ status_t MetadataConverter::ApplySceneModeParameters(camera_metadata_t * request
 
     case AA_SCENE_MODE_NIGHT:
         dst->ctl.aa.mode = AA_CONTROL_USE_SCENE_MODE;
-        if (dst->ctl.aa.aeMode != AA_AEMODE_LOCKED)
-            dst->ctl.aa.aeMode = AA_AEMODE_ON;
+        dst->ctl.aa.aeMode = AA_AEMODE_ON; // AE_LOCK is prohibited
         dst->ctl.aa.awbMode = AA_AWBMODE_WB_AUTO;
         dst->ctl.aa.isoMode = AA_ISOMODE_AUTO;
         dst->ctl.aa.isoValue = 0;
-        dst->ctl.aa.aeTargetFpsRange[0] = 2;
+        dst->ctl.aa.aeTargetFpsRange[0] = 8;
         dst->ctl.aa.aeTargetFpsRange[1] = 30;
 
         dst->ctl.noise.mode = PROCESSING_MODE_FAST;
index 779ce3ff64fb63d0419d57c607b6a8194dd081be..95771c59b77a3511b239e5049633a6041a219dfc 100644 (file)
@@ -503,7 +503,8 @@ enum aa_scene_mode {
        AA_SCENE_MODE_SPORTS,
        AA_SCENE_MODE_PARTY,
        AA_SCENE_MODE_CANDLELIGHT,
-       AA_SCENE_MODE_BARCODE
+       AA_SCENE_MODE_BARCODE,
+       AA_SCENE_MODE_NIGHT_CAPTURE  /* part of night mode */
 };
 
 enum aa_effect_mode {