diff options
author | Kyle Repinski <repinski23@gmail.com> | 2015-01-07 08:39:28 -0600 |
---|---|---|
committer | Ziyan <jaraidaniel@gmail.com> | 2015-04-11 20:24:52 +0200 |
commit | c5f4358c48d6e50b2affb3ad6c2c0f59546f5b04 (patch) | |
tree | 74070cb6d50ec822d3ef7acdaa390cf2f94c4097 /camera/OMXCameraAdapter/OMXCapabilities.cpp | |
parent | c52c76fa1593f374173a818b4de5bd7c51903fbc (diff) | |
download | device_samsung_tuna-c5f4358c48d6e50b2affb3ad6c2c0f59546f5b04.zip device_samsung_tuna-c5f4358c48d6e50b2affb3ad6c2c0f59546f5b04.tar.gz device_samsung_tuna-c5f4358c48d6e50b2affb3ad6c2c0f59546f5b04.tar.bz2 |
camera: Update camera HAL.
OmapZoom p-jb-release branch with 'CameraHal: Camera Capabilities query update' reverted,
as well as a bunch of stuff ifdef'd out.
Needs a lot of work still. At this point it's a regression, but it has to be done.
Diffstat (limited to 'camera/OMXCameraAdapter/OMXCapabilities.cpp')
-rw-r--r-- | camera/OMXCameraAdapter/OMXCapabilities.cpp | 1977 |
1 files changed, 1630 insertions, 347 deletions
diff --git a/camera/OMXCameraAdapter/OMXCapabilities.cpp b/camera/OMXCameraAdapter/OMXCapabilities.cpp index e1323ee..646e964 100644 --- a/camera/OMXCameraAdapter/OMXCapabilities.cpp +++ b/camera/OMXCameraAdapter/OMXCapabilities.cpp @@ -26,46 +26,90 @@ #include "ErrorUtils.h" #include "TICameraParameters.h" -namespace android { - -#undef LOG_TAG - -// Maintain a separate tag for OMXCameraAdapter logs to isolate issues OMX specific -#define LOG_TAG "CameraHAL" +namespace Ti { +namespace Camera { /************************************ * global constants and variables *************************************/ #define ARRAY_SIZE(array) (sizeof((array)) / sizeof((array)[0])) -#define FPS_MIN 5 -#define FPS_STEP 5 -#define FPS_RANGE_STEP 5 static const char PARAM_SEP[] = ","; -static const int PARAM_SEP_CHAR = ','; static const uint32_t VFR_OFFSET = 8; -static const char VFR_BACKET_START[] = "("; -static const char VFR_BRACKET_END[] = ")"; -static const char FRAMERATE_COUNT = 10; +static const char FPS_STR_MAX_LEN = 10; + +static const unsigned int MANUAL_EXPOSURE_STEP = 1; +static const unsigned int MANUAL_GAIN_ISO_MIN = 100; +static const unsigned int MANUAL_GAIN_ISO_STEP = 100; + +const int OMXCameraAdapter::SENSORID_IMX060 = 300; +const int OMXCameraAdapter::SENSORID_OV5650 = 301; +const int OMXCameraAdapter::SENSORID_OV5640 = 302; +const int OMXCameraAdapter::SENSORID_OV14825 = 304; +const int OMXCameraAdapter::SENSORID_S5K4E1GA = 305; +const int OMXCameraAdapter::SENSORID_S5K6A1GX03 = 306; + +const int OMXCameraAdapter::FPS_MIN = 5; +const int OMXCameraAdapter::FPS_MAX = 30; +const int OMXCameraAdapter::FPS_MAX_EXTENDED = 60; + +inline static int androidFromDucatiFrameRate(OMX_U32 frameRate) { + return (frameRate >> VFR_OFFSET) * CameraHal::VFR_SCALE; +} /**** look up tables to translate OMX Caps to Parameter ****/ const CapResolution OMXCameraAdapter::mImageCapRes [] = { + { 4416, 3312, "4416x3312" }, { 4032, 3024, "4032x3024" }, { 4000, 3000, "4000x3000" }, { 3648, 2736, "3648x2736" }, { 3264, 2448, "3264x2448" }, + { 2608, 1960, "2608x1960" }, { 2592, 1944, "2592x1944" }, { 2592, 1728, "2592x1728" }, { 2592, 1458, "2592x1458" }, + { 2304, 1296, "2304x1296" }, + { 2240, 1344, "2240x1344" }, + { 2160, 1440, "2160x1440" }, + { 2112, 1728, "2112x1728" }, { 2048, 1536, "2048x1536" }, + { 2016, 1512, "2016x1512" }, + { 2000, 1600, "2000x1600" }, { 1600, 1200, "1600x1200" }, { 1280, 1024, "1280x1024" }, - { 1152, 864, "1152x864" }, - { 1280, 960, "1280x960" }, - { 640, 480, "640x480" }, - { 320, 240, "320x240" }, + { 1152, 864, "1152x864" }, + { 1280, 960, "1280x960" }, + { 1024, 768, "1024x768" }, + { 640, 480, "640x480" }, + { 320, 240, "320x240" }, +}; + +const CapResolution OMXCameraAdapter::mImageCapResSS [] = { + { 4032*2, 3024, "8064x3024" }, + { 3648*2, 2736, "7296x2736" }, + { 3264*2, 2448, "6528x2448" }, + { 2592*2, 1944, "5184x1944" }, + { 2048*2, 1536, "4096x1536" }, + { 1600*2, 1200, "3200x1200" }, + { 1280*2, 960, "2560x960" }, + { 1024*2, 768, "2048x768" }, + { 640*2, 480, "1280x480" }, + { 320*2, 240, "640x240" }, +}; + +const CapResolution OMXCameraAdapter::mImageCapResTB [] = { + { 4032, 3024*2, "4032x6048" }, + { 3648, 2736*2, "3648x5472" }, + { 3264, 2448*2, "3264x4896" }, + { 2592, 1944*2, "2592x3888" }, + { 2048, 1536*2, "2048x3072" }, + { 1600, 1200*2, "1600x2400" }, + { 1280, 960*2, "1280x1920" }, + { 1024, 768*2, "1024x1536" }, + { 640, 480*2, "640x960" }, + { 320, 240*2, "320x480" }, }; const CapResolution OMXCameraAdapter::mPreviewRes [] = { @@ -81,9 +125,57 @@ const CapResolution OMXCameraAdapter::mPreviewRes [] = { { 352, 288, "352x288" }, { 240, 160, "240x160" }, { 176, 144, "176x144" }, + { 160, 120, "160x120" }, { 128, 96, "128x96" }, }; +const CapResolution OMXCameraAdapter::mPreviewPortraitRes [] = { + //Portrait resolutions + { 1088, 1920, "1088x1920" }, + { 720, 1280, "720x1280" }, + { 480, 800, "480x800" }, + { 576, 720, "576x720" }, + { 576, 768, "576x768" }, + { 480, 720, "480x720" }, + { 480, 640, "480x640" }, + { 288, 352, "288x352" }, + { 240, 320, "240x320" }, + { 160, 240, "160x240" }, + { 144, 176, "144x176" }, + { 120, 160, "120x160"}, + { 96, 128, "96x128" } +}; + +const CapResolution OMXCameraAdapter::mPreviewResSS [] = { + { 1920*2, 1080, "3840x1080" }, + { 1280*2, 720, "2560x720" }, + { 800*2, 480, "1600x480" }, + { 720*2, 576, "1440x576" }, + { 720*2, 480, "1440x480" }, + { 768*2, 576, "1536x576" }, + { 640*2, 480, "1280x480" }, + { 320*2, 240, "640x240" }, + { 352*2, 288, "704x288" }, + { 240*2, 160, "480x160" }, + { 176*2, 144, "352x144" }, + { 128*2, 96, "256x96" } +}; + +const CapResolution OMXCameraAdapter::mPreviewResTB [] = { + { 1920, 1080*2, "1920x2160" }, + { 1280, 720*2, "1280x1440" }, + { 800, 480*2, "800x960" }, + { 720, 576*2, "720x1152" }, + { 720, 480*2, "720x960" }, + { 768, 576*2, "768x1152" }, + { 640, 480*2, "640x960" }, + { 320, 240*2, "320x480" }, + { 352, 288*2, "352x576" }, + { 240, 160*2, "240x320" }, + { 176, 144*2, "176x288" }, + { 128, 96*2, "128x192" }, +}; + const CapResolution OMXCameraAdapter::mThumbRes [] = { { 640, 480, "640x480" }, { 160, 120, "160x120" }, @@ -96,16 +188,42 @@ const CapResolution OMXCameraAdapter::mThumbRes [] = { }; const CapPixelformat OMXCameraAdapter::mPixelformats [] = { - { OMX_COLOR_FormatCbYCrY, CameraParameters::PIXEL_FORMAT_YUV422I }, - { OMX_COLOR_FormatYUV420SemiPlanar, CameraParameters::PIXEL_FORMAT_YUV420SP }, - { OMX_COLOR_Format16bitRGB565, CameraParameters::PIXEL_FORMAT_RGB565 }, - { OMX_COLOR_FormatRawBayer10bit, TICameraParameters::PIXEL_FORMAT_RAW }, - { OMX_COLOR_FormatYUV420SemiPlanar, CameraParameters::PIXEL_FORMAT_YUV420P }, + { OMX_COLOR_FormatCbYCrY, android::CameraParameters::PIXEL_FORMAT_YUV422I }, + { OMX_COLOR_FormatYUV420SemiPlanar, android::CameraParameters::PIXEL_FORMAT_YUV420SP }, + { OMX_COLOR_Format16bitRGB565, android::CameraParameters::PIXEL_FORMAT_RGB565 }, + { OMX_COLOR_FormatYUV420SemiPlanar, android::CameraParameters::PIXEL_FORMAT_YUV420P }, + { OMX_COLOR_FormatUnused, TICameraParameters::PIXEL_FORMAT_UNUSED }, + { OMX_COLOR_FormatRawBayer10bit, android::CameraParameters::PIXEL_FORMAT_BAYER_RGGB }, +}; + +const userToOMX_LUT OMXCameraAdapter::mFrameLayout [] = { + { TICameraParameters::S3D_NONE, OMX_TI_StereoFrameLayout2D }, + { TICameraParameters::S3D_TB_FULL, OMX_TI_StereoFrameLayoutTopBottom }, + { TICameraParameters::S3D_SS_FULL, OMX_TI_StereoFrameLayoutLeftRight }, +#ifndef OMAP_TUNA + { TICameraParameters::S3D_TB_SUBSAMPLED, OMX_TI_StereoFrameLayoutTopBottomSubsample }, + { TICameraParameters::S3D_SS_SUBSAMPLED, OMX_TI_StereoFrameLayoutLeftRightSubsample }, +#endif +}; + +const LUTtype OMXCameraAdapter::mLayoutLUT = { + ARRAY_SIZE(mFrameLayout), + mFrameLayout +}; + +const CapCodingFormat OMXCameraAdapter::mImageCodingFormat [] = { + { OMX_IMAGE_CodingJPEG, android::CameraParameters::PIXEL_FORMAT_JPEG }, + { (OMX_IMAGE_CODINGTYPE)OMX_TI_IMAGE_CodingJPS, TICameraParameters::PIXEL_FORMAT_JPS }, + { (OMX_IMAGE_CODINGTYPE)OMX_TI_IMAGE_CodingMPO, TICameraParameters::PIXEL_FORMAT_MPO }, }; const CapFramerate OMXCameraAdapter::mFramerates [] = { + { 60, "60" }, { 30, "30" }, + { 24, "24" }, + { 20, "20" }, { 15, "15" }, + { 10, "10" }, }; const CapZoom OMXCameraAdapter::mZoomStages [] = { @@ -185,37 +303,45 @@ const CapISO OMXCameraAdapter::mISOStages [] = { // mapped values have to match with new_sensor_MSP.h const CapU32 OMXCameraAdapter::mSensorNames [] = { - { 300, "IMX060" }, - { 301, "OV5650" }, - { 305, "S5K4E1GA"}, - { 306, "S5K6A1GX03" } + { SENSORID_IMX060, "IMX060" }, + { SENSORID_OV5650, "OV5650" }, + { SENSORID_OV5640, "OV5640" }, + { SENSORID_OV14825, "OV14825"}, + { SENSORID_S5K4E1GA, "S5K4E1GA"}, + { SENSORID_S5K6A1GX03, "S5K6A1GX03" } // TODO(XXX): need to account for S3D camera later }; -// values for supported variable framerates sorted in ascending order -// CapU32Pair = (max fps, min fps, string representation) -const CapU32Pair OMXCameraAdapter::mVarFramerates [] = { - { 15, 15, "(15000,15000)"}, - { 30, 15, "(15000,30000)" }, - { 30, 24, "(24000,30000)" }, -// TODO(XXX): Removing 30,30 range to limit 1080p at 24fps. Will put back soon. -#if 0 - { 30, 30, "(30000,30000)" }, -#endif +const userToOMX_LUT OMXCameraAdapter::mAutoConvergence [] = { + { TICameraParameters::AUTOCONVERGENCE_MODE_DISABLE, OMX_TI_AutoConvergenceModeDisable }, + { TICameraParameters::AUTOCONVERGENCE_MODE_FRAME, OMX_TI_AutoConvergenceModeFrame }, + { TICameraParameters::AUTOCONVERGENCE_MODE_CENTER, OMX_TI_AutoConvergenceModeCenter }, + { TICameraParameters::AUTOCONVERGENCE_MODE_TOUCH, OMX_TI_AutoConvergenceModeFocusFaceTouch }, + { TICameraParameters::AUTOCONVERGENCE_MODE_MANUAL, OMX_TI_AutoConvergenceModeManual } }; -/************************************ - * static helper functions - *************************************/ -// utility function to remove last seperator -void remove_last_sep(char* buffer) { - char* last_sep = NULL; - last_sep = strrchr(buffer, PARAM_SEP_CHAR); - if (last_sep != NULL) { - last_sep[0] = '\0'; - } -} +const LUTtype OMXCameraAdapter::mAutoConvergenceLUT = { + ARRAY_SIZE(mAutoConvergence), + mAutoConvergence +}; +const userToOMX_LUT OMXCameraAdapter::mBracketingModes [] = { + { TICameraParameters::TEMP_BRACKETING , OMX_BracketTemporal }, + { TICameraParameters::EXPOSURE_BRACKETING , OMX_BracketExposureRelativeInEV } +}; + +const LUTtype OMXCameraAdapter::mBracketingModesLUT = { + ARRAY_SIZE(mBracketingModes), + mBracketingModes +}; + +// values for supported camera facing direction +const CapU32 OMXCameraAdapter::mFacing [] = { +#ifndef OMAP_TUNA + { OMX_TI_SENFACING_BACK , TICameraParameters::FACING_BACK }, + { OMX_TI_SENFACING_FRONT, TICameraParameters::FACING_FRONT}, +#endif +}; /***************************************** * internal static function declarations @@ -223,24 +349,28 @@ void remove_last_sep(char* buffer) { /**** Utility functions to help translate OMX Caps to Parameter ****/ -status_t OMXCameraAdapter::encodePixelformatCap(OMX_COLOR_FORMATTYPE format, - const CapPixelformat *cap, - size_t capCount, - char * buffer, - size_t bufferSize) { +status_t OMXCameraAdapter::encodeImageCodingFormatCap(OMX_IMAGE_CODINGTYPE format, + const CapCodingFormat *cap, + size_t capCount, + char * buffer) { + status_t ret = NO_ERROR; LOG_FUNCTION_NAME; if ( ( NULL == buffer ) || ( NULL == cap ) ) { CAMHAL_LOGEA("Invalid input arguments"); - return -EINVAL; + ret = -EINVAL; } - for ( unsigned int i = 0; i < capCount; i++ ) { - if ( format == cap[i].pixelformat ) { - strncat(buffer, cap[i].param, bufferSize - 1); - strncat(buffer, PARAM_SEP, bufferSize - 1); + if ( NO_ERROR == ret ) { + for ( unsigned int i = 0 ; i < capCount ; i++ ) { + if ( format == cap[i].imageCodingFormat ) { + if (buffer[0] != '\0') { + strncat(buffer, PARAM_SEP, ((((int)MAX_PROP_VALUE_LENGTH - 1 - (int)strlen(buffer)) < 0) ? 0 : (MAX_PROP_VALUE_LENGTH - 1 - strlen(buffer)))); + } + strncat(buffer, cap[i].param, ((((int)MAX_PROP_VALUE_LENGTH - 1 - (int)strlen(buffer)) < 0) ? 0 : (MAX_PROP_VALUE_LENGTH - 1 - strlen(buffer)))); + } } } @@ -249,16 +379,13 @@ status_t OMXCameraAdapter::encodePixelformatCap(OMX_COLOR_FORMATTYPE format, return ret; } -status_t OMXCameraAdapter::encodeFramerateCap(OMX_U32 framerateMax, - OMX_U32 framerateMin, - const CapFramerate *cap, - size_t capCount, - char * buffer, - size_t bufferSize) { +status_t OMXCameraAdapter::encodePixelformatCap(OMX_COLOR_FORMATTYPE format, + const CapPixelformat *cap, + size_t capCount, + char * buffer, + size_t bufferSize) +{ status_t ret = NO_ERROR; - bool minInserted = false; - bool maxInserted = false; - char tmpBuffer[FRAMERATE_COUNT]; LOG_FUNCTION_NAME; @@ -267,113 +394,86 @@ status_t OMXCameraAdapter::encodeFramerateCap(OMX_U32 framerateMax, return -EINVAL; } - for ( unsigned int i = 0; i < capCount; i++ ) { - if ( (framerateMax >= cap[i].num) && (framerateMin <= cap[i].num) ) { - strncat(buffer, cap[i].param, bufferSize - 1); - strncat(buffer, PARAM_SEP, bufferSize - 1); - if ( cap[i].num == framerateMin ) { - minInserted = true; + for ( unsigned int i = 0 ; i < capCount ; i++ ) + { + if ( format == cap[i].pixelformat ) + { + if (buffer[0] != '\0') { + strncat(buffer, PARAM_SEP, bufferSize - 1); + } + strncat(buffer, cap[i].param, bufferSize - 1); } } - if ( cap[i].num == framerateMax ) { - maxInserted = true; - } - } - - if ( !maxInserted ) { - memset(tmpBuffer, 0, FRAMERATE_COUNT); - snprintf(tmpBuffer, FRAMERATE_COUNT - 1, "%u,", ( unsigned int ) framerateMax); - strncat(buffer, tmpBuffer, bufferSize - 1); - strncat(buffer, PARAM_SEP, bufferSize - 1); - } - - if ( !minInserted ) { - memset(tmpBuffer, 0, FRAMERATE_COUNT); - snprintf(tmpBuffer, FRAMERATE_COUNT - 1, "%u,", ( unsigned int ) framerateMin); - strncat(buffer, tmpBuffer, bufferSize - 1); - strncat(buffer, PARAM_SEP, bufferSize - 1); - } - - remove_last_sep(buffer); LOG_FUNCTION_NAME_EXIT; return ret; } -status_t OMXCameraAdapter::encodeVFramerateCap(OMX_TI_CAPTYPE &caps, - const CapU32Pair *cap, - size_t capCount, - char *buffer, - char *defaultRange, - size_t bufferSize) { - status_t ret = NO_ERROR; - uint32_t minVFR, maxVFR; - int default_index = -1; - +void OMXCameraAdapter::encodeFrameRates(const int minFrameRate, const int maxFrameRate, + const OMX_TI_CAPTYPE & caps, const CapFramerate * const fixedFrameRates, + const int frameRateCount, android::Vector<FpsRange> & fpsRanges) { LOG_FUNCTION_NAME; - if ( (NULL == buffer) || (NULL == cap) ) { - CAMHAL_LOGEA("Invalid input arguments"); - return -EINVAL; + if ( minFrameRate == maxFrameRate ) { + // single fixed frame rate supported + fpsRanges.add(FpsRange(minFrameRate, maxFrameRate)); + return; } - if(caps.ulPrvVarFPSModesCount < 1) { - return NO_ERROR; - } + // insert min and max frame rates + fpsRanges.add(FpsRange(minFrameRate, minFrameRate)); + fpsRanges.add(FpsRange(maxFrameRate, maxFrameRate)); - // Assumption: last range in tPrvVarFPSModes will be for S30FPSHD mode - minVFR = caps.tPrvVarFPSModes[caps.ulPrvVarFPSModesCount-1].nVarFPSMin >> VFR_OFFSET; - maxVFR = caps.tPrvVarFPSModes[caps.ulPrvVarFPSModesCount-1].nVarFPSMax >> VFR_OFFSET; + // insert variable frame rates + for ( int i = 0; i < static_cast<int>(caps.ulPrvVarFPSModesCount); ++i ) { + const FpsRange fpsRange = FpsRange( + max(androidFromDucatiFrameRate(caps.tPrvVarFPSModes[i].nVarFPSMin), minFrameRate), + min(androidFromDucatiFrameRate(caps.tPrvVarFPSModes[i].nVarFPSMax), maxFrameRate)); - if (minVFR < FPS_MIN) { - minVFR = FPS_MIN; + if ( fpsRange.isFixed() ) { + // this range is either min or max fixed frame rate, already added above + continue; + } + + fpsRanges.add(fpsRange); } - for (unsigned int i = 0; i < capCount; i++) { - // add cap[i] if it is in range and maxVFR != minVFR - if ((maxVFR >= cap[i].num1) && (minVFR <= cap[i].num2)) { - if (buffer[0] != '\0') { - strncat(buffer, PARAM_SEP, bufferSize - 1); - } - strncat(buffer, cap[i].param, bufferSize - 1); + // insert fixed frame rates + for ( int i = 0; i < frameRateCount; ++i ) { + const int fixedFrameRate = fixedFrameRates[i].num * CameraHal::VFR_SCALE; - // choose the max variable framerate as default - if (cap[i].num1 != cap[i].num2) { - default_index = i; - } + if ( fixedFrameRate < minFrameRate || fixedFrameRate > maxFrameRate ) { + // not supported by hardware + continue; } - } - // if we haven't found any caps in the list to populate - // just use the min and max - if (buffer[0] == '\0') { - snprintf(buffer, bufferSize - 1, - "(%u,%u)", - minVFR * CameraHal::VFR_SCALE, - maxVFR * CameraHal::VFR_SCALE); + const FpsRange fpsRange = FpsRange(fixedFrameRate, fixedFrameRate); + fpsRanges.add(fpsRange); } - if (default_index != -1) { - snprintf(defaultRange, (MAX_PROP_VALUE_LENGTH - 1), "%lu,%lu", - cap[default_index].num2 * CameraHal::VFR_SCALE, - cap[default_index].num1 * CameraHal::VFR_SCALE); - } else { - snprintf(defaultRange, (MAX_PROP_VALUE_LENGTH - 1), "%u,%u", - minVFR * CameraHal::VFR_SCALE, maxVFR * CameraHal::VFR_SCALE); - } - - LOG_FUNCTION_NAME_EXIT; + // sort first by max, then by min, according to Android API requirements + fpsRanges.sort(FpsRange::compare); - return ret; + // remove duplicated frame rates + for ( int i = 0; i < static_cast<int>(fpsRanges.size()) - 1; ) { + const FpsRange & current = fpsRanges.itemAt(i); + const FpsRange & next = fpsRanges.itemAt(i + 1); + if ( current == next ) { + fpsRanges.removeAt(i + 1); + } else { + i++; + } + } } size_t OMXCameraAdapter::encodeZoomCap(OMX_S32 maxZoom, const CapZoom *cap, size_t capCount, char * buffer, - size_t bufferSize) { + size_t bufferSize) +{ status_t res = NO_ERROR; size_t ret = 0; @@ -387,12 +487,13 @@ size_t OMXCameraAdapter::encodeZoomCap(OMX_S32 maxZoom, for ( unsigned int i = 0; i < capCount; i++ ) { if ( cap[i].num <= maxZoom ) { + if (buffer[0] != '\0') { + strncat(buffer, PARAM_SEP, bufferSize - 1); + } strncat(buffer, cap[i].param, bufferSize - 1); - strncat(buffer, PARAM_SEP, bufferSize - 1); ret++; } } - remove_last_sep(buffer); LOG_FUNCTION_NAME_EXIT; @@ -403,7 +504,8 @@ status_t OMXCameraAdapter::encodeISOCap(OMX_U32 maxISO, const CapISO *cap, size_t capCount, char * buffer, - size_t bufferSize) { + size_t bufferSize) +{ status_t ret = NO_ERROR; LOG_FUNCTION_NAME; @@ -415,11 +517,12 @@ status_t OMXCameraAdapter::encodeISOCap(OMX_U32 maxISO, for ( unsigned int i = 0; i < capCount; i++ ) { if ( cap[i].num <= maxISO) { + if (buffer[0] != '\0') { + strncat(buffer, PARAM_SEP, bufferSize - 1); + } strncat(buffer, cap[i].param, bufferSize - 1); - strncat(buffer, PARAM_SEP, bufferSize - 1); } } - remove_last_sep(buffer); LOG_FUNCTION_NAME_EXIT; @@ -430,7 +533,8 @@ status_t OMXCameraAdapter::encodeSizeCap(OMX_TI_CAPRESTYPE &res, const CapResolution *cap, size_t capCount, char * buffer, - size_t bufferSize) { + size_t bufferSize) +{ status_t ret = NO_ERROR; LOG_FUNCTION_NAME; @@ -445,8 +549,10 @@ status_t OMXCameraAdapter::encodeSizeCap(OMX_TI_CAPRESTYPE &res, (cap[i].height <= res.nHeightMax) && (cap[i].width >= res.nWidthMin) && (cap[i].height >= res.nHeightMin) ) { + if (buffer[0] != '\0') { + strncat(buffer, PARAM_SEP, bufferSize - 1); + } strncat(buffer, cap[i].param, bufferSize -1); - strncat(buffer, PARAM_SEP, bufferSize - 1); } } @@ -455,59 +561,287 @@ status_t OMXCameraAdapter::encodeSizeCap(OMX_TI_CAPRESTYPE &res, return ret; } -status_t OMXCameraAdapter::insertImageSizes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { +status_t OMXCameraAdapter::encodeSizeCap3D(OMX_TI_CAPRESTYPE &res, + const CapResolution *cap, + size_t capCount, + char * buffer, + size_t bufferSize) +{ + status_t ret = NO_ERROR; + + LOG_FUNCTION_NAME; + + if ( (NULL == buffer) || (NULL == cap) ) { + CAMHAL_LOGEA("Invalid input arguments"); + return -EINVAL; + } + + for ( unsigned int i = 0 ; i < capCount ; i++ ) { + if ( (cap[i].width <= res.nWidthMax) && + (cap[i].height <= res.nHeightMax) && + (cap[i].width >= res.nWidthMin) && + (cap[i].height >= res.nHeightMin) +#ifndef OMAP_TUNA + && (cap[i].width * cap[i].height <= res.nMaxResInPixels) +#endif + ) { + if (buffer[0] != '\0') { + strncat(buffer, PARAM_SEP, bufferSize - 1); + } + strncat(buffer, cap[i].param, bufferSize -1); + } + } + + LOG_FUNCTION_NAME_EXIT; + + return ret; +} + +status_t OMXCameraAdapter::insertImageSizes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ status_t ret = NO_ERROR; char supported[MAX_PROP_VALUE_LENGTH]; + int s3d_detected = 0; + int s3d_ss_detected = 0; + int s3d_tb_detected = 0; LOG_FUNCTION_NAME; +#ifndef OMAP_TUNA + for ( unsigned int i = 0 ; i < caps.ulCapFrameLayoutCount; i++ ) { + if (caps.eCapFrameLayout[i] == OMX_TI_StereoFrameLayoutTopBottom) + { + s3d_tb_detected = 1; + } + else if (caps.eCapFrameLayout[i] == OMX_TI_StereoFrameLayoutLeftRight) + { + s3d_ss_detected = 1; + } + else if ( (caps.eCapFrameLayout[i] == OMX_TI_StereoFrameLayoutTopBottomSubsample) + || (caps.eCapFrameLayout[i] == OMX_TI_StereoFrameLayoutLeftRightSubsample) ) + { + s3d_detected = 1; + } + } +#endif + memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - ret = encodeSizeCap(caps.tImageResRange, + // Check if we are in 2d mode + if (!s3d_ss_detected && !s3d_tb_detected && !s3d_detected) + { + ret = encodeSizeCap(caps.tImageResRange, mImageCapRes, ARRAY_SIZE(mImageCapRes), supported, MAX_PROP_VALUE_LENGTH); - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("Error inserting supported picture sizes 0x%x", ret); - } else { - remove_last_sep(supported); - params->set(CameraProperties::SUPPORTED_PICTURE_SIZES, supported); + if ( NO_ERROR != ret ) { + CAMHAL_LOGEB("Error inserting supported picture sizes 0x%x", ret); + } else { + params->set(CameraProperties::SUPPORTED_PICTURE_SIZES, supported); + } + params->set(CameraProperties::MAX_PICTURE_WIDTH, caps.tImageResRange.nWidthMax); + params->set(CameraProperties::MAX_PICTURE_HEIGHT, caps.tImageResRange.nHeightMax); } + else // 3d mode + { + if (s3d_tb_detected) + { + ret = encodeSizeCap3D(caps.tImageResRange, + mImageCapResTB, + ARRAY_SIZE(mImageCapResTB), + supported, + MAX_PROP_VALUE_LENGTH); + + if ( NO_ERROR != ret ) { + CAMHAL_LOGEB("Error inserting supported picture sizes 0x%x", ret); + } else { + params->set(CameraProperties::SUPPORTED_PICTURE_TOPBOTTOM_SIZES, supported); + } + } + else + { + params->set(CameraProperties::SUPPORTED_PICTURE_TOPBOTTOM_SIZES, supported); + } - LOG_FUNCTION_NAME; + memset(supported, '\0', MAX_PROP_VALUE_LENGTH); + + if (s3d_ss_detected) + { + ret = encodeSizeCap3D(caps.tImageResRange, + mImageCapResSS, + ARRAY_SIZE(mImageCapResSS), + supported, + MAX_PROP_VALUE_LENGTH); + + if ( NO_ERROR != ret ) { + CAMHAL_LOGEB("Error inserting supported picture sizes 0x%x", ret); + } else { + params->set(CameraProperties::SUPPORTED_PICTURE_SIDEBYSIDE_SIZES, supported); + } + } + else + { + params->set(CameraProperties::SUPPORTED_PICTURE_SIDEBYSIDE_SIZES, supported); + } + + memset(supported, '\0', MAX_PROP_VALUE_LENGTH); + + if (s3d_detected) + { + ret = encodeSizeCap3D(caps.tImageResRange, + mImageCapRes, + ARRAY_SIZE(mImageCapRes), + supported, + MAX_PROP_VALUE_LENGTH); + + if ( NO_ERROR != ret ) { + CAMHAL_LOGEB("Error inserting supported picture sizes 0x%x", ret); + } else { + params->set(CameraProperties::SUPPORTED_PICTURE_SUBSAMPLED_SIZES, supported); + } + } else { + params->set(CameraProperties::SUPPORTED_PICTURE_SUBSAMPLED_SIZES, supported); + } + } + + LOG_FUNCTION_NAME_EXIT; return ret; } -status_t OMXCameraAdapter::insertPreviewSizes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { +status_t OMXCameraAdapter::insertPreviewSizes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ status_t ret = NO_ERROR; char supported[MAX_PROP_VALUE_LENGTH]; + int s3d_detected = 0; + int s3d_ss_detected = 0; + int s3d_tb_detected = 0; LOG_FUNCTION_NAME; +#ifndef OMAP_TUNA + for ( unsigned int i = 0 ; i < caps.ulPrvFrameLayoutCount; i++ ) { + if (caps.ePrvFrameLayout[i] == OMX_TI_StereoFrameLayoutTopBottom) + { + s3d_tb_detected = 1; + } + else if (caps.ePrvFrameLayout[i] == OMX_TI_StereoFrameLayoutLeftRight) + { + s3d_ss_detected = 1; + } + else if ( (caps.ePrvFrameLayout[i] == OMX_TI_StereoFrameLayoutTopBottomSubsample) + || (caps.ePrvFrameLayout[i] == OMX_TI_StereoFrameLayoutLeftRightSubsample) ) + { + s3d_detected = 1; + } + } +#endif + memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - ret = encodeSizeCap(caps.tPreviewResRange, + // Check if we are in 2d mode + if (!s3d_ss_detected && !s3d_tb_detected && !s3d_detected) + { + ret = encodeSizeCap(caps.tPreviewResRange, mPreviewRes, ARRAY_SIZE(mPreviewRes), supported, MAX_PROP_VALUE_LENGTH); - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("Error inserting supported preview sizes 0x%x", ret); - } else { - remove_last_sep(supported); - params->set(CameraProperties::SUPPORTED_PREVIEW_SIZES, supported); + if ( NO_ERROR != ret ) { + CAMHAL_LOGEB("Error inserting supported Landscape preview sizes 0x%x", ret); + return ret; + } + +#ifndef OMAP_TUNA + /* Insert Portait Resolutions by verifying Potrait Capability Support */ + ret = encodeSizeCap(caps.tRotatedPreviewResRange, + mPreviewPortraitRes, + ARRAY_SIZE(mPreviewPortraitRes), + supported, + MAX_PROP_VALUE_LENGTH); + + if ( NO_ERROR != ret ) { + CAMHAL_LOGEB("Error inserting supported Potrait preview sizes 0x%x", ret); + } else { + params->set(CameraProperties::SUPPORTED_PREVIEW_SIZES, supported); + } +#endif } + else // 3d mode + { + if (s3d_tb_detected) + { + ret = encodeSizeCap3D(caps.tPreviewResRange, + mPreviewResTB, + ARRAY_SIZE(mPreviewResTB), + supported, + MAX_PROP_VALUE_LENGTH); + if ( NO_ERROR != ret ) { + CAMHAL_LOGEB("Error inserting supported 3D TB preview sizes 0x%x", ret); + return ret; + } else { + params->set(CameraProperties::SUPPORTED_PREVIEW_TOPBOTTOM_SIZES, supported); + } + } + else + { + params->set(CameraProperties::SUPPORTED_PREVIEW_TOPBOTTOM_SIZES, supported); + } - LOG_FUNCTION_NAME; + memset(supported, '\0', MAX_PROP_VALUE_LENGTH); + + if (s3d_ss_detected) + { + ret = encodeSizeCap3D(caps.tPreviewResRange, + mPreviewResSS, + ARRAY_SIZE(mPreviewResSS), + supported, + MAX_PROP_VALUE_LENGTH); + if ( NO_ERROR != ret ) { + CAMHAL_LOGEB("Error inserting supported 3D SS preview sizes 0x%x", ret); + return ret; + } else { + params->set(CameraProperties::SUPPORTED_PREVIEW_SIDEBYSIDE_SIZES, supported); + } + } + else + { + params->set(CameraProperties::SUPPORTED_PREVIEW_SIDEBYSIDE_SIZES, supported); + } + + memset(supported, '\0', MAX_PROP_VALUE_LENGTH); + + if (s3d_detected) + { + ret = encodeSizeCap3D(caps.tPreviewResRange, + mPreviewRes, + ARRAY_SIZE(mPreviewRes), + supported, + MAX_PROP_VALUE_LENGTH); + + if ( NO_ERROR != ret ) { + CAMHAL_LOGEB("Error inserting supported preview sizes 0x%x", ret); + return ret; + } else { + params->set(CameraProperties::SUPPORTED_PREVIEW_SUBSAMPLED_SIZES, supported); + } + } + else + { + params->set(CameraProperties::SUPPORTED_PREVIEW_SUBSAMPLED_SIZES, supported); + } + } + + LOG_FUNCTION_NAME_EXIT; return ret; } -status_t OMXCameraAdapter::insertVideoSizes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { +status_t OMXCameraAdapter::insertVideoSizes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ status_t ret = NO_ERROR; char supported[MAX_PROP_VALUE_LENGTH]; @@ -524,16 +858,16 @@ status_t OMXCameraAdapter::insertVideoSizes(CameraProperties::Properties* params if ( NO_ERROR != ret ) { CAMHAL_LOGEB("Error inserting supported video sizes 0x%x", ret); } else { - remove_last_sep(supported); params->set(CameraProperties::SUPPORTED_VIDEO_SIZES, supported); } - LOG_FUNCTION_NAME; + LOG_FUNCTION_NAME_EXIT; return ret; } -status_t OMXCameraAdapter::insertThumbSizes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { +status_t OMXCameraAdapter::insertThumbSizes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ status_t ret = NO_ERROR; char supported[MAX_PROP_VALUE_LENGTH]; @@ -551,11 +885,14 @@ status_t OMXCameraAdapter::insertThumbSizes(CameraProperties::Properties* params CAMHAL_LOGEB("Error inserting supported thumbnail sizes 0x%x", ret); } else { //CTS Requirement: 0x0 should always be supported + if (supported[0] != '\0') { + strncat(supported, PARAM_SEP, 1); + } strncat(supported, "0x0", MAX_PROP_NAME_LENGTH); params->set(CameraProperties::SUPPORTED_THUMBNAIL_SIZES, supported); } - LOG_FUNCTION_NAME; + LOG_FUNCTION_NAME_EXIT; return ret; } @@ -580,25 +917,26 @@ status_t OMXCameraAdapter::insertZoomStages(CameraProperties::Properties* params params->set(CameraProperties::SUPPORTED_ZOOM_STAGES, zoomStageCount - 1); //As per CTS requirement if ( 0 == zoomStageCount ) { - params->set(CameraProperties::ZOOM_SUPPORTED, TICameraParameters::ZOOM_UNSUPPORTED); - params->set(CameraProperties::SMOOTH_ZOOM_SUPPORTED, TICameraParameters::ZOOM_UNSUPPORTED); + params->set(CameraProperties::ZOOM_SUPPORTED, android::CameraParameters::FALSE); + params->set(CameraProperties::SMOOTH_ZOOM_SUPPORTED, android::CameraParameters::FALSE); } else { - params->set(CameraProperties::ZOOM_SUPPORTED, TICameraParameters::ZOOM_SUPPORTED); - params->set(CameraProperties::SMOOTH_ZOOM_SUPPORTED, TICameraParameters::ZOOM_SUPPORTED); + params->set(CameraProperties::ZOOM_SUPPORTED, android::CameraParameters::TRUE); + params->set(CameraProperties::SMOOTH_ZOOM_SUPPORTED, android::CameraParameters::TRUE); } - LOG_FUNCTION_NAME; + LOG_FUNCTION_NAME_EXIT; return ret; } -status_t OMXCameraAdapter::insertImageFormats(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { +status_t OMXCameraAdapter::insertImageFormats(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ status_t ret = NO_ERROR; char supported[MAX_PROP_VALUE_LENGTH]; LOG_FUNCTION_NAME; - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); + memset(supported, '\0', sizeof(supported)); for ( int i = 0 ; i < caps.ulImageFormatCount ; i++ ) { ret = encodePixelformatCap(caps.eImageFormats[i], @@ -606,24 +944,38 @@ status_t OMXCameraAdapter::insertImageFormats(CameraProperties::Properties* para ARRAY_SIZE(mPixelformats), supported, MAX_PROP_VALUE_LENGTH); + + if ( NO_ERROR != ret ) { + CAMHAL_LOGEB("Error inserting supported picture formats 0x%x", ret); + break; + } + } + +#ifndef OMAP_TUNA + for (int i = 0; i < caps.ulImageCodingFormatCount ; i++) { + ret = encodeImageCodingFormatCap(caps.eImageCodingFormat[i], + mImageCodingFormat, + ARRAY_SIZE(mImageCodingFormat), + supported); + if ( NO_ERROR != ret ) { CAMHAL_LOGEB("Error inserting supported picture formats 0x%x", ret); break; } } +#endif if ( NO_ERROR == ret ) { - //jpeg is not supported in OMX capabilies yet - strncat(supported, CameraParameters::PIXEL_FORMAT_JPEG, MAX_PROP_VALUE_LENGTH - 1); params->set(CameraProperties::SUPPORTED_PICTURE_FORMATS, supported); } - LOG_FUNCTION_NAME; + LOG_FUNCTION_NAME_EXIT; return ret; } -status_t OMXCameraAdapter::insertPreviewFormats(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { +status_t OMXCameraAdapter::insertPreviewFormats(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ status_t ret = NO_ERROR; char supported[MAX_PROP_VALUE_LENGTH]; @@ -646,74 +998,132 @@ status_t OMXCameraAdapter::insertPreviewFormats(CameraProperties::Properties* pa if ( NO_ERROR == ret ) { // need to advertise we support YV12 format // We will program preview port with NV21 when we see application set YV12 - strncat(supported, CameraParameters::PIXEL_FORMAT_YUV420P, MAX_PROP_VALUE_LENGTH - 1); + if (supported[0] != '\0') { + strncat(supported, PARAM_SEP, 1); + } + strncat(supported, android::CameraParameters::PIXEL_FORMAT_YUV420P, MAX_PROP_VALUE_LENGTH - 1); params->set(CameraProperties::SUPPORTED_PREVIEW_FORMATS, supported); } - LOG_FUNCTION_NAME; + LOG_FUNCTION_NAME_EXIT; return ret; } -status_t OMXCameraAdapter::insertFramerates(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; +status_t OMXCameraAdapter::insertFramerates(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ + // collect supported normal frame rates + { + android::Vector<FpsRange> fpsRanges; + + const int minFrameRate = max<int>(FPS_MIN * CameraHal::VFR_SCALE, + androidFromDucatiFrameRate(caps.xFramerateMin)); + const int maxFrameRate = min<int>(FPS_MAX * CameraHal::VFR_SCALE, + androidFromDucatiFrameRate(caps.xFramerateMax)); + + if ( minFrameRate > maxFrameRate ) { + CAMHAL_LOGE("Invalid frame rate range: [%d .. %d]", caps.xFramerateMin, caps.xFramerateMax); + return BAD_VALUE; + } - LOG_FUNCTION_NAME; + encodeFrameRates(minFrameRate, maxFrameRate, caps, mFramerates, ARRAY_SIZE(mFramerates), fpsRanges); - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); + // populate variable frame rates + char supported[MAX_PROP_VALUE_LENGTH]; + char defaultRange[MAX_PROP_VALUE_LENGTH]; - ret = encodeFramerateCap(caps.xFramerateMax >> VFR_OFFSET, - caps.xFramerateMin >> VFR_OFFSET, - mFramerates, - ARRAY_SIZE(mFramerates), - supported, - MAX_PROP_VALUE_LENGTH); + memset(supported, 0, sizeof(supported)); + memset(defaultRange, 0, sizeof(defaultRange)); - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("Error inserting supported preview framerates 0x%x", ret); - } else { + for ( int i = 0; i < static_cast<int>(fpsRanges.size()); ++i ) { + const FpsRange & fpsRange = fpsRanges.itemAt(i); + if ( supported[0] ) strncat(supported, PARAM_SEP, 1); + char tmp[MAX_PROP_VALUE_LENGTH]; + snprintf(tmp, sizeof(tmp) - 1, "(%d,%d)", fpsRange.min(), fpsRange.max()); + strcat(supported, tmp); + } + + const FpsRange & defaultFpsRange = fpsRanges.itemAt(fpsRanges.size() - 1); + snprintf(defaultRange, sizeof(defaultRange) - 1, "%d,%d", defaultFpsRange.min(), defaultFpsRange.max()); + + CAMHAL_LOGD("Supported framerate ranges: %s", supported); + CAMHAL_LOGD("Default framerate range: [%s]", defaultRange); + + params->set(CameraProperties::FRAMERATE_RANGE_SUPPORTED, supported); + params->set(CameraProperties::FRAMERATE_RANGE, defaultRange); + + // populate fixed frame rates + memset(supported, 0, sizeof(supported)); + memset(defaultRange, 0, sizeof(defaultRange)); + + for ( int i = 0; i < static_cast<int>(fpsRanges.size()); ++i ) { + const FpsRange & fpsRange = fpsRanges.itemAt(i); + if ( fpsRange.isFixed() && (fpsRange.min()%CameraHal::VFR_SCALE) == 0 ) { + if ( supported[0] ) strncat(supported, PARAM_SEP, 1); + char tmp[MAX_PROP_VALUE_LENGTH]; + snprintf(tmp, sizeof(tmp) - 1, "%d", fpsRange.min()/CameraHal::VFR_SCALE); + strcat(supported, tmp); + } + } + + CAMHAL_LOGD("Supported preview framerates: %s", supported); params->set(CameraProperties::SUPPORTED_PREVIEW_FRAME_RATES, supported); + + // insert default frame rate only if it is fixed + if ( defaultFpsRange.isFixed() && (defaultFpsRange.min()%CameraHal::VFR_SCALE) == 0 ) { + snprintf(defaultRange, sizeof(defaultRange) - 1, "%d", defaultFpsRange.min()/CameraHal::VFR_SCALE); + params->set(CameraProperties::PREVIEW_FRAME_RATE, defaultRange); + } } - LOG_FUNCTION_NAME; + // collect supported extended frame rates + { + android::Vector<FpsRange> fpsRanges; - return ret; -} + const int minFrameRate = max<int>(FPS_MIN * CameraHal::VFR_SCALE, + androidFromDucatiFrameRate(caps.xFramerateMin)); + const int maxFrameRate = min<int>(FPS_MAX_EXTENDED * CameraHal::VFR_SCALE, + androidFromDucatiFrameRate(caps.xFramerateMax)); -status_t OMXCameraAdapter::insertVFramerates(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; - char defaultRange[MAX_PROP_VALUE_LENGTH]; + encodeFrameRates(minFrameRate, maxFrameRate, caps, mFramerates, ARRAY_SIZE(mFramerates), fpsRanges); - LOG_FUNCTION_NAME; + // populate variable frame rates + char supported[MAX_PROP_VALUE_LENGTH]; + memset(supported, 0, sizeof(supported) - 1); - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); + for ( int i = 0; i < static_cast<int>(fpsRanges.size()); ++i ) { + const FpsRange & fpsRange = fpsRanges.itemAt(i); + if ( supported[0] ) strncat(supported, PARAM_SEP, 1); + char tmp[MAX_PROP_VALUE_LENGTH]; + snprintf(tmp, sizeof(tmp) - 1, "(%d,%d)", fpsRange.min(), fpsRange.max()); + strcat(supported, tmp); + } - ret = encodeVFramerateCap(caps, - mVarFramerates, - ARRAY_SIZE(mVarFramerates), - supported, - defaultRange, - MAX_PROP_VALUE_LENGTH); + CAMHAL_LOGD("Supported framerate ranges extended: %s", supported); + params->set(CameraProperties::FRAMERATE_RANGE_EXT_SUPPORTED, supported); - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("Error inserting supported preview framerate ranges 0x%x", ret); - } else { - params->set(CameraProperties::FRAMERATE_RANGE_SUPPORTED, supported); - CAMHAL_LOGDB("framerate ranges %s", supported); - params->set(CameraProperties::FRAMERATE_RANGE, DEFAULT_FRAMERATE_RANGE_IMAGE); - params->set(CameraProperties::FRAMERATE_RANGE_VIDEO, DEFAULT_FRAMERATE_RANGE_VIDEO); - params->set(CameraProperties::FRAMERATE_RANGE_IMAGE, DEFAULT_FRAMERATE_RANGE_IMAGE); - CAMHAL_LOGDB("Default framerate range: [%s]", DEFAULT_FRAMERATE_RANGE_IMAGE); - } + // populate fixed frame rates + memset(supported, 0, sizeof(supported) - 1); - LOG_FUNCTION_NAME; + for ( int i = 0; i < static_cast<int>(fpsRanges.size()); ++i ) { + const FpsRange & fpsRange = fpsRanges.itemAt(i); + if ( fpsRange.isFixed() && (fpsRange.min()%CameraHal::VFR_SCALE) == 0 ) { + if ( supported[0] ) strncat(supported, PARAM_SEP, 1); + char tmp[MAX_PROP_VALUE_LENGTH]; + snprintf(tmp, sizeof(tmp) - 1, "%d", fpsRange.min()/CameraHal::VFR_SCALE); + strcat(supported, tmp); + } + } - return ret; + CAMHAL_LOGD("Supported extended preview framerates: %s", supported); + params->set(CameraProperties::SUPPORTED_PREVIEW_FRAME_RATES_EXT, supported); + } + + return OK; } -status_t OMXCameraAdapter::insertEVs(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { +status_t OMXCameraAdapter::insertEVs(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ status_t ret = NO_ERROR; char supported[MAX_PROP_VALUE_LENGTH]; @@ -727,12 +1137,13 @@ status_t OMXCameraAdapter::insertEVs(CameraProperties::Properties* params, OMX_T snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", ( int ) ( caps.xEVCompensationMax * 10 )); params->set(CameraProperties::SUPPORTED_EV_MAX, supported); - LOG_FUNCTION_NAME; + LOG_FUNCTION_NAME_EXIT; return ret; } -status_t OMXCameraAdapter::insertISOModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { +status_t OMXCameraAdapter::insertISOModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ status_t ret = NO_ERROR; char supported[MAX_PROP_VALUE_LENGTH]; @@ -751,12 +1162,13 @@ status_t OMXCameraAdapter::insertISOModes(CameraProperties::Properties* params, params->set(CameraProperties::SUPPORTED_ISO_VALUES, supported); } - LOG_FUNCTION_NAME; + LOG_FUNCTION_NAME_EXIT; return ret; } -status_t OMXCameraAdapter::insertIPPModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { +status_t OMXCameraAdapter::insertIPPModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ status_t ret = NO_ERROR; char supported[MAX_PROP_VALUE_LENGTH]; @@ -766,32 +1178,31 @@ status_t OMXCameraAdapter::insertIPPModes(CameraProperties::Properties* params, //Off is always supported strncat(supported, TICameraParameters::IPP_NONE, MAX_PROP_NAME_LENGTH); - strncat(supported, PARAM_SEP, 1); if ( caps.bLensDistortionCorrectionSupported ) { - strncat(supported, TICameraParameters::IPP_LDC, MAX_PROP_NAME_LENGTH); strncat(supported, PARAM_SEP, 1); + strncat(supported, TICameraParameters::IPP_LDC, MAX_PROP_NAME_LENGTH); } if ( caps.bISONoiseFilterSupported ) { - strncat(supported, TICameraParameters::IPP_NSF, MAX_PROP_NAME_LENGTH); strncat(supported, PARAM_SEP, 1); + strncat(supported, TICameraParameters::IPP_NSF, MAX_PROP_NAME_LENGTH); } if ( caps.bISONoiseFilterSupported && caps.bLensDistortionCorrectionSupported ) { - strncat(supported, TICameraParameters::IPP_LDCNSF, MAX_PROP_NAME_LENGTH); strncat(supported, PARAM_SEP, 1); + strncat(supported, TICameraParameters::IPP_LDCNSF, MAX_PROP_NAME_LENGTH); } - remove_last_sep(supported); params->set(CameraProperties::SUPPORTED_IPP_MODES, supported); - LOG_FUNCTION_NAME; + LOG_FUNCTION_NAME_EXIT; return ret; } -status_t OMXCameraAdapter::insertWBModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { +status_t OMXCameraAdapter::insertWBModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ status_t ret = NO_ERROR; char supported[MAX_PROP_VALUE_LENGTH]; const char *p; @@ -803,19 +1214,22 @@ status_t OMXCameraAdapter::insertWBModes(CameraProperties::Properties* params, O for ( unsigned int i = 0 ; i < caps.ulWhiteBalanceCount ; i++ ) { p = getLUTvalue_OMXtoHAL(caps.eWhiteBalanceModes[i], WBalLUT); if ( NULL != p ) { + if (supported[0] != '\0') { + strncat(supported, PARAM_SEP, 1); + } strncat(supported, p, MAX_PROP_NAME_LENGTH); - strncat(supported, PARAM_SEP, 1); } } params->set(CameraProperties::SUPPORTED_WHITE_BALANCE, supported); - LOG_FUNCTION_NAME; + LOG_FUNCTION_NAME_EXIT; return ret; } -status_t OMXCameraAdapter::insertEffects(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { +status_t OMXCameraAdapter::insertEffects(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ status_t ret = NO_ERROR; char supported[MAX_PROP_VALUE_LENGTH]; const char *p; @@ -827,19 +1241,22 @@ status_t OMXCameraAdapter::insertEffects(CameraProperties::Properties* params, O for ( unsigned int i = 0 ; i < caps.ulColorEffectCount; i++ ) { p = getLUTvalue_OMXtoHAL(caps.eColorEffects[i], EffLUT); if ( NULL != p ) { + if (supported[0] != '\0') { + strncat(supported, PARAM_SEP, 1); + } strncat(supported, p, MAX_PROP_NAME_LENGTH); - strncat(supported, PARAM_SEP, 1); } } - remove_last_sep(supported); + params->set(CameraProperties::SUPPORTED_EFFECTS, supported); - LOG_FUNCTION_NAME; + LOG_FUNCTION_NAME_EXIT; return ret; } -status_t OMXCameraAdapter::insertExpModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { +status_t OMXCameraAdapter::insertExpModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ status_t ret = NO_ERROR; char supported[MAX_PROP_VALUE_LENGTH]; const char *p; @@ -851,19 +1268,77 @@ status_t OMXCameraAdapter::insertExpModes(CameraProperties::Properties* params, for ( unsigned int i = 0 ; i < caps.ulExposureModeCount; i++ ) { p = getLUTvalue_OMXtoHAL(caps.eExposureModes[i], ExpLUT); if ( NULL != p ) { + if (supported[0] != '\0') { + strncat(supported, PARAM_SEP, 1); + } strncat(supported, p, MAX_PROP_NAME_LENGTH); - strncat(supported, PARAM_SEP, 1); } } params->set(CameraProperties::SUPPORTED_EXPOSURE_MODES, supported); + LOG_FUNCTION_NAME_EXIT; + + return ret; +} + +status_t OMXCameraAdapter::insertManualExpRanges(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { + status_t ret = NO_ERROR; + char supported[MAX_PROP_VALUE_LENGTH]; + LOG_FUNCTION_NAME; +#ifndef OMAP_TUNA + if (caps.nManualExpMin > caps.nManualExpMax) { +#endif + snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", (int) 0); + params->set(CameraProperties::SUPPORTED_MANUAL_EXPOSURE_MIN, supported); + + snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", (int) 0); + params->set(CameraProperties::SUPPORTED_MANUAL_EXPOSURE_MAX, supported); + + snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", (int) 0); + params->set(CameraProperties::SUPPORTED_MANUAL_EXPOSURE_STEP, supported); +#ifndef OMAP_TUNA + } else { + snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", (int) caps.nManualExpMin); + params->set(CameraProperties::SUPPORTED_MANUAL_EXPOSURE_MIN, supported); + + snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", (int) caps.nManualExpMax); + params->set(CameraProperties::SUPPORTED_MANUAL_EXPOSURE_MAX, supported); + + snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", (int) MANUAL_EXPOSURE_STEP); + params->set(CameraProperties::SUPPORTED_MANUAL_EXPOSURE_STEP, supported); + } +#endif + + if (MANUAL_GAIN_ISO_MIN > caps.nSensitivityMax) { + snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", (int) 0); + params->set(CameraProperties::SUPPORTED_MANUAL_GAIN_ISO_MIN, supported); + + snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", (int) 0); + params->set(CameraProperties::SUPPORTED_MANUAL_GAIN_ISO_MAX, supported); + + snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", (int) 0); + params->set(CameraProperties::SUPPORTED_MANUAL_GAIN_ISO_STEP, supported); } + else { + snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", (int) MANUAL_GAIN_ISO_MIN); + params->set(CameraProperties::SUPPORTED_MANUAL_GAIN_ISO_MIN, supported); + + snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", (int) caps.nSensitivityMax); + params->set(CameraProperties::SUPPORTED_MANUAL_GAIN_ISO_MAX, supported); + + snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", (int) MANUAL_GAIN_ISO_STEP); + params->set(CameraProperties::SUPPORTED_MANUAL_GAIN_ISO_STEP, supported); + } + + LOG_FUNCTION_NAME_EXIT; + return ret; } -status_t OMXCameraAdapter::insertFlashModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { +status_t OMXCameraAdapter::insertFlashModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ status_t ret = NO_ERROR; char supported[MAX_PROP_VALUE_LENGTH]; const char *p; @@ -875,20 +1350,26 @@ status_t OMXCameraAdapter::insertFlashModes(CameraProperties::Properties* params for ( unsigned int i = 0 ; i < caps.ulFlashCount; i++ ) { p = getLUTvalue_OMXtoHAL(caps.eFlashModes[i], FlashLUT); if ( NULL != p ) { + if (supported[0] != '\0') { + strncat(supported, PARAM_SEP, 1); + } strncat(supported, p, MAX_PROP_NAME_LENGTH); - strncat(supported, PARAM_SEP, 1); } } - remove_last_sep(supported); + if ( strlen(supported) == 0 ) { + strncpy(supported, DEFAULT_FLASH_MODE, MAX_PROP_NAME_LENGTH); + } + params->set(CameraProperties::SUPPORTED_FLASH_MODES, supported); - LOG_FUNCTION_NAME; + LOG_FUNCTION_NAME_EXIT; return ret; } -status_t OMXCameraAdapter::insertSceneModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { +status_t OMXCameraAdapter::insertSceneModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ status_t ret = NO_ERROR; char supported[MAX_PROP_VALUE_LENGTH]; const char *p; @@ -900,34 +1381,31 @@ status_t OMXCameraAdapter::insertSceneModes(CameraProperties::Properties* params for ( unsigned int i = 0 ; i < caps.ulSceneCount; i++ ) { p = getLUTvalue_OMXtoHAL(caps.eSceneModes[i], SceneLUT); if ( NULL != p ) { + if (supported[0] != '\0') { + strncat(supported, PARAM_SEP, 1); + } strncat(supported, p, MAX_PROP_NAME_LENGTH); - strncat(supported, PARAM_SEP, 1); } } - remove_last_sep(supported); params->set(CameraProperties::SUPPORTED_SCENE_MODES, supported); - LOG_FUNCTION_NAME; + LOG_FUNCTION_NAME_EXIT; return ret; } -status_t OMXCameraAdapter::insertFocusModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { +status_t OMXCameraAdapter::insertFocusModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ status_t ret = NO_ERROR; char supported[MAX_PROP_VALUE_LENGTH]; - const char *p; LOG_FUNCTION_NAME; memset(supported, '\0', MAX_PROP_VALUE_LENGTH); for ( unsigned int i = 0 ; i < caps.ulFocusModeCount; i++ ) { - p = getLUTvalue_OMXtoHAL(caps.eFocusModes[i], FocusLUT); - if ( NULL != p ) { - strncat(supported, p, MAX_PROP_NAME_LENGTH); - strncat(supported, PARAM_SEP, 1); - } + getMultipleLUTvalue_OMXtoHAL(caps.eFocusModes[i], FocusLUT, supported); } // Check if focus is supported by camera @@ -935,21 +1413,21 @@ status_t OMXCameraAdapter::insertFocusModes(CameraProperties::Properties* params caps.eFocusModes[0] == OMX_IMAGE_FocusControlOff) { // Focus is not supported by camera // Advertise this to app as infinitiy focus mode - strncat(supported, CameraParameters::FOCUS_MODE_INFINITY, MAX_PROP_NAME_LENGTH); - } else { - // Focus is supported but these modes are not supported by the - // capability feature. Apply manually - strncat(supported, CameraParameters::FOCUS_MODE_CONTINUOUS_PICTURE, MAX_PROP_NAME_LENGTH); + if (supported[0] != '\0') { + strncat(supported, PARAM_SEP, 1); + } + strncat(supported, android::CameraParameters::FOCUS_MODE_INFINITY, MAX_PROP_NAME_LENGTH); } params->set(CameraProperties::SUPPORTED_FOCUS_MODES, supported); - LOG_FUNCTION_NAME; + LOG_FUNCTION_NAME_EXIT; return ret; } -status_t OMXCameraAdapter::insertFlickerModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { +status_t OMXCameraAdapter::insertFlickerModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ status_t ret = NO_ERROR; char supported[MAX_PROP_VALUE_LENGTH]; const char *p; @@ -961,19 +1439,22 @@ status_t OMXCameraAdapter::insertFlickerModes(CameraProperties::Properties* para for ( unsigned int i = 0 ; i < caps.ulFlickerCount; i++ ) { p = getLUTvalue_OMXtoHAL(caps.eFlicker[i], FlickerLUT); if ( NULL != p ) { + if (supported[0] != '\0') { + strncat(supported, PARAM_SEP, 1); + } strncat(supported, p, MAX_PROP_NAME_LENGTH); - strncat(supported, PARAM_SEP, 1); } } - remove_last_sep(supported); + params->set(CameraProperties::SUPPORTED_ANTIBANDING, supported); - LOG_FUNCTION_NAME; + LOG_FUNCTION_NAME_EXIT; return ret; } -status_t OMXCameraAdapter::insertAreas(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { +status_t OMXCameraAdapter::insertAreas(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ status_t ret = NO_ERROR; char supported[MAX_PROP_VALUE_LENGTH]; const char *p; @@ -991,31 +1472,490 @@ status_t OMXCameraAdapter::insertAreas(CameraProperties::Properties* params, OMX params->set(CameraProperties::MAX_NUM_METERING_AREAS, supported); CAMHAL_LOGDB("Maximum supported exposure areas %s", supported); + LOG_FUNCTION_NAME_EXIT; + + return ret; +} + +status_t OMXCameraAdapter::insertVNFSupported(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { + status_t ret = NO_ERROR; + LOG_FUNCTION_NAME; +#ifndef OMAP_TUNA + if ( OMX_TRUE == caps.bVideoNoiseFilterSupported ) { + params->set(CameraProperties::VNF_SUPPORTED, android::CameraParameters::TRUE); + } else { +#endif + params->set(CameraProperties::VNF_SUPPORTED, android::CameraParameters::FALSE); +#ifndef OMAP_TUNA + } +#endif + + LOG_FUNCTION_NAME_EXIT; + return ret; } -status_t OMXCameraAdapter::insertLocks(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { +status_t OMXCameraAdapter::insertVSTABSupported(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { status_t ret = NO_ERROR; - LOG_FUNCTION_NAME + LOG_FUNCTION_NAME; + +#ifndef OMAP_TUNA + if ( OMX_TRUE == caps.bVideoStabilizationSupported ) { + params->set(CameraProperties::VSTAB_SUPPORTED, android::CameraParameters::TRUE); + } else { +#endif + params->set(CameraProperties::VSTAB_SUPPORTED, android::CameraParameters::FALSE); +#ifndef OMAP_TUNA + } +#endif + + LOG_FUNCTION_NAME_EXIT; + + return ret; +} - params->set(CameraProperties::AUTO_EXPOSURE_LOCK_SUPPORTED, DEFAULT_LOCK_SUPPORTED); - params->set(CameraProperties::AUTO_WHITEBALANCE_LOCK_SUPPORTED, DEFAULT_LOCK_SUPPORTED); +status_t OMXCameraAdapter::insertLocks(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ + status_t ret = NO_ERROR; LOG_FUNCTION_NAME +#ifndef OMAP_TUNA + if ( caps.bAELockSupported ) { + params->set(CameraProperties::AUTO_EXPOSURE_LOCK_SUPPORTED, android::CameraParameters::TRUE); + } else { +#endif + params->set(CameraProperties::AUTO_EXPOSURE_LOCK_SUPPORTED, android::CameraParameters::FALSE); +#ifndef OMAP_TUNA + } +#endif + +#ifndef OMAP_TUNA + if ( caps.bAWBLockSupported ) { + params->set(CameraProperties::AUTO_WHITEBALANCE_LOCK_SUPPORTED, android::CameraParameters::TRUE); + } else { +#endif + params->set(CameraProperties::AUTO_WHITEBALANCE_LOCK_SUPPORTED, android::CameraParameters::FALSE); +#ifndef OMAP_TUNA + } +#endif + + LOG_FUNCTION_NAME_EXIT + return ret; } -status_t OMXCameraAdapter::insertDefaults(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { +status_t OMXCameraAdapter::insertSenMount(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ status_t ret = NO_ERROR; char supported[MAX_PROP_VALUE_LENGTH]; const char *p; + unsigned int i = 0; LOG_FUNCTION_NAME; + memset(supported, '\0', sizeof(supported)); + + // 1) Look up and assign sensor name + for (i = 0; i < ARRAY_SIZE(mSensorNames); i++) { + if(mSensorNames[i].num == caps.tSenMounting.nSenId) { + // sensor found + break; + } + } + if ( i == ARRAY_SIZE(mSensorNames) ) { + p = "UNKNOWN_SENSOR"; + } else { + p = mSensorNames[i].param; + } + strncat(supported, p, REMAINING_BYTES(supported)); + params->set(CameraProperties::CAMERA_NAME, supported); + params->set(CameraProperties::CAMERA_SENSOR_ID, caps.tSenMounting.nSenId); + + // 2) Assign mounting rotation + params->set(CameraProperties::ORIENTATION_INDEX, caps.tSenMounting.nRotation); + + LOG_FUNCTION_NAME_EXIT; + + return ret; +} + +status_t OMXCameraAdapter::insertRaw(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { + + status_t ret = NO_ERROR; + char supported[MAX_PROP_VALUE_LENGTH]; + unsigned int i = 0; + + LOG_FUNCTION_NAME; + + memset(supported, '\0', sizeof(supported)); +#ifndef OMAP_TUNA + sprintf(supported,"%d",int(caps.uSenNativeResWidth)); +#endif + params->set(CameraProperties::RAW_WIDTH, supported); + + memset(supported, '\0', sizeof(supported)); +#ifndef OMAP_TUNA + if (caps.bMechanicalMisalignmentSupported) { + sprintf(supported,"%d",int(caps.uSenNativeResHeight) * 2); + } else { + sprintf(supported,"%d",int(caps.uSenNativeResHeight)); + } +#endif + params->set(CameraProperties::RAW_HEIGHT, supported); + + LOG_FUNCTION_NAME_EXIT; + + return ret; +} + +status_t OMXCameraAdapter::insertFacing(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ + status_t ret = NO_ERROR; + char supported[MAX_PROP_VALUE_LENGTH]; + const char *p; + unsigned int i = 0; + + LOG_FUNCTION_NAME; + + memset(supported, '\0', sizeof(supported)); + +#ifndef OMAP_TUNA + for (i = 0; i < ARRAY_SIZE(mFacing); i++) { + if((OMX_TI_SENFACING_TYPE)mFacing[i].num == caps.tSenMounting.eFacing) { + break; + } + } +#endif + if ( i == ARRAY_SIZE(mFacing) ) { + p = "UNKNOWN_FACING"; + } else { + p = mFacing[i].param; + } + strncat(supported, p, REMAINING_BYTES(supported)); + params->set(CameraProperties::FACING_INDEX, supported); + + LOG_FUNCTION_NAME_EXIT; + + return ret; +} + +status_t OMXCameraAdapter::insertFocalLength(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ + status_t ret = NO_ERROR; + char supported[MAX_PROP_VALUE_LENGTH]; + + LOG_FUNCTION_NAME; + + memset(supported, '\0', sizeof(supported)); + +#ifndef OMAP_TUNA + sprintf(supported, "%d", caps.nFocalLength / 100); +#endif + strncat(supported, ".", REMAINING_BYTES(supported)); +#ifndef OMAP_TUNA + sprintf(supported+(strlen(supported)*sizeof(char)), "%d", caps.nFocalLength % 100); +#endif + + params->set(CameraProperties::FOCAL_LENGTH, supported); + + LOG_FUNCTION_NAME_EXIT + + return ret; +} + +status_t OMXCameraAdapter::insertAutoConvergenceModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ + status_t ret = NO_ERROR; + char supported[MAX_PROP_VALUE_LENGTH]; + const char *p; + unsigned int i = 0; + + LOG_FUNCTION_NAME; + + memset(supported, '\0', sizeof(supported)); +#ifndef OMAP_TUNA + for ( unsigned int i = 0 ; i < caps.ulAutoConvModesCount; i++ ) { + p = getLUTvalue_OMXtoHAL(caps.eAutoConvModes[i], mAutoConvergenceLUT); + if ( NULL != p ) { + if (supported[0] != '\0') { + strncat(supported, PARAM_SEP, REMAINING_BYTES(supported)); + } + strncat(supported, p, REMAINING_BYTES(supported)); + } + } +#endif + params->set(CameraProperties::AUTOCONVERGENCE_MODE_VALUES, supported); + + LOG_FUNCTION_NAME_EXIT; + + return ret; +} + +status_t OMXCameraAdapter::insertManualConvergenceRange(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ + status_t ret = NO_ERROR; + char supported[MAX_PROP_VALUE_LENGTH]; + + LOG_FUNCTION_NAME; + +#ifndef OMAP_TUNA + snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", ( int ) ( caps.nManualConvMin )); +#endif + params->set(CameraProperties::SUPPORTED_MANUAL_CONVERGENCE_MIN, supported); + +#ifndef OMAP_TUNA + snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", ( int ) ( caps.nManualConvMax )); +#endif + params->set(CameraProperties::SUPPORTED_MANUAL_CONVERGENCE_MAX, supported); + +#ifndef OMAP_TUNA + snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", ( int ) ( caps.nManualConvMax != caps.nManualConvMin )); +#endif + params->set(CameraProperties::SUPPORTED_MANUAL_CONVERGENCE_STEP, supported); + + LOG_FUNCTION_NAME_EXIT; + + return ret; +} + +#ifndef OMAP_TUNA +status_t OMXCameraAdapter::insertMechanicalMisalignmentCorrection(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ + LOG_FUNCTION_NAME; + + params->set(CameraProperties::MECHANICAL_MISALIGNMENT_CORRECTION_SUPPORTED, + caps.bMechanicalMisalignmentSupported == OMX_TRUE ? + android::CameraParameters::TRUE : android::CameraParameters::FALSE); + + return OK; +} +#endif + +status_t OMXCameraAdapter::insertCaptureModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ + status_t ret = NO_ERROR; + char supported[MAX_PROP_VALUE_LENGTH]; + const char *p; + + LOG_FUNCTION_NAME; + + memset(supported, '\0', sizeof(supported)); + +#ifndef OMAP_TUNA + // 3D mode detect: Misalignment is present only in 3d mode + if (caps.bMechanicalMisalignmentSupported) + { + strncat(supported, TICameraParameters::HIGH_QUALITY_MODE, REMAINING_BYTES(supported)); + strncat(supported, PARAM_SEP, REMAINING_BYTES(supported)); + strncat(supported, TICameraParameters::VIDEO_MODE, REMAINING_BYTES(supported)); + } + else // 2D mode detect: Misalignment is present only in 3d mode + { +#endif + strncat(supported, TICameraParameters::HIGH_QUALITY_MODE, REMAINING_BYTES(supported)); + strncat(supported, PARAM_SEP, REMAINING_BYTES(supported)); + strncat(supported, TICameraParameters::VIDEO_MODE, REMAINING_BYTES(supported)); + strncat(supported, PARAM_SEP, REMAINING_BYTES(supported)); + strncat(supported, TICameraParameters::HIGH_PERFORMANCE_MODE, REMAINING_BYTES(supported)); + strncat(supported, PARAM_SEP, REMAINING_BYTES(supported)); + strncat(supported, TICameraParameters::HIGH_QUALITY_ZSL_MODE, REMAINING_BYTES(supported)); +#ifdef OMAP_ENHANCEMENT_CPCAM + strncat(supported, PARAM_SEP, REMAINING_BYTES(supported)); + strncat(supported, TICameraParameters::CP_CAM_MODE, REMAINING_BYTES(supported)); +#endif + strncat(supported, PARAM_SEP, REMAINING_BYTES(supported)); + strncat(supported, TICameraParameters::ZOOM_BRACKETING, REMAINING_BYTES(supported)); +#ifndef OMAP_TUNA + } +#endif + +#ifndef OMAP_TUNA + for ( unsigned int i = 0 ; i < caps.ulBracketingModesCount; i++ ) { + p = getLUTvalue_OMXtoHAL(caps.eBracketingModes[i], mBracketingModesLUT); + if ( NULL != p ) { + if (supported[0] != '\0') { + strncat(supported, PARAM_SEP, REMAINING_BYTES(supported)); + } + strncat(supported, p, REMAINING_BYTES(supported)); + } + } +#endif + + params->set(CameraProperties::CAP_MODE_VALUES, supported); + + LOG_FUNCTION_NAME_EXIT; + + return ret; +} + +status_t OMXCameraAdapter::insertLayout(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ + status_t ret = NO_ERROR; + char supported[MAX_PROP_VALUE_LENGTH]; + const char *p; + unsigned int i = 0; + + LOG_FUNCTION_NAME; + + memset(supported, '\0', MAX_PROP_VALUE_LENGTH); +#ifndef OMAP_TUNA + for ( unsigned int i = 0 ; i < caps.ulPrvFrameLayoutCount; i++ ) { + p = getLUTvalue_OMXtoHAL(caps.ePrvFrameLayout[i], mLayoutLUT); + if ( NULL != p ) { + if (supported[0] != '\0') { + strncat(supported, PARAM_SEP, 1); + } + strncat(supported, p, MAX_PROP_NAME_LENGTH); + } + } +#endif + params->set(CameraProperties::S3D_PRV_FRAME_LAYOUT_VALUES, supported); + + memset(supported, '\0', MAX_PROP_VALUE_LENGTH); +#ifndef OMAP_TUNA + for ( unsigned int i = 0 ; i < caps.ulCapFrameLayoutCount; i++ ) { + p = getLUTvalue_OMXtoHAL(caps.eCapFrameLayout[i], mLayoutLUT); + if ( NULL != p ) { + if (supported[0] != '\0') { + strncat(supported, PARAM_SEP, 1); + } + strncat(supported, p, MAX_PROP_NAME_LENGTH); + } + } +#endif + params->set(CameraProperties::S3D_CAP_FRAME_LAYOUT_VALUES, supported); + + LOG_FUNCTION_NAME_EXIT; + + return ret; +} + +status_t OMXCameraAdapter::insertVideoSnapshotSupported(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ + status_t ret = NO_ERROR; + + LOG_FUNCTION_NAME; + +#ifndef OMAP_TUNA + if (caps.bStillCapDuringVideoSupported) + { + params->set(CameraProperties::VIDEO_SNAPSHOT_SUPPORTED, android::CameraParameters::TRUE); + } + else + { +#endif + params->set(CameraProperties::VIDEO_SNAPSHOT_SUPPORTED, android::CameraParameters::FALSE); +#ifndef OMAP_TUNA + } +#endif + + LOG_FUNCTION_NAME_EXIT; + + return ret; +} + +status_t OMXCameraAdapter::insertGBCESupported(CameraProperties::Properties* params, + const OMX_TI_CAPTYPE &caps) +{ + status_t ret = NO_ERROR; + + LOG_FUNCTION_NAME; + +#ifndef OMAP_TUNA + if (caps.bGbceSupported) { + params->set(CameraProperties::SUPPORTED_GBCE, + android::CameraParameters::TRUE); + } else { +#endif + params->set(CameraProperties::SUPPORTED_GBCE, + android::CameraParameters::FALSE); +#ifndef OMAP_TUNA + } +#endif + + LOG_FUNCTION_NAME_EXIT; + + return ret; +} + +status_t OMXCameraAdapter::insertGLBCESupported(CameraProperties::Properties* params, + const OMX_TI_CAPTYPE &caps) +{ + status_t ret = NO_ERROR; + + LOG_FUNCTION_NAME; + +#ifndef OMAP_TUNA + if (caps.bGlbceSupported) { + params->set(CameraProperties::SUPPORTED_GLBCE, + android::CameraParameters::TRUE); + } else { +#endif + params->set(CameraProperties::SUPPORTED_GLBCE, + android::CameraParameters::FALSE); +#ifndef OMAP_TUNA + } +#endif + + LOG_FUNCTION_NAME_EXIT; + + return ret; +} + +status_t OMXCameraAdapter::insertDefaults(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ + status_t ret = NO_ERROR; + char *pos, *str, *def; + char temp[MAX_PROP_VALUE_LENGTH]; + + LOG_FUNCTION_NAME; + + /* If default is supported - set it, else - set first supported */ + if (strstr(params->get(CameraProperties::S3D_PRV_FRAME_LAYOUT_VALUES), DEFAULT_S3D_PREVIEW_LAYOUT)) { + strncpy(temp, DEFAULT_S3D_PREVIEW_LAYOUT, MAX_PROP_VALUE_LENGTH - 1); + } else { + strncpy(temp, params->get(CameraProperties::S3D_PRV_FRAME_LAYOUT_VALUES), + MAX_PROP_VALUE_LENGTH - 1); + if ((pos = strstr(temp, PARAM_SEP))) { + *pos = '\0'; + } + } + params->set(CameraProperties::S3D_PRV_FRAME_LAYOUT, temp); + + if (!strcmp(TICameraParameters::S3D_TB_FULL, temp)) { + params->set(CameraProperties::SUPPORTED_PREVIEW_SIZES, params->get(CameraProperties::SUPPORTED_PREVIEW_TOPBOTTOM_SIZES)); + } else if (!strcmp(TICameraParameters::S3D_SS_FULL, temp)) { + params->set(CameraProperties::SUPPORTED_PREVIEW_SIZES, params->get(CameraProperties::SUPPORTED_PREVIEW_SIDEBYSIDE_SIZES)); + } else if ((!strcmp(TICameraParameters::S3D_TB_SUBSAMPLED, temp)) + || (!strcmp(TICameraParameters::S3D_SS_SUBSAMPLED, temp))) { + params->set(CameraProperties::SUPPORTED_PREVIEW_SIZES, params->get(CameraProperties::SUPPORTED_PREVIEW_SUBSAMPLED_SIZES)); + } + + /* If default is supported - set it, else - set first supported */ + if (strstr(params->get(CameraProperties::S3D_CAP_FRAME_LAYOUT_VALUES), DEFAULT_S3D_PICTURE_LAYOUT)) { + strncpy(temp, DEFAULT_S3D_PICTURE_LAYOUT, MAX_PROP_VALUE_LENGTH - 1); + } else { + strncpy(temp, params->get(CameraProperties::S3D_CAP_FRAME_LAYOUT_VALUES), + MAX_PROP_VALUE_LENGTH - 1); + if ((pos = strstr(temp, PARAM_SEP))) { + *pos = '\0'; + } + } + params->set(CameraProperties::S3D_CAP_FRAME_LAYOUT, temp); + + if (!strcmp(TICameraParameters::S3D_TB_FULL, temp)) { + params->set(CameraProperties::SUPPORTED_PICTURE_SIZES, params->get(CameraProperties::SUPPORTED_PICTURE_TOPBOTTOM_SIZES)); + } else if (!strcmp(TICameraParameters::S3D_SS_FULL, temp)) { + params->set(CameraProperties::SUPPORTED_PICTURE_SIZES, params->get(CameraProperties::SUPPORTED_PICTURE_SIDEBYSIDE_SIZES)); + } else if ((!strcmp(TICameraParameters::S3D_TB_SUBSAMPLED, temp)) + || (!strcmp(TICameraParameters::S3D_SS_SUBSAMPLED, temp))) { + params->set(CameraProperties::SUPPORTED_PICTURE_SIZES, params->get(CameraProperties::SUPPORTED_PICTURE_SUBSAMPLED_SIZES)); + } + params->set(CameraProperties::ANTIBANDING, DEFAULT_ANTIBANDING); params->set(CameraProperties::BRIGHTNESS, DEFAULT_BRIGHTNESS); params->set(CameraProperties::CONTRAST, DEFAULT_CONTRAST); @@ -1024,7 +1964,7 @@ status_t OMXCameraAdapter::insertDefaults(CameraProperties::Properties* params, params->set(CameraProperties::SUPPORTED_EV_STEP, DEFAULT_EV_STEP); params->set(CameraProperties::EXPOSURE_MODE, DEFAULT_EXPOSURE_MODE); params->set(CameraProperties::FLASH_MODE, DEFAULT_FLASH_MODE); - char *pos = strstr(params->get(CameraProperties::SUPPORTED_FOCUS_MODES), DEFAULT_FOCUS_MODE_PREFERRED); + pos = strstr(params->get(CameraProperties::SUPPORTED_FOCUS_MODES), DEFAULT_FOCUS_MODE_PREFERRED); if ( NULL != pos ) { params->set(CameraProperties::FOCUS_MODE, DEFAULT_FOCUS_MODE_PREFERRED); @@ -1034,81 +1974,99 @@ status_t OMXCameraAdapter::insertDefaults(CameraProperties::Properties* params, params->set(CameraProperties::FOCUS_MODE, DEFAULT_FOCUS_MODE); } params->set(CameraProperties::IPP, DEFAULT_IPP); - params->set(CameraProperties::GBCE, DEFAULT_GBCE); + params->set(CameraProperties::GBCE, android::CameraParameters::FALSE); + params->set(CameraProperties::GLBCE, android::CameraParameters::FALSE); params->set(CameraProperties::ISO_MODE, DEFAULT_ISO_MODE); params->set(CameraProperties::JPEG_QUALITY, DEFAULT_JPEG_QUALITY); params->set(CameraProperties::JPEG_THUMBNAIL_QUALITY, DEFAULT_THUMBNAIL_QUALITY); params->set(CameraProperties::JPEG_THUMBNAIL_SIZE, DEFAULT_THUMBNAIL_SIZE); params->set(CameraProperties::PICTURE_FORMAT, DEFAULT_PICTURE_FORMAT); - params->set(CameraProperties::PICTURE_SIZE, DEFAULT_PICTURE_SIZE); + + if (!strcmp(params->get(CameraProperties::S3D_CAP_FRAME_LAYOUT), + TICameraParameters::S3D_TB_FULL)) { + params->set(CameraProperties::PICTURE_SIZE, DEFAULT_PICTURE_TB_SIZE); + } else if (!strcmp(params->get(CameraProperties::S3D_CAP_FRAME_LAYOUT), + TICameraParameters::S3D_SS_FULL)) { + params->set(CameraProperties::PICTURE_SIZE, DEFAULT_PICTURE_SS_SIZE); + } else { + params->set(CameraProperties::PICTURE_SIZE, DEFAULT_PICTURE_SIZE); + } + + if (!strcmp(params->get(CameraProperties::S3D_PRV_FRAME_LAYOUT), + TICameraParameters::S3D_TB_FULL)) { + params->set(CameraProperties::PREVIEW_SIZE, DEFAULT_PREVIEW_TB_SIZE); + } else if (!strcmp(params->get(CameraProperties::S3D_PRV_FRAME_LAYOUT), + TICameraParameters::S3D_SS_FULL)) { + params->set(CameraProperties::PREVIEW_SIZE, DEFAULT_PREVIEW_SS_SIZE); + } else { + params->set(CameraProperties::PREVIEW_SIZE, DEFAULT_PREVIEW_SIZE); + } + params->set(CameraProperties::PREVIEW_FORMAT, DEFAULT_PREVIEW_FORMAT); - params->set(CameraProperties::PREVIEW_FRAME_RATE, DEFAULT_FRAMERATE); - params->set(CameraProperties::PREVIEW_SIZE, DEFAULT_PREVIEW_SIZE); + + /* Set default value if supported, otherwise set max supported value */ + strncpy(temp, params->get(CameraProperties::SUPPORTED_PREVIEW_FRAME_RATES), + MAX_PROP_VALUE_LENGTH - 1); + def = str = temp; + while (1) { + if ((pos = strstr(str, PARAM_SEP))) { + *pos = '\0'; + } + if (!strcmp(str, DEFAULT_FRAMERATE)) { + def = str; + break; + } + if (atoi(str) > atoi(def)) { + def = str; + } + if (pos == NULL) { + break; + } + str = pos + strlen(PARAM_SEP); + } + params->set(CameraProperties::PREVIEW_FRAME_RATE, def); + params->set(CameraProperties::REQUIRED_PREVIEW_BUFS, DEFAULT_NUM_PREV_BUFS); params->set(CameraProperties::REQUIRED_IMAGE_BUFS, DEFAULT_NUM_PIC_BUFS); params->set(CameraProperties::SATURATION, DEFAULT_SATURATION); params->set(CameraProperties::SCENE_MODE, DEFAULT_SCENE_MODE); params->set(CameraProperties::SHARPNESS, DEFAULT_SHARPNESS); params->set(CameraProperties::VSTAB, DEFAULT_VSTAB); - params->set(CameraProperties::VSTAB_SUPPORTED, DEFAULT_VSTAB_SUPPORTED); + params->set(CameraProperties::VNF, DEFAULT_VNF); params->set(CameraProperties::WHITEBALANCE, DEFAULT_WB); params->set(CameraProperties::ZOOM, DEFAULT_ZOOM); params->set(CameraProperties::MAX_FD_HW_FACES, DEFAULT_MAX_FD_HW_FACES); params->set(CameraProperties::MAX_FD_SW_FACES, DEFAULT_MAX_FD_SW_FACES); params->set(CameraProperties::AUTO_EXPOSURE_LOCK, DEFAULT_AE_LOCK); params->set(CameraProperties::AUTO_WHITEBALANCE_LOCK, DEFAULT_AWB_LOCK); - if(caps.tSenMounting.nSenId == 305) { - params->set(CameraProperties::FOCAL_LENGTH, DEFAULT_FOCAL_LENGTH_PRIMARY); - } else { - params->set(CameraProperties::FOCAL_LENGTH, DEFAULT_FOCAL_LENGTH_SECONDARY); - } params->set(CameraProperties::HOR_ANGLE, DEFAULT_HOR_ANGLE); params->set(CameraProperties::VER_ANGLE, DEFAULT_VER_ANGLE); - params->set(CameraProperties::VIDEO_SNAPSHOT_SUPPORTED, DEFAULT_VIDEO_SNAPSHOT_SUPPORTED); params->set(CameraProperties::VIDEO_SIZE, DEFAULT_VIDEO_SIZE); - params->set(CameraProperties::PREFERRED_PREVIEW_SIZE_FOR_VIDEO, DEFAULT_PREFERRED_PREVIEW_SIZE_FOR_VIDEO); + params->set(CameraProperties::SENSOR_ORIENTATION, DEFAULT_SENSOR_ORIENTATION); + params->set(CameraProperties::AUTOCONVERGENCE_MODE, DEFAULT_AUTOCONVERGENCE_MODE); + params->set(CameraProperties::MANUAL_CONVERGENCE, DEFAULT_MANUAL_CONVERGENCE); + params->set(CameraProperties::MECHANICAL_MISALIGNMENT_CORRECTION, DEFAULT_MECHANICAL_MISALIGNMENT_CORRECTION_MODE); + + char property[PROPERTY_VALUE_MAX]; + property_get("ro.product.manufacturer", + property, + DEFAULT_EXIF_MAKE); + property[0] = toupper(property[0]); + params->set(CameraProperties::EXIF_MAKE, property); + property_get("ro.product.model", + property, + DEFAULT_EXIF_MODEL); + property[0] = toupper(property[0]); + params->set(CameraProperties::EXIF_MODEL, property); - LOG_FUNCTION_NAME; - - return ret; -} - -status_t OMXCameraAdapter::insertSenMount(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; - const char *p; - unsigned int i = 0; - - LOG_FUNCTION_NAME; - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - - // 1) Look up and assign sensor name - for (i = 0; i < ARRAY_SIZE(mSensorNames); i++) { - if(mSensorNames[i].num == caps.tSenMounting.nSenId) { - // sensor found - break; - } - } - if ( i == ARRAY_SIZE(mSensorNames) ) { - p = "UNKNOWN_SENSOR"; - } else { - p = mSensorNames[i].param; - } - strncat(supported, p, MAX_PROP_NAME_LENGTH); - params->set(CameraProperties::CAMERA_NAME, supported); - - // 2) Assign mounting rotation - params->set(CameraProperties::ORIENTATION_INDEX, caps.tSenMounting.nRotation); - - LOG_FUNCTION_NAME; + LOG_FUNCTION_NAME_EXIT; return ret; } -status_t OMXCameraAdapter::insertCapabilities(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { +status_t OMXCameraAdapter::insertCapabilities(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) +{ status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; LOG_FUNCTION_NAME; @@ -1141,10 +2099,6 @@ status_t OMXCameraAdapter::insertCapabilities(CameraProperties::Properties* para } if ( NO_ERROR == ret ) { - ret = insertVFramerates(params, caps); - } - - if ( NO_ERROR == ret ) { ret = insertEVs(params, caps); } @@ -1169,6 +2123,10 @@ status_t OMXCameraAdapter::insertCapabilities(CameraProperties::Properties* para } if ( NO_ERROR == ret ) { + ret = insertManualExpRanges(params, caps); + } + + if ( NO_ERROR == ret ) { ret = insertFlashModes(params, caps); } @@ -1191,46 +2149,368 @@ status_t OMXCameraAdapter::insertCapabilities(CameraProperties::Properties* para if ( NO_ERROR == ret ) { ret = insertLocks(params, caps); } + if ( NO_ERROR == ret) { ret = insertAreas(params, caps); + } + + if ( NO_ERROR == ret) { + ret = insertFacing(params, caps); + } + + if ( NO_ERROR == ret) { + ret = insertFocalLength(params, caps); + } + + if ( NO_ERROR == ret) { + ret = insertAutoConvergenceModes(params, caps); + } + if ( NO_ERROR == ret) { + ret = insertManualConvergenceRange(params, caps); + } + +#ifndef OMAP_TUNA + if ( NO_ERROR == ret) { + ret = insertMechanicalMisalignmentCorrection(params, caps); + } +#endif + + if ( NO_ERROR == ret) { + ret = insertRaw(params, caps); + } + + if ( NO_ERROR == ret) { + ret = insertCaptureModes(params, caps); + } + + if ( NO_ERROR == ret) { + ret = insertLayout(params, caps); + } + + if ( NO_ERROR == ret) { + ret = insertVideoSnapshotSupported(params, caps); + } + + if ( NO_ERROR == ret ) { + ret = insertVSTABSupported(params, caps); + } + + if ( NO_ERROR == ret) { + ret = insertVNFSupported(params, caps); } //NOTE: Ensure that we always call insertDefaults after inserting the supported capabilities //as there are checks inside insertDefaults to make sure a certain default is supported // or not if ( NO_ERROR == ret ) { - ret = insertVideoSizes(params, caps); + ret = insertVideoSizes(params, caps); } - if ( NO_ERROR == ret ) { - ret = insertDefaults(params, caps); + if ( NO_ERROR == ret) { + ret = insertGBCESupported(params, caps); } + if ( NO_ERROR == ret) { + ret = insertGLBCESupported(params, caps); + } + if ( NO_ERROR == ret ) { + ret = insertDefaults(params, caps); + } LOG_FUNCTION_NAME_EXIT; return ret; } + +bool OMXCameraAdapter::_checkOmxTiCap(const OMX_TI_CAPTYPE & caps) +{ +#define CAMHAL_CHECK_OMX_TI_CAP(countVar, arrayVar) \ + do { \ + const int count = static_cast<int>(caps.countVar); \ + const int maxSize = CAMHAL_SIZE_OF_ARRAY(caps.arrayVar); \ + if ( count < 0 || count > maxSize ) \ + { \ + CAMHAL_LOGE("OMX_TI_CAPTYPE verification failed"); \ + CAMHAL_LOGE(" variable: OMX_TI_CAPTYPE::" #countVar \ + ", value: %d, max allowed: %d", \ + count, maxSize); \ + return false; \ + } \ + } while (0) + + CAMHAL_CHECK_OMX_TI_CAP(ulPreviewFormatCount, ePreviewFormats); + CAMHAL_CHECK_OMX_TI_CAP(ulImageFormatCount, eImageFormats); + CAMHAL_CHECK_OMX_TI_CAP(ulWhiteBalanceCount, eWhiteBalanceModes); + CAMHAL_CHECK_OMX_TI_CAP(ulColorEffectCount, eColorEffects); + CAMHAL_CHECK_OMX_TI_CAP(ulFlickerCount, eFlicker); + CAMHAL_CHECK_OMX_TI_CAP(ulExposureModeCount, eExposureModes); + CAMHAL_CHECK_OMX_TI_CAP(ulFocusModeCount, eFocusModes); + CAMHAL_CHECK_OMX_TI_CAP(ulSceneCount, eSceneModes); + CAMHAL_CHECK_OMX_TI_CAP(ulFlashCount, eFlashModes); + CAMHAL_CHECK_OMX_TI_CAP(ulPrvVarFPSModesCount, tPrvVarFPSModes); + CAMHAL_CHECK_OMX_TI_CAP(ulCapVarFPSModesCount, tCapVarFPSModes); +#ifndef OMAP_TUNA + CAMHAL_CHECK_OMX_TI_CAP(ulAutoConvModesCount, eAutoConvModes); + CAMHAL_CHECK_OMX_TI_CAP(ulBracketingModesCount, eBracketingModes); + CAMHAL_CHECK_OMX_TI_CAP(ulImageCodingFormatCount, eImageCodingFormat); + CAMHAL_CHECK_OMX_TI_CAP(ulPrvFrameLayoutCount, ePrvFrameLayout); + CAMHAL_CHECK_OMX_TI_CAP(ulCapFrameLayoutCount, eCapFrameLayout); +#endif + +#undef CAMHAL_CHECK_OMX_TI_CAP + + return true; +} + + +bool OMXCameraAdapter::_dumpOmxTiCap(const int sensorId, const OMX_TI_CAPTYPE & caps) +{ + if ( !_checkOmxTiCap(caps) ) + { + CAMHAL_LOGE("OMX_TI_CAPTYPE structure is invalid"); + return false; + } + + CAMHAL_LOGD("==================================================="); + CAMHAL_LOGD("---- Dumping OMX capabilities for sensor id: %d ----", sensorId); + + CAMHAL_LOGD(""); + CAMHAL_LOGD("ulPreviewFormatCount = %d", int(caps.ulPreviewFormatCount)); + for ( int i = 0; i < int(caps.ulPreviewFormatCount); ++i ) + CAMHAL_LOGD(" ePreviewFormats[%2d] = %d", i, int(caps.ePreviewFormats[i])); + + CAMHAL_LOGD(""); + CAMHAL_LOGD("ulImageFormatCount = %d", int(caps.ulImageFormatCount)); + for ( int i = 0; i < int(caps.ulImageFormatCount); ++i ) + CAMHAL_LOGD(" eImageFormats[%2d] = %d", i, int(caps.eImageFormats[i])); + + CAMHAL_LOGD(""); + CAMHAL_LOGD("tPreviewResRange.nWidthMin = %d", int(caps.tPreviewResRange.nWidthMin)); + CAMHAL_LOGD("tPreviewResRange.nHeightMin = %d", int(caps.tPreviewResRange.nHeightMin)); + CAMHAL_LOGD("tPreviewResRange.nWidthMax = %d", int(caps.tPreviewResRange.nWidthMax)); + CAMHAL_LOGD("tPreviewResRange.nHeightMax = %d", int(caps.tPreviewResRange.nHeightMax)); + CAMHAL_LOGD("tPreviewResRange.nMaxResInPixels = %d", int(caps.tPreviewResRange.nMaxResInPixels)); + +#ifndef OMAP_TUNA + CAMHAL_LOGD(""); + CAMHAL_LOGD("tRotatedPreviewResRange.nWidthMin = %d", int(caps.tRotatedPreviewResRange.nWidthMin)); + CAMHAL_LOGD("tRotatedPreviewResRange.nHeightMin = %d", int(caps.tRotatedPreviewResRange.nHeightMin)); + CAMHAL_LOGD("tRotatedPreviewResRange.nWidthMax = %d", int(caps.tRotatedPreviewResRange.nWidthMax)); + CAMHAL_LOGD("tRotatedPreviewResRange.nHeightMax = %d", int(caps.tRotatedPreviewResRange.nHeightMax)); + CAMHAL_LOGD("tRotatedPreviewResRange.nMaxResInPixels = %d", int(caps.tRotatedPreviewResRange.nMaxResInPixels)); +#endif + + CAMHAL_LOGD(""); + CAMHAL_LOGD("tImageResRange.nWidthMin = %d", int(caps.tImageResRange.nWidthMin)); + CAMHAL_LOGD("tImageResRange.nHeightMin = %d", int(caps.tImageResRange.nHeightMin)); + CAMHAL_LOGD("tImageResRange.nWidthMax = %d", int(caps.tImageResRange.nWidthMax)); + CAMHAL_LOGD("tImageResRange.nHeightMax = %d", int(caps.tImageResRange.nHeightMax)); + CAMHAL_LOGD("tImageResRange.nMaxResInPixels = %d", int(caps.tImageResRange.nMaxResInPixels)); + + CAMHAL_LOGD(""); + CAMHAL_LOGD("tThumbResRange.nWidthMin = %d", int(caps.tThumbResRange.nWidthMin)); + CAMHAL_LOGD("tThumbResRange.nHeightMin = %d", int(caps.tThumbResRange.nHeightMin)); + CAMHAL_LOGD("tThumbResRange.nWidthMax = %d", int(caps.tThumbResRange.nWidthMax)); + CAMHAL_LOGD("tThumbResRange.nHeightMax = %d", int(caps.tThumbResRange.nHeightMax)); + CAMHAL_LOGD("tThumbResRange.nMaxResInPixels = %d", int(caps.tThumbResRange.nMaxResInPixels)); + + CAMHAL_LOGD(""); + CAMHAL_LOGD("ulWhiteBalanceCount = %d", int(caps.ulWhiteBalanceCount)); + for ( int i = 0; i < int(caps.ulWhiteBalanceCount); ++i ) + CAMHAL_LOGD(" eWhiteBalanceModes[%2d] = 0x%08x", i, int(caps.eWhiteBalanceModes[i])); + + CAMHAL_LOGD(""); + CAMHAL_LOGD("ulColorEffectCount = %d", int(caps.ulColorEffectCount)); + for ( int i = 0; i < int(caps.ulColorEffectCount); ++i ) + CAMHAL_LOGD(" eColorEffects[%2d] = 0x%08x", i, int(caps.eColorEffects[i])); + + CAMHAL_LOGD(""); + CAMHAL_LOGD("xMaxWidthZoom = %d", int(caps.xMaxWidthZoom)); + CAMHAL_LOGD("xMaxHeightZoom = %d", int(caps.xMaxHeightZoom)); + + CAMHAL_LOGD(""); + CAMHAL_LOGD("ulFlickerCount = %d", int(caps.ulFlickerCount)); + for ( int i = 0; i < int(caps.ulFlickerCount); ++i ) + CAMHAL_LOGD(" eFlicker[%2d] = %d", i, int(caps.eFlicker[i])); + + CAMHAL_LOGD(""); + CAMHAL_LOGD("ulExposureModeCount = %d", int(caps.ulExposureModeCount)); + for ( int i = 0; i < int(caps.ulExposureModeCount); ++i ) + CAMHAL_LOGD(" eExposureModes[%2d] = 0x%08x", i, int(caps.eExposureModes[i])); + + CAMHAL_LOGD(""); + CAMHAL_LOGD("bLensDistortionCorrectionSupported = %d", int(caps.bLensDistortionCorrectionSupported)); + CAMHAL_LOGD("bISONoiseFilterSupported = %d", int(caps.bISONoiseFilterSupported)); + CAMHAL_LOGD("xEVCompensationMin = %d", int(caps.xEVCompensationMin)); + CAMHAL_LOGD("xEVCompensationMax = %d", int(caps.xEVCompensationMax)); + CAMHAL_LOGD("nSensitivityMax = %d", int(caps.nSensitivityMax)); + + CAMHAL_LOGD(""); + CAMHAL_LOGD("ulFocusModeCount = %d", int(caps.ulFocusModeCount)); + for ( int i = 0; i < int(caps.ulFocusModeCount); ++i ) + CAMHAL_LOGD(" eFocusModes[%2d] = 0x%08x", i, int(caps.eFocusModes[i])); + + CAMHAL_LOGD(""); + CAMHAL_LOGD("ulSceneCount = %d", int(caps.ulSceneCount)); + for ( int i = 0; i < int(caps.ulSceneCount); ++i ) + CAMHAL_LOGD(" eSceneModes[%2d] = %d", i, int(caps.eSceneModes[i])); + + CAMHAL_LOGD(""); + CAMHAL_LOGD("ulFlashCount = %d", int(caps.ulFlashCount)); + for ( int i = 0; i < int(caps.ulFlashCount); ++i ) + CAMHAL_LOGD(" eFlashModes[%2d] = %d", i, int(caps.eFlashModes[i])); + + CAMHAL_LOGD("xFramerateMin = %d", int(caps.xFramerateMin)); + CAMHAL_LOGD("xFramerateMax = %d", int(caps.xFramerateMax)); + CAMHAL_LOGD("bContrastSupported = %d", int(caps.bContrastSupported)); + CAMHAL_LOGD("bSaturationSupported = %d", int(caps.bSaturationSupported)); + CAMHAL_LOGD("bBrightnessSupported = %d", int(caps.bBrightnessSupported)); + CAMHAL_LOGD("bProcessingLevelSupported = %d", int(caps.bProcessingLevelSupported)); + CAMHAL_LOGD("bQFactorSupported = %d", int(caps.bQFactorSupported)); + + CAMHAL_LOGD(""); + CAMHAL_LOGD("ulPrvVarFPSModesCount = %d", int(caps.ulPrvVarFPSModesCount)); + for ( int i = 0; i < int(caps.ulPrvVarFPSModesCount); ++i ) + { + CAMHAL_LOGD(" tPrvVarFPSModes[%d].nVarFPSMin = %d", i, int(caps.tPrvVarFPSModes[i].nVarFPSMin)); + CAMHAL_LOGD(" tPrvVarFPSModes[%d].nVarFPSMax = %d", i, int(caps.tPrvVarFPSModes[i].nVarFPSMax)); + } + + CAMHAL_LOGD(""); + CAMHAL_LOGD("ulCapVarFPSModesCount = %d", int(caps.ulCapVarFPSModesCount)); + for ( int i = 0; i < int(caps.ulCapVarFPSModesCount); ++i ) + { + CAMHAL_LOGD(" tCapVarFPSModes[%d].nVarFPSMin = %d", i, int(caps.tCapVarFPSModes[i].nVarFPSMin)); + CAMHAL_LOGD(" tCapVarFPSModes[%d].nVarFPSMax = %d", i, int(caps.tCapVarFPSModes[i].nVarFPSMax)); + } + + CAMHAL_LOGD(""); + CAMHAL_LOGD("tSenMounting.nSenId = %d", int(caps.tSenMounting.nSenId)); + CAMHAL_LOGD("tSenMounting.nRotation = %d", int(caps.tSenMounting.nRotation)); + CAMHAL_LOGD("tSenMounting.bMirror = %d", int(caps.tSenMounting.bMirror)); + CAMHAL_LOGD("tSenMounting.bFlip = %d", int(caps.tSenMounting.bFlip)); + CAMHAL_LOGD("tSenMounting.eFacing = %d", int(caps.tSenMounting.eFacing)); + +#ifndef OMAP_TUNA + CAMHAL_LOGD(""); + CAMHAL_LOGD("ulAutoConvModesCount = %d", int(caps.ulAutoConvModesCount)); + for ( int i = 0; i < int(caps.ulAutoConvModesCount); ++i ) + CAMHAL_LOGD(" eAutoConvModes[%2d] = %d", i, int(caps.eAutoConvModes[i])); + + CAMHAL_LOGD(""); + CAMHAL_LOGD("ulBracketingModesCount = %d", int(caps.ulBracketingModesCount)); + for ( int i = 0; i < int(caps.ulBracketingModesCount); ++i ) + CAMHAL_LOGD(" eBracketingModes[%2d] = %d", i, int(caps.eBracketingModes[i])); +#endif + + CAMHAL_LOGD(""); +#ifndef OMAP_TUNA + CAMHAL_LOGD("bGbceSupported = %d", int(caps.bGbceSupported)); +#endif + CAMHAL_LOGD("bRawJpegSupported = %d", int(caps.bRawJpegSupported)); + +#ifndef OMAP_TUNA + CAMHAL_LOGD(""); + CAMHAL_LOGD("ulImageCodingFormatCount = %d", int(caps.ulImageCodingFormatCount)); + for ( int i = 0; i < int(caps.ulImageCodingFormatCount); ++i ) + CAMHAL_LOGD(" eImageCodingFormat[%2d] = %d", i, int(caps.eImageCodingFormat[i])); +#endif + + CAMHAL_LOGD(""); +#ifndef OMAP_TUNA + CAMHAL_LOGD("uSenNativeResWidth = %d", int(caps.uSenNativeResWidth)); + CAMHAL_LOGD("uSenNativeResHeight = %d", int(caps.uSenNativeResHeight)); +#endif + CAMHAL_LOGD("ulAlgoAreasFocusCount = %d", int(caps.ulAlgoAreasFocusCount)); + CAMHAL_LOGD("ulAlgoAreasExposureCount = %d", int(caps.ulAlgoAreasExposureCount)); +#ifndef OMAP_TUNA + CAMHAL_LOGD("bAELockSupported = %d", int(caps.bAELockSupported)); + CAMHAL_LOGD("bAWBLockSupported = %d", int(caps.bAWBLockSupported)); +#endif + CAMHAL_LOGD("bAFLockSupported = %d", int(caps.bAFLockSupported)); +#ifndef OMAP_TUNA + CAMHAL_LOGD("nFocalLength = %d", int(caps.nFocalLength)); +#endif + +#ifndef OMAP_TUNA + CAMHAL_LOGD(""); + CAMHAL_LOGD("ulPrvFrameLayoutCount = %d", int(caps.ulPrvFrameLayoutCount)); + for ( int i = 0; i < int(caps.ulPrvFrameLayoutCount); ++i ) + CAMHAL_LOGD(" ePrvFrameLayout[%2d] = %d", i, int(caps.ePrvFrameLayout[i])); + + CAMHAL_LOGD(""); + CAMHAL_LOGD("ulCapFrameLayoutCount = %d", int(caps.ulCapFrameLayoutCount)); + for ( int i = 0; i < int(caps.ulCapFrameLayoutCount); ++i ) + CAMHAL_LOGD(" eCapFrameLayout[%2d] = %d", i, int(caps.eCapFrameLayout[i])); +#endif + + CAMHAL_LOGD(""); +#ifndef OMAP_TUNA + CAMHAL_LOGD("bVideoNoiseFilterSupported = %d", int(caps.bVideoNoiseFilterSupported )); + CAMHAL_LOGD("bVideoStabilizationSupported = %d", int(caps.bVideoStabilizationSupported )); +#endif + CAMHAL_LOGD("bStillCapDuringVideoSupported = %d", int(caps.bStillCapDuringVideoSupported )); +#ifndef OMAP_TUNA + CAMHAL_LOGD("bMechanicalMisalignmentSupported = %d", int(caps.bMechanicalMisalignmentSupported)); +#endif + CAMHAL_LOGD("bFacePrioritySupported = %d", int(caps.bFacePrioritySupported )); + CAMHAL_LOGD("bRegionPrioritySupported = %d", int(caps.bRegionPrioritySupported )); +#ifndef OMAP_TUNA + CAMHAL_LOGD("bGlbceSupported = %d", int(caps.bGlbceSupported)); +#endif + + CAMHAL_LOGD(""); +#ifndef OMAP_TUNA + CAMHAL_LOGD("nManualConvMin = %d", int(caps.nManualConvMin )); + CAMHAL_LOGD("nManualConvMax = %d", int(caps.nManualConvMax )); + CAMHAL_LOGD("nManualExpMin = %d", int(caps.nManualExpMin )); + CAMHAL_LOGD("nManualExpMax = %d", int(caps.nManualExpMax )); +#endif + CAMHAL_LOGD("nBrightnessMin = %d", int(caps.nBrightnessMin )); + CAMHAL_LOGD("nBrightnessMax = %d", int(caps.nBrightnessMax )); + CAMHAL_LOGD("nContrastMin = %d", int(caps.nContrastMin )); + CAMHAL_LOGD("nContrastMax = %d", int(caps.nContrastMax )); + CAMHAL_LOGD("nSharpnessMin = %d", int(caps.nSharpnessMin )); + CAMHAL_LOGD("nSharpnessMax = %d", int(caps.nSharpnessMax )); + CAMHAL_LOGD("nSaturationMin = %d", int(caps.nSaturationMin )); + CAMHAL_LOGD("nSaturationMax = %d", int(caps.nSaturationMax )); + + CAMHAL_LOGD(""); + CAMHAL_LOGD("------------------- end of dump -------------------"); + CAMHAL_LOGD("==================================================="); + + return true; +} + /***************************************** * public exposed function declarations *****************************************/ -status_t OMXCameraAdapter::getCaps(CameraProperties::Properties* params, OMX_HANDLETYPE handle) { +status_t OMXCameraAdapter::getCaps(const int sensorId, CameraProperties::Properties* params, OMX_HANDLETYPE handle) +{ status_t ret = NO_ERROR; int caps_size = 0; OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_TI_CAPTYPE** caps = NULL;; + CameraBuffer *bufferlist; + OMX_TI_CAPTYPE* caps; OMX_TI_CONFIG_SHAREDBUFFER sharedBuffer; MemoryManager memMgr; LOG_FUNCTION_NAME; + ret = memMgr.initialize(); + if ( ret != OK ) { + CAMHAL_LOGE("MemoryManager initialization failed, error: %d", ret); + return ret; + } + // allocate tiler (or ion) buffer for caps (size is always a multiple of 4K) caps_size = ((sizeof(OMX_TI_CAPTYPE)+4095)/4096)*4096; - caps = (OMX_TI_CAPTYPE**) memMgr.allocateBuffer(0, 0, NULL, caps_size, 1); + bufferlist = memMgr.allocateBufferList(0, 0, NULL, caps_size, 1); + caps = (OMX_TI_CAPTYPE*) bufferlist[0].opaque; if (!caps) { CAMHAL_LOGEB("Error allocating buffer for caps %d", eError); @@ -1239,13 +2519,13 @@ status_t OMXCameraAdapter::getCaps(CameraProperties::Properties* params, OMX_HAN } // initialize structures to be passed to OMX Camera - OMX_INIT_STRUCT_PTR (caps[0], OMX_TI_CAPTYPE); - caps[0]->nPortIndex = OMX_ALL; + OMX_INIT_STRUCT_PTR (caps, OMX_TI_CAPTYPE); + caps->nPortIndex = OMX_ALL; OMX_INIT_STRUCT_PTR (&sharedBuffer, OMX_TI_CONFIG_SHAREDBUFFER); sharedBuffer.nPortIndex = OMX_ALL; sharedBuffer.nSharedBuffSize = caps_size; - sharedBuffer.pSharedBuff = (OMX_U8 *) caps[0]; + sharedBuffer.pSharedBuff = (OMX_U8 *) camera_buffer_get_omx_ptr (&bufferlist[0]); // Get capabilities from OMX Camera eError = OMX_GetConfig(handle, (OMX_INDEXTYPE) OMX_TI_IndexConfigCamCapabilities, &sharedBuffer); @@ -1257,23 +2537,26 @@ status_t OMXCameraAdapter::getCaps(CameraProperties::Properties* params, OMX_HAN CAMHAL_LOGDA("OMX capability query success"); } +#ifdef CAMERAHAL_DEBUG + _dumpOmxTiCap(sensorId, *caps); +#endif + // Translate and insert Ducati capabilities to CameraProperties if ( NO_ERROR == ret ) { - ret = insertCapabilities(params, *caps[0]); + ret = insertCapabilities(params, *caps); } - CAMHAL_LOGDB("sen mount id=%u", (unsigned int)caps[0]->tSenMounting.nSenId); - + CAMHAL_LOGDB("sen mount id=%u", (unsigned int)caps->tSenMounting.nSenId); + CAMHAL_LOGDB("facing id=%u", (unsigned int)caps->tSenMounting.eFacing); EXIT: - if (caps) { - memMgr.freeBuffer((void*) caps); - caps = NULL; + if (bufferlist) { + memMgr.freeBufferList(bufferlist); } LOG_FUNCTION_NAME_EXIT; return ret; } -}; - +} // namespace Camera +} // namespace Ti |