V4L2(video for linux version 2),是内核中视频设备的驱动框架,为上层访问视频设备提供统一接口。

V4L2整体框架如下图:

24、V4L2框架主要结构体分析和虚拟摄像头驱动编写

 

图中主要包括两层和三个结构体:

两层是:

1. v4l2驱动核心层:包含video_device和v4l2_device的分配、设置和注册

2. v4l2下层接口层:具体的底层传感器驱动,现在的摄像头可能支持硬件解码,这就需要在摄像头驱动下面提供解码器IC驱动

三个结构体是:

1. v4l2_device:

struct v4l2_device {
    /* dev->driver_data points to this struct.
       Note: dev might be NULL if there is no parent device
       as is the case with e.g. ISA devices. */
    struct device *dev;
    /* used to keep track of the registered subdevs */
    struct list_head subdevs;
    /* lock this struct; can be used by the driver as well if this
       struct is embedded into a larger struct. */
    spinlock_t lock;
    /* unique device name, by default the driver name + bus ID */
    char name[V4L2_DEVICE_NAME_SIZE];
    /* notify callback called by some sub-devices. */
    void (*notify)(struct v4l2_subdev *sd,
            unsigned int notification, void *arg);
    /* The control handler. May be NULL. */
    struct v4l2_ctrl_handler *ctrl_handler;
    /* Device's priority state */
    struct v4l2_prio_state prio;
    /* BKL replacement mutex. Temporary solution only. */
    struct mutex ioctl_lock;
    /* Keep track of the references to this struct. */
    struct kref ref;
    /* Release function that is called when the ref count goes to 0. */
    void (*release)(struct v4l2_device *v4l2_dev);
};
View Code

相关文章:

  • 2022-01-11
  • 2022-02-21
  • 2022-12-23
  • 2021-04-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-09
  • 2022-12-23
  • 2021-11-11
  • 2022-12-23
  • 2022-01-08
  • 2021-11-16
相关资源
相似解决方案