v4l2驱动的switch结构是在kernel/drivers/media/video/v4l2-ioctl.c 文件里头实现的。
一、BUFFER REQUEST:VIDIOC_REQBUFS
1.__video_do_ioctl(path: .../v4l2-ioctl.c)
In v4l2-ioctl.c file,there is a function:__video_do_ioctl, commands form user space distributed according to different macros,through ops->XXX(arg1,arg2),such as
ops->vidioc_g_priority(file, fh, p),
2.fimc_capture_ioctl_ops(path:kernel/drivers/media/video/s5p-fimc/fimc-capture.c)
functions in structrue fimc_capture_ioctl_ops,whic in kernel/drivers/media/video/s5p-fimc/fimc-capture.c ,will be incoked.
Then fimc_cap_reqbufs invoked,key funcition in fimc_cap_reqbufs is vb2_reqbufs
3.vb2_reqbufs (path:kernel/drivers/media/video/vidoebuf2-core.c)
in vb2_reqbufs,__vb2_queue_alloc be used to allocate a memory.
二.VIDIOC_STREAMON:streamon (start data collection),users use the command to start data collection
Base on the above procedure(beginning is :__video_do_ioctl)
1.vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type) (path: kernel/drivers/media/video/videobuf2-core.c)
In this function ret = call_qop(q, start_streaming, q, atomic_read(&q->queued_count)); is key function.start_streaming decleared in kernel/drivers/media/video/videobuf2-core.h, and be realized in file fimc-capture.c (drivers/media/video/s5p-fimc)。
FIMC is a camera controll interface,it is also undertake output function adn overlay function.
2.static int start_streaming(struct vb2_queue *q, unsigned int count)(path:kernel/drivers/media/video/s5p-fimc/fimc-capture.c)
in start_stream function ,key function fimc_pipeline_s_stream(fimc, 1); be invoked.
3.int fimc_pipeline_s_stream(struct fimc_dev *fimc, int on) (path:kernel/drivers/media/video/s5p-fimc/fimc-mdevices.c)
in this function ,ret = v4l2_subdev_call(on ? p->sensor : p->csis,video, s_stream, on); we use this function to call subdevice's function,the subdevices function was defined in driver file,such as XXX_v4l2.c file. s_stream is a function of v4l2_subdev_ops.now ,data collection is beginning.