xilinx_frmbuf.h
- Using the Video Framebuffer API, configure the DMA device with the expected memory format for write
- Prepare an interleaved template describing the buffer location (note: see section DMA Interleaved Template Requirements below for more details)
- Pass the interleaved template to the DMA device using the Linux DMA Engine interface
- With the DMA descriptor which is returned from step 3, add a callback and then submit to the DMA device via the DMA Engine interface
- Start the DMA write operation
- Terminate DMA write operation when frame processing deemed complete by client
/* Abstract V4L2 Client Code Example */ struct dma_chan *frmbuf_dma = to_frmbuf_dma_chan(xdev); struct dma_interleaved_template dma_tmplt; dma_addr_t addr = vb2_dma_contig_plane_dma_addr(vb2_buffer_ptr, 0); u32 flags = DMA_PREP_INTERRUPT | DMA_CTRL_ACK; /* Step 1 - Configure the dma channel to write out packed RGB */ xilinx_xdma_v4l2_config(frmbuf_dma, V4L2_PIX_FMT_RGB24); /* Step 2 - Describe the buffer attributes for a 1080p frame */ dma_tmplt.dir = DMA_DEV_TO_MEM; /* DMA_MEM_TO_DEV */ dma_tmplt.src_sgl = false; dma_tmplt.dst_sgl = true; dma_tmplt.dst_start = addr; dma_tmplt.frame_size = 1; /* single plane pixel format */ dma_tmplt.numf = 1080; /* 1920x1080 frame */ dma_tmplt.sgl[0].size = 5760; /* 3 bytes/pixel x 1920 pixels */ dma_tmplt.sgl[0].icg = 0; /* Step 3 - Submit the buffer description to the dma channel */ desc = dmaengine_prep_interleaved_dma(frmbuf_dma, &&dma_tmplt, flags); desc->callback = dma_complete; desc->callback_param = buf; /* Step 4 - Submit the returned and updated descriptor to the dma channel */ dmaengine_submit(desc); /* Step 5 - Start dma to memory operation */ dma_async_issue_pending(frmbuf_dma); /* Step 6 - Halt DMA when required frame processing completed */ dmaengine_terminate_all(frmbuf_dma);