S5PV210开发板 介绍camera V4L2 FIMC (3)

本文介绍了Linux中摄像头驱动的标准——V4L2,包括其简介、数据结构和主要接口函数。接着详细讨论了Samsung FIMC驱动,解释了其不仅作为控制接口,还承担V4L2的output和overlay功能,以及FIMC的主要数据结构和初始化设置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  前面两篇说的有点多了,不过多了解点东西也挺好的,遇到问题时可以有更多的思路,真正驱动是从这一块开始。一般BSP的camera都是完好的,我们只用关心驱动这些就可以了。

1. V4L2

1)简介

在Linux中,摄像头方面的标准化程度比较高,这个标准就是V4L2驱动程序,这也是业界比较公认的方式。

V4L全称是Video for Linux,是Linux内核中标准的关于视频驱动程序,目前使用比较多的版本是Video for Linux 2,简称V4L2。它为Linux下的视频驱动提供了统一的接口,使得应用程序可以使用统一的API操作不同的视频设备。从内核空间到用户空间,主要的数据流和控制类均由V4L2驱动程序的框架来定义。

V4L2驱动程序一般只提供Video数据的获得,而如何实现视频预览,如何向上层发送数据,如何把纯视频流和取景器、视频录制等实际业务组织起来,都是camera的硬件抽象层需要负责的工作。

V4L2驱动核心实现为如下文件:drivers/media/video/v4l2-dev.c。

V4l2-dev.h中定义的video_device是V4L2驱动程序的核心数据结构,它为具体的摄像头sensor驱动提供了接口调用。

V4l2的采集过程(应用程序):

1) 打开设备,获得文件描述符;

2) 设置图片格式;

3) 分配缓冲区;

4) 启动采集过程,读取数据;

5) 停止采集,关闭设备。


2)数据结构

V4L2的主要数据结构是video_device,定义在v4l2_dev.h中:

  1. struct video_device
  2. {
  3. /* device ops */
  4. const struct v4l2_file_operations *fops; /*接口函数指针*/
  5. /* sysfs */
  6. struct device dev; /* v4l 设备结构 */
  7. struct cdev *cdev; /* 字符设备结构*/
  8. /* Set either parent or v4l2_dev if your driver uses v4l2_device */
  9. struct device *parent; /* 设备父指针 */
  10. struct v4l2_device *v4l2_dev; /* v4l2设备指针*/
  11. /* device info */
  12. char name[32]; /*设备名称*/
  13. int vfl_type;
  14. /* 'minor' is set to -1 if the registration failed */
  15. int minor; /*次设备号*/
  16. u16 num;
  17. /* use bitops to set/clear/test flags */
  18. unsigned long flags;
  19. /* attribute to differentiate multiple indices on one physical device */
  20. int index;
  21. /* V4L2 file handles */
  22. spinlock_t fh_lock; /* Lock for all v4l2_fhs */
  23. struct list_head fh_list; /* List of struct v4l2_fh */
  24. int debug; /* debug 级别*/
  25. /* Video 标准变量 */
  26. v4l2_std_id tvnorms; /* Supported tv norms */
  27. v4l2_std_id current_norm; /* Current tvnorm */
  28. /* 回调函数 */
  29. void (*release)(struct video_device *vdev);
  30. /* ioctl 回调函数 */
  31. const struct v4l2_ioctl_ops *ioctl_ops;
  32. };
struct video_device
{
	/* device ops */
	const struct v4l2_file_operations *fops;  /*接口函数指针*/

	/* sysfs */
	struct device dev;		/* v4l 设备结构 */
	struct cdev *cdev;		/* 字符设备结构*/

	/* Set either parent or v4l2_dev if your driver uses v4l2_device */
	struct device *parent;		/* 设备父指针 */
	struct v4l2_device *v4l2_dev;	/* v4l2设备指针*/

	/* device info */
	char name[32];  /*设备名称*/
	int vfl_type;
	/* 'minor' is set to -1 if the registration failed */
	int minor;    /*次设备号*/
	u16 num;
	/* use bitops to set/clear/test flags */
	unsigned long flags;
	/* attribute to differentiate multiple indices on one physical device */
	int index;

	/* V4L2 file 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值