概述
系统默认只支持两路Camera,只要将CameraHal中的数量限制改掉就可以了。
另外,有些地方直接用0和1表示Camera通道,也要做相应修改。
注意:因为Android只定义了Front和Back两种Camera属性,所以不能使用默认的APK测试。
patch:
diff --git a/device/rockchip/common/ueventd.rockchip.rc b/device/rockchip/common/ueventd.rockchip.rc
index 7316ebf..e73da8d 100755
--- a/device/rockchip/common/ueventd.rockchip.rc
+++ b/device/rockchip/common/ueventd.rockchip.rc
@@ -19,6 +19,23 @@
/dev/video1 0660 media camera
/dev/video2 0660 media camera
/dev/video3 0660 media camera
+/dev/video4 0660 media camera
+/dev/video5 0660 media camera
+/dev/video6 0660 media camera
+/dev/video7 0660 media camera
+/dev/video8 0660 media camera
+/dev/video9 0660 media camera
+/dev/video10 0660 media camera
+/dev/video11 0660 media camera
+/dev/video12 0660 media camera
+/dev/video13 0660 media camera
+/dev/video14 0660 media camera
+/dev/video15 0660 media camera
+/dev/video16 0660 media camera
+/dev/video17 0660 media camera
+/dev/video18 0660 media camera
+/dev/video19 0660 media camera
+/dev/video20 0660 media camera
/dev/pmem_cam 0660 system camera
/dev/vpu 0660 system system
/dev/vpu_service 0666 media media
diff --git a/hardware/rockchip/camera/CameraHal/CameraHal_Module.cpp b/hardware/rockchip/camera/CameraHal/CameraHal_Module.cpp
index 3365339..012d14e 100755
--- a/hardware/rockchip/camera/CameraHal/CameraHal_Module.cpp
+++ b/hardware/rockchip/camera/CameraHal/CameraHal_Module.cpp
@@ -712,9 +712,10 @@ int usb_camera_hotplug(void)
(strcmp(usbcameraPlug, "remove") == 0);
return plugstate;
}
-
+//modify by fujianyong for [Supporting multiple cameras] start
int camera_get_number_of_cameras(void)
{
+ char cam_sys[40];
char cam_path[20];
char cam_num[3],i;
int cam_cnt=0,fd=-1,rk29_cam[CAMERAS_SUPPORT_MAX];
@@ -770,9 +771,11 @@ int camera_get_number_of_cameras(void)
delete camEngVerItf;
}
-
- memset(&camInfoTmp[0],0x00,sizeof(rk_cam_info_t));
- memset(&camInfoTmp[1],0x00,sizeof(rk_cam_info_t));
+ for(int i=0;i<CAMERAS_SUPPORT_MAX;i++){
+ memset(&camInfoTmp[i],0x00,sizeof(rk_cam_info_t));
+ }
+ //memset(&camInfoTmp[0],0x00,sizeof(rk_cam_info_t));
+ //memset(&camInfoTmp[1],0x00,sizeof(rk_cam_info_t));
profiles = camera_board_profiles::getInstance();
nCamDev = profiles->mDevieVector.size();
@@ -787,18 +790,18 @@ int camera_get_number_of_cameras(void)
if(profiles->mDevieVector[i]->mIsConnect==1){
rk_sensor_info *pSensorInfo = &(profiles->mDevieVector[i]->mHardInfo.mSensorInfo);
- camInfoTmp[cam_cnt&0x01].pcam_total_info = profiles->mDevieVector[i];
- strncpy(camInfoTmp[cam_cnt&0x01].device_path, pSensorInfo->mCamsysDevPath, sizeof(camInfoTmp[cam_cnt&0x01].device_path));
- strncpy(camInfoTmp[cam_cnt&0x01].driver, pSensorInfo->mSensorDriver, sizeof(camInfoTmp[cam_cnt&0x01].driver));
+ camInfoTmp[cam_cnt].pcam_total_info = profiles->mDevieVector[i];
+ strncpy(camInfoTmp[cam_cnt].device_path, pSensorInfo->mCamsysDevPath, sizeof(camInfoTmp[cam_cnt].device_path));
+ strncpy(camInfoTmp[cam_cnt].driver, pSensorInfo->mSensorDriver, sizeof(camInfoTmp[cam_cnt].driver));
unsigned int SensorDrvVersion = profiles->mDevieVector[i]->mLoadSensorInfo.mpI2cInfo->sensor_drv_version;
memset(version,0x00,sizeof(version));
sprintf(version,"%d.%d.%d",((SensorDrvVersion&0xff0000)>>16),
((SensorDrvVersion&0xff00)>>8),SensorDrvVersion&0xff);
if(pSensorInfo->mFacing == RK_CAM_FACING_FRONT){
- camInfoTmp[cam_cnt&0x01].facing_info.facing = CAMERA_FACING_FRONT;
+ camInfoTmp[cam_cnt].facing_info.facing = CAMERA_FACING_FRONT;
} else {
- camInfoTmp[cam_cnt&0x01].facing_info.facing = CAMERA_FACING_BACK;
+ camInfoTmp[cam_cnt].facing_info.facing = CAMERA_FACING_BACK;
}
memset(sensor_ver,0x00,sizeof(sensor_ver));
@@ -808,7 +811,7 @@ int camera_get_number_of_cameras(void)
sprintf(sensor_ver,"%s",pSensorInfo->mSensorName);
property_set(sensor_ver, version);
- camInfoTmp[cam_cnt&0x01].facing_info.orientation = pSensorInfo->mOrientation;
+ camInfoTmp[cam_cnt].facing_info.orientation = pSensorInfo->mOrientation;
cam_cnt++;
unsigned int CamsysDrvVersion = profiles->mDevieVector[i]->mCamsysVersion.drv_ver;
@@ -833,13 +836,34 @@ int camera_get_number_of_cameras(void)
i++;
}
- for (i=0; i<10; i++) {
+ for (i=0; i<20; i++) {
cam_path[0] = 0x00;
- unsigned int pix_format_tmp = V4L2_PIX_FMT_NV12;
- strcat(cam_path, CAMERA_DEVICE_NAME);
+ //unsigned int pix_format_tmp = V4L2_PIX_FMT_NV12;
+ //strcat(cam_path, CAMERA_DEVICE_NAME);
+ cam_sys[0] = 0x00;
+ strcat(cam_sys, CAM_SYS_NAME);
sprintf(cam_num, "%d", i);
+ strcat(cam_sys,cam_num);
+ strcat(cam_sys,"/index");
+ FILE* ifp;
+ ifp = fopen(cam_sys, "r");
+ if (ifp == NULL){
+ LOGD("fail to open sys file:%s",cam_sys);
+ continue;
+ }
+ unsigned char index;
+ fread(&index, sizeof(char),1, ifp);
+ fclose(ifp);
+ LOGD("open %s index %x",cam_sys,index);
+ if(index == 0x31){
+ LOGD("%s wrong index continue",cam_sys);
+ continue;
+ }
+ strcat(cam_path, CAMERA_DEVICE_NAME);
+
strcat(cam_path,cam_num);
fd = open(cam_path, O_RDONLY);
+ unsigned int pix_format_tmp = V4L2_PIX_FMT_NV12;
if (fd < 0) {
LOGE("Open %s failed! strr: %s",cam_path,strerror(errno));
break;
@@ -856,31 +880,31 @@ int camera_get_number_of_cameras(void)
LOGD("Video device(%s): video capture not supported.n",cam_path);
} else {
rk_cam_total_info* pNewCamInfo = new rk_cam_total_info();
- memset(camInfoTmp[cam_cnt&0x01].device_path,0x00, sizeof(camInfoTmp[cam_cnt&0x01].device_path));
- strcat(camInfoTmp[cam_cnt&0x01].device_path,cam_path);
- memset(camInfoTmp[cam_cnt&0x01].fival_list,0x00, sizeof(camInfoTmp[cam_cnt&0x01].fival_list));
- memcpy(camInfoTmp[cam_cnt&0x01].driver,capability.driver, sizeof(camInfoTmp[cam_cnt&0x01].driver));
- camInfoTmp[cam_cnt&0x01].version = capability.version;
+ memset(camInfoTmp[cam_cnt].device_path,0x00, sizeof(camInfoTmp[cam_cnt].device_path));
+ strcat(camInfoTmp[cam_cnt].device_path,cam_path);
+ memset(camInfoTmp[cam_cnt].fival_list,0x00, sizeof(camInfoTmp[cam_cnt].fival_list));
+ memcpy(camInfoTmp[cam_cnt].driver,capability.driver, sizeof(camInfoTmp[cam_cnt].driver));
+ camInfoTmp[cam_cnt].version = capability.version;
if (strstr((char*)&capability.card[0], "front") != NULL) {
- camInfoTmp[cam_cnt&0x01].facing_info.facing = CAMERA_FACING_FRONT;
+ camInfoTmp[cam_cnt].facing_info.facing = CAMERA_FACING_FRONT;
#ifdef LAPTOP
} else if (strstr((char*)&capability.card[0], "HP HD") != NULL
|| strstr((char*)&capability.card[0], "HP IR")) {
- camInfoTmp[cam_cnt&0x01].facing_info.facing = CAMERA_FACING_FRONT;
+ camInfoTmp[cam_cnt].facing_info.facing = CAMERA_FACING_FRONT;
if (strstr((char*)&capability.card[0], "HP IR"))
gCamerasUnavailabled++;
- gUsbCameraNames[cam_cnt&0x01] = String8((char*)&capability.card[0]);
- LOGD("Camera %d name: %s", (cam_cnt&0x01), gUsbCameraNames[cam_cnt&0x01].string());
+ gUsbCameraNames[cam_cnt] = String8((char*)&capability.card[0]);
+ LOGD("Camera %d name: %s", (cam_cnt), gUsbCameraNames[cam_cnt].string());
#endif
} else {
- camInfoTmp[cam_cnt&0x01].facing_info.facing = CAMERA_FACING_BACK;
+ camInfoTmp[cam_cnt].facing_info.facing = CAMERA_FACING_BACK;
}
ptr = strstr((char*)&capability.card[0],"-");
if (ptr != NULL) {
ptr++;
- camInfoTmp[cam_cnt&0x01].facing_info.orientation = atoi(ptr);
+ camInfoTmp[cam_cnt].facing_info.orientation = atoi(ptr);
} else {
- camInfoTmp[cam_cnt&0x01].facing_info.orientation = 0;
+ camInfoTmp[cam_cnt].facing_info.orientation = 0;
}
memset(version,0x00,sizeof(version));
@@ -1168,7 +1192,7 @@ int camera_get_number_of_cameras(void)
camInfoTmp[cam_cnt].pcam_total_info = pNewCamInfo;
cam_cnt++;
if (cam_cnt >= CAMERAS_SUPPORT_MAX)
- i = 10;
+ i = 20;
}
loop_continue:
if (fd > 0) {
@@ -1215,8 +1239,11 @@ int camera_get_number_of_cameras(void)
}
#endif
- memcpy(&gCamInfos[0], &camInfoTmp[0], sizeof(rk_cam_info_t));
- memcpy(&gCamInfos[1], &camInfoTmp[1], sizeof(rk_cam_info_t));
+ //memcpy(&gCamInfos[0], &camInfoTmp[0], sizeof(rk_cam_info_t));
+ //memcpy(&gCamInfos[1], &camInfoTmp[1], sizeof(rk_cam_info_t));
+ for(int i=0;i<CAMERAS_SUPPORT_MAX;i++){
+ memcpy(&gCamInfos[i], &camInfoTmp[i], sizeof(rk_cam_info_t));
+ }
property_get("ro.sf.hwrotation", property, "0");
@@ -1240,7 +1267,7 @@ camera_get_number_of_cameras_end:
#else
return gCamerasNumber;
#endif
-}
+}//modify by fujianyong for [Supporting multiple cameras] end
#if 0
int camera_get_number_of_cameras(void)
diff --git a/hardware/rockchip/camera/CameraHal/CameraHal_Module.h b/hardware/rockchip/camera/CameraHal/CameraHal_Module.h
index 45c81ec..3927ddf 100755
--- a/hardware/rockchip/camera/CameraHal/CameraHal_Module.h
+++ b/hardware/rockchip/camera/CameraHal/CameraHal_Module.h
@@ -11,13 +11,14 @@ using namespace android;
#define CAMERA_DEFAULT_PREVIEW_FPS_MIN 8000 //8 fps
#define CAMERA_DEFAULT_PREVIEW_FPS_MAX 15000
#endif
-#define CAMERAS_SUPPORT_MAX 2
+#define CAMERAS_SUPPORT_MAX 4
#if defined(TARGET_RK3399)
- #define CAMERAS_SUPPORTED_SIMUL_MAX 2
+ #define CAMERAS_SUPPORTED_SIMUL_MAX 4
#else
#define CAMERAS_SUPPORTED_SIMUL_MAX 1
#endif
#define CAMERA_DEVICE_NAME "/dev/video"
+#define CAM_SYS_NAME "/sys/class/video4linux/video"
#define CAMERA_MODULE_NAME "RK29_ICS_CameraHal_Module"
typedef struct rk_cam_info_s {
最后
以上就是温柔电脑为你收集整理的[AndroidO] [RK3399] -- 支持4路camera Preview的全部内容,希望文章能够帮你解决[AndroidO] [RK3399] -- 支持4路camera Preview所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复