summaryrefslogtreecommitdiff
authorjiyu.yang <jiyu.yang@amlogic.com>2013-01-15 06:38:15 (GMT)
committer jiyu.yang <jiyu.yang@amlogic.com>2013-01-15 06:38:15 (GMT)
commit40d1c7c015f81aea418763d824a4d189b9d95a5a (patch)
treef5ddea0172649116fdc281c481475493087710b8
parent762776f3ab12d13fe63db7341d43a581ba519b42 (diff)
downloadcamera-40d1c7c015f81aea418763d824a4d189b9d95a5a.zip
camera-40d1c7c015f81aea418763d824a4d189b9d95a5a.tar.gz
camera-40d1c7c015f81aea418763d824a4d189b9d95a5a.tar.bz2
initialize the specified cameraid when open
if must load every time should set RELOAD_WHEN_OPEN key to 1.
Diffstat
-rwxr-xr-xCameraHal.cpp1
-rwxr-xr-xCameraHal_Module.cpp3
-rwxr-xr-xCameraParameters.cpp2
-rwxr-xr-xCameraProperties.cpp68
-rwxr-xr-xV4LCameraAdapter/V4LCameraAdapter.cpp6
-rwxr-xr-xinc/CameraProperties.h3
6 files changed, 45 insertions, 38 deletions
diff --git a/CameraHal.cpp b/CameraHal.cpp
index 4478ed5..0f501bc 100755
--- a/CameraHal.cpp
+++ b/CameraHal.cpp
@@ -2232,6 +2232,7 @@ void CameraHal::stopRecording()
// reset internal recording hint in case camera adapter needs to make some
// decisions....(will only be sent to camera adapter if camera restart is required)
mParameters.remove(ExCameraParameters::KEY_RECORDING_HINT);
+ mParameters.remove(CameraProperties::RELOAD_WHEN_OPEN);
LOG_FUNCTION_NAME_EXIT;
}
diff --git a/CameraHal_Module.cpp b/CameraHal_Module.cpp
index ef1e623..5914da3 100755
--- a/CameraHal_Module.cpp
+++ b/CameraHal_Module.cpp
@@ -649,7 +649,8 @@ int camera_get_camera_info(int camera_id, struct camera_info *info)
LOGD("camera_get_camera_info camera_id=%d", camera_id);
// this going to be the first call from camera service
// initialize camera properties here...
- if(gCameraProperties.initialize() != android::NO_ERROR)
+ if( ( gCamerasOpen == 0 )
+ && (gCameraProperties.initialize(camera_id) != android::NO_ERROR))
{
CAMHAL_LOGEA("Unable to create or initialize CameraProperties");
return -EINVAL;
diff --git a/CameraParameters.cpp b/CameraParameters.cpp
index 79b2819..a71c019 100755
--- a/CameraParameters.cpp
+++ b/CameraParameters.cpp
@@ -107,7 +107,7 @@ const char CameraProperties::VIDEO_SIZE[] = "video-size";
const char CameraProperties::PREFERRED_PREVIEW_SIZE_FOR_VIDEO[] = "preferred-preview-size-for-video";
const char CameraProperties::PIXEL_FORMAT_RGB24[] = "rgb24";
-
+const char CameraProperties::RELOAD_WHEN_OPEN[]="prop-reload-key";
const char CameraProperties::DEFAULT_VALUE[] = "";
diff --git a/CameraProperties.cpp b/CameraProperties.cpp
index 7bb7c24..72191a6 100755
--- a/CameraProperties.cpp
+++ b/CameraProperties.cpp
@@ -33,6 +33,9 @@ namespace android {
#define LOGE ALOGE
#define LOGI ALOGI
+extern "C" int CameraAdapter_CameraNum();
+extern "C" void loadCaps(int camera_id, CameraProperties::Properties* params);
+
/*********************************************************
CameraProperties - public function implemetation
**********************************************************/
@@ -56,35 +59,50 @@ CameraProperties::~CameraProperties()
// Initializes the CameraProperties class
-status_t CameraProperties::initialize()
+status_t CameraProperties::initialize(int cameraid)
{
LOG_FUNCTION_NAME;
- status_t ret;
+ status_t ret = NO_ERROR;
Mutex::Autolock lock(mLock);
- if(mInitialized)
- return NO_ERROR;
+ LOGD("%s\n", mInitialized?"initialized":"no initialize");
-#ifdef AMLOGIC_USB_CAMERA_SUPPORT
- mCamerasSupported = 0;
- ret = loadProperties();
- mInitialized = 0;
-#else
- ret = loadProperties();
- mInitialized = 1;
-#endif
+ LOGD("mCamerasSupported=%d\n", mCamerasSupported);
+ if( !mInitialized ){
- LOG_FUNCTION_NAME_EXIT;
+ LOGD("no initialized loadCaps all\n");
+ int temp = CameraAdapter_CameraNum();
+ for ( int i = 0; i < temp; i++) {
+ LOGD("mCameraProps[%d]=%p\n", i, &mCameraProps[i]);
+ mInitialized |= (1 << cameraid);
+ mCamerasSupported ++;
+ mCameraProps[i].set(CameraProperties::CAMERA_SENSOR_INDEX, i);
+ loadCaps(i, &mCameraProps[i]);
+ mCameraProps[i].dump();
+ }
+
+ }else{
+
+ if(!strcmp( mCameraProps[cameraid].get(CameraProperties::RELOAD_WHEN_OPEN), "1") ){
+ LOGD("re loadCaps again\n");
+ LOGD("mCameraProps[%d]=%p\n", cameraid, &mCameraProps[cameraid]);
+ loadCaps(cameraid, &mCameraProps[cameraid]);
+ }else{
+ LOGD("%s,%d, device dont need reload return\n", __func__, __LINE__);
+ }
+
+ }
+ LOG_FUNCTION_NAME_EXIT;
return ret;
+
}
extern "C" int CameraAdapter_Capabilities(CameraProperties::Properties* properties_array,
const unsigned int starting_camera,
const unsigned int camera_num);
-extern "C" int CameraAdapter_CameraNum();
///Loads all the Camera related properties
status_t CameraProperties::loadProperties()
@@ -92,27 +110,7 @@ status_t CameraProperties::loadProperties()
LOG_FUNCTION_NAME;
status_t ret = NO_ERROR;
-
- // adapter updates capabilities and we update camera count
- mCamerasSupported = CameraAdapter_Capabilities(mCameraProps, mCamerasSupported, CameraAdapter_CameraNum());
-
- if((int)mCamerasSupported < 0) {
- LOGE("error while getting capabilities");
- ret = UNKNOWN_ERROR;
- } else if (mCamerasSupported > MAX_CAMERAS_SUPPORTED) {
- LOGE("returned too many adapaters");
- ret = UNKNOWN_ERROR;
- } else {
- LOGE("num_cameras = %d", mCamerasSupported);
-
- for (unsigned int i = 0; i < mCamerasSupported; i++) {
- mCameraProps[i].set(CAMERA_SENSOR_INDEX, i);
- mCameraProps[i].dump();
- }
- }
-
- LOGV("mCamerasSupported = %d", mCamerasSupported);
- LOG_FUNCTION_NAME_EXIT;
+ LOGD("%s,%d,this func delete!!!\n", __func__, __LINE__);
return ret;
}
diff --git a/V4LCameraAdapter/V4LCameraAdapter.cpp b/V4LCameraAdapter/V4LCameraAdapter.cpp
index b3e268f..b0825fd 100755
--- a/V4LCameraAdapter/V4LCameraAdapter.cpp
+++ b/V4LCameraAdapter/V4LCameraAdapter.cpp
@@ -2641,6 +2641,12 @@ extern "C" void loadCaps(int camera_id, CameraProperties::Properties* params) {
}
}
+#ifdef AMLOGIC_USB_CAMERA_SUPPORT
+ params->set(CameraProperties::RELOAD_WHEN_OPEN, "1");
+
+#else
+ params->set(CameraProperties::RELOAD_WHEN_OPEN, "0");
+#endif
params->set(CameraProperties::SUPPORTED_PREVIEW_FORMATS,"yuv420sp,yuv420p"); //yuv420p for cts
if(DEFAULT_PREVIEW_PIXEL_FORMAT == V4L2_PIX_FMT_YUYV){ // 422I
//params->set(CameraProperties::SUPPORTED_PREVIEW_FORMATS,PREVIEW_FORMAT_422I);
diff --git a/inc/CameraProperties.h b/inc/CameraProperties.h
index c47613d..abcb2e4 100755
--- a/inc/CameraProperties.h
+++ b/inc/CameraProperties.h
@@ -151,6 +151,7 @@ public:
static const char PREFERRED_PREVIEW_SIZE_FOR_VIDEO[];
static const char PIXEL_FORMAT_RGB24[];
+ static const char RELOAD_WHEN_OPEN[];
CameraProperties();
~CameraProperties();
@@ -189,7 +190,7 @@ public:
};
///Initializes the CameraProperties class
- status_t initialize();
+ status_t initialize(int cameraid);
status_t loadProperties();
int camerasSupported();
int getProperties(int cameraIndex, Properties** properties);