曾经在全志平台上调试过UVC摄像头,当时调试过程比较流畅,丝毫没有碰上异常情况,这一次在RK上碰到较大的困难,下面介绍一下我的调试过程。
首先,不用说当然在内核配置中配置上UVC摄像头,重新编译内核,烧录。
Device Drivers --->
<*> Multimedia support --->
<*> Video For Linux
[*] Enable Video For Linux API 1 (DEPRECATED)
[*] Video capture adapters --->
[*] V4L USB devices --->
<*> USB Video Class (UVC)
[*] UVC input events device support
然后查看内核信息,cat /proc/kmsg 然后接上摄像头,会看到类似的设备信息,说明我们的摄像头已经可以正常使用了。
usb 1-1.1: new full speed USB device using address 3
usb 1-1.1: New USB device found, idVendor=0ac8, idProduct=3450
usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1.1: Product: Deasy USB2.0 Camera
uvcvideo: Found UVC 1.00 device Deasy USB2.0 Camera (0ac8:3450)
E/SensorService( 471): Error activating sensor 0 (Operation not permitted)
V/CAM_PhotoModule( 1041): On resume.
V/CAM_PhotoModule( 1041): Executing onResumeTasks.
V/CAM_PhotoModule( 1041): Open camera device.
V/CameraHolder( 1041): open camera 0
E/CameraService( 163): CameraService::connect X (pid 1041) rejected (invalid cameraId 0).
frameworks/av/services/camera/libcameraservice/CameraService.cpp 查看异常的日志是哪里打印出来,很快就发现
if (cameraId < 0 || cameraId >= mNumberOfCameras) {
ALOGE("CameraService::connect X (pid %d) rejected (invalid cameraId %d).",
callingPid, cameraId);
return -ENODEV;
}
private CameraHolder() {
HandlerThread ht = new HandlerThread("CameraHolder");
ht.start();
mHandler = new MyHandler(ht.getLooper());
mNumberOfCameras = android.hardware.Camera.getNumberOfCameras();
mInfo = new CameraInfo[mNumberOfCameras];
for (int i = 0; i < mNumberOfCameras; i++) {
mInfo[i] = new CameraInfo();
android.hardware.Camera.getCameraInfo(i, mInfo[i]);
if (mBackCameraId == -1 && mInfo[i].facing == CameraInfo.CAMERA_FACING_BACK) {
mBackCameraId = i;
}
if (mFrontCameraId == -1 && mInfo[i].facing == CameraInfo.CAMERA_FACING_FRONT) {
mFrontCameraId = i;
}
}
}
1.死机后的信息
D/CameraHolder( 1043): CameraHoler().go
D/CameraHolder( 1043): mMockCameraInfo ==null, getNumberOfCameras()
D/CameraHolder( 1043): return number === 1
2.提示打不开的信息
D/CameraHolder( 1043): CameraHoler().go
D/CameraHolder( 1043): mMockCameraInfo ==null, getNumberOfCameras()
D/CameraHolder( 1043): return number === 0
int32_t CameraService::getNumberOfCameras() {
if(mNumberOfCameras == 0) {
ALOGE("no camera found before! check again...");
onFirstRef();
}
return mNumberOfCameras;
}