hardware: samsung_slsi: libcamera2: Enable 4x digital zoom
authorSungjoong Kang <sj3.kang@samsung.com>
Tue, 28 Aug 2012 22:02:19 +0000 (15:02 -0700)
committerRebecca Schultz Zavin <rebecca@android.com>
Wed, 29 Aug 2012 00:26:55 +0000 (17:26 -0700)
Enables 4x digital zoom function
Requires matching version of driver

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

index 6e10ab6c7df9c102ef1f1c5ef7d4304d42dd3f10..554dfef613287c664110d731cc250ad4d18da2ba 100644 (file)
@@ -117,6 +117,7 @@ const int32_t scalerResolutionS5K4E5[] =
 {
     1920, 1080,
     1440, 1080,
+    1280, 1024,
     1280,  720,
      640,  480,
      320,  240,
@@ -126,6 +127,7 @@ const int32_t scalerResolutionS5K4E5[] =
 const int32_t jpegResolutionS5K4E5[] =
 {
     2560, 1920,
+    2560, 1440,
     2048, 1536,
     1600, 1200,
     1280, 1024,
@@ -156,6 +158,8 @@ ExynosCamera2InfoS5K4E5::~ExynosCamera2InfoS5K4E5()
 }
 const int32_t scalerResolutionS5K6A3[] =
 {
+    1392, 1392,
+    1280, 1024,
     1280,  960,
     1280,  720,
      640,  480,
@@ -169,6 +173,7 @@ const int32_t jpegResolutionS5K6A3[] =
     1392,  784,
     1280, 1024,
     1280,  960,
+    1280,  720,
     1152,  864,
      640,  480,
      320,  240,
@@ -399,7 +404,7 @@ status_t ExynosCamera2::constructStaticInfo(camera_metadata_t **info,
             kAvailableJpegMinDurations,
             sizeof(kAvailableJpegMinDurations)/sizeof(uint64_t));
 
-    static const float maxZoom = 1;
+    static const float maxZoom = 4;
     ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_MAX_ZOOM, &maxZoom, 1);
 
     // android.jpeg
index 8a5c963fd5d72522ce1b17166d309887832c466c..a26a3a61ecef11dd96b714e886b49882934e6ab1 100644 (file)
@@ -510,9 +510,10 @@ int RequestManager::MarkProcessingRequest(ExynosBuffer* buf, int *afMode)
     shot_ext->shot.ctl.sensor.frameDuration = 33*1000*1000;
     shot_ext->shot.ctl.sensor.sensitivity = 0;
 
-    shot_ext->shot.ctl.scaler.cropRegion[0] = 0;
-    shot_ext->shot.ctl.scaler.cropRegion[1] = 0;
-    shot_ext->shot.ctl.scaler.cropRegion[2] = m_cropX;
+
+    shot_ext->shot.ctl.scaler.cropRegion[0] = newEntry->internal_shot.shot.ctl.scaler.cropRegion[0];
+    shot_ext->shot.ctl.scaler.cropRegion[1] = newEntry->internal_shot.shot.ctl.scaler.cropRegion[1];
+    shot_ext->shot.ctl.scaler.cropRegion[2] = newEntry->internal_shot.shot.ctl.scaler.cropRegion[2];
 
     m_entryProcessingIndex = newProcessingIndex;
     return newProcessingIndex;
@@ -635,6 +636,10 @@ void    RequestManager::UpdateIspParameters(struct camera2_shot_ext *shot_ext, i
     shot_ext->shot.ctl.request.outputStreams[1] = 0;
     shot_ext->shot.ctl.request.outputStreams[2] = 0;
 
+    shot_ext->shot.ctl.scaler.cropRegion[0] = request_shot->shot.ctl.scaler.cropRegion[0];
+    shot_ext->shot.ctl.scaler.cropRegion[1] = request_shot->shot.ctl.scaler.cropRegion[1];
+    shot_ext->shot.ctl.scaler.cropRegion[2] = request_shot->shot.ctl.scaler.cropRegion[2];
+
     if (m_lastAaMode == request_shot->shot.ctl.aa.mode) {
         shot_ext->shot.ctl.aa.mode = (enum aa_mode)(0);
     }
@@ -2400,6 +2405,33 @@ void ExynosCameraHWInterface2::m_sensorThreadFunc(SignalDrivenThread * self)
                     OnAfTrigger(m_afPendingTriggerId);
                 }
             }
+            float zoomRatio = m_camera2->getSensorW() / shot_ext->shot.ctl.scaler.cropRegion[2];
+            float zoomLeft, zoomTop, zoomWidth, zoomHeight;
+            int crop_x = 0, crop_y = 0, crop_w = 0, crop_h = 0;
+
+            m_getRatioSize(m_camera2->getSensorW(), m_camera2->getSensorH(),
+                           m_streamThreads[0]->m_parameters.outputWidth, m_streamThreads[0]->m_parameters.outputHeight,
+                           &crop_x, &crop_y,
+                           &crop_w, &crop_h,
+                           0);
+
+            if (m_streamThreads[0]->m_parameters.outputWidth >= m_streamThreads[0]->m_parameters.outputHeight) {
+                zoomWidth =  m_camera2->getSensorW() / zoomRatio;
+                zoomHeight = zoomWidth *
+                        m_streamThreads[0]->m_parameters.outputHeight / m_streamThreads[0]->m_parameters.outputWidth;
+            } else {
+                zoomHeight = m_camera2->getSensorH() / zoomRatio;
+                zoomWidth = zoomHeight *
+                        m_streamThreads[0]->m_parameters.outputWidth / m_streamThreads[0]->m_parameters.outputHeight;
+            }
+            zoomLeft = (crop_w - zoomWidth) / 2;
+            zoomTop = (crop_h - zoomHeight) / 2;
+
+            int32_t new_cropRegion[3] = { zoomLeft, zoomTop, zoomWidth };
+
+            shot_ext->shot.ctl.scaler.cropRegion[0] = new_cropRegion[0];
+            shot_ext->shot.ctl.scaler.cropRegion[1] = new_cropRegion[1];
+            shot_ext->shot.ctl.scaler.cropRegion[2] = new_cropRegion[2];
             if (m_IsAfModeUpdateRequired) {
                 ALOGE("### AF Mode change(Mode %d) ", m_afMode);
                 shot_ext->shot.ctl.aa.afMode = m_afMode;
@@ -3132,8 +3164,11 @@ void ExynosCameraHWInterface2::m_streamFunc1(SignalDrivenThread *self)
 
             ExynosBuffer* m_pictureBuf = &(m_camera_info.capture.buffer[index]);
 
-            pictureW = selfStreamParms->nodeWidth;
-            pictureH = selfStreamParms->nodeHeight;
+            m_getRatioSize(selfStreamParms->nodeWidth, selfStreamParms->nodeHeight,
+                           m_orgPictureRect.w, m_orgPictureRect.h,
+                           &cropX, &cropY,
+                           &pictureW, &pictureH,
+                           0);
             pictureFormat = V4L2_PIX_FMT_YUYV;
             pictureFramesize = FRAME_SIZE(V4L2_PIX_2_HAL_PIXEL_FORMAT(pictureFormat), pictureW, pictureH);
 
index 3976a266320283e8b15f8c12ec9499ae19400d3a..f314fe4d417d36813172e92ccb4a99feb1f8bdf8 100644 (file)
@@ -32,6 +32,7 @@
 #include <utils/Log.h>
 
 #include "MetadataConverter.h"
+#include "exynos_format.h"
 
 namespace android {
 
@@ -151,6 +152,12 @@ status_t MetadataConverter::ToInternalShot(camera_metadata_t * request, struct c
 
 
 
+            case ANDROID_SCALER_CROP_REGION:
+                if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_INT32, 3))
+                    break;
+                for (i=0 ; i<curr_entry.count ; i++)
+                    dst->ctl.scaler.cropRegion[i] = ALIGN(curr_entry.data.i32[i], 2);
+                break;
 
 
             case ANDROID_JPEG_QUALITY: