author | brian.zhu <brian.zhu@amlogic.com> | 2012-02-20 11:20:08 (GMT) |
---|---|---|
committer | brian.zhu <brian.zhu@amlogic.com> | 2012-02-20 11:20:08 (GMT) |
commit | c3c378a8d9d6febadafc4458f397a862bd472bf0 (patch) | |
tree | a277138f2c3c22fe8a69b431234b2141a1f5437a | |
parent | 1a49371a1f7ebddf11790dd4e4f369ecc793d39a (diff) | |
download | camera-c3c378a8d9d6febadafc4458f397a862bd472bf0.zip camera-c3c378a8d9d6febadafc4458f397a862bd472bf0.tar.gz camera-c3c378a8d9d6febadafc4458f397a862bd472bf0.tar.bz2 |
Revert "need close camera device when reset frame format and resolution"
This reverts commit 1a49371a1f7ebddf11790dd4e4f369ecc793d39a.
-rwxr-xr-x | V4LCameraAdapter/V4LCameraAdapter.cpp | 142 | ||||
-rwxr-xr-x | inc/V4LCameraAdapter/V4LCameraAdapter.h | 16 |
2 files changed, 11 insertions, 147 deletions
diff --git a/V4LCameraAdapter/V4LCameraAdapter.cpp b/V4LCameraAdapter/V4LCameraAdapter.cpp index 1aa6a86..8e1151a 100755 --- a/V4LCameraAdapter/V4LCameraAdapter.cpp +++ b/V4LCameraAdapter/V4LCameraAdapter.cpp @@ -133,10 +133,6 @@ status_t V4LCameraAdapter::initialize(CameraProperties::Properties* caps) return NO_MEMORY; } -#ifdef AMLOGIC_USB_CAMERA_SUPPORT - mUsbCameraStatus = USBCAMERA_NO_INIT; -#endif - if ((mCameraHandle = open(DEVICE_PATH(mSensorIndex), O_RDWR)) == -1) { CAMHAL_LOGEB("Error while opening handle to V4L2 Camera: %s", strerror(errno)); @@ -174,10 +170,6 @@ status_t V4LCameraAdapter::initialize(CameraProperties::Properties* caps) mRecording = false; mZoomlevel = -1; -#ifdef AMLOGIC_USB_CAMERA_SUPPORT - mUsbCameraStatus = USBCAMERA_INITED; -#endif - #ifndef AMLOGIC_USB_CAMERA_SUPPORT // --------- writefile((char*)SYSFILE_CAMERA_SET_PARA, (char*)"1"); @@ -377,27 +369,6 @@ status_t V4LCameraAdapter::setBuffersFormat(int width, int height, int pixelform return ret; } -status_t V4LCameraAdapter::getBuffersFormat(int &width, int &height, int &pixelformat) -{ - int ret = NO_ERROR; - struct v4l2_format format; - - memset(&format, 0,sizeof(struct v4l2_format)); - - format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - ret = ioctl(mCameraHandle, VIDIOC_G_FMT, &format); - if (ret < 0) { - CAMHAL_LOGEB("Open: VIDIOC_G_FMT Failed: %s", strerror(errno)); - LOGD("ret=%d", ret); - return ret; - } - width = format.fmt.pix.width; - height = format.fmt.pix.height; - pixelformat = format.fmt.pix.pixelformat; - CAMHAL_LOGDB("Get BufferFormat Width * Height %d x %d format 0x%x", width, height, pixelformat); - return ret; -} - status_t V4LCameraAdapter::UseBuffersPreview(void* bufArr, int num) { int ret = NO_ERROR; @@ -407,42 +378,6 @@ status_t V4LCameraAdapter::UseBuffersPreview(void* bufArr, int num) return BAD_VALUE; } -#ifdef AMLOGIC_USB_CAMERA_SUPPORT - if((mUsbCameraStatus == USBCAMERA_ACTIVED)||(mUsbCameraStatus == USBCAMERA_NO_INIT)){ - if(mCameraHandle>=0) - close(mCameraHandle); - - mUsbCameraStatus = USBCAMERA_NO_INIT; - - if ((mCameraHandle = open(DEVICE_PATH(mSensorIndex), O_RDWR)) == -1) - { - CAMHAL_LOGEB("Error while opening handle to V4L2 Camera: %s", strerror(errno)); - return -EINVAL; - } - - ret = ioctl (mCameraHandle, VIDIOC_QUERYCAP, &mVideoInfo->cap); - if (ret < 0) - { - CAMHAL_LOGEA("Error when querying the capabilities of the V4L Camera"); - return -EINVAL; - } - - if ((mVideoInfo->cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) == 0) - { - CAMHAL_LOGEA("Error while adapter initialization: video capture not supported."); - return -EINVAL; - } - - if (!(mVideoInfo->cap.capabilities & V4L2_CAP_STREAMING)) - { - CAMHAL_LOGEA("Error while adapter initialization: Capture device does not support streaming i/o"); - return -EINVAL; - } - mUsbCameraStatus = USBCAMERA_INITED; - mVideoInfo->isStreaming = false; - } -#endif - int width, height; mParams.getPreviewSize(&width, &height); #ifdef AMLOGIC_USB_CAMERA_SUPPORT @@ -504,9 +439,7 @@ status_t V4LCameraAdapter::UseBuffersPreview(void* bufArr, int num) // Update the preview buffer count mPreviewBufferCount = num; -#ifdef AMLOGIC_USB_CAMERA_SUPPORT - mUsbCameraStatus = USBCAMERA_ACTIVED; -#endif + return ret; } @@ -530,50 +463,10 @@ status_t V4LCameraAdapter::UseBuffersCapture(void* bufArr, int num) LOGD("UseBuffersCapture stopPreview.."); this->stopPreview(); -#ifdef AMLOGIC_USB_CAMERA_SUPPORT - if((mUsbCameraStatus == USBCAMERA_ACTIVED)||(mUsbCameraStatus == USBCAMERA_NO_INIT)){ - if(mCameraHandle>=0) - close(mCameraHandle); - - mUsbCameraStatus = USBCAMERA_NO_INIT; - - if ((mCameraHandle = open(DEVICE_PATH(mSensorIndex), O_RDWR)) == -1) - { - CAMHAL_LOGEB("Error while opening handle to V4L2 Camera: %s", strerror(errno)); - return -EINVAL; - } - - ret = ioctl (mCameraHandle, VIDIOC_QUERYCAP, &mVideoInfo->cap); - if (ret < 0) - { - CAMHAL_LOGEA("Error when querying the capabilities of the V4L Camera"); - return -EINVAL; - } - - if ((mVideoInfo->cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) == 0) - { - CAMHAL_LOGEA("Error while adapter initialization: video capture not supported."); - return -EINVAL; - } - - if (!(mVideoInfo->cap.capabilities & V4L2_CAP_STREAMING)) - { - CAMHAL_LOGEA("Error while adapter initialization: Capture device does not support streaming i/o"); - return -EINVAL; - } - mUsbCameraStatus = USBCAMERA_INITED; - mVideoInfo->isStreaming = false; - } -#endif - LOGD("UseBuffersCapture setBuffersFormat.."); int width, height; mParams.getPictureSize(&width, &height); -#ifdef AMLOGIC_USB_CAMERA_SUPPORT - setBuffersFormat(width, height, V4L2_PIX_FMT_YUYV); -#else setBuffersFormat(width, height, DEFAULT_IMAGE_CAPTURE_PIXEL_FORMAT); -#endif //First allocate adapter internal buffers at V4L level for Cam //These are the buffers from which we will copy the data into display buffers @@ -618,10 +511,6 @@ status_t V4LCameraAdapter::UseBuffersCapture(void* bufArr, int num) LOGV("UseBuffersCapture %#x", ptr[0]); mCaptureBuf = (camera_memory_t*)ptr[0]; } - -#ifdef AMLOGIC_USB_CAMERA_SUPPORT - mUsbCameraStatus = USBCAMERA_ACTIVED; -#endif return ret; } @@ -888,10 +777,6 @@ V4LCameraAdapter::~V4LCameraAdapter() mVideoInfo = NULL; } -#ifdef AMLOGIC_USB_CAMERA_SUPPORT - mUsbCameraStatus = USBCAMERA_NO_INIT; -#endif - LOG_FUNCTION_NAME_EXIT; } @@ -1152,14 +1037,14 @@ int V4LCameraAdapter::pictureThread() ret = ioctl(mCameraHandle, VIDIOC_QBUF, &mVideoInfo->buf); if (ret < 0) - { + { CAMHAL_LOGEA("VIDIOC_QBUF Failed"); return -EINVAL; } enum v4l2_buf_type bufType; if (!mVideoInfo->isStreaming) - { + { bufType = V4L2_BUF_TYPE_VIDEO_CAPTURE; ret = ioctl (mCameraHandle, VIDIOC_STREAMON, &bufType); @@ -1486,12 +1371,7 @@ extern "C" void loadCaps(int camera_id, CameraProperties::Properties* params) { params->set(CameraProperties::FRAMERATE_RANGE_VIDEO, "10000,15000"); //get preview size & set - char *sizes = (char *) calloc (1, 1024); - if(!sizes){ - CAMHAL_LOGEA("Alloc string buff error!"); - return; - } - memset(sizes,0,1024); + char sizes[128]; uint32_t preview_format = DEFAULT_PREVIEW_PIXEL_FORMAT; #ifdef AMLOGIC_USB_CAMERA_SUPPORT preview_format = V4L2_PIX_FMT_YUYV; @@ -1503,18 +1383,17 @@ extern "C" void loadCaps(int camera_id, CameraProperties::Properties* params) { if(sizes[len-1] == ',') sizes[len-1] = '\0'; } - #ifdef AML_CAMERA_BY_VM_INTERFACE char small_size[8] = "176x144"; //for cts if(strstr(sizes,small_size)==NULL){ - if((len+sizeof(small_size))<(1024-1)){ + if((len+sizeof(small_size))<(128-1)){ strcat(sizes,","); strcat(sizes,small_size); } } #endif params->set(CameraProperties::SUPPORTED_PREVIEW_SIZES, sizes); - + //set last size as default char * b = (char *)sizes; while(b != NULL){ if (sscanf(b, "%dx%d", &supported_w, &supported_h) != 2){ @@ -1529,7 +1408,7 @@ extern "C" void loadCaps(int camera_id, CameraProperties::Properties* params) { b++; } if((w>0)&&(h>0)){ - memset(sizes, 0, 1024); + memset(sizes, 0, sizeof(sizes)); sprintf(sizes,"%dx%d",w,h); } //char * b = strrchr(sizes, ','); @@ -1560,7 +1439,6 @@ extern "C" void loadCaps(int camera_id, CameraProperties::Properties* params) { params->set(CameraProperties::JPEG_THUMBNAIL_QUALITY, 90); //get & set picture size - memset(sizes,0,1024); uint32_t picture_format = DEFAULT_IMAGE_CAPTURE_PIXEL_FORMAT; #ifdef AMLOGIC_USB_CAMERA_SUPPORT picture_format = V4L2_PIX_FMT_YUYV; @@ -1572,9 +1450,8 @@ extern "C" void loadCaps(int camera_id, CameraProperties::Properties* params) { if(sizes[len-1] == ',') sizes[len-1] = '\0'; } - params->set(CameraProperties::SUPPORTED_PICTURE_SIZES, sizes); - + //set last size as default char * b = (char *)sizes; while(b != NULL){ if (sscanf(b, "%dx%d", &supported_w, &supported_h) != 2){ @@ -1589,7 +1466,7 @@ extern "C" void loadCaps(int camera_id, CameraProperties::Properties* params) { b++; } if((w>0)&&(h>0)){ - memset(sizes, 0, 1024); + memset(sizes, 0, sizeof(sizes)); sprintf(sizes,"%dx%d",w,h); } //char * b = strrchr(sizes, ','); @@ -1609,7 +1486,6 @@ extern "C" void loadCaps(int camera_id, CameraProperties::Properties* params) { params->set(CameraProperties::PICTURE_SIZE,"640x480"); #endif } - free(sizes); params->set(CameraProperties::SUPPORTED_FOCUS_MODES, "fixed"); params->set(CameraProperties::FOCUS_MODE, "fixed"); diff --git a/inc/V4LCameraAdapter/V4LCameraAdapter.h b/inc/V4LCameraAdapter/V4LCameraAdapter.h index 4e35b50..8b07467 100755 --- a/inc/V4LCameraAdapter/V4LCameraAdapter.h +++ b/inc/V4LCameraAdapter/V4LCameraAdapter.h @@ -29,7 +29,7 @@ namespace android { #ifdef AMLOGIC_USB_CAMERA_SUPPORT #define DEFAULT_PREVIEW_PIXEL_FORMAT V4L2_PIX_FMT_NV21 //#define DEFAULT_PREVIEW_PIXEL_FORMAT V4L2_PIX_FMT_YUYV -#define DEFAULT_IMAGE_CAPTURE_PIXEL_FORMAT V4L2_PIX_FMT_RGB24 +#define DEFAULT_IMAGE_CAPTURE_PIXEL_FORMAT V4L2_PIX_FMT_YUYV #else #define DEFAULT_PREVIEW_PIXEL_FORMAT V4L2_PIX_FMT_NV21 #define DEFAULT_IMAGE_CAPTURE_PIXEL_FORMAT V4L2_PIX_FMT_RGB24 @@ -166,7 +166,6 @@ typedef enum camera_night_mode_flip_e { CAM_NM_AUTO = 0, CAM_NM_ENABLE, }camera_night_mode_flip_t; - typedef enum camera_effect_flip_e { CAM_EFFECT_ENC_NORMAL = 0, CAM_EFFECT_ENC_GRAYSCALE, @@ -256,7 +255,6 @@ private: }; status_t setBuffersFormat(int width, int height, int pixelformat); - status_t getBuffersFormat(int &width, int &height, int &pixelformat); //Used for calculation of the average frame rate during preview status_t recalculateFPS(); @@ -309,17 +307,7 @@ private: int nDequeued; int mZoomlevel; - -#ifdef AMLOGIC_USB_CAMERA_SUPPORT - int mUsbCameraStatus; - - enum UsbCameraStatus - { - USBCAMERA_NO_INIT, - USBCAMERA_INITED, - USBCAMERA_ACTIVED - }; -#endif + //int maxQueueable;//the max queued buffers in v4l }; |