In Linux, the camera driver-general Linux technology-Linux programming and kernel information. For more information, see the following. Cameras are video devices. In the current Linux core, the Video standard is Video for Linux (V4L for short ). This standard actually defines a set of interfaces. the kernel, driver, and application communicate with each other based on this interface. Currently, V4L covers video, audio stream capturing, processing, and other content. USB cameras are also supported.
Therefore, the driver of the USB camera should be linked to the video driver provided by the kernel. That is, first declare a video_device structure in the driver, and specify the file operation function pointer array. fops for it, and register it with the system. When an application sends commands related to file operations, the core calls the corresponding functions based on these pointers and passes the structure as a parameter to them. In this way, the communication between the driver and the core is completed. For example: