第6讲 CRM V4L2驱动模型讲解

本讲是Camera KMD ISP子系统专题的第6讲,我们讲解CRM V4L2驱动模型。

更多资源:

资源 描述
在线课程 极客笔记在线课程
知识星球 星球名称:深入浅出Android Camera
星球ID: 17296815
Wechat 极客笔记圈

V4L2重要结构体

struct v4l2_device

struct v4l2_device {
    struct device *dev;
    struct media_device *mdev;//属于哪个media_device
    struct list_head subdevs;//保存所有的v4l2_subdev
    spinlock_t lock;
    char name[V4L2_DEVICE_NAME_SIZE];
    void (*notify)(struct v4l2_subdev *sd,unsigned int notification, void *arg);
    struct v4l2_ctrl_handler *ctrl_handler;
    struct v4l2_prio_state prio;
    struct kref ref;
    void (*release)(struct v4l2_device *v4l2_dev);
};

struct video_device

struct video_device {
    struct media_entity entity;//用于挂到media_device的entities链表上
    struct v4l2_device *v4l2_dev;//指向一个v4l2_device
    struct vb2_queue *queue;//video buffer queue
    char name[32];//设备名
    enum vfl_devnode_type vfl_type;//type of V4L2 device node(VFL_TYPE_VIDEO, VFL_TYPE_SUBDEV)
    const struct v4l2_ioctl_ops *ioctl_ops;//指向 v4l2_ioctl_ops指针
}

其中,ioctl_ops如下:

V4L2重要结构体

struct media_device

struct media_device {
    /* dev->driver_data points to this struct. */
    struct device *dev;
    struct media_devnode *devnode;//创建设备节点相关的
    char model[32];//保存的是名字,例如:”cam-req-mgr-devnode”
    struct list_head entities;//保存了所有的entity
}

struct media_entity

struct media_entity {
    struct media_gobj graph_obj;//用于挂在media_device entities链表
    const char *name; // entity的名字
    enum media_entity_type obj_type; // MEDIA_ENTITY_TYPE_VIDEO_DEVICE, MEDIA_ENTITY_TYPE_V4L2_SUBDEV
    u32 function;// CAM_DEVICE_TYPE_BASE, CAM_TFE_DEVICE_TYPE
}

struct media_gobj {
    struct media_device *mdev;
    u32         id;
    struct list_head    list; //用于挂在media_device entities链表
};

struct v4l2_subdev

struct v4l2_subdev {
    struct media_entity entity;//用于挂到media_device的entities链表上
    struct list_head list;//用于挂在v4l2_device的subdevs链表上
    u32 flags;//标志信息,例如: V4L2_SUBDEV_FL_HAS_DEVNODE, V4L2_SUBDEV_FL_HAS_EVENTS
    struct v4l2_device *v4l2_dev;//指向一个v4l2_device对象,跟主设备指向的是同一个v4l2_device对象
    const struct v4l2_subdev_ops *ops;// pointer to struct &v4l2_subdev_ops
    const struct v4l2_subdev_internal_ops *internal_ops;// pointer to struct &v4l2_subdev_internal_ops.
    char name[V4L2_SUBDEV_NAME_SIZE];//子设备名字
    struct video_device *devnode;//创建设备节点/dev/v4l2-subdevX时创建的video_device
}

V4L2重要结构体

V4L2重要结构体

CRM V4l2 驱动模型

CRM V4L2框架初始化流程(主设备)

CRM V4l2 驱动模型

CRM V4L2框架初始化流程(子设备)

CRM V4l2 驱动模型

CRM V4L2驱动模型拓扑图

CRM V4l2 驱动模型

CSL Layer 如何使用media entity

CRM V4l2 驱动模型

CRM V4L2驱动设备节点含义

/dev/video0:       crm-req-mgr
/dev/v4l-subdev0:  cam-cpas
/dev/v4l-subdev1:  cam-isp
/dev/v4l-subdev2:  cam-csiphy-driver
/dev/v4l-subdev3:  cam-csiphy-driver
/dev/v4l-subdev4:  cam-csiphy-driver
/dev/v4l-subdev5:  cam-actuator-driver
/dev/v4l-subdev6:  cam-sensor-driver
/dev/v4l-subdev7:  cam-sensor-driver
/dev/v4l-subdev8:  cam-sensor-driver
/dev/v4l-subdev9:  cam-eeprom
/dev/v4l-subdev10: cam-eeprom
/dev/v4l-subdev11: cam-flash-dev
/dev/v4l-subdev12: cam-ope

CRM V4L2驱动设备节点含义对照

header file(entity type): include/uapi/camera/media/cam_req_mgr.h

CRM V4l2 驱动模型

CRM驱动ioctl调用流程

CRM V4l2 驱动模型

CRM V4l2 驱动模型

子设备驱动ioctl调用流程

CRM V4l2 驱动模型

CRM V4l2 驱动模型

Camera课程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

办公软件教程

Linux教程

计算机教程

大数据教程

开发工具教程