uvc app程序camera 接入分析

代码路径:

/ws/rv1126_old/external/uvc_app

external/uvc_app/uvc/uvc-gadget.c

**uvc_gadget_main**(int id)

定义了默认使用的设备结点 video0
char *v4l2_devname = "/dev/video0";
打开对应的结点
ret = v4l2_open(&vdev, v4l2_devname, &fmt);

把 uvc 设备和 v4l2_devname 进行绑定
/* Open the UVC device. */
ret = uvc_open(&udev, uvc_devname);
vdev->v4l2_devname = v4l2_devname;

传递参数给 v4l2
/* Set parameters as passed by user. */
udev->width = (default_resolution == 0) ? 640 : uvc_frames_mjpeg[num_uvc_frame].width;
udev->height = (default_resolution == 0) ? 480 : uvc_frames_mjpeg[num_uvc_frame].height;
udev->imgsize = (default_format == 0) ?
                (udev->width * udev->height * 2) :
                (udev->width * udev->height * 2/*1.5*/);
switch (default_format)
{
case 1:
    udev->fcc = V4L2_PIX_FMT_MJPEG;
    break;

设定 reqbufs
if (!dummy_data_gen_mode && !mjpeg_image //&&
   )  //(IO_METHOD_MMAP == vdev->io)
{
    /*
     * Ensure that the V4L2 video capture device has already some
     * buffers queued.
     */
    v4l2_reqbufs(vdev, vdev->nbufs);
}

其他接口
./uvc/uvc-gadget.c:    int v4l2_fd;
./uvc/uvc-gadget.c:    ret = ioctl(dev->v4l2_fd, VIDIOC_REQBUFS, &req);
./uvc/uvc-gadget.c:        ret = ioctl(dev->v4l2_fd, VIDIOC_QUERYBUF, &(dev->mem[i].buf));
./uvc/uvc-gadget.c:                                 dev->v4l2_fd, dev->mem[i].buf.m.offset);
./uvc/uvc-gadget.c:    ret = ioctl(dev->v4l2_fd, VIDIOC_REQBUFS, &req);
./uvc/uvc-gadget.c:        ret = ioctl(dev->v4l2_fd, VIDIOC_QBUF, &(dev->mem[i].buf));
./uvc/uvc-gadget.c:    ret = ioctl(dev->v4l2_fd, VIDIOC_DQBUF, &vbuf);
./uvc/uvc-gadget.c:    ret = ioctl(dev->v4l2_fd, VIDIOC_G_FMT, &fmt);
./uvc/uvc-gadget.c:    ret = ioctl(dev->v4l2_fd, VIDIOC_S_FMT, fmt);
./uvc/uvc-gadget.c:        ret = ioctl(dev->v4l2_fd, VIDIOC_QUERYCTRL, &queryctrl);
./uvc/uvc-gadget.c:            ret = ioctl(dev->v4l2_fd, VIDIOC_S_CTRL, &control);
./uvc/uvc-gadget.c:    ret = ioctl(dev->v4l2_fd, VIDIOC_STREAMON, &type);
./uvc/uvc-gadget.c:        ret = ioctl(dev->v4l2_fd, VIDIOC_STREAMOFF, &type);
./uvc/uvc-gadget.c:    dev->v4l2_fd = fd;
./uvc/uvc-gadget.c:    close(dev->v4l2_fd);
./uvc/uvc-gadget.c:        ret = ioctl(dev->vdev->v4l2_fd, VIDIOC_QBUF, &vbuf);
./uvc/uvc-gadget.c:            FD_SET(vdev->v4l2_fd, &fdsv);
./uvc/uvc-gadget.c:            nfds = max(vdev->v4l2_fd, udev->uvc_fd);
./uvc/uvc-gadget.c:            if (FD_ISSET(vdev->v4l2_fd, &fdsv))
./uvc/uvc_video.h:    int v4l2_fd;
© 版权声明
THE END
在时间中留下我的脚印
分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情图片