summaryrefslogtreecommitdiff
authorjiyu.yang <jiyu.yang@amlogic.com>2013-11-26 08:45:29 (GMT)
committer Sandy lUo <sandy.luo@amlogic.com>2013-11-27 05:53:49 (GMT)
commit610b2b1e5435da81f0201fa3f4ecd159f77de8e9 (patch)
tree38645442ca28b87f417bfd3e60732e8cc3d47146
parentf1ac2f5ec4260b69adaf087eb3ab11a8f9b7a720 (diff)
downloadcamera-610b2b1e5435da81f0201fa3f4ecd159f77de8e9.zip
camera-610b2b1e5435da81f0201fa3f4ecd159f77de8e9.tar.gz
camera-610b2b1e5435da81f0201fa3f4ecd159f77de8e9.tar.bz2
vidioc_s_crop added for capture
Diffstat
-rwxr-xr-xV4LCameraAdapter/V4LCameraAdapter.cpp32
-rwxr-xr-xinc/V4LCameraAdapter/V4LCameraAdapter.h1
2 files changed, 28 insertions, 5 deletions
diff --git a/V4LCameraAdapter/V4LCameraAdapter.cpp b/V4LCameraAdapter/V4LCameraAdapter.cpp
index 2e27dcc..6ccefe2 100755
--- a/V4LCameraAdapter/V4LCameraAdapter.cpp
+++ b/V4LCameraAdapter/V4LCameraAdapter.cpp
@@ -717,6 +717,24 @@ status_t V4LCameraAdapter::getBuffersFormat(int &width, int &height, int &pixelf
return ret;
}
+status_t V4LCameraAdapter::setCrop(int width, int height)
+{
+ int ret = NO_ERROR;
+ struct v4l2_crop crop;
+
+ memset (&crop, 0, sizeof(crop));
+ crop.c.width = width;
+ crop.c.height = height;
+ ret = ioctl(mCameraHandle, VIDIOC_S_CROP, &crop);
+ if (ret < 0) {
+ CAMHAL_LOGEB("VIDIOC_S_CROP Failed: %s, ret=%d\n", strerror(errno), ret);
+ }
+
+ CAMHAL_LOGIB("crop w=%d, h=%d\n", width, height);
+
+ return ret;
+}
+
status_t V4LCameraAdapter::UseBuffersPreview(void* bufArr, int num)
{
int ret = NO_ERROR;
@@ -833,11 +851,6 @@ status_t V4LCameraAdapter::UseBuffersCapture(void* bufArr, int num)
CAMHAL_LOGDB("num=%d\n", num);
}
- /* This will only be called right before taking a picture, so
- * stop preview now so that we can set buffer format here.
- */
- this->stopPreview();
-
int width, height;
mParams.getPictureSize(&width, &height);
mCaptureWidth = width;
@@ -858,6 +871,14 @@ status_t V4LCameraAdapter::UseBuffersCapture(void* bufArr, int num)
}
mSensorFormat = DEFAULT_IMAGE_CAPTURE_PIXEL_FORMAT;
#endif
+
+ setCrop( mCaptureWidth, mCaptureHeight);
+ /* This will only be called right before taking a picture, so
+ * stop preview now so that we can set buffer format here.
+ */
+ this->stopPreview();
+
+
setBuffersFormat(width, height, mSensorFormat);
//First allocate adapter internal buffers at V4L level for Cam
@@ -1942,6 +1963,7 @@ int V4LCameraAdapter::pictureThread()
}
#endif
+ setCrop( 0, 0); //set to zero and then go preview
// start preview thread again after stopping it in UseBuffersCapture
{
Mutex::Autolock lock(mPreviewBufferLock);
diff --git a/inc/V4LCameraAdapter/V4LCameraAdapter.h b/inc/V4LCameraAdapter/V4LCameraAdapter.h
index ac36e9b..f961a21 100755
--- a/inc/V4LCameraAdapter/V4LCameraAdapter.h
+++ b/inc/V4LCameraAdapter/V4LCameraAdapter.h
@@ -328,6 +328,7 @@ private:
};
status_t setBuffersFormat(int width, int height, int pixelformat);
+ status_t setCrop(int width, int height);
status_t getBuffersFormat(int &width, int &height, int &pixelformat);
//Used for calculation of the average frame rate during preview