Android Camera HAL through v4l2 interface and Kernel Camera Driver interaction. This article examines the Android Camera subsystem from the perspective of Linux application developers .
V4L2 Application Development General process:
1. Open the device file. int Fd=open ("/dev/videoX″,o_rdwr);
2. Get the capability of the device to see what features the device has, such as whether it has video input or audio input and output. Vidioc_querycap,structv4l2_capability
3. Select video input and a video device can have multiple video inputs. Vidioc_s_input,struct V4l2_input
4. Set the format and frame of the video, including PAL,NTSC, the format of the frame includes width and height, etc. Vidioc_s_std,vidioc_s_fmt,structv4l2_std_id,struct V4l2_format
5. Apply frame buffer to the driver, generally no more than 5. Vidioc_reqbufs,struct v4l2_requestbuffers
6. Map the requested frame buffer to the user space so that the captured frames can be manipulated directly without having to replicate. Mmap
7. All the requested frame buffers are queued in order to store the collected data. Vidioc_qbuf,struct V4l2_buffer
8. Start the video collection. Vidioc_streamon
9. Out of the queue to obtain the captured data frame buffer, to obtain the original acquisition data. Vidioc_dqbuf
10. Re-enter the buffer to the end of the queue so that it can be collected in a loop. Vidioc_qbuf
11. Stop the Video collection. Vidioc_streamoff
12. Turn off the video device. Close (FD);