Platform: RK3368
OS: Android 6.0
Kernel: 3.10.0
UVC摄像头方向调试
方法1修改CameraHal
修改代码位置hardware/rockchip/camera/CameraHal
直接在CameraHal中修改facing_info.
diff --git a/CameraHal/CameraHal_Module.cpp b/CameraHal/CameraHal_Module.cpp
index ec56a08..78500e3 100755
--- a/CameraHal/CameraHal_Module.cpp
+++ b/CameraHal/CameraHal_Module.cpp
@@ -771,14 +771,14 @@ int camera_get_number_of_cameras(void)
if (strstr((char*)&capability.card[0], "front") != NULL) {
camInfoTmp[cam_cnt&0x01].facing_info.facing = CAMERA_FACING_FRONT;
} else {
- camInfoTmp[cam_cnt&0x01].facing_info.facing = CAMERA_FACING_BACK;
+ camInfoTmp[cam_cnt&0x01].facing_info.facing = CAMERA_FACING_FRONT;
}
ptr = strstr((char*)&capability.card[0],"-");
if (ptr != NULL) {
ptr++;
camInfoTmp[cam_cnt&0x01].facing_info.orientation = atoi(ptr);
} else {
- camInfoTmp[cam_cnt&0x01].facing_info.orientation = 0;
+ camInfoTmp[cam_cnt&0x01].facing_info.orientation = 180;
}
memset(version,0x00,sizeof(version));
方法2修改驱动
将capability card改为"facing-orientation".
例如facing(1), orientation(180)就是"front-180",android的CameraHal会根据命名规则来解析是前置摄像头还是后置摄像头,以及摄像头的方向.如果要做多个摄像头兼容可以加上VID与PID匹配.
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index 196198f..d81586f 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -564,6 +564,14 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
memset(cap, 0, sizeof *cap);
strlcpy(cap->driver, "uvcvideo", sizeof cap->driver);
strlcpy(cap->card, vdev->name, sizeof cap->card);
+
+ if(le16_to_cpu(stream->dev->udev->descriptor.idVendor)==0x058f &&
+ le16_to_cpu(stream->dev->udev->descriptor.idProduct)==0x3841){//058f:3841
+ pr_info("uvc vendor product matched\n");
+ memset(cap->card, 0, sizeof cap->card);
+ strlcpy(cap->card, "front-180", sizeof cap->card);
+ }
+
usb_make_path(stream->dev->udev,
cap->bus_info, sizeof(cap->bus_info));
cap->version = LINUX_VERSION_CODE;

本文主要介绍了在RK3368平台、Android 6.0系统上,针对3.10.0内核的UVC摄像头进行方向调试的方法。提供了两种解决方案:一是修改CameraHal中的facing_info,二是调整驱动,通过修改capability card为"facing-orientation"来指定摄像头的朝向。同时,还提到为了实现多摄像头兼容,可以结合VID与PID进行匹配。
776

被折叠的 条评论
为什么被折叠?



