v4l2框架的虚拟视频驱动程序详解
来源:互联网 发布:淘宝网禁止有毒化学物 编辑:程序博客网 时间:2024/05/06 17:43
dc2h_driver.c :
static int __init dc2h_init(void){ int ret; struct dc2h_device *dev; struct video_device *vdev; struct v4l2_ctrl_handler *hdl; struct vb2_queue *q; printk(KERN_EMERG "\n\n\n\n ***************** dc2h init module *********************\n\n\n\n"); //printk(KERN_EMERG"@@@@@ddc2h_init start@@@@\n"); dev = kzalloc(sizeof(*dev), GFP_KERNEL); if(!dev) { printk(KERN_EMERG "@@@@@dev is null @@@@\n"); return -ENOMEM; } strcpy(dev->v4l2_dev.name, "/dev/dc2h_video"); ret = v4l2_device_register(NULL, &dev->v4l2_dev);/*register the v4l2_device*/ if( ret ) { printk(KERN_EMERG "@@@@@v4l2_device_register fail@@@@\n"); goto free_dev; }else{ printk(KERN_EMERG "@@@@@v4l2_device_register success!@@@@\n"); } /* initialize locks */ spin_lock_init(&dev->slock); mutex_init(&dev->mutex); /* before register the video_device, init the video_device data*/ ret = -ENOMEM; vdev = video_device_alloc(); if(!vdev) { printk(KERN_EMERG "@@@@@video_device_alloc fail@@@@\n"); goto unreg_dev; }else{ printk(KERN_EMERG "@@@@@video_device_alloc success!@@@@\n"); } *vdev = d2ch_tmplate; /* the most important struct */ vdev->v4l2_dev = &dev->v4l2_dev; /* here set the v4l2_device, you have already registered it */ //set_bit(V4L2_FL_USE_FH_PRIO, &vdev->flags); vdev->lock = &dev->mutex;/*Provide a mutex to v4l2 core to protect all fops and v4l2 ioctls*/ vdev->testflag = 123; //just test;!@# ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1); if (ret < 0) { printk(KERN_EMERG "@@@@@video_register_device fail@@@@\n"); goto rel_vdev; }else{ printk(KERN_EMERG "@@@@@video_register_device success!@@@@\n"); } printk(KERN_EMERG " @@@@@vdev->testflag-before = %d\n", vdev->testflag); video_set_drvdata(vdev, dev);//!@# set driver data dev->vdev = vdev; /*assoiate video_device and dc2h_device*/ printk(KERN_EMERG " @@@@@vdev->testflag-after1 = %d\n", vdev->testflag); /* the debug message*/ v4l2_info(&dev->v4l2_dev, "V4L2 device registered as %s\n", video_device_node_name(vdev)); return 0; // result : Unable to handle kernel NULL pointer dereference at virtual address 00000000 //video_device_node_namerel_vdev: video_device_release(vdev);unreg_dev: v4l2_ctrl_handler_free(hdl); v4l2_device_unregister(&dev->v4l2_dev);free_dev: kfree(dev); printk(KERN_EMERG " @@@@@vdev->testflag-after1 = %d\n", vdev->testflag); return ret;}
0 0
- v4l2框架的虚拟视频驱动程序详解
- 基于V4L2框架的linux驱动程序编写
- V4L2视频编程框架
- V4L2视频采集框架
- linux V4L2框架 视频驱动
- V4L2视频采集驱动框架
- v4l2视频采集驱动框架
- V4L2的视频驱动
- 基于V4L2接口的视频开发流程详解
- 基于V4L2接口的视频开发流程详解
- 虚拟摄像头驱动程序框架分析
- 虚拟驱动程序的安装
- 网卡驱动程序的框架以及一个简单的虚拟网卡驱动程序
- 虚拟视频驱动程序vivi.c源码分析
- 虚拟视频驱动程序vivi.c源码分析
- 虚拟视频驱动程序vivi.c源码分析
- 虚拟视频驱动程序vivi.c源码分析
- 虚拟视频驱动程序vivi.c源码分析
- javascript笔记
- 解决WampServer图标不变绿的方法
- 2016年第七届蓝桥杯C/C++程序设计本科B组省赛 凑算式(结果填空)
- deepin 录音器
- v9视频教程
- v4l2框架的虚拟视频驱动程序详解
- Dijkstra算法——求单源最短路径
- iOS开发 (4.2~10.3)developerDiskImage
- Spring MVC处理流程
- TCP三次握手与四次分手、TCP与UDP区别
- python 爬虫学习笔记(1)
- 微信小程序 wx.request()无返回结果
- 接口
- QT之标准对话框