diff options
author | Andriy Chepurnyy <x0155536@ti.com> | 2012-10-23 14:57:25 +0300 |
---|---|---|
committer | Daniel Levin <dendy@ti.com> | 2012-11-26 20:17:15 +0200 |
commit | 1e610a23c8797a3ae0e933bd2a54b99e742badf9 (patch) | |
tree | b8a888f0fde50b61c3b1c1aa6f5afb51d2191fd5 /camera | |
parent | 5be19d85932b7efd58885bf4ca1934f52beb32c0 (diff) | |
download | hardware_ti_omap4-1e610a23c8797a3ae0e933bd2a54b99e742badf9.zip hardware_ti_omap4-1e610a23c8797a3ae0e933bd2a54b99e742badf9.tar.gz hardware_ti_omap4-1e610a23c8797a3ae0e933bd2a54b99e742badf9.tar.bz2 |
CameraHAL : Added fps handling for V4L cameras
- Added FRAMERATE_RANGE_SUPPORTED parameter fill.
Also added dynamic fps change handling.
Change-Id: I8752987dd51301d1022081f7bd633cd425b866e4
Signed-off-by: Andriy Chepurnyy <x0155536@ti.com>
Diffstat (limited to 'camera')
-rwxr-xr-x | camera/V4LCameraAdapter/V4LCameraAdapter.cpp | 57 | ||||
-rwxr-xr-x | camera/V4LCameraAdapter/V4LCapabilities.cpp | 19 | ||||
-rwxr-xr-x | camera/inc/V4LCameraAdapter/V4LCameraAdapter.h | 4 |
3 files changed, 49 insertions, 31 deletions
diff --git a/camera/V4LCameraAdapter/V4LCameraAdapter.cpp b/camera/V4LCameraAdapter/V4LCameraAdapter.cpp index a28cd26..7b29b31 100755 --- a/camera/V4LCameraAdapter/V4LCameraAdapter.cpp +++ b/camera/V4LCameraAdapter/V4LCameraAdapter.cpp @@ -163,7 +163,10 @@ status_t V4LCameraAdapter::v4lStartStreaming () { if (!mVideoInfo->isStreaming) { bufType = V4L2_BUF_TYPE_VIDEO_CAPTURE; - + ret = applyFpsValue(); + if (ret != NO_ERROR) { + return ret; + } ret = v4lIoctl (mCameraHandle, VIDIOC_STREAMON, &bufType); if (ret < 0) { CAMHAL_LOGEB("StartStreaming: Unable to start capture: %s", strerror(errno)); @@ -263,18 +266,6 @@ status_t V4LCameraAdapter::restartPreview () goto EXIT; } - //set frame rate - streamParams.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - streamParams.parm.capture.capability = V4L2_CAP_TIMEPERFRAME; - streamParams.parm.capture.capturemode = V4L2_MODE_HIGHQUALITY; - streamParams.parm.capture.timeperframe.denominator = FPS_PERIOD; - streamParams.parm.capture.timeperframe.numerator= 1; - ret = v4lIoctl(mCameraHandle, VIDIOC_S_PARM, &streamParams); - if (ret < 0) { - CAMHAL_LOGEB("VIDIOC_S_PARM Failed: %s", strerror(errno)); - goto EXIT; - } - for (int i = 0; i < mPreviewBufferCountQueueable; i++) { v4l2_buffer buf; @@ -399,11 +390,29 @@ EXIT: } +status_t V4LCameraAdapter::applyFpsValue() { + struct v4l2_streamparm streamParams; + status_t ret = NO_ERROR; + streamParams.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + streamParams.parm.capture.capability = V4L2_CAP_TIMEPERFRAME; + streamParams.parm.capture.capturemode = V4L2_MODE_HIGHQUALITY; + streamParams.parm.capture.timeperframe.denominator = mFrameRate / CameraHal::VFR_SCALE; + streamParams.parm.capture.timeperframe.numerator= 1; + ret = v4lIoctl(mCameraHandle, VIDIOC_S_PARM, &streamParams); + if (ret < 0) { + CAMHAL_LOGEB(" VIDIOC_S_PARM Failed: %s", strerror(errno)); + return ret; + } + int actualFps = streamParams.parm.capture.timeperframe.denominator / streamParams.parm.capture.timeperframe.numerator; + CAMHAL_LOGDB("Actual FPS set is : %d.", actualFps); + return NO_ERROR; +} + status_t V4LCameraAdapter::setParameters(const android::CameraParameters ¶ms) { status_t ret = NO_ERROR; int width, height; - struct v4l2_streamparm streamParams; + int minFps = 0, maxFps = 0; LOG_FUNCTION_NAME; @@ -416,20 +425,13 @@ status_t V4LCameraAdapter::setParameters(const android::CameraParameters ¶ms CAMHAL_LOGEB(" VIDIOC_S_FMT Failed: %s", strerror(errno)); goto EXIT; } - //set frame rate - // Now its fixed to 30 FPS - streamParams.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - streamParams.parm.capture.capability = V4L2_CAP_TIMEPERFRAME; - streamParams.parm.capture.capturemode = V4L2_MODE_HIGHQUALITY; - streamParams.parm.capture.timeperframe.denominator = FPS_PERIOD; - streamParams.parm.capture.timeperframe.numerator= 1; - ret = v4lIoctl(mCameraHandle, VIDIOC_S_PARM, &streamParams); - if (ret < 0) { - CAMHAL_LOGEB(" VIDIOC_S_PARM Failed: %s", strerror(errno)); - goto EXIT; + + params.getPreviewFpsRange(&minFps, &maxFps); + CAMHAL_LOGD("Current fps is %d new fps is (%d,%d)", mFrameRate, minFps, maxFps); + if (maxFps != mFrameRate) { + mFrameRate = maxFps; } - int actualFps = streamParams.parm.capture.timeperframe.denominator / streamParams.parm.capture.timeperframe.numerator; - CAMHAL_LOGDB("Actual FPS set is : %d.", actualFps); + } // Udpate the current parameter set @@ -926,6 +928,7 @@ void V4LCameraAdapter::onOrientationEvent(uint32_t orientation, uint32_t tilt) V4LCameraAdapter::V4LCameraAdapter(size_t sensor_index) +: mFrameRate(0) { LOG_FUNCTION_NAME; diff --git a/camera/V4LCameraAdapter/V4LCapabilities.cpp b/camera/V4LCameraAdapter/V4LCapabilities.cpp index 3177756..ff3708f 100755 --- a/camera/V4LCameraAdapter/V4LCapabilities.cpp +++ b/camera/V4LCameraAdapter/V4LCapabilities.cpp @@ -48,6 +48,7 @@ const char V4LCameraAdapter::DEFAULT_PREVIEW_SIZE[] = "640x480"; const char V4LCameraAdapter::DEFAULT_NUM_PREV_BUFS[] = "6"; const char V4LCameraAdapter::DEFAULT_FRAMERATE[] = "30"; const char V4LCameraAdapter::DEFAULT_FOCUS_MODE[] = "infinity"; +const char V4LCameraAdapter::DEFAULT_FRAMERATE_RANGE[] = "30000,30000"; const char * V4LCameraAdapter::DEFAULT_VSTAB = android::CameraParameters::FALSE; const char * V4LCameraAdapter::DEFAULT_VNF = android::CameraParameters::FALSE; @@ -81,8 +82,7 @@ status_t V4LCameraAdapter::insertDefaults(CameraProperties::Properties* params, params->set(CameraProperties::JPEG_THUMBNAIL_SIZE, "320x240"); params->set(CameraProperties::JPEG_QUALITY, "90"); params->set(CameraProperties::JPEG_THUMBNAIL_QUALITY, "50"); - params->set(CameraProperties::FRAMERATE_RANGE_SUPPORTED, "(30000,30000)"); - params->set(CameraProperties::FRAMERATE_RANGE, "30000,30000"); + params->set(CameraProperties::FRAMERATE_RANGE, DEFAULT_FRAMERATE_RANGE); params->set(CameraProperties::S3D_PRV_FRAME_LAYOUT, "none"); params->set(CameraProperties::SUPPORTED_EXPOSURE_MODES, "auto"); params->set(CameraProperties::SUPPORTED_ISO_VALUES, "auto"); @@ -154,11 +154,11 @@ status_t V4LCameraAdapter::insertImageSizes(CameraProperties::Properties* params status_t V4LCameraAdapter::insertFrameRates(CameraProperties::Properties* params, V4L_TI_CAPTYPE &caps) { char supported[MAX_PROP_VALUE_LENGTH]; - char temp[10]; + char temp[MAX_PROP_VALUE_LENGTH]; memset(supported, '\0', MAX_PROP_VALUE_LENGTH); for (int i = 0; i < caps.ulFrameRateCount; i++) { - snprintf (temp, 10, "%d", caps.ulFrameRates[i] ); + snprintf (temp, sizeof(temp) - 1, "%d", caps.ulFrameRates[i] ); if (supported[0] != '\0') { strncat(supported, PARAM_SEP, 1); } @@ -166,6 +166,17 @@ status_t V4LCameraAdapter::insertFrameRates(CameraProperties::Properties* params } params->set(CameraProperties::SUPPORTED_PREVIEW_FRAME_RATES, supported); + + memset(supported, 0, sizeof(supported)); + + for (int i = caps.ulFrameRateCount - 1; i >= 0 ; i--) { + if ( supported[0] ) strncat(supported, PARAM_SEP, 1); + snprintf(temp, sizeof(temp) - 1, "(%d,%d)", caps.ulFrameRates[i] * CameraHal::VFR_SCALE, caps.ulFrameRates[i] * CameraHal::VFR_SCALE); + strcat(supported, temp); + } + + params->set(CameraProperties::FRAMERATE_RANGE_SUPPORTED, supported); + return NO_ERROR; } diff --git a/camera/inc/V4LCameraAdapter/V4LCameraAdapter.h b/camera/inc/V4LCameraAdapter/V4LCameraAdapter.h index e9c910c..ace19e5 100755 --- a/camera/inc/V4LCameraAdapter/V4LCameraAdapter.h +++ b/camera/inc/V4LCameraAdapter/V4LCameraAdapter.h @@ -178,6 +178,7 @@ private: static const char DEFAULT_PICTURE_FORMAT[]; static const char DEFAULT_PICTURE_SIZE[]; static const char DEFAULT_FOCUS_MODE[]; + static const char DEFAULT_FRAMERATE_RANGE[]; static const char * DEFAULT_VSTAB; static const char * DEFAULT_VNF; @@ -196,6 +197,7 @@ private: status_t v4lStopStreaming(int nBufferCount); status_t v4lSetFormat(int, int, uint32_t); status_t restartPreview(); + status_t applyFpsValue(); int mPreviewBufferCount; @@ -236,6 +238,8 @@ private: Decoder_libjpeg jpgdecoder; unsigned char *jpeg_with_dht_buffer[NB_BUFFER]; unsigned int jpeg_with_dht_buffer_size; + + int mFrameRate; }; } // namespace Camera |