v4l2框架v4l2 device API分析

2021-08-01 08:28:10 字數 1487 閱讀 6637

涉及到的結構體:

struct v4l2_device在v4l2框架中充當所有v4l2_subdev的父裝置,管理著註冊在其下的子裝置:

struct v4l2_device ;

struct device 代表子裝置,包含了子裝置的相關屬性和操作:

struct device ;
struct subdev:

struct v4l2_subdev ;

涉及到的api:

void v4l2_device_get(struct v4l2_device *v4l2_dev)

v4l2_dev的引用計數kref加一

int v4l2_device_put(struct v4l2_device *v4l2_dev)

v4l2_dev的引用計數kref減一

int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4l2_dev)

對v4l2_dev中的鍊錶、自旋鎖、互斥體、優先狀態等進行初始化,並把v4l2_dev->dev指向dev

int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,atomic_t *instance)

設定v4l2_dev->name

void v4l2_device_disconnect(struct v4l2_device *v4l2_dev)

把v4l2_dev從指向的dev上互相斷開(指向null)

void v4l2_device_unregister(struct v4l2_device *v4l2_dev)

把v4l2_dev從指向的dev上互相斷開,並把掛接在v4l2_dev鍊錶上的v4l2_subdev裝置一一解除安裝

int __must_check v4l2_device_register_subdev(struct v4l2_device *v4l2_dev,struct v4l2_subdev *sd)

把v4l2_dev->v4l2_device指向v4l2_dev,並呼叫v4l2_dev->internal_ops(不會在driver中呼叫的ops)->registered註冊v4l2_dev

void v4l2_device_unregister_subdev(struct v4l2_subdev *sd)

把sd從掛接的v4l2_device鍊錶上刪除,並執行sd->unregistered,解除安裝

int __must_check v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev)

為v4l2_dev鍊錶上每個具有v4l2_subdev_fl_has_devnode標誌的subdevs建立video_device節點

V4L2驅動框架

v4l2驅動框架 主裝置號 81 次裝置號 0 63 64 67 192 223 224 255 dev videox 應用層 char驅動 v4l2 具體的驅動 硬體應用層的操作都需要有底層v4l2驅動的支援。核心中有一些非常完善的例子。比如 linux 2.6.26核心目錄drivers med...

V4L2框架分析

uvc probe uvc driver.c硬體相關層,定會分配設定向核心層註冊一結構體 v4l2 device register uvc register chains uvc register terms uvc register video struct video device vdev v...

V4L2程式設計框架

v4l2較v4l有較大的改動,並已成為2.6的標準介面,函蓋video dvb fm 多數驅動都在向v4l2遷移。更好地了解v4l2先從應 來實現。用非阻塞模式開啟攝像頭裝置int camerafd camerafd open dev video0 o rdwr o nonblock,0 如果用阻塞...