From 308291dee65548eccf93232e60da7d8c32ad7f27 Mon Sep 17 00:00:00 2001 From: hyeonmyeong Choi Date: Wed, 29 Aug 2012 13:55:01 -0700 Subject: [PATCH] hardware: samsung_slsi: libcamera2: Bug fix for digital zoom This patch fixed bug for capture when digital zoom. Change-Id: I37184b3245752db998958cbe326bd487b0affe06 Signed-off-by: hyeonmyeong Choi --- libcamera2/ExynosCameraHWInterface2.cpp | 29 ++++++++++++++++++------- libcamera2/ExynosCameraHWInterface2.h | 1 + 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/libcamera2/ExynosCameraHWInterface2.cpp b/libcamera2/ExynosCameraHWInterface2.cpp index 905ce47..0e94cc2 100644 --- a/libcamera2/ExynosCameraHWInterface2.cpp +++ b/libcamera2/ExynosCameraHWInterface2.cpp @@ -838,6 +838,7 @@ ExynosCameraHWInterface2::ExynosCameraHWInterface2(int cameraId, camera2_device_ m_needsRecordBufferInit(false), m_needsPreviewCbBufferInit(false), lastFrameCnt(-1), + m_zoomRatio(1), m_scp_closing(false), m_scp_closed(false), m_afState(HAL_AFSTATE_INACTIVE), @@ -2645,7 +2646,7 @@ void ExynosCameraHWInterface2::m_sensorThreadFunc(SignalDrivenThread * self) OnAfTrigger(m_afPendingTriggerId); } } - float zoomRatio = m_camera2->getSensorW() / shot_ext->shot.ctl.scaler.cropRegion[2]; + m_zoomRatio = (float)m_camera2->getSensorW() / (float)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; @@ -2656,11 +2657,11 @@ void ExynosCameraHWInterface2::m_sensorThreadFunc(SignalDrivenThread * self) 0); if (m_streamThreads[0]->m_parameters.outputWidth >= m_streamThreads[0]->m_parameters.outputHeight) { - zoomWidth = m_camera2->getSensorW() / zoomRatio; + zoomWidth = m_camera2->getSensorW() / m_zoomRatio; zoomHeight = zoomWidth * m_streamThreads[0]->m_parameters.outputHeight / m_streamThreads[0]->m_parameters.outputWidth; } else { - zoomHeight = m_camera2->getSensorH() / zoomRatio; + zoomHeight = m_camera2->getSensorH() / m_zoomRatio; zoomWidth = zoomHeight * m_streamThreads[0]->m_parameters.outputWidth / m_streamThreads[0]->m_parameters.outputHeight; } @@ -2669,6 +2670,11 @@ void ExynosCameraHWInterface2::m_sensorThreadFunc(SignalDrivenThread * self) int32_t new_cropRegion[3] = { zoomLeft, zoomTop, zoomWidth }; + if (new_cropRegion[0] * 2 + new_cropRegion[2] > m_camera2->getSensorW()) + new_cropRegion[2]--; + else if (new_cropRegion[0] * 2 + new_cropRegion[2] < m_camera2->getSensorW()) + new_cropRegion[2]++; + 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]; @@ -3664,11 +3670,18 @@ void ExynosCameraHWInterface2::m_streamFunc1(SignalDrivenThread *self) pictureFramesize = FRAME_SIZE(V4L2_PIX_2_HAL_PIXEL_FORMAT(pictureFormat), pictureW, pictureH); if (m_exynosPictureCSC) { - m_getRatioSize(pictureW, pictureH, - m_orgPictureRect.w, m_orgPictureRect.h, - &cropX, &cropY, - &cropW, &cropH, - 0); + float zoom_w = 0, zoom_h = 0; + if (m_orgPictureRect.w >= m_orgPictureRect.h) { + zoom_w = pictureW / m_zoomRatio; + zoom_h = zoom_w * m_orgPictureRect.h / m_orgPictureRect.w; + } else { + zoom_h = pictureH / m_zoomRatio; + zoom_w = zoom_h * m_orgPictureRect.w / m_orgPictureRect.h; + } + cropX = (pictureW - zoom_w) / 2; + cropY = (pictureH - zoom_h) / 2; + cropW = zoom_w; + cropH = zoom_h; ALOGV("DEBUG(%s):cropX = %d, cropY = %d, cropW = %d, cropH = %d", __FUNCTION__, cropX, cropY, cropW, cropH); diff --git a/libcamera2/ExynosCameraHWInterface2.h b/libcamera2/ExynosCameraHWInterface2.h index 57c5ee9..5e579f4 100644 --- a/libcamera2/ExynosCameraHWInterface2.h +++ b/libcamera2/ExynosCameraHWInterface2.h @@ -608,6 +608,7 @@ class MainThread : public SignalDrivenThread { bool m_wideAspect; bool m_aspectChanged; uint32_t lastAfRegion[4]; + float m_zoomRatio; mutable Mutex m_qbufLock; -- 2.20.1