VS-RK3288调试笔记 --- 如何区分两颗相同的USB UVC Camera
[复制链接]
VS-RK3288调试笔记 --- 如何区分两颗相同的USB UVC Camera
问题:
当系统接上两颗相同的UVC Camera后, 由于分辨率, PID/VID都一样,
再加上系统初始化的先后不确定,这样HAL层就无法得知前后置摄像头的
对应顺序了.
分析:
由于Camera接的是不同的USB bus, 比如A Camera接USB1, B接USB2.
那么在驱动中的UVC初始化或者上层对底层查询时修改相应的参数就可以实现了,这里改的是后者.
不过此方法也只能作为一个patch添加处理了.
解决方法:
Kernel部分:
rk3288/kernel/drivers/media/usb/uvc/uvc_v4l2.c
static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
{
......
case VIDIOC_QUERYCAP:
{
struct v4l2_capability *cap = arg;
struct device_node *vpu_node;
int vpu_iommu_enabled = 0;
memset(cap, 0, sizeof *cap);
strlcpy(cap->driver, "uvcvideo", sizeof cap->driver);
/*Kris {*/
#if 0
strlcpy(cap->card, vdev->name, sizeof cap->card);
#else
if( stream->dev->udev->bus->busnum == 3) {
strcpy(cap->card, "front");
} else {
strcpy(cap->card, "back");
}
#endif
/*Kris }*/
......
}
HAL层调用:
rk3288/hardware/rockchip/camera/CameraHal/CameraHal_Module.cpp
if (ioctl(fd, VIDIOC_QUERYCAP, &capability) < 0) {
LOGE("Video device(%s): query capability not supported.\n",cam_path);
goto loop_continue;
}
......
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;
}
此内容由EEWORLD论坛网友videostrong原创,如需转载或用于商业用途需征得作者同意并注明出处
|