v4l2的結構體之v4l2 device

2021-10-22 14:49:43 字數 1879 閱讀 4946

乙個硬體裝置可能包含多個子裝置,比如乙個電視卡除了有capture裝置,可能還有vbi裝置或者fm tunner。而v4l2_device就是所有這些裝置的根節點,負責管理所有的子裝置,可將該抽象為soc的資料採集器,如csi、mipi、isp等soc的控制器。

/**

* struct v4l2_device - main struct to for v4l2 device drivers

* * @dev: pointer to struct device.

* @mdev: pointer to struct media_device, may be null.

* @subdevs: used to keep track of the registered subdevs

* @lock: lock this struct; can be used by the driver as well

* if this struct is embedded into a larger struct.

* @name: unique device name, by default the driver name + bus id

* @notify: notify operation called by some sub-devices.

* @ctrl_handler: the control handler. may be %null.

* @prio: device's priority state

* @ref: keep track of the references to this struct.

* @release: release function that is called when the ref count

* goes to 0.

* * each instance of a v4l2 device should create the v4l2_device struct,

* either stand-alone or embedded in a larger struct.

* * it allows easy access to sub-devices (see v4l2-subdev.h) and provides

* basic v4l2 device-level support.

* * .. note::

* * #) @dev->driver_data points to this struct.

* #) @dev might be %null if there is no parent device

*/struct v4l2_device ;

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

/* set name to driver name + device name if it is empty. */

if (!v4l2_dev->name[0])

snprintf(v4l2_dev->name, sizeof(v4l2_dev->name), "%s %s",

dev->driver->name, dev_name(dev));

if (!dev_get_drvdata(dev))

dev_set_drvdata(dev, v4l2_dev);

return 0;

}export_symbol_gpl(v4l2_device_register);

static void v4l2_device_release(struct kref *ref)

V4L2程式設計

include include include include include include include include include include typedef struct buftype buftype user buf int n buffer 0 開啟攝像頭裝置 int ope...

V4L2 程式設計

v4l2程式設計 1.定義 2.工作流程 開啟裝置 檢查和設定裝置屬性 設定幀格式 設定一種輸入輸出方法 緩衝區管理 迴圈獲取資料 關閉裝置。3.裝置的開啟和關閉 include int open const char device name,int flags include int close ...

v4l2框架v4l2 device API分析

涉及到的結構體 struct v4l2 device在v4l2框架中充當所有v4l2 subdev的父裝置,管理著註冊在其下的子裝置 struct v4l2 device struct device 代表子裝置,包含了子裝置的相關屬性和操作 struct device struct subdev s...