static LIST_HEAD(hosts)
所有的host都在hosts指向的鏈表上
static LIST_HEAD(devices);
所有soc camera device都掛在devices指向的鏈表上。
系統內可能有多個soc_camera_host,每個soc_camera_host可以對應1 ~ n個soc_camera_device。每個soc_camera_device通過soc_camera_video_start函數創建設備節點/dev/videoX
soc_camera_host對應著系統camera處理模塊,盡管理論上可以有多個camera host,但是大部分系統僅有一個camera host
在soc_camera_host_register中調用v4l2_device_register為這個soc_camera_host注冊一個v4l2_device設備。
在soc_camera_probe中調用soc_camera_init_i2c,為soc_camera_device注冊一個v4l2_subdev,我們從soc_camera_probe代碼可以看出,只有i2C的設備可以使用這種方式,對於非I2C設備來說,需要soc_camera_link提供add_device來增加子設備。
soc_camera_host, soc_camera_device,v4l2_device,v4l2_subdev關系如下:
struct soc_camera_device {
struct list_head list;
struct device dev;
struct device *pdev; /* Platform device */
s32 user_width;
s32 user_height;
enum v4l2_colorspace colorspace;
unsigned char iface; /* Host number */
unsigned char devnum; /* Device number per host */
struct soc_camera_sense *sense; /* See comment in struct definition */
struct soc_camera_ops *ops;
struct video_device *vdev;
const struct soc_camera_format_xlate *current_fmt;
struct soc_camera_format_xlate *user_formats;
int num_user_formats;
enum v4l2_field field; /* Preserve field over close() */
void *host_priv; /* Per-device host private data */
/* soc_camera.c private count. Only accessed with .video_lock held */
int use_count;
struct mutex video_lock; /* Protects device data */
struct file *streamer; /* stream owner */
struct videobuf_queue vb_vidq;
};