v4l2

soc_camera.c
--------------------------------------------------------------------------------
soc_camera_init(void)
bus_register(&soc_camera_bus_type);//reg bus
platform_driver_probe(&soc_camera_pdrv, soc_camera_pdrv_probe);
    soc_camera_pdrv_probe(struct platform_device *pdev)
        ret = soc_camera_device_register(icd);//add soc_camera_device to list
        soc_camera_device_init(&icd->dev, icl);
            dev->bus        = &soc_camera_bus_type; //set soc_camera_device bus type

struct bus_type soc_camera_bus_type = {
    .name        = "soc-camera",
    .probe        = soc_camera_probe,

--------------------------------------------------------------------------------
pxa_camera.c
static int __devinit pxa_camera_probe(struct platform_device *pdev)
    err = soc_camera_host_register(&pcdev->soc_host);
        ret = v4l2_device_register(ici->v4l2_dev.dev, &ici->v4l2_dev);//reg soc_camera_host to v4l2 framework as v4l2_device
        static void scan_add_host(struct soc_camera_host *ici)
            ret = device_register(&icd->dev); //reg soc_camera_device (1)

static int soc_camera_probe(struct device *dev)//parameter is soc_camera_device
        ret = video_dev_create(icd);//set function pointers to  video_device like fileoperation
        soc_camera_init_i2c(icd, icl);//new i2c device and reg soc_camera_device to v4l2 framework as v4l2_subdevice
        or ret = icl->add_device(icl, &icd->dev);//to create "soc_camera_platform"(sensor platform driver)
        ret = soc_camera_video_start(icd);//create dev node

soc_camera_platform.c
--------------------------------------------------------------------------------
static int soc_camera_platform_probe(struct platform_device *pdev)

mt9v022.c (i2c sensor device)
--------------------------------------------------------------------------------
static int mt9v022_probe(struct i2c_client *client,
             const struct i2c_device_id *did)

mach device
--------------------------------------------------------------------------------
platform_device "soc-camera-pdrv"
soc_camera_link

v4l2
ret = video_register_device(vfd, VFL_TYPE_GRABBER, video_nr);
//1.create file node and char dev
2.set vdev->cdev->ops = &v4l2_fops;
3.register video_device to v4l2  video_device array

read in  v4l2_fops will select the right video_device and call fops registered by v4l2 client

你可能感兴趣的:(v4l2)