The video application can apply for a buffer from the v4l2 driver in two ways.
1. userptr, as the name implies, refers to the user space pointer. the application layer allocates the required memory space and passes it to the v4l2 driver layer as a pointer, the v4l2 driver saves the content of capture to the space indicated by the pointer.
In general, the application layer needs to ensure that the memory space is physically consecutive (the IPU processing unit is required), and the Android system can use the pmem driver to allocate large contiguous physical memory. The application layer is responsible for releasing the applied pmem memory when it is not needed.
2. In MMAP mode and memory ing mode, the app calls vidioc_reqbufs IOCTL to allocate the device buffers. The parameter identifies the required quantity and type. This IOCTL can also be used to change the data of buffers and release the allocated memory. Of course, this memory space is also continuous. Before the application space can access these physical addresses, you must call the MMAP function to map these physical spaces to your virtual address space.
The virtual address space is released through the munmap function, while the physical memory is released through vidioc_reqbufs (set the Buf count parameter to (0 )), the release of physical memory is specific, and MX51 v4l2 is released when the device is disabled.
Therefore, both applications apply for continuous physical memory, but the application and release methods are different.