Use DMABUF memory method to operate a MIPI device

Sunplus MIPI-CSI RX driver can support DMABUF memory method. You need to enable the following kernel configurations for it first.

CONFIG_ANDRIOD

CONFIG_ION

CONFIG_ION_SYSTEM_HEAP

CONFIG_CMA

CONFIG_DMA_CMA

CONFIG_ION_CMA_HEAP

We have developed a test application – camera. You can use this APP to test it. The camera APP is in /linux/application/module_test/mipi/camera directory. Please run ‘make’ command to make it.

ccho@scdiu3:~/Source/sp7021/linux/application/module_test/mipi/camera$ make

After made it, you need copy the executable file, camera, to the disk directory of the rootfs file system.

ccho@scdiu3:~/Source/sp7021/linux/application/module_test/mipi/camera$ cp camera /home/ccho/Source/sp7021/linux/rootfs/initramfs/disk/usr/

Run ‘make all’ to make the Linux kernel image. Update the storage device of your board and reboot it. After command prompt appears, change the working directory to “usr”. Run the camera APP.

/usr # ./camera

You will see the log as follows:

/usr # ./camera ## Query capability ## Driver Caps:   Driver: "SP MIPI Driver"   Card: "SP MIPI Camera Card"   Bus: "SP MIPI Camera BUS"   Version: 5.0   Capabilities: 85200001 ## Enumerate image formats ## SUPPORT #0: 8-bit Bayer BGBG/GRGR format id: 0, fourcc: BA81(0x31384142) ## Enumerate frame intervals ## [640x480] 15.000000 fps [640x480] 30.000000 fps [640x480] 60.000000 fps ## Set format ## ## Get format ## Stream Format Informations: type: 1 width: 640 height: 480 pixelformat: BA81 field: 0 bytesperline: 640 sizeimage: 307200 colorspace: 0 Type: 1, Device height = 480; width = 640 init_device done init_dma_buffer, count: 4, memory: 4 init_ion_buffer, allocate: 2457600, dmabuf_fd: 5 DMABUF buffer: i = 0, dmabuf_fd = 5, cpu_ptr = 0xb6c8c000 init_ion_buffer, allocate: 2457600, dmabuf_fd: 6 DMABUF buffer: i = 1, dmabuf_fd = 6, cpu_ptr = 0xb6a34000 init_ion_buffer, allocate: 2457600, dmabuf_fd: 7 DMABUF buffer: i = 2, dmabuf_fd = 7, cpu_ptr = 0xb67dc000 init_ion_buffer, allocate: 2457600, dmabuf_fd: 8 DMABUF buffer: i = 3, dmabuf_fd = 8, cpu_ptr = 0xb6584000 init_buffer done start_capture start_capture done frame 00, index: 0, dmabuf_fd: 5 frame 01, index: 1, dmabuf_fd: 6 frame 02, index: 2, dmabuf_fd: 7 frame 03, index: 3, dmabuf_fd: 8 frame 04, index: 0, dmabuf_fd: 5 frame 05, index: 1, dmabuf_fd: 6 frame 06, index: 2, dmabuf_fd: 7 frame 07, index: 3, dmabuf_fd: 8 frame 08, index: 0, dmabuf_fd: 5 frame 09, index: 1, dmabuf_fd: 6 read 10 frames done