imx6 摄像头代码简析



/*imx6摄像头部分代码分析*/


imx6代码结构.1
  
  app
   |
v4l2-dev.c(提供注册和应用app调用接口)
   |
mxc_v4l2_capture.c (执行IOCTRL命令)
   |
 ov5640.c  (执行真正摄像头硬件操作)


 ///
imx6代码结构.2
   
   app
    | 
v4l2-dev.c  (提供注册和应用app调用接口)
    |
TW68-video.c  TW68-core.c (执行IOCTRL命令)
     


 


//应用调用1  
 


                    app open
|
..........................................................................   
                     |
                     |
static int v4l2_open(struct inode *inode, struct file *filp)  /*v4l2-dev.c*/  
{                    |
  static int mxc_v4l_open(struct file *file)                  /*mxc_v4l2_capture.c*/
  {                  | 
                     |
              int vidioc_int_g_ifparm(struct v4l2_int_device *s)   /*Ov5640.c*/
                         


 
//应用调用2
 ioctl
    |
..........................................................................
 video_usercopy(file, cmd, arg, __video_do_ioctl);   /*v4l2-ioctl.c*/
                                       | 
                  |
..........................................................................
static long mxc_v4l_do_ioctl(struct file *file,unsigned int ioctlnr, void *arg)
    |                               /*mxc_v4l2_capture.c*/
|
.........................................................................
 static struct v4l2_int_ioctl_desc ov5640_ioctl_desc[] = {
                                                      /*ov5640.c*/









vivi.c 的调用过程
..........................................................................
ivi.c 注册过程
static int __init vivi_create_instance(int inst)
              |
           v4l2_device_register
              |
           INIT_LIST_HEAD(&dev->vidq.active);
     |
  init_waitqueue_head(&dev->vidq.wq);
              |
  *vfd =video_device_alloc
              |
           video_register_device(vfd, VFL_TYPE_GRABBER, video_nr);


..................................................................................................................................   
           app
            | 
 open  read  write  ioctl
 ....................................
                        |              v4l2-dev.c 
                        |
 open   read  writ      |
vdev->                  |
 fops->                 |  
   open                 |
    |                   |
....|...................|.....................................................................................................................
    |                   |                vivi.c                                                                                              |
 int v4l2_fh_open(struct| file *filp)                                                                        static const struct v4l2_ioctl_ops vivi_ioctl_ops = {
               |                                                                                                                 .vidioc_querycap      = vidioc_querycap,
                        |                                                                                                                                   =======> 
        static long v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)                |
                        |                                                                                                                                    | 
                        |                                                                                                            |
           ret = vdev->fops->unlocked_ioctl(filp, cmd, arg);                                                            |
                        |                                                                                                                                    |
               因为 vivi.c 中 .unlocked_ioctl = video_ioctl2 的定义                                                    |
..............................................................................................v4l2-ioctl.c                                           |
               这里调用v                              |                                                                                             | 
                                                video_ioctl2(struct file *file,                                                           |
                                            |                                                                                                              |
                                 video_usercopy(file, cmd, arg, __video_do_ioctl);                                |
                                                                          |                                                                             |
                                          long __video_do_ioctl(struct file *file,                                         |
                                                     |                                                                                              |
                                                  ioctl实现再次调用 vivi.c 中的 ====================
                                         













  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值