diff options
-rw-r--r-- | camera/CameraHal.cpp | 81 | ||||
-rw-r--r-- | camera/CameraHalCommon.cpp | 20 | ||||
-rw-r--r-- | camera/OMXCameraAdapter/OMXCameraAdapter.cpp | 69 | ||||
-rw-r--r-- | camera/TICameraParameters.cpp | 2 | ||||
-rwxr-xr-x | camera/V4LCameraAdapter/V4LCameraAdapter.cpp | 5 | ||||
-rw-r--r-- | camera/inc/CameraHal.h | 1 | ||||
-rw-r--r-- | camera/inc/TICameraParameters.h | 2 |
7 files changed, 98 insertions, 82 deletions
diff --git a/camera/CameraHal.cpp b/camera/CameraHal.cpp index 720d2d6..b4fa319 100644 --- a/camera/CameraHal.cpp +++ b/camera/CameraHal.cpp @@ -385,7 +385,6 @@ int CameraHal::setParameters(const android::CameraParameters& params) int w, h; int framerate; - int maxFPS, minFPS; const char *valstr = NULL; int varint = 0; status_t ret = NO_ERROR; @@ -684,54 +683,63 @@ int CameraHal::setParameters(const android::CameraParameters& params) #endif // Variable framerate ranges have higher priority over - // deprecated constant FPS. "KEY_PREVIEW_FPS_RANGE" should - // be cleared by the client in order for constant FPS to get - // applied. - // If Port FPS needs to be used for configuring, then FPS RANGE should not be set by the APP. - valstr = params.get(android::CameraParameters::KEY_PREVIEW_FPS_RANGE); - if (valstr != NULL && strlen(valstr)) { - int curMaxFPS = 0; - int curMinFPS = 0; + // deprecated constant FPS. + // There is possible 3 situations : + // 1) User change FPS range and HAL use it for fps port value (don't care about + // changed or not const FPS). + // 2) User change single FPS and not change FPS range - will be applyed single FPS value + // to port. + // 3) Both FPS range and const FPS are unchanged - FPS range will be applied to port. + + int curFramerate = 0; + bool frameRangeUpdated = false, fpsUpdated = false; + int curMaxFPS = 0, curMinFPS = 0, maxFPS = 0, minFPS = 0; - // APP wants to set FPS range - // Set framerate = MAXFPS - CAMHAL_LOGDA("APP IS CHANGING FRAME RATE RANGE"); + mParameters.getPreviewFpsRange(&curMinFPS, &curMaxFPS); + params.getPreviewFpsRange(&minFPS, &maxFPS); - mParameters.getPreviewFpsRange(&curMinFPS, &curMaxFPS); - CAMHAL_LOGDB("## current minFPS = %d; maxFPS=%d",curMinFPS, curMaxFPS); + curFramerate = mParameters.getPreviewFrameRate(); + framerate = params.getPreviewFrameRate(); - params.getPreviewFpsRange(&minFPS, &maxFPS); - CAMHAL_LOGDB("## requested minFPS = %d; maxFPS=%d",minFPS, maxFPS); - // Validate VFR + valstr = params.get(android::CameraParameters::KEY_PREVIEW_FPS_RANGE); + if (valstr != NULL && strlen(valstr) && + ((curMaxFPS != maxFPS) || (curMinFPS != minFPS))) { + CAMHAL_LOGDB("## current minFPS = %d; maxFPS=%d", curMinFPS, curMaxFPS); + CAMHAL_LOGDB("## requested minFPS = %d; maxFPS=%d", minFPS, maxFPS); if (!isFpsRangeValid(minFPS, maxFPS, params.get(android::CameraParameters::KEY_SUPPORTED_PREVIEW_FPS_RANGE)) && !isFpsRangeValid(minFPS, maxFPS, params.get(TICameraParameters::KEY_FRAMERATE_RANGES_EXT_SUPPORTED))) { - CAMHAL_LOGEA("Invalid FPS Range"); + CAMHAL_LOGEA("Trying to set invalid FPS Range (%d,%d)", minFPS, maxFPS); return BAD_VALUE; - } else { - framerate = maxFPS / CameraHal::VFR_SCALE; - mParameters.setPreviewFrameRate(framerate); - CAMHAL_LOGDB("SET FRAMERATE %d", framerate); - mParameters.set(android::CameraParameters::KEY_PREVIEW_FPS_RANGE, valstr); - CAMHAL_LOGDB("FPS Range = %s", valstr); - if ( curMaxFPS == (FRAME_RATE_HIGH_HD * CameraHal::VFR_SCALE) && - maxFPS < (FRAME_RATE_HIGH_HD * CameraHal::VFR_SCALE) ) { - restartPreviewRequired = true; - } } - } else { - framerate = params.getPreviewFrameRate(); + mParameters.set(android::CameraParameters::KEY_PREVIEW_FPS_RANGE, valstr); + CAMHAL_LOGDB("FPS Range = %s", valstr); + if ( curMaxFPS == (FRAME_RATE_HIGH_HD * CameraHal::VFR_SCALE) && + maxFPS < (FRAME_RATE_HIGH_HD * CameraHal::VFR_SCALE) ) { + restartPreviewRequired = true; + } + frameRangeUpdated = true; + } + + valstr = params.get(android::CameraParameters::KEY_PREVIEW_FRAME_RATE); + if (valstr != NULL && strlen(valstr) && (framerate != curFramerate)) { + CAMHAL_LOGD("current framerate = %d reqested framerate = %d", curFramerate, framerate); if (!isParameterValid(framerate, params.get(android::CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES)) && !isParameterValid(framerate, params.get(TICameraParameters::KEY_FRAMERATES_EXT_SUPPORTED))) { - CAMHAL_LOGEA("Invalid frame rate"); + CAMHAL_LOGEA("Trying to set invalid frame rate %d", framerate); return BAD_VALUE; } - char tmpBuffer[MAX_PROP_VALUE_LENGTH]; + mParameters.setPreviewFrameRate(framerate); + CAMHAL_LOGDB("Set frame rate %d", framerate); + fpsUpdated = true; + } + if (frameRangeUpdated) { + mParameters.set(TICameraParameters::KEY_PREVIEW_FRAME_RATE_RANGE, + mParameters.get(android::CameraParameters::KEY_PREVIEW_FPS_RANGE)); + } else if (fpsUpdated) { + char tmpBuffer[MAX_PROP_VALUE_LENGTH]; sprintf(tmpBuffer, "%d,%d", framerate * CameraHal::VFR_SCALE, framerate * CameraHal::VFR_SCALE); - mParameters.setPreviewFrameRate(framerate); - CAMHAL_LOGDB("SET FRAMERATE %d", framerate); - mParameters.set(android::CameraParameters::KEY_PREVIEW_FPS_RANGE, tmpBuffer); - CAMHAL_LOGDB("FPS Range = %s", tmpBuffer); + mParameters.set(TICameraParameters::KEY_PREVIEW_FRAME_RATE_RANGE, tmpBuffer); } if ((valstr = params.get(TICameraParameters::KEY_GBCE)) != NULL) { @@ -4555,6 +4563,7 @@ void CameraHal::initDefaultParameters() //Insert default values p.setPreviewFrameRate(atoi(mCameraProperties->get(CameraProperties::PREVIEW_FRAME_RATE))); p.set(android::CameraParameters::KEY_PREVIEW_FPS_RANGE, mCameraProperties->get(CameraProperties::FRAMERATE_RANGE)); + p.set(TICameraParameters::KEY_PREVIEW_FRAME_RATE_RANGE, mCameraProperties->get(CameraProperties::FRAMERATE_RANGE)); p.setPreviewFormat(mCameraProperties->get(CameraProperties::PREVIEW_FORMAT)); p.setPictureFormat(mCameraProperties->get(CameraProperties::PICTURE_FORMAT)); p.set(android::CameraParameters::KEY_JPEG_QUALITY, mCameraProperties->get(CameraProperties::JPEG_QUALITY)); diff --git a/camera/CameraHalCommon.cpp b/camera/CameraHalCommon.cpp index ff460f9..ce01528 100644 --- a/camera/CameraHalCommon.cpp +++ b/camera/CameraHalCommon.cpp @@ -209,5 +209,25 @@ size_t CameraHal::calculateBufferSize(const char* parametersFormat, int width, i } +bool CameraHal::parsePair(const char *str, int *first, int *second, char delim) +{ + // Find the first integer. + char *end; + int w = (int)strtol(str, &end, 10); + // If a delimeter does not immediately follow, give up. + if (*end != delim) { + CAMHAL_LOGE("Cannot find delimeter (%c) in str=%s", delim, str); + return false; + } + + // Find the second integer, immediately after the delimeter. + int h = (int)strtol(end+1, &end, 10); + + *first = w; + *second = h; + + return true; +} + } // namespace Camera } // namespace Ti diff --git a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp b/camera/OMXCameraAdapter/OMXCameraAdapter.cpp index 75bde38..47e245c 100644 --- a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp +++ b/camera/OMXCameraAdapter/OMXCameraAdapter.cpp @@ -594,56 +594,37 @@ status_t OMXCameraAdapter::setParameters(const android::CameraParameters ¶ms params.getPreviewSize(&w, &h); frameRate = params.getPreviewFrameRate(); - params.getPreviewFpsRange(&minFramerate, &maxFramerate); + + const char *frameRateRange = params.get(TICameraParameters::KEY_PREVIEW_FRAME_RATE_RANGE); + bool fpsRangeParsed = CameraHal::parsePair(frameRateRange, &minFramerate, &maxFramerate, ','); + CAMHAL_ASSERT(fpsRangeParsed); + minFramerate /= CameraHal::VFR_SCALE; maxFramerate /= CameraHal::VFR_SCALE; - if ( ( 0 < minFramerate ) && ( 0 < maxFramerate ) ) { - if ( minFramerate > maxFramerate ) { - CAMHAL_LOGEA(" Min FPS set higher than MAX. So setting MIN and MAX to the higher value"); - maxFramerate = minFramerate; - } - if ( 0 >= frameRate ) { - frameRate = maxFramerate; - } + frameRate = maxFramerate; - if ( ( cap->mMinFrameRate != (OMX_U32) minFramerate ) || - ( cap->mMaxFrameRate != (OMX_U32) maxFramerate ) ) { - cap->mMinFrameRate = minFramerate; - cap->mMaxFrameRate = maxFramerate; - setVFramerate(cap->mMinFrameRate, cap->mMaxFrameRate); - } + if ( ( cap->mMinFrameRate != (OMX_U32) minFramerate ) || + ( cap->mMaxFrameRate != (OMX_U32) maxFramerate ) ) { + cap->mMinFrameRate = minFramerate; + cap->mMaxFrameRate = maxFramerate; + setVFramerate(cap->mMinFrameRate, cap->mMaxFrameRate); } - if ( 0 < frameRate ) - { - cap->mColorFormat = pixFormat; - cap->mWidth = w; - cap->mHeight = h; - cap->mFrameRate = frameRate; - - CAMHAL_LOGVB("Prev: cap.mColorFormat = %d", (int)cap->mColorFormat); - CAMHAL_LOGVB("Prev: cap.mWidth = %d", (int)cap->mWidth); - CAMHAL_LOGVB("Prev: cap.mHeight = %d", (int)cap->mHeight); - CAMHAL_LOGVB("Prev: cap.mFrameRate = %d", (int)cap->mFrameRate); - - //TODO: Add an additional parameter for video resolution - //use preview resolution for now - cap = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex]; - cap->mColorFormat = pixFormat; - cap->mWidth = w; - cap->mHeight = h; - cap->mFrameRate = frameRate; - - CAMHAL_LOGVB("Video: cap.mColorFormat = %d", (int)cap->mColorFormat); - CAMHAL_LOGVB("Video: cap.mWidth = %d", (int)cap->mWidth); - CAMHAL_LOGVB("Video: cap.mHeight = %d", (int)cap->mHeight); - CAMHAL_LOGVB("Video: cap.mFrameRate = %d", (int)cap->mFrameRate); - - ///mStride is set from setBufs() while passing the APIs - cap->mStride = 4096; - cap->mBufSize = cap->mStride * cap->mHeight; - } + cap->mColorFormat = pixFormat; + cap->mWidth = w; + cap->mHeight = h; + cap->mFrameRate = frameRate; + + CAMHAL_LOGVB("Prev: cap.mColorFormat = %d", (int)cap->mColorFormat); + CAMHAL_LOGVB("Prev: cap.mWidth = %d", (int)cap->mWidth); + CAMHAL_LOGVB("Prev: cap.mHeight = %d", (int)cap->mHeight); + CAMHAL_LOGVB("Prev: cap.mFrameRate = %d", (int)cap->mFrameRate); + + ///mStride is set from setBufs() while passing the APIs + cap->mStride = 4096; + cap->mBufSize = cap->mStride * cap->mHeight; + if ( ( cap->mWidth >= 1920 ) && ( cap->mHeight >= 1080 ) && diff --git a/camera/TICameraParameters.cpp b/camera/TICameraParameters.cpp index ae8cd81..fb511f2 100644 --- a/camera/TICameraParameters.cpp +++ b/camera/TICameraParameters.cpp @@ -230,5 +230,7 @@ const char TICameraParameters::KEY_ALGO_GIC[] = TI_KEY_ALGO_PREFIX "gic"; const char TICameraParameters::KEY_GAMMA_TABLE[] = "gamma-table"; +const char TICameraParameters::KEY_PREVIEW_FRAME_RATE_RANGE[] = "preview-frame-rate-range"; + } // namespace Camera } // namespace Ti diff --git a/camera/V4LCameraAdapter/V4LCameraAdapter.cpp b/camera/V4LCameraAdapter/V4LCameraAdapter.cpp index f08fc8c..10a1574 100755 --- a/camera/V4LCameraAdapter/V4LCameraAdapter.cpp +++ b/camera/V4LCameraAdapter/V4LCameraAdapter.cpp @@ -508,8 +508,9 @@ status_t V4LCameraAdapter::setParameters(const android::CameraParameters ¶ms CAMHAL_LOGEB(" VIDIOC_S_FMT Failed: %s", strerror(errno)); goto EXIT; } - - params.getPreviewFpsRange(&minFps, &maxFps); + const char *frameRateRange = params.get(TICameraParameters::KEY_PREVIEW_FRAME_RATE_RANGE); + bool fpsRangeParsed = CameraHal::parsePair(frameRateRange, &minFps, &maxFps, ','); + CAMHAL_ASSERT(fpsRangeParsed); CAMHAL_LOGD("Current fps is %d new fps is (%d,%d)", mFrameRate, minFps, maxFps); if (maxFps != mFrameRate) { mFrameRate = maxFps; diff --git a/camera/inc/CameraHal.h b/camera/inc/CameraHal.h index ef11baa..72f0f37 100644 --- a/camera/inc/CameraHal.h +++ b/camera/inc/CameraHal.h @@ -1311,6 +1311,7 @@ public: unsigned int offset, unsigned int stride, const char* format); static unsigned int getBPP(const char* format); + static bool parsePair(const char *str, int *first, int *second, char delim); /*--------------------Internal Member functions - Private---------------------------------*/ private: diff --git a/camera/inc/TICameraParameters.h b/camera/inc/TICameraParameters.h index c5a24e9..951c663 100644 --- a/camera/inc/TICameraParameters.h +++ b/camera/inc/TICameraParameters.h @@ -255,6 +255,8 @@ static const char KEY_ALGO_GIC[]; //Gamma table static const char KEY_GAMMA_TABLE[]; +static const char KEY_PREVIEW_FRAME_RATE_RANGE[]; + }; } // namespace Camera |