From 644c7c15cce4e7d84f141236b7ee9362c181a0e9 Mon Sep 17 00:00:00 2001 From: Lajos Molnar Date: Wed, 24 Aug 2011 21:12:52 -0500 Subject: hwc: account for 1 16MB tiler slot instead of 4 4MB one This requires corresponding kernel change that manages TILER1D mappings into 1 large tiler slot. Change-Id: I868e2c252378ef74c343876eb94c15fe549cd2ed Signed-off-by: Lajos Molnar --- hwc/hwc.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/hwc/hwc.c b/hwc/hwc.c index b0d041ea..f35875ea 100644 --- a/hwc/hwc.c +++ b/hwc/hwc.c @@ -43,7 +43,7 @@ #define HAL_PIXEL_FORMAT_BGRX_8888 0x1FF #define HAL_PIXEL_FORMAT_TI_NV12 0x100 #define HAL_PIXEL_FORMAT_TI_NV12_PADDED 0x101 -#define MAX_TILER_SLOT (4 << 20) +#define MAX_TILER_SLOT (16 << 20) #define MIN(a,b) ((a)<(b)?(a):(b)) #define MAX(a,b) ((a)>(b)?(a):(b)) @@ -183,6 +183,16 @@ static int sync_id = 0; #define is_BGR(format) ((format) == HAL_PIXEL_FORMAT_RGBX_8888 || (format) == HAL_PIXEL_FORMAT_RGBA_8888) #define is_NV12(format) ((format) == HAL_PIXEL_FORMAT_TI_NV12 || (format) == HAL_PIXEL_FORMAT_TI_NV12_PADDED) +static unsigned int mem1d(IMG_native_handle_t *handle) +{ + if (handle == NULL) + return 0; + + int bpp = is_NV12(handle->iFormat) ? 0 : (handle->iFormat == HAL_PIXEL_FORMAT_RGB_565 ? 2 : 4); + int stride = ALIGN(handle->iWidth, HW_ALIGN) * bpp; + return stride * handle->iHeight; +} + static void omap4_hwc_setup_layer_base(struct dss2_ovl_cfg *oc, int index, int format, int width, int height) { @@ -428,9 +438,7 @@ static int omap4_hwc_is_valid_layer(hwc_layer_t *layer, if (!is_NV12(handle->iFormat)) { if (layer->transform) return 0; - int bpp = (handle->iFormat == HAL_PIXEL_FORMAT_RGB_565 ? 2 : 4); - int stride = ALIGN(handle->iWidth, HW_ALIGN) * bpp; - if (stride * handle->iHeight > MAX_TILER_SLOT) + if (mem1d(handle) > MAX_TILER_SLOT) return 0; } return 1; @@ -446,6 +454,7 @@ struct counts { unsigned int displays; unsigned int max_hw_overlays; unsigned int max_scaling_overlays; + unsigned int mem; }; static inline int can_dss_render_all(omap4_hwc_device_t *hwc_dev, struct counts *num) @@ -497,6 +506,8 @@ static inline int can_dss_render_all(omap4_hwc_device_t *hwc_dev, struct counts num->possible_overlay_layers <= num->max_hw_overlays && num->possible_overlay_layers == num->composited_layers && num->scaled_layers <= num->max_scaling_overlays && + /* fits into TILER slot */ + num->mem <= MAX_TILER_SLOT && /* we cannot clone non-NV12 transformed layers */ (!tform || num->NV12 == num->possible_overlay_layers) && /* HDMI cannot display BGR */ @@ -555,6 +566,8 @@ static int omap4_hwc_prepare(struct hwc_composer_device *dev, hwc_layer_list_t* num.RGB++; else if (is_NV12(handle->iFormat)) num.NV12++; + + num.mem += mem1d(handle); } } @@ -586,14 +599,17 @@ static int omap4_hwc_prepare(struct hwc_composer_device *dev, hwc_layer_list_t* int ix_nv12 = -1; /* set up if DSS layers */ + unsigned int mem_used = 0; for (i = 0; i < list->numHwLayers && dsscomp->num_ovls < num.max_hw_overlays; i++) { hwc_layer_t *layer = &list->hwLayers[i]; IMG_native_handle_t *handle = (IMG_native_handle_t *)layer->handle; if (can_dss_render_layer(hwc_dev, layer) && + mem_used + mem1d(handle) < MAX_TILER_SLOT && /* can't have a transparent overlay in the middle of the framebuffer stack */ !(is_ALPHA(handle->iFormat) && fb_z >= 0)) { /* render via DSS overlay */ + mem_used += mem1d(handle); layer->compositionType = HWC_OVERLAY; hwc_dev->buffers[dsscomp->num_ovls] = layer->handle; -- cgit v1.2.3 From 9da0da99e24196e363b02a0238ce2a827f008966 Mon Sep 17 00:00:00 2001 From: Lajos Molnar Date: Wed, 31 Aug 2011 17:58:18 -0500 Subject: hwc: fix z-order settings for fb If a hardware layer was sandwiched between framebuffer layers, the z-order of the framebuffer layer was not adjusted. This is now fixed. Change-Id: Ib9eff3e3f1cd14b7c2a1d00ce2b451b04667e09a Signed-off-by: Lajos Molnar --- hwc/hwc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hwc/hwc.c b/hwc/hwc.c index f35875ea..885028d1 100644 --- a/hwc/hwc.c +++ b/hwc/hwc.c @@ -651,6 +651,7 @@ static int omap4_hwc_prepare(struct hwc_composer_device *dev, hwc_layer_list_t* /* move fb z-order up (by lowering dss layers) */ while (fb_zmax < z - 1) dsscomp->ovls[1 + fb_zmax++].cfg.zorder--; + fb_z = fb_zmax; } } } -- cgit v1.2.3 From 99bf99a34483be85c31cde2263e3b68c80745100 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Fri, 2 Sep 2011 11:47:13 -0700 Subject: fix more drawing artifacts caused by hw composer hwc used the pixelformat to determine if a layer was opaque instead of using the blending field. Change-Id: I0e3dba7234639cb75156c6e941bf5e6aa0ecaf8d --- hwc/hwc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hwc/hwc.c b/hwc/hwc.c index c22f85b2..6b69e4be 100644 --- a/hwc/hwc.c +++ b/hwc/hwc.c @@ -178,7 +178,8 @@ static int scaled(hwc_layer_t *layer) static int sync_id = 0; -#define is_ALPHA(format) ((format) == HAL_PIXEL_FORMAT_BGRA_8888 || (format) == HAL_PIXEL_FORMAT_RGBA_8888) +#define is_BLENDED(blending) ((blending) != HWC_BLENDING_NONE) + #define is_RGB(format) ((format) == HAL_PIXEL_FORMAT_BGRA_8888 || (format) == HAL_PIXEL_FORMAT_RGB_565 || (format) == HAL_PIXEL_FORMAT_BGRX_8888) #define is_BGR(format) ((format) == HAL_PIXEL_FORMAT_RGBX_8888 || (format) == HAL_PIXEL_FORMAT_RGBA_8888) #define is_NV12(format) ((format) == HAL_PIXEL_FORMAT_TI_NV12 || (format) == HAL_PIXEL_FORMAT_TI_NV12_PADDED) @@ -607,7 +608,7 @@ static int omap4_hwc_prepare(struct hwc_composer_device *dev, hwc_layer_list_t* if (can_dss_render_layer(hwc_dev, layer) && mem_used + mem1d(handle) < MAX_TILER_SLOT && /* can't have a transparent overlay in the middle of the framebuffer stack */ - !(is_ALPHA(handle->iFormat) && fb_z >= 0)) { + !(is_BLENDED(layer->blending) && fb_z >= 0)) { /* render via DSS overlay */ mem_used += mem1d(handle); layer->compositionType = HWC_OVERLAY; @@ -663,7 +664,7 @@ static int omap4_hwc_prepare(struct hwc_composer_device *dev, hwc_layer_list_t* IMG_native_handle_t *handle = (IMG_native_handle_t *)layer->handle; if ((layer->flags & HWC_SKIP_LAYER) || !layer->handle) continue; - if (!is_ALPHA(handle->iFormat)) + if (!is_BLENDED(layer->blending)) layer->hints |= HWC_HINT_CLEAR_FB; } } -- cgit v1.2.3 From c38fc64ba349d4814ef870d97e1e86f78f4bc325 Mon Sep 17 00:00:00 2001 From: Iliyan Malchev Date: Tue, 6 Sep 2011 16:51:00 -0700 Subject: Revert "CameraHAL : Multiple focus and exposure areas support" This reverts commit bd9754a1b2c8d5e0a8788d0e42d018857bfef7a7. Conflicts: camera/inc/OMXCameraAdapter/OMXCameraAdapter.h Change-Id: Iad51c457b05de9b5492061b8402e508a6c5b42bf --- camera/CameraHal.cpp | 5 - camera/OMXCameraAdapter/OMX3A.cpp | 146 +++---------------------- camera/OMXCameraAdapter/OMXCapabilities.cpp | 31 +----- camera/OMXCameraAdapter/OMXDefaults.cpp | 1 + camera/OMXCameraAdapter/OMXFocus.cpp | 109 ++++-------------- camera/inc/CameraHal.h | 6 - camera/inc/CameraProperties.h | 1 - camera/inc/General3A_Settings.h | 1 - camera/inc/OMXCameraAdapter/OMXCameraAdapter.h | 12 +- 9 files changed, 47 insertions(+), 265 deletions(-) diff --git a/camera/CameraHal.cpp b/camera/CameraHal.cpp index dde21453..cd28c0ab 100644 --- a/camera/CameraHal.cpp +++ b/camera/CameraHal.cpp @@ -827,11 +827,6 @@ int CameraHal::setParameters(const CameraParameters& params) CAMHAL_LOGDB("Auto WhiteBalance Lock set %s", params.get(CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK)); mParameters.set(CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK, valstr); } - if( (valstr = params.get(CameraParameters::KEY_METERING_AREAS)) != NULL ) - { - CAMHAL_LOGEB("Metering areas position set %s", params.get(CameraParameters::KEY_METERING_AREAS)); - mParameters.set(CameraParameters::KEY_METERING_AREAS, valstr); - } CameraParameters adapterParams = mParameters; diff --git a/camera/OMXCameraAdapter/OMX3A.cpp b/camera/OMXCameraAdapter/OMX3A.cpp index cc8f6651..cba5ec68 100644 --- a/camera/OMXCameraAdapter/OMX3A.cpp +++ b/camera/OMXCameraAdapter/OMX3A.cpp @@ -33,8 +33,6 @@ #define TRUE "true" #define FALSE "false" -#define METERING_AREAS_RANGE 0xFF - namespace android { status_t OMXCameraAdapter::setParameters3A(const CameraParameters ¶ms, @@ -262,30 +260,6 @@ status_t OMXCameraAdapter::setParameters3A(const CameraParameters ¶ms, } } - str = params.get(CameraParameters::KEY_METERING_AREAS); - if ( (str != NULL) ) - { - size_t MAX_METERING_AREAS; - MAX_METERING_AREAS = atoi(params.get(CameraParameters::KEY_MAX_NUM_METERING_AREAS)); - - mMeteringAreas.clear(); - - CameraArea::parseFocusArea(str, strlen(str), mMeteringAreas); - - if ( MAX_METERING_AREAS > mMeteringAreas.size() ) - { - CAMHAL_LOGDB("Setting Metering Areas %s", - params.get(CameraParameters::KEY_METERING_AREAS)); - - mPending3Asettings |= SetMeteringAreas; - } - else - { - CAMHAL_LOGEB("Metering areas supported %d, metering areas set %d", - MAX_METERING_AREAS, mMeteringAreas.size()); - } - } - LOG_FUNCTION_NAME_EXIT; return ret; @@ -505,7 +479,21 @@ status_t OMXCameraAdapter::setFocusMode(Gen3A_settings& Gen3A) //Enable region algorithm priority setAlgoPriority(REGION_PRIORITY, FOCUS_ALGO, true); - setTouchFocus(); + //Set position + OMXCameraPortParameters * mPreviewData = NULL; + mPreviewData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex]; + focusArea->transfrom(mPreviewData->mWidth, + mPreviewData->mHeight, + top, + left, + width, + height); + setTouchFocus(left, + top, + width, + height, + mPreviewData->mWidth, + mPreviewData->mHeight); //Do normal focus afterwards //FIXME: Check if the extended focus control is needed? this overrides caf @@ -1086,106 +1074,6 @@ status_t OMXCameraAdapter::set3ALock(OMX_BOOL toggle) } -status_t OMXCameraAdapter::setMeteringAreas(Gen3A_settings& Gen3A) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - - OMX_ALGOAREASTYPE **meteringAreas; - OMX_TI_CONFIG_SHAREDBUFFER sharedBuffer; - MemoryManager memMgr; - int areasSize = 0; - - LOG_FUNCTION_NAME - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - areasSize = ((sizeof(OMX_ALGOAREASTYPE)+4095)/4096)*4096; - meteringAreas = (OMX_ALGOAREASTYPE**) memMgr.allocateBuffer(0, 0, NULL, areasSize, 1); - - OMXCameraPortParameters * mPreviewData = NULL; - mPreviewData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex]; - - if (!meteringAreas) - { - CAMHAL_LOGEB("Error allocating buffer for metering areas %d", eError); - return -ENOMEM; - } - - OMX_INIT_STRUCT_PTR (meteringAreas[0], OMX_ALGOAREASTYPE); - - meteringAreas[0]->nPortIndex = OMX_ALL; - meteringAreas[0]->nNumAreas = mMeteringAreas.size(); - meteringAreas[0]->nAlgoAreaPurpose = OMX_AlgoAreaExposure; - - for ( unsigned int n = 0; n < mMeteringAreas.size(); n++) - { - // transform the coordinates to 3A-type coordinates - mMeteringAreas.itemAt(n)->transfrom((size_t)mPreviewData->mWidth, - (size_t)mPreviewData->mHeight, - (size_t&)meteringAreas[0]->tAlgoAreas[n].nTop, - (size_t&)meteringAreas[0]->tAlgoAreas[n].nLeft, - (size_t&)meteringAreas[0]->tAlgoAreas[n].nWidth, - (size_t&)meteringAreas[0]->tAlgoAreas[n].nHeight); - - meteringAreas[0]->tAlgoAreas[n].nLeft = - ( meteringAreas[0]->tAlgoAreas[n].nLeft * METERING_AREAS_RANGE ) / mPreviewData->mWidth; - meteringAreas[0]->tAlgoAreas[n].nTop = - ( meteringAreas[0]->tAlgoAreas[n].nTop* METERING_AREAS_RANGE ) / mPreviewData->mHeight; - meteringAreas[0]->tAlgoAreas[n].nWidth = - ( meteringAreas[0]->tAlgoAreas[n].nWidth * METERING_AREAS_RANGE ) / mPreviewData->mWidth; - meteringAreas[0]->tAlgoAreas[n].nHeight = - ( meteringAreas[0]->tAlgoAreas[n].nHeight * METERING_AREAS_RANGE ) / mPreviewData->mHeight; - - meteringAreas[0]->tAlgoAreas[n].nPriority = mMeteringAreas.itemAt(n)->getWeight(); - - CAMHAL_LOGDB("Metering area %d : top = %d left = %d width = %d height = %d prio = %d", - n, (int)meteringAreas[0]->tAlgoAreas[n].nTop, (int)meteringAreas[0]->tAlgoAreas[n].nLeft, - (int)meteringAreas[0]->tAlgoAreas[n].nWidth, (int)meteringAreas[0]->tAlgoAreas[n].nHeight, - (int)meteringAreas[0]->tAlgoAreas[n].nPriority); - - } - - OMX_INIT_STRUCT_PTR (&sharedBuffer, OMX_TI_CONFIG_SHAREDBUFFER); - - sharedBuffer.nPortIndex = OMX_ALL; - sharedBuffer.nSharedBuffSize = areasSize; - sharedBuffer.pSharedBuff = (OMX_U8 *) meteringAreas[0]; - - if ( NULL == sharedBuffer.pSharedBuff ) - { - CAMHAL_LOGEA("No resources to allocate OMX shared buffer"); - ret = -ENOMEM; - goto EXIT; - } - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE) OMX_TI_IndexConfigAlgoAreas, &sharedBuffer); - - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while setting Focus Areas configuration 0x%x", eError); - ret = -EINVAL; - } - else - { - CAMHAL_LOGDA("Metering Areas SetConfig successfull."); - } - - EXIT: - if (NULL != meteringAreas) - { - memMgr.freeBuffer((void*) meteringAreas); - meteringAreas = NULL; - } - - return ret; -} - status_t OMXCameraAdapter::apply3Asettings( Gen3A_settings& Gen3A ) { status_t ret = NO_ERROR; @@ -1301,10 +1189,6 @@ status_t OMXCameraAdapter::apply3Asettings( Gen3A_settings& Gen3A ) ret |= setWhiteBalanceLock(Gen3A); break; } - case SetMeteringAreas: - { - ret |= setMeteringAreas(Gen3A); - } default: CAMHAL_LOGEB("this setting (0x%x) is still not supported in CameraAdapter ", diff --git a/camera/OMXCameraAdapter/OMXCapabilities.cpp b/camera/OMXCameraAdapter/OMXCapabilities.cpp index ec7be70a..02fd41c6 100644 --- a/camera/OMXCameraAdapter/OMXCapabilities.cpp +++ b/camera/OMXCameraAdapter/OMXCapabilities.cpp @@ -925,29 +925,6 @@ status_t OMXCameraAdapter::insertFlickerModes(CameraProperties::Properties* para return ret; } -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; - - LOG_FUNCTION_NAME; - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - - sprintf(supported, "%d", caps.ulAlgoAreasFocusCount); - params->set(CameraProperties::MAX_FOCUS_AREAS, supported); - CAMHAL_LOGDB("Maximum supported focus areas %s", supported); - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - sprintf(supported, "%d", caps.ulAlgoAreasExposureCount); - params->set(CameraProperties::MAX_NUM_METERING_AREAS, supported); - CAMHAL_LOGDB("Maximum supported exposure areas %s", supported); - - LOG_FUNCTION_NAME; - - return ret; -} - status_t OMXCameraAdapter::insertLocks(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { status_t ret = NO_ERROR; @@ -990,6 +967,7 @@ status_t OMXCameraAdapter::insertDefaults(CameraProperties::Properties* params, params->set(CameraProperties::PREVIEW_SIZE, DEFAULT_PREVIEW_SIZE); params->set(CameraProperties::REQUIRED_PREVIEW_BUFS, DEFAULT_NUM_PREV_BUFS); params->set(CameraProperties::REQUIRED_IMAGE_BUFS, DEFAULT_NUM_PIC_BUFS); + params->set(CameraProperties::MAX_FOCUS_AREAS, DEFAULT_MAX_FOCUS_AREAS); params->set(CameraProperties::SATURATION, DEFAULT_SATURATION); params->set(CameraProperties::SCENE_MODE, DEFAULT_SCENE_MODE); params->set(CameraProperties::SHARPNESS, DEFAULT_SHARPNESS); @@ -1000,6 +978,7 @@ status_t OMXCameraAdapter::insertDefaults(CameraProperties::Properties* params, 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); + params->set(CameraProperties::MAX_NUM_METERING_AREAS, DEFAULT_MAX_NUM_METERING_AREAS); params->set(CameraProperties::FOCAL_LENGTH, DEFAULT_FOCAL_LENGTH); params->set(CameraProperties::HOR_ANGLE, DEFAULT_HOR_ANGLE); params->set(CameraProperties::VER_ANGLE, DEFAULT_VER_ANGLE); @@ -1127,17 +1106,11 @@ 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 = insertDefaults(params, caps); } - - LOG_FUNCTION_NAME_EXIT; return ret; diff --git a/camera/OMXCameraAdapter/OMXDefaults.cpp b/camera/OMXCameraAdapter/OMXDefaults.cpp index 1f6af83c..84d8cc2d 100644 --- a/camera/OMXCameraAdapter/OMXDefaults.cpp +++ b/camera/OMXCameraAdapter/OMXDefaults.cpp @@ -72,5 +72,6 @@ const char OMXCameraAdapter::DEFAULT_LOCK_SUPPORTED[] = "true"; const char OMXCameraAdapter::DEFAULT_LOCK_UNSUPPORTED[] = "false"; const char OMXCameraAdapter::DEFAULT_VIDEO_SNAPSHOT_SUPPORTED[] = "true"; +const size_t OMXCameraAdapter::MAX_FOCUS_AREAS = 1; }; diff --git a/camera/OMXCameraAdapter/OMXFocus.cpp b/camera/OMXCameraAdapter/OMXFocus.cpp index b7517a80..3469394c 100644 --- a/camera/OMXCameraAdapter/OMXFocus.cpp +++ b/camera/OMXCameraAdapter/OMXFocus.cpp @@ -41,15 +41,10 @@ status_t OMXCameraAdapter::setParametersFocus(const CameraParameters ¶ms, status_t ret = NO_ERROR; const char *str = NULL; Mutex::Autolock lock(mFocusAreasLock); - size_t MAX_FOCUS_AREAS; - LOG_FUNCTION_NAME; str = params.get(CameraParameters::KEY_FOCUS_AREAS); - - MAX_FOCUS_AREAS = atoi(params.get(CameraParameters::KEY_MAX_NUM_FOCUS_AREAS)); - mFocusAreas.clear(); if ( NULL != str ) { ret = CameraArea::parseFocusArea(str, ( strlen(str) + 1 ), mFocusAreas); @@ -652,15 +647,16 @@ status_t OMXCameraAdapter::addFocusDistances(OMX_U32 &near, return ret; } -status_t OMXCameraAdapter::setTouchFocus() +status_t OMXCameraAdapter::setTouchFocus(size_t posX, + size_t posY, + size_t posWidth, + size_t posHeight, + size_t previewWidth, + size_t previewHeight) { status_t ret = NO_ERROR; OMX_ERRORTYPE eError = OMX_ErrorNone; - - OMX_ALGOAREASTYPE **focusAreas; - OMX_TI_CONFIG_SHAREDBUFFER sharedBuffer; - MemoryManager memMgr; - int areasSize = 0; + OMX_CONFIG_EXTFOCUSREGIONTYPE touchControl; LOG_FUNCTION_NAME; @@ -672,86 +668,27 @@ status_t OMXCameraAdapter::setTouchFocus() if ( NO_ERROR == ret ) { + OMX_INIT_STRUCT_PTR (&touchControl, OMX_CONFIG_EXTFOCUSREGIONTYPE); + touchControl.nLeft = ( posX * TOUCH_FOCUS_RANGE ) / previewWidth; + touchControl.nTop = ( posY * TOUCH_FOCUS_RANGE ) / previewHeight; + touchControl.nWidth = ( posWidth * TOUCH_FOCUS_RANGE ) / previewWidth; + touchControl.nHeight = ( posHeight * TOUCH_FOCUS_RANGE ) / previewHeight; - areasSize = ((sizeof(OMX_ALGOAREASTYPE)+4095)/4096)*4096; - focusAreas = (OMX_ALGOAREASTYPE**) memMgr.allocateBuffer(0, 0, NULL, areasSize, 1); - - OMXCameraPortParameters * mPreviewData = NULL; - mPreviewData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex]; - - if (!focusAreas) - { - CAMHAL_LOGEB("Error allocating buffer for focus areas %d", eError); - return -ENOMEM; - } - - OMX_INIT_STRUCT_PTR (focusAreas[0], OMX_ALGOAREASTYPE); - - focusAreas[0]->nPortIndex = OMX_ALL; - focusAreas[0]->nNumAreas = mFocusAreas.size(); - focusAreas[0]->nAlgoAreaPurpose = OMX_AlgoAreaFocus; - - // If the area is the special case of (0, 0, 0, 0, 0), then - // the algorithm needs nNumAreas to be set to 0, - // in order to automatically choose the best fitting areas. - if ( mFocusAreas.itemAt(0)->isZeroArea() ) - { - focusAreas[0]->nNumAreas = 0; - } - - for ( unsigned int n = 0; n < mFocusAreas.size(); n++) - { - // transform the coordinates to 3A-type coordinates - mFocusAreas.itemAt(n)->transfrom((size_t)mPreviewData->mWidth, - (size_t)mPreviewData->mHeight, - (size_t&)focusAreas[0]->tAlgoAreas[n].nTop, - (size_t&)focusAreas[0]->tAlgoAreas[n].nLeft, - (size_t&)focusAreas[0]->tAlgoAreas[n].nWidth, - (size_t&)focusAreas[0]->tAlgoAreas[n].nHeight); - - focusAreas[0]->tAlgoAreas[n].nLeft = - ( focusAreas[0]->tAlgoAreas[n].nLeft * TOUCH_FOCUS_RANGE ) / mPreviewData->mWidth; - focusAreas[0]->tAlgoAreas[n].nTop = - ( focusAreas[0]->tAlgoAreas[n].nTop* TOUCH_FOCUS_RANGE ) / mPreviewData->mHeight; - focusAreas[0]->tAlgoAreas[n].nWidth = - ( focusAreas[0]->tAlgoAreas[n].nWidth * TOUCH_FOCUS_RANGE ) / mPreviewData->mWidth; - focusAreas[0]->tAlgoAreas[n].nHeight = - ( focusAreas[0]->tAlgoAreas[n].nHeight * TOUCH_FOCUS_RANGE ) / mPreviewData->mHeight; - focusAreas[0]->tAlgoAreas[n].nPriority = mFocusAreas.itemAt(n)->getWeight(); - - CAMHAL_LOGDB("Focus area %d : top = %d left = %d width = %d height = %d prio = %d", - n, (int)focusAreas[0]->tAlgoAreas[n].nTop, (int)focusAreas[0]->tAlgoAreas[n].nLeft, - (int)focusAreas[0]->tAlgoAreas[n].nWidth, (int)focusAreas[0]->tAlgoAreas[n].nHeight, - (int)focusAreas[0]->tAlgoAreas[n].nPriority); - } - - OMX_INIT_STRUCT_PTR (&sharedBuffer, OMX_TI_CONFIG_SHAREDBUFFER); - - sharedBuffer.nPortIndex = OMX_ALL; - sharedBuffer.nSharedBuffSize = areasSize; - sharedBuffer.pSharedBuff = (OMX_U8 *) focusAreas[0]; - - if ( NULL == sharedBuffer.pSharedBuff ) - { - CAMHAL_LOGEA("No resources to allocate OMX shared buffer"); - ret = -ENOMEM; - goto EXIT; - } - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE) OMX_TI_IndexConfigAlgoAreas, &sharedBuffer); - + eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, + ( OMX_INDEXTYPE ) OMX_IndexConfigExtFocusRegion, + &touchControl); if ( OMX_ErrorNone != eError ) { - CAMHAL_LOGEB("Error while setting Focus Areas configuration 0x%x", eError); - ret = -EINVAL; + CAMHAL_LOGEB("Error while configuring touch focus 0x%x", eError); + ret = -1; } - - EXIT: - if (NULL != focusAreas) + else { - memMgr.freeBuffer((void*) focusAreas); - focusAreas = NULL; + CAMHAL_LOGDB("Touch focus %d,%d %d,%d configured successfuly", + ( int ) touchControl.nLeft, + ( int ) touchControl.nTop, + ( int ) touchControl.nWidth, + ( int ) touchControl.nHeight); } } diff --git a/camera/inc/CameraHal.h b/camera/inc/CameraHal.h index 475f7fa4..b423a943 100644 --- a/camera/inc/CameraHal.h +++ b/camera/inc/CameraHal.h @@ -139,12 +139,6 @@ public: return ( ( 0 != mTop ) || ( 0 != mLeft ) || ( 0 != mBottom ) || ( 0 != mRight) ); } - bool isZeroArea() - { - return ( (0 == mTop ) && ( 0 == mLeft ) && ( 0 == mBottom ) - && ( 0 == mRight ) && ( 0 == mWeight )); - } - size_t getWeight() { return mWeight; diff --git a/camera/inc/CameraProperties.h b/camera/inc/CameraProperties.h index 186aa4b4..30128643 100644 --- a/camera/inc/CameraProperties.h +++ b/camera/inc/CameraProperties.h @@ -127,7 +127,6 @@ public: static const char AUTO_WHITEBALANCE_LOCK_SUPPORTED[]; static const char MAX_NUM_METERING_AREAS[]; static const char METERING_AREAS[]; - static const char MAX_NUM_FOCUS_AREAS[]; static const char VIDEO_SNAPSHOT_SUPPORTED[]; diff --git a/camera/inc/General3A_Settings.h b/camera/inc/General3A_Settings.h index 8267c04a..9e0e7981 100644 --- a/camera/inc/General3A_Settings.h +++ b/camera/inc/General3A_Settings.h @@ -253,7 +253,6 @@ enum E3ASettingsFlags SetFlash = 1 << 15, SetExpLock = 1 << 16, SetWBLock = 1 << 17, - SetMeteringAreas = 1 << 18, E3aSettingMax, E3AsettingsAll = ( ((E3aSettingMax -1 ) << 1) -1 ) /// all possible flags raised diff --git a/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h b/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h index 4f53b7d7..8e3a2956 100644 --- a/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h +++ b/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h @@ -474,7 +474,6 @@ private: status_t setExposureLock(Gen3A_settings& Gen3A); status_t setWhiteBalanceLock(Gen3A_settings& Gen3A); status_t set3ALock(OMX_BOOL toggle); - status_t setMeteringAreas(Gen3A_settings& Gen3A); //API to set FrameRate using VFR interface status_t setVFramerate(OMX_U32 minFrameRate,OMX_U32 maxFrameRate); @@ -497,7 +496,12 @@ private: status_t printComponentVersion(OMX_HANDLETYPE handle); //Touch AF - status_t setTouchFocus(); + status_t setTouchFocus(size_t posX, + size_t posY, + size_t posWidth, + size_t posHeight, + size_t previewWidth, + size_t previewHeight); //Face detection status_t setParametersFD(const CameraParameters ¶ms, @@ -553,7 +557,6 @@ private: static status_t insertSenMount(CameraProperties::Properties*, OMX_TI_CAPTYPE&); static status_t insertDefaults(CameraProperties::Properties*, OMX_TI_CAPTYPE&); static status_t insertLocks(CameraProperties::Properties*, OMX_TI_CAPTYPE&); - static status_t insertAreas(CameraProperties::Properties*, OMX_TI_CAPTYPE&); status_t setParametersCapture(const CameraParameters ¶ms, BaseCameraAdapter::AdapterState state); @@ -727,9 +730,6 @@ private: Vector< sp > mFocusAreas; mutable Mutex mFocusAreasLock; - // Current Metering areas - Vector< sp > mMeteringAreas; - CaptureMode mCapMode; size_t mBurstFrames; size_t mCapturedFrames; -- cgit v1.2.3 From 706197842333cd21fd09361903b755d734421183 Mon Sep 17 00:00:00 2001 From: Lajos Molnar Date: Thu, 25 Aug 2011 20:44:38 -0500 Subject: hwc: set hdmi mode (resolution) through new dsscomp API Read supported monitor resolutions on hpd. Try to pick one that is the same size as the main screen. If that is not supported, pick the default (TV preferred) resolution. Change-Id: I49732b292d4651aeac504b7053fad928c0de2251 --- hwc/hwc.c | 57 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/hwc/hwc.c b/hwc/hwc.c index 4d60e9d5..a94e6e7b 100644 --- a/hwc/hwc.c +++ b/hwc/hwc.c @@ -73,8 +73,10 @@ struct omap4_hwc_device { int dsscomp_fd; int hdmi_fb_fd; - __u16 aspect_ratio; - struct omap_video_timings ext_timings; + __u16 ext_width; + __u16 ext_height; + __u32 ext_xres; + __u32 ext_yres; float m[2][3]; IMG_framebuffer_device_public_t *fb_dev; struct dsscomp_setup_dispc_data dsscomp_data; @@ -348,14 +350,14 @@ static inline int m_round(float x) static void set_ext_matrix(omap4_hwc_device_t *hwc_dev, int orig_w, int orig_h) { /* target screen aspect ratio */ - int target_x = hwc_dev->aspect_ratio >> 8; - int target_y = hwc_dev->aspect_ratio & 0xFF; + int target_x = hwc_dev->ext_width; + int target_y = hwc_dev->ext_height; /* source pixel aspect ratio */ int source_x = 1; int source_y = 1; - int target_w = hwc_dev->ext_timings.x_res; - int target_h = hwc_dev->ext_timings.y_res; + int target_w = hwc_dev->ext_xres; + int target_h = hwc_dev->ext_yres; int cropped_w = target_w; int cropped_h = target_h; if (!target_x || !target_y) { @@ -395,10 +397,10 @@ static void omap4_hwc_create_ext_matrix(omap4_hwc_device_t *hwc_dev) { /* use VGA external resolution as default */ - if (!hwc_dev->ext_timings.x_res || - !hwc_dev->ext_timings.y_res) { - hwc_dev->ext_timings.x_res = 640; - hwc_dev->ext_timings.y_res = 480; + if (!hwc_dev->ext_xres || + !hwc_dev->ext_yres) { + hwc_dev->ext_xres = 640; + hwc_dev->ext_yres = 480; } /* if docking, we cannot create the matrix ahead of time as it depends on input size */ @@ -933,13 +935,38 @@ static void handle_hotplug(omap4_hwc_device_t *hwc_dev, int state) pthread_mutex_lock(&hwc_dev->lock); hwc_dev->ext = 0; if (state) { - struct dsscomp_display_info dis = { .ix = 1, }; - int ret = ioctl(hwc_dev->dsscomp_fd, DSSCOMP_QUERY_DISPLAY, &dis); + struct _qdis { + struct dsscomp_display_info dis; + struct dsscomp_videomode modedb[16]; + } d = { .dis = { .ix = 1 } }; + d.dis.modedb_len = sizeof(d.modedb) / sizeof(*d.modedb); + int ret = ioctl(hwc_dev->dsscomp_fd, DSSCOMP_QUERY_DISPLAY, &d); if (!ret) { - hwc_dev->ext_timings = dis.timings; - hwc_dev->aspect_ratio = dis.s3d_info.gap; // temp way of getting aspect ratio + __u32 i, best = ~0; + for (i = 0; i < d.dis.modedb_len; i++) { + LOGD("#%d: %dx%d %dHz", i, d.modedb[i].xres, d.modedb[i].yres, d.modedb[i].refresh); + if (!~best && + d.modedb[i].xres == hwc_dev->fb_dev->base.height && + d.modedb[i].yres == hwc_dev->fb_dev->base.width) { + best = i; + } + } + if (~best || d.dis.modedb_len) { + struct dsscomp_setup_display_data sdis = { .ix = 1, }; + best = ~best ? best : 0; + sdis.mode = d.dis.modedb[best]; + LOGD("picking #%d", best); + ioctl(hwc_dev->dsscomp_fd, DSSCOMP_SETUP_DISPLAY, &sdis); + hwc_dev->ext_xres = sdis.mode.xres; + hwc_dev->ext_yres = sdis.mode.yres; + } else { + hwc_dev->ext_xres = d.dis.timings.x_res; + hwc_dev->ext_yres = d.dis.timings.y_res; + } + hwc_dev->ext_width = d.dis.width_in_mm; + hwc_dev->ext_height = d.dis.height_in_mm; hwc_dev->ext = EXT_ON | 3; - if (dis.channel == OMAP_DSS_CHANNEL_DIGIT) + if (d.dis.channel == OMAP_DSS_CHANNEL_DIGIT) hwc_dev->ext |= EXT_TV; ioctl(hwc_dev->hdmi_fb_fd, FBIOBLANK, FB_BLANK_UNBLANK); } -- cgit v1.2.3 From da9210e54de6c168c733db767b51df642001ebd1 Mon Sep 17 00:00:00 2001 From: Akwasi Boateng Date: Wed, 7 Sep 2011 19:32:14 -0500 Subject: FPS range and frame rate changes Adjust framerate to match fps range if app wants to a different fps range other than the defualt and also adjust fps range to match frame rate if app wants to chnage frame rate only. Change-Id: I1e15e4a021140f5b1cf78fcbb57c722a8e97e983 Signed-off-by: Akwasi Boateng --- camera/CameraHal.cpp | 97 ++++++++++++++++++++++++++++++++++++++++---------- camera/inc/CameraHal.h | 2 ++ 2 files changed, 80 insertions(+), 19 deletions(-) diff --git a/camera/CameraHal.cpp b/camera/CameraHal.cpp index 4db34d8c..91d20424 100644 --- a/camera/CameraHal.cpp +++ b/camera/CameraHal.cpp @@ -446,46 +446,70 @@ int CameraHal::setParameters(const CameraParameters& params) // deprecated constant FPS. "KEY_PREVIEW_FPS_RANGE" should // be cleared by the client in order for constant FPS to get // applied. - if ( ( valstr = params.get(CameraParameters::KEY_PREVIEW_FPS_RANGE) ) != NULL ) - { + if ( (valstr = params.get(CameraParameters::KEY_PREVIEW_FPS_RANGE) ) != NULL ) + { CAMHAL_LOGDB("FPS Range = %s", valstr); + CAMHAL_LOGDB("DEFAULT FPS Range = %s", mCameraProperties->get(CameraProperties::FRAMERATE_RANGE)); + params.getPreviewFpsRange(&minFPS, &maxFPS); if ( ( 0 > minFPS ) || ( 0 > maxFPS ) ) - { + { CAMHAL_LOGEA("ERROR: FPS Range is negative!"); ret = -EINVAL; - } + } minFPS /= CameraHal::VFR_SCALE; maxFPS /= CameraHal::VFR_SCALE; if ( ( 0 == minFPS ) || ( 0 == maxFPS ) ) - { + { CAMHAL_LOGEA("ERROR: FPS Range is invalid!"); ret = -EINVAL; - } + } if ( maxFPS < minFPS ) - { + { CAMHAL_LOGEA("ERROR: Max FPS is smaller than Min FPS!"); ret = -EINVAL; - } + } - if ( maxFPS > framerate ) - { - framerate = maxFPS; - mParameters.setPreviewFrameRate(framerate); - } + if ( strcmp(valstr, mCameraProperties->get(CameraProperties::FRAMERATE_RANGE)) != 0) + { + // APP wants to set FPS range + //Set framerate = MAXFPS + CAMHAL_LOGDA("APP IS CHANGING FRAME RATE RANGE"); + framerate = maxFPS ; + } + else if ( framerate != atoi(mCameraProperties->get(CameraProperties::PREVIEW_FRAME_RATE)) ) + { + //APP wants to set framerate + //Change FPS range to match framerate + //MAXFPS = Framerate + if ( isParameterValid(framerate, + mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_FRAME_RATES)) ) + { + CAMHAL_LOGDA("APP IS CHANGING FRAME RATE"); + selectFPSRange(framerate, &minFPS, &maxFPS); + } + else + { + CAMHAL_LOGEA("Framerate NOT Supported!"); + return -EINVAL; + } + } + + CAMHAL_LOGDB("SET FRAMERATE %d", framerate); + mParameters.setPreviewFrameRate(framerate); CAMHAL_LOGDB("FPS Range [%d, %d]", minFPS, maxFPS); mParameters.set(TICameraParameters::KEY_MINFRAMERATE, minFPS); mParameters.set(TICameraParameters::KEY_MAXFRAMERATE, maxFPS); mParameters.set(CameraParameters::KEY_PREVIEW_FPS_RANGE, valstr); - } + } else if ( isParameterValid(framerate, - mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_FRAME_RATES)) ) - { + mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_FRAME_RATES)) ) + { minFPS = framerate; maxFPS = framerate; mParameters.setPreviewFrameRate(framerate); @@ -495,11 +519,11 @@ int CameraHal::setParameters(const CameraParameters& params) mParameters.set(TICameraParameters::KEY_MAXFRAMERATE, maxFPS); mParameters.set(CameraParameters::KEY_PREVIEW_FPS_RANGE, params.get(CameraParameters::KEY_PREVIEW_FPS_RANGE)); - } + } else - { + { return -EINVAL; - } + } if( ( valstr = params.get(TICameraParameters::KEY_GBCE) ) != NULL ) { @@ -3215,6 +3239,41 @@ status_t CameraHal::storeMetaDataInBuffers(bool enable) LOG_FUNCTION_NAME_EXIT; } +void CameraHal::selectFPSRange(int framerate, int *min_fps, int *max_fps) +{ + char * ptr; + char supported[MAX_PROP_VALUE_LENGTH]; + int fpsrangeArray[2]; + int i = 0; + + LOG_FUNCTION_NAME; + size_t size = strlen(mCameraProperties->get(CameraProperties::FRAMERATE_RANGE_SUPPORTED))+1; + strncpy(supported, mCameraProperties->get(CameraProperties::FRAMERATE_RANGE_SUPPORTED), size); + + ptr = strtok (supported," (,)"); + + while (ptr != NULL) + { + fpsrangeArray[i]= atoi(ptr)/CameraHal::VFR_SCALE; + if (i == 1) + { + if (framerate == fpsrangeArray[i]) + { + CAMHAL_LOGDB("SETTING FPS RANGE min = %d max = %d \n", fpsrangeArray[0], fpsrangeArray[1]); + *min_fps = fpsrangeArray[0]; + *max_fps = fpsrangeArray[1]; + break; + } + } + ptr = strtok (NULL, " (,)"); + i++; + i%=2; + } + + LOG_FUNCTION_NAME_EXIT; + +} + }; diff --git a/camera/inc/CameraHal.h b/camera/inc/CameraHal.h index 475f7fa4..f717c766 100644 --- a/camera/inc/CameraHal.h +++ b/camera/inc/CameraHal.h @@ -1089,6 +1089,8 @@ private: void forceStopPreview(); + void selectFPSRange(int framerate, int *min_fps, int *max_fps); + //@} -- cgit v1.2.3 From 3223eb23dedbf4b2acfeec2e2b26202de2e356f4 Mon Sep 17 00:00:00 2001 From: Akwasi Boateng Date: Wed, 7 Sep 2011 21:28:38 -0500 Subject: Set default fps range for video mode to 24<->30 Hack to allow image mode fps=15 and vide mode fps = 24 Change-Id: Ie2a4b3d5c7e32515a1af948fa65c934baaf3e1a9 Signed-off-by: Akwasi Boateng --- camera/CameraHal.cpp | 10 ++++++++++ camera/CameraParameters.cpp | 2 ++ camera/OMXCameraAdapter/OMXCapabilities.cpp | 8 ++------ camera/OMXCameraAdapter/OMXDefaults.cpp | 2 +- camera/inc/CameraProperties.h | 1 + 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/camera/CameraHal.cpp b/camera/CameraHal.cpp index 91d20424..10b8716b 100644 --- a/camera/CameraHal.cpp +++ b/camera/CameraHal.cpp @@ -253,6 +253,7 @@ int CameraHal::setParameters(const CameraParameters& params) // Needed for KEY_RECORDING_HINT bool restartPreviewRequired = false; CameraParameters oldParams(mParameters.flatten()); + bool videoMode = false; { Mutex::Autolock lock(mLock); @@ -385,6 +386,7 @@ int CameraHal::setParameters(const CameraParameters& params) CAMHAL_LOGDB("Recording Hint is set to %s", valstr); mParameters.set(CameraParameters::KEY_RECORDING_HINT, valstr); restartPreviewRequired = setVideoModeParameters(); + videoMode = true; } else if(strcmp(valstr, CameraParameters::FALSE) == 0) { @@ -453,6 +455,14 @@ int CameraHal::setParameters(const CameraParameters& params) params.getPreviewFpsRange(&minFPS, &maxFPS); + if (videoMode) + { + mCameraProperties->set(CameraProperties::FRAMERATE_RANGE, CameraProperties::DEFAULT_VIDEO_FPS_RANGE); + valstr = mCameraProperties->get(CameraProperties::FRAMERATE_RANGE); + mParameters.set(CameraParameters::KEY_PREVIEW_FPS_RANGE, valstr); + mParameters.getPreviewFpsRange(&minFPS, &maxFPS); + } + if ( ( 0 > minFPS ) || ( 0 > maxFPS ) ) { CAMHAL_LOGEA("ERROR: FPS Range is negative!"); diff --git a/camera/CameraParameters.cpp b/camera/CameraParameters.cpp index dfb941b6..092a20c9 100644 --- a/camera/CameraParameters.cpp +++ b/camera/CameraParameters.cpp @@ -112,6 +112,8 @@ const char CameraProperties::DEFAULT_VALUE[] = ""; const char CameraProperties::PARAMS_DELIMITER []= ","; +const char CameraProperties::DEFAULT_VIDEO_FPS_RANGE[]="24000,30000"; + // Returns the properties class for a specific Camera // Each value is indexed by the CameraProperties::CameraPropertyIndex enum int CameraProperties::getProperties(int cameraIndex, CameraProperties::Properties** properties) diff --git a/camera/OMXCameraAdapter/OMXCapabilities.cpp b/camera/OMXCameraAdapter/OMXCapabilities.cpp index ec7be70a..0e329b98 100644 --- a/camera/OMXCameraAdapter/OMXCapabilities.cpp +++ b/camera/OMXCameraAdapter/OMXCapabilities.cpp @@ -106,11 +106,7 @@ const CapPixelformat OMXCameraAdapter::mPixelformats [] = { const CapFramerate OMXCameraAdapter::mFramerates [] = { { 30, "30" }, - { 25, "25" }, - { 24, "24" }, - { 20, "20" }, { 15, "15" }, - { 10, "10" }, }; const CapZoom OMXCameraAdapter::mZoomStages [] = { @@ -648,8 +644,8 @@ status_t OMXCameraAdapter::insertVFramerates(CameraProperties::Properties* param } else { params->set(CameraProperties::FRAMERATE_RANGE_SUPPORTED, supported); CAMHAL_LOGDB("framerate ranges %s", supported); - params->set(CameraProperties::FRAMERATE_RANGE, defaultRange); - CAMHAL_LOGDB("Default framerate range: [%s]", defaultRange); + params->set(CameraProperties::FRAMERATE_RANGE, DEFAULT_FRAMERATE_RANGE); + CAMHAL_LOGDB("Default framerate range: [%s]", DEFAULT_FRAMERATE_RANGE); } LOG_FUNCTION_NAME; diff --git a/camera/OMXCameraAdapter/OMXDefaults.cpp b/camera/OMXCameraAdapter/OMXDefaults.cpp index 1f6af83c..5801d3c6 100644 --- a/camera/OMXCameraAdapter/OMXDefaults.cpp +++ b/camera/OMXCameraAdapter/OMXDefaults.cpp @@ -39,7 +39,7 @@ const char OMXCameraAdapter::DEFAULT_EV_STEP[] = "0.1"; const char OMXCameraAdapter::DEFAULT_EXPOSURE_MODE[] = "auto"; const char OMXCameraAdapter::DEFAULT_FLASH_MODE[] = "off"; const char OMXCameraAdapter::DEFAULT_FOCUS_MODE[] = "infinity"; -const char OMXCameraAdapter::DEFAULT_FRAMERATE_RANGE[] = "20000,30000"; +const char OMXCameraAdapter::DEFAULT_FRAMERATE_RANGE[] = "15000,30000"; const char OMXCameraAdapter::DEFAULT_IPP[] = "ldc-nsf"; const char OMXCameraAdapter::DEFAULT_GBCE[] = "enable"; const char OMXCameraAdapter::DEFAULT_ISO_MODE[] = "auto"; diff --git a/camera/inc/CameraProperties.h b/camera/inc/CameraProperties.h index 186aa4b4..27824f39 100644 --- a/camera/inc/CameraProperties.h +++ b/camera/inc/CameraProperties.h @@ -130,6 +130,7 @@ public: static const char MAX_NUM_FOCUS_AREAS[]; static const char VIDEO_SNAPSHOT_SUPPORTED[]; + static const char DEFAULT_VIDEO_FPS_RANGE[]; CameraProperties(); ~CameraProperties(); -- cgit v1.2.3 From de79dd63803258b10b6b78971f423cd575550f9d Mon Sep 17 00:00:00 2001 From: Sarthak Aggarwal Date: Fri, 9 Sep 2011 05:08:11 +0530 Subject: Moving DCC buffers from MemMgr to ion Change-Id: I9367d2e918109ecc9bec59bdbfe6238cb7d694cd Signed-off-by: Sarthak Aggarwal --- domx/omx_proxy_component/Android.mk | 4 +- .../omx_camera/src/omx_proxy_camera.c | 70 +++++++++++++++++++--- 2 files changed, 63 insertions(+), 11 deletions(-) diff --git a/domx/omx_proxy_component/Android.mk b/domx/omx_proxy_component/Android.mk index b17fc38e..633cd52f 100644 --- a/domx/omx_proxy_component/Android.mk +++ b/domx/omx_proxy_component/Android.mk @@ -70,7 +70,7 @@ LOCAL_C_INCLUDES += \ $(LOCAL_PATH)/../omx_core/inc \ $(LOCAL_PATH)/../mm_osal/inc \ $(LOCAL_PATH)/../domx \ - $(LOCAL_PATH)/../../tiler \ + $(HARDWARE_TI_OMAP4_BASE)/ion/ \ $(LOCAL_PATH)/../domx/omx_rpc/inc LOCAL_SHARED_LIBRARIES := \ @@ -78,7 +78,7 @@ LOCAL_SHARED_LIBRARIES := \ libc \ libOMX_Core \ liblog \ - libtimemmgr \ + libion \ libdomx LOCAL_CFLAGS += -DTMS32060 -D_DB_TIOMAP -DSYSLINK_USE_SYSMGR -DSYSLINK_USE_LOADER diff --git a/domx/omx_proxy_component/omx_camera/src/omx_proxy_camera.c b/domx/omx_proxy_component/omx_camera/src/omx_proxy_camera.c index 541c31a4..9f5ce7b9 100755 --- a/domx/omx_proxy_component/omx_camera/src/omx_proxy_camera.c +++ b/domx/omx_proxy_component/omx_camera/src/omx_proxy_camera.c @@ -72,8 +72,18 @@ #include "omx_proxy_common.h" #include "timm_osal_mutex.h" +#ifdef USE_ION +#include +#include +#include +#include +#include +#include + +#else /* Tiler APIs */ #include +#endif #define COMPONENT_NAME "OMX.TI.DUCATI1.VIDEO.CAMERA" /*Needs to be specific for every configuration wrapper*/ @@ -106,8 +116,16 @@ TIMM_OSAL_PTR cam_mutex = NULL; OMX_S32 dccbuf_size = 0; /* Ducati Mapped Addr */ +OMX_PTR DCC_Buff = NULL; + +#ifdef USE_ION +OMX_PTR DCC_Buff_ptr = NULL; +int ion_fd; +int mmap_fd; + +#else MemAllocBlock *MemReqDescTiler; -OMX_PTR TilerAddr = NULL; +#endif OMX_S32 read_DCCdir(OMX_PTR, OMX_STRING *, OMX_U16); OMX_ERRORTYPE DCC_Init(OMX_HANDLETYPE); @@ -307,6 +325,7 @@ OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent) assert(strlen(COMPONENT_NAME) + 1 < MAX_COMPONENT_NAME_LENGTH); TIMM_OSAL_Memcpy(pComponentPrivate->cCompName, COMPONENT_NAME, strlen(COMPONENT_NAME) + 1); + /*Calling Proxy Common Init() */ eError = OMX_ProxyCommonInit(hComponent); if (eError != OMX_ErrorNone) @@ -375,6 +394,9 @@ OMX_ERRORTYPE DCC_Init(OMX_HANDLETYPE hComponent) OMX_PTR ptempbuf; OMX_U16 nIndex = 0; OMX_ERRORTYPE eError = OMX_ErrorNone; +#ifdef USE_ION + int ret; +#endif OMX_S32 status = 0; OMX_STRING dcc_dir[200]; @@ -423,6 +445,26 @@ OMX_ERRORTYPE DCC_Init(OMX_HANDLETYPE hComponent) return OMX_ErrorInsufficientResources; } +#ifdef USE_ION + ion_fd = ion_open(); + if(ion_fd == 0) + { + DOMX_ERROR("ion_open failed!!!"); + return OMX_ErrorInsufficientResources; + } + dccbuf_size = (dccbuf_size + LINUX_PAGE_SIZE -1) & ~(LINUX_PAGE_SIZE - 1); + ret = ion_alloc(ion_fd, dccbuf_size, 0x1000, 1 << ION_HEAP_TYPE_CARVEOUT, &DCC_Buff); + if (ret) + return OMX_ErrorInsufficientResources; + + if (ion_map(ion_fd, DCC_Buff, dccbuf_size, PROT_READ | PROT_WRITE, MAP_SHARED, 0, + &DCC_Buff_ptr,&mmap_fd) < 0) + { + DOMX_ERROR("userspace mapping of ION buffers returned error"); + return OMX_ErrorInsufficientResources; + } + ptempbuf = DCC_Buff_ptr; +#else MemReqDescTiler = (MemAllocBlock *) TIMM_OSAL_Malloc((sizeof(MemAllocBlock) * 2), TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_EXT); @@ -433,11 +475,11 @@ OMX_ERRORTYPE DCC_Init(OMX_HANDLETYPE hComponent) MemReqDescTiler[0].fmt = PIXEL_FMT_PAGE; MemReqDescTiler[0].dim.len = dccbuf_size; MemReqDescTiler[0].stride = 0; - TilerAddr = MemMgr_Alloc(MemReqDescTiler, 1); - PROXY_assert(TilerAddr != NULL, + DCC_Buff = MemMgr_Alloc(MemReqDescTiler, 1); + PROXY_assert(DCC_Buff != NULL, OMX_ErrorInsufficientResources, "ERROR Allocating 1D TILER BUF"); - - ptempbuf = TilerAddr; + ptempbuf = DCC_Buff; +#endif dccbuf_size = read_DCCdir(ptempbuf, dcc_dir, nIndex); PROXY_assert(dccbuf_size > 0, OMX_ErrorInsufficientResources, @@ -475,7 +517,7 @@ OMX_ERRORTYPE send_DCCBufPtr(OMX_HANDLETYPE hComponent) DOMX_ENTER("ENTER"); uribufparam.nSharedBuffSize = dccbuf_size; - uribufparam.pSharedBuff = (OMX_U8 *) TilerAddr; + uribufparam.pSharedBuff = (OMX_U8 *) DCC_Buff; DOMX_DEBUG("SYSLINK MAPPED ADDR: 0x%x sizeof buffer %d", uribufparam.pSharedBuff, uribufparam.nSharedBuffSize); @@ -595,11 +637,21 @@ void DCC_DeInit() { DOMX_ENTER("ENTER"); - if (TilerAddr) - MemMgr_Free(TilerAddr); - + if (DCC_Buff) + { +#ifdef USE_ION + munmap(DCC_Buff_ptr, dccbuf_size); + close(mmap_fd); + ion_free(ion_fd, DCC_Buff); + DCC_Buff = NULL; +#else + MemMgr_Free(DCC_Buff); +#endif + } +#ifndef USE_ION if (MemReqDescTiler) TIMM_OSAL_Free(MemReqDescTiler); +#endif DOMX_EXIT("EXIT"); } -- cgit v1.2.3 From 46e92e099319a5735c62079b7cf3e2f56076aef1 Mon Sep 17 00:00:00 2001 From: Sarthak Aggarwal Date: Fri, 9 Sep 2011 09:14:28 +0530 Subject: Moving encoder buffers for surface encoder to gralloc buffers Moving the buffers to gralloc removes the unnecessary step of user-mapping which will improve performance. Change-Id: I4b1b12c82466a2629e7edc3484f4ab56300dd38c Signed-off-by: Sarthak Aggarwal --- domx/omx_proxy_component/Android.mk | 2 - .../omx_h264_enc/src/omx_proxy_h264enc.c | 112 +++++++++------------ 2 files changed, 45 insertions(+), 69 deletions(-) diff --git a/domx/omx_proxy_component/Android.mk b/domx/omx_proxy_component/Android.mk index 633cd52f..b650b81d 100644 --- a/domx/omx_proxy_component/Android.mk +++ b/domx/omx_proxy_component/Android.mk @@ -105,7 +105,6 @@ LOCAL_C_INCLUDES += \ $(LOCAL_PATH)/../../hwc \ $(HARDWARE_TI_OMAP4_BASE)/camera/inc \ frameworks/base/include/media/stagefright \ - $(HARDWARE_TI_OMAP4_BASE)/tiler/ LOCAL_SHARED_LIBRARIES := \ libmm_osal \ @@ -113,7 +112,6 @@ LOCAL_SHARED_LIBRARIES := \ libOMX_Core \ liblog \ libdomx \ - libtimemmgr \ libhardware diff --git a/domx/omx_proxy_component/omx_h264_enc/src/omx_proxy_h264enc.c b/domx/omx_proxy_component/omx_h264_enc/src/omx_proxy_h264enc.c index 15da999a..9cb797a4 100644 --- a/domx/omx_proxy_component/omx_h264_enc/src/omx_proxy_h264enc.c +++ b/domx/omx_proxy_component/omx_h264_enc/src/omx_proxy_h264enc.c @@ -58,14 +58,6 @@ /****************************************************************** * INCLUDE FILES ******************************************************************/ -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT -/* Opaque color format requires below quirks to be enabled - * ENABLE_GRALLOC_BUFFER - * ANDROID_QUIRK_CHANGE_PORT_VALUES - */ -#include "memmgr.h" -#include "tiler.h" -#endif #include #include @@ -100,6 +92,10 @@ OMX_ERRORTYPE LOCAL_PROXY_H264E_SetParameter(OMX_IN OMX_HANDLETYPE hComponent, #endif #ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT +/* Opaque color format requires below quirks to be enabled + * ENABLE_GRALLOC_BUFFER + * ANDROID_QUIRCK_CHANGE_PORT_VALUES + */ #define OMX_H264VE_NUM_INTERNAL_BUF (8) #define HAL_PIXEL_FORMAT_TI_NV12 (0x100) @@ -109,12 +105,12 @@ OMX_ERRORTYPE LOCAL_PROXY_H264E_SetParameter(OMX_IN OMX_HANDLETYPE hComponent, #define COLORCONVERT_BUFTYPE_ION (0x1) #define COLORCONVERT_BUFTYPE_GRALLOCOPAQUE (0x2) -int COLORCONVERT_open(void **hCC); +int COLORCONVERT_open(void **hCC, PROXY_COMPONENT_PRIVATE *pCompPrv); int COLORCONVERT_PlatformOpaqueToNV12(void *hCC, void *pSrc[], void *pDst[], int nWidth, int nHeight, int nStride, int nSrcBufType, int nDstBufType); -int COLORCONVERT_close(void *hCC); +int COLORCONVERT_close(void *hCC,PROXY_COMPONENT_PRIVATE *pCompPrv); static OMX_ERRORTYPE LOCAL_PROXY_H264E_AllocateBuffer(OMX_IN OMX_HANDLETYPE hComponent, OMX_INOUT OMX_BUFFERHEADERTYPE ** ppBufferHdr, OMX_IN OMX_U32 nPortIndex, @@ -130,9 +126,9 @@ typedef struct _OMX_PROXY_H264E_PRIVATE OMX_PTR hBufPipe; OMX_BOOL bAndroidOpaqueFormat; OMX_PTR hCC; - OMX_PTR pBuf0[OMX_H264VE_NUM_INTERNAL_BUF]; - OMX_PTR pBuf1[OMX_H264VE_NUM_INTERNAL_BUF]; + IMG_native_handle_t* gralloc_handle[OMX_H264VE_NUM_INTERNAL_BUF]; OMX_S32 nCurBufIndex; + alloc_device_t* mAllocDev; }OMX_PROXY_H264E_PRIVATE; #endif @@ -408,7 +404,7 @@ OMX_ERRORTYPE LOCAL_PROXY_H264E_SetParameter(OMX_IN OMX_HANDLETYPE hComponent, #ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT else if(pPortDef->format.video.eColorFormat == OMX_COLOR_FormatAndroidOpaque) { - if(COLORCONVERT_open(&pProxy->hCC) != 0) + if(COLORCONVERT_open(&pProxy->hCC,pCompPrv) != 0) { PROXY_assert(0, OMX_ErrorInsufficientResources, "Failed to open Color converting service"); @@ -429,7 +425,7 @@ OMX_ERRORTYPE LOCAL_PROXY_H264E_SetParameter(OMX_IN OMX_HANDLETYPE hComponent, #ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT else if(pPortParams->eColorFormat == OMX_COLOR_FormatAndroidOpaque) { - if(COLORCONVERT_open(&pProxy->hCC) != 0) + if(COLORCONVERT_open(&pProxy->hCC,pCompPrv) != 0) { PROXY_assert(0, OMX_ErrorInsufficientResources, "Failed to open Color converting service"); @@ -562,7 +558,6 @@ OMX_ERRORTYPE LOCAL_PROXY_H264E_EmptyThisBuffer(OMX_HANDLETYPE hComponent, #ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT OMX_PROXY_H264E_PRIVATE *pProxy = NULL; TIMM_OSAL_ERRORTYPE eOSALStatus = TIMM_OSAL_ERR_NONE; - void *pDest[COLORCONVERT_MAX_SUB_BUFFERS]={NULL,NULL,NULL}; OMX_U32 nBufIndex = 0, nSize=0, nRet=0; #endif @@ -652,15 +647,12 @@ OMX_ERRORTYPE LOCAL_PROXY_H264E_EmptyThisBuffer(OMX_HANDLETYPE hComponent, TIMM_OSAL_SUSPEND); PROXY_assert(eOSALStatus == TIMM_OSAL_ERR_NONE, OMX_ErrorBadParameter, NULL); - pDest[0] = pProxy->pBuf0[nBufIndex]; - pDest[1] = pProxy->pBuf1[nBufIndex]; - /* Get NV12 data after colorconv*/ - nRet = COLORCONVERT_PlatformOpaqueToNV12(pProxy->hCC, (void **) &pGrallocHandle, pDest, + nRet = COLORCONVERT_PlatformOpaqueToNV12(pProxy->hCC, (void **) &pGrallocHandle, (void **) &pProxy->gralloc_handle[nBufIndex], pGrallocHandle->iWidth, pGrallocHandle->iHeight, 4096, COLORCONVERT_BUFTYPE_GRALLOCOPAQUE, - COLORCONVERT_BUFTYPE_VIRTUAL); + COLORCONVERT_BUFTYPE_GRALLOCOPAQUE ); if(nRet != 0) { eOSALStatus = TIMM_OSAL_WriteToPipe(pProxy->hBufPipe, (void *) &nBufIndex, @@ -669,8 +661,8 @@ OMX_ERRORTYPE LOCAL_PROXY_H264E_EmptyThisBuffer(OMX_HANDLETYPE hComponent, } /* Update pBufferHdr with NV12 buffers for OMX component */ - pBufferHdr->pBuffer= pDest[0]; - ((OMX_TI_PLATFORMPRIVATE *) pBufferHdr->pPlatformPrivate)->pAuxBuf1 = pDest[1]; + pBufferHdr->pBuffer= pProxy->gralloc_handle[nBufIndex]->fd[0]; + ((OMX_TI_PLATFORMPRIVATE *) pBufferHdr->pPlatformPrivate)->pAuxBuf1 = pProxy->gralloc_handle[nBufIndex]->fd[1]; } #endif #endif @@ -709,10 +701,10 @@ static OMX_ERRORTYPE LOCAL_PROXY_H264E_AllocateBuffer(OMX_HANDLETYPE hComponent, OMX_ERRORTYPE eError = OMX_ErrorNone; PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - MemAllocBlock blocks[2]; OMX_CONFIG_RECTTYPE tParamRect; OMX_PROXY_H264E_PRIVATE *pProxy = NULL; TIMM_OSAL_ERRORTYPE eOSALStatus = TIMM_OSAL_ERR_NONE; + int err, nStride; PROXY_require(hComp->pComponentPrivate != NULL, OMX_ErrorBadParameter, NULL); @@ -722,7 +714,6 @@ static OMX_ERRORTYPE LOCAL_PROXY_H264E_AllocateBuffer(OMX_HANDLETYPE hComponent, if((nPortIndex == OMX_H264E_INPUT_PORT) && (pProxy->bAndroidOpaqueFormat)) { - memset(blocks, 0, sizeof(MemAllocBlock)*2); tParamRect.nSize = sizeof(OMX_CONFIG_RECTTYPE); tParamRect.nVersion.s.nVersionMajor = 1; @@ -734,23 +725,8 @@ static OMX_ERRORTYPE LOCAL_PROXY_H264E_AllocateBuffer(OMX_HANDLETYPE hComponent, eError = PROXY_GetParameter(hComponent, (OMX_INDEXTYPE)OMX_TI_IndexParam2DBufferAllocDimension, &tParamRect); PROXY_assert(eError == OMX_ErrorNone, eError," Error in Proxy GetParameter"); - blocks[0].fmt = PIXEL_FMT_8BIT; - blocks[0].dim.area.width = tParamRect.nWidth; - blocks[0].dim.area.height = tParamRect.nHeight; - blocks[0].stride = 0; - - blocks[1].fmt = PIXEL_FMT_16BIT; - blocks[1].dim.area.width = tParamRect.nWidth >> 1; - blocks[1].dim.area.height = tParamRect.nHeight >> 1; - blocks[1].stride = 0; - - pProxy->pBuf0[pProxy->nCurBufIndex] = (OMX_U8*) MemMgr_Alloc(&blocks[0], 1); - PROXY_assert((pProxy->pBuf0[pProxy->nCurBufIndex] != NULL), - OMX_ErrorInsufficientResources, "MemMgr_Alloc returns NULL, abort,"); - - pProxy->pBuf1[pProxy->nCurBufIndex] = (OMX_U8*) MemMgr_Alloc(&blocks[1], 1); - PROXY_assert((pProxy->pBuf1[pProxy->nCurBufIndex] != NULL), - OMX_ErrorInsufficientResources, "MemMgr_Alloc returns NULL, abort,"); + err = pProxy->mAllocDev->alloc(pProxy->mAllocDev,(int) tParamRect.nWidth,(int) tParamRect.nHeight, + (int) HAL_PIXEL_FORMAT_TI_NV12,(int) GRALLOC_USAGE_HW_RENDER, &(pProxy->gralloc_handle[pProxy->nCurBufIndex]), &nStride); } eError = PROXY_AllocateBuffer(hComponent, ppBufferHdr, nPortIndex, @@ -761,14 +737,7 @@ EXIT: { if(eError != OMX_ErrorNone) { - if(pProxy->pBuf0[pProxy->nCurBufIndex]) - MemMgr_Free(pProxy->pBuf0[pProxy->nCurBufIndex]); - - if(pProxy->pBuf1[pProxy->nCurBufIndex]) - MemMgr_Free(pProxy->pBuf1[pProxy->nCurBufIndex]); - - pProxy->pBuf0[pProxy->nCurBufIndex] = NULL; - pProxy->pBuf1[pProxy->nCurBufIndex] = NULL; + err = pProxy->mAllocDev->free(pProxy->mAllocDev, pProxy->gralloc_handle[pProxy->nCurBufIndex]); } else { @@ -802,14 +771,11 @@ static OMX_ERRORTYPE LOCAL_PROXY_H264E_FreeBuffer(OMX_IN OMX_HANDLETYPE hCompone PROXY_require(pProxy->nCurBufIndex >=0, OMX_ErrorBadParameter, "Buffer index underflow"); - if(pProxy->pBuf0[pProxy->nCurBufIndex]) - MemMgr_Free(pProxy->pBuf0[pProxy->nCurBufIndex]); - - if(pProxy->pBuf1[pProxy->nCurBufIndex]) - MemMgr_Free(pProxy->pBuf1[pProxy->nCurBufIndex]); - - pProxy->pBuf0[pProxy->nCurBufIndex] = NULL; - pProxy->pBuf1[pProxy->nCurBufIndex] = NULL; + if(pProxy->gralloc_handle[pProxy->nCurBufIndex]) + { + pProxy->mAllocDev->free(pProxy->mAllocDev, pProxy->gralloc_handle[pProxy->nCurBufIndex]); + pProxy->gralloc_handle[pProxy->nCurBufIndex] = NULL; + } /*Clear the Bufindex pipe by dummy reads*/ TIMM_OSAL_GetPipeReadyMessageCount(pProxy->hBufPipe, (TIMM_OSAL_U32 *)&nCount); @@ -845,15 +811,10 @@ OMX_ERRORTYPE LOCAL_PROXY_H264E_ComponentDeInit(OMX_HANDLETYPE hComponent) /* Cleanup internal buffers in pipe if not freed on FreeBuffer */ for(i=0; ipBuf0[i] != NULL) - { - MemMgr_Free(pProxy->pBuf0[i]); - pProxy->pBuf0[i] = NULL; - } - if(pProxy->pBuf1[i] != NULL) + if(pProxy->gralloc_handle[pProxy->nCurBufIndex]) { - MemMgr_Free(pProxy->pBuf1[i]); - pProxy->pBuf1[i] = NULL; + pProxy->mAllocDev->free(pProxy->mAllocDev, pProxy->gralloc_handle[pProxy->nCurBufIndex]); + pProxy->gralloc_handle[pProxy->nCurBufIndex] = NULL; } } @@ -867,6 +828,9 @@ OMX_ERRORTYPE LOCAL_PROXY_H264E_ComponentDeInit(OMX_HANDLETYPE hComponent) DOMX_ERROR("Pipe deletion failed"); } } + + COLORCONVERT_close(pProxy->hCC,pCompPrv); + if(pCompPrv->pCompProxyPrv != NULL) { TIMM_OSAL_Free(pCompPrv->pCompProxyPrv); @@ -882,11 +846,13 @@ EXIT: return eError; } -int COLORCONVERT_open(void **hCC) +int COLORCONVERT_open(void **hCC, PROXY_COMPONENT_PRIVATE *pCompPrv) { int nErr = -1; hw_module_t const* module = NULL; + OMX_PROXY_H264E_PRIVATE *pProxy = NULL; + pProxy = (OMX_PROXY_H264E_PRIVATE *) pCompPrv->pCompProxyPrv; nErr = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module); if (nErr == 0) @@ -899,6 +865,8 @@ int COLORCONVERT_open(void **hCC) %s module err = %x", GRALLOC_HARDWARE_MODULE_ID, nErr); } + gralloc_open(module, &(pProxy->mAllocDev)); + return nErr; } @@ -915,12 +883,22 @@ int COLORCONVERT_PlatformOpaqueToNV12(void *hCC, { nErr = module->Blit(module, pSrc[0], pDst, HAL_PIXEL_FORMAT_TI_NV12); } + else if((nSrcBufType == COLORCONVERT_BUFTYPE_GRALLOCOPAQUE) && (nDstBufType == COLORCONVERT_BUFTYPE_GRALLOCOPAQUE )) + { + nErr = module->Blit2(module, pSrc[0], pDst[0], nWidth, nHeight, 0, 0); + } return nErr; } -int COLORCONVERT_close(void *hCC) +int COLORCONVERT_close(void *hCC,PROXY_COMPONENT_PRIVATE *pCompPrv) { + OMX_PROXY_H264E_PRIVATE *pProxy = NULL; + pProxy = (OMX_PROXY_H264E_PRIVATE *) pCompPrv->pCompProxyPrv; + if(pProxy && pProxy->mAllocDev) + { + gralloc_close(pProxy->mAllocDev); + } return 0; } #endif -- cgit v1.2.3 From 5de6fb151c078f7c3718f6daa645d6d9d2ed717e Mon Sep 17 00:00:00 2001 From: Sarthak Aggarwal Date: Fri, 7 Oct 2011 04:01:59 +0530 Subject: Enable Secure-component call into Misc driver Change-Id: If2cb2f7744967df6632dd097bd5a9576cf4f9718 Signed-off-by: Sarthak Aggarwal --- domx/domx/omx_proxy_common.h | 1 + domx/domx/omx_rpc/src/omx_rpc.c | 20 ++++-- domx/omx_core/src/OMX_Core.c | 12 ++++ domx/omx_proxy_component/Android.mk | 31 ++++++++ .../omx_video_dec/src/omx_proxy_videodec.c | 18 ++--- .../omx_video_dec/src/omx_proxy_videodec_secure.c | 84 ++++++++++++++++++++++ omap4.mk | 1 + 7 files changed, 154 insertions(+), 13 deletions(-) diff --git a/domx/domx/omx_proxy_common.h b/domx/domx/omx_proxy_common.h index 638cbc51..8eb21e51 100755 --- a/domx/domx/omx_proxy_common.h +++ b/domx/domx/omx_proxy_common.h @@ -207,6 +207,7 @@ extern "C" OMX_BOOL bUseIon; OMX_BOOL bMapIonBuffers; #endif + int secure_misc_drv_fd; } PROXY_COMPONENT_PRIVATE; diff --git a/domx/domx/omx_rpc/src/omx_rpc.c b/domx/domx/omx_rpc/src/omx_rpc.c index ff1022b6..d93134c2 100755 --- a/domx/domx/omx_rpc/src/omx_rpc.c +++ b/domx/domx/omx_rpc/src/omx_rpc.c @@ -108,7 +108,7 @@ RPC_OMX_ERRORTYPE RPC_InstanceInit(OMX_STRING cComponentName, OMX_S32 status = 0; struct omx_conn_req sReq = { .name = "OMX" }; TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE; - OMX_U32 i = 0; + OMX_U32 i = 0, nAttempts = 0; *(RPC_OMX_CONTEXT **) phRPCCtx = NULL; @@ -126,9 +126,21 @@ RPC_OMX_ERRORTYPE RPC_InstanceInit(OMX_STRING cComponentName, /*Assuming that open maintains an internal count for multi instance */ DOMX_DEBUG("Calling open on the device"); - pRPCCtx->fd_omx = open("/dev/rpmsg-omx1", O_RDWR); - RPC_assert(pRPCCtx->fd_omx >= 0, RPC_OMX_ErrorInsufficientResources, - "Can't open device"); + while (1) + { + pRPCCtx->fd_omx = open("/dev/rpmsg-omx1", O_RDWR); + if(pRPCCtx->fd_omx >= 0 || errno != ENOENT || nAttempts == 15) + break; + DOMX_DEBUG("errno from open= %d, REATTEMPTING OPEN!!!!",errno); + nAttempts++; + usleep(1000000); + } + if(pRPCCtx->fd_omx < 0) + { + DOMX_ERROR("Can't open device, errorno from open = %d",errno); + eError = RPC_OMX_ErrorInsufficientResources; + goto EXIT; + } DOMX_DEBUG("Open was successful, pRPCCtx->fd_omx = %d", pRPCCtx->fd_omx); //AD diff --git a/domx/omx_core/src/OMX_Core.c b/domx/omx_core/src/OMX_Core.c index fc439db5..8c2fb15f 100755 --- a/domx/omx_core/src/OMX_Core.c +++ b/domx/omx_core/src/OMX_Core.c @@ -113,6 +113,8 @@ extern OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent); goto EXIT; }\ } while(0) +OMX_U32 DUCATI_IN_SECURE_MODE = 0; +OMX_U32 SECURE_COMPONENTS_RUNNING = 0; /******************************Public*Routine******************************\ * OMX_Init() @@ -228,6 +230,16 @@ OMX_ERRORTYPE OMX_GetHandle(OMX_HANDLETYPE * pHandle, strcpy(buf, prefix); /* the lengths are defined herein or have been */ strcat(buf, cComponentName); /* checked already, so strcpy and strcat are */ strcat(buf, postfix); /* are safe to use in this context. */ + + if(DUCATI_IN_SECURE_MODE == 1) + { + if(strstr(cComponentName,"secure") == NULL) + { + TIMM_OSAL_Error("non-secure component not supported in secure mode"); + eError = OMX_ErrorComponentNotFound; + goto EXIT; + } + } //#if 0 pModules[i] = dlopen(buf, RTLD_LAZY | RTLD_GLOBAL); if (pModules[i] == NULL) diff --git a/domx/omx_proxy_component/Android.mk b/domx/omx_proxy_component/Android.mk index fede2376..4ebd727e 100644 --- a/domx/omx_proxy_component/Android.mk +++ b/domx/omx_proxy_component/Android.mk @@ -159,3 +159,34 @@ LOCAL_SRC_FILES:= omx_mpeg4_enc/src/omx_proxy_mpeg4enc.c LOCAL_MODULE:= libOMX.TI.DUCATI1.VIDEO.MPEG4E include $(BUILD_HEAPTRACKED_SHARED_LIBRARY) +# +# libOMX.TI.DUCATI1.VIDEO.DECODER.secure +# + +include $(CLEAR_VARS) + +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/../omx_core/inc \ + $(LOCAL_PATH)/../mm_osal/inc \ + $(LOCAL_PATH)/../domx \ + $(LOCAL_PATH)/../domx/omx_rpc/inc \ + $(HARDWARE_TI_OMAP4_BASE)/../../libhardware/include \ + $(HARDWARE_TI_OMAP4_BASE)/hwc/ + +LOCAL_SHARED_LIBRARIES := \ + libmm_osal \ + libc \ + libOMX_Core \ + liblog \ + libdomx \ + libhardware \ + libOMX.TI.DUCATI1.VIDEO.DECODER + +LOCAL_CFLAGS += -DLINUX -DTMS32060 -D_DB_TIOMAP -DSYSLINK_USE_SYSMGR -DSYSLINK_USE_LOADER +LOCAL_CFLAGS += -D_Android -DSET_STRIDE_PADDING_FROM_PROXY -DANDROID_QUIRK_CHANGE_PORT_VALUES -DUSE_ENHANCED_PORTRECONFIG +LOCAL_CFLAGS += -DANDROID_QUIRK_LOCK_BUFFER -DUSE_ION -DENABLE_GRALLOC_BUFFERS +LOCAL_MODULE_TAGS:= optional + +LOCAL_SRC_FILES:= omx_video_dec/src/omx_proxy_videodec_secure.c +LOCAL_MODULE:= libOMX.TI.DUCATI1.VIDEO.DECODER.secure +include $(BUILD_HEAPTRACKED_SHARED_LIBRARY) diff --git a/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec.c b/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec.c index 572592b0..1b0d8f5c 100755 --- a/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec.c +++ b/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec.c @@ -151,13 +151,6 @@ OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent) OMX_ErrorInsufficientResources, " Error in Allocating space for proxy component table"); - // Copying component Name - this will be picked up in the proxy common - PROXY_assert(strlen(COMPONENT_NAME) + 1 < MAX_COMPONENT_NAME_LENGTH, - OMX_ErrorInvalidComponentName, - "Length of component name is longer than the max allowed"); - TIMM_OSAL_Memcpy(pComponentPrivate->cCompName, COMPONENT_NAME, - strlen(COMPONENT_NAME) + 1); - eError = OMX_ProxyViddecInit(hComponent); EXIT: @@ -180,8 +173,15 @@ OMX_ERRORTYPE OMX_ProxyViddecInit(OMX_HANDLETYPE hComponent) DOMX_DEBUG("Component name provided is %s", COMPONENT_NAME); - pComponentPrivate = - (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate; + pComponentPrivate = + (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate; + + // Copying component Name - this will be picked up in the proxy common + PROXY_assert(strlen(COMPONENT_NAME) + 1 < MAX_COMPONENT_NAME_LENGTH, + OMX_ErrorInvalidComponentName, + "Length of component name is longer than the max allowed"); + TIMM_OSAL_Memcpy(pComponentPrivate->cCompName, COMPONENT_NAME, + strlen(COMPONENT_NAME) + 1); eError = OMX_ProxyCommonInit(hComponent); // Calling Proxy Common Init() PROXY_assert(eError == OMX_ErrorNone, eError, "Proxy common init returned error"); diff --git a/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_secure.c b/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_secure.c index 616d6992..f0db1f50 100644 --- a/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_secure.c +++ b/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_secure.c @@ -3,14 +3,27 @@ #include #include "omx_proxy_common.h" #include +#include +#include +#include +#include #define COMPONENT_NAME "OMX.TI.DUCATI1.VIDEO.DECODER.secure" +extern OMX_U32 DUCATI_IN_SECURE_MODE; +extern OMX_U32 SECURE_COMPONENTS_RUNNING; + +extern OMX_ERRORTYPE OMX_ProxyViddecInit(OMX_HANDLETYPE hComponent); +OMX_ERRORTYPE PROXY_VIDDEC_Secure_ComponentDeInit(OMX_HANDLETYPE hComponent); + OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent) { OMX_ERRORTYPE eError = OMX_ErrorNone; OMX_COMPONENTTYPE *pHandle = NULL; PROXY_COMPONENT_PRIVATE *pComponentPrivate = NULL; + OMX_U8 enable = 1, mode; + int ret; + pHandle = (OMX_COMPONENTTYPE *) hComponent; DOMX_ENTER(""); @@ -47,7 +60,33 @@ OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent) TIMM_OSAL_Memcpy(pComponentPrivate->cCompName, COMPONENT_NAME, strlen(COMPONENT_NAME) + 1); + if(DUCATI_IN_SECURE_MODE == 0) + { + DUCATI_IN_SECURE_MODE = 1; + pComponentPrivate->secure_misc_drv_fd = open("/dev/rproc_user", O_SYNC | O_RDWR); + if (pComponentPrivate->secure_misc_drv_fd < 0) + { + DOMX_ERROR("Can't open rproc_user device 0x%x\n", errno); + return OMX_ErrorInsufficientResources; + } + + ret = write(pComponentPrivate->secure_misc_drv_fd, &enable, sizeof(enable)); + if(ret != 1) + { + DOMX_ERROR("errno from setting secure mode = %x",errno); + } + PROXY_assert(ret == 1, OMX_ErrorUndefined,"ERROR: Unable to set secure mode"); + DOMX_DEBUG("ret value from Misc driver for secure playback = 0x%x\n", ret); + + ret = read(pComponentPrivate->secure_misc_drv_fd, &mode, sizeof(mode)); + PROXY_assert(mode == enable, OMX_ErrorUndefined,"ERROR: We are not in secure mode"); + DOMX_DEBUG("secure mode recieved from Misc driver for secure playback = 0x%x\n", mode); + } + + SECURE_COMPONENTS_RUNNING++; + eError = OMX_ProxyViddecInit(hComponent); + pHandle->ComponentDeInit = PROXY_VIDDEC_Secure_ComponentDeInit; #ifdef USE_ION pComponentPrivate->bUseIon = OMX_TRUE; @@ -56,3 +95,48 @@ OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent) EXIT: return eError; } + +OMX_ERRORTYPE PROXY_VIDDEC_Secure_ComponentDeInit(OMX_HANDLETYPE hComponent) +{ + OMX_ERRORTYPE eError = OMX_ErrorNone; + OMX_COMPONENTTYPE *pHandle = NULL; + PROXY_COMPONENT_PRIVATE *pComponentPrivate = NULL; + int ret; + OMX_U8 disable = 0; + int secure_misc_drv_fd; + + pHandle = (OMX_COMPONENTTYPE *) hComponent; + + pComponentPrivate = + (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate; + + secure_misc_drv_fd = pComponentPrivate->secure_misc_drv_fd; + + eError = PROXY_ComponentDeInit(hComponent); + if(eError != OMX_ErrorNone) + { + DOMX_ERROR("Proxy common deinit returned error = %x",eError); + } + pComponentPrivate = NULL; + + if(DUCATI_IN_SECURE_MODE == 1 && SECURE_COMPONENTS_RUNNING == 1) + { + ret = write(secure_misc_drv_fd, &disable, sizeof(disable)); + if (ret < 0) + { + DOMX_ERROR("Setting unsecure mode failed"); + } + + ret = close(secure_misc_drv_fd); + if (ret < 0) + { + DOMX_ERROR("Can't close the driver"); + } + DUCATI_IN_SECURE_MODE = 0; + } + + SECURE_COMPONENTS_RUNNING--; + + return eError; +} + diff --git a/omap4.mk b/omap4.mk index 0936b98e..2b02c86e 100644 --- a/omap4.mk +++ b/omap4.mk @@ -21,6 +21,7 @@ PRODUCT_PACKAGES := \ libOMX.TI.DUCATI1.VIDEO.H264E \ libOMX.TI.DUCATI1.VIDEO.MPEG4E \ libOMX.TI.DUCATI1.VIDEO.DECODER \ + libOMX.TI.DUCATI1.VIDEO.DECODER.secure \ libOMX.TI.DUCATI1.VIDEO.CAMERA \ libOMX.TI.DUCATI1.MISC.SAMPLE \ libstagefrighthw \ -- cgit v1.2.3 From d35bd9ffba0bf46e22259b545b7c0258d745686b Mon Sep 17 00:00:00 2001 From: Jeff Tinker Date: Fri, 7 Oct 2011 20:55:33 -0700 Subject: Revert "Enable Secure-component call into Misc driver" This reverts commit 5de6fb151c078f7c3718f6daa645d6d9d2ed717e --- domx/domx/omx_proxy_common.h | 1 - domx/domx/omx_rpc/src/omx_rpc.c | 20 ++---- domx/omx_core/src/OMX_Core.c | 12 ---- domx/omx_proxy_component/Android.mk | 31 -------- .../omx_video_dec/src/omx_proxy_videodec.c | 18 ++--- .../omx_video_dec/src/omx_proxy_videodec_secure.c | 84 ---------------------- omap4.mk | 1 - 7 files changed, 13 insertions(+), 154 deletions(-) diff --git a/domx/domx/omx_proxy_common.h b/domx/domx/omx_proxy_common.h index 8eb21e51..638cbc51 100755 --- a/domx/domx/omx_proxy_common.h +++ b/domx/domx/omx_proxy_common.h @@ -207,7 +207,6 @@ extern "C" OMX_BOOL bUseIon; OMX_BOOL bMapIonBuffers; #endif - int secure_misc_drv_fd; } PROXY_COMPONENT_PRIVATE; diff --git a/domx/domx/omx_rpc/src/omx_rpc.c b/domx/domx/omx_rpc/src/omx_rpc.c index d93134c2..ff1022b6 100755 --- a/domx/domx/omx_rpc/src/omx_rpc.c +++ b/domx/domx/omx_rpc/src/omx_rpc.c @@ -108,7 +108,7 @@ RPC_OMX_ERRORTYPE RPC_InstanceInit(OMX_STRING cComponentName, OMX_S32 status = 0; struct omx_conn_req sReq = { .name = "OMX" }; TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE; - OMX_U32 i = 0, nAttempts = 0; + OMX_U32 i = 0; *(RPC_OMX_CONTEXT **) phRPCCtx = NULL; @@ -126,21 +126,9 @@ RPC_OMX_ERRORTYPE RPC_InstanceInit(OMX_STRING cComponentName, /*Assuming that open maintains an internal count for multi instance */ DOMX_DEBUG("Calling open on the device"); - while (1) - { - pRPCCtx->fd_omx = open("/dev/rpmsg-omx1", O_RDWR); - if(pRPCCtx->fd_omx >= 0 || errno != ENOENT || nAttempts == 15) - break; - DOMX_DEBUG("errno from open= %d, REATTEMPTING OPEN!!!!",errno); - nAttempts++; - usleep(1000000); - } - if(pRPCCtx->fd_omx < 0) - { - DOMX_ERROR("Can't open device, errorno from open = %d",errno); - eError = RPC_OMX_ErrorInsufficientResources; - goto EXIT; - } + pRPCCtx->fd_omx = open("/dev/rpmsg-omx1", O_RDWR); + RPC_assert(pRPCCtx->fd_omx >= 0, RPC_OMX_ErrorInsufficientResources, + "Can't open device"); DOMX_DEBUG("Open was successful, pRPCCtx->fd_omx = %d", pRPCCtx->fd_omx); //AD diff --git a/domx/omx_core/src/OMX_Core.c b/domx/omx_core/src/OMX_Core.c index 8c2fb15f..fc439db5 100755 --- a/domx/omx_core/src/OMX_Core.c +++ b/domx/omx_core/src/OMX_Core.c @@ -113,8 +113,6 @@ extern OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent); goto EXIT; }\ } while(0) -OMX_U32 DUCATI_IN_SECURE_MODE = 0; -OMX_U32 SECURE_COMPONENTS_RUNNING = 0; /******************************Public*Routine******************************\ * OMX_Init() @@ -230,16 +228,6 @@ OMX_ERRORTYPE OMX_GetHandle(OMX_HANDLETYPE * pHandle, strcpy(buf, prefix); /* the lengths are defined herein or have been */ strcat(buf, cComponentName); /* checked already, so strcpy and strcat are */ strcat(buf, postfix); /* are safe to use in this context. */ - - if(DUCATI_IN_SECURE_MODE == 1) - { - if(strstr(cComponentName,"secure") == NULL) - { - TIMM_OSAL_Error("non-secure component not supported in secure mode"); - eError = OMX_ErrorComponentNotFound; - goto EXIT; - } - } //#if 0 pModules[i] = dlopen(buf, RTLD_LAZY | RTLD_GLOBAL); if (pModules[i] == NULL) diff --git a/domx/omx_proxy_component/Android.mk b/domx/omx_proxy_component/Android.mk index 4ebd727e..fede2376 100644 --- a/domx/omx_proxy_component/Android.mk +++ b/domx/omx_proxy_component/Android.mk @@ -159,34 +159,3 @@ LOCAL_SRC_FILES:= omx_mpeg4_enc/src/omx_proxy_mpeg4enc.c LOCAL_MODULE:= libOMX.TI.DUCATI1.VIDEO.MPEG4E include $(BUILD_HEAPTRACKED_SHARED_LIBRARY) -# -# libOMX.TI.DUCATI1.VIDEO.DECODER.secure -# - -include $(CLEAR_VARS) - -LOCAL_C_INCLUDES += \ - $(LOCAL_PATH)/../omx_core/inc \ - $(LOCAL_PATH)/../mm_osal/inc \ - $(LOCAL_PATH)/../domx \ - $(LOCAL_PATH)/../domx/omx_rpc/inc \ - $(HARDWARE_TI_OMAP4_BASE)/../../libhardware/include \ - $(HARDWARE_TI_OMAP4_BASE)/hwc/ - -LOCAL_SHARED_LIBRARIES := \ - libmm_osal \ - libc \ - libOMX_Core \ - liblog \ - libdomx \ - libhardware \ - libOMX.TI.DUCATI1.VIDEO.DECODER - -LOCAL_CFLAGS += -DLINUX -DTMS32060 -D_DB_TIOMAP -DSYSLINK_USE_SYSMGR -DSYSLINK_USE_LOADER -LOCAL_CFLAGS += -D_Android -DSET_STRIDE_PADDING_FROM_PROXY -DANDROID_QUIRK_CHANGE_PORT_VALUES -DUSE_ENHANCED_PORTRECONFIG -LOCAL_CFLAGS += -DANDROID_QUIRK_LOCK_BUFFER -DUSE_ION -DENABLE_GRALLOC_BUFFERS -LOCAL_MODULE_TAGS:= optional - -LOCAL_SRC_FILES:= omx_video_dec/src/omx_proxy_videodec_secure.c -LOCAL_MODULE:= libOMX.TI.DUCATI1.VIDEO.DECODER.secure -include $(BUILD_HEAPTRACKED_SHARED_LIBRARY) diff --git a/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec.c b/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec.c index 1b0d8f5c..572592b0 100755 --- a/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec.c +++ b/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec.c @@ -151,6 +151,13 @@ OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent) OMX_ErrorInsufficientResources, " Error in Allocating space for proxy component table"); + // Copying component Name - this will be picked up in the proxy common + PROXY_assert(strlen(COMPONENT_NAME) + 1 < MAX_COMPONENT_NAME_LENGTH, + OMX_ErrorInvalidComponentName, + "Length of component name is longer than the max allowed"); + TIMM_OSAL_Memcpy(pComponentPrivate->cCompName, COMPONENT_NAME, + strlen(COMPONENT_NAME) + 1); + eError = OMX_ProxyViddecInit(hComponent); EXIT: @@ -173,15 +180,8 @@ OMX_ERRORTYPE OMX_ProxyViddecInit(OMX_HANDLETYPE hComponent) DOMX_DEBUG("Component name provided is %s", COMPONENT_NAME); - pComponentPrivate = - (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate; - - // Copying component Name - this will be picked up in the proxy common - PROXY_assert(strlen(COMPONENT_NAME) + 1 < MAX_COMPONENT_NAME_LENGTH, - OMX_ErrorInvalidComponentName, - "Length of component name is longer than the max allowed"); - TIMM_OSAL_Memcpy(pComponentPrivate->cCompName, COMPONENT_NAME, - strlen(COMPONENT_NAME) + 1); + pComponentPrivate = + (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate; eError = OMX_ProxyCommonInit(hComponent); // Calling Proxy Common Init() PROXY_assert(eError == OMX_ErrorNone, eError, "Proxy common init returned error"); diff --git a/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_secure.c b/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_secure.c index f0db1f50..616d6992 100644 --- a/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_secure.c +++ b/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_secure.c @@ -3,27 +3,14 @@ #include #include "omx_proxy_common.h" #include -#include -#include -#include -#include #define COMPONENT_NAME "OMX.TI.DUCATI1.VIDEO.DECODER.secure" -extern OMX_U32 DUCATI_IN_SECURE_MODE; -extern OMX_U32 SECURE_COMPONENTS_RUNNING; - -extern OMX_ERRORTYPE OMX_ProxyViddecInit(OMX_HANDLETYPE hComponent); -OMX_ERRORTYPE PROXY_VIDDEC_Secure_ComponentDeInit(OMX_HANDLETYPE hComponent); - OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent) { OMX_ERRORTYPE eError = OMX_ErrorNone; OMX_COMPONENTTYPE *pHandle = NULL; PROXY_COMPONENT_PRIVATE *pComponentPrivate = NULL; - OMX_U8 enable = 1, mode; - int ret; - pHandle = (OMX_COMPONENTTYPE *) hComponent; DOMX_ENTER(""); @@ -60,33 +47,7 @@ OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent) TIMM_OSAL_Memcpy(pComponentPrivate->cCompName, COMPONENT_NAME, strlen(COMPONENT_NAME) + 1); - if(DUCATI_IN_SECURE_MODE == 0) - { - DUCATI_IN_SECURE_MODE = 1; - pComponentPrivate->secure_misc_drv_fd = open("/dev/rproc_user", O_SYNC | O_RDWR); - if (pComponentPrivate->secure_misc_drv_fd < 0) - { - DOMX_ERROR("Can't open rproc_user device 0x%x\n", errno); - return OMX_ErrorInsufficientResources; - } - - ret = write(pComponentPrivate->secure_misc_drv_fd, &enable, sizeof(enable)); - if(ret != 1) - { - DOMX_ERROR("errno from setting secure mode = %x",errno); - } - PROXY_assert(ret == 1, OMX_ErrorUndefined,"ERROR: Unable to set secure mode"); - DOMX_DEBUG("ret value from Misc driver for secure playback = 0x%x\n", ret); - - ret = read(pComponentPrivate->secure_misc_drv_fd, &mode, sizeof(mode)); - PROXY_assert(mode == enable, OMX_ErrorUndefined,"ERROR: We are not in secure mode"); - DOMX_DEBUG("secure mode recieved from Misc driver for secure playback = 0x%x\n", mode); - } - - SECURE_COMPONENTS_RUNNING++; - eError = OMX_ProxyViddecInit(hComponent); - pHandle->ComponentDeInit = PROXY_VIDDEC_Secure_ComponentDeInit; #ifdef USE_ION pComponentPrivate->bUseIon = OMX_TRUE; @@ -95,48 +56,3 @@ OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent) EXIT: return eError; } - -OMX_ERRORTYPE PROXY_VIDDEC_Secure_ComponentDeInit(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - PROXY_COMPONENT_PRIVATE *pComponentPrivate = NULL; - int ret; - OMX_U8 disable = 0; - int secure_misc_drv_fd; - - pHandle = (OMX_COMPONENTTYPE *) hComponent; - - pComponentPrivate = - (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate; - - secure_misc_drv_fd = pComponentPrivate->secure_misc_drv_fd; - - eError = PROXY_ComponentDeInit(hComponent); - if(eError != OMX_ErrorNone) - { - DOMX_ERROR("Proxy common deinit returned error = %x",eError); - } - pComponentPrivate = NULL; - - if(DUCATI_IN_SECURE_MODE == 1 && SECURE_COMPONENTS_RUNNING == 1) - { - ret = write(secure_misc_drv_fd, &disable, sizeof(disable)); - if (ret < 0) - { - DOMX_ERROR("Setting unsecure mode failed"); - } - - ret = close(secure_misc_drv_fd); - if (ret < 0) - { - DOMX_ERROR("Can't close the driver"); - } - DUCATI_IN_SECURE_MODE = 0; - } - - SECURE_COMPONENTS_RUNNING--; - - return eError; -} - diff --git a/omap4.mk b/omap4.mk index 2b02c86e..0936b98e 100644 --- a/omap4.mk +++ b/omap4.mk @@ -21,7 +21,6 @@ PRODUCT_PACKAGES := \ libOMX.TI.DUCATI1.VIDEO.H264E \ libOMX.TI.DUCATI1.VIDEO.MPEG4E \ libOMX.TI.DUCATI1.VIDEO.DECODER \ - libOMX.TI.DUCATI1.VIDEO.DECODER.secure \ libOMX.TI.DUCATI1.VIDEO.CAMERA \ libOMX.TI.DUCATI1.MISC.SAMPLE \ libstagefrighthw \ -- cgit v1.2.3 From 5a4102c53c97fb8a3a0f794143d7935a00e77f79 Mon Sep 17 00:00:00 2001 From: Milen Mitkov Date: Wed, 30 Nov 2011 17:01:58 +0200 Subject: CameraHAL: Perform focus even if CAF has failed Fixes b/5534973 Used to force focus if CAF has failed (before capture). CAF's state is 'failed' even if a scene change is detected only. Change-Id: I0878a9f862b7800b566e578efdfa62baec7e5889 Signed-off-by: Milen Mitkov --- camera/OMXCameraAdapter/OMXFocus.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/camera/OMXCameraAdapter/OMXFocus.cpp b/camera/OMXCameraAdapter/OMXFocus.cpp index 30ce3c1d..b48cfecd 100644 --- a/camera/OMXCameraAdapter/OMXFocus.cpp +++ b/camera/OMXCameraAdapter/OMXFocus.cpp @@ -153,7 +153,8 @@ status_t OMXCameraAdapter::doAutoFocus() } if ( (focusControl.eFocusControl == OMX_IMAGE_FocusControlAuto - && focusStatus.eFocusStatus == OMX_FocusStatusRequest) || + && (focusStatus.eFocusStatus == OMX_FocusStatusRequest + || focusStatus.eFocusStatus == OMX_FocusStatusUnableToReach) ) || (mParameters3A.Focus != (OMX_IMAGE_FOCUSCONTROLTYPE)OMX_IMAGE_FocusControlAuto) ) { OMX_INIT_STRUCT_PTR (&bOMX, OMX_CONFIG_BOOLEANTYPE); @@ -170,6 +171,14 @@ status_t OMXCameraAdapter::doAutoFocus() OMX_IndexConfigCommonFocusStatus, mDoAFSem); + // force AF, Ducati will take care of whether CAF + // or AF will be performed, depending on light conditions + if ( focusControl.eFocusControl == OMX_IMAGE_FocusControlAuto + && focusStatus.eFocusStatus == OMX_FocusStatusUnableToReach ) + { + focusControl.eFocusControl = OMX_IMAGE_FocusControlAutoLock; + } + if ( focusControl.eFocusControl != OMX_IMAGE_FocusControlAuto ) { eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, -- cgit v1.2.3 From 9868c22360da99c90ef404474dfac8bad6fd536c Mon Sep 17 00:00:00 2001 From: Milen Mitkov Date: Wed, 12 Oct 2011 17:01:19 +0300 Subject: CameraHAL: Enable LDCNSF for Video snapshot Enables LDCNSF for Video snapshot, also adds start_offset and right_crop fields to the JPEG encoder wrapper, because the image with LDCNSF has artifacts on top and right. Change-Id: I1011252e3f8068083f9d057b7763b7f79c59a75d Signed-off-by: Milen Mitkov --- camera/AppCallbackNotifier.cpp | 16 ++++++++++++++-- camera/Encoder_libjpeg.cpp | 11 +++++++---- camera/OMXCameraAdapter/OMXAlgo.cpp | 3 ++- camera/OMXCameraAdapter/OMXCameraAdapter.cpp | 1 + camera/OMXCameraAdapter/OMXCapture.cpp | 2 +- camera/inc/Encoder_libjpeg.h | 2 ++ 6 files changed, 27 insertions(+), 8 deletions(-) diff --git a/camera/AppCallbackNotifier.cpp b/camera/AppCallbackNotifier.cpp index 29143075..bfdd6718 100644 --- a/camera/AppCallbackNotifier.cpp +++ b/camera/AppCallbackNotifier.cpp @@ -844,16 +844,26 @@ void AppCallbackNotifier::notifyFrame() main_jpeg = (Encoder_libjpeg::params*) malloc(sizeof(Encoder_libjpeg::params)); + + // Video snapshot with LDCNSF on adds a few bytes start offset + // and a few bytes on every line. They must be skipped. + int rightCrop = frame->mAlignment/2 - frame->mWidth; + + CAMHAL_LOGDB("Video snapshot right crop = %d", rightCrop); + CAMHAL_LOGDB("Video snapshot offset = %d", frame->mOffset); + if (main_jpeg) { main_jpeg->src = (uint8_t*) frame->mBuffer; main_jpeg->src_size = frame->mLength; main_jpeg->dst = (uint8_t*) buf; main_jpeg->dst_size = frame->mLength; main_jpeg->quality = encode_quality; - main_jpeg->in_width = frame->mWidth; + main_jpeg->in_width = frame->mAlignment/2; // use stride here main_jpeg->in_height = frame->mHeight; - main_jpeg->out_width = frame->mWidth; + main_jpeg->out_width = frame->mAlignment/2; main_jpeg->out_height = frame->mHeight; + main_jpeg->right_crop = rightCrop; + main_jpeg->start_offset = frame->mOffset; main_jpeg->format = CameraParameters::PIXEL_FORMAT_YUV422I; } @@ -882,6 +892,8 @@ void AppCallbackNotifier::notifyFrame() tn_jpeg->in_height = height; tn_jpeg->out_width = tn_width; tn_jpeg->out_height = tn_height; + tn_jpeg->right_crop = 0; + tn_jpeg->start_offset = 0; tn_jpeg->format = CameraParameters::PIXEL_FORMAT_YUV420SP;; } diff --git a/camera/Encoder_libjpeg.cpp b/camera/Encoder_libjpeg.cpp index 0240fb0d..7a6054f4 100644 --- a/camera/Encoder_libjpeg.cpp +++ b/camera/Encoder_libjpeg.cpp @@ -357,6 +357,7 @@ size_t Encoder_libjpeg::encode(params* input) { int out_width = 0, in_width = 0; int out_height = 0, in_height = 0; int bpp = 2; // for uyvy + int right_crop = 0, start_offset = 0; if (!input) { return 0; @@ -366,6 +367,8 @@ size_t Encoder_libjpeg::encode(params* input) { in_width = input->in_width; out_height = input->out_height; in_height = input->in_height; + right_crop = input->right_crop; + start_offset = input->start_offset; src = input->src; input->jpeg_size = 0; @@ -408,7 +411,7 @@ size_t Encoder_libjpeg::encode(params* input) { input->dst_size, src); cinfo.dest = &dest_mgr; - cinfo.image_width = out_width; + cinfo.image_width = out_width - right_crop; cinfo.image_height = out_height; cinfo.input_components = 3; cinfo.in_color_space = JCS_YCbCr; @@ -421,7 +424,7 @@ size_t Encoder_libjpeg::encode(params* input) { jpeg_start_compress(&cinfo, TRUE); row_tmp = (uint8_t*)malloc(out_width * 3); - row_src = src; + row_src = src + start_offset; row_uv = src + out_width * out_height * bpp; while ((cinfo.next_scanline < cinfo.image_height) && !mCancelEncoding) { @@ -429,9 +432,9 @@ size_t Encoder_libjpeg::encode(params* input) { // convert input yuv format to yuv444 if (strcmp(input->format, CameraParameters::PIXEL_FORMAT_YUV420SP) == 0) { - nv21_to_yuv(row_tmp, row_src, row_uv, out_width); + nv21_to_yuv(row_tmp, row_src, row_uv, out_width - right_crop); } else { - uyvy_to_yuv(row_tmp, (uint32_t*)row_src, out_width); + uyvy_to_yuv(row_tmp, (uint32_t*)row_src, out_width - right_crop); } row[0] = row_tmp; diff --git a/camera/OMXCameraAdapter/OMXAlgo.cpp b/camera/OMXCameraAdapter/OMXAlgo.cpp index c19e0462..5924ddeb 100644 --- a/camera/OMXCameraAdapter/OMXAlgo.cpp +++ b/camera/OMXCameraAdapter/OMXAlgo.cpp @@ -83,7 +83,8 @@ status_t OMXCameraAdapter::setParametersAlgo(const CameraParameters ¶ms, /// Configure IPP, LDCNSF, GBCE and GLBCE only in HQ mode IPPMode ipp; - if((mCapMode == OMXCameraAdapter::HIGH_QUALITY) || (mCapMode == OMXCameraAdapter::HIGH_QUALITY_ZSL)) + if((mCapMode == OMXCameraAdapter::HIGH_QUALITY) || (mCapMode == OMXCameraAdapter::HIGH_QUALITY_ZSL) + || (mCapMode == OMXCameraAdapter::VIDEO_MODE) ) { if ( (valstr = params.get(TICameraParameters::KEY_IPP)) != NULL ) { diff --git a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp b/camera/OMXCameraAdapter/OMXCameraAdapter.cpp index ee818aee..aa32ede0 100755 --- a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp +++ b/camera/OMXCameraAdapter/OMXCameraAdapter.cpp @@ -864,6 +864,7 @@ status_t OMXCameraAdapter::setFormat(OMX_U32 port, OMXCameraPortParameters &port GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); portParams.mBufSize = portCheck.nBufferSize; + portParams.mStride = portCheck.format.image.nStride; if ( OMX_CAMERA_PORT_IMAGE_OUT_IMAGE == port ) { diff --git a/camera/OMXCameraAdapter/OMXCapture.cpp b/camera/OMXCameraAdapter/OMXCapture.cpp index 9ba438cc..38eb2f8b 100644 --- a/camera/OMXCameraAdapter/OMXCapture.cpp +++ b/camera/OMXCameraAdapter/OMXCapture.cpp @@ -57,7 +57,7 @@ status_t OMXCameraAdapter::setParametersCapture(const CameraParameters ¶ms, cap->mWidth = w; cap->mHeight = h; //TODO: Support more pixelformats - cap->mStride = 2; + //cap->mStride = 2; CAMHAL_LOGVB("Image: cap.mWidth = %d", (int)cap->mWidth); CAMHAL_LOGVB("Image: cap.mHeight = %d", (int)cap->mHeight); diff --git a/camera/inc/Encoder_libjpeg.h b/camera/inc/Encoder_libjpeg.h index e3e9ac55..fef873f2 100755 --- a/camera/inc/Encoder_libjpeg.h +++ b/camera/inc/Encoder_libjpeg.h @@ -97,6 +97,8 @@ class Encoder_libjpeg : public Thread { int in_height; int out_width; int out_height; + int right_crop; + int start_offset; const char* format; size_t jpeg_size; }; -- cgit v1.2.3