summaryrefslogtreecommitdiff
authorjiyu.yang <jiyu.yang@amlogic.com>2012-10-25 02:57:00 (GMT)
committer jiyu.yang <jiyu.yang@amlogic.com>2012-10-25 02:57:00 (GMT)
commitdfb21ee31f975eb20f0fba6998afcc49c6e86d89 (patch)
tree9ef6a2f038ac7fd7378e1c6750d728af115f20ac
parent7d04b2f3cac801987ddfaba6d960866f92f29200 (diff)
downloadcamera-dfb21ee31f975eb20f0fba6998afcc49c6e86d89.zip
camera-dfb21ee31f975eb20f0fba6998afcc49c6e86d89.tar.gz
camera-dfb21ee31f975eb20f0fba6998afcc49c6e86d89.tar.bz2
fix cheap copy USB cam start_frame wrong, banding off
Diffstat
-rwxr-xr-xV4LCameraAdapter/V4LCameraAdapter.cpp51
1 files changed, 48 insertions, 3 deletions
diff --git a/V4LCameraAdapter/V4LCameraAdapter.cpp b/V4LCameraAdapter/V4LCameraAdapter.cpp
index 2938535..4840ac6 100755
--- a/V4LCameraAdapter/V4LCameraAdapter.cpp
+++ b/V4LCameraAdapter/V4LCameraAdapter.cpp
@@ -450,7 +450,7 @@ status_t V4LCameraAdapter::fillThisBuffer(void* frameBuf, CameraFrame::FrameType
#endif
ret = ioctl(mCameraHandle, VIDIOC_QBUF, &hbuf_query);
if (ret < 0) {
- CAMHAL_LOGEB("Init: VIDIOC_QBUF %d Failed",i);
+ CAMHAL_LOGEB("Init: VIDIOC_QBUF %d Failed, errno=%d\n",i, errno);
return -1;
}
//CAMHAL_LOGEB("fillThis Buffer %d",i);
@@ -1473,6 +1473,14 @@ int V4LCameraAdapter::previewThread()
CAMHAL_LOGEA("Preview thread mPreviewBufs error!");
return BAD_VALUE;
}
+#ifdef AMLOGIC_USB_CAMERA_SUPPORT
+ if(mVideoInfo->buf.length != mVideoInfo->buf.bytesused){
+ fillThisBuffer( ptr, CameraFrame::PREVIEW_FRAME_SYNC);
+ CAMHAL_LOGDB("length=%d bytesused=%d index=%d\n",
+ mVideoInfo->buf.length, mVideoInfo->buf.bytesused, index);
+ return 0;
+ }
+#endif
#ifdef AMLOGIC_CAMERA_NONBLOCK_SUPPORT
gettimeofday( &previewTime2, NULL);
@@ -1723,6 +1731,7 @@ int V4LCameraAdapter::pictureThread()
status_t ret = NO_ERROR;
int width, height;
CameraFrame frame;
+ int dqTryNum = 3;
#ifndef AMLOGIC_USB_CAMERA_SUPPORT
setMirrorEffect();
@@ -1750,6 +1759,7 @@ int V4LCameraAdapter::pictureThread()
CAMHAL_LOGEA("VIDIOC_QBUF Failed");
return -EINVAL;
}
+ nQueued ++;
#ifndef AMLOGIC_USB_CAMERA_SUPPORT
if(mIoctlSupport & IOCTL_MASK_ROTATE){
@@ -1771,9 +1781,37 @@ int V4LCameraAdapter::pictureThread()
mVideoInfo->isStreaming = true;
}
- nQueued ++;
int index = 0;
char *fp = this->GetFrame(index);
+#ifdef AMLOGIC_USB_CAMERA_SUPPORT
+ while((mVideoInfo->buf.length != mVideoInfo->buf.bytesused)&&(dqTryNum>0)){
+ if(NULL != fp){
+ mVideoInfo->buf.index = 0;
+ mVideoInfo->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ mVideoInfo->buf.memory = V4L2_MEMORY_MMAP;
+
+
+ if(mIsDequeuedEIOError){
+ CAMHAL_LOGEA("DQBUF EIO has occured!\n");
+ break;
+ }
+
+ ret = ioctl(mCameraHandle, VIDIOC_QBUF, &mVideoInfo->buf);
+ if (ret < 0)
+ {
+ CAMHAL_LOGEB("VIDIOC_QBUF Failed errno=%d\n", errno);
+ break;
+ }
+ nQueued ++;
+ dqTryNum --;
+ }
+
+#ifdef AMLOGIC_CAMERA_NONBLOCK_SUPPORT
+ usleep( 10000 );
+#endif
+ fp = this->GetFrame(index);
+ }
+#endif
#ifdef AMLOGIC_CAMERA_NONBLOCK_SUPPORT
while(!fp && (-1 == index) ){
@@ -1783,6 +1821,7 @@ int V4LCameraAdapter::pictureThread()
#else
if(!fp)
{
+ CAMHAL_LOGDA("GetFrame fail, this may stop preview\n");
return 0; //BAD_VALUE;
}
#endif
@@ -2256,8 +2295,14 @@ static bool getCameraBanding(int camera_fd, char* banding_modes, char*def_bandin
char *tmp =NULL;
tmp = strstr( banding_modes, "auto");
if(tmp){
+ item_count ++;
strcat( tmpbuf, "auto,");
}
+ tmp = strstr( banding_modes, "isable");//Disabled
+ if(tmp){
+ item_count ++;
+ strcat( tmpbuf, "off,");
+ }
tmp = strstr( banding_modes, "50");
if(tmp){
item_count ++;
@@ -2275,7 +2320,7 @@ static bool getCameraBanding(int camera_fd, char* banding_modes, char*def_bandin
strcat(tmpbuf, "50hz");
}else if( NULL != (tmp = strstr(def_banding_mode, "60")) ){
strcat(tmpbuf, "60hz");
- }else if( NULL != (tmp = strstr(def_banding_mode, "Disabled")) ){
+ }else if( NULL != (tmp = strstr(def_banding_mode, "isable")) ){
strcat(tmpbuf, "off");
}else if( NULL != (tmp = strstr(def_banding_mode, "auto")) ){
strcat(tmpbuf, "auto");